ARM: OMAP2+: AM43x/AM335x prcm reset driver
Subsystems (5)
cover ARM: OMAP2+: AM43x/AM335x prcm reset driver
Hi,
This is an attempt to achieve reset on AM43x/AM335x based SoC's with reset driver making use of the reset framework.
prcm node is added in device tree, which would hold reset bindings. Initially node was made as a one that represents reset functionality of SoC. but ended up with node for prcm (which is felt to be natural choice) instead. I am a bit doubtful whether placement of prcm node in root node as in this series is the right thing.
Reset driver gets probed for specific prcm node, the same defines register details to be used for a particular SoC (using ".data" field associated with ".compatible" in driver match table).
Another option to handle different SoC's would be to add register details to DT and let the driver extract it from DT. I vaguely remember seeing a thread mentioning that putting register details in DT is not preferred. But open to putting register level details instead in DT if that is being generally preferred. This would have advantage that adding reset support for a new SoC would be easier, but would have to put more thought before doing so as DT bindings should not change.
With the approach taken here, for supporting a new SoC with new prcm register details, driver would have to be updated much like the way a pci based ethernet driver would have to be updated to handle a new IP version that is not register level compatible with the existing ones.
In this series out of the three IP's (gfx, m3, pruss) that would need reset support, here as a proof of concept only gfx is taken care. Other's can be easily supported by adding new register data array entries.
Two new reset API's are provided to check whether reset is ready and to clear reset. This would be required in case IP needs to mix reset handling procedure with power/clock managment procedure to achieve proper reset and these procedures are sometimes IP specific that would make it difficult to handle reset fully in pm_runtime platform support.
*------*
client IP handling s/w (DT based) should do as follows:
1. Specify reset handle in the relevant DT node, for eg.
myip at deadbeef {
:
:
/* here prcm is the handle to reset binding node */
resets = <&prcm 0>;
};2. In driver, that require reset to be deasserted,
(this is the sequence required for gfx on AM43x/AM335x, this would
depend on requirements of the IP)
mydriver_probe(struct platform device *pdev)
{
:
:
reset_control_get(&pdev->dev, NULL);
reset_control_clear_reset();
reset_control_deassert();
pm_runtime_get_sync();
if (reset_control_is_reset() != true)
goto err;
reset_control_put();
:
:
}*------*
May be removing reset handling in hwmod can be considered by making use of reset driver.
Or as another extreme, perhaps, other logic's in the prcm can be handled by a new prcm driver and then this reset driver can be a child of it.
Regards
Afzal
Afzal Mohammed (6):
reset: is_reset and clear_reset api's
doc: dt: binding: omap: am43x/am335x prcm reset
reset: am43x/am335x support
ARM: OMAP2+: AM43x/AM335x: have reset controller
ARM: dts: AM335x: prcm node (for reset)
ARM: dts: AM4372: prcm node (for reset)
.../devicetree/bindings/arm/omap/prcm.txt | 13 ++ arch/arm/boot/dts/am33xx.dtsi | 6 + arch/arm/boot/dts/am4372.dtsi | 6 + arch/arm/mach-omap2/Kconfig | 2 + drivers/reset/Kconfig | 14 ++ drivers/reset/Makefile | 1 + drivers/reset/amx3_reset.c | 157 +++++++++++++++++++++ drivers/reset/core.c | 32 +++++ include/linux/reset-controller.h | 2 + include/linux/reset.h | 2 + 10 files changed, 235 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/omap/prcm.txt create mode 100644 drivers/reset/amx3_reset.c
Signature · 1 line
1.8.3.4
RFC PATCH 1/6 reset: is_reset and clear_reset api's
Enhance reset framework with "is_reset" and "clear_reset" api's. is_reset - used by client driver to know reset status clear_reset - used by client driver to clear reset status
These functionalities may sometimes be achieved by using existing api like deassert. But in some scenarios, steps to achieve reset requires clearing reset, deassert reset, enabling clock to module and then checking reset status. Here enabling clock module is coming in between reset procedure, hence enhance framework with additional api's.
--- drivers/reset/core.c | 32 ++++++++++++++++++++++++++++++++ include/linux/reset-controller.h | 2 ++ include/linux/reset.h | 2 ++ 3 files changed, 36 insertions(+)
drivers/reset/core.c +32 -0
@@ -127,6 +127,38 @@ int reset_control_deassert(struct reset_control *rstc)EXPORT_SYMBOL_GPL (reset_control_deassert);/** +* reset_control_is_reset - check reset status +* @rstc: reset controller +* +* Returns a boolean or negative error code +* +*/ +int reset_control_is_reset (struct reset_control *rstc) +{ +if (rstc->rcdev->ops->is_reset) +return rstc->rcdev->ops->is_reset (rstc->rcdev, rstc->id); + +return -ENOSYS ; +} +EXPORT_SYMBOL_GPL (reset_control_is_reset); + +/** +* reset_control_clear_reset - clear the reset +* @rstc: reset controller +* +* Returns zero on success or negative error code +* +*/ +int reset_control_clear_reset (struct reset_control *rstc) +{ +if (rstc->rcdev->ops->clear_reset) +return rstc->rcdev->ops->clear_reset (rstc->rcdev, rstc->id); + +return -ENOSYS ; +} +EXPORT_SYMBOL_GPL (reset_control_clear_reset); + +/** * reset_control_get - Lookup and obtain a reference to a reset controller. * @dev: device to be reset by the controller * @id: reset line name
include/linux/reset-controller.h +2 -0
@@ -17,6 +17,8 @@ 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); +int (*is_reset)(struct reset_controller_dev *rcdev,unsigned long id); +int (*clear_reset)(struct reset_controller_dev *rcdev,unsigned long i); };struct module ;
include/linux/reset.h +2 -0
@@ -7,6 +7,8 @@ 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); +int reset_control_is_reset (struct reset_control *rstc); +int reset_control_clear_reset (struct reset_control *rstc);struct reset_control *reset_control_get (struct device *dev,const char *id);void reset_control_put (struct reset_control *rstc);
Signature · 1 line
1.8.3.4
RFC PATCH 2/6 doc: dt: binding: omap: am43x/am335x prcm reset
In reply to Afzal Mohammedprcm reset binding for AM43x/AM335x SoC's.
This was started with an attempt to add reset binding without a clear idea on the device node where binding should appear. So a new node with compatible "am4372-reset" to represent reset managment in prcm was added. But finally ended up with a node to represent prcm (with compatible "am4372-prcm") which was felt to be the natural one.
--- Documentation/devicetree/bindings/arm/omap/prcm.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/omap/prcm.txt
Documentation/devicetree/bindings/arm/omap/prcm.txt new file +13 -0
@@ -0,0 +1,13 @@ +TI Power Reset Clock Manager (PRCM) + +Properties: +- compatible: "ti,am4372-prcm" for prcm in am43x SoC's + "ti,am3352-prcm" for prcm in am335x SoC's +- #reset-cells: 1 (refer generic reset bindings for details) + +example: + prcm: prcm at 44df0000 { + compatible = "ti,am4372-prcm"; + reg = <0x44df0000 0xa000>; + #reset-cells = <1>; + };
Signature · 1 line
1.8.3.4
RFC PATCH 3/6 reset: am43x/am335x support
In reply to Afzal MohammedDriver to handle reset block in prcm of AM43x, AM335x SoC's. There are three reset's that can be handled by this reset driver - gfx, m3 and pruss. Of this only gfx has been handled here, adding support for the remaining only require adding array entries with details of pruss and m3.
--- drivers/reset/Kconfig | 14 ++++ drivers/reset/Makefile | 1 + drivers/reset/amx3_reset.c | 157 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 172 insertions(+) create mode 100644 drivers/reset/amx3_reset.c
drivers/reset/Kconfig +14 -0
@@ -11,3 +11,17 @@ menuconfig RESET_CONTROLLER via GPIOs or SoC-internal reset controller modules. If unsure, say no. + +if RESET_CONTROLLER + +config RESET_AMX3 + bool "AMx3 reset controller" + help + Reset controller support for AM43x/AM335x SoC's + + Reset controller found in TI's AM series of SoC's like + AM335x and AM43x + + If unsure, say no. + +endif
drivers/reset/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_RESET_CONTROLLER) += core.o +obj-$(CONFIG_RESET_AMX3) += amx3_reset.o
drivers/reset/amx3_reset.c new file +157 -0
157 lines not on this page · raw message
Signature · 1 line
1.8.3.4
RFC PATCH 4/6 ARM: OMAP2+: AM43x/AM335x: have reset controller
In reply to Afzal MohammedAM43x, AM335x have reset block as part of prcm, let reset driver be usable with these SoC's.
--- arch/arm/mach-omap2/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-omap2/Kconfig +2 -0
@@ -72,6 +72,7 @@ config SOC_AM33XX select CPU_V7 select MULTI_IRQ_HANDLER select COMMON_CLK + select ARCH_HAS_RESET_CONTROLLER config SOC_AM43XX bool "TI AM43x"
@@ -82,6 +83,7 @@ config SOC_AM43XX select ARM_GIC select COMMON_CLK select MACH_OMAP_GENERIC + select ARCH_HAS_RESET_CONTROLLER config ARCH_OMAP2PLUS bool
Signature · 1 line
1.8.3.4
Re: [PATCH RFC 4/6] ARM: OMAP2+: AM43x/AM335x: have reset controller
Quoted 2 lines · Afzal Mohammed
AM43x, AM335x have reset block as part of prcm, let reset driver be usable with these SoC's.
Once the driver is ready, this can be merged along with the reset driver:
Quoted 28 lines
Signed-off-by Afzal Mohammed <[email protected]>--- arch/arm/mach-omap2/Kconfig | 2 ++ 1 file changed, 2 insertions(+)arch/arm/mach-omap2/Kconfig +2
-0@@ -72,6 +72,7 @@ config SOC_AM33XX select CPU_V7 select MULTI_IRQ_HANDLER select COMMON_CLK + select ARCH_HAS_RESET_CONTROLLER config SOC_AM43XX bool "TI AM43x"@@ -82,6 +83,7 @@ config SOC_AM43XX select ARM_GIC select COMMON_CLK select MACH_OMAP_GENERIC + select ARCH_HAS_RESET_CONTROLLER config ARCH_OMAP2PLUS boolSignature · 1 line
1.8.3.4
RFC PATCH 5/6 ARM: dts: AM335x: prcm node (for reset)
In reply to Afzal MohammedAdd AM335x prcm node with reset binding.
--- arch/arm/boot/dts/am33xx.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/am33xx.dtsi +6 -0
@@ -530,6 +530,12 @@ #size-cells = <1>; status = "disabled"; }; + + prcm: prcm at 44e00000 { + compatible = "ti,am3352-prcm"; + reg = <0x44e00000 0x1300>; + #reset-cells = <1>; + }; }; clocks {
Signature · 1 line
1.8.3.4
Tony Lindgren
maintainerRe: [PATCH RFC 5/6] ARM: dts: AM335x: prcm node (for reset)
Quoted 1 line · Afzal Mohammed
Add AM335x prcm node with reset binding.
Please put the .dts changes into a separate series from driver changes so the driver maintainers don't accidentally queue also the .dts changes. This is to avoid pointless self-inflicted merge conflicts.
Regards,
Tony
Quoted 25 lines
Signed-off-by Afzal Mohammed <[email protected]>--- arch/arm/boot/dts/am33xx.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)arch/arm/boot/dts/am33xx.dtsi +6
-0@@ -530,6 +530,12 @@ #size-cells = <1>; status = "disabled"; }; + + prcm: prcm at 44e00000 { + compatible = "ti,am3352-prcm"; + reg = <0x44e00000 0x1300>; + #reset-cells = <1>; + }; }; clocks {Signature · 1 line
1.8.3.4
RFC PATCH 6/6 ARM: dts: AM4372: prcm node (for reset)
In reply to Afzal MohammedAdd AM4372 prcm node with reset binding.
--- arch/arm/boot/dts/am4372.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/am4372.dtsi +6 -0
@@ -411,6 +411,12 @@ ti,hwmods = "epwmss5"; status = "disabled"; }; + + prcm: prcm at 44df0000 { + compatible = "ti,am4372-prcm"; + reg = <0x44df0000 0xa000>; + #reset-cells = <1>; + }; }; clocks {
Signature · 1 line
1.8.3.4
Philipp Zabel
maintainerHi Afzal,
Am Montag, den 02.09.2013, 19:41 +0530 schrieb Afzal Mohammed:
Quoted 71 lines
Hi,
This is an attempt to achieve reset on AM43x/AM335x based SoC's with reset driver making use of the reset framework.
prcm node is added in device tree, which would hold reset bindings. Initially node was made as a one that represents reset functionality of SoC. but ended up with node for prcm (which is felt to be natural choice) instead. I am a bit doubtful whether placement of prcm node in root node as in this series is the right thing.
Reset driver gets probed for specific prcm node, the same defines register details to be used for a particular SoC (using ".data" field associated with ".compatible" in driver match table).
Another option to handle different SoC's would be to add register details to DT and let the driver extract it from DT. I vaguely remember seeing a thread mentioning that putting register details in DT is not preferred. But open to putting register level details instead in DT if that is being generally preferred. This would have advantage that adding reset support for a new SoC would be easier, but would have to put more thought before doing so as DT bindings should not change.
With the approach taken here, for supporting a new SoC with new prcm register details, driver would have to be updated much like the way a pci based ethernet driver would have to be updated to handle a new IP version that is not register level compatible with the existing ones.
In this series out of the three IP's (gfx, m3, pruss) that would need reset support, here as a proof of concept only gfx is taken care. Other's can be easily supported by adding new register data array entries.
Two new reset API's are provided to check whether reset is ready and to clear reset. This would be required in case IP needs to mix reset handling procedure with power/clock managment procedure to achieve proper reset and these procedures are sometimes IP specific that would make it difficult to handle reset fully in
pm_runtimeplatform support.*------*
client IP handling s/w (DT based) should do as follows:1. Specify reset handle in the relevant DT node, for eg.
myip at deadbeef { : : /* here prcm is the handle to reset binding node */ resets = <&prcm 0>; };2. In driver, that require reset to be deasserted,
(this is the sequence required for gfx on AM43x/AM335x, this would
depend on requirements of the IP)mydriver_probe(struct platform device *pdev) { : : reset_control_get(&pdev->dev, NULL); reset_control_clear_reset(); reset_control_deassert(); pm_runtime_get_sync(); if (reset_control_is_reset() != true) goto err; reset_control_put(); : : }
Quoted 1 line
*------*
if possible, I'd like to move this logic into the reset controller driver. Can this be reordered to enable power before deasserting the reset line (assuming it is initially asserted)? In this case, I'd suggest to just call device_reset:
pm_runtime_get_sync(&pdev->dev); ret = device_reset(&pdev->dev); if (ret) goto err;
The ops.reset callback in the prcm driver then can handle clearing the reset status bit, deasserting the reset control bit, and waiting for the reset status bit to be set (or timing out with an error).
Quoted 19 lines
May be removing reset handling in hwmod can be considered by making use of reset driver.
Or as another extreme, perhaps, other logic's in the prcm can be handled by a new prcm driver and then this reset driver can be a child of it.
Regards
AfzalAfzal Mohammed (6):
reset:is_resetandclear_resetapi's
doc: dt: binding: omap: am43x/am335x prcm reset
reset: am43x/am335x support
ARM: OMAP2+: AM43x/AM335x: have reset controller
ARM: dts: AM335x: prcm node (for reset)
ARM: dts: AM4372: prcm node (for reset)
Quoted 13 lines
.../devicetree/bindings/arm/omap/prcm.txt | 13 ++ arch/arm/boot/dts/am33xx.dtsi | 6 + arch/arm/boot/dts/am4372.dtsi | 6 + arch/arm/mach-omap2/Kconfig | 2 + drivers/reset/Kconfig | 14 ++ drivers/reset/Makefile | 1 + drivers/reset/amx3_reset.c | 157 +++++++++++++++++++++ drivers/reset/core.c | 32 +++++ include/linux/reset-controller.h | 2 + include/linux/reset.h | 2 + 10 files changed, 235 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/omap/prcm.txt create mode 100644 drivers/reset/amx3_reset.c
regards
Philipp
Hi Philipp,
Quoted 34 lines · Philipp Zabel
Am Montag, den 02.09.2013, 19:41 +0530 schrieb Afzal Mohammed:
Quoted 12 lines
Two new reset API's are provided to check whether reset is ready and to clear reset. This would be required in case IP needs to mix reset handling procedure with power/clock managment procedure to achieve proper reset and these procedures are sometimes IP specific that would make it difficult to handle reset fully in
pm_runtimeplatform support.client IP handling s/w (DT based) should do as follows:
2. In driver, that require reset to be deasserted,
(this is the sequence required for gfx on AM43x/AM335x, this would
depend on requirements of the IP)Quoted 14 lines
mydriver_probe(struct platform device *pdev) { : : reset_control_get(&pdev->dev, NULL); reset_control_clear_reset(); reset_control_deassert(); pm_runtime_get_sync(); if (reset_control_is_reset() != true) goto err; reset_control_put(); : : }if possible, I'd like to move this logic into the reset controller driver. Can this be reordered to enable power before deasserting the reset line (assuming it is initially asserted)? In this case, I'd suggest to just call
device_reset:
Quoted 8 lines
pm_runtime_get_sync(&pdev->dev); ret = device_reset(&pdev->dev); if (ret) goto err;The ops.reset callback in the prcm driver then can handle clearing the reset status bit, deasserting the reset control bit, and waiting for the reset status bit to be set (or timing out with an error).
I too would have loved to have it in such a clean way and was initially proceeding in that direction, but there is an issue specific to OMAP family SoC's, which was required to be taken care of (even though present use case for AM335x/AM43x would work [as it does not have hardware supervised clockdomain mode] with a small change in platform level power management support code - a generic one shared with other OMAP family SoC's)
For a module to be reset, clock domain to which the module clock belongs should be set to software supervised mode. During "pm_runtime_get_sync", in OMAP platform level handling code, it first put clockdomain into software supervised mode, enables clock to module, and once module is ready, module will be put to hardware supervised mode. In hardware supervised mode, reset may not happen.
So if device_reset() is done after pm_runtime_get_sync(), reset may not happen as by the time device_reset() is called, clockdomain would be in hardware supervised mode. But in other case, as reset is already deasserted when pm_runtime_get_sync() is called, module would be reset as it first puts to software supervised mode.
And device reset would happen only upon enabling clock to module (if reset was deasserted) by pm_runtime_get_sync(), so reset status has to be checked after pm call, preventing us having device_reset() before pm_runtime_get_sync(), or else in that case we have to sacrifice on reset status checking (which may not be reliable)
Another alternative would have been to integrate this reset handling in low level power management code thus hiding all reset handling from driver, but as far as I know the reset sequence to be done is sometimes IP specific, preventing it.
Regards
Afzal
Philipp Zabel
maintainerAm Donnerstag, den 05.09.2013, 21:26 +0530 schrieb Afzal Mohammed:
Quoted 73 lines
Hi Philipp,
Quoted 34 lines · Philipp Zabel
Am Montag, den 02.09.2013, 19:41 +0530 schrieb Afzal Mohammed:
Quoted 12 lines
Two new reset API's are provided to check whether reset is ready and to clear reset. This would be required in case IP needs to mix reset handling procedure with power/clock managment procedure to achieve proper reset and these procedures are sometimes IP specific that would make it difficult to handle reset fully in
pm_runtimeplatform support.client IP handling s/w (DT based) should do as follows:
2. In driver, that require reset to be deasserted,
(this is the sequence required for gfx on AM43x/AM335x, this would
depend on requirements of the IP)Quoted 14 lines
mydriver_probe(struct platform device *pdev) { : : reset_control_get(&pdev->dev, NULL); reset_control_clear_reset(); reset_control_deassert(); pm_runtime_get_sync(); if (reset_control_is_reset() != true) goto err; reset_control_put(); : : }if possible, I'd like to move this logic into the reset controller driver. Can this be reordered to enable power before deasserting the reset line (assuming it is initially asserted)? In this case, I'd suggest to just call
device_reset:Quoted 8 lines
pm_runtime_get_sync(&pdev->dev); ret = device_reset(&pdev->dev); if (ret) goto err;The ops.reset callback in the prcm driver then can handle clearing the reset status bit, deasserting the reset control bit, and waiting for the reset status bit to be set (or timing out with an error).
I too would have loved to have it in such a clean way and was initially proceeding in that direction, but there is an issue specific to OMAP family SoC's, which was required to be taken care of (even though present use case for AM335x/AM43x would work [as it does not have hardware supervised clockdomain mode] with a small change in platform level power management support code - a generic one shared with other OMAP family SoC's)
For a module to be reset, clock domain to which the module clock belongs should be set to software supervised mode. During "
pm_runtime_get_sync", in OMAP platform level handling code, it first put clockdomain into software supervised mode, enables clock to module, and once module is ready, module will be put to hardware supervised mode. In hardware supervised mode, reset may not happen.So if
device_reset()is done afterpm_runtime_get_sync(), reset may not happen as by the timedevice_reset()is called, clockdomain would be in hardware supervised mode. But in other case, as reset is already deasserted whenpm_runtime_get_sync()is called, module would be reset as it first puts to software supervised mode.And device reset would happen only upon enabling clock to module (if reset was deasserted) by
pm_runtime_get_sync(), so reset status has to be checked after pm call, preventing us havingdevice_reset()beforepm_runtime_get_sync(), or else in that case we have to sacrifice on reset status checking (which may not be reliable)
Quoted 4 lines
Another alternative would have been to integrate this reset handling in low level power management code thus hiding all reset handling from driver, but as far as I know the reset sequence to be done is sometimes IP specific, preventing it.
So if I understand correctly, the only problem is that on OMAP the clock needs to be enabled to deassert the reset, but as long as the clock domain is in hardware supervised mode, it won't be enabled? Would it be possible to create an internal API to switch the clock domain to software supervised mode, which can be used both by the code behind pm_runtime_get_sync and reset_control_deassert?
regards
Philipp
Hi Philipp,
Quoted 3 lines · Philipp Zabel
So if I understand correctly, the only problem is that on OMAP the clock needs to be enabled to deassert the reset, but as long as the clock domain is in hardware supervised mode, it won't be enabled?
Yes, enabling clock with reset deassertion might not reset the module if the clock domain is in hardware supervised mode.
Quoted 3 lines
Would it be possible to create an internal API to switch the clock domain to software supervised mode, which can be used both by the code behind
pm_runtime_get_syncandreset_control_deassert?
I will see if that is acceptable.
Another option that would have to be explored is invoking device_reset() (taking care of clear, deassert & status checking as you suggested) midway through pm_run_time_get_sync(), when the clockdomain is in software supervised mode with reset driver taking care of any particular sequence in the case of multiple reset signals, instead of the IP driver requiring to take care of it.
Regards
Afzal