2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
9 * MPC8xx Internal Memory Map Functions
15 #if defined(CONFIG_8xx)
17 #include <asm/8xx_immap.h>
19 #include <asm/iopin_8xx.h>
21 DECLARE_GLOBAL_DATA_PTR;
24 do_siuinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
26 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
28 volatile sysconf8xx_t *sc = &immap->im_siu_conf;
30 printf ("SIUMCR= %08x SYPCR = %08x\n", sc->sc_siumcr, sc->sc_sypcr);
31 printf ("SWT = %08x\n", sc->sc_swt);
32 printf ("SIPEND= %08x SIMASK= %08x\n", sc->sc_sipend, sc->sc_simask);
33 printf ("SIEL = %08x SIVEC = %08x\n", sc->sc_siel, sc->sc_sivec);
34 printf ("TESR = %08x SDCR = %08x\n", sc->sc_tesr, sc->sc_sdcr);
39 do_memcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
41 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
43 volatile memctl8xx_t *memctl = &immap->im_memctl;
45 volatile uint *p = &memctl->memc_br0;
48 for (i = 0; i < nbanks; i++, p += 2) {
50 printf ("BR%d = %08x OR%d = %08x\n",
53 printf ("BR%d = %08x OR%d = %08x\n",
58 printf ("MAR = %08x", memctl->memc_mar);
59 printf (" MCR = %08x\n", memctl->memc_mcr);
60 printf ("MAMR = %08x MBMR = %08x",
61 memctl->memc_mamr, memctl->memc_mbmr);
62 printf ("\nMSTAT = %04x\n", memctl->memc_mstat);
63 printf ("MPTPR = %04x MDR = %08x\n",
64 memctl->memc_mptpr, memctl->memc_mdr);
69 do_carinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
71 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
73 volatile car8xx_t *car = &immap->im_clkrst;
75 printf ("SCCR = %08x\n", car->car_sccr);
76 printf ("PLPRCR= %08x\n", car->car_plprcr);
77 printf ("RSR = %08x\n", car->car_rsr);
87 -------------------------------- --------------------------------\
88 00000000001111111111222222222233 00000000001111111111222222222233\
89 01234567890123456789012345678901 01234567890123456789012345678901\
90 -------------------------------- --------------------------------\
98 for (i = 0; i < 4; i++, data += 79)
99 printf("%.79s\n", data);
102 static void binary (char *label, uint value, int nbits)
104 uint mask = 1 << (nbits - 1);
105 int i, second = (counter++ % 2);
110 for (i = 32 + 1; i != nbits; i--)
133 do_iopinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
135 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
137 volatile iop8xx_t *iop = &immap->im_ioport;
138 volatile ushort *l, *r;
149 R = &immap->im_cpm.cp_pbdir;
150 binary ("PA_DIR", *l++, PA_NBITS);
151 binary ("PB_DIR", *R++, PB_NBITS);
152 binary ("PA_PAR", *l++, PA_NBITS);
153 binary ("PB_PAR", *R++, PB_NBITS);
154 binary ("PA_ODR", *l++, PA_NB_ODR);
155 binary ("PB_ODR", *R++, PB_NB_ODR);
156 binary ("PA_DAT", *l++, PA_NBITS);
157 binary ("PB_DAT", *R++, PB_NBITS);
167 binary ("PC_DIR", *l++, PC_NBITS);
168 binary ("PD_DIR", *r++, PD_NBITS);
169 binary ("PC_PAR", *l++, PC_NBITS);
170 binary ("PD_PAR", *r++, PD_NBITS);
171 binary ("PC_SO ", *l++, PC_NBITS);
174 binary ("PC_DAT", *l++, PC_NBITS);
175 binary ("PD_DAT", *r++, PD_NBITS);
176 binary ("PC_INT", *l++, PC_NBITS);
184 * this needs a clean up for smaller tighter code
185 * use *uint and set the address based on cmd + port
188 do_iopset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
192 static uint port = 0;
194 static uint value = 0;
205 puts ("iopset PORT PIN CMD VALUE\n");
208 port = argv[1][0] - 'A';
213 pin = simple_strtol (argv[2], NULL, 10);
218 switch (argv[3][0]) {
220 if (argv[3][1] == 'a')
222 else if (argv[3][1] == 'i')
240 printf ("iopset: unknown command %s\n", argv[3]);
243 if (argv[4][0] == '1')
245 else if (argv[4][0] == '0')
256 iopin_set_out (&iopin);
258 iopin_set_in (&iopin);
262 iopin_set_ded (&iopin);
264 iopin_set_gen (&iopin);
268 iopin_set_opt2 (&iopin);
270 iopin_set_opt1 (&iopin);
274 iopin_set_odr (&iopin);
276 iopin_set_act (&iopin);
280 iopin_set_high (&iopin);
282 iopin_set_low (&iopin);
286 iopin_set_falledge (&iopin);
288 iopin_set_anyedge (&iopin);
296 static void prbrg (int n, uint val)
298 uint extc = (val >> 14) & 3;
299 uint cd = (val & CPM_BRG_CD_MASK) >> 1;
300 uint div16 = (val & CPM_BRG_DIV16) != 0;
302 ulong clock = gd->cpu_clk;
304 printf ("BRG%d:", n);
306 if (val & CPM_BRG_RST)
311 if (val & CPM_BRG_EN)
316 printf (" EXTC=%d", extc);
318 if (val & CPM_BRG_ATB)
323 printf (" DIVIDER=%4d", cd);
324 if (extc == 0 && cd != 0) {
328 baudrate = (clock / 16) / (cd + 1);
330 baudrate = clock / (cd + 1);
332 printf ("=%6d bps", baudrate);
337 if (val & CPM_BRG_DIV16)
346 do_brginfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
348 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
350 volatile cpm8xx_t *cp = &immap->im_cpm;
351 volatile uint *p = &cp->cp_brgc1;
360 /***************************************************/
363 siuinfo, 1, 1, do_siuinfo,
364 "print System Interface Unit (SIU) registers",
369 memcinfo, 1, 1, do_memcinfo,
370 "print Memory Controller registers",
375 carinfo, 1, 1, do_carinfo,
376 "print Clocks and Reset registers",
381 iopinfo, 1, 1, do_iopinfo,
382 "print I/O Port registers",
387 iopset, 5, 0, do_iopset,
388 "set I/O Port registers",
389 "PORT PIN CMD VALUE\nPORT: A-D, PIN: 0-31, CMD: [dat|dir|odr|sor], VALUE: 0|1"
393 brginfo, 1, 1, do_brginfo,
394 "print Baud Rate Generator (BRG) registers",