From: Geert Uytterhoeven <geert+renesas@glider.be>
To: Philipp Zabel <p.zabel@pengutronix.de>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@codeaurora.org>,
Simon Horman <horms@verge.net.au>,
Magnus Damm <magnus.damm@gmail.com>
Cc: devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>
Subject: [PATCH v4 02/23] soc: renesas: Add R-Car RST driver
Date: Fri, 21 Oct 2016 15:17:16 +0200 [thread overview]
Message-ID: <1477055857-17936-3-git-send-email-geert+renesas@glider.be> (raw)
In-Reply-To: <1477055857-17936-1-git-send-email-geert+renesas@glider.be>
Add a driver for the Renesas R-Car Gen1 RESET/WDT and R-Car Gen2/Gen3
and RZ/G RST module.
For now this driver just provides an API to obtain the state of the mode
pins, as latched at reset time. As this is typically called from the
probe function of a clock driver, which can run much earlier than any
initcall, calling rcar_rst_read_mode_pins() just forces an early
initialization of the driver.
Despite the current simple and almost identical handling for all
supported SoCs, the driver matches against SoC-specific compatible
values, as the features provided by the hardware module differ a lot
across the various SoC families and members.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Dirk Behme <dirk.behme@de.bosch.com>
---
v4:
- Add Acked-by,
- Remove the initcall and the rcar_rst_base check in rcar_rst_init(),
as rcar_rst_init() is only used as a support function for
rcar_rst_read_mode_pins(),
- Refer to rcar_rst_gen2 for R-Car Gen3 instead of providing an
identical copy,
- Add RZ/G1M and RZ/G1E,
v3:
- New.
---
drivers/soc/renesas/Makefile | 5 ++
drivers/soc/renesas/rcar-rst.c | 92 ++++++++++++++++++++++++++++++++++++
include/linux/soc/renesas/rcar-rst.h | 6 +++
3 files changed, 103 insertions(+)
create mode 100644 drivers/soc/renesas/rcar-rst.c
create mode 100644 include/linux/soc/renesas/rcar-rst.h
diff --git a/drivers/soc/renesas/Makefile b/drivers/soc/renesas/Makefile
index 623039c3514cdc34..86cc78cd1962701a 100644
--- a/drivers/soc/renesas/Makefile
+++ b/drivers/soc/renesas/Makefile
@@ -1,3 +1,8 @@
+obj-$(CONFIG_ARCH_RCAR_GEN1) += rcar-rst.o
+obj-$(CONFIG_ARCH_RCAR_GEN2) += rcar-rst.o
+obj-$(CONFIG_ARCH_R8A7795) += rcar-rst.o
+obj-$(CONFIG_ARCH_R8A7796) += rcar-rst.o
+
obj-$(CONFIG_ARCH_R8A7779) += rcar-sysc.o r8a7779-sysc.o
obj-$(CONFIG_ARCH_R8A7790) += rcar-sysc.o r8a7790-sysc.o
obj-$(CONFIG_ARCH_R8A7791) += rcar-sysc.o r8a7791-sysc.o
diff --git a/drivers/soc/renesas/rcar-rst.c b/drivers/soc/renesas/rcar-rst.c
new file mode 100644
index 0000000000000000..a6d1c26d31675cf3
--- /dev/null
+++ b/drivers/soc/renesas/rcar-rst.c
@@ -0,0 +1,92 @@
+/*
+ * R-Car Gen1 RESET/WDT, R-Car Gen2, Gen3, and RZ/G RST Driver
+ *
+ * Copyright (C) 2016 Glider bvba
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/of_address.h>
+#include <linux/soc/renesas/rcar-rst.h>
+
+struct rst_config {
+ unsigned int modemr; /* Mode Monitoring Register Offset */
+};
+
+static const struct rst_config rcar_rst_gen1 __initconst = {
+ .modemr = 0x20,
+};
+
+static const struct rst_config rcar_rst_gen2 __initconst = {
+ .modemr = 0x60,
+};
+
+static const struct of_device_id rcar_rst_matches[] __initconst = {
+ /* RZ/G is handled like R-Car Gen2 */
+ { .compatible = "renesas,r8a7743-rst", .data = &rcar_rst_gen2 },
+ { .compatible = "renesas,r8a7745-rst", .data = &rcar_rst_gen2 },
+ /* R-Car Gen1 */
+ { .compatible = "renesas,r8a7778-reset-wdt", .data = &rcar_rst_gen1 },
+ { .compatible = "renesas,r8a7779-reset-wdt", .data = &rcar_rst_gen1 },
+ /* R-Car Gen2 */
+ { .compatible = "renesas,r8a7790-rst", .data = &rcar_rst_gen2 },
+ { .compatible = "renesas,r8a7791-rst", .data = &rcar_rst_gen2 },
+ { .compatible = "renesas,r8a7792-rst", .data = &rcar_rst_gen2 },
+ { .compatible = "renesas,r8a7793-rst", .data = &rcar_rst_gen2 },
+ { .compatible = "renesas,r8a7794-rst", .data = &rcar_rst_gen2 },
+ /* R-Car Gen3 is handled like R-Car Gen2 */
+ { .compatible = "renesas,r8a7795-rst", .data = &rcar_rst_gen2 },
+ { .compatible = "renesas,r8a7796-rst", .data = &rcar_rst_gen2 },
+ { /* sentinel */ }
+};
+
+static void __iomem *rcar_rst_base __initdata;
+static u32 saved_mode __initdata;
+
+static int __init rcar_rst_init(void)
+{
+ const struct of_device_id *match;
+ const struct rst_config *cfg;
+ struct device_node *np;
+ void __iomem *base;
+ int error = 0;
+
+ np = of_find_matching_node_and_match(NULL, rcar_rst_matches, &match);
+ if (!np)
+ return -ENODEV;
+
+ base = of_iomap(np, 0);
+ if (!base) {
+ pr_warn("%s: Cannot map regs\n", np->full_name);
+ error = -ENOMEM;
+ goto out_put;
+ }
+
+ rcar_rst_base = base;
+ cfg = match->data;
+ saved_mode = ioread32(base + cfg->modemr);
+
+ pr_debug("%s: MODE = 0x%08x\n", np->full_name, saved_mode);
+
+out_put:
+ of_node_put(np);
+ return error;
+}
+
+int __init rcar_rst_read_mode_pins(u32 *mode)
+{
+ int error;
+
+ if (!rcar_rst_base) {
+ error = rcar_rst_init();
+ if (error)
+ return error;
+ }
+
+ *mode = saved_mode;
+ return 0;
+}
diff --git a/include/linux/soc/renesas/rcar-rst.h b/include/linux/soc/renesas/rcar-rst.h
new file mode 100644
index 0000000000000000..a18e0783946b66ec
--- /dev/null
+++ b/include/linux/soc/renesas/rcar-rst.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_SOC_RENESAS_RCAR_RST_H__
+#define __LINUX_SOC_RENESAS_RCAR_RST_H__
+
+int rcar_rst_read_mode_pins(u32 *mode);
+
+#endif /* __LINUX_SOC_RENESAS_RCAR_RST_H__ */
--
1.9.1
next prev parent reply other threads:[~2016-10-21 13:17 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-21 13:17 [PATCH v4 00/23] soc: renesas: Add R-Car RST driver for obtaining mode pin state Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 01/23] reset: Add renesas,rst DT bindings Geert Uytterhoeven
[not found] ` <1477055857-17936-2-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2016-10-21 15:48 ` Philipp Zabel
2016-10-30 20:41 ` Rob Herring
2016-10-21 13:17 ` Geert Uytterhoeven [this message]
2016-10-21 13:17 ` [PATCH v4 03/23] ARM: dts: r8a7778: Add device node for RESET/WDT module Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 04/23] ARM: dts: r8a7779: " Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 06/23] ARM: dts: r8a7791: Add device node for RST module Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 07/23] ARM: dts: r8a7792: " Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 08/23] ARM: dts: r8a7793: " Geert Uytterhoeven
[not found] ` <1477055857-17936-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2016-10-21 13:17 ` [PATCH v4 05/23] ARM: dts: r8a7790: " Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 09/23] ARM: dts: r8a7794: " Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 13/23] clk: renesas: r8a7779: Obtain mode pin values from R-Car RST driver Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 14/23] clk: renesas: rcar-gen2: Obtain mode pin values using " Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 20/23] ARM: shmobile: rcar-gen2: Stop passing mode pins state to clock driver Geert Uytterhoeven
2016-11-01 13:35 ` Sergei Shtylyov
2016-11-02 8:09 ` Geert Uytterhoeven
2016-10-21 15:45 ` [PATCH v4 00/23] soc: renesas: Add R-Car RST driver for obtaining mode pin state Philipp Zabel
[not found] ` <1477064730.2508.24.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-10-21 15:47 ` Philipp Zabel
2016-10-26 11:56 ` Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 10/23] arm64: renesas: r8a7795 dtsi: Add device node for RST module Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 11/23] arm64: renesas: r8a7796 " Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 12/23] clk: renesas: r8a7778: Obtain mode pin values using R-Car RST driver Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 15/23] clk: renesas: r8a7795: Obtain mode pin values from " Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 16/23] clk: renesas: r8a7796: " Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 17/23] clk: renesas: rcar-gen3-cpg: Remove obsolete rcar_gen3_read_mode_pins() Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 18/23] ARM: shmobile: r8a7778: Stop passing mode pins state to clock driver Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 19/23] ARM: shmobile: r8a7779: " Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 21/23] clk: renesas: r8a7778: Remove obsolete r8a7778_clocks_init() Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 22/23] clk: renesas: r8a7779: Remove obsolete r8a7779_clocks_init() Geert Uytterhoeven
2016-10-21 13:17 ` [PATCH v4 23/23] clk: renesas: rcar-gen2: Remove obsolete rcar_gen2_clocks_init() Geert Uytterhoeven
2016-10-26 12:00 ` [PATCH v4 00/23] soc: renesas: Add R-Car RST driver for obtaining mode pin state Geert Uytterhoeven
[not found] ` <CAMuHMdVbpuv94x-ocTSDoEj+SbnESDbkuMXsXExQvoyZepp+Zg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-31 8:19 ` Simon Horman
[not found] ` <20161031081923.GF18195-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>
2016-10-31 8:32 ` Geert Uytterhoeven
[not found] ` <CAMuHMdXA-hemOT=ZysEfettei9=HsDddGhqddkw38hwRrdeagw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-31 23:25 ` Stephen Boyd
[not found] ` <20161031232537.GT16026-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-11-02 9:02 ` Geert Uytterhoeven
2016-11-04 19:49 ` Stephen Boyd
2016-11-07 9:30 ` Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1477055857-17936-3-git-send-email-geert+renesas@glider.be \
--to=geert+renesas@glider.be \
--cc=devicetree@vger.kernel.org \
--cc=horms@verge.net.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=mturquette@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=sboyd@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).