Commit 0759c886 authored by Nikita Yushchenko's avatar Nikita Yushchenko Committed by Alexandre Belloni

rtc: ds1307: add basic support for ds1341 chip

This adds support for reading and writing date/time from/to ds1341 chip.

ds1341 chip has other features - alarms, input clock (can be used instead
of intercal oscillator for better accuracy), output clock ("square wave
generation"). However, not all of that is available at the same time.
Same chip pins, CLKIN/nINTA and SQW/nINTB, can be used either for
input/output clocks, or for alarm interrupts. Role of these pins on
particular board depends on hardware wiring.

We can add device tree properties that describe if each of pins is wired
as clock, or as interrupt, or left unconnected, and enable support for
corresponding functionality based on that. But that is cumbersome, requires
hardware for testing, and has to deal with bit enabling/disabling output
clock also affects which pins alarm interrupts are routed to.

Another factor is that there are hardware setups (i.e. ZII RDU2) that
power DS1341 from SuperCap, which makes power saving critical. For such
setups, kernel driver should leave register bits that control mentioned
pins in the state configured by bootloader.

Given all that, it was decided to limit support to "only date/time" for
now. That is enough for common use case. Full (and cumbersome)
implementation can be added later if ever needed.
Signed-off-by: default avatarNikita Yushchenko <nikita.yoush@cogentembedded.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Tested-by: default avatarAleksander Morgado <aleksander@aleksander.es>
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
parent 969fa07b
...@@ -227,14 +227,14 @@ config RTC_DRV_AS3722 ...@@ -227,14 +227,14 @@ config RTC_DRV_AS3722
will be called rtc-as3722. will be called rtc-as3722.
config RTC_DRV_DS1307 config RTC_DRV_DS1307
tristate "Dallas/Maxim DS1307/37/38/39/40, ST M41T00, EPSON RX-8025, ISL12057" tristate "Dallas/Maxim DS1307/37/38/39/40/41, ST M41T00, EPSON RX-8025, ISL12057"
help help
If you say yes here you get support for various compatible RTC If you say yes here you get support for various compatible RTC
chips (often with battery backup) connected with I2C. This driver chips (often with battery backup) connected with I2C. This driver
should handle DS1307, DS1337, DS1338, DS1339, DS1340, ST M41T00, should handle DS1307, DS1337, DS1338, DS1339, DS1340, DS1341,
EPSON RX-8025, Intersil ISL12057 and probably other chips. In some ST M41T00, EPSON RX-8025, Intersil ISL12057 and probably other chips.
cases the RTC must already have been initialized (by manufacturing or In some cases the RTC must already have been initialized (by
a bootloader). manufacturing or a bootloader).
The first seven registers on these chips hold an RTC, and other The first seven registers on these chips hold an RTC, and other
registers may add features such as NVRAM, a trickle charger for registers may add features such as NVRAM, a trickle charger for
......
...@@ -39,6 +39,7 @@ enum ds_type { ...@@ -39,6 +39,7 @@ enum ds_type {
ds_1338, ds_1338,
ds_1339, ds_1339,
ds_1340, ds_1340,
ds_1341,
ds_1388, ds_1388,
ds_3231, ds_3231,
m41t0, m41t0,
...@@ -206,6 +207,10 @@ static const struct chip_desc chips[last_ds_type] = { ...@@ -206,6 +207,10 @@ static const struct chip_desc chips[last_ds_type] = {
.century_bit = DS1340_BIT_CENTURY, .century_bit = DS1340_BIT_CENTURY,
.trickle_charger_reg = 0x08, .trickle_charger_reg = 0x08,
}, },
[ds_1341] = {
.century_reg = DS1307_REG_MONTH,
.century_bit = DS1337_BIT_CENTURY,
},
[ds_1388] = { [ds_1388] = {
.offset = 1, .offset = 1,
.trickle_charger_reg = 0x0a, .trickle_charger_reg = 0x0a,
...@@ -243,6 +248,7 @@ static const struct i2c_device_id ds1307_id[] = { ...@@ -243,6 +248,7 @@ static const struct i2c_device_id ds1307_id[] = {
{ "ds1339", ds_1339 }, { "ds1339", ds_1339 },
{ "ds1388", ds_1388 }, { "ds1388", ds_1388 },
{ "ds1340", ds_1340 }, { "ds1340", ds_1340 },
{ "ds1341", ds_1341 },
{ "ds3231", ds_3231 }, { "ds3231", ds_3231 },
{ "m41t0", m41t0 }, { "m41t0", m41t0 },
{ "m41t00", m41t00 }, { "m41t00", m41t00 },
...@@ -286,6 +292,10 @@ static const struct of_device_id ds1307_of_match[] = { ...@@ -286,6 +292,10 @@ static const struct of_device_id ds1307_of_match[] = {
.compatible = "dallas,ds1340", .compatible = "dallas,ds1340",
.data = (void *)ds_1340 .data = (void *)ds_1340
}, },
{
.compatible = "dallas,ds1341",
.data = (void *)ds_1341
},
{ {
.compatible = "maxim,ds3231", .compatible = "maxim,ds3231",
.data = (void *)ds_3231 .data = (void *)ds_3231
...@@ -332,6 +342,7 @@ static const struct acpi_device_id ds1307_acpi_ids[] = { ...@@ -332,6 +342,7 @@ static const struct acpi_device_id ds1307_acpi_ids[] = {
{ .id = "DS1339", .driver_data = ds_1339 }, { .id = "DS1339", .driver_data = ds_1339 },
{ .id = "DS1388", .driver_data = ds_1388 }, { .id = "DS1388", .driver_data = ds_1388 },
{ .id = "DS1340", .driver_data = ds_1340 }, { .id = "DS1340", .driver_data = ds_1340 },
{ .id = "DS1341", .driver_data = ds_1341 },
{ .id = "DS3231", .driver_data = ds_3231 }, { .id = "DS3231", .driver_data = ds_3231 },
{ .id = "M41T0", .driver_data = m41t0 }, { .id = "M41T0", .driver_data = m41t0 },
{ .id = "M41T00", .driver_data = m41t00 }, { .id = "M41T00", .driver_data = m41t00 },
...@@ -1408,6 +1419,7 @@ static int ds1307_probe(struct i2c_client *client, ...@@ -1408,6 +1419,7 @@ static int ds1307_probe(struct i2c_client *client,
switch (ds1307->type) { switch (ds1307->type) {
case ds_1337: case ds_1337:
case ds_1339: case ds_1339:
case ds_1341:
case ds_3231: case ds_3231:
/* get registers that the "rtc" read below won't read... */ /* get registers that the "rtc" read below won't read... */
err = regmap_bulk_read(ds1307->regmap, DS1337_REG_CONTROL, err = regmap_bulk_read(ds1307->regmap, DS1337_REG_CONTROL,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment