From patchwork Thu Jun 22 20:54:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 9805281 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D5A8A600C5 for ; Thu, 22 Jun 2017 20:54:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3332B28542 for ; Thu, 22 Jun 2017 20:54:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2706828563; Thu, 22 Jun 2017 20:54:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 114E128542 for ; Thu, 22 Jun 2017 20:54:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=+AbdgbMuSWT3T9qvN/bTWZjf5WO6hFHWZ8Yute12RFU=; b=GRI B84yQ8OkMDPAPlyW8dLkrXrdJlh+LneOmohSVK3rWkVdRZyNUDH9vsF63u03XuNBmCx5JoRj92n3i QKoYmqs8GiBCAl08HCRo1LmROyZhCcrUCTDYOpTCzxeCmLy8AxdAPkH9AMeg5XzEpfrgXoYg/+J5W EHNu02M7VZfrqgvfLq+drYJFWHNkzwBqQ9TkUANFBWYVS5R8Mgwe/2/YFHVFxS7BZ1Z59oE9ZugQH iOcld8R3EZhoUkigH/Qjh9SgtebEguEiLiTnxZp568tQoBLdtBM3+HSPjxDfimVmaOn2+KIws9hBB 6jTRWyicsVAQNZOn4/ncsR5yCEZBLng==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dO97h-000379-DO; Thu, 22 Jun 2017 20:54:41 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dO97d-00036D-AQ for linux-arm-kernel@lists.infradead.org; Thu, 22 Jun 2017 20:54:39 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6051460A97; Thu, 22 Jun 2017 20:54:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1498164854; bh=1SdyrRt3tj6xlDr6GtB2ZhrNJN/ua6Rw9c0zzaxUZKc=; h=From:To:Cc:Subject:Date:From; b=VpT0XYZYee1rNFizwSagHrG9xNrZEb9RfnElrtR1K7UXAwjX1zMjOygikkG0+JJI+ nHds3aynbIj+4MJVMnNl5VDEnRHmvI3jQFH9/guy1XHD5m0HBH84lnAwvi6SEAx1RR 9h2a2aPcLedHsxiKcmljDHB9f6ZQ0gYsQacIm7Es= Received: from timur-ubuntu.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: timur@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 15E7260316; Thu, 22 Jun 2017 20:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1498164853; bh=1SdyrRt3tj6xlDr6GtB2ZhrNJN/ua6Rw9c0zzaxUZKc=; h=From:To:Cc:Subject:Date:From; b=ZnmCNlUytfcISBGsL1tsXZKnK+04JF8WtUAngRrSoGNnFDgRt+AheE6MejOleuNAu NwB66lY9UpZO5jSHXoeAh6Lz8UIO69Awj8ANeAeb9vI9p1qL+4ssbIFnCDjj95X5U6 R17Rb6bgW8ShvSEaXghfSORQFEEwlWVAFQ5esLuo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 15E7260316 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=timur@codeaurora.org From: Timur Tabi To: Andy Gross , David Brown , Linus Walleij , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, Bjorn Andersson Subject: [PATCH] pinctrl: qcom: qdf2xxx: expose only some GPIO pins Date: Thu, 22 Jun 2017 15:54:10 -0500 Message-Id: <1498164850-4738-1-git-send-email-timur@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170622_135437_441024_E5B63111 X-CRM114-Status: GOOD ( 14.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: timur@codeaurora.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Qualcomm Technologies QDF2xxx platforms, only a subset of the GPIOs are actually available to the HLOS. The others are blocked by the XPU, and any attempt to access them will cause an XPU violation that halts the system. Instead, the ACPI table now lists only specific GPIOs that are exposed externally as generic GPIO pins. To maintain consistency, the GPIOs are enumerated 0 .. (N-1) as before, so that "gpio0" is really whatever is the first GPIO listed in ACPI. The actual mapping is available via /sys/kernel/debug/gpio. Tested-by: Tyler Baicar Signed-off-by: Timur Tabi --- drivers/pinctrl/qcom/pinctrl-qdf2xxx.c | 46 ++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-qdf2xxx.c b/drivers/pinctrl/qcom/pinctrl-qdf2xxx.c index bb3ce5c..983df72 100644 --- a/drivers/pinctrl/qcom/pinctrl-qdf2xxx.c +++ b/drivers/pinctrl/qcom/pinctrl-qdf2xxx.c @@ -32,9 +32,6 @@ static struct msm_pinctrl_soc_data qdf2xxx_pinctrl; -/* A reasonable limit to the number of GPIOS */ -#define MAX_GPIOS 256 - /* maximum size of each gpio name (enough room for "gpioXXX" + null) */ #define NAME_SIZE 8 @@ -43,22 +40,35 @@ static int qdf2xxx_pinctrl_probe(struct platform_device *pdev) struct pinctrl_pin_desc *pins; struct msm_pingroup *groups; char (*names)[NAME_SIZE]; - unsigned int i; - u32 num_gpios; + unsigned int i, num_gpios; + u32 *gpios; int ret; /* Query the number of GPIOs from ACPI */ - ret = device_property_read_u32(&pdev->dev, "num-gpios", &num_gpios); + num_gpios = ret = device_property_read_u32_array(&pdev->dev, "gpios", + NULL, 0); if (ret < 0) { - dev_warn(&pdev->dev, "missing num-gpios property\n"); + dev_err(&pdev->dev, + "missing or invalid 'gpios' property (ret=%i)\n", ret); return ret; } - - if (!num_gpios || num_gpios > MAX_GPIOS) { - dev_warn(&pdev->dev, "invalid num-gpios property\n"); + if (ret == 0) { + dev_warn(&pdev->dev, "no GPIOs defined\n"); return -ENODEV; } + gpios = devm_kcalloc(&pdev->dev, num_gpios, sizeof(u32), GFP_KERNEL); + if (!gpios) + return -ENOMEM; + + ret = device_property_read_u32_array(&pdev->dev, "gpios", gpios, + num_gpios); + if (ret < 0) { + dev_err(&pdev->dev, + "could not read list of GPIOs (ret=%i)\n", ret); + return ret; + } + pins = devm_kcalloc(&pdev->dev, num_gpios, sizeof(struct pinctrl_pin_desc), GFP_KERNEL); groups = devm_kcalloc(&pdev->dev, num_gpios, @@ -69,7 +79,9 @@ static int qdf2xxx_pinctrl_probe(struct platform_device *pdev) return -ENOMEM; for (i = 0; i < num_gpios; i++) { - snprintf(names[i], NAME_SIZE, "gpio%u", i); + unsigned int gpio = gpios[i]; + + snprintf(names[i], NAME_SIZE, "gpio%u", gpio); pins[i].number = i; pins[i].name = names[i]; @@ -78,11 +90,11 @@ static int qdf2xxx_pinctrl_probe(struct platform_device *pdev) groups[i].name = names[i]; groups[i].pins = &pins[i].number; - groups[i].ctl_reg = 0x10000 * i; - groups[i].io_reg = 0x04 + 0x10000 * i; - groups[i].intr_cfg_reg = 0x08 + 0x10000 * i; - groups[i].intr_status_reg = 0x0c + 0x10000 * i; - groups[i].intr_target_reg = 0x08 + 0x10000 * i; + groups[i].ctl_reg = 0x10000 * gpio; + groups[i].io_reg = 0x04 + 0x10000 * gpio; + groups[i].intr_cfg_reg = 0x08 + 0x10000 * gpio; + groups[i].intr_status_reg = 0x0c + 0x10000 * gpio; + groups[i].intr_target_reg = 0x08 + 0x10000 * gpio; groups[i].mux_bit = 2; groups[i].pull_bit = 0; @@ -100,6 +112,8 @@ static int qdf2xxx_pinctrl_probe(struct platform_device *pdev) groups[i].intr_detection_width = 2; } + devm_kfree(&pdev->dev, gpios); + qdf2xxx_pinctrl.pins = pins; qdf2xxx_pinctrl.groups = groups; qdf2xxx_pinctrl.npins = num_gpios;