aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2015-05-13 10:20:04 -0400
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>2015-09-05 13:37:15 -0400
commit3cdf4ad9633e3ca616617e76b46915c02cba426b (patch)
tree7ddb19a25cc7b4f6ec97690fa9cd908c0d175596 /drivers/rtc
parent8c0961ba7c9356186a0606a391f08e2ecb491a57 (diff)
rtc: pxa: convert to use shared sa1100 functions
Currently, the rtc-sa1100 and rtc-pxa drivers co-exist as rtc-pxa has a superset of functionality. Having 2 drivers sharing the same memory resource is not allowed by the driver model if resources are properly declared. This problem was avoided by not adding memory resources to the SA1100 RTC driver, but that prevents clean-up of the SA1100 driver. This commit converts the PXA RTC to use the exported SA1100 RTC functions. Now the sa1100-rtc and pxa-rtc devices are mutually exclusive, so we must remove the sa1100-rtc from pxa27x and pxa3xx. Signed-off-by: Rob Herring <robh@kernel.org> Cc: Daniel Mack <daniel@zonque.org> Cc: Haojian Zhuang <haojian.zhuang@gmail.com> Cc: Robert Jarzmik <robert.jarzmik@free.fr> Cc: Russell King <linux@arm.linux.org.uk> Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com> Cc: linux-arm-kernel@lists.infradead.org Cc: rtc-linux@googlegroups.com Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/Kconfig12
-rw-r--r--drivers/rtc/rtc-pxa.c51
2 files changed, 31 insertions, 32 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 35ea04c50a5c..0f65a222a48a 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1306,11 +1306,13 @@ config RTC_DRV_GENERIC
1306 just say Y. 1306 just say Y.
1307 1307
1308config RTC_DRV_PXA 1308config RTC_DRV_PXA
1309 tristate "PXA27x/PXA3xx" 1309 tristate "PXA27x/PXA3xx"
1310 depends on ARCH_PXA 1310 depends on ARCH_PXA
1311 help 1311 select RTC_DRV_SA1100
1312 If you say Y here you will get access to the real time clock 1312 help
1313 built into your PXA27x or PXA3xx CPU. 1313 If you say Y here you will get access to the real time clock
1314 built into your PXA27x or PXA3xx CPU. This RTC is actually 2 RTCs
1315 consisting of an SA1100 compatible RTC and the extended PXA RTC.
1314 1316
1315 This RTC driver uses PXA RTC registers available since pxa27x 1317 This RTC driver uses PXA RTC registers available since pxa27x
1316 series (RDxR, RYxR) instead of legacy RCNR, RTAR. 1318 series (RDxR, RYxR) instead of legacy RCNR, RTAR.
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c
index 4561f375327d..fb9b3a7d2266 100644
--- a/drivers/rtc/rtc-pxa.c
+++ b/drivers/rtc/rtc-pxa.c
@@ -32,6 +32,8 @@
32 32
33#include <mach/hardware.h> 33#include <mach/hardware.h>
34 34
35#include "rtc-sa1100.h"
36
35#define RTC_DEF_DIVIDER (32768 - 1) 37#define RTC_DEF_DIVIDER (32768 - 1)
36#define RTC_DEF_TRIM 0 38#define RTC_DEF_TRIM 0
37#define MAXFREQ_PERIODIC 1000 39#define MAXFREQ_PERIODIC 1000
@@ -86,10 +88,9 @@
86 __raw_writel((value), (pxa_rtc)->base + (reg)) 88 __raw_writel((value), (pxa_rtc)->base + (reg))
87 89
88struct pxa_rtc { 90struct pxa_rtc {
91 struct sa1100_rtc sa1100_rtc;
89 struct resource *ress; 92 struct resource *ress;
90 void __iomem *base; 93 void __iomem *base;
91 int irq_1Hz;
92 int irq_Alrm;
93 struct rtc_device *rtc; 94 struct rtc_device *rtc;
94 spinlock_t lock; /* Protects this structure */ 95 spinlock_t lock; /* Protects this structure */
95}; 96};
@@ -184,25 +185,25 @@ static int pxa_rtc_open(struct device *dev)
184 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); 185 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev);
185 int ret; 186 int ret;
186 187
187 ret = request_irq(pxa_rtc->irq_1Hz, pxa_rtc_irq, 0, 188 ret = request_irq(pxa_rtc->sa1100_rtc.irq_1hz, pxa_rtc_irq, 0,
188 "rtc 1Hz", dev); 189 "rtc 1Hz", dev);
189 if (ret < 0) { 190 if (ret < 0) {
190 dev_err(dev, "can't get irq %i, err %d\n", pxa_rtc->irq_1Hz, 191 dev_err(dev, "can't get irq %i, err %d\n",
191 ret); 192 pxa_rtc->sa1100_rtc.irq_1hz, ret);
192 goto err_irq_1Hz; 193 goto err_irq_1Hz;
193 } 194 }
194 ret = request_irq(pxa_rtc->irq_Alrm, pxa_rtc_irq, 0, 195 ret = request_irq(pxa_rtc->sa1100_rtc.irq_alarm, pxa_rtc_irq, 0,
195 "rtc Alrm", dev); 196 "rtc Alrm", dev);
196 if (ret < 0) { 197 if (ret < 0) {
197 dev_err(dev, "can't get irq %i, err %d\n", pxa_rtc->irq_Alrm, 198 dev_err(dev, "can't get irq %i, err %d\n",
198 ret); 199 pxa_rtc->sa1100_rtc.irq_alarm, ret);
199 goto err_irq_Alrm; 200 goto err_irq_Alrm;
200 } 201 }
201 202
202 return 0; 203 return 0;
203 204
204err_irq_Alrm: 205err_irq_Alrm:
205 free_irq(pxa_rtc->irq_1Hz, dev); 206 free_irq(pxa_rtc->sa1100_rtc.irq_1hz, dev);
206err_irq_1Hz: 207err_irq_1Hz:
207 return ret; 208 return ret;
208} 209}
@@ -215,8 +216,8 @@ static void pxa_rtc_release(struct device *dev)
215 rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); 216 rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE);
216 spin_unlock_irq(&pxa_rtc->lock); 217 spin_unlock_irq(&pxa_rtc->lock);
217 218
218 free_irq(pxa_rtc->irq_Alrm, dev); 219 free_irq(pxa_rtc->sa1100_rtc.irq_1hz, dev);
219 free_irq(pxa_rtc->irq_1Hz, dev); 220 free_irq(pxa_rtc->sa1100_rtc.irq_alarm, dev);
220} 221}
221 222
222static int pxa_alarm_irq_enable(struct device *dev, unsigned int enabled) 223static int pxa_alarm_irq_enable(struct device *dev, unsigned int enabled)
@@ -320,12 +321,13 @@ static int __init pxa_rtc_probe(struct platform_device *pdev)
320{ 321{
321 struct device *dev = &pdev->dev; 322 struct device *dev = &pdev->dev;
322 struct pxa_rtc *pxa_rtc; 323 struct pxa_rtc *pxa_rtc;
324 struct sa1100_rtc *sa1100_rtc;
323 int ret; 325 int ret;
324 u32 rttr;
325 326
326 pxa_rtc = devm_kzalloc(dev, sizeof(*pxa_rtc), GFP_KERNEL); 327 pxa_rtc = devm_kzalloc(dev, sizeof(*pxa_rtc), GFP_KERNEL);
327 if (!pxa_rtc) 328 if (!pxa_rtc)
328 return -ENOMEM; 329 return -ENOMEM;
330 sa1100_rtc = &pxa_rtc->sa1100_rtc;
329 331
330 spin_lock_init(&pxa_rtc->lock); 332 spin_lock_init(&pxa_rtc->lock);
331 platform_set_drvdata(pdev, pxa_rtc); 333 platform_set_drvdata(pdev, pxa_rtc);
@@ -336,13 +338,13 @@ static int __init pxa_rtc_probe(struct platform_device *pdev)
336 return -ENXIO; 338 return -ENXIO;
337 } 339 }
338 340
339 pxa_rtc->irq_1Hz = platform_get_irq(pdev, 0); 341 sa1100_rtc->irq_1hz = platform_get_irq(pdev, 0);
340 if (pxa_rtc->irq_1Hz < 0) { 342 if (sa1100_rtc->irq_1hz < 0) {
341 dev_err(dev, "No 1Hz IRQ resource defined\n"); 343 dev_err(dev, "No 1Hz IRQ resource defined\n");
342 return -ENXIO; 344 return -ENXIO;
343 } 345 }
344 pxa_rtc->irq_Alrm = platform_get_irq(pdev, 1); 346 sa1100_rtc->irq_alarm = platform_get_irq(pdev, 1);
345 if (pxa_rtc->irq_Alrm < 0) { 347 if (sa1100_rtc->irq_alarm < 0) {
346 dev_err(dev, "No alarm IRQ resource defined\n"); 348 dev_err(dev, "No alarm IRQ resource defined\n");
347 return -ENXIO; 349 return -ENXIO;
348 } 350 }
@@ -354,15 +356,10 @@ static int __init pxa_rtc_probe(struct platform_device *pdev)
354 return -ENOMEM; 356 return -ENOMEM;
355 } 357 }
356 358
357 /* 359 ret = sa1100_rtc_init(pdev, sa1100_rtc);
358 * If the clock divider is uninitialized then reset it to the 360 if (!ret) {
359 * default value to get the 1Hz clock. 361 dev_err(dev, "Unable to init SA1100 RTC sub-device\n");
360 */ 362 return ret;
361 if (rtc_readl(pxa_rtc, RTTR) == 0) {
362 rttr = RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16);
363 rtc_writel(pxa_rtc, RTTR, rttr);
364 dev_warn(dev, "warning: initializing default clock"
365 " divider/trim value\n");
366 } 363 }
367 364
368 rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); 365 rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE);
@@ -402,7 +399,7 @@ static int pxa_rtc_suspend(struct device *dev)
402 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); 399 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev);
403 400
404 if (device_may_wakeup(dev)) 401 if (device_may_wakeup(dev))
405 enable_irq_wake(pxa_rtc->irq_Alrm); 402 enable_irq_wake(pxa_rtc->sa1100_rtc.irq_alarm);
406 return 0; 403 return 0;
407} 404}
408 405
@@ -411,7 +408,7 @@ static int pxa_rtc_resume(struct device *dev)
411 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); 408 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev);
412 409
413 if (device_may_wakeup(dev)) 410 if (device_may_wakeup(dev))
414 disable_irq_wake(pxa_rtc->irq_Alrm); 411 disable_irq_wake(pxa_rtc->sa1100_rtc.irq_alarm);
415 return 0; 412 return 0;
416} 413}
417#endif 414#endif