[ARM] 5525/1: AFEB9260: fix for MMC support
[safe/jmp/linux-2.6] / arch / arm / mach-pxa / pxa3xx.c
index 37b0721..b02d454 100644 (file)
 #include <linux/sysdev.h>
 
 #include <mach/hardware.h>
+#include <mach/gpio.h>
 #include <mach/pxa3xx-regs.h>
+#include <mach/reset.h>
 #include <mach/ohci.h>
 #include <mach/pm.h>
 #include <mach/dma.h>
 #include <mach/ssp.h>
+#include <mach/i2c.h>
 
 #include "generic.h"
 #include "devices.h"
@@ -109,6 +112,12 @@ unsigned int pxa3xx_get_memclk_frequency_10khz(void)
        return (clk / 10000);
 }
 
+void pxa3xx_clear_reset_status(unsigned int mask)
+{
+       /* RESET_STATUS_* has a 1:1 mapping with ARSR */
+       ARSR = mask;
+}
+
 /*
  * Return the current AC97 clock frequency.
  */
@@ -196,36 +205,71 @@ static const struct clkops clk_pout_ops = {
        .disable        = clk_pout_disable,
 };
 
-static struct clk pxa3xx_clks[] = {
-       {
-               .name           = "CLK_POUT",
-               .ops            = &clk_pout_ops,
-               .rate           = 13000000,
-               .delay          = 70,
-       },
+static void clk_dummy_enable(struct clk *clk)
+{
+}
 
-       PXA3xx_CK("LCDCLK",  LCD,    &clk_pxa3xx_hsio_ops, &pxa_device_fb.dev),
-       PXA3xx_CK("CAMCLK",  CAMERA, &clk_pxa3xx_hsio_ops, NULL),
-       PXA3xx_CK("AC97CLK", AC97,   &clk_pxa3xx_ac97_ops, NULL),
+static void clk_dummy_disable(struct clk *clk)
+{
+}
 
-       PXA3xx_CKEN("UARTCLK", FFUART, 14857000, 1, &pxa_device_ffuart.dev),
-       PXA3xx_CKEN("UARTCLK", BTUART, 14857000, 1, &pxa_device_btuart.dev),
-       PXA3xx_CKEN("UARTCLK", STUART, 14857000, 1, NULL),
+static const struct clkops clk_dummy_ops = {
+       .enable         = clk_dummy_enable,
+       .disable        = clk_dummy_disable,
+};
 
-       PXA3xx_CKEN("I2CCLK", I2C,  32842000, 0, &pxa_device_i2c.dev),
-       PXA3xx_CKEN("UDCCLK", UDC,  48000000, 5, &pxa27x_device_udc.dev),
-       PXA3xx_CKEN("USBCLK", USBH, 48000000, 0, &pxa27x_device_ohci.dev),
-       PXA3xx_CKEN("KBDCLK", KEYPAD,  32768, 0, &pxa27x_device_keypad.dev),
+static struct clk clk_pxa3xx_pout = {
+       .ops            = &clk_pout_ops,
+       .rate           = 13000000,
+       .delay          = 70,
+};
 
-       PXA3xx_CKEN("SSPCLK", SSP1, 13000000, 0, &pxa27x_device_ssp1.dev),
-       PXA3xx_CKEN("SSPCLK", SSP2, 13000000, 0, &pxa27x_device_ssp2.dev),
-       PXA3xx_CKEN("SSPCLK", SSP3, 13000000, 0, &pxa27x_device_ssp3.dev),
-       PXA3xx_CKEN("SSPCLK", SSP4, 13000000, 0, &pxa3xx_device_ssp4.dev),
-       PXA3xx_CKEN("PWMCLK", PWM0, 13000000, 0, &pxa27x_device_pwm0.dev),
-       PXA3xx_CKEN("PWMCLK", PWM1, 13000000, 0, &pxa27x_device_pwm1.dev),
+static struct clk clk_dummy = {
+       .ops            = &clk_dummy_ops,
+};
 
-       PXA3xx_CKEN("MMCCLK", MMC1, 19500000, 0, &pxa_device_mci.dev),
-       PXA3xx_CKEN("MMCCLK", MMC2, 19500000, 0, &pxa3xx_device_mci2.dev),
+static DEFINE_PXA3_CK(pxa3xx_lcd, LCD, &clk_pxa3xx_hsio_ops);
+static DEFINE_PXA3_CK(pxa3xx_camera, CAMERA, &clk_pxa3xx_hsio_ops);
+static DEFINE_PXA3_CK(pxa3xx_ac97, AC97, &clk_pxa3xx_ac97_ops);
+static DEFINE_PXA3_CKEN(pxa3xx_ffuart, FFUART, 14857000, 1);
+static DEFINE_PXA3_CKEN(pxa3xx_btuart, BTUART, 14857000, 1);
+static DEFINE_PXA3_CKEN(pxa3xx_stuart, STUART, 14857000, 1);
+static DEFINE_PXA3_CKEN(pxa3xx_i2c, I2C, 32842000, 0);
+static DEFINE_PXA3_CKEN(pxa3xx_udc, UDC, 48000000, 5);
+static DEFINE_PXA3_CKEN(pxa3xx_usbh, USBH, 48000000, 0);
+static DEFINE_PXA3_CKEN(pxa3xx_keypad, KEYPAD, 32768, 0);
+static DEFINE_PXA3_CKEN(pxa3xx_ssp1, SSP1, 13000000, 0);
+static DEFINE_PXA3_CKEN(pxa3xx_ssp2, SSP2, 13000000, 0);
+static DEFINE_PXA3_CKEN(pxa3xx_ssp3, SSP3, 13000000, 0);
+static DEFINE_PXA3_CKEN(pxa3xx_ssp4, SSP4, 13000000, 0);
+static DEFINE_PXA3_CKEN(pxa3xx_pwm0, PWM0, 13000000, 0);
+static DEFINE_PXA3_CKEN(pxa3xx_pwm1, PWM1, 13000000, 0);
+static DEFINE_PXA3_CKEN(pxa3xx_mmc1, MMC1, 19500000, 0);
+static DEFINE_PXA3_CKEN(pxa3xx_mmc2, MMC2, 19500000, 0);
+
+static struct clk_lookup pxa3xx_clkregs[] = {
+       INIT_CLKREG(&clk_pxa3xx_pout, NULL, "CLK_POUT"),
+       /* Power I2C clock is always on */
+       INIT_CLKREG(&clk_dummy, "pxa2xx-i2c.1", NULL),
+       INIT_CLKREG(&clk_pxa3xx_lcd, "pxa2xx-fb", NULL),
+       INIT_CLKREG(&clk_pxa3xx_camera, NULL, "CAMCLK"),
+       INIT_CLKREG(&clk_pxa3xx_ac97, NULL, "AC97CLK"),
+       INIT_CLKREG(&clk_pxa3xx_ffuart, "pxa2xx-uart.0", NULL),
+       INIT_CLKREG(&clk_pxa3xx_btuart, "pxa2xx-uart.1", NULL),
+       INIT_CLKREG(&clk_pxa3xx_stuart, "pxa2xx-uart.2", NULL),
+       INIT_CLKREG(&clk_pxa3xx_stuart, "pxa2xx-ir", "UARTCLK"),
+       INIT_CLKREG(&clk_pxa3xx_i2c, "pxa2xx-i2c.0", NULL),
+       INIT_CLKREG(&clk_pxa3xx_udc, "pxa27x-udc", NULL),
+       INIT_CLKREG(&clk_pxa3xx_usbh, "pxa27x-ohci", NULL),
+       INIT_CLKREG(&clk_pxa3xx_keypad, "pxa27x-keypad", NULL),
+       INIT_CLKREG(&clk_pxa3xx_ssp1, "pxa27x-ssp.0", NULL),
+       INIT_CLKREG(&clk_pxa3xx_ssp2, "pxa27x-ssp.1", NULL),
+       INIT_CLKREG(&clk_pxa3xx_ssp3, "pxa27x-ssp.2", NULL),
+       INIT_CLKREG(&clk_pxa3xx_ssp4, "pxa27x-ssp.3", NULL),
+       INIT_CLKREG(&clk_pxa3xx_pwm0, "pxa27x-pwm.0", NULL),
+       INIT_CLKREG(&clk_pxa3xx_pwm1, "pxa27x-pwm.1", NULL),
+       INIT_CLKREG(&clk_pxa3xx_mmc1, "pxa2xx-mci.0", NULL),
+       INIT_CLKREG(&clk_pxa3xx_mmc2, "pxa2xx-mci.1", NULL),
 };
 
 #ifdef CONFIG_PM
@@ -495,19 +539,25 @@ void __init pxa3xx_init_irq(void)
        __asm__ __volatile__("mcr p15, 0, %0, c15, c1, 0\n": :"r"(value));
 
        pxa_init_irq(56, pxa3xx_set_wake);
-       pxa_init_gpio(128, NULL);
+       pxa_init_gpio(IRQ_GPIO_2_x, 2, 127, NULL);
 }
 
 /*
  * device registration specific to PXA3xx.
  */
 
+void __init pxa3xx_set_i2c_power_info(struct i2c_pxa_platform_data *info)
+{
+       pxa_register_device(&pxa3xx_device_i2c_power, info);
+}
+
 static struct platform_device *devices[] __initdata = {
 /*     &pxa_device_udc,        The UDC driver is PXA25x only */
        &pxa_device_ffuart,
        &pxa_device_btuart,
        &pxa_device_stuart,
        &pxa_device_i2s,
+       &sa1100_device_rtc,
        &pxa_device_rtc,
        &pxa27x_device_ssp1,
        &pxa27x_device_ssp2,
@@ -532,6 +582,9 @@ static int __init pxa3xx_init(void)
        int i, ret = 0;
 
        if (cpu_is_pxa3xx()) {
+
+               reset_status = ARSR;
+
                /*
                 * clear RDH bit every time after reset
                 *
@@ -540,9 +593,9 @@ static int __init pxa3xx_init(void)
                 */
                ASCR &= ~(ASCR_RDH | ASCR_D1S | ASCR_D2S | ASCR_D3S);
 
-               clks_register(pxa3xx_clks, ARRAY_SIZE(pxa3xx_clks));
+               clks_register(pxa3xx_clkregs, ARRAY_SIZE(pxa3xx_clkregs));
 
-               if ((ret = pxa_init_dma(32)))
+               if ((ret = pxa_init_dma(IRQ_DMA, 32)))
                        return ret;
 
                pxa3xx_init_pm();