From patchwork Wed Dec 12 05:23:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Schocher X-Patchwork-Id: 1011569 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43F4x919y2z9s2P for ; Wed, 12 Dec 2018 16:24:09 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 77A10C2252F; Wed, 12 Dec 2018 05:24:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 59EE8C22265; Wed, 12 Dec 2018 05:24:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 293B5C22265; Wed, 12 Dec 2018 05:23:59 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by lists.denx.de (Postfix) with ESMTPS id 904D7C22228 for ; Wed, 12 Dec 2018 05:23:58 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43F4wt0Wzsz1qxQC; Wed, 12 Dec 2018 06:23:58 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43F4ws6ygQz1qsZl; Wed, 12 Dec 2018 06:23:57 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id xxdJa38i2rM0; Wed, 12 Dec 2018 06:23:56 +0100 (CET) X-Auth-Info: UKI73DPJs/RYpXb+oIWjoNxNvjGJXdcX111cWaYAk0M= Received: from [192.168.1.106] (87.97.35.225.pool.invitel.hu [87.97.35.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Wed, 12 Dec 2018 06:23:56 +0100 (CET) To: "u-boot@lists.denx.de" From: Heiko Schocher Message-ID: Date: Wed, 12 Dec 2018 06:23:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 Content-Language: en-US Subject: [U-Boot] u-boot: at91: wdt broken for smartweb and taurus board X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: hs@denx.de Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Hello all, just found out, that since patch: commit 1473f6ac882fde8078826ca828aa3494ff98bf08 Author: Prasanthi Chellakumar Date: Tue Oct 9 11:46:40 2018 -0700 arm: at91: wdt: Convert watchdog driver to dm/dt Convert the Watchdog driver for AT91SAM9x processors to support the driver model and device tree. Changes "CONFIG_AT91SAM9_WATCHDOG" to new "CONFIG_WDT_AT91" Kconfig option. Signed-off-by: Prasanthi Chellakumar wdt always triggers really fast on smartweb and taurus board... A fast look into it, and I see, that at91_wdt_probe() seems not called. Prasanthi already mentioned to me (offlist), to add #include static struct udevice *watchdog_dev; #ifdef CONFIG_WDT_AT91 if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) { printf("Cannot find watchdog!\n"); } else { printf("Enabling Watchdog\n"); wdt_start(watchdog_dev, 15, 0); } #endif into board code. With this patch at91_wdt_probe() is called now. Digging deeper in it and it seems there are more things broken: http://git.denx.de/?p=u-boot.git;a=blob;f=drivers/watchdog/at91sam9_wdt.c;h=13f8772e4130ac1e273c920d211eefc4491f5eff;hb=ee168783ae889cf449cee36cc1e51e108a210ed4#l48 timeout_s in at91_wdt_start() is assumed in seconds, but wdt_start in include/wdt.h states the timeout is in milliseconds :-( So code goes into the if: if (timeout_s > WDT_MAX_TIMEOUT || timeout_s < WDT_MIN_TIMEOUT) timeout = priv->timeout; and sets timeout new, but never converts the new value with WDT_SEC2TICKS() macro, so the wrong value is written into AT91_WDT_MR ... following patch fixes this: With this 2 patches, same value as before commit 1473f6ac882fd is written into AT91_WDT_MR now ... but board reset thorugh WDT still remains ... Seems with DM_WDT support, wdt reset() gets not called ... Any ideas where to look at ? And is it really necessary to call wdt_start() from board code to start wdt ? DTS entries for wdt seem correct to me. Thanks! bye, Heiko diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c index 81f448322d..c67bed705f 100644 --- a/drivers/watchdog/at91sam9_wdt.c +++ b/drivers/watchdog/at91sam9_wdt.c @@ -48,11 +48,12 @@ struct at91_wdt_priv { static int at91_wdt_start(struct udevice *dev, u64 timeout_s, ulong flags) { struct at91_wdt_priv *priv = dev_get_priv(dev); - u32 timeout = WDT_SEC2TICKS(timeout_s); + u32 timeout; if (timeout_s > WDT_MAX_TIMEOUT || timeout_s < WDT_MIN_TIMEOUT) - timeout = priv->timeout; + timeout_s = priv->timeout; + timeout = WDT_SEC2TICKS(timeout_s); /* Check if disabled */ if (readl(priv->regs + AT91_WDT_MR) & AT91_WDT_MR_WDDIS) { printf("sorry, watchdog is disabled\n");