From patchwork Fri Jun 7 08:28:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 166064 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp346119ili; Fri, 7 Jun 2019 01:29:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzauIEgY5HlswsLwSBJ+nQXWIl9BxCSyxjhn3IVoBBxeI9GRxDMy8bJ37SeiqmA91FfgvzT X-Received: by 2002:a63:5211:: with SMTP id g17mr1563844pgb.405.1559896148804; Fri, 07 Jun 2019 01:29:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559896148; cv=none; d=google.com; s=arc-20160816; b=rtM+1nhJzbjsJZqq2DtGq4+a6xARGSb19UEuWtJZggLwv5P+dduc81jCgMBrZL7DoQ h/5Ot+8rk0zS4oeU7xB+NbtKn+FmmhAqawcxwWi87jMWxpIL0yizl2Qs4fOq2JdnrFi+ hI8ehZ1yxxWVZYm+eDVmtrHuzkBTgO4GroRAfPb9D2w4njs6i50ZmutWQBtMqK6C4PCN S9MluQ45PJCXJPOHqYpUOtoopQqkDdU+o+o7MQ8mOyzVnMEXdzrNXRvh80vtKuSo/6fH QwW3zDznTao27jVMD49K1FZILE1OGPw5TV9BcA8tUW1FJjnnrZuatx4ZVnTrGxcD75sI vA9w== 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:message-id:date :subject:cc:to:from:dkim-signature; bh=slZHnEyI/3MoxuWJDHsmJjpXD82N/IlcEekyL2S9VGE=; b=NnCC+DnrJXS55TOrio7tnDFKTLVU3gctiNsrIRzYoZ6lFYhXWeRNzP0NQ0HbvYl40K CsroQK4K6ocw5JdZOV1LHDl8kZI8bGEyCG2/A9mBTFZF4vTlQO/E0gh1uYaDZ57d7b7N u1rw5olGfRqVwnQhn2yftp7QMbDY2Rt7VHzftHooJjtfNCYG2J67uN8TYlvV8PKeObb9 zjd+A+7xRw4V0emVyeew550dzCE3diPYeVlHoMSH8iXESPLIygILN6FapBsif+cCPkW9 5TcwEkjYef8wdNFeJZ2gsK/gLsQF59NWL6l8noWpz0cbEpnogTPu00fri+HS4/UpUyRB Db4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=h368Vx+b; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-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 f92si1397328plf.100.2019.06.07.01.29.08; Fri, 07 Jun 2019 01:29:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-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=h368Vx+b; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-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 S1727922AbfFGI3H (ORCPT + 5 others); Fri, 7 Jun 2019 04:29:07 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44033 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727263AbfFGI3H (ORCPT ); Fri, 7 Jun 2019 04:29:07 -0400 Received: by mail-wr1-f67.google.com with SMTP id b17so1213447wrq.11 for ; Fri, 07 Jun 2019 01:29:06 -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; bh=slZHnEyI/3MoxuWJDHsmJjpXD82N/IlcEekyL2S9VGE=; b=h368Vx+bZLWr0EL6gvHppBTRSD6ciSTtbA08qgE1t4taX1ccezuX+R++aXgYdUyb8y xqoTAMMnzsmDvOSRVcoiqE2DFyL7TAalaemw43t6ANajvZ6wL8XrTBPrSPCTaI37JOuC C+5L9vX/X5BqHwAWrn/zEo5FE4WFb8KPgNsOOUzOOniHj63Dv+LyXOscl8dFK8OY1u1o E/HW76TPKlwVq8tS/VJKvSGDMVvLLxyzlkHBehpsvVoeNsfJs8g8ByEL/eJhJVNJIndQ NPfMFhvNB2TjUGWQBnh8Zme9lqz8vUpZd67SuV+J3hkfi1YClwo9647sqAdkVGU2KAHa w/Bg== 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; bh=slZHnEyI/3MoxuWJDHsmJjpXD82N/IlcEekyL2S9VGE=; b=oHxDWcWtpgb4zuOx0wZcvpGjxcA0PCrw/n6iWp6jmDLq1tKRdieTE7V5UslYvF2sBD lMymOizaq08zPmB6N0wTpYhz2LvRjI/KZPYTB/L/+f1m1hzB92zj5RENr6mw9ZYcAO20 yz/nxnnz5xnsYkZLbW2yEsnhxgmpbVmUyfmf0lbTe1+uGcngwPW+ORzz9vTBS9jDWw25 sB7dpNfKmbLGsy3N2ywaAT5+EeLPSiAV6SJF+jkW8MZaFz0eabE3RlsMmEkF1ym7ZuSk DzHBpud9FB6JQYkR6mtBWnF4yLfXo8HefDA1oHV3NWuPBCWC2CMk9VEEMgNnca7b22si gzNA== X-Gm-Message-State: APjAAAW9K5TN86KR+QoADq7Bxz3MA40FYjb/w/ScHK5RagHWmEZSVCxO r1dEJI4pKn8HPTtezCIR4LmLnQ== X-Received: by 2002:a5d:5702:: with SMTP id a2mr370680wrv.89.1559896145359; Fri, 07 Jun 2019 01:29:05 -0700 (PDT) Received: from localhost.localdomain ([2.31.167.229]) by smtp.gmail.com with ESMTPSA id a3sm1092946wmb.35.2019.06.07.01.29.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Jun 2019 01:29:04 -0700 (PDT) From: Lee Jones To: alokc@codeaurora.org, andy.gross@linaro.org, david.brown@linaro.org, wsa+renesas@sang-engineering.com, bjorn.andersson@linaro.org, linus.walleij@linaro.org, balbi@kernel.org, gregkh@linuxfoundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, jlhugo@gmail.com, linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-gpio@vger.kernel.org, linux-usb@vger.kernel.org, Lee Jones Subject: [PATCH v2 3/8] pinctrl: msm: Add ability for drivers to supply a reserved GPIO list Date: Fri, 7 Jun 2019 09:28:56 +0100 Message-Id: <20190607082901.6491-3-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190607082901.6491-1-lee.jones@linaro.org> References: <20190607082901.6491-1-lee.jones@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org When booting MSM based platforms with Device Tree or some ACPI implementations, it is possible to provide a list of reserved pins via the 'gpio-reserved-ranges' and 'gpios' properties respectively. However some ACPI tables are not populated with this information, thus it has to come from a knowledgable device driver instead. Here we provide the MSM common driver with additional support to parse this informtion and correctly populate the widely used 'valid_mask'. Signed-off-by: Lee Jones --- drivers/pinctrl/qcom/pinctrl-msm.c | 18 ++++++++++++++++++ drivers/pinctrl/qcom/pinctrl-msm.h | 1 + 2 files changed, 19 insertions(+) -- 2.17.1 diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index ee8119879c4c..3ac740b36508 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -607,8 +607,23 @@ static int msm_gpio_init_valid_mask(struct gpio_chip *chip) int ret; unsigned int len, i; unsigned int max_gpios = pctrl->soc->ngpios; + const int *reserved = pctrl->soc->reserved_gpios; u16 *tmp; + /* Driver provided reserved list overrides DT and ACPI */ + if (reserved) { + bitmap_fill(chip->valid_mask, max_gpios); + for (i = 0; reserved[i] >= 0; i++) { + if (i >= max_gpios || reserved[i] >= max_gpios) { + dev_err(pctrl->dev, "invalid list of reserved GPIOs\n"); + return -EINVAL; + } + clear_bit(reserved[i], chip->valid_mask); + } + + return 0; + } + /* The number of GPIOs in the ACPI tables */ len = ret = device_property_read_u16_array(pctrl->dev, "gpios", NULL, 0); @@ -964,6 +979,9 @@ static void msm_gpio_irq_handler(struct irq_desc *desc) static bool msm_gpio_needs_valid_mask(struct msm_pinctrl *pctrl) { + if (pctrl->soc->reserved_gpios) + return true; + return device_property_read_u16_array(pctrl->dev, "gpios", NULL, 0) > 0; } diff --git a/drivers/pinctrl/qcom/pinctrl-msm.h b/drivers/pinctrl/qcom/pinctrl-msm.h index c12048e54a6f..23b93ae92269 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.h +++ b/drivers/pinctrl/qcom/pinctrl-msm.h @@ -121,6 +121,7 @@ struct msm_pinctrl_soc_data { bool pull_no_keeper; const char *const *tiles; unsigned int ntiles; + const int *reserved_gpios; }; extern const struct dev_pm_ops msm_pinctrl_dev_pm_ops;