1. 14 12月, 2018 1 次提交
  2. 03 10月, 2018 1 次提交
  3. 25 9月, 2018 1 次提交
  4. 18 9月, 2018 1 次提交
    • L
      gpio: Get rid of legacy header · f13a0b0b
      Linus Walleij 提交于
      A bunch of core gpiolib files still include the <linux/gpio.h>
      legacy API header for no good reason. After this only the
      gpiolib-legacy.c file includes it, which is fine.
      
      The sysfs ABI code has a pointless wrapper function around
      gpio_to_desc() we can just loose.
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      f13a0b0b
  5. 29 8月, 2018 2 次提交
    • H
      gpiolib-acpi: Register GpioInt ACPI event handlers from a late_initcall · 78d3a92e
      Hans de Goede 提交于
      GpioInt ACPI event handlers may see there IRQ triggered immediately
      after requesting the IRQ (esp. level triggered ones). This means that they
      may run before any other (builtin) drivers have had a chance to register
      their OpRegion handlers, leading to errors like this:
      
      [    1.133274] ACPI Error: No handler for Region [PMOP] ((____ptrval____)) [UserDefinedRegion] (20180531/evregion-132)
      [    1.133286] ACPI Error: Region UserDefinedRegion (ID=141) has no handler (20180531/exfldio-265)
      [    1.133297] ACPI Error: Method parse/execution failed \_SB.GPO2._L01, AE_NOT_EXIST (20180531/psparse-516)
      
      We already defer the manual initial trigger of edge triggered interrupts
      by running it from a late_initcall handler, this commit replaces this with
      deferring the entire acpi_gpiochip_request_interrupts() call till then,
      fixing the problem of some OpRegions not being registered yet.
      
      Note that this removes the need to have a list of edge triggered handlers
      which need to run, since the entire acpi_gpiochip_request_interrupts() call
      is now delayed, acpi_gpiochip_request_interrupt() can call these directly
      now.
      Acked-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      78d3a92e
    • A
      gpiolib: acpi: Switch to cansleep version of GPIO library call · 993b9bc5
      Andy Shevchenko 提交于
      The commit ca876c74
      
        ("gpiolib-acpi: make sure we trigger edge events at least once on boot")
      
      added a initial value check for pin which is about to be locked as IRQ.
      Unfortunately, not all GPIO drivers can do that atomically. Thus,
      switch to cansleep version of the call. Otherwise we have a warning:
      
      ...
        WARNING: CPU: 2 PID: 1408 at drivers/gpio/gpiolib.c:2883 gpiod_get_value+0x46/0x50
      ...
        RIP: 0010:gpiod_get_value+0x46/0x50
      ...
      
      The change tested on Intel Broxton with Whiskey Cove PMIC GPIO controller.
      
      Fixes: ca876c74 ("gpiolib-acpi: make sure we trigger edge events at least once on boot")
      Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
      Acked-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      993b9bc5
  6. 01 8月, 2018 1 次提交
    • B
      gpiolib-acpi: make sure we trigger edge events at least once on boot · ca876c74
      Benjamin Tissoires 提交于
      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: NBenjamin 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: NHans de Goede <hdegoede@redhat.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      ca876c74
  7. 23 7月, 2018 1 次提交
  8. 22 12月, 2017 1 次提交
  9. 30 11月, 2017 6 次提交
  10. 29 11月, 2017 1 次提交
    • M
      gpio / ACPI: Drop unnecessary ACPI GPIO to Linux GPIO translation · 03c4749d
      Mika Westerberg 提交于
      We added acpi_gpiochip_pin_to_gpio_offset() because there was a need to
      translate from ACPI GpioIo/GpioInt number to Linux GPIO number in the
      Cherryview pinctrl driver. This translation is necessary because
      Cherryview has gaps in the pin list and the driver used continuous GPIO
      number space in Linux side as follows:
      
        created GPIO range 0->7 ==> INT33FF:03 PIN 0->7
        created GPIO range 8->19 ==> INT33FF:03 PIN 15->26
        created GPIO range 20->25 ==> INT33FF:03 PIN 30->35
        created GPIO range 26->33 ==> INT33FF:03 PIN 45->52
        created GPIO range 34->43 ==> INT33FF:03 PIN 60->69
        created GPIO range 44->54 ==> INT33FF:03 PIN 75->85
      
      For example when ACPI GpioInt resource refers to GPIO 81 (SDMMC3_CD_B)
      we translate from pin 81 to the corresponding Linux GPIO number, which
      is 50. This number is then used when the GPIO is accessed through gpiolib.
      
      It turns out, this is not necessary at all. We can just pass 1:1 mapping
      between Linux GPIO numbers and pin numbers (including gaps) and the
      pinctrl core handles all the details automatically:
      
        created GPIO range 0->7 ==> INT33FF:03 PIN 0->7
        created GPIO range 15->26 ==> INT33FF:03 PIN 15->26
        created GPIO range 30->35 ==> INT33FF:03 PIN 30->35
        created GPIO range 45->52 ==> INT33FF:03 PIN 45->52
        created GPIO range 60->69 ==> INT33FF:03 PIN 60->69
        created GPIO range 75->85 ==> INT33FF:03 PIN 75->85
      
      Here GPIO 81 is exactly same than the hardware pin 81 (SDMMC3_CD_B).
      
      As an added bonus this simplifies both the ACPI GPIO core code and the
      Cherryview pinctrl driver.
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Acked-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Reviewed-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      03c4749d
  11. 19 9月, 2017 1 次提交
    • A
      gpio: acpi: work around false-positive -Wstring-overflow warning · e40a3ae1
      Arnd Bergmann 提交于
      gcc-7 notices that the pin_table is an array of 16-bit numbers,
      but fails to take the following range check into account:
      
      drivers/gpio/gpiolib-acpi.c: In function 'acpi_gpiochip_request_interrupt':
      drivers/gpio/gpiolib-acpi.c:206:24: warning: '%02X' directive writing between 2 and 4 bytes into a region of size 3 [-Wformat-overflow=]
         sprintf(ev_name, "_%c%02X",
                              ^~~~
      drivers/gpio/gpiolib-acpi.c:206:20: note: directive argument in the range [0, 65535]
         sprintf(ev_name, "_%c%02X",
                          ^~~~~~~~~
      drivers/gpio/gpiolib-acpi.c:206:3: note: 'sprintf' output between 5 and 7 bytes into a destination of size 5
         sprintf(ev_name, "_%c%02X",
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
          agpio->triggering == ACPI_EDGE_SENSITIVE ? 'E' : 'L',
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          pin);
          ~~~~
      
      As suggested by Andy, this changes the format string to have a fixed length.
      Since modifying the range check did not help, I also opened a bug against
      gcc, see link below.
      
      Fixes: 0d1c28a4 ("gpiolib-acpi: Add ACPI5 event model support to gpio.")
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Link: https://patchwork.kernel.org/patch/9840801/
      Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82123Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      e40a3ae1
  12. 14 8月, 2017 1 次提交
  13. 29 6月, 2017 1 次提交
  14. 29 5月, 2017 7 次提交
  15. 30 3月, 2017 2 次提交
  16. 17 3月, 2017 2 次提交
  17. 15 3月, 2017 1 次提交
  18. 11 1月, 2017 1 次提交
  19. 09 11月, 2016 1 次提交
    • A
      ACPI / gpio: avoid warning for gpio hogging code · c82064f2
      Arnd Bergmann 提交于
      The newly added acpi_gpiochip_scan_gpios function produces a few harmless
      warnings:
      
      drivers/gpio/gpiolib-acpi.c: In function ‘acpi_gpiochip_add’:
      drivers/gpio/gpiolib-acpi.c:925:7: error: ‘dflags’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
      drivers/gpio/gpiolib-acpi.c:925:9: error: ‘lflags’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
      
      The problem is that he compiler cannot know that a negative return value
      from fwnode_property_read_u32_array() or acpi_gpiochip_pin_to_gpio_offset()
      implies that the IS_ERR(gpio_desc) is true, as the value could in theory
      be below -MAX_ERRNO.
      
      The function already initializes its output values to zero, and moving
      that intialization a little higher up ensures that we can never have
      uninitialized data in the caller.
      
      Fixes: c80f1ba7 ("ACPI / gpio: Add hogging support")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      c82064f2
  20. 31 10月, 2016 2 次提交
  21. 24 10月, 2016 3 次提交
  22. 20 10月, 2016 1 次提交
  23. 04 10月, 2016 1 次提交
    • L
      gpio: acpi: separation of concerns · 031ba28a
      Linus Walleij 提交于
      The generic GPIO library directly implement code for acpi_find_gpio()
      which is only used with CONFIG_ACPI. This was probably done because
      OF did the same thing, but I removed that so remove this too.
      
      Rename the internal acpi_find_gpio() in gpiolib-acpi.c to
      acpi_populate_gpio_lookup() which seems to be more appropriate anyway
      so as to avoid a namespace clash with the same function.
      
      Make the stub return -ENOENT rather than -ENOSYS (as that is for
      syscalls!).
      
      For some reason the sunxi pin control driver was including the private
      gpiolib header, it works just fine without it so remove that oneliner.
      
      Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      031ba28a