Skip to contentSkip to conversation

ARM: prima2: move to generic reset controller driver framework

PATCH Superseded Barry Song 2 participants 7 messages Jan 6, 2014 – Jan 9, 2014

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Barry Song

author
#0 lore raw

PATCH v4 1/1 ARM: prima2: move to generic reset controller driver framework

this moves to generic IP module reset framework, and make other drivers use common device_reset() API.

---
-v4: fix checkpatch issues pointed out by Philipp;

 .../devicetree/bindings/reset/sirf,rstc.txt        |   42 ++++++++++
 arch/arm/boot/dts/atlas6.dtsi                      |    3 +-
 arch/arm/boot/dts/marco.dtsi                       |    3 +-
 arch/arm/boot/dts/prima2.dtsi                      |    3 +-
 arch/arm/mach-prima2/Kconfig                       |    1 +
 arch/arm/mach-prima2/common.c                      |   12 +++-
 arch/arm/mach-prima2/common.h                      |    1 +
 arch/arm/mach-prima2/rstc.c                        |   80 +++++++++++--------
 8 files changed, 107 insertions(+), 38 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/reset/sirf,rstc.txt
Documentation/devicetree/bindings/reset/sirf,rstc.txt new file +42 -0
new file mode 100644
index 0000000..0505de7
@@ -0,0 +1,42 @@
+CSR SiRFSoC Reset Controller
+======================================
+
+Please also refer to reset.txt in this directory for common reset
+controller binding usage.
+
+Required properties:
+- compatible: Should be "sirf,prima2-rstc" or "sirf,marco-rstc"
+- reg: should be register base and length as documented in the
+  datasheet
+- #reset-cells: 1, see below
+
+example:
+
+rstc: reset-controller at 88010000 {
+	compatible = "sirf,prima2-rstc";
+	reg = <0x88010000 0x1000>;
+	#reset-cells = <1>;
+};
+
+Specifying reset lines connected to IP modules
+==============================================
+
+The reset controller(rstc) manages various reset sources. This module provides
+reset signals for most blocks in system. Those device nodes should specify the
+reset line on the rstc in their resets property, containing a phandle to the
+rstc device node and a RESET_INDEX specifying which module to reset, as described
+in reset.txt.
+
+For SiRFSoC, RESET_INDEX is just reset_bit defined in SW_RST0 and SW_RST1 registers.
+For modules whose rest_bit is in SW_RST0, its RESET_INDEX is 0~31. For modules whose
+rest_bit is in SW_RST1, its RESET_INDEX is 32~63.
+
+example:
+
+vpp at 90020000 {
+	compatible = "sirf,prima2-vpp";
+	reg = <0x90020000 0x10000>;
+	interrupts = <31>;
+	clocks = <&clks 35>;
+	resets = <&rstc 6>;
+};
arch/arm/boot/dts/atlas6.dtsi +2 -1
index 978bab4..b63cfef 100644
@@ -56,9 +56,10 @@
 				#clock-cells = <1>;
 			};
 
-			reset-controller at 88010000 {
+			rstc: reset-controller at 88010000 {
 				compatible = "sirf,prima2-rstc";
 				reg = <0x88010000 0x1000>;
+				#reset-cells = <1>;
 			};
 
 			rsc-controller at 88020000 {
arch/arm/boot/dts/marco.dtsi +2 -1
index 1579c34..0c9647d 100644
@@ -58,9 +58,10 @@
 			#size-cells = <1>;
 			ranges = <0xc2000000 0xc2000000 0x1000000>;
 
-			reset-controller at c2000000 {
+			rstc: reset-controller at c2000000 {
 				compatible = "sirf,marco-rstc";
 				reg = <0xc2000000 0x10000>;
+				#reset-cells = <1>;
 			};
 		};
 
arch/arm/boot/dts/prima2.dtsi +2 -1
index daee5894..b292a5c 100644
@@ -67,9 +67,10 @@
 				#clock-cells = <1>;
 			};
 
-			reset-controller at 88010000 {
+			rstc: reset-controller at 88010000 {
 				compatible = "sirf,prima2-rstc";
 				reg = <0x88010000 0x1000>;
+				#reset-cells = <1>;
 			};
 
 			rsc-controller at 88020000 {
arch/arm/mach-prima2/Kconfig +1 -0
index 6988b11..f37a1de 100644
@@ -1,5 +1,6 @@
 config ARCH_SIRF
 	bool "CSR SiRF" if ARCH_MULTI_V7
+	select ARCH_HAS_RESET_CONTROLLER
 	select ARCH_REQUIRE_GPIOLIB
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_IRQ_CHIP
arch/arm/mach-prima2/common.c +11 -1
index d49aff7..4a14ae7 100644
@@ -15,7 +15,14 @@
 #include <linux/of_platform.h>
 #include "common.h"
 
-void __init sirfsoc_init_late(void)
+static void __init sirfsoc_init_mach(void)
+{
+	sirfsoc_of_rstc_init();
+	of_platform_populate(NULL, of_default_bus_match_table,
+		NULL, NULL);
+}
+
+static void __init sirfsoc_init_late(void)
 {
 	sirfsoc_pm_init();
 }
@@ -35,6 +42,7 @@ static const char *atlas6_dt_match[] __initdata = {
 DT_MACHINE_START(ATLAS6_DT, "Generic ATLAS6 (Flattened Device Tree)")
 	/* Maintainer: Barry Song <[email protected]> */
 	.map_io         = sirfsoc_map_io,
+	.init_machine   = sirfsoc_init_mach,
 	.init_late	= sirfsoc_init_late,
 	.dt_compat      = atlas6_dt_match,
 	.restart	= sirfsoc_restart,
@@ -51,6 +59,7 @@ DT_MACHINE_START(PRIMA2_DT, "Generic PRIMA2 (Flattened Device Tree)")
 	/* Maintainer: Barry Song <[email protected]> */
 	.map_io         = sirfsoc_map_io,
 	.dma_zone_size	= SZ_256M,
+	.init_machine   = sirfsoc_init_mach,
 	.init_late	= sirfsoc_init_late,
 	.dt_compat      = prima2_dt_match,
 	.restart	= sirfsoc_restart,
@@ -67,6 +76,7 @@ DT_MACHINE_START(MARCO_DT, "Generic MARCO (Flattened Device Tree)")
 	/* Maintainer: Barry Song <[email protected]> */
 	.smp            = smp_ops(sirfsoc_smp_ops),
 	.map_io         = sirfsoc_map_io,
+	.init_machine   = sirfsoc_init_mach,
 	.init_late	= sirfsoc_init_late,
 	.dt_compat      = marco_dt_match,
 	.restart	= sirfsoc_restart,
arch/arm/mach-prima2/common.h +1 -0
index 4b76806..0896efd 100644
@@ -22,6 +22,7 @@ extern struct smp_operations   sirfsoc_smp_ops;
 extern void sirfsoc_secondary_startup(void);
 extern void sirfsoc_cpu_die(unsigned int cpu);
 
+extern void __init sirfsoc_of_rstc_init(void);
 extern void __init sirfsoc_of_irq_init(void);
 extern void sirfsoc_restart(enum reboot_mode, const char *);
 extern asmlinkage void __exception_irq_entry sirfsoc_handle_irq(struct pt_regs *regs);
arch/arm/mach-prima2/rstc.c +46 -34

117 lines not on this page · raw message

Signature · 1 line
1.7.5.4
#1 lore raw

PATCH v4 1/1 ARM: prima2: move to generic reset controller driver framework

Quoted 18 lines · Barry Song

this moves to generic IP module reset framework, and make other drivers use common device_reset() API.

Documentation/devicetree/bindings/reset/sirf,rstc.txt new file +9 -0
new file mode 100644
index 0000000..0505de7
@@ -0,0 +1,42 @@
+CSR SiRFSoC Reset Controller
+======================================
+
+Please also refer to reset.txt in this directory for common reset
+controller binding usage.
+
+Required properties:
+- compatible: Should be "sirf,prima2-rstc" or "sirf,marco-rstc"
+- reg: should be register base and length as documented in the

Documentation/devicetree/bindings/reset/sirf,rstc.txt line 19

Quoted 10 lines
Documentation/devicetree/bindings/reset/sirf,rstc.txt new file +10 -0
+  datasheet
+- #reset-cells: 1, see below
+
+example:
+
+rstc: reset-controller at 88010000 {
+	compatible = "sirf,prima2-rstc";
+	reg = <0x88010000 0x1000>;
+	#reset-cells = <1>;
+};

Binding looks good to me.

Quoted 9 lines
Documentation/devicetree/bindings/reset/sirf,rstc.txt new file +9 -0
+void __init sirfsoc_of_rstc_init(void)
+{
+	struct device_node *np = of_find_matching_node(NULL, rstc_ids);
+	if (!np) {
+		pr_err("unable to find compatible sirf rstc node in dtb\n");
+		return;
+	}
+
+	sirfsoc_rstc_base = of_iomap(np, 0);

Documentation/devicetree/bindings/reset/sirf,rstc.txt line 38

Quoted 10 lines
Documentation/devicetree/bindings/reset/sirf,rstc.txt new file +10 -0
+	if (!sirfsoc_rstc_base) {
+		pr_err("unable to map rstc cpu registers\n");
+		return;
+	}
+
+	sirfsoc_reset_controller.of_node = np;
+
+	reset_controller_register(&sirfsoc_reset_controller);
+}
+

Can't this be a regular platform device? Drivers that get the reference to the reset controller should respect a -EPROBE_DEFER error message if they get initialized in the wrong order.

Arnd

author
#2 lore raw

PATCH v4 1/1 ARM: prima2: move to generic reset controller driver framework

2014/1/6 Arnd Bergmann <[email protected]>:

Quoted 47 lines · Barry Song
Quoted 18 lines

this moves to generic IP module reset framework, and make other drivers use common device_reset() API.

Documentation/devicetree/bindings/reset/sirf,rstc.txt new file +9 -0
new file mode 100644
index 0000000..0505de7
@@ -0,0 +1,42 @@
+CSR SiRFSoC Reset Controller
+======================================
+
+Please also refer to reset.txt in this directory for common reset
+controller binding usage.
+
+Required properties:
+- compatible: Should be "sirf,prima2-rstc" or "sirf,marco-rstc"
+- reg: should be register base and length as documented in the

Documentation/devicetree/bindings/reset/sirf,rstc.txt line 19

Quoted 10 lines
Documentation/devicetree/bindings/reset/sirf,rstc.txt new file +10 -0
+  datasheet
+- #reset-cells: 1, see below
+
+example:
+
+rstc: reset-controller at 88010000 {
+     compatible = "sirf,prima2-rstc";
+     reg = <0x88010000 0x1000>;
+     #reset-cells = <1>;
+};

Binding looks good to me.

Quoted 15 lines
Documentation/devicetree/bindings/reset/sirf,rstc.txt new file +15 -0
+void __init sirfsoc_of_rstc_init(void)
+{
+     struct device_node *np = of_find_matching_node(NULL, rstc_ids);
+     if (!np) {
+             pr_err("unable to find compatible sirf rstc node in dtb\n");
+             return;
+     }
+
+     sirfsoc_rstc_base = of_iomap(np, 0);
+     if (!sirfsoc_rstc_base) {
+             pr_err("unable to map rstc cpu registers\n");
+             return;
+     }
+
+     sirfsoc_reset_controller.of_node = np;
Quoted 8 lines

Documentation/devicetree/bindings/reset/sirf,rstc.txt line 38

Quoted 4 lines
Documentation/devicetree/bindings/reset/sirf,rstc.txt new file +4 -0
+
+     reset_controller_register(&sirfsoc_reset_controller);
+}
+

Can't this be a regular platform device? Drivers that get the reference to the reset controller should respect a -EPROBE_DEFER error message if they get initialized in the wrong order.

Arnd, it is ok if prima2 is not a platform for automotive. here prima2 actually wants a "right" order for products.
for example, there are some local hacking to move camera for rearview started earlier than other devices as this feature needs to be ready as early as possible.
some earlier boot devices depend on reset module to be ready. so if we move to regular platform driver for upstream, it still requires some local hacking to move it earlier.

Quoted 2 lines

Arnd

-barry

#3 lore raw

PATCH v4 1/1 ARM: prima2: move to generic reset controller driver framework

Quoted 27 lines · Barry Song

2014/1/6 Arnd Bergmann <[email protected]>:

Quoted 17 lines · Barry Song
Quoted 16 lines
arch/arm/mach-prima2/rstc.c +15 -0
+void __init sirfsoc_of_rstc_init(void)
+{
+     struct device_node *np = of_find_matching_node(NULL, rstc_ids);
+     if (!np) {
+             pr_err("unable to find compatible sirf rstc node in dtb\n");
+             return;
+     }
+
+     sirfsoc_rstc_base = of_iomap(np, 0);
+     if (!sirfsoc_rstc_base) {
+             pr_err("unable to map rstc cpu registers\n");
+             return;
+     }
+
+     sirfsoc_reset_controller.of_node = np;
Quoted 8 lines

arch/arm/mach-prima2/rstc.c int sirfsoc_reset_device(struct device *dev) · line 97

Quoted 4 lines
arch/arm/mach-prima2/rstc.c +4 -0
+
+     reset_controller_register(&sirfsoc_reset_controller);
+}
+

Can't this be a regular platform device? Drivers that get the reference to the reset controller should respect a -EPROBE_DEFER error message if they get initialized in the wrong order.

Quoted 8 lines

Arnd, it is ok if prima2 is not a platform for automotive. here prima2 actually wants a "right" order for products.
for example, there are some local hacking to move camera for rearview started earlier than other devices as this feature needs to be ready as early as possible.
some earlier boot devices depend on reset module to be ready. so if we move to regular platform driver for upstream, it still requires some local hacking to move it earlier.

I don't understand what you mean. It should be a matter of a few miliseconds at most to retry initialization, more likely in the microseconds. How big are the delays you are worried about?

Arnd

author
#4 lore raw

PATCH v4 1/1 ARM: prima2: move to generic reset controller driver framework

2014/1/7 Arnd Bergmann <[email protected]>:

Quoted 37 lines · Barry Song
Quoted 27 lines

2014/1/6 Arnd Bergmann <[email protected]>:

Quoted 17 lines · Barry Song
Quoted 16 lines
arch/arm/mach-prima2/rstc.c +15 -0
+void __init sirfsoc_of_rstc_init(void)
+{
+     struct device_node *np = of_find_matching_node(NULL, rstc_ids);
+     if (!np) {
+             pr_err("unable to find compatible sirf rstc node in dtb\n");
+             return;
+     }
+
+     sirfsoc_rstc_base = of_iomap(np, 0);
+     if (!sirfsoc_rstc_base) {
+             pr_err("unable to map rstc cpu registers\n");
+             return;
+     }
+
+     sirfsoc_reset_controller.of_node = np;
Quoted 8 lines

arch/arm/mach-prima2/rstc.c int sirfsoc_reset_device(struct device *dev) · line 97

Quoted 4 lines
arch/arm/mach-prima2/rstc.c +4 -0
+
+     reset_controller_register(&sirfsoc_reset_controller);
+}
+

Can't this be a regular platform device? Drivers that get the reference to the reset controller should respect a -EPROBE_DEFER error message if they get initialized in the wrong order.

Quoted 8 lines

Arnd, it is ok if prima2 is not a platform for automotive. here prima2 actually wants a "right" order for products.
for example, there are some local hacking to move camera for rearview started earlier than other devices as this feature needs to be ready as early as possible.
some earlier boot devices depend on reset module to be ready. so if we move to regular platform driver for upstream, it still requires some local hacking to move it earlier.

Quoted 3 lines

I don't understand what you mean. It should be a matter of a few miliseconds at most to retry initialization, more likely in the microseconds. How big are the delays you are worried about?

what i am worrried about is 100ms or more. device drivers need time to initialize and that will take time, if some devices initialization happen before the deferred probing, the deferred probing might be delayed 100ms.
for example, we want camera begin to show rear-view in several hundreds of ms, there are some local hacking to move i2c and camera probe earlier than other devices.
that means actually there is requirement for right order of probing but not defer probing sometimes.

Quoted 2 lines

Arnd

-barry

#5 lore raw

PATCH v4 1/1 ARM: prima2: move to generic reset controller driver framework

Quoted 19 lines · Barry Song

2014/1/7 Arnd Bergmann <[email protected]>:

Quoted 14 lines · Barry Song
Quoted 4 lines
Quoted 3 lines

Can't this be a regular platform device? Drivers that get the reference to the reset controller should respect a -EPROBE_DEFER error message if they get initialized in the wrong order.

Quoted 8 lines

Arnd, it is ok if prima2 is not a platform for automotive. here prima2 actually wants a "right" order for products.
for example, there are some local hacking to move camera for rearview started earlier than other devices as this feature needs to be ready as early as possible.
some earlier boot devices depend on reset module to be ready. so if we move to regular platform driver for upstream, it still requires some local hacking to move it earlier.

Quoted 3 lines

I don't understand what you mean. It should be a matter of a few miliseconds at most to retry initialization, more likely in the microseconds. How big are the delays you are worried about?

Quoted 9 lines

what i am worrried about is 100ms or more. device drivers need time to initialize and that will take time, if some devices initialization happen before the deferred probing, the deferred probing might be delayed 100ms.
for example, we want camera begin to show rear-view in several hundreds of ms, there are some local hacking to move i2c and camera probe earlier than other devices.
that means actually there is requirement for right order of probing but not defer probing sometimes.

I see, this seems like a valid concern. I had not considered that other drivers might need more time for initialization. In general of course they should not, but I understand that hardware is not perfect and some drivers you don't own may have bugs that cause unnecessary delays.

We have discussed probe ordering a lot of times on the mailing lists and also during the last kernel summit, but those discussions are usually focused on trying to correctly boot up a system, which is hard enough even without additional requirements like yours.

Generally the hack that people use when things fail to work correctly is to hijack an earlier initcall level, e.g. subsys_initcall rather than using module_init. Please first see if that can solve your problem. If it doesn't help, please resubmit your current patch with a detailed description in the code on why you have to do it like this.

Arnd

author
#6 lore raw

PATCH v4 1/1 ARM: prima2: move to generic reset controller driver framework

2014/1/9 Arnd Bergmann <[email protected]>:

Quoted 30 lines · Barry Song
Quoted 19 lines

2014/1/7 Arnd Bergmann <[email protected]>:

Quoted 14 lines · Barry Song
Quoted 4 lines
Quoted 3 lines

Can't this be a regular platform device? Drivers that get the reference to the reset controller should respect a -EPROBE_DEFER error message if they get initialized in the wrong order.

Quoted 8 lines

Arnd, it is ok if prima2 is not a platform for automotive. here prima2 actually wants a "right" order for products.
for example, there are some local hacking to move camera for rearview started earlier than other devices as this feature needs to be ready as early as possible.
some earlier boot devices depend on reset module to be ready. so if we move to regular platform driver for upstream, it still requires some local hacking to move it earlier.

Quoted 3 lines

I don't understand what you mean. It should be a matter of a few miliseconds at most to retry initialization, more likely in the microseconds. How big are the delays you are worried about?

Quoted 9 lines

what i am worrried about is 100ms or more. device drivers need time to initialize and that will take time, if some devices initialization happen before the deferred probing, the deferred probing might be delayed 100ms.
for example, we want camera begin to show rear-view in several hundreds of ms, there are some local hacking to move i2c and camera probe earlier than other devices.
that means actually there is requirement for right order of probing but not defer probing sometimes.

Quoted 4 lines

I see, this seems like a valid concern. I had not considered that other drivers might need more time for initialization. In general of course they should not, but I understand that hardware is not perfect and some drivers you don't own may have bugs that cause unnecessary delays.

the functionality of defer probing is really working. but embedded systems with all kinds of hardware and various strange requirement will want the "right" order.

Quoted 11 lines

We have discussed probe ordering a lot of times on the mailing lists and also during the last kernel summit, but those discussions are usually focused on trying to correctly boot up a system, which is hard enough even without additional requirements like yours.

Generally the hack that people use when things fail to work correctly is to hijack an earlier initcall level, e.g. subsys_initcall rather than using module_init. Please first see if that can solve your problem. If it doesn't help, please resubmit your current patch with a detailed description in the code on why you have to do it like this.

that is ok if it moves to subsys_initcall. some people might think using subsys_initcall imports redundant function call for non-sirf platform in multi-platform and machine-specific hook will not import that :-)

Quoted 2 lines

Arnd

-barry