19 #define LAN7800_VENDOR_ID 0x424
20 #define LAN7800_PRODUCT_ID 0x7800
22 usb_status_t
lan7800_write_reg(
struct usb_device *udev, uint32_t index, uint32_t data);
23 usb_status_t
lan7800_read_reg(
struct usb_device *udev, uint32_t index, uint32_t *data);
24 usb_status_t
lan7800_modify_reg(
struct usb_device *udev, uint32_t index, uint32_t mask, uint32_t set);
30 struct usb_xfer_request;
36 __lan7800_dump_reg(
struct usb_device *udev, uint32_t index,
const char *name)
40 kprintf(
"LAN7800: %s = 0x%08X\r\n", name, val);
43 #define lan7800_dump_reg(udev, index) __lan7800_dump_reg(udev, index, #index)
46 usb_status_t lan7800_mdio_read (
struct usb_device *udev,
int phy_id,
int idx);
47 void lan7800_mdio_write(
struct usb_device *udev,
int phy_id,
int idx,
int regval);
50 usb_status_t lan7800_read_raw_otp(
struct usb_device *udev, uint32_t offset,
51 uint32_t length, uint8_t *data);
52 int lan7800_read_otp_mac(
unsigned char *enetaddr,
53 struct usb_device *udev);
54 usb_status_t lan7800_eeprom_confirm_not_busy(
struct usb_device *udev);
55 usb_status_t lan7800_wait_eeprom(
struct usb_device *udev);
57 uint32_t length, uint8_t *data);
58 usb_status_t lan7800_read_eeprom(
struct usb_device *dev, uint32_t offset,
59 uint32_t length, uint8_t *data);
62 #define NETIF_F_RXCSUM 4
63 #define NETIF_F_HW_VLAN_CTAG_RX 2
64 #define NETIF_F_HW_VLAN_CTAG_FILTER 1
66 usb_status_t
lan7800_init(
struct usb_device *dev, uint8_t* macaddress);
73 #define lan7800_wait_for_bit lan7800_mdio_wait_for_bit
83 #define TX_CMD_A_IGE_ 0x20000000
84 #define TX_CMD_A_ICE_ 0x10000000
87 #define TX_CMD_A_LSO 0x08000000
89 #define TX_CMD_A_IPE_ 0x04000000
90 #define TX_CMD_A_TPE_ 0x02000000
91 #define TX_CMD_A_IVTG_ 0x01000000
92 #define TX_CMD_A_RVTG_ 0x00800000
95 #define LAN7800_TX_CMD_A_BUF_SIZE 0x000FFFFF
98 #define TX_CMD_B_MSS_SHIFT_ 16
99 #define TX_CMD_B_MSS_MASK_ 0x3FFF0000
100 #define TX_CMD_B_MSS_MIN_ (unsigned short)8
101 #define TX_CMD_B_VTAG_MASK_ 0x0000FFFF
102 #define TX_CMD_B_VTAG_PRI_MASK_ 0x0000E000
103 #define TX_CMD_B_VTAG_CFI_MASK_ 0x00001000
104 #define TX_CMD_B_VTAG_VID_MASK_ 0x00000FFF
109 #define LAN7800_TX_OVERHEAD 8
110 #define LAN7800_RX_OVERHEAD 4
113 #define LAN7800_HS_USB_PKT_SIZE 512
116 #define LAN7800_VENDOR_REQUEST_WRITE 0xA0
117 #define LAN7800_VENDOR_REQUEST_READ 0xA1
118 #define LAN7800_VENDER_REQUEST_GET_STATS 0xA2
121 #define LAN7800_MAC_RX 0x104
122 #define LAN7800_MAC_TX 0x108
125 #define LAN7800_ADDRH 0x118
126 #define LAN7800_ADDRL 0x11C
129 #define LAN7800_HW_CFG 0x010
132 #define LAN7800_HW_CFG_SRST 0x00000001
133 #define LAN7800_HW_CFG_LRST 0x00000002
135 #define LAN7800_BURST_CAP 0x090
136 #define LAN7800_BURST_CAP_SIZE 0x000000FF
139 #define MAC_CR_LOOPBACK 0x00000400
142 #define LAN7800_RX_STS_FL 0x00003FFF
145 #define LAN7800_RX_CMD_A_RX_ERR 0xC03F0000
152 #define LAN7800_TX_FLOW 0x0D0
155 #define LAN7800_RFE_CTL 0x0B0
157 #define LAN7800_MAC_CR 0x100
160 #define LAN7800_MAC_CR_ADP (1 << 13)
162 #define LAN7800_FCT_TX_CTL 0x0C4
164 #define LAN7800_ETH_FRAME_LEN 1514
165 #define LAN7800_MAC_RX_MAX_SIZE(mtu) \
167 #define LAN7800_MAC_RX_MAX_SIZE_DEFAULT LAN7800_MAC_RX_MAX_SIZE(LAN7800_ETH_FRAME_LEN + 4 + 4 )
169 #define LAN7800_MAC_RX_FCS_STRIP (1 << 4)
171 #define LAN7800_FCT_RX_CTL 0x0C0
174 #define LAN78XX_MAF_BASE 0x400
175 #define LAN78XX_MAF_HIX 0x00
176 #define LAN78XX_MAF_LOX 0x04
177 #define LAN78XX_MAF_HI_BEGIN (LAN78XX_MAF_BASE + LAN78XX_MAF_HIX)
178 #define LAN78XX_MAF_LO_BEGIN (LAN78XX_MAF_BASE + LAN78XX_MAF_LOX)
179 #define LAN78XX_MAF_HI(index) (LAN78XX_MAF_BASE + (8 * (index)) + \
181 #define LAN78XX_MAF_LO(index) (LAN78XX_MAF_BASE + (8 * (index)) + \
183 #define LAN78XX_MAF_HI_VALID BIT(31)
187 #define MII_ACC 0x120
188 #define MII_ACC_MII_READ 0x0
189 #define MII_ACC_MII_WRITE 0x2
190 #define MII_ACC_MII_BUSY 1 << 0
192 #define MII_DATA 0x124
194 #define TX_OVERHEAD 8
195 #define RX_OVERHEAD 10
196 #define RX_CMD_A_LEN_MASK 0x00003FFF
197 #define RX_CMD_A_RED 0x00400000
198 #define TX_CMD_A_LEN_MASK 0x000FFFFF
199 #define TX_CMD_A_FCS 0x00400000
203 #define LAN7800_OTP_BASE 0x00001000
204 #define LAN7800_OTP_PWR_DN LAN7800_OTP_BASE + 4 * 0x00
205 #define LAN7800_OTP_PWR_DN_PWRDN_N 0x01
206 #define LAN7800_OTP_ADDR1 LAN7800_OTP_BASE + 4 * 0x01
207 #define LAN7800_OTP_ADDR1_15_11 0x1F
208 #define LAN7800_OTP_ADDR2 LAN7800_OTP_BASE + 4 * 0x02
209 #define LAN7800_OTP_ADDR2_10_3 0xFF
210 #define LAN7800_OTP_FUNC_CMD LAN7800_OTP_BASE + 4 * 0x08
211 #define LAN7800_OTP_FUNC_CMD_READ 0x01
212 #define LAN7800_OTP_CMD_GO LAN7800_OTP_BASE + 4 * 0x0A
213 #define LAN7800_OTP_CMD_GO_GO 0x01
214 #define LAN7800_OTP_STATUS LAN7800_OTP_BASE + 4 * 0x0C
215 #define LAN7800_OTP_STATUS_BUSY 0x01
216 #define LAN7800_OTP_RD_DATA 0x01
217 #define LAN7800_OTP_INDICATOR_1 0xF3
218 #define LAN7800_OTP_INDICATOR_2 0xF7
223 #define LAN7800_EEPROM_INDICATOR 0xA5
224 #define LAN7800_E2P_CMD 0x040
225 #define LAN7800_E2P_CMD_EPC_BUSY 0x80000000
226 #define LAN7800_EEPROM_MAC_OFFSET 0x01
227 #define LAN7800_E2P_CMD_EPC_TIMEOUT 0x00000400
228 #define LAN7800_HW_CFG_LED3_EN 0x00800000
229 #define LAN7800_HW_CFG_LED2_EN 0x00400000
230 #define LAN7800_HW_CFG_LED1_EN 0x00200000
231 #define LAN7800_HW_CFG_LED0_EN 0x00100000
232 #define LAN7800_E2P_CMD_EPC_CMD_READ 0x00000000
233 #define LAN7800_E2P_CMD_EPC_ADDR_MASK 0x000001FF
234 #define LAN7800_E2P_DATA 0x44
235 #define LAN7800_USB_CFG1 0x084
236 #define LAN7800_USB_CFG1_LTM_ENABLE 0x00000100
238 #define LAN7800_LTM_BELT_IDLE0 0x0E0
239 #define LAN7800_LTM_BELT_IDLE1 0x0E4
240 #define LAN7800_LTM_BELT_ACT0 0x0E8
241 #define LAN7800_LTM_BELT_ACT1 0x0EC
242 #define LAN7800_LTM_INACTIVE0 0x0F0
243 #define LAN7800_LTM_INACTIVE1 0x0F4
244 #define LAN7800_MAC_RX_MAX_SIZE_MASK 0x3FFF0000
245 #define LAN7800_MAC_RX_MAX_SIZE_SHIFT 16
248 #define RFE_CTL_TCPUDP_COE 0x00001000
249 #define RFE_CTL_IP_COE 0x00000800
250 #define RFE_CTL_ICMP_COE 0x00002000
251 #define RFE_CTL_IGMP_COE 0x00004000
252 #define RFE_CTL_TCPUDP_COE 0x00001000
253 #define NETIF_F_HW_VLAN_CTAG_RX 2
254 #define RFE_CTL_VLAN_STRIP 0x00000080
255 #define NETIF_F_HW_VLAN_CTAG_FILTER 1
256 #define RFE_CTL_VLAN_FILTER 0x00000020
257 #define NETIF_F_RXCSUM 4
260 #define LAN7800_USB_CFG0 0x080
261 #define LAN7800_USB_CFG_BIR 0x00000040
262 #define LAN7800_MAX_TX_FIFO_SIZE 12 * 1024
263 #define LAN7800_MAX_RX_FIFO_SIZE 12 * 1024
264 #define LAN7800_DEFAULT_BURST_CAP_SIZE LAN7800_MAX_TX_FIFO_SIZE
265 #define LAN7800_FS_USB_PKT_SIZE 64
266 #define LAN7800_HS_USB_PKT_SIZE 512
267 #define LAN7800_SS_USB_PKT_SIZE 1024
269 #define LAN7800_BULK_IN_DLY 0x094
270 #define LAN7800_DEFAULT_BULK_IN_DELAY 0x0800
272 #define LAN7800_HW_CFG_MEF 0x00000010
273 #define LAN7800_USB_CFG_BCE 0x00000020
276 #define LAN7800_INT_STS 0x0C
277 #define LAN7800_INT_STS_CLEAR_ALL 0xFFFFFFFF
278 #define LAN7800_FLOW 0x10C
279 #define LAN7800_FCT_FLOW 0x0D0
280 #define LAN7800_FCT_TX_FIFO_END 0x0CC
281 #define LAN7800_FCT_RX_FIFO_END 0x0C8
283 #define LAN7800_RFE_CTL_BCAST_EN 0x00000400
284 #define LAN7800_RFE_CTL_DA_PERFECT 0x00000002
285 #define LAN7800_RFE_CTL 0x0B0
286 #define LAN7800_RFE_CTL_UCAST_EN 0x00000100
287 #define LAN7800_RFE_CTL_MCAST_EN 0x00000200
288 #define LAN7800_RFE_CTL_MCAST_HASH 0x00000008
291 #define LAN7800_PMT_CTL 0x014
292 #define LAN7800_PMT_CTL_PHY_RST 0x00000010
295 #define LAN7800_EEPROM_INDICATOR 0xA5
296 #define LAN7800_MAC_CR_AUTO_DUPLEX 0x00001000
297 #define LAN7800_MAC_CR_AUTO_SPEED 0x00000800
298 #define LAN7800_FCT_TX_CTL 0x0C4
301 #define LAN7800_ETH_MTU 1500
303 #define LAN7800_ETH_ALEN 6
305 #define LAN7800_ETH_VLAN_LEN 4
306 #define LAN7800_MAC_RX_RXEN 0x00000001
307 #define LAN7800_MAC_TX_TXEN 0x00000001
310 #define LAN7800_FCT_RX_CTL 0x0C0
311 #define LAN7800_FCT_RX_CTL_EN 0x80000000
312 #define LAN7800_FCT_TX_CTL 0x0C4
313 #define LAN7800_FCT_TX_CTL_EN 0x80000000
usb_status_t lan7800_write_reg(struct usb_device *udev, uint32_t index, uint32_t data)
Definition: lan7800.c:36
usb_status_t lan7800_wait_device_attached(ushort minor)
Definition: etherInit.c:210
usb_status_t lan7800_read_raw_eeprom(struct usb_device *udev, uint32_t offset, uint32_t length, uint8_t *data)
Definition: lan7800.c:237
usb_status_t lan7800_set_mac_address(struct usb_device *udev, const uint8_t *macaddr)
Definition: lan7800.c:122
usb_status_t lan7800_get_mac_address(struct usb_device *udev, uint8_t *macaddr)
Definition: lan7800.c:148
usb_status_t lan7800_set_rx_max_frame_length(struct usb_device *udev, int size)
Definition: lan7800.c:294
usb_status_t lan7800_mdio_wait_for_bit(struct usb_device *udev, const uint32_t reg, const uint32_t mask, const bool set)
Definition: lan7800.c:184
usb_status_t lan7800_modify_reg(struct usb_device *udev, uint32_t index, uint32_t mask, uint32_t set)
Definition: lan7800.c:80
usb_status_t lan7800_init(struct usb_device *udev, uint8_t *macaddress)
Definition: lan7800.c:367
void lan7800_rx_complete(struct usb_xfer_request *req)
Definition: etherInterrupt.c:58
void lan7800_tx_complete(struct usb_xfer_request *req)
Definition: etherInterrupt.c:33
usb_status_t lan7800_set_reg_bits(struct usb_device *udev, uint32_t index, uint32_t set)
Definition: lan7800.c:106
usb_status_t lan7800_read_reg(struct usb_device *udev, uint32_t index, uint32_t *data)
Definition: lan7800.c:56
usb_status_t lan7800_set_features(struct usb_device *udev, uint32_t set)
Definition: lan7800.c:330
syscall kprintf(const char *format,...)
Definition: kprintf.c:26