From patchwork Mon Jun 10 08:42:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 166294 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp759027ilk; Mon, 10 Jun 2019 01:42:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6t+A1hK5W+tMxUUkblNf6u4qcmRvjpDaG51fKp9zw4e8VZ9fGD5RJkhQw78ZPQ+pgssON X-Received: by 2002:a63:4185:: with SMTP id o127mr3376084pga.82.1560156177692; Mon, 10 Jun 2019 01:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560156177; cv=none; d=google.com; s=arc-20160816; b=cjUBHO4GOjBMwzqs/fNTBrf9/g1LvVCUvBwDv+21wBrqTP9fEJVc1xGATmOuChBAnd pC7JDi/7kg7XYpYdfJJCtNvb9fJRrSnW7LuddMhwNLp8PYB0EDJh8X3W2fucWCKokVt4 3j2A0L21XZJ/xuFglX1qONqOdpdpYYNiBj9d5iHtHi+nWkFPVcPIEgIAC4c44gMWh81w N+AQjExN+kSWkQciSBCHYw++6O66ok4GsgZT+wIeI8QHtELTAigGbW6i7XqTMuOFaaze ZAu3VRd8h5HyadIYcvJ9WEETszo2/nVrlkdaSydFecVxZf5leyPHmE2KbYtGdSiqQ0zj lkDQ== 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=qYq7mFFCoR+D5QhtdnXfa7L63GrDNr+4aaRo7anMzNg=; b=VCCp9THmIPS1mq2PyEBJpDfA9WWc1aFgQQ55SGtxKTTqmgQQ7DogfSpqbsFvNwwV3d 7bPQL4UYFqbVAJC41F4nmMjvXok9qef+PLWkMIHIwj9wLLe6gD8iedBKG9tin2Ii4pXf yXj09qtqaBHTz/Bu+MhUbJNfoaJuBJsz6SyZUbvKhr0O9vXHaWCAqbytYRWUz5VvGruc 6QRwqyZOmBZPHqh5PMCYAhhYbEWUJY8uaotb4ZA69DYneAmchXWbA54M/ABVezulxAHp 4VZu79R55B/1vw58CxL+HGyL2q7GqtdntYWAOSozUQxbAJziGkptHgr0V1ZJ0sb0yLZY tJJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HAQGPWUr; 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 w6si2515243pfn.84.2019.06.10.01.42.57; Mon, 10 Jun 2019 01:42:57 -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=HAQGPWUr; 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 S2388415AbfFJIm4 (ORCPT + 5 others); Mon, 10 Jun 2019 04:42:56 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:44098 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388372AbfFJImU (ORCPT ); Mon, 10 Jun 2019 04:42:20 -0400 Received: by mail-wr1-f66.google.com with SMTP id b17so8236680wrq.11 for ; Mon, 10 Jun 2019 01:42:19 -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=qYq7mFFCoR+D5QhtdnXfa7L63GrDNr+4aaRo7anMzNg=; b=HAQGPWUrBC+m/uOp1ExdylTBwwXMRfgop11L7pNji5XWXcPZW+6ErRLi511mBcytaZ W3UqLkpw33YmjBArJFkiHuEHbOEyKduZ+bAn1mEZaUDLiIz0ME6BhyAqU9BZvH7w4t+c rfxKHG3Vi1cDONkuWZlhKKSyjl21utH0TeuiZXwU6bY4c5DqQm23B1Ij/Kf+CFiZQdZS 1IreLq1aIZRV0ksEv4kfk4qGpXympkIsPxtlWW9qyKWS8h1amE5syenHSK7Z1CX4qH63 7iKFPjYSg8pCpTER+gxm8AcOcrvXC8eg15KcJ/txMHz4kDbhbyfiQ5AM02XS+7GT4M7B 8oMA== 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=qYq7mFFCoR+D5QhtdnXfa7L63GrDNr+4aaRo7anMzNg=; b=f2T+cFCV7B9nbEJ0XM9/C26peu/GPA3Ihb6wYT1Kt4k87ym1rRkVc4BXcXl0a/FkHQ YW5aYhpkKPpv8VKRKNY9krEHSw0YNLlIjdAjT3lERYQV3WtvSdP8xgDdLk+JMsTrkUlH GeUWrKAT6McnCnfzC8LEF7urXGme0/YLhEAHdCciVXnKV2brnGNLRbG9KSslb8DxutPx FpatZVteTxSCNkAdLQiGdezIGZk8HZ9Ykx5/bQWitpBabjjCfjtljajC+mmhF8LelbK3 25YVB/53rx1pYZt/RUBrdGg2jJd/2jDKF4G6myiedF1RemzZoPpgQphEFr37bXqy2cvr 9NDQ== X-Gm-Message-State: APjAAAVaQLy7na8CHnjC/BYmcqpwc5eXt05tr3J/RoWHHCEwqMO8NFta EeD09/jEoNjGDGv3+Xpi/icpYQ== X-Received: by 2002:adf:ed41:: with SMTP id u1mr28476611wro.162.1560156138478; Mon, 10 Jun 2019 01:42:18 -0700 (PDT) Received: from localhost.localdomain ([2.31.167.229]) by smtp.gmail.com with ESMTPSA id a125sm9929670wmf.42.2019.06.10.01.42.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jun 2019 01:42:18 -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, ard.biesheuvel@linaro.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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Lee Jones Subject: [PATCH v3 3/8] pinctrl: msm: Add ability for drivers to supply a reserved GPIO list Date: Mon, 10 Jun 2019 09:42:08 +0100 Message-Id: <20190610084213.1052-3-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190610084213.1052-1-lee.jones@linaro.org> References: <20190610084213.1052-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 Reviewed-by: Bjorn Andersson --- 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;