All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clocksource: dw_apb: add reset control
@ 2018-09-17 14:52 Dinh Nguyen
  2018-09-26 13:42 ` Dinh Nguyen
  2018-09-26 15:21 ` Daniel Lezcano
  0 siblings, 2 replies; 7+ messages in thread
From: Dinh Nguyen @ 2018-09-17 14:52 UTC (permalink / raw)
  To: daniel.lezcano; +Cc: dinguyen, tglx, linux-kernel, Marek Vasut

Add code to retrieve the reset property for the dw-apb timers.

Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
---
 drivers/clocksource/dw_apb_timer_of.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/clocksource/dw_apb_timer_of.c b/drivers/clocksource/dw_apb_timer_of.c
index 69866cd..24bc073 100644
--- a/drivers/clocksource/dw_apb_timer_of.c
+++ b/drivers/clocksource/dw_apb_timer_of.c
@@ -22,6 +22,7 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/clk.h>
+#include <linux/reset.h>
 #include <linux/sched_clock.h>
 
 static void __init timer_get_base_and_rate(struct device_node *np,
@@ -29,12 +30,20 @@ static void __init timer_get_base_and_rate(struct device_node *np,
 {
 	struct clk *timer_clk;
 	struct clk *pclk;
+	struct reset_control *rstc;
 
 	*base = of_iomap(np, 0);
 
 	if (!*base)
 		panic("Unable to map regs for %s", np->name);
 
+	/* Unreset the timer if applicable */
+	rstc = of_reset_control_get(np, NULL);
+	if (!IS_ERR(rstc)) {
+		reset_control_assert(rstc);
+		reset_control_deassert(rstc);
+	}
+
 	/*
 	 * Not all implementations use a periphal clock, so don't panic
 	 * if it's not present
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] clocksource: dw_apb: add reset control
  2018-09-17 14:52 [PATCH] clocksource: dw_apb: add reset control Dinh Nguyen
@ 2018-09-26 13:42 ` Dinh Nguyen
  2018-09-26 15:21 ` Daniel Lezcano
  1 sibling, 0 replies; 7+ messages in thread
From: Dinh Nguyen @ 2018-09-26 13:42 UTC (permalink / raw)
  To: daniel.lezcano; +Cc: tglx, linux-kernel, Marek Vasut

Ping?

On 09/17/2018 09:52 AM, Dinh Nguyen wrote:
> Add code to retrieve the reset property for the dw-apb timers.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
> ---
>  drivers/clocksource/dw_apb_timer_of.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/clocksource/dw_apb_timer_of.c b/drivers/clocksource/dw_apb_timer_of.c
> index 69866cd..24bc073 100644
> --- a/drivers/clocksource/dw_apb_timer_of.c
> +++ b/drivers/clocksource/dw_apb_timer_of.c
> @@ -22,6 +22,7 @@
>  #include <linux/of_address.h>
>  #include <linux/of_irq.h>
>  #include <linux/clk.h>
> +#include <linux/reset.h>
>  #include <linux/sched_clock.h>
>  
>  static void __init timer_get_base_and_rate(struct device_node *np,
> @@ -29,12 +30,20 @@ static void __init timer_get_base_and_rate(struct device_node *np,
>  {
>  	struct clk *timer_clk;
>  	struct clk *pclk;
> +	struct reset_control *rstc;
>  
>  	*base = of_iomap(np, 0);
>  
>  	if (!*base)
>  		panic("Unable to map regs for %s", np->name);
>  
> +	/* Unreset the timer if applicable */
> +	rstc = of_reset_control_get(np, NULL);
> +	if (!IS_ERR(rstc)) {
> +		reset_control_assert(rstc);
> +		reset_control_deassert(rstc);
> +	}
> +
>  	/*
>  	 * Not all implementations use a periphal clock, so don't panic
>  	 * if it's not present
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] clocksource: dw_apb: add reset control
  2018-09-17 14:52 [PATCH] clocksource: dw_apb: add reset control Dinh Nguyen
  2018-09-26 13:42 ` Dinh Nguyen
@ 2018-09-26 15:21 ` Daniel Lezcano
  2018-09-27 13:52   ` Dinh Nguyen
  1 sibling, 1 reply; 7+ messages in thread
From: Daniel Lezcano @ 2018-09-26 15:21 UTC (permalink / raw)
  To: Dinh Nguyen; +Cc: tglx, linux-kernel, Marek Vasut

On 17/09/2018 16:52, Dinh Nguyen wrote:
> Add code to retrieve the reset property for the dw-apb timers.

The patch does more than that. Can you explain why the assert/deassert ?


> Signed-off-by: Marek Vasut <marex@denx.de>
> Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
> ---
>  drivers/clocksource/dw_apb_timer_of.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/clocksource/dw_apb_timer_of.c b/drivers/clocksource/dw_apb_timer_of.c
> index 69866cd..24bc073 100644
> --- a/drivers/clocksource/dw_apb_timer_of.c
> +++ b/drivers/clocksource/dw_apb_timer_of.c
> @@ -22,6 +22,7 @@
>  #include <linux/of_address.h>
>  #include <linux/of_irq.h>
>  #include <linux/clk.h>
> +#include <linux/reset.h>
>  #include <linux/sched_clock.h>
>  
>  static void __init timer_get_base_and_rate(struct device_node *np,
> @@ -29,12 +30,20 @@ static void __init timer_get_base_and_rate(struct device_node *np,
>  {
>  	struct clk *timer_clk;
>  	struct clk *pclk;
> +	struct reset_control *rstc;
>  
>  	*base = of_iomap(np, 0);
>  
>  	if (!*base)
>  		panic("Unable to map regs for %s", np->name);
>  
> +	/* Unreset the timer if applicable */
> +	rstc = of_reset_control_get(np, NULL);
> +	if (!IS_ERR(rstc)) {
> +		reset_control_assert(rstc);
> +		reset_control_deassert(rstc);
> +	}
> +
>  	/*
>  	 * Not all implementations use a periphal clock, so don't panic
>  	 * if it's not present
> 


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] clocksource: dw_apb: add reset control
  2018-09-26 15:21 ` Daniel Lezcano
@ 2018-09-27 13:52   ` Dinh Nguyen
  2018-09-27 14:22     ` Daniel Lezcano
  0 siblings, 1 reply; 7+ messages in thread
From: Dinh Nguyen @ 2018-09-27 13:52 UTC (permalink / raw)
  To: Daniel Lezcano; +Cc: tglx, linux-kernel, Marek Vasut



On 09/26/2018 10:21 AM, Daniel Lezcano wrote:
> On 17/09/2018 16:52, Dinh Nguyen wrote:
>> Add code to retrieve the reset property for the dw-apb timers.
> 
> The patch does more than that. Can you explain why the assert/deassert ?

Can I update the commit message to this?

Add code to retrieve the reset property from the dw-apb timers and if
the property is available, the safe operation is to assert the timer
into reset, and followed by a deassert of the timer reset(brings the
timer out of reset).

This patch is needed for systems where the bootloader has left the timer
not used in reset.

Dinh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] clocksource: dw_apb: add reset control
  2018-09-27 13:52   ` Dinh Nguyen
@ 2018-09-27 14:22     ` Daniel Lezcano
  2018-09-27 14:22       ` [PATCH] clocksource/drivers/dw_apb: Add " Daniel Lezcano
  2018-09-27 14:32       ` [PATCH] clocksource: dw_apb: add " Dinh Nguyen
  0 siblings, 2 replies; 7+ messages in thread
From: Daniel Lezcano @ 2018-09-27 14:22 UTC (permalink / raw)
  To: Dinh Nguyen; +Cc: tglx, linux-kernel, Marek Vasut

On 27/09/2018 15:52, Dinh Nguyen wrote:
> Add code to retrieve the reset property from the dw-apb timers and if
> the property is available, the safe operation is to assert the timer
> into reset, and followed by a deassert of the timer reset(brings the
> timer out of reset).
> 
> This patch is needed for systems where the bootloader has left the timer
> not used in reset.

Ok, I have updated the commit log.

I had to fix a trivial conflict. Let me know if you are all right with
the change.

  -- Daniel

-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] clocksource/drivers/dw_apb: Add reset control
  2018-09-27 14:22     ` Daniel Lezcano
@ 2018-09-27 14:22       ` Daniel Lezcano
  2018-09-27 14:32       ` [PATCH] clocksource: dw_apb: add " Dinh Nguyen
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Lezcano @ 2018-09-27 14:22 UTC (permalink / raw)
  To: dinguyen; +Cc: tglx, marex, open list:CLOCKSOURCE, CLOCKEVENT DRIVERS

From: Dinh Nguyen <dinguyen@kernel.org>

Add code to retrieve the reset property from the dw-apb timers and if
the property is available, the safe operation is to assert the timer
into reset, and followed by a deassert of the timer reset (brings the
timer out of reset).

This patch is needed for systems where the bootloader has left the timer
not used in reset.

 - Trivial conflict with commit a74bd1ad7a:
    "Convert to using %pOFn instead of device_node.name"

Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/clocksource/dw_apb_timer_of.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/clocksource/dw_apb_timer_of.c b/drivers/clocksource/dw_apb_timer_of.c
index fabaa29..db410ac 100644
--- a/drivers/clocksource/dw_apb_timer_of.c
+++ b/drivers/clocksource/dw_apb_timer_of.c
@@ -22,6 +22,7 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/clk.h>
+#include <linux/reset.h>
 #include <linux/sched_clock.h>
 
 static void __init timer_get_base_and_rate(struct device_node *np,
@@ -29,6 +30,7 @@ static void __init timer_get_base_and_rate(struct device_node *np,
 {
 	struct clk *timer_clk;
 	struct clk *pclk;
+	struct reset_control *rstc;
 
 	*base = of_iomap(np, 0);
 
@@ -36,6 +38,16 @@ static void __init timer_get_base_and_rate(struct device_node *np,
 		panic("Unable to map regs for %pOFn", np);
 
 	/*
+	 * Reset the timer if the reset control is available, wiping
+	 * out the state the firmware may have left it
+	 */
+	rstc = of_reset_control_get(np, NULL);
+	if (!IS_ERR(rstc)) {
+		reset_control_assert(rstc);
+		reset_control_deassert(rstc);
+	}
+
+	/*
 	 * Not all implementations use a periphal clock, so don't panic
 	 * if it's not present
 	 */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] clocksource: dw_apb: add reset control
  2018-09-27 14:22     ` Daniel Lezcano
  2018-09-27 14:22       ` [PATCH] clocksource/drivers/dw_apb: Add " Daniel Lezcano
@ 2018-09-27 14:32       ` Dinh Nguyen
  1 sibling, 0 replies; 7+ messages in thread
From: Dinh Nguyen @ 2018-09-27 14:32 UTC (permalink / raw)
  To: Daniel Lezcano; +Cc: tglx, linux-kernel, Marek Vasut



On 09/27/2018 09:22 AM, Daniel Lezcano wrote:
> On 27/09/2018 15:52, Dinh Nguyen wrote:
>> Add code to retrieve the reset property from the dw-apb timers and if
>> the property is available, the safe operation is to assert the timer
>> into reset, and followed by a deassert of the timer reset(brings the
>> timer out of reset).
>>
>> This patch is needed for systems where the bootloader has left the timer
>> not used in reset.
> 
> Ok, I have updated the commit log.
> 
> I had to fix a trivial conflict. Let me know if you are all right with
> the change.
> 

Thanks, I'm fine with the change.

Dinh

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-09-27 14:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-17 14:52 [PATCH] clocksource: dw_apb: add reset control Dinh Nguyen
2018-09-26 13:42 ` Dinh Nguyen
2018-09-26 15:21 ` Daniel Lezcano
2018-09-27 13:52   ` Dinh Nguyen
2018-09-27 14:22     ` Daniel Lezcano
2018-09-27 14:22       ` [PATCH] clocksource/drivers/dw_apb: Add " Daniel Lezcano
2018-09-27 14:32       ` [PATCH] clocksource: dw_apb: add " Dinh Nguyen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.