Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E031DC433EF for ; Thu, 9 Dec 2021 16:33:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2F258811D9; Thu, 9 Dec 2021 17:32:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id B041E83096; Thu, 9 Dec 2021 17:32:55 +0100 (CET) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 19EA7811D9 for ; Thu, 9 Dec 2021 17:32:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michael.opdenacker@bootlin.com Received: (Authenticated sender: michael.opdenacker@bootlin.com) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 982D21C0003 for ; Thu, 9 Dec 2021 16:32:51 +0000 (UTC) To: "u-boot@lists.denx.de" From: Michael Opdenacker Subject: ARM: mach-at91: how to stop U-Boot/SPL from disabling the watchdog timer on SAMAD3 Xplained Organization: Bootlin Message-ID: Date: Thu, 9 Dec 2021 17:32:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Greetings, Documenting the issue and a workaround here in case other people encounter it, but if you have tips for fixing the issue in U-Boot, I'm interested of course! I noticed that the SAMA5D3 Xplained board didn't have the watchdog timer enabled in the Linux DTS. I submitted a patch to fix this: https://lkml.org/lkml/2021/12/9/740 However, applying this patch isn't sufficient to make the watchdog available on Linux: at91_wdt fffffe40.watchdog: watchdog is disabled at91_wdt: probe of fffffe40.watchdog failed with error -22 As explained on https://elixir.bootlin.com/linux/latest/source/drivers/watchdog/at91sam9_wdt.c#L10, this happens because the bootloader or bootstrap code already disables the watchdog. The trouble is, unlike on SAMA5D2 and SAMAD4 (if I understood correctly),"The Watchdog Timer Mode Register can be only written to once". However, I haven't managed to disable this behavior in U-Boot (including the SPL). I have no watchdog related option turned on anywhere, and by adding puts() messages in the code, I believe that the wdt_stop() function doesn't get called either. Maybe the corresponding watchdog register is written to by the code initializing the SoC, but I couldn't find where. A workaround is to use at91bootstrap instead of U-Boot SPL, which has a configuration parameter to disable to watchdog: git clone https://github.com/linux4sam/at91bootstrap.git export CROSS_COMPILE=arm-linux- (whatever your cross-compiler is) make sama5d3_xplainedsd_uboot_defconfig make menuconfig (Disable CONFIG_DISABLE_WATCHDOG) make Copy boot.bin (under build/...) and u-boot.bin (from U-Boot sources) to the SD card. At least, this proves that the culprit is U-Boot SPL! So, any advice for making it possible prevent the SPL from disabling the watchdog on SAMA5D3 (Xplained at least)? Cheers Michael. -- Michael Opdenacker, Bootlin Embedded Linux and Kernel engineering https://bootlin.com