drivers: ethernet: Fix adin2111 multiple compatibles support
The adin2111 ethernet driver supports both adi,adin2111 and adi,adin1110 devicetree compatibles, however it failed to build when both compatibles existed in the same devicetree. This may be an unusual configuration for real systems, but was found when extending tests/drivers/build_all/ethernet to cover both compatibles. Signed-off-by: Maureen Helm <maureen.helm@analog.com>
This commit is contained in:
parent
cdebe6ef71
commit
e503ec4064
1 changed files with 17 additions and 17 deletions
|
@ -943,57 +943,57 @@ static const struct ethernet_api adin2111_port_api = {
|
|||
#define ADIN2111_PORT_MAC(adin_n, port_n) \
|
||||
DT_PROP(DT_CHILD(DT_DRV_INST(adin_n), port##port_n), local_mac_address)
|
||||
|
||||
#define ADIN2111_PORT_DEVICE_INIT_INSTANCE(parent_n, port_n, phy_n) \
|
||||
static struct adin2111_port_data adin2111_port_data_##port_n = { \
|
||||
#define ADIN2111_PORT_DEVICE_INIT_INSTANCE(parent_n, port_n, phy_n, name) \
|
||||
static struct adin2111_port_data name##_port_data_##port_n = { \
|
||||
.mac_addr = ADIN2111_PORT_MAC(parent_n, phy_n), \
|
||||
}; \
|
||||
static const struct adin2111_port_config adin2111_port_config_##port_n = { \
|
||||
static const struct adin2111_port_config name##_port_config_##port_n = { \
|
||||
.adin = DEVICE_DT_INST_GET(parent_n), \
|
||||
.phy = ADIN2111_MDIO_PHY_BY_ADDR(parent_n, phy_n), \
|
||||
.port_idx = port_n, \
|
||||
.phy_addr = phy_n, \
|
||||
}; \
|
||||
NET_DEVICE_INIT_INSTANCE(adin2111_port_##port_n, "port_" ADIN2111_XSTR(port_n), port_n, \
|
||||
NULL, NULL, &adin2111_port_data_##port_n, \
|
||||
&adin2111_port_config_##port_n, CONFIG_ETH_INIT_PRIORITY, \
|
||||
NET_DEVICE_INIT_INSTANCE(name##_port_##port_n, "port_" ADIN2111_XSTR(port_n), port_n, \
|
||||
NULL, NULL, &name##_port_data_##port_n, \
|
||||
&name##_port_config_##port_n, CONFIG_ETH_INIT_PRIORITY, \
|
||||
&adin2111_port_api, ETHERNET_L2, \
|
||||
NET_L2_GET_CTX_TYPE(ETHERNET_L2), NET_ETH_MTU);
|
||||
|
||||
#define ADIN2111_SPI_OPERATION ((uint16_t)(SPI_OP_MODE_MASTER | SPI_TRANSFER_MSB | SPI_WORD_SET(8)))
|
||||
|
||||
#define ADIN2111_MAC_INITIALIZE(inst, dev_id, ifaces) \
|
||||
static uint8_t __aligned(4) adin2111_buffer_##inst[CONFIG_ETH_ADIN2111_BUFFER_SIZE]; \
|
||||
static const struct adin2111_config adin2111_config_##inst = { \
|
||||
#define ADIN2111_MAC_INITIALIZE(inst, dev_id, ifaces, name) \
|
||||
static uint8_t __aligned(4) name##_buffer_##inst[CONFIG_ETH_ADIN2111_BUFFER_SIZE]; \
|
||||
static const struct adin2111_config name##_config_##inst = { \
|
||||
.id = dev_id, \
|
||||
.spi = SPI_DT_SPEC_INST_GET(inst, ADIN2111_SPI_OPERATION, 1), \
|
||||
.interrupt = GPIO_DT_SPEC_INST_GET(inst, int_gpios), \
|
||||
.reset = GPIO_DT_SPEC_INST_GET_OR(inst, reset_gpios, { 0 }), \
|
||||
}; \
|
||||
static struct adin2111_data adin2111_data_##inst = { \
|
||||
static struct adin2111_data name##_data_##inst = { \
|
||||
.ifaces_left_to_init = ifaces, \
|
||||
.port = {}, \
|
||||
.offload_sem = Z_SEM_INITIALIZER(adin2111_data_##inst.offload_sem, 0, 1), \
|
||||
.lock = Z_MUTEX_INITIALIZER(adin2111_data_##inst.lock), \
|
||||
.buf = adin2111_buffer_##inst, \
|
||||
.buf = name##_buffer_##inst, \
|
||||
}; \
|
||||
/* adin */ \
|
||||
DEVICE_DT_DEFINE(DT_DRV_INST(inst), adin2111_init, NULL, \
|
||||
&adin2111_data_##inst, &adin2111_config_##inst, \
|
||||
&name##_data_##inst, &name##_config_##inst, \
|
||||
POST_KERNEL, CONFIG_ETH_ADIN2111_INIT_PRIORITY, \
|
||||
NULL);
|
||||
|
||||
#define ADIN2111_MAC_INIT(inst) ADIN2111_MAC_INITIALIZE(inst, ADIN2111_MAC, 2) \
|
||||
#define ADIN2111_MAC_INIT(inst) ADIN2111_MAC_INITIALIZE(inst, ADIN2111_MAC, 2, adin2111) \
|
||||
/* ports */ \
|
||||
ADIN2111_PORT_DEVICE_INIT_INSTANCE(inst, 0, 1) \
|
||||
ADIN2111_PORT_DEVICE_INIT_INSTANCE(inst, 1, 2)
|
||||
ADIN2111_PORT_DEVICE_INIT_INSTANCE(inst, 0, 1, adin2111) \
|
||||
ADIN2111_PORT_DEVICE_INIT_INSTANCE(inst, 1, 2, adin2111)
|
||||
|
||||
#undef DT_DRV_COMPAT
|
||||
#define DT_DRV_COMPAT adi_adin2111
|
||||
DT_INST_FOREACH_STATUS_OKAY(ADIN2111_MAC_INIT)
|
||||
|
||||
#define ADIN1110_MAC_INIT(inst) ADIN2111_MAC_INITIALIZE(inst, ADIN1110_MAC, 1) \
|
||||
#define ADIN1110_MAC_INIT(inst) ADIN2111_MAC_INITIALIZE(inst, ADIN1110_MAC, 1, adin1110) \
|
||||
/* ports */ \
|
||||
ADIN2111_PORT_DEVICE_INIT_INSTANCE(inst, 0, 1)
|
||||
ADIN2111_PORT_DEVICE_INIT_INSTANCE(inst, 0, 1, adin1110)
|
||||
|
||||
#undef DT_DRV_COMPAT
|
||||
#define DT_DRV_COMPAT adi_adin1110
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue