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 X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75F7DC49ED9 for ; Thu, 12 Sep 2019 10:07:01 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 43B7620830 for ; Thu, 12 Sep 2019 10:07:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="LIvf0Von" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 43B7620830 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject: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=DzjN29NEiSUzYmf28SWAbByTm5G2iZqx7Z+uCQKCbxM=; b=LIvf0Von42oKh8 hQ8hAWhyinJy/gcRvKezXCcwA9MuYuUJmDxlYSh+YxeIcu0MrjBzbsbUepVU++VhK0mFd4E5XCNeQ cIn5QheSMArJn0AWrqAxiOGFRreiHfatgXqCpdRy2bMUk7MEWRb5+lBOBUSpXQh7PYOjI8TwwPfZO RylfyrYWoTHMszqvamqc6K2k6PaOvd+pkP6aH8wdVwoBz8paeJRRJ47Pe0NVXHbrGm8k2EjcixJpk 600immVTkp8l6eFqDnUDCWbWhikwCyLhMHgc4FDnjJHNN22WYHYkaOBQ7g3VNkaGTR4A7SQ2HbaNg q3Dtk0nXnMsBRfGjoJfg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1i8M0C-0003kA-Uc; Thu, 12 Sep 2019 10:07:00 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1i8M0A-0003jf-8a for linux-arm-kernel@lists.infradead.org; Thu, 12 Sep 2019 10:06:59 +0000 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1i8M08-0000kf-G0; Thu, 12 Sep 2019 12:06:56 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1i8M07-00077t-7R; Thu, 12 Sep 2019 12:06:55 +0200 Date: Thu, 12 Sep 2019 12:06:55 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Linus Walleij Subject: Re: [PATCH RFC] gpio: define gpio-init nodes to initialize pins similar to hogs Message-ID: <20190912100655.jucqrh2jaf6vgwm2@pengutronix.de> References: <20190909105919.30418-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190912_030658_303345_97340E4B X-CRM114-Status: GOOD ( 22.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Pawel Moll , "open list:GPIO SUBSYSTEM" , Ian Campbell , Bartosz Golaszewski , Rob Herring , Sascha Hauer , Kumar Gala , Linux ARM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Sep 12, 2019 at 10:05:23AM +0100, Linus Walleij wrote: > On Mon, Sep 9, 2019 at 11:59 AM Uwe Kleine-K=F6nig > wrote: > = > > Sometimes it is handy to be able to easily define a "safe" state for a > > GPIO. This might for example be used to ensure that an ethernet phy is > > properly reset during startup or just that all pins have a defined state > > to minimize leakage current. As such a pin must be requestable (and > > changable) by a device driver, a gpio-hog cannot be used. > > > > So define a GPIO initializer with a syntax identical to a GPIO hog just > > using "gpio-init" as identifier instead of "gpio-hog". > > > > The usage I have in mind (and also implemented in a custom patch stack > > on top of barebox already) is targeting the bootloader and not > > necessarily Linux as such an boot-up initialisation should be done as > > early as possible. > > > > Not-yet-signed-off-by: Uwe Kleine-K=F6nig > > --- > > Hello, > > > > maybe it also makes sense to use "gpio-safe"? Maybe it (then) makes > > sense to reset the gpio in the indicated state after it is released? > > > > Also it might be beneficial to make the wording more explicit in the > > description and for example tell that only one of gpio-hog and gpio-init > > must be provided. > = > It's no secret that I am in favor of this approach, as I like consistency > with the hogs. > = > The DT people have been against, as they prefer something like an > initial array of values akin to gpio-names IIRC. But this is a good > time for them to speak up. To be fair, I added them to Cc:. For the new readers: The diff I suggested looks as follows (probably whitespace broken as I cut-n-pasted): > diff --git a/Documentation/devicetree/bindings/gpio/gpio.txt b/Documentat= ion/devicetree/bindings/gpio/gpio.txt > index a8895d339bfe..5b7883f5520f 100644 > --- a/Documentation/devicetree/bindings/gpio/gpio.txt > +++ b/Documentation/devicetree/bindings/gpio/gpio.txt > @@ -182,13 +182,16 @@ gpio-controller@00000000 { > "poweroff", "reset"; > } > = > -The GPIO chip may contain GPIO hog definitions. GPIO hogging is a mechan= ism > -providing automatic GPIO request and configuration as part of the > -gpio-controller's driver probe function. > +The GPIO chip may contain GPIO hog and init definitions. GPIO hogging is= a > +mechanism providing automatic GPIO request and configuration as part of = the > +gpio-controller's driver probe function. An GPIO initializer is similar = but > +doesn't prevent later requesting and reconfiguration. > = > Each GPIO hog definition is represented as a child node of the GPIO cont= roller. > Required properties: > - gpio-hog: A property specifying that this child node represents a GP= IO hog. > +- gpio-init: A property specifying that this child node represents a GP= IO > + initializer. > - gpios: Store the GPIO information (id, flags, ...) for each GPIO = to > affect. Shall contain an integer multiple of the number of= cells > specified in its parent node (GPIO controller node). How would this alternate approach look like? Something like: gpio-controler@123450 { compatible =3D ".."; gpio-controller; #gpio-cells =3D <2>; init =3D "", "output-high", "", "input", "", "", "output-low"; }; ? Compared to the solution I suggested (and hogs) this differs as you cannot pass flags like GPIO_ACTIVE_LOW. (Sidenode: As mygpio { gpio-hog; gpios =3D <5 GPIO_ACTIVE_LOW>; output-low; }; makes AFAIK the output high it would be less surprising if the binding supported "output-active" and "output-inactive".) Best regards Uwe -- = Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | http://www.pengutronix.de/ | _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel