Skip to contentSkip to conversation

: Fix e500 v2 core reboot bug

PATCH In review Zang Roy-r61911 4 participants 13 messages Jun 13, 2007 – Jun 14, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 : Fix e500 v2 core reboot bug

From: Roy Zang <[email protected]>

Fix the reset bug on 8548CDS board.

Quoted 1 line

From MPC8548CDS with e500 v2 core, a new reset control register is added.

This register is used for the cpu reset.

---
Please ignore all the previous ones :-(
Segher, do you have any comment?
If yes, I will revise again; if No, pick it up!
Thanks!

 arch/powerpc/boot/dts/mpc8548cds.dts |    6 ++++++
 arch/powerpc/platforms/85xx/misc.c   |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)
arch/powerpc/boot/dts/mpc8548cds.dts +6 -0
index ad96381..0550a3c 100644
@@ -177,6 +177,12 @@
 			interrupt-parent = <&mpic>;
 		};
 
+		global-utilities@e0000 {	//global utilities reg
+			compatible = "fsl,mpc8548-guts";
+			reg = <e0000 1000>;
+			fsl,has-rstcr;
+		};
+
 		pci1: pci@8000 {
 			interrupt-map-mask = <1f800 0 0 7>;
 			interrupt-map = <
arch/powerpc/platforms/85xx/misc.c +32 -0
index 3e62fcb..8286393 100644
@@ -13,11 +13,43 @@
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/prom.h>
+#include <sysdev/fsl_soc.h>
+
+static __be32 __iomem *rstcr;
 
 extern void abort(void);
 
+static int __init mpc85xx_rstcr(void)
+{
+	struct device_node *np;
+	np = of_find_node_by_name(NULL, "global-utilities");
+	if ((np && of_get_property(np, "fsl,has-rstcr", NULL))) {
+		const u32 *prop = of_get_property(np, "reg", NULL);
+		if (prop) {
+			/* map reset control register
+			 * 0xE00B0 is offset of reset control register
+			 */
+			rstcr = ioremap(get_immrbase() + *prop + 0xB0, 0xff);
+			if (!rstcr)
+				printk (KERN_EMERG "Error: reset control \
+					register not mapped, spinning!\n");
+		}
+	} else
+		printk (KERN_INFO "rstcr compatible register does not exist!\n");
+	if (np)
+		of_node_put(np);
+	return 0;
+}
+
+arch_initcall(mpc85xx_rstcr);
+
 void mpc85xx_restart(char *cmd)
 {
 	local_irq_disable();
+	if (rstcr)
+		/* set reset control register */
+		out_be32(rstcr, 0x2);	/* HRESET_REQ */
 	abort();
 }
Signature · 1 line
1.5.1
#1 lore raw
Quoted 3 lines

Fix the reset bug on 8548CDS board.

Segher, do you have any comment?

This one looks fine, only some cosmetics left :-)

Quoted 1 line

If yes, I will revise again; if No, pick it up!

Well it's not me who picks things up around here...

arch/powerpc/platforms/85xx/misc.c line 37

Quoted 2 lines
arch/powerpc/platforms/85xx/misc.c +2 -0
+				printk (KERN_EMERG "Error: reset control \
+					register not mapped, spinning!\n");

...(... "bla bla bla "

	"bla bla bla\n");

instead? Or there'll be a lot of whitespace in your string. I don't see anything spinning like the warning says, btw (or it must be something in abort()?)

Segher

#2 lore raw
Quoted 9 lines · Segher Boessenkool
Quoted 3 lines

Fix the reset bug on 8548CDS board.

Segher, do you have any comment?

This one looks fine, only some cosmetics left :-)

Quoted 1 line

If yes, I will revise again; if No, pick it up!

Well it's not me who picks things up around here...

I know, it's Paul or Kumar! I just like to hear your valuable comment...

Quoted 10 lines
Quoted 2 lines

+ printk (KERN_EMERG "Error: reset

control \

Quoted 1 line

+ register not mapped,

spinning!\n");

...(... "bla bla bla "

        "bla bla bla\n");

instead? Or there'll be a lot of whitespace in your string.

I just do not know the difference of these two style.

Quoted 2 lines

I don't see anything spinning like the warning says, btw (or it must be something in abort()?)

You can find the similar thing in 83xx/mis.c
[snip]

	} else {
		printk (KERN_EMERG "Error: Restart registers not mapped,
spinning!\n");
	}

[snip]
Roy

#3 lore raw
Quoted 10 lines
Quoted 9 lines
Quoted 1 line

+ printk (KERN_EMERG "Error: reset

control \

Quoted 1 line

+ register not mapped,

spinning!\n");

...(... "bla bla bla "

        "bla bla bla\n");

instead? Or there'll be a lot of whitespace in your string.

I just do not know the difference of these two style.

Your code puts a bunch of extra whitespace in the string (all the tabs before "register not mapped"). Two strings after each other (like in my example) are just pasted together.

There is no real reason to break the string in two anyway, it is fine to have a more-than-80-char line in printk messages.

Quoted 9 lines
Quoted 2 lines

I don't see anything spinning like the warning says, btw (or it must be something in abort()?)

You can find the similar thing in 83xx/mis.c
[snip]

	} else {
		printk (KERN_EMERG "Error: Restart registers not mapped,
spinning!\n");
	}

[snip]

You shouldn't have snipped, right after that it says

        for (;;) ;

Segher

#4 lore raw
Quoted 9 lines · Segher Boessenkool
Quoted 9 lines
Quoted 9 lines
Quoted 1 line

+ printk (KERN_EMERG "Error: reset

control \

Quoted 1 line

+ register not mapped,

spinning!\n");

...(... "bla bla bla "

        "bla bla bla\n");

instead? Or there'll be a lot of whitespace in your string.

Quoted 9 lines
Quoted 1 line

I just do not know the difference of these two style.

Your code puts a bunch of extra whitespace in the string (all the tabs before "register not mapped"). Two strings after each other (like in my example) are just pasted together.

There is no real reason to break the string in two anyway, it is fine to have a more-than-80-char line in printk messages.

I separate it, because I am afraid I will be challenged by 80 char column rule.

Please check the CodeStyle file and its example:

Statements longer than 80 columns will be broken into sensible chunks. Descendants are always substantially shorter than the parent and are placed
substantially to the right. The same applies to function headers with a long
argument list. Long strings are as well broken into shorter strings. [snip]
void fun(int a, int b, int c)

{
	if (condition)
		printk(KERN_WARNING "Warning this is a long printk with "
						"3 parameters a: %u b: %u "
						"c: %u \n", a, b, c);
	else
		next_statement;
}

[snip]
If it does not matter, I'd like to put them in one line :-). Roy

#5 lore raw
Quoted 2 lines

-----Original Message-----
From: [email protected]

[mailto:[email protected]] On Behalf Of

Quoted 25 lines

Zang Roy-r61911
Sent: Wednesday, June 13, 2007 3:44 PM
To: Segher Boessenkool
Cc: linuxppc-dev list; Paul Mackerras
Subject: Re: [PATCH v4]: Fix e500 v2 core reboot bug =20

Quoted 9 lines · Segher Boessenkool
Quoted 9 lines
Quoted 9 lines
Quoted 1 line

+ printk (KERN_EMERG "Error: reset

control \

Quoted 1 line

+ register not mapped,

spinning!\n");

...(... "bla bla bla "

        "bla bla bla\n");

instead? Or there'll be a lot of whitespace in your string.

Quoted 9 lines
Quoted 1 line

I just do not know the difference of these two style.

Your code puts a bunch of extra whitespace in the string (all the tabs before "register not mapped"). Two strings after each other (like in my example) are just pasted together.

There is no real reason to break the string in two anyway, it is fine to have a more-than-80-char line in printk messages.

Quoted 9 lines

I separate it, because I am afraid I will be challenged by 80 char column rule.
=20
Please check the CodeStyle file and its example:
=20
Statements longer than 80 columns will be broken into sensible chunks. Descendants are always substantially shorter than the parent and are placed
substantially to the right. The same applies to function headers with

a

Quoted 7 lines

long
argument list. Long strings are as well broken into shorter strings. [snip]
void fun(int a, int b, int c)
{
if (condition)
printk(KERN_WARNING "Warning this is a long printk with

"

Quoted 1 line

"3 parameters a: %u b:

%u "

Quoted 4 lines
						"c: %u \n", a, b, c);
	else
		next_statement;
}

It will be good if you do:
+ printk (KERN_EMERG "Error: reset
control"
+ "register not mapped,
spinning!\n");

Instead of:
+ printk (KERN_EMERG "Error: reset control
\
+ register not mapped,
spinning!\n");

- Leo

#6 lore raw
Quoted 11 lines

It will be good if you do:

(quoted diff) +1 -0
+				printk (KERN_EMERG "Error: reset

control"

(quoted diff) +1 -0
+					"register not mapped,

spinning!\n");

Instead of:

(quoted diff) +1 -0
+				printk (KERN_EMERG "Error: reset control

\

(quoted diff) +1 -0
+					register not mapped,

spinning!\n");

Except you forgot a space. Too much whitespace in the resulting string is bad, but too little doesn't help either ;-)

Segher

#7 lore raw
Quoted 8 lines · Segher Boessenkool
Quoted 8 lines

It will be good if you do:
+ printk (KERN_EMERG "Error: reset
control"
+ "register not mapped,
spinning!\n");

Instead of:
+ printk (KERN_EMERG "Error: reset

Quoted 8 lines

control

Quoted 3 lines

\
+ register not mapped,
spinning!\n");

Except you forgot a space. Too much whitespace in the resulting string is bad, but too little doesn't help either ;-)

I noticed that space, except that I am not sure the difference between \
and ".
I decided to leave it as two line with " not \.
Thanks
Roy

#8 lore raw
Quoted 17 lines

-----Original Message-----
From: Zang Roy-r61911 [mailto:[email protected]]
Sent: Wednesday, June 13, 2007 4:07 PM
To: Segher Boessenkool
Cc: Li Yang-r58472; linuxppc-dev list; Paul Mackerras
Subject: Re: [PATCH v4]: Fix e500 v2 core reboot bug =20

Quoted 9 lines · Segher Boessenkool
Quoted 8 lines

It will be good if you do:
+ printk (KERN_EMERG "Error: reset
control"
+ "register not mapped,
spinning!\n");

Instead of:
+ printk (KERN_EMERG "Error: reset

control

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

\
+ register not mapped,
spinning!\n");

Except you forgot a space. Too much whitespace in the resulting string is bad, but too little doesn't help either ;-)

I noticed that space, except that I am not sure the difference between

\

Quoted 1 line

and ".

The difference is that you will get all the indentation in the next line into the string if you use \. :-)
The output will be "Error: reset control<tab><tab><tab><tab> register not mapped, spinning!\n"

- Leo

#9 lore raw
In reply to Segher Boessenkool

From: Roy Zang <[email protected]>

Fix the reset bug on 8548CDS board.
Begin from MPC8548 with e500 v2 core, a new reset
control register is added.
This register is used for the cpu reset.

---
Pick up this one :-(

 arch/powerpc/boot/dts/mpc8548cds.dts |    6 ++++++
 arch/powerpc/platforms/85xx/misc.c   |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)
arch/powerpc/boot/dts/mpc8548cds.dts +6 -0
index ad96381..0550a3c 100644
@@ -177,6 +177,12 @@
 			interrupt-parent = <&mpic>;
 		};
 
+		global-utilities@e0000 {	//global utilities reg
+			compatible = "fsl,mpc8548-guts";
+			reg = <e0000 1000>;
+			fsl,has-rstcr;
+		};
+
 		pci1: pci@8000 {
 			interrupt-map-mask = <1f800 0 0 7>;
 			interrupt-map = <
arch/powerpc/platforms/85xx/misc.c +32 -0
index 3e62fcb..4ac0b20 100644
@@ -13,11 +13,43 @@
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/prom.h>
+#include <sysdev/fsl_soc.h>
+
+static __be32 __iomem *rstcr;
 
 extern void abort(void);
 
+static int __init mpc85xx_rstcr(void)
+{
+	struct device_node *np;
+	np = of_find_node_by_name(NULL, "global-utilities");
+	if ((np && of_get_property(np, "fsl,has-rstcr", NULL))) {
+		const u32 *prop = of_get_property(np, "reg", NULL);
+		if (prop) {
+			/* map reset control register
+			 * 0xE00B0 is offset of reset control register
+			 */
+			rstcr = ioremap(get_immrbase() + *prop + 0xB0, 0xff);
+			if (!rstcr)
+				printk (KERN_EMERG "Error: reset control "
+						"register not mapped!\n");
+		}
+	} else
+		printk (KERN_INFO "rstcr compatible register does not exist!\n");
+	if (np)
+		of_node_put(np);
+	return 0;
+}
+
+arch_initcall(mpc85xx_rstcr);
+
 void mpc85xx_restart(char *cmd)
 {
 	local_irq_disable();
+	if (rstcr)
+		/* set reset control register */
+		out_be32(rstcr, 0x2);	/* HRESET_REQ */
 	abort();
 }
Signature · 1 line
1.5.1
#10 lore raw
Quoted 23 lines · On Jun 13, 2007, at 4:13 AM, Zang Roy-r61911 wrote:

From: Roy Zang <[email protected]>

Fix the reset bug on 8548CDS board.
Begin from MPC8548 with e500 v2 core, a new reset
control register is added.
This register is used for the cpu reset.

---
Pick up this one :-(

 arch/powerpc/boot/dts/mpc8548cds.dts |    6 ++++++
 arch/powerpc/platforms/85xx/misc.c   |   32 +++++++++++++++++++++++ 
+++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)
arch/powerpc/boot/dts/mpc8548cds.dts +0 -0
index ad96381..0550a3c 100644
@@ -177,6 +177,12 @@
 			interrupt-parent = <&mpic>;
 		};

arch/powerpc/boot/dts/mpc8548cds.dts line 188

Quoted 10 lines
arch/powerpc/boot/dts/mpc8548cds.dts +6 -0
 
+		global-utilities@e0000 {	//global utilities reg
+			compatible = "fsl,mpc8548-guts";
+			reg = <e0000 1000>;
+			fsl,has-rstcr;
+		};
+
 		pci1: pci@8000 {
 			interrupt-map-mask = <1f800 0 0 7>;
 			interrupt-map = <

Now that we resolved this can you work up a second patch to update Documentation/powerpc/booting-without-of.txt for this node.

- k

#11 lore raw
In reply to Zang Roy-r61911
Quoted 5 lines
Quoted 3 lines

There is no real reason to break the string in two anyway, it is fine to have a more-than-80-char line in printk messages.

I separate it, because I am afraid I will be challenged by 80 char column rule.

Yeah, I understand.

Quoted 1 line

Please check the CodeStyle file and its example:

[snip]

Quoted 1 line

If it does not matter, I'd like to put them in one line :-).

Current thinking on this seems to be that long literal strings are fine. You are right that some people might challenge you on this, of course ;-)

Segher

#12 lore raw

On Wed, 2007-06-13 at 15:54, Segher Boessenkool wrote:
[snip]

Quoted 6 lines
Quoted 2 lines

If it does not matter, I'd like to put them in one line :-).

Current thinking on this seems to be that long literal strings are fine. You are right that some people might challenge you on this, of course ;-)

Then, I will say Segher tell me to do that ...
Roy