]> err.no Git - linux-2.6/blobdiff - drivers/ide/legacy/qd65xx.c
Merge branch 'linus' into x86/kconfig
[linux-2.6] / drivers / ide / legacy / qd65xx.c
index d8a05b57277bc6d243ad5929e3cf70f815a91331..6424af154325d9f1c0776b37f7cb7aac7d932593 100644 (file)
  *
  * QDI QD6500/QD6580 EIDE controller fast support
  *
- * Please set local bus speed using kernel parameter idebus
- *     for example, "idebus=33" stands for 33Mhz VLbus
  * To activate controller support, use "ide0=qd65xx"
- * To enable tuning, use "hda=autotune hdb=autotune"
- * To enable 2nd channel tuning (qd6580 only), use "hdc=autotune hdd=autotune"
  */
 
 /*
@@ -37,6 +33,8 @@
 #include <asm/system.h>
 #include <asm/io.h>
 
+#define DRV_NAME "qd65xx"
+
 #include "qd65xx.h"
 
 /*
@@ -112,17 +110,18 @@ static void qd65xx_select(ide_drive_t *drive)
 
 static u8 qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recovery_time)
 {
-       u8 active_cycle,recovery_cycle;
+       int clk = ide_vlb_clk ? ide_vlb_clk : system_bus_clock();
+       u8 act_cyc, rec_cyc;
 
-       if (system_bus_clock()<=33) {
-               active_cycle =   9  - IDE_IN(active_time   * system_bus_clock() / 1000 + 1, 2, 9);
-               recovery_cycle = 15 - IDE_IN(recovery_time * system_bus_clock() / 1000 + 1, 0, 15);
+       if (clk <= 33) {
+               act_cyc =  9 - IDE_IN(active_time   * clk / 1000 + 1, 2,  9);
+               rec_cyc = 15 - IDE_IN(recovery_time * clk / 1000 + 1, 0, 15);
        } else {
-               active_cycle =   8  - IDE_IN(active_time   * system_bus_clock() / 1000 + 1, 1, 8);
-               recovery_cycle = 18 - IDE_IN(recovery_time * system_bus_clock() / 1000 + 1, 3, 18);
+               act_cyc =  8 - IDE_IN(active_time   * clk / 1000 + 1, 1,  8);
+               rec_cyc = 18 - IDE_IN(recovery_time * clk / 1000 + 1, 3, 18);
        }
 
-       return((recovery_cycle<<4) | 0x08 | active_cycle);
+       return (rec_cyc << 4) | 0x08 | act_cyc;
 }
 
 /*
@@ -133,10 +132,13 @@ static u8 qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recovery
 
 static u8 qd6580_compute_timing (int active_time, int recovery_time)
 {
-       u8 active_cycle   = 17 - IDE_IN(active_time   * system_bus_clock() / 1000 + 1, 2, 17);
-       u8 recovery_cycle = 15 - IDE_IN(recovery_time * system_bus_clock() / 1000 + 1, 2, 15);
+       int clk = ide_vlb_clk ? ide_vlb_clk : system_bus_clock();
+       u8 act_cyc, rec_cyc;
+
+       act_cyc = 17 - IDE_IN(active_time   * clk / 1000 + 1, 2, 17);
+       rec_cyc = 15 - IDE_IN(recovery_time * clk / 1000 + 1, 2, 15);
 
-       return((recovery_cycle<<4) | active_cycle);
+       return (rec_cyc << 4) | act_cyc;
 }
 
 /*
@@ -317,10 +319,10 @@ static const struct ide_port_ops qd6580_port_ops = {
 };
 
 static const struct ide_port_info qd65xx_port_info __initdata = {
+       .name                   = DRV_NAME,
        .chipset                = ide_qd65xx,
        .host_flags             = IDE_HFLAG_IO_32BIT |
-                                 IDE_HFLAG_NO_DMA |
-                                 IDE_HFLAG_NO_AUTOTUNE,
+                                 IDE_HFLAG_NO_DMA,
        .pio_mask               = ATA_PIO4,
 };
 
@@ -334,7 +336,7 @@ static const struct ide_port_info qd65xx_port_info __initdata = {
 static int __init qd_probe(int base)
 {
        int rc;
-       u8 config, unit;
+       u8 config, unit, control;
        struct ide_port_info d = qd65xx_port_info;
 
        config = inb(QD_CONFIG_PORT);
@@ -347,13 +349,11 @@ static int __init qd_probe(int base)
        if (unit)
                d.host_flags |= IDE_HFLAG_QD_2ND_PORT;
 
-       if ((config & 0xf0) == QD_CONFIG_QD6500) {
-
+       switch (config & 0xf0) {
+       case QD_CONFIG_QD6500:
                if (qd_testreg(base))
                         return -ENODEV;        /* bad register */
 
-               /* qd6500 found */
-
                if (config & QD_CONFIG_DISABLED) {
                        printk(KERN_WARNING "qd6500 is disabled !\n");
                        return -ENODEV;
@@ -365,22 +365,12 @@ static int __init qd_probe(int base)
 
                d.port_ops = &qd6500_port_ops;
                d.host_flags |= IDE_HFLAG_SINGLE;
-
-               rc = ide_legacy_device_add(&d, (base << 8) | config);
-
-               return (rc == 0) ? 1 : rc;
-       }
-
-       if (((config & 0xf0) == QD_CONFIG_QD6580_A) ||
-           ((config & 0xf0) == QD_CONFIG_QD6580_B)) {
-
-               u8 control;
-
+               break;
+       case QD_CONFIG_QD6580_A:
+       case QD_CONFIG_QD6580_B:
                if (qd_testreg(base) || qd_testreg(base + 0x02))
                        return -ENODEV; /* bad registers */
 
-               /* qd6580 found */
-
                control = inb(QD_CONTROL_PORT);
 
                printk(KERN_NOTICE "qd6580 at %#x\n", base);
@@ -390,31 +380,25 @@ static int __init qd_probe(int base)
                outb(QD_DEF_CONTR, QD_CONTROL_PORT);
 
                d.port_ops = &qd6580_port_ops;
-
-               if (control & QD_CONTR_SEC_DISABLED) {
-                       /* secondary disabled */
-
-                       printk(KERN_INFO "qd6580: single IDE board\n");
-
+               if (control & QD_CONTR_SEC_DISABLED)
                        d.host_flags |= IDE_HFLAG_SINGLE;
 
-                       rc = ide_legacy_device_add(&d, (base << 8) | config);
+               printk(KERN_INFO "qd6580: %s IDE board\n",
+                       (control & QD_CONTR_SEC_DISABLED) ? "single" : "dual");
+               break;
+       default:
+               return -ENODEV;
+       }
 
-                       return (rc == 0) ? 1 : rc;
-               } else {
-                       /* secondary enabled */
-                       printk(KERN_INFO "qd6580: dual IDE board\n");
+       rc = ide_legacy_device_add(&d, (base << 8) | config);
 
-                       rc = ide_legacy_device_add(&d, (base << 8) | config);
+       if (d.host_flags & IDE_HFLAG_SINGLE)
+               return (rc == 0) ? 1 : rc;
 
-                       return rc; /* no other qd65xx possible */
-               }
-       }
-       /* no qd65xx found */
-       return -ENODEV;
+       return rc;
 }
 
-int probe_qd65xx = 0;
+static int probe_qd65xx;
 
 module_param_named(probe, probe_qd65xx, bool, 0);
 MODULE_PARM_DESC(probe, "probe for QD65xx chipsets");