From: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
To: Vinod Koul <vkoul@kernel.org>,
Neil Armstrong <neil.armstrong@linaro.org>,
Manivannan Sadhasivam <mani@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Wesley Cheng <quic_wcheng@quicinc.com>,
Manu Gautam <mgautam@codeaurora.org>,
Stephen Boyd <sboyd@kernel.org>,
Philipp Zabel <pza@pengutronix.de>
Cc: linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
Subject: [PATCH v2 4/5] phy: qcom: snps-femto-v2: Move PHY init registers to config tables
Date: Tue, 01 Sep 2026 11:34:22 +0530 [thread overview]
Message-ID: <20260901-phy-v2-4-cc93d2f3b1bf@oss.qualcomm.com> (raw)
In-Reply-To: <20260901-phy-v2-0-cc93d2f3b1bf@oss.qualcomm.com>
The driver currently programs the common PHY register sequence directly in
qcom_snps_hsphy_init(), with the fixed register writes split around the
override parameter handling. This makes it hard to support SoCs that need a
different sequence or different values.
Move the fixed pre- and post-override register programming into per-
compatible configuration tables, and keep the 7 nm override parameters in
the same match-data structure. This allows the driver to share the common
sequence while adding SoC-specific sequences for future platforms such as
IPQ9650.
Additionally, address the register bit field mask & value mixup for
USB2_PHY_USB_PHY_REFCLK_CTRL in qcom_snps_hsphy_init() and USB2_AUTO_RESUME
in qcom_snps_hsphy_suspend().
Fixes: 51e8114f80d07 ("phy: qcom-snps: Add SNPS USB PHY driver for QCOM based SOCs")
Fixes: 0d75f508a9d56 ("phy: qcom-snps: Add runtime suspend and resume handlers")
Signed-off-by: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
---
drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c | 126 ++++++++++++++++----------
1 file changed, 79 insertions(+), 47 deletions(-)
diff --git a/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c b/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c
index 980ad1fb1e2e..b6bbf2b570c7 100644
--- a/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c
+++ b/drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c
@@ -104,6 +104,20 @@ struct phy_override_seq {
u8 mask;
};
+struct phy_reg_config {
+ u32 offset;
+ u32 mask;
+ u32 val;
+};
+
+struct phy_config_data {
+ const struct phy_reg_config *pre_tuning;
+ const struct override_param_map *override;
+ const struct phy_reg_config *post_tuning;
+ const u32 num_pre_tuning;
+ const u32 num_post_tuning;
+};
+
#define NUM_HSPHY_TUNING_PARAMS (9)
/**
@@ -193,7 +207,7 @@ static int qcom_snps_hsphy_suspend(struct qcom_snps_hsphy *hsphy)
usleep_range(500, 1000);
qcom_snps_hsphy_write_mask(hsphy->base,
USB2_PHY_USB_PHY_HS_PHY_CTRL2,
- 0, USB2_AUTO_RESUME);
+ USB2_AUTO_RESUME, 0);
}
return 0;
@@ -383,13 +397,40 @@ static const struct override_param_map sc7280_snps_7nm_phy[] = {
{},
};
+static const struct phy_reg_config hs_5nm_phy_pre_tuning[] = {
+ { USB2_PHY_USB_PHY_CFG0, UTMI_PHY_CMN_CTRL_OVERRIDE_EN, UTMI_PHY_CMN_CTRL_OVERRIDE_EN },
+ { USB2_PHY_USB_PHY_UTMI_CTRL5, POR, POR },
+ { USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0, FSEL_MASK, 0 },
+ { USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1, PLLBTUNE, PLLBTUNE },
+ { USB2_PHY_USB_PHY_REFCLK_CTRL, REFCLK_SEL_MASK, REFCLK_SEL_DEFAULT },
+ { USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1, VBUSVLDEXTSEL0, VBUSVLDEXTSEL0 },
+ { USB2_PHY_USB_PHY_HS_PHY_CTRL1, VBUSVLDEXT0, VBUSVLDEXT0 },
+};
+
+static const struct phy_reg_config hs_5nm_phy_post_tuning[] = {
+ { USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON2, VREGBYPASS, VREGBYPASS },
+ { USB2_PHY_USB_PHY_HS_PHY_CTRL2, USB2_SUSPEND_N_SEL | USB2_SUSPEND_N,
+ USB2_SUSPEND_N_SEL | USB2_SUSPEND_N },
+ { USB2_PHY_USB_PHY_UTMI_CTRL0, SLEEPM, SLEEPM },
+ { USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0, SIDDQ, 0 },
+ { USB2_PHY_USB_PHY_UTMI_CTRL5, POR, 0 },
+ { USB2_PHY_USB_PHY_HS_PHY_CTRL2, USB2_SUSPEND_N_SEL, 0 },
+ { USB2_PHY_USB_PHY_CFG0, UTMI_PHY_CMN_CTRL_OVERRIDE_EN, 0 },
+};
+
static int qcom_snps_hsphy_init(struct phy *phy)
{
struct qcom_snps_hsphy *hsphy = phy_get_drvdata(phy);
+ const struct phy_config_data *data;
+ const struct phy_reg_config *tmp;
int ret, i;
dev_vdbg(&phy->dev, "%s(): Initializing SNPS HS phy\n", __func__);
+ data = of_device_get_match_data(hsphy->dev);
+ if (!data)
+ return -ENODEV;
+
ret = regulator_bulk_enable(ARRAY_SIZE(hsphy->vregs), hsphy->vregs);
if (ret)
return ret;
@@ -414,24 +455,8 @@ static int qcom_snps_hsphy_init(struct phy *phy)
goto disable_clks;
}
- qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_CFG0,
- UTMI_PHY_CMN_CTRL_OVERRIDE_EN,
- UTMI_PHY_CMN_CTRL_OVERRIDE_EN);
- qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_UTMI_CTRL5,
- POR, POR);
- qcom_snps_hsphy_write_mask(hsphy->base,
- USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0,
- FSEL_MASK, 0);
- qcom_snps_hsphy_write_mask(hsphy->base,
- USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1,
- PLLBTUNE, PLLBTUNE);
- qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_REFCLK_CTRL,
- REFCLK_SEL_DEFAULT, REFCLK_SEL_MASK);
- qcom_snps_hsphy_write_mask(hsphy->base,
- USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON1,
- VBUSVLDEXTSEL0, VBUSVLDEXTSEL0);
- qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_HS_PHY_CTRL1,
- VBUSVLDEXT0, VBUSVLDEXT0);
+ for (tmp = data->pre_tuning, i = 0; i < data->num_pre_tuning; i++, tmp++)
+ qcom_snps_hsphy_write_mask(hsphy->base, tmp->offset, tmp->mask, tmp->val);
for (i = 0; i < ARRAY_SIZE(hsphy->update_seq_cfg); i++) {
if (hsphy->update_seq_cfg[i].need_update)
@@ -441,28 +466,8 @@ static int qcom_snps_hsphy_init(struct phy *phy)
hsphy->update_seq_cfg[i].value);
}
- qcom_snps_hsphy_write_mask(hsphy->base,
- USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON2,
- VREGBYPASS, VREGBYPASS);
-
- qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_HS_PHY_CTRL2,
- USB2_SUSPEND_N_SEL | USB2_SUSPEND_N,
- USB2_SUSPEND_N_SEL | USB2_SUSPEND_N);
-
- qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_UTMI_CTRL0,
- SLEEPM, SLEEPM);
-
- qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0,
- SIDDQ, 0);
-
- qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_UTMI_CTRL5,
- POR, 0);
-
- qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_HS_PHY_CTRL2,
- USB2_SUSPEND_N_SEL, 0);
-
- qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_CFG0,
- UTMI_PHY_CMN_CTRL_OVERRIDE_EN, 0);
+ for (tmp = data->post_tuning, i = 0; i < data->num_post_tuning; i++, tmp++)
+ qcom_snps_hsphy_write_mask(hsphy->base, tmp->offset, tmp->mask, tmp->val);
hsphy->phy_initialized = true;
@@ -495,14 +500,38 @@ static const struct phy_ops qcom_snps_hsphy_gen_ops = {
.owner = THIS_MODULE,
};
+static const struct phy_config_data hs_5nm_phy = {
+ .pre_tuning = hs_5nm_phy_pre_tuning,
+ .num_pre_tuning = ARRAY_SIZE(hs_5nm_phy_pre_tuning),
+ .post_tuning = hs_5nm_phy_post_tuning,
+ .num_post_tuning = ARRAY_SIZE(hs_5nm_phy_post_tuning),
+};
+
+static const struct phy_config_data hs_7nm_phy = {
+ .pre_tuning = hs_5nm_phy_pre_tuning,
+ .num_pre_tuning = ARRAY_SIZE(hs_5nm_phy_pre_tuning),
+ .override = sc7280_snps_7nm_phy,
+ .post_tuning = hs_5nm_phy_post_tuning,
+ .num_post_tuning = ARRAY_SIZE(hs_5nm_phy_post_tuning),
+};
+
static const struct of_device_id qcom_snps_hsphy_of_match_table[] = {
- { .compatible = "qcom,sm8150-usb-hs-phy", },
- { .compatible = "qcom,usb-snps-hs-5nm-phy", },
+ {
+ .compatible = "qcom,sm8150-usb-hs-phy",
+ .data = &hs_5nm_phy,
+ },
+ {
+ .compatible = "qcom,usb-snps-hs-5nm-phy",
+ .data = &hs_5nm_phy,
+ },
{
.compatible = "qcom,usb-snps-hs-7nm-phy",
- .data = &sc7280_snps_7nm_phy,
+ .data = &hs_7nm_phy,
+ },
+ {
+ .compatible = "qcom,usb-snps-femto-v2-phy",
+ .data = &hs_5nm_phy,
},
- { .compatible = "qcom,usb-snps-femto-v2-phy", },
{ }
};
MODULE_DEVICE_TABLE(of, qcom_snps_hsphy_of_match_table);
@@ -541,11 +570,14 @@ static void qcom_snps_hsphy_read_override_param_seq(struct device *dev)
s32 val;
int ret, i;
struct qcom_snps_hsphy *hsphy;
- const struct override_param_map *cfg = of_device_get_match_data(dev);
+ const struct phy_config_data *data = of_device_get_match_data(dev);
+ const struct override_param_map *cfg;
- if (!cfg)
+ if (!data || !data->override)
return;
+ cfg = data->override;
+
hsphy = dev_get_drvdata(dev);
for (i = 0; cfg[i].prop_name != NULL; i++) {
--
2.34.1
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-09-01 6:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 6:04 [PATCH v2 0/5] Add support for USB phys in IPQ9650 Varadarajan Narayanan
2026-09-01 6:04 ` [PATCH v2 1/5] dt-bindings: phy: qcom,qmp-usb: Add IPQ9650 USB3 PHY Varadarajan Narayanan
2026-09-01 6:04 ` [PATCH v2 2/5] dt-bindings: phy: qcom,usb-snps-femto-v2: Add IPQ9650 compatible Varadarajan Narayanan
2026-09-03 10:21 ` Krzysztof Kozlowski
2026-09-01 6:04 ` [PATCH v2 3/5] phy: qcom: qmp-usb: Add IPQ9650 USB3 PHY configuration Varadarajan Narayanan
2026-09-03 10:25 ` Abel Vesa
2026-09-01 6:04 ` Varadarajan Narayanan [this message]
2026-09-01 6:04 ` [PATCH v2 5/5] phy: qcom: snps-femto-v2: Add IPQ9650 support Varadarajan Narayanan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260901-phy-v2-4-cc93d2f3b1bf@oss.qualcomm.com \
--to=varadarajan.narayanan@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=mani@kernel.org \
--cc=mgautam@codeaurora.org \
--cc=neil.armstrong@linaro.org \
--cc=pza@pengutronix.de \
--cc=quic_wcheng@quicinc.com \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox