Re: [PATCH 3/4] reset_resource: add wakeup source

2012-10-15 Thread Jan Lübbe
On Sat, 2012-10-13 at 15:49 +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
 +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);

The EXPORT_SYMBOL should be for _wakeup_ instead of _reset_.

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


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 3/4] reset_resource: add wakeup source

2012-10-14 Thread Eric Bénard
Hi Jean Christophe

Le Sun, 14 Oct 2012 11:56:16 +0200,
Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com a écrit :
 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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/4] reset_resource: add wakeup source

2012-10-13 Thread Jean-Christophe PLAGNIOL-VILLARD
This will allow to known the source of wakeup

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/reset_source.c  |   17 +
 include/reset_source.h |   11 +++
 2 files changed, 28 insertions(+)

diff --git a/common/reset_source.c b/common/reset_source.c
index ec1afc0..8fd8a6d 100644
--- a/common/reset_source.c
+++ b/common/reset_source.c
@@ -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,
+   [RESET_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;
 }
 
diff --git a/include/reset_source.h b/include/reset_source.h
index 5129c6a..d08aa65 100644
--- a/include/reset_source.h
+++ b/include/reset_source.h
@@ -25,4 +25,15 @@ enum reset_src_type {
 
 void set_reset_source(enum reset_src_type);
 
+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 */
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/4] reset_resource: add wakeup source

2012-10-13 Thread Jean-Christophe PLAGNIOL-VILLARD
This will allow to known the source of wakeup

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/reset_source.c  |   17 +
 include/reset_source.h |   11 +++
 2 files changed, 28 insertions(+)

diff --git a/common/reset_source.c b/common/reset_source.c
index ec1afc0..4791d29 100644
--- a/common/reset_source.c
+++ b/common/reset_source.c
@@ -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;
 }
 
diff --git a/include/reset_source.h b/include/reset_source.h
index af4246a..1777b2b 100644
--- a/include/reset_source.h
+++ b/include/reset_source.h
@@ -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 */
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 3/4] reset_resource: add wakeup source

2012-10-13 Thread Sascha Hauer
On Sat, Oct 13, 2012 at 03:49:21PM +0200, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
 This will allow to known the source of wakeup
 
 Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
 ---
  common/reset_source.c  |   17 +
  include/reset_source.h |   11 +++
  2 files changed, 28 insertions(+)
 
 diff --git a/common/reset_source.c b/common/reset_source.c
 index ec1afc0..4791d29 100644
 --- a/common/reset_source.c
 +++ b/common/reset_source.c
 @@ -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,
 +};

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

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

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox