• Benjamin Tissoires's avatar
    gpiolib-acpi: make sure we trigger edge events at least once on boot · ca876c74
    Benjamin Tissoires authored
    On some systems using edge triggered ACPI Event Interrupts, the initial
    state at boot is not setup by the firmware, instead relying on the edge
    irq event handler running at least once to setup the initial state.
    
    2 known examples of this are:
    
    1) The Surface 3 has its _LID state controlled by an ACPI operation region
     triggered by a GPIO event:
    
     OperationRegion (GPOR, GeneralPurposeIo, Zero, One)
     Field (GPOR, ByteAcc, NoLock, Preserve)
     {
         Connection (
             GpioIo (Shared, PullNone, 0x0000, 0x0000, IoRestrictionNone,
                 "\\_SB.GPO0", 0x00, ResourceConsumer, ,
                 )
                 {   // Pin list
                     0x004C
                 }
         ),
         HELD,   1
     }
    
     Method (_E4C, 0, Serialized)  // _Exx: Edge-Triggered GPE
     {
         If ((HELD == One))
         {
             ^^LID.LIDB = One
         }
         Else
         {
             ^^LID.LIDB = Zero
             Notify (LID, 0x80) // Status Change
         }
    
         Notify (^^PCI0.SPI1.NTRG, One) // Device Check
     }
    
     Currently, the state of LIDB is wrong until the user actually closes or
     open the cover. We need to trigger the GPIO event once to update the
     internal ACPI state.
    
     Coincidentally, this also enables the Surface 2 integrated HID sensor hub
     which also requires an ACPI gpio operation region to start initialization.
    
    2) Various Bay Trail based tablets come with an external USB mux and
     TI T1210B USB phy to enable USB gadget mode. The mux is controlled by a
     GPIO which is controlled by an edge triggered ACPI Event Interrupt which
     monitors the micro-USB ID pin.
    
     When the tablet is connected to a PC (or no cable is plugged in), the ID
     pin is high and the tablet should be in gadget mode. But the GPIO
     controlling the mux is initialized by the firmware so that the USB data
     lines are muxed to the host controller.
    
     This means that if the user wants to use gadget mode, the user needs to
     first plug in a host-cable to force the ID pin low and then unplug it
     and connect the tablet to a PC, to get the ACPI event handler to run and
     switch the mux to device mode,
    
    This commit fixes both by running the event-handler once on boot.
    
    Note that the running of the event-handler is done from a late_initcall,
    this is done because the handler AML code may rely on OperationRegions
    registered by other builtin drivers. This avoids errors like these:
    
    [    0.133026] ACPI Error: No handler for Region [XSCG] ((____ptrval____)) [GenericSerialBus] (20180531/evregion-132)
    [    0.133036] ACPI Error: Region GenericSerialBus (ID=9) has no handler (20180531/exfldio-265)
    [    0.133046] ACPI Error: Method parse/execution failed \_SB.GPO2._E12, AE_NOT_EXIST (20180531/psparse-516)
    Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
    [hdegoede: Document BYT USB mux reliance on initial trigger]
    [hdegoede: Run event handler from a late_initcall, rather then immediately]
    Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
    Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
    Acked-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
    Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
    ca876c74
Name
Last commit
Last update
..
Kconfig Loading commit data...
Makefile Loading commit data...
devres.c Loading commit data...
gpio-104-dio-48e.c Loading commit data...
gpio-104-idi-48.c Loading commit data...
gpio-104-idio-16.c Loading commit data...
gpio-74x164.c Loading commit data...
gpio-74xx-mmio.c Loading commit data...
gpio-adnp.c Loading commit data...
gpio-adp5520.c Loading commit data...
gpio-adp5588.c Loading commit data...
gpio-altera-a10sr.c Loading commit data...
gpio-altera.c Loading commit data...
gpio-amd8111.c Loading commit data...
gpio-amdpt.c Loading commit data...
gpio-arizona.c Loading commit data...
gpio-aspeed.c Loading commit data...
gpio-ath79.c Loading commit data...
gpio-bcm-kona.c Loading commit data...
gpio-bd9571mwv.c Loading commit data...
gpio-brcmstb.c Loading commit data...
gpio-bt8xx.c Loading commit data...
gpio-clps711x.c Loading commit data...
gpio-crystalcove.c Loading commit data...
gpio-cs5535.c Loading commit data...
gpio-da9052.c Loading commit data...
gpio-da9055.c Loading commit data...
gpio-davinci.c Loading commit data...
gpio-dln2.c Loading commit data...
gpio-dwapb.c Loading commit data...
gpio-eic-sprd.c Loading commit data...
gpio-em.c Loading commit data...
gpio-ep93xx.c Loading commit data...
gpio-exar.c Loading commit data...
gpio-f7188x.c Loading commit data...
gpio-ftgpio010.c Loading commit data...
gpio-ge.c Loading commit data...
gpio-gpio-mm.c Loading commit data...
gpio-grgpio.c Loading commit data...
gpio-hlwd.c Loading commit data...
gpio-htc-egpio.c Loading commit data...
gpio-ich.c Loading commit data...
gpio-ingenic.c Loading commit data...
gpio-intel-mid.c Loading commit data...
gpio-iop.c Loading commit data...
gpio-it87.c Loading commit data...
gpio-janz-ttl.c Loading commit data...
gpio-kempld.c Loading commit data...
gpio-ks8695.c Loading commit data...
gpio-loongson.c Loading commit data...
gpio-loongson1.c Loading commit data...
gpio-lp3943.c Loading commit data...
gpio-lp873x.c Loading commit data...
gpio-lp87565.c Loading commit data...
gpio-lpc18xx.c Loading commit data...
gpio-lpc32xx.c Loading commit data...
gpio-lynxpoint.c Loading commit data...
gpio-max3191x.c Loading commit data...
gpio-max7300.c Loading commit data...
gpio-max7301.c Loading commit data...
gpio-max730x.c Loading commit data...
gpio-max732x.c Loading commit data...
gpio-max77620.c Loading commit data...
gpio-mb86s7x.c Loading commit data...
gpio-mc33880.c Loading commit data...
gpio-mc9s08dz60.c Loading commit data...
gpio-menz127.c Loading commit data...
gpio-merrifield.c Loading commit data...
gpio-ml-ioh.c Loading commit data...
gpio-mm-lantiq.c Loading commit data...
gpio-mmio.c Loading commit data...
gpio-mockup.c Loading commit data...
gpio-mpc5200.c Loading commit data...
gpio-mpc8xxx.c Loading commit data...
gpio-msic.c Loading commit data...
gpio-mvebu.c Loading commit data...
gpio-mxc.c Loading commit data...
gpio-mxs.c Loading commit data...
gpio-octeon.c Loading commit data...
gpio-omap.c Loading commit data...
gpio-palmas.c Loading commit data...
gpio-pca953x.c Loading commit data...
gpio-pcf857x.c Loading commit data...
gpio-pch.c Loading commit data...
gpio-pci-idio-16.c Loading commit data...
gpio-pcie-idio-24.c Loading commit data...
gpio-pisosr.c Loading commit data...
gpio-pl061.c Loading commit data...
gpio-pmic-eic-sprd.c Loading commit data...
gpio-pxa.c Loading commit data...
gpio-raspberrypi-exp.c Loading commit data...
gpio-rc5t583.c Loading commit data...
gpio-rcar.c Loading commit data...
gpio-rdc321x.c Loading commit data...
gpio-reg.c Loading commit data...
gpio-sa1100.c Loading commit data...
gpio-sch.c Loading commit data...
gpio-sch311x.c Loading commit data...
gpio-sodaville.c Loading commit data...
gpio-spear-spics.c Loading commit data...
gpio-sprd.c Loading commit data...
gpio-sta2x11.c Loading commit data...
gpio-stmpe.c Loading commit data...
gpio-stp-xway.c Loading commit data...
gpio-syscon.c Loading commit data...
gpio-tb10x.c Loading commit data...
gpio-tc3589x.c Loading commit data...
gpio-tegra.c Loading commit data...
gpio-tegra186.c Loading commit data...
gpio-thunderx.c Loading commit data...
gpio-timberdale.c Loading commit data...
gpio-tpic2810.c Loading commit data...
gpio-tps65086.c Loading commit data...
gpio-tps65218.c Loading commit data...
gpio-tps6586x.c Loading commit data...
gpio-tps65910.c Loading commit data...
gpio-tps65912.c Loading commit data...
gpio-tps68470.c Loading commit data...
gpio-ts4800.c Loading commit data...
gpio-ts4900.c Loading commit data...
gpio-ts5500.c Loading commit data...
gpio-twl4030.c Loading commit data...
gpio-twl6040.c Loading commit data...
gpio-ucb1400.c Loading commit data...
gpio-uniphier.c Loading commit data...
gpio-vf610.c Loading commit data...
gpio-viperboard.c Loading commit data...
gpio-vr41xx.c Loading commit data...
gpio-vx855.c Loading commit data...
gpio-wcove.c Loading commit data...
gpio-winbond.c Loading commit data...
gpio-wm831x.c Loading commit data...
gpio-wm8350.c Loading commit data...
gpio-wm8994.c Loading commit data...
gpio-ws16c48.c Loading commit data...
gpio-xgene-sb.c Loading commit data...
gpio-xgene.c Loading commit data...
gpio-xilinx.c Loading commit data...
gpio-xlp.c Loading commit data...
gpio-xra1403.c Loading commit data...
gpio-xtensa.c Loading commit data...
gpio-zevio.c Loading commit data...
gpio-zx.c Loading commit data...
gpio-zynq.c Loading commit data...
gpiolib-acpi.c Loading commit data...
gpiolib-devprop.c Loading commit data...
gpiolib-legacy.c Loading commit data...
gpiolib-of.c Loading commit data...
gpiolib-sysfs.c Loading commit data...
gpiolib.c Loading commit data...
gpiolib.h Loading commit data...