Sven Schnelle | 4b7b320 | 2012-01-08 15:27:18 +0100 | [diff] [blame] | 1 | /* |
| 2 | * inteltool - dump all registers on an Intel CPU + chipset based system. |
| 3 | * |
| 4 | * Copyright (C) 2012 Sven Schnelle <svens@stackframe.org> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 | */ |
| 19 | |
| 20 | |
| 21 | #include <stdio.h> |
| 22 | #include <stdlib.h> |
| 23 | #include "inteltool.h" |
| 24 | |
| 25 | #define AMB_CONFIG_SPACE_SIZE 0x20000 |
| 26 | |
| 27 | #define AMB_ADDR(base, fn, reg) (base | ((fn & 7) << 8) | ((reg & 0xff))) |
| 28 | |
| 29 | static uint32_t amb_read_config32(volatile void *base, int fn, int reg) |
| 30 | { |
| 31 | return *(uint32_t *)(AMB_ADDR((uint64_t)base, fn, reg)); |
| 32 | } |
| 33 | |
| 34 | static void amb_printreg32(volatile void *base, int fn, int reg, |
| 35 | const char *name, int printzero) |
| 36 | { |
| 37 | uint32_t val = amb_read_config32(base, fn, reg); |
| 38 | if (!val && !printzero) |
| 39 | return; |
| 40 | printf("%d:%2.2x %-16.16s: 0x%08x\n", fn, reg, name, val); |
| 41 | } |
| 42 | |
| 43 | static uint16_t amb_read_config16(volatile void *base, int fn, int reg) |
| 44 | { |
| 45 | return *(uint16_t *)(AMB_ADDR((uint64_t)base, fn, reg)); |
| 46 | } |
| 47 | |
| 48 | static void amb_printreg16(volatile void *base, int fn, int reg, |
| 49 | const char *name, int printzero) |
| 50 | { |
| 51 | uint16_t val = amb_read_config16(base, fn, reg); |
| 52 | if (!val && !printzero) |
| 53 | return; |
| 54 | printf("%d:%2.2x %-16.16s: 0x%04x\n", fn, reg, name, val); |
| 55 | |
| 56 | } |
| 57 | |
| 58 | static uint8_t amb_read_config8(volatile void *base, int fn, int reg) |
| 59 | { |
| 60 | return *(uint8_t *)(AMB_ADDR((uint64_t)base, fn, reg)); |
| 61 | } |
| 62 | |
| 63 | static void amb_printreg8(volatile void *base, int fn, int reg, |
| 64 | const char *name, int printzero) |
| 65 | { |
| 66 | uint8_t val = amb_read_config8(base, fn, reg); |
| 67 | if (!val && !printzero) |
| 68 | return; |
| 69 | printf("%d:%2.2x %-16.16s: 0x%02x\n", fn, reg, name, val); |
| 70 | |
| 71 | } |
| 72 | |
| 73 | static void amb_printreg24(volatile void *base, int fn, int reg, |
| 74 | const char *name, int printzero) |
| 75 | { |
| 76 | uint32_t val; |
| 77 | |
| 78 | if (reg & 1) { |
| 79 | val = amb_read_config8(base, fn, reg) | |
| 80 | (amb_read_config16(base, fn, reg + 1) << 8); |
| 81 | } else { |
| 82 | val = amb_read_config16(base, fn, reg) | |
| 83 | (amb_read_config8(base, fn, reg + 2) << 16); |
| 84 | } |
| 85 | |
| 86 | if (!val && !printzero) |
| 87 | return; |
| 88 | |
| 89 | printf("%d:%2.2x %-16.16s: 0x%06x\n", fn, reg, name, val); |
| 90 | } |
| 91 | |
| 92 | |
| 93 | struct amb_register { |
| 94 | int fn; |
| 95 | int offset; |
| 96 | const char *name; |
| 97 | void (*printfunc)(volatile void *, int, int, const char *, int); |
| 98 | int width; |
| 99 | } amb_registers[] = { |
| 100 | { 0, 0x00, "VID", NULL, 2 }, |
| 101 | { 0, 0x02, "DID", NULL, 2 }, |
| 102 | { 0, 0x08, "RID", NULL, 1 }, |
| 103 | { 0, 0x09, "CCR", NULL, 3 }, |
| 104 | { 0, 0x0e, "HDR", NULL, 1 }, |
| 105 | { 1, 0x40, "FBDS0", NULL, 1 }, |
| 106 | { 1, 0x41, "FBDS1", NULL, 1 }, |
| 107 | { 1, 0x42, "FBDS2", NULL, 1 }, |
| 108 | { 1, 0x43, "FBDS3", NULL, 1 }, |
| 109 | { 1, 0x50, "FBDSBCFGCUR", NULL, 1 }, |
| 110 | { 1, 0x51, "FBDNBCFGCUR", NULL, 1 }, |
| 111 | { 1, 0x52, "LINKPARCUR", NULL, 2 }, |
| 112 | { 1, 0x54, "FBDSBCFGNXT", NULL, 1 }, |
| 113 | { 1, 0x55, "FBDNBCFGNXT", NULL, 1 }, |
| 114 | { 1, 0x56, "LINKPARNXT", NULL, 2 }, |
| 115 | { 1, 0x5a, "SBRXMAR", NULL, 1 }, |
| 116 | { 1, 0x5b, "NBRXMAR", NULL, 1 }, |
| 117 | { 1, 0x5c, "MODES", NULL, 1 }, |
| 118 | { 1, 0x60, "FEATURES", NULL, 2 }, |
| 119 | { 1, 0x64, "FBDLIS", NULL, 3 }, |
| 120 | { 1, 0x68, "FBDLOCKTO", NULL, 2 }, |
| 121 | { 1, 0x6c, "FBDHAC", NULL, 1 }, |
| 122 | { 1, 0x6e, "FBDLS", NULL, 1 }, |
| 123 | { 1, 0x70, "RECALDUR", NULL, 1 }, |
| 124 | { 1, 0x74, "LOSDUR", NULL, 1 }, |
| 125 | { 1, 0x78, "SYNCTRAININT", NULL, 1 }, |
| 126 | { 1, 0x7c, "SBCALSTATUS", NULL, 2 }, |
| 127 | { 1, 0x7e, "NBCALSTATUS", NULL, 2 }, |
| 128 | { 1, 0x88, "CBC", NULL, 1 }, |
| 129 | { 1, 0x8c, "EMASK", NULL, 1 }, |
| 130 | { 1, 0x90, "FERR", NULL, 1 }, |
| 131 | { 1, 0x94, "NERR", NULL, 1 }, |
| 132 | { 1, 0x98, "RECCFG", NULL, 2 }, |
| 133 | { 1, 0x9c, "RECFBD0", NULL, 2 }, |
| 134 | { 1, 0x9e, "RECFBD1", NULL, 2 }, |
| 135 | { 1, 0xa0, "RECFBD2", NULL, 2 }, |
| 136 | { 1, 0xa2, "RECFBD3", NULL, 2 }, |
| 137 | { 1, 0xa4, "RECFBD4", NULL, 2 }, |
| 138 | { 1, 0xa6, "RECFBD5", NULL, 2 }, |
| 139 | { 1, 0xa8, "RECFBD6", NULL, 2 }, |
| 140 | { 1, 0xaa, "RECFBD7", NULL, 2 }, |
| 141 | { 1, 0xac, "RECFBD8", NULL, 2 }, |
| 142 | { 1, 0xae, "RECFBD9", NULL, 2 }, |
| 143 | { 1, 0xb0, "PERSBYTE0NXT", NULL, 1 }, |
| 144 | { 1, 0xb1, "PERSBYTE1NXT", NULL, 1 }, |
| 145 | { 1, 0xb2, "PERSBYTE2NXT", NULL, 1 }, |
| 146 | { 1, 0xb3, "PERSBYTE3NXT", NULL, 1 }, |
| 147 | { 1, 0xb4, "PERSBYTE4NXT", NULL, 1 }, |
| 148 | { 1, 0xb5, "PERSBYTE5NXT", NULL, 1 }, |
| 149 | { 1, 0xb6, "PERSBYTE6NXT", NULL, 1 }, |
| 150 | { 1, 0xb7, "PERSBYTE7NXT", NULL, 1 }, |
| 151 | { 1, 0xb8, "PERSBYTE8NXT", NULL, 1 }, |
| 152 | { 1, 0xb9, "PERSBYTE9NXT", NULL, 1 }, |
| 153 | { 1, 0xba, "PERSBYTE10NXT", NULL, 1 }, |
| 154 | { 1, 0xbb, "PERSBYTE11NXT", NULL, 1 }, |
| 155 | { 1, 0xbc, "PERSBYTE12NXT", NULL, 1 }, |
| 156 | { 1, 0xbd, "PERSBYTE13NXT", NULL, 1 }, |
| 157 | { 1, 0xc0, "PERSBYTE0CUR", NULL, 1 }, |
| 158 | { 1, 0xc1, "PERSBYTE1CUR", NULL, 1 }, |
| 159 | { 1, 0xc2, "PERSBYTE2CUR", NULL, 1 }, |
| 160 | { 1, 0xc3, "PERSBYTE3CUR", NULL, 1 }, |
| 161 | { 1, 0xc4, "PERSBYTE4CUR", NULL, 1 }, |
| 162 | { 1, 0xc5, "PERSBYTE5CUR", NULL, 1 }, |
| 163 | { 1, 0xc6, "PERSBYTE6CUR", NULL, 1 }, |
| 164 | { 1, 0xc7, "PERSBYTE7CUR", NULL, 1 }, |
| 165 | { 1, 0xc8, "PERSBYTE8CUR", NULL, 1 }, |
| 166 | { 1, 0xc9, "PERSBYTE9CUR", NULL, 1 }, |
| 167 | { 1, 0xca, "PERSBYTE10CUR", NULL, 1 }, |
| 168 | { 1, 0xcb, "PERSBYTE11CUR", NULL, 1 }, |
| 169 | { 1, 0xcc, "PERSBYTE12CUR", NULL, 1 }, |
| 170 | { 1, 0xcd, "PERSBYTE13CUR", NULL, 1 }, |
| 171 | { 1, 0xe8, "CMD2DATANXT", NULL, 1 }, |
| 172 | { 1, 0xe9, "CMD2DATACUR", NULL, 1 }, |
| 173 | { 1, 0xea, "C2DINCRNXT", NULL, 1 }, |
| 174 | { 1, 0xeb, "C2DINCRCUR", NULL, 1 }, |
| 175 | { 1, 0xec, "C2DDECRNXT", NULL, 1 }, |
| 176 | { 1, 0xed, "C2DDECRCUR", NULL, 1 }, |
| 177 | { 2, 0x40, "SBDRVCFG", NULL, 1 }, |
| 178 | { 2, 0x41, "NBDRVCFG", NULL, 1 }, |
| 179 | { 2, 0x42, "FBDPDCFG", NULL, 1 }, |
| 180 | { 2, 0x44, "RTERMCFG", NULL, 3 }, |
| 181 | { 2, 0x47, "IDTCTRLCFG", NULL, 1 }, |
| 182 | { 2, 0x48, "FBDBUFCFG", NULL, 1 }, |
| 183 | { 2, 0x50, "SBRQOFFS0", NULL, 1 }, |
| 184 | { 2, 0x51, "SBRQOFFS1", NULL, 1 }, |
| 185 | { 2, 0x52, "SBRQOFFS2", NULL, 1 }, |
| 186 | { 2, 0x53, "SBRQOFFS3", NULL, 1 }, |
| 187 | { 2, 0x54, "SBRQOFFS4", NULL, 1 }, |
| 188 | { 2, 0x55, "SBRQOFFS5", NULL, 1 }, |
| 189 | { 2, 0x56, "SBRQOFFS6", NULL, 1 }, |
| 190 | { 2, 0x57, "SBRQOFFS7", NULL, 1 }, |
| 191 | { 2, 0x58, "SBRQOFFS8", NULL, 1 }, |
| 192 | { 2, 0x59, "SBRQOFFS9", NULL, 1 }, |
| 193 | |
| 194 | { 2, 0x60, "NBRQOFFS0", NULL, 1 }, |
| 195 | { 2, 0x61, "NBRQOFFS1", NULL, 1 }, |
| 196 | { 2, 0x62, "NBRQOFFS2", NULL, 1 }, |
| 197 | { 2, 0x63, "NBRQOFFS3", NULL, 1 }, |
| 198 | { 2, 0x64, "NBRQOFFS4", NULL, 1 }, |
| 199 | { 2, 0x65, "NBRQOFFS5", NULL, 1 }, |
| 200 | { 2, 0x66, "NBRQOFFS6", NULL, 1 }, |
| 201 | { 2, 0x67, "NBRQOFFS7", NULL, 1 }, |
| 202 | { 2, 0x68, "NBRQOFFS8", NULL, 1 }, |
| 203 | { 2, 0x69, "NBRQOFFS9", NULL, 1 }, |
| 204 | { 2, 0x6a, "NBRQOFFS10", NULL, 1 }, |
| 205 | { 2, 0x6b, "NBRQOFFS11", NULL, 1 }, |
| 206 | { 2, 0x6c, "NBRQOFFS12", NULL, 1 }, |
| 207 | { 2, 0x6d, "NBRQOFFS13", NULL, 1 }, |
| 208 | { 2, 0x90, "TESTCFG", NULL, 1 }, |
| 209 | { 2, 0x94, "SBTXENCFG", NULL, 2 }, |
| 210 | { 2, 0x96, "NBTXENCFG", NULL, 2 }, |
| 211 | { 2, 0x98, "IDLEDETCFG", NULL, 2 }, |
| 212 | { 2, 0xa4, "SBRXSTATUS", NULL, 4 }, |
| 213 | { 2, 0xa8, "SBRXSTATUS", NULL, 1 }, |
| 214 | { 3, 0x3c, "MBIDT", NULL, 1 }, |
| 215 | { 3, 0x40, "MBCSR", NULL, 4 }, |
| 216 | { 3, 0x44, "MBADDR", NULL, 4 }, |
| 217 | { 3, 0x40, "MBDATA0", NULL, 4 }, |
| 218 | { 3, 0x41, "MBDATA1", NULL, 4 }, |
| 219 | { 3, 0x42, "MBDATA2", NULL, 4 }, |
| 220 | { 3, 0x43, "MBDATA3", NULL, 4 }, |
| 221 | { 3, 0x44, "MBDATA4", NULL, 4 }, |
| 222 | { 3, 0x45, "MBDATA5", NULL, 4 }, |
| 223 | { 3, 0x46, "MBDATA6", NULL, 4 }, |
| 224 | { 3, 0x47, "MBDATA7", NULL, 4 }, |
| 225 | { 3, 0x48, "MBDATA8", NULL, 4 }, |
| 226 | { 3, 0x49, "MBDATA9", NULL, 4 }, |
| 227 | { 3, 0x70, "DAREFTC", NULL, 4 }, |
| 228 | { 3, 0x74, "DSREFTC", NULL, 3 }, |
| 229 | { 3, 0x77, "MTR", NULL, 1 }, |
| 230 | { 3, 0x78, "DRT", NULL, 4 }, |
| 231 | { 3, 0x7c, "DRC", NULL, 4 }, |
| 232 | { 3, 0x80, "TEMPLO", NULL, 1 }, |
| 233 | { 3, 0x81, "TEMPMID", NULL, 1 }, |
| 234 | { 3, 0x82, "TEMPHI", NULL, 1 }, |
| 235 | { 3, 0x83, "UPDATED", NULL, 1 }, |
| 236 | { 3, 0x84, "TEMPSTAT", NULL, 1 }, |
| 237 | { 3, 0x85, "TEMP", NULL, 1 }, |
| 238 | { 3, 0x86, "TEMPOFFSET", NULL, 1 }, |
| 239 | { 3, 0x9c, "MB_START_ADDR", NULL, 4 }, |
| 240 | { 3, 0xa0, "MB_END_ADDR", NULL, 4 }, |
| 241 | { 3, 0xa4, "MBLFSRSEED", NULL, 4 }, |
| 242 | { 3, 0xa8, "MBFADDRPTR", NULL, 4 }, |
| 243 | { 3, 0xb0, "MB_ERR_DATA00", NULL, 4 }, |
| 244 | { 3, 0xb4, "MB_ERR_DATA01", NULL, 4 }, |
| 245 | { 3, 0xb8, "MB_ERR_DATA02", NULL, 4 }, |
| 246 | { 3, 0xbc, "MB_ERR_DATA03", NULL, 4 }, |
| 247 | { 3, 0xc0, "MB_ERR_DATA04", NULL, 2 }, |
| 248 | { 3, 0xc4, "MB_ERR_DATA10", NULL, 4 }, |
| 249 | { 3, 0xc8, "MB_ERR_DATA11", NULL, 4 }, |
| 250 | { 3, 0xcc, "MB_ERR_DATA12", NULL, 4 }, |
| 251 | { 3, 0xd0, "MB_ERR_DATA13", NULL, 4 }, |
| 252 | { 3, 0xd4, "MB_ERR_DATA14", NULL, 2 }, |
| 253 | |
| 254 | { 4, 0x40, "DCALCSR", NULL, 4 }, |
| 255 | { 4, 0x44, "DCALADDR", NULL, 4 }, |
| 256 | { 4, 0x98, "DSRETC", NULL, 4 }, |
| 257 | { 4, 0xa4, "S3RESTORE0", NULL, 4 }, |
| 258 | { 4, 0xa8, "S3RESTORE1", NULL, 4 }, |
| 259 | { 4, 0xac, "S3RESTORE2", NULL, 4 }, |
| 260 | { 4, 0xb0, "S3RESTORE3", NULL, 4 }, |
| 261 | { 4, 0xb4, "S3RESTORE4", NULL, 4 }, |
| 262 | { 4, 0xb8, "S3RESTORE5", NULL, 4 }, |
| 263 | { 4, 0xbc, "S3RESTORE6", NULL, 4 }, |
| 264 | { 4, 0xc0, "S3RESTORE7", NULL, 4 }, |
| 265 | { 4, 0xc4, "S3RESTORE8", NULL, 4 }, |
| 266 | { 4, 0xc8, "S3RESTORE9", NULL, 4 }, |
| 267 | { 4, 0xcc, "S3RESTORE10", NULL, 4 }, |
| 268 | { 4, 0xe8, "FIVESREG", NULL, 4 }, |
| 269 | { 4, 0xea, "AAAAREG", NULL, 4 }, |
| 270 | |
| 271 | { 5, 0x3c, "TRANSCFG", NULL, 4 }, |
| 272 | { 5, 0x40, "TRANDERR0", NULL, 2 }, |
| 273 | { 5, 0x42, "TRANDERR1", NULL, 2 }, |
| 274 | { 5, 0x44, "TRANDERR2", NULL, 2 }, |
| 275 | { 5, 0x46, "TRANDERR3", NULL, 2 }, |
| 276 | { 5, 0x48, "TRANDERR4", NULL, 2 }, |
| 277 | { 5, 0x4a, "TRANDERR5", NULL, 2 }, |
| 278 | { 5, 0x4c, "TRANDERR6", NULL, 2 }, |
| 279 | { 5, 0x4e, "TRANDERR7", NULL, 2 }, |
| 280 | { 5, 0x50, "TRANDERR8", NULL, 2 }, |
| 281 | { 5, 0x80, "TRANSCTRL", NULL, 1 }, |
| 282 | { 5, 0xbc, "SBMATCHU", NULL, 3 }, |
| 283 | { 5, 0xc0, "SBMATCHL0", NULL, 4 }, |
| 284 | { 5, 0xcc, "SBMASKU", NULL, 3 }, |
| 285 | { 5, 0xd0, "SBMASKL0", NULL, 4 }, |
| 286 | { 5, 0xe0, "EVENTSEL0", NULL, 3 }, |
| 287 | { 5, 0xfc, "EICNTL", NULL, 1 }, |
| 288 | { 5, 0xfe, "STUCKL", NULL, 1 }, |
| 289 | |
| 290 | { 6, 0x50, "NBRXSTATUS", NULL, 4 }, |
| 291 | { 6, 0x7c, "SPAD0", NULL, 4 }, |
| 292 | { 6, 0x80, "SBFIBPORTCTL", NULL, 4 }, |
| 293 | { 6, 0x84, "SBFIBPGCTL", NULL, 4 }, |
| 294 | { 6, 0x88, "SBFIBPATTBUF1", NULL, 3 }, |
| 295 | { 6, 0x8c, "SBFIBTXMSK", NULL, 2 }, |
| 296 | { 6, 0x90, "SBFIBRXMSK", NULL, 2 }, |
| 297 | { 6, 0x94, "SBFIBTXSHFT", NULL, 2 }, |
| 298 | { 6, 0x98, "SBFIBRXSHFT", NULL, 2 }, |
| 299 | { 6, 0x9c, "SBFIBRXLNERR", NULL, 2 }, |
| 300 | { 6, 0xa0, "SBFIBPATTBUF2", NULL, 3 }, |
| 301 | { 6, 0xa4, "SBFIBPATT2EN", NULL, 2 }, |
| 302 | { 6, 0xb0, "SBFIBINIT", NULL, 4 }, |
| 303 | { 6, 0xb4, "SBIBISTMISC", NULL, 3 }, |
| 304 | { 6, 0xc0, "NBFIBPORTCTL", NULL, 4 }, |
| 305 | { 6, 0xc4, "NBFIBPGCTL", NULL, 4 }, |
| 306 | { 6, 0xc8, "NBFIBPATTBUF1", NULL, 3 }, |
| 307 | { 6, 0xcc, "NBFIBTXMSK", NULL, 2 }, |
| 308 | { 6, 0xd0, "NBFIBRXMSK", NULL, 2 }, |
| 309 | { 6, 0xd4, "NBFIBTXSHFT", NULL, 2 }, |
| 310 | { 6, 0xd8, "NBFIBRXSHFT", NULL, 2 }, |
| 311 | { 6, 0xdc, "NBFIBRXLNERR", NULL, 2 }, |
| 312 | { 6, 0xe0, "NBFIBPATTBUF2", NULL, 3 }, |
| 313 | { 6, 0xe4, "NBFIBPATT2EN", NULL, 2 }, |
| 314 | { 6, 0xf0, "NBFIBINIT", NULL, 4 }, |
| 315 | { 6, 0xf4, "NBIBISTMISC", NULL, 3 }, |
| 316 | |
| 317 | { 7, 0x40, "ODRV_ADJ_ADDR_A", NULL, 3 }, |
| 318 | { 7, 0x43, "ODRV_ADJ_CAS_A", NULL, 3 }, |
| 319 | { 7, 0x46, "ODRV_ADJ_CKE_A", NULL, 3 }, |
| 320 | { 7, 0x49, "ODRV_ADJ_ODT_A", NULL, 3 }, |
| 321 | { 7, 0x4c, "ODRV_ADJ_ADDR_B", NULL, 3 }, |
| 322 | { 7, 0x4f, "ODRV_ADJ_CAS_B", NULL, 3 }, |
| 323 | { 7, 0x52, "ODRV_ADJ_CKE_B", NULL, 3 }, |
| 324 | { 7, 0x55, "ODRV_ADJ_ODT_B", NULL, 3 }, |
| 325 | { 7, 0x58, "ODRV_ADJ_CLK0", NULL, 3 }, |
| 326 | { 7, 0x5b, "ODRV_ADJ_CLK1", NULL, 3 }, |
| 327 | { 7, 0x5e, "ODRV_ADJ_CLK2", NULL, 3 }, |
| 328 | { 7, 0x61, "ODRV_ADJ_CLK3", NULL, 3 }, |
| 329 | { 7, 0x64, "ODRV_ADJ_DQ_DQS", NULL, 3 }, |
| 330 | { 7, 0x67, "DDR_ODTCTL", NULL, 1 }, |
| 331 | { 7, 0x69, "DDR_ZCAL", NULL, 2 }, |
| 332 | { 7, 0x6c, "DDR_ZCTL", NULL, 4 }, |
| 333 | { 7, 0x78, "VHOSTCNTL", NULL, 1 }, |
| 334 | { 7, 0x79, "DQSDLY_SMBUSCTL", NULL, 1 }, |
| 335 | { 7, 0x7c, "SPAD1", NULL, 4 }, |
| 336 | { 7, 0x80, "CTL_ADDR_A", NULL, 1 }, |
| 337 | { 7, 0x81, "CTL_CAS_A", NULL, 1 }, |
| 338 | { 7, 0x82, "CTL_CKE_A", NULL, 1 }, |
| 339 | { 7, 0x83, "CTL_ODT_A", NULL, 1 }, |
| 340 | { 7, 0x84, "CTL_ADDR_B", NULL, 1 }, |
| 341 | { 7, 0x85, "CTL_CAS_B", NULL, 1 }, |
| 342 | { 7, 0x86, "CTL_CKE_B", NULL, 1 }, |
| 343 | { 7, 0x87, "CTL_ODT_B", NULL, 1 }, |
| 344 | { 7, 0x88, "CTL_CLK0", NULL, 1 }, |
| 345 | { 7, 0x89, "CTL_CLK1", NULL, 1 }, |
| 346 | { 7, 0x8a, "CTL_CLK2", NULL, 1 }, |
| 347 | { 7, 0x8b, "CTL_CLK3", NULL, 1 }, |
| 348 | { 7, 0x8c, "CTL_DQ", NULL, 1 }, |
| 349 | { 7, 0x8d, "CTL_DQS", NULL, 1 }, |
| 350 | { 0, 0x00, NULL, NULL, 0 }, |
| 351 | }; |
| 352 | |
| 353 | static void dump_amb(volatile void *ambconfig, int branch, int channel, int amb) |
| 354 | { |
| 355 | struct amb_register *reg; |
| 356 | static int lastreg, lastfn; |
| 357 | int bytes; |
| 358 | |
| 359 | volatile void *base = ambconfig + \ |
| 360 | ((branch << 16) | (channel << 15) | (amb << 11)); |
| 361 | |
| 362 | if ((amb_read_config32(base, 0, 0) == 0xffffffff) | |
| 363 | (amb_read_config32(base, 0, 0) == 0x00000000)) |
| 364 | return; |
| 365 | |
| 366 | printf("AMB %d, branch %d, channel %d register dump:\n" |
| 367 | "============================================\n", |
| 368 | amb, branch, channel); |
| 369 | |
| 370 | for(reg = amb_registers; reg->name; reg++) { |
| 371 | if (reg->fn == lastfn && reg->offset > 0 && reg->offset - lastreg) { |
| 372 | bytes = reg->offset - lastreg; |
| 373 | |
| 374 | do { |
| 375 | if (!(lastreg & 3) && bytes >= 4) { |
| 376 | amb_printreg32(base, reg->fn, lastreg, "RESERVED", 0); |
| 377 | bytes -= 4; |
| 378 | lastreg += 4; |
| 379 | } else if (!(lastreg & 1) && bytes >= 2) { |
| 380 | amb_printreg16(base, reg->fn, lastreg, "RESERVED", 0); |
| 381 | bytes -= 2; |
| 382 | lastreg += 2; |
| 383 | } else { |
| 384 | amb_printreg8(base, reg->fn, lastreg, "RESERVED", 0); |
| 385 | bytes -= 1; |
| 386 | lastreg += 1; |
| 387 | } |
| 388 | } while(bytes > 0); |
| 389 | } |
| 390 | |
| 391 | switch(reg->width) { |
| 392 | case 1: |
| 393 | amb_printreg8(base, reg->fn, reg->offset, reg->name, 1); |
| 394 | break; |
| 395 | case 2: |
| 396 | amb_printreg16(base, reg->fn, reg->offset, reg->name, 1); |
| 397 | break; |
| 398 | |
| 399 | case 3: |
| 400 | amb_printreg24(base, reg->fn, reg->offset, reg->name, 1); |
| 401 | break; |
| 402 | |
| 403 | case 4: |
| 404 | amb_printreg32(base, reg->fn, reg->offset, reg->name, 1); |
| 405 | break; |
| 406 | |
| 407 | default: |
| 408 | break; |
| 409 | } |
| 410 | |
| 411 | if (reg->printfunc) |
| 412 | reg->printfunc(base, reg->fn, reg->offset, reg->name, 1); |
| 413 | lastreg = reg->offset + reg->width; |
| 414 | lastfn = reg->fn; |
| 415 | } |
| 416 | printf("\n\n"); |
| 417 | } |
| 418 | |
| 419 | int print_ambs(struct pci_dev *dev, struct pci_access *pacc) |
| 420 | { |
| 421 | struct pci_dev *dev16; |
| 422 | int branch, channel, amb; |
| 423 | int max_branch, max_channel, max_amb; |
| 424 | volatile void *ambconfig; |
| 425 | uint64_t ambconfig_phys; |
| 426 | |
| 427 | printf("\n============= AMBs ============\n\n"); |
| 428 | |
| 429 | switch (dev->device_id) { |
| 430 | case PCI_DEVICE_ID_INTEL_I5000P: |
| 431 | case PCI_DEVICE_ID_INTEL_I5000X: |
| 432 | case PCI_DEVICE_ID_INTEL_I5000Z: |
| 433 | |
| 434 | max_branch = 2; |
| 435 | |
| 436 | if (!(dev16 = pci_get_dev(pacc, 0, 0, 0x10, 0))) { |
| 437 | perror("Error: no device 0:16.0\n"); |
| 438 | return 1; |
| 439 | } |
| 440 | |
| 441 | ambconfig_phys = ((u64)pci_read_long(dev16, 0x4c) << 32) | |
| 442 | pci_read_long(dev16, 0x48); |
| 443 | |
| 444 | max_channel = pci_read_byte(dev16, 0x56)/max_branch; |
| 445 | max_amb = pci_read_byte(dev16, 0x57); |
| 446 | break; |
| 447 | |
| 448 | default: |
| 449 | fprintf(stderr, "Error: Dumping AMBs on this MCH is not (yet) supported.\n"); |
| 450 | return 1; |
| 451 | } |
| 452 | |
| 453 | if (!(ambconfig = map_physical(ambconfig_phys, AMB_CONFIG_SPACE_SIZE))) { |
| 454 | fprintf(stderr, "Error mapping AMB config space\n"); |
| 455 | return 1; |
| 456 | } |
| 457 | |
| 458 | for(branch = 0; branch < max_branch; branch++) { |
| 459 | for(channel = 0; channel < max_channel; channel++) { |
| 460 | for(amb = 0; amb < max_amb; amb++) { |
| 461 | dump_amb(ambconfig, branch, channel, amb); |
| 462 | } |
| 463 | } |
| 464 | } |
| 465 | unmap_physical((void *)ambconfig, AMB_CONFIG_SPACE_SIZE); |
| 466 | return 0; |
| 467 | } |
| 468 | |
| 469 | |