Merge branch 'for-linus' of git://oss.sgi.com:8090/xfs/xfs-2.6
[sfrench/cifs-2.6.git] / drivers / ata / pata_pcmcia.c
index fd36099428a45cbf85b84a46d457bcef57a56209..3e7f6a9da28bd941965c1d5fd887be1054347a7c 100644 (file)
@@ -42,7 +42,7 @@
 
 
 #define DRV_NAME "pata_pcmcia"
-#define DRV_VERSION "0.3.2"
+#define DRV_VERSION "0.3.3"
 
 /*
  *     Private data structure to glue stuff together
@@ -86,6 +86,47 @@ static int pcmcia_set_mode(struct ata_link *link, struct ata_device **r_failed_d
        return ata_do_set_mode(link, r_failed_dev);
 }
 
+/**
+ *     pcmcia_set_mode_8bit    -       PCMCIA specific mode setup
+ *     @link: link
+ *     @r_failed_dev: Return pointer for failed device
+ *
+ *     For the simple emulated 8bit stuff the less we do the better.
+ */
+
+static int pcmcia_set_mode_8bit(struct ata_link *link,
+                               struct ata_device **r_failed_dev)
+{
+       return 0;
+}
+
+/**
+ *     ata_data_xfer_8bit       -      Transfer data by 8bit PIO
+ *     @dev: device to target
+ *     @buf: data buffer
+ *     @buflen: buffer length
+ *     @rw: read/write
+ *
+ *     Transfer data from/to the device data register by 8 bit PIO.
+ *
+ *     LOCKING:
+ *     Inherited from caller.
+ */
+
+static unsigned int ata_data_xfer_8bit(struct ata_device *dev,
+                               unsigned char *buf, unsigned int buflen, int rw)
+{
+       struct ata_port *ap = dev->link->ap;
+
+       if (rw == READ)
+               ioread8_rep(ap->ioaddr.data_addr, buf, buflen);
+       else
+               iowrite8_rep(ap->ioaddr.data_addr, buf, buflen);
+
+       return buflen;
+}
+
+
 static struct scsi_host_template pcmcia_sht = {
        .module                 = THIS_MODULE,
        .name                   = DRV_NAME,
@@ -129,6 +170,31 @@ static struct ata_port_operations pcmcia_port_ops = {
        .port_start     = ata_sff_port_start,
 };
 
+static struct ata_port_operations pcmcia_8bit_port_ops = {
+       .set_mode       = pcmcia_set_mode_8bit,
+       .tf_load        = ata_tf_load,
+       .tf_read        = ata_tf_read,
+       .check_status   = ata_check_status,
+       .exec_command   = ata_exec_command,
+       .dev_select     = ata_std_dev_select,
+
+       .freeze         = ata_bmdma_freeze,
+       .thaw           = ata_bmdma_thaw,
+       .error_handler  = ata_bmdma_error_handler,
+       .post_internal_cmd = ata_bmdma_post_internal_cmd,
+       .cable_detect   = ata_cable_40wire,
+
+       .qc_prep        = ata_qc_prep,
+       .qc_issue       = ata_qc_issue_prot,
+
+       .data_xfer      = ata_data_xfer_8bit,
+
+       .irq_clear      = ata_bmdma_irq_clear,
+       .irq_on         = ata_irq_on,
+
+       .port_start     = ata_sff_port_start,
+};
+
 #define CS_CHECK(fn, ret) \
 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
@@ -153,9 +219,12 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
                cistpl_cftable_entry_t dflt;
        } *stk = NULL;
        cistpl_cftable_entry_t *cfg;
-       int pass, last_ret = 0, last_fn = 0, is_kme = 0, ret = -ENOMEM;
+       int pass, last_ret = 0, last_fn = 0, is_kme = 0, ret = -ENOMEM, p;
        unsigned long io_base, ctl_base;
        void __iomem *io_addr, *ctl_addr;
+       int n_ports = 1;
+
+       struct ata_port_operations *ops = &pcmcia_port_ops;
 
        info = kzalloc(sizeof(*info), GFP_KERNEL);
        if (info == NULL)
@@ -282,27 +351,32 @@ next_entry:
        /* FIXME: Could be more ports at base + 0x10 but we only deal with
           one right now */
        if (pdev->io.NumPorts1 >= 0x20)
-               printk(KERN_WARNING DRV_NAME ": second channel not yet supported.\n");
+               n_ports = 2;
 
+       if (pdev->manf_id == 0x0097 && pdev->card_id == 0x1620)
+               ops = &pcmcia_8bit_port_ops;
        /*
         *      Having done the PCMCIA plumbing the ATA side is relatively
         *      sane.
         */
        ret = -ENOMEM;
-       host = ata_host_alloc(&pdev->dev, 1);
+       host = ata_host_alloc(&pdev->dev, n_ports);
        if (!host)
                goto failed;
-       ap = host->ports[0];
 
-       ap->ops = &pcmcia_port_ops;
-       ap->pio_mask = 1;               /* ISA so PIO 0 cycles */
-       ap->flags |= ATA_FLAG_SLAVE_POSS;
-       ap->ioaddr.cmd_addr = io_addr;
-       ap->ioaddr.altstatus_addr = ctl_addr;
-       ap->ioaddr.ctl_addr = ctl_addr;
-       ata_std_ports(&ap->ioaddr);
+       for (p = 0; p < n_ports; p++) {
+               ap = host->ports[p];
 
-       ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx", io_base, ctl_base);
+               ap->ops = ops;
+               ap->pio_mask = 1;               /* ISA so PIO 0 cycles */
+               ap->flags |= ATA_FLAG_SLAVE_POSS;
+               ap->ioaddr.cmd_addr = io_addr + 0x10 * p;
+               ap->ioaddr.altstatus_addr = ctl_addr + 0x10 * p;
+               ap->ioaddr.ctl_addr = ctl_addr + 0x10 * p;
+               ata_std_ports(&ap->ioaddr);
+
+               ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx", io_base, ctl_base);
+       }
 
        /* activate */
        ret = ata_host_activate(host, pdev->irq.AssignedIRQ, ata_interrupt,
@@ -360,6 +434,7 @@ static struct pcmcia_device_id pcmcia_devices[] = {
        PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704),
        PCMCIA_DEVICE_MANF_CARD(0x0032, 0x2904),
        PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401),        /* SanDisk CFA */
+       PCMCIA_DEVICE_MANF_CARD(0x0097, 0x1620),        /* TI emulated */
        PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000),        /* Toshiba */
        PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d),
        PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000),        /* Samsung */