diff mbox series

[13/13] clocksource/drivers/dw_apb: Add reset control

Message ID 1538750143-4282-13-git-send-email-daniel.lezcano@linaro.org
State Accepted
Commit 1f174a1a2cdebc65138e6ed1448b842e73200bb5
Headers show
Series [01/13] clocksource: Convert to using %pOFn instead of device_node.name | expand

Commit Message

Daniel Lezcano Oct. 5, 2018, 2:35 p.m. UTC
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(+)

-- 
2.7.4

Comments

Thomas Gleixner Oct. 6, 2018, 12:34 p.m. UTC | #1
On Fri, 5 Oct 2018, Daniel Lezcano wrote:

> 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>


Ingo just noticed, that this SOB chain is wrong. How is Marek involved
here? Can you please fix that up and send me another pull request?

Thanks,

	tglx
Daniel Lezcano Oct. 6, 2018, 5:02 p.m. UTC | #2
On 06/10/2018 14:34, Thomas Gleixner wrote:
> On Fri, 5 Oct 2018, Daniel Lezcano wrote:

> 

>> 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>

> 

> Ingo just noticed, that this SOB chain is wrong. How is Marek involved

> here? Can you please fix that up and send me another pull request?


Thomas,

I will fix it as soon as possible but I would like to give the
opportunity to Dinh to explain why he sent the patch with Marek's SOB.

Dinh ?


-- 
 <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
Thomas Gleixner Oct. 6, 2018, 5:07 p.m. UTC | #3
On Sat, 6 Oct 2018, Daniel Lezcano wrote:

> On 06/10/2018 14:34, Thomas Gleixner wrote:

> > On Fri, 5 Oct 2018, Daniel Lezcano wrote:

> > 

> >> 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>

> > 

> > Ingo just noticed, that this SOB chain is wrong. How is Marek involved

> > here? Can you please fix that up and send me another pull request?

> 

> Thomas,

> 

> I will fix it as soon as possible but I would like to give the

> opportunity to Dinh to explain why he sent the patch with Marek's SOB.

> 

> Dinh ?


No rush.
Marek Vasut Oct. 7, 2018, 12:10 p.m. UTC | #4
On 10/06/2018 07:07 PM, Thomas Gleixner wrote:
> On Sat, 6 Oct 2018, Daniel Lezcano wrote:

> 

>> On 06/10/2018 14:34, Thomas Gleixner wrote:

>>> On Fri, 5 Oct 2018, Daniel Lezcano wrote:

>>>

>>>> 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>

>>>

>>> Ingo just noticed, that this SOB chain is wrong. How is Marek involved

>>> here? Can you please fix that up and send me another pull request?

>>

>> Thomas,

>>

>> I will fix it as soon as possible but I would like to give the

>> opportunity to Dinh to explain why he sent the patch with Marek's SOB.

>>

>> Dinh ?

> 

> No rush.


I reported this to Dinh and gave him some prototype patches to start
with, since I didn't have the time to write a patch. You can change it
to Reported-by: if you want.

-- 
Best regards,
Marek Vasut
Daniel Lezcano Oct. 7, 2018, 12:16 p.m. UTC | #5
On 07/10/2018 14:10, Marek Vasut wrote:
> On 10/06/2018 07:07 PM, Thomas Gleixner wrote:

>> On Sat, 6 Oct 2018, Daniel Lezcano wrote:

>>

>>> On 06/10/2018 14:34, Thomas Gleixner wrote:

>>>> On Fri, 5 Oct 2018, Daniel Lezcano wrote:

>>>>

>>>>> 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>

>>>>

>>>> Ingo just noticed, that this SOB chain is wrong. How is Marek involved

>>>> here? Can you please fix that up and send me another pull request?

>>>

>>> Thomas,

>>>

>>> I will fix it as soon as possible but I would like to give the

>>> opportunity to Dinh to explain why he sent the patch with Marek's SOB.

>>>

>>> Dinh ?

>>

>> No rush.

> 

> I reported this to Dinh and gave him some prototype patches to start

> with, since I didn't have the time to write a patch. You can change it

> to Reported-by: if you want.


Ok, thanks


-- 
 <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
Thomas Gleixner Oct. 7, 2018, 8 p.m. UTC | #6
On Sun, 7 Oct 2018, Marek Vasut wrote:
> 

> I reported this to Dinh and gave him some prototype patches to start

> with, since I didn't have the time to write a patch. You can change it

> to Reported-by: if you want.


Marek, thanks for clarification!
diff mbox series

Patch

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
 	 */