From patchwork Thu Nov 30 02:38:30 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: 120066 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp133761qgn; Wed, 29 Nov 2017 18:38:58 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ8eTPBEy91MiAYgTSZOBotZcsHPR7ax6+xYNzlUDpUI8VTvgnQF5kbsRqq7KC3A0mvkBYd X-Received: by 10.99.173.78 with SMTP id y14mr931410pgo.107.1512009538481; Wed, 29 Nov 2017 18:38:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512009538; cv=none; d=google.com; s=arc-20160816; b=szQxub2mHymVCZTzXXtKIGHCPm1f99WPSPt6FvF0jGd8K9PeyGFrwJyLRf9k8smwRY ZJw8BtCf+roIBInnA94UyNJ8gxr6k5/aBAsx+FLvlAsl147FRzYmU1EOtG/XJm603Hj3 ncCc2t3K7oH4lfqxvpldYMtQz6Q6vWZsd8HbuUCxDntfNId0Cr2CATi3IilC0+BLScXO NN371mWjrIDrzL/SNjwyexcMD7VPfeELlfPY1Ej69iAw0r4a1Y+vRO/5Z1ffYOjaxsJG +KjbVtStYUKcEAKetEjNth719t5sNbIL8UtKibOgTMajpML7Nfw6NYrsikbMHyCCaCie Z9VQ== 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=HdHHtrxEK3RT4C1um+xXjJkL9uYnQlasgc7RN2z57xc=; b=YP5bwkL+GMRz+hyrfvatd2ck8X5CKUQJfKsQD8iTa3KOc6DzmBAEiqqaCEFhHcrZ4P 0W3FLT6KNBiR3ngKc7Wku4Gm0YLgyc1l4HW3MJLV85zagzt56IDpAC9Hawv0FG6QmxIs 7f4IMkht9yB115ohi+87lErF7cSIYmZ1WWOL1k8/KKltshc/zdPzDQdKcPP+r/iXU+yJ 1ziiFeyxOXkpj8gEzq4XONiZ1xGQBiNzj0dmieNYWH9VXlRr6isNRbOGtAnh9AYxctSZ bxQt1m0czMQTQY8IuvMGDQpuxALmW/CiRBOezndNTjP4lHdaUYH1c/JdUfBiwgdtmMf1 J6Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G8qUjKkG; 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 f19si2243650plr.610.2017.11.29.18.38.58; Wed, 29 Nov 2017 18:38:58 -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=G8qUjKkG; 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 S1753393AbdK3Ci4 (ORCPT + 28 others); Wed, 29 Nov 2017 21:38:56 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:38661 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752604AbdK3Ciy (ORCPT ); Wed, 29 Nov 2017 21:38:54 -0500 Received: by mail-pg0-f68.google.com with SMTP id f12so2392368pgo.5 for ; Wed, 29 Nov 2017 18:38:54 -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=HdHHtrxEK3RT4C1um+xXjJkL9uYnQlasgc7RN2z57xc=; b=G8qUjKkGsfR2wDaz3HTJklRUI3zexcnz97uqAFy08ntDTPtw0ndRLUcQ5yYIob6ZcN D1YkqUIV8ZEkVy7e4G0j1ZUbgimIlDXud6Hwv18RFmjpIYKG8oKmUA12z0rnI1UD8fMz +5577EzhptAHApqh94HvS8rQhs88hVmCwR5q4= 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=HdHHtrxEK3RT4C1um+xXjJkL9uYnQlasgc7RN2z57xc=; b=UP2Eyx1ywTcFR7d6VPNnzsvosK4NUtmuK+fn9346CHlvm8VqpmdkxjYpWzPPcHYXgo NmOhRpCZ4cTc7NfsFJIh9AyUDpZnwMEM8nA1d8zEE58JMXbXvzz9Hob1z4PA62YQJbNW Z07m4p422gyz7GV/gK2+wSQ757pKuaEG5eh6l1iMtkVGly+uIODbJKZKQfJrcBfc13Zx z1BGHjJmWTxpmp5c35TKG6be8KLGIwo9ZWQPFaCsMFBrblfvEJl+/q6UE5wMJVvi8xTy 3gNP3ydhZX/XWReBBPwtplNDzEjTV4KzsGIz29pjonnFJUxxCzlCrvGU3UbDFpYuRY4Q IGKA== X-Gm-Message-State: AJaThX6+spjNdmZoLYfOVlaeWJIhL6qYsEZQVPeCNtVkvMICpJl7zO0l xGTASztdfdN+pJrOJmNR2fomZA== X-Received: by 10.99.109.5 with SMTP id i5mr906313pgc.359.1512009534205; Wed, 29 Nov 2017 18:38:54 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id 69sm5557413pft.11.2017.11.29.18.38.51 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Nov 2017 18:38:53 -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 v4] mfd: syscon: Add hardware spinlock support Date: Thu, 30 Nov 2017 10:38:30 +0800 Message-Id: <2344ec4123c8b0985e54e03a0fa1bfe8d5e68235.1512009343.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 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 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 | 1 + drivers/mfd/syscon.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) -- 1.7.9.5 diff --git a/Documentation/devicetree/bindings/mfd/syscon.txt b/Documentation/devicetree/bindings/mfd/syscon.txt index 8b92d45..f464cc8 100644 --- a/Documentation/devicetree/bindings/mfd/syscon.txt +++ b/Documentation/devicetree/bindings/mfd/syscon.txt @@ -16,6 +16,7 @@ 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 { diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index b93fe4c..caf6a25 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;