Skip to content

Commit df56ce3

Browse files
galakcarlescufi
authored andcommitted
drivers: ethernet: mcux: rework how unique mac is determined
Instead of having a Kconfig property, if there is no local-mac-address property in the devicetree than we'll generate a unique MAC address based on unique ID registers on the SoC. We remove the local-mac-address properties in the SoC dtsi files to match the default behavior that existed before (ie, unique MAC address) Signed-off-by: Kumar Gala <[email protected]>
1 parent b19cf0b commit df56ce3

File tree

5 files changed

+7
-43
lines changed

5 files changed

+7
-43
lines changed

drivers/ethernet/Kconfig.mcux

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -54,43 +54,12 @@ config ETH_MCUX_0
5454
help
5555
Include port 0 driver
5656

57-
if ETH_MCUX_0
58-
59-
choice ETH_MCUX_0_MAC_SELECT
60-
prompt "MAC address"
61-
help
62-
Choose how to configure MAC address.
63-
64-
config ETH_MCUX_0_UNIQUE_MAC
65-
bool "Stable MAC address"
66-
help
67-
Generate MAC address from MCU's unique identification register.
68-
endchoice
69-
70-
endif # ETH_MCUX_0
71-
7257
config ETH_MCUX_1
7358
bool "MCUX Ethernet port 1"
7459
depends on SOC_MIMXRT1062 || SOC_MIMXRT1064
7560
help
7661
Include port 1 driver
7762

78-
if ETH_MCUX_1
79-
80-
choice ETH_MCUX_1_MAC_SELECT
81-
prompt "MAC address"
82-
help
83-
Choose how to configure MAC address.
84-
85-
config ETH_MCUX_1_UNIQUE_MAC
86-
bool "Stable MAC address"
87-
help
88-
Generate MAC address from MCU's unique identification register.
89-
90-
endchoice
91-
92-
endif # ETH_MCUX_1
93-
9463
config ETH_MCUX_HW_ACCELERATION
9564
bool "Enable hardware acceleration"
9665
help

drivers/ethernet/eth_mcux.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -887,8 +887,8 @@ static void generate_random_mac(u8_t *mac_addr)
887887
}
888888
#endif
889889

890-
#if defined(CONFIG_ETH_MCUX_0_UNIQUE_MAC) || \
891-
defined(CONFIG_ETH_MCUX_1_UNIQUE_MAC)
890+
#if !DT_INST_NODE_HAS_PROP(0, local_mac_address) || \
891+
DT_HAS_NODE_STATUS_OKAY(DT_DRV_INST(1)) && !DT_INST_NODE_HAS_PROP(1, local_mac_address)
892892
static void generate_eth0_unique_mac(u8_t *mac_addr)
893893
{
894894
/* Trivially "hash" up to 128 bits of MCU unique identifier */
@@ -907,7 +907,7 @@ static void generate_eth0_unique_mac(u8_t *mac_addr)
907907
}
908908
#endif
909909

910-
#if defined(CONFIG_ETH_MCUX_1_UNIQUE_MAC)
910+
#if DT_HAS_NODE_STATUS_OKAY(DT_DRV_INST(1)) && !DT_INST_NODE_HAS_PROP(1, local_mac_address)
911911
static void generate_eth1_unique_mac(u8_t *mac_addr)
912912
{
913913
generate_eth0_unique_mac(mac_addr);
@@ -1204,15 +1204,14 @@ static struct eth_context eth_0_context = {
12041204
.phy_addr = 0U,
12051205
.phy_duplex = kPHY_FullDuplex,
12061206
.phy_speed = kPHY_Speed100M,
1207-
#if defined(CONFIG_ETH_MCUX_0_UNIQUE_MAC)
1208-
.generate_mac = generate_eth0_unique_mac,
1209-
#endif
12101207
#if DT_INST_PROP(0, zephyr_random_mac_address)
12111208
.generate_mac = generate_random_mac,
12121209
#endif
12131210
#if NODE_HAS_VALID_MAC_ADDR(DT_DRV_INST(0))
12141211
.mac_addr = DT_INST_PROP(0, local_mac_address),
12151212
.generate_mac = NULL,
1213+
#else
1214+
.generate_mac = generate_eth0_unique_mac,
12161215
#endif
12171216
};
12181217

@@ -1271,15 +1270,14 @@ static struct eth_context eth_1_context = {
12711270
.phy_addr = 0U,
12721271
.phy_duplex = kPHY_FullDuplex,
12731272
.phy_speed = kPHY_Speed100M,
1274-
#if defined(CONFIG_ETH_MCUX_1_UNIQUE_MAC)
1275-
.generate_mac = generate_eth1_unique_mac,
1276-
#endif
12771273
#if DT_INST_PROP(1, zephyr_random_mac_address)
12781274
.generate_mac = generate_random_mac,
12791275
#endif
12801276
#if NODE_HAS_VALID_MAC_ADDR(DT_DRV_INST(1))
12811277
.mac_addr = DT_INST_PROP(1, local_mac_address),
12821278
.generate_mac = NULL,
1279+
#else
1280+
.generate_mac = generate_eth1_unique_mac,
12831281
#endif
12841282
};
12851283

dts/arm/nxp/nxp_k6x.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,6 @@
473473
interrupts = <83 0>, <84 0>, <85 0>;
474474
interrupt-names = "TX", "RX", "ERR_MISC";
475475
status = "disabled";
476-
local-mac-address = [00 00 00 00 00 00];
477476
label = "ETH_0";
478477
clocks = <&sim KINETIS_SIM_CORESYS_CLK 0 0>;
479478
ptp {

dts/arm/nxp/nxp_rt.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,6 @@
536536
interrupts = <114 0>;
537537
interrupt-names = "COMMON";
538538
status = "disabled";
539-
local-mac-address = [00 00 00 00 00 00];
540539
label = "ETH_0";
541540
ptp {
542541
compatible = "nxp,kinetis-ptp";

dts/arm/nxp/nxp_rt1060.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
interrupts = <152 0>;
3131
interrupt-names = "COMMON";
3232
status = "disabled";
33-
local-mac-address = [00 00 00 00 00 00];
3433
label = "ETH_1";
3534
ptp {
3635
compatible = "nxp,kinetis-ptp";

0 commit comments

Comments
 (0)