pata_sis: add mode_filter method for certain sis5513 chipsets
[linux-2.6.git] / drivers / ata / ahci_platform.c
index 42cdd73..c03277d 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/gfp.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/ahci_platform.h>
 #include "ahci.h"
 
-static int __init ahci_probe(struct platform_device *pdev)
-{
-       struct device *dev = &pdev->dev;
-       struct ahci_platform_data *pdata = dev->platform_data;
-       struct ata_port_info pi = {
+enum ahci_type {
+       AHCI,           /* standard platform ahci */
+       IMX53_AHCI,     /* ahci on i.mx53 */
+};
+
+static struct platform_device_id ahci_devtype[] = {
+       {
+               .name = "ahci",
+               .driver_data = AHCI,
+       }, {
+               .name = "imx53-ahci",
+               .driver_data = IMX53_AHCI,
+       }, {
+               /* sentinel */
+       }
+};
+MODULE_DEVICE_TABLE(platform, ahci_devtype);
+
+
+static const struct ata_port_info ahci_port_info[] = {
+       /* by features */
+       [AHCI] = {
                .flags          = AHCI_FLAG_COMMON,
                .pio_mask       = ATA_PIO4,
                .udma_mask      = ATA_UDMA6,
                .port_ops       = &ahci_ops,
-       };
+       },
+       [IMX53_AHCI] = {
+               .flags          = AHCI_FLAG_COMMON,
+               .pio_mask       = ATA_PIO4,
+               .udma_mask      = ATA_UDMA6,
+               .port_ops       = &ahci_pmp_retry_srst_ops,
+       },
+};
+
+static struct scsi_host_template ahci_platform_sht = {
+       AHCI_SHT("ahci_platform"),
+};
+
+static int __init ahci_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct ahci_platform_data *pdata = dev->platform_data;
+       const struct platform_device_id *id = platform_get_device_id(pdev);
+       struct ata_port_info pi = ahci_port_info[id->driver_data];
        const struct ata_port_info *ppi[] = { &pi, NULL };
        struct ahci_host_priv *hpriv;
        struct ata_host *host;
@@ -53,19 +89,13 @@ static int __init ahci_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       if (pdata && pdata->init) {
-               rc = pdata->init(dev);
-               if (rc)
-                       return rc;
-       }
-
        if (pdata && pdata->ata_port_info)
                pi = *pdata->ata_port_info;
 
        hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
        if (!hpriv) {
-               rc = -ENOMEM;
-               goto err0;
+               dev_err(dev, "can't alloc ahci_host_priv\n");
+               return -ENOMEM;
        }
 
        hpriv->flags |= (unsigned long)pi.private_data;
@@ -73,8 +103,19 @@ static int __init ahci_probe(struct platform_device *pdev)
        hpriv->mmio = devm_ioremap(dev, mem->start, resource_size(mem));
        if (!hpriv->mmio) {
                dev_err(dev, "can't map %pR\n", mem);
-               rc = -ENOMEM;
-               goto err0;
+               return -ENOMEM;
+       }
+
+       /*
+        * Some platforms might need to prepare for mmio region access,
+        * which could be done in the following init call. So, the mmio
+        * region shouldn't be accessed before init (if provided) has
+        * returned successfully.
+        */
+       if (pdata && pdata->init) {
+               rc = pdata->init(dev, hpriv->mmio);
+               if (rc)
+                       return rc;
        }
 
        ahci_save_initial_config(dev, hpriv,
@@ -119,12 +160,9 @@ static int __init ahci_probe(struct platform_device *pdev)
                ata_port_desc(ap, "mmio %pR", mem);
                ata_port_desc(ap, "port 0x%x", 0x100 + ap->port_no * 0x80);
 
-               /* set initial link pm policy */
-               ap->pm_policy = NOT_AVAILABLE;
-
                /* set enclosure management message type */
                if (ap->flags & ATA_FLAG_EM)
-                       ap->em_message_type = ahci_em_messages;
+                       ap->em_message_type = hpriv->em_msg_type;
 
                /* disabled/not-implemented port */
                if (!(hpriv->port_map & (1 << i)))
@@ -139,7 +177,7 @@ static int __init ahci_probe(struct platform_device *pdev)
        ahci_print_info(host, "platform");
 
        rc = ata_host_activate(host, irq, ahci_interrupt, IRQF_SHARED,
-                              &ahci_sht);
+                              &ahci_platform_sht);
        if (rc)
                goto err0;
 
@@ -165,12 +203,12 @@ static int __devexit ahci_remove(struct platform_device *pdev)
 }
 
 static struct platform_driver ahci_driver = {
-       .probe = ahci_probe,
        .remove = __devexit_p(ahci_remove),
        .driver = {
                .name = "ahci",
                .owner = THIS_MODULE,
        },
+       .id_table       = ahci_devtype,
 };
 
 static int __init ahci_init(void)