Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[deliverable/linux.git] / drivers / ide / pci / hpt34x.c
index 924eaa3a5708890e592dce1d7d130b769c37f25b..218852aaf22aa11329dae8d320f3b6be1ba091c2 100644 (file)
 
 #define HPT343_DEBUG_DRIVE_INFO                0
 
-static u8 hpt34x_ratemask (ide_drive_t *drive)
-{
-       return 1;
-}
-
-static int hpt34x_tune_chipset (ide_drive_t *drive, u8 xferspeed)
+static void hpt34x_set_mode(ide_drive_t *drive, const u8 speed)
 {
        struct pci_dev *dev     = HWIF(drive)->pci_dev;
-       u8 speed        = ide_rate_filter(hpt34x_ratemask(drive), xferspeed);
        u32 reg1= 0, tmp1 = 0, reg2 = 0, tmp2 = 0;
        u8                      hi_speed, lo_speed;
 
@@ -79,47 +73,22 @@ static int hpt34x_tune_chipset (ide_drive_t *drive, u8 xferspeed)
                drive->dn, reg1, tmp1, reg2, tmp2,
                hi_speed, lo_speed);
 #endif /* HPT343_DEBUG_DRIVE_INFO */
-
-       return(ide_config_drive_speed(drive, speed));
 }
 
-static void hpt34x_tune_drive (ide_drive_t *drive, u8 pio)
+static void hpt34x_set_pio_mode(ide_drive_t *drive, const u8 pio)
 {
-       pio = ide_get_best_pio_mode(drive, pio, 5, NULL);
-       (void) hpt34x_tune_chipset(drive, (XFER_PIO_0 + pio));
-}
-
-/*
- * This allows the configuration of ide_pci chipset registers
- * for cards that learn about the drive's UDMA, DMA, PIO capabilities
- * after the drive is reported by the OS.  Initially for designed for
- * HPT343 UDMA chipset by HighPoint|Triones Technologies, Inc.
- */
-
-static int config_chipset_for_dma (ide_drive_t *drive)
-{
-       u8 speed = ide_dma_speed(drive, hpt34x_ratemask(drive));
-
-       if (!(speed))
-               return 0;
-
-       (void) hpt34x_tune_chipset(drive, speed);
-       return ide_dma_enable(drive);
+       hpt34x_set_mode(drive, XFER_PIO_0 + pio);
 }
 
 static int hpt34x_config_drive_xfer_rate (ide_drive_t *drive)
 {
        drive->init_speed = 0;
 
-       if (ide_use_dma(drive) && config_chipset_for_dma(drive))
-#ifndef CONFIG_HPT34X_AUTODMA
+       if (ide_tune_dma(drive))
                return -1;
-#else
-               return 0;
-#endif
 
        if (ide_use_fast_pio(drive))
-               hpt34x_tune_drive(drive, 255);
+               ide_set_max_pio(drive);
 
        return -1;
 }
@@ -143,17 +112,10 @@ static unsigned int __devinit init_chipset_hpt34x(struct pci_dev *dev, const cha
        pci_write_config_byte(dev, HPT34X_PCI_INIT_REG, 0x00);
        pci_read_config_word(dev, PCI_COMMAND, &cmd);
 
-       if (cmd & PCI_COMMAND_MEMORY) {
-               if (pci_resource_start(dev, PCI_ROM_RESOURCE)) {
-                       pci_write_config_dword(dev, PCI_ROM_ADDRESS,
-                               dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
-                       printk(KERN_INFO "HPT345: ROM enabled at 0x%08lx\n",
-                               (unsigned long)dev->resource[PCI_ROM_RESOURCE].start);
-               }
+       if (cmd & PCI_COMMAND_MEMORY)
                pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xF0);
-       } else {
+       else
                pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20);
-       }
 
        /*
         * Since 20-23 can be assigned and are R/W, we correct them.
@@ -180,8 +142,9 @@ static void __devinit init_hwif_hpt34x(ide_hwif_t *hwif)
 
        hwif->autodma = 0;
 
-       hwif->tuneproc = &hpt34x_tune_drive;
-       hwif->speedproc = &hpt34x_tune_chipset;
+       hwif->set_pio_mode = &hpt34x_set_pio_mode;
+       hwif->set_dma_mode = &hpt34x_set_mode;
+
        hwif->drives[0].autotune = 1;
        hwif->drives[1].autotune = 1;
 
@@ -190,9 +153,11 @@ static void __devinit init_hwif_hpt34x(ide_hwif_t *hwif)
        if (!hwif->dma_base)
                return;
 
+#ifdef CONFIG_HPT34X_AUTODMA
        hwif->ultra_mask = 0x07;
        hwif->mwdma_mask = 0x07;
        hwif->swdma_mask = 0x07;
+#endif
 
        hwif->ide_dma_check = &hpt34x_config_drive_xfer_rate;
        if (!noautodma)
@@ -205,10 +170,10 @@ static ide_pci_device_t hpt34x_chipset __devinitdata = {
        .name           = "HPT34X",
        .init_chipset   = init_chipset_hpt34x,
        .init_hwif      = init_hwif_hpt34x,
-       .channels       = 2,
        .autodma        = NOAUTODMA,
        .bootable       = NEVER_BOARD,
-       .extra          = 16
+       .extra          = 16,
+       .pio_mask       = ATA_PIO5,
 };
 
 static int __devinit hpt34x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
This page took 0.031383 seconds and 5 git commands to generate.