wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1 | /* |
| 2 | * tsec.h |
| 3 | * |
| 4 | * Driver for the Motorola Triple Speed Ethernet Controller |
| 5 | * |
Claudiu Manoil | cd0c412 | 2013-09-30 12:44:42 +0300 | [diff] [blame] | 6 | * Copyright 2004, 2007, 2009, 2011, 2013 Freescale Semiconductor, Inc. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 7 | * (C) Copyright 2003, Motorola, Inc. |
| 8 | * maintained by Xianghua Xiao (x.xiao@motorola.com) |
| 9 | * author Andy Fleming |
| 10 | * |
Bin Meng | 79cd33a | 2016-01-11 22:41:18 -0800 | [diff] [blame] | 11 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #ifndef __TSEC_H |
| 15 | #define __TSEC_H |
| 16 | |
| 17 | #include <net.h> |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 18 | #include <config.h> |
Andy Fleming | 422effd | 2011-04-08 02:10:54 -0500 | [diff] [blame] | 19 | #include <phy.h> |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 20 | |
Alison Wang | 32cc591 | 2014-09-05 13:52:38 +0800 | [diff] [blame] | 21 | #ifdef CONFIG_LS102XA |
| 22 | #define TSEC_SIZE 0x40000 |
| 23 | #define TSEC_MDIO_OFFSET 0x40000 |
| 24 | #else |
Sandeep Gopalpet | b5541ef | 2009-10-31 00:35:04 +0530 | [diff] [blame] | 25 | #define TSEC_SIZE 0x01000 |
| 26 | #define TSEC_MDIO_OFFSET 0x01000 |
Alison Wang | 32cc591 | 2014-09-05 13:52:38 +0800 | [diff] [blame] | 27 | #endif |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 28 | |
Andy Fleming | 6855a65 | 2011-04-29 02:26:52 -0500 | [diff] [blame] | 29 | #define CONFIG_SYS_MDIO_BASE_ADDR (MDIO_BASE_ADDR + 0x520) |
Andy Fleming | 422effd | 2011-04-08 02:10:54 -0500 | [diff] [blame] | 30 | |
Claudiu Manoil | cd0c412 | 2013-09-30 12:44:42 +0300 | [diff] [blame] | 31 | #define TSEC_GET_REGS(num, offset) \ |
| 32 | (struct tsec __iomem *)\ |
| 33 | (TSEC_BASE_ADDR + (((num) - 1) * (offset))) |
| 34 | |
| 35 | #define TSEC_GET_REGS_BASE(num) \ |
| 36 | TSEC_GET_REGS((num), TSEC_SIZE) |
| 37 | |
| 38 | #define TSEC_GET_MDIO_REGS(num, offset) \ |
| 39 | (struct tsec_mii_mng __iomem *)\ |
| 40 | (CONFIG_SYS_MDIO_BASE_ADDR + ((num) - 1) * (offset)) |
| 41 | |
| 42 | #define TSEC_GET_MDIO_REGS_BASE(num) \ |
| 43 | TSEC_GET_MDIO_REGS((num), TSEC_MDIO_OFFSET) |
| 44 | |
Andy Fleming | 422effd | 2011-04-08 02:10:54 -0500 | [diff] [blame] | 45 | #define DEFAULT_MII_NAME "FSL_MDIO" |
| 46 | |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 47 | #define STD_TSEC_INFO(num) \ |
| 48 | { \ |
Claudiu Manoil | cd0c412 | 2013-09-30 12:44:42 +0300 | [diff] [blame] | 49 | .regs = TSEC_GET_REGS_BASE(num), \ |
| 50 | .miiregs_sgmii = TSEC_GET_MDIO_REGS_BASE(num), \ |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 51 | .devname = CONFIG_TSEC##num##_NAME, \ |
| 52 | .phyaddr = TSEC##num##_PHY_ADDR, \ |
Andy Fleming | 422effd | 2011-04-08 02:10:54 -0500 | [diff] [blame] | 53 | .flags = TSEC##num##_FLAGS, \ |
| 54 | .mii_devname = DEFAULT_MII_NAME \ |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | #define SET_STD_TSEC_INFO(x, num) \ |
| 58 | { \ |
Claudiu Manoil | cd0c412 | 2013-09-30 12:44:42 +0300 | [diff] [blame] | 59 | x.regs = TSEC_GET_REGS_BASE(num); \ |
| 60 | x.miiregs_sgmii = TSEC_GET_MDIO_REGS_BASE(num); \ |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 61 | x.devname = CONFIG_TSEC##num##_NAME; \ |
| 62 | x.phyaddr = TSEC##num##_PHY_ADDR; \ |
| 63 | x.flags = TSEC##num##_FLAGS;\ |
Andy Fleming | 422effd | 2011-04-08 02:10:54 -0500 | [diff] [blame] | 64 | x.mii_devname = DEFAULT_MII_NAME;\ |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 65 | } |
| 66 | |
Bin Meng | 79cd33a | 2016-01-11 22:41:18 -0800 | [diff] [blame] | 67 | #define MAC_ADDR_LEN 6 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 68 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 69 | /* #define TSEC_TIMEOUT 1000000 */ |
Bin Meng | 79cd33a | 2016-01-11 22:41:18 -0800 | [diff] [blame] | 70 | #define TSEC_TIMEOUT 1000 |
| 71 | #define TOUT_LOOP 1000000 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 72 | |
Andy Fleming | ac65e07 | 2008-08-31 16:33:27 -0500 | [diff] [blame] | 73 | /* TBI register addresses */ |
| 74 | #define TBI_CR 0x00 |
| 75 | #define TBI_SR 0x01 |
| 76 | #define TBI_ANA 0x04 |
| 77 | #define TBI_ANLPBPA 0x05 |
| 78 | #define TBI_ANEX 0x06 |
| 79 | #define TBI_TBICON 0x11 |
| 80 | |
| 81 | /* TBI MDIO register bit fields*/ |
| 82 | #define TBICON_CLK_SELECT 0x0020 |
Bin Meng | 79cd33a | 2016-01-11 22:41:18 -0800 | [diff] [blame] | 83 | #define TBIANA_ASYMMETRIC_PAUSE 0x0100 |
| 84 | #define TBIANA_SYMMETRIC_PAUSE 0x0080 |
Andy Fleming | ac65e07 | 2008-08-31 16:33:27 -0500 | [diff] [blame] | 85 | #define TBIANA_HALF_DUPLEX 0x0040 |
| 86 | #define TBIANA_FULL_DUPLEX 0x0020 |
| 87 | #define TBICR_PHY_RESET 0x8000 |
| 88 | #define TBICR_ANEG_ENABLE 0x1000 |
| 89 | #define TBICR_RESTART_ANEG 0x0200 |
| 90 | #define TBICR_FULL_DUPLEX 0x0100 |
| 91 | #define TBICR_SPEED1_SET 0x0040 |
| 92 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 93 | /* MAC register bits */ |
| 94 | #define MACCFG1_SOFT_RESET 0x80000000 |
| 95 | #define MACCFG1_RESET_RX_MC 0x00080000 |
| 96 | #define MACCFG1_RESET_TX_MC 0x00040000 |
| 97 | #define MACCFG1_RESET_RX_FUN 0x00020000 |
Bin Meng | 79cd33a | 2016-01-11 22:41:18 -0800 | [diff] [blame] | 98 | #define MACCFG1_RESET_TX_FUN 0x00010000 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 99 | #define MACCFG1_LOOPBACK 0x00000100 |
| 100 | #define MACCFG1_RX_FLOW 0x00000020 |
| 101 | #define MACCFG1_TX_FLOW 0x00000010 |
| 102 | #define MACCFG1_SYNCD_RX_EN 0x00000008 |
| 103 | #define MACCFG1_RX_EN 0x00000004 |
| 104 | #define MACCFG1_SYNCD_TX_EN 0x00000002 |
| 105 | #define MACCFG1_TX_EN 0x00000001 |
| 106 | |
| 107 | #define MACCFG2_INIT_SETTINGS 0x00007205 |
| 108 | #define MACCFG2_FULL_DUPLEX 0x00000001 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 109 | #define MACCFG2_IF 0x00000300 |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 110 | #define MACCFG2_GMII 0x00000200 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 111 | #define MACCFG2_MII 0x00000100 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 112 | |
| 113 | #define ECNTRL_INIT_SETTINGS 0x00001000 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 114 | #define ECNTRL_TBI_MODE 0x00000020 |
Andy Fleming | 422effd | 2011-04-08 02:10:54 -0500 | [diff] [blame] | 115 | #define ECNTRL_REDUCED_MODE 0x00000010 |
Jon Loeliger | 77a4f6e | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 116 | #define ECNTRL_R100 0x00000008 |
Andy Fleming | 422effd | 2011-04-08 02:10:54 -0500 | [diff] [blame] | 117 | #define ECNTRL_REDUCED_MII_MODE 0x00000004 |
Andy Fleming | 2fffa05 | 2007-04-23 02:24:28 -0500 | [diff] [blame] | 118 | #define ECNTRL_SGMII_MODE 0x00000002 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 119 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 120 | #ifndef CONFIG_SYS_TBIPA_VALUE |
Bin Meng | 79cd33a | 2016-01-11 22:41:18 -0800 | [diff] [blame] | 121 | # define CONFIG_SYS_TBIPA_VALUE 0x1f |
Joe Hamman | 4290d4c | 2007-08-09 09:08:18 -0500 | [diff] [blame] | 122 | #endif |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 123 | |
| 124 | #define MRBLR_INIT_SETTINGS PKTSIZE_ALIGN |
| 125 | |
| 126 | #define MINFLR_INIT_SETTINGS 0x00000040 |
| 127 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 128 | #define DMACTRL_INIT_SETTINGS 0x000000c3 |
| 129 | #define DMACTRL_GRS 0x00000010 |
| 130 | #define DMACTRL_GTS 0x00000008 |
Alison Wang | 32cc591 | 2014-09-05 13:52:38 +0800 | [diff] [blame] | 131 | #define DMACTRL_LE 0x00008000 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 132 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 133 | #define TSTAT_CLEAR_THALT 0x80000000 |
| 134 | #define RSTAT_CLEAR_RHALT 0x00800000 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 135 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 136 | #define IEVENT_INIT_CLEAR 0xffffffff |
| 137 | #define IEVENT_BABR 0x80000000 |
| 138 | #define IEVENT_RXC 0x40000000 |
| 139 | #define IEVENT_BSY 0x20000000 |
| 140 | #define IEVENT_EBERR 0x10000000 |
| 141 | #define IEVENT_MSRO 0x04000000 |
| 142 | #define IEVENT_GTSC 0x02000000 |
| 143 | #define IEVENT_BABT 0x01000000 |
| 144 | #define IEVENT_TXC 0x00800000 |
| 145 | #define IEVENT_TXE 0x00400000 |
| 146 | #define IEVENT_TXB 0x00200000 |
| 147 | #define IEVENT_TXF 0x00100000 |
| 148 | #define IEVENT_IE 0x00080000 |
| 149 | #define IEVENT_LC 0x00040000 |
| 150 | #define IEVENT_CRL 0x00020000 |
| 151 | #define IEVENT_XFUN 0x00010000 |
| 152 | #define IEVENT_RXB0 0x00008000 |
| 153 | #define IEVENT_GRSC 0x00000100 |
| 154 | #define IEVENT_RXF0 0x00000080 |
| 155 | |
| 156 | #define IMASK_INIT_CLEAR 0x00000000 |
| 157 | #define IMASK_TXEEN 0x00400000 |
| 158 | #define IMASK_TXBEN 0x00200000 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 159 | #define IMASK_TXFEN 0x00100000 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 160 | #define IMASK_RXFEN0 0x00000080 |
| 161 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 162 | /* Default Attribute fields */ |
Bin Meng | 79cd33a | 2016-01-11 22:41:18 -0800 | [diff] [blame] | 163 | #define ATTR_INIT_SETTINGS 0x000000c0 |
| 164 | #define ATTRELI_INIT_SETTINGS 0x00000000 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 165 | |
| 166 | /* TxBD status field bits */ |
| 167 | #define TXBD_READY 0x8000 |
| 168 | #define TXBD_PADCRC 0x4000 |
| 169 | #define TXBD_WRAP 0x2000 |
| 170 | #define TXBD_INTERRUPT 0x1000 |
| 171 | #define TXBD_LAST 0x0800 |
| 172 | #define TXBD_CRC 0x0400 |
| 173 | #define TXBD_DEF 0x0200 |
| 174 | #define TXBD_HUGEFRAME 0x0080 |
| 175 | #define TXBD_LATECOLLISION 0x0080 |
| 176 | #define TXBD_RETRYLIMIT 0x0040 |
Bin Meng | 79cd33a | 2016-01-11 22:41:18 -0800 | [diff] [blame] | 177 | #define TXBD_RETRYCOUNTMASK 0x003c |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 178 | #define TXBD_UNDERRUN 0x0002 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 179 | #define TXBD_STATS 0x03ff |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 180 | |
| 181 | /* RxBD status field bits */ |
| 182 | #define RXBD_EMPTY 0x8000 |
| 183 | #define RXBD_RO1 0x4000 |
| 184 | #define RXBD_WRAP 0x2000 |
| 185 | #define RXBD_INTERRUPT 0x1000 |
| 186 | #define RXBD_LAST 0x0800 |
| 187 | #define RXBD_FIRST 0x0400 |
| 188 | #define RXBD_MISS 0x0100 |
| 189 | #define RXBD_BROADCAST 0x0080 |
| 190 | #define RXBD_MULTICAST 0x0040 |
| 191 | #define RXBD_LARGE 0x0020 |
| 192 | #define RXBD_NONOCTET 0x0010 |
| 193 | #define RXBD_SHORT 0x0008 |
| 194 | #define RXBD_CRCERR 0x0004 |
| 195 | #define RXBD_OVERRUN 0x0002 |
| 196 | #define RXBD_TRUNCATED 0x0001 |
| 197 | #define RXBD_STATS 0x003f |
| 198 | |
Claudiu Manoil | eec416b | 2013-10-04 19:13:53 +0300 | [diff] [blame] | 199 | struct txbd8 { |
Bin Meng | 79cd33a | 2016-01-11 22:41:18 -0800 | [diff] [blame] | 200 | uint16_t status; /* Status Fields */ |
| 201 | uint16_t length; /* Buffer length */ |
| 202 | uint32_t bufptr; /* Buffer Pointer */ |
Claudiu Manoil | eec416b | 2013-10-04 19:13:53 +0300 | [diff] [blame] | 203 | }; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 204 | |
Claudiu Manoil | eec416b | 2013-10-04 19:13:53 +0300 | [diff] [blame] | 205 | struct rxbd8 { |
Bin Meng | 79cd33a | 2016-01-11 22:41:18 -0800 | [diff] [blame] | 206 | uint16_t status; /* Status Fields */ |
| 207 | uint16_t length; /* Buffer Length */ |
| 208 | uint32_t bufptr; /* Buffer Pointer */ |
Claudiu Manoil | eec416b | 2013-10-04 19:13:53 +0300 | [diff] [blame] | 209 | }; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 210 | |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 211 | struct tsec_rmon_mib { |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 212 | /* Transmit and Receive Counters */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 213 | u32 tr64; /* Tx/Rx 64-byte Frame Counter */ |
| 214 | u32 tr127; /* Tx/Rx 65-127 byte Frame Counter */ |
| 215 | u32 tr255; /* Tx/Rx 128-255 byte Frame Counter */ |
| 216 | u32 tr511; /* Tx/Rx 256-511 byte Frame Counter */ |
| 217 | u32 tr1k; /* Tx/Rx 512-1023 byte Frame Counter */ |
| 218 | u32 trmax; /* Tx/Rx 1024-1518 byte Frame Counter */ |
| 219 | u32 trmgv; /* Tx/Rx 1519-1522 byte Good VLAN Frame */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 220 | /* Receive Counters */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 221 | u32 rbyt; /* Receive Byte Counter */ |
| 222 | u32 rpkt; /* Receive Packet Counter */ |
| 223 | u32 rfcs; /* Receive FCS Error Counter */ |
| 224 | u32 rmca; /* Receive Multicast Packet (Counter) */ |
| 225 | u32 rbca; /* Receive Broadcast Packet */ |
| 226 | u32 rxcf; /* Receive Control Frame Packet */ |
| 227 | u32 rxpf; /* Receive Pause Frame Packet */ |
| 228 | u32 rxuo; /* Receive Unknown OP Code */ |
| 229 | u32 raln; /* Receive Alignment Error */ |
| 230 | u32 rflr; /* Receive Frame Length Error */ |
| 231 | u32 rcde; /* Receive Code Error */ |
| 232 | u32 rcse; /* Receive Carrier Sense Error */ |
| 233 | u32 rund; /* Receive Undersize Packet */ |
| 234 | u32 rovr; /* Receive Oversize Packet */ |
| 235 | u32 rfrg; /* Receive Fragments */ |
| 236 | u32 rjbr; /* Receive Jabber */ |
| 237 | u32 rdrp; /* Receive Drop */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 238 | /* Transmit Counters */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 239 | u32 tbyt; /* Transmit Byte Counter */ |
| 240 | u32 tpkt; /* Transmit Packet */ |
| 241 | u32 tmca; /* Transmit Multicast Packet */ |
| 242 | u32 tbca; /* Transmit Broadcast Packet */ |
| 243 | u32 txpf; /* Transmit Pause Control Frame */ |
| 244 | u32 tdfr; /* Transmit Deferral Packet */ |
| 245 | u32 tedf; /* Transmit Excessive Deferral Packet */ |
| 246 | u32 tscl; /* Transmit Single Collision Packet */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 247 | /* (0x2_n700) */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 248 | u32 tmcl; /* Transmit Multiple Collision Packet */ |
| 249 | u32 tlcl; /* Transmit Late Collision Packet */ |
| 250 | u32 txcl; /* Transmit Excessive Collision Packet */ |
| 251 | u32 tncl; /* Transmit Total Collision */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 252 | |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 253 | u32 res2; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 254 | |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 255 | u32 tdrp; /* Transmit Drop Frame */ |
| 256 | u32 tjbr; /* Transmit Jabber Frame */ |
| 257 | u32 tfcs; /* Transmit FCS Error */ |
| 258 | u32 txcf; /* Transmit Control Frame */ |
| 259 | u32 tovr; /* Transmit Oversize Frame */ |
| 260 | u32 tund; /* Transmit Undersize Frame */ |
| 261 | u32 tfrg; /* Transmit Fragments Frame */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 262 | /* General Registers */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 263 | u32 car1; /* Carry Register One */ |
| 264 | u32 car2; /* Carry Register Two */ |
| 265 | u32 cam1; /* Carry Register One Mask */ |
| 266 | u32 cam2; /* Carry Register Two Mask */ |
| 267 | }; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 268 | |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 269 | struct tsec_hash_regs { |
| 270 | u32 iaddr0; /* Individual Address Register 0 */ |
| 271 | u32 iaddr1; /* Individual Address Register 1 */ |
| 272 | u32 iaddr2; /* Individual Address Register 2 */ |
| 273 | u32 iaddr3; /* Individual Address Register 3 */ |
| 274 | u32 iaddr4; /* Individual Address Register 4 */ |
| 275 | u32 iaddr5; /* Individual Address Register 5 */ |
| 276 | u32 iaddr6; /* Individual Address Register 6 */ |
| 277 | u32 iaddr7; /* Individual Address Register 7 */ |
| 278 | u32 res1[24]; |
| 279 | u32 gaddr0; /* Group Address Register 0 */ |
| 280 | u32 gaddr1; /* Group Address Register 1 */ |
| 281 | u32 gaddr2; /* Group Address Register 2 */ |
| 282 | u32 gaddr3; /* Group Address Register 3 */ |
| 283 | u32 gaddr4; /* Group Address Register 4 */ |
| 284 | u32 gaddr5; /* Group Address Register 5 */ |
| 285 | u32 gaddr6; /* Group Address Register 6 */ |
| 286 | u32 gaddr7; /* Group Address Register 7 */ |
| 287 | u32 res2[24]; |
| 288 | }; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 289 | |
Claudiu Manoil | cd0c412 | 2013-09-30 12:44:42 +0300 | [diff] [blame] | 290 | struct tsec { |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 291 | /* General Control and Status Registers (0x2_n000) */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 292 | u32 res000[4]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 293 | |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 294 | u32 ievent; /* Interrupt Event */ |
| 295 | u32 imask; /* Interrupt Mask */ |
| 296 | u32 edis; /* Error Disabled */ |
| 297 | u32 res01c; |
| 298 | u32 ecntrl; /* Ethernet Control */ |
| 299 | u32 minflr; /* Minimum Frame Length */ |
| 300 | u32 ptv; /* Pause Time Value */ |
| 301 | u32 dmactrl; /* DMA Control */ |
| 302 | u32 tbipa; /* TBI PHY Address */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 303 | |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 304 | u32 res034[3]; |
| 305 | u32 res040[48]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 306 | |
| 307 | /* Transmit Control and Status Registers (0x2_n100) */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 308 | u32 tctrl; /* Transmit Control */ |
| 309 | u32 tstat; /* Transmit Status */ |
| 310 | u32 res108; |
| 311 | u32 tbdlen; /* Tx BD Data Length */ |
| 312 | u32 res110[5]; |
| 313 | u32 ctbptr; /* Current TxBD Pointer */ |
| 314 | u32 res128[23]; |
| 315 | u32 tbptr; /* TxBD Pointer */ |
| 316 | u32 res188[30]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 317 | /* (0x2_n200) */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 318 | u32 res200; |
| 319 | u32 tbase; /* TxBD Base Address */ |
| 320 | u32 res208[42]; |
| 321 | u32 ostbd; /* Out of Sequence TxBD */ |
| 322 | u32 ostbdp; /* Out of Sequence Tx Data Buffer Pointer */ |
| 323 | u32 res2b8[18]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 324 | |
| 325 | /* Receive Control and Status Registers (0x2_n300) */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 326 | u32 rctrl; /* Receive Control */ |
| 327 | u32 rstat; /* Receive Status */ |
| 328 | u32 res308; |
| 329 | u32 rbdlen; /* RxBD Data Length */ |
| 330 | u32 res310[4]; |
| 331 | u32 res320; |
Bin Meng | 79cd33a | 2016-01-11 22:41:18 -0800 | [diff] [blame] | 332 | u32 crbptr; /* Current Receive Buffer Pointer */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 333 | u32 res328[6]; |
Bin Meng | 79cd33a | 2016-01-11 22:41:18 -0800 | [diff] [blame] | 334 | u32 mrblr; /* Maximum Receive Buffer Length */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 335 | u32 res344[16]; |
Bin Meng | 79cd33a | 2016-01-11 22:41:18 -0800 | [diff] [blame] | 336 | u32 rbptr; /* RxBD Pointer */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 337 | u32 res388[30]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 338 | /* (0x2_n400) */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 339 | u32 res400; |
Bin Meng | 79cd33a | 2016-01-11 22:41:18 -0800 | [diff] [blame] | 340 | u32 rbase; /* RxBD Base Address */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 341 | u32 res408[62]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 342 | |
| 343 | /* MAC Registers (0x2_n500) */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 344 | u32 maccfg1; /* MAC Configuration #1 */ |
| 345 | u32 maccfg2; /* MAC Configuration #2 */ |
| 346 | u32 ipgifg; /* Inter Packet Gap/Inter Frame Gap */ |
| 347 | u32 hafdup; /* Half-duplex */ |
| 348 | u32 maxfrm; /* Maximum Frame */ |
| 349 | u32 res514; |
| 350 | u32 res518; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 351 | |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 352 | u32 res51c; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 353 | |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 354 | u32 resmdio[6]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 355 | |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 356 | u32 res538; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 357 | |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 358 | u32 ifstat; /* Interface Status */ |
| 359 | u32 macstnaddr1; /* Station Address, part 1 */ |
| 360 | u32 macstnaddr2; /* Station Address, part 2 */ |
| 361 | u32 res548[46]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 362 | |
| 363 | /* (0x2_n600) */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 364 | u32 res600[32]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 365 | |
| 366 | /* RMON MIB Registers (0x2_n680-0x2_n73c) */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 367 | struct tsec_rmon_mib rmon; |
| 368 | u32 res740[48]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 369 | |
| 370 | /* Hash Function Registers (0x2_n800) */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 371 | struct tsec_hash_regs hash; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 372 | |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 373 | u32 res900[128]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 374 | |
| 375 | /* Pattern Registers (0x2_nb00) */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 376 | u32 resb00[62]; |
| 377 | u32 attr; /* Default Attribute Register */ |
| 378 | u32 attreli; /* Default Attribute Extract Length and Index */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 379 | |
| 380 | /* TSEC Future Expansion Space (0x2_nc00-0x2_nffc) */ |
Claudiu Manoil | a18ab90 | 2013-09-30 12:44:46 +0300 | [diff] [blame] | 381 | u32 resc00[256]; |
Claudiu Manoil | cd0c412 | 2013-09-30 12:44:42 +0300 | [diff] [blame] | 382 | }; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 383 | |
Bin Meng | 79cd33a | 2016-01-11 22:41:18 -0800 | [diff] [blame] | 384 | #define TSEC_GIGABIT (1 << 0) |
Jon Loeliger | 77a4f6e | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 385 | |
Andy Fleming | 422effd | 2011-04-08 02:10:54 -0500 | [diff] [blame] | 386 | /* These flags currently only have meaning if we're using the eTSEC */ |
Peter Tyser | 94f63a7 | 2009-11-09 13:09:48 -0600 | [diff] [blame] | 387 | #define TSEC_REDUCED (1 << 1) /* MAC-PHY interface uses RGMII */ |
| 388 | #define TSEC_SGMII (1 << 2) /* MAC-PHY interface uses SGMII */ |
Jon Loeliger | 77a4f6e | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 389 | |
Bin Meng | 1120c54 | 2016-01-11 22:41:20 -0800 | [diff] [blame] | 390 | #define TX_BUF_CNT 2 |
| 391 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 392 | struct tsec_private { |
Bin Meng | 1120c54 | 2016-01-11 22:41:20 -0800 | [diff] [blame] | 393 | struct txbd8 __iomem txbd[TX_BUF_CNT]; |
| 394 | struct rxbd8 __iomem rxbd[PKTBUFSRX]; |
Claudiu Manoil | cd0c412 | 2013-09-30 12:44:42 +0300 | [diff] [blame] | 395 | struct tsec __iomem *regs; |
| 396 | struct tsec_mii_mng __iomem *phyregs_sgmii; |
Andy Fleming | 422effd | 2011-04-08 02:10:54 -0500 | [diff] [blame] | 397 | struct phy_device *phydev; |
| 398 | phy_interface_t interface; |
| 399 | struct mii_dev *bus; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 400 | uint phyaddr; |
Andy Fleming | 422effd | 2011-04-08 02:10:54 -0500 | [diff] [blame] | 401 | char mii_devname[16]; |
Jon Loeliger | 77a4f6e | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 402 | u32 flags; |
Bin Meng | 76f5399 | 2016-01-11 22:41:19 -0800 | [diff] [blame] | 403 | uint rx_idx; /* index of the current RX buffer */ |
| 404 | uint tx_idx; /* index of the current TX buffer */ |
Bin Meng | e86a6cd | 2016-01-11 22:41:22 -0800 | [diff] [blame^] | 405 | struct eth_device *dev; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 406 | }; |
| 407 | |
Andy Fleming | c067fc1 | 2008-08-31 16:33:25 -0500 | [diff] [blame] | 408 | struct tsec_info_struct { |
Claudiu Manoil | cd0c412 | 2013-09-30 12:44:42 +0300 | [diff] [blame] | 409 | struct tsec __iomem *regs; |
| 410 | struct tsec_mii_mng __iomem *miiregs_sgmii; |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 411 | char *devname; |
Andy Fleming | 422effd | 2011-04-08 02:10:54 -0500 | [diff] [blame] | 412 | char *mii_devname; |
| 413 | phy_interface_t interface; |
Andy Fleming | c067fc1 | 2008-08-31 16:33:25 -0500 | [diff] [blame] | 414 | unsigned int phyaddr; |
| 415 | u32 flags; |
Andy Fleming | c067fc1 | 2008-08-31 16:33:25 -0500 | [diff] [blame] | 416 | }; |
| 417 | |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 418 | int tsec_standard_init(bd_t *bis); |
| 419 | int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsec_info, int num); |
| 420 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 421 | #endif /* __TSEC_H */ |