]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/pcs440ep/pcs440ep.c
3 * Stefan Roese, DENX Software Engineering, sr@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,
29 #include <asm/processor.h>
30 #include <spd_sdram.h>
31 #include <status_led.h>
34 DECLARE_GLOBAL_DATA_PTR
;
36 extern flash_info_t flash_info
[CFG_MAX_FLASH_BANKS
]; /* info for FLASH chips */
38 unsigned char sha1_checksum
[SHA1_SUM_LEN
];
40 /* swap 4 Bits (Bit0 = Bit3, Bit1 = Bit2, Bit2 = Bit1 and Bit3 = Bit0) */
41 unsigned char swapbits
[16] = {0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe,
42 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf};
44 static void set_leds (int val
)
46 out32(GPIO0_OR
, (in32 (GPIO0_OR
) & ~0x78000000) | (val
<< 27));
49 #define GET_LEDS ((in32 (GPIO0_OR) & 0x78000000) >> 27)
51 void __led_init (led_id_t mask
, int state
)
55 if (state
== STATUS_LED_ON
)
62 void __led_set (led_id_t mask
, int state
)
66 if (state
== STATUS_LED_ON
)
68 else if (state
== STATUS_LED_OFF
)
73 void __led_toggle (led_id_t mask
)
81 static void status_led_blink (void)
86 /* set all LED which are on, to state BLINKING */
87 for (i
= 0; i
< 4; i
++) {
88 if (val
& 0x01) status_led_set (3 - i
, STATUS_LED_BLINKING
);
89 else status_led_set (3 - i
, STATUS_LED_OFF
);
94 #if defined(CONFIG_SHOW_BOOT_PROGRESS)
95 void show_boot_progress (int val
)
97 /* find all valid Codes for val in README */
98 if (val
== -30) return;
100 /* smthing goes wrong */
106 /* validating Image */
107 status_led_set (0, STATUS_LED_OFF
);
108 status_led_set (1, STATUS_LED_ON
);
109 status_led_set (2, STATUS_LED_ON
);
113 status_led_set (0, STATUS_LED_ON
);
114 status_led_set (1, STATUS_LED_ON
);
115 status_led_set (2, STATUS_LED_ON
);
119 /* starting Ethernet configuration */
120 status_led_set (0, STATUS_LED_OFF
);
121 status_led_set (1, STATUS_LED_OFF
);
122 status_led_set (2, STATUS_LED_ON
);
127 status_led_set (0, STATUS_LED_ON
);
128 status_led_set (1, STATUS_LED_OFF
);
129 status_led_set (2, STATUS_LED_ON
);
135 int board_early_init_f(void)
139 set_leds(0); /* display boot info counter */
141 /*--------------------------------------------------------------------
142 * Setup the external bus controller/chip selects
143 *-------------------------------------------------------------------*/
144 mtdcr(ebccfga
, xbcfg
);
145 reg
= mfdcr(ebccfgd
);
146 mtdcr(ebccfgd
, reg
| 0x04000000); /* Set ATC */
148 /*--------------------------------------------------------------------
149 * GPIO's are alreay setup in cpu/ppc4xx/cpu_init.c
150 * via define from board config file.
151 *-------------------------------------------------------------------*/
153 /*--------------------------------------------------------------------
154 * Setup the interrupt controller polarities, triggers, etc.
155 *-------------------------------------------------------------------*/
156 mtdcr(uic0sr
, 0xffffffff); /* clear all */
157 mtdcr(uic0er
, 0x00000000); /* disable all */
158 mtdcr(uic0cr
, 0x00000001); /* UIC1 crit is critical */
159 mtdcr(uic0pr
, 0xfffffe1f); /* per ref-board manual */
160 mtdcr(uic0tr
, 0x01c00000); /* per ref-board manual */
161 mtdcr(uic0vr
, 0x00000001); /* int31 highest, base=0x000 */
162 mtdcr(uic0sr
, 0xffffffff); /* clear all */
164 mtdcr(uic1sr
, 0xffffffff); /* clear all */
165 mtdcr(uic1er
, 0x00000000); /* disable all */
166 mtdcr(uic1cr
, 0x00000000); /* all non-critical */
167 mtdcr(uic1pr
, 0xffffe0ff); /* per ref-board manual */
168 mtdcr(uic1tr
, 0x00ffc000); /* per ref-board manual */
169 mtdcr(uic1vr
, 0x00000001); /* int31 highest, base=0x000 */
170 mtdcr(uic1sr
, 0xffffffff); /* clear all */
172 /*--------------------------------------------------------------------
173 * Setup other serial configuration
174 *-------------------------------------------------------------------*/
175 mfsdr(sdr_pci0
, reg
);
176 mtsdr(sdr_pci0
, 0x80000000 | reg
); /* PCI arbiter enabled */
177 mtsdr(sdr_pfc0
, 0x00000100); /* Pin function: enable GPIO49-63 */
178 mtsdr(sdr_pfc1
, 0x00048000); /* Pin function: UART0 has 4 pins, select IRQ5 */
183 #define EEPROM_LEN 256
184 void load_sernum_ethaddr (void)
187 char buf
[EEPROM_LEN
];
190 u16 checksumcrc16
= 0;
192 /* read the MACs from EEprom */
193 status_led_set (0, STATUS_LED_ON
);
194 status_led_set (1, STATUS_LED_ON
);
195 ret
= eeprom_read (CFG_I2C_EEPROM_ADDR
, 0, (uchar
*)buf
, EEPROM_LEN
);
197 checksumcrc16
= cyg_crc16 ((uchar
*)buf
, EEPROM_LEN
- 2);
198 /* check, if the EEprom is programmed:
199 * - The Prefix(Byte 0,1,2) is equal to "ATR"
200 * - The checksum, stored in the last 2 Bytes, is correct
202 if ((strncmp (buf
,"ATR",3) != 0) ||
203 ((checksumcrc16
>> 8) != buf
[EEPROM_LEN
- 2]) ||
204 ((checksumcrc16
& 0xff) != buf
[EEPROM_LEN
- 1])) {
205 /* EEprom is not programmed */
206 printf("%s: EEPROM Checksum not OK\n", __FUNCTION__
);
209 sprintf (mac
, "%02x:%02x:%02x:%02x:%02x:%02x",
216 setenv ("ethaddr", (char *) mac
);
217 sprintf (mac
, "%02x:%02x:%02x:%02x:%02x:%02x",
224 setenv ("eth1addr", (char *) mac
);
229 /* some error reading the EEprom */
230 if ((use_eeprom
= getenv ("use_eeprom_ethaddr")) == NULL
) {
231 /* dont use bootcmd */
232 setenv("bootdelay", "-1");
235 /* == default ? use standard */
236 if (strncmp (use_eeprom
, "default", 7) == 0) {
239 /* Env doesnt exist -> hang */
245 #ifdef CONFIG_PREBOOT
247 static uchar kbd_magic_prefix
[] = "key_magic";
248 static uchar kbd_command_prefix
[] = "key_cmd";
255 struct kbd_data_t
* get_keys (struct kbd_data_t
*kbd_data
)
260 /* use the DIPs for some bootoptions */
261 val
= getenv (ENV_NAME_DIP
);
262 tmp
= simple_strtoul (val
, NULL
, 16);
264 kbd_data
->s2
= (tmp
& 0x0f);
265 kbd_data
->s1
= (tmp
& 0xf0) >> 4;
269 static int compare_magic (const struct kbd_data_t
*kbd_data
, char *str
)
273 if (s1
>= '0' && s1
<= '9')
275 else if (s1
>= 'a' && s1
<= 'f')
277 else if (s1
>= 'A' && s1
<= 'F')
282 if (s1
!= kbd_data
->s1
) return -1;
285 if (s1
>= '0' && s1
<= '9')
287 else if (s1
>= 'a' && s1
<= 'f')
289 else if (s1
>= 'A' && s1
<= 'F')
294 if (s1
!= kbd_data
->s2
) return -1;
298 static char *key_match (const struct kbd_data_t
*kbd_data
)
300 char magic
[sizeof (kbd_magic_prefix
) + 1];
302 char *kbd_magic_keys
;
305 * The following string defines the characters that can be appended
306 * to "key_magic" to form the names of environment variables that
307 * hold "magic" key codes, i. e. such key codes that can cause
308 * pre-boot actions. If the string is empty (""), then only
309 * "key_magic" is checked (old behaviour); the string "125" causes
310 * checks for "key_magic1", "key_magic2" and "key_magic5", etc.
312 if ((kbd_magic_keys
= getenv ("magic_keys")) == NULL
)
315 /* loop over all magic keys;
316 * use '\0' suffix in case of empty string
318 for (suffix
= kbd_magic_keys
; *suffix
||
319 suffix
== kbd_magic_keys
; ++suffix
) {
320 sprintf (magic
, "%s%c", kbd_magic_prefix
, *suffix
);
321 if (compare_magic (kbd_data
, getenv (magic
)) == 0) {
322 char cmd_name
[sizeof (kbd_command_prefix
) + 1];
325 sprintf (cmd_name
, "%s%c", kbd_command_prefix
, *suffix
);
326 cmd
= getenv (cmd_name
);
334 #endif /* CONFIG_PREBOOT */
336 static int pcs440ep_readinputs (void)
341 /* read the inputs and set the Envvars */
342 /* Revision Level Bit 26 - 29 */
343 i
= ((in32 (GPIO0_IR
) & 0x0000003c) >> 2);
345 sprintf (value
, "%02x", i
);
346 setenv (ENV_NAME_REVLEV
, value
);
347 /* Solder Switch Bit 30 - 33 */
348 i
= (in32 (GPIO0_IR
) & 0x00000003) << 2;
349 i
+= (in32 (GPIO1_IR
) & 0xc0000000) >> 30;
351 sprintf (value
, "%02x", i
);
352 setenv (ENV_NAME_SOLDER
, value
);
353 /* DIP Switch Bit 49 - 56 */
354 i
= ((in32 (GPIO1_IR
) & 0x00007f80) >> 7);
355 i
= (swapbits
[i
& 0x0f] << 4) + swapbits
[(i
& 0xf0) >> 4];
356 sprintf (value
, "%02x", i
);
357 setenv (ENV_NAME_DIP
, value
);
362 #if defined(CONFIG_SHA1_CHECK_UB_IMG)
363 /*************************************************************************
364 * calculate a SHA1 sum for the U-Boot image in Flash.
366 ************************************************************************/
367 static int pcs440ep_sha1 (int docheck
)
370 unsigned char *ptroff
;
371 unsigned char output
[20];
372 unsigned char org
[20];
373 int i
, len
= CONFIG_SHA1_LEN
;
375 memcpy ((char *)CFG_LOAD_ADDR
, (char *)CONFIG_SHA1_START
, len
);
376 data
= (unsigned char *)CFG_LOAD_ADDR
;
377 ptroff
= &data
[len
+ SHA1_SUM_POS
];
379 for (i
= 0; i
< SHA1_SUM_LEN
; i
++) {
384 sha1_csum ((unsigned char *) data
, len
, (unsigned char *)output
);
387 for (i
= 0; i
< 20 ; i
++) {
388 printf("%02X ", output
[i
]);
393 for (i
= 0; i
< 20 ; i
++) {
394 if (org
[i
] != output
[i
]) return 1;
400 /*************************************************************************
401 * do some checks after the SHA1 checksum from the U-Boot Image was
404 ************************************************************************/
405 static void pcs440ep_checksha1 (void)
410 status_led_set (0, STATUS_LED_OFF
);
411 status_led_set (1, STATUS_LED_OFF
);
412 status_led_set (2, STATUS_LED_ON
);
413 ret
= pcs440ep_sha1 (1);
414 if (ret
== 0) return;
416 if ((cs_test
= getenv ("cs_test")) == NULL
) {
417 /* Env doesnt exist -> hang */
422 if (strncmp (cs_test
, "off", 3) == 0) {
423 printf ("SHA1 U-Boot sum NOT ok!\n");
424 setenv ("bootdelay", "-1");
428 static __inline__
void pcs440ep_checksha1 (void) { do {} while (0);}
431 int misc_init_r (void)
436 /* Re-do sizing to get full correct info */
437 mtdcr(ebccfga
, pb0cr
);
438 pbcr
= mfdcr(ebccfgd
);
439 switch (gd
->bd
->bi_flashsize
) {
465 pbcr
= (pbcr
& 0x0001ffff) | gd
->bd
->bi_flashstart
| (size_val
<< 17);
466 mtdcr(ebccfga
, pb0cr
);
467 mtdcr(ebccfgd
, pbcr
);
469 /* adjust flash start and offset */
470 gd
->bd
->bi_flashstart
= 0 - gd
->bd
->bi_flashsize
;
471 gd
->bd
->bi_flashoffset
= 0;
473 /* Monitor protection ON by default */
474 (void)flash_protect(FLAG_PROTECT_SET
,
479 /* Env protection ON by default */
480 (void)flash_protect(FLAG_PROTECT_SET
,
482 CFG_ENV_ADDR_REDUND
+ 2*CFG_ENV_SECT_SIZE
- 1,
485 pcs440ep_readinputs ();
486 pcs440ep_checksha1 ();
487 #ifdef CONFIG_PREBOOT
489 struct kbd_data_t kbd_data
;
491 char *str
= strdup (key_match (get_keys (&kbd_data
)));
492 /* Set or delete definition */
493 setenv ("preboot", str
);
496 #endif /* CONFIG_PREBOOT */
502 char *s
= getenv("serial#");
504 printf("Board: PCS440EP");
514 void spd_ddr_init_hang (void)
516 status_led_set (0, STATUS_LED_OFF
);
517 status_led_set (1, STATUS_LED_ON
);
518 /* we cannot use hang() because we are still running from
519 Flash, and so the status_led driver is not initialized */
520 puts ("### ERROR ### Please RESET the board ###\n");
527 long int initdram (int board_type
)
531 status_led_set (0, STATUS_LED_ON
);
532 status_led_set (1, STATUS_LED_OFF
);
533 dram_size
= spd_sdram();
534 status_led_set (0, STATUS_LED_OFF
);
535 status_led_set (1, STATUS_LED_ON
);
536 if (dram_size
== 0) {
543 #if defined(CFG_DRAM_TEST)
546 unsigned long *mem
= (unsigned long *)0;
547 const unsigned long kend
= (1024 / sizeof(unsigned long));
552 for (k
= 0; k
< CFG_KBYTES_SDRAM
;
553 ++k
, mem
+= (1024 / sizeof(unsigned long))) {
554 if ((k
& 1023) == 0) {
555 printf("%3d MB\r", k
/ 1024);
558 memset(mem
, 0xaaaaaaaa, 1024);
559 for (n
= 0; n
< kend
; ++n
) {
560 if (mem
[n
] != 0xaaaaaaaa) {
561 printf("SDRAM test fails at: %08x\n",
567 memset(mem
, 0x55555555, 1024);
568 for (n
= 0; n
< kend
; ++n
) {
569 if (mem
[n
] != 0x55555555) {
570 printf("SDRAM test fails at: %08x\n",
576 printf("SDRAM test passes\n");
581 /*************************************************************************
584 * This routine is called just prior to registering the hose and gives
585 * the board the opportunity to check things. Returning a value of zero
586 * indicates that things are bad & PCI initialization should be aborted.
588 * Different boards may wish to customize the pci controller structure
589 * (add regions, override default access routines, etc) or perform
590 * certain pre-initialization actions.
592 ************************************************************************/
593 #if defined(CONFIG_PCI)
594 int pci_pre_init(struct pci_controller
*hose
)
598 /*-------------------------------------------------------------------------+
599 | Set priority for all PLB3 devices to 0.
600 | Set PLB3 arbiter to fair mode.
601 +-------------------------------------------------------------------------*/
602 mfsdr(sdr_amp1
, addr
);
603 mtsdr(sdr_amp1
, (addr
& 0x000000FF) | 0x0000FF00);
604 addr
= mfdcr(plb3_acr
);
605 mtdcr(plb3_acr
, addr
| 0x80000000);
607 /*-------------------------------------------------------------------------+
608 | Set priority for all PLB4 devices to 0.
609 +-------------------------------------------------------------------------*/
610 mfsdr(sdr_amp0
, addr
);
611 mtsdr(sdr_amp0
, (addr
& 0x000000FF) | 0x0000FF00);
612 addr
= mfdcr(plb4_acr
) | 0xa0000000; /* Was 0x8---- */
613 mtdcr(plb4_acr
, addr
);
615 /*-------------------------------------------------------------------------+
616 | Set Nebula PLB4 arbiter to fair mode.
617 +-------------------------------------------------------------------------*/
619 addr
= (mfdcr(plb0_acr
) & ~plb0_acr_ppm_mask
) | plb0_acr_ppm_fair
;
620 addr
= (addr
& ~plb0_acr_hbu_mask
) | plb0_acr_hbu_enabled
;
621 addr
= (addr
& ~plb0_acr_rdp_mask
) | plb0_acr_rdp_4deep
;
622 addr
= (addr
& ~plb0_acr_wrp_mask
) | plb0_acr_wrp_2deep
;
623 mtdcr(plb0_acr
, addr
);
626 addr
= (mfdcr(plb1_acr
) & ~plb1_acr_ppm_mask
) | plb1_acr_ppm_fair
;
627 addr
= (addr
& ~plb1_acr_hbu_mask
) | plb1_acr_hbu_enabled
;
628 addr
= (addr
& ~plb1_acr_rdp_mask
) | plb1_acr_rdp_4deep
;
629 addr
= (addr
& ~plb1_acr_wrp_mask
) | plb1_acr_wrp_2deep
;
630 mtdcr(plb1_acr
, addr
);
634 #endif /* defined(CONFIG_PCI) */
636 /*************************************************************************
639 * The bootstrap configuration provides default settings for the pci
640 * inbound map (PIM). But the bootstrap config choices are limited and
641 * may not be sufficient for a given board.
643 ************************************************************************/
644 #if defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT)
645 void pci_target_init(struct pci_controller
*hose
)
647 /*--------------------------------------------------------------------------+
648 * Set up Direct MMIO registers
649 *--------------------------------------------------------------------------*/
650 /*--------------------------------------------------------------------------+
651 | PowerPC440 EP PCI Master configuration.
652 | Map one 1Gig range of PLB/processor addresses to PCI memory space.
653 | PLB address 0xA0000000-0xDFFFFFFF ==> PCI address 0xA0000000-0xDFFFFFFF
654 | Use byte reversed out routines to handle endianess.
655 | Make this region non-prefetchable.
656 +--------------------------------------------------------------------------*/
657 out32r(PCIX0_PMM0MA
, 0x00000000); /* PMM0 Mask/Attribute - disabled b4 setting */
658 out32r(PCIX0_PMM0LA
, CFG_PCI_MEMBASE
); /* PMM0 Local Address */
659 out32r(PCIX0_PMM0PCILA
, CFG_PCI_MEMBASE
); /* PMM0 PCI Low Address */
660 out32r(PCIX0_PMM0PCIHA
, 0x00000000); /* PMM0 PCI High Address */
661 out32r(PCIX0_PMM0MA
, 0xE0000001); /* 512M + No prefetching, and enable region */
663 out32r(PCIX0_PMM1MA
, 0x00000000); /* PMM0 Mask/Attribute - disabled b4 setting */
664 out32r(PCIX0_PMM1LA
, CFG_PCI_MEMBASE2
); /* PMM0 Local Address */
665 out32r(PCIX0_PMM1PCILA
, CFG_PCI_MEMBASE2
); /* PMM0 PCI Low Address */
666 out32r(PCIX0_PMM1PCIHA
, 0x00000000); /* PMM0 PCI High Address */
667 out32r(PCIX0_PMM1MA
, 0xE0000001); /* 512M + No prefetching, and enable region */
669 out32r(PCIX0_PTM1MS
, 0x00000001); /* Memory Size/Attribute */
670 out32r(PCIX0_PTM1LA
, 0); /* Local Addr. Reg */
671 out32r(PCIX0_PTM2MS
, 0); /* Memory Size/Attribute */
672 out32r(PCIX0_PTM2LA
, 0); /* Local Addr. Reg */
674 /*--------------------------------------------------------------------------+
675 * Set up Configuration registers
676 *--------------------------------------------------------------------------*/
678 /* Program the board's subsystem id/vendor id */
679 pci_write_config_word(0, PCI_SUBSYSTEM_VENDOR_ID
,
680 CFG_PCI_SUBSYS_VENDORID
);
681 pci_write_config_word(0, PCI_SUBSYSTEM_ID
, CFG_PCI_SUBSYS_ID
);
683 /* Configure command register as bus master */
684 pci_write_config_word(0, PCI_COMMAND
, PCI_COMMAND_MASTER
);
686 /* 240nS PCI clock */
687 pci_write_config_word(0, PCI_LATENCY_TIMER
, 1);
689 /* No error reporting */
690 pci_write_config_word(0, PCI_ERREN
, 0);
692 pci_write_config_dword(0, PCI_BRDGOPT2
, 0x00000101);
695 #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT) */
697 /*************************************************************************
700 ************************************************************************/
701 #if defined(CONFIG_PCI) && defined(CFG_PCI_MASTER_INIT)
702 void pci_master_init(struct pci_controller
*hose
)
704 unsigned short temp_short
;
706 /*--------------------------------------------------------------------------+
707 | Write the PowerPC440 EP PCI Configuration regs.
708 | Enable PowerPC440 EP to be a master on the PCI bus (PMM).
709 | Enable PowerPC440 EP to act as a PCI memory target (PTM).
710 +--------------------------------------------------------------------------*/
711 pci_read_config_word(0, PCI_COMMAND
, &temp_short
);
712 pci_write_config_word(0, PCI_COMMAND
,
713 temp_short
| PCI_COMMAND_MASTER
|
716 #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_MASTER_INIT) */
718 /*************************************************************************
721 * This routine is called to determine if a pci scan should be
722 * performed. With various hardware environments (especially cPCI and
723 * PPMC) it's insufficient to depend on the state of the arbiter enable
724 * bit in the strap register, or generic host/adapter assumptions.
726 * Rather than hard-code a bad assumption in the general 440 code, the
727 * 440 pci code requires the board to decide at runtime.
729 * Return 0 for adapter mode, non-zero for host (monarch) mode.
732 ************************************************************************/
733 #if defined(CONFIG_PCI)
734 int is_pci_host(struct pci_controller
*hose
)
736 /* PCS440EP is always configured as host. */
739 #endif /* defined(CONFIG_PCI) */
741 /*************************************************************************
744 * This routine is called to reset (keep alive) the watchdog timer
746 ************************************************************************/
747 #if defined(CONFIG_HW_WATCHDOG)
748 void hw_watchdog_reset(void)
754 /*************************************************************************
755 * "led" Commando for the U-Boot shell
757 ************************************************************************/
758 int do_led (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
763 pattern
= simple_strtoul (argv
[1], NULL
, 16);
764 if (pattern
> 0x400) {
766 printf ("led: %x\n", val
);
769 if (pattern
> 0x200) {
774 if (pattern
> 0x100) {
779 for (i
= 0; i
< 4; i
++) {
780 if (pattern
& 0x01) status_led_set (i
, STATUS_LED_ON
);
781 else status_led_set (i
, STATUS_LED_OFF
);
782 pattern
= pattern
>> 1;
789 "led [bitmask] - set the DIAG-LED\n",
790 "[bitmask] 0x01 = DIAG 1 on\n"
791 " 0x02 = DIAG 2 on\n"
792 " 0x04 = DIAG 3 on\n"
793 " 0x08 = DIAG 4 on\n"
794 " > 0x100 set the LED, who are on, to state blinking\n"
797 #if defined(CONFIG_SHA1_CHECK_UB_IMG)
798 /*************************************************************************
799 * "sha1" Commando for the U-Boot shell
801 ************************************************************************/
802 int do_sha1 (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
808 printf ("Usage:\n%s\n", cmdtp
->usage
);
814 unsigned char output
[20];
818 data
= (unsigned char *)simple_strtoul (argv
[1], NULL
, 16);
819 len
= simple_strtoul (argv
[2], NULL
, 16);
820 sha1_csum (data
, len
, (unsigned char *)output
);
821 printf ("U-Boot sum:\n");
822 for (i
= 0; i
< 20 ; i
++) {
823 printf ("%02X ", output
[i
]);
827 data
= (unsigned char *)simple_strtoul (argv
[3], NULL
, 16);
828 memcpy (data
, output
, 20);
834 if (*ptr
!= '-') goto usage
;
836 if ((*ptr
== 'c') || (*ptr
== 'C')) {
837 rcode
= pcs440ep_sha1 (1);
838 printf ("SHA1 U-Boot sum %sok!\n", (rcode
!= 0) ? "not " : "");
839 } else if ((*ptr
== 'p') || (*ptr
== 'P')) {
840 rcode
= pcs440ep_sha1 (2);
842 rcode
= pcs440ep_sha1 (0);
851 "sha1 - calculate the SHA1 Sum\n",
852 "address len [addr] calculate the SHA1 sum [save at addr]\n"
853 " -p calculate the SHA1 sum from the U-Boot image in flash and print\n"
854 " -c check the U-Boot image in flash\n"
858 #ifdef CONFIG_IDE_PREINIT
859 int ide_preinit (void)
861 /* Set True IDE Mode */
862 out32 (GPIO0_OR
, (in32 (GPIO0_OR
) | 0x00100000));
863 out32 (GPIO0_OR
, (in32 (GPIO0_OR
) | 0x00200000));
864 out32 (GPIO1_OR
, (in32 (GPIO1_OR
) & ~0x00008040));
870 #if defined (CFG_CMD_IDE) && defined (CONFIG_IDE_RESET)
871 void ide_set_reset (int idereset
)
873 debug ("ide_reset(%d)\n", idereset
);
875 out32 (GPIO0_OR
, (in32 (GPIO0_OR
) | 0x00200000));
877 out32 (GPIO0_OR
, (in32 (GPIO0_OR
) & ~0x00200000));
881 #endif /* defined (CFG_CMD_IDE) && defined (CONFIG_IDE_RESET) */