ramips: switch all supported devices to nvmem-cells

This commit is contained in:
AmadeusGhost 2021-10-07 23:09:06 +08:00
parent bde39179ff
commit 1bf59628e6
12 changed files with 120 additions and 85 deletions

View File

@ -53,67 +53,73 @@
#size-cells = <1>; #size-cells = <1>;
compatible = "mtk,mt7620-nand"; compatible = "mtk,mt7620-nand";
partition@0 { partitions {
label = "Bootloader"; compatible = "fixed-partitions";
reg = <0x0 0x40000>; #address-cells = <1>;
read-only; #size-cells = <1>;
};
partition@40000 { partition@0 {
label = "Config"; label = "Bootloader";
reg = <0x40000 0x40000>; reg = <0x0 0x40000>;
}; read-only;
};
partition@80000 { partition@40000 {
label = "Bdata"; label = "Config";
reg = <0x80000 0x40000>; reg = <0x40000 0x40000>;
read-only; };
};
factory: partition@0xc0000 { partition@80000 {
label = "factory"; label = "Bdata";
reg = <0xc0000 0x40000>; reg = <0x80000 0x40000>;
read-only; read-only;
}; };
partition@100000 { factory: partition@0xc0000 {
label = "crash"; label = "factory";
reg = <0x100000 0x40000>; reg = <0xc0000 0x40000>;
read-only; read-only;
}; };
partition@140000 { partition@100000 {
label = "crash_syslog"; label = "crash";
reg = <0x140000 0x40000>; reg = <0x100000 0x40000>;
read-only; read-only;
}; };
partition@180000 { partition@140000 {
label = "reserved0"; label = "crash_syslog";
reg = <0x180000 0x80000>; reg = <0x140000 0x40000>;
read-only; read-only;
}; };
partition@200000 { partition@180000 {
label = "kernel_stock"; label = "reserved0";
reg = <0x200000 0x400000>; reg = <0x180000 0x80000>;
}; read-only;
};
partition@600000 { partition@200000 {
label = "kernel"; label = "kernel_stock";
reg = <0x600000 0x400000>; reg = <0x200000 0x400000>;
}; };
/* ubi partition is the result of squashing partition@600000 {
* next consequent stock partitions: label = "kernel";
* - rootfs0 (rootfs partition for stock kernel0), reg = <0x600000 0x400000>;
* - rootfs1 (rootfs partition for stock failsafe kernel1), };
* - overlay (used as ubi overlay in stock fw)
* resulting 117,5MiB space for packages. /* ubi partition is the result of squashing
*/ * next consequent stock partitions:
partition@a00000 { * - rootfs0 (rootfs partition for stock kernel0),
label = "ubi"; * - rootfs1 (rootfs partition for stock failsafe kernel1),
reg = <0xa00000 0x7600000>; * - overlay (used as ubi overlay in stock fw)
* resulting 117,5MiB space for packages.
*/
partition@a00000 {
label = "ubi";
reg = <0xa00000 0x7600000>;
};
}; };
}; };
}; };
@ -133,7 +139,8 @@
&ethernet { &ethernet {
pinctrl-names = "default"; pinctrl-names = "default";
pinctrl-0 = <&ephy_pins>; pinctrl-0 = <&ephy_pins>;
mtd-mac-address = <&factory 0x28>; nvmem-cells = <&macaddr_factory_28>;
nvmem-cell-names = "mac-address";
mediatek,portmap = "llllw"; mediatek,portmap = "llllw";
}; };
@ -167,3 +174,13 @@
}; };
}; };
}; };
&factory {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;
macaddr_factory_28: macaddr@28 {
reg = <0x28 0x6>;
};
};

View File

@ -151,7 +151,8 @@
&ethernet { &ethernet {
compatible = "mediatek,ralink-mt7621-eth"; compatible = "mediatek,ralink-mt7621-eth";
mediatek,switch = <&gsw>; mediatek,switch = <&gsw>;
mtd-mac-address = <&factory 0xe000>; nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
}; };
&switch0 { &switch0 {

View File

@ -113,7 +113,8 @@
&ethernet { &ethernet {
compatible = "mediatek,ralink-mt7621-eth"; compatible = "mediatek,ralink-mt7621-eth";
mediatek,switch = <&gsw>; mediatek,switch = <&gsw>;
mtd-mac-address = <&factory 0xe000>; nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
}; };
&switch0 { &switch0 {

View File

@ -91,7 +91,8 @@
&ethernet { &ethernet {
compatible = "mediatek,ralink-mt7621-eth"; compatible = "mediatek,ralink-mt7621-eth";
mediatek,switch = <&gsw>; mediatek,switch = <&gsw>;
mtd-mac-address = <&factory 0xe000>; nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
}; };
&switch0 { &switch0 {

View File

@ -14,7 +14,6 @@
led-failsafe = &led_red; led-failsafe = &led_red;
led-running = &led_green; led-running = &led_green;
led-upgrade = &led_blue; led-upgrade = &led_blue;
label-mac-device = &gmac0;
}; };
chosen { chosen {
@ -75,7 +74,7 @@
read-only; read-only;
}; };
config: partition@30000 { partition@30000 {
label = "config"; label = "config";
reg = <0x30000 0x10000>; reg = <0x30000 0x10000>;
read-only; read-only;
@ -108,10 +107,6 @@
}; };
}; };
&gmac0 {
mtd-mac-address-ascii = <&config 0x4429>;
};
&switch0 { &switch0 {
ports { ports {
port@0 { port@0 {
@ -138,7 +133,6 @@
&pcie0 { &pcie0 {
wifi@0,0 { wifi@0,0 {
reg = <0x0000 0 0 0 0>; reg = <0x0000 0 0 0 0>;
mtd-mac-address-ascii = <&config 0x4429>;
mediatek,mtd-eeprom = <&factory 0x0>; mediatek,mtd-eeprom = <&factory 0x0>;
}; };
}; };
@ -146,9 +140,6 @@
&pcie1 { &pcie1 {
wifi@0,0 { wifi@0,0 {
reg = <0x0000 0 0 0 0>; reg = <0x0000 0 0 0 0>;
mtd-mac-address-ascii = <&config 0x4429>;
mtd-mac-address-increment = <0x80>;
mtd-mac-address-increment-byte = <3>;
mediatek,mtd-eeprom = <&factory 0x8000>; mediatek,mtd-eeprom = <&factory 0x8000>;
ieee80211-freq-limit = <5000000 6000000>; ieee80211-freq-limit = <5000000 6000000>;
}; };

View File

@ -164,7 +164,8 @@
&ethernet { &ethernet {
compatible = "mediatek,ralink-mt7621-eth"; compatible = "mediatek,ralink-mt7621-eth";
mediatek,switch = <&gsw>; mediatek,switch = <&gsw>;
mtd-mac-address = <&factory 0x4>; nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
}; };
&switch0 { &switch0 {

View File

@ -105,7 +105,8 @@
&ethernet { &ethernet {
compatible = "mediatek,ralink-mt7621-eth"; compatible = "mediatek,ralink-mt7621-eth";
mediatek,switch = <&gsw>; mediatek,switch = <&gsw>;
mtd-mac-address = <&factory 0xe000>; nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
}; };
&switch0 { &switch0 {

View File

@ -27,7 +27,8 @@
&ethernet { &ethernet {
compatible = "mediatek,ralink-mt7621-eth"; compatible = "mediatek,ralink-mt7621-eth";
mediatek,switch = <&gsw>; mediatek,switch = <&gsw>;
mtd-mac-address = <&factory 0xe006>; nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
}; };
&switch0 { &switch0 {

View File

@ -87,7 +87,8 @@
&ethernet { &ethernet {
compatible = "mediatek,ralink-mt7621-eth"; compatible = "mediatek,ralink-mt7621-eth";
mediatek,switch = <&gsw>; mediatek,switch = <&gsw>;
mtd-mac-address = <&factory 0x4>; nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
}; };
&switch0 { &switch0 {

View File

@ -9,10 +9,6 @@
compatible = "zbtlink,zbt-wg108", "mediatek,mt7621-soc"; compatible = "zbtlink,zbt-wg108", "mediatek,mt7621-soc";
model = "Zbtlink ZBT-WG108"; model = "Zbtlink ZBT-WG108";
aliases {
label-mac-device = &wifi1;
};
chosen { chosen {
bootargs = "console=ttyS0,115200"; bootargs = "console=ttyS0,115200";
}; };
@ -76,7 +72,8 @@
}; };
&gmac0 { &gmac0 {
mtd-mac-address = <&factory 0xe000>; nvmem-cells = <&macaddr_factory_e000>;
nvmem-cell-names = "mac-address";
}; };
&switch0 { &switch0 {
@ -104,7 +101,8 @@
port@4 { port@4 {
status = "okay"; status = "okay";
label = "wan"; label = "wan";
mtd-mac-address = <&factory 0xe006>; nvmem-cells = <&macaddr_factory_e006>;
nvmem-cell-names = "mac-address";
}; };
}; };
}; };
@ -132,3 +130,17 @@
&sdhci { &sdhci {
status = "okay"; status = "okay";
}; };
&factory {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;
macaddr_factory_e000: macaddr@e000 {
reg = <0xe000 0x6>;
};
macaddr_factory_e006: macaddr@e006 {
reg = <0xe006 0x6>;
};
};

View File

@ -33,6 +33,7 @@ ramips_setup_interfaces()
;; ;;
asiarf,ap7621-nv1|\ asiarf,ap7621-nv1|\
jcg,q20|\ jcg,q20|\
jdcloud,re-sp-01b|\
lenovo,newifi-d1|\ lenovo,newifi-d1|\
mikrotik,routerboard-m33g|\ mikrotik,routerboard-m33g|\
xiaomi,mi-router-3g|\ xiaomi,mi-router-3g|\
@ -142,7 +143,10 @@ ramips_setup_macs()
wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)" wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
lan_mac=$wan_mac lan_mac=$wan_mac
;; ;;
d-team,newifi-d2) d-team,newifi-d2|\
phicomm,k2p|\
xiaomi,mi-router-ac2100|\
xiaomi,redmi-router-ac2100)
lan_mac=$(cat /sys/class/net/eth0/address) lan_mac=$(cat /sys/class/net/eth0/address)
wan_mac=$(mtd_get_mac_binary factory 0xe006) wan_mac=$(mtd_get_mac_binary factory 0xe006)
;; ;;
@ -188,6 +192,12 @@ ramips_setup_macs()
wan_mac=$(mtd_get_mac_binary factory 0xe006) wan_mac=$(mtd_get_mac_binary factory 0xe006)
label_mac=$(mtd_get_mac_binary factory 0x4) label_mac=$(mtd_get_mac_binary factory 0x4)
;; ;;
jdcloud,re-sp-01b)
local index="$(find_mtd_index "config")"
label_mac=$(macaddr_canonicalize $(dd if="/dev/mtd${index}" bs=12 skip=17449 iflag=skip_bytes count=1 2>/dev/null))
lan_mac=$label_mac
wan_mac=$label_mac
;;
linksys,e5600|\ linksys,e5600|\
linksys,ea7300-v1|\ linksys,ea7300-v1|\
linksys,ea7300-v2|\ linksys,ea7300-v2|\
@ -211,14 +221,6 @@ ramips_setup_macs()
lan_mac=$(mtd_get_mac_binary factory 0x4) lan_mac=$(mtd_get_mac_binary factory 0x4)
wan_mac=$(macaddr_add "$lan_mac" 2) wan_mac=$(macaddr_add "$lan_mac" 2)
;; ;;
phicomm,k2p)
wan_mac=$(mtd_get_mac_binary factory 0xe006)
;;
xiaomi,mi-router-ac2100|\
xiaomi,redmi-router-ac2100)
lan_mac=$(cat /sys/class/net/eth0/address)
wan_mac=$(mtd_get_mac_binary factory 0xe000)
;;
xiaoyu,xy-c5) xiaoyu,xy-c5)
wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1) wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1)
;; ;;

View File

@ -29,6 +29,12 @@ case "$board" in
[ "$PHYNBR" = "1" ] && \ [ "$PHYNBR" = "1" ] && \
macaddr_setbit_la "$(mtd_get_mac_binary Factory 0x4)" > /sys${DEVPATH}/macaddress macaddr_setbit_la "$(mtd_get_mac_binary Factory 0x4)" > /sys${DEVPATH}/macaddress
;; ;;
jdcloud,re-sp-01b)
local index="$(find_mtd_index "config")"
local label_mac=$(macaddr_canonicalize $(dd if="/dev/mtd${index}" bs=12 skip=17449 iflag=skip_bytes count=1 2>/dev/null))
[ "$PHYNBR" -eq 0 ] && echo $label_mac > /sys${DEVPATH}/macaddress
[ "$PHYNBR" -eq 1 ] && macaddr_add $label_mac 0x800000 > /sys${DEVPATH}/macaddress
;;
linksys,e5600|\ linksys,e5600|\
linksys,ea7300-v1|\ linksys,ea7300-v1|\
linksys,ea7300-v2|\ linksys,ea7300-v2|\