crypto: vmac - Fix big-endian support
[safe/jmp/linux-2.6] / drivers / ide / amd74xx.c
index 69660a4..3747b25 100644 (file)
@@ -3,7 +3,7 @@
  * IDE driver for Linux.
  *
  * Copyright (c) 2000-2002 Vojtech Pavlik
- * Copyright (c) 2007-2008 Bartlomiej Zolnierkiewicz
+ * Copyright (c) 2007-2010 Bartlomiej Zolnierkiewicz
  *
  * Based on the work of:
  *      Andre Hedrick
@@ -70,7 +70,8 @@ static void amd_set_speed(struct pci_dev *dev, u8 dn, u8 udma_mask,
        default: return;
        }
 
-       pci_write_config_byte(dev, AMD_UDMA_TIMING + offset + (3 - dn), t);
+       if (timing->udma)
+               pci_write_config_byte(dev, AMD_UDMA_TIMING + offset + 3 - dn, t);
 }
 
 /*
@@ -78,14 +79,14 @@ static void amd_set_speed(struct pci_dev *dev, u8 dn, u8 udma_mask,
  * to a desired transfer mode.  It also can be called by upper layers.
  */
 
-static void amd_set_drive(ide_drive_t *drive, const u8 speed)
+static void amd_set_drive(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       ide_hwif_t *hwif = drive->hwif;
        struct pci_dev *dev = to_pci_dev(hwif->dev);
        ide_drive_t *peer = ide_get_pair_dev(drive);
        struct ide_timing t, p;
        int T, UT;
        u8 udma_mask = hwif->ultra_mask;
+       const u8 speed = drive->dma_mode;
 
        T = 1000000000 / amd_clock;
        UT = (udma_mask == ATA_UDMA2) ? T : (T / 2);
@@ -93,7 +94,7 @@ static void amd_set_drive(ide_drive_t *drive, const u8 speed)
        ide_timing_compute(drive, speed, &t, T, UT);
 
        if (peer) {
-               ide_timing_compute(peer, peer->current_speed, &p, T, UT);
+               ide_timing_compute(peer, peer->pio_mode, &p, T, UT);
                ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT);
        }
 
@@ -107,9 +108,10 @@ static void amd_set_drive(ide_drive_t *drive, const u8 speed)
  * amd_set_pio_mode() is a callback from upper layers for PIO-only tuning.
  */
 
-static void amd_set_pio_mode(ide_drive_t *drive, const u8 pio)
+static void amd_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
 {
-       amd_set_drive(drive, XFER_PIO_0 + pio);
+       drive->dma_mode = drive->pio_mode;
+       amd_set_drive(hwif, drive);
 }
 
 static void amd7409_cable_detect(struct pci_dev *dev)
@@ -140,7 +142,7 @@ static void amd7411_cable_detect(struct pci_dev *dev)
  * The initialization callback.  Initialize drive independent registers.
  */
 
-static unsigned int init_chipset_amd74xx(struct pci_dev *dev)
+static int init_chipset_amd74xx(struct pci_dev *dev)
 {
        u8 t = 0, offset = amd_offset(dev);
 
@@ -166,13 +168,13 @@ static unsigned int init_chipset_amd74xx(struct pci_dev *dev)
         * Check for broken FIFO support.
         */
        if (dev->vendor == PCI_VENDOR_ID_AMD &&
-           dev->vendor == PCI_DEVICE_ID_AMD_VIPER_7411)
+           dev->device == PCI_DEVICE_ID_AMD_VIPER_7411)
                t &= 0x0f;
        else
                t |= 0xf0;
        pci_write_config_byte(dev, AMD_IDE_CONFIG + offset, t);
 
-       return dev->irq;
+       return 0;
 }
 
 static u8 amd_cable_detect(ide_hwif_t *hwif)
@@ -183,14 +185,6 @@ static u8 amd_cable_detect(ide_hwif_t *hwif)
                return ATA_CBL_PATA40;
 }
 
-static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
-{
-       struct pci_dev *dev = to_pci_dev(hwif->dev);
-
-       if (hwif->irq == 0) /* 0 is bogus but will do for now */
-               hwif->irq = pci_get_legacy_ide_irq(dev, hwif->channel);
-}
-
 static const struct ide_port_ops amd_port_ops = {
        .set_pio_mode           = amd_set_pio_mode,
        .set_dma_mode           = amd_set_drive,
@@ -207,7 +201,6 @@ static const struct ide_port_ops amd_port_ops = {
        {                                                               \
                .name           = DRV_NAME,                             \
                .init_chipset   = init_chipset_amd74xx,                 \
-               .init_hwif      = init_hwif_amd74xx,                    \
                .enablebits     = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \
                .port_ops       = &amd_port_ops,                        \
                .host_flags     = IDE_HFLAGS_AMD,                       \
@@ -221,7 +214,6 @@ static const struct ide_port_ops amd_port_ops = {
        {                                                               \
                .name           = DRV_NAME,                             \
                .init_chipset   = init_chipset_amd74xx,                 \
-               .init_hwif      = init_hwif_amd74xx,                    \
                .enablebits     = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \
                .port_ops       = &amd_port_ops,                        \
                .host_flags     = IDE_HFLAGS_AMD,                       \
@@ -350,6 +342,6 @@ static void __exit amd74xx_ide_exit(void)
 module_init(amd74xx_ide_init);
 module_exit(amd74xx_ide_exit);
 
-MODULE_AUTHOR("Vojtech Pavlik");
+MODULE_AUTHOR("Vojtech Pavlik, Bartlomiej Zolnierkiewicz");
 MODULE_DESCRIPTION("AMD PCI IDE driver");
 MODULE_LICENSE("GPL");