bf60x: sec: Clean up interrupt initialization code for SEC.
[linux-2.6/libata-dev.git] / arch / arm / mach-sa1100 / pm.c
blob690cf0ce5c0caa8f06ca8b10d0b31d0a36cc3032
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/suspend.h>
33 #include <asm/mach/time.h>
35 extern int sa1100_finish_suspend(unsigned long);
37 #define SAVE(x) sleep_save[SLEEP_SAVE_##x] = x
38 #define RESTORE(x) x = sleep_save[SLEEP_SAVE_##x]
41 * List of global SA11x0 peripheral registers to preserve.
42 * More ones like CP and general purpose register values are preserved
43 * on the stack and then the stack pointer is stored last in sleep.S.
45 enum { SLEEP_SAVE_GPDR, SLEEP_SAVE_GAFR,
46 SLEEP_SAVE_PPDR, SLEEP_SAVE_PPSR, SLEEP_SAVE_PPAR, SLEEP_SAVE_PSDR,
48 SLEEP_SAVE_Ser1SDCR0,
50 SLEEP_SAVE_COUNT
54 static int sa11x0_pm_enter(suspend_state_t state)
56 unsigned long gpio, sleep_save[SLEEP_SAVE_COUNT];
58 gpio = GPLR;
60 /* save vital registers */
61 SAVE(GPDR);
62 SAVE(GAFR);
64 SAVE(PPDR);
65 SAVE(PPSR);
66 SAVE(PPAR);
67 SAVE(PSDR);
69 SAVE(Ser1SDCR0);
71 /* Clear previous reset status */
72 RCSR = RCSR_HWR | RCSR_SWR | RCSR_WDR | RCSR_SMR;
74 /* set resume return address */
75 PSPR = virt_to_phys(cpu_resume);
77 /* go zzz */
78 cpu_suspend(0, sa1100_finish_suspend);
81 * Ensure not to come back here if it wasn't intended
83 PSPR = 0;
86 * Ensure interrupt sources are disabled; we will re-init
87 * the interrupt subsystem via the device manager.
89 ICLR = 0;
90 ICCR = 1;
91 ICMR = 0;
93 /* restore registers */
94 RESTORE(GPDR);
95 RESTORE(GAFR);
97 RESTORE(PPDR);
98 RESTORE(PPSR);
99 RESTORE(PPAR);
100 RESTORE(PSDR);
102 RESTORE(Ser1SDCR0);
104 GPSR = gpio;
105 GPCR = ~gpio;
108 * Clear the peripheral sleep-hold bit.
110 PSSR = PSSR_PH;
112 return 0;
115 static const struct platform_suspend_ops sa11x0_pm_ops = {
116 .enter = sa11x0_pm_enter,
117 .valid = suspend_valid_only_mem,
120 int __init sa11x0_pm_init(void)
122 suspend_set_ops(&sa11x0_pm_ops);
123 return 0;