wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 2 | * (C) Copyright 2000-2003 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * MPC8xx/MPC8260 Internal Memory Map Functions |
| 10 | */ |
| 11 | |
| 12 | #include <common.h> |
| 13 | #include <command.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 14 | |
Grant Likely | c0d32e9 | 2007-09-24 09:05:31 -0600 | [diff] [blame] | 15 | #if defined(CONFIG_8xx) || defined(CONFIG_8260) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 16 | |
| 17 | #if defined(CONFIG_8xx) |
| 18 | #include <asm/8xx_immap.h> |
| 19 | #include <commproc.h> |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 20 | #include <asm/iopin_8xx.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 21 | #elif defined(CONFIG_8260) |
| 22 | #include <asm/immap_8260.h> |
| 23 | #include <asm/cpm_8260.h> |
| 24 | #include <asm/iopin_8260.h> |
| 25 | #endif |
| 26 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 27 | DECLARE_GLOBAL_DATA_PTR; |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 28 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 29 | static void |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 30 | unimplemented ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 31 | { |
| 32 | printf ("Sorry, but the '%s' command has not been implemented\n", |
| 33 | cmdtp->name); |
| 34 | } |
| 35 | |
| 36 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 37 | do_siuinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 38 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 39 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 40 | |
| 41 | #if defined(CONFIG_8xx) |
| 42 | volatile sysconf8xx_t *sc = &immap->im_siu_conf; |
| 43 | #elif defined(CONFIG_8260) |
| 44 | volatile sysconf8260_t *sc = &immap->im_siu_conf; |
| 45 | #endif |
| 46 | |
| 47 | printf ("SIUMCR= %08x SYPCR = %08x\n", sc->sc_siumcr, sc->sc_sypcr); |
| 48 | #if defined(CONFIG_8xx) |
| 49 | printf ("SWT = %08x\n", sc->sc_swt); |
| 50 | printf ("SIPEND= %08x SIMASK= %08x\n", sc->sc_sipend, sc->sc_simask); |
| 51 | printf ("SIEL = %08x SIVEC = %08x\n", sc->sc_siel, sc->sc_sivec); |
| 52 | printf ("TESR = %08x SDCR = %08x\n", sc->sc_tesr, sc->sc_sdcr); |
| 53 | #elif defined(CONFIG_8260) |
| 54 | printf ("BCR = %08x\n", sc->sc_bcr); |
| 55 | printf ("P_ACR = %02x P_ALRH= %08x P_ALRL= %08x\n", |
| 56 | sc->sc_ppc_acr, sc->sc_ppc_alrh, sc->sc_ppc_alrl); |
| 57 | printf ("L_ACR = %02x L_ALRH= %08x L_ALRL= %08x\n", |
| 58 | sc->sc_lcl_acr, sc->sc_lcl_alrh, sc->sc_lcl_alrl); |
| 59 | printf ("PTESR1= %08x PTESR2= %08x\n", sc->sc_tescr1, sc->sc_tescr2); |
| 60 | printf ("LTESR1= %08x LTESR2= %08x\n", sc->sc_ltescr1, sc->sc_ltescr2); |
| 61 | printf ("PDTEA = %08x PDTEM = %02x\n", sc->sc_pdtea, sc->sc_pdtem); |
| 62 | printf ("LDTEA = %08x LDTEM = %02x\n", sc->sc_ldtea, sc->sc_ldtem); |
| 63 | #endif |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 68 | do_memcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 69 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 70 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 71 | |
| 72 | #if defined(CONFIG_8xx) |
| 73 | volatile memctl8xx_t *memctl = &immap->im_memctl; |
| 74 | int nbanks = 8; |
| 75 | #elif defined(CONFIG_8260) |
| 76 | volatile memctl8260_t *memctl = &immap->im_memctl; |
| 77 | int nbanks = 12; |
| 78 | #endif |
| 79 | volatile uint *p = &memctl->memc_br0; |
| 80 | int i; |
| 81 | |
| 82 | for (i = 0; i < nbanks; i++, p += 2) { |
| 83 | if (i < 10) { |
| 84 | printf ("BR%d = %08x OR%d = %08x\n", |
| 85 | i, p[0], i, p[1]); |
| 86 | } else { |
| 87 | printf ("BR%d = %08x OR%d = %08x\n", |
| 88 | i, p[0], i, p[1]); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | printf ("MAR = %08x", memctl->memc_mar); |
| 93 | #if defined(CONFIG_8xx) |
| 94 | printf (" MCR = %08x\n", memctl->memc_mcr); |
| 95 | #elif defined(CONFIG_8260) |
wdenk | 42c0547 | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 96 | putc ('\n'); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 97 | #endif |
| 98 | printf ("MAMR = %08x MBMR = %08x", |
| 99 | memctl->memc_mamr, memctl->memc_mbmr); |
| 100 | #if defined(CONFIG_8xx) |
| 101 | printf ("\nMSTAT = %04x\n", memctl->memc_mstat); |
| 102 | #elif defined(CONFIG_8260) |
| 103 | printf (" MCMR = %08x\n", memctl->memc_mcmr); |
| 104 | #endif |
| 105 | printf ("MPTPR = %04x MDR = %08x\n", |
| 106 | memctl->memc_mptpr, memctl->memc_mdr); |
| 107 | #if defined(CONFIG_8260) |
| 108 | printf ("PSDMR = %08x LSDMR = %08x\n", |
| 109 | memctl->memc_psdmr, memctl->memc_lsdmr); |
| 110 | printf ("PURT = %02x PSRT = %02x\n", |
| 111 | memctl->memc_purt, memctl->memc_psrt); |
| 112 | printf ("LURT = %02x LSRT = %02x\n", |
| 113 | memctl->memc_lurt, memctl->memc_lsrt); |
| 114 | printf ("IMMR = %08x\n", memctl->memc_immr); |
| 115 | #endif |
| 116 | return 0; |
| 117 | } |
| 118 | |
| 119 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 120 | do_sitinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 121 | { |
| 122 | unimplemented (cmdtp, flag, argc, argv); |
| 123 | return 0; |
| 124 | } |
| 125 | |
| 126 | #ifdef CONFIG_8260 |
| 127 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 128 | do_icinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 129 | { |
| 130 | unimplemented (cmdtp, flag, argc, argv); |
| 131 | return 0; |
| 132 | } |
| 133 | #endif |
| 134 | |
| 135 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 136 | do_carinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 137 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 138 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 139 | |
| 140 | #if defined(CONFIG_8xx) |
| 141 | volatile car8xx_t *car = &immap->im_clkrst; |
| 142 | #elif defined(CONFIG_8260) |
| 143 | volatile car8260_t *car = &immap->im_clkrst; |
| 144 | #endif |
| 145 | |
| 146 | #if defined(CONFIG_8xx) |
| 147 | printf ("SCCR = %08x\n", car->car_sccr); |
| 148 | printf ("PLPRCR= %08x\n", car->car_plprcr); |
| 149 | printf ("RSR = %08x\n", car->car_rsr); |
| 150 | #elif defined(CONFIG_8260) |
| 151 | printf ("SCCR = %08x\n", car->car_sccr); |
| 152 | printf ("SCMR = %08x\n", car->car_scmr); |
| 153 | printf ("RSR = %08x\n", car->car_rsr); |
| 154 | printf ("RMR = %08x\n", car->car_rmr); |
| 155 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 156 | return 0; |
| 157 | } |
| 158 | |
| 159 | static int counter; |
| 160 | |
| 161 | static void |
| 162 | header(void) |
| 163 | { |
| 164 | char *data = "\ |
| 165 | -------------------------------- --------------------------------\ |
| 166 | 00000000001111111111222222222233 00000000001111111111222222222233\ |
| 167 | 01234567890123456789012345678901 01234567890123456789012345678901\ |
| 168 | -------------------------------- --------------------------------\ |
| 169 | "; |
| 170 | int i; |
| 171 | |
| 172 | if (counter % 2) |
wdenk | 381669a | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 173 | putc('\n'); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 174 | counter = 0; |
| 175 | |
| 176 | for (i = 0; i < 4; i++, data += 79) |
| 177 | printf("%.79s\n", data); |
| 178 | } |
| 179 | |
| 180 | static void binary (char *label, uint value, int nbits) |
| 181 | { |
| 182 | uint mask = 1 << (nbits - 1); |
| 183 | int i, second = (counter++ % 2); |
| 184 | |
| 185 | if (second) |
| 186 | putc (' '); |
| 187 | puts (label); |
| 188 | for (i = 32 + 1; i != nbits; i--) |
| 189 | putc (' '); |
| 190 | |
| 191 | while (mask != 0) { |
| 192 | if (value & mask) |
| 193 | putc ('1'); |
| 194 | else |
| 195 | putc ('0'); |
| 196 | mask >>= 1; |
| 197 | } |
| 198 | |
| 199 | if (second) |
| 200 | putc ('\n'); |
| 201 | } |
| 202 | |
| 203 | #if defined(CONFIG_8xx) |
| 204 | #define PA_NBITS 16 |
| 205 | #define PA_NB_ODR 8 |
| 206 | #define PB_NBITS 18 |
| 207 | #define PB_NB_ODR 16 |
| 208 | #define PC_NBITS 12 |
| 209 | #define PD_NBITS 13 |
| 210 | #elif defined(CONFIG_8260) |
| 211 | #define PA_NBITS 32 |
| 212 | #define PA_NB_ODR 32 |
| 213 | #define PB_NBITS 28 |
| 214 | #define PB_NB_ODR 28 |
| 215 | #define PC_NBITS 32 |
| 216 | #define PD_NBITS 28 |
| 217 | #endif |
| 218 | |
| 219 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 220 | do_iopinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 221 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 222 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 223 | |
| 224 | #if defined(CONFIG_8xx) |
| 225 | volatile iop8xx_t *iop = &immap->im_ioport; |
| 226 | volatile ushort *l, *r; |
| 227 | #elif defined(CONFIG_8260) |
| 228 | volatile iop8260_t *iop = &immap->im_ioport; |
| 229 | volatile uint *l, *r; |
| 230 | #endif |
| 231 | volatile uint *R; |
| 232 | |
| 233 | counter = 0; |
| 234 | header (); |
| 235 | |
| 236 | /* |
| 237 | * Ports A & B |
| 238 | */ |
| 239 | |
| 240 | #if defined(CONFIG_8xx) |
| 241 | l = &iop->iop_padir; |
| 242 | R = &immap->im_cpm.cp_pbdir; |
| 243 | #elif defined(CONFIG_8260) |
| 244 | l = &iop->iop_pdira; |
| 245 | R = &iop->iop_pdirb; |
| 246 | #endif |
| 247 | binary ("PA_DIR", *l++, PA_NBITS); |
| 248 | binary ("PB_DIR", *R++, PB_NBITS); |
| 249 | binary ("PA_PAR", *l++, PA_NBITS); |
| 250 | binary ("PB_PAR", *R++, PB_NBITS); |
| 251 | #if defined(CONFIG_8260) |
| 252 | binary ("PA_SOR", *l++, PA_NBITS); |
| 253 | binary ("PB_SOR", *R++, PB_NBITS); |
| 254 | #endif |
| 255 | binary ("PA_ODR", *l++, PA_NB_ODR); |
| 256 | binary ("PB_ODR", *R++, PB_NB_ODR); |
| 257 | binary ("PA_DAT", *l++, PA_NBITS); |
| 258 | binary ("PB_DAT", *R++, PB_NBITS); |
| 259 | |
| 260 | header (); |
| 261 | |
| 262 | /* |
| 263 | * Ports C & D |
| 264 | */ |
| 265 | |
| 266 | #if defined(CONFIG_8xx) |
| 267 | l = &iop->iop_pcdir; |
| 268 | r = &iop->iop_pddir; |
| 269 | #elif defined(CONFIG_8260) |
| 270 | l = &iop->iop_pdirc; |
| 271 | r = &iop->iop_pdird; |
| 272 | #endif |
| 273 | binary ("PC_DIR", *l++, PC_NBITS); |
| 274 | binary ("PD_DIR", *r++, PD_NBITS); |
| 275 | binary ("PC_PAR", *l++, PC_NBITS); |
| 276 | binary ("PD_PAR", *r++, PD_NBITS); |
| 277 | #if defined(CONFIG_8xx) |
| 278 | binary ("PC_SO ", *l++, PC_NBITS); |
| 279 | binary (" ", 0, 0); |
| 280 | r++; |
| 281 | #elif defined(CONFIG_8260) |
| 282 | binary ("PC_SOR", *l++, PC_NBITS); |
| 283 | binary ("PD_SOR", *r++, PD_NBITS); |
| 284 | binary ("PC_ODR", *l++, PC_NBITS); |
| 285 | binary ("PD_ODR", *r++, PD_NBITS); |
| 286 | #endif |
| 287 | binary ("PC_DAT", *l++, PC_NBITS); |
| 288 | binary ("PD_DAT", *r++, PD_NBITS); |
| 289 | #if defined(CONFIG_8xx) |
| 290 | binary ("PC_INT", *l++, PC_NBITS); |
| 291 | #endif |
| 292 | |
| 293 | header (); |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | /* |
| 298 | * set the io pins |
| 299 | * this needs a clean up for smaller tighter code |
| 300 | * use *uint and set the address based on cmd + port |
| 301 | */ |
| 302 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 303 | do_iopset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 304 | { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 305 | uint rcode = 0; |
Wolfgang Denk | 27a5b0b | 2005-10-13 01:45:54 +0200 | [diff] [blame] | 306 | iopin_t iopin; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 307 | static uint port = 0; |
| 308 | static uint pin = 0; |
| 309 | static uint value = 0; |
Wolfgang Denk | 27a5b0b | 2005-10-13 01:45:54 +0200 | [diff] [blame] | 310 | static enum { |
| 311 | DIR, |
| 312 | PAR, |
| 313 | SOR, |
| 314 | ODR, |
| 315 | DAT, |
| 316 | #if defined(CONFIG_8xx) |
| 317 | INT |
| 318 | #endif |
| 319 | } cmd = DAT; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 320 | |
| 321 | if (argc != 5) { |
wdenk | 42c0547 | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 322 | puts ("iopset PORT PIN CMD VALUE\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 323 | return 1; |
| 324 | } |
| 325 | port = argv[1][0] - 'A'; |
| 326 | if (port > 3) |
| 327 | port -= 0x20; |
| 328 | if (port > 3) |
| 329 | rcode = 1; |
| 330 | pin = simple_strtol (argv[2], NULL, 10); |
| 331 | if (pin > 31) |
| 332 | rcode = 1; |
| 333 | |
| 334 | |
| 335 | switch (argv[3][0]) { |
| 336 | case 'd': |
| 337 | if (argv[3][1] == 'a') |
| 338 | cmd = DAT; |
| 339 | else if (argv[3][1] == 'i') |
| 340 | cmd = DIR; |
| 341 | else |
| 342 | rcode = 1; |
| 343 | break; |
| 344 | case 'p': |
| 345 | cmd = PAR; |
| 346 | break; |
| 347 | case 'o': |
| 348 | cmd = ODR; |
| 349 | break; |
| 350 | case 's': |
| 351 | cmd = SOR; |
| 352 | break; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 353 | #if defined(CONFIG_8xx) |
| 354 | case 'i': |
| 355 | cmd = INT; |
| 356 | break; |
| 357 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 358 | default: |
| 359 | printf ("iopset: unknown command %s\n", argv[3]); |
| 360 | rcode = 1; |
| 361 | } |
| 362 | if (argv[4][0] == '1') |
| 363 | value = 1; |
| 364 | else if (argv[4][0] == '0') |
| 365 | value = 0; |
| 366 | else |
| 367 | rcode = 1; |
| 368 | if (rcode == 0) { |
| 369 | iopin.port = port; |
| 370 | iopin.pin = pin; |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 371 | iopin.flag = 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 372 | switch (cmd) { |
| 373 | case DIR: |
| 374 | if (value) |
| 375 | iopin_set_out (&iopin); |
| 376 | else |
| 377 | iopin_set_in (&iopin); |
| 378 | break; |
| 379 | case PAR: |
| 380 | if (value) |
| 381 | iopin_set_ded (&iopin); |
| 382 | else |
| 383 | iopin_set_gen (&iopin); |
| 384 | break; |
| 385 | case SOR: |
| 386 | if (value) |
| 387 | iopin_set_opt2 (&iopin); |
| 388 | else |
| 389 | iopin_set_opt1 (&iopin); |
| 390 | break; |
| 391 | case ODR: |
| 392 | if (value) |
| 393 | iopin_set_odr (&iopin); |
| 394 | else |
| 395 | iopin_set_act (&iopin); |
| 396 | break; |
| 397 | case DAT: |
| 398 | if (value) |
| 399 | iopin_set_high (&iopin); |
| 400 | else |
| 401 | iopin_set_low (&iopin); |
| 402 | break; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 403 | #if defined(CONFIG_8xx) |
| 404 | case INT: |
| 405 | if (value) |
| 406 | iopin_set_falledge (&iopin); |
| 407 | else |
| 408 | iopin_set_anyedge (&iopin); |
| 409 | break; |
| 410 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | } |
| 414 | return rcode; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 418 | do_dmainfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 419 | { |
| 420 | unimplemented (cmdtp, flag, argc, argv); |
| 421 | return 0; |
| 422 | } |
| 423 | |
| 424 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 425 | do_fccinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 426 | { |
| 427 | unimplemented (cmdtp, flag, argc, argv); |
| 428 | return 0; |
| 429 | } |
| 430 | |
| 431 | static void prbrg (int n, uint val) |
| 432 | { |
| 433 | uint extc = (val >> 14) & 3; |
| 434 | uint cd = (val & CPM_BRG_CD_MASK) >> 1; |
| 435 | uint div16 = (val & CPM_BRG_DIV16) != 0; |
| 436 | |
| 437 | #if defined(CONFIG_8xx) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 438 | ulong clock = gd->cpu_clk; |
| 439 | #elif defined(CONFIG_8260) |
Simon Glass | 34a194f | 2012-12-13 20:48:44 +0000 | [diff] [blame] | 440 | ulong clock = gd->arch.brg_clk; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 441 | #endif |
| 442 | |
| 443 | printf ("BRG%d:", n); |
| 444 | |
| 445 | if (val & CPM_BRG_RST) |
| 446 | puts (" RESET"); |
| 447 | else |
| 448 | puts (" "); |
| 449 | |
| 450 | if (val & CPM_BRG_EN) |
| 451 | puts (" ENABLED"); |
| 452 | else |
| 453 | puts (" DISABLED"); |
| 454 | |
| 455 | printf (" EXTC=%d", extc); |
| 456 | |
| 457 | if (val & CPM_BRG_ATB) |
| 458 | puts (" ATB"); |
| 459 | else |
| 460 | puts (" "); |
| 461 | |
| 462 | printf (" DIVIDER=%4d", cd); |
| 463 | if (extc == 0 && cd != 0) { |
| 464 | uint baudrate; |
| 465 | |
| 466 | if (div16) |
| 467 | baudrate = (clock / 16) / (cd + 1); |
| 468 | else |
| 469 | baudrate = clock / (cd + 1); |
| 470 | |
| 471 | printf ("=%6d bps", baudrate); |
| 472 | } else { |
| 473 | puts (" "); |
| 474 | } |
| 475 | |
| 476 | if (val & CPM_BRG_DIV16) |
| 477 | puts (" DIV16"); |
| 478 | else |
| 479 | puts (" "); |
| 480 | |
| 481 | putc ('\n'); |
| 482 | } |
| 483 | |
| 484 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 485 | do_brginfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 486 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 487 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 488 | |
| 489 | #if defined(CONFIG_8xx) |
| 490 | volatile cpm8xx_t *cp = &immap->im_cpm; |
| 491 | volatile uint *p = &cp->cp_brgc1; |
| 492 | #elif defined(CONFIG_8260) |
| 493 | volatile uint *p = &immap->im_brgc1; |
| 494 | #endif |
| 495 | int i = 1; |
| 496 | |
| 497 | while (i <= 4) |
| 498 | prbrg (i++, *p++); |
| 499 | |
| 500 | #if defined(CONFIG_8260) |
| 501 | p = &immap->im_brgc5; |
| 502 | while (i <= 8) |
| 503 | prbrg (i++, *p++); |
| 504 | #endif |
| 505 | return 0; |
| 506 | } |
| 507 | |
| 508 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 509 | do_i2cinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 510 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 511 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 512 | |
| 513 | #if defined(CONFIG_8xx) |
| 514 | volatile i2c8xx_t *i2c = &immap->im_i2c; |
| 515 | volatile cpm8xx_t *cp = &immap->im_cpm; |
| 516 | volatile iic_t *iip = (iic_t *) & cp->cp_dparam[PROFF_IIC]; |
| 517 | #elif defined(CONFIG_8260) |
| 518 | volatile i2c8260_t *i2c = &immap->im_i2c; |
| 519 | volatile iic_t *iip; |
| 520 | uint dpaddr; |
| 521 | |
Scott Wood | 8a88e9f | 2013-05-17 20:01:54 -0500 | [diff] [blame] | 522 | dpaddr = immap->im_dprambase16[PROFF_I2C_BASE / sizeof(u16)]; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 523 | if (dpaddr == 0) |
| 524 | iip = NULL; |
| 525 | else |
| 526 | iip = (iic_t *) & immap->im_dprambase[dpaddr]; |
| 527 | #endif |
| 528 | |
| 529 | printf ("I2MOD = %02x I2ADD = %02x\n", i2c->i2c_i2mod, i2c->i2c_i2add); |
| 530 | printf ("I2BRG = %02x I2COM = %02x\n", i2c->i2c_i2brg, i2c->i2c_i2com); |
| 531 | printf ("I2CER = %02x I2CMR = %02x\n", i2c->i2c_i2cer, i2c->i2c_i2cmr); |
| 532 | |
| 533 | if (iip == NULL) |
wdenk | 42c0547 | 2004-03-23 22:14:11 +0000 | [diff] [blame] | 534 | puts ("i2c parameter ram not allocated\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 535 | else { |
| 536 | printf ("RBASE = %08x TBASE = %08x\n", |
| 537 | iip->iic_rbase, iip->iic_tbase); |
| 538 | printf ("RFCR = %02x TFCR = %02x\n", |
| 539 | iip->iic_rfcr, iip->iic_tfcr); |
| 540 | printf ("MRBLR = %04x\n", iip->iic_mrblr); |
| 541 | printf ("RSTATE= %08x RDP = %08x\n", |
| 542 | iip->iic_rstate, iip->iic_rdp); |
| 543 | printf ("RBPTR = %04x RBC = %04x\n", |
| 544 | iip->iic_rbptr, iip->iic_rbc); |
| 545 | printf ("RXTMP = %08x\n", iip->iic_rxtmp); |
| 546 | printf ("TSTATE= %08x TDP = %08x\n", |
| 547 | iip->iic_tstate, iip->iic_tdp); |
| 548 | printf ("TBPTR = %04x TBC = %04x\n", |
| 549 | iip->iic_tbptr, iip->iic_tbc); |
| 550 | printf ("TXTMP = %08x\n", iip->iic_txtmp); |
| 551 | } |
| 552 | return 0; |
| 553 | } |
| 554 | |
| 555 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 556 | do_sccinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 557 | { |
| 558 | unimplemented (cmdtp, flag, argc, argv); |
| 559 | return 0; |
| 560 | } |
| 561 | |
| 562 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 563 | do_smcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 564 | { |
| 565 | unimplemented (cmdtp, flag, argc, argv); |
| 566 | return 0; |
| 567 | } |
| 568 | |
| 569 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 570 | do_spiinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 571 | { |
| 572 | unimplemented (cmdtp, flag, argc, argv); |
| 573 | return 0; |
| 574 | } |
| 575 | |
| 576 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 577 | do_muxinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 578 | { |
| 579 | unimplemented (cmdtp, flag, argc, argv); |
| 580 | return 0; |
| 581 | } |
| 582 | |
| 583 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 584 | do_siinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 585 | { |
| 586 | unimplemented (cmdtp, flag, argc, argv); |
| 587 | return 0; |
| 588 | } |
| 589 | |
| 590 | int |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 591 | do_mccinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 592 | { |
| 593 | unimplemented (cmdtp, flag, argc, argv); |
| 594 | return 0; |
| 595 | } |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 596 | |
| 597 | /***************************************************/ |
| 598 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 599 | U_BOOT_CMD( |
| 600 | siuinfo, 1, 1, do_siuinfo, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 601 | "print System Interface Unit (SIU) registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 602 | "" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 603 | ); |
| 604 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 605 | U_BOOT_CMD( |
| 606 | memcinfo, 1, 1, do_memcinfo, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 607 | "print Memory Controller registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 608 | "" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 609 | ); |
| 610 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 611 | U_BOOT_CMD( |
| 612 | sitinfo, 1, 1, do_sitinfo, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 613 | "print System Integration Timers (SIT) registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 614 | "" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 615 | ); |
| 616 | |
| 617 | #ifdef CONFIG_8260 |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 618 | U_BOOT_CMD( |
| 619 | icinfo, 1, 1, do_icinfo, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 620 | "print Interrupt Controller registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 621 | "" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 622 | ); |
| 623 | #endif |
| 624 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 625 | U_BOOT_CMD( |
| 626 | carinfo, 1, 1, do_carinfo, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 627 | "print Clocks and Reset registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 628 | "" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 629 | ); |
| 630 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 631 | U_BOOT_CMD( |
| 632 | iopinfo, 1, 1, do_iopinfo, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 633 | "print I/O Port registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 634 | "" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 635 | ); |
| 636 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 637 | U_BOOT_CMD( |
| 638 | iopset, 5, 0, do_iopset, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 639 | "set I/O Port registers", |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 640 | "PORT PIN CMD VALUE\nPORT: A-D, PIN: 0-31, CMD: [dat|dir|odr|sor], VALUE: 0|1" |
| 641 | ); |
| 642 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 643 | U_BOOT_CMD( |
| 644 | dmainfo, 1, 1, do_dmainfo, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 645 | "print SDMA/IDMA registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 646 | "" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 647 | ); |
| 648 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 649 | U_BOOT_CMD( |
| 650 | fccinfo, 1, 1, do_fccinfo, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 651 | "print FCC registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 652 | "" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 653 | ); |
| 654 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 655 | U_BOOT_CMD( |
| 656 | brginfo, 1, 1, do_brginfo, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 657 | "print Baud Rate Generator (BRG) registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 658 | "" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 659 | ); |
| 660 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 661 | U_BOOT_CMD( |
| 662 | i2cinfo, 1, 1, do_i2cinfo, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 663 | "print I2C registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 664 | "" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 665 | ); |
| 666 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 667 | U_BOOT_CMD( |
| 668 | sccinfo, 1, 1, do_sccinfo, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 669 | "print SCC registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 670 | "" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 671 | ); |
| 672 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 673 | U_BOOT_CMD( |
| 674 | smcinfo, 1, 1, do_smcinfo, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 675 | "print SMC registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 676 | "" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 677 | ); |
| 678 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 679 | U_BOOT_CMD( |
| 680 | spiinfo, 1, 1, do_spiinfo, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 681 | "print Serial Peripheral Interface (SPI) registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 682 | "" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 683 | ); |
| 684 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 685 | U_BOOT_CMD( |
| 686 | muxinfo, 1, 1, do_muxinfo, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 687 | "print CPM Multiplexing registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 688 | "" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 689 | ); |
| 690 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 691 | U_BOOT_CMD( |
| 692 | siinfo, 1, 1, do_siinfo, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 693 | "print Serial Interface (SI) registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 694 | "" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 695 | ); |
| 696 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 697 | U_BOOT_CMD( |
| 698 | mccinfo, 1, 1, do_mccinfo, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 699 | "print MCC registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 700 | "" |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 701 | ); |
| 702 | |
Jon Loeliger | d704d91 | 2007-07-10 11:02:44 -0500 | [diff] [blame] | 703 | #endif |