]> git.ipfire.org Git - people/ms/u-boot.git/blob - board/pcs440ep/pcs440ep.c
includes: move openssl headers to include/u-boot
[people/ms/u-boot.git] / board / pcs440ep / pcs440ep.c
1 /*
2 * (C) Copyright 2006
3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8 #include <common.h>
9 #include <asm/ppc4xx.h>
10 #include <malloc.h>
11 #include <command.h>
12 #include <crc.h>
13 #include <asm/processor.h>
14 #include <spd_sdram.h>
15 #include <status_led.h>
16 #include <u-boot/sha1.h>
17 #include <asm/io.h>
18 #include <net.h>
19 #include <ata.h>
20
21 DECLARE_GLOBAL_DATA_PTR;
22
23 extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */
24
25 unsigned char sha1_checksum[SHA1_SUM_LEN];
26
27 /* swap 4 Bits (Bit0 = Bit3, Bit1 = Bit2, Bit2 = Bit1 and Bit3 = Bit0) */
28 unsigned char swapbits[16] = {0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe,
29 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf};
30
31 static void set_leds (int val)
32 {
33 out32(GPIO0_OR, (in32 (GPIO0_OR) & ~0x78000000) | (val << 27));
34 }
35
36 #define GET_LEDS ((in32 (GPIO0_OR) & 0x78000000) >> 27)
37
38 void __led_init (led_id_t mask, int state)
39 {
40 int val = GET_LEDS;
41
42 if (state == STATUS_LED_ON)
43 val |= mask;
44 else
45 val &= ~mask;
46 set_leds (val);
47 }
48
49 void __led_set (led_id_t mask, int state)
50 {
51 int val = GET_LEDS;
52
53 if (state == STATUS_LED_ON)
54 val |= mask;
55 else if (state == STATUS_LED_OFF)
56 val &= ~mask;
57 set_leds (val);
58 }
59
60 void __led_toggle (led_id_t mask)
61 {
62 int val = GET_LEDS;
63
64 val ^= mask;
65 set_leds (val);
66 }
67
68 static void status_led_blink (void)
69 {
70 int i;
71 int val = GET_LEDS;
72
73 /* set all LED which are on, to state BLINKING */
74 for (i = 0; i < 4; i++) {
75 if (val & 0x01) status_led_set (3 - i, STATUS_LED_BLINKING);
76 else status_led_set (3 - i, STATUS_LED_OFF);
77 val = val >> 1;
78 }
79 }
80
81 #if defined(CONFIG_SHOW_BOOT_PROGRESS)
82 void show_boot_progress (int val)
83 {
84 /* find all valid Codes for val in README */
85 if (val == -BOOTSTAGE_ID_NEED_RESET)
86 return;
87 if (val < 0) {
88 /* smthing goes wrong */
89 status_led_blink ();
90 return;
91 }
92 switch (val) {
93 case BOOTSTAGE_ID_CHECK_MAGIC:
94 /* validating Image */
95 status_led_set(0, STATUS_LED_OFF);
96 status_led_set(1, STATUS_LED_ON);
97 status_led_set(2, STATUS_LED_ON);
98 break;
99 case BOOTSTAGE_ID_RUN_OS:
100 status_led_set(0, STATUS_LED_ON);
101 status_led_set(1, STATUS_LED_ON);
102 status_led_set(2, STATUS_LED_ON);
103 break;
104 #if 0
105 case BOOTSTAGE_ID_NET_ETH_START:
106 /* starting Ethernet configuration */
107 status_led_set(0, STATUS_LED_OFF);
108 status_led_set(1, STATUS_LED_OFF);
109 status_led_set(2, STATUS_LED_ON);
110 break;
111 #endif
112 case BOOTSTAGE_ID_NET_START:
113 /* loading Image */
114 status_led_set(0, STATUS_LED_ON);
115 status_led_set(1, STATUS_LED_OFF);
116 status_led_set(2, STATUS_LED_ON);
117 break;
118 }
119 }
120 #endif
121
122 int board_early_init_f(void)
123 {
124 register uint reg;
125
126 set_leds(0); /* display boot info counter */
127
128 /*--------------------------------------------------------------------
129 * Setup the external bus controller/chip selects
130 *-------------------------------------------------------------------*/
131 mtdcr(EBC0_CFGADDR, EBC0_CFG);
132 reg = mfdcr(EBC0_CFGDATA);
133 mtdcr(EBC0_CFGDATA, reg | 0x04000000); /* Set ATC */
134
135 /*--------------------------------------------------------------------
136 * GPIO's are alreay setup in arch/powerpc/cpu/ppc4xx/cpu_init.c
137 * via define from board config file.
138 *-------------------------------------------------------------------*/
139
140 /*--------------------------------------------------------------------
141 * Setup the interrupt controller polarities, triggers, etc.
142 *-------------------------------------------------------------------*/
143 mtdcr(UIC0SR, 0xffffffff); /* clear all */
144 mtdcr(UIC0ER, 0x00000000); /* disable all */
145 mtdcr(UIC0CR, 0x00000001); /* UIC1 crit is critical */
146 mtdcr(UIC0PR, 0xfffffe1f); /* per ref-board manual */
147 mtdcr(UIC0TR, 0x01c00000); /* per ref-board manual */
148 mtdcr(UIC0VR, 0x00000001); /* int31 highest, base=0x000 */
149 mtdcr(UIC0SR, 0xffffffff); /* clear all */
150
151 mtdcr(UIC1SR, 0xffffffff); /* clear all */
152 mtdcr(UIC1ER, 0x00000000); /* disable all */
153 mtdcr(UIC1CR, 0x00000000); /* all non-critical */
154 mtdcr(UIC1PR, 0xffffe0ff); /* per ref-board manual */
155 mtdcr(UIC1TR, 0x00ffc000); /* per ref-board manual */
156 mtdcr(UIC1VR, 0x00000001); /* int31 highest, base=0x000 */
157 mtdcr(UIC1SR, 0xffffffff); /* clear all */
158
159 /*--------------------------------------------------------------------
160 * Setup other serial configuration
161 *-------------------------------------------------------------------*/
162 mfsdr(SDR0_PCI0, reg);
163 mtsdr(SDR0_PCI0, 0x80000000 | reg); /* PCI arbiter enabled */
164 mtsdr(SDR0_PFC0, 0x00000000); /* Pin function: enable GPIO49-63 */
165 mtsdr(SDR0_PFC1, 0x00048000); /* Pin function: UART0 has 4 pins, select IRQ5 */
166
167 return 0;
168 }
169
170 #define EEPROM_LEN 256
171 static void load_ethaddr(void)
172 {
173 int ok_ethaddr, ok_eth1addr;
174 int ret;
175 uchar buf[EEPROM_LEN];
176 char *use_eeprom;
177 u16 checksumcrc16 = 0;
178
179 /* If the env is sane, then nothing for us to do */
180 ok_ethaddr = eth_getenv_enetaddr("ethaddr", buf);
181 ok_eth1addr = eth_getenv_enetaddr("eth1addr", buf);
182 if (ok_ethaddr && ok_eth1addr)
183 return;
184
185 /* read the MACs from EEprom */
186 status_led_set (0, STATUS_LED_ON);
187 status_led_set (1, STATUS_LED_ON);
188 ret = eeprom_read (CONFIG_SYS_I2C_EEPROM_ADDR, 0, buf, EEPROM_LEN);
189 if (ret == 0) {
190 checksumcrc16 = cyg_crc16 (buf, EEPROM_LEN - 2);
191 /* check, if the EEprom is programmed:
192 * - The Prefix(Byte 0,1,2) is equal to "ATR"
193 * - The checksum, stored in the last 2 Bytes, is correct
194 */
195 if ((strncmp ((char *)buf,"ATR",3) != 0) ||
196 ((checksumcrc16 >> 8) != buf[EEPROM_LEN - 2]) ||
197 ((checksumcrc16 & 0xff) != buf[EEPROM_LEN - 1])) {
198 /* EEprom is not programmed */
199 printf("%s: EEPROM Checksum not OK\n", __FUNCTION__);
200 } else {
201 /* get the MACs */
202 if (!ok_ethaddr)
203 eth_setenv_enetaddr("ethaddr", &buf[3]);
204 if (!ok_eth1addr)
205 eth_setenv_enetaddr("eth1addr", &buf[9]);
206 return;
207 }
208 }
209
210 /* some error reading the EEprom */
211 if ((use_eeprom = getenv ("use_eeprom_ethaddr")) == NULL) {
212 /* dont use bootcmd */
213 setenv("bootdelay", "-1");
214 return;
215 }
216 /* == default ? use standard */
217 if (strncmp (use_eeprom, "default", 7) == 0) {
218 return;
219 }
220 /* Env doesnt exist -> hang */
221 status_led_blink ();
222 /* here we do this "handy" because we have no interrupts
223 at this time */
224 puts ("### EEPROM ERROR ### Please RESET the board ###\n");
225 for (;;) {
226 __led_toggle (12);
227 udelay (100000);
228 }
229 return;
230 }
231
232 #ifdef CONFIG_PREBOOT
233
234 static uchar kbd_magic_prefix[] = "key_magic";
235 static uchar kbd_command_prefix[] = "key_cmd";
236
237 struct kbd_data_t {
238 char s1;
239 char s2;
240 };
241
242 struct kbd_data_t* get_keys (struct kbd_data_t *kbd_data)
243 {
244 char *val;
245 unsigned long tmp;
246
247 /* use the DIPs for some bootoptions */
248 val = getenv (ENV_NAME_DIP);
249 tmp = simple_strtoul (val, NULL, 16);
250
251 kbd_data->s2 = (tmp & 0x0f);
252 kbd_data->s1 = (tmp & 0xf0) >> 4;
253 return kbd_data;
254 }
255
256 static int compare_magic (const struct kbd_data_t *kbd_data, char *str)
257 {
258 char s1 = str[0];
259
260 if (s1 >= '0' && s1 <= '9')
261 s1 -= '0';
262 else if (s1 >= 'a' && s1 <= 'f')
263 s1 = s1 - 'a' + 10;
264 else if (s1 >= 'A' && s1 <= 'F')
265 s1 = s1 - 'A' + 10;
266 else
267 return -1;
268
269 if (s1 != kbd_data->s1) return -1;
270
271 s1 = str[1];
272 if (s1 >= '0' && s1 <= '9')
273 s1 -= '0';
274 else if (s1 >= 'a' && s1 <= 'f')
275 s1 = s1 - 'a' + 10;
276 else if (s1 >= 'A' && s1 <= 'F')
277 s1 = s1 - 'A' + 10;
278 else
279 return -1;
280
281 if (s1 != kbd_data->s2) return -1;
282 return 0;
283 }
284
285 static char *key_match (const struct kbd_data_t *kbd_data)
286 {
287 char magic[sizeof (kbd_magic_prefix) + 1];
288 char *suffix;
289 char *kbd_magic_keys;
290
291 /*
292 * The following string defines the characters that can be appended
293 * to "key_magic" to form the names of environment variables that
294 * hold "magic" key codes, i. e. such key codes that can cause
295 * pre-boot actions. If the string is empty (""), then only
296 * "key_magic" is checked (old behaviour); the string "125" causes
297 * checks for "key_magic1", "key_magic2" and "key_magic5", etc.
298 */
299 if ((kbd_magic_keys = getenv ("magic_keys")) == NULL)
300 kbd_magic_keys = "";
301
302 /* loop over all magic keys;
303 * use '\0' suffix in case of empty string
304 */
305 for (suffix = kbd_magic_keys; *suffix ||
306 suffix == kbd_magic_keys; ++suffix) {
307 sprintf (magic, "%s%c", kbd_magic_prefix, *suffix);
308 if (compare_magic (kbd_data, getenv (magic)) == 0) {
309 char cmd_name[sizeof (kbd_command_prefix) + 1];
310 char *cmd;
311
312 sprintf (cmd_name, "%s%c", kbd_command_prefix, *suffix);
313 cmd = getenv (cmd_name);
314
315 return (cmd);
316 }
317 }
318 return (NULL);
319 }
320
321 #endif /* CONFIG_PREBOOT */
322
323 static int pcs440ep_readinputs (void)
324 {
325 int i;
326 char value[20];
327
328 /* read the inputs and set the Envvars */
329 /* Revision Level Bit 26 - 29 */
330 i = ((in32 (GPIO0_IR) & 0x0000003c) >> 2);
331 i = swapbits[i];
332 sprintf (value, "%02x", i);
333 setenv (ENV_NAME_REVLEV, value);
334 /* Solder Switch Bit 30 - 33 */
335 i = (in32 (GPIO0_IR) & 0x00000003) << 2;
336 i += (in32 (GPIO1_IR) & 0xc0000000) >> 30;
337 i = swapbits[i];
338 sprintf (value, "%02x", i);
339 setenv (ENV_NAME_SOLDER, value);
340 /* DIP Switch Bit 49 - 56 */
341 i = ((in32 (GPIO1_IR) & 0x00007f80) >> 7);
342 i = (swapbits[i & 0x0f] << 4) + swapbits[(i & 0xf0) >> 4];
343 sprintf (value, "%02x", i);
344 setenv (ENV_NAME_DIP, value);
345 return 0;
346 }
347
348
349 #if defined(CONFIG_SHA1_CHECK_UB_IMG)
350 /*************************************************************************
351 * calculate a SHA1 sum for the U-Boot image in Flash.
352 *
353 ************************************************************************/
354 static int pcs440ep_sha1 (int docheck)
355 {
356 unsigned char *data;
357 unsigned char *ptroff;
358 unsigned char output[20];
359 unsigned char org[20];
360 int i, len = CONFIG_SHA1_LEN;
361
362 memcpy ((char *)CONFIG_SYS_LOAD_ADDR, (char *)CONFIG_SHA1_START, len);
363 data = (unsigned char *)CONFIG_SYS_LOAD_ADDR;
364 ptroff = &data[len + SHA1_SUM_POS];
365
366 for (i = 0; i < SHA1_SUM_LEN; i++) {
367 org[i] = ptroff[i];
368 ptroff[i] = 0;
369 }
370
371 sha1_csum ((unsigned char *) data, len, (unsigned char *)output);
372
373 if (docheck == 2) {
374 for (i = 0; i < 20 ; i++) {
375 printf("%02X ", output[i]);
376 }
377 printf("\n");
378 }
379 if (docheck == 1) {
380 for (i = 0; i < 20 ; i++) {
381 if (org[i] != output[i]) return 1;
382 }
383 }
384 return 0;
385 }
386
387 /*************************************************************************
388 * do some checks after the SHA1 checksum from the U-Boot Image was
389 * calculated.
390 *
391 ************************************************************************/
392 static void pcs440ep_checksha1 (void)
393 {
394 int ret;
395 char *cs_test;
396
397 status_led_set (0, STATUS_LED_OFF);
398 status_led_set (1, STATUS_LED_OFF);
399 status_led_set (2, STATUS_LED_ON);
400 ret = pcs440ep_sha1 (1);
401 if (ret == 0) return;
402
403 if ((cs_test = getenv ("cs_test")) == NULL) {
404 /* Env doesnt exist -> hang */
405 status_led_blink ();
406 /* here we do this "handy" because we have no interrupts
407 at this time */
408 puts ("### SHA1 ERROR ### Please RESET the board ###\n");
409 for (;;) {
410 __led_toggle (2);
411 udelay (100000);
412 }
413 }
414
415 if (strncmp (cs_test, "off", 3) == 0) {
416 printf ("SHA1 U-Boot sum NOT ok!\n");
417 setenv ("bootdelay", "-1");
418 }
419 }
420 #else
421 static __inline__ void pcs440ep_checksha1 (void) { do {} while (0);}
422 #endif
423
424 int misc_init_r (void)
425 {
426 uint pbcr;
427 int size_val = 0;
428
429 load_ethaddr();
430
431 /* Re-do sizing to get full correct info */
432 mtdcr(EBC0_CFGADDR, PB0CR);
433 pbcr = mfdcr(EBC0_CFGDATA);
434 switch (gd->bd->bi_flashsize) {
435 case 1 << 20:
436 size_val = 0;
437 break;
438 case 2 << 20:
439 size_val = 1;
440 break;
441 case 4 << 20:
442 size_val = 2;
443 break;
444 case 8 << 20:
445 size_val = 3;
446 break;
447 case 16 << 20:
448 size_val = 4;
449 break;
450 case 32 << 20:
451 size_val = 5;
452 break;
453 case 64 << 20:
454 size_val = 6;
455 break;
456 case 128 << 20:
457 size_val = 7;
458 break;
459 }
460 pbcr = (pbcr & 0x0001ffff) | gd->bd->bi_flashstart | (size_val << 17);
461 mtdcr(EBC0_CFGADDR, PB0CR);
462 mtdcr(EBC0_CFGDATA, pbcr);
463
464 /* adjust flash start and offset */
465 gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
466 gd->bd->bi_flashoffset = 0;
467
468 /* Monitor protection ON by default */
469 (void)flash_protect(FLAG_PROTECT_SET,
470 -CONFIG_SYS_MONITOR_LEN,
471 0xffffffff,
472 &flash_info[1]);
473
474 /* Env protection ON by default */
475 (void)flash_protect(FLAG_PROTECT_SET,
476 CONFIG_ENV_ADDR_REDUND,
477 CONFIG_ENV_ADDR_REDUND + 2*CONFIG_ENV_SECT_SIZE - 1,
478 &flash_info[1]);
479
480 pcs440ep_readinputs ();
481 pcs440ep_checksha1 ();
482 #ifdef CONFIG_PREBOOT
483 {
484 struct kbd_data_t kbd_data;
485 /* Decode keys */
486 char *str = strdup (key_match (get_keys (&kbd_data)));
487 /* Set or delete definition */
488 setenv ("preboot", str);
489 free (str);
490 }
491 #endif /* CONFIG_PREBOOT */
492 return 0;
493 }
494
495 int checkboard(void)
496 {
497 char buf[64];
498 int i = getenv_f("serial#", buf, sizeof(buf));
499
500 printf("Board: PCS440EP");
501 if (i > 0) {
502 puts(", serial# ");
503 puts(buf);
504 }
505 putc('\n');
506
507 return (0);
508 }
509
510 void spd_ddr_init_hang (void)
511 {
512 status_led_set (0, STATUS_LED_OFF);
513 status_led_set (1, STATUS_LED_ON);
514 /* we cannot use hang() because we are still running from
515 Flash, and so the status_led driver is not initialized */
516 puts ("### SDRAM ERROR ### Please RESET the board ###\n");
517 for (;;) {
518 __led_toggle (4);
519 udelay (100000);
520 }
521 }
522
523 phys_size_t initdram (int board_type)
524 {
525 long dram_size = 0;
526
527 status_led_set (0, STATUS_LED_ON);
528 status_led_set (1, STATUS_LED_OFF);
529 dram_size = spd_sdram();
530 status_led_set (0, STATUS_LED_OFF);
531 status_led_set (1, STATUS_LED_ON);
532 if (dram_size == 0) {
533 hang();
534 }
535
536 return dram_size;
537 }
538
539 /*************************************************************************
540 * hw_watchdog_reset
541 *
542 * This routine is called to reset (keep alive) the watchdog timer
543 *
544 ************************************************************************/
545 #if defined(CONFIG_HW_WATCHDOG)
546 void hw_watchdog_reset(void)
547 {
548
549 }
550 #endif
551
552 /*************************************************************************
553 * "led" Commando for the U-Boot shell
554 *
555 ************************************************************************/
556 int do_led (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
557 {
558 int rcode = 0, i;
559 ulong pattern = 0;
560
561 pattern = simple_strtoul (argv[1], NULL, 16);
562 if (pattern > 0x400) {
563 int val = GET_LEDS;
564 printf ("led: %x\n", val);
565 return rcode;
566 }
567 if (pattern > 0x200) {
568 status_led_blink ();
569 hang ();
570 return rcode;
571 }
572 if (pattern > 0x100) {
573 status_led_blink ();
574 return rcode;
575 }
576 pattern &= 0x0f;
577 for (i = 0; i < 4; i++) {
578 if (pattern & 0x01) status_led_set (i, STATUS_LED_ON);
579 else status_led_set (i, STATUS_LED_OFF);
580 pattern = pattern >> 1;
581 }
582 return rcode;
583 }
584
585 U_BOOT_CMD(
586 led, 2, 1, do_led,
587 "set the DIAG-LED",
588 "[bitmask] 0x01 = DIAG 1 on\n"
589 " 0x02 = DIAG 2 on\n"
590 " 0x04 = DIAG 3 on\n"
591 " 0x08 = DIAG 4 on\n"
592 " > 0x100 set the LED, who are on, to state blinking"
593 );
594
595 #if defined(CONFIG_SHA1_CHECK_UB_IMG)
596 /*************************************************************************
597 * "sha1" Commando for the U-Boot shell
598 *
599 ************************************************************************/
600 int do_sha1 (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
601 {
602 int rcode = -1;
603
604 if (argc < 2) {
605 usage:
606 return cmd_usage(cmdtp);
607 }
608
609 if (argc >= 3) {
610 unsigned char *data;
611 unsigned char output[20];
612 int len;
613 int i;
614
615 data = (unsigned char *)simple_strtoul (argv[1], NULL, 16);
616 len = simple_strtoul (argv[2], NULL, 16);
617 sha1_csum (data, len, (unsigned char *)output);
618 printf ("U-Boot sum:\n");
619 for (i = 0; i < 20 ; i++) {
620 printf ("%02X ", output[i]);
621 }
622 printf ("\n");
623 if (argc == 4) {
624 data = (unsigned char *)simple_strtoul (argv[3], NULL, 16);
625 memcpy (data, output, 20);
626 }
627 return 0;
628 }
629 if (argc == 2) {
630 char *ptr = argv[1];
631 if (*ptr != '-') goto usage;
632 ptr++;
633 if ((*ptr == 'c') || (*ptr == 'C')) {
634 rcode = pcs440ep_sha1 (1);
635 printf ("SHA1 U-Boot sum %sok!\n", (rcode != 0) ? "not " : "");
636 } else if ((*ptr == 'p') || (*ptr == 'P')) {
637 rcode = pcs440ep_sha1 (2);
638 } else {
639 rcode = pcs440ep_sha1 (0);
640 }
641 return rcode;
642 }
643 return rcode;
644 }
645
646 U_BOOT_CMD(
647 sha1, 4, 1, do_sha1,
648 "calculate the SHA1 Sum",
649 "address len [addr] calculate the SHA1 sum [save at addr]\n"
650 " -p calculate the SHA1 sum from the U-Boot image in flash and print\n"
651 " -c check the U-Boot image in flash"
652 );
653 #endif
654
655 #if defined (CONFIG_CMD_IDE)
656 /* These addresses need to be shifted one place to the left
657 * ( bus per_addr 20 -30 is connectsd on CF bus A10-A0)
658 * These values are shifted
659 */
660 void inline ide_outb(int dev, int port, unsigned char val)
661 {
662 debug ("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n",
663 dev, port, val, (ATA_CURR_BASE(dev)+port));
664
665 out_be16((u16 *)(ATA_CURR_BASE(dev)+(port << 1)), val);
666 }
667 unsigned char inline ide_inb(int dev, int port)
668 {
669 uchar val;
670 val = in_be16((u16 *)(ATA_CURR_BASE(dev)+(port << 1)));
671 debug ("ide_inb (dev= %d, port= 0x%x) : @ 0x%08lx -> 0x%02x\n",
672 dev, port, (ATA_CURR_BASE(dev)+port), val);
673 return (val);
674 }
675 #endif
676
677 #ifdef CONFIG_IDE_PREINIT
678 int ide_preinit (void)
679 {
680 /* Set True IDE Mode */
681 out32 (GPIO0_OR, (in32 (GPIO0_OR) | 0x00100000));
682 out32 (GPIO0_OR, (in32 (GPIO0_OR) | 0x00200000));
683 out32 (GPIO1_OR, (in32 (GPIO1_OR) & ~0x00008040));
684 udelay (100000);
685 return 0;
686 }
687 #endif
688
689 #if defined (CONFIG_CMD_IDE) && defined (CONFIG_IDE_RESET)
690 void ide_set_reset (int idereset)
691 {
692 debug ("ide_reset(%d)\n", idereset);
693 if (idereset == 0) {
694 out32 (GPIO0_OR, (in32 (GPIO0_OR) | 0x00200000));
695 } else {
696 out32 (GPIO0_OR, (in32 (GPIO0_OR) & ~0x00200000));
697 }
698 udelay (10000);
699 }
700 #endif /* defined (CONFIG_CMD_IDE) && defined (CONFIG_IDE_RESET) */
701
702
703 /* this is motly the same as it should, causing a little code duplication */
704 #if defined(CONFIG_CMD_IDE)
705 #define EIEIO __asm__ volatile ("eieio")
706
707 void ide_input_swap_data(int dev, ulong *sect_buf, int words)
708 {
709 volatile ushort *pbuf =
710 (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
711 ushort *dbuf = (ushort *) sect_buf;
712
713 debug("in input swap data base for read is %lx\n",
714 (unsigned long) pbuf);
715
716 while (words--) {
717 *dbuf++ = *pbuf;
718 *dbuf++ = *pbuf;
719 }
720 }
721
722 void ide_output_data(int dev, const ulong *sect_buf, int words)
723 {
724 ushort *dbuf;
725 volatile ushort *pbuf;
726
727 pbuf = (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
728 dbuf = (ushort *) sect_buf;
729 while (words--) {
730 EIEIO;
731 *pbuf = ld_le16(dbuf++);
732 EIEIO;
733 *pbuf = ld_le16(dbuf++);
734 }
735 }
736
737 void ide_input_data(int dev, ulong *sect_buf, int words)
738 {
739 ushort *dbuf;
740 volatile ushort *pbuf;
741
742 pbuf = (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
743 dbuf = (ushort *) sect_buf;
744
745 debug("in input data base for read is %lx\n", (unsigned long) pbuf);
746
747 while (words--) {
748 EIEIO;
749 *dbuf++ = ld_le16(pbuf);
750 EIEIO;
751 *dbuf++ = ld_le16(pbuf);
752 }
753 }
754
755 #endif