Merge branch 'next' into for-linus-3.0
[linux-2.6.git] / arch / arm / mach-ep93xx / core.c
index f4b25bf..dd87a82 100644 (file)
@@ -216,8 +216,8 @@ void ep93xx_devcfg_set_clear(unsigned int set_bits, unsigned int clear_bits)
        spin_lock_irqsave(&syscon_swlock, flags);
 
        val = __raw_readl(EP93XX_SYSCON_DEVCFG);
-       val |= set_bits;
        val &= ~clear_bits;
+       val |= set_bits;
        __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK);
        __raw_writel(val, EP93XX_SYSCON_DEVCFG);
 
@@ -251,9 +251,9 @@ static void ep93xx_uart_set_mctrl(struct amba_device *dev,
        unsigned int mcr;
 
        mcr = 0;
-       if (!(mctrl & TIOCM_RTS))
+       if (mctrl & TIOCM_RTS)
                mcr |= 2;
-       if (!(mctrl & TIOCM_DTR))
+       if (mctrl & TIOCM_DTR)
                mcr |= 1;
 
        __raw_writel(mcr, base + EP93XX_UART_MCR_OFFSET);
@@ -402,11 +402,15 @@ static struct resource ep93xx_eth_resource[] = {
        }
 };
 
+static u64 ep93xx_eth_dma_mask = DMA_BIT_MASK(32);
+
 static struct platform_device ep93xx_eth_device = {
        .name           = "ep93xx-eth",
        .id             = -1,
        .dev            = {
-               .platform_data  = &ep93xx_eth_data,
+               .platform_data          = &ep93xx_eth_data,
+               .coherent_dma_mask      = DMA_BIT_MASK(32),
+               .dma_mask               = &ep93xx_eth_dma_mask,
        },
        .num_resources  = ARRAY_SIZE(ep93xx_eth_resource),
        .resource       = ep93xx_eth_resource,
@@ -488,11 +492,15 @@ static struct resource ep93xx_spi_resources[] = {
        },
 };
 
+static u64 ep93xx_spi_dma_mask = DMA_BIT_MASK(32);
+
 static struct platform_device ep93xx_spi_device = {
        .name           = "ep93xx-spi",
        .id             = 0,
        .dev            = {
-               .platform_data = &ep93xx_spi_master_data,
+               .platform_data          = &ep93xx_spi_master_data,
+               .coherent_dma_mask      = DMA_BIT_MASK(32),
+               .dma_mask               = &ep93xx_spi_dma_mask,
        },
        .num_resources  = ARRAY_SIZE(ep93xx_spi_resources),
        .resource       = ep93xx_spi_resources,
@@ -758,6 +766,113 @@ void ep93xx_keypad_release_gpio(struct platform_device *pdev)
 }
 EXPORT_SYMBOL(ep93xx_keypad_release_gpio);
 
+/*************************************************************************
+ * EP93xx I2S audio peripheral handling
+ *************************************************************************/
+static struct resource ep93xx_i2s_resource[] = {
+       {
+               .start  = EP93XX_I2S_PHYS_BASE,
+               .end    = EP93XX_I2S_PHYS_BASE + 0x100 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device ep93xx_i2s_device = {
+       .name           = "ep93xx-i2s",
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(ep93xx_i2s_resource),
+       .resource       = ep93xx_i2s_resource,
+};
+
+static struct platform_device ep93xx_pcm_device = {
+       .name           = "ep93xx-pcm-audio",
+       .id             = -1,
+};
+
+void __init ep93xx_register_i2s(void)
+{
+       platform_device_register(&ep93xx_i2s_device);
+       platform_device_register(&ep93xx_pcm_device);
+}
+
+#define EP93XX_SYSCON_DEVCFG_I2S_MASK  (EP93XX_SYSCON_DEVCFG_I2SONSSP | \
+                                        EP93XX_SYSCON_DEVCFG_I2SONAC97)
+
+#define EP93XX_I2SCLKDIV_MASK          (EP93XX_SYSCON_I2SCLKDIV_ORIDE | \
+                                        EP93XX_SYSCON_I2SCLKDIV_SPOL)
+
+int ep93xx_i2s_acquire(unsigned i2s_pins, unsigned i2s_config)
+{
+       unsigned val;
+
+       /* Sanity check */
+       if (i2s_pins & ~EP93XX_SYSCON_DEVCFG_I2S_MASK)
+               return -EINVAL;
+       if (i2s_config & ~EP93XX_I2SCLKDIV_MASK)
+               return -EINVAL;
+
+       /* Must have only one of I2SONSSP/I2SONAC97 set */
+       if ((i2s_pins & EP93XX_SYSCON_DEVCFG_I2SONSSP) ==
+           (i2s_pins & EP93XX_SYSCON_DEVCFG_I2SONAC97))
+               return -EINVAL;
+
+       ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_I2S_MASK);
+       ep93xx_devcfg_set_bits(i2s_pins);
+
+       /*
+        * This is potentially racy with the clock api for i2s_mclk, sclk and 
+        * lrclk. Since the i2s driver is the only user of those clocks we
+        * rely on it to prevent parallel use of this function and the 
+        * clock api for the i2s clocks.
+        */
+       val = __raw_readl(EP93XX_SYSCON_I2SCLKDIV);
+       val &= ~EP93XX_I2SCLKDIV_MASK;
+       val |= i2s_config;
+       ep93xx_syscon_swlocked_write(val, EP93XX_SYSCON_I2SCLKDIV);
+
+       return 0;
+}
+EXPORT_SYMBOL(ep93xx_i2s_acquire);
+
+void ep93xx_i2s_release(void)
+{
+       ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_I2S_MASK);
+}
+EXPORT_SYMBOL(ep93xx_i2s_release);
+
+/*************************************************************************
+ * EP93xx AC97 audio peripheral handling
+ *************************************************************************/
+static struct resource ep93xx_ac97_resources[] = {
+       {
+               .start  = EP93XX_AAC_PHYS_BASE,
+               .end    = EP93XX_AAC_PHYS_BASE + 0xac - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .start  = IRQ_EP93XX_AACINTR,
+               .end    = IRQ_EP93XX_AACINTR,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device ep93xx_ac97_device = {
+       .name           = "ep93xx-ac97",
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(ep93xx_ac97_resources),
+       .resource       = ep93xx_ac97_resources,
+};
+
+void __init ep93xx_register_ac97(void)
+{
+       /*
+        * Make sure that the AC97 pins are not used by I2S.
+        */
+       ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_I2SONAC97);
+
+       platform_device_register(&ep93xx_ac97_device);
+       platform_device_register(&ep93xx_pcm_device);
+}
 
 extern void ep93xx_gpio_init(void);