From patchwork Fri Jul 26 07:20:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 169785 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12648116ilk; Fri, 26 Jul 2019 00:21:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqz73U69no+Errvavk2oFKJQMvn5HTUg3aJ407KC6g4hKXIi0CAdIRF9KMfU/w5boAHXtT3q X-Received: by 2002:a63:d90f:: with SMTP id r15mr70066877pgg.259.1564125700114; Fri, 26 Jul 2019 00:21:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564125700; cv=none; d=google.com; s=arc-20160816; b=BDdb3fZnBcm/zJvAeRfyJ0kTdtMdS62TDAMvWG4nXqDJDVcNYCXwi8lzHQYf4lSb2W +DdoxQgw6nIOVlOPS1lxCHRdjnISgTh+AtIAfdsKoFKP7DjXiSBHhf2T1kQTlK7YKWUT hLpcQ7nWxLNGQOKA+0vfVeo3t6NzScHDlI15s1pIjCxV8vUl2IYBLeplSHlpILXsVDwJ 0tz+FBUcTnv7Ox1jrHICyfk8SjzYVNzKZaH8ZO6oyhaxtcD73dSV5AfKs6LQKuiZnaZD RAAiGGODH1V7zEz4UylWHPvEsSEcJBBasX2tqsYRTdj5JCYLoE29GhWyhHAh6Pm0ZcWU YMOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=awaZGPNc/AiKA1O3cSLxgegYtsyLyL9rlW0mw3ih7no=; b=Pa7qy+K0YN7yHMjXIFnBy+3ApE2Y2KepGs5vND8dX8ZPvGqB04BGX60RSb3gko/nsb T82ArJ6VbjH7XQzNbusXCAyMlNw9GbITB+WULEzhlZZfMakwL0nYHih8QvP9lQUSG0bt Zfzp/sJo/Cx6hX9rXLzFI380H9vcOa6BJ6HhammuFtZfkIu1NKm1u/+xTF4v3M8mG0cq 1Fk0DTLLmMTdY53KVR2QJnG62r9ptunGdgMinHnwatGZ2HTu/td9t5JNUOzcGFQJJcDx h3grMuCkEaa1eD14xrSty44l6+Ylad1NGePi7Gj+Lt5JFnkq0XO+Ahd4LWacgG7QsSeC c6hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hcdxHXTX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17si18447977pgg.155.2019.07.26.00.21.39; Fri, 26 Jul 2019 00:21:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hcdxHXTX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726526AbfGZHVi (ORCPT + 29 others); Fri, 26 Jul 2019 03:21:38 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:41612 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726490AbfGZHVh (ORCPT ); Fri, 26 Jul 2019 03:21:37 -0400 Received: by mail-pl1-f196.google.com with SMTP id m9so24315230pls.8 for ; Fri, 26 Jul 2019 00:21:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=awaZGPNc/AiKA1O3cSLxgegYtsyLyL9rlW0mw3ih7no=; b=hcdxHXTXSCGhdOQdBW4+4VMJP+Jhc+nc1uovLJWNFJxc41lrFFPfCNYwCPTFcxDoXb 9tr86iamuf0K6KAiiVUTjXGfwpT4MgiIe6IjOR7TQFqZicFg82ntoaSGMYaV7wmpo0Ie CqZfC8dNbK0TPqeiXoAsJwnIBcsbukcG7qH+elAgtHduucPyF0kt6NKVL3/FuNCxVwxS YkPZZi33pmgj+rZqQ1vAkYonQd1huLBzxfwiLZvixQKPKhxjSnPc4BJ9EscG0vQVrHBW o9Mik5sW0MV6Fuv0x725KZOrtn3ECutcv0/R93ssh5nHgN1o27ocG+l30Hvj2DCYc1Gu l+eQ== 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:in-reply-to:references; bh=awaZGPNc/AiKA1O3cSLxgegYtsyLyL9rlW0mw3ih7no=; b=GJR+Nauz9WALvixnllXzf+yuDWEHAisYKu3Ee5jhJQ9tQBCetIvZjUi3GkSzKpUbxh 0InRSPgFwSzaFslzOjghTskjbKhrmJ5pWuluGP6Lgfg70PLXEFJ25cOfWVj7TIzXbTl4 odMXIK77X2nYty3ACTbOkY1l9U3Ux31X3LhN2gcScmziZK5d3Yzvbfg0UP1CsOxTSBpa noI0sPNia8WpmVeR44gGyP2JFH9cC4QlkcuzNO5AjdJSG7OfMMcE7V8epmxStC7kuejJ toJF5XJ8A7PTSpUrhuJ2Ko2wpCfmTb/3aL07qlfi96tciJwU3uHSR4uF9JCAn+14QO6S ySJA== X-Gm-Message-State: APjAAAXFxJxb+dUd+paMA3zujo/1GW11FaeGVPKSka8+evKAVh5sfAg9 mYwogYwMB3FO+VboyYYPhXejpg== X-Received: by 2002:a17:902:9688:: with SMTP id n8mr92948320plp.227.1564125696457; Fri, 26 Jul 2019 00:21:36 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id o12sm39216152pjr.22.2019.07.26.00.21.33 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jul 2019 00:21:36 -0700 (PDT) From: Baolin Wang To: broonie@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, orsonzhai@gmail.com, zhang.lyra@gmail.com Cc: weicx@spreadst.com, sherry.zong@unisoc.com, baolin.wang@linaro.org, vincent.guittot@linaro.org, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] spi: sprd: adi: Add a reset reason for watchdog mode Date: Fri, 26 Jul 2019 15:20:51 +0800 Message-Id: <1563f3de43c6c2262d597a25d6138b5de61ea23d.1564125131.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sherry Zong When the system was rebooted by watchdog, now we did not save the watchdog reset mode which will make system enter a incorrect mode after rebooting. Thus we should set the watchdog reset mode as default when opening the watchdog configuration, that means if the system was rebooted by other reason through the restart_handler(), then we will clear the default watchdog reset mode to save the correct reset mode. Signed-off-by: Sherry Zong Signed-off-by: Baolin Wang --- drivers/spi/spi-sprd-adi.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) -- 1.7.9.5 diff --git a/drivers/spi/spi-sprd-adi.c b/drivers/spi/spi-sprd-adi.c index 509ce69..0d767eb 100644 --- a/drivers/spi/spi-sprd-adi.c +++ b/drivers/spi/spi-sprd-adi.c @@ -99,6 +99,7 @@ #define HWRST_STATUS_IQMODE 0xb0 #define HWRST_STATUS_SPRDISK 0xc0 #define HWRST_STATUS_FACTORYTEST 0xe0 +#define HWRST_STATUS_WATCHDOG 0xf0 /* Use default timeout 50 ms that converts to watchdog values */ #define WDG_LOAD_VAL ((50 * 1000) / 32768) @@ -309,6 +310,18 @@ static int sprd_adi_transfer_one(struct spi_controller *ctlr, return 0; } +static void sprd_adi_set_wdt_rst_mode(struct sprd_adi *sadi) +{ +#ifdef CONFIG_SPRD_WATCHDOG + u32 val; + + /* Set default watchdog reboot mode */ + sprd_adi_read(sadi, sadi->slave_pbase + PMIC_RST_STATUS, &val); + val |= HWRST_STATUS_WATCHDOG; + sprd_adi_write(sadi, sadi->slave_pbase + PMIC_RST_STATUS, val); +#endif +} + static int sprd_adi_restart_handler(struct notifier_block *this, unsigned long mode, void *cmd) { @@ -347,6 +360,7 @@ static int sprd_adi_restart_handler(struct notifier_block *this, /* Record the reboot mode */ sprd_adi_read(sadi, sadi->slave_pbase + PMIC_RST_STATUS, &val); + val &= ~HWRST_STATUS_WATCHDOG; val |= reboot_mode; sprd_adi_write(sadi, sadi->slave_pbase + PMIC_RST_STATUS, val); @@ -475,6 +489,7 @@ static int sprd_adi_probe(struct platform_device *pdev) } sprd_adi_hw_init(sadi); + sprd_adi_set_wdt_rst_mode(sadi); ctlr->dev.of_node = pdev->dev.of_node; ctlr->bus_num = pdev->id;