drivers: nxp_enet: Do clock init from zephyr
Need to do the ENET module-level clock initialization from zephyr instead of MCUX HAL, because now there are multiple zephyr drivers with different init priorities that rely on the module being clocked. MDIO must be initialized before the ENET MAC, and the MAC driver currently calls ENET_Init from the HAL to initialize the clock, but MDIO needs the module clock enabled first on some platforms. So replace the MAC init with ENET_Up from the HAL, which doesn't include clock init, then do clock init from a higher priority sys init based on the parent compatible. Also, add support for enet clock ungating with clock_control_on on ccm driver do this with current platforms supported. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
This commit is contained in:
parent
19773a61c6
commit
20af909df5
|
@ -106,6 +106,12 @@ static int mcux_ccm_on(const struct device *dev,
|
|||
CLOCK_EnableClock(lpuart_clocks[instance]);
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ETH_NXP_ENET)
|
||||
case IMX_CCM_ENET_CLK:
|
||||
CLOCK_EnableClock(kCLOCK_Enet);
|
||||
return 0;
|
||||
#endif
|
||||
default:
|
||||
(void)instance;
|
||||
return 0;
|
||||
|
|
|
@ -800,7 +800,7 @@ static int eth_nxp_enet_init(const struct device *dev)
|
|||
enet_config.callback = eth_callback;
|
||||
enet_config.userData = (void *)dev;
|
||||
|
||||
ENET_Init(config->base,
|
||||
ENET_Up(config->base,
|
||||
&data->enet_handle,
|
||||
&enet_config,
|
||||
&config->buffer_config,
|
||||
|
@ -971,7 +971,7 @@ static const struct ethernet_api api_funcs = {
|
|||
.txFrameInfo = NULL
|
||||
#endif
|
||||
|
||||
#define NXP_ENET_INIT(n) \
|
||||
#define NXP_ENET_MAC_INIT(n) \
|
||||
NXP_ENET_GENERATE_MAC(n) \
|
||||
\
|
||||
PINCTRL_DT_INST_DEFINE(n); \
|
||||
|
@ -1047,4 +1047,29 @@ static const struct ethernet_api api_funcs = {
|
|||
CONFIG_ETH_INIT_PRIORITY, \
|
||||
&api_funcs, NET_ETH_MTU);
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(NXP_ENET_MAC_INIT)
|
||||
|
||||
|
||||
/*
|
||||
* ENET module-level management
|
||||
*/
|
||||
|
||||
#undef DT_DRV_COMPAT
|
||||
#define DT_DRV_COMPAT nxp_enet
|
||||
|
||||
#define NXP_ENET_INIT(n) \
|
||||
\
|
||||
int nxp_enet_##n##_init(void) \
|
||||
{ \
|
||||
clock_control_on(DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
|
||||
(void *)DT_INST_CLOCKS_CELL_BY_IDX(n, 0, name)); \
|
||||
\
|
||||
ENET_Reset((ENET_Type *)DT_INST_REG_ADDR(n)); \
|
||||
\
|
||||
return 0; \
|
||||
} \
|
||||
\
|
||||
/* Init the module before any of the MAC, MDIO, or PTP clock */ \
|
||||
SYS_INIT(nxp_enet_##n##_init, POST_KERNEL, 0);
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(NXP_ENET_INIT)
|
||||
|
|
Loading…
Reference in a new issue