1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2011 The Chromium OS Authors.
6 #ifndef __USB_ETHER_H__
7 #define __USB_ETHER_H__
11 /* TODO(sjg@chromium.org): Remove @pusb_dev when all boards use CONFIG_DM_ETH */
17 int rxlen; /* Total bytes available in rxbuf */
18 int rxptr; /* Current position in rxbuf */
20 struct eth_device eth_dev; /* used with eth_register */
24 int phy_id; /* mii phy id */
27 struct usb_device *pusb_dev; /* this usb_device */
28 unsigned char ifnum; /* interface number */
29 unsigned char ep_in; /* in endpoint */
30 unsigned char ep_out; /* out ....... */
31 unsigned char ep_int; /* interrupt . */
32 unsigned char subclass; /* as in overview */
33 unsigned char protocol; /* .............. */
34 unsigned char irqinterval; /* Intervall for IRQ Pipe */
39 * usb_ether_register() - register a new USB ethernet device
41 * This selects the correct USB interface and figures out the endpoints to use.
44 * @ss: Place to put USB ethernet data
45 * @rxsize: Maximum size to allocate for the receive buffer
46 * Return: 0 if OK, -ve on error
48 int usb_ether_register(struct udevice *dev, struct ueth_data *ueth, int rxsize);
51 * usb_ether_deregister() - deregister a USB ethernet device
53 * @ueth: USB Ethernet device
56 int usb_ether_deregister(struct ueth_data *ueth);
59 * usb_ether_receive() - recieve a packet from the bulk in endpoint
61 * The packet is stored in the internal buffer ready for processing.
63 * @ueth: USB Ethernet device
64 * @rxsize: Maximum size to receive
65 * Return: 0 if a packet was received, -EAGAIN if not, -ENOSPC if @rxsize is
66 * larger than the size passed ot usb_ether_register(), other -ve on error
68 int usb_ether_receive(struct ueth_data *ueth, int rxsize);
71 * usb_ether_get_rx_bytes() - obtain bytes from the internal packet buffer
73 * This should be called repeatedly to obtain packet data until it returns 0.
74 * After each packet is processed, call usb_ether_advance_rxbuf() to move to
77 * @ueth: USB Ethernet device
78 * @ptrp: Returns a pointer to the start of the next packet if there is
80 * Return: number of bytes available, or 0 if none
82 int usb_ether_get_rx_bytes(struct ueth_data *ueth, uint8_t **ptrp);
85 * usb_ether_advance_rxbuf() - Advance to the next packet in the internal buffer
87 * After processing the data returned by usb_ether_get_rx_bytes(), call this
88 * function to move to the next packet. You must specify the number of bytes
89 * you have processed in @num_bytes.
91 * @ueth: USB Ethernet device
92 * @num_bytes: Number of bytes to skip, or -1 to skip all bytes
94 void usb_ether_advance_rxbuf(struct ueth_data *ueth, int num_bytes);
97 * Function definitions for each USB ethernet driver go here
98 * (declaration is unconditional, compilation is conditional)
100 void asix_eth_before_probe(void);
101 int asix_eth_probe(struct usb_device *dev, unsigned int ifnum,
102 struct ueth_data *ss);
103 int asix_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
104 struct eth_device *eth);
106 void ax88179_eth_before_probe(void);
107 int ax88179_eth_probe(struct usb_device *dev, unsigned int ifnum,
108 struct ueth_data *ss);
109 int ax88179_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
110 struct eth_device *eth);
112 void mcs7830_eth_before_probe(void);
113 int mcs7830_eth_probe(struct usb_device *dev, unsigned int ifnum,
114 struct ueth_data *ss);
115 int mcs7830_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
116 struct eth_device *eth);
118 void smsc95xx_eth_before_probe(void);
119 int smsc95xx_eth_probe(struct usb_device *dev, unsigned int ifnum,
120 struct ueth_data *ss);
121 int smsc95xx_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
122 struct eth_device *eth);
124 void r8152_eth_before_probe(void);
125 int r8152_eth_probe(struct usb_device *dev, unsigned int ifnum,
126 struct ueth_data *ss);
127 int r8152_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
128 struct eth_device *eth);
131 #endif /* __USB_ETHER_H__ */