162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/* Aquantia Corp. Aquantia AQtion USB to 5GbE Controller
362306a36Sopenharmony_ci * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
462306a36Sopenharmony_ci * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net>
562306a36Sopenharmony_ci * Copyright (C) 2002-2003 TiVo Inc.
662306a36Sopenharmony_ci * Copyright (C) 2017-2018 ASIX
762306a36Sopenharmony_ci * Copyright (C) 2018 Aquantia Corp.
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifndef __LINUX_USBNET_AQC111_H
1162306a36Sopenharmony_ci#define __LINUX_USBNET_AQC111_H
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#define URB_SIZE	(1024 * 62)
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define AQ_MCAST_FILTER_SIZE		8
1662306a36Sopenharmony_ci#define AQ_MAX_MCAST			64
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#define AQ_ACCESS_MAC			0x01
1962306a36Sopenharmony_ci#define AQ_FLASH_PARAMETERS		0x20
2062306a36Sopenharmony_ci#define AQ_PHY_POWER			0x31
2162306a36Sopenharmony_ci#define AQ_WOL_CFG			0x60
2262306a36Sopenharmony_ci#define AQ_PHY_OPS			0x61
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#define AQ_USB_PHY_SET_TIMEOUT		10000
2562306a36Sopenharmony_ci#define AQ_USB_SET_TIMEOUT		4000
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci/* Feature. ********************************************/
2862306a36Sopenharmony_ci#define AQ_SUPPORT_FEATURE	(NETIF_F_SG | NETIF_F_IP_CSUM |\
2962306a36Sopenharmony_ci				 NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |\
3062306a36Sopenharmony_ci				 NETIF_F_TSO | NETIF_F_HW_VLAN_CTAG_TX |\
3162306a36Sopenharmony_ci				 NETIF_F_HW_VLAN_CTAG_RX)
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#define AQ_SUPPORT_HW_FEATURE	(NETIF_F_SG | NETIF_F_IP_CSUM |\
3462306a36Sopenharmony_ci				 NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |\
3562306a36Sopenharmony_ci				 NETIF_F_TSO | NETIF_F_HW_VLAN_CTAG_FILTER)
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#define AQ_SUPPORT_VLAN_FEATURE (NETIF_F_SG | NETIF_F_IP_CSUM |\
3862306a36Sopenharmony_ci				 NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |\
3962306a36Sopenharmony_ci				 NETIF_F_TSO)
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci/* SFR Reg. ********************************************/
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#define SFR_GENERAL_STATUS		0x03
4462306a36Sopenharmony_ci#define SFR_CHIP_STATUS			0x05
4562306a36Sopenharmony_ci#define SFR_RX_CTL			0x0B
4662306a36Sopenharmony_ci	#define SFR_RX_CTL_TXPADCRC		0x0400
4762306a36Sopenharmony_ci	#define SFR_RX_CTL_IPE			0x0200
4862306a36Sopenharmony_ci	#define SFR_RX_CTL_DROPCRCERR		0x0100
4962306a36Sopenharmony_ci	#define SFR_RX_CTL_START		0x0080
5062306a36Sopenharmony_ci	#define SFR_RX_CTL_RF_WAK		0x0040
5162306a36Sopenharmony_ci	#define SFR_RX_CTL_AP			0x0020
5262306a36Sopenharmony_ci	#define SFR_RX_CTL_AM			0x0010
5362306a36Sopenharmony_ci	#define SFR_RX_CTL_AB			0x0008
5462306a36Sopenharmony_ci	#define SFR_RX_CTL_AMALL		0x0002
5562306a36Sopenharmony_ci	#define SFR_RX_CTL_PRO			0x0001
5662306a36Sopenharmony_ci	#define SFR_RX_CTL_STOP			0x0000
5762306a36Sopenharmony_ci#define SFR_INTER_PACKET_GAP_0		0x0D
5862306a36Sopenharmony_ci#define SFR_NODE_ID			0x10
5962306a36Sopenharmony_ci#define SFR_MULTI_FILTER_ARRY		0x16
6062306a36Sopenharmony_ci#define SFR_MEDIUM_STATUS_MODE		0x22
6162306a36Sopenharmony_ci	#define SFR_MEDIUM_XGMIIMODE		0x0001
6262306a36Sopenharmony_ci	#define SFR_MEDIUM_FULL_DUPLEX		0x0002
6362306a36Sopenharmony_ci	#define SFR_MEDIUM_RXFLOW_CTRLEN	0x0010
6462306a36Sopenharmony_ci	#define SFR_MEDIUM_TXFLOW_CTRLEN	0x0020
6562306a36Sopenharmony_ci	#define SFR_MEDIUM_JUMBO_EN		0x0040
6662306a36Sopenharmony_ci	#define SFR_MEDIUM_RECEIVE_EN		0x0100
6762306a36Sopenharmony_ci#define SFR_MONITOR_MODE		0x24
6862306a36Sopenharmony_ci	#define SFR_MONITOR_MODE_EPHYRW		0x01
6962306a36Sopenharmony_ci	#define SFR_MONITOR_MODE_RWLC		0x02
7062306a36Sopenharmony_ci	#define SFR_MONITOR_MODE_RWMP		0x04
7162306a36Sopenharmony_ci	#define SFR_MONITOR_MODE_RWWF		0x08
7262306a36Sopenharmony_ci	#define SFR_MONITOR_MODE_RW_FLAG	0x10
7362306a36Sopenharmony_ci	#define SFR_MONITOR_MODE_PMEPOL		0x20
7462306a36Sopenharmony_ci	#define SFR_MONITOR_MODE_PMETYPE	0x40
7562306a36Sopenharmony_ci#define SFR_PHYPWR_RSTCTL		0x26
7662306a36Sopenharmony_ci	#define SFR_PHYPWR_RSTCTL_BZ		0x0010
7762306a36Sopenharmony_ci	#define SFR_PHYPWR_RSTCTL_IPRL		0x0020
7862306a36Sopenharmony_ci#define SFR_VLAN_ID_ADDRESS		0x2A
7962306a36Sopenharmony_ci#define SFR_VLAN_ID_CONTROL		0x2B
8062306a36Sopenharmony_ci	#define SFR_VLAN_CONTROL_WE		0x0001
8162306a36Sopenharmony_ci	#define SFR_VLAN_CONTROL_RD		0x0002
8262306a36Sopenharmony_ci	#define SFR_VLAN_CONTROL_VSO		0x0010
8362306a36Sopenharmony_ci	#define SFR_VLAN_CONTROL_VFE		0x0020
8462306a36Sopenharmony_ci#define SFR_VLAN_ID_DATA0		0x2C
8562306a36Sopenharmony_ci#define SFR_VLAN_ID_DATA1		0x2D
8662306a36Sopenharmony_ci#define SFR_RX_BULKIN_QCTRL		0x2E
8762306a36Sopenharmony_ci	#define SFR_RX_BULKIN_QCTRL_TIME	0x01
8862306a36Sopenharmony_ci	#define SFR_RX_BULKIN_QCTRL_IFG		0x02
8962306a36Sopenharmony_ci	#define SFR_RX_BULKIN_QCTRL_SIZE	0x04
9062306a36Sopenharmony_ci#define SFR_RX_BULKIN_QTIMR_LOW		0x2F
9162306a36Sopenharmony_ci#define SFR_RX_BULKIN_QTIMR_HIGH	0x30
9262306a36Sopenharmony_ci#define SFR_RX_BULKIN_QSIZE		0x31
9362306a36Sopenharmony_ci#define SFR_RX_BULKIN_QIFG		0x32
9462306a36Sopenharmony_ci#define SFR_RXCOE_CTL			0x34
9562306a36Sopenharmony_ci	#define SFR_RXCOE_IP			0x01
9662306a36Sopenharmony_ci	#define SFR_RXCOE_TCP			0x02
9762306a36Sopenharmony_ci	#define SFR_RXCOE_UDP			0x04
9862306a36Sopenharmony_ci	#define SFR_RXCOE_ICMP			0x08
9962306a36Sopenharmony_ci	#define SFR_RXCOE_IGMP			0x10
10062306a36Sopenharmony_ci	#define SFR_RXCOE_TCPV6			0x20
10162306a36Sopenharmony_ci	#define SFR_RXCOE_UDPV6			0x40
10262306a36Sopenharmony_ci	#define SFR_RXCOE_ICMV6			0x80
10362306a36Sopenharmony_ci#define SFR_TXCOE_CTL			0x35
10462306a36Sopenharmony_ci	#define SFR_TXCOE_IP			0x01
10562306a36Sopenharmony_ci	#define SFR_TXCOE_TCP			0x02
10662306a36Sopenharmony_ci	#define SFR_TXCOE_UDP			0x04
10762306a36Sopenharmony_ci	#define SFR_TXCOE_ICMP			0x08
10862306a36Sopenharmony_ci	#define SFR_TXCOE_IGMP			0x10
10962306a36Sopenharmony_ci	#define SFR_TXCOE_TCPV6			0x20
11062306a36Sopenharmony_ci	#define SFR_TXCOE_UDPV6			0x40
11162306a36Sopenharmony_ci	#define SFR_TXCOE_ICMV6			0x80
11262306a36Sopenharmony_ci#define SFR_BM_INT_MASK			0x41
11362306a36Sopenharmony_ci#define SFR_BMRX_DMA_CONTROL		0x43
11462306a36Sopenharmony_ci	#define SFR_BMRX_DMA_EN			0x80
11562306a36Sopenharmony_ci#define SFR_BMTX_DMA_CONTROL		0x46
11662306a36Sopenharmony_ci#define SFR_PAUSE_WATERLVL_LOW		0x54
11762306a36Sopenharmony_ci#define SFR_PAUSE_WATERLVL_HIGH		0x55
11862306a36Sopenharmony_ci#define SFR_ARC_CTRL			0x9E
11962306a36Sopenharmony_ci#define SFR_SWP_CTRL			0xB1
12062306a36Sopenharmony_ci#define SFR_TX_PAUSE_RESEND_T		0xB2
12162306a36Sopenharmony_ci#define SFR_ETH_MAC_PATH		0xB7
12262306a36Sopenharmony_ci	#define SFR_RX_PATH_READY		0x01
12362306a36Sopenharmony_ci#define SFR_BULK_OUT_CTRL		0xB9
12462306a36Sopenharmony_ci	#define SFR_BULK_OUT_FLUSH_EN		0x01
12562306a36Sopenharmony_ci	#define SFR_BULK_OUT_EFF_EN		0x02
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci#define AQ_FW_VER_MAJOR			0xDA
12862306a36Sopenharmony_ci#define AQ_FW_VER_MINOR			0xDB
12962306a36Sopenharmony_ci#define AQ_FW_VER_REV			0xDC
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ci/*PHY_OPS**********************************************************************/
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ci#define AQ_ADV_100M	BIT(0)
13462306a36Sopenharmony_ci#define AQ_ADV_1G	BIT(1)
13562306a36Sopenharmony_ci#define AQ_ADV_2G5	BIT(2)
13662306a36Sopenharmony_ci#define AQ_ADV_5G	BIT(3)
13762306a36Sopenharmony_ci#define AQ_ADV_MASK	0x0F
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci#define AQ_PAUSE	BIT(16)
14062306a36Sopenharmony_ci#define AQ_ASYM_PAUSE	BIT(17)
14162306a36Sopenharmony_ci#define AQ_LOW_POWER	BIT(18)
14262306a36Sopenharmony_ci#define AQ_PHY_POWER_EN	BIT(19)
14362306a36Sopenharmony_ci#define AQ_WOL		BIT(20)
14462306a36Sopenharmony_ci#define AQ_DOWNSHIFT	BIT(21)
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci#define AQ_DSH_RETRIES_SHIFT	0x18
14762306a36Sopenharmony_ci#define AQ_DSH_RETRIES_MASK	0xF000000
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci#define AQ_WOL_FLAG_MP			0x2
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci/******************************************************************************/
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_cistruct aqc111_wol_cfg {
15462306a36Sopenharmony_ci	u8 hw_addr[6];
15562306a36Sopenharmony_ci	u8 flags;
15662306a36Sopenharmony_ci	u8 rsvd[283];
15762306a36Sopenharmony_ci} __packed;
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci#define WOL_CFG_SIZE sizeof(struct aqc111_wol_cfg)
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_cistruct aqc111_data {
16262306a36Sopenharmony_ci	u16 rxctl;
16362306a36Sopenharmony_ci	u8 rx_checksum;
16462306a36Sopenharmony_ci	u8 link_speed;
16562306a36Sopenharmony_ci	u8 link;
16662306a36Sopenharmony_ci	u8 autoneg;
16762306a36Sopenharmony_ci	u32 advertised_speed;
16862306a36Sopenharmony_ci	struct {
16962306a36Sopenharmony_ci		u8 major;
17062306a36Sopenharmony_ci		u8 minor;
17162306a36Sopenharmony_ci		u8 rev;
17262306a36Sopenharmony_ci	} fw_ver;
17362306a36Sopenharmony_ci	u32 phy_cfg;
17462306a36Sopenharmony_ci	u8 wol_flags;
17562306a36Sopenharmony_ci};
17662306a36Sopenharmony_ci
17762306a36Sopenharmony_ci#define AQ_LS_MASK		0x8000
17862306a36Sopenharmony_ci#define AQ_SPEED_MASK		0x7F00
17962306a36Sopenharmony_ci#define AQ_SPEED_SHIFT		0x0008
18062306a36Sopenharmony_ci#define AQ_INT_SPEED_5G		0x000F
18162306a36Sopenharmony_ci#define AQ_INT_SPEED_2_5G	0x0010
18262306a36Sopenharmony_ci#define AQ_INT_SPEED_1G		0x0011
18362306a36Sopenharmony_ci#define AQ_INT_SPEED_100M	0x0013
18462306a36Sopenharmony_ci
18562306a36Sopenharmony_ci/* TX Descriptor */
18662306a36Sopenharmony_ci#define AQ_TX_DESC_LEN_MASK	0x1FFFFF
18762306a36Sopenharmony_ci#define AQ_TX_DESC_DROP_PADD	BIT(28)
18862306a36Sopenharmony_ci#define AQ_TX_DESC_VLAN		BIT(29)
18962306a36Sopenharmony_ci#define AQ_TX_DESC_MSS_MASK	0x7FFF
19062306a36Sopenharmony_ci#define AQ_TX_DESC_MSS_SHIFT	0x20
19162306a36Sopenharmony_ci#define AQ_TX_DESC_VLAN_MASK	0xFFFF
19262306a36Sopenharmony_ci#define AQ_TX_DESC_VLAN_SHIFT	0x30
19362306a36Sopenharmony_ci
19462306a36Sopenharmony_ci#define AQ_RX_HW_PAD			0x02
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_ci/* RX Packet Descriptor */
19762306a36Sopenharmony_ci#define AQ_RX_PD_L4_ERR		BIT(0)
19862306a36Sopenharmony_ci#define AQ_RX_PD_L3_ERR		BIT(1)
19962306a36Sopenharmony_ci#define AQ_RX_PD_L4_TYPE_MASK	0x1C
20062306a36Sopenharmony_ci#define AQ_RX_PD_L4_UDP		0x04
20162306a36Sopenharmony_ci#define AQ_RX_PD_L4_TCP		0x10
20262306a36Sopenharmony_ci#define AQ_RX_PD_L3_TYPE_MASK	0x60
20362306a36Sopenharmony_ci#define AQ_RX_PD_L3_IP		0x20
20462306a36Sopenharmony_ci#define AQ_RX_PD_L3_IP6		0x40
20562306a36Sopenharmony_ci
20662306a36Sopenharmony_ci#define AQ_RX_PD_VLAN		BIT(10)
20762306a36Sopenharmony_ci#define AQ_RX_PD_RX_OK		BIT(11)
20862306a36Sopenharmony_ci#define AQ_RX_PD_DROP		BIT(31)
20962306a36Sopenharmony_ci#define AQ_RX_PD_LEN_MASK	0x7FFF0000
21062306a36Sopenharmony_ci#define AQ_RX_PD_LEN_SHIFT	0x10
21162306a36Sopenharmony_ci#define AQ_RX_PD_VLAN_SHIFT	0x20
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_ci/* RX Descriptor header */
21462306a36Sopenharmony_ci#define AQ_RX_DH_PKT_CNT_MASK		0x1FFF
21562306a36Sopenharmony_ci#define AQ_RX_DH_DESC_OFFSET_MASK	0xFFFFE000
21662306a36Sopenharmony_ci#define AQ_RX_DH_DESC_OFFSET_SHIFT	0x0D
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_cistatic struct {
21962306a36Sopenharmony_ci	unsigned char ctrl;
22062306a36Sopenharmony_ci	unsigned char timer_l;
22162306a36Sopenharmony_ci	unsigned char timer_h;
22262306a36Sopenharmony_ci	unsigned char size;
22362306a36Sopenharmony_ci	unsigned char ifg;
22462306a36Sopenharmony_ci} AQC111_BULKIN_SIZE[] = {
22562306a36Sopenharmony_ci	/* xHCI & EHCI & OHCI */
22662306a36Sopenharmony_ci	{7, 0x00, 0x01, 0x1E, 0xFF},/* 10G, 5G, 2.5G, 1G */
22762306a36Sopenharmony_ci	{7, 0xA0, 0x00, 0x14, 0x00},/* 100M */
22862306a36Sopenharmony_ci	/* Jumbo packet */
22962306a36Sopenharmony_ci	{7, 0x00, 0x01, 0x18, 0xFF},
23062306a36Sopenharmony_ci};
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ci#endif /* __LINUX_USBNET_AQC111_H */
233