bcm53xx: MR32: read mac-address from eeprom master
authorChristian Lamparter <chunkeey@gmail.com>
Sat, 18 Sep 2021 14:41:41 +0000 (16:41 +0200)
committerChristian Lamparter <chunkeey@gmail.com>
Sat, 18 Sep 2021 17:41:54 +0000 (19:41 +0200)
Meraki wrote the ethernet MAC-address of the device
onto the eeprom (AT24C64) at the fixed location 0x66
to 0x6C. Let's fetch it from there.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
target/linux/bcm53xx/base-files/etc/board.d/02_network
target/linux/bcm53xx/patches-5.10/191-ARM-BCM53016-Specify-mac-address-nvmem.patch [new file with mode: 0644]
target/linux/bcm53xx/patches-5.10/332-net-broadcom-wait-for-nvmem-address.patch [new file with mode: 0644]

index 4952b64..40eb12c 100644 (file)
@@ -97,10 +97,6 @@ bcm53xx_setup_macs()
                # As vendor doesn't use eth0 its MAC may be missing. Use one from eth2.
                et2macaddr="$(nvram get et2macaddr)"
                ;;
-       meraki,mr32)
-               # The MAC is stored on an AT24C64 eeprom and not on the nvram
-               et2macaddr=$(get_mac_binary "/sys/bus/i2c/devices/0-0050/eeprom" 0x66)
-               ;;
        esac
 
        [ -n "$et2macaddr" ] && ucidef_set_interface_macaddr "lan" "$et2macaddr"
diff --git a/target/linux/bcm53xx/patches-5.10/191-ARM-BCM53016-Specify-mac-address-nvmem.patch b/target/linux/bcm53xx/patches-5.10/191-ARM-BCM53016-Specify-mac-address-nvmem.patch
new file mode 100644 (file)
index 0000000..fab7cf7
--- /dev/null
@@ -0,0 +1,45 @@
+From 6e250ca23596d890466babfae95dcd69dfd7e01b Mon Sep 17 00:00:00 2001
+From: Christian Lamparter <chunkeey@gmail.com>
+Date: Sat, 18 Sep 2021 16:33:22 +0200
+Subject: [PATCH 2/2] ARM: BCM53016: MR32: get mac-address from nvmem
+
+The MAC-Address of the MR32's sole ethernet port is
+located in offset 0x66 of the attached AT24C64 eeprom.
+
+Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
+---
+ arch/arm/boot/dts/bcm53016-meraki-mr32.dts | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+diff --git a/arch/arm/boot/dts/bcm53016-meraki-mr32.dts b/arch/arm/boot/dts/bcm53016-meraki-mr32.dts
+index 1dbfa05b6501..c58e75dde7b3 100644
+--- a/arch/arm/boot/dts/bcm53016-meraki-mr32.dts
++++ b/arch/arm/boot/dts/bcm53016-meraki-mr32.dts
+@@ -110,6 +110,12 @@ eeprom: eeprom@50 {
+                       reg = <0x50>;
+                       pagesize = <32>;
+                       read-only;
++                      #address-cells = <1>;
++                      #size-cells = <1>;
++
++                      mac_address: mac-address@66 {
++                              reg = <0x66 0x6>;
++                      };
+               };
+       };
+ };
+@@ -133,6 +139,11 @@ &uart2 {
+        */
+ };
++&gmac0 {
++      nvmem-cell-names = "mac-address";
++      nvmem-cells = <&mac_address>;
++};
++
+ &gmac1 {
+       status = "disabled";
+ };
+-- 
+2.33.0
+
diff --git a/target/linux/bcm53xx/patches-5.10/332-net-broadcom-wait-for-nvmem-address.patch b/target/linux/bcm53xx/patches-5.10/332-net-broadcom-wait-for-nvmem-address.patch
new file mode 100644 (file)
index 0000000..e8d78f6
--- /dev/null
@@ -0,0 +1,25 @@
+From 9e4a914a915248b7ac6341d34cf9e7e2a1c013fa Mon Sep 17 00:00:00 2001
+From: Christian Lamparter <chunkeey@gmail.com>
+Date: Sat, 18 Sep 2021 17:23:26 +0200
+Subject: [PATCH] net: broadcom: wait for nvmem/address
+
+---
+ drivers/net/ethernet/broadcom/bgmac-bcma.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/net/ethernet/broadcom/bgmac-bcma.c b/drivers/net/ethernet/broadcom/bgmac-bcma.c
+index 85fa0ab7201c..9513cfb5ba58 100644
+--- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
++++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
+@@ -129,6 +129,8 @@ static int bgmac_probe(struct bcma_device *core)
+       bcma_set_drvdata(core, bgmac);
+       err = of_get_mac_address(bgmac->dev->of_node, bgmac->net_dev->dev_addr);
++      if (err == -EPROBE_DEFER)
++              return err;
+       /* If no MAC address assigned via device tree, check SPROM */
+       if (err) {
+-- 
+2.33.0
+