netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/3] extend stmmac DT support.
@ 2013-07-02 13:03 Srinivas KANDAGATLA
       [not found] ` <1372770219-1643-1-git-send-email-srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Srinivas KANDAGATLA @ 2013-07-02 13:03 UTC (permalink / raw)
  To: netdev
  Cc: Giuseppe Cavallaro, Grant Likely, Rob Herring, Rob Landley,
	devicetree-discuss, linux-doc, linux-kernel, Srinivas Kandagatla

From: Srinivas Kandagatla <srinivas.kandagatla@st.com>

Hi Peppe,

Thankyou for the comments on RFC patches.

This patch series adds support to new gmac versions 3.6.10 and 3.710, these
versions of IP are integrated into ST STiH415/STiH416 SOCs.
This patchset also adds phy reset capablity to stmmac-mdio driver via DT.

Changes since RFC:
	- re-use existing compatible strings to select right properties.
	- clean up reset callback support so that DT is not parsed everytime.

Thanks,
srini

Srinivas Kandagatla (3):
  dt:net:stmmac: Allocate platform data only if its NULL.
  dt:net:stmmac: Add support to dwmac version 3.610 and 3.710
  dt:net:stmmac: Add dt specific phy reset callback support.

 Documentation/devicetree/bindings/net/stmmac.txt   |   10 ++++
 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c  |   50 +++++++++++++++++++-
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   32 +++++++++++-
 include/linux/stmmac.h                             |    4 ++
 4 files changed, 91 insertions(+), 5 deletions(-)

-- 
1.7.6.5


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v1 1/3] dt:net:stmmac: Allocate platform data only if its NULL.
       [not found] ` <1372770219-1643-1-git-send-email-srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>
@ 2013-07-02 13:04   ` Srinivas KANDAGATLA
  0 siblings, 0 replies; 6+ messages in thread
From: Srinivas KANDAGATLA @ 2013-07-02 13:04 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-doc-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Srinivas Kandagatla,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Grant Likely,
	Giuseppe Cavallaro

From: Srinivas Kandagatla <srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>

In some DT use-cases platform data might be already allocated and passed
via AUXDATA. These are the cases where machine level code populates few
callbacks in the platform data.

This patch adds check and reuses platform_data if its valid, before
allocating a new one.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>
Acked-by: Giuseppe Cavallaro <peppe.cavallaro-qxv4g6HH51o@public.gmane.org>
---
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 1d3780f..5907920 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -92,8 +92,10 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 	if (IS_ERR(addr))
 		return PTR_ERR(addr);
 
+	plat_dat = pdev->dev.platform_data;
 	if (pdev->dev.of_node) {
-		plat_dat = devm_kzalloc(&pdev->dev,
+		if (!plat_dat)
+			plat_dat = devm_kzalloc(&pdev->dev,
 					sizeof(struct plat_stmmacenet_data),
 					GFP_KERNEL);
 		if (!plat_dat) {
@@ -106,8 +108,6 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 			pr_err("%s: main dt probe failed", __func__);
 			return ret;
 		}
-	} else {
-		plat_dat = pdev->dev.platform_data;
 	}
 
 	/* Custom initialisation (if needed)*/
-- 
1.7.6.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 2/3] dt:net:stmmac: Add support to dwmac version 3.610 and 3.710
  2013-07-02 13:03 [PATCH v1 0/3] extend stmmac DT support Srinivas KANDAGATLA
       [not found] ` <1372770219-1643-1-git-send-email-srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>
@ 2013-07-02 13:04 ` Srinivas KANDAGATLA
  2013-07-02 13:04 ` [PATCH v1 3/3] dt:net:stmmac: Add dt specific phy reset callback support Srinivas KANDAGATLA
  2013-07-03 23:04 ` [PATCH v1 0/3] extend stmmac DT support David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: Srinivas KANDAGATLA @ 2013-07-02 13:04 UTC (permalink / raw)
  To: netdev
  Cc: Giuseppe Cavallaro, Grant Likely, Rob Herring, Rob Landley,
	devicetree-discuss, linux-doc, linux-kernel, Srinivas Kandagatla

From: Srinivas Kandagatla <srinivas.kandagatla@st.com>

This patch adds dt support to dwmac version 3.610 and 3.710 these
versions are integrated in STiH415 and STiH416 ARM A9 SOCs.
To support these IP version, some of the device tree properties are
extended.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
---
 Documentation/devicetree/bindings/net/stmmac.txt   |    4 +++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   26 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/stmmac.txt b/Documentation/devicetree/bindings/net/stmmac.txt
index 060bbf0..e1ddfcc 100644
--- a/Documentation/devicetree/bindings/net/stmmac.txt
+++ b/Documentation/devicetree/bindings/net/stmmac.txt
@@ -12,6 +12,10 @@ Required properties:
   property
 - phy-mode: String, operation mode of the PHY interface.
   Supported values are: "mii", "rmii", "gmii", "rgmii".
+- snps,phy-addr		phy address to connect to.
+- snps,pbl		Programmable Burst Length
+- snps,fixed-burst	Program the DMA to use the fixed burst mode
+- snps,mixed-burst	Program the DMA to use the mixed burst mode
 
 Optional properties:
 - mac-address: 6 bytes, mac address
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 5907920..7963115 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -34,12 +34,20 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
 				  const char **mac)
 {
 	struct device_node *np = pdev->dev.of_node;
+	struct stmmac_dma_cfg *dma_cfg;
 
 	if (!np)
 		return -ENODEV;
 
 	*mac = of_get_mac_address(np);
 	plat->interface = of_get_phy_mode(np);
+
+	plat->bus_id = of_alias_get_id(np, "ethernet");
+	if (plat->bus_id < 0)
+		plat->bus_id = 0;
+
+	of_property_read_u32(np, "snps,phy-addr", &plat->phy_addr);
+
 	plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
 					   sizeof(struct stmmac_mdio_bus_data),
 					   GFP_KERNEL);
@@ -56,6 +64,22 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
 		plat->pmt = 1;
 	}
 
+	if (of_device_is_compatible(np, "snps,dwmac-3.610") ||
+		of_device_is_compatible(np, "snps,dwmac-3.710")) {
+		plat->enh_desc = 1;
+		plat->bugged_jumbo = 1;
+		plat->force_sf_dma_mode = 1;
+	}
+
+	dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg), GFP_KERNEL);
+	if (!dma_cfg)
+		return -ENOMEM;
+
+	plat->dma_cfg = dma_cfg;
+	of_property_read_u32(np, "snps,pbl", &dma_cfg->pbl);
+	dma_cfg->fixed_burst = of_property_read_bool(np, "snps,fixed-burst");
+	dma_cfg->mixed_burst = of_property_read_bool(np, "snps,mixed-burst");
+
 	return 0;
 }
 #else
@@ -230,7 +254,9 @@ static const struct dev_pm_ops stmmac_pltfr_pm_ops;
 
 static const struct of_device_id stmmac_dt_ids[] = {
 	{ .compatible = "st,spear600-gmac"},
+	{ .compatible = "snps,dwmac-3.610"},
 	{ .compatible = "snps,dwmac-3.70a"},
+	{ .compatible = "snps,dwmac-3.710"},
 	{ .compatible = "snps,dwmac"},
 	{ /* sentinel */ }
 };
-- 
1.7.6.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 3/3] dt:net:stmmac: Add dt specific phy reset callback support.
  2013-07-02 13:03 [PATCH v1 0/3] extend stmmac DT support Srinivas KANDAGATLA
       [not found] ` <1372770219-1643-1-git-send-email-srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>
  2013-07-02 13:04 ` [PATCH v1 2/3] dt:net:stmmac: Add support to dwmac version 3.610 and 3.710 Srinivas KANDAGATLA
@ 2013-07-02 13:04 ` Srinivas KANDAGATLA
  2013-07-03 23:04 ` [PATCH v1 0/3] extend stmmac DT support David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: Srinivas KANDAGATLA @ 2013-07-02 13:04 UTC (permalink / raw)
  To: netdev
  Cc: Giuseppe Cavallaro, Grant Likely, Rob Herring, Rob Landley,
	devicetree-discuss, linux-doc, linux-kernel, Srinivas Kandagatla

From: Srinivas Kandagatla <srinivas.kandagatla@st.com>

This patch adds phy reset callback support for stmmac driver via device
trees. It adds three new properties to gmac device tree bindings to
define the reset signal via gpio.

With this patch users can conveniently pass reset gpio number with pre,
pulse and post delay in micro secs via DTs.

 active low:
		_________		 ____________
	<pre-delay>	|<pulse-delay>	|<post-delay>
		 	|		|
		 	|_______________|

 active high:
 			 ________________
	<pre-delay>	|<pulse-delay>	|<post-delay>
			|		|
		________|		|___________

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
---
 Documentation/devicetree/bindings/net/stmmac.txt  |    6 +++
 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c |   50 ++++++++++++++++++++-
 include/linux/stmmac.h                            |    4 ++
 3 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/stmmac.txt b/Documentation/devicetree/bindings/net/stmmac.txt
index e1ddfcc..261c563 100644
--- a/Documentation/devicetree/bindings/net/stmmac.txt
+++ b/Documentation/devicetree/bindings/net/stmmac.txt
@@ -13,6 +13,12 @@ Required properties:
 - phy-mode: String, operation mode of the PHY interface.
   Supported values are: "mii", "rmii", "gmii", "rgmii".
 - snps,phy-addr		phy address to connect to.
+- snps,reset-gpio 	gpio number for phy reset.
+- snps,reset-active-low boolean flag to indicate if phy reset is active low.
+- snps,reset-delays-us  is triplet of delays
+	The 1st cell is reset pre-delay in micro seconds.
+	The 2nd cell is reset pulse in micro seconds.
+	The 3rd cell is reset post-delay in micro seconds.
 - snps,pbl		Programmable Burst Length
 - snps,fixed-burst	Program the DMA to use the fixed burst mode
 - snps,mixed-burst	Program the DMA to use the mixed burst mode
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index cc15039..deb384e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -27,6 +27,9 @@
 #include <linux/mii.h>
 #include <linux/phy.h>
 #include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+
 #include <asm/io.h>
 
 #include "stmmac.h"
@@ -131,10 +134,47 @@ static int stmmac_mdio_reset(struct mii_bus *bus)
 	struct net_device *ndev = bus->priv;
 	struct stmmac_priv *priv = netdev_priv(ndev);
 	unsigned int mii_address = priv->hw->mii.addr;
+	struct device *dev = priv->device;
+	struct stmmac_mdio_bus_data *data = priv->plat->mdio_bus_data;
+
+#ifdef CONFIG_OF
+	if (dev->of_node) {
+		int reset_gpio, active_low;
+
+		if (data->reset_gpio < 0) {
+			struct device_node *np = dev->of_node;
+			if (!np)
+				return 0;
+
+			data->reset_gpio = of_get_named_gpio(np,
+						"snps,reset-gpio", 0);
+			if (data->reset_gpio < 0)
+				return 0;
+
+			data->active_low = of_property_read_bool(np,
+						"snps,reset-active-low");
+			of_property_read_u32_array(np,
+				"snps,reset-delays-us", data->delays, 3);
+		}
+
+		reset_gpio = data->reset_gpio;
+		active_low = data->active_low;
+
+		if (!gpio_request(reset_gpio, "mdio-reset")) {
+			gpio_direction_output(reset_gpio, active_low ? 1 : 0);
+			udelay(data->delays[0]);
+			gpio_set_value(reset_gpio, active_low ? 0 : 1);
+			udelay(data->delays[1]);
+			gpio_set_value(reset_gpio, active_low ? 1 : 0);
+			udelay(data->delays[2]);
+			gpio_free(reset_gpio);
+		}
+	}
+#endif
 
-	if (priv->plat->mdio_bus_data->phy_reset) {
+	if (data->phy_reset) {
 		pr_debug("stmmac_mdio_reset: calling phy_reset\n");
-		priv->plat->mdio_bus_data->phy_reset(priv->plat->bsp_priv);
+		data->phy_reset(priv->plat->bsp_priv);
 	}
 
 	/* This is a workaround for problems with the STE101P PHY.
@@ -157,6 +197,7 @@ int stmmac_mdio_register(struct net_device *ndev)
 	struct mii_bus *new_bus;
 	int *irqlist;
 	struct stmmac_priv *priv = netdev_priv(ndev);
+	struct device *dev = priv->device;
 	struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data;
 	int addr, found;
 
@@ -172,6 +213,11 @@ int stmmac_mdio_register(struct net_device *ndev)
 	else
 		irqlist = priv->mii_irq;
 
+#ifdef CONFIG_OF
+	if (dev->of_node)
+		mdio_bus_data->reset_gpio = -1;
+#endif
+
 	new_bus->name = "stmmac";
 	new_bus->read = &stmmac_mdio_read;
 	new_bus->write = &stmmac_mdio_write;
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index c1b3ed3..9e495d31 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -80,6 +80,10 @@ struct stmmac_mdio_bus_data {
 	unsigned int phy_mask;
 	int *irqs;
 	int probed_phy_irq;
+#ifdef CONFIG_OF
+	int reset_gpio, active_low;
+	u32 delays[3];
+#endif
 };
 
 struct stmmac_dma_cfg {
-- 
1.7.6.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 0/3] extend stmmac DT support.
  2013-07-02 13:03 [PATCH v1 0/3] extend stmmac DT support Srinivas KANDAGATLA
                   ` (2 preceding siblings ...)
  2013-07-02 13:04 ` [PATCH v1 3/3] dt:net:stmmac: Add dt specific phy reset callback support Srinivas KANDAGATLA
@ 2013-07-03 23:04 ` David Miller
       [not found]   ` <20130703.160423.1285164466482391784.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
  3 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2013-07-03 23:04 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: netdev, peppe.cavallaro, grant.likely, rob.herring, rob,
	devicetree-discuss, linux-doc, linux-kernel

From: Srinivas KANDAGATLA <srinivas.kandagatla@st.com>
Date: Tue,  2 Jul 2013 14:03:39 +0100

> From: Srinivas Kandagatla <srinivas.kandagatla@st.com>
> 
> Hi Peppe,
> 
> Thankyou for the comments on RFC patches.
> 
> This patch series adds support to new gmac versions 3.6.10 and 3.710, these
> versions of IP are integrated into ST STiH415/STiH416 SOCs.
> This patchset also adds phy reset capablity to stmmac-mdio driver via DT.
> 
> Changes since RFC:
> 	- re-use existing compatible strings to select right properties.
> 	- clean up reset callback support so that DT is not parsed everytime.

You are going to have to fix up the following build warnings and resubmit:

  CC [M]  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.o
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c: In function ‘stmmac_mdio_reset’:
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c:137:17: warning: unused variable ‘dev’ [-Wunused-variable]
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c: In function ‘stmmac_mdio_register’:
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c:200:17: warning: unused variable ‘dev’ [-Wunused-variable]


Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 0/3] extend stmmac DT support.
       [not found]   ` <20130703.160423.1285164466482391784.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
@ 2013-07-04  8:44     ` Srinivas KANDAGATLA
  0 siblings, 0 replies; 6+ messages in thread
From: Srinivas KANDAGATLA @ 2013-07-04  8:44 UTC (permalink / raw)
  To: David Miller
  Cc: linux-doc-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A, peppe.cavallaro-qxv4g6HH51o

On 04/07/13 00:04, David Miller wrote:

> You are going to have to fix up the following build warnings and resubmit:
> 
>   CC [M]  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.o
> drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c: In function ‘stmmac_mdio_reset’:
> drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c:137:17: warning: unused variable ‘dev’ [-Wunused-variable]
> drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c: In function ‘stmmac_mdio_register’:
> drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c:200:17: warning: unused variable ‘dev’ [-Wunused-variable]
Thanks Dave,
I will resubmit the patches with this warning fix.

Thanks,
srini
> 
> 
> Thanks.
> 

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-07-04  8:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-02 13:03 [PATCH v1 0/3] extend stmmac DT support Srinivas KANDAGATLA
     [not found] ` <1372770219-1643-1-git-send-email-srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>
2013-07-02 13:04   ` [PATCH v1 1/3] dt:net:stmmac: Allocate platform data only if its NULL Srinivas KANDAGATLA
2013-07-02 13:04 ` [PATCH v1 2/3] dt:net:stmmac: Add support to dwmac version 3.610 and 3.710 Srinivas KANDAGATLA
2013-07-02 13:04 ` [PATCH v1 3/3] dt:net:stmmac: Add dt specific phy reset callback support Srinivas KANDAGATLA
2013-07-03 23:04 ` [PATCH v1 0/3] extend stmmac DT support David Miller
     [not found]   ` <20130703.160423.1285164466482391784.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2013-07-04  8:44     ` Srinivas KANDAGATLA

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