From patchwork Wed May 3 08:46:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13229868 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3253BC7EE26 for ; Wed, 3 May 2023 08:46:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229574AbjECIqW (ORCPT ); Wed, 3 May 2023 04:46:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjECIqV (ORCPT ); Wed, 3 May 2023 04:46:21 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E800E40CF; Wed, 3 May 2023 01:46:19 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.99,246,1677510000"; d="scan'208";a="158019816" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 03 May 2023 17:46:19 +0900 Received: from localhost.localdomain (unknown [10.226.92.153]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 72CDE41C6679; Wed, 3 May 2023 17:46:16 +0900 (JST) From: Biju Das To: Lee Jones , Rob Herring , Krzysztof Kozlowski Cc: Biju Das , Geert Uytterhoeven , Magnus Damm , devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Fabrizio Castro Subject: [PATCH RFC 1/6] dt-bindings: mfd: Add Renesas RAA215300 PMIC bindings Date: Wed, 3 May 2023 09:46:03 +0100 Message-Id: <20230503084608.14008-2-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230503084608.14008-1-biju.das.jz@bp.renesas.com> References: <20230503084608.14008-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Document Renesas RAA215300 PMIC bindings. The RAA215300 is a high Performance 9-Channel PMIC supporting DDR Memory, with Built-In Charger and RTC. It supports DDR3, DDR3L, DDR4, and LPDDR4 memory power requirements. The internally compensated regulators, built-in Real-Time Clock (RTC), 32kHz crystal oscillator, and coin cell battery charger provide a highly integrated, small footprint power solution ideal for System-On-Module (SOM) applications. A spread spectrum feature provides an ease-of-use solution for noise-sensitive audio or RF applications. Signed-off-by: Biju Das --- .../bindings/mfd/renesas,raa215300.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/renesas,raa215300.yaml diff --git a/Documentation/devicetree/bindings/mfd/renesas,raa215300.yaml b/Documentation/devicetree/bindings/mfd/renesas,raa215300.yaml new file mode 100644 index 000000000000..1e65f7618333 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/renesas,raa215300.yaml @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/renesas,raa215300.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas RAA215300 Power Management Integrated Circuit (PMIC) + +maintainers: + - Biju Das + +description: | + The RAA215300 is a high-performance, low-cost 9-channel PMIC designed for + 32-bit and 64-bit MCU and MPU applications. It supports DDR3, DDR3L, DDR4, + and LPDDR4 memory power requirements. The internally compensated regulators, + built-in Real-Time Clock (RTC), 32kHz crystal oscillator, and coin cell + battery charger provide a highly integrated, small footprint power solution + ideal for System-On-Module (SOM) applications. A spread spectrum feature + provides an ease-of-use solution for noise-sensitive audio or RF applications. + + This device exposes two devices via I2C. One for the integrated RTC IP, and + one for everything else. + + Link to datasheet: + 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 + +properties: + compatible: + enum: + - renesas,raa215300 + + reg: + maxItems: 1 + + renesas,raa215300-rtc: + $ref: /schemas/types.yaml#/definitions/phandle + description: phandle to the built-in RTC device. + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmic: raa215300@12 { + compatible = "renesas,raa215300"; + reg = <0x12>; + + renesas,raa215300-rtc = <&rtc_raa215300>; + }; + }; From patchwork Wed May 3 08:46:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13229869 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 396B2C7EE22 for ; Wed, 3 May 2023 08:46:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229441AbjECIqY (ORCPT ); Wed, 3 May 2023 04:46:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjECIqX (ORCPT ); Wed, 3 May 2023 04:46:23 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 824D949FC for ; Wed, 3 May 2023 01:46:22 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.99,246,1677510000"; d="scan'208";a="158019821" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 03 May 2023 17:46:22 +0900 Received: from localhost.localdomain (unknown [10.226.92.153]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id BFED741C667B; Wed, 3 May 2023 17:46:19 +0900 (JST) From: Biju Das To: Lee Jones Cc: Biju Das , Geert Uytterhoeven , Alessandro Zummo , Alexandre Belloni , Magnus Damm , linux-renesas-soc@vger.kernel.org, Fabrizio Castro Subject: [PATCH RFC 2/6] mfd: Add Renesas PMIC RAA215300 driver Date: Wed, 3 May 2023 09:46:04 +0100 Message-Id: <20230503084608.14008-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230503084608.14008-1-biju.das.jz@bp.renesas.com> References: <20230503084608.14008-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The RAA215300 is a 9-channel PMIC that consists of * Internally compensated regulators * built-in Real Time Clock (RTC) * 32kHz crystal oscillator * coin cell battery charger The RTC on RAA215300 is similar to the IP found in the ISL1208. The existing driver for the ISL1208 works for this PMIC too, however the RAA215300 exposes two devices via I2C, one for the RTC IP, and one for everything else. The RTC IP has to be enabled by the other I2C device, therefore this driver is necessary to get the RTC to work. Add PMIC RAA215300 driver for enabling RTC and sharing PMIC version to RTC driver. Signed-off-by: Biju Das --- drivers/mfd/Kconfig | 8 ++++ drivers/mfd/Makefile | 2 + drivers/mfd/raa215300.c | 91 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 drivers/mfd/raa215300.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index e90463c4441c..3e2a7f033b26 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -311,6 +311,14 @@ config MFD_CS47L92 help Support for Cirrus Logic CS42L92, CS47L92 and CS47L93 Smart Codecs +config PMIC_RAA215300 + tristate "Renesas RAA215300 driver" + select REGMAP_I2C + depends on I2C + help + Select this to get support for the Renesas RAA215300 PMIC and to + enable the built-in RTC. + config PMIC_DA903X bool "Dialog Semiconductor DA9030/DA9034 PMIC Support" depends on I2C=y diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 1d2392f06f78..d9c601120bfd 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -126,6 +126,8 @@ ifeq ($(CONFIG_SA1100_ASSABET),y) obj-$(CONFIG_MCP_UCB1200) += ucb1x00-assabet.o endif +obj-$(CONFIG_PMIC_RAA215300) += raa215300.o + obj-$(CONFIG_PMIC_DA903X) += da903x.o obj-$(CONFIG_PMIC_DA9052) += da9052-irq.o diff --git a/drivers/mfd/raa215300.c b/drivers/mfd/raa215300.c new file mode 100644 index 000000000000..33f93bd9ef17 --- /dev/null +++ b/drivers/mfd/raa215300.c @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Renesas RAA215300 PMIC driver + * + * Copyright (C) 2023 Renesas Electronics Corporation + */ + +#include +#include +#include +#include +#include + +#define RAA215300_REG_BLOCK_EN 0x6c +#define RAA215300_HW_REV 0xf8 + +#define RAA215300_REG_BLOCK_EN_RTC_EN BIT(6) + +static bool raa215300_is_volatile_reg(struct device *dev, unsigned int reg) +{ + return true; +} + +static const struct regmap_config raa215300_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = 0xff, + .volatile_reg = raa215300_is_volatile_reg, + .cache_type = REGCACHE_FLAT, +}; + +static int raa215300_i2c_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + unsigned int *pmic_version; + struct device_node *np; + struct regmap *regmap; + int ret; + + pmic_version = devm_kzalloc(dev, sizeof(*pmic_version), GFP_KERNEL); + if (!pmic_version) + return -ENOMEM; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + return -EOPNOTSUPP; + + regmap = devm_regmap_init_i2c(client, &raa215300_regmap_config); + if (IS_ERR(regmap)) + return dev_err_probe(dev, PTR_ERR(regmap), + "regmap i2c init failed\n"); + + ret = regmap_read(regmap, RAA215300_HW_REV, pmic_version); + if (ret < 0) + return dev_err_probe(dev, ret, "HW rev read failed\n"); + + dev_set_drvdata(dev, pmic_version); + dev_dbg(dev, "RAA215300 PMIC version 0x%04x\n", *pmic_version); + + /* Enable RTC block */ + np = of_parse_phandle(dev->of_node, "renesas,raa215300-rtc", 0); + if (np) + regmap_update_bits(regmap, RAA215300_REG_BLOCK_EN, + RAA215300_REG_BLOCK_EN_RTC_EN, + RAA215300_REG_BLOCK_EN_RTC_EN); + + of_node_put(np); + + return 0; +} + +static const struct of_device_id raa215300_dt_match[] = { + { .compatible = "renesas,raa215300" }, + { /* Sentinel */ } +}; +MODULE_DEVICE_TABLE(of, raa215300_dt_match); + +static struct i2c_driver raa215300_i2c_driver = { + .driver = { + .name = "raa215300", + .of_match_table = raa215300_dt_match, + }, + .probe_new = raa215300_i2c_probe, +}; + +module_i2c_driver(raa215300_i2c_driver); + +MODULE_DESCRIPTION("Renesas RAA215300 PMIC driver"); +MODULE_AUTHOR("Fabrizio Castro "); +MODULE_AUTHOR("Biju Das "); +MODULE_LICENSE("GPL"); +MODULE_SOFTDEP("post: rtc_isl1208"); From patchwork Wed May 3 08:46:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13229870 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E659FC77B7F for ; Wed, 3 May 2023 08:46:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229733AbjECIq3 (ORCPT ); Wed, 3 May 2023 04:46:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbjECIq2 (ORCPT ); Wed, 3 May 2023 04:46:28 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7127E49CA; Wed, 3 May 2023 01:46:26 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.99,246,1677510000"; d="scan'208";a="158019835" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 03 May 2023 17:46:26 +0900 Received: from localhost.localdomain (unknown [10.226.92.153]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id CCA6D41C6679; Wed, 3 May 2023 17:46:22 +0900 (JST) From: Biju Das To: Alessandro Zummo , Alexandre Belloni , Rob Herring , Krzysztof Kozlowski Cc: Biju Das , Trent Piepho , linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, Geert Uytterhoeven , Fabrizio Castro , linux-renesas-soc@vger.kernel.org Subject: [PATCH RFC 3/6] dt-bindings: rtc: isl1208: Convert to json-schema Date: Wed, 3 May 2023 09:46:05 +0100 Message-Id: <20230503084608.14008-4-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230503084608.14008-1-biju.das.jz@bp.renesas.com> References: <20230503084608.14008-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Convert the isl1208 RTC device tree binding documentation to json-schema. Update the example to match reality. Signed-off-by: Biju Das --- .../devicetree/bindings/rtc/isil,isl1208.txt | 38 ---------- .../devicetree/bindings/rtc/isil,isl1208.yaml | 74 +++++++++++++++++++ 2 files changed, 74 insertions(+), 38 deletions(-) delete mode 100644 Documentation/devicetree/bindings/rtc/isil,isl1208.txt create mode 100644 Documentation/devicetree/bindings/rtc/isil,isl1208.yaml diff --git a/Documentation/devicetree/bindings/rtc/isil,isl1208.txt b/Documentation/devicetree/bindings/rtc/isil,isl1208.txt deleted file mode 100644 index 51f003006f04..000000000000 --- a/Documentation/devicetree/bindings/rtc/isil,isl1208.txt +++ /dev/null @@ -1,38 +0,0 @@ -Intersil ISL1209/19 I2C RTC/Alarm chip with event in - -ISL12X9 have additional pins EVIN and #EVDET for tamper detection, while the -ISL1208 and ISL1218 do not. They are all use the same driver with the bindings -described here, with chip specific properties as noted. - -Required properties supported by the device: - - "compatible": Should be one of the following: - - "isil,isl1208" - - "isil,isl1209" - - "isil,isl1218" - - "isil,isl1219" - - "reg": I2C bus address of the device - -Optional properties: - - "interrupt-names": list which may contains "irq" and "evdet" - evdet applies to isl1209 and isl1219 only - - "interrupts": list of interrupts for "irq" and "evdet" - evdet applies to isl1209 and isl1219 only - - "isil,ev-evienb": Enable or disable internal pull on EVIN pin - Applies to isl1209 and isl1219 only - Possible values are 0 and 1 - Value 0 enables internal pull-up on evin pin, 1 disables it. - Default will leave the non-volatile configuration of the pullup - as is. - -Example isl1219 node with #IRQ pin connected to SoC gpio1 pin12 and #EVDET pin -connected to SoC gpio2 pin 24 and internal pull-up enabled in EVIN pin. - - isl1219: rtc@68 { - compatible = "isil,isl1219"; - reg = <0x68>; - interrupt-names = "irq", "evdet"; - interrupts-extended = <&gpio1 12 IRQ_TYPE_EDGE_FALLING>, - <&gpio2 24 IRQ_TYPE_EDGE_FALLING>; - isil,ev-evienb = <1>; - }; - diff --git a/Documentation/devicetree/bindings/rtc/isil,isl1208.yaml b/Documentation/devicetree/bindings/rtc/isil,isl1208.yaml new file mode 100644 index 000000000000..04d51887855f --- /dev/null +++ b/Documentation/devicetree/bindings/rtc/isil,isl1208.yaml @@ -0,0 +1,74 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/rtc/isil,isl1208.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Intersil ISL12{08,09,18,19} I2C RTC/Alarm chip + +maintainers: + - Biju Das + - Trent Piepho + +properties: + compatible: + oneOf: + - enum: + - isil,isl1208 + - isil,isl1209 + - isil,isl1218 + - isil,isl1219 + + reg: + maxItems: 1 + + interrupts: + minItems: 1 + maxItems: 2 + + interrupt-names: + items: + - const: irq + - const: evdet + + isil,ev-evienb: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [ 0, 1 ] + default: 0 + description: | + Enable or disable internal pull on EVIN pin: + <0> : Enable internal pull-up + <1> : Disable internal pull-up + +required: + - compatible + - reg + +allOf: + - $ref: rtc.yaml# + - if: + properties: + compatible: + contains: + enum: + - isil,isl1209 + - isil,isl1219 + then: + required: + - interrupts-extended + - interrupt-names + - isil,ev-evienb + +unevaluatedProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + rtc_twi: rtc@6f { + compatible = "isil,isl1208"; + reg = <0x6f>; + }; + }; From patchwork Wed May 3 08:46:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13229871 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD867C7EE26 for ; Wed, 3 May 2023 08:46:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229748AbjECIqd (ORCPT ); Wed, 3 May 2023 04:46:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjECIqc (ORCPT ); Wed, 3 May 2023 04:46:32 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 902624C21; Wed, 3 May 2023 01:46:30 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.99,246,1677510000"; d="scan'208";a="161494713" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 03 May 2023 17:46:30 +0900 Received: from localhost.localdomain (unknown [10.226.92.153]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id ACE1F41C6900; Wed, 3 May 2023 17:46:26 +0900 (JST) From: Biju Das To: Alessandro Zummo , Alexandre Belloni , Rob Herring , Krzysztof Kozlowski Cc: Biju Das , Geert Uytterhoeven , Magnus Damm , Trent Piepho , linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Fabrizio Castro Subject: [PATCH RFC 4/6] dt-bindings: rtc: isl1208: Document built-in RTC device on PMIC RAA215300 Date: Wed, 3 May 2023 09:46:06 +0100 Message-Id: <20230503084608.14008-5-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230503084608.14008-1-biju.das.jz@bp.renesas.com> References: <20230503084608.14008-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The Built-in RTC device found on PMIC RAA215300 is similar to the isl1208 IP. However, RTC is enabled by PMIC RAA215300 and the polarity of the external oscillator is determined by the PMIC revision. Document renesas,raa215300-isl1208 compatible and renesas,raa215300-pmic property to handle these differences. Signed-off-by: Biju Das --- .../devicetree/bindings/rtc/isil,isl1208.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Documentation/devicetree/bindings/rtc/isil,isl1208.yaml b/Documentation/devicetree/bindings/rtc/isil,isl1208.yaml index 04d51887855f..888a832ed1db 100644 --- a/Documentation/devicetree/bindings/rtc/isil,isl1208.yaml +++ b/Documentation/devicetree/bindings/rtc/isil,isl1208.yaml @@ -18,6 +18,7 @@ properties: - isil,isl1209 - isil,isl1218 - isil,isl1219 + - renesas,raa215300-isl1208 reg: maxItems: 1 @@ -40,6 +41,10 @@ properties: <0> : Enable internal pull-up <1> : Disable internal pull-up + renesas,raa215300-pmic: + $ref: /schemas/types.yaml#/definitions/phandle + description: phandle to the pmic device with isl1208 built-in RTC. + required: - compatible - reg @@ -58,6 +63,14 @@ allOf: - interrupts-extended - interrupt-names - isil,ev-evienb + - if: + properties: + compatible: + contains: + const: renesas,raa215300-isl1208 + then: + required: + - renesas,raa215300-pmic unevaluatedProperties: false From patchwork Wed May 3 08:46:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13229872 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EF5FC7EE26 for ; Wed, 3 May 2023 08:46:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229693AbjECIqg (ORCPT ); Wed, 3 May 2023 04:46:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbjECIqf (ORCPT ); Wed, 3 May 2023 04:46:35 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 97BA240CF; Wed, 3 May 2023 01:46:34 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.99,246,1677510000"; d="scan'208";a="158019849" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 03 May 2023 17:46:34 +0900 Received: from localhost.localdomain (unknown [10.226.92.153]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id D565341C6679; Wed, 3 May 2023 17:46:30 +0900 (JST) From: Biju Das To: Alessandro Zummo , Alexandre Belloni Cc: Biju Das , Geert Uytterhoeven , Magnus Damm , Lee Jones , linux-rtc@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Fabrizio Castro Subject: [PATCH RFC 5/6] rtc: isl1208: Add support for the built-in RTC on the PMIC RAA215300 Date: Wed, 3 May 2023 09:46:07 +0100 Message-Id: <20230503084608.14008-6-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230503084608.14008-1-biju.das.jz@bp.renesas.com> References: <20230503084608.14008-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The built-in RTC found on PMIC RAA215300 is the same as ISL1208. However, the external oscillator polarity is determined by the PMIC version. For eg: the PMIC version has inverted polarity for the external oscillator and the corresponding bit in RTC need to be inverted(XTOSCB). This info needs to be shared from PMIC driver to RTC driver, so that it can support all versions without any code changes. Add a new compatible renesas,raa215300-isl1208 to support RTC found on PMIC RAA215300 and renesas,raa215300-pmic property to support different versions. Signed-off-by: Biju Das --- drivers/rtc/rtc-isl1208.c | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c index 73cc6aaf9b8b..f4ea19691ac1 100644 --- a/drivers/rtc/rtc-isl1208.c +++ b/drivers/rtc/rtc-isl1208.c @@ -74,6 +74,7 @@ enum isl1208_id { TYPE_ISL1209, TYPE_ISL1218, TYPE_ISL1219, + TYPE_RAA215300_ISL1208, ISL_LAST_ID }; @@ -83,11 +84,13 @@ static const struct isl1208_config { unsigned int nvmem_length; unsigned has_tamper:1; unsigned has_timestamp:1; + unsigned has_pmic_parent:1; } isl1208_configs[] = { [TYPE_ISL1208] = { "isl1208", 2, false, false }, [TYPE_ISL1209] = { "isl1209", 2, true, false }, [TYPE_ISL1218] = { "isl1218", 8, false, false }, [TYPE_ISL1219] = { "isl1219", 2, true, true }, + [TYPE_RAA215300_ISL1208] = { "isl1208", 2, false, false, true }, }; static const struct i2c_device_id isl1208_id[] = { @@ -104,6 +107,10 @@ static const __maybe_unused struct of_device_id isl1208_of_match[] = { { .compatible = "isil,isl1209", .data = &isl1208_configs[TYPE_ISL1209] }, { .compatible = "isil,isl1218", .data = &isl1208_configs[TYPE_ISL1218] }, { .compatible = "isil,isl1219", .data = &isl1208_configs[TYPE_ISL1219] }, + { + .compatible = "renesas,raa215300-isl1208", + .data = &isl1208_configs[TYPE_RAA215300_ISL1208] + }, { } }; MODULE_DEVICE_TABLE(of, isl1208_of_match); @@ -166,6 +173,43 @@ isl1208_i2c_validate_client(struct i2c_client *client) return 0; } +static bool isl1208_is_xtosc_polarity_inverted(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct i2c_client *pmic_dev; + unsigned int *pmic_version; + struct device_node *np; + bool ret = false; + + np = of_parse_phandle(dev->of_node, "renesas,raa215300-pmic", 0); + if (np) + pmic_dev = of_find_i2c_device_by_node(np); + + of_node_put(np); + if (!pmic_dev) + return ret; + + pmic_version = dev_get_drvdata(&pmic_dev->dev); + /* External Oscillator polarity is inverted on revision 0x12 onwards */ + if (*pmic_version >= 0x12) + ret = true; + + put_device(&pmic_dev->dev); + + return ret; +} + +static int +isl1208_set_ext_osc_based_on_pmic_version(struct i2c_client *client, int rc) +{ + if (isl1208_is_xtosc_polarity_inverted(client)) + 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) { @@ -845,6 +889,12 @@ isl1208_probe(struct i2c_client *client) return rc; } + if (isl1208->config->has_pmic_parent) { + rc = isl1208_set_ext_osc_based_on_pmic_version(client, rc); + if (rc) + return rc; + } + if (rc & ISL1208_REG_SR_RTCF) dev_warn(&client->dev, "rtc power failure detected, " "please set clock.\n"); From patchwork Wed May 3 08:46:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13229873 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E73C1C77B7F for ; Wed, 3 May 2023 08:46:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229660AbjECIqi (ORCPT ); Wed, 3 May 2023 04:46:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbjECIqi (ORCPT ); Wed, 3 May 2023 04:46:38 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E2FE946AF; Wed, 3 May 2023 01:46:36 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.99,246,1677510000"; d="scan'208";a="158019857" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 03 May 2023 17:46:36 +0900 Received: from localhost.localdomain (unknown [10.226.92.153]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 30C5441C691B; Wed, 3 May 2023 17:46:33 +0900 (JST) From: Biju Das To: Rob Herring , Krzysztof Kozlowski Cc: Biju Das , Geert Uytterhoeven , Magnus Damm , linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, Fabrizio Castro Subject: [PATCH RFC 6/6] arm64: dts: renesas: rzg2l-smarc-som: Enable PMIC and built-in RTC Date: Wed, 3 May 2023 09:46:08 +0100 Message-Id: <20230503084608.14008-7-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230503084608.14008-1-biju.das.jz@bp.renesas.com> References: <20230503084608.14008-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Enable PMIC RAA215300 and the built-in RTC on the RZ/{G2L,V2L} SMARC EVK. Signed-off-by: Biju Das --- arch/arm64/boot/dts/renesas/rzg2l-smarc-som.dtsi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/arm64/boot/dts/renesas/rzg2l-smarc-som.dtsi b/arch/arm64/boot/dts/renesas/rzg2l-smarc-som.dtsi index fbbb4f03440b..c9805d76ebb0 100644 --- a/arch/arm64/boot/dts/renesas/rzg2l-smarc-som.dtsi +++ b/arch/arm64/boot/dts/renesas/rzg2l-smarc-som.dtsi @@ -351,3 +351,19 @@ &wdt1 { status = "okay"; timeout-sec = <60>; }; + +&i2c3 { + pmic: raa215300@12 { + compatible = "renesas,raa215300"; + reg = <0x12>; + + renesas,raa215300-rtc = <&rtc_raa215300>; + }; + + rtc_raa215300: rtc@6f { + compatible = "renesas,raa215300-isl1208"; + reg = <0x6f>; + + renesas,raa215300-pmic = <&pmic>; + }; +};