From patchwork Sun Oct 27 15:53:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1185056 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="jLVL9dIV"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 471N1m4TJ0z9sPK for ; Mon, 28 Oct 2019 03:03:40 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 4CB97C21DD4; Sun, 27 Oct 2019 15:57:29 +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, T_DKIM_INVALID 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 044DDC21E30; Sun, 27 Oct 2019 15:55:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D8191C21DB6; Sun, 27 Oct 2019 15:55:33 +0000 (UTC) Received: from mail-il1-f194.google.com (mail-il1-f194.google.com [209.85.166.194]) by lists.denx.de (Postfix) with ESMTPS id 7696FC21DCA for ; Sun, 27 Oct 2019 15:54:43 +0000 (UTC) Received: by mail-il1-f194.google.com with SMTP id p8so5883855ilp.2 for ; Sun, 27 Oct 2019 08:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EE8dt7ceTRbdTcty6pscSS8MV2EkNPTvLOS0Jyyaw+8=; b=jLVL9dIVNAIIU5g9IIsOC+V8SsyCL7Vz77+QkP6rGXPhaUri99SWnTgjd65wQqwbMA vUozIKW4WdSEnMWfLacrldcCJX5Qtuoqg1ZoXcj7i/Gvw9RsHKNjR50orq8Owonwp799 ur+aOscoD1s6IgaJXT+UUbtt872ffj4T0LG58= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EE8dt7ceTRbdTcty6pscSS8MV2EkNPTvLOS0Jyyaw+8=; b=NLLZDdjFiRd3bz3cRjlBTouSkmHzKnY5g4XTXytCdMt6ele3I0JyyU0rgv5SGd+Bwi cHo5A76g8IJFE59mQLHQmnPIeTxKhLi1h3KpvXq7aDRH/+FQ2GrMs1Hy9D8pKMwSnL1+ 3puoft8WPgOA8Udve+qQgq7KSUTge8adX5AxudkIFSzCjLbOeAzzhwZyvpbLFbg3WaP6 uH/NeUirG7qvTLlgQIkYNzYZu6xxMppmwlO0y2VIoyTJ3eNwfbJzLm5rOy8VQx0EbQGE abFDU0FBqLEQ31I2qx8e43nFQUUg+xQFoNLyJOpXPy7R9rQV1D4fxH3qILHLXstKCDh+ e63Q== X-Gm-Message-State: APjAAAUoIbVB+GODUtxYypHPGF9xl1nJDre7x6Oull4rAUF/Kfz0d79W J+NJkdyjk2K+PenRNx4m9KhLWYe/b6hTlg== X-Google-Smtp-Source: APXvYqzUwz3e/DTePfRDQTtrClu9gzTIC6Sii41Kg3bp/FEJaR/Ug276/Z++RgokfKakvkfPL14Vfg== X-Received: by 2002:a05:6e02:608:: with SMTP id t8mr6212923ils.297.1572191682292; Sun, 27 Oct 2019 08:54:42 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id n3sm1215070ilm.8.2019.10.27.08.54.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Oct 2019 08:54:41 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Sun, 27 Oct 2019 09:53:45 -0600 Message-Id: <20191027155410.187957-5-sjg@chromium.org> X-Mailer: git-send-email 2.24.0.rc0.303.g954a862665-goog In-Reply-To: <20191027155410.187957-1-sjg@chromium.org> References: <20191027155410.187957-1-sjg@chromium.org> MIME-Version: 1.0 Cc: Marek Vasut , Tom Rini , Stefan Roese , Michal Simek Subject: [U-Boot] [PATCH 05/30] wdt: Move code out of the header 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" We should not have C code in a header file. Move it into a shared C file so it can be used by U-Boot and SPL. Signed-off-by: Simon Glass Reviewed-by: Stefan Roese --- common/init/Makefile | 1 + common/init/wdt.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ include/init.h | 7 +++++++ include/wdt.h | 38 ------------------------------------ 4 files changed, 54 insertions(+), 38 deletions(-) create mode 100644 common/init/wdt.c diff --git a/common/init/Makefile b/common/init/Makefile index 853b56d1e5..a76dedf350 100644 --- a/common/init/Makefile +++ b/common/init/Makefile @@ -6,3 +6,4 @@ obj-y += board_init.o obj-$(CONFIG_$(SPL_TPL_)HANDOFF) += handoff.o +obj-$(CONFIG_$(SPL_TPL_)WDT) += wdt.o diff --git a/common/init/wdt.c b/common/init/wdt.c new file mode 100644 index 0000000000..79146fb293 --- /dev/null +++ b/common/init/wdt.c @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2017 Google, Inc + */ + +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +#ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS +#define CONFIG_WATCHDOG_TIMEOUT_MSECS (60 * 1000) +#endif +#define WATCHDOG_TIMEOUT_SECS (CONFIG_WATCHDOG_TIMEOUT_MSECS / 1000) + +int initr_watchdog(void) +{ + u32 timeout = WATCHDOG_TIMEOUT_SECS; + + /* + * Init watchdog: This will call the probe function of the + * watchdog driver, enabling the use of the device + */ + if (uclass_get_device_by_seq(UCLASS_WDT, 0, + (struct udevice **)&gd->watchdog_dev)) { + debug("WDT: Not found by seq!\n"); + if (uclass_get_device(UCLASS_WDT, 0, + (struct udevice **)&gd->watchdog_dev)) { + printf("WDT: Not found!\n"); + return 0; + } + } + + if (CONFIG_IS_ENABLED(OF_CONTROL)) { + timeout = dev_read_u32_default(gd->watchdog_dev, "timeout-sec", + WATCHDOG_TIMEOUT_SECS); + } + + wdt_start(gd->watchdog_dev, timeout * 1000, 0); + gd->flags |= GD_FLG_WDT_READY; + printf("WDT: Started with%s servicing (%ds timeout)\n", + IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out", timeout); + + return 0; +} diff --git a/include/init.h b/include/init.h index afc953d51e..3e5857f07f 100644 --- a/include/init.h +++ b/include/init.h @@ -181,6 +181,13 @@ int init_func_vid(void); int checkboard(void); int show_board_info(void); +/** + * initr_watchdog() - Init the watchdog + * + * @return 0 if OK, -ve on error + */ +int initr_watchdog(void); + #endif /* __ASSEMBLY__ */ /* Put only stuff here that the assembler can digest */ diff --git a/include/wdt.h b/include/wdt.h index 5bcff24ab3..5698605c02 100644 --- a/include/wdt.h +++ b/include/wdt.h @@ -106,42 +106,4 @@ struct wdt_ops { int (*expire_now)(struct udevice *dev, ulong flags); }; -#if CONFIG_IS_ENABLED(WDT) -#ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS -#define CONFIG_WATCHDOG_TIMEOUT_MSECS (60 * 1000) -#endif -#define WATCHDOG_TIMEOUT_SECS (CONFIG_WATCHDOG_TIMEOUT_MSECS / 1000) - -static inline int initr_watchdog(void) -{ - u32 timeout = WATCHDOG_TIMEOUT_SECS; - - /* - * Init watchdog: This will call the probe function of the - * watchdog driver, enabling the use of the device - */ - if (uclass_get_device_by_seq(UCLASS_WDT, 0, - (struct udevice **)&gd->watchdog_dev)) { - debug("WDT: Not found by seq!\n"); - if (uclass_get_device(UCLASS_WDT, 0, - (struct udevice **)&gd->watchdog_dev)) { - printf("WDT: Not found!\n"); - return 0; - } - } - - if (CONFIG_IS_ENABLED(OF_CONTROL)) { - timeout = dev_read_u32_default(gd->watchdog_dev, "timeout-sec", - WATCHDOG_TIMEOUT_SECS); - } - - wdt_start(gd->watchdog_dev, timeout * 1000, 0); - gd->flags |= GD_FLG_WDT_READY; - printf("WDT: Started with%s servicing (%ds timeout)\n", - IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out", timeout); - - return 0; -} -#endif - #endif /* _WDT_H_ */