X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=common%2Fcmd_ide.c;h=ecd3e9d64f086318578af7579e125dabdf0c381b;hb=79d19734a9e2dbd3fc414512227a24f60cd3572a;hp=c375ef2093b46ea3507c1071ff0bb26aa2489314;hpb=3be2bdf5dc69b3142c1162a59bc67191c9077567;p=oweals%2Fu-boot.git diff --git a/common/cmd_ide.c b/common/cmd_ide.c index c375ef2093..ecd3e9d64f 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -79,7 +79,7 @@ static void ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len #ifdef CONFIG_ATAPI static void atapi_inquiry(block_dev_desc_t *dev_desc); -static ulong atapi_read(int device, ulong blknr, lbaint_t blkcnt, +static ulong atapi_read(int device, lbaint_t blknr, lbaint_t blkcnt, void *buffer); #endif @@ -253,7 +253,7 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) /* ------------------------------------------------------------------------- */ -void __ide_led(uchar led, uchar status) +__weak void ide_led(uchar led, uchar status) { #if defined(CONFIG_IDE_LED) && defined(PER8_BASE) /* required by LED_PORT */ static uchar led_buffer; /* Buffer for current LED status */ @@ -269,9 +269,6 @@ void __ide_led(uchar led, uchar status) #endif } -void ide_led(uchar led, uchar status) - __attribute__ ((weak, alias("__ide_led"))); - #ifndef CONFIG_IDE_LED /* define LED macros, they are not used anyways */ # define DEVICE_LED(x) 0 # define LED_IDE1 1 @@ -280,7 +277,7 @@ void ide_led(uchar led, uchar status) /* ------------------------------------------------------------------------- */ -inline void __ide_outb(int dev, int port, unsigned char val) +__weak void ide_outb(int dev, int port, unsigned char val) { debug("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n", dev, port, val, @@ -299,10 +296,7 @@ inline void __ide_outb(int dev, int port, unsigned char val) #endif } -void ide_outb(int dev, int port, unsigned char val) - __attribute__ ((weak, alias("__ide_outb"))); - -inline unsigned char __ide_inb(int dev, int port) +__weak unsigned char ide_inb(int dev, int port) { uchar val; @@ -318,19 +312,6 @@ inline unsigned char __ide_inb(int dev, int port) return val; } -unsigned char ide_inb(int dev, int port) - __attribute__ ((weak, alias("__ide_inb"))); - -#ifdef CONFIG_TUNE_PIO -inline int __ide_set_piomode(int pio_mode) -{ - return 0; -} - -inline int ide_set_piomode(int pio_mode) - __attribute__ ((weak, alias("__ide_set_piomode"))); -#endif - void ide_init(void) { unsigned char c; @@ -471,23 +452,14 @@ block_dev_desc_t *ide_get_dev(int dev) /* ------------------------------------------------------------------------- */ -void ide_input_swap_data(int dev, ulong *sect_buf, int words) - __attribute__ ((weak, alias("__ide_input_swap_data"))); - -void ide_input_data(int dev, ulong *sect_buf, int words) - __attribute__ ((weak, alias("__ide_input_data"))); - -void ide_output_data(int dev, const ulong *sect_buf, int words) - __attribute__ ((weak, alias("__ide_output_data"))); - /* We only need to swap data if we are running on a big endian cpu. */ #if defined(__LITTLE_ENDIAN) -void __ide_input_swap_data(int dev, ulong *sect_buf, int words) +__weak void ide_input_swap_data(int dev, ulong *sect_buf, int words) { ide_input_data(dev, sect_buf, words); } #else -void __ide_input_swap_data(int dev, ulong *sect_buf, int words) +__weak void ide_input_swap_data(int dev, ulong *sect_buf, int words) { volatile ushort *pbuf = (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG); @@ -510,7 +482,7 @@ void __ide_input_swap_data(int dev, ulong *sect_buf, int words) #if defined(CONFIG_IDE_SWAP_IO) -void __ide_output_data(int dev, const ulong *sect_buf, int words) +__weak void ide_output_data(int dev, const ulong *sect_buf, int words) { ushort *dbuf; volatile ushort *pbuf; @@ -525,7 +497,7 @@ void __ide_output_data(int dev, const ulong *sect_buf, int words) } } #else /* ! CONFIG_IDE_SWAP_IO */ -void __ide_output_data(int dev, const ulong *sect_buf, int words) +__weak void ide_output_data(int dev, const ulong *sect_buf, int words) { #if defined(CONFIG_IDE_AHB) ide_write_data(dev, sect_buf, words); @@ -536,7 +508,7 @@ void __ide_output_data(int dev, const ulong *sect_buf, int words) #endif /* CONFIG_IDE_SWAP_IO */ #if defined(CONFIG_IDE_SWAP_IO) -void __ide_input_data(int dev, ulong *sect_buf, int words) +__weak void ide_input_data(int dev, ulong *sect_buf, int words) { ushort *dbuf; volatile ushort *pbuf; @@ -554,7 +526,7 @@ void __ide_input_data(int dev, ulong *sect_buf, int words) } } #else /* ! CONFIG_IDE_SWAP_IO */ -void __ide_input_data(int dev, ulong *sect_buf, int words) +__weak void ide_input_data(int dev, ulong *sect_buf, int words) { #if defined(CONFIG_IDE_AHB) ide_read_data(dev, sect_buf, words); @@ -575,14 +547,6 @@ static void ide_ident(block_dev_desc_t *dev_desc) #ifdef CONFIG_ATAPI int retries = 0; #endif - -#ifdef CONFIG_TUNE_PIO - int pio_mode; -#endif - -#if 0 - int mode, cycle_time; -#endif int device; device = dev_desc->dev; @@ -691,72 +655,6 @@ static void ide_ident(block_dev_desc_t *dev_desc) else dev_desc->removable = 0; -#ifdef CONFIG_TUNE_PIO - /* Mode 0 - 2 only, are directly determined by word 51. */ - pio_mode = iop.tPIO; - if (pio_mode > 2) { - printf("WARNING: Invalid PIO (word 51 = %d).\n", pio_mode); - /* Force it to dead slow, and hope for the best... */ - pio_mode = 0; - } - - /* Any CompactFlash Storage Card that supports PIO mode 3 or above - * shall set bit 1 of word 53 to one and support the fields contained - * in words 64 through 70. - */ - if (iop.field_valid & 0x02) { - /* - * Mode 3 and above are possible. Check in order from slow - * to fast, so we wind up with the highest mode allowed. - */ - if (iop.eide_pio_modes & 0x01) - pio_mode = 3; - if (iop.eide_pio_modes & 0x02) - pio_mode = 4; - if (ata_id_is_cfa((u16 *)&iop)) { - if ((iop.cf_advanced_caps & 0x07) == 0x01) - pio_mode = 5; - if ((iop.cf_advanced_caps & 0x07) == 0x02) - pio_mode = 6; - } - } - - /* System-specific, depends on bus speeds, etc. */ - ide_set_piomode(pio_mode); -#endif /* CONFIG_TUNE_PIO */ - -#if 0 - /* - * Drive PIO mode autoselection - */ - mode = iop.tPIO; - - printf("tPIO = 0x%02x = %d\n", mode, mode); - if (mode > 2) { /* 2 is maximum allowed tPIO value */ - mode = 2; - debug("Override tPIO -> 2\n"); - } - if (iop.field_valid & 2) { /* drive implements ATA2? */ - debug("Drive implements ATA2\n"); - if (iop.capability & 8) { /* drive supports use_iordy? */ - cycle_time = iop.eide_pio_iordy; - } else { - cycle_time = iop.eide_pio; - } - debug("cycle time = %d\n", cycle_time); - mode = 4; - if (cycle_time > 120) - mode = 3; /* 120 ns for PIO mode 4 */ - if (cycle_time > 180) - mode = 2; /* 180 ns for PIO mode 3 */ - if (cycle_time > 240) - mode = 1; /* 240 ns for PIO mode 4 */ - if (cycle_time > 383) - mode = 0; /* 383 ns for PIO mode 4 */ - } - printf("PIO mode to use: PIO %d\n", mode); -#endif /* 0 */ - #ifdef CONFIG_ATAPI if (dev_desc->if_type == IF_TYPE_ATAPI) { atapi_inquiry(dev_desc); @@ -1122,17 +1020,10 @@ int ide_device_present(int dev) * ATAPI Support */ -void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts) - __attribute__ ((weak, alias("__ide_input_data_shorts"))); - -void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts) - __attribute__ ((weak, alias("__ide_output_data_shorts"))); - - #if defined(CONFIG_IDE_SWAP_IO) /* since ATAPI may use commands with not 4 bytes alligned length * we have our own transfer functions, 2 bytes alligned */ -void __ide_output_data_shorts(int dev, ushort *sect_buf, int shorts) +__weak void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts) { ushort *dbuf; volatile ushort *pbuf; @@ -1149,7 +1040,7 @@ void __ide_output_data_shorts(int dev, ushort *sect_buf, int shorts) } } -void __ide_input_data_shorts(int dev, ushort *sect_buf, int shorts) +__weak void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts) { ushort *dbuf; volatile ushort *pbuf; @@ -1167,12 +1058,12 @@ void __ide_input_data_shorts(int dev, ushort *sect_buf, int shorts) } #else /* ! CONFIG_IDE_SWAP_IO */ -void __ide_output_data_shorts(int dev, ushort *sect_buf, int shorts) +__weak void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts) { outsw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, shorts); } -void __ide_input_data_shorts(int dev, ushort *sect_buf, int shorts) +__weak void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts) { insw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, shorts); } @@ -1497,13 +1388,13 @@ static void atapi_inquiry(block_dev_desc_t *dev_desc) #define ATAPI_READ_BLOCK_SIZE 2048 /* assuming CD part */ #define ATAPI_READ_MAX_BLOCK (ATAPI_READ_MAX_BYTES/ATAPI_READ_BLOCK_SIZE) -ulong atapi_read(int device, ulong blknr, lbaint_t blkcnt, void *buffer) +ulong atapi_read(int device, lbaint_t blknr, lbaint_t blkcnt, void *buffer) { ulong n = 0; unsigned char ccb[12]; /* Command descriptor block */ ulong cnt; - debug("atapi_read dev %d start %lX, blocks " LBAF " buffer at %lX\n", + debug("atapi_read dev %d start " LBAF " blocks " LBAF " buffer at %lX\n", device, blknr, blkcnt, (ulong) buffer); do {