* [PATCH v3: For next 1/2] reset_source: Add external reset
@ 2015-02-10 14:13 Wadim Egorov
2015-02-10 14:13 ` [PATCH v3: For next 2/2] ARM: am33xx: Add support for reset reason detection Wadim Egorov
0 siblings, 1 reply; 6+ messages in thread
From: Wadim Egorov @ 2015-02-10 14:13 UTC (permalink / raw)
To: barebox
Some SoCs have special device pins for external reset signals.
Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
---
common/reset_source.c | 1 +
include/reset_source.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/common/reset_source.c b/common/reset_source.c
index 946670b..ae2f9f3 100644
--- a/common/reset_source.c
+++ b/common/reset_source.c
@@ -26,6 +26,7 @@ static const char * const reset_src_names[] = {
[RESET_WKE] = "WKE",
[RESET_JTAG] = "JTAG",
[RESET_THERM] = "THERM",
+ [RESET_EXT] = "EXT",
};
static enum reset_src_type reset_source;
diff --git a/include/reset_source.h b/include/reset_source.h
index 6620228..367f93b 100644
--- a/include/reset_source.h
+++ b/include/reset_source.h
@@ -21,6 +21,7 @@ enum reset_src_type {
RESET_WKE, /* wake-up (some SoCs can handle this) */
RESET_JTAG, /* JTAG reset */
RESET_THERM, /* SoC shut down because of overtemperature */
+ RESET_EXT, /* External reset through device pin */
};
#ifdef CONFIG_RESET_SOURCE
--
1.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3: For next 2/2] ARM: am33xx: Add support for reset reason detection
2015-02-10 14:13 [PATCH v3: For next 1/2] reset_source: Add external reset Wadim Egorov
@ 2015-02-10 14:13 ` Wadim Egorov
2015-02-11 7:39 ` Sascha Hauer
0 siblings, 1 reply; 6+ messages in thread
From: Wadim Egorov @ 2015-02-10 14:13 UTC (permalink / raw)
To: barebox
Also activate in defconfig.
Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
---
v3: Remove init wrapper
---
arch/arm/configs/am335x_defconfig | 1 +
arch/arm/mach-omap/am33xx_generic.c | 39 ++++++++++++++++++++++++
arch/arm/mach-omap/include/mach/am33xx-silicon.h | 1 +
3 files changed, 41 insertions(+)
diff --git a/arch/arm/configs/am335x_defconfig b/arch/arm/configs/am335x_defconfig
index f34a4c6..0b8f58d 100644
--- a/arch/arm/configs/am335x_defconfig
+++ b/arch/arm/configs/am335x_defconfig
@@ -24,6 +24,7 @@ CONFIG_MENU=y
CONFIG_BLSPEC=y
CONFIG_CONSOLE_ACTIVATE_NONE=y
CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
+CONFIG_RESET_SOURCE=y
CONFIG_DEBUG_INFO=y
CONFIG_LONGHELP=y
CONFIG_CMD_IOMEM=y
diff --git a/arch/arm/mach-omap/am33xx_generic.c b/arch/arm/mach-omap/am33xx_generic.c
index 912138d..21e1bd1 100644
--- a/arch/arm/mach-omap/am33xx_generic.c
+++ b/arch/arm/mach-omap/am33xx_generic.c
@@ -26,6 +26,7 @@
#include <mach/sys_info.h>
#include <mach/am33xx-generic.h>
#include <mach/gpmc.h>
+#include <reset_source.h>
void __noreturn am33xx_reset_cpu(unsigned long addr)
{
@@ -152,6 +153,44 @@ static int am33xx_bootsource(void)
return 0;
}
+static int am33xx_detect_reset_reason(void)
+{
+ uint32_t val = 0;
+
+ if (!IS_ENABLED(CONFIG_RESET_SOURCE))
+ return 0;
+
+ val = readl(AM33XX_PRM_RSTST);
+ /* clear AM33XX_PRM_RSTST - must be cleared by software
+ * (warm reset insensitive) */
+ writel(val, AM33XX_PRM_RSTST);
+
+ switch (val) {
+ case (1 << 9):
+ reset_source_set(RESET_JTAG);
+ break;
+ case (1 << 5):
+ reset_source_set(RESET_EXT);
+ break;
+ case (1 << 4):
+ case (1 << 3):
+ reset_source_set(RESET_WDG);
+ break;
+ case (1 << 1):
+ reset_source_set(RESET_RST);
+ break;
+ case (1 << 0):
+ reset_source_set(RESET_POR);
+ break;
+ default:
+ reset_source_set(RESET_UKWN);
+ break;
+ }
+
+ return 0;
+}
+device_initcall(am33xx_detect_reset_reason);
+
int am33xx_register_ethaddr(int eth_id, int mac_id)
{
void __iomem *mac_id_low = (void *)AM33XX_MAC_ID0_LO + mac_id * 8;
diff --git a/arch/arm/mach-omap/include/mach/am33xx-silicon.h b/arch/arm/mach-omap/include/mach/am33xx-silicon.h
index 4e63b43..7c209ec 100644
--- a/arch/arm/mach-omap/include/mach/am33xx-silicon.h
+++ b/arch/arm/mach-omap/include/mach/am33xx-silicon.h
@@ -68,6 +68,7 @@
#define AM33XX_PRM_RSTCTRL (AM33XX_PRM_BASE + 0x0f00)
#define AM33XX_PRM_RSTCTRL_RESET 0x1
+#define AM33XX_PRM_RSTST (AM33XX_PRM_BASE + 0x0f08)
/* CTRL */
#define AM33XX_CTRL_BASE (AM33XX_L4_WKUP_BASE + 0x210000)
--
1.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3: For next 2/2] ARM: am33xx: Add support for reset reason detection
2015-02-10 14:13 ` [PATCH v3: For next 2/2] ARM: am33xx: Add support for reset reason detection Wadim Egorov
@ 2015-02-11 7:39 ` Sascha Hauer
2015-02-11 9:57 ` Wadim Egorov
0 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2015-02-11 7:39 UTC (permalink / raw)
To: Wadim Egorov; +Cc: barebox
On Tue, Feb 10, 2015 at 03:13:58PM +0100, Wadim Egorov wrote:
> Also activate in defconfig.
>
> Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
> + break;
> + case (1 << 1):
> + reset_source_set(RESET_RST);
> + break;
> + case (1 << 0):
> + reset_source_set(RESET_POR);
> + break;
> + default:
> + reset_source_set(RESET_UKWN);
> + break;
> + }
> +
> + return 0;
> +}
> +device_initcall(am33xx_detect_reset_reason);
No SoC specific initcall without testing if you're running on the
correct SoC please. Better call it from am33xx_init() which is only
executed on am33xx.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3: For next 2/2] ARM: am33xx: Add support for reset reason detection
2015-02-11 7:39 ` Sascha Hauer
@ 2015-02-11 9:57 ` Wadim Egorov
2015-02-12 8:30 ` Sascha Hauer
0 siblings, 1 reply; 6+ messages in thread
From: Wadim Egorov @ 2015-02-11 9:57 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On 11.02.2015 08:39, Sascha Hauer wrote:
> On Tue, Feb 10, 2015 at 03:13:58PM +0100, Wadim Egorov wrote:
>> Also activate in defconfig.
>>
>> Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
>> + break;
>> + case (1 << 1):
>> + reset_source_set(RESET_RST);
>> + break;
>> + case (1 << 0):
>> + reset_source_set(RESET_POR);
>> + break;
>> + default:
>> + reset_source_set(RESET_UKWN);
>> + break;
>> + }
>> +
>> + return 0;
>> +}
>> +device_initcall(am33xx_detect_reset_reason);
> No SoC specific initcall without testing if you're running on the
> correct SoC please. Better call it from am33xx_init() which is only
> executed on am33xx.
>
> Sascha
Calling it from am33xx_init() was also my idea in the first place.
AFAIK you have to call reset_source_set() after coredevice_initcall().
So it is not possible to call it from am33xx_init().
But I can do a cpu check within am33xx_detect_reset_reason() and
cancel the detection if it is not an am335.
>
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3: For next 2/2] ARM: am33xx: Add support for reset reason detection
2015-02-11 9:57 ` Wadim Egorov
@ 2015-02-12 8:30 ` Sascha Hauer
2015-02-12 9:03 ` Wadim Egorov
0 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2015-02-12 8:30 UTC (permalink / raw)
To: Wadim Egorov; +Cc: barebox
On Wed, Feb 11, 2015 at 10:57:50AM +0100, Wadim Egorov wrote:
>
> On 11.02.2015 08:39, Sascha Hauer wrote:
> >On Tue, Feb 10, 2015 at 03:13:58PM +0100, Wadim Egorov wrote:
> >>Also activate in defconfig.
> >>
> >>Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
> >>+ break;
> >>+ case (1 << 1):
> >>+ reset_source_set(RESET_RST);
> >>+ break;
> >>+ case (1 << 0):
> >>+ reset_source_set(RESET_POR);
> >>+ break;
> >>+ default:
> >>+ reset_source_set(RESET_UKWN);
> >>+ break;
> >>+ }
> >>+
> >>+ return 0;
> >>+}
> >>+device_initcall(am33xx_detect_reset_reason);
> >No SoC specific initcall without testing if you're running on the
> >correct SoC please. Better call it from am33xx_init() which is only
> >executed on am33xx.
> >
> >Sascha
> Calling it from am33xx_init() was also my idea in the first place.
> AFAIK you have to call reset_source_set() after coredevice_initcall().
> So it is not possible to call it from am33xx_init().
Could you try this patch? It shoud resolve this issue.
Sascha
------------------------8<---------------------------------
From a6efde9c06046111cfe2ad92bb38430674a893b7 Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Thu, 12 Feb 2015 09:27:35 +0100
Subject: [PATCH] reset_source: make safe to call earlier
reset_source_init used to set the reset source to unknown in a
coredevice_initcall. This means if reset_source_set() has been called
earlier the value would have been overwritten. Fix this by calling
globalvar_add_simple() each time reset_source_set() is called.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/reset_source.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/common/reset_source.c b/common/reset_source.c
index 946670b..0147b5c 100644
--- a/common/reset_source.c
+++ b/common/reset_source.c
@@ -40,14 +40,14 @@ void reset_source_set(enum reset_src_type st)
{
reset_source = st;
- setenv("global.system.reset", reset_src_names[st]);
+ globalvar_add_simple("system.reset", reset_src_names[reset_source]);
}
EXPORT_SYMBOL(reset_source_set);
/* ensure this runs after the 'global' device is already registerd */
static int reset_source_init(void)
{
- globalvar_add_simple("system.reset", reset_src_names[RESET_UKWN]);
+ reset_source_set(reset_source);
return 0;
}
--
2.1.4
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3: For next 2/2] ARM: am33xx: Add support for reset reason detection
2015-02-12 8:30 ` Sascha Hauer
@ 2015-02-12 9:03 ` Wadim Egorov
0 siblings, 0 replies; 6+ messages in thread
From: Wadim Egorov @ 2015-02-12 9:03 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On 12.02.2015 09:30, Sascha Hauer wrote:
> On Wed, Feb 11, 2015 at 10:57:50AM +0100, Wadim Egorov wrote:
>> On 11.02.2015 08:39, Sascha Hauer wrote:
>>> On Tue, Feb 10, 2015 at 03:13:58PM +0100, Wadim Egorov wrote:
>>>> Also activate in defconfig.
>>>>
>>>> Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
>>>> + break;
>>>> + case (1 << 1):
>>>> + reset_source_set(RESET_RST);
>>>> + break;
>>>> + case (1 << 0):
>>>> + reset_source_set(RESET_POR);
>>>> + break;
>>>> + default:
>>>> + reset_source_set(RESET_UKWN);
>>>> + break;
>>>> + }
>>>> +
>>>> + return 0;
>>>> +}
>>>> +device_initcall(am33xx_detect_reset_reason);
>>> No SoC specific initcall without testing if you're running on the
>>> correct SoC please. Better call it from am33xx_init() which is only
>>> executed on am33xx.
>>>
>>> Sascha
>> Calling it from am33xx_init() was also my idea in the first place.
>> AFAIK you have to call reset_source_set() after coredevice_initcall().
>> So it is not possible to call it from am33xx_init().
> Could you try this patch? It shoud resolve this issue.
>
> Sascha
It works with your changes. I will send a v4 later.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-02-12 9:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-10 14:13 [PATCH v3: For next 1/2] reset_source: Add external reset Wadim Egorov
2015-02-10 14:13 ` [PATCH v3: For next 2/2] ARM: am33xx: Add support for reset reason detection Wadim Egorov
2015-02-11 7:39 ` Sascha Hauer
2015-02-11 9:57 ` Wadim Egorov
2015-02-12 8:30 ` Sascha Hauer
2015-02-12 9:03 ` Wadim Egorov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox