linux/drivers/net/usb/mcs7830.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * MOSCHIP MCS7830 based (7730/7830/7832) USB 2.0 Ethernet Devices
 *
 * based on usbnet.c, asix.c and the vendor provided mcs7830 driver
 *
 * Copyright (C) 2010 Andreas Mohr <[email protected]>
 * Copyright (C) 2006 Arnd Bergmann <[email protected]>
 * Copyright (C) 2003-2005 David Hollis <[email protected]>
 * Copyright (C) 2005 Phil Chang <[email protected]>
 * Copyright (c) 2002-2003 TiVo Inc.
 *
 * Definitions gathered from MOSCHIP, Data Sheet_7830DA.pdf (thanks!).
 *
 * 2010-12-19: add 7832 USB PID ("functionality same as MCS7830"),
 *             per active notification by manufacturer
 *
 * TODO:
 * - support HIF_REG_CONFIG_SLEEPMODE/HIF_REG_CONFIG_TXENABLE (via autopm?)
 * - implement ethtool_ops get_pauseparam/set_pauseparam
 *   via HIF_REG_PAUSE_THRESHOLD (>= revision C only!)
 * - implement get_eeprom/[set_eeprom]
 * - switch PHY on/off on ifup/ifdown (perhaps in usbnet.c, via MII)
 * - mcs7830_get_regs() handling is weird: for rev 2 we return 32 regs,
 *   can access only ~ 24, remaining user buffer is uninitialized garbage
 * - anything else?
 */

#include <linux/crc32.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/mii.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/slab.h>
#include <linux/usb.h>
#include <linux/usb/usbnet.h>

/* requests */
#define MCS7830_RD_BMREQ
#define MCS7830_WR_BMREQ
#define MCS7830_RD_BREQ
#define MCS7830_WR_BREQ

#define MCS7830_CTRL_TIMEOUT
#define MCS7830_MAX_MCAST

#define MCS7830_VENDOR_ID
#define MCS7832_PRODUCT_ID
#define MCS7830_PRODUCT_ID
#define MCS7730_PRODUCT_ID

#define SITECOM_VENDOR_ID
#define LN_030_PRODUCT_ID

#define MCS7830_MII_ADVERTISE

/* HIF_REG_XX corresponding index value */
enum {};

/* Trailing status byte in Ethernet Rx frame */
enum {};

struct mcs7830_data {};

static const char driver_name[] =;

static int mcs7830_get_reg(struct usbnet *dev, u16 index, u16 size, void *data)
{}

static int mcs7830_set_reg(struct usbnet *dev, u16 index, u16 size, const void *data)
{}

static void mcs7830_set_reg_async(struct usbnet *dev, u16 index, u16 size, void *data)
{}

static int mcs7830_hif_get_mac_address(struct usbnet *dev, unsigned char *addr)
{}

static int mcs7830_hif_set_mac_address(struct usbnet *dev,
				       const unsigned char *addr)
{}

static int mcs7830_set_mac_address(struct net_device *netdev, void *p)
{}

static int mcs7830_read_phy(struct usbnet *dev, u8 index)
{}

static int mcs7830_write_phy(struct usbnet *dev, u8 index, u16 val)
{}

/*
 * This algorithm comes from the original mcs7830 version 1.4 driver,
 * not sure if it is needed.
 */
static int mcs7830_set_autoneg(struct usbnet *dev, int ptrUserPhyMode)
{}


/*
 * if we can read register 22, the chip revision is C or higher
 */
static int mcs7830_get_rev(struct usbnet *dev)
{}

/*
 * On rev. C we need to set the pause threshold
 */
static void mcs7830_rev_C_fixup(struct usbnet *dev)
{}

static int mcs7830_mdio_read(struct net_device *netdev, int phy_id,
			     int location)
{}

static void mcs7830_mdio_write(struct net_device *netdev, int phy_id,
				int location, int val)
{}

static int mcs7830_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
{}

static inline struct mcs7830_data *mcs7830_get_data(struct usbnet *dev)
{}

static void mcs7830_hif_update_multicast_hash(struct usbnet *dev)
{}

static void mcs7830_hif_update_config(struct usbnet *dev)
{}

static void mcs7830_data_set_multicast(struct net_device *net)
{}

static int mcs7830_apply_base_config(struct usbnet *dev)
{}

/* credits go to asix_set_multicast */
static void mcs7830_set_multicast(struct net_device *net)
{}

static int mcs7830_get_regs_len(struct net_device *net)
{}

static void mcs7830_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *drvinfo)
{}

static void mcs7830_get_regs(struct net_device *net, struct ethtool_regs *regs, void *data)
{}

static const struct ethtool_ops mcs7830_ethtool_ops =;

static const struct net_device_ops mcs7830_netdev_ops =;

static int mcs7830_bind(struct usbnet *dev, struct usb_interface *udev)
{}

/* The chip always appends a status byte that we need to strip */
static int mcs7830_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
{}

static void mcs7830_status(struct usbnet *dev, struct urb *urb)
{}

static const struct driver_info moschip_info =;

static const struct driver_info sitecom_info =;

static const struct usb_device_id products[] =;
MODULE_DEVICE_TABLE(usb, products);

static int mcs7830_reset_resume (struct usb_interface *intf)
{}

static struct usb_driver mcs7830_driver =;

module_usb_driver();

MODULE_DESCRIPTION();
MODULE_LICENSE();