From patchwork Mon Aug 13 21:16:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Lengfeld X-Patchwork-Id: 10564813 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 363F79093 for ; Mon, 13 Aug 2018 21:16:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25487286FD for ; Mon, 13 Aug 2018 21:16:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19B9028B68; Mon, 13 Aug 2018 21:16:26 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47E7428E29 for ; Mon, 13 Aug 2018 21:16:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730178AbeHNAAU (ORCPT ); Mon, 13 Aug 2018 20:00:20 -0400 Received: from stcim.de ([78.46.90.227]:34454 "EHLO stcim.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729947AbeHNAAT (ORCPT ); Mon, 13 Aug 2018 20:00:19 -0400 Received: from xdsl-87-78-37-34.netcologne.de ([87.78.37.34] helo=localhost.localdomain) by stcim with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1fpKCG-0008Ap-IC; Mon, 13 Aug 2018 23:16:16 +0200 From: Stefan Lengfeld To: linux-i2c@vger.kernel.org Cc: wsa@the-dreams.de, preid@electromag.com.au, j-keerthy@ti.com, tony@atomide.com, nsekhar@ti.com, vigneshr@ti.com, linux-omap@vger.kernel.org Subject: [RFC PATCH 3/4] watchdog: da9062: avoid regmap in restart handler Date: Mon, 13 Aug 2018 23:16:13 +0200 Message-Id: <20180813211614.16440-4-contact@stefanchrist.eu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180813211614.16440-1-contact@stefanchrist.eu> References: <5bb4b898-acc3-7c73-2285-cf84a88961e6@ti.com> <20180813211614.16440-1-contact@stefanchrist.eu> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using i2c_transfer() to set the shutdown bit is more reliable than using regmap. Furthermore you have to void the default lock configuration in the regmap configuration, e.g. by setting use_hwlock to true, to used in atomic/IRQ disabled contexts. Tested on a phyCORE-i.MX6 Solo board. Signed-off-by: Stefan Lengfeld --- drivers/mfd/da9062-core.c | 1 + drivers/watchdog/da9062_wdt.c | 17 +++++++++++++---- include/linux/mfd/da9062/core.h | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c index 9f6105906c09..b6a01054ba0f 100644 --- a/drivers/mfd/da9062-core.c +++ b/drivers/mfd/da9062-core.c @@ -609,6 +609,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, chip); chip->dev = &i2c->dev; + chip->i2c = i2c; if (!i2c->irq) { dev_err(chip->dev, "No IRQ configured\n"); diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c index fe169d8e1fb2..ad6483d25f83 100644 --- a/drivers/watchdog/da9062_wdt.c +++ b/drivers/watchdog/da9062_wdt.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -152,12 +153,20 @@ static int da9062_wdt_restart(struct watchdog_device *wdd, unsigned long action, void *data) { struct da9062_watchdog *wdt = watchdog_get_drvdata(wdd); + struct i2c_client *client = wdt->hw->i2c; + __u8 buf[3] = {DA9062AA_CONTROL_F, DA9062AA_SHUTDOWN_MASK, 0x0}; + struct i2c_msg msgs[1] = { + { + .addr = client->addr, + .flags = (client->flags & I2C_M_TEN), + .len = sizeof(buf), + .buf = buf, + } + }; int ret; - ret = regmap_write(wdt->hw->regmap, - DA9062AA_CONTROL_F, - DA9062AA_SHUTDOWN_MASK); - if (ret) + ret = i2c_transfer(client->adapter, msgs, sizeof(msgs)); + if (ret < 0) dev_alert(wdt->hw->dev, "Failed to shutdown (err = %d)\n", ret); diff --git a/include/linux/mfd/da9062/core.h b/include/linux/mfd/da9062/core.h index 74d33a01ddae..c994293b3aef 100644 --- a/include/linux/mfd/da9062/core.h +++ b/include/linux/mfd/da9062/core.h @@ -68,6 +68,7 @@ enum da9062_irqs { struct da9062 { struct device *dev; struct regmap *regmap; + struct i2c_client *i2c; struct regmap_irq_chip_data *regmap_irq; enum da9062_compatible_types chip_type; };