rtc-cmos.c 31 KB

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