From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19FFBC25B48 for ; Tue, 24 Oct 2023 10:55:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229569AbjJXKz6 (ORCPT ); Tue, 24 Oct 2023 06:55:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232851AbjJXKz5 (ORCPT ); Tue, 24 Oct 2023 06:55:57 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 93F06D7A; Tue, 24 Oct 2023 03:55:55 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5D0DE2F4; Tue, 24 Oct 2023 03:56:36 -0700 (PDT) Received: from pluto (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E12D63F64C; Tue, 24 Oct 2023 03:55:53 -0700 (PDT) Date: Tue, 24 Oct 2023 11:55:48 +0100 From: Cristian Marussi To: Linus Walleij Cc: AKASHI Takahiro , Rob Herring , sudeep.holla@arm.com, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, Oleksii_Moisieiev@epam.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Subject: Re: [RFC v2 5/5] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver Message-ID: References: <20231005025843.508689-1-takahiro.akashi@linaro.org> <20231005025843.508689-6-takahiro.akashi@linaro.org> <20231006132346.GA3426353-robh@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org On Tue, Oct 24, 2023 at 11:40:00AM +0200, Linus Walleij wrote: > Hi Takahiro, > Hi, > On Tue, Oct 24, 2023 at 9:12 AM AKASHI Takahiro > wrote: > > > > I think it is better of the pin controller just parse and add any > > > subdevices (GPIO or other) using of_platform_default_populate() > > > (just grep for this function and you will see how many device > > > drivers use that). > > > > IICU, then, we will have to add a "compatible" to pinctrl node > > to make of_platform_default_populate() work as expected. That is: > > > > scmi { > > ... > > protocol@19 { > > compatible = "simple-bus"; // <- added > > Hm right, but you could also use > of_platform_populate(np, NULL, NULL, dev); > > Then the compatible match is of no concern. > > Sorry for my lack of attention to details :/ > > If you want to restrict the population to a few select compatibles > (maybe only "pin-control-gpio") then you can do > that with > > const struct of_device_id of_scmi_protocol_19_match_table[] = { > { .compatible = "pin-control-gpio", }, > {} > }; > of_platform_populate(np, of_scmi_protocol_19_match_table, NULL, dev); > > > Is this what you meant? > > In this case, however, "protocol@19" has a mixture of sub-nodes, > > most are pinconf definitions which are the properties of the pin > > controller, while "scmi_gpio" is a separate device. > > That looks good to me, it makes sense to have the GPIO as a subnode > here and mandate it with a compatible to match. > > > The code will work, but is it sane from DT binding pov? > > Let's let the DT people jump in on that. > > > > Instead just call gpiochip_add_pin_range() directly in Linux > > > after adding the pin controller and gpio_chip. > > > C.f. drivers/pinctrl/pinctrl-sx150x.c for an example of a driver > > > doing this. In this case the SX150X is hot-plugged (on a slow > > > bus) so it needs to figure out all ranges at runtime anyway. > > > > Are you suggesting implementing a custom function for parsing "gpio-ranges" > > and calling it in pin_control_gpio_probe() instead of a generic helper? > > The generic helper will always be attempted but if there are > no ranges in the device tree, it will just continue without adding > any ranges. I suggest putting *no* ranges into the device tree. > > > Or do you want to always map all the pin controller's pins to > > gpio pins as sx150x does? > > I think since the SCMI firmware knows about the available line > and pins etc, it makes sense that the driver comes up with the > applicable ranges on its own (derived from the information froms > the SCMI firmware) and add them, instead of trying to put that > information into the device tree at all. Just omit it, and make your > own ranges, and add them in the Linux driver with > gpiochip_add_pin_range() without involving DT at all when defining > the ranges. > > I'm sorry if I'm unclear sometimes. ...a maybe dumb question from my side, BUT does the SCMI Pinctrl carry enough information as it stands for the driver to derive autonomously and efficently the possible/applicable gpio ranges ? Are they (GPIOs) all the remaining unassociated pins ? If this is the case note that the SCMI Pinctrl lets you query the associations in groups or functions and this is generally now done only lazily on-demand when specific pins/groups/funcs are requested by the parsed DT confs: IOW, in order to derive GPIOs from the set of unassociated ones, you will have to at first add some new full-lookup pinctrl_ops to query upfront all existing associations (avoiding, at will, the lazy querying adopted now) and then singling-out the non-associated ones from the lists of all possible group/funcs associations. Moreover, should we allow anyway the optional possibility to forcibly restrict the available gpios from the DT, or we can just assume that those un-available (map out as above) wont just be exposed by the SCMI server ? ..again sorry if I am missing something crucial here and just talking non-sense but I have limited familiarity with Pinctrl/GPIOs usage. Thanks Cristian From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E38E5C25B6C for ; Tue, 24 Oct 2023 10:56:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4Ja/XG5viJA5feI9XDNp7YdonI6mxJ32EvYUm5hJ2n8=; b=5EikQ0oGMB3DBY /RWK02n4OLTdU8G7SwuewumoBe5xo4HnYHUVImCxfzksjGdHSJ6fl9YapTCbIcbNpbhmcRxvalQHh 7Z2roau28nCvIYCswot3ft3wbeXIJg1W0RBbqE5dwjsFeAmGXz6y0jI3byNtnzHL24O/04K9YKjxP wZ8mLKggJzYP7+NrorxkFwel01R4MWf0NWjeHJIrYV+ximDBWbAbl8keeAucHJt18/stajuHtxMCP +6LsVkfxIVuvU5vDJQQSGB5hVzHSQnuh+5RQ9gaXZHahNGdQhy18mB1kIlhGrO0VxP/64Kxlipp2g 1yceS4OBB5oK0lgDeJXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvF4w-009bC3-0r; Tue, 24 Oct 2023 10:56:06 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvF4s-009bAm-1y for linux-arm-kernel@lists.infradead.org; Tue, 24 Oct 2023 10:56:04 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5D0DE2F4; Tue, 24 Oct 2023 03:56:36 -0700 (PDT) Received: from pluto (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E12D63F64C; Tue, 24 Oct 2023 03:55:53 -0700 (PDT) Date: Tue, 24 Oct 2023 11:55:48 +0100 From: Cristian Marussi To: Linus Walleij Cc: AKASHI Takahiro , Rob Herring , sudeep.holla@arm.com, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, Oleksii_Moisieiev@epam.com, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Subject: Re: [RFC v2 5/5] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver Message-ID: References: <20231005025843.508689-1-takahiro.akashi@linaro.org> <20231005025843.508689-6-takahiro.akashi@linaro.org> <20231006132346.GA3426353-robh@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231024_035602_766753_0C0515F5 X-CRM114-Status: GOOD ( 42.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org T24gVHVlLCBPY3QgMjQsIDIwMjMgYXQgMTE6NDA6MDBBTSArMDIwMCwgTGludXMgV2FsbGVpaiB3 cm90ZToKPiBIaSBUYWthaGlybywKPiAKCkhpLAoKPiBPbiBUdWUsIE9jdCAyNCwgMjAyMyBhdCA5 OjEy4oCvQU0gQUtBU0hJIFRha2FoaXJvCj4gPHRha2FoaXJvLmFrYXNoaUBsaW5hcm8ub3JnPiB3 cm90ZToKPiAKPiA+ID4gSSB0aGluayBpdCBpcyBiZXR0ZXIgb2YgdGhlIHBpbiBjb250cm9sbGVy IGp1c3QgcGFyc2UgYW5kIGFkZCBhbnkKPiA+ID4gc3ViZGV2aWNlcyAoR1BJTyBvciBvdGhlcikg dXNpbmcgb2ZfcGxhdGZvcm1fZGVmYXVsdF9wb3B1bGF0ZSgpCj4gPiA+IChqdXN0IGdyZXAgZm9y IHRoaXMgZnVuY3Rpb24gYW5kIHlvdSB3aWxsIHNlZSBob3cgbWFueSBkZXZpY2UKPiA+ID4gZHJp dmVycyB1c2UgdGhhdCkuCj4gPgo+ID4gSUlDVSwgdGhlbiwgd2Ugd2lsbCBoYX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