blob: 0dfb0404f867d214a47078f839ac1cc6cfc3772d [file] [log] [blame]
David Brownelldb68b182006-12-06 20:38:36 -08001/*
2 * TI OMAP1 Real Time Clock interface for Linux
3 *
4 * Copyright (C) 2003 MontaVista Software, Inc.
5 * Author: George G. Davis <gdavis@mvista.com> or <source@mvista.com>
6 *
7 * Copyright (C) 2006 David Brownell (new RTC framework)
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/module.h>
18#include <linux/ioport.h>
19#include <linux/delay.h>
20#include <linux/rtc.h>
21#include <linux/bcd.h>
22#include <linux/platform_device.h>
Afzal Mohammed9e0344d2012-12-17 16:02:15 -080023#include <linux/of.h>
24#include <linux/of_device.h>
Vaibhav Hiremathfc9bd902012-12-17 16:02:18 -080025#include <linux/pm_runtime.h>
Sachin Kamat4b30c9f2013-07-03 15:06:00 -070026#include <linux/io.h>
David Brownelldb68b182006-12-06 20:38:36 -080027
28/* The OMAP1 RTC is a year/month/day/hours/minutes/seconds BCD clock
29 * with century-range alarm matching, driven by the 32kHz clock.
30 *
31 * The main user-visible ways it differs from PC RTCs are by omitting
32 * "don't care" alarm fields and sub-second periodic IRQs, and having
33 * an autoadjust mechanism to calibrate to the true oscillator rate.
34 *
35 * Board-specific wiring options include using split power mode with
36 * RTC_OFF_NOFF used as the reset signal (so the RTC won't be reset),
37 * and wiring RTC_WAKE_INT (so the RTC alarm can wake the system from
Sekhar Norifa5b0782010-10-27 15:33:05 -070038 * low power modes) for OMAP1 boards (OMAP-L138 has this built into
39 * the SoC). See the BOARD-SPECIFIC CUSTOMIZATION comment.
David Brownelldb68b182006-12-06 20:38:36 -080040 */
41
David Brownelldb68b182006-12-06 20:38:36 -080042/* RTC registers */
43#define OMAP_RTC_SECONDS_REG 0x00
44#define OMAP_RTC_MINUTES_REG 0x04
45#define OMAP_RTC_HOURS_REG 0x08
46#define OMAP_RTC_DAYS_REG 0x0C
47#define OMAP_RTC_MONTHS_REG 0x10
48#define OMAP_RTC_YEARS_REG 0x14
49#define OMAP_RTC_WEEKS_REG 0x18
50
51#define OMAP_RTC_ALARM_SECONDS_REG 0x20
52#define OMAP_RTC_ALARM_MINUTES_REG 0x24
53#define OMAP_RTC_ALARM_HOURS_REG 0x28
54#define OMAP_RTC_ALARM_DAYS_REG 0x2c
55#define OMAP_RTC_ALARM_MONTHS_REG 0x30
56#define OMAP_RTC_ALARM_YEARS_REG 0x34
57
58#define OMAP_RTC_CTRL_REG 0x40
59#define OMAP_RTC_STATUS_REG 0x44
60#define OMAP_RTC_INTERRUPTS_REG 0x48
61
62#define OMAP_RTC_COMP_LSB_REG 0x4c
63#define OMAP_RTC_COMP_MSB_REG 0x50
64#define OMAP_RTC_OSC_REG 0x54
65
Afzal Mohammedcab14582012-12-17 16:02:11 -080066#define OMAP_RTC_KICK0_REG 0x6c
67#define OMAP_RTC_KICK1_REG 0x70
68
Hebbar Gururaja8af750e2013-09-11 14:24:18 -070069#define OMAP_RTC_IRQWAKEEN 0x7c
70
Johan Hovold222a12f2014-12-10 15:53:13 -080071#define OMAP_RTC_ALARM2_SECONDS_REG 0x80
72#define OMAP_RTC_ALARM2_MINUTES_REG 0x84
73#define OMAP_RTC_ALARM2_HOURS_REG 0x88
74#define OMAP_RTC_ALARM2_DAYS_REG 0x8c
75#define OMAP_RTC_ALARM2_MONTHS_REG 0x90
76#define OMAP_RTC_ALARM2_YEARS_REG 0x94
77
78#define OMAP_RTC_PMIC_REG 0x98
79
David Brownelldb68b182006-12-06 20:38:36 -080080/* OMAP_RTC_CTRL_REG bit fields: */
Sekhar Nori92adb962014-06-06 14:36:05 -070081#define OMAP_RTC_CTRL_SPLIT BIT(7)
82#define OMAP_RTC_CTRL_DISABLE BIT(6)
83#define OMAP_RTC_CTRL_SET_32_COUNTER BIT(5)
84#define OMAP_RTC_CTRL_TEST BIT(4)
85#define OMAP_RTC_CTRL_MODE_12_24 BIT(3)
86#define OMAP_RTC_CTRL_AUTO_COMP BIT(2)
87#define OMAP_RTC_CTRL_ROUND_30S BIT(1)
88#define OMAP_RTC_CTRL_STOP BIT(0)
David Brownelldb68b182006-12-06 20:38:36 -080089
90/* OMAP_RTC_STATUS_REG bit fields: */
Sekhar Nori92adb962014-06-06 14:36:05 -070091#define OMAP_RTC_STATUS_POWER_UP BIT(7)
Johan Hovold222a12f2014-12-10 15:53:13 -080092#define OMAP_RTC_STATUS_ALARM2 BIT(7)
Sekhar Nori92adb962014-06-06 14:36:05 -070093#define OMAP_RTC_STATUS_ALARM BIT(6)
94#define OMAP_RTC_STATUS_1D_EVENT BIT(5)
95#define OMAP_RTC_STATUS_1H_EVENT BIT(4)
96#define OMAP_RTC_STATUS_1M_EVENT BIT(3)
97#define OMAP_RTC_STATUS_1S_EVENT BIT(2)
98#define OMAP_RTC_STATUS_RUN BIT(1)
99#define OMAP_RTC_STATUS_BUSY BIT(0)
David Brownelldb68b182006-12-06 20:38:36 -0800100
101/* OMAP_RTC_INTERRUPTS_REG bit fields: */
Johan Hovold222a12f2014-12-10 15:53:13 -0800102#define OMAP_RTC_INTERRUPTS_IT_ALARM2 BIT(4)
Sekhar Nori92adb962014-06-06 14:36:05 -0700103#define OMAP_RTC_INTERRUPTS_IT_ALARM BIT(3)
104#define OMAP_RTC_INTERRUPTS_IT_TIMER BIT(2)
David Brownelldb68b182006-12-06 20:38:36 -0800105
Sekhar Noricd914bb2014-06-06 14:36:06 -0700106/* OMAP_RTC_OSC_REG bit fields: */
107#define OMAP_RTC_OSC_32KCLK_EN BIT(6)
108
Hebbar Gururaja8af750e2013-09-11 14:24:18 -0700109/* OMAP_RTC_IRQWAKEEN bit fields: */
Sekhar Nori92adb962014-06-06 14:36:05 -0700110#define OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN BIT(1)
Hebbar Gururaja8af750e2013-09-11 14:24:18 -0700111
Johan Hovold222a12f2014-12-10 15:53:13 -0800112/* OMAP_RTC_PMIC bit fields: */
113#define OMAP_RTC_PMIC_POWER_EN_EN BIT(16)
114
Afzal Mohammedcab14582012-12-17 16:02:11 -0800115/* OMAP_RTC_KICKER values */
116#define KICK0_VALUE 0x83e70b13
117#define KICK1_VALUE 0x95a4f1e0
118
Johan Hovold2153f942014-12-10 15:53:01 -0800119struct omap_rtc_device_type {
120 bool has_32kclk_en;
121 bool has_kicker;
122 bool has_irqwakeen;
Johan Hovold222a12f2014-12-10 15:53:13 -0800123 bool has_pmic_mode;
Johan Hovold9291e342014-12-10 15:53:04 -0800124 bool has_power_up_reset;
Johan Hovold2153f942014-12-10 15:53:01 -0800125};
Sekhar Noricd914bb2014-06-06 14:36:06 -0700126
Johan Hovold55ba9532014-12-10 15:52:55 -0800127struct omap_rtc {
128 struct rtc_device *rtc;
129 void __iomem *base;
130 int irq_alarm;
131 int irq_timer;
132 u8 interrupts_reg;
Johan Hovold222a12f2014-12-10 15:53:13 -0800133 bool is_pmic_controller;
Johan Hovold2153f942014-12-10 15:53:01 -0800134 const struct omap_rtc_device_type *type;
Johan Hovold55ba9532014-12-10 15:52:55 -0800135};
David Brownelldb68b182006-12-06 20:38:36 -0800136
Johan Hovold55ba9532014-12-10 15:52:55 -0800137static inline u8 rtc_read(struct omap_rtc *rtc, unsigned int reg)
138{
139 return readb(rtc->base + reg);
140}
Afzal Mohammedcab14582012-12-17 16:02:11 -0800141
Johan Hovoldc253a892014-12-10 15:53:10 -0800142static inline u32 rtc_readl(struct omap_rtc *rtc, unsigned int reg)
143{
144 return readl(rtc->base + reg);
145}
146
Johan Hovold55ba9532014-12-10 15:52:55 -0800147static inline void rtc_write(struct omap_rtc *rtc, unsigned int reg, u8 val)
148{
149 writeb(val, rtc->base + reg);
150}
David Brownelldb68b182006-12-06 20:38:36 -0800151
Johan Hovold55ba9532014-12-10 15:52:55 -0800152static inline void rtc_writel(struct omap_rtc *rtc, unsigned int reg, u32 val)
153{
154 writel(val, rtc->base + reg);
155}
David Brownelldb68b182006-12-06 20:38:36 -0800156
David Brownelldb68b182006-12-06 20:38:36 -0800157/* we rely on the rtc framework to handle locking (rtc->ops_lock),
158 * so the only other requirement is that register accesses which
159 * require BUSY to be clear are made with IRQs locally disabled
160 */
Johan Hovold55ba9532014-12-10 15:52:55 -0800161static void rtc_wait_not_busy(struct omap_rtc *rtc)
David Brownelldb68b182006-12-06 20:38:36 -0800162{
163 int count = 0;
164 u8 status;
165
166 /* BUSY may stay active for 1/32768 second (~30 usec) */
167 for (count = 0; count < 50; count++) {
Johan Hovold55ba9532014-12-10 15:52:55 -0800168 status = rtc_read(rtc, OMAP_RTC_STATUS_REG);
David Brownelldb68b182006-12-06 20:38:36 -0800169 if ((status & (u8)OMAP_RTC_STATUS_BUSY) == 0)
170 break;
171 udelay(1);
172 }
173 /* now we have ~15 usec to read/write various registers */
174}
175
Johan Hovold55ba9532014-12-10 15:52:55 -0800176static irqreturn_t rtc_irq(int irq, void *dev_id)
David Brownelldb68b182006-12-06 20:38:36 -0800177{
Johan Hovold55ba9532014-12-10 15:52:55 -0800178 struct omap_rtc *rtc = dev_id;
David Brownelldb68b182006-12-06 20:38:36 -0800179 unsigned long events = 0;
180 u8 irq_data;
181
Johan Hovold55ba9532014-12-10 15:52:55 -0800182 irq_data = rtc_read(rtc, OMAP_RTC_STATUS_REG);
David Brownelldb68b182006-12-06 20:38:36 -0800183
184 /* alarm irq? */
185 if (irq_data & OMAP_RTC_STATUS_ALARM) {
Johan Hovold55ba9532014-12-10 15:52:55 -0800186 rtc_write(rtc, OMAP_RTC_STATUS_REG, OMAP_RTC_STATUS_ALARM);
David Brownelldb68b182006-12-06 20:38:36 -0800187 events |= RTC_IRQF | RTC_AF;
188 }
189
190 /* 1/sec periodic/update irq? */
191 if (irq_data & OMAP_RTC_STATUS_1S_EVENT)
192 events |= RTC_IRQF | RTC_UF;
193
Johan Hovold55ba9532014-12-10 15:52:55 -0800194 rtc_update_irq(rtc->rtc, 1, events);
David Brownelldb68b182006-12-06 20:38:36 -0800195
196 return IRQ_HANDLED;
197}
198
John Stultz16380c12011-02-02 17:02:41 -0800199static int omap_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
200{
Johan Hovold55ba9532014-12-10 15:52:55 -0800201 struct omap_rtc *rtc = dev_get_drvdata(dev);
Lokesh Vutlaab7f5802014-06-06 14:36:12 -0700202 u8 reg, irqwake_reg = 0;
John Stultz16380c12011-02-02 17:02:41 -0800203
204 local_irq_disable();
Johan Hovold55ba9532014-12-10 15:52:55 -0800205 rtc_wait_not_busy(rtc);
206 reg = rtc_read(rtc, OMAP_RTC_INTERRUPTS_REG);
Johan Hovold2153f942014-12-10 15:53:01 -0800207 if (rtc->type->has_irqwakeen)
Johan Hovold55ba9532014-12-10 15:52:55 -0800208 irqwake_reg = rtc_read(rtc, OMAP_RTC_IRQWAKEEN);
Lokesh Vutlaab7f5802014-06-06 14:36:12 -0700209
210 if (enabled) {
John Stultz16380c12011-02-02 17:02:41 -0800211 reg |= OMAP_RTC_INTERRUPTS_IT_ALARM;
Lokesh Vutlaab7f5802014-06-06 14:36:12 -0700212 irqwake_reg |= OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN;
213 } else {
John Stultz16380c12011-02-02 17:02:41 -0800214 reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM;
Lokesh Vutlaab7f5802014-06-06 14:36:12 -0700215 irqwake_reg &= ~OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN;
216 }
Johan Hovold55ba9532014-12-10 15:52:55 -0800217 rtc_wait_not_busy(rtc);
218 rtc_write(rtc, OMAP_RTC_INTERRUPTS_REG, reg);
Johan Hovold2153f942014-12-10 15:53:01 -0800219 if (rtc->type->has_irqwakeen)
Johan Hovold55ba9532014-12-10 15:52:55 -0800220 rtc_write(rtc, OMAP_RTC_IRQWAKEEN, irqwake_reg);
John Stultz16380c12011-02-02 17:02:41 -0800221 local_irq_enable();
222
223 return 0;
224}
225
David Brownelldb68b182006-12-06 20:38:36 -0800226/* this hardware doesn't support "don't care" alarm fields */
227static int tm2bcd(struct rtc_time *tm)
228{
229 if (rtc_valid_tm(tm) != 0)
230 return -EINVAL;
231
Adrian Bunkfe20ba72008-10-18 20:28:41 -0700232 tm->tm_sec = bin2bcd(tm->tm_sec);
233 tm->tm_min = bin2bcd(tm->tm_min);
234 tm->tm_hour = bin2bcd(tm->tm_hour);
235 tm->tm_mday = bin2bcd(tm->tm_mday);
David Brownelldb68b182006-12-06 20:38:36 -0800236
Adrian Bunkfe20ba72008-10-18 20:28:41 -0700237 tm->tm_mon = bin2bcd(tm->tm_mon + 1);
David Brownelldb68b182006-12-06 20:38:36 -0800238
239 /* epoch == 1900 */
240 if (tm->tm_year < 100 || tm->tm_year > 199)
241 return -EINVAL;
Adrian Bunkfe20ba72008-10-18 20:28:41 -0700242 tm->tm_year = bin2bcd(tm->tm_year - 100);
David Brownelldb68b182006-12-06 20:38:36 -0800243
244 return 0;
245}
246
247static void bcd2tm(struct rtc_time *tm)
248{
Adrian Bunkfe20ba72008-10-18 20:28:41 -0700249 tm->tm_sec = bcd2bin(tm->tm_sec);
250 tm->tm_min = bcd2bin(tm->tm_min);
251 tm->tm_hour = bcd2bin(tm->tm_hour);
252 tm->tm_mday = bcd2bin(tm->tm_mday);
253 tm->tm_mon = bcd2bin(tm->tm_mon) - 1;
David Brownelldb68b182006-12-06 20:38:36 -0800254 /* epoch == 1900 */
Adrian Bunkfe20ba72008-10-18 20:28:41 -0700255 tm->tm_year = bcd2bin(tm->tm_year) + 100;
David Brownelldb68b182006-12-06 20:38:36 -0800256}
257
Johan Hovoldcbbe3262014-12-10 15:53:07 -0800258static void omap_rtc_read_time_raw(struct omap_rtc *rtc, struct rtc_time *tm)
259{
260 tm->tm_sec = rtc_read(rtc, OMAP_RTC_SECONDS_REG);
261 tm->tm_min = rtc_read(rtc, OMAP_RTC_MINUTES_REG);
262 tm->tm_hour = rtc_read(rtc, OMAP_RTC_HOURS_REG);
263 tm->tm_mday = rtc_read(rtc, OMAP_RTC_DAYS_REG);
264 tm->tm_mon = rtc_read(rtc, OMAP_RTC_MONTHS_REG);
265 tm->tm_year = rtc_read(rtc, OMAP_RTC_YEARS_REG);
266}
David Brownelldb68b182006-12-06 20:38:36 -0800267
268static int omap_rtc_read_time(struct device *dev, struct rtc_time *tm)
269{
Johan Hovold55ba9532014-12-10 15:52:55 -0800270 struct omap_rtc *rtc = dev_get_drvdata(dev);
271
David Brownelldb68b182006-12-06 20:38:36 -0800272 /* we don't report wday/yday/isdst ... */
273 local_irq_disable();
Johan Hovold55ba9532014-12-10 15:52:55 -0800274 rtc_wait_not_busy(rtc);
Johan Hovoldcbbe3262014-12-10 15:53:07 -0800275 omap_rtc_read_time_raw(rtc, tm);
David Brownelldb68b182006-12-06 20:38:36 -0800276 local_irq_enable();
277
278 bcd2tm(tm);
279 return 0;
280}
281
282static int omap_rtc_set_time(struct device *dev, struct rtc_time *tm)
283{
Johan Hovold55ba9532014-12-10 15:52:55 -0800284 struct omap_rtc *rtc = dev_get_drvdata(dev);
285
David Brownelldb68b182006-12-06 20:38:36 -0800286 if (tm2bcd(tm) < 0)
287 return -EINVAL;
288 local_irq_disable();
Johan Hovold55ba9532014-12-10 15:52:55 -0800289 rtc_wait_not_busy(rtc);
David Brownelldb68b182006-12-06 20:38:36 -0800290
Johan Hovold55ba9532014-12-10 15:52:55 -0800291 rtc_write(rtc, OMAP_RTC_YEARS_REG, tm->tm_year);
292 rtc_write(rtc, OMAP_RTC_MONTHS_REG, tm->tm_mon);
293 rtc_write(rtc, OMAP_RTC_DAYS_REG, tm->tm_mday);
294 rtc_write(rtc, OMAP_RTC_HOURS_REG, tm->tm_hour);
295 rtc_write(rtc, OMAP_RTC_MINUTES_REG, tm->tm_min);
296 rtc_write(rtc, OMAP_RTC_SECONDS_REG, tm->tm_sec);
David Brownelldb68b182006-12-06 20:38:36 -0800297
298 local_irq_enable();
299
300 return 0;
301}
302
303static int omap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
304{
Johan Hovold55ba9532014-12-10 15:52:55 -0800305 struct omap_rtc *rtc = dev_get_drvdata(dev);
David Brownelldb68b182006-12-06 20:38:36 -0800306
Johan Hovold55ba9532014-12-10 15:52:55 -0800307 local_irq_disable();
308 rtc_wait_not_busy(rtc);
309
310 alm->time.tm_sec = rtc_read(rtc, OMAP_RTC_ALARM_SECONDS_REG);
311 alm->time.tm_min = rtc_read(rtc, OMAP_RTC_ALARM_MINUTES_REG);
312 alm->time.tm_hour = rtc_read(rtc, OMAP_RTC_ALARM_HOURS_REG);
313 alm->time.tm_mday = rtc_read(rtc, OMAP_RTC_ALARM_DAYS_REG);
314 alm->time.tm_mon = rtc_read(rtc, OMAP_RTC_ALARM_MONTHS_REG);
315 alm->time.tm_year = rtc_read(rtc, OMAP_RTC_ALARM_YEARS_REG);
David Brownelldb68b182006-12-06 20:38:36 -0800316
317 local_irq_enable();
318
319 bcd2tm(&alm->time);
Johan Hovold55ba9532014-12-10 15:52:55 -0800320 alm->enabled = !!(rtc_read(rtc, OMAP_RTC_INTERRUPTS_REG)
David Brownelldb68b182006-12-06 20:38:36 -0800321 & OMAP_RTC_INTERRUPTS_IT_ALARM);
David Brownelldb68b182006-12-06 20:38:36 -0800322
323 return 0;
324}
325
326static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
327{
Johan Hovold55ba9532014-12-10 15:52:55 -0800328 struct omap_rtc *rtc = dev_get_drvdata(dev);
Lokesh Vutlaab7f5802014-06-06 14:36:12 -0700329 u8 reg, irqwake_reg = 0;
David Brownelldb68b182006-12-06 20:38:36 -0800330
David Brownelldb68b182006-12-06 20:38:36 -0800331 if (tm2bcd(&alm->time) < 0)
332 return -EINVAL;
333
334 local_irq_disable();
Johan Hovold55ba9532014-12-10 15:52:55 -0800335 rtc_wait_not_busy(rtc);
David Brownelldb68b182006-12-06 20:38:36 -0800336
Johan Hovold55ba9532014-12-10 15:52:55 -0800337 rtc_write(rtc, OMAP_RTC_ALARM_YEARS_REG, alm->time.tm_year);
338 rtc_write(rtc, OMAP_RTC_ALARM_MONTHS_REG, alm->time.tm_mon);
339 rtc_write(rtc, OMAP_RTC_ALARM_DAYS_REG, alm->time.tm_mday);
340 rtc_write(rtc, OMAP_RTC_ALARM_HOURS_REG, alm->time.tm_hour);
341 rtc_write(rtc, OMAP_RTC_ALARM_MINUTES_REG, alm->time.tm_min);
342 rtc_write(rtc, OMAP_RTC_ALARM_SECONDS_REG, alm->time.tm_sec);
David Brownelldb68b182006-12-06 20:38:36 -0800343
Johan Hovold55ba9532014-12-10 15:52:55 -0800344 reg = rtc_read(rtc, OMAP_RTC_INTERRUPTS_REG);
Johan Hovold2153f942014-12-10 15:53:01 -0800345 if (rtc->type->has_irqwakeen)
Johan Hovold55ba9532014-12-10 15:52:55 -0800346 irqwake_reg = rtc_read(rtc, OMAP_RTC_IRQWAKEEN);
Lokesh Vutlaab7f5802014-06-06 14:36:12 -0700347
348 if (alm->enabled) {
David Brownelldb68b182006-12-06 20:38:36 -0800349 reg |= OMAP_RTC_INTERRUPTS_IT_ALARM;
Lokesh Vutlaab7f5802014-06-06 14:36:12 -0700350 irqwake_reg |= OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN;
351 } else {
David Brownelldb68b182006-12-06 20:38:36 -0800352 reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM;
Lokesh Vutlaab7f5802014-06-06 14:36:12 -0700353 irqwake_reg &= ~OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN;
354 }
Johan Hovold55ba9532014-12-10 15:52:55 -0800355 rtc_write(rtc, OMAP_RTC_INTERRUPTS_REG, reg);
Johan Hovold2153f942014-12-10 15:53:01 -0800356 if (rtc->type->has_irqwakeen)
Johan Hovold55ba9532014-12-10 15:52:55 -0800357 rtc_write(rtc, OMAP_RTC_IRQWAKEEN, irqwake_reg);
David Brownelldb68b182006-12-06 20:38:36 -0800358
359 local_irq_enable();
360
361 return 0;
362}
363
Johan Hovold222a12f2014-12-10 15:53:13 -0800364static struct omap_rtc *omap_rtc_power_off_rtc;
365
366/*
367 * omap_rtc_poweroff: RTC-controlled power off
368 *
369 * The RTC can be used to control an external PMIC via the pmic_power_en pin,
370 * which can be configured to transition to OFF on ALARM2 events.
371 *
372 * Notes:
373 * The two-second alarm offset is the shortest offset possible as the alarm
374 * registers must be set before the next timer update and the offset
375 * calculation is too heavy for everything to be done within a single access
376 * period (~15 us).
377 *
378 * Called with local interrupts disabled.
379 */
380static void omap_rtc_power_off(void)
381{
382 struct omap_rtc *rtc = omap_rtc_power_off_rtc;
383 struct rtc_time tm;
384 unsigned long now;
385 u32 val;
386
387 /* enable pmic_power_en control */
388 val = rtc_readl(rtc, OMAP_RTC_PMIC_REG);
389 rtc_writel(rtc, OMAP_RTC_PMIC_REG, val | OMAP_RTC_PMIC_POWER_EN_EN);
390
391 /* set alarm two seconds from now */
392 omap_rtc_read_time_raw(rtc, &tm);
393 bcd2tm(&tm);
394 rtc_tm_to_time(&tm, &now);
395 rtc_time_to_tm(now + 2, &tm);
396
397 if (tm2bcd(&tm) < 0) {
398 dev_err(&rtc->rtc->dev, "power off failed\n");
399 return;
400 }
401
402 rtc_wait_not_busy(rtc);
403
404 rtc_write(rtc, OMAP_RTC_ALARM2_SECONDS_REG, tm.tm_sec);
405 rtc_write(rtc, OMAP_RTC_ALARM2_MINUTES_REG, tm.tm_min);
406 rtc_write(rtc, OMAP_RTC_ALARM2_HOURS_REG, tm.tm_hour);
407 rtc_write(rtc, OMAP_RTC_ALARM2_DAYS_REG, tm.tm_mday);
408 rtc_write(rtc, OMAP_RTC_ALARM2_MONTHS_REG, tm.tm_mon);
409 rtc_write(rtc, OMAP_RTC_ALARM2_YEARS_REG, tm.tm_year);
410
411 /*
412 * enable ALARM2 interrupt
413 *
414 * NOTE: this fails on AM3352 if rtc_write (writeb) is used
415 */
416 val = rtc_read(rtc, OMAP_RTC_INTERRUPTS_REG);
417 rtc_writel(rtc, OMAP_RTC_INTERRUPTS_REG,
418 val | OMAP_RTC_INTERRUPTS_IT_ALARM2);
419
420 /*
421 * Wait for alarm to trigger (within two seconds) and external PMIC to
422 * power off the system. Add a 500 ms margin for external latencies
423 * (e.g. debounce circuits).
424 */
425 mdelay(2500);
426}
427
David Brownelldb68b182006-12-06 20:38:36 -0800428static struct rtc_class_ops omap_rtc_ops = {
David Brownelldb68b182006-12-06 20:38:36 -0800429 .read_time = omap_rtc_read_time,
430 .set_time = omap_rtc_set_time,
431 .read_alarm = omap_rtc_read_alarm,
432 .set_alarm = omap_rtc_set_alarm,
John Stultz16380c12011-02-02 17:02:41 -0800433 .alarm_irq_enable = omap_rtc_alarm_irq_enable,
David Brownelldb68b182006-12-06 20:38:36 -0800434};
435
Johan Hovold2153f942014-12-10 15:53:01 -0800436static const struct omap_rtc_device_type omap_rtc_default_type = {
Johan Hovold9291e342014-12-10 15:53:04 -0800437 .has_power_up_reset = true,
Johan Hovold2153f942014-12-10 15:53:01 -0800438};
Afzal Mohammed9e0344d2012-12-17 16:02:15 -0800439
Johan Hovold2153f942014-12-10 15:53:01 -0800440static const struct omap_rtc_device_type omap_rtc_am3352_type = {
441 .has_32kclk_en = true,
442 .has_kicker = true,
443 .has_irqwakeen = true,
Johan Hovold222a12f2014-12-10 15:53:13 -0800444 .has_pmic_mode = true,
Johan Hovold2153f942014-12-10 15:53:01 -0800445};
446
447static const struct omap_rtc_device_type omap_rtc_da830_type = {
448 .has_kicker = true,
449};
450
451static const struct platform_device_id omap_rtc_id_table[] = {
Afzal Mohammedcab14582012-12-17 16:02:11 -0800452 {
Johan Hovolda430ca22014-12-10 15:52:58 -0800453 .name = "omap_rtc",
Johan Hovold2153f942014-12-10 15:53:01 -0800454 .driver_data = (kernel_ulong_t)&omap_rtc_default_type,
455 }, {
Hebbar Gururaja8af750e2013-09-11 14:24:18 -0700456 .name = "am3352-rtc",
Johan Hovold2153f942014-12-10 15:53:01 -0800457 .driver_data = (kernel_ulong_t)&omap_rtc_am3352_type,
458 }, {
Afzal Mohammedcab14582012-12-17 16:02:11 -0800459 .name = "da830-rtc",
Johan Hovold2153f942014-12-10 15:53:01 -0800460 .driver_data = (kernel_ulong_t)&omap_rtc_da830_type,
461 }, {
462 /* sentinel */
463 }
Afzal Mohammedcab14582012-12-17 16:02:11 -0800464};
Johan Hovold2153f942014-12-10 15:53:01 -0800465MODULE_DEVICE_TABLE(platform, omap_rtc_id_table);
Afzal Mohammedcab14582012-12-17 16:02:11 -0800466
Afzal Mohammed9e0344d2012-12-17 16:02:15 -0800467static const struct of_device_id omap_rtc_of_match[] = {
Johan Hovold2153f942014-12-10 15:53:01 -0800468 {
469 .compatible = "ti,am3352-rtc",
470 .data = &omap_rtc_am3352_type,
471 }, {
472 .compatible = "ti,da830-rtc",
473 .data = &omap_rtc_da830_type,
474 }, {
475 /* sentinel */
476 }
Afzal Mohammed9e0344d2012-12-17 16:02:15 -0800477};
478MODULE_DEVICE_TABLE(of, omap_rtc_of_match);
479
David Brownell71fc8222008-07-23 21:30:38 -0700480static int __init omap_rtc_probe(struct platform_device *pdev)
David Brownelldb68b182006-12-06 20:38:36 -0800481{
Johan Hovold55ba9532014-12-10 15:52:55 -0800482 struct omap_rtc *rtc;
Vishwanathrao Badarkhe, Manish3765e8f2013-04-29 16:20:04 -0700483 struct resource *res;
Johan Hovold9291e342014-12-10 15:53:04 -0800484 u8 reg, mask, new_ctrl;
Afzal Mohammedcab14582012-12-17 16:02:11 -0800485 const struct platform_device_id *id_entry;
Afzal Mohammed9e0344d2012-12-17 16:02:15 -0800486 const struct of_device_id *of_id;
Johan Hovold437b37a2014-12-10 15:52:40 -0800487 int ret;
Afzal Mohammed9e0344d2012-12-17 16:02:15 -0800488
Johan Hovold55ba9532014-12-10 15:52:55 -0800489 rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
490 if (!rtc)
491 return -ENOMEM;
492
Afzal Mohammed9e0344d2012-12-17 16:02:15 -0800493 of_id = of_match_device(omap_rtc_of_match, &pdev->dev);
Johan Hovold2153f942014-12-10 15:53:01 -0800494 if (of_id) {
495 rtc->type = of_id->data;
Johan Hovold222a12f2014-12-10 15:53:13 -0800496 rtc->is_pmic_controller = rtc->type->has_pmic_mode &&
497 of_property_read_bool(pdev->dev.of_node,
498 "ti,system-power-controller");
Johan Hovold2153f942014-12-10 15:53:01 -0800499 } else {
500 id_entry = platform_get_device_id(pdev);
501 rtc->type = (void *)id_entry->driver_data;
Sekhar Nori337b6002014-06-06 14:36:04 -0700502 }
503
Johan Hovold55ba9532014-12-10 15:52:55 -0800504 rtc->irq_timer = platform_get_irq(pdev, 0);
505 if (rtc->irq_timer <= 0)
David Brownelldb68b182006-12-06 20:38:36 -0800506 return -ENOENT;
David Brownelldb68b182006-12-06 20:38:36 -0800507
Johan Hovold55ba9532014-12-10 15:52:55 -0800508 rtc->irq_alarm = platform_get_irq(pdev, 1);
509 if (rtc->irq_alarm <= 0)
David Brownelldb68b182006-12-06 20:38:36 -0800510 return -ENOENT;
David Brownelldb68b182006-12-06 20:38:36 -0800511
David Brownelldb68b182006-12-06 20:38:36 -0800512 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Johan Hovold55ba9532014-12-10 15:52:55 -0800513 rtc->base = devm_ioremap_resource(&pdev->dev, res);
514 if (IS_ERR(rtc->base))
515 return PTR_ERR(rtc->base);
516
517 platform_set_drvdata(pdev, rtc);
Mark A. Greer8cfde8c2009-12-15 16:46:11 -0800518
Vaibhav Hiremathfc9bd902012-12-17 16:02:18 -0800519 /* Enable the clock/module so that we can access the registers */
520 pm_runtime_enable(&pdev->dev);
521 pm_runtime_get_sync(&pdev->dev);
522
Johan Hovold2153f942014-12-10 15:53:01 -0800523 if (rtc->type->has_kicker) {
Johan Hovold55ba9532014-12-10 15:52:55 -0800524 rtc_writel(rtc, OMAP_RTC_KICK0_REG, KICK0_VALUE);
525 rtc_writel(rtc, OMAP_RTC_KICK1_REG, KICK1_VALUE);
Afzal Mohammedcab14582012-12-17 16:02:11 -0800526 }
527
Johan Hovold1ed8b5d2014-12-10 15:52:36 -0800528 /*
529 * disable interrupts
530 *
531 * NOTE: ALARM2 is not cleared on AM3352 if rtc_write (writeb) is used
David Brownelldb68b182006-12-06 20:38:36 -0800532 */
Johan Hovold55ba9532014-12-10 15:52:55 -0800533 rtc_writel(rtc, OMAP_RTC_INTERRUPTS_REG, 0);
David Brownelldb68b182006-12-06 20:38:36 -0800534
Sekhar Noricd914bb2014-06-06 14:36:06 -0700535 /* enable RTC functional clock */
Johan Hovold2153f942014-12-10 15:53:01 -0800536 if (rtc->type->has_32kclk_en) {
Johan Hovold55ba9532014-12-10 15:52:55 -0800537 reg = rtc_read(rtc, OMAP_RTC_OSC_REG);
538 rtc_writel(rtc, OMAP_RTC_OSC_REG,
539 reg | OMAP_RTC_OSC_32KCLK_EN);
Johan Hovold44c63a52014-12-10 15:52:30 -0800540 }
Sekhar Noricd914bb2014-06-06 14:36:06 -0700541
David Brownelldb68b182006-12-06 20:38:36 -0800542 /* clear old status */
Johan Hovold55ba9532014-12-10 15:52:55 -0800543 reg = rtc_read(rtc, OMAP_RTC_STATUS_REG);
Johan Hovold9291e342014-12-10 15:53:04 -0800544
545 mask = OMAP_RTC_STATUS_ALARM;
546
Johan Hovold222a12f2014-12-10 15:53:13 -0800547 if (rtc->type->has_pmic_mode)
548 mask |= OMAP_RTC_STATUS_ALARM2;
549
Johan Hovold9291e342014-12-10 15:53:04 -0800550 if (rtc->type->has_power_up_reset) {
551 mask |= OMAP_RTC_STATUS_POWER_UP;
552 if (reg & OMAP_RTC_STATUS_POWER_UP)
553 dev_info(&pdev->dev, "RTC power up reset detected\n");
David Brownelldb68b182006-12-06 20:38:36 -0800554 }
Johan Hovold9291e342014-12-10 15:53:04 -0800555
556 if (reg & mask)
557 rtc_write(rtc, OMAP_RTC_STATUS_REG, reg & mask);
David Brownelldb68b182006-12-06 20:38:36 -0800558
David Brownelldb68b182006-12-06 20:38:36 -0800559 /* On boards with split power, RTC_ON_NOFF won't reset the RTC */
Johan Hovold55ba9532014-12-10 15:52:55 -0800560 reg = rtc_read(rtc, OMAP_RTC_CTRL_REG);
David Brownelldb68b182006-12-06 20:38:36 -0800561 if (reg & (u8) OMAP_RTC_CTRL_STOP)
Johan Hovold397b6302014-12-10 15:52:49 -0800562 dev_info(&pdev->dev, "already running\n");
David Brownelldb68b182006-12-06 20:38:36 -0800563
564 /* force to 24 hour mode */
Daniel Glöckner12b3e032011-08-03 16:21:02 -0700565 new_ctrl = reg & (OMAP_RTC_CTRL_SPLIT|OMAP_RTC_CTRL_AUTO_COMP);
David Brownelldb68b182006-12-06 20:38:36 -0800566 new_ctrl |= OMAP_RTC_CTRL_STOP;
567
568 /* BOARD-SPECIFIC CUSTOMIZATION CAN GO HERE:
569 *
Sekhar Norifa5b0782010-10-27 15:33:05 -0700570 * - Device wake-up capability setting should come through chip
571 * init logic. OMAP1 boards should initialize the "wakeup capable"
572 * flag in the platform device if the board is wired right for
573 * being woken up by RTC alarm. For OMAP-L138, this capability
574 * is built into the SoC by the "Deep Sleep" capability.
David Brownelldb68b182006-12-06 20:38:36 -0800575 *
576 * - Boards wired so RTC_ON_nOFF is used as the reset signal,
577 * rather than nPWRON_RESET, should forcibly enable split
578 * power mode. (Some chip errata report that RTC_CTRL_SPLIT
579 * is write-only, and always reads as zero...)
580 */
David Brownelldb68b182006-12-06 20:38:36 -0800581
582 if (new_ctrl & (u8) OMAP_RTC_CTRL_SPLIT)
Johan Hovold397b6302014-12-10 15:52:49 -0800583 dev_info(&pdev->dev, "split power mode\n");
David Brownelldb68b182006-12-06 20:38:36 -0800584
585 if (reg != new_ctrl)
Johan Hovold55ba9532014-12-10 15:52:55 -0800586 rtc_write(rtc, OMAP_RTC_CTRL_REG, new_ctrl);
David Brownelldb68b182006-12-06 20:38:36 -0800587
Johan Hovold4390ce02014-12-10 15:52:43 -0800588 device_init_wakeup(&pdev->dev, true);
589
Johan Hovold55ba9532014-12-10 15:52:55 -0800590 rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
Johan Hovold4390ce02014-12-10 15:52:43 -0800591 &omap_rtc_ops, THIS_MODULE);
Johan Hovold55ba9532014-12-10 15:52:55 -0800592 if (IS_ERR(rtc->rtc)) {
593 ret = PTR_ERR(rtc->rtc);
Johan Hovold4390ce02014-12-10 15:52:43 -0800594 goto err;
595 }
Johan Hovold4390ce02014-12-10 15:52:43 -0800596
597 /* handle periodic and alarm irqs */
Johan Hovold55ba9532014-12-10 15:52:55 -0800598 ret = devm_request_irq(&pdev->dev, rtc->irq_timer, rtc_irq, 0,
599 dev_name(&rtc->rtc->dev), rtc);
Johan Hovold4390ce02014-12-10 15:52:43 -0800600 if (ret)
601 goto err;
602
Johan Hovold55ba9532014-12-10 15:52:55 -0800603 if (rtc->irq_timer != rtc->irq_alarm) {
604 ret = devm_request_irq(&pdev->dev, rtc->irq_alarm, rtc_irq, 0,
605 dev_name(&rtc->rtc->dev), rtc);
Johan Hovold4390ce02014-12-10 15:52:43 -0800606 if (ret)
607 goto err;
608 }
609
Johan Hovold222a12f2014-12-10 15:53:13 -0800610 if (rtc->is_pmic_controller) {
611 if (!pm_power_off) {
612 omap_rtc_power_off_rtc = rtc;
613 pm_power_off = omap_rtc_power_off;
614 }
615 }
616
David Brownelldb68b182006-12-06 20:38:36 -0800617 return 0;
618
Johan Hovold437b37a2014-12-10 15:52:40 -0800619err:
Johan Hovold7ecd9a32014-12-10 15:52:33 -0800620 device_init_wakeup(&pdev->dev, false);
Johan Hovold2153f942014-12-10 15:53:01 -0800621 if (rtc->type->has_kicker)
Johan Hovold55ba9532014-12-10 15:52:55 -0800622 rtc_writel(rtc, OMAP_RTC_KICK0_REG, 0);
Vaibhav Hiremathfc9bd902012-12-17 16:02:18 -0800623 pm_runtime_put_sync(&pdev->dev);
624 pm_runtime_disable(&pdev->dev);
Johan Hovold437b37a2014-12-10 15:52:40 -0800625
626 return ret;
David Brownelldb68b182006-12-06 20:38:36 -0800627}
628
David Brownell71fc8222008-07-23 21:30:38 -0700629static int __exit omap_rtc_remove(struct platform_device *pdev)
David Brownelldb68b182006-12-06 20:38:36 -0800630{
Johan Hovold55ba9532014-12-10 15:52:55 -0800631 struct omap_rtc *rtc = platform_get_drvdata(pdev);
David Brownelldb68b182006-12-06 20:38:36 -0800632
Johan Hovold222a12f2014-12-10 15:53:13 -0800633 if (pm_power_off == omap_rtc_power_off &&
634 omap_rtc_power_off_rtc == rtc) {
635 pm_power_off = NULL;
636 omap_rtc_power_off_rtc = NULL;
637 }
638
David Brownelldb68b182006-12-06 20:38:36 -0800639 device_init_wakeup(&pdev->dev, 0);
640
641 /* leave rtc running, but disable irqs */
Johan Hovold55ba9532014-12-10 15:52:55 -0800642 rtc_write(rtc, OMAP_RTC_INTERRUPTS_REG, 0);
David Brownelldb68b182006-12-06 20:38:36 -0800643
Johan Hovold2153f942014-12-10 15:53:01 -0800644 if (rtc->type->has_kicker)
Johan Hovold55ba9532014-12-10 15:52:55 -0800645 rtc_writel(rtc, OMAP_RTC_KICK0_REG, 0);
Vaibhav Hiremathfc9bd902012-12-17 16:02:18 -0800646
647 /* Disable the clock/module */
648 pm_runtime_put_sync(&pdev->dev);
649 pm_runtime_disable(&pdev->dev);
650
David Brownelldb68b182006-12-06 20:38:36 -0800651 return 0;
652}
653
Jingoo Han04ebc352013-04-29 16:21:01 -0700654#ifdef CONFIG_PM_SLEEP
Jingoo Han04ebc352013-04-29 16:21:01 -0700655static int omap_rtc_suspend(struct device *dev)
David Brownelldb68b182006-12-06 20:38:36 -0800656{
Johan Hovold55ba9532014-12-10 15:52:55 -0800657 struct omap_rtc *rtc = dev_get_drvdata(dev);
658
659 rtc->interrupts_reg = rtc_read(rtc, OMAP_RTC_INTERRUPTS_REG);
David Brownelldb68b182006-12-06 20:38:36 -0800660
661 /* FIXME the RTC alarm is not currently acting as a wakeup event
Hebbar Gururaja8af750e2013-09-11 14:24:18 -0700662 * source on some platforms, and in fact this enable() call is just
663 * saving a flag that's never used...
David Brownelldb68b182006-12-06 20:38:36 -0800664 */
Lokesh Vutlaab7f5802014-06-06 14:36:12 -0700665 if (device_may_wakeup(dev))
Johan Hovold55ba9532014-12-10 15:52:55 -0800666 enable_irq_wake(rtc->irq_alarm);
Lokesh Vutlaab7f5802014-06-06 14:36:12 -0700667 else
Johan Hovold55ba9532014-12-10 15:52:55 -0800668 rtc_write(rtc, OMAP_RTC_INTERRUPTS_REG, 0);
David Brownelldb68b182006-12-06 20:38:36 -0800669
Vaibhav Hiremathfc9bd902012-12-17 16:02:18 -0800670 /* Disable the clock/module */
Jingoo Han04ebc352013-04-29 16:21:01 -0700671 pm_runtime_put_sync(dev);
Vaibhav Hiremathfc9bd902012-12-17 16:02:18 -0800672
David Brownelldb68b182006-12-06 20:38:36 -0800673 return 0;
674}
675
Jingoo Han04ebc352013-04-29 16:21:01 -0700676static int omap_rtc_resume(struct device *dev)
David Brownelldb68b182006-12-06 20:38:36 -0800677{
Johan Hovold55ba9532014-12-10 15:52:55 -0800678 struct omap_rtc *rtc = dev_get_drvdata(dev);
679
Vaibhav Hiremathfc9bd902012-12-17 16:02:18 -0800680 /* Enable the clock/module so that we can access the registers */
Jingoo Han04ebc352013-04-29 16:21:01 -0700681 pm_runtime_get_sync(dev);
Vaibhav Hiremathfc9bd902012-12-17 16:02:18 -0800682
Lokesh Vutlaab7f5802014-06-06 14:36:12 -0700683 if (device_may_wakeup(dev))
Johan Hovold55ba9532014-12-10 15:52:55 -0800684 disable_irq_wake(rtc->irq_alarm);
Lokesh Vutlaab7f5802014-06-06 14:36:12 -0700685 else
Johan Hovold55ba9532014-12-10 15:52:55 -0800686 rtc_write(rtc, OMAP_RTC_INTERRUPTS_REG, rtc->interrupts_reg);
Lokesh Vutlaab7f5802014-06-06 14:36:12 -0700687
David Brownelldb68b182006-12-06 20:38:36 -0800688 return 0;
689}
David Brownelldb68b182006-12-06 20:38:36 -0800690#endif
691
Jingoo Han04ebc352013-04-29 16:21:01 -0700692static SIMPLE_DEV_PM_OPS(omap_rtc_pm_ops, omap_rtc_suspend, omap_rtc_resume);
693
David Brownelldb68b182006-12-06 20:38:36 -0800694static void omap_rtc_shutdown(struct platform_device *pdev)
695{
Johan Hovold55ba9532014-12-10 15:52:55 -0800696 struct omap_rtc *rtc = platform_get_drvdata(pdev);
Johan Hovold8ad5c722014-12-10 15:53:16 -0800697 u8 mask;
Johan Hovold55ba9532014-12-10 15:52:55 -0800698
Johan Hovold8ad5c722014-12-10 15:53:16 -0800699 /*
700 * Keep the ALARM interrupt enabled to allow the system to power up on
701 * alarm events.
702 */
703 mask = rtc_read(rtc, OMAP_RTC_INTERRUPTS_REG);
704 mask &= OMAP_RTC_INTERRUPTS_IT_ALARM;
705 rtc_write(rtc, OMAP_RTC_INTERRUPTS_REG, mask);
David Brownelldb68b182006-12-06 20:38:36 -0800706}
707
David Brownelldb68b182006-12-06 20:38:36 -0800708static struct platform_driver omap_rtc_driver = {
David Brownell71fc8222008-07-23 21:30:38 -0700709 .remove = __exit_p(omap_rtc_remove),
David Brownelldb68b182006-12-06 20:38:36 -0800710 .shutdown = omap_rtc_shutdown,
711 .driver = {
Johan Hovolda430ca22014-12-10 15:52:58 -0800712 .name = "omap_rtc",
David Brownelldb68b182006-12-06 20:38:36 -0800713 .owner = THIS_MODULE,
Jingoo Han04ebc352013-04-29 16:21:01 -0700714 .pm = &omap_rtc_pm_ops,
Sachin Kamat616b7342013-11-12 15:10:55 -0800715 .of_match_table = omap_rtc_of_match,
David Brownelldb68b182006-12-06 20:38:36 -0800716 },
Johan Hovold2153f942014-12-10 15:53:01 -0800717 .id_table = omap_rtc_id_table,
David Brownelldb68b182006-12-06 20:38:36 -0800718};
719
Jingoo Han09c5a362013-04-29 16:18:46 -0700720module_platform_driver_probe(omap_rtc_driver, omap_rtc_probe);
David Brownelldb68b182006-12-06 20:38:36 -0800721
Johan Hovolda430ca22014-12-10 15:52:58 -0800722MODULE_ALIAS("platform:omap_rtc");
David Brownelldb68b182006-12-06 20:38:36 -0800723MODULE_AUTHOR("George G. Davis (and others)");
724MODULE_LICENSE("GPL");