add wakup source
Subsystems (5)
v2 cover add wakup source
HI,
v2:
update against next
add wakeup source and amek power source human readable
The following changes since commit f0c7ee4201d56ec87c8b0deff3a481644a34bb9d:
Merge branch 'for-next-1/karo-tx53' into next (2012-10-13 14:24:49 +0200)
are available in the git repository at:
git://git.jcrosoft.org/barebox.git delivery/reset_source
for you to fetch changes up to f4d6ae60c34f1e01bf913e3b8166b478e1b55fb2:
at91: add reset and wakeup source detection support (2012-10-13 13:45:02 +0800)
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (4):
reset_source: make enum and string human readable
reset_source: add software reset as possible source
reset_resource: add wakeup source
at91: add reset and wakeup source detection support
arch/arm/mach-at91/Makefile | 1 + arch/arm/mach-at91/include/mach/at91_shdwc.h | 40 ++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-at91/reset_source.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-imx/imx1.c | 6 +++--- arch/arm/mach-samsung/reset_source.c | 6 +++--- common/reset_source.c | 32 +++++++++++++++++++++++++------- drivers/watchdog/im28wd.c | 6 +++--- drivers/watchdog/imxwd.c | 6 +++--- include/reset_source.h | 22 +++++++++++++++++----- 9 files changed, 154 insertions(+), 24 deletions(-) create mode 100644 arch/arm/mach-at91/include/mach/at91_shdwc.h create mode 100644 arch/arm/mach-at91/reset_source.c
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 2/4 reset_source: add software reset as possible source
In reply to Jean-Christophe PLAGNIOL-VILLARD--- common/reset_source.c | 1 + include/reset_source.h | 1 + 2 files changed, 2 insertions(+)
common/reset_source.c +1 -0
@@ -22,6 +22,7 @@ static const char * const reset_src_names[] = { [RESET_UKWNOWN] = "unknown", [RESET_POWER] = "power", [RESET_RESET] = "reset", + [RESET_SOFTWARE] = "software", [RESET_WATCHDOG] = "watchdog", [RESET_WAKEUP] = "wakeup", [RESET_JTAG] = "jtag",
include/reset_source.h +1 -0
@@ -17,6 +17,7 @@ enum reset_src_type {RESET_UKWNOWN ,/* maybe the SoC cannot detect the reset source */ RESET_POWER ,/* Power On Reset (cold start) */ RESET_RESET ,/* generic ReSeT (warm start) */ +RESET_SOFTWARE ,/* software */ RESET_WATCHDOG ,/* watchdog */ RESET_WAKEUP ,/* wake-up (some SoCs can handle this) */ RESET_JTAG, /* JTAG reset */
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 3/4 reset_resource: add wakeup source
In reply to Jean-Christophe PLAGNIOL-VILLARDThis will allow to known the source of wakeup
--- common/reset_source.c | 17 +++++++++++++++++ include/reset_source.h | 11 +++++++++++ 2 files changed, 28 insertions(+)
common/reset_source.c +17 -0
@@ -34,11 +34,28 @@ void set_reset_source(enum reset_src_type st) }EXPORT_SYMBOL (set_reset_source); +static const char *const wakeup_src_names[] = { + [WAKEUP_UKWNOWN ] ="unknown" , + [WAKEUP_POWER ] ="power" , + [WAKEUP_RTC ] ="rtc" , + [WAKEUP_TIMER ] ="timer" , + [WAKEUP_USER ] ="user" , + [WAKEUP_WOL ] ="wakeup on lan" , +}; + +void set_wakeup_source (enum wakeup_src_type st) +{ +setenv ("global.system.wakeup" , wakeup_src_names[st]); +} +EXPORT_SYMBOL (set_reset_source); +/* ensure this runs after the 'global' device is already registerd */ static int init_reset_source (void ) {globalvar_add_simple ("system.reset" ); +globalvar_add_simple ("system.wakeup" );set_reset_source (RESET_UKWNOWN ); +set_wakeup_source (WAKEUP_UKWNOWN );return 0 ; }
include/reset_source.h +11 -0
@@ -31,4 +31,15 @@ static inline void set_reset_source(enum reset_src_type unused) }#endif +enum wakeup_src_type { +WAKEUP_UKWNOWN ,/* maybe the SoC cannot detect the wakeup source */ +WAKEUP_POWER ,/* Power restore */ +WAKEUP_RTC ,/* rtc */ +WAKEUP_TIMER ,/* timer */ +WAKEUP_USER ,/* user */ +WAKEUP_WOL ,/* wakeup on lan */ +}; + +void set_wakeup_source (enum wakeup_src_type ); +#endif /* __INCLUDE_RESET_SOURCE_H */
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 1/4 reset_source: make enum and string human readable
In reply to Jean-Christophe PLAGNIOL-VILLARDToday we need to read the code to understand it
--- arch/arm/mach-imx/imx1.c | 6 +++--- arch/arm/mach-samsung/reset_source.c | 6 +++--- common/reset_source.c | 14 +++++++------- drivers/watchdog/im28wd.c | 6 +++--- drivers/watchdog/imxwd.c | 6 +++--- include/reset_source.h | 10 +++++----- 6 files changed, 24 insertions(+), 24 deletions(-)
arch/arm/mach-imx/imx1.c +3 -3
@@ -29,13 +29,13 @@ static void imx1_detect_reset_source(void)switch (val) {case RSR_EXR : -set_reset_source (RESET_RST ); +set_reset_source (RESET_RESET );return ;case RSR_WDR : -set_reset_source (RESET_WDG ); +set_reset_source (RESET_WATCHDOG );return ;case 0 : -set_reset_source (RESET_POR ); +set_reset_source (RESET_POWER );return ;default :/* else keep the default 'unknown' state */
arch/arm/mach-samsung/reset_source.c +3 -3
@@ -29,21 +29,21 @@ static int s3c_detect_reset_source(void)u32 reg =readl (S3C_GPIO_BASE +S3C2440_GSTATUS2 );if (reg &S3C2440_GSTATUS2_PWRST ) { -set_reset_source (RESET_POR ); +set_reset_source (RESET_POWER );writel (S3C2440_GSTATUS2_PWRST ,S3C_GPIO_BASE +S3C2440_GSTATUS2 );return 0 ; }if (reg &S3C2440_GSTATUS2_SLEEPRST ) { -set_reset_source (RESET_WKE ); +set_reset_source (RESET_WAKEUP );writel (S3C2440_GSTATUS2_SLEEPRST ,S3C_GPIO_BASE +S3C2440_GSTATUS2 );return 0 ; }if (reg &S3C2440_GSTATUS2_WDRST ) { -set_reset_source (RESET_WDG ); +set_reset_source (RESET_WATCHDOG );writel (S3C2440_GSTATUS2_WDRST ,S3C_GPIO_BASE +S3C2440_GSTATUS2 );return 0 ;
common/reset_source.c +7 -7
@@ -19,12 +19,12 @@#include <reset_source.h> static const char *const reset_src_names[] = { - [RESET_UKWN ] ="unknown" , - [RESET_POR ] ="POR" , - [RESET_RST ] ="RST" , - [RESET_WDG ] ="WDG" , - [RESET_WKE ] ="WKE" , - [RESET_JTAG ] ="JTAG" , + [RESET_UKWNOWN ] ="unknown" , + [RESET_POWER ] ="power" , + [RESET_RESET ] ="reset" , + [RESET_WATCHDOG ] ="watchdog" , + [RESET_WAKEUP ] ="wakeup" , + [RESET_JTAG ] ="jtag" , };void set_reset_source (enum reset_src_type st)
@@ -37,7 +37,7 @@ EXPORT_SYMBOL(set_reset_source);static int init_reset_source (void ) {globalvar_add_simple ("system.reset" ); -set_reset_source (RESET_UKWN ); +set_reset_source (RESET_UKWNOWN );return 0 ; }
drivers/watchdog/im28wd.c +3 -3
@@ -82,17 +82,17 @@ static void __maybe_unused imx28_detect_reset_source(const struct imx28_wd *p)if (reg &MXS_RTC_PERSISTENT0_EXT_RST ) {writel (MXS_RTC_PERSISTENT0_EXT_RST , p->regs +MXS_RTC_PERSISTENT0 +MXS_RTC_CLR_ADDR ); -set_reset_source (RESET_POR ); +set_reset_source (RESET_POWER );return ; }if (reg &MXS_RTC_PERSISTENT0_THM_RST ) {writel (MXS_RTC_PERSISTENT0_THM_RST , p->regs +MXS_RTC_PERSISTENT0 +MXS_RTC_CLR_ADDR ); -set_reset_source (RESET_RST ); +set_reset_source (RESET_RESET );return ; } -set_reset_source (RESET_RST ); +set_reset_source (RESET_RESET ); }static int imx28_wd_probe (struct device_d *dev)
drivers/watchdog/imxwd.c +3 -3
@@ -129,17 +129,17 @@ static void imx_watchdog_detect_reset_source(struct imx_wd *priv)u16 val =readw (priv->base +IMX21_WDOG_WSTR );if (val &WSTR_COLDSTART ) { -set_reset_source (RESET_POR ); +set_reset_source (RESET_POWER );return ; }if (val & (WSTR_HARDRESET |WSTR_WARMSTART )) { -set_reset_source (RESET_RST ); +set_reset_source (RESET_RESET );return ; }if (val &WSTR_WDOG ) { -set_reset_source (RESET_WDG ); +set_reset_source (RESET_WATCHDOG );return ; }
include/reset_source.h +5 -5
@@ -14,11 +14,11 @@# define __INCLUDE_RESET_SOURCE_Henum reset_src_type { -RESET_UKWN ,/* maybe the SoC cannot detect the reset source */ -RESET_POR ,/* Power On Reset (cold start) */ -RESET_RST ,/* generic ReSeT (warm start) */ -RESET_WDG ,/* watchdog */ -RESET_WKE ,/* wake-up (some SoCs can handle this) */ +RESET_UKWNOWN ,/* maybe the SoC cannot detect the reset source */ +RESET_POWER ,/* Power On Reset (cold start) */ +RESET_RESET ,/* generic ReSeT (warm start) */ +RESET_WATCHDOG ,/* watchdog */ +RESET_WAKEUP ,/* wake-up (some SoCs can handle this) */ RESET_JTAG ,/* JTAG reset */ };
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 4/4 at91: add reset and wakeup source detection support
--- arch/arm/mach-at91/Makefile | 1 + arch/arm/mach-at91/include/mach/at91_shdwc.h | 40 +++++++++++++++++ arch/arm/mach-at91/reset_source.c | 59 ++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 arch/arm/mach-at91/include/mach/at91_shdwc.h create mode 100644 arch/arm/mach-at91/reset_source.c
arch/arm/mach-at91/Makefile +1 -0
@@ -8,6 +8,7 @@ pbl-$(CONFIG_MACH_DO_LOWLEVEL_INIT) += $(lowlevel_init-y) obj-$(CONFIG_AT91SAM9_RESET) += at91sam9_reset.o obj-$(CONFIG_AT91SAM9G45_RESET) += at91sam9g45_reset.o +obj-$(CONFIG_RESET_SOURCE) += reset_source.o # CPU-specific support obj-$(CONFIG_ARCH_AT91RM9200) += at91rm9200.o at91rm9200_time.o at91rm9200_devices.o
arch/arm/mach-at91/include/mach/at91_shdwc.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* arch/arm/mach-at91/include/mach/at91_shdwc.h +* +* Copyright (C) 2007 Andrew Victor +* Copyright (C) 2007 Atmel Corporation. +* +* Shutdown Controller (SHDWC) - System peripherals regsters. +* Based on AT91SAM9261 datasheet revision D. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ + +#ifndef AT91_SHDWC_H +#define AT91_SHDWC_H + +#define AT91_SHDW_CR (AT91_SHDWC + 0x00)/* Shut Down Control Register */ +#define AT91_SHDW_SHDW (1 << 0)/* Shut Down command */ +#define AT91_SHDW_KEY (0xa5 << 24)/* KEY Password */ + +#define AT91_SHDW_MR (AT91_SHDWC + 0x04)/* Shut Down Mode Register */ +#define AT91_SHDW_WKMODE0 (3 << 0)/* Wake-up 0 Mode Selection */ +#define AT91_SHDW_WKMODE0_NONE 0 +#define AT91_SHDW_WKMODE0_HIGH 1 +#define AT91_SHDW_WKMODE0_LOW 2 +#define AT91_SHDW_WKMODE0_ANYLEVEL 3 +#define AT91_SHDW_CPTWK0_MAX 0xf/* Maximum Counter On Wake Up 0 */ +#define AT91_SHDW_CPTWK0 (AT91_SHDW_CPTWK0_MAX << 4)/* Counter On Wake Up 0 */ +#define AT91_SHDW_CPTWK0_ (x) ((x) << 4) +#define AT91_SHDW_RTTWKEN (1 << 16)/* Real Time Timer Wake-up Enable */ +#define AT91_SHDW_RTCWKEN (1 << 17)/* Real Time Clock Wake-up Enable */ + +#define AT91_SHDW_SR (AT91_SHDWC + 0x08)/* Shut Down Status Register */ +#define AT91_SHDW_WAKEUP0 (1 << 0)/* Wake-up 0 Status */ +#define AT91_SHDW_RTTWK (1 << 16)/* Real-time Timer Wake-up */ +#define AT91_SHDW_RTCWK (1 << 17)/* Real-time Clock Wake-up [SAM9RL] */ + +#endif
arch/arm/mach-at91/reset_source.c new file +59 -0
59 lines not on this page · raw message
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
maintainerRe: [PATCH 3/4] reset_resource: add wakeup source
In reply to Jean-Christophe PLAGNIOL-VILLARDQuoted 14 lines · Jean-Christophe PLAGNIOL-VILLARD
This will allow to known the source of wakeup
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- common/reset_source.c | 17 +++++++++++++++++ include/reset_source.h | 11 +++++++++++ 2 files changed, 28 insertions(+)common/reset_source.c +0
-0@@ -34,11 +34,28 @@ void set_reset_source(enum reset_src_type st) }
common/reset_source.c void set_reset_source(enum reset_src_type st) · line 44
Quoted 10 lines
common/reset_source.c +8
-0EXPORT_SYMBOL (set_reset_source); +static const char *const wakeup_src_names[] = { + [WAKEUP_UKWNOWN ] ="unknown" , + [WAKEUP_POWER ] ="power" , + [WAKEUP_RTC ] ="rtc" , + [WAKEUP_TIMER ] ="timer" , + [WAKEUP_USER ] ="user" , + [WAKEUP_WOL ] ="wakeup on lan" , +};
I'm unsure we need a second array for this. I mean RTC can't be seen as a reset source, but with a bit of good will the watchdog for example can be seen as a wakeup source. We have:
WAKEUP_POWER
WAKEUP_RTC
WAKEUP_TIMER
WAKEUP_USER
WAKEUP_WOL
RESET_POWER
RESET_RESET
RESET_WATCHDOG
RESET_WAKEUP
RESET_JTAG
WAKEUP_POWER and RESET_POWER are duplicates, RESET_WAKEUP is just an indicator that we should look into the WAKEUP_* array. The rest are all mutually exclusive. So we would have:
WAKEUP_POWER
WAKEUP_RTC
WAKEUP_TIMER
WAKEUP_USER
WAKEUP_WOL
WAKEUP_RESET
WAKEUP_WATCHDOG
WAKEUP_JTAG
Wouldn't that be better?
Sascha
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 3/4] reset_resource: add wakeup source
Quoted 41 lines · Sascha Hauer
Quoted 14 lines · Jean-Christophe PLAGNIOL-VILLARD
This will allow to known the source of wakeup
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- common/reset_source.c | 17 +++++++++++++++++ include/reset_source.h | 11 +++++++++++ 2 files changed, 28 insertions(+)common/reset_source.c +0
-0@@ -34,11 +34,28 @@ void set_reset_source(enum reset_src_type st) }common/reset_source.c void set_reset_source(enum reset_src_type st) · line 44
Quoted 10 lines
common/reset_source.c +8
-0EXPORT_SYMBOL (set_reset_source); +static const char *const wakeup_src_names[] = { + [WAKEUP_UKWNOWN ] ="unknown" , + [WAKEUP_POWER ] ="power" , + [WAKEUP_RTC ] ="rtc" , + [WAKEUP_TIMER ] ="timer" , + [WAKEUP_USER ] ="user" , + [WAKEUP_WOL ] ="wakeup on lan" , +};I'm unsure we need a second array for this. I mean RTC can't be seen as a reset source, but with a bit of good will the watchdog for example can be seen as a wakeup source. We have:
WAKEUP_POWER
WAKEUP_RTC
WAKEUP_TIMER
WAKEUP_USER
WAKEUP_WOL
RESET_POWER
RESET_RESET
RESET_WATCHDOG
RESET_WAKEUP
RESET_JTAG
Quoted 3 lines
WAKEUP_POWERandRESET_POWERare duplicates,RESET_WAKEUPis just an indicator that we should look into the WAKEUP_* array. The rest are all mutually exclusive. So we would have:
for reset POWER mean inmy ming we gcc power up on the soc not I plug the power
so it could be WKAEUP_POWER_UP
for RESET_WAKEUP I agree
Quoted 11 lines
WAKEUP_POWER
WAKEUP_RTC
WAKEUP_TIMER
WAKEUP_USER
WAKEUP_WOL
WAKEUP_RESET
WAKEUP_WATCHDOG
WAKEUP_JTAGWouldn't that be better?
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 3/4] reset_resource: add wakeup source
Hi Jean Christophe
Quoted 3 lines · Jean-Christophe PLAGNIOL-VILLARD
for reset POWER mean inmy ming we gcc power up on the soc not I plug the power
can you please make an effort in your emails or just tell me which language should I use in google translator to understand that ? ;-)
Thanks !
Eric
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 3/4] reset_resource: add wakeup source
In reply to Jean-Christophe PLAGNIOL-VILLARDQuoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD
common/reset_source.c +4
-0+static const char *const wakeup_src_names[] = { + [WAKEUP_UKWNOWN ] ="unknown" , + [WAKEUP_POWER ] ="power" , + [WAKEUP_RTC ] ="rtc" ,
common/reset_source.c void set_reset_source(enum reset_src_type st) · line 50
Quoted 10 lines
common/reset_source.c +10
-0+ [WAKEUP_TIMER] = "timer", + [WAKEUP_USER] = "user", + [WAKEUP_WOL] = "wakeup on lan", +}; + +void set_wakeup_source (enum wakeup_src_type st) +{ +setenv ("global.system.wakeup" , wakeup_src_names[st]); +} +EXPORT_SYMBOL (set_reset_source);
The EXPORT_SYMBOL should be for _wakeup_ instead of _reset_.
Signature · 10 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox