Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mediatek: filogic: convert ASUS device to use NVMEM-on-UBI #14676

Merged
merged 3 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
62 changes: 54 additions & 8 deletions target/linux/mediatek/dts/mt7986a-asus-rt-ax59u.dts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

aliases {
serial0 = &uart0;
label-mac-device = &gmac0;
led-boot = &led_status_green;
led-failsafe = &led_status_red;
led-running = &led_status_green;
Expand All @@ -22,7 +23,7 @@

chosen {
stdout-path = "serial0:115200n8";
bootargs-override = "ubi.mtd=UBI_DEV";
rmilecki marked this conversation as resolved.
Show resolved Hide resolved
bootargs-override = "";
};

memory {
Expand Down Expand Up @@ -89,6 +90,8 @@
/* LAN */
compatible = "mediatek,eth-mac";
reg = <0>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
dangowrt marked this conversation as resolved.
Show resolved Hide resolved
phy-mode = "2500base-x";

fixed-link {
Expand Down Expand Up @@ -206,44 +209,87 @@
pinctrl-0 = <&spi_flash_pins>;
status = "okay";

spi_nand: spi_nand@0 {
spi_nand: flash@0 {
compatible = "spi-nand";
reg = <0>;
#address-cells = <1>;
#size-cells = <1>;
reg = <0>;

spi-max-frequency = <20000000>;
spi-tx-bus-width = <4>;
spi-rx-bus-width = <4>;

partitions: partitions {
/*
* ASUS bootloader tries to replace the partitions defined in
* Device Tree and by that also deletes all additional properties
* needed for UBI and NVMEM-on-UBI.
* Prevent this from happening by tricking the loader to delete and
* replace a bait node instead.
*/
partitions: dummy {
compatible = "u-boot-dummy-partitions";
#address-cells = <1>;
#size-cells = <1>;

partition@0 {
reg = <0x0 0x0>;
label = "remove_me";
};
};

partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

partition@0 {
label = "u-boot";
reg = <0x0 0x400000>;
label = "u-boot";
read-only;
};

partition@400000 {
compatible = "linux,ubi";
dangowrt marked this conversation as resolved.
Show resolved Hide resolved
reg = <0x400000 0xfc00000>;
label = "UBI_DEV";
reg = <0x400000 0x7c00000>;

volumes {
ubi_factory: ubi-volume-factory {
volname = "Factory";
};
};
};
};
};
};

&ubi_factory {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we used to do that a lot in OpenWrt but I have no idea why and I think recently we do less of such referencing.

If ubi_factory is in the same file (just few lines above) why not put nvmem-layout directly there? I think that would help reading DTS fle.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only makes sense to do with dts files that reference dtsi definitions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used to agree but was criticized for that and told that references are ok also if they reduce the level of indentation (which is why I applied this here). I don't mind either way, my screen is big enough and my text editor smart enough for me not to care.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My 2 cents when the nvmem conversion was done all the reference were done as it was easier to handle them with a script. But the normal way would be that if the node is in the same dts then the node should be changed directly.

nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;

eeprom_factory_0: eeprom@0 {
reg = <0x0 0x1000>;
};

macaddr_factory_4: macaddr@4 {
reg = <0x4 0x6>;
};
};
};

&watchdog {
status = "okay";
};

&wifi {
status = "okay";
pinctrl-names = "default", "dbdc";
nvmem-cells = <&eeprom_factory_0>;
nvmem-cell-names = "eeprom";
pinctrl-0 = <&wf_2g_5g_pins>;
pinctrl-1 = <&wf_dbdc_pins>;
pinctrl-names = "default", "dbdc";
status = "okay";
};

&trng {
Expand Down
58 changes: 52 additions & 6 deletions target/linux/mediatek/dts/mt7986a-asus-tuf-ax4200.dts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

aliases {
serial0 = &uart0;
label-mac-device = &gmac0;
led-boot = &led_system;
led-failsafe = &led_system;
led-running = &led_system;
Expand All @@ -21,7 +22,7 @@

chosen {
stdout-path = "serial0:115200n8";
bootargs-override = "ubi.mtd=UBI_DEV";
bootargs-override = "";
};

memory {
Expand Down Expand Up @@ -101,6 +102,8 @@
/* LAN */
compatible = "mediatek,eth-mac";
reg = <0>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
phy-mode = "2500base-x";

fixed-link {
Expand Down Expand Up @@ -215,25 +218,66 @@
spi-tx-bus-width = <4>;
spi-rx-bus-width = <4>;

partitions: partitions {
/*
* ASUS bootloader tries to replace the partitions defined in
* Device Tree and by that also deletes all additional properties
* needed for UBI and NVMEM-on-UBI.
* Prevent this from happening by tricking the loader to delete and
* replace a bait node instead.
*/
partitions: dummy {
compatible = "u-boot-dummy-partitions";
#address-cells = <1>;
#size-cells = <1>;

partition@0 {
reg = <0x0 0x0>;
label = "remove_me";
};
};

partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

partition@0 {
label = "bootloader";
reg = <0x0 0x400000>;
label = "bootloader";
read-only;
};

partition@400000 {
label = "UBI_DEV";
compatible = "linux,ubi";
reg = <0x400000 0xfc00000>;
label = "UBI_DEV";

volumes {
ubi_factory: ubi-volume-factory {
volname = "Factory";
};
};
};
};
};
};

&ubi_factory {
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;

eeprom_factory_0: eeprom@0 {
reg = <0x0 0x1000>;
};

macaddr_factory_4: macaddr@4 {
reg = <0x4 0x6>;
};
};
};

&switch {
ports {
#address-cells = <1>;
Expand Down Expand Up @@ -340,10 +384,12 @@
};

&wifi {
status = "okay";
pinctrl-names = "default", "dbdc";
nvmem-cells = <&eeprom_factory_0>;
nvmem-cell-names = "eeprom";
pinctrl-0 = <&wf_2g_5g_pins>;
pinctrl-1 = <&wf_dbdc_pins>;
pinctrl-names = "default", "dbdc";
status = "okay";
};

&trng {
Expand Down
58 changes: 52 additions & 6 deletions target/linux/mediatek/dts/mt7986a-asus-tuf-ax6000.dts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

aliases {
serial0 = &uart0;
label-mac-device = &gmac0;
led-boot = &led_system;
led-failsafe = &led_system;
led-running = &led_system;
Expand All @@ -21,7 +22,7 @@

chosen {
stdout-path = "serial0:115200n8";
bootargs-override = "ubi.mtd=UBI_DEV";
bootargs-override = "";
};

memory {
Expand Down Expand Up @@ -101,6 +102,8 @@
/* LAN */
compatible = "mediatek,eth-mac";
reg = <0>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
phy-mode = "2500base-x";

fixed-link {
Expand Down Expand Up @@ -219,33 +222,74 @@

spi_nand_flash: flash@0 {
compatible = "spi-nand";
reg = <0>;
#address-cells = <1>;
#size-cells = <1>;
reg = <0>;

spi-max-frequency = <20000000>;
spi-tx-bus-width = <4>;
spi-rx-bus-width = <4>;

partitions: partitions {
/*
* ASUS bootloader tries to replace the partitions defined in
* Device Tree and by that also deletes all additional properties
* needed for UBI and NVMEM-on-UBI.
* Prevent this from happening by tricking the loader to delete and
* replace a bait node instead.
*/
partitions: dummy {
compatible = "u-boot-dummy-partitions";
#address-cells = <1>;
#size-cells = <1>;

partition@0 {
reg = <0x0 0x0>;
label = "remove_me";
};
};

partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

partition@0 {
label = "bootloader";
reg = <0x0 0x400000>;
label = "bootloader";
read-only;
};

partition@400000 {
label = "UBI_DEV";
compatible = "linux,ubi";
reg = <0x400000 0xfc00000>;
label = "UBI_DEV";

volumes {
ubi_factory: ubi-volume-factory {
volname = "Factory";
};
};
};
};
};
};

&ubi_factory {
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;

eeprom_factory_0: eeprom@0 {
reg = <0x0 0x1000>;
};

macaddr_factory_4: macaddr@4 {
reg = <0x4 0x6>;
};
};
};

&switch {
ports {
#address-cells = <1>;
Expand Down Expand Up @@ -360,10 +404,12 @@
};

&wifi {
status = "okay";
nvmem-cells = <&eeprom_factory_0>;
nvmem-cell-names = "eeprom";
pinctrl-names = "default", "dbdc";
pinctrl-0 = <&wf_2g_5g_pins>;
pinctrl-1 = <&wf_dbdc_pins>;
status = "okay";
};

&trng {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,6 @@ mediatek_setup_macs()
local label_mac=""

case $board in
asus,rt-ax59u|\
asus,tuf-ax4200|\
asus,tuf-ax6000)
CI_UBIPART="UBI_DEV"
addr=$(mtd_get_mac_binary_ubi "Factory" 0x4)
wan_mac="${addr}"
lan_mac="${addr}"
;;
bananapi,bpi-r3)
wan_mac=$(macaddr_add $(cat /sys/class/net/eth0/address) 1)
;;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,8 @@ case "$FIRMWARE" in
;;
esac
;;
"mediatek/mt7986_eeprom_mt7976_dbdc.bin")
case "$board" in
asus,rt-ax59u|\
asus,tuf-ax4200)
CI_UBIPART="UBI_DEV"
caldata_extract_ubi "Factory" 0x0 0x1000
;;
esac
;;
"mediatek/mt7986_eeprom_mt7976_dual.bin")
case "$board" in
asus,tuf-ax6000)
CI_UBIPART="UBI_DEV"
caldata_extract_ubi "Factory" 0x0 0x1000
;;
jdcloud,re-cp-03)
caldata_extract_mmc "factory" 0x0 0x1000
;;
Expand Down