GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / arm / mach-sa1100 / pm.c
blobc83fdc80edfd1226c8ddea56b700e047f099d218
1 /*
2 * SA1100 Power Management Routines
4 * Copyright (c) 2001 Cliff Brake <cbrake@accelent.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License.
9 * History:
11 * 2001-02-06: Cliff Brake Initial code
13 * 2001-02-25: Sukjae Cho <sjcho@east.isi.edu> &
14 * Chester Kuo <chester@linux.org.tw>
15 * Save more value for the resume function! Support
16 * Bitsy/Assabet/Freebird board
18 * 2001-08-29: Nicolas Pitre <nico@fluxnic.net>
19 * Cleaned up, pushed platform dependent stuff
20 * in the platform specific files.
22 * 2002-05-27: Nicolas Pitre Killed sleep.h and the kmalloced save array.
23 * Storage is local on the stack now.
25 #include <linux/init.h>
26 #include <linux/suspend.h>
27 #include <linux/errno.h>
28 #include <linux/time.h>
30 #include <mach/hardware.h>
31 #include <asm/memory.h>
32 #include <asm/system.h>
33 #include <asm/mach/time.h>
35 extern void sa1100_cpu_suspend(void);
36 extern void sa1100_cpu_resume(void);
38 #define SAVE(x) sleep_save[SLEEP_SAVE_##x] = x
39 #define RESTORE(x) x = sleep_save[SLEEP_SAVE_##x]
42 * List of global SA11x0 peripheral registers to preserve.
43 * More ones like CP and general purpose register values are preserved
44 * on the stack and then the stack pointer is stored last in sleep.S.
46 enum { SLEEP_SAVE_GPDR, SLEEP_SAVE_GAFR,
47 SLEEP_SAVE_PPDR, SLEEP_SAVE_PPSR, SLEEP_SAVE_PPAR, SLEEP_SAVE_PSDR,
49 SLEEP_SAVE_Ser1SDCR0,
51 SLEEP_SAVE_COUNT
55 static int sa11x0_pm_enter(suspend_state_t state)
57 unsigned long gpio, sleep_save[SLEEP_SAVE_COUNT];
59 gpio = GPLR;
61 /* save vital registers */
62 SAVE(GPDR);
63 SAVE(GAFR);
65 SAVE(PPDR);
66 SAVE(PPSR);
67 SAVE(PPAR);
68 SAVE(PSDR);
70 SAVE(Ser1SDCR0);
72 /* Clear previous reset status */
73 RCSR = RCSR_HWR | RCSR_SWR | RCSR_WDR | RCSR_SMR;
75 /* set resume return address */
76 PSPR = virt_to_phys(sa1100_cpu_resume);
78 /* go zzz */
79 sa1100_cpu_suspend();
81 cpu_init();
84 * Ensure not to come back here if it wasn't intended
86 PSPR = 0;
89 * Ensure interrupt sources are disabled; we will re-init
90 * the interrupt subsystem via the device manager.
92 ICLR = 0;
93 ICCR = 1;
94 ICMR = 0;
96 /* restore registers */
97 RESTORE(GPDR);
98 RESTORE(GAFR);
100 RESTORE(PPDR);
101 RESTORE(PPSR);
102 RESTORE(PPAR);
103 RESTORE(PSDR);
105 RESTORE(Ser1SDCR0);
107 GPSR = gpio;
108 GPCR = ~gpio;
111 * Clear the peripheral sleep-hold bit.
113 PSSR = PSSR_PH;
115 return 0;
118 unsigned long sleep_phys_sp(void *sp)
120 return virt_to_phys(sp);
123 static struct platform_suspend_ops sa11x0_pm_ops = {
124 .enter = sa11x0_pm_enter,
125 .valid = suspend_valid_only_mem,
128 static int __init sa11x0_pm_init(void)
130 suspend_set_ops(&sa11x0_pm_ops);
131 return 0;
134 late_initcall(sa11x0_pm_init);