Skip to contentSkip to conversation

soc: renesas: Add R-Car RST driver for obtaining mode pin state

PATCH Superseded Geert Uytterhoeven 6 participants 42 messages Jun 1, 2016 – Sep 13, 2016 1 message not in the archive

Subsystems (7)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Geert Uytterhoeven

author maintainer
#0 lore raw

v3 cover soc: renesas: Add R-Car RST driver for obtaining mode pin state

Hi all,

Currently the R-Car Clock Pulse Generator (CPG) drivers obtains the state of the mode pins either by a call from the board code, or directly by using a hardcoded register access. This is a bit messy, and creates a dependency between driver and platform code.

This RFC patch series converts the various Renesas R-Car clock drivers and support code from reading the mode pin states using a hardcoded register access to using a new R-Car RST driver.

This series consists of 5 parts:
A. Patches 1 and 2 add DT bindings and driver code for the R-Car RST
driver,
B. Patches 3-10 add device nodes for the RST modules to the R-Car DTS
files,
C. Patches 11-16 convert the clock drivers to call into the new R-Car
RST driver,
D. Patches 17-19 remove passing mode pin state to the clock drivers
from the board code,
E. Patches 20-22 remove dead code from the clock drivers.

I've kept all parts together as this is an RFC, and to avoid losing the bigger picture. I will split it in series per maintainer, when we have decided how to handle the dependencies (see below).

After this, there are still a few users of rcar_gen2_read_mode_pins() left in board code, which should be converted in one way or another. However, all R-Car clock drivers will rely on the presence in DT of a device node for the RST module. Backwards compatibility with old DTBs is retained only for R-Car Gen2, which has fallback code calling into rcar_gen2_read_mode_pins().

As is usually the case with moving functionality from board code to DT, there are lots of hard dependencies:
- The DT updates in Part B can be merged as soon as the DT bindings in Part A have been approved,
- The clock driver updates in Part C depend functionally on the driver code in Part A,
- The board code cleanups in Part D depend on the clock driver updates in Part C,
- The block driver cleanups in part E depend on the board code cleanups in part D.

This series has evolved over time, cfr.
- "[PATCH/RFC 00/11] ARM: shmobile: Let CPG use syscon for MD pin

    values" (http://www.spinics.net/lists/linux-clk/msg01478.html),
  - "[PATCH 00/10] arm64: renesas: Obtain MD pin values using
    syscon/regmap".
    (http://www.spinics.net/lists/linux-sh/msg44757.html)

Changes compared to v2:
- Use "renesas,<soctype>-rst" instead of "renesas,rst-<soctype>",
- Drop "syscon" compatible value and "renesas,modemr" property, use a real driver instead,
- Add support for R-Car M1A, H1, and M3-W.

Changes compared to v1:
- Add support for R-Car H3.

An alternative and broader solution was proposed by Simon Horman as "[PATCH/RFC 0/6] boot-mode-reg: Add core"
(http://www.spinics.net/lists/linux-sh/msg45969.html).

This patch series is against renesas-drivers.
It has been tested on r8a7778/bockw, r8a7779/marzen, r8a7791/koelsch, and r8a7795/salvator-x.

Thanks for your comments!

Geert Uytterhoeven (22):
reset: Add renesas,rst DT bindings
soc: renesas: Add R-Car RST driver
ARM: dts: r8a7778: Add device node for RESET/WDT module
ARM: dts: r8a7779: Add device node for RESET/WDT module
ARM: dts: r8a7790: Add device node for RST module
ARM: dts: r8a7791: Add device node for RST module
ARM: dts: r8a7793: Add device node for RST module
ARM: dts: r8a7794: Add device node for RST module
arm64: renesas: r8a7795 dtsi: Add device node for RST module
arm64: renesas: r8a7796 dtsi: Add device node for RST module
clk: renesas: r8a7778: Obtain mode pin values using R-Car RST driver
clk: renesas: r8a7779: Obtain mode pin values from R-Car RST driver
clk: renesas: rcar-gen2: Obtain mode pin values using RST driver
clk: renesas: r8a7795: Obtain mode pin values from R-Car RST driver
clk: renesas: r8a7796: Obtain mode pin values from R-Car RST driver
clk: renesas: rcar-gen3-cpg: Remove obsolete

    rcar_gen3_read_mode_pins()

ARM: shmobile: r8a7778: Stop passing mode pins state to clock driver
ARM: shmobile: r8a7779: Stop passing mode pins state to clock driver
ARM: shmobile: rcar-gen2: Stop passing mode pins state to clock driver
clk: renesas: r8a7778: Remove obsolete r8a7778_clocks_init()
clk: renesas: r8a7779: Remove obsolete r8a7779_clocks_init()
clk: renesas: rcar-gen2: Remove obsolete rcar_gen2_clocks_init()

 .../devicetree/bindings/reset/renesas,rst.txt      | 35 ++++++++
 arch/arm/boot/dts/r8a7778.dtsi                     |  5 ++
 arch/arm/boot/dts/r8a7779.dtsi                     |  5 ++
 arch/arm/boot/dts/r8a7790.dtsi                     |  5 ++
 arch/arm/boot/dts/r8a7791.dtsi                     |  5 ++
 arch/arm/boot/dts/r8a7793.dtsi                     |  5 ++
 arch/arm/boot/dts/r8a7794.dtsi                     |  5 ++
 arch/arm/mach-shmobile/setup-r8a7778.c             | 15 ----
 arch/arm/mach-shmobile/setup-r8a7779.c             | 27 -------
 arch/arm/mach-shmobile/setup-rcar-gen2.c           |  6 +-
 arch/arm64/boot/dts/renesas/r8a7795.dtsi           |  5 ++
 arch/arm64/boot/dts/renesas/r8a7796.dtsi           |  5 ++
 drivers/clk/renesas/clk-r8a7778.c                  | 26 +++---
 drivers/clk/renesas/clk-r8a7779.c                  | 18 ++---
 drivers/clk/renesas/clk-rcar-gen2.c                | 17 ++--
 drivers/clk/renesas/r8a7795-cpg-mssr.c             |  8 +-
 drivers/clk/renesas/r8a7796-cpg-mssr.c             |  8 +-
 drivers/clk/renesas/rcar-gen3-cpg.c                | 17 ----
 drivers/clk/renesas/rcar-gen3-cpg.h                |  1 -
 drivers/soc/renesas/Makefile                       |  5 ++
 drivers/soc/renesas/rcar-rst.c                     | 94 ++++++++++++++++++++++
 include/linux/clk/renesas.h                        |  4 -
 include/linux/soc/renesas/rcar-rst.h               |  6 ++
 23 files changed, 227 insertions(+), 100 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/reset/renesas,rst.txt
 create mode 100644 drivers/soc/renesas/rcar-rst.c
 create mode 100644 include/linux/soc/renesas/rcar-rst.h
Signature · 12 lines
1.9.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
author maintainer
#1 lore raw

PATCH v3 1/22 reset: Add renesas,rst DT bindings

Add DT bindings for the Renesas R-Car Reset Controller (R-Car Gen1 RESET/WDT and R-Car Gen2/Gen3 RST).

As the features provided by the hardware module differ a lot across the various SoC families and members, only SoC-specific compatible values are defined.

For now we use the RST only for providing access to the state of the mode pins.

---
v3:
- Clarify current usage,
- Use "renesas,<soctype>-rst" instead of "renesas,rst-<soctype>",
- Drop "syscon" compatible value,
- Add R-Car M3-W,
- Add R-Car Gen1,

v2:
- Add Acked-by.

---
 .../devicetree/bindings/reset/renesas,rst.txt      | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reset/renesas,rst.txt
Documentation/devicetree/bindings/reset/renesas,rst.txt new file +35 -0
new file mode 100644
index 0000000000000000..488c72e1ee849cd3
@@ -0,0 +1,35 @@
+DT bindings for the Renesas R-Car Reset Controller
+
+The R-Car Reset Controller provides reset control, and implements the following
+functions:
+  - Latching of the levels on mode pins when PRESET# is negated,
+  - Mode monitoring register,
+  - Reset control of peripheral devices (on R-Car Gen1),
+  - Watchdog timer (on R-Car Gen1).
+  - Register-based reset control and boot address registers for the various CPU
+    cores (on R-Car Gen2/Gen3),
+
+
+Required properties:
+  - compatible: Should be
+		  - "renesas,<soctype>-reset-wdt" for R-Car Gen1,
+		  - "renesas,<soctype>-rst" for R-Car Gen2/Gen3.
+		Examples with soctypes are:
+		  - "renesas,r8a7778-reset-wdt" (R-Car M1A)
+		  - "renesas,r8a7779-reset-wdt" (R-Car H1)
+		  - "renesas,r8a7790-rst" (R-Car H2)
+		  - "renesas,r8a7791-rst" (R-Car M2-W)
+		  - "renesas,r8a7792-rst" (R-Car V2H
+		  - "renesas,r8a7793-rst" (R-Car M2-N)
+		  - "renesas,r8a7794-rst" (R-Car E2)
+		  - "renesas,r8a7795-rst" (R-Car H3)
+		  - "renesas,r8a7796-rst" (R-Car M3-W)
+  - reg: Address start and address range for the device.
+
+
+Example:
+
+	rst: reset-controller@e6160000 {
+		compatible = "renesas,r8a7795-rst";
+		reg = <0 0xe6160000 0 0x0200>;
+	};
Signature · 1 line
1.9.1
#2 lore raw

PATCH v3 1/22 reset: Add renesas,rst DT bindings

Quoted 33 lines · Geert Uytterhoeven

Add DT bindings for the Renesas R-Car Reset Controller (R-Car Gen1 RESET/WDT and R-Car Gen2/Gen3 RST).

As the features provided by the hardware module differ a lot across the various SoC families and members, only SoC-specific compatible values are defined.

For now we use the RST only for providing access to the state of the mode pins.

---
v3:
- Clarify current usage,
- Use "renesas,<soctype>-rst" instead of "renesas,rst-<soctype>",
- Drop "syscon" compatible value,
- Add R-Car M3-W,
- Add R-Car Gen1,

v2:
- Add Acked-by.

---
 .../devicetree/bindings/reset/renesas,rst.txt      | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reset/renesas,rst.txt
Documentation/devicetree/bindings/reset/renesas,rst.txt new file +0 -0
new file mode 100644
index 0000000000000000..488c72e1ee849cd3

Documentation/devicetree/bindings/reset/renesas,rst.txt line 8

Quoted 8 lines
Documentation/devicetree/bindings/reset/renesas,rst.txt new file +8 -0
@@ -0,0 +1,35 @@
+DT bindings for the Renesas R-Car Reset Controller
+
+The R-Car Reset Controller provides reset control, and implements the following
+functions:
+  - Latching of the levels on mode pins when PRESET# is negated,
+  - Mode monitoring register,
+  - Reset control of peripheral devices (on R-Car Gen1),
+  - Watchdog timer (on R-Car Gen1).

Quite minor nit: s/./,/

Or drop all the ',' completely?

Documentation/devicetree/bindings/reset/renesas,rst.txt line 10

Quoted 2 lines
Documentation/devicetree/bindings/reset/renesas,rst.txt new file +2 -0
+  - Register-based reset control and boot address registers for the various CPU
+    cores (on R-Car Gen2/Gen3),

Best regards

Dirk

#3 lore raw

PATCH v3 1/22 reset: Add renesas,rst DT bindings

In reply to Geert Uytterhoeven

Hi Geert,

Thank you for the patch.

Quoted 52 lines · On Wednesday 01 Jun 2016 21:20:59 Geert Uytterhoeven wrote:

Add DT bindings for the Renesas R-Car Reset Controller (R-Car Gen1 RESET/WDT and R-Car Gen2/Gen3 RST).

As the features provided by the hardware module differ a lot across the various SoC families and members, only SoC-specific compatible values are defined.

For now we use the RST only for providing access to the state of the mode pins.

---
v3:
- Clarify current usage,
- Use "renesas,<soctype>-rst" instead of "renesas,rst-<soctype>",
- Drop "syscon" compatible value,
- Add R-Car M3-W,
- Add R-Car Gen1,

v2:
- Add Acked-by.

---
 .../devicetree/bindings/reset/renesas,rst.txt      | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reset/renesas,rst.txt
(quoted diff) +0 -0

b/Documentation/devicetree/bindings/reset/renesas,rst.txt new file mode 100644
index 0000000000000000..488c72e1ee849cd3

Documentation/devicetree/bindings/reset/renesas,rst.txt new file +3 -0
@@ -0,0 +1,35 @@
+DT bindings for the Renesas R-Car Reset Controller
+
+The R-Car Reset Controller provides reset control, and implements the

following

Documentation/devicetree/bindings/reset/renesas,rst.txt new file +6 -0
+functions:
+  - Latching of the levels on mode pins when PRESET# is negated,
+  - Mode monitoring register,
+  - Reset control of peripheral devices (on R-Car Gen1),
+  - Watchdog timer (on R-Car Gen1).
+  - Register-based reset control and boot address registers for the various

CPU

Documentation/devicetree/bindings/reset/renesas,rst.txt new file +7 -0
+    cores (on R-Car Gen2/Gen3),
+
+
+Required properties:
+  - compatible: Should be
+		  - "renesas,<soctype>-reset-wdt" for R-Car Gen1,
+		  - "renesas,<soctype>-rst" for R-Car Gen2/Gen3.

Documentation/devicetree/bindings/reset/renesas,rst.txt line 26

Quoted 10 lines
Documentation/devicetree/bindings/reset/renesas,rst.txt new file +10 -0
+		Examples with soctypes are:
+		  - "renesas,r8a7778-reset-wdt" (R-Car M1A)
+		  - "renesas,r8a7779-reset-wdt" (R-Car H1)
+		  - "renesas,r8a7790-rst" (R-Car H2)
+		  - "renesas,r8a7791-rst" (R-Car M2-W)
+		  - "renesas,r8a7792-rst" (R-Car V2H
+		  - "renesas,r8a7793-rst" (R-Car M2-N)
+		  - "renesas,r8a7794-rst" (R-Car E2)
+		  - "renesas,r8a7795-rst" (R-Car H3)
+		  - "renesas,r8a7796-rst" (R-Car M3-W)

Any specific reason for such a large indentation ? (I know this is really nitpicking)

Apart from that, it's just a bit of a shame we can't have generic compatible strings, but that would require additional DT properties to describe the reset controller features, and I assume that's not a path we want to take.

Quoted 9 lines
Documentation/devicetree/bindings/reset/renesas,rst.txt new file +9 -0
+  - reg: Address start and address range for the device.
+
+
+Example:
+
+	rst: reset-controller@e6160000 {
+		compatible = "renesas,r8a7795-rst";
+		reg = <0 0xe6160000 0 0x0200>;
+	};
Signature · 3 lines
Regards,

Laurent Pinchart
#4 lore raw

PATCH v3 1/22 reset: Add renesas,rst DT bindings

Hi Laurent,

Quoted 26 lines · Laurent Pinchart
Quoted 26 lines
Documentation/devicetree/bindings/reset/renesas,rst.txt new file +3 -0
@@ -0,0 +1,35 @@
+DT bindings for the Renesas R-Car Reset Controller
+
+The R-Car Reset Controller provides reset control, and implements the

following

Documentation/devicetree/bindings/reset/renesas,rst.txt new file +6 -0
+functions:
+  - Latching of the levels on mode pins when PRESET# is negated,
+  - Mode monitoring register,
+  - Reset control of peripheral devices (on R-Car Gen1),
+  - Watchdog timer (on R-Car Gen1).
+  - Register-based reset control and boot address registers for the various

CPU

Documentation/devicetree/bindings/reset/renesas,rst.txt new file +12 -0
+    cores (on R-Car Gen2/Gen3),
+
+
+Required properties:
+  - compatible: Should be
+               - "renesas,<soctype>-reset-wdt" for R-Car Gen1,
+               - "renesas,<soctype>-rst" for R-Car Gen2/Gen3.
+             Examples with soctypes are:
+               - "renesas,r8a7778-reset-wdt" (R-Car M1A)
+               - "renesas,r8a7779-reset-wdt" (R-Car H1)
+               - "renesas,r8a7790-rst" (R-Car H2)
+               - "renesas,r8a7791-rst" (R-Car M2-W)
Quoted 8 lines

Documentation/devicetree/bindings/reset/renesas,rst.txt line 26

Quoted 5 lines
Documentation/devicetree/bindings/reset/renesas,rst.txt new file +5 -0
+               - "renesas,r8a7792-rst" (R-Car V2H
+               - "renesas,r8a7793-rst" (R-Car M2-N)
+               - "renesas,r8a7794-rst" (R-Car E2)
+               - "renesas,r8a7795-rst" (R-Car H3)
+               - "renesas,r8a7796-rst" (R-Car M3-W)

Any specific reason for such a large indentation ? (I know this is really nitpicking)

To align the two paragraphs and lists.

Quoted 3 lines

Apart from that, it's just a bit of a shame we can't have generic compatible strings, but that would require additional DT properties to describe the reset controller features, and I assume that's not a path we want to take.

The reset controller is one of the few blocks that really differs between members
of the same family, due to the relationship with the various CPU cores.

Quoted 1 line

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer
#5 lore raw

PATCH v3 2/22 soc: renesas: Add R-Car RST driver

In reply to Geert Uytterhoeven

Add a driver for the Renesas R-Car Gen1 RESET/WDT and R-Car Gen2/Gen3 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() may force 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 only, as the features provided by the hardware module differ a lot across the various SoC families and members.

---
v3:
- New.

---
 drivers/soc/renesas/Makefile         |  5 ++
 drivers/soc/renesas/rcar-rst.c       | 94 ++++++++++++++++++++++++++++++++++++
 include/linux/soc/renesas/rcar-rst.h |  6 +++
 3 files changed, 105 insertions(+)
 create mode 100644 drivers/soc/renesas/rcar-rst.c
 create mode 100644 include/linux/soc/renesas/rcar-rst.h
drivers/soc/renesas/Makefile +5 -0
index f32a001c65c3ab44..0d732ff893dd8fba 100644
@@ -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
drivers/soc/renesas/rcar-rst.c new file +94 -0

94 lines not on this page · raw message

include/linux/soc/renesas/rcar-rst.h new file +6 -0
new file mode 100644
index 0000000000000000..a18e0783946b66ec
@@ -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__ */
Signature · 1 line
1.9.1
#6 lore raw

PATCH v3 2/22 soc: renesas: Add R-Car RST driver

Quoted 117 lines · Geert Uytterhoeven

Add a driver for the Renesas R-Car Gen1 RESET/WDT and R-Car Gen2/Gen3 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() may force 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 only, as the features provided by the hardware module differ a lot across the various SoC families and members.

---
v3:
- New.

---
 drivers/soc/renesas/Makefile         |  5 ++
 drivers/soc/renesas/rcar-rst.c       | 94 ++++++++++++++++++++++++++++++++++++
 include/linux/soc/renesas/rcar-rst.h |  6 +++
 3 files changed, 105 insertions(+)
 create mode 100644 drivers/soc/renesas/rcar-rst.c
 create mode 100644 include/linux/soc/renesas/rcar-rst.h
drivers/soc/renesas/Makefile +5 -0
index f32a001c65c3ab44..0d732ff893dd8fba 100644
@@ -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
drivers/soc/renesas/rcar-rst.c new file +72 -0
new file mode 100644
index 0000000000000000..1997c348c0853254
@@ -0,0 +1,94 @@
+/*
+ * R-Car Gen1 RESET/WDT and R-Car Gen2/Gen3 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 rst_config rcar_rst_gen3 __initconst = {
+	.modemr = 0x60,
+};
+
+static const struct of_device_id rcar_rst_matches[] __initconst = {
+	{ .compatible = "renesas,r8a7778-reset-wdt", .data = &rcar_rst_gen1 },
+	{ .compatible = "renesas,r8a7779-reset-wdt", .data = &rcar_rst_gen1 },
+	{ .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 },
+	{ .compatible = "renesas,r8a7795-rst", .data = &rcar_rst_gen3 },
+	{ .compatible = "renesas,r8a7796-rst", .data = &rcar_rst_gen3 },
+	{ /* 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;
+
+	if (rcar_rst_base)
+		return 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);

drivers/soc/renesas/rcar-rst.c line 82

Quoted 10 lines
drivers/soc/renesas/rcar-rst.c new file +10 -0
+
+	pr_debug("%s: MODE = 0x%08x\n", np->full_name, saved_mode);
+
+out_put:
+	of_node_put(np);
+	return error;
+}
+arch_initcall(rcar_rst_init);
+
+int __init rcar_rst_read_mode_pins(u32 *mode)

Just a style issue: Is the string 'pins' in the function name still relevant? I.e. what's about just 'rcar_rst_read_mode()'?

Best regards

Dirk

#7 lore raw

PATCH v3 2/22 soc: renesas: Add R-Car RST driver

Hi Dirk,

Quoted 4 lines · Dirk Behme
Quoted 1 line

+int __init rcar_rst_read_mode_pins(u32 *mode)

Just a style issue: Is the string 'pins' in the function name still relevant? I.e. what's about just 'rcar_rst_read_mode()'?

I feel "mode" is a too generic word for a public API.
It's used a several contexts inside the RST module (secure mode, 64-bit addressing mode, free-running mode, step-up mode).

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#8 lore raw

PATCH v3 2/22 soc: renesas: Add R-Car RST driver

Quoted 11 lines · Geert Uytterhoeven

Hi Dirk,

Quoted 4 lines · Dirk Behme
Quoted 1 line

+int __init rcar_rst_read_mode_pins(u32 *mode)

Just a style issue: Is the string 'pins' in the function name still relevant? I.e. what's about just 'rcar_rst_read_mode()'?

I feel "mode" is a too generic word for a public API.
It's used a several contexts inside the RST module (secure mode, 64-bit addressing mode, free-running mode, step-up mode).

What's about

rcar_rst_read_mode_monitor()

then?

Taken from the manual ;)

Best regards

Dirk

#9 lore raw

PATCH v3 2/22 soc: renesas: Add R-Car RST driver

In reply to Geert Uytterhoeven
Quoted 11 lines · On Friday 10 Jun 2016 09:58:28 Geert Uytterhoeven wrote:

Hi Dirk,

Quoted 4 lines · Dirk Behme
Quoted 1 line

+int __init rcar_rst_read_mode_pins(u32 *mode)

Just a style issue: Is the string 'pins' in the function name still relevant? I.e. what's about just 'rcar_rst_read_mode()'?

I feel "mode" is a too generic word for a public API.
It's used a several contexts inside the RST module (secure mode, 64-bit addressing mode, free-running mode, step-up mode).

<bikeshedding>

If it's "pins" that bothers Dirk, how about rcar_rst_read_boot_mode() ? Or maybe rcar_rst_boot_mode(), given that the function caches the value, it doesn't read it every time.

</bikeshedding>

Signature · 3 lines
Regards,

Laurent Pinchart
#10 lore raw

PATCH v3 2/22 soc: renesas: Add R-Car RST driver

In reply to Geert Uytterhoeven

Hi Geert,

Thank you for the patch.

Quoted 116 lines · On Wednesday 01 Jun 2016 21:21:00 Geert Uytterhoeven wrote:

Add a driver for the Renesas R-Car Gen1 RESET/WDT and R-Car Gen2/Gen3 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() may force 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 only, as the features provided by the hardware module differ a lot across the various SoC families and members.

---
v3:
- New.

---
 drivers/soc/renesas/Makefile         |  5 ++
 drivers/soc/renesas/rcar-rst.c       | 94 +++++++++++++++++++++++++++++++++
 include/linux/soc/renesas/rcar-rst.h |  6 +++
 3 files changed, 105 insertions(+)
 create mode 100644 drivers/soc/renesas/rcar-rst.c
 create mode 100644 include/linux/soc/renesas/rcar-rst.h
drivers/soc/renesas/Makefile +5 -0
index f32a001c65c3ab44..0d732ff893dd8fba 100644
@@ -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
drivers/soc/renesas/rcar-rst.c new file +6 -0
new file mode 100644
index 0000000000000000..1997c348c0853254
@@ -0,0 +1,94 @@
+/*
+ * R-Car Gen1 RESET/WDT and R-Car Gen2/Gen3 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.
+ */

drivers/soc/renesas/rcar-rst.c new file +61 -0
+
+#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 rst_config rcar_rst_gen3 __initconst = {
+	.modemr = 0x60,
+};
+
+static const struct of_device_id rcar_rst_matches[] __initconst = {
+	{ .compatible = "renesas,r8a7778-reset-wdt", .data = &rcar_rst_gen1 },
+	{ .compatible = "renesas,r8a7779-reset-wdt", .data = &rcar_rst_gen1 },
+	{ .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 },
+	{ .compatible = "renesas,r8a7795-rst", .data = &rcar_rst_gen3 },
+	{ .compatible = "renesas,r8a7796-rst", .data = &rcar_rst_gen3 },
+	{ /* 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;
+
+	if (rcar_rst_base)
+		return 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;

drivers/soc/renesas/rcar-rst.c line 80

Quoted 10 lines
drivers/soc/renesas/rcar-rst.c new file +10 -0
+	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;
+}
+arch_initcall(rcar_rst_init);

Given that rcar_rst_init() is only used as a support function for rcar_rst_read_mode_pins(), how about removing the initcall ?

Quoted 25 lines
drivers/soc/renesas/rcar-rst.c new file +13 -0
+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;
+}
(quoted diff) +0 -0

b/include/linux/soc/renesas/rcar-rst.h new file mode 100644 index 0000000000000000..a18e0783946b66ec

include/linux/soc/renesas/rcar-rst.h new file +6 -0
@@ -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__ */
Signature · 3 lines
Regards,

Laurent Pinchart
#11 lore raw

PATCH v3 2/22 soc: renesas: Add R-Car RST driver

Hi Laurent,

Quoted 5 lines · Laurent Pinchart
Quoted 5 lines
drivers/soc/renesas/rcar-rst.c new file +2 -0
 
+static int __init rcar_rst_init(void)
+{

[...]

Quoted 5 lines

drivers/soc/renesas/rcar-rst.c

Quoted 2 lines
drivers/soc/renesas/rcar-rst.c new file +2 -0
+}
+arch_initcall(rcar_rst_init);

Given that rcar_rst_init() is only used as a support function for rcar_rst_read_mode_pins(), how about removing the initcall ?

Thanks, good idea!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

A message that is not in the archive (sent off-list or not yet received): 1464808880-343-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org

#13 lore raw

PATCH v3 3/22 ARM: dts: r8a7778: Add device node for RESET/WDT module

Add a device node for the RESET/WDT module, which provides a.o. reset control, mode pin monitoring, and watchdog control.

---
v3:
- New.

---
 arch/arm/boot/dts/r8a7778.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/r8a7778.dtsi +5 -0
index e571d66ea0fe1721..3d0a18abd408c76d 100644
@@ -626,4 +626,9 @@
 				"sru-src6", "sru-src7", "sru-src8";
 		};
 	};
+
+	rst: reset-controller@ffcc0000 {
+		compatible = "renesas,r8a7778-reset-wdt";
+		reg = <0xffcc0000 0x40>;
+	};
 };
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#14 lore raw

PATCH v3 4/22 ARM: dts: r8a7779: Add device node for RESET/WDT module

In reply to a message not in the archive

Add a device node for the RESET/WDT module, which provides a.o. reset control, mode pin monitoring, and watchdog control.

---
v3:
- New.

---
 arch/arm/boot/dts/r8a7779.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/r8a7779.dtsi +5 -0
index b9bbcce69dfbd5b9..4a30b232624e1d24 100644
@@ -595,4 +595,9 @@
 		reg = <0xffd85000 0x0200>;
 		#power-domain-cells = <1>;
 	};
+
+	rst: reset-controller@ffcc0000 {
+		compatible = "renesas,r8a7779-reset-wdt";
+		reg = <0xffcc0000 0x48>;
+	};
 };
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#15 lore raw

PATCH v3 11/22 clk: renesas: r8a7778: Obtain mode pin values using R-Car RST driver

In reply to a message not in the archive

Obtain the values of the mode pins from the R-Car RST driver, which relies on the presence in DT of a device node for the RESET/WDT module.

---
v3:
- New.

---
 drivers/clk/renesas/clk-r8a7778.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/clk/renesas/clk-r8a7778.c +13 -0
index 40e3a501a50e200f..07ea411098a75ad1 100644
@@ -12,6 +12,7 @@
 #include <linux/clk/renesas.h>
 #include <linux/of_address.h>
 #include <linux/slab.h>
+#include <linux/soc/renesas/rcar-rst.h>
 
 struct r8a7778_cpg {
 	struct clk_onecell_data data;
@@ -83,6 +84,18 @@ static void __init r8a7778_cpg_clocks_init(struct device_node *np)
 	struct clk **clks;
 	unsigned int i;
 	int num_clks;
+	u32 mode;
+
+	if (rcar_rst_read_mode_pins(&mode))
+		return;
+
+	BUG_ON(!(mode & BIT(19)));
+
+	cpg_mode_rates = (!!(mode & BIT(18)) << 2) |
+			 (!!(mode & BIT(12)) << 1) |
+			 (!!(mode & BIT(11)));
+	cpg_mode_divs = (!!(mode & BIT(2)) << 1) |
+			(!!(mode & BIT(1)));
 
 	num_clks = of_property_count_strings(np, "clock-output-names");
 	if (num_clks < 0) {
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#16 lore raw

PATCH v3 12/22 clk: renesas: r8a7779: Obtain mode pin values from R-Car RST driver

In reply to a message not in the archive

Obtain the values of the mode pins from the R-Car RST driver, which relies on the presence in DT of a device node for the RESET/WDT module.

---
v3:
- New.

---
 drivers/clk/renesas/clk-r8a7779.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/clk/renesas/clk-r8a7779.c +7 -2
index cf2a37df03b15e60..ca7551bcb1153c3d 100644
@@ -18,6 +18,7 @@
 #include <linux/of_address.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/soc/renesas/rcar-rst.h>
 
 #include <dt-bindings/clock/r8a7779-clock.h>
 
@@ -127,6 +128,10 @@ static void __init r8a7779_cpg_clocks_init(struct device_node *np)
 	struct clk **clks;
 	unsigned int i, plla_mult;
 	int num_clks;
+	u32 mode;
+
+	if (rcar_rst_read_mode_pins(&mode))
+		return;
 
 	num_clks = of_property_count_strings(np, "clock-output-names");
 	if (num_clks < 0) {
@@ -148,8 +153,8 @@ static void __init r8a7779_cpg_clocks_init(struct device_node *np)
 	cpg->data.clks = clks;
 	cpg->data.clk_num = num_clks;
 
-	config = &cpg_clk_configs[CPG_CLK_CONFIG_INDEX(cpg_mode)];
-	plla_mult = cpg_plla_mult[CPG_PLLA_MULT_INDEX(cpg_mode)];
+	config = &cpg_clk_configs[CPG_CLK_CONFIG_INDEX(mode)];
+	plla_mult = cpg_plla_mult[CPG_PLLA_MULT_INDEX(mode)];
 
 	for (i = 0; i < num_clks; ++i) {
 		const char *name;
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#17 lore raw

PATCH v3 16/22 clk: renesas: rcar-gen3-cpg: Remove obsolete rcar_gen3_read_mode_pins()

In reply to a message not in the archive

All R-Car Gen3 clock drivers now obtain the values of the mode pins from the R-Car RST driver.

---
 drivers/clk/renesas/rcar-gen3-cpg.c | 17 -----------------
 drivers/clk/renesas/rcar-gen3-cpg.h |  1 -
 2 files changed, 18 deletions(-)
drivers/clk/renesas/rcar-gen3-cpg.c +0 -17
index bb4f2f9a8c2f5ba8..9d76076da4948fc4 100644
@@ -333,23 +333,6 @@ struct clk * __init rcar_gen3_cpg_clk_register(struct device *dev,
 					 __clk_get_name(parent), 0, mult, div);
 }
 
-/*
- * Reset register definitions.
- */
-#define MODEMR	0xe6160060
-
-u32 __init rcar_gen3_read_mode_pins(void)
-{
-	void __iomem *modemr = ioremap_nocache(MODEMR, 4);
-	u32 mode;
-
-	BUG_ON(!modemr);
-	mode = ioread32(modemr);
-	iounmap(modemr);
-
-	return mode;
-}
-
 int __init rcar_gen3_cpg_init(const struct rcar_gen3_cpg_pll_config *config,
 			      unsigned int clk_extalr)
 {
drivers/clk/renesas/rcar-gen3-cpg.h +0 -1
index f699085147d1aece..f788f481dd42cdf6 100644
@@ -33,7 +33,6 @@ struct rcar_gen3_cpg_pll_config {
 
 #define CPG_RCKCR	0x240
 
-u32 rcar_gen3_read_mode_pins(void);
 struct clk *rcar_gen3_cpg_clk_register(struct device *dev,
 	const struct cpg_core_clk *core, const struct cpg_mssr_info *info,
 	struct clk **clks, void __iomem *base);
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#18 lore raw

PATCH v3 16/22 clk: renesas: rcar-gen3-cpg: Remove obsolete rcar_gen3_read_mode_pins()

Hi Geert,

Thank you for the patch.

Quoted 4 lines · On Wednesday 01 Jun 2016 21:21:14 Geert Uytterhoeven wrote:

All R-Car Gen3 clock drivers now obtain the values of the mode pins from the R-Car RST driver.

Quoted 47 lines
---
 drivers/clk/renesas/rcar-gen3-cpg.c | 17 -----------------
 drivers/clk/renesas/rcar-gen3-cpg.h |  1 -
 2 files changed, 18 deletions(-)
(quoted diff) +0 -0

b/drivers/clk/renesas/rcar-gen3-cpg.c index
bb4f2f9a8c2f5ba8..9d76076da4948fc4 100644

drivers/clk/renesas/rcar-gen3-cpg.c +0 -17
@@ -333,23 +333,6 @@ struct clk * __init rcar_gen3_cpg_clk_register(struct
 device *dev, __clk_get_name(parent), 0, mult, div);
 }
 
-/*
- * Reset register definitions.
- */
-#define MODEMR	0xe6160060
-
-u32 __init rcar_gen3_read_mode_pins(void)
-{
-	void __iomem *modemr = ioremap_nocache(MODEMR, 4);
-	u32 mode;
-
-	BUG_ON(!modemr);
-	mode = ioread32(modemr);
-	iounmap(modemr);
-
-	return mode;
-}
-
 int __init rcar_gen3_cpg_init(const struct rcar_gen3_cpg_pll_config
 *config, unsigned int clk_extalr)
 {
(quoted diff) +0 -0

b/drivers/clk/renesas/rcar-gen3-cpg.h index
f699085147d1aece..f788f481dd42cdf6 100644

drivers/clk/renesas/rcar-gen3-cpg.h +0 -1
@@ -33,7 +33,6 @@ struct rcar_gen3_cpg_pll_config {
 
 #define CPG_RCKCR	0x240
 
-u32 rcar_gen3_read_mode_pins(void);
 struct clk *rcar_gen3_cpg_clk_register(struct device *dev,
 	const struct cpg_core_clk *core, const struct cpg_mssr_info *info,
 	struct clk **clks, void __iomem *base);
Signature · 3 lines
Regards,

Laurent Pinchart
#19 lore raw

PATCH v3 21/22 clk: renesas: r8a7779: Remove obsolete r8a7779_clocks_init()

In reply to a message not in the archive

The R-Car H1 board code no longer calls r8a7779_clocks_init().

---
v3:
- New.

---
 drivers/clk/renesas/clk-r8a7779.c | 9 ---------
 include/linux/clk/renesas.h       | 1 -
 2 files changed, 10 deletions(-)
drivers/clk/renesas/clk-r8a7779.c +0 -9
index ca7551bcb1153c3d..27fbfafaf2cd0353 100644
@@ -89,8 +89,6 @@ static const unsigned int cpg_plla_mult[4] __initconst = { 42, 48, 56, 64 };
  * Initialization
  */
 
-static u32 cpg_mode __initdata;
-
 static struct clk * __init
 r8a7779_cpg_register_clock(struct device_node *np, struct r8a7779_cpg *cpg,
 			   const struct cpg_clk_config *config,
@@ -178,10 +176,3 @@ static void __init r8a7779_cpg_clocks_init(struct device_node *np)
 }
 CLK_OF_DECLARE(r8a7779_cpg_clks, "renesas,r8a7779-cpg-clocks",
 	       r8a7779_cpg_clocks_init);
-
-void __init r8a7779_clocks_init(u32 mode)
-{
-	cpg_mode = mode;
-
-	of_clk_init(NULL);
-}
include/linux/clk/renesas.h +0 -1
index 2b663bba1adcc7c1..9e969941f3f62878 100644
@@ -20,7 +20,6 @@ struct device;
 struct device_node;
 struct generic_pm_domain;
 
-void r8a7779_clocks_init(u32 mode);
 void rcar_gen2_clocks_init(u32 mode);
 
 void cpg_mstp_add_clk_domain(struct device_node *np);
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author maintainer
#20 lore raw

PATCH v3 5/22 ARM: dts: r8a7790: Add device node for RST module

In reply to Geert Uytterhoeven

Add a device node for the RST module, which provides a.o. reset control and mode pin monitoring.

---
v3:
- Use "renesas,<soctype>-rst" instead of "renesas,rst-<soctype>",
- Drop "syscon" compatible value,

v2:
- Correct unit address,
- Drop RFC status and TODO,
- Change one-line summary prefix to match current arm-soc practices.

---
 arch/arm/boot/dts/r8a7790.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/r8a7790.dtsi +5 -0
index 9997e7dfabe2250c..0c548e9b180b6c1d 100644
@@ -1481,6 +1481,11 @@
 		};
 	};
 
+	rst: reset-controller@e6160000 {
+		compatible = "renesas,r8a7790-rst";
+		reg = <0 0xe6160000 0 0x0100>;
+	};
+
 	sysc: system-controller@e6180000 {
 		compatible = "renesas,r8a7790-sysc";
 		reg = <0 0xe6180000 0 0x0200>;
Signature · 1 line
1.9.1
author maintainer
#21 lore raw

PATCH v3 6/22 ARM: dts: r8a7791: Add device node for RST module

In reply to Geert Uytterhoeven

Add a device node for the RST module, which provides a.o. reset control and mode pin monitoring.

---
v3:
- Use "renesas,<soctype>-rst" instead of "renesas,rst-<soctype>",
- Drop "syscon" compatible value,

v2:
- Correct unit address,
- Drop RFC status and TODO,
- Change one-line summary prefix to match current arm-soc practices.

---
 arch/arm/boot/dts/r8a7791.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/r8a7791.dtsi +5 -0
index 1985bd0dc32ce738..f8f1371f3621d1a3 100644
@@ -1493,6 +1493,11 @@
 		};
 	};
 
+	rst: reset-controller@e6160000 {
+		compatible = "renesas,r8a7791-rst";
+		reg = <0 0xe6160000 0 0x0100>;
+	};
+
 	sysc: system-controller@e6180000 {
 		compatible = "renesas,r8a7791-sysc";
 		reg = <0 0xe6180000 0 0x0200>;
Signature · 1 line
1.9.1
author maintainer
#22 lore raw

PATCH v3 7/22 ARM: dts: r8a7793: Add device node for RST module

In reply to Geert Uytterhoeven

Add a device node for the RST module, which provides a.o. reset control and mode pin monitoring.

---
v3:
- Use "renesas,<soctype>-rst" instead of "renesas,rst-<soctype>",
- Drop "syscon" compatible value,

v2:
- Correct unit address,
- Drop RFC status and TODO,
- Change one-line summary prefix to match current arm-soc practices.

---
 arch/arm/boot/dts/r8a7793.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/r8a7793.dtsi +5 -0
index 9b55c1c6ee31a49d..5a6c9808410761ce 100644
@@ -1264,6 +1264,11 @@
 		};
 	};
 
+	rst: reset-controller@e6160000 {
+		compatible = "renesas,r8a7793-rst";
+		reg = <0 0xe6160000 0 0x0100>;
+	};
+
 	sysc: system-controller@e6180000 {
 		compatible = "renesas,r8a7793-sysc";
 		reg = <0 0xe6180000 0 0x0200>;
Signature · 1 line
1.9.1
author maintainer
#23 lore raw

PATCH v3 8/22 ARM: dts: r8a7794: Add device node for RST module

In reply to Geert Uytterhoeven

Add a device node for the RST module, which provides a.o. reset control and mode pin monitoring.

---
v3:
- Use "renesas,<soctype>-rst" instead of "renesas,rst-<soctype>",
- Drop "syscon" compatible value,

v2:
- Correct unit address,
- Drop RFC status and TODO,
- Change one-line summary prefix to match current arm-soc practices.

---
 arch/arm/boot/dts/r8a7794.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/r8a7794.dtsi +5 -0
index 685f986cf962752f..ce98f358ce731798 100644
@@ -1249,6 +1249,11 @@
 		};
 	};
 
+	rst: reset-controller@e6160000 {
+		compatible = "renesas,r8a7794-rst";
+		reg = <0 0xe6160000 0 0x0100>;
+	};
+
 	sysc: system-controller@e6180000 {
 		compatible = "renesas,r8a7794-sysc";
 		reg = <0 0xe6180000 0 0x0200>;
Signature · 1 line
1.9.1
author maintainer
#24 lore raw

PATCH v3 9/22 arm64: renesas: r8a7795 dtsi: Add device node for RST module

In reply to Geert Uytterhoeven

Add a device node for the RST module, which provides a.o. reset control and mode pin monitoring.

---
v3:
- Use "renesas,<soctype>-rst" instead of "renesas,rst-<soctype>",
- Drop "syscon" compatible value,

v2:
- New.

---
 arch/arm64/boot/dts/renesas/r8a7795.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/renesas/r8a7795.dtsi +5 -0
index 9297658534803f43..fca68d7b047dfa1d 100644
@@ -319,6 +319,11 @@
 			#power-domain-cells = <0>;
 		};
 
+		rst: reset-controller@e6160000 {
+			compatible = "renesas,r8a7795-rst";
+			reg = <0 0xe6160000 0 0x0200>;
+		};
+
 		sysc: system-controller@e6180000 {
 			compatible = "renesas,r8a7795-sysc";
 			reg = <0 0xe6180000 0 0x0400>;
Signature · 1 line
1.9.1
author maintainer
#25 lore raw

PATCH v3 10/22 arm64: renesas: r8a7796 dtsi: Add device node for RST module

In reply to Geert Uytterhoeven

Add a device node for the RST module, which provides a.o. reset control and mode pin monitoring.

---
v3:
- New.

---
 arch/arm64/boot/dts/renesas/r8a7796.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/renesas/r8a7796.dtsi +5 -0
index fab61eddede3818c..cb7cd9dceafe4c40 100644
@@ -107,6 +107,11 @@
 			#power-domain-cells = <0>;
 		};
 
+		rst: reset-controller@e6160000 {
+			compatible = "renesas,r8a7796-rst";
+			reg = <0 0xe6160000 0 0x0200>;
+		};
+
 		sysc: system-controller@e6180000 {
 			compatible = "renesas,r8a7796-sysc";
 			reg = <0 0xe6180000 0 0x0400>;
Signature · 1 line
1.9.1
author maintainer
#26 lore raw

PATCH v3 13/22 clk: renesas: rcar-gen2: Obtain mode pin values using RST driver

In reply to Geert Uytterhoeven

Obtain the values of the mode pins from the R-Car RST driver, which relies on the presence in DT of a device node for the RST module.

Fall back to calling rcar_gen2_read_mode_pins() in the R-Car Gen2 platform code for backward-compatibility with old DTs.

---
v3:
- Use the R-Car RST driver instead of syscon/regmap and the "renesas,modemr" property in DT,

v2:
- drivers/clk/shmobile/ was renamed to drivers/clk/renesas/.

---
 drivers/clk/renesas/clk-rcar-gen2.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/clk/renesas/clk-rcar-gen2.c +10 -0
index 00e6aba4b9c09596..436fc7a7714e4bd7 100644
@@ -19,6 +19,7 @@
 #include <linux/of_address.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/soc/renesas/rcar-rst.h>
 
 struct rcar_gen2_cpg {
 	struct clk_onecell_data data;
@@ -372,6 +373,15 @@ static void __init rcar_gen2_cpg_clocks_init(struct device_node *np)
 	unsigned int i;
 	int num_clks;
 
+	if (rcar_rst_read_mode_pins(&cpg_mode)) {
+		/* Backward-compatibility with old DT */
+		extern u32 rcar_gen2_read_mode_pins(void);
+
+		pr_warn("%s: failed to obtain mode pins from RST\n",
+			np->full_name);
+		cpg_mode = rcar_gen2_read_mode_pins();
+	}
+
 	num_clks = of_property_count_strings(np, "clock-output-names");
 	if (num_clks < 0) {
 		pr_err("%s: failed to count clocks\n", __func__);
Signature · 1 line
1.9.1
author maintainer
#27 lore raw

PATCH v3 14/22 clk: renesas: r8a7795: Obtain mode pin values from R-Car RST driver

In reply to Geert Uytterhoeven

Obtain the values of the mode pins from the R-Car RST driver, which relies on the presence in DT of a device node for the RST module.

---
v3:
- New.

---
 drivers/clk/renesas/r8a7795-cpg-mssr.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/clk/renesas/r8a7795-cpg-mssr.c +7 -1
index e53aff5b23ad4967..e1f2359a59feee7e 100644
@@ -15,6 +15,7 @@
 #include <linux/device.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/soc/renesas/rcar-rst.h>
 
 #include <dt-bindings/clock/r8a7795-cpg-mssr.h>
 
@@ -294,7 +295,12 @@ static const struct rcar_gen3_cpg_pll_config cpg_pll_configs[16] __initconst = {
 static int __init r8a7795_cpg_mssr_init(struct device *dev)
 {
 	const struct rcar_gen3_cpg_pll_config *cpg_pll_config;
-	u32 cpg_mode = rcar_gen3_read_mode_pins();
+	u32 cpg_mode;
+	int error;
+
+	error = rcar_rst_read_mode_pins(&cpg_mode);
+	if (error)
+		return error;
 
 	cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX(cpg_mode)];
 	if (!cpg_pll_config->extal_div) {
Signature · 1 line
1.9.1
#28 lore raw

PATCH v3 14/22 clk: renesas: r8a7795: Obtain mode pin values from R-Car RST driver

Hi Geert,

Thank you for the patch.

Quoted 4 lines · On Wednesday 01 Jun 2016 21:21:12 Geert Uytterhoeven wrote:

Obtain the values of the mode pins from the R-Car RST driver, which relies on the presence in DT of a device node for the RST module.

Quoted 35 lines

---
v3:
- New.

---
 drivers/clk/renesas/r8a7795-cpg-mssr.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/clk/renesas/r8a7795-cpg-mssr.c index
e53aff5b23ad4967..e1f2359a59feee7e 100644

drivers/clk/renesas/r8a7795-cpg-mssr.c +1 -0
@@ -15,6 +15,7 @@
 #include <linux/device.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/soc/renesas/rcar-rst.h>
 
 #include <dt-bindings/clock/r8a7795-cpg-mssr.h>
 
@@ -294,7 +295,12 @@ static const struct rcar_gen3_cpg_pll_config

cpg_pll_configs[16] __initconst = { static int __init r8a7795_cpg_mssr_init(struct device *dev)
{

drivers/clk/renesas/r8a7795-cpg-mssr.c +6 -1
 	const struct rcar_gen3_cpg_pll_config *cpg_pll_config;
-	u32 cpg_mode = rcar_gen3_read_mode_pins();
+	u32 cpg_mode;
+	int error;
+
+	error = rcar_rst_read_mode_pins(&cpg_mode);
+	if (error)
+		return error;
 
 	cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX(cpg_mode)];
 	if (!cpg_pll_config->extal_div) {
Signature · 3 lines
Regards,

Laurent Pinchart
author maintainer
#29 lore raw

PATCH v3 15/22 clk: renesas: r8a7796: Obtain mode pin values from R-Car RST driver

In reply to Geert Uytterhoeven

Obtain the values of the mode pins from the R-Car RST driver, which relies on the presence in DT of a device node for the RST module.

---
v3:
- New.

---
 drivers/clk/renesas/r8a7796-cpg-mssr.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/clk/renesas/r8a7796-cpg-mssr.c +7 -1
index c84b549c14d2e57d..3db2d1cfc8cd788e 100644
@@ -16,6 +16,7 @@
 #include <linux/device.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/soc/renesas/rcar-rst.h>
 
 #include <dt-bindings/clock/r8a7796-cpg-mssr.h>
 
@@ -159,7 +160,12 @@ static const struct rcar_gen3_cpg_pll_config cpg_pll_configs[16] __initconst = {
 static int __init r8a7796_cpg_mssr_init(struct device *dev)
 {
 	const struct rcar_gen3_cpg_pll_config *cpg_pll_config;
-	u32 cpg_mode = rcar_gen3_read_mode_pins();
+	u32 cpg_mode;
+	int error;
+
+	error = rcar_rst_read_mode_pins(&cpg_mode);
+	if (error)
+		return error;
 
 	cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX(cpg_mode)];
 	if (!cpg_pll_config->extal_div) {
Signature · 1 line
1.9.1
#30 lore raw

PATCH v3 15/22 clk: renesas: r8a7796: Obtain mode pin values from R-Car RST driver

Hi Geert,

Thank you for the patch.

Quoted 4 lines · On Wednesday 01 Jun 2016 21:21:13 Geert Uytterhoeven wrote:

Obtain the values of the mode pins from the R-Car RST driver, which relies on the presence in DT of a device node for the RST module.

Quoted 35 lines

---
v3:
- New.

---
 drivers/clk/renesas/r8a7796-cpg-mssr.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/clk/renesas/r8a7796-cpg-mssr.c index
c84b549c14d2e57d..3db2d1cfc8cd788e 100644

drivers/clk/renesas/r8a7796-cpg-mssr.c +1 -0
@@ -16,6 +16,7 @@
 #include <linux/device.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/soc/renesas/rcar-rst.h>
 
 #include <dt-bindings/clock/r8a7796-cpg-mssr.h>
 
@@ -159,7 +160,12 @@ static const struct rcar_gen3_cpg_pll_config

cpg_pll_configs[16] __initconst = { static int __init r8a7796_cpg_mssr_init(struct device *dev)
{

drivers/clk/renesas/r8a7796-cpg-mssr.c +6 -1
 	const struct rcar_gen3_cpg_pll_config *cpg_pll_config;
-	u32 cpg_mode = rcar_gen3_read_mode_pins();
+	u32 cpg_mode;
+	int error;
+
+	error = rcar_rst_read_mode_pins(&cpg_mode);
+	if (error)
+		return error;
 
 	cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX(cpg_mode)];
 	if (!cpg_pll_config->extal_div) {
Signature · 3 lines
Regards,

Laurent Pinchart
author maintainer
#31 lore raw

PATCH v3 17/22 ARM: shmobile: r8a7778: Stop passing mode pins state to clock driver

In reply to Geert Uytterhoeven

Now the R-Car M1A CPG clock driver obtains the state of the mode pins from the R-Car RST driver, there's no longer a need to pass this state explicitly. Hence we can just remove the .init_time() callback, the generic ARM code will take care of calling of_clk_init().

---
v3:
- New.

---
 arch/arm/mach-shmobile/setup-r8a7778.c | 15 ---------------
 1 file changed, 15 deletions(-)
arch/arm/mach-shmobile/setup-r8a7778.c +0 -15
index cf236db686a9dd47..7fa4a0b5f6549287 100644
@@ -15,7 +15,6 @@
  * GNU General Public License for more details.
  */
 
-#include <linux/clk/renesas.h>
 #include <linux/io.h>
 #include <linux/irqchip.h>
 
@@ -23,19 +22,6 @@
 
 #include "common.h"
 
-#define MODEMR 0xffcc0020
-
-static void __init r8a7778_timer_init(void)
-{
-	u32 mode;
-	void __iomem *modemr = ioremap_nocache(MODEMR, 4);
-
-	BUG_ON(!modemr);
-	mode = ioread32(modemr);
-	iounmap(modemr);
-	r8a7778_clocks_init(mode);
-}
-
 #define INT2SMSKCR0	0x82288 /* 0xfe782288 */
 #define INT2SMSKCR1	0x8228c /* 0xfe78228c */
 
@@ -70,6 +56,5 @@ DT_MACHINE_START(R8A7778_DT, "Generic R8A7778 (Flattened Device Tree)")
 	.init_early	= shmobile_init_delay,
 	.init_irq	= r8a7778_init_irq_dt,
 	.init_late	= shmobile_init_late,
-	.init_time	= r8a7778_timer_init,
 	.dt_compat	= r8a7778_compat_dt,
 MACHINE_END
Signature · 1 line
1.9.1
author maintainer
#32 lore raw

PATCH v3 18/22 ARM: shmobile: r8a7779: Stop passing mode pins state to clock driver

In reply to Geert Uytterhoeven

Now the R-Car H1 CPG clock driver obtains the state of the mode pins from the R-Car RST driver, there's no longer a need to pass this state explicitly. Hence we can just remove the .init_time() callback, the generic ARM code will take care of calling of_clk_init() and clocksource_probe().

---
v3:
- New.

---
 arch/arm/mach-shmobile/setup-r8a7779.c | 27 ---------------------------
 1 file changed, 27 deletions(-)
arch/arm/mach-shmobile/setup-r8a7779.c +0 -27
index 0007ff51d180379f..0686112f243525b6 100644
@@ -14,8 +14,6 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  */
-#include <linux/clk/renesas.h>
-#include <linux/clocksource.h>
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <linux/irqchip.h>
@@ -76,30 +74,6 @@ static void __init r8a7779_init_irq_dt(void)
 	__raw_writel(0x003fee3f, INT2SMSKCR4);
 }
 
-#define MODEMR		0xffcc0020
-
-static u32 __init r8a7779_read_mode_pins(void)
-{
-	static u32 mode;
-	static bool mode_valid;
-
-	if (!mode_valid) {
-		void __iomem *modemr = ioremap_nocache(MODEMR, PAGE_SIZE);
-		BUG_ON(!modemr);
-		mode = ioread32(modemr);
-		iounmap(modemr);
-		mode_valid = true;
-	}
-
-	return mode;
-}
-
-static void __init r8a7779_init_time(void)
-{
-	r8a7779_clocks_init(r8a7779_read_mode_pins());
-	clocksource_probe();
-}
-
 static const char *const r8a7779_compat_dt[] __initconst = {
 	"renesas,r8a7779",
 	NULL,
@@ -109,7 +83,6 @@ DT_MACHINE_START(R8A7779_DT, "Generic R8A7779 (Flattened Device Tree)")
 	.smp		= smp_ops(r8a7779_smp_ops),
 	.map_io		= r8a7779_map_io,
 	.init_early	= shmobile_init_delay,
-	.init_time	= r8a7779_init_time,
 	.init_irq	= r8a7779_init_irq_dt,
 	.init_late	= shmobile_init_late,
 	.dt_compat	= r8a7779_compat_dt,
Signature · 1 line
1.9.1
author maintainer
#33 lore raw

PATCH v3 19/22 ARM: shmobile: rcar-gen2: Stop passing mode pins state to clock driver

In reply to Geert Uytterhoeven

Now the R-Car Gen2 CPG clock driver obtains the state of the mode pins from the R-Car RST driver, there's no longer a need to pass this state explicitly. Hence we can just call of_clk_init() instead.

---
v3:
- Drop "select MFD_SYSCON", as the clock driver no longer uses syscon,

v2:
- Kill compiler warning if CONFIG_ARM_ARCH_TIMER is not enabled.

---
 arch/arm/mach-shmobile/setup-rcar-gen2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-shmobile/setup-rcar-gen2.c +3 -3
index 1c6fd11c2f824019..755ce7a940c11848 100644
@@ -15,7 +15,7 @@
  * GNU General Public License for more details.
  */
 
-#include <linux/clk/renesas.h>
+#include <linux/clk-provider.h>
 #include <linux/clocksource.h>
 #include <linux/device.h>
 #include <linux/dma-contiguous.h>
@@ -51,8 +51,8 @@ u32 rcar_gen2_read_mode_pins(void)
 
 void __init rcar_gen2_timer_init(void)
 {
-	u32 mode = rcar_gen2_read_mode_pins();
 #ifdef CONFIG_ARM_ARCH_TIMER
+	u32 mode = rcar_gen2_read_mode_pins();
 	void __iomem *base;
 	int extal_mhz = 0;
 	u32 freq;
@@ -127,7 +127,7 @@ void __init rcar_gen2_timer_init(void)
 	iounmap(base);
 #endif /* CONFIG_ARM_ARCH_TIMER */
 
-	rcar_gen2_clocks_init(mode);
+	of_clk_init(NULL);
 	clocksource_probe();
 }
 
Signature · 1 line
1.9.1
author maintainer
#34 lore raw

PATCH v3 20/22 clk: renesas: r8a7778: Remove obsolete r8a7778_clocks_init()

In reply to Geert Uytterhoeven

The R-Car M1A board code no longer calls r8a7778_clocks_init().

---
v3:
- New.

---
 drivers/clk/renesas/clk-r8a7778.c | 13 -------------
 include/linux/clk/renesas.h       |  1 -
 2 files changed, 14 deletions(-)
drivers/clk/renesas/clk-r8a7778.c +0 -13
index 07ea411098a75ad1..886a8380e91247a1 100644
@@ -143,16 +143,3 @@ static void __init r8a7778_cpg_clocks_init(struct device_node *np)
 
 CLK_OF_DECLARE(r8a7778_cpg_clks, "renesas,r8a7778-cpg-clocks",
 	       r8a7778_cpg_clocks_init);
-
-void __init r8a7778_clocks_init(u32 mode)
-{
-	BUG_ON(!(mode & BIT(19)));
-
-	cpg_mode_rates = (!!(mode & BIT(18)) << 2) |
-			 (!!(mode & BIT(12)) << 1) |
-			 (!!(mode & BIT(11)));
-	cpg_mode_divs = (!!(mode & BIT(2)) << 1) |
-			(!!(mode & BIT(1)));
-
-	of_clk_init(NULL);
-}
include/linux/clk/renesas.h +0 -1
index ba6fa4148515e5c9..2b663bba1adcc7c1 100644
@@ -20,7 +20,6 @@ struct device;
 struct device_node;
 struct generic_pm_domain;
 
-void r8a7778_clocks_init(u32 mode);
 void r8a7779_clocks_init(u32 mode);
 void rcar_gen2_clocks_init(u32 mode);
 
Signature · 1 line
1.9.1
#35 lore raw

PATCH v3 20/22 clk: renesas: r8a7778: Remove obsolete r8a7778_clocks_init()

Quoted 22 lines · Geert Uytterhoeven

The R-Car M1A board code no longer calls r8a7778_clocks_init().

---
v3:
- New.

---
 drivers/clk/renesas/clk-r8a7778.c | 13 -------------
 include/linux/clk/renesas.h       |  1 -
 2 files changed, 14 deletions(-)
drivers/clk/renesas/clk-r8a7778.c +0 -3
index 07ea411098a75ad1..886a8380e91247a1 100644
@@ -143,16 +143,3 @@ static void __init r8a7778_cpg_clocks_init(struct device_node *np)
 
 CLK_OF_DECLARE(r8a7778_cpg_clks, "renesas,r8a7778-cpg-clocks",
 	       r8a7778_cpg_clocks_init);
-
-void __init r8a7778_clocks_init(u32 mode)
-{

drivers/clk/renesas/clk-r8a7778.c static void __init r8a7778_cpg_clocks_init(struct device_node *np) · line 158

Quoted 10 lines
drivers/clk/renesas/clk-r8a7778.c +0 -10
-	BUG_ON(!(mode & BIT(19)));
-
-	cpg_mode_rates = (!!(mode & BIT(18)) << 2) |
-			 (!!(mode & BIT(12)) << 1) |
-			 (!!(mode & BIT(11)));
-	cpg_mode_divs = (!!(mode & BIT(2)) << 1) |
-			(!!(mode & BIT(1)));
-
-	of_clk_init(NULL);
-}

Just a question on how you structured the patches: Is there a special reason why you do the adding of new code and the removal of dead code in two patches?

Having both in one patch normally makes it more obvious which old code is replaced by which new code.

An example: In patch

[PATCH/RFC v3 11/22] clk: renesas: r8a7778: Obtain mode pin values using R-Car RST driver

I wondered where the section

+ BUG_ON(!(mode & BIT(19)));
+
+ cpg_mode_rates = (!!(mode & BIT(18)) << 2) |
+ (!!(mode & BIT(12)) << 1) |
+ (!!(mode & BIT(11)));
+ cpg_mode_divs = (!!(mode & BIT(2)) << 1) |
+ (!!(mode & BIT(1)));

comes from. This becomes obvious with this patch 20/22. But it's 9 patches later ;) So why don't make the whole replacement visible in one patch?

Best regards

Dirk

#36 lore raw

PATCH v3 20/22 clk: renesas: r8a7778: Remove obsolete r8a7778_clocks_init()

Hi Dirk,

Quoted 58 lines · Dirk Behme
Quoted 24 lines · Geert Uytterhoeven

The R-Car M1A board code no longer calls r8a7778_clocks_init().

---
v3:
- New.

---
 drivers/clk/renesas/clk-r8a7778.c | 13 -------------
 include/linux/clk/renesas.h       |  1 -
 2 files changed, 14 deletions(-)
drivers/clk/renesas/clk-r8a7778.c +0 -3
index 07ea411098a75ad1..886a8380e91247a1 100644
@@ -143,16 +143,3 @@ static void __init r8a7778_cpg_clocks_init(struct
 device_node *np)
 
 CLK_OF_DECLARE(r8a7778_cpg_clks, "renesas,r8a7778-cpg-clocks",
               r8a7778_cpg_clocks_init);
-
-void __init r8a7778_clocks_init(u32 mode)
-{

drivers/clk/renesas/clk-r8a7778.c static void __init r8a7778_cpg_clocks_init(struct · line 158

Quoted 10 lines
drivers/clk/renesas/clk-r8a7778.c +0 -10
-       BUG_ON(!(mode & BIT(19)));
-
-       cpg_mode_rates = (!!(mode & BIT(18)) << 2) |
-                        (!!(mode & BIT(12)) << 1) |
-                        (!!(mode & BIT(11)));
-       cpg_mode_divs = (!!(mode & BIT(2)) << 1) |
-                       (!!(mode & BIT(1)));
-
-       of_clk_init(NULL);
-}

Just a question on how you structured the patches: Is there a special reason why you do the adding of new code and the removal of dead code in two patches?

Having both in one patch normally makes it more obvious which old code is replaced by which new code.

An example: In patch

[PATCH/RFC v3 11/22] clk: renesas: r8a7778: Obtain mode pin values using R-Car RST driver

I wondered where the section

(quoted diff) +7 -0
+       BUG_ON(!(mode & BIT(19)));
+
+       cpg_mode_rates = (!!(mode & BIT(18)) << 2) |
+                        (!!(mode & BIT(12)) << 1) |
+                        (!!(mode & BIT(11)));
+       cpg_mode_divs = (!!(mode & BIT(2)) << 1) |
+                       (!!(mode & BIT(1)));
Quoted 2 lines

comes from. This becomes obvious with this patch 20/22. But it's 9 patches later ;) So why don't make the whole replacement visible in one patch?

Because that would break bisection.
Path 20 depends on patch 17, which depends on patch 11.
These three can't be a single patch because they touch multiple subsystems.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer
#37 lore raw

PATCH v3 22/22 clk: renesas: rcar-gen2: Remove obsolete rcar_gen2_clocks_init()

In reply to Geert Uytterhoeven

The R-Car Gen2 board code no longer calls rcar_gen2_clocks_init().

---
v3:
- rebased,

v2:
- No changes.

---
 drivers/clk/renesas/clk-rcar-gen2.c | 7 -------
 include/linux/clk/renesas.h         | 2 --
 2 files changed, 9 deletions(-)
drivers/clk/renesas/clk-rcar-gen2.c +0 -7
index 436fc7a7714e4bd7..4860022627bb455f 100644
@@ -430,10 +430,3 @@ static void __init rcar_gen2_cpg_clocks_init(struct device_node *np)
 }
 CLK_OF_DECLARE(rcar_gen2_cpg_clks, "renesas,rcar-gen2-cpg-clocks",
 	       rcar_gen2_cpg_clocks_init);
-
-void __init rcar_gen2_clocks_init(u32 mode)
-{
-	cpg_mode = mode;
-
-	of_clk_init(NULL);
-}
include/linux/clk/renesas.h +0 -2
index 9e969941f3f62878..9ebf1f8243bb57af 100644
@@ -20,8 +20,6 @@ struct device;
 struct device_node;
 struct generic_pm_domain;
 
-void rcar_gen2_clocks_init(u32 mode);
-
 void cpg_mstp_add_clk_domain(struct device_node *np);
 #ifdef CONFIG_CLK_RENESAS_CPG_MSTP
 int cpg_mstp_attach_dev(struct generic_pm_domain *unused, struct device *dev);
Signature · 1 line
1.9.1
#38 lore raw

v3 cover soc: renesas: Add R-Car RST driver for obtaining mode pin state

In reply to Geert Uytterhoeven
Quoted 114 lines · Geert Uytterhoeven

Hi all,

Currently the R-Car Clock Pulse Generator (CPG) drivers obtains the state of the mode pins either by a call from the board code, or directly by using a hardcoded register access. This is a bit messy, and creates a dependency between driver and platform code.

This RFC patch series converts the various Renesas R-Car clock drivers and support code from reading the mode pin states using a hardcoded register access to using a new R-Car RST driver.

This series consists of 5 parts:
A. Patches 1 and 2 add DT bindings and driver code for the R-Car RST
driver,
B. Patches 3-10 add device nodes for the RST modules to the R-Car DTS
files,
C. Patches 11-16 convert the clock drivers to call into the new R-Car
RST driver,
D. Patches 17-19 remove passing mode pin state to the clock drivers
from the board code,
E. Patches 20-22 remove dead code from the clock drivers.

I've kept all parts together as this is an RFC, and to avoid losing the bigger picture. I will split it in series per maintainer, when we have decided how to handle the dependencies (see below).

After this, there are still a few users of rcar_gen2_read_mode_pins() left in board code, which should be converted in one way or another. However, all R-Car clock drivers will rely on the presence in DT of a device node for the RST module. Backwards compatibility with old DTBs is retained only for R-Car Gen2, which has fallback code calling into rcar_gen2_read_mode_pins().

As is usually the case with moving functionality from board code to DT, there are lots of hard dependencies:
- The DT updates in Part B can be merged as soon as the DT bindings in Part A have been approved,
- The clock driver updates in Part C depend functionally on the driver code in Part A,
- The board code cleanups in Part D depend on the clock driver updates in Part C,
- The block driver cleanups in part E depend on the board code cleanups in part D.

This series has evolved over time, cfr.
- "[PATCH/RFC 00/11] ARM: shmobile: Let CPG use syscon for MD pin

    values" (http://www.spinics.net/lists/linux-clk/msg01478.html),
  - "[PATCH 00/10] arm64: renesas: Obtain MD pin values using
    syscon/regmap".
    (http://www.spinics.net/lists/linux-sh/msg44757.html)

Changes compared to v2:
- Use "renesas,<soctype>-rst" instead of "renesas,rst-<soctype>",
- Drop "syscon" compatible value and "renesas,modemr" property, use a real driver instead,
- Add support for R-Car M1A, H1, and M3-W.

Changes compared to v1:
- Add support for R-Car H3.

An alternative and broader solution was proposed by Simon Horman as "[PATCH/RFC 0/6] boot-mode-reg: Add core"
(http://www.spinics.net/lists/linux-sh/msg45969.html).

This patch series is against renesas-drivers.
It has been tested on r8a7778/bockw, r8a7779/marzen, r8a7791/koelsch, and r8a7795/salvator-x.

Thanks for your comments!

Geert Uytterhoeven (22):
reset: Add renesas,rst DT bindings
soc: renesas: Add R-Car RST driver
ARM: dts: r8a7778: Add device node for RESET/WDT module
ARM: dts: r8a7779: Add device node for RESET/WDT module
ARM: dts: r8a7790: Add device node for RST module
ARM: dts: r8a7791: Add device node for RST module
ARM: dts: r8a7793: Add device node for RST module
ARM: dts: r8a7794: Add device node for RST module
arm64: renesas: r8a7795 dtsi: Add device node for RST module
arm64: renesas: r8a7796 dtsi: Add device node for RST module
clk: renesas: r8a7778: Obtain mode pin values using R-Car RST driver
clk: renesas: r8a7779: Obtain mode pin values from R-Car RST driver
clk: renesas: rcar-gen2: Obtain mode pin values using RST driver
clk: renesas: r8a7795: Obtain mode pin values from R-Car RST driver
clk: renesas: r8a7796: Obtain mode pin values from R-Car RST driver
clk: renesas: rcar-gen3-cpg: Remove obsolete

    rcar_gen3_read_mode_pins()

ARM: shmobile: r8a7778: Stop passing mode pins state to clock driver
ARM: shmobile: r8a7779: Stop passing mode pins state to clock driver
ARM: shmobile: rcar-gen2: Stop passing mode pins state to clock driver
clk: renesas: r8a7778: Remove obsolete r8a7778_clocks_init()
clk: renesas: r8a7779: Remove obsolete r8a7779_clocks_init()
clk: renesas: rcar-gen2: Remove obsolete rcar_gen2_clocks_init()

 .../devicetree/bindings/reset/renesas,rst.txt      | 35 ++++++++
 arch/arm/boot/dts/r8a7778.dtsi                     |  5 ++
 arch/arm/boot/dts/r8a7779.dtsi                     |  5 ++
 arch/arm/boot/dts/r8a7790.dtsi                     |  5 ++
 arch/arm/boot/dts/r8a7791.dtsi                     |  5 ++
 arch/arm/boot/dts/r8a7793.dtsi                     |  5 ++
 arch/arm/boot/dts/r8a7794.dtsi                     |  5 ++
 arch/arm/mach-shmobile/setup-r8a7778.c             | 15 ----
 arch/arm/mach-shmobile/setup-r8a7779.c             | 27 -------
 arch/arm/mach-shmobile/setup-rcar-gen2.c           |  6 +-
 arch/arm64/boot/dts/renesas/r8a7795.dtsi           |  5 ++
 arch/arm64/boot/dts/renesas/r8a7796.dtsi           |  5 ++
 drivers/clk/renesas/clk-r8a7778.c                  | 26 +++---
 drivers/clk/renesas/clk-r8a7779.c                  | 18 ++---
 drivers/clk/renesas/clk-rcar-gen2.c                | 17 ++--
 drivers/clk/renesas/r8a7795-cpg-mssr.c             |  8 +-
 drivers/clk/renesas/r8a7796-cpg-mssr.c             |  8 +-
 drivers/clk/renesas/rcar-gen3-cpg.c                | 17 ----
 drivers/clk/renesas/rcar-gen3-cpg.h                |  1 -
Quoted 8 lines
 drivers/soc/renesas/Makefile                       |  5 ++
 drivers/soc/renesas/rcar-rst.c                     | 94 ++++++++++++++++++++++
 include/linux/clk/renesas.h                        |  4 -
 include/linux/soc/renesas/rcar-rst.h               |  6 ++
 23 files changed, 227 insertions(+), 100 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/reset/renesas,rst.txt
 create mode 100644 drivers/soc/renesas/rcar-rst.c
 create mode 100644 include/linux/soc/renesas/rcar-rst.h

Whole series:

Thanks!

Dirk

#39 lore raw

v3 cover soc: renesas: Add R-Car RST driver for obtaining mode pin state

In reply to Geert Uytterhoeven
Quoted 10 lines · Geert Uytterhoeven

Hi all,

Currently the R-Car Clock Pulse Generator (CPG) drivers obtains the state of the mode pins either by a call from the board code, or directly by using a hardcoded register access. This is a bit messy, and creates a dependency between driver and platform code.

This RFC patch series converts the various Renesas R-Car clock drivers and support code from reading the mode pin states using a hardcoded register access to using a new R-Car RST driver.

Dumb question, can we use the nvmem reading APIs instead of an SoC specific function to read the modes?

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#40 lore raw

v3 cover soc: renesas: Add R-Car RST driver for obtaining mode pin state

Hi Stephen,

Quoted 6 lines · Stephen Boyd
Quoted 5 lines · Geert Uytterhoeven

Currently the R-Car Clock Pulse Generator (CPG) drivers obtains the state of the mode pins either by a call from the board code, or directly by using a hardcoded register access. This is a bit messy, and creates a dependency between driver and platform code.

Quoted 6 lines
Quoted 3 lines

This RFC patch series converts the various Renesas R-Car clock drivers and support code from reading the mode pin states using a hardcoded register access to using a new R-Car RST driver.

Dumb question, can we use the nvmem reading APIs instead of an SoC specific function to read the modes?

Thanks for your suggestion, the nvmem API indeed looks like a suitable API, as it does support read-only nvmems.

Unfortunately I also see a few disadvantages:
1. nvmem_init() is a subsys_initcall(), while most of our users (except for the recent renesas-cpg-mssr driver) are clock drivers using CLK_OF_DECLARE(), and are thus initialized from of_clk_init() at much earlier time_init() time.
Of course the mvmem subsystem and/or the clock drivers can be changed, if deemed useful.
2. Using the nvmem DT bindings means we have to add more DT glue from the nvmem consumer(s) to the nvmem provider. As we need to provide backwards compatibility with old DTSes, this means we need more C code or DT fixup code to handle that.
3. The nvmem subsystem may be overkill to provide access to a simple 32-bit read-only register that never changes value after boot.

Thoughts?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#41 lore raw

v3 cover soc: renesas: Add R-Car RST driver for obtaining mode pin state

Quoted 19 lines · Geert Uytterhoeven

Hi Stephen,

Quoted 6 lines · Stephen Boyd
Quoted 5 lines · Geert Uytterhoeven

Currently the R-Car Clock Pulse Generator (CPG) drivers obtains the state of the mode pins either by a call from the board code, or directly by using a hardcoded register access. This is a bit messy, and creates a dependency between driver and platform code.

Quoted 6 lines
Quoted 3 lines

This RFC patch series converts the various Renesas R-Car clock drivers and support code from reading the mode pin states using a hardcoded register access to using a new R-Car RST driver.

Dumb question, can we use the nvmem reading APIs instead of an SoC specific function to read the modes?

Thanks for your suggestion, the nvmem API indeed looks like a suitable API, as it does support read-only nvmems.

Quoted 7 lines

Unfortunately I also see a few disadvantages:
1. nvmem_init() is a subsys_initcall(), while most of our users (except for the recent renesas-cpg-mssr driver) are clock drivers using CLK_OF_DECLARE(), and are thus initialized from of_clk_init() at much earlier time_init() time.
Of course the mvmem subsystem and/or the clock drivers can be changed, if deemed useful.

Sounds like this is solvable.

Quoted 4 lines

2. Using the nvmem DT bindings means we have to add more DT glue from the nvmem consumer(s) to the nvmem provider. As we need to provide backwards compatibility with old DTSes, this means we need more C code or DT fixup code to handle that.

Ah I wasn't aware we were keeping backwards compatibility around.

Quoted 2 lines

3. The nvmem subsystem may be overkill to provide access to a simple 32-bit read-only register that never changes value after boot.

The nvmem subsystem is designed to read values from things that mostly never change. Overkill may be true, but the nice thing about using nvmem APIs is that the driver doesn't have to use some platform specific function that duplicates similar functionality. It's unfortunate that backwards incompatibility limits our ability to move to common linux frameworks when they are created after the binding is used.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#42 lore raw

v3 cover soc: renesas: Add R-Car RST driver for obtaining mode pin state

Hi Stephen,

Quoted 26 lines · Stephen Boyd
Quoted 17 lines · Geert Uytterhoeven
Quoted 6 lines · Stephen Boyd
Quoted 5 lines · Geert Uytterhoeven

Currently the R-Car Clock Pulse Generator (CPG) drivers obtains the state of the mode pins either by a call from the board code, or directly by using a hardcoded register access. This is a bit messy, and creates a dependency between driver and platform code.

Quoted 6 lines
Quoted 3 lines

This RFC patch series converts the various Renesas R-Car clock drivers and support code from reading the mode pin states using a hardcoded register access to using a new R-Car RST driver.

Dumb question, can we use the nvmem reading APIs instead of an SoC specific function to read the modes?

Thanks for your suggestion, the nvmem API indeed looks like a suitable API, as it does support read-only nvmems.

Quoted 7 lines

Unfortunately I also see a few disadvantages:
1. nvmem_init() is a subsys_initcall(), while most of our users (except for the recent renesas-cpg-mssr driver) are clock drivers using CLK_OF_DECLARE(), and are thus initialized from of_clk_init() at much earlier time_init() time.
Of course the mvmem subsystem and/or the clock drivers can be changed, if deemed useful.

Quoted 1 line

Sounds like this is solvable.

Sure.

Quoted 10 lines
Quoted 4 lines

2. Using the nvmem DT bindings means we have to add more DT glue from the nvmem consumer(s) to the nvmem provider. As we need to provide backwards compatibility with old DTSes, this means we need more C code or DT fixup code to handle that.

Ah I wasn't aware we were keeping backwards compatibility around.

Quoted 2 lines

3. The nvmem subsystem may be overkill to provide access to a simple 32-bit read-only register that never changes value after boot.

Quoted 7 lines

The nvmem subsystem is designed to read values from things that mostly never change. Overkill may be true, but the nice thing about using nvmem APIs is that the driver doesn't have to use some platform specific function that duplicates similar functionality. It's unfortunate that backwards incompatibility limits our ability to move to common linux frameworks when they are created after the binding is used.

This is continuing work to support old, current, and new SoCs properly. When the first support for R-Car Gen2 SoCs was added, many frameworks didn't have DT support, or didn't even exist.

Unlike in the mobile market, development and life span is much larger than 6 months here...

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds