Skip to content

Commit 36e830f

Browse files
maass-hamburgkartben
authored andcommitted
drivers: ethernet: stm32: remove hal api v1 ptp code
Only STM32F1X and STM32F2X are using the hal api v1, both of these soc don't support ptp, so ptp support for hal api v1 can be dropped. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
1 parent 64fe934 commit 36e830f

File tree

2 files changed

+7
-57
lines changed

2 files changed

+7
-57
lines changed

drivers/ethernet/Kconfig.stm32_hal

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,47 +82,45 @@ config ETH_STM32_HW_CHECKSUM
8282
performances.
8383
See reference manual for more information on this feature.
8484

85-
if SOC_SERIES_STM32F7X || SOC_SERIES_STM32H7X || SOC_SERIES_STM32H5X
86-
87-
config PTP_CLOCK_STM32_HAL
85+
menuconfig PTP_CLOCK_STM32_HAL
8886
bool "STM32 HAL PTP clock driver support"
8987
default y
9088
depends on PTP_CLOCK || NET_L2_PTP
89+
depends on ETH_STM32_HAL_API_V2
90+
depends on SOC_SERIES_STM32F7X || SOC_SERIES_STM32H7X || SOC_SERIES_STM32H5X
9191
help
9292
Enable STM32 PTP clock support.
9393

94+
if PTP_CLOCK_STM32_HAL
95+
9496
config ETH_STM32_HAL_PTP_CLOCK_SRC_HZ
9597
int "Frequency of the clock source for the PTP timer"
9698
default 50000000
97-
depends on PTP_CLOCK_STM32_HAL
9899
help
99100
Set the frequency in Hz sourced to the PTP timer.
100101
If the value is set properly, the timer will be accurate.
101102

102103
config ETH_STM32_HAL_PTP_CLOCK_ADJ_MIN_PCT
103104
int "Lower bound of clock frequency adjustment (in percent)"
104105
default 90
105-
depends on PTP_CLOCK_STM32_HAL
106106
help
107107
Specifies lower bound of PTP clock rate adjustment.
108108

109109
config ETH_STM32_HAL_PTP_CLOCK_ADJ_MAX_PCT
110110
int "Upper bound of clock frequency adjustment (in percent)"
111111
default 110
112-
depends on PTP_CLOCK_STM32_HAL
113112
help
114113
Specifies upper bound of PTP clock rate adjustment.
115114

116115
config ETH_STM32_HAL_PTP_CLOCK_INIT_PRIO
117116
int
118117
default 85
119-
depends on PTP_CLOCK_STM32_HAL
120118
help
121119
STM32 PTP Clock initialization priority level. There is
122120
a dependency from the network stack that this device
123121
initializes before network stack (NET_INIT_PRIO).
124122

125-
endif # SOC_SERIES_STM32F7X || SOC_SERIES_STM32H7X || SOC_SERIES_STM32H5X
123+
endif # PTP_CLOCK_STM32_HAL
126124

127125
config ETH_STM32_MULTICAST_FILTER
128126
bool "Multicast hash filter support"

drivers/ethernet/eth_stm32_hal.c

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ static bool eth_is_ptp_pkt(struct net_if *iface, struct net_pkt *pkt)
297297

298298
return true;
299299
}
300-
#if defined(CONFIG_ETH_STM32_HAL_API_V2)
300+
301301
void HAL_ETH_TxPtpCallback(uint32_t *buff, ETH_TimeStampTypeDef *timestamp)
302302
{
303303
struct eth_stm32_tx_context *ctx = (struct eth_stm32_tx_context *)buff;
@@ -307,7 +307,6 @@ void HAL_ETH_TxPtpCallback(uint32_t *buff, ETH_TimeStampTypeDef *timestamp)
307307

308308
net_if_add_tx_timestamp(ctx->pkt);
309309
}
310-
#endif /* CONFIG_ETH_STM32_HAL_API_V2 */
311310
#endif /* CONFIG_PTP_CLOCK_STM32_HAL */
312311

313312
static int eth_tx(const struct device *dev, struct net_pkt *pkt)
@@ -359,11 +358,7 @@ static int eth_tx(const struct device *dev, struct net_pkt *pkt)
359358
net_pkt_is_tx_timestamping(pkt);
360359
if (timestamped_frame) {
361360
/* Enable transmit timestamp */
362-
#if defined(CONFIG_ETH_STM32_HAL_API_V2)
363361
HAL_ETH_PTP_InsertTxTimestamp(heth);
364-
#else
365-
dma_tx_desc->Status |= ETH_DMATXDESC_TTSE;
366-
#endif /* CONFIG_ETH_STM32_HAL_API_V2 */
367362
}
368363
#endif /* CONFIG_PTP_CLOCK_STM32_HAL */
369364

@@ -484,35 +479,6 @@ static int eth_tx(const struct device *dev, struct net_pkt *pkt)
484479
}
485480
#endif /* CONFIG_ETH_STM32_HAL_API_V2 */
486481

487-
#if defined(CONFIG_PTP_CLOCK_STM32_HAL) && !defined(CONFIG_ETH_STM32_HAL_API_V2)
488-
if (timestamped_frame) {
489-
/* Retrieve transmission timestamp from last DMA TX descriptor */
490-
__IO ETH_DMADescTypeDef *last_dma_tx_desc = dma_tx_desc;
491-
492-
while (!(last_dma_tx_desc->Status & ETH_DMATXDESC_LS) &&
493-
last_dma_tx_desc->Buffer2NextDescAddr) {
494-
last_dma_tx_desc =
495-
(ETH_DMADescTypeDef *)last_dma_tx_desc->Buffer2NextDescAddr;
496-
}
497-
498-
while (IS_ETH_DMATXDESC_OWN(last_dma_tx_desc) != (uint32_t)RESET) {
499-
/* Wait for transmission */
500-
k_yield();
501-
}
502-
503-
if (last_dma_tx_desc->Status & ETH_DMATXDESC_LS &&
504-
last_dma_tx_desc->Status & ETH_DMATXDESC_TTSS) {
505-
pkt->timestamp.second = last_dma_tx_desc->TimeStampHigh;
506-
pkt->timestamp.nanosecond = last_dma_tx_desc->TimeStampLow;
507-
} else {
508-
/* Invalid value */
509-
pkt->timestamp.second = UINT64_MAX;
510-
pkt->timestamp.nanosecond = UINT32_MAX;
511-
}
512-
net_if_add_tx_timestamp(pkt);
513-
}
514-
#endif /* CONFIG_PTP_CLOCK_STM32_HAL && !CONFIG_ETH_STM32_HAL_API_V2 */
515-
516482
res = 0;
517483
error:
518484

@@ -552,9 +518,7 @@ static struct net_pkt *eth_rx(const struct device *dev)
552518
#endif /* CONFIG_ETH_STM32_HAL_API_V2 */
553519
#if defined(CONFIG_PTP_CLOCK_STM32_HAL)
554520
struct net_ptp_time timestamp;
555-
#if defined(CONFIG_ETH_STM32_HAL_API_V2)
556521
ETH_TimeStampTypeDef ts_registers;
557-
#endif /* CONFIG_ETH_STM32_HAL_API_V2 */
558522
/* Default to invalid value. */
559523
timestamp.second = UINT64_MAX;
560524
timestamp.nanosecond = UINT32_MAX;
@@ -591,22 +555,10 @@ static struct net_pkt *eth_rx(const struct device *dev)
591555
#endif /* CONFIG_ETH_STM32_HAL_API_V2 */
592556

593557
#if defined(CONFIG_PTP_CLOCK_STM32_HAL)
594-
#if defined(CONFIG_ETH_STM32_HAL_API_V2)
595-
596558
if (HAL_ETH_PTP_GetRxTimestamp(heth, &ts_registers) == HAL_OK) {
597559
timestamp.second = ts_registers.TimeStampHigh;
598560
timestamp.nanosecond = ts_registers.TimeStampLow;
599561
}
600-
#else
601-
__IO ETH_DMADescTypeDef *last_dma_rx_desc;
602-
603-
last_dma_rx_desc = heth->RxFrameInfos.LSRxDesc;
604-
if (last_dma_rx_desc->TimeStampHigh != UINT32_MAX ||
605-
last_dma_rx_desc->TimeStampLow != UINT32_MAX) {
606-
timestamp.second = last_dma_rx_desc->TimeStampHigh;
607-
timestamp.nanosecond = last_dma_rx_desc->TimeStampLow;
608-
}
609-
#endif /* CONFIG_ETH_STM32_HAL_API_V2 */
610562
#endif /* CONFIG_PTP_CLOCK_STM32_HAL */
611563

612564
pkt = net_pkt_rx_alloc_with_buffer(get_iface(dev_data),

0 commit comments

Comments
 (0)