ide: remove obsoleted "idebus=" kernel parameter
[linux-2.6-block.git] / drivers / ide / legacy / ht6560b.c
index 02d12c74764a6a6fcd38935f8cbba4286398b4f7..dd6dfb32e85303b4342be96afddddd4584cf33f4 100644 (file)
  *                      "Prefetch" mode bit OFF for ide disks and
  *                      ON for anything else.
  *
+ *  Version 0.08        Need to force prefetch for CDs and other non-disk
+ *                      devices. (not sure which devices exactly need
+ *                      prefetch)
  *
  *  HT-6560B EIDE-controller support
  *  To activate controller support use kernel parameter "ide0=ht6560b".
  *  Use hdparm utility to enable PIO mode support.
  *
  *  Author:    Mikko Ala-Fossi            <maf@iki.fi>
- *             Jan Evert van Grootheest   <janevert@iae.nl>
+ *             Jan Evert van Grootheest   <janevert@caiway.nl>
  *
  *  Try:  http://www.maf.iki.fi/~maf/ht6560b/
  */
 
-#define HT6560B_VERSION "v0.07"
+#define DRV_NAME       "ht6560b"
+#define HT6560B_VERSION "v0.08"
 
 #include <linux/module.h>
 #include <linux/types.h>
@@ -79,7 +83,7 @@
  * out how they setup those cycle time interfacing values, as they at Holtek
  * call them. IDESETUP.COM that is supplied with the drivers figures out
  * optimal values and fetches those values to drivers. I found out that
- * they use IDE_SELECT_REG to fetch timings to the ide board right after
+ * they use Select register to fetch timings to the ide board right after
  * interface switching. After that it was quite easy to add code to
  * ht6560b.c.
  *
  */
 static void ht6560b_selectproc (ide_drive_t *drive)
 {
+       ide_hwif_t *hwif = drive->hwif;
        unsigned long flags;
        static u8 current_select = 0;
        static u8 current_timing = 0;
        u8 select, timing;
        
        local_irq_save(flags);
-       
+
        select = HT_CONFIG(drive);
        timing = HT_TIMING(drive);
-       
+
+       /*
+        * Need to enforce prefetch sometimes because otherwise
+        * it'll hang (hard).
+        */
+       if (drive->media != ide_disk || !drive->present)
+               select |= HT_PREFETCH_MODE;
+
        if (select != current_select || timing != current_timing) {
                current_select = select;
                current_timing = timing;
-               if (drive->media != ide_disk || !drive->present)
-                       select |= HT_PREFETCH_MODE;
                (void)inb(HT_CONFIG_PORT);
                (void)inb(HT_CONFIG_PORT);
                (void)inb(HT_CONFIG_PORT);
@@ -147,8 +157,8 @@ static void ht6560b_selectproc (ide_drive_t *drive)
                /*
                 * Set timing for this drive:
                 */
-               outb(timing, IDE_SELECT_REG);
-               (void)inb(IDE_STATUS_REG);
+               outb(timing, hwif->io_ports.device_addr);
+               (void)inb(hwif->io_ports.status_addr);
 #ifdef DEBUG
                printk("ht6560b: %s: select=%#x timing=%#x\n",
                        drive->name, select, timing);
@@ -185,14 +195,15 @@ static int __init try_to_init_ht6560b(void)
         * Ht6560b autodetected
         */
        outb(HT_CONFIG_DEFAULT, HT_CONFIG_PORT);
-       outb(HT_TIMING_DEFAULT, 0x1f6);  /* IDE_SELECT_REG */
-       (void) inb(0x1f7);               /* IDE_STATUS_REG */
-       
-       printk("\nht6560b " HT6560B_VERSION
+       outb(HT_TIMING_DEFAULT, 0x1f6); /* Select register */
+       (void)inb(0x1f7);               /* Status register */
+
+       printk("ht6560b " HT6560B_VERSION
               ": chipset detected and initialized"
 #ifdef DEBUG
               " with debug enabled"
 #endif
+              "\n"
                );
        return 1;
 }
@@ -201,8 +212,8 @@ static u8 ht_pio2timings(ide_drive_t *drive, const u8 pio)
 {
        int active_time, recovery_time;
        int active_cycles, recovery_cycles;
-       int bus_speed = system_bus_clock();
-       
+       int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50;
+
         if (pio) {
                unsigned int cycle_time;
 
@@ -312,54 +323,44 @@ static void __init ht6560b_port_init_devs(ide_hwif_t *hwif)
        hwif->drives[1].drive_data = t;
 }
 
-int probe_ht6560b = 0;
+static int probe_ht6560b;
 
 module_param_named(probe, probe_ht6560b, bool, 0);
 MODULE_PARM_DESC(probe, "probe for HT6560B chipset");
 
+static const struct ide_port_ops ht6560b_port_ops = {
+       .port_init_devs         = ht6560b_port_init_devs,
+       .set_pio_mode           = ht6560b_set_pio_mode,
+       .selectproc             = ht6560b_selectproc,
+};
+
 static const struct ide_port_info ht6560b_port_info __initdata = {
+       .name                   = DRV_NAME,
        .chipset                = ide_ht6560b,
+       .port_ops               = &ht6560b_port_ops,
        .host_flags             = IDE_HFLAG_SERIALIZE | /* is this needed? */
                                  IDE_HFLAG_NO_DMA |
-                                 IDE_HFLAG_NO_AUTOTUNE |
                                  IDE_HFLAG_ABUSE_PREFETCH,
-       .pio_mask               = ATA_PIO5,
+       .pio_mask               = ATA_PIO4,
 };
 
 static int __init ht6560b_init(void)
 {
-       ide_hwif_t *hwif, *mate;
-       static u8 idx[4] = { 0, 1, 0xff, 0xff };
-
        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__);
+                       __func__);
                return -ENODEV;
        }
 
        if (!try_to_init_ht6560b()) {
-               printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__);
+               printk(KERN_NOTICE "%s: HBA not found\n", __func__);
                goto release_region;
        }
 
-       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->port_init_devs = ht6560b_port_init_devs;
-       mate->port_init_devs = ht6560b_port_init_devs;
-
-       ide_device_add(idx, &ht6560b_port_info);
-
-       return 0;
+       return ide_legacy_device_add(&ht6560b_port_info, 0);
 
 release_region:
        release_region(HT_CONFIG_PORT, 1);