From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CC583C3DA4B for ; Wed, 17 Jul 2024 07:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=hYmLVYWXk1bMWnCbE/bbshFQAVmL1hOp1kfOD1hykXU=; b=YbaspXcaGfKPtRnrV/8si2rQYm VugibphwtIpI9iALdleN/39GnrIXb/BiTDApfcJWO0OhmcoYe5hMbuHi4F3+vH1uC4mvfOQa9EZqs /nLZXz+pxJuEQV4fzmTZUzFlyLnIRkjZrRBc+sondsgLpvUFsMGZXWRrRHiSLngMvqk1FB2xiUzVH ZXNPlHZAkY4izbwaNbLTUW3ftKgrwqIrPg3c/JskSGdTMpbGLWe/As6SnhidHoDT9i9cxi3+sIwxn LG0r3jMz4eAcOXb7iFXnS86Vb8rQuoNSKjFw3hWwY2Ad1FeR0obAm9eTNClK6u34Za8Bmxq63C0fy IwlzgTMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTzNG-0000000D196-0emU; Wed, 17 Jul 2024 07:46:54 +0000 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTzMu-0000000D14Z-3ucf for linux-arm-kernel@lists.infradead.org; Wed, 17 Jul 2024 07:46:34 +0000 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-52ea7d2a039so6777456e87.3 for ; Wed, 17 Jul 2024 00:46:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1721202391; x=1721807191; darn=lists.infradead.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=hYmLVYWXk1bMWnCbE/bbshFQAVmL1hOp1kfOD1hykXU=; b=cBv49gi3ZQsUExhk10jxCpBfYyJ3XEn/XJreGXvdjqdbvOrX8PsygRxzzSN4G5ZmTv L6nJOlMVxRfo4LuJysgpzLt9KOtVPDl22MWYwdlA2DwyihPS4XIRlDhQbhv1xLjblC+X dx1tmv4Gr7He4nyL1okgv0mz1bFe6Vcs0Qw8c8RsApWLwMj1PnO4zAfYSOzjDLa4k4M6 AV/7b1JhG3Gp56LFrBrLUPDKAtNeDH4UKtjuyPMo85rqazyVP/o7FfUROTBBVS6ZROVu hd1ATRwRz/p2jZyVPG2rsvlWqbyRlA8T/CT0aAqzHmCdc34US+bP0IX3/bPjzXCyNtno 1ZsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721202391; x=1721807191; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hYmLVYWXk1bMWnCbE/bbshFQAVmL1hOp1kfOD1hykXU=; b=IYbPhafWpId61kKO704vzAA27/5eb0j5xd0Y1pOIJLEx4hYWsb/m73a2wtYmmPR40a //+u9qQLSZHktoCLBzvmTZnsxuYvOPWXqtdpJ3WYSG3viL3Ms132HG8hAZb+bSGP5vzo XRk/eCnLbABGMMqWFpeVlOotgeEi3WkeO7mfbOCVg2pRMOIBp5f0oYUkG8ym2bg1J6dE cVNQ7Xt3C4cNlEtND7BmUvcI56gmIi14qy1R0MA2HH0VQoaZ6HklBEoEh9zW8P98NxXp exQR0fn3EKdvx00GXcdOkX+QCwMoQrhCTMmVn4DH+as67Cdfsvi+4FF/8hJMV3XmaHFA wkdA== X-Forwarded-Encrypted: i=1; AJvYcCU9wupgW/RgvXHq2TXKYbDQoftvsh62Lve1LqzYaaV1mlSe0KwkipnoUwUlbIf5er0iai4ytjqsLjb3Uy2FnPaxQMb31m3esqt4ZgYGva/yg2zMSE0= X-Gm-Message-State: AOJu0YyqqRCHmELnO3z7+IJ5NcM1NirEB3f9whvYqco7lu1aMEWTYNJm dPzbnC3phpe2e8DHTx0RtYo4ksb2thGMBXFWDFQFb38AK4Ai2lynL2f7gNkPxPyKqBA9n0pDtHX T X-Google-Smtp-Source: AGHT+IGszrXHx0KHBmy0iQwD3ICpkbfColejw+97LZhBsXwp+xoAEe4EMP07eMeEcMWmReOlcLiFBg== X-Received: by 2002:a05:6512:3a87:b0:52e:7ef1:7c6e with SMTP id 2adb3069b0e04-52ee5429389mr555426e87.51.1721202390445; Wed, 17 Jul 2024 00:46:30 -0700 (PDT) Received: from [192.168.50.4] ([82.78.167.171]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a5e9a809sm160194035e9.28.2024.07.17.00.46.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Jul 2024 00:46:29 -0700 (PDT) Message-ID: <40d1bb5b-f8ff-4fdc-a2b3-b51ca8b11c10@tuxon.dev> Date: Wed, 17 Jul 2024 10:46:28 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 02/11] mfd: renesas-vbattb: Add a MFD driver for the Renesas VBATTB IP Content-Language: en-US To: Biju Das , "lee@kernel.org" , "robh@kernel.org" , "krzk+dt@kernel.org" , "conor+dt@kernel.org" , "alexandre.belloni@bootlin.com" , "geert+renesas@glider.be" , "magnus.damm@gmail.com" , "mturquette@baylibre.com" , "sboyd@kernel.org" , "p.zabel@pengutronix.de" Cc: "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-rtc@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-clk@vger.kernel.org" , Claudiu Beznea References: <20240716103025.1198495-1-claudiu.beznea.uj@bp.renesas.com> <20240716103025.1198495-3-claudiu.beznea.uj@bp.renesas.com> From: claudiu beznea In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240717_004633_012691_E9ACBCFC X-CRM114-Status: GOOD ( 29.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, Biju, On 16.07.2024 14:07, Biju Das wrote: > Hi Claudiu, > >> -----Original Message----- >> From: Claudiu >> 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 >> >> 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 >> --- >> >> 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 >> +#include >> +#include >> +#include >> +#include >> + >> +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 "); >> +MODULE_DESCRIPTION("Renesas VBATTB driver"); MODULE_LICENSE("GPL"); >> -- >> 2.39.2 >> >