From patchwork Wed Nov 23 10:42:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 627976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83998C4708C for ; Wed, 23 Nov 2022 10:54:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236817AbiKWKyk (ORCPT ); Wed, 23 Nov 2022 05:54:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236713AbiKWKyM (ORCPT ); Wed, 23 Nov 2022 05:54:12 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DD62133941 for ; Wed, 23 Nov 2022 02:42:20 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id b3so27563498lfv.2 for ; Wed, 23 Nov 2022 02:42:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=y93JMbDS7TCZqUPnYPX61/7g1utQYXApLn3dq22TrxU=; b=GYYeZpi/JBdpolSjWg8MPg8EOJhxUlIoNFxzQLIoZmAdMr92nZhJ+C13nQHT9sgERX ZeOCh2GX1f19L417t8b3FCx54ygqTIeYkLvhHBKgayaGSULqeCCAgJd5b//6t+ox1EL/ 8ghnBmO+QZrOfjCuozwmmPv4T5qsFsb9VsixDMDyvGJtu+7hrv+lBLa7NTvb+nMOnbXA 2lEoyFVEq0yQ698sIoQGpzuYFxa6nxGHwutUc5hkR6FcfTfPXqSa/dozSFA08EalKMXN GtonyBjXvaRNJXELetmV18iv25Cp0EFd6PAw/Scfex9o6/3IKuiVpoo5e6sYZ4jEdMBa rwog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y93JMbDS7TCZqUPnYPX61/7g1utQYXApLn3dq22TrxU=; b=hm971+srcO01gr4LSRfKeU+RtMGx7dGRHto8THrDjImpGibsQDQUf8KizG/DIromhA KM7FjhP+kafMPNwswsDdQ7+E8/82hUiPQqZgyT4Z/Aw8c4TYt8swbgJmCjx0IT5OORBl Mlg98X2oHLYgYSXbEQeRROytdaeMUPLmxuf2WybMw7rMZkDxDGtXo+eUyiqP3fgRx1nr Cwx5jBmMSno4gu32CSGG5jDCC1zMAAueNiRbATMQ6nir/Tlr8Nso0m8iiyvTyh8CS6lR +k0Lz2qrLy/TItIbV9W7Hdqezx7fZqunPsNQYK4tXezmzzrnXVbt1k8A6XkZFk/nx6cE OvYg== X-Gm-Message-State: ANoB5pmitvNhXOufdl94lAC+7b+JEuMgmcme2kUu73aARTBMAgMyKjyL udFl2SeTBwiEYycJGxUUOJI7Dw== X-Google-Smtp-Source: AA0mqf5rDVfpAq3LaO8lx02Cx7o/wDWgvx2Reqy56WpYBBRnJzGTTEMOSpNLLRfqFvu1sFxVu2DDAg== X-Received: by 2002:a05:6512:2814:b0:4b1:b7a0:aa69 with SMTP id cf20-20020a056512281400b004b1b7a0aa69mr4435162lfb.239.1669200139324; Wed, 23 Nov 2022 02:42:19 -0800 (PST) Received: from eriador.lumag.spb.ru (dzpbg0ftyyyyyyyyyyyyt-3.rev.dnainternet.fi. [2001:14ba:a302:5f12::1]) by smtp.gmail.com with ESMTPSA id n5-20020a05651203e500b00498f570aef2sm2862908lfq.209.2022.11.23.02.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 02:42:18 -0800 (PST) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski Cc: Johan Hovold , Philipp Zabel , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org Subject: [PATCH v8 4/4] phy: qcom-qmp-ufs: provide symbol clocks Date: Wed, 23 Nov 2022 12:42:15 +0200 Message-Id: <20221123104215.3414528-5-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221123104215.3414528-1-dmitry.baryshkov@linaro.org> References: <20221123104215.3414528-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Register three UFS symbol clocks (ufs_rx_symbol_0_clk_src, ufs_rx_symbol_1_clk_src ufs_tx_symbol_0_clk_src). Register OF clock provider to let other devices link these clocks through the DT. Signed-off-by: Dmitry Baryshkov --- drivers/phy/qualcomm/phy-qcom-qmp-ufs.c | 64 +++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c index 189103d1bd18..78d7daf34667 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c @@ -1023,6 +1023,66 @@ static int qmp_ufs_clk_init(struct qmp_ufs *qmp) return devm_clk_bulk_get(dev, num, qmp->clks); } +static void phy_clk_release_provider(void *res) +{ + of_clk_del_provider(res); +} + +#define UFS_SYMBOL_CLOCKS 3 + +static int phy_symbols_clk_register(struct qmp_ufs *qmp, struct device_node *np) +{ + struct clk_hw_onecell_data *clk_data; + struct clk_hw *hw; + char name[64]; + int ret; + + clk_data = devm_kzalloc(qmp->dev, + struct_size(clk_data, hws, UFS_SYMBOL_CLOCKS), + GFP_KERNEL); + if (!clk_data) + return -ENOMEM; + + clk_data->num = UFS_SYMBOL_CLOCKS; + + snprintf(name, sizeof(name), "%s::rx_symbol_0", dev_name(qmp->dev)); + hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); + if (IS_ERR(hw)) + return PTR_ERR(hw); + + clk_data->hws[0] = hw; + + snprintf(name, sizeof(name), "%s::rx_symbol_1", dev_name(qmp->dev)); + hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); + if (IS_ERR(hw)) + return PTR_ERR(hw); + + clk_data->hws[1] = hw; + + snprintf(name, sizeof(name), "%s::tx_symbol_0", dev_name(qmp->dev)); + hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); + if (IS_ERR(hw)) + return PTR_ERR(hw); + + clk_data->hws[2] = hw; + + ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_data); + if (ret) + return ret; + + /* + * Roll a devm action because the clock provider is the child node, but + * the child node is not actually a device. + */ + return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np); +} + +static const struct phy_ops qcom_qmp_ufs_ops = { + .power_on = qmp_ufs_enable, + .power_off = qmp_ufs_disable, + .owner = THIS_MODULE, +}; + static int qmp_ufs_parse_dt_legacy(struct qmp_ufs *qmp, struct device_node *np) { struct platform_device *pdev = to_platform_device(qmp->dev); @@ -1135,6 +1195,10 @@ static int qmp_ufs_probe(struct platform_device *pdev) if (ret) goto err_node_put; + ret = phy_symbols_clk_register(qmp, np); + if (ret) + goto err_node_put; + qmp->phy = devm_phy_create(dev, np, &qcom_qmp_ufs_phy_ops); if (IS_ERR(qmp->phy)) { ret = PTR_ERR(qmp->phy);