From patchwork Fri Jul 26 07:20:49 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: 169783 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12647977ilk; Fri, 26 Jul 2019 00:21:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQAcENuVI4f8zxUB7UC5EKW3HPBcOm0mYoFvIA4dDGEnbiaYeqqRuBtHJPUKjQHE2b8Aua X-Received: by 2002:a17:902:a606:: with SMTP id u6mr88114596plq.275.1564125692719; Fri, 26 Jul 2019 00:21:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564125692; cv=none; d=google.com; s=arc-20160816; b=1BoYgXdU2iAc0XJTXsTnPLLtoLfGWcU6u7Ni50bRJ5CuWk7rCY4ZbY8j1E9QDsk3Qf gGGJ1jrBlwYxJA3J8G7oByABpdois6ck+lGHIqzlUnxX02QJy72gzkMG5yyshNsO58UV 5axtYApWD7HkBOFaTyEsfD51hXi885vec6gW9BySEpHjR804HtvpGVws336CnGUlwH3k Pz4tcMv9bGHdtoiADZtnT4Y7gbwHT6BWJWtM15bcO99cc+owlOl6ixHhMGOuuO0++IJt XxJAMKDf+A8WYoDusSBV7lOCDoYtg/LKjTmrMqWSCsLzjrXIke0PMPYzxLJjLoQh8mmW AQ9Q== 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=b1L8klkoL2Oqr4w2X+VMFT6OyaJM5PiYuc6bxPNU4L8=; b=N5Ndax8tDicII4nUYbx/w77NIjbWkKJA7MTs+uYODh2/J92F2nk+/hBOo6LtaNZ4xI Nsd5h+3Q3GQ1FbDY++7kxGZXrsNqdkXiQGUN6OwPW6y4ZgkutsVrQ92tBJikDNycxnKu gQb0DR1EUTl00ekMrD+mjNzCNZFJ6ahx27DkSaII/IN5G3AfsdYg4Nt07ksL4ZuGO2rJ YcgJGM9NdvITi2PX/G14CIAaAEpfkl49MqOQZdsTdatAOfbcc6/uBaXn9wq9g/qnPW9/ wiUZU0n5GrSpLsflv3JC3ye1rD2dNP8BvkHAZ0/fBMahHOb84zxwhqY39QLQq7oQFGQt sKog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vFi7c+GF; 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 33si44695577plv.153.2019.07.26.00.21.32; Fri, 26 Jul 2019 00:21:32 -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=vFi7c+GF; 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 S1725944AbfGZHVb (ORCPT + 29 others); Fri, 26 Jul 2019 03:21:31 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42665 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725867AbfGZHV3 (ORCPT ); Fri, 26 Jul 2019 03:21:29 -0400 Received: by mail-pf1-f193.google.com with SMTP id q10so24054756pff.9 for ; Fri, 26 Jul 2019 00:21:29 -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=b1L8klkoL2Oqr4w2X+VMFT6OyaJM5PiYuc6bxPNU4L8=; b=vFi7c+GFBkJu3RCOXu9B84n2sjWjYyooQbcp5xnohrzGwUanT74gDGHm+agculUfuB e+79A1x/faNu+a9h13lWaqV6TWZpV6mecRdyBZ6TTI+KoZWr25dixirBm4GiFD5OwLdH tXpgF3leSF9Hs5VNpLmJ/1VMcVsFxY8oZ2tvjTCBmcxd+nyxhsxNINiJiMZWFB7r0bMw nqP6whtn/2Twy8dv5V44OsUyAZiiEPr5BLB9z4reDW3slv0nfeAYEikjH6tR2mHedotn 43lqm3+QaTTwusAVyqhZ+Fb6WO7w9H+n7v9xTrvAgCehB6j4/OOEAyLxgRGq0nTQHjHh IG/A== 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=b1L8klkoL2Oqr4w2X+VMFT6OyaJM5PiYuc6bxPNU4L8=; b=ARlGuVR+GbiBOw32FQ9XgQW6pGMmyco9S3N1wIEtzui9WwjXPYJGU9kePDPOAKpNZR 3N13hu2AO/K3s6rdg7YnEhPRlCHZjIu7GbfkYZS9JM/Xt1DvSeZnec0zsTsFEYtLUg9r ntt8E5JrCQfO8y5DGrqoDk96zJJxf1dC9wrCkrfXvRSuAab0vteoHC8tmw/8PSx6P1ZA wLhodgoa7E/LlnUrcvBzSxcTqiYKkx/3LRl/IVW3arFUvYg1KmtFaSKCRhLmbp0QrTl6 qNphKWs/zvJoJr2UZR02FFTk39YHLZnhWMYFkHWIfHdDtCy3wef+FY0bRUGPCwjEgKI/ lRdg== X-Gm-Message-State: APjAAAV97xdahJHIl3nIuVvwpu6i1ul4FsMEdw72s0qp2zEcYiamSDm6 koWJ+pIlMULVud5KDRT2Zt4b8Q== X-Received: by 2002:a65:6691:: with SMTP id b17mr74681456pgw.217.1564125689079; Fri, 26 Jul 2019 00:21:29 -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.25 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jul 2019 00:21:28 -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 2/6] spi: sprd: adi: Add a reset reason for TOS panic Date: Fri, 26 Jul 2019 15:20:49 +0800 Message-Id: <97583aad1f2b849d69b4e76e8d29113da72a9fff.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: Chenxu Wei Add a new reset flag to indicate the reset reason is caused by TOS. Signed-off-by: Chenxu Wei Signed-off-by: Baolin Wang --- drivers/spi/spi-sprd-adi.c | 3 +++ 1 file changed, 3 insertions(+) -- 1.7.9.5 diff --git a/drivers/spi/spi-sprd-adi.c b/drivers/spi/spi-sprd-adi.c index 11880db..0b3f23a 100644 --- a/drivers/spi/spi-sprd-adi.c +++ b/drivers/spi/spi-sprd-adi.c @@ -86,6 +86,7 @@ #define BIT_WDG_EN BIT(2) /* Definition of PMIC reset status register */ +#define HWRST_STATUS_SECURITY 0x02 #define HWRST_STATUS_RECOVERY 0x20 #define HWRST_STATUS_NORMAL 0x40 #define HWRST_STATUS_ALARM 0x50 @@ -336,6 +337,8 @@ static int sprd_adi_restart_handler(struct notifier_block *this, reboot_mode = HWRST_STATUS_IQMODE; else if (!strncmp(cmd, "sprdisk", 7)) reboot_mode = HWRST_STATUS_SPRDISK; + else if (!strncmp(cmd, "tospanic", 8)) + reboot_mode = HWRST_STATUS_SECURITY; else reboot_mode = HWRST_STATUS_NORMAL; 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; From patchwork Fri Jul 26 07:20:52 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: 169786 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12648171ilk; Fri, 26 Jul 2019 00:21:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZzoJFV3Srs9RTLxEINkMGmoK2EyKiyuM7D7kjmb/rWzEU7aOXaVQrBHaWlffRr+hL2JLg X-Received: by 2002:a65:4844:: with SMTP id i4mr91439066pgs.113.1564125703572; Fri, 26 Jul 2019 00:21:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564125703; cv=none; d=google.com; s=arc-20160816; b=fz5vt97o1ihXANGqaIHGINHzlteB4U00lUNtW2GGa4hfW7tUfNuNfr+OYXRUd/EsDy AWHdDCmYDxE6fO2uRfdIfdtroFoy7LKUKY8fCyK9vafNi+2fkF8gpm+mDAXV0+8LvHSU dQPNGciJsHvNCkOS5JHRTOxTtW3z1nRR9w3FOPISuzlp6ueEU0+niqJv6so491Jl7yHw eCLPADRy+jqzNsn3XcefkZc70rfoK4AQQ2O1wH/jh3HQOIUzMfjpAgSiPqDjyZdjxBzO y92Oy6EmFSh69gFKrbeOfG8OYabhTSeniVZZ2y9h2SY2GJJxoxj5PkIZmgIKTlz0bIsX 7MwA== 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=NWVsUkkDHIuRmUj9QU93X+5+YMySiLs15Fa6SS5cpaE=; b=kv3sha3cJzhphsb8pXyow0tEj4+7Reo0ivfEKw7OgUGP+g6JDea5dXBBHpSOxzqCl9 JxGaKT17HzRXBe/ailoOcFLoKPQX2GUyQlPeec6p0mtiTaKTG2hamervVzq/p6iYZDA5 LDRjENE+Y+xuHNQ9VkLrWa2ixAPxt2WZVS5RAr2qgO454RGzI8SXNe/XZweCha7xCGr5 HnXhlO+h1PYerNac+eXy2ONM4pYicvRT+COZuFB28VJbP4Ab1CmctmXPH6cdo2KysAOj LG8o8dpj7PjoMj2DYvJvj6/z9ZyhBHXFTCC7GZBCzZ8y0689f4yNtcW6oxlCRngwPoB0 NLBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PV6UmmpT; 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.43; Fri, 26 Jul 2019 00:21:43 -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=PV6UmmpT; 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 S1726561AbfGZHVm (ORCPT + 29 others); Fri, 26 Jul 2019 03:21:42 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:33932 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726529AbfGZHVk (ORCPT ); Fri, 26 Jul 2019 03:21:40 -0400 Received: by mail-pg1-f194.google.com with SMTP id n9so18111207pgc.1 for ; Fri, 26 Jul 2019 00:21:40 -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=NWVsUkkDHIuRmUj9QU93X+5+YMySiLs15Fa6SS5cpaE=; b=PV6UmmpTsl4qyL9YLpPEkrDLpNgZumlLqQgJL5tf2AhWNCYTaorte9k2Pj6IBUNSly P3k2AtwrjF3ASvtlPfbzMtob1Cg03Jd+goAm4I7kOQisa12ZR8ojvxgnuaesv3WCzKFe Pq4rBflmWmlGTT2BdXqwa0x25C5sGnY4r3dCX5ZxUlkDj23l8P1xT5sr2XjxSPYPgErI 6schkzFTtMrRNHU3fT2UZrOgBpsicdyIYMZgQj3x1b4OkZNx911u9ycHBJuLm7pEVZda IlKXw2hSsZESskRI+3b+vVA34+9nm2QXl2cxQB7Nb6VGGObnFHwYVgBPu6WvUEsFzssY vvvQ== 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=NWVsUkkDHIuRmUj9QU93X+5+YMySiLs15Fa6SS5cpaE=; b=Y+Or2/DDUXYPwgSWBgAFITAleGBM6HtGe44dhSRhQ0n30w4PnUTCYlCJ0z8VFhLzXi 1ErSX6QEQ6Di+Avnm6ky0vwH+M9IT89K9hi5hKYIQVBz/gDfNqmIzV51/yCHYlbqRSYW 4hHd9m1bodBb7MBCfShovCF5winh6qvlk8UOONeZ3iQWeQf4qxbOQ6ymKT8QkTwwRzBy I349eOV+dEV5up0Z+1+GpnNavfOJqoLl3GeTf6XqjSVwIBbav3ysttuRP2qDt4f2I60j bG6795XRsLvgu2gbSyb2KPJsWcyCROSIUMduc6iaSo02LdldbT0PUz+pSjVin48rN4k4 qXGw== X-Gm-Message-State: APjAAAWUPABVvtX3eiGlvFUyfz63pAM4sVLWtE0Sa9Evn4CVOHT+EGTW cjS60LxW+7eVgMee5Yx4N4kobQ== X-Received: by 2002:a63:7358:: with SMTP id d24mr89898767pgn.224.1564125700079; Fri, 26 Jul 2019 00:21:40 -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.36 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jul 2019 00:21:39 -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 5/6] spi: sprd: adi: Change hwlock to be optional Date: Fri, 26 Jul 2019 15:20:52 +0800 Message-Id: <2abe7dcf210e4197f8c5ece7fc6d6cc1eda8c655.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 Now Spreadtrum ADI controller supplies multiple master accessing channel to support multiple subsystems accessing, instead of using a hardware spinlock to synchronize between the multiple subsystems. To keep backward compatibility, we should change the hardware spinlock to be optional. Moreover change to use of_hwspin_lock_get_id() function which return -ENOENT error number to indicate no hwlock support. Signed-off-by: Baolin Wang --- drivers/spi/spi-sprd-adi.c | 68 +++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 26 deletions(-) -- 1.7.9.5 diff --git a/drivers/spi/spi-sprd-adi.c b/drivers/spi/spi-sprd-adi.c index 0d767eb..9a05128 100644 --- a/drivers/spi/spi-sprd-adi.c +++ b/drivers/spi/spi-sprd-adi.c @@ -165,14 +165,16 @@ static int sprd_adi_read(struct sprd_adi *sadi, u32 reg_paddr, u32 *read_val) int read_timeout = ADI_READ_TIMEOUT; unsigned long flags; u32 val, rd_addr; - int ret; - - ret = hwspin_lock_timeout_irqsave(sadi->hwlock, - ADI_HWSPINLOCK_TIMEOUT, - &flags); - if (ret) { - dev_err(sadi->dev, "get the hw lock failed\n"); - return ret; + int ret = 0; + + if (sadi->hwlock) { + ret = hwspin_lock_timeout_irqsave(sadi->hwlock, + ADI_HWSPINLOCK_TIMEOUT, + &flags); + if (ret) { + dev_err(sadi->dev, "get the hw lock failed\n"); + return ret; + } } /* @@ -219,7 +221,8 @@ static int sprd_adi_read(struct sprd_adi *sadi, u32 reg_paddr, u32 *read_val) *read_val = val & RD_VALUE_MASK; out: - hwspin_unlock_irqrestore(sadi->hwlock, &flags); + if (sadi->hwlock) + hwspin_unlock_irqrestore(sadi->hwlock, &flags); return ret; } @@ -230,12 +233,14 @@ static int sprd_adi_write(struct sprd_adi *sadi, u32 reg_paddr, u32 val) unsigned long flags; int ret; - ret = hwspin_lock_timeout_irqsave(sadi->hwlock, - ADI_HWSPINLOCK_TIMEOUT, - &flags); - if (ret) { - dev_err(sadi->dev, "get the hw lock failed\n"); - return ret; + if (sadi->hwlock) { + ret = hwspin_lock_timeout_irqsave(sadi->hwlock, + ADI_HWSPINLOCK_TIMEOUT, + &flags); + if (ret) { + dev_err(sadi->dev, "get the hw lock failed\n"); + return ret; + } } ret = sprd_adi_drain_fifo(sadi); @@ -261,7 +266,8 @@ static int sprd_adi_write(struct sprd_adi *sadi, u32 reg_paddr, u32 val) } out: - hwspin_unlock_irqrestore(sadi->hwlock, &flags); + if (sadi->hwlock) + hwspin_unlock_irqrestore(sadi->hwlock, &flags); return ret; } @@ -476,16 +482,26 @@ static int sprd_adi_probe(struct platform_device *pdev) sadi->slave_pbase = res->start + ADI_SLAVE_OFFSET; sadi->ctlr = ctlr; sadi->dev = &pdev->dev; - ret = of_hwspin_lock_get_id_byname(np, "adi"); - if (ret < 0) { - dev_err(&pdev->dev, "can not get the hardware spinlock\n"); - goto put_ctlr; - } - - sadi->hwlock = devm_hwspin_lock_request_specific(&pdev->dev, ret); - if (!sadi->hwlock) { - ret = -ENXIO; - goto put_ctlr; + ret = of_hwspin_lock_get_id(np, 0); + if (ret > 0 || (IS_ENABLED(CONFIG_HWSPINLOCK) && ret == 0)) { + sadi->hwlock = + devm_hwspin_lock_request_specific(&pdev->dev, ret); + if (!sadi->hwlock) { + ret = -ENXIO; + goto put_ctlr; + } + } else { + switch (ret) { + case -ENOENT: + dev_info(&pdev->dev, "no hardware spinlock supplied\n"); + break; + default: + dev_err(&pdev->dev, + "failed to find hwlock id, %d\n", ret); + /* fall-through */ + case -EPROBE_DEFER: + goto put_ctlr; + } } sprd_adi_hw_init(sadi);