From patchwork Thu May 24 00:15:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ray Jui X-Patchwork-Id: 10422525 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 85D016032C for ; Thu, 24 May 2018 00:18:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4828429160 for ; Thu, 24 May 2018 00:18:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C991291B6; Thu, 24 May 2018 00:18:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8763029160 for ; Thu, 24 May 2018 00:18:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=yE5M1lS9ScMdX+cnQVJ93ccPqI0/UfnZLAnqj2CKEsk=; b=cSARIwuzFUVkPWYpV0UHZ4At5+ ZEOnbx3TQiwOgvgOxkhnWAHGW7Z7/jZ3UYSDPiVJa42PdZLlOP1VqNzyqKVhcmF9HQ+sFf1Fyvt7O AjMnQXlOXFxTPVpN8NIc0OI0mF1rtzbOVOxqVjxhBbY6DlUWlNDsddD4eti9fc3Iv7ijEskNH75Bv gShtRN9waMDYMVcVnLJTwvufYAw9v0bVG3ZAnMnKIMkJ+uLt6V5VbAtusnkUYIrf1LaS67sPer1w3 LRcZQkRbo1kpJuGGZnSMK1sEaTJxR7UCeUKvG8uaEWKBoltpEMP1UHoWGRY0aCvCY1Y+IdfbCTspm 4MsFqquA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fLdxe-0004LK-JW; Thu, 24 May 2018 00:18:30 +0000 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fLdvG-0002oA-H3 for linux-arm-kernel@lists.infradead.org; Thu, 24 May 2018 00:16:09 +0000 Received: by mail-qt0-x243.google.com with SMTP id m5-v6so30547599qti.1 for ; Wed, 23 May 2018 17:15:52 -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=stGZociEH2eWVBN9zoz9wqwGnPceJsZ4J8FDyHubcvM=; b=AKkZ59/XbzmZvJ+R5Wr3zguMV6CJayTmNXrJkWC6Q1GtfPqzimhitetsl/+O0TlVaH uhual8SzQrGlb6Bnv4+MzWL8BbdQH/LLUkUPsvGc6/NBq07/U/OITHgTNw6O4tqcRk6X aCyDAUNQRLTsydgGl8XBK73KrYPWUOF3WIO88= 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=stGZociEH2eWVBN9zoz9wqwGnPceJsZ4J8FDyHubcvM=; b=HTTmrlO94VwiDE/91RfcgB2cZNgz5LGt8luIQc2m0uE5RwVRTfR82gEOry6NeaEPlB bgP31PjYXbBKE4mqVtGe+iPN0hP9I+GAlVPiLg7SyE7a+yCJiz91oO1ESdy4mJGZytoR WbzEplCSVJa2WulBd64Xp7s/SqFQ6SmN05KraQ+V5bHzbPaPlsoB4OYMDSxFY8cjsm/g MhojIaDOHu8Fb4lX3f3VQCp/kI1rv93y1pfXnL3KGh1bmEo8Ab+Kk8Sn2WURC0FwaYPY d+6suQVs3Vu4m/q6rzu3Mj5Gl5/ahdWMWAg+SibdLc5nMOOUZwmv3fvJHrPo2dxkfSwk rn5Q== X-Gm-Message-State: ALKqPwfCKrrAV8WOEQ1PZvExB1okBvu7jd8byowAF7r347hVQ0SWG0fi Pi9e//YpopqK1Kb+UIKVhdDwjQ== X-Google-Smtp-Source: ADUXVKJ2pO4CDnnePg7rrqHC/bAjngyZPgIaZqpYu1ex6ki0MKrhQR5oXa7f4NXQSDpif3gnwSeHLg== X-Received: by 2002:ac8:92c:: with SMTP id t41-v6mr5062983qth.292.1527120951136; Wed, 23 May 2018 17:15:51 -0700 (PDT) Received: from lbrmn-lnxub44-1.ric.broadcom.com ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id p72-v6sm3028874qkh.5.2018.05.23.17.15.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 May 2018 17:15:50 -0700 (PDT) From: Ray Jui To: Wim Van Sebroeck , Guenter Roeck , Rob Herring , Mark Rutland , Frank Rowand , Catalin Marinas , Will Deacon , Robin Murphy Subject: [PATCH v3 4/6] watchdog: sp805: set WDOG_HW_RUNNING when appropriate Date: Wed, 23 May 2018 17:15:22 -0700 Message-Id: <1527120924-12131-5-git-send-email-ray.jui@broadcom.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1527120924-12131-1-git-send-email-ray.jui@broadcom.com> References: <1527120924-12131-1-git-send-email-ray.jui@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180523_171602_606377_19C3B104 X-CRM114-Status: GOOD ( 16.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Ray Jui , bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If the watchdog hardware is already enabled during the boot process, when the Linux watchdog driver loads, it should reset the watchdog and tell the watchdog framework. As a result, ping can be generated from the watchdog framework, until the userspace watchdog daemon takes over control Signed-off-by: Ray Jui Reviewed-by: Vladimir Olovyannikov Reviewed-by: Scott Branden Reviewed-by: Guenter Roeck --- drivers/watchdog/sp805_wdt.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c index 1484609..d662a6f 100644 --- a/drivers/watchdog/sp805_wdt.c +++ b/drivers/watchdog/sp805_wdt.c @@ -42,6 +42,7 @@ /* control register masks */ #define INT_ENABLE (1 << 0) #define RESET_ENABLE (1 << 1) + #define ENABLE_MASK (INT_ENABLE | RESET_ENABLE) #define WDTINTCLR 0x00C #define WDTRIS 0x010 #define WDTMIS 0x014 @@ -74,6 +75,15 @@ module_param(nowayout, bool, 0); MODULE_PARM_DESC(nowayout, "Set to 1 to keep watchdog running after device release"); +/* returns true if wdt is running; otherwise returns false */ +static bool wdt_is_running(struct watchdog_device *wdd) +{ + struct sp805_wdt *wdt = watchdog_get_drvdata(wdd); + u32 wdtcontrol = readl_relaxed(wdt->base + WDTCONTROL); + + return (wdtcontrol & ENABLE_MASK) == ENABLE_MASK; +} + /* This routine finds load value that will reset system in required timout */ static int wdt_setload(struct watchdog_device *wdd, unsigned int timeout) { @@ -239,6 +249,15 @@ sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id) watchdog_init_timeout(&wdt->wdd, 0, &adev->dev); wdt_setload(&wdt->wdd, wdt->wdd.timeout); + /* + * If HW is already running, enable/reset the wdt and set the running + * bit to tell the wdt subsystem + */ + if (wdt_is_running(&wdt->wdd)) { + wdt_enable(&wdt->wdd); + set_bit(WDOG_HW_RUNNING, &wdt->wdd.status); + } + ret = watchdog_register_device(&wdt->wdd); if (ret) { dev_err(&adev->dev, "watchdog_register_device() failed: %d\n",