[U-Boot] [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.
Signed-off-by: Lukasz Dalek luk0104@gmail.com --- arch/arm/cpu/pxa/pxa2xx.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/pxa/pxa2xx.c b/arch/arm/cpu/pxa/pxa2xx.c index 09e8177..5520f4f 100644 --- a/arch/arm/cpu/pxa/pxa2xx.c +++ b/arch/arm/cpu/pxa/pxa2xx.c @@ -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);

Use Samsung S3CA410X01 companion chip to reset PDA.
Signed-off-by: Lukasz Dalek luk0104@gmail.com --- board/h2200/h2200.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/board/h2200/h2200.c b/board/h2200/h2200.c index 720b06e..a716a3f 100644 --- a/board/h2200/h2200.c +++ b/board/h2200/h2200.c @@ -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 */

Dear Lukasz Dalek,
Use Samsung S3CA410X01 companion chip to reset PDA.
Signed-off-by: Lukasz Dalek luk0104@gmail.com
board/h2200/h2200.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/board/h2200/h2200.c b/board/h2200/h2200.c index 720b06e..a716a3f 100644 --- a/board/h2200/h2200.c +++ b/board/h2200/h2200.c @@ -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);
+}
Can you not reimplement reset_cpu() ?
int board_init(void) { /* We have RAM, disable cache */
Best regards, Marek Vasut

On 13.01.2013 00:54, Marek Vasut wrote:
Dear Lukasz Dalek,
+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() ?
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

Dear Łukasz Dałek,
On 13.01.2013 00:54, Marek Vasut wrote:
Dear Lukasz Dalek,
+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() ?
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

Use Samsung S3CA410X01 companion chip to reset PDA.
Signed-off-by: Lukasz Dalek luk0104@gmail.com --- Changes for v2: - Reimplement reset_cpu() instead of board_reset() --- board/h2200/h2200.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/board/h2200/h2200.c b/board/h2200/h2200.c index 720b06e..738e480 100644 --- a/board/h2200/h2200.c +++ b/board/h2200/h2200.c @@ -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 */

This commit allows pxa2xx based boards to reimplement reset_cpu() function with board specific reset sequence.
Signed-off-by: Lukasz Dalek luk0104@gmail.com --- arch/arm/cpu/pxa/pxa2xx.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/arm/cpu/pxa/pxa2xx.c b/arch/arm/cpu/pxa/pxa2xx.c index 09e8177..0c18610 100644 --- a/arch/arm/cpu/pxa/pxa2xx.c +++ b/arch/arm/cpu/pxa/pxa2xx.c @@ -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) {

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.
Signed-off-by: Lukasz Dalek luk0104@gmail.com --- arch/arm/cpu/pxa/start.S | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/pxa/start.S b/arch/arm/cpu/pxa/start.S index 72af869..e71803e 100644 --- a/arch/arm/cpu/pxa/start.S +++ b/arch/arm/cpu/pxa/start.S @@ -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

Dear 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.
Signed-off-by: Lukasz Dalek luk0104@gmail.com
Acked-by: Marek Vasut marex@denx.de
Tom/Albert, can you please apply this for .01, seems critical to me ?
arch/arm/cpu/pxa/start.S | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/pxa/start.S b/arch/arm/cpu/pxa/start.S index 72af869..e71803e 100644 --- a/arch/arm/cpu/pxa/start.S +++ b/arch/arm/cpu/pxa/start.S @@ -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

On Sat, Jan 12, 2013 at 11:39:27AM -0000, Lukasz Dalek wrote:
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.
Signed-off-by: Lukasz Dalek luk0104@gmail.com Acked-by: Marek Vasut marex@denx.de
This portion of the series is now applied to u-boot/master, thanks!
participants (4)
-
Lukasz Dalek
-
Marek Vasut
-
Tom Rini
-
Łukasz Dałek