]> err.no Git - linux-2.6/blobdiff - arch/arm/mach-pxa/pxa27x.c
[ARM] 5075/1: i2c-pxa: move i2c pin setup and PCFR_PI2CEN handling into arch/arm...
[linux-2.6] / arch / arm / mach-pxa / pxa27x.c
index 343296a710b3e1ec4f2f1b4b31e9c94a35b854eb..48cbdc771a808b246305997babac8abe71981ee5 100644 (file)
@@ -23,6 +23,7 @@
 #include <asm/arch/irqs.h>
 #include <asm/arch/pxa-regs.h>
 #include <asm/arch/pxa2xx-regs.h>
+#include <asm/arch/mfp-pxa27x.h>
 #include <asm/arch/ohci.h>
 #include <asm/arch/pm.h>
 #include <asm/arch/dma.h>
@@ -151,12 +152,15 @@ static struct clk pxa27x_clks[] = {
 
        INIT_CKEN("USBCLK", USBHOST, 48000000, 0, &pxa27x_device_ohci.dev),
        INIT_CKEN("I2CCLK", PWRI2C, 13000000, 0, &pxa27x_device_i2c_power.dev),
-       INIT_CKEN("KBDCLK", KEYPAD, 32768, 0, NULL),
+       INIT_CKEN("KBDCLK", KEYPAD, 32768, 0, &pxa27x_device_keypad.dev),
 
        INIT_CKEN("SSPCLK", SSP1, 13000000, 0, &pxa27x_device_ssp1.dev),
        INIT_CKEN("SSPCLK", SSP2, 13000000, 0, &pxa27x_device_ssp2.dev),
        INIT_CKEN("SSPCLK", SSP3, 13000000, 0, &pxa27x_device_ssp3.dev),
 
+       INIT_CKEN("AC97CLK",     AC97,     24576000, 0, NULL),
+       INIT_CKEN("AC97CONFCLK", AC97CONF, 24576000, 0, NULL),
+
        /*
        INIT_CKEN("PWMCLK",  PWM0, 13000000, 0, NULL),
        INIT_CKEN("MSLCLK",  MSL,  48000000, 0, NULL),
@@ -172,23 +176,12 @@ static struct clk pxa27x_clks[] = {
 #define SAVE(x)                sleep_save[SLEEP_SAVE_##x] = x
 #define RESTORE(x)     x = sleep_save[SLEEP_SAVE_##x]
 
-#define RESTORE_GPLEVEL(n) do { \
-       GPSR##n = sleep_save[SLEEP_SAVE_GPLR##n]; \
-       GPCR##n = ~sleep_save[SLEEP_SAVE_GPLR##n]; \
-} while (0)
-
 /*
  * List of global PXA peripheral registers to preserve.
  * More ones like CP and general purpose register values are preserved
  * with the stack pointer in sleep.S.
  */
-enum { SLEEP_SAVE_START = 0,
-
-       SLEEP_SAVE_GPLR0, SLEEP_SAVE_GPLR1, SLEEP_SAVE_GPLR2, SLEEP_SAVE_GPLR3,
-       SLEEP_SAVE_GPDR0, SLEEP_SAVE_GPDR1, SLEEP_SAVE_GPDR2, SLEEP_SAVE_GPDR3,
-       SLEEP_SAVE_GRER0, SLEEP_SAVE_GRER1, SLEEP_SAVE_GRER2, SLEEP_SAVE_GRER3,
-       SLEEP_SAVE_GFER0, SLEEP_SAVE_GFER1, SLEEP_SAVE_GFER2, SLEEP_SAVE_GFER3,
-       SLEEP_SAVE_PGSR0, SLEEP_SAVE_PGSR1, SLEEP_SAVE_PGSR2, SLEEP_SAVE_PGSR3,
+enum { SLEEP_SAVE_PGSR0, SLEEP_SAVE_PGSR1, SLEEP_SAVE_PGSR2, SLEEP_SAVE_PGSR3,
 
        SLEEP_SAVE_GAFR0_L, SLEEP_SAVE_GAFR0_U,
        SLEEP_SAVE_GAFR1_L, SLEEP_SAVE_GAFR1_U,
@@ -203,15 +196,11 @@ enum {    SLEEP_SAVE_START = 0,
        SLEEP_SAVE_PWER, SLEEP_SAVE_PCFR, SLEEP_SAVE_PRER,
        SLEEP_SAVE_PFER, SLEEP_SAVE_PKWR,
 
-       SLEEP_SAVE_SIZE
+       SLEEP_SAVE_COUNT
 };
 
 void pxa27x_cpu_pm_save(unsigned long *sleep_save)
 {
-       SAVE(GPLR0); SAVE(GPLR1); SAVE(GPLR2); SAVE(GPLR3);
-       SAVE(GPDR0); SAVE(GPDR1); SAVE(GPDR2); SAVE(GPDR3);
-       SAVE(GRER0); SAVE(GRER1); SAVE(GRER2); SAVE(GRER3);
-       SAVE(GFER0); SAVE(GFER1); SAVE(GFER2); SAVE(GFER3);
        SAVE(PGSR0); SAVE(PGSR1); SAVE(PGSR2); SAVE(PGSR3);
 
        SAVE(GAFR0_L); SAVE(GAFR0_U);
@@ -225,9 +214,6 @@ void pxa27x_cpu_pm_save(unsigned long *sleep_save)
 
        SAVE(CKEN);
        SAVE(PSTR);
-
-       /* Clear GPIO transition detect bits */
-       GEDR0 = GEDR0; GEDR1 = GEDR1; GEDR2 = GEDR2; GEDR3 = GEDR3;
 }
 
 void pxa27x_cpu_pm_restore(unsigned long *sleep_save)
@@ -236,15 +222,10 @@ void pxa27x_cpu_pm_restore(unsigned long *sleep_save)
        PSPR = 0;
 
        /* restore registers */
-       RESTORE_GPLEVEL(0); RESTORE_GPLEVEL(1);
-       RESTORE_GPLEVEL(2); RESTORE_GPLEVEL(3);
-       RESTORE(GPDR0); RESTORE(GPDR1); RESTORE(GPDR2); RESTORE(GPDR3);
        RESTORE(GAFR0_L); RESTORE(GAFR0_U);
        RESTORE(GAFR1_L); RESTORE(GAFR1_U);
        RESTORE(GAFR2_L); RESTORE(GAFR2_U);
        RESTORE(GAFR3_L); RESTORE(GAFR3_U);
-       RESTORE(GRER0); RESTORE(GRER1); RESTORE(GRER2); RESTORE(GRER3);
-       RESTORE(GFER0); RESTORE(GFER1); RESTORE(GFER2); RESTORE(GFER3);
        RESTORE(PGSR0); RESTORE(PGSR1); RESTORE(PGSR2); RESTORE(PGSR3);
 
        RESTORE(MDREFR);
@@ -268,6 +249,9 @@ void pxa27x_cpu_pm_enter(suspend_state_t state)
        /* Clear edge-detect status register. */
        PEDR = 0xDF12FE1B;
 
+       /* Clear reset status */
+       RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
+
        switch (state) {
        case PM_SUSPEND_STANDBY:
                pxa_cpu_standby();
@@ -286,7 +270,7 @@ static int pxa27x_cpu_pm_valid(suspend_state_t state)
 }
 
 static struct pxa_cpu_pm_fns pxa27x_cpu_pm_fns = {
-       .save_size      = SLEEP_SAVE_SIZE,
+       .save_count     = SLEEP_SAVE_COUNT,
        .save           = pxa27x_cpu_pm_save,
        .restore        = pxa27x_cpu_pm_restore,
        .valid          = pxa27x_cpu_pm_valid,
@@ -304,37 +288,16 @@ static inline void pxa27x_init_pm(void) {}
 /* PXA27x:  Various gpios can issue wakeup events.  This logic only
  * handles the simple cases, not the WEMUX2 and WEMUX3 options
  */
-#define PXA27x_GPIO_NOWAKE_MASK \
-        ((1 << 8) | (1 << 7) | (1 << 6) | (1 << 5) | (1 << 2))
-#define WAKEMASK(gpio) \
-        (((gpio) <= 15) \
-                 ? ((1 << (gpio)) & ~PXA27x_GPIO_NOWAKE_MASK) \
-                 : ((gpio == 35) ? (1 << 24) : 0))
-
 static int pxa27x_set_wake(unsigned int irq, unsigned int on)
 {
        int gpio = IRQ_TO_GPIO(irq);
        uint32_t mask;
 
-       if ((gpio >= 0 && gpio <= 15) || (gpio == 35)) {
-               if (WAKEMASK(gpio) == 0)
-                       return -EINVAL;
+       if (gpio >= 0 && gpio < 128)
+               return gpio_set_wake(gpio, on);
 
-               mask = WAKEMASK(gpio);
-
-               if (on) {
-                       if (GRER(gpio) | GPIO_bit(gpio))
-                               PRER |= mask;
-                       else
-                               PRER &= ~mask;
-
-                       if (GFER(gpio) | GPIO_bit(gpio))
-                               PFER |= mask;
-                       else
-                               PFER &= ~mask;
-               }
-               goto set_pwer;
-       }
+       if (irq == IRQ_KEYPAD)
+               return keypad_set_wake(on);
 
        switch (irq) {
        case IRQ_RTCAlrm:
@@ -347,7 +310,6 @@ static int pxa27x_set_wake(unsigned int irq, unsigned int on)
                return -EINVAL;
        }
 
-set_pwer:
        if (on)
                PWER |= mask;
        else
@@ -358,10 +320,8 @@ set_pwer:
 
 void __init pxa27x_init_irq(void)
 {
-       pxa_init_irq_low();
-       pxa_init_irq_high();
-       pxa_init_irq_gpio(128);
-       pxa_init_irq_set_wake(pxa27x_set_wake);
+       pxa_init_irq(34, pxa27x_set_wake);
+       pxa_init_gpio(128, pxa27x_set_wake);
 }
 
 /*
@@ -389,11 +349,14 @@ struct platform_device pxa27x_device_i2c_power = {
 
 void __init pxa_set_i2c_power_info(struct i2c_pxa_platform_data *info)
 {
+       local_irq_disable();
+       PCFR |= PCFR_PI2CEN;
+       local_irq_enable();
        pxa27x_device_i2c_power.dev.platform_data = info;
 }
 
 static struct platform_device *devices[] __initdata = {
-       &pxa_device_udc,
+/*     &pxa_device_udc,        The UDC driver is PXA25x only */
        &pxa_device_ffuart,
        &pxa_device_btuart,
        &pxa_device_stuart,
@@ -407,11 +370,9 @@ static struct platform_device *devices[] __initdata = {
 
 static struct sys_device pxa27x_sysdev[] = {
        {
-               .id     = 0,
                .cls    = &pxa_irq_sysclass,
        }, {
-               .id     = 1,
-               .cls    = &pxa_irq_sysclass,
+               .cls    = &pxa_gpio_sysclass,
        },
 };
 
@@ -439,4 +400,4 @@ static int __init pxa27x_init(void)
        return ret;
 }
 
-subsys_initcall(pxa27x_init);
+postcore_initcall(pxa27x_init);