2 * linux/arch/arm/mach-pxa/pxa25x.c
4 * Author: Nicolas Pitre
5 * Created: Jun 15, 2001
6 * Copyright: MontaVista Software Inc.
8 * Code specific to PXA21x/25x/26x variants.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 * Since this file should be linked before any other machine specific file,
15 * the __initcall() here will be executed first. This serves as default
16 * initialization stuff for PXA machines which can be overridden later if
19 #include <linux/gpio.h>
20 #include <linux/gpio-pxa.h>
21 #include <linux/module.h>
22 #include <linux/kernel.h>
23 #include <linux/init.h>
24 #include <linux/platform_device.h>
25 #include <linux/suspend.h>
26 #include <linux/syscore_ops.h>
27 #include <linux/irq.h>
29 #include <asm/mach/map.h>
30 #include <asm/suspend.h>
31 #include <mach/hardware.h>
32 #include <mach/irqs.h>
33 #include <mach/pxa25x.h>
34 #include <mach/reset.h>
37 #include <mach/smemc.h>
43 * Various clock factors driven by the CCCR register.
48 #define SAVE(x) sleep_save[SLEEP_SAVE_##x] = x
49 #define RESTORE(x) x = sleep_save[SLEEP_SAVE_##x]
52 * List of global PXA peripheral registers to preserve.
53 * More ones like CP and general purpose register values are preserved
54 * with the stack pointer in sleep.S.
62 static void pxa25x_cpu_pm_save(unsigned long *sleep_save
)
67 static void pxa25x_cpu_pm_restore(unsigned long *sleep_save
)
72 static void pxa25x_cpu_pm_enter(suspend_state_t state
)
74 /* Clear reset status */
75 RCSR
= RCSR_HWR
| RCSR_WDR
| RCSR_SMR
| RCSR_GPR
;
79 cpu_suspend(PWRMODE_SLEEP
, pxa25x_finish_suspend
);
84 static int pxa25x_cpu_pm_prepare(void)
86 /* set resume return address */
87 PSPR
= virt_to_phys(cpu_resume
);
91 static void pxa25x_cpu_pm_finish(void)
93 /* ensure not to come back here if it wasn't intended */
97 static struct pxa_cpu_pm_fns pxa25x_cpu_pm_fns
= {
98 .save_count
= SLEEP_SAVE_COUNT
,
99 .valid
= suspend_valid_only_mem
,
100 .save
= pxa25x_cpu_pm_save
,
101 .restore
= pxa25x_cpu_pm_restore
,
102 .enter
= pxa25x_cpu_pm_enter
,
103 .prepare
= pxa25x_cpu_pm_prepare
,
104 .finish
= pxa25x_cpu_pm_finish
,
107 static void __init
pxa25x_init_pm(void)
109 pxa_cpu_pm_fns
= &pxa25x_cpu_pm_fns
;
112 static inline void pxa25x_init_pm(void) {}
115 /* PXA25x: supports wakeup from GPIO0..GPIO15 and RTC alarm
118 static int pxa25x_set_wake(struct irq_data
*d
, unsigned int on
)
120 int gpio
= pxa_irq_to_gpio(d
->irq
);
123 if (gpio
>= 0 && gpio
< 85)
124 return gpio_set_wake(gpio
, on
);
126 if (d
->irq
== IRQ_RTCAlrm
) {
142 void __init
pxa25x_init_irq(void)
144 pxa_init_irq(32, pxa25x_set_wake
);
147 #ifdef CONFIG_CPU_PXA26x
148 void __init
pxa26x_init_irq(void)
150 pxa_init_irq(32, pxa25x_set_wake
);
154 static struct map_desc pxa25x_io_desc
[] __initdata
= {
156 .virtual = (unsigned long)SMEMC_VIRT
,
157 .pfn
= __phys_to_pfn(PXA2XX_SMEMC_BASE
),
158 .length
= SMEMC_SIZE
,
160 }, { /* UNCACHED_PHYS_0 */
161 .virtual = UNCACHED_PHYS_0
,
162 .pfn
= __phys_to_pfn(0x00000000),
163 .length
= UNCACHED_PHYS_0_SIZE
,
168 void __init
pxa25x_map_io(void)
171 iotable_init(ARRAY_AND_SIZE(pxa25x_io_desc
));
172 pxa25x_get_clk_frequency_khz(1);
175 static struct pxa_gpio_platform_data pxa25x_gpio_info __initdata
= {
176 .irq_base
= PXA_GPIO_TO_IRQ(0),
177 .gpio_set_wake
= gpio_set_wake
,
180 static struct platform_device
*pxa25x_devices
[] __initdata
= {
190 &pxa_device_asoc_platform
,
193 static int __init
pxa25x_init(void)
197 if (cpu_is_pxa25x()) {
201 if ((ret
= pxa_init_dma(IRQ_DMA
, 16)))
206 register_syscore_ops(&pxa_irq_syscore_ops
);
207 register_syscore_ops(&pxa2xx_mfp_syscore_ops
);
209 pxa2xx_set_dmac_info(16);
210 pxa_register_device(&pxa25x_device_gpio
, &pxa25x_gpio_info
);
211 ret
= platform_add_devices(pxa25x_devices
,
212 ARRAY_SIZE(pxa25x_devices
));
220 postcore_initcall(pxa25x_init
);