1*d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2c9b37458SLiu Junliang /* 3c9b37458SLiu Junliang * CoreChip-sz SR9700 one chip USB 1.1 Ethernet Devices 4c9b37458SLiu Junliang * 5c9b37458SLiu Junliang * Author : Liu Junliang <liujunliang_ljl@163.com> 6c9b37458SLiu Junliang */ 7c9b37458SLiu Junliang 8c9b37458SLiu Junliang #ifndef _SR9700_H 9c9b37458SLiu Junliang #define _SR9700_H 10c9b37458SLiu Junliang 11c9b37458SLiu Junliang /* sr9700 spec. register table on Linux platform */ 12c9b37458SLiu Junliang 13c9b37458SLiu Junliang /* Network Control Reg */ 1406b19b1bSChen Gang #define SR_NCR 0x00 15c9b37458SLiu Junliang #define NCR_RST (1 << 0) 16c9b37458SLiu Junliang #define NCR_LBK (3 << 1) 17c9b37458SLiu Junliang #define NCR_FDX (1 << 3) 18c9b37458SLiu Junliang #define NCR_WAKEEN (1 << 6) 19c9b37458SLiu Junliang /* Network Status Reg */ 2006b19b1bSChen Gang #define SR_NSR 0x01 21c9b37458SLiu Junliang #define NSR_RXRDY (1 << 0) 22c9b37458SLiu Junliang #define NSR_RXOV (1 << 1) 23c9b37458SLiu Junliang #define NSR_TX1END (1 << 2) 24c9b37458SLiu Junliang #define NSR_TX2END (1 << 3) 25c9b37458SLiu Junliang #define NSR_TXFULL (1 << 4) 26c9b37458SLiu Junliang #define NSR_WAKEST (1 << 5) 27c9b37458SLiu Junliang #define NSR_LINKST (1 << 6) 28c9b37458SLiu Junliang #define NSR_SPEED (1 << 7) 29c9b37458SLiu Junliang /* Tx Control Reg */ 3006b19b1bSChen Gang #define SR_TCR 0x02 31c9b37458SLiu Junliang #define TCR_CRC_DIS (1 << 1) 32c9b37458SLiu Junliang #define TCR_PAD_DIS (1 << 2) 33c9b37458SLiu Junliang #define TCR_LC_CARE (1 << 3) 34c9b37458SLiu Junliang #define TCR_CRS_CARE (1 << 4) 35c9b37458SLiu Junliang #define TCR_EXCECM (1 << 5) 36c9b37458SLiu Junliang #define TCR_LF_EN (1 << 6) 37c9b37458SLiu Junliang /* Tx Status Reg for Packet Index 1 */ 3806b19b1bSChen Gang #define SR_TSR1 0x03 39c9b37458SLiu Junliang #define TSR1_EC (1 << 2) 40c9b37458SLiu Junliang #define TSR1_COL (1 << 3) 41c9b37458SLiu Junliang #define TSR1_LC (1 << 4) 42c9b37458SLiu Junliang #define TSR1_NC (1 << 5) 43c9b37458SLiu Junliang #define TSR1_LOC (1 << 6) 44c9b37458SLiu Junliang #define TSR1_TLF (1 << 7) 45c9b37458SLiu Junliang /* Tx Status Reg for Packet Index 2 */ 4606b19b1bSChen Gang #define SR_TSR2 0x04 47c9b37458SLiu Junliang #define TSR2_EC (1 << 2) 48c9b37458SLiu Junliang #define TSR2_COL (1 << 3) 49c9b37458SLiu Junliang #define TSR2_LC (1 << 4) 50c9b37458SLiu Junliang #define TSR2_NC (1 << 5) 51c9b37458SLiu Junliang #define TSR2_LOC (1 << 6) 52c9b37458SLiu Junliang #define TSR2_TLF (1 << 7) 53c9b37458SLiu Junliang /* Rx Control Reg*/ 5406b19b1bSChen Gang #define SR_RCR 0x05 55c9b37458SLiu Junliang #define RCR_RXEN (1 << 0) 56c9b37458SLiu Junliang #define RCR_PRMSC (1 << 1) 57c9b37458SLiu Junliang #define RCR_RUNT (1 << 2) 58c9b37458SLiu Junliang #define RCR_ALL (1 << 3) 59c9b37458SLiu Junliang #define RCR_DIS_CRC (1 << 4) 60c9b37458SLiu Junliang #define RCR_DIS_LONG (1 << 5) 61c9b37458SLiu Junliang /* Rx Status Reg */ 6206b19b1bSChen Gang #define SR_RSR 0x06 63c9b37458SLiu Junliang #define RSR_AE (1 << 2) 64c9b37458SLiu Junliang #define RSR_MF (1 << 6) 65c9b37458SLiu Junliang #define RSR_RF (1 << 7) 66c9b37458SLiu Junliang /* Rx Overflow Counter Reg */ 6706b19b1bSChen Gang #define SR_ROCR 0x07 68c9b37458SLiu Junliang #define ROCR_ROC (0x7F << 0) 69c9b37458SLiu Junliang #define ROCR_RXFU (1 << 7) 70c9b37458SLiu Junliang /* Back Pressure Threshold Reg */ 7106b19b1bSChen Gang #define SR_BPTR 0x08 72c9b37458SLiu Junliang #define BPTR_JPT (0x0F << 0) 73c9b37458SLiu Junliang #define BPTR_BPHW (0x0F << 4) 74c9b37458SLiu Junliang /* Flow Control Threshold Reg */ 7506b19b1bSChen Gang #define SR_FCTR 0x09 76c9b37458SLiu Junliang #define FCTR_LWOT (0x0F << 0) 77c9b37458SLiu Junliang #define FCTR_HWOT (0x0F << 4) 78c9b37458SLiu Junliang /* rx/tx Flow Control Reg */ 7906b19b1bSChen Gang #define SR_FCR 0x0A 80c9b37458SLiu Junliang #define FCR_FLCE (1 << 0) 81c9b37458SLiu Junliang #define FCR_BKPA (1 << 4) 82c9b37458SLiu Junliang #define FCR_TXPEN (1 << 5) 83c9b37458SLiu Junliang #define FCR_TXPF (1 << 6) 84c9b37458SLiu Junliang #define FCR_TXP0 (1 << 7) 85c9b37458SLiu Junliang /* Eeprom & Phy Control Reg */ 8606b19b1bSChen Gang #define SR_EPCR 0x0B 87c9b37458SLiu Junliang #define EPCR_ERRE (1 << 0) 88c9b37458SLiu Junliang #define EPCR_ERPRW (1 << 1) 89c9b37458SLiu Junliang #define EPCR_ERPRR (1 << 2) 90c9b37458SLiu Junliang #define EPCR_EPOS (1 << 3) 91c9b37458SLiu Junliang #define EPCR_WEP (1 << 4) 92c9b37458SLiu Junliang /* Eeprom & Phy Address Reg */ 9306b19b1bSChen Gang #define SR_EPAR 0x0C 94c9b37458SLiu Junliang #define EPAR_EROA (0x3F << 0) 95c9b37458SLiu Junliang #define EPAR_PHY_ADR_MASK (0x03 << 6) 96c9b37458SLiu Junliang #define EPAR_PHY_ADR (0x01 << 6) 97c9b37458SLiu Junliang /* Eeprom & Phy Data Reg */ 9806b19b1bSChen Gang #define SR_EPDR 0x0D /* 0x0D ~ 0x0E for Data Reg Low & High */ 99c9b37458SLiu Junliang /* Wakeup Control Reg */ 10006b19b1bSChen Gang #define SR_WCR 0x0F 101c9b37458SLiu Junliang #define WCR_MAGICST (1 << 0) 102c9b37458SLiu Junliang #define WCR_LINKST (1 << 2) 103c9b37458SLiu Junliang #define WCR_MAGICEN (1 << 3) 104c9b37458SLiu Junliang #define WCR_LINKEN (1 << 5) 105c9b37458SLiu Junliang /* Physical Address Reg */ 10606b19b1bSChen Gang #define SR_PAR 0x10 /* 0x10 ~ 0x15 6 bytes for PAR */ 107c9b37458SLiu Junliang /* Multicast Address Reg */ 10806b19b1bSChen Gang #define SR_MAR 0x16 /* 0x16 ~ 0x1D 8 bytes for MAR */ 109c9b37458SLiu Junliang /* 0x1e unused */ 110c9b37458SLiu Junliang /* Phy Reset Reg */ 11106b19b1bSChen Gang #define SR_PRR 0x1F 112c9b37458SLiu Junliang #define PRR_PHY_RST (1 << 0) 113c9b37458SLiu Junliang /* Tx sdram Write Pointer Address Low */ 11406b19b1bSChen Gang #define SR_TWPAL 0x20 115c9b37458SLiu Junliang /* Tx sdram Write Pointer Address High */ 11606b19b1bSChen Gang #define SR_TWPAH 0x21 117c9b37458SLiu Junliang /* Tx sdram Read Pointer Address Low */ 11806b19b1bSChen Gang #define SR_TRPAL 0x22 119c9b37458SLiu Junliang /* Tx sdram Read Pointer Address High */ 12006b19b1bSChen Gang #define SR_TRPAH 0x23 121c9b37458SLiu Junliang /* Rx sdram Write Pointer Address Low */ 12206b19b1bSChen Gang #define SR_RWPAL 0x24 123c9b37458SLiu Junliang /* Rx sdram Write Pointer Address High */ 12406b19b1bSChen Gang #define SR_RWPAH 0x25 125c9b37458SLiu Junliang /* Rx sdram Read Pointer Address Low */ 12606b19b1bSChen Gang #define SR_RRPAL 0x26 127c9b37458SLiu Junliang /* Rx sdram Read Pointer Address High */ 12806b19b1bSChen Gang #define SR_RRPAH 0x27 129c9b37458SLiu Junliang /* Vendor ID register */ 13006b19b1bSChen Gang #define SR_VID 0x28 /* 0x28 ~ 0x29 2 bytes for VID */ 131c9b37458SLiu Junliang /* Product ID register */ 13206b19b1bSChen Gang #define SR_PID 0x2A /* 0x2A ~ 0x2B 2 bytes for PID */ 133c9b37458SLiu Junliang /* CHIP Revision register */ 13406b19b1bSChen Gang #define SR_CHIPR 0x2C 135c9b37458SLiu Junliang /* 0x2D --> 0xEF unused */ 136c9b37458SLiu Junliang /* USB Device Address */ 13706b19b1bSChen Gang #define SR_USBDA 0xF0 138c9b37458SLiu Junliang #define USBDA_USBFA (0x7F << 0) 139c9b37458SLiu Junliang /* RX packet Counter Reg */ 14006b19b1bSChen Gang #define SR_RXC 0xF1 141c9b37458SLiu Junliang /* Tx packet Counter & USB Status Reg */ 14206b19b1bSChen Gang #define SR_TXC_USBS 0xF2 143c9b37458SLiu Junliang #define TXC_USBS_TXC0 (1 << 0) 144c9b37458SLiu Junliang #define TXC_USBS_TXC1 (1 << 1) 145c9b37458SLiu Junliang #define TXC_USBS_TXC2 (1 << 2) 146c9b37458SLiu Junliang #define TXC_USBS_EP1RDY (1 << 5) 147c9b37458SLiu Junliang #define TXC_USBS_SUSFLAG (1 << 6) 148c9b37458SLiu Junliang #define TXC_USBS_RXFAULT (1 << 7) 149c9b37458SLiu Junliang /* USB Control register */ 15006b19b1bSChen Gang #define SR_USBC 0xF4 151c9b37458SLiu Junliang #define USBC_EP3NAK (1 << 4) 152c9b37458SLiu Junliang #define USBC_EP3ACK (1 << 5) 153c9b37458SLiu Junliang 154c9b37458SLiu Junliang /* Register access commands and flags */ 155c9b37458SLiu Junliang #define SR_RD_REGS 0x00 156c9b37458SLiu Junliang #define SR_WR_REGS 0x01 157c9b37458SLiu Junliang #define SR_WR_REG 0x03 158c9b37458SLiu Junliang #define SR_REQ_RD_REG (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE) 159c9b37458SLiu Junliang #define SR_REQ_WR_REG (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE) 160c9b37458SLiu Junliang 161c9b37458SLiu Junliang /* parameters */ 162c9b37458SLiu Junliang #define SR_SHARE_TIMEOUT 1000 163c9b37458SLiu Junliang #define SR_EEPROM_LEN 256 164c9b37458SLiu Junliang #define SR_MCAST_SIZE 8 165c9b37458SLiu Junliang #define SR_MCAST_ADDR_FLAG 0x80 166c9b37458SLiu Junliang #define SR_MCAST_MAX 64 167c9b37458SLiu Junliang #define SR_TX_OVERHEAD 2 /* 2bytes header */ 168c9b37458SLiu Junliang #define SR_RX_OVERHEAD 7 /* 3bytes header + 4crc tail */ 169c9b37458SLiu Junliang 170c9b37458SLiu Junliang #endif /* _SR9700_H */ 171