Skip to contentSkip to conversation

Add rtc support for rn5t618 mfd

PATCH Superseded Andreas Kemnade 3 participants 9 messages Dec 20, 2019 – Feb 26, 2020

Subsystems (3)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover Add rtc support for rn5t618 mfd

In the variant RC5T619 the mfd has an RTC. This patchset adds support for it. To do so it adds the missing register defines in rn5t618.h and general irq handling for that.
It seems that the irq definitions are the same except missing RTC but due to missing ability to test that I do not add them here.

The rtc driver itself is based on
https://github.com/kobolabs/Kobo-Reader/blob/master/hw/imx6sll-clara/kernel.tar.bz2
but heavily reworked.

It was tested on the Kobo Clara HD.

For cleaning up there is a separate off-topic patch:
mfd: rn5t618: cleanup i2c_device_id

Changes in v5:
- static rn5t618_irq_init
- PLATFORM_DEVID_NONE
- added some Acked-Bys

Changes in v4:
- use macros for IRQ definitions
- merge rn5t618-core.c and rn5t618-irq.c

Changes in v3:
- alignment cleanup
- output cleanup, remove useless toggling of alarm flag in rtc probe
- updated bindings description, so patch 1/5 becomes 2/6 and so on

Changes in v2:
- no dead code in irq code
- various improvements and cleanups in rtc driver itself

Andreas Kemnade (5):
dt-bindings: mfd: rn5t618: Document optional property interrupts
mfd: rn5t618: add IRQ support
mfd: rn5t618: add RTC related registers
mfd: rn5t618: add more subdevices
rtc: rc5t619: add ricoh rc5t619 RTC driver

 Documentation/devicetree/bindings/mfd/rn5t618.txt |   4 +
 drivers/mfd/Kconfig                               |   1 +
 drivers/mfd/rn5t618.c                             | 109 +++++-
 drivers/rtc/Kconfig                               |  10 +
 drivers/rtc/Makefile                              |   1 +
 drivers/rtc/rtc-rc5t619.c                         | 444 ++++++++++++++++++++++
 include/linux/mfd/rn5t618.h                       |  26 ++
 7 files changed, 593 insertions(+), 2 deletions(-)
 create mode 100644 drivers/rtc/rtc-rc5t619.c
Signature · 1 line
2.11.0
#1 lore raw

PATCH v5 1/5 dt-bindings: mfd: rn5t618: Document optional property interrupts

These chips use interrupts for various things like RTC alarm.

---
Changes in v4: add refernce to interrupt binding
documentation

 Documentation/devicetree/bindings/mfd/rn5t618.txt | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/mfd/rn5t618.txt +4 -0
index b74e5e94d1cb..16778ea00dbc 100644
@@ -15,6 +15,8 @@ Required properties:
  - reg: the I2C slave address of the device
 
 Optional properties:
+ - interrupts: interrupt mapping for IRQ
+   See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
  - system-power-controller:
    See Documentation/devicetree/bindings/power/power-controller.txt
 
@@ -32,6 +34,8 @@ Example:
 	pmic@32 {
 		compatible = "ricoh,rn5t618";
 		reg = <0x32>;
+		interrupt-parent = <&gpio5>;
+		interrupts = <11 IRQ_TYPE_EDGE_FALLING>;
 		system-power-controller;
 
 		regulators {
Signature · 1 line
2.11.0
#2 lore raw

PATCH v5 2/5 mfd: rn5t618: add IRQ support

In reply to Andreas Kemnade

This adds support for IRQ handling in the RC5T619 which is required for properly implementing subdevices like RTC.
For now only definitions for the variant RC5T619 are included.

---
Changes in v5:
rn5t618_irq_init static

Changes in v4:
merge rn5t618-irq.c into rn5t618.c
use macros for IRQ table

Changes in v3:
alignment cleanup

Changes in v2:
- no dead code, did some more testing and thinking for that
- remove extra empty lines

 drivers/mfd/Kconfig         |  1 +
 drivers/mfd/rn5t618.c       | 88 +++++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/rn5t618.h | 15 ++++++++
 3 files changed, 104 insertions(+)
drivers/mfd/Kconfig +1 -0
index ae24d3ea68ea..522e068d0082 100644
@@ -1057,6 +1057,7 @@ config MFD_RN5T618
 	depends on OF
 	select MFD_CORE
 	select REGMAP_I2C
+	select REGMAP_IRQ
 	help
 	  Say yes here to add support for the Ricoh RN5T567,
 	  RN5T618, RC5T619 PMIC.
drivers/mfd/rn5t618.c +88 -0

130 lines not on this page · raw message

include/linux/mfd/rn5t618.h +15 -0
index d62ef48060b5..739571656f2b 100644
@@ -242,9 +242,24 @@ enum {
 	RC5T619,
 };
 
+/* RN5T618 IRQ definitions */
+enum {
+	RN5T618_IRQ_SYS = 0,
+	RN5T618_IRQ_DCDC,
+	RN5T618_IRQ_RTC,
+	RN5T618_IRQ_ADC,
+	RN5T618_IRQ_GPIO,
+	RN5T618_IRQ_CHG,
+	RN5T618_NR_IRQS,
+};
+
 struct rn5t618 {
 	struct regmap *regmap;
+	struct device *dev;
 	long variant;
+
+	int irq;
+	struct regmap_irq_chip_data *irq_data;
 };
 
 #endif /* __LINUX_MFD_RN5T618_H */
Signature · 1 line
2.11.0
#3 lore raw

PATCH v5 3/5 mfd: rn5t618: add RTC related registers

In reply to Andreas Kemnade

Defines for some RTC related registers were missing, also they were not included in the volatile register list

---

 drivers/mfd/rn5t618.c       |  2 ++
 include/linux/mfd/rn5t618.h | 11 +++++++++++
 2 files changed, 13 insertions(+)
drivers/mfd/rn5t618.c +2 -0
index fbd31397b047..6bdc5a023cbf 100644
@@ -33,6 +33,8 @@ static bool rn5t618_volatile_reg(struct device *dev, unsigned int reg)
 	case RN5T618_IR_GPF:
 	case RN5T618_MON_IOIN:
 	case RN5T618_INTMON:
+	case RN5T618_RTC_CTRL1 ... RN5T618_RTC_CTRL2:
+	case RN5T618_RTC_SECONDS ... RN5T618_RTC_YEAR:
 		return true;
 	default:
 		return false;
include/linux/mfd/rn5t618.h +11 -0
index 739571656f2b..fba0df13d9a8 100644
@@ -139,6 +139,17 @@
 #define RN5T618_INTPOL			0x9c
 #define RN5T618_INTEN			0x9d
 #define RN5T618_INTMON			0x9e
+
+#define RN5T618_RTC_SECONDS     0xA0
+#define RN5T618_RTC_MDAY        0xA4
+#define RN5T618_RTC_MONTH       0xA5
+#define RN5T618_RTC_YEAR        0xA6
+#define RN5T618_RTC_ADJUST      0xA7
+#define RN5T618_RTC_ALARM_Y_SEC 0xA8
+#define RN5T618_RTC_DAL_MONTH   0xAC
+#define RN5T618_RTC_CTRL1       0xAE
+#define RN5T618_RTC_CTRL2       0xAF
+
 #define RN5T618_PREVINDAC		0xb0
 #define RN5T618_BATDAC			0xb1
 #define RN5T618_CHGCTL1			0xb3
Signature · 1 line
2.11.0
#4 lore raw

PATCH v5 4/5 mfd: rn5t618: add more subdevices

In reply to Andreas Kemnade

The RC5T619 has a RTC which is missing in the
RN5T618. Add it as subdevice to prepare for their implementation

---
Changes in v3:
- alignment cleanup

 drivers/mfd/rn5t618.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/mfd/rn5t618.c +17 -2
index 6bdc5a023cbf..ec378715137b 100644
@@ -14,6 +14,7 @@
 #include <linux/mfd/rn5t618.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
+#include <linux/platform_device.h>
 #include <linux/reboot.h>
 #include <linux/regmap.h>
 
@@ -22,6 +23,12 @@ static const struct mfd_cell rn5t618_cells[] = {
 	{ .name = "rn5t618-wdt" },
 };
 
+static const struct mfd_cell rc5t619_cells[] = {
+	{ .name = "rn5t618-regulator" },
+	{ .name = "rc5t619-rtc" },
+	{ .name = "rn5t618-wdt" },
+};
+
 static bool rn5t618_volatile_reg(struct device *dev, unsigned int reg)
 {
 	switch (reg) {
@@ -173,8 +180,16 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c,
 		return ret;
 	}
 
-	ret = devm_mfd_add_devices(&i2c->dev, -1, rn5t618_cells,
-				   ARRAY_SIZE(rn5t618_cells), NULL, 0, NULL);
+	if (priv->variant == RC5T619)
+		ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_NONE,
+					   rc5t619_cells,
+					   ARRAY_SIZE(rc5t619_cells),
+					   NULL, 0, NULL);
+	else
+		ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_NONE,
+					   rn5t618_cells,
+					   ARRAY_SIZE(rn5t618_cells),
+					   NULL, 0, NULL);
 	if (ret) {
 		dev_err(&i2c->dev, "failed to add sub-devices: %d\n", ret);
 		return ret;
Signature · 1 line
2.11.0
#5 lore raw

PATCH v5 5/5 rtc: rc5t619: add ricoh rc5t619 RTC driver

In reply to Andreas Kemnade

Add an RTC driver for the RTC device on Ricoh MFD RC5T619, which is implemented as a variant of RN5T618.

rtc-range output:
Testing 2000-02-28 23:59:59.
OK

Testing 2038-01-19 03:14:07.
OK

Testing 2069-12-31 23:59:59.
OK

Testing 2099-12-31 23:59:59.
KO RTC_RD_TIME returned 22 (line 138)

Testing 2100-02-28 23:59:59.
KO RTC_SET_TIME returned 34 (line 122)

Testing 2106-02-07 06:28:15.
KO RTC_SET_TIME returned 34 (line 122)

Testing 2262-04-11 23:47:16.
KO RTC_SET_TIME returned 34 (line 122)

---
Changes in v3:
- further output cleanup
- remove useless toggling of alarm flag in rtc probe
- alignment cleanup

Changes in v2:
- correct subject line
- reset pon flag not at probe but later
- initialize things only on pon
- 12h handling
- ranges
- style cleanup
- less magic values

 drivers/rtc/Kconfig       |  10 ++
 drivers/rtc/Makefile      |   1 +
 drivers/rtc/rtc-rc5t619.c | 444 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 455 insertions(+)
 create mode 100644 drivers/rtc/rtc-rc5t619.c
drivers/rtc/Kconfig +10 -0
index 1adf9f815652..b8e5bfa8efc6 100644
@@ -600,6 +600,16 @@ config RTC_DRV_RC5T583
 	  This driver can also be built as a module. If so, the module
 	  will be called rtc-rc5t583.
 
+config RTC_DRV_RC5T619
+	tristate "RICOH RC5T619 RTC driver"
+	depends on MFD_RN5T618
+	help
+	  If you say yes here you get support for the RTC on the
+	  RICOH RC5T619 chips.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rtc-rc5t619.
+
 config RTC_DRV_S35390A
 	tristate "Seiko Instruments S-35390A"
 	select BITREVERSE
drivers/rtc/Makefile +1 -0
index 4ac8f19fb631..7612912cdf00 100644
@@ -137,6 +137,7 @@ obj-$(CONFIG_RTC_DRV_PXA)	+= rtc-pxa.o
 obj-$(CONFIG_RTC_DRV_R7301)	+= rtc-r7301.o
 obj-$(CONFIG_RTC_DRV_R9701)	+= rtc-r9701.o
 obj-$(CONFIG_RTC_DRV_RC5T583)	+= rtc-rc5t583.o
+obj-$(CONFIG_RTC_DRV_RC5T619)	+= rtc-rc5t619.o
 obj-$(CONFIG_RTC_DRV_RK808)	+= rtc-rk808.o
 obj-$(CONFIG_RTC_DRV_RP5C01)	+= rtc-rp5c01.o
 obj-$(CONFIG_RTC_DRV_RS5C313)	+= rtc-rs5c313.o
drivers/rtc/rtc-rc5t619.c new file +444 -0

444 lines not on this page · raw message

Signature · 1 line
2.11.0
#6 lore raw
In reply to Andreas Kemnade

Hi,

I hope everyone went well into new year, are there any open issues left here preveting applying these patches?

Quoted 4 lines · On Fri, 20 Dec 2019 13:24:11 +0100 Andreas Kemnade <[email protected]> wrote:

In the variant RC5T619 the mfd has an RTC. This patchset adds support for it. To do so it adds the missing register defines in rn5t618.h and general irq handling for that.
It seems that the irq definitions are the same except missing RTC

missing words ... for the rn5t618 ...

Quoted 50 lines

but due to missing ability to test that I do not add them here.

The rtc driver itself is based on
https://github.com/kobolabs/Kobo-Reader/blob/master/hw/imx6sll-clara/kernel.tar.bz2
but heavily reworked.

It was tested on the Kobo Clara HD.

For cleaning up there is a separate off-topic patch:
mfd: rn5t618: cleanup i2c_device_id

Changes in v5:
- static rn5t618_irq_init
- PLATFORM_DEVID_NONE
- added some Acked-Bys

Changes in v4:
- use macros for IRQ definitions
- merge rn5t618-core.c and rn5t618-irq.c

Changes in v3:
- alignment cleanup
- output cleanup, remove useless toggling of alarm flag in rtc probe
- updated bindings description, so patch 1/5 becomes 2/6 and so on

Changes in v2:
- no dead code in irq code
- various improvements and cleanups in rtc driver itself

Andreas Kemnade (5):
dt-bindings: mfd: rn5t618: Document optional property interrupts
mfd: rn5t618: add IRQ support
mfd: rn5t618: add RTC related registers
mfd: rn5t618: add more subdevices
rtc: rc5t619: add ricoh rc5t619 RTC driver

 Documentation/devicetree/bindings/mfd/rn5t618.txt |   4 +
 drivers/mfd/Kconfig                               |   1 +
 drivers/mfd/rn5t618.c                             | 109 +++++-
 drivers/rtc/Kconfig                               |  10 +
 drivers/rtc/Makefile                              |   1 +
 drivers/rtc/rtc-rc5t619.c                         | 444 ++++++++++++++++++++++
 include/linux/mfd/rn5t618.h                       |  26 ++
 7 files changed, 593 insertions(+), 2 deletions(-)
 create mode 100644 drivers/rtc/rtc-rc5t619.c
Signature · 1 line
2.11.0
#7 lore raw
In reply to Andreas Kemnade

Hi,

Quoted 35 lines

Am 20.12.2019 um 13:24 schrieb Andreas Kemnade <[email protected]>:

In the variant RC5T619 the mfd has an RTC. This patchset adds support for it. To do so it adds the missing register defines in rn5t618.h and general irq handling for that.
It seems that the irq definitions are the same except missing RTC but due to missing ability to test that I do not add them here.

The rtc driver itself is based on
https://github.com/kobolabs/Kobo-Reader/blob/master/hw/imx6sll-clara/kernel.tar.bz2
but heavily reworked.

It was tested on the Kobo Clara HD.

For cleaning up there is a separate off-topic patch:
mfd: rn5t618: cleanup i2c_device_id

Changes in v5:
- static rn5t618_irq_init
- PLATFORM_DEVID_NONE
- added some Acked-Bys

Changes in v4:
- use macros for IRQ definitions
- merge rn5t618-core.c and rn5t618-irq.c

Changes in v3:
- alignment cleanup
- output cleanup, remove useless toggling of alarm flag in rtc probe
- updated bindings description, so patch 1/5 becomes 2/6 and so on

Changes in v2:
- no dead code in irq code
- various improvements and cleanups in rtc driver itself

Quoted 6 lines

Andreas Kemnade (5):
dt-bindings: mfd: rn5t618: Document optional property interrupts
mfd: rn5t618: add IRQ support
mfd: rn5t618: add RTC related registers
mfd: rn5t618: add more subdevices
rtc: rc5t619: add ricoh rc5t619 RTC driver

what has happened to this series?
It looks like something got lost so that it has not yet arrived in linux-next.

BR and thanks,
Nikolaus Schaller

Quoted 13 lines
Documentation/devicetree/bindings/mfd/rn5t618.txt |   4 +
drivers/mfd/Kconfig                               |   1 +
drivers/mfd/rn5t618.c                             | 109 +++++-
drivers/rtc/Kconfig                               |  10 +
drivers/rtc/Makefile                              |   1 +
drivers/rtc/rtc-rc5t619.c                         | 444 ++++++++++++++++++++++
include/linux/mfd/rn5t618.h                       |  26 ++
7 files changed, 593 insertions(+), 2 deletions(-)

create mode 100644 drivers/rtc/rtc-rc5t619.c

Signature · 1 line
2.11.0
#8 lore raw
Quoted 44 lines · H. Nikolaus Schaller

Hi,

Quoted 35 lines

Am 20.12.2019 um 13:24 schrieb Andreas Kemnade <[email protected]>:

In the variant RC5T619 the mfd has an RTC. This patchset adds support for it. To do so it adds the missing register defines in rn5t618.h and general irq handling for that.
It seems that the irq definitions are the same except missing RTC but due to missing ability to test that I do not add them here.

The rtc driver itself is based on
https://github.com/kobolabs/Kobo-Reader/blob/master/hw/imx6sll-clara/kernel.tar.bz2
but heavily reworked.

It was tested on the Kobo Clara HD.

For cleaning up there is a separate off-topic patch:
mfd: rn5t618: cleanup i2c_device_id

Changes in v5:
- static rn5t618_irq_init
- PLATFORM_DEVID_NONE
- added some Acked-Bys

Changes in v4:
- use macros for IRQ definitions
- merge rn5t618-core.c and rn5t618-irq.c

Changes in v3:
- alignment cleanup
- output cleanup, remove useless toggling of alarm flag in rtc probe
- updated bindings description, so patch 1/5 becomes 2/6 and so on

Changes in v2:
- no dead code in irq code
- various improvements and cleanups in rtc driver itself

Quoted 6 lines

Andreas Kemnade (5):
dt-bindings: mfd: rn5t618: Document optional property interrupts
mfd: rn5t618: add IRQ support
mfd: rn5t618: add RTC related registers
mfd: rn5t618: add more subdevices
rtc: rc5t619: add ricoh rc5t619 RTC driver

Quoted 2 lines

what has happened to this series?
It looks like something got lost so that it has not yet arrived in linux-next.

It won't show up in -next until it's been reviewed/applied.

If it's not been touched for a few weeks/months, assume it's slipped through the gaps, collect all of the *-bys and submit a [RESEND].

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog