aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/boot/dts/prima2-cb.dts9
-rw-r--r--arch/arm/mach-prima2/Makefile2
-rw-r--r--arch/arm/mach-prima2/clock.c1
-rw-r--r--arch/arm/mach-prima2/irq.c44
-rw-r--r--arch/arm/mach-prima2/pm.c149
-rw-r--r--arch/arm/mach-prima2/pm.h29
-rw-r--r--arch/arm/mach-prima2/rstc.c1
-rw-r--r--arch/arm/mach-prima2/rtciobrg.c139
-rw-r--r--arch/arm/mach-prima2/sleep.S64
-rw-r--r--arch/arm/mach-prima2/timer.c35
-rw-r--r--include/linux/rtc/sirfsoc_rtciobrg.h18
11 files changed, 489 insertions, 2 deletions
diff --git a/arch/arm/boot/dts/prima2-cb.dts b/arch/arm/boot/dts/prima2-cb.dts
index 6fecc88065b2..17b6737c4ee5 100644
--- a/arch/arm/boot/dts/prima2-cb.dts
+++ b/arch/arm/boot/dts/prima2-cb.dts
@@ -67,6 +67,11 @@
67 compatible = "sirf,prima2-rstc"; 67 compatible = "sirf,prima2-rstc";
68 reg = <0x88010000 0x1000>; 68 reg = <0x88010000 0x1000>;
69 }; 69 };
70
71 rsc-controller@88020000 {
72 compatible = "sirf,prima2-rsc";
73 reg = <0x88020000 0x1000>;
74 };
70 }; 75 };
71 76
72 mem-iobg { 77 mem-iobg {
@@ -274,7 +279,7 @@
274 gpio: gpio-controller@b0120000 { 279 gpio: gpio-controller@b0120000 {
275 #gpio-cells = <2>; 280 #gpio-cells = <2>;
276 #interrupt-cells = <2>; 281 #interrupt-cells = <2>;
277 compatible = "sirf,prima2-gpio"; 282 compatible = "sirf,prima2-gpio-pinmux";
278 reg = <0xb0120000 0x10000>; 283 reg = <0xb0120000 0x10000>;
279 gpio-controller; 284 gpio-controller;
280 interrupt-controller; 285 interrupt-controller;
@@ -358,7 +363,7 @@
358 }; 363 };
359 364
360 rtc-iobg { 365 rtc-iobg {
361 compatible = "sirf,prima2-rtciobg", "simple-bus"; 366 compatible = "sirf,prima2-rtciobg", "sirf-prima2-rtciobg-bus";
362 #address-cells = <1>; 367 #address-cells = <1>;
363 #size-cells = <1>; 368 #size-cells = <1>;
364 reg = <0x80030000 0x10000>; 369 reg = <0x80030000 0x10000>;
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
3obj-y += clock.o 3obj-y += clock.o
4obj-y += rstc.o 4obj-y += rstc.o
5obj-y += prima2.o 5obj-y += prima2.o
6obj-y += rtciobrg.o
6obj-$(CONFIG_DEBUG_LL) += lluart.o 7obj-$(CONFIG_DEBUG_LL) += lluart.o
7obj-$(CONFIG_CACHE_L2X0) += l2x0.o 8obj-$(CONFIG_CACHE_L2X0) += l2x0.o
9obj-$(CONFIG_SUSPEND) += pm.o sleep.o
diff --git a/arch/arm/mach-prima2/clock.c b/arch/arm/mach-prima2/clock.c
index f9a2aaf63f71..615a4e75ceab 100644
--- a/arch/arm/mach-prima2/clock.c
+++ b/arch/arm/mach-prima2/clock.c
@@ -481,6 +481,7 @@ static void __init sirfsoc_clk_init(void)
481 481
482static struct of_device_id clkc_ids[] = { 482static struct of_device_id clkc_ids[] = {
483 { .compatible = "sirf,prima2-clkc" }, 483 { .compatible = "sirf,prima2-clkc" },
484 {},
484}; 485};
485 486
486void __init sirfsoc_of_clk_init(void) 487void __init sirfsoc_of_clk_init(void)
diff --git a/arch/arm/mach-prima2/irq.c b/arch/arm/mach-prima2/irq.c
index c3404cbb6ff7..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
@@ -51,6 +53,7 @@ static __init void sirfsoc_irq_init(void)
51 53
52static struct of_device_id intc_ids[] = { 54static struct of_device_id intc_ids[] = {
53 { .compatible = "sirf,prima2-intc" }, 55 { .compatible = "sirf,prima2-intc" },
56 {},
54}; 57};
55 58
56void __init sirfsoc_of_irq_init(void) 59void __init sirfsoc_of_irq_init(void)
@@ -65,7 +68,48 @@ void __init sirfsoc_of_irq_init(void)
65 if (!sirfsoc_intc_base) 68 if (!sirfsoc_intc_base)
66 panic("unable to map intc cpu registers\n"); 69 panic("unable to map intc cpu registers\n");
67 70
71 irq_domain_add_simple(np, 0);
72
68 of_node_put(np); 73 of_node_put(np);
69 74
70 sirfsoc_irq_init(); 75 sirfsoc_irq_init();
71} 76}
77
78struct sirfsoc_irq_status {
79 u32 mask0;
80 u32 mask1;
81 u32 level0;
82 u32 level1;
83};
84
85static struct sirfsoc_irq_status sirfsoc_irq_st;
86
87static 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
97static 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
105static struct syscore_ops sirfsoc_irq_syscore_ops = {
106 .suspend = sirfsoc_irq_suspend,
107 .resume = sirfsoc_irq_resume,
108};
109
110static int __init sirfsoc_irq_pm_init(void)
111{
112 register_syscore_ops(&sirfsoc_irq_syscore_ops);
113 return 0;
114}
115device_initcall(sirfsoc_irq_pm_init);
diff --git a/arch/arm/mach-prima2/pm.c b/arch/arm/mach-prima2/pm.c
new file mode 100644
index 000000000000..0ba39f3e16ba
--- /dev/null
+++ b/arch/arm/mach-prima2/pm.c
@@ -0,0 +1,149 @@
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 */
27u32 sirfsoc_pwrc_base;
28void __iomem *sirfsoc_memc_base;
29
30static 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
40static 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
50static 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
64static 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 break;
75 default:
76 return -EINVAL;
77 }
78 return 0;
79}
80
81static const struct platform_suspend_ops sirfsoc_pm_ops = {
82 .enter = sirfsoc_pm_enter,
83 .valid = suspend_valid_only_mem,
84};
85
86static int __init sirfsoc_pm_init(void)
87{
88 suspend_set_ops(&sirfsoc_pm_ops);
89 return 0;
90}
91late_initcall(sirfsoc_pm_init);
92
93static const struct of_device_id pwrc_ids[] = {
94 { .compatible = "sirf,prima2-pwrc" },
95 {}
96};
97
98static int __init sirfsoc_of_pwrc_init(void)
99{
100 struct device_node *np;
101
102 np = of_find_matching_node(NULL, pwrc_ids);
103 if (!np)
104 panic("unable to find compatible pwrc node in dtb\n");
105
106 /*
107 * pwrc behind rtciobrg is not located in memory space
108 * though the property is named reg. reg only means base
109 * offset for pwrc. then of_iomap is not suitable here.
110 */
111 if (of_property_read_u32(np, "reg", &sirfsoc_pwrc_base))
112 panic("unable to find base address of pwrc node in dtb\n");
113
114 of_node_put(np);
115
116 return 0;
117}
118postcore_initcall(sirfsoc_of_pwrc_init);
119
120static const struct of_device_id memc_ids[] = {
121 { .compatible = "sirf,prima2-memc" },
122 {}
123};
124
125static int __devinit sirfsoc_memc_probe(struct platform_device *op)
126{
127 struct device_node *np = op->dev.of_node;
128
129 sirfsoc_memc_base = of_iomap(np, 0);
130 if (!sirfsoc_memc_base)
131 panic("unable to map memc registers\n");
132
133 return 0;
134}
135
136static struct platform_driver sirfsoc_memc_driver = {
137 .probe = sirfsoc_memc_probe,
138 .driver = {
139 .name = "sirfsoc-memc",
140 .owner = THIS_MODULE,
141 .of_match_table = memc_ids,
142 },
143};
144
145static int __init sirfsoc_memc_init(void)
146{
147 return platform_driver_register(&sirfsoc_memc_driver);
148}
149postcore_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__
25extern int sirfsoc_finish_suspend(unsigned long);
26#endif
27
28#endif
29
diff --git a/arch/arm/mach-prima2/rstc.c b/arch/arm/mach-prima2/rstc.c
index d074786e83d4..492cfa8d2610 100644
--- a/arch/arm/mach-prima2/rstc.c
+++ b/arch/arm/mach-prima2/rstc.c
@@ -19,6 +19,7 @@ static DEFINE_MUTEX(rstc_lock);
19 19
20static struct of_device_id rstc_ids[] = { 20static struct of_device_id rstc_ids[] = {
21 { .compatible = "sirf,prima2-rstc" }, 21 { .compatible = "sirf,prima2-rstc" },
22 {},
22}; 23};
23 24
24static int __init sirfsoc_of_rstc_init(void) 25static int __init sirfsoc_of_rstc_init(void)
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 */
27void __iomem *sirfsoc_rtciobrg_base;
28static 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 */
34void sirfsoc_rtc_iobrg_wait_sync(void)
35{
36 while (readl_relaxed(sirfsoc_rtciobrg_base + SIRFSOC_CPUIOBRG_CTRL))
37 cpu_relax();
38}
39
40void 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}
50EXPORT_SYMBOL_GPL(sirfsoc_rtc_iobrg_besyncing);
51
52u32 __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
65u32 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}
77EXPORT_SYMBOL_GPL(sirfsoc_rtc_iobrg_readl);
78
79void 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
89void 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}
103EXPORT_SYMBOL_GPL(sirfsoc_rtc_iobrg_writel);
104
105static const struct of_device_id rtciobrg_ids[] = {
106 { .compatible = "sirf,prima2-rtciobg" },
107 {}
108};
109
110static 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
121static 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
130static int __init sirfsoc_rtciobrg_init(void)
131{
132 return platform_driver_register(&sirfsoc_rtciobrg_driver);
133}
134postcore_initcall(sirfsoc_rtciobrg_init);
135
136MODULE_AUTHOR("Zhiwu Song <zhiwu.song@csr.com>, "
137 "Barry Song <baohua.song@csr.com>");
138MODULE_DESCRIPTION("CSR SiRFprimaII rtc io bridge");
139MODULE_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
20ENTRY(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
511:
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
601:
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 44027f34a88a..3b159615de24 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
45static 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
52static u32 sirfsoc_timer_reg_val[SIRFSOC_TIMER_REG_CNT];
53
43static void __iomem *sirfsoc_timer_base; 54static void __iomem *sirfsoc_timer_base;
44static void __init sirfsoc_of_timer_map(void); 55static 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
120static 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
130static 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
109static struct clock_event_device sirfsoc_clockevent = { 141static 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
125static struct irqaction sirfsoc_timer_irq = { 159static struct irqaction sirfsoc_timer_irq = {
@@ -190,6 +224,7 @@ static void __init sirfsoc_timer_init(void)
190 224
191static struct of_device_id timer_ids[] = { 225static struct of_device_id timer_ids[] = {
192 { .compatible = "sirf,prima2-tick" }, 226 { .compatible = "sirf,prima2-tick" },
227 {},
193}; 228};
194 229
195static void __init sirfsoc_of_timer_map(void) 230static void __init sirfsoc_of_timer_map(void)
diff --git a/include/linux/rtc/sirfsoc_rtciobrg.h b/include/linux/rtc/sirfsoc_rtciobrg.h
new file mode 100644
index 000000000000..2c92e1c8e055
--- /dev/null
+++ b/include/linux/rtc/sirfsoc_rtciobrg.h
@@ -0,0 +1,18 @@
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#ifndef _SIRFSOC_RTC_IOBRG_H_
10#define _SIRFSOC_RTC_IOBRG_H_
11
12extern void sirfsoc_rtc_iobrg_besyncing(void);
13
14extern u32 sirfsoc_rtc_iobrg_readl(u32 addr);
15
16extern void sirfsoc_rtc_iobrg_writel(u32 val, u32 addr);
17
18#endif