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 #elif defined(CONFIG_8260)
38 #include <asm/immap_8260.h>
39 #include <asm/cpm_8260.h>
40 #include <asm/iopin_8260.h>
44 unimplemented ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
46 printf ("Sorry, but the '%s' command has not been implemented\n",
51 do_siuinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
53 volatile immap_t *immap = (immap_t *) CFG_IMMR;
55 #if defined(CONFIG_8xx)
56 volatile sysconf8xx_t *sc = &immap->im_siu_conf;
57 #elif defined(CONFIG_8260)
58 volatile sysconf8260_t *sc = &immap->im_siu_conf;
61 printf ("SIUMCR= %08x SYPCR = %08x\n", sc->sc_siumcr, sc->sc_sypcr);
62 #if defined(CONFIG_8xx)
63 printf ("SWT = %08x\n", sc->sc_swt);
64 printf ("SIPEND= %08x SIMASK= %08x\n", sc->sc_sipend, sc->sc_simask);
65 printf ("SIEL = %08x SIVEC = %08x\n", sc->sc_siel, sc->sc_sivec);
66 printf ("TESR = %08x SDCR = %08x\n", sc->sc_tesr, sc->sc_sdcr);
67 #elif defined(CONFIG_8260)
68 printf ("BCR = %08x\n", sc->sc_bcr);
69 printf ("P_ACR = %02x P_ALRH= %08x P_ALRL= %08x\n",
70 sc->sc_ppc_acr, sc->sc_ppc_alrh, sc->sc_ppc_alrl);
71 printf ("L_ACR = %02x L_ALRH= %08x L_ALRL= %08x\n",
72 sc->sc_lcl_acr, sc->sc_lcl_alrh, sc->sc_lcl_alrl);
73 printf ("PTESR1= %08x PTESR2= %08x\n", sc->sc_tescr1, sc->sc_tescr2);
74 printf ("LTESR1= %08x LTESR2= %08x\n", sc->sc_ltescr1, sc->sc_ltescr2);
75 printf ("PDTEA = %08x PDTEM = %02x\n", sc->sc_pdtea, sc->sc_pdtem);
76 printf ("LDTEA = %08x LDTEM = %02x\n", sc->sc_ldtea, sc->sc_ldtem);
82 do_memcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
84 volatile immap_t *immap = (immap_t *) CFG_IMMR;
86 #if defined(CONFIG_8xx)
87 volatile memctl8xx_t *memctl = &immap->im_memctl;
89 #elif defined(CONFIG_8260)
90 volatile memctl8260_t *memctl = &immap->im_memctl;
93 volatile uint *p = &memctl->memc_br0;
96 for (i = 0; i < nbanks; i++, p += 2) {
98 printf ("BR%d = %08x OR%d = %08x\n",
101 printf ("BR%d = %08x OR%d = %08x\n",
106 printf ("MAR = %08x", memctl->memc_mar);
107 #if defined(CONFIG_8xx)
108 printf (" MCR = %08x\n", memctl->memc_mcr);
109 #elif defined(CONFIG_8260)
112 printf ("MAMR = %08x MBMR = %08x",
113 memctl->memc_mamr, memctl->memc_mbmr);
114 #if defined(CONFIG_8xx)
115 printf ("\nMSTAT = %04x\n", memctl->memc_mstat);
116 #elif defined(CONFIG_8260)
117 printf (" MCMR = %08x\n", memctl->memc_mcmr);
119 printf ("MPTPR = %04x MDR = %08x\n",
120 memctl->memc_mptpr, memctl->memc_mdr);
121 #if defined(CONFIG_8260)
122 printf ("PSDMR = %08x LSDMR = %08x\n",
123 memctl->memc_psdmr, memctl->memc_lsdmr);
124 printf ("PURT = %02x PSRT = %02x\n",
125 memctl->memc_purt, memctl->memc_psrt);
126 printf ("LURT = %02x LSRT = %02x\n",
127 memctl->memc_lurt, memctl->memc_lsrt);
128 printf ("IMMR = %08x\n", memctl->memc_immr);
134 do_sitinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
136 unimplemented (cmdtp, flag, argc, argv);
142 do_icinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
144 unimplemented (cmdtp, flag, argc, argv);
150 do_carinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
152 volatile immap_t *immap = (immap_t *) CFG_IMMR;
154 #if defined(CONFIG_8xx)
155 volatile car8xx_t *car = &immap->im_clkrst;
156 #elif defined(CONFIG_8260)
157 volatile car8260_t *car = &immap->im_clkrst;
160 #if defined(CONFIG_8xx)
161 printf ("SCCR = %08x\n", car->car_sccr);
162 printf ("PLPRCR= %08x\n", car->car_plprcr);
163 printf ("RSR = %08x\n", car->car_rsr);
164 #elif defined(CONFIG_8260)
165 printf ("SCCR = %08x\n", car->car_sccr);
166 printf ("SCMR = %08x\n", car->car_scmr);
167 printf ("RSR = %08x\n", car->car_rsr);
168 printf ("RMR = %08x\n", car->car_rmr);
179 -------------------------------- --------------------------------\
180 00000000001111111111222222222233 00000000001111111111222222222233\
181 01234567890123456789012345678901 01234567890123456789012345678901\
182 -------------------------------- --------------------------------\
190 for (i = 0; i < 4; i++, data += 79)
191 printf("%.79s\n", data);
194 static void binary (char *label, uint value, int nbits)
196 uint mask = 1 << (nbits - 1);
197 int i, second = (counter++ % 2);
202 for (i = 32 + 1; i != nbits; i--)
217 #if defined(CONFIG_8xx)
224 #elif defined(CONFIG_8260)
234 do_iopinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
236 volatile immap_t *immap = (immap_t *) CFG_IMMR;
238 #if defined(CONFIG_8xx)
239 volatile iop8xx_t *iop = &immap->im_ioport;
240 volatile ushort *l, *r;
241 #elif defined(CONFIG_8260)
242 volatile iop8260_t *iop = &immap->im_ioport;
243 volatile uint *l, *r;
254 #if defined(CONFIG_8xx)
256 R = &immap->im_cpm.cp_pbdir;
257 #elif defined(CONFIG_8260)
261 binary ("PA_DIR", *l++, PA_NBITS);
262 binary ("PB_DIR", *R++, PB_NBITS);
263 binary ("PA_PAR", *l++, PA_NBITS);
264 binary ("PB_PAR", *R++, PB_NBITS);
265 #if defined(CONFIG_8260)
266 binary ("PA_SOR", *l++, PA_NBITS);
267 binary ("PB_SOR", *R++, PB_NBITS);
269 binary ("PA_ODR", *l++, PA_NB_ODR);
270 binary ("PB_ODR", *R++, PB_NB_ODR);
271 binary ("PA_DAT", *l++, PA_NBITS);
272 binary ("PB_DAT", *R++, PB_NBITS);
280 #if defined(CONFIG_8xx)
283 #elif defined(CONFIG_8260)
287 binary ("PC_DIR", *l++, PC_NBITS);
288 binary ("PD_DIR", *r++, PD_NBITS);
289 binary ("PC_PAR", *l++, PC_NBITS);
290 binary ("PD_PAR", *r++, PD_NBITS);
291 #if defined(CONFIG_8xx)
292 binary ("PC_SO ", *l++, PC_NBITS);
295 #elif defined(CONFIG_8260)
296 binary ("PC_SOR", *l++, PC_NBITS);
297 binary ("PD_SOR", *r++, PD_NBITS);
298 binary ("PC_ODR", *l++, PC_NBITS);
299 binary ("PD_ODR", *r++, PD_NBITS);
301 binary ("PC_DAT", *l++, PC_NBITS);
302 binary ("PD_DAT", *r++, PD_NBITS);
303 #if defined(CONFIG_8xx)
304 binary ("PC_INT", *l++, PC_NBITS);
313 * this needs a clean up for smaller tighter code
314 * use *uint and set the address based on cmd + port
317 do_iopset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
319 #if defined(CONFIG_8260)
321 static uint port = 0;
323 static uint value = 0;
324 static enum { DIR, PAR, SOR, ODR, DAT } cmd = DAT;
328 printf ("iopset PORT PIN CMD VALUE\n");
331 port = argv[1][0] - 'A';
336 pin = simple_strtol (argv[2], NULL, 10);
341 switch (argv[3][0]) {
343 if (argv[3][1] == 'a')
345 else if (argv[3][1] == 'i')
360 printf ("iopset: unknown command %s\n", argv[3]);
363 if (argv[4][0] == '1')
365 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);
408 unimplemented (cmdtp, flag, argc, argv);
414 do_dmainfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
416 unimplemented (cmdtp, flag, argc, argv);
421 do_fccinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
423 unimplemented (cmdtp, flag, argc, argv);
427 static void prbrg (int n, uint val)
429 uint extc = (val >> 14) & 3;
430 uint cd = (val & CPM_BRG_CD_MASK) >> 1;
431 uint div16 = (val & CPM_BRG_DIV16) != 0;
433 #if defined(CONFIG_8xx)
434 DECLARE_GLOBAL_DATA_PTR;
435 ulong clock = gd->cpu_clk;
436 #elif defined(CONFIG_8260)
437 DECLARE_GLOBAL_DATA_PTR;
438 ulong clock = gd->brg_clk;
441 printf ("BRG%d:", n);
443 if (val & CPM_BRG_RST)
448 if (val & CPM_BRG_EN)
453 printf (" EXTC=%d", extc);
455 if (val & CPM_BRG_ATB)
460 printf (" DIVIDER=%4d", cd);
461 if (extc == 0 && cd != 0) {
465 baudrate = (clock / 16) / (cd + 1);
467 baudrate = clock / (cd + 1);
469 printf ("=%6d bps", baudrate);
474 if (val & CPM_BRG_DIV16)
483 do_brginfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
485 volatile immap_t *immap = (immap_t *) CFG_IMMR;
487 #if defined(CONFIG_8xx)
488 volatile cpm8xx_t *cp = &immap->im_cpm;
489 volatile uint *p = &cp->cp_brgc1;
490 #elif defined(CONFIG_8260)
491 volatile uint *p = &immap->im_brgc1;
498 #if defined(CONFIG_8260)
499 p = &immap->im_brgc5;
507 do_i2cinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
509 volatile immap_t *immap = (immap_t *) CFG_IMMR;
511 #if defined(CONFIG_8xx)
512 volatile i2c8xx_t *i2c = &immap->im_i2c;
513 volatile cpm8xx_t *cp = &immap->im_cpm;
514 volatile iic_t *iip = (iic_t *) & cp->cp_dparam[PROFF_IIC];
515 #elif defined(CONFIG_8260)
516 volatile i2c8260_t *i2c = &immap->im_i2c;
520 dpaddr = *((unsigned short *) (&immap->im_dprambase[PROFF_I2C_BASE]));
524 iip = (iic_t *) & immap->im_dprambase[dpaddr];
527 printf ("I2MOD = %02x I2ADD = %02x\n", i2c->i2c_i2mod, i2c->i2c_i2add);
528 printf ("I2BRG = %02x I2COM = %02x\n", i2c->i2c_i2brg, i2c->i2c_i2com);
529 printf ("I2CER = %02x I2CMR = %02x\n", i2c->i2c_i2cer, i2c->i2c_i2cmr);
532 printf ("i2c parameter ram not allocated\n");
534 printf ("RBASE = %08x TBASE = %08x\n",
535 iip->iic_rbase, iip->iic_tbase);
536 printf ("RFCR = %02x TFCR = %02x\n",
537 iip->iic_rfcr, iip->iic_tfcr);
538 printf ("MRBLR = %04x\n", iip->iic_mrblr);
539 printf ("RSTATE= %08x RDP = %08x\n",
540 iip->iic_rstate, iip->iic_rdp);
541 printf ("RBPTR = %04x RBC = %04x\n",
542 iip->iic_rbptr, iip->iic_rbc);
543 printf ("RXTMP = %08x\n", iip->iic_rxtmp);
544 printf ("TSTATE= %08x TDP = %08x\n",
545 iip->iic_tstate, iip->iic_tdp);
546 printf ("TBPTR = %04x TBC = %04x\n",
547 iip->iic_tbptr, iip->iic_tbc);
548 printf ("TXTMP = %08x\n", iip->iic_txtmp);
554 do_sccinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
556 unimplemented (cmdtp, flag, argc, argv);
561 do_smcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
563 unimplemented (cmdtp, flag, argc, argv);
568 do_spiinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
570 unimplemented (cmdtp, flag, argc, argv);
575 do_muxinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
577 unimplemented (cmdtp, flag, argc, argv);
582 do_siinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
584 unimplemented (cmdtp, flag, argc, argv);
589 do_mccinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
591 unimplemented (cmdtp, flag, argc, argv);
595 /***************************************************/
598 siuinfo, 1, 1, do_siuinfo,
599 "siuinfo - print System Interface Unit (SIU) registers\n",
604 memcinfo, 1, 1, do_memcinfo,
605 "memcinfo- print Memory Controller registers\n",
610 sitinfo, 1, 1, do_sitinfo,
611 "sitinfo - print System Integration Timers (SIT) registers\n",
617 icinfo, 1, 1, do_icinfo,
618 "icinfo - print Interrupt Controller registers\n",
624 carinfo, 1, 1, do_carinfo,
625 "carinfo - print Clocks and Reset registers\n",
630 iopinfo, 1, 1, do_iopinfo,
631 "iopinfo - print I/O Port registers\n",
636 iopset, 5, 0, do_iopset,
637 "iopset - set I/O Port registers\n",
638 "PORT PIN CMD VALUE\nPORT: A-D, PIN: 0-31, CMD: [dat|dir|odr|sor], VALUE: 0|1"
642 dmainfo, 1, 1, do_dmainfo,
643 "dmainfo - print SDMA/IDMA registers\n",
648 fccinfo, 1, 1, do_fccinfo,
649 "fccinfo - print FCC registers\n",
654 brginfo, 1, 1, do_brginfo,
655 "brginfo - print Baud Rate Generator (BRG) registers\n",
660 i2cinfo, 1, 1, do_i2cinfo,
661 "i2cinfo - print I2C registers\n",
666 sccinfo, 1, 1, do_sccinfo,
667 "sccinfo - print SCC registers\n",
672 smcinfo, 1, 1, do_smcinfo,
673 "smcinfo - print SMC registers\n",
678 spiinfo, 1, 1, do_spiinfo,
679 "spiinfo - print Serial Peripheral Interface (SPI) registers\n",
684 muxinfo, 1, 1, do_muxinfo,
685 "muxinfo - print CPM Multiplexing registers\n",
690 siinfo, 1, 1, do_siinfo,
691 "siinfo - print Serial Interface (SI) registers\n",
696 mccinfo, 1, 1, do_mccinfo,
697 "mccinfo - print MCC registers\n",
702 #endif /* CFG_CMD_IMMAP && (CONFIG_8xx || CONFIG_8260) */