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 (CONFIG_COMMANDS & CFG_CMD_IMMAP) && \
32 (defined(CONFIG_8xx) || defined(CONFIG_8260))
34 #if defined(CONFIG_8xx)
35 #include <asm/8xx_immap.h>
37 #include <asm/iopin_8xx.h>
38 #elif defined(CONFIG_8260)
39 #include <asm/immap_8260.h>
40 #include <asm/cpm_8260.h>
41 #include <asm/iopin_8260.h>
45 unimplemented ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
47 printf ("Sorry, but the '%s' command has not been implemented\n",
52 do_siuinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
54 volatile immap_t *immap = (immap_t *) CFG_IMMR;
56 #if defined(CONFIG_8xx)
57 volatile sysconf8xx_t *sc = &immap->im_siu_conf;
58 #elif defined(CONFIG_8260)
59 volatile sysconf8260_t *sc = &immap->im_siu_conf;
62 printf ("SIUMCR= %08x SYPCR = %08x\n", sc->sc_siumcr, sc->sc_sypcr);
63 #if defined(CONFIG_8xx)
64 printf ("SWT = %08x\n", sc->sc_swt);
65 printf ("SIPEND= %08x SIMASK= %08x\n", sc->sc_sipend, sc->sc_simask);
66 printf ("SIEL = %08x SIVEC = %08x\n", sc->sc_siel, sc->sc_sivec);
67 printf ("TESR = %08x SDCR = %08x\n", sc->sc_tesr, sc->sc_sdcr);
68 #elif defined(CONFIG_8260)
69 printf ("BCR = %08x\n", sc->sc_bcr);
70 printf ("P_ACR = %02x P_ALRH= %08x P_ALRL= %08x\n",
71 sc->sc_ppc_acr, sc->sc_ppc_alrh, sc->sc_ppc_alrl);
72 printf ("L_ACR = %02x L_ALRH= %08x L_ALRL= %08x\n",
73 sc->sc_lcl_acr, sc->sc_lcl_alrh, sc->sc_lcl_alrl);
74 printf ("PTESR1= %08x PTESR2= %08x\n", sc->sc_tescr1, sc->sc_tescr2);
75 printf ("LTESR1= %08x LTESR2= %08x\n", sc->sc_ltescr1, sc->sc_ltescr2);
76 printf ("PDTEA = %08x PDTEM = %02x\n", sc->sc_pdtea, sc->sc_pdtem);
77 printf ("LDTEA = %08x LDTEM = %02x\n", sc->sc_ldtea, sc->sc_ldtem);
83 do_memcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
85 volatile immap_t *immap = (immap_t *) CFG_IMMR;
87 #if defined(CONFIG_8xx)
88 volatile memctl8xx_t *memctl = &immap->im_memctl;
90 #elif defined(CONFIG_8260)
91 volatile memctl8260_t *memctl = &immap->im_memctl;
94 volatile uint *p = &memctl->memc_br0;
97 for (i = 0; i < nbanks; i++, p += 2) {
99 printf ("BR%d = %08x OR%d = %08x\n",
102 printf ("BR%d = %08x OR%d = %08x\n",
107 printf ("MAR = %08x", memctl->memc_mar);
108 #if defined(CONFIG_8xx)
109 printf (" MCR = %08x\n", memctl->memc_mcr);
110 #elif defined(CONFIG_8260)
113 printf ("MAMR = %08x MBMR = %08x",
114 memctl->memc_mamr, memctl->memc_mbmr);
115 #if defined(CONFIG_8xx)
116 printf ("\nMSTAT = %04x\n", memctl->memc_mstat);
117 #elif defined(CONFIG_8260)
118 printf (" MCMR = %08x\n", memctl->memc_mcmr);
120 printf ("MPTPR = %04x MDR = %08x\n",
121 memctl->memc_mptpr, memctl->memc_mdr);
122 #if defined(CONFIG_8260)
123 printf ("PSDMR = %08x LSDMR = %08x\n",
124 memctl->memc_psdmr, memctl->memc_lsdmr);
125 printf ("PURT = %02x PSRT = %02x\n",
126 memctl->memc_purt, memctl->memc_psrt);
127 printf ("LURT = %02x LSRT = %02x\n",
128 memctl->memc_lurt, memctl->memc_lsrt);
129 printf ("IMMR = %08x\n", memctl->memc_immr);
135 do_sitinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
137 unimplemented (cmdtp, flag, argc, argv);
143 do_icinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
145 unimplemented (cmdtp, flag, argc, argv);
151 do_carinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
153 volatile immap_t *immap = (immap_t *) CFG_IMMR;
155 #if defined(CONFIG_8xx)
156 volatile car8xx_t *car = &immap->im_clkrst;
157 #elif defined(CONFIG_8260)
158 volatile car8260_t *car = &immap->im_clkrst;
161 #if defined(CONFIG_8xx)
162 printf ("SCCR = %08x\n", car->car_sccr);
163 printf ("PLPRCR= %08x\n", car->car_plprcr);
164 printf ("RSR = %08x\n", car->car_rsr);
165 #elif defined(CONFIG_8260)
166 printf ("SCCR = %08x\n", car->car_sccr);
167 printf ("SCMR = %08x\n", car->car_scmr);
168 printf ("RSR = %08x\n", car->car_rsr);
169 printf ("RMR = %08x\n", car->car_rmr);
180 -------------------------------- --------------------------------\
181 00000000001111111111222222222233 00000000001111111111222222222233\
182 01234567890123456789012345678901 01234567890123456789012345678901\
183 -------------------------------- --------------------------------\
191 for (i = 0; i < 4; i++, data += 79)
192 printf("%.79s\n", data);
195 static void binary (char *label, uint value, int nbits)
197 uint mask = 1 << (nbits - 1);
198 int i, second = (counter++ % 2);
203 for (i = 32 + 1; i != nbits; i--)
218 #if defined(CONFIG_8xx)
225 #elif defined(CONFIG_8260)
235 do_iopinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
237 volatile immap_t *immap = (immap_t *) CFG_IMMR;
239 #if defined(CONFIG_8xx)
240 volatile iop8xx_t *iop = &immap->im_ioport;
241 volatile ushort *l, *r;
242 #elif defined(CONFIG_8260)
243 volatile iop8260_t *iop = &immap->im_ioport;
244 volatile uint *l, *r;
255 #if defined(CONFIG_8xx)
257 R = &immap->im_cpm.cp_pbdir;
258 #elif defined(CONFIG_8260)
262 binary ("PA_DIR", *l++, PA_NBITS);
263 binary ("PB_DIR", *R++, PB_NBITS);
264 binary ("PA_PAR", *l++, PA_NBITS);
265 binary ("PB_PAR", *R++, PB_NBITS);
266 #if defined(CONFIG_8260)
267 binary ("PA_SOR", *l++, PA_NBITS);
268 binary ("PB_SOR", *R++, PB_NBITS);
270 binary ("PA_ODR", *l++, PA_NB_ODR);
271 binary ("PB_ODR", *R++, PB_NB_ODR);
272 binary ("PA_DAT", *l++, PA_NBITS);
273 binary ("PB_DAT", *R++, PB_NBITS);
281 #if defined(CONFIG_8xx)
284 #elif defined(CONFIG_8260)
288 binary ("PC_DIR", *l++, PC_NBITS);
289 binary ("PD_DIR", *r++, PD_NBITS);
290 binary ("PC_PAR", *l++, PC_NBITS);
291 binary ("PD_PAR", *r++, PD_NBITS);
292 #if defined(CONFIG_8xx)
293 binary ("PC_SO ", *l++, PC_NBITS);
296 #elif defined(CONFIG_8260)
297 binary ("PC_SOR", *l++, PC_NBITS);
298 binary ("PD_SOR", *r++, PD_NBITS);
299 binary ("PC_ODR", *l++, PC_NBITS);
300 binary ("PD_ODR", *r++, PD_NBITS);
302 binary ("PC_DAT", *l++, PC_NBITS);
303 binary ("PD_DAT", *r++, PD_NBITS);
304 #if defined(CONFIG_8xx)
305 binary ("PC_INT", *l++, PC_NBITS);
314 * this needs a clean up for smaller tighter code
315 * use *uint and set the address based on cmd + port
318 do_iopset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
322 static uint port = 0;
324 static uint value = 0;
331 #if defined(CONFIG_8xx)
337 puts ("iopset PORT PIN CMD VALUE\n");
340 port = argv[1][0] - 'A';
345 pin = simple_strtol (argv[2], NULL, 10);
350 switch (argv[3][0]) {
352 if (argv[3][1] == 'a')
354 else if (argv[3][1] == 'i')
368 #if defined(CONFIG_8xx)
374 printf ("iopset: unknown command %s\n", argv[3]);
377 if (argv[4][0] == '1')
379 else if (argv[4][0] == '0')
390 iopin_set_out (&iopin);
392 iopin_set_in (&iopin);
396 iopin_set_ded (&iopin);
398 iopin_set_gen (&iopin);
402 iopin_set_opt2 (&iopin);
404 iopin_set_opt1 (&iopin);
408 iopin_set_odr (&iopin);
410 iopin_set_act (&iopin);
414 iopin_set_high (&iopin);
416 iopin_set_low (&iopin);
418 #if defined(CONFIG_8xx)
421 iopin_set_falledge (&iopin);
423 iopin_set_anyedge (&iopin);
433 do_dmainfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
435 unimplemented (cmdtp, flag, argc, argv);
440 do_fccinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
442 unimplemented (cmdtp, flag, argc, argv);
446 static void prbrg (int n, uint val)
448 uint extc = (val >> 14) & 3;
449 uint cd = (val & CPM_BRG_CD_MASK) >> 1;
450 uint div16 = (val & CPM_BRG_DIV16) != 0;
452 #if defined(CONFIG_8xx)
453 DECLARE_GLOBAL_DATA_PTR;
454 ulong clock = gd->cpu_clk;
455 #elif defined(CONFIG_8260)
456 DECLARE_GLOBAL_DATA_PTR;
457 ulong clock = gd->brg_clk;
460 printf ("BRG%d:", n);
462 if (val & CPM_BRG_RST)
467 if (val & CPM_BRG_EN)
472 printf (" EXTC=%d", extc);
474 if (val & CPM_BRG_ATB)
479 printf (" DIVIDER=%4d", cd);
480 if (extc == 0 && cd != 0) {
484 baudrate = (clock / 16) / (cd + 1);
486 baudrate = clock / (cd + 1);
488 printf ("=%6d bps", baudrate);
493 if (val & CPM_BRG_DIV16)
502 do_brginfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
504 volatile immap_t *immap = (immap_t *) CFG_IMMR;
506 #if defined(CONFIG_8xx)
507 volatile cpm8xx_t *cp = &immap->im_cpm;
508 volatile uint *p = &cp->cp_brgc1;
509 #elif defined(CONFIG_8260)
510 volatile uint *p = &immap->im_brgc1;
517 #if defined(CONFIG_8260)
518 p = &immap->im_brgc5;
526 do_i2cinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
528 volatile immap_t *immap = (immap_t *) CFG_IMMR;
530 #if defined(CONFIG_8xx)
531 volatile i2c8xx_t *i2c = &immap->im_i2c;
532 volatile cpm8xx_t *cp = &immap->im_cpm;
533 volatile iic_t *iip = (iic_t *) & cp->cp_dparam[PROFF_IIC];
534 #elif defined(CONFIG_8260)
535 volatile i2c8260_t *i2c = &immap->im_i2c;
539 dpaddr = *((unsigned short *) (&immap->im_dprambase[PROFF_I2C_BASE]));
543 iip = (iic_t *) & immap->im_dprambase[dpaddr];
546 printf ("I2MOD = %02x I2ADD = %02x\n", i2c->i2c_i2mod, i2c->i2c_i2add);
547 printf ("I2BRG = %02x I2COM = %02x\n", i2c->i2c_i2brg, i2c->i2c_i2com);
548 printf ("I2CER = %02x I2CMR = %02x\n", i2c->i2c_i2cer, i2c->i2c_i2cmr);
551 puts ("i2c parameter ram not allocated\n");
553 printf ("RBASE = %08x TBASE = %08x\n",
554 iip->iic_rbase, iip->iic_tbase);
555 printf ("RFCR = %02x TFCR = %02x\n",
556 iip->iic_rfcr, iip->iic_tfcr);
557 printf ("MRBLR = %04x\n", iip->iic_mrblr);
558 printf ("RSTATE= %08x RDP = %08x\n",
559 iip->iic_rstate, iip->iic_rdp);
560 printf ("RBPTR = %04x RBC = %04x\n",
561 iip->iic_rbptr, iip->iic_rbc);
562 printf ("RXTMP = %08x\n", iip->iic_rxtmp);
563 printf ("TSTATE= %08x TDP = %08x\n",
564 iip->iic_tstate, iip->iic_tdp);
565 printf ("TBPTR = %04x TBC = %04x\n",
566 iip->iic_tbptr, iip->iic_tbc);
567 printf ("TXTMP = %08x\n", iip->iic_txtmp);
573 do_sccinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
575 unimplemented (cmdtp, flag, argc, argv);
580 do_smcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
582 unimplemented (cmdtp, flag, argc, argv);
587 do_spiinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
589 unimplemented (cmdtp, flag, argc, argv);
594 do_muxinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
596 unimplemented (cmdtp, flag, argc, argv);
601 do_siinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
603 unimplemented (cmdtp, flag, argc, argv);
608 do_mccinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
610 unimplemented (cmdtp, flag, argc, argv);
614 /***************************************************/
617 siuinfo, 1, 1, do_siuinfo,
618 "siuinfo - print System Interface Unit (SIU) registers\n",
623 memcinfo, 1, 1, do_memcinfo,
624 "memcinfo- print Memory Controller registers\n",
629 sitinfo, 1, 1, do_sitinfo,
630 "sitinfo - print System Integration Timers (SIT) registers\n",
636 icinfo, 1, 1, do_icinfo,
637 "icinfo - print Interrupt Controller registers\n",
643 carinfo, 1, 1, do_carinfo,
644 "carinfo - print Clocks and Reset registers\n",
649 iopinfo, 1, 1, do_iopinfo,
650 "iopinfo - print I/O Port registers\n",
655 iopset, 5, 0, do_iopset,
656 "iopset - set I/O Port registers\n",
657 "PORT PIN CMD VALUE\nPORT: A-D, PIN: 0-31, CMD: [dat|dir|odr|sor], VALUE: 0|1"
661 dmainfo, 1, 1, do_dmainfo,
662 "dmainfo - print SDMA/IDMA registers\n",
667 fccinfo, 1, 1, do_fccinfo,
668 "fccinfo - print FCC registers\n",
673 brginfo, 1, 1, do_brginfo,
674 "brginfo - print Baud Rate Generator (BRG) registers\n",
679 i2cinfo, 1, 1, do_i2cinfo,
680 "i2cinfo - print I2C registers\n",
685 sccinfo, 1, 1, do_sccinfo,
686 "sccinfo - print SCC registers\n",
691 smcinfo, 1, 1, do_smcinfo,
692 "smcinfo - print SMC registers\n",
697 spiinfo, 1, 1, do_spiinfo,
698 "spiinfo - print Serial Peripheral Interface (SPI) registers\n",
703 muxinfo, 1, 1, do_muxinfo,
704 "muxinfo - print CPM Multiplexing registers\n",
709 siinfo, 1, 1, do_siinfo,
710 "siinfo - print Serial Interface (SI) registers\n",
715 mccinfo, 1, 1, do_mccinfo,
716 "mccinfo - print MCC registers\n",
721 #endif /* CFG_CMD_IMMAP && (CONFIG_8xx || CONFIG_8260) */