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 9AC7BC3DA5D for ; Thu, 25 Jul 2024 08:04:13 +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=4z2Uc1+f5cX84JLz/1h0gVqAuZCumfNxe++nghYRv/0=; b=UoSW8cMYQ0o8j1Xi18ZWoFdFxH w9AFghRvqf/9hGbeqphv/T5WhWaFc31ovhMPTnOGd7ItQDIPzP4Z1edVx1SGbpyfQZTqIsPbn2wAV NWkgqGC6a9RSxb1GB6bC8qX9zQzcd7ddr0OlROM3XVGlT3dqwePPZyDJD6+kFa4yh/SOUk36bb8qU RtqtlHJlmJNSiXL2bS8LmaWdoArn9EQipYxiJaG9Iym28XeLVxh6qjLQvhBB8myZGHhAZv99VRCx2 WUI0UaNtWM2eekx2PYCbnaw0/6piQXOmwwKErZG2JHLLxFlGZiz44UCG/65Foj2nhpcNB9z680ZeZ Cv1f01Vg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWtSA-00000000HMi-3zSQ; Thu, 25 Jul 2024 08:03:58 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWtRk-00000000HBu-3Xtb for linux-arm-kernel@lists.infradead.org; Thu, 25 Jul 2024 08:03:35 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-36868fcb919so339279f8f.2 for ; Thu, 25 Jul 2024 01:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1721894610; x=1722499410; 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=4z2Uc1+f5cX84JLz/1h0gVqAuZCumfNxe++nghYRv/0=; b=jFQV3zgKEkcfWnnU8bn+PGBNHWnXWk93GhPC90NA3Bmgup/0tbUqaxoETuuMVRLGxw EchKq2SsGK9CEfdJE5oZ5PjuGMRUqaUshi6oOhqC7y3fofZXXCKK1g7U8oEKmam171fl 99ud+MSXpSS2VsZZ8Xp5nWr1sgYyM83M9zGm/RiGIXVn4UFK0FHOVM4+h7JKFI8BXi+C tTL6iWYAlz6gm7XLy/JhnPla6OCcMoLXo6ZqeebSYo5cz5G51DQrSI/cMwl4NhzHr/1n Qw+9qJ2cVDxlIfXPP4XTTnhCumVacHB/onB1sPx4yAF5RONs+HClxocMXzOa0jnHwYpN 0tJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721894610; x=1722499410; 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=4z2Uc1+f5cX84JLz/1h0gVqAuZCumfNxe++nghYRv/0=; b=aHiyPOQgPC6WgXdD+/m3lSLqan/uUxotyem9YYDLyyrtngyhN2GBzn1K4fVhYveE6B 7wrRWKGFYKT25uFqytv8nWVSd4j96K5ZRbAxXDH50fQHTQfX0deR17uZDIqwEs+DcQUX FD3UZdLoW5kD0Z6yoddnyCLsKvpUioxwVnxnNG0lSusn7hp+V6+dlUIfbQsbqmTUvDA6 o6jVqWLOh+lyUJKwZUvYzcez6bv/lovk8MWm4GKgzytoIY3DZPtqRcLEFqNN/ROep901 KxRmLqugngciJUsR1QtvAfk6Jo6WeJtbwh7R+KdJgDIhBzrMjtuOsTIia+aisGwA7gE6 Nv2Q== X-Forwarded-Encrypted: i=1; AJvYcCVfQZM0/vYjNeLi8hLKnntXYaUmhZj0wHZV/gF59JzDn4sW2+cVWJoLlSL3GcvRvLojSltVIdJQ+zvLHyNvJ++5mLnYBzs18mWEJnZLM+HmL4Ym2dw= X-Gm-Message-State: AOJu0Yx+enugVqPoZF/AfW02IwCCjZT1HZOSuLz0cwjLnnZXA3/Bc4CM 994HK1w/Gl7n9SCe09omW7fValiXAFamgcIDwKmvjKHAuIULejv9GXPgSVR9oH4= X-Google-Smtp-Source: AGHT+IEdIMU7gNsMkl9HIcug6VPT3zrOREmSFi2MwfJIgxqpUobBXyo8Rbm7rnDHLGFwE6AXmCrkRQ== X-Received: by 2002:a5d:534b:0:b0:367:89fd:1e06 with SMTP id ffacd0b85a97d-36b31b08411mr1369965f8f.36.1721894610460; Thu, 25 Jul 2024 01:03:30 -0700 (PDT) Received: from [192.168.50.4] ([82.78.167.146]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367d9a2fsm1257331f8f.32.2024.07.25.01.03.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Jul 2024 01:03:30 -0700 (PDT) Message-ID: <80bbdca4-7f01-48d0-ab91-8847ef8ef1df@tuxon.dev> Date: Thu, 25 Jul 2024 11:03:27 +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: Lee Jones Cc: 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, 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> <20240724145340.GZ501857@google.com> From: claudiu beznea In-Reply-To: <20240724145340.GZ501857@google.com> 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-20240725_010333_027289_A422B166 X-CRM114-Status: GOOD ( 29.32 ) 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, Lee, On 24.07.2024 17:53, Lee Jones wrote: > On Tue, 16 Jul 2024, Claudiu wrote: > >> 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; >> + >> + ret = reset_control_deassert(rstc); >> + if (ret) >> + goto rpm_put; >> + >> + platform_set_drvdata(pdev, rstc); > > Where is this consumed? In vbattb_remove(). > >> + ret = devm_of_platform_populate(dev); > > > Which devices will this probe? In this version it is used by clock logic from VBATTB IP, modeled as individual device. A schema of the blocks controlled in the VBATTB IP can be found at [1] (please note that there is also the RTC mentioned there but because it is on the PD_VBATT always-on power domain (backed by battery); in fact, it is an individual device mapped at it's own address). Here: - the 32KHz-clock oscillator, mux (with XC, XBYP inputs), CGC are used in the cock driver (introduced in this series) - tamper detector module with gate controlled by TAMPICR1 being part of tamper detection logic (no driver for this ATM) - backup registers being the SRAM (tried locally with mmio-sram driver (drives/misc/sram.c)), subnode described with (for internal development): vbattb: vbattb@1005c000 { // ... backup_sram: sram@80 { compatible = "mmio-sram"; reg = <0 0x80 0 0x80>; clocks = <&cpg CPG_MOD R9A08G045_VBAT_BCLK>; clock-names = "bclk"; power-domains = <&cpg>; resets = <&cpg R9A08G045_VBAT_BRESETN>; no-memory-wc; #address-cells = <2>; #size-cells = <2>; ranges = <0 0 0 0x80 0 0x80>; pool@0 { reg = <0 0 0 0x80>; label = "sram-test"; export; }; }; }; My initial idea was to have logic blocks of the VBATTB IP grouped as devices (clock for the moment and for future, at least the small SRAM, if needed at some point). After the discussion with Stephen on clock driver I tend to give up this model. Please let me know if you have any hints on how to go forward. Thank you for your review, Claudiu Beznea [1] https://i2.paste.pics/RFKJ0.png?rand=Xq8w1RLDvZ > >> + 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 >> >