1. 06 11月, 2014 1 次提交
  2. 05 11月, 2014 2 次提交
    • R
      ACPI / GPIO: Driver GPIO mappings for ACPI GPIOs · f028d524
      Rafael J. Wysocki 提交于
      Provide a way for device drivers using GPIOs described by ACPI
      GpioIo resources in _CRS to tell the GPIO subsystem what names
      (connection IDs) to associate with specific GPIO pins defined
      in there.
      
      To do that, a driver needs to define a mapping table as a
      NULL-terminated array of struct acpi_gpio_mapping objects
      that each contain a name, a pointer to an array of line data
      (struct acpi_gpio_params) objects and the size of that array.
      
      Each struct acpi_gpio_params object consists of three fields,
      crs_entry_index, line_index, active_low, representing the index of
      the target GpioIo()/GpioInt() resource in _CRS starting from zero,
      the index of the target line in that resource starting from zero,
      and the active-low flag for that line, respectively.
      
      Next, the mapping table needs to be passed as the second
      argument to acpi_dev_add_driver_gpios() that will register it with
      the ACPI device object pointed to by its first argument.  That
      should be done in the driver's .probe() routine.
      
      On removal, the driver should unregister its GPIO mapping table
      by calling acpi_dev_remove_driver_gpios() on the ACPI device
      object where that table was previously registered.
      
      Included are fixes from Mika Westerberg.
      Acked-by: NAlexandre Courbot <acourbot@nvidia.com>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      f028d524
    • M
      gpio / ACPI: Add support for _DSD device properties · 0d9a693c
      Mika Westerberg 提交于
      With release of ACPI 5.1 and _DSD method we can finally name GPIOs (and
      other things as well) returned by _CRS. Previously we were only able to
      use integer index to find the corresponding GPIO, which is pretty error
      prone if the order changes.
      
      With _DSD we can now query GPIOs using name instead of an integer index,
      like the below example shows:
      
        // Bluetooth device with reset and shutdown GPIOs
        Device (BTH)
        {
            Name (_HID, ...)
      
            Name (_CRS, ResourceTemplate ()
            {
                GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
                        "\\_SB.GPO0", 0, ResourceConsumer) {15}
                GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly,
                        "\\_SB.GPO0", 0, ResourceConsumer) {27, 31}
            })
      
            Name (_DSD, Package ()
            {
                ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
                Package ()
      	  {
                    Package () {"reset-gpio", Package() {^BTH, 1, 1, 0 }},
                    Package () {"shutdown-gpio", Package() {^BTH, 0, 0, 0 }},
                }
            })
        }
      
      The format of the supported GPIO property is:
      
        Package () { "name", Package () { ref, index, pin, active_low }}
      
        ref - The device that has _CRS containing GpioIo()/GpioInt() resources,
              typically this is the device itself (BTH in our case).
        index - Index of the GpioIo()/GpioInt() resource in _CRS starting from zero.
        pin - Pin in the GpioIo()/GpioInt() resource. Typically this is zero.
        active_low - If 1 the GPIO is marked as active_low.
      
      Since ACPI GpioIo() resource does not have field saying whether it is
      active low or high, the "active_low" argument can be used here. Setting
      it to 1 marks the GPIO as active low.
      
      In our Bluetooth example the "reset-gpio" refers to the second GpioIo()
      resource, second pin in that resource with the GPIO number of 31.
      
      This patch implements necessary support to gpiolib for extracting GPIOs
      using _DSD device properties.
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Acked-by: NLinus Walleij <linus.walleij@linaro.org>
      Acked-by: NGrant Likely <grant.likely@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      0d9a693c
  3. 04 11月, 2014 1 次提交
  4. 29 10月, 2014 1 次提交
  5. 25 9月, 2014 1 次提交
  6. 29 8月, 2014 2 次提交
  7. 28 7月, 2014 1 次提交
  8. 23 7月, 2014 1 次提交
  9. 23 5月, 2014 1 次提交
  10. 14 4月, 2014 2 次提交
    • M
      gpio / ACPI: Prevent potential wrap of GPIO value on OpRegion read · b5539fa2
      Mika Westerberg 提交于
      Dan Carpenter's static code checker reports:
      
       The patch 473ed7be: "gpio / ACPI: Add support for ACPI GPIO
       operation regions" from Mar 14, 2014, leads to the following static
       checker warning:
      
        drivers/gpio/gpiolib-acpi.c:454 acpi_gpio_adr_space_handler()
        warn: should 'gpiod_get_raw_value(desc) << i' be a 64 bit type?
      
      This is due the fact that *value is of type u64 and gpiod_get_raw_value()
      returns int. Since i can be larger than 31, it is possible that the value
      returned gets wrapped.
      
      Fix this by casting the return of gpiod_get_raw_value() to u64 first before
      shift.
      Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      b5539fa2
    • M
      gpio / ACPI: Don't crash on NULL chip->dev · e9595f84
      Mika Westerberg 提交于
      Commit aa92b6f6 (gpio / ACPI: Allocate ACPI specific data directly in
      acpi_gpiochip_add()) moved ACPI handle checking to acpi_gpiochip_add() but
      forgot to check whether chip->dev is NULL before dereferencing it.
      
      Since chip->dev pointer is optional we can end up with crash like following:
      
       BUG: unable to handle kernel NULL pointer dereference at 00000138
       IP: [<c126c2b3>] acpi_gpiochip_add+0x13/0x190
       *pde = 00000000
       Oops: 0000 [#1] PREEMPT SMP
       Modules linked in: ssb(+) ...
       CPU: 0 PID: 512 Comm: modprobe Tainted: G        W     3.14.0-rc7-next-20140324-t1 #24
       Hardware name: Dell Inc. Latitude D830                   /0UY141, BIOS A02 06/07/2007
       task: f5799900 ti: f543e000 task.ti: f543e000
       EIP: 0060:[<c126c2b3>] EFLAGS: 00010282 CPU: 0
       EIP is at acpi_gpiochip_add+0x13/0x190
       EAX: 00000000 EBX: f57824c4 ECX: 00000000 EDX: 00000000
       ESI: f57824c4 EDI: 00000010 EBP: f543fc54 ESP: f543fc40
        DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
       CR0: 8005003b CR2: 00000138 CR3: 355f8000 CR4: 000007d0
       Stack:
        f543fc5c fd1f7790 f57824c4 000000be 00000010 f543fc84 c1269f4e f543fc74
        fd1f78bd 00008002 f57822b0 f5782090 fd1f8400 00000286 fd1f9994 00000000
        f5782000 f543fc8c fd1f7e39 f543fcc8 fd1f0bd8 000000c0 00000000 00000000
       Call Trace:
        [<fd1f7790>] ? ssb_pcie_mdio_write+0xa0/0xd0 [ssb]
        [<c1269f4e>] gpiochip_add+0xee/0x300
        [<fd1f78bd>] ? ssb_pcicore_serdes_workaround+0xfd/0x140 [ssb]
        [<fd1f7e39>] ssb_gpio_init+0x89/0xa0 [ssb]
        [<fd1f0bd8>] ssb_attach_queued_buses+0xc8/0x2d0 [ssb]
        [<fd1f0f65>] ssb_bus_register+0x185/0x1f0 [ssb]
        [<fd1f3120>] ? ssb_pci_xtal+0x220/0x220 [ssb]
        [<fd1f106c>] ssb_bus_pcibus_register+0x2c/0x80 [ssb]
        [<fd1f40dc>] ssb_pcihost_probe+0x9c/0x110 [ssb]
        [<c1276c8f>] pci_device_probe+0x6f/0xc0
        [<c11bdb55>] ? sysfs_create_link+0x25/0x40
        [<c131d8b9>] driver_probe_device+0x79/0x360
        [<c1276512>] ? pci_match_device+0xb2/0xc0
        [<c131dc51>] __driver_attach+0x71/0x80
        [<c131dbe0>] ? __device_attach+0x40/0x40
        [<c131bd87>] bus_for_each_dev+0x47/0x80
        [<c131d3ae>] driver_attach+0x1e/0x20
        [<c131dbe0>] ? __device_attach+0x40/0x40
        [<c131d007>] bus_add_driver+0x157/0x230
        [<c131e219>] driver_register+0x59/0xe0
        ...
      
      Fix this by checking chip->dev pointer against NULL first. Also we can now
      remove redundant check in acpi_gpiochip_request/free_interrupts().
      Reported-by: NSabrina Dubroca <sd@queasysnail.net>
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Tested-by: NSabrina Dubroca <sd@queasysnail.net>
      Acked-by: NAlexandre Courbot <acourbot@nvidia.com>
      Tested-by: NJosh Boyer <jwboyer@fedoraproject.org>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      e9595f84
  11. 15 3月, 2014 1 次提交
    • M
      gpio / ACPI: Add support for ACPI GPIO operation regions · 473ed7be
      Mika Westerberg 提交于
      GPIO operation regions is a new feature introduced in ACPI 5.0
      specification. This feature adds a way for platform ASL code to call back
      to OS GPIO driver and toggle GPIO pins.
      
      An example ASL code from Lenovo Miix 2 tablet with only relevant part
      listed:
      
       Device (\_SB.GPO0)
       {
           Name (AVBL, Zero)
           Method (_REG, 2, NotSerialized)
           {
               If (LEqual (Arg0, 0x08))
               {
                   // Marks the region available
                   Store (Arg1, AVBL)
               }
           }
      
           OperationRegion (GPOP, GeneralPurposeIo, Zero, 0x0C)
           Field (GPOP, ByteAcc, NoLock, Preserve)
           {
               Connection (
                   GpioIo (Exclusive, PullDefault, 0, 0, IoRestrictionOutputOnly,
                           "\\_SB.GPO0", 0x00, ResourceConsumer,,)
                   {
                       0x003B
                   }
               ),
               SHD3,   1,
           }
       }
      
       Device (SHUB)
       {
           Method (_PS0, 0, Serialized)
           {
               If (LEqual (\_SB.GPO0.AVBL, One))
               {
                   Store (One, \_SB.GPO0.SHD3)
                   Sleep (0x32)
               }
           }
           Method (_PS3, 0, Serialized)
           {
               If (LEqual (\_SB.GPO0.AVBL, One))
               {
                   Store (Zero, \_SB.GPO0.SHD3)
               }
           }
       }
      
      How this works is that whenever _PS0 or _PS3 method is run (typically when
      SHUB device is transitioned to D0 or D3 respectively), ASL code checks if
      the GPIO operation region is available (\_SB.GPO0.AVBL). If it is we go and
      store either 0 or 1 to \_SB.GPO0.SHD3.
      
      Now, when ACPICA notices ACPI GPIO operation region access (the store
      above) it will call acpi_gpio_adr_space_handler() that then toggles the
      GPIO accordingly using standard gpiolib interfaces.
      
      Implement the support by registering GPIO operation region handlers for all
      GPIO devices that have an ACPI handle. First time the GPIO is used by the
      ASL code we make sure that the GPIO stays requested until the GPIO chip
      driver itself is unloaded. If we find out that the GPIO is already
      requested we just toggle it according to the value got from ASL code.
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      473ed7be
  12. 13 3月, 2014 3 次提交
  13. 13 2月, 2014 1 次提交
  14. 08 1月, 2014 2 次提交
  15. 13 12月, 2013 1 次提交
  16. 20 10月, 2013 2 次提交
  17. 11 10月, 2013 1 次提交
  18. 24 9月, 2013 1 次提交
  19. 17 9月, 2013 1 次提交
  20. 12 4月, 2013 1 次提交
  21. 11 4月, 2013 1 次提交
    • R
      gpio / ACPI: Handle ACPI events in accordance with the spec · 7fc7acb9
      Rafael J. Wysocki 提交于
      Commit 0d1c28a4 (gpiolib-acpi: Add ACPI5 event model support to gpio.)
      that added support for ACPI events signalled through GPIO interrupts
      covered only GPIO pins whose numbers are less than or equal to 255.
      However, there may be GPIO pins with numbers greater than 255 and
      the ACPI spec (ACPI 5.0, Section 5.6.5.1) requires the _EVT method
      to be used for handling events corresponding to those pins.
      
      Moreover, according to the spec, _EVT is the default mechanism
      for handling all ACPI events signalled through GPIO interrupts,
      so if the _Exx/_Lxx method is not present for the given pin,
      _EVT should be used instead.  If present, though, _Exx/_Lxx take
      precedence over _EVT which shouldn't be executed in that case
      (ACPI 5.0, Section 5.6.5.3).
      
      Modify acpi_gpiochip_request_interrupts() to follow the spec as
      described above and add acpi_gpiochip_free_interrupts() needed
      to free interrupts associated with _EVT.
      Signed-off-by: NRafael 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>
      7fc7acb9
  22. 05 2月, 2013 1 次提交
  23. 29 1月, 2013 1 次提交
  24. 30 11月, 2012 1 次提交