Patchwork [U-Boot,v3,2/3] MX31: Introduce get_reset_cause()

login
register
mail settings
Submitter Fabio Estevam
Date April 15, 2011, 2:21 a.m.
Message ID <1302834109-15171-2-git-send-email-festevam@gmail.com>
Download mbox | patch
Permalink /patch/91315/
State Changes Requested
Headers show

Comments

Fabio Estevam - April 15, 2011, 2:21 a.m.
Introduce get_reset_cause() function to indicate the source of the reset.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 arch/arm/cpu/arm1136/mx31/generic.c       |   26 ++++++++++++++++++++++++++
 arch/arm/include/asm/arch-mx31/imx-regs.h |    2 ++
 2 files changed, 28 insertions(+), 0 deletions(-)
Stefano Babic - April 15, 2011, 6:18 p.m.
On 04/15/2011 04:21 AM, Fabio Estevam wrote:
> Introduce get_reset_cause() function to indicate the source of the reset.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  arch/arm/cpu/arm1136/mx31/generic.c       |   26 ++++++++++++++++++++++++++
>  arch/arm/include/asm/arch-mx31/imx-regs.h |    2 ++
>  2 files changed, 28 insertions(+), 0 deletions(-)
> 

Hi Fabio,

> diff --git a/arch/arm/include/asm/arch-mx31/imx-regs.h b/arch/arm/include/asm/arch-mx31/imx-regs.h
> index 74444f2..2b0881d 100644
> --- a/arch/arm/include/asm/arch-mx31/imx-regs.h
> +++ b/arch/arm/include/asm/arch-mx31/imx-regs.h
> @@ -27,6 +27,8 @@
>  #if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__))
>  #include <asm/types.h>
>  
> +extern char *get_reset_cause(void);
> +

The imx-regs.h contains only defines and structures for the processor,
and no prototypes. Function prototypes are then listed in sys_proto.h,
not only for i.MX processor. I prefer to maintain this rule and to not
add prototypes to this file.

Best regards,
Stefano Babic
Detlev Zundel - April 18, 2011, 9:02 a.m.
Hi Fabio and Stefan,

> On 04/15/2011 04:21 AM, Fabio Estevam wrote:
>> Introduce get_reset_cause() function to indicate the source of the reset.
>> 
>> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
>> ---
>>  arch/arm/cpu/arm1136/mx31/generic.c       |   26 ++++++++++++++++++++++++++
>>  arch/arm/include/asm/arch-mx31/imx-regs.h |    2 ++
>>  2 files changed, 28 insertions(+), 0 deletions(-)
>> 
>
> Hi Fabio,
>
>> diff --git a/arch/arm/include/asm/arch-mx31/imx-regs.h
>> b/arch/arm/include/asm/arch-mx31/imx-regs.h
>> index 74444f2..2b0881d 100644
>> --- a/arch/arm/include/asm/arch-mx31/imx-regs.h
>> +++ b/arch/arm/include/asm/arch-mx31/imx-regs.h
>> @@ -27,6 +27,8 @@
>>  #if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__))
>>  #include <asm/types.h>
>>  
>> +extern char *get_reset_cause(void);
>> +
>
> The imx-regs.h contains only defines and structures for the processor,
> and no prototypes. Function prototypes are then listed in sys_proto.h,
> not only for i.MX processor. I prefer to maintain this rule and to not
> add prototypes to this file.

Why can't we have this code in the cpu specific code _without_ any call
from a board so _ecery_ board gets the additional information for free?

See for example arch/powerpc/cpu/mpc512x/cpu.c where this is done for
RSR on 5121.  I do not understand what the problem is here, can someone
enlighten me please?

Cheers
  Detlev

Patch

diff --git a/arch/arm/cpu/arm1136/mx31/generic.c b/arch/arm/cpu/arm1136/mx31/generic.c
index 9b7a7a2..ea452a9 100644
--- a/arch/arm/cpu/arm1136/mx31/generic.c
+++ b/arch/arm/cpu/arm1136/mx31/generic.c
@@ -132,6 +132,32 @@  char *get_cpu_rev(void)
 		return "unknown";
 }
 
+char *get_reset_cause(void)
+{
+	/* read SRS register from CCM module */
+	struct clock_control_regs *ccm =
+		(struct clock_control_regs *)CCM_BASE;
+
+	u32 cause = readl(&ccm->rcsr) & 0x07;
+
+	switch (cause) {
+	case 0x0000:
+		return "POR";
+		break;
+	case 0x0001:
+		return "RST";
+		break;
+	case 0x0002:
+		return "WDOG";
+		break;
+	case 0x0006:
+		return "JTAG";
+		break;
+	default:
+		return "unknown reset";
+	}
+}
+
 #if defined(CONFIG_DISPLAY_CPUINFO)
 int print_cpuinfo (void)
 {
diff --git a/arch/arm/include/asm/arch-mx31/imx-regs.h b/arch/arm/include/asm/arch-mx31/imx-regs.h
index 74444f2..2b0881d 100644
--- a/arch/arm/include/asm/arch-mx31/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx31/imx-regs.h
@@ -27,6 +27,8 @@ 
 #if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__))
 #include <asm/types.h>
 
+extern char *get_reset_cause(void);
+
 /* Clock control module registers */
 struct clock_control_regs {
 	u32 ccmr;