ppc4xx: Fix problem with DIMMs with 8 banks in 44x_spd_ddr2.c
[platform/kernel/u-boot.git] / common / cmd_ide.c
index 79b7dfb..ead7e10 100644 (file)
@@ -370,6 +370,9 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        disk_partition_t info;
        image_header_t *hdr;
        int rcode = 0;
+#if defined(CONFIG_FIT)
+       const void *fit_hdr;
+#endif
 
        show_boot_progress (41);
        switch (argc) {
@@ -450,11 +453,6 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        case IMAGE_FORMAT_LEGACY:
                hdr = (image_header_t *)addr;
 
-               if (!image_check_magic (hdr)) {
-                       printf("\n** Bad Magic Number **\n");
-                       show_boot_progress (-49);
-                       return 1;
-               }
                show_boot_progress (49);
 
                if (!image_check_hcrc (hdr)) {
@@ -470,10 +468,20 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                break;
 #if defined(CONFIG_FIT)
        case IMAGE_FORMAT_FIT:
-               fit_unsupported ("diskboot");
-               return 1;
+               fit_hdr = (const void *)addr;
+               if (!fit_check_format (fit_hdr)) {
+                       show_boot_progress (-140);
+                       puts ("** Bad FIT image format\n");
+                       return 1;
+               }
+               show_boot_progress (141);
+               puts ("Fit image detected...\n");
+
+               cnt = fit_get_size (fit_hdr);
+               break;
 #endif
        default:
+               show_boot_progress (-49);
                puts ("** Unknown image type\n");
                return 1;
        }
@@ -490,6 +498,11 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        }
        show_boot_progress (51);
 
+#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)
+               fit_print_contents ((const void *)addr);
+#endif
 
        /* Loading ok, update default load address */
 
@@ -1251,7 +1264,7 @@ ulong ide_read (int device, lbaint_t blknr, ulong blkcnt, void *buffer)
 #ifdef CONFIG_LBA48
        unsigned char lba48 = 0;
 
-       if (blknr & 0x0000fffff0000000) {
+       if (blknr & 0x0000fffff0000000ULL) {
                /* more than 28 bits used, use 48bit mode */
                lba48 = 1;
        }
@@ -1305,8 +1318,13 @@ ulong ide_read (int device, lbaint_t blknr, ulong blkcnt, void *buffer)
                        /* write high bits */
                        ide_outb (device, ATA_SECT_CNT, 0);
                        ide_outb (device, ATA_LBA_LOW,  (blknr >> 24) & 0xFF);
+#ifdef CFG_64BIT_LBA
                        ide_outb (device, ATA_LBA_MID,  (blknr >> 32) & 0xFF);
                        ide_outb (device, ATA_LBA_HIGH, (blknr >> 40) & 0xFF);
+#else
+                       ide_outb (device, ATA_LBA_MID,  0);
+                       ide_outb (device, ATA_LBA_HIGH, 0);
+#endif
                }
 #endif
                ide_outb (device, ATA_SECT_CNT, 1);
@@ -1370,7 +1388,7 @@ ulong ide_write (int device, lbaint_t blknr, ulong blkcnt, void *buffer)
 #ifdef CONFIG_LBA48
        unsigned char lba48 = 0;
 
-       if (blknr & 0x0000fffff0000000) {
+       if (blknr & 0x0000fffff0000000ULL) {
                /* more than 28 bits used, use 48bit mode */
                lba48 = 1;
        }
@@ -1395,8 +1413,13 @@ ulong ide_write (int device, lbaint_t blknr, ulong blkcnt, void *buffer)
                        /* write high bits */
                        ide_outb (device, ATA_SECT_CNT, 0);
                        ide_outb (device, ATA_LBA_LOW,  (blknr >> 24) & 0xFF);
+#ifdef CFG_64BIT_LBA
                        ide_outb (device, ATA_LBA_MID,  (blknr >> 32) & 0xFF);
                        ide_outb (device, ATA_LBA_HIGH, (blknr >> 40) & 0xFF);
+#else
+                       ide_outb (device, ATA_LBA_MID,  0);
+                       ide_outb (device, ATA_LBA_HIGH, 0);
+#endif
                }
 #endif
                ide_outb (device, ATA_SECT_CNT, 1);
@@ -1516,6 +1539,9 @@ static void ide_reset (void)
 
        ide_set_reset (1); /* assert reset */
 
+       /* the reset signal shall be asserted for et least 25 us */
+       udelay(25);
+
        WATCHDOG_RESET();
 
 #ifdef CFG_PB_12V_ENABLE