forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eth_gecko_priv.h
137 lines (109 loc) · 4.38 KB
/
eth_gecko_priv.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
* Copyright (c) 2019 Interay Solutions B.V.
* Copyright (c) 2019 Oane Kingma
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_DRIVERS_ETHERNET_ETH_GECKO_PRIV_H_
#define ZEPHYR_DRIVERS_ETHERNET_ETH_GECKO_PRIV_H_
#include <zephyr/kernel.h>
#include <zephyr/types.h>
#define ETH_GECKO_MTU NET_ETH_MTU
#define SILABS_OUI_B0 0x00
#define SILABS_OUI_B1 0x0B
#define SILABS_OUI_B2 0x57
#define ETH_TX_BUF_SIZE 1536
#define ETH_TX_BUF_COUNT 2
#define ETH_RX_BUF_SIZE 128
#define ETH_RX_BUF_COUNT 32
#define ETH_BUF_ALIGNMENT 16
#define ETH_DESC_ALIGNMENT 4
#define ETH_TX_USED BIT(31)
#define ETH_TX_WRAP BIT(30)
#define ETH_TX_ERROR BIT(29)
#define ETH_TX_UNDERRUN BIT(28)
#define ETH_TX_EXHAUSTED BIT(27)
#define ETH_TX_NO_CRC BIT(16)
#define ETH_TX_LAST BIT(15)
#define ETH_TX_LENGTH (2048-1)
#define ETH_RX_ADDRESS ~(ETH_DESC_ALIGNMENT-1)
#define ETH_RX_WRAP BIT(1)
#define ETH_RX_OWNERSHIP BIT(0)
#define ETH_RX_BROADCAST BIT(31)
#define ETH_RX_MULTICAST_HASH BIT(30)
#define ETH_RX_UNICAST_HASH BIT(29)
#define ETH_RX_EXT_ADDR BIT(28)
#define ETH_RX_SAR1 BIT(26)
#define ETH_RX_SAR2 BIT(25)
#define ETH_RX_SAR3 BIT(24)
#define ETH_RX_SAR4 BIT(23)
#define ETH_RX_TYPE_ID BIT(22)
#define ETH_RX_VLAN_TAG BIT(21)
#define ETH_RX_PRIORITY_TAG BIT(20)
#define ETH_RX_VLAN_PRIORITY (0x7UL<<17)
#define ETH_RX_CFI BIT(16)
#define ETH_RX_EOF BIT(15)
#define ETH_RX_SOF BIT(14)
#define ETH_RX_OFFSET (0x3UL<<12)
#define ETH_RX_LENGTH (4096-1)
#define ETH_RX_ENABLE(base) (base->NETWORKCTRL |= ETH_NETWORKCTRL_ENBRX)
#define ETH_RX_DISABLE(base) (base->NETWORKCTRL &= ~ETH_NETWORKCTRL_ENBRX)
#define ETH_TX_ENABLE(base) (base->NETWORKCTRL |= ETH_NETWORKCTRL_ENBTX)
#define ETH_TX_DISABLE(base) (base->NETWORKCTRL &= ~ETH_NETWORKCTRL_ENBTX)
struct eth_buf_desc {
uint32_t address;
uint32_t status;
};
struct eth_gecko_pin_list {
struct soc_gpio_pin mdio[2];
struct soc_gpio_pin rmii[7];
};
/* Device constant configuration parameters */
struct eth_gecko_dev_cfg {
ETH_TypeDef *regs;
const struct eth_gecko_pin_list *pin_list;
uint32_t pin_list_size;
void (*config_func)(void);
struct phy_gecko_dev phy;
};
/* Device run time data */
struct eth_gecko_dev_data {
struct net_if *iface;
uint8_t mac_addr[6];
struct k_sem tx_sem;
struct k_sem rx_sem;
K_KERNEL_STACK_MEMBER(rx_thread_stack,
CONFIG_ETH_GECKO_RX_THREAD_STACK_SIZE);
struct k_thread rx_thread;
bool link_up;
};
/* PHY Management pins */
#define PIN_PHY_MDC {DT_INST_PROP_BY_IDX(0, location_phy_mdc, 1), \
DT_INST_PROP_BY_IDX(0, location_phy_mdc, 2), gpioModePushPull,\
0}
#define PIN_PHY_MDIO {DT_INST_PROP_BY_IDX(0, location_phy_mdio, 1), \
DT_INST_PROP_BY_IDX(0, location_phy_mdio, 2), gpioModePushPull,\
0}
#define PIN_LIST_PHY {PIN_PHY_MDC, PIN_PHY_MDIO}
/* RMII pins excluding reference clock, handled by board.c */
#define PIN_RMII_CRSDV {DT_INST_PROP_BY_IDX(0, location_rmii_crs_dv, 1),\
DT_INST_PROP_BY_IDX(0, location_rmii_crs_dv, 2), gpioModeInput, 0}
#define PIN_RMII_TXD0 {DT_INST_PROP_BY_IDX(0, location_rmii_txd0, 1),\
DT_INST_PROP_BY_IDX(0, location_rmii_txd0, 2), gpioModePushPull, 0}
#define PIN_RMII_TXD1 {DT_INST_PROP_BY_IDX(0, location_rmii_txd1, 1),\
DT_INST_PROP_BY_IDX(0, location_rmii_txd1, 2), gpioModePushPull, 0}
#define PIN_RMII_TX_EN {DT_INST_PROP_BY_IDX(0, location_rmii_tx_en, 1),\
DT_INST_PROP_BY_IDX(0, location_rmii_tx_en, 2), gpioModePushPull, 0}
#define PIN_RMII_RXD0 {DT_INST_PROP_BY_IDX(0, location_rmii_rxd0, 1),\
DT_INST_PROP_BY_IDX(0, location_rmii_rxd0, 2), gpioModeInput, 0}
#define PIN_RMII_RXD1 {DT_INST_PROP_BY_IDX(0, location_rmii_rxd1, 1),\
DT_INST_PROP_BY_IDX(0, location_rmii_rxd1, 2), gpioModeInput, 0}
#define PIN_RMII_RX_ER {DT_INST_PROP_BY_IDX(0, location_rmii_rx_er, 1),\
DT_INST_PROP_BY_IDX(0, location_rmii_rx_er, 2), gpioModeInput, 0}
#define PIN_LIST_RMII {PIN_RMII_CRSDV, PIN_RMII_TXD0, PIN_RMII_TXD1, \
PIN_RMII_TX_EN, PIN_RMII_RXD0, PIN_RMII_RXD1, PIN_RMII_RX_ER}
/* RMII reference clock is not included in RMII pin set
* #define PIN_RMII_REFCLK {DT_INST_PROP_BY_IDX(0, location_rmii_refclk, 1),\
* DT_INST_PROP_BY_IDX(0, location_rmii_refclk, 2), gpioModePushPull, 0}
*/
#endif /* ZEPHYR_DRIVERS_ETHERNET_ETH_GECKO_PRIV_H_ */