diff options
Diffstat (limited to 'drivers/ide/legacy')
-rw-r--r-- | drivers/ide/legacy/ali14xx.c | 30 | ||||
-rw-r--r-- | drivers/ide/legacy/buddha.c | 2 | ||||
-rw-r--r-- | drivers/ide/legacy/dtc2278.c | 22 | ||||
-rw-r--r-- | drivers/ide/legacy/falconide.c | 9 | ||||
-rw-r--r-- | drivers/ide/legacy/gayle.c | 2 | ||||
-rw-r--r-- | drivers/ide/legacy/hd.c | 78 | ||||
-rw-r--r-- | drivers/ide/legacy/ht6560b.c | 34 | ||||
-rw-r--r-- | drivers/ide/legacy/ide-4drives.c | 36 | ||||
-rw-r--r-- | drivers/ide/legacy/ide-cs.c | 2 | ||||
-rw-r--r-- | drivers/ide/legacy/ide_platform.c | 7 | ||||
-rw-r--r-- | drivers/ide/legacy/macide.c | 2 | ||||
-rw-r--r-- | drivers/ide/legacy/q40ide.c | 2 | ||||
-rw-r--r-- | drivers/ide/legacy/qd65xx.c | 165 | ||||
-rw-r--r-- | drivers/ide/legacy/qd65xx.h | 1 | ||||
-rw-r--r-- | drivers/ide/legacy/umc8672.c | 81 |
15 files changed, 251 insertions, 222 deletions
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c index bc8b1f8de614..33bb7b87be5d 100644 --- a/drivers/ide/legacy/ali14xx.c +++ b/drivers/ide/legacy/ali14xx.c @@ -86,7 +86,7 @@ static u8 regOff; /* output to base port to close registers */ /* * Read a controller register. */ -static inline u8 inReg (u8 reg) +static inline u8 inReg(u8 reg) { outb_p(reg, regPort); return inb(dataPort); @@ -95,7 +95,7 @@ static inline u8 inReg (u8 reg) /* * Write a controller register. */ -static void outReg (u8 data, u8 reg) +static void outReg(u8 data, u8 reg) { outb_p(reg, regPort); outb_p(data, dataPort); @@ -143,7 +143,7 @@ static void ali14xx_set_pio_mode(ide_drive_t *drive, const u8 pio) /* * Auto-detect the IDE controller port. */ -static int __init findPort (void) +static int __init findPort(void) { int i; u8 t; @@ -175,7 +175,8 @@ static int __init findPort (void) /* * Initialize controller registers with default values. */ -static int __init initRegisters (void) { +static int __init initRegisters(void) +{ const RegInitializer *p; u8 t; unsigned long flags; @@ -199,7 +200,8 @@ static const struct ide_port_info ali14xx_port_info = { static int __init ali14xx_probe(void) { - static u8 idx[4] = { 0, 1, 0xff, 0xff }; + ide_hwif_t *hwif, *mate; + static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; hw_regs_t hw[2]; printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n", @@ -219,18 +221,26 @@ static int __init ali14xx_probe(void) ide_std_init_ports(&hw[1], 0x170, 0x376); hw[1].irq = 15; - ide_init_port_hw(&ide_hwifs[0], &hw[0]); - ide_init_port_hw(&ide_hwifs[1], &hw[1]); + hwif = ide_find_port(); + if (hwif) { + ide_init_port_hw(hwif, &hw[0]); + hwif->set_pio_mode = &ali14xx_set_pio_mode; + idx[0] = hwif->index; + } - ide_hwifs[0].set_pio_mode = &ali14xx_set_pio_mode; - ide_hwifs[1].set_pio_mode = &ali14xx_set_pio_mode; + mate = ide_find_port(); + if (mate) { + ide_init_port_hw(mate, &hw[1]); + mate->set_pio_mode = &ali14xx_set_pio_mode; + idx[1] = mate->index; + } ide_device_add(idx, &ali14xx_port_info); return 0; } -int probe_ali14xx = 0; +int probe_ali14xx; module_param_named(probe, probe_ali14xx, bool, 0); MODULE_PARM_DESC(probe, "probe for ALI M14xx chipsets"); diff --git a/drivers/ide/legacy/buddha.c b/drivers/ide/legacy/buddha.c index fdd3791e465f..6956eb8f2d5f 100644 --- a/drivers/ide/legacy/buddha.c +++ b/drivers/ide/legacy/buddha.c @@ -221,7 +221,7 @@ fail_base2: buddha_setup_ports(&hw, base, ctl, irq_port, ack_intr); - hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); + hwif = ide_find_port(); if (hwif) { u8 index = hwif->index; diff --git a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c index 5f69cd2ea6f7..9c6b3249a004 100644 --- a/drivers/ide/legacy/dtc2278.c +++ b/drivers/ide/legacy/dtc2278.c @@ -102,15 +102,9 @@ static int __init dtc2278_probe(void) { unsigned long flags; ide_hwif_t *hwif, *mate; - static u8 idx[4] = { 0, 1, 0xff, 0xff }; + static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; hw_regs_t hw[2]; - hwif = &ide_hwifs[0]; - mate = &ide_hwifs[1]; - - if (hwif->chipset != ide_unknown || mate->chipset != ide_unknown) - return 1; - local_irq_save(flags); /* * This enables the second interface @@ -137,10 +131,18 @@ static int __init dtc2278_probe(void) ide_std_init_ports(&hw[1], 0x170, 0x376); hw[1].irq = 15; - ide_init_port_hw(hwif, &hw[0]); - ide_init_port_hw(mate, &hw[1]); + hwif = ide_find_port(); + if (hwif) { + ide_init_port_hw(hwif, &hw[0]); + hwif->set_pio_mode = dtc2278_set_pio_mode; + idx[0] = hwif->index; + } - hwif->set_pio_mode = &dtc2278_set_pio_mode; + mate = ide_find_port(); + if (mate) { + ide_init_port_hw(mate, &hw[1]); + idx[1] = mate->index; + } ide_device_add(idx, &dtc2278_port_info); diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c index e950afa5939c..8c9c9f7f54ca 100644 --- a/drivers/ide/legacy/falconide.c +++ b/drivers/ide/legacy/falconide.c @@ -22,6 +22,7 @@ #include <asm/atariints.h> #include <asm/atari_stdma.h> +#define DRV_NAME "falconide" /* * Base of the IDE interface @@ -74,15 +75,21 @@ static int __init falconide_init(void) printk(KERN_INFO "ide: Falcon IDE controller\n"); + if (!request_mem_region(ATA_HD_BASE, 0x40, DRV_NAME)) { + printk(KERN_ERR "%s: resources busy\n", DRV_NAME); + return -EBUSY; + } + falconide_setup_ports(&hw); - hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); + hwif = ide_find_port(); if (hwif) { u8 index = hwif->index; u8 idx[4] = { index, 0xff, 0xff, 0xff }; ide_init_port_data(hwif, index); ide_init_port_hw(hwif, &hw); + hwif->mmio = 1; ide_get_lock(NULL, NULL); ide_device_add(idx, NULL); diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c index e3b4638cc883..fcc8d52bf2a1 100644 --- a/drivers/ide/legacy/gayle.c +++ b/drivers/ide/legacy/gayle.c @@ -175,7 +175,7 @@ found: gayle_setup_ports(&hw, base, ctrlport, irqport, ack_intr); - hwif = ide_find_port(base); + hwif = ide_find_port(); if (hwif) { u8 index = hwif->index; diff --git a/drivers/ide/legacy/hd.c b/drivers/ide/legacy/hd.c index 0b0d86731927..abdedf56643e 100644 --- a/drivers/ide/legacy/hd.c +++ b/drivers/ide/legacy/hd.c @@ -122,12 +122,12 @@ static int hd_error; * This struct defines the HD's and their types. */ struct hd_i_struct { - unsigned int head,sect,cyl,wpcom,lzone,ctl; + unsigned int head, sect, cyl, wpcom, lzone, ctl; int unit; int recalibrate; int special_op; }; - + #ifdef HD_TYPE static struct hd_i_struct hd_info[] = { HD_TYPE }; static int NR_HD = ARRAY_SIZE(hd_info); @@ -168,7 +168,7 @@ unsigned long read_timer(void) spin_lock_irqsave(&i8253_lock, flags); t = jiffies * 11932; - outb_p(0, 0x43); + outb_p(0, 0x43); i = inb_p(0x40); i |= inb(0x40) << 8; spin_unlock_irqrestore(&i8253_lock, flags); @@ -183,7 +183,7 @@ static void __init hd_setup(char *str, int *ints) if (ints[0] != 3) return; if (hd_info[0].head != 0) - hdind=1; + hdind = 1; hd_info[hdind].head = ints[2]; hd_info[hdind].sect = ints[3]; hd_info[hdind].cyl = ints[1]; @@ -193,7 +193,7 @@ static void __init hd_setup(char *str, int *ints) NR_HD = hdind+1; } -static void dump_status (const char *msg, unsigned int stat) +static void dump_status(const char *msg, unsigned int stat) { char *name = "hd?"; if (CURRENT) @@ -291,7 +291,6 @@ static int controller_ready(unsigned int drive, unsigned int head) return 0; } - static void hd_out(struct hd_i_struct *disk, unsigned int nsect, unsigned int sect, @@ -313,15 +312,15 @@ static void hd_out(struct hd_i_struct *disk, return; } SET_HANDLER(intr_addr); - outb_p(disk->ctl,HD_CMD); - port=HD_DATA; - outb_p(disk->wpcom>>2,++port); - outb_p(nsect,++port); - outb_p(sect,++port); - outb_p(cyl,++port); - outb_p(cyl>>8,++port); - outb_p(0xA0|(disk->unit<<4)|head,++port); - outb_p(cmd,++port); + outb_p(disk->ctl, HD_CMD); + port = HD_DATA; + outb_p(disk->wpcom >> 2, ++port); + outb_p(nsect, ++port); + outb_p(sect, ++port); + outb_p(cyl, ++port); + outb_p(cyl >> 8, ++port); + outb_p(0xA0 | (disk->unit << 4) | head, ++port); + outb_p(cmd, ++port); } static void hd_request (void); @@ -344,14 +343,14 @@ static void reset_controller(void) { int i; - outb_p(4,HD_CMD); - for(i = 0; i < 1000; i++) barrier(); - outb_p(hd_info[0].ctl & 0x0f,HD_CMD); - for(i = 0; i < 1000; i++) barrier(); + outb_p(4, HD_CMD); + for (i = 0; i < 1000; i++) barrier(); + outb_p(hd_info[0].ctl & 0x0f, HD_CMD); + for (i = 0; i < 1000; i++) barrier(); if (drive_busy()) printk("hd: controller still busy\n"); else if ((hd_error = inb(HD_ERROR)) != 1) - printk("hd: controller reset failed: %02x\n",hd_error); + printk("hd: controller reset failed: %02x\n", hd_error); } static void reset_hd(void) @@ -371,8 +370,8 @@ repeat: if (++i < NR_HD) { struct hd_i_struct *disk = &hd_info[i]; disk->special_op = disk->recalibrate = 1; - hd_out(disk,disk->sect,disk->sect,disk->head-1, - disk->cyl,WIN_SPECIFY,&reset_hd); + hd_out(disk, disk->sect, disk->sect, disk->head-1, + disk->cyl, WIN_SPECIFY, &reset_hd); if (reset) goto repeat; } else @@ -393,7 +392,7 @@ static void unexpected_hd_interrupt(void) unsigned int stat = inb_p(HD_STATUS); if (stat & (BUSY_STAT|DRQ_STAT|ECC_STAT|ERR_STAT)) { - dump_status ("unexpected interrupt", stat); + dump_status("unexpected interrupt", stat); SET_TIMER; } } @@ -453,7 +452,7 @@ static void read_intr(void) return; ok_to_read: req = CURRENT; - insw(HD_DATA,req->buffer,256); + insw(HD_DATA, req->buffer, 256); req->sector++; req->buffer += 512; req->errors = 0; @@ -507,7 +506,7 @@ ok_to_write: end_request(req, 1); if (i > 0) { SET_HANDLER(&write_intr); - outsw(HD_DATA,req->buffer,256); + outsw(HD_DATA, req->buffer, 256); local_irq_enable(); } else { #if (HD_DELAY > 0) @@ -560,11 +559,11 @@ static int do_special_op(struct hd_i_struct *disk, struct request *req) { if (disk->recalibrate) { disk->recalibrate = 0; - hd_out(disk,disk->sect,0,0,0,WIN_RESTORE,&recal_intr); + hd_out(disk, disk->sect, 0, 0, 0, WIN_RESTORE, &recal_intr); return reset; } if (disk->head > 16) { - printk ("%s: cannot handle device with more than 16 heads - giving up\n", req->rq_disk->disk_name); + printk("%s: cannot handle device with more than 16 heads - giving up\n", req->rq_disk->disk_name); end_request(req, 0); } disk->special_op = 0; @@ -633,19 +632,21 @@ repeat: if (blk_fs_request(req)) { switch (rq_data_dir(req)) { case READ: - hd_out(disk,nsect,sec,head,cyl,WIN_READ,&read_intr); + hd_out(disk, nsect, sec, head, cyl, WIN_READ, + &read_intr); if (reset) goto repeat; break; case WRITE: - hd_out(disk,nsect,sec,head,cyl,WIN_WRITE,&write_intr); + hd_out(disk, nsect, sec, head, cyl, WIN_WRITE, + &write_intr); if (reset) goto repeat; if (wait_DRQ()) { bad_rw_intr(); goto repeat; } - outsw(HD_DATA,req->buffer,256); + outsw(HD_DATA, req->buffer, 256); break; default: printk("unknown hd-command\n"); @@ -655,7 +656,7 @@ repeat: } } -static void do_hd_request (struct request_queue * q) +static void do_hd_request(struct request_queue *q) { disable_irq(HD_IRQ); hd_request(); @@ -708,12 +709,12 @@ static int __init hd_init(void) { int drive; - if (register_blkdev(MAJOR_NR,"hd")) + if (register_blkdev(MAJOR_NR, "hd")) return -1; hd_queue = blk_init_queue(do_hd_request, &hd_lock); if (!hd_queue) { - unregister_blkdev(MAJOR_NR,"hd"); + unregister_blkdev(MAJOR_NR, "hd"); return -ENOMEM; } @@ -742,7 +743,7 @@ static int __init hd_init(void) goto out; } - for (drive=0 ; drive < NR_HD ; drive++) { + for (drive = 0 ; drive < NR_HD ; drive++) { struct gendisk *disk = alloc_disk(64); struct hd_i_struct *p = &hd_info[drive]; if (!disk) @@ -756,7 +757,7 @@ static int __init hd_init(void) disk->queue = hd_queue; p->unit = drive; hd_gendisk[drive] = disk; - printk ("%s: %luMB, CHS=%d/%d/%d\n", + printk("%s: %luMB, CHS=%d/%d/%d\n", disk->disk_name, (unsigned long)get_capacity(disk)/2048, p->cyl, p->head, p->sect); } @@ -776,7 +777,7 @@ static int __init hd_init(void) } /* Let them fly */ - for(drive=0; drive < NR_HD; drive++) + for (drive = 0; drive < NR_HD; drive++) add_disk(hd_gendisk[drive]); return 0; @@ -791,7 +792,7 @@ out1: NR_HD = 0; out: del_timer(&device_timer); - unregister_blkdev(MAJOR_NR,"hd"); + unregister_blkdev(MAJOR_NR, "hd"); blk_cleanup_queue(hd_queue); return -1; Enomem: @@ -800,7 +801,8 @@ Enomem: goto out; } -static int __init parse_hd_setup (char *line) { +static int __init parse_hd_setup(char *line) +{ int ints[6]; (void) get_options(line, ARRAY_SIZE(ints), ints); diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c index 88fe9070c9c3..60f52f5158c9 100644 --- a/drivers/ide/legacy/ht6560b.c +++ b/drivers/ide/legacy/ht6560b.c @@ -35,6 +35,7 @@ * Try: http://www.maf.iki.fi/~maf/ht6560b/ */ +#define DRV_NAME "ht6560b" #define HT6560B_VERSION "v0.08" #include <linux/module.h> @@ -339,16 +340,13 @@ static const struct ide_port_info ht6560b_port_info __initdata = { static int __init ht6560b_init(void) { ide_hwif_t *hwif, *mate; - static u8 idx[4] = { 0, 1, 0xff, 0xff }; + static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; hw_regs_t hw[2]; if (probe_ht6560b == 0) return -ENODEV; - hwif = &ide_hwifs[0]; - mate = &ide_hwifs[1]; - - if (!request_region(HT_CONFIG_PORT, 1, hwif->name)) { + if (!request_region(HT_CONFIG_PORT, 1, DRV_NAME)) { printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n", __FUNCTION__); return -ENODEV; @@ -367,17 +365,23 @@ static int __init ht6560b_init(void) ide_std_init_ports(&hw[1], 0x170, 0x376); hw[1].irq = 15; - ide_init_port_hw(hwif, &hw[0]); - ide_init_port_hw(mate, &hw[1]); - - hwif->selectproc = &ht6560b_selectproc; - hwif->set_pio_mode = &ht6560b_set_pio_mode; - - mate->selectproc = &ht6560b_selectproc; - mate->set_pio_mode = &ht6560b_set_pio_mode; + hwif = ide_find_port(); + if (hwif) { + ide_init_port_hw(hwif, &hw[0]); + hwif->selectproc = ht6560b_selectproc; + hwif->set_pio_mode = ht6560b_set_pio_mode; + hwif->port_init_devs = ht6560b_port_init_devs; + idx[0] = hwif->index; + } - hwif->port_init_devs = ht6560b_port_init_devs; - mate->port_init_devs = ht6560b_port_init_devs; + mate = ide_find_port(); + if (mate) { + ide_init_port_hw(mate, &hw[1]); + mate->selectproc = ht6560b_selectproc; + mate->set_pio_mode = ht6560b_set_pio_mode; + mate->port_init_devs = ht6560b_port_init_devs; + idx[1] = mate->index; + } ide_device_add(idx, &ht6560b_port_info); diff --git a/drivers/ide/legacy/ide-4drives.c b/drivers/ide/legacy/ide-4drives.c index ecd7f3553554..c352f12348af 100644 --- a/drivers/ide/legacy/ide-4drives.c +++ b/drivers/ide/legacy/ide-4drives.c @@ -4,7 +4,7 @@ #include <linux/module.h> #include <linux/ide.h> -int probe_4drives = 0; +int probe_4drives; module_param_named(probe, probe_4drives, bool, 0); MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port"); @@ -12,31 +12,37 @@ MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port"); static int __init ide_4drives_init(void) { ide_hwif_t *hwif, *mate; - u8 idx[4] = { 0, 1, 0xff, 0xff }; + u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; hw_regs_t hw; if (probe_4drives == 0) return -ENODEV; - hwif = &ide_hwifs[0]; - mate = &ide_hwifs[1]; - memset(&hw, 0, sizeof(hw)); ide_std_init_ports(&hw, 0x1f0, 0x3f6); hw.irq = 14; hw.chipset = ide_4drives; - ide_init_port_hw(hwif, &hw); - ide_init_port_hw(mate, &hw); - - mate->drives[0].select.all ^= 0x20; - mate->drives[1].select.all ^= 0x20; - - hwif->mate = mate; - mate->mate = hwif; - - hwif->serialized = mate->serialized = 1; + hwif = ide_find_port(); + if (hwif) { + ide_init_port_hw(hwif, &hw); + idx[0] = hwif->index; + } + + mate = ide_find_port(); + if (mate) { + ide_init_port_hw(mate, &hw); + mate->drives[0].select.all ^= 0x20; + mate->drives[1].select.all ^= 0x20; + idx[1] = mate->index; + + if (hwif) { + hwif->mate = mate; + mate->mate = hwif; + hwif->serialized = mate->serialized = 1; + } + } ide_device_add(idx, NULL); diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index 9a23b94f2939..b97b8d51b3eb 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c @@ -156,7 +156,7 @@ static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq hw.chipset = ide_pci; hw.dev = &handle->dev; - hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); + hwif = ide_find_port(); if (hwif == NULL) return -1; diff --git a/drivers/ide/legacy/ide_platform.c b/drivers/ide/legacy/ide_platform.c index 361b1bb544bf..bf240775531e 100644 --- a/drivers/ide/legacy/ide_platform.c +++ b/drivers/ide/legacy/ide_platform.c @@ -89,7 +89,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) res_alt->start, res_alt->end - res_alt->start + 1); } - hwif = ide_find_port((unsigned long)base); + hwif = ide_find_port(); if (!hwif) { ret = -ENODEV; goto out; @@ -100,11 +100,10 @@ static int __devinit plat_ide_probe(struct platform_device *pdev) hw.dev = &pdev->dev; ide_init_port_hw(hwif, &hw); + hwif->mmio = 1; - if (mmio) { - hwif->mmio = 1; + if (mmio) default_hwif_mmiops(hwif); - } idx[0] = hwif->index; diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c index eaf5dbe58bc2..7429b80cb089 100644 --- a/drivers/ide/legacy/macide.c +++ b/drivers/ide/legacy/macide.c @@ -120,7 +120,7 @@ static int __init macide_init(void) macide_setup_ports(&hw, base, irq, ack_intr); - hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); + hwif = ide_find_port(); if (hwif) { u8 index = hwif->index; u8 idx[4] = { index, 0xff, 0xff, 0xff }; diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c index 2da28759686e..fcbff0eced1b 100644 --- a/drivers/ide/legacy/q40ide.c +++ b/drivers/ide/legacy/q40ide.c @@ -137,7 +137,7 @@ static int __init q40ide_init(void) // m68kide_iops, q40ide_default_irq(pcide_bases[i])); - hwif = ide_find_port(hw.io_ports[IDE_DATA_OFFSET]); + hwif = ide_find_port(); if (hwif) { ide_init_port_data(hwif, hwif->index); ide_init_port_hw(hwif, &hw); diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c index 7016bdf4fcc1..6e820c7c5c6b 100644 --- a/drivers/ide/legacy/qd65xx.c +++ b/drivers/ide/legacy/qd65xx.c @@ -88,12 +88,12 @@ static int timings[4]={-1,-1,-1,-1}; /* stores current timing for each timer */ /* - * qd_select: + * qd65xx_select: * - * This routine is invoked from ide.c to prepare for access to a given drive. + * This routine is invoked to prepare for access to a given drive. */ -static void qd_select (ide_drive_t *drive) +static void qd65xx_select(ide_drive_t *drive) { u8 index = (( (QD_TIMREG(drive)) & 0x80 ) >> 7) | (QD_TIMREG(drive) & 0x02); @@ -168,36 +168,15 @@ static int qd_find_disk_type (ide_drive_t *drive, } /* - * qd_timing_ok: - * - * check whether timings don't conflict - */ - -static int qd_timing_ok (ide_drive_t drives[]) -{ - return (IDE_IMPLY(drives[0].present && drives[1].present, - IDE_IMPLY(QD_TIMREG(drives) == QD_TIMREG(drives+1), - QD_TIMING(drives) == QD_TIMING(drives+1)))); - /* if same timing register, must be same timing */ -} - -/* * qd_set_timing: * - * records the timing, and enables selectproc as needed + * records the timing */ static void qd_set_timing (ide_drive_t *drive, u8 timing) { - ide_hwif_t *hwif = HWIF(drive); - drive->drive_data &= 0xff00; drive->drive_data |= timing; - if (qd_timing_ok(hwif->drives)) { - qd_select(drive); /* selects once */ - hwif->selectproc = NULL; - } else - hwif->selectproc = &qd_select; printk(KERN_DEBUG "%s: %#x\n", drive->name, timing); } @@ -225,10 +204,11 @@ static void qd6500_set_pio_mode(ide_drive_t *drive, const u8 pio) static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio) { - int base = HWIF(drive)->select_data; + ide_hwif_t *hwif = drive->hwif; unsigned int cycle_time; int active_time = 175; int recovery_time = 415; /* worst case values from the dos driver */ + u8 base = (hwif->config_data & 0xff00) >> 8; if (drive->id && !qd_find_disk_type(drive, &active_time, &recovery_time)) { cycle_time = ide_pio_cycle_time(drive, pio); @@ -299,21 +279,10 @@ static int __init qd_testreg(int port) return (readreg != QD_TESTVAL); } -/* - * qd_setup: - * - * called to setup an ata channel : adjusts attributes & links for tuning - */ - -static void __init qd_setup(ide_hwif_t *hwif, int base, int config) -{ - hwif->select_data = base; - hwif->config_data = config; -} - static void __init qd6500_port_init_devs(ide_hwif_t *hwif) { - u8 base = hwif->select_data, config = QD_CONFIG(hwif); + u8 base = (hwif->config_data & 0xff00) >> 8; + u8 config = QD_CONFIG(hwif); hwif->drives[0].drive_data = QD6500_DEF_DATA; hwif->drives[1].drive_data = QD6500_DEF_DATA; @@ -322,9 +291,10 @@ static void __init qd6500_port_init_devs(ide_hwif_t *hwif) static void __init qd6580_port_init_devs(ide_hwif_t *hwif) { u16 t1, t2; - u8 base = hwif->select_data, config = QD_CONFIG(hwif); + u8 base = (hwif->config_data & 0xff00) >> 8; + u8 config = QD_CONFIG(hwif); - if (QD_CONTROL(hwif) & QD_CONTR_SEC_DISABLED) { + if (hwif->host_flags & IDE_HFLAG_SINGLE) { t1 = QD6580_DEF_DATA; t2 = QD6580_DEF_DATA2; } else @@ -355,14 +325,18 @@ static int __init qd_probe(int base) u8 config, unit; u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; hw_regs_t hw[2]; + struct ide_port_info d = qd65xx_port_info; config = inb(QD_CONFIG_PORT); if (! ((config & QD_CONFIG_BASEPORT) >> 1 == (base == 0xb0)) ) - return 1; + return -ENODEV; unit = ! (config & QD_CONFIG_IDE_BASEPORT); + if (unit) + d.host_flags |= IDE_HFLAG_QD_2ND_PORT; + memset(&hw, 0, sizeof(hw)); ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); @@ -373,30 +347,37 @@ static int __init qd_probe(int base) if ((config & 0xf0) == QD_CONFIG_QD6500) { - if (qd_testreg(base)) return 1; /* bad register */ + if (qd_testreg(base)) + return -ENODEV; /* bad register */ /* qd6500 found */ - hwif = &ide_hwifs[unit]; - printk(KERN_NOTICE "%s: qd6500 at %#x\n", hwif->name, base); - printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n", - config, QD_ID3); - if (config & QD_CONFIG_DISABLED) { printk(KERN_WARNING "qd6500 is disabled !\n"); - return 1; + return -ENODEV; } + printk(KERN_NOTICE "qd6500 at %#x\n", base); + printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n", + config, QD_ID3); + + d.host_flags |= IDE_HFLAG_SINGLE; + + hwif = ide_find_port_slot(&d); + if (hwif == NULL) + return -ENOENT; + ide_init_port_hw(hwif, &hw[unit]); - qd_setup(hwif, base, config); + hwif->config_data = (base << 8) | config; hwif->port_init_devs = qd6500_port_init_devs; - hwif->set_pio_mode = &qd6500_set_pio_mode; + hwif->set_pio_mode = qd6500_set_pio_mode; + hwif->selectproc = qd65xx_select; - idx[unit] = unit; + idx[unit] = hwif->index; - ide_device_add(idx, &qd65xx_port_info); + ide_device_add(idx, &d); return 1; } @@ -406,8 +387,8 @@ static int __init qd_probe(int base) u8 control; - if (qd_testreg(base) || qd_testreg(base+0x02)) return 1; - /* bad registers */ + if (qd_testreg(base) || qd_testreg(base + 0x02)) + return -ENODEV; /* bad registers */ /* qd6580 found */ @@ -422,46 +403,52 @@ static int __init qd_probe(int base) if (control & QD_CONTR_SEC_DISABLED) { /* secondary disabled */ - hwif = &ide_hwifs[unit]; - printk(KERN_INFO "%s: qd6580: single IDE board\n", - hwif->name); + printk(KERN_INFO "qd6580: single IDE board\n"); + + d.host_flags |= IDE_HFLAG_SINGLE; + + hwif = ide_find_port_slot(&d); + if (hwif == NULL) + return -ENOENT; ide_init_port_hw(hwif, &hw[unit]); - qd_setup(hwif, base, config | (control << 8)); + hwif->config_data = (base << 8) | config; hwif->port_init_devs = qd6580_port_init_devs; - hwif->set_pio_mode = &qd6580_set_pio_mode; + hwif->set_pio_mode = qd6580_set_pio_mode; + hwif->selectproc = qd65xx_select; - idx[unit] = unit; + idx[unit] = hwif->index; - ide_device_add(idx, &qd65xx_port_info); + ide_device_add(idx, &d); return 1; } else { ide_hwif_t *mate; - hwif = &ide_hwifs[0]; - mate = &ide_hwifs[1]; /* secondary enabled */ - printk(KERN_INFO "%s&%s: qd6580: dual IDE board\n", - hwif->name, mate->name); - - ide_init_port_hw(hwif, &hw[0]); - ide_init_port_hw(mate, &hw[1]); - - qd_setup(hwif, base, config | (control << 8)); - - hwif->port_init_devs = qd6580_port_init_devs; - hwif->set_pio_mode = &qd6580_set_pio_mode; - - qd_setup(mate, base, config | (control << 8)); - - mate->port_init_devs = qd6580_port_init_devs; - mate->set_pio_mode = &qd6580_set_pio_mode; - - idx[0] = 0; - idx[1] = 1; + printk(KERN_INFO "qd6580: dual IDE board\n"); + + hwif = ide_find_port(); + if (hwif) { + ide_init_port_hw(hwif, &hw[0]); + hwif->config_data = (base << 8) | config; + hwif->port_init_devs = qd6580_port_init_devs; + hwif->set_pio_mode = qd6580_set_pio_mode; + hwif->selectproc = qd65xx_select; + idx[0] = hwif->index; + } + + mate = ide_find_port(); + if (mate) { + ide_init_port_hw(mate, &hw[1]); + mate->config_data = (base << 8) | config; + mate->port_init_devs = qd6580_port_init_devs; + mate->set_pio_mode = qd6580_set_pio_mode; + mate->selectproc = qd65xx_select; + idx[1] = mate->index; + } ide_device_add(idx, &qd65xx_port_info); @@ -469,7 +456,7 @@ static int __init qd_probe(int base) } } /* no qd65xx found */ - return 1; + return -ENODEV; } int probe_qd65xx = 0; @@ -479,14 +466,18 @@ MODULE_PARM_DESC(probe, "probe for QD65xx chipsets"); static int __init qd65xx_init(void) { + int rc1, rc2 = -ENODEV; + if (probe_qd65xx == 0) return -ENODEV; - if (qd_probe(0x30)) - qd_probe(0xb0); - if (ide_hwifs[0].chipset != ide_qd65xx && - ide_hwifs[1].chipset != ide_qd65xx) + rc1 = qd_probe(0x30); + if (rc1) + rc2 = qd_probe(0xb0); + + if (rc1 < 0 && rc2 < 0) return -ENODEV; + return 0; } diff --git a/drivers/ide/legacy/qd65xx.h b/drivers/ide/legacy/qd65xx.h index 28dd50a15d55..c83dea85e621 100644 --- a/drivers/ide/legacy/qd65xx.h +++ b/drivers/ide/legacy/qd65xx.h @@ -30,7 +30,6 @@ #define QD_ID3 ((config & QD_CONFIG_ID3)!=0) #define QD_CONFIG(hwif) ((hwif)->config_data & 0x00ff) -#define QD_CONTROL(hwif) (((hwif)->config_data & 0xff00) >> 8) #define QD_TIMING(drive) (byte)(((drive)->drive_data) & 0x00ff) #define QD_TIMREG(drive) (byte)((((drive)->drive_data) & 0xff00) >> 8) diff --git a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c index bc1944811b99..4d90badd2bda 100644 --- a/drivers/ide/legacy/umc8672.c +++ b/drivers/ide/legacy/umc8672.c @@ -19,7 +19,7 @@ */ /* - * VLB Controller Support from + * VLB Controller Support from * Wolfram Podien * Rohoefe 3 * D28832 Achim @@ -32,7 +32,7 @@ * #define UMC_DRIVE0 11 * in the beginning of the driver, which sets the speed of drive 0 to 11 (there * are some lines present). 0 - 11 are allowed speed values. These values are - * the results from the DOS speed test program supplied from UMC. 11 is the + * the results from the DOS speed test program supplied from UMC. 11 is the * highest speed (about PIO mode 3) */ #define REALLY_SLOW_IO /* some systems can safely undef this */ @@ -60,62 +60,62 @@ #define UMC_DRIVE3 1 /* In case of crash reduce speed */ static u8 current_speeds[4] = {UMC_DRIVE0, UMC_DRIVE1, UMC_DRIVE2, UMC_DRIVE3}; -static const u8 pio_to_umc [5] = {0,3,7,10,11}; /* rough guesses */ +static const u8 pio_to_umc [5] = {0, 3, 7, 10, 11}; /* rough guesses */ /* 0 1 2 3 4 5 6 7 8 9 10 11 */ static const u8 speedtab [3][12] = { - {0xf, 0xb, 0x2, 0x2, 0x2, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1 }, - {0x3, 0x2, 0x2, 0x2, 0x2, 0x2, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1 }, - {0xff,0xcb,0xc0,0x58,0x36,0x33,0x23,0x22,0x21,0x11,0x10,0x0}}; + {0x0f, 0x0b, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1}, + {0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1}, + {0xff, 0xcb, 0xc0, 0x58, 0x36, 0x33, 0x23, 0x22, 0x21, 0x11, 0x10, 0x0} +}; -static void out_umc (char port,char wert) +static void out_umc(char port, char wert) { - outb_p(port,0x108); - outb_p(wert,0x109); + outb_p(port, 0x108); + outb_p(wert, 0x109); } -static inline u8 in_umc (char port) +static inline u8 in_umc(char port) { - outb_p(port,0x108); + outb_p(port, 0x108); return inb_p(0x109); } -static void umc_set_speeds (u8 speeds[]) +static void umc_set_speeds(u8 speeds[]) { int i, tmp; - outb_p(0x5A,0x108); /* enable umc */ + outb_p(0x5A, 0x108); /* enable umc */ - out_umc (0xd7,(speedtab[0][speeds[2]] | (speedtab[0][speeds[3]]<<4))); - out_umc (0xd6,(speedtab[0][speeds[0]] | (speedtab[0][speeds[1]]<<4))); + out_umc(0xd7, (speedtab[0][speeds[2]] | (speedtab[0][speeds[3]]<<4))); + out_umc(0xd6, (speedtab[0][speeds[0]] | (speedtab[0][speeds[1]]<<4))); tmp = 0; - for (i = 3; i >= 0; i--) { + for (i = 3; i >= 0; i--) tmp = (tmp << 2) | speedtab[1][speeds[i]]; + out_umc(0xdc, tmp); + for (i = 0; i < 4; i++) { + out_umc(0xd0 + i, speedtab[2][speeds[i]]); + out_umc(0xd8 + i, speedtab[2][speeds[i]]); } - out_umc (0xdc,tmp); - for (i = 0;i < 4; i++) { - out_umc (0xd0+i,speedtab[2][speeds[i]]); - out_umc (0xd8+i,speedtab[2][speeds[i]]); - } - outb_p(0xa5,0x108); /* disable umc */ + outb_p(0xa5, 0x108); /* disable umc */ - printk ("umc8672: drive speeds [0 to 11]: %d %d %d %d\n", + printk("umc8672: drive speeds [0 to 11]: %d %d %d %d\n", speeds[0], speeds[1], speeds[2], speeds[3]); } static void umc_set_pio_mode(ide_drive_t *drive, const u8 pio) { + ide_hwif_t *hwif = drive->hwif; unsigned long flags; - ide_hwgroup_t *hwgroup = ide_hwifs[HWIF(drive)->index^1].hwgroup; printk("%s: setting umc8672 to PIO mode%d (speed %d)\n", drive->name, pio, pio_to_umc[pio]); spin_lock_irqsave(&ide_lock, flags); - if (hwgroup && hwgroup->handler != NULL) { + if (hwif->mate && hwif->mate->hwgroup->handler) { printk(KERN_ERR "umc8672: other interface is busy: exiting tune_umc()\n"); } else { current_speeds[drive->name[2] - 'a'] = pio_to_umc[pio]; - umc_set_speeds (current_speeds); + umc_set_speeds(current_speeds); } spin_unlock_irqrestore(&ide_lock, flags); } @@ -128,8 +128,9 @@ static const struct ide_port_info umc8672_port_info __initdata = { static int __init umc8672_probe(void) { + ide_hwif_t *hwif, *mate; unsigned long flags; - static u8 idx[4] = { 0, 1, 0xff, 0xff }; + static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; hw_regs_t hw[2]; if (!request_region(0x108, 2, "umc8672")) { @@ -137,16 +138,16 @@ static int __init umc8672_probe(void) return 1; } local_irq_save(flags); - outb_p(0x5A,0x108); /* enable umc */ + outb_p(0x5A, 0x108); /* enable umc */ if (in_umc (0xd5) != 0xa0) { local_irq_restore(flags); printk(KERN_ERR "umc8672: not found\n"); release_region(0x108, 2); - return 1; + return 1; } - outb_p(0xa5,0x108); /* disable umc */ + outb_p(0xa5, 0x108); /* disable umc */ - umc_set_speeds (current_speeds); + umc_set_speeds(current_speeds); local_irq_restore(flags); memset(&hw, 0, sizeof(hw)); @@ -157,18 +158,26 @@ static int __init umc8672_probe(void) ide_std_init_ports(&hw[1], 0x170, 0x376); hw[1].irq = 15; - ide_init_port_hw(&ide_hwifs[0], &hw[0]); - ide_init_port_hw(&ide_hwifs[1], &hw[1]); + hwif = ide_find_port(); + if (hwif) { + ide_init_port_hw(hwif, &hw[0]); + hwif->set_pio_mode = umc_set_pio_mode; + idx[0] = hwif->index; + } - ide_hwifs[0].set_pio_mode = &umc_set_pio_mode; - ide_hwifs[1].set_pio_mode = &umc_set_pio_mode; + mate = ide_find_port(); + if (mate) { + ide_init_port_hw(mate, &hw[1]); + mate->set_pio_mode = umc_set_pio_mode; + idx[1] = mate->index; + } ide_device_add(idx, &umc8672_port_info); return 0; } -int probe_umc8672 = 0; +int probe_umc8672; module_param_named(probe, probe_umc8672, bool, 0); MODULE_PARM_DESC(probe, "probe for UMC8672 chipset"); |