drivers: ethernet: Convert drivers to new DT device macros

Convert ethernet drivers from:

    DEVICE_AND_API_INIT -> DEVICE_DT_INST_DEFINE
    DEVICE_GET -> DEVICE_DT_INST_GET
    DEVICE_DECLARE -> DEVICE_DT_INST_DECLARE
    ETH_NET_DEVICE_INIT -> ETH_NET_DEVICE_DT_INST_DEFINE
    NET_DEVICE_INIT -> NET_DEVICE_DT_INST_DEFINE

etc...

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2020-12-16 11:17:24 -06:00 committed by Kumar Gala
parent 7bd5607c33
commit ae9e086802
13 changed files with 33 additions and 49 deletions

View file

@ -9,13 +9,6 @@ menuconfig ETH_GECKO
if ETH_GECKO
config ETH_GECKO_NAME
string "Device name"
default "ETH_0"
help
Device name allows user to obtain a handle to the device object
required by all driver API functions. Device name has to be unique.
config ETH_GECKO_IRQ_PRI
int "Interrupt priority"
default 0

View file

@ -17,10 +17,6 @@ menuconfig ETH_STM32_HAL
if ETH_STM32_HAL
config ETH_STM32_HAL_NAME
string "Device name"
default "ETH_0"
config ETH_STM32_HAL_IRQ_PRI
int "Controller interrupt priority"
default 0

View file

@ -210,7 +210,7 @@ static void e1000_isr(const struct device *device)
#define PCI_VENDOR_ID_INTEL 0x8086
#define PCI_DEVICE_ID_I82540EM 0x100e
DEVICE_DECLARE(eth_e1000);
DEVICE_DT_INST_DECLARE(0);
int e1000_probe(const struct device *device)
{
@ -279,7 +279,7 @@ static void e1000_iface_init(struct net_if *iface)
/* Do the phy link up only once */
IRQ_CONNECT(DT_INST_IRQN(0),
DT_INST_IRQ(0, priority),
e1000_isr, DEVICE_GET(eth_e1000),
e1000_isr, DEVICE_DT_INST_GET(0),
DT_INST_IRQ(0, sense));
irq_enable(DT_INST_IRQN(0));
@ -303,8 +303,7 @@ static const struct ethernet_api e1000_api = {
.send = e1000_send,
};
ETH_NET_DEVICE_INIT(eth_e1000,
"ETH_0",
ETH_NET_DEVICE_DT_INST_DEFINE(0,
e1000_probe,
device_pm_control_nop,
&e1000_dev,

View file

@ -846,7 +846,7 @@ static const struct eth_enc28j60_config eth_enc28j60_0_config = {
.timeout = CONFIG_ETH_ENC28J60_TIMEOUT,
};
ETH_NET_DEVICE_INIT(enc28j60_0, DT_INST_LABEL(0),
ETH_NET_DEVICE_DT_INST_DEFINE(0,
eth_enc28j60_init, device_pm_control_nop,
&eth_enc28j60_0_runtime, &eth_enc28j60_0_config,
CONFIG_ETH_INIT_PRIORITY, &api_funcs, NET_ETH_MTU);

View file

@ -770,7 +770,7 @@ static const struct enc424j600_config enc424j600_0_config = {
.timeout = CONFIG_ETH_ENC424J600_TIMEOUT,
};
ETH_NET_DEVICE_INIT(enc424j600_0, DT_INST_LABEL(0),
ETH_NET_DEVICE_DT_INST_DEFINE(0,
enc424j600_init, device_pm_control_nop,
&enc424j600_0_runtime, &enc424j600_0_config,
CONFIG_ETH_INIT_PRIORITY, &api_funcs, NET_ETH_MTU);

View file

@ -636,13 +636,13 @@ static const struct ethernet_api eth_api = {
.send = eth_tx,
};
DEVICE_DECLARE(eth_gecko);
DEVICE_DT_INST_DECLARE(0);
static void eth0_irq_config(void)
{
IRQ_CONNECT(DT_INST_IRQN(0),
DT_INST_IRQ(0, priority), eth_isr,
DEVICE_GET(eth_gecko), 0);
DEVICE_DT_INST_GET(0), 0);
irq_enable(DT_INST_IRQN(0));
}
@ -669,6 +669,6 @@ static struct eth_gecko_dev_data eth0_data = {
#endif
};
ETH_NET_DEVICE_INIT(eth_gecko, CONFIG_ETH_GECKO_NAME, eth_init,
ETH_NET_DEVICE_DT_INST_DEFINE(0, eth_init,
device_pm_control_nop, &eth0_data, &eth0_config,
CONFIG_ETH_INIT_PRIORITY, &eth_api, ETH_GECKO_MTU);

View file

@ -54,9 +54,6 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#define LITEETH_IRQ DT_INST_IRQN(0)
#define LITEETH_IRQ_PRIORITY CONFIG_ETH_LITEETH_0_IRQ_PRI
/* label */
#define LITEETH_LABEL DT_INST_LABEL(0)
struct eth_liteeth_dev_data {
struct net_if *iface;
uint8_t mac_addr[6];
@ -244,14 +241,14 @@ static const struct ethernet_api eth_api = {
.send = eth_tx
};
NET_DEVICE_INIT(eth0, LITEETH_LABEL, eth_initialize, device_pm_control_nop,
NET_DEVICE_DT_INST_DEFINE(0, eth_initialize, device_pm_control_nop,
&eth_data, &eth_config, CONFIG_ETH_INIT_PRIORITY, &eth_api,
ETHERNET_L2, NET_L2_GET_CTX_TYPE(ETHERNET_L2), NET_ETH_MTU);
static void eth_irq_config(void)
{
IRQ_CONNECT(LITEETH_IRQ, LITEETH_IRQ_PRIORITY, eth_irq_handler,
DEVICE_GET(eth0), 0);
DEVICE_DT_INST_GET(0), 0);
irq_enable(LITEETH_IRQ);
sys_write8(1, LITEETH_RX_EV_ENABLE);
}

View file

@ -1210,7 +1210,7 @@ static void eth_mcux_err_isr(const struct device *dev)
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(n, name, irq), \
DT_INST_IRQ_BY_NAME(n, name, priority), \
eth_mcux_##name##_isr, \
DEVICE_GET(eth_mcux_##n), \
DEVICE_DT_INST_GET(n), \
0); \
irq_enable(DT_INST_IRQ_BY_NAME(n, name, irq)); \
} while (0)
@ -1228,7 +1228,7 @@ static void eth_mcux_err_isr(const struct device *dev)
IRQ_CONNECT(DT_IRQ_BY_NAME(PTP_INST_NODEID(n), ieee1588_tmr, irq), \
DT_IRQ_BY_NAME(PTP_INST_NODEID(n), ieee1588_tmr, priority), \
eth_mcux_ptp_isr, \
DEVICE_GET(eth_mcux_##n), \
DEVICE_DT_INST_GET(n), \
0); \
irq_enable(DT_IRQ_BY_NAME(PTP_INST_NODEID(n), ieee1588_tmr, irq)); \
} while (0)
@ -1367,8 +1367,7 @@ static void eth_mcux_err_isr(const struct device *dev)
ETH_MCUX_PTP_FRAMEINFO(n) \
}; \
\
ETH_NET_DEVICE_INIT(eth_mcux_##n, \
DT_INST_LABEL(n), \
ETH_NET_DEVICE_DT_INST_DEFINE(n, \
eth_init, \
ETH_MCUX_PM_FUNC, \
&eth##n##_context, \
@ -1509,7 +1508,7 @@ static const struct ptp_clock_driver_api api = {
static int ptp_mcux_init(const struct device *port)
{
const struct device *eth_dev = DEVICE_GET(eth_mcux_0);
const struct device *eth_dev = DEVICE_DT_GET(DT_NODELABEL(enet));
struct eth_context *context = eth_dev->data;
struct ptp_context *ptp_context = port->data;

View file

@ -2139,47 +2139,47 @@ static const struct ethernet_api eth_api = {
#endif
};
DEVICE_DECLARE(eth0_sam_gmac);
DEVICE_DT_INST_DECLARE(0);
static void eth0_irq_config(void)
{
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(0, gmac, irq),
DT_INST_IRQ_BY_NAME(0, gmac, priority),
queue0_isr, DEVICE_GET(eth0_sam_gmac), 0);
queue0_isr, DEVICE_DT_INST_GET(0), 0);
irq_enable(DT_INST_IRQ_BY_NAME(0, gmac, irq));
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(0, q1, irq),
DT_INST_IRQ_BY_NAME(0, q1, priority),
queue1_isr, DEVICE_GET(eth0_sam_gmac), 0);
queue1_isr, DEVICE_DT_INST_GET(0), 0);
irq_enable(DT_INST_IRQ_BY_NAME(0, q1, irq));
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 2
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(0, q2, irq),
DT_INST_IRQ_BY_NAME(0, q1, priority),
queue2_isr, DEVICE_GET(eth0_sam_gmac), 0);
queue2_isr, DEVICE_DT_INST_GET(0), 0);
irq_enable(DT_INST_IRQ_BY_NAME(0, q2, irq));
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 3
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(0, q3, irq),
DT_INST_IRQ_BY_NAME(0, q3, priority),
queue3_isr, DEVICE_GET(eth0_sam_gmac), 0);
queue3_isr, DEVICE_DT_INST_GET(0), 0);
irq_enable(DT_INST_IRQ_BY_NAME(0, q3, irq));
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 4
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(0, q4, irq),
DT_INST_IRQ_BY_NAME(0, q4, priority),
queue4_isr, DEVICE_GET(eth0_sam_gmac), 0);
queue4_isr, DEVICE_DT_INST_GET(0), 0);
irq_enable(DT_INST_IRQ_BY_NAME(0, q4, irq));
#endif
#if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 5
IRQ_CONNECT(DT_INST_IRQ_BY_NAME(0, q5, irq),
DT_INST_IRQ_BY_NAME(0, q5, priority),
queue5_isr, DEVICE_GET(eth0_sam_gmac), 0);
queue5_isr, DEVICE_DT_INST_GET(0), 0);
irq_enable(DT_INST_IRQ_BY_NAME(0, q5, irq));
#endif
}
@ -2366,7 +2366,7 @@ static struct eth_sam_dev_data eth0_data = {
},
};
ETH_NET_DEVICE_INIT(eth0_sam_gmac, DT_INST_LABEL(0),
ETH_NET_DEVICE_DT_INST_DEFINE(0,
eth_initialize, device_pm_control_nop, &eth0_data,
&eth0_config, CONFIG_ETH_INIT_PRIORITY, &eth_api,
GMAC_MTU);
@ -2439,7 +2439,7 @@ static const struct ptp_clock_driver_api ptp_api = {
static int ptp_gmac_init(const struct device *port)
{
const struct device *eth_dev = DEVICE_GET(eth0_sam_gmac);
const struct device *eth_dev = DEVICE_DT_INST_GET(0);
struct eth_sam_dev_data *dev_data = eth_dev->data;
struct ptp_context *ptp_context = port->data;

View file

@ -658,13 +658,13 @@ done:
/* Bindings to the platform */
DEVICE_DECLARE(eth_smsc911x_0);
DEVICE_DT_INST_DECLARE(0);
int eth_init(const struct device *dev)
{
IRQ_CONNECT(DT_INST_IRQN(0),
DT_INST_IRQ(0, priority),
eth_smsc911x_isr, DEVICE_GET(eth_smsc911x_0), 0);
eth_smsc911x_isr, DEVICE_DT_INST_GET(0), 0);
int ret = smsc_init();
@ -680,7 +680,7 @@ int eth_init(const struct device *dev)
static struct eth_context eth_0_context;
ETH_NET_DEVICE_INIT(eth_smsc911x_0, "smsc911x_0",
ETH_NET_DEVICE_DT_INST_DEFINE(0,
eth_init, device_pm_control_nop, &eth_0_context,
NULL /*&eth_config_0*/, CONFIG_ETH_INIT_PRIORITY, &api_funcs,
NET_ETH_MTU /*MTU*/);

View file

@ -318,14 +318,14 @@ static int eth_stellaris_dev_init(const struct device *dev)
return 0;
}
DEVICE_DECLARE(eth_stellaris);
DEVICE_DT_INST_DECLARE(0);
static void eth_stellaris_irq_config(const struct device *dev)
{
/* Enable Interrupt. */
IRQ_CONNECT(DT_INST_IRQN(0),
DT_INST_IRQ(0, priority),
eth_stellaris_isr, DEVICE_GET(eth_stellaris), 0);
eth_stellaris_isr, DEVICE_DT_INST_GET(0), 0);
irq_enable(DT_INST_IRQN(0));
}
@ -349,7 +349,7 @@ static const struct ethernet_api eth_stellaris_apis = {
#endif
};
NET_DEVICE_INIT(eth_stellaris, DT_INST_LABEL(0),
NET_DEVICE_DT_INST_DEFINE(0,
eth_stellaris_dev_init, device_pm_control_nop,
&eth_data, &eth_cfg, CONFIG_ETH_INIT_PRIORITY,
&eth_stellaris_apis, ETHERNET_L2,

View file

@ -855,12 +855,12 @@ static const struct ethernet_api eth_api = {
.send = eth_tx,
};
DEVICE_DECLARE(eth0_stm32_hal);
DEVICE_DT_INST_DECLARE(0);
static void eth0_irq_config(void)
{
IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), eth_isr,
DEVICE_GET(eth0_stm32_hal), 0);
DEVICE_DT_INST_GET(0), 0);
irq_enable(DT_INST_IRQN(0));
}
@ -911,6 +911,6 @@ static struct eth_stm32_hal_dev_data eth0_data = {
},
};
ETH_NET_DEVICE_INIT(eth0_stm32_hal, DT_INST_LABEL(0), eth_initialize,
ETH_NET_DEVICE_DT_INST_DEFINE(0, eth_initialize,
device_pm_control_nop, &eth0_data, &eth0_config,
CONFIG_ETH_INIT_PRIORITY, &eth_api, ETH_STM32_HAL_MTU);

View file

@ -588,7 +588,7 @@ static const struct w5500_config w5500_0_config = {
.timeout = CONFIG_ETH_W5500_TIMEOUT,
};
ETH_NET_DEVICE_INIT(eth_w5500, DT_INST_LABEL(0),
ETH_NET_DEVICE_DT_INST_DEFINE(0,
w5500_init, device_pm_control_nop,
&w5500_0_runtime, &w5500_0_config,
CONFIG_ETH_INIT_PRIORITY, &w5500_api_funcs, NET_ETH_MTU);