linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Add Renesas PMIC RAA215300 and built-in RTC support
@ 2023-05-05 17:25 Biju Das
  2023-05-05 17:25 ` [PATCH v2 3/5] rtc: isl1208: Add support for the built-in RTC on the PMIC RAA215300 Biju Das
  0 siblings, 1 reply; 2+ messages in thread
From: Biju Das @ 2023-05-05 17:25 UTC (permalink / raw)
  To: Lee Jones, Alessandro Zummo, Alexandre Belloni, Rob Herring,
	Krzysztof Kozlowski
  Cc: Biju Das, Geert Uytterhoeven, Magnus Damm, devicetree, linux-rtc,
	linux-renesas-soc, Fabrizio Castro

This patch series aims to add support for Renesas PMIC RAA215300 and
built-in RTC found on this PMIC device.

The details of PMIC can be found here[1].

The built-in RTC is same as ISL-1208. Enabling of the
RTC is done by the PMIC module. Also the external osciallator bit is
inverted on PMIC version 0x12 and later. The PMIC version is shared
between PMIC driver and RTC driver.

RAA215300PMIC driver has MFD cell entry for RTC platform driver and it
instantiates the RTC platform driver. RTC platform creates rtc device by
using i2c_new_ancillary_device() and register the rtc device by
calling the helper function provided by rtc-isl2108 driver.

[1]
https://www.renesas.com/in/en/products/power-power-management/multi-channel-power-management-ics-pmics/ssdsoc-power-management-ics-pmic-and-pmus/raa215300-high-performance-9-channel-pmic-supporting-ddr-memory-built-charger-and-rtc

[2]
 https://patchwork.kernel.org/project/linux-renesas-soc/patch/20230505091720.115675-1-biju.das.jz@bp.renesas.com/

RFC->v2:
 * Dropped the cross-links from bindings and used a single compatible
   with separate i2c addresses for pmic main and rtc device.
 * Dropped patch#4 and split patch#3 from this series and send as
   separate patch to ML [2].
 * Added RTC platform driver and mfd cell entry to the PMIC driver.RTC
   platform driver creates rtc device by using i2c_new_ancillary_device()
   and register the rtc device by calling the helper function provided
   by rtc-isl2108 driver.
 * Updated reg property in bindings.
 * Added optional reg-names, interrupts and renesas,rtc-enabled
   properties.
 * Fixed the node name in the binding example
 * Dropped the cross link property renesas,raa215300-rtc.
 * Updated the binding example
 * Dropped MODULE_SOFTDEP from the driver as it is added in RTC platform
   driver.
 * Dropped compatible "renesas,raa215300-isl1208" and "renesas,raa215300-pmic" property.
 * Updated the comment polarity->bit for External Oscillator.
 * Added raa215300_rtc_probe_helper() for registering raa215300_rtc device and
   added the helper function isl1208_probe_helper() to share the code.
 * Updated pmic device node on the SoM dtsi based on the bindings.

Logs:
[   15.055110] dummy 3-006f: registered as rtc0
[   15.189869] dummy 3-006f: setting system clock to 2023-04-27T19:32:41 UTC (1682623961)

root@smarc-rzg2l:~# hwclock -r
2023-04-27 19:43:09.802884+00:00
root@smarc-rzg2l:~# hwclock -r
2023-04-27 19:43:10.996184+00:00
root@smarc-rzg2l:~#

Biju Das (5):
  dt-bindings: mfd: Add Renesas RAA215300 PMIC bindings
  mfd: Add Renesas PMIC RAA215300 driver
  rtc: isl1208: Add support for the built-in RTC on the PMIC RAA215300
  mfd: Add Renesas PMIC RAA215300 RTC driver
  arm64: dts: renesas: rzg2l-smarc-som: Enable PMIC and built-in RTC

 .../bindings/mfd/renesas,raa215300.yaml       |  68 +++++++++++
 .../boot/dts/renesas/rzg2l-smarc-som.dtsi     |  10 ++
 drivers/mfd/Kconfig                           |  14 +++
 drivers/mfd/Makefile                          |   3 +
 drivers/mfd/raa215300-rtc.c                   |  52 +++++++++
 drivers/mfd/raa215300.c                       | 106 ++++++++++++++++++
 drivers/rtc/rtc-isl1208.c                     |  61 ++++++++--
 include/linux/rtc/isl1208.h                   |   9 ++
 8 files changed, 312 insertions(+), 11 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/renesas,raa215300.yaml
 create mode 100644 drivers/mfd/raa215300-rtc.c
 create mode 100644 drivers/mfd/raa215300.c
 create mode 100644 include/linux/rtc/isl1208.h

-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v2 3/5] rtc: isl1208: Add support for the built-in RTC on the PMIC RAA215300
  2023-05-05 17:25 [PATCH v2 0/5] Add Renesas PMIC RAA215300 and built-in RTC support Biju Das
@ 2023-05-05 17:25 ` Biju Das
  0 siblings, 0 replies; 2+ messages in thread
From: Biju Das @ 2023-05-05 17:25 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni
  Cc: Biju Das, Geert Uytterhoeven, Magnus Damm, Lee Jones, linux-rtc,
	linux-renesas-soc, Fabrizio Castro

The built-in RTC found on PMIC RAA215300 is the same as ISL1208.
However, the external oscillator bit is inverted on PMIC version
0x12 and later. This info needs to be shared from the PMIC driver
to the RTC driver so that it can support all versions without any
code changes.

Add support for RTC found on PMIC RAA215300 by adding a helper
function for registering the RTC device.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
RFC->v2:
 * Dropped compatible "renesas,raa215300-isl1208" and "renesas,raa215300-pmic" property.
 * Updated the comment polarity->bit for External Oscillator.
 * Added raa215300_rtc_probe_helper() for registering raa215300_rtc device and
   added the helper function isl1208_probe_helper() to share the code.
---
 drivers/rtc/rtc-isl1208.c   | 61 ++++++++++++++++++++++++++++++-------
 include/linux/rtc/isl1208.h |  9 ++++++
 2 files changed, 59 insertions(+), 11 deletions(-)
 create mode 100644 include/linux/rtc/isl1208.h

diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 73cc6aaf9b8b..f2dc96d3e4e1 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -166,6 +166,19 @@ isl1208_i2c_validate_client(struct i2c_client *client)
 	return 0;
 }
 
+static int
+isl1208_set_ext_osc_based_on_pmic_version(struct i2c_client *client, int rc,
+					  unsigned int pmic_version)
+{
+	/* External Oscillator bit is inverted on revision 0x12 and later */
+	if (pmic_version >= 0x12)
+		rc &= ~ISL1208_REG_SR_XTOSCB;
+	else
+		rc |= ISL1208_REG_SR_XTOSCB;
+
+	return i2c_smbus_write_byte_data(client, ISL1208_REG_SR, rc);
+}
+
 static int
 isl1208_i2c_get_sr(struct i2c_client *client)
 {
@@ -797,7 +810,8 @@ static int isl1208_setup_irq(struct i2c_client *client, int irq)
 }
 
 static int
-isl1208_probe(struct i2c_client *client)
+isl1208_probe_helper(struct i2c_client *client, bool is_raa215300_rtc,
+		     unsigned int pmic_version)
 {
 	int rc = 0;
 	struct isl1208_state *isl1208;
@@ -815,17 +829,22 @@ isl1208_probe(struct i2c_client *client)
 		return -ENOMEM;
 	i2c_set_clientdata(client, isl1208);
 
-	/* Determine which chip we have */
-	if (client->dev.of_node) {
-		isl1208->config = of_device_get_match_data(&client->dev);
-		if (!isl1208->config)
-			return -ENODEV;
+	if (is_raa215300_rtc) {
+		isl1208->config = &isl1208_configs[TYPE_ISL1208];
 	} else {
-		const struct i2c_device_id *id = i2c_match_id(isl1208_id, client);
-
-		if (id->driver_data >= ISL_LAST_ID)
-			return -ENODEV;
-		isl1208->config = &isl1208_configs[id->driver_data];
+		/* Determine which chip we have */
+		if (client->dev.of_node) {
+			isl1208->config = of_device_get_match_data(&client->dev);
+			if (!isl1208->config)
+				return -ENODEV;
+		} else {
+			const struct i2c_device_id *id = i2c_match_id(isl1208_id,
+								      client);
+
+			if (id->driver_data >= ISL_LAST_ID)
+				return -ENODEV;
+			isl1208->config = &isl1208_configs[id->driver_data];
+		}
 	}
 
 	isl1208->rtc = devm_rtc_allocate_device(&client->dev);
@@ -845,6 +864,13 @@ isl1208_probe(struct i2c_client *client)
 		return rc;
 	}
 
+	if (is_raa215300_rtc) {
+		rc = isl1208_set_ext_osc_based_on_pmic_version(client, rc,
+							       pmic_version);
+		if (rc)
+			return rc;
+	}
+
 	if (rc & ISL1208_REG_SR_RTCF)
 		dev_warn(&client->dev, "rtc power failure detected, "
 			 "please set clock.\n");
@@ -903,6 +929,19 @@ isl1208_probe(struct i2c_client *client)
 	return devm_rtc_register_device(isl1208->rtc);
 }
 
+static int
+isl1208_probe(struct i2c_client *client)
+{
+	return isl1208_probe_helper(client, false, 0);
+}
+
+int
+raa215300_rtc_probe_helper(struct i2c_client *client, unsigned int pmic_version)
+{
+	return isl1208_probe_helper(client, true, pmic_version);
+}
+EXPORT_SYMBOL(raa215300_rtc_probe_helper);
+
 static struct i2c_driver isl1208_driver = {
 	.driver = {
 		.name = "rtc-isl1208",
diff --git a/include/linux/rtc/isl1208.h b/include/linux/rtc/isl1208.h
new file mode 100644
index 000000000000..1dee540f9ab4
--- /dev/null
+++ b/include/linux/rtc/isl1208.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _LINUX_ISL1208_H_
+#define _LINUX_ISL1208_H_
+
+int raa215300_rtc_probe_helper(struct i2c_client *client,
+			       unsigned int pmic_version);
+
+#endif /* _LINUX_ISL1208_H_ */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-05 17:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-05 17:25 [PATCH v2 0/5] Add Renesas PMIC RAA215300 and built-in RTC support Biju Das
2023-05-05 17:25 ` [PATCH v2 3/5] rtc: isl1208: Add support for the built-in RTC on the PMIC RAA215300 Biju Das

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).