mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] reset_source: add thermal reset
@ 2014-10-20 18:15 Lucas Stach
  2014-10-20 18:15 ` [PATCH 2/2] tegra: pmc: add support for reset src detection Lucas Stach
  2014-10-21 11:12 ` [PATCH 1/2] reset_source: add thermal reset Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Lucas Stach @ 2014-10-20 18:15 UTC (permalink / raw)
  To: barebox

Some SoCs are able to detect if they got reset
in response to an overtemperature event.

Signed-off-by: Lucas Stach <dev@lynxeye.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 6026af1..946670b 100644
--- a/common/reset_source.c
+++ b/common/reset_source.c
@@ -25,6 +25,7 @@ static const char * const reset_src_names[] = {
 	[RESET_WDG] = "WDG",
 	[RESET_WKE] = "WKE",
 	[RESET_JTAG] = "JTAG",
+	[RESET_THERM] = "THERM",
 };
 
 static enum reset_src_type reset_source;
diff --git a/include/reset_source.h b/include/reset_source.h
index bff7f97..6620228 100644
--- a/include/reset_source.h
+++ b/include/reset_source.h
@@ -20,6 +20,7 @@ enum reset_src_type {
 	RESET_WDG,	/* watchdog */
 	RESET_WKE,	/* wake-up (some SoCs can handle this) */
 	RESET_JTAG,	/* JTAG reset */
+	RESET_THERM,	/* SoC shut down because of overtemperature */
 };
 
 #ifdef CONFIG_RESET_SOURCE
-- 
1.9.3


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] tegra: pmc: add support for reset src detection
  2014-10-20 18:15 [PATCH 1/2] reset_source: add thermal reset Lucas Stach
@ 2014-10-20 18:15 ` Lucas Stach
  2014-10-21 11:12 ` [PATCH 1/2] reset_source: add thermal reset Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Lucas Stach @ 2014-10-20 18:15 UTC (permalink / raw)
  To: barebox

Also activate in defconfig.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
 arch/arm/configs/tegra_v7_defconfig            |  1 +
 arch/arm/mach-tegra/include/mach/tegra20-pmc.h |  9 +++++++
 arch/arm/mach-tegra/tegra20-pmc.c              | 33 +++++++++++++++++++++++++-
 3 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/arch/arm/configs/tegra_v7_defconfig b/arch/arm/configs/tegra_v7_defconfig
index 22f5765..3ad67be 100644
--- a/arch/arm/configs/tegra_v7_defconfig
+++ b/arch/arm/configs/tegra_v7_defconfig
@@ -16,6 +16,7 @@ CONFIG_AUTO_COMPLETE=y
 CONFIG_MENU=y
 CONFIG_BLSPEC=y
 CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
+CONFIG_RESET_SOURCE=y
 CONFIG_LONGHELP=y
 CONFIG_CMD_IOMEM=y
 CONFIG_CMD_MEMINFO=y
diff --git a/arch/arm/mach-tegra/include/mach/tegra20-pmc.h b/arch/arm/mach-tegra/include/mach/tegra20-pmc.h
index 30ac065..c379544 100644
--- a/arch/arm/mach-tegra/include/mach/tegra20-pmc.h
+++ b/arch/arm/mach-tegra/include/mach/tegra20-pmc.h
@@ -71,3 +71,12 @@
 #define PMC_PARTID_C0NC			15
 
 #define PMC_SCRATCH(i)			(0x050 + 0x4*i)
+
+#define PMC_RST_STATUS			0x1b4
+#define PMC_RST_STATUS_RST_SRC_SHIFT	0
+#define PMC_RST_STATUS_RST_SRC_MASK	(0x7 << PMC_RST_STATUS_RST_SRC_SHIFT)
+#define PMC_RST_STATUS_RST_SRC_POR	0
+#define PMC_RST_STATUS_RST_SRC_WATCHDOG	1
+#define PMC_RST_STATUS_RST_SRC_SENSOR	2
+#define PMC_RST_STATUS_RST_SRC_SW_MAIN	3
+#define PMC_RST_STATUS_RST_SRC_LP0	4
diff --git a/arch/arm/mach-tegra/tegra20-pmc.c b/arch/arm/mach-tegra/tegra20-pmc.c
index d868094..434a7eb 100644
--- a/arch/arm/mach-tegra/tegra20-pmc.c
+++ b/arch/arm/mach-tegra/tegra20-pmc.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Lucas Stach <l.stach@pengutronix.de>
+ * Copyright (C) 2013-2014 Lucas Stach <l.stach@pengutronix.de>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -24,6 +24,7 @@
 #include <init.h>
 #include <io.h>
 #include <linux/err.h>
+#include <reset_source.h>
 
 #include <mach/tegra20-pmc.h>
 
@@ -38,6 +39,33 @@ void __noreturn reset_cpu(ulong addr)
 }
 EXPORT_SYMBOL(reset_cpu);
 
+static void tegra20_pmc_detect_reset_cause(void)
+{
+	u32 reg = readl(pmc_base + PMC_RST_STATUS);
+
+	switch ((reg & PMC_RST_STATUS_RST_SRC_MASK) >>
+	         PMC_RST_STATUS_RST_SRC_SHIFT) {
+	case PMC_RST_STATUS_RST_SRC_POR:
+		reset_source_set(RESET_POR);
+		break;
+	case PMC_RST_STATUS_RST_SRC_WATCHDOG:
+		reset_source_set(RESET_WDG);
+		break;
+	case PMC_RST_STATUS_RST_SRC_LP0:
+		reset_source_set(RESET_WKE);
+		break;
+	case PMC_RST_STATUS_RST_SRC_SW_MAIN:
+		reset_source_set(RESET_RST);
+		break;
+	case PMC_RST_STATUS_RST_SRC_SENSOR:
+		reset_source_set(RESET_THERM);
+		break;
+	default:
+		reset_source_set(RESET_UKWN);
+		break;
+	}
+}
+
 static int tegra20_pmc_probe(struct device_d *dev)
 {
 	pmc_base = dev_request_mem_region(dev, 0);
@@ -46,6 +74,9 @@ static int tegra20_pmc_probe(struct device_d *dev)
 		return PTR_ERR(pmc_base);
 	}
 
+	if (IS_ENABLED(CONFIG_RESET_SOURCE))
+		tegra20_pmc_detect_reset_cause();
+
 	return 0;
 }
 
-- 
1.9.3


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] reset_source: add thermal reset
  2014-10-20 18:15 [PATCH 1/2] reset_source: add thermal reset Lucas Stach
  2014-10-20 18:15 ` [PATCH 2/2] tegra: pmc: add support for reset src detection Lucas Stach
@ 2014-10-21 11:12 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2014-10-21 11:12 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox

On Mon, Oct 20, 2014 at 08:15:29PM +0200, Lucas Stach wrote:
> Some SoCs are able to detect if they got reset
> in response to an overtemperature event.
> 
> Signed-off-by: Lucas Stach <dev@lynxeye.de>

Applied, thanks

Sascha

> ---
>  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 6026af1..946670b 100644
> --- a/common/reset_source.c
> +++ b/common/reset_source.c
> @@ -25,6 +25,7 @@ static const char * const reset_src_names[] = {
>  	[RESET_WDG] = "WDG",
>  	[RESET_WKE] = "WKE",
>  	[RESET_JTAG] = "JTAG",
> +	[RESET_THERM] = "THERM",
>  };
>  
>  static enum reset_src_type reset_source;
> diff --git a/include/reset_source.h b/include/reset_source.h
> index bff7f97..6620228 100644
> --- a/include/reset_source.h
> +++ b/include/reset_source.h
> @@ -20,6 +20,7 @@ enum reset_src_type {
>  	RESET_WDG,	/* watchdog */
>  	RESET_WKE,	/* wake-up (some SoCs can handle this) */
>  	RESET_JTAG,	/* JTAG reset */
> +	RESET_THERM,	/* SoC shut down because of overtemperature */
>  };
>  
>  #ifdef CONFIG_RESET_SOURCE
> -- 
> 1.9.3
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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] 3+ messages in thread

end of thread, other threads:[~2014-10-21 11:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-20 18:15 [PATCH 1/2] reset_source: add thermal reset Lucas Stach
2014-10-20 18:15 ` [PATCH 2/2] tegra: pmc: add support for reset src detection Lucas Stach
2014-10-21 11:12 ` [PATCH 1/2] reset_source: add thermal reset Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox