Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Rob Herring and committed by
Alexandre Belloni
3cdf4ad9 8c0961ba

+31 -34
-1
arch/arm/mach-pxa/pxa27x.c
··· 282 282 &pxa_device_asoc_ssp2, 283 283 &pxa_device_asoc_ssp3, 284 284 &pxa_device_asoc_platform, 285 - &sa1100_device_rtc, 286 285 &pxa_device_rtc, 287 286 &pxa27x_device_ssp1, 288 287 &pxa27x_device_ssp2,
-1
arch/arm/mach-pxa/pxa3xx.c
··· 394 394 &pxa_device_asoc_ssp3, 395 395 &pxa_device_asoc_ssp4, 396 396 &pxa_device_asoc_platform, 397 - &sa1100_device_rtc, 398 397 &pxa_device_rtc, 399 398 &pxa3xx_device_ssp1, 400 399 &pxa3xx_device_ssp2,
+7 -5
drivers/rtc/Kconfig
··· 1306 1306 just say Y. 1307 1307 1308 1308 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. 1314 1316 1315 1317 This RTC driver uses PXA RTC registers available since pxa27x 1316 1318 series (RDxR, RYxR) instead of legacy RCNR, RTAR.
+24 -27
drivers/rtc/rtc-pxa.c
··· 32 32 33 33 #include <mach/hardware.h> 34 34 35 + #include "rtc-sa1100.h" 36 + 35 37 #define RTC_DEF_DIVIDER (32768 - 1) 36 38 #define RTC_DEF_TRIM 0 37 39 #define MAXFREQ_PERIODIC 1000 ··· 88 86 __raw_writel((value), (pxa_rtc)->base + (reg)) 89 87 90 88 struct pxa_rtc { 89 + struct sa1100_rtc sa1100_rtc; 91 90 struct resource *ress; 92 91 void __iomem *base; 93 - int irq_1Hz; 94 - int irq_Alrm; 95 92 struct rtc_device *rtc; 96 93 spinlock_t lock; /* Protects this structure */ 97 94 }; ··· 185 184 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); 186 185 int ret; 187 186 188 - ret = request_irq(pxa_rtc->irq_1Hz, pxa_rtc_irq, 0, 187 + ret = request_irq(pxa_rtc->sa1100_rtc.irq_1hz, pxa_rtc_irq, 0, 189 188 "rtc 1Hz", dev); 190 189 if (ret < 0) { 191 - dev_err(dev, "can't get irq %i, err %d\n", pxa_rtc->irq_1Hz, 192 - ret); 190 + dev_err(dev, "can't get irq %i, err %d\n", 191 + pxa_rtc->sa1100_rtc.irq_1hz, ret); 193 192 goto err_irq_1Hz; 194 193 } 195 - ret = request_irq(pxa_rtc->irq_Alrm, pxa_rtc_irq, 0, 194 + ret = request_irq(pxa_rtc->sa1100_rtc.irq_alarm, pxa_rtc_irq, 0, 196 195 "rtc Alrm", dev); 197 196 if (ret < 0) { 198 - dev_err(dev, "can't get irq %i, err %d\n", pxa_rtc->irq_Alrm, 199 - ret); 197 + dev_err(dev, "can't get irq %i, err %d\n", 198 + pxa_rtc->sa1100_rtc.irq_alarm, ret); 200 199 goto err_irq_Alrm; 201 200 } 202 201 203 202 return 0; 204 203 205 204 err_irq_Alrm: 206 - free_irq(pxa_rtc->irq_1Hz, dev); 205 + free_irq(pxa_rtc->sa1100_rtc.irq_1hz, dev); 207 206 err_irq_1Hz: 208 207 return ret; 209 208 } ··· 216 215 rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); 217 216 spin_unlock_irq(&pxa_rtc->lock); 218 217 219 - free_irq(pxa_rtc->irq_Alrm, dev); 220 - free_irq(pxa_rtc->irq_1Hz, dev); 218 + free_irq(pxa_rtc->sa1100_rtc.irq_1hz, dev); 219 + free_irq(pxa_rtc->sa1100_rtc.irq_alarm, dev); 221 220 } 222 221 223 222 static int pxa_alarm_irq_enable(struct device *dev, unsigned int enabled) ··· 321 320 { 322 321 struct device *dev = &pdev->dev; 323 322 struct pxa_rtc *pxa_rtc; 323 + struct sa1100_rtc *sa1100_rtc; 324 324 int ret; 325 - u32 rttr; 326 325 327 326 pxa_rtc = devm_kzalloc(dev, sizeof(*pxa_rtc), GFP_KERNEL); 328 327 if (!pxa_rtc) 329 328 return -ENOMEM; 329 + sa1100_rtc = &pxa_rtc->sa1100_rtc; 330 330 331 331 spin_lock_init(&pxa_rtc->lock); 332 332 platform_set_drvdata(pdev, pxa_rtc); ··· 338 336 return -ENXIO; 339 337 } 340 338 341 - pxa_rtc->irq_1Hz = platform_get_irq(pdev, 0); 342 - if (pxa_rtc->irq_1Hz < 0) { 339 + sa1100_rtc->irq_1hz = platform_get_irq(pdev, 0); 340 + if (sa1100_rtc->irq_1hz < 0) { 343 341 dev_err(dev, "No 1Hz IRQ resource defined\n"); 344 342 return -ENXIO; 345 343 } 346 - pxa_rtc->irq_Alrm = platform_get_irq(pdev, 1); 347 - if (pxa_rtc->irq_Alrm < 0) { 344 + sa1100_rtc->irq_alarm = platform_get_irq(pdev, 1); 345 + if (sa1100_rtc->irq_alarm < 0) { 348 346 dev_err(dev, "No alarm IRQ resource defined\n"); 349 347 return -ENXIO; 350 348 } ··· 356 354 return -ENOMEM; 357 355 } 358 356 359 - /* 360 - * If the clock divider is uninitialized then reset it to the 361 - * default value to get the 1Hz clock. 362 - */ 363 - if (rtc_readl(pxa_rtc, RTTR) == 0) { 364 - rttr = RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16); 365 - rtc_writel(pxa_rtc, RTTR, rttr); 366 - dev_warn(dev, "warning: initializing default clock" 367 - " divider/trim value\n"); 357 + ret = sa1100_rtc_init(pdev, sa1100_rtc); 358 + if (!ret) { 359 + dev_err(dev, "Unable to init SA1100 RTC sub-device\n"); 360 + return ret; 368 361 } 369 362 370 363 rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); ··· 399 402 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); 400 403 401 404 if (device_may_wakeup(dev)) 402 - enable_irq_wake(pxa_rtc->irq_Alrm); 405 + enable_irq_wake(pxa_rtc->sa1100_rtc.irq_alarm); 403 406 return 0; 404 407 } 405 408 ··· 408 411 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); 409 412 410 413 if (device_may_wakeup(dev)) 411 - disable_irq_wake(pxa_rtc->irq_Alrm); 414 + disable_irq_wake(pxa_rtc->sa1100_rtc.irq_alarm); 412 415 return 0; 413 416 } 414 417 #endif