ipq40xx: use nvmem for mikrotik mac address

Userspace handling is deprecated.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2024-08-24 13:54:10 -07:00
parent 1306885968
commit 95004898db
10 changed files with 136 additions and 21 deletions

View File

@ -219,19 +219,6 @@ ipq40xx_setup_macs()
wan_mac=$(mmc_get_mac_ascii devinfo hw_mac_addr)
lan_mac="$wan_mac"
;;
mikrotik,cap-ac |\
mikrotik,hap-ac2|\
mikrotik,hap-ac3|\
mikrotik,hap-ac3-lte6-kit)
wan_mac=$(cat /sys/firmware/mikrotik/hard_config/mac_base)
lan_mac=$(macaddr_add $wan_mac 1)
label_mac="$wan_mac"
;;
mikrotik,lhgg-60ad|\
mikrotik,sxtsq-5-ac)
lan_mac=$(cat /sys/firmware/mikrotik/hard_config/mac_base)
label_mac="$lan_mac"
;;
netgear,rbr50|\
netgear,rbs50|\
netgear,srr60|\

View File

@ -36,13 +36,6 @@ preinit_set_mac_address() {
ip link set dev lan address "$base_mac"
ip link set dev wan address "$base_mac"
;;
mikrotik,wap-ac|\
mikrotik,wap-ac-lte|\
mikrotik,wap-r-ac)
base_mac=$(cat /sys/firmware/mikrotik/hard_config/mac_base)
ip link set dev sw-eth1 address "$base_mac"
ip link set dev sw-eth2 address $(macaddr_add "$base_mac" 1)
;;
zyxel,nbg6617)
base_mac=$(cat /sys/class/net/eth0/address)
ip link set dev eth0 address $(macaddr_add "$base_mac" 2)

View File

@ -25,6 +25,7 @@
led-failsafe = &led_user;
led-running = &led_user;
led-upgrade = &led_user;
label-mac_device = &swport5;
};
soc {
@ -180,6 +181,14 @@
hard_config {
read-only;
nvmem-layout {
compatible = "mikrotik,routerboot-nvmem";
macaddr_hard: base-mac-address {
#nvmem-cell-cells = <1>;
};
};
};
dtb_config {
@ -226,6 +235,9 @@
&gmac {
status = "okay";
nvmem-cells = <&macaddr_hard 1>;
nvmem-cell-names = "mac-address";
};
&switch {
@ -240,6 +252,9 @@
&swport5 {
status = "okay";
nvmem-cells = <&macaddr_hard 0>;
nvmem-cell-names = "mac-address";
};
&wifi0 {

View File

@ -25,6 +25,7 @@
led-failsafe = &led_user;
led-running = &led_user;
led-upgrade = &led_user;
label-mac-device = &swport5;
};
soc {
@ -176,6 +177,14 @@
hard_config {
read-only;
size = <0x2000>;
nvmem-layout {
compatible = "mikrotik,routerboot-nvmem";
macaddr_hard: base-mac-address {
#nvmem-cell-cells = <1>;
};
};
};
dtb_config {
@ -255,6 +264,9 @@
&gmac {
status = "okay";
nvmem-cells = <&macaddr_hard 1>;
nvmem-cell-names = "mac-address";
};
&switch {
@ -264,25 +276,40 @@
&swport1 {
status = "okay";
label = "lan4";
nvmem-cells = <&macaddr_hard 4>;
nvmem-cell-names = "mac-address";
};
&swport2 {
status = "okay";
label = "lan3";
nvmem-cells = <&macaddr_hard 3>;
nvmem-cell-names = "mac-address";
};
&swport3 {
status = "okay";
label = "lan2";
nvmem-cells = <&macaddr_hard 2>;
nvmem-cell-names = "mac-address";
};
&swport4 {
status = "okay";
label = "lan1";
nvmem-cells = <&macaddr_hard 1>;
nvmem-cell-names = "mac-address";
};
&swport5 {
status = "okay";
nvmem-cells = <&macaddr_hard 0>;
nvmem-cell-names = "mac-address";
};
&wifi0 {

View File

@ -25,6 +25,7 @@
led-failsafe = &led_user;
led-running = &led_user;
led-upgrade = &led_user;
label-mac-device = &gmac;
};
soc {
@ -179,6 +180,14 @@
hard_config {
read-only;
nvmem-layout {
compatible = "mikrotik,routerboot-nvmem";
macaddr_hard: base-mac-address {
#nvmem-cell-cells = <1>;
};
};
};
dtb_config {
@ -221,6 +230,9 @@
&gmac {
status = "okay";
nvmem-cells = <&macaddr_hard 0>;
nvmem-cell-names = "mac-address";
};
&switch {

View File

@ -22,6 +22,7 @@
led-failsafe = &led_user;
led-running = &led_user;
led-upgrade = &led_user;
label-mac-device = &swport5;
};
soc {
@ -144,6 +145,14 @@
hard_config {
read-only;
size = <0x2000>;
nvmem-layout {
compatible = "mikrotik,routerboot-nvmem";
macaddr_hard: base-mac-address {
#nvmem-cell-cells = <1>;
};
};
};
dtb_config {
@ -197,11 +206,17 @@
&swport4 {
status = "okay";
label = "sw-eth2";
nvmem-cells = <&macaddr_hard 1>;
nvmem-cell-names = "mac-address";
};
&swport5 {
status = "okay";
label = "sw-eth1";
nvmem-cells = <&macaddr_hard 0>;
nvmem-cell-names = "mac-address";
};
&wifi0 {

View File

@ -25,6 +25,7 @@
led-failsafe = &led_status_red;
led-running = &led_status_blue;
led-upgrade = &led_status_red;
label-mac-device = &swport5;
};
soc {
@ -208,6 +209,14 @@
hard_config {
size = <0x2000>;
nvmem-layout {
compatible = "mikrotik,routerboot-nvmem";
macaddr_hard: base-mac-address {
#nvmem-cell-cells = <1>;
};
};
};
dtb_config {
@ -263,6 +272,9 @@
&gmac {
status = "okay";
nvmem-cells = <&macaddr_hard 1>;
nvmem-cell-names = "mac-address";
};
&switch {
@ -272,25 +284,40 @@
&swport1 {
status = "okay";
label = "lan4";
nvmem-cells = <&macaddr_hard 4>;
nvmem-cell-names = "mac-address";
};
&swport2 {
status = "okay";
label = "lan3";
nvmem-cells = <&macaddr_hard 3>;
nvmem-cell-names = "mac-address";
};
&swport3 {
status = "okay";
label = "lan2";
nvmem-cells = <&macaddr_hard 2>;
nvmem-cell-names = "mac-address";
};
&swport4 {
status = "okay";
label = "lan1";
nvmem-cells = <&macaddr_hard 1>;
nvmem-cell-names = "mac-address";
};
&swport5 {
status = "okay";
nvmem-cells = <&macaddr_hard 0>;
nvmem-cell-names = "mac-address";
};
&wifi0 {

View File

@ -25,6 +25,7 @@
led-failsafe = &led_status_red;
led-running = &led_status_blue;
led-upgrade = &led_status_red;
label-mac-device = &swport5;
};
soc {
@ -247,6 +248,14 @@
hard_config {
read-only;
size = <0x2000>;
nvmem-layout {
compatible = "mikrotik,routerboot-nvmem";
macaddr_hard: base-mac-address {
#nvmem-cell-cells = <1>;
};
};
};
dtb_config {
@ -314,6 +323,9 @@
&gmac {
status = "okay";
nvmem-cells = <&macaddr_hard 1>;
nvmem-cell-names = "mac-address";
};
&switch {
@ -323,25 +335,40 @@
&swport1 {
status = "okay";
label = "lan4";
nvmem-cells = <&macaddr_hard 4>;
nvmem-cell-names = "mac-address";
};
&swport2 {
status = "okay";
label = "lan3";
nvmem-cells = <&macaddr_hard 3>;
nvmem-cell-names = "mac-address";
};
&swport3 {
status = "okay";
label = "lan2";
nvmem-cells = <&macaddr_hard 2>;
nvmem-cell-names = "mac-address";
};
&swport4 {
status = "okay";
label = "lan1";
nvmem-cells = <&macaddr_hard 1>;
nvmem-cell-names = "mac-address";
};
&swport5 {
status = "okay";
nvmem-cells = <&macaddr_hard 0>;
nvmem-cell-names = "mac-address";
};
&wifi0 {

View File

@ -39,6 +39,7 @@
led-failsafe = &user;
led-running = &user;
led-upgrade = &user;
label-mac-device = &gmac;
};
soc {
@ -193,6 +194,14 @@
hard_config {
read-only;
size = <0x2000>;
nvmem-layout {
compatible = "mikrotik,routerboot-nvmem";
macaddr_hard: base-mac-address {
#nvmem-cell-cells = <1>;
};
};
};
dtb_config {
@ -279,6 +288,9 @@
&gmac {
status = "okay";
nvmem-cells = <&macaddr_hard 0>;
nvmem-cell-names = "mac-address";
};
&switch {

View File

@ -9,5 +9,5 @@ CONFIG_MTD_UBI_BEB_LIMIT=20
CONFIG_MTD_UBI_BLOCK=y
CONFIG_MTD_UBI_NVMEM=y
CONFIG_MTD_UBI_WL_THRESHOLD=4096
# CONFIG_NVMEM_LAYOUT_MIKROTIK is not set
CONFIG_NVMEM_LAYOUT_MIKROTIK=y
CONFIG_UBIFS_FS=y