Skip to contentSkip to conversation

Introduce keystone reset driver

PATCH Superseded Ivan Khoronzhuk 3 participants 13 messages May 21, 2014

Subsystems (6)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v4 cover Introduce keystone reset driver

These patches introduce keystone reset driver.

The keystone SoC can be rebooted in several ways. By external reset pin, by soft and by watchdogs. This driver allows software reset and reset by one of the watchdogs. Also added opportunity to set soft/hard reset type.

Based on linux-next/master

v4..v3
Power: reset: keystone-reset: introduce keystone reset driver
- change to use syscon framework
- change to use regmap to access registers
Power: reset: add bindings for keystone reset driver
- deleted properties "reg", "reg-names"
- added properties "ti,syscon-pll", "ti,syscon-dev"
ARM: dts: keystone: update reset node to work with reset driver
- deleted properties "reg", "reg-names"
- added properties "ti,syscon-pll", "ti,syscon-dev"

v2..v3
Power: reset: keystone-reset: introduce keystone reset driver
- no functional changes, only sanity
Power: reset: add bindings for keystone reset driver
- corrected WDT numeration in examples
- extended description of wdt_list property

v1..v2
- re basedon on v3.15-rc1 without changes

Ivan Khoronzhuk (5):
Power: reset: keystone-reset: introduce keystone reset driver
Power: reset: add bindings for keystone reset driver
ARM: keystone: remove redundant reset stuff
ARM: dts: keystone: update reset node to work with reset driver
ARM: keystone: enable reset driver support

 .../bindings/power/reset/keystone-reset.txt        |  66 +++++++++
 arch/arm/boot/dts/keystone.dtsi                    |   4 +-
 arch/arm/configs/keystone_defconfig                |   3 +
 arch/arm/mach-keystone/keystone.c                  |  34 -----
 drivers/power/reset/Kconfig                        |   8 ++
 drivers/power/reset/Makefile                       |   1 +
 drivers/power/reset/keystone-reset.c               | 153 +++++++++++++++++++++
 7 files changed, 234 insertions(+), 35 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/power/reset/keystone-reset.txt
 create mode 100644 drivers/power/reset/keystone-reset.c
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH v4 1/5 Power: reset: keystone-reset: introduce keystone reset driver

The keystone SoC can be rebooted in several ways. By external reset pin, by soft and by watchdogs. To allow keystone SoC reset if watchdog is triggered we have to enable it in reset mux configuration register regarding of watchdog configuration. Also we need to set soft/hard reset we are going to use.

So add keystone reset driver to handle all this stuff.

---
 drivers/power/reset/Kconfig          |   8 ++
 drivers/power/reset/Makefile         |   1 +
 drivers/power/reset/keystone-reset.c | 153 +++++++++++++++++++++++++++++++++++
 3 files changed, 162 insertions(+)
 create mode 100644 drivers/power/reset/keystone-reset.c
drivers/power/reset/Kconfig +8 -0
index fa0e4e0..d095e5b 100644
@@ -57,3 +57,11 @@ config POWER_RESET_XGENE
 	depends on POWER_RESET
 	help
 	  Reboot support for the APM SoC X-Gene Eval boards.
+
+config POWER_RESET_KEYSTONE
+	bool "Keystone reset driver"
+	depends on ARCH_KEYSTONE
+	select MFD_SYSCON
+	help
+	  Reboot support for the KEYSTONE SoCs.
+
drivers/power/reset/Makefile +1 -0
index a5b4a77..802a420 100644
@@ -5,3 +5,4 @@ obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
 obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
 obj-$(CONFIG_POWER_RESET_VEXPRESS) += vexpress-poweroff.o
 obj-$(CONFIG_POWER_RESET_XGENE) += xgene-reboot.o
+obj-$(CONFIG_POWER_RESET_KEYSTONE) += keystone-reset.o
drivers/power/reset/keystone-reset.c new file +153 -0

153 lines not on this page · raw message

Signature · 1 line
1.8.3.2
#2 lore raw

PATCH v4 2/5 Power: reset: add bindings for keystone reset driver

In reply to Ivan Khoronzhuk

This node is intended to allow SoC reset in case of software reset or appropriate watchdogs.

The Keystone SoCs can contain up to 4 watchdog timers to reset SoC. Each watchdog timer event input is connected to the Reset Mux block. The Reset Mux block can be configured to cause reset or not.

Additionally soft or hard reset can be configured.

---
 .../bindings/power/reset/keystone-reset.txt        | 66 ++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/reset/keystone-reset.txt
Documentation/devicetree/bindings/power/reset/keystone-reset.txt new file +66 -0
new file mode 100644
index 0000000..64cb7b4
@@ -0,0 +1,66 @@
+* Device tree bindings for Texas Instruments keystone reset
+
+This node is intended to allow SoC reset in case of software reset
+of selected watchdogs.
+
+The Keystone SoCs can contain up to 4 watchdog timers to reset
+SoC. Each watchdog timer event input is connected to the Reset Mux
+block. The Reset Mux block can be configured to cause reset or not.
+
+Additionally soft or hard reset can be configured.
+
+Required properties:
+
+- compatible:		ti,keystone-reset
+
+- ti,syscon-pll:	syscon register range used to access pll controller
+			registers in order to use reset control registers.
+
+- ti,syscon-dev:	syscon register range used to access device state
+			control registers in order to use mux block registers
+			for all watchdogs.
+
+Optional properties:
+
+- ti,soft-reset:	Boolean option indicating soft reset.
+			By default hard reset is used.
+
+- ti,wdt_list:		WDT list that can cause SoC reset. It's not related
+			to WDT driver, it's just needed to enable a SoC related
+			reset that's triggered by one of WDTs. The list is
+			in format: <0>, <2>; It can be in random order and
+			begins from 0 to 3, as keystone can contain up to 4 SoC
+			reset watchdogs and can be in random order.
+
+Example 1:
+Setup keystone reset so that in case software reset or
+WDT0 is triggered it issues hard reset for SoC.
+
+pllctrl: pll_controller {
+	compatible = "syscon";
+	reg = <0x2310000 0x200>;
+};
+
+devctrl: device_state_control {
+	compatible = "syscon";
+	reg = <0x2620000 0x1000>;
+};
+
+rstctrl: reset-controller {
+	compatible = "ti,keystone-reset";
+	ti,syscon-pll = <&pllctrl>;
+	ti,syscon-dev = <&devctrl>;
+	ti,wdt_list = <0>;
+};
+
+Example 2:
+Setup keystone reset so that in case of software reset or
+WDT0 or WDT2 is triggered it issues soft reset for SoC.
+
+rstctrl: reset-controller {
+	compatible = "ti,keystone-reset";
+	ti,syscon-pll = <&pllctrl>;
+	ti,syscon-dev = <&devctrl>;
+	ti,wdt_list = <0>, <2>;
+	ti,soft-reset;
+};
Signature · 1 line
1.8.3.2
#3 lore raw

Re: [Patch v4 2/5] Power: reset: add bindings for keystone reset driver

Quoted 32 lines · On Wednesday 21 May 2014 17:27:31 Ivan Khoronzhuk wrote:

This node is intended to allow SoC reset in case of software reset or appropriate watchdogs.

The Keystone SoCs can contain up to 4 watchdog timers to reset SoC. Each watchdog timer event input is connected to the Reset Mux block. The Reset Mux block can be configured to cause reset or not.

Additionally soft or hard reset can be configured.

---
 .../bindings/power/reset/keystone-reset.txt        | 66 ++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/reset/keystone-reset.txt
Documentation/devicetree/bindings/power/reset/keystone-reset.txt new file +11 -0
new file mode 100644
index 0000000..64cb7b4
@@ -0,0 +1,66 @@
+* Device tree bindings for Texas Instruments keystone reset
+
+This node is intended to allow SoC reset in case of software reset
+of selected watchdogs.
+
+The Keystone SoCs can contain up to 4 watchdog timers to reset
+SoC. Each watchdog timer event input is connected to the Reset Mux
+block. The Reset Mux block can be configured to cause reset or not.
+
+Additionally soft or hard reset can be configured.
+

Documentation/devicetree/bindings/power/reset/keystone-reset.txt line 21

Quoted 10 lines
Documentation/devicetree/bindings/power/reset/keystone-reset.txt new file +10 -0
+Required properties:
+
+- compatible:		ti,keystone-reset
+
+- ti,syscon-pll:	syscon register range used to access pll controller
+			registers in order to use reset control registers.
+
+- ti,syscon-dev:	syscon register range used to access device state
+			control registers in order to use mux block registers
+			for all watchdogs.

This should be updated to call these phandles rather than register ranges.

Quoted 15 lines
Documentation/devicetree/bindings/power/reset/keystone-reset.txt new file +15 -0
+Optional properties:
+
+- ti,soft-reset:	Boolean option indicating soft reset.
+			By default hard reset is used.
+
+- ti,wdt_list:		WDT list that can cause SoC reset. It's not related
+			to WDT driver, it's just needed to enable a SoC related
+			reset that's triggered by one of WDTs. The list is
+			in format: <0>, <2>; It can be in random order and
+			begins from 0 to 3, as keystone can contain up to 4 SoC
+			reset watchdogs and can be in random order.
+
+Example 1:
+Setup keystone reset so that in case software reset or
+WDT0 is triggered it issues hard reset for SoC.

Documentation/devicetree/bindings/power/reset/keystone-reset.txt line 47

Quoted 10 lines
Documentation/devicetree/bindings/power/reset/keystone-reset.txt new file +10 -0
+
+pllctrl: pll_controller {
+	compatible = "syscon";
+	reg = <0x2310000 0x200>;
+};
+
+devctrl: device_state_control {
+	compatible = "syscon";
+	reg = <0x2620000 0x1000>;
+};

It's ok to have these in the example, but please also add a binding file for each one describing what they are, and add a proper "compatible" string so they can be matched by a high-level device driver if needed.

This could for instance be

	compatible = "ti,keystone-1.0-pll-controller", "syscon";


	Arnd
#4 lore raw

Re: [Patch v4 2/5] Power: reset: add bindings for keystone reset driver

Quoted 74 lines · Arnd Bergmann
Quoted 32 lines · On Wednesday 21 May 2014 17:27:31 Ivan Khoronzhuk wrote:

This node is intended to allow SoC reset in case of software reset or appropriate watchdogs.

The Keystone SoCs can contain up to 4 watchdog timers to reset SoC. Each watchdog timer event input is connected to the Reset Mux block. The Reset Mux block can be configured to cause reset or not.

Additionally soft or hard reset can be configured.

---
  .../bindings/power/reset/keystone-reset.txt        | 66 ++++++++++++++++++++++
  1 file changed, 66 insertions(+)

create mode 100644 Documentation/devicetree/bindings/power/reset/keystone-reset.txt

Documentation/devicetree/bindings/power/reset/keystone-reset.txt new file +11 -0
new file mode 100644
index 0000000..64cb7b4
@@ -0,0 +1,66 @@
+* Device tree bindings for Texas Instruments keystone reset
+
+This node is intended to allow SoC reset in case of software reset
+of selected watchdogs.
+
+The Keystone SoCs can contain up to 4 watchdog timers to reset
+SoC. Each watchdog timer event input is connected to the Reset Mux
+block. The Reset Mux block can be configured to cause reset or not.
+
+Additionally soft or hard reset can be configured.
+

Documentation/devicetree/bindings/power/reset/keystone-reset.txt line 21

Quoted 10 lines
Documentation/devicetree/bindings/power/reset/keystone-reset.txt new file +10 -0
+Required properties:
+
+- compatible:		ti,keystone-reset
+
+- ti,syscon-pll:	syscon register range used to access pll controller
+			registers in order to use reset control registers.
+
+- ti,syscon-dev:	syscon register range used to access device state
+			control registers in order to use mux block registers
+			for all watchdogs.

This should be updated to call these phandles rather than register ranges.

Quoted 15 lines
Documentation/devicetree/bindings/power/reset/keystone-reset.txt new file +15 -0
+Optional properties:
+
+- ti,soft-reset:	Boolean option indicating soft reset.
+			By default hard reset is used.
+
+- ti,wdt_list:		WDT list that can cause SoC reset. It's not related
+			to WDT driver, it's just needed to enable a SoC related
+			reset that's triggered by one of WDTs. The list is
+			in format: <0>, <2>; It can be in random order and
+			begins from 0 to 3, as keystone can contain up to 4 SoC
+			reset watchdogs and can be in random order.
+
+Example 1:
+Setup keystone reset so that in case software reset or
+WDT0 is triggered it issues hard reset for SoC.

Documentation/devicetree/bindings/power/reset/keystone-reset.txt line 47

Quoted 10 lines
Documentation/devicetree/bindings/power/reset/keystone-reset.txt new file +10 -0
+
+pllctrl: pll_controller {
+	compatible = "syscon";
+	reg = <0x2310000 0x200>;
+};
+
+devctrl: device_state_control {
+	compatible = "syscon";
+	reg = <0x2620000 0x1000>;
+};

It's ok to have these in the example, but please also add a binding file for each one describing what they are, and add a proper "compatible" string so they can be matched by a high-level device driver if needed.

Quoted 3 lines

This could for instance be

	compatible = "ti,keystone-1.0-pll-controller", "syscon";

Arnd,

I've slightly confused where should I add these bindings. The main pll controller mostly used by clk driver....
As its register set is used also by reset driver it's logically to put it to bindings/mfd,
but pll controller in mfd it's strange....

Could you please help to decide where should it be?.

Signature · 2 lines
Regards,
Ivan Khoronzhuk
#5 lore raw

Re: [Patch v4 2/5] Power: reset: add bindings for keystone reset driver

Quoted 8 lines · On Wednesday 21 May 2014 19:03:38 Ivan Khoronzhuk wrote:

I've slightly confused where should I add these bindings. The main pll controller mostly used by clk driver....
As its register set is used also by reset driver it's logically to put it to bindings/mfd,
but pll controller in mfd it's strange....

Could you please help to decide where should it be?.

Put it into Documentation/devicetree/bindings/clock/keystone-pll.txt

Arnd

#6 lore raw

Re: [Patch v4 2/5] Power: reset: add bindings for keystone reset driver

Quoted 8 lines · Arnd Bergmann
Quoted 7 lines · On Wednesday 21 May 2014 19:03:38 Ivan Khoronzhuk wrote:

I've slightly confused where should I add these bindings. The main pll controller mostly used by clk driver....
As its register set is used also by reset driver it's logically to put it to bindings/mfd,
but pll controller in mfd it's strange....

Quoted 4 lines
Quoted 1 line

Could you please help to decide where should it be?.

Put it into Documentation/devicetree/bindings/clock/keystone-pll.txt

I was just about post the same suggestion. Lets do that.

regards,
Santosh

#7 lore raw

PATCH v4 3/5 ARM: keystone: remove redundant reset stuff

In reply to Ivan Khoronzhuk

Remove reset stuff in flavour of using keystone reset driver:
driver/power/reset/keystone-reset.c

---
 arch/arm/mach-keystone/keystone.c | 34 ----------------------------------
 1 file changed, 34 deletions(-)
arch/arm/mach-keystone/keystone.c +0 -34
index 59b8383..1f9ae89 100644
@@ -26,11 +26,6 @@
 
 #include "keystone.h"
 
-#define PLL_RESET_WRITE_KEY_MASK		0xffff0000
-#define PLL_RESET_WRITE_KEY			0x5a69
-#define PLL_RESET				BIT(16)
-
-static void __iomem *keystone_rstctrl;
 static struct notifier_block platform_nb;
 static unsigned long keystone_dma_pfn_offset __read_mostly;
 
@@ -55,16 +50,6 @@ static int keystone_platform_notifier(struct notifier_block *nb,
 
 static void __init keystone_init(void)
 {
-	struct device_node *node;
-
-	node = of_find_compatible_node(NULL, NULL, "ti,keystone-reset");
-	if (WARN_ON(!node))
-		pr_warn("ti,keystone-reset node undefined\n");
-
-	keystone_rstctrl = of_iomap(node, 0);
-	if (WARN_ON(!keystone_rstctrl))
-		pr_warn("ti,keystone-reset iomap error\n");
-
 	keystone_pm_runtime_init();
 	if (platform_nb.notifier_call)
 		bus_register_notifier(&platform_bus_type, &platform_nb);
@@ -123,24 +108,6 @@ static const char *keystone_match[] __initconst = {
 	NULL,
 };
 
-void keystone_restart(enum reboot_mode mode, const char *cmd)
-{
-	u32 val;
-
-	BUG_ON(!keystone_rstctrl);
-
-	/* Enable write access to RSTCTRL */
-	val = readl(keystone_rstctrl);
-	val &= PLL_RESET_WRITE_KEY_MASK;
-	val |= PLL_RESET_WRITE_KEY;
-	writel(val, keystone_rstctrl);
-
-	/* Reset the SOC */
-	val = readl(keystone_rstctrl);
-	val &= ~PLL_RESET;
-	writel(val, keystone_rstctrl);
-}
-
 DT_MACHINE_START(KEYSTONE, "Keystone")
 #if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE)
 	.dma_zone_size	= SZ_2G,
@@ -148,6 +115,5 @@ DT_MACHINE_START(KEYSTONE, "Keystone")
 	.smp		= smp_ops(keystone_smp_ops),
 	.init_machine	= keystone_init,
 	.dt_compat	= keystone_match,
-	.restart	= keystone_restart,
 	.init_meminfo   = keystone_init_meminfo,
 MACHINE_END
Signature · 1 line
1.8.3.2
#8 lore raw

PATCH v4 4/5 ARM: dts: keystone: update reset node to work with reset driver

In reply to Ivan Khoronzhuk

The keystone driver requires the next additional properties:

"ti,syscon-pll" - syscon register range used to access pll controller
registers in order to use reset control registers.
"ti,syscon-dev" - syscon register range used to access device state
control registers in order to use mux block registers for all watchdogs.

"ti,wdt_list" - option to declare what watchdog are used to reboot
the SoC, so set "0" WDT as default.

---
 arch/arm/boot/dts/keystone.dtsi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/boot/dts/keystone.dtsi +3 -1
index 8b899ba..783da60 100644
@@ -78,7 +78,9 @@
 
 		rstctrl: reset-controller {
 			compatible = "ti,keystone-reset";
-			reg = <0x023100e8 4>;	/* pll reset control reg */
+			ti,syscon-pll = <&pllctrl>;
+			ti,syscon-dev = <&devctrl>;
+			ti,wdt_list = <0>;
 		};
 
 		/include/ "keystone-clocks.dtsi"
Signature · 1 line
1.8.3.2
#9 lore raw

Re: [Patch v4 4/5] ARM: dts: keystone: update reset node to work with reset driver

Quoted 8 lines · On Wednesday 21 May 2014 17:27:33 Ivan Khoronzhuk wrote:

The keystone driver requires the next additional properties:

"ti,syscon-pll" - syscon register range used to access pll controller
registers in order to use reset control registers.
"ti,syscon-dev" - syscon register range used to access device state
control registers in order to use mux block registers for all watchdogs.

Quoted 4 lines

"ti,wdt_list" - option to declare what watchdog are used to reboot
the SoC, so set "0" WDT as default.

Same comment as what I had for the binding: it's not a register range any more, but a phandle for a device.

Quoted 9 lines
---
 arch/arm/boot/dts/keystone.dtsi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/boot/dts/keystone.dtsi +0 -0
index 8b899ba..783da60 100644

arch/arm/boot/dts/keystone.dtsi line 85

Quoted 9 lines
arch/arm/boot/dts/keystone.dtsi +3 -1
@@ -78,7 +78,9 @@
 
                rstctrl: reset-controller {
                        compatible = "ti,keystone-reset";
-                       reg = <0x023100e8 4>;   /* pll reset control reg */
+                       ti,syscon-pll = <&pllctrl>;
+                       ti,syscon-dev = <&devctrl>;
+                       ti,wdt_list = <0>;
                };
 

I don't see a definition for the two labels, so this will cause a build error. It makes sense to add them in the same patch.

Arnd

#10 lore raw

Re: [Patch v4 4/5] ARM: dts: keystone: update reset node to work with reset driver

Quoted 37 lines · Arnd Bergmann
Quoted 8 lines · On Wednesday 21 May 2014 17:27:33 Ivan Khoronzhuk wrote:

The keystone driver requires the next additional properties:

"ti,syscon-pll" - syscon register range used to access pll controller
registers in order to use reset control registers.
"ti,syscon-dev" - syscon register range used to access device state
control registers in order to use mux block registers for all watchdogs.

Quoted 4 lines

"ti,wdt_list" - option to declare what watchdog are used to reboot
the SoC, so set "0" WDT as default.

Same comment as what I had for the binding: it's not a register range any more, but a phandle for a device.

Quoted 9 lines
---
  arch/arm/boot/dts/keystone.dtsi | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/boot/dts/keystone.dtsi +0 -0
index 8b899ba..783da60 100644

arch/arm/boot/dts/keystone.dtsi line 85

Quoted 9 lines
arch/arm/boot/dts/keystone.dtsi +3 -1
@@ -78,7 +78,9 @@
 
                 rstctrl: reset-controller {
                         compatible = "ti,keystone-reset";
-                       reg = <0x023100e8 4>;   /* pll reset control reg */
+                       ti,syscon-pll = <&pllctrl>;
+                       ti,syscon-dev = <&devctrl>;
+                       ti,wdt_list = <0>;
                 };
 

I don't see a definition for the two labels, so this will cause a build error. It makes sense to add them in the same patch.

Quoted 1 line

Arnd

Thanks,

I'll correct

Signature · 2 lines
Regards,
Ivan Khoronzhuk
#11 lore raw

PATCH v4 5/5 ARM: keystone: enable reset driver support

In reply to Ivan Khoronzhuk

Enable reset driver support in order to have opportunity to reboot SoC by watchdog and by software.

---
 arch/arm/configs/keystone_defconfig | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/configs/keystone_defconfig +3 -0
index 07b4327..dc0da3f 100644
@@ -132,6 +132,9 @@ CONFIG_SPI=y
 CONFIG_SPI_DAVINCI=y
 CONFIG_SPI_SPIDEV=y
 # CONFIG_HWMON is not set
+CONFIG_POWER_SUPPLY=y
+CONFIG_POWER_RESET=y
+CONFIG_POWER_RESET_KEYSTONE=y
 CONFIG_WATCHDOG=y
 CONFIG_WATCHDOG_CORE=y
 CONFIG_DAVINCI_WATCHDOG=y
Signature · 1 line
1.8.3.2
Reviewed-by on the v4 series
#12 lore raw
In reply to Ivan Khoronzhuk
Quoted 7 lines · On Wednesday 21 May 2014 17:27:29 Ivan Khoronzhuk wrote:

These patches introduce keystone reset driver.

The keystone SoC can be rebooted in several ways. By external reset pin, by soft and by watchdogs. This driver allows software reset and reset by one of the watchdogs. Also added opportunity to set soft/hard reset type.

Based on linux-next/master

Hi Ivan,

The code looks good to me now, but I have some comments about the binding. Patches 1, 3 and 5

Thanks for the quick update.