pata_hpt{37x,3x2n}: add debounce delay to cable detection methods
[safe/jmp/linux-2.6] / drivers / ata / pata_of_platform.c
index b7bc4e4..1f18ad9 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of_platform.h>
-#include <linux/pata_platform.h>
+#include <linux/ata_platform.h>
 
 static int __devinit pata_of_platform_probe(struct of_device *ofdev,
                                            const struct of_device_id *match)
@@ -34,16 +34,25 @@ static int __devinit pata_of_platform_probe(struct of_device *ofdev,
                return -EINVAL;
        }
 
-       ret = of_address_to_resource(dn, 1, &ctl_res);
-       if (ret) {
-               dev_err(&ofdev->dev, "can't get CTL address from "
-                       "device tree\n");
-               return -EINVAL;
+       if (of_device_is_compatible(dn, "electra-ide")) {
+               /* Altstatus is really at offset 0x3f6 from the primary window
+                * on electra-ide. Adjust ctl_res and io_res accordingly.
+                */
+               ctl_res = io_res;
+               ctl_res.start = ctl_res.start+0x3f6;
+               io_res.end = ctl_res.start-1;
+       } else {
+               ret = of_address_to_resource(dn, 1, &ctl_res);
+               if (ret) {
+                       dev_err(&ofdev->dev, "can't get CTL address from "
+                               "device tree\n");
+                       return -EINVAL;
+               }
        }
 
        ret = of_irq_to_resource(dn, 0, &irq_res);
        if (ret == NO_IRQ)
-               irq_res.start = irq_res.end = -1;
+               irq_res.start = irq_res.end = 0;
        else
                irq_res.flags = 0;
 
@@ -76,6 +85,7 @@ static int __devexit pata_of_platform_remove(struct of_device *ofdev)
 
 static struct of_device_id pata_of_platform_match[] = {
        { .compatible = "ata-generic", },
+       { .compatible = "electra-ide", },
        {},
 };
 MODULE_DEVICE_TABLE(of, pata_of_platform_match);