public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Eugen.Hristev at microchip.com <Eugen.Hristev@microchip.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 06/11] arm: at91: Enable watchdog support
Date: Thu, 21 Mar 2019 12:07:23 +0000	[thread overview]
Message-ID: <95f4fc3e-8770-54e0-0dae-4bf06b56d671@microchip.com> (raw)
In-Reply-To: <08faa2ec-0522-89f3-0616-3d24fddf4dd8@denx.de>



On 21.03.2019 14:00, Stefan Roese wrote:
> External E-Mail
> 
> 
> On 21.03.19 11:23, Eugen.Hristev at microchip.com wrote:
>>
>>
>> On 19.03.2019 17:56, Stefan Roese wrote:
>>> External E-Mail
>>>
>>>
>>> This patch enables and starts the watchdog on the AT91 platform if
>>> configured. Currently the WD timeout is configured to 16 seconds,
>>> which is the longest value for this timer.
>>>
>>> Signed-off-by: Stefan Roese <sr@denx.de>
>>> Cc: Heiko Schocher <hs@denx.de>
>>> Cc: Andreas Bießmann <andreas@biessmann.org>
>>> Cc: Eugen Hristev <eugen.hristev@microchip.com>
>>> ---
>>>    arch/arm/mach-at91/clock.c | 41 
>>> ++++++++++++++++++++++++++++++++++++++
>>>    1 file changed, 41 insertions(+)
>>>
>>> diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
>>> index 64cbc3d1ed..2d442d0092 100644
>>> --- a/arch/arm/mach-at91/clock.c
>>> +++ b/arch/arm/mach-at91/clock.c
>>> @@ -5,6 +5,8 @@
>>>     */
>>>    #include <common.h>
>>> +#include <dm.h>
>>> +#include <wdt.h>
>>>    #include <asm/io.h>
>>>    #include <asm/arch/hardware.h>
>>>    #include <asm/arch/at91_pmc.h>
>>> @@ -118,3 +120,42 @@ void at91_pllicpr_init(u32 icpr)
>>>        writel(icpr, &pmc->pllicpr);
>>>    }
>>> +
>>> +#if defined(CONFIG_WATCHDOG) && !defined(CONFIG_SPL_BUILD)
>>
>> Hi Stefan,
>>
>> Does this mean that for CONFIG_SPL_BUILD, this functions won't exist,
>> thus the SPL cannot use the watchdog ?
>>
>> For example, configuring CONFIG_SPL_WATCHDOG_SUPPORT=y
>> makes SPL build fail :
>>
>> drivers/built-in.o: In function `atmel_nand_pmecc_write_page':
>> /home/eugen/u-boot-denx/drivers/mtd/nand/raw/atmel_nand.c:592: undefined
>> reference to `watchdog_reset'
>> drivers/built-in.o: In function `atmel_nand_pmecc_read_page':
>> /home/eugen/u-boot-denx/drivers/mtd/nand/raw/atmel_nand.c:552: undefined
>> reference to `watchdog_reset'
>> drivers/built-in.o: In function `pmecc_err_location':
>> /home/eugen/u-boot-denx/drivers/mtd/nand/raw/atmel_nand.c:416: undefined
>> reference to `watchdog_reset'
>> scripts/Makefile.spl:384: recipe for target 'spl/u-boot-spl' failed
> 
> Let me see, if I can change this so that this code is
> available if selected in SPL as well. Even though arch_misc_init()
> will not be called, so the watchdog will not be started.

It should at least build :)

> 
> But the code looks cleaner without this #ifdef and if you agree, I
> will send v2 soon with this change.

I did not have time to review all the patch series yet. So more reviews 
will follow

> 
>>
>>> +static struct udevice *watchdog_dev;
>>> +
>>> +/* Called by macro WATCHDOG_RESET */
>>> +void watchdog_reset(void)
>>> +{
>>> +    static ulong next_reset;
>>> +    ulong now;
>>> +
>>> +    if (!watchdog_dev)
>>> +        return;
>>> +
>>> +    now = get_timer(0);
>>> +
>>> +    /* Do not reset the watchdog too often */
>>> +    if (now > next_reset) {
>>> +        next_reset = now + 1000;    /* reset every 1000ms */
>>> +        wdt_reset(watchdog_dev);
>>> +    }
>>> +}
>>> +
>>> +int arch_misc_init(void)
>>> +{
>>> +    /* Init watchdog */
>>> +    if (uclass_get_device_by_seq(UCLASS_WDT, 0, &watchdog_dev)) {
>>> +        debug("Watchdog: Not found by seq!\n");
>>> +        if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) {
>>> +            puts("Watchdog: Not found!\n");
>>> +            return 0;
>>> +        }
>>> +    }
>>> +
>>> +    wdt_start(watchdog_dev, 16000, 0);    /* 16 seconds is max */
>>> +    printf("Watchdog: Started\n");
>>> +
>>
>> Any reason why you use printf and puts and debug in the same function ?
>> Would expect to see debug everywhere except some fatal error that should
>> be printed all the time.
> 
> Good catch. This is copy-pasted from other very similar implementations.
> I personally find this last status message "Watchdog: Started" quite
> useful and would like to keep it. All others might be changed to debug().

I do not mind if you keep it

Eugen

> 
> Thanks,
> Stefan

  reply	other threads:[~2019-03-21 12:07 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19 15:56 [U-Boot] [PATCH 01/11] arm: at91: Makefile: Compile lowlevel_init only when really necessary Stefan Roese
2019-03-19 15:56 ` [U-Boot] [PATCH 02/11] arm: at91: spl_at91.c: Call spl_early_init() if OF_CONTROL is enabled Stefan Roese
2019-03-19 15:56 ` [U-Boot] [PATCH 03/11] serial: atmel_usart: Use fixed clock value in SPL version Stefan Roese
2019-03-20  7:25   ` Eugen.Hristev at microchip.com
2019-03-20  7:30     ` Stefan Roese
2019-03-25 14:27       ` Eugen.Hristev at microchip.com
2019-03-25 14:57         ` Stefan Roese
2019-03-19 15:56 ` [U-Boot] [PATCH 04/11] watchdog: Handle SPL build with watchdog disabled Stefan Roese
2019-03-20  7:30   ` Eugen.Hristev at microchip.com
2019-03-20  7:33     ` Stefan Roese
2019-03-20  7:41       ` Eugen.Hristev at microchip.com
2019-03-20  7:48         ` Stefan Roese
2019-03-20  8:06           ` Eugen.Hristev at microchip.com
2019-03-20  8:10             ` Stefan Roese
2019-03-19 15:56 ` [U-Boot] [PATCH 05/11] watchdog: at91sam9_wdt: Fix WDT setup in at91_wdt_start() Stefan Roese
2019-03-19 15:56 ` [U-Boot] [PATCH 06/11] arm: at91: Enable watchdog support Stefan Roese
2019-03-21 10:23   ` Eugen.Hristev at microchip.com
2019-03-21 12:00     ` Stefan Roese
2019-03-21 12:07       ` Eugen.Hristev at microchip.com [this message]
2019-03-19 15:56 ` [U-Boot] [PATCH 07/11] arm: at91: arm926ejs/u-boot-spl.lds: Add _image_binary_end to SPL lds Stefan Roese
2019-03-19 15:56 ` [U-Boot] [PATCH 08/11] Makefile.spl: Move generate AT91SAM NAND image boot.bin to spl directory Stefan Roese
2019-03-25 14:22   ` Eugen.Hristev at microchip.com
2019-03-25 14:24     ` Stefan Roese
2019-03-26  7:06       ` Heiko Schocher
2019-03-19 15:56 ` [U-Boot] [PATCH 09/11] Makefile: Add Kconfig option CONFIG_SPL_IMAGE to select the SPL binary Stefan Roese
2019-03-19 15:56 ` [U-Boot] [PATCH 10/11] arm: at91: siemens: Add support to generate combined SPL+U-Boot image Stefan Roese
2019-03-19 15:56 ` [U-Boot] [PATCH 11/11] arm: at91: Add gardena-gateway-at91sam support Stefan Roese

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=95f4fc3e-8770-54e0-0dae-4bf06b56d671@microchip.com \
    --to=eugen.hristev@microchip.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox