From patchwork Tue Jul 16 10:30:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13734275 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 511A0C3DA59 for ; Tue, 16 Jul 2024 10:31:48 +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: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wPLuLQoZENDdi//jkP+m+sJa9j1xpR49CY9yYB9V7TA=; b=wCv+VMTa2WokwPU3z47SJgrRDO VRnwlflmLq+u8VUEMWXjky94kbAb8H7iVyQhsCfxYbgaxLFVeyI9FLB48LjPSRAHAlMGbXfTSauQy J1nnsxiy3wkwbJqxlY7kBxA8tkse9b5ApxYg0TZVWY3O960WgK5BmIh0iSXVWIaP1/CGqP+EEwavr LrzFVQl38nGn4jyX+IQfF5D7lGE1ppfgxRhTxKdpJlw6QidEWPX/aX/ZEuqaiA2QGZXCf6G4Ctbqj C0bfXdi1oyvRxYZgEb2wx3YL2kTW1QIP6Fo8UtDLo6daz0FO30oyspfpRiKgdCIoap9j+lEgW5TLj l4B5HMKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTfT6-0000000A2of-0GIb; Tue, 16 Jul 2024 10:31:36 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTfSC-0000000A2Qr-3J9P for linux-arm-kernel@lists.infradead.org; Tue, 16 Jul 2024 10:30:42 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-427b4c621b9so10301215e9.1 for ; Tue, 16 Jul 2024 03:30:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1721125839; x=1721730639; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wPLuLQoZENDdi//jkP+m+sJa9j1xpR49CY9yYB9V7TA=; b=Z1KPLTfjVOyrpN3VOwHfbTRDqrUxXFJvNLb+6CWjCdM2aWuChjtklke0+N9oLMxTXd adUGYJUGmTFjy87GRQkTF0ejozVjOhaSuaZcDzuD6sfVdSd2aJwWlASCYsbGbauUxa+A B1h+QxeI0QFB8s7pF2VByiarIJx4CSq/ouOfrX9/X2rEX62F4+6dj3dhX8CdZLnyOGdE 1o+QDDQJZLEQflh2o2i6aQBWBHLown+4s9PvU0E/Ue3+Vmb6qbOEuOpQ4JgiqcRy9uO9 YztyBEYZbLxvYm2NWHKHL0+AUEVpsiA8AUerp8yCecWeC1dFtA9o5p02KDKd8LP1rcvz NRlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721125839; x=1721730639; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wPLuLQoZENDdi//jkP+m+sJa9j1xpR49CY9yYB9V7TA=; b=ATfTRIIoHpfLPpf0hxKQVOkc39M7fOhkldMT1oh/VenJjPT+F/ljC1yUqpYumYOGXx OSPO5a6RRhhwzgT+wIFlhFChacYd2GUaQNM65LyzRUc5neIykhCBfOWMcwr15L1n2qsz elmwPpKdt8b0z7LyqmcBI4jfuZEfsv+x0e+I3qfSWLGaSAwV8YIgKofScZ/TOGNV7pNP eleJ1HOyzUYCioiZPWEsh90bJ8gy0hj4EIhKzAIJSa5jPLieNmKm9QMFaHEqIjVNzUKc qgaXn+3+O+EQCJ1vysBoCBNoefu6ghvwEfhJrqQ6L50IiYTdsGDGH4piuR0MPXYqUi3t uPSQ== X-Forwarded-Encrypted: i=1; AJvYcCUaI/Gk2YQ/K8rKqMQmlIp6KAnvqiMu9ijyDuFBk+R59LtsP17DXpmcRIDmmPsYSX/4vSlZnmSdvPlSrdzGZq3Cg9/i1BrR9v1D9mQete+QNQvjbWE= X-Gm-Message-State: AOJu0YyC31oKU/4X0nBFNfHKAtg9iuVLVcIS8DiuMQkNCWXze7esYl9u Y8fFGutcKYT/C6Li4JVcq+elnqEey4l7FzW2cC6vM7ejaJXF8rhaDnuLQKGE7Tg= X-Google-Smtp-Source: AGHT+IHVW6yRfdgEc3IWW0j9GtIckJ7vtGhNTVh5Ka58Ken968QRPKCQQvNko4nwFp7mgOiOKSesPg== X-Received: by 2002:a05:600c:4e92:b0:426:5cee:4abc with SMTP id 5b1f17b1804b1-427ba691136mr12483235e9.20.1721125839410; Tue, 16 Jul 2024 03:30:39 -0700 (PDT) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.171]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a5e77488sm121546145e9.9.2024.07.16.03.30.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 03:30:38 -0700 (PDT) From: Claudiu X-Google-Original-From: Claudiu To: 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@tuxon.dev, Claudiu Beznea Subject: [PATCH v2 02/11] mfd: renesas-vbattb: Add a MFD driver for the Renesas VBATTB IP Date: Tue, 16 Jul 2024 13:30:16 +0300 Message-Id: <20240716103025.1198495-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240716103025.1198495-1-claudiu.beznea.uj@bp.renesas.com> References: <20240716103025.1198495-1-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240716_033040_859522_23F06D2F X-CRM114-Status: GOOD ( 22.67 ) 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 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); + + 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");