diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-01 23:22:01 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-01 23:22:01 -0400 |
commit | cd9a0b6bd67ec372b0ef3cb2abe26974f888b956 (patch) | |
tree | ffec66aa48f95b2b764f9e84fbafc519cce5000e /arch/arm/mach-prima2 | |
parent | ac5761a650d22dd7dfad4d417463a0981d2da0a4 (diff) | |
parent | 090ad104c5c59c7952d4b8d4cfb60559b38eb3e0 (diff) |
Merge branch 'next/pm' of git://git.linaro.org/people/arnd/arm-soc
* 'next/pm' of git://git.linaro.org/people/arnd/arm-soc: (66 commits)
ARM: CSR: PM: use outer_resume to resume L2 cache
ARM: CSR: call l2x0_of_init to init L2 cache of SiRFprimaII
ARM: OMAP: voltage: voltage layer present, even when CONFIG_PM=n
ARM: CSR: PM: add sleep entry for SiRFprimaII
ARM: CSR: PM: save/restore irq status in suspend cycle
ARM: CSR: PM: save/restore timer status in suspend cycle
OMAP4: PM: TWL6030: add cmd register
OMAP4: PM: TWL6030: fix ON/RET/OFF voltages
OMAP4: PM: TWL6030: address 0V conversions
OMAP4: PM: TWL6030: fix uv to voltage for >0x39
OMAP4: PM: TWL6030: fix voltage conversion formula
omap: voltage: add a stub header file for external/regulator use
OMAP2+: VC: more registers are per-channel starting with OMAP5
OMAP3+: voltage: update nominal voltage in voltdm_scale() not VC post-scale
OMAP3+: voltage: rename omap_voltage_get_nom_volt -> voltdm_get_voltage
OMAP3+: voltdm: final removal of omap_vdd_info
OMAP3+: voltage: move/rename curr_volt from vdd_info into struct voltagedomain
OMAP3+: voltage: rename scale and reset functions using voltdm_ prefix
OMAP3+: VP: combine setting init voltage into common function
OMAP3+: VP: remove unused omap_vp_get_curr_volt()
...
Fix up trivial conflict in arch/arm/mach-prima2/l2x0.c (code removal vs
edit)
Diffstat (limited to 'arch/arm/mach-prima2')
-rw-r--r-- | arch/arm/mach-prima2/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/mach-prima2/irq.c | 43 | ||||
-rw-r--r-- | arch/arm/mach-prima2/l2x0.c | 45 | ||||
-rw-r--r-- | arch/arm/mach-prima2/pm.c | 150 | ||||
-rw-r--r-- | arch/arm/mach-prima2/pm.h | 29 | ||||
-rw-r--r-- | arch/arm/mach-prima2/rtciobrg.c | 139 | ||||
-rw-r--r-- | arch/arm/mach-prima2/sleep.S | 64 | ||||
-rw-r--r-- | arch/arm/mach-prima2/timer.c | 34 |
8 files changed, 470 insertions, 36 deletions
diff --git a/arch/arm/mach-prima2/Makefile b/arch/arm/mach-prima2/Makefile index 7af7fc05d565..13dd1604d951 100644 --- a/arch/arm/mach-prima2/Makefile +++ b/arch/arm/mach-prima2/Makefile | |||
@@ -3,5 +3,7 @@ obj-y += irq.o | |||
3 | obj-y += clock.o | 3 | obj-y += clock.o |
4 | obj-y += rstc.o | 4 | obj-y += rstc.o |
5 | obj-y += prima2.o | 5 | obj-y += prima2.o |
6 | obj-y += rtciobrg.o | ||
6 | obj-$(CONFIG_DEBUG_LL) += lluart.o | 7 | obj-$(CONFIG_DEBUG_LL) += lluart.o |
7 | obj-$(CONFIG_CACHE_L2X0) += l2x0.o | 8 | obj-$(CONFIG_CACHE_L2X0) += l2x0.o |
9 | obj-$(CONFIG_SUSPEND) += pm.o sleep.o | ||
diff --git a/arch/arm/mach-prima2/irq.c b/arch/arm/mach-prima2/irq.c index 7af254d046ba..d93ceef4a50a 100644 --- a/arch/arm/mach-prima2/irq.c +++ b/arch/arm/mach-prima2/irq.c | |||
@@ -13,6 +13,8 @@ | |||
13 | #include <asm/mach/irq.h> | 13 | #include <asm/mach/irq.h> |
14 | #include <linux/of.h> | 14 | #include <linux/of.h> |
15 | #include <linux/of_address.h> | 15 | #include <linux/of_address.h> |
16 | #include <linux/irqdomain.h> | ||
17 | #include <linux/syscore_ops.h> | ||
16 | 18 | ||
17 | #define SIRFSOC_INT_RISC_MASK0 0x0018 | 19 | #define SIRFSOC_INT_RISC_MASK0 0x0018 |
18 | #define SIRFSOC_INT_RISC_MASK1 0x001C | 20 | #define SIRFSOC_INT_RISC_MASK1 0x001C |
@@ -66,7 +68,48 @@ void __init sirfsoc_of_irq_init(void) | |||
66 | if (!sirfsoc_intc_base) | 68 | if (!sirfsoc_intc_base) |
67 | panic("unable to map intc cpu registers\n"); | 69 | panic("unable to map intc cpu registers\n"); |
68 | 70 | ||
71 | irq_domain_add_simple(np, 0); | ||
72 | |||
69 | of_node_put(np); | 73 | of_node_put(np); |
70 | 74 | ||
71 | sirfsoc_irq_init(); | 75 | sirfsoc_irq_init(); |
72 | } | 76 | } |
77 | |||
78 | struct sirfsoc_irq_status { | ||
79 | u32 mask0; | ||
80 | u32 mask1; | ||
81 | u32 level0; | ||
82 | u32 level1; | ||
83 | }; | ||
84 | |||
85 | static struct sirfsoc_irq_status sirfsoc_irq_st; | ||
86 | |||
87 | static int sirfsoc_irq_suspend(void) | ||
88 | { | ||
89 | sirfsoc_irq_st.mask0 = readl_relaxed(sirfsoc_intc_base + SIRFSOC_INT_RISC_MASK0); | ||
90 | sirfsoc_irq_st.mask1 = readl_relaxed(sirfsoc_intc_base + SIRFSOC_INT_RISC_MASK1); | ||
91 | sirfsoc_irq_st.level0 = readl_relaxed(sirfsoc_intc_base + SIRFSOC_INT_RISC_LEVEL0); | ||
92 | sirfsoc_irq_st.level1 = readl_relaxed(sirfsoc_intc_base + SIRFSOC_INT_RISC_LEVEL1); | ||
93 | |||
94 | return 0; | ||
95 | } | ||
96 | |||
97 | static void sirfsoc_irq_resume(void) | ||
98 | { | ||
99 | writel_relaxed(sirfsoc_irq_st.mask0, sirfsoc_intc_base + SIRFSOC_INT_RISC_MASK0); | ||
100 | writel_relaxed(sirfsoc_irq_st.mask1, sirfsoc_intc_base + SIRFSOC_INT_RISC_MASK1); | ||
101 | writel_relaxed(sirfsoc_irq_st.level0, sirfsoc_intc_base + SIRFSOC_INT_RISC_LEVEL0); | ||
102 | writel_relaxed(sirfsoc_irq_st.level1, sirfsoc_intc_base + SIRFSOC_INT_RISC_LEVEL1); | ||
103 | } | ||
104 | |||
105 | static struct syscore_ops sirfsoc_irq_syscore_ops = { | ||
106 | .suspend = sirfsoc_irq_suspend, | ||
107 | .resume = sirfsoc_irq_resume, | ||
108 | }; | ||
109 | |||
110 | static int __init sirfsoc_irq_pm_init(void) | ||
111 | { | ||
112 | register_syscore_ops(&sirfsoc_irq_syscore_ops); | ||
113 | return 0; | ||
114 | } | ||
115 | device_initcall(sirfsoc_irq_pm_init); | ||
diff --git a/arch/arm/mach-prima2/l2x0.c b/arch/arm/mach-prima2/l2x0.c index 66c6387e5a04..c99837797d76 100644 --- a/arch/arm/mach-prima2/l2x0.c +++ b/arch/arm/mach-prima2/l2x0.c | |||
@@ -8,51 +8,24 @@ | |||
8 | 8 | ||
9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
11 | #include <linux/io.h> | ||
12 | #include <linux/errno.h> | ||
13 | #include <linux/of.h> | 11 | #include <linux/of.h> |
14 | #include <linux/of_address.h> | ||
15 | #include <asm/hardware/cache-l2x0.h> | 12 | #include <asm/hardware/cache-l2x0.h> |
16 | 13 | ||
17 | #define L2X0_ADDR_FILTERING_START 0xC00 | 14 | static struct of_device_id prima2_l2x0_ids[] = { |
18 | #define L2X0_ADDR_FILTERING_END 0xC04 | 15 | { .compatible = "sirf,prima2-pl310-cache" }, |
19 | 16 | {}, | |
20 | static struct of_device_id l2x_ids[] = { | ||
21 | { .compatible = "arm,pl310-cache" }, | ||
22 | }; | 17 | }; |
23 | 18 | ||
24 | static int __init sirfsoc_of_l2x_init(void) | 19 | static int __init sirfsoc_l2x0_init(void) |
25 | { | 20 | { |
26 | struct device_node *np; | 21 | struct device_node *np; |
27 | void __iomem *sirfsoc_l2x_base; | ||
28 | |||
29 | np = of_find_matching_node(NULL, l2x_ids); | ||
30 | if (!np) | ||
31 | panic("unable to find compatible l2x node in dtb\n"); | ||
32 | |||
33 | sirfsoc_l2x_base = of_iomap(np, 0); | ||
34 | if (!sirfsoc_l2x_base) | ||
35 | panic("unable to map l2x cpu registers\n"); | ||
36 | |||
37 | of_node_put(np); | ||
38 | |||
39 | if (!(readl_relaxed(sirfsoc_l2x_base + L2X0_CTRL) & 1)) { | ||
40 | /* | ||
41 | * set the physical memory windows L2 cache will cover | ||
42 | */ | ||
43 | writel_relaxed(PHYS_OFFSET + 1024 * 1024 * 1024, | ||
44 | sirfsoc_l2x_base + L2X0_ADDR_FILTERING_END); | ||
45 | writel_relaxed(PHYS_OFFSET | 0x1, | ||
46 | sirfsoc_l2x_base + L2X0_ADDR_FILTERING_START); | ||
47 | 22 | ||
48 | writel_relaxed(0, | 23 | np = of_find_matching_node(NULL, prima2_l2x0_ids); |
49 | sirfsoc_l2x_base + L2X0_TAG_LATENCY_CTRL); | 24 | if (np) { |
50 | writel_relaxed(0, | 25 | pr_info("Initializing prima2 L2 cache\n"); |
51 | sirfsoc_l2x_base + L2X0_DATA_LATENCY_CTRL); | 26 | return l2x0_of_init(0x40000, 0); |
52 | } | 27 | } |
53 | l2x0_init((void __iomem *)sirfsoc_l2x_base, 0x00040000, | ||
54 | 0x00000000); | ||
55 | 28 | ||
56 | return 0; | 29 | return 0; |
57 | } | 30 | } |
58 | early_initcall(sirfsoc_of_l2x_init); | 31 | early_initcall(sirfsoc_l2x0_init); |
diff --git a/arch/arm/mach-prima2/pm.c b/arch/arm/mach-prima2/pm.c new file mode 100644 index 000000000000..cb53160f6c5d --- /dev/null +++ b/arch/arm/mach-prima2/pm.c | |||
@@ -0,0 +1,150 @@ | |||
1 | /* | ||
2 | * power management entry for CSR SiRFprimaII | ||
3 | * | ||
4 | * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. | ||
5 | * | ||
6 | * Licensed under GPLv2 or later. | ||
7 | */ | ||
8 | |||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/suspend.h> | ||
11 | #include <linux/slab.h> | ||
12 | #include <linux/of.h> | ||
13 | #include <linux/of_address.h> | ||
14 | #include <linux/of_device.h> | ||
15 | #include <linux/of_platform.h> | ||
16 | #include <linux/io.h> | ||
17 | #include <linux/rtc/sirfsoc_rtciobrg.h> | ||
18 | #include <asm/suspend.h> | ||
19 | #include <asm/hardware/cache-l2x0.h> | ||
20 | |||
21 | #include "pm.h" | ||
22 | |||
23 | /* | ||
24 | * suspend asm codes will access these to make DRAM become self-refresh and | ||
25 | * system sleep | ||
26 | */ | ||
27 | u32 sirfsoc_pwrc_base; | ||
28 | void __iomem *sirfsoc_memc_base; | ||
29 | |||
30 | static void sirfsoc_set_wakeup_source(void) | ||
31 | { | ||
32 | u32 pwr_trigger_en_reg; | ||
33 | pwr_trigger_en_reg = sirfsoc_rtc_iobrg_readl(sirfsoc_pwrc_base + | ||
34 | SIRFSOC_PWRC_TRIGGER_EN); | ||
35 | #define X_ON_KEY_B (1 << 0) | ||
36 | sirfsoc_rtc_iobrg_writel(pwr_trigger_en_reg | X_ON_KEY_B, | ||
37 | sirfsoc_pwrc_base + SIRFSOC_PWRC_TRIGGER_EN); | ||
38 | } | ||
39 | |||
40 | static void sirfsoc_set_sleep_mode(u32 mode) | ||
41 | { | ||
42 | u32 sleep_mode = sirfsoc_rtc_iobrg_readl(sirfsoc_pwrc_base + | ||
43 | SIRFSOC_PWRC_PDN_CTRL); | ||
44 | sleep_mode &= ~(SIRFSOC_SLEEP_MODE_MASK << 1); | ||
45 | sleep_mode |= mode << 1; | ||
46 | sirfsoc_rtc_iobrg_writel(sleep_mode, sirfsoc_pwrc_base + | ||
47 | SIRFSOC_PWRC_PDN_CTRL); | ||
48 | } | ||
49 | |||
50 | static int sirfsoc_pre_suspend_power_off(void) | ||
51 | { | ||
52 | u32 wakeup_entry = virt_to_phys(cpu_resume); | ||
53 | |||
54 | sirfsoc_rtc_iobrg_writel(wakeup_entry, sirfsoc_pwrc_base + | ||
55 | SIRFSOC_PWRC_SCRATCH_PAD1); | ||
56 | |||
57 | sirfsoc_set_wakeup_source(); | ||
58 | |||
59 | sirfsoc_set_sleep_mode(SIRFSOC_DEEP_SLEEP_MODE); | ||
60 | |||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | static int sirfsoc_pm_enter(suspend_state_t state) | ||
65 | { | ||
66 | switch (state) { | ||
67 | case PM_SUSPEND_MEM: | ||
68 | sirfsoc_pre_suspend_power_off(); | ||
69 | |||
70 | outer_flush_all(); | ||
71 | outer_disable(); | ||
72 | /* go zzz */ | ||
73 | cpu_suspend(0, sirfsoc_finish_suspend); | ||
74 | outer_resume(); | ||
75 | break; | ||
76 | default: | ||
77 | return -EINVAL; | ||
78 | } | ||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | static const struct platform_suspend_ops sirfsoc_pm_ops = { | ||
83 | .enter = sirfsoc_pm_enter, | ||
84 | .valid = suspend_valid_only_mem, | ||
85 | }; | ||
86 | |||
87 | static int __init sirfsoc_pm_init(void) | ||
88 | { | ||
89 | suspend_set_ops(&sirfsoc_pm_ops); | ||
90 | return 0; | ||
91 | } | ||
92 | late_initcall(sirfsoc_pm_init); | ||
93 | |||
94 | static const struct of_device_id pwrc_ids[] = { | ||
95 | { .compatible = "sirf,prima2-pwrc" }, | ||
96 | {} | ||
97 | }; | ||
98 | |||
99 | static int __init sirfsoc_of_pwrc_init(void) | ||
100 | { | ||
101 | struct device_node *np; | ||
102 | |||
103 | np = of_find_matching_node(NULL, pwrc_ids); | ||
104 | if (!np) | ||
105 | panic("unable to find compatible pwrc node in dtb\n"); | ||
106 | |||
107 | /* | ||
108 | * pwrc behind rtciobrg is not located in memory space | ||
109 | * though the property is named reg. reg only means base | ||
110 | * offset for pwrc. then of_iomap is not suitable here. | ||
111 | */ | ||
112 | if (of_property_read_u32(np, "reg", &sirfsoc_pwrc_base)) | ||
113 | panic("unable to find base address of pwrc node in dtb\n"); | ||
114 | |||
115 | of_node_put(np); | ||
116 | |||
117 | return 0; | ||
118 | } | ||
119 | postcore_initcall(sirfsoc_of_pwrc_init); | ||
120 | |||
121 | static const struct of_device_id memc_ids[] = { | ||
122 | { .compatible = "sirf,prima2-memc" }, | ||
123 | {} | ||
124 | }; | ||
125 | |||
126 | static int __devinit sirfsoc_memc_probe(struct platform_device *op) | ||
127 | { | ||
128 | struct device_node *np = op->dev.of_node; | ||
129 | |||
130 | sirfsoc_memc_base = of_iomap(np, 0); | ||
131 | if (!sirfsoc_memc_base) | ||
132 | panic("unable to map memc registers\n"); | ||
133 | |||
134 | return 0; | ||
135 | } | ||
136 | |||
137 | static struct platform_driver sirfsoc_memc_driver = { | ||
138 | .probe = sirfsoc_memc_probe, | ||
139 | .driver = { | ||
140 | .name = "sirfsoc-memc", | ||
141 | .owner = THIS_MODULE, | ||
142 | .of_match_table = memc_ids, | ||
143 | }, | ||
144 | }; | ||
145 | |||
146 | static int __init sirfsoc_memc_init(void) | ||
147 | { | ||
148 | return platform_driver_register(&sirfsoc_memc_driver); | ||
149 | } | ||
150 | postcore_initcall(sirfsoc_memc_init); | ||
diff --git a/arch/arm/mach-prima2/pm.h b/arch/arm/mach-prima2/pm.h new file mode 100644 index 000000000000..bae6d77e01ab --- /dev/null +++ b/arch/arm/mach-prima2/pm.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-prima2/pm.h | ||
3 | * | ||
4 | * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. | ||
5 | * | ||
6 | * Licensed under GPLv2 or later. | ||
7 | */ | ||
8 | |||
9 | #ifndef _MACH_PRIMA2_PM_H_ | ||
10 | #define _MACH_PRIMA2_PM_H_ | ||
11 | |||
12 | #define SIRFSOC_PWR_SLEEPFORCE 0x01 | ||
13 | |||
14 | #define SIRFSOC_SLEEP_MODE_MASK 0x3 | ||
15 | #define SIRFSOC_DEEP_SLEEP_MODE 0x1 | ||
16 | |||
17 | #define SIRFSOC_PWRC_PDN_CTRL 0x0 | ||
18 | #define SIRFSOC_PWRC_PON_OFF 0x4 | ||
19 | #define SIRFSOC_PWRC_TRIGGER_EN 0x8 | ||
20 | #define SIRFSOC_PWRC_PIN_STATUS 0x14 | ||
21 | #define SIRFSOC_PWRC_SCRATCH_PAD1 0x18 | ||
22 | #define SIRFSOC_PWRC_SCRATCH_PAD2 0x1C | ||
23 | |||
24 | #ifndef __ASSEMBLY__ | ||
25 | extern int sirfsoc_finish_suspend(unsigned long); | ||
26 | #endif | ||
27 | |||
28 | #endif | ||
29 | |||
diff --git a/arch/arm/mach-prima2/rtciobrg.c b/arch/arm/mach-prima2/rtciobrg.c new file mode 100644 index 000000000000..9d80f1e20a98 --- /dev/null +++ b/arch/arm/mach-prima2/rtciobrg.c | |||
@@ -0,0 +1,139 @@ | |||
1 | /* | ||
2 | * RTC I/O Bridge interfaces for CSR SiRFprimaII | ||
3 | * ARM access the registers of SYSRTC, GPSRTC and PWRC through this module | ||
4 | * | ||
5 | * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. | ||
6 | * | ||
7 | * Licensed under GPLv2 or later. | ||
8 | */ | ||
9 | |||
10 | #include <linux/kernel.h> | ||
11 | #include <linux/module.h> | ||
12 | #include <linux/io.h> | ||
13 | #include <linux/of.h> | ||
14 | #include <linux/of_address.h> | ||
15 | #include <linux/of_device.h> | ||
16 | #include <linux/of_platform.h> | ||
17 | |||
18 | #define SIRFSOC_CPUIOBRG_CTRL 0x00 | ||
19 | #define SIRFSOC_CPUIOBRG_WRBE 0x04 | ||
20 | #define SIRFSOC_CPUIOBRG_ADDR 0x08 | ||
21 | #define SIRFSOC_CPUIOBRG_DATA 0x0c | ||
22 | |||
23 | /* | ||
24 | * suspend asm codes will access this address to make system deepsleep | ||
25 | * after DRAM becomes self-refresh | ||
26 | */ | ||
27 | void __iomem *sirfsoc_rtciobrg_base; | ||
28 | static DEFINE_SPINLOCK(rtciobrg_lock); | ||
29 | |||
30 | /* | ||
31 | * symbols without lock are only used by suspend asm codes | ||
32 | * and these symbols are not exported too | ||
33 | */ | ||
34 | void sirfsoc_rtc_iobrg_wait_sync(void) | ||
35 | { | ||
36 | while (readl_relaxed(sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_CTRL)) | ||
37 | cpu_relax(); | ||
38 | } | ||
39 | |||
40 | void sirfsoc_rtc_iobrg_besyncing(void) | ||
41 | { | ||
42 | unsigned long flags; | ||
43 | |||
44 | spin_lock_irqsave(&rtciobrg_lock, flags); | ||
45 | |||
46 | sirfsoc_rtc_iobrg_wait_sync(); | ||
47 | |||
48 | spin_unlock_irqrestore(&rtciobrg_lock, flags); | ||
49 | } | ||
50 | EXPORT_SYMBOL_GPL(sirfsoc_rtc_iobrg_besyncing); | ||
51 | |||
52 | u32 __sirfsoc_rtc_iobrg_readl(u32 addr) | ||
53 | { | ||
54 | sirfsoc_rtc_iobrg_wait_sync(); | ||
55 | |||
56 | writel_relaxed(0x00, sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_WRBE); | ||
57 | writel_relaxed(addr, sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_ADDR); | ||
58 | writel_relaxed(0x01, sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_CTRL); | ||
59 | |||
60 | sirfsoc_rtc_iobrg_wait_sync(); | ||
61 | |||
62 | return readl_relaxed(sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_DATA); | ||
63 | } | ||
64 | |||
65 | u32 sirfsoc_rtc_iobrg_readl(u32 addr) | ||
66 | { | ||
67 | unsigned long flags, val; | ||
68 | |||
69 | spin_lock_irqsave(&rtciobrg_lock, flags); | ||
70 | |||
71 | val = __sirfsoc_rtc_iobrg_readl(addr); | ||
72 | |||
73 | spin_unlock_irqrestore(&rtciobrg_lock, flags); | ||
74 | |||
75 | return val; | ||
76 | } | ||
77 | EXPORT_SYMBOL_GPL(sirfsoc_rtc_iobrg_readl); | ||
78 | |||
79 | void sirfsoc_rtc_iobrg_pre_writel(u32 val, u32 addr) | ||
80 | { | ||
81 | sirfsoc_rtc_iobrg_wait_sync(); | ||
82 | |||
83 | writel_relaxed(0xf1, sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_WRBE); | ||
84 | writel_relaxed(addr, sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_ADDR); | ||
85 | |||
86 | writel_relaxed(val, sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_DATA); | ||
87 | } | ||
88 | |||
89 | void sirfsoc_rtc_iobrg_writel(u32 val, u32 addr) | ||
90 | { | ||
91 | unsigned long flags; | ||
92 | |||
93 | spin_lock_irqsave(&rtciobrg_lock, flags); | ||
94 | |||
95 | sirfsoc_rtc_iobrg_pre_writel(val, addr); | ||
96 | |||
97 | writel_relaxed(0x01, sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_CTRL); | ||
98 | |||
99 | sirfsoc_rtc_iobrg_wait_sync(); | ||
100 | |||
101 | spin_unlock_irqrestore(&rtciobrg_lock, flags); | ||
102 | } | ||
103 | EXPORT_SYMBOL_GPL(sirfsoc_rtc_iobrg_writel); | ||
104 | |||
105 | static const struct of_device_id rtciobrg_ids[] = { | ||
106 | { .compatible = "sirf,prima2-rtciobg" }, | ||
107 | {} | ||
108 | }; | ||
109 | |||
110 | static int __devinit sirfsoc_rtciobrg_probe(struct platform_device *op) | ||
111 | { | ||
112 | struct device_node *np = op->dev.of_node; | ||
113 | |||
114 | sirfsoc_rtciobrg_base = of_iomap(np, 0); | ||
115 | if (!sirfsoc_rtciobrg_base) | ||
116 | panic("unable to map rtc iobrg registers\n"); | ||
117 | |||
118 | return 0; | ||
119 | } | ||
120 | |||
121 | static struct platform_driver sirfsoc_rtciobrg_driver = { | ||
122 | .probe = sirfsoc_rtciobrg_probe, | ||
123 | .driver = { | ||
124 | .name = "sirfsoc-rtciobrg", | ||
125 | .owner = THIS_MODULE, | ||
126 | .of_match_table = rtciobrg_ids, | ||
127 | }, | ||
128 | }; | ||
129 | |||
130 | static int __init sirfsoc_rtciobrg_init(void) | ||
131 | { | ||
132 | return platform_driver_register(&sirfsoc_rtciobrg_driver); | ||
133 | } | ||
134 | postcore_initcall(sirfsoc_rtciobrg_init); | ||
135 | |||
136 | MODULE_AUTHOR("Zhiwu Song <zhiwu.song@csr.com>, " | ||
137 | "Barry Song <baohua.song@csr.com>"); | ||
138 | MODULE_DESCRIPTION("CSR SiRFprimaII rtc io bridge"); | ||
139 | MODULE_LICENSE("GPL"); | ||
diff --git a/arch/arm/mach-prima2/sleep.S b/arch/arm/mach-prima2/sleep.S new file mode 100644 index 000000000000..0745abc365fc --- /dev/null +++ b/arch/arm/mach-prima2/sleep.S | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | * sleep mode for CSR SiRFprimaII | ||
3 | * | ||
4 | * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. | ||
5 | * | ||
6 | * Licensed under GPLv2 or later. | ||
7 | */ | ||
8 | |||
9 | #include <linux/linkage.h> | ||
10 | #include <asm/ptrace.h> | ||
11 | #include <asm/assembler.h> | ||
12 | |||
13 | #include "pm.h" | ||
14 | |||
15 | #define DENALI_CTL_22_OFF 0x58 | ||
16 | #define DENALI_CTL_112_OFF 0x1c0 | ||
17 | |||
18 | .text | ||
19 | |||
20 | ENTRY(sirfsoc_finish_suspend) | ||
21 | @ r5: mem controller | ||
22 | ldr r0, =sirfsoc_memc_base | ||
23 | ldr r5, [r0] | ||
24 | @ r6: pwrc base offset | ||
25 | ldr r0, =sirfsoc_pwrc_base | ||
26 | ldr r6, [r0] | ||
27 | @ r7: rtc iobrg controller | ||
28 | ldr r0, =sirfsoc_rtciobrg_base | ||
29 | ldr r7, [r0] | ||
30 | |||
31 | @ Read the power control register and set the | ||
32 | @ sleep force bit. | ||
33 | add r0, r6, #SIRFSOC_PWRC_PDN_CTRL | ||
34 | bl __sirfsoc_rtc_iobrg_readl | ||
35 | orr r0,r0,#SIRFSOC_PWR_SLEEPFORCE | ||
36 | add r1, r6, #SIRFSOC_PWRC_PDN_CTRL | ||
37 | bl sirfsoc_rtc_iobrg_pre_writel | ||
38 | mov r1, #0x1 | ||
39 | |||
40 | @ read the MEM ctl register and set the self | ||
41 | @ refresh bit | ||
42 | |||
43 | ldr r2, [r5, #DENALI_CTL_22_OFF] | ||
44 | orr r2, r2, #0x1 | ||
45 | |||
46 | @ Following code has to run from cache since | ||
47 | @ the RAM is going to self refresh mode | ||
48 | .align 5 | ||
49 | str r2, [r5, #DENALI_CTL_22_OFF] | ||
50 | |||
51 | 1: | ||
52 | ldr r4, [r5, #DENALI_CTL_112_OFF] | ||
53 | tst r4, #0x1 | ||
54 | bne 1b | ||
55 | |||
56 | @ write SLEEPFORCE through rtc iobridge | ||
57 | |||
58 | str r1, [r7] | ||
59 | @ wait rtc io bridge sync | ||
60 | 1: | ||
61 | ldr r3, [r7] | ||
62 | tst r3, #0x01 | ||
63 | bne 1b | ||
64 | b . | ||
diff --git a/arch/arm/mach-prima2/timer.c b/arch/arm/mach-prima2/timer.c index 26ab6fee5619..b7a6091ce791 100644 --- a/arch/arm/mach-prima2/timer.c +++ b/arch/arm/mach-prima2/timer.c | |||
@@ -40,6 +40,17 @@ | |||
40 | 40 | ||
41 | #define SIRFSOC_TIMER_LATCH_BIT BIT(0) | 41 | #define SIRFSOC_TIMER_LATCH_BIT BIT(0) |
42 | 42 | ||
43 | #define SIRFSOC_TIMER_REG_CNT 11 | ||
44 | |||
45 | static const u32 sirfsoc_timer_reg_list[SIRFSOC_TIMER_REG_CNT] = { | ||
46 | SIRFSOC_TIMER_MATCH_0, SIRFSOC_TIMER_MATCH_1, SIRFSOC_TIMER_MATCH_2, | ||
47 | SIRFSOC_TIMER_MATCH_3, SIRFSOC_TIMER_MATCH_4, SIRFSOC_TIMER_MATCH_5, | ||
48 | SIRFSOC_TIMER_INT_EN, SIRFSOC_TIMER_WATCHDOG_EN, SIRFSOC_TIMER_DIV, | ||
49 | SIRFSOC_TIMER_LATCHED_LO, SIRFSOC_TIMER_LATCHED_HI, | ||
50 | }; | ||
51 | |||
52 | static u32 sirfsoc_timer_reg_val[SIRFSOC_TIMER_REG_CNT]; | ||
53 | |||
43 | static void __iomem *sirfsoc_timer_base; | 54 | static void __iomem *sirfsoc_timer_base; |
44 | static void __init sirfsoc_of_timer_map(void); | 55 | static void __init sirfsoc_of_timer_map(void); |
45 | 56 | ||
@@ -106,6 +117,27 @@ static void sirfsoc_timer_set_mode(enum clock_event_mode mode, | |||
106 | } | 117 | } |
107 | } | 118 | } |
108 | 119 | ||
120 | static void sirfsoc_clocksource_suspend(struct clocksource *cs) | ||
121 | { | ||
122 | int i; | ||
123 | |||
124 | writel_relaxed(SIRFSOC_TIMER_LATCH_BIT, sirfsoc_timer_base + SIRFSOC_TIMER_LATCH); | ||
125 | |||
126 | for (i = 0; i < SIRFSOC_TIMER_REG_CNT; i++) | ||
127 | sirfsoc_timer_reg_val[i] = readl_relaxed(sirfsoc_timer_base + sirfsoc_timer_reg_list[i]); | ||
128 | } | ||
129 | |||
130 | static void sirfsoc_clocksource_resume(struct clocksource *cs) | ||
131 | { | ||
132 | int i; | ||
133 | |||
134 | for (i = 0; i < SIRFSOC_TIMER_REG_CNT; i++) | ||
135 | writel_relaxed(sirfsoc_timer_reg_val[i], sirfsoc_timer_base + sirfsoc_timer_reg_list[i]); | ||
136 | |||
137 | writel_relaxed(sirfsoc_timer_reg_val[i - 2], sirfsoc_timer_base + SIRFSOC_TIMER_COUNTER_LO); | ||
138 | writel_relaxed(sirfsoc_timer_reg_val[i - 1], sirfsoc_timer_base + SIRFSOC_TIMER_COUNTER_HI); | ||
139 | } | ||
140 | |||
109 | static struct clock_event_device sirfsoc_clockevent = { | 141 | static struct clock_event_device sirfsoc_clockevent = { |
110 | .name = "sirfsoc_clockevent", | 142 | .name = "sirfsoc_clockevent", |
111 | .rating = 200, | 143 | .rating = 200, |
@@ -120,6 +152,8 @@ static struct clocksource sirfsoc_clocksource = { | |||
120 | .mask = CLOCKSOURCE_MASK(64), | 152 | .mask = CLOCKSOURCE_MASK(64), |
121 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | 153 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
122 | .read = sirfsoc_timer_read, | 154 | .read = sirfsoc_timer_read, |
155 | .suspend = sirfsoc_clocksource_suspend, | ||
156 | .resume = sirfsoc_clocksource_resume, | ||
123 | }; | 157 | }; |
124 | 158 | ||
125 | static struct irqaction sirfsoc_timer_irq = { | 159 | static struct irqaction sirfsoc_timer_irq = { |