arm64: renesas: Obtain MD pin values using syscon/regmap
Subsystems (6)
cover arm64: renesas: Obtain MD pin values using syscon/regmap
This is a resend of
http://www.spinics.net/lists/linux-sh/msg44757.html
It's rebased against
https://git.kernel.org/cgit/linux/kernel/git/geert/renesas-drivers.git/log/?h=topic/gen3-latest0ea1cc9f0c9537d3fb42722c188
[WIP] arm64: r8a7796: Integration
and adds support for r8a7796, too.
It's boot tested on r8a7795 Salvator-X and checked that the same mode value is read without and with this patch series.
Dirk
PATCH 1/6 reset: Add renesas,rst DT bindings.
From: Geert Uytterhoeven <[email protected]>
Add DT bindings for the Renesas R-Car Reset Controller
--- .../devicetree/bindings/reset/renesas,rst.txt | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/reset/renesas,rst.txt
Documentation/devicetree/bindings/reset/renesas,rst.txt new file +29 -0
@@ -0,0 +1,29 @@ +DT bindings for the Renesas R-Car Reset Controller + +The R-Car Reset Controller provides reset control, and implements the following +functions: + - Register-based reset control for the various CPU cores, + - Latching of the levels on mode pins when PRESET# is negated, + - Mode monitoring register, + - Boot address registers for the various CPU cores. + + +Required properties: + - compatible: Should be "renesas,rst-<soctype>", and "syscon". + Examples with soctypes are: + - "renesas,rst-r8a7790" (R-Car H2) + - "renesas,rst-r8a7791" (R-Car M2-W) + - "renesas,rst-r8a7792" (R-Car V2H + - "renesas,rst-r8a7793" (R-Car M2-N) + - "renesas,rst-r8a7794" (R-Car E2) + - "renesas,rst-r8a7795" (R-Car H3) + - "renesas,rst-r8a7796" (R-Car M3) + - reg: Address start and address range for the device. + + +Example: + + rst: reset-controller@e6160000 { + compatible = "renesas,rst-r8a7795", "syscon"; + reg = <0 0xe6160000 0 0x0200>; + };
Signature · 1 line
2.8.0
Re: [PATCH 1/6] reset: Add renesas,rst DT bindings.
Quoted 18 lines · Dirk Behme
From: Geert Uytterhoeven <[email protected]>
Add DT bindings for the Renesas R-Car Reset Controller
Signed-off-by Geert Uytterhoeven <[email protected]>--- .../devicetree/bindings/reset/renesas,rst.txt | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/reset/renesas,rst.txtDocumentation/devicetree/bindings/reset/renesas,rst.txt new file +2
-0@@ -0,0 +1,29 @@ +DT bindings for the Renesas R-Car Reset Controller +
Documentation/devicetree/bindings/reset/renesas,rst.txt line 12
Quoted 10 lines
Documentation/devicetree/bindings/reset/renesas,rst.txt new file +10
-0+The R-Car Reset Controller provides reset control, and implements the following +functions: + - Register-based reset control for the various CPU cores, + - Latching of the levels on mode pins when PRESET# is negated, + - Mode monitoring register, + - Boot address registers for the various CPU cores. + + +Required properties: + - compatible: Should be "renesas,rst-<soctype>", and "syscon".
Should become "renesas,<soctype>-rst" to match current best practices.
Documentation/devicetree/bindings/reset/renesas,rst.txt line 20
Quoted 8 lines
Documentation/devicetree/bindings/reset/renesas,rst.txt new file +8
-0+ Examples with soctypes are: + - "renesas,rst-r8a7790" (R-Car H2) + - "renesas,rst-r8a7791" (R-Car M2-W) + - "renesas,rst-r8a7792" (R-Car V2H + - "renesas,rst-r8a7793" (R-Car M2-N) + - "renesas,rst-r8a7794" (R-Car E2) + - "renesas,rst-r8a7795" (R-Car H3) + - "renesas,rst-r8a7796" (R-Car M3)
"renesas,r8a7790-rst" etc.
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
PATCH 2/6 clk: renesas: rcar-gen3: Document renesas,modemr
In reply to Dirk BehmeFrom: Geert Uytterhoeven <[email protected]>
Document the "renesas,modemr" property, which allows the Clock Pulse Generator driver to obtain the values of the mode pin using syscon and regmap.
--- Documentation/devicetree/bindings/clock/renesas,cpg-mssr.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/clock/renesas,cpg-mssr.txt +3 -0
@@ -39,6 +39,8 @@ Required Properties: Domain bindings in Documentation/devicetree/bindings/power/power_domain.txt. + - renesas,modemr: Reference to the RST module node, and register offset of + the Mode Monitor Register (MODEMR) inside the RST module Examples --------
@@ -52,6 +54,7 @@ Examples clock-names = "extal", "extalr"; #clock-cells = <2>; #power-domain-cells = <0>; + renesas,modemr = <&rst 0x60>; };
Signature · 1 line
2.8.0
PATCH 3/6 clk: renesas: rcar-gen3: Obtain MD pin values using syscon/regmap
In reply to Dirk BehmeFrom: Geert Uytterhoeven <[email protected]>
Obtain the values of the mode pins by reading the Mode Monitoring Register (MODEMR) using syscon and regmap. The syscon device and register offset to use are obtained from the "renesas,modemr" property in DT.
--- drivers/clk/renesas/r8a7795-cpg-mssr.c | 15 ++++++++++++++- drivers/clk/renesas/r8a7796-cpg-mssr.c | 15 ++++++++++++++- drivers/clk/renesas/rcar-gen3-cpg.c | 17 ----------------- drivers/clk/renesas/rcar-gen3-cpg.h | 1 - 4 files changed, 28 insertions(+), 20 deletions(-)
drivers/clk/renesas/r8a7795-cpg-mssr.c +14 -1
@@ -15,6 +15,9 @@#include <linux/device.h> #include <linux/init.h> #include <linux/kernel.h> +#include <linux/mfd/syscon.h> +#include <linux/of.h> +#include <linux/regmap.h> #include <dt-bindings/clock/r8a7795-cpg-mssr.h>
@@ -294,7 +297,17 @@ 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 (); +struct device_node *np = dev->of_node; +struct regmap *regmap; +u32 cpg_mode, reg; + + regmap =syscon_regmap_lookup_by_phandle (np,"renesas,modemr" ); +if (IS_ERR (regmap) || +of_property_read_u32_index (np,"renesas,modemr" ,1 , ®) || +regmap_read (regmap, reg, &cpg_mode)) { +dev_err (dev,"Failed to parse renesas,modemr\n" ); +return -EINVAL ; + } cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX (cpg_mode)];if (!cpg_pll_config->extal_div) {
drivers/clk/renesas/r8a7796-cpg-mssr.c +14 -1
@@ -16,6 +16,9 @@#include <linux/device.h> #include <linux/init.h> #include <linux/kernel.h> +#include <linux/mfd/syscon.h> +#include <linux/of.h> +#include <linux/regmap.h> #include <dt-bindings/clock/r8a7796-cpg-mssr.h>
@@ -159,7 +162,17 @@ 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 (); +struct device_node *np = dev->of_node; +struct regmap *regmap; +u32 cpg_mode, reg; + + regmap =syscon_regmap_lookup_by_phandle (np,"renesas,modemr" ); +if (IS_ERR (regmap) || +of_property_read_u32_index (np,"renesas,modemr" ,1 , ®) || +regmap_read (regmap, reg, &cpg_mode)) { +dev_err (dev,"Failed to parse renesas,modemr\n" ); +return -EINVAL ; + } cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX (cpg_mode)];if (!cpg_pll_config->extal_div) {
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) {
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 · 1 line
2.8.0
Re: [PATCH 3/6] clk: renesas: rcar-gen3: Obtain MD pin values using syscon/regmap
Quoted 18 lines · Dirk Behme
drivers/clk/renesas/r8a7795-cpg-mssr.c +4
-1@@ -15,6 +15,9 @@#include <linux/device.h> #include <linux/init.h> #include <linux/kernel.h> +#include <linux/mfd/syscon.h> +#include <linux/of.h> +#include <linux/regmap.h> #include <dt-bindings/clock/r8a7795-cpg-mssr.h> @@ -294,7 +297,17 @@ 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 (); +struct device_node *np = dev->of_node;
drivers/clk/renesas/r8a7795-cpg-mssr.c static const struct rcar_gen3_cpg_pll_config cpg_pll_configs[16] __initconst = { · line 310
Quoted 10 lines
drivers/clk/renesas/r8a7795-cpg-mssr.c +10
-0+struct regmap *regmap; +u32 cpg_mode, reg; + + regmap =syscon_regmap_lookup_by_phandle (np,"renesas,modemr" ); +if (IS_ERR (regmap) || +of_property_read_u32_index (np,"renesas,modemr" ,1 , ®) || +regmap_read (regmap, reg, &cpg_mode)) { +dev_err (dev,"Failed to parse renesas,modemr\n" ); +return -EINVAL ; + }
I would not add this to each and ...
Quoted 18 lines
drivers/clk/renesas/r8a7796-cpg-mssr.c +4
-1@@ -16,6 +16,9 @@#include <linux/device.h> #include <linux/init.h> #include <linux/kernel.h> +#include <linux/mfd/syscon.h> +#include <linux/of.h> +#include <linux/regmap.h> #include <dt-bindings/clock/r8a7796-cpg-mssr.h> @@ -159,7 +162,17 @@ 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 (); +struct device_node *np = dev->of_node;
drivers/clk/renesas/r8a7796-cpg-mssr.c static const struct rcar_gen3_cpg_pll_config cpg_pll_configs[16] __initconst = { · line 175
Quoted 10 lines
drivers/clk/renesas/r8a7796-cpg-mssr.c +10
-0+struct regmap *regmap; +u32 cpg_mode, reg; + + regmap =syscon_regmap_lookup_by_phandle (np,"renesas,modemr" ); +if (IS_ERR (regmap) || +of_property_read_u32_index (np,"renesas,modemr" ,1 , ®) || +regmap_read (regmap, reg, &cpg_mode)) { +dev_err (dev,"Failed to parse renesas,modemr\n" ); +return -EINVAL ; + }
... every subdriver for all SoCs that need it...
Quoted 14 lines
drivers/clk/renesas/rcar-gen3-cpg.c +0
-6@@ -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 )
drivers/clk/renesas/rcar-gen3-cpg.c struct clk * __init rcar_gen3_cpg_clk_register(struct device *dev, · line 351
Quoted 10 lines
drivers/clk/renesas/rcar-gen3-cpg.c +0
-10-{ -void __iomem *modemr =ioremap_nocache (MODEMR ,4 ); -u32 mode; - -BUG_ON (!modemr); - mode =ioread32 (modemr); -iounmap (modemr); - -return mode; -}
... but add it here.
Or perhaps just in renesas-cpg-mssr.c, as we're gonna need it for R-Car Gen2 too, if/when that is converted to cpg-mssr.c.
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
PATCH 4/6 arm64: dts: renesas: Add device node for RST module
In reply to Dirk BehmeFrom: Geert Uytterhoeven <[email protected]>
Add a device node for the RST module, which provides reset control. Declare it to be a system controller (syscon), so other device nodes can refer to its registers.
--- arch/arm64/boot/dts/renesas/r8a7795.dtsi | 5 +++++ arch/arm64/boot/dts/renesas/r8a7796.dtsi | 5 +++++ 2 files changed, 10 insertions(+)
arch/arm64/boot/dts/renesas/r8a7795.dtsi +5 -0
@@ -526,6 +526,11 @@ #iommu-cells = <1>; }; + rst: reset-controller@e6160000 { + compatible = "renesas,rst-r8a7795", "syscon"; + reg = <0 0xe6160000 0 0x0200>; + }; + dmac0: dma-controller@e6700000 { compatible = "renesas,dmac-r8a7795", "renesas,rcar-dmac";
arch/arm64/boot/dts/renesas/r8a7796.dtsi +5 -0
@@ -115,6 +115,11 @@ #power-domain-cells = <1>; }; + rst: reset-controller@e6160000 { + compatible = "renesas,rst-r8a7795", "syscon"; + reg = <0 0xe6160000 0 0x0200>; + }; + dmac0: dma-controller@e6700000 { /* Empty node for now */ };
Signature · 1 line
2.8.0
Re: [PATCH 4/6] arm64: dts: renesas: Add device node for RST module
arch/arm64/boot/dts/renesas/r8a7795.dtsi line 530
Quoted 8 lines · Dirk Behme
arch/arm64/boot/dts/renesas/r8a7795.dtsi +2
-0@@ -526,6 +526,11 @@ #iommu-cells = <1>; }; + rst: reset-controller@e6160000 { + compatible = "renesas,rst-r8a7795", "syscon";
"renesas,r8a7795-rst", to match current practices.
arch/arm64/boot/dts/renesas/r8a7796.dtsi line 119
Quoted 10 lines
arch/arm64/boot/dts/renesas/r8a7796.dtsi +2
-0@@ -115,6 +115,11 @@ #power-domain-cells = <1>; }; + rst: reset-controller@e6160000 { + compatible = "renesas,rst-r8a7795", "syscon";
"renesas,r8a7796-rst" (not '95 ;-).
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
PATCH 5/6 arm64: dts: renesas: Link CPG to RST using "renesas,modemr"
In reply to Dirk BehmeFrom: Geert Uytterhoeven <[email protected]>
Add a link from the Clock Pulse Generator node to the Reset Controller node, so the CPG can read the Mode Monitoring Register (MODEMR) to obtain the mode pin values.
--- arch/arm64/boot/dts/renesas/r8a7795.dtsi | 1 + arch/arm64/boot/dts/renesas/r8a7796.dtsi | 1 + 2 files changed, 2 insertions(+)
arch/arm64/boot/dts/renesas/r8a7795.dtsi +1 -0
@@ -307,6 +307,7 @@ clock-names = "extal", "extalr"; #clock-cells = <2>; #power-domain-cells = <0>; + renesas,modemr = <&rst 0x60>; }; sysc: system-controller@e6180000 {
arch/arm64/boot/dts/renesas/r8a7796.dtsi +1 -0
@@ -107,6 +107,7 @@ clock-names = "extal", "extalr"; #clock-cells = <2>; #power-domain-cells = <0>; + renesas,modemr = <&rst 0x60>; }; sysc: system-controller@e6180000 {
Signature · 1 line
2.8.0
PATCH 6/6 arm64: renesas: select MFD_SYSCON
In reply to Dirk BehmeFrom: Geert Uytterhoeven <[email protected]>
The Clock Pulse Generator (CPG) relies on syscon to obtain the values of the mode pins.
--- arch/arm64/Kconfig.platforms | 1 + 1 file changed, 1 insertion(+)
arch/arm64/Kconfig.platforms +1 -0
@@ -106,6 +106,7 @@ config ARCH_SHMOBILE config ARCH_RENESAS bool "Renesas SoC Platforms" select ARCH_SHMOBILE + select MFD_SYSCON select PINCTRL select PM select PM_GENERIC_DOMAINS
Signature · 1 line
2.8.0
Hi Dirk,
Quoted 6 lines · Dirk Behme
This is a resend of
http://www.spinics.net/lists/linux-sh/msg44757.html
It's rebased against
Quoted 8 lines
https://git.kernel.org/cgit/linux/kernel/git/geert/renesas-drivers.git/log/?h=topic/gen3-latest
0ea1cc9f0c9537d3fb42722c188
[WIP] arm64: r8a7796: Integrationand adds support for r8a7796, too.
It's boot tested on r8a7795 Salvator-X and checked that the same mode value is read without and with this patch series.
Thanks a lot for updating my old series!
Now we have both variants (drivers/misc vs. syscon) public, perhaps we can make an educated decision about which route to take?
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
Quoted 15 lines · Geert Uytterhoeven
Hi Dirk,
Quoted 12 lines · Dirk Behme
This is a resend of
http://www.spinics.net/lists/linux-sh/msg44757.html
It's rebased against
https://git.kernel.org/cgit/linux/kernel/git/geert/renesas-drivers.git/log/?h=topic/gen3-latest
0ea1cc9f0c9537d3fb42722c188
[WIP] arm64: r8a7796: Integrationand adds support for r8a7796, too.
Quoted 7 lines
Quoted 2 lines
It's boot tested on r8a7795 Salvator-X and checked that the same mode value is read without and with this patch series.
Thanks a lot for updating my old series!
Now we have both variants (
drivers/miscvs. syscon) public, perhaps we can make an educated decision about which route to take?
I definitely vote for syscon as it's cleaner and more "mainline compatible".
Best regards
Dirk