Subject: Re: [PATCH 2/4] net: smsc911x: add a reset GPIO DT binding

From: Laurent Pinchart <[email-masked]>
Date: Wed, 24 Jul 2013 00:10:54 +0200

Hi Guennadi,

Thanks for the patch.

On Tuesday 23 July 2013 18:12:02 Guennadi Liakhovetski wrote:
> Add a new DT property to specify a reset GPIO.
> 
> Signed-off-by: Guennadi Liakhovetski <[email-masked]>
> Cc: [email-masked]
> ---
>  Documentation/devicetree/bindings/net/smsc911x.txt |    1 +
>  drivers/net/ethernet/smsc/smsc911x.c               |   11 +++++++++++
>  2 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/smsc911x.txt
> b/Documentation/devicetree/bindings/net/smsc911x.txt index adb5b57..2bf32be
> 100644
> --- a/Documentation/devicetree/bindings/net/smsc911x.txt
> +++ b/Documentation/devicetree/bindings/net/smsc911x.txt
> @@ -23,6 +23,7 @@ Optional properties:
>    external PHY
>  - smsc,save-mac-address : Indicates that mac address needs to be saved
>    before resetting the controller
> +- smsc,reset-gpios : a GPIO binding to take the controller out of reset

Albeit defined in the smsc911x bindings, this property doesn't seem very 
device-specific. I wonder whether it would make sense to drop the "smsc," 
prefix.

>  - local-mac-address : 6 bytes, mac address
> 
>  Examples:
> diff --git a/drivers/net/ethernet/smsc/smsc911x.c
> b/drivers/net/ethernet/smsc/smsc911x.c index ca01c03..db6255e 100644
> --- a/drivers/net/ethernet/smsc/smsc911x.c
> +++ b/drivers/net/ethernet/smsc/smsc911x.c
> @@ -2328,6 +2328,8 @@ static int smsc911x_probe_config_dt(struct
> smsc911x_platform_config *config, {
>  	const char *mac;
>  	u32 width = 0;
> +	enum of_gpio_flags flags;
> +	int gpio;
> 
>  	if (!np)
>  		return -ENODEV;
> @@ -2361,6 +2363,15 @@ static int smsc911x_probe_config_dt(struct
> smsc911x_platform_config *config, if (of_get_property(np,
> "smsc,save-mac-address", NULL))
>  		config->flags |= SMSC911X_SAVE_MAC_ADDRESS;
> 
> +	gpio = of_get_named_gpio_flags(np, "smsc,reset-gpios", 0, &flags);
> +	if (gpio == -EPROBE_DEFER)
> +		return gpio;
> +	if (gpio_is_valid(gpio)) {
> +		config->reset_gpio = gpio;
> +		config->reset_gpio_config = SMSC911X_RESET_GPIO_VALID |
> +			(flags & OF_GPIO_ACTIVE_LOW ? GPIOF_INIT_LOW : GPIOF_INIT_HIGH);
> +	}
> +
>  	return 0;
>  }
>  #else
-- 
Regards,

Laurent Pinchart