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 | * |
| 6 | * This software may be used and distributed according to the |
| 7 | * terms of the GNU Public License, Version 2, incorporated |
| 8 | * herein by reference. |
| 9 | * |
Andy Fleming | 2fffa05 | 2007-04-23 02:24:28 -0500 | [diff] [blame] | 10 | * Copyright 2004, 2007 Freescale Semiconductor, Inc. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 11 | * (C) Copyright 2003, Motorola, Inc. |
| 12 | * maintained by Xianghua Xiao (x.xiao@motorola.com) |
| 13 | * author Andy Fleming |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #ifndef __TSEC_H |
| 18 | #define __TSEC_H |
| 19 | |
| 20 | #include <net.h> |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 21 | #include <config.h> |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 22 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 23 | #ifndef CFG_TSEC1_OFFSET |
| 24 | #define CFG_TSEC1_OFFSET (0x24000) |
| 25 | #endif |
| 26 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 27 | #define TSEC_SIZE 0x01000 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 28 | |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 29 | /* FIXME: Should these be pushed back to 83xx and 85xx config files? */ |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 30 | #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 31 | #define TSEC_BASE_ADDR (CFG_IMMR + CFG_TSEC1_OFFSET) |
| 32 | #elif defined(CONFIG_MPC83XX) |
Timur Tabi | 386a280 | 2006-11-03 12:00:28 -0600 | [diff] [blame] | 33 | #define TSEC_BASE_ADDR (CFG_IMMR + CFG_TSEC1_OFFSET) |
Eran Liberty | 9095d4a | 2005-07-28 10:08:46 -0500 | [diff] [blame] | 34 | #endif |
| 35 | |
| 36 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 37 | #define MAC_ADDR_LEN 6 |
| 38 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 39 | /* #define TSEC_TIMEOUT 1000000 */ |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 40 | #define TSEC_TIMEOUT 1000 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 41 | #define TOUT_LOOP 1000000 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 42 | |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 43 | #define PHY_AUTONEGOTIATE_TIMEOUT 5000 /* in ms */ |
| 44 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 45 | /* MAC register bits */ |
| 46 | #define MACCFG1_SOFT_RESET 0x80000000 |
| 47 | #define MACCFG1_RESET_RX_MC 0x00080000 |
| 48 | #define MACCFG1_RESET_TX_MC 0x00040000 |
| 49 | #define MACCFG1_RESET_RX_FUN 0x00020000 |
| 50 | #define MACCFG1_RESET_TX_FUN 0x00010000 |
| 51 | #define MACCFG1_LOOPBACK 0x00000100 |
| 52 | #define MACCFG1_RX_FLOW 0x00000020 |
| 53 | #define MACCFG1_TX_FLOW 0x00000010 |
| 54 | #define MACCFG1_SYNCD_RX_EN 0x00000008 |
| 55 | #define MACCFG1_RX_EN 0x00000004 |
| 56 | #define MACCFG1_SYNCD_TX_EN 0x00000002 |
| 57 | #define MACCFG1_TX_EN 0x00000001 |
| 58 | |
| 59 | #define MACCFG2_INIT_SETTINGS 0x00007205 |
| 60 | #define MACCFG2_FULL_DUPLEX 0x00000001 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 61 | #define MACCFG2_IF 0x00000300 |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 62 | #define MACCFG2_GMII 0x00000200 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 63 | #define MACCFG2_MII 0x00000100 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 64 | |
| 65 | #define ECNTRL_INIT_SETTINGS 0x00001000 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 66 | #define ECNTRL_TBI_MODE 0x00000020 |
Jon Loeliger | 77a4f6e | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 67 | #define ECNTRL_R100 0x00000008 |
Andy Fleming | 2fffa05 | 2007-04-23 02:24:28 -0500 | [diff] [blame] | 68 | #define ECNTRL_SGMII_MODE 0x00000002 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 69 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 70 | #define miim_end -2 |
| 71 | #define miim_read -1 |
| 72 | |
Joe Hamman | 4290d4c | 2007-08-09 09:08:18 -0500 | [diff] [blame] | 73 | #ifndef CFG_TBIPA_VALUE |
| 74 | #define CFG_TBIPA_VALUE 0x1f |
| 75 | #endif |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 76 | #define MIIMCFG_INIT_VALUE 0x00000003 |
| 77 | #define MIIMCFG_RESET 0x80000000 |
| 78 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 79 | #define MIIMIND_BUSY 0x00000001 |
| 80 | #define MIIMIND_NOTVALID 0x00000004 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 81 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 82 | #define MIIM_CONTROL 0x00 |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 83 | #define MIIM_CONTROL_RESET 0x00009140 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 84 | #define MIIM_CONTROL_INIT 0x00001140 |
| 85 | #define MIIM_CONTROL_RESTART 0x00001340 |
| 86 | #define MIIM_ANEN 0x00001000 |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 87 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 88 | #define MIIM_CR 0x00 |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 89 | #define MIIM_CR_RST 0x00008000 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 90 | #define MIIM_CR_INIT 0x00001000 |
wdenk | 78924a7 | 2004-04-18 21:45:42 +0000 | [diff] [blame] | 91 | |
| 92 | #define MIIM_STATUS 0x1 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 93 | #define MIIM_STATUS_AN_DONE 0x00000020 |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 94 | #define MIIM_STATUS_LINK 0x0004 |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 95 | #define PHY_BMSR_AUTN_ABLE 0x0008 |
| 96 | #define PHY_BMSR_AUTN_COMP 0x0020 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 97 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 98 | #define MIIM_PHYIR1 0x2 |
| 99 | #define MIIM_PHYIR2 0x3 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 100 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 101 | #define MIIM_ANAR 0x4 |
| 102 | #define MIIM_ANAR_INIT 0x1e1 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 103 | |
| 104 | #define MIIM_TBI_ANLPBPA 0x5 |
| 105 | #define MIIM_TBI_ANLPBPA_HALF 0x00000040 |
| 106 | #define MIIM_TBI_ANLPBPA_FULL 0x00000020 |
| 107 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 108 | #define MIIM_TBI_ANEX 0x6 |
| 109 | #define MIIM_TBI_ANEX_NP 0x00000004 |
| 110 | #define MIIM_TBI_ANEX_PRX 0x00000002 |
| 111 | |
| 112 | #define MIIM_GBIT_CONTROL 0x9 |
| 113 | #define MIIM_GBIT_CONTROL_INIT 0xe00 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 114 | |
Andre Schwarz | 1e18be1 | 2008-04-29 19:18:32 +0200 | [diff] [blame] | 115 | #define MIIM_EXT_PAGE_ACCESS 0x1f |
| 116 | |
Paul Gortmaker | 2bd9f1b | 2007-01-16 11:38:14 -0500 | [diff] [blame] | 117 | /* Broadcom BCM54xx -- taken from linux sungem_phy */ |
| 118 | #define MIIM_BCM54xx_AUXSTATUS 0x19 |
| 119 | #define MIIM_BCM54xx_AUXSTATUS_LINKMODE_MASK 0x0700 |
| 120 | #define MIIM_BCM54xx_AUXSTATUS_LINKMODE_SHIFT 8 |
| 121 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 122 | /* Cicada Auxiliary Control/Status Register */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 123 | #define MIIM_CIS8201_AUX_CONSTAT 0x1c |
| 124 | #define MIIM_CIS8201_AUXCONSTAT_INIT 0x0004 |
| 125 | #define MIIM_CIS8201_AUXCONSTAT_DUPLEX 0x0020 |
| 126 | #define MIIM_CIS8201_AUXCONSTAT_SPEED 0x0018 |
| 127 | #define MIIM_CIS8201_AUXCONSTAT_GBIT 0x0010 |
| 128 | #define MIIM_CIS8201_AUXCONSTAT_100 0x0008 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 129 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 130 | /* Cicada Extended Control Register 1 */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 131 | #define MIIM_CIS8201_EXT_CON1 0x17 |
| 132 | #define MIIM_CIS8201_EXTCON1_INIT 0x0000 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 133 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 134 | /* Cicada 8204 Extended PHY Control Register 1 */ |
| 135 | #define MIIM_CIS8204_EPHY_CON 0x17 |
| 136 | #define MIIM_CIS8204_EPHYCON_INIT 0x0006 |
Wolfgang Denk | 4de55c0 | 2006-03-12 18:09:47 +0100 | [diff] [blame] | 137 | #define MIIM_CIS8204_EPHYCON_RGMII 0x1100 |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 138 | |
| 139 | /* Cicada 8204 Serial LED Control Register */ |
| 140 | #define MIIM_CIS8204_SLED_CON 0x1b |
| 141 | #define MIIM_CIS8204_SLEDCON_INIT 0x1115 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 142 | |
| 143 | #define MIIM_GBIT_CON 0x09 |
wdenk | 78924a7 | 2004-04-18 21:45:42 +0000 | [diff] [blame] | 144 | #define MIIM_GBIT_CON_ADVERT 0x0e00 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 145 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 146 | /* Entry for Vitesse VSC8244 regs starts here */ |
| 147 | /* Vitesse VSC8244 Auxiliary Control/Status Register */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 148 | #define MIIM_VSC8244_AUX_CONSTAT 0x1c |
| 149 | #define MIIM_VSC8244_AUXCONSTAT_INIT 0x0000 |
| 150 | #define MIIM_VSC8244_AUXCONSTAT_DUPLEX 0x0020 |
| 151 | #define MIIM_VSC8244_AUXCONSTAT_SPEED 0x0018 |
| 152 | #define MIIM_VSC8244_AUXCONSTAT_GBIT 0x0010 |
| 153 | #define MIIM_VSC8244_AUXCONSTAT_100 0x0008 |
| 154 | #define MIIM_CONTROL_INIT_LOOPBACK 0x4000 |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 155 | |
| 156 | /* Vitesse VSC8244 Extended PHY Control Register 1 */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 157 | #define MIIM_VSC8244_EPHY_CON 0x17 |
| 158 | #define MIIM_VSC8244_EPHYCON_INIT 0x0006 |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 159 | |
| 160 | /* Vitesse VSC8244 Serial LED Control Register */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 161 | #define MIIM_VSC8244_LED_CON 0x1b |
| 162 | #define MIIM_VSC8244_LEDCON_INIT 0xF011 |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 163 | |
Tor Krill | 8b3a82f | 2008-03-28 15:29:45 +0100 | [diff] [blame] | 164 | /* Entry for Vitesse VSC8601 regs starts here (Not complete) */ |
| 165 | /* Vitesse VSC8601 Extended PHY Control Register 1 */ |
Andre Schwarz | 1e18be1 | 2008-04-29 19:18:32 +0200 | [diff] [blame] | 166 | #define MIIM_VSC8601_EPHY_CON 0x17 |
Tor Krill | 8b3a82f | 2008-03-28 15:29:45 +0100 | [diff] [blame] | 167 | #define MIIM_VSC8601_EPHY_CON_INIT_SKEW 0x1120 |
Andre Schwarz | 1e18be1 | 2008-04-29 19:18:32 +0200 | [diff] [blame] | 168 | #define MIIM_VSC8601_SKEW_CTRL 0x1c |
Tor Krill | 8b3a82f | 2008-03-28 15:29:45 +0100 | [diff] [blame] | 169 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 170 | /* 88E1011 PHY Status Register */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 171 | #define MIIM_88E1011_PHY_STATUS 0x11 |
| 172 | #define MIIM_88E1011_PHYSTAT_SPEED 0xc000 |
| 173 | #define MIIM_88E1011_PHYSTAT_GBIT 0x8000 |
| 174 | #define MIIM_88E1011_PHYSTAT_100 0x4000 |
| 175 | #define MIIM_88E1011_PHYSTAT_DUPLEX 0x2000 |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 176 | #define MIIM_88E1011_PHYSTAT_SPDDONE 0x0800 |
| 177 | #define MIIM_88E1011_PHYSTAT_LINK 0x0400 |
| 178 | |
Andy Fleming | 239e75f | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 179 | #define MIIM_88E1011_PHY_SCR 0x10 |
| 180 | #define MIIM_88E1011_PHY_MDI_X_AUTO 0x0060 |
| 181 | |
| 182 | /* 88E1111 PHY LED Control Register */ |
Andre Schwarz | 1e18be1 | 2008-04-29 19:18:32 +0200 | [diff] [blame] | 183 | #define MIIM_88E1111_PHY_LED_CONTROL 24 |
| 184 | #define MIIM_88E1111_PHY_LED_DIRECT 0x4100 |
| 185 | #define MIIM_88E1111_PHY_LED_COMBINE 0x411C |
Andy Fleming | 239e75f | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 186 | |
| 187 | /* 88E1145 Extended PHY Specific Control Register */ |
| 188 | #define MIIM_88E1145_PHY_EXT_CR 20 |
| 189 | #define MIIM_M88E1145_RGMII_RX_DELAY 0x0080 |
| 190 | #define MIIM_M88E1145_RGMII_TX_DELAY 0x0002 |
| 191 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 192 | #define MIIM_88E1145_PHY_PAGE 29 |
Andy Fleming | 239e75f | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 193 | #define MIIM_88E1145_PHY_CAL_OV 30 |
| 194 | |
Dave Liu | a304a28 | 2008-01-11 18:45:28 +0800 | [diff] [blame] | 195 | /* RTL8211B PHY Status Register */ |
| 196 | #define MIIM_RTL8211B_PHY_STATUS 0x11 |
| 197 | #define MIIM_RTL8211B_PHYSTAT_SPEED 0xc000 |
| 198 | #define MIIM_RTL8211B_PHYSTAT_GBIT 0x8000 |
| 199 | #define MIIM_RTL8211B_PHYSTAT_100 0x4000 |
| 200 | #define MIIM_RTL8211B_PHYSTAT_DUPLEX 0x2000 |
| 201 | #define MIIM_RTL8211B_PHYSTAT_SPDDONE 0x0800 |
| 202 | #define MIIM_RTL8211B_PHYSTAT_LINK 0x0400 |
Andy Fleming | 239e75f | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 203 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 204 | /* DM9161 Control register values */ |
| 205 | #define MIIM_DM9161_CR_STOP 0x0400 |
| 206 | #define MIIM_DM9161_CR_RSTAN 0x1200 |
| 207 | |
| 208 | #define MIIM_DM9161_SCR 0x10 |
| 209 | #define MIIM_DM9161_SCR_INIT 0x0610 |
| 210 | |
| 211 | /* DM9161 Specified Configuration and Status Register */ |
| 212 | #define MIIM_DM9161_SCSR 0x11 |
| 213 | #define MIIM_DM9161_SCSR_100F 0x8000 |
| 214 | #define MIIM_DM9161_SCSR_100H 0x4000 |
| 215 | #define MIIM_DM9161_SCSR_10F 0x2000 |
| 216 | #define MIIM_DM9161_SCSR_10H 0x1000 |
| 217 | |
| 218 | /* DM9161 10BT Configuration/Status */ |
| 219 | #define MIIM_DM9161_10BTCSR 0x12 |
| 220 | #define MIIM_DM9161_10BTCSR_INIT 0x7800 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 221 | |
wdenk | f41ff3b | 2005-04-04 23:43:44 +0000 | [diff] [blame] | 222 | /* LXT971 Status 2 registers */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 223 | #define MIIM_LXT971_SR2 0x11 /* Status Register 2 */ |
Wolfgang Denk | a79c44f | 2006-03-12 18:06:37 +0100 | [diff] [blame] | 224 | #define MIIM_LXT971_SR2_SPEED_MASK 0x4200 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 225 | #define MIIM_LXT971_SR2_10HDX 0x0000 /* 10 Mbit half duplex selected */ |
| 226 | #define MIIM_LXT971_SR2_10FDX 0x0200 /* 10 Mbit full duplex selected */ |
| 227 | #define MIIM_LXT971_SR2_100HDX 0x4000 /* 100 Mbit half duplex selected */ |
| 228 | #define MIIM_LXT971_SR2_100FDX 0x4200 /* 100 Mbit full duplex selected */ |
wdenk | f41ff3b | 2005-04-04 23:43:44 +0000 | [diff] [blame] | 229 | |
Wolfgang Denk | f0c4e46 | 2006-03-12 22:50:55 +0100 | [diff] [blame] | 230 | /* DP83865 Control register values */ |
| 231 | #define MIIM_DP83865_CR_INIT 0x9200 |
| 232 | |
| 233 | /* DP83865 Link and Auto-Neg Status Register */ |
| 234 | #define MIIM_DP83865_LANR 0x11 |
| 235 | #define MIIM_DP83865_SPD_MASK 0x0018 |
| 236 | #define MIIM_DP83865_SPD_1000 0x0010 |
| 237 | #define MIIM_DP83865_SPD_100 0x0008 |
| 238 | #define MIIM_DP83865_DPX_FULL 0x0002 |
| 239 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 240 | #define MIIM_READ_COMMAND 0x00000001 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 241 | |
| 242 | #define MRBLR_INIT_SETTINGS PKTSIZE_ALIGN |
| 243 | |
| 244 | #define MINFLR_INIT_SETTINGS 0x00000040 |
| 245 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 246 | #define DMACTRL_INIT_SETTINGS 0x000000c3 |
| 247 | #define DMACTRL_GRS 0x00000010 |
| 248 | #define DMACTRL_GTS 0x00000008 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 249 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 250 | #define TSTAT_CLEAR_THALT 0x80000000 |
| 251 | #define RSTAT_CLEAR_RHALT 0x00800000 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 252 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 253 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 254 | #define IEVENT_INIT_CLEAR 0xffffffff |
| 255 | #define IEVENT_BABR 0x80000000 |
| 256 | #define IEVENT_RXC 0x40000000 |
| 257 | #define IEVENT_BSY 0x20000000 |
| 258 | #define IEVENT_EBERR 0x10000000 |
| 259 | #define IEVENT_MSRO 0x04000000 |
| 260 | #define IEVENT_GTSC 0x02000000 |
| 261 | #define IEVENT_BABT 0x01000000 |
| 262 | #define IEVENT_TXC 0x00800000 |
| 263 | #define IEVENT_TXE 0x00400000 |
| 264 | #define IEVENT_TXB 0x00200000 |
| 265 | #define IEVENT_TXF 0x00100000 |
| 266 | #define IEVENT_IE 0x00080000 |
| 267 | #define IEVENT_LC 0x00040000 |
| 268 | #define IEVENT_CRL 0x00020000 |
| 269 | #define IEVENT_XFUN 0x00010000 |
| 270 | #define IEVENT_RXB0 0x00008000 |
| 271 | #define IEVENT_GRSC 0x00000100 |
| 272 | #define IEVENT_RXF0 0x00000080 |
| 273 | |
| 274 | #define IMASK_INIT_CLEAR 0x00000000 |
| 275 | #define IMASK_TXEEN 0x00400000 |
| 276 | #define IMASK_TXBEN 0x00200000 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 277 | #define IMASK_TXFEN 0x00100000 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 278 | #define IMASK_RXFEN0 0x00000080 |
| 279 | |
| 280 | |
| 281 | /* Default Attribute fields */ |
| 282 | #define ATTR_INIT_SETTINGS 0x000000c0 |
| 283 | #define ATTRELI_INIT_SETTINGS 0x00000000 |
| 284 | |
| 285 | |
| 286 | /* TxBD status field bits */ |
| 287 | #define TXBD_READY 0x8000 |
| 288 | #define TXBD_PADCRC 0x4000 |
| 289 | #define TXBD_WRAP 0x2000 |
| 290 | #define TXBD_INTERRUPT 0x1000 |
| 291 | #define TXBD_LAST 0x0800 |
| 292 | #define TXBD_CRC 0x0400 |
| 293 | #define TXBD_DEF 0x0200 |
| 294 | #define TXBD_HUGEFRAME 0x0080 |
| 295 | #define TXBD_LATECOLLISION 0x0080 |
| 296 | #define TXBD_RETRYLIMIT 0x0040 |
| 297 | #define TXBD_RETRYCOUNTMASK 0x003c |
| 298 | #define TXBD_UNDERRUN 0x0002 |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 299 | #define TXBD_STATS 0x03ff |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 300 | |
| 301 | /* RxBD status field bits */ |
| 302 | #define RXBD_EMPTY 0x8000 |
| 303 | #define RXBD_RO1 0x4000 |
| 304 | #define RXBD_WRAP 0x2000 |
| 305 | #define RXBD_INTERRUPT 0x1000 |
| 306 | #define RXBD_LAST 0x0800 |
| 307 | #define RXBD_FIRST 0x0400 |
| 308 | #define RXBD_MISS 0x0100 |
| 309 | #define RXBD_BROADCAST 0x0080 |
| 310 | #define RXBD_MULTICAST 0x0040 |
| 311 | #define RXBD_LARGE 0x0020 |
| 312 | #define RXBD_NONOCTET 0x0010 |
| 313 | #define RXBD_SHORT 0x0008 |
| 314 | #define RXBD_CRCERR 0x0004 |
| 315 | #define RXBD_OVERRUN 0x0002 |
| 316 | #define RXBD_TRUNCATED 0x0001 |
| 317 | #define RXBD_STATS 0x003f |
| 318 | |
| 319 | typedef struct txbd8 |
| 320 | { |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 321 | ushort status; /* Status Fields */ |
| 322 | ushort length; /* Buffer length */ |
| 323 | uint bufPtr; /* Buffer Pointer */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 324 | } txbd8_t; |
| 325 | |
| 326 | typedef struct rxbd8 |
| 327 | { |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 328 | ushort status; /* Status Fields */ |
| 329 | ushort length; /* Buffer Length */ |
| 330 | uint bufPtr; /* Buffer Pointer */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 331 | } rxbd8_t; |
| 332 | |
| 333 | typedef struct rmon_mib |
| 334 | { |
| 335 | /* Transmit and Receive Counters */ |
| 336 | uint tr64; /* Transmit and Receive 64-byte Frame Counter */ |
| 337 | uint tr127; /* Transmit and Receive 65-127 byte Frame Counter */ |
| 338 | uint tr255; /* Transmit and Receive 128-255 byte Frame Counter */ |
| 339 | uint tr511; /* Transmit and Receive 256-511 byte Frame Counter */ |
| 340 | uint tr1k; /* Transmit and Receive 512-1023 byte Frame Counter */ |
| 341 | uint trmax; /* Transmit and Receive 1024-1518 byte Frame Counter */ |
| 342 | uint trmgv; /* Transmit and Receive 1519-1522 byte Good VLAN Frame */ |
| 343 | /* Receive Counters */ |
| 344 | uint rbyt; /* Receive Byte Counter */ |
| 345 | uint rpkt; /* Receive Packet Counter */ |
| 346 | uint rfcs; /* Receive FCS Error Counter */ |
| 347 | uint rmca; /* Receive Multicast Packet (Counter) */ |
| 348 | uint rbca; /* Receive Broadcast Packet */ |
| 349 | uint rxcf; /* Receive Control Frame Packet */ |
| 350 | uint rxpf; /* Receive Pause Frame Packet */ |
| 351 | uint rxuo; /* Receive Unknown OP Code */ |
| 352 | uint raln; /* Receive Alignment Error */ |
| 353 | uint rflr; /* Receive Frame Length Error */ |
| 354 | uint rcde; /* Receive Code Error */ |
| 355 | uint rcse; /* Receive Carrier Sense Error */ |
| 356 | uint rund; /* Receive Undersize Packet */ |
| 357 | uint rovr; /* Receive Oversize Packet */ |
| 358 | uint rfrg; /* Receive Fragments */ |
| 359 | uint rjbr; /* Receive Jabber */ |
| 360 | uint rdrp; /* Receive Drop */ |
| 361 | /* Transmit Counters */ |
| 362 | uint tbyt; /* Transmit Byte Counter */ |
| 363 | uint tpkt; /* Transmit Packet */ |
| 364 | uint tmca; /* Transmit Multicast Packet */ |
| 365 | uint tbca; /* Transmit Broadcast Packet */ |
| 366 | uint txpf; /* Transmit Pause Control Frame */ |
| 367 | uint tdfr; /* Transmit Deferral Packet */ |
| 368 | uint tedf; /* Transmit Excessive Deferral Packet */ |
| 369 | uint tscl; /* Transmit Single Collision Packet */ |
| 370 | /* (0x2_n700) */ |
| 371 | uint tmcl; /* Transmit Multiple Collision Packet */ |
| 372 | uint tlcl; /* Transmit Late Collision Packet */ |
| 373 | uint txcl; /* Transmit Excessive Collision Packet */ |
| 374 | uint tncl; /* Transmit Total Collision */ |
| 375 | |
| 376 | uint res2; |
| 377 | |
| 378 | uint tdrp; /* Transmit Drop Frame */ |
| 379 | uint tjbr; /* Transmit Jabber Frame */ |
| 380 | uint tfcs; /* Transmit FCS Error */ |
| 381 | uint txcf; /* Transmit Control Frame */ |
| 382 | uint tovr; /* Transmit Oversize Frame */ |
| 383 | uint tund; /* Transmit Undersize Frame */ |
| 384 | uint tfrg; /* Transmit Fragments Frame */ |
| 385 | /* General Registers */ |
| 386 | uint car1; /* Carry Register One */ |
| 387 | uint car2; /* Carry Register Two */ |
| 388 | uint cam1; /* Carry Register One Mask */ |
| 389 | uint cam2; /* Carry Register Two Mask */ |
| 390 | } rmon_mib_t; |
| 391 | |
| 392 | typedef struct tsec_hash_regs |
| 393 | { |
| 394 | uint iaddr0; /* Individual Address Register 0 */ |
| 395 | uint iaddr1; /* Individual Address Register 1 */ |
| 396 | uint iaddr2; /* Individual Address Register 2 */ |
| 397 | uint iaddr3; /* Individual Address Register 3 */ |
| 398 | uint iaddr4; /* Individual Address Register 4 */ |
| 399 | uint iaddr5; /* Individual Address Register 5 */ |
| 400 | uint iaddr6; /* Individual Address Register 6 */ |
| 401 | uint iaddr7; /* Individual Address Register 7 */ |
| 402 | uint res1[24]; |
| 403 | uint gaddr0; /* Group Address Register 0 */ |
| 404 | uint gaddr1; /* Group Address Register 1 */ |
| 405 | uint gaddr2; /* Group Address Register 2 */ |
| 406 | uint gaddr3; /* Group Address Register 3 */ |
| 407 | uint gaddr4; /* Group Address Register 4 */ |
| 408 | uint gaddr5; /* Group Address Register 5 */ |
| 409 | uint gaddr6; /* Group Address Register 6 */ |
| 410 | uint gaddr7; /* Group Address Register 7 */ |
| 411 | uint res2[24]; |
| 412 | } tsec_hash_t; |
| 413 | |
| 414 | typedef struct tsec |
| 415 | { |
| 416 | /* General Control and Status Registers (0x2_n000) */ |
| 417 | uint res000[4]; |
| 418 | |
| 419 | uint ievent; /* Interrupt Event */ |
| 420 | uint imask; /* Interrupt Mask */ |
| 421 | uint edis; /* Error Disabled */ |
| 422 | uint res01c; |
| 423 | uint ecntrl; /* Ethernet Control */ |
| 424 | uint minflr; /* Minimum Frame Length */ |
| 425 | uint ptv; /* Pause Time Value */ |
| 426 | uint dmactrl; /* DMA Control */ |
| 427 | uint tbipa; /* TBI PHY Address */ |
| 428 | |
| 429 | uint res034[3]; |
| 430 | uint res040[48]; |
| 431 | |
| 432 | /* Transmit Control and Status Registers (0x2_n100) */ |
| 433 | uint tctrl; /* Transmit Control */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 434 | uint tstat; /* Transmit Status */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 435 | uint res108; |
| 436 | uint tbdlen; /* Tx BD Data Length */ |
| 437 | uint res110[5]; |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 438 | uint ctbptr; /* Current TxBD Pointer */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 439 | uint res128[23]; |
| 440 | uint tbptr; /* TxBD Pointer */ |
| 441 | uint res188[30]; |
| 442 | /* (0x2_n200) */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 443 | uint res200; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 444 | uint tbase; /* TxBD Base Address */ |
| 445 | uint res208[42]; |
| 446 | uint ostbd; /* Out of Sequence TxBD */ |
| 447 | uint ostbdp; /* Out of Sequence Tx Data Buffer Pointer */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 448 | uint res2b8[18]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 449 | |
| 450 | /* Receive Control and Status Registers (0x2_n300) */ |
| 451 | uint rctrl; /* Receive Control */ |
| 452 | uint rstat; /* Receive Status */ |
| 453 | uint res308; |
| 454 | uint rbdlen; /* RxBD Data Length */ |
| 455 | uint res310[4]; |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 456 | uint res320; |
| 457 | uint crbptr; /* Current Receive Buffer Pointer */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 458 | uint res328[6]; |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 459 | uint mrblr; /* Maximum Receive Buffer Length */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 460 | uint res344[16]; |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 461 | uint rbptr; /* RxBD Pointer */ |
| 462 | uint res388[30]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 463 | /* (0x2_n400) */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 464 | uint res400; |
| 465 | uint rbase; /* RxBD Base Address */ |
| 466 | uint res408[62]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 467 | |
| 468 | /* MAC Registers (0x2_n500) */ |
| 469 | uint maccfg1; /* MAC Configuration #1 */ |
| 470 | uint maccfg2; /* MAC Configuration #2 */ |
| 471 | uint ipgifg; /* Inter Packet Gap/Inter Frame Gap */ |
| 472 | uint hafdup; /* Half-duplex */ |
| 473 | uint maxfrm; /* Maximum Frame */ |
| 474 | uint res514; |
| 475 | uint res518; |
| 476 | |
| 477 | uint res51c; |
| 478 | |
| 479 | uint miimcfg; /* MII Management: Configuration */ |
| 480 | uint miimcom; /* MII Management: Command */ |
| 481 | uint miimadd; /* MII Management: Address */ |
| 482 | uint miimcon; /* MII Management: Control */ |
| 483 | uint miimstat; /* MII Management: Status */ |
| 484 | uint miimind; /* MII Management: Indicators */ |
| 485 | |
| 486 | uint res538; |
| 487 | |
| 488 | uint ifstat; /* Interface Status */ |
| 489 | uint macstnaddr1; /* Station Address, part 1 */ |
| 490 | uint macstnaddr2; /* Station Address, part 2 */ |
| 491 | uint res548[46]; |
| 492 | |
| 493 | /* (0x2_n600) */ |
| 494 | uint res600[32]; |
| 495 | |
| 496 | /* RMON MIB Registers (0x2_n680-0x2_n73c) */ |
| 497 | rmon_mib_t rmon; |
| 498 | uint res740[48]; |
| 499 | |
| 500 | /* Hash Function Registers (0x2_n800) */ |
| 501 | tsec_hash_t hash; |
| 502 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 503 | uint res900[128]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 504 | |
| 505 | /* Pattern Registers (0x2_nb00) */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 506 | uint resb00[62]; |
| 507 | uint attr; /* Default Attribute Register */ |
| 508 | uint attreli; /* Default Attribute Extract Length and Index */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 509 | |
| 510 | /* TSEC Future Expansion Space (0x2_nc00-0x2_nffc) */ |
| 511 | uint resc00[256]; |
| 512 | } tsec_t; |
| 513 | |
Jon Loeliger | 77a4f6e | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 514 | #define TSEC_GIGABIT (1) |
| 515 | |
| 516 | /* This flag currently only has |
| 517 | * meaning if we're using the eTSEC */ |
| 518 | #define TSEC_REDUCED (1 << 1) |
| 519 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 520 | struct tsec_private { |
| 521 | volatile tsec_t *regs; |
| 522 | volatile tsec_t *phyregs; |
| 523 | struct phy_info *phyinfo; |
| 524 | uint phyaddr; |
Jon Loeliger | 77a4f6e | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 525 | u32 flags; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 526 | uint link; |
| 527 | uint duplexity; |
| 528 | uint speed; |
| 529 | }; |
| 530 | |
| 531 | |
| 532 | /* |
| 533 | * struct phy_cmd: A command for reading or writing a PHY register |
| 534 | * |
| 535 | * mii_reg: The register to read or write |
| 536 | * |
| 537 | * mii_data: For writes, the value to put in the register. |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 538 | * A value of -1 indicates this is a read. |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 539 | * |
| 540 | * funct: A function pointer which is invoked for each command. |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 541 | * For reads, this function will be passed the value read |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 542 | * from the PHY, and process it. |
| 543 | * For writes, the result of this function will be written |
| 544 | * to the PHY register |
| 545 | */ |
| 546 | struct phy_cmd { |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 547 | uint mii_reg; |
| 548 | uint mii_data; |
| 549 | uint (*funct) (uint mii_reg, struct tsec_private * priv); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 550 | }; |
| 551 | |
| 552 | /* struct phy_info: a structure which defines attributes for a PHY |
| 553 | * |
| 554 | * id will contain a number which represents the PHY. During |
| 555 | * startup, the driver will poll the PHY to find out what its |
| 556 | * UID--as defined by registers 2 and 3--is. The 32-bit result |
| 557 | * gotten from the PHY will be shifted right by "shift" bits to |
| 558 | * discard any bits which may change based on revision numbers |
| 559 | * unimportant to functionality |
| 560 | * |
| 561 | * The struct phy_cmd entries represent pointers to an arrays of |
| 562 | * commands which tell the driver what to do to the PHY. |
| 563 | */ |
| 564 | struct phy_info { |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 565 | uint id; |
| 566 | char *name; |
| 567 | uint shift; |
| 568 | /* Called to configure the PHY, and modify the controller |
| 569 | * based on the results */ |
| 570 | struct phy_cmd *config; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 571 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 572 | /* Called when starting up the controller */ |
| 573 | struct phy_cmd *startup; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 574 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 575 | /* Called when bringing down the controller */ |
| 576 | struct phy_cmd *shutdown; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 577 | }; |
| 578 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 579 | #endif /* __TSEC_H */ |