Skip to content

Commit 3cdf4ad

Browse files
robherringalexandrebelloni
authored andcommitted
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 <[email protected]> Cc: Daniel Mack <[email protected]> Cc: Haojian Zhuang <[email protected]> Cc: Robert Jarzmik <[email protected]> Cc: Russell King <[email protected]> Cc: Alessandro Zummo <[email protected]> Cc: Alexandre Belloni <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 8c0961b commit 3cdf4ad

File tree

4 files changed

+31
-34
lines changed

4 files changed

+31
-34
lines changed

arch/arm/mach-pxa/pxa27x.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ static struct platform_device *devices[] __initdata = {
282282
&pxa_device_asoc_ssp2,
283283
&pxa_device_asoc_ssp3,
284284
&pxa_device_asoc_platform,
285-
&sa1100_device_rtc,
286285
&pxa_device_rtc,
287286
&pxa27x_device_ssp1,
288287
&pxa27x_device_ssp2,

arch/arm/mach-pxa/pxa3xx.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ static struct platform_device *devices[] __initdata = {
394394
&pxa_device_asoc_ssp3,
395395
&pxa_device_asoc_ssp4,
396396
&pxa_device_asoc_platform,
397-
&sa1100_device_rtc,
398397
&pxa_device_rtc,
399398
&pxa3xx_device_ssp1,
400399
&pxa3xx_device_ssp2,

drivers/rtc/Kconfig

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,11 +1306,13 @@ config RTC_DRV_GENERIC
13061306
just say Y.
13071307

13081308
config RTC_DRV_PXA
1309-
tristate "PXA27x/PXA3xx"
1310-
depends on ARCH_PXA
1311-
help
1312-
If you say Y here you will get access to the real time clock
1313-
built into your PXA27x or PXA3xx CPU.
1309+
tristate "PXA27x/PXA3xx"
1310+
depends on ARCH_PXA
1311+
select RTC_DRV_SA1100
1312+
help
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.
13141316

13151317
This RTC driver uses PXA RTC registers available since pxa27x
13161318
series (RDxR, RYxR) instead of legacy RCNR, RTAR.

drivers/rtc/rtc-pxa.c

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
#include <mach/hardware.h>
3434

35+
#include "rtc-sa1100.h"
36+
3537
#define RTC_DEF_DIVIDER (32768 - 1)
3638
#define RTC_DEF_TRIM 0
3739
#define MAXFREQ_PERIODIC 1000
@@ -86,10 +88,9 @@
8688
__raw_writel((value), (pxa_rtc)->base + (reg))
8789

8890
struct pxa_rtc {
91+
struct sa1100_rtc sa1100_rtc;
8992
struct resource *ress;
9093
void __iomem *base;
91-
int irq_1Hz;
92-
int irq_Alrm;
9394
struct rtc_device *rtc;
9495
spinlock_t lock; /* Protects this structure */
9596
};
@@ -184,25 +185,25 @@ static int pxa_rtc_open(struct device *dev)
184185
struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev);
185186
int ret;
186187

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,
188189
"rtc 1Hz", dev);
189190
if (ret < 0) {
190-
dev_err(dev, "can't get irq %i, err %d\n", pxa_rtc->irq_1Hz,
191-
ret);
191+
dev_err(dev, "can't get irq %i, err %d\n",
192+
pxa_rtc->sa1100_rtc.irq_1hz, ret);
192193
goto err_irq_1Hz;
193194
}
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,
195196
"rtc Alrm", dev);
196197
if (ret < 0) {
197-
dev_err(dev, "can't get irq %i, err %d\n", pxa_rtc->irq_Alrm,
198-
ret);
198+
dev_err(dev, "can't get irq %i, err %d\n",
199+
pxa_rtc->sa1100_rtc.irq_alarm, ret);
199200
goto err_irq_Alrm;
200201
}
201202

202203
return 0;
203204

204205
err_irq_Alrm:
205-
free_irq(pxa_rtc->irq_1Hz, dev);
206+
free_irq(pxa_rtc->sa1100_rtc.irq_1hz, dev);
206207
err_irq_1Hz:
207208
return ret;
208209
}
@@ -215,8 +216,8 @@ static void pxa_rtc_release(struct device *dev)
215216
rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE);
216217
spin_unlock_irq(&pxa_rtc->lock);
217218

218-
free_irq(pxa_rtc->irq_Alrm, dev);
219-
free_irq(pxa_rtc->irq_1Hz, dev);
219+
free_irq(pxa_rtc->sa1100_rtc.irq_1hz, dev);
220+
free_irq(pxa_rtc->sa1100_rtc.irq_alarm, dev);
220221
}
221222

222223
static 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)
320321
{
321322
struct device *dev = &pdev->dev;
322323
struct pxa_rtc *pxa_rtc;
324+
struct sa1100_rtc *sa1100_rtc;
323325
int ret;
324-
u32 rttr;
325326

326327
pxa_rtc = devm_kzalloc(dev, sizeof(*pxa_rtc), GFP_KERNEL);
327328
if (!pxa_rtc)
328329
return -ENOMEM;
330+
sa1100_rtc = &pxa_rtc->sa1100_rtc;
329331

330332
spin_lock_init(&pxa_rtc->lock);
331333
platform_set_drvdata(pdev, pxa_rtc);
@@ -336,13 +338,13 @@ static int __init pxa_rtc_probe(struct platform_device *pdev)
336338
return -ENXIO;
337339
}
338340

339-
pxa_rtc->irq_1Hz = platform_get_irq(pdev, 0);
340-
if (pxa_rtc->irq_1Hz < 0) {
341+
sa1100_rtc->irq_1hz = platform_get_irq(pdev, 0);
342+
if (sa1100_rtc->irq_1hz < 0) {
341343
dev_err(dev, "No 1Hz IRQ resource defined\n");
342344
return -ENXIO;
343345
}
344-
pxa_rtc->irq_Alrm = platform_get_irq(pdev, 1);
345-
if (pxa_rtc->irq_Alrm < 0) {
346+
sa1100_rtc->irq_alarm = platform_get_irq(pdev, 1);
347+
if (sa1100_rtc->irq_alarm < 0) {
346348
dev_err(dev, "No alarm IRQ resource defined\n");
347349
return -ENXIO;
348350
}
@@ -354,15 +356,10 @@ static int __init pxa_rtc_probe(struct platform_device *pdev)
354356
return -ENOMEM;
355357
}
356358

357-
/*
358-
* If the clock divider is uninitialized then reset it to the
359-
* default value to get the 1Hz clock.
360-
*/
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");
359+
ret = sa1100_rtc_init(pdev, sa1100_rtc);
360+
if (!ret) {
361+
dev_err(dev, "Unable to init SA1100 RTC sub-device\n");
362+
return ret;
366363
}
367364

368365
rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE);
@@ -402,7 +399,7 @@ static int pxa_rtc_suspend(struct device *dev)
402399
struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev);
403400

404401
if (device_may_wakeup(dev))
405-
enable_irq_wake(pxa_rtc->irq_Alrm);
402+
enable_irq_wake(pxa_rtc->sa1100_rtc.irq_alarm);
406403
return 0;
407404
}
408405

@@ -411,7 +408,7 @@ static int pxa_rtc_resume(struct device *dev)
411408
struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev);
412409

413410
if (device_may_wakeup(dev))
414-
disable_irq_wake(pxa_rtc->irq_Alrm);
411+
disable_irq_wake(pxa_rtc->sa1100_rtc.irq_alarm);
415412
return 0;
416413
}
417414
#endif

0 commit comments

Comments
 (0)