diff options
author | NeilBrown <neilb@suse.de> | 2010-05-21 18:31:36 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-05-21 18:31:36 -0400 |
commit | 19fdb9eefb21b72edbc365b838502780c392bad6 (patch) | |
tree | deae04c48532d6eab64ed4b0396737bb854b5506 /drivers/rtc | |
parent | be6800a73aa2f3dc14744c3b80e676d189789f04 (diff) | |
parent | 3ff195b011d7decf501a4d55aeed312731094796 (diff) |
Merge commit '3ff195b011d7decf501a4d55aeed312731094796' into for-linus
Conflicts:
drivers/md/md.c
- Resolved conflict in md_update_sb
- Added extra 'NULL' arg to new instance of sysfs_get_dirent.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/rtc')
49 files changed, 796 insertions, 55 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 6a1303759432..50ac047cd136 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -620,6 +620,16 @@ config RTC_DRV_NUC900 | |||
620 | 620 | ||
621 | comment "on-CPU RTC drivers" | 621 | comment "on-CPU RTC drivers" |
622 | 622 | ||
623 | config RTC_DRV_DAVINCI | ||
624 | tristate "TI DaVinci RTC" | ||
625 | depends on ARCH_DAVINCI_DM365 | ||
626 | help | ||
627 | If you say yes here you get support for the RTC on the | ||
628 | DaVinci platforms (DM365). | ||
629 | |||
630 | This driver can also be built as a module. If so, the module | ||
631 | will be called rtc-davinci. | ||
632 | |||
623 | config RTC_DRV_OMAP | 633 | config RTC_DRV_OMAP |
624 | tristate "TI OMAP1" | 634 | tristate "TI OMAP1" |
625 | depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 || ARCH_DAVINCI_DA8XX | 635 | depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 || ARCH_DAVINCI_DA8XX |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 44ef194a9573..245311a1348f 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
@@ -27,6 +27,7 @@ obj-$(CONFIG_RTC_DRV_BQ32K) += rtc-bq32k.o | |||
27 | obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o | 27 | obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o |
28 | obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o | 28 | obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o |
29 | obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o | 29 | obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o |
30 | obj-$(CONFIG_RTC_DRV_DAVINCI) += rtc-davinci.o | ||
30 | obj-$(CONFIG_RTC_DRV_DM355EVM) += rtc-dm355evm.o | 31 | obj-$(CONFIG_RTC_DRV_DM355EVM) += rtc-dm355evm.o |
31 | obj-$(CONFIG_RTC_DRV_DS1216) += rtc-ds1216.o | 32 | obj-$(CONFIG_RTC_DRV_DS1216) += rtc-ds1216.o |
32 | obj-$(CONFIG_RTC_DRV_DS1286) += rtc-ds1286.o | 33 | obj-$(CONFIG_RTC_DRV_DS1286) += rtc-ds1286.o |
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 40845c7e9322..565562ba6ac9 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/rtc.h> | 15 | #include <linux/rtc.h> |
16 | #include <linux/kdev_t.h> | 16 | #include <linux/kdev_t.h> |
17 | #include <linux/idr.h> | 17 | #include <linux/idr.h> |
18 | #include <linux/slab.h> | ||
18 | 19 | ||
19 | #include "rtc-core.h" | 20 | #include "rtc-core.h" |
20 | 21 | ||
diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c index 33c0e98243ee..bc90b091f195 100644 --- a/drivers/rtc/hctosys.c +++ b/drivers/rtc/hctosys.c | |||
@@ -22,48 +22,57 @@ | |||
22 | * the best guess is to add 0.5s. | 22 | * the best guess is to add 0.5s. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | int rtc_hctosys_ret = -ENODEV; | ||
26 | |||
25 | static int __init rtc_hctosys(void) | 27 | static int __init rtc_hctosys(void) |
26 | { | 28 | { |
27 | int err; | 29 | int err = -ENODEV; |
28 | struct rtc_time tm; | 30 | struct rtc_time tm; |
31 | struct timespec tv = { | ||
32 | .tv_nsec = NSEC_PER_SEC >> 1, | ||
33 | }; | ||
29 | struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); | 34 | struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); |
30 | 35 | ||
31 | if (rtc == NULL) { | 36 | if (rtc == NULL) { |
32 | printk("%s: unable to open rtc device (%s)\n", | 37 | pr_err("%s: unable to open rtc device (%s)\n", |
33 | __FILE__, CONFIG_RTC_HCTOSYS_DEVICE); | 38 | __FILE__, CONFIG_RTC_HCTOSYS_DEVICE); |
34 | return -ENODEV; | 39 | goto err_open; |
35 | } | 40 | } |
36 | 41 | ||
37 | err = rtc_read_time(rtc, &tm); | 42 | err = rtc_read_time(rtc, &tm); |
38 | if (err == 0) { | 43 | if (err) { |
39 | err = rtc_valid_tm(&tm); | 44 | dev_err(rtc->dev.parent, |
40 | if (err == 0) { | 45 | "hctosys: unable to read the hardware clock\n"); |
41 | struct timespec tv; | 46 | goto err_read; |
42 | 47 | ||
43 | tv.tv_nsec = NSEC_PER_SEC >> 1; | 48 | } |
44 | 49 | ||
45 | rtc_tm_to_time(&tm, &tv.tv_sec); | 50 | err = rtc_valid_tm(&tm); |
51 | if (err) { | ||
52 | dev_err(rtc->dev.parent, | ||
53 | "hctosys: invalid date/time\n"); | ||
54 | goto err_invalid; | ||
55 | } | ||
46 | 56 | ||
47 | do_settimeofday(&tv); | 57 | rtc_tm_to_time(&tm, &tv.tv_sec); |
48 | 58 | ||
49 | dev_info(rtc->dev.parent, | 59 | do_settimeofday(&tv); |
50 | "setting system clock to " | ||
51 | "%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n", | ||
52 | tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, | ||
53 | tm.tm_hour, tm.tm_min, tm.tm_sec, | ||
54 | (unsigned int) tv.tv_sec); | ||
55 | } | ||
56 | else | ||
57 | dev_err(rtc->dev.parent, | ||
58 | "hctosys: invalid date/time\n"); | ||
59 | } | ||
60 | else | ||
61 | dev_err(rtc->dev.parent, | ||
62 | "hctosys: unable to read the hardware clock\n"); | ||
63 | 60 | ||
61 | dev_info(rtc->dev.parent, | ||
62 | "setting system clock to " | ||
63 | "%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n", | ||
64 | tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, | ||
65 | tm.tm_hour, tm.tm_min, tm.tm_sec, | ||
66 | (unsigned int) tv.tv_sec); | ||
67 | |||
68 | err_invalid: | ||
69 | err_read: | ||
64 | rtc_class_close(rtc); | 70 | rtc_class_close(rtc); |
65 | 71 | ||
66 | return 0; | 72 | err_open: |
73 | rtc_hctosys_ret = err; | ||
74 | |||
75 | return err; | ||
67 | } | 76 | } |
68 | 77 | ||
69 | late_initcall(rtc_hctosys); | 78 | late_initcall(rtc_hctosys); |
diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c index 8825695777df..b2752b6e7a2f 100644 --- a/drivers/rtc/rtc-at32ap700x.c +++ b/drivers/rtc/rtc-at32ap700x.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/platform_device.h> | 13 | #include <linux/platform_device.h> |
14 | #include <linux/slab.h> | ||
14 | #include <linux/rtc.h> | 15 | #include <linux/rtc.h> |
15 | #include <linux/io.h> | 16 | #include <linux/io.h> |
16 | 17 | ||
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c index 78a018b5c941..f677e0710ca1 100644 --- a/drivers/rtc/rtc-at91sam9.c +++ b/drivers/rtc/rtc-at91sam9.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/rtc.h> | 18 | #include <linux/rtc.h> |
19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
20 | #include <linux/ioctl.h> | 20 | #include <linux/ioctl.h> |
21 | #include <linux/slab.h> | ||
21 | 22 | ||
22 | #include <mach/board.h> | 23 | #include <mach/board.h> |
23 | #include <mach/at91_rtt.h> | 24 | #include <mach/at91_rtt.h> |
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c index b11485b9f21c..72b2bcc2c224 100644 --- a/drivers/rtc/rtc-bfin.c +++ b/drivers/rtc/rtc-bfin.c | |||
@@ -51,6 +51,7 @@ | |||
51 | #include <linux/platform_device.h> | 51 | #include <linux/platform_device.h> |
52 | #include <linux/rtc.h> | 52 | #include <linux/rtc.h> |
53 | #include <linux/seq_file.h> | 53 | #include <linux/seq_file.h> |
54 | #include <linux/slab.h> | ||
54 | 55 | ||
55 | #include <asm/blackfin.h> | 56 | #include <asm/blackfin.h> |
56 | 57 | ||
diff --git a/drivers/rtc/rtc-bq4802.c b/drivers/rtc/rtc-bq4802.c index 280fe48ada0b..128270ce355d 100644 --- a/drivers/rtc/rtc-bq4802.c +++ b/drivers/rtc/rtc-bq4802.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/platform_device.h> | 10 | #include <linux/platform_device.h> |
11 | #include <linux/rtc.h> | 11 | #include <linux/rtc.h> |
12 | #include <linux/bcd.h> | 12 | #include <linux/bcd.h> |
13 | #include <linux/slab.h> | ||
13 | 14 | ||
14 | MODULE_AUTHOR("David S. Miller <davem@davemloft.net>"); | 15 | MODULE_AUTHOR("David S. Miller <davem@davemloft.net>"); |
15 | MODULE_DESCRIPTION("TI BQ4802 RTC driver"); | 16 | MODULE_DESCRIPTION("TI BQ4802 RTC driver"); |
diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c index 44c4399ee714..316f484999b5 100644 --- a/drivers/rtc/rtc-coh901331.c +++ b/drivers/rtc/rtc-coh901331.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/pm.h> | 14 | #include <linux/pm.h> |
15 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <linux/slab.h> | ||
17 | 18 | ||
18 | /* | 19 | /* |
19 | * Registers in the COH 901 331 | 20 | * Registers in the COH 901 331 |
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c new file mode 100644 index 000000000000..92a8f6cacda9 --- /dev/null +++ b/drivers/rtc/rtc-davinci.c | |||
@@ -0,0 +1,673 @@ | |||
1 | /* | ||
2 | * DaVinci Power Management and Real Time Clock Driver for TI platforms | ||
3 | * | ||
4 | * Copyright (C) 2009 Texas Instruments, Inc | ||
5 | * | ||
6 | * Author: Miguel Aguilar <miguel.aguilar@ridgerun.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/ioport.h> | ||
26 | #include <linux/delay.h> | ||
27 | #include <linux/spinlock.h> | ||
28 | #include <linux/rtc.h> | ||
29 | #include <linux/bcd.h> | ||
30 | #include <linux/platform_device.h> | ||
31 | #include <linux/io.h> | ||
32 | |||
33 | /* | ||
34 | * The DaVinci RTC is a simple RTC with the following | ||
35 | * Sec: 0 - 59 : BCD count | ||
36 | * Min: 0 - 59 : BCD count | ||
37 | * Hour: 0 - 23 : BCD count | ||
38 | * Day: 0 - 0x7FFF(32767) : Binary count ( Over 89 years ) | ||
39 | */ | ||
40 | |||
41 | /* PRTC interface registers */ | ||
42 | #define DAVINCI_PRTCIF_PID 0x00 | ||
43 | #define PRTCIF_CTLR 0x04 | ||
44 | #define PRTCIF_LDATA 0x08 | ||
45 | #define PRTCIF_UDATA 0x0C | ||
46 | #define PRTCIF_INTEN 0x10 | ||
47 | #define PRTCIF_INTFLG 0x14 | ||
48 | |||
49 | /* PRTCIF_CTLR bit fields */ | ||
50 | #define PRTCIF_CTLR_BUSY BIT(31) | ||
51 | #define PRTCIF_CTLR_SIZE BIT(25) | ||
52 | #define PRTCIF_CTLR_DIR BIT(24) | ||
53 | #define PRTCIF_CTLR_BENU_MSB BIT(23) | ||
54 | #define PRTCIF_CTLR_BENU_3RD_BYTE BIT(22) | ||
55 | #define PRTCIF_CTLR_BENU_2ND_BYTE BIT(21) | ||
56 | #define PRTCIF_CTLR_BENU_LSB BIT(20) | ||
57 | #define PRTCIF_CTLR_BENU_MASK (0x00F00000) | ||
58 | #define PRTCIF_CTLR_BENL_MSB BIT(19) | ||
59 | #define PRTCIF_CTLR_BENL_3RD_BYTE BIT(18) | ||
60 | #define PRTCIF_CTLR_BENL_2ND_BYTE BIT(17) | ||
61 | #define PRTCIF_CTLR_BENL_LSB BIT(16) | ||
62 | #define PRTCIF_CTLR_BENL_MASK (0x000F0000) | ||
63 | |||
64 | /* PRTCIF_INTEN bit fields */ | ||
65 | #define PRTCIF_INTEN_RTCSS BIT(1) | ||
66 | #define PRTCIF_INTEN_RTCIF BIT(0) | ||
67 | #define PRTCIF_INTEN_MASK (PRTCIF_INTEN_RTCSS \ | ||
68 | | PRTCIF_INTEN_RTCIF) | ||
69 | |||
70 | /* PRTCIF_INTFLG bit fields */ | ||
71 | #define PRTCIF_INTFLG_RTCSS BIT(1) | ||
72 | #define PRTCIF_INTFLG_RTCIF BIT(0) | ||
73 | #define PRTCIF_INTFLG_MASK (PRTCIF_INTFLG_RTCSS \ | ||
74 | | PRTCIF_INTFLG_RTCIF) | ||
75 | |||
76 | /* PRTC subsystem registers */ | ||
77 | #define PRTCSS_RTC_INTC_EXTENA1 (0x0C) | ||
78 | #define PRTCSS_RTC_CTRL (0x10) | ||
79 | #define PRTCSS_RTC_WDT (0x11) | ||
80 | #define PRTCSS_RTC_TMR0 (0x12) | ||
81 | #define PRTCSS_RTC_TMR1 (0x13) | ||
82 | #define PRTCSS_RTC_CCTRL (0x14) | ||
83 | #define PRTCSS_RTC_SEC (0x15) | ||
84 | #define PRTCSS_RTC_MIN (0x16) | ||
85 | #define PRTCSS_RTC_HOUR (0x17) | ||
86 | #define PRTCSS_RTC_DAY0 (0x18) | ||
87 | #define PRTCSS_RTC_DAY1 (0x19) | ||
88 | #define PRTCSS_RTC_AMIN (0x1A) | ||
89 | #define PRTCSS_RTC_AHOUR (0x1B) | ||
90 | #define PRTCSS_RTC_ADAY0 (0x1C) | ||
91 | #define PRTCSS_RTC_ADAY1 (0x1D) | ||
92 | #define PRTCSS_RTC_CLKC_CNT (0x20) | ||
93 | |||
94 | /* PRTCSS_RTC_INTC_EXTENA1 */ | ||
95 | #define PRTCSS_RTC_INTC_EXTENA1_MASK (0x07) | ||
96 | |||
97 | /* PRTCSS_RTC_CTRL bit fields */ | ||
98 | #define PRTCSS_RTC_CTRL_WDTBUS BIT(7) | ||
99 | #define PRTCSS_RTC_CTRL_WEN BIT(6) | ||
100 | #define PRTCSS_RTC_CTRL_WDRT BIT(5) | ||
101 | #define PRTCSS_RTC_CTRL_WDTFLG BIT(4) | ||
102 | #define PRTCSS_RTC_CTRL_TE BIT(3) | ||
103 | #define PRTCSS_RTC_CTRL_TIEN BIT(2) | ||
104 | #define PRTCSS_RTC_CTRL_TMRFLG BIT(1) | ||
105 | #define PRTCSS_RTC_CTRL_TMMD BIT(0) | ||
106 | |||
107 | /* PRTCSS_RTC_CCTRL bit fields */ | ||
108 | #define PRTCSS_RTC_CCTRL_CALBUSY BIT(7) | ||
109 | #define PRTCSS_RTC_CCTRL_DAEN BIT(5) | ||
110 | #define PRTCSS_RTC_CCTRL_HAEN BIT(4) | ||
111 | #define PRTCSS_RTC_CCTRL_MAEN BIT(3) | ||
112 | #define PRTCSS_RTC_CCTRL_ALMFLG BIT(2) | ||
113 | #define PRTCSS_RTC_CCTRL_AIEN BIT(1) | ||
114 | #define PRTCSS_RTC_CCTRL_CAEN BIT(0) | ||
115 | |||
116 | static DEFINE_SPINLOCK(davinci_rtc_lock); | ||
117 | |||
118 | struct davinci_rtc { | ||
119 | struct rtc_device *rtc; | ||
120 | void __iomem *base; | ||
121 | resource_size_t pbase; | ||
122 | size_t base_size; | ||
123 | int irq; | ||
124 | }; | ||
125 | |||
126 | static inline void rtcif_write(struct davinci_rtc *davinci_rtc, | ||
127 | u32 val, u32 addr) | ||
128 | { | ||
129 | writel(val, davinci_rtc->base + addr); | ||
130 | } | ||
131 | |||
132 | static inline u32 rtcif_read(struct davinci_rtc *davinci_rtc, u32 addr) | ||
133 | { | ||
134 | return readl(davinci_rtc->base + addr); | ||
135 | } | ||
136 | |||
137 | static inline void rtcif_wait(struct davinci_rtc *davinci_rtc) | ||
138 | { | ||
139 | while (rtcif_read(davinci_rtc, PRTCIF_CTLR) & PRTCIF_CTLR_BUSY) | ||
140 | cpu_relax(); | ||
141 | } | ||
142 | |||
143 | static inline void rtcss_write(struct davinci_rtc *davinci_rtc, | ||
144 | unsigned long val, u8 addr) | ||
145 | { | ||
146 | rtcif_wait(davinci_rtc); | ||
147 | |||
148 | rtcif_write(davinci_rtc, PRTCIF_CTLR_BENL_LSB | addr, PRTCIF_CTLR); | ||
149 | rtcif_write(davinci_rtc, val, PRTCIF_LDATA); | ||
150 | |||
151 | rtcif_wait(davinci_rtc); | ||
152 | } | ||
153 | |||
154 | static inline u8 rtcss_read(struct davinci_rtc *davinci_rtc, u8 addr) | ||
155 | { | ||
156 | rtcif_wait(davinci_rtc); | ||
157 | |||
158 | rtcif_write(davinci_rtc, PRTCIF_CTLR_DIR | PRTCIF_CTLR_BENL_LSB | addr, | ||
159 | PRTCIF_CTLR); | ||
160 | |||
161 | rtcif_wait(davinci_rtc); | ||
162 | |||
163 | return rtcif_read(davinci_rtc, PRTCIF_LDATA); | ||
164 | } | ||
165 | |||
166 | static inline void davinci_rtcss_calendar_wait(struct davinci_rtc *davinci_rtc) | ||
167 | { | ||
168 | while (rtcss_read(davinci_rtc, PRTCSS_RTC_CCTRL) & | ||
169 | PRTCSS_RTC_CCTRL_CALBUSY) | ||
170 | cpu_relax(); | ||
171 | } | ||
172 | |||
173 | static irqreturn_t davinci_rtc_interrupt(int irq, void *class_dev) | ||
174 | { | ||
175 | struct davinci_rtc *davinci_rtc = class_dev; | ||
176 | unsigned long events = 0; | ||
177 | u32 irq_flg; | ||
178 | u8 alm_irq, tmr_irq; | ||
179 | u8 rtc_ctrl, rtc_cctrl; | ||
180 | int ret = IRQ_NONE; | ||
181 | |||
182 | irq_flg = rtcif_read(davinci_rtc, PRTCIF_INTFLG) & | ||
183 | PRTCIF_INTFLG_RTCSS; | ||
184 | |||
185 | alm_irq = rtcss_read(davinci_rtc, PRTCSS_RTC_CCTRL) & | ||
186 | PRTCSS_RTC_CCTRL_ALMFLG; | ||
187 | |||
188 | tmr_irq = rtcss_read(davinci_rtc, PRTCSS_RTC_CTRL) & | ||
189 | PRTCSS_RTC_CTRL_TMRFLG; | ||
190 | |||
191 | if (irq_flg) { | ||
192 | if (alm_irq) { | ||
193 | events |= RTC_IRQF | RTC_AF; | ||
194 | rtc_cctrl = rtcss_read(davinci_rtc, PRTCSS_RTC_CCTRL); | ||
195 | rtc_cctrl |= PRTCSS_RTC_CCTRL_ALMFLG; | ||
196 | rtcss_write(davinci_rtc, rtc_cctrl, PRTCSS_RTC_CCTRL); | ||
197 | } else if (tmr_irq) { | ||
198 | events |= RTC_IRQF | RTC_PF; | ||
199 | rtc_ctrl = rtcss_read(davinci_rtc, PRTCSS_RTC_CTRL); | ||
200 | rtc_ctrl |= PRTCSS_RTC_CTRL_TMRFLG; | ||
201 | rtcss_write(davinci_rtc, rtc_ctrl, PRTCSS_RTC_CTRL); | ||
202 | } | ||
203 | |||
204 | rtcif_write(davinci_rtc, PRTCIF_INTFLG_RTCSS, | ||
205 | PRTCIF_INTFLG); | ||
206 | rtc_update_irq(davinci_rtc->rtc, 1, events); | ||
207 | |||
208 | ret = IRQ_HANDLED; | ||
209 | } | ||
210 | |||
211 | return ret; | ||
212 | } | ||
213 | |||
214 | static int | ||
215 | davinci_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
216 | { | ||
217 | struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); | ||
218 | u8 rtc_ctrl; | ||
219 | unsigned long flags; | ||
220 | int ret = 0; | ||
221 | |||
222 | spin_lock_irqsave(&davinci_rtc_lock, flags); | ||
223 | |||
224 | rtc_ctrl = rtcss_read(davinci_rtc, PRTCSS_RTC_CTRL); | ||
225 | |||
226 | switch (cmd) { | ||
227 | case RTC_WIE_ON: | ||
228 | rtc_ctrl |= PRTCSS_RTC_CTRL_WEN | PRTCSS_RTC_CTRL_WDTFLG; | ||
229 | break; | ||
230 | case RTC_WIE_OFF: | ||
231 | rtc_ctrl &= ~PRTCSS_RTC_CTRL_WEN; | ||
232 | break; | ||
233 | case RTC_UIE_OFF: | ||
234 | case RTC_UIE_ON: | ||
235 | ret = -ENOTTY; | ||
236 | break; | ||
237 | default: | ||
238 | ret = -ENOIOCTLCMD; | ||
239 | } | ||
240 | |||
241 | rtcss_write(davinci_rtc, rtc_ctrl, PRTCSS_RTC_CTRL); | ||
242 | |||
243 | spin_unlock_irqrestore(&davinci_rtc_lock, flags); | ||
244 | |||
245 | return ret; | ||
246 | } | ||
247 | |||
248 | static int convertfromdays(u16 days, struct rtc_time *tm) | ||
249 | { | ||
250 | int tmp_days, year, mon; | ||
251 | |||
252 | for (year = 2000;; year++) { | ||
253 | tmp_days = rtc_year_days(1, 12, year); | ||
254 | if (days >= tmp_days) | ||
255 | days -= tmp_days; | ||
256 | else { | ||
257 | for (mon = 0;; mon++) { | ||
258 | tmp_days = rtc_month_days(mon, year); | ||
259 | if (days >= tmp_days) { | ||
260 | days -= tmp_days; | ||
261 | } else { | ||
262 | tm->tm_year = year - 1900; | ||
263 | tm->tm_mon = mon; | ||
264 | tm->tm_mday = days + 1; | ||
265 | break; | ||
266 | } | ||
267 | } | ||
268 | break; | ||
269 | } | ||
270 | } | ||
271 | return 0; | ||
272 | } | ||
273 | |||
274 | static int convert2days(u16 *days, struct rtc_time *tm) | ||
275 | { | ||
276 | int i; | ||
277 | *days = 0; | ||
278 | |||
279 | /* epoch == 1900 */ | ||
280 | if (tm->tm_year < 100 || tm->tm_year > 199) | ||
281 | return -EINVAL; | ||
282 | |||
283 | for (i = 2000; i < 1900 + tm->tm_year; i++) | ||
284 | *days += rtc_year_days(1, 12, i); | ||
285 | |||
286 | *days += rtc_year_days(tm->tm_mday, tm->tm_mon, 1900 + tm->tm_year); | ||
287 | |||
288 | return 0; | ||
289 | } | ||
290 | |||
291 | static int davinci_rtc_read_time(struct device *dev, struct rtc_time *tm) | ||
292 | { | ||
293 | struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); | ||
294 | u16 days = 0; | ||
295 | u8 day0, day1; | ||
296 | unsigned long flags; | ||
297 | |||
298 | spin_lock_irqsave(&davinci_rtc_lock, flags); | ||
299 | |||
300 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
301 | tm->tm_sec = bcd2bin(rtcss_read(davinci_rtc, PRTCSS_RTC_SEC)); | ||
302 | |||
303 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
304 | tm->tm_min = bcd2bin(rtcss_read(davinci_rtc, PRTCSS_RTC_MIN)); | ||
305 | |||
306 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
307 | tm->tm_hour = bcd2bin(rtcss_read(davinci_rtc, PRTCSS_RTC_HOUR)); | ||
308 | |||
309 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
310 | day0 = rtcss_read(davinci_rtc, PRTCSS_RTC_DAY0); | ||
311 | |||
312 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
313 | day1 = rtcss_read(davinci_rtc, PRTCSS_RTC_DAY1); | ||
314 | |||
315 | spin_unlock_irqrestore(&davinci_rtc_lock, flags); | ||
316 | |||
317 | days |= day1; | ||
318 | days <<= 8; | ||
319 | days |= day0; | ||
320 | |||
321 | if (convertfromdays(days, tm) < 0) | ||
322 | return -EINVAL; | ||
323 | |||
324 | return 0; | ||
325 | } | ||
326 | |||
327 | static int davinci_rtc_set_time(struct device *dev, struct rtc_time *tm) | ||
328 | { | ||
329 | struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); | ||
330 | u16 days; | ||
331 | u8 rtc_cctrl; | ||
332 | unsigned long flags; | ||
333 | |||
334 | if (convert2days(&days, tm) < 0) | ||
335 | return -EINVAL; | ||
336 | |||
337 | spin_lock_irqsave(&davinci_rtc_lock, flags); | ||
338 | |||
339 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
340 | rtcss_write(davinci_rtc, bin2bcd(tm->tm_sec), PRTCSS_RTC_SEC); | ||
341 | |||
342 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
343 | rtcss_write(davinci_rtc, bin2bcd(tm->tm_min), PRTCSS_RTC_MIN); | ||
344 | |||
345 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
346 | rtcss_write(davinci_rtc, bin2bcd(tm->tm_hour), PRTCSS_RTC_HOUR); | ||
347 | |||
348 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
349 | rtcss_write(davinci_rtc, days & 0xFF, PRTCSS_RTC_DAY0); | ||
350 | |||
351 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
352 | rtcss_write(davinci_rtc, (days & 0xFF00) >> 8, PRTCSS_RTC_DAY1); | ||
353 | |||
354 | rtc_cctrl = rtcss_read(davinci_rtc, PRTCSS_RTC_CCTRL); | ||
355 | rtc_cctrl |= PRTCSS_RTC_CCTRL_CAEN; | ||
356 | rtcss_write(davinci_rtc, rtc_cctrl, PRTCSS_RTC_CCTRL); | ||
357 | |||
358 | spin_unlock_irqrestore(&davinci_rtc_lock, flags); | ||
359 | |||
360 | return 0; | ||
361 | } | ||
362 | |||
363 | static int davinci_rtc_alarm_irq_enable(struct device *dev, | ||
364 | unsigned int enabled) | ||
365 | { | ||
366 | struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); | ||
367 | unsigned long flags; | ||
368 | u8 rtc_cctrl = rtcss_read(davinci_rtc, PRTCSS_RTC_CCTRL); | ||
369 | |||
370 | spin_lock_irqsave(&davinci_rtc_lock, flags); | ||
371 | |||
372 | if (enabled) | ||
373 | rtc_cctrl |= PRTCSS_RTC_CCTRL_DAEN | | ||
374 | PRTCSS_RTC_CCTRL_HAEN | | ||
375 | PRTCSS_RTC_CCTRL_MAEN | | ||
376 | PRTCSS_RTC_CCTRL_ALMFLG | | ||
377 | PRTCSS_RTC_CCTRL_AIEN; | ||
378 | else | ||
379 | rtc_cctrl &= ~PRTCSS_RTC_CCTRL_AIEN; | ||
380 | |||
381 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
382 | rtcss_write(davinci_rtc, rtc_cctrl, PRTCSS_RTC_CCTRL); | ||
383 | |||
384 | spin_unlock_irqrestore(&davinci_rtc_lock, flags); | ||
385 | |||
386 | return 0; | ||
387 | } | ||
388 | |||
389 | static int davinci_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) | ||
390 | { | ||
391 | struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); | ||
392 | u16 days = 0; | ||
393 | u8 day0, day1; | ||
394 | unsigned long flags; | ||
395 | |||
396 | spin_lock_irqsave(&davinci_rtc_lock, flags); | ||
397 | |||
398 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
399 | alm->time.tm_min = bcd2bin(rtcss_read(davinci_rtc, PRTCSS_RTC_AMIN)); | ||
400 | |||
401 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
402 | alm->time.tm_hour = bcd2bin(rtcss_read(davinci_rtc, PRTCSS_RTC_AHOUR)); | ||
403 | |||
404 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
405 | day0 = rtcss_read(davinci_rtc, PRTCSS_RTC_ADAY0); | ||
406 | |||
407 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
408 | day1 = rtcss_read(davinci_rtc, PRTCSS_RTC_ADAY1); | ||
409 | |||
410 | spin_unlock_irqrestore(&davinci_rtc_lock, flags); | ||
411 | days |= day1; | ||
412 | days <<= 8; | ||
413 | days |= day0; | ||
414 | |||
415 | if (convertfromdays(days, &alm->time) < 0) | ||
416 | return -EINVAL; | ||
417 | |||
418 | alm->pending = !!(rtcss_read(davinci_rtc, | ||
419 | PRTCSS_RTC_CCTRL) & | ||
420 | PRTCSS_RTC_CCTRL_AIEN); | ||
421 | alm->enabled = alm->pending && device_may_wakeup(dev); | ||
422 | |||
423 | return 0; | ||
424 | } | ||
425 | |||
426 | static int davinci_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | ||
427 | { | ||
428 | struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); | ||
429 | unsigned long flags; | ||
430 | u16 days; | ||
431 | |||
432 | if (alm->time.tm_mday <= 0 && alm->time.tm_mon < 0 | ||
433 | && alm->time.tm_year < 0) { | ||
434 | struct rtc_time tm; | ||
435 | unsigned long now, then; | ||
436 | |||
437 | davinci_rtc_read_time(dev, &tm); | ||
438 | rtc_tm_to_time(&tm, &now); | ||
439 | |||
440 | alm->time.tm_mday = tm.tm_mday; | ||
441 | alm->time.tm_mon = tm.tm_mon; | ||
442 | alm->time.tm_year = tm.tm_year; | ||
443 | rtc_tm_to_time(&alm->time, &then); | ||
444 | |||
445 | if (then < now) { | ||
446 | rtc_time_to_tm(now + 24 * 60 * 60, &tm); | ||
447 | alm->time.tm_mday = tm.tm_mday; | ||
448 | alm->time.tm_mon = tm.tm_mon; | ||
449 | alm->time.tm_year = tm.tm_year; | ||
450 | } | ||
451 | } | ||
452 | |||
453 | if (convert2days(&days, &alm->time) < 0) | ||
454 | return -EINVAL; | ||
455 | |||
456 | spin_lock_irqsave(&davinci_rtc_lock, flags); | ||
457 | |||
458 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
459 | rtcss_write(davinci_rtc, bin2bcd(alm->time.tm_min), PRTCSS_RTC_AMIN); | ||
460 | |||
461 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
462 | rtcss_write(davinci_rtc, bin2bcd(alm->time.tm_hour), PRTCSS_RTC_AHOUR); | ||
463 | |||
464 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
465 | rtcss_write(davinci_rtc, days & 0xFF, PRTCSS_RTC_ADAY0); | ||
466 | |||
467 | davinci_rtcss_calendar_wait(davinci_rtc); | ||
468 | rtcss_write(davinci_rtc, (days & 0xFF00) >> 8, PRTCSS_RTC_ADAY1); | ||
469 | |||
470 | spin_unlock_irqrestore(&davinci_rtc_lock, flags); | ||
471 | |||
472 | return 0; | ||
473 | } | ||
474 | |||
475 | static int davinci_rtc_irq_set_state(struct device *dev, int enabled) | ||
476 | { | ||
477 | struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); | ||
478 | unsigned long flags; | ||
479 | u8 rtc_ctrl; | ||
480 | |||
481 | spin_lock_irqsave(&davinci_rtc_lock, flags); | ||
482 | |||
483 | rtc_ctrl = rtcss_read(davinci_rtc, PRTCSS_RTC_CTRL); | ||
484 | |||
485 | if (enabled) { | ||
486 | while (rtcss_read(davinci_rtc, PRTCSS_RTC_CTRL) | ||
487 | & PRTCSS_RTC_CTRL_WDTBUS) | ||
488 | cpu_relax(); | ||
489 | |||
490 | rtc_ctrl |= PRTCSS_RTC_CTRL_TE; | ||
491 | rtcss_write(davinci_rtc, rtc_ctrl, PRTCSS_RTC_CTRL); | ||
492 | |||
493 | rtcss_write(davinci_rtc, 0x0, PRTCSS_RTC_CLKC_CNT); | ||
494 | |||
495 | rtc_ctrl |= PRTCSS_RTC_CTRL_TIEN | | ||
496 | PRTCSS_RTC_CTRL_TMMD | | ||
497 | PRTCSS_RTC_CTRL_TMRFLG; | ||
498 | } else | ||
499 | rtc_ctrl &= ~PRTCSS_RTC_CTRL_TIEN; | ||
500 | |||
501 | rtcss_write(davinci_rtc, rtc_ctrl, PRTCSS_RTC_CTRL); | ||
502 | |||
503 | spin_unlock_irqrestore(&davinci_rtc_lock, flags); | ||
504 | |||
505 | return 0; | ||
506 | } | ||
507 | |||
508 | static int davinci_rtc_irq_set_freq(struct device *dev, int freq) | ||
509 | { | ||
510 | struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); | ||
511 | unsigned long flags; | ||
512 | u16 tmr_counter = (0x8000 >> (ffs(freq) - 1)); | ||
513 | |||
514 | spin_lock_irqsave(&davinci_rtc_lock, flags); | ||
515 | |||
516 | rtcss_write(davinci_rtc, tmr_counter & 0xFF, PRTCSS_RTC_TMR0); | ||
517 | rtcss_write(davinci_rtc, (tmr_counter & 0xFF00) >> 8, PRTCSS_RTC_TMR1); | ||
518 | |||
519 | spin_unlock_irqrestore(&davinci_rtc_lock, flags); | ||
520 | |||
521 | return 0; | ||
522 | } | ||
523 | |||
524 | static struct rtc_class_ops davinci_rtc_ops = { | ||
525 | .ioctl = davinci_rtc_ioctl, | ||
526 | .read_time = davinci_rtc_read_time, | ||
527 | .set_time = davinci_rtc_set_time, | ||
528 | .alarm_irq_enable = davinci_rtc_alarm_irq_enable, | ||
529 | .read_alarm = davinci_rtc_read_alarm, | ||
530 | .set_alarm = davinci_rtc_set_alarm, | ||
531 | .irq_set_state = davinci_rtc_irq_set_state, | ||
532 | .irq_set_freq = davinci_rtc_irq_set_freq, | ||
533 | }; | ||
534 | |||
535 | static int __init davinci_rtc_probe(struct platform_device *pdev) | ||
536 | { | ||
537 | struct device *dev = &pdev->dev; | ||
538 | struct davinci_rtc *davinci_rtc; | ||
539 | struct resource *res, *mem; | ||
540 | int ret = 0; | ||
541 | |||
542 | davinci_rtc = kzalloc(sizeof(struct davinci_rtc), GFP_KERNEL); | ||
543 | if (!davinci_rtc) { | ||
544 | dev_dbg(dev, "could not allocate memory for private data\n"); | ||
545 | return -ENOMEM; | ||
546 | } | ||
547 | |||
548 | davinci_rtc->irq = platform_get_irq(pdev, 0); | ||
549 | if (davinci_rtc->irq < 0) { | ||
550 | dev_err(dev, "no RTC irq\n"); | ||
551 | ret = davinci_rtc->irq; | ||
552 | goto fail1; | ||
553 | } | ||
554 | |||
555 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
556 | if (!res) { | ||
557 | dev_err(dev, "no mem resource\n"); | ||
558 | ret = -EINVAL; | ||
559 | goto fail1; | ||
560 | } | ||
561 | |||
562 | davinci_rtc->pbase = res->start; | ||
563 | davinci_rtc->base_size = resource_size(res); | ||
564 | |||
565 | mem = request_mem_region(davinci_rtc->pbase, davinci_rtc->base_size, | ||
566 | pdev->name); | ||
567 | if (!mem) { | ||
568 | dev_err(dev, "RTC registers at %08x are not free\n", | ||
569 | davinci_rtc->pbase); | ||
570 | ret = -EBUSY; | ||
571 | goto fail1; | ||
572 | } | ||
573 | |||
574 | davinci_rtc->base = ioremap(davinci_rtc->pbase, davinci_rtc->base_size); | ||
575 | if (!davinci_rtc->base) { | ||
576 | dev_err(dev, "unable to ioremap MEM resource\n"); | ||
577 | ret = -ENOMEM; | ||
578 | goto fail2; | ||
579 | } | ||
580 | |||
581 | davinci_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, | ||
582 | &davinci_rtc_ops, THIS_MODULE); | ||
583 | if (IS_ERR(davinci_rtc->rtc)) { | ||
584 | dev_err(dev, "unable to register RTC device, err %ld\n", | ||
585 | PTR_ERR(davinci_rtc->rtc)); | ||
586 | goto fail3; | ||
587 | } | ||
588 | |||
589 | rtcif_write(davinci_rtc, PRTCIF_INTFLG_RTCSS, PRTCIF_INTFLG); | ||
590 | rtcif_write(davinci_rtc, 0, PRTCIF_INTEN); | ||
591 | rtcss_write(davinci_rtc, 0, PRTCSS_RTC_INTC_EXTENA1); | ||
592 | |||
593 | rtcss_write(davinci_rtc, 0, PRTCSS_RTC_CTRL); | ||
594 | rtcss_write(davinci_rtc, 0, PRTCSS_RTC_CCTRL); | ||
595 | |||
596 | ret = request_irq(davinci_rtc->irq, davinci_rtc_interrupt, | ||
597 | IRQF_DISABLED, "davinci_rtc", davinci_rtc); | ||
598 | if (ret < 0) { | ||
599 | dev_err(dev, "unable to register davinci RTC interrupt\n"); | ||
600 | goto fail4; | ||
601 | } | ||
602 | |||
603 | /* Enable interrupts */ | ||
604 | rtcif_write(davinci_rtc, PRTCIF_INTEN_RTCSS, PRTCIF_INTEN); | ||
605 | rtcss_write(davinci_rtc, PRTCSS_RTC_INTC_EXTENA1_MASK, | ||
606 | PRTCSS_RTC_INTC_EXTENA1); | ||
607 | |||
608 | rtcss_write(davinci_rtc, PRTCSS_RTC_CCTRL_CAEN, PRTCSS_RTC_CCTRL); | ||
609 | |||
610 | platform_set_drvdata(pdev, davinci_rtc); | ||
611 | |||
612 | device_init_wakeup(&pdev->dev, 0); | ||
613 | |||
614 | return 0; | ||
615 | |||
616 | fail4: | ||
617 | rtc_device_unregister(davinci_rtc->rtc); | ||
618 | fail3: | ||
619 | iounmap(davinci_rtc->base); | ||
620 | fail2: | ||
621 | release_mem_region(davinci_rtc->pbase, davinci_rtc->base_size); | ||
622 | fail1: | ||
623 | kfree(davinci_rtc); | ||
624 | |||
625 | return ret; | ||
626 | } | ||
627 | |||
628 | static int __devexit davinci_rtc_remove(struct platform_device *pdev) | ||
629 | { | ||
630 | struct davinci_rtc *davinci_rtc = platform_get_drvdata(pdev); | ||
631 | |||
632 | device_init_wakeup(&pdev->dev, 0); | ||
633 | |||
634 | rtcif_write(davinci_rtc, 0, PRTCIF_INTEN); | ||
635 | |||
636 | free_irq(davinci_rtc->irq, davinci_rtc); | ||
637 | |||
638 | rtc_device_unregister(davinci_rtc->rtc); | ||
639 | |||
640 | iounmap(davinci_rtc->base); | ||
641 | release_mem_region(davinci_rtc->pbase, davinci_rtc->base_size); | ||
642 | |||
643 | platform_set_drvdata(pdev, NULL); | ||
644 | |||
645 | kfree(davinci_rtc); | ||
646 | |||
647 | return 0; | ||
648 | } | ||
649 | |||
650 | static struct platform_driver davinci_rtc_driver = { | ||
651 | .probe = davinci_rtc_probe, | ||
652 | .remove = __devexit_p(davinci_rtc_remove), | ||
653 | .driver = { | ||
654 | .name = "rtc_davinci", | ||
655 | .owner = THIS_MODULE, | ||
656 | }, | ||
657 | }; | ||
658 | |||
659 | static int __init rtc_init(void) | ||
660 | { | ||
661 | return platform_driver_probe(&davinci_rtc_driver, davinci_rtc_probe); | ||
662 | } | ||
663 | module_init(rtc_init); | ||
664 | |||
665 | static void __exit rtc_exit(void) | ||
666 | { | ||
667 | platform_driver_unregister(&davinci_rtc_driver); | ||
668 | } | ||
669 | module_exit(rtc_exit); | ||
670 | |||
671 | MODULE_AUTHOR("Miguel Aguilar <miguel.aguilar@ridgerun.com>"); | ||
672 | MODULE_DESCRIPTION("Texas Instruments DaVinci PRTC Driver"); | ||
673 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/rtc/rtc-ds1216.c b/drivers/rtc/rtc-ds1216.c index 4aedc705518c..45cd8c9f5a39 100644 --- a/drivers/rtc/rtc-ds1216.c +++ b/drivers/rtc/rtc-ds1216.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/rtc.h> | 9 | #include <linux/rtc.h> |
10 | #include <linux/platform_device.h> | 10 | #include <linux/platform_device.h> |
11 | #include <linux/bcd.h> | 11 | #include <linux/bcd.h> |
12 | #include <linux/slab.h> | ||
12 | 13 | ||
13 | #define DRV_VERSION "0.2" | 14 | #define DRV_VERSION "0.2" |
14 | 15 | ||
diff --git a/drivers/rtc/rtc-ds1286.c b/drivers/rtc/rtc-ds1286.c index 4fcb16bbff4a..bf430f9091ed 100644 --- a/drivers/rtc/rtc-ds1286.c +++ b/drivers/rtc/rtc-ds1286.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/bcd.h> | 18 | #include <linux/bcd.h> |
19 | #include <linux/ds1286.h> | 19 | #include <linux/ds1286.h> |
20 | #include <linux/io.h> | 20 | #include <linux/io.h> |
21 | #include <linux/slab.h> | ||
21 | 22 | ||
22 | #define DRV_VERSION "1.0" | 23 | #define DRV_VERSION "1.0" |
23 | 24 | ||
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c index 9630e7d3314e..7836c9cec557 100644 --- a/drivers/rtc/rtc-ds1305.c +++ b/drivers/rtc/rtc-ds1305.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/bcd.h> | 13 | #include <linux/bcd.h> |
14 | #include <linux/slab.h> | ||
14 | #include <linux/rtc.h> | 15 | #include <linux/rtc.h> |
15 | #include <linux/workqueue.h> | 16 | #include <linux/workqueue.h> |
16 | 17 | ||
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c index 5317bbcbc7a0..61945734ad00 100644 --- a/drivers/rtc/rtc-ds1374.c +++ b/drivers/rtc/rtc-ds1374.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/rtc.h> | 24 | #include <linux/rtc.h> |
25 | #include <linux/bcd.h> | 25 | #include <linux/bcd.h> |
26 | #include <linux/workqueue.h> | 26 | #include <linux/workqueue.h> |
27 | #include <linux/slab.h> | ||
27 | 28 | ||
28 | #define DS1374_REG_TOD0 0x00 /* Time of Day */ | 29 | #define DS1374_REG_TOD0 0x00 /* Time of Day */ |
29 | #define DS1374_REG_TOD1 0x01 | 30 | #define DS1374_REG_TOD1 0x01 |
diff --git a/drivers/rtc/rtc-ds1390.c b/drivers/rtc/rtc-ds1390.c index cdb705057091..26a86d235051 100644 --- a/drivers/rtc/rtc-ds1390.c +++ b/drivers/rtc/rtc-ds1390.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/rtc.h> | 19 | #include <linux/rtc.h> |
20 | #include <linux/spi/spi.h> | 20 | #include <linux/spi/spi.h> |
21 | #include <linux/bcd.h> | 21 | #include <linux/bcd.h> |
22 | #include <linux/slab.h> | ||
22 | 23 | ||
23 | #define DS1390_REG_100THS 0x00 | 24 | #define DS1390_REG_100THS 0x00 |
24 | #define DS1390_REG_SECONDS 0x01 | 25 | #define DS1390_REG_SECONDS 0x01 |
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c index 4166b84cb514..06b8566c4532 100644 --- a/drivers/rtc/rtc-ds1511.c +++ b/drivers/rtc/rtc-ds1511.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/bcd.h> | 17 | #include <linux/bcd.h> |
18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/gfp.h> | ||
20 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
21 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
22 | #include <linux/rtc.h> | 23 | #include <linux/rtc.h> |
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c index ed1ef7c9cc06..244f9994bcbb 100644 --- a/drivers/rtc/rtc-ds1553.c +++ b/drivers/rtc/rtc-ds1553.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/bcd.h> | 11 | #include <linux/bcd.h> |
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/gfp.h> | ||
14 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
15 | #include <linux/jiffies.h> | 16 | #include <linux/jiffies.h> |
16 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c index a1273360a44e..2b4b0bc42d6f 100644 --- a/drivers/rtc/rtc-ds1742.c +++ b/drivers/rtc/rtc-ds1742.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/bcd.h> | 15 | #include <linux/bcd.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/gfp.h> | ||
18 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
19 | #include <linux/jiffies.h> | 20 | #include <linux/jiffies.h> |
20 | #include <linux/rtc.h> | 21 | #include <linux/rtc.h> |
@@ -184,6 +185,7 @@ static int __devinit ds1742_rtc_probe(struct platform_device *pdev) | |||
184 | pdata->size_nvram = pdata->size - RTC_SIZE; | 185 | pdata->size_nvram = pdata->size - RTC_SIZE; |
185 | pdata->ioaddr_rtc = ioaddr + pdata->size_nvram; | 186 | pdata->ioaddr_rtc = ioaddr + pdata->size_nvram; |
186 | 187 | ||
188 | sysfs_bin_attr_init(&pdata->nvram_attr); | ||
187 | pdata->nvram_attr.attr.name = "nvram"; | 189 | pdata->nvram_attr.attr.name = "nvram"; |
188 | pdata->nvram_attr.attr.mode = S_IRUGO | S_IWUSR; | 190 | pdata->nvram_attr.attr.mode = S_IRUGO | S_IWUSR; |
189 | pdata->nvram_attr.read = ds1742_nvram_read; | 191 | pdata->nvram_attr.read = ds1742_nvram_read; |
diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c index 91bde976bc0f..11ae64dcbf3c 100644 --- a/drivers/rtc/rtc-ep93xx.c +++ b/drivers/rtc/rtc-ep93xx.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/rtc.h> | 13 | #include <linux/rtc.h> |
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/io.h> | 15 | #include <linux/io.h> |
16 | #include <linux/gfp.h> | ||
16 | 17 | ||
17 | #define EP93XX_RTC_DATA 0x000 | 18 | #define EP93XX_RTC_DATA 0x000 |
18 | #define EP93XX_RTC_MATCH 0x004 | 19 | #define EP93XX_RTC_MATCH 0x004 |
diff --git a/drivers/rtc/rtc-fm3130.c b/drivers/rtc/rtc-fm3130.c index 812c66755083..ff6fce61ea41 100644 --- a/drivers/rtc/rtc-fm3130.c +++ b/drivers/rtc/rtc-fm3130.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/i2c.h> | 13 | #include <linux/i2c.h> |
14 | #include <linux/rtc.h> | 14 | #include <linux/rtc.h> |
15 | #include <linux/bcd.h> | 15 | #include <linux/bcd.h> |
16 | #include <linux/slab.h> | ||
16 | 17 | ||
17 | #define FM3130_RTC_CONTROL (0x0) | 18 | #define FM3130_RTC_CONTROL (0x0) |
18 | #define FM3130_CAL_CONTROL (0x1) | 19 | #define FM3130_CAL_CONTROL (0x1) |
diff --git a/drivers/rtc/rtc-m48t35.c b/drivers/rtc/rtc-m48t35.c index 8cb5b8959e5b..7410875e5838 100644 --- a/drivers/rtc/rtc-m48t35.c +++ b/drivers/rtc/rtc-m48t35.c | |||
@@ -16,6 +16,7 @@ | |||
16 | 16 | ||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/rtc.h> | 18 | #include <linux/rtc.h> |
19 | #include <linux/slab.h> | ||
19 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
20 | #include <linux/bcd.h> | 21 | #include <linux/bcd.h> |
21 | #include <linux/io.h> | 22 | #include <linux/io.h> |
diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c index ede43b846859..365ff3ac2348 100644 --- a/drivers/rtc/rtc-m48t59.c +++ b/drivers/rtc/rtc-m48t59.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/rtc.h> | 19 | #include <linux/rtc.h> |
20 | #include <linux/rtc/m48t59.h> | 20 | #include <linux/rtc/m48t59.h> |
21 | #include <linux/bcd.h> | 21 | #include <linux/bcd.h> |
22 | #include <linux/slab.h> | ||
22 | 23 | ||
23 | #ifndef NO_IRQ | 24 | #ifndef NO_IRQ |
24 | #define NO_IRQ (-1) | 25 | #define NO_IRQ (-1) |
diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c index acdbb1760187..174036dda786 100644 --- a/drivers/rtc/rtc-max8925.c +++ b/drivers/rtc/rtc-max8925.c | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/i2c.h> | 13 | #include <linux/i2c.h> |
14 | #include <linux/slab.h> | ||
14 | #include <linux/rtc.h> | 15 | #include <linux/rtc.h> |
15 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
16 | #include <linux/mfd/max8925.h> | 17 | #include <linux/mfd/max8925.h> |
diff --git a/drivers/rtc/rtc-mc13783.c b/drivers/rtc/rtc-mc13783.c index d60c81b7b693..675bfb515367 100644 --- a/drivers/rtc/rtc-mc13783.c +++ b/drivers/rtc/rtc-mc13783.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/platform_device.h> | 13 | #include <linux/platform_device.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/slab.h> | ||
16 | #include <linux/rtc.h> | 17 | #include <linux/rtc.h> |
17 | 18 | ||
18 | #define DRIVER_NAME "mc13783-rtc" | 19 | #define DRIVER_NAME "mc13783-rtc" |
@@ -319,35 +320,38 @@ static int __devinit mc13783_rtc_probe(struct platform_device *pdev) | |||
319 | { | 320 | { |
320 | int ret; | 321 | int ret; |
321 | struct mc13783_rtc *priv; | 322 | struct mc13783_rtc *priv; |
323 | struct mc13783 *mc13783; | ||
322 | int rtcrst_pending; | 324 | int rtcrst_pending; |
323 | 325 | ||
324 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 326 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
325 | if (!priv) | 327 | if (!priv) |
326 | return -ENOMEM; | 328 | return -ENOMEM; |
327 | 329 | ||
328 | priv->mc13783 = dev_get_drvdata(pdev->dev.parent); | 330 | mc13783 = dev_get_drvdata(pdev->dev.parent); |
331 | priv->mc13783 = mc13783; | ||
332 | |||
329 | platform_set_drvdata(pdev, priv); | 333 | platform_set_drvdata(pdev, priv); |
330 | 334 | ||
331 | mc13783_lock(priv->mc13783); | 335 | mc13783_lock(mc13783); |
332 | 336 | ||
333 | ret = mc13783_irq_request(priv->mc13783, MC13783_IRQ_RTCRST, | 337 | ret = mc13783_irq_request(mc13783, MC13783_IRQ_RTCRST, |
334 | mc13783_rtc_reset_handler, DRIVER_NAME, priv); | 338 | mc13783_rtc_reset_handler, DRIVER_NAME, priv); |
335 | if (ret) | 339 | if (ret) |
336 | goto err_reset_irq_request; | 340 | goto err_reset_irq_request; |
337 | 341 | ||
338 | ret = mc13783_irq_status(priv->mc13783, MC13783_IRQ_RTCRST, | 342 | ret = mc13783_irq_status(mc13783, MC13783_IRQ_RTCRST, |
339 | NULL, &rtcrst_pending); | 343 | NULL, &rtcrst_pending); |
340 | if (ret) | 344 | if (ret) |
341 | goto err_reset_irq_status; | 345 | goto err_reset_irq_status; |
342 | 346 | ||
343 | priv->valid = !rtcrst_pending; | 347 | priv->valid = !rtcrst_pending; |
344 | 348 | ||
345 | ret = mc13783_irq_request_nounmask(priv->mc13783, MC13783_IRQ_1HZ, | 349 | ret = mc13783_irq_request_nounmask(mc13783, MC13783_IRQ_1HZ, |
346 | mc13783_rtc_update_handler, DRIVER_NAME, priv); | 350 | mc13783_rtc_update_handler, DRIVER_NAME, priv); |
347 | if (ret) | 351 | if (ret) |
348 | goto err_update_irq_request; | 352 | goto err_update_irq_request; |
349 | 353 | ||
350 | ret = mc13783_irq_request_nounmask(priv->mc13783, MC13783_IRQ_TODA, | 354 | ret = mc13783_irq_request_nounmask(mc13783, MC13783_IRQ_TODA, |
351 | mc13783_rtc_alarm_handler, DRIVER_NAME, priv); | 355 | mc13783_rtc_alarm_handler, DRIVER_NAME, priv); |
352 | if (ret) | 356 | if (ret) |
353 | goto err_alarm_irq_request; | 357 | goto err_alarm_irq_request; |
@@ -357,22 +361,22 @@ static int __devinit mc13783_rtc_probe(struct platform_device *pdev) | |||
357 | if (IS_ERR(priv->rtc)) { | 361 | if (IS_ERR(priv->rtc)) { |
358 | ret = PTR_ERR(priv->rtc); | 362 | ret = PTR_ERR(priv->rtc); |
359 | 363 | ||
360 | mc13783_irq_free(priv->mc13783, MC13783_IRQ_TODA, priv); | 364 | mc13783_irq_free(mc13783, MC13783_IRQ_TODA, priv); |
361 | err_alarm_irq_request: | 365 | err_alarm_irq_request: |
362 | 366 | ||
363 | mc13783_irq_free(priv->mc13783, MC13783_IRQ_1HZ, priv); | 367 | mc13783_irq_free(mc13783, MC13783_IRQ_1HZ, priv); |
364 | err_update_irq_request: | 368 | err_update_irq_request: |
365 | 369 | ||
366 | err_reset_irq_status: | 370 | err_reset_irq_status: |
367 | 371 | ||
368 | mc13783_irq_free(priv->mc13783, MC13783_IRQ_RTCRST, priv); | 372 | mc13783_irq_free(mc13783, MC13783_IRQ_RTCRST, priv); |
369 | err_reset_irq_request: | 373 | err_reset_irq_request: |
370 | 374 | ||
371 | platform_set_drvdata(pdev, NULL); | 375 | platform_set_drvdata(pdev, NULL); |
372 | kfree(priv); | 376 | kfree(priv); |
373 | } | 377 | } |
374 | 378 | ||
375 | mc13783_unlock(priv->mc13783); | 379 | mc13783_unlock(mc13783); |
376 | 380 | ||
377 | return ret; | 381 | return ret; |
378 | } | 382 | } |
diff --git a/drivers/rtc/rtc-mpc5121.c b/drivers/rtc/rtc-mpc5121.c index 4313ca03a96d..f0dbf9cb8f9c 100644 --- a/drivers/rtc/rtc-mpc5121.c +++ b/drivers/rtc/rtc-mpc5121.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/of_device.h> | 15 | #include <linux/of_device.h> |
16 | #include <linux/of_platform.h> | 16 | #include <linux/of_platform.h> |
17 | #include <linux/io.h> | 17 | #include <linux/io.h> |
18 | #include <linux/slab.h> | ||
18 | 19 | ||
19 | struct mpc5121_rtc_regs { | 20 | struct mpc5121_rtc_regs { |
20 | u8 set_time; /* RTC + 0x00 */ | 21 | u8 set_time; /* RTC + 0x00 */ |
diff --git a/drivers/rtc/rtc-msm6242.c b/drivers/rtc/rtc-msm6242.c index 5f5968a48925..b2fff0ca49f8 100644 --- a/drivers/rtc/rtc-msm6242.c +++ b/drivers/rtc/rtc-msm6242.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/rtc.h> | 15 | #include <linux/rtc.h> |
16 | #include <linux/slab.h> | ||
16 | 17 | ||
17 | 18 | ||
18 | enum { | 19 | enum { |
diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c index dc052ce6e63a..bcca47298554 100644 --- a/drivers/rtc/rtc-mv.c +++ b/drivers/rtc/rtc-mv.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/io.h> | 13 | #include <linux/io.h> |
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
16 | #include <linux/gfp.h> | ||
16 | 17 | ||
17 | 18 | ||
18 | #define RTC_TIME_REG_OFFS 0 | 19 | #define RTC_TIME_REG_OFFS 0 |
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c index 8710f9415d98..d71fe61db1d6 100644 --- a/drivers/rtc/rtc-mxc.c +++ b/drivers/rtc/rtc-mxc.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/io.h> | 12 | #include <linux/io.h> |
13 | #include <linux/rtc.h> | 13 | #include <linux/rtc.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/slab.h> | ||
15 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
16 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
17 | #include <linux/clk.h> | 18 | #include <linux/clk.h> |
@@ -383,21 +384,26 @@ static int __init mxc_rtc_probe(struct platform_device *pdev) | |||
383 | struct rtc_device *rtc; | 384 | struct rtc_device *rtc; |
384 | struct rtc_plat_data *pdata = NULL; | 385 | struct rtc_plat_data *pdata = NULL; |
385 | u32 reg; | 386 | u32 reg; |
386 | int ret, rate; | 387 | unsigned long rate; |
388 | int ret; | ||
387 | 389 | ||
388 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 390 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
389 | if (!res) | 391 | if (!res) |
390 | return -ENODEV; | 392 | return -ENODEV; |
391 | 393 | ||
392 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); | 394 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); |
393 | if (!pdata) | 395 | if (!pdata) |
394 | return -ENOMEM; | 396 | return -ENOMEM; |
395 | 397 | ||
396 | pdata->ioaddr = ioremap(res->start, resource_size(res)); | 398 | if (!devm_request_mem_region(&pdev->dev, res->start, |
399 | resource_size(res), pdev->name)) | ||
400 | return -EBUSY; | ||
401 | |||
402 | pdata->ioaddr = devm_ioremap(&pdev->dev, res->start, | ||
403 | resource_size(res)); | ||
397 | 404 | ||
398 | clk = clk_get(&pdev->dev, "ckil"); | 405 | clk = clk_get(&pdev->dev, "ckil"); |
399 | if (IS_ERR(clk)) { | 406 | if (IS_ERR(clk)) { |
400 | iounmap(pdata->ioaddr); | ||
401 | ret = PTR_ERR(clk); | 407 | ret = PTR_ERR(clk); |
402 | goto exit_free_pdata; | 408 | goto exit_free_pdata; |
403 | } | 409 | } |
@@ -412,8 +418,7 @@ static int __init mxc_rtc_probe(struct platform_device *pdev) | |||
412 | else if (rate == 38400) | 418 | else if (rate == 38400) |
413 | reg = RTC_INPUT_CLK_38400HZ; | 419 | reg = RTC_INPUT_CLK_38400HZ; |
414 | else { | 420 | else { |
415 | dev_err(&pdev->dev, "rtc clock is not valid (%lu)\n", | 421 | dev_err(&pdev->dev, "rtc clock is not valid (%lu)\n", rate); |
416 | clk_get_rate(clk)); | ||
417 | ret = -EINVAL; | 422 | ret = -EINVAL; |
418 | goto exit_free_pdata; | 423 | goto exit_free_pdata; |
419 | } | 424 | } |
@@ -449,8 +454,8 @@ static int __init mxc_rtc_probe(struct platform_device *pdev) | |||
449 | pdata->irq = platform_get_irq(pdev, 0); | 454 | pdata->irq = platform_get_irq(pdev, 0); |
450 | 455 | ||
451 | if (pdata->irq >= 0 && | 456 | if (pdata->irq >= 0 && |
452 | request_irq(pdata->irq, mxc_rtc_interrupt, IRQF_SHARED, | 457 | devm_request_irq(&pdev->dev, pdata->irq, mxc_rtc_interrupt, |
453 | pdev->name, pdev) < 0) { | 458 | IRQF_SHARED, pdev->name, pdev) < 0) { |
454 | dev_warn(&pdev->dev, "interrupt not available.\n"); | 459 | dev_warn(&pdev->dev, "interrupt not available.\n"); |
455 | pdata->irq = -1; | 460 | pdata->irq = -1; |
456 | } | 461 | } |
@@ -458,10 +463,10 @@ static int __init mxc_rtc_probe(struct platform_device *pdev) | |||
458 | return 0; | 463 | return 0; |
459 | 464 | ||
460 | exit_put_clk: | 465 | exit_put_clk: |
466 | clk_disable(pdata->clk); | ||
461 | clk_put(pdata->clk); | 467 | clk_put(pdata->clk); |
462 | 468 | ||
463 | exit_free_pdata: | 469 | exit_free_pdata: |
464 | kfree(pdata); | ||
465 | 470 | ||
466 | return ret; | 471 | return ret; |
467 | } | 472 | } |
@@ -472,12 +477,8 @@ static int __exit mxc_rtc_remove(struct platform_device *pdev) | |||
472 | 477 | ||
473 | rtc_device_unregister(pdata->rtc); | 478 | rtc_device_unregister(pdata->rtc); |
474 | 479 | ||
475 | if (pdata->irq >= 0) | ||
476 | free_irq(pdata->irq, pdev); | ||
477 | |||
478 | clk_disable(pdata->clk); | 480 | clk_disable(pdata->clk); |
479 | clk_put(pdata->clk); | 481 | clk_put(pdata->clk); |
480 | kfree(pdata); | ||
481 | platform_set_drvdata(pdev, NULL); | 482 | platform_set_drvdata(pdev, NULL); |
482 | 483 | ||
483 | return 0; | 484 | return 0; |
diff --git a/drivers/rtc/rtc-nuc900.c b/drivers/rtc/rtc-nuc900.c index bf59c9c586b2..a351bd5d8176 100644 --- a/drivers/rtc/rtc-nuc900.c +++ b/drivers/rtc/rtc-nuc900.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/slab.h> | ||
15 | #include <linux/rtc.h> | 16 | #include <linux/rtc.h> |
16 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
17 | #include <linux/io.h> | 18 | #include <linux/io.h> |
diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c index a99c28992d21..25c0b3fd44f1 100644 --- a/drivers/rtc/rtc-pcap.c +++ b/drivers/rtc/rtc-pcap.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/mfd/ezx-pcap.h> | 18 | #include <linux/mfd/ezx-pcap.h> |
19 | #include <linux/rtc.h> | 19 | #include <linux/rtc.h> |
20 | #include <linux/slab.h> | ||
20 | #include <linux/platform_device.h> | 21 | #include <linux/platform_device.h> |
21 | 22 | ||
22 | struct pcap_rtc { | 23 | struct pcap_rtc { |
diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c index 2ceb365533b2..71bab0ef5443 100644 --- a/drivers/rtc/rtc-pcf2123.c +++ b/drivers/rtc/rtc-pcf2123.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/init.h> | 39 | #include <linux/init.h> |
40 | #include <linux/kernel.h> | 40 | #include <linux/kernel.h> |
41 | #include <linux/string.h> | 41 | #include <linux/string.h> |
42 | #include <linux/slab.h> | ||
42 | #include <linux/rtc.h> | 43 | #include <linux/rtc.h> |
43 | #include <linux/spi/spi.h> | 44 | #include <linux/spi/spi.h> |
44 | 45 | ||
diff --git a/drivers/rtc/rtc-pcf50633.c b/drivers/rtc/rtc-pcf50633.c index 854c3cb365a1..16edf94ab42f 100644 --- a/drivers/rtc/rtc-pcf50633.c +++ b/drivers/rtc/rtc-pcf50633.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/device.h> | 20 | #include <linux/device.h> |
21 | #include <linux/slab.h> | ||
21 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
22 | #include <linux/rtc.h> | 23 | #include <linux/rtc.h> |
23 | #include <linux/bcd.h> | 24 | #include <linux/bcd.h> |
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index 65f346b2fbae..1af42b4a6f59 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
18 | #include <linux/bcd.h> | 18 | #include <linux/bcd.h> |
19 | #include <linux/rtc.h> | 19 | #include <linux/rtc.h> |
20 | #include <linux/slab.h> | ||
20 | 21 | ||
21 | #define DRV_VERSION "0.4.3" | 22 | #define DRV_VERSION "0.4.3" |
22 | 23 | ||
diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c index 457231bb1029..bbdb2f02798a 100644 --- a/drivers/rtc/rtc-pl030.c +++ b/drivers/rtc/rtc-pl030.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/interrupt.h> | 13 | #include <linux/interrupt.h> |
14 | #include <linux/amba/bus.h> | 14 | #include <linux/amba/bus.h> |
15 | #include <linux/io.h> | 15 | #include <linux/io.h> |
16 | #include <linux/slab.h> | ||
16 | 17 | ||
17 | #define RTC_DR (0) | 18 | #define RTC_DR (0) |
18 | #define RTC_MR (4) | 19 | #define RTC_MR (4) |
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index c256aacfa954..3587d9922f28 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/bcd.h> | 24 | #include <linux/bcd.h> |
25 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
26 | #include <linux/version.h> | 26 | #include <linux/version.h> |
27 | #include <linux/slab.h> | ||
27 | 28 | ||
28 | /* | 29 | /* |
29 | * Register definitions | 30 | * Register definitions |
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c index e6351b743da6..e9c6fa035989 100644 --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/seq_file.h> | 26 | #include <linux/seq_file.h> |
27 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
28 | #include <linux/io.h> | 28 | #include <linux/io.h> |
29 | #include <linux/slab.h> | ||
29 | 30 | ||
30 | #include <mach/hardware.h> | 31 | #include <mach/hardware.h> |
31 | 32 | ||
diff --git a/drivers/rtc/rtc-rp5c01.c b/drivers/rtc/rtc-rp5c01.c index e1313feb060f..a95f733bb15a 100644 --- a/drivers/rtc/rtc-rp5c01.c +++ b/drivers/rtc/rtc-rp5c01.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/platform_device.h> | 13 | #include <linux/platform_device.h> |
14 | #include <linux/rtc.h> | 14 | #include <linux/rtc.h> |
15 | #include <linux/slab.h> | ||
15 | 16 | ||
16 | 17 | ||
17 | enum { | 18 | enum { |
diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c index 2099037cb3ea..368d0e63cf83 100644 --- a/drivers/rtc/rtc-rs5c348.c +++ b/drivers/rtc/rtc-rs5c348.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
21 | #include <linux/string.h> | 21 | #include <linux/string.h> |
22 | #include <linux/slab.h> | ||
22 | #include <linux/rtc.h> | 23 | #include <linux/rtc.h> |
23 | #include <linux/workqueue.h> | 24 | #include <linux/workqueue.h> |
24 | #include <linux/spi/spi.h> | 25 | #include <linux/spi/spi.h> |
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c index 2f2c68d476da..90cf0a6ff23e 100644 --- a/drivers/rtc/rtc-rs5c372.c +++ b/drivers/rtc/rtc-rs5c372.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/i2c.h> | 13 | #include <linux/i2c.h> |
14 | #include <linux/rtc.h> | 14 | #include <linux/rtc.h> |
15 | #include <linux/bcd.h> | 15 | #include <linux/bcd.h> |
16 | #include <linux/slab.h> | ||
16 | 17 | ||
17 | #define DRV_VERSION "0.6" | 18 | #define DRV_VERSION "0.6" |
18 | 19 | ||
diff --git a/drivers/rtc/rtc-rx8025.c b/drivers/rtc/rtc-rx8025.c index b1a29bcfdf13..b65c82f792d9 100644 --- a/drivers/rtc/rtc-rx8025.c +++ b/drivers/rtc/rtc-rx8025.c | |||
@@ -20,6 +20,7 @@ | |||
20 | */ | 20 | */ |
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/slab.h> | ||
23 | #include <linux/init.h> | 24 | #include <linux/init.h> |
24 | #include <linux/bcd.h> | 25 | #include <linux/bcd.h> |
25 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
diff --git a/drivers/rtc/rtc-rx8581.c b/drivers/rtc/rtc-rx8581.c index c9522f3bc21c..9718aaaa8215 100644 --- a/drivers/rtc/rtc-rx8581.c +++ b/drivers/rtc/rtc-rx8581.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * An I2C driver for the Epson RX8581 RTC | 2 | * An I2C driver for the Epson RX8581 RTC |
3 | * | 3 | * |
4 | * Author: Martyn Welch <martyn.welch@gefanuc.com> | 4 | * Author: Martyn Welch <martyn.welch@ge.com> |
5 | * Copyright 2008 GE Fanuc Intelligent Platforms Embedded Systems, Inc. | 5 | * Copyright 2008 GE Intelligent Platforms Embedded Systems, Inc. |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License version 2 as | 8 | * it under the terms of the GNU General Public License version 2 as |
@@ -272,7 +272,7 @@ static void __exit rx8581_exit(void) | |||
272 | i2c_del_driver(&rx8581_driver); | 272 | i2c_del_driver(&rx8581_driver); |
273 | } | 273 | } |
274 | 274 | ||
275 | MODULE_AUTHOR("Martyn Welch <martyn.welch@gefanuc.com>"); | 275 | MODULE_AUTHOR("Martyn Welch <martyn.welch@ge.com>"); |
276 | MODULE_DESCRIPTION("Epson RX-8581 RTC driver"); | 276 | MODULE_DESCRIPTION("Epson RX-8581 RTC driver"); |
277 | MODULE_LICENSE("GPL"); | 277 | MODULE_LICENSE("GPL"); |
278 | MODULE_VERSION(DRV_VERSION); | 278 | MODULE_VERSION(DRV_VERSION); |
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index e0d7b9991505..4969b6059c89 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/bcd.h> | 21 | #include <linux/bcd.h> |
22 | #include <linux/clk.h> | 22 | #include <linux/clk.h> |
23 | #include <linux/log2.h> | 23 | #include <linux/log2.h> |
24 | #include <linux/slab.h> | ||
24 | 25 | ||
25 | #include <mach/hardware.h> | 26 | #include <mach/hardware.h> |
26 | #include <asm/uaccess.h> | 27 | #include <asm/uaccess.h> |
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index e95cc6f8d61e..5efbd5990ff8 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/io.h> | 26 | #include <linux/io.h> |
27 | #include <linux/log2.h> | 27 | #include <linux/log2.h> |
28 | #include <linux/clk.h> | 28 | #include <linux/clk.h> |
29 | #include <linux/slab.h> | ||
29 | #include <asm/rtc.h> | 30 | #include <asm/rtc.h> |
30 | 31 | ||
31 | #define DRV_NAME "sh-rtc" | 32 | #define DRV_NAME "sh-rtc" |
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c index 67700831b5c9..b53a00198dbe 100644 --- a/drivers/rtc/rtc-stk17ta8.c +++ b/drivers/rtc/rtc-stk17ta8.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * A RTC driver for the Simtek STK17TA8 | 2 | * A RTC driver for the Simtek STK17TA8 |
3 | * | 3 | * |
4 | * By Thomas Hommel <thomas.hommel@gefanuc.com> | 4 | * By Thomas Hommel <thomas.hommel@ge.com> |
5 | * | 5 | * |
6 | * Based on the DS1553 driver from | 6 | * Based on the DS1553 driver from |
7 | * Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 7 | * Atsushi Nemoto <anemo@mba.ocn.ne.jp> |
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/bcd.h> | 14 | #include <linux/bcd.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/gfp.h> | ||
17 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
18 | #include <linux/jiffies.h> | 19 | #include <linux/jiffies.h> |
19 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
@@ -381,7 +382,7 @@ static __exit void stk17ta8_exit(void) | |||
381 | module_init(stk17ta8_init); | 382 | module_init(stk17ta8_init); |
382 | module_exit(stk17ta8_exit); | 383 | module_exit(stk17ta8_exit); |
383 | 384 | ||
384 | MODULE_AUTHOR("Thomas Hommel <thomas.hommel@gefanuc.com>"); | 385 | MODULE_AUTHOR("Thomas Hommel <thomas.hommel@ge.com>"); |
385 | MODULE_DESCRIPTION("Simtek STK17TA8 RTC driver"); | 386 | MODULE_DESCRIPTION("Simtek STK17TA8 RTC driver"); |
386 | MODULE_LICENSE("GPL"); | 387 | MODULE_LICENSE("GPL"); |
387 | MODULE_VERSION(DRV_VERSION); | 388 | MODULE_VERSION(DRV_VERSION); |
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c index d7ce1a5c857d..7e7d0c806f2d 100644 --- a/drivers/rtc/rtc-stmp3xxx.c +++ b/drivers/rtc/rtc-stmp3xxx.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
23 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
24 | #include <linux/rtc.h> | 24 | #include <linux/rtc.h> |
25 | #include <linux/slab.h> | ||
25 | 26 | ||
26 | #include <mach/platform.h> | 27 | #include <mach/platform.h> |
27 | #include <mach/stmp3xxx.h> | 28 | #include <mach/stmp3xxx.h> |
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c index 7dd23a6fc825..380083ca572f 100644 --- a/drivers/rtc/rtc-sysfs.c +++ b/drivers/rtc/rtc-sysfs.c | |||
@@ -107,8 +107,9 @@ rtc_sysfs_show_hctosys(struct device *dev, struct device_attribute *attr, | |||
107 | char *buf) | 107 | char *buf) |
108 | { | 108 | { |
109 | #ifdef CONFIG_RTC_HCTOSYS_DEVICE | 109 | #ifdef CONFIG_RTC_HCTOSYS_DEVICE |
110 | if (strcmp(dev_name(&to_rtc_device(dev)->dev), | 110 | if (rtc_hctosys_ret == 0 && |
111 | CONFIG_RTC_HCTOSYS_DEVICE) == 0) | 111 | strcmp(dev_name(&to_rtc_device(dev)->dev), |
112 | CONFIG_RTC_HCTOSYS_DEVICE) == 0) | ||
112 | return sprintf(buf, "1\n"); | 113 | return sprintf(buf, "1\n"); |
113 | else | 114 | else |
114 | #endif | 115 | #endif |
diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c index 9ee81d8aa7c0..20bfc64a15c8 100644 --- a/drivers/rtc/rtc-tx4939.c +++ b/drivers/rtc/rtc-tx4939.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/platform_device.h> | 12 | #include <linux/platform_device.h> |
13 | #include <linux/interrupt.h> | 13 | #include <linux/interrupt.h> |
14 | #include <linux/io.h> | 14 | #include <linux/io.h> |
15 | #include <linux/gfp.h> | ||
15 | #include <asm/txx9/tx4939.h> | 16 | #include <asm/txx9/tx4939.h> |
16 | 17 | ||
17 | struct tx4939rtc_plat_data { | 18 | struct tx4939rtc_plat_data { |
diff --git a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c index bed4cab07043..f71c3ce18036 100644 --- a/drivers/rtc/rtc-v3020.c +++ b/drivers/rtc/rtc-v3020.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/rtc-v3020.h> | 28 | #include <linux/rtc-v3020.h> |
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/gpio.h> | 30 | #include <linux/gpio.h> |
31 | #include <linux/slab.h> | ||
31 | 32 | ||
32 | #include <linux/io.h> | 33 | #include <linux/io.h> |
33 | 34 | ||
diff --git a/drivers/rtc/rtc-wm831x.c b/drivers/rtc/rtc-wm831x.c index 000c7e481e59..b16cfe57a484 100644 --- a/drivers/rtc/rtc-wm831x.c +++ b/drivers/rtc/rtc-wm831x.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/time.h> | 17 | #include <linux/time.h> |
18 | #include <linux/rtc.h> | 18 | #include <linux/rtc.h> |
19 | #include <linux/slab.h> | ||
19 | #include <linux/bcd.h> | 20 | #include <linux/bcd.h> |
20 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
21 | #include <linux/ioctl.h> | 22 | #include <linux/ioctl.h> |