aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-stmp3xxx.c
diff options
context:
space:
mode:
authorWolfram Sang <w.sang@pengutronix.de>2011-05-25 06:56:52 -0400
committerJohn Stultz <john.stultz@linaro.org>2011-07-01 21:09:56 -0400
commitb5167159d4341d408ef6b941975f2fe8973b2a94 (patch)
treee5424d893af19f51bdd6dbb8167c68c7eab36e04 /drivers/rtc/rtc-stmp3xxx.c
parenta91d2bab355f3a5caa767d7316f80422bfcd2ad6 (diff)
rtc: stmp3xxx: Get rid of mach-specific accessors
Replace the accessors with standard readl/writel to remove their platform-dependency. Also, drop __raw_(read|write)l-accessors while we are here. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Tested-by: Shawn Guo <shawn.guo@freescale.com> Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'drivers/rtc/rtc-stmp3xxx.c')
-rw-r--r--drivers/rtc/rtc-stmp3xxx.c64
1 files changed, 34 insertions, 30 deletions
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c
index 90f05fe60620..ad1851796940 100644
--- a/drivers/rtc/rtc-stmp3xxx.c
+++ b/drivers/rtc/rtc-stmp3xxx.c
@@ -18,6 +18,7 @@
18 */ 18 */
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/io.h>
21#include <linux/init.h> 22#include <linux/init.h>
22#include <linux/platform_device.h> 23#include <linux/platform_device.h>
23#include <linux/interrupt.h> 24#include <linux/interrupt.h>
@@ -25,9 +26,10 @@
25#include <linux/slab.h> 26#include <linux/slab.h>
26 27
27#include <mach/common.h> 28#include <mach/common.h>
28#include <mach/mxs.h>
29 29
30#define STMP3XXX_RTC_CTRL 0x0 30#define STMP3XXX_RTC_CTRL 0x0
31#define STMP3XXX_RTC_CTRL_SET 0x4
32#define STMP3XXX_RTC_CTRL_CLR 0x8
31#define STMP3XXX_RTC_CTRL_ALARM_IRQ_EN 0x00000001 33#define STMP3XXX_RTC_CTRL_ALARM_IRQ_EN 0x00000001
32#define STMP3XXX_RTC_CTRL_ONEMSEC_IRQ_EN 0x00000002 34#define STMP3XXX_RTC_CTRL_ONEMSEC_IRQ_EN 0x00000002
33#define STMP3XXX_RTC_CTRL_ALARM_IRQ 0x00000004 35#define STMP3XXX_RTC_CTRL_ALARM_IRQ 0x00000004
@@ -42,6 +44,8 @@
42#define STMP3XXX_RTC_ALARM 0x40 44#define STMP3XXX_RTC_ALARM 0x40
43 45
44#define STMP3XXX_RTC_PERSISTENT0 0x60 46#define STMP3XXX_RTC_PERSISTENT0 0x60
47#define STMP3XXX_RTC_PERSISTENT0_SET 0x64
48#define STMP3XXX_RTC_PERSISTENT0_CLR 0x68
45#define STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN 0x00000002 49#define STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN 0x00000002
46#define STMP3XXX_RTC_PERSISTENT0_ALARM_EN 0x00000004 50#define STMP3XXX_RTC_PERSISTENT0_ALARM_EN 0x00000004
47#define STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE 0x00000080 51#define STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE 0x00000080
@@ -60,7 +64,7 @@ static void stmp3xxx_wait_time(struct stmp3xxx_rtc_data *rtc_data)
60 * NEW_REGS/STALE_REGS bitfields go. In fact it's 0x1=P0, 64 * NEW_REGS/STALE_REGS bitfields go. In fact it's 0x1=P0,
61 * 0x2=P1, .., 0x20=P5, 0x40=ALARM, 0x80=SECONDS 65 * 0x2=P1, .., 0x20=P5, 0x40=ALARM, 0x80=SECONDS
62 */ 66 */
63 while (__raw_readl(rtc_data->io + STMP3XXX_RTC_STAT) & 67 while (readl(rtc_data->io + STMP3XXX_RTC_STAT) &
64 (0x80 << STMP3XXX_RTC_STAT_STALE_SHIFT)) 68 (0x80 << STMP3XXX_RTC_STAT_STALE_SHIFT))
65 cpu_relax(); 69 cpu_relax();
66} 70}
@@ -71,8 +75,7 @@ static int stmp3xxx_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm)
71 struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); 75 struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
72 76
73 stmp3xxx_wait_time(rtc_data); 77 stmp3xxx_wait_time(rtc_data);
74 rtc_time_to_tm(__raw_readl(rtc_data->io + STMP3XXX_RTC_SECONDS), 78 rtc_time_to_tm(readl(rtc_data->io + STMP3XXX_RTC_SECONDS), rtc_tm);
75 rtc_tm);
76 return 0; 79 return 0;
77} 80}
78 81
@@ -80,7 +83,7 @@ static int stmp3xxx_rtc_set_mmss(struct device *dev, unsigned long t)
80{ 83{
81 struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); 84 struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
82 85
83 __raw_writel(t, rtc_data->io + STMP3XXX_RTC_SECONDS); 86 writel(t, rtc_data->io + STMP3XXX_RTC_SECONDS);
84 stmp3xxx_wait_time(rtc_data); 87 stmp3xxx_wait_time(rtc_data);
85 return 0; 88 return 0;
86} 89}
@@ -92,19 +95,19 @@ static irqreturn_t stmp3xxx_rtc_interrupt(int irq, void *dev_id)
92 u32 status; 95 u32 status;
93 u32 events = 0; 96 u32 events = 0;
94 97
95 status = __raw_readl(rtc_data->io + STMP3XXX_RTC_CTRL) & 98 status = readl(rtc_data->io + STMP3XXX_RTC_CTRL) &
96 (STMP3XXX_RTC_CTRL_ALARM_IRQ | 99 (STMP3XXX_RTC_CTRL_ALARM_IRQ |
97 STMP3XXX_RTC_CTRL_ONEMSEC_IRQ); 100 STMP3XXX_RTC_CTRL_ONEMSEC_IRQ);
98 101
99 if (status & STMP3XXX_RTC_CTRL_ALARM_IRQ) { 102 if (status & STMP3XXX_RTC_CTRL_ALARM_IRQ) {
100 __mxs_clrl(STMP3XXX_RTC_CTRL_ALARM_IRQ, 103 writel(STMP3XXX_RTC_CTRL_ALARM_IRQ,
101 rtc_data->io + STMP3XXX_RTC_CTRL); 104 rtc_data->io + STMP3XXX_RTC_CTRL_CLR);
102 events |= RTC_AF | RTC_IRQF; 105 events |= RTC_AF | RTC_IRQF;
103 } 106 }
104 107
105 if (status & STMP3XXX_RTC_CTRL_ONEMSEC_IRQ) { 108 if (status & STMP3XXX_RTC_CTRL_ONEMSEC_IRQ) {
106 __mxs_clrl(STMP3XXX_RTC_CTRL_ONEMSEC_IRQ, 109 writel(STMP3XXX_RTC_CTRL_ONEMSEC_IRQ,
107 rtc_data->io + STMP3XXX_RTC_CTRL); 110 rtc_data->io + STMP3XXX_RTC_CTRL_CLR);
108 if (++rtc_data->irq_count % 1000 == 0) { 111 if (++rtc_data->irq_count % 1000 == 0) {
109 events |= RTC_UF | RTC_IRQF; 112 events |= RTC_UF | RTC_IRQF;
110 rtc_data->irq_count = 0; 113 rtc_data->irq_count = 0;
@@ -120,17 +123,19 @@ static irqreturn_t stmp3xxx_rtc_interrupt(int irq, void *dev_id)
120static int stmp3xxx_alarm_irq_enable(struct device *dev, unsigned int enabled) 123static int stmp3xxx_alarm_irq_enable(struct device *dev, unsigned int enabled)
121{ 124{
122 struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); 125 struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
123 void __iomem *p = rtc_data->io + STMP3XXX_RTC_PERSISTENT0,
124 *ctl = rtc_data->io + STMP3XXX_RTC_CTRL;
125 126
126 if (enabled) { 127 if (enabled) {
127 __mxs_setl(STMP3XXX_RTC_PERSISTENT0_ALARM_EN | 128 writel(STMP3XXX_RTC_PERSISTENT0_ALARM_EN |
128 STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN, p); 129 STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN,
129 __mxs_setl(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, ctl); 130 rtc_data->io + STMP3XXX_RTC_PERSISTENT0_SET);
131 writel(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN,
132 rtc_data->io + STMP3XXX_RTC_CTRL_SET);
130 } else { 133 } else {
131 __mxs_clrl(STMP3XXX_RTC_PERSISTENT0_ALARM_EN | 134 writel(STMP3XXX_RTC_PERSISTENT0_ALARM_EN |
132 STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN, p); 135 STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN,
133 __mxs_clrl(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, ctl); 136 rtc_data->io + STMP3XXX_RTC_PERSISTENT0_CLR);
137 writel(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN,
138 rtc_data->io + STMP3XXX_RTC_CTRL_CLR);
134 } 139 }
135 return 0; 140 return 0;
136} 141}
@@ -139,8 +144,7 @@ static int stmp3xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
139{ 144{
140 struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); 145 struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
141 146
142 rtc_time_to_tm(__raw_readl(rtc_data->io + STMP3XXX_RTC_ALARM), 147 rtc_time_to_tm(readl(rtc_data->io + STMP3XXX_RTC_ALARM), &alm->time);
143 &alm->time);
144 return 0; 148 return 0;
145} 149}
146 150
@@ -150,7 +154,7 @@ static int stmp3xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
150 struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); 154 struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
151 155
152 rtc_tm_to_time(&alm->time, &t); 156 rtc_tm_to_time(&alm->time, &t);
153 __raw_writel(t, rtc_data->io + STMP3XXX_RTC_ALARM); 157 writel(t, rtc_data->io + STMP3XXX_RTC_ALARM);
154 return 0; 158 return 0;
155} 159}
156 160
@@ -170,9 +174,9 @@ static int stmp3xxx_rtc_remove(struct platform_device *pdev)
170 if (!rtc_data) 174 if (!rtc_data)
171 return 0; 175 return 0;
172 176
173 __mxs_clrl(STMP3XXX_RTC_CTRL_ONEMSEC_IRQ_EN | 177 writel(STMP3XXX_RTC_CTRL_ONEMSEC_IRQ_EN |
174 STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, 178 STMP3XXX_RTC_CTRL_ALARM_IRQ_EN,
175 rtc_data->io + STMP3XXX_RTC_CTRL); 179 rtc_data->io + STMP3XXX_RTC_CTRL_CLR);
176 free_irq(rtc_data->irq_alarm, &pdev->dev); 180 free_irq(rtc_data->irq_alarm, &pdev->dev);
177 free_irq(rtc_data->irq_1msec, &pdev->dev); 181 free_irq(rtc_data->irq_1msec, &pdev->dev);
178 rtc_device_unregister(rtc_data->rtc); 182 rtc_device_unregister(rtc_data->rtc);
@@ -210,7 +214,7 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev)
210 rtc_data->irq_alarm = platform_get_irq(pdev, 0); 214 rtc_data->irq_alarm = platform_get_irq(pdev, 0);
211 rtc_data->irq_1msec = platform_get_irq(pdev, 1); 215 rtc_data->irq_1msec = platform_get_irq(pdev, 1);
212 216
213 if (!(__raw_readl(STMP3XXX_RTC_STAT + rtc_data->io) & 217 if (!(readl(STMP3XXX_RTC_STAT + rtc_data->io) &
214 STMP3XXX_RTC_STAT_RTC_PRESENT)) { 218 STMP3XXX_RTC_STAT_RTC_PRESENT)) {
215 dev_err(&pdev->dev, "no device onboard\n"); 219 dev_err(&pdev->dev, "no device onboard\n");
216 err = -ENODEV; 220 err = -ENODEV;
@@ -220,10 +224,10 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev)
220 platform_set_drvdata(pdev, rtc_data); 224 platform_set_drvdata(pdev, rtc_data);
221 225
222 mxs_reset_block(rtc_data->io); 226 mxs_reset_block(rtc_data->io);
223 __mxs_clrl(STMP3XXX_RTC_PERSISTENT0_ALARM_EN | 227 writel(STMP3XXX_RTC_PERSISTENT0_ALARM_EN |
224 STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN | 228 STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN |
225 STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE, 229 STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE,
226 rtc_data->io + STMP3XXX_RTC_PERSISTENT0); 230 rtc_data->io + STMP3XXX_RTC_PERSISTENT0_CLR);
227 231
228 rtc_data->rtc = rtc_device_register(pdev->name, &pdev->dev, 232 rtc_data->rtc = rtc_device_register(pdev->name, &pdev->dev,
229 &stmp3xxx_rtc_ops, THIS_MODULE); 233 &stmp3xxx_rtc_ops, THIS_MODULE);
@@ -253,9 +257,9 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev)
253out_irq1: 257out_irq1:
254 free_irq(rtc_data->irq_alarm, &pdev->dev); 258 free_irq(rtc_data->irq_alarm, &pdev->dev);
255out_irq_alarm: 259out_irq_alarm:
256 __mxs_clrl(STMP3XXX_RTC_CTRL_ONEMSEC_IRQ_EN | 260 writel(STMP3XXX_RTC_CTRL_ONEMSEC_IRQ_EN |
257 STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, 261 STMP3XXX_RTC_CTRL_ALARM_IRQ_EN,
258 rtc_data->io + STMP3XXX_RTC_CTRL); 262 rtc_data->io + STMP3XXX_RTC_CTRL_CLR);
259 rtc_device_unregister(rtc_data->rtc); 263 rtc_device_unregister(rtc_data->rtc);
260out_remap: 264out_remap:
261 platform_set_drvdata(pdev, NULL); 265 platform_set_drvdata(pdev, NULL);
@@ -276,10 +280,10 @@ static int stmp3xxx_rtc_resume(struct platform_device *dev)
276 struct stmp3xxx_rtc_data *rtc_data = platform_get_drvdata(dev); 280 struct stmp3xxx_rtc_data *rtc_data = platform_get_drvdata(dev);
277 281
278 mxs_reset_block(rtc_data->io); 282 mxs_reset_block(rtc_data->io);
279 __mxs_clrl(STMP3XXX_RTC_PERSISTENT0_ALARM_EN | 283 writel(STMP3XXX_RTC_PERSISTENT0_ALARM_EN |
280 STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN | 284 STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN |
281 STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE, 285 STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE,
282 rtc_data->io + STMP3XXX_RTC_PERSISTENT0); 286 rtc_data->io + STMP3XXX_RTC_PERSISTENT0_CLR);
283 return 0; 287 return 0;
284} 288}
285#else 289#else