--- zzzz-none-000/linux-2.4.17/drivers/ide/ide-probe.c 2001-11-26 13:29:17.000000000 +0000 +++ sangam-fb-401/linux-2.4.17/drivers/ide/ide-probe.c 2005-05-13 14:50:21.000000000 +0000 @@ -193,6 +193,8 @@ unsigned long timeout; byte s, a; + DBG_IDE( "actual_try_to_identify ... " ); + if (IDE_CONTROL_REG) { /* take a deep breath */ ide_delay_50ms(); @@ -222,7 +224,7 @@ } } else #endif /* CONFIG_BLK_DEV_PDC4030 */ - OUT_BYTE(cmd,IDE_COMMAND_REG); /* ask drive for ID */ + OUT_BYTE(cmd,IDE_COMMAND_REG); /* ask drive for ID */ timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; timeout += jiffies; do { @@ -252,15 +254,18 @@ int autoprobe = 0; unsigned long cookie = 0; + DBG_IDE( "try_to_identify: drive %s", drive->name[3] == '0' ? drive->name : "???" ); if (IDE_CONTROL_REG && !HWIF(drive)->irq) { autoprobe = 1; cookie = probe_irq_on(); OUT_BYTE(drive->ctl,IDE_CONTROL_REG); /* enable device irq */ + DBG_IDE("try_to_identify out: 0x%02X -> 0x%p", drive->ctl,(void *) IDE_CONTROL_REG ); /* enable device irq */ } retval = actual_try_to_identify(drive, cmd); if (autoprobe) { + DBG_IDE( "try_to_identify: autoprobe " ); int irq; OUT_BYTE(drive->ctl|2,IDE_CONTROL_REG); /* mask device irq */ (void) GET_STAT(); /* clear drive IRQ */ @@ -305,11 +310,13 @@ static int do_probe (ide_drive_t *drive, byte cmd) { int rc; + unsigned char reg = 0; ide_hwif_t *hwif = HWIF(drive); if (drive->present) { /* avoid waiting for inappropriate probes */ if ((drive->media != ide_disk) && (cmd == WIN_IDENTIFY)) return 4; } + DBG_IDE( "do_probe: ..." ); #ifdef DEBUG printk("probing for %s: present=%d, media=%d, probetype=%s\n", drive->name, drive->present, drive->media, @@ -318,7 +325,9 @@ ide_delay_50ms(); /* needed for some systems (e.g. crw9624 as drive0 with disk as slave) */ SELECT_DRIVE(hwif,drive); ide_delay_50ms(); - if (IN_BYTE(IDE_SELECT_REG) != drive->select.all && !drive->present) { + reg = IN_BYTE(IDE_SELECT_REG); + if ( reg != drive->select.all && !drive->present) { +// if (IN_BYTE(IDE_SELECT_REG) != drive->select.all && !drive->present) { if (drive->select.b.unit != 0) { SELECT_DRIVE(hwif,&hwif->drives[0]); /* exit with drive0 selected */ ide_delay_50ms(); /* allow BUSY_STAT to assert & clear */ @@ -326,6 +335,7 @@ return 3; /* no i/f present: mmm.. this should be a 4 -ml */ } + DBG_IDE( "do_probe: select i.o. ... " ); if (OK_STAT(GET_STAT(),READY_STAT,BUSY_STAT) || drive->present || cmd == WIN_PIDENTIFY) { @@ -347,6 +357,7 @@ printk("%s: no response (status = 0x%02x)\n", drive->name, GET_STAT()); (void) GET_STAT(); /* ensure drive irq is clear */ } else { + DBG_IDE( "do_probe: not present or maybe ATAPI" ); rc = 3; /* not present or maybe ATAPI */ } if (drive->select.b.unit != 0) { @@ -394,15 +405,30 @@ */ static inline byte probe_for_drive (ide_drive_t *drive) { + int res = 0xff; + if (drive->noprobe) /* skip probing? */ return drive->present; - if (do_probe(drive, WIN_IDENTIFY) >= 2) { /* if !(success||timed-out) */ - (void) do_probe(drive, WIN_PIDENTIFY); /* look for ATAPI device */ + + DBG_IDE_DRIVE( drive ); + + if (( res = do_probe(drive, WIN_IDENTIFY)) >= 2) { /* if !(success||timed-out) */ + res = do_probe(drive, WIN_PIDENTIFY); /* look for ATAPI device */ } + DBG_IDE( "do_probe result: %s", \ + res == 0 ? "found" : \ + res == 1 ? "timed-out" : \ + res == 2 ? "command aborted" : \ + res == 3 ? "bad status" : \ + res == 4 ? "probe not attempted ..." : "???" ); + if (drive->id && strstr(drive->id->model, "E X A B Y T E N E S T")) enable_nest(drive); if (!drive->present) + { + DBG_IDE( "Drive not found." ); return 0; /* drive not found */ + } if (drive->id == NULL) { /* identification failed? */ if (drive->media == ide_disk) { printk ("%s: non-IDE drive, CHS=%d/%d/%d\n", @@ -410,6 +436,7 @@ } else if (drive->media == ide_cdrom) { printk("%s: ATAPI cdrom (?)\n", drive->name); } else { + DBG_IDE( "id=0 -> not present" ); drive->present = 0; /* nuke it */ } } @@ -450,6 +477,8 @@ static void hwif_register (ide_hwif_t *hwif) { + + DBG_IDE( "hwif_register %d", hwif->index ); if (((unsigned long)hwif->io_ports[IDE_DATA_OFFSET] | 7) == ((unsigned long)hwif->io_ports[IDE_STATUS_OFFSET])) { ide_request_region(hwif->io_ports[IDE_DATA_OFFSET], 8, hwif->name); @@ -502,6 +531,7 @@ } #endif + DBG_IDE( "(probe_hwif) index=%d", hwif->index ); if ((hwif->chipset != ide_4drives || !hwif->mate->present) && #if CONFIG_BLK_DEV_PDC4030 (hwif->chipset != ide_pdc4030 || hwif->channel == 0) && @@ -556,6 +586,7 @@ ide_drive_t *drive = &hwif->drives[unit]; if (drive->present) { ide_tuneproc_t *tuneproc = HWIF(drive)->tuneproc; + DBG_IDE( "tuneproc: %s", tuneproc == NULL ? "not available" : "is available" ); if (tuneproc != NULL && drive->autotune == 1) tuneproc(drive, 255); /* auto-tune PIO mode */ } @@ -622,6 +653,7 @@ /* Allocate the buffer and potentially sleep first */ + DBG_IDE( "init_irq ..." ); new_hwgroup = kmalloc(sizeof(ide_hwgroup_t),GFP_KERNEL); save_flags(flags); /* all CPUs */ @@ -681,6 +713,7 @@ */ if (!match || match->irq != hwif->irq) { #ifdef CONFIG_IDEPCI_SHARE_IRQ +#error lajföalj int sa = IDE_CHIPSET_IS_PCI(hwif->chipset) ? SA_SHIRQ : SA_INTERRUPT; #else /* !CONFIG_IDEPCI_SHARE_IRQ */ int sa = IDE_CHIPSET_IS_PCI(hwif->chipset) ? SA_INTERRUPT|SA_SHIRQ : SA_INTERRUPT; @@ -693,6 +726,7 @@ } } + DBG_IDE( "init_irq: done ..." ); /* * Everything is okay, so link us into the hwgroup */ @@ -719,7 +753,7 @@ restore_flags(flags); /* all CPUs; safe now that hwif->hwgroup is set up */ #if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__) - printk("%s at 0x%03x-0x%03x,0x%03x on irq %d", hwif->name, + printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, hwif->io_ports[IDE_DATA_OFFSET], hwif->io_ports[IDE_DATA_OFFSET]+7, hwif->io_ports[IDE_CONTROL_OFFSET], hwif->irq); @@ -820,6 +854,8 @@ static int hwif_init (ide_hwif_t *hwif) { + + DBG_IDE( "hwif_init ..." ); if (!hwif->present) return 0; if (!hwif->irq) { @@ -844,6 +880,7 @@ } if (init_irq(hwif)) { + DBG_IDE( "failed to init IRQ .... " ); int i = hwif->irq; /* * It failed to initialise. Find the default IRQ for @@ -891,11 +928,16 @@ { unsigned int index; int probe[MAX_HWIFS]; + + DBG_IDE( "ideprobe_init ..." ); MOD_INC_USE_COUNT; memset(probe, 0, MAX_HWIFS * sizeof(int)); for (index = 0; index < MAX_HWIFS; ++index) - probe[index] = !ide_hwifs[index].present; + { + DBG_IDE_HWIF((&ide_hwifs[index])); + probe[index] = !ide_hwifs[index].present; + } /* * Probe for drives in the usual way.. CMOS/BIOS, then poke at ports