* [PATCH 1/2] dt-bindings: rtc: ds1307: Add support for Epson RX8111 @ 2022-10-28 14:40 glasveze 2022-10-28 14:40 ` [PATCH 2/2] " glasveze 2022-10-28 17:38 ` [PATCH 1/2] dt-bindings: " Krzysztof Kozlowski 0 siblings, 2 replies; 7+ messages in thread From: glasveze @ 2022-10-28 14:40 UTC (permalink / raw) To: linux-rtc, devicetree Cc: a.zummo, alexandre.belloni, robh+dt, linux-kernel, Mike Looijmans From: Mike Looijmans <mike.looijmans@topic.nl> The rx_8111 is quite similar to the rx_8030. This adds support for this chip to the ds1307 driver. This adds the entry to the devicetree bindings. Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> --- Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml b/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml index 98d10e680144..a9590da64b84 100644 --- a/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml +++ b/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml @@ -30,6 +30,7 @@ properties: - pericom,pt7c4338 - epson,rx8025 - isil,isl12057 + - epson,rx8111 - epson,rx8130 - items: -- 2.17.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] rtc: ds1307: Add support for Epson RX8111 2022-10-28 14:40 [PATCH 1/2] dt-bindings: rtc: ds1307: Add support for Epson RX8111 glasveze @ 2022-10-28 14:40 ` glasveze 2022-11-14 22:17 ` Alexandre Belloni 2022-10-28 17:38 ` [PATCH 1/2] dt-bindings: " Krzysztof Kozlowski 1 sibling, 1 reply; 7+ messages in thread From: glasveze @ 2022-10-28 14:40 UTC (permalink / raw) To: linux-rtc, devicetree Cc: a.zummo, alexandre.belloni, robh+dt, linux-kernel, Mike Looijmans From: Mike Looijmans <mike.looijmans@topic.nl> The rx_8111 is quite similar to the rx_8030. This adds support for this chip to the ds1307 driver. Date/time and alarm registers are in the usual places. The nvmem is located at 0x40. Time stamping is not supported. Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> --- drivers/rtc/rtc-ds1307.c | 129 ++++++++++++++++++++++++++++++++------- 1 file changed, 107 insertions(+), 22 deletions(-) diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index d51565bcc189..f5f0f0d02fe0 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c @@ -46,6 +46,7 @@ enum ds_type { m41t11, mcp794xx, rx_8025, + rx_8111, rx_8130, last_ds_type /* always last */ /* rs5c372 too? different address... */ @@ -113,6 +114,14 @@ enum ds_type { # define RX8025_BIT_VDET 0x40 # define RX8025_BIT_XST 0x20 +#define RX8111_FLAG 0x1e +# define RX8111_FLAG_VLF BIT(1) +# define RX8111_FLAG_AF BIT(3) +#define RX8111_PWR_SWITCH_CTRL 0x32 +# define RX8111_PSC_SMP_INIEN BIT(6) +# define RX8111_PSC_SMP_CHGEN BIT(7) +#define RX8111_TIME_STAMP_BUF_CTRL 0x34 + #define RX8130_REG_ALARM_MIN 0x17 #define RX8130_REG_ALARM_HOUR 0x18 #define RX8130_REG_ALARM_WEEK_OR_DAY 0x19 @@ -205,6 +214,68 @@ struct chip_desc { static const struct chip_desc chips[last_ds_type]; +static int ds1307_check_voltage_lost(struct ds1307 *ds1307) +{ + int ret; + unsigned int reg; + unsigned int mask; + unsigned int regflag; + + switch (ds1307->type) { + case rx_8111: + reg = RX8111_FLAG; + mask = RX8111_FLAG_VLF; + break; + case rx_8130: + reg = RX8130_REG_FLAG; + mask = RX8130_REG_FLAG_VLF; + break; + default: + return 0; + } + + ret = regmap_read(ds1307->regmap, reg, ®flag); + if (ret) { + dev_err(ds1307->dev, "%s error %d\n", "read", ret); + return ret; + } + + if (regflag & mask) { + dev_warn_once(ds1307->dev, "oscillator failed, set time!\n"); + return -EINVAL; + } + + return 0; +} + +static int ds1307_clear_voltage_lost(struct ds1307 *ds1307) +{ + int ret; + unsigned int reg; + unsigned int mask; + + switch (ds1307->type) { + case rx_8111: + reg = RX8111_FLAG; + mask = (unsigned int)~RX8111_FLAG_VLF; + break; + case rx_8130: + reg = RX8130_REG_FLAG; + mask = (unsigned int)~RX8130_REG_FLAG_VLF; + break; + default: + return 0; + } + + ret = regmap_write(ds1307->regmap, reg, mask); + if (ret) { + dev_err(ds1307->dev, "%s error %d\n", "write", ret); + return ret; + } + + return 0; +} + static int ds1307_get_time(struct device *dev, struct rtc_time *t) { struct ds1307 *ds1307 = dev_get_drvdata(dev); @@ -212,19 +283,9 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t) const struct chip_desc *chip = &chips[ds1307->type]; u8 regs[7]; - if (ds1307->type == rx_8130) { - unsigned int regflag; - ret = regmap_read(ds1307->regmap, RX8130_REG_FLAG, ®flag); - if (ret) { - dev_err(dev, "%s error %d\n", "read", ret); - return ret; - } - - if (regflag & RX8130_REG_FLAG_VLF) { - dev_warn_once(dev, "oscillator failed, set time!\n"); - return -EINVAL; - } - } + ret = ds1307_check_voltage_lost(ds1307); + if (ret) + return ret; /* read the RTC date and time registers all at once */ ret = regmap_bulk_read(ds1307->regmap, chip->offset, regs, @@ -397,15 +458,9 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t) return result; } - if (ds1307->type == rx_8130) { - /* clear Voltage Loss Flag as data is available now */ - result = regmap_write(ds1307->regmap, RX8130_REG_FLAG, - ~(u8)RX8130_REG_FLAG_VLF); - if (result) { - dev_err(dev, "%s error %d\n", "write", result); - return result; - } - } + result = ds1307_clear_voltage_lost(ds1307); + if (result) + return result; return 0; } @@ -541,6 +596,17 @@ static u8 do_trickle_setup_ds1339(struct ds1307 *ds1307, u32 ohms, bool diode) return setup; } +static u8 do_trickle_setup_rx8111(struct ds1307 *ds1307, u32 ohms, bool diode) +{ + /* make sure that the backup battery is enabled */ + u8 setup = RX8111_PSC_SMP_INIEN; + + if (diode) + setup |= RX8111_PSC_SMP_CHGEN; + + return setup; +} + static u8 do_trickle_setup_rx8130(struct ds1307 *ds1307, u32 ohms, bool diode) { /* make sure that the backup battery is enabled */ @@ -1012,6 +1078,16 @@ static const struct chip_desc chips[last_ds_type] = { .century_bit = DS1337_BIT_CENTURY, .bbsqi_bit = DS3231_BIT_BBSQW, }, + [rx_8111] = { + .alarm = 1, + .nvram_offset = 0x40, + .nvram_size = 0x40, /* 0x40 .. 0x7F is user RAM */ + .offset = 0x10, + .irq_handler = rx8130_irq, + .rtc_ops = &rx8130_rtc_ops, + .trickle_charger_reg = RX8111_PWR_SWITCH_CTRL, + .do_trickle_setup = &do_trickle_setup_rx8111, + }, [rx_8130] = { .alarm = 1, /* this is battery backed SRAM */ @@ -1063,6 +1139,7 @@ static const struct i2c_device_id ds1307_id[] = { { "pt7c4338", ds_1307 }, { "rx8025", rx_8025 }, { "isl12057", ds_1337 }, + { "rx8111", rx_8111 }, { "rx8130", rx_8130 }, { } }; @@ -1137,6 +1214,10 @@ static const struct of_device_id ds1307_of_match[] = { .compatible = "isil,isl12057", .data = (void *)ds_1337 }, + { + .compatible = "epson,rx8111", + .data = (void *)rx_8111 + }, { .compatible = "epson,rx8130", .data = (void *)rx_8130 @@ -1880,6 +1961,10 @@ static int ds1307_probe(struct i2c_client *client, DS1307_REG_HOUR << 4 | 0x08, hour); } break; + case rx_8111: + /* Use memory as user RAM */ + regmap_write(ds1307->regmap, RX8111_TIME_STAMP_BUF_CTRL, 0); + break; case ds_1388: err = regmap_read(ds1307->regmap, DS1388_REG_CONTROL, &tmp); if (err) { -- 2.17.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] rtc: ds1307: Add support for Epson RX8111 2022-10-28 14:40 ` [PATCH 2/2] " glasveze @ 2022-11-14 22:17 ` Alexandre Belloni 0 siblings, 0 replies; 7+ messages in thread From: Alexandre Belloni @ 2022-11-14 22:17 UTC (permalink / raw) To: glasveze Cc: linux-rtc, devicetree, a.zummo, robh+dt, linux-kernel, Mike Looijmans Hello, On 28/10/2022 16:40:41+0200, glasveze@delta.nl wrote: > +static u8 do_trickle_setup_rx8111(struct ds1307 *ds1307, u32 ohms, bool diode) > +{ > + /* make sure that the backup battery is enabled */ > + u8 setup = RX8111_PSC_SMP_INIEN; You can't do that, else it will never be possible to remove that without breaking existing users. Instead, you should use RTC_PARAM_BACKUP_SWITCH_MODE. Honestly, I would really like stopping adding support for more RTCs in this driver and instead split them all out. > + > + if (diode) > + setup |= RX8111_PSC_SMP_CHGEN; > + > + return setup; > +} > + > static u8 do_trickle_setup_rx8130(struct ds1307 *ds1307, u32 ohms, bool diode) > { > /* make sure that the backup battery is enabled */ > @@ -1012,6 +1078,16 @@ static const struct chip_desc chips[last_ds_type] = { > .century_bit = DS1337_BIT_CENTURY, > .bbsqi_bit = DS3231_BIT_BBSQW, > }, > + [rx_8111] = { > + .alarm = 1, > + .nvram_offset = 0x40, > + .nvram_size = 0x40, /* 0x40 .. 0x7F is user RAM */ > + .offset = 0x10, > + .irq_handler = rx8130_irq, > + .rtc_ops = &rx8130_rtc_ops, > + .trickle_charger_reg = RX8111_PWR_SWITCH_CTRL, > + .do_trickle_setup = &do_trickle_setup_rx8111, > + }, > [rx_8130] = { > .alarm = 1, > /* this is battery backed SRAM */ > @@ -1063,6 +1139,7 @@ static const struct i2c_device_id ds1307_id[] = { > { "pt7c4338", ds_1307 }, > { "rx8025", rx_8025 }, > { "isl12057", ds_1337 }, > + { "rx8111", rx_8111 }, > { "rx8130", rx_8130 }, > { } > }; > @@ -1137,6 +1214,10 @@ static const struct of_device_id ds1307_of_match[] = { > .compatible = "isil,isl12057", > .data = (void *)ds_1337 > }, > + { > + .compatible = "epson,rx8111", > + .data = (void *)rx_8111 > + }, > { > .compatible = "epson,rx8130", > .data = (void *)rx_8130 > @@ -1880,6 +1961,10 @@ static int ds1307_probe(struct i2c_client *client, > DS1307_REG_HOUR << 4 | 0x08, hour); > } > break; > + case rx_8111: > + /* Use memory as user RAM */ > + regmap_write(ds1307->regmap, RX8111_TIME_STAMP_BUF_CTRL, 0); > + break; > case ds_1388: > err = regmap_read(ds1307->regmap, DS1388_REG_CONTROL, &tmp); > if (err) { > -- > 2.17.1 > -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] dt-bindings: rtc: ds1307: Add support for Epson RX8111 2022-10-28 14:40 [PATCH 1/2] dt-bindings: rtc: ds1307: Add support for Epson RX8111 glasveze 2022-10-28 14:40 ` [PATCH 2/2] " glasveze @ 2022-10-28 17:38 ` Krzysztof Kozlowski 1 sibling, 0 replies; 7+ messages in thread From: Krzysztof Kozlowski @ 2022-10-28 17:38 UTC (permalink / raw) To: glasveze, linux-rtc, devicetree Cc: a.zummo, alexandre.belloni, robh+dt, linux-kernel, Mike Looijmans On 28/10/2022 10:40, glasveze@delta.nl wrote: > From: Mike Looijmans <mike.looijmans@topic.nl> > > The rx_8111 is quite similar to the rx_8030. This adds support for this > chip to the ds1307 driver. > > This adds the entry to the devicetree bindings. > > Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Please use scripts/get_maintainers.pl to get a list of necessary people and lists to CC. It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel. Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Best regards, Krzysztof ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] dt-bindings: rtc: ds1307: Add support for Epson RX8111 @ 2022-10-31 6:54 glasveze [not found] ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.9ece6833-e74a-4c7a-a461-cb644d735850@emailsignatures365.codetwo.com> 0 siblings, 1 reply; 7+ messages in thread From: glasveze @ 2022-10-31 6:54 UTC (permalink / raw) To: linux-rtc, devicetree Cc: a.zummo, alexandre.belloni, robh+dt, linux-kernel, Mike Looijmans From: Mike Looijmans <mike.looijmans@topic.nl> The rx_8111 is quite similar to the rx_8030. This adds support for this chip to the ds1307 driver. This adds the entry to the devicetree bindings. Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> --- Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml b/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml index 98d10e680144..a9590da64b84 100644 --- a/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml +++ b/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml @@ -30,6 +30,7 @@ properties: - pericom,pt7c4338 - epson,rx8025 - isil,isl12057 + - epson,rx8111 - epson,rx8130 - items: -- 2.17.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
[parent not found: <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.9ece6833-e74a-4c7a-a461-cb644d735850@emailsignatures365.codetwo.com>]
[parent not found: <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.0d2bd5fa-15cc-4b27-b94e-83614f9e5b38.26ae0640-23b6-42bd-b752-f9965c8a2c94@emailsignatures365.codetwo.com>]
* Re: [PATCH 1/2] dt-bindings: rtc: ds1307: Add support for Epson RX8111 [not found] ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.0d2bd5fa-15cc-4b27-b94e-83614f9e5b38.26ae0640-23b6-42bd-b752-f9965c8a2c94@emailsignatures365.codetwo.com> @ 2022-10-31 7:09 ` Mike Looijmans 0 siblings, 0 replies; 7+ messages in thread From: Mike Looijmans @ 2022-10-31 7:09 UTC (permalink / raw) To: glasveze, linux-rtc, devicetree Cc: a.zummo, alexandre.belloni, robh+dt, linux-kernel Sorry for the duplicates - there's some trouble with company spam filters that won't deliver mail from myself to myself... Met vriendelijke groet / kind regards, Mike Looijmans System Expert TOPIC Embedded Products B.V. Materiaalweg 4, 5681 RJ Best The Netherlands T: +31 (0) 499 33 69 69 E: mike.looijmans@topicproducts.com W: www.topic.nl Please consider the environment before printing this e-mail On 31-10-2022 07:54, glasveze@delta.nl wrote: > From: Mike Looijmans <mike.looijmans@topic.nl> > > The rx_8111 is quite similar to the rx_8030. This adds support for this > chip to the ds1307 driver. > > This adds the entry to the devicetree bindings. > > Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> > --- > Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml b/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml > index 98d10e680144..a9590da64b84 100644 > --- a/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml > +++ b/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml > @@ -30,6 +30,7 @@ properties: > - pericom,pt7c4338 > - epson,rx8025 > - isil,isl12057 > + - epson,rx8111 > - epson,rx8130 > > - items: -- Mike Looijmans ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] dt-bindings: rtc: ds1307: Add support for Epson RX8111 @ 2022-10-28 14:19 glasveze 0 siblings, 0 replies; 7+ messages in thread From: glasveze @ 2022-10-28 14:19 UTC (permalink / raw) To: a.zummo, alexandre.belloni, linux-rtc, robh+dt, devicetree Cc: linux-kernel, Mike Looijmans From: Mike Looijmans <mike.looijmans@topic.nl> The rx_8111 is quite similar to the rx_8030. This adds support for this chip to the ds1307 driver. This adds the entry to the devicetree bindings. Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> --- Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml b/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml index 98d10e680144..a9590da64b84 100644 --- a/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml +++ b/Documentation/devicetree/bindings/rtc/rtc-ds1307.yaml @@ -30,6 +30,7 @@ properties: - pericom,pt7c4338 - epson,rx8025 - isil,isl12057 + - epson,rx8111 - epson,rx8130 - items: -- 2.17.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-11-14 22:18 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-10-28 14:40 [PATCH 1/2] dt-bindings: rtc: ds1307: Add support for Epson RX8111 glasveze 2022-10-28 14:40 ` [PATCH 2/2] " glasveze 2022-11-14 22:17 ` Alexandre Belloni 2022-10-28 17:38 ` [PATCH 1/2] dt-bindings: " Krzysztof Kozlowski -- strict thread matches above, loose matches on Subject: below -- 2022-10-31 6:54 glasveze [not found] ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.949ef384-8293-46b8-903f-40a477c056ae.9ece6833-e74a-4c7a-a461-cb644d735850@emailsignatures365.codetwo.com> [not found] ` <1b153bce-a66a-45ee-a5c6-963ea6fb1c82.0d2bd5fa-15cc-4b27-b94e-83614f9e5b38.26ae0640-23b6-42bd-b752-f9965c8a2c94@emailsignatures365.codetwo.com> 2022-10-31 7:09 ` Mike Looijmans 2022-10-28 14:19 glasveze
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).