Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000-2003 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * MPC8xx Internal Memory Map Functions |
| 10 | */ |
| 11 | |
| 12 | #include <common.h> |
| 13 | #include <command.h> |
| 14 | |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 15 | #include <asm/8xx_immap.h> |
| 16 | #include <commproc.h> |
| 17 | #include <asm/iopin_8xx.h> |
Christophe Leroy | ba3da73 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 18 | #include <asm/io.h> |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 19 | |
| 20 | DECLARE_GLOBAL_DATA_PTR; |
| 21 | |
Christophe Leroy | 08dd988 | 2017-07-13 15:10:08 +0200 | [diff] [blame] | 22 | static int do_siuinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 23 | { |
Christophe Leroy | ba3da73 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 24 | immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR; |
| 25 | sysconf8xx_t __iomem *sc = &immap->im_siu_conf; |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 26 | |
Christophe Leroy | ba3da73 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 27 | printf("SIUMCR= %08x SYPCR = %08x\n", |
| 28 | in_be32(&sc->sc_siumcr), in_be32(&sc->sc_sypcr)); |
| 29 | printf("SWT = %08x\n", in_be32(&sc->sc_swt)); |
| 30 | printf("SIPEND= %08x SIMASK= %08x\n", |
| 31 | in_be32(&sc->sc_sipend), in_be32(&sc->sc_simask)); |
| 32 | printf("SIEL = %08x SIVEC = %08x\n", |
| 33 | in_be32(&sc->sc_siel), in_be32(&sc->sc_sivec)); |
| 34 | printf("TESR = %08x SDCR = %08x\n", |
| 35 | in_be32(&sc->sc_tesr), in_be32(&sc->sc_sdcr)); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 36 | return 0; |
| 37 | } |
| 38 | |
Christophe Leroy | 08dd988 | 2017-07-13 15:10:08 +0200 | [diff] [blame] | 39 | static int do_memcinfo(cmd_tbl_t *cmdtp, int flag, int argc, |
| 40 | char * const argv[]) |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 41 | { |
Christophe Leroy | ba3da73 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 42 | immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR; |
| 43 | memctl8xx_t __iomem *memctl = &immap->im_memctl; |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 44 | int nbanks = 8; |
Christophe Leroy | ba3da73 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 45 | uint __iomem *p = &memctl->memc_br0; |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 46 | int i; |
| 47 | |
Christophe Leroy | ba3da73 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 48 | for (i = 0; i < nbanks; i++, p += 2) |
| 49 | printf("BR%-2d = %08x OR%-2d = %08x\n", |
| 50 | i, in_be32(p), i, in_be32(p + 1)); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 51 | |
Christophe Leroy | ba3da73 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 52 | printf("MAR = %08x", in_be32(&memctl->memc_mar)); |
| 53 | printf(" MCR = %08x\n", in_be32(&memctl->memc_mcr)); |
| 54 | printf("MAMR = %08x MBMR = %08x", |
| 55 | in_be32(&memctl->memc_mamr), in_be32(&memctl->memc_mbmr)); |
| 56 | printf("\nMSTAT = %04x\n", in_be16(&memctl->memc_mstat)); |
| 57 | printf("MPTPR = %04x MDR = %08x\n", |
| 58 | in_be16(&memctl->memc_mptpr), in_be32(&memctl->memc_mdr)); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 59 | return 0; |
| 60 | } |
| 61 | |
Christophe Leroy | 08dd988 | 2017-07-13 15:10:08 +0200 | [diff] [blame] | 62 | static int do_carinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 63 | { |
Christophe Leroy | ba3da73 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 64 | immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR; |
| 65 | car8xx_t __iomem *car = &immap->im_clkrst; |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 66 | |
Christophe Leroy | ba3da73 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 67 | printf("SCCR = %08x\n", in_be32(&car->car_sccr)); |
| 68 | printf("PLPRCR= %08x\n", in_be32(&car->car_plprcr)); |
| 69 | printf("RSR = %08x\n", in_be32(&car->car_rsr)); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | static int counter; |
| 74 | |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 75 | static void header(void) |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 76 | { |
| 77 | char *data = "\ |
| 78 | -------------------------------- --------------------------------\ |
| 79 | 00000000001111111111222222222233 00000000001111111111222222222233\ |
| 80 | 01234567890123456789012345678901 01234567890123456789012345678901\ |
| 81 | -------------------------------- --------------------------------\ |
| 82 | "; |
| 83 | int i; |
| 84 | |
| 85 | if (counter % 2) |
| 86 | putc('\n'); |
| 87 | counter = 0; |
| 88 | |
| 89 | for (i = 0; i < 4; i++, data += 79) |
| 90 | printf("%.79s\n", data); |
| 91 | } |
| 92 | |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 93 | static void binary(char *label, uint value, int nbits) |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 94 | { |
| 95 | uint mask = 1 << (nbits - 1); |
| 96 | int i, second = (counter++ % 2); |
| 97 | |
| 98 | if (second) |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 99 | putc(' '); |
| 100 | puts(label); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 101 | for (i = 32 + 1; i != nbits; i--) |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 102 | putc(' '); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 103 | |
| 104 | while (mask != 0) { |
| 105 | if (value & mask) |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 106 | putc('1'); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 107 | else |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 108 | putc('0'); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 109 | mask >>= 1; |
| 110 | } |
| 111 | |
| 112 | if (second) |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 113 | putc('\n'); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | #define PA_NBITS 16 |
| 117 | #define PA_NB_ODR 8 |
| 118 | #define PB_NBITS 18 |
| 119 | #define PB_NB_ODR 16 |
| 120 | #define PC_NBITS 12 |
| 121 | #define PD_NBITS 13 |
| 122 | |
Christophe Leroy | 08dd988 | 2017-07-13 15:10:08 +0200 | [diff] [blame] | 123 | static int do_iopinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 124 | { |
Christophe Leroy | ba3da73 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 125 | immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR; |
| 126 | iop8xx_t __iomem *iop = &immap->im_ioport; |
| 127 | ushort __iomem *l, *r; |
| 128 | uint __iomem *R; |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 129 | |
| 130 | counter = 0; |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 131 | header(); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 132 | |
| 133 | /* |
| 134 | * Ports A & B |
| 135 | */ |
| 136 | |
| 137 | l = &iop->iop_padir; |
| 138 | R = &immap->im_cpm.cp_pbdir; |
Christophe Leroy | ba3da73 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 139 | binary("PA_DIR", in_be16(l++), PA_NBITS); |
| 140 | binary("PB_DIR", in_be32(R++), PB_NBITS); |
| 141 | binary("PA_PAR", in_be16(l++), PA_NBITS); |
| 142 | binary("PB_PAR", in_be32(R++), PB_NBITS); |
| 143 | binary("PA_ODR", in_be16(l++), PA_NB_ODR); |
| 144 | binary("PB_ODR", in_be32(R++), PB_NB_ODR); |
| 145 | binary("PA_DAT", in_be16(l++), PA_NBITS); |
| 146 | binary("PB_DAT", in_be32(R++), PB_NBITS); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 147 | |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 148 | header(); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 149 | |
| 150 | /* |
| 151 | * Ports C & D |
| 152 | */ |
| 153 | |
| 154 | l = &iop->iop_pcdir; |
| 155 | r = &iop->iop_pddir; |
Christophe Leroy | ba3da73 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 156 | binary("PC_DIR", in_be16(l++), PC_NBITS); |
| 157 | binary("PD_DIR", in_be16(r++), PD_NBITS); |
| 158 | binary("PC_PAR", in_be16(l++), PC_NBITS); |
| 159 | binary("PD_PAR", in_be16(r++), PD_NBITS); |
| 160 | binary("PC_SO ", in_be16(l++), PC_NBITS); |
| 161 | binary(" ", 0, 0); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 162 | r++; |
Christophe Leroy | ba3da73 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 163 | binary("PC_DAT", in_be16(l++), PC_NBITS); |
| 164 | binary("PD_DAT", in_be16(r++), PD_NBITS); |
| 165 | binary("PC_INT", in_be16(l++), PC_NBITS); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 166 | |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 167 | header(); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 168 | return 0; |
| 169 | } |
| 170 | |
| 171 | /* |
| 172 | * set the io pins |
| 173 | * this needs a clean up for smaller tighter code |
| 174 | * use *uint and set the address based on cmd + port |
| 175 | */ |
Christophe Leroy | 08dd988 | 2017-07-13 15:10:08 +0200 | [diff] [blame] | 176 | static int do_iopset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 177 | { |
| 178 | uint rcode = 0; |
| 179 | iopin_t iopin; |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 180 | static uint port; |
| 181 | static uint pin; |
| 182 | static uint value; |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 183 | static enum { |
| 184 | DIR, |
| 185 | PAR, |
| 186 | SOR, |
| 187 | ODR, |
| 188 | DAT, |
| 189 | INT |
| 190 | } cmd = DAT; |
| 191 | |
| 192 | if (argc != 5) { |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 193 | puts("iopset PORT PIN CMD VALUE\n"); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 194 | return 1; |
| 195 | } |
| 196 | port = argv[1][0] - 'A'; |
| 197 | if (port > 3) |
| 198 | port -= 0x20; |
| 199 | if (port > 3) |
| 200 | rcode = 1; |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 201 | pin = simple_strtol(argv[2], NULL, 10); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 202 | if (pin > 31) |
| 203 | rcode = 1; |
| 204 | |
| 205 | |
| 206 | switch (argv[3][0]) { |
| 207 | case 'd': |
| 208 | if (argv[3][1] == 'a') |
| 209 | cmd = DAT; |
| 210 | else if (argv[3][1] == 'i') |
| 211 | cmd = DIR; |
| 212 | else |
| 213 | rcode = 1; |
| 214 | break; |
| 215 | case 'p': |
| 216 | cmd = PAR; |
| 217 | break; |
| 218 | case 'o': |
| 219 | cmd = ODR; |
| 220 | break; |
| 221 | case 's': |
| 222 | cmd = SOR; |
| 223 | break; |
| 224 | case 'i': |
| 225 | cmd = INT; |
| 226 | break; |
| 227 | default: |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 228 | printf("iopset: unknown command %s\n", argv[3]); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 229 | rcode = 1; |
| 230 | } |
| 231 | if (argv[4][0] == '1') |
| 232 | value = 1; |
| 233 | else if (argv[4][0] == '0') |
| 234 | value = 0; |
| 235 | else |
| 236 | rcode = 1; |
| 237 | if (rcode == 0) { |
| 238 | iopin.port = port; |
| 239 | iopin.pin = pin; |
| 240 | iopin.flag = 0; |
| 241 | switch (cmd) { |
| 242 | case DIR: |
| 243 | if (value) |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 244 | iopin_set_out(&iopin); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 245 | else |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 246 | iopin_set_in(&iopin); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 247 | break; |
| 248 | case PAR: |
| 249 | if (value) |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 250 | iopin_set_ded(&iopin); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 251 | else |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 252 | iopin_set_gen(&iopin); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 253 | break; |
| 254 | case SOR: |
| 255 | if (value) |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 256 | iopin_set_opt2(&iopin); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 257 | else |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 258 | iopin_set_opt1(&iopin); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 259 | break; |
| 260 | case ODR: |
| 261 | if (value) |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 262 | iopin_set_odr(&iopin); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 263 | else |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 264 | iopin_set_act(&iopin); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 265 | break; |
| 266 | case DAT: |
| 267 | if (value) |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 268 | iopin_set_high(&iopin); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 269 | else |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 270 | iopin_set_low(&iopin); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 271 | break; |
| 272 | case INT: |
| 273 | if (value) |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 274 | iopin_set_falledge(&iopin); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 275 | else |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 276 | iopin_set_anyedge(&iopin); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 277 | break; |
| 278 | } |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 279 | } |
| 280 | return rcode; |
| 281 | } |
| 282 | |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 283 | static void prbrg(int n, uint val) |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 284 | { |
| 285 | uint extc = (val >> 14) & 3; |
| 286 | uint cd = (val & CPM_BRG_CD_MASK) >> 1; |
| 287 | uint div16 = (val & CPM_BRG_DIV16) != 0; |
| 288 | |
| 289 | ulong clock = gd->cpu_clk; |
| 290 | |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 291 | printf("BRG%d:", n); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 292 | |
| 293 | if (val & CPM_BRG_RST) |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 294 | puts(" RESET"); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 295 | else |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 296 | puts(" "); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 297 | |
| 298 | if (val & CPM_BRG_EN) |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 299 | puts(" ENABLED"); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 300 | else |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 301 | puts(" DISABLED"); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 302 | |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 303 | printf(" EXTC=%d", extc); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 304 | |
| 305 | if (val & CPM_BRG_ATB) |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 306 | puts(" ATB"); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 307 | else |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 308 | puts(" "); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 309 | |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 310 | printf(" DIVIDER=%4d", cd); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 311 | if (extc == 0 && cd != 0) { |
| 312 | uint baudrate; |
| 313 | |
| 314 | if (div16) |
| 315 | baudrate = (clock / 16) / (cd + 1); |
| 316 | else |
| 317 | baudrate = clock / (cd + 1); |
| 318 | |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 319 | printf("=%6d bps", baudrate); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 320 | } else { |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 321 | puts(" "); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | if (val & CPM_BRG_DIV16) |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 325 | puts(" DIV16"); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 326 | else |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 327 | puts(" "); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 328 | |
Christophe Leroy | 70fd071 | 2017-07-06 10:33:17 +0200 | [diff] [blame] | 329 | putc('\n'); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 330 | } |
| 331 | |
Christophe Leroy | 08dd988 | 2017-07-13 15:10:08 +0200 | [diff] [blame] | 332 | static int do_brginfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 333 | { |
Christophe Leroy | ba3da73 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 334 | immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR; |
| 335 | cpm8xx_t __iomem *cp = &immap->im_cpm; |
| 336 | uint __iomem *p = &cp->cp_brgc1; |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 337 | int i = 1; |
| 338 | |
| 339 | while (i <= 4) |
Christophe Leroy | ba3da73 | 2017-07-06 10:33:13 +0200 | [diff] [blame] | 340 | prbrg(i++, in_be32(p++)); |
Christophe Leroy | 907208c | 2017-07-06 10:23:22 +0200 | [diff] [blame] | 341 | |
| 342 | return 0; |
| 343 | } |
| 344 | |
| 345 | /***************************************************/ |
| 346 | |
| 347 | U_BOOT_CMD( |
| 348 | siuinfo, 1, 1, do_siuinfo, |
| 349 | "print System Interface Unit (SIU) registers", |
| 350 | "" |
| 351 | ); |
| 352 | |
| 353 | U_BOOT_CMD( |
| 354 | memcinfo, 1, 1, do_memcinfo, |
| 355 | "print Memory Controller registers", |
| 356 | "" |
| 357 | ); |
| 358 | |
| 359 | U_BOOT_CMD( |
| 360 | carinfo, 1, 1, do_carinfo, |
| 361 | "print Clocks and Reset registers", |
| 362 | "" |
| 363 | ); |
| 364 | |
| 365 | U_BOOT_CMD( |
| 366 | iopinfo, 1, 1, do_iopinfo, |
| 367 | "print I/O Port registers", |
| 368 | "" |
| 369 | ); |
| 370 | |
| 371 | U_BOOT_CMD( |
| 372 | iopset, 5, 0, do_iopset, |
| 373 | "set I/O Port registers", |
| 374 | "PORT PIN CMD VALUE\nPORT: A-D, PIN: 0-31, CMD: [dat|dir|odr|sor], VALUE: 0|1" |
| 375 | ); |
| 376 | |
| 377 | U_BOOT_CMD( |
| 378 | brginfo, 1, 1, do_brginfo, |
| 379 | "print Baud Rate Generator (BRG) registers", |
| 380 | "" |
| 381 | ); |