]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/legacy/ali14xx.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-fixes-2.6
[linux-2.6-omap-h63xx.git] / drivers / ide / legacy / ali14xx.c
index bc8b1f8de614d6aef0ae6ab5fd1beaacc13b05d8..4ec19737f3c5356e88e00403714e0afa482bc3f4 100644 (file)
@@ -49,6 +49,8 @@
 
 #include <asm/io.h>
 
+#define DRV_NAME "ali14xx"
+
 /* port addresses for auto-detection */
 #define ALI_NUM_PORTS 4
 static const int ports[ALI_NUM_PORTS] __initdata =
@@ -86,7 +88,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 +97,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);
@@ -114,11 +116,12 @@ static void ali14xx_set_pio_mode(ide_drive_t *drive, const u8 pio)
        int time1, time2;
        u8 param1, param2, param3, param4;
        unsigned long flags;
-       int bus_speed = system_bus_clock();
+       int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50;
+       struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
 
        /* calculate timing, according to PIO mode */
        time1 = ide_pio_cycle_time(drive, pio);
-       time2 = ide_pio_timings[pio].active_time;
+       time2 = t->active;
        param3 = param1 = (time2 * bus_speed + 999) / 1000;
        param4 = param2 = (time1 * bus_speed + 999) / 1000 - param1;
        if (pio < 3) {
@@ -143,7 +146,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 +178,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;
@@ -191,17 +195,20 @@ static int __init initRegisters (void) {
        return t;
 }
 
+static const struct ide_port_ops ali14xx_port_ops = {
+       .set_pio_mode           = ali14xx_set_pio_mode,
+};
+
 static const struct ide_port_info ali14xx_port_info = {
+       .name                   = DRV_NAME,
        .chipset                = ide_ali14xx,
-       .host_flags             = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE,
+       .port_ops               = &ali14xx_port_ops,
+       .host_flags             = IDE_HFLAG_NO_DMA,
        .pio_mask               = ATA_PIO4,
 };
 
 static int __init ali14xx_probe(void)
 {
-       static u8 idx[4] = { 0, 1, 0xff, 0xff };
-       hw_regs_t hw[2];
-
        printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n",
                          basePort, regOn);
 
@@ -211,26 +218,10 @@ static int __init ali14xx_probe(void)
                return 1;
        }
 
-       memset(&hw, 0, sizeof(hw));
-
-       ide_std_init_ports(&hw[0], 0x1f0, 0x3f6);
-       hw[0].irq = 14;
-
-       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]);
-
-       ide_hwifs[0].set_pio_mode = &ali14xx_set_pio_mode;
-       ide_hwifs[1].set_pio_mode = &ali14xx_set_pio_mode;
-
-       ide_device_add(idx, &ali14xx_port_info);
-
-       return 0;
+       return ide_legacy_device_add(&ali14xx_port_info, 0);
 }
 
-int probe_ali14xx = 0;
+static int probe_ali14xx;
 
 module_param_named(probe, probe_ali14xx, bool, 0);
 MODULE_PARM_DESC(probe, "probe for ALI M14xx chipsets");