# include <status_led.h>
#endif
-#ifdef CONFIG_IDE_8xx_DIRECT
-DECLARE_GLOBAL_DATA_PTR;
-#endif
-
#ifdef __PPC__
# define EIEIO __asm__ volatile ("eieio")
# define SYNC __asm__ volatile ("sync")
# define SYNC /* nothing */
#endif
-#ifdef CONFIG_IDE_8xx_DIRECT
-/* Timings for IDE Interface
- *
- * SETUP / LENGTH / HOLD - cycles valid for 50 MHz clk
- * 70 165 30 PIO-Mode 0, [ns]
- * 4 9 2 [Cycles]
- * 50 125 20 PIO-Mode 1, [ns]
- * 3 7 2 [Cycles]
- * 30 100 15 PIO-Mode 2, [ns]
- * 2 6 1 [Cycles]
- * 30 80 10 PIO-Mode 3, [ns]
- * 2 5 1 [Cycles]
- * 25 70 10 PIO-Mode 4, [ns]
- * 2 4 1 [Cycles]
- */
-
-const static pio_config_t pio_config_ns [IDE_MAX_PIO_MODE+1] =
-{
- /* Setup Length Hold */
- { 70, 165, 30 }, /* PIO-Mode 0, [ns] */
- { 50, 125, 20 }, /* PIO-Mode 1, [ns] */
- { 30, 101, 15 }, /* PIO-Mode 2, [ns] */
- { 30, 80, 10 }, /* PIO-Mode 3, [ns] */
- { 25, 70, 10 }, /* PIO-Mode 4, [ns] */
-};
-
-static pio_config_t pio_config_clk [IDE_MAX_PIO_MODE+1];
-
-#ifndef CONFIG_SYS_PIO_MODE
-#define CONFIG_SYS_PIO_MODE 0 /* use a relaxed default */
-#endif
-static int pio_mode = CONFIG_SYS_PIO_MODE;
-
-/* Make clock cycles and always round up */
-
-#define PCMCIA_MK_CLKS( t, T ) (( (t) * (T) + 999U ) / 1000U )
-
-#endif /* CONFIG_IDE_8xx_DIRECT */
-
/* ------------------------------------------------------------------------- */
/* Current I/O Device */
#endif
-#ifdef CONFIG_IDE_8xx_DIRECT
-static void set_pcmcia_timing (int pmode);
-#endif
-
/* ------------------------------------------------------------------------- */
int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{
- char *boot_device = NULL;
- char *ep;
- int dev, part = 0;
- ulong addr, cnt;
- disk_partition_t info;
- image_header_t *hdr;
-
-#if defined(CONFIG_FIT)
- const void *fit_hdr = NULL;
-#endif
-
- show_boot_progress(BOOTSTAGE_ID_IDE_START);
- switch (argc) {
- case 1:
- addr = CONFIG_SYS_LOAD_ADDR;
- boot_device = getenv("bootdevice");
- break;
- case 2:
- addr = simple_strtoul(argv[1], NULL, 16);
- boot_device = getenv("bootdevice");
- break;
- case 3:
- addr = simple_strtoul(argv[1], NULL, 16);
- boot_device = argv[2];
- break;
- default:
- show_boot_error(BOOTSTAGE_ID_IDE_ADDR);
- return CMD_RET_USAGE;
- }
- show_boot_progress(BOOTSTAGE_ID_IDE_ADDR);
-
- if (!boot_device) {
- puts("\n** No boot device **\n");
- show_boot_error(BOOTSTAGE_ID_IDE_BOOT_DEVICE);
- return 1;
- }
- show_boot_progress(BOOTSTAGE_ID_IDE_BOOT_DEVICE);
-
- dev = simple_strtoul(boot_device, &ep, 16);
-
- if (ide_dev_desc[dev].type == DEV_TYPE_UNKNOWN) {
- printf("\n** Device %d not available\n", dev);
- show_boot_error(BOOTSTAGE_ID_IDE_TYPE);
- return 1;
- }
- show_boot_progress(BOOTSTAGE_ID_IDE_TYPE);
-
- if (*ep) {
- if (*ep != ':') {
- puts("\n** Invalid boot device, use `dev[:part]' **\n");
- show_boot_error(BOOTSTAGE_ID_IDE_PART);
- return 1;
- }
- part = simple_strtoul(++ep, NULL, 16);
- }
- show_boot_progress(BOOTSTAGE_ID_IDE_PART);
-
- if (get_partition_info(&ide_dev_desc[dev], part, &info)) {
- show_boot_error(BOOTSTAGE_ID_IDE_PART_INFO);
- return 1;
- }
- show_boot_progress(BOOTSTAGE_ID_IDE_PART_INFO);
-
- if ((strncmp((char *)info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0)
- &&
- (strncmp((char *)info.type, BOOT_PART_COMP, sizeof(info.type)) != 0)
- ) {
- printf("\n** Invalid partition type \"%.32s\"" " (expect \""
- BOOT_PART_TYPE "\")\n",
- info.type);
- show_boot_error(BOOTSTAGE_ID_IDE_PART_TYPE);
- return 1;
- }
- show_boot_progress(BOOTSTAGE_ID_IDE_PART_TYPE);
-
- printf("\nLoading from IDE device %d, partition %d: "
- "Name: %.32s Type: %.32s\n", dev, part, info.name, info.type);
-
- debug("First Block: %ld, # of blocks: %ld, Block Size: %ld\n",
- info.start, info.size, info.blksz);
-
- if (ide_dev_desc[dev].
- block_read(dev, info.start, 1, (ulong *) addr) != 1) {
- printf("** Read error on %d:%d\n", dev, part);
- show_boot_error(BOOTSTAGE_ID_IDE_PART_READ);
- return 1;
- }
- show_boot_progress(BOOTSTAGE_ID_IDE_PART_READ);
-
- switch (genimg_get_format((void *) addr)) {
- case IMAGE_FORMAT_LEGACY:
- hdr = (image_header_t *) addr;
-
- show_boot_progress(BOOTSTAGE_ID_IDE_FORMAT);
-
- if (!image_check_hcrc(hdr)) {
- puts("\n** Bad Header Checksum **\n");
- show_boot_error(BOOTSTAGE_ID_IDE_CHECKSUM);
- return 1;
- }
- show_boot_progress(BOOTSTAGE_ID_IDE_CHECKSUM);
-
- image_print_contents(hdr);
-
- cnt = image_get_image_size(hdr);
- break;
-#if defined(CONFIG_FIT)
- case IMAGE_FORMAT_FIT:
- fit_hdr = (const void *) addr;
- puts("Fit image detected...\n");
-
- cnt = fit_get_size(fit_hdr);
- break;
-#endif
- default:
- show_boot_error(BOOTSTAGE_ID_IDE_FORMAT);
- puts("** Unknown image type\n");
- return 1;
- }
-
- cnt += info.blksz - 1;
- cnt /= info.blksz;
- cnt -= 1;
-
- if (ide_dev_desc[dev].block_read(dev, info.start + 1, cnt,
- (ulong *)(addr + info.blksz)) != cnt) {
- printf("** Read error on %d:%d\n", dev, part);
- show_boot_error(BOOTSTAGE_ID_IDE_READ);
- return 1;
- }
- show_boot_progress(BOOTSTAGE_ID_IDE_READ);
-
-#if defined(CONFIG_FIT)
- /* This cannot be done earlier, we need complete FIT image in RAM first */
- if (genimg_get_format((void *) addr) == IMAGE_FORMAT_FIT) {
- if (!fit_check_format(fit_hdr)) {
- show_boot_error(BOOTSTAGE_ID_IDE_FIT_READ);
- puts("** Bad FIT image format\n");
- return 1;
- }
- show_boot_progress(BOOTSTAGE_ID_IDE_FIT_READ_OK);
- fit_print_contents(fit_hdr);
- }
-#endif
-
- /* Loading ok, update default load address */
-
- load_addr = addr;
-
- return bootm_maybe_autostart(cmdtp, argv[0]);
+ return common_diskboot(cmdtp, "ide", argc, argv);
}
/* ------------------------------------------------------------------------- */
void ide_init(void)
{
-
-#ifdef CONFIG_IDE_8xx_DIRECT
- volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
- volatile pcmconf8xx_t *pcmp = &(immr->im_pcmcia);
-#endif
unsigned char c;
int i, bus;
-#if defined(CONFIG_SC3)
- unsigned int ata_reset_time = ATA_RESET_TIME;
-#endif
#ifdef CONFIG_IDE_8xx_PCCARD
- extern int pcmcia_on(void);
extern int ide_devices_found; /* Initialized in check_ide_device() */
#endif /* CONFIG_IDE_8xx_PCCARD */
#ifdef CONFIG_IDE_PREINIT
- extern int ide_preinit(void);
-
WATCHDOG_RESET();
if (ide_preinit()) {
}
#endif /* CONFIG_IDE_PREINIT */
-#ifdef CONFIG_IDE_8xx_PCCARD
- extern int pcmcia_on(void);
- extern int ide_devices_found; /* Initialized in check_ide_device() */
-
WATCHDOG_RESET();
- ide_devices_found = 0;
- /* initialize the PCMCIA IDE adapter card */
- pcmcia_on();
- if (!ide_devices_found)
- return;
- udelay(1000000); /* 1 s */
-#endif /* CONFIG_IDE_8xx_PCCARD */
-
- WATCHDOG_RESET();
-
-#ifdef CONFIG_IDE_8xx_DIRECT
- /* Initialize PIO timing tables */
- for (i = 0; i <= IDE_MAX_PIO_MODE; ++i) {
- pio_config_clk[i].t_setup =
- PCMCIA_MK_CLKS(pio_config_ns[i].t_setup, gd->bus_clk);
- pio_config_clk[i].t_length =
- PCMCIA_MK_CLKS(pio_config_ns[i].t_length,
- gd->bus_clk);
- pio_config_clk[i].t_hold =
- PCMCIA_MK_CLKS(pio_config_ns[i].t_hold, gd->bus_clk);
- debug("PIO Mode %d: setup=%2d ns/%d clk" " len=%3d ns/%d clk"
- " hold=%2d ns/%d clk\n", i, pio_config_ns[i].t_setup,
- pio_config_clk[i].t_setup, pio_config_ns[i].t_length,
- pio_config_clk[i].t_length, pio_config_ns[i].t_hold,
- pio_config_clk[i].t_hold);
- }
-#endif /* CONFIG_IDE_8xx_DIRECT */
-
/*
* Reset the IDE just to be sure.
* Light LED's to show
/* ATAPI Drives seems to need a proper IDE Reset */
ide_reset();
-#ifdef CONFIG_IDE_8xx_DIRECT
- /* PCMCIA / IDE initialization for common mem space */
- pcmp->pcmc_pgcrb = 0;
+#ifdef CONFIG_IDE_INIT_POSTRESET
+ WATCHDOG_RESET();
- /* start in PIO mode 0 - most relaxed timings */
- pio_mode = 0;
- set_pcmcia_timing(pio_mode);
-#endif /* CONFIG_IDE_8xx_DIRECT */
+ if (ide_init_postreset()) {
+ puts("ide_preinit_postreset failed\n");
+ return;
+ }
+#endif /* CONFIG_IDE_INIT_POSTRESET */
/*
* Wait for IDE to get ready.
c = ide_inb(dev, ATA_STATUS);
i++;
-#if defined(CONFIG_SC3)
- if (i > (ata_reset_time * 100)) {
-#else
if (i > (ATA_RESET_TIME * 100)) {
-#endif
puts("** Timeout **\n");
/* LED's off */
ide_led((LED_IDE1 | LED_IDE2), 0);
}
#endif
-
-#ifdef CONFIG_IDE_8xx_DIRECT
-
-static void set_pcmcia_timing(int pmode)
-{
- volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
- volatile pcmconf8xx_t *pcmp = &(immr->im_pcmcia);
- ulong timings;
-
- debug("Set timing for PIO Mode %d\n", pmode);
-
- timings = PCMCIA_SHT(pio_config_clk[pmode].t_hold)
- | PCMCIA_SST(pio_config_clk[pmode].t_setup)
- | PCMCIA_SL(pio_config_clk[pmode].t_length);
-
- /*
- * IDE 0
- */
- pcmp->pcmc_pbr0 = CONFIG_SYS_PCMCIA_PBR0;
- pcmp->pcmc_por0 = CONFIG_SYS_PCMCIA_POR0
-#if (CONFIG_SYS_PCMCIA_POR0 != 0)
- | timings
-#endif
- ;
- debug("PBR0: %08x POR0: %08x\n", pcmp->pcmc_pbr0, pcmp->pcmc_por0);
-
- pcmp->pcmc_pbr1 = CONFIG_SYS_PCMCIA_PBR1;
- pcmp->pcmc_por1 = CONFIG_SYS_PCMCIA_POR1
-#if (CONFIG_SYS_PCMCIA_POR1 != 0)
- | timings
-#endif
- ;
- debug("PBR1: %08x POR1: %08x\n", pcmp->pcmc_pbr1, pcmp->pcmc_por1);
-
- pcmp->pcmc_pbr2 = CONFIG_SYS_PCMCIA_PBR2;
- pcmp->pcmc_por2 = CONFIG_SYS_PCMCIA_POR2
-#if (CONFIG_SYS_PCMCIA_POR2 != 0)
- | timings
-#endif
- ;
- debug("PBR2: %08x POR2: %08x\n", pcmp->pcmc_pbr2, pcmp->pcmc_por2);
-
- pcmp->pcmc_pbr3 = CONFIG_SYS_PCMCIA_PBR3;
- pcmp->pcmc_por3 = CONFIG_SYS_PCMCIA_POR3
-#if (CONFIG_SYS_PCMCIA_POR3 != 0)
- | timings
-#endif
- ;
- debug("PBR3: %08x POR3: %08x\n", pcmp->pcmc_pbr3, pcmp->pcmc_por3);
-
- /*
- * IDE 1
- */
- pcmp->pcmc_pbr4 = CONFIG_SYS_PCMCIA_PBR4;
- pcmp->pcmc_por4 = CONFIG_SYS_PCMCIA_POR4
-#if (CONFIG_SYS_PCMCIA_POR4 != 0)
- | timings
-#endif
- ;
- debug("PBR4: %08x POR4: %08x\n", pcmp->pcmc_pbr4, pcmp->pcmc_por4);
-
- pcmp->pcmc_pbr5 = CONFIG_SYS_PCMCIA_PBR5;
- pcmp->pcmc_por5 = CONFIG_SYS_PCMCIA_POR5
-#if (CONFIG_SYS_PCMCIA_POR5 != 0)
- | timings
-#endif
- ;
- debug("PBR5: %08x POR5: %08x\n", pcmp->pcmc_pbr5, pcmp->pcmc_por5);
-
- pcmp->pcmc_pbr6 = CONFIG_SYS_PCMCIA_PBR6;
- pcmp->pcmc_por6 = CONFIG_SYS_PCMCIA_POR6
-#if (CONFIG_SYS_PCMCIA_POR6 != 0)
- | timings
-#endif
- ;
- debug("PBR6: %08x POR6: %08x\n", pcmp->pcmc_pbr6, pcmp->pcmc_por6);
-
- pcmp->pcmc_pbr7 = CONFIG_SYS_PCMCIA_PBR7;
- pcmp->pcmc_por7 = CONFIG_SYS_PCMCIA_POR7
-#if (CONFIG_SYS_PCMCIA_POR7 != 0)
- | timings
-#endif
- ;
- debug("PBR7: %08x POR7: %08x\n", pcmp->pcmc_pbr7, pcmp->pcmc_por7);
-
-}
-
-#endif /* CONFIG_IDE_8xx_DIRECT */
-
/* ------------------------------------------------------------------------- */
/* We only need to swap data if we are running on a big endian cpu. */
/* But Au1x00 cpu:s already swaps data in big endian mode! */
-#if defined(__LITTLE_ENDIAN) || \
- (defined(CONFIG_SOC_AU1X00) && !defined(CONFIG_GTH2))
+#if defined(__LITTLE_ENDIAN) || defined(CONFIG_SOC_AU1X00)
#define input_swap_data(x,y,z) input_data(x,y,z)
#else
static void input_swap_data(int dev, ulong *sect_buf, int words)