tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: ACPI GPIO



On Sat, Dec 11, 2021 at 06:37:32AM +0000, Emmanuel Dreyfus wrote:
> Current code in src/sys/dev/acpi does not know about ACPI GPIO resouces.
> I modified it a bit, and now acpi_resource_parse  _CRS reports two 
> GPIO. Now I need to use them. ACPI documentation talks about
> GpioInt and GpioIo macros. There are references about them in 
> src/sys/external/bsd/acpica/dist but i did not understand how I
> was suposed to use them, or even where they are defined.

I now understand that macros are just used to produce ACPI tables
that describes the device. 

And indeed the ACPI tables contain TPL1 and TPL2 devices that seems
to match the Goodix touchscreen. The kernel dmesg says
TPL1 (GXTP7386) at acpi0 not configured

Decompiled DSDT has for TPL1:
                    GpioInt (Level, ActiveLow, Shared, PullDefault, 0x0000,
                        "\\_SB.PCI0.GPI0", 0x00, ResourceConsumer, ,
                        )
                        {   // Pin list
                            0x0012
                        }

That means the GPIO is hooked to pci bus as device GPI0, right? dmesg says:
GPI0 (INT344B) at acpi0 not configured

The kernel attached no gpio device, that means I need to write a driver
for that? DSDT tells some stuff about it, but I do not know how it should
be used. Do we have code for another similar device to get some insights?

        Device (GPI0)
        {
            Method (_HID, 0, NotSerialized)  // _HID: Hardware ID
            {
                If ((PCHV () == SPTH))
                {
                    If ((PCHG == 0x02))
                    {
                        Return ("INT3451")
                    }

                    Return ("INT345D")
                }

                Return ("INT344B")
            }

            Name (LINK, "\\_SB.PCI0.GPI0")
            Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
            {
                Name (RBUF, ResourceTemplate ()
                {
                    Memory32Fixed (ReadWrite,
                        0x00000000,         // Address Base
                        0x00010000,         // Address Length
                        _Y2B)
                    Memory32Fixed (ReadWrite,
                        0x00000000,         // Address Base
                        0x00010000,         // Address Length
                        _Y2C)
                    Memory32Fixed (ReadWrite,
                        0x00000000,         // Address Base
                        0x00010000,         // Address Length
                        _Y2E)
                    Interrupt (ResourceConsumer, Level, ActiveLow, Shared, ,, _Y2D)
                    {
                        0x0000000E,
                    }
                })
                CreateDWordField (RBUF, \_SB.PCI0.GPI0._CRS._Y2B._BAS, COM0)  // _BAS: Base Address
                CreateDWordField (RBUF, \_SB.PCI0.GPI0._CRS._Y2C._BAS, COM1)  // _BAS: Base Address
                CreateDWordField (RBUF, \_SB.PCI0.GPI0._CRS._Y2D._INT, IRQN)  // _INT: Interrupts
                COM0 = (SBRG + 0x00AF0000)
                COM1 = (SBRG + 0x00AE0000)
                CreateDWordField (RBUF, \_SB.PCI0.GPI0._CRS._Y2E._BAS, COM3)  // _BAS: Base Address
                COM3 = (SBRG + 0x00AC0000)
                IRQN = SGIR /* \SGIR */
                Return (RBUF) /* \_SB_.PCI0.GPI0._CRS.RBUF */
            }

            Method (_STA, 0, NotSerialized)  // _STA: Status
            {
                If ((SBRG == Zero))
                {
                    Return (Zero)
                }

                If ((GPEN == Zero))
                {
                    Return (Zero)
                }

                Return (0x0F)
            }
        }


-- 
Emmanuel Dreyfus
manu%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index