Some Ventana boards have a Marvell sky2 GigE controller as eth1 however
assigning the mac address through device-tree is difficult because the
PCI slot can move around depending on board configuration and slot population.

To work around this we add a patch to the sky2 driver to allow accessing its
mac address via a device-tree alias.

Signed-off-by: Tim Harvey <[email protected]>
---
 .../208-sky2-allow-mac-to-come-from-dt.patch       | 30 ++++++++++++++++++++++
 .../209-ARM-imx-ventana-add-sky2-alias.patch       | 24 +++++++++++++++++
 2 files changed, 54 insertions(+)
 create mode 100644 
target/linux/imx6/patches-4.1/208-sky2-allow-mac-to-come-from-dt.patch
 create mode 100644 
target/linux/imx6/patches-4.1/209-ARM-imx-ventana-add-sky2-alias.patch

diff --git 
a/target/linux/imx6/patches-4.1/208-sky2-allow-mac-to-come-from-dt.patch 
b/target/linux/imx6/patches-4.1/208-sky2-allow-mac-to-come-from-dt.patch
new file mode 100644
index 0000000..c9c352c
--- /dev/null
+++ b/target/linux/imx6/patches-4.1/208-sky2-allow-mac-to-come-from-dt.patch
@@ -0,0 +1,30 @@
+Index: linux-4.1.6/drivers/net/ethernet/marvell/sky2.c
+===================================================================
+--- linux-4.1.6.orig/drivers/net/ethernet/marvell/sky2.c       2015-08-16 
20:52:51.000000000 -0700
++++ linux-4.1.6/drivers/net/ethernet/marvell/sky2.c    2015-10-05 
12:58:01.805935731 -0700
+@@ -4812,7 +4812,24 @@
+        * 1) from device tree data
+        * 2) from internal registers set by bootloader
+        */
+-      iap = of_get_mac_address(hw->pdev->dev.of_node);
++
++      iap = NULL;
++      if (IS_ENABLED(CONFIG_OF)) {
++              struct device_node *np;
++              np = of_find_node_by_path("/aliases");
++              if (np) {
++                      const char *path = of_get_property(np, "sky2", NULL);
++                      if (path)
++                              np = of_find_node_by_path(path);
++                      if (np)
++                              path = of_get_mac_address(np);
++                      if (path)
++                              iap = (unsigned char *) path;
++              }
++      }
++
++      if (!iap)
++              iap = of_get_mac_address(hw->pdev->dev.of_node);
+       if (iap)
+               memcpy(dev->dev_addr, iap, ETH_ALEN);
+       else
diff --git 
a/target/linux/imx6/patches-4.1/209-ARM-imx-ventana-add-sky2-alias.patch 
b/target/linux/imx6/patches-4.1/209-ARM-imx-ventana-add-sky2-alias.patch
new file mode 100644
index 0000000..eef81fa
--- /dev/null
+++ b/target/linux/imx6/patches-4.1/209-ARM-imx-ventana-add-sky2-alias.patch
@@ -0,0 +1,24 @@
+Index: linux-4.1.6/arch/arm/boot/dts/imx6qdl-gw53xx.dtsi
+===================================================================
+--- linux-4.1.6.orig/arch/arm/boot/dts/imx6qdl-gw53xx.dtsi     2015-10-05 
13:18:30.973900271 -0700
++++ linux-4.1.6/arch/arm/boot/dts/imx6qdl-gw53xx.dtsi  2015-10-05 
13:21:28.577895147 -0700
+@@ -15,6 +15,7 @@
+       /* these are used by bootloader for disabling nodes */
+       aliases {
+               ethernet1 = &eth1;
++              sky2 = &eth1;
+               led0 = &led0;
+               led1 = &led1;
+               led2 = &led2;
+Index: linux-4.1.6/arch/arm/boot/dts/imx6qdl-gw54xx.dtsi
+===================================================================
+--- linux-4.1.6.orig/arch/arm/boot/dts/imx6qdl-gw54xx.dtsi     2015-10-05 
13:18:30.973900271 -0700
++++ linux-4.1.6/arch/arm/boot/dts/imx6qdl-gw54xx.dtsi  2015-10-05 
13:20:09.261897435 -0700
+@@ -15,6 +15,7 @@
+       /* these are used by bootloader for disabling nodes */
+       aliases {
+               ethernet1 = &eth1;
++              sky2 = &eth1;
+               led0 = &led0;
+               led1 = &led1;
+               led2 = &led2;
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to