Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1801108rda; Tue, 24 Oct 2023 03:56:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFSkFcUfszNbXZ81ZSEcjzCxBXke6I2DDJhuK3crSdFh2JHqg6hxmuqLM/WR661f30azTBO X-Received: by 2002:a05:6a21:498e:b0:16b:7f7d:8364 with SMTP id ax14-20020a056a21498e00b0016b7f7d8364mr2364157pzc.58.1698144976893; Tue, 24 Oct 2023 03:56:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698144976; cv=none; d=google.com; s=arc-20160816; b=qJjD/GxpsnmFgOvsYV3ZfEFYGiZJ0phehhiA166EvSQIr4JxZo1Z3DvH344kGUlraN rEwTuuAS0RSDvAjRJGZgiR4piD4vegPu52/4AAhEBLc0Bdms8yefA7UK4QeVCYvUDgMZ pl61Ak72iZIsxoRVXwz34QCkU5ocn/GecuS6RpMre8Rpvgj0FXaY4PQy3CO6udE47B3t SJZOIFuXoZrEWh1VYcOHUTE2KKQSex2xyjyliZ1oCBMpo7VQqx42RWCAS1hgY9y1D4qS 2FFvhxg/Wyy/iI27KRjv6SW4yFXP2sng1/hpj0nx5mzQM9u2wtYC0yuxBBvWc/e13zKP tkAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=KObzz0w1XmtHY2+zxGq9cosofvhXd1w5NLEqBfA0G5g=; fh=IsgPLWCaddo8rRgpH4/XXnsgDVEX+CUHAXaROAHthf0=; b=J7zwHva73nJWYqMf3T+NoCki5BcO9Zb+S6eecdl44g92gxpFMAx1bfVa5jfym52gXD hKDP9RH7KzE9HTIpCeO4ye7osu9ELPN+divpiSlHsNyUajTU23wi4zy/wTAkODytXTB2 NpivOXt5zeeCCkhR07vdSqemZMO7XnnV7MFkznNEaczuJCwbDzVTanxkLUTt3rkf1zLQ TLqvUqtITwNwVydohyD7XLZjrcSPkuUQK3lq9gJ6t+5DPa9mhzElqHRyRzMjfcHMe7pM Vg1qZDyOIrqi2LmhJMPh7TTqP6O4lLBEd4qKmJUcTK2g7r3EPW2tUJFIk5wyOpelghXN e+2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id q8-20020aa78428000000b0068fe0f46f27si8168813pfn.171.2023.10.24.03.56.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 03:56:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 4349C80C6DED; Tue, 24 Oct 2023 03:56:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233000AbjJXKz7 (ORCPT + 99 others); Tue, 24 Oct 2023 06:55:59 -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: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 24 Oct 2023 03:56:13 -0700 (PDT) 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