* [PATCH u-boot-mvebu] watchdog: armada_37xx: Probe driver also when watchdog is already running
@ 2022-02-23 13:21 Pali Rohár
2022-02-23 14:35 ` Marek Behún
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Pali Rohár @ 2022-02-23 13:21 UTC (permalink / raw)
To: Stefan Roese, Marek Behún; +Cc: u-boot
If Armada 37xx watchdog is started before U-Boot then CNTR_CTRL_ACTIVE bit
is set, U-Boot armada-37xx-wdt.c driver fails to initialize and so U-Boot
is unable to use or kick this watchdog.
Do not check for CNTR_CTRL_ACTIVE bit and always initialize watchdog. Same
behavior is implemented in Linux kernel driver.
This change allows to activate watchdog in firmware which loads U-Boot.
Signed-off-by: Pali Rohár <pali@kernel.org>
---
drivers/watchdog/armada-37xx-wdt.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/drivers/watchdog/armada-37xx-wdt.c b/drivers/watchdog/armada-37xx-wdt.c
index 2e119b9b5aad..bacebbc7926a 100644
--- a/drivers/watchdog/armada-37xx-wdt.c
+++ b/drivers/watchdog/armada-37xx-wdt.c
@@ -58,13 +58,11 @@ static void counter_disable(struct a37xx_wdt *priv, int id)
clrbits_le32(priv->reg + CNTR_CTRL(id), CNTR_CTRL_ENABLE);
}
-static int init_counter(struct a37xx_wdt *priv, int id, u32 mode, u32 trig_src)
+static void init_counter(struct a37xx_wdt *priv, int id, u32 mode, u32 trig_src)
{
u32 reg;
reg = readl(priv->reg + CNTR_CTRL(id));
- if (reg & CNTR_CTRL_ACTIVE)
- return -EBUSY;
reg &= ~(CNTR_CTRL_MODE_MASK | CNTR_CTRL_PRESCALE_MASK |
CNTR_CTRL_TRIG_SRC_MASK);
@@ -79,8 +77,6 @@ static int init_counter(struct a37xx_wdt *priv, int id, u32 mode, u32 trig_src)
reg |= trig_src;
writel(reg, priv->reg + CNTR_CTRL(id));
-
- return 0;
}
static int a37xx_wdt_reset(struct udevice *dev)
@@ -116,16 +112,9 @@ static int a37xx_wdt_expire_now(struct udevice *dev, ulong flags)
static int a37xx_wdt_start(struct udevice *dev, u64 ms, ulong flags)
{
struct a37xx_wdt *priv = dev_get_priv(dev);
- int err;
-
- err = init_counter(priv, 0, CNTR_CTRL_MODE_ONESHOT, 0);
- if (err < 0)
- return err;
- err = init_counter(priv, 1, CNTR_CTRL_MODE_HWSIG,
- CNTR_CTRL_TRIG_SRC_PREV_CNTR);
- if (err < 0)
- return err;
+ init_counter(priv, 0, CNTR_CTRL_MODE_ONESHOT, 0);
+ init_counter(priv, 1, CNTR_CTRL_MODE_HWSIG, CNTR_CTRL_TRIG_SRC_PREV_CNTR);
priv->timeout = ms * priv->clk_rate / 1000 / CNTR_CTRL_PRESCALE_MIN;
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH u-boot-mvebu] watchdog: armada_37xx: Probe driver also when watchdog is already running
2022-02-23 13:21 [PATCH u-boot-mvebu] watchdog: armada_37xx: Probe driver also when watchdog is already running Pali Rohár
@ 2022-02-23 14:35 ` Marek Behún
2022-03-04 7:27 ` Stefan Roese
2022-03-08 9:10 ` Stefan Roese
2 siblings, 0 replies; 4+ messages in thread
From: Marek Behún @ 2022-02-23 14:35 UTC (permalink / raw)
To: Pali Rohár; +Cc: Stefan Roese, u-boot
On Wed, 23 Feb 2022 14:21:40 +0100
Pali Rohár <pali@kernel.org> wrote:
> If Armada 37xx watchdog is started before U-Boot then CNTR_CTRL_ACTIVE bit
> is set, U-Boot armada-37xx-wdt.c driver fails to initialize and so U-Boot
> is unable to use or kick this watchdog.
>
> Do not check for CNTR_CTRL_ACTIVE bit and always initialize watchdog. Same
> behavior is implemented in Linux kernel driver.
>
> This change allows to activate watchdog in firmware which loads U-Boot.
>
> Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH u-boot-mvebu] watchdog: armada_37xx: Probe driver also when watchdog is already running
2022-02-23 13:21 [PATCH u-boot-mvebu] watchdog: armada_37xx: Probe driver also when watchdog is already running Pali Rohár
2022-02-23 14:35 ` Marek Behún
@ 2022-03-04 7:27 ` Stefan Roese
2022-03-08 9:10 ` Stefan Roese
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2022-03-04 7:27 UTC (permalink / raw)
To: Pali Rohár, Marek Behún; +Cc: u-boot
On 2/23/22 14:21, Pali Rohár wrote:
> If Armada 37xx watchdog is started before U-Boot then CNTR_CTRL_ACTIVE bit
> is set, U-Boot armada-37xx-wdt.c driver fails to initialize and so U-Boot
> is unable to use or kick this watchdog.
>
> Do not check for CNTR_CTRL_ACTIVE bit and always initialize watchdog. Same
> behavior is implemented in Linux kernel driver.
>
> This change allows to activate watchdog in firmware which loads U-Boot.
>
> Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Thanks,
Stefan
> ---
> drivers/watchdog/armada-37xx-wdt.c | 17 +++--------------
> 1 file changed, 3 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/watchdog/armada-37xx-wdt.c b/drivers/watchdog/armada-37xx-wdt.c
> index 2e119b9b5aad..bacebbc7926a 100644
> --- a/drivers/watchdog/armada-37xx-wdt.c
> +++ b/drivers/watchdog/armada-37xx-wdt.c
> @@ -58,13 +58,11 @@ static void counter_disable(struct a37xx_wdt *priv, int id)
> clrbits_le32(priv->reg + CNTR_CTRL(id), CNTR_CTRL_ENABLE);
> }
>
> -static int init_counter(struct a37xx_wdt *priv, int id, u32 mode, u32 trig_src)
> +static void init_counter(struct a37xx_wdt *priv, int id, u32 mode, u32 trig_src)
> {
> u32 reg;
>
> reg = readl(priv->reg + CNTR_CTRL(id));
> - if (reg & CNTR_CTRL_ACTIVE)
> - return -EBUSY;
>
> reg &= ~(CNTR_CTRL_MODE_MASK | CNTR_CTRL_PRESCALE_MASK |
> CNTR_CTRL_TRIG_SRC_MASK);
> @@ -79,8 +77,6 @@ static int init_counter(struct a37xx_wdt *priv, int id, u32 mode, u32 trig_src)
> reg |= trig_src;
>
> writel(reg, priv->reg + CNTR_CTRL(id));
> -
> - return 0;
> }
>
> static int a37xx_wdt_reset(struct udevice *dev)
> @@ -116,16 +112,9 @@ static int a37xx_wdt_expire_now(struct udevice *dev, ulong flags)
> static int a37xx_wdt_start(struct udevice *dev, u64 ms, ulong flags)
> {
> struct a37xx_wdt *priv = dev_get_priv(dev);
> - int err;
> -
> - err = init_counter(priv, 0, CNTR_CTRL_MODE_ONESHOT, 0);
> - if (err < 0)
> - return err;
>
> - err = init_counter(priv, 1, CNTR_CTRL_MODE_HWSIG,
> - CNTR_CTRL_TRIG_SRC_PREV_CNTR);
> - if (err < 0)
> - return err;
> + init_counter(priv, 0, CNTR_CTRL_MODE_ONESHOT, 0);
> + init_counter(priv, 1, CNTR_CTRL_MODE_HWSIG, CNTR_CTRL_TRIG_SRC_PREV_CNTR);
>
> priv->timeout = ms * priv->clk_rate / 1000 / CNTR_CTRL_PRESCALE_MIN;
>
Viele Grüße,
Stefan Roese
--
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@denx.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH u-boot-mvebu] watchdog: armada_37xx: Probe driver also when watchdog is already running
2022-02-23 13:21 [PATCH u-boot-mvebu] watchdog: armada_37xx: Probe driver also when watchdog is already running Pali Rohár
2022-02-23 14:35 ` Marek Behún
2022-03-04 7:27 ` Stefan Roese
@ 2022-03-08 9:10 ` Stefan Roese
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2022-03-08 9:10 UTC (permalink / raw)
To: Pali Rohár, Marek Behún; +Cc: u-boot
On 2/23/22 14:21, Pali Rohár wrote:
> If Armada 37xx watchdog is started before U-Boot then CNTR_CTRL_ACTIVE bit
> is set, U-Boot armada-37xx-wdt.c driver fails to initialize and so U-Boot
> is unable to use or kick this watchdog.
>
> Do not check for CNTR_CTRL_ACTIVE bit and always initialize watchdog. Same
> behavior is implemented in Linux kernel driver.
>
> This change allows to activate watchdog in firmware which loads U-Boot.
>
> Signed-off-by: Pali Rohár <pali@kernel.org>
Applied to u-boot-watchdog/master
Thanks,
Stefan
> ---
> drivers/watchdog/armada-37xx-wdt.c | 17 +++--------------
> 1 file changed, 3 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/watchdog/armada-37xx-wdt.c b/drivers/watchdog/armada-37xx-wdt.c
> index 2e119b9b5aad..bacebbc7926a 100644
> --- a/drivers/watchdog/armada-37xx-wdt.c
> +++ b/drivers/watchdog/armada-37xx-wdt.c
> @@ -58,13 +58,11 @@ static void counter_disable(struct a37xx_wdt *priv, int id)
> clrbits_le32(priv->reg + CNTR_CTRL(id), CNTR_CTRL_ENABLE);
> }
>
> -static int init_counter(struct a37xx_wdt *priv, int id, u32 mode, u32 trig_src)
> +static void init_counter(struct a37xx_wdt *priv, int id, u32 mode, u32 trig_src)
> {
> u32 reg;
>
> reg = readl(priv->reg + CNTR_CTRL(id));
> - if (reg & CNTR_CTRL_ACTIVE)
> - return -EBUSY;
>
> reg &= ~(CNTR_CTRL_MODE_MASK | CNTR_CTRL_PRESCALE_MASK |
> CNTR_CTRL_TRIG_SRC_MASK);
> @@ -79,8 +77,6 @@ static int init_counter(struct a37xx_wdt *priv, int id, u32 mode, u32 trig_src)
> reg |= trig_src;
>
> writel(reg, priv->reg + CNTR_CTRL(id));
> -
> - return 0;
> }
>
> static int a37xx_wdt_reset(struct udevice *dev)
> @@ -116,16 +112,9 @@ static int a37xx_wdt_expire_now(struct udevice *dev, ulong flags)
> static int a37xx_wdt_start(struct udevice *dev, u64 ms, ulong flags)
> {
> struct a37xx_wdt *priv = dev_get_priv(dev);
> - int err;
> -
> - err = init_counter(priv, 0, CNTR_CTRL_MODE_ONESHOT, 0);
> - if (err < 0)
> - return err;
>
> - err = init_counter(priv, 1, CNTR_CTRL_MODE_HWSIG,
> - CNTR_CTRL_TRIG_SRC_PREV_CNTR);
> - if (err < 0)
> - return err;
> + init_counter(priv, 0, CNTR_CTRL_MODE_ONESHOT, 0);
> + init_counter(priv, 1, CNTR_CTRL_MODE_HWSIG, CNTR_CTRL_TRIG_SRC_PREV_CNTR);
>
> priv->timeout = ms * priv->clk_rate / 1000 / CNTR_CTRL_PRESCALE_MIN;
>
Viele Grüße,
Stefan Roese
--
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@denx.de
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-03-08 9:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-23 13:21 [PATCH u-boot-mvebu] watchdog: armada_37xx: Probe driver also when watchdog is already running Pali Rohár
2022-02-23 14:35 ` Marek Behún
2022-03-04 7:27 ` Stefan Roese
2022-03-08 9:10 ` Stefan Roese
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).