summaryrefslogtreecommitdiffstats
path: root/common/cmd_ide.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/cmd_ide.c')
-rw-r--r--common/cmd_ide.c100
1 files changed, 72 insertions, 28 deletions
diff --git a/common/cmd_ide.c b/common/cmd_ide.c
index 97a873d1c9..2fcaff8c5a 100644
--- a/common/cmd_ide.c
+++ b/common/cmd_ide.c
@@ -161,8 +161,6 @@ static uchar ide_wait (int dev, ulong t);
#define IDE_SPIN_UP_TIME_OUT 5000 /* 5 sec spin-up timeout */
-void inline ide_outb(int dev, int port, unsigned char val);
-unsigned char inline ide_inb(int dev, int port);
static void input_data(int dev, ulong *sect_buf, int words);
static void output_data(int dev, ulong *sect_buf, int words);
static void ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len);
@@ -298,7 +296,7 @@ int do_ide (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
ulong addr = simple_strtoul(argv[2], NULL, 16);
ulong cnt = simple_strtoul(argv[4], NULL, 16);
ulong n;
-#ifdef CFG_64BIT_STRTOUL
+#ifdef CFG_64BIT_LBA
lbaint_t blk = simple_strtoull(argv[3], NULL, 16);
printf ("\nIDE read: device %d block # %qd, count %ld ... ",
@@ -327,7 +325,7 @@ int do_ide (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
ulong addr = simple_strtoul(argv[2], NULL, 16);
ulong cnt = simple_strtoul(argv[4], NULL, 16);
ulong n;
-#ifdef CFG_64BIT_STRTOUL
+#ifdef CFG_64BIT_LBA
lbaint_t blk = simple_strtoull(argv[3], NULL, 16);
printf ("\nIDE write: device %d block # %qd, count %ld ... ",
@@ -523,6 +521,38 @@ int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
/* ------------------------------------------------------------------------- */
+void inline
+__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, (ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port)));
+ outb(val, (ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port)));
+}
+void inline ide_outb (int dev, int port, unsigned char val)
+ __attribute__((weak, alias("__ide_outb")));
+
+unsigned char inline
+__ide_inb(int dev, int port)
+{
+ uchar val;
+ val = inb((ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port)));
+ debug ("ide_inb (dev= %d, port= 0x%x) : @ 0x%08lx -> 0x%02x\n",
+ dev, port, (ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port)), val);
+ return val;
+}
+unsigned char inline ide_inb(int dev, int port)
+ __attribute__((weak, alias("__ide_inb")));
+
+#ifdef CONFIG_TUNE_PIO
+int inline
+__ide_set_piomode(int pio_mode)
+{
+ return 0;
+}
+int inline ide_set_piomode(int pio_mode)
+ __attribute__((weak, alias("__ide_set_piomode")));
+#endif
+
void ide_init (void)
{
@@ -817,28 +847,6 @@ set_pcmcia_timing (int pmode)
/* ------------------------------------------------------------------------- */
-void inline
-__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, (ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port)));
- outb(val, (ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port)));
-}
-void inline ide_outb (int dev, int port, unsigned char val)
- __attribute__((weak, alias("__ide_outb")));
-
-unsigned char inline
-__ide_inb(int dev, int port)
-{
- uchar val;
- val = inb((ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port)));
- debug ("ide_inb (dev= %d, port= 0x%x) : @ 0x%08lx -> 0x%02x\n",
- dev, port, (ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port)), val);
- return val;
-}
-unsigned char inline ide_inb(int dev, int port)
- __attribute__((weak, alias("__ide_inb")));
-
#ifdef __PPC__
# ifdef CONFIG_AMIGAONEG3SE
static void
@@ -1055,6 +1063,10 @@ static void ide_ident (block_dev_desc_t *dev_desc)
int do_retry = 0;
#endif
+#ifdef CONFIG_TUNE_PIO
+ int pio_mode;
+#endif
+
#if 0
int mode, cycle_time;
#endif
@@ -1170,6 +1182,38 @@ 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);
+ pio_mode = 0; /* Force it to dead slow, and hope for the best... */
+ }
+
+ /* 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
@@ -1778,7 +1822,7 @@ unsigned char atapi_issue(int device,unsigned char* ccb,int ccblen, unsigned cha
c = atapi_wait_mask(device,ATAPI_TIME_OUT,mask,res);
if ((c & mask) != res) { /* DRQ must be 1, BSY 0 */
- printf ("ATTAPI_ISSUE: Error (no IRQ) before sending ccb dev %d status 0x%02x\n",device,c);
+ printf ("ATAPI_ISSUE: Error (no IRQ) before sending ccb dev %d status 0x%02x\n",device,c);
err=0xFF;
goto AI_OUT;
}
@@ -1799,7 +1843,7 @@ unsigned char atapi_issue(int device,unsigned char* ccb,int ccblen, unsigned cha
err=(ide_inb(device,ATA_ERROR_REG))>>4;
debug ("atapi_issue 1 returned sense key %X status %02X\n",err,c);
} else {
- printf ("ATTAPI_ISSUE: (no DRQ) after sending ccb (%x) status 0x%02x\n", ccb[0],c);
+ printf ("ATAPI_ISSUE: (no DRQ) after sending ccb (%x) status 0x%02x\n", ccb[0],c);
err=0xFF;
}
goto AI_OUT;
OpenPOWER on IntegriCloud