netwave: convert to internal net_device_stats
[safe/jmp/linux-2.6] / drivers / ata / pata_bf54x.c
index 9ab8973..1050fed 100644 (file)
@@ -356,7 +356,6 @@ static void bfin_set_piomode(struct ata_port *ap, struct ata_device *adev)
  *     bfin_set_dmamode - Initialize host controller PATA DMA timings
  *     @ap: Port whose timings we are configuring
  *     @adev: um
- *     @udma: udma mode, 0 - 6
  *
  *     Set UDMA mode for device.
  *
@@ -911,7 +910,10 @@ static void bfin_bmdma_start(struct ata_queued_cmd *qc)
        /* Reset all transfer count */
        ATAPI_SET_CONTROL(base, ATAPI_GET_CONTROL(base) | TFRCNT_RST);
 
-               /* Set transfer length to buffer len */
+       /* Set ATAPI state machine contorl in terminate sequence */
+       ATAPI_SET_CONTROL(base, ATAPI_GET_CONTROL(base) | END_ON_TERM);
+
+       /* Set transfer length to buffer len */
        for_each_sg(qc->sg, sg, qc->n_elem, si) {
                ATAPI_SET_XFER_LEN(base, (sg_dma_len(sg) >> 1));
        }
@@ -1008,7 +1010,7 @@ static void bfin_bus_post_reset(struct ata_port *ap, unsigned int devmask)
        void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr;
        unsigned int dev0 = devmask & (1 << 0);
        unsigned int dev1 = devmask & (1 << 1);
-       unsigned long timeout;
+       unsigned long deadline;
 
        /* if device 0 was found in ata_devchk, wait for its
         * BSY bit to clear
@@ -1019,7 +1021,7 @@ static void bfin_bus_post_reset(struct ata_port *ap, unsigned int devmask)
        /* if device 1 was found in ata_devchk, wait for
         * register access, then wait for BSY to clear
         */
-       timeout = jiffies + ATA_TMOUT_BOOT;
+       deadline = ata_deadline(jiffies, ATA_TMOUT_BOOT);
        while (dev1) {
                u8 nsect, lbal;
 
@@ -1028,7 +1030,7 @@ static void bfin_bus_post_reset(struct ata_port *ap, unsigned int devmask)
                lbal = read_atapi_register(base, ATA_REG_LBAL);
                if ((nsect == 1) && (lbal == 1))
                        break;
-               if (time_after(jiffies, timeout)) {
+               if (time_after(jiffies, deadline)) {
                        dev1 = 0;
                        break;
                }
@@ -1629,6 +1631,8 @@ static int __devinit bfin_atapi_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
+       dev_set_drvdata(&pdev->dev, host);
+
        return 0;
 }
 
@@ -1645,6 +1649,7 @@ static int __devexit bfin_atapi_remove(struct platform_device *pdev)
        struct ata_host *host = dev_get_drvdata(dev);
 
        ata_host_detach(host);
+       dev_set_drvdata(&pdev->dev, NULL);
 
        peripheral_free_list(atapi_io_port);
 
@@ -1652,27 +1657,44 @@ static int __devexit bfin_atapi_remove(struct platform_device *pdev)
 }
 
 #ifdef CONFIG_PM
-int bfin_atapi_suspend(struct platform_device *pdev, pm_message_t state)
+static int bfin_atapi_suspend(struct platform_device *pdev, pm_message_t state)
 {
-       return 0;
+       struct ata_host *host = dev_get_drvdata(&pdev->dev);
+       if (host)
+               return ata_host_suspend(host, state);
+       else
+               return 0;
 }
 
-int bfin_atapi_resume(struct platform_device *pdev)
+static int bfin_atapi_resume(struct platform_device *pdev)
 {
+       struct ata_host *host = dev_get_drvdata(&pdev->dev);
+       int ret;
+
+       if (host) {
+               ret = bfin_reset_controller(host);
+               if (ret) {
+                       printk(KERN_ERR DRV_NAME ": Error during HW init\n");
+                       return ret;
+               }
+               ata_host_resume(host);
+       }
+
        return 0;
 }
+#else
+#define bfin_atapi_suspend NULL
+#define bfin_atapi_resume NULL
 #endif
 
 static struct platform_driver bfin_atapi_driver = {
        .probe                  = bfin_atapi_probe,
        .remove                 = __devexit_p(bfin_atapi_remove),
+       .suspend                = bfin_atapi_suspend,
+       .resume                 = bfin_atapi_resume,
        .driver = {
                .name           = DRV_NAME,
                .owner          = THIS_MODULE,
-#ifdef CONFIG_PM
-               .suspend        = bfin_atapi_suspend,
-               .resume         = bfin_atapi_resume,
-#endif
        },
 };