From patchwork Thu Nov 30 09:10:57 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: 120088 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp418304qgn; Thu, 30 Nov 2017 01:11:27 -0800 (PST) X-Google-Smtp-Source: AGs4zMbGh9/UvgY6BtJ5yX2vC5RYpnUhdX5FGTBzxPYMLWgBTKEwRBccwAzMbTeDbDO0kVqoZ2s7 X-Received: by 10.98.127.149 with SMTP id a143mr5979976pfd.65.1512033086913; Thu, 30 Nov 2017 01:11:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512033086; cv=none; d=google.com; s=arc-20160816; b=ZX8Ot1PULX/oAsO6UIntrCTgSyHBZRnaoOov6X+DyKrIL17AQrB8m6bdIvv5xpP2vF RsVhOClpCZq8aJ3n5NJBQH/Sma/mUa32hfQaBsJEdVT5CXDEo8iQD6CKzoqO7S9mU48e y+YMvcVY7d6FZeHKDdIta9mQTIp428xqpPtTCzdFAbuz25oH2El25eBx7MOFQzF5uHlG DZ0dBUsqdKF8GVDpubOlUGgvqAkLNCoRn+oSK076WH/N5fyBlfvrjpBB5EtpRjdt8HdX RUM0UOeqF5d8jDd98JqBE4FSsHooMqNehko/m43kLDoJnSIV4BPTMRuS8cOQkmj8sKu0 1O7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=noAz9PWP3MHfZPaOHbyxuEin6wwv8lTIu8ZNRlrv2Uk=; b=CpEbjWbDvc+nzo32mOU3MFoR4H8NZNiGtTFSZtUUKVMv9WzvmbCX/mGF33SKyBz+Oe bDLjPqAEeEMyTa3wDjSxUwpmo1zkCvsTSP5TsVPI1vZCu2bmZ4Gs1MOikX1zypniCfBr 6Pvcf3WZKwMCqviytMoC1kVr4VYGyZU2o5rm8h5pyUz/M9QVnHYIr27NEyWcGryfHbTf NURIRTQWgLNAJalNECRmPkpElYHnRVjQQlcR1QWA8mZN3WfAaJEjzLMKi+rZDN93XXV/ wBupEoHzMQGEIrSCD+7VtvW7X+NCiwosRydkDzHxM6xXUv1bZbqYLzyf7NuKBc2asBl4 cHOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LT3Qo/q1; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (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 e11si2616909plj.660.2017.11.30.01.11.26; Thu, 30 Nov 2017 01:11:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LT3Qo/q1; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751366AbdK3JLZ (ORCPT + 6 others); Thu, 30 Nov 2017 04:11:25 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:36063 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751157AbdK3JLX (ORCPT ); Thu, 30 Nov 2017 04:11:23 -0500 Received: by mail-pl0-f66.google.com with SMTP id b12so3876454plm.3 for ; Thu, 30 Nov 2017 01:11:23 -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; bh=wPsPt88Mvx6a1puwc9Se6r7Z6tKAPNwy7TiyoJ3xTR4=; b=LT3Qo/q1/cZleWphDHvUwJX7fi8ULTlJkeJpRVNjxY5K4r+ctjq9dHx0ThlMVzpi58 xTCaJbYOBCFWz8C6tDTQaHsycEYX7JPwS2Z5XJ4OLOa4zmlR2fEuA2WrGhEB7feCx5qh fSuDgW3+kFidAUdPgJDmlGhb6XIFgxAtDdZKw= 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; bh=wPsPt88Mvx6a1puwc9Se6r7Z6tKAPNwy7TiyoJ3xTR4=; b=EJ8/loc3vwnpSa6Yuy39zR7CKl+Mm7lMru9Z84K3PQPE/eCgEoLUHuMmPZr0SirXJg QQKfkjSArkup8NMjzS2CMZQHpybNlnNyie7K2RBugOwKv031g5OTpb3IA3eijtvuVG8N cTsgOeeBEZAdv6fHWE5ARjCBf61NYvSGhOmFgHEzIjJnbgyNOaf579e6mvWQwwWXeqha r88Rb3YuTMS4YFExXnpBeh93zacRmV1JgmSvYLZy0CdXL/mtt+/11+zLOyCTXVRyYWae VUugcQQR2HXDMJQFtGmaJHV+0+/s/NU8iVaSJMadJ9NKDKL16L7OG2WOUv3RY3k2GqzK pLGA== X-Gm-Message-State: AJaThX6WiSp8etO+a07BFfmHnYC112Q7TglN1ypQJJtwqUFSxVy+wYTJ NJq2uJPIvrnKYj6h8vuem1SS+A== X-Received: by 10.84.174.1 with SMTP id q1mr1973713plb.220.1512033082917; Thu, 30 Nov 2017 01:11:22 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id u6sm7251912pfk.126.2017.11.30.01.11.19 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Nov 2017 01:11:22 -0800 (PST) From: Baolin Wang To: lee.jones@linaro.org, arnd@arndb.de, robh+dt@kernel.org, mark.rutland@arm.com Cc: broonie@kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, baolin.wang@linaro.org Subject: [PATCH v5] mfd: syscon: Add hardware spinlock support Date: Thu, 30 Nov 2017 17:10:57 +0800 Message-Id: <9bd0bfdaf4e869e6216a0ef032b52cd28b33ab16.1512032962.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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 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 | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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..5b67dbc 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c @@ -13,6 +13,7 @@ */ #include +#include #include #include #include @@ -87,6 +88,26 @@ 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) { + syscon_config.hwlock_id = ret; + syscon_config.hwlock_mode = HWLOCK_IRQSTATE; + } else { + switch (ret) { + case -ENOENT: + /* Ignore missing hwlock, it's optional. */ + break; + case 0: + ret = -EINVAL; + /* fall-through */ + 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;