From nobody Wed Apr 8 07:59:17 2026 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 899B1ECDFA1 for ; Mon, 24 Oct 2022 09:02:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231137AbiJXJC2 (ORCPT ); Mon, 24 Oct 2022 05:02:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229613AbiJXJBm (ORCPT ); Mon, 24 Oct 2022 05:01:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22CF227CD8; Mon, 24 Oct 2022 02:01:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id ADE42B80FC9; Mon, 24 Oct 2022 09:01:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAA8DC4347C; Mon, 24 Oct 2022 09:01:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666602097; bh=XfrhZZ3hdURm8ajGKt9NS2MAtDQc+KzKurmU2+Tfeyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eNspZSZecXgQUmn8Zwgwx9XYXoY1InofeQu7HDGa9EpGPRKQGwm0apmG4hLL7w5TT 4kQtFjv6txcDuJhMGWtgrQ+ooek/DvoRNY9bVIcVpG8mAtFvWm3MWtvQkLhj3uhlti XujkM/GEAWqmaiFjvC3UpDqT1IqcaIN0wVxaitEiQLIam55dKfJXuACpW57bGve1sW NzaESSVdmVoRkNnrCMx/anGuvwZLGB5jilU3grNDHJTyqsDG+oycUxPJ97IYTgywNV 1gPWRl619ZYYIhJxQoR85YpTmR1U9i1CwBolrQBmIF13wjz4Yem2PyT3x9usMHJo+g JMJuGWjwd5veg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1omtKj-00056P-3y; Mon, 24 Oct 2022 11:01:21 +0200 From: Johan Hovold To: Vinod Koul Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Dmitry Baryshkov , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 02/10] phy: qcom-qmp-ufs: merge driver data Date: Mon, 24 Oct 2022 11:00:33 +0200 Message-Id: <20221024090041.19574-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221024090041.19574-1-johan+linaro@kernel.org> References: <20221024090041.19574-1-johan+linaro@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The UFS QMP PHY driver only manages a single PHY so merge the old qcom_qmp and qmp_phy structures and drop the PHY array. Signed-off-by: Johan Hovold Reviewed-by: Dmitry Baryshkov --- drivers/phy/qualcomm/phy-qcom-qmp-ufs.c | 171 +++++++++--------------- 1 file changed, 63 insertions(+), 108 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c b/drivers/phy/qualcomm= /phy-qcom-qmp-ufs.c index acb8efa1d758..b4c3b3d97f52 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c @@ -548,54 +548,24 @@ struct qmp_phy_cfg { bool no_pcs_sw_reset; }; =20 -/** - * struct qmp_phy - per-lane phy descriptor - * - * @phy: generic phy - * @cfg: phy specific configuration - * @serdes: iomapped memory space for phy's serdes (i.e. PLL) - * @tx: iomapped memory space for lane's tx - * @rx: iomapped memory space for lane's rx - * @pcs: iomapped memory space for lane's pcs - * @tx2: iomapped memory space for second lane's tx (in dual lane PHYs) - * @rx2: iomapped memory space for second lane's rx (in dual lane PHYs) - * @pcs_misc: iomapped memory space for lane's pcs_misc - * @qmp: QMP phy to which this lane belongs - */ -struct qmp_phy { - struct phy *phy; +struct qmp_ufs { + struct device *dev; + const struct qmp_phy_cfg *cfg; + void __iomem *serdes; + void __iomem *pcs; + void __iomem *pcs_misc; void __iomem *tx; void __iomem *rx; - void __iomem *pcs; void __iomem *tx2; void __iomem *rx2; - void __iomem *pcs_misc; - struct qcom_qmp *qmp; -}; - -/** - * struct qcom_qmp - structure holding QMP phy block attributes - * - * @dev: device - * - * @clks: array of clocks required by phy - * @resets: array of resets required by phy - * @vregs: regulator supplies bulk data - * - * @phys: array of per-lane phy descriptors - * @ufs_reset: optional UFS PHY reset handle - */ -struct qcom_qmp { - struct device *dev; =20 struct clk_bulk_data *clks; struct regulator_bulk_data *vregs; - - struct qmp_phy **phys; - struct reset_control *ufs_reset; + + struct phy *phy; }; =20 static inline void qphy_setbits(void __iomem *base, u32 offset, u32 val) @@ -782,10 +752,10 @@ static void qmp_ufs_configure(void __iomem *base, qmp_ufs_configure_lane(base, tbl, num, 0xff); } =20 -static int qmp_ufs_serdes_init(struct qmp_phy *qphy) +static int qmp_ufs_serdes_init(struct qmp_ufs *qmp) { - const struct qmp_phy_cfg *cfg =3D qphy->cfg; - void __iomem *serdes =3D qphy->serdes; + const struct qmp_phy_cfg *cfg =3D qmp->cfg; + void __iomem *serdes =3D qmp->serdes; const struct qmp_phy_init_tbl *serdes_tbl =3D cfg->serdes_tbl; int serdes_tbl_num =3D cfg->serdes_tbl_num; =20 @@ -794,11 +764,10 @@ static int qmp_ufs_serdes_init(struct qmp_phy *qphy) return 0; } =20 -static int qmp_ufs_com_init(struct qmp_phy *qphy) +static int qmp_ufs_com_init(struct qmp_ufs *qmp) { - struct qcom_qmp *qmp =3D qphy->qmp; - const struct qmp_phy_cfg *cfg =3D qphy->cfg; - void __iomem *pcs =3D qphy->pcs; + const struct qmp_phy_cfg *cfg =3D qmp->cfg; + void __iomem *pcs =3D qmp->pcs; int ret; =20 ret =3D regulator_bulk_enable(cfg->num_vregs, qmp->vregs); @@ -821,10 +790,9 @@ static int qmp_ufs_com_init(struct qmp_phy *qphy) return ret; } =20 -static int qmp_ufs_com_exit(struct qmp_phy *qphy) +static int qmp_ufs_com_exit(struct qmp_ufs *qmp) { - struct qcom_qmp *qmp =3D qphy->qmp; - const struct qmp_phy_cfg *cfg =3D qphy->cfg; + const struct qmp_phy_cfg *cfg =3D qmp->cfg; =20 reset_control_assert(qmp->ufs_reset); =20 @@ -837,9 +805,8 @@ static int qmp_ufs_com_exit(struct qmp_phy *qphy) =20 static int qmp_ufs_init(struct phy *phy) { - struct qmp_phy *qphy =3D phy_get_drvdata(phy); - struct qcom_qmp *qmp =3D qphy->qmp; - const struct qmp_phy_cfg *cfg =3D qphy->cfg; + struct qmp_ufs *qmp =3D phy_get_drvdata(phy); + const struct qmp_phy_cfg *cfg =3D qmp->cfg; int ret; dev_vdbg(qmp->dev, "Initializing QMP phy\n"); =20 @@ -870,7 +837,7 @@ static int qmp_ufs_init(struct phy *phy) return ret; } =20 - ret =3D qmp_ufs_com_init(qphy); + ret =3D qmp_ufs_com_init(qmp); if (ret) return ret; =20 @@ -879,28 +846,27 @@ static int qmp_ufs_init(struct phy *phy) =20 static int qmp_ufs_power_on(struct phy *phy) { - struct qmp_phy *qphy =3D phy_get_drvdata(phy); - struct qcom_qmp *qmp =3D qphy->qmp; - const struct qmp_phy_cfg *cfg =3D qphy->cfg; - void __iomem *tx =3D qphy->tx; - void __iomem *rx =3D qphy->rx; - void __iomem *pcs =3D qphy->pcs; + struct qmp_ufs *qmp =3D phy_get_drvdata(phy); + const struct qmp_phy_cfg *cfg =3D qmp->cfg; + void __iomem *tx =3D qmp->tx; + void __iomem *rx =3D qmp->rx; + void __iomem *pcs =3D qmp->pcs; void __iomem *status; unsigned int val; int ret; =20 - qmp_ufs_serdes_init(qphy); + qmp_ufs_serdes_init(qmp); =20 /* Tx, Rx, and PCS configurations */ qmp_ufs_configure_lane(tx, cfg->tx_tbl, cfg->tx_tbl_num, 1); =20 if (cfg->lanes >=3D 2) - qmp_ufs_configure_lane(qphy->tx2, cfg->tx_tbl, cfg->tx_tbl_num, 2); + qmp_ufs_configure_lane(qmp->tx2, cfg->tx_tbl, cfg->tx_tbl_num, 2); =20 qmp_ufs_configure_lane(rx, cfg->rx_tbl, cfg->rx_tbl_num, 1); =20 if (cfg->lanes >=3D 2) - qmp_ufs_configure_lane(qphy->rx2, cfg->rx_tbl, cfg->rx_tbl_num, 2); + qmp_ufs_configure_lane(qmp->rx2, cfg->rx_tbl, cfg->rx_tbl_num, 2); =20 qmp_ufs_configure(pcs, cfg->pcs_tbl, cfg->pcs_tbl_num); =20 @@ -928,18 +894,18 @@ static int qmp_ufs_power_on(struct phy *phy) =20 static int qmp_ufs_power_off(struct phy *phy) { - struct qmp_phy *qphy =3D phy_get_drvdata(phy); - const struct qmp_phy_cfg *cfg =3D qphy->cfg; + struct qmp_ufs *qmp =3D phy_get_drvdata(phy); + const struct qmp_phy_cfg *cfg =3D qmp->cfg; =20 /* PHY reset */ if (!cfg->no_pcs_sw_reset) - qphy_setbits(qphy->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); + qphy_setbits(qmp->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); =20 /* stop SerDes */ - qphy_clrbits(qphy->pcs, cfg->regs[QPHY_START_CTRL], SERDES_START); + qphy_clrbits(qmp->pcs, cfg->regs[QPHY_START_CTRL], SERDES_START); =20 /* Put PHY into POWER DOWN state: active low */ - qphy_clrbits(qphy->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], + qphy_clrbits(qmp->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], SW_PWRDN); =20 return 0; @@ -947,9 +913,9 @@ static int qmp_ufs_power_off(struct phy *phy) =20 static int qmp_ufs_exit(struct phy *phy) { - struct qmp_phy *qphy =3D phy_get_drvdata(phy); + struct qmp_ufs *qmp =3D phy_get_drvdata(phy); =20 - qmp_ufs_com_exit(qphy); + qmp_ufs_com_exit(qmp); =20 return 0; } @@ -981,7 +947,7 @@ static int qmp_ufs_disable(struct phy *phy) =20 static int qmp_ufs_vreg_init(struct device *dev, const struct qmp_phy_cfg = *cfg) { - struct qcom_qmp *qmp =3D dev_get_drvdata(dev); + struct qmp_ufs *qmp =3D dev_get_drvdata(dev); int num =3D cfg->num_vregs; int i; =20 @@ -997,7 +963,7 @@ static int qmp_ufs_vreg_init(struct device *dev, const = struct qmp_phy_cfg *cfg) =20 static int qmp_ufs_clk_init(struct device *dev, const struct qmp_phy_cfg *= cfg) { - struct qcom_qmp *qmp =3D dev_get_drvdata(dev); + struct qmp_ufs *qmp =3D dev_get_drvdata(dev); int num =3D cfg->num_clks; int i; =20 @@ -1017,78 +983,71 @@ static const struct phy_ops qcom_qmp_ufs_ops =3D { .owner =3D THIS_MODULE, }; =20 -static int qmp_ufs_create(struct device *dev, struct device_node *np, int = id, +static int qmp_ufs_create(struct device *dev, struct device_node *np, void __iomem *serdes, const struct qmp_phy_cfg *cfg) { - struct qcom_qmp *qmp =3D dev_get_drvdata(dev); + struct qmp_ufs *qmp =3D dev_get_drvdata(dev); struct phy *generic_phy; - struct qmp_phy *qphy; int ret; =20 - qphy =3D devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); - if (!qphy) - return -ENOMEM; - - qphy->cfg =3D cfg; - qphy->serdes =3D serdes; + qmp->cfg =3D cfg; + qmp->serdes =3D serdes; /* * Get memory resources for the PHY: * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 * For single lane PHYs: pcs_misc (optional) -> 3. */ - qphy->tx =3D devm_of_iomap(dev, np, 0, NULL); - if (IS_ERR(qphy->tx)) - return PTR_ERR(qphy->tx); + qmp->tx =3D devm_of_iomap(dev, np, 0, NULL); + if (IS_ERR(qmp->tx)) + return PTR_ERR(qmp->tx); =20 - qphy->rx =3D devm_of_iomap(dev, np, 1, NULL); - if (IS_ERR(qphy->rx)) - return PTR_ERR(qphy->rx); + qmp->rx =3D devm_of_iomap(dev, np, 1, NULL); + if (IS_ERR(qmp->rx)) + return PTR_ERR(qmp->rx); =20 - qphy->pcs =3D devm_of_iomap(dev, np, 2, NULL); - if (IS_ERR(qphy->pcs)) - return PTR_ERR(qphy->pcs); + qmp->pcs =3D devm_of_iomap(dev, np, 2, NULL); + if (IS_ERR(qmp->pcs)) + return PTR_ERR(qmp->pcs); =20 if (cfg->lanes >=3D 2) { - qphy->tx2 =3D devm_of_iomap(dev, np, 3, NULL); - if (IS_ERR(qphy->tx2)) - return PTR_ERR(qphy->tx2); + qmp->tx2 =3D devm_of_iomap(dev, np, 3, NULL); + if (IS_ERR(qmp->tx2)) + return PTR_ERR(qmp->tx2); =20 - qphy->rx2 =3D devm_of_iomap(dev, np, 4, NULL); - if (IS_ERR(qphy->rx2)) - return PTR_ERR(qphy->rx2); + qmp->rx2 =3D devm_of_iomap(dev, np, 4, NULL); + if (IS_ERR(qmp->rx2)) + return PTR_ERR(qmp->rx2); =20 - qphy->pcs_misc =3D devm_of_iomap(dev, np, 5, NULL); + qmp->pcs_misc =3D devm_of_iomap(dev, np, 5, NULL); } else { - qphy->pcs_misc =3D devm_of_iomap(dev, np, 3, NULL); + qmp->pcs_misc =3D devm_of_iomap(dev, np, 3, NULL); } =20 - if (IS_ERR(qphy->pcs_misc)) + if (IS_ERR(qmp->pcs_misc)) dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); =20 generic_phy =3D devm_phy_create(dev, np, &qcom_qmp_ufs_ops); if (IS_ERR(generic_phy)) { ret =3D PTR_ERR(generic_phy); - dev_err(dev, "failed to create qphy %d\n", ret); + dev_err(dev, "failed to create PHY: %d\n", ret); return ret; } =20 - qphy->phy =3D generic_phy; - qphy->qmp =3D qmp; - qmp->phys[id] =3D qphy; - phy_set_drvdata(generic_phy, qphy); + qmp->phy =3D generic_phy; + phy_set_drvdata(generic_phy, qmp); =20 return 0; } =20 static int qmp_ufs_probe(struct platform_device *pdev) { - struct qcom_qmp *qmp; struct device *dev =3D &pdev->dev; struct device_node *child; struct phy_provider *phy_provider; void __iomem *serdes; const struct qmp_phy_cfg *cfg =3D NULL; + struct qmp_ufs *qmp; int num, id; int ret; =20 @@ -1120,14 +1079,10 @@ static int qmp_ufs_probe(struct platform_device *pd= ev) if (num > 1) return -EINVAL; =20 - qmp->phys =3D devm_kcalloc(dev, num, sizeof(*qmp->phys), GFP_KERNEL); - if (!qmp->phys) - return -ENOMEM; - id =3D 0; for_each_available_child_of_node(dev->of_node, child) { /* Create per-lane phy */ - ret =3D qmp_ufs_create(dev, child, id, serdes, cfg); + ret =3D qmp_ufs_create(dev, child, serdes, cfg); if (ret) { dev_err(dev, "failed to create lane%d phy, %d\n", id, ret); --=20 2.37.3