2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
25 * MPC8xx/MPC8260 Internal Memory Map Functions
31 #if defined(CONFIG_8xx) || defined(CONFIG_8260)
33 #if defined(CONFIG_8xx)
34 #include <asm/8xx_immap.h>
36 #include <asm/iopin_8xx.h>
37 #elif defined(CONFIG_8260)
38 #include <asm/immap_8260.h>
39 #include <asm/cpm_8260.h>
40 #include <asm/iopin_8260.h>
43 DECLARE_GLOBAL_DATA_PTR;
46 unimplemented ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
48 printf ("Sorry, but the '%s' command has not been implemented\n",
53 do_siuinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
55 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
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;
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);
84 do_memcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
86 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
88 #if defined(CONFIG_8xx)
89 volatile memctl8xx_t *memctl = &immap->im_memctl;
91 #elif defined(CONFIG_8260)
92 volatile memctl8260_t *memctl = &immap->im_memctl;
95 volatile uint *p = &memctl->memc_br0;
98 for (i = 0; i < nbanks; i++, p += 2) {
100 printf ("BR%d = %08x OR%d = %08x\n",
103 printf ("BR%d = %08x OR%d = %08x\n",
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)
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);
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);
136 do_sitinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
138 unimplemented (cmdtp, flag, argc, argv);
144 do_icinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
146 unimplemented (cmdtp, flag, argc, argv);
152 do_carinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
154 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
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;
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);
181 -------------------------------- --------------------------------\
182 00000000001111111111222222222233 00000000001111111111222222222233\
183 01234567890123456789012345678901 01234567890123456789012345678901\
184 -------------------------------- --------------------------------\
192 for (i = 0; i < 4; i++, data += 79)
193 printf("%.79s\n", data);
196 static void binary (char *label, uint value, int nbits)
198 uint mask = 1 << (nbits - 1);
199 int i, second = (counter++ % 2);
204 for (i = 32 + 1; i != nbits; i--)
219 #if defined(CONFIG_8xx)
226 #elif defined(CONFIG_8260)
236 do_iopinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
238 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
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;
256 #if defined(CONFIG_8xx)
258 R = &immap->im_cpm.cp_pbdir;
259 #elif defined(CONFIG_8260)
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);
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);
282 #if defined(CONFIG_8xx)
285 #elif defined(CONFIG_8260)
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);
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);
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);
315 * this needs a clean up for smaller tighter code
316 * use *uint and set the address based on cmd + port
319 do_iopset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
323 static uint port = 0;
325 static uint value = 0;
332 #if defined(CONFIG_8xx)
338 puts ("iopset PORT PIN CMD VALUE\n");
341 port = argv[1][0] - 'A';
346 pin = simple_strtol (argv[2], NULL, 10);
351 switch (argv[3][0]) {
353 if (argv[3][1] == 'a')
355 else if (argv[3][1] == 'i')
369 #if defined(CONFIG_8xx)
375 printf ("iopset: unknown command %s\n", argv[3]);
378 if (argv[4][0] == '1')
380 else if (argv[4][0] == '0')
391 iopin_set_out (&iopin);
393 iopin_set_in (&iopin);
397 iopin_set_ded (&iopin);
399 iopin_set_gen (&iopin);
403 iopin_set_opt2 (&iopin);
405 iopin_set_opt1 (&iopin);
409 iopin_set_odr (&iopin);
411 iopin_set_act (&iopin);
415 iopin_set_high (&iopin);
417 iopin_set_low (&iopin);
419 #if defined(CONFIG_8xx)
422 iopin_set_falledge (&iopin);
424 iopin_set_anyedge (&iopin);
434 do_dmainfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
436 unimplemented (cmdtp, flag, argc, argv);
441 do_fccinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
443 unimplemented (cmdtp, flag, argc, argv);
447 static void prbrg (int n, uint val)
449 uint extc = (val >> 14) & 3;
450 uint cd = (val & CPM_BRG_CD_MASK) >> 1;
451 uint div16 = (val & CPM_BRG_DIV16) != 0;
453 #if defined(CONFIG_8xx)
454 ulong clock = gd->cpu_clk;
455 #elif defined(CONFIG_8260)
456 ulong clock = gd->arch.brg_clk;
459 printf ("BRG%d:", n);
461 if (val & CPM_BRG_RST)
466 if (val & CPM_BRG_EN)
471 printf (" EXTC=%d", extc);
473 if (val & CPM_BRG_ATB)
478 printf (" DIVIDER=%4d", cd);
479 if (extc == 0 && cd != 0) {
483 baudrate = (clock / 16) / (cd + 1);
485 baudrate = clock / (cd + 1);
487 printf ("=%6d bps", baudrate);
492 if (val & CPM_BRG_DIV16)
501 do_brginfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
503 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
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;
516 #if defined(CONFIG_8260)
517 p = &immap->im_brgc5;
525 do_i2cinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
527 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
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;
538 dpaddr = *((unsigned short *) (&immap->im_dprambase[PROFF_I2C_BASE]));
542 iip = (iic_t *) & immap->im_dprambase[dpaddr];
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);
550 puts ("i2c parameter ram not allocated\n");
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);
572 do_sccinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
574 unimplemented (cmdtp, flag, argc, argv);
579 do_smcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
581 unimplemented (cmdtp, flag, argc, argv);
586 do_spiinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
588 unimplemented (cmdtp, flag, argc, argv);
593 do_muxinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
595 unimplemented (cmdtp, flag, argc, argv);
600 do_siinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
602 unimplemented (cmdtp, flag, argc, argv);
607 do_mccinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
609 unimplemented (cmdtp, flag, argc, argv);
613 /***************************************************/
616 siuinfo, 1, 1, do_siuinfo,
617 "print System Interface Unit (SIU) registers",
622 memcinfo, 1, 1, do_memcinfo,
623 "print Memory Controller registers",
628 sitinfo, 1, 1, do_sitinfo,
629 "print System Integration Timers (SIT) registers",
635 icinfo, 1, 1, do_icinfo,
636 "print Interrupt Controller registers",
642 carinfo, 1, 1, do_carinfo,
643 "print Clocks and Reset registers",
648 iopinfo, 1, 1, do_iopinfo,
649 "print I/O Port registers",
654 iopset, 5, 0, do_iopset,
655 "set I/O Port registers",
656 "PORT PIN CMD VALUE\nPORT: A-D, PIN: 0-31, CMD: [dat|dir|odr|sor], VALUE: 0|1"
660 dmainfo, 1, 1, do_dmainfo,
661 "print SDMA/IDMA registers",
666 fccinfo, 1, 1, do_fccinfo,
667 "print FCC registers",
672 brginfo, 1, 1, do_brginfo,
673 "print Baud Rate Generator (BRG) registers",
678 i2cinfo, 1, 1, do_i2cinfo,
679 "print I2C registers",
684 sccinfo, 1, 1, do_sccinfo,
685 "print SCC registers",
690 smcinfo, 1, 1, do_smcinfo,
691 "print SMC registers",
696 spiinfo, 1, 1, do_spiinfo,
697 "print Serial Peripheral Interface (SPI) registers",
702 muxinfo, 1, 1, do_muxinfo,
703 "print CPM Multiplexing registers",
708 siinfo, 1, 1, do_siinfo,
709 "print Serial Interface (SI) registers",
714 mccinfo, 1, 1, do_mccinfo,
715 "print MCC registers",