Browse Source

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 <[email protected]>
Daniel Golle 1 year ago
parent
commit
bf20585412

+ 45 - 0
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>;
+						};
+					};
+				};
+			};
+		};
+	};
 };

+ 0 - 5
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)

+ 0 - 1
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
 		;;