]> git.ipfire.org Git - thirdparty/u-boot.git/blame - include/usb_ether.h
Merge branch 'master' of https://gitlab.denx.de/u-boot/custodians/u-boot-spi
[thirdparty/u-boot.git] / include / usb_ether.h
CommitLineData
83d290c5 1/* SPDX-License-Identifier: GPL-2.0+ */
89d48367
SG
2/*
3 * Copyright (c) 2011 The Chromium OS Authors.
89d48367
SG
4 */
5
6#ifndef __USB_ETHER_H__
7#define __USB_ETHER_H__
8
9#include <net.h>
89d48367 10
c8c2797c 11/* TODO(sjg@chromium.org): Remove @pusb_dev when all boards use CONFIG_DM_ETH */
89d48367
SG
12struct ueth_data {
13 /* eth info */
c8c2797c
SG
14#ifdef CONFIG_DM_ETH
15 uint8_t *rxbuf;
16 int rxsize;
17 int rxlen; /* Total bytes available in rxbuf */
18 int rxptr; /* Current position in rxbuf */
19#else
20 struct eth_device eth_dev; /* used with eth_register */
21 /* driver private */
22 void *dev_priv;
23#endif
24 int phy_id; /* mii phy id */
89d48367
SG
25
26 /* usb info */
27 struct usb_device *pusb_dev; /* this usb_device */
c8c2797c
SG
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; /* .............. */
89d48367 34 unsigned char irqinterval; /* Intervall for IRQ Pipe */
89d48367
SG
35};
36
c8c2797c
SG
37#ifdef CONFIG_DM_ETH
38/**
39 * usb_ether_register() - register a new USB ethernet device
40 *
41 * This selects the correct USB interface and figures out the endpoints to use.
42 *
43 * @dev: USB device
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
47 */
48int usb_ether_register(struct udevice *dev, struct ueth_data *ueth, int rxsize);
49
50/**
51 * usb_ether_deregister() - deregister a USB ethernet device
52 *
53 * @ueth: USB Ethernet device
54 * @return 0
55 */
56int usb_ether_deregister(struct ueth_data *ueth);
57
58/**
59 * usb_ether_receive() - recieve a packet from the bulk in endpoint
60 *
61 * The packet is stored in the internal buffer ready for processing.
62 *
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
67 */
68int usb_ether_receive(struct ueth_data *ueth, int rxsize);
69
70/**
71 * usb_ether_get_rx_bytes() - obtain bytes from the internal packet buffer
72 *
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
75 * the next one.
76 *
77 * @ueth: USB Ethernet device
78 * @ptrp: Returns a pointer to the start of the next packet if there is
79 * one available
80 * @return number of bytes available, or 0 if none
81 */
82int usb_ether_get_rx_bytes(struct ueth_data *ueth, uint8_t **ptrp);
83
84/**
85 * usb_ether_advance_rxbuf() - Advance to the next packet in the internal buffer
86 *
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.
90 *
91 * @ueth: USB Ethernet device
92 * @num_bytes: Number of bytes to skip, or -1 to skip all bytes
93 */
94void usb_ether_advance_rxbuf(struct ueth_data *ueth, int num_bytes);
95#else
89d48367 96/*
440a5742
GS
97 * Function definitions for each USB ethernet driver go here
98 * (declaration is unconditional, compilation is conditional)
89d48367 99 */
9b70e007
SG
100void asix_eth_before_probe(void);
101int asix_eth_probe(struct usb_device *dev, unsigned int ifnum,
102 struct ueth_data *ss);
103int asix_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
104 struct eth_device *eth);
89d48367 105
e9954b86
RG
106void ax88179_eth_before_probe(void);
107int ax88179_eth_probe(struct usb_device *dev, unsigned int ifnum,
108 struct ueth_data *ss);
109int ax88179_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
110 struct eth_device *eth);
111
df4fb1c3
GS
112void mcs7830_eth_before_probe(void);
113int mcs7830_eth_probe(struct usb_device *dev, unsigned int ifnum,
114 struct ueth_data *ss);
115int mcs7830_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
116 struct eth_device *eth);
117
291391be
SG
118void smsc95xx_eth_before_probe(void);
119int smsc95xx_eth_probe(struct usb_device *dev, unsigned int ifnum,
120 struct ueth_data *ss);
121int smsc95xx_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
122 struct eth_device *eth);
9dc8ba19
TC
123
124void r8152_eth_before_probe(void);
125int r8152_eth_probe(struct usb_device *dev, unsigned int ifnum,
126 struct ueth_data *ss);
127int r8152_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
128 struct eth_device *eth);
c8c2797c 129#endif
291391be 130
89d48367 131#endif /* __USB_ETHER_H__ */