From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mika Westerberg Subject: Re: GPIO bindings guidelines (Was: Re: [PATCH v5 10/12] gpio: Support for unified device properties interface) Date: Wed, 22 Oct 2014 11:10:44 +0300 Message-ID: <20141022081044.GB1484@lahna.fi.intel.com> References: <4582579.9WMrIMALsy@wuerfel> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <4582579.9WMrIMALsy@wuerfel> Sender: linux-acpi-owner@vger.kernel.org To: Arnd Bergmann Cc: Alexandre Courbot , "Rafael J. Wysocki" , Linux Kernel Mailing List , Greg Kroah-Hartman , Grant Likely , ACPI Devel Maling List , Aaron Lu , "devicetree@vger.kernel.org" , Linus Walleij , Dmitry Torokhov , Bryan Wu , Darren Hart , Mark Rutland List-Id: devicetree@vger.kernel.org On Tue, Oct 21, 2014 at 09:54:45AM +0200, Arnd Bergmann wrote: > On Tuesday 21 October 2014 14:14:02 Alexandre Courbot wrote: > > > > > > We have enforced naming things for the dmaengine binding, which has > > > just led to everyone calling things "rx" and "tx". My fear is that > > > if we start to enforce giving a name, we'd end up with lots of > > > drivers that use a "gpio-gpios" property or something silly. > > > > Checking the bindings is also part of the review process. Things > > like "gpio-gpios" should simply not be accepted to begin with. > > > > This sounds like a good chance to finally land some guidelines > > regarding GPIO bindings. Let's summarize the situation: > > - GPIO bindings can be defined using both DT and ACPI (both interfaces > > nicely abstracted by the interface introduced by this series) > > - Both firmware interfaces support indexed GPIOs > > - Both firmware interfaces support named GPIO properties, with an > > optional index (can we absolutely take this for granted on ACPI now?) > > The developers working on it have said that they definitely want to > be compatible with the existing bindings, so the answer to your question > is yes. One thing to consider still is that we have plenty of existing ACPI code out there where _DSD is not used but instead we rely on the index. An example would be rfkill-gpio.c driver: gpio = devm_gpiod_get_index(&pdev->dev, "reset", 0); if (!IS_ERR(gpio)) { ... } gpio = devm_gpiod_get_index(&pdev->dev, "shutdown", 1); if (!IS_ERR(gpio)) { ... } It expects that GPIOs returned from _CRS are in specific order. Since we can't change these existing ACPI tables, we must support them somehow. This patch series handles it so that: 1) If we can't find given property (e.g "reset-gpios" or "shutdown-gpios") the index above will refer directly to the GPIO resource returned from _CRS. 2) If the property is found we ignore index and take it from the property instead. This has the drawback that we cannot support this: Package () { "reset-gpios", Package () { ^GPIO, 0, 0, 0, ^GPIO, 1, 0, 0}} ^^^^^^^^^^^^^^ So the second entry in the above is not accessible using gpiod_get_index() and the reason is that we want to support the existing and new ACPI tables where _DSD is not being used.