From: claudiu beznea <claudiu.beznea@tuxon.dev>
To: Biju Das <biju.das.jz@bp.renesas.com>,
"lee@kernel.org" <lee@kernel.org>,
"robh@kernel.org" <robh@kernel.org>,
"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
"conor+dt@kernel.org" <conor+dt@kernel.org>,
"alexandre.belloni@bootlin.com" <alexandre.belloni@bootlin.com>,
"geert+renesas@glider.be" <geert+renesas@glider.be>,
"magnus.damm@gmail.com" <magnus.damm@gmail.com>,
"mturquette@baylibre.com" <mturquette@baylibre.com>,
"sboyd@kernel.org" <sboyd@kernel.org>,
"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>
Cc: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-rtc@vger.kernel.org" <linux-rtc@vger.kernel.org>,
"linux-renesas-soc@vger.kernel.org"
<linux-renesas-soc@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-clk@vger.kernel.org" <linux-clk@vger.kernel.org>,
Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Subject: Re: [PATCH v2 02/11] mfd: renesas-vbattb: Add a MFD driver for the Renesas VBATTB IP
Date: Wed, 17 Jul 2024 10:46:28 +0300 [thread overview]
Message-ID: <40d1bb5b-f8ff-4fdc-a2b3-b51ca8b11c10@tuxon.dev> (raw)
In-Reply-To: <TY3PR01MB11346E71D18A145DA70441CF786A22@TY3PR01MB11346.jpnprd01.prod.outlook.com>
Hi, Biju,
On 16.07.2024 14:07, Biju Das wrote:
> Hi Claudiu,
>
>> -----Original Message-----
>> From: Claudiu <claudiu.beznea@tuxon.dev>
>> Sent: Tuesday, July 16, 2024 11:30 AM
>> Subject: [PATCH v2 02/11] mfd: renesas-vbattb: Add a MFD driver for the Renesas VBATTB IP
>>
>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>
>> Renesas VBATTB IP has logic to control the RTC clock, tamper detection and a small 128B memory. Add a
>> MFD driver to do the basic initialization of the VBATTB IP for the inner components to work.
>>
>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>> ---
>>
>> Changes in v2:
>> - none; this driver is new
>>
>> drivers/mfd/Kconfig | 8 ++++
>> drivers/mfd/Makefile | 1 +
>> drivers/mfd/renesas-vbattb.c | 78 ++++++++++++++++++++++++++++++++++++
>> 3 files changed, 87 insertions(+)
>> create mode 100644 drivers/mfd/renesas-vbattb.c
>>
>> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index bc8be2e593b6..df93e8b05065 100644
>> --- a/drivers/mfd/Kconfig
>> +++ b/drivers/mfd/Kconfig
>> @@ -1383,6 +1383,14 @@ config MFD_SC27XX_PMIC
>> This driver provides common support for accessing the SC27xx PMICs,
>> and it also adds the irq_chip parts for handling the PMIC chip events.
>>
>> +config MFD_RENESAS_VBATTB
>> + tristate "Renesas VBATTB driver"
>> + depends on (ARCH_RZG2L && OF) || COMPILE_TEST
>> + select MFD_CORE
>> + help
>> + Select this option to enable Renesas RZ/G3S VBATTB driver which
>> + provides support for the RTC clock, tamper detector and 128B SRAM.
>> +
>> config RZ_MTU3
>> tristate "Renesas RZ/G2L MTU3a core driver"
>> depends on (ARCH_RZG2L && OF) || COMPILE_TEST diff --git a/drivers/mfd/Makefile
>> b/drivers/mfd/Makefile index 02b651cd7535..cd2f27492df2 100644
>> --- a/drivers/mfd/Makefile
>> +++ b/drivers/mfd/Makefile
>> @@ -186,6 +186,7 @@ pcf50633-objs := pcf50633-core.o pcf50633-irq.o
>> obj-$(CONFIG_MFD_PCF50633) += pcf50633.o
>> obj-$(CONFIG_PCF50633_ADC) += pcf50633-adc.o
>> obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o
>> +obj-$(CONFIG_MFD_RENESAS_VBATTB) += renesas-vbattb.o
>> obj-$(CONFIG_RZ_MTU3) += rz-mtu3.o
>> obj-$(CONFIG_ABX500_CORE) += abx500-core.o
>> obj-$(CONFIG_MFD_DB8500_PRCMU) += db8500-prcmu.o
>> diff --git a/drivers/mfd/renesas-vbattb.c b/drivers/mfd/renesas-vbattb.c new file mode 100644 index
>> 000000000000..5d71565b8cbf
>> --- /dev/null
>> +++ b/drivers/mfd/renesas-vbattb.c
>> @@ -0,0 +1,78 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * VBATTB driver
>> + *
>> + * Copyright (C) 2024 Renesas Electronics Corp.
>> + */
>> +
>> +#include <linux/mod_devicetable.h>
>> +#include <linux/of_platform.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/pm_runtime.h>
>> +#include <linux/reset.h>
>> +
>> +static int vbattb_probe(struct platform_device *pdev) {
>> + struct device *dev = &pdev->dev;
>> + struct reset_control *rstc;
>> + int ret;
>> +
>> + rstc = devm_reset_control_array_get_exclusive(dev);
>> + if (IS_ERR(rstc))
>> + return PTR_ERR(rstc);
>> +
>> + ret = devm_pm_runtime_enable(dev);
>> + if (ret)
>> + return ret;
>> +
>> + ret = pm_runtime_resume_and_get(dev);
>> + if (ret)
>> + return ret;
>
> Maybe as an optimization drop pm calls and use "devm_clk_get_enabled"
> instead as it perfectly fits in this scenario??
VBATTB is still part of a PM domain. That needs to be enabled as well.
pm_runtime_* APIs takes care of both clock enable and power domain on
operations.
One thing to notice is that on RZ/G3S the VBATTB clock is CRITICAL (thus
enabled in the probe of the clock driver), the PM domain is always ON (and
also enabled by clock driver). We can get rid of pm_runtime_* at all for
RZ/G3S but I think it would be better to have it here as well for future
platforms and to emphasize from driver that these resources are needed by
the VBATTB. The same approach is used for other RZ/G2 drivers that
declares critical clocks/always-on domains (e.g. dma driver, IA55 driver).
Thank you,
Claudiu Beznea
>
>> +
>> + ret = reset_control_deassert(rstc);
>> + if (ret)
>> + goto rpm_put;
>> +
>> + platform_set_drvdata(pdev, rstc);
>> +
>> + ret = devm_of_platform_populate(dev);
>> + if (ret)
>> + goto reset_assert;
>> +
>> + return 0;
>> +
>> +reset_assert:
>> + reset_control_assert(rstc);
>> +rpm_put:
>> + pm_runtime_put(dev);
>> + return ret;
>> +}
>> +
>> +static void vbattb_remove(struct platform_device *pdev) {
>> + struct reset_control *rstc = platform_get_drvdata(pdev);
>> +
>> + reset_control_assert(rstc);
>> + pm_runtime_put(&pdev->dev);
>> +}
>> +
>> +static const struct of_device_id vbattb_match[] = {
>> + { .compatible = "renesas,r9a08g045-vbattb" },
>> + { /* sentinel */ },
>> +};
>> +MODULE_DEVICE_TABLE(of, vbattb_match);
>> +
>> +static struct platform_driver vbattb_driver = {
>> + .probe = vbattb_probe,
>> + .remove_new = vbattb_remove,
>> + .driver = {
>> + .name = "renesas-vbattb",
>> + .of_match_table = vbattb_match,
>> + },
>> +};
>> +module_platform_driver(vbattb_driver);
>> +
>> +MODULE_ALIAS("platform:renesas-vbattb");
>> +MODULE_AUTHOR("Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>");
>> +MODULE_DESCRIPTION("Renesas VBATTB driver"); MODULE_LICENSE("GPL");
>> --
>> 2.39.2
>>
>
next prev parent reply other threads:[~2024-07-17 7:47 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-16 10:30 [PATCH v2 00/11] Add RTC support for the Renesas RZ/G3S SoC Claudiu
2024-07-16 10:30 ` [PATCH v2 01/11] dt-bindings: mfd: renesas,r9a08g045-vbattb: Document VBATTB Claudiu
2024-07-23 2:17 ` Rob Herring
2024-07-23 7:10 ` claudiu beznea
2024-07-16 10:30 ` [PATCH v2 02/11] mfd: renesas-vbattb: Add a MFD driver for the Renesas VBATTB IP Claudiu
2024-07-16 11:00 ` Biju Das
2024-07-17 7:37 ` claudiu beznea
2024-07-17 8:07 ` Biju Das
2024-07-16 11:07 ` Biju Das
2024-07-17 7:46 ` claudiu beznea [this message]
2024-07-17 8:16 ` Biju Das
2024-07-16 19:29 ` Krzysztof Kozlowski
2024-07-17 7:47 ` claudiu beznea
2024-07-24 14:53 ` Lee Jones
2024-07-25 8:03 ` claudiu beznea
2024-07-16 10:30 ` [PATCH v2 03/11] clk: renesas: clk-vbattb: Add VBATTB clock driver Claudiu
2024-07-16 22:28 ` Stephen Boyd
2024-07-17 8:31 ` claudiu beznea
2024-07-18 0:39 ` Stephen Boyd
2024-07-18 14:41 ` claudiu beznea
2024-07-19 1:08 ` Stephen Boyd
2024-07-16 10:30 ` [PATCH v2 04/11] dt-bindings: rtc: renesas,rzg3s-rtc: Document the Renesas RTCA-3 IP Claudiu
2024-07-16 15:46 ` Conor Dooley
2024-07-16 10:30 ` [PATCH v2 05/11] rtc: renesas-rtca3: Add driver for RTCA-3 available on Renesas RZ/G3S SoC Claudiu
2024-07-19 3:28 ` kernel test robot
2024-07-16 10:30 ` [PATCH v2 06/11] arm64: dts: renesas: r9a08g045: Add VBATTB node Claudiu
2024-07-16 10:30 ` [PATCH v2 07/11] arm64: dts: renesas: r9a08g045: Add RTC node Claudiu
2024-07-16 10:30 ` [PATCH v2 08/11] arm64: dts: renesas: rzg3s-smarc-som: Enable VBATTB clock Claudiu
2024-07-16 10:30 ` [PATCH v2 09/11] arm64: dts: renesas: rzg3s-smarc-som: Enable RTC Claudiu
2024-07-16 10:30 ` [PATCH v2 10/11] arm64: defconfig: Enable VBATTB Claudiu
2024-07-16 10:30 ` [PATCH v2 11/11] arm64: defconfig: Enable Renesas RTCA-3 flag Claudiu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40d1bb5b-f8ff-4fdc-a2b3-b51ca8b11c10@tuxon.dev \
--to=claudiu.beznea@tuxon.dev \
--cc=alexandre.belloni@bootlin.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=claudiu.beznea.uj@bp.renesas.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=mturquette@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).