mirror of
https://github.com/openwrt/openwrt.git
synced 2025-01-31 08:25:29 +00:00
ramips: use nvmem to get mikrotik mac
73a9f9f857947bc63fef1aefb7e2e4b906fb9d2b added support. Let's use it. Calibration data is not yet supported. Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: https://github.com/openwrt/openwrt/pull/16256 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
parent
c5287069ea
commit
4f4cb52e24
@ -49,6 +49,14 @@
|
|||||||
|
|
||||||
hard_config {
|
hard_config {
|
||||||
read-only;
|
read-only;
|
||||||
|
|
||||||
|
nvmem-layout {
|
||||||
|
compatible = "mikrotik,routerboot-nvmem";
|
||||||
|
|
||||||
|
macaddr_hard: base-mac-address {
|
||||||
|
#nvmem-cell-cells = <1>;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
partition@10000 {
|
partition@10000 {
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
led-failsafe = &led_usr;
|
led-failsafe = &led_usr;
|
||||||
led-running = &led_usr;
|
led-running = &led_usr;
|
||||||
led-upgrade = &led_usr;
|
led-upgrade = &led_usr;
|
||||||
|
label-mac-device = ðernet;
|
||||||
};
|
};
|
||||||
|
|
||||||
ath9k-leds {
|
ath9k-leds {
|
||||||
@ -128,6 +129,9 @@
|
|||||||
|
|
||||||
ðernet {
|
ðernet {
|
||||||
pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>;
|
pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>;
|
||||||
|
|
||||||
|
nvmem-cells = <&macaddr_hard 0>;
|
||||||
|
nvmem-cell-names = "mac-address";
|
||||||
};
|
};
|
||||||
|
|
||||||
&switch0 {
|
&switch0 {
|
||||||
@ -146,6 +150,8 @@
|
|||||||
compatible = "pci168c,0030";
|
compatible = "pci168c,0030";
|
||||||
reg = <0x0000 0 0 0 0>;
|
reg = <0x0000 0 0 0 0>;
|
||||||
qca,no-eeprom;
|
qca,no-eeprom;
|
||||||
|
nvmem-cells = <&macaddr_hard 1>;
|
||||||
|
nvmem-cell-names = "mac-address";
|
||||||
gpio-controller;
|
gpio-controller;
|
||||||
#gpio-cells = <2>;
|
#gpio-cells = <2>;
|
||||||
};
|
};
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
led-failsafe = &led_usr;
|
led-failsafe = &led_usr;
|
||||||
led-running = &led_usr;
|
led-running = &led_usr;
|
||||||
led-upgrade = &led_usr;
|
led-upgrade = &led_usr;
|
||||||
|
label-mac-device = &gmac1;
|
||||||
};
|
};
|
||||||
|
|
||||||
leds {
|
leds {
|
||||||
@ -40,6 +41,9 @@
|
|||||||
status = "okay";
|
status = "okay";
|
||||||
label = "wan";
|
label = "wan";
|
||||||
phy-handle = <ðphy0>;
|
phy-handle = <ðphy0>;
|
||||||
|
|
||||||
|
nvmem-cells = <&macaddr_hard 0>;
|
||||||
|
nvmem-cell-names = "mac-address";
|
||||||
};
|
};
|
||||||
|
|
||||||
ðphy0 {
|
ðphy0 {
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
led-failsafe = &led_pwr;
|
led-failsafe = &led_pwr;
|
||||||
led-running = &led_pwr;
|
led-running = &led_pwr;
|
||||||
led-upgrade = &led_pwr;
|
led-upgrade = &led_pwr;
|
||||||
|
label-mac-device = &port0;
|
||||||
};
|
};
|
||||||
|
|
||||||
leds {
|
leds {
|
||||||
@ -51,6 +52,9 @@
|
|||||||
label = "sfp";
|
label = "sfp";
|
||||||
phy-mode = "rgmii-rxid";
|
phy-mode = "rgmii-rxid";
|
||||||
phy-handle = <&ephy7>;
|
phy-handle = <&ephy7>;
|
||||||
|
|
||||||
|
nvmem-cells = <&macaddr_hard 5>;
|
||||||
|
nvmem-cell-names = "mac-address";
|
||||||
};
|
};
|
||||||
|
|
||||||
&i2c {
|
&i2c {
|
||||||
|
@ -40,29 +40,44 @@
|
|||||||
|
|
||||||
&switch0 {
|
&switch0 {
|
||||||
ports {
|
ports {
|
||||||
port@0 {
|
port0: port@0 {
|
||||||
status = "okay";
|
status = "okay";
|
||||||
label = "wan";
|
label = "wan";
|
||||||
|
|
||||||
|
nvmem-cells = <&macaddr_hard 0>;
|
||||||
|
nvmem-cell-names = "mac-address";
|
||||||
};
|
};
|
||||||
|
|
||||||
port@1 {
|
port@1 {
|
||||||
status = "okay";
|
status = "okay";
|
||||||
label = "lan2";
|
label = "lan2";
|
||||||
|
|
||||||
|
nvmem-cells = <&macaddr_hard 1>;
|
||||||
|
nvmem-cell-names = "mac-address";
|
||||||
};
|
};
|
||||||
|
|
||||||
port@2 {
|
port@2 {
|
||||||
status = "okay";
|
status = "okay";
|
||||||
label = "lan3";
|
label = "lan3";
|
||||||
|
|
||||||
|
nvmem-cells = <&macaddr_hard 2>;
|
||||||
|
nvmem-cell-names = "mac-address";
|
||||||
};
|
};
|
||||||
|
|
||||||
port@3 {
|
port@3 {
|
||||||
status = "okay";
|
status = "okay";
|
||||||
label = "lan4";
|
label = "lan4";
|
||||||
|
|
||||||
|
nvmem-cells = <&macaddr_hard 3>;
|
||||||
|
nvmem-cell-names = "mac-address";
|
||||||
};
|
};
|
||||||
|
|
||||||
port@4 {
|
port@4 {
|
||||||
status = "okay";
|
status = "okay";
|
||||||
label = "lan5";
|
label = "lan5";
|
||||||
|
|
||||||
|
nvmem-cells = <&macaddr_hard 4>;
|
||||||
|
nvmem-cell-names = "mac-address";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
led-failsafe = &led_usr;
|
led-failsafe = &led_usr;
|
||||||
led-running = &led_usr;
|
led-running = &led_usr;
|
||||||
led-upgrade = &led_usr;
|
led-upgrade = &led_usr;
|
||||||
|
label-mac-device = ðernet;
|
||||||
};
|
};
|
||||||
|
|
||||||
leds {
|
leds {
|
||||||
@ -68,6 +69,9 @@
|
|||||||
|
|
||||||
ðernet {
|
ðernet {
|
||||||
pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>;
|
pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>;
|
||||||
|
|
||||||
|
nvmem-cells = <&macaddr_hard 0>;
|
||||||
|
nvmem-cell-names = "mac-address";
|
||||||
};
|
};
|
||||||
|
|
||||||
&switch0 {
|
&switch0 {
|
||||||
@ -75,6 +79,9 @@
|
|||||||
port@0 {
|
port@0 {
|
||||||
status = "okay";
|
status = "okay";
|
||||||
label = "lan";
|
label = "lan";
|
||||||
|
|
||||||
|
nvmem-cells = <&macaddr_hard 1>;
|
||||||
|
nvmem-cell-names = "mac-address";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
led-failsafe = &led_usr;
|
led-failsafe = &led_usr;
|
||||||
led-running = &led_usr;
|
led-running = &led_usr;
|
||||||
led-upgrade = &led_usr;
|
led-upgrade = &led_usr;
|
||||||
|
label-mac-device = &gmac1;
|
||||||
};
|
};
|
||||||
|
|
||||||
leds {
|
leds {
|
||||||
@ -94,6 +95,9 @@
|
|||||||
status = "okay";
|
status = "okay";
|
||||||
label = "wan";
|
label = "wan";
|
||||||
phy-handle = <ðphy0>;
|
phy-handle = <ðphy0>;
|
||||||
|
|
||||||
|
nvmem-cells = <&macaddr_hard 0>;
|
||||||
|
nvmem-cell-names = "mac-address";
|
||||||
};
|
};
|
||||||
|
|
||||||
ðphy0 {
|
ðphy0 {
|
||||||
@ -105,11 +109,17 @@
|
|||||||
port@1 {
|
port@1 {
|
||||||
status = "okay";
|
status = "okay";
|
||||||
label = "lan1";
|
label = "lan1";
|
||||||
|
|
||||||
|
nvmem-cells = <&macaddr_hard 1>;
|
||||||
|
nvmem-cell-names = "mac-address";
|
||||||
};
|
};
|
||||||
|
|
||||||
port@2 {
|
port@2 {
|
||||||
status = "okay";
|
status = "okay";
|
||||||
label = "lan2";
|
label = "lan2";
|
||||||
|
|
||||||
|
nvmem-cells = <&macaddr_hard 2>;
|
||||||
|
nvmem-cell-names = "mac-address";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -299,10 +299,6 @@ ramips_setup_macs()
|
|||||||
wan_mac=$(mtd_get_mac_ascii Config wan_hwaddr)
|
wan_mac=$(mtd_get_mac_ascii Config wan_hwaddr)
|
||||||
label_mac=$lan_mac
|
label_mac=$lan_mac
|
||||||
;;
|
;;
|
||||||
mikrotik,ltap-2hnd)
|
|
||||||
label_mac=$(cat "/sys/firmware/mikrotik/hard_config/mac_base")
|
|
||||||
lan_mac=$label_mac
|
|
||||||
;;
|
|
||||||
tplink,er605-v2)
|
tplink,er605-v2)
|
||||||
CI_UBIPART="firmware"
|
CI_UBIPART="firmware"
|
||||||
label_mac=$(mtd_get_mac_uci_config_ubi "tddp")
|
label_mac=$(mtd_get_mac_uci_config_ubi "tddp")
|
||||||
@ -314,14 +310,6 @@ ramips_setup_macs()
|
|||||||
wwan_mac=$(macaddr_add $label_mac 1)
|
wwan_mac=$(macaddr_add $label_mac 1)
|
||||||
ucidef_set_interface "wwan0" device "/dev/cdc-wdm0" protocol "qmi" macaddr "$wwan_mac"
|
ucidef_set_interface "wwan0" device "/dev/cdc-wdm0" protocol "qmi" macaddr "$wwan_mac"
|
||||||
;;
|
;;
|
||||||
mikrotik,routerboard-750gr3|\
|
|
||||||
mikrotik,routerboard-760igs|\
|
|
||||||
mikrotik,routerboard-m11g|\
|
|
||||||
mikrotik,routerboard-m33g)
|
|
||||||
label_mac=$(cat "/sys/firmware/mikrotik/hard_config/mac_base")
|
|
||||||
wan_mac=$label_mac
|
|
||||||
lan_mac=$(macaddr_add $label_mac 1)
|
|
||||||
;;
|
|
||||||
ruijie,rg-ew1200g-pro-v1.1)
|
ruijie,rg-ew1200g-pro-v1.1)
|
||||||
lan_mac=$(mtd_get_mac_ascii product_info ethaddr)
|
lan_mac=$(mtd_get_mac_ascii product_info ethaddr)
|
||||||
wan_mac=$(macaddr_add "$lan_mac" 8)
|
wan_mac=$(macaddr_add "$lan_mac" 8)
|
||||||
|
@ -4,26 +4,13 @@
|
|||||||
|
|
||||||
. /lib/functions/caldata.sh
|
. /lib/functions/caldata.sh
|
||||||
|
|
||||||
caldata_mikrotik_ath9k() {
|
|
||||||
local offset=$(($1))
|
|
||||||
local count=$(($2))
|
|
||||||
local macaddr=$3
|
|
||||||
local wlan_data="/sys/firmware/mikrotik/hard_config/wlan_data"
|
|
||||||
|
|
||||||
caldata_from_file $wlan_data $offset $count /tmp/$FIRMWARE
|
|
||||||
ath9k_patch_mac "$macaddr" /tmp/$FIRMWARE
|
|
||||||
caldata_sysfsload_from_file /tmp/$FIRMWARE 0x0 $count
|
|
||||||
rm -f /tmp/$FIRMWARE
|
|
||||||
}
|
|
||||||
|
|
||||||
board=$(board_name)
|
board=$(board_name)
|
||||||
|
|
||||||
case "$FIRMWARE" in
|
case "$FIRMWARE" in
|
||||||
"ath9k-eeprom-pci-0000:01:00.0.bin")
|
"ath9k-eeprom-pci-0000:01:00.0.bin")
|
||||||
case $board in
|
case $board in
|
||||||
mikrotik,ltap-2hnd)
|
mikrotik,ltap-2hnd)
|
||||||
mac_base="$(cat /sys/firmware/mikrotik/hard_config/mac_base)"
|
caldata_sysfsload_from_file "/sys/firmware/mikrotik/hard_config/wlan_data" 0x5000 0x440
|
||||||
caldata_mikrotik_ath9k 0x5000 0x440 $(macaddr_add "$mac_base" 1)
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
caldata_die "board $board is not supported yet"
|
caldata_die "board $board is not supported yet"
|
||||||
|
@ -202,7 +202,7 @@ CONFIG_NO_HZ_IDLE=y
|
|||||||
CONFIG_NR_CPUS=4
|
CONFIG_NR_CPUS=4
|
||||||
CONFIG_NVMEM=y
|
CONFIG_NVMEM=y
|
||||||
CONFIG_NVMEM_LAYOUTS=y
|
CONFIG_NVMEM_LAYOUTS=y
|
||||||
# CONFIG_NVMEM_LAYOUT_MIKROTIK is not set
|
CONFIG_NVMEM_LAYOUT_MIKROTIK=y
|
||||||
CONFIG_NVMEM_LAYOUT_U_BOOT_ENV=y
|
CONFIG_NVMEM_LAYOUT_U_BOOT_ENV=y
|
||||||
CONFIG_OF=y
|
CONFIG_OF=y
|
||||||
CONFIG_OF_ADDRESS=y
|
CONFIG_OF_ADDRESS=y
|
||||||
|
Loading…
x
Reference in New Issue
Block a user