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 <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2020-04-23 13:22:38 -05:00 committed by Carles Cufí
commit df56ce3efb
5 changed files with 7 additions and 43 deletions

View file

@ -54,43 +54,12 @@ config ETH_MCUX_0
help help
Include port 0 driver Include port 0 driver
if ETH_MCUX_0
choice ETH_MCUX_0_MAC_SELECT
prompt "MAC address"
help
Choose how to configure MAC address.
config ETH_MCUX_0_UNIQUE_MAC
bool "Stable MAC address"
help
Generate MAC address from MCU's unique identification register.
endchoice
endif # ETH_MCUX_0
config ETH_MCUX_1 config ETH_MCUX_1
bool "MCUX Ethernet port 1" bool "MCUX Ethernet port 1"
depends on SOC_MIMXRT1062 || SOC_MIMXRT1064 depends on SOC_MIMXRT1062 || SOC_MIMXRT1064
help help
Include port 1 driver Include port 1 driver
if ETH_MCUX_1
choice ETH_MCUX_1_MAC_SELECT
prompt "MAC address"
help
Choose how to configure MAC address.
config ETH_MCUX_1_UNIQUE_MAC
bool "Stable MAC address"
help
Generate MAC address from MCU's unique identification register.
endchoice
endif # ETH_MCUX_1
config ETH_MCUX_HW_ACCELERATION config ETH_MCUX_HW_ACCELERATION
bool "Enable hardware acceleration" bool "Enable hardware acceleration"
help help

View file

@ -887,8 +887,8 @@ static void generate_random_mac(u8_t *mac_addr)
} }
#endif #endif
#if defined(CONFIG_ETH_MCUX_0_UNIQUE_MAC) || \ #if !DT_INST_NODE_HAS_PROP(0, local_mac_address) || \
defined(CONFIG_ETH_MCUX_1_UNIQUE_MAC) DT_HAS_NODE_STATUS_OKAY(DT_DRV_INST(1)) && !DT_INST_NODE_HAS_PROP(1, local_mac_address)
static void generate_eth0_unique_mac(u8_t *mac_addr) static void generate_eth0_unique_mac(u8_t *mac_addr)
{ {
/* Trivially "hash" up to 128 bits of MCU unique identifier */ /* Trivially "hash" up to 128 bits of MCU unique identifier */
@ -907,7 +907,7 @@ static void generate_eth0_unique_mac(u8_t *mac_addr)
} }
#endif #endif
#if defined(CONFIG_ETH_MCUX_1_UNIQUE_MAC) #if DT_HAS_NODE_STATUS_OKAY(DT_DRV_INST(1)) && !DT_INST_NODE_HAS_PROP(1, local_mac_address)
static void generate_eth1_unique_mac(u8_t *mac_addr) static void generate_eth1_unique_mac(u8_t *mac_addr)
{ {
generate_eth0_unique_mac(mac_addr); generate_eth0_unique_mac(mac_addr);
@ -1204,15 +1204,14 @@ static struct eth_context eth_0_context = {
.phy_addr = 0U, .phy_addr = 0U,
.phy_duplex = kPHY_FullDuplex, .phy_duplex = kPHY_FullDuplex,
.phy_speed = kPHY_Speed100M, .phy_speed = kPHY_Speed100M,
#if defined(CONFIG_ETH_MCUX_0_UNIQUE_MAC)
.generate_mac = generate_eth0_unique_mac,
#endif
#if DT_INST_PROP(0, zephyr_random_mac_address) #if DT_INST_PROP(0, zephyr_random_mac_address)
.generate_mac = generate_random_mac, .generate_mac = generate_random_mac,
#endif #endif
#if NODE_HAS_VALID_MAC_ADDR(DT_DRV_INST(0)) #if NODE_HAS_VALID_MAC_ADDR(DT_DRV_INST(0))
.mac_addr = DT_INST_PROP(0, local_mac_address), .mac_addr = DT_INST_PROP(0, local_mac_address),
.generate_mac = NULL, .generate_mac = NULL,
#else
.generate_mac = generate_eth0_unique_mac,
#endif #endif
}; };
@ -1271,15 +1270,14 @@ static struct eth_context eth_1_context = {
.phy_addr = 0U, .phy_addr = 0U,
.phy_duplex = kPHY_FullDuplex, .phy_duplex = kPHY_FullDuplex,
.phy_speed = kPHY_Speed100M, .phy_speed = kPHY_Speed100M,
#if defined(CONFIG_ETH_MCUX_1_UNIQUE_MAC)
.generate_mac = generate_eth1_unique_mac,
#endif
#if DT_INST_PROP(1, zephyr_random_mac_address) #if DT_INST_PROP(1, zephyr_random_mac_address)
.generate_mac = generate_random_mac, .generate_mac = generate_random_mac,
#endif #endif
#if NODE_HAS_VALID_MAC_ADDR(DT_DRV_INST(1)) #if NODE_HAS_VALID_MAC_ADDR(DT_DRV_INST(1))
.mac_addr = DT_INST_PROP(1, local_mac_address), .mac_addr = DT_INST_PROP(1, local_mac_address),
.generate_mac = NULL, .generate_mac = NULL,
#else
.generate_mac = generate_eth1_unique_mac,
#endif #endif
}; };

View file

@ -473,7 +473,6 @@
interrupts = <83 0>, <84 0>, <85 0>; interrupts = <83 0>, <84 0>, <85 0>;
interrupt-names = "TX", "RX", "ERR_MISC"; interrupt-names = "TX", "RX", "ERR_MISC";
status = "disabled"; status = "disabled";
local-mac-address = [00 00 00 00 00 00];
label = "ETH_0"; label = "ETH_0";
clocks = <&sim KINETIS_SIM_CORESYS_CLK 0 0>; clocks = <&sim KINETIS_SIM_CORESYS_CLK 0 0>;
ptp { ptp {

View file

@ -536,7 +536,6 @@
interrupts = <114 0>; interrupts = <114 0>;
interrupt-names = "COMMON"; interrupt-names = "COMMON";
status = "disabled"; status = "disabled";
local-mac-address = [00 00 00 00 00 00];
label = "ETH_0"; label = "ETH_0";
ptp { ptp {
compatible = "nxp,kinetis-ptp"; compatible = "nxp,kinetis-ptp";

View file

@ -30,7 +30,6 @@
interrupts = <152 0>; interrupts = <152 0>;
interrupt-names = "COMMON"; interrupt-names = "COMMON";
status = "disabled"; status = "disabled";
local-mac-address = [00 00 00 00 00 00];
label = "ETH_1"; label = "ETH_1";
ptp { ptp {
compatible = "nxp,kinetis-ptp"; compatible = "nxp,kinetis-ptp";