public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/3] pxa: Add support for board specific reset function
@ 2013-01-12 21:39 Lukasz Dalek
  2013-01-12 21:39 ` [U-Boot] [PATCH 2/3] h2200: Add board reset support Lukasz Dalek
  2013-01-12 21:39 ` [U-Boot] [PATCH 3/3] pxa: Save lr register in relocate_code function Lukasz Dalek
  0 siblings, 2 replies; 10+ messages in thread
From: Lukasz Dalek @ 2013-01-12 21:39 UTC (permalink / raw)
  To: u-boot

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);
-- 
1.7.8.6

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

* [U-Boot] [PATCH 2/3] h2200: Add board reset support
  2013-01-12 21:39 [U-Boot] [PATCH 1/3] pxa: Add support for board specific reset function Lukasz Dalek
@ 2013-01-12 21:39 ` Lukasz Dalek
  2013-01-12 23:54   ` Marek Vasut
  2013-01-12 21:39 ` [U-Boot] [PATCH 3/3] pxa: Save lr register in relocate_code function Lukasz Dalek
  1 sibling, 1 reply; 10+ messages in thread
From: Lukasz Dalek @ 2013-01-12 21:39 UTC (permalink / raw)
  To: u-boot

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 */
-- 
1.7.8.6

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

* [U-Boot] [PATCH 3/3] pxa: Save lr register in relocate_code function
  2013-01-12 21:39 [U-Boot] [PATCH 1/3] pxa: Add support for board specific reset function Lukasz Dalek
  2013-01-12 21:39 ` [U-Boot] [PATCH 2/3] h2200: Add board reset support Lukasz Dalek
@ 2013-01-12 21:39 ` Lukasz Dalek
  2013-01-12 23:53   ` Marek Vasut
  2013-01-14 23:23   ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 2 replies; 10+ messages in thread
From: Lukasz Dalek @ 2013-01-12 21:39 UTC (permalink / raw)
  To: u-boot

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
-- 
1.7.8.6

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

* [U-Boot] [PATCH 3/3] pxa: Save lr register in relocate_code function
  2013-01-12 21:39 ` [U-Boot] [PATCH 3/3] pxa: Save lr register in relocate_code function Lukasz Dalek
@ 2013-01-12 23:53   ` Marek Vasut
  2013-01-14 23:23   ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 10+ messages in thread
From: Marek Vasut @ 2013-01-12 23:53 UTC (permalink / raw)
  To: u-boot

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

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

* [U-Boot] [PATCH 2/3] h2200: Add board reset support
  2013-01-12 21:39 ` [U-Boot] [PATCH 2/3] h2200: Add board reset support Lukasz Dalek
@ 2013-01-12 23:54   ` Marek Vasut
  2013-01-13  1:00     ` Łukasz Dałek
  0 siblings, 1 reply; 10+ messages in thread
From: Marek Vasut @ 2013-01-12 23:54 UTC (permalink / raw)
  To: u-boot

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

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

* [U-Boot] [PATCH 2/3] h2200: Add board reset support
  2013-01-12 23:54   ` Marek Vasut
@ 2013-01-13  1:00     ` Łukasz Dałek
  2013-01-13  1:05       ` Marek Vasut
  0 siblings, 1 reply; 10+ messages in thread
From: Łukasz Dałek @ 2013-01-13  1:00 UTC (permalink / raw)
  To: u-boot

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

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

* [U-Boot] [PATCH 2/3] h2200: Add board reset support
  2013-01-13  1:00     ` Łukasz Dałek
@ 2013-01-13  1:05       ` Marek Vasut
  2013-01-13  1:32         ` [U-Boot] [PATCH v2] " Lukasz Dalek
  0 siblings, 1 reply; 10+ messages in thread
From: Marek Vasut @ 2013-01-13  1:05 UTC (permalink / raw)
  To: u-boot

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

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

* [U-Boot] [PATCH v2] h2200: Add board reset support
  2013-01-13  1:05       ` Marek Vasut
@ 2013-01-13  1:32         ` Lukasz Dalek
  2013-01-13  1:32           ` [U-Boot] [PATCH] pxa: Add weak attribute to reset_cpu() function Lukasz Dalek
  0 siblings, 1 reply; 10+ messages in thread
From: Lukasz Dalek @ 2013-01-13  1:32 UTC (permalink / raw)
  To: u-boot

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 */
-- 
1.7.8.6

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

* [U-Boot] [PATCH] pxa: Add weak attribute to reset_cpu() function
  2013-01-13  1:32         ` [U-Boot] [PATCH v2] " Lukasz Dalek
@ 2013-01-13  1:32           ` Lukasz Dalek
  0 siblings, 0 replies; 10+ messages in thread
From: Lukasz Dalek @ 2013-01-13  1:32 UTC (permalink / raw)
  To: u-boot

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)
 {
-- 
1.7.8.6

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

* [U-Boot] [U-Boot, 3/3] pxa: Save lr register in relocate_code function
  2013-01-12 21:39 ` [U-Boot] [PATCH 3/3] pxa: Save lr register in relocate_code function Lukasz Dalek
  2013-01-12 23:53   ` Marek Vasut
@ 2013-01-14 23:23   ` Tom Rini
  1 sibling, 0 replies; 10+ messages in thread
From: Tom Rini @ 2013-01-14 23:23 UTC (permalink / raw)
  To: u-boot

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!

-- 
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>

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

end of thread, other threads:[~2013-01-14 23:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-12 21:39 [U-Boot] [PATCH 1/3] pxa: Add support for board specific reset function Lukasz Dalek
2013-01-12 21:39 ` [U-Boot] [PATCH 2/3] h2200: Add board reset support Lukasz Dalek
2013-01-12 23:54   ` Marek Vasut
2013-01-13  1:00     ` Łukasz Dałek
2013-01-13  1:05       ` Marek Vasut
2013-01-13  1:32         ` [U-Boot] [PATCH v2] " Lukasz Dalek
2013-01-13  1:32           ` [U-Boot] [PATCH] pxa: Add weak attribute to reset_cpu() function Lukasz Dalek
2013-01-12 21:39 ` [U-Boot] [PATCH 3/3] pxa: Save lr register in relocate_code function Lukasz Dalek
2013-01-12 23:53   ` Marek Vasut
2013-01-14 23:23   ` [U-Boot] [U-Boot, " Tom Rini

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