X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=common%2Fcmd_ide.c;h=97a873d1c96a517f3e96db09038f44f1ea421083;hb=7f9f4347cf325c63a39fe30910f3fb211ae2cc15;hp=bef04db4f663e282fceed4c9da9367cea02467db;hpb=e18489e8c27e843e337258fb00f2652ff0f43b92;p=oweals%2Fu-boot.git diff --git a/common/cmd_ide.c b/common/cmd_ide.c index bef04db4f6..97a873d1c9 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -52,10 +52,6 @@ # include #endif -#ifndef __PPC__ -#include -#endif - #ifdef CONFIG_IDE_8xx_DIRECT DECLARE_GLOBAL_DATA_PTR; #endif @@ -370,6 +366,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 = NULL; +#endif show_boot_progress (41); switch (argc) { @@ -446,15 +445,10 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) } show_boot_progress (48); - switch (gen_image_get_format ((void *)addr)) { + switch (genimg_get_format ((void *)addr)) { 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 +464,14 @@ 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; + 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 +488,18 @@ 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) { + if (!fit_check_format (fit_hdr)) { + show_boot_progress (-140); + puts ("** Bad FIT image format\n"); + return 1; + } + show_boot_progress (141); + fit_print_contents (fit_hdr); + } +#endif /* Loading ok, update default load address */ @@ -1224,7 +1234,7 @@ static void ide_ident (block_dev_desc_t *dev_desc) dev_desc->blksz=ATA_BLOCKSIZE; dev_desc->lun=0; /* just to fill something in... */ -#if 0 /* only used to test the powersaving mode, +#if 0 /* only used to test the powersaving mode, * if enabled, the drive goes after 5 sec * in standby mode */ ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device)); @@ -1251,7 +1261,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 +1315,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 +1385,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 +1410,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 +1536,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 @@ -1761,7 +1784,7 @@ unsigned char atapi_issue(int device,unsigned char* ccb,int ccblen, unsigned cha } output_data_shorts (device, (unsigned short *)ccb,ccblen/2); /* write command block */ - /* ATAPI Command written wait for completition */ + /* ATAPI Command written wait for completition */ udelay (5000); /* device must set bsy */ mask = ATA_STAT_DRQ|ATA_STAT_BUSY|ATA_STAT_ERR; @@ -1830,7 +1853,7 @@ AI_OUT: * returns, an request_sense will be issued */ -#define ATAPI_DRIVE_NOT_READY 100 +#define ATAPI_DRIVE_NOT_READY 100 #define ATAPI_UNIT_ATTN 10 unsigned char atapi_issue_autoreq (int device,