Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 1 | /* |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 2 | * (C) Copyright 2007-2008 |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 3 | * Matthias Fuchs, esd Gmbh, matthias.fuchs@esd-electronics.com. |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 6 | */ |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 7 | #include <common.h> |
| 8 | #include <command.h> |
Simon Glass | 24b852a | 2015-11-08 23:47:45 -0700 | [diff] [blame] | 9 | #include <console.h> |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 10 | #include <asm/io.h> |
| 11 | #include <asm/cache.h> |
| 12 | #include <asm/processor.h> |
Matthias Fuchs | 75183b1 | 2008-10-28 13:36:59 +0100 | [diff] [blame] | 13 | #if defined(CONFIG_LOGBUFFER) |
| 14 | #include <logbuff.h> |
| 15 | #endif |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 16 | |
| 17 | #include "pmc440.h" |
| 18 | |
| 19 | int is_monarch(void); |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 20 | int bootstrap_eeprom_write(unsigned dev_addr, unsigned offset, |
| 21 | uchar *buffer, unsigned cnt); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 22 | int eeprom_write_enable(unsigned dev_addr, int state); |
| 23 | |
| 24 | DECLARE_GLOBAL_DATA_PTR; |
| 25 | |
| 26 | #if defined(CONFIG_CMD_BSP) |
| 27 | |
| 28 | static int got_fifoirq; |
| 29 | static int got_hcirq; |
| 30 | |
| 31 | int fpga_interrupt(u32 arg) |
| 32 | { |
| 33 | pmc440_fpga_t *fpga = (pmc440_fpga_t *)arg; |
| 34 | int rc = -1; /* not for us */ |
| 35 | u32 status = FPGA_IN32(&fpga->status); |
| 36 | |
| 37 | /* check for interrupt from fifo module */ |
| 38 | if (status & STATUS_FIFO_ISF) { |
| 39 | /* disable this int source */ |
| 40 | FPGA_OUT32(&fpga->hostctrl, HOSTCTRL_FIFOIE_GATE); |
| 41 | rc = 0; |
| 42 | got_fifoirq = 1; /* trigger backend */ |
| 43 | } |
| 44 | |
| 45 | if (status & STATUS_HOST_ISF) { |
| 46 | FPGA_OUT32(&fpga->hostctrl, HOSTCTRL_HCINT_GATE); |
| 47 | rc = 0; |
| 48 | got_hcirq = 1; |
| 49 | } |
| 50 | |
| 51 | return rc; |
| 52 | } |
| 53 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 54 | int do_waithci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 55 | { |
| 56 | pmc440_fpga_t *fpga = (pmc440_fpga_t *)FPGA_BA; |
| 57 | |
| 58 | got_hcirq = 0; |
| 59 | |
| 60 | FPGA_CLRBITS(&fpga->ctrla, CTRL_HOST_IE); |
| 61 | FPGA_OUT32(&fpga->hostctrl, HOSTCTRL_HCINT_GATE); |
| 62 | |
| 63 | irq_install_handler(IRQ0_FPGA, |
| 64 | (interrupt_handler_t *)fpga_interrupt, |
| 65 | fpga); |
| 66 | |
| 67 | FPGA_SETBITS(&fpga->ctrla, CTRL_HOST_IE); |
| 68 | |
| 69 | while (!got_hcirq) { |
| 70 | /* Abort if ctrl-c was pressed */ |
| 71 | if (ctrlc()) { |
| 72 | puts("\nAbort\n"); |
| 73 | break; |
| 74 | } |
| 75 | } |
| 76 | if (got_hcirq) |
| 77 | printf("Got interrupt!\n"); |
| 78 | |
| 79 | FPGA_CLRBITS(&fpga->ctrla, CTRL_HOST_IE); |
| 80 | irq_free_handler(IRQ0_FPGA); |
| 81 | return 0; |
| 82 | } |
| 83 | U_BOOT_CMD( |
| 84 | waithci, 1, 1, do_waithci, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 85 | "Wait for host control interrupt", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 86 | "" |
| 87 | ); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 88 | |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 89 | void dump_fifo(pmc440_fpga_t *fpga, int f, int *n) |
| 90 | { |
| 91 | u32 ctrl; |
| 92 | |
| 93 | while (!((ctrl = FPGA_IN32(&fpga->fifo[f].ctrl)) & FIFO_EMPTY)) { |
| 94 | printf("%5d %d %3d %08x", |
| 95 | (*n)++, f, ctrl & (FIFO_LEVEL_MASK | FIFO_FULL), |
| 96 | FPGA_IN32(&fpga->fifo[f].data)); |
| 97 | if (ctrl & FIFO_OVERFLOW) { |
| 98 | printf(" OVERFLOW\n"); |
| 99 | FPGA_CLRBITS(&fpga->fifo[f].ctrl, FIFO_OVERFLOW); |
| 100 | } else |
| 101 | printf("\n"); |
| 102 | } |
| 103 | } |
| 104 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 105 | int do_fifo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 106 | { |
| 107 | pmc440_fpga_t *fpga = (pmc440_fpga_t *)FPGA_BA; |
| 108 | int i; |
| 109 | int n = 0; |
| 110 | u32 ctrl, data, f; |
| 111 | char str[] = "\\|/-"; |
| 112 | int abort = 0; |
| 113 | int count = 0; |
| 114 | int count2 = 0; |
| 115 | |
| 116 | switch (argc) { |
| 117 | case 1: |
| 118 | /* print all fifos status information */ |
| 119 | printf("fifo level status\n"); |
| 120 | printf("______________________________\n"); |
| 121 | for (i=0; i<FIFO_COUNT; i++) { |
| 122 | ctrl = FPGA_IN32(&fpga->fifo[i].ctrl); |
| 123 | printf(" %d %3d %s%s%s %s\n", |
| 124 | i, ctrl & (FIFO_LEVEL_MASK | FIFO_FULL), |
| 125 | ctrl & FIFO_FULL ? "FULL " : "", |
| 126 | ctrl & FIFO_EMPTY ? "EMPTY " : "", |
| 127 | ctrl & (FIFO_FULL|FIFO_EMPTY) ? "" : "NOT EMPTY", |
| 128 | ctrl & FIFO_OVERFLOW ? "OVERFLOW" : ""); |
| 129 | } |
| 130 | break; |
| 131 | |
| 132 | case 2: |
| 133 | /* completely read out fifo 'n' */ |
| 134 | if (!strcmp(argv[1],"read")) { |
| 135 | printf(" # fifo level data\n"); |
| 136 | printf("______________________________\n"); |
| 137 | |
| 138 | for (i=0; i<FIFO_COUNT; i++) |
| 139 | dump_fifo(fpga, i, &n); |
| 140 | |
| 141 | } else if (!strcmp(argv[1],"wait")) { |
| 142 | got_fifoirq = 0; |
| 143 | |
| 144 | irq_install_handler(IRQ0_FPGA, |
| 145 | (interrupt_handler_t *)fpga_interrupt, |
| 146 | fpga); |
| 147 | |
| 148 | printf(" # fifo level data\n"); |
| 149 | printf("______________________________\n"); |
| 150 | |
| 151 | /* enable all fifo interrupts */ |
| 152 | FPGA_OUT32(&fpga->hostctrl, |
| 153 | HOSTCTRL_FIFOIE_GATE | HOSTCTRL_FIFOIE_FLAG); |
| 154 | for (i=0; i<FIFO_COUNT; i++) { |
| 155 | /* enable interrupts from all fifos */ |
| 156 | FPGA_SETBITS(&fpga->fifo[i].ctrl, FIFO_IE); |
| 157 | } |
| 158 | |
| 159 | while (1) { |
| 160 | /* wait loop */ |
| 161 | while (!got_fifoirq) { |
| 162 | count++; |
| 163 | if (!(count % 100)) { |
| 164 | count2++; |
| 165 | putc(0x08); /* backspace */ |
| 166 | putc(str[count2 % 4]); |
| 167 | } |
| 168 | |
| 169 | /* Abort if ctrl-c was pressed */ |
| 170 | if ((abort = ctrlc())) { |
| 171 | puts("\nAbort\n"); |
| 172 | break; |
| 173 | } |
| 174 | udelay(1000); |
| 175 | } |
| 176 | if (abort) |
| 177 | break; |
| 178 | |
| 179 | /* simple fifo backend */ |
| 180 | if (got_fifoirq) { |
| 181 | for (i=0; i<FIFO_COUNT; i++) |
| 182 | dump_fifo(fpga, i, &n); |
| 183 | |
| 184 | got_fifoirq = 0; |
| 185 | /* unmask global fifo irq */ |
| 186 | FPGA_OUT32(&fpga->hostctrl, |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 187 | HOSTCTRL_FIFOIE_GATE | |
| 188 | HOSTCTRL_FIFOIE_FLAG); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 189 | } |
| 190 | } |
| 191 | |
| 192 | /* disable all fifo interrupts */ |
| 193 | FPGA_OUT32(&fpga->hostctrl, HOSTCTRL_FIFOIE_GATE); |
| 194 | for (i=0; i<FIFO_COUNT; i++) |
| 195 | FPGA_CLRBITS(&fpga->fifo[i].ctrl, FIFO_IE); |
| 196 | |
| 197 | irq_free_handler(IRQ0_FPGA); |
| 198 | |
| 199 | } else { |
| 200 | printf("Usage:\nfifo %s\n", cmdtp->help); |
| 201 | return 1; |
| 202 | } |
| 203 | break; |
| 204 | |
| 205 | case 4: |
| 206 | case 5: |
| 207 | if (!strcmp(argv[1],"write")) { |
| 208 | /* get fifo number or fifo address */ |
| 209 | f = simple_strtoul(argv[2], NULL, 16); |
| 210 | |
| 211 | /* data paramter */ |
| 212 | data = simple_strtoul(argv[3], NULL, 16); |
| 213 | |
| 214 | /* get optional count parameter */ |
| 215 | n = 1; |
| 216 | if (argc >= 5) |
| 217 | n = (int)simple_strtoul(argv[4], NULL, 10); |
| 218 | |
| 219 | if (f < FIFO_COUNT) { |
| 220 | printf("writing %d x %08x to fifo %d\n", |
| 221 | n, data, f); |
| 222 | for (i=0; i<n; i++) |
| 223 | FPGA_OUT32(&fpga->fifo[f].data, data); |
| 224 | } else { |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 225 | printf("writing %d x %08x to fifo port at " |
| 226 | "address %08x\n", |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 227 | n, data, f); |
| 228 | for (i=0; i<n; i++) |
Matthias Fuchs | bb57ad4 | 2009-02-20 10:19:19 +0100 | [diff] [blame] | 229 | out_be32((void *)f, data); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 230 | } |
| 231 | } else { |
| 232 | printf("Usage:\nfifo %s\n", cmdtp->help); |
| 233 | return 1; |
| 234 | } |
| 235 | break; |
| 236 | |
| 237 | default: |
| 238 | printf("Usage:\nfifo %s\n", cmdtp->help); |
| 239 | return 1; |
| 240 | } |
| 241 | return 0; |
| 242 | } |
| 243 | U_BOOT_CMD( |
| 244 | fifo, 5, 1, do_fifo, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 245 | "Fifo module operations", |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 246 | "wait\nfifo read\n" |
| 247 | "fifo write fifo(0..3) data [cnt=1]\n" |
| 248 | "fifo write address(>=4) data [cnt=1]\n" |
| 249 | " - without arguments: print all fifo's status\n" |
| 250 | " - with 'wait' argument: interrupt driven read from all fifos\n" |
| 251 | " - with 'read' argument: read current contents from all fifos\n" |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 252 | " - with 'write' argument: write 'data' 'cnt' times to " |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 253 | "'fifo' or 'address'" |
| 254 | ); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 255 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 256 | int do_setup_bootstrap_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 257 | { |
| 258 | ulong sdsdp[5]; |
| 259 | ulong delay; |
| 260 | int count=16; |
| 261 | |
| 262 | if (argc < 2) { |
| 263 | printf("Usage:\nsbe %s\n", cmdtp->help); |
| 264 | return -1; |
| 265 | } |
| 266 | |
| 267 | if (argc > 1) { |
| 268 | if (!strcmp(argv[1], "400")) { |
Matthias Fuchs | ff5fb8a | 2008-01-08 12:49:58 +0100 | [diff] [blame] | 269 | /* PLB=133MHz, PLB/PCI=3 */ |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 270 | printf("Bootstrapping for 400MHz\n"); |
| 271 | sdsdp[0]=0x8678624e; |
Matthias Fuchs | ff5fb8a | 2008-01-08 12:49:58 +0100 | [diff] [blame] | 272 | sdsdp[1]=0x095fa030; |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 273 | sdsdp[2]=0x40082350; |
| 274 | sdsdp[3]=0x0d050000; |
| 275 | } else if (!strcmp(argv[1], "533")) { |
| 276 | /* PLB=133MHz, PLB/PCI=3 */ |
| 277 | printf("Bootstrapping for 533MHz\n"); |
| 278 | sdsdp[0]=0x87788252; |
| 279 | sdsdp[1]=0x095fa030; |
| 280 | sdsdp[2]=0x40082350; |
| 281 | sdsdp[3]=0x0d050000; |
| 282 | } else if (!strcmp(argv[1], "667")) { |
Matthias Fuchs | 79941d6 | 2008-04-21 18:01:07 +0200 | [diff] [blame] | 283 | /* PLB=133MHz, PLB/PCI=3 */ |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 284 | printf("Bootstrapping for 667MHz\n"); |
| 285 | sdsdp[0]=0x8778a256; |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 286 | sdsdp[1]=0x095fa030; |
| 287 | sdsdp[2]=0x40082350; |
| 288 | sdsdp[3]=0x0d050000; |
| 289 | } else { |
| 290 | printf("Usage:\nsbe %s\n", cmdtp->help); |
| 291 | return -1; |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | if (argc > 2) { |
| 296 | sdsdp[4] = 0; |
| 297 | if (argv[2][0]=='1') |
| 298 | sdsdp[4]=0x19750100; |
| 299 | else if (argv[2][0]=='0') |
| 300 | sdsdp[4]=0x19750000; |
| 301 | if (sdsdp[4]) |
| 302 | count += 4; |
| 303 | } |
| 304 | |
| 305 | if (argc > 3) { |
| 306 | delay = simple_strtoul(argv[3], NULL, 10); |
| 307 | if (delay > 20) |
| 308 | delay = 20; |
| 309 | sdsdp[4] |= delay; |
| 310 | } |
| 311 | |
| 312 | printf("Writing boot EEPROM ...\n"); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 313 | if (bootstrap_eeprom_write(CONFIG_SYS_I2C_BOOT_EEPROM_ADDR, |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 314 | 0, (uchar*)sdsdp, count) != 0) |
| 315 | printf("bootstrap_eeprom_write failed\n"); |
| 316 | else |
| 317 | printf("done (dump via 'i2c md 52 0.1 14')\n"); |
| 318 | |
| 319 | return 0; |
| 320 | } |
| 321 | U_BOOT_CMD( |
| 322 | sbe, 4, 0, do_setup_bootstrap_eeprom, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 323 | "setup bootstrap eeprom", |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 324 | "<cpufreq:400|533|667> [<console-uart:0|1> [<bringup delay (0..20s)>]]" |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 325 | ); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 326 | |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 327 | #if defined(CONFIG_PRAM) |
| 328 | #include <environment.h> |
Matthias Fuchs | a6569c6 | 2011-11-24 16:36:06 +0100 | [diff] [blame] | 329 | #include <search.h> |
| 330 | #include <errno.h> |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 331 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 332 | int do_painit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 333 | { |
Matthias Fuchs | 75183b1 | 2008-10-28 13:36:59 +0100 | [diff] [blame] | 334 | u32 pram, nextbase, base; |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 335 | char *v; |
| 336 | u32 param; |
| 337 | ulong *lptr; |
| 338 | |
Matthias Fuchs | a6569c6 | 2011-11-24 16:36:06 +0100 | [diff] [blame] | 339 | env_t *envp; |
| 340 | char *res; |
| 341 | int len; |
| 342 | |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 343 | v = getenv("pram"); |
| 344 | if (v) |
| 345 | pram = simple_strtoul(v, NULL, 10); |
| 346 | else { |
| 347 | printf("Error: pram undefined. Please define pram in KiB\n"); |
| 348 | return 1; |
| 349 | } |
| 350 | |
Matthias Fuchs | f39c5d1 | 2014-10-24 12:44:40 +0200 | [diff] [blame] | 351 | base = (u32)gd->ram_size; |
Matthias Fuchs | 75183b1 | 2008-10-28 13:36:59 +0100 | [diff] [blame] | 352 | #if defined(CONFIG_LOGBUFFER) |
| 353 | base -= LOGBUFF_LEN + LOGBUFF_OVERHEAD; |
| 354 | #endif |
| 355 | /* |
Matthias Fuchs | f39c5d1 | 2014-10-24 12:44:40 +0200 | [diff] [blame] | 356 | * gd->ram_size == physical ram size - CONFIG_SYS_MEM_TOP_HIDE |
Matthias Fuchs | 75183b1 | 2008-10-28 13:36:59 +0100 | [diff] [blame] | 357 | */ |
| 358 | param = base - (pram << 10); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 359 | printf("PARAM: @%08x\n", param); |
Matthias Fuchs | f39c5d1 | 2014-10-24 12:44:40 +0200 | [diff] [blame] | 360 | debug("memsize=0x%08x, base=0x%08x\n", (u32)gd->ram_size, base); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 361 | |
Matthias Fuchs | 75183b1 | 2008-10-28 13:36:59 +0100 | [diff] [blame] | 362 | /* clear entire PA ram */ |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 363 | memset((void*)param, 0, (pram << 10)); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 364 | |
Matthias Fuchs | 75183b1 | 2008-10-28 13:36:59 +0100 | [diff] [blame] | 365 | /* reserve 4k for pointer field */ |
| 366 | nextbase = base - 4096; |
| 367 | lptr = (ulong*)(base); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 368 | |
Matthias Fuchs | 75183b1 | 2008-10-28 13:36:59 +0100 | [diff] [blame] | 369 | /* |
| 370 | * *(--lptr) = item_size; |
| 371 | * *(--lptr) = base - item_base = distance from field top; |
| 372 | */ |
| 373 | |
| 374 | /* env is first (4k aligned) */ |
| 375 | nextbase -= ((CONFIG_ENV_SIZE + 4096 - 1) & ~(4096 - 1)); |
Matthias Fuchs | a6569c6 | 2011-11-24 16:36:06 +0100 | [diff] [blame] | 376 | envp = (env_t *)nextbase; |
| 377 | res = (char *)envp->data; |
Joe Hershberger | be11235 | 2012-12-11 22:16:23 -0600 | [diff] [blame] | 378 | len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL); |
Matthias Fuchs | a6569c6 | 2011-11-24 16:36:06 +0100 | [diff] [blame] | 379 | if (len < 0) { |
| 380 | error("Cannot export environment: errno = %d\n", errno); |
| 381 | return 1; |
| 382 | } |
| 383 | envp->crc = crc32(0, envp->data, ENV_SIZE); |
| 384 | |
Matthias Fuchs | 75183b1 | 2008-10-28 13:36:59 +0100 | [diff] [blame] | 385 | *(--lptr) = CONFIG_ENV_SIZE; /* size */ |
| 386 | *(--lptr) = base - nextbase; /* offset | type=0 */ |
| 387 | |
| 388 | /* free section */ |
| 389 | *(--lptr) = nextbase - param; /* size */ |
| 390 | *(--lptr) = (base - param) | 126; /* offset | type=126 */ |
| 391 | |
| 392 | /* terminate pointer field */ |
| 393 | *(--lptr) = crc32(0, (void*)(base - 0x10), 0x10); |
| 394 | *(--lptr) = 0; /* offset=0 -> terminator */ |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 395 | return 0; |
| 396 | } |
| 397 | U_BOOT_CMD( |
| 398 | painit, 1, 1, do_painit, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 399 | "prepare PciAccess system", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 400 | "" |
| 401 | ); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 402 | #endif /* CONFIG_PRAM */ |
| 403 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 404 | int do_selfreset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 405 | { |
Matthias Fuchs | 75183b1 | 2008-10-28 13:36:59 +0100 | [diff] [blame] | 406 | in_be32((void*)CONFIG_SYS_RESET_BASE); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 407 | return 0; |
| 408 | } |
| 409 | U_BOOT_CMD( |
Matthias Fuchs | 75183b1 | 2008-10-28 13:36:59 +0100 | [diff] [blame] | 410 | selfreset, 1, 1, do_selfreset, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 411 | "assert self-reset# signal", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 412 | "" |
| 413 | ); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 414 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 415 | int do_resetout(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 416 | { |
| 417 | pmc440_fpga_t *fpga = (pmc440_fpga_t *)FPGA_BA; |
| 418 | |
| 419 | /* requiers bootet FPGA and PLD_IOEN_N active */ |
| 420 | if (in_be32((void*)GPIO1_OR) & GPIO1_IOEN_N) { |
| 421 | printf("Error: resetout requires a bootet FPGA\n"); |
| 422 | return -1; |
| 423 | } |
| 424 | |
| 425 | if (argc > 1) { |
| 426 | if (argv[1][0] == '0') { |
| 427 | /* assert */ |
| 428 | printf("PMC-RESETOUT# asserted\n"); |
| 429 | FPGA_OUT32(&fpga->hostctrl, |
| 430 | HOSTCTRL_PMCRSTOUT_GATE); |
| 431 | } else { |
| 432 | /* deassert */ |
| 433 | printf("PMC-RESETOUT# deasserted\n"); |
| 434 | FPGA_OUT32(&fpga->hostctrl, |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 435 | HOSTCTRL_PMCRSTOUT_GATE | |
| 436 | HOSTCTRL_PMCRSTOUT_FLAG); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 437 | } |
| 438 | } else { |
| 439 | printf("PMC-RESETOUT# is %s\n", |
| 440 | FPGA_IN32(&fpga->hostctrl) & HOSTCTRL_PMCRSTOUT_FLAG ? |
| 441 | "inactive" : "active"); |
| 442 | } |
| 443 | |
| 444 | return 0; |
| 445 | } |
| 446 | U_BOOT_CMD( |
| 447 | resetout, 2, 1, do_resetout, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 448 | "assert PMC-RESETOUT# signal", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 449 | "" |
| 450 | ); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 451 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 452 | int do_inta(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 453 | { |
| 454 | if (is_monarch()) { |
| 455 | printf("This command is only supported in non-monarch mode\n"); |
| 456 | return -1; |
| 457 | } |
| 458 | |
| 459 | if (argc > 1) { |
| 460 | if (argv[1][0] == '0') { |
| 461 | /* assert */ |
| 462 | printf("inta# asserted\n"); |
| 463 | out_be32((void*)GPIO1_TCR, |
| 464 | in_be32((void*)GPIO1_TCR) | GPIO1_INTA_FAKE); |
| 465 | } else { |
| 466 | /* deassert */ |
| 467 | printf("inta# deasserted\n"); |
| 468 | out_be32((void*)GPIO1_TCR, |
| 469 | in_be32((void*)GPIO1_TCR) & ~GPIO1_INTA_FAKE); |
| 470 | } |
| 471 | } else { |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 472 | printf("inta# is %s\n", |
| 473 | in_be32((void*)GPIO1_TCR) & GPIO1_INTA_FAKE ? |
| 474 | "active" : "inactive"); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 475 | } |
| 476 | return 0; |
| 477 | } |
| 478 | U_BOOT_CMD( |
| 479 | inta, 2, 1, do_inta, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 480 | "Assert/Deassert or query INTA# state in non-monarch mode", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 481 | "" |
| 482 | ); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 483 | |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 484 | /* test-only */ |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 485 | int do_pmm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 486 | { |
| 487 | ulong pciaddr; |
| 488 | |
| 489 | if (argc > 1) { |
| 490 | pciaddr = simple_strtoul(argv[1], NULL, 16); |
| 491 | |
| 492 | pciaddr &= 0xf0000000; |
| 493 | |
| 494 | /* map PCI address at 0xc0000000 in PLB space */ |
Matthias Fuchs | 034394a | 2008-03-30 18:52:44 +0200 | [diff] [blame] | 495 | |
Stefan Roese | 02e3892 | 2008-03-31 12:20:48 +0200 | [diff] [blame] | 496 | /* PMM1 Mask/Attribute - disabled b4 setting */ |
Niklaus Giger | ddc922f | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 497 | out32r(PCIL0_PMM1MA, 0x00000000); |
Stefan Roese | 02e3892 | 2008-03-31 12:20:48 +0200 | [diff] [blame] | 498 | /* PMM1 Local Address */ |
Niklaus Giger | ddc922f | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 499 | out32r(PCIL0_PMM1LA, 0xc0000000); |
Stefan Roese | 02e3892 | 2008-03-31 12:20:48 +0200 | [diff] [blame] | 500 | /* PMM1 PCI Low Address */ |
Niklaus Giger | ddc922f | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 501 | out32r(PCIL0_PMM1PCILA, pciaddr); |
Stefan Roese | 02e3892 | 2008-03-31 12:20:48 +0200 | [diff] [blame] | 502 | /* PMM1 PCI High Address */ |
Niklaus Giger | ddc922f | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 503 | out32r(PCIL0_PMM1PCIHA, 0x00000000); |
Stefan Roese | 02e3892 | 2008-03-31 12:20:48 +0200 | [diff] [blame] | 504 | /* 256MB + No prefetching, and enable region */ |
Niklaus Giger | ddc922f | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 505 | out32r(PCIL0_PMM1MA, 0xf0000001); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 506 | } else { |
| 507 | printf("Usage:\npmm %s\n", cmdtp->help); |
| 508 | } |
| 509 | return 0; |
| 510 | } |
| 511 | U_BOOT_CMD( |
| 512 | pmm, 2, 1, do_pmm, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 513 | "Setup pmm[1] registers", |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 514 | "<pciaddr> (pciaddr will be aligned to 256MB)" |
| 515 | ); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 516 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 517 | #if defined(CONFIG_SYS_EEPROM_WREN) |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 518 | int do_eep_wren(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 519 | { |
| 520 | int query = argc == 1; |
| 521 | int state = 0; |
| 522 | |
| 523 | if (query) { |
| 524 | /* Query write access state. */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 525 | state = eeprom_write_enable(CONFIG_SYS_I2C_EEPROM_ADDR, -1); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 526 | if (state < 0) { |
| 527 | puts("Query of write access state failed.\n"); |
| 528 | } else { |
| 529 | printf("Write access for device 0x%0x is %sabled.\n", |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 530 | CONFIG_SYS_I2C_EEPROM_ADDR, state ? "en" : "dis"); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 531 | state = 0; |
| 532 | } |
| 533 | } else { |
| 534 | if ('0' == argv[1][0]) { |
| 535 | /* Disable write access. */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 536 | state = eeprom_write_enable(CONFIG_SYS_I2C_EEPROM_ADDR, 0); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 537 | } else { |
| 538 | /* Enable write access. */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 539 | state = eeprom_write_enable(CONFIG_SYS_I2C_EEPROM_ADDR, 1); |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 540 | } |
| 541 | if (state < 0) { |
| 542 | puts("Setup of write access state failed.\n"); |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | return state; |
| 547 | } |
| 548 | U_BOOT_CMD(eepwren, 2, 0, do_eep_wren, |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 549 | "Enable / disable / query EEPROM write access", |
| 550 | "" |
| 551 | ); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 552 | #endif /* #if defined(CONFIG_SYS_EEPROM_WREN) */ |
Matthias Fuchs | 407843a | 2007-12-28 17:07:18 +0100 | [diff] [blame] | 553 | |
| 554 | #endif /* CONFIG_CMD_BSP */ |