From nobody Mon Nov 25 03:04:33 2024 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EAAD1E285C for ; Wed, 30 Oct 2024 11:01:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286103; cv=none; b=GPj0hQLLsbhm9uCCIG4DCEiwe20C3LcogJGGyKLLhVRBqcFMf9rBfyTSgfphTQ1kGry80TpmThLUpQz2BB7k+uv5WcPAC//DUGgReiB37NZAHq9aKR36aehA/+UW7r8nue/W/DWtOkXbgp1vfS5o2Y3wAh0/eYhf8ibUZe/TAiU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286103; c=relaxed/simple; bh=YdpeMJoCXUJ1RxY/p6VhRloddkd3ds0I4meNGZvdr2k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bvIwerQdY87zI09IFRCAEyS4laTnQxIHRI4ZjWXh8lhs620wHT8ot7cp0XpoBQM1VhH0ksjxpdqvpJpfTjX/0kinIU8dpX1SPeKlQ7+OFYJP8zENPPjcrmIYSsAY2w5jU+TGARFP7KBET0SgHsTrFNGSg7xm9qZNyYDIbbZmD7o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=QB7wZK+m; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="QB7wZK+m" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4314c452180so4707175e9.0 for ; Wed, 30 Oct 2024 04:01:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1730286099; x=1730890899; darn=vger.kernel.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=VPAY99/b86NU6xxyFr+lv4xE3Qrx/qwWg87o/3GcG2k=; b=QB7wZK+m72eSZEqBQZqC7/5QzBtyZUzf2nyPO15xx4ZOM3z3pb4Jich1ZqJXwtdxER l/WU7wQBwc0OZ3TNWWy1Hw4gB2sMjhOyLdUm4pHlaHETN6/vVyct9hWeya7CE7gBMpn/ EIMr+NyaP+6nq1UV8B83UKuUbWoUxFUtvNDg6iJ0R6Rj5n30lotBaZ3d+Y19m+VqVd7V zj2EM97rUsjue8FLpOU5l+rlOxOXgyYVTNdvlfMpn5cmDcmQkVXGQ10KFheEmKG/+eZk oqSXooY6dDDSw4pnanD7FdTDKEwR5AS36nj+Qw2JYqhaH6+aN8XkkS3DGxeXXnaPETpp 5trA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730286099; x=1730890899; 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=VPAY99/b86NU6xxyFr+lv4xE3Qrx/qwWg87o/3GcG2k=; b=UoRulFs1BgcutmEy5L3xowBBpitScV6XQBXmU8cfr8LjH5I9kZ6izhmMS1sHyM0jeG 0ki3u7Pz7vlx6cunHsCMc3FinlibeaVKS3aFvOhZZW7QD6ZtZriceXtKuaw8jy8aZY6e 8gJtNcHjkNXMWJGCiO9O7zrqXNngacgzMOBNu56VMqvH3m/icCQb4+FQGmnvyaWXNEuS MOLa5anofzG7XuhyWxC0DQob82MAERuops6b9nON3rLRjoktC/PravzW6ru7qE9c48+b P8bX4FqbRMWpjMoXoJEGzeQsaN1af9FPXS0dipdqDcGAmTPgI0hXEyixT125kjQUCBAp O6ww== X-Forwarded-Encrypted: i=1; AJvYcCWkWysMDzeB7RWZpYeVkxlUYQ4gffW8uF6iLae6coN7dx3XwXWnLefNs8ZGWGd4CuMS14HY33NVIqcgctc=@vger.kernel.org X-Gm-Message-State: AOJu0YwYHJ7CRP4zVX6A7OPzFOcUBiB4BaD+dIPYkDqRfNQ+ett3Fq81 Fkqj0pt4nmekytINdFRM4uBp5MA4dSHQP5DKnmx7bAwChs4X5lkR2jLmvd5AQ/4= X-Google-Smtp-Source: AGHT+IEHPgxDfD5Fa5a5J0wxXIUzXwZQ07u3mw8zxEnQypPfCK1PseGSZb+5VYyckxdfvK6nA0eerQ== X-Received: by 2002:a05:600c:314e:b0:431:47e7:9f45 with SMTP id 5b1f17b1804b1-431bd8a09aamr15476845e9.11.1730286098704; Wed, 30 Oct 2024 04:01:38 -0700 (PDT) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.190]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd99edebsm17956935e9.45.2024.10.30.04.01.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 04:01:38 -0700 (PDT) From: Claudiu X-Google-Original-From: Claudiu To: geert+renesas@glider.be, mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, alexandre.belloni@bootlin.com, magnus.damm@gmail.com, p.zabel@pengutronix.de Cc: linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH v5 01/10] dt-bindings: clock: renesas,r9a08g045-vbattb: Document VBATTB Date: Wed, 30 Oct 2024 13:01:11 +0200 Message-Id: <20241030110120.332802-2-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> References: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea The VBATTB IP of the Renesas RZ/G3S SoC controls the clock for RTC, the tamper detector and a small general usage memory of 128B. The VBATTB controller controls the clock for the RTC on the Renesas RZ/G3S. The HW block diagram for the clock logic is as follows: +----------+ XC `\ RTXIN --->| |----->| \ +----+ VBATTCLK | 32K clock| | |----->|gate|-----------> | osc | XBYP | | +----+ RTXOUT --->| |----->| / +----------+ ,/ One could connect as input to this HW block either a crystal or an external clock device. This is board specific. After discussions w/ Stephen Boyd the clock tree associated with this hardware block was exported in Linux as: input-xtal xbyp xc mux vbattclk where: - input-xtal is the input clock (connected to RTXIN, RTXOUT pins) - xc, xbyp are mux inputs - mux is the internal mux - vbattclk is the gate clock that feeds in the end the RTC to allow selecting the input of the MUX though assigned-clock DT properties, using the already existing clock drivers and avoid adding other DT properties. This allows select the input of the mux based on the type of the connected input clock: - if the 32768 crystal is connected as input for the VBATTB, the input of the mux should be xc - if an external clock device is connected as input for the VBATTB the input of the mux should be xbyp Add bindings for the VBATTB controller. Reviewed-by: Geert Uytterhoeven Signed-off-by: Claudiu Beznea Reviewed-by: Krzysztof Kozlowski --- Changes in v5: - used spaces in the diagram from the patch description - added "This is board specific" in the board description to emphasize the usage of the assigned-clocks in the example - added default for quartz-load-femtofarads - collected tags Changes in v4: - squashed with patch "Add clock IDs for the VBATTB controller" from v3 - removed "oscillator" word from commit description - added assigned-clocks, assigned-clock-parents to the documentation example - used clock-controller for the node name - used "quartz-load-femtofarads" property for the load capacitance - renamed include/dt-bindings/clock/r9a08g045-vbattb.h to include/dt-bindings/clock/renesas,r9a08g045-vbattb.h Changes in v3: - moved the file to clock dt bindings directory as it is the only functionality supported at the moment; the other functionalities (tamper detector, SRAM) are offered though register spreaded though the address space of the VBATTB IP and not actually individual devices; the other functionalities are not planned to be supported soon and if they will be I think they fit better on auxiliary bus than MFD - dropped interrupt names as requested in the review process - dropped the inner node for clock controller - added #clock-cells - added rtx clock - updated description for renesas,vbattb-load-nanofarads - included dt-bindings/interrupt-controller/irq.h in examples section Changes in v2: - changed file name and compatible - updated title, description sections - added clock controller part documentation and drop dedicated file for it included in v1 - used items to describe interrupts, interrupt-names, clocks, clock-names, resets - dropped node labels and status - updated clock-names for clock controller to cope with the new logic on detecting the necessity to setup bypass .../clock/renesas,r9a08g045-vbattb.yaml | 84 +++++++++++++++++++ .../clock/renesas,r9a08g045-vbattb.h | 13 +++ 2 files changed, 97 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/renesas,r9a08g0= 45-vbattb.yaml create mode 100644 include/dt-bindings/clock/renesas,r9a08g045-vbattb.h diff --git a/Documentation/devicetree/bindings/clock/renesas,r9a08g045-vbat= tb.yaml b/Documentation/devicetree/bindings/clock/renesas,r9a08g045-vbattb.= yaml new file mode 100644 index 000000000000..3707e4118949 --- /dev/null +++ b/Documentation/devicetree/bindings/clock/renesas,r9a08g045-vbattb.yaml @@ -0,0 +1,84 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/renesas,r9a08g045-vbattb.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas Battery Backup Function (VBATTB) + +description: + Renesas VBATTB is an always on powered module (backed by battery) which + controls the RTC clock (VBATTCLK), tamper detection logic and a small + general usage memory (128B). + +maintainers: + - Claudiu Beznea + +properties: + compatible: + const: renesas,r9a08g045-vbattb + + reg: + maxItems: 1 + + interrupts: + items: + - description: tamper detector interrupt + + clocks: + items: + - description: VBATTB module clock + - description: RTC input clock (crystal or external clock device) + + clock-names: + items: + - const: bclk + - const: rtx + + '#clock-cells': + const: 1 + + power-domains: + maxItems: 1 + + resets: + items: + - description: VBATTB module reset + + quartz-load-femtofarads: + description: load capacitance of the on board crystal + enum: [ 4000, 7000, 9000, 12500 ] + default: 4000 + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - '#clock-cells' + - power-domains + - resets + +additionalProperties: false + +examples: + - | + #include + #include + #include + #include + + clock-controller@1005c000 { + compatible =3D "renesas,r9a08g045-vbattb"; + reg =3D <0x1005c000 0x1000>; + interrupts =3D ; + clocks =3D <&cpg CPG_MOD R9A08G045_VBAT_BCLK>, <&vbattb_xtal>; + clock-names =3D "bclk", "rtx"; + assigned-clocks =3D <&vbattb VBATTB_MUX>; + assigned-clock-parents =3D <&vbattb VBATTB_XC>; + #clock-cells =3D <1>; + power-domains =3D <&cpg>; + resets =3D <&cpg R9A08G045_VBAT_BRESETN>; + quartz-load-femtofarads =3D <12500>; + }; diff --git a/include/dt-bindings/clock/renesas,r9a08g045-vbattb.h b/include= /dt-bindings/clock/renesas,r9a08g045-vbattb.h new file mode 100644 index 000000000000..67774eafad06 --- /dev/null +++ b/include/dt-bindings/clock/renesas,r9a08g045-vbattb.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) + * + * Copyright (C) 2024 Renesas Electronics Corp. + */ +#ifndef __DT_BINDINGS_CLOCK_R9A08G045_VBATTB_H__ +#define __DT_BINDINGS_CLOCK_R9A08G045_VBATTB_H__ + +#define VBATTB_XC 0 +#define VBATTB_XBYP 1 +#define VBATTB_MUX 2 +#define VBATTB_VBATTCLK 3 + +#endif /* __DT_BINDINGS_CLOCK_R9A08G045_VBATTB_H__ */ --=20 2.39.2 From nobody Mon Nov 25 03:04:33 2024 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 056A91DA31F for ; Wed, 30 Oct 2024 11:01:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286104; cv=none; b=Er4gSuRu++l14YIdo8Xm8oiMxz0jd3cuxvs+LqUpKgypYQJx4GGWdfQWcPGzqeQ+m3k8smtATixnAsIn1MEkTpZ+JiTYpLJ3mtmviaMxyu8lYIsODrzCLEal4teIoiXCtv+jN4KFXNZJ3C+fA0Ty+klDDdZdaBAYed1Vxe8Iphw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286104; c=relaxed/simple; bh=BmdIaibnqlMskUSKL0DNaHvY6ItL8yLeys+bv/Ts46I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rtXF66jRAizMj0Unp5W4SEFXQ0c7OL1t3PPYGbk4yYwt9zh5XMhNBU30WM5MKyD13rBkizM/HtFW8Kiy+OZbq/5rjynC+o5HZv6CDjJlfGRs+qbg+x6xCufvmrrcqIET/IzNctUuEcFU7px0edzG6ODq2v/JE3f0kLLjXtTfmLc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=nLl/cCke; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="nLl/cCke" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-43167ff0f91so62177495e9.1 for ; Wed, 30 Oct 2024 04:01:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1730286100; x=1730890900; darn=vger.kernel.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=4zIqqwXla8XXFQks2xCDUhtmqZI6NDOV+FlaKIa//Ps=; b=nLl/cCkeuXU+yKlPGRjfPx4/s4488pBItGx5FAtD9mqGZiiWOmvOMi9XEbMmBzwOF7 njfJGAWDt1f1x4va8++DcRRr0qUzdpeLaozyqHtys1yNclkaPUJDON11m7wtyco9zpPJ iHoKPtxh96iozsimKQ1Q1WSTieVPvMn7VdEavPKjmrAEMAr86pTrhCUg7SgBC48FEz+I wrXceotnDLYlIezgOUSSTWNWhrGtEATLe9PucDX+ByLPqrPLBCD/fDizQ19/VS4hB7uh y0B/bUVD+mUReUm2PskngAO/Ycp44UPSsaex3j/nKCdLGeQ/auOGtpZX0gBJOkBCgZu9 rI1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730286100; x=1730890900; 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=4zIqqwXla8XXFQks2xCDUhtmqZI6NDOV+FlaKIa//Ps=; b=bbG8gyy7TKDLEcWgkrMnZZ9flkDAogdK2WUFPODOd90bAeaON3qBc2c8B/CiyyIcC/ Sy3aQrsP5ZPBp2cWDcQqDjIXy5nftQXIBg6B6097Bjsrmk3qJTZwLBUxv/XNVDM9KefB jZgOysJ92VDNTtQFyVazSSqZfClH+Epqh2C8YJsuHDwWdrOoa92JKczZVSiKYdZbWAPy LbO+rUkzQGrfDzzo6m5/RnkiCJvv7CIdRKVUcs5LmnRQ+69ybHk/PGkGBJB43d0w6lYT IZhTSL4WiVgrIG9ujlOxWYSMJ6IzzCi/qoepC7xnLlAd4m2pk9w7G8sw9QByehvPrchp YcNA== X-Forwarded-Encrypted: i=1; AJvYcCUhmGZAlg1tBaPYRFCNlbm8cQQrVkytkCEGW5zLcWkOtIa6MibTT+A5+chd3R2vePrlQkAGoDWhgwHpVnE=@vger.kernel.org X-Gm-Message-State: AOJu0YxKuYK/n18FGCfflzuygFG+dqTD2iMDWPQs/yv7p6Rpr29KmHZ1 Sr96R2b5UELLgsjfvV6ASXzF2WXa3AyP2b8ZIZNSB/l5juzs0MsKzmv5q7lgxuo= X-Google-Smtp-Source: AGHT+IEzFYp8eHXbfgCK6D2romhGEawaY5yFHitwbM0KqZrPl9MhxCwPdoh5AirYsRT0AM+eT9M2fw== X-Received: by 2002:a05:600c:3b16:b0:431:58bc:ad5e with SMTP id 5b1f17b1804b1-4319ad0b8a9mr120556035e9.28.1730286100253; Wed, 30 Oct 2024 04:01:40 -0700 (PDT) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.190]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd99edebsm17956935e9.45.2024.10.30.04.01.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 04:01:39 -0700 (PDT) From: Claudiu X-Google-Original-From: Claudiu To: geert+renesas@glider.be, mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, alexandre.belloni@bootlin.com, magnus.damm@gmail.com, p.zabel@pengutronix.de Cc: linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH v5 02/10] clk: linux/clk-provider.h: Add devm_clk_hw_register_gate_parent_hw() Date: Wed, 30 Oct 2024 13:01:12 +0200 Message-Id: <20241030110120.332802-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> References: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Add devm_clk_hw_register_gate_parent_hw() macro to allow registering devres managed gate clocks providing struct clk_hw object as parent. Reviewed-by: Geert Uytterhoeven Signed-off-by: Claudiu Beznea Acked-by: Stephen Boyd --- Changes in v5: - none Changes in v4: - collected tags Changes in v3: - none; this patch is new include/linux/clk-provider.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 75444e250a78..a49859ef3304 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -622,6 +622,24 @@ struct clk *clk_register_gate(struct device *dev, cons= t char *name, __devm_clk_hw_register_gate((dev), NULL, (name), (parent_name), NULL, \ NULL, (flags), (reg), (bit_idx), \ (clk_gate_flags), (lock)) +/** + * devm_clk_hw_register_gate_parent_hw - register a gate clock with the cl= ock + * framework + * @dev: device that is registering this clock + * @name: name of this clock + * @parent_hw: pointer to parent clk + * @flags: framework-specific flags for this clock + * @reg: register address to control gating of this clock + * @bit_idx: which bit in the register controls gating of this clock + * @clk_gate_flags: gate-specific flags for this clock + * @lock: shared register lock for this clock + */ +#define devm_clk_hw_register_gate_parent_hw(dev, name, parent_hw, flags, = \ + reg, bit_idx, clk_gate_flags, \ + lock) \ + __devm_clk_hw_register_gate((dev), NULL, (name), NULL, (parent_hw), \ + NULL, (flags), (reg), (bit_idx), \ + (clk_gate_flags), (lock)) /** * devm_clk_hw_register_gate_parent_data - register a gate clock with the * clock framework --=20 2.39.2 From nobody Mon Nov 25 03:04:33 2024 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F2331E47D0 for ; Wed, 30 Oct 2024 11:01:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286107; cv=none; b=ibJ0Izjr2ELIyi/LLS/TgQDKiliZCVt/wL1CqXN44CyHksca6FKYYGYmDDLRGFKXdcL8V+TGJNHg9uZ5eciaY/tpMBdMO7tw6IqUASj58hISpNn/s0gNKCXEoGYl0pVEFGjdiksjMetdT+01IZx1ycxWUrF0sa5Ct7CU0J8I9CE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286107; c=relaxed/simple; bh=XV/Qlyw5O0x2GBrEZ1EKh9SbkIyZCTJ3iMTVDkj+CCY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tZrKU6qb2ZwGiPcYeV6XAO9umxy5GmQ4Z4wmc29qSbFENtrjAy8NfW4V+KUsgod1Mn2AE4jWhK0pHrVd7r9wUWiBtvdS9Hl6yp3M0fMSmys+sXh/mm/brgmO81H2Vez88F4rg4odRCm6keAkqy26tlLAGjhuSFhon96iABl/pZs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=U6YqpcKC; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="U6YqpcKC" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-431548bd1b4so59884425e9.3 for ; Wed, 30 Oct 2024 04:01:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1730286102; x=1730890902; darn=vger.kernel.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=Q5jMJgoG95XOAacDcXbjb/TlnRn6Yww+ugS+rzM6glY=; b=U6YqpcKCDffc7cpo0dXE6U0Syton5VMfFqRfyH4LdlN2/fTlBDQjoRWKRtmlTLXEIt Cj/9IWh4tDl5lf6DSaKUv4ngoqiATu7EenazlJmEFLixM8ym7nzClWf4yDo/vZZeuwre csTY8uYfIwhpEILfLWhNRTS0s3d3ecJnHuZB/fFZoL0nT1Q3Xdw/1rRxF8PakUcsVa7+ anqUmu4AfmdiRaF+M1myBCSIVtF3rV0Ksi/9YcLwVk34aPBZMSwjgDswb1TodQaqbw2p gMvYaGaKqKG3IwM0yA1tiX3lewlG0aq62np7Ka3aQ76AonMReWxxlRbSqCM81+2tl3On w18Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730286102; x=1730890902; 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=Q5jMJgoG95XOAacDcXbjb/TlnRn6Yww+ugS+rzM6glY=; b=bdheKXVTErIXFvRKrseOEfrDgRlt62tLh0A0Igfs803ymIWo3XHQDFxTxM+42ng5Ka zCk/q/a9YUFgEh1Bu19Y8CpjpP6+2KyZqyRxp0T2loaYCabei8iK9eRYRDHOnxE8cU7k nkgDMCjaGXmjQZLky/GQE//Z5d1UoYrAsDq8zi/VhX7WSeyK4wqIaYyqJNSrgkPN81Cp tz+uaaZzvOww+LpxSLg0AfHN2Im6vbOknUAs8euVffIky72O0X/24yRhMqAl6oGKWFnP MGkuSXIM7OnLIp2lc82Q3kgIUzws9cjdiDH/Lmf39/NGkvP3xe6kBSI42RjUwHIcZJEL 5EjA== X-Forwarded-Encrypted: i=1; AJvYcCWllE1eAI4peBLE7EFH4taHKrUFF2ENyeuemiAU1blj2Kv0edWtsEZ8cjVZfO9wsAzh/ybBAM3lG8g2n+Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yz8gAKQ45Kfo8/Ot3kRELdKyjcMsn6yBAsGylSFGSuR5TPysqrk EfIFLUPH1QFSVBqh15NnZm3lk+wimlU1NaQxNvw1YFa5z0Ow7cfIeDqFoWV0bUI= X-Google-Smtp-Source: AGHT+IFmFwJJ0ufsoUOu1khJaP/6/a9dAYPQCY28++3H8CGwqztdgu3NntxDTlQgRgR/516shIZFpA== X-Received: by 2002:a05:600c:35d3:b0:42c:c401:6d8b with SMTP id 5b1f17b1804b1-4319ac7832dmr131351465e9.7.1730286101965; Wed, 30 Oct 2024 04:01:41 -0700 (PDT) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.190]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd99edebsm17956935e9.45.2024.10.30.04.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 04:01:41 -0700 (PDT) From: Claudiu X-Google-Original-From: Claudiu To: geert+renesas@glider.be, mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, alexandre.belloni@bootlin.com, magnus.damm@gmail.com, p.zabel@pengutronix.de Cc: linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH v5 03/10] clk: renesas: clk-vbattb: Add VBATTB clock driver Date: Wed, 30 Oct 2024 13:01:13 +0200 Message-Id: <20241030110120.332802-4-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> References: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea The VBATTB IP of the Renesas RZ/G3S SoC controls the clock that is used by the RTC. The input to the VBATTB could be a 32KHz crystal or an external clock device. The HW block diagram for the clock generator is as follows: +----------+ XC `\ RTXIN --->| |----->| \ +----+ VBATTCLK | 32K clock| | |----->|gate|-----------> | osc | XBYP | | +----+ RTXOUT --->| |----->| / +----------+ , After discussions w/ Stephen Boyd the clock tree associated with this hardware block was exported in Linux as: vbattb-xtal xbyp xc mux vbattbclk where: - input-xtal is the input clock (connected to RTXIN, RTXOUT pins) - xc, xbyp are mux inputs - mux is the internal mux - vbattclk is the gate clock that feeds in the end the RTC to allow selecting the input of the MUX though assigned-clock DT properties, using the already existing clock drivers and avoid adding other DT properties. If the crystal is connected on RTXIN, RTXOUT pins the XC will be selected as mux input. If an external clock device is connected on RTXIN, RTXOUT pins the XBYP will be selected as mux input. The load capacitance of the internal crystal can be configured with renesas,vbattb-load-nanofarads DT property. Reviewed-by: Geert Uytterhoeven Signed-off-by: Claudiu Beznea --- Changes in v5: - collected tags Changes in v4: - dropped oscillator from patch description - s/on-board/internal in patch description - updated dt-binding included file name in the driver as it has been renamed to include/dt-bindings/clock/renesas,r9a08g045-vbattb.h - dropped the "_BIT" from driver macros - used "quartz-load-femtofarads" dt property instead of adding a new one - register the "vbattclk" as critical clock as this feeds the RTC counter logic and it needs to stay on from the moment the RTC is configured; along with it, added a comment to express this. Changes in v3: - updated patch description - dropped dependency on MFD_RENESAS_VBATTB as now there is no driver built under this flag - dropped include/clk.h - added pm_runtime and reset control support - updated register offsets - registered 4 clocks: xc, xbyp, mux, vbattclk using generic clock drivers - added MODULE_DEVICE_TABLE() Changes in v2: - updated patch description - added vendor name in Kconfig flag - used cleanup.h lock helpers - dropped the MFD code - updated registers offsets - added vbattb_clk_update_bits() and used it where possible - added vbattb_clk_need_bypass() to detect the bypass setup necessity - changed the compatible and driver names drivers/clk/renesas/Kconfig | 4 + drivers/clk/renesas/Makefile | 1 + drivers/clk/renesas/clk-vbattb.c | 205 +++++++++++++++++++++++++++++++ 3 files changed, 210 insertions(+) create mode 100644 drivers/clk/renesas/clk-vbattb.c diff --git a/drivers/clk/renesas/Kconfig b/drivers/clk/renesas/Kconfig index 76791a1c50ac..4e835a3f1ab4 100644 --- a/drivers/clk/renesas/Kconfig +++ b/drivers/clk/renesas/Kconfig @@ -237,6 +237,10 @@ config CLK_RZV2H bool "RZ/V2H(P) family clock support" if COMPILE_TEST select RESET_CONTROLLER =20 +config CLK_RENESAS_VBATTB + bool "Renesas VBATTB clock controller" + select RESET_CONTROLLER + # Generic config CLK_RENESAS_CPG_MSSR bool "CPG/MSSR clock support" if COMPILE_TEST diff --git a/drivers/clk/renesas/Makefile b/drivers/clk/renesas/Makefile index 23d2e26051c8..82efaa835ac7 100644 --- a/drivers/clk/renesas/Makefile +++ b/drivers/clk/renesas/Makefile @@ -53,3 +53,4 @@ obj-$(CONFIG_CLK_RZV2H) +=3D rzv2h-cpg.o obj-$(CONFIG_CLK_RENESAS_CPG_MSSR) +=3D renesas-cpg-mssr.o obj-$(CONFIG_CLK_RENESAS_CPG_MSTP) +=3D clk-mstp.o obj-$(CONFIG_CLK_RENESAS_DIV6) +=3D clk-div6.o +obj-$(CONFIG_CLK_RENESAS_VBATTB) +=3D clk-vbattb.o diff --git a/drivers/clk/renesas/clk-vbattb.c b/drivers/clk/renesas/clk-vba= ttb.c new file mode 100644 index 000000000000..ff9d1ead455c --- /dev/null +++ b/drivers/clk/renesas/clk-vbattb.c @@ -0,0 +1,205 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * VBATTB clock driver + * + * Copyright (C) 2024 Renesas Electronics Corp. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define VBATTB_BKSCCR 0x1c +#define VBATTB_BKSCCR_SOSEL 6 +#define VBATTB_SOSCCR2 0x24 +#define VBATTB_SOSCCR2_SOSTP2 0 +#define VBATTB_XOSCCR 0x30 +#define VBATTB_XOSCCR_OUTEN 16 +#define VBATTB_XOSCCR_XSEL GENMASK(1, 0) +#define VBATTB_XOSCCR_XSEL_4_PF 0x0 +#define VBATTB_XOSCCR_XSEL_7_PF 0x1 +#define VBATTB_XOSCCR_XSEL_9_PF 0x2 +#define VBATTB_XOSCCR_XSEL_12_5_PF 0x3 + +/** + * struct vbattb_clk - VBATTB clock data structure + * @base: base address + * @lock: lock + */ +struct vbattb_clk { + void __iomem *base; + spinlock_t lock; +}; + +static int vbattb_clk_validate_load_capacitance(u32 *reg_lc, u32 of_lc) +{ + switch (of_lc) { + case 4000: + *reg_lc =3D VBATTB_XOSCCR_XSEL_4_PF; + break; + case 7000: + *reg_lc =3D VBATTB_XOSCCR_XSEL_7_PF; + break; + case 9000: + *reg_lc =3D VBATTB_XOSCCR_XSEL_9_PF; + break; + case 12500: + *reg_lc =3D VBATTB_XOSCCR_XSEL_12_5_PF; + break; + default: + return -EINVAL; + } + + return 0; +} + +static void vbattb_clk_action(void *data) +{ + struct device *dev =3D data; + struct reset_control *rstc =3D dev_get_drvdata(dev); + int ret; + + ret =3D reset_control_assert(rstc); + if (ret) + dev_err(dev, "Failed to de-assert reset!"); + + ret =3D pm_runtime_put_sync(dev); + if (ret < 0) + dev_err(dev, "Failed to runtime suspend!"); + + of_clk_del_provider(dev->of_node); +} + +static int vbattb_clk_probe(struct platform_device *pdev) +{ + struct device_node *np =3D pdev->dev.of_node; + struct clk_parent_data parent_data =3D {}; + struct clk_hw_onecell_data *clk_data; + const struct clk_hw *parent_hws[2]; + struct device *dev =3D &pdev->dev; + struct reset_control *rstc; + struct vbattb_clk *vbclk; + u32 of_lc, reg_lc; + struct clk_hw *hw; + /* 4 clocks are exported: VBATTB_XC, VBATTB_XBYP, VBATTB_MUX, VBATTB_VBAT= TCLK. */ + u8 num_clks =3D 4; + int ret; + + /* Default to 4pF as this is not needed if external clock device is conne= cted. */ + of_lc =3D 4000; + of_property_read_u32(np, "quartz-load-femtofarads", &of_lc); + + ret =3D vbattb_clk_validate_load_capacitance(®_lc, of_lc); + if (ret) + return ret; + + vbclk =3D devm_kzalloc(dev, sizeof(*vbclk), GFP_KERNEL); + if (!vbclk) + return -ENOMEM; + + clk_data =3D devm_kzalloc(dev, struct_size(clk_data, hws, num_clks), GFP_= KERNEL); + if (!clk_data) + return -ENOMEM; + clk_data->num =3D num_clks; + + vbclk->base =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(vbclk->base)) + return PTR_ERR(vbclk->base); + + ret =3D devm_pm_runtime_enable(dev); + if (ret) + return ret; + + rstc =3D devm_reset_control_get_shared(dev, NULL); + if (IS_ERR(rstc)) + return PTR_ERR(rstc); + + ret =3D pm_runtime_resume_and_get(dev); + if (ret) + return ret; + + ret =3D reset_control_deassert(rstc); + if (ret) { + pm_runtime_put_sync(dev); + return ret; + } + + dev_set_drvdata(dev, rstc); + ret =3D devm_add_action_or_reset(dev, vbattb_clk_action, dev); + if (ret) + return ret; + + spin_lock_init(&vbclk->lock); + + parent_data.fw_name =3D "rtx"; + hw =3D devm_clk_hw_register_gate_parent_data(dev, "xc", &parent_data, 0, + vbclk->base + VBATTB_SOSCCR2, + VBATTB_SOSCCR2_SOSTP2, + CLK_GATE_SET_TO_DISABLE, &vbclk->lock); + if (IS_ERR(hw)) + return PTR_ERR(hw); + clk_data->hws[VBATTB_XC] =3D hw; + + hw =3D devm_clk_hw_register_fixed_factor_fwname(dev, np, "xbyp", "rtx", 0= , 1, 1); + if (IS_ERR(hw)) + return PTR_ERR(hw); + clk_data->hws[VBATTB_XBYP] =3D hw; + + parent_hws[0] =3D clk_data->hws[VBATTB_XC]; + parent_hws[1] =3D clk_data->hws[VBATTB_XBYP]; + hw =3D devm_clk_hw_register_mux_parent_hws(dev, "mux", parent_hws, 2, 0, + vbclk->base + VBATTB_BKSCCR, + VBATTB_BKSCCR_SOSEL, + 1, 0, &vbclk->lock); + if (IS_ERR(hw)) + return PTR_ERR(hw); + clk_data->hws[VBATTB_MUX] =3D hw; + + /* Set load capacitance before registering the VBATTCLK clock. */ + scoped_guard(spinlock, &vbclk->lock) { + u32 val =3D readl_relaxed(vbclk->base + VBATTB_XOSCCR); + + val &=3D ~VBATTB_XOSCCR_XSEL; + val |=3D reg_lc; + writel_relaxed(val, vbclk->base + VBATTB_XOSCCR); + } + + /* This feeds the RTC counter clock and it needs to stay on. */ + hw =3D devm_clk_hw_register_gate_parent_hw(dev, "vbattclk", hw, CLK_IS_CR= ITICAL, + vbclk->base + VBATTB_XOSCCR, + VBATTB_XOSCCR_OUTEN, 0, + &vbclk->lock); + + if (IS_ERR(hw)) + return PTR_ERR(hw); + clk_data->hws[VBATTB_VBATTCLK] =3D hw; + + return of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_data); +} + +static const struct of_device_id vbattb_clk_match[] =3D { + { .compatible =3D "renesas,r9a08g045-vbattb" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, vbattb_clk_match); + +static struct platform_driver vbattb_clk_driver =3D { + .driver =3D { + .name =3D "renesas-vbattb-clk", + .of_match_table =3D vbattb_clk_match, + }, + .probe =3D vbattb_clk_probe, +}; +module_platform_driver(vbattb_clk_driver); + +MODULE_DESCRIPTION("Renesas VBATTB Clock Driver"); +MODULE_AUTHOR("Claudiu Beznea "); +MODULE_LICENSE("GPL"); --=20 2.39.2 From nobody Mon Nov 25 03:04:33 2024 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5478F1E4938 for ; Wed, 30 Oct 2024 11:01:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286108; cv=none; b=sxNx59IJQGuLYGZOVbzqJLX4YVmjCFzzwsUYMUiUFMvCOpAMmd4IlGsLTbjBkBYLEKsFRcdUg1CLRucr6X/02VBsCMTSiGwVZOXK8pXQI2hcGZ2s9iNiq5Clnawp6qPrPCQIhEpzCzWTxY7pnceYdefLtPNoCm/5qcPxocM17To= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286108; c=relaxed/simple; bh=GzhYOIOjWWWkcnxKv/+WunfUEbU6v0yAgqFMhuJW65E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FhUeLiybIqgzjgm4odKLTd5NuTWQPQH46O1JCzTFngK0knnndIoLAOMpF1UZtzm5ThxxMtdHTuu+qGB+ee63mo7byLUhTo6adFeokVfu/knIW7RUWJFRE87ystoa9DNxazK7dRR6Yt5laAxJbpOwG7S06x4+jTSLQVPlQ0z/hsA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=fdW2T6ug; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="fdW2T6ug" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-431481433bdso62047925e9.3 for ; Wed, 30 Oct 2024 04:01:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1730286104; x=1730890904; darn=vger.kernel.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=C4QBNlB+d2PHxk6dWy4yzXj/lD/DoVJIDKguatDDGb4=; b=fdW2T6ugKpHYeb2S0hhZkw47wyu0c4aIb6hYbyV6anYa0nKhycayNVZxCWZk/fRLXU k+YHx7OHGajDh8VVBXsbGDGyRP2SuSHYp92Ym9XtCQYou5RhIJPuqXlITDnKUXlsvyBj ZOKN5Meg5jeqjD73g1ASPLG59ssYINR4gpzlnHcl//TYvkTuwyaFSWmplBErPOM6hvFz aeZrHIo+7lytEhRtqO8+KThOksuVUx+b3ex6RpZOuwrOPRPt9sh8mDrTcK6zDx70UtYk oAfZiJ7VaB7VOk418Qb6EELKespsE5kv7LhHqh6TpRbg037silXd3PD0gURMjEQO0s0P EBjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730286104; x=1730890904; 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=C4QBNlB+d2PHxk6dWy4yzXj/lD/DoVJIDKguatDDGb4=; b=JbKckXUSEoSr+pApXh609m12sPYj95IChJP0En+f/QQTfJGlfJmF4shQ1fARXvsHRV lIED4yq4ksRtn6ocT6kpz0gI896BqaGfe69cO1WXarME9gMa8MH/cx1dULth9Jw9xAnL S3tfLqU6zufe819r6+ak3kAq718WO5y3s8HVUEO7ppaoPbB4CcBnSX/rbz87hz4g8u7U gdeUIMaRAQ24NelwdA9s+qvtFC7EihDopFJ7RhYbK4957mB2EB9j1hyNip9+wooeiNgW lXAetR177g4n/ffWIWzmDDowMqyC5AhmSpRI8g1s589ClMN0ypWdleQVx+mC2w+3sl// 1i0g== X-Forwarded-Encrypted: i=1; AJvYcCUrCZohVgjxRsg4QAC77JEFsRE16M3dakXl58Ai5MBTraz7awwHYNZXFBr0vIbOxOJFUj2gR5vexS88F+k=@vger.kernel.org X-Gm-Message-State: AOJu0Yyuh2sBbdeHgi5AuFuGUToFcYlmT6yJG1wzW2GkTmqliL82f+ZG d/4c5n5zC2qBEQWcAhdSzkVi9nahVV9pp2zxZdtzo0ij5yjVBKuW36+FzViBzkQ= X-Google-Smtp-Source: AGHT+IH0M773hGU4oya6J/fuA+HUQZaFJdAlea6vN77xZ1FRNiRTnlZxHceEr+4/h6lEyss2Uuvwjw== X-Received: by 2002:a05:600c:1ca6:b0:431:52da:9d67 with SMTP id 5b1f17b1804b1-4319ac7435bmr135949865e9.3.1730286103671; Wed, 30 Oct 2024 04:01:43 -0700 (PDT) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.190]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd99edebsm17956935e9.45.2024.10.30.04.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 04:01:43 -0700 (PDT) From: Claudiu X-Google-Original-From: Claudiu To: geert+renesas@glider.be, mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, alexandre.belloni@bootlin.com, magnus.damm@gmail.com, p.zabel@pengutronix.de Cc: linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH v5 04/10] dt-bindings: rtc: renesas,rzg3s-rtc: Document the Renesas RTCA-3 IP Date: Wed, 30 Oct 2024 13:01:14 +0200 Message-Id: <20241030110120.332802-5-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> References: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Document the RTC IP (RTCA-3) available on the Renesas RZ/G3S SoC. The RTC IP available on Renesas RZ/V2H is almost identical with the one found on Renesas RZ/G3S (it misses the time capture functionality which is not yet implemented on proposed driver). For this, added also a generic compatible that will be used at the moment as fallback for both RZ/G3S and RZ/V2H. Reviewed-by: Rob Herring (Arm) Signed-off-by: Claudiu Beznea Reviewed-by: Geert Uytterhoeven --- Changes in v5: - added back the #include in example section to fix the build error - kept the Rb tag from Rob; Rob, please let me know if you consider it otherwise Changes in v4: - collected tags - dropped the assigned-clocks, assigned-clock-parents properties from the example, along with r9a08g045-vbattb.h inclusion; these were moved to the VBATTB example as it fits better in there since these are related to the VBATTB but not to the RTC; Rob, I haven't dropped your Rb tag for this; please let me know if you consider it otherwise. Changes in v3: - added RTC bus clock, reset and power-domain; it has been detected by reverse engineering that RTC and VBATTB clock, reset and power domain are shared; HW manual doesn't mention it - updated example with these and with assigned-clock properties needed to configure the VBATTCLK MUX with proper parent - updated example section with dt-bindings/clock/r9a08g045-cpg.h and dt-bindings/clock/r9a08g045-vbattb.h includes - for all these, dropped Conor's Rb tag Changes in v2: - updated patch description and title - included reference to rtc.yaml - updated compatible list with a generic compatible as explained in patch description; with this the node in examples section has also been updated - used items to describe interrupts, interrupt-names, clock, clock-names - updated title section .../bindings/rtc/renesas,rz-rtca3.yaml | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 Documentation/devicetree/bindings/rtc/renesas,rz-rtca3.= yaml diff --git a/Documentation/devicetree/bindings/rtc/renesas,rz-rtca3.yaml b/= Documentation/devicetree/bindings/rtc/renesas,rz-rtca3.yaml new file mode 100644 index 000000000000..e70eeb66aa64 --- /dev/null +++ b/Documentation/devicetree/bindings/rtc/renesas,rz-rtca3.yaml @@ -0,0 +1,84 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/rtc/renesas,rz-rtca3.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas RTCA-3 Real Time Clock + +maintainers: + - Claudiu Beznea + +allOf: + - $ref: rtc.yaml# + +properties: + compatible: + items: + - enum: + - renesas,r9a08g045-rtca3 # RZ/G3S + - const: renesas,rz-rtca3 + + reg: + maxItems: 1 + + interrupts: + items: + - description: Alarm interrupt + - description: Periodic interrupt + - description: Carry interrupt + + interrupt-names: + items: + - const: alarm + - const: period + - const: carry + + clocks: + items: + - description: RTC bus clock + - description: RTC counter clock + + clock-names: + items: + - const: bus + - const: counter + + power-domains: + maxItems: 1 + + resets: + items: + - description: VBATTB module reset + +required: + - compatible + - reg + - interrupts + - interrupt-names + - clocks + - clock-names + - power-domains + - resets + +additionalProperties: false + +examples: + - | + #include + #include + #include + #include + + rtc@1004ec00 { + compatible =3D "renesas,r9a08g045-rtca3", "renesas,rz-rtca3"; + reg =3D <0x1004ec00 0x400>; + interrupts =3D , + , + ; + interrupt-names =3D "alarm", "period", "carry"; + clocks =3D <&cpg CPG_MOD R9A08G045_VBAT_BCLK>, <&vbattclk VBATTB_V= BATTCLK>; + clock-names =3D "bus", "counter"; + power-domains =3D <&cpg>; + resets =3D <&cpg R9A08G045_VBAT_BRESETN>; + }; --=20 2.39.2 From nobody Mon Nov 25 03:04:33 2024 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 689401E5733 for ; Wed, 30 Oct 2024 11:01:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286112; cv=none; b=p3AyI4SZXcpvHRtvR9coIDKcDEctuOq2AUqGcPAqQhPj/JNNLzKntszaZlHV+gfxeh4sLl5I53Du8cvrJ9r+B0GTV/w/S8PLuvOpOb7vtZG0U22S9g6s9IozStBBdZmmjwM+QjAQXtYLuHnmyrzhl8MSX3EpK+2yyyyO4iqPPCU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286112; c=relaxed/simple; bh=U8KTmky3jV2n2tn8j+2EJLuzFrRxFtml+LDKIJCQDVk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=aLg+755uFSvdvpymQIwDHbzjjZ1tVFz/DrQfC/ucuynX6APxhS36hoWufTiWVhOa8/LWL+6ySuAJlzNzL0XMFO5EB5siDEDjo7SlbLc2p0/0rcKNmYdXdW8pws/3Kbg+/kVHBPsRF1VccBbvRJLVrfcWSdDD8tnyOPK+QdeBX+s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=qgeRJhq6; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="qgeRJhq6" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-431688d5127so60797025e9.0 for ; Wed, 30 Oct 2024 04:01:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1730286106; x=1730890906; darn=vger.kernel.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=wI4oTi7KNsCPu/jACMk+3l9Mw/gBU8QXyrga3CqIbo0=; b=qgeRJhq6ySDpjmxVUDogAt8iq5WZM8KYgeQzSdX21AQJNQ2mSpSdRCQh1bnZC6c+hu zAeEZBHig+/wf3TfyKljV4M+fdfheFFsuai9aazjFE7/tF9k9UV9Jo45HuY8NELv9jNg RoCk31xkl9OULieqAkGPGlh0ZpfW3fglgJ+9NMyuCcmu9dgOsTWA9JQIGs9GwGyAcBs3 nsE47Q2Volu9TOG4cHWsNKeBqDigqYm/QryRfHmwa0QRhjUwIoD6SvEVv0wtCZw5+q4g wEND2d5foFRu85vHpbYYVaWDcqRXs16TtNruudC93DCaBCNKMhK03iTXmvGG8ekUUtrH 66Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730286106; x=1730890906; 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=wI4oTi7KNsCPu/jACMk+3l9Mw/gBU8QXyrga3CqIbo0=; b=iQUjfISO7tb/KRp2CAQ9utPNEr87iWAs7b10WiGPXkdcEg7tzfdsv9uiSUcWE5KmtY naj7fjKkn6I1kyt4VP64bpoTz4RiSkjzHV7RZsenUIegb7BSalYyuH5m7iBi3+DMe1vs QwLQRBlPXlC42MFZKPmmrquWy7muw7hPsslCwH0aTgVHLTkIBwqbb/F0mecRXlBYDRzZ CvgQ/iLgLWbovoxN3POI1bW2PwAv7TeL3CJIWZ7RHUHgw9YO4WDkfyg+yXqYrL57MnWI VKe/4bTAwJXtVqVaPZ/neWpHVhUC015014Z21bzTQ18r6bD+99/gDWmfCaO5f2of9xyq p7vw== X-Forwarded-Encrypted: i=1; AJvYcCX+yjjfY7KrEJBh/g8CiQrdZY2yXpMRqEmS9MM5bbg7TSNBAJH+/C3llMVXX0DaWfoPbLasiUecuKvJ7fg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw7ijXMacM1zIQEydFQ3/LAc2tx6LUcgTCXwM+Cwfnjpl++ryaU IY1jQBEGFh0V5VjDEB7/bvnATnTeMr6OsZjQd4ktucJPdEV3qflj60DQUEyz/5k= X-Google-Smtp-Source: AGHT+IH/8vd1HYap/O8fMpStUO34YwrMPFLRvkYIUvRoQ/yl0Mcn8A5rWIKKjlooG8uRW4OcEAwiqg== X-Received: by 2002:a05:600c:3586:b0:431:4c14:abf4 with SMTP id 5b1f17b1804b1-4319acac8dbmr146728925e9.14.1730286105459; Wed, 30 Oct 2024 04:01:45 -0700 (PDT) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.190]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd99edebsm17956935e9.45.2024.10.30.04.01.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 04:01:45 -0700 (PDT) From: Claudiu X-Google-Original-From: Claudiu To: geert+renesas@glider.be, mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, alexandre.belloni@bootlin.com, magnus.damm@gmail.com, p.zabel@pengutronix.de Cc: linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, claudiu.beznea@tuxon.dev, Claudiu Beznea , kernel test robot Subject: [PATCH v5 05/10] rtc: renesas-rtca3: Add driver for RTCA-3 available on Renesas RZ/G3S SoC Date: Wed, 30 Oct 2024 13:01:15 +0200 Message-Id: <20241030110120.332802-6-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> References: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Claudiu Beznea The RTC IP (RTCA-3) available on the Renesas RZ/G3S SoC has calendar count mode and binary count mode (selectable though RCR2.CNTMD) capabilities, alarm capabilities, clock error correction capabilities. It can generate alarm, period, carry interrupts. Add a driver for RTCA-3 IP. The driver implements calendar count mode (as the conversion b/w RTC and system time is simpler, done with bcd2bin(), bin2bcd()), read and set time, read and set alarm, read and set an offset. Signed-off-by: Claudiu Beznea Reported-by: kernel test robot --- Changes in v5: - populate struct platform_driver::remove instead of struct platform_driver::remove_new Changes in v4: - disabled all interrupts on the initial setup, function rtca3_initial_setu= p(); RTCA3_RCR1_PIE interrupt (disabled in this series) is used on alarm setup. - added a comment about the counter clock, when requesting it, to let others know that this should stay on for the full lifetime of the RTC - used RTC_TIMESTAMP_BEGIN_2000 and RTC_TIMESTAMP_BEGIN_2099 - added a comment on rtca3_remove() to mention that the RTC cannot power on the system Changes in v3: - added pm runtime and reset control support; probe() was changed and rtca3_action() was added as for cleanup; VBATTB and RTC shares the clock, reset and PM domain; hw manual doesn't specifies this; it has been detected though reverse engineering - dropped clk member of struct rtca3_priv as it is used only in probe() - renamed rtca3_alarm_irq_enable_helper() to rtca3_alarm_irq_set_helper() and used it all over the places - fixed the issue: Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202407191156.wJPjHtKG-lkp@int= el.com/ - removed __maybe_unused from suspend/resume function and use DEFINE_SIMPLE_DEV_PM_OPS() along with pm_ptr() Changes in v2: - used cleanup.h helpers for locking - updated the MAINTAINERS entry with the new name for RTCA-3 documentation file and a new title (from "RENESAS RZ/G3S RTC DRIVER" to "RENESAS RTCA-3 RTC DRIVER") - used 24 hours mode - changed startup sequence (rtca3_initial_setup()) to avoid stopping the RTC if it's already configured - updated the RTC range to 2000-2099 - updated the compatible with the generic one (renesas,rz-rtca3) in the idea the driver will be also used by the RZ/V2H w/o the necessity to add a new compatible MAINTAINERS | 8 + drivers/rtc/Kconfig | 10 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-renesas-rtca3.c | 899 ++++++++++++++++++++++++++++++++ 4 files changed, 918 insertions(+) create mode 100644 drivers/rtc/rtc-renesas-rtca3.c diff --git a/MAINTAINERS b/MAINTAINERS index 0967064d4fdc..c27e7b5dc80d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19745,6 +19745,14 @@ S: Supported F: Documentation/devicetree/bindings/timer/renesas,rz-mtu3.yaml F: drivers/counter/rz-mtu3-cnt.c =20 +RENESAS RTCA-3 RTC DRIVER +M: Claudiu Beznea +L: linux-rtc@vger.kernel.org +L: linux-renesas-soc@vger.kernel.org +S: Supported +F: Documentation/devicetree/bindings/rtc/renesas,rz-rtca3.yaml +F: drivers/rtc/rtc-renesas-rtca3.c + RENESAS RZ/N1 A5PSW SWITCH DRIVER M: Cl=C3=A9ment L=C3=A9ger L: linux-renesas-soc@vger.kernel.org diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 66eb1122248b..5c003c0c2f7a 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -2005,6 +2005,16 @@ config RTC_DRV_MA35D1 This driver can also be built as a module, if so, the module will be called "rtc-ma35d1". =20 +config RTC_DRV_RENESAS_RTCA3 + tristate "Renesas RTCA-3 RTC" + depends on ARCH_RENESAS + help + If you say yes here you get support for the Renesas RTCA-3 RTC + available on the Renesas RZ/G3S SoC. + + This driver can also be built as a module, if so, the module + will be called "rtc-rtca3". + comment "HID Sensor RTC drivers" =20 config RTC_DRV_HID_SENSOR_TIME diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index f62340ecc534..184d2f3cf743 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -158,6 +158,7 @@ obj-$(CONFIG_RTC_DRV_RX8025) +=3D rtc-rx8025.o obj-$(CONFIG_RTC_DRV_RX8111) +=3D rtc-rx8111.o obj-$(CONFIG_RTC_DRV_RX8581) +=3D rtc-rx8581.o obj-$(CONFIG_RTC_DRV_RZN1) +=3D rtc-rzn1.o +obj-$(CONFIG_RTC_DRV_RENESAS_RTCA3) +=3D rtc-renesas-rtca3.o obj-$(CONFIG_RTC_DRV_S35390A) +=3D rtc-s35390a.o obj-$(CONFIG_RTC_DRV_S3C) +=3D rtc-s3c.o obj-$(CONFIG_RTC_DRV_S5M) +=3D rtc-s5m.o diff --git a/drivers/rtc/rtc-renesas-rtca3.c b/drivers/rtc/rtc-renesas-rtca= 3.c new file mode 100644 index 000000000000..abb0f6f73906 --- /dev/null +++ b/drivers/rtc/rtc-renesas-rtca3.c @@ -0,0 +1,899 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * On-Chip RTC Support available on RZ/G3S SoC + * + * Copyright (C) 2024 Renesas Electronics Corp. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Counter registers. */ +#define RTCA3_RSECCNT 0x2 +#define RTCA3_RSECCNT_SEC GENMASK(6, 0) +#define RTCA3_RMINCNT 0x4 +#define RTCA3_RMINCNT_MIN GENMASK(6, 0) +#define RTCA3_RHRCNT 0x6 +#define RTCA3_RHRCNT_HR GENMASK(5, 0) +#define RTCA3_RHRCNT_PM BIT(6) +#define RTCA3_RWKCNT 0x8 +#define RTCA3_RWKCNT_WK GENMASK(2, 0) +#define RTCA3_RDAYCNT 0xa +#define RTCA3_RDAYCNT_DAY GENMASK(5, 0) +#define RTCA3_RMONCNT 0xc +#define RTCA3_RMONCNT_MONTH GENMASK(4, 0) +#define RTCA3_RYRCNT 0xe +#define RTCA3_RYRCNT_YEAR GENMASK(7, 0) + +/* Alarm registers. */ +#define RTCA3_RSECAR 0x10 +#define RTCA3_RSECAR_SEC GENMASK(6, 0) +#define RTCA3_RMINAR 0x12 +#define RTCA3_RMINAR_MIN GENMASK(6, 0) +#define RTCA3_RHRAR 0x14 +#define RTCA3_RHRAR_HR GENMASK(5, 0) +#define RTCA3_RHRAR_PM BIT(6) +#define RTCA3_RWKAR 0x16 +#define RTCA3_RWKAR_DAYW GENMASK(2, 0) +#define RTCA3_RDAYAR 0x18 +#define RTCA3_RDAYAR_DATE GENMASK(5, 0) +#define RTCA3_RMONAR 0x1a +#define RTCA3_RMONAR_MON GENMASK(4, 0) +#define RTCA3_RYRAR 0x1c +#define RTCA3_RYRAR_YR GENMASK(7, 0) +#define RTCA3_RYRAREN 0x1e + +/* Alarm enable bit (for all alarm registers). */ +#define RTCA3_AR_ENB BIT(7) + +/* Control registers. */ +#define RTCA3_RCR1 0x22 +#define RTCA3_RCR1_AIE BIT(0) +#define RTCA3_RCR1_CIE BIT(1) +#define RTCA3_RCR1_PIE BIT(2) +#define RTCA3_RCR1_PES GENMASK(7, 4) +#define RTCA3_RCR1_PES_1_64_SEC 0x8 +#define RTCA3_RCR2 0x24 +#define RTCA3_RCR2_START BIT(0) +#define RTCA3_RCR2_RESET BIT(1) +#define RTCA3_RCR2_AADJE BIT(4) +#define RTCA3_RCR2_ADJP BIT(5) +#define RTCA3_RCR2_HR24 BIT(6) +#define RTCA3_RCR2_CNTMD BIT(7) +#define RTCA3_RSR 0x20 +#define RTCA3_RSR_AF BIT(0) +#define RTCA3_RSR_CF BIT(1) +#define RTCA3_RSR_PF BIT(2) +#define RTCA3_RADJ 0x2e +#define RTCA3_RADJ_ADJ GENMASK(5, 0) +#define RTCA3_RADJ_ADJ_MAX 0x3f +#define RTCA3_RADJ_PMADJ GENMASK(7, 6) +#define RTCA3_RADJ_PMADJ_NONE 0 +#define RTCA3_RADJ_PMADJ_ADD 1 +#define RTCA3_RADJ_PMADJ_SUB 2 + +/* Polling operation timeouts. */ +#define RTCA3_DEFAULT_TIMEOUT_US 150 +#define RTCA3_IRQSET_TIMEOUT_US 5000 +#define RTCA3_START_TIMEOUT_US 150000 +#define RTCA3_RESET_TIMEOUT_US 200000 + +/** + * enum rtca3_alrm_set_step - RTCA3 alarm set steps + * @RTCA3_ALRM_SSTEP_DONE: alarm setup done step + * @RTCA3_ALRM_SSTEP_IRQ: two 1/64 periodic IRQs were generated step + * @RTCA3_ALRM_SSTEP_INIT: alarm setup initialization step + */ +enum rtca3_alrm_set_step { + RTCA3_ALRM_SSTEP_DONE =3D 0, + RTCA3_ALRM_SSTEP_IRQ =3D 1, + RTCA3_ALRM_SSTEP_INIT =3D 3, +}; + +/** + * struct rtca3_ppb_per_cycle - PPB per cycle + * @ten_sec: PPB per cycle in 10 seconds adjutment mode + * @sixty_sec: PPB per cycle in 60 seconds adjustment mode + */ +struct rtca3_ppb_per_cycle { + int ten_sec; + int sixty_sec; +}; + +/** + * struct rtca3_priv - RTCA3 private data structure + * @base: base address + * @rtc_dev: RTC device + * @rstc: reset control + * @set_alarm_completion: alarm setup completion + * @alrm_sstep: alarm setup step (see enum rtca3_alrm_set_step) + * @lock: device lock + * @ppb: ppb per cycle for each the available adjustment modes + * @wakeup_irq: wakeup IRQ + */ +struct rtca3_priv { + void __iomem *base; + struct rtc_device *rtc_dev; + struct reset_control *rstc; + struct completion set_alarm_completion; + atomic_t alrm_sstep; + spinlock_t lock; + struct rtca3_ppb_per_cycle ppb; + int wakeup_irq; +}; + +static void rtca3_byte_update_bits(struct rtca3_priv *priv, u8 off, u8 mas= k, u8 val) +{ + u8 tmp; + + tmp =3D readb(priv->base + off); + tmp &=3D ~mask; + tmp |=3D (val & mask); + writeb(tmp, priv->base + off); +} + +static u8 rtca3_alarm_handler_helper(struct rtca3_priv *priv) +{ + u8 val, pending; + + val =3D readb(priv->base + RTCA3_RSR); + pending =3D val & RTCA3_RSR_AF; + writeb(val & ~pending, priv->base + RTCA3_RSR); + + if (pending) + rtc_update_irq(priv->rtc_dev, 1, RTC_AF | RTC_IRQF); + + return pending; +} + +static irqreturn_t rtca3_alarm_handler(int irq, void *dev_id) +{ + struct rtca3_priv *priv =3D dev_id; + u8 pending; + + guard(spinlock)(&priv->lock); + + pending =3D rtca3_alarm_handler_helper(priv); + + return IRQ_RETVAL(pending); +} + +static irqreturn_t rtca3_periodic_handler(int irq, void *dev_id) +{ + struct rtca3_priv *priv =3D dev_id; + u8 val, pending; + + guard(spinlock)(&priv->lock); + + val =3D readb(priv->base + RTCA3_RSR); + pending =3D val & RTCA3_RSR_PF; + + if (pending) { + writeb(val & ~pending, priv->base + RTCA3_RSR); + + if (atomic_read(&priv->alrm_sstep) > RTCA3_ALRM_SSTEP_IRQ) { + /* Alarm setup in progress. */ + atomic_dec(&priv->alrm_sstep); + + if (atomic_read(&priv->alrm_sstep) =3D=3D RTCA3_ALRM_SSTEP_IRQ) { + /* + * We got 2 * 1/64 periodic interrupts. Disable + * interrupt and let alarm setup continue. + */ + rtca3_byte_update_bits(priv, RTCA3_RCR1, + RTCA3_RCR1_PIE, 0); + readb_poll_timeout_atomic(priv->base + RTCA3_RCR1, val, + !(val & RTCA3_RCR1_PIE), + 10, RTCA3_DEFAULT_TIMEOUT_US); + complete(&priv->set_alarm_completion); + } + } + } + + return IRQ_RETVAL(pending); +} + +static void rtca3_prepare_cntalrm_regs_for_read(struct rtca3_priv *priv, b= ool cnt) +{ + /* Offset b/w time and alarm registers. */ + u8 offset =3D cnt ? 0 : 0xe; + + /* + * According to HW manual (section 22.6.4. Notes on writing to and + * reading from registers) after writing to count registers, alarm + * registers, year alarm enable register, bits RCR2.AADJE, AADJP, + * and HR24 register, we need to do 3 empty reads before being + * able to fetch the registers content. + */ + for (u8 i =3D 0; i < 3; i++) { + readb(priv->base + RTCA3_RSECCNT + offset); + readb(priv->base + RTCA3_RMINCNT + offset); + readb(priv->base + RTCA3_RHRCNT + offset); + readb(priv->base + RTCA3_RWKCNT + offset); + readb(priv->base + RTCA3_RDAYCNT + offset); + readw(priv->base + RTCA3_RYRCNT + offset); + if (!cnt) + readb(priv->base + RTCA3_RYRAREN); + } +} + +static int rtca3_read_time(struct device *dev, struct rtc_time *tm) +{ + struct rtca3_priv *priv =3D dev_get_drvdata(dev); + u8 sec, min, hour, wday, mday, month, tmp; + u8 trials =3D 0; + u32 year100; + u16 year; + + guard(spinlock_irqsave)(&priv->lock); + + tmp =3D readb(priv->base + RTCA3_RCR2); + if (!(tmp & RTCA3_RCR2_START)) + return -EINVAL; + + do { + /* Clear carry interrupt. */ + rtca3_byte_update_bits(priv, RTCA3_RSR, RTCA3_RSR_CF, 0); + + /* Read counters. */ + sec =3D readb(priv->base + RTCA3_RSECCNT); + min =3D readb(priv->base + RTCA3_RMINCNT); + hour =3D readb(priv->base + RTCA3_RHRCNT); + wday =3D readb(priv->base + RTCA3_RWKCNT); + mday =3D readb(priv->base + RTCA3_RDAYCNT); + month =3D readb(priv->base + RTCA3_RMONCNT); + year =3D readw(priv->base + RTCA3_RYRCNT); + + tmp =3D readb(priv->base + RTCA3_RSR); + + /* + * We cannot generate carries due to reading 64Hz counter as + * the driver doesn't implement carry, thus, carries will be + * generated once per seconds. Add a timeout of 5 trials here + * to avoid infinite loop, if any. + */ + } while ((tmp & RTCA3_RSR_CF) && ++trials < 5); + + if (trials >=3D 5) + return -ETIMEDOUT; + + tm->tm_sec =3D bcd2bin(FIELD_GET(RTCA3_RSECCNT_SEC, sec)); + tm->tm_min =3D bcd2bin(FIELD_GET(RTCA3_RMINCNT_MIN, min)); + tm->tm_hour =3D bcd2bin(FIELD_GET(RTCA3_RHRCNT_HR, hour)); + tm->tm_wday =3D bcd2bin(FIELD_GET(RTCA3_RWKCNT_WK, wday)); + tm->tm_mday =3D bcd2bin(FIELD_GET(RTCA3_RDAYCNT_DAY, mday)); + tm->tm_mon =3D bcd2bin(FIELD_GET(RTCA3_RMONCNT_MONTH, month)) - 1; + year =3D FIELD_GET(RTCA3_RYRCNT_YEAR, year); + year100 =3D bcd2bin((year =3D=3D 0x99) ? 0x19 : 0x20); + tm->tm_year =3D (year100 * 100 + bcd2bin(year)) - 1900; + + return 0; +} + +static int rtca3_set_time(struct device *dev, struct rtc_time *tm) +{ + struct rtca3_priv *priv =3D dev_get_drvdata(dev); + u8 rcr2, tmp; + int ret; + + guard(spinlock_irqsave)(&priv->lock); + + /* Stop the RTC. */ + rcr2 =3D readb(priv->base + RTCA3_RCR2); + writeb(rcr2 & ~RTCA3_RCR2_START, priv->base + RTCA3_RCR2); + ret =3D readb_poll_timeout_atomic(priv->base + RTCA3_RCR2, tmp, + !(tmp & RTCA3_RCR2_START), + 10, RTCA3_DEFAULT_TIMEOUT_US); + if (ret) + return ret; + + /* Update time. */ + writeb(bin2bcd(tm->tm_sec), priv->base + RTCA3_RSECCNT); + writeb(bin2bcd(tm->tm_min), priv->base + RTCA3_RMINCNT); + writeb(bin2bcd(tm->tm_hour), priv->base + RTCA3_RHRCNT); + writeb(bin2bcd(tm->tm_wday), priv->base + RTCA3_RWKCNT); + writeb(bin2bcd(tm->tm_mday), priv->base + RTCA3_RDAYCNT); + writeb(bin2bcd(tm->tm_mon + 1), priv->base + RTCA3_RMONCNT); + writew(bin2bcd(tm->tm_year % 100), priv->base + RTCA3_RYRCNT); + + /* Make sure we can read back the counters. */ + rtca3_prepare_cntalrm_regs_for_read(priv, true); + + /* Start RTC. */ + writeb(rcr2 | RTCA3_RCR2_START, priv->base + RTCA3_RCR2); + return readb_poll_timeout_atomic(priv->base + RTCA3_RCR2, tmp, + (tmp & RTCA3_RCR2_START), + 10, RTCA3_DEFAULT_TIMEOUT_US); +} + +static int rtca3_alarm_irq_set_helper(struct rtca3_priv *priv, + u8 interrupts, + unsigned int enabled) +{ + u8 tmp, val; + + if (enabled) { + /* + * AIE, CIE, PIE bit indexes in RSR corresponds with + * those on RCR1. Same interrupts mask can be used. + */ + rtca3_byte_update_bits(priv, RTCA3_RSR, interrupts, 0); + val =3D interrupts; + } else { + val =3D 0; + } + + rtca3_byte_update_bits(priv, RTCA3_RCR1, interrupts, val); + return readb_poll_timeout_atomic(priv->base + RTCA3_RCR1, tmp, + ((tmp & interrupts) =3D=3D val), + 10, RTCA3_IRQSET_TIMEOUT_US); +} + +static int rtca3_alarm_irq_enable(struct device *dev, unsigned int enabled) +{ + struct rtca3_priv *priv =3D dev_get_drvdata(dev); + + guard(spinlock_irqsave)(&priv->lock); + + return rtca3_alarm_irq_set_helper(priv, RTCA3_RCR1_AIE, enabled); +} + +static int rtca3_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) +{ + struct rtca3_priv *priv =3D dev_get_drvdata(dev); + u8 sec, min, hour, wday, mday, month; + struct rtc_time *tm =3D &wkalrm->time; + u32 year100; + u16 year; + + guard(spinlock_irqsave)(&priv->lock); + + sec =3D readb(priv->base + RTCA3_RSECAR); + min =3D readb(priv->base + RTCA3_RMINAR); + hour =3D readb(priv->base + RTCA3_RHRAR); + wday =3D readb(priv->base + RTCA3_RWKAR); + mday =3D readb(priv->base + RTCA3_RDAYAR); + month =3D readb(priv->base + RTCA3_RMONAR); + year =3D readw(priv->base + RTCA3_RYRAR); + + tm->tm_sec =3D bcd2bin(FIELD_GET(RTCA3_RSECAR_SEC, sec)); + tm->tm_min =3D bcd2bin(FIELD_GET(RTCA3_RMINAR_MIN, min)); + tm->tm_hour =3D bcd2bin(FIELD_GET(RTCA3_RHRAR_HR, hour)); + tm->tm_wday =3D bcd2bin(FIELD_GET(RTCA3_RWKAR_DAYW, wday)); + tm->tm_mday =3D bcd2bin(FIELD_GET(RTCA3_RDAYAR_DATE, mday)); + tm->tm_mon =3D bcd2bin(FIELD_GET(RTCA3_RMONAR_MON, month)) - 1; + year =3D FIELD_GET(RTCA3_RYRAR_YR, year); + year100 =3D bcd2bin((year =3D=3D 0x99) ? 0x19 : 0x20); + tm->tm_year =3D (year100 * 100 + bcd2bin(year)) - 1900; + + wkalrm->enabled =3D !!(readb(priv->base + RTCA3_RCR1) & RTCA3_RCR1_AIE); + + return 0; +} + +static int rtca3_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) +{ + struct rtca3_priv *priv =3D dev_get_drvdata(dev); + struct rtc_time *tm =3D &wkalrm->time; + u8 rcr1, tmp; + int ret; + + scoped_guard(spinlock_irqsave, &priv->lock) { + tmp =3D readb(priv->base + RTCA3_RCR2); + if (!(tmp & RTCA3_RCR2_START)) + return -EPERM; + + /* Disable AIE to prevent false interrupts. */ + rcr1 =3D readb(priv->base + RTCA3_RCR1); + rcr1 &=3D ~RTCA3_RCR1_AIE; + writeb(rcr1, priv->base + RTCA3_RCR1); + ret =3D readb_poll_timeout_atomic(priv->base + RTCA3_RCR1, tmp, + !(tmp & RTCA3_RCR1_AIE), + 10, RTCA3_DEFAULT_TIMEOUT_US); + if (ret) + return ret; + + /* Set the time and enable the alarm. */ + writeb(RTCA3_AR_ENB | bin2bcd(tm->tm_sec), priv->base + RTCA3_RSECAR); + writeb(RTCA3_AR_ENB | bin2bcd(tm->tm_min), priv->base + RTCA3_RMINAR); + writeb(RTCA3_AR_ENB | bin2bcd(tm->tm_hour), priv->base + RTCA3_RHRAR); + writeb(RTCA3_AR_ENB | bin2bcd(tm->tm_wday), priv->base + RTCA3_RWKAR); + writeb(RTCA3_AR_ENB | bin2bcd(tm->tm_mday), priv->base + RTCA3_RDAYAR); + writeb(RTCA3_AR_ENB | bin2bcd(tm->tm_mon + 1), priv->base + RTCA3_RMONAR= ); + + writew(bin2bcd(tm->tm_year % 100), priv->base + RTCA3_RYRAR); + writeb(RTCA3_AR_ENB, priv->base + RTCA3_RYRAREN); + + /* Make sure we can read back the counters. */ + rtca3_prepare_cntalrm_regs_for_read(priv, false); + + /* Need to wait for 2 * 1/64 periodic interrupts to be generated. */ + atomic_set(&priv->alrm_sstep, RTCA3_ALRM_SSTEP_INIT); + reinit_completion(&priv->set_alarm_completion); + + /* Enable periodic interrupt. */ + rcr1 |=3D RTCA3_RCR1_PIE; + writeb(rcr1, priv->base + RTCA3_RCR1); + ret =3D readb_poll_timeout_atomic(priv->base + RTCA3_RCR1, tmp, + (tmp & RTCA3_RCR1_PIE), + 10, RTCA3_IRQSET_TIMEOUT_US); + } + + if (ret) + goto setup_failed; + + /* Wait for the 2 * 1/64 periodic interrupts. */ + ret =3D wait_for_completion_interruptible_timeout(&priv->set_alarm_comple= tion, + msecs_to_jiffies(500)); + if (ret <=3D 0) { + ret =3D -ETIMEDOUT; + goto setup_failed; + } + + scoped_guard(spinlock_irqsave, &priv->lock) { + ret =3D rtca3_alarm_irq_set_helper(priv, RTCA3_RCR1_AIE, wkalrm->enabled= ); + atomic_set(&priv->alrm_sstep, RTCA3_ALRM_SSTEP_DONE); + } + + return ret; + +setup_failed: + scoped_guard(spinlock_irqsave, &priv->lock) { + /* + * Disable PIE to avoid interrupt storm in case HW needed more than + * specified timeout for setup. + */ + writeb(rcr1 & ~RTCA3_RCR1_PIE, priv->base + RTCA3_RCR1); + readb_poll_timeout_atomic(priv->base + RTCA3_RCR1, tmp, !(tmp & ~RTCA3_R= CR1_PIE), + 10, RTCA3_DEFAULT_TIMEOUT_US); + atomic_set(&priv->alrm_sstep, RTCA3_ALRM_SSTEP_DONE); + } + + return ret; +} + +static int rtca3_read_offset(struct device *dev, long *offset) +{ + struct rtca3_priv *priv =3D dev_get_drvdata(dev); + u8 val, radj, cycles; + u32 ppb_per_cycle; + + scoped_guard(spinlock_irqsave, &priv->lock) { + radj =3D readb(priv->base + RTCA3_RADJ); + val =3D readb(priv->base + RTCA3_RCR2); + } + + cycles =3D FIELD_GET(RTCA3_RADJ_ADJ, radj); + + if (!cycles) { + *offset =3D 0; + return 0; + } + + if (val & RTCA3_RCR2_ADJP) + ppb_per_cycle =3D priv->ppb.ten_sec; + else + ppb_per_cycle =3D priv->ppb.sixty_sec; + + *offset =3D cycles * ppb_per_cycle; + val =3D FIELD_GET(RTCA3_RADJ_PMADJ, radj); + if (val =3D=3D RTCA3_RADJ_PMADJ_SUB) + *offset =3D -(*offset); + + return 0; +} + +static int rtca3_set_offset(struct device *dev, long offset) +{ + struct rtca3_priv *priv =3D dev_get_drvdata(dev); + int cycles, cycles10, cycles60; + u8 radj, adjp, tmp; + int ret; + + /* + * Automatic time error adjustment could be set at intervals of 10 + * or 60 seconds. + */ + cycles10 =3D DIV_ROUND_CLOSEST(offset, priv->ppb.ten_sec); + cycles60 =3D DIV_ROUND_CLOSEST(offset, priv->ppb.sixty_sec); + + /* We can set b/w 1 and 63 clock cycles. */ + if (cycles60 >=3D -RTCA3_RADJ_ADJ_MAX && + cycles60 <=3D RTCA3_RADJ_ADJ_MAX) { + cycles =3D cycles60; + adjp =3D 0; + } else if (cycles10 >=3D -RTCA3_RADJ_ADJ_MAX && + cycles10 <=3D RTCA3_RADJ_ADJ_MAX) { + cycles =3D cycles10; + adjp =3D RTCA3_RCR2_ADJP; + } else { + return -ERANGE; + } + + radj =3D FIELD_PREP(RTCA3_RADJ_ADJ, abs(cycles)); + if (!cycles) + radj |=3D FIELD_PREP(RTCA3_RADJ_PMADJ, RTCA3_RADJ_PMADJ_NONE); + else if (cycles > 0) + radj |=3D FIELD_PREP(RTCA3_RADJ_PMADJ, RTCA3_RADJ_PMADJ_ADD); + else + radj |=3D FIELD_PREP(RTCA3_RADJ_PMADJ, RTCA3_RADJ_PMADJ_SUB); + + guard(spinlock_irqsave)(&priv->lock); + + tmp =3D readb(priv->base + RTCA3_RCR2); + + if ((tmp & RTCA3_RCR2_ADJP) !=3D adjp) { + /* RADJ.PMADJ need to be set to zero before setting RCR2.ADJP. */ + writeb(0, priv->base + RTCA3_RADJ); + ret =3D readb_poll_timeout_atomic(priv->base + RTCA3_RADJ, tmp, !tmp, + 10, RTCA3_DEFAULT_TIMEOUT_US); + if (ret) + return ret; + + rtca3_byte_update_bits(priv, RTCA3_RCR2, RTCA3_RCR2_ADJP, adjp); + ret =3D readb_poll_timeout_atomic(priv->base + RTCA3_RCR2, tmp, + ((tmp & RTCA3_RCR2_ADJP) =3D=3D adjp), + 10, RTCA3_DEFAULT_TIMEOUT_US); + if (ret) + return ret; + } + + writeb(radj, priv->base + RTCA3_RADJ); + return readb_poll_timeout_atomic(priv->base + RTCA3_RADJ, tmp, (tmp =3D= =3D radj), + 10, RTCA3_DEFAULT_TIMEOUT_US); +} + +static const struct rtc_class_ops rtca3_ops =3D { + .read_time =3D rtca3_read_time, + .set_time =3D rtca3_set_time, + .read_alarm =3D rtca3_read_alarm, + .set_alarm =3D rtca3_set_alarm, + .alarm_irq_enable =3D rtca3_alarm_irq_enable, + .set_offset =3D rtca3_set_offset, + .read_offset =3D rtca3_read_offset, +}; + +static int rtca3_initial_setup(struct clk *clk, struct rtca3_priv *priv) +{ + unsigned long osc32k_rate; + u8 val, tmp, mask; + u32 sleep_us; + int ret; + + osc32k_rate =3D clk_get_rate(clk); + if (!osc32k_rate) + return -EINVAL; + + sleep_us =3D DIV_ROUND_UP_ULL(1000000ULL, osc32k_rate) * 6; + + priv->ppb.ten_sec =3D DIV_ROUND_CLOSEST_ULL(1000000000ULL, (osc32k_rate *= 10)); + priv->ppb.sixty_sec =3D DIV_ROUND_CLOSEST_ULL(1000000000ULL, (osc32k_rate= * 60)); + + /* + * According to HW manual (section 22.4.2. Clock and count mode setting p= rocedure) + * we need to wait at least 6 cycles of the 32KHz clock after clock was e= nabled. + */ + usleep_range(sleep_us, sleep_us + 10); + + /* Disable all interrupts. */ + mask =3D RTCA3_RCR1_AIE | RTCA3_RCR1_CIE | RTCA3_RCR1_PIE; + ret =3D rtca3_alarm_irq_set_helper(priv, mask, 0); + if (ret) + return ret; + + mask =3D RTCA3_RCR2_START | RTCA3_RCR2_HR24; + val =3D readb(priv->base + RTCA3_RCR2); + /* Nothing to do if already started in 24 hours and calendar count mode. = */ + if ((val & mask) =3D=3D mask) + return 0; + + /* Reconfigure the RTC in 24 hours and calendar count mode. */ + mask =3D RTCA3_RCR2_START | RTCA3_RCR2_CNTMD; + writeb(0, priv->base + RTCA3_RCR2); + ret =3D readb_poll_timeout(priv->base + RTCA3_RCR2, tmp, !(tmp & mask), + 10, RTCA3_DEFAULT_TIMEOUT_US); + if (ret) + return ret; + + /* + * Set 24 hours mode. According to HW manual (section 22.3.19. RTC Control + * Register 2) this needs to be done separate from stop operation. + */ + mask =3D RTCA3_RCR2_HR24; + val =3D RTCA3_RCR2_HR24; + writeb(val, priv->base + RTCA3_RCR2); + ret =3D readb_poll_timeout(priv->base + RTCA3_RCR2, tmp, (tmp & mask), + 10, RTCA3_DEFAULT_TIMEOUT_US); + if (ret) + return ret; + + /* Execute reset. */ + mask =3D RTCA3_RCR2_RESET; + writeb(val | RTCA3_RCR2_RESET, priv->base + RTCA3_RCR2); + ret =3D readb_poll_timeout(priv->base + RTCA3_RCR2, tmp, !(tmp & mask), + 10, RTCA3_RESET_TIMEOUT_US); + if (ret) + return ret; + + /* + * According to HW manual (section 22.6.3. Notes on writing to and reading + * from registers) after reset we need to wait 6 clock cycles before + * writing to RTC registers. + */ + usleep_range(sleep_us, sleep_us + 10); + + /* Set no adjustment. */ + writeb(0, priv->base + RTCA3_RADJ); + ret =3D readb_poll_timeout(priv->base + RTCA3_RADJ, tmp, !tmp, 10, + RTCA3_DEFAULT_TIMEOUT_US); + + /* Start the RTC and enable automatic time error adjustment. */ + mask =3D RTCA3_RCR2_START | RTCA3_RCR2_AADJE; + val |=3D RTCA3_RCR2_START | RTCA3_RCR2_AADJE; + writeb(val, priv->base + RTCA3_RCR2); + ret =3D readb_poll_timeout(priv->base + RTCA3_RCR2, tmp, ((tmp & mask) = =3D=3D mask), + 10, RTCA3_START_TIMEOUT_US); + if (ret) + return ret; + + /* + * According to HW manual (section 22.6.4. Notes on writing to and reading + * from registers) we need to wait 1/128 seconds while the clock is opera= ting + * (RCR2.START bit =3D 1) to be able to read the counters after a return = from + * reset. + */ + usleep_range(8000, 9000); + + /* Set period interrupt to 1/64 seconds. It is necessary for alarm setup.= */ + val =3D FIELD_PREP(RTCA3_RCR1_PES, RTCA3_RCR1_PES_1_64_SEC); + rtca3_byte_update_bits(priv, RTCA3_RCR1, RTCA3_RCR1_PES, val); + return readb_poll_timeout(priv->base + RTCA3_RCR1, tmp, ((tmp & RTCA3_RCR= 1_PES) =3D=3D val), + 10, RTCA3_DEFAULT_TIMEOUT_US); +} + +static int rtca3_request_irqs(struct platform_device *pdev, struct rtca3_p= riv *priv) +{ + struct device *dev =3D &pdev->dev; + int ret, irq; + + irq =3D platform_get_irq_byname(pdev, "alarm"); + if (irq < 0) + return dev_err_probe(dev, irq, "Failed to get alarm IRQ!\n"); + + ret =3D devm_request_irq(dev, irq, rtca3_alarm_handler, 0, "rtca3-alarm",= priv); + if (ret) + return dev_err_probe(dev, ret, "Failed to request alarm IRQ!\n"); + priv->wakeup_irq =3D irq; + + irq =3D platform_get_irq_byname(pdev, "period"); + if (irq < 0) + return dev_err_probe(dev, irq, "Failed to get period IRQ!\n"); + + ret =3D devm_request_irq(dev, irq, rtca3_periodic_handler, 0, "rtca3-peri= od", priv); + if (ret) + return dev_err_probe(dev, ret, "Failed to request period IRQ!\n"); + + /* + * Driver doesn't implement carry handler. Just get the IRQ here + * for backward compatibility, in case carry support will be added later. + */ + irq =3D platform_get_irq_byname(pdev, "carry"); + if (irq < 0) + return dev_err_probe(dev, irq, "Failed to get carry IRQ!\n"); + + return 0; +} + +static void rtca3_action(void *data) +{ + struct device *dev =3D data; + struct rtca3_priv *priv =3D dev_get_drvdata(dev); + int ret; + + ret =3D reset_control_assert(priv->rstc); + if (ret) + dev_err(dev, "Failed to de-assert reset!"); + + ret =3D pm_runtime_put_sync(dev); + if (ret < 0) + dev_err(dev, "Failed to runtime suspend!"); +} + +static int rtca3_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct rtca3_priv *priv; + struct clk *clk; + int ret; + + priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->base =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(priv->base)) + return PTR_ERR(priv->base); + + ret =3D devm_pm_runtime_enable(dev); + if (ret) + return ret; + + priv->rstc =3D devm_reset_control_get_shared(dev, NULL); + if (IS_ERR(priv->rstc)) + return PTR_ERR(priv->rstc); + + ret =3D pm_runtime_resume_and_get(dev); + if (ret) + return ret; + + ret =3D reset_control_deassert(priv->rstc); + if (ret) { + pm_runtime_put_sync(dev); + return ret; + } + + dev_set_drvdata(dev, priv); + ret =3D devm_add_action_or_reset(dev, rtca3_action, dev); + if (ret) + return ret; + + /* + * This must be an always-on clock to keep the RTC running even after + * driver is unbinded. + */ + clk =3D devm_clk_get_enabled(dev, "counter"); + if (IS_ERR(clk)) + return PTR_ERR(clk); + + spin_lock_init(&priv->lock); + atomic_set(&priv->alrm_sstep, RTCA3_ALRM_SSTEP_DONE); + init_completion(&priv->set_alarm_completion); + + ret =3D rtca3_initial_setup(clk, priv); + if (ret) + return dev_err_probe(dev, ret, "Failed to setup the RTC!\n"); + + ret =3D rtca3_request_irqs(pdev, priv); + if (ret) + return ret; + + device_init_wakeup(&pdev->dev, 1); + + priv->rtc_dev =3D devm_rtc_allocate_device(&pdev->dev); + if (IS_ERR(priv->rtc_dev)) + return PTR_ERR(priv->rtc_dev); + + priv->rtc_dev->ops =3D &rtca3_ops; + priv->rtc_dev->max_user_freq =3D 256; + priv->rtc_dev->range_min =3D RTC_TIMESTAMP_BEGIN_2000; + priv->rtc_dev->range_max =3D RTC_TIMESTAMP_END_2099; + + return devm_rtc_register_device(priv->rtc_dev); +} + +static void rtca3_remove(struct platform_device *pdev) +{ + struct rtca3_priv *priv =3D platform_get_drvdata(pdev); + + guard(spinlock_irqsave)(&priv->lock); + + /* + * Disable alarm, periodic interrupts. The RTC device cannot + * power up the system. + */ + rtca3_alarm_irq_set_helper(priv, RTCA3_RCR1_AIE | RTCA3_RCR1_PIE, 0); +} + +static int rtca3_suspend(struct device *dev) +{ + struct rtca3_priv *priv =3D dev_get_drvdata(dev); + + if (!device_may_wakeup(dev)) + return 0; + + /* Alarm setup in progress. */ + if (atomic_read(&priv->alrm_sstep) !=3D RTCA3_ALRM_SSTEP_DONE) + return -EBUSY; + + enable_irq_wake(priv->wakeup_irq); + + return 0; +} + +static int rtca3_clean_alarm(struct rtca3_priv *priv) +{ + struct rtc_device *rtc_dev =3D priv->rtc_dev; + time64_t alarm_time, now; + struct rtc_wkalrm alarm; + struct rtc_time tm; + u8 pending; + int ret; + + ret =3D rtc_read_alarm(rtc_dev, &alarm); + if (ret) + return ret; + + if (!alarm.enabled) + return 0; + + ret =3D rtc_read_time(rtc_dev, &tm); + if (ret) + return ret; + + alarm_time =3D rtc_tm_to_time64(&alarm.time); + now =3D rtc_tm_to_time64(&tm); + if (alarm_time >=3D now) + return 0; + + /* + * Heuristically, it has been determined that when returning from deep + * sleep state the RTCA3_RSR.AF is zero even though the alarm expired. + * Call again the rtc_update_irq() if alarm helper detects this. + */ + + guard(spinlock_irqsave)(&priv->lock); + + pending =3D rtca3_alarm_handler_helper(priv); + if (!pending) + rtc_update_irq(priv->rtc_dev, 1, RTC_AF | RTC_IRQF); + + return 0; +} + +static int rtca3_resume(struct device *dev) +{ + struct rtca3_priv *priv =3D dev_get_drvdata(dev); + + if (!device_may_wakeup(dev)) + return 0; + + disable_irq_wake(priv->wakeup_irq); + + /* + * According to the HW manual (section 22.6.4 Notes on writing to + * and reading from registers) we need to wait 1/128 seconds while + * RCR2.START =3D 1 to be able to read the counters after a return from l= ow + * power consumption state. + */ + mdelay(8); + + /* + * The alarm cannot wake the system from deep sleep states. In case + * we return from deep sleep states and the alarm expired we need + * to disable it to avoid failures when setting another alarm. + */ + return rtca3_clean_alarm(priv); +} + +static DEFINE_SIMPLE_DEV_PM_OPS(rtca3_pm_ops, rtca3_suspend, rtca3_resume); + +static const struct of_device_id rtca3_of_match[] =3D { + { .compatible =3D "renesas,rz-rtca3", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, rtca3_of_match); + +static struct platform_driver rtca3_platform_driver =3D { + .driver =3D { + .name =3D "rtc-rtca3", + .pm =3D pm_ptr(&rtca3_pm_ops), + .of_match_table =3D rtca3_of_match, + }, + .probe =3D rtca3_probe, + .remove =3D rtca3_remove, +}; +module_platform_driver(rtca3_platform_driver); + +MODULE_DESCRIPTION("Renesas RTCA-3 RTC driver"); +MODULE_AUTHOR("Claudiu Beznea "); +MODULE_LICENSE("GPL"); --=20 2.39.2 From nobody Mon Nov 25 03:04:33 2024 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE7471D278D for ; Wed, 30 Oct 2024 11:01:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286111; cv=none; b=cIopGH4VqhUrSVZxSaSWQSTamr13eTWEWUjBz5wvbQ2uAa8MwqjPLIdQoaCrnqUe8F+cBBPplzFYuAptwqqsOrA8oXQNLdRj8CMGSW7YAB1BslOCcKNGf+C1nGjqFcnE7ND3/Gwo+horiRIPaJjOo5TcHz+pby0rSNdTlc4G04c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286111; c=relaxed/simple; bh=mfKKujpI4Yk4mdg6+t15nnjqJVfhNqwOoY0zzp8KwTk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hS/4sE2vCgweLD0LXu0scAaXAvrcOCbo5IsNAxqayX2+9taPOcEmuklAuBQFoPfrcH7yvwDHquo9OgiK1TwCV+DInA9X+yJivrlmoXj5FRvLPNMmlF/sEn2epvbBvJHxcmuSX76vSuNbCoon+s3BaHD/9UMIkN6eiARmVx5YdOM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=qYc+697a; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="qYc+697a" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4314c452180so4707955e9.0 for ; Wed, 30 Oct 2024 04:01:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1730286107; x=1730890907; darn=vger.kernel.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=EJGzqHo9qrTCAAwlf27yjT302x4NzmzPRcOQ+gtBk24=; b=qYc+697aqOs1n3Ry1sQjcjtuzVrBO0fwko+3ya1ZTf32gqlMMbdIYGpPx8q4MNBQTi T4sQ4K/u9LcOZjHmRK1QRfXUwLOlH891Mym6eJZzCHF0I0Zh7mehb6ij68qy7Tet14Ba XbiH4a77az5USUUixHcVYQfvrdX3DCvq3IvJh7e+xjo90F/31Ohu4hlZrPbLSQVZnPvk bBWN1QYjPNY395lu8z8Gbhh14mINhK9BVMwYFlCU9ckwpb/tJh1DIFlIT6PLx+tvzDL4 A7bfzggXlr071yHn5/tezLVM8TS3j8wsEDOjx9blle2DEmlj+cg6sDL7lMzvOwqlAkW8 M+xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730286107; x=1730890907; 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=EJGzqHo9qrTCAAwlf27yjT302x4NzmzPRcOQ+gtBk24=; b=CdWq0V8wO1wn7C9A+iBxO+zVX3Nse5WLS85kHK44StL+QMPmgueoiZuJXxyEclQX8i t3t+MZM33gQiNyGPH6ECtbz/73x9hbGAFjZLDm8p3PpHBp3YyD13qdOc/FR3PXDtI6rt QPPqVJF0nCF16WnuSx+BMNoGGIRFdSUWi+x/MHPamCNFnPcqs6PU35Tdc4eU9ypleBCE 9/Bii8V60JcdLmUIQau8+6kc7dUIiSHul/mpYQCDwJ1E+cSBSpAVw4363u7CqvsuUjwX dbTtTbNJWIdrbrJZnHQqwRj3i4lcXlV/eb8xdRAjTOtUqd6rDuCUb5TC6SwUIYLy+RNC x7FQ== X-Forwarded-Encrypted: i=1; AJvYcCXCHgAjR3oBba6378MijdGstAYFzuQjjhx2/TN6BjgBKbygdJzfOE0s5876LbDMl9HZcF6SUArOQxkO8HA=@vger.kernel.org X-Gm-Message-State: AOJu0YycneGIIPtq/PSjeqZQ0LHwWyasKNZqAlVQdZzulGjzapNp6KZv nkRyMGmrjU+Zsbvo79/2YkhLugrBhrqXuzQK/6VLbCVKj0WjLTFpsXWyfQANh84= X-Google-Smtp-Source: AGHT+IE5VulypisySsncZjnqUpvTj2AV1Yc80jON0brb1Iv05v/0FIWD5VcuOaypPQ/AlZFz+rbyng== X-Received: by 2002:a05:600c:5253:b0:431:55f3:d34e with SMTP id 5b1f17b1804b1-431b5739d3amr42501345e9.15.1730286107092; Wed, 30 Oct 2024 04:01:47 -0700 (PDT) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.190]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd99edebsm17956935e9.45.2024.10.30.04.01.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 04:01:46 -0700 (PDT) From: Claudiu X-Google-Original-From: Claudiu To: geert+renesas@glider.be, mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, alexandre.belloni@bootlin.com, magnus.damm@gmail.com, p.zabel@pengutronix.de Cc: linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH v5 06/10] arm64: dts: renesas: r9a08g045: Add VBATTB node Date: Wed, 30 Oct 2024 13:01:16 +0200 Message-Id: <20241030110120.332802-7-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> References: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Add the DT node for the VBATTB IP along with DT bindings for the clock it provides. Reviewed-by: Geert Uytterhoeven Signed-off-by: Claudiu Beznea --- Changes in v5: - dropped the status =3D "disabled"; for the vbattb-xtal node Changes in v4: - used clock-controller for the vbattb node name - move the node near scif0 for ordering - set the vbattb_xtal status as disabled to avoid having it exported in linux with frequency =3D 0 in boards that don't use it - collected tags Changes in v3: - dropped the child nodes of vbattb; along with this dropped ranges, interrupt-names, #address-cells, #size-cells - added vbattb_xtal as input clock for vbattb Changes in v2: - update compatibles - updated clocks and clock-names for clock-controller node - removed the power domain from the clock-controller as this is controlled by parent node in v2 arch/arm64/boot/dts/renesas/r9a08g045.dtsi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/arch/arm64/boot/dts/renesas/r9a08g045.dtsi b/arch/arm64/boot/d= ts/renesas/r9a08g045.dtsi index 067a26a66c24..a1d5084b074a 100644 --- a/arch/arm64/boot/dts/renesas/r9a08g045.dtsi +++ b/arch/arm64/boot/dts/renesas/r9a08g045.dtsi @@ -72,6 +72,18 @@ scif0: serial@1004b800 { status =3D "disabled"; }; =20 + vbattb: clock-controller@1005c000 { + compatible =3D "renesas,r9a08g045-vbattb"; + reg =3D <0 0x1005c000 0 0x1000>; + interrupts =3D ; + clocks =3D <&cpg CPG_MOD R9A08G045_VBAT_BCLK>, <&vbattb_xtal>; + clock-names =3D "bclk", "rtx"; + #clock-cells =3D <1>; + power-domains =3D <&cpg>; + resets =3D <&cpg R9A08G045_VBAT_BRESETN>; + status =3D "disabled"; + }; + i2c0: i2c@10090000 { compatible =3D "renesas,riic-r9a08g045", "renesas,riic-r9a09g057"; reg =3D <0 0x10090000 0 0x400>; @@ -425,4 +437,11 @@ timer { interrupt-names =3D "sec-phys", "phys", "virt", "hyp-phys", "hyp-virt"; }; + + vbattb_xtal: vbattb-xtal { + compatible =3D "fixed-clock"; + #clock-cells =3D <0>; + /* This value must be overridden by the board. */ + clock-frequency =3D <0>; + }; }; --=20 2.39.2 From nobody Mon Nov 25 03:04:33 2024 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 033D21E3DD7 for ; Wed, 30 Oct 2024 11:01:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286114; cv=none; b=NOLy8EMvBY6F4ji/0UZCh08YQ3drG+s4hdISpRce3TMdSM1tGuLGCfLVRYcC0/JP4Gzs8ubpexXZH0kE0gGM9u3pytFd/L1lsyoDD19xaRVoHLfCOqMRdtsw89Iw//Pz8C0adPK8FL8EqKlh5cvWGxTKMkzejo3jbafW9+StoG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286114; c=relaxed/simple; bh=6xtMMXXDmhpyzfk9l5ztEozds8JDDcUbVhXj7fK5hCs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CFj1LI549rzYiQa68gBNhS3/QOVPimgoYj/wKYC6KRGAtZLUsmnp+LM33Ljzwo4OdfDPlcuEiLS7iptKxe4QSwDuSWkJKpdDKk1d+wxOX8024t87aivXOY0Ph/WuHvn9Ovif3rINXmlq0kzKD9G6P2Cyv1u3/SAd8qXEGfoAbno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=YRVfF+Hi; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="YRVfF+Hi" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-539f7606199so6989765e87.0 for ; Wed, 30 Oct 2024 04:01:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1730286109; x=1730890909; darn=vger.kernel.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=0RaA8Oq2TnPgWUFVlg85ZPuyptoCXBTMqrBfg+ChE0c=; b=YRVfF+Hi6Z3/PDT/xE0Phm/DZyL7RAzyRtfHEyOEXtf+jh9N10C+mTTZhnNk0t/1my 1C6THXVhpJ7w/iMnJTe16oXnW8pcSzFuhmxM/on42bxrubxEcxPOlp6B4QL8AfcF5xYF 4cxz3iPMjKitUeNrQrnmpfLuM36f4iWReroEETEr01LjKWROaPBOqt9IaRWITH8Cva1t 1O+ur8MkDZ7+ESNHxu59Vz+YKlY3H0C56FcBlGlcrN2apGEkDK+P1ja38Hy/Ly6vUNj7 C7PliKFJAqkCw3CPyVZ86eJ4gzsDQ1b5TartIv63kS7/uSMt60l7XxS3Mkl9CUu+C5is XMWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730286109; x=1730890909; 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=0RaA8Oq2TnPgWUFVlg85ZPuyptoCXBTMqrBfg+ChE0c=; b=UnI0208NCNN2oCOnkhZsi0+JoHMfCqcgg8LBI6LYQLLlcW2OuokTTle+7yyqAnl7hJ I26Z3MoB1SUeDygVfALUNGT7xxKKB8zXPHdYDdLQU/TEUxpnfY+autZZrKMeDojua0tH OPGUZXLpfDY51hQ7vXBGFUzqarqc0KTjZC8u1cf7NTQ7dDfp2qhdYSx0oB08wFLga1yK 68IMIM1Pq4ff4UE2xATk6VR6hGW0870Od2NDPwMNcTRUOBo5RFNZinnKsgHye8VUVQW1 YHuNTStgMOZec+J8UuGq0kK370qt4suprLoG3K50qfEVKCKhx6nprtbNkg+o115A3Ted +qHA== X-Forwarded-Encrypted: i=1; AJvYcCVX0coPXss21qIm095v372kulwOz8VEE1YyeieJ/eAFUykNVpxcopeCO9DM5zV1S33ditRYxhFCiXuVxBc=@vger.kernel.org X-Gm-Message-State: AOJu0YxBCt4l2XxosBeTZehLvv3QkY5eT1TTDnRCE3BHBTwGcAD7alqb 77HhR3TNk80pTJnWk3KJaV5jR2KfMdXNEIYvQLgiVOgE1y7hvdIKLq/OXV/F2M8= X-Google-Smtp-Source: AGHT+IGLcUn8UrUCFSXa2wdI7F5DblgU1h3Tlqu+CabGKPz2NXZLaP7HRpfptZfpKopeGY3o0sPrRg== X-Received: by 2002:ac2:4c4b:0:b0:52f:ca2b:1d33 with SMTP id 2adb3069b0e04-53b7ece170dmr1555512e87.20.1730286108705; Wed, 30 Oct 2024 04:01:48 -0700 (PDT) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.190]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd99edebsm17956935e9.45.2024.10.30.04.01.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 04:01:48 -0700 (PDT) From: Claudiu X-Google-Original-From: Claudiu To: geert+renesas@glider.be, mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, alexandre.belloni@bootlin.com, magnus.damm@gmail.com, p.zabel@pengutronix.de Cc: linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH v5 07/10] arm64: dts: renesas: r9a08g045: Add RTC node Date: Wed, 30 Oct 2024 13:01:17 +0200 Message-Id: <20241030110120.332802-8-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> References: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Add the DT node for the RTC IP available on the Renesas RZ/G3S SoC. Reviewed-by: Geert Uytterhoeven Signed-off-by: Claudiu Beznea --- Changes in v5: - collected tags Changes in v4: - dropped the assigned-clocks, assigned-clock-parents properties as they fit better on vbattb node - moved the RTC close to serial node for ordering Changes in v3: - added CPG clock, power domain, reset - and assigned-clocks, assigned-clock-parents to configure the VBATTCLK - included dt-bindings/clock/r9a08g045-vbattb.h Changes in v2: - updated compatibles arch/arm64/boot/dts/renesas/r9a08g045.dtsi | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arm64/boot/dts/renesas/r9a08g045.dtsi b/arch/arm64/boot/d= ts/renesas/r9a08g045.dtsi index a1d5084b074a..be8a0a768c65 100644 --- a/arch/arm64/boot/dts/renesas/r9a08g045.dtsi +++ b/arch/arm64/boot/dts/renesas/r9a08g045.dtsi @@ -7,6 +7,7 @@ =20 #include #include +#include =20 / { compatible =3D "renesas,r9a08g045"; @@ -72,6 +73,20 @@ scif0: serial@1004b800 { status =3D "disabled"; }; =20 + rtc: rtc@1004ec00 { + compatible =3D "renesas,r9a08g045-rtca3", "renesas,rz-rtca3"; + reg =3D <0 0x1004ec00 0 0x400>; + interrupts =3D , + , + ; + interrupt-names =3D "alarm", "period", "carry"; + clocks =3D <&cpg CPG_MOD R9A08G045_VBAT_BCLK>, <&vbattb VBATTB_VBATTCLK= >; + clock-names =3D "bus", "counter"; + power-domains =3D <&cpg>; + resets =3D <&cpg R9A08G045_VBAT_BRESETN>; + status =3D "disabled"; + }; + vbattb: clock-controller@1005c000 { compatible =3D "renesas,r9a08g045-vbattb"; reg =3D <0 0x1005c000 0 0x1000>; --=20 2.39.2 From nobody Mon Nov 25 03:04:33 2024 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F2B21E7C3A for ; Wed, 30 Oct 2024 11:01:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286114; cv=none; b=iciuFdifsDWzfjDvFYBd5CI4fl1OtghvTfR+MchgTM+MNJDU0jZis8ZqKKNetWt/iXASUBIJ+J20XLQaHinh44HIbM1sSuf+su8kRliMPW6XOn48gzjPdEcnd5TaAy0EObCkUskJEgPnmIjoG7in06DpI/ceR9UO/i9GALOaYDs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286114; c=relaxed/simple; bh=KFwokuMw1FPK/d+QbmXe76gVKRCfIfuQJJ5Szt8cbuI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LjG1q5OLW+jLsw0FljZFy2HGmB3gJrkoADuecQGkiTVKu8ZqSd27+Mi5HB9DSwu11yDWSDxC+2gMdES7J99iKsW4mLHdkfflktXCVJuYjVyVYZj8VIxsIqyYrHXjbPm0t7kG5sHfzIyckRVkojPDcXrrP0rQ+Du2vGqqwRxEbGo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=foML93mn; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="foML93mn" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4315e9e9642so58259685e9.0 for ; Wed, 30 Oct 2024 04:01:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1730286110; x=1730890910; darn=vger.kernel.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=LfEYLhjMDeZH0WbYlTTTFbhTtromhzFBfjXyLFGdvks=; b=foML93mneT8qrVZ+PgUgcJQrcxR7FRzYhY8fo2T4K0JWklN2z1amHp3EFZVrnHQC/t aDhpcHs825p5jQP5NrY3P2oU8OGPQrBA9zwEAo6bKnZdgvttGZ5eTErqFR2/YxPwJgcL 3LCg3B79SNkqw+wBtcQCoBdUSf2NznvvdKS1vJP4ahROql24M7Z7ugrRMeqLPK62G7rw Q2ayJZ59BBTlJy39kSoGzSz2MnoLmYA7Lzzd4KLzEFicZaZcYOpOmjiv+LUlx2/VaSKn b7CSxPrjf7XSZGz+D/y4ftAFTipINhgOwpYSWG5XE2ZpU00XQ7bP8c6DBPMv//P3sbn4 iTeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730286110; x=1730890910; 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=LfEYLhjMDeZH0WbYlTTTFbhTtromhzFBfjXyLFGdvks=; b=scwlyYuCiG6H0pIPTNM61RQZPeezKz7eNy0x6lhs6dSuiCgeboZYKj62qHiD5UF9zl jBXqF4UH+2HAZ8STmjG3uxTNgFiiE+XbDc65t0umYbzG8nWu2QsVYjfBF84Vtgwm9CBi ifucuW8hz4dn9PWh2TxBCHiZWjLHEPZ4pipAvO7EwuKDYvsB8AmmU9eCi3NzMOnFGNS2 PT1UMdH0q9dtxy2c8yrCgPTvnmCZhmUq9EBS9gOZTazJx7/EYCgOC7CXPObALzgGYHIM L1wEZinDneXwhUVbWmvSyIm9xHvpG+PBL47su5KIcoVJrU3YReH0pznBoiMIZxtBAOOz bjWg== X-Forwarded-Encrypted: i=1; AJvYcCVUFEAKdmFK168MlG/PMq7W8RmJfB97Fq8TDoI63edSoO/zRneC3XO9W/IpICZldgTp0+83+lD8wDQqyBY=@vger.kernel.org X-Gm-Message-State: AOJu0YybEfy1I0yj449HGdfaBw1i1BpewjCpvCZKwPoHWDM9gffKg5i/ irnEVGvTqk/svfOGeuB/IH2ooIL/BkW/3fQTLTE76EaKaloT6O143/GnBlgh8j3kcWEvr3ehIkh G X-Google-Smtp-Source: AGHT+IFSBbnTsjzeDFuXW2ohx80Zl9EjjF5HTT3F6o10bua6BUx513xSS7WM3daoN9qpwdEzGQrg/Q== X-Received: by 2002:a05:600c:3ca3:b0:42c:bb96:340e with SMTP id 5b1f17b1804b1-4319ad317e5mr121837365e9.31.1730286110454; Wed, 30 Oct 2024 04:01:50 -0700 (PDT) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.190]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd99edebsm17956935e9.45.2024.10.30.04.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 04:01:49 -0700 (PDT) From: Claudiu X-Google-Original-From: Claudiu To: geert+renesas@glider.be, mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, alexandre.belloni@bootlin.com, magnus.damm@gmail.com, p.zabel@pengutronix.de Cc: linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH v5 08/10] arm64: dts: renesas: rzg3s-smarc-som: Enable VBATTB Date: Wed, 30 Oct 2024 13:01:18 +0200 Message-Id: <20241030110120.332802-9-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> References: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Enable the VBATTB controller. It provides the clock for RTC. Reviewed-by: Geert Uytterhoeven Signed-off-by: Claudiu Beznea --- Changes in v5: - dropped the status =3D "okay"; from vbattb_xtal node Changes in v4: - added assigned-clocks, assigned-clock-parents properties - set vbattb_xtal status =3D "okay" - collected tags Changes in v3: - updated patch description - dropped vbattclk - added renesas,vbattb-load-nanofarads on vbattb - moved vbattb before vbattb_xtal Changes in v2: - none arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi b/arch/arm64/= boot/dts/renesas/rzg3s-smarc-som.dtsi index 71424e69939e..30bb4f5a7dfd 100644 --- a/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi +++ b/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi @@ -5,6 +5,7 @@ * Copyright (C) 2023 Renesas Electronics Corp. */ =20 +#include #include #include =20 @@ -344,6 +345,17 @@ mux { }; }; =20 +&vbattb { + assigned-clocks =3D <&vbattb VBATTB_MUX>; + assigned-clock-parents =3D <&vbattb VBATTB_XC>; + quartz-load-femtofarads =3D <12500>; + status =3D "okay"; +}; + +&vbattb_xtal { + clock-frequency =3D <32768>; +}; + &wdt0 { timeout-sec =3D <60>; status =3D "okay"; --=20 2.39.2 From nobody Mon Nov 25 03:04:33 2024 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3E711E884D for ; Wed, 30 Oct 2024 11:01:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286116; cv=none; b=g3p3vfWZHOswQlO/Lgb/ZfEVd3jXuPNpijPVlzt7KhPywGQdQGZFrpWAA4IbSbGG4f8dtqB9cI7tBOepEzusliRHwSeNvJ0zk9VNWGYbYtt/Ltpj2pUs7SBMM58l0jTOmDK547C5I7LUvuGsgMLtkMDx9UtOgHujNbtniRfqE4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286116; c=relaxed/simple; bh=kyir3JEG5+6DbB/0JMXlelJP87co/+s1ZGU+FQQMA3k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EILp+kZkYLIZNSqtRV8+3vd/Iw6zU4Gnu/pWtK8T3HHA0DAnyNmIjC/GRcIv4A1tGHbqjqepGlFGudfhAfFJoZ8NNcJbs15ME4xPGs4nuRP/hOK1jpp2pSfJdd1PLsyhlK7ZVsEUULr6W0r2YVdLNUOO/1qUW43IJa/J9QeE7ak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=FJW+i4xV; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="FJW+i4xV" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4314fa33a35so60325375e9.1 for ; Wed, 30 Oct 2024 04:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1730286112; x=1730890912; darn=vger.kernel.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=T6d1zYErtt6QdLWN37Xr5fe5oN1ubht0jqLtcLPDyds=; b=FJW+i4xVJ5AEyqERaxA4g2xz4ZwpE5YXwkWNT2ge7pb+azrBBKMkzdIpkvF5gO9A/M +YZblq9RuCZSKyVJXaGcWs1WjD9LKngZhAyF2w9D4tQUZsxiNVTfl7bdY6wKF8w7tmlw iluXT88GwxqtllRE0goMuMuck4iQIdZyJtUqz1jDi40iXEvIU8ZjCoNc7mj7TEro38ct VrmASCxUTOuj03wx1YTxIkZAV4+6xmApAim0eWGdlv7pEyJ+lzLj9cwvDWOltlQN/ouk pnLhC5YI9bv9lQ3P4/KwjMTyY8kYNGWXT1f2s32P58irGhl8H67AZrpcefQC9qyR536A rf2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730286112; x=1730890912; 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=T6d1zYErtt6QdLWN37Xr5fe5oN1ubht0jqLtcLPDyds=; b=CyZVPMJF4/douZ9y9kR6y7n0V3khwG8InD1ssL9300hbGfteE1fqk8JFfnr36Wn6eV VYjVOUAEoY6f69dfn7ENh0nXTBhSDe3r09VtqsUgAJZGEF/8CosXaGoymh3SEC5Setr+ ZzBe/2PKr9dNyzHBCb9AJkEv3kYLHW2ChyRQ7RE7ZtKiTCVAKQIoaNuXerHAvLAkyKj5 9bT3cBECJwvSGfmMYNulFAxGADUVlxnEOTISwmz4fwfvoqLHqZFSFNTWACjx1IKK4uT2 03Ui1L9HaYBgs1Y717oVmpxYiyA2AAcRFLXJ9UoQE36/iGieyE8pHsPqbPMjYZTiMwcr 0WxA== X-Forwarded-Encrypted: i=1; AJvYcCV/vkW+xt1RtgY4DSP35rEqb6Og4gsso+rbrx885oHv5wAukG2qRDOMTNfLvzRo6uCWir5pyvrsIvirXY8=@vger.kernel.org X-Gm-Message-State: AOJu0YxL43Z3YL7eXvy+KPo2pwmUm4Zm99FdyVRWjHIuZyYSGw+YfYt4 HSe5eRVdjWal48JAwsMMFy+Qby/ftb0JrKTyzwpE0WWO7zVnJwTlbMHYwEh8jbU= X-Google-Smtp-Source: AGHT+IHGe0bvz9X7exQp8lHGjNHl0u1fiwa/DD0OtcpsRQbPlicMRE8mwu6Ni/h1QGYotgNsQMhw7w== X-Received: by 2002:a05:600c:1c9d:b0:431:5187:28dd with SMTP id 5b1f17b1804b1-431bb9d1675mr22685875e9.28.1730286112159; Wed, 30 Oct 2024 04:01:52 -0700 (PDT) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.190]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd99edebsm17956935e9.45.2024.10.30.04.01.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 04:01:51 -0700 (PDT) From: Claudiu X-Google-Original-From: Claudiu To: geert+renesas@glider.be, mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, alexandre.belloni@bootlin.com, magnus.damm@gmail.com, p.zabel@pengutronix.de Cc: linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH v5 09/10] arm64: dts: renesas: rzg3s-smarc-som: Enable RTC Date: Wed, 30 Oct 2024 13:01:19 +0200 Message-Id: <20241030110120.332802-10-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> References: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Enable RTC. Reviewed-by: Geert Uytterhoeven Signed-off-by: Claudiu Beznea --- Changes in v5: - none Changes in v4: - collected tags Changes in v3: - none Changes in v2: - none arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi b/arch/arm64/= boot/dts/renesas/rzg3s-smarc-som.dtsi index 30bb4f5a7dfd..2ed01d391554 100644 --- a/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi +++ b/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi @@ -345,6 +345,10 @@ mux { }; }; =20 +&rtc { + status =3D "okay"; +}; + &vbattb { assigned-clocks =3D <&vbattb VBATTB_MUX>; assigned-clock-parents =3D <&vbattb VBATTB_XC>; --=20 2.39.2 From nobody Mon Nov 25 03:04:33 2024 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 713951E907D for ; Wed, 30 Oct 2024 11:01:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286117; cv=none; b=UGTD4sZVbCMDut/F502ZC0ssMticMXrXoNnTbEfUsG9GXLLU1QJvev490LjIn+wqlPstPTFz2K1p1ovv/u51SfmDL3+v3uFQcNEptzVWSofLZVdWOdDyyiyyQ5cyNAV73CvW4DueV+uKZv0MgqnStAf746SN4c4nRMIylk7yNnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730286117; c=relaxed/simple; bh=ITkAAPBuQN7qt/2aNfaGc9Z5M3Kkbo9w1OZJ+C50G0I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CGYo+uDHrYn78TzKOZ1lQMo7p5YSTSSqnYpI1z0OYGL+viCklP2c4pvWjKHbAtFS7MTbBCLNIxoQXMYx38rgtlQOKtuaxwwg0SI5janOieOS5juGlpdRuVmsA3IuWQ89l0kQHCw76GpK1N6T3k05gJNkmWROMa6lnLiKgyWP3Dg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=P9uLa7ec; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="P9uLa7ec" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-43155afca99so4571275e9.1 for ; Wed, 30 Oct 2024 04:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1730286114; x=1730890914; darn=vger.kernel.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=+rgH4N0XoiBaBn2DnREg2ur7KL1nWjEyXhZb98mz/Ng=; b=P9uLa7ecQkPsoGz3RFrnra7DW5aBagtOIpPsbpt53gnQ9vVcGKyYW7z7M1bF8R93UH e4+2dsOfUzaSBt6iZp9QqEtBzS5uX5o+CQ59fvcW3py37oE40wb19nbCcLhB5hCnPhCG G+knFDa5uWzy5P0Pj7h/SVEXAg0N9/4BBk4WkYTImh+CsYwC/y2eZDqejaVziy5+AB1F NtCn0vkwnKT7D6LUCa7g68/t+UIPjGsub0X+Tq4JG/kpfiZnzatJH7QVWtKh9MbhdEnQ kjrzuk4eCAewgTEICLU0gLjv/3kBckHfxAnhDbeXEf4U/80vHbHf+liLAyLXQ3w0HyDQ TcoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730286114; x=1730890914; 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=+rgH4N0XoiBaBn2DnREg2ur7KL1nWjEyXhZb98mz/Ng=; b=uqAQqwDIuh5ZH+2C/IRwxN4fS08Xg9PT385vg2zL+p+Q7zOcVEyVH66OnBq2qkqeVR N89IoM2MhmiSj/2G+DKNYeadMfS15bMW8L7xxqsoobELNIulNRESvXEqkhkhFT88Z48J WXEaWGxJtmhMhSr93pbgYv12UyrVSyMA99Ewh6ock/R1wzsmVseXOfjhrRoGKe5dYId8 6/3R1ZJE+elYzv1CKuKazmwGAY8X+9OGulHz6yLXG0lvoRi2HWiovBhhGmpToBQSHqyt JvEgBnV7xGNZRbQ7XnxxP4lmBT0zNh8SqobAoubF9+dpyWfve61fOLKeNcCuBfZGNCed 0naw== X-Forwarded-Encrypted: i=1; AJvYcCUiHbdoi2OIX6cNSNhLOTs38Ur8OeLh9PxqMiqw7xs1NSfbN9IhurD7e4LM6ZyOO4Ryf4DPreW9BuXDIRU=@vger.kernel.org X-Gm-Message-State: AOJu0YyxblOdHjpAkLX2wtx/a6EU0IzNfWhJCuQ5p/EO7zz8RtPjAN13 GY3zs5Fc5aJfL6q/tz3U6XX22dDjjpKscd5uLCOtcz3W+qdiOL24aqdLn5PY7KI= X-Google-Smtp-Source: AGHT+IGfKyeSaef4KGaUGWI/IsN7D3+8OWnPlyJSqw8C74dZyJJbZrKCWAh3Eh0KnB9ZpF56LKeAYw== X-Received: by 2002:a05:600c:1c96:b0:431:55af:a220 with SMTP id 5b1f17b1804b1-431b5729f16mr45142475e9.12.1730286113827; Wed, 30 Oct 2024 04:01:53 -0700 (PDT) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.190]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd99edebsm17956935e9.45.2024.10.30.04.01.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 04:01:53 -0700 (PDT) From: Claudiu X-Google-Original-From: Claudiu To: geert+renesas@glider.be, mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, alexandre.belloni@bootlin.com, magnus.damm@gmail.com, p.zabel@pengutronix.de Cc: linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH v5 10/10] arm64: defconfig: Enable VBATTB clock and Renesas RTCA-3 flags Date: Wed, 30 Oct 2024 13:01:20 +0200 Message-Id: <20241030110120.332802-11-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> References: <20241030110120.332802-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea Enable the Renesas VBATTB clock and RTCA-3 RTC drivers. These are available on the Renesas RZ/G3S SoC. VBATTB is the clock provider for the RTC counter. Reviewed-by: Geert Uytterhoeven Signed-off-by: Claudiu Beznea --- Changes in v5: - none Changes in v4: - squashed w/ patch "arm64: defconfig: Enable Renesas RTCA-3 flag" from v3 - updated patch description - collected tags Changes in v3: - update patch title and description - dropped CONFIG_MFD_RENESAS_VBATTB Changes in v2: - added CONFIG_MFD_RENESAS_VBATTB - added vendor name in the VBATTB clock flag arch/arm64/configs/defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index 0fad83642034..4f4fe8d9125c 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -1222,6 +1222,7 @@ CONFIG_RTC_DRV_IMX_SC=3Dm CONFIG_RTC_DRV_MT6397=3Dm CONFIG_RTC_DRV_XGENE=3Dy CONFIG_RTC_DRV_TI_K3=3Dm +CONFIG_RTC_DRV_RENESAS_RTCA3=3Dy CONFIG_DMADEVICES=3Dy CONFIG_DMA_BCM2835=3Dy CONFIG_DMA_SUN6I=3Dm @@ -1371,6 +1372,7 @@ CONFIG_SM_VIDEOCC_8250=3Dy CONFIG_QCOM_HFPLL=3Dy CONFIG_CLK_GFM_LPASS_SM8250=3Dm CONFIG_CLK_RCAR_USB2_CLOCK_SEL=3Dy +CONFIG_CLK_RENESAS_VBATTB=3Dy CONFIG_HWSPINLOCK=3Dy CONFIG_HWSPINLOCK_QCOM=3Dy CONFIG_TEGRA186_TIMER=3Dy --=20 2.39.2