Skip to content

Commit

Permalink
mediatek: use NVMEM framework on all Adtran devices
Browse files Browse the repository at this point in the history
Use NVMEM framework to assign MAC addresses and WiFi EEPROM data on
all Adtran SmartRG devices.

Signed-off-by: Daniel Golle <[email protected]>
  • Loading branch information
dangowrt committed Oct 15, 2024
1 parent b6d8297 commit 3e6de5d
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 79 deletions.
77 changes: 70 additions & 7 deletions target/linux/mediatek/dts/mt7986a-smartrg-bonanza-peak.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
/ {
aliases {
serial0 = &uart0;
ethernet0 = &gmac0;
ethernet1 = &gmac1;
label-mac-device = &gmac1;
led-boot = &led_status_green;
led-failsafe = &led_status_red;
led-running = &led_status_white;
Expand Down Expand Up @@ -188,16 +187,17 @@
gmac0: mac@0 {
compatible = "mediatek,eth-mac";
reg = <0>;

nvmem-cells = <&macaddr 1>;
nvmem-cell-names = "mac-address";
phy-mode = "2500base-x";
};

gmac1: mac@1 {
label = "wan";

compatible = "mediatek,eth-mac";
reg = <1>;

label = "wan";
nvmem-cells = <&macaddr 0>;
nvmem-cell-names = "mac-address";
phy-mode = "2500base-x";
};

Expand Down Expand Up @@ -254,6 +254,47 @@
no-sd;
no-sdio;
status = "okay";

card@0 {
compatible = "mmc-card";
reg = <0>;

block {
compatible = "block-device";

partitions {
block-partition-factory {
partname = "factory";

nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;

eeprom_factory_0: eeprom@0 {
reg = <0x0 0x1000>;
};

eeprom_factory_a0000: eeprom@a0000 {
reg = <0xa0000 0x1000>;
};
};
};

block-partition-mfginfo {
partname = "mfginfo";

nvmem-layout {
compatible = "adtran,mfginfo";

macaddr: mfg-mac {
#nvmem-cell-cells = <1>;
};
};
};
};
};
};
};

&pcie {
Expand All @@ -266,6 +307,9 @@

radio0: mt7915@0,0 {
reg = <0x0000 0 0 0 0>;

nvmem-cells = <&eeprom_factory_a0000>, <&macaddr 4>;
nvmem-cell-names = "eeprom", "mac-address";
};
};
};
Expand All @@ -275,9 +319,28 @@
};

&wifi {
status = "okay";
nvmem-cells = <&eeprom_factory_0>;
nvmem-cell-names = "eeprom";
pinctrl-names = "default";
pinctrl-0 = <&wf_2g_5g_pins>;
#address-cells = <1>;
#size-cells = <0>;

status = "okay";

band@0 {
/* 2.4 GHz */
reg = <0>;
nvmem-cells = <&macaddr 2>;
nvmem-cell-names = "mac-address";
};

band@1 {
/* lower 5 GHz */
reg = <1>;
nvmem-cells = <&macaddr 3>;
nvmem-cell-names = "mac-address";
};
};

&pio {
Expand Down
49 changes: 45 additions & 4 deletions target/linux/mediatek/dts/mt7988a-smartrg-mt-stuart.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
/ {
aliases {
serial0 = &uart0;
ethernet0 = &gmac0;
ethernet1 = &gmac1;
label-mac-device = &gmac1;
led-boot = &led_sys_green;
led-failsafe = &led_sys_blue;
led-running = &led_sys_white;
Expand Down Expand Up @@ -250,21 +249,30 @@
};

&gmac0 {
nvmem-cells = <&macaddr 1>;
nvmem-cell-names = "mac-address";

status = "okay";
};

&gmac1 {
nvmem-cells = <&macaddr 0>;
nvmem-cell-names = "mac-address";
label = "wan";
status = "okay";
phy-mode = "usxgmii";

status = "okay";
};

&gmac2 {
nvmem-cells = <&macaddr 1>;
nvmem-cell-names = "mac-address";
label = "lan1";
status = "okay";
phy-mode = "usxgmii";
phy-connection-type = "usxgmii";
phy = <&phy8>;

status = "okay";
};

&gsw_phy0 {
Expand Down Expand Up @@ -513,6 +521,18 @@
};
};
};

block-partition-mfginfo {
partname = "mfginfo";

nvmem-layout {
compatible = "adtran,mfginfo";

macaddr: mfg-mac {
#nvmem-cell-cells = <1>;
};
};
};
};
};
};
Expand All @@ -532,6 +552,27 @@
nvmem-cells = <&eeprom_factory_0>;
nvmem-cell-names = "eeprom";
ieee80211-freq-limit = <2400000 2500000>, <5170000 5835000>, <5945000 7125000>;

band@0 {
/* 2.4 GHz */
reg = <0>;
nvmem-cells = <&macaddr 4>;
nvmem-cell-names = "mac-address";
};

band@1 {
/* 5 GHz */
reg = <1>;
nvmem-cells = <&macaddr 10>;
nvmem-cell-names = "mac-address";
};

band@2 {
/* 6 GHz */
reg = <2>;
nvmem-cells = <&macaddr 6>;
nvmem-cell-names = "mac-address";
};
};
};
};
Expand Down
4 changes: 4 additions & 0 deletions target/linux/mediatek/dts/mt7988d-smartrg-SDG-8733A.dts
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,17 @@

&gmac1 {
label = "lan";
nvmem-cells = <&macaddr 1>;
nvmem-cell-names = "mac-address";
phy-mode = "internal";
phy-connection-type = "internal";
phy = <&int_2p5g_phy>;
};

&gmac2 {
label = "wan";
nvmem-cells = <&macaddr 0>;
nvmem-cell-names = "mac-address";
phy-mode = "usxgmii";
phy-connection-type = "usxgmii";
phy = <&phy8>;
Expand Down
10 changes: 0 additions & 10 deletions target/linux/mediatek/filogic/base-files/etc/board.d/02_network
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,6 @@ mediatek_setup_macs()
wan_mac=$label_mac
lan_mac=$(macaddr_add "$label_mac" 1)
;;
smartrg,sdg-8612|\
smartrg,sdg-8614|\
smartrg,sdg-8622|\
smartrg,sdg-8632|\
smartrg,sdg-8733|\
smartrg,sdg-8734)
label_mac=$(mmc_get_mac_ascii mfginfo MFG_MAC)
wan_mac=$label_mac
lan_mac=$(macaddr_add "$label_mac" 1)
;;
xiaomi,mi-router-ax3000t|\
xiaomi,mi-router-ax3000t-ubootmod|\
xiaomi,mi-router-wr30u-stock|\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,6 @@
board=$(board_name)

case "$FIRMWARE" in
"mediatek/mt7915_eeprom.bin")
case "$board" in
smartrg,sdg-8622)
caldata_extract_mmc "factory" 0xa0000 0x1000
;;
esac
;;
"mediatek/mt7916_eeprom.bin")
case "$board" in
acer,predator-w6|\
smartrg,sdg-8632)
caldata_extract_mmc "factory" 0xa0000 0x1000
;;
esac
;;
"mediatek/mt7981_eeprom_mt7976_dbdc.bin")
case "$board" in
ubnt,unifi-6-plus)
Expand All @@ -36,12 +21,6 @@ case "$FIRMWARE" in
ln -sf /tmp/tp_data/MT7986_EEPROM.bin \
/lib/firmware/$FIRMWARE
;;
smartrg,sdg-8612|\
smartrg,sdg-8614|\
smartrg,sdg-8622|\
smartrg,sdg-8632)
caldata_extract_mmc "factory" 0x0 0x1000
;;
esac
;;
"mediatek/mt7986_eeprom_mt7976.bin")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,6 @@ case "$board" in
[ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
;;
smartrg,sdg-8612|\
smartrg,sdg-8614|\
smartrg,sdg-8622|\
smartrg,sdg-8632)
addr=$(mmc_get_mac_ascii mfginfo MFG_MAC)
[ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "2" ] && macaddr_add $addr 4 > /sys${DEVPATH}/macaddress
;;
smartrg,sdg-8733|\
smartrg,sdg-8733a|\
smartrg,sdg-8734)
addr=$(mmc_get_mac_ascii mfginfo MFG_MAC)
[ "$PHYNBR" = "0" ] && macaddr_add $addr 4 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr a > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "2" ] && macaddr_add $addr 6 > /sys${DEVPATH}/macaddress
;;
tplink,tl-xdr4288|\
tplink,tl-xdr6086|\
tplink,tl-xdr6088)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,6 @@ preinit_set_mac_address() {
addr=$(get_mac_binary "/tmp/tp_data/default-mac" 0)
ip link set dev eth1 address "$(macaddr_add $addr 1)"
;;
smartrg,sdg-8612|\
smartrg,sdg-8614|\
smartrg,sdg-8733|\
smartrg,sdg-8734)
addr=$(mmc_get_mac_ascii mfginfo MFG_MAC)
lan_addr=$(macaddr_add $addr 1)
ip link set dev wan address "$addr"
ip link set dev eth0 address "$lan_addr"
ip link set dev lan1 address "$lan_addr"
ip link set dev lan2 address "$lan_addr"
ip link set dev lan3 address "$lan_addr"
ip link set dev lan4 address "$lan_addr"
;;
smartrg,sdg-8622|\
smartrg,sdg-8632|\
smartrg,sdg-8733a)
addr=$(mmc_get_mac_ascii mfginfo MFG_MAC)
ip link set dev wan address "$addr"
ip link set dev lan address "$(macaddr_add $addr 1)"
;;
*)
;;
esac
Expand Down

0 comments on commit 3e6de5d

Please sign in to comment.