libata: convert legacy PCI host handling to new init model
[powerpc.git] / drivers / ata / pata_hpt3x2n.c
index 58cfb2b..7832392 100644 (file)
@@ -25,7 +25,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME       "pata_hpt3x2n"
-#define DRV_VERSION    "0.3"
+#define DRV_VERSION    "0.3.3"
 
 enum {
        HPT_PCI_FAST    =       (1 << 31),
@@ -115,14 +115,13 @@ static u32 hpt3x2n_find_mode(struct ata_port *ap, int speed)
 }
 
 /**
- *     hpt3x2n_pre_reset       -       reset the hpt3x2n bus
- *     @ap: ATA port to reset
+ *     hpt3x2n_cable_detect    -       Detect the cable type
+ *     @ap: ATA port to detect on
  *
- *     Perform the initial reset handling for the 3x2n series controllers.
- *     Reset the hardware and state machine, obtain the cable type.
+ *     Return the cable type attached to this port
  */
 
-static int hpt3xn_pre_reset(struct ata_port *ap)
+static int hpt3x2n_cable_detect(struct ata_port *ap)
 {
        u8 scr2, ata66;
        struct pci_dev *pdev = to_pci_dev(ap->host->dev);
@@ -135,15 +134,26 @@ static int hpt3xn_pre_reset(struct ata_port *ap)
        pci_write_config_byte(pdev, 0x5B, scr2);
 
        if (ata66 & (1 << ap->port_no))
-               ap->cbl = ATA_CBL_PATA40;
+               return ATA_CBL_PATA40;
        else
-               ap->cbl = ATA_CBL_PATA80;
+               return ATA_CBL_PATA80;
+}
+
+/**
+ *     hpt3x2n_pre_reset       -       reset the hpt3x2n bus
+ *     @ap: ATA port to reset
+ *
+ *     Perform the initial reset handling for the 3x2n series controllers.
+ *     Reset the hardware and state machine,
+ */
 
+static int hpt3xn_pre_reset(struct ata_port *ap)
+{
+       struct pci_dev *pdev = to_pci_dev(ap->host->dev);
        /* Reset the state machine */
        pci_write_config_byte(pdev, 0x50, 0x37);
        pci_write_config_byte(pdev, 0x54, 0x37);
        udelay(100);
-
        return ata_std_prereset(ap);
 }
 
@@ -263,26 +273,26 @@ static void hpt3x2n_bmdma_stop(struct ata_queued_cmd *qc)
 
 static void hpt3x2n_set_clock(struct ata_port *ap, int source)
 {
-       unsigned long bmdma = ap->ioaddr.bmdma_addr;
+       void __iomem *bmdma = ap->ioaddr.bmdma_addr;
 
        /* Tristate the bus */
-       outb(0x80, bmdma+0x73);
-       outb(0x80, bmdma+0x77);
+       iowrite8(0x80, bmdma+0x73);
+       iowrite8(0x80, bmdma+0x77);
 
        /* Switch clock and reset channels */
-       outb(source, bmdma+0x7B);
-       outb(0xC0, bmdma+0x79);
+       iowrite8(source, bmdma+0x7B);
+       iowrite8(0xC0, bmdma+0x79);
 
        /* Reset state machines */
-       outb(0x37, bmdma+0x70);
-       outb(0x37, bmdma+0x74);
+       iowrite8(0x37, bmdma+0x70);
+       iowrite8(0x37, bmdma+0x74);
 
        /* Complete reset */
-       outb(0x00, bmdma+0x79);
+       iowrite8(0x00, bmdma+0x79);
 
        /* Reconnect channels to bus */
-       outb(0x00, bmdma+0x73);
-       outb(0x00, bmdma+0x77);
+       iowrite8(0x00, bmdma+0x73);
+       iowrite8(0x00, bmdma+0x77);
 }
 
 /* Check if our partner interface is busy */
@@ -297,11 +307,11 @@ static int hpt3x2n_pair_idle(struct ata_port *ap)
        return 0;
 }
 
-static int hpt3x2n_use_dpll(struct ata_port *ap, int reading)
+static int hpt3x2n_use_dpll(struct ata_port *ap, int writing)
 {
        long flags = (long)ap->host->private_data;
        /* See if we should use the DPLL */
-       if (reading == 0)
+       if (writing)
                return USE_DPLL;        /* Needed for write */
        if (flags & PCI66)
                return USE_DPLL;        /* Needed at 66Mhz */
@@ -334,13 +344,13 @@ static struct scsi_host_template hpt3x2n_sht = {
        .can_queue              = ATA_DEF_QUEUE,
        .this_id                = ATA_SHT_THIS_ID,
        .sg_tablesize           = LIBATA_MAX_PRD,
-       .max_sectors            = ATA_MAX_SECTORS,
        .cmd_per_lun            = ATA_SHT_CMD_PER_LUN,
        .emulated               = ATA_SHT_EMULATED,
        .use_clustering         = ATA_SHT_USE_CLUSTERING,
        .proc_name              = DRV_NAME,
        .dma_boundary           = ATA_DMA_BOUNDARY,
        .slave_configure        = ata_scsi_slave_config,
+       .slave_destroy          = ata_scsi_slave_destroy,
        .bios_param             = ata_std_bios_param,
 };
 
@@ -364,6 +374,7 @@ static struct ata_port_operations hpt3x2n_port_ops = {
        .thaw           = ata_bmdma_thaw,
        .error_handler  = hpt3x2n_error_handler,
        .post_internal_cmd = ata_bmdma_post_internal_cmd,
+       .cable_detect   = hpt3x2n_cable_detect,
 
        .bmdma_setup    = ata_bmdma_setup,
        .bmdma_start    = ata_bmdma_start,
@@ -373,14 +384,14 @@ static struct ata_port_operations hpt3x2n_port_ops = {
        .qc_prep        = ata_qc_prep,
        .qc_issue       = hpt3x2n_qc_issue_prot,
 
-       .data_xfer      = ata_pio_data_xfer,
+       .data_xfer      = ata_data_xfer,
 
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+       .irq_ack        = ata_irq_ack,
 
        .port_start     = ata_port_start,
-       .port_stop      = ata_port_stop,
-       .host_stop      = ata_host_stop
 };
 
 /**