Skip to contentSkip to conversation

pxa: Add support for board specific reset function

PATCH New Lukasz Dalek 3 participants 10 messages Jan 12, 2013 – Jan 14, 2013 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 pxa: Add support for board specific reset function

Some boards have its own way to reset board. This patch adds support for board_reset() function which is called from reset_cpu() to do board specific actions before/instead main reset_cpu() actions.

---
 arch/arm/cpu/pxa/pxa2xx.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
arch/arm/cpu/pxa/pxa2xx.c +7 -0
index 09e8177..5520f4f 100644
@@ -284,12 +284,19 @@ void i2c_clk_enable(void)
 	writel(readl(CKEN) | CKEN14_I2C, CKEN);
 }
 
+void __attribute__((weak)) board_reset(void)
+{
+	/* do nothing */
+}
+
 void reset_cpu(ulong ignored) __attribute__((noreturn));
 
 void reset_cpu(ulong ignored)
 {
 	uint32_t tmp;
 
+	board_reset();
+
 	setbits_le32(OWER, OWER_WME);
 
 	tmp = readl(OSCR);
Signature · 1 line
1.7.8.6
#1 lore raw

PATCH 2/3 h2200: Add board reset support

Use Samsung S3CA410X01 companion chip to reset PDA.

---
 board/h2200/h2200.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
board/h2200/h2200.c +9 -0
index 720b06e..a716a3f 100644
@@ -32,6 +32,15 @@ int board_eth_init(bd_t *bis)
 	return 0;
 }
 
+void board_reset(void)
+{
+	/* Enable VLIO interface on Hamcop */
+	writeb(0x1, 0x4000);
+
+	/* Reset board (cold reset) */
+	writeb(0xff, 0x4002);
+}
+
 int board_init(void)
 {
 	/* We have RAM, disable cache */
Signature · 1 line
1.7.8.6
#2 lore raw

PATCH 2/3 h2200: Add board reset support

Dear Lukasz Dalek,

Quoted 13 lines

Use Samsung S3CA410X01 companion chip to reset PDA.

---
 board/h2200/h2200.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
board/h2200/h2200.c +0 -0
index 720b06e..a716a3f 100644
@@ -32,6 +32,15 @@ int board_eth_init(bd_t *bis)
 	return 0;

board/h2200/h2200.c int board_eth_init(bd_t *bis) · line 42

Quoted 10 lines
board/h2200/h2200.c +8 -0
 }
 
+void board_reset(void)
+{
+	/* Enable VLIO interface on Hamcop */
+	writeb(0x1, 0x4000);
+
+	/* Reset board (cold reset) */
+	writeb(0xff, 0x4002);
+}

Can you not reimplement reset_cpu() ?

board/h2200/h2200.c int board_eth_init(bd_t *bis) · line 46

Quoted 3 lines
board/h2200/h2200.c +0 -0
 int board_init(void)
 {
 	/* We have RAM, disable cache */

Best regards,
Marek Vasut

#3 lore raw

PATCH 2/3 h2200: Add board reset support

Quoted 11 lines · Marek Vasut

Dear Lukasz Dalek,

board/h2200/h2200.c +8 -0
+void board_reset(void)
+{
+	/* Enable VLIO interface on Hamcop */
+	writeb(0x1, 0x4000);
+
+	/* Reset board (cold reset) */
+	writeb(0xff, 0x4002);
+}
Quoted 1 line

Can you not reimplement reset_cpu() ?

reset_cpu() doesn't have __attribute__((weak)) so if I would try to implement it
compiler will return with error.

Yours sincerely,
?ukasz Da?ek

#4 lore raw

PATCH 2/3 h2200: Add board reset support

Dear ?ukasz Da?ek,

Quoted 17 lines · Marek Vasut
Quoted 11 lines

Dear Lukasz Dalek,

board/h2200/h2200.c +8 -0
+void board_reset(void)
+{
+	/* Enable VLIO interface on Hamcop */
+	writeb(0x1, 0x4000);
+
+	/* Reset board (cold reset) */
+	writeb(0xff, 0x4002);
+}
Quoted 1 line

Can you not reimplement reset_cpu() ?

reset_cpu() doesn't have __attribute__((weak)) so if I would try to implement it
compiler will return with error.

Add it? Wasn't there similar patch already for some altera device?

Best regards,
Marek Vasut

#5 lore raw

PATCH v2 1/1 h2200: Add board reset support

Use Samsung S3CA410X01 companion chip to reset PDA.

---
Changes for v2:
- Reimplement reset_cpu() instead of board_reset()

---
 board/h2200/h2200.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
board/h2200/h2200.c +9 -0
index 720b06e..738e480 100644
@@ -32,6 +32,15 @@ int board_eth_init(bd_t *bis)
 	return 0;
 }
 
+void reset_cpu(ulong ignore)
+{
+	/* Enable VLIO interface on Hamcop */
+	writeb(0x1, 0x4000);
+
+	/* Reset board (cold reset) */
+	writeb(0xff, 0x4002);
+}
+
 int board_init(void)
 {
 	/* We have RAM, disable cache */
Signature · 1 line
1.7.8.6
#6 lore raw

PATCH 1/1 pxa: Add weak attribute to reset_cpu() function

This commit allows pxa2xx based boards to reimplement reset_cpu() function with board specific reset sequence.

---
 arch/arm/cpu/pxa/pxa2xx.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/cpu/pxa/pxa2xx.c +1 -1
index 09e8177..0c18610 100644
@@ -284,7 +284,7 @@ void i2c_clk_enable(void)
 	writel(readl(CKEN) | CKEN14_I2C, CKEN);
 }
 
-void reset_cpu(ulong ignored) __attribute__((noreturn));
+void __attribute__((weak)) reset_cpu(ulong ignored) __attribute__((noreturn));
 
 void reset_cpu(ulong ignored)
 {
Signature · 1 line
1.7.8.6
#7 lore raw

PATCH 3/3 pxa: Save lr register in relocate_code function

In reply to Lukasz Dalek

When u-boot is compiled for PXA25x processor, pxa/start.S is calling cpu_init_crit by BL instruction. BL is overwriting lr register so relocate_code is going into infinite loop. This patch preservs lr register in r12 before calling cpu_init_crit and after function returns restores it.

---
 arch/arm/cpu/pxa/start.S |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/cpu/pxa/start.S +2 -0
index 72af869..e71803e 100644
@@ -183,7 +183,9 @@ relocate_code:
 
 /* Disable the Dcache RAM lock for stack now */
 #ifdef	CONFIG_CPU_PXA25X
+	mov	r12, lr
 	bl	cpu_init_crit
+	mov	lr, r12
 #endif
 
 	adr	r0, _start
Signature · 1 line
1.7.8.6
#8 lore raw

PATCH 3/3 pxa: Save lr register in relocate_code function

Dear Lukasz Dalek,

Quoted 7 lines

When u-boot is compiled for PXA25x processor, pxa/start.S is calling cpu_init_crit by BL instruction. BL is overwriting lr register so relocate_code is going into infinite loop. This patch preservs lr register in r12 before calling cpu_init_crit and after function returns restores it.

Tom/Albert, can you please apply this for .01, seems critical to me ?

Quoted 9 lines
---
 arch/arm/cpu/pxa/start.S |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/cpu/pxa/start.S +0 -0
index 72af869..e71803e 100644

arch/arm/cpu/pxa/start.S relocate_code: · line 191

Quoted 9 lines
arch/arm/cpu/pxa/start.S +2 -0
@@ -183,7 +183,9 @@ relocate_code:
 
 /* Disable the Dcache RAM lock for stack now */
 #ifdef	CONFIG_CPU_PXA25X
+	mov	r12, lr
 	bl	cpu_init_crit
+	mov	lr, r12
 #endif
 
 	adr	r0, _start

Best regards,
Marek Vasut

#9 lore raw

PATCH 3/3 pxa: Save lr register in relocate_code function

In reply to Lukasz Dalek
Quoted 8 lines · Lukasz Dalek

When u-boot is compiled for PXA25x processor, pxa/start.S is calling cpu_init_crit by BL instruction. BL is overwriting lr register so relocate_code is going into infinite loop. This patch preservs lr register in r12 before calling cpu_init_crit and after function returns restores it.

This portion of the series is now applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130114/0b7a6579/attachment.pgp>