From patchwork Tue Jun 4 10:44:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 165748 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp5667938ili; Tue, 4 Jun 2019 03:45:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBAVlHlcFPn3bKGaGRdyPs/KSMpe9aUXH30dbbr+EpR9spMRytmjGMw99J112kwk2iAqp9 X-Received: by 2002:a17:90a:9201:: with SMTP id m1mr36310192pjo.38.1559645105051; Tue, 04 Jun 2019 03:45:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559645105; cv=none; d=google.com; s=arc-20160816; b=l1c4eEMJIJR6CUPLQ8etyJOB730OwZV3HkyjDdjk1isBnORA3KTQwtNcMNKMehABzl NAO4fz6w4FVi5Fdq/QadrxiLp9dZighuTweX3fDNF4iP9qZi1FeBYXdDBNjsXYxqPbDg 8+4ipSrbFDrby1K7yF+YG/TIjSJIB9qxrJHWnOs3D2XkyAVtxHXROEWerPF5Fo31EZ+Z yxaeQPq8/071fUOcY6G+kV2W1GtzXgwijKF8LD5rUF4h9c8SzMjkOIC9yBSIule8aqhY hqYniXy5FsCh60NgICIJOk2plGuyFIT1KmeHraJI8pDQKVDlXrTbKdzEBDzudQiDu2te bJRg== 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=A0dgN5hMyM5nxH9+M3vRRIGFYdtXHLmFGt167GY3zJI=; b=q9JluFiW4cBlUjqDbB+22SUyLGHL5LkU6d2qkFEGN2wU1xmJQRgzcIS6F0GETUVhko Xv5bsm0rFjhFXI7OHvpt80Irv1lkVdXOlGNQCOVyb+IoQzRN0L7UYFnkGQ/vXdjBF/Lp vJoiuJWoo2EKs3lPBnKjmLMNL2/W1vduhev3GihVsAgockazbCGDjYiUKIM458wffK9t UmmB748NGXghDuARtD85e9UgcLMLYUbZ1Wdi77zqHroNTKoaO5vI93WGbsmeRbEY70LO f86JHTUh5dUeVA1PWCv6b5QIDT4CW6gOcJc8JZPb5Sxh5cSTr1ZV1MYOqqdghDAYfnHe 6CHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DHDjY8W7; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 j19si25417017pfd.189.2019.06.04.03.45.04; Tue, 04 Jun 2019 03:45:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=DHDjY8W7; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1727107AbfFDKpD (ORCPT + 15 others); Tue, 4 Jun 2019 06:45:03 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33893 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727420AbfFDKpC (ORCPT ); Tue, 4 Jun 2019 06:45:02 -0400 Received: by mail-wr1-f65.google.com with SMTP id e16so7021936wrn.1 for ; Tue, 04 Jun 2019 03:45:02 -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=A0dgN5hMyM5nxH9+M3vRRIGFYdtXHLmFGt167GY3zJI=; b=DHDjY8W7XNwgZLrWs6Tbaf/vx11sNga7Bt6FMHM9T7hwa8GkndNSQBvuVNxuhwVnLC CmSYL3dxuhqZfnAng9Fj6BbpLFcDcCeFXCKhWKDEHRJTllPxEK/xFxJLgnTVkupDLvQs 2+FLplp7gSQ1nlMo8mCnf+3tmok03BTwcuEtLI9n6LgUQ/RQVxhuS6PmOm35rtdI0uLj MTJE0qn6O0nQecJCUQgO0dajMXH90s1mNhc9Ax9vsrvbd/7VnruOU44JAk3lClJF2uEY XxCS1L4nRHo2Tdd1zgkaMv0onf2ZyNa9nq21lCWcHh/79BqgateHE8PYQwdpXhXWSi6B 00Hw== 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=A0dgN5hMyM5nxH9+M3vRRIGFYdtXHLmFGt167GY3zJI=; b=OPVoLcklrfYgnYyqhpj22WhVl6E0pmyc5QfDekrNK3nWojgb3VnBVZaVpe8GqWlyYu 3kqM6EvaAbNF6tV+cNlFJ0f3wKs5x74RDgY/lfSY/yK3sOkva73023WG2TDZQxKaPgEr E73uxR21OHWpqyJPQBD/zC7ilwQH4c1qcaM4syuwKU8zf3y9W9dd2BhUx5dEmNEmzZOf PbE+YbXnUv7t//TfsUjNomtGv2r3sBcmqbWtShvPa67WsENeD1kxO5Q1S0Cu+g5qvMkC 9yeJRyXwpReLNLR76B7tNEUDURdMhzRS3JaDmttF5Z1ZvdmuXfG2bGSffI0qnieWtSeH E+XQ== X-Gm-Message-State: APjAAAXNqZK3pLbF0HSBwHGvD4z0MHk40M53/kGsegnWgCEFeATczgRC Vc7Rf7+HsllSqP9IhGHDRl5+vOpqk5k= X-Received: by 2002:adf:ff88:: with SMTP id j8mr1508854wrr.317.1559645101648; Tue, 04 Jun 2019 03:45:01 -0700 (PDT) Received: from localhost.localdomain ([2.27.167.43]) by smtp.gmail.com with ESMTPSA id t140sm2718623wmt.0.2019.06.04.03.45.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 03:45:01 -0700 (PDT) From: Lee Jones To: alokc@codeaurora.org, kramasub@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 3/8] pinctrl: msm: Add ability for drivers to supply a reserved GPIO list Date: Tue, 4 Jun 2019 11:44:50 +0100 Message-Id: <20190604104455.8877-3-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190604104455.8877-1-lee.jones@linaro.org> References: <20190604104455.8877-1-lee.jones@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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..b77f22348907 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; i < max_gpios && 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;