Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
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 4/5] phy: qcom: sgmii-eth: parameterize readiness register offsets
Date: Fri, 4 Dec 2026 12:10:15 +0100	[thread overview]
Message-ID: <axKfl70roiMLaeY1@lore-desk> (raw)
In-Reply-To: <20261202-nord_ethernet_serdes-v2-4-95bb41a719c7@oss.qualcomm.com>

[-- Attachment #1: Type: text/plain, Size: 5331 bytes --]

> QMP v5 and v7 use different offsets for the COM ready and common-status
> registers, while the Ethernet SerDes readiness checks otherwise match.
> 
> Move the polling sequence into a helper and supply these two offsets
> through match data. Populate the v5 offsets for SA8775P, preserving the
> check order, masks, timeouts and error handling.
> 
> Signed-off-by: Mohd Ayaan Anwar <mohd.anwar@oss.qualcomm.com>

Reviewed-by: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>

> ---
>  drivers/phy/qualcomm/phy-qcom-sgmii-eth.c | 92 +++++++++++++++++--------------
>  1 file changed, 52 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/phy/qualcomm/phy-qcom-sgmii-eth.c b/drivers/phy/qualcomm/phy-qcom-sgmii-eth.c
> index 25e49f2b6824..2aa32870dd69 100644
> --- a/drivers/phy/qualcomm/phy-qcom-sgmii-eth.c
> +++ b/drivers/phy/qualcomm/phy-qcom-sgmii-eth.c
> @@ -39,6 +39,8 @@ struct qcom_dwmac_sgmii_phy_match_data {
>  	phy_interface_t interface;
>  	void (*init_1g)(struct regmap *regmap);
>  	void (*init_2p5g)(struct regmap *regmap);
> +	u32 com_c_ready_status;
> +	u32 com_cmn_status;
>  };
>  
>  struct qcom_dwmac_sgmii_phy_data {
> @@ -49,6 +51,53 @@ struct qcom_dwmac_sgmii_phy_data {
>  	phy_interface_t interface;
>  };
>  
> +static inline int
> +qcom_dwmac_sgmii_phy_poll_status(struct regmap *regmap, unsigned int reg,
> +				 unsigned int bit)
> +{
> +	unsigned int val;
> +
> +	return regmap_read_poll_timeout(regmap, reg, val,
> +					val & bit, 1500, 750000);
> +}
> +
> +static int qcom_dwmac_sgmii_phy_poll_ready(struct phy *phy)
> +{
> +	struct qcom_dwmac_sgmii_phy_data *data = phy_get_drvdata(phy);
> +	const struct qcom_dwmac_sgmii_phy_match_data *match_data = data->match_data;
> +	struct device *dev = phy->dev.parent;
> +
> +	if (qcom_dwmac_sgmii_phy_poll_status(data->regmap,
> +					     QSERDES_QMP_PLL + match_data->com_c_ready_status,
> +					     QSERDES_COM_C_READY)) {
> +		dev_err(dev, "QSERDES_COM_C_READY_STATUS timed-out");
> +		return -ETIMEDOUT;
> +	}
> +
> +	if (qcom_dwmac_sgmii_phy_poll_status(data->regmap,
> +					     QSERDES_PCS + QPHY_PCS_PCS_READY_STATUS,
> +					     QSERDES_PCS_READY)) {
> +		dev_err(dev, "PCS_READY timed-out");
> +		return -ETIMEDOUT;
> +	}
> +
> +	if (qcom_dwmac_sgmii_phy_poll_status(data->regmap,
> +					     QSERDES_PCS + QPHY_PCS_PCS_READY_STATUS,
> +					     QSERDES_PCS_SGMIIPHY_READY)) {
> +		dev_err(dev, "SGMIIPHY_READY timed-out");
> +		return -ETIMEDOUT;
> +	}
> +
> +	if (qcom_dwmac_sgmii_phy_poll_status(data->regmap,
> +					     QSERDES_QMP_PLL + match_data->com_cmn_status,
> +					     QSERDES_COM_C_PLL_LOCKED)) {
> +		dev_err(dev, "PLL Lock Status timed-out");
> +		return -ETIMEDOUT;
> +	}
> +
> +	return 0;
> +}
> +
>  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))
> @@ -246,20 +295,9 @@ static void qcom_dwmac_sgmii_phy_init_v5_2p5g(struct regmap *regmap)
>  	regmap_write(regmap, QSERDES_PCS + QPHY_PCS_PHY_START, 0x01);
>  }
>  
> -static inline int
> -qcom_dwmac_sgmii_phy_poll_status(struct regmap *regmap, unsigned int reg,
> -				 unsigned int bit)
> -{
> -	unsigned int val;
> -
> -	return regmap_read_poll_timeout(regmap, reg, val,
> -					val & bit, 1500, 750000);
> -}
> -
>  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;
>  
> @@ -269,35 +307,7 @@ static int qcom_dwmac_sgmii_phy_calibrate(struct phy *phy)
>  
>  	init(data->regmap);
>  
> -	if (qcom_dwmac_sgmii_phy_poll_status(data->regmap,
> -					     QSERDES_QMP_PLL + QSERDES_V5_COM_C_READY_STATUS,
> -					     QSERDES_COM_C_READY)) {
> -		dev_err(dev, "QSERDES_COM_C_READY_STATUS timed-out");
> -		return -ETIMEDOUT;
> -	}
> -
> -	if (qcom_dwmac_sgmii_phy_poll_status(data->regmap,
> -					     QSERDES_PCS + QPHY_PCS_PCS_READY_STATUS,
> -					     QSERDES_PCS_READY)) {
> -		dev_err(dev, "PCS_READY timed-out");
> -		return -ETIMEDOUT;
> -	}
> -
> -	if (qcom_dwmac_sgmii_phy_poll_status(data->regmap,
> -					     QSERDES_PCS + QPHY_PCS_PCS_READY_STATUS,
> -					     QSERDES_PCS_SGMIIPHY_READY)) {
> -		dev_err(dev, "SGMIIPHY_READY timed-out");
> -		return -ETIMEDOUT;
> -	}
> -
> -	if (qcom_dwmac_sgmii_phy_poll_status(data->regmap,
> -					     QSERDES_QMP_PLL + QSERDES_V5_COM_CMN_STATUS,
> -					     QSERDES_COM_C_PLL_LOCKED)) {
> -		dev_err(dev, "PLL Lock Status timed-out");
> -		return -ETIMEDOUT;
> -	}
> -
> -	return 0;
> +	return qcom_dwmac_sgmii_phy_poll_ready(phy);
>  }
>  
>  static int qcom_dwmac_sgmii_phy_power_on(struct phy *phy)
> @@ -448,6 +458,8 @@ 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,
> +	.com_c_ready_status = QSERDES_V5_COM_C_READY_STATUS,
> +	.com_cmn_status = QSERDES_V5_COM_CMN_STATUS,
>  };
>  
>  static const struct of_device_id qcom_dwmac_sgmii_phy_of_match[] = {
> 
> -- 
> 2.34.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-12-04 11:10 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
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 [this message]
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=axKfl70roiMLaeY1@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