blob: 6495f84f74288cfda5e2a26274dbdedb152531b2 [file] [log] [blame]
Krzysztof Kozlowski26dcc122018-08-07 18:19:19 +02001// SPDX-License-Identifier: GPL-2.0+
2//
3// Copyright (c) 2013-2014 Samsung Electronics Co., Ltd
4// http://www.samsung.com
5//
6// Copyright (C) 2013 Google, Inc
Sangbeom Kim5bccae62013-11-12 15:11:04 -08007
Joe Perchesa737e832015-04-16 12:46:14 -07008#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9
Sangbeom Kim5bccae62013-11-12 15:11:04 -080010#include <linux/module.h>
11#include <linux/i2c.h>
Sangbeom Kim5bccae62013-11-12 15:11:04 -080012#include <linux/bcd.h>
Sangbeom Kim5bccae62013-11-12 15:11:04 -080013#include <linux/regmap.h>
14#include <linux/rtc.h>
Sangbeom Kim5bccae62013-11-12 15:11:04 -080015#include <linux/platform_device.h>
16#include <linux/mfd/samsung/core.h>
17#include <linux/mfd/samsung/irq.h>
18#include <linux/mfd/samsung/rtc.h>
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -070019#include <linux/mfd/samsung/s2mps14.h>
Sangbeom Kim5bccae62013-11-12 15:11:04 -080020
Krzysztof Kozlowskid73238d2013-12-12 17:12:28 -080021/*
22 * Maximum number of retries for checking changes in UDR field
Krzysztof Kozlowski602cb5b2014-06-10 15:18:40 -070023 * of S5M_RTC_UDR_CON register (to limit possible endless loop).
Krzysztof Kozlowskid73238d2013-12-12 17:12:28 -080024 *
25 * After writing to RTC registers (setting time or alarm) read the UDR field
Krzysztof Kozlowski602cb5b2014-06-10 15:18:40 -070026 * in S5M_RTC_UDR_CON register. UDR is auto-cleared when data have
Krzysztof Kozlowskid73238d2013-12-12 17:12:28 -080027 * been transferred.
28 */
29#define UDR_READ_RETRY_CNT 5
30
Gustavo A. R. Silva4a681242018-03-10 00:27:15 -060031enum {
32 RTC_SEC = 0,
33 RTC_MIN,
34 RTC_HOUR,
35 RTC_WEEKDAY,
36 RTC_DATE,
37 RTC_MONTH,
38 RTC_YEAR1,
39 RTC_YEAR2,
Gustavo A. R. Silva756d5282018-03-10 00:27:35 -060040 /* Make sure this is always the last enum name. */
41 RTC_MAX_NUM_TIME_REGS
Gustavo A. R. Silva4a681242018-03-10 00:27:15 -060042};
43
Krzysztof Kozlowski8ae83b62015-12-30 13:47:27 +090044/*
45 * Registers used by the driver which are different between chipsets.
46 *
47 * Operations like read time and write alarm/time require updating
48 * specific fields in UDR register. These fields usually are auto-cleared
49 * (with some exceptions).
50 *
51 * Table of operations per device:
52 *
53 * Device | Write time | Read time | Write alarm
54 * =================================================
55 * S5M8767 | UDR + TIME | | UDR
56 * S2MPS11/14 | WUDR | RUDR | WUDR + RUDR
57 * S2MPS13 | WUDR | RUDR | WUDR + AUDR
58 * S2MPS15 | WUDR | RUDR | AUDR
59 */
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -070060struct s5m_rtc_reg_config {
61 /* Number of registers used for setting time/alarm0/alarm1 */
62 unsigned int regs_count;
63 /* First register for time, seconds */
64 unsigned int time;
65 /* RTC control register */
66 unsigned int ctrl;
67 /* First register for alarm 0, seconds */
68 unsigned int alarm0;
69 /* First register for alarm 1, seconds */
70 unsigned int alarm1;
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -070071 /*
72 * Register for update flag (UDR). Typically setting UDR field to 1
73 * will enable update of time or alarm register. Then it will be
74 * auto-cleared after successful update.
75 */
Krzysztof Kozlowskia83a7932015-12-30 13:47:25 +090076 unsigned int udr_update;
Krzysztof Kozlowski67a60252015-12-30 13:47:26 +090077 /* Auto-cleared mask in UDR field for writing time and alarm */
78 unsigned int autoclear_udr_mask;
Krzysztof Kozlowski8ae83b62015-12-30 13:47:27 +090079 /*
80 * Masks in UDR field for time and alarm operations.
81 * The read time mask can be 0. Rest should not.
82 */
83 unsigned int read_time_udr_mask;
84 unsigned int write_time_udr_mask;
85 unsigned int write_alarm_udr_mask;
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -070086};
87
88/* Register map for S5M8763 and S5M8767 */
89static const struct s5m_rtc_reg_config s5m_rtc_regs = {
90 .regs_count = 8,
91 .time = S5M_RTC_SEC,
92 .ctrl = S5M_ALARM1_CONF,
93 .alarm0 = S5M_ALARM0_SEC,
94 .alarm1 = S5M_ALARM1_SEC,
Krzysztof Kozlowskia83a7932015-12-30 13:47:25 +090095 .udr_update = S5M_RTC_UDR_CON,
Krzysztof Kozlowski67a60252015-12-30 13:47:26 +090096 .autoclear_udr_mask = S5M_RTC_UDR_MASK,
Krzysztof Kozlowski8ae83b62015-12-30 13:47:27 +090097 .read_time_udr_mask = 0, /* Not needed */
98 .write_time_udr_mask = S5M_RTC_UDR_MASK | S5M_RTC_TIME_EN_MASK,
99 .write_alarm_udr_mask = S5M_RTC_UDR_MASK,
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700100};
101
Krzysztof Kozlowski8ae83b62015-12-30 13:47:27 +0900102/* Register map for S2MPS13 */
103static const struct s5m_rtc_reg_config s2mps13_rtc_regs = {
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700104 .regs_count = 7,
105 .time = S2MPS_RTC_SEC,
106 .ctrl = S2MPS_RTC_CTRL,
107 .alarm0 = S2MPS_ALARM0_SEC,
108 .alarm1 = S2MPS_ALARM1_SEC,
Krzysztof Kozlowskia83a7932015-12-30 13:47:25 +0900109 .udr_update = S2MPS_RTC_UDR_CON,
Krzysztof Kozlowski67a60252015-12-30 13:47:26 +0900110 .autoclear_udr_mask = S2MPS_RTC_WUDR_MASK,
Krzysztof Kozlowski8ae83b62015-12-30 13:47:27 +0900111 .read_time_udr_mask = S2MPS_RTC_RUDR_MASK,
112 .write_time_udr_mask = S2MPS_RTC_WUDR_MASK,
113 .write_alarm_udr_mask = S2MPS_RTC_WUDR_MASK | S2MPS13_RTC_AUDR_MASK,
114};
115
116/* Register map for S2MPS11/14 */
117static const struct s5m_rtc_reg_config s2mps14_rtc_regs = {
118 .regs_count = 7,
119 .time = S2MPS_RTC_SEC,
120 .ctrl = S2MPS_RTC_CTRL,
121 .alarm0 = S2MPS_ALARM0_SEC,
122 .alarm1 = S2MPS_ALARM1_SEC,
123 .udr_update = S2MPS_RTC_UDR_CON,
124 .autoclear_udr_mask = S2MPS_RTC_WUDR_MASK,
125 .read_time_udr_mask = S2MPS_RTC_RUDR_MASK,
126 .write_time_udr_mask = S2MPS_RTC_WUDR_MASK,
127 .write_alarm_udr_mask = S2MPS_RTC_WUDR_MASK | S2MPS_RTC_RUDR_MASK,
128};
129
130/*
131 * Register map for S2MPS15 - in comparison to S2MPS14 the WUDR and AUDR bits
132 * are swapped.
133 */
134static const struct s5m_rtc_reg_config s2mps15_rtc_regs = {
135 .regs_count = 7,
136 .time = S2MPS_RTC_SEC,
137 .ctrl = S2MPS_RTC_CTRL,
138 .alarm0 = S2MPS_ALARM0_SEC,
139 .alarm1 = S2MPS_ALARM1_SEC,
140 .udr_update = S2MPS_RTC_UDR_CON,
141 .autoclear_udr_mask = S2MPS_RTC_WUDR_MASK,
142 .read_time_udr_mask = S2MPS_RTC_RUDR_MASK,
143 .write_time_udr_mask = S2MPS15_RTC_WUDR_MASK,
144 .write_alarm_udr_mask = S2MPS15_RTC_AUDR_MASK,
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700145};
146
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800147struct s5m_rtc_info {
148 struct device *dev;
Krzysztof Kozlowskie349c912014-04-14 09:40:45 +0200149 struct i2c_client *i2c;
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800150 struct sec_pmic_dev *s5m87xx;
Geert Uytterhoeven5ccb7d72013-12-12 17:12:25 -0800151 struct regmap *regmap;
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800152 struct rtc_device *rtc_dev;
153 int irq;
Krzysztof Kozlowski94f91922015-04-16 12:49:27 -0700154 enum sec_device_type device_type;
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800155 int rtc_24hr_mode;
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700156 const struct s5m_rtc_reg_config *regs;
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800157};
158
Krzysztof Kozlowskie349c912014-04-14 09:40:45 +0200159static const struct regmap_config s5m_rtc_regmap_config = {
160 .reg_bits = 8,
161 .val_bits = 8,
162
Krzysztof Kozlowski602cb5b2014-06-10 15:18:40 -0700163 .max_register = S5M_RTC_REG_MAX,
Krzysztof Kozlowskie349c912014-04-14 09:40:45 +0200164};
165
166static const struct regmap_config s2mps14_rtc_regmap_config = {
167 .reg_bits = 8,
168 .val_bits = 8,
169
170 .max_register = S2MPS_RTC_REG_MAX,
171};
172
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800173static void s5m8767_data_to_tm(u8 *data, struct rtc_time *tm,
174 int rtc_24hr_mode)
175{
176 tm->tm_sec = data[RTC_SEC] & 0x7f;
177 tm->tm_min = data[RTC_MIN] & 0x7f;
178 if (rtc_24hr_mode) {
179 tm->tm_hour = data[RTC_HOUR] & 0x1f;
180 } else {
181 tm->tm_hour = data[RTC_HOUR] & 0x0f;
182 if (data[RTC_HOUR] & HOUR_PM_MASK)
183 tm->tm_hour += 12;
184 }
185
186 tm->tm_wday = ffs(data[RTC_WEEKDAY] & 0x7f);
187 tm->tm_mday = data[RTC_DATE] & 0x1f;
188 tm->tm_mon = (data[RTC_MONTH] & 0x0f) - 1;
189 tm->tm_year = (data[RTC_YEAR1] & 0x7f) + 100;
190 tm->tm_yday = 0;
191 tm->tm_isdst = 0;
192}
193
194static int s5m8767_tm_to_data(struct rtc_time *tm, u8 *data)
195{
196 data[RTC_SEC] = tm->tm_sec;
197 data[RTC_MIN] = tm->tm_min;
198
199 if (tm->tm_hour >= 12)
200 data[RTC_HOUR] = tm->tm_hour | HOUR_PM_MASK;
201 else
202 data[RTC_HOUR] = tm->tm_hour & ~HOUR_PM_MASK;
203
204 data[RTC_WEEKDAY] = 1 << tm->tm_wday;
205 data[RTC_DATE] = tm->tm_mday;
206 data[RTC_MONTH] = tm->tm_mon + 1;
207 data[RTC_YEAR1] = tm->tm_year > 100 ? (tm->tm_year - 100) : 0;
208
209 if (tm->tm_year < 100) {
Joe Perchesa737e832015-04-16 12:46:14 -0700210 pr_err("RTC cannot handle the year %d\n",
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800211 1900 + tm->tm_year);
212 return -EINVAL;
213 } else {
214 return 0;
215 }
216}
217
Krzysztof Kozlowskid73238d2013-12-12 17:12:28 -0800218/*
219 * Read RTC_UDR_CON register and wait till UDR field is cleared.
220 * This indicates that time/alarm update ended.
221 */
Krzysztof Kozlowski8124c712016-02-16 11:04:42 +0900222static int s5m8767_wait_for_udr_update(struct s5m_rtc_info *info)
Krzysztof Kozlowskid73238d2013-12-12 17:12:28 -0800223{
224 int ret, retry = UDR_READ_RETRY_CNT;
225 unsigned int data;
226
227 do {
Krzysztof Kozlowskia83a7932015-12-30 13:47:25 +0900228 ret = regmap_read(info->regmap, info->regs->udr_update, &data);
Krzysztof Kozlowski67a60252015-12-30 13:47:26 +0900229 } while (--retry && (data & info->regs->autoclear_udr_mask) && !ret);
Krzysztof Kozlowskid73238d2013-12-12 17:12:28 -0800230
231 if (!retry)
232 dev_err(info->dev, "waiting for UDR update, reached max number of retries\n");
233
234 return ret;
235}
236
Krzysztof Kozlowski8124c712016-02-16 11:04:42 +0900237static int s5m_check_peding_alarm_interrupt(struct s5m_rtc_info *info,
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700238 struct rtc_wkalrm *alarm)
239{
240 int ret;
241 unsigned int val;
242
243 switch (info->device_type) {
244 case S5M8767X:
245 case S5M8763X:
246 ret = regmap_read(info->regmap, S5M_RTC_STATUS, &val);
247 val &= S5M_ALARM0_STATUS;
248 break;
Alim Akhtara65e5ef2015-11-20 16:07:53 +0530249 case S2MPS15X:
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700250 case S2MPS14X:
Krzysztof Kozlowski5281f942015-04-16 12:45:45 -0700251 case S2MPS13X:
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700252 ret = regmap_read(info->s5m87xx->regmap_pmic, S2MPS14_REG_ST2,
253 &val);
254 val &= S2MPS_ALARM0_STATUS;
255 break;
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700256 default:
257 return -EINVAL;
258 }
259 if (ret < 0)
260 return ret;
261
262 if (val)
263 alarm->pending = 1;
264 else
265 alarm->pending = 0;
266
267 return 0;
268}
269
Krzysztof Kozlowski8124c712016-02-16 11:04:42 +0900270static int s5m8767_rtc_set_time_reg(struct s5m_rtc_info *info)
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800271{
272 int ret;
273 unsigned int data;
274
Krzysztof Kozlowskia83a7932015-12-30 13:47:25 +0900275 ret = regmap_read(info->regmap, info->regs->udr_update, &data);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800276 if (ret < 0) {
277 dev_err(info->dev, "failed to read update reg(%d)\n", ret);
278 return ret;
279 }
280
Krzysztof Kozlowski8ae83b62015-12-30 13:47:27 +0900281 data |= info->regs->write_time_udr_mask;
Alim Akhtara65e5ef2015-11-20 16:07:53 +0530282
Krzysztof Kozlowskia83a7932015-12-30 13:47:25 +0900283 ret = regmap_write(info->regmap, info->regs->udr_update, data);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800284 if (ret < 0) {
285 dev_err(info->dev, "failed to write update reg(%d)\n", ret);
286 return ret;
287 }
288
Krzysztof Kozlowskid73238d2013-12-12 17:12:28 -0800289 ret = s5m8767_wait_for_udr_update(info);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800290
291 return ret;
292}
293
Krzysztof Kozlowski8124c712016-02-16 11:04:42 +0900294static int s5m8767_rtc_set_alarm_reg(struct s5m_rtc_info *info)
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800295{
296 int ret;
297 unsigned int data;
298
Krzysztof Kozlowskia83a7932015-12-30 13:47:25 +0900299 ret = regmap_read(info->regmap, info->regs->udr_update, &data);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800300 if (ret < 0) {
301 dev_err(info->dev, "%s: fail to read update reg(%d)\n",
302 __func__, ret);
303 return ret;
304 }
305
Krzysztof Kozlowski8ae83b62015-12-30 13:47:27 +0900306 data |= info->regs->write_alarm_udr_mask;
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700307 switch (info->device_type) {
308 case S5M8763X:
309 case S5M8767X:
310 data &= ~S5M_RTC_TIME_EN_MASK;
311 break;
Alim Akhtara65e5ef2015-11-20 16:07:53 +0530312 case S2MPS15X:
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700313 case S2MPS14X:
Krzysztof Kozlowski5281f942015-04-16 12:45:45 -0700314 case S2MPS13X:
Krzysztof Kozlowski8ae83b62015-12-30 13:47:27 +0900315 /* No exceptions needed */
Krzysztof Kozlowski5281f942015-04-16 12:45:45 -0700316 break;
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700317 default:
318 return -EINVAL;
319 }
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800320
Krzysztof Kozlowskia83a7932015-12-30 13:47:25 +0900321 ret = regmap_write(info->regmap, info->regs->udr_update, data);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800322 if (ret < 0) {
323 dev_err(info->dev, "%s: fail to write update reg(%d)\n",
324 __func__, ret);
325 return ret;
326 }
327
Krzysztof Kozlowskid73238d2013-12-12 17:12:28 -0800328 ret = s5m8767_wait_for_udr_update(info);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800329
Krzysztof Kozlowski5281f942015-04-16 12:45:45 -0700330 /* On S2MPS13 the AUDR is not auto-cleared */
331 if (info->device_type == S2MPS13X)
Krzysztof Kozlowskia83a7932015-12-30 13:47:25 +0900332 regmap_update_bits(info->regmap, info->regs->udr_update,
Krzysztof Kozlowski5281f942015-04-16 12:45:45 -0700333 S2MPS13_RTC_AUDR_MASK, 0);
334
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800335 return ret;
336}
337
338static void s5m8763_data_to_tm(u8 *data, struct rtc_time *tm)
339{
340 tm->tm_sec = bcd2bin(data[RTC_SEC]);
341 tm->tm_min = bcd2bin(data[RTC_MIN]);
342
343 if (data[RTC_HOUR] & HOUR_12) {
344 tm->tm_hour = bcd2bin(data[RTC_HOUR] & 0x1f);
345 if (data[RTC_HOUR] & HOUR_PM)
346 tm->tm_hour += 12;
347 } else {
348 tm->tm_hour = bcd2bin(data[RTC_HOUR] & 0x3f);
349 }
350
351 tm->tm_wday = data[RTC_WEEKDAY] & 0x07;
352 tm->tm_mday = bcd2bin(data[RTC_DATE]);
353 tm->tm_mon = bcd2bin(data[RTC_MONTH]);
354 tm->tm_year = bcd2bin(data[RTC_YEAR1]) + bcd2bin(data[RTC_YEAR2]) * 100;
355 tm->tm_year -= 1900;
356}
357
358static void s5m8763_tm_to_data(struct rtc_time *tm, u8 *data)
359{
360 data[RTC_SEC] = bin2bcd(tm->tm_sec);
361 data[RTC_MIN] = bin2bcd(tm->tm_min);
362 data[RTC_HOUR] = bin2bcd(tm->tm_hour);
363 data[RTC_WEEKDAY] = tm->tm_wday;
364 data[RTC_DATE] = bin2bcd(tm->tm_mday);
365 data[RTC_MONTH] = bin2bcd(tm->tm_mon);
366 data[RTC_YEAR1] = bin2bcd(tm->tm_year % 100);
367 data[RTC_YEAR2] = bin2bcd((tm->tm_year + 1900) / 100);
368}
369
370static int s5m_rtc_read_time(struct device *dev, struct rtc_time *tm)
371{
372 struct s5m_rtc_info *info = dev_get_drvdata(dev);
Gustavo A. R. Silva756d5282018-03-10 00:27:35 -0600373 u8 data[RTC_MAX_NUM_TIME_REGS];
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800374 int ret;
375
Krzysztof Kozlowski8ae83b62015-12-30 13:47:27 +0900376 if (info->regs->read_time_udr_mask) {
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700377 ret = regmap_update_bits(info->regmap,
Krzysztof Kozlowskia83a7932015-12-30 13:47:25 +0900378 info->regs->udr_update,
Krzysztof Kozlowski8ae83b62015-12-30 13:47:27 +0900379 info->regs->read_time_udr_mask,
380 info->regs->read_time_udr_mask);
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700381 if (ret) {
382 dev_err(dev,
383 "Failed to prepare registers for time reading: %d\n",
384 ret);
385 return ret;
386 }
387 }
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700388 ret = regmap_bulk_read(info->regmap, info->regs->time, data,
389 info->regs->regs_count);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800390 if (ret < 0)
391 return ret;
392
393 switch (info->device_type) {
394 case S5M8763X:
395 s5m8763_data_to_tm(data, tm);
396 break;
397
398 case S5M8767X:
Alim Akhtara65e5ef2015-11-20 16:07:53 +0530399 case S2MPS15X:
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700400 case S2MPS14X:
Krzysztof Kozlowski5281f942015-04-16 12:45:45 -0700401 case S2MPS13X:
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800402 s5m8767_data_to_tm(data, tm, info->rtc_24hr_mode);
403 break;
404
405 default:
406 return -EINVAL;
407 }
408
409 dev_dbg(dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__,
410 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday,
411 tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_wday);
412
Alexandre Belloni22652ba2018-02-19 16:23:56 +0100413 return 0;
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800414}
415
416static int s5m_rtc_set_time(struct device *dev, struct rtc_time *tm)
417{
418 struct s5m_rtc_info *info = dev_get_drvdata(dev);
Gustavo A. R. Silva756d5282018-03-10 00:27:35 -0600419 u8 data[RTC_MAX_NUM_TIME_REGS];
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800420 int ret = 0;
421
422 switch (info->device_type) {
423 case S5M8763X:
424 s5m8763_tm_to_data(tm, data);
425 break;
426 case S5M8767X:
Alim Akhtara65e5ef2015-11-20 16:07:53 +0530427 case S2MPS15X:
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700428 case S2MPS14X:
Krzysztof Kozlowski5281f942015-04-16 12:45:45 -0700429 case S2MPS13X:
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800430 ret = s5m8767_tm_to_data(tm, data);
431 break;
432 default:
433 return -EINVAL;
434 }
435
436 if (ret < 0)
437 return ret;
438
439 dev_dbg(dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__,
440 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday,
441 tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_wday);
442
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700443 ret = regmap_raw_write(info->regmap, info->regs->time, data,
444 info->regs->regs_count);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800445 if (ret < 0)
446 return ret;
447
448 ret = s5m8767_rtc_set_time_reg(info);
449
450 return ret;
451}
452
453static int s5m_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
454{
455 struct s5m_rtc_info *info = dev_get_drvdata(dev);
Gustavo A. R. Silva756d5282018-03-10 00:27:35 -0600456 u8 data[RTC_MAX_NUM_TIME_REGS];
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800457 unsigned int val;
458 int ret, i;
459
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700460 ret = regmap_bulk_read(info->regmap, info->regs->alarm0, data,
461 info->regs->regs_count);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800462 if (ret < 0)
463 return ret;
464
465 switch (info->device_type) {
466 case S5M8763X:
467 s5m8763_data_to_tm(data, &alrm->time);
Krzysztof Kozlowski602cb5b2014-06-10 15:18:40 -0700468 ret = regmap_read(info->regmap, S5M_ALARM0_CONF, &val);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800469 if (ret < 0)
470 return ret;
471
472 alrm->enabled = !!val;
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800473 break;
474
475 case S5M8767X:
Alim Akhtara65e5ef2015-11-20 16:07:53 +0530476 case S2MPS15X:
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700477 case S2MPS14X:
Krzysztof Kozlowski5281f942015-04-16 12:45:45 -0700478 case S2MPS13X:
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800479 s5m8767_data_to_tm(data, &alrm->time, info->rtc_24hr_mode);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800480 alrm->enabled = 0;
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700481 for (i = 0; i < info->regs->regs_count; i++) {
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800482 if (data[i] & ALARM_ENABLE_MASK) {
483 alrm->enabled = 1;
484 break;
485 }
486 }
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800487 break;
488
489 default:
490 return -EINVAL;
491 }
492
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700493 dev_dbg(dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__,
494 1900 + alrm->time.tm_year, 1 + alrm->time.tm_mon,
495 alrm->time.tm_mday, alrm->time.tm_hour,
496 alrm->time.tm_min, alrm->time.tm_sec,
497 alrm->time.tm_wday);
498
499 ret = s5m_check_peding_alarm_interrupt(info, alrm);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800500
501 return 0;
502}
503
504static int s5m_rtc_stop_alarm(struct s5m_rtc_info *info)
505{
Gustavo A. R. Silva756d5282018-03-10 00:27:35 -0600506 u8 data[RTC_MAX_NUM_TIME_REGS];
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800507 int ret, i;
508 struct rtc_time tm;
509
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700510 ret = regmap_bulk_read(info->regmap, info->regs->alarm0, data,
511 info->regs->regs_count);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800512 if (ret < 0)
513 return ret;
514
515 s5m8767_data_to_tm(data, &tm, info->rtc_24hr_mode);
516 dev_dbg(info->dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__,
517 1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday,
518 tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_wday);
519
520 switch (info->device_type) {
521 case S5M8763X:
Krzysztof Kozlowski602cb5b2014-06-10 15:18:40 -0700522 ret = regmap_write(info->regmap, S5M_ALARM0_CONF, 0);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800523 break;
524
525 case S5M8767X:
Alim Akhtara65e5ef2015-11-20 16:07:53 +0530526 case S2MPS15X:
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700527 case S2MPS14X:
Krzysztof Kozlowski5281f942015-04-16 12:45:45 -0700528 case S2MPS13X:
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700529 for (i = 0; i < info->regs->regs_count; i++)
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800530 data[i] &= ~ALARM_ENABLE_MASK;
531
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700532 ret = regmap_raw_write(info->regmap, info->regs->alarm0, data,
533 info->regs->regs_count);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800534 if (ret < 0)
535 return ret;
536
537 ret = s5m8767_rtc_set_alarm_reg(info);
538
539 break;
540
541 default:
542 return -EINVAL;
543 }
544
545 return ret;
546}
547
548static int s5m_rtc_start_alarm(struct s5m_rtc_info *info)
549{
550 int ret;
Gustavo A. R. Silva756d5282018-03-10 00:27:35 -0600551 u8 data[RTC_MAX_NUM_TIME_REGS];
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800552 u8 alarm0_conf;
553 struct rtc_time tm;
554
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700555 ret = regmap_bulk_read(info->regmap, info->regs->alarm0, data,
556 info->regs->regs_count);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800557 if (ret < 0)
558 return ret;
559
560 s5m8767_data_to_tm(data, &tm, info->rtc_24hr_mode);
561 dev_dbg(info->dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__,
562 1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday,
563 tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_wday);
564
565 switch (info->device_type) {
566 case S5M8763X:
567 alarm0_conf = 0x77;
Krzysztof Kozlowski602cb5b2014-06-10 15:18:40 -0700568 ret = regmap_write(info->regmap, S5M_ALARM0_CONF, alarm0_conf);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800569 break;
570
571 case S5M8767X:
Alim Akhtara65e5ef2015-11-20 16:07:53 +0530572 case S2MPS15X:
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700573 case S2MPS14X:
Krzysztof Kozlowski5281f942015-04-16 12:45:45 -0700574 case S2MPS13X:
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800575 data[RTC_SEC] |= ALARM_ENABLE_MASK;
576 data[RTC_MIN] |= ALARM_ENABLE_MASK;
577 data[RTC_HOUR] |= ALARM_ENABLE_MASK;
578 data[RTC_WEEKDAY] &= ~ALARM_ENABLE_MASK;
579 if (data[RTC_DATE] & 0x1f)
580 data[RTC_DATE] |= ALARM_ENABLE_MASK;
581 if (data[RTC_MONTH] & 0xf)
582 data[RTC_MONTH] |= ALARM_ENABLE_MASK;
583 if (data[RTC_YEAR1] & 0x7f)
584 data[RTC_YEAR1] |= ALARM_ENABLE_MASK;
585
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700586 ret = regmap_raw_write(info->regmap, info->regs->alarm0, data,
587 info->regs->regs_count);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800588 if (ret < 0)
589 return ret;
590 ret = s5m8767_rtc_set_alarm_reg(info);
591
592 break;
593
594 default:
595 return -EINVAL;
596 }
597
598 return ret;
599}
600
601static int s5m_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
602{
603 struct s5m_rtc_info *info = dev_get_drvdata(dev);
Gustavo A. R. Silva756d5282018-03-10 00:27:35 -0600604 u8 data[RTC_MAX_NUM_TIME_REGS];
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800605 int ret;
606
607 switch (info->device_type) {
608 case S5M8763X:
609 s5m8763_tm_to_data(&alrm->time, data);
610 break;
611
612 case S5M8767X:
Alim Akhtara65e5ef2015-11-20 16:07:53 +0530613 case S2MPS15X:
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700614 case S2MPS14X:
Krzysztof Kozlowski5281f942015-04-16 12:45:45 -0700615 case S2MPS13X:
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800616 s5m8767_tm_to_data(&alrm->time, data);
617 break;
618
619 default:
620 return -EINVAL;
621 }
622
623 dev_dbg(dev, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__,
624 1900 + alrm->time.tm_year, 1 + alrm->time.tm_mon,
625 alrm->time.tm_mday, alrm->time.tm_hour, alrm->time.tm_min,
626 alrm->time.tm_sec, alrm->time.tm_wday);
627
628 ret = s5m_rtc_stop_alarm(info);
629 if (ret < 0)
630 return ret;
631
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700632 ret = regmap_raw_write(info->regmap, info->regs->alarm0, data,
633 info->regs->regs_count);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800634 if (ret < 0)
635 return ret;
636
637 ret = s5m8767_rtc_set_alarm_reg(info);
638 if (ret < 0)
639 return ret;
640
641 if (alrm->enabled)
642 ret = s5m_rtc_start_alarm(info);
643
644 return ret;
645}
646
647static int s5m_rtc_alarm_irq_enable(struct device *dev,
648 unsigned int enabled)
649{
650 struct s5m_rtc_info *info = dev_get_drvdata(dev);
651
652 if (enabled)
653 return s5m_rtc_start_alarm(info);
654 else
655 return s5m_rtc_stop_alarm(info);
656}
657
658static irqreturn_t s5m_rtc_alarm_irq(int irq, void *data)
659{
660 struct s5m_rtc_info *info = data;
661
662 rtc_update_irq(info->rtc_dev, 1, RTC_IRQF | RTC_AF);
663
664 return IRQ_HANDLED;
665}
666
667static const struct rtc_class_ops s5m_rtc_ops = {
668 .read_time = s5m_rtc_read_time,
669 .set_time = s5m_rtc_set_time,
670 .read_alarm = s5m_rtc_read_alarm,
671 .set_alarm = s5m_rtc_set_alarm,
672 .alarm_irq_enable = s5m_rtc_alarm_irq_enable,
673};
674
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800675static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info)
676{
677 u8 data[2];
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800678 int ret;
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800679
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700680 switch (info->device_type) {
681 case S5M8763X:
682 case S5M8767X:
683 /* UDR update time. Default of 7.32 ms is too long. */
684 ret = regmap_update_bits(info->regmap, S5M_RTC_UDR_CON,
685 S5M_RTC_UDR_T_MASK, S5M_RTC_UDR_T_450_US);
686 if (ret < 0)
687 dev_err(info->dev, "%s: fail to change UDR time: %d\n",
688 __func__, ret);
Krzysztof Kozlowski0c5f5d92014-06-10 15:18:43 -0700689
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700690 /* Set RTC control register : Binary mode, 24hour mode */
691 data[0] = (1 << BCD_EN_SHIFT) | (1 << MODEL24_SHIFT);
692 data[1] = (0 << BCD_EN_SHIFT) | (1 << MODEL24_SHIFT);
693
694 ret = regmap_raw_write(info->regmap, S5M_ALARM0_CONF, data, 2);
695 break;
696
Alim Akhtara65e5ef2015-11-20 16:07:53 +0530697 case S2MPS15X:
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700698 case S2MPS14X:
Krzysztof Kozlowski5281f942015-04-16 12:45:45 -0700699 case S2MPS13X:
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700700 data[0] = (0 << BCD_EN_SHIFT) | (1 << MODEL24_SHIFT);
701 ret = regmap_write(info->regmap, info->regs->ctrl, data[0]);
Joonyoung Shimff02c042015-08-21 18:43:41 +0900702 if (ret < 0)
703 break;
704
705 /*
706 * Should set WUDR & (RUDR or AUDR) bits to high after writing
707 * RTC_CTRL register like writing Alarm registers. We can't find
708 * the description from datasheet but vendor code does that
709 * really.
710 */
711 ret = s5m8767_rtc_set_alarm_reg(info);
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700712 break;
713
714 default:
715 return -EINVAL;
716 }
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800717
718 info->rtc_24hr_mode = 1;
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800719 if (ret < 0) {
720 dev_err(info->dev, "%s: fail to write controlm reg(%d)\n",
721 __func__, ret);
722 return ret;
723 }
724
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800725 return ret;
726}
727
728static int s5m_rtc_probe(struct platform_device *pdev)
729{
730 struct sec_pmic_dev *s5m87xx = dev_get_drvdata(pdev->dev.parent);
731 struct sec_platform_data *pdata = s5m87xx->pdata;
732 struct s5m_rtc_info *info;
Krzysztof Kozlowskie349c912014-04-14 09:40:45 +0200733 const struct regmap_config *regmap_cfg;
Krzysztof Kozlowskia0347f22014-06-10 15:18:47 -0700734 int ret, alarm_irq;
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800735
736 if (!pdata) {
737 dev_err(pdev->dev.parent, "Platform data not supplied\n");
738 return -ENODEV;
739 }
740
741 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
742 if (!info)
743 return -ENOMEM;
744
Krzysztof Kozlowski94f91922015-04-16 12:49:27 -0700745 switch (platform_get_device_id(pdev)->driver_data) {
Alim Akhtara65e5ef2015-11-20 16:07:53 +0530746 case S2MPS15X:
Krzysztof Kozlowski8ae83b62015-12-30 13:47:27 +0900747 regmap_cfg = &s2mps14_rtc_regmap_config;
748 info->regs = &s2mps15_rtc_regs;
749 alarm_irq = S2MPS14_IRQ_RTCA0;
750 break;
Krzysztof Kozlowskie349c912014-04-14 09:40:45 +0200751 case S2MPS14X:
Krzysztof Kozlowski8ae83b62015-12-30 13:47:27 +0900752 regmap_cfg = &s2mps14_rtc_regmap_config;
753 info->regs = &s2mps14_rtc_regs;
754 alarm_irq = S2MPS14_IRQ_RTCA0;
755 break;
Krzysztof Kozlowski5281f942015-04-16 12:45:45 -0700756 case S2MPS13X:
Krzysztof Kozlowskie349c912014-04-14 09:40:45 +0200757 regmap_cfg = &s2mps14_rtc_regmap_config;
Krzysztof Kozlowski8ae83b62015-12-30 13:47:27 +0900758 info->regs = &s2mps13_rtc_regs;
Krzysztof Kozlowskia0347f22014-06-10 15:18:47 -0700759 alarm_irq = S2MPS14_IRQ_RTCA0;
Krzysztof Kozlowskie349c912014-04-14 09:40:45 +0200760 break;
761 case S5M8763X:
762 regmap_cfg = &s5m_rtc_regmap_config;
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700763 info->regs = &s5m_rtc_regs;
Krzysztof Kozlowskia0347f22014-06-10 15:18:47 -0700764 alarm_irq = S5M8763_IRQ_ALARM0;
Krzysztof Kozlowskie349c912014-04-14 09:40:45 +0200765 break;
766 case S5M8767X:
767 regmap_cfg = &s5m_rtc_regmap_config;
Krzysztof Kozlowskif8b23bb2014-06-10 15:18:44 -0700768 info->regs = &s5m_rtc_regs;
Krzysztof Kozlowskia0347f22014-06-10 15:18:47 -0700769 alarm_irq = S5M8767_IRQ_RTCA1;
Krzysztof Kozlowskie349c912014-04-14 09:40:45 +0200770 break;
771 default:
Krzysztof Kozlowski94f91922015-04-16 12:49:27 -0700772 dev_err(&pdev->dev,
773 "Device type %lu is not supported by RTC driver\n",
774 platform_get_device_id(pdev)->driver_data);
Krzysztof Kozlowskie349c912014-04-14 09:40:45 +0200775 return -ENODEV;
776 }
777
778 info->i2c = i2c_new_dummy(s5m87xx->i2c->adapter, RTC_I2C_ADDR);
779 if (!info->i2c) {
780 dev_err(&pdev->dev, "Failed to allocate I2C for RTC\n");
781 return -ENODEV;
782 }
783
784 info->regmap = devm_regmap_init_i2c(info->i2c, regmap_cfg);
785 if (IS_ERR(info->regmap)) {
786 ret = PTR_ERR(info->regmap);
787 dev_err(&pdev->dev, "Failed to allocate RTC register map: %d\n",
788 ret);
789 goto err;
790 }
791
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800792 info->dev = &pdev->dev;
793 info->s5m87xx = s5m87xx;
Krzysztof Kozlowski94f91922015-04-16 12:49:27 -0700794 info->device_type = platform_get_device_id(pdev)->driver_data;
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800795
Bartlomiej Zolnierkiewiczb7d5b9a2014-08-29 15:18:53 -0700796 if (s5m87xx->irq_data) {
797 info->irq = regmap_irq_get_virq(s5m87xx->irq_data, alarm_irq);
798 if (info->irq <= 0) {
799 ret = -EINVAL;
800 dev_err(&pdev->dev, "Failed to get virtual IRQ %d\n",
Krzysztof Kozlowskia0347f22014-06-10 15:18:47 -0700801 alarm_irq);
Bartlomiej Zolnierkiewiczb7d5b9a2014-08-29 15:18:53 -0700802 goto err;
803 }
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800804 }
805
806 platform_set_drvdata(pdev, info);
807
808 ret = s5m8767_rtc_init_reg(info);
809
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800810 device_init_wakeup(&pdev->dev, 1);
811
812 info->rtc_dev = devm_rtc_device_register(&pdev->dev, "s5m-rtc",
813 &s5m_rtc_ops, THIS_MODULE);
814
Krzysztof Kozlowskie349c912014-04-14 09:40:45 +0200815 if (IS_ERR(info->rtc_dev)) {
816 ret = PTR_ERR(info->rtc_dev);
817 goto err;
818 }
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800819
Bartlomiej Zolnierkiewiczb7d5b9a2014-08-29 15:18:53 -0700820 if (!info->irq) {
821 dev_info(&pdev->dev, "Alarm IRQ not available\n");
822 return 0;
823 }
824
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800825 ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
826 s5m_rtc_alarm_irq, 0, "rtc-alarm0",
827 info);
Krzysztof Kozlowskie349c912014-04-14 09:40:45 +0200828 if (ret < 0) {
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800829 dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
830 info->irq, ret);
Krzysztof Kozlowskie349c912014-04-14 09:40:45 +0200831 goto err;
832 }
833
834 return 0;
835
836err:
837 i2c_unregister_device(info->i2c);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800838
839 return ret;
840}
841
Krzysztof Kozlowskie349c912014-04-14 09:40:45 +0200842static int s5m_rtc_remove(struct platform_device *pdev)
843{
844 struct s5m_rtc_info *info = platform_get_drvdata(pdev);
845
Krzysztof Kozlowskie349c912014-04-14 09:40:45 +0200846 i2c_unregister_device(info->i2c);
847
848 return 0;
849}
850
Geert Uytterhoeven11ba5a12014-01-23 15:55:19 -0800851#ifdef CONFIG_PM_SLEEP
Krzysztof Kozlowski222ead72013-12-12 17:12:30 -0800852static int s5m_rtc_resume(struct device *dev)
853{
854 struct s5m_rtc_info *info = dev_get_drvdata(dev);
855 int ret = 0;
856
Bartlomiej Zolnierkiewiczb7d5b9a2014-08-29 15:18:53 -0700857 if (info->irq && device_may_wakeup(dev))
Krzysztof Kozlowski222ead72013-12-12 17:12:30 -0800858 ret = disable_irq_wake(info->irq);
859
860 return ret;
861}
862
863static int s5m_rtc_suspend(struct device *dev)
864{
865 struct s5m_rtc_info *info = dev_get_drvdata(dev);
866 int ret = 0;
867
Bartlomiej Zolnierkiewiczb7d5b9a2014-08-29 15:18:53 -0700868 if (info->irq && device_may_wakeup(dev))
Krzysztof Kozlowski222ead72013-12-12 17:12:30 -0800869 ret = enable_irq_wake(info->irq);
870
871 return ret;
872}
Geert Uytterhoeven11ba5a12014-01-23 15:55:19 -0800873#endif /* CONFIG_PM_SLEEP */
Krzysztof Kozlowski222ead72013-12-12 17:12:30 -0800874
875static SIMPLE_DEV_PM_OPS(s5m_rtc_pm_ops, s5m_rtc_suspend, s5m_rtc_resume);
876
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800877static const struct platform_device_id s5m_rtc_id[] = {
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700878 { "s5m-rtc", S5M8767X },
Krzysztof Kozlowski5281f942015-04-16 12:45:45 -0700879 { "s2mps13-rtc", S2MPS13X },
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700880 { "s2mps14-rtc", S2MPS14X },
Alim Akhtara65e5ef2015-11-20 16:07:53 +0530881 { "s2mps15-rtc", S2MPS15X },
Andrey Ryabinin45cd15e2015-01-26 12:58:46 -0800882 { },
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800883};
Javier Martinez Canillas63074cc2015-08-27 12:34:32 +0200884MODULE_DEVICE_TABLE(platform, s5m_rtc_id);
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800885
886static struct platform_driver s5m_rtc_driver = {
887 .driver = {
888 .name = "s5m-rtc",
Krzysztof Kozlowski222ead72013-12-12 17:12:30 -0800889 .pm = &s5m_rtc_pm_ops,
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800890 },
891 .probe = s5m_rtc_probe,
Krzysztof Kozlowskie349c912014-04-14 09:40:45 +0200892 .remove = s5m_rtc_remove,
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800893 .id_table = s5m_rtc_id,
894};
895
896module_platform_driver(s5m_rtc_driver);
897
898/* Module information */
899MODULE_AUTHOR("Sangbeom Kim <sbkim73@samsung.com>");
Krzysztof Kozlowski0c5deb12014-06-10 15:18:46 -0700900MODULE_DESCRIPTION("Samsung S5M/S2MPS14 RTC driver");
Sangbeom Kim5bccae62013-11-12 15:11:04 -0800901MODULE_LICENSE("GPL");
902MODULE_ALIAS("platform:s5m-rtc");