2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
9 * MPC8xx/MPC8260 Internal Memory Map Functions
15 #if defined(CONFIG_8xx) || defined(CONFIG_MPC8260)
17 #if defined(CONFIG_8xx)
18 #include <asm/8xx_immap.h>
20 #include <asm/iopin_8xx.h>
21 #elif defined(CONFIG_MPC8260)
22 #include <asm/immap_8260.h>
23 #include <asm/cpm_8260.h>
24 #include <asm/iopin_8260.h>
27 DECLARE_GLOBAL_DATA_PTR;
30 unimplemented ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
32 printf ("Sorry, but the '%s' command has not been implemented\n",
37 do_siuinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
39 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
41 #if defined(CONFIG_8xx)
42 volatile sysconf8xx_t *sc = &immap->im_siu_conf;
43 #elif defined(CONFIG_MPC8260)
44 volatile sysconf8260_t *sc = &immap->im_siu_conf;
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_MPC8260)
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);
68 do_memcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
70 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
72 #if defined(CONFIG_8xx)
73 volatile memctl8xx_t *memctl = &immap->im_memctl;
75 #elif defined(CONFIG_MPC8260)
76 volatile memctl8260_t *memctl = &immap->im_memctl;
79 volatile uint *p = &memctl->memc_br0;
82 for (i = 0; i < nbanks; i++, p += 2) {
84 printf ("BR%d = %08x OR%d = %08x\n",
87 printf ("BR%d = %08x OR%d = %08x\n",
92 printf ("MAR = %08x", memctl->memc_mar);
93 #if defined(CONFIG_8xx)
94 printf (" MCR = %08x\n", memctl->memc_mcr);
95 #elif defined(CONFIG_MPC8260)
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_MPC8260)
103 printf (" MCMR = %08x\n", memctl->memc_mcmr);
105 printf ("MPTPR = %04x MDR = %08x\n",
106 memctl->memc_mptpr, memctl->memc_mdr);
107 #if defined(CONFIG_MPC8260)
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);
120 do_sitinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
122 unimplemented (cmdtp, flag, argc, argv);
126 #ifdef CONFIG_MPC8260
128 do_icinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
130 unimplemented (cmdtp, flag, argc, argv);
136 do_carinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
138 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
140 #if defined(CONFIG_8xx)
141 volatile car8xx_t *car = &immap->im_clkrst;
142 #elif defined(CONFIG_MPC8260)
143 volatile car8260_t *car = &immap->im_clkrst;
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_MPC8260)
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);
165 -------------------------------- --------------------------------\
166 00000000001111111111222222222233 00000000001111111111222222222233\
167 01234567890123456789012345678901 01234567890123456789012345678901\
168 -------------------------------- --------------------------------\
176 for (i = 0; i < 4; i++, data += 79)
177 printf("%.79s\n", data);
180 static void binary (char *label, uint value, int nbits)
182 uint mask = 1 << (nbits - 1);
183 int i, second = (counter++ % 2);
188 for (i = 32 + 1; i != nbits; i--)
203 #if defined(CONFIG_8xx)
210 #elif defined(CONFIG_MPC8260)
220 do_iopinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
222 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
224 #if defined(CONFIG_8xx)
225 volatile iop8xx_t *iop = &immap->im_ioport;
226 volatile ushort *l, *r;
227 #elif defined(CONFIG_MPC8260)
228 volatile iop8260_t *iop = &immap->im_ioport;
229 volatile uint *l, *r;
240 #if defined(CONFIG_8xx)
242 R = &immap->im_cpm.cp_pbdir;
243 #elif defined(CONFIG_MPC8260)
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_MPC8260)
252 binary ("PA_SOR", *l++, PA_NBITS);
253 binary ("PB_SOR", *R++, PB_NBITS);
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);
266 #if defined(CONFIG_8xx)
269 #elif defined(CONFIG_MPC8260)
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);
281 #elif defined(CONFIG_MPC8260)
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);
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);
299 * this needs a clean up for smaller tighter code
300 * use *uint and set the address based on cmd + port
303 do_iopset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
307 static uint port = 0;
309 static uint value = 0;
316 #if defined(CONFIG_8xx)
322 puts ("iopset PORT PIN CMD VALUE\n");
325 port = argv[1][0] - 'A';
330 pin = simple_strtol (argv[2], NULL, 10);
335 switch (argv[3][0]) {
337 if (argv[3][1] == 'a')
339 else if (argv[3][1] == 'i')
353 #if defined(CONFIG_8xx)
359 printf ("iopset: unknown command %s\n", argv[3]);
362 if (argv[4][0] == '1')
364 else if (argv[4][0] == '0')
375 iopin_set_out (&iopin);
377 iopin_set_in (&iopin);
381 iopin_set_ded (&iopin);
383 iopin_set_gen (&iopin);
387 iopin_set_opt2 (&iopin);
389 iopin_set_opt1 (&iopin);
393 iopin_set_odr (&iopin);
395 iopin_set_act (&iopin);
399 iopin_set_high (&iopin);
401 iopin_set_low (&iopin);
403 #if defined(CONFIG_8xx)
406 iopin_set_falledge (&iopin);
408 iopin_set_anyedge (&iopin);
418 do_dmainfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
420 unimplemented (cmdtp, flag, argc, argv);
425 do_fccinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
427 unimplemented (cmdtp, flag, argc, argv);
431 static void prbrg (int n, uint val)
433 uint extc = (val >> 14) & 3;
434 uint cd = (val & CPM_BRG_CD_MASK) >> 1;
435 uint div16 = (val & CPM_BRG_DIV16) != 0;
437 #if defined(CONFIG_8xx)
438 ulong clock = gd->cpu_clk;
439 #elif defined(CONFIG_MPC8260)
440 ulong clock = gd->arch.brg_clk;
443 printf ("BRG%d:", n);
445 if (val & CPM_BRG_RST)
450 if (val & CPM_BRG_EN)
455 printf (" EXTC=%d", extc);
457 if (val & CPM_BRG_ATB)
462 printf (" DIVIDER=%4d", cd);
463 if (extc == 0 && cd != 0) {
467 baudrate = (clock / 16) / (cd + 1);
469 baudrate = clock / (cd + 1);
471 printf ("=%6d bps", baudrate);
476 if (val & CPM_BRG_DIV16)
485 do_brginfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
487 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
489 #if defined(CONFIG_8xx)
490 volatile cpm8xx_t *cp = &immap->im_cpm;
491 volatile uint *p = &cp->cp_brgc1;
492 #elif defined(CONFIG_MPC8260)
493 volatile uint *p = &immap->im_brgc1;
500 #if defined(CONFIG_MPC8260)
501 p = &immap->im_brgc5;
509 do_i2cinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
511 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
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_MPC8260)
518 volatile i2c8260_t *i2c = &immap->im_i2c;
522 dpaddr = immap->im_dprambase16[PROFF_I2C_BASE / sizeof(u16)];
526 iip = (iic_t *) & immap->im_dprambase[dpaddr];
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);
534 puts ("i2c parameter ram not allocated\n");
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);
556 do_sccinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
558 unimplemented (cmdtp, flag, argc, argv);
563 do_smcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
565 unimplemented (cmdtp, flag, argc, argv);
570 do_spiinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
572 unimplemented (cmdtp, flag, argc, argv);
577 do_muxinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
579 unimplemented (cmdtp, flag, argc, argv);
584 do_siinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
586 unimplemented (cmdtp, flag, argc, argv);
591 do_mccinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
593 unimplemented (cmdtp, flag, argc, argv);
597 /***************************************************/
600 siuinfo, 1, 1, do_siuinfo,
601 "print System Interface Unit (SIU) registers",
606 memcinfo, 1, 1, do_memcinfo,
607 "print Memory Controller registers",
612 sitinfo, 1, 1, do_sitinfo,
613 "print System Integration Timers (SIT) registers",
617 #ifdef CONFIG_MPC8260
619 icinfo, 1, 1, do_icinfo,
620 "print Interrupt Controller registers",
626 carinfo, 1, 1, do_carinfo,
627 "print Clocks and Reset registers",
632 iopinfo, 1, 1, do_iopinfo,
633 "print I/O Port registers",
638 iopset, 5, 0, do_iopset,
639 "set I/O Port registers",
640 "PORT PIN CMD VALUE\nPORT: A-D, PIN: 0-31, CMD: [dat|dir|odr|sor], VALUE: 0|1"
644 dmainfo, 1, 1, do_dmainfo,
645 "print SDMA/IDMA registers",
650 fccinfo, 1, 1, do_fccinfo,
651 "print FCC registers",
656 brginfo, 1, 1, do_brginfo,
657 "print Baud Rate Generator (BRG) registers",
662 i2cinfo, 1, 1, do_i2cinfo,
663 "print I2C registers",
668 sccinfo, 1, 1, do_sccinfo,
669 "print SCC registers",
674 smcinfo, 1, 1, do_smcinfo,
675 "print SMC registers",
680 spiinfo, 1, 1, do_spiinfo,
681 "print Serial Peripheral Interface (SPI) registers",
686 muxinfo, 1, 1, do_muxinfo,
687 "print CPM Multiplexing registers",
692 siinfo, 1, 1, do_siinfo,
693 "print Serial Interface (SI) registers",
698 mccinfo, 1, 1, do_mccinfo,
699 "print MCC registers",