rtc-cmos.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274
  1. /*
  2. * RTC class driver for "CMOS RTC": PCs, ACPI, etc
  3. *
  4. * Copyright (C) 1996 Paul Gortmaker (drivers/char/rtc.c)
  5. * Copyright (C) 2006 David Brownell (convert to new framework)
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. */
  12. /*
  13. * The original "cmos clock" chip was an MC146818 chip, now obsolete.
  14. * That defined the register interface now provided by all PCs, some
  15. * non-PC systems, and incorporated into ACPI. Modern PC chipsets
  16. * integrate an MC146818 clone in their southbridge, and boards use
  17. * that instead of discrete clones like the DS12887 or M48T86. There
  18. * are also clones that connect using the LPC bus.
  19. *
  20. * That register API is also used directly by various other drivers
  21. * (notably for integrated NVRAM), infrastructure (x86 has code to
  22. * bypass the RTC framework, directly reading the RTC during boot
  23. * and updating minutes/seconds for systems using NTP synch) and
  24. * utilities (like userspace 'hwclock', if no /dev node exists).
  25. *
  26. * So **ALL** calls to CMOS_READ and CMOS_WRITE must be done with
  27. * interrupts disabled, holding the global rtc_lock, to exclude those
  28. * other drivers and utilities on correctly configured systems.
  29. */
  30. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  31. #include <linux/kernel.h>
  32. #include <linux/module.h>
  33. #include <linux/init.h>
  34. #include <linux/interrupt.h>
  35. #include <linux/spinlock.h>
  36. #include <linux/platform_device.h>
  37. #include <linux/log2.h>
  38. #include <linux/pm.h>
  39. #include <linux/of.h>
  40. #include <linux/of_platform.h>
  41. #include <linux/dmi.h>
  42. /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */
  43. #include <asm-generic/rtc.h>
  44. struct cmos_rtc {
  45. struct rtc_device *rtc;
  46. struct device *dev;
  47. int irq;
  48. struct resource *iomem;
  49. void (*wake_on)(struct device *);
  50. void (*wake_off)(struct device *);
  51. u8 enabled_wake;
  52. u8 suspend_ctrl;
  53. /* newer hardware extends the original register set */
  54. u8 day_alrm;
  55. u8 mon_alrm;
  56. u8 century;
  57. };
  58. /* both platform and pnp busses use negative numbers for invalid irqs */
  59. #define is_valid_irq(n) ((n) > 0)
  60. static const char driver_name[] = "rtc_cmos";
  61. /* The RTC_INTR register may have e.g. RTC_PF set even if RTC_PIE is clear;
  62. * always mask it against the irq enable bits in RTC_CONTROL. Bit values
  63. * are the same: PF==PIE, AF=AIE, UF=UIE; so RTC_IRQMASK works with both.
  64. */
  65. #define RTC_IRQMASK (RTC_PF | RTC_AF | RTC_UF)
  66. static inline int is_intr(u8 rtc_intr)
  67. {
  68. if (!(rtc_intr & RTC_IRQF))
  69. return 0;
  70. return rtc_intr & RTC_IRQMASK;
  71. }
  72. /*----------------------------------------------------------------*/
  73. /* Much modern x86 hardware has HPETs (10+ MHz timers) which, because
  74. * many BIOS programmers don't set up "sane mode" IRQ routing, are mostly
  75. * used in a broken "legacy replacement" mode. The breakage includes
  76. * HPET #1 hijacking the IRQ for this RTC, and being unavailable for
  77. * other (better) use.
  78. *
  79. * When that broken mode is in use, platform glue provides a partial
  80. * emulation of hardware RTC IRQ facilities using HPET #1. We don't
  81. * want to use HPET for anything except those IRQs though...
  82. */
  83. #ifdef CONFIG_HPET_EMULATE_RTC
  84. #include <asm/hpet.h>
  85. #else
  86. static inline int is_hpet_enabled(void)
  87. {
  88. return 0;
  89. }
  90. static inline int hpet_mask_rtc_irq_bit(unsigned long mask)
  91. {
  92. return 0;
  93. }
  94. static inline int hpet_set_rtc_irq_bit(unsigned long mask)
  95. {
  96. return 0;
  97. }
  98. static inline int
  99. hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec)
  100. {
  101. return 0;
  102. }
  103. static inline int hpet_set_periodic_freq(unsigned long freq)
  104. {
  105. return 0;
  106. }
  107. static inline int hpet_rtc_dropped_irq(void)
  108. {
  109. return 0;
  110. }
  111. static inline int hpet_rtc_timer_init(void)
  112. {
  113. return 0;
  114. }
  115. extern irq_handler_t hpet_rtc_interrupt;
  116. static inline int hpet_register_irq_handler(irq_handler_t handler)
  117. {
  118. return 0;
  119. }
  120. static inline int hpet_unregister_irq_handler(irq_handler_t handler)
  121. {
  122. return 0;
  123. }
  124. #endif
  125. /*----------------------------------------------------------------*/
  126. #ifdef RTC_PORT
  127. /* Most newer x86 systems have two register banks, the first used
  128. * for RTC and NVRAM and the second only for NVRAM. Caller must
  129. * own rtc_lock ... and we won't worry about access during NMI.
  130. */
  131. #define can_bank2 true
  132. static inline unsigned char cmos_read_bank2(unsigned char addr)
  133. {
  134. outb(addr, RTC_PORT(2));
  135. return inb(RTC_PORT(3));
  136. }
  137. static inline void cmos_write_bank2(unsigned char val, unsigned char addr)
  138. {
  139. outb(addr, RTC_PORT(2));
  140. outb(val, RTC_PORT(3));
  141. }
  142. #else
  143. #define can_bank2 false
  144. static inline unsigned char cmos_read_bank2(unsigned char addr)
  145. {
  146. return 0;
  147. }
  148. static inline void cmos_write_bank2(unsigned char val, unsigned char addr)
  149. {
  150. }
  151. #endif
  152. /*----------------------------------------------------------------*/
  153. static int cmos_read_time(struct device *dev, struct rtc_time *t)
  154. {
  155. /* REVISIT: if the clock has a "century" register, use
  156. * that instead of the heuristic in get_rtc_time().
  157. * That'll make Y3K compatility (year > 2070) easy!
  158. */
  159. get_rtc_time(t);
  160. return 0;
  161. }
  162. static int cmos_set_time(struct device *dev, struct rtc_time *t)
  163. {
  164. /* REVISIT: set the "century" register if available
  165. *
  166. * NOTE: this ignores the issue whereby updating the seconds
  167. * takes effect exactly 500ms after we write the register.
  168. * (Also queueing and other delays before we get this far.)
  169. */
  170. return set_rtc_time(t);
  171. }
  172. static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t)
  173. {
  174. struct cmos_rtc *cmos = dev_get_drvdata(dev);
  175. unsigned char rtc_control;
  176. if (!is_valid_irq(cmos->irq))
  177. return -EIO;
  178. /* Basic alarms only support hour, minute, and seconds fields.
  179. * Some also support day and month, for alarms up to a year in
  180. * the future.
  181. */
  182. t->time.tm_mday = -1;
  183. t->time.tm_mon = -1;
  184. spin_lock_irq(&rtc_lock);
  185. t->time.tm_sec = CMOS_READ(RTC_SECONDS_ALARM);
  186. t->time.tm_min = CMOS_READ(RTC_MINUTES_ALARM);
  187. t->time.tm_hour = CMOS_READ(RTC_HOURS_ALARM);
  188. if (cmos->day_alrm) {
  189. /* ignore upper bits on readback per ACPI spec */
  190. t->time.tm_mday = CMOS_READ(cmos->day_alrm) & 0x3f;
  191. if (!t->time.tm_mday)
  192. t->time.tm_mday = -1;
  193. if (cmos->mon_alrm) {
  194. t->time.tm_mon = CMOS_READ(cmos->mon_alrm);
  195. if (!t->time.tm_mon)
  196. t->time.tm_mon = -1;
  197. }
  198. }
  199. rtc_control = CMOS_READ(RTC_CONTROL);
  200. spin_unlock_irq(&rtc_lock);
  201. if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
  202. if (((unsigned)t->time.tm_sec) < 0x60)
  203. t->time.tm_sec = bcd2bin(t->time.tm_sec);
  204. else
  205. t->time.tm_sec = -1;
  206. if (((unsigned)t->time.tm_min) < 0x60)
  207. t->time.tm_min = bcd2bin(t->time.tm_min);
  208. else
  209. t->time.tm_min = -1;
  210. if (((unsigned)t->time.tm_hour) < 0x24)
  211. t->time.tm_hour = bcd2bin(t->time.tm_hour);
  212. else
  213. t->time.tm_hour = -1;
  214. if (cmos->day_alrm) {
  215. if (((unsigned)t->time.tm_mday) <= 0x31)
  216. t->time.tm_mday = bcd2bin(t->time.tm_mday);
  217. else
  218. t->time.tm_mday = -1;
  219. if (cmos->mon_alrm) {
  220. if (((unsigned)t->time.tm_mon) <= 0x12)
  221. t->time.tm_mon = bcd2bin(t->time.tm_mon)-1;
  222. else
  223. t->time.tm_mon = -1;
  224. }
  225. }
  226. }
  227. t->time.tm_year = -1;
  228. t->enabled = !!(rtc_control & RTC_AIE);
  229. t->pending = 0;
  230. return 0;
  231. }
  232. static void cmos_checkintr(struct cmos_rtc *cmos, unsigned char rtc_control)
  233. {
  234. unsigned char rtc_intr;
  235. /* NOTE after changing RTC_xIE bits we always read INTR_FLAGS;
  236. * allegedly some older rtcs need that to handle irqs properly
  237. */
  238. rtc_intr = CMOS_READ(RTC_INTR_FLAGS);
  239. if (is_hpet_enabled())
  240. return;
  241. rtc_intr &= (rtc_control & RTC_IRQMASK) | RTC_IRQF;
  242. if (is_intr(rtc_intr))
  243. rtc_update_irq(cmos->rtc, 1, rtc_intr);
  244. }
  245. static void cmos_irq_enable(struct cmos_rtc *cmos, unsigned char mask)
  246. {
  247. unsigned char rtc_control;
  248. /* flush any pending IRQ status, notably for update irqs,
  249. * before we enable new IRQs
  250. */
  251. rtc_control = CMOS_READ(RTC_CONTROL);
  252. cmos_checkintr(cmos, rtc_control);
  253. rtc_control |= mask;
  254. CMOS_WRITE(rtc_control, RTC_CONTROL);
  255. hpet_set_rtc_irq_bit(mask);
  256. cmos_checkintr(cmos, rtc_control);
  257. }
  258. static void cmos_irq_disable(struct cmos_rtc *cmos, unsigned char mask)
  259. {
  260. unsigned char rtc_control;
  261. rtc_control = CMOS_READ(RTC_CONTROL);
  262. rtc_control &= ~mask;
  263. CMOS_WRITE(rtc_control, RTC_CONTROL);
  264. hpet_mask_rtc_irq_bit(mask);
  265. cmos_checkintr(cmos, rtc_control);
  266. }
  267. static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t)
  268. {
  269. struct cmos_rtc *cmos = dev_get_drvdata(dev);
  270. unsigned char mon, mday, hrs, min, sec, rtc_control;
  271. if (!is_valid_irq(cmos->irq))
  272. return -EIO;
  273. mon = t->time.tm_mon + 1;
  274. mday = t->time.tm_mday;
  275. hrs = t->time.tm_hour;
  276. min = t->time.tm_min;
  277. sec = t->time.tm_sec;
  278. rtc_control = CMOS_READ(RTC_CONTROL);
  279. if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
  280. /* Writing 0xff means "don't care" or "match all". */
  281. mon = (mon <= 12) ? bin2bcd(mon) : 0xff;
  282. mday = (mday >= 1 && mday <= 31) ? bin2bcd(mday) : 0xff;
  283. hrs = (hrs < 24) ? bin2bcd(hrs) : 0xff;
  284. min = (min < 60) ? bin2bcd(min) : 0xff;
  285. sec = (sec < 60) ? bin2bcd(sec) : 0xff;
  286. }
  287. spin_lock_irq(&rtc_lock);
  288. /* next rtc irq must not be from previous alarm setting */
  289. cmos_irq_disable(cmos, RTC_AIE);
  290. /* update alarm */
  291. CMOS_WRITE(hrs, RTC_HOURS_ALARM);
  292. CMOS_WRITE(min, RTC_MINUTES_ALARM);
  293. CMOS_WRITE(sec, RTC_SECONDS_ALARM);
  294. /* the system may support an "enhanced" alarm */
  295. if (cmos->day_alrm) {
  296. CMOS_WRITE(mday, cmos->day_alrm);
  297. if (cmos->mon_alrm)
  298. CMOS_WRITE(mon, cmos->mon_alrm);
  299. }
  300. /* FIXME the HPET alarm glue currently ignores day_alrm
  301. * and mon_alrm ...
  302. */
  303. hpet_set_alarm_time(t->time.tm_hour, t->time.tm_min, t->time.tm_sec);
  304. if (t->enabled)
  305. cmos_irq_enable(cmos, RTC_AIE);
  306. spin_unlock_irq(&rtc_lock);
  307. return 0;
  308. }
  309. /*
  310. * Do not disable RTC alarm on shutdown - workaround for b0rked BIOSes.
  311. */
  312. static bool alarm_disable_quirk;
  313. static int __init set_alarm_disable_quirk(const struct dmi_system_id *id)
  314. {
  315. alarm_disable_quirk = true;
  316. pr_info("BIOS has alarm-disable quirk - RTC alarms disabled\n");
  317. return 0;
  318. }
  319. static const struct dmi_system_id rtc_quirks[] __initconst = {
  320. /* https://bugzilla.novell.com/show_bug.cgi?id=805740 */
  321. {
  322. .callback = set_alarm_disable_quirk,
  323. .ident = "IBM Truman",
  324. .matches = {
  325. DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
  326. DMI_MATCH(DMI_PRODUCT_NAME, "4852570"),
  327. },
  328. },
  329. /* https://bugzilla.novell.com/show_bug.cgi?id=812592 */
  330. {
  331. .callback = set_alarm_disable_quirk,
  332. .ident = "Gigabyte GA-990XA-UD3",
  333. .matches = {
  334. DMI_MATCH(DMI_SYS_VENDOR,
  335. "Gigabyte Technology Co., Ltd."),
  336. DMI_MATCH(DMI_PRODUCT_NAME, "GA-990XA-UD3"),
  337. },
  338. },
  339. /* http://permalink.gmane.org/gmane.linux.kernel/1604474 */
  340. {
  341. .callback = set_alarm_disable_quirk,
  342. .ident = "Toshiba Satellite L300",
  343. .matches = {
  344. DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
  345. DMI_MATCH(DMI_PRODUCT_NAME, "Satellite L300"),
  346. },
  347. },
  348. {}
  349. };
  350. static int cmos_alarm_irq_enable(struct device *dev, unsigned int enabled)
  351. {
  352. struct cmos_rtc *cmos = dev_get_drvdata(dev);
  353. unsigned long flags;
  354. if (!is_valid_irq(cmos->irq))
  355. return -EINVAL;
  356. if (alarm_disable_quirk)
  357. return 0;
  358. spin_lock_irqsave(&rtc_lock, flags);
  359. if (enabled)
  360. cmos_irq_enable(cmos, RTC_AIE);
  361. else
  362. cmos_irq_disable(cmos, RTC_AIE);
  363. spin_unlock_irqrestore(&rtc_lock, flags);
  364. return 0;
  365. }
  366. #if defined(CONFIG_RTC_INTF_PROC) || defined(CONFIG_RTC_INTF_PROC_MODULE)
  367. static int cmos_procfs(struct device *dev, struct seq_file *seq)
  368. {
  369. struct cmos_rtc *cmos = dev_get_drvdata(dev);
  370. unsigned char rtc_control, valid;
  371. spin_lock_irq(&rtc_lock);
  372. rtc_control = CMOS_READ(RTC_CONTROL);
  373. valid = CMOS_READ(RTC_VALID);
  374. spin_unlock_irq(&rtc_lock);
  375. /* NOTE: at least ICH6 reports battery status using a different
  376. * (non-RTC) bit; and SQWE is ignored on many current systems.
  377. */
  378. seq_printf(seq,
  379. "periodic_IRQ\t: %s\n"
  380. "update_IRQ\t: %s\n"
  381. "HPET_emulated\t: %s\n"
  382. // "square_wave\t: %s\n"
  383. "BCD\t\t: %s\n"
  384. "DST_enable\t: %s\n"
  385. "periodic_freq\t: %d\n"
  386. "batt_status\t: %s\n",
  387. (rtc_control & RTC_PIE) ? "yes" : "no",
  388. (rtc_control & RTC_UIE) ? "yes" : "no",
  389. is_hpet_enabled() ? "yes" : "no",
  390. // (rtc_control & RTC_SQWE) ? "yes" : "no",
  391. (rtc_control & RTC_DM_BINARY) ? "no" : "yes",
  392. (rtc_control & RTC_DST_EN) ? "yes" : "no",
  393. cmos->rtc->irq_freq,
  394. (valid & RTC_VRT) ? "okay" : "dead");
  395. return 0;
  396. }
  397. #else
  398. #define cmos_procfs NULL
  399. #endif
  400. static const struct rtc_class_ops cmos_rtc_ops = {
  401. .read_time = cmos_read_time,
  402. .set_time = cmos_set_time,
  403. .read_alarm = cmos_read_alarm,
  404. .set_alarm = cmos_set_alarm,
  405. .proc = cmos_procfs,
  406. .alarm_irq_enable = cmos_alarm_irq_enable,
  407. };
  408. /*----------------------------------------------------------------*/
  409. /*
  410. * All these chips have at least 64 bytes of address space, shared by
  411. * RTC registers and NVRAM. Most of those bytes of NVRAM are used
  412. * by boot firmware. Modern chips have 128 or 256 bytes.
  413. */
  414. #define NVRAM_OFFSET (RTC_REG_D + 1)
  415. static ssize_t
  416. cmos_nvram_read(struct file *filp, struct kobject *kobj,
  417. struct bin_attribute *attr,
  418. char *buf, loff_t off, size_t count)
  419. {
  420. int retval;
  421. if (unlikely(off >= attr->size))
  422. return 0;
  423. if (unlikely(off < 0))
  424. return -EINVAL;
  425. if ((off + count) > attr->size)
  426. count = attr->size - off;
  427. off += NVRAM_OFFSET;
  428. spin_lock_irq(&rtc_lock);
  429. for (retval = 0; count; count--, off++, retval++) {
  430. if (off < 128)
  431. *buf++ = CMOS_READ(off);
  432. else if (can_bank2)
  433. *buf++ = cmos_read_bank2(off);
  434. else
  435. break;
  436. }
  437. spin_unlock_irq(&rtc_lock);
  438. return retval;
  439. }
  440. static ssize_t
  441. cmos_nvram_write(struct file *filp, struct kobject *kobj,
  442. struct bin_attribute *attr,
  443. char *buf, loff_t off, size_t count)
  444. {
  445. struct cmos_rtc *cmos;
  446. int retval;
  447. cmos = dev_get_drvdata(container_of(kobj, struct device, kobj));
  448. if (unlikely(off >= attr->size))
  449. return -EFBIG;
  450. if (unlikely(off < 0))
  451. return -EINVAL;
  452. if ((off + count) > attr->size)
  453. count = attr->size - off;
  454. /* NOTE: on at least PCs and Ataris, the boot firmware uses a
  455. * checksum on part of the NVRAM data. That's currently ignored
  456. * here. If userspace is smart enough to know what fields of
  457. * NVRAM to update, updating checksums is also part of its job.
  458. */
  459. off += NVRAM_OFFSET;
  460. spin_lock_irq(&rtc_lock);
  461. for (retval = 0; count; count--, off++, retval++) {
  462. /* don't trash RTC registers */
  463. if (off == cmos->day_alrm
  464. || off == cmos->mon_alrm
  465. || off == cmos->century)
  466. buf++;
  467. else if (off < 128)
  468. CMOS_WRITE(*buf++, off);
  469. else if (can_bank2)
  470. cmos_write_bank2(*buf++, off);
  471. else
  472. break;
  473. }
  474. spin_unlock_irq(&rtc_lock);
  475. return retval;
  476. }
  477. static struct bin_attribute nvram = {
  478. .attr = {
  479. .name = "nvram",
  480. .mode = S_IRUGO | S_IWUSR,
  481. },
  482. .read = cmos_nvram_read,
  483. .write = cmos_nvram_write,
  484. /* size gets set up later */
  485. };
  486. /*----------------------------------------------------------------*/
  487. static struct cmos_rtc cmos_rtc;
  488. static irqreturn_t cmos_interrupt(int irq, void *p)
  489. {
  490. u8 irqstat;
  491. u8 rtc_control;
  492. spin_lock(&rtc_lock);
  493. /* When the HPET interrupt handler calls us, the interrupt
  494. * status is passed as arg1 instead of the irq number. But
  495. * always clear irq status, even when HPET is in the way.
  496. *
  497. * Note that HPET and RTC are almost certainly out of phase,
  498. * giving different IRQ status ...
  499. */
  500. irqstat = CMOS_READ(RTC_INTR_FLAGS);
  501. rtc_control = CMOS_READ(RTC_CONTROL);
  502. if (is_hpet_enabled())
  503. irqstat = (unsigned long)irq & 0xF0;
  504. /* If we were suspended, RTC_CONTROL may not be accurate since the
  505. * bios may have cleared it.
  506. */
  507. if (!cmos_rtc.suspend_ctrl)
  508. irqstat &= (rtc_control & RTC_IRQMASK) | RTC_IRQF;
  509. else
  510. irqstat &= (cmos_rtc.suspend_ctrl & RTC_IRQMASK) | RTC_IRQF;
  511. /* All Linux RTC alarms should be treated as if they were oneshot.
  512. * Similar code may be needed in system wakeup paths, in case the
  513. * alarm woke the system.
  514. */
  515. if (irqstat & RTC_AIE) {
  516. cmos_rtc.suspend_ctrl &= ~RTC_AIE;
  517. rtc_control &= ~RTC_AIE;
  518. CMOS_WRITE(rtc_control, RTC_CONTROL);
  519. hpet_mask_rtc_irq_bit(RTC_AIE);
  520. CMOS_READ(RTC_INTR_FLAGS);
  521. }
  522. spin_unlock(&rtc_lock);
  523. if (is_intr(irqstat)) {
  524. rtc_update_irq(p, 1, irqstat);
  525. return IRQ_HANDLED;
  526. } else
  527. return IRQ_NONE;
  528. }
  529. #ifdef CONFIG_PNP
  530. #define INITSECTION
  531. #else
  532. #define INITSECTION __init
  533. #endif
  534. static int INITSECTION
  535. cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
  536. {
  537. struct cmos_rtc_board_info *info = dev_get_platdata(dev);
  538. int retval = 0;
  539. unsigned char rtc_control;
  540. unsigned address_space;
  541. u32 flags = 0;
  542. /* there can be only one ... */
  543. if (cmos_rtc.dev)
  544. return -EBUSY;
  545. if (!ports)
  546. return -ENODEV;
  547. /* Claim I/O ports ASAP, minimizing conflict with legacy driver.
  548. *
  549. * REVISIT non-x86 systems may instead use memory space resources
  550. * (needing ioremap etc), not i/o space resources like this ...
  551. */
  552. if (RTC_IOMAPPED)
  553. ports = request_region(ports->start, resource_size(ports),
  554. driver_name);
  555. else
  556. ports = request_mem_region(ports->start, resource_size(ports),
  557. driver_name);
  558. if (!ports) {
  559. dev_dbg(dev, "i/o registers already in use\n");
  560. return -EBUSY;
  561. }
  562. cmos_rtc.irq = rtc_irq;
  563. cmos_rtc.iomem = ports;
  564. /* Heuristic to deduce NVRAM size ... do what the legacy NVRAM
  565. * driver did, but don't reject unknown configs. Old hardware
  566. * won't address 128 bytes. Newer chips have multiple banks,
  567. * though they may not be listed in one I/O resource.
  568. */
  569. #if defined(CONFIG_ATARI)
  570. address_space = 64;
  571. #elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) \
  572. || defined(__sparc__) || defined(__mips__) \
  573. || defined(__powerpc__)
  574. address_space = 128;
  575. #else
  576. #warning Assuming 128 bytes of RTC+NVRAM address space, not 64 bytes.
  577. address_space = 128;
  578. #endif
  579. if (can_bank2 && ports->end > (ports->start + 1))
  580. address_space = 256;
  581. /* For ACPI systems extension info comes from the FADT. On others,
  582. * board specific setup provides it as appropriate. Systems where
  583. * the alarm IRQ isn't automatically a wakeup IRQ (like ACPI, and
  584. * some almost-clones) can provide hooks to make that behave.
  585. *
  586. * Note that ACPI doesn't preclude putting these registers into
  587. * "extended" areas of the chip, including some that we won't yet
  588. * expect CMOS_READ and friends to handle.
  589. */
  590. if (info) {
  591. if (info->flags)
  592. flags = info->flags;
  593. if (info->address_space)
  594. address_space = info->address_space;
  595. if (info->rtc_day_alarm && info->rtc_day_alarm < 128)
  596. cmos_rtc.day_alrm = info->rtc_day_alarm;
  597. if (info->rtc_mon_alarm && info->rtc_mon_alarm < 128)
  598. cmos_rtc.mon_alrm = info->rtc_mon_alarm;
  599. if (info->rtc_century && info->rtc_century < 128)
  600. cmos_rtc.century = info->rtc_century;
  601. if (info->wake_on && info->wake_off) {
  602. cmos_rtc.wake_on = info->wake_on;
  603. cmos_rtc.wake_off = info->wake_off;
  604. }
  605. }
  606. cmos_rtc.dev = dev;
  607. dev_set_drvdata(dev, &cmos_rtc);
  608. cmos_rtc.rtc = rtc_device_register(driver_name, dev,
  609. &cmos_rtc_ops, THIS_MODULE);
  610. if (IS_ERR(cmos_rtc.rtc)) {
  611. retval = PTR_ERR(cmos_rtc.rtc);
  612. goto cleanup0;
  613. }
  614. rename_region(ports, dev_name(&cmos_rtc.rtc->dev));
  615. spin_lock_irq(&rtc_lock);
  616. if (!(flags & CMOS_RTC_FLAGS_NOFREQ)) {
  617. /* force periodic irq to CMOS reset default of 1024Hz;
  618. *
  619. * REVISIT it's been reported that at least one x86_64 ALI
  620. * mobo doesn't use 32KHz here ... for portability we might
  621. * need to do something about other clock frequencies.
  622. */
  623. cmos_rtc.rtc->irq_freq = 1024;
  624. hpet_set_periodic_freq(cmos_rtc.rtc->irq_freq);
  625. CMOS_WRITE(RTC_REF_CLCK_32KHZ | 0x06, RTC_FREQ_SELECT);
  626. }
  627. /* disable irqs */
  628. if (is_valid_irq(rtc_irq))
  629. cmos_irq_disable(&cmos_rtc, RTC_PIE | RTC_AIE | RTC_UIE);
  630. rtc_control = CMOS_READ(RTC_CONTROL);
  631. spin_unlock_irq(&rtc_lock);
  632. /* FIXME:
  633. * <asm-generic/rtc.h> doesn't know 12-hour mode either.
  634. */
  635. if (is_valid_irq(rtc_irq) && !(rtc_control & RTC_24H)) {
  636. dev_warn(dev, "only 24-hr supported\n");
  637. retval = -ENXIO;
  638. goto cleanup1;
  639. }
  640. if (is_valid_irq(rtc_irq)) {
  641. irq_handler_t rtc_cmos_int_handler;
  642. if (is_hpet_enabled()) {
  643. rtc_cmos_int_handler = hpet_rtc_interrupt;
  644. retval = hpet_register_irq_handler(cmos_interrupt);
  645. if (retval) {
  646. dev_warn(dev, "hpet_register_irq_handler "
  647. " failed in rtc_init().");
  648. goto cleanup1;
  649. }
  650. } else
  651. rtc_cmos_int_handler = cmos_interrupt;
  652. retval = request_irq(rtc_irq, rtc_cmos_int_handler,
  653. 0, dev_name(&cmos_rtc.rtc->dev),
  654. cmos_rtc.rtc);
  655. if (retval < 0) {
  656. dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
  657. goto cleanup1;
  658. }
  659. }
  660. hpet_rtc_timer_init();
  661. /* export at least the first block of NVRAM */
  662. nvram.size = address_space - NVRAM_OFFSET;
  663. retval = sysfs_create_bin_file(&dev->kobj, &nvram);
  664. if (retval < 0) {
  665. dev_dbg(dev, "can't create nvram file? %d\n", retval);
  666. goto cleanup2;
  667. }
  668. dev_info(dev, "%s%s, %zd bytes nvram%s\n",
  669. !is_valid_irq(rtc_irq) ? "no alarms" :
  670. cmos_rtc.mon_alrm ? "alarms up to one year" :
  671. cmos_rtc.day_alrm ? "alarms up to one month" :
  672. "alarms up to one day",
  673. cmos_rtc.century ? ", y3k" : "",
  674. nvram.size,
  675. is_hpet_enabled() ? ", hpet irqs" : "");
  676. return 0;
  677. cleanup2:
  678. if (is_valid_irq(rtc_irq))
  679. free_irq(rtc_irq, cmos_rtc.rtc);
  680. cleanup1:
  681. cmos_rtc.dev = NULL;
  682. rtc_device_unregister(cmos_rtc.rtc);
  683. cleanup0:
  684. if (RTC_IOMAPPED)
  685. release_region(ports->start, resource_size(ports));
  686. else
  687. release_mem_region(ports->start, resource_size(ports));
  688. return retval;
  689. }
  690. static void cmos_do_shutdown(int rtc_irq)
  691. {
  692. spin_lock_irq(&rtc_lock);
  693. if (is_valid_irq(rtc_irq))
  694. cmos_irq_disable(&cmos_rtc, RTC_IRQMASK);
  695. spin_unlock_irq(&rtc_lock);
  696. }
  697. static void __exit cmos_do_remove(struct device *dev)
  698. {
  699. struct cmos_rtc *cmos = dev_get_drvdata(dev);
  700. struct resource *ports;
  701. cmos_do_shutdown(cmos->irq);
  702. sysfs_remove_bin_file(&dev->kobj, &nvram);
  703. if (is_valid_irq(cmos->irq)) {
  704. free_irq(cmos->irq, cmos->rtc);
  705. hpet_unregister_irq_handler(cmos_interrupt);
  706. }
  707. rtc_device_unregister(cmos->rtc);
  708. cmos->rtc = NULL;
  709. ports = cmos->iomem;
  710. if (RTC_IOMAPPED)
  711. release_region(ports->start, resource_size(ports));
  712. else
  713. release_mem_region(ports->start, resource_size(ports));
  714. cmos->iomem = NULL;
  715. cmos->dev = NULL;
  716. }
  717. #ifdef CONFIG_PM
  718. static int cmos_suspend(struct device *dev)
  719. {
  720. struct cmos_rtc *cmos = dev_get_drvdata(dev);
  721. unsigned char tmp;
  722. /* only the alarm might be a wakeup event source */
  723. spin_lock_irq(&rtc_lock);
  724. cmos->suspend_ctrl = tmp = CMOS_READ(RTC_CONTROL);
  725. if (tmp & (RTC_PIE|RTC_AIE|RTC_UIE)) {
  726. unsigned char mask;
  727. if (device_may_wakeup(dev))
  728. mask = RTC_IRQMASK & ~RTC_AIE;
  729. else
  730. mask = RTC_IRQMASK;
  731. tmp &= ~mask;
  732. CMOS_WRITE(tmp, RTC_CONTROL);
  733. hpet_mask_rtc_irq_bit(mask);
  734. cmos_checkintr(cmos, tmp);
  735. }
  736. spin_unlock_irq(&rtc_lock);
  737. if (tmp & RTC_AIE) {
  738. cmos->enabled_wake = 1;
  739. if (cmos->wake_on)
  740. cmos->wake_on(dev);
  741. else
  742. enable_irq_wake(cmos->irq);
  743. }
  744. dev_dbg(dev, "suspend%s, ctrl %02x\n",
  745. (tmp & RTC_AIE) ? ", alarm may wake" : "",
  746. tmp);
  747. return 0;
  748. }
  749. /* We want RTC alarms to wake us from e.g. ACPI G2/S5 "soft off", even
  750. * after a detour through G3 "mechanical off", although the ACPI spec
  751. * says wakeup should only work from G1/S4 "hibernate". To most users,
  752. * distinctions between S4 and S5 are pointless. So when the hardware
  753. * allows, don't draw that distinction.
  754. */
  755. static inline int cmos_poweroff(struct device *dev)
  756. {
  757. return cmos_suspend(dev);
  758. }
  759. #ifdef CONFIG_PM_SLEEP
  760. static int cmos_resume(struct device *dev)
  761. {
  762. struct cmos_rtc *cmos = dev_get_drvdata(dev);
  763. unsigned char tmp;
  764. if (cmos->enabled_wake) {
  765. if (cmos->wake_off)
  766. cmos->wake_off(dev);
  767. else
  768. disable_irq_wake(cmos->irq);
  769. cmos->enabled_wake = 0;
  770. }
  771. spin_lock_irq(&rtc_lock);
  772. tmp = cmos->suspend_ctrl;
  773. cmos->suspend_ctrl = 0;
  774. /* re-enable any irqs previously active */
  775. if (tmp & RTC_IRQMASK) {
  776. unsigned char mask;
  777. if (device_may_wakeup(dev))
  778. hpet_rtc_timer_init();
  779. do {
  780. CMOS_WRITE(tmp, RTC_CONTROL);
  781. hpet_set_rtc_irq_bit(tmp & RTC_IRQMASK);
  782. mask = CMOS_READ(RTC_INTR_FLAGS);
  783. mask &= (tmp & RTC_IRQMASK) | RTC_IRQF;
  784. if (!is_hpet_enabled() || !is_intr(mask))
  785. break;
  786. /* force one-shot behavior if HPET blocked
  787. * the wake alarm's irq
  788. */
  789. rtc_update_irq(cmos->rtc, 1, mask);
  790. tmp &= ~RTC_AIE;
  791. hpet_mask_rtc_irq_bit(RTC_AIE);
  792. } while (mask & RTC_AIE);
  793. }
  794. spin_unlock_irq(&rtc_lock);
  795. dev_dbg(dev, "resume, ctrl %02x\n", tmp);
  796. return 0;
  797. }
  798. #endif
  799. #else
  800. static inline int cmos_poweroff(struct device *dev)
  801. {
  802. return -ENOSYS;
  803. }
  804. #endif
  805. static SIMPLE_DEV_PM_OPS(cmos_pm_ops, cmos_suspend, cmos_resume);
  806. /*----------------------------------------------------------------*/
  807. /* On non-x86 systems, a "CMOS" RTC lives most naturally on platform_bus.
  808. * ACPI systems always list these as PNPACPI devices, and pre-ACPI PCs
  809. * probably list them in similar PNPBIOS tables; so PNP is more common.
  810. *
  811. * We don't use legacy "poke at the hardware" probing. Ancient PCs that
  812. * predate even PNPBIOS should set up platform_bus devices.
  813. */
  814. #ifdef CONFIG_ACPI
  815. #include <linux/acpi.h>
  816. static u32 rtc_handler(void *context)
  817. {
  818. struct device *dev = context;
  819. pm_wakeup_event(dev, 0);
  820. acpi_clear_event(ACPI_EVENT_RTC);
  821. acpi_disable_event(ACPI_EVENT_RTC, 0);
  822. return ACPI_INTERRUPT_HANDLED;
  823. }
  824. static inline void rtc_wake_setup(struct device *dev)
  825. {
  826. acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, dev);
  827. /*
  828. * After the RTC handler is installed, the Fixed_RTC event should
  829. * be disabled. Only when the RTC alarm is set will it be enabled.
  830. */
  831. acpi_clear_event(ACPI_EVENT_RTC);
  832. acpi_disable_event(ACPI_EVENT_RTC, 0);
  833. }
  834. static void rtc_wake_on(struct device *dev)
  835. {
  836. acpi_clear_event(ACPI_EVENT_RTC);
  837. acpi_enable_event(ACPI_EVENT_RTC, 0);
  838. }
  839. static void rtc_wake_off(struct device *dev)
  840. {
  841. acpi_disable_event(ACPI_EVENT_RTC, 0);
  842. }
  843. /* Every ACPI platform has a mc146818 compatible "cmos rtc". Here we find
  844. * its device node and pass extra config data. This helps its driver use
  845. * capabilities that the now-obsolete mc146818 didn't have, and informs it
  846. * that this board's RTC is wakeup-capable (per ACPI spec).
  847. */
  848. static struct cmos_rtc_board_info acpi_rtc_info;
  849. static void cmos_wake_setup(struct device *dev)
  850. {
  851. if (acpi_disabled)
  852. return;
  853. rtc_wake_setup(dev);
  854. acpi_rtc_info.wake_on = rtc_wake_on;
  855. acpi_rtc_info.wake_off = rtc_wake_off;
  856. /* workaround bug in some ACPI tables */
  857. if (acpi_gbl_FADT.month_alarm && !acpi_gbl_FADT.day_alarm) {
  858. dev_dbg(dev, "bogus FADT month_alarm (%d)\n",
  859. acpi_gbl_FADT.month_alarm);
  860. acpi_gbl_FADT.month_alarm = 0;
  861. }
  862. acpi_rtc_info.rtc_day_alarm = acpi_gbl_FADT.day_alarm;
  863. acpi_rtc_info.rtc_mon_alarm = acpi_gbl_FADT.month_alarm;
  864. acpi_rtc_info.rtc_century = acpi_gbl_FADT.century;
  865. /* NOTE: S4_RTC_WAKE is NOT currently useful to Linux */
  866. if (acpi_gbl_FADT.flags & ACPI_FADT_S4_RTC_WAKE)
  867. dev_info(dev, "RTC can wake from S4\n");
  868. dev->platform_data = &acpi_rtc_info;
  869. /* RTC always wakes from S1/S2/S3, and often S4/STD */
  870. device_init_wakeup(dev, 1);
  871. }
  872. #else
  873. static void cmos_wake_setup(struct device *dev)
  874. {
  875. }
  876. #endif
  877. #ifdef CONFIG_PNP
  878. #include <linux/pnp.h>
  879. static int cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
  880. {
  881. cmos_wake_setup(&pnp->dev);
  882. if (pnp_port_start(pnp, 0) == 0x70 && !pnp_irq_valid(pnp, 0))
  883. /* Some machines contain a PNP entry for the RTC, but
  884. * don't define the IRQ. It should always be safe to
  885. * hardcode it in these cases
  886. */
  887. return cmos_do_probe(&pnp->dev,
  888. pnp_get_resource(pnp, IORESOURCE_IO, 0), 8);
  889. else
  890. return cmos_do_probe(&pnp->dev,
  891. pnp_get_resource(pnp, IORESOURCE_IO, 0),
  892. pnp_irq(pnp, 0));
  893. }
  894. static void __exit cmos_pnp_remove(struct pnp_dev *pnp)
  895. {
  896. cmos_do_remove(&pnp->dev);
  897. }
  898. static void cmos_pnp_shutdown(struct pnp_dev *pnp)
  899. {
  900. struct device *dev = &pnp->dev;
  901. struct cmos_rtc *cmos = dev_get_drvdata(dev);
  902. if (system_state == SYSTEM_POWER_OFF && !cmos_poweroff(dev))
  903. return;
  904. cmos_do_shutdown(cmos->irq);
  905. }
  906. static const struct pnp_device_id rtc_ids[] = {
  907. { .id = "PNP0b00", },
  908. { .id = "PNP0b01", },
  909. { .id = "PNP0b02", },
  910. { },
  911. };
  912. MODULE_DEVICE_TABLE(pnp, rtc_ids);
  913. static struct pnp_driver cmos_pnp_driver = {
  914. .name = (char *) driver_name,
  915. .id_table = rtc_ids,
  916. .probe = cmos_pnp_probe,
  917. .remove = __exit_p(cmos_pnp_remove),
  918. .shutdown = cmos_pnp_shutdown,
  919. /* flag ensures resume() gets called, and stops syslog spam */
  920. .flags = PNP_DRIVER_RES_DO_NOT_CHANGE,
  921. .driver = {
  922. .pm = &cmos_pm_ops,
  923. },
  924. };
  925. #endif /* CONFIG_PNP */
  926. #ifdef CONFIG_OF
  927. static const struct of_device_id of_cmos_match[] = {
  928. {
  929. .compatible = "motorola,mc146818",
  930. },
  931. { },
  932. };
  933. MODULE_DEVICE_TABLE(of, of_cmos_match);
  934. static __init void cmos_of_init(struct platform_device *pdev)
  935. {
  936. struct device_node *node = pdev->dev.of_node;
  937. struct rtc_time time;
  938. int ret;
  939. const __be32 *val;
  940. if (!node)
  941. return;
  942. val = of_get_property(node, "ctrl-reg", NULL);
  943. if (val)
  944. CMOS_WRITE(be32_to_cpup(val), RTC_CONTROL);
  945. val = of_get_property(node, "freq-reg", NULL);
  946. if (val)
  947. CMOS_WRITE(be32_to_cpup(val), RTC_FREQ_SELECT);
  948. get_rtc_time(&time);
  949. ret = rtc_valid_tm(&time);
  950. if (ret) {
  951. struct rtc_time def_time = {
  952. .tm_year = 1,
  953. .tm_mday = 1,
  954. };
  955. set_rtc_time(&def_time);
  956. }
  957. }
  958. #else
  959. static inline void cmos_of_init(struct platform_device *pdev) {}
  960. #endif
  961. /*----------------------------------------------------------------*/
  962. /* Platform setup should have set up an RTC device, when PNP is
  963. * unavailable ... this could happen even on (older) PCs.
  964. */
  965. static int __init cmos_platform_probe(struct platform_device *pdev)
  966. {
  967. struct resource *resource;
  968. int irq;
  969. cmos_of_init(pdev);
  970. cmos_wake_setup(&pdev->dev);
  971. if (RTC_IOMAPPED)
  972. resource = platform_get_resource(pdev, IORESOURCE_IO, 0);
  973. else
  974. resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  975. irq = platform_get_irq(pdev, 0);
  976. if (irq < 0)
  977. irq = -1;
  978. return cmos_do_probe(&pdev->dev, resource, irq);
  979. }
  980. static int __exit cmos_platform_remove(struct platform_device *pdev)
  981. {
  982. cmos_do_remove(&pdev->dev);
  983. return 0;
  984. }
  985. static void cmos_platform_shutdown(struct platform_device *pdev)
  986. {
  987. struct device *dev = &pdev->dev;
  988. struct cmos_rtc *cmos = dev_get_drvdata(dev);
  989. if (system_state == SYSTEM_POWER_OFF && !cmos_poweroff(dev))
  990. return;
  991. cmos_do_shutdown(cmos->irq);
  992. }
  993. /* work with hotplug and coldplug */
  994. MODULE_ALIAS("platform:rtc_cmos");
  995. static struct platform_driver cmos_platform_driver = {
  996. .remove = __exit_p(cmos_platform_remove),
  997. .shutdown = cmos_platform_shutdown,
  998. .driver = {
  999. .name = driver_name,
  1000. #ifdef CONFIG_PM
  1001. .pm = &cmos_pm_ops,
  1002. #endif
  1003. .of_match_table = of_match_ptr(of_cmos_match),
  1004. }
  1005. };
  1006. #ifdef CONFIG_PNP
  1007. static bool pnp_driver_registered;
  1008. #endif
  1009. static bool platform_driver_registered;
  1010. static int __init cmos_init(void)
  1011. {
  1012. int retval = 0;
  1013. #ifdef CONFIG_PNP
  1014. retval = pnp_register_driver(&cmos_pnp_driver);
  1015. if (retval == 0)
  1016. pnp_driver_registered = true;
  1017. #endif
  1018. if (!cmos_rtc.dev) {
  1019. retval = platform_driver_probe(&cmos_platform_driver,
  1020. cmos_platform_probe);
  1021. if (retval == 0)
  1022. platform_driver_registered = true;
  1023. }
  1024. dmi_check_system(rtc_quirks);
  1025. if (retval == 0)
  1026. return 0;
  1027. #ifdef CONFIG_PNP
  1028. if (pnp_driver_registered)
  1029. pnp_unregister_driver(&cmos_pnp_driver);
  1030. #endif
  1031. return retval;
  1032. }
  1033. module_init(cmos_init);
  1034. static void __exit cmos_exit(void)
  1035. {
  1036. #ifdef CONFIG_PNP
  1037. if (pnp_driver_registered)
  1038. pnp_unregister_driver(&cmos_pnp_driver);
  1039. #endif
  1040. if (platform_driver_registered)
  1041. platform_driver_unregister(&cmos_platform_driver);
  1042. }
  1043. module_exit(cmos_exit);
  1044. MODULE_AUTHOR("David Brownell");
  1045. MODULE_DESCRIPTION("Driver for PC-style 'CMOS' RTCs");
  1046. MODULE_LICENSE("GPL");