Back to home page

OSCL-LXR

 
 

    


0001 /* CoreChip-sz SR9800 one chip USB 2.0 Ethernet Devices
0002  *
0003  * Author : Liu Junliang <liujunliang_ljl@163.com>
0004  *
0005  * This file is licensed under the terms of the GNU General Public License
0006  * version 2.  This program is licensed "as is" without any warranty of any
0007  * kind, whether express or implied.
0008  */
0009 
0010 #ifndef _SR9800_H
0011 #define _SR9800_H
0012 
0013 /* SR9800 spec. command table on Linux Platform */
0014 
0015 /* command : Software Station Management Control Reg */
0016 #define SR_CMD_SET_SW_MII       0x06
0017 /* command : PHY Read Reg */
0018 #define SR_CMD_READ_MII_REG     0x07
0019 /* command : PHY Write Reg */
0020 #define SR_CMD_WRITE_MII_REG        0x08
0021 /* command : Hardware Station Management Control Reg */
0022 #define SR_CMD_SET_HW_MII       0x0a
0023 /* command : SROM Read Reg */
0024 #define SR_CMD_READ_EEPROM      0x0b
0025 /* command : SROM Write Reg */
0026 #define SR_CMD_WRITE_EEPROM     0x0c
0027 /* command : SROM Write Enable Reg */
0028 #define SR_CMD_WRITE_ENABLE     0x0d
0029 /* command : SROM Write Disable Reg */
0030 #define SR_CMD_WRITE_DISABLE        0x0e
0031 /* command : RX Control Read Reg */
0032 #define SR_CMD_READ_RX_CTL      0x0f
0033 #define     SR_RX_CTL_PRO           (1 << 0)
0034 #define     SR_RX_CTL_AMALL         (1 << 1)
0035 #define     SR_RX_CTL_SEP           (1 << 2)
0036 #define     SR_RX_CTL_AB            (1 << 3)
0037 #define     SR_RX_CTL_AM            (1 << 4)
0038 #define     SR_RX_CTL_AP            (1 << 5)
0039 #define     SR_RX_CTL_ARP           (1 << 6)
0040 #define     SR_RX_CTL_SO            (1 << 7)
0041 #define     SR_RX_CTL_RH1M          (1 << 8)
0042 #define     SR_RX_CTL_RH2M          (1 << 9)
0043 #define     SR_RX_CTL_RH3M          (1 << 10)
0044 /* command : RX Control Write Reg */
0045 #define SR_CMD_WRITE_RX_CTL     0x10
0046 /* command : IPG0/IPG1/IPG2 Control Read Reg */
0047 #define SR_CMD_READ_IPG012      0x11
0048 /* command : IPG0/IPG1/IPG2 Control Write Reg */
0049 #define SR_CMD_WRITE_IPG012     0x12
0050 /* command : Node ID Read Reg */
0051 #define SR_CMD_READ_NODE_ID     0x13
0052 /* command : Node ID Write Reg */
0053 #define SR_CMD_WRITE_NODE_ID        0x14
0054 /* command : Multicast Filter Array Read Reg */
0055 #define SR_CMD_READ_MULTI_FILTER    0x15
0056 /* command : Multicast Filter Array Write Reg */
0057 #define SR_CMD_WRITE_MULTI_FILTER   0x16
0058 /* command : Eth/HomePNA PHY Address Reg */
0059 #define SR_CMD_READ_PHY_ID      0x19
0060 /* command : Medium Status Read Reg */
0061 #define SR_CMD_READ_MEDIUM_STATUS   0x1a
0062 #define     SR_MONITOR_LINK         (1 << 1)
0063 #define     SR_MONITOR_MAGIC        (1 << 2)
0064 #define     SR_MONITOR_HSFS         (1 << 4)
0065 /* command : Medium Status Write Reg */
0066 #define SR_CMD_WRITE_MEDIUM_MODE    0x1b
0067 #define     SR_MEDIUM_GM            (1 << 0)
0068 #define     SR_MEDIUM_FD            (1 << 1)
0069 #define     SR_MEDIUM_AC            (1 << 2)
0070 #define     SR_MEDIUM_ENCK          (1 << 3)
0071 #define     SR_MEDIUM_RFC           (1 << 4)
0072 #define     SR_MEDIUM_TFC           (1 << 5)
0073 #define     SR_MEDIUM_JFE           (1 << 6)
0074 #define     SR_MEDIUM_PF            (1 << 7)
0075 #define     SR_MEDIUM_RE            (1 << 8)
0076 #define     SR_MEDIUM_PS            (1 << 9)
0077 #define     SR_MEDIUM_RSV           (1 << 10)
0078 #define     SR_MEDIUM_SBP           (1 << 11)
0079 #define     SR_MEDIUM_SM            (1 << 12)
0080 /* command : Monitor Mode Status Read Reg */
0081 #define SR_CMD_READ_MONITOR_MODE    0x1c
0082 /* command : Monitor Mode Status Write Reg */
0083 #define SR_CMD_WRITE_MONITOR_MODE   0x1d
0084 /* command : GPIO Status Read Reg */
0085 #define SR_CMD_READ_GPIOS       0x1e
0086 #define     SR_GPIO_GPO0EN      (1 << 0) /* GPIO0 Output enable */
0087 #define     SR_GPIO_GPO_0       (1 << 1) /* GPIO0 Output value */
0088 #define     SR_GPIO_GPO1EN      (1 << 2) /* GPIO1 Output enable */
0089 #define     SR_GPIO_GPO_1       (1 << 3) /* GPIO1 Output value */
0090 #define     SR_GPIO_GPO2EN      (1 << 4) /* GPIO2 Output enable */
0091 #define     SR_GPIO_GPO_2       (1 << 5) /* GPIO2 Output value */
0092 #define     SR_GPIO_RESERVED    (1 << 6) /* Reserved */
0093 #define     SR_GPIO_RSE     (1 << 7) /* Reload serial EEPROM */
0094 /* command : GPIO Status Write Reg */
0095 #define SR_CMD_WRITE_GPIOS      0x1f
0096 /* command : Eth PHY Power and Reset Control Reg */
0097 #define SR_CMD_SW_RESET         0x20
0098 #define     SR_SWRESET_CLEAR        0x00
0099 #define     SR_SWRESET_RR           (1 << 0)
0100 #define     SR_SWRESET_RT           (1 << 1)
0101 #define     SR_SWRESET_PRTE         (1 << 2)
0102 #define     SR_SWRESET_PRL          (1 << 3)
0103 #define     SR_SWRESET_BZ           (1 << 4)
0104 #define     SR_SWRESET_IPRL         (1 << 5)
0105 #define     SR_SWRESET_IPPD         (1 << 6)
0106 /* command : Software Interface Selection Status Read Reg */
0107 #define SR_CMD_SW_PHY_STATUS        0x21
0108 /* command : Software Interface Selection Status Write Reg */
0109 #define SR_CMD_SW_PHY_SELECT        0x22
0110 /* command : BULK in Buffer Size Reg */
0111 #define SR_CMD_BULKIN_SIZE      0x2A
0112 /* command : LED_MUX Control Reg */
0113 #define SR_CMD_LED_MUX          0x70
0114 #define     SR_LED_MUX_TX_ACTIVE        (1 << 0)
0115 #define     SR_LED_MUX_RX_ACTIVE        (1 << 1)
0116 #define     SR_LED_MUX_COLLISION        (1 << 2)
0117 #define     SR_LED_MUX_DUP_COL      (1 << 3)
0118 #define     SR_LED_MUX_DUP          (1 << 4)
0119 #define     SR_LED_MUX_SPEED        (1 << 5)
0120 #define     SR_LED_MUX_LINK_ACTIVE      (1 << 6)
0121 #define     SR_LED_MUX_LINK         (1 << 7)
0122 
0123 /* Register Access Flags */
0124 #define SR_REQ_RD_REG   (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE)
0125 #define SR_REQ_WR_REG   (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE)
0126 
0127 /* Multicast Filter Array size & Max Number */
0128 #define SR_MCAST_FILTER_SIZE        8
0129 #define SR_MAX_MCAST            64
0130 
0131 /* IPG0/1/2 Default Value */
0132 #define SR9800_IPG0_DEFAULT     0x15
0133 #define SR9800_IPG1_DEFAULT     0x0c
0134 #define SR9800_IPG2_DEFAULT     0x12
0135 
0136 /* Medium Status Default Mode */
0137 #define SR9800_MEDIUM_DEFAULT   \
0138     (SR_MEDIUM_FD | SR_MEDIUM_RFC | \
0139      SR_MEDIUM_TFC | SR_MEDIUM_PS | \
0140      SR_MEDIUM_AC | SR_MEDIUM_RE)
0141 
0142 /* RX Control Default Setting */
0143 #define SR_DEFAULT_RX_CTL   \
0144     (SR_RX_CTL_SO | SR_RX_CTL_AB | SR_RX_CTL_RH1M)
0145 
0146 /* EEPROM Magic Number & EEPROM Size */
0147 #define SR_EEPROM_MAGIC         0xdeadbeef
0148 #define SR9800_EEPROM_LEN       0xff
0149 
0150 /* SR9800 Driver Version and Driver Name */
0151 #define DRIVER_VERSION          "11-Nov-2013"
0152 #define DRIVER_NAME         "CoreChips"
0153 #define DRIVER_FLAG     \
0154     (FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR |  FLAG_MULTI_PACKET)
0155 
0156 /* SR9800 BULKIN Buffer Size */
0157 #define SR9800_MAX_BULKIN_2K        0
0158 #define SR9800_MAX_BULKIN_4K        1
0159 #define SR9800_MAX_BULKIN_6K        2
0160 #define SR9800_MAX_BULKIN_8K        3
0161 #define SR9800_MAX_BULKIN_16K       4
0162 #define SR9800_MAX_BULKIN_20K       5
0163 #define SR9800_MAX_BULKIN_24K       6
0164 #define SR9800_MAX_BULKIN_32K       7
0165 
0166 static const struct {unsigned short size, byte_cnt, threshold; } SR9800_BULKIN_SIZE[] = {
0167     /* 2k */
0168     {2048, 0x8000, 0x8001},
0169     /* 4k */
0170     {4096, 0x8100, 0x8147},
0171     /* 6k */
0172     {6144, 0x8200, 0x81EB},
0173     /* 8k */
0174     {8192, 0x8300, 0x83D7},
0175     /* 16 */
0176     {16384, 0x8400, 0x851E},
0177     /* 20k */
0178     {20480, 0x8500, 0x8666},
0179     /* 24k */
0180     {24576, 0x8600, 0x87AE},
0181     /* 32k */
0182     {32768, 0x8700, 0x8A3D},
0183 };
0184 
0185 /* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
0186 struct sr_data {
0187     u8 multi_filter[SR_MCAST_FILTER_SIZE];
0188     u8 mac_addr[ETH_ALEN];
0189     u8 phymode;
0190     u8 ledmode;
0191     u8 eeprom_len;
0192 };
0193 
0194 struct sr9800_int_data {
0195     __le16 res1;
0196     u8 link;
0197     __le16 res2;
0198     u8 status;
0199     __le16 res3;
0200 } __packed;
0201 
0202 #endif  /* _SR9800_H */