From patchwork Thu Jan 25 18:22:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Kundr=C3=A1t?= X-Patchwork-Id: 925170 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=cesnet.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=cesnet.cz header.i=@cesnet.cz header.b="IAG9xfyM"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4102VK44T8z9s0W for ; Tue, 5 Jun 2018 03:48:41 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751058AbeFDRsg (ORCPT ); Mon, 4 Jun 2018 13:48:36 -0400 Received: from office2.cesnet.cz ([195.113.144.244]:48656 "EHLO office2.cesnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751285AbeFDRse (ORCPT ); Mon, 4 Jun 2018 13:48:34 -0400 Received: from localhost (unknown [IPv6:2001:718:1:2c:a4a8:fc6b:670f:47e3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by office2.cesnet.cz (Postfix) with ESMTPSA id 75F70400075; Mon, 4 Jun 2018 19:40:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesnet.cz; s=office2; t=1528134030; bh=aLtikjsk+FnEa4h3m8cD/btRuvfRb76gf2k+CVBA03s=; h=Resent-Date:Resent-From:Resent-To:Resent-Cc:In-Reply-To: References:From:Date:Subject:To:Cc; b=IAG9xfyMEpD5aotkEYhy2aJFtGzCRvsP8O75JYWdQIc33xpklbl3eRcnwE3NzoMBd usen3GI5J+OL/h8ZveV5wxMQicMDU1W0RrkDJRYpOOLre3ajGezbIshLXjJRTS7048 bOSXq1nS6TayyP0l8wuB+OHoc2wTRRwdRP8J/8Mc= Message-Id: In-Reply-To: References: From: =?utf-8?q?Jan_Kundr=C3=A1t?= Date: Thu, 25 Jan 2018 19:22:02 +0100 Subject: [PATCH 1/4] pinctrl: mcp23s08: Do not complain about unsupported params MIME-Version: 1.0 To: linux-gpio@vger.kernel.org Cc: Sebastian Reichel , Linus Walleij , Phil Reid Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org It is expected that some of these operations won't work on each and every HW. Previously, even a simple `cat /sys/kernel/debug/pinctrl/spi1.1/pinconf-pins` caused excessive dmesg output. Signed-off-by: Jan Kundrát Reviewed-by: Phil Reid --- drivers/pinctrl/pinctrl-mcp23s08.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c index 022307dd4b54..fd9d27e8126e 100644 --- a/drivers/pinctrl/pinctrl-mcp23s08.c +++ b/drivers/pinctrl/pinctrl-mcp23s08.c @@ -265,7 +265,6 @@ static int mcp_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin, status = (data & BIT(pin)) ? 1 : 0; break; default: - dev_err(mcp->dev, "Invalid config param %04x\n", param); return -ENOTSUPP; } @@ -292,7 +291,6 @@ static int mcp_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, ret = mcp_set_bit(mcp, MCP_GPPU, pin, arg); break; default: - dev_err(mcp->dev, "Invalid config param %04x\n", param); return -ENOTSUPP; } } From patchwork Thu Feb 15 14:56:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Kundr=C3=A1t?= X-Patchwork-Id: 925169 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=cesnet.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=cesnet.cz header.i=@cesnet.cz header.b="qADBOfJ3"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4102VJ5Txnz9s0w for ; Tue, 5 Jun 2018 03:48:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751274AbeFDRsf (ORCPT ); Mon, 4 Jun 2018 13:48:35 -0400 Received: from office2.cesnet.cz ([195.113.144.244]:48640 "EHLO office2.cesnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751058AbeFDRsc (ORCPT ); Mon, 4 Jun 2018 13:48:32 -0400 Received: from localhost (unknown [IPv6:2001:718:1:2c:a4a8:fc6b:670f:47e3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by office2.cesnet.cz (Postfix) with ESMTPSA id DB4F9400077; Mon, 4 Jun 2018 19:40:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesnet.cz; s=office2; t=1528134031; bh=aMQ31P5PNpIPwKT1y7HFH1U8U153tE/ot9HiJ492uCo=; h=Resent-Date:Resent-From:Resent-To:Resent-Cc:In-Reply-To: References:From:Date:Subject:To:Cc; b=qADBOfJ3x1DjETrwaYJh4Q/DGccsWogKxGCcAdPtUqhm1dT60JQV9nXlvpZO/zZ9X HEGqFnLHX7aZJv6oeoZmXUuOnrgv52lkQItJs3sjyeuKUDBx+ZgnXEU4RBaBxfa0X3 1xLOfmCKhr989g8SiUjnmI5Q5+1Uzd45Ex9W4OXQ= Message-Id: In-Reply-To: References: From: =?utf-8?q?Jan_Kundr=C3=A1t?= Date: Thu, 15 Feb 2018 15:56:03 +0100 Subject: [PATCH 2/4] pinctrl: mcp23s08: Kconfig: update to reflect supported features MIME-Version: 1.0 To: linux-gpio@vger.kernel.org Cc: Sebastian Reichel , Linus Walleij , Phil Reid Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Commit d8f4494e70ae removed comments which described this limitation. The code supported interrupts even before. Also add some spacing so that the chip IDs are a bit more readable. Signed-off-by: Jan Kundrát Reviewed-by: Phil Reid --- drivers/pinctrl/Kconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index 01fe8e0455a0..3df05c1e1efc 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig @@ -161,10 +161,10 @@ config PINCTRL_MCP23S08 select REGMAP_SPI if SPI_MASTER select GENERIC_PINCONF help - SPI/I2C driver for Microchip MCP23S08/MCP23S17/MCP23008/MCP23017 - I/O expanders. - This provides a GPIO interface supporting inputs and outputs. - The I2C versions of the chips can be used as interrupt-controller. + SPI/I2C driver for Microchip MCP23S08 / MCP23S17 / MCP23S18 / + MCP23008 / MCP23017 / MCP23018 I/O expanders. + This provides a GPIO interface supporting inputs and outputs and a + corresponding interrupt-controller. config PINCTRL_OXNAS bool From patchwork Tue Feb 20 18:04:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Kundr=C3=A1t?= X-Patchwork-Id: 925167 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=cesnet.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=cesnet.cz header.i=@cesnet.cz header.b="kzktr8jD"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4102VH1YKGz9s0w for ; Tue, 5 Jun 2018 03:48:39 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751182AbeFDRse (ORCPT ); Mon, 4 Jun 2018 13:48:34 -0400 Received: from office2.cesnet.cz ([195.113.144.244]:48644 "EHLO office2.cesnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751042AbeFDRsc (ORCPT ); Mon, 4 Jun 2018 13:48:32 -0400 Received: from localhost (unknown [IPv6:2001:718:1:2c:a4a8:fc6b:670f:47e3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by office2.cesnet.cz (Postfix) with ESMTPSA id B126D400079; Mon, 4 Jun 2018 19:40:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesnet.cz; s=office2; t=1528134037; bh=W6aUB1xTpgjRZ8oPQwqLmCvJj1mnAorxhglGROC30nE=; h=Resent-Date:Resent-From:Resent-To:Resent-Cc:In-Reply-To: References:From:Date:Subject:To:Cc; b=kzktr8jD9WJhaLZ5OK+afIJejV3rB6Ez/HxTnPDc4zk8fB8YjqqVsVlMq57dPiapN G8hECzsPeyEUO+Pt/v7uwKBJB6p4GYBGUwZvv1N2vwq/znaY7fVbh2Zq5h/3r1OQIQ hSPxKfrP2GqZtxp6XxSouaBmMzx/Nl6QzpAnyAsA= Message-Id: In-Reply-To: References: From: =?utf-8?q?Jan_Kundr=C3=A1t?= Date: Tue, 20 Feb 2018 19:04:47 +0100 Subject: [PATCH 3/4] pinctrl: mcp23s08: debugfs: Do not restore the INTF register MIME-Version: 1.0 To: linux-gpio@vger.kernel.org Cc: Sebastian Reichel , Linus Walleij , Phil Reid Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Apart from the usual stuff, the debugfs code is currently also used for one non-obvious side effect. It attempts to check whether the chip's registers are still set to an expected value, and if not, re-initializes them. It seems that the driver has "always" done so. The code, however, also checks the INTF register which normally indicates which pins have caused the recent interrupt. That's a volatile register, and the datasheet says that writes are ignored in there. When I'm just cat-ing /sys/kernel/debug/gpio with no SPI traffic and no nosie on the GPIO lines, I'm not getting any warnings. Once I actually use these GPIOs and cat that file in parallel, I always seem to get a: mcp23s08 spi1.1: restoring reg 0x07 from 0x0000 to 0xffff (power-loss?) This might be a sign that I should not leave my unused inputs floating, but the code should not be checking a volatile register, anyway. Let's simply skip this last item in the iteration. I was also considering removing this enitre re-initialization because it's non-obvious, but the code survived various refactorings already and has sign-offs by people who know more than I do, so let's leave it as-is. For now :). Signed-off-by: Jan Kundrát Reviewed-by: Phil Reid --- drivers/pinctrl/pinctrl-mcp23s08.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c index fd9d27e8126e..bbef9833edb8 100644 --- a/drivers/pinctrl/pinctrl-mcp23s08.c +++ b/drivers/pinctrl/pinctrl-mcp23s08.c @@ -664,7 +664,7 @@ static int mcp23s08_irq_setup(struct mcp23s08 *mcp) * can be used to fix state for MCP23xxx, that temporary * lost its power supply. */ -#define MCP23S08_CONFIG_REGS 8 +#define MCP23S08_CONFIG_REGS 7 static int __check_mcp23s08_reg_cache(struct mcp23s08 *mcp) { int cached[MCP23S08_CONFIG_REGS]; From patchwork Mon Jun 4 17:05:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Kundr=C3=A1t?= X-Patchwork-Id: 925166 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=cesnet.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=cesnet.cz header.i=@cesnet.cz header.b="QQEe6OSp"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4102VC2LrJz9s0W for ; Tue, 5 Jun 2018 03:48:35 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751213AbeFDRsd (ORCPT ); Mon, 4 Jun 2018 13:48:33 -0400 Received: from office2.cesnet.cz ([195.113.144.244]:48648 "EHLO office2.cesnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750987AbeFDRsc (ORCPT ); Mon, 4 Jun 2018 13:48:32 -0400 X-Greylist: delayed 490 seconds by postgrey-1.27 at vger.kernel.org; Mon, 04 Jun 2018 13:48:32 EDT Received: from localhost (unknown [IPv6:2001:718:1:2c:a4a8:fc6b:670f:47e3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by office2.cesnet.cz (Postfix) with ESMTPSA id CC4AF40007B; Mon, 4 Jun 2018 19:40:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesnet.cz; s=office2; t=1528134038; bh=sYpDTFFcwaAjmYh3pXtaRQagUEpPSfRfH1w1FD2iw54=; h=Resent-Date:Resent-From:Resent-To:Resent-Cc:In-Reply-To: References:From:Date:Subject:To:Cc; b=QQEe6OSpoJcxPoD5JurI1HrSN3oMxYCxMnyVJd+H41FpYEmiNzBRoWYndQw19GDq2 45LRrDTv57+uJIIlWjOrLnMB9Ckv6313G6/bHrjDTjKcHiZPnFQYUHPV0TJ8Sgr2sH r+iZduvNYhf6Xzn5QGfcqLravQ6wYgBljE/aqKII= Message-Id: <2777f8fbccbe8bacbb1003b3206e665eaf8deda0.1528133622.git.jan.kundrat@cesnet.cz> In-Reply-To: References: From: =?utf-8?q?Jan_Kundr=C3=A1t?= Date: Mon, 4 Jun 2018 19:05:10 +0200 Subject: [PATCH 4/4] pinctrl: mcp23s08: work around GPIO line naming MIME-Version: 1.0 To: linux-gpio@vger.kernel.org Cc: Sebastian Reichel , Linus Walleij , Phil Reid Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This driver is a bit weird because it can hide several gpio_chip instances underneath a single SPI slave. One cannot put the gpio-line-names DT stanza directly to the SPI slave when the spi-present-mask has more than one bit set. I'm making up the `gpio-bank` DT child name as well as its `address` property. We need something to match the DT entries with the SPI address. Signed-off-by: Jan Kundrát Reviewed-by: Phil Reid --- .../bindings/pinctrl/pinctrl-mcp23s08.txt | 35 +++++++++++++++++++ drivers/pinctrl/pinctrl-mcp23s08.c | 12 +++++++ 2 files changed, 47 insertions(+) diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt index a5a8322a31bd..7573df69ccea 100644 --- a/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt @@ -142,3 +142,38 @@ gpio21: gpio@21 { bias-pull-up; }; }; + +Line naming +=========== + +Because several gpio_chip instances are hidden below a single device tree +node, it is necessary to split the names into several child nodes. Ensure +that the configured addresses match those in the microchip,spi-present-mask: + +gpio@0 { + compatible = "microchip,mcp23s17"; + gpio-controller; + #gpio-cells = <2>; + /* this bitmask has bits #0 (0x01) and #2 (0x04) set */ + spi-present-mask = <0x05>; + reg = <0>; + spi-max-frequency = <1000000>; + + gpio-bank@1 { + address = <0>; + gpio-line-names = + "GPA0", + "GPA1", + ... + "GPA7", + "GPB0", + "GPB1", + ... + "GPB7"; + }; + + gpio-bank@2 { + address = <2>; + gpio-line-names = ... + }; +}; diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c index bbef9833edb8..c4fac4e1de71 100644 --- a/drivers/pinctrl/pinctrl-mcp23s08.c +++ b/drivers/pinctrl/pinctrl-mcp23s08.c @@ -16,6 +16,7 @@ #include #include #include +#include "../gpio/gpiolib.h" /* * MCP types supported by driver @@ -1086,6 +1087,7 @@ static int mcp23s08_probe(struct spi_device *spi) int status, type; unsigned ngpio = 0; const struct of_device_id *match; + struct device_node *np; match = of_match_device(of_match_ptr(mcp23s08_spi_of_match), &spi->dev); if (match) @@ -1148,6 +1150,16 @@ static int mcp23s08_probe(struct spi_device *spi) if (pdata->base != -1) pdata->base += data->mcp[addr]->chip.ngpio; ngpio += data->mcp[addr]->chip.ngpio; + + for_each_available_child_of_node(spi->dev.of_node, np) { + u32 chip_addr; + status = of_property_read_u32(np, "address", &chip_addr); + if (status) + continue; + if (chip_addr != addr) + continue; + devprop_gpiochip_set_names(&data->mcp[addr]->chip, of_fwnode_handle(np)); + } } data->ngpio = ngpio;