iPXE
Functions | Variables
lan78xx.c File Reference

Microchip LAN78xx USB Ethernet driver. More...

#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <ipxe/ethernet.h>
#include <ipxe/usb.h>
#include <ipxe/usbnet.h>
#include "lan78xx.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static int lan78xx_eeprom_fetch_mac (struct smscusb_device *smscusb)
 Fetch MAC address from EEPROM. More...
 
static int lan78xx_fetch_mac (struct smscusb_device *smscusb)
 Fetch MAC address. More...
 
static int lan78xx_reset (struct smscusb_device *smscusb)
 Reset device. More...
 
static int lan78xx_open (struct net_device *netdev)
 Open network device. More...
 
static void lan78xx_close (struct net_device *netdev)
 Close network device. More...
 
static int lan78xx_probe (struct usb_function *func, struct usb_configuration_descriptor *config)
 Probe device. More...
 
static void lan78xx_remove (struct usb_function *func)
 Remove device. More...
 

Variables

static struct net_device_operations lan78xx_operations
 LAN78xx network device operations. More...
 
static struct usb_device_id lan78xx_ids []
 LAN78xx device IDs. More...
 
struct usb_driver lan78xx_driver __usb_driver
 LAN78xx driver. More...
 

Detailed Description

Microchip LAN78xx USB Ethernet driver.

Definition in file lan78xx.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ lan78xx_eeprom_fetch_mac()

static int lan78xx_eeprom_fetch_mac ( struct smscusb_device smscusb)
static

Fetch MAC address from EEPROM.

Parameters
smscusbSMSC USB device
Return values
rcReturn status code

Definition at line 53 of file lan78xx.c.

53  {
54  uint32_t hw_cfg;
55  uint32_t orig_hw_cfg;
56  int rc;
57 
58  /* Read original HW_CFG value */
59  if ( ( rc = smscusb_readl ( smscusb, LAN78XX_HW_CFG, &hw_cfg ) ) != 0 )
60  goto err_read_hw_cfg;
61  orig_hw_cfg = hw_cfg;
62 
63  /* Temporarily disable LED0 and LED1 (which share physical
64  * pins with EEDO and EECLK respectively).
65  */
67  if ( ( rc = smscusb_writel ( smscusb, LAN78XX_HW_CFG, hw_cfg ) ) != 0 )
68  goto err_write_hw_cfg;
69 
70  /* Fetch MAC address from EEPROM */
71  if ( ( rc = smscusb_eeprom_fetch_mac ( smscusb,
72  LAN78XX_E2P_BASE ) ) != 0 )
73  goto err_fetch_mac;
74 
75  err_fetch_mac:
76  smscusb_writel ( smscusb, LAN78XX_HW_CFG, orig_hw_cfg );
77  err_write_hw_cfg:
78  err_read_hw_cfg:
79  return rc;
80 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define LAN78XX_HW_CFG_LED1_EN
LED1 enable.
Definition: lan78xx.h:17
#define LAN78XX_HW_CFG_LED0_EN
LED1 enable.
Definition: lan78xx.h:18
static int smscusb_writel(struct smscusb_device *smscusb, unsigned int address, uint32_t value)
Write register.
Definition: smscusb.h:182
#define LAN78XX_E2P_BASE
EEPROM register base.
Definition: lan78xx.h:31
#define LAN78XX_HW_CFG
Hardware configuration register.
Definition: lan78xx.h:16
static int smscusb_readl(struct smscusb_device *smscusb, unsigned int address, uint32_t *value)
Read register.
Definition: smscusb.h:203
int smscusb_eeprom_fetch_mac(struct smscusb_device *smscusb, unsigned int e2p_base)
Fetch MAC address from EEPROM.
Definition: smscusb.c:215
unsigned int uint32_t
Definition: stdint.h:12

References LAN78XX_E2P_BASE, LAN78XX_HW_CFG, LAN78XX_HW_CFG_LED0_EN, LAN78XX_HW_CFG_LED1_EN, rc, smscusb_eeprom_fetch_mac(), smscusb_readl(), and smscusb_writel().

Referenced by lan78xx_fetch_mac().

◆ lan78xx_fetch_mac()

static int lan78xx_fetch_mac ( struct smscusb_device smscusb)
static

Fetch MAC address.

Parameters
smscusbSMSC USB device
Return values
rcReturn status code

Definition at line 88 of file lan78xx.c.

88  {
89  struct net_device *netdev = smscusb->netdev;
90  int rc;
91 
92  /* Read MAC address from EEPROM, if present */
93  if ( ( rc = lan78xx_eeprom_fetch_mac ( smscusb ) ) == 0 )
94  return 0;
95 
96  /* Read MAC address from OTP, if present */
97  if ( ( rc = smscusb_otp_fetch_mac ( smscusb, LAN78XX_OTP_BASE ) ) == 0 )
98  return 0;
99 
100  /* Read MAC address from device tree, if present */
101  if ( ( rc = smscusb_fdt_fetch_mac ( smscusb ) ) == 0 )
102  return 0;
103 
104  /* Otherwise, generate a random MAC address */
106  DBGC ( smscusb, "LAN78XX %p using random MAC %s\n",
107  smscusb, eth_ntoa ( netdev->hw_addr ) );
108  return 0;
109 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
static struct net_device * netdev
Definition: gdbudp.c:52
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
A network device.
Definition: netdevice.h:348
static int lan78xx_eeprom_fetch_mac(struct smscusb_device *smscusb)
Fetch MAC address from EEPROM.
Definition: lan78xx.c:53
int smscusb_otp_fetch_mac(struct smscusb_device *smscusb, unsigned int otp_base)
Fetch MAC address from OTP.
Definition: smscusb.c:400
#define LAN78XX_OTP_BASE
OTP register base.
Definition: lan78xx.h:98
struct net_device * netdev
Network device.
Definition: smscusb.h:153
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition: netdevice.h:375
int smscusb_fdt_fetch_mac(struct smscusb_device *smscusb)
Fetch MAC address from device tree.
Definition: smscusb.c:456
void eth_random_addr(void *hw_addr)
Generate random Ethernet address.
Definition: ethernet.c:159

References DBGC, eth_ntoa(), eth_random_addr(), net_device::hw_addr, lan78xx_eeprom_fetch_mac(), LAN78XX_OTP_BASE, netdev, smscusb_device::netdev, rc, smscusb_fdt_fetch_mac(), and smscusb_otp_fetch_mac().

Referenced by lan78xx_probe().

◆ lan78xx_reset()

static int lan78xx_reset ( struct smscusb_device smscusb)
static

Reset device.

Parameters
smscusbSMSC USB device
Return values
rcReturn status code

Definition at line 124 of file lan78xx.c.

124  {
125  uint32_t hw_cfg;
126  unsigned int i;
127  int rc;
128 
129  /* Reset device */
130  if ( ( rc = smscusb_writel ( smscusb, LAN78XX_HW_CFG,
131  LAN78XX_HW_CFG_LRST ) ) != 0 )
132  return rc;
133 
134  /* Wait for reset to complete */
135  for ( i = 0 ; i < LAN78XX_RESET_MAX_WAIT_MS ; i++ ) {
136 
137  /* Check if reset has completed */
138  if ( ( rc = smscusb_readl ( smscusb, LAN78XX_HW_CFG,
139  &hw_cfg ) ) != 0 )
140  return rc;
141  if ( ! ( hw_cfg & LAN78XX_HW_CFG_LRST ) )
142  return 0;
143 
144  /* Delay */
145  mdelay ( 1 );
146  }
147 
148  DBGC ( smscusb, "LAN78XX %p timed out waiting for reset\n",
149  smscusb );
150  return -ETIMEDOUT;
151 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
static int smscusb_writel(struct smscusb_device *smscusb, unsigned int address, uint32_t value)
Write register.
Definition: smscusb.h:182
#define LAN78XX_HW_CFG
Hardware configuration register.
Definition: lan78xx.h:16
#define LAN78XX_HW_CFG_LRST
Soft lite reset.
Definition: lan78xx.h:19
static int smscusb_readl(struct smscusb_device *smscusb, unsigned int address, uint32_t *value)
Read register.
Definition: smscusb.h:203
unsigned int uint32_t
Definition: stdint.h:12
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
#define LAN78XX_RESET_MAX_WAIT_MS
Maximum time to wait for reset (in milliseconds)
Definition: lan78xx.h:101

References DBGC, ETIMEDOUT, LAN78XX_HW_CFG, LAN78XX_HW_CFG_LRST, LAN78XX_RESET_MAX_WAIT_MS, mdelay(), rc, smscusb_readl(), and smscusb_writel().

Referenced by lan78xx_close(), lan78xx_open(), and lan78xx_probe().

◆ lan78xx_open()

static int lan78xx_open ( struct net_device netdev)
static

Open network device.

Parameters
netdevNetwork device
Return values
rcReturn status code

Definition at line 166 of file lan78xx.c.

166  {
167  struct smscusb_device *smscusb = netdev->priv;
168  uint32_t usb_cfg0;
169  int rc;
170 
171  /* Clear stored interrupt status */
172  smscusb->int_sts = 0;
173 
174  /* Configure bulk IN empty response */
175  if ( ( rc = smscusb_readl ( smscusb, LAN78XX_USB_CFG0,
176  &usb_cfg0 ) ) != 0 )
177  goto err_usb_cfg0_read;
178  usb_cfg0 |= LAN78XX_USB_CFG0_BIR;
179  if ( ( rc = smscusb_writel ( smscusb, LAN78XX_USB_CFG0,
180  usb_cfg0 ) ) != 0 )
181  goto err_usb_cfg0_write;
182 
183  /* Open USB network device */
184  if ( ( rc = usbnet_open ( &smscusb->usbnet ) ) != 0 ) {
185  DBGC ( smscusb, "LAN78XX %p could not open: %s\n",
186  smscusb, strerror ( rc ) );
187  goto err_open;
188  }
189 
190  /* Configure interrupt endpoint */
191  if ( ( rc = smscusb_writel ( smscusb, LAN78XX_INT_EP_CTL,
193  LAN78XX_INT_EP_CTL_PHY_EN ) ) ) != 0 )
194  goto err_int_ep_ctl;
195 
196  /* Configure bulk IN delay */
197  if ( ( rc = smscusb_writel ( smscusb, LAN78XX_BULK_IN_DLY,
198  LAN78XX_BULK_IN_DLY_SET ( 0 ) ) ) != 0 )
199  goto err_bulk_in_dly;
200 
201  /* Enable automatic speed and duplex detection */
202  if ( ( rc = smscusb_writel ( smscusb, LAN78XX_MAC_CR,
205  LAN78XX_MAC_CR_ASD ) ) ) != 0 )
206  goto err_mac_cr;
207 
208  /* Configure receive filters */
209  if ( ( rc = smscusb_writel ( smscusb, LAN78XX_RFE_CTL,
212  LAN78XX_RFE_CTL_AU ) ) ) != 0 )
213  goto err_rfe_ctl;
214 
215  /* Configure receive FIFO */
216  if ( ( rc = smscusb_writel ( smscusb, LAN78XX_FCT_RX_CTL,
218  LAN78XX_FCT_RX_CTL_BAD ) ) ) != 0 )
219  goto err_fct_rx_ctl;
220 
221  /* Configure transmit FIFO */
222  if ( ( rc = smscusb_writel ( smscusb, LAN78XX_FCT_TX_CTL,
223  LAN78XX_FCT_TX_CTL_EN ) ) != 0 )
224  goto err_fct_tx_ctl;
225 
226  /* Configure receive datapath */
227  if ( ( rc = smscusb_writel ( smscusb, LAN78XX_MAC_RX,
230  LAN78XX_MAC_RX_EN ) ) ) != 0 )
231  goto err_mac_rx;
232 
233  /* Configure transmit datapath */
234  if ( ( rc = smscusb_writel ( smscusb, LAN78XX_MAC_TX,
235  LAN78XX_MAC_TX_EN ) ) != 0 )
236  goto err_mac_tx;
237 
238  /* Set MAC address */
239  if ( ( rc = smscusb_set_address ( smscusb,
240  LAN78XX_RX_ADDR_BASE ) ) != 0 )
241  goto err_set_address;
242 
243  /* Set MAC address perfect filter */
244  if ( ( rc = smscusb_set_filter ( smscusb,
245  LAN78XX_ADDR_FILT_BASE ) ) != 0 )
246  goto err_set_filter;
247 
248  /* Enable PHY interrupts and update link status */
249  if ( ( rc = smscusb_mii_open ( smscusb, LAN78XX_MII_PHY_INTR_MASK,
253  LAN78XX_PHY_INTR_ANEG_DONE ) ) ) != 0 )
254  goto err_mii_open;
255 
256  return 0;
257 
258  err_mii_open:
259  err_set_filter:
260  err_set_address:
261  err_mac_tx:
262  err_mac_rx:
263  err_fct_tx_ctl:
264  err_fct_rx_ctl:
265  err_rfe_ctl:
266  err_mac_cr:
267  err_bulk_in_dly:
268  err_int_ep_ctl:
269  usbnet_close ( &smscusb->usbnet );
270  err_open:
271  err_usb_cfg0_write:
272  err_usb_cfg0_read:
273  lan78xx_reset ( smscusb );
274  return rc;
275 }
int smscusb_set_address(struct smscusb_device *smscusb, unsigned int addr_base)
Set receive address.
Definition: smscusb.c:686
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define LAN78XX_PHY_INTR_ANEG_ERR
PHY interrupt: auto-negotiation failure.
Definition: lan78xx.h:89
#define LAN78XX_PHY_INTR_ENABLE
PHY interrupt: global enable.
Definition: lan78xx.h:83
An SMSC USB device.
Definition: smscusb.h:147
#define LAN78XX_MAC_CR_ASD
Auto speed.
Definition: lan78xx.h:56
#define LAN78XX_ADDR_FILT_BASE
MAC address perfect filter register base.
Definition: lan78xx.h:95
#define LAN78XX_FCT_RX_CTL_BAD
Store bad frames.
Definition: lan78xx.h:46
#define LAN78XX_USB_CFG0
USB configuration register 0.
Definition: lan78xx.h:34
#define DBGC(...)
Definition: compiler.h:505
#define LAN78XX_MAC_CR_ADP
Duplex polarity.
Definition: lan78xx.h:54
#define LAN78XX_FCT_RX_CTL
FIFO controller RX FIFO control register.
Definition: lan78xx.h:44
#define LAN78XX_FCT_TX_CTL
FIFO controller TX FIFO control register.
Definition: lan78xx.h:49
#define LAN78XX_USB_CFG0_BIR
Bulk IN use NAK.
Definition: lan78xx.h:35
static int smscusb_writel(struct smscusb_device *smscusb, unsigned int address, uint32_t value)
Write register.
Definition: smscusb.h:182
#define LAN78XX_MAC_CR
MAC control register.
Definition: lan78xx.h:53
#define LAN78XX_FCT_RX_CTL_EN
FCT RX enable.
Definition: lan78xx.h:45
#define LAN78XX_INT_EP_CTL
Interrupt endpoint control register.
Definition: lan78xx.h:22
int smscusb_mii_open(struct smscusb_device *smscusb, unsigned int phy_mask, unsigned int intrs)
Enable PHY interrupts and update link status.
Definition: smscusb.c:655
#define LAN78XX_MAC_RX_FCS
FCS stripping.
Definition: lan78xx.h:63
int smscusb_set_filter(struct smscusb_device *smscusb, unsigned int filt_base)
Set receive filter.
Definition: smscusb.c:718
#define LAN78XX_MII_PHY_INTR_MASK
PHY interrupt mask MII register.
Definition: lan78xx.h:77
uint32_t int_sts
Interrupt status.
Definition: smscusb.h:165
struct usbnet_device usbnet
USB network device.
Definition: smscusb.h:155
#define LAN78XX_MAC_RX
MAC receive register.
Definition: lan78xx.h:59
#define LAN78XX_MAC_RX_MAX_SIZE_DEFAULT
Definition: lan78xx.h:61
void * priv
Driver private data.
Definition: netdevice.h:425
static struct net_device * netdev
Definition: gdbudp.c:52
#define LAN78XX_MAC_RX_EN
RX enable.
Definition: lan78xx.h:64
static int smscusb_readl(struct smscusb_device *smscusb, unsigned int address, uint32_t *value)
Read register.
Definition: smscusb.h:203
#define LAN78XX_RFE_CTL_AM
Accept multicast.
Definition: lan78xx.h:40
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define LAN78XX_RFE_CTL_AU
Accept unicast.
Definition: lan78xx.h:41
#define LAN78XX_FCT_TX_CTL_EN
FCT TX enable.
Definition: lan78xx.h:50
unsigned int uint32_t
Definition: stdint.h:12
#define LAN78XX_RFE_CTL
Receive filtering engine control register.
Definition: lan78xx.h:38
#define LAN78XX_MAC_TX_EN
TX enable.
Definition: lan78xx.h:68
#define LAN78XX_PHY_INTR_LINK
PHY interrupt: link state change.
Definition: lan78xx.h:86
#define LAN78XX_RFE_CTL_AB
Accept broadcast.
Definition: lan78xx.h:39
#define LAN78XX_INT_EP_CTL_RDFO_EN
RX FIFO overflow.
Definition: lan78xx.h:23
#define LAN78XX_BULK_IN_DLY_SET(ticks)
Delay / 16.7ns.
Definition: lan78xx.h:28
static int lan78xx_reset(struct smscusb_device *smscusb)
Reset device.
Definition: lan78xx.c:124
#define LAN78XX_RX_ADDR_BASE
MAC receive address register base.
Definition: lan78xx.h:71
#define LAN78XX_PHY_INTR_ANEG_DONE
PHY interrupt: auto-negotiation complete.
Definition: lan78xx.h:92
void usbnet_close(struct usbnet_device *usbnet)
Close USB network device.
Definition: usbnet.c:127
#define LAN78XX_MAC_TX
MAC transmit register.
Definition: lan78xx.h:67
#define LAN78XX_INT_EP_CTL_PHY_EN
PHY interrupt.
Definition: lan78xx.h:24
#define LAN78XX_BULK_IN_DLY
Bulk IN delay register.
Definition: lan78xx.h:27
#define LAN78XX_MAC_CR_ADD
Auto duplex.
Definition: lan78xx.h:55
int usbnet_open(struct usbnet_device *usbnet)
Open USB network device.
Definition: usbnet.c:54

References DBGC, smscusb_device::int_sts, LAN78XX_ADDR_FILT_BASE, LAN78XX_BULK_IN_DLY, LAN78XX_BULK_IN_DLY_SET, LAN78XX_FCT_RX_CTL, LAN78XX_FCT_RX_CTL_BAD, LAN78XX_FCT_RX_CTL_EN, LAN78XX_FCT_TX_CTL, LAN78XX_FCT_TX_CTL_EN, LAN78XX_INT_EP_CTL, LAN78XX_INT_EP_CTL_PHY_EN, LAN78XX_INT_EP_CTL_RDFO_EN, LAN78XX_MAC_CR, LAN78XX_MAC_CR_ADD, LAN78XX_MAC_CR_ADP, LAN78XX_MAC_CR_ASD, LAN78XX_MAC_RX, LAN78XX_MAC_RX_EN, LAN78XX_MAC_RX_FCS, LAN78XX_MAC_RX_MAX_SIZE_DEFAULT, LAN78XX_MAC_TX, LAN78XX_MAC_TX_EN, LAN78XX_MII_PHY_INTR_MASK, LAN78XX_PHY_INTR_ANEG_DONE, LAN78XX_PHY_INTR_ANEG_ERR, LAN78XX_PHY_INTR_ENABLE, LAN78XX_PHY_INTR_LINK, lan78xx_reset(), LAN78XX_RFE_CTL, LAN78XX_RFE_CTL_AB, LAN78XX_RFE_CTL_AM, LAN78XX_RFE_CTL_AU, LAN78XX_RX_ADDR_BASE, LAN78XX_USB_CFG0, LAN78XX_USB_CFG0_BIR, netdev, net_device::priv, rc, smscusb_mii_open(), smscusb_readl(), smscusb_set_address(), smscusb_set_filter(), smscusb_writel(), strerror(), smscusb_device::usbnet, usbnet_close(), and usbnet_open().

◆ lan78xx_close()

static void lan78xx_close ( struct net_device netdev)
static

Close network device.

Parameters
netdevNetwork device

Definition at line 282 of file lan78xx.c.

282  {
283  struct smscusb_device *smscusb = netdev->priv;
284 
285  /* Close USB network device */
286  usbnet_close ( &smscusb->usbnet );
287 
288  /* Dump statistics (for debugging) */
289  if ( DBG_LOG )
290  smsc75xx_dump_statistics ( smscusb );
291 
292  /* Reset device */
293  lan78xx_reset ( smscusb );
294 }
An SMSC USB device.
Definition: smscusb.h:147
struct usbnet_device usbnet
USB network device.
Definition: smscusb.h:155
void * priv
Driver private data.
Definition: netdevice.h:425
int smsc75xx_dump_statistics(struct smscusb_device *smscusb)
Dump statistics (for debugging)
Definition: smsc75xx.c:63
static struct net_device * netdev
Definition: gdbudp.c:52
static int lan78xx_reset(struct smscusb_device *smscusb)
Reset device.
Definition: lan78xx.c:124
void usbnet_close(struct usbnet_device *usbnet)
Close USB network device.
Definition: usbnet.c:127
#define DBG_LOG
Definition: compiler.h:317

References DBG_LOG, lan78xx_reset(), netdev, net_device::priv, smsc75xx_dump_statistics(), smscusb_device::usbnet, and usbnet_close().

◆ lan78xx_probe()

static int lan78xx_probe ( struct usb_function func,
struct usb_configuration_descriptor config 
)
static

Probe device.

Parameters
funcUSB function
configConfiguration descriptor
Return values
rcReturn status code

Definition at line 318 of file lan78xx.c.

319  {
320  struct net_device *netdev;
321  struct smscusb_device *smscusb;
322  int rc;
323 
324  /* Allocate and initialise structure */
325  netdev = alloc_etherdev ( sizeof ( *smscusb ) );
326  if ( ! netdev ) {
327  rc = -ENOMEM;
328  goto err_alloc;
329  }
331  netdev->dev = &func->dev;
332  smscusb = netdev->priv;
333  memset ( smscusb, 0, sizeof ( *smscusb ) );
334  smscusb_init ( smscusb, netdev, func, &smsc75xx_in_operations );
337  usb_refill_init ( &smscusb->usbnet.in, 0, SMSC75XX_IN_MTU,
339  DBGC ( smscusb, "LAN78XX %p on %s\n", smscusb, func->name );
340 
341  /* Describe USB network device */
342  if ( ( rc = usbnet_describe ( &smscusb->usbnet, config ) ) != 0 ) {
343  DBGC ( smscusb, "LAN78XX %p could not describe: %s\n",
344  smscusb, strerror ( rc ) );
345  goto err_describe;
346  }
347 
348  /* Reset device */
349  if ( ( rc = lan78xx_reset ( smscusb ) ) != 0 )
350  goto err_reset;
351 
352  /* Read MAC address */
353  if ( ( rc = lan78xx_fetch_mac ( smscusb ) ) != 0 )
354  goto err_fetch_mac;
355 
356  /* Register network device */
357  if ( ( rc = register_netdev ( netdev ) ) != 0 )
358  goto err_register;
359 
360  usb_func_set_drvdata ( func, netdev );
361  return 0;
362 
364  err_register:
365  err_fetch_mac:
366  err_reset:
367  err_describe:
369  netdev_put ( netdev );
370  err_alloc:
371  return rc;
372 }
#define SMSC75XX_IN_MAX_FILL
Bulk IN maximum fill level.
Definition: smsc75xx.h:209
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Name.
Definition: usb.h:659
static int lan78xx_fetch_mac(struct smscusb_device *smscusb)
Fetch MAC address.
Definition: lan78xx.c:88
An SMSC USB device.
Definition: smscusb.h:147
static void smscusb_init(struct smscusb_device *smscusb, struct net_device *netdev, struct usb_function *func, struct usb_endpoint_driver_operations *in)
Initialise SMSC USB device.
Definition: smscusb.h:259
#define DBGC(...)
Definition: compiler.h:505
#define SMSC75XX_IN_MTU
Bulk IN buffer size.
Definition: smsc75xx.h:212
struct usb_endpoint_driver_operations smsc75xx_in_operations
Bulk IN endpoint operations.
Definition: smsc75xx.c:233
static void smscusb_mii_init(struct smscusb_device *smscusb, unsigned int mii_base, unsigned int phy_source)
Initialise SMSC USB device MII interface.
Definition: smscusb.h:280
#define LAN78XX_MII_BASE
MII register base.
Definition: lan78xx.h:74
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition: netdevice.h:498
#define ENOMEM
Not enough space.
Definition: errno.h:534
struct usbnet_device usbnet
USB network device.
Definition: smscusb.h:155
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
void * priv
Driver private data.
Definition: netdevice.h:425
static void usb_refill_init(struct usb_endpoint *ep, size_t reserve, size_t len, unsigned int max)
Initialise USB endpoint refill.
Definition: usb.h:601
static struct net_device * netdev
Definition: gdbudp.c:52
static void usb_func_set_drvdata(struct usb_function *func, void *priv)
Set USB function driver private data.
Definition: usb.h:690
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:844
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
int register_netdev(struct net_device *netdev)
Register network device.
Definition: netdevice.c:667
A network device.
Definition: netdevice.h:348
struct usb_endpoint in
Bulk IN endpoint.
Definition: usbnet.h:29
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:511
struct device * dev
Underlying hardware device.
Definition: netdevice.h:360
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition: ethernet.c:264
static int lan78xx_reset(struct smscusb_device *smscusb)
Reset device.
Definition: lan78xx.c:124
int usbnet_describe(struct usbnet_device *usbnet, struct usb_configuration_descriptor *config)
Describe USB network device interfaces.
Definition: usbnet.c:277
static struct net_device_operations lan78xx_operations
LAN78xx network device operations.
Definition: lan78xx.c:297
struct device dev
Generic device.
Definition: usb.h:665
#define LAN78XX_MII_PHY_INTR_SOURCE
PHY interrupt source MII register.
Definition: lan78xx.h:80
void * memset(void *dest, int character, size_t len) __nonnull

References alloc_etherdev(), DBGC, net_device::dev, usb_function::dev, ENOMEM, usbnet_device::in, lan78xx_fetch_mac(), LAN78XX_MII_BASE, LAN78XX_MII_PHY_INTR_SOURCE, lan78xx_operations, lan78xx_reset(), memset(), usb_function::name, netdev, netdev_init(), netdev_nullify(), netdev_put(), net_device::priv, rc, register_netdev(), SMSC75XX_IN_MAX_FILL, SMSC75XX_IN_MTU, smsc75xx_in_operations, smscusb_init(), smscusb_mii_init(), strerror(), unregister_netdev(), usb_func_set_drvdata(), usb_refill_init(), smscusb_device::usbnet, and usbnet_describe().

◆ lan78xx_remove()

static void lan78xx_remove ( struct usb_function func)
static

Remove device.

Parameters
funcUSB function

Definition at line 379 of file lan78xx.c.

379  {
380  struct net_device *netdev = usb_func_get_drvdata ( func );
381 
384  netdev_put ( netdev );
385 }
static void * usb_func_get_drvdata(struct usb_function *func)
Get USB function driver private data.
Definition: usb.h:701
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition: netdevice.h:555
static struct net_device * netdev
Definition: gdbudp.c:52
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition: netdevice.c:844
A network device.
Definition: netdevice.h:348
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition: netdevice.h:511

References netdev, netdev_nullify(), netdev_put(), unregister_netdev(), and usb_func_get_drvdata().

Variable Documentation

◆ lan78xx_operations

struct net_device_operations lan78xx_operations
static
Initial value:
= {
.open = lan78xx_open,
.close = lan78xx_close,
.transmit = smsc75xx_transmit,
.poll = smsc75xx_poll,
}
int smsc75xx_transmit(struct net_device *netdev, struct io_buffer *iobuf)
Transmit packet.
Definition: smsc75xx.c:403
static int lan78xx_open(struct net_device *netdev)
Open network device.
Definition: lan78xx.c:166
void smsc75xx_poll(struct net_device *netdev)
Poll for completed and received packets.
Definition: smsc75xx.c:419
static void lan78xx_close(struct net_device *netdev)
Close network device.
Definition: lan78xx.c:282

LAN78xx network device operations.

Definition at line 297 of file lan78xx.c.

Referenced by lan78xx_probe().

◆ lan78xx_ids

struct usb_device_id lan78xx_ids[]
static
Initial value:
= {
{
.name = "lan7800",
.vendor = 0x0424,
.product = 0x7800,
},
{
.name = "lan7850",
.vendor = 0x0424,
.product = 0x7850,
},
}

LAN78xx device IDs.

Definition at line 388 of file lan78xx.c.

◆ __usb_driver

struct usb_driver lan78xx_driver __usb_driver
Initial value:
= {
.ids = lan78xx_ids,
.id_count = ( sizeof ( lan78xx_ids ) / sizeof ( lan78xx_ids[0] ) ),
.class = USB_CLASS_ID ( 0xff, 0x00, 0xff ),
.score = USB_SCORE_NORMAL,
.probe = lan78xx_probe,
.remove = lan78xx_remove,
}
static int lan78xx_probe(struct usb_function *func, struct usb_configuration_descriptor *config)
Probe device.
Definition: lan78xx.c:318
static void lan78xx_remove(struct usb_function *func)
Remove device.
Definition: lan78xx.c:379
static struct usb_device_id lan78xx_ids[]
LAN78xx device IDs.
Definition: lan78xx.c:388
#define USB_CLASS_ID(base, subclass, protocol)
Construct USB class ID.
Definition: usb.h:1345
Normal driver.
Definition: usb.h:1406

LAN78xx driver.

Definition at line 402 of file lan78xx.c.