18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* Aquantia Corp. Aquantia AQtion USB to 5GbE Controller 38c2ecf20Sopenharmony_ci * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com> 48c2ecf20Sopenharmony_ci * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net> 58c2ecf20Sopenharmony_ci * Copyright (C) 2002-2003 TiVo Inc. 68c2ecf20Sopenharmony_ci * Copyright (C) 2017-2018 ASIX 78c2ecf20Sopenharmony_ci * Copyright (C) 2018 Aquantia Corp. 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef __LINUX_USBNET_AQC111_H 118c2ecf20Sopenharmony_ci#define __LINUX_USBNET_AQC111_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#define URB_SIZE (1024 * 62) 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define AQ_MCAST_FILTER_SIZE 8 168c2ecf20Sopenharmony_ci#define AQ_MAX_MCAST 64 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define AQ_ACCESS_MAC 0x01 198c2ecf20Sopenharmony_ci#define AQ_FLASH_PARAMETERS 0x20 208c2ecf20Sopenharmony_ci#define AQ_PHY_POWER 0x31 218c2ecf20Sopenharmony_ci#define AQ_WOL_CFG 0x60 228c2ecf20Sopenharmony_ci#define AQ_PHY_OPS 0x61 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#define AQ_USB_PHY_SET_TIMEOUT 10000 258c2ecf20Sopenharmony_ci#define AQ_USB_SET_TIMEOUT 4000 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* Feature. ********************************************/ 288c2ecf20Sopenharmony_ci#define AQ_SUPPORT_FEATURE (NETIF_F_SG | NETIF_F_IP_CSUM |\ 298c2ecf20Sopenharmony_ci NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |\ 308c2ecf20Sopenharmony_ci NETIF_F_TSO | NETIF_F_HW_VLAN_CTAG_TX |\ 318c2ecf20Sopenharmony_ci NETIF_F_HW_VLAN_CTAG_RX) 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define AQ_SUPPORT_HW_FEATURE (NETIF_F_SG | NETIF_F_IP_CSUM |\ 348c2ecf20Sopenharmony_ci NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |\ 358c2ecf20Sopenharmony_ci NETIF_F_TSO | NETIF_F_HW_VLAN_CTAG_FILTER) 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define AQ_SUPPORT_VLAN_FEATURE (NETIF_F_SG | NETIF_F_IP_CSUM |\ 388c2ecf20Sopenharmony_ci NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |\ 398c2ecf20Sopenharmony_ci NETIF_F_TSO) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/* SFR Reg. ********************************************/ 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#define SFR_GENERAL_STATUS 0x03 448c2ecf20Sopenharmony_ci#define SFR_CHIP_STATUS 0x05 458c2ecf20Sopenharmony_ci#define SFR_RX_CTL 0x0B 468c2ecf20Sopenharmony_ci #define SFR_RX_CTL_TXPADCRC 0x0400 478c2ecf20Sopenharmony_ci #define SFR_RX_CTL_IPE 0x0200 488c2ecf20Sopenharmony_ci #define SFR_RX_CTL_DROPCRCERR 0x0100 498c2ecf20Sopenharmony_ci #define SFR_RX_CTL_START 0x0080 508c2ecf20Sopenharmony_ci #define SFR_RX_CTL_RF_WAK 0x0040 518c2ecf20Sopenharmony_ci #define SFR_RX_CTL_AP 0x0020 528c2ecf20Sopenharmony_ci #define SFR_RX_CTL_AM 0x0010 538c2ecf20Sopenharmony_ci #define SFR_RX_CTL_AB 0x0008 548c2ecf20Sopenharmony_ci #define SFR_RX_CTL_AMALL 0x0002 558c2ecf20Sopenharmony_ci #define SFR_RX_CTL_PRO 0x0001 568c2ecf20Sopenharmony_ci #define SFR_RX_CTL_STOP 0x0000 578c2ecf20Sopenharmony_ci#define SFR_INTER_PACKET_GAP_0 0x0D 588c2ecf20Sopenharmony_ci#define SFR_NODE_ID 0x10 598c2ecf20Sopenharmony_ci#define SFR_MULTI_FILTER_ARRY 0x16 608c2ecf20Sopenharmony_ci#define SFR_MEDIUM_STATUS_MODE 0x22 618c2ecf20Sopenharmony_ci #define SFR_MEDIUM_XGMIIMODE 0x0001 628c2ecf20Sopenharmony_ci #define SFR_MEDIUM_FULL_DUPLEX 0x0002 638c2ecf20Sopenharmony_ci #define SFR_MEDIUM_RXFLOW_CTRLEN 0x0010 648c2ecf20Sopenharmony_ci #define SFR_MEDIUM_TXFLOW_CTRLEN 0x0020 658c2ecf20Sopenharmony_ci #define SFR_MEDIUM_JUMBO_EN 0x0040 668c2ecf20Sopenharmony_ci #define SFR_MEDIUM_RECEIVE_EN 0x0100 678c2ecf20Sopenharmony_ci#define SFR_MONITOR_MODE 0x24 688c2ecf20Sopenharmony_ci #define SFR_MONITOR_MODE_EPHYRW 0x01 698c2ecf20Sopenharmony_ci #define SFR_MONITOR_MODE_RWLC 0x02 708c2ecf20Sopenharmony_ci #define SFR_MONITOR_MODE_RWMP 0x04 718c2ecf20Sopenharmony_ci #define SFR_MONITOR_MODE_RWWF 0x08 728c2ecf20Sopenharmony_ci #define SFR_MONITOR_MODE_RW_FLAG 0x10 738c2ecf20Sopenharmony_ci #define SFR_MONITOR_MODE_PMEPOL 0x20 748c2ecf20Sopenharmony_ci #define SFR_MONITOR_MODE_PMETYPE 0x40 758c2ecf20Sopenharmony_ci#define SFR_PHYPWR_RSTCTL 0x26 768c2ecf20Sopenharmony_ci #define SFR_PHYPWR_RSTCTL_BZ 0x0010 778c2ecf20Sopenharmony_ci #define SFR_PHYPWR_RSTCTL_IPRL 0x0020 788c2ecf20Sopenharmony_ci#define SFR_VLAN_ID_ADDRESS 0x2A 798c2ecf20Sopenharmony_ci#define SFR_VLAN_ID_CONTROL 0x2B 808c2ecf20Sopenharmony_ci #define SFR_VLAN_CONTROL_WE 0x0001 818c2ecf20Sopenharmony_ci #define SFR_VLAN_CONTROL_RD 0x0002 828c2ecf20Sopenharmony_ci #define SFR_VLAN_CONTROL_VSO 0x0010 838c2ecf20Sopenharmony_ci #define SFR_VLAN_CONTROL_VFE 0x0020 848c2ecf20Sopenharmony_ci#define SFR_VLAN_ID_DATA0 0x2C 858c2ecf20Sopenharmony_ci#define SFR_VLAN_ID_DATA1 0x2D 868c2ecf20Sopenharmony_ci#define SFR_RX_BULKIN_QCTRL 0x2E 878c2ecf20Sopenharmony_ci #define SFR_RX_BULKIN_QCTRL_TIME 0x01 888c2ecf20Sopenharmony_ci #define SFR_RX_BULKIN_QCTRL_IFG 0x02 898c2ecf20Sopenharmony_ci #define SFR_RX_BULKIN_QCTRL_SIZE 0x04 908c2ecf20Sopenharmony_ci#define SFR_RX_BULKIN_QTIMR_LOW 0x2F 918c2ecf20Sopenharmony_ci#define SFR_RX_BULKIN_QTIMR_HIGH 0x30 928c2ecf20Sopenharmony_ci#define SFR_RX_BULKIN_QSIZE 0x31 938c2ecf20Sopenharmony_ci#define SFR_RX_BULKIN_QIFG 0x32 948c2ecf20Sopenharmony_ci#define SFR_RXCOE_CTL 0x34 958c2ecf20Sopenharmony_ci #define SFR_RXCOE_IP 0x01 968c2ecf20Sopenharmony_ci #define SFR_RXCOE_TCP 0x02 978c2ecf20Sopenharmony_ci #define SFR_RXCOE_UDP 0x04 988c2ecf20Sopenharmony_ci #define SFR_RXCOE_ICMP 0x08 998c2ecf20Sopenharmony_ci #define SFR_RXCOE_IGMP 0x10 1008c2ecf20Sopenharmony_ci #define SFR_RXCOE_TCPV6 0x20 1018c2ecf20Sopenharmony_ci #define SFR_RXCOE_UDPV6 0x40 1028c2ecf20Sopenharmony_ci #define SFR_RXCOE_ICMV6 0x80 1038c2ecf20Sopenharmony_ci#define SFR_TXCOE_CTL 0x35 1048c2ecf20Sopenharmony_ci #define SFR_TXCOE_IP 0x01 1058c2ecf20Sopenharmony_ci #define SFR_TXCOE_TCP 0x02 1068c2ecf20Sopenharmony_ci #define SFR_TXCOE_UDP 0x04 1078c2ecf20Sopenharmony_ci #define SFR_TXCOE_ICMP 0x08 1088c2ecf20Sopenharmony_ci #define SFR_TXCOE_IGMP 0x10 1098c2ecf20Sopenharmony_ci #define SFR_TXCOE_TCPV6 0x20 1108c2ecf20Sopenharmony_ci #define SFR_TXCOE_UDPV6 0x40 1118c2ecf20Sopenharmony_ci #define SFR_TXCOE_ICMV6 0x80 1128c2ecf20Sopenharmony_ci#define SFR_BM_INT_MASK 0x41 1138c2ecf20Sopenharmony_ci#define SFR_BMRX_DMA_CONTROL 0x43 1148c2ecf20Sopenharmony_ci #define SFR_BMRX_DMA_EN 0x80 1158c2ecf20Sopenharmony_ci#define SFR_BMTX_DMA_CONTROL 0x46 1168c2ecf20Sopenharmony_ci#define SFR_PAUSE_WATERLVL_LOW 0x54 1178c2ecf20Sopenharmony_ci#define SFR_PAUSE_WATERLVL_HIGH 0x55 1188c2ecf20Sopenharmony_ci#define SFR_ARC_CTRL 0x9E 1198c2ecf20Sopenharmony_ci#define SFR_SWP_CTRL 0xB1 1208c2ecf20Sopenharmony_ci#define SFR_TX_PAUSE_RESEND_T 0xB2 1218c2ecf20Sopenharmony_ci#define SFR_ETH_MAC_PATH 0xB7 1228c2ecf20Sopenharmony_ci #define SFR_RX_PATH_READY 0x01 1238c2ecf20Sopenharmony_ci#define SFR_BULK_OUT_CTRL 0xB9 1248c2ecf20Sopenharmony_ci #define SFR_BULK_OUT_FLUSH_EN 0x01 1258c2ecf20Sopenharmony_ci #define SFR_BULK_OUT_EFF_EN 0x02 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci#define AQ_FW_VER_MAJOR 0xDA 1288c2ecf20Sopenharmony_ci#define AQ_FW_VER_MINOR 0xDB 1298c2ecf20Sopenharmony_ci#define AQ_FW_VER_REV 0xDC 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci/*PHY_OPS**********************************************************************/ 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci#define AQ_ADV_100M BIT(0) 1348c2ecf20Sopenharmony_ci#define AQ_ADV_1G BIT(1) 1358c2ecf20Sopenharmony_ci#define AQ_ADV_2G5 BIT(2) 1368c2ecf20Sopenharmony_ci#define AQ_ADV_5G BIT(3) 1378c2ecf20Sopenharmony_ci#define AQ_ADV_MASK 0x0F 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci#define AQ_PAUSE BIT(16) 1408c2ecf20Sopenharmony_ci#define AQ_ASYM_PAUSE BIT(17) 1418c2ecf20Sopenharmony_ci#define AQ_LOW_POWER BIT(18) 1428c2ecf20Sopenharmony_ci#define AQ_PHY_POWER_EN BIT(19) 1438c2ecf20Sopenharmony_ci#define AQ_WOL BIT(20) 1448c2ecf20Sopenharmony_ci#define AQ_DOWNSHIFT BIT(21) 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci#define AQ_DSH_RETRIES_SHIFT 0x18 1478c2ecf20Sopenharmony_ci#define AQ_DSH_RETRIES_MASK 0xF000000 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci#define AQ_WOL_FLAG_MP 0x2 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci/******************************************************************************/ 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_cistruct aqc111_wol_cfg { 1548c2ecf20Sopenharmony_ci u8 hw_addr[6]; 1558c2ecf20Sopenharmony_ci u8 flags; 1568c2ecf20Sopenharmony_ci u8 rsvd[283]; 1578c2ecf20Sopenharmony_ci} __packed; 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci#define WOL_CFG_SIZE sizeof(struct aqc111_wol_cfg) 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_cistruct aqc111_data { 1628c2ecf20Sopenharmony_ci u16 rxctl; 1638c2ecf20Sopenharmony_ci u8 rx_checksum; 1648c2ecf20Sopenharmony_ci u8 link_speed; 1658c2ecf20Sopenharmony_ci u8 link; 1668c2ecf20Sopenharmony_ci u8 autoneg; 1678c2ecf20Sopenharmony_ci u32 advertised_speed; 1688c2ecf20Sopenharmony_ci struct { 1698c2ecf20Sopenharmony_ci u8 major; 1708c2ecf20Sopenharmony_ci u8 minor; 1718c2ecf20Sopenharmony_ci u8 rev; 1728c2ecf20Sopenharmony_ci } fw_ver; 1738c2ecf20Sopenharmony_ci u32 phy_cfg; 1748c2ecf20Sopenharmony_ci u8 wol_flags; 1758c2ecf20Sopenharmony_ci}; 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci#define AQ_LS_MASK 0x8000 1788c2ecf20Sopenharmony_ci#define AQ_SPEED_MASK 0x7F00 1798c2ecf20Sopenharmony_ci#define AQ_SPEED_SHIFT 0x0008 1808c2ecf20Sopenharmony_ci#define AQ_INT_SPEED_5G 0x000F 1818c2ecf20Sopenharmony_ci#define AQ_INT_SPEED_2_5G 0x0010 1828c2ecf20Sopenharmony_ci#define AQ_INT_SPEED_1G 0x0011 1838c2ecf20Sopenharmony_ci#define AQ_INT_SPEED_100M 0x0013 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci/* TX Descriptor */ 1868c2ecf20Sopenharmony_ci#define AQ_TX_DESC_LEN_MASK 0x1FFFFF 1878c2ecf20Sopenharmony_ci#define AQ_TX_DESC_DROP_PADD BIT(28) 1888c2ecf20Sopenharmony_ci#define AQ_TX_DESC_VLAN BIT(29) 1898c2ecf20Sopenharmony_ci#define AQ_TX_DESC_MSS_MASK 0x7FFF 1908c2ecf20Sopenharmony_ci#define AQ_TX_DESC_MSS_SHIFT 0x20 1918c2ecf20Sopenharmony_ci#define AQ_TX_DESC_VLAN_MASK 0xFFFF 1928c2ecf20Sopenharmony_ci#define AQ_TX_DESC_VLAN_SHIFT 0x30 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci#define AQ_RX_HW_PAD 0x02 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci/* RX Packet Descriptor */ 1978c2ecf20Sopenharmony_ci#define AQ_RX_PD_L4_ERR BIT(0) 1988c2ecf20Sopenharmony_ci#define AQ_RX_PD_L3_ERR BIT(1) 1998c2ecf20Sopenharmony_ci#define AQ_RX_PD_L4_TYPE_MASK 0x1C 2008c2ecf20Sopenharmony_ci#define AQ_RX_PD_L4_UDP 0x04 2018c2ecf20Sopenharmony_ci#define AQ_RX_PD_L4_TCP 0x10 2028c2ecf20Sopenharmony_ci#define AQ_RX_PD_L3_TYPE_MASK 0x60 2038c2ecf20Sopenharmony_ci#define AQ_RX_PD_L3_IP 0x20 2048c2ecf20Sopenharmony_ci#define AQ_RX_PD_L3_IP6 0x40 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci#define AQ_RX_PD_VLAN BIT(10) 2078c2ecf20Sopenharmony_ci#define AQ_RX_PD_RX_OK BIT(11) 2088c2ecf20Sopenharmony_ci#define AQ_RX_PD_DROP BIT(31) 2098c2ecf20Sopenharmony_ci#define AQ_RX_PD_LEN_MASK 0x7FFF0000 2108c2ecf20Sopenharmony_ci#define AQ_RX_PD_LEN_SHIFT 0x10 2118c2ecf20Sopenharmony_ci#define AQ_RX_PD_VLAN_SHIFT 0x20 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci/* RX Descriptor header */ 2148c2ecf20Sopenharmony_ci#define AQ_RX_DH_PKT_CNT_MASK 0x1FFF 2158c2ecf20Sopenharmony_ci#define AQ_RX_DH_DESC_OFFSET_MASK 0xFFFFE000 2168c2ecf20Sopenharmony_ci#define AQ_RX_DH_DESC_OFFSET_SHIFT 0x0D 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_cistatic struct { 2198c2ecf20Sopenharmony_ci unsigned char ctrl; 2208c2ecf20Sopenharmony_ci unsigned char timer_l; 2218c2ecf20Sopenharmony_ci unsigned char timer_h; 2228c2ecf20Sopenharmony_ci unsigned char size; 2238c2ecf20Sopenharmony_ci unsigned char ifg; 2248c2ecf20Sopenharmony_ci} AQC111_BULKIN_SIZE[] = { 2258c2ecf20Sopenharmony_ci /* xHCI & EHCI & OHCI */ 2268c2ecf20Sopenharmony_ci {7, 0x00, 0x01, 0x1E, 0xFF},/* 10G, 5G, 2.5G, 1G */ 2278c2ecf20Sopenharmony_ci {7, 0xA0, 0x00, 0x14, 0x00},/* 100M */ 2288c2ecf20Sopenharmony_ci /* Jumbo packet */ 2298c2ecf20Sopenharmony_ci {7, 0x00, 0x01, 0x18, 0xFF}, 2308c2ecf20Sopenharmony_ci}; 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci#endif /* __LINUX_USBNET_AQC111_H */ 233