From bf205854128cc791e5805ed20ef3bd0bb53c339a Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sat, 17 Feb 2024 22:14:01 +0000 Subject: [PATCH] mediatek: filogic: convert GL.iNet MT-6000 to NVMEM-on-MMC Now that we can reference MMC partitions in device tree, use that to get rid of Wi-Fi EEPROM and MAC address setup in userspace. Signed-off-by: Daniel Golle --- .../mediatek/dts/mt7986a-glinet-gl-mt6000.dts | 45 +++++++++++++++++++ .../filogic/base-files/etc/board.d/02_network | 5 --- .../etc/hotplug.d/firmware/11-mt76-caldata | 1 - 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/target/linux/mediatek/dts/mt7986a-glinet-gl-mt6000.dts b/target/linux/mediatek/dts/mt7986a-glinet-gl-mt6000.dts index 26996e7b4a..fd0e1a6915 100644 --- a/target/linux/mediatek/dts/mt7986a-glinet-gl-mt6000.dts +++ b/target/linux/mediatek/dts/mt7986a-glinet-gl-mt6000.dts @@ -13,6 +13,7 @@ aliases { serial0 = &uart0; + label-mac-device = &gmac1; led-boot = &led_blue; led-failsafe = &led_blue; led-running = &led_white; @@ -84,6 +85,8 @@ compatible = "mediatek,eth-mac"; reg = <0>; phy-mode = "2500base-x"; + nvmem-cells = <&macaddr_factory_a 2>; + nvmem-cell-names = "mac-address"; fixed-link { speed = <2500>; @@ -95,6 +98,8 @@ gmac1: mac@1 { compatible = "mediatek,eth-mac"; reg = <1>; + nvmem-cells = <&macaddr_factory_a 0>; + nvmem-cell-names = "mac-address"; phy-mode = "2500base-x"; phy-handle = <&phy1>; }; @@ -285,6 +290,8 @@ }; &wifi { + nvmem-cells = <&eeprom_factory_0>; + nvmem-cell-names = "eeprom"; pinctrl-names = "default"; pinctrl-0 = <&wf_2g_5g_pins>; status = "okay"; @@ -306,4 +313,42 @@ no-sd; no-sdio; status = "okay"; + + card@0 { + compatible = "mmc-card"; + reg = <0>; + + block { + compatible = "block-device"; + partitions { + block-partition-env { + partname = "u-boot-env"; + + nvmem-layout { + compatible = "u-boot,env-layout"; + }; + }; + + block-partition-factory { + partname = "factory"; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + eeprom_factory_0: eeprom@0 { + reg = <0x0 0x1000>; + }; + + macaddr_factory_a: macaddr@a { + compatible = "mac-base"; + reg = <0xa 0x6>; + #nvmem-cell-cells = <1>; + }; + }; + }; + }; + }; + }; }; diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network index 5542f1518a..caeeaaf223 100644 --- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network +++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network @@ -134,11 +134,6 @@ mediatek_setup_macs() wan_mac="$label_mac" lan_mac="$(macaddr_add $label_mac 1)" ;; - glinet,gl-mt6000) - label_mac=$(mmc_get_mac_binary factory 0x0a) - wan_mac=$label_mac - lan_mac=$(macaddr_add "$label_mac" 2) - ;; h3c,magic-nx30-pro) wan_mac=$(mtd_get_mac_ascii pdt_data_1 ethaddr) lan_mac=$(macaddr_add "$wan_mac" 1) diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata index 22ab26608f..1ec648584d 100644 --- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata +++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata @@ -72,7 +72,6 @@ case "$FIRMWARE" in CI_UBIPART="UBI_DEV" caldata_extract_ubi "Factory" 0x0 0x1000 ;; - glinet,gl-mt6000|\ jdcloud,re-cp-03) caldata_extract_mmc "factory" 0x0 0x1000 ;; -- 2.30.2