Skip to content

Commit

Permalink
ramips: convert mtd-mac-address to nvmem implementation
Browse files Browse the repository at this point in the history
Define nvmem-cells and convert mtd-mac-address to nvmem implementation.
The conversion is done with an automated script.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
  • Loading branch information
Ansuel authored and ynezz committed Jul 19, 2021
1 parent abc17bf commit 06bb4a5
Show file tree
Hide file tree
Showing 319 changed files with 4,213 additions and 434 deletions.
13 changes: 12 additions & 1 deletion target/linux/ramips/dts/mt7620a_aigale_ai-br100.dts
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,22 @@
};

&ethernet {
mtd-mac-address = <&factory 0x4>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";

mediatek,portmap = "llllw";
};

&wmac {
ralink,mtd-eeprom = <&factory 0x0>;
};

&factory {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_factory_4: macaddr@4 {
reg = <0x4 0x6>;
};
};
13 changes: 12 additions & 1 deletion target/linux/ramips/dts/mt7620a_alfa-network_ac1200rm.dts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
pinctrl-names = "default";
pinctrl-0 = <&ephy_pins>;

mtd-mac-address = <&factory 0x28>;
nvmem-cells = <&macaddr_factory_28>;
nvmem-cell-names = "mac-address";

mediatek,portmap = "llllw";
};
Expand Down Expand Up @@ -148,3 +149,13 @@
&wmac {
ralink,mtd-eeprom = <&factory 0x0>;
};

&factory {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_factory_28: macaddr@28 {
reg = <0x28 0x6>;
};
};
13 changes: 12 additions & 1 deletion target/linux/ramips/dts/mt7620a_alfa-network_r36m-e4g.dts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@
};

&ethernet {
mtd-mac-address = <&factory 0x28>;
nvmem-cells = <&macaddr_factory_28>;
nvmem-cell-names = "mac-address";
};

&gpio1 {
Expand Down Expand Up @@ -209,3 +210,13 @@
&wmac {
ralink,mtd-eeprom = <&factory 0x0>;
};

&factory {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_factory_28: macaddr@28 {
reg = <0x28 0x6>;
};
};
13 changes: 12 additions & 1 deletion target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
};

&ethernet {
mtd-mac-address = <&factory 0x28>;
nvmem-cells = <&macaddr_factory_28>;
nvmem-cell-names = "mac-address";
};

&gpio1 {
Expand Down Expand Up @@ -178,3 +179,13 @@
&wmac {
status = "disabled";
};

&factory {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_factory_28: macaddr@28 {
reg = <0x28 0x6>;
};
};
13 changes: 12 additions & 1 deletion target/linux/ramips/dts/mt7620a_asus_rt-ac5x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
};

&ethernet {
mtd-mac-address = <&factory 0x28>;
nvmem-cells = <&macaddr_factory_28>;
nvmem-cell-names = "mac-address";

mediatek,portmap = "wllll";
};
Expand All @@ -134,3 +135,13 @@
&pcie {
status = "okay";
};

&factory {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_factory_28: macaddr@28 {
reg = <0x28 0x6>;
};
};
13 changes: 12 additions & 1 deletion target/linux/ramips/dts/mt7620a_bdcom_wap2100-sk.dts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
};

&ethernet {
mtd-mac-address = <&factory 0x4>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";

mediatek,portmap = "wllll";
};
Expand All @@ -144,3 +145,13 @@
function = "gpio";
};
};

&factory {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_factory_4: macaddr@4 {
reg = <0x4 0x6>;
};
};
13 changes: 12 additions & 1 deletion target/linux/ramips/dts/mt7620a_buffalo_whr-1166d.dts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@
pinctrl-names = "default";
pinctrl-0 = <&rgmii1_pins &mdio_pins>;

mtd-mac-address = <&factory 0x4>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";

port@5 {
status = "okay";
Expand Down Expand Up @@ -173,3 +174,13 @@
ieee80211-freq-limit = <5000000 6000000>;
};
};

&factory {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_factory_4: macaddr@4 {
reg = <0x4 0x6>;
};
};
13 changes: 12 additions & 1 deletion target/linux/ramips/dts/mt7620a_buffalo_whr-300hp2.dts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@
pinctrl-names = "default";
pinctrl-0 = <&ephy_pins>;

mtd-mac-address = <&factory 0x4>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";

mediatek,portmap = "llllw";
};
Expand All @@ -149,3 +150,13 @@
pinctrl-names = "default";
pinctrl-0 = <&pa_pins>;
};

&factory {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_factory_4: macaddr@4 {
reg = <0x4 0x6>;
};
};
13 changes: 12 additions & 1 deletion target/linux/ramips/dts/mt7620a_buffalo_whr-600d.dts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@
pinctrl-names = "default";
pinctrl-0 = <&ephy_pins>;

mtd-mac-address = <&factory 0x4>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";

mediatek,portmap = "llllw";
};
Expand All @@ -159,3 +160,13 @@
ralink,mtd-eeprom = <&factory 0x8000>;
};
};

&factory {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_factory_4: macaddr@4 {
reg = <0x4 0x6>;
};
};
19 changes: 16 additions & 3 deletions target/linux/ramips/dts/mt7620a_cameo_810.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@
};

&ethernet {
mtd-mac-address = <&factory 0x28>;
nvmem-cells = <&macaddr_factory_28>;
nvmem-cell-names = "mac-address";

mediatek,portmap = "llllw";
};
Expand All @@ -141,7 +142,8 @@
pinctrl-0 = <&pa_pins>;

ralink,mtd-eeprom = <&factory 0x0>;
mtd-mac-address = <&factory 0x28>;
nvmem-cells = <&macaddr_factory_28>;
nvmem-cell-names = "mac-address";
};

&pcie {
Expand All @@ -153,7 +155,18 @@
reg = <0x0000 0 0 0 0>;
mediatek,mtd-eeprom = <&factory 0x8000>;
ieee80211-freq-limit = <5000000 6000000>;
mtd-mac-address = <&factory 0x28>;
nvmem-cells = <&macaddr_factory_28>;
nvmem-cell-names = "mac-address";
mac-address-increment = <2>;
};
};

&factory {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_factory_28: macaddr@28 {
reg = <0x28 0x6>;
};
};
13 changes: 12 additions & 1 deletion target/linux/ramips/dts/mt7620a_dlink_dch-m225.dts
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,22 @@
};

&ethernet {
mtd-mac-address = <&factory 0x4>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
};

&wmac {
ralink,mtd-eeprom = <&factory 0x0>;
pinctrl-names = "default";
pinctrl-0 = <&pa_pins>;
};

&factory {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_factory_4: macaddr@4 {
reg = <0x4 0x6>;
};
};
13 changes: 12 additions & 1 deletion target/linux/ramips/dts/mt7620a_dlink_dir-510l.dts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@
&pcie0 {
mt76x0e@0,0 {
reg = <0x0000 0 0 0 0>;
mtd-mac-address = <&config 0xe490>;
nvmem-cells = <&macaddr_config_e490>;
nvmem-cell-names = "mac-address";
mac-address-increment = <(2)>;
mediatek,mtd-eeprom = <&config 0xe05d>;
};
Expand All @@ -126,3 +127,13 @@
function = "gpio";
};
};

&config {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_config_e490: macaddr@e490 {
reg = <0xe490 0x6>;
};
};
13 changes: 12 additions & 1 deletion target/linux/ramips/dts/mt7620a_dlink_dwr-118-a1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@
&pcie0 {
wifi@0,0 {
reg = <0x0000 0 0 0 0>;
mtd-mac-address = <&config 0xe496>;
nvmem-cells = <&macaddr_config_e496>;
nvmem-cell-names = "mac-address";
mac-address-increment = <(2)>;
mediatek,mtd-eeprom = <&config 0xe083>;

Expand Down Expand Up @@ -188,3 +189,13 @@
mediatek,port4-gmac;
mediatek,ephy-base = /bits/ 8 <8>;
};

&config {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_config_e496: macaddr@e496 {
reg = <0xe496 0x6>;
};
};
13 changes: 12 additions & 1 deletion target/linux/ramips/dts/mt7620a_dlink_dwr-118-a2.dts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@
wifi@0,0 {
reg = <0x0000 0 0 0 0>;
ieee80211-freq-limit = <5000000 6000000>;
mtd-mac-address = <&config 0xe4a8>;
nvmem-cells = <&macaddr_config_e4a8>;
nvmem-cell-names = "mac-address";
mac-address-increment = <(2)>;

led {
Expand Down Expand Up @@ -176,3 +177,13 @@
mediatek,port4-gmac;
mediatek,ephy-base = /bits/ 8 <2>;
};

&config {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_config_e4a8: macaddr@e4a8 {
reg = <0xe4a8 0x6>;
};
};
13 changes: 12 additions & 1 deletion target/linux/ramips/dts/mt7620a_dlink_dwr-960.dts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@
reg = <0x0000 0 0 0 0>;
ieee80211-freq-limit = <5000000 6000000>;
mediatek,mtd-eeprom = <&config 0xe08e>;
mtd-mac-address = <&config 0xe50e>;
nvmem-cells = <&macaddr_config_e50e>;
nvmem-cell-names = "mac-address";
mac-address-increment = <2>;
};
};
Expand All @@ -186,3 +187,13 @@
function = "gpio";
};
};

&config {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_config_e50e: macaddr@e50e {
reg = <0xe50e 0x6>;
};
};
13 changes: 12 additions & 1 deletion target/linux/ramips/dts/mt7620a_edimax_br-6478ac-v2.dts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@
pinctrl-names = "default";
pinctrl-0 = <&rgmii1_pins &rgmii2_pins &mdio_pins>;

mtd-mac-address = <&factory 0x4>;
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";

mediatek,portmap = "wllll";

Expand Down Expand Up @@ -204,3 +205,13 @@
&ohci {
status = "okay";
};

&factory {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

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

11 comments on commit 06bb4a5

@ptpt52
Copy link
Contributor

@ptpt52 ptpt52 commented on 06bb4a5 Jul 19, 2021

Choose a reason for hiding this comment

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

I notice that many board change to nvmem implementation
but some not
why?

@Ansuel @ynezz

target/linux/ramips/dts/mt7620a_zbtlink_zbt-we826.dtsi:73:	mtd-mac-address = <&factory 0x4>;
target/linux/ramips/dts/rt5350_nexx_wt1520.dtsi:29:	mtd-mac-address = <&factory 0x4>;
target/linux/ramips/dts/mt7621_dlink_dir-8xx.dtsi:95:	mtd-mac-address = <&factory 0xe000>;
target/linux/ramips/dts/mt7621_dlink_dir-8xx.dtsi:123:			mtd-mac-address = <&factory 0xe006>;
target/linux/ramips/dts/mt7620n_nexx_wt3020.dtsi:42:	mtd-mac-address = <&factory 0x4>;
target/linux/ramips/dts/mt7621_xiaomi_mi-router-4.dts:70:	mtd-mac-address = <&factory 0xe000>;
target/linux/ramips/dts/mt7620a_xiaomi_miwifi-r3.dts:136:	mtd-mac-address = <&factory 0x28>;
target/linux/ramips/dts/rt5350_7links_px-4885.dtsi:52:	mtd-mac-address = <&devconf 0x28>;
target/linux/ramips/dts/mt7621_dlink_dir-853-a3.dts:161:		mtd-mac-address = <&factory 0x4>;
target/linux/ramips/dts/mt7621_dlink_dir-853-a3.dts:166:	mtd-mac-address = <&factory 0xe000>;

@Ansuel
Copy link
Member Author

@Ansuel Ansuel commented on 06bb4a5 Jul 20, 2021

Choose a reason for hiding this comment

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

99% of them are dtsi that require manual migration and we still have to take a decision on how to address these dtsi

Aside from that do you have something to report? Someone reported that currently mt7621 generates random mac instead of the correct one. Can you confirm that?

@ptpt52
Copy link
Contributor

@ptpt52 ptpt52 commented on 06bb4a5 Jul 20, 2021

Choose a reason for hiding this comment

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

I would test some board and report back.

@ptpt52
Copy link
Contributor

@ptpt52 ptpt52 commented on 06bb4a5 Jul 20, 2021

Choose a reason for hiding this comment

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

@Ansuel confirm that it generates random mac.

@ptpt52
Copy link
Contributor

@ptpt52 ptpt52 commented on 06bb4a5 Jul 20, 2021

Choose a reason for hiding this comment

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

some boot log:

[    0.874646] mt7621-nand 1e003000.nand: Using programmed access timing: 31c07388
[    0.882198] nand: device found, Manufacturer ID: 0xef, Chip ID: 0xf1
[    0.888518] nand: Winbond W29N01HV
[    0.891921] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[    0.899457] mt7621-nand 1e003000.nand: ECC strength adjusted to 4 bits
[    0.906006] mt7621-nand 1e003000.nand: Using programmed access timing: 21005134
[    0.913300] mt7621-nand 1e003000.nand: Using programmed access timing: 21005134
[    0.920574] Scanning device for bad blocks
[    1.573535] 5 fixed-partitions partitions found on MTD device mt7621-nand
[    1.580289] Creating 5 MTD partitions on "mt7621-nand":
[    1.585512] 0x000000000000-0x000000080000 : "Bootloader"
[    1.592370] 0x000000080000-0x000000100000 : "Config"
[    1.598597] 0x000000100000-0x000000180000 : "factory"
[    1.605181] 0x000000180000-0x000000580000 : "kernel"
[    1.611620] 0x000000580000-0x000007700000 : "ubi"
[    1.619636] libphy: Fixed MDIO Bus: probed
[    1.661545] libphy: mdio: probed
[    1.664974] mt7530 mdio-bus:1f: MT7530 adapts as multi-chip module
[    1.673989] mtk_soc_eth 1e100000.ethernet: generated random MAC address 26:8f:92:db:b6:d3
[    1.683092] mtk_soc_eth 1e100000.ethernet eth0: mediatek frame engine at 0xbe100000, irq 21
[    1.691504] mtk_soc_eth 1e100000.ethernet: generated random MAC address da:77:14:a0:56:ea
[    1.700367] mtk_soc_eth 1e100000.ethernet wan: mediatek frame engine at 0xbe100000, irq 21
[    1.711040] mt7621-pci 1e140000.pcie: Parsing DT failed
[    1.718593] NET: Registered protocol family 10
[    1.724548] Segment Routing with IPv6
[    1.728292] NET: Registered protocol family 17

@ptpt52
Copy link
Contributor

@ptpt52 ptpt52 commented on 06bb4a5 Jul 20, 2021

Choose a reason for hiding this comment

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

@Ansuel which code parse the 'nvmem-cells' property?

@ynezz
Copy link
Member

@ynezz ynezz commented on 06bb4a5 Jul 20, 2021

Choose a reason for hiding this comment

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

@Ansuel which code parse the 'nvmem-cells' property?

Can you try enabling CONFIG_NVMEM=y in your kernel config?

@ptpt52
Copy link
Contributor

@ptpt52 ptpt52 commented on 06bb4a5 Jul 20, 2021

Choose a reason for hiding this comment

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

@Ansuel which code parse the 'nvmem-cells' property?

Can you try enabling CONFIG_NVMEM=y in your kernel config?

seems no help.

@ptpt52
Copy link
Contributor

@ptpt52 ptpt52 commented on 06bb4a5 Jul 20, 2021

Choose a reason for hiding this comment

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

@Ansuel which code parse the 'nvmem-cells' property?

Can you try enabling CONFIG_NVMEM=y in your kernel config?

@Ansuel no help. any issue report on other platform? only happens on mt7621?

@fda77
Copy link

@fda77 fda77 commented on 06bb4a5 Jul 21, 2021

Choose a reason for hiding this comment

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

mt7622 too 1e6f330

@dangowrt
Copy link
Member

Choose a reason for hiding this comment

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

Fixed by 6bc6a41

Please sign in to comment.