diff mbox

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

Message ID 1374595924-12338-3-git-send-email-g.liakhovetski@gmx.de
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Guennadi Liakhovetski July 23, 2013, 4:12 p.m. UTC
Add a new DT property to specify a reset GPIO.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
Cc: devicetree@vger.kernel.org
---
 Documentation/devicetree/bindings/net/smsc911x.txt |    1 +
 drivers/net/ethernet/smsc/smsc911x.c               |   11 +++++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

Comments

Laurent Pinchart July 23, 2013, 10:10 p.m. UTC | #1
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 <g.liakhovetski+renesas@gmail.com>
> Cc: devicetree@vger.kernel.org
> ---
>  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
Sascha Hauer July 23, 2013, 10:18 p.m. UTC | #2
On Tue, Jul 23, 2013 at 06:12:02PM +0200, Guennadi Liakhovetski wrote:
> Add a new DT property to specify a reset GPIO.
> 
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
> Cc: devicetree@vger.kernel.org
> ---
>  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
>  - local-mac-address : 6 bytes, mac address

BTW there's also:

[PATCH v10] reset: Add driver for gpio-controlled reset pins

http://www.mail-archive.com/devicetree-discuss@lists.ozlabs.org/msg36900.html

which may be a generic way to handle device resets. Not mainline yet,
though.

Sascha
diff mbox

Patch

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
 - 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