#include <usb.h>
#include <linux/mii.h>
#include "usb_ether.h"
+#include <malloc.h>
/* SMSC LAN95xx based USB 2.0 Ethernet Devices */
/* local vars */
static int curr_eth_dev; /* index for name of next device detected */
+/* driver private */
+struct smsc95xx_private {
+ size_t rx_urb_size; /* maximum USB URB size */
+ u32 mac_cr; /* MAC control register value */
+ int have_hwaddr; /* 1 if we have a hardware MAC address */
+};
/*
* Smsc95xx infrastructure commands
static int smsc95xx_write_hwaddr(struct eth_device *eth)
{
struct ueth_data *dev = (struct ueth_data *)eth->priv;
+ struct smsc95xx_private *priv = dev->dev_priv;
u32 addr_lo = __get_unaligned_le32(ð->enetaddr[0]);
u32 addr_hi = __get_unaligned_le16(ð->enetaddr[4]);
int ret;
return ret;
debug("MAC %pM\n", eth->enetaddr);
- dev->have_hwaddr = 1;
+ priv->have_hwaddr = 1;
return 0;
}
static void smsc95xx_set_multicast(struct ueth_data *dev)
{
+ struct smsc95xx_private *priv = dev->dev_priv;
+
/* No multicast in u-boot */
- dev->mac_cr &= ~(MAC_CR_PRMS_ | MAC_CR_MCPAS_ | MAC_CR_HPFILT_);
+ priv->mac_cr &= ~(MAC_CR_PRMS_ | MAC_CR_MCPAS_ | MAC_CR_HPFILT_);
}
/* starts the TX path */
static void smsc95xx_start_tx_path(struct ueth_data *dev)
{
+ struct smsc95xx_private *priv = dev->dev_priv;
u32 reg_val;
/* Enable Tx at MAC */
- dev->mac_cr |= MAC_CR_TXEN_;
+ priv->mac_cr |= MAC_CR_TXEN_;
- smsc95xx_write_reg(dev, MAC_CR, dev->mac_cr);
+ smsc95xx_write_reg(dev, MAC_CR, priv->mac_cr);
/* Enable Tx at SCSRs */
reg_val = TX_CFG_ON_;
/* Starts the Receive path */
static void smsc95xx_start_rx_path(struct ueth_data *dev)
{
- dev->mac_cr |= MAC_CR_RXEN_;
- smsc95xx_write_reg(dev, MAC_CR, dev->mac_cr);
+ struct smsc95xx_private *priv = dev->dev_priv;
+
+ priv->mac_cr |= MAC_CR_RXEN_;
+ smsc95xx_write_reg(dev, MAC_CR, priv->mac_cr);
}
/*
u32 burst_cap;
int timeout;
struct ueth_data *dev = (struct ueth_data *)eth->priv;
+ struct smsc95xx_private *priv =
+ (struct smsc95xx_private *)dev->dev_priv;
#define TIMEOUT_RESOLUTION 50 /* ms */
int link_detected;
debug("timeout waiting for PHY Reset\n");
return -1;
}
- if (!dev->have_hwaddr && smsc95xx_init_mac_address(eth, dev) == 0)
- dev->have_hwaddr = 1;
- if (!dev->have_hwaddr) {
+ if (!priv->have_hwaddr && smsc95xx_init_mac_address(eth, dev) == 0)
+ priv->have_hwaddr = 1;
+ if (!priv->have_hwaddr) {
puts("Error: SMSC95xx: No MAC address set - set usbethaddr\n");
return -1;
}
#ifdef TURBO_MODE
if (dev->pusb_dev->speed == USB_SPEED_HIGH) {
burst_cap = DEFAULT_HS_BURST_CAP_SIZE / HS_USB_PKT_SIZE;
- dev->rx_urb_size = DEFAULT_HS_BURST_CAP_SIZE;
+ priv->rx_urb_size = DEFAULT_HS_BURST_CAP_SIZE;
} else {
burst_cap = DEFAULT_FS_BURST_CAP_SIZE / FS_USB_PKT_SIZE;
- dev->rx_urb_size = DEFAULT_FS_BURST_CAP_SIZE;
+ priv->rx_urb_size = DEFAULT_FS_BURST_CAP_SIZE;
}
#else
burst_cap = 0;
- dev->rx_urb_size = MAX_SINGLE_PACKET_SIZE;
+ priv->rx_urb_size = MAX_SINGLE_PACKET_SIZE;
#endif
- debug("rx_urb_size=%ld\n", (ulong)dev->rx_urb_size);
+ debug("rx_urb_size=%ld\n", (ulong)priv->rx_urb_size);
ret = smsc95xx_write_reg(dev, BURST_CAP, burst_cap);
if (ret < 0)
if (ret < 0)
return ret;
- ret = smsc95xx_read_reg(dev, MAC_CR, &dev->mac_cr);
+ ret = smsc95xx_read_reg(dev, MAC_CR, &priv->mac_cr);
if (ret < 0)
return ret;
return 0;
}
dev->privptr = (void *)ss;
+
+ /* alloc driver private */
+ ss->dev_priv = calloc(1, sizeof(struct smsc95xx_private));
+ if (!ss->dev_priv)
+ return 0;
+
return 1;
}