diff options
author | Wolfram Sang <w.sang@pengutronix.de> | 2011-05-25 06:56:53 -0400 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2011-07-01 21:09:57 -0400 |
commit | 7e794cb7e36ccdb8c44b8ca7738720625b7aa2da (patch) | |
tree | 4092b4402f32813f2554481752e2d45faedf31c1 /drivers/rtc | |
parent | b5167159d4341d408ef6b941975f2fe8973b2a94 (diff) |
rtc: stmp3xxx: Remove UIE handlers
The RTC core handles UIE since 6610e08 (RTC: Rework RTC code to use
timerqueue for events), so remove the specific interrupt in this driver.
To make it work at all, enable interrupts in set_alarm() if needed. Drop
IRQF_DISABLED which is deprecated, while we are here. Finally, add my
copyright after all these changes.
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')
-rw-r--r-- | drivers/rtc/rtc-stmp3xxx.c | 61 |
1 files changed, 18 insertions, 43 deletions
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c index ad185179694..7315068daa5 100644 --- a/drivers/rtc/rtc-stmp3xxx.c +++ b/drivers/rtc/rtc-stmp3xxx.c | |||
@@ -6,6 +6,7 @@ | |||
6 | * | 6 | * |
7 | * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved. | 7 | * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved. |
8 | * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved. | 8 | * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved. |
9 | * Copyright 2011 Wolfram Sang, Pengutronix e.K. | ||
9 | */ | 10 | */ |
10 | 11 | ||
11 | /* | 12 | /* |
@@ -33,7 +34,6 @@ | |||
33 | #define STMP3XXX_RTC_CTRL_ALARM_IRQ_EN 0x00000001 | 34 | #define STMP3XXX_RTC_CTRL_ALARM_IRQ_EN 0x00000001 |
34 | #define STMP3XXX_RTC_CTRL_ONEMSEC_IRQ_EN 0x00000002 | 35 | #define STMP3XXX_RTC_CTRL_ONEMSEC_IRQ_EN 0x00000002 |
35 | #define STMP3XXX_RTC_CTRL_ALARM_IRQ 0x00000004 | 36 | #define STMP3XXX_RTC_CTRL_ALARM_IRQ 0x00000004 |
36 | #define STMP3XXX_RTC_CTRL_ONEMSEC_IRQ 0x00000008 | ||
37 | 37 | ||
38 | #define STMP3XXX_RTC_STAT 0x10 | 38 | #define STMP3XXX_RTC_STAT 0x10 |
39 | #define STMP3XXX_RTC_STAT_STALE_SHIFT 16 | 39 | #define STMP3XXX_RTC_STAT_STALE_SHIFT 16 |
@@ -52,9 +52,8 @@ | |||
52 | 52 | ||
53 | struct stmp3xxx_rtc_data { | 53 | struct stmp3xxx_rtc_data { |
54 | struct rtc_device *rtc; | 54 | struct rtc_device *rtc; |
55 | unsigned irq_count; | ||
56 | void __iomem *io; | 55 | void __iomem *io; |
57 | int irq_alarm, irq_1msec; | 56 | int irq_alarm; |
58 | }; | 57 | }; |
59 | 58 | ||
60 | static void stmp3xxx_wait_time(struct stmp3xxx_rtc_data *rtc_data) | 59 | static void stmp3xxx_wait_time(struct stmp3xxx_rtc_data *rtc_data) |
@@ -92,32 +91,16 @@ static int stmp3xxx_rtc_set_mmss(struct device *dev, unsigned long t) | |||
92 | static irqreturn_t stmp3xxx_rtc_interrupt(int irq, void *dev_id) | 91 | static irqreturn_t stmp3xxx_rtc_interrupt(int irq, void *dev_id) |
93 | { | 92 | { |
94 | struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev_id); | 93 | struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev_id); |
95 | u32 status; | 94 | u32 status = readl(rtc_data->io + STMP3XXX_RTC_CTRL); |
96 | u32 events = 0; | ||
97 | |||
98 | status = readl(rtc_data->io + STMP3XXX_RTC_CTRL) & | ||
99 | (STMP3XXX_RTC_CTRL_ALARM_IRQ | | ||
100 | STMP3XXX_RTC_CTRL_ONEMSEC_IRQ); | ||
101 | 95 | ||
102 | if (status & STMP3XXX_RTC_CTRL_ALARM_IRQ) { | 96 | if (status & STMP3XXX_RTC_CTRL_ALARM_IRQ) { |
103 | writel(STMP3XXX_RTC_CTRL_ALARM_IRQ, | 97 | writel(STMP3XXX_RTC_CTRL_ALARM_IRQ, |
104 | rtc_data->io + STMP3XXX_RTC_CTRL_CLR); | 98 | rtc_data->io + STMP3XXX_RTC_CTRL_CLR); |
105 | events |= RTC_AF | RTC_IRQF; | 99 | rtc_update_irq(rtc_data->rtc, 1, RTC_AF | RTC_IRQF); |
100 | return IRQ_HANDLED; | ||
106 | } | 101 | } |
107 | 102 | ||
108 | if (status & STMP3XXX_RTC_CTRL_ONEMSEC_IRQ) { | 103 | return IRQ_NONE; |
109 | writel(STMP3XXX_RTC_CTRL_ONEMSEC_IRQ, | ||
110 | rtc_data->io + STMP3XXX_RTC_CTRL_CLR); | ||
111 | if (++rtc_data->irq_count % 1000 == 0) { | ||
112 | events |= RTC_UF | RTC_IRQF; | ||
113 | rtc_data->irq_count = 0; | ||
114 | } | ||
115 | } | ||
116 | |||
117 | if (events) | ||
118 | rtc_update_irq(rtc_data->rtc, 1, events); | ||
119 | |||
120 | return IRQ_HANDLED; | ||
121 | } | 104 | } |
122 | 105 | ||
123 | static int stmp3xxx_alarm_irq_enable(struct device *dev, unsigned int enabled) | 106 | static int stmp3xxx_alarm_irq_enable(struct device *dev, unsigned int enabled) |
@@ -155,6 +138,9 @@ static int stmp3xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
155 | 138 | ||
156 | rtc_tm_to_time(&alm->time, &t); | 139 | rtc_tm_to_time(&alm->time, &t); |
157 | writel(t, rtc_data->io + STMP3XXX_RTC_ALARM); | 140 | writel(t, rtc_data->io + STMP3XXX_RTC_ALARM); |
141 | |||
142 | stmp3xxx_alarm_irq_enable(dev, alm->enabled); | ||
143 | |||
158 | return 0; | 144 | return 0; |
159 | } | 145 | } |
160 | 146 | ||
@@ -174,11 +160,9 @@ static int stmp3xxx_rtc_remove(struct platform_device *pdev) | |||
174 | if (!rtc_data) | 160 | if (!rtc_data) |
175 | return 0; | 161 | return 0; |
176 | 162 | ||
177 | writel(STMP3XXX_RTC_CTRL_ONEMSEC_IRQ_EN | | 163 | writel(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, |
178 | STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, | ||
179 | rtc_data->io + STMP3XXX_RTC_CTRL_CLR); | 164 | rtc_data->io + STMP3XXX_RTC_CTRL_CLR); |
180 | free_irq(rtc_data->irq_alarm, &pdev->dev); | 165 | free_irq(rtc_data->irq_alarm, &pdev->dev); |
181 | free_irq(rtc_data->irq_1msec, &pdev->dev); | ||
182 | rtc_device_unregister(rtc_data->rtc); | 166 | rtc_device_unregister(rtc_data->rtc); |
183 | platform_set_drvdata(pdev, NULL); | 167 | platform_set_drvdata(pdev, NULL); |
184 | iounmap(rtc_data->io); | 168 | iounmap(rtc_data->io); |
@@ -212,7 +196,6 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev) | |||
212 | } | 196 | } |
213 | 197 | ||
214 | rtc_data->irq_alarm = platform_get_irq(pdev, 0); | 198 | rtc_data->irq_alarm = platform_get_irq(pdev, 0); |
215 | rtc_data->irq_1msec = platform_get_irq(pdev, 1); | ||
216 | 199 | ||
217 | if (!(readl(STMP3XXX_RTC_STAT + rtc_data->io) & | 200 | if (!(readl(STMP3XXX_RTC_STAT + rtc_data->io) & |
218 | STMP3XXX_RTC_STAT_RTC_PRESENT)) { | 201 | STMP3XXX_RTC_STAT_RTC_PRESENT)) { |
@@ -229,6 +212,10 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev) | |||
229 | STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE, | 212 | STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE, |
230 | rtc_data->io + STMP3XXX_RTC_PERSISTENT0_CLR); | 213 | rtc_data->io + STMP3XXX_RTC_PERSISTENT0_CLR); |
231 | 214 | ||
215 | writel(STMP3XXX_RTC_CTRL_ONEMSEC_IRQ_EN | | ||
216 | STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, | ||
217 | rtc_data->io + STMP3XXX_RTC_CTRL_CLR); | ||
218 | |||
232 | rtc_data->rtc = rtc_device_register(pdev->name, &pdev->dev, | 219 | rtc_data->rtc = rtc_device_register(pdev->name, &pdev->dev, |
233 | &stmp3xxx_rtc_ops, THIS_MODULE); | 220 | &stmp3xxx_rtc_ops, THIS_MODULE); |
234 | if (IS_ERR(rtc_data->rtc)) { | 221 | if (IS_ERR(rtc_data->rtc)) { |
@@ -236,30 +223,17 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev) | |||
236 | goto out_remap; | 223 | goto out_remap; |
237 | } | 224 | } |
238 | 225 | ||
239 | rtc_data->irq_count = 0; | 226 | err = request_irq(rtc_data->irq_alarm, stmp3xxx_rtc_interrupt, 0, |
240 | err = request_irq(rtc_data->irq_alarm, stmp3xxx_rtc_interrupt, | 227 | "RTC alarm", &pdev->dev); |
241 | IRQF_DISABLED, "RTC alarm", &pdev->dev); | ||
242 | if (err) { | 228 | if (err) { |
243 | dev_err(&pdev->dev, "Cannot claim IRQ%d\n", | 229 | dev_err(&pdev->dev, "Cannot claim IRQ%d\n", |
244 | rtc_data->irq_alarm); | 230 | rtc_data->irq_alarm); |
245 | goto out_irq_alarm; | 231 | goto out_irq_alarm; |
246 | } | 232 | } |
247 | err = request_irq(rtc_data->irq_1msec, stmp3xxx_rtc_interrupt, | ||
248 | IRQF_DISABLED, "RTC tick", &pdev->dev); | ||
249 | if (err) { | ||
250 | dev_err(&pdev->dev, "Cannot claim IRQ%d\n", | ||
251 | rtc_data->irq_1msec); | ||
252 | goto out_irq1; | ||
253 | } | ||
254 | 233 | ||
255 | return 0; | 234 | return 0; |
256 | 235 | ||
257 | out_irq1: | ||
258 | free_irq(rtc_data->irq_alarm, &pdev->dev); | ||
259 | out_irq_alarm: | 236 | out_irq_alarm: |
260 | writel(STMP3XXX_RTC_CTRL_ONEMSEC_IRQ_EN | | ||
261 | STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, | ||
262 | rtc_data->io + STMP3XXX_RTC_CTRL_CLR); | ||
263 | rtc_device_unregister(rtc_data->rtc); | 237 | rtc_device_unregister(rtc_data->rtc); |
264 | out_remap: | 238 | out_remap: |
265 | platform_set_drvdata(pdev, NULL); | 239 | platform_set_drvdata(pdev, NULL); |
@@ -316,5 +290,6 @@ module_init(stmp3xxx_rtc_init); | |||
316 | module_exit(stmp3xxx_rtc_exit); | 290 | module_exit(stmp3xxx_rtc_exit); |
317 | 291 | ||
318 | MODULE_DESCRIPTION("STMP3xxx RTC Driver"); | 292 | MODULE_DESCRIPTION("STMP3xxx RTC Driver"); |
319 | MODULE_AUTHOR("dmitry pervushin <dpervushin@embeddedalley.com>"); | 293 | MODULE_AUTHOR("dmitry pervushin <dpervushin@embeddedalley.com> and " |
294 | "Wolfram Sang <w.sang@pengutronix.de>"); | ||
320 | MODULE_LICENSE("GPL"); | 295 | MODULE_LICENSE("GPL"); |