From patchwork Thu Jan 7 06:37:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 12003057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E755AC433E9 for ; Thu, 7 Jan 2021 06:38:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8943208A9 for ; Thu, 7 Jan 2021 06:38:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726323AbhAGGhx (ORCPT ); Thu, 7 Jan 2021 01:37:53 -0500 Received: from mail-lf1-f49.google.com ([209.85.167.49]:34237 "EHLO mail-lf1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725763AbhAGGhx (ORCPT ); Thu, 7 Jan 2021 01:37:53 -0500 Received: by mail-lf1-f49.google.com with SMTP id o19so12223966lfo.1; Wed, 06 Jan 2021 22:37:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=eugQ6sBmsnErNR+lYgl7iFDp5HtAPo4b3aA9DfPqt+s=; b=mNwtFTMCl1xizO5O+RPx7fM5ZXVtXkS1reTXwpxUprep7JY7aqLoviT2bTUyslhap5 zy+9lLYGmJ9vxYBJp8KgSx13E6XrMvu2SYxCCUka8ZZDZHTEmWHSstYHvmpD7Qj3uUro iOstd1o0VE8Bzay2owFIDNSq27LrJ/iWLnkZN0WdyrtKkvAZ3vdGOWIqn8CIflaRVz3p /E9+MaA05Cbo1WyAPAuCxSumyr2hO9uykcCWrU7VSSPM9rvzm6dGcR6wieyGLHzfeyJM y1LCDNrFfZ4ryJci6pF4CHP7h14R7G4/szfFihCitTkE6i4NBd0+LfueXbYMC7VvSzfJ vZhw== X-Gm-Message-State: AOAM531wkp5m3x3Jkj3zW9FjcdaWnWpHrC5iHLEzj9cUW4Fsk+B7t+UU qbdsgz+NB5aYKi6lm2/x8+c= X-Google-Smtp-Source: ABdhPJyXrX4vEvOHyQMS2ciT6sAzN1vrJY7FdCRzKtCqvSzFgr4W4E8Qk2+BjmzQ4SmtbyKSq/5zFA== X-Received: by 2002:a19:c7cb:: with SMTP id x194mr3375847lff.426.1610001430714; Wed, 06 Jan 2021 22:37:10 -0800 (PST) Received: from localhost.localdomain (62-78-225-252.bb.dnainternet.fi. [62.78.225.252]) by smtp.gmail.com with ESMTPSA id v14sm924248lfe.270.2021.01.06.22.37.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 22:37:09 -0800 (PST) Date: Thu, 7 Jan 2021 08:37:03 +0200 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com Cc: Wim Van Sebroeck , Guenter Roeck , linux-power@fi.rohmeurope.com, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] watchdog: bd70528: don't crash if WDG is confiured with BD71828 Message-ID: <671ac57ad53ab1614da7fe9a3d0f78bdb5b51fda.1610001365.git.matti.vaittinen@fi.rohmeurope.com> MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org If config for BD70528 watchdog is enabled when BD71828 or BD71815 are used the RTC module will issue call to BD70528 watchdog with NULL data. Ignore this call and don't crash. Signed-off-by: Matti Vaittinen --- drivers/watchdog/bd70528_wdt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) base-commit: 2c85ebc57b3e1817b6ce1a6b703928e113a90442 diff --git a/drivers/watchdog/bd70528_wdt.c b/drivers/watchdog/bd70528_wdt.c index 0170b37e6674..fde242b8a4a6 100644 --- a/drivers/watchdog/bd70528_wdt.c +++ b/drivers/watchdog/bd70528_wdt.c @@ -49,6 +49,21 @@ int bd70528_wdt_set(struct rohm_regmap_dev *data, int enable, int *old_state) u8 wd_ctrl_arr[3] = { WD_CTRL_MAGIC1, WD_CTRL_MAGIC2, 0 }; u8 *wd_ctrl = &wd_ctrl_arr[2]; + /* + * BD71828 and BD71815 use same RTC driver as BD70528. + * BD71815 and BD71828 do not need MFD data as they do not share + * RTC counter with watchdog. The BD70528 watchdog should not be + * compiled in with BD71815 or BD71828 and the stub implementation + * for the bd70528_wdt_set should be provided instead. + * + * If one compiles this watchdog with BD71828 or BD71815 - the call + * from RTC may get here and the data pointer is NULL. In that case, + * warn and go out. + */ + if (!data) { + pr_warn("BD70528_WATCHDOG misconfigured\n"); + return 0; + } ret = regmap_read(bd70528->chip.regmap, BD70528_REG_WDT_CTRL, &tmp); if (ret) return ret; From patchwork Thu Jan 7 06:37:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 12003059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BFCAC433E9 for ; Thu, 7 Jan 2021 06:38:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8798208A9 for ; Thu, 7 Jan 2021 06:38:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726581AbhAGGiP (ORCPT ); Thu, 7 Jan 2021 01:38:15 -0500 Received: from mail-lf1-f54.google.com ([209.85.167.54]:43834 "EHLO mail-lf1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726631AbhAGGiP (ORCPT ); Thu, 7 Jan 2021 01:38:15 -0500 Received: by mail-lf1-f54.google.com with SMTP id 23so12105971lfg.10; Wed, 06 Jan 2021 22:37:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ck++y5Feh91jiOvRScUEvnGd3M5vPkF/bZjgY6vW3Q8=; b=i6jTleOuNSBo7FJBBu0TlmGFbmq1rZzBr6ucciz70e3p7ST5C0+rwpS+/ZrcXJOElZ hoAFJWUtN2K1r4eeLZ1n5Zt7oU8BaBYjJ97XoalM9fm/sOFl+8MPckM30hmIIR2m0diN ewONjKS5KN1YNpRSs4ZmISs17ypr0nCSSKDnWNPWyM8mHoqAt5CggCV4A8Sv8a6CfVq3 cRffdOC6XsFsj1Zn5/A46wON5+YyBgUBATzoEtswyuflrvIzhdC1ePwkXRqYN86UtS0g p5lKJo7gZFaLgdhvicvqCMAiPR8zECGChEXpg5JERFZEVU2oadmUzI5gtDAoSTqk2EiN dFlQ== X-Gm-Message-State: AOAM531l/slUvu6QpUrKXYVyiUzE40CWtuPY10PfC6OtMlxepv0w8FHF ps06t+EmJuBDr/KXMjcmhn+ZP4cJVPY= X-Google-Smtp-Source: ABdhPJwLZv/Co8Bk6wTUARStsieeclPeKUBRVY217meVgJzXiTVacF8B/i0KL6vJ7fBEqel58E3lnA== X-Received: by 2002:a2e:870d:: with SMTP id m13mr3346818lji.136.1610001452821; Wed, 06 Jan 2021 22:37:32 -0800 (PST) Received: from localhost.localdomain (62-78-225-252.bb.dnainternet.fi. [62.78.225.252]) by smtp.gmail.com with ESMTPSA id z23sm912912lfi.1.2021.01.06.22.37.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 22:37:32 -0800 (PST) Date: Thu, 7 Jan 2021 08:37:25 +0200 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com Cc: Wim Van Sebroeck , Guenter Roeck , linux-power@fi.rohmeurope.com, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] watchdog: BD70528: conditionally allow BD70528 module Message-ID: <019c196041600a00143fe16bda19b2a8f060e9a9.1610001365.git.matti.vaittinen@fi.rohmeurope.com> References: <671ac57ad53ab1614da7fe9a3d0f78bdb5b51fda.1610001365.git.matti.vaittinen@fi.rohmeurope.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <671ac57ad53ab1614da7fe9a3d0f78bdb5b51fda.1610001365.git.matti.vaittinen@fi.rohmeurope.com> Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org The BD70528 watchdog module provides start/stop interface for RTC driver because the BD70528 watchdog must be stopped when RTC time is set. (WDG uses RTC counter and setting RTC may accidentally trigger WDG if WDG is enabled). The BD71828 use same RTC driver as BD70528 but don't share same WDG logic. When BD70528 is not configured a stub call to "stop WDG" is implemented and in case when BD71828 is used, this stub function should be called. Prevent configuring in the BD70528 watchdog when BD71828 is configured to avoid access to real WDG functions when WDG does not exist in HW. Signed-off-by: Matti Vaittinen --- drivers/watchdog/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index fd7968635e6d..40e1b4c69537 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -163,6 +163,7 @@ config SOFT_WATCHDOG_PRETIMEOUT config BD70528_WATCHDOG tristate "ROHM BD70528 PMIC Watchdog" depends on MFD_ROHM_BD70528 + depends on MFD_ROHM_BD71828 = n select WATCHDOG_CORE help Support for the watchdog in the ROHM BD70528 PMIC. Watchdog trigger