[U-Boot] [RFC 0/7] Beginning of migration of MPC8xx to DM model

This serie is the beginning of MPC8xx migration to DM model.
Please comment and help me get the good direction.
Christophe Leroy (7): powercp: mpc8xx: move commproc.h powerpc: mpc8xx: redistribute data in CPM dpram board: MCR3000: properly setup initial RAM board: MCR3000: Activate CONFIG_DM and CONFIG_OF_CONTROL powerpc: mpc8xx: move watchdog into drivers/watchdog drivers: watchdog: add a driver for the MPC8xx watchdog board: MCR3000: use new DM watchdog
arch/powerpc/Kconfig | 2 +- arch/powerpc/cpu/mpc8xx/Kconfig | 4 ++ arch/powerpc/cpu/mpc8xx/cpu.c | 15 +---- arch/powerpc/cpu/mpc8xx/cpu_init.c | 4 +- arch/powerpc/cpu/mpc8xx/immap.c | 2 +- arch/powerpc/cpu/mpc8xx/interrupts.c | 2 +- arch/powerpc/cpu/mpc8xx/start.S | 5 +- arch/powerpc/dts/Makefile | 16 +++++ arch/powerpc/dts/mcr3000.dts | 15 +++++ .../powerpc/include/asm/cpm_8xx.h | 16 ++--- board/cssi/MCR3000/MCR3000.c | 19 ++++++ board/cssi/MCR3000/u-boot.lds | 6 ++ configs/MCR3000_defconfig | 5 ++ drivers/net/mpc8xx_fec.c | 2 +- drivers/serial/serial_mpc8xx.c | 2 +- drivers/spi/mpc8xx_spi.c | 2 +- drivers/watchdog/Kconfig | 6 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/mpc8xx_wdt.c | 72 ++++++++++++++++++++++ include/configs/MCR3000.h | 8 ++- 20 files changed, 169 insertions(+), 35 deletions(-) create mode 100644 arch/powerpc/dts/Makefile create mode 100644 arch/powerpc/dts/mcr3000.dts rename include/commproc.h => arch/powerpc/include/asm/cpm_8xx.h (99%) create mode 100644 drivers/watchdog/mpc8xx_wdt.c

include/commproc.h is dedicated to the 8xx, rename it cpm_8xx.h and move it into arch/powerpc/include/asm
Signed-off-by: Christophe Leroy christophe.leroy@c-s.fr --- arch/powerpc/cpu/mpc8xx/cpu.c | 2 +- arch/powerpc/cpu/mpc8xx/cpu_init.c | 2 +- arch/powerpc/cpu/mpc8xx/immap.c | 2 +- arch/powerpc/cpu/mpc8xx/interrupts.c | 2 +- include/commproc.h => arch/powerpc/include/asm/cpm_8xx.h | 0 drivers/net/mpc8xx_fec.c | 2 +- drivers/serial/serial_mpc8xx.c | 2 +- drivers/spi/mpc8xx_spi.c | 2 +- 8 files changed, 7 insertions(+), 7 deletions(-) rename include/commproc.h => arch/powerpc/include/asm/cpm_8xx.h (100%)
diff --git a/arch/powerpc/cpu/mpc8xx/cpu.c b/arch/powerpc/cpu/mpc8xx/cpu.c index 4ed61e2d977..d3d46b097cd 100644 --- a/arch/powerpc/cpu/mpc8xx/cpu.c +++ b/arch/powerpc/cpu/mpc8xx/cpu.c @@ -21,9 +21,9 @@ #include <watchdog.h> #include <command.h> #include <mpc8xx.h> -#include <commproc.h> #include <netdev.h> #include <asm/cache.h> +#include <asm/cpm_8xx.h> #include <linux/compiler.h> #include <asm/io.h>
diff --git a/arch/powerpc/cpu/mpc8xx/cpu_init.c b/arch/powerpc/cpu/mpc8xx/cpu_init.c index 654d559eeb8..3dfea6125ea 100644 --- a/arch/powerpc/cpu/mpc8xx/cpu_init.c +++ b/arch/powerpc/cpu/mpc8xx/cpu_init.c @@ -9,7 +9,7 @@ #include <watchdog.h>
#include <mpc8xx.h> -#include <commproc.h> +#include <asm/cpm_8xx.h> #include <asm/io.h>
DECLARE_GLOBAL_DATA_PTR; diff --git a/arch/powerpc/cpu/mpc8xx/immap.c b/arch/powerpc/cpu/mpc8xx/immap.c index 0cbfe900771..8e732555baf 100644 --- a/arch/powerpc/cpu/mpc8xx/immap.c +++ b/arch/powerpc/cpu/mpc8xx/immap.c @@ -13,7 +13,7 @@ #include <command.h>
#include <asm/immap_8xx.h> -#include <commproc.h> +#include <asm/cpm_8xx.h> #include <asm/iopin_8xx.h> #include <asm/io.h>
diff --git a/arch/powerpc/cpu/mpc8xx/interrupts.c b/arch/powerpc/cpu/mpc8xx/interrupts.c index 846148ab986..20f9664f060 100644 --- a/arch/powerpc/cpu/mpc8xx/interrupts.c +++ b/arch/powerpc/cpu/mpc8xx/interrupts.c @@ -8,9 +8,9 @@ #include <common.h> #include <mpc8xx.h> #include <mpc8xx_irq.h> +#include <asm/cpm_8xx.h> #include <asm/processor.h> #include <asm/io.h> -#include <commproc.h>
/************************************************************************/
diff --git a/include/commproc.h b/arch/powerpc/include/asm/cpm_8xx.h similarity index 100% rename from include/commproc.h rename to arch/powerpc/include/asm/cpm_8xx.h diff --git a/drivers/net/mpc8xx_fec.c b/drivers/net/mpc8xx_fec.c index 71fe984a5dd..1dd41df18be 100644 --- a/drivers/net/mpc8xx_fec.c +++ b/drivers/net/mpc8xx_fec.c @@ -7,10 +7,10 @@
#include <common.h> #include <command.h> -#include <commproc.h> #include <malloc.h> #include <net.h> #include <netdev.h> +#include <asm/cpm_8xx.h> #include <asm/io.h>
#include <phy.h> diff --git a/drivers/serial/serial_mpc8xx.c b/drivers/serial/serial_mpc8xx.c index 26a8085a691..7a5908f4645 100644 --- a/drivers/serial/serial_mpc8xx.c +++ b/drivers/serial/serial_mpc8xx.c @@ -6,10 +6,10 @@ */
#include <common.h> -#include <commproc.h> #include <command.h> #include <serial.h> #include <watchdog.h> +#include <asm/cpm_8xx.h> #include <linux/compiler.h>
DECLARE_GLOBAL_DATA_PTR; diff --git a/drivers/spi/mpc8xx_spi.c b/drivers/spi/mpc8xx_spi.c index b5bd558526b..eb035e9510c 100644 --- a/drivers/spi/mpc8xx_spi.c +++ b/drivers/spi/mpc8xx_spi.c @@ -19,7 +19,7 @@
#include <common.h> #include <mpc8xx.h> -#include <commproc.h> +#include <asm/cpm_8xx.h> #include <linux/ctype.h> #include <malloc.h> #include <post.h>

Some malloc memory is needed at startup for DM model. Lets reorganise the use of the CPM dpram.
The MPC866/885 dpram, we have 8kbytes dual port RAM, which is usable as: IMMR + 0x2000..0x2800: BD/Data/Microcode IMMR + 0x2800..0x2e00: BD/Data IMMR + 0x2e00..0x3800: BD/Data/Microcode IMMR + 0x3800..0x3a00: BD/Data IMMR + 0x3a00..0x3c00: BD/Data/Microcode IMMR + 0x3c00..0x4000: Parameters for the Peripheral Controllers
Lets reallocate all BDs in the 3800..3a00 area and give the full 2800..2e00 for dynamic RAM allocation including global data
That way, the microcode areas remain available if needed on day
Signed-off-by: Christophe Leroy christophe.leroy@c-s.fr --- arch/powerpc/include/asm/cpm_8xx.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/include/asm/cpm_8xx.h b/arch/powerpc/include/asm/cpm_8xx.h index bd8adec6b07..85903d21088 100644 --- a/arch/powerpc/include/asm/cpm_8xx.h +++ b/arch/powerpc/include/asm/cpm_8xx.h @@ -51,14 +51,14 @@ /* * DPRAM defines and allocation functions */ -#define CPM_SERIAL_BASE 0x0800 -#define CPM_I2C_BASE 0x0820 -#define CPM_SPI_BASE 0x0840 -#define CPM_FEC_BASE 0x0860 -#define CPM_SERIAL2_BASE 0x08E0 -#define CPM_SCC_BASE 0x0900 -#define CPM_POST_BASE 0x0980 -#define CPM_WLKBD_BASE 0x0a00 +#define CPM_SERIAL_BASE 0x1800 +#define CPM_I2C_BASE 0x1820 +#define CPM_SPI_BASE 0x1840 +#define CPM_FEC_BASE 0x1860 +#define CPM_SERIAL2_BASE 0x18e0 +#define CPM_SCC_BASE 0x1900 +#define CPM_POST_BASE 0x1980 +#define CPM_WLKBD_BASE 0x1a00
#define BD_IIC_START ((uint) 0x0400) /* <- please use CPM_I2C_BASE !! */

In order to use CONFIG_DM, some initial RAM is needed for malloc()
Signed-off-by: Christophe Leroy christophe.leroy@c-s.fr --- arch/powerpc/cpu/mpc8xx/cpu_init.c | 2 +- arch/powerpc/cpu/mpc8xx/start.S | 5 +++-- include/configs/MCR3000.h | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/cpu/mpc8xx/cpu_init.c b/arch/powerpc/cpu/mpc8xx/cpu_init.c index 3dfea6125ea..f27ad86e393 100644 --- a/arch/powerpc/cpu/mpc8xx/cpu_init.c +++ b/arch/powerpc/cpu/mpc8xx/cpu_init.c @@ -28,7 +28,7 @@ void cpu_init_f(immap_t __iomem *immr)
gd = (gd_t *)(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET); /* Clear initial global data */ - memset((void *)gd, 0, sizeof(*gd)); + board_init_f_init_reserve((ulong)gd);
/* SYPCR - contains watchdog control (11-9) */
diff --git a/arch/powerpc/cpu/mpc8xx/start.S b/arch/powerpc/cpu/mpc8xx/start.S index 202ea81ae49..781bcd887e0 100644 --- a/arch/powerpc/cpu/mpc8xx/start.S +++ b/arch/powerpc/cpu/mpc8xx/start.S @@ -130,8 +130,9 @@ in_flash: /* initialize some SPRs that are hard to access from C */ /*----------------------------------------------------------------------*/
- lis r3, CONFIG_SYS_IMMR@h /* pass IMMR as arg1 to C routine */ - ori r1, r3, CONFIG_SYS_INIT_SP_OFFSET /* set up the stack in internal DPRAM */ + /* set up the stack in internal DPRAM */ + lis r3, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)@h + ori r1, r3, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)@l /* Note: R0 is still 0 here */ stwu r0, -4(r1) /* clear final stack frame so that */ stwu r0, -4(r1) /* stack backtraces terminate cleanly */ diff --git a/include/configs/MCR3000.h b/include/configs/MCR3000.h index 2b49f97e091..7f31c427791 100644 --- a/include/configs/MCR3000.h +++ b/include/configs/MCR3000.h @@ -70,11 +70,12 @@ #define CONFIG_SYS_HZ 1000
/* Definitions for initial stack pointer and data area (in DPRAM) */ -#define CONFIG_SYS_INIT_RAM_ADDR CONFIG_SYS_IMMR -#define CONFIG_SYS_INIT_RAM_SIZE 0x2f00 +#define CONFIG_SYS_INIT_RAM_ADDR (CONFIG_SYS_IMMR + 0x2800) +#define CONFIG_SYS_INIT_RAM_SIZE (0x2e00 - 0x2800) #define CONFIG_SYS_GBL_DATA_SIZE 64 #define CONFIG_SYS_GBL_DATA_OFFSET (CONFIG_SYS_INIT_RAM_SIZE - \ - CONFIG_SYS_GBL_DATA_SIZE) + CONFIG_SYS_GBL_DATA_SIZE - \ + CONFIG_SYS_MALLOC_F_LEN) #define CONFIG_SYS_INIT_SP_OFFSET CONFIG_SYS_GBL_DATA_OFFSET
/* RAM configuration (note that CONFIG_SYS_SDRAM_BASE must be zero) */

Add mcr3000 device tree and activate CONFIG_DM and CONFIG_OF_CONTROL
Signed-off-by: Christophe Leroy christophe.leroy@c-s.fr --- arch/powerpc/dts/Makefile | 16 ++++++++++++++++ arch/powerpc/dts/mcr3000.dts | 12 ++++++++++++ board/cssi/MCR3000/u-boot.lds | 6 ++++++ configs/MCR3000_defconfig | 3 +++ 4 files changed, 37 insertions(+) create mode 100644 arch/powerpc/dts/Makefile create mode 100644 arch/powerpc/dts/mcr3000.dts
diff --git a/arch/powerpc/dts/Makefile b/arch/powerpc/dts/Makefile new file mode 100644 index 00000000000..c1c5d9c6dd3 --- /dev/null +++ b/arch/powerpc/dts/Makefile @@ -0,0 +1,16 @@ +# +# SPDX-License-Identifier: GPL-2.0+ +# + +dtb-$(CONFIG_MCR3000) += mcr3000.dtb + +targets += $(dtb-y) + +# Add any required device tree compiler flags here +DTC_FLAGS += + +PHONY += dtbs +dtbs: $(addprefix $(obj)/, $(dtb-y)) + @: + +clean-files := *.dtb diff --git a/arch/powerpc/dts/mcr3000.dts b/arch/powerpc/dts/mcr3000.dts new file mode 100644 index 00000000000..e4b222857b5 --- /dev/null +++ b/arch/powerpc/dts/mcr3000.dts @@ -0,0 +1,12 @@ +/* + * MCR3000 Device Tree Source + * + * Copyright 2017 CS Systemes d'Information + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +/dts-v1/; + +/ { +}; diff --git a/board/cssi/MCR3000/u-boot.lds b/board/cssi/MCR3000/u-boot.lds index 990cca4ebb6..46cbbab6c4b 100644 --- a/board/cssi/MCR3000/u-boot.lds +++ b/board/cssi/MCR3000/u-boot.lds @@ -70,6 +70,12 @@ SECTIONS __ex_table : { *(__ex_table) } __stop___ex_table = .;
+ /* + * _end - This is end of u-boot.bin image. + * dtb will be appended here to make u-boot-dtb.bin + */ + _end = .; + . = ALIGN(4096); __init_begin = .; .text.init : { *(.text.init) } diff --git a/configs/MCR3000_defconfig b/configs/MCR3000_defconfig index e32273cb2ee..4608f335748 100644 --- a/configs/MCR3000_defconfig +++ b/configs/MCR3000_defconfig @@ -73,3 +73,6 @@ CONFIG_LZMA=y CONFIG_OF_LIBFDT=y CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="run flashboot" +CONFIG_DM=y +CONFIG_OF_CONTROL=y +CONFIG_DEFAULT_DEVICE_TREE="mcr3000"

In preparation of DM watchdog, move basic actions into drivers/watchdog
Signed-off-by: Christophe Leroy christophe.leroy@c-s.fr --- arch/powerpc/Kconfig | 2 +- arch/powerpc/cpu/mpc8xx/Kconfig | 4 ++++ arch/powerpc/cpu/mpc8xx/cpu.c | 13 ------------- drivers/watchdog/Makefile | 1 + drivers/watchdog/mpc8xx_wdt.c | 21 +++++++++++++++++++++ 5 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 drivers/watchdog/mpc8xx_wdt.c
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index af45cfe8498..13a79560b24 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -34,7 +34,7 @@ config MPC8xx bool "MPC8xx" select BOARD_EARLY_INIT_F imply CMD_REGINFO - imply HW_WATCHDOG + imply MPC8xx_WATCHDOG
endchoice
diff --git a/arch/powerpc/cpu/mpc8xx/Kconfig b/arch/powerpc/cpu/mpc8xx/Kconfig index f1123173765..b0e90a0f203 100644 --- a/arch/powerpc/cpu/mpc8xx/Kconfig +++ b/arch/powerpc/cpu/mpc8xx/Kconfig @@ -25,6 +25,10 @@ config MPC885
endchoice
+config MPC8xx_WATCHDOG + bool "Watchdog" + select HW_WATCHDOG + config 8xx_GCLK_FREQ int "CPU GCLK Frequency"
diff --git a/arch/powerpc/cpu/mpc8xx/cpu.c b/arch/powerpc/cpu/mpc8xx/cpu.c index d3d46b097cd..7b1d2921b3e 100644 --- a/arch/powerpc/cpu/mpc8xx/cpu.c +++ b/arch/powerpc/cpu/mpc8xx/cpu.c @@ -272,19 +272,6 @@ unsigned long get_tbclk(void)
/* ------------------------------------------------------------------------- */
-#if defined(CONFIG_HW_WATCHDOG) -void hw_watchdog_reset(void) -{ - immap_t __iomem *immr = (immap_t __iomem *)CONFIG_SYS_IMMR; - int re_enable = disable_interrupts(); - - out_be16(&immr->im_siu_conf.sc_swsr, 0x556c); /* write magic1 */ - out_be16(&immr->im_siu_conf.sc_swsr, 0xaa39); /* write magic2 */ - if (re_enable) - enable_interrupts(); -} -#endif /* CONFIG_WATCHDOG */ - /* * Initializes on-chip ethernet controllers. * to override, implement board_eth_init() diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index ab6a6b79e1d..6c605e87e85 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -22,3 +22,4 @@ obj-$(CONFIG_WDT_ASPEED) += ast_wdt.o obj-$(CONFIG_WDT_BCM6345) += bcm6345_wdt.o obj-$(CONFIG_BCM2835_WDT) += bcm2835_wdt.o obj-$(CONFIG_WDT_ORION) += orion_wdt.o +obj-$(CONFIG_MPC8xx_WATCHDOG) += mpc8xx_wdt.o diff --git a/drivers/watchdog/mpc8xx_wdt.c b/drivers/watchdog/mpc8xx_wdt.c new file mode 100644 index 00000000000..ded80c4d6a9 --- /dev/null +++ b/drivers/watchdog/mpc8xx_wdt.c @@ -0,0 +1,21 @@ +/* + * Copyright 2017 CS Systemes d'Information + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <mpc8xx.h> +#include <asm/cpm_8xx.h> +#include <asm/io.h> + +DECLARE_GLOBAL_DATA_PTR; + +void hw_watchdog_reset(void) +{ + immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR; + + out_be16(&immap->im_siu_conf.sc_swsr, 0x556c); /* write magic1 */ + out_be16(&immap->im_siu_conf.sc_swsr, 0xaa39); /* write magic2 */ +} +

This patch adds a DM driver for the MPC8xx watchdog. Basically, the watchdog is enabled by default from the start and SYPCR register has to be writen once to set the timeout and/or deactivate the watchdog. Once written, it cannot be written again.
It means that wdt_stop() can be called before wdt_start() to stop the watchdog, but cannot be called if wdt_start() has been called.
Signed-off-by: Christophe Leroy christophe.leroy@c-s.fr --- drivers/watchdog/Kconfig | 6 +++++ drivers/watchdog/mpc8xx_wdt.c | 51 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+)
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index fc46b6774d5..15d79ee5e17 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -78,4 +78,10 @@ config WDT_ORION Select this to enable Orion watchdog timer, which can be found on some Marvell Armada chips.
+config WDT_MPC8xx + bool "MPC8xx watchdog timer support" + depends on WDT && MPC8xx + help + Select this to enable mpc8xx watchdog timer + endmenu diff --git a/drivers/watchdog/mpc8xx_wdt.c b/drivers/watchdog/mpc8xx_wdt.c index ded80c4d6a9..29b185f45b3 100644 --- a/drivers/watchdog/mpc8xx_wdt.c +++ b/drivers/watchdog/mpc8xx_wdt.c @@ -5,6 +5,8 @@ */
#include <common.h> +#include <dm.h> +#include <wdt.h> #include <mpc8xx.h> #include <asm/cpm_8xx.h> #include <asm/io.h> @@ -19,3 +21,52 @@ void hw_watchdog_reset(void) out_be16(&immap->im_siu_conf.sc_swsr, 0xaa39); /* write magic2 */ }
+#ifdef CONFIG_WDT_MPC8xx +static int mpc8xx_wdt_start(struct udevice *dev, u64 timeout, ulong flags) +{ + immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR; + + out_be32(&immap->im_siu_conf.sc_sypcr, CONFIG_SYS_SYPCR); + + if (!(in_be32(&immap->im_siu_conf.sc_sypcr) & SYPCR_SWE)) + return -EBUSY; + return 0; + +} + +static int mpc8xx_wdt_stop(struct udevice *dev) +{ + immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR; + + out_be32(&immap->im_siu_conf.sc_sypcr, CONFIG_SYS_SYPCR & ~SYPCR_SWE); + + if (in_be32(&immap->im_siu_conf.sc_sypcr) & SYPCR_SWE) + return -EBUSY; + return 0; +} + +static int mpc8xx_wdt_reset(struct udevice *dev) +{ + hw_watchdog_reset(); + + return 0; +} + +static const struct wdt_ops mpc8xx_wdt_ops = { + .start = mpc8xx_wdt_start, + .reset = mpc8xx_wdt_reset, + .stop = mpc8xx_wdt_stop, +}; + +static const struct udevice_id mpc8xx_wdt_ids[] = { + { .compatible = "fsl,pq1-wdt" }, + {} +}; + +U_BOOT_DRIVER(wdt_mpc8xx) = { + .name = "wdt_mpc8xx", + .id = UCLASS_WDT, + .of_match = mpc8xx_wdt_ids, + .ops = &mpc8xx_wdt_ops, +}; +#endif /* CONFIG_WDT_MPC8xx */

Signed-off-by: Christophe Leroy christophe.leroy@c-s.fr --- arch/powerpc/dts/mcr3000.dts | 3 +++ board/cssi/MCR3000/MCR3000.c | 19 +++++++++++++++++++ configs/MCR3000_defconfig | 2 ++ include/configs/MCR3000.h | 1 + 4 files changed, 25 insertions(+)
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 6939a2cf617..f3533baffa2 100644 --- a/board/cssi/MCR3000/MCR3000.c +++ b/board/cssi/MCR3000/MCR3000.c @@ -13,6 +13,8 @@ #include <mpc8xx.h> #include <fdt_support.h> #include <asm/io.h> +#include <dm/uclass.h> +#include <wdt.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -144,3 +146,20 @@ 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"); + if (IS_ENABLED(CONFIG_HW_WATCHDOG)) + wdt_start(watchdog_dev, 0xffff, 0); + else + wdt_stop(watchdog_dev); + } + + return 0; +} diff --git a/configs/MCR3000_defconfig b/configs/MCR3000_defconfig index 4608f335748..fe882fffe87 100644 --- a/configs/MCR3000_defconfig +++ b/configs/MCR3000_defconfig @@ -76,3 +76,5 @@ CONFIG_BOOTCOMMAND="run flashboot" CONFIG_DM=y CONFIG_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="mcr3000" +CONFIG_WDT=y +CONFIG_WDT_MPC8xx=y diff --git a/include/configs/MCR3000.h b/include/configs/MCR3000.h index 7f31c427791..186759fdecf 100644 --- a/include/configs/MCR3000.h +++ b/include/configs/MCR3000.h @@ -10,6 +10,7 @@
/* High Level Configuration Options */ #define CONFIG_MISC_INIT_R 1 /* Call misc_init_r */ +#define CONFIG_BOARD_EARLY_INIT_R 1
#define CONFIG_EXTRA_ENV_SETTINGS \ "sdram_type=SDRAM\0" \
participants (1)
-
Christophe Leroy