Skip to content

Commit c38dec7

Browse files
committed
Merge tag 'rtc-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull RTC updates from Alexandre Belloni: "Core: - fix module reference count in rtc-proc - Replace simple_strtoul by kstrtoul New driver: - Epson RX8010SJ Subsystem wide cleanups: - use %ph for short hex dumps - constify *_chip_ops structures Drivers: - abx80x: Microcrystal rv1805 support, alarm support - cmos: prevent kernel warning on IRQ flags mismatch - s5m: various cleanups - rv8803: rx8900 compatibility, small error path fix - sunxi: various cleanups - lpc32xx: remove irq > NR_IRQS check from probe() - imxdi: fix spelling mistake in warning message - ds1685: don't try to micromanage sysfs output size - da9063: avoid writing undefined data to rtc - gemini: Remove unnecessary platform_set_drvdata() - efi: add efi_procfs in efi_rtc_ops - pcf8523: refuse to write dates later than 2099" * tag 'rtc-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (24 commits) rtc: cmos: prevent kernel warning on IRQ flags mismatch rtc: rtc-ds2404: constify ds2404_chip_ops structures rtc: s5m: Make register configuration per S2MPS device to remove exceptions rtc: s5m: Add separate field for storing auto-cleared mask in register config rtc: s5m: Cleanup by removing useless 'rtc' prefix from fields rtc: Replace simple_strtoul by kstrtoul rtc: abx80x: add alarm support rtc: abx80x: Add Microcrystal rv1805 support rtc: v3020: constify v3020_chip_ops structures rtc: rv8803: Extend compatibility with the rx8900 rtc: rv8803: fix handling return value of i2c_smbus_read_byte_data rtc: Add Epson RX8010SJ RTC driver rtc: lpc32xx: remove irq > NR_IRQS check from probe() rtc: imxdi: fix spelling mistake in warning message rtc: ds1685: don't try to micromanage sysfs output size rtc: use %ph for short hex dumps rtc: da9063: avoid writing undefined data to rtc rtc: sunxi: use of_device_get_match_data rtc: sunxi: constify the data_year_param structure rtc: sunxi: fix signedness issues ...
2 parents d43fb9f + 079062b commit c38dec7

22 files changed

+894
-130
lines changed

drivers/rtc/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,16 @@ config RTC_DRV_FM3130
558558
This driver can also be built as a module. If so the module
559559
will be called rtc-fm3130.
560560

561+
config RTC_DRV_RX8010
562+
tristate "Epson RX8010SJ"
563+
depends on I2C
564+
help
565+
If you say yes here you get support for the Epson RX8010SJ RTC
566+
chip.
567+
568+
This driver can also be built as a module. If so, the module
569+
will be called rtc-rx8010.
570+
561571
config RTC_DRV_RX8581
562572
tristate "Epson RX-8581"
563573
help

drivers/rtc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o
128128
obj-$(CONFIG_RTC_DRV_RV3029C2) += rtc-rv3029c2.o
129129
obj-$(CONFIG_RTC_DRV_RV8803) += rtc-rv8803.o
130130
obj-$(CONFIG_RTC_DRV_RX4581) += rtc-rx4581.o
131+
obj-$(CONFIG_RTC_DRV_RX8010) += rtc-rx8010.o
131132
obj-$(CONFIG_RTC_DRV_RX8025) += rtc-rx8025.o
132133
obj-$(CONFIG_RTC_DRV_RX8581) += rtc-rx8581.o
133134
obj-$(CONFIG_RTC_DRV_S35390A) += rtc-s35390a.o

drivers/rtc/rtc-abx80x.c

Lines changed: 142 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,28 @@
2727
#define ABX8XX_REG_YR 0x06
2828
#define ABX8XX_REG_WD 0x07
2929

30+
#define ABX8XX_REG_AHTH 0x08
31+
#define ABX8XX_REG_ASC 0x09
32+
#define ABX8XX_REG_AMN 0x0a
33+
#define ABX8XX_REG_AHR 0x0b
34+
#define ABX8XX_REG_ADA 0x0c
35+
#define ABX8XX_REG_AMO 0x0d
36+
#define ABX8XX_REG_AWD 0x0e
37+
38+
#define ABX8XX_REG_STATUS 0x0f
39+
#define ABX8XX_STATUS_AF BIT(2)
40+
3041
#define ABX8XX_REG_CTRL1 0x10
3142
#define ABX8XX_CTRL_WRITE BIT(0)
43+
#define ABX8XX_CTRL_ARST BIT(2)
3244
#define ABX8XX_CTRL_12_24 BIT(6)
3345

46+
#define ABX8XX_REG_IRQ 0x12
47+
#define ABX8XX_IRQ_AIE BIT(2)
48+
#define ABX8XX_IRQ_IM_1_4 (0x3 << 5)
49+
50+
#define ABX8XX_REG_CD_TIMER_CTL 0x18
51+
3452
#define ABX8XX_REG_CFG_KEY 0x1f
3553
#define ABX8XX_CFG_KEY_MISC 0x9d
3654

@@ -63,8 +81,6 @@ static struct abx80x_cap abx80x_caps[] = {
6381
[ABX80X] = {.pn = 0}
6482
};
6583

66-
static struct i2c_driver abx80x_driver;
67-
6884
static int abx80x_enable_trickle_charger(struct i2c_client *client,
6985
u8 trickle_cfg)
7086
{
@@ -148,9 +164,111 @@ static int abx80x_rtc_set_time(struct device *dev, struct rtc_time *tm)
148164
return 0;
149165
}
150166

167+
static irqreturn_t abx80x_handle_irq(int irq, void *dev_id)
168+
{
169+
struct i2c_client *client = dev_id;
170+
struct rtc_device *rtc = i2c_get_clientdata(client);
171+
int status;
172+
173+
status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS);
174+
if (status < 0)
175+
return IRQ_NONE;
176+
177+
if (status & ABX8XX_STATUS_AF)
178+
rtc_update_irq(rtc, 1, RTC_AF | RTC_IRQF);
179+
180+
i2c_smbus_write_byte_data(client, ABX8XX_REG_STATUS, 0);
181+
182+
return IRQ_HANDLED;
183+
}
184+
185+
static int abx80x_read_alarm(struct device *dev, struct rtc_wkalrm *t)
186+
{
187+
struct i2c_client *client = to_i2c_client(dev);
188+
unsigned char buf[7];
189+
190+
int irq_mask, err;
191+
192+
if (client->irq <= 0)
193+
return -EINVAL;
194+
195+
err = i2c_smbus_read_i2c_block_data(client, ABX8XX_REG_ASC,
196+
sizeof(buf), buf);
197+
if (err)
198+
return err;
199+
200+
irq_mask = i2c_smbus_read_byte_data(client, ABX8XX_REG_IRQ);
201+
if (irq_mask < 0)
202+
return irq_mask;
203+
204+
t->time.tm_sec = bcd2bin(buf[0] & 0x7F);
205+
t->time.tm_min = bcd2bin(buf[1] & 0x7F);
206+
t->time.tm_hour = bcd2bin(buf[2] & 0x3F);
207+
t->time.tm_mday = bcd2bin(buf[3] & 0x3F);
208+
t->time.tm_mon = bcd2bin(buf[4] & 0x1F) - 1;
209+
t->time.tm_wday = buf[5] & 0x7;
210+
211+
t->enabled = !!(irq_mask & ABX8XX_IRQ_AIE);
212+
t->pending = (buf[6] & ABX8XX_STATUS_AF) && t->enabled;
213+
214+
return err;
215+
}
216+
217+
static int abx80x_set_alarm(struct device *dev, struct rtc_wkalrm *t)
218+
{
219+
struct i2c_client *client = to_i2c_client(dev);
220+
u8 alarm[6];
221+
int err;
222+
223+
if (client->irq <= 0)
224+
return -EINVAL;
225+
226+
alarm[0] = 0x0;
227+
alarm[1] = bin2bcd(t->time.tm_sec);
228+
alarm[2] = bin2bcd(t->time.tm_min);
229+
alarm[3] = bin2bcd(t->time.tm_hour);
230+
alarm[4] = bin2bcd(t->time.tm_mday);
231+
alarm[5] = bin2bcd(t->time.tm_mon + 1);
232+
233+
err = i2c_smbus_write_i2c_block_data(client, ABX8XX_REG_AHTH,
234+
sizeof(alarm), alarm);
235+
if (err < 0) {
236+
dev_err(&client->dev, "Unable to write alarm registers\n");
237+
return -EIO;
238+
}
239+
240+
if (t->enabled) {
241+
err = i2c_smbus_write_byte_data(client, ABX8XX_REG_IRQ,
242+
(ABX8XX_IRQ_IM_1_4 |
243+
ABX8XX_IRQ_AIE));
244+
if (err)
245+
return err;
246+
}
247+
248+
return 0;
249+
}
250+
251+
static int abx80x_alarm_irq_enable(struct device *dev, unsigned int enabled)
252+
{
253+
struct i2c_client *client = to_i2c_client(dev);
254+
int err;
255+
256+
if (enabled)
257+
err = i2c_smbus_write_byte_data(client, ABX8XX_REG_IRQ,
258+
(ABX8XX_IRQ_IM_1_4 |
259+
ABX8XX_IRQ_AIE));
260+
else
261+
err = i2c_smbus_write_byte_data(client, ABX8XX_REG_IRQ,
262+
ABX8XX_IRQ_IM_1_4);
263+
return err;
264+
}
265+
151266
static const struct rtc_class_ops abx80x_rtc_ops = {
152267
.read_time = abx80x_rtc_read_time,
153268
.set_time = abx80x_rtc_set_time,
269+
.read_alarm = abx80x_read_alarm,
270+
.set_alarm = abx80x_set_alarm,
271+
.alarm_irq_enable = abx80x_alarm_irq_enable,
154272
};
155273

156274
static int abx80x_dt_trickle_cfg(struct device_node *np)
@@ -225,7 +343,8 @@ static int abx80x_probe(struct i2c_client *client,
225343
}
226344

227345
err = i2c_smbus_write_byte_data(client, ABX8XX_REG_CTRL1,
228-
((data & ~ABX8XX_CTRL_12_24) |
346+
((data & ~(ABX8XX_CTRL_12_24 |
347+
ABX8XX_CTRL_ARST)) |
229348
ABX8XX_CTRL_WRITE));
230349
if (err < 0) {
231350
dev_err(&client->dev, "Unable to write control register\n");
@@ -260,14 +379,32 @@ static int abx80x_probe(struct i2c_client *client,
260379
abx80x_enable_trickle_charger(client, trickle_cfg);
261380
}
262381

263-
rtc = devm_rtc_device_register(&client->dev, abx80x_driver.driver.name,
382+
err = i2c_smbus_write_byte_data(client, ABX8XX_REG_CD_TIMER_CTL,
383+
BIT(2));
384+
if (err)
385+
return err;
386+
387+
rtc = devm_rtc_device_register(&client->dev, "abx8xx",
264388
&abx80x_rtc_ops, THIS_MODULE);
265389

266390
if (IS_ERR(rtc))
267391
return PTR_ERR(rtc);
268392

269393
i2c_set_clientdata(client, rtc);
270394

395+
if (client->irq > 0) {
396+
dev_info(&client->dev, "IRQ %d supplied\n", client->irq);
397+
err = devm_request_threaded_irq(&client->dev, client->irq, NULL,
398+
abx80x_handle_irq,
399+
IRQF_SHARED | IRQF_ONESHOT,
400+
"abx8xx",
401+
client);
402+
if (err) {
403+
dev_err(&client->dev, "unable to request IRQ, alarms disabled\n");
404+
client->irq = 0;
405+
}
406+
}
407+
271408
return 0;
272409
}
273410

@@ -286,6 +423,7 @@ static const struct i2c_device_id abx80x_id[] = {
286423
{ "ab1803", AB1803 },
287424
{ "ab1804", AB1804 },
288425
{ "ab1805", AB1805 },
426+
{ "rv1805", AB1805 },
289427
{ }
290428
};
291429
MODULE_DEVICE_TABLE(i2c, abx80x_id);

drivers/rtc/rtc-cmos.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
725725
rtc_cmos_int_handler = cmos_interrupt;
726726

727727
retval = request_irq(rtc_irq, rtc_cmos_int_handler,
728-
0, dev_name(&cmos_rtc.rtc->dev),
728+
IRQF_SHARED, dev_name(&cmos_rtc.rtc->dev),
729729
cmos_rtc.rtc);
730730
if (retval < 0) {
731731
dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);

drivers/rtc/rtc-da9063.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -191,24 +191,13 @@ static void da9063_tm_to_data(struct rtc_time *tm, u8 *data,
191191
{
192192
const struct da9063_compatible_rtc_regmap *config = rtc->config;
193193

194-
data[RTC_SEC] &= ~config->rtc_count_sec_mask;
195-
data[RTC_SEC] |= tm->tm_sec & config->rtc_count_sec_mask;
196-
197-
data[RTC_MIN] &= ~config->rtc_count_min_mask;
198-
data[RTC_MIN] |= tm->tm_min & config->rtc_count_min_mask;
199-
200-
data[RTC_HOUR] &= ~config->rtc_count_hour_mask;
201-
data[RTC_HOUR] |= tm->tm_hour & config->rtc_count_hour_mask;
202-
203-
data[RTC_DAY] &= ~config->rtc_count_day_mask;
204-
data[RTC_DAY] |= tm->tm_mday & config->rtc_count_day_mask;
205-
206-
data[RTC_MONTH] &= ~config->rtc_count_month_mask;
207-
data[RTC_MONTH] |= MONTHS_TO_DA9063(tm->tm_mon) &
194+
data[RTC_SEC] = tm->tm_sec & config->rtc_count_sec_mask;
195+
data[RTC_MIN] = tm->tm_min & config->rtc_count_min_mask;
196+
data[RTC_HOUR] = tm->tm_hour & config->rtc_count_hour_mask;
197+
data[RTC_DAY] = tm->tm_mday & config->rtc_count_day_mask;
198+
data[RTC_MONTH] = MONTHS_TO_DA9063(tm->tm_mon) &
208199
config->rtc_count_month_mask;
209-
210-
data[RTC_YEAR] &= ~config->rtc_count_year_mask;
211-
data[RTC_YEAR] |= YEARS_TO_DA9063(tm->tm_year) &
200+
data[RTC_YEAR] = YEARS_TO_DA9063(tm->tm_year) &
212201
config->rtc_count_year_mask;
213202
}
214203

drivers/rtc/rtc-ds1305.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ static int ds1305_get_time(struct device *dev, struct rtc_time *time)
186186
if (status < 0)
187187
return status;
188188

189-
dev_vdbg(dev, "%s: %02x %02x %02x, %02x %02x %02x %02x\n",
190-
"read", buf[0], buf[1], buf[2], buf[3],
191-
buf[4], buf[5], buf[6]);
189+
dev_vdbg(dev, "%s: %3ph, %4ph\n", "read", &buf[0], &buf[3]);
192190

193191
/* Decode the registers */
194192
time->tm_sec = bcd2bin(buf[DS1305_SEC]);
@@ -232,9 +230,7 @@ static int ds1305_set_time(struct device *dev, struct rtc_time *time)
232230
*bp++ = bin2bcd(time->tm_mon + 1);
233231
*bp++ = bin2bcd(time->tm_year - 100);
234232

235-
dev_dbg(dev, "%s: %02x %02x %02x, %02x %02x %02x %02x\n",
236-
"write", buf[1], buf[2], buf[3],
237-
buf[4], buf[5], buf[6], buf[7]);
233+
dev_dbg(dev, "%s: %3ph, %4ph\n", "write", &buf[1], &buf[4]);
238234

239235
/* use write-then-read since dma from stack is nonportable */
240236
return spi_write_then_read(ds1305->spi, buf, sizeof(buf),

drivers/rtc/rtc-ds1307.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -460,13 +460,8 @@ static int ds1337_read_alarm(struct device *dev, struct rtc_wkalrm *t)
460460
return -EIO;
461461
}
462462

463-
dev_dbg(dev, "%s: %02x %02x %02x %02x, %02x %02x %02x, %02x %02x\n",
464-
"alarm read",
465-
ds1307->regs[0], ds1307->regs[1],
466-
ds1307->regs[2], ds1307->regs[3],
467-
ds1307->regs[4], ds1307->regs[5],
468-
ds1307->regs[6], ds1307->regs[7],
469-
ds1307->regs[8]);
463+
dev_dbg(dev, "%s: %4ph, %3ph, %2ph\n", "alarm read",
464+
&ds1307->regs[0], &ds1307->regs[4], &ds1307->regs[7]);
470465

471466
/*
472467
* report alarm time (ALARM1); assume 24 hour and day-of-month modes,
@@ -522,12 +517,8 @@ static int ds1337_set_alarm(struct device *dev, struct rtc_wkalrm *t)
522517
control = ds1307->regs[7];
523518
status = ds1307->regs[8];
524519

525-
dev_dbg(dev, "%s: %02x %02x %02x %02x, %02x %02x %02x, %02x %02x\n",
526-
"alarm set (old status)",
527-
ds1307->regs[0], ds1307->regs[1],
528-
ds1307->regs[2], ds1307->regs[3],
529-
ds1307->regs[4], ds1307->regs[5],
530-
ds1307->regs[6], control, status);
520+
dev_dbg(dev, "%s: %4ph, %3ph, %02x %02x\n", "alarm set (old status)",
521+
&ds1307->regs[0], &ds1307->regs[4], control, status);
531522

532523
/* set ALARM1, using 24 hour and day-of-month modes */
533524
buf[0] = bin2bcd(t->time.tm_sec);

0 commit comments

Comments
 (0)