1# STM32 HAL Ethernet driver configuration options
2
3# Copyright (c) 2017 Erwin Rol <erwin@erwinrol.com>
4# Copyright (c) 2020 Alexander Kozhinov <ak.alexander.kozhinov@gmail.com>
5# SPDX-License-Identifier: Apache-2.0
6
7menuconfig ETH_STM32_HAL
8	bool "STM32 HAL Ethernet driver"
9	default y
10	depends on DT_HAS_ST_STM32_ETHERNET_ENABLED
11	select USE_STM32_HAL_ETH
12	select USE_STM32_HAL_RIF if SOC_SERIES_STM32N6X
13	select NOCACHE_MEMORY if (SOC_SERIES_STM32H7X && CPU_CORTEX_M7) || SOC_SERIES_STM32N6X
14	select HWINFO
15	select ETH_DSA_SUPPORT
16	select PINCTRL
17	select MDIO if DT_HAS_ST_STM32_MDIO_ENABLED
18	imply CRC
19	help
20	  Enable STM32 HAL based Ethernet driver. It is available for
21	  all Ethernet enabled variants of the F2, F4, F7 and H7 series.
22
23if ETH_STM32_HAL
24
25choice ETH_STM32_HAL_API_VERSION
26	prompt "STM32Cube HAL Ethernet version"
27
28config ETH_STM32_HAL_API_V2
29	bool "Use official STM32Cube HAL driver"
30	depends on SOC_SERIES_STM32H7X || SOC_SERIES_STM32H5X || SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X || SOC_SERIES_STM32N6X
31	select USE_STM32_HAL_ETH_EX if SOC_SERIES_STM32N6X
32	help
33	  Use the official STM32Cube HAL driver instead of the legacy one.
34
35config ETH_STM32_HAL_API_V1
36	bool "Use legacy STM32Cube HAL driver"
37	depends on SOC_SERIES_STM32F1X || SOC_SERIES_STM32F2X
38	help
39	  Driver version based on legacy HAL version as the current official API version.
40	  Available only for STM32F1 and STM32F2 SoC series.
41
42endchoice
43
44config ETH_STM32_HAL_RX_THREAD_STACK_SIZE
45	int "RX thread stack size"
46	default 1500
47	help
48	  RX thread stack size
49
50config ETH_STM32_HAL_RX_THREAD_PREEMPTIVE
51	bool "STM32 Ethernet RX Thread pre-emptive [EXPERIMENTAL]"
52	default y if NET_TC_THREAD_PREEMPTIVE
53	depends on PREEMPT_ENABLED
54	select EXPERIMENTAL
55	help
56	  With pre-emptive threads, the thread can be pre-empted.
57
58config ETH_STM32_HAL_RX_THREAD_PRIO
59	int "STM32 Ethernet RX Thread Priority"
60	default 2
61	help
62	  This option allows to configure the priority of the RX thread that
63	  handles incoming Ethernet packets.
64	  Switching between preemptive and cooperative scheduling can be done by
65	  NET_TC_THREAD_PREEMPTIVE.
66	  Preemptive scheduling can lead to more responsive handling of network traffic,
67	  especially under high load.
68
69config ETH_STM32_HAL_USE_DTCM_FOR_DMA_BUFFER
70	bool "Use DTCM for DMA buffers"
71	default y
72	depends on SOC_SERIES_STM32F7X
73	help
74	  When this option is activated, the buffers for DMA transfer are
75	  moved from SRAM to the DTCM (Data Tightly Coupled Memory).
76
77config ETH_STM32_HAL_PHY_ADDRESS
78	int "Phy address"
79	default 0
80	help
81	  The phy address to use.
82
83config ETH_STM32_CARRIER_CHECK
84	bool "Check PHY carrier periodically"
85	default y
86	help
87	  Enables or disables checking of the PHY's carrier status.
88	  See also CONFIG_ETH_STM32_CARRIER_CHECK_RX_IDLE_TIMEOUT_MS
89
90config ETH_STM32_CARRIER_CHECK_RX_IDLE_TIMEOUT_MS
91	int "Carrier check timeout period (ms)"
92	depends on ETH_STM32_CARRIER_CHECK
93	default 500
94	range 100 30000
95	help
96	  Set the RX idle timeout period in milliseconds after which the
97	  PHY's carrier status is re-evaluated.
98
99config ETH_STM32_AUTO_NEGOTIATION_ENABLE
100	bool "Autonegotiation mode"
101	default y
102	help
103	  Enable this if using autonegotiation
104
105config ETH_STM32_HW_CHECKSUM
106	bool "Use TX and RX hardware checksum"
107	depends on !SOC_SERIES_STM32H5X
108	help
109	  Enable receive and transmit checksum offload to enhance throughput
110	  performances.
111	  See reference manual for more information on this feature.
112
113if !ETH_STM32_AUTO_NEGOTIATION_ENABLE
114
115config ETH_STM32_SPEED_10M
116	bool "Set speed to 10 Mbps when autonegotiation is disabled"
117	help
118	  Set this if using 10 Mbps and when autonegotiation is disabled, otherwise speed
119	  is 100 Mbps
120
121config ETH_STM32_MODE_HALFDUPLEX
122	bool "Half duplex mode"
123	help
124	  Set this if using half duplex when autonegotiation is disabled otherwise
125	  duplex mode is full duplex
126
127endif # !ETH_STM32_AUTO_NEGOTIATION_ENABLE
128
129if SOC_SERIES_STM32F7X || SOC_SERIES_STM32H7X || SOC_SERIES_STM32H5X
130
131config PTP_CLOCK_STM32_HAL
132	bool "STM32 HAL PTP clock driver support"
133	default y
134	depends on PTP_CLOCK || NET_L2_PTP
135	help
136	  Enable STM32 PTP clock support.
137
138config ETH_STM32_HAL_PTP_CLOCK_SRC_HZ
139	int "Frequency of the clock source for the PTP timer"
140	default 50000000
141	depends on PTP_CLOCK_STM32_HAL
142	help
143	  Set the frequency in Hz sourced to the PTP timer.
144	  If the value is set properly, the timer will be accurate.
145
146config ETH_STM32_HAL_PTP_CLOCK_ADJ_MIN_PCT
147	int "Lower bound of clock frequency adjustment (in percent)"
148	default 90
149	depends on PTP_CLOCK_STM32_HAL
150	help
151	  Specifies lower bound of PTP clock rate adjustment.
152
153config ETH_STM32_HAL_PTP_CLOCK_ADJ_MAX_PCT
154	int "Upper bound of clock frequency adjustment (in percent)"
155	default 110
156	depends on PTP_CLOCK_STM32_HAL
157	help
158	  Specifies upper bound of PTP clock rate adjustment.
159
160config ETH_STM32_HAL_PTP_CLOCK_INIT_PRIO
161	int
162	default 85
163	depends on PTP_CLOCK_STM32_HAL
164	help
165	  STM32 PTP Clock initialization priority level. There is
166	  a dependency from the network stack that this device
167	  initializes before network stack (NET_INIT_PRIO).
168
169endif # SOC_SERIES_STM32F7X || SOC_SERIES_STM32H7X || SOC_SERIES_STM32H5X
170
171config ETH_STM32_MULTICAST_FILTER
172	bool "Multicast hash filter support"
173	help
174	  Enable support for multicast hash filtering in the MAC.
175	  Once enabled the ethernet MAC performs imperfect filtering
176	  based on a computed hash of the destination MAC address of
177	  the multicast address. Only multicast with the computed
178	  hash set in the multicast table will be received and all
179	  other multicast is dropped by the MAC. If disabled then all
180	  multicast is received by the MAC.
181
182endif # ETH_STM32_HAL
183