1 /* 2 * Copyright (c) 2017 Erwin Rol <erwin@erwinrol.com> 3 * SPDX-License-Identifier: Apache-2.0 4 */ 5 6 #ifndef ZEPHYR_DRIVERS_ETHERNET_ETH_STM32_HAL_PRIV_H_ 7 #define ZEPHYR_DRIVERS_ETHERNET_ETH_STM32_HAL_PRIV_H_ 8 9 #include <zephyr/kernel.h> 10 #include <zephyr/types.h> 11 12 /* Naming of the ETH PTP Config Status changes depending on the stm32 serie */ 13 #if defined(CONFIG_SOC_SERIES_STM32F4X) 14 #define ETH_STM32_PTP_CONFIGURED HAL_ETH_PTP_CONFIGURATED 15 #define ETH_STM32_PTP_NOT_CONFIGURED HAL_ETH_PTP_NOT_CONFIGURATED 16 #else 17 #define ETH_STM32_PTP_CONFIGURED HAL_ETH_PTP_CONFIGURED 18 #define ETH_STM32_PTP_NOT_CONFIGURED HAL_ETH_PTP_NOT_CONFIGURED 19 #endif /* stm32F7x or sm32F4x */ 20 21 #define ST_OUI_B0 0x00 22 #define ST_OUI_B1 0x80 23 #define ST_OUI_B2 0xE1 24 25 #define ETH_STM32_HAL_MTU NET_ETH_MTU 26 #define ETH_STM32_HAL_FRAME_SIZE_MAX (ETH_STM32_HAL_MTU + 18) 27 28 /* Definition of the Ethernet driver buffers size and count */ 29 #define ETH_STM32_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ 30 #define ETH_STM32_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ 31 32 /* Device constant configuration parameters */ 33 struct eth_stm32_hal_dev_cfg { 34 void (*config_func)(void); 35 struct stm32_pclken pclken; 36 struct stm32_pclken pclken_rx; 37 struct stm32_pclken pclken_tx; 38 #if DT_INST_CLOCKS_HAS_NAME(0, mac_clk_ptp) 39 struct stm32_pclken pclken_ptp; 40 #endif 41 const struct pinctrl_dev_config *pcfg; 42 }; 43 44 /* Device run time data */ 45 struct eth_stm32_hal_dev_data { 46 struct net_if *iface; 47 uint8_t mac_addr[6]; 48 ETH_HandleTypeDef heth; 49 /* clock device */ 50 const struct device *clock; 51 struct k_mutex tx_mutex; 52 struct k_sem rx_int_sem; 53 #if defined(CONFIG_ETH_STM32_HAL_API_V2) 54 struct k_sem tx_int_sem; 55 #endif /* CONFIG_ETH_STM32_HAL_API_V2 */ 56 K_KERNEL_STACK_MEMBER(rx_thread_stack, 57 CONFIG_ETH_STM32_HAL_RX_THREAD_STACK_SIZE); 58 struct k_thread rx_thread; 59 bool link_up; 60 #if defined(CONFIG_ETH_STM32_MULTICAST_FILTER) 61 uint8_t hash_index_cnt[64]; 62 #endif /* CONFIG_ETH_STM32_MULTICAST_FILTER */ 63 #if defined(CONFIG_PTP_CLOCK_STM32_HAL) 64 const struct device *ptp_clock; 65 float clk_ratio; 66 float clk_ratio_adj; 67 #endif /* CONFIG_PTP_CLOCK_STM32_HAL */ 68 #if defined(CONFIG_NET_STATISTICS_ETHERNET) 69 struct net_stats_eth stats; 70 #endif 71 }; 72 73 #endif /* ZEPHYR_DRIVERS_ETHERNET_ETH_STM32_HAL_PRIV_H_ */ 74