ramips: convert HiWiFi devices MAC address to NVMEM format
For all HiWiFi series devices, the base MAC address is stored on "bdinfo" partition, offset 0x18a, ASCII text format. The recently introduced "mac-base" nvmem layout can handle the ASCII text now, so it's time to move MAC address configurations to dts. There is no valid MAC info in the "factory" partition, hence they will be replaced with the correct ones. Tested on HiWiFi HC5661A and HC5861. Signed-off-by: Shiji Yang <yangshiji66@outlook.com> Link: https://github.com/openwrt/openwrt/pull/18251 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
parent
b44a97a9f5
commit
9e08350b10
14 changed files with 76 additions and 67 deletions
|
@ -5,6 +5,7 @@
|
|||
model = "HiWiFi HC5661";
|
||||
|
||||
aliases {
|
||||
label-mac-device = ðernet;
|
||||
led-boot = &led_system;
|
||||
led-failsafe = &led_system;
|
||||
led-running = &led_system;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
model = "HiWiFi HC5761";
|
||||
|
||||
aliases {
|
||||
label-mac-device = ðernet;
|
||||
led-boot = &led_system;
|
||||
led-failsafe = &led_system;
|
||||
led-running = &led_system;
|
||||
|
@ -63,8 +64,8 @@
|
|||
&pcie0 {
|
||||
mt76@0,0 {
|
||||
reg = <0x0000 0 0 0 0>;
|
||||
nvmem-cells = <&eeprom_factory_8000>;
|
||||
nvmem-cell-names = "eeprom";
|
||||
nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_18a 0>;
|
||||
nvmem-cell-names = "eeprom", "mac-address";
|
||||
ieee80211-freq-limit = <5000000 6000000>;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
model = "HiWiFi HC5861";
|
||||
|
||||
aliases {
|
||||
label-mac-device = ðernet;
|
||||
led-boot = &led_system;
|
||||
led-failsafe = &led_system;
|
||||
led-running = &led_system;
|
||||
|
@ -95,8 +96,8 @@
|
|||
wifi@0,0 {
|
||||
compatible = "pci14c3,7662";
|
||||
reg = <0x0000 0 0 0 0>;
|
||||
nvmem-cells = <&eeprom_factory_8000>;
|
||||
nvmem-cell-names = "eeprom";
|
||||
nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_18a 0>;
|
||||
nvmem-cell-names = "eeprom", "mac-address";
|
||||
ieee80211-freq-limit = <5000000 6000000>;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -68,10 +68,6 @@
|
|||
eeprom_factory_8000: eeprom@8000 {
|
||||
reg = <0x8000 0x200>;
|
||||
};
|
||||
|
||||
macaddr_factory_4: macaddr@4 {
|
||||
reg = <0x4 0x6>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -91,6 +87,18 @@
|
|||
label = "bdinfo";
|
||||
reg = <0xfe0000 0x10000>;
|
||||
read-only;
|
||||
|
||||
nvmem-layout {
|
||||
compatible = "fixed-layout";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
macaddr_bdinfo_18a: macaddr@18a {
|
||||
compatible = "mac-base";
|
||||
reg = <0x18a 0x11>;
|
||||
#nvmem-cell-cells = <1>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
partition@ff0000 {
|
||||
|
@ -103,10 +111,10 @@
|
|||
};
|
||||
|
||||
ðernet {
|
||||
nvmem-cells = <&macaddr_factory_4>;
|
||||
nvmem-cell-names = "mac-address";
|
||||
|
||||
mediatek,portmap = "wllll";
|
||||
|
||||
nvmem-cells = <&macaddr_bdinfo_18a 0>;
|
||||
nvmem-cell-names = "mac-address";
|
||||
};
|
||||
|
||||
&sdhci {
|
||||
|
@ -114,8 +122,8 @@
|
|||
};
|
||||
|
||||
&wmac {
|
||||
nvmem-cells = <&eeprom_factory_0>;
|
||||
nvmem-cell-names = "eeprom";
|
||||
nvmem-cells = <&eeprom_factory_0>, <&macaddr_bdinfo_18a 0>;
|
||||
nvmem-cell-names = "eeprom", "mac-address";
|
||||
};
|
||||
|
||||
&state_default {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
model = "HiWiFi HC5962";
|
||||
|
||||
aliases {
|
||||
label-mac-device = &gmac0;
|
||||
led-boot = &led_system;
|
||||
led-failsafe = &led_system;
|
||||
led-running = &led_status;
|
||||
|
@ -116,6 +117,18 @@
|
|||
label = "bdinfo";
|
||||
reg = <0x21c0000 0x80000>;
|
||||
read-only;
|
||||
|
||||
nvmem-layout {
|
||||
compatible = "fixed-layout";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
macaddr_bdinfo_18a: macaddr@18a {
|
||||
compatible = "mac-base";
|
||||
reg = <0x18a 0x11>;
|
||||
#nvmem-cell-cells = <1>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
ubiconcat1: partition@2240000 {
|
||||
|
@ -132,8 +145,8 @@
|
|||
&pcie0 {
|
||||
mt76@0,0 {
|
||||
reg = <0x0000 0 0 0 0>;
|
||||
nvmem-cells = <&eeprom_factory_0>;
|
||||
nvmem-cell-names = "eeprom";
|
||||
nvmem-cells = <&eeprom_factory_0>, <&macaddr_bdinfo_18a 0>;
|
||||
nvmem-cell-names = "eeprom", "mac-address";
|
||||
ieee80211-freq-limit = <2400000 2500000>;
|
||||
};
|
||||
};
|
||||
|
@ -141,16 +154,24 @@
|
|||
&pcie1 {
|
||||
mt76@0,0 {
|
||||
reg = <0x0000 0 0 0 0>;
|
||||
nvmem-cells = <&eeprom_factory_8000>;
|
||||
nvmem-cell-names = "eeprom";
|
||||
nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_18a 0>;
|
||||
nvmem-cell-names = "eeprom", "mac-address";
|
||||
ieee80211-freq-limit = <5000000 6000000>;
|
||||
};
|
||||
};
|
||||
|
||||
&gmac0 {
|
||||
nvmem-cells = <&macaddr_bdinfo_18a 0>;
|
||||
nvmem-cell-names = "mac-address";
|
||||
};
|
||||
|
||||
&gmac1 {
|
||||
status = "okay";
|
||||
label = "wan";
|
||||
phy-handle = <ðphy4>;
|
||||
|
||||
nvmem-cells = <&macaddr_bdinfo_18a 1>;
|
||||
nvmem-cell-names = "mac-address";
|
||||
};
|
||||
|
||||
ðphy4 {
|
||||
|
|
|
@ -73,8 +73,8 @@
|
|||
&pcie0 {
|
||||
wifi@0,0 {
|
||||
reg = <0x0000 0 0 0 0>;
|
||||
nvmem-cells = <&eeprom_factory_8000>;
|
||||
nvmem-cell-names = "eeprom";
|
||||
nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_18a 0>;
|
||||
nvmem-cell-names = "eeprom", "mac-address";
|
||||
ieee80211-freq-limit = <5000000 6000000>;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
wifi@0,0 {
|
||||
reg = <0x0000 0 0 0 0>;
|
||||
ieee80211-freq-limit = <5000000 6000000>;
|
||||
nvmem-cells = <&eeprom_factory_8000>, <&macaddr_factory_2e>;
|
||||
nvmem-cells = <&eeprom_factory_8000>, <&macaddr_bdinfo_18a 0>;
|
||||
nvmem-cell-names = "eeprom", "mac-address";
|
||||
|
||||
led {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
compatible = "hiwifi,hc5x61a", "mediatek,mt7628an-soc";
|
||||
|
||||
aliases {
|
||||
label-mac-device = ðernet;
|
||||
led-boot = &led_system;
|
||||
led-failsafe = &led_system;
|
||||
led-running = &led_system;
|
||||
|
@ -73,14 +74,6 @@
|
|||
eeprom_factory_8000: eeprom@8000 {
|
||||
reg = <0x8000 0x200>;
|
||||
};
|
||||
|
||||
macaddr_factory_4: macaddr@4 {
|
||||
reg = <0x4 0x6>;
|
||||
};
|
||||
|
||||
macaddr_factory_2e: macaddr@2e {
|
||||
reg = <0x2e 0x6>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -100,6 +93,18 @@
|
|||
label = "bdinfo";
|
||||
reg = <0xfe0000 0x10000>;
|
||||
read-only;
|
||||
|
||||
nvmem-layout {
|
||||
compatible = "fixed-layout";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
macaddr_bdinfo_18a: macaddr@18a {
|
||||
compatible = "mac-base";
|
||||
reg = <0x18a 0x11>;
|
||||
#nvmem-cell-cells = <1>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
partition@ff0000 {
|
||||
|
@ -112,13 +117,13 @@
|
|||
};
|
||||
|
||||
ðernet {
|
||||
nvmem-cells = <&macaddr_factory_4>;
|
||||
nvmem-cells = <&macaddr_bdinfo_18a 0>;
|
||||
nvmem-cell-names = "mac-address";
|
||||
};
|
||||
|
||||
&wmac {
|
||||
status = "okay";
|
||||
|
||||
nvmem-cells = <&eeprom_factory_0>;
|
||||
nvmem-cell-names = "eeprom";
|
||||
nvmem-cells = <&eeprom_factory_0>, <&macaddr_bdinfo_18a 0>;
|
||||
nvmem-cell-names = "eeprom", "mac-address";
|
||||
};
|
||||
|
|
|
@ -382,10 +382,7 @@ ramips_setup_macs()
|
|||
hiwifi,hc5661|\
|
||||
hiwifi,hc5761|\
|
||||
hiwifi,hc5861)
|
||||
lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
|
||||
label_mac=$lan_mac
|
||||
[ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
|
||||
wan_mac=$(macaddr_add "$lan_mac" 1)
|
||||
wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
|
||||
;;
|
||||
iodata,wn-ac1167gr|\
|
||||
iodata,wn-ac733gr3)
|
||||
|
|
|
@ -10,17 +10,9 @@ PHYNBR=${DEVPATH##*/phy}
|
|||
board=$(board_name)
|
||||
|
||||
case "$board" in
|
||||
hiwifi,hc5661)
|
||||
label_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
|
||||
[ "$PHYNBR" = "0" ] && [ -n "$label_mac" ] && \
|
||||
echo -n "$label_mac" > /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
hiwifi,hc5761|\
|
||||
hiwifi,hc5861)
|
||||
label_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
|
||||
[ "$PHYNBR" = "1" ] && [ -n "$label_mac" ] && \
|
||||
echo -n "$label_mac" > /sys${DEVPATH}/macaddress
|
||||
[ "$PHYNBR" = "0" ] && [ -n "$label_mac" ] && \
|
||||
macaddr_unsetbit "$label_mac" 6 > /sys${DEVPATH}/macaddress
|
||||
[ "$PHYNBR" = "0" ] && \
|
||||
macaddr_unsetbit "$(cat /sys${DEVPATH}/macaddress)" 6 > /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -272,12 +272,6 @@ ramips_setup_macs()
|
|||
lan_mac=$(macaddr_add "$label_mac" 1)
|
||||
wan_mac=$label_mac
|
||||
;;
|
||||
hiwifi,hc5962)
|
||||
lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac")
|
||||
label_mac=$lan_mac
|
||||
[ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
|
||||
wan_mac=$(macaddr_add "$lan_mac" 1)
|
||||
;;
|
||||
iodata,wnpr2600g)
|
||||
wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
|
||||
label_mac=$wan_mac
|
||||
|
|
|
@ -110,11 +110,8 @@ case "$board" in
|
|||
macaddr_setbit_la "$(mtd_get_mac_binary factory 0x4)" > /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
hiwifi,hc5962)
|
||||
label_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac")
|
||||
[ "$PHYNBR" = "0" ] && [ -n "$label_mac" ] && \
|
||||
echo -n "$label_mac" > /sys${DEVPATH}/macaddress
|
||||
[ "$PHYNBR" = "1" ] && [ -n "$label_mac" ] && \
|
||||
macaddr_unsetbit "$label_mac" 6 > /sys${DEVPATH}/macaddress
|
||||
[ "$PHYNBR" = "1" ] && \
|
||||
macaddr_unsetbit "$(cat /sys${DEVPATH}/macaddress)" 6 > /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
iptime,a3002mesh|\
|
||||
iptime,a3004t)
|
||||
|
|
|
@ -290,10 +290,7 @@ ramips_setup_macs()
|
|||
hiwifi,hc5661a|\
|
||||
hiwifi,hc5761a|\
|
||||
hiwifi,hc5861b)
|
||||
lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
|
||||
label_mac=$lan_mac
|
||||
[ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
|
||||
wan_mac=$(macaddr_add "$lan_mac" 1)
|
||||
wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
|
||||
;;
|
||||
iptime,a3|\
|
||||
iptime,a604m|\
|
||||
|
|
|
@ -10,14 +10,9 @@ PHYNBR=${DEVPATH##*/phy}
|
|||
board=$(board_name)
|
||||
|
||||
case "$board" in
|
||||
hiwifi,hc5611|\
|
||||
hiwifi,hc5661a|\
|
||||
hiwifi,hc5761a|\
|
||||
hiwifi,hc5861b)
|
||||
label_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
|
||||
[ "$PHYNBR" = "0" ] && [ -n "$label_mac" ] && \
|
||||
echo -n "$label_mac" > /sys${DEVPATH}/macaddress
|
||||
[ "$PHYNBR" = "1" ] && [ -n "$label_mac" ] && \
|
||||
macaddr_unsetbit "$label_mac" 6 > /sys${DEVPATH}/macaddress
|
||||
[ "$PHYNBR" = "1" ] && \
|
||||
macaddr_unsetbit "$(cat /sys${DEVPATH}/macaddress)" 6 > /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
esac
|
||||
|
|
Loading…
Reference in a new issue