From patchwork Thu Mar 7 13:31:02 2019 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: 1052925 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="RGASAKsX"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44FXJJ5RT1z9s1B for ; Fri, 8 Mar 2019 00:57:36 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726293AbfCGN5g (ORCPT ); Thu, 7 Mar 2019 08:57:36 -0500 Received: from office2.cesnet.cz ([195.113.144.244]:33914 "EHLO office2.cesnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726180AbfCGN5g (ORCPT ); Thu, 7 Mar 2019 08:57:36 -0500 Received: from localhost (unknown [IPv6:2001:718:1:2c:9077:1a3:d51f:f1d6]) (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 39A89400052; Thu, 7 Mar 2019 14:57:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesnet.cz; s=office2; t=1551967053; bh=WmmZKcx0NllRr9j4ueWCaS5aOujIQIzJfNf794xUZ9o=; h=Resent-Date:Resent-From:Resent-To:Resent-Cc:In-Reply-To: References:From:Date:Subject:To:Cc; b=RGASAKsXPbk4QT4sQoIA9MwLD8MxAjXdpW7KTE1lF5j+F6lNpFY2IgdtxBHOmqWx1 cHSAMscakzDDjVIG7lG0pu2gsdI9iFyvk2BZhXcSpBcLCmsGgFe8Ma9S0lz6ozrwt3 l4aQfzHjsx+lVrChJvROJslJD+viCiu+UbPJzD+Y= Message-Id: <517dcdda21ea0b0df884bc6adcba1dadb78b66b1.1551966077.git.jan.kundrat@cesnet.cz> In-Reply-To: References: From: =?utf-8?q?Jan_Kundr=C3=A1t?= Date: Thu, 7 Mar 2019 14:31:02 +0100 Subject: [PATCH v2 3/4] pinctrl: mcp23s08: work around GPIO line naming MIME-Version: 1.0 To: linux-gpio@vger.kernel.org, Linus Walleij , Phil Reid Cc: Sebastian Reichel , Mika Westerberg 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 Cc: Linus Walleij --- v2: Depend on exported devprop_gpiochip_set_names --- .../bindings/pinctrl/pinctrl-mcp23s08.txt | 35 +++++++++++++++++++ drivers/pinctrl/pinctrl-mcp23s08.c | 11 ++++++ 2 files changed, 46 insertions(+) diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt index 625a22e2f211..a0b1eb9aedad 100644 --- a/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt @@ -144,3 +144,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 fd9d6f026d70..7810f56f8dd1 100644 --- a/drivers/pinctrl/pinctrl-mcp23s08.c +++ b/drivers/pinctrl/pinctrl-mcp23s08.c @@ -1102,6 +1102,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) @@ -1170,6 +1171,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;