* [PATCH 1/4] net: smsc911x: add support for a reset GPIO
2013-07-23 16:12 [PATCH 0/4] net: smsc911x: support reset GPIO and use it on ape6evm Guennadi Liakhovetski
@ 2013-07-23 16:12 ` Guennadi Liakhovetski
2013-07-23 16:38 ` Fabio Estevam
2013-07-23 17:36 ` Sergei Shtylyov
2013-07-23 16:12 ` [PATCH 2/4] net: smsc911x: add a reset GPIO DT binding Guennadi Liakhovetski
` (2 subsequent siblings)
3 siblings, 2 replies; 10+ messages in thread
From: Guennadi Liakhovetski @ 2013-07-23 16:12 UTC (permalink / raw)
To: linux-sh
Cc: Magnus Damm, Simon Horman, Steve Glendinning, netdev,
Guennadi Liakhovetski
If a reset GPIO is specified in platform data, take the controller out of
reset before using it.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
---
drivers/net/ethernet/smsc/smsc911x.c | 19 ++++++++++++++++++-
include/linux/smsc911x.h | 10 ++++++++++
2 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index a141921..ca01c03 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -2300,6 +2300,9 @@ static int smsc911x_drv_remove(struct platform_device *pdev)
free_netdev(dev);
+ if (pdata->config.reset_gpio_config & SMSC911X_RESET_GPIO_VALID)
+ gpio_free(pdata->config.reset_gpio);
+
return 0;
}
@@ -2479,10 +2482,21 @@ static int smsc911x_drv_probe(struct platform_device *pdev)
goto out_disable_resources;
}
+ if (pdata->config.reset_gpio_config & SMSC911X_RESET_GPIO_VALID) {
+ /* Take the chip out of hard reset */
+ unsigned long flags = (pdata->config.reset_gpio_config ^
+ GPIOF_INIT_HIGH) & 0xf;
+ retval = gpio_request_one(pdata->config.reset_gpio,
+ GPIOF_DIR_OUT | flags,
+ netdev_name(dev));
+ if (retval < 0)
+ goto out_free_irq;
+ }
+
retval = register_netdev(dev);
if (retval) {
SMSC_WARN(pdata, probe, "Error %i registering device", retval);
- goto out_free_irq;
+ goto out_free_reset;
} else {
SMSC_TRACE(pdata, probe,
"Network interface: \"%s\"", dev->name);
@@ -2531,6 +2545,9 @@ static int smsc911x_drv_probe(struct platform_device *pdev)
out_unregister_netdev_5:
unregister_netdev(dev);
+out_free_reset:
+ if (pdata->config.reset_gpio_config & SMSC911X_RESET_GPIO_VALID)
+ gpio_free(pdata->config.reset_gpio);
out_free_irq:
free_irq(dev->irq, dev);
out_disable_resources:
diff --git a/include/linux/smsc911x.h b/include/linux/smsc911x.h
index 4dde70e..4e3e49d 100644
--- a/include/linux/smsc911x.h
+++ b/include/linux/smsc911x.h
@@ -32,8 +32,18 @@ struct smsc911x_platform_config {
unsigned int shift;
phy_interface_t phy_interface;
unsigned char mac[6];
+ unsigned int reset_gpio;
+ unsigned int reset_gpio_config;
};
+/*
+ * Bits for platform_device reest GPIO configuration: an OR of any GPIOF_* flags
+ * from <linux/gpio.h>, specifically one of GPIOF_INIT_LOW or GPIOF_INIT_HIGH
+ * and the below SMSC911X_RESET_GPIO_VALID flag. We define GPIOF_INIT_* as the
+ * level, that activates chip reset.
+ */
+#define SMSC911X_RESET_GPIO_VALID BIT(31)
+
/* Constants for platform_device irq polarity configuration */
#define SMSC911X_IRQ_POLARITY_ACTIVE_LOW 0
#define SMSC911X_IRQ_POLARITY_ACTIVE_HIGH 1
--
1.7.2.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] net: smsc911x: add support for a reset GPIO
2013-07-23 16:12 ` [PATCH 1/4] net: smsc911x: add support for a reset GPIO Guennadi Liakhovetski
@ 2013-07-23 16:38 ` Fabio Estevam
2013-07-23 16:44 ` Guennadi Liakhovetski
2013-07-23 17:36 ` Sergei Shtylyov
1 sibling, 1 reply; 10+ messages in thread
From: Fabio Estevam @ 2013-07-23 16:38 UTC (permalink / raw)
To: Guennadi Liakhovetski
Cc: linux-sh, Magnus Damm, Simon Horman, Steve Glendinning, netdev,
Guennadi Liakhovetski
On Tue, Jul 23, 2013 at 1:12 PM, Guennadi Liakhovetski
<g.liakhovetski@gmx.de> wrote:
> + if (pdata->config.reset_gpio_config & SMSC911X_RESET_GPIO_VALID) {
> + /* Take the chip out of hard reset */
> + unsigned long flags = (pdata->config.reset_gpio_config ^
> + GPIOF_INIT_HIGH) & 0xf;
> + retval = gpio_request_one(pdata->config.reset_gpio,
If you use devm_gpio_request_one() here, then you can simplify your
code by not having to call gpio_free.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] net: smsc911x: add support for a reset GPIO
2013-07-23 16:38 ` Fabio Estevam
@ 2013-07-23 16:44 ` Guennadi Liakhovetski
0 siblings, 0 replies; 10+ messages in thread
From: Guennadi Liakhovetski @ 2013-07-23 16:44 UTC (permalink / raw)
To: Fabio Estevam
Cc: linux-sh, Magnus Damm, Simon Horman, Steve Glendinning, netdev
On Tue, 23 Jul 2013, Fabio Estevam wrote:
> On Tue, Jul 23, 2013 at 1:12 PM, Guennadi Liakhovetski
> <g.liakhovetski@gmx.de> wrote:
>
> > + if (pdata->config.reset_gpio_config & SMSC911X_RESET_GPIO_VALID) {
> > + /* Take the chip out of hard reset */
> > + unsigned long flags = (pdata->config.reset_gpio_config ^
> > + GPIOF_INIT_HIGH) & 0xf;
> > + retval = gpio_request_one(pdata->config.reset_gpio,
>
> If you use devm_gpio_request_one() here, then you can simplify your
> code by not having to call gpio_free.
Oops, sure, will update, thanks.
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] net: smsc911x: add support for a reset GPIO
2013-07-23 16:12 ` [PATCH 1/4] net: smsc911x: add support for a reset GPIO Guennadi Liakhovetski
2013-07-23 16:38 ` Fabio Estevam
@ 2013-07-23 17:36 ` Sergei Shtylyov
1 sibling, 0 replies; 10+ messages in thread
From: Sergei Shtylyov @ 2013-07-23 17:36 UTC (permalink / raw)
To: Guennadi Liakhovetski
Cc: linux-sh, Magnus Damm, Simon Horman, Steve Glendinning, netdev,
Guennadi Liakhovetski
Hello.
On 07/23/2013 08:12 PM, Guennadi Liakhovetski wrote:
> If a reset GPIO is specified in platform data, take the controller out of
> reset before using it.
A small typo in the comment...
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
[...]
> diff --git a/include/linux/smsc911x.h b/include/linux/smsc911x.h
> index 4dde70e..4e3e49d 100644
> --- a/include/linux/smsc911x.h
> +++ b/include/linux/smsc911x.h
> @@ -32,8 +32,18 @@ struct smsc911x_platform_config {
> unsigned int shift;
> phy_interface_t phy_interface;
> unsigned char mac[6];
> + unsigned int reset_gpio;
> + unsigned int reset_gpio_config;
> };
>
> +/*
> + * Bits for platform_device reest GPIO configuration: an OR of any GPIOF_* flags
s/reest/reset/
WBR, Sergei
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/4] net: smsc911x: add a reset GPIO DT binding
2013-07-23 16:12 [PATCH 0/4] net: smsc911x: support reset GPIO and use it on ape6evm Guennadi Liakhovetski
2013-07-23 16:12 ` [PATCH 1/4] net: smsc911x: add support for a reset GPIO Guennadi Liakhovetski
@ 2013-07-23 16:12 ` Guennadi Liakhovetski
2013-07-23 22:10 ` Laurent Pinchart
2013-07-23 22:18 ` Sascha Hauer
2013-07-23 16:12 ` [PATCH 3/4] ARM: shmobile: ape6evm: use smsc911x platform parameters to handle eth reset Guennadi Liakhovetski
2013-07-23 16:12 ` [PATCH 4/4] ARM: shmobile: ape6evm-reference: add smsc911x ethernet support Guennadi Liakhovetski
3 siblings, 2 replies; 10+ messages in thread
From: Guennadi Liakhovetski @ 2013-07-23 16:12 UTC (permalink / raw)
To: linux-sh
Cc: Magnus Damm, Simon Horman, Steve Glendinning, netdev,
Guennadi Liakhovetski, devicetree
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
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
--
1.7.2.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/4] net: smsc911x: add a reset GPIO DT binding
2013-07-23 16:12 ` [PATCH 2/4] net: smsc911x: add a reset GPIO DT binding Guennadi Liakhovetski
@ 2013-07-23 22:10 ` Laurent Pinchart
2013-07-23 22:18 ` Sascha Hauer
1 sibling, 0 replies; 10+ messages in thread
From: Laurent Pinchart @ 2013-07-23 22:10 UTC (permalink / raw)
To: Guennadi Liakhovetski
Cc: linux-sh, Magnus Damm, Simon Horman, Steve Glendinning, netdev,
Guennadi Liakhovetski, devicetree
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
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/4] net: smsc911x: add a reset GPIO DT binding
2013-07-23 16:12 ` [PATCH 2/4] net: smsc911x: add a reset GPIO DT binding Guennadi Liakhovetski
2013-07-23 22:10 ` Laurent Pinchart
@ 2013-07-23 22:18 ` Sascha Hauer
1 sibling, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2013-07-23 22:18 UTC (permalink / raw)
To: Guennadi Liakhovetski
Cc: linux-sh, Magnus Damm, Simon Horman, Steve Glendinning, netdev,
Guennadi Liakhovetski, devicetree
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
--
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 |
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 3/4] ARM: shmobile: ape6evm: use smsc911x platform parameters to handle eth reset
2013-07-23 16:12 [PATCH 0/4] net: smsc911x: support reset GPIO and use it on ape6evm Guennadi Liakhovetski
2013-07-23 16:12 ` [PATCH 1/4] net: smsc911x: add support for a reset GPIO Guennadi Liakhovetski
2013-07-23 16:12 ` [PATCH 2/4] net: smsc911x: add a reset GPIO DT binding Guennadi Liakhovetski
@ 2013-07-23 16:12 ` Guennadi Liakhovetski
2013-07-23 16:12 ` [PATCH 4/4] ARM: shmobile: ape6evm-reference: add smsc911x ethernet support Guennadi Liakhovetski
3 siblings, 0 replies; 10+ messages in thread
From: Guennadi Liakhovetski @ 2013-07-23 16:12 UTC (permalink / raw)
To: linux-sh
Cc: Magnus Damm, Simon Horman, Steve Glendinning, netdev,
Guennadi Liakhovetski
Instead of fixing ethernet reset GPIO in platform initialisation code, pass
the GPIO to the driver.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
---
arch/arm/mach-shmobile/board-ape6evm.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-shmobile/board-ape6evm.c b/arch/arm/mach-shmobile/board-ape6evm.c
index 96a6994..bd46c75 100644
--- a/arch/arm/mach-shmobile/board-ape6evm.c
+++ b/arch/arm/mach-shmobile/board-ape6evm.c
@@ -56,6 +56,8 @@ static const struct smsc911x_platform_config lan9220_data = {
.flags = SMSC911X_USE_32BIT,
.irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
.irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
+ .reset_gpio = 270,
+ .reset_gpio_config = SMSC911X_RESET_GPIO_VALID | GPIOF_INIT_LOW,
};
/*
@@ -156,9 +158,6 @@ static void __init ape6evm_add_standard_devices(void)
r8a73a4_pinmux_init();
r8a73a4_add_standard_devices();
- /* LAN9220 ethernet */
- gpio_request_one(270, GPIOF_OUT_INIT_HIGH, NULL); /* smsc9220 RESET */
-
regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
platform_device_register_resndata(&platform_bus, "smsc911x", -1,
--
1.7.2.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/4] ARM: shmobile: ape6evm-reference: add smsc911x ethernet support
2013-07-23 16:12 [PATCH 0/4] net: smsc911x: support reset GPIO and use it on ape6evm Guennadi Liakhovetski
` (2 preceding siblings ...)
2013-07-23 16:12 ` [PATCH 3/4] ARM: shmobile: ape6evm: use smsc911x platform parameters to handle eth reset Guennadi Liakhovetski
@ 2013-07-23 16:12 ` Guennadi Liakhovetski
3 siblings, 0 replies; 10+ messages in thread
From: Guennadi Liakhovetski @ 2013-07-23 16:12 UTC (permalink / raw)
To: linux-sh
Cc: Magnus Damm, Simon Horman, Steve Glendinning, netdev,
Guennadi Liakhovetski
Add support for the SMSC9220 ethernet chip on the board.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
---
arch/arm/boot/dts/r8a73a4-ape6evm-reference.dts | 25 ++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/arch/arm/boot/dts/r8a73a4-ape6evm-reference.dts b/arch/arm/boot/dts/r8a73a4-ape6evm-reference.dts
index 3bcbc9f..4215ebc 100644
--- a/arch/arm/boot/dts/r8a73a4-ape6evm-reference.dts
+++ b/arch/arm/boot/dts/r8a73a4-ape6evm-reference.dts
@@ -8,6 +8,8 @@
* kind, whether express or implied.
*/
+#include <dt-bindings/gpio/gpio.h>
+
/dts-v1/;
/include/ "r8a73a4.dtsi"
@@ -16,7 +18,7 @@
compatible = "renesas,ape6evm-reference", "renesas,r8a73a4";
chosen {
- bootargs = "console=ttySC0,115200 ignore_loglevel";
+ bootargs = "console=ttySC0,115200 debug ip=dhcp root=/dev/nfs";
};
memory@40000000 {
@@ -37,6 +39,22 @@
#address-cells = <1>;
#size-cells = <1>;
ranges = <0 0 0 0x80000000>;
+
+ ethernet@8000000 {
+ compatible = "smsc,lan9118", "smsc,lan9115";
+ reg = <0x08000000 0x1000>;
+ interrupt-parent = <&irqc1>;
+ interrupts = <8 0x4>;
+ phy-mode = "mii";
+ reg-io-width = <4>;
+ smsc,irq-active-high;
+ smsc,irq-push-pull;
+ smsc,reset-gpios = <&pfc 270 GPIO_ACTIVE_LOW>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&smsc_pins>;
+ vdd33a-supply = <&ape6evm_fixed_3v3>;
+ vddvario-supply = <&ape6evm_fixed_3v3>;
+ };
};
};
@@ -85,6 +103,11 @@
renesas,groups = "sdhi1_data4", "sdhi1_ctrl";
renesas,function = "sdhi1";
};
+
+ smsc_pins: eth0 {
+ renesas,groups = "irqc_irq40";
+ renesas,function = "irqc";
+ };
};
&mmcif0 {
--
1.7.2.5
^ permalink raw reply related [flat|nested] 10+ messages in thread