linux/drivers/net/usb/asix.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * ASIX AX8817X based USB 2.0 Ethernet Devices
 * Copyright (C) 2003-2006 David Hollis <[email protected]>
 * Copyright (C) 2005 Phil Chang <[email protected]>
 * Copyright (C) 2006 James Painter <[email protected]>
 * Copyright (c) 2002-2003 TiVo Inc.
 */

#ifndef _ASIX_H
#define _ASIX_H

// #define	DEBUG			// error path messages, extra info
// #define	VERBOSE			// more; success messages

#include <linux/module.h>
#include <linux/kmod.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/workqueue.h>
#include <linux/mii.h>
#include <linux/usb.h>
#include <linux/crc32.h>
#include <linux/usb/usbnet.h>
#include <linux/slab.h>
#include <linux/if_vlan.h>
#include <linux/phy.h>
#include <net/selftests.h>
#include <linux/phylink.h>

#define DRIVER_VERSION
#define DRIVER_NAME

/* ASIX AX8817X based USB 2.0 Ethernet Devices */

#define AX_CMD_SET_SW_MII
#define AX_CMD_READ_MII_REG
#define AX_CMD_WRITE_MII_REG
#define AX_CMD_STATMNGSTS_REG
#define AX_CMD_SET_HW_MII
#define AX_CMD_READ_EEPROM
#define AX_CMD_WRITE_EEPROM
#define AX_CMD_WRITE_ENABLE
#define AX_CMD_WRITE_DISABLE
#define AX_CMD_READ_RX_CTL
#define AX_CMD_WRITE_RX_CTL
#define AX_CMD_READ_IPG012
#define AX_CMD_WRITE_IPG0
#define AX_CMD_WRITE_IPG1
#define AX_CMD_READ_NODE_ID
#define AX_CMD_WRITE_NODE_ID
#define AX_CMD_WRITE_IPG2
#define AX_CMD_WRITE_MULTI_FILTER
#define AX88172_CMD_READ_NODE_ID
#define AX_CMD_READ_PHY_ID
#define AX_CMD_READ_MEDIUM_STATUS
#define AX_CMD_WRITE_MEDIUM_MODE
#define AX_CMD_READ_MONITOR_MODE
#define AX_CMD_WRITE_MONITOR_MODE
#define AX_CMD_READ_GPIOS
#define AX_CMD_WRITE_GPIOS
#define AX_CMD_SW_RESET
#define AX_CMD_SW_PHY_STATUS
#define AX_CMD_SW_PHY_SELECT
#define AX_QCTCTRL

#define AX_CHIPCODE_MASK
#define AX_AX88772_CHIPCODE
#define AX_AX88772A_CHIPCODE
#define AX_AX88772B_CHIPCODE
#define AX_HOST_EN

#define AX_PHYSEL_PSEL
#define AX_PHYSEL_SSMII
#define AX_PHYSEL_SSEN

#define AX_PHY_SELECT_MASK
#define AX_PHY_SELECT_INTERNAL
#define AX_PHY_SELECT_EXTERNAL

#define AX_MONITOR_MODE
#define AX_MONITOR_LINK
#define AX_MONITOR_MAGIC
#define AX_MONITOR_HSFS

/* AX88172 Medium Status Register values */
#define AX88172_MEDIUM_FD
#define AX88172_MEDIUM_TX
#define AX88172_MEDIUM_FC
#define AX88172_MEDIUM_DEFAULT

#define AX_MCAST_FILTER_SIZE
#define AX_MAX_MCAST

#define AX_SWRESET_CLEAR
#define AX_SWRESET_RR
#define AX_SWRESET_RT
#define AX_SWRESET_PRTE
#define AX_SWRESET_PRL
#define AX_SWRESET_BZ
#define AX_SWRESET_IPRL
#define AX_SWRESET_IPPD

#define AX88772_IPG0_DEFAULT
#define AX88772_IPG1_DEFAULT
#define AX88772_IPG2_DEFAULT

/* AX88772 & AX88178 Medium Mode Register */
#define AX_MEDIUM_PF
#define AX_MEDIUM_JFE
#define AX_MEDIUM_TFC
#define AX_MEDIUM_RFC
#define AX_MEDIUM_ENCK
#define AX_MEDIUM_AC
#define AX_MEDIUM_FD
#define AX_MEDIUM_GM
#define AX_MEDIUM_SM
#define AX_MEDIUM_SBP
#define AX_MEDIUM_PS
#define AX_MEDIUM_RE

#define AX88178_MEDIUM_DEFAULT

#define AX88772_MEDIUM_DEFAULT

/* AX88772 & AX88178 RX_CTL values */
#define AX_RX_CTL_SO
#define AX_RX_CTL_AP
#define AX_RX_CTL_AM
#define AX_RX_CTL_AB
#define AX_RX_CTL_SEP
#define AX_RX_CTL_AMALL
#define AX_RX_CTL_PRO
#define AX_RX_CTL_MFB_2048
#define AX_RX_CTL_MFB_4096
#define AX_RX_CTL_MFB_8192
#define AX_RX_CTL_MFB_16384

#define AX_DEFAULT_RX_CTL

/* GPIO 0 .. 2 toggles */
#define AX_GPIO_GPO0EN
#define AX_GPIO_GPO_0
#define AX_GPIO_GPO1EN
#define AX_GPIO_GPO_1
#define AX_GPIO_GPO2EN
#define AX_GPIO_GPO_2
#define AX_GPIO_RESERVED
#define AX_GPIO_RSE

#define AX_EEPROM_MAGIC
#define AX_EEPROM_LEN

#define AX_EMBD_PHY_ADDR

/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
struct asix_data {};

struct asix_rx_fixup_info {};

struct asix_common_private {};

extern const struct driver_info ax88172a_info;

/* ASIX specific flags */
#define FLAG_EEPROM_MAC

int __must_check asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
			       u16 size, void *data, int in_pm);

int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
		   u16 size, void *data, int in_pm);

void asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value,
			  u16 index, u16 size, void *data);

int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
			   struct asix_rx_fixup_info *rx);
int asix_rx_fixup_common(struct usbnet *dev, struct sk_buff *skb);
void asix_rx_fixup_common_free(struct asix_common_private *dp);

struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
			      gfp_t flags);

int asix_read_phy_addr(struct usbnet *dev, bool internal);

int asix_sw_reset(struct usbnet *dev, u8 flags, int in_pm);

u16 asix_read_rx_ctl(struct usbnet *dev, int in_pm);
int asix_write_rx_ctl(struct usbnet *dev, u16 mode, int in_pm);

u16 asix_read_medium_status(struct usbnet *dev, int in_pm);
int asix_write_medium_mode(struct usbnet *dev, u16 mode, int in_pm);
void asix_adjust_link(struct net_device *netdev);

int asix_write_gpio(struct usbnet *dev, u16 value, int sleep, int in_pm);

void asix_set_multicast(struct net_device *net);

int asix_mdio_read(struct net_device *netdev, int phy_id, int loc);
void asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val);

int asix_mdio_bus_read(struct mii_bus *bus, int phy_id, int regnum);
int asix_mdio_bus_write(struct mii_bus *bus, int phy_id, int regnum, u16 val);

int asix_mdio_read_nopm(struct net_device *netdev, int phy_id, int loc);
void asix_mdio_write_nopm(struct net_device *netdev, int phy_id, int loc,
			  int val);

void asix_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo);
int asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo);

int asix_get_eeprom_len(struct net_device *net);
int asix_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,
		    u8 *data);
int asix_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,
		    u8 *data);

void asix_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info);

int asix_set_mac_address(struct net_device *net, void *p);

#endif /* _ASIX_H */