Skip to content

Commit ee6b20e

Browse files
yangbolu1991nashif
authored andcommitted
drivers: ethernet: nxp_imx_netc: handle ports without PTP clock enabled
PTP clock may be enabled per Ethernet port. Especially pseudo port for switch management does not need PTP clock. Signed-off-by: Yangbo Lu <[email protected]>
1 parent 590d9d1 commit ee6b20e

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

drivers/ethernet/nxp_imx_netc/eth_nxp_imx_netc.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ int netc_eth_init_common(const struct device *dev)
246246
config->bdr_init(&bdr_config, &rx_bdr_config, &tx_bdr_config);
247247

248248
#ifdef CONFIG_PTP_CLOCK_NXP_NETC
249-
bdr_config.rxBdrConfig[0].extendDescEn = true;
249+
if (netc_eth_get_ptp_clock(dev) != NULL) {
250+
bdr_config.rxBdrConfig[0].extendDescEn = true;
251+
}
250252
#endif
251253

252254
/* MSIX entry configuration */
@@ -377,6 +379,8 @@ int netc_eth_tx(const struct device *dev, struct net_pkt *pkt)
377379
size_t pkt_len = net_pkt_get_len(pkt);
378380
#if defined(NETC_HAS_NO_SWITCH_TAG_SUPPORT)
379381
struct ethernet_context *eth_ctx = net_if_l2_data(data->iface);
382+
#endif
383+
#if defined(NETC_HAS_NO_SWITCH_TAG_SUPPORT) || defined(CONFIG_PTP_CLOCK_NXP_NETC)
380384
const struct netc_eth_config *cfg = dev->config;
381385
#endif
382386
status_t result;
@@ -404,7 +408,8 @@ int netc_eth_tx(const struct device *dev, struct net_pkt *pkt)
404408

405409
#ifdef CONFIG_PTP_CLOCK_NXP_NETC
406410
pkt_is_gptp = ntohs(NET_ETH_HDR(pkt)->type) == NET_ETH_PTYPE_PTP;
407-
if (pkt_is_gptp || net_pkt_is_tx_timestamping(pkt)) {
411+
if ((pkt_is_gptp || net_pkt_is_tx_timestamping(pkt)) &&
412+
(netc_eth_get_ptp_clock(dev) != NULL)) {
408413
opt.flags |= kEP_TX_OPT_REQ_TS;
409414
}
410415
#endif
@@ -487,14 +492,16 @@ enum ethernet_hw_caps netc_eth_get_capabilities(const struct device *dev)
487492
#if defined(CONFIG_NET_VLAN)
488493
| ETHERNET_HW_VLAN
489494
#endif
490-
#if defined(CONFIG_PTP_CLOCK_NXP_NETC)
491-
| ETHERNET_PTP
492-
#endif
493495
#if defined(CONFIG_NET_PROMISCUOUS_MODE)
494496
| ETHERNET_PROMISC_MODE
495497
#endif
496498
);
497499

500+
#if defined(CONFIG_PTP_CLOCK_NXP_NETC)
501+
if (netc_eth_get_ptp_clock(dev) != NULL) {
502+
caps |= ETHERNET_PTP;
503+
}
504+
#endif
498505
return caps;
499506
}
500507

drivers/ethernet/nxp_imx_netc/eth_nxp_imx_netc_psi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static const struct ethernet_api netc_eth_api = {.iface_api.init = netc_eth_ifac
217217
(.tx_intr_msg_data = NETC_TX_INTR_MSG_DATA_START + n, \
218218
.rx_intr_msg_data = NETC_RX_INTR_MSG_DATA_START + n,)) \
219219
IF_ENABLED(CONFIG_PTP_CLOCK_NXP_NETC, \
220-
(.ptp_clock = DEVICE_DT_GET(DT_INST_PHANDLE(n, ptp_clock)),)) \
220+
(.ptp_clock = DEVICE_DT_GET_OR_NULL(DT_INST_PHANDLE(n, ptp_clock)),)) \
221221
}; \
222222
ETH_NET_DEVICE_DT_INST_DEFINE(n, netc_eth_init, NULL, &netc_eth##n##_data, \
223223
&netc_eth##n##_config, CONFIG_ETH_INIT_PRIORITY, \

0 commit comments

Comments
 (0)