From patchwork Mon Dec 25 06:37:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 122693 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5179520qgn; Sun, 24 Dec 2017 22:38:16 -0800 (PST) X-Google-Smtp-Source: ACJfBovh6yA3dqEUPkH1TJ8y4cnwgUDh/gYsZqoJ3O3PeUBIIK119HSjRbP6VXRm9UASmBfv0Hmm X-Received: by 10.101.100.143 with SMTP id e15mr4252451pgv.307.1514183896863; Sun, 24 Dec 2017 22:38:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514183896; cv=none; d=google.com; s=arc-20160816; b=i1CW1nPSWF63v1Gxbxe6Qe0ANGxly/eeUXpFnwbAOSwYgRfSbiXWxeARo9etXs/XFn DrzLOTgRnFH2OgIHnQf7PcA7uXJwY8YCPreCfFCH1yf/LKAXS80smtlVgjlEiLjzH2CB uiwagfSLExtpTCSGAqs3E4Ua2pPTrFG57KwvEEIu0vhxLFZ/vdjBoTK2Z8D8wIuU9t90 agO6iDg9qBSGPAdruhTyyMQ3PsEX6Pj9UIal4rkJUJi/ylttLlTILwA65oja1zWlXR9n xUH3qUp5qmmbJ0J7m5fqdfsTQxsYxkOGFwZ5sXUC33uwGcYPeDHVW/z2FjZofWeAmMrz 5qZw== 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 :arc-authentication-results; bh=guPdRaHcjPSZpN4m+itgCwTYvsRD99usjS2jyQHAnfU=; b=gs7vDCKv1jljExiLA65WMfzHoJ+iAOtbL7nLhmWJlbs4BZc71If5TAT7d1Rx2lKDpb vsQOiqhlfsLEd7vcqjZWBylc1dYwqx4lKc6RDt92LNvbiHeuUrW2zekCLJWAJNMrxsSt JiqfUtrlobR3T2TK+L+CsYp0BkFREhdtHUddyegueWOTkUvyRycOMI0Qngb/lCTqt9/F Etyjec/G/pRSDP/dP1t/9BIfVnY81uYglTbKSABaQn2ilhD/PnaXNYr8kjo147U3km0x ONMtKva58hbLcIYAmLrjjIR/6mepx05/wE0hn5hyalDSgnNq9gGUUqv2OgtnTT9RavvH wdXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NIggOUYu; 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 n11si15195466plg.289.2017.12.24.22.38.16; Sun, 24 Dec 2017 22:38:16 -0800 (PST) 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=NIggOUYu; 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 S1751809AbdLYGiG (ORCPT + 28 others); Mon, 25 Dec 2017 01:38:06 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:37024 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750981AbdLYGh5 (ORCPT ); Mon, 25 Dec 2017 01:37:57 -0500 Received: by mail-pg0-f66.google.com with SMTP id o13so5983226pgp.4 for ; Sun, 24 Dec 2017 22:37:57 -0800 (PST) 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=guPdRaHcjPSZpN4m+itgCwTYvsRD99usjS2jyQHAnfU=; b=NIggOUYut5ErOFIqnId3Dbc31QmwB4nCFsgHs5TlhSI5JdtoKshKwg364jNAq0J6Q0 6qWExD0vUdTrQjmDEafrJCG+zKDtzyhz/hrtqOw4vMEuMmtmeM4ncUvWDdQNLVg5hh6+ Wtv7YCH/59umUJJByFs1Qi+0vpdoPwedhxBfE= 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=guPdRaHcjPSZpN4m+itgCwTYvsRD99usjS2jyQHAnfU=; b=N41mZG6pWAkeB1YvfUSaw75mFty3FVNsI9vC95azQiqHiqGD9z/ZogJc4V2bx+m7v6 o8YFwS4yVMHxCQKPLdBghzSGfvaY6kr2RFozwl5HF6Z5RA/Wm0R2ypzcE3GHHjsLsZJp cd5aycx7icsgxiPIpwThkByfoaXhE+wnV2dqpEFVJMkPFdsDa6FzElqKQfoxb84KMugY 1UsTUW64YzdUmqj+kp1YZN0GfAbloXgtKmxxwbSLYYt2EfrxUqsgEA6XIBfbQTP9qCuX 4TmwOR26Hw87MsSLZ+QhT+w+O2Kbwqcht9vzwkAaQkbbJtu4gKZPiwMxrRcjKlt2UNPw NsYA== X-Gm-Message-State: AKGB3mL0mK4GeS6Nh3kEQVtismYG0n+htBTeRQi1QvB1Bfs9eDMUrW/8 X1IoZSAj3GJCx5OV7hWxdsCXLw== X-Received: by 10.98.31.142 with SMTP id l14mr21836724pfj.62.1514183877090; Sun, 24 Dec 2017 22:37:57 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id n66sm24007668pfn.64.2017.12.24.22.37.54 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Dec 2017 22:37:56 -0800 (PST) From: Baolin Wang To: lee.jones@linaro.org, arnd@arndb.de, robh+dt@kernel.org, mark.rutland@arm.com, broonie@kernel.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, baolin.wang@linaro.org Subject: [PATCH v7 2/2] mfd: syscon: Add hardware spinlock support Date: Mon, 25 Dec 2017 14:37:10 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <29fa88f883dae4c1f8a3acb2656cbd7c5a539d40.1514180039.git.baolin.wang@linaro.org> References: <29fa88f883dae4c1f8a3acb2656cbd7c5a539d40.1514180039.git.baolin.wang@linaro.org> In-Reply-To: <29fa88f883dae4c1f8a3acb2656cbd7c5a539d40.1514180039.git.baolin.wang@linaro.org> References: <29fa88f883dae4c1f8a3acb2656cbd7c5a539d40.1514180039.git.baolin.wang@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some system control registers need hardware spinlock to synchronize between the multiple subsystems, so we should add hardware spinlock support for syscon. Signed-off-by: Baolin Wang Acked-by: Rob Herring --- Changes since v6: - Treat hwlock id 0 as valid for regmap. Changes since v5: - Fix the case that hwspinlock is not enabled. Changes since v4: - Add one exapmle to show how to add hwlock. - Fix the coding style issue. Changes since v3: - Add error handling for of_hwspin_lock_get_id() Changes since v2: - Add acked tag from Rob. Changes since v1: - Remove timeout configuration. - Modify the binding file to add hwlocks. --- Documentation/devicetree/bindings/mfd/syscon.txt | 8 ++++++++ drivers/mfd/syscon.c | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) -- 1.7.9.5 diff --git a/Documentation/devicetree/bindings/mfd/syscon.txt b/Documentation/devicetree/bindings/mfd/syscon.txt index 8b92d45..25d9e9c 100644 --- a/Documentation/devicetree/bindings/mfd/syscon.txt +++ b/Documentation/devicetree/bindings/mfd/syscon.txt @@ -16,9 +16,17 @@ Required properties: Optional property: - reg-io-width: the size (in bytes) of the IO accesses that should be performed on the device. +- hwlocks: reference to a phandle of a hardware spinlock provider node. Examples: gpr: iomuxc-gpr@20e0000 { compatible = "fsl,imx6q-iomuxc-gpr", "syscon"; reg = <0x020e0000 0x38>; + hwlocks = <&hwlock1 1>; +}; + +hwlock1: hwspinlock@40500000 { + ... + reg = <0x40500000 0x1000>; + #hwlock-cells = <1>; }; diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index b93fe4c..7eaa40b 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c @@ -13,6 +13,7 @@ */ #include +#include #include #include #include @@ -87,6 +88,24 @@ static struct syscon *of_syscon_register(struct device_node *np) if (ret) reg_io_width = 4; + ret = of_hwspin_lock_get_id(np, 0); + if (ret > 0 || (IS_ENABLED(CONFIG_HWSPINLOCK) && ret == 0)) { + syscon_config.use_hwlock = true; + syscon_config.hwlock_id = ret; + syscon_config.hwlock_mode = HWLOCK_IRQSTATE; + } else if (ret < 0) { + switch (ret) { + case -ENOENT: + /* Ignore missing hwlock, it's optional. */ + break; + default: + pr_err("Failed to retrieve valid hwlock: %d\n", ret); + /* fall-through */ + case -EPROBE_DEFER: + goto err_regmap; + } + } + syscon_config.reg_stride = reg_io_width; syscon_config.val_bits = reg_io_width * 8; syscon_config.max_register = resource_size(&res) - reg_io_width;