Skip to contentSkip to conversation

stmmac: Add device-tree support

PATCH Superseded Stefan Roese 6 participants 18 messages Mar 12, 2012 – Mar 15, 2012 1 message not in the archive

Subsystems (5)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 stmmac: Add device-tree support

This patch adds support to configure the STMMAC ethernet driver via device-tree instead of platform_data.

Currently, only the properties needed on SPEAr600 are provided. All other properties should be added once needed on other platforms.

Cc Giuseppe Cavallaro <[email protected]>
Cc Viresh Kumar <[email protected]>
---
 Documentation/devicetree/bindings/net/stmmac.txt   |   38 +++++++++++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   66 +++++++++++++++++++-
 2 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt
Documentation/devicetree/bindings/net/stmmac.txt new file +38 -0
new file mode 100644
index 0000000..386a47f
@@ -0,0 +1,38 @@
+* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
+
+Required properties:
+- compatible: Should be "stm,gmac"
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the STMMAC interrupts
+- interrupt-names: Should contain the interrupt names "macirq"
+  "eth_wake_irq" if this interrupt is supported in the "interrupts"
+  property
+- phy-mode: String, operation mode of the PHY interface.
+  Supported values are: "mii", "rmii", "gmii", "rgmii".
+- phy-addr: MDIO address of the PHY
+
+Optional properties:
+- stm,prog-burst-len: Specify the burst length
+- stm,has-gmac: Indicates that the controller supports 1000Mbps
+- stm,has-pmt: Indicates that the controller supports power management
+- mac-address: 6 bytes, mac address
+
+Examples:
+
+	gmac0: stmmac at e0800000 {
+		compatible = "stm,gmac";
+		reg = <0xe0800000 0x8000>;
+		interrupt-parent = <&vic1>;
+		interrupts = <24 23>;
+		interrupt-names = "macirq", "eth_wake_irq";
+		mac-address = [000000000000]; /* Filled in by U-Boot */
+
+		stm,prog-burst-len = <8>;
+		stm,has-gmac;
+		stm,has-pmt;
+
+		phy-mode = "gmii";
+		phy-addr = <0>;
+	};
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +65 -1

110 lines not on this page · raw message

Signature · 1 line
1.7.9.2
#1 lore raw
Quoted 21 lines · Stefan Roese

This patch adds support to configure the STMMAC ethernet driver via device-tree instead of platform_data.

Currently, only the properties needed on SPEAr600 are provided. All other properties should be added once needed on other platforms.

Cc Giuseppe Cavallaro <[email protected]>
Cc Viresh Kumar <[email protected]>
---
 Documentation/devicetree/bindings/net/stmmac.txt   |   38 +++++++++++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   66 +++++++++++++++++++-
 2 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt
Documentation/devicetree/bindings/net/stmmac.txt new file +0 -0
new file mode 100644
index 0000000..386a47f

Documentation/devicetree/bindings/net/stmmac.txt line 4

Quoted 4 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +4 -0
@@ -0,0 +1,38 @@
+* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
+
+Required properties:
+- compatible: Should be "stm,gmac"

This is too generic. This should be 1 string per version of h/w.

'stm' should be 'st' according to vendor-prefixes.txt.

Documentation/devicetree/bindings/net/stmmac.txt line 11

Quoted 7 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +7 -0
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the STMMAC interrupts
+- interrupt-names: Should contain the interrupt names "macirq"
+  "eth_wake_irq" if this interrupt is supported in the "interrupts"
+  property

You should be able to tell this from the compatible string and number of interrupts.

Documentation/devicetree/bindings/net/stmmac.txt line 14

Quoted 3 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +3 -0
+- phy-mode: String, operation mode of the PHY interface.
+  Supported values are: "mii", "rmii", "gmii", "rgmii".
+- phy-addr: MDIO address of the PHY

This is normally probed or the mdio bus is a sub-node of the MAC node. See arch/powerpc/boot/dts/mpc8377_mds.dts for an example.

Documentation/devicetree/bindings/net/stmmac.txt line 19

Quoted 5 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +5 -0
+
+Optional properties:
+- stm,prog-burst-len: Specify the burst length
+- stm,has-gmac: Indicates that the controller supports 1000Mbps
+- stm,has-pmt: Indicates that the controller supports power management

I think these should all be encoded by the compatible string.

Rob

Quoted 140 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +19 -0
+- mac-address: 6 bytes, mac address
+
+Examples:
+
+	gmac0: stmmac at e0800000 {
+		compatible = "stm,gmac";
+		reg = <0xe0800000 0x8000>;
+		interrupt-parent = <&vic1>;
+		interrupts = <24 23>;
+		interrupt-names = "macirq", "eth_wake_irq";
+		mac-address = [000000000000]; /* Filled in by U-Boot */
+
+		stm,prog-burst-len = <8>;
+		stm,has-gmac;
+		stm,has-pmt;
+
+		phy-mode = "gmii";
+		phy-addr = <0>;
+	};
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +65 -1
index 3aad981..fcf46c7 100644
@@ -24,8 +24,43 @@
 
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_net.h>
 #include "stmmac.h"
 
+#ifdef CONFIG_OF
+static int __devinit stmmac_probe_config_dt(struct platform_device *pdev,
+					    struct plat_stmmacenet_data *plat,
+					    const char **mac)
+{
+	struct device_node *np = pdev->dev.of_node;
+
+	if (!np)
+		return -ENODEV;
+
+	*mac = of_get_mac_address(np);
+
+	plat->interface = of_get_phy_mode(np);
+	of_property_read_u32(np, "phy-addr", &plat->phy_addr);
+	plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
+					   sizeof(struct stmmac_mdio_bus_data),
+					   GFP_KERNEL);
+
+	/*
+	 * Currently only the properties needed on SPEAr600
+	 * are provided. All other properties should be added
+	 * once needed on other platforms.
+	 */
+	of_property_read_u32(np, "stm,prog-burst-len", &plat->pbl);
+	if (of_get_property(np, "stm,has-gmac", NULL))
+		plat->has_gmac = 1;
+	if (of_get_property(np, "stm,has-pmt", NULL))
+		plat->pmt = 1;
+
+	return 0;
+}
+#endif /* CONFIG_OF */
+
 /**
  * stmmac_pltfr_probe
  * @pdev: platform device pointer
@@ -39,7 +74,8 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 	struct resource *res;
 	void __iomem *addr = NULL;
 	struct stmmac_priv *priv = NULL;
-	struct plat_stmmacenet_data *plat_dat;
+	struct plat_stmmacenet_data *plat_dat = NULL;
+	const char *mac = NULL;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res)
@@ -58,6 +94,22 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 		ret = -ENOMEM;
 		goto out_release_region;
 	}
+
+#ifdef CONFIG_OF
+	plat_dat = devm_kzalloc(&pdev->dev, sizeof(struct plat_stmmacenet_data),
+				GFP_KERNEL);
+	if (!plat_dat) {
+		pr_err("%s: ERROR: no memory", __func__);
+		ret = -ENOMEM;
+		goto out_unmap;
+	}
+
+	ret = stmmac_probe_config_dt(pdev, plat_dat, &mac);
+	if (ret) {
+		pr_err("%s: main dt probe failed", __func__);
+		goto out_unmap;
+	}
+#else
 	plat_dat = pdev->dev.platform_data;
 
 	/* Custom initialisation (if needed)*/
@@ -66,6 +118,7 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 		if (unlikely(ret))
 			goto out_unmap;
 	}
+#endif
 
 	priv = stmmac_dvr_probe(&(pdev->dev), plat_dat, addr);
 	if (!priv) {
@@ -73,6 +126,10 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 		goto out_unmap;
 	}
 
+	/* Get MAC address if available (DT) */
+	if (mac)
+		memcpy(priv->dev->dev_addr, mac, ETH_ALEN);
+
 	/* Get the MAC information */
 	priv->dev->irq = platform_get_irq_byname(pdev, "macirq");
 	if (priv->dev->irq == -ENXIO) {
@@ -178,6 +235,12 @@ static const struct dev_pm_ops stmmac_pltfr_pm_ops = {
 static const struct dev_pm_ops stmmac_pltfr_pm_ops;
 #endif /* CONFIG_PM */
 
+static const struct of_device_id stmmac_dt_ids[] = {
+	{ .compatible = "stm,gmac", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
+
 static struct platform_driver stmmac_driver = {
 	.probe = stmmac_pltfr_probe,
 	.remove = stmmac_pltfr_remove,
@@ -185,6 +248,7 @@ static struct platform_driver stmmac_driver = {
 		   .name = STMMAC_RESOURCE_NAME,
 		   .owner = THIS_MODULE,
 		   .pm = &stmmac_pltfr_pm_ops,
+		   .of_match_table = of_match_ptr(stmmac_dt_ids),
 		   },
 };
 
#2 lore raw

Hi Rob,

Quoted 17 lines · On Monday 12 March 2012 15:34:59 Rob Herring wrote:
Quoted 16 lines · Stefan Roese

This patch adds support to configure the STMMAC ethernet driver via device-tree instead of platform_data.

Currently, only the properties needed on SPEAr600 are provided. All other properties should be added once needed on other platforms.

Cc Giuseppe Cavallaro <[email protected]>
Cc Viresh Kumar <[email protected]>

---

 Documentation/devicetree/bindings/net/stmmac.txt   |   38 +++++++++++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   66
 +++++++++++++++++++- 2 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt
Quoted 12 lines

Documentation/devicetree/bindings/net/stmmac.txt line 4

Quoted 10 lines
(quoted diff) +0 -0

b/Documentation/devicetree/bindings/net/stmmac.txt new file mode 100644 index 0000000..386a47f

Documentation/devicetree/bindings/net/stmmac.txt new file +4 -0
@@ -0,0 +1,38 @@
+* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
+
+Required properties:
+- compatible: Should be "stm,gmac"

This is too generic. This should be 1 string per version of h/w.

Viresh, Giuseppe, can you please suggest a proper string for the SPEAr600 STMMAC core, including version?

Quoted 1 line

'stm' should be 'st' according to vendor-prefixes.txt.

Okay.

Quoted 10 lines

Documentation/devicetree/bindings/net/stmmac.txt line 11

Quoted 7 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +7 -0
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the STMMAC interrupts
+- interrupt-names: Should contain the interrupt names "macirq"
+  "eth_wake_irq" if this interrupt is supported in the "interrupts"
+  property

You should be able to tell this from the compatible string and number of interrupts.

Yes. Currently the driver uses platform_get_irq_byname() to register the irq's. That's why I added these properties. Is there something wrong with using it this way?

Quoted 6 lines

Documentation/devicetree/bindings/net/stmmac.txt line 14

Quoted 3 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +3 -0
+- phy-mode: String, operation mode of the PHY interface.
+  Supported values are: "mii", "rmii", "gmii", "rgmii".
+- phy-addr: MDIO address of the PHY

This is normally probed or the mdio bus is a sub-node of the MAC node. See arch/powerpc/boot/dts/mpc8377_mds.dts for an example.

Okay, I'll rework this.

Quoted 7 lines

Documentation/devicetree/bindings/net/stmmac.txt line 19

Quoted 5 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +5 -0
+
+Optional properties:
+- stm,prog-burst-len: Specify the burst length
+- stm,has-gmac: Indicates that the controller supports 1000Mbps
+- stm,has-pmt: Indicates that the controller supports power management

I think these should all be encoded by the compatible string.

You mean that by defining a specific compatible string (e.g. "st,gmac-spear600"), these settings are implicitly set? And should therefore be omitted from the dts?

Thanks,
Stefan

#3 lore raw
Quoted 33 lines · Stefan Roese

Hi Rob,

Quoted 17 lines · On Monday 12 March 2012 15:34:59 Rob Herring wrote:
Quoted 16 lines · Stefan Roese

This patch adds support to configure the STMMAC ethernet driver via device-tree instead of platform_data.

Currently, only the properties needed on SPEAr600 are provided. All other properties should be added once needed on other platforms.

Cc Giuseppe Cavallaro <[email protected]>
Cc Viresh Kumar <[email protected]>

---

 Documentation/devicetree/bindings/net/stmmac.txt   |   38 +++++++++++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   66
 +++++++++++++++++++- 2 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt
Quoted 12 lines

Documentation/devicetree/bindings/net/stmmac.txt line 4

Quoted 10 lines
(quoted diff) +0 -0

b/Documentation/devicetree/bindings/net/stmmac.txt new file mode 100644 index 0000000..386a47f

Documentation/devicetree/bindings/net/stmmac.txt new file +4 -0
@@ -0,0 +1,38 @@
+* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
+
+Required properties:
+- compatible: Should be "stm,gmac"

This is too generic. This should be 1 string per version of h/w.

Quoted 2 lines

Viresh, Giuseppe, can you please suggest a proper string for the SPEAr600 STMMAC core, including version?

IIRC this IP is the same as the sti7108

st,sti7018-gmac

as this IP has been used first on SH4

Best Regards,
J.

#4 lore raw
In reply to Stefan Roese
Quoted 33 lines · Stefan Roese

Hi Rob,

Quoted 17 lines · On Monday 12 March 2012 15:34:59 Rob Herring wrote:
Quoted 16 lines · Stefan Roese

This patch adds support to configure the STMMAC ethernet driver via device-tree instead of platform_data.

Currently, only the properties needed on SPEAr600 are provided. All other properties should be added once needed on other platforms.

Cc Giuseppe Cavallaro <[email protected]>
Cc Viresh Kumar <[email protected]>

---

 Documentation/devicetree/bindings/net/stmmac.txt   |   38 +++++++++++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   66
 +++++++++++++++++++- 2 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt
Quoted 12 lines

Documentation/devicetree/bindings/net/stmmac.txt line 4

Quoted 10 lines
(quoted diff) +0 -0

b/Documentation/devicetree/bindings/net/stmmac.txt new file mode 100644 index 0000000..386a47f

Documentation/devicetree/bindings/net/stmmac.txt new file +4 -0
@@ -0,0 +1,38 @@
+* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
+
+Required properties:
+- compatible: Should be "stm,gmac"

This is too generic. This should be 1 string per version of h/w.

Quoted 4 lines

Viresh, Giuseppe, can you please suggest a proper string for the SPEAr600 STMMAC core, including version?

Quoted 1 line

'stm' should be 'st' according to vendor-prefixes.txt.

I'm not familiar with devicetree; maybe we should have:

"stmicro,mac100"
"stmicro,gmac"

or: st instead of stmicro if you prefer.

in fact, stmmac is for mac100 and gmac devices.

Quoted 18 lines

Okay.

Quoted 10 lines

Documentation/devicetree/bindings/net/stmmac.txt line 11

Quoted 7 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +7 -0
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the STMMAC interrupts
+- interrupt-names: Should contain the interrupt names "macirq"
+  "eth_wake_irq" if this interrupt is supported in the "interrupts"
+  property

You should be able to tell this from the compatible string and number of interrupts.

Yes. Currently the driver uses platform_get_irq_byname() to register the irq's. That's why I added these properties. Is there something wrong with using it this way?

Quoted 16 lines
Quoted 6 lines

Documentation/devicetree/bindings/net/stmmac.txt line 14

Quoted 3 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +3 -0
+- phy-mode: String, operation mode of the PHY interface.
+  Supported values are: "mii", "rmii", "gmii", "rgmii".
+- phy-addr: MDIO address of the PHY

This is normally probed or the mdio bus is a sub-node of the MAC node. See arch/powerpc/boot/dts/mpc8377_mds.dts for an example.

Okay, I'll rework this.

Quoted 7 lines

Documentation/devicetree/bindings/net/stmmac.txt line 19

Quoted 5 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +5 -0
+
+Optional properties:
+- stm,prog-burst-len: Specify the burst length
+- stm,has-gmac: Indicates that the controller supports 1000Mbps
+- stm,has-pmt: Indicates that the controller supports power management

I think these should all be encoded by the compatible string.

and should we have all the other flags e.g. tx_coe etc? (see stmmac.txt)

Peppe

Quoted 12 lines

You mean that by defining a specific compatible string (e.g. "st,gmac-spear600"), these settings are implicitly set? And should therefore be omitted from the dts?

Thanks,
Stefan
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 10 lines · On Monday 12 March 2012 16:30:37 Giuseppe CAVALLARO wrote:
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

+Required properties:
+- compatible: Should be "stm,gmac"

This is too generic. This should be 1 string per version of h/w.

Viresh, Giuseppe, can you please suggest a proper string for the SPEAr600 STMMAC core, including version?

Quoted 1 line

'stm' should be 'st' according to vendor-prefixes.txt.

Quoted 8 lines

I'm not familiar with devicetree; maybe we should have:

"stmicro,mac100"
"stmicro,gmac"

or: st instead of stmicro if you prefer.

in fact, stmmac is for mac100 and gmac devices.

How about "st,spear600-gmac" for SPEAr600 then?

Quoted 34 lines
Quoted 17 lines

Okay.

Quoted 10 lines

Documentation/devicetree/bindings/net/stmmac.txt line 11

Quoted 7 lines
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
Documentation/devicetree/bindings/net/stmmac.txt new file +5 -0
+  that services interrupts for this device
+- interrupts: Should contain the STMMAC interrupts
+- interrupt-names: Should contain the interrupt names "macirq"
+  "eth_wake_irq" if this interrupt is supported in the "interrupts"
+  property

You should be able to tell this from the compatible string and number of interrupts.

Yes. Currently the driver uses platform_get_irq_byname() to register the irq's. That's why I added these properties. Is there something wrong with using it this way?

Quoted 16 lines
Quoted 6 lines
Quoted 3 lines
+- phy-mode: String, operation mode of the PHY interface.
+  Supported values are: "mii", "rmii", "gmii", "rgmii".
+- phy-addr: MDIO address of the PHY

This is normally probed or the mdio bus is a sub-node of the MAC node. See arch/powerpc/boot/dts/mpc8377_mds.dts for an example.

Okay, I'll rework this.

Quoted 7 lines

Documentation/devicetree/bindings/net/stmmac.txt line 19

Quoted 5 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +5 -0
+
+Optional properties:
+- stm,prog-burst-len: Specify the burst length
+- stm,has-gmac: Indicates that the controller supports 1000Mbps
+- stm,has-pmt: Indicates that the controller supports power management

I think these should all be encoded by the compatible string.

Quoted 2 lines

and should we have all the other flags e.g. tx_coe etc? (see stmmac.txt)

As Rob suggested, some of these flags/parameters are implicitly defined by the compatible string. If this is not the case, then sure, those flags/parameters need to be provided via the device-tree as well. I just don't need "tx_coe" etc. for my platform (SPEAr600) as far as I know. I suggest to add support for them once they are really needed/used by other platforms.

Thanks,
Stefan

#6 lore raw
Quoted 13 lines · Stefan Roese
Quoted 12 lines · On Monday 12 March 2012 16:30:37 Giuseppe CAVALLARO wrote:
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

+Required properties:
+- compatible: Should be "stm,gmac"

This is too generic. This should be 1 string per version of h/w.

Viresh, Giuseppe, can you please suggest a proper string for the SPEAr600 STMMAC core, including version?

Quoted 1 line

'stm' should be 'st' according to vendor-prefixes.txt.

I'm not familiar with devicetree; maybe we should have:

Quoted 8 lines
Quoted 6 lines

"stmicro,mac100"
"stmicro,gmac"

or: st instead of stmicro if you prefer.

in fact, stmmac is for mac100 and gmac devices.

How about "st,spear600-gmac" for SPEAr600 then?

IIUC, as final result we should have something like this... that sounds quite good to me.

ST/ARM SPEAr
"st,spear600-gmac"
"st,spear1310-gmac"
...

ST/SH

"st,stx7108-gmac"
"st,stx7106-gmac"
"st,stx7109-mac" ->>> mac10/100
...

MIPS
"st,Loongson1B"

Quoted 35 lines
Quoted 35 lines
Quoted 34 lines

Okay.

Quoted 10 lines

Documentation/devicetree/bindings/net/stmmac.txt line 11

Quoted 7 lines
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
Documentation/devicetree/bindings/net/stmmac.txt new file +5 -0
+  that services interrupts for this device
+- interrupts: Should contain the STMMAC interrupts
+- interrupt-names: Should contain the interrupt names "macirq"
+  "eth_wake_irq" if this interrupt is supported in the "interrupts"
+  property

You should be able to tell this from the compatible string and number of interrupts.

Yes. Currently the driver uses platform_get_irq_byname() to register the irq's. That's why I added these properties. Is there something wrong with using it this way?

Quoted 6 lines
Quoted 3 lines
+- phy-mode: String, operation mode of the PHY interface.
+  Supported values are: "mii", "rmii", "gmii", "rgmii".
+- phy-addr: MDIO address of the PHY

This is normally probed or the mdio bus is a sub-node of the MAC node. See arch/powerpc/boot/dts/mpc8377_mds.dts for an example.

Okay, I'll rework this.

Quoted 7 lines

Documentation/devicetree/bindings/net/stmmac.txt line 19

Quoted 5 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +5 -0
+
+Optional properties:
+- stm,prog-burst-len: Specify the burst length
+- stm,has-gmac: Indicates that the controller supports 1000Mbps
+- stm,has-pmt: Indicates that the controller supports power management

I think these should all be encoded by the compatible string.

Quoted 8 lines
Quoted 2 lines

and should we have all the other flags e.g. tx_coe etc? (see stmmac.txt)

As Rob suggested, some of these flags/parameters are implicitly defined by the compatible string. If this is not the case, then sure, those flags/parameters need to be provided via the device-tree as well. I just don't need "tx_coe" etc. for my platform (SPEAr600) as far as I know. I suggest to add support for them once they are really needed/used by other platforms.

Ok, but on SPEAr indeed some of these are not used at all. If you agree, we can go head with these and then we will add new ones next time. In the meantime, I will try to be more familiar with devicetree and provide further patches

peppe

Quoted 8 lines

Thanks,
Stefan
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw
Quoted 33 lines · Giuseppe CAVALLARO
Quoted 13 lines · Stefan Roese
Quoted 12 lines · On Monday 12 March 2012 16:30:37 Giuseppe CAVALLARO wrote:
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

+Required properties:
+- compatible: Should be "stm,gmac"

This is too generic. This should be 1 string per version of h/w.

Viresh, Giuseppe, can you please suggest a proper string for the SPEAr600 STMMAC core, including version?

Quoted 1 line

'stm' should be 'st' according to vendor-prefixes.txt.

I'm not familiar with devicetree; maybe we should have:

Quoted 8 lines
Quoted 6 lines

"stmicro,mac100"
"stmicro,gmac"

or: st instead of stmicro if you prefer.

in fact, stmmac is for mac100 and gmac devices.

How about "st,spear600-gmac" for SPEAr600 then?

IIUC, as final result we should have something like this... that sounds quite good to me.

ST/ARM SPEAr
"st,spear600-gmac"
"st,spear1310-gmac"
...

ST/SH

Quoted 8 lines

"st,stx7108-gmac"
"st,stx7106-gmac"
"st,stx7109-mac" ->>> mac10/100
...

MIPS
"st,Loongson1B"

This seems fine to me.

Rob

Quoted 60 lines
Quoted 35 lines
Quoted 35 lines
Quoted 34 lines

Okay.

Quoted 10 lines

Documentation/devicetree/bindings/net/stmmac.txt line 11

Quoted 7 lines
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
Documentation/devicetree/bindings/net/stmmac.txt new file +5 -0
+  that services interrupts for this device
+- interrupts: Should contain the STMMAC interrupts
+- interrupt-names: Should contain the interrupt names "macirq"
+  "eth_wake_irq" if this interrupt is supported in the "interrupts"
+  property

You should be able to tell this from the compatible string and number of interrupts.

Yes. Currently the driver uses platform_get_irq_byname() to register the irq's. That's why I added these properties. Is there something wrong with using it this way?

Quoted 6 lines
Quoted 3 lines
+- phy-mode: String, operation mode of the PHY interface.
+  Supported values are: "mii", "rmii", "gmii", "rgmii".
+- phy-addr: MDIO address of the PHY

This is normally probed or the mdio bus is a sub-node of the MAC node. See arch/powerpc/boot/dts/mpc8377_mds.dts for an example.

Okay, I'll rework this.

Quoted 7 lines

Documentation/devicetree/bindings/net/stmmac.txt line 19

Quoted 5 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +5 -0
+
+Optional properties:
+- stm,prog-burst-len: Specify the burst length
+- stm,has-gmac: Indicates that the controller supports 1000Mbps
+- stm,has-pmt: Indicates that the controller supports power management

I think these should all be encoded by the compatible string.

Quoted 8 lines
Quoted 2 lines

and should we have all the other flags e.g. tx_coe etc? (see stmmac.txt)

As Rob suggested, some of these flags/parameters are implicitly defined by the compatible string. If this is not the case, then sure, those flags/parameters need to be provided via the device-tree as well. I just don't need "tx_coe" etc. for my platform (SPEAr600) as far as I know. I suggest to add support for them once they are really needed/used by other platforms.

Ok, but on SPEAr indeed some of these are not used at all. If you agree, we can go head with these and then we will add new ones next time. In the meantime, I will try to be more familiar with devicetree and provide further patches

peppe

Quoted 8 lines

Thanks,
Stefan
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw
In reply to Giuseppe CAVALLARO
Quoted 37 lines · Giuseppe CAVALLARO
Quoted 36 lines · Stefan Roese

Hi Rob,

Quoted 17 lines · On Monday 12 March 2012 15:34:59 Rob Herring wrote:
Quoted 16 lines · Stefan Roese

This patch adds support to configure the STMMAC ethernet driver via device-tree instead of platform_data.

Currently, only the properties needed on SPEAr600 are provided. All other properties should be added once needed on other platforms.

Cc Giuseppe Cavallaro <[email protected]>
Cc Viresh Kumar <[email protected]>

---

 Documentation/devicetree/bindings/net/stmmac.txt   |   38 +++++++++++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   66
 +++++++++++++++++++- 2 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt
Quoted 12 lines

Documentation/devicetree/bindings/net/stmmac.txt line 4

Quoted 10 lines
(quoted diff) +0 -0

b/Documentation/devicetree/bindings/net/stmmac.txt new file mode 100644 index 0000000..386a47f

Documentation/devicetree/bindings/net/stmmac.txt new file +4 -0
@@ -0,0 +1,38 @@
+* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
+
+Required properties:
+- compatible: Should be "stm,gmac"

This is too generic. This should be 1 string per version of h/w.

Viresh, Giuseppe, can you please suggest a proper string for the SPEAr600 STMMAC core, including version?

Quoted 8 lines
Quoted 1 line
Quoted 1 line

'stm' should be 'st' according to vendor-prefixes.txt.

I'm not familiar with devicetree; maybe we should have:

"stmicro,mac100"
"stmicro,gmac"

or: st instead of stmicro if you prefer.

you need to put the first soc where the ip appear on gmac it's sti7105

but with PM IIRC it's sti7108

Best Regards,
J.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw
Quoted 21 lines · Stefan Roese

This patch adds support to configure the STMMAC ethernet driver via device-tree instead of platform_data.

Currently, only the properties needed on SPEAr600 are provided. All other properties should be added once needed on other platforms.

Cc Giuseppe Cavallaro <[email protected]>
Cc Viresh Kumar <[email protected]>
---
 Documentation/devicetree/bindings/net/stmmac.txt   |   38 +++++++++++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   66 +++++++++++++++++++-
 2 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt
Documentation/devicetree/bindings/net/stmmac.txt new file +0 -0
new file mode 100644
index 0000000..386a47f

Documentation/devicetree/bindings/net/stmmac.txt line 4

Quoted 4 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +4 -0
@@ -0,0 +1,38 @@
+* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
+
+Required properties:
+- compatible: Should be "stm,gmac"

this IP have 2 version at least the GMAC for the second generation and mac for the first generation

Documentation/devicetree/bindings/net/stmmac.txt line 11

Quoted 7 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +7 -0
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the STMMAC interrupts
+- interrupt-names: Should contain the interrupt names "macirq"
+  "eth_wake_irq" if this interrupt is supported in the "interrupts"
+  property

optionnal

Documentation/devicetree/bindings/net/stmmac.txt line 18

Quoted 7 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +7 -0
+- phy-mode: String, operation mode of the PHY interface.
+  Supported values are: "mii", "rmii", "gmii", "rgmii".
+- phy-addr: MDIO address of the PHY
+
+Optional properties:
+- stm,prog-burst-len: Specify the burst length
+- stm,has-gmac: Indicates that the controller supports 1000Mbps

this IP support more mode 10/100/300/1000

Quoted 88 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +20 -0
+- stm,has-pmt: Indicates that the controller supports power management
+- mac-address: 6 bytes, mac address
+
+Examples:
+
+	gmac0: stmmac at e0800000 {
+		compatible = "stm,gmac";
+		reg = <0xe0800000 0x8000>;
+		interrupt-parent = <&vic1>;
+		interrupts = <24 23>;
+		interrupt-names = "macirq", "eth_wake_irq";
+		mac-address = [000000000000]; /* Filled in by U-Boot */
+
+		stm,prog-burst-len = <8>;
+		stm,has-gmac;
+		stm,has-pmt;
+
+		phy-mode = "gmii";
+		phy-addr = <0>;
+	};
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +43 -1
index 3aad981..fcf46c7 100644
@@ -24,8 +24,43 @@
 
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_net.h>
 #include "stmmac.h"
 
+#ifdef CONFIG_OF
+static int __devinit stmmac_probe_config_dt(struct platform_device *pdev,
+					    struct plat_stmmacenet_data *plat,
+					    const char **mac)
+{
+	struct device_node *np = pdev->dev.of_node;
+
+	if (!np)
+		return -ENODEV;
+
+	*mac = of_get_mac_address(np);
+
+	plat->interface = of_get_phy_mode(np);
+	of_property_read_u32(np, "phy-addr", &plat->phy_addr);
+	plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
+					   sizeof(struct stmmac_mdio_bus_data),
+					   GFP_KERNEL);
+
+	/*
+	 * Currently only the properties needed on SPEAr600
+	 * are provided. All other properties should be added
+	 * once needed on other platforms.
+	 */
+	of_property_read_u32(np, "stm,prog-burst-len", &plat->pbl);
+	if (of_get_property(np, "stm,has-gmac", NULL))
+		plat->has_gmac = 1;
+	if (of_get_property(np, "stm,has-pmt", NULL))
+		plat->pmt = 1;
+
+	return 0;
+}
+#endif /* CONFIG_OF */
+
 /**
  * stmmac_pltfr_probe
  * @pdev: platform device pointer
@@ -39,7 +74,8 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 	struct resource *res;
 	void __iomem *addr = NULL;
 	struct stmmac_priv *priv = NULL;
-	struct plat_stmmacenet_data *plat_dat;
+	struct plat_stmmacenet_data *plat_dat = NULL;
+	const char *mac = NULL;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res)
@@ -58,6 +94,22 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 		ret = -ENOMEM;
 		goto out_release_region;
 	}
+
+#ifdef CONFIG_OF
+	plat_dat = devm_kzalloc(&pdev->dev, sizeof(struct plat_stmmacenet_data),
+				GFP_KERNEL);
+	if (!plat_dat) {
+		pr_err("%s: ERROR: no memory", __func__);

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c static int stmmac_pltfr_probe(struct platform_device *pdev) · line 112

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +10 -0
+		ret = -ENOMEM;
+		goto out_unmap;
+	}
+
+	ret = stmmac_probe_config_dt(pdev, plat_dat, &mac);
+	if (ret) {
+		pr_err("%s: main dt probe failed", __func__);
+		goto out_unmap;
+	}
+#else

This must be check at runtime, we can boot a kernel with or without DT.

Best Reards,
J.

Quoted 50 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +12 -0
 	plat_dat = pdev->dev.platform_data;
 
 	/* Custom initialisation (if needed)*/
@@ -66,6 +118,7 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 		if (unlikely(ret))
 			goto out_unmap;
 	}
+#endif
 
 	priv = stmmac_dvr_probe(&(pdev->dev), plat_dat, addr);
 	if (!priv) {
@@ -73,6 +126,10 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 		goto out_unmap;
 	}
 
+	/* Get MAC address if available (DT) */
+	if (mac)
+		memcpy(priv->dev->dev_addr, mac, ETH_ALEN);
+
 	/* Get the MAC information */
 	priv->dev->irq = platform_get_irq_byname(pdev, "macirq");
 	if (priv->dev->irq == -ENXIO) {
@@ -178,6 +235,12 @@ static const struct dev_pm_ops stmmac_pltfr_pm_ops = {
 static const struct dev_pm_ops stmmac_pltfr_pm_ops;
 #endif /* CONFIG_PM */
 
+static const struct of_device_id stmmac_dt_ids[] = {
+	{ .compatible = "stm,gmac", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
+
 static struct platform_driver stmmac_driver = {
 	.probe = stmmac_pltfr_probe,
 	.remove = stmmac_pltfr_remove,
@@ -185,6 +248,7 @@ static struct platform_driver stmmac_driver = {
 		   .name = STMMAC_RESOURCE_NAME,
 		   .owner = THIS_MODULE,
 		   .pm = &stmmac_pltfr_pm_ops,
+		   .of_match_table = of_match_ptr(stmmac_dt_ids),
 		   },
 };
 
Signature · 6 lines
1.7.9.2

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw
Quoted 18 lines · On Monday 12 March 2012 15:38:25 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 18 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +3 -0
@@ -58,6 +94,22 @@ static int stmmac_pltfr_probe(struct platform_device
 *pdev)
 
 		ret = -ENOMEM;
 		goto out_release_region;
 
 	}
 
+
+#ifdef CONFIG_OF
+	plat_dat = devm_kzalloc(&pdev->dev, sizeof(struct

plat_stmmacenet_data), + GFP_KERNEL);

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +6 -0
+	if (!plat_dat) {
+		pr_err("%s: ERROR: no memory", __func__);
+		ret = -ENOMEM;
+		goto out_unmap;
+	}
+
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c static int stmmac_pltfr_probe(struct platform_device *pdev) · line 112

Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +6 -0
+	ret = stmmac_probe_config_dt(pdev, plat_dat, &mac);
+	if (ret) {
+		pr_err("%s: main dt probe failed", __func__);
+		goto out_unmap;
+	}
+#else

This must be check at runtime, we can boot a kernel with or without DT.

Are you referring to using "if (pdev->dev.of_node)" to distinguish between DT and non-DT version instead of this #ifdef?

Thanks,
Stefan

#12 lore raw
Quoted 28 lines · Stefan Roese
Quoted 18 lines · On Monday 12 March 2012 15:38:25 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 18 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +3 -0
@@ -58,6 +94,22 @@ static int stmmac_pltfr_probe(struct platform_device
 *pdev)
 
 		ret = -ENOMEM;
 		goto out_release_region;
 
 	}
 
+
+#ifdef CONFIG_OF
+	plat_dat = devm_kzalloc(&pdev->dev, sizeof(struct

plat_stmmacenet_data), + GFP_KERNEL);

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +6 -0
+	if (!plat_dat) {
+		pr_err("%s: ERROR: no memory", __func__);
+		ret = -ENOMEM;
+		goto out_unmap;
+	}
+
Quoted 8 lines

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c static int stmmac_pltfr_probe(struct platform_device *pdev) · line 112

Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +6 -0
+	ret = stmmac_probe_config_dt(pdev, plat_dat, &mac);
+	if (ret) {
+		pr_err("%s: main dt probe failed", __func__);
+		goto out_unmap;
+	}
+#else

This must be check at runtime, we can boot a kernel with or without DT.

Quoted 2 lines

Are you referring to using "if (pdev->dev.of_node)" to distinguish between DT and non-DT version instead of this #ifdef?

yes

Best Regards,
J.

#13 lore raw
In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 16 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 15 lines · Stefan Roese

This patch adds support to configure the STMMAC ethernet driver via device-tree instead of platform_data.

Currently, only the properties needed on SPEAr600 are provided. All other properties should be added once needed on other platforms.

Cc Giuseppe Cavallaro <[email protected]>
Cc Viresh Kumar <[email protected]>
---
 Documentation/devicetree/bindings/net/stmmac.txt   |   38 +++++++++++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   66 +++++++++++++++++++-
 2 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt
Quoted 13 lines

Documentation/devicetree/bindings/net/stmmac.txt line 4

Quoted 10 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +4 -0
new file mode 100644
index 0000000..386a47f
@@ -0,0 +1,38 @@
+* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
+
+Required properties:
+- compatible: Should be "stm,gmac"

this IP have 2 version at least the GMAC for the second generation and mac for the first generation

yes you are right. STMMAC supports two device generations I named:
dwma10/100 and dwmac1000 (gmac).

Concerning the latter, we support several different versions of the synopsys GMAC cores ... from 3.30 to 3.61a.

For example, stx7108 and Stx7109 have the same GMAC core (also SPEAr600 IIRC).
SPEAr13xx has 3.50a
New ST SoC Stxh415 has the 3.60a. etc.

Quoted 8 lines

Documentation/devicetree/bindings/net/stmmac.txt line 11

Quoted 7 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +7 -0
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the STMMAC interrupts
+- interrupt-names: Should contain the interrupt names "macirq"
+  "eth_wake_irq" if this interrupt is supported in the "interrupts"
+  property

optionnal

yes

note that there will be a new field for lpi IRQ as well

Quoted 8 lines

Documentation/devicetree/bindings/net/stmmac.txt line 18

Quoted 7 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +7 -0
+- phy-mode: String, operation mode of the PHY interface.
+  Supported values are: "mii", "rmii", "gmii", "rgmii".
+- phy-addr: MDIO address of the PHY
+
+Optional properties:
+- stm,prog-burst-len: Specify the burst length
+- stm,has-gmac: Indicates that the controller supports 1000Mbps

this IP support more mode 10/100/300/1000

has_gmac was used to understand on devices w/o the HW cap registers if the core is a gmac... another useful parameter could be : enh_desc

In fact, there are several possible HW configurations:

gmac core + enh desc
gmac core + norm_desc
mac core + norm_des

...

W/o cap register (present in new cores newer than 3.50) we need to pass this info from the plt.

Quoted 157 lines
Quoted 88 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +20 -0
+- stm,has-pmt: Indicates that the controller supports power management
+- mac-address: 6 bytes, mac address
+
+Examples:
+
+	gmac0: stmmac at e0800000 {
+		compatible = "stm,gmac";
+		reg = <0xe0800000 0x8000>;
+		interrupt-parent = <&vic1>;
+		interrupts = <24 23>;
+		interrupt-names = "macirq", "eth_wake_irq";
+		mac-address = [000000000000]; /* Filled in by U-Boot */
+
+		stm,prog-burst-len = <8>;
+		stm,has-gmac;
+		stm,has-pmt;
+
+		phy-mode = "gmii";
+		phy-addr = <0>;
+	};
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +43 -1
index 3aad981..fcf46c7 100644
@@ -24,8 +24,43 @@
 
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_net.h>
 #include "stmmac.h"
 
+#ifdef CONFIG_OF
+static int __devinit stmmac_probe_config_dt(struct platform_device *pdev,
+					    struct plat_stmmacenet_data *plat,
+					    const char **mac)
+{
+	struct device_node *np = pdev->dev.of_node;
+
+	if (!np)
+		return -ENODEV;
+
+	*mac = of_get_mac_address(np);
+
+	plat->interface = of_get_phy_mode(np);
+	of_property_read_u32(np, "phy-addr", &plat->phy_addr);
+	plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
+					   sizeof(struct stmmac_mdio_bus_data),
+					   GFP_KERNEL);
+
+	/*
+	 * Currently only the properties needed on SPEAr600
+	 * are provided. All other properties should be added
+	 * once needed on other platforms.
+	 */
+	of_property_read_u32(np, "stm,prog-burst-len", &plat->pbl);
+	if (of_get_property(np, "stm,has-gmac", NULL))
+		plat->has_gmac = 1;
+	if (of_get_property(np, "stm,has-pmt", NULL))
+		plat->pmt = 1;
+
+	return 0;
+}
+#endif /* CONFIG_OF */
+
 /**
  * stmmac_pltfr_probe
  * @pdev: platform device pointer
@@ -39,7 +74,8 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 	struct resource *res;
 	void __iomem *addr = NULL;
 	struct stmmac_priv *priv = NULL;
-	struct plat_stmmacenet_data *plat_dat;
+	struct plat_stmmacenet_data *plat_dat = NULL;
+	const char *mac = NULL;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res)
@@ -58,6 +94,22 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 		ret = -ENOMEM;
 		goto out_release_region;
 	}
+
+#ifdef CONFIG_OF
+	plat_dat = devm_kzalloc(&pdev->dev, sizeof(struct plat_stmmacenet_data),
+				GFP_KERNEL);
+	if (!plat_dat) {
+		pr_err("%s: ERROR: no memory", __func__);

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c static int stmmac_pltfr_probe(struct platform_device *pdev) · line 112

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +10 -0
+		ret = -ENOMEM;
+		goto out_unmap;
+	}
+
+	ret = stmmac_probe_config_dt(pdev, plat_dat, &mac);
+	if (ret) {
+		pr_err("%s: main dt probe failed", __func__);
+		goto out_unmap;
+	}
+#else

This must be check at runtime, we can boot a kernel with or without DT.

Best Reards,
J.

Quoted 50 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +12 -0
 	plat_dat = pdev->dev.platform_data;
 
 	/* Custom initialisation (if needed)*/
@@ -66,6 +118,7 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 		if (unlikely(ret))
 			goto out_unmap;
 	}
+#endif
 
 	priv = stmmac_dvr_probe(&(pdev->dev), plat_dat, addr);
 	if (!priv) {
@@ -73,6 +126,10 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 		goto out_unmap;
 	}
 
+	/* Get MAC address if available (DT) */
+	if (mac)
+		memcpy(priv->dev->dev_addr, mac, ETH_ALEN);
+
 	/* Get the MAC information */
 	priv->dev->irq = platform_get_irq_byname(pdev, "macirq");
 	if (priv->dev->irq == -ENXIO) {
@@ -178,6 +235,12 @@ static const struct dev_pm_ops stmmac_pltfr_pm_ops = {
 static const struct dev_pm_ops stmmac_pltfr_pm_ops;
 #endif /* CONFIG_PM */
 
+static const struct of_device_id stmmac_dt_ids[] = {
+	{ .compatible = "stm,gmac", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
+
 static struct platform_driver stmmac_driver = {
 	.probe = stmmac_pltfr_probe,
 	.remove = stmmac_pltfr_remove,
@@ -185,6 +248,7 @@ static struct platform_driver stmmac_driver = {
 		   .name = STMMAC_RESOURCE_NAME,
 		   .owner = THIS_MODULE,
 		   .pm = &stmmac_pltfr_pm_ops,
+		   .of_match_table = of_match_ptr(stmmac_dt_ids),
 		   },
 };
 
Signature · 6 lines
1.7.9.2

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

#14 lore raw
Quoted 34 lines · Giuseppe CAVALLARO
Quoted 16 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 15 lines · Stefan Roese

This patch adds support to configure the STMMAC ethernet driver via device-tree instead of platform_data.

Currently, only the properties needed on SPEAr600 are provided. All other properties should be added once needed on other platforms.

Cc Giuseppe Cavallaro <[email protected]>
Cc Viresh Kumar <[email protected]>
---
 Documentation/devicetree/bindings/net/stmmac.txt   |   38 +++++++++++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   66 +++++++++++++++++++-
 2 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt
Quoted 13 lines

Documentation/devicetree/bindings/net/stmmac.txt line 4

Quoted 10 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +4 -0
new file mode 100644
index 0000000..386a47f
@@ -0,0 +1,38 @@
+* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
+
+Required properties:
+- compatible: Should be "stm,gmac"

this IP have 2 version at least the GMAC for the second generation and mac for the first generation

yes you are right. STMMAC supports two device generations I named:
dwma10/100 and dwmac1000 (gmac).

Quoted 7 lines

Concerning the latter, we support several different versions of the synopsys GMAC cores ... from 3.30 to 3.61a.

For example, stx7108 and Stx7109 have the same GMAC core (also SPEAr600 IIRC).
SPEAr13xx has 3.50a
New ST SoC Stxh415 has the 3.60a. etc.

In that case, you should definitely list the exact device versions in the compatible string, like:

compatible = "stm,spear600-gmac", "snps,dw-gmac-3.50a", "snps,dw-gmac";

When we have other socs with the same version, that lets us add quirks for the specific version by checking the compatible property once in the driver.

It also sounds to me that the entire stmmac driver should live in the drivers/net/ethernet/synopsys directory, not stmicro, but that is a different issue.

Arnd

#15 lore raw
Quoted 43 lines · Arnd Bergmann
Quoted 34 lines · Giuseppe CAVALLARO
Quoted 16 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 15 lines · Stefan Roese

This patch adds support to configure the STMMAC ethernet driver via device-tree instead of platform_data.

Currently, only the properties needed on SPEAr600 are provided. All other properties should be added once needed on other platforms.

Cc Giuseppe Cavallaro <[email protected]>
Cc Viresh Kumar <[email protected]>
---
 Documentation/devicetree/bindings/net/stmmac.txt   |   38 +++++++++++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   66 +++++++++++++++++++-
 2 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt
Quoted 13 lines

Documentation/devicetree/bindings/net/stmmac.txt line 4

Quoted 10 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +4 -0
new file mode 100644
index 0000000..386a47f
@@ -0,0 +1,38 @@
+* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
+
+Required properties:
+- compatible: Should be "stm,gmac"

this IP have 2 version at least the GMAC for the second generation and mac for the first generation

yes you are right. STMMAC supports two device generations I named:
dwma10/100 and dwmac1000 (gmac).

Quoted 7 lines

Concerning the latter, we support several different versions of the synopsys GMAC cores ... from 3.30 to 3.61a.

For example, stx7108 and Stx7109 have the same GMAC core (also SPEAr600 IIRC).
SPEAr13xx has 3.50a
New ST SoC Stxh415 has the 3.60a. etc.

Quoted 4 lines

In that case, you should definitely list the exact device versions in the compatible string, like:

compatible = "stm,spear600-gmac", "snps,dw-gmac-3.50a", "snps,dw-gmac";

looks good to me

Quoted 9 lines

When we have other socs with the same version, that lets us add quirks for the specific version by checking the compatible property once in the driver.

It also sounds to me that the entire stmmac driver should live in the drivers/net/ethernet/synopsys directory, not stmicro, but that is a different issue.

I had also proposed to rename it from stmmac to synmac.

peppe

Quoted 6 lines

Arnd
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

#16 lore raw
Quoted 8 lines · On Wednesday 14 March 2012 14:16:56 Giuseppe CAVALLARO wrote:
Quoted 8 lines
Quoted 7 lines

Concerning the latter, we support several different versions of the synopsys GMAC cores ... from 3.30 to 3.61a.

For example, stx7108 and Stx7109 have the same GMAC core (also SPEAr600 IIRC).
SPEAr13xx has 3.50a
New ST SoC Stxh415 has the 3.60a. etc.

Quoted 6 lines
Quoted 4 lines

In that case, you should definitely list the exact device versions in the compatible string, like:

compatible = "stm,spear600-gmac", "snps,dw-gmac-3.50a", "snps,dw-gmac";

looks good to me

So whats the Synopsys version for SPEAr600?

"snps,dw-gmac-3.50a" ???

Perhaps you should add this info for all supported SoC's into the device driver? Or even better into the devicetree bindings Documentation?

Thanks,
Stefan

#17 lore raw
In reply to Giuseppe CAVALLARO
Quoted 31 lines · Giuseppe CAVALLARO
Quoted 16 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 15 lines · Stefan Roese

This patch adds support to configure the STMMAC ethernet driver via device-tree instead of platform_data.

Currently, only the properties needed on SPEAr600 are provided. All other properties should be added once needed on other platforms.

Cc Giuseppe Cavallaro <[email protected]>
Cc Viresh Kumar <[email protected]>
---
 Documentation/devicetree/bindings/net/stmmac.txt   |   38 +++++++++++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   66 +++++++++++++++++++-
 2 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt
Quoted 13 lines

Documentation/devicetree/bindings/net/stmmac.txt line 4

Quoted 10 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +4 -0
new file mode 100644
index 0000000..386a47f
@@ -0,0 +1,38 @@
+* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
+
+Required properties:
+- compatible: Should be "stm,gmac"

this IP have 2 version at least the GMAC for the second generation and mac for the first generation

Quoted 8 lines

yes you are right. STMMAC supports two device generations I named:
dwma10/100 and dwmac1000 (gmac).

Concerning the latter, we support several different versions of the synopsys GMAC cores ... from 3.30 to 3.61a.

For example, stx7108 and Stx7109 have the same GMAC core (also SPEAr600 IIRC).

no PM the PM was only since 7108 IIRC

7109 use mac not gmac IIRC it's 7105 that start to use the GMAC with 300Mbps max

Quoted 25 lines

SPEAr13xx has 3.50a
New ST SoC Stxh415 has the 3.60a. etc.

Quoted 8 lines

Documentation/devicetree/bindings/net/stmmac.txt line 11

Quoted 7 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +7 -0
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the STMMAC interrupts
+- interrupt-names: Should contain the interrupt names "macirq"
+  "eth_wake_irq" if this interrupt is supported in the "interrupts"
+  property

optionnal

yes

note that there will be a new field for lpi IRQ as well

Quoted 8 lines

Documentation/devicetree/bindings/net/stmmac.txt line 18

Quoted 7 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +7 -0
+- phy-mode: String, operation mode of the PHY interface.
+  Supported values are: "mii", "rmii", "gmii", "rgmii".
+- phy-addr: MDIO address of the PHY
+
+Optional properties:
+- stm,prog-burst-len: Specify the burst length
+- stm,has-gmac: Indicates that the controller supports 1000Mbps

this IP support more mode 10/100/300/1000

Quoted 2 lines

has_gmac was used to understand on devices w/o the HW cap registers if the core is a gmac... another useful parameter could be : enh_desc

this need to manage via compatible

Best Regards,
J.

#18 lore raw
Quoted 35 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 34 lines · Giuseppe CAVALLARO
Quoted 16 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 15 lines · Stefan Roese

This patch adds support to configure the STMMAC ethernet driver via device-tree instead of platform_data.

Currently, only the properties needed on SPEAr600 are provided. All other properties should be added once needed on other platforms.

Cc Giuseppe Cavallaro <[email protected]>
Cc Viresh Kumar <[email protected]>
---
 Documentation/devicetree/bindings/net/stmmac.txt   |   38 +++++++++++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   66 +++++++++++++++++++-
 2 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt
Quoted 13 lines

Documentation/devicetree/bindings/net/stmmac.txt line 4

Quoted 10 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +4 -0
new file mode 100644
index 0000000..386a47f
@@ -0,0 +1,38 @@
+* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
+
+Required properties:
+- compatible: Should be "stm,gmac"

this IP have 2 version at least the GMAC for the second generation and mac for the first generation

yes you are right. STMMAC supports two device generations I named:
dwma10/100 and dwmac1000 (gmac).

Quoted 6 lines
Quoted 5 lines

Concerning the latter, we support several different versions of the synopsys GMAC cores ... from 3.30 to 3.61a.

For example, stx7108 and Stx7109 have the same GMAC core (also SPEAr600 IIRC).

no PM the PM was only since 7108 IIRC

Sorry! you are right :-)

7109 has the mac10/100 (databook 1.91) and 7105/8 have the gmac databook 3.30.

peppe

Quoted 35 lines

7109 use mac not gmac IIRC it's 7105 that start to use the GMAC with 300Mbps max

Quoted 25 lines

SPEAr13xx has 3.50a
New ST SoC Stxh415 has the 3.60a. etc.

Quoted 8 lines

Documentation/devicetree/bindings/net/stmmac.txt line 11

Quoted 7 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +7 -0
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the STMMAC interrupts
+- interrupt-names: Should contain the interrupt names "macirq"
+  "eth_wake_irq" if this interrupt is supported in the "interrupts"
+  property

optionnal

yes

note that there will be a new field for lpi IRQ as well

Quoted 8 lines

Documentation/devicetree/bindings/net/stmmac.txt line 18

Quoted 7 lines
Documentation/devicetree/bindings/net/stmmac.txt new file +7 -0
+- phy-mode: String, operation mode of the PHY interface.
+  Supported values are: "mii", "rmii", "gmii", "rgmii".
+- phy-addr: MDIO address of the PHY
+
+Optional properties:
+- stm,prog-burst-len: Specify the burst length
+- stm,has-gmac: Indicates that the controller supports 1000Mbps

this IP support more mode 10/100/300/1000

Quoted 2 lines

has_gmac was used to understand on devices w/o the HW cap registers if the core is a gmac... another useful parameter could be : enh_desc

this need to manage via compatible

Best Regards,
J.