Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1707507rda; Tue, 24 Oct 2023 00:12:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzOxRXgsmIRyJgO/SVR1w4SY+C604vFirJ95XK2jMtnHzx/mJJNg2PplKycJlDinefhHKE X-Received: by 2002:aa7:96e4:0:b0:6b2:2a2d:7a25 with SMTP id i4-20020aa796e4000000b006b22a2d7a25mr8488652pfq.29.1698131566548; Tue, 24 Oct 2023 00:12:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698131566; cv=none; d=google.com; s=arc-20160816; b=UsbVCw+jjg+tON87h14n88MJ4Yckmrc+bwW3XC47lhGKkqBj990gCU7Jp2+2FOhcal jUcJIIgO21iBs9WD2sEM9ni0SdQkTaK8EHdlhOvU0RELTCpr08PBwcA5acwLqAlj4Ty5 6qAZSvof0TsxiSByLFDHRUwODd9VTlwq7qTqs1H2gEzS15S3RijKXe+Zq2hsYswV2zV+ CNyHXe25uAe0FDnN7WhYWokAbGhap8gt1NDIw2ao6YFZGoZ/3osc7njWF/yZfW9N5CF+ hY8ecql6DS8mXXQFDHDKPPREvQjadSrFIox+H3/ybaay9HPQimwYiUPgqYiLiXDMCrni 3o5A== 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-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=amFp0BVeavttuQpXCOb46m8XpZ/bsIpXzEjd5+Ix8vo=; fh=VYHYLZF2XbPvGme9Y3zkdWTYuAo7LCRg6JosWpUQi08=; b=RfFbRjRtZtlAJCzaIaEQcyv92JgXya3pvR9bOU9uY4Aek4El8J/BPLi0aWqkPqSAWZ qlsaFLGk/Pn3388IgIU6QaH74NwMD0ls61TEAEMW7N7U3T56sSrCdmn27D7MSc0bFBGJ 640mbnwPYDWnK5Ql/pMtL1jIXXS7634XsfKiG4IeN5ay3c4f+FWckl4z2mAmEg4z1x+Y kBJs6uqhOtKCTuCJe2+6xamLllwjS0qnbXqzRdcZmPvOZB2jZtpX+ma4keU/IFDwef1M GVtu8rK0/i/J26Rtxsr7IlmRJDFyM1n9y4DIOAMux3SRywv2O3Fv5tXD4q0doae0WOdU dG3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="a/83O0rd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id u11-20020a6540cb000000b005b891b74b31si5702767pgp.625.2023.10.24.00.12.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 00:12:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="a/83O0rd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 200978095DFA; Tue, 24 Oct 2023 00:12:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232576AbjJXHMh (ORCPT + 99 others); Tue, 24 Oct 2023 03:12:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232499AbjJXHMg (ORCPT ); Tue, 24 Oct 2023 03:12:36 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FA52110 for ; Tue, 24 Oct 2023 00:12:33 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6ba8eb7e581so1113035b3a.0 for ; Tue, 24 Oct 2023 00:12:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698131552; x=1698736352; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=amFp0BVeavttuQpXCOb46m8XpZ/bsIpXzEjd5+Ix8vo=; b=a/83O0rdBkdMDQZyDt02QYcuE0lIIprKzdgEyUXSML5pdYXctr31KnCsKCICL4S57g QhJ41BrV7b1nyxLPGWAg3srra3OV+13KA6pDUray43GHjicqllO51aC2vnJbULxfhGPE Q8d1kiHEwKdCAB9URmvkGexBBeZ2jDuV6DepO8nXpEePkeQDEvZiaIcPncUFCCQFVT5w yju/nX5zjb/WSqKFy4fhd4xXmNChTe0WL5cI7Kf5GdFUZ5DNFcmB6cAUmsFE9v4G8q5e tDtezRD7tAfGyRLAJJA+2Wy1y0Gl9h8aLti4iGkCCJR6caXSh1lzju4K9W3gU+YqsTwp XV+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698131552; x=1698736352; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=amFp0BVeavttuQpXCOb46m8XpZ/bsIpXzEjd5+Ix8vo=; b=eIuwtIS2Zvz3skqA8bfjfWzsM6FytG2Pl3ADMnCZp6vIZrvcs0/V6bf91klUis61Is Ctwc94EFhKivqlz+gkrRCbNvBOLQ0EjXaecrQx5/ymYx5m7jrPhdOKY/hGuHWD9N1Sf/ iPAF8Qaru9u2tg/SCDEFlaPmS9rkOFnvySGnOx1OnEDYVb3nfqMjAcW/UpsuWYsQkq3V enOzYF8xM1bnntY8bmd80I3z8Sj1LWwpZ4uM2Uj0TSmUdNbO+hk69lFKFcvGMoVK/71V YsDD0r04qjLQ4kV7Fy118jnHfbsp+nCRsM1LuL8Pgtq0Lgt8QowMSkCKxQ31i4OTfFLJ /vWg== X-Gm-Message-State: AOJu0Yx+Gj6sBRaptQ6n3Mcr5UW+4kxeT3ndLMVVOzVVGERepcqD3b13 q0z4Um9sz1NkdTP1k1D7sAZcQg== X-Received: by 2002:a05:6a20:2451:b0:171:737:df97 with SMTP id t17-20020a056a20245100b001710737df97mr14371285pzc.2.1698131552304; Tue, 24 Oct 2023 00:12:32 -0700 (PDT) Received: from octopus ([2400:4050:c3e1:100:7c15:610f:1205:f10c]) by smtp.gmail.com with ESMTPSA id ch20-20020a17090af41400b0026b3f76a063sm6535391pjb.44.2023.10.24.00.12.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 00:12:31 -0700 (PDT) Date: Tue, 24 Oct 2023 16:12:27 +0900 From: AKASHI Takahiro To: Linus Walleij Cc: Rob Herring , sudeep.holla@arm.com, cristian.marussi@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: Mail-Followup-To: AKASHI Takahiro , Linus Walleij , Rob Herring , sudeep.holla@arm.com, cristian.marussi@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 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=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 morse.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 (morse.vger.email [0.0.0.0]); Tue, 24 Oct 2023 00:12:44 -0700 (PDT) Hi Linus, On Mon, Oct 23, 2023 at 10:12:21AM +0200, Linus Walleij wrote: > Hi Takashi, > > sorry for slow response :( Thank you for your feedback. > On Tue, Oct 17, 2023 at 4:32???AM AKASHI Takahiro > wrote: > > > > > > We can probably mandate that this has to be inside a pin controller > > > > > since it is a first. > > > > > > > > Yeah, my U-Boot implementation tentatively supports both (inside and > > > > outside pin controller). But it is not a user's choice, but we should > > > > decide which way to go. > > > > > > OK I have decided we are going to put it inside the pin control node, > > > as a subnode. (I don't expect anyone to object.) > > > > While I'm still thinking of how I can modify my current implementation > > to fit into 'inside' syntax, there are a couple of concerns: > > > > 1) invoke gpiochip_add_data() at probe function > > Probably we no longer need "compatible" property, > > The DT binding people made it clear to me that they really > like compatibles for this kind of stuff so we should probably > keep it. Okay, I will assume this in the following discussion. > > but instead we need to > > call gpiochip_add_data() explicitly in SCMI pin controller's probe > > as follows: > > > > scmi_pinctrl_probe() > > ... > > devm_pinctrl_register_and_init(dev, ..., pctrldev); > > pinctrl_enable(pctrldev); > > > > device_for_each_child_node(dev, fwnode) > > if (fwnode contains "gpio-controller") { > > /* what pin_control_gpio_probe() does */ > > gc->get_direction = ...; > > ... > > devm_gpiochip_data_add(dev, gc, ...); > > } > > 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 reg = <0x19>; ... // a couple of pinconf nodes scmi_gpio { compatible = "pin-control-gpio"; ... } } } 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. The code will work, but is it sane from DT binding pov? > What is good with this approach is that if you place this call > last in the probe() we know the GPIO driver has all resources > it needs when it probes so it won't defer. > > > 2) gpio-by-pinctrl.c > > While this file is SCMI-independent now, due to a change at (1), > > it would be better to move the whole content inside SCMI pin controller > > driver (because there is no other user for now). > > That works, too. I have no strong opinion on this subject. I assumed that "compatible" had been removed here. If we retain "compatible" property, I don't care either way. > > 3) Then, pin-control-gpio.yaml may also be put into SCMI binding > > (i.e. firmware/arm,scmi.yaml). Can we leave the gpio binding outside? > > There is no clear pattern whether to put subdevice bindings into > the parent device binding or not. Maybe? A lot of MFD devices does > this for sure. The same as above. > > 4) phandle in "gpio-ranges" property > > (As you mentioned) > > The first element in a tuple of "gpio-ranges" is a phandle to a pin > > controller node. Now that the gpio node is a sub node of pin controller, > > the phandle is trivial. But there is no easier way to represent it > > than using an explicit label: > > (My U-Boot implementation does this.) > > > > scmi { > > ... > > scmi_pinctrl: protocol@19 { > > ... > > gpio { > > gpio-controller; > > ... > > gpio-ranges = <&scmi_pinctrl ... >; > > } > > } > > } > > > > I tried: > > gpio-ranges = <0 ...>; // dtc passed, but '0' might be illegal by spec. > > gpio-ranges = <(-1) ...>; // dtc passed, but ... > > gpio-ranges = <&{..} ...>; // dtc error because it's not a full path. > > > > Do you have any other idea? Otherwise, I will modify my RFC > > with the changes above. > > If you have the GPIO node inside the pin controller node > and have all the details of the existing ranges available, there > is no need to put that into the device tree at all, just omit it? Then, of_gpiochip_add_data() (hence, of_gpiochip_add()/gpiochip_add_data()) won't work because it always assume phandle + 3 arguments. Right? In this case, "gpio-ranges" here may have different semantics from the other pinctrl-based gpio drivers. Doesn't matter from DT pov? > 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? Or do you want to always map all the pin controller's pins to gpio pins as sx150x does? -Takahiro Akashi > Yours, > Linus Walleij