From patchwork Thu Nov 30 13:33:11 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: 120194 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp674921qgn; Thu, 30 Nov 2017 05:33:38 -0800 (PST) X-Google-Smtp-Source: AGs4zMbBb/fMIeDwJtMo7FRkXKaIGtVQEDdS25+vNlhohYW14WhDZVegVNJImfbnqAf2sH+Nfkvv X-Received: by 10.101.102.66 with SMTP id z2mr2445169pgv.352.1512048818069; Thu, 30 Nov 2017 05:33:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512048818; cv=none; d=google.com; s=arc-20160816; b=Wd7f11foBaV8/I7+72wuPEi+KmEMsnDR145eZ7k/wsqBvf4enTKgsnHzpax83wI7li FLa1vs1GvjM0ftjG8BdsbZ3bCrYQvYa83sLTgYkmvoKIuahvEtJhNfJ+yViXhBsAn9Bv rt4K8vRbHiR1BfEHbuj+eQ9FzeAzpBsZQ+4SjrO4pre3HvrttSXp0Wc3+0lGf69CSFvw ykjSSXC/+hiB/ANDjC/4vaf8DmUOxgufAjRfAFDkjsFuLTk7r1MoNh91Ed/335FbEM0O 5v/lgF5lZm7sOt4NG7zWYsV1EdXkXXEAO74TbiHpezbzC307jk215/F32hVviSKR163L ExXg== 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=tK8S1kH1OlFZJHeFmF0g3/Y5d/9la/IxJPf7Nx+Q/bY=; b=YqMvXBS+j91AzbGQPjPrv2H3a9dnbCXAptjOt1/ErDXXE6Gv7raRjz7jcdL7O3BVSK zTm64h7tus1F4cjP0VoZfac0SGYSt6ZJA5n1He/3VkEYvJH3IE0AdRitU5uZCodSv/Sx 4sS7NQIWKwhx/Nl37WLcz1yZOud6niGcjWW5bK8fDzkaNDv3OKtDeZDYoLsxgsRd4q6r gpnTzp+FmsWTvdwomTAssNNhDLgQrngidCYnq8w6fO6SHJMnjIrapHuVNzFS/5yJHJ2G LuISlEdT05nXeBDFPwXe1jDOId8hMzKXmErkU68vemSJdayI1sE6VRWjoXLwtRXAv/AG LjeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Se+Nrw87; 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 e23si3018305pli.201.2017.11.30.05.33.37; Thu, 30 Nov 2017 05:33:38 -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=Se+Nrw87; 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 S1752730AbdK3Ndh (ORCPT + 27 others); Thu, 30 Nov 2017 08:33:37 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36628 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752651AbdK3Nde (ORCPT ); Thu, 30 Nov 2017 08:33:34 -0500 Received: by mail-pf0-f195.google.com with SMTP id p84so3113015pfd.3 for ; Thu, 30 Nov 2017 05:33:34 -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=tK8S1kH1OlFZJHeFmF0g3/Y5d/9la/IxJPf7Nx+Q/bY=; b=Se+Nrw87uPxhJvNPwR1bS6/Exs+XtsmGKXPdobrTm4HEx2rk+/tvnALQqBky36OGoa vz2iuw+z2NGXCZGc1Dalccz7jsG/pt08ybPpNft3jiRTP/YxNAQizgpoJ/NcBH+2PeBw eUHFgwgfJLuhLY5AWtTFAelAvaULB/CNtvIr4= 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=tK8S1kH1OlFZJHeFmF0g3/Y5d/9la/IxJPf7Nx+Q/bY=; b=sp0oHbawnyyER0mkfXOtTkxT4xUcPKC5XHUjrR3Zhgn8KlEt4NClxJ+skkgVi/ik4R bZbDgNW4NkJ9o/81BnDNoC6HiFfYw/JwJwrBy3m5J5YBWi7Hn4i93YzVbmCYA+9Ul8AW he+SQCVDS4sPZD8yws2ER6f7PsZi6pq/brGec6qLNDqMgnWVOzo+tIXd8ShhW8jiVOYV SCO8YEfgTFrVC0J6IpjWUFOcHGTMvn6F5MSSvR8uNjjiP3aGVpp76trXkdQ7lPWTMgUC cZDZWVzQGsVniN6SHkpYO6OzecjBytYXAo5ufjY1pNcqsc2YmJTzVwUG9eC8z7W20lXt xYCQ== X-Gm-Message-State: AJaThX4nyrCToPC3G29P+ngqi5qwA/NzNl1cSTJbKetJbakvRq0CO1pa E0hLiz5Lu6jqN7SUnADCftGBNw== X-Received: by 10.101.101.12 with SMTP id x12mr2407205pgv.420.1512048814060; Thu, 30 Nov 2017 05:33:34 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id 68sm8736066pfo.17.2017.11.30.05.33.30 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Nov 2017 05:33:33 -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 v6] mfd: syscon: Add hardware spinlock support Date: Thu, 30 Nov 2017 21:33:11 +0800 Message-Id: <87ec50c846bbc7afc09ba0855aba1cdea6473308.1512048582.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 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 | 25 ++++++++++++++++++++++ 2 files changed, 33 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..a7ae391 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c @@ -13,6 +13,7 @@ */ #include +#include #include #include #include @@ -87,6 +88,30 @@ 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: + /* In case of the HWSPINLOCK is not enabled. */ + if (!IS_ENABLED(CONFIG_HWSPINLOCK)) + break; + + 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;