[RFC] net: dm9k: add device tree support

Sascha Hauer s.hauer at pengutronix.de
Wed Sep 10 23:23:38 PDT 2014


On Wed, Sep 10, 2014 at 11:53:48AM +0400, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
> ---
>  drivers/net/dm9k.c | 46 +++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 39 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/dm9k.c b/drivers/net/dm9k.c
> index e525a84..9e7b415 100644
> --- a/drivers/net/dm9k.c
> +++ b/drivers/net/dm9k.c
> @@ -707,16 +707,30 @@ static int dm9k_init_dev(struct eth_device *edev)
>  	return 0;
>  }
>  
> +static struct dm9000_platform_data *dm9000_parse_dt(struct device_d *dev)
> +{
> +	struct dm9000_platform_data *pdata;
> +	struct device_node *np = dev->device_node;
> +
> +	if (!IS_ENABLED(CONFIG_OF) || !np)
> +		return NULL;
> +
> +	pdata = xzalloc(sizeof(*pdata));
> +
> +	pdata->srom = 0;

Please don't allocate platform_data for the device tree case. Instead,
add a srom variable to struct dm9k and set it either from platform_data
or device tree.

> -	priv->buswidth = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
> +	switch (resource_size(&dev->resource[0])) {
> +	case 1:
> +		priv->buswidth = IORESOURCE_MEM_8BIT;
> +		break;
> +	case 2:
> +		priv->buswidth = IORESOURCE_MEM_16BIT;
> +		break;
> +	case 4:
> +		priv->buswidth = IORESOURCE_MEM_32BIT;
> +		break;
> +	default:
> +		dev_err(dev, "Wrong io resource size\n");
> +		priv->buswidth = 0;
> +	}

Does this work for device tree?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list