Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 1 | /* drivers/rtc/rtc-s3c.c |
| 2 | * |
Atul Dahiya | e48add8 | 2010-07-20 12:19:14 +0530 | [diff] [blame] | 3 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. |
| 4 | * http://www.samsung.com/ |
| 5 | * |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 6 | * Copyright (c) 2004,2006 Simtec Electronics |
| 7 | * Ben Dooks, <ben@simtec.co.uk> |
| 8 | * http://armlinux.simtec.co.uk/ |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License version 2 as |
| 12 | * published by the Free Software Foundation. |
| 13 | * |
| 14 | * S3C2410/S3C2440/S3C24XX Internal RTC Driver |
| 15 | */ |
| 16 | |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/fs.h> |
| 19 | #include <linux/string.h> |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/platform_device.h> |
| 22 | #include <linux/interrupt.h> |
| 23 | #include <linux/rtc.h> |
| 24 | #include <linux/bcd.h> |
| 25 | #include <linux/clk.h> |
Robert P. J. Day | 9974b6e | 2008-02-06 01:38:42 -0800 | [diff] [blame] | 26 | #include <linux/log2.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 27 | #include <linux/slab.h> |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 28 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 29 | #include <mach/hardware.h> |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 30 | #include <asm/uaccess.h> |
| 31 | #include <asm/io.h> |
| 32 | #include <asm/irq.h> |
Ben Dooks | e2cd00c | 2008-10-30 10:14:34 +0000 | [diff] [blame] | 33 | #include <plat/regs-rtc.h> |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 34 | |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 35 | enum s3c_cpu_type { |
| 36 | TYPE_S3C2410, |
| 37 | TYPE_S3C64XX, |
| 38 | }; |
| 39 | |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 40 | /* I have yet to find an S3C implementation with more than one |
| 41 | * of these rtc blocks in */ |
| 42 | |
| 43 | static struct resource *s3c_rtc_mem; |
| 44 | |
Atul Dahiya | e48add8 | 2010-07-20 12:19:14 +0530 | [diff] [blame] | 45 | static struct clk *rtc_clk; |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 46 | static void __iomem *s3c_rtc_base; |
| 47 | static int s3c_rtc_alarmno = NO_IRQ; |
| 48 | static int s3c_rtc_tickno = NO_IRQ; |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 49 | static enum s3c_cpu_type s3c_rtc_cpu_type; |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 50 | |
| 51 | static DEFINE_SPINLOCK(s3c_rtc_pie_lock); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 52 | |
| 53 | /* IRQ Handlers */ |
| 54 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 55 | static irqreturn_t s3c_rtc_alarmirq(int irq, void *id) |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 56 | { |
| 57 | struct rtc_device *rdev = id; |
| 58 | |
David Brownell | ab6a2d7 | 2007-05-08 00:33:30 -0700 | [diff] [blame] | 59 | rtc_update_irq(rdev, 1, RTC_AF | RTC_IRQF); |
Atul Dahiya | 2f3478f | 2010-07-20 16:02:51 +0530 | [diff] [blame^] | 60 | |
| 61 | if (s3c_rtc_cpu_type == TYPE_S3C64XX) |
| 62 | writeb(S3C2410_INTP_ALM, s3c_rtc_base + S3C2410_INTP); |
| 63 | |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 64 | return IRQ_HANDLED; |
| 65 | } |
| 66 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 67 | static irqreturn_t s3c_rtc_tickirq(int irq, void *id) |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 68 | { |
| 69 | struct rtc_device *rdev = id; |
| 70 | |
Ben Dooks | 773be7e | 2008-07-23 21:30:45 -0700 | [diff] [blame] | 71 | rtc_update_irq(rdev, 1, RTC_PF | RTC_IRQF); |
Atul Dahiya | 2f3478f | 2010-07-20 16:02:51 +0530 | [diff] [blame^] | 72 | |
| 73 | if (s3c_rtc_cpu_type == TYPE_S3C64XX) |
| 74 | writeb(S3C2410_INTP_TIC, s3c_rtc_base + S3C2410_INTP); |
| 75 | |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 76 | return IRQ_HANDLED; |
| 77 | } |
| 78 | |
| 79 | /* Update control registers */ |
| 80 | static void s3c_rtc_setaie(int to) |
| 81 | { |
| 82 | unsigned int tmp; |
| 83 | |
Harvey Harrison | 2a4e2b8 | 2008-04-28 02:12:00 -0700 | [diff] [blame] | 84 | pr_debug("%s: aie=%d\n", __func__, to); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 85 | |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 86 | tmp = readb(s3c_rtc_base + S3C2410_RTCALM) & ~S3C2410_RTCALM_ALMEN; |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 87 | |
| 88 | if (to) |
| 89 | tmp |= S3C2410_RTCALM_ALMEN; |
| 90 | |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 91 | writeb(tmp, s3c_rtc_base + S3C2410_RTCALM); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 92 | } |
| 93 | |
Ben Dooks | 773be7e | 2008-07-23 21:30:45 -0700 | [diff] [blame] | 94 | static int s3c_rtc_setpie(struct device *dev, int enabled) |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 95 | { |
| 96 | unsigned int tmp; |
| 97 | |
Ben Dooks | 773be7e | 2008-07-23 21:30:45 -0700 | [diff] [blame] | 98 | pr_debug("%s: pie=%d\n", __func__, enabled); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 99 | |
| 100 | spin_lock_irq(&s3c_rtc_pie_lock); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 101 | |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 102 | if (s3c_rtc_cpu_type == TYPE_S3C64XX) { |
| 103 | tmp = readb(s3c_rtc_base + S3C2410_RTCCON); |
| 104 | tmp &= ~S3C64XX_RTCCON_TICEN; |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 105 | |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 106 | if (enabled) |
| 107 | tmp |= S3C64XX_RTCCON_TICEN; |
| 108 | |
Atul Dahiya | 2f3478f | 2010-07-20 16:02:51 +0530 | [diff] [blame^] | 109 | writew(tmp, s3c_rtc_base + S3C2410_RTCCON); |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 110 | } else { |
| 111 | tmp = readb(s3c_rtc_base + S3C2410_TICNT); |
| 112 | tmp &= ~S3C2410_TICNT_ENABLE; |
| 113 | |
| 114 | if (enabled) |
| 115 | tmp |= S3C2410_TICNT_ENABLE; |
| 116 | |
| 117 | writeb(tmp, s3c_rtc_base + S3C2410_TICNT); |
| 118 | } |
| 119 | |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 120 | spin_unlock_irq(&s3c_rtc_pie_lock); |
Ben Dooks | 773be7e | 2008-07-23 21:30:45 -0700 | [diff] [blame] | 121 | |
| 122 | return 0; |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 123 | } |
| 124 | |
Ben Dooks | 773be7e | 2008-07-23 21:30:45 -0700 | [diff] [blame] | 125 | static int s3c_rtc_setfreq(struct device *dev, int freq) |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 126 | { |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 127 | struct platform_device *pdev = to_platform_device(dev); |
| 128 | struct rtc_device *rtc_dev = platform_get_drvdata(pdev); |
| 129 | unsigned int tmp = 0; |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 130 | |
Jonathan Cameron | 5d2a503 | 2009-01-06 14:42:12 -0800 | [diff] [blame] | 131 | if (!is_power_of_2(freq)) |
| 132 | return -EINVAL; |
| 133 | |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 134 | spin_lock_irq(&s3c_rtc_pie_lock); |
Ben Dooks | 773be7e | 2008-07-23 21:30:45 -0700 | [diff] [blame] | 135 | |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 136 | if (s3c_rtc_cpu_type == TYPE_S3C2410) { |
| 137 | tmp = readb(s3c_rtc_base + S3C2410_TICNT); |
| 138 | tmp &= S3C2410_TICNT_ENABLE; |
| 139 | } |
| 140 | |
| 141 | tmp |= (rtc_dev->max_user_freq / freq)-1; |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 142 | |
Atul Dahiya | 2f3478f | 2010-07-20 16:02:51 +0530 | [diff] [blame^] | 143 | writel(tmp, s3c_rtc_base + S3C2410_TICNT); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 144 | spin_unlock_irq(&s3c_rtc_pie_lock); |
Ben Dooks | 773be7e | 2008-07-23 21:30:45 -0700 | [diff] [blame] | 145 | |
| 146 | return 0; |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | /* Time read/write */ |
| 150 | |
| 151 | static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm) |
| 152 | { |
| 153 | unsigned int have_retried = 0; |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 154 | void __iomem *base = s3c_rtc_base; |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 155 | |
| 156 | retry_get_time: |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 157 | rtc_tm->tm_min = readb(base + S3C2410_RTCMIN); |
| 158 | rtc_tm->tm_hour = readb(base + S3C2410_RTCHOUR); |
| 159 | rtc_tm->tm_mday = readb(base + S3C2410_RTCDATE); |
| 160 | rtc_tm->tm_mon = readb(base + S3C2410_RTCMON); |
| 161 | rtc_tm->tm_year = readb(base + S3C2410_RTCYEAR); |
| 162 | rtc_tm->tm_sec = readb(base + S3C2410_RTCSEC); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 163 | |
| 164 | /* the only way to work out wether the system was mid-update |
| 165 | * when we read it is to check the second counter, and if it |
| 166 | * is zero, then we re-try the entire read |
| 167 | */ |
| 168 | |
| 169 | if (rtc_tm->tm_sec == 0 && !have_retried) { |
| 170 | have_retried = 1; |
| 171 | goto retry_get_time; |
| 172 | } |
| 173 | |
| 174 | pr_debug("read time %02x.%02x.%02x %02x/%02x/%02x\n", |
| 175 | rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday, |
| 176 | rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec); |
| 177 | |
Adrian Bunk | fe20ba7 | 2008-10-18 20:28:41 -0700 | [diff] [blame] | 178 | rtc_tm->tm_sec = bcd2bin(rtc_tm->tm_sec); |
| 179 | rtc_tm->tm_min = bcd2bin(rtc_tm->tm_min); |
| 180 | rtc_tm->tm_hour = bcd2bin(rtc_tm->tm_hour); |
| 181 | rtc_tm->tm_mday = bcd2bin(rtc_tm->tm_mday); |
| 182 | rtc_tm->tm_mon = bcd2bin(rtc_tm->tm_mon); |
| 183 | rtc_tm->tm_year = bcd2bin(rtc_tm->tm_year); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 184 | |
| 185 | rtc_tm->tm_year += 100; |
| 186 | rtc_tm->tm_mon -= 1; |
| 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | static int s3c_rtc_settime(struct device *dev, struct rtc_time *tm) |
| 192 | { |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 193 | void __iomem *base = s3c_rtc_base; |
Ben Dooks | 641741e | 2006-08-27 01:23:27 -0700 | [diff] [blame] | 194 | int year = tm->tm_year - 100; |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 195 | |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 196 | pr_debug("set time %02d.%02d.%02d %02d/%02d/%02d\n", |
| 197 | tm->tm_year, tm->tm_mon, tm->tm_mday, |
| 198 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
| 199 | |
Ben Dooks | 641741e | 2006-08-27 01:23:27 -0700 | [diff] [blame] | 200 | /* we get around y2k by simply not supporting it */ |
| 201 | |
| 202 | if (year < 0 || year >= 100) { |
| 203 | dev_err(dev, "rtc only supports 100 years\n"); |
| 204 | return -EINVAL; |
| 205 | } |
| 206 | |
Adrian Bunk | fe20ba7 | 2008-10-18 20:28:41 -0700 | [diff] [blame] | 207 | writeb(bin2bcd(tm->tm_sec), base + S3C2410_RTCSEC); |
| 208 | writeb(bin2bcd(tm->tm_min), base + S3C2410_RTCMIN); |
| 209 | writeb(bin2bcd(tm->tm_hour), base + S3C2410_RTCHOUR); |
| 210 | writeb(bin2bcd(tm->tm_mday), base + S3C2410_RTCDATE); |
| 211 | writeb(bin2bcd(tm->tm_mon + 1), base + S3C2410_RTCMON); |
| 212 | writeb(bin2bcd(year), base + S3C2410_RTCYEAR); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 213 | |
| 214 | return 0; |
| 215 | } |
| 216 | |
| 217 | static int s3c_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm) |
| 218 | { |
| 219 | struct rtc_time *alm_tm = &alrm->time; |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 220 | void __iomem *base = s3c_rtc_base; |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 221 | unsigned int alm_en; |
| 222 | |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 223 | alm_tm->tm_sec = readb(base + S3C2410_ALMSEC); |
| 224 | alm_tm->tm_min = readb(base + S3C2410_ALMMIN); |
| 225 | alm_tm->tm_hour = readb(base + S3C2410_ALMHOUR); |
| 226 | alm_tm->tm_mon = readb(base + S3C2410_ALMMON); |
| 227 | alm_tm->tm_mday = readb(base + S3C2410_ALMDATE); |
| 228 | alm_tm->tm_year = readb(base + S3C2410_ALMYEAR); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 229 | |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 230 | alm_en = readb(base + S3C2410_RTCALM); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 231 | |
David Brownell | a2db8df | 2006-12-13 00:35:08 -0800 | [diff] [blame] | 232 | alrm->enabled = (alm_en & S3C2410_RTCALM_ALMEN) ? 1 : 0; |
| 233 | |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 234 | pr_debug("read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n", |
| 235 | alm_en, |
| 236 | alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday, |
| 237 | alm_tm->tm_hour, alm_tm->tm_min, alm_tm->tm_sec); |
| 238 | |
| 239 | |
| 240 | /* decode the alarm enable field */ |
| 241 | |
| 242 | if (alm_en & S3C2410_RTCALM_SECEN) |
Adrian Bunk | fe20ba7 | 2008-10-18 20:28:41 -0700 | [diff] [blame] | 243 | alm_tm->tm_sec = bcd2bin(alm_tm->tm_sec); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 244 | else |
| 245 | alm_tm->tm_sec = 0xff; |
| 246 | |
| 247 | if (alm_en & S3C2410_RTCALM_MINEN) |
Adrian Bunk | fe20ba7 | 2008-10-18 20:28:41 -0700 | [diff] [blame] | 248 | alm_tm->tm_min = bcd2bin(alm_tm->tm_min); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 249 | else |
| 250 | alm_tm->tm_min = 0xff; |
| 251 | |
| 252 | if (alm_en & S3C2410_RTCALM_HOUREN) |
Adrian Bunk | fe20ba7 | 2008-10-18 20:28:41 -0700 | [diff] [blame] | 253 | alm_tm->tm_hour = bcd2bin(alm_tm->tm_hour); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 254 | else |
| 255 | alm_tm->tm_hour = 0xff; |
| 256 | |
| 257 | if (alm_en & S3C2410_RTCALM_DAYEN) |
Adrian Bunk | fe20ba7 | 2008-10-18 20:28:41 -0700 | [diff] [blame] | 258 | alm_tm->tm_mday = bcd2bin(alm_tm->tm_mday); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 259 | else |
| 260 | alm_tm->tm_mday = 0xff; |
| 261 | |
| 262 | if (alm_en & S3C2410_RTCALM_MONEN) { |
Adrian Bunk | fe20ba7 | 2008-10-18 20:28:41 -0700 | [diff] [blame] | 263 | alm_tm->tm_mon = bcd2bin(alm_tm->tm_mon); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 264 | alm_tm->tm_mon -= 1; |
| 265 | } else { |
| 266 | alm_tm->tm_mon = 0xff; |
| 267 | } |
| 268 | |
| 269 | if (alm_en & S3C2410_RTCALM_YEAREN) |
Adrian Bunk | fe20ba7 | 2008-10-18 20:28:41 -0700 | [diff] [blame] | 270 | alm_tm->tm_year = bcd2bin(alm_tm->tm_year); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 271 | else |
| 272 | alm_tm->tm_year = 0xffff; |
| 273 | |
| 274 | return 0; |
| 275 | } |
| 276 | |
| 277 | static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) |
| 278 | { |
| 279 | struct rtc_time *tm = &alrm->time; |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 280 | void __iomem *base = s3c_rtc_base; |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 281 | unsigned int alrm_en; |
| 282 | |
| 283 | pr_debug("s3c_rtc_setalarm: %d, %02x/%02x/%02x %02x.%02x.%02x\n", |
| 284 | alrm->enabled, |
| 285 | tm->tm_mday & 0xff, tm->tm_mon & 0xff, tm->tm_year & 0xff, |
| 286 | tm->tm_hour & 0xff, tm->tm_min & 0xff, tm->tm_sec); |
| 287 | |
| 288 | |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 289 | alrm_en = readb(base + S3C2410_RTCALM) & S3C2410_RTCALM_ALMEN; |
| 290 | writeb(0x00, base + S3C2410_RTCALM); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 291 | |
| 292 | if (tm->tm_sec < 60 && tm->tm_sec >= 0) { |
| 293 | alrm_en |= S3C2410_RTCALM_SECEN; |
Adrian Bunk | fe20ba7 | 2008-10-18 20:28:41 -0700 | [diff] [blame] | 294 | writeb(bin2bcd(tm->tm_sec), base + S3C2410_ALMSEC); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | if (tm->tm_min < 60 && tm->tm_min >= 0) { |
| 298 | alrm_en |= S3C2410_RTCALM_MINEN; |
Adrian Bunk | fe20ba7 | 2008-10-18 20:28:41 -0700 | [diff] [blame] | 299 | writeb(bin2bcd(tm->tm_min), base + S3C2410_ALMMIN); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | if (tm->tm_hour < 24 && tm->tm_hour >= 0) { |
| 303 | alrm_en |= S3C2410_RTCALM_HOUREN; |
Adrian Bunk | fe20ba7 | 2008-10-18 20:28:41 -0700 | [diff] [blame] | 304 | writeb(bin2bcd(tm->tm_hour), base + S3C2410_ALMHOUR); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | pr_debug("setting S3C2410_RTCALM to %08x\n", alrm_en); |
| 308 | |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 309 | writeb(alrm_en, base + S3C2410_RTCALM); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 310 | |
Ben Dooks | 773be7e | 2008-07-23 21:30:45 -0700 | [diff] [blame] | 311 | s3c_rtc_setaie(alrm->enabled); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 312 | |
| 313 | if (alrm->enabled) |
| 314 | enable_irq_wake(s3c_rtc_alarmno); |
| 315 | else |
| 316 | disable_irq_wake(s3c_rtc_alarmno); |
| 317 | |
| 318 | return 0; |
| 319 | } |
| 320 | |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 321 | static int s3c_rtc_proc(struct device *dev, struct seq_file *seq) |
| 322 | { |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 323 | unsigned int ticnt; |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 324 | |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 325 | if (s3c_rtc_cpu_type == TYPE_S3C64XX) { |
| 326 | ticnt = readb(s3c_rtc_base + S3C2410_RTCCON); |
| 327 | ticnt &= S3C64XX_RTCCON_TICEN; |
| 328 | } else { |
| 329 | ticnt = readb(s3c_rtc_base + S3C2410_TICNT); |
| 330 | ticnt &= S3C2410_TICNT_ENABLE; |
| 331 | } |
| 332 | |
| 333 | seq_printf(seq, "periodic_IRQ\t: %s\n", ticnt ? "yes" : "no"); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 334 | return 0; |
| 335 | } |
| 336 | |
| 337 | static int s3c_rtc_open(struct device *dev) |
| 338 | { |
| 339 | struct platform_device *pdev = to_platform_device(dev); |
| 340 | struct rtc_device *rtc_dev = platform_get_drvdata(pdev); |
| 341 | int ret; |
| 342 | |
| 343 | ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq, |
Thomas Gleixner | 38515e9 | 2007-02-14 00:33:16 -0800 | [diff] [blame] | 344 | IRQF_DISABLED, "s3c2410-rtc alarm", rtc_dev); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 345 | |
| 346 | if (ret) { |
| 347 | dev_err(dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret); |
| 348 | return ret; |
| 349 | } |
| 350 | |
| 351 | ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq, |
Thomas Gleixner | 38515e9 | 2007-02-14 00:33:16 -0800 | [diff] [blame] | 352 | IRQF_DISABLED, "s3c2410-rtc tick", rtc_dev); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 353 | |
| 354 | if (ret) { |
| 355 | dev_err(dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret); |
| 356 | goto tick_err; |
| 357 | } |
| 358 | |
| 359 | return ret; |
| 360 | |
| 361 | tick_err: |
| 362 | free_irq(s3c_rtc_alarmno, rtc_dev); |
| 363 | return ret; |
| 364 | } |
| 365 | |
| 366 | static void s3c_rtc_release(struct device *dev) |
| 367 | { |
| 368 | struct platform_device *pdev = to_platform_device(dev); |
| 369 | struct rtc_device *rtc_dev = platform_get_drvdata(pdev); |
| 370 | |
| 371 | /* do not clear AIE here, it may be needed for wake */ |
| 372 | |
Ben Dooks | 773be7e | 2008-07-23 21:30:45 -0700 | [diff] [blame] | 373 | s3c_rtc_setpie(dev, 0); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 374 | free_irq(s3c_rtc_alarmno, rtc_dev); |
| 375 | free_irq(s3c_rtc_tickno, rtc_dev); |
| 376 | } |
| 377 | |
David Brownell | ff8371a | 2006-09-30 23:28:17 -0700 | [diff] [blame] | 378 | static const struct rtc_class_ops s3c_rtcops = { |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 379 | .open = s3c_rtc_open, |
| 380 | .release = s3c_rtc_release, |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 381 | .read_time = s3c_rtc_gettime, |
| 382 | .set_time = s3c_rtc_settime, |
| 383 | .read_alarm = s3c_rtc_getalarm, |
| 384 | .set_alarm = s3c_rtc_setalarm, |
Ben Dooks | 773be7e | 2008-07-23 21:30:45 -0700 | [diff] [blame] | 385 | .irq_set_freq = s3c_rtc_setfreq, |
| 386 | .irq_set_state = s3c_rtc_setpie, |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 387 | .proc = s3c_rtc_proc, |
| 388 | }; |
| 389 | |
| 390 | static void s3c_rtc_enable(struct platform_device *pdev, int en) |
| 391 | { |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 392 | void __iomem *base = s3c_rtc_base; |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 393 | unsigned int tmp; |
| 394 | |
| 395 | if (s3c_rtc_base == NULL) |
| 396 | return; |
| 397 | |
| 398 | if (!en) { |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 399 | tmp = readb(base + S3C2410_RTCCON); |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 400 | if (s3c_rtc_cpu_type == TYPE_S3C64XX) |
| 401 | tmp &= ~S3C64XX_RTCCON_TICEN; |
| 402 | tmp &= ~S3C2410_RTCCON_RTCEN; |
| 403 | writeb(tmp, base + S3C2410_RTCCON); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 404 | |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 405 | if (s3c_rtc_cpu_type == TYPE_S3C2410) { |
| 406 | tmp = readb(base + S3C2410_TICNT); |
| 407 | tmp &= ~S3C2410_TICNT_ENABLE; |
| 408 | writeb(tmp, base + S3C2410_TICNT); |
| 409 | } |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 410 | } else { |
| 411 | /* re-enable the device, and check it is ok */ |
| 412 | |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 413 | if ((readb(base+S3C2410_RTCCON) & S3C2410_RTCCON_RTCEN) == 0){ |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 414 | dev_info(&pdev->dev, "rtc disabled, re-enabling\n"); |
| 415 | |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 416 | tmp = readb(base + S3C2410_RTCCON); |
| 417 | writeb(tmp|S3C2410_RTCCON_RTCEN, base+S3C2410_RTCCON); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 418 | } |
| 419 | |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 420 | if ((readb(base + S3C2410_RTCCON) & S3C2410_RTCCON_CNTSEL)){ |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 421 | dev_info(&pdev->dev, "removing RTCCON_CNTSEL\n"); |
| 422 | |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 423 | tmp = readb(base + S3C2410_RTCCON); |
| 424 | writeb(tmp& ~S3C2410_RTCCON_CNTSEL, base+S3C2410_RTCCON); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 425 | } |
| 426 | |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 427 | if ((readb(base + S3C2410_RTCCON) & S3C2410_RTCCON_CLKRST)){ |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 428 | dev_info(&pdev->dev, "removing RTCCON_CLKRST\n"); |
| 429 | |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 430 | tmp = readb(base + S3C2410_RTCCON); |
| 431 | writeb(tmp & ~S3C2410_RTCCON_CLKRST, base+S3C2410_RTCCON); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 432 | } |
| 433 | } |
| 434 | } |
| 435 | |
Ben Dooks | 4cd0c5c | 2008-07-23 21:30:44 -0700 | [diff] [blame] | 436 | static int __devexit s3c_rtc_remove(struct platform_device *dev) |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 437 | { |
| 438 | struct rtc_device *rtc = platform_get_drvdata(dev); |
| 439 | |
| 440 | platform_set_drvdata(dev, NULL); |
| 441 | rtc_device_unregister(rtc); |
| 442 | |
Ben Dooks | 773be7e | 2008-07-23 21:30:45 -0700 | [diff] [blame] | 443 | s3c_rtc_setpie(&dev->dev, 0); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 444 | s3c_rtc_setaie(0); |
| 445 | |
Atul Dahiya | e48add8 | 2010-07-20 12:19:14 +0530 | [diff] [blame] | 446 | clk_disable(rtc_clk); |
| 447 | clk_put(rtc_clk); |
| 448 | rtc_clk = NULL; |
| 449 | |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 450 | iounmap(s3c_rtc_base); |
| 451 | release_resource(s3c_rtc_mem); |
| 452 | kfree(s3c_rtc_mem); |
| 453 | |
| 454 | return 0; |
| 455 | } |
| 456 | |
Ben Dooks | 4cd0c5c | 2008-07-23 21:30:44 -0700 | [diff] [blame] | 457 | static int __devinit s3c_rtc_probe(struct platform_device *pdev) |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 458 | { |
| 459 | struct rtc_device *rtc; |
| 460 | struct resource *res; |
| 461 | int ret; |
| 462 | |
Harvey Harrison | 2a4e2b8 | 2008-04-28 02:12:00 -0700 | [diff] [blame] | 463 | pr_debug("%s: probe=%p\n", __func__, pdev); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 464 | |
| 465 | /* find the IRQs */ |
| 466 | |
| 467 | s3c_rtc_tickno = platform_get_irq(pdev, 1); |
| 468 | if (s3c_rtc_tickno < 0) { |
| 469 | dev_err(&pdev->dev, "no irq for rtc tick\n"); |
| 470 | return -ENOENT; |
| 471 | } |
| 472 | |
| 473 | s3c_rtc_alarmno = platform_get_irq(pdev, 0); |
| 474 | if (s3c_rtc_alarmno < 0) { |
| 475 | dev_err(&pdev->dev, "no irq for alarm\n"); |
| 476 | return -ENOENT; |
| 477 | } |
| 478 | |
| 479 | pr_debug("s3c2410_rtc: tick irq %d, alarm irq %d\n", |
| 480 | s3c_rtc_tickno, s3c_rtc_alarmno); |
| 481 | |
| 482 | /* get the memory region */ |
| 483 | |
| 484 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 485 | if (res == NULL) { |
| 486 | dev_err(&pdev->dev, "failed to get memory region resource\n"); |
| 487 | return -ENOENT; |
| 488 | } |
| 489 | |
| 490 | s3c_rtc_mem = request_mem_region(res->start, |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 491 | res->end-res->start+1, |
| 492 | pdev->name); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 493 | |
| 494 | if (s3c_rtc_mem == NULL) { |
| 495 | dev_err(&pdev->dev, "failed to reserve memory region\n"); |
| 496 | ret = -ENOENT; |
| 497 | goto err_nores; |
| 498 | } |
| 499 | |
| 500 | s3c_rtc_base = ioremap(res->start, res->end - res->start + 1); |
| 501 | if (s3c_rtc_base == NULL) { |
| 502 | dev_err(&pdev->dev, "failed ioremap()\n"); |
| 503 | ret = -EINVAL; |
| 504 | goto err_nomap; |
| 505 | } |
| 506 | |
Atul Dahiya | e48add8 | 2010-07-20 12:19:14 +0530 | [diff] [blame] | 507 | rtc_clk = clk_get(&pdev->dev, "rtc"); |
| 508 | if (IS_ERR(rtc_clk)) { |
| 509 | dev_err(&pdev->dev, "failed to find rtc clock source\n"); |
| 510 | ret = PTR_ERR(rtc_clk); |
| 511 | rtc_clk = NULL; |
| 512 | goto err_clk; |
| 513 | } |
| 514 | |
| 515 | clk_enable(rtc_clk); |
| 516 | |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 517 | /* check to see if everything is setup correctly */ |
| 518 | |
| 519 | s3c_rtc_enable(pdev, 1); |
| 520 | |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 521 | pr_debug("s3c2410_rtc: RTCCON=%02x\n", |
| 522 | readb(s3c_rtc_base + S3C2410_RTCCON)); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 523 | |
Yauhen Kharuzhy | 51b7616 | 2008-10-29 14:01:16 -0700 | [diff] [blame] | 524 | device_init_wakeup(&pdev->dev, 1); |
| 525 | |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 526 | /* register RTC and exit */ |
| 527 | |
| 528 | rtc = rtc_device_register("s3c", &pdev->dev, &s3c_rtcops, |
| 529 | THIS_MODULE); |
| 530 | |
| 531 | if (IS_ERR(rtc)) { |
| 532 | dev_err(&pdev->dev, "cannot attach rtc\n"); |
| 533 | ret = PTR_ERR(rtc); |
| 534 | goto err_nortc; |
| 535 | } |
| 536 | |
Maurus Cuelenaere | eaa6e4d | 2010-06-04 14:14:46 -0700 | [diff] [blame] | 537 | s3c_rtc_cpu_type = platform_get_device_id(pdev)->driver_data; |
| 538 | |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 539 | if (s3c_rtc_cpu_type == TYPE_S3C64XX) |
| 540 | rtc->max_user_freq = 32768; |
| 541 | else |
| 542 | rtc->max_user_freq = 128; |
| 543 | |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 544 | platform_set_drvdata(pdev, rtc); |
Maurus Cuelenaere | e893de5 | 2010-06-04 14:14:44 -0700 | [diff] [blame] | 545 | |
| 546 | s3c_rtc_setfreq(&pdev->dev, 1); |
| 547 | |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 548 | return 0; |
| 549 | |
| 550 | err_nortc: |
| 551 | s3c_rtc_enable(pdev, 0); |
Atul Dahiya | e48add8 | 2010-07-20 12:19:14 +0530 | [diff] [blame] | 552 | clk_disable(rtc_clk); |
| 553 | clk_put(rtc_clk); |
| 554 | |
| 555 | err_clk: |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 556 | iounmap(s3c_rtc_base); |
| 557 | |
| 558 | err_nomap: |
| 559 | release_resource(s3c_rtc_mem); |
| 560 | |
| 561 | err_nores: |
| 562 | return ret; |
| 563 | } |
| 564 | |
| 565 | #ifdef CONFIG_PM |
| 566 | |
| 567 | /* RTC Power management control */ |
| 568 | |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 569 | static int ticnt_save, ticnt_en_save; |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 570 | |
| 571 | static int s3c_rtc_suspend(struct platform_device *pdev, pm_message_t state) |
| 572 | { |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 573 | /* save TICNT for anyone using periodic interrupts */ |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 574 | ticnt_save = readb(s3c_rtc_base + S3C2410_TICNT); |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 575 | if (s3c_rtc_cpu_type == TYPE_S3C64XX) { |
| 576 | ticnt_en_save = readb(s3c_rtc_base + S3C2410_RTCCON); |
| 577 | ticnt_en_save &= S3C64XX_RTCCON_TICEN; |
| 578 | } |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 579 | s3c_rtc_enable(pdev, 0); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 580 | return 0; |
| 581 | } |
| 582 | |
| 583 | static int s3c_rtc_resume(struct platform_device *pdev) |
| 584 | { |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 585 | unsigned int tmp; |
| 586 | |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 587 | s3c_rtc_enable(pdev, 1); |
Ben Dooks | 9a65451 | 2006-08-27 01:23:22 -0700 | [diff] [blame] | 588 | writeb(ticnt_save, s3c_rtc_base + S3C2410_TICNT); |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 589 | if (s3c_rtc_cpu_type == TYPE_S3C64XX && ticnt_en_save) { |
| 590 | tmp = readb(s3c_rtc_base + S3C2410_RTCCON); |
| 591 | writeb(tmp | ticnt_en_save, s3c_rtc_base + S3C2410_RTCCON); |
| 592 | } |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 593 | return 0; |
| 594 | } |
| 595 | #else |
| 596 | #define s3c_rtc_suspend NULL |
| 597 | #define s3c_rtc_resume NULL |
| 598 | #endif |
| 599 | |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 600 | static struct platform_device_id s3c_rtc_driver_ids[] = { |
| 601 | { |
| 602 | .name = "s3c2410-rtc", |
| 603 | .driver_data = TYPE_S3C2410, |
| 604 | }, { |
| 605 | .name = "s3c64xx-rtc", |
| 606 | .driver_data = TYPE_S3C64XX, |
| 607 | }, |
| 608 | { } |
| 609 | }; |
| 610 | |
| 611 | MODULE_DEVICE_TABLE(platform, s3c_rtc_driver_ids); |
| 612 | |
| 613 | static struct platform_driver s3c_rtc_driver = { |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 614 | .probe = s3c_rtc_probe, |
Ben Dooks | 4cd0c5c | 2008-07-23 21:30:44 -0700 | [diff] [blame] | 615 | .remove = __devexit_p(s3c_rtc_remove), |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 616 | .suspend = s3c_rtc_suspend, |
| 617 | .resume = s3c_rtc_resume, |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 618 | .id_table = s3c_rtc_driver_ids, |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 619 | .driver = { |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 620 | .name = "s3c-rtc", |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 621 | .owner = THIS_MODULE, |
| 622 | }, |
| 623 | }; |
| 624 | |
| 625 | static char __initdata banner[] = "S3C24XX RTC, (c) 2004,2006 Simtec Electronics\n"; |
| 626 | |
| 627 | static int __init s3c_rtc_init(void) |
| 628 | { |
| 629 | printk(banner); |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 630 | return platform_driver_register(&s3c_rtc_driver); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 631 | } |
| 632 | |
| 633 | static void __exit s3c_rtc_exit(void) |
| 634 | { |
Maurus Cuelenaere | 9f4123b | 2010-05-24 14:33:43 -0700 | [diff] [blame] | 635 | platform_driver_unregister(&s3c_rtc_driver); |
Ben Dooks | 1add678 | 2006-07-01 04:36:26 -0700 | [diff] [blame] | 636 | } |
| 637 | |
| 638 | module_init(s3c_rtc_init); |
| 639 | module_exit(s3c_rtc_exit); |
| 640 | |
| 641 | MODULE_DESCRIPTION("Samsung S3C RTC Driver"); |
| 642 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); |
| 643 | MODULE_LICENSE("GPL"); |
Kay Sievers | ad28a07 | 2008-04-10 21:29:25 -0700 | [diff] [blame] | 644 | MODULE_ALIAS("platform:s3c2410-rtc"); |