Skip to contentSkip to conversation

cpsw: enable DM_ETH on dra74 and am437x evms

PATCH Superseded Mugunthan V N 4 participants 29 messages Apr 7, 2016 – Apr 12, 2016

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover cpsw: enable DM_ETH on dra74 and am437x evms

This series adds the following
* Enable DM_ETH on dra74, am437x gp and am437x sk evms.
* Add support to verify of_is_device_conpatible() based on linux implementation
* Fix an issue in fdtdec get addr for address and size cell length

Pushed a branch for others for testing [1] and logs at [2]

[1] - git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git cpsw
[2] - http://pastebin.ubuntu.com/15671145/

Mugunthan V N (11):
drivers: core: device: add support to check dt compatible for a
device/machine
lib: fdtdec: fix size cell and address cell parse from DT
ti_omap5_common: eth: do not define DM_ETH for spl
drivers: net: cpsw: fix cpsw dp parse when num slaves as 1
ARM: omap5: add platform specific ethernet phy modes configurations
drivers: net: cpsw: add support for reading mac address from efuse
arm: dts: am4372: add syscon node to cpsw to read mac address
arm: dts: dra7: add syscon node to cpsw to read mac address
defconfig: am437x_gp_evm: enable eth driver model
defconfig: am437x_sk_evm: enable eth driver model
defconfig: dra74_evm: enable eth driver model

 arch/arm/dts/am4372.dtsi              |   1 +
 arch/arm/dts/dra7.dtsi                |   1 +
 arch/arm/include/asm/arch-omap5/cpu.h |  12 ++++
 configs/am437x_gp_evm_defconfig       |   1 +
 configs/am437x_sk_evm_defconfig       |   1 +
 configs/dra74_evm_defconfig           |   1 +
 drivers/core/device.c                 |  27 ++++++++
 drivers/net/Makefile                  |   2 +-
 drivers/net/cpsw-common.c             | 121 ++++++++++++++++++++++++++++++++++
 drivers/net/cpsw.c                    |  30 +++------
 include/configs/ti_omap5_common.h     |   1 +
 include/cpsw.h                        |   1 +
 include/dm/device.h                   |  23 +++++++
 lib/fdtdec.c                          |   9 ++-
 14 files changed, 208 insertions(+), 23 deletions(-)
 create mode 100644 drivers/net/cpsw-common.c
Signature · 1 line
2.8.1.101.g72d917a
#1 lore raw

PATCH 1/11 drivers: core: device: add support to check dt compatible for a device/machine

Provide an api to check whether the given device or machine is compatible with the given compat string which helps in making decisions in drivers based on device or machine compatible.

Idea taken from Linux.

---
 drivers/core/device.c | 27 +++++++++++++++++++++++++++
 include/dm/device.h   | 23 +++++++++++++++++++++++
 2 files changed, 50 insertions(+)
drivers/core/device.c +27 -0
index cb24a61..445b22e 100644
@@ -691,3 +691,30 @@ int device_set_name(struct udevice *dev, const char *name)
 
 	return 0;
 }
+
+bool of_device_is_compatible(int offset, const char *compat)
+{
+	const void *fdt = gd->fdt_blob;
+	const char *str;
+	int str_len;
+	int len = 0;
+
+	str = fdt_getprop(fdt, 0, "compatible", &str_len);
+	if(!str) {
+		debug("compatible field not found in node(%d)\n", offset);
+		return false;
+	}
+
+	while (len < str_len) {
+		if (!strcmp(compat, &str[len]))
+			return true;
+		len += strlen(&str[len]) + 1;
+	}
+
+	return false;
+}
+
+bool of_machine_is_compatible(const char *compat)
+{
+	return of_device_is_compatible(0, compat);
+}
include/dm/device.h +23 -0
index 1cf8150..9a1b3d0 100644
@@ -510,6 +510,29 @@ bool device_is_last_sibling(struct udevice *dev);
 int device_set_name(struct udevice *dev, const char *name);
 
 /**
+ * of_device_is_compatible() - check if the device is compatible with the compat
+ *
+ * This allows to check whether the device is comaptible with the compat.
+ *
+ * @offset:	Offset to the device
+ * @compat:	Compatible string which needs to verified in the given
+ *		device offset
+ * @return true if OK, false if the compatible is not found
+ */
+bool of_device_is_compatible(int offset, const char *compat);
+
+/**
+ * of_machine_is_compatible() - check if the machine is compatible with
+ *				the compat
+ *
+ * This allows to check whether the machine is comaptible with the compat.
+ *
+ * @compat:	Compatible string which needs to verified
+ * @return true if OK, false if the compatible is not found
+ */
+bool of_machine_is_compatible(const char *compat);
+
+/**
  * device_is_on_pci_bus - Test if a device is on a PCI bus
  *
  * @dev:	device to test
Signature · 1 line
2.8.1.101.g72d917a
#2 lore raw

PATCH 1/11 drivers: core: device: add support to check dt compatible for a device/machine

Hi Mugunthan,

Quoted 17 lines · Mugunthan V N

Provide an api to check whether the given device or machine is compatible with the given compat string which helps in making decisions in drivers based on device or machine compatible.

Idea taken from Linux.

---
 drivers/core/device.c | 27 +++++++++++++++++++++++++++
 include/dm/device.h   | 23 +++++++++++++++++++++++
 2 files changed, 50 insertions(+)
drivers/core/device.c +0 -0
index cb24a61..445b22e 100644

drivers/core/device.c int device_set_name(struct udevice *dev, const char *name) · line 695

Quoted 5 lines
drivers/core/device.c +2 -0
@@ -691,3 +691,30 @@ int device_set_name(struct udevice *dev, const char *name)
 
        return 0;
 }
+
+bool of_device_is_compatible(int offset, const char *compat)

struct udevice *dev should be the first parameter. We may one day stop using offsets and use a pointer, so the less we have to change the better.

drivers/core/device.c int device_set_name(struct udevice *dev, const char *name) · line 708

Quoted 13 lines
drivers/core/device.c +13 -0
+{
+       const void *fdt = gd->fdt_blob;
+       const char *str;
+       int str_len;
+       int len = 0;
+
+       str = fdt_getprop(fdt, 0, "compatible", &str_len);
+       if(!str) {
+               debug("compatible field not found in node(%d)\n", offset);
+               return false;
+       }
+
+       while (len < str_len) {

Can you use fdt_node_check_compatible() here?

Quoted 47 lines
drivers/core/device.c +12 -0
+               if (!strcmp(compat, &str[len]))
+                       return true;
+               len += strlen(&str[len]) + 1;
+       }
+
+       return false;
+}
+
+bool of_machine_is_compatible(const char *compat)
+{
+       return of_device_is_compatible(0, compat);
+}
include/dm/device.h +23 -1
index 1cf8150..9a1b3d0 100644
@@ -510,6 +510,29 @@ bool device_is_last_sibling(struct udevice *dev);
 int device_set_name(struct udevice *dev, const char *name);
 
 /**
+ * of_device_is_compatible() - check if the device is compatible with the compat
+ *
+ * This allows to check whether the device is comaptible with the compat.
+ *
+ * @offset:    Offset to the device
+ * @compat:    Compatible string which needs to verified in the given
+ *             device offset
+ * @return true if OK, false if the compatible is not found
+ */
+bool of_device_is_compatible(int offset, const char *compat);
+
+/**
+ * of_machine_is_compatible() - check if the machine is compatible with
+ *                             the compat
+ *
+ * This allows to check whether the machine is comaptible with the compat.
+ *
+ * @compat:    Compatible string which needs to verified
+ * @return true if OK, false if the compatible is not found
+ */
+bool of_machine_is_compatible(const char *compat);
+
+/**
  * device_is_on_pci_bus - Test if a device is on a PCI bus
  *
  * @dev:       device to test
--
Quoted 2 lines

2.8.1.101.g72d917a

Regards,
Simon

#3 lore raw

PATCH 2/11 lib: fdtdec: fix size cell and address cell parse from DT

In reply to Mugunthan V N

Size cell and address cell should be read from the parent node and should not assume with data structures as an example TI DRA7xx SoC is enabled as 64bit as there is LPAE support but the addresses specified in DT are all 32 bit sizes. So changing the code to read from parent node instead of calculations.

---
 lib/fdtdec.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
lib/fdtdec.c +7 -2
index 70acc29..8a5fb8c 100644
@@ -88,15 +88,20 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node,
 	const fdt32_t *prop_addr, *prop_size, *prop_after_size;
 	int len;
 	fdt_addr_t addr;
+	int parent;
 
 	debug("%s: %s: ", __func__, prop_name);
 
-	if (na > (sizeof(fdt_addr_t) / sizeof(fdt32_t))) {
+	parent = fdt_parent_offset(blob, node);
+
+	na = fdt_address_cells(blob, parent);
+	if (na < 1) {
 		debug("(na too large for fdt_addr_t type)\n");
 		return FDT_ADDR_T_NONE;
 	}
 
-	if (ns > (sizeof(fdt_size_t) / sizeof(fdt32_t))) {
+	ns = fdt_size_cells(blob, parent);
+	if (ns < 0) {
 		debug("(ns too large for fdt_size_t type)\n");
 		return FDT_ADDR_T_NONE;
 	}
Signature · 1 line
2.8.1.101.g72d917a
#4 lore raw

PATCH 2/11 lib: fdtdec: fix size cell and address cell parse from DT

+Stephen

Hi Mugunthan,

Quoted 6 lines · Mugunthan V N

Size cell and address cell should be read from the parent node and should not assume with data structures as an example TI DRA7xx SoC is enabled as 64bit as there is LPAE support but the addresses specified in DT are all 32 bit sizes. So changing the code to read from parent node instead of calculations.

I don't understand this. Can you please reword it and shorten the sentences?

Quoted 11 lines
---
 lib/fdtdec.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
lib/fdtdec.c +0 -0
index 70acc29..8a5fb8c 100644

lib/fdtdec.c fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node, · line 95

Quoted 9 lines
lib/fdtdec.c +2 -1
@@ -88,15 +88,20 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node,
        const fdt32_t *prop_addr, *prop_size, *prop_after_size;
        int len;
        fdt_addr_t addr;
+       int parent;
 
        debug("%s: %s: ", __func__, prop_name);
 
-       if (na > (sizeof(fdt_addr_t) / sizeof(fdt32_t))) {
+       parent = fdt_parent_offset(blob, node);

This is a very slow function. I hope this changes is not needed.

Quoted 14 lines
lib/fdtdec.c +5 -2
+
+       na = fdt_address_cells(blob, parent);
+       if (na < 1) {
                debug("(na too large for fdt_addr_t type)\n");
                return FDT_ADDR_T_NONE;
        }
 
-       if (ns > (sizeof(fdt_size_t) / sizeof(fdt32_t))) {
+       ns = fdt_size_cells(blob, parent);
+       if (ns < 0) {
                debug("(ns too large for fdt_size_t type)\n");
                return FDT_ADDR_T_NONE;
        }
--
Quoted 2 lines

2.8.1.101.g72d917a

Regards,
Simon

#5 lore raw

PATCH 2/11 lib: fdtdec: fix size cell and address cell parse from DT

Quoted 24 lines · Simon Glass

+Stephen

Hi Mugunthan,

Quoted 6 lines · Mugunthan V N

Size cell and address cell should be read from the parent node and should not assume with data structures as an example TI DRA7xx SoC is enabled as 64bit as there is LPAE support but the addresses specified in DT are all 32 bit sizes. So changing the code to read from parent node instead of calculations.

I don't understand this. Can you please reword it and shorten the sentences?

Quoted 10 lines
lib/fdtdec.c +1 -0
index 70acc29..8a5fb8c 100644
@@ -88,15 +88,20 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node,
         const fdt32_t *prop_addr, *prop_size, *prop_after_size;
         int len;
         fdt_addr_t addr;
+       int parent;
 
Quoted 20 lines

lib/fdtdec.c fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node, · line 95

Quoted 4 lines
lib/fdtdec.c +1 -1
         debug("%s: %s: ", __func__, prop_name);
 
-       if (na > (sizeof(fdt_addr_t) / sizeof(fdt32_t))) {
+       parent = fdt_parent_offset(blob, node);

This is a very slow function. I hope this changes is not needed.

Quoted 13 lines
lib/fdtdec.c +5 -1
+
+       na = fdt_address_cells(blob, parent);
+       if (na < 1) {
                 debug("(na too large for fdt_addr_t type)\n");
                 return FDT_ADDR_T_NONE;
         }
 
-       if (ns > (sizeof(fdt_size_t) / sizeof(fdt32_t))) {
+       ns = fdt_size_cells(blob, parent);
+       if (ns < 0) {
                 debug("(ns too large for fdt_size_t type)\n");
                 return FDT_ADDR_T_NONE;
         }

The entire point of fdtdec_get_addr_size_fixed() is for use-cases where na and ns are known and fixed ahead of time, or have already been retrieved from the parent node by the caller. This patch is incorrect. I expect the correct fix is to call e.g. fdtdec_get_addr_size_auto_parent() or fdtdec_get_addr_size_auto_noparent() from somewhere, rather than calling fdtdec_get_addr_size_fixed().

#6 lore raw

PATCH 2/11 lib: fdtdec: fix size cell and address cell parse from DT

Stephen

Quoted 48 lines · Stephen Warren
Quoted 26 lines · Simon Glass

+Stephen

Hi Mugunthan,

Quoted 6 lines · Mugunthan V N

Size cell and address cell should be read from the parent node and should not assume with data structures as an example TI DRA7xx SoC is enabled as 64bit as there is LPAE support but the addresses specified in DT are all 32 bit sizes. So changing the code to read from parent node instead of calculations.

I don't understand this. Can you please reword it and shorten the sentences?

Quoted 11 lines
lib/fdtdec.c +1 -0
index 70acc29..8a5fb8c 100644
@@ -88,15 +88,20 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void
 *blob, int node,
         const fdt32_t *prop_addr, *prop_size, *prop_after_size;
         int len;
         fdt_addr_t addr;
+       int parent;
 
Quoted 20 lines

lib/fdtdec.c fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node, · line 95

Quoted 4 lines
lib/fdtdec.c +1 -1
         debug("%s: %s: ", __func__, prop_name);
 
-       if (na > (sizeof(fdt_addr_t) / sizeof(fdt32_t))) {
+       parent = fdt_parent_offset(blob, node);

This is a very slow function. I hope this changes is not needed.

Quoted 13 lines
lib/fdtdec.c +5 -1
+
+       na = fdt_address_cells(blob, parent);
+       if (na < 1) {
                 debug("(na too large for fdt_addr_t type)\n");
                 return FDT_ADDR_T_NONE;
         }
 
-       if (ns > (sizeof(fdt_size_t) / sizeof(fdt32_t))) {
+       ns = fdt_size_cells(blob, parent);
+       if (ns < 0) {
                 debug("(ns too large for fdt_size_t type)\n");
                 return FDT_ADDR_T_NONE;
         }
Quoted 7 lines

The entire point of fdtdec_get_addr_size_fixed() is for use-cases where na and ns are known and fixed ahead of time, or have already been retrieved from the parent node by the caller. This patch is incorrect. I expect the correct fix is to call e.g. fdtdec_get_addr_size_auto_parent() or fdtdec_get_addr_size_auto_noparent() from somewhere, rather than calling fdtdec_get_addr_size_fixed().

Will fix thos in v2 by using fdtdec_get_addr_size_auto_parent()

Regards
Mugunthan V N

#7 lore raw

PATCH 3/11 ti_omap5_common: eth: do not define DM_ETH for spl

In reply to Mugunthan V N

Since omap's spl doesn't support DM currently, do not define DM_ETH for spl build.

---
 include/configs/ti_omap5_common.h | 1 +
 1 file changed, 1 insertion(+)
include/configs/ti_omap5_common.h +1 -0
index 202b18c..c592646 100644
@@ -155,6 +155,7 @@
 #ifdef CONFIG_SPL_BUILD
 #undef CONFIG_DM_MMC
 #undef CONFIG_TIMER
+#undef CONFIG_DM_ETH
 #endif
 
 #endif /* __CONFIG_TI_OMAP5_COMMON_H */
Signature · 1 line
2.8.1.101.g72d917a
#8 lore raw

PATCH 3/11 ti_omap5_common: eth: do not define DM_ETH for spl

Hi Mugunthan,

Quoted 7 lines · Mugunthan V N

Since omap's spl doesn't support DM currently, do not define DM_ETH for spl build.

---
 include/configs/ti_omap5_common.h | 1 +
 1 file changed, 1 insertion(+)

I suppose this is OK as a temporary convenience, although we should use defconfig for this sort of thing.

Quoted 16 lines
include/configs/ti_omap5_common.h +1 -1
index 202b18c..c592646 100644
@@ -155,6 +155,7 @@
 #ifdef CONFIG_SPL_BUILD
 #undef CONFIG_DM_MMC
 #undef CONFIG_TIMER
+#undef CONFIG_DM_ETH
 #endif
 
 #endif /* __CONFIG_TI_OMAP5_COMMON_H */
--

2.8.1.101.g72d917a

#9 lore raw

PATCH 3/11 ti_omap5_common: eth: do not define DM_ETH for spl

Quoted 11 lines · Simon Glass

Hi Mugunthan,

Quoted 7 lines · Mugunthan V N

Since omap's spl doesn't support DM currently, do not define DM_ETH for spl build.

---
 include/configs/ti_omap5_common.h | 1 +
 1 file changed, 1 insertion(+)
Quoted 5 lines

I suppose this is OK as a temporary convenience, although we should use defconfig for this sort of thing.

Yes, this is a temporary. When omap's spl updated to support DM, these undefs has to be removed.

Regards
Mugunthan V N

#10 lore raw

PATCH 3/11 ti_omap5_common: eth: do not define DM_ETH for spl

In reply to Mugunthan V N
Quoted 4 lines · Mugunthan V N

Since omap's spl doesn't support DM currently, do not define DM_ETH for spl build.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160411/69d0aaba/attachment-0001.sig>
#11 lore raw

PATCH 4/11 drivers: net: cpsw: fix cpsw dp parse when num slaves as 1

In reply to Mugunthan V N

On some boards number of slaves can be 1 when only one port ethernet is pinned out. So do not break when slave_index and num slaves check fails, instead continue to parse the next child.

---
 drivers/net/cpsw.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/cpsw.c +2 -4
index 7104754..971ebf0 100644
@@ -1209,10 +1209,8 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev)
 		if (!strncmp(name, "slave", 5)) {
 			u32 phy_id[2];
 
-			if (slave_index >= priv->data.slaves) {
-				printf("error: num slaves and slave nodes did not match\n");
-				return -EINVAL;
-			}
+			if (slave_index >= priv->data.slaves)
+				continue;
 			phy_mode = fdt_getprop(fdt, subnode, "phy-mode", NULL);
 			if (phy_mode)
 				priv->data.slave_data[slave_index].phy_if =
Signature · 1 line
2.8.1.101.g72d917a
#12 lore raw

PATCH 4/11 drivers: net: cpsw: fix cpsw dp parse when num slaves as 1

Quoted 6 lines · Mugunthan V N

On some boards number of slaves can be 1 when only one port ethernet is pinned out. So do not break when slave_index and num slaves check fails, instead continue to parse the next child.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160411/bddfcd4c/attachment.sig>
#13 lore raw

PATCH 5/11 ARM: omap5: add platform specific ethernet phy modes configurations

In reply to Mugunthan V N

Add platforms specific phy mode configuration bits to be used to configure phy mode in control module.

---
 arch/arm/include/asm/arch-omap5/cpu.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/include/asm/arch-omap5/cpu.h +12 -0
index b1513e9..683d905 100644
@@ -116,4 +116,16 @@ struct watchdog {
 #define CPSW_BASE			0x48484000
 #define CPSW_MDIO_BASE			0x48485000
 
+/* gmii_sel register defines */
+#define GMII1_SEL_MII		0x0
+#define GMII1_SEL_RMII		0x1
+#define GMII1_SEL_RGMII		0x2
+#define GMII2_SEL_MII		(GMII1_SEL_MII << 4)
+#define GMII2_SEL_RMII		(GMII1_SEL_RMII << 4)
+#define GMII2_SEL_RGMII		(GMII1_SEL_RGMII << 4)
+
+#define MII_MODE_ENABLE		(GMII1_SEL_MII | GMII2_SEL_MII)
+#define RMII_MODE_ENABLE        (GMII1_SEL_RMII | GMII2_SEL_RMII)
+#define RGMII_MODE_ENABLE	(GMII1_SEL_RGMII | GMII2_SEL_RGMII)
+
 #endif /* _CPU_H */
Signature · 1 line
2.8.1.101.g72d917a
#14 lore raw

PATCH 5/11 ARM: omap5: add platform specific ethernet phy modes configurations

Quoted 4 lines · Mugunthan V N

Add platforms specific phy mode configuration bits to be used to configure phy mode in control module.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160411/5ce8f103/attachment.sig>
#15 lore raw

PATCH 6/11 drivers: net: cpsw: add support for reading mac address from efuse

In reply to Mugunthan V N

Different TI platforms has to read with different combination to get the mac address from efuse. So add support to read mac address based on machine/device compatibles.

The code is taken from Linux drivers/net/ethernet/ti/cpsw-common.c done by Tony Lindgren.

---
 drivers/net/Makefile      |   2 +-
 drivers/net/cpsw-common.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/cpsw.c        |  24 +++------
 include/cpsw.h            |   1 +
 4 files changed, 131 insertions(+), 17 deletions(-)
 create mode 100644 drivers/net/cpsw-common.c
drivers/net/Makefile +1 -1
index fbedd04..d5e4a97 100644
@@ -59,7 +59,7 @@ obj-$(CONFIG_SMC91111) += smc91111.o
 obj-$(CONFIG_SMC911X) += smc911x.o
 obj-$(CONFIG_DRIVER_TI_EMAC) += davinci_emac.o
 obj-$(CONFIG_TSEC_ENET) += tsec.o fsl_mdio.o
-obj-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o
+obj-$(CONFIG_DRIVER_TI_CPSW) += cpsw.o cpsw-common.o
 obj-$(CONFIG_FMAN_ENET) += fsl_mdio.o
 obj-$(CONFIG_TSI108_ETH) += tsi108_eth.o
 obj-$(CONFIG_ULI526X) += uli526x.o
drivers/net/cpsw-common.c new file +121 -0

121 lines not on this page · raw message

drivers/net/cpsw.c +8 -16
index 971ebf0..cc63833 100644
@@ -26,6 +26,7 @@
 #include <phy.h>
 #include <asm/arch/cpu.h>
 #include <dm.h>
+#include <fdt_support.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -1146,9 +1147,8 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev)
 	int node = dev->of_offset;
 	int subnode;
 	int slave_index = 0;
-	uint32_t mac_hi, mac_lo;
-	fdt32_t gmii = 0;
 	int active_slave;
+	int ret;
 
 	pdata->iobase = dev_get_addr(dev);
 	priv->data.version = CPSW_CTRL_VERSION_2;
@@ -1234,20 +1234,11 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev)
 		priv->data.slave_data[1].sliver_reg_ofs = CPSW_SLIVER1_OFFSET;
 	}
 
-	subnode = fdtdec_lookup_phandle(fdt, node, "syscon");
-	priv->data.mac_id = fdt_translate_address((void *)fdt, subnode, &gmii);
-	priv->data.mac_id += AM335X_GMII_SEL_OFFSET;
-	priv->data.mac_id += active_slave * 8;
-
-	/* try reading mac address from efuse */
-	mac_lo = readl(priv->data.mac_id);
-	mac_hi = readl(priv->data.mac_id + 4);
-	pdata->enetaddr[0] = mac_hi & 0xFF;
-	pdata->enetaddr[1] = (mac_hi & 0xFF00) >> 8;
-	pdata->enetaddr[2] = (mac_hi & 0xFF0000) >> 16;
-	pdata->enetaddr[3] = (mac_hi & 0xFF000000) >> 24;
-	pdata->enetaddr[4] = mac_lo & 0xFF;
-	pdata->enetaddr[5] = (mac_lo & 0xFF00) >> 8;
+	ret = ti_cm_get_macid(dev, active_slave, pdata->enetaddr);
+	if (ret < 0) {
+		error("cpsw read efuse mac failed\n");
+		return ret;
+	}
 
 	pdata->phy_interface = priv->data.slave_data[active_slave].phy_if;
 	if (pdata->phy_interface == -1) {
@@ -1268,6 +1259,7 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev)
 		writel(RGMII_MODE_ENABLE, priv->data.gmii_sel);
 		break;
 	}
+
 	return 0;
 }
 
include/cpsw.h +1 -0
index cf1d30b..6255cd8 100644
@@ -51,5 +51,6 @@ struct cpsw_platform_data {
 };
 
 int cpsw_register(struct cpsw_platform_data *data);
+int ti_cm_get_macid(struct udevice *dev, int slave, u8 *mac_addr);
 
 #endif /* _CPSW_H_  */
Signature · 1 line
2.8.1.101.g72d917a
#16 lore raw

PATCH 6/11 drivers: net: cpsw: add support for reading mac address from efuse

Quoted 8 lines · Mugunthan V N

Different TI platforms has to read with different combination to get the mac address from efuse. So add support to read mac address based on machine/device compatibles.

The code is taken from Linux drivers/net/ethernet/ti/cpsw-common.c done by Tony Lindgren.

... but we don't do anything with the half dozen copies of that code that we already have in the tree and it needs to also take care of setting ethaddr.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160411/bc238d7f/attachment.sig>
#17 lore raw

PATCH 6/11 drivers: net: cpsw: add support for reading mac address from efuse

Quoted 6 lines · Tom Rini
Quoted 4 lines · Mugunthan V N

Different TI platforms has to read with different combination to get the mac address from efuse. So add support to read mac address based on machine/device compatibles.

Quoted 9 lines
Quoted 4 lines

The code is taken from Linux drivers/net/ethernet/ti/cpsw-common.c done by Tony Lindgren.

... but we don't do anything with the half dozen copies of that code that we already have in the tree and it needs to also take care of setting ethaddr.

The file is just a copy of the file from Kernel and modified header file inclusions and defines as per u-boot requirement. Kept the functions intact so that later patches from Kernel can be pulled to u-boot or vice-versa when new SoC is brought up.

Driver has to update the pdata->enetaddr, it will be set to env in eth uclass driver post probe function.

Regards
Mugunthan V N

#18 lore raw

PATCH 6/11 drivers: net: cpsw: add support for reading mac address from efuse

Quoted 17 lines · Mugunthan V N
Quoted 6 lines · Tom Rini
Quoted 4 lines · Mugunthan V N

Different TI platforms has to read with different combination to get the mac address from efuse. So add support to read mac address based on machine/device compatibles.

Quoted 9 lines
Quoted 4 lines

The code is taken from Linux drivers/net/ethernet/ti/cpsw-common.c done by Tony Lindgren.

... but we don't do anything with the half dozen copies of that code that we already have in the tree and it needs to also take care of setting ethaddr.

Quoted 7 lines

The file is just a copy of the file from Kernel and modified header file inclusions and defines as per u-boot requirement. Kept the functions intact so that later patches from Kernel can be pulled to u-boot or vice-versa when new SoC is brought up.

Driver has to update the pdata->enetaddr, it will be set to env in eth uclass driver post probe function.

Ah, OK. So we'll be able to remove the board/ versions and such after we move it all to DM, I can accept that, thanks.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160412/60513c7b/attachment.sig>
#19 lore raw

PATCH 7/11 arm: dts: am4372: add syscon node to cpsw to read mac address

In reply to Mugunthan V N

Add syscon node to cpsw device node to read mac address from efuse.

---
 arch/arm/dts/am4372.dtsi | 1 +
 1 file changed, 1 insertion(+)
arch/arm/dts/am4372.dtsi +1 -0
index c95d1d3..3ffa8e0 100644
@@ -547,6 +547,7 @@
 			active_slave = <0>;
 			cpts_clock_mult = <0x80000000>;
 			cpts_clock_shift = <29>;
+			syscon = <&scm_conf>;
 			ranges;
 
 			davinci_mdio: mdio at 4a101000 {
Signature · 1 line
2.8.1.101.g72d917a
#20 lore raw

PATCH 7/11 arm: dts: am4372: add syscon node to cpsw to read mac address

Quoted 4 lines · Mugunthan V N

Add syscon node to cpsw device node to read mac address from efuse.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160411/8f01924c/attachment.sig>
#21 lore raw

PATCH 8/11 arm: dts: dra7: add syscon node to cpsw to read mac address

In reply to Mugunthan V N

Add syscon node to cpsw device node to read mac address from efuse.

---
 arch/arm/dts/dra7.dtsi | 1 +
 1 file changed, 1 insertion(+)
arch/arm/dts/dra7.dtsi +1 -0
index e7fecf7..3059273 100644
@@ -1426,6 +1426,7 @@
 			active_slave = <0>;
 			cpts_clock_mult = <0x80000000>;
 			cpts_clock_shift = <29>;
+			syscon = <&scm_conf>;
 			reg = <0x48484000 0x1000
 			       0x48485200 0x2E00>;
 			#address-cells = <1>;
Signature · 1 line
2.8.1.101.g72d917a
#22 lore raw

PATCH 8/11 arm: dts: dra7: add syscon node to cpsw to read mac address

Quoted 4 lines · Mugunthan V N

Add syscon node to cpsw device node to read mac address from efuse.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160411/d4f5cad1/attachment.sig>
#23 lore raw

PATCH 9/11 defconfig: am437x_gp_evm: enable eth driver model

In reply to Mugunthan V N

Enable eth driver model for am437x_gp_evm as cpsw supports driver model.

---
 configs/am437x_gp_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/am437x_gp_evm_defconfig +1 -0
index 356f6fd..760e1f3 100644
@@ -22,3 +22,4 @@ CONFIG_TIMER=y
 CONFIG_OMAP_TIMER=y
 CONFIG_USB=y
 CONFIG_USB_GADGET=y
+CONFIG_DM_ETH=y
Signature · 1 line
2.8.1.101.g72d917a
#24 lore raw

PATCH 9/11 defconfig: am437x_gp_evm: enable eth driver model

Quoted 4 lines · Mugunthan V N

Enable eth driver model for am437x_gp_evm as cpsw supports driver model.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160411/df6101f5/attachment.sig>
#25 lore raw

PATCH 10/11 defconfig: am437x_sk_evm: enable eth driver model

In reply to Mugunthan V N

Enable eth driver model for am437x_sk_evm as cpsw supports driver model.

---
 configs/am437x_sk_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/am437x_sk_evm_defconfig +1 -0
index 2e2827f..324e8ed 100644
@@ -26,3 +26,4 @@ CONFIG_TIMER=y
 CONFIG_OMAP_TIMER=y
 CONFIG_USB=y
 CONFIG_USB_GADGET=y
+CONFIG_DM_ETH=y
Signature · 1 line
2.8.1.101.g72d917a
#26 lore raw

PATCH 10/11 defconfig: am437x_sk_evm: enable eth driver model

Quoted 4 lines · Mugunthan V N

Enable eth driver model for am437x_sk_evm as cpsw supports driver model.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160411/4c078947/attachment.sig>
#27 lore raw

PATCH 11/11 defconfig: dra74_evm: enable eth driver model

In reply to Mugunthan V N

Enable eth driver model for dra74_evm as cpsw supports driver model.

---
 configs/dra74_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/dra74_evm_defconfig +1 -0
index 5f50004..682c126 100644
@@ -25,3 +25,4 @@ CONFIG_OMAP_TIMER=y
 CONFIG_USB=y
 CONFIG_USB_GADGET=y
 CONFIG_DM_MMC=y
+CONFIG_DM_ETH=y
Signature · 1 line
2.8.1.101.g72d917a
#28 lore raw

PATCH 11/11 defconfig: dra74_evm: enable eth driver model

Quoted 4 lines · Mugunthan V N

Enable eth driver model for dra74_evm as cpsw supports driver model.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160411/4d553df7/attachment.sig>