* [U-Boot] [PATCH] ls102xa: Fix reset hang
@ 2015-10-02 13:25 Fabio Estevam
2015-10-02 14:21 ` Sinan Akman
2015-10-02 14:42 ` Wolfgang Denk
0 siblings, 2 replies; 11+ messages in thread
From: Fabio Estevam @ 2015-10-02 13:25 UTC (permalink / raw)
To: u-boot
From: Fabio Estevam <fabio.estevam@freescale.com>
Since commit 623d96e89aca6("imx: wdog: correct wcr register settings")
issuing a 'reset' command causes the system to hang.
Unlike i.MX and Vybrid, the watchdog controller on LS102x is big-endian.
This means that the watchdog on LS1021 has been working by accident as
it does not use the big-endian accessors in drivers/watchdog/imx_watchdog.c.
Commit 623d96e89aca6("imx: wdog: correct wcr register settings") only
revelead the endianness problem on LS102x.
In order to fix the reset hang, introduce a reset_cpu() implementation that
is specific for ls102x, which accesses the watchdog WCR register in big-endian
format. All that is required to reset LS102x is to clear the SRS bit.
Reported-by: Sinan Akman <sinan@writeme.com>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
arch/arm/cpu/armv7/ls102xa/cpu.c | 21 +++++++++++++++++++++
drivers/watchdog/Makefile | 2 +-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/arch/arm/cpu/armv7/ls102xa/cpu.c b/arch/arm/cpu/armv7/ls102xa/cpu.c
index 8dd95d9..0de6f19 100644
--- a/arch/arm/cpu/armv7/ls102xa/cpu.c
+++ b/arch/arm/cpu/armv7/ls102xa/cpu.c
@@ -13,6 +13,7 @@
#include <tsec.h>
#include <netdev.h>
#include <fsl_esdhc.h>
+#include <config.h>
#include "fsl_epu.h"
@@ -354,3 +355,23 @@ void smp_kick_all_cpus(void)
asm volatile("sev");
}
#endif
+
+struct watchdog_regs {
+ u16 wcr; /* Control */
+ u16 wsr; /* Service */
+ u16 wrsr; /* Reset Status */
+};
+
+#define WCR_SRS (1 << 4)
+void reset_cpu(ulong addr)
+{
+ struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;
+
+ clrbits_be16(&wdog->wcr, WCR_SRS);
+
+ while (1) {
+ /*
+ * Let the watchdog trigger
+ */
+ }
+}
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 9e9cb55..a007ae8 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -7,7 +7,7 @@
obj-$(CONFIG_AT91SAM9_WATCHDOG) += at91sam9_wdt.o
obj-$(CONFIG_FTWDT010_WATCHDOG) += ftwdt010_wdt.o
-ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610 ls102xa))
+ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610))
obj-y += imx_watchdog.o
endif
obj-$(CONFIG_S5P) += s5p_wdt.o
--
1.9.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH] ls102xa: Fix reset hang
2015-10-02 13:25 [U-Boot] [PATCH] ls102xa: Fix reset hang Fabio Estevam
@ 2015-10-02 14:21 ` Sinan Akman
2015-10-02 14:34 ` Fabio Estevam
2015-10-02 14:42 ` Wolfgang Denk
1 sibling, 1 reply; 11+ messages in thread
From: Sinan Akman @ 2015-10-02 14:21 UTC (permalink / raw)
To: u-boot
Hi Fabio
On 02/10/15 09:25 AM, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> Since commit 623d96e89aca6("imx: wdog: correct wcr register settings")
> issuing a 'reset' command causes the system to hang.
>
> Unlike i.MX and Vybrid, the watchdog controller on LS102x is big-endian.
>
> This means that the watchdog on LS1021 has been working by accident as
> it does not use the big-endian accessors in drivers/watchdog/imx_watchdog.c.
> Commit 623d96e89aca6("imx: wdog: correct wcr register settings") only
> revelead the endianness problem on LS102x.
>
> In order to fix the reset hang, introduce a reset_cpu() implementation that
> is specific for ls102x, which accesses the watchdog WCR register in big-endian
> format. All that is required to reset LS102x is to clear the SRS bit.
>
> Reported-by: Sinan Akman <sinan@writeme.com>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> arch/arm/cpu/armv7/ls102xa/cpu.c | 21 +++++++++++++++++++++
> drivers/watchdog/Makefile | 2 +-
> 2 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/cpu/armv7/ls102xa/cpu.c b/arch/arm/cpu/armv7/ls102xa/cpu.c
> index 8dd95d9..0de6f19 100644
> --- a/arch/arm/cpu/armv7/ls102xa/cpu.c
> +++ b/arch/arm/cpu/armv7/ls102xa/cpu.c
> @@ -13,6 +13,7 @@
> #include <tsec.h>
> #include <netdev.h>
> #include <fsl_esdhc.h>
> +#include <config.h>
>
> #include "fsl_epu.h"
>
> @@ -354,3 +355,23 @@ void smp_kick_all_cpus(void)
> asm volatile("sev");
> }
> #endif
> +
> +struct watchdog_regs {
> + u16 wcr; /* Control */
> + u16 wsr; /* Service */
> + u16 wrsr; /* Reset Status */
> +};
> +
> +#define WCR_SRS (1 << 4)
> +void reset_cpu(ulong addr)
> +{
> + struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;
> +
> + clrbits_be16(&wdog->wcr, WCR_SRS);
> +
> + while (1) {
> + /*
> + * Let the watchdog trigger
> + */
> + }
> +}
> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> index 9e9cb55..a007ae8 100644
> --- a/drivers/watchdog/Makefile
> +++ b/drivers/watchdog/Makefile
> @@ -7,7 +7,7 @@
>
> obj-$(CONFIG_AT91SAM9_WATCHDOG) += at91sam9_wdt.o
> obj-$(CONFIG_FTWDT010_WATCHDOG) += ftwdt010_wdt.o
> -ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610 ls102xa))
> +ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610))
> obj-y += imx_watchdog.o
> endif
> obj-$(CONFIG_S5P) += s5p_wdt.o
Tested-by: Sinan Akman <sinan@writeme.com>
Regards
Sinan Akman
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH] ls102xa: Fix reset hang
2015-10-02 14:21 ` Sinan Akman
@ 2015-10-02 14:34 ` Fabio Estevam
2015-10-02 14:55 ` Sinan Akman
0 siblings, 1 reply; 11+ messages in thread
From: Fabio Estevam @ 2015-10-02 14:34 UTC (permalink / raw)
To: u-boot
On Fri, Oct 2, 2015 at 11:21 AM, Sinan Akman <sinan@writeme.com> wrote:
> Tested-by: Sinan Akman <sinan@writeme.com>
Thanks a lot for your help, Sinan!
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH] ls102xa: Fix reset hang
2015-10-02 13:25 [U-Boot] [PATCH] ls102xa: Fix reset hang Fabio Estevam
2015-10-02 14:21 ` Sinan Akman
@ 2015-10-02 14:42 ` Wolfgang Denk
2015-10-02 14:51 ` Sinan Akman
` (2 more replies)
1 sibling, 3 replies; 11+ messages in thread
From: Wolfgang Denk @ 2015-10-02 14:42 UTC (permalink / raw)
To: u-boot
Dear Fabio,
In message <1443792315-18997-1-git-send-email-festevam@gmail.com> you wrote:
>
...
> Unlike i.MX and Vybrid, the watchdog controller on LS102x is big-endian.
...
> +struct watchdog_regs {
> + u16 wcr; /* Control */
> + u16 wsr; /* Service */
> + u16 wrsr; /* Reset Status */
> +};
> +
> +#define WCR_SRS (1 << 4)
This belongs to some watchdog (or processor) related header file.
As is, it duplicates code from drivers/watchdog/imx_watchdog.c which
is something we should not do.
> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> index 9e9cb55..a007ae8 100644
> --- a/drivers/watchdog/Makefile
> +++ b/drivers/watchdog/Makefile
> @@ -7,7 +7,7 @@
>
> obj-$(CONFIG_AT91SAM9_WATCHDOG) += at91sam9_wdt.o
> obj-$(CONFIG_FTWDT010_WATCHDOG) += ftwdt010_wdt.o
> -ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610 ls102xa))
> +ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610))
So this fixes the reset problem for now - but what happens when
someone wants to use the watchdog for real? Will we create a copy of
drivers/watchdog/imx_watchdog.c using big-endian accessors? This
cannot be right?
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The only person who always got his work done by Friday
was Robinson Crusoe.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH] ls102xa: Fix reset hang
2015-10-02 14:42 ` Wolfgang Denk
@ 2015-10-02 14:51 ` Sinan Akman
2015-10-02 15:00 ` Fabio Estevam
2015-10-03 15:18 ` Tom Rini
2 siblings, 0 replies; 11+ messages in thread
From: Sinan Akman @ 2015-10-02 14:51 UTC (permalink / raw)
To: u-boot
Hi Wolfgang
On 02/10/15 10:42 AM, Wolfgang Denk wrote:
> Dear Fabio,
>
> In message <1443792315-18997-1-git-send-email-festevam@gmail.com> you wrote:
> ...
>> Unlike i.MX and Vybrid, the watchdog controller on LS102x is big-endian.
> ...
>> +struct watchdog_regs {
>> + u16 wcr; /* Control */
>> + u16 wsr; /* Service */
>> + u16 wrsr; /* Reset Status */
>> +};
>> +
>> +#define WCR_SRS (1 << 4)
> This belongs to some watchdog (or processor) related header file.
>
> As is, it duplicates code from drivers/watchdog/imx_watchdog.c which
> is something we should not do.
>
>> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
>> index 9e9cb55..a007ae8 100644
>> --- a/drivers/watchdog/Makefile
>> +++ b/drivers/watchdog/Makefile
>> @@ -7,7 +7,7 @@
>>
>> obj-$(CONFIG_AT91SAM9_WATCHDOG) += at91sam9_wdt.o
>> obj-$(CONFIG_FTWDT010_WATCHDOG) += ftwdt010_wdt.o
>> -ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610 ls102xa))
>> +ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610))
> So this fixes the reset problem for now - but what happens when
> someone wants to use the watchdog for real? Will we create a copy of
> drivers/watchdog/imx_watchdog.c using big-endian accessors? This
> cannot be right?
I don't know if you've seen my earlier e-mail on this but I was
suggesting
to bring watchdog to DM and then consider endian type from dts to implement
it properly. Would this not ultimately be the right solution ?
Regards
Sinan Akman
>
> Best regards,
>
> Wolfgang Denk
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH] ls102xa: Fix reset hang
2015-10-02 14:34 ` Fabio Estevam
@ 2015-10-02 14:55 ` Sinan Akman
0 siblings, 0 replies; 11+ messages in thread
From: Sinan Akman @ 2015-10-02 14:55 UTC (permalink / raw)
To: u-boot
On 02/10/15 10:34 AM, Fabio Estevam wrote:
> On Fri, Oct 2, 2015 at 11:21 AM, Sinan Akman <sinan@writeme.com> wrote:
>
>> Tested-by: Sinan Akman <sinan@writeme.com>
> Thanks a lot for your help, Sinan!
You are very welcome Fabio. Let's take a cleaner look
at this for 2016.01 to consider all the mixed endian type
peripheral blocks.
Regards
Sinan Akman
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH] ls102xa: Fix reset hang
2015-10-02 14:42 ` Wolfgang Denk
2015-10-02 14:51 ` Sinan Akman
@ 2015-10-02 15:00 ` Fabio Estevam
2015-10-03 15:18 ` Tom Rini
2 siblings, 0 replies; 11+ messages in thread
From: Fabio Estevam @ 2015-10-02 15:00 UTC (permalink / raw)
To: u-boot
On Fri, Oct 2, 2015 at 11:42 AM, Wolfgang Denk <wd@denx.de> wrote:
> So this fixes the reset problem for now - but what happens when
> someone wants to use the watchdog for real? Will we create a copy of
> drivers/watchdog/imx_watchdog.c using big-endian accessors? This
> cannot be right?
If someone wants to use the watchdog for real on LS102x then this is a
new feature that needs to be properly implemented.
In the kernel we have a common watchdog driver for i.MX, Vybrid and
LS, which uses regmap and take the endianness into consideration. We
should make drivers/watchdog/imx_watchdog.c endianness-aware so that
it can work for all these different SoCs. I was not suggesting to
create a new copy of drivers/watchdog/imx_watchdog.c.
Regards,
Fabio Estevam
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH] ls102xa: Fix reset hang
2015-10-02 14:42 ` Wolfgang Denk
2015-10-02 14:51 ` Sinan Akman
2015-10-02 15:00 ` Fabio Estevam
@ 2015-10-03 15:18 ` Tom Rini
2015-10-07 21:43 ` Fabio Estevam
2 siblings, 1 reply; 11+ messages in thread
From: Tom Rini @ 2015-10-03 15:18 UTC (permalink / raw)
To: u-boot
On Fri, Oct 02, 2015 at 04:42:14PM +0200, Wolfgang Denk wrote:
> Dear Fabio,
>
> In message <1443792315-18997-1-git-send-email-festevam@gmail.com> you wrote:
> >
> ...
> > Unlike i.MX and Vybrid, the watchdog controller on LS102x is big-endian.
> ...
> > +struct watchdog_regs {
> > + u16 wcr; /* Control */
> > + u16 wsr; /* Service */
> > + u16 wrsr; /* Reset Status */
> > +};
> > +
> > +#define WCR_SRS (1 << 4)
>
> This belongs to some watchdog (or processor) related header file.
>
> As is, it duplicates code from drivers/watchdog/imx_watchdog.c which
> is something we should not do.
>
> > diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> > index 9e9cb55..a007ae8 100644
> > --- a/drivers/watchdog/Makefile
> > +++ b/drivers/watchdog/Makefile
> > @@ -7,7 +7,7 @@
> >
> > obj-$(CONFIG_AT91SAM9_WATCHDOG) += at91sam9_wdt.o
> > obj-$(CONFIG_FTWDT010_WATCHDOG) += ftwdt010_wdt.o
> > -ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610 ls102xa))
> > +ifneq (,$(filter $(SOC), mx31 mx35 mx5 mx6 mx7 vf610))
>
> So this fixes the reset problem for now - but what happens when
> someone wants to use the watchdog for real? Will we create a copy of
> drivers/watchdog/imx_watchdog.c using big-endian accessors? This
> cannot be right?
Fabio, can you do a v2 that makes the commit message a bit clearer that
this is a temporary work-around and that a proper solution to the
underlying problem is coming? I think everyone that's reading this
thread knows this but we should make it clear to someone that just picks
up the code / commit (so maybe a comment block too) that we're making
things non-broken for the release but that's not the same thing as
making it correct for the long term. Thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151003/8d2a2e20/attachment-0001.sig>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH] ls102xa: Fix reset hang
2015-10-03 15:18 ` Tom Rini
@ 2015-10-07 21:43 ` Fabio Estevam
2015-10-07 21:45 ` York Sun
0 siblings, 1 reply; 11+ messages in thread
From: Fabio Estevam @ 2015-10-07 21:43 UTC (permalink / raw)
To: u-boot
On Sat, Oct 3, 2015 at 12:18 PM, Tom Rini <trini@konsulko.com> wrote:
> Fabio, can you do a v2 that makes the commit message a bit clearer that
> this is a temporary work-around and that a proper solution to the
> underlying problem is coming? I think everyone that's reading this
> thread knows this but we should make it clear to someone that just picks
> up the code / commit (so maybe a comment block too) that we're making
> things non-broken for the release but that's not the same thing as
> making it correct for the long term. Thanks!
Did as suggested in v3.
Into which tree will the patch go in: Yours or York's?
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH] ls102xa: Fix reset hang
2015-10-07 21:43 ` Fabio Estevam
@ 2015-10-07 21:45 ` York Sun
2015-10-07 21:47 ` Fabio Estevam
0 siblings, 1 reply; 11+ messages in thread
From: York Sun @ 2015-10-07 21:45 UTC (permalink / raw)
To: u-boot
On 10/07/2015 02:43 PM, Fabio Estevam wrote:
> On Sat, Oct 3, 2015 at 12:18 PM, Tom Rini <trini@konsulko.com> wrote:
>
>> Fabio, can you do a v2 that makes the commit message a bit clearer that
>> this is a temporary work-around and that a proper solution to the
>> underlying problem is coming? I think everyone that's reading this
>> thread knows this but we should make it clear to someone that just picks
>> up the code / commit (so maybe a comment block too) that we're making
>> things non-broken for the release but that's not the same thing as
>> making it correct for the long term. Thanks!
>
> Did as suggested in v3.
>
> Into which tree will the patch go in: Yours or York's?
>
Please use master, or Tom's tree. My tree is behind and I only update before
requesting a pull.
York
^ permalink raw reply [flat|nested] 11+ messages in thread
* [U-Boot] [PATCH] ls102xa: Fix reset hang
2015-10-07 21:45 ` York Sun
@ 2015-10-07 21:47 ` Fabio Estevam
0 siblings, 0 replies; 11+ messages in thread
From: Fabio Estevam @ 2015-10-07 21:47 UTC (permalink / raw)
To: u-boot
On Wed, Oct 7, 2015 at 6:45 PM, York Sun <yorksun@freescale.com> wrote:
> Please use master, or Tom's tree. My tree is behind and I only update before
> requesting a pull.
I generated the patches against master, so Tom should be able to apply
them cleanly.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-10-07 21:47 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-02 13:25 [U-Boot] [PATCH] ls102xa: Fix reset hang Fabio Estevam
2015-10-02 14:21 ` Sinan Akman
2015-10-02 14:34 ` Fabio Estevam
2015-10-02 14:55 ` Sinan Akman
2015-10-02 14:42 ` Wolfgang Denk
2015-10-02 14:51 ` Sinan Akman
2015-10-02 15:00 ` Fabio Estevam
2015-10-03 15:18 ` Tom Rini
2015-10-07 21:43 ` Fabio Estevam
2015-10-07 21:45 ` York Sun
2015-10-07 21:47 ` Fabio Estevam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox