From 5c880d2293f2a8d3b44eab3f58eae3618654b52d Mon Sep 17 00:00:00 2001 From: TOKITA Hiroshi Date: Wed, 27 Nov 2024 15:41:06 +0900 Subject: [PATCH 1/2] drivers: gpio: phy: adin2111: Fix to allow the use of multiple models Compilation will fail if both adin2111 and adin1100 are used at the same time. Changing to define different unique names for the symbols to avoid conflicts. Signed-off-by: TOKITA Hiroshi --- drivers/ethernet/phy/phy_adin2111.c | 46 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/ethernet/phy/phy_adin2111.c b/drivers/ethernet/phy/phy_adin2111.c index 48c83b5401b5..5f762ce69196 100644 --- a/drivers/ethernet/phy/phy_adin2111.c +++ b/drivers/ethernet/phy/phy_adin2111.c @@ -7,12 +7,6 @@ #include -#if DT_NODE_HAS_STATUS_OKAY(DT_INST(0, adi_adin2111_phy)) -#define DT_DRV_COMPAT adi_adin2111_phy -#else -#define DT_DRV_COMPAT adi_adin1100_phy -#endif - LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_PHY_LOG_LEVEL); #include @@ -636,22 +630,28 @@ static DEVICE_API(ethphy, phy_adin2111_api) = { .write = phy_adin2111_reg_write, }; -#define ADIN2111_PHY_INITIALIZE(n) \ - static const struct phy_adin2111_config phy_adin2111_config_##n = { \ - .mdio = DEVICE_DT_GET(DT_INST_BUS(n)), \ - .phy_addr = DT_INST_REG_ADDR(n), \ - .led0_en = DT_INST_PROP(n, led0_en), \ - .led1_en = DT_INST_PROP(n, led1_en), \ - .tx_24v = !(DT_INST_PROP(n, disable_tx_mode_24v)), \ - IF_ENABLED(DT_HAS_COMPAT_STATUS_OKAY(adi_adin1100_phy), \ - (.mii = 1)) \ - }; \ - static struct phy_adin2111_data phy_adin2111_data_##n = { \ - .sem = Z_SEM_INITIALIZER(phy_adin2111_data_##n.sem, 1, 1), \ - }; \ - DEVICE_DT_INST_DEFINE(n, &phy_adin2111_init, NULL, \ - &phy_adin2111_data_##n, &phy_adin2111_config_##n, \ - POST_KERNEL, CONFIG_PHY_INIT_PRIORITY, \ +#define ADIN2111_PHY_INITIALIZE(n, model) \ + static const struct phy_adin2111_config phy_adin##model##_config_##n = { \ + .mdio = DEVICE_DT_GET(DT_INST_BUS(n)), \ + .phy_addr = DT_INST_REG_ADDR(n), \ + .led0_en = DT_INST_PROP(n, led0_en), \ + .led1_en = DT_INST_PROP(n, led1_en), \ + .tx_24v = !(DT_INST_PROP(n, disable_tx_mode_24v)), \ + IF_ENABLED(DT_HAS_COMPAT_STATUS_OKAY(adi_adin1100_phy), \ + (.mii = 1)) \ + }; \ + static struct phy_adin2111_data phy_adin##model##_data_##n = { \ + .sem = Z_SEM_INITIALIZER(phy_adin##model##_data_##n.sem, 1, 1), \ + }; \ + DEVICE_DT_INST_DEFINE(n, &phy_adin2111_init, NULL, \ + &phy_adin##model##_data_##n, \ + &phy_adin##model##_config_##n, \ + POST_KERNEL, CONFIG_PHY_INIT_PRIORITY, \ &phy_adin2111_api); -DT_INST_FOREACH_STATUS_OKAY(ADIN2111_PHY_INITIALIZE) +#define DT_DRV_COMPAT adi_adin2111_phy +DT_INST_FOREACH_STATUS_OKAY_VARGS(ADIN2111_PHY_INITIALIZE, 2111) +#undef DT_DRV_COMPAT +#define DT_DRV_COMPAT adi_adin1100_phy +DT_INST_FOREACH_STATUS_OKAY_VARGS(ADIN2111_PHY_INITIALIZE, 1100) +#undef DT_DRV_COMPAT From a5f1f4a01218579ef68b50ff8d1f05afd535e60f Mon Sep 17 00:00:00 2001 From: TOKITA Hiroshi Date: Tue, 26 Nov 2024 17:23:52 +0900 Subject: [PATCH 2/2] tests: drivers: build_all: ethernet: Test handling plural "compatible"s Add device definitions in dt to test drivers that handle multiple "compatible"s by a single driver. Signed-off-by: TOKITA Hiroshi --- tests/drivers/build_all/ethernet/app.overlay | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/drivers/build_all/ethernet/app.overlay b/tests/drivers/build_all/ethernet/app.overlay index 98c3b89b2ac4..e74cb985a0fc 100644 --- a/tests/drivers/build_all/ethernet/app.overlay +++ b/tests/drivers/build_all/ethernet/app.overlay @@ -49,6 +49,36 @@ int-gpios = <&test_gpio 0 0>; microchip,interface-type = "rmii"; }; + + ethernet-phy@3 { + reg = <0x3>; + compatible = "microchip,ksz8794"; + status = "okay"; + reset-gpios = <&test_gpio 0 0>; + int-gpios = <&test_gpio 0 0>; + microchip,interface-type = "rmii"; + }; + + ethernet-phy@4 { + reg = <0x4>; + compatible = "microchip,ksz8863"; + status = "okay"; + reset-gpios = <&test_gpio 0 0>; + int-gpios = <&test_gpio 0 0>; + microchip,interface-type = "rmii"; + }; + + ethernet-phy@5 { + reg = <0x5>; + compatible = "adi,adin1100-phy"; + status = "okay"; + }; + + ethernet-phy@6 { + reg = <0x6>; + compatible = "adi,adin2111-phy"; + status = "okay"; + }; }; }; };