[U-Boot] [PATCH 3/6] net: ti: cpsw: add support for standard eth "max-speed" dt property

Grygorii Strashko grygorii.strashko at ti.com
Mon Sep 16 09:42:59 UTC 2019



On 09/09/2019 18:00, Grygorii Strashko wrote:
> This patch adds support for standard Ethernet "max-speed" DT property to
> allow PHY link speed limitation.

This patch by itself will break network boot (see below).
But with whole series issue will not be reproducible, because it's
implicitly fixed by patch 6.

I'll send v2.

> 
> Signed-off-by: Grygorii Strashko <grygorii.strashko at ti.com>
> ---
>   drivers/net/ti/cpsw.c | 14 ++++++++++++++
>   include/cpsw.h        |  1 +
>   2 files changed, 15 insertions(+)
> 
> diff --git a/drivers/net/ti/cpsw.c b/drivers/net/ti/cpsw.c
> index 533c167995..af4db89341 100644
> --- a/drivers/net/ti/cpsw.c
> +++ b/drivers/net/ti/cpsw.c
> @@ -839,6 +839,7 @@ static int cpsw_phy_init(struct cpsw_priv *priv, struct cpsw_slave *slave)
>   {
>   	struct phy_device *phydev;
>   	u32 supported = PHY_GBIT_FEATURES;
> +	int ret;
>   
>   	phydev = phy_connect(priv->bus,
>   			slave->data->phy_addr,
> @@ -849,6 +850,13 @@ static int cpsw_phy_init(struct cpsw_priv *priv, struct cpsw_slave *slave)
>   		return -1;
>   
>   	phydev->supported &= supported;
> +	if (slave->data->max_speed) {
> +		ret = phy_set_supported(phydev, slave->data->max_speed);
> +		if (ret)
> +			return ret;
> +		dev_dbg(priv->dev, "Port %u speed forced to %uMbit\n",
> +			slave->slave_num + 1, slave->data->max_speed);
> +	}
>   	phydev->advertising = phydev->supported;
>   
>   #ifdef CONFIG_DM_ETH
> @@ -1185,6 +1193,7 @@ static void cpsw_eth_of_parse_slave(struct cpsw_platform_data *data,
>   	struct cpsw_slave_data	*slave_data;
>   	const void *fdt = gd->fdt_blob;
>   	const char *phy_mode;
> +	int max_speed = -1;
>   	u32 phy_id[2];
>   
>   	slave_data = &data->slave_data[slave_index];
> @@ -1206,6 +1215,11 @@ static void cpsw_eth_of_parse_slave(struct cpsw_platform_data *data,
>   				     phy_id, 2);
>   		slave_data->phy_addr = phy_id[1];
>   	}
> +

slave_data->max_speed has to be reset to 0 here.

> +	max_speed = fdtdec_get_int(fdt, subnode,
> +				   "max-speed", max_speed);
> +	if (max_speed > 0)
> +		slave_data->max_speed = max_speed;
>   }
>   


-- 
Best regards,
grygorii


More information about the U-Boot mailing list