diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-27 19:41:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-27 19:41:24 -0400 |
commit | 34800598b2eebe061445216473b1e4c2ff5cba99 (patch) | |
tree | a6d0eb6fe45d9480888d7ddb34840e172ed80e56 /drivers/rtc | |
parent | 46b407ca4a6149c8d27fcec1881d4f184bec7c77 (diff) | |
parent | 511f1cb6d426938fabf9c6d69ce4861b66ffd919 (diff) |
Merge tag 'drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull "ARM: driver specific updates" from Arnd Bergmann:
"These are all specific to some driver. They are typically the
platform side of a change in the drivers directory, such as adding a
new driver or extending the interface to the platform. In cases where
there is no maintainer for the driver, or the maintainer prefers to
have the platform changes in the same branch as the driver changes,
the patches to the drivers are included as well.
A much smaller set of driver updates that depend on other branches
getting merged first will be sent later.
The new export of tegra_chip_uid conflicts with other changes in
fuse.c. In rtc-sa1100.c, the global removal of IRQF_DISABLED
conflicts with the cleanup of the interrupt handling of that driver.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>"
Fixed up aforementioned trivial conflicts.
* tag 'drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (94 commits)
ARM: SAMSUNG: change the name from s3c-sdhci to exynos4-sdhci
mmc: sdhci-s3c: add platform data for the second capability
ARM: SAMSUNG: support the second capability for samsung-soc
ARM: EXYNOS: add support DMA for EXYNOS4X12 SoC
ARM: EXYNOS: Add apb_pclk clkdev entry for mdma1
ARM: EXYNOS: Enable MDMA driver
regulator: Remove bq24022 regulator driver
rtc: sa1100: add OF support
pxa: magician/hx4700: Convert to gpio-regulator from bq24022
ARM: OMAP3+: SmartReflex: fix error handling
ARM: OMAP3+: SmartReflex: fix the use of debugfs_create_* API
ARM: OMAP3+: SmartReflex: micro-optimization for sanity check
ARM: OMAP3+: SmartReflex: misc cleanups
ARM: OMAP3+: SmartReflex: move late_initcall() closer to its argument
ARM: OMAP3+: SmartReflex: add missing platform_set_drvdata()
ARM: OMAP3+: hwmod: add SmartReflex IRQs
ARM: OMAP3+: SmartReflex: clear ERRCONFIG_VPBOUNDINTST only on a need
ARM: OMAP3+: SmartReflex: Fix status masking in ERRCONFIG register
ARM: OMAP3+: SmartReflex: Add a shutdown hook
ARM: OMAP3+: SmartReflex Class3: disable errorgen before disable VP
...
Conflicts:
arch/arm/mach-tegra/Makefile
arch/arm/mach-tegra/fuse.c
drivers/rtc/rtc-sa1100.c
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/Kconfig | 4 | ||||
-rw-r--r-- | drivers/rtc/rtc-s3c.c | 71 | ||||
-rw-r--r-- | drivers/rtc/rtc-sa1100.c | 127 |
3 files changed, 154 insertions, 48 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 4768a9d28375..8c8377d50c4c 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -780,8 +780,8 @@ config RTC_DRV_EP93XX | |||
780 | will be called rtc-ep93xx. | 780 | will be called rtc-ep93xx. |
781 | 781 | ||
782 | config RTC_DRV_SA1100 | 782 | config RTC_DRV_SA1100 |
783 | tristate "SA11x0/PXA2xx" | 783 | tristate "SA11x0/PXA2xx/PXA910" |
784 | depends on ARCH_SA1100 || ARCH_PXA | 784 | depends on ARCH_SA1100 || ARCH_PXA || ARCH_MMP |
785 | help | 785 | help |
786 | If you say Y here you will get access to the real time clock | 786 | If you say Y here you will get access to the real time clock |
787 | built into your SA11x0 or PXA2xx CPU. | 787 | built into your SA11x0 or PXA2xx CPU. |
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index c543f6f1eec2..9ccea134a996 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -35,6 +35,8 @@ | |||
35 | 35 | ||
36 | enum s3c_cpu_type { | 36 | enum s3c_cpu_type { |
37 | TYPE_S3C2410, | 37 | TYPE_S3C2410, |
38 | TYPE_S3C2416, | ||
39 | TYPE_S3C2443, | ||
38 | TYPE_S3C64XX, | 40 | TYPE_S3C64XX, |
39 | }; | 41 | }; |
40 | 42 | ||
@@ -132,6 +134,7 @@ static int s3c_rtc_setfreq(struct device *dev, int freq) | |||
132 | struct platform_device *pdev = to_platform_device(dev); | 134 | struct platform_device *pdev = to_platform_device(dev); |
133 | struct rtc_device *rtc_dev = platform_get_drvdata(pdev); | 135 | struct rtc_device *rtc_dev = platform_get_drvdata(pdev); |
134 | unsigned int tmp = 0; | 136 | unsigned int tmp = 0; |
137 | int val; | ||
135 | 138 | ||
136 | if (!is_power_of_2(freq)) | 139 | if (!is_power_of_2(freq)) |
137 | return -EINVAL; | 140 | return -EINVAL; |
@@ -139,12 +142,22 @@ static int s3c_rtc_setfreq(struct device *dev, int freq) | |||
139 | clk_enable(rtc_clk); | 142 | clk_enable(rtc_clk); |
140 | spin_lock_irq(&s3c_rtc_pie_lock); | 143 | spin_lock_irq(&s3c_rtc_pie_lock); |
141 | 144 | ||
142 | if (s3c_rtc_cpu_type == TYPE_S3C2410) { | 145 | if (s3c_rtc_cpu_type != TYPE_S3C64XX) { |
143 | tmp = readb(s3c_rtc_base + S3C2410_TICNT); | 146 | tmp = readb(s3c_rtc_base + S3C2410_TICNT); |
144 | tmp &= S3C2410_TICNT_ENABLE; | 147 | tmp &= S3C2410_TICNT_ENABLE; |
145 | } | 148 | } |
146 | 149 | ||
147 | tmp |= (rtc_dev->max_user_freq / freq)-1; | 150 | val = (rtc_dev->max_user_freq / freq) - 1; |
151 | |||
152 | if (s3c_rtc_cpu_type == TYPE_S3C2416 || s3c_rtc_cpu_type == TYPE_S3C2443) { | ||
153 | tmp |= S3C2443_TICNT_PART(val); | ||
154 | writel(S3C2443_TICNT1_PART(val), s3c_rtc_base + S3C2443_TICNT1); | ||
155 | |||
156 | if (s3c_rtc_cpu_type == TYPE_S3C2416) | ||
157 | writel(S3C2416_TICNT2_PART(val), s3c_rtc_base + S3C2416_TICNT2); | ||
158 | } else { | ||
159 | tmp |= val; | ||
160 | } | ||
148 | 161 | ||
149 | writel(tmp, s3c_rtc_base + S3C2410_TICNT); | 162 | writel(tmp, s3c_rtc_base + S3C2410_TICNT); |
150 | spin_unlock_irq(&s3c_rtc_pie_lock); | 163 | spin_unlock_irq(&s3c_rtc_pie_lock); |
@@ -371,7 +384,7 @@ static void s3c_rtc_enable(struct platform_device *pdev, int en) | |||
371 | tmp &= ~S3C2410_RTCCON_RTCEN; | 384 | tmp &= ~S3C2410_RTCCON_RTCEN; |
372 | writew(tmp, base + S3C2410_RTCCON); | 385 | writew(tmp, base + S3C2410_RTCCON); |
373 | 386 | ||
374 | if (s3c_rtc_cpu_type == TYPE_S3C2410) { | 387 | if (s3c_rtc_cpu_type != TYPE_S3C64XX) { |
375 | tmp = readb(base + S3C2410_TICNT); | 388 | tmp = readb(base + S3C2410_TICNT); |
376 | tmp &= ~S3C2410_TICNT_ENABLE; | 389 | tmp &= ~S3C2410_TICNT_ENABLE; |
377 | writeb(tmp, base + S3C2410_TICNT); | 390 | writeb(tmp, base + S3C2410_TICNT); |
@@ -428,12 +441,27 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev) | |||
428 | return 0; | 441 | return 0; |
429 | } | 442 | } |
430 | 443 | ||
444 | static const struct of_device_id s3c_rtc_dt_match[]; | ||
445 | |||
446 | static inline int s3c_rtc_get_driver_data(struct platform_device *pdev) | ||
447 | { | ||
448 | #ifdef CONFIG_OF | ||
449 | if (pdev->dev.of_node) { | ||
450 | const struct of_device_id *match; | ||
451 | match = of_match_node(s3c_rtc_dt_match, pdev->dev.of_node); | ||
452 | return match->data; | ||
453 | } | ||
454 | #endif | ||
455 | return platform_get_device_id(pdev)->driver_data; | ||
456 | } | ||
457 | |||
431 | static int __devinit s3c_rtc_probe(struct platform_device *pdev) | 458 | static int __devinit s3c_rtc_probe(struct platform_device *pdev) |
432 | { | 459 | { |
433 | struct rtc_device *rtc; | 460 | struct rtc_device *rtc; |
434 | struct rtc_time rtc_tm; | 461 | struct rtc_time rtc_tm; |
435 | struct resource *res; | 462 | struct resource *res; |
436 | int ret; | 463 | int ret; |
464 | int tmp; | ||
437 | 465 | ||
438 | pr_debug("%s: probe=%p\n", __func__, pdev); | 466 | pr_debug("%s: probe=%p\n", __func__, pdev); |
439 | 467 | ||
@@ -508,13 +536,7 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) | |||
508 | goto err_nortc; | 536 | goto err_nortc; |
509 | } | 537 | } |
510 | 538 | ||
511 | #ifdef CONFIG_OF | 539 | s3c_rtc_cpu_type = s3c_rtc_get_driver_data(pdev); |
512 | if (pdev->dev.of_node) | ||
513 | s3c_rtc_cpu_type = of_device_is_compatible(pdev->dev.of_node, | ||
514 | "samsung,s3c6410-rtc") ? TYPE_S3C64XX : TYPE_S3C2410; | ||
515 | else | ||
516 | #endif | ||
517 | s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data; | ||
518 | 540 | ||
519 | /* Check RTC Time */ | 541 | /* Check RTC Time */ |
520 | 542 | ||
@@ -533,11 +555,17 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) | |||
533 | dev_warn(&pdev->dev, "warning: invalid RTC value so initializing it\n"); | 555 | dev_warn(&pdev->dev, "warning: invalid RTC value so initializing it\n"); |
534 | } | 556 | } |
535 | 557 | ||
536 | if (s3c_rtc_cpu_type == TYPE_S3C64XX) | 558 | if (s3c_rtc_cpu_type != TYPE_S3C2410) |
537 | rtc->max_user_freq = 32768; | 559 | rtc->max_user_freq = 32768; |
538 | else | 560 | else |
539 | rtc->max_user_freq = 128; | 561 | rtc->max_user_freq = 128; |
540 | 562 | ||
563 | if (s3c_rtc_cpu_type == TYPE_S3C2416 || s3c_rtc_cpu_type == TYPE_S3C2443) { | ||
564 | tmp = readw(s3c_rtc_base + S3C2410_RTCCON); | ||
565 | tmp |= S3C2443_RTCCON_TICSEL; | ||
566 | writew(tmp, s3c_rtc_base + S3C2410_RTCCON); | ||
567 | } | ||
568 | |||
541 | platform_set_drvdata(pdev, rtc); | 569 | platform_set_drvdata(pdev, rtc); |
542 | 570 | ||
543 | s3c_rtc_setfreq(&pdev->dev, 1); | 571 | s3c_rtc_setfreq(&pdev->dev, 1); |
@@ -638,8 +666,19 @@ static int s3c_rtc_resume(struct platform_device *pdev) | |||
638 | 666 | ||
639 | #ifdef CONFIG_OF | 667 | #ifdef CONFIG_OF |
640 | static const struct of_device_id s3c_rtc_dt_match[] = { | 668 | static const struct of_device_id s3c_rtc_dt_match[] = { |
641 | { .compatible = "samsung,s3c2410-rtc" }, | 669 | { |
642 | { .compatible = "samsung,s3c6410-rtc" }, | 670 | .compatible = "samsung,s3c2410-rtc" |
671 | .data = TYPE_S3C2410, | ||
672 | }, { | ||
673 | .compatible = "samsung,s3c2416-rtc" | ||
674 | .data = TYPE_S3C2416, | ||
675 | }, { | ||
676 | .compatible = "samsung,s3c2443-rtc" | ||
677 | .data = TYPE_S3C2443, | ||
678 | }, { | ||
679 | .compatible = "samsung,s3c6410-rtc" | ||
680 | .data = TYPE_S3C64XX, | ||
681 | }, | ||
643 | {}, | 682 | {}, |
644 | }; | 683 | }; |
645 | MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match); | 684 | MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match); |
@@ -652,6 +691,12 @@ static struct platform_device_id s3c_rtc_driver_ids[] = { | |||
652 | .name = "s3c2410-rtc", | 691 | .name = "s3c2410-rtc", |
653 | .driver_data = TYPE_S3C2410, | 692 | .driver_data = TYPE_S3C2410, |
654 | }, { | 693 | }, { |
694 | .name = "s3c2416-rtc", | ||
695 | .driver_data = TYPE_S3C2416, | ||
696 | }, { | ||
697 | .name = "s3c2443-rtc", | ||
698 | .driver_data = TYPE_S3C2443, | ||
699 | }, { | ||
655 | .name = "s3c64xx-rtc", | 700 | .name = "s3c64xx-rtc", |
656 | .driver_data = TYPE_S3C64XX, | 701 | .driver_data = TYPE_S3C64XX, |
657 | }, | 702 | }, |
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index 44cd81c72ea1..fa512ed42017 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -23,35 +23,44 @@ | |||
23 | 23 | ||
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/clk.h> | ||
26 | #include <linux/rtc.h> | 27 | #include <linux/rtc.h> |
27 | #include <linux/init.h> | 28 | #include <linux/init.h> |
28 | #include <linux/fs.h> | 29 | #include <linux/fs.h> |
29 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | #include <linux/slab.h> | ||
30 | #include <linux/string.h> | 32 | #include <linux/string.h> |
33 | #include <linux/of.h> | ||
31 | #include <linux/pm.h> | 34 | #include <linux/pm.h> |
32 | #include <linux/bitops.h> | 35 | #include <linux/bitops.h> |
33 | 36 | ||
34 | #include <mach/hardware.h> | 37 | #include <mach/hardware.h> |
35 | #include <asm/irq.h> | 38 | #include <asm/irq.h> |
36 | 39 | ||
37 | #ifdef CONFIG_ARCH_PXA | 40 | #if defined(CONFIG_ARCH_PXA) || defined(CONFIG_ARCH_MMP) |
38 | #include <mach/regs-rtc.h> | 41 | #include <mach/regs-rtc.h> |
39 | #endif | 42 | #endif |
40 | 43 | ||
41 | #define RTC_DEF_DIVIDER (32768 - 1) | 44 | #define RTC_DEF_DIVIDER (32768 - 1) |
42 | #define RTC_DEF_TRIM 0 | 45 | #define RTC_DEF_TRIM 0 |
43 | 46 | #define RTC_FREQ 1024 | |
44 | static const unsigned long RTC_FREQ = 1024; | 47 | |
45 | static DEFINE_SPINLOCK(sa1100_rtc_lock); | 48 | struct sa1100_rtc { |
49 | spinlock_t lock; | ||
50 | int irq_1hz; | ||
51 | int irq_alarm; | ||
52 | struct rtc_device *rtc; | ||
53 | struct clk *clk; | ||
54 | }; | ||
46 | 55 | ||
47 | static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) | 56 | static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) |
48 | { | 57 | { |
49 | struct platform_device *pdev = to_platform_device(dev_id); | 58 | struct sa1100_rtc *info = dev_get_drvdata(dev_id); |
50 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 59 | struct rtc_device *rtc = info->rtc; |
51 | unsigned int rtsr; | 60 | unsigned int rtsr; |
52 | unsigned long events = 0; | 61 | unsigned long events = 0; |
53 | 62 | ||
54 | spin_lock(&sa1100_rtc_lock); | 63 | spin_lock(&info->lock); |
55 | 64 | ||
56 | rtsr = RTSR; | 65 | rtsr = RTSR; |
57 | /* clear interrupt sources */ | 66 | /* clear interrupt sources */ |
@@ -87,26 +96,28 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) | |||
87 | 96 | ||
88 | rtc_update_irq(rtc, 1, events); | 97 | rtc_update_irq(rtc, 1, events); |
89 | 98 | ||
90 | spin_unlock(&sa1100_rtc_lock); | 99 | spin_unlock(&info->lock); |
91 | 100 | ||
92 | return IRQ_HANDLED; | 101 | return IRQ_HANDLED; |
93 | } | 102 | } |
94 | 103 | ||
95 | static int sa1100_rtc_open(struct device *dev) | 104 | static int sa1100_rtc_open(struct device *dev) |
96 | { | 105 | { |
106 | struct sa1100_rtc *info = dev_get_drvdata(dev); | ||
107 | struct rtc_device *rtc = info->rtc; | ||
97 | int ret; | 108 | int ret; |
98 | struct platform_device *plat_dev = to_platform_device(dev); | ||
99 | struct rtc_device *rtc = platform_get_drvdata(plat_dev); | ||
100 | 109 | ||
101 | ret = request_irq(IRQ_RTC1Hz, sa1100_rtc_interrupt, 0, "rtc 1Hz", dev); | 110 | ret = clk_prepare_enable(info->clk); |
111 | if (ret) | ||
112 | goto fail_clk; | ||
113 | ret = request_irq(info->irq_1hz, sa1100_rtc_interrupt, 0, "rtc 1Hz", dev); | ||
102 | if (ret) { | 114 | if (ret) { |
103 | dev_err(dev, "IRQ %d already in use.\n", IRQ_RTC1Hz); | 115 | dev_err(dev, "IRQ %d already in use.\n", info->irq_1hz); |
104 | goto fail_ui; | 116 | goto fail_ui; |
105 | } | 117 | } |
106 | ret = request_irq(IRQ_RTCAlrm, sa1100_rtc_interrupt, 0, | 118 | ret = request_irq(info->irq_alarm, sa1100_rtc_interrupt, 0, "rtc Alrm", dev); |
107 | "rtc Alrm", dev); | ||
108 | if (ret) { | 119 | if (ret) { |
109 | dev_err(dev, "IRQ %d already in use.\n", IRQ_RTCAlrm); | 120 | dev_err(dev, "IRQ %d already in use.\n", info->irq_alarm); |
110 | goto fail_ai; | 121 | goto fail_ai; |
111 | } | 122 | } |
112 | rtc->max_user_freq = RTC_FREQ; | 123 | rtc->max_user_freq = RTC_FREQ; |
@@ -115,29 +126,36 @@ static int sa1100_rtc_open(struct device *dev) | |||
115 | return 0; | 126 | return 0; |
116 | 127 | ||
117 | fail_ai: | 128 | fail_ai: |
118 | free_irq(IRQ_RTC1Hz, dev); | 129 | free_irq(info->irq_1hz, dev); |
119 | fail_ui: | 130 | fail_ui: |
131 | clk_disable_unprepare(info->clk); | ||
132 | fail_clk: | ||
120 | return ret; | 133 | return ret; |
121 | } | 134 | } |
122 | 135 | ||
123 | static void sa1100_rtc_release(struct device *dev) | 136 | static void sa1100_rtc_release(struct device *dev) |
124 | { | 137 | { |
125 | spin_lock_irq(&sa1100_rtc_lock); | 138 | struct sa1100_rtc *info = dev_get_drvdata(dev); |
139 | |||
140 | spin_lock_irq(&info->lock); | ||
126 | RTSR = 0; | 141 | RTSR = 0; |
127 | spin_unlock_irq(&sa1100_rtc_lock); | 142 | spin_unlock_irq(&info->lock); |
128 | 143 | ||
129 | free_irq(IRQ_RTCAlrm, dev); | 144 | free_irq(info->irq_alarm, dev); |
130 | free_irq(IRQ_RTC1Hz, dev); | 145 | free_irq(info->irq_1hz, dev); |
146 | clk_disable_unprepare(info->clk); | ||
131 | } | 147 | } |
132 | 148 | ||
133 | static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | 149 | static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
134 | { | 150 | { |
135 | spin_lock_irq(&sa1100_rtc_lock); | 151 | struct sa1100_rtc *info = dev_get_drvdata(dev); |
152 | |||
153 | spin_lock_irq(&info->lock); | ||
136 | if (enabled) | 154 | if (enabled) |
137 | RTSR |= RTSR_ALE; | 155 | RTSR |= RTSR_ALE; |
138 | else | 156 | else |
139 | RTSR &= ~RTSR_ALE; | 157 | RTSR &= ~RTSR_ALE; |
140 | spin_unlock_irq(&sa1100_rtc_lock); | 158 | spin_unlock_irq(&info->lock); |
141 | return 0; | 159 | return 0; |
142 | } | 160 | } |
143 | 161 | ||
@@ -170,10 +188,11 @@ static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
170 | 188 | ||
171 | static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 189 | static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
172 | { | 190 | { |
191 | struct sa1100_rtc *info = dev_get_drvdata(dev); | ||
173 | unsigned long time; | 192 | unsigned long time; |
174 | int ret; | 193 | int ret; |
175 | 194 | ||
176 | spin_lock_irq(&sa1100_rtc_lock); | 195 | spin_lock_irq(&info->lock); |
177 | ret = rtc_tm_to_time(&alrm->time, &time); | 196 | ret = rtc_tm_to_time(&alrm->time, &time); |
178 | if (ret != 0) | 197 | if (ret != 0) |
179 | goto out; | 198 | goto out; |
@@ -184,7 +203,7 @@ static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
184 | else | 203 | else |
185 | RTSR &= ~RTSR_ALE; | 204 | RTSR &= ~RTSR_ALE; |
186 | out: | 205 | out: |
187 | spin_unlock_irq(&sa1100_rtc_lock); | 206 | spin_unlock_irq(&info->lock); |
188 | 207 | ||
189 | return ret; | 208 | return ret; |
190 | } | 209 | } |
@@ -211,6 +230,27 @@ static const struct rtc_class_ops sa1100_rtc_ops = { | |||
211 | static int sa1100_rtc_probe(struct platform_device *pdev) | 230 | static int sa1100_rtc_probe(struct platform_device *pdev) |
212 | { | 231 | { |
213 | struct rtc_device *rtc; | 232 | struct rtc_device *rtc; |
233 | struct sa1100_rtc *info; | ||
234 | int irq_1hz, irq_alarm, ret = 0; | ||
235 | |||
236 | irq_1hz = platform_get_irq_byname(pdev, "rtc 1Hz"); | ||
237 | irq_alarm = platform_get_irq_byname(pdev, "rtc alarm"); | ||
238 | if (irq_1hz < 0 || irq_alarm < 0) | ||
239 | return -ENODEV; | ||
240 | |||
241 | info = kzalloc(sizeof(struct sa1100_rtc), GFP_KERNEL); | ||
242 | if (!info) | ||
243 | return -ENOMEM; | ||
244 | info->clk = clk_get(&pdev->dev, NULL); | ||
245 | if (IS_ERR(info->clk)) { | ||
246 | dev_err(&pdev->dev, "failed to find rtc clock source\n"); | ||
247 | ret = PTR_ERR(info->clk); | ||
248 | goto err_clk; | ||
249 | } | ||
250 | info->irq_1hz = irq_1hz; | ||
251 | info->irq_alarm = irq_alarm; | ||
252 | spin_lock_init(&info->lock); | ||
253 | platform_set_drvdata(pdev, info); | ||
214 | 254 | ||
215 | /* | 255 | /* |
216 | * According to the manual we should be able to let RTTR be zero | 256 | * According to the manual we should be able to let RTTR be zero |
@@ -232,10 +272,11 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
232 | rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops, | 272 | rtc = rtc_device_register(pdev->name, &pdev->dev, &sa1100_rtc_ops, |
233 | THIS_MODULE); | 273 | THIS_MODULE); |
234 | 274 | ||
235 | if (IS_ERR(rtc)) | 275 | if (IS_ERR(rtc)) { |
236 | return PTR_ERR(rtc); | 276 | ret = PTR_ERR(rtc); |
237 | 277 | goto err_dev; | |
238 | platform_set_drvdata(pdev, rtc); | 278 | } |
279 | info->rtc = rtc; | ||
239 | 280 | ||
240 | /* Fix for a nasty initialization problem the in SA11xx RTSR register. | 281 | /* Fix for a nasty initialization problem the in SA11xx RTSR register. |
241 | * See also the comments in sa1100_rtc_interrupt(). | 282 | * See also the comments in sa1100_rtc_interrupt(). |
@@ -262,14 +303,24 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
262 | RTSR = RTSR_AL | RTSR_HZ; | 303 | RTSR = RTSR_AL | RTSR_HZ; |
263 | 304 | ||
264 | return 0; | 305 | return 0; |
306 | err_dev: | ||
307 | platform_set_drvdata(pdev, NULL); | ||
308 | clk_put(info->clk); | ||
309 | err_clk: | ||
310 | kfree(info); | ||
311 | return ret; | ||
265 | } | 312 | } |
266 | 313 | ||
267 | static int sa1100_rtc_remove(struct platform_device *pdev) | 314 | static int sa1100_rtc_remove(struct platform_device *pdev) |
268 | { | 315 | { |
269 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 316 | struct sa1100_rtc *info = platform_get_drvdata(pdev); |
270 | 317 | ||
271 | if (rtc) | 318 | if (info) { |
272 | rtc_device_unregister(rtc); | 319 | rtc_device_unregister(info->rtc); |
320 | clk_put(info->clk); | ||
321 | platform_set_drvdata(pdev, NULL); | ||
322 | kfree(info); | ||
323 | } | ||
273 | 324 | ||
274 | return 0; | 325 | return 0; |
275 | } | 326 | } |
@@ -277,15 +328,17 @@ static int sa1100_rtc_remove(struct platform_device *pdev) | |||
277 | #ifdef CONFIG_PM | 328 | #ifdef CONFIG_PM |
278 | static int sa1100_rtc_suspend(struct device *dev) | 329 | static int sa1100_rtc_suspend(struct device *dev) |
279 | { | 330 | { |
331 | struct sa1100_rtc *info = dev_get_drvdata(dev); | ||
280 | if (device_may_wakeup(dev)) | 332 | if (device_may_wakeup(dev)) |
281 | enable_irq_wake(IRQ_RTCAlrm); | 333 | enable_irq_wake(info->irq_alarm); |
282 | return 0; | 334 | return 0; |
283 | } | 335 | } |
284 | 336 | ||
285 | static int sa1100_rtc_resume(struct device *dev) | 337 | static int sa1100_rtc_resume(struct device *dev) |
286 | { | 338 | { |
339 | struct sa1100_rtc *info = dev_get_drvdata(dev); | ||
287 | if (device_may_wakeup(dev)) | 340 | if (device_may_wakeup(dev)) |
288 | disable_irq_wake(IRQ_RTCAlrm); | 341 | disable_irq_wake(info->irq_alarm); |
289 | return 0; | 342 | return 0; |
290 | } | 343 | } |
291 | 344 | ||
@@ -295,6 +348,13 @@ static const struct dev_pm_ops sa1100_rtc_pm_ops = { | |||
295 | }; | 348 | }; |
296 | #endif | 349 | #endif |
297 | 350 | ||
351 | static struct of_device_id sa1100_rtc_dt_ids[] = { | ||
352 | { .compatible = "mrvl,sa1100-rtc", }, | ||
353 | { .compatible = "mrvl,mmp-rtc", }, | ||
354 | {} | ||
355 | }; | ||
356 | MODULE_DEVICE_TABLE(of, sa1100_rtc_dt_ids); | ||
357 | |||
298 | static struct platform_driver sa1100_rtc_driver = { | 358 | static struct platform_driver sa1100_rtc_driver = { |
299 | .probe = sa1100_rtc_probe, | 359 | .probe = sa1100_rtc_probe, |
300 | .remove = sa1100_rtc_remove, | 360 | .remove = sa1100_rtc_remove, |
@@ -303,6 +363,7 @@ static struct platform_driver sa1100_rtc_driver = { | |||
303 | #ifdef CONFIG_PM | 363 | #ifdef CONFIG_PM |
304 | .pm = &sa1100_rtc_pm_ops, | 364 | .pm = &sa1100_rtc_pm_ops, |
305 | #endif | 365 | #endif |
366 | .of_match_table = sa1100_rtc_dt_ids, | ||
306 | }, | 367 | }, |
307 | }; | 368 | }; |
308 | 369 | ||