Re: [PATCH] net: designware: rockchip: improve support for multiple gmac instances

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 07, 2022 at 08:16:27AM +0100, Michael Riesch wrote:
> Do not rely on (board-specific) aliases to distinguish between multiple
> (SoC-specific) GMAC instances. Instead, use the base address of the
> controllers as is done in the Linux kernel.
> 
> Signed-off-by: Michael Riesch <michael.riesch@xxxxxxxxxxxxxx>
> ---
>  drivers/net/designware_rockchip.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/net/designware_rockchip.c b/drivers/net/designware_rockchip.c
> index da57ed171..dcf65c9ad 100644
> --- a/drivers/net/designware_rockchip.c
> +++ b/drivers/net/designware_rockchip.c
> @@ -21,6 +21,7 @@ struct rk_gmac_ops {
>  	void (*set_rmii_speed)(struct eqos *eqos, int speed);
>  	void (*set_rgmii_speed)(struct eqos *eqos, int speed);
>  	void (*integrated_phy_powerup)(struct eqos *eqos);
> +	u32 regs[];
>  };
>  
>  struct eqos_rk_gmac {
> @@ -174,6 +175,11 @@ static const struct rk_gmac_ops rk3568_ops = {
>  	.set_to_rmii = rk3568_set_to_rmii,
>  	.set_rmii_speed = rk3568_set_gmac_speed,
>  	.set_rgmii_speed = rk3568_set_gmac_speed,
> +	.regs = {
> +		0xfe2a0000, /* gmac0 */
> +		0xfe010000, /* gmac1 */
> +		0x0, /* sentinel */
> +	},
>  };
>  
>  static int rk_gmac_powerup(struct eqos *eqos)
> @@ -228,7 +234,7 @@ static int eqos_init_rk_gmac(struct device_d *dev, struct eqos *eqos)
>  {
>  	struct device_node *np = dev->device_node;
>  	struct eqos_rk_gmac *priv = to_rk_gmac(eqos);
> -	int ret;
> +	int i = 0, ret;
>  	const char *strings;
>  
>  	priv->dev = dev;
> @@ -247,7 +253,15 @@ static int eqos_init_rk_gmac(struct device_d *dev, struct eqos *eqos)
>  
>  	priv->ops = device_get_match_data(dev);
>  
> -	priv->bus_id = of_alias_get_id(np, "ethernet");
> +	if (dev->num_resources > 0) {
> +		while (priv->ops->regs[i]) {
> +			if (priv->ops->regs[i] == dev->resource[0].start) {
> +				priv->bus_id = i;
> +				break;
> +			}
> +			i++;
> +		}
> +	}
>  
>  	priv->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
>  	if (IS_ERR(priv->grf)) {
> -- 
> 2.30.2
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@xxxxxxxxxxxxxxxxxxx
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux