eth: mcux: Make consistent use of #if defined
As well as #ifndef. Apply it for all CONFIG_* defines. Signed-off-by: Armand Ciejak <armand@riedonetworks.com>
This commit is contained in:
parent
cd35b17879
commit
c627ef37ed
1 changed files with 30 additions and 31 deletions
|
@ -39,7 +39,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
||||||
|
|
||||||
#include "fsl_enet.h"
|
#include "fsl_enet.h"
|
||||||
#include "fsl_phy.h"
|
#include "fsl_phy.h"
|
||||||
#ifdef CONFIG_NET_POWER_MANAGEMENT
|
#if defined(CONFIG_NET_POWER_MANAGEMENT)
|
||||||
#include "fsl_clock.h"
|
#include "fsl_clock.h"
|
||||||
#include <drivers/clock_control.h>
|
#include <drivers/clock_control.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -71,14 +71,14 @@ enum eth_mcux_phy_state {
|
||||||
eth_mcux_phy_state_closing
|
eth_mcux_phy_state_closing
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_NET_POWER_MANAGEMENT
|
#if defined(CONFIG_NET_POWER_MANAGEMENT)
|
||||||
extern uint32_t ENET_GetInstance(ENET_Type * base);
|
extern uint32_t ENET_GetInstance(ENET_Type * base);
|
||||||
static const clock_ip_name_t enet_clocks[] = ENET_CLOCKS;
|
static const clock_ip_name_t enet_clocks[] = ENET_CLOCKS;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void eth_mcux_init(const struct device *dev);
|
static void eth_mcux_init(const struct device *dev);
|
||||||
|
|
||||||
#ifdef CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG
|
#if defined(CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG)
|
||||||
static const char *phy_state_name(enum eth_mcux_phy_state state)
|
static const char *phy_state_name(enum eth_mcux_phy_state state)
|
||||||
{
|
{
|
||||||
static const char * const name[] = {
|
static const char * const name[] = {
|
||||||
|
@ -118,7 +118,7 @@ struct eth_context {
|
||||||
* used for anything.
|
* used for anything.
|
||||||
*/
|
*/
|
||||||
struct net_if *iface;
|
struct net_if *iface;
|
||||||
#ifdef CONFIG_NET_POWER_MANAGEMENT
|
#if defined(CONFIG_NET_POWER_MANAGEMENT)
|
||||||
const char *clock_name;
|
const char *clock_name;
|
||||||
clock_ip_name_t clock;
|
clock_ip_name_t clock;
|
||||||
const struct device *clock_dev;
|
const struct device *clock_dev;
|
||||||
|
@ -158,7 +158,7 @@ struct eth_context {
|
||||||
uint8_t frame_buf[NET_ETH_MAX_FRAME_SIZE]; /* Max MTU + ethernet header */
|
uint8_t frame_buf[NET_ETH_MAX_FRAME_SIZE]; /* Max MTU + ethernet header */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_HAS_MCUX_CACHE
|
#if defined(CONFIG_HAS_MCUX_CACHE)
|
||||||
static __nocache enet_rx_bd_struct_t __aligned(ENET_BUFF_ALIGNMENT)
|
static __nocache enet_rx_bd_struct_t __aligned(ENET_BUFF_ALIGNMENT)
|
||||||
rx_buffer_desc[CONFIG_ETH_MCUX_RX_BUFFERS];
|
rx_buffer_desc[CONFIG_ETH_MCUX_RX_BUFFERS];
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ rx_buffer[CONFIG_ETH_MCUX_RX_BUFFERS][ETH_MCUX_BUFFER_SIZE];
|
||||||
static uint8_t __aligned(ENET_BUFF_ALIGNMENT)
|
static uint8_t __aligned(ENET_BUFF_ALIGNMENT)
|
||||||
tx_buffer[CONFIG_ETH_MCUX_TX_BUFFERS][ETH_MCUX_BUFFER_SIZE];
|
tx_buffer[CONFIG_ETH_MCUX_TX_BUFFERS][ETH_MCUX_BUFFER_SIZE];
|
||||||
|
|
||||||
#ifdef CONFIG_NET_POWER_MANAGEMENT
|
#if defined(CONFIG_NET_POWER_MANAGEMENT)
|
||||||
static void eth_mcux_phy_enter_reset(struct eth_context *context);
|
static void eth_mcux_phy_enter_reset(struct eth_context *context);
|
||||||
void eth_mcux_phy_stop(struct eth_context *context);
|
void eth_mcux_phy_stop(struct eth_context *context);
|
||||||
|
|
||||||
|
@ -320,21 +320,21 @@ static inline struct net_if *get_iface(struct eth_context *ctx, uint16_t vlan_ta
|
||||||
static void eth_mcux_phy_enter_reset(struct eth_context *context)
|
static void eth_mcux_phy_enter_reset(struct eth_context *context)
|
||||||
{
|
{
|
||||||
/* Reset the PHY. */
|
/* Reset the PHY. */
|
||||||
#ifndef CONFIG_ETH_MCUX_NO_PHY_SMI
|
#if !defined(CONFIG_ETH_MCUX_NO_PHY_SMI)
|
||||||
ENET_StartSMIWrite(context->base, context->phy_addr,
|
ENET_StartSMIWrite(context->base, context->phy_addr,
|
||||||
PHY_BASICCONTROL_REG,
|
PHY_BASICCONTROL_REG,
|
||||||
kENET_MiiWriteValidFrame,
|
kENET_MiiWriteValidFrame,
|
||||||
PHY_BCTL_RESET_MASK);
|
PHY_BCTL_RESET_MASK);
|
||||||
#endif
|
#endif
|
||||||
context->phy_state = eth_mcux_phy_state_reset;
|
context->phy_state = eth_mcux_phy_state_reset;
|
||||||
#ifdef CONFIG_ETH_MCUX_NO_PHY_SMI
|
#if defined(CONFIG_ETH_MCUX_NO_PHY_SMI)
|
||||||
k_work_submit(&context->phy_work);
|
k_work_submit(&context->phy_work);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void eth_mcux_phy_start(struct eth_context *context)
|
static void eth_mcux_phy_start(struct eth_context *context)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG
|
#if defined(CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG)
|
||||||
LOG_DBG("%s phy_state=%s", eth_name(context->base),
|
LOG_DBG("%s phy_state=%s", eth_name(context->base),
|
||||||
phy_state_name(context->phy_state));
|
phy_state_name(context->phy_state));
|
||||||
#endif
|
#endif
|
||||||
|
@ -345,7 +345,7 @@ static void eth_mcux_phy_start(struct eth_context *context)
|
||||||
case eth_mcux_phy_state_initial:
|
case eth_mcux_phy_state_initial:
|
||||||
ENET_ActiveRead(context->base);
|
ENET_ActiveRead(context->base);
|
||||||
/* Reset the PHY. */
|
/* Reset the PHY. */
|
||||||
#ifndef CONFIG_ETH_MCUX_NO_PHY_SMI
|
#if !defined(CONFIG_ETH_MCUX_NO_PHY_SMI)
|
||||||
ENET_StartSMIWrite(context->base, context->phy_addr,
|
ENET_StartSMIWrite(context->base, context->phy_addr,
|
||||||
PHY_BASICCONTROL_REG,
|
PHY_BASICCONTROL_REG,
|
||||||
kENET_MiiWriteValidFrame,
|
kENET_MiiWriteValidFrame,
|
||||||
|
@ -358,7 +358,7 @@ static void eth_mcux_phy_start(struct eth_context *context)
|
||||||
k_work_submit(&context->phy_work);
|
k_work_submit(&context->phy_work);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_SOC_SERIES_IMX_RT
|
#if defined(CONFIG_SOC_SERIES_IMX_RT)
|
||||||
context->phy_state = eth_mcux_phy_state_initial;
|
context->phy_state = eth_mcux_phy_state_initial;
|
||||||
#else
|
#else
|
||||||
context->phy_state = eth_mcux_phy_state_reset;
|
context->phy_state = eth_mcux_phy_state_reset;
|
||||||
|
@ -379,7 +379,7 @@ static void eth_mcux_phy_start(struct eth_context *context)
|
||||||
|
|
||||||
void eth_mcux_phy_stop(struct eth_context *context)
|
void eth_mcux_phy_stop(struct eth_context *context)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG
|
#if defined(CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG)
|
||||||
LOG_DBG("%s phy_state=%s", eth_name(context->base),
|
LOG_DBG("%s phy_state=%s", eth_name(context->base),
|
||||||
phy_state_name(context->phy_state));
|
phy_state_name(context->phy_state));
|
||||||
#endif
|
#endif
|
||||||
|
@ -415,20 +415,20 @@ static void eth_mcux_phy_event(struct eth_context *context)
|
||||||
uint32_t status;
|
uint32_t status;
|
||||||
#endif
|
#endif
|
||||||
bool link_up;
|
bool link_up;
|
||||||
#ifdef CONFIG_SOC_SERIES_IMX_RT
|
#if defined(CONFIG_SOC_SERIES_IMX_RT)
|
||||||
status_t res;
|
status_t res;
|
||||||
uint32_t ctrl2;
|
uint32_t ctrl2;
|
||||||
#endif
|
#endif
|
||||||
phy_duplex_t phy_duplex = kPHY_FullDuplex;
|
phy_duplex_t phy_duplex = kPHY_FullDuplex;
|
||||||
phy_speed_t phy_speed = kPHY_Speed100M;
|
phy_speed_t phy_speed = kPHY_Speed100M;
|
||||||
|
|
||||||
#ifdef CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG
|
#if defined(CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG)
|
||||||
LOG_DBG("%s phy_state=%s", eth_name(context->base),
|
LOG_DBG("%s phy_state=%s", eth_name(context->base),
|
||||||
phy_state_name(context->phy_state));
|
phy_state_name(context->phy_state));
|
||||||
#endif
|
#endif
|
||||||
switch (context->phy_state) {
|
switch (context->phy_state) {
|
||||||
case eth_mcux_phy_state_initial:
|
case eth_mcux_phy_state_initial:
|
||||||
#ifdef CONFIG_SOC_SERIES_IMX_RT
|
#if defined(CONFIG_SOC_SERIES_IMX_RT)
|
||||||
ENET_DisableInterrupts(context->base, ENET_EIR_MII_MASK);
|
ENET_DisableInterrupts(context->base, ENET_EIR_MII_MASK);
|
||||||
res = PHY_Read(context->base, context->phy_addr,
|
res = PHY_Read(context->base, context->phy_addr,
|
||||||
PHY_CONTROL2_REG, &ctrl2);
|
PHY_CONTROL2_REG, &ctrl2);
|
||||||
|
@ -445,7 +445,7 @@ static void eth_mcux_phy_event(struct eth_context *context)
|
||||||
}
|
}
|
||||||
context->phy_state = eth_mcux_phy_state_reset;
|
context->phy_state = eth_mcux_phy_state_reset;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_ETH_MCUX_NO_PHY_SMI
|
#if defined(CONFIG_ETH_MCUX_NO_PHY_SMI)
|
||||||
/*
|
/*
|
||||||
* When the iface is available proceed with the eth link setup,
|
* When the iface is available proceed with the eth link setup,
|
||||||
* otherwise reschedule the eth_mcux_phy_event and check after
|
* otherwise reschedule the eth_mcux_phy_event and check after
|
||||||
|
@ -468,7 +468,7 @@ static void eth_mcux_phy_event(struct eth_context *context)
|
||||||
break;
|
break;
|
||||||
case eth_mcux_phy_state_reset:
|
case eth_mcux_phy_state_reset:
|
||||||
/* Setup PHY autonegotiation. */
|
/* Setup PHY autonegotiation. */
|
||||||
#ifndef CONFIG_ETH_MCUX_NO_PHY_SMI
|
#if !defined(CONFIG_ETH_MCUX_NO_PHY_SMI)
|
||||||
ENET_StartSMIWrite(context->base, context->phy_addr,
|
ENET_StartSMIWrite(context->base, context->phy_addr,
|
||||||
PHY_AUTONEG_ADVERTISE_REG,
|
PHY_AUTONEG_ADVERTISE_REG,
|
||||||
kENET_MiiWriteValidFrame,
|
kENET_MiiWriteValidFrame,
|
||||||
|
@ -478,12 +478,12 @@ static void eth_mcux_phy_event(struct eth_context *context)
|
||||||
PHY_10BASETX_HALFDUPLEX_MASK | 0x1U));
|
PHY_10BASETX_HALFDUPLEX_MASK | 0x1U));
|
||||||
#endif
|
#endif
|
||||||
context->phy_state = eth_mcux_phy_state_autoneg;
|
context->phy_state = eth_mcux_phy_state_autoneg;
|
||||||
#ifdef CONFIG_ETH_MCUX_NO_PHY_SMI
|
#if defined(CONFIG_ETH_MCUX_NO_PHY_SMI)
|
||||||
k_work_submit(&context->phy_work);
|
k_work_submit(&context->phy_work);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case eth_mcux_phy_state_autoneg:
|
case eth_mcux_phy_state_autoneg:
|
||||||
#ifndef CONFIG_ETH_MCUX_NO_PHY_SMI
|
#if !defined(CONFIG_ETH_MCUX_NO_PHY_SMI)
|
||||||
/* Setup PHY autonegotiation. */
|
/* Setup PHY autonegotiation. */
|
||||||
ENET_StartSMIWrite(context->base, context->phy_addr,
|
ENET_StartSMIWrite(context->base, context->phy_addr,
|
||||||
PHY_BASICCONTROL_REG,
|
PHY_BASICCONTROL_REG,
|
||||||
|
@ -492,20 +492,20 @@ static void eth_mcux_phy_event(struct eth_context *context)
|
||||||
PHY_BCTL_RESTART_AUTONEG_MASK));
|
PHY_BCTL_RESTART_AUTONEG_MASK));
|
||||||
#endif
|
#endif
|
||||||
context->phy_state = eth_mcux_phy_state_restart;
|
context->phy_state = eth_mcux_phy_state_restart;
|
||||||
#ifdef CONFIG_ETH_MCUX_NO_PHY_SMI
|
#if defined(CONFIG_ETH_MCUX_NO_PHY_SMI)
|
||||||
k_work_submit(&context->phy_work);
|
k_work_submit(&context->phy_work);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case eth_mcux_phy_state_wait:
|
case eth_mcux_phy_state_wait:
|
||||||
case eth_mcux_phy_state_restart:
|
case eth_mcux_phy_state_restart:
|
||||||
/* Start reading the PHY basic status. */
|
/* Start reading the PHY basic status. */
|
||||||
#ifndef CONFIG_ETH_MCUX_NO_PHY_SMI
|
#if !defined(CONFIG_ETH_MCUX_NO_PHY_SMI)
|
||||||
ENET_StartSMIRead(context->base, context->phy_addr,
|
ENET_StartSMIRead(context->base, context->phy_addr,
|
||||||
PHY_BASICSTATUS_REG,
|
PHY_BASICSTATUS_REG,
|
||||||
kENET_MiiReadValidFrame);
|
kENET_MiiReadValidFrame);
|
||||||
#endif
|
#endif
|
||||||
context->phy_state = eth_mcux_phy_state_read_status;
|
context->phy_state = eth_mcux_phy_state_read_status;
|
||||||
#ifdef CONFIG_ETH_MCUX_NO_PHY_SMI
|
#if defined(CONFIG_ETH_MCUX_NO_PHY_SMI)
|
||||||
k_work_submit(&context->phy_work);
|
k_work_submit(&context->phy_work);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
@ -519,7 +519,7 @@ static void eth_mcux_phy_event(struct eth_context *context)
|
||||||
#endif
|
#endif
|
||||||
if (link_up && !context->link_up) {
|
if (link_up && !context->link_up) {
|
||||||
/* Start reading the PHY control register. */
|
/* Start reading the PHY control register. */
|
||||||
#ifndef CONFIG_ETH_MCUX_NO_PHY_SMI
|
#if !defined(CONFIG_ETH_MCUX_NO_PHY_SMI)
|
||||||
ENET_StartSMIRead(context->base, context->phy_addr,
|
ENET_StartSMIRead(context->base, context->phy_addr,
|
||||||
PHY_CONTROL1_REG,
|
PHY_CONTROL1_REG,
|
||||||
kENET_MiiReadValidFrame);
|
kENET_MiiReadValidFrame);
|
||||||
|
@ -532,7 +532,7 @@ static void eth_mcux_phy_event(struct eth_context *context)
|
||||||
net_eth_carrier_on(context->iface);
|
net_eth_carrier_on(context->iface);
|
||||||
k_msleep(USEC_PER_MSEC);
|
k_msleep(USEC_PER_MSEC);
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_ETH_MCUX_NO_PHY_SMI
|
#if defined(CONFIG_ETH_MCUX_NO_PHY_SMI)
|
||||||
k_work_submit(&context->phy_work);
|
k_work_submit(&context->phy_work);
|
||||||
#endif
|
#endif
|
||||||
} else if (!link_up && context->link_up) {
|
} else if (!link_up && context->link_up) {
|
||||||
|
@ -598,7 +598,7 @@ static void eth_mcux_delayed_phy_work(struct k_work *item)
|
||||||
|
|
||||||
static void eth_mcux_phy_setup(struct eth_context *context)
|
static void eth_mcux_phy_setup(struct eth_context *context)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_SOC_SERIES_IMX_RT
|
#if defined(CONFIG_SOC_SERIES_IMX_RT)
|
||||||
status_t res;
|
status_t res;
|
||||||
uint32_t oms_override;
|
uint32_t oms_override;
|
||||||
|
|
||||||
|
@ -693,7 +693,7 @@ static bool eth_get_ptp_data(struct net_if *iface, struct net_pkt *pkt,
|
||||||
ptpTsData->messageType = hdr->message_type;
|
ptpTsData->messageType = hdr->message_type;
|
||||||
ptpTsData->sequenceId = ntohs(hdr->sequence_id);
|
ptpTsData->sequenceId = ntohs(hdr->sequence_id);
|
||||||
|
|
||||||
#ifdef CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG
|
#if defined(CONFIG_ETH_MCUX_PHY_EXTRA_DEBUG)
|
||||||
LOG_DBG("PTP packet: ver %d type %d len %d seq %d",
|
LOG_DBG("PTP packet: ver %d type %d len %d seq %d",
|
||||||
ptpTsData->version,
|
ptpTsData->version,
|
||||||
ptpTsData->messageType,
|
ptpTsData->messageType,
|
||||||
|
@ -857,7 +857,7 @@ static void eth_rx(struct eth_context *context)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_NET_VLAN */
|
||||||
|
|
||||||
#if defined(CONFIG_PTP_CLOCK_MCUX)
|
#if defined(CONFIG_PTP_CLOCK_MCUX)
|
||||||
if (eth_get_ptp_data(get_iface(context, vlan_tag), pkt,
|
if (eth_get_ptp_data(get_iface(context, vlan_tag), pkt,
|
||||||
|
@ -929,7 +929,7 @@ static inline void ts_register_tx_event(struct eth_context *context)
|
||||||
ts_tx_rd = 0;
|
ts_tx_rd = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_PTP_CLOCK_MCUX */
|
||||||
|
|
||||||
static void eth_callback(ENET_Type *base, enet_handle_t *handle,
|
static void eth_callback(ENET_Type *base, enet_handle_t *handle,
|
||||||
enet_event_t event, void *param)
|
enet_event_t event, void *param)
|
||||||
|
@ -996,7 +996,7 @@ static void eth_mcux_init(const struct device *dev)
|
||||||
ENET_GetDefaultConfig(&enet_config);
|
ENET_GetDefaultConfig(&enet_config);
|
||||||
enet_config.interrupt |= kENET_RxFrameInterrupt;
|
enet_config.interrupt |= kENET_RxFrameInterrupt;
|
||||||
enet_config.interrupt |= kENET_TxFrameInterrupt;
|
enet_config.interrupt |= kENET_TxFrameInterrupt;
|
||||||
#ifndef CONFIG_ETH_MCUX_NO_PHY_SMI
|
#if !defined(CONFIG_ETH_MCUX_NO_PHY_SMI)
|
||||||
enet_config.interrupt |= kENET_MiiInterrupt;
|
enet_config.interrupt |= kENET_MiiInterrupt;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1024,7 +1024,6 @@ static void eth_mcux_init(const struct device *dev)
|
||||||
context->mac_addr,
|
context->mac_addr,
|
||||||
sys_clock);
|
sys_clock);
|
||||||
|
|
||||||
|
|
||||||
#if defined(CONFIG_PTP_CLOCK_MCUX)
|
#if defined(CONFIG_PTP_CLOCK_MCUX)
|
||||||
ENET_AddMulticastGroup(context->base, ptp_multicast);
|
ENET_AddMulticastGroup(context->base, ptp_multicast);
|
||||||
|
|
||||||
|
@ -1045,7 +1044,7 @@ static void eth_mcux_init(const struct device *dev)
|
||||||
ENET_AddMulticastGroup(context->base, mdns_multicast);
|
ENET_AddMulticastGroup(context->base, mdns_multicast);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_ETH_MCUX_NO_PHY_SMI
|
#if !defined(CONFIG_ETH_MCUX_NO_PHY_SMI)
|
||||||
ENET_SetSMI(context->base, sys_clock, false);
|
ENET_SetSMI(context->base, sys_clock, false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue