[PATCH v2 8/8] board: ns3: start sp805 watchdog service
Stefan Roese
sr at denx.de
Wed Jun 10 13:03:02 CEST 2020
On 10.06.20 12:52, Rayagonda Kokatanur wrote:
> Start sp805 watchdog service.
>
> Parse wdt timeout from env and dts, give precedence to env
> timeout if defined. Set default timeout to 60s if both env
> and dts doesn't specifiy timeout.
>
> Stop the WDT in board late init and start the
> WDT service before giving control to Linux.
I don't really understand, why you need such a board specific
watchdog handling. You disable and enable it at some points? Why
exactly? Usually the common WDT IF is used and it enables and
services the WDT (if configured this way) until the OS is started.
Then the OS needs to service the WDT. If the OS fails here (doesn't
start correctly etc), then the board will reset via the WDT.
So what is missing in the commin WDT IF for your setup?
Thanks,
Stefan
> Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur at broadcom.com>
> Signed-off-by: Bharat Kumar Reddy Gooty <bharat.gooty at broadcom.com>
> Signed-off-by: Pramod Kumar <pramod.kumar at broadcom.com>
> ---
> Changes from v1:
> -Address review comments from Simon,
> -include <dm.h> instead of <dm/device.h> and <dm/uclass.h>
> -remove include <fdtdec.h> as its not required
> -Use if() instead of #if def
> -rearrange code in start_wdt()
> -remove #else part of #ifdef CONFIG_DT
>
> board/broadcom/bcmns3/ns3.c | 50 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 50 insertions(+)
>
> diff --git a/board/broadcom/bcmns3/ns3.c b/board/broadcom/bcmns3/ns3.c
> index 0dd78cde34..1ba6c3fe5d 100644
> --- a/board/broadcom/bcmns3/ns3.c
> +++ b/board/broadcom/bcmns3/ns3.c
> @@ -5,7 +5,10 @@
> */
>
> #include <common.h>
> +#include <dm.h>
> +#include <env.h>
> #include <fdt_support.h>
> +#include <wdt.h>
> #include <asm/io.h>
> #include <asm/gic.h>
> #include <asm/gic-v3.h>
> @@ -133,6 +136,13 @@ int board_init(void)
>
> int board_late_init(void)
> {
> + /*
> + * Default WDT service is started with 60 sec time out.
> + * Disable it and start before giving control to Linux.
> + */
> + if (CONFIG_IS_ENABLED(WDT))
> + wdt_stop(gd->watchdog_dev);
> +
> return 0;
> }
>
> @@ -184,12 +194,52 @@ void reset_cpu(ulong level)
> }
>
> #ifdef CONFIG_OF_BOARD_SETUP
> +
> +#ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS
> +#define CONFIG_WATCHDOG_TIMEOUT_MSECS (60 * 1000)
> +#endif
> +#define DEF_TIMEOUT_SEC (CONFIG_WATCHDOG_TIMEOUT_MSECS / 1000)
> +
> +static int start_wdt(void)
> +{
> + u32 timeout = DEF_TIMEOUT_SEC;
> + struct udevice *udev;
> + int rc = 0;
> + u32 wdt_enable;
> +
> + wdt_enable = env_get_ulong("wdt_enable", 16, 0);
> + printf("wdt_enable :%u\n", wdt_enable);
> + if (!wdt_enable)
> + return rc;
> +
> + rc = uclass_get_device(UCLASS_WDT, 0, &udev);
> + if (rc) {
> + printf("Failed to get wdt rc:%d\n", rc);
> + return rc;
> + }
> +
> + timeout = env_get_ulong("wdt_timeout_sec", 10, 0);
> + if (!timeout) {
> + if (CONFIG_IS_ENABLED(OF_CONTROL))
> + timeout = dev_read_u32_default(gd->watchdog_dev,
> + "timeout-sec",
> + DEF_TIMEOUT_SEC);
> + }
> + wdt_start(udev, timeout * 1000, 0);
> + printf("Started wdt (%ds timeout)\n", timeout);
> +
> + return rc;
> +}
> +
> int ft_board_setup(void *fdt, bd_t *bd)
> {
> gic_lpi_tables_init(BCM_NS3_GIC_LPI_BASE, MAX_GIC_REDISTRIBUTORS);
>
> mem_info_parse_fixup(fdt);
>
> + if (CONFIG_IS_ENABLED(WDT))
> + start_wdt();
> +
> return 0;
> }
> #endif /* CONFIG_OF_BOARD_SETUP */
>
Viele Grüße,
Stefan
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
More information about the U-Boot
mailing list