[U-Boot,4/9] board: MCR3000: use new DM watchdog

Message ID eef5ebf941c7ccece83f7095b70da9a80eb2bdae.1541455253.git.christophe.leroy@c-s.fr
State Changes Requested
Delegated to: Tom Rini
Headers show
Series
  • [U-Boot,1/9] powerpc, mpc8xx: clear top of stack
Related show

Commit Message

Christophe Leroy Nov. 6, 2018, 11:25 a.m.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/dts/mcr3000.dts |  3 +++
 board/cssi/MCR3000/MCR3000.c | 16 ++++++++++++++++
 configs/MCR3000_defconfig    |  3 +++
 3 files changed, 22 insertions(+)

Comments

Tom Rini Nov. 20, 2018, 2:56 p.m. | #1
On Tue, Nov 06, 2018 at 11:25:41AM +0000, Christophe Leroy wrote:

> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
>  arch/powerpc/dts/mcr3000.dts |  3 +++
>  board/cssi/MCR3000/MCR3000.c | 16 ++++++++++++++++
>  configs/MCR3000_defconfig    |  3 +++
>  3 files changed, 22 insertions(+)

This fails to build for me in travis currently:
   powerpc:  +   MCR3000
+(MCR3000) u-boot.lds:12 cannot move location counter backwards (from 000000000400400c to 0000000004004000)
+(MCR3000) make[1]: *** [u-boot] Error 1
+(MCR3000) make: *** [sub-make] Error 2
Christophe Leroy Nov. 20, 2018, 4:14 p.m. | #2
Le 20/11/2018 à 15:56, Tom Rini a écrit :
> On Tue, Nov 06, 2018 at 11:25:41AM +0000, Christophe Leroy wrote:
> 
>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>> ---
>>   arch/powerpc/dts/mcr3000.dts |  3 +++
>>   board/cssi/MCR3000/MCR3000.c | 16 ++++++++++++++++
>>   configs/MCR3000_defconfig    |  3 +++
>>   3 files changed, 22 insertions(+)
> 
> This fails to build for me in travis currently:
>     powerpc:  +   MCR3000
> +(MCR3000) u-boot.lds:12 cannot move location counter backwards (from 000000000400400c to 0000000004004000)
> +(MCR3000) make[1]: *** [u-boot] Error 1
> +(MCR3000) make: *** [sub-make] Error 2

This means your compiler generates bigger code than mine.

u-boot.lds needs to be adjusted manually for each version of compiler, 
so that the amount of text before env_offset is just enough but not too 
much.

Christophe
Tom Rini Nov. 20, 2018, 4:23 p.m. | #3
On Tue, Nov 20, 2018 at 05:14:14PM +0100, Christophe LEROY wrote:

> Le 20/11/2018 à 15:56, Tom Rini a écrit :
> >On Tue, Nov 06, 2018 at 11:25:41AM +0000, Christophe Leroy wrote:
> >
> >>Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> >>---
> >>  arch/powerpc/dts/mcr3000.dts |  3 +++
> >>  board/cssi/MCR3000/MCR3000.c | 16 ++++++++++++++++
> >>  configs/MCR3000_defconfig    |  3 +++
> >>  3 files changed, 22 insertions(+)
> >
> >This fails to build for me in travis currently:
> >    powerpc:  +   MCR3000
> >+(MCR3000) u-boot.lds:12 cannot move location counter backwards (from 000000000400400c to 0000000004004000)
> >+(MCR3000) make[1]: *** [u-boot] Error 1
> >+(MCR3000) make: *** [sub-make] Error 2
> 
> This means your compiler generates bigger code than mine.
> 
> u-boot.lds needs to be adjusted manually for each version of compiler, so
> that the amount of text before env_offset is just enough but not too much.

Right.  Please note that for various reasons, the toolchains used by
buildman (which in turn are the kernel.org ones that're generally
encouraged to be used when just "a" compiler is needed, outside of the
U-Boot community even) must succeed :)  Please re-submit the series
with it passing a run in travis, or at least a buildman of all powerpc
with that toolchain, thanks!

Patch

diff --git a/arch/powerpc/dts/mcr3000.dts b/arch/powerpc/dts/mcr3000.dts
index e4b222857b5..ef423d73c20 100644
--- a/arch/powerpc/dts/mcr3000.dts
+++ b/arch/powerpc/dts/mcr3000.dts
@@ -9,4 +9,7 @@ 
 /dts-v1/;
 
 / {
+	WDT: watchdog@0 {
+		compatible = "fsl,pq1-wdt";
+	};
 };
diff --git a/board/cssi/MCR3000/MCR3000.c b/board/cssi/MCR3000/MCR3000.c
index ffbeb14ed0f..d26ac35b440 100644
--- a/board/cssi/MCR3000/MCR3000.c
+++ b/board/cssi/MCR3000/MCR3000.c
@@ -12,6 +12,8 @@ 
 #include <mpc8xx.h>
 #include <fdt_support.h>
 #include <asm/io.h>
+#include <dm/uclass.h>
+#include <wdt.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -143,3 +145,17 @@  int board_early_init_f(void)
 
 	return 0;
 }
+
+int board_early_init_r(void)
+{
+	struct udevice *watchdog_dev = NULL;
+
+	if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) {
+		puts("Cannot find watchdog!\n");
+	} else {
+		puts("Enabling watchdog.\n");
+		wdt_start(watchdog_dev, 0xffff, 0);
+	}
+
+	return 0;
+}
diff --git a/configs/MCR3000_defconfig b/configs/MCR3000_defconfig
index 6d7dda82a21..2e79425bdbc 100644
--- a/configs/MCR3000_defconfig
+++ b/configs/MCR3000_defconfig
@@ -42,6 +42,7 @@  CONFIG_BOOTDELAY=5
 CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="run flashboot"
 CONFIG_MISC_INIT_R=y
+CONFIG_BOARD_EARLY_INIT_R=y
 CONFIG_HUSH_PARSER=y
 # CONFIG_AUTO_COMPLETE is not set
 CONFIG_SYS_PROMPT="S3K> "
@@ -76,3 +77,5 @@  CONFIG_OF_LIBFDT=y
 CONFIG_DM=y
 CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="mcr3000"
+CONFIG_WDT=y
+CONFIG_WDT_MPC8xx=y