Reset controller API to reset IP modules on i.MX5 and i.MX6
Subsystems (6)
Philipp Zabel
maintainerv2 cover Reset controller API to reset IP modules on i.MX5 and i.MX6
The system reset controller (SRC) on i.MX51, i.MX53, and i.MX6q controls reset lines to the GPU, VPU, IPU, and OpenVG IP modules.
The following patches add a simple API for devices to request being reset by separate reset controller hardware and implements the reset signal device tree binding proposed by Stephen Warren. Contrary to Tegra hardware, the i.MX SRC contains self-deasserting reset registers, so I've included both ops to manually assert/deassert a reset line, as well as a "reset" operation that is supposed to assert the reset line and wait for it to deassert.
The i.MX SRC is enhanced to provide a reset controller and the IPU driver is made to request being reset by calling the device_reset(&pdev->dev) convenience wrapper during probing.
Changes since v1:
- Fixed issues from comments
- Added reset controller driver for GPIO controlled resets
regards
Philipp
--- .../devicetree/bindings/reset/fsl,imx-src.txt | 49 ++++ Documentation/devicetree/bindings/reset/reset.txt | 75 ++++++ .../bindings/staging/imx-drm/fsl-imx-drm.txt | 3 + arch/arm/boot/dts/imx51.dtsi | 7 + arch/arm/boot/dts/imx53.dtsi | 7 + arch/arm/boot/dts/imx6q.dtsi | 5 +- arch/arm/mach-imx/Kconfig | 2 + arch/arm/mach-imx/mm-imx5.c | 2 + arch/arm/mach-imx/src.c | 58 ++++- drivers/Kconfig | 2 + drivers/Makefile | 3 + drivers/reset/Kconfig | 22 ++ drivers/reset/Makefile | 2 + drivers/reset/core.c | 238 ++++++++++++++++++++ drivers/reset/gpio-reset.c | 188 ++++++++++++++++ drivers/staging/imx-drm/ipu-v3/ipu-common.c | 12 +- include/linux/reset-controller.h | 39 ++++ include/linux/reset.h | 17 ++ 18 files changed, 726 insertions(+), 5 deletions(-)
Philipp Zabel
maintainerPATCH v2 1/8 dt: describe base reset signal binding
From: Stephen Warren <[email protected]>
This binding is intended to represent the hardware reset signals present internally in most IC (SoC, FPGA, ...) designs.
It consists of a binding for a reset controller device (provider), and a pair of properties, "resets" and "reset-names", to link a device node (consumer) to its reset controller via phandle, similarly to the clock and interrupt bindings.
The reset controller has all information necessary to reset the consumer device. That could be provided via device tree, or it could be implemented in hardware.
The aim is to enable device drivers to request a framework API to issue a reset simply by providing their struct device pointer as the most common case.
--- Documentation/devicetree/bindings/reset/reset.txt | 75 +++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 Documentation/devicetree/bindings/reset/reset.txt
Documentation/devicetree/bindings/reset/reset.txt new file +75 -0
@@ -0,0 +1,75 @@ += Reset Signal Device Tree Bindings = + +This binding is intended to represent the hardware reset signals present +internally in most IC (SoC, FPGA, ...) designs. Reset signals for whole +standalone chips are most likely better represented as GPIOs, although there +are likely to be exceptions to this rule. + +Hardware blocks typically receive a reset signal. This signal is generated by +a reset provider (e.g. power management or clock module) and received by a +reset consumer (the module being reset, or a module managing when a sub- +ordinate module is reset). This binding exists to represent the provider and +consumer, and provide a way to couple the two together. + +A reset signal is represented by the phandle of the provider, plus a reset +specifier - a list of DT cells that represents the reset signal within the +provider. The length (number of cells) and semantics of the reset specifier +are dictated by the binding of the reset provider, although common schemes +are described below. + +A word on where to place reset signal consumers in device tree: It is possible +in hardware for a reset signal to affect multiple logically separate HW blocks +at once. In this case, it would be unwise to represent this reset signal in +the DT node of each affected HW block, since if activated, an unrelated block +may be reset. Instead, reset signals should be represented in the DT node +where it makes most sense to control it; this may be a bus node if all +children of the bus are affected by the reset signal, or an individual HW +block node for dedicated reset signals. The intent of this binding is to give +appropriate software access to the reset signals in order to manage the HW, +rather than to slavishly enumerate the reset signal that affects each HW +block. + += Reset providers = + +Required properties: +#reset-cells: Number of cells in a reset specifier; Typically 0 for nodes + with a single reset output and 1 for nodes with multiple + reset outputs. + +For example: + + rst: reset-controller { + #reset-cells = <1>; + }; + += Reset consumers = + +Required properties: +resets: List of phandle and reset specifier pairs, one pair + for each reset signal that affects the device, or that the + device manages. Note: if the reset provider specifies '0' for + #reset-cells, then only the phandle portion of the pair will + appear. + +Optional properties: +reset-names: List of reset signal name strings sorted in the same order as + the resets property. Consumers drivers will use reset-names to + match reset signal names with reset specifiers. + +For example: + + device { + resets = <&rst 20>; + reset-names = "reset"; + }; + +This represents a device with a single reset signal named "reset". + + bus { + resets = <&rst 10> <&rst 11> <&rst 12> <&rst 11>; + reset-names = "i2s1", "i2s2", "dma", "mixer"; + }; + +This represents a bus that controls the reset signal of each of four sub- +ordinate devices. Consider for example a bus that fails to operate unless no +child device has reset asserted.
Signature · 1 line
1.7.10.4
PATCH v2 1/8 dt: describe base reset signal binding
Quoted 16 lines · Philipp Zabel
From: Stephen Warren <[email protected]>
This binding is intended to represent the hardware reset signals present internally in most IC (SoC, FPGA, ...) designs.
It consists of a binding for a reset controller device (provider), and a pair of properties, "resets" and "reset-names", to link a device node (consumer) to its reset controller via phandle, similarly to the clock and interrupt bindings.The reset controller has all information necessary to reset the consumer device. That could be provided via device tree, or it could be implemented in hardware.
The aim is to enable device drivers to request a framework API to issue a reset simply by providing their struct device pointer as the most common case.
Quoted 2 lines
Signed-off-by Stephen Warren <[email protected]>Signed-off-by Philipp Zabel <[email protected]>
Philipp Zabel
maintainerPATCH v2 1/8 dt: describe base reset signal binding
Hi Shawn,
Am Sonntag, den 17.02.2013, 21:05 +0800 schrieb Shawn Guo:
Quoted 17 lines · Philipp Zabel
Quoted 16 lines
From: Stephen Warren <[email protected]>
This binding is intended to represent the hardware reset signals present internally in most IC (SoC, FPGA, ...) designs.
It consists of a binding for a reset controller device (provider), and a pair of properties, "resets" and "reset-names", to link a device node (consumer) to its reset controller via phandle, similarly to the clock and interrupt bindings.The reset controller has all information necessary to reset the consumer device. That could be provided via device tree, or it could be implemented in hardware.
The aim is to enable device drivers to request a framework API to issue a reset simply by providing their struct device pointer as the most common case.
Quoted 4 lines
Quoted 2 lines
Signed-off-by Stephen Warren <[email protected]>Signed-off-by Philipp Zabel <[email protected]>Reviewed-by Shawn Guo <[email protected]>
thank you for the review. I have made the changes you suggested and will resend, rebased onto next-20130219.
regards
Philipp
Philipp Zabel
maintainerPATCH v2 2/8 reset: Add reset controller API
In reply to Philipp ZabelThis adds a simple API for devices to request being reset by separate reset controller hardware and implements the reset signal device tree binding.
---
Changes since v1:
- Added missing header files.
- Fixed reset_controller_register comment.
- Added missing reset_controller_unregister.
- Made reset_control_reset/assert/deassert return -ENOSYS if not implemented by the reset controller driver.
- Fixed reset_control_put to not access rstc after freeing it.
- Whitespace fixes
--- drivers/Kconfig | 2 + drivers/Makefile | 3 + drivers/reset/Kconfig | 9 ++ drivers/reset/Makefile | 1 + drivers/reset/core.c | 238 ++++++++++++++++++++++++++++++++++++++ include/linux/reset-controller.h | 39 +++++++ include/linux/reset.h | 17 +++ 7 files changed, 309 insertions(+) create mode 100644 drivers/reset/Kconfig create mode 100644 drivers/reset/Makefile create mode 100644 drivers/reset/core.c create mode 100644 include/linux/reset-controller.h create mode 100644 include/linux/reset.h
drivers/Kconfig +2 -0
@@ -162,4 +162,6 @@ source "drivers/irqchip/Kconfig" source "drivers/ipack/Kconfig" +source "drivers/reset/Kconfig" + endmenu
drivers/Makefile +3 -0
@@ -42,6 +42,9 @@ ifndef CONFIG_ARCH_USES_GETTIMEOFFSET obj-y += clocksource/ endif +# reset controllers early, since gpu drivers might rely on them to initialize +obj-$(CONFIG_RESET_CONTROLLER) += reset/ + # tty/ comes before char/ so that the VT console is the boot-time # default. obj-y += tty/
drivers/reset/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +menuconfig RESET_CONTROLLER + bool "Reset Controller Support" + help + Generic Reset Controller support. + + This framework is designed to abstract reset handling of devices + via GPIOs or SoC-internal reset controller modules. + + If unsure, say no.
drivers/reset/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_RESET_CONTROLLER) += core.o
drivers/reset/core.c new file +238 -0
238 lines not on this page · raw message
include/linux/reset-controller.h new file +39 -0
@@ -0,0 +1,39 @@ +#ifndef _LINUX_RESET_CONTROLLER_H_ +#define _LINUX_RESET_CONTROLLER_H_ + +#include <linux/list.h> + +struct reset_controller_dev ; + +/** +* struct reset_control_ops +* +* @reset: for self-deasserting resets, does all necessary +* things to reset the device +* @assert: manually assert the reset line, if supported +* @deassert: manually deassert the reset line, if supported +*/ +struct reset_control_ops { +int (*reset)(struct reset_controller_dev *rcdev,unsigned long id); +int (*assert)(struct reset_controller_dev *rcdev,unsigned long id); +int (*deassert)(struct reset_controller_dev *rcdev,unsigned long id); +}; + +struct module ; +struct device_node ; + +/** +* struct reset_controller - reset controller entity that might +* provide multiple reset controls +*/ +struct reset_controller_dev { +struct reset_control_ops *ops; +struct module *owner; +struct list_head list; +struct device_node *of_node; +}; + +int reset_controller_register (struct reset_controller_dev *rcdev); +void reset_controller_unregister (struct reset_controller_dev *rcdev); + +#endif
include/linux/reset.h new file +17 -0
@@ -0,0 +1,17 @@ +#ifndef _LINUX_RESET_H_ +#define _LINUX_RESET_H_ + +struct device ; +struct reset_control ; + +int reset_control_reset (struct reset_control *rstc); +int reset_control_assert (struct reset_control *rstc); +int reset_control_deassert (struct reset_control *rstc); + +struct reset_control *reset_controlr_get (struct device *dev,const char *id); +void reset_control_put (struct reset_control *rstc); +struct reset_control *devm_reset_control_get (struct device *dev,const char *id); + +int device_reset (struct device *dev); + +#endif
Signature · 1 line
1.7.10.4
PATCH v2 2/8 reset: Add reset controller API
Quoted 89 lines · Philipp Zabel
This adds a simple API for devices to request being reset by separate reset controller hardware and implements the reset signal device tree binding.
Signed-off-by Philipp Zabel <[email protected]>Reviewed-by Stephen Warren <[email protected]>---
Changes since v1:
- Added missing header files.
- Fixedreset_controller_registercomment.
- Added missingreset_controller_unregister.
- Made reset_control_reset/assert/deassert return-ENOSYSif not implemented by the reset controller driver.
- Fixedreset_control_putto not access rstc after freeing it.
- Whitespace fixes--- drivers/Kconfig | 2 + drivers/Makefile | 3 + drivers/reset/Kconfig | 9 ++ drivers/reset/Makefile | 1 + drivers/reset/core.c | 238 ++++++++++++++++++++++++++++++++++++++ include/linux/reset-controller.h | 39 +++++++ include/linux/reset.h | 17 +++ 7 files changed, 309 insertions(+) create mode 100644 drivers/reset/Kconfig create mode 100644 drivers/reset/Makefile create mode 100644 drivers/reset/core.c create mode 100644 include/linux/reset-controller.h create mode 100644 include/linux/reset.hdrivers/Kconfig +2
-0@@ -162,4 +162,6 @@ source "drivers/irqchip/Kconfig" source "drivers/ipack/Kconfig" +source "drivers/reset/Kconfig" + endmenudrivers/Makefile +3
-0@@ -42,6 +42,9 @@ ifndef CONFIG_ARCH_USES_GETTIMEOFFSET obj-y += clocksource/ endif +# reset controllers early, since gpu drivers might rely on them to initialize +obj-$(CONFIG_RESET_CONTROLLER) += reset/ + # tty/ comes before char/ so that the VT console is the boot-time # default. obj-y += tty/drivers/reset/Kconfig new file +9
-0@@ -0,0 +1,9 @@ +menuconfig RESET_CONTROLLER + bool "Reset Controller Support" + help + Generic Reset Controller support. + + This framework is designed to abstract reset handling of devices + via GPIOs or SoC-internal reset controller modules. + + If unsure, say no.drivers/reset/Makefile new file +1
-0@@ -0,0 +1 @@ +obj-$(CONFIG_RESET_CONTROLLER) += core.odrivers/reset/core.c new file +6
-0@@ -0,0 +1,238 @@ +#include <linux/device.h> +#include <linux/err.h> +#include <linux/export.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h>
drivers/reset/core.c line 16
Quoted 10 lines
drivers/reset/core.c new file +10
-0+#include <linux/reset.h> +#include <linux/reset-controller.h> +#include <linux/slab.h> + +static DEFINE_MUTEX (reset_controller_list_mutex); +static LIST_HEAD (reset_controller_list); + +/** +* struct reset_control - a reset control +*
I see two kerneldoc styles in the file. Some have new lines here while others do not.
And @rcdev is missing.
Quoted 11 lines
drivers/reset/core.c new file +11
-0+* @id: ID of the reset controller in the reset +* controller device +*/ +struct reset_control { +struct reset_controller_dev *rcdev; +unsigned int id; +}; + +/** +* reset_controller_register - register a reset controller device +*
drivers/reset/core.c line 37
Quoted 10 lines
drivers/reset/core.c new file +10
-0+* @rcdev: a pointer to struct reset_controller_dev +*/ +int reset_controller_register (struct reset_controller_dev *rcdev) +{ +mutex_lock (&reset_controller_list_mutex); +list_add (&rcdev->list, &reset_controller_list); +mutex_unlock (&reset_controller_list_mutex); + +return 0 ; +}
I think we need EXPORT_SYMBOL_GPL on it, as the gpio-reset driver added in patch #8 which supports module build will need it.
drivers/reset/core.c line 49
Quoted 12 lines
drivers/reset/core.c new file +12
-0+ +/** +* reset_controller_unregister - unregister a reset controller device +* +* @rcdev: a pointer to struct reset_controller_dev +*/ +void reset_controller_unregister (struct reset_controller_dev *rcdev) +{ +mutex_lock (&reset_controller_list_mutex); +list_del (&rcdev->list); +mutex_unlock (&reset_controller_list_mutex); +}
Ditto
Quoted 77 lines
drivers/reset/core.c new file +77
-0+ +/** +* reset_control_reset - reset the controlled device +* @rstc: reset controller +*/ +int reset_control_reset (struct reset_control *rstc) +{ +if (rstc->rcdev->ops->reset) +return rstc->rcdev->ops->reset (rstc->rcdev, rstc->id); + +return -ENOSYS ; +} +EXPORT_SYMBOL_GPL (reset_control_reset); + +/** +* reset_control_assert - asserts the reset line +* @rstc: reset controller +*/ +int reset_control_assert (struct reset_control *rstc) +{ +if (rstc->rcdev->ops->assert) +return rstc->rcdev->ops->assert (rstc->rcdev, rstc->id); + +return -ENOSYS ; +} +EXPORT_SYMBOL_GPL (reset_control_assert); + +/** +* reset_control_deassert - deasserts the reset line +* @rstc: reset controller +*/ +int reset_control_deassert (struct reset_control *rstc) +{ +if (rstc->rcdev->ops->deassert) +return rstc->rcdev->ops->deassert (rstc->rcdev, rstc->id); + +return -ENOSYS ; +} +EXPORT_SYMBOL_GPL (reset_control_deassert); + +/** +* reset_control_get - Lookup and obtain a reference to a reset controller. +* @dev: device to be reset by the controller +* @id: reset line name +* +* Returns a struct reset_control or IS_ERR() condition containing errno. +* +* Use of id names is optional. +*/ +struct reset_control *reset_control_get (struct device *dev,const char *id) +{ +struct reset_control *rstc =ERR_PTR (-EPROBE_DEFER ); +struct reset_controller_dev *r, *rcdev; +struct device_node *rcdev_node; +struct of_phandle_args args; +int rcdev_index; +int ret; +int i; + +if (!dev) +return ERR_PTR (-EINVAL ); + + rcdev_node =NULL ; +for (i =0 ; rcdev_node ==NULL ; i++) { + ret =of_parse_phandle_with_args (dev->of_node,"resets" , +"#reset-cells" , i, &args); +if (ret) +return ERR_PTR (ret); +of_node_put (args.np); +if (args.args_count <=0 ) +return ERR_PTR (-EINVAL ); + +if (id) { +const char *reset_name; + ret =of_property_read_string_index (dev->of_node, +"reset-names" , i, + &reset_name);
drivers/reset/core.c line 136
Quoted 10 lines
drivers/reset/core.c new file +10
-0+if (ret) +return ERR_PTR (ret); +if (strcmp (id, reset_name) !=0 ) +continue ; + } + + rcdev_index = args.args[0 ]; + rcdev_node = args.np; +break ; + }
I feel the block could be simplified a little bit by calling of_property_match_string(dev->of_node, "reset-names", id) to find the index that is needed by of_parse_phandle_with_args() call.
You might want to take a look at of_clk_get_by_name() - drivers/clk/clkdev.c for example.
Quoted 20 lines
drivers/reset/core.c new file +20
-0+ +mutex_lock (&reset_controller_list_mutex); + rcdev =NULL ; +list_for_each_entry (r, &reset_controller_list, list) { +if (rcdev_node == r->of_node) { + rcdev = r; +break ; + } + } +mutex_unlock (&reset_controller_list_mutex); + +if (!rcdev) +return ERR_PTR (-ENODEV ); + +try_module_get (rcdev->owner); + + rstc =kzalloc (sizeof (*rstc),GFP_KERNEL ); +if (!rstc) +return ERR_PTR (-ENOMEM ); +
drivers/reset/core.c line 166
Quoted 10 lines
drivers/reset/core.c new file +10
-0+ rstc->rcdev = rcdev; + rstc->id = rcdev_index; + +return rstc; +} +EXPORT_SYMBOL_GPL (reset_control_get); + +/** +* reset_control_put - free the reset controller +* @reset: reset controller
@rstc, not @reset.
Quoted 58 lines
drivers/reset/core.c new file +58
-0+*/ + +void reset_control_put (struct reset_control *rstc) +{ +if (IS_ERR (rstc)) +return ; + +module_put (rstc->rcdev->owner); +kfree (rstc); +} +EXPORT_SYMBOL_GPL (reset_control_put); + +static void devm_reset_control_release (struct device *dev,void *res) +{ +reset_control_put (*(struct reset_control **)res); +} + +/** +* devm_reset_control_get - resource managed reset_control_get() +* @dev: device to be reset by the controller +* @id: reset line name +* +* Managed reset_control_get(). For reset controllers returned from this +* function, reset_control_put() is called automatically on driver detach. +* See reset_control_get() for more information. +*/ +struct reset_control *devm_reset_control_get (struct device *dev,const char *id) +{ +struct reset_control **ptr, *rstc; + + ptr =devres_alloc (devm_reset_control_release,sizeof (*ptr), +GFP_KERNEL ); +if (!ptr) +return ERR_PTR (-ENOMEM ); + + rstc =reset_control_get (dev, id); +if (!IS_ERR (rstc)) { + *ptr = rstc; +devres_add (dev, ptr); + }else { +devres_free (ptr); + } + +return rstc; +} +EXPORT_SYMBOL_GPL (devm_reset_control_get); + +/** +* device_reset - find reset controller associated with the device +* and perform reset +* @dev: device to be reset by the controller +* +* Convenience wrapper for reset_control_get() and reset_control_reset(). +* This is useful for the common case of devices with single, dedicated reset +* lines. +*/ +int device_reset (struct device *dev) +{
drivers/reset/core.c line 234
Quoted 10 lines
drivers/reset/core.c new file +10
-0+struct reset_control *rstc; +int ret; + + rstc =reset_control_get (dev,NULL ); +if (IS_ERR (rstc)) +return PTR_ERR (rstc); + + ret =reset_control_reset (rstc); + +kfree (rstc);
Shouldn't reset_control_put() be called here instead?
Quoted 26 lines
drivers/reset/core.c new file +4
-0+ +return ret; +} +EXPORT_SYMBOL_GPL (device_reset);include/linux/reset-controller.h new file +16
-0@@ -0,0 +1,39 @@ +#ifndef _LINUX_RESET_CONTROLLER_H_ +#define _LINUX_RESET_CONTROLLER_H_ + +#include <linux/list.h> + +struct reset_controller_dev ; + +/** +* struct reset_control_ops +* +* @reset: for self-deasserting resets, does all necessary +* things to reset the device +* @assert: manually assert the reset line, if supported +* @deassert: manually deassert the reset line, if supported +*/ +struct reset_control_ops {
include/linux/reset-controller.h line 26
Quoted 10 lines
include/linux/reset-controller.h new file +10
-0+int (*reset)(struct reset_controller_dev *rcdev,unsigned long id); +int (*assert)(struct reset_controller_dev *rcdev,unsigned long id); +int (*deassert)(struct reset_controller_dev *rcdev,unsigned long id); +}; + +struct module ; +struct device_node ; + +/** +* struct reset_controller - reset controller entity that might
s/reset_controller/reset_controller_dev
include/linux/reset-controller.h line 27
Quoted 1 line
include/linux/reset-controller.h new file +1
-0+* provide multiple reset controls
Kerneldoc of parameters are missing.
Shawn
Quoted 38 lines
include/linux/reset-controller.h new file +12
-0+*/ +struct reset_controller_dev { +struct reset_control_ops *ops; +struct module *owner; +struct list_head list; +struct device_node *of_node; +}; + +int reset_controller_register (struct reset_controller_dev *rcdev); +void reset_controller_unregister (struct reset_controller_dev *rcdev); + +#endif include/linux/reset.h new file +17
-0@@ -0,0 +1,17 @@ +#ifndef _LINUX_RESET_H_ +#define _LINUX_RESET_H_ + +struct device ; +struct reset_control ; + +int reset_control_reset (struct reset_control *rstc); +int reset_control_assert (struct reset_control *rstc); +int reset_control_deassert (struct reset_control *rstc); + +struct reset_control *reset_controlr_get (struct device *dev,const char *id); +void reset_control_put (struct reset_control *rstc); +struct reset_control *devm_reset_control_get (struct device *dev,const char *id); + +int device_reset (struct device *dev); + +#endif Signature · 1 line
1.7.10.4
Philipp Zabel
maintainerPATCH v2 3/8 ARM i.MX6q: Add GPU, VPU, IPU, and OpenVG resets to System Reset Controller (SRC)
In reply to Philipp ZabelThe SRC has auto-deasserting reset bits that control reset lines to the GPU, VPU, IPU, and OpenVG IP modules. This patch adds a reset controller that can be controlled by those devices using the reset controller API.
---
Changes since v1:
- Removed .is_asserted op.
- Added struct reset_controller_dev pointer to .reset op.
--- .../devicetree/bindings/reset/fsl,imx-src.txt | 49 ++++++++++++++++++ arch/arm/mach-imx/src.c | 54 ++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 Documentation/devicetree/bindings/reset/fsl,imx-src.txt
Documentation/devicetree/bindings/reset/fsl,imx-src.txt new file +49 -0
@@ -0,0 +1,49 @@ +Freescale i.MX System Reset Controller +====================================== + +Please also refer to reset.txt in this directory for common reset +controller binding usage. + +Required properties: +- compatible: Should be "fsl,<chip>-src" +- reg: should be register base and length as documented in the + datasheet +- interrupts: Should contain SRC interrupt and CPU WDOG interrupt, + in this order. +- #reset-cells: 1, see below + +example: + +src: src at 020d8000 { + compatible = "fsl,imx6q-src"; + reg = <0x020d8000 0x4000>; + interrupts = <0 91 0x04 0 96 0x04>; + #reset-cells = <1>; +}; + +Specifying reset lines connected to IP modules +============================================== + +The system reset controller can be used to reset the GPU, VPU, +IPU, and OpenVG IP modules on i.MX5 and i.MX6 ICs. Those device +nodes should specify the reset line on the SRC in their resets +property, containing a phandle to the SRC device node and a +RESET_INDEX specifying which module to reset, as described in +reset.txt + +example: + + ipu1: ipu at 02400000 { + resets = <&src 2>; + }; + ipu2: ipu at 02800000 { + resets = <&src 4>; + }; + +The following RESET_INDEX values are valid for i.MX5: +GPU_RESET 0 +VPU_RESET 1 +IPU1_RESET 2 +OPEN_VG_RESET 3 +The following additional RESET_INDEX value is valid for i.MX6: +IPU2_RESET 4
arch/arm/mach-imx/src.c +54 -0
77 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v2 3/8 ARM i.MX6q: Add GPU, VPU, IPU, and OpenVG resets to System Reset Controller (SRC)
Quoted 113 lines · Philipp Zabel
The SRC has auto-deasserting reset bits that control reset lines to the GPU, VPU, IPU, and OpenVG IP modules. This patch adds a reset controller that can be controlled by those devices using the reset controller API.
Signed-off-by Philipp Zabel <[email protected]>Reviewed-by Stephen Warren <[email protected]>---
Changes since v1:
- Removed .is_asserted op.
- Added structreset_controller_devpointer to .reset op.--- .../devicetree/bindings/reset/fsl,imx-src.txt | 49 ++++++++++++++++++ arch/arm/mach-imx/src.c | 54 ++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 Documentation/devicetree/bindings/reset/fsl,imx-src.txtDocumentation/devicetree/bindings/reset/fsl,imx-src.txt new file +49
-0@@ -0,0 +1,49 @@ +Freescale i.MX System Reset Controller +====================================== + +Please also refer to reset.txt in this directory for common reset +controller binding usage. + +Required properties: +- compatible: Should be "fsl,<chip>-src" +- reg: should be register base and length as documented in the + datasheet +- interrupts: Should contain SRC interrupt and CPU WDOG interrupt, + in this order. +- #reset-cells: 1, see below + +example: + +src: src at 020d8000 { + compatible = "fsl,imx6q-src"; + reg = <0x020d8000 0x4000>; + interrupts = <0 91 0x04 0 96 0x04>; + #reset-cells = <1>; +}; + +Specifying reset lines connected to IP modules +============================================== + +The system reset controller can be used to reset the GPU, VPU, +IPU, and OpenVG IP modules on i.MX5 and i.MX6 ICs. Those device +nodes should specify the reset line on the SRC in their resets +property, containing a phandle to the SRC device node and a +RESET_INDEX specifying which module to reset, as described in +reset.txt + +example: + + ipu1: ipu at 02400000 { + resets = <&src 2>; + }; + ipu2: ipu at 02800000 { + resets = <&src 4>; + }; + +The following RESET_INDEX values are valid for i.MX5: +GPU_RESET 0 +VPU_RESET 1 +IPU1_RESET 2 +OPEN_VG_RESET 3 +The following additional RESET_INDEX value is valid for i.MX6: +IPU2_RESET 4arch/arm/mach-imx/src.c +22
-0@@ -14,17 +14,68 @@#include <linux/io.h> #include <linux/of.h> #include <linux/of_address.h> +#include <linux/reset-controller.h> #include <linux/smp.h> #include <asm/smp_plat.h> #define SRC_SCR 0x000#define SRC_GPR1 0x020#define BP_SRC_SCR_WARM_RESET_ENABLE 0 +#define BP_SRC_SCR_SW_GPU_RST 1 +#define BP_SRC_SCR_SW_VPU_RST 2 +#define BP_SRC_SCR_SW_IPU1_RST 3 +#define BP_SRC_SCR_SW_OPEN_VG_RST 4 +#define BP_SRC_SCR_SW_IPU2_RST 12#define BP_SRC_SCR_CORE1_RST 14#define BP_SRC_SCR_CORE1_ENABLE 22static void __iomem *src_base; +static int sw_reset_bits[5 ] = { +BP_SRC_SCR_SW_GPU_RST , +BP_SRC_SCR_SW_VPU_RST , +BP_SRC_SCR_SW_IPU1_RST , +BP_SRC_SCR_SW_OPEN_VG_RST , +BP_SRC_SCR_SW_IPU2_RST +}; + +static int imx_src_reset_module (struct reset_controller_dev *rcdev, +unsigned long sw_reset_idx) +{ +unsigned long timeout; +int bit; +u32 val; + +if (!src_base)
arch/arm/mach-imx/src.c line 59
Quoted 10 lines
arch/arm/mach-imx/src.c +10
-0+return -ENODEV ; + +if (sw_reset_idx >=ARRAY_SIZE (sw_reset_bits)) +return -EINVAL ; + + bit =1 << sw_reset_bits[sw_reset_idx]; + + val =readl_relaxed (src_base +SRC_SCR ); + val |= bit; +writel_relaxed (val, src_base +SRC_SCR );
Now, SRC_SCR is read/modify/write in a few contexts. I'm wondering if we need some locking mechanism protecting against it.
Shawn
Quoted 35 lines
arch/arm/mach-imx/src.c +22
-0+ + timeout = jiffies +msecs_to_jiffies (1000 ); +while (readl (src_base +SRC_SCR ) & bit) { +if (time_after (jiffies, timeout)) +return -ETIME ; +cpu_relax (); + } + +return 0 ; +} + +static struct reset_control_ops imx_src_ops = { + .reset = imx_src_reset_module, +}; + +static struct reset_controller_dev imx_reset_controller = { + .ops = &imx_src_ops, +}; +void imx_enable_cpu (int cpu,bool enable) {u32 mask, val;@@ -65,6 +116,9 @@ void __init imx_src_init(void) src_base =of_iomap (np,0 );WARN_ON (!src_base); + imx_reset_controller.of_node = np; +reset_controller_register (&imx_reset_controller); +/* * force warm reset sources to generate cold reset * for a more reliable restart Signature · 1 line
1.7.10.4
PATCH v2 3/8 ARM i.MX6q: Add GPU, VPU, IPU, and OpenVG resets to System Reset Controller (SRC)
In reply to Philipp ZabelQuoted 4 lines · Philipp Zabel
The SRC has auto-deasserting reset bits that control reset lines to the GPU, VPU, IPU, and OpenVG IP modules. This patch adds a reset controller that can be controlled by those devices using the reset controller API.
We now architecturally depend on RESET_CONTROLLER, so need to have Kconfig to reflect that. Not sure if it's the best solution, the following is what I have.
drivers/reset/Kconfig:
config ARCH_HAS_RESET_CONTROLLER
bool
menuconfig RESET_CONTROLLER
bool "Reset Controller Support"
default y if ARCH_HAS_RESET_CONTROLLER
arch/arm/mach-imx/Kconfig:
config ARCH_MXC
bool "Freescale i.MX family" if ARCH_MULTI_V4_V5 || ARCH_MULTI_V6_V7
+ select ARCH_HAS_RESET_CONTROLLER
select ARCH_REQUIRE_GPIOLIB
select ARM_PATCH_PHYS_VIRT
select AUTO_ZRELADDR if !ZBOOT_ROM
Shawn
Philipp Zabel
maintainerPATCH v2 4/8 ARM i.MX6q: Link system reset controller (SRC) to IPU in DT
In reply to Philipp Zabel---
Changes since v1:
- Fixed resets property in ipu2 device node.
--- arch/arm/boot/dts/imx6q.dtsi | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/boot/dts/imx6q.dtsi +3 -0
@@ -555,6 +555,7 @@ compatible = "fsl,imx6q-src"; reg = <0x020d8000 0x4000>; interrupts = <0 91 0x04 0 96 0x04>; + #reset-cells = <1>; }; gpc: gpc at 020dc000 {
@@ -1046,6 +1047,7 @@ interrupts = <0 6 0x4 0 5 0x4>; clocks = <&clks 130>, <&clks 131>, <&clks 132>; clock-names = "bus", "di0", "di1"; + resets = <&src 2>; }; ipu2: ipu at 02800000 {
@@ -1055,6 +1057,7 @@ interrupts = <0 8 0x4 0 7 0x4>; clocks = <&clks 133>, <&clks 134>, <&clks 137>; clock-names = "bus", "di0", "di1"; + resets = <&src 4>; }; }; };
Signature · 1 line
1.7.10.4
Philipp Zabel
maintainerPATCH v2 5/8 staging: drm/imx: Use SRC to reset IPU
In reply to Philipp ZabelRequest the System Reset Controller to reset the IPU if specified via device tree phandle.
--- .../devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt | 3 +++ drivers/staging/imx-drm/ipu-v3/ipu-common.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/staging/imx-drm/fsl-imx-drm.txt +3 -0
@@ -8,6 +8,8 @@ Required properties: - interrupts: Should contain sync interrupt and error interrupt, in this order. - #crtc-cells: 1, See below +- resets: phandle pointing to the system reset controller and + reset line index, see reset/fsl,imx-src.txt for details example:
@@ -16,6 +18,7 @@ ipu: ipu at 18000000 { compatible = "fsl,imx53-ipu"; reg = <0x18000000 0x080000000>; interrupts = <11 10>; + resets = <&src 2>; }; Parallel display support
drivers/staging/imx-drm/ipu-v3/ipu-common.c +9 -3
@@ -16,6 +16,7 @@#include <linux/export.h> #include <linux/types.h> #include <linux/init.h> +#include <linux/reset.h> #include <linux/platform_device.h> #include <linux/err.h> #include <linux/spinlock.h>
@@ -660,7 +661,7 @@ int ipu_idmac_disable_channel(struct ipuv3_channel *channel) }EXPORT_SYMBOL_GPL (ipu_idmac_disable_channel); -static int ipu_reset (struct ipu_soc *ipu) +static int ipu_memory_reset (struct ipu_soc *ipu) {unsigned long timeout;
@@ -1104,7 +1105,12 @@ static int ipu_probe(struct platform_device *pdev)if (ret) goto out_failed_irq; - ret =ipu_reset (ipu); + ret =device_reset (&pdev->dev); +if (ret) { +dev_err (&pdev->dev,"failed to reset: %d\n" , ret); + goto out_failed_reset; + } + ret =ipu_memory_reset (ipu);if (ret) goto out_failed_reset;
@@ -1130,8 +1136,8 @@ static int ipu_probe(struct platform_device *pdev) failed_add_clients:ipu_submodules_exit (ipu); failed_submodules_init: -ipu_irq_exit (ipu); out_failed_reset: +ipu_irq_exit (ipu); out_failed_irq:clk_disable_unprepare (ipu->clk); failed_clk_get:
Signature · 1 line
1.7.10.4
Philipp Zabel
maintainerPATCH v2 6/8 ARM i.MX5: Add System Reset Controller (SRC) support for i.MX51 and i.MX53
In reply to Philipp ZabelThe SRC in i.MX51 and i.MX53 is similar to the one in i.MX6q minus the IPU2 reset line and multi core CPU reset/enable bits.
---
Changes since v1:
- Changed matching compatible string to "fsl,imx51-src"
- Use imx_src_init for both i.MX5 and i.MX6
--- arch/arm/boot/dts/imx6q.dtsi | 2 +- arch/arm/mach-imx/Kconfig | 2 ++ arch/arm/mach-imx/mm-imx5.c | 2 ++ arch/arm/mach-imx/src.c | 4 +++- 4 files changed, 8 insertions(+), 2 deletions(-)
arch/arm/boot/dts/imx6q.dtsi +1 -1
@@ -552,7 +552,7 @@ }; src: src at 020d8000 { - compatible = "fsl,imx6q-src"; + compatible = "fsl,imx6q-src", "fsl,imx51-src"; reg = <0x020d8000 0x4000>; interrupts = <0 91 0x04 0 96 0x04>; #reset-cells = <1>;
arch/arm/mach-imx/Kconfig +2 -0
@@ -165,6 +165,7 @@ config SOC_IMX51 bool select ARCH_MX5 select ARCH_MX51 + select HAVE_IMX_SRC select PINCTRL select PINCTRL_IMX51 select SOC_IMX5
@@ -792,6 +793,7 @@ config SOC_IMX53 select ARCH_MX5 select ARCH_MX53 select HAVE_CAN_FLEXCAN if CAN + select HAVE_IMX_SRC select IMX_HAVE_PLATFORM_IMX2_WDT select PINCTRL select PINCTRL_IMX53
arch/arm/mach-imx/mm-imx5.c +2 -0
@@ -84,6 +84,7 @@ void __init imx51_init_early(void)mxc_set_cpu_type (MXC_CPU_MX51 );mxc_iomux_v3_init (MX51_IO_ADDRESS (MX51_IOMUXC_BASE_ADDR ));mxc_arch_reset_init (MX51_IO_ADDRESS (MX51_WDOG1_BASE_ADDR )); +imx_src_init (); }void __init imx53_init_early (void )
@@ -91,6 +92,7 @@ void __init imx53_init_early(void)mxc_set_cpu_type (MXC_CPU_MX53 );mxc_iomux_v3_init (MX53_IO_ADDRESS (MX53_IOMUXC_BASE_ADDR ));mxc_arch_reset_init (MX53_IO_ADDRESS (MX53_WDOG1_BASE_ADDR )); +imx_src_init (); }void __init mx51_init_irq (void )
arch/arm/mach-imx/src.c +3 -1
@@ -112,7 +112,9 @@ void __init imx_src_init(void)struct device_node *np;u32 val; - np =of_find_compatible_node (NULL ,NULL ,"fsl,imx6q-src" ); + np =of_find_compatible_node (NULL ,NULL ,"fsl,imx51-src" ); +if (!np) +return ; src_base =of_iomap (np,0 );WARN_ON (!src_base);
Signature · 1 line
1.7.10.4
Philipp Zabel
maintainerPATCH v2 7/8 ARM i.MX5: Add system reset controller (SRC) to i.MX51 and i.MX53 device tree
In reply to Philipp ZabelAlso, link SRC to IPU via phandle.
---
Changes since v1:
- Changed compatible strings to "fsl,<soc>-src"
--- arch/arm/boot/dts/imx51.dtsi | 7 +++++++ arch/arm/boot/dts/imx53.dtsi | 7 +++++++ 2 files changed, 14 insertions(+)
arch/arm/boot/dts/imx51.dtsi +7 -0
@@ -67,6 +67,7 @@ compatible = "fsl,imx51-ipu"; reg = <0x40000000 0x20000000>; interrupts = <11 10>; + resets = <&src 2>; }; aips at 70000000 { /* AIPS1 */
@@ -448,6 +449,12 @@ status = "disabled"; }; + src: src at 73fd0000 { + compatible = "fsl,imx51-src"; + reg = <0x73fd0000 0x4000>; + #reset-cells = <1>; + }; + clks: ccm at 73fd4000{ compatible = "fsl,imx51-ccm"; reg = <0x73fd4000 0x4000>;
arch/arm/boot/dts/imx53.dtsi +7 -0
@@ -72,6 +72,7 @@ compatible = "fsl,imx53-ipu"; reg = <0x18000000 0x080000000>; interrupts = <11 10>; + resets = <&src 2>; }; aips at 50000000 { /* AIPS1 */
@@ -497,6 +498,12 @@ status = "disabled"; }; + src: src at 53fd0000 { + compatible = "fsl,imx53-src", "fsl,imx51-src"; + reg = <0x53fd0000 0x4000>; + #reset-cells = <1>; + }; + clks: ccm at 53fd4000{ compatible = "fsl,imx53-ccm"; reg = <0x53fd4000 0x4000>;
Signature · 1 line
1.7.10.4
Philipp Zabel
maintainerPATCH v2 8/8 reset: Add driver for gpio-controlled reset pins
In reply to Philipp Zabel--- drivers/reset/Kconfig | 13 +++ drivers/reset/Makefile | 1 + drivers/reset/gpio-reset.c | 188 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 202 insertions(+) create mode 100644 drivers/reset/gpio-reset.c
drivers/reset/Kconfig +13 -0
@@ -7,3 +7,16 @@ menuconfig RESET_CONTROLLER via GPIOs or SoC-internal reset controller modules. If unsure, say no. + +if RESET_CONTROLLER + +config RESET_GPIO + tristate "GPIO reset controller support" + depends on GENERIC_GPIO + help + This driver provides support for reset lines that are controlled + directly by GPIOs. + The delay between assertion and de-assertion of the reset signal + can be configured. + +endif
drivers/reset/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_RESET_CONTROLLER) += core.o +obj-$(CONFIG_RESET_GPIO) += gpio-reset.o
drivers/reset/gpio-reset.c new file +188 -0
188 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v2 8/8 reset: Add driver for gpio-controlled reset pins
Quoted 1 line · Philipp Zabel
Signed-off-by Philipp Zabel <[email protected]>
Just be aware that PXA has a "gpio reset" facility which is used for SoC reset - see arch/arm/mach-pxa/reset.c
The use of gpio-reset would be ambiguous... or maybe PXA's usage could be combined somehow with this?
Philipp Zabel
maintainerPATCH v2 8/8 reset: Add driver for gpio-controlled reset pins
Hi Russell,
Am Donnerstag, den 14.02.2013, 10:56 +0000 schrieb Russell King - ARM Linux:
Quoted 8 lines · Philipp Zabel
Quoted 1 line
Signed-off-by Philipp Zabel <[email protected]>Just be aware that PXA has a "gpio reset" facility which is used for SoC reset - see
arch/arm/mach-pxa/reset.cThe use of gpio-reset would be ambiguous... or maybe PXA's usage could be combined somehow with this?
thank you for pointing this out. The PXA gpio reset code is used for system/board reset and fiddles with the reset line to trigger all possible types of reset without needing configuration. The code I suggest is targeted at resetting peripheral devices, like I2C and SPI ICs with a reset line connected via GPIO, and it has to be configured for either active-high or active-low GPIOs. Should this be combined? I wonder if it would be worth the effort to make the PXA gpio reset go through this reset API, as there isn't even a struct device that would be the reset "consumer".
In fact, I don't even think most drivers that currently implement gpio resets themselves would gain much from switching to another level of abstraction, unless the SoC already has an on-chip reset controller anyway - in which case this would mostly increase overall consistency.
regards
Philipp
PATCH v2 8/8 reset: Add driver for gpio-controlled reset pins
In reply to Philipp ZabelQuoted 1 line · Philipp Zabel
Signed-off-by Philipp Zabel <[email protected]>
You must have something to mention in the commit log when you add such a new reset controller.
Quoted 6 lines
--- drivers/reset/Kconfig | 13 +++ drivers/reset/Makefile | 1 + drivers/reset/gpio-reset.c | 188 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 202 insertions(+) create mode 100644 drivers/reset/gpio-reset.c
...
Quoted 4 lines
drivers/reset/gpio-reset.c new file +4
-0+static int gpio_reset_probe (struct platform_device *pdev) +{ +struct device_node *np = pdev->dev.of_node; +struct gpio_reset_data *drvdata;
drivers/reset/gpio-reset.c line 101
Quoted 10 lines
drivers/reset/gpio-reset.c new file +10
-0+enum of_gpio_flags flags; +u32 *delays =NULL ; +int ret; +int i; + + drvdata =devm_kzalloc (&pdev->dev,sizeof (*drvdata),GFP_KERNEL ); +if (drvdata ==NULL ) +return -ENOMEM ; + + drvdata->nr_gpios =of_gpio_named_count (np,"gpios" );
I would suggest to name the property reset-gpios.
All the properties and compatible used in the driver should be documented in the binding doc.
Shawn
Quoted 90 lines
drivers/reset/gpio-reset.c new file +87
-0+if (drvdata->nr_gpios <1 ) +return -EINVAL ; + + drvdata->gpios =devm_kzalloc (&pdev->dev,sizeof (struct gpio_reset ) * + drvdata->nr_gpios,GFP_KERNEL ); +if (drvdata->gpios ==NULL ) +return -ENOMEM ; + +if (of_find_property (np,"reset-delays" ,NULL )) { + delays =devm_kzalloc (&pdev->dev,sizeof (u32) * + drvdata->nr_gpios,GFP_KERNEL ); +if (delays ==NULL ) +return -ENOMEM ; + + ret =of_property_read_u32_array (np,"reset-delays" , delays, + drvdata->nr_gpios); +if (ret <0 ) +return ret; + } + +for (i =0 ; i < drvdata->nr_gpios; i++) { + drvdata->gpios[i].gpio =of_get_named_gpio_flags (np,"gpios" , + i, &flags); +if (drvdata->gpios[i].gpio <0 ) { +dev_err (&pdev->dev,"invalid gpio for reset %d\n" , i); +return drvdata->gpios[i].gpio; + } + +/* +* The flags are also used to remember whether a given GPIO +* reset is active-low. +*/ +if (flags &OF_GPIO_ACTIVE_LOW ) + drvdata->gpios[i].flags =GPIOF_OUT_INIT_HIGH ; +else + drvdata->gpios[i].flags =GPIOF_OUT_INIT_LOW ; + + ret =devm_gpio_request_one (&pdev->dev, drvdata->gpios[i].gpio, + drvdata->gpios[i].flags,NULL ); +if (ret <0 ) { +dev_err (&pdev->dev,"failed to request gpio %d for reset %d\n" , + drvdata->gpios[i].gpio, i); +return ret; + } + +if (delays !=NULL ) + drvdata->gpios[i].delay_ms = delays[i]; +else + drvdata->gpios[i].delay_ms =-1 ;/* .reset returns -ENOSYS */ + } + +devm_kfree (&pdev->dev, delays); + + drvdata->rcdev.of_node = np; + drvdata->rcdev.ops = &gpio_reset_ops; +reset_controller_register (&drvdata->rcdev); + +platform_set_drvdata (pdev, drvdata); + +return 0 ; +} + +static int gpio_reset_remove (struct platform_device *pdev) +{ +struct gpio_reset_data *drvdata =platform_get_drvdata (pdev); + +reset_controller_unregister (&drvdata->rcdev); + +return 0 ; +} + +static struct of_device_id gpio_reset_dt_ids[] = { + { .compatible ="gpio-reset" }, + { } +}; + +static struct platform_driver gpio_reset_driver = { + .probe = gpio_reset_probe, + .remove = gpio_reset_remove, + .driver = { + .name ="gpio-reset" , + .owner =THIS_MODULE , + .of_match_table =of_match_ptr (gpio_reset_dt_ids), + }, +}; + +module_platform_driver (gpio_reset_driver);Signature · 1 line
1.7.10.4