[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VdBJEbm0=eNZMdc2ZWMh4qwP2S7jRECWWWvh2EfA-NykA@mail.gmail.com>
Date: Fri, 2 Oct 2020 16:23:32 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Flavio Suligoi <f.suligoi@...m.it>
Cc: Bartosz Golaszewski <brgl@...ev.pl>,
"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
"linux-acpi@...r.kernel.org" <linux-acpi@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: How to use an ACPI declared GPIO in a userspace ...
On Fri, Oct 2, 2020 at 3:48 PM Andy Shevchenko
<andy.shevchenko@...il.com> wrote:
>
> On Fri, Oct 2, 2020 at 1:02 PM Flavio Suligoi <f.suligoi@...m.it> wrote:
>
> > > > > My SSDT table is:
> > > >
> > > > ^^^^ See the difference? I can't help here.
> >
> > This is the DSDT table related to the GPIO controller of my board:
> >
> > Device (GPO1)
> > {
> > Name (_ADR, Zero) // _ADR: Address
> > Name (_HID, "INT3452") // _HID: Hardware ID
> > Name (_CID, "INT3452") // _CID: Compatible ID
> > Name (_DDN, "General Purpose Input/Output (GPIO) Controller - Northwest") // _DDN: DOS Device Name
> > Name (_UID, 0x02) // _UID: Unique ID
> > Name (RBUF, ResourceTemplate ()
> > {
> > Memory32Fixed (ReadWrite,
> > 0x00000000, // Address Base
> > 0x00004000, // Address Length
> > _Y08)
> > Interrupt (ResourceConsumer, Level, ActiveLow, Shared, ,, )
> > {
> > 0x0000000E,
> > }
> > })
> > Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings
> > {
> > CreateDWordField (RBUF, \_SB.GPO1._Y08._BAS, B0BA) // _BAS: Base Address
> > CreateDWordField (RBUF, \_SB.GPO1._Y08._LEN, B0LN) // _LEN: Length
> > B0BA = GP1A /* \GP1A */
> > B0LN = GP1L /* \GP1L */
> > Return (RBUF) /* \_SB_.GPO1.RBUF */
> > }
> >
> > Method (_STA, 0, NotSerialized) // _STA: Status
> > {
> > If ((OSYS < 0x07DC))
> > {
> > Return (Zero)
> > }
> >
> > Return (0x0F)
> > }
> > }
>
> So, what about adding the following
>
> DefinitionBlock ("linename.aml", "SSDT", 5, "", "LINENAME", 1)
> {
> External (_SB_.GPO1, DeviceObj)
> Scope (\_SB.GPO1)
> {
> Name (_DSD, Package () {
> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> Package () {
> Package () {
> "gpio-line-names",
> Package () {
> "Line0",
> "Line1",
> "Line2",
> ...
> }
> },
> }
> })
> }
> }
>
> ?
>
> (Replace '...' with meaningful line names or drop for now, but in any
> case you need to provide as much names as lines of such GPIO
> controller)
I have checked the code, so it allows you to define from 0 up to all
lines, but no gaps.
Thus, I have dropped '...' line in above excerpt, added the compiled
AML to initramfs (initrd method) and voila!
% gpioinfo gpiochip1
gpiochip1 - 77 lines:
line 0: "Line0" unused input active-high
line 1: "Line1" unused input active-high
line 2: "Line2" unused input active-high
line 3: unnamed unused input active-high
% gpiofind Line2
gpiochip1 2
Of course you may convert _DSD to be a Method and fill the line names
dynamically with help of ASL.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists