From 58e0c21c9406d859acaf9f17d1ea5c5c11ab22af Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Sat, 12 Jun 2021 01:10:18 +0800 Subject: [PATCH] rockchip: nanopi r4s: read mac address from eeprom NanoPi R4S has a unique MAC address for the ethernet on board. As the PCIe NIC doesn't have, just reuse this MAC and flipp the LA bit for it. Signed-off-by: Tianling Shen (cherry picked from commit 99adbe5ffd70995136a3cf12e0700ded7a04a072) --- .../armv8/base-files/etc/board.d/02_network | 4 +- ...kchip-add-EEPROM-node-for-NanoPi-R4S.patch | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 target/linux/rockchip/patches-5.4/010-arm64-dts-rockchip-add-EEPROM-node-for-NanoPi-R4S.patch diff --git a/target/linux/rockchip/armv8/base-files/etc/board.d/02_network b/target/linux/rockchip/armv8/base-files/etc/board.d/02_network index 42e3a20940..2b6e3af3d5 100755 --- a/target/linux/rockchip/armv8/base-files/etc/board.d/02_network +++ b/target/linux/rockchip/armv8/base-files/etc/board.d/02_network @@ -39,8 +39,8 @@ rockchip_setup_macs() lan_mac=$(macaddr_add "$wan_mac" +1) ;; friendlyarm,nanopi-r4s) - wan_mac=$(cat /sys/class/net/eth0/address) - lan_mac=$(macaddr_add "$wan_mac" +1) + wan_mac=$(get_mac_binary "/sys/bus/i2c/devices/2-0051/eeprom" 0xfa) + lan_mac=$(macaddr_setbit_la "$wan_mac") ;; xunlong,orangepi-r1-plus) lan_mac=$(cat /sys/class/net/eth1/address) diff --git a/target/linux/rockchip/patches-5.4/010-arm64-dts-rockchip-add-EEPROM-node-for-NanoPi-R4S.patch b/target/linux/rockchip/patches-5.4/010-arm64-dts-rockchip-add-EEPROM-node-for-NanoPi-R4S.patch new file mode 100644 index 0000000000..167c4bf054 --- /dev/null +++ b/target/linux/rockchip/patches-5.4/010-arm64-dts-rockchip-add-EEPROM-node-for-NanoPi-R4S.patch @@ -0,0 +1,40 @@ +From 43f3999d1836117ab2e601aec9a9e6f292ce4958 Mon Sep 17 00:00:00 2001 +From: Tianling Shen +Date: Mon, 7 Jun 2021 15:45:37 +0800 +Subject: [PATCH] arm64: dts: rockchip: add EEPROM node for NanoPi R4S + +NanoPi R4S has a EEPROM attached to the 2nd I2C bus (U92), which +stores the MAC address. + +Signed-off-by: Tianling Shen +--- + .../boot/dts/rockchip/rk3399-nanopi-r4s.dts | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +--- a/arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4s.dts ++++ b/arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4s.dts +@@ -68,6 +68,24 @@ + status = "disabled"; + }; + ++&gmac { ++ nvmem-cells = <&mac_address>; ++ nvmem-cells-names = "mac-address"; ++}; ++ ++&i2c2 { ++ eeprom@51 { ++ compatible = "microchip,24c02", "atmel,24c02"; ++ reg = <0x51>; ++ pagesize = <16>; ++ size = <256>; ++ ++ mac_address: mac-address@fa { ++ reg = <0xfa 0x06>; ++ }; ++ }; ++}; ++ + &i2c4 { + status = "disabled"; + };