From: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
To: Mohd Ayaan Anwar <mohd.anwar@oss.qualcomm.com>
Cc: 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>,
Bartosz Golaszewski <brgl@kernel.org>,
linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v2 3/5] phy: qcom: sgmii-eth: select init functions through match data
Date: Fri, 4 Dec 2026 12:07:49 +0100 [thread overview]
Message-ID: <axKfBUNeA1T75DLT@lore-desk> (raw)
In-Reply-To: <20261202-nord_ethernet_serdes-v2-3-95bb41a719c7@oss.qualcomm.com>
[-- Attachment #1: Type: text/plain, Size: 5461 bytes --]
> The current initialization sequences use QMP v5 registers. Adding
> support for a new SerDes generation requires selecting its sequences by
> the compatible.
>
> Store the initial interface and per-rate initializer callbacks in match
> data. Use a selector for validation and calibration, rejecting modes
> without an initializer before accessing registers. This also protects
> calibration invoked directly or through power-on.
>
> Populate the existing SGMII/1000BASE-X and 2500BASE-X initializers for
> SA8775P and retain SGMII as its initial interface. Register programming
> and readiness checks are unchanged.
>
> Signed-off-by: Mohd Ayaan Anwar <mohd.anwar@oss.qualcomm.com>
Hi Mohd,
I think the patch is fine, just few comments inline.
Regards,
Lorenzo
> ---
> drivers/phy/qualcomm/phy-qcom-sgmii-eth.c | 76 ++++++++++++++++++++++---------
> 1 file changed, 55 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/phy/qualcomm/phy-qcom-sgmii-eth.c b/drivers/phy/qualcomm/phy-qcom-sgmii-eth.c
> index 196e9f057387..25e49f2b6824 100644
> --- a/drivers/phy/qualcomm/phy-qcom-sgmii-eth.c
> +++ b/drivers/phy/qualcomm/phy-qcom-sgmii-eth.c
> @@ -34,13 +34,42 @@ static const struct regulator_bulk_data qcom_dwmac_sgmii_phy_vregs[] = {
>
> #define QCOM_SGMII_NUM_SUPPLIES ARRAY_SIZE(qcom_dwmac_sgmii_phy_vregs)
>
> +struct qcom_dwmac_sgmii_phy_match_data {
> + /* Initial interface used before the consumer selects a mode. */
> + phy_interface_t interface;
> + void (*init_1g)(struct regmap *regmap);
> + void (*init_2p5g)(struct regmap *regmap);
> +};
> +
> struct qcom_dwmac_sgmii_phy_data {
> + const struct qcom_dwmac_sgmii_phy_match_data *match_data;
> struct regulator_bulk_data *vregs;
> struct regmap *regmap;
> struct clk *refclk;
> phy_interface_t interface;
> };
>
> +static int
> +qcom_dwmac_sgmii_phy_select_init(const struct qcom_dwmac_sgmii_phy_match_data *match_data,
> + int submode, void (**init)(struct regmap *regmap))
> +{
> + switch (submode) {
> + case PHY_INTERFACE_MODE_SGMII:
> + case PHY_INTERFACE_MODE_1000BASEX:
> + /* 1.25 Gbaud */
> + *init = match_data->init_1g;
> + break;
> + case PHY_INTERFACE_MODE_2500BASEX:
> + /* 3.125 Gbaud */
> + *init = match_data->init_2p5g;
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + return *init ? 0 : -EINVAL;
I guess you can run the function here instead of returning it, right?
> +}
> +
> static void qcom_dwmac_sgmii_phy_init_v5_1g(struct regmap *regmap)
> {
> regmap_write(regmap, QSERDES_PCS + QPHY_PCS_SW_RESET, 0x01);
> @@ -231,20 +260,14 @@ static int qcom_dwmac_sgmii_phy_calibrate(struct phy *phy)
> {
> struct qcom_dwmac_sgmii_phy_data *data = phy_get_drvdata(phy);
> struct device *dev = phy->dev.parent;
> + void (*init)(struct regmap *regmap);
> + int ret;
>
> - switch (data->interface) {
> - case PHY_INTERFACE_MODE_SGMII:
> - case PHY_INTERFACE_MODE_1000BASEX:
> - /* 1.25Gbps mode */
> - qcom_dwmac_sgmii_phy_init_v5_1g(data->regmap);
> - break;
> - case PHY_INTERFACE_MODE_2500BASEX:
> - /* 3.125Gbps mode */
> - qcom_dwmac_sgmii_phy_init_v5_2p5g(data->regmap);
> - break;
> - default:
> - return -EINVAL;
> - }
> + ret = qcom_dwmac_sgmii_phy_select_init(data->match_data, data->interface, &init);
> + if (ret)
> + return ret;
> +
> + init(data->regmap);
>
> if (qcom_dwmac_sgmii_phy_poll_status(data->regmap,
> QSERDES_QMP_PLL + QSERDES_V5_COM_C_READY_STATUS,
> @@ -325,15 +348,13 @@ static int qcom_dwmac_sgmii_phy_validate(struct phy *phy, enum phy_mode mode,
> int submode,
> union phy_configure_opts *opts)
> {
> + struct qcom_dwmac_sgmii_phy_data *data = phy_get_drvdata(phy);
> + void (*init)(struct regmap *regmap);
> +
> if (mode != PHY_MODE_ETHERNET)
> return -EINVAL;
>
> - if (submode == PHY_INTERFACE_MODE_SGMII ||
> - submode == PHY_INTERFACE_MODE_1000BASEX ||
> - submode == PHY_INTERFACE_MODE_2500BASEX)
> - return 0;
> -
> - return -EINVAL;
> + return qcom_dwmac_sgmii_phy_select_init(data->match_data, submode, &init);
Why is it needed here? It seems you are not using the init function pointer,
right?
> }
>
> static int qcom_dwmac_sgmii_phy_set_mode(struct phy *phy, enum phy_mode mode,
> @@ -385,7 +406,11 @@ static int qcom_dwmac_sgmii_phy_probe(struct platform_device *pdev)
> if (!data)
> return -ENOMEM;
>
> - data->interface = PHY_INTERFACE_MODE_SGMII;
> + data->match_data = device_get_match_data(dev);
> + if (!data->match_data)
> + return -EINVAL;
> +
> + data->interface = data->match_data->interface;
>
> base = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(base))
> @@ -419,8 +444,17 @@ static int qcom_dwmac_sgmii_phy_probe(struct platform_device *pdev)
> return 0;
> }
>
> +static const struct qcom_dwmac_sgmii_phy_match_data sa8775p_match_data = {
> + .interface = PHY_INTERFACE_MODE_SGMII,
> + .init_1g = qcom_dwmac_sgmii_phy_init_v5_1g,
> + .init_2p5g = qcom_dwmac_sgmii_phy_init_v5_2p5g,
> +};
> +
> static const struct of_device_id qcom_dwmac_sgmii_phy_of_match[] = {
> - { .compatible = "qcom,sa8775p-dwmac-sgmii-phy" },
> + {
> + .compatible = "qcom,sa8775p-dwmac-sgmii-phy",
> + .data = &sa8775p_match_data,
> + },
> { },
> };
> MODULE_DEVICE_TABLE(of, qcom_dwmac_sgmii_phy_of_match);
>
> --
> 2.34.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-12-04 11:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 19:59 [PATCH v2 0/5] phy: qcom: sgmii-eth: add Nord USXGMII support Mohd Ayaan Anwar
2026-12-01 19:59 ` [PATCH v2 1/5] dt-bindings: phy: qcom,sa8775p-dwmac-sgmii-phy: add Nord compatible Mohd Ayaan Anwar
2026-12-01 19:59 ` [PATCH v2 2/5] phy: qcom: sgmii-eth: rename QMP v5 initialization functions Mohd Ayaan Anwar
2026-12-04 10:57 ` Lorenzo Bianconi
2026-12-01 19:59 ` [PATCH v2 3/5] phy: qcom: sgmii-eth: select init functions through match data Mohd Ayaan Anwar
2026-12-04 11:07 ` Lorenzo Bianconi [this message]
2026-12-01 19:59 ` [PATCH v2 4/5] phy: qcom: sgmii-eth: parameterize readiness register offsets Mohd Ayaan Anwar
2026-12-04 11:10 ` Lorenzo Bianconi
2026-12-01 19:59 ` [PATCH v2 5/5] phy: qcom: sgmii-eth: add Nord USXGMII support Mohd Ayaan Anwar
2026-12-04 11:13 ` Lorenzo Bianconi
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=axKfBUNeA1T75DLT@lore-desk \
--to=lorenzo.bianconi@oss.qualcomm.com \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=mani@kernel.org \
--cc=mohd.anwar@oss.qualcomm.com \
--cc=neil.armstrong@linaro.org \
--cc=robh@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