From patchwork Sun May 17 08:19:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rayagonda Kokatanur X-Patchwork-Id: 1292065 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=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=M2PtBPLB; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49PwBt1Xf3z9sT6 for ; Sun, 17 May 2020 18:23:18 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E392581947; Sun, 17 May 2020 10:21:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.b="M2PtBPLB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A50FB8191D; Sun, 17 May 2020 10:21:13 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6B5BD81689 for ; Sun, 17 May 2020 10:21:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rayagonda.kokatanur@broadcom.com Received: by mail-wr1-x444.google.com with SMTP id k13so6063970wrx.3 for ; Sun, 17 May 2020 01:21:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=luwceobe0o3mGxD/TONM9t1q1nfgit8DLV+IYffe4To=; b=M2PtBPLBOELebPDSjI07xFNK5I1qOT6inE46AFsuwFNX1mF+s7jEy5bthNo7sSmt7A /djrbiCCBINj1EH+czGsJv5dJDT/bNVHdo6qNgkc6v6z8ViUWjiZkOxESPWk+80QXGuj caXFn6X7jPkTLFh81xr2DIqErlU44S6W/l/mY= 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; bh=luwceobe0o3mGxD/TONM9t1q1nfgit8DLV+IYffe4To=; b=d280+ElEOZe3H+2dMbxdEfwIr+TbXSrjzTgAcZGRdyTAaLlxwbiwRREnJUS7pqpaVh zeDIWfDW0PUaPC5ADzp5FATWONDBqM/kRwkWCFj0CoyXTXnp7zJkFwuoUILx2ItaxHNY Laa+fNeb1QjvmfeHt0uESfH+OY9LMGAbyXxXYDP9IVHLvjLySzgo0zLxqA9k52bYSZNl zGUKDUyzxXD5ctba+R1l1Hr+852IDhbfTtk6AghJWihxYW4ebQDzqXbRiAeb6lo3TIlB IS5/AvKkb3CekWsqj11QIwFwHHiiAZa3vX6Uv20seXoNe9tKs2qNX+WyWkEohjrSqFLI Pq8w== X-Gm-Message-State: AOAM531JUDLeDlA3Ec498nvdPpZmlxZXUVaOxoWZGP+qjIMr/BU1tcTE jA+ZbgzetkSbcsWenIhK1BQkS0apBd37fM3QLQFU9Zs432z0rRgmeog7lKDjl1ILb9vA71iW/ck it53PXZM67WlHbgPDJD/duvwYiYHVSvc0O/YYM8wVxuXSk9J4vqNmXkXaEPgDIA/DWuF6lnPLQ+ AV3as= X-Google-Smtp-Source: ABdhPJx4TCbR+sLOziQbpnCqL3BgmpeOxzev02A2bbcxG5xm/vMmaoEHD1NJ5KEXoGGC7AUchVpdxA== X-Received: by 2002:a5d:6b83:: with SMTP id n3mr14297674wrx.213.1589703669478; Sun, 17 May 2020 01:21:09 -0700 (PDT) Received: from rayagonda.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id b65sm11735427wmc.30.2020.05.17.01.21.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 May 2020 01:21:08 -0700 (PDT) From: Rayagonda Kokatanur To: u-boot@lists.denx.de, Simon Glass , Bharat Gooty Cc: Rayagonda Kokatanur , Pramod Kumar Subject: [PATCH v1 15/15] board: ns3: start sp805 watchdog service Date: Sun, 17 May 2020 13:49:45 +0530 Message-Id: <20200517081945.21282-16-rayagonda.kokatanur@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200517081945.21282-1-rayagonda.kokatanur@broadcom.com> References: <20200517081945.21282-1-rayagonda.kokatanur@broadcom.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean Start sp805 watchdog service. Parse wdt timeout from env and dts, give precedence to env timeout if defined. Set default timeout to 60s if both env and dts doesn't specifiy timeout. Stop the WDT in board late init and start the WDT service before giving control to Linux. Signed-off-by: Rayagonda Kokatanur Signed-off-by: Bharat Kumar Reddy Gooty Signed-off-by: Pramod Kumar --- board/broadcom/bcmns3/ns3.c | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/board/broadcom/bcmns3/ns3.c b/board/broadcom/bcmns3/ns3.c index 51cab1aad3..37a3cf9d14 100644 --- a/board/broadcom/bcmns3/ns3.c +++ b/board/broadcom/bcmns3/ns3.c @@ -11,9 +11,12 @@ #include #include #include +#include +#include #include #include #include +#include #define BANK_OFFSET(bank) ((u64)BCM_NS3_DDR_INFO_BASE + 8 + ((bank) * 16)) @@ -134,6 +137,14 @@ int board_init(void) int board_late_init(void) { +#if CONFIG_IS_ENABLED(WDT) + /* + * Default WDT service is started with 60 sec time out. + * Disable it and start before giving control to Linux. + */ + wdt_stop(gd->watchdog_dev); +#endif + return 0; } @@ -185,12 +196,57 @@ void reset_cpu(ulong level) } #ifdef CONFIG_OF_BOARD_SETUP +#if CONFIG_IS_ENABLED(WDT) + +#ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS +#define CONFIG_WATCHDOG_TIMEOUT_MSECS (60 * 1000) +#endif +#define DEF_TIMEOUT_SEC (CONFIG_WATCHDOG_TIMEOUT_MSECS / 1000) + +static int start_wdt(void) +{ + u32 timeout = DEF_TIMEOUT_SEC; + struct udevice *udev; + int rc = 0; + u32 wdt_enable; + + wdt_enable = env_get_ulong("wdt_enable", 16, 0); + printf("wdt_enable :%u\n", wdt_enable); + if (!wdt_enable) + return rc; + + rc = uclass_get_device(UCLASS_WDT, 0, &udev); + if (rc) { + printf("Failed to get wdt rc:%d\n", rc); + } else { + timeout = env_get_ulong("wdt_timeout_sec", 10, 0); + if (!timeout) { + if (CONFIG_IS_ENABLED(OF_CONTROL)) + timeout = dev_read_u32_default(gd->watchdog_dev, + "timeout-sec", + DEF_TIMEOUT_SEC); + } + wdt_start(udev, timeout * 1000, 0); + printf("Started wdt (%ds timeout)\n", timeout); + } + + return rc; +} +#else +static int start_wdt(void) +{ + return 0; +} +#endif /* CONFIG_WDT */ + int ft_board_setup(void *fdt, bd_t *bd) { gic_lpi_tables_init(BCM_NS3_GIC_LPI_BASE, MAX_GIC_REDISTRIBUTORS); mem_info_parse_fixup(fdt); + start_wdt(); + return 0; } #endif /* CONFIG_OF_BOARD_SETUP */