netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
To: linux-sh@vger.kernel.org
Cc: Magnus Damm <magnus.damm@gmail.com>,
	Simon Horman <horms@verge.net.au>,
	Steve Glendinning <steve.glendinning@shawell.net>,
	netdev@vger.kernel.org,
	Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
Subject: [PATCH 1/4] net: smsc911x: add support for a reset GPIO
Date: Tue, 23 Jul 2013 18:12:01 +0200	[thread overview]
Message-ID: <1374595924-12338-2-git-send-email-g.liakhovetski@gmx.de> (raw)
In-Reply-To: <1374595924-12338-1-git-send-email-g.liakhovetski@gmx.de>

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

  reply	other threads:[~2013-07-23 16:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2013-07-23 16:38   ` [PATCH 1/4] net: smsc911x: add support for a reset GPIO Fabio Estevam
2013-07-23 16:44     ` Guennadi Liakhovetski
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
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374595924-12338-2-git-send-email-g.liakhovetski@gmx.de \
    --to=g.liakhovetski@gmx.de \
    --cc=g.liakhovetski+renesas@gmail.com \
    --cc=horms@verge.net.au \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=steve.glendinning@shawell.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).