[ARM] 5210/2: AFEB9260: board support
[safe/jmp/linux-2.6] / arch / arm / mach-pxa / ssp.c
index b6d37fa..9bd93c5 100644 (file)
  *  IO-based SSP applications and allows easy port setup for DMA access.
  *
  *  Author: Liam Girdwood <liam.girdwood@wolfsonmicro.com>
- *
- *  Revision history:
- *   22nd Aug 2003 Initial version.
- *   20th Dec 2004 Added ssp_config for changing port config without
- *                 closing the port.
- *    4th Aug 2005 Added option to disable irq handler registration and
- *                 cleaned up irq and clock detection.
  */
 
 #include <linux/module.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/hardware.h>
-#include <asm/arch/ssp.h>
-#include <asm/arch/pxa-regs.h>
-#include <asm/arch/regs-ssp.h>
+#include <mach/hardware.h>
+#include <mach/ssp.h>
+#include <mach/pxa-regs.h>
+#include <mach/regs-ssp.h>
 
 #define TIMEOUT 100000
 
 static irqreturn_t ssp_interrupt(int irq, void *dev_id)
 {
-       struct ssp_dev *dev = (struct ssp_dev*) dev_id;
+       struct ssp_dev *dev = dev_id;
        struct ssp_device *ssp = dev->ssp;
        unsigned int status;
 
@@ -138,6 +131,16 @@ int ssp_flush(struct ssp_dev *dev)
        struct ssp_device *ssp = dev->ssp;
        int timeout = TIMEOUT * 2;
 
+       /* ensure TX FIFO is empty instead of not full */
+       if (cpu_is_pxa3xx()) {
+               while (__raw_readl(ssp->mmio_base + SSSR) & 0xf00) {
+                       if (!--timeout)
+                               return -ETIMEDOUT;
+                       cpu_relax();
+               }
+               timeout = TIMEOUT * 2;
+       }
+
        do {
                while (__raw_readl(ssp->mmio_base + SSSR) & SSSR_RNE) {
                        if (!--timeout)
@@ -275,7 +278,7 @@ int ssp_init(struct ssp_dev *dev, u32 port, u32 init_flags)
                        goto out_region;
                dev->irq = ssp->irq;
        } else
-               dev->irq = 0;
+               dev->irq = NO_IRQ;
 
        /* turn on SSP port clock */
        clk_enable(ssp->clk);
@@ -296,7 +299,8 @@ void ssp_exit(struct ssp_dev *dev)
        struct ssp_device *ssp = dev->ssp;
 
        ssp_disable(dev);
-       free_irq(dev->irq, dev);
+       if (dev->irq != NO_IRQ)
+               free_irq(dev->irq, dev);
        clk_disable(ssp->clk);
        ssp_free(ssp);
 }
@@ -320,7 +324,7 @@ struct ssp_device *ssp_request(int port, const char *label)
 
        mutex_unlock(&ssp_lock);
 
-       if (ssp->port_id != port)
+       if (&ssp->node == &ssp_list)
                return NULL;
 
        return ssp;
@@ -350,6 +354,7 @@ static int __devinit ssp_probe(struct platform_device *pdev, int type)
                dev_err(&pdev->dev, "failed to allocate memory");
                return -ENOMEM;
        }
+       ssp->pdev = pdev;
 
        ssp->clk = clk_get(&pdev->dev, "SSPCLK");
        if (IS_ERR(ssp->clk)) {
@@ -524,7 +529,7 @@ static void __exit pxa_ssp_exit(void)
        platform_driver_unregister(&pxa27x_ssp_driver);
 }
 
-module_init(pxa_ssp_init);
+arch_initcall(pxa_ssp_init);
 module_exit(pxa_ssp_exit);
 
 EXPORT_SYMBOL(ssp_write_word);