mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-22 04:44:46 +00:00
usb: eth: r8152: Remove non-DM_ETH code
As DM_ETH is required for all network drivers, it's now safe to remove the non-DM_ETH support code. Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
05d654b564
commit
82cdcd5792
2 changed files with 0 additions and 277 deletions
|
@ -18,43 +18,6 @@
|
||||||
#include "usb_ether.h"
|
#include "usb_ether.h"
|
||||||
#include "r8152.h"
|
#include "r8152.h"
|
||||||
|
|
||||||
#ifndef CONFIG_DM_ETH
|
|
||||||
/* local vars */
|
|
||||||
static int curr_eth_dev; /* index for name of next device detected */
|
|
||||||
|
|
||||||
struct r8152_dongle {
|
|
||||||
unsigned short vendor;
|
|
||||||
unsigned short product;
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct r8152_dongle r8152_dongles[] = {
|
|
||||||
/* Realtek */
|
|
||||||
{ 0x0bda, 0x8050 },
|
|
||||||
{ 0x0bda, 0x8152 },
|
|
||||||
{ 0x0bda, 0x8153 },
|
|
||||||
|
|
||||||
/* Samsung */
|
|
||||||
{ 0x04e8, 0xa101 },
|
|
||||||
|
|
||||||
/* Lenovo */
|
|
||||||
{ 0x17ef, 0x304f },
|
|
||||||
{ 0x17ef, 0x3052 },
|
|
||||||
{ 0x17ef, 0x3054 },
|
|
||||||
{ 0x17ef, 0x3057 },
|
|
||||||
{ 0x17ef, 0x7205 },
|
|
||||||
{ 0x17ef, 0x720a },
|
|
||||||
{ 0x17ef, 0x720b },
|
|
||||||
{ 0x17ef, 0x720c },
|
|
||||||
|
|
||||||
/* TP-LINK */
|
|
||||||
{ 0x2357, 0x0601 },
|
|
||||||
{ 0x2357, 0x0602 },
|
|
||||||
|
|
||||||
/* Nvidia */
|
|
||||||
{ 0x0955, 0x09ff },
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct r8152_version {
|
struct r8152_version {
|
||||||
unsigned short tcr;
|
unsigned short tcr;
|
||||||
unsigned short version;
|
unsigned short version;
|
||||||
|
@ -1479,243 +1442,6 @@ static int r8152_send_common(struct ueth_data *ueth, void *packet, int length)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CONFIG_DM_ETH
|
|
||||||
static int r8152_init(struct eth_device *eth, struct bd_info *bd)
|
|
||||||
{
|
|
||||||
struct ueth_data *dev = (struct ueth_data *)eth->priv;
|
|
||||||
struct r8152 *tp = (struct r8152 *)dev->dev_priv;
|
|
||||||
|
|
||||||
return r8152_init_common(tp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int r8152_send(struct eth_device *eth, void *packet, int length)
|
|
||||||
{
|
|
||||||
struct ueth_data *dev = (struct ueth_data *)eth->priv;
|
|
||||||
|
|
||||||
return r8152_send_common(dev, packet, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int r8152_recv(struct eth_device *eth)
|
|
||||||
{
|
|
||||||
struct ueth_data *dev = (struct ueth_data *)eth->priv;
|
|
||||||
|
|
||||||
ALLOC_CACHE_ALIGN_BUFFER(uint8_t, recv_buf, RTL8152_AGG_BUF_SZ);
|
|
||||||
unsigned char *pkt_ptr;
|
|
||||||
int err;
|
|
||||||
int actual_len;
|
|
||||||
u16 packet_len;
|
|
||||||
|
|
||||||
u32 bytes_process = 0;
|
|
||||||
struct rx_desc *rx_desc;
|
|
||||||
|
|
||||||
debug("** %s()\n", __func__);
|
|
||||||
|
|
||||||
err = usb_bulk_msg(dev->pusb_dev,
|
|
||||||
usb_rcvbulkpipe(dev->pusb_dev, dev->ep_in),
|
|
||||||
(void *)recv_buf,
|
|
||||||
RTL8152_AGG_BUF_SZ,
|
|
||||||
&actual_len,
|
|
||||||
USB_BULK_RECV_TIMEOUT);
|
|
||||||
debug("Rx: len = %u, actual = %u, err = %d\n", RTL8152_AGG_BUF_SZ,
|
|
||||||
actual_len, err);
|
|
||||||
if (err != 0) {
|
|
||||||
debug("Rx: failed to receive\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (actual_len > RTL8152_AGG_BUF_SZ) {
|
|
||||||
debug("Rx: received too many bytes %d\n", actual_len);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (bytes_process < actual_len) {
|
|
||||||
rx_desc = (struct rx_desc *)(recv_buf + bytes_process);
|
|
||||||
pkt_ptr = recv_buf + sizeof(struct rx_desc) + bytes_process;
|
|
||||||
|
|
||||||
packet_len = le32_to_cpu(rx_desc->opts1) & RX_LEN_MASK;
|
|
||||||
packet_len -= CRC_SIZE;
|
|
||||||
|
|
||||||
net_process_received_packet(pkt_ptr, packet_len);
|
|
||||||
|
|
||||||
bytes_process +=
|
|
||||||
(packet_len + sizeof(struct rx_desc) + CRC_SIZE);
|
|
||||||
|
|
||||||
if (bytes_process % 8)
|
|
||||||
bytes_process = bytes_process + 8 - (bytes_process % 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void r8152_halt(struct eth_device *eth)
|
|
||||||
{
|
|
||||||
struct ueth_data *dev = (struct ueth_data *)eth->priv;
|
|
||||||
struct r8152 *tp = (struct r8152 *)dev->dev_priv;
|
|
||||||
|
|
||||||
debug("** %s()\n", __func__);
|
|
||||||
|
|
||||||
tp->rtl_ops.disable(tp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int r8152_write_hwaddr(struct eth_device *eth)
|
|
||||||
{
|
|
||||||
struct ueth_data *dev = (struct ueth_data *)eth->priv;
|
|
||||||
struct r8152 *tp = (struct r8152 *)dev->dev_priv;
|
|
||||||
|
|
||||||
unsigned char enetaddr[8] = {0};
|
|
||||||
|
|
||||||
memcpy(enetaddr, eth->enetaddr, ETH_ALEN);
|
|
||||||
|
|
||||||
ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_CONFIG);
|
|
||||||
pla_ocp_write(tp, PLA_IDR, BYTE_EN_SIX_BYTES, 8, enetaddr);
|
|
||||||
ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML);
|
|
||||||
|
|
||||||
debug("MAC %pM\n", eth->enetaddr);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void r8152_eth_before_probe(void)
|
|
||||||
{
|
|
||||||
curr_eth_dev = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Probe to see if a new device is actually an realtek device */
|
|
||||||
int r8152_eth_probe(struct usb_device *dev, unsigned int ifnum,
|
|
||||||
struct ueth_data *ss)
|
|
||||||
{
|
|
||||||
struct usb_interface *iface;
|
|
||||||
struct usb_interface_descriptor *iface_desc;
|
|
||||||
int ep_in_found = 0, ep_out_found = 0;
|
|
||||||
struct r8152 *tp;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* let's examine the device now */
|
|
||||||
iface = &dev->config.if_desc[ifnum];
|
|
||||||
iface_desc = &dev->config.if_desc[ifnum].desc;
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(r8152_dongles); i++) {
|
|
||||||
if (dev->descriptor.idVendor == r8152_dongles[i].vendor &&
|
|
||||||
dev->descriptor.idProduct == r8152_dongles[i].product)
|
|
||||||
/* Found a supported dongle */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == ARRAY_SIZE(r8152_dongles))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
memset(ss, 0, sizeof(struct ueth_data));
|
|
||||||
|
|
||||||
/* At this point, we know we've got a live one */
|
|
||||||
debug("\n\nUSB Ethernet device detected: %#04x:%#04x\n",
|
|
||||||
dev->descriptor.idVendor, dev->descriptor.idProduct);
|
|
||||||
|
|
||||||
/* Initialize the ueth_data structure with some useful info */
|
|
||||||
ss->ifnum = ifnum;
|
|
||||||
ss->pusb_dev = dev;
|
|
||||||
ss->subclass = iface_desc->bInterfaceSubClass;
|
|
||||||
ss->protocol = iface_desc->bInterfaceProtocol;
|
|
||||||
|
|
||||||
/* alloc driver private */
|
|
||||||
ss->dev_priv = calloc(1, sizeof(struct r8152));
|
|
||||||
|
|
||||||
if (!ss->dev_priv)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We are expecting a minimum of 3 endpoints - in, out (bulk), and
|
|
||||||
* int. We will ignore any others.
|
|
||||||
*/
|
|
||||||
for (i = 0; i < iface_desc->bNumEndpoints; i++) {
|
|
||||||
/* is it an BULK endpoint? */
|
|
||||||
if ((iface->ep_desc[i].bmAttributes &
|
|
||||||
USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) {
|
|
||||||
u8 ep_addr = iface->ep_desc[i].bEndpointAddress;
|
|
||||||
|
|
||||||
if (ep_addr & USB_DIR_IN) {
|
|
||||||
if (!ep_in_found) {
|
|
||||||
ss->ep_in = ep_addr &
|
|
||||||
USB_ENDPOINT_NUMBER_MASK;
|
|
||||||
ep_in_found = 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!ep_out_found) {
|
|
||||||
ss->ep_out = ep_addr &
|
|
||||||
USB_ENDPOINT_NUMBER_MASK;
|
|
||||||
ep_out_found = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* is it an interrupt endpoint? */
|
|
||||||
if ((iface->ep_desc[i].bmAttributes &
|
|
||||||
USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) {
|
|
||||||
ss->ep_int = iface->ep_desc[i].bEndpointAddress &
|
|
||||||
USB_ENDPOINT_NUMBER_MASK;
|
|
||||||
ss->irqinterval = iface->ep_desc[i].bInterval;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
debug("Endpoints In %d Out %d Int %d\n",
|
|
||||||
ss->ep_in, ss->ep_out, ss->ep_int);
|
|
||||||
|
|
||||||
/* Do some basic sanity checks, and bail if we find a problem */
|
|
||||||
if (usb_set_interface(dev, iface_desc->bInterfaceNumber, 0) ||
|
|
||||||
!ss->ep_in || !ss->ep_out || !ss->ep_int) {
|
|
||||||
debug("Problems with device\n");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->privptr = (void *)ss;
|
|
||||||
|
|
||||||
tp = ss->dev_priv;
|
|
||||||
tp->udev = dev;
|
|
||||||
tp->intf = iface;
|
|
||||||
|
|
||||||
r8152b_get_version(tp);
|
|
||||||
|
|
||||||
if (rtl_ops_init(tp))
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
tp->rtl_ops.init(tp);
|
|
||||||
tp->rtl_ops.up(tp);
|
|
||||||
|
|
||||||
rtl8152_set_speed(tp, AUTONEG_ENABLE,
|
|
||||||
tp->supports_gmii ? SPEED_1000 : SPEED_100,
|
|
||||||
DUPLEX_FULL);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
error:
|
|
||||||
cfree(ss->dev_priv);
|
|
||||||
ss->dev_priv = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int r8152_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
|
|
||||||
struct eth_device *eth)
|
|
||||||
{
|
|
||||||
if (!eth) {
|
|
||||||
debug("%s: missing parameter.\n", __func__);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(eth->name, "%s#%d", R8152_BASE_NAME, curr_eth_dev++);
|
|
||||||
eth->init = r8152_init;
|
|
||||||
eth->send = r8152_send;
|
|
||||||
eth->recv = r8152_recv;
|
|
||||||
eth->halt = r8152_halt;
|
|
||||||
eth->write_hwaddr = r8152_write_hwaddr;
|
|
||||||
eth->priv = ss;
|
|
||||||
|
|
||||||
/* Get the MAC address */
|
|
||||||
if (r8152_read_mac(ss->dev_priv, eth->enetaddr) < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
debug("MAC %pM\n", eth->enetaddr);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif /* !CONFIG_DM_ETH */
|
|
||||||
|
|
||||||
#ifdef CONFIG_DM_ETH
|
|
||||||
static int r8152_eth_start(struct udevice *dev)
|
static int r8152_eth_start(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct r8152 *tp = dev_get_priv(dev);
|
struct r8152 *tp = dev_get_priv(dev);
|
||||||
|
@ -1895,4 +1621,3 @@ static const struct usb_device_id r8152_eth_id_table[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
U_BOOT_USB_DEVICE(r8152_eth, r8152_eth_id_table);
|
U_BOOT_USB_DEVICE(r8152_eth, r8152_eth_id_table);
|
||||||
#endif /* CONFIG_DM_ETH */
|
|
||||||
|
|
|
@ -642,9 +642,7 @@ struct r8152 {
|
||||||
|
|
||||||
u8 version;
|
u8 version;
|
||||||
|
|
||||||
#ifdef CONFIG_DM_ETH
|
|
||||||
struct ueth_data ueth;
|
struct ueth_data ueth;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int generic_ocp_write(struct r8152 *tp, u16 index, u16 byteen,
|
int generic_ocp_write(struct r8152 *tp, u16 index, u16 byteen,
|
||||||
|
|
Loading…
Add table
Reference in a new issue