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