Subject: Re: [PATCH v8 13/14] net: phy: at803x: configure qca8084 work mode

From: Simon Horman <[email-masked]>
Date: Sun, 17 Dec 2023 13:02:21 +0000

On Fri, Dec 15, 2023 at 03:40:03PM +0800, Luo Jie wrote:

...

> @@ -1038,6 +1045,46 @@ static int qca8084_common_clock_init(struct phy_device *phydev)
>  	return clk_prepare_enable(priv->clk[MDIO_MASTER_AHB_CLK]);
>  }
>  
> +static int qca8084_parse_and_set_work_mode(struct phy_device *phydev)
> +{
> +	struct device_node *node;
> +	struct at803x_priv *priv;
> +	u32 value, work_mode;
> +	int ret;
> +
> +	node = phydev->mdio.dev.of_node;
> +	priv = phydev->priv;

Hi Luo Jie,

a minor nit from my side: priv is set but otherwise unused in this function.

> +
> +	/* The property "qcom,phy-work-mode" is only defined in one
> +	 * PHY device tree node.
> +	 */
> +	ret = of_property_read_u32(node, "qcom,phy-work-mode", &value);
> +	if (ret)
> +		return ret == -EINVAL ? 0 : ret;
> +
> +	switch (value) {
> +	case 0:
> +		work_mode = QCA8084_WORK_MODE_QXGMII;
> +		break;
> +	case 1:
> +		work_mode = QCA8084_WORK_MODE_QXGMII_PORT4_SGMII;
> +		break;
> +	case 2:
> +		work_mode = QCA8084_WORK_MODE_SWITCH;
> +		break;
> +	case 3:
> +		work_mode = QCA8084_WORK_MODE_SWITCH_PORT4_SGMII;
> +		break;
> +	default:
> +		phydev_err(phydev, "invalid qcom,phy-work-mode %d\n", value);
> +		return -EINVAL;
> +	}
> +
> +	return qca8084_mii_modify(phydev, QCA8084_WORK_MODE_CFG,
> +				  QCA8084_WORK_MODE_MASK,
> +				  FIELD_PREP(QCA8084_WORK_MODE_MASK, work_mode));
> +}

...