From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1] watchdog: Introduce watchdog driver for Intel Tangier
Date: Tue, 18 Apr 2017 16:49:26 +0200 [thread overview]
Message-ID: <20170418164926.040301f7@jawa> (raw)
In-Reply-To: <20170418135149.39798-1-andriy.shevchenko@linux.intel.com>
Hi Andy,
> From: Felipe Balbi <felipe.balbi@linux.intel.com>
>
> Add watchdog driver for Intel Tangier based platforms.
>
> Signed-off-by: Vincent Tinelli <vincent.tinelli@intel.com>
> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> common/board_f.c | 1 +
> drivers/watchdog/Kconfig | 8 ++++++
> drivers/watchdog/Makefile | 1 +
> drivers/watchdog/tangier_wdt.c | 63
> ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 73
> insertions(+) create mode 100644 drivers/watchdog/tangier_wdt.c
>
> diff --git a/common/board_f.c b/common/board_f.c
> index d9431ee79a..ad1eae98a5 100644
> --- a/common/board_f.c
> +++ b/common/board_f.c
> @@ -91,6 +91,7 @@ static int init_func_watchdog_init(void)
> (defined(CONFIG_M68K) || defined(CONFIG_MICROBLAZE) || \
> defined(CONFIG_SH) || defined(CONFIG_AT91SAM9_WATCHDOG) || \
> defined(CONFIG_DESIGNWARE_WATCHDOG) || \
> + defined(CONFIG_TANGIER_WATCHDOG) || \
> defined(CONFIG_IMX_WATCHDOG))
I have stumbled upon similar patch... There should be new Kconfig
option created and enabled in required SoCs.
> hw_watchdog_init();
> puts(" Watchdog enabled\n");
> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index dbdaafc149..66fe70dba1 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -1,5 +1,13 @@
> menu "WATCHDOG support"
>
> +config TANGIER_WATCHDOG
> + bool "Intel Tangier watchdog"
> + depends on INTEL_MID
> + help
> + This enables support for watchdog controller available on
> + Intel Tangier SoC. If you're using a board with Intel
> Tangier
> + SoC, say Y here.
> +
> config ULP_WATCHDOG
> bool "i.MX7ULP watchdog"
> help
> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> index dea18363ca..7b77d8379f 100644
> --- a/drivers/watchdog/Makefile
> +++ b/drivers/watchdog/Makefile
> @@ -15,4 +15,5 @@ obj-$(CONFIG_XILINX_TB_WATCHDOG) += xilinx_tb_wdt.o
> obj-$(CONFIG_BFIN_WATCHDOG) += bfin_wdt.o
> obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o
> obj-$(CONFIG_DESIGNWARE_WATCHDOG) += designware_wdt.o
> +obj-$(CONFIG_TANGIER_WATCHDOG) += tangier_wdt.o
> obj-$(CONFIG_ULP_WATCHDOG) += ulp_wdog.o
> diff --git a/drivers/watchdog/tangier_wdt.c
> b/drivers/watchdog/tangier_wdt.c new file mode 100644
> index 0000000000..23be71a42f
> --- /dev/null
> +++ b/drivers/watchdog/tangier_wdt.c
> @@ -0,0 +1,63 @@
> +/*
> + * Copyright (c) 2017 Intel Corporation
> + *
> + * SPDX-License-Identifier: GPL-2.0+
> + */
> +#include <common.h>
> +#include <watchdog.h>
> +#include <asm/scu.h>
> +
> +/* Hardware timeout in seconds */
> +#ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS
> +#define WATCHDOG_HEARTBEAT 60000
> +#else
> +#define WATCHDOG_HEARTBEAT CONFIG_WATCHDOG_TIMEOUT_MSECS
> +#endif
> +
> +enum {
> + SCU_WATCHDOG_START = 0,
> + SCU_WATCHDOG_STOP = 1,
> + SCU_WATCHDOG_KEEPALIVE = 2,
> + SCU_WATCHDOG_SET_ACTION_ON_TIMEOUT = 3,
> +};
> +
> +void hw_watchdog_reset(void)
> +{
> + static unsigned long prev;
> + unsigned long now;
> +
> + if (gd->timer)
> + now = timer_get_us();
> + else
> + now = rdtsc() / 1000000;
> +
> + /* Do not flood SCU */
> + if (unlikely((now - prev) > (WATCHDOG_HEARTBEAT * 1000))) {
> + prev = now;
> + scu_ipc_simple_command(IPCMSG_WATCHDOG_TIMER,
> SCU_WATCHDOG_KEEPALIVE);
> + }
> +}
> +
> +int hw_watchdog_disable(void)
> +{
> + return scu_ipc_simple_command(IPCMSG_WATCHDOG_TIMER,
> SCU_WATCHDOG_STOP); +}
> +
> +void hw_watchdog_init(void)
> +{
> + u32 timeout = WATCHDOG_HEARTBEAT / 1000;
> + int in_size;
> + struct ipc_wd_start {
> + u32 pretimeout;
> + u32 timeout;
> + } ipc_wd_start = { timeout, timeout };
> +
> + /*
> + * SCU expects the input size for watchdog IPC
> + * to be based on 4 bytes
> + */
> + in_size = DIV_ROUND_UP(sizeof(ipc_wd_start), 4);
> +
> + scu_ipc_command(IPCMSG_WATCHDOG_TIMER, SCU_WATCHDOG_START,
> + (u32 *)&ipc_wd_start, in_size, NULL, 0);
> +}
The code seems OK, but recently patches to add wdt-uclass has been
posted:
http://patchwork.ozlabs.org/patch/751448/
http://patchwork.ozlabs.org/patch/751451/
Maybe it would be better to port this driver to the uclass from the
very beginning?
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
next prev parent reply other threads:[~2017-04-18 14:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-18 13:51 [U-Boot] [PATCH v1] watchdog: Introduce watchdog driver for Intel Tangier Andy Shevchenko
2017-04-18 14:49 ` Lukasz Majewski [this message]
2017-04-18 14:57 ` Andy Shevchenko
2017-04-18 16:30 ` Tom Rini
2017-07-04 19:48 ` Andy Shevchenko
2017-07-04 20:31 ` Tom Rini
2017-07-04 20:41 ` Andy Shevchenko
2017-07-04 21:23 ` lukma
2017-07-04 22:36 ` Andy Shevchenko
2017-07-05 15:59 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170418164926.040301f7@jawa \
--to=lukma@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.