1. 29 8月, 2018 1 次提交
  2. 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
  3. 23 7月, 2018 1 次提交
  4. 22 12月, 2017 1 次提交
  5. 30 11月, 2017 6 次提交
  6. 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
  7. 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
  8. 14 8月, 2017 1 次提交
  9. 29 6月, 2017 1 次提交
  10. 29 5月, 2017 7 次提交
  11. 30 3月, 2017 2 次提交
  12. 17 3月, 2017 2 次提交
  13. 15 3月, 2017 1 次提交
  14. 11 1月, 2017 1 次提交
  15. 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
  16. 31 10月, 2016 2 次提交
  17. 24 10月, 2016 3 次提交
  18. 20 10月, 2016 1 次提交
  19. 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
  20. 15 6月, 2016 1 次提交
  21. 30 4月, 2016 1 次提交
    • V
      gpiolib-acpi: Duplicate con_id string when adding it to the crs lookup list · 7df89e92
      Ville Syrjälä 提交于
      Calling gpiod_get() from a module and then unloading the module leads to an
      oops due to acpi_can_fallback_to_crs() storing the pointer to the passed
      'con_id' string onto acpi_crs_lookup_list. The next guy to come along will then
      try to access the string but the memory may now be gone with the module.
      Make a copy of the passed string instead, and store the copy on the list.
      
      BUG: unable to handle kernel paging request at ffffffffa03e7855
      IP: [<ffffffff81338322>] strcmp+0x12/0x30
      PGD 2a07067 PUD 2a08063 PMD 74720067 PTE 0
      Oops: 0000 [#1] PREEMPT SMP
      Modules linked in: i915(+) drm_kms_helper drm intel_gtt snd_hda_codec snd_hda_core i2c_algo_bit syscopya
      rea sysfillrect sysimgblt fb_sys_fops agpgart snd_soc_sst_bytcr_rt5640 coretemp hwmon intel_rapl intel_soc_dts_thermal
      punit_atom_debug snd_soc_rt5640 snd_soc_rl6231 serio snd_intel_sst_acpi snd_intel_sst_core video snd_soc_sst_mfld_platf
      orm snd_soc_sst_match backlight int3402_thermal processor_thermal_device int3403_thermal int3400_thermal acpi_thermal_r
      el snd_soc_core intel_soc_dts_iosf int340x_thermal_zone snd_compress i2c_hid hid snd_pcm snd_timer snd soundcore evdev
      sch_fq_codel efivarfs ipv6 autofs4 [last unloaded: drm]
      CPU: 2 PID: 3064 Comm: modprobe Tainted: G     U  W       4.6.0-rc3-ffrd-ipvr+ #302
      Hardware name: Intel Corp. VALLEYVIEW C0 PLATFORM/BYT-T FFD8, BIOS BLAKFF81.X64.0088.R10.1403240443 FFD8
      _X64_R_2014_13_1_00 03/24/2014
      task: ffff8800701cd200 ti: ffff880070034000 task.ti: ffff880070034000
      RIP: 0010:[<ffffffff81338322>]  [<ffffffff81338322>] strcmp+0x12/0x30
      RSP: 0000:ffff880070037748  EFLAGS: 00010286
      RAX: 0000000080000000 RBX: ffff88007a342800 RCX: 0000000000000006
      RDX: 0000000000000006 RSI: ffffffffa054f856 RDI: ffffffffa03e7856
      RBP: ffff880070037748 R08: 0000000000000000 R09: 0000000000000001
      R10: 0000000000000000 R11: 0000000000000000 R12: ffffffffa054f855
      R13: ffff88007281cae0 R14: 0000000000000010 R15: ffffffffffffffea
      FS:  00007faa51447700(0000) GS:ffff880079300000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: ffffffffa03e7855 CR3: 0000000041eba000 CR4: 00000000001006e0
      Stack:
       ffff880070037770 ffffffff8136ad28 ffffffffa054f855 0000000000000000
       ffff88007a0a2098 ffff8800700377e8 ffffffff8136852e ffff88007a342800
       00000007700377a0 ffff8800700377a0 ffffffff81412442 70672d6c656e6170
      Call Trace:
       [<ffffffff8136ad28>] acpi_can_fallback_to_crs+0x88/0x100
       [<ffffffff8136852e>] gpiod_get_index+0x25e/0x310
       [<ffffffff81412442>] ? mipi_dsi_attach+0x22/0x30
       [<ffffffff813685f2>] gpiod_get+0x12/0x20
       [<ffffffffa04fcf41>] intel_dsi_init+0x421/0x480 [i915]
       [<ffffffffa04d3783>] intel_modeset_init+0x853/0x16b0 [i915]
       [<ffffffffa0504864>] ? intel_setup_gmbus+0x214/0x260 [i915]
       [<ffffffffa0510158>] i915_driver_load+0xdc8/0x19b0 [i915]
       [<ffffffff8160fb53>] ? _raw_spin_unlock_irqrestore+0x43/0x70
       [<ffffffffa026b13b>] drm_dev_register+0xab/0xc0 [drm]
       [<ffffffffa026d7b3>] drm_get_pci_dev+0x93/0x1f0 [drm]
       [<ffffffff8160fb53>] ? _raw_spin_unlock_irqrestore+0x43/0x70
       [<ffffffffa043f1f4>] i915_pci_probe+0x34/0x50 [i915]
       [<ffffffff81379751>] pci_device_probe+0x91/0x100
       [<ffffffff8141a75a>] driver_probe_device+0x20a/0x2d0
       [<ffffffff8141a8be>] __driver_attach+0x9e/0xb0
       [<ffffffff8141a820>] ? driver_probe_device+0x2d0/0x2d0
       [<ffffffff81418439>] bus_for_each_dev+0x69/0xa0
       [<ffffffff8141a04e>] driver_attach+0x1e/0x20
       [<ffffffff81419c20>] bus_add_driver+0x1c0/0x240
       [<ffffffff8141b6d0>] driver_register+0x60/0xe0
       [<ffffffff81377d20>] __pci_register_driver+0x60/0x70
       [<ffffffffa026d9f4>] drm_pci_init+0xe4/0x110 [drm]
       [<ffffffff810ce04e>] ? trace_hardirqs_on+0xe/0x10
       [<ffffffffa02f1000>] ? 0xffffffffa02f1000
       [<ffffffffa02f1094>] i915_init+0x94/0x9b [i915]
       [<ffffffff810003bb>] do_one_initcall+0x8b/0x1c0
       [<ffffffff810eb616>] ? rcu_read_lock_sched_held+0x86/0x90
       [<ffffffff811de6d6>] ? kmem_cache_alloc_trace+0x1f6/0x270
       [<ffffffff81183826>] do_init_module+0x60/0x1dc
       [<ffffffff81115a8d>] load_module+0x1d0d/0x2390
       [<ffffffff811120b0>] ? __symbol_put+0x70/0x70
       [<ffffffff811f41b2>] ? kernel_read_file+0x92/0x120
       [<ffffffff811162f4>] SYSC_finit_module+0xa4/0xb0
       [<ffffffff8111631e>] SyS_finit_module+0xe/0x10
       [<ffffffff81001ff3>] do_syscall_64+0x63/0x350
       [<ffffffff816103da>] entry_SYSCALL64_slow_path+0x25/0x25
      Code: f7 48 8d 76 01 48 8d 52 01 0f b6 4e ff 84 c9 88 4a ff 75 ed 5d c3 0f 1f 00 55 48 89 e5 eb 04 84 c0
       74 18 48 8d 7f 01 48 8d 76 01 <0f> b6 47 ff 3a 46 ff 74 eb 19 c0 83 c8 01 5d c3 31 c0 5d c3 66
      RIP  [<ffffffff81338322>] strcmp+0x12/0x30
       RSP <ffff880070037748>
      CR2: ffffffffa03e7855
      
      v2: Make the copied con_id const
      
      Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
      Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
      Cc: Alexandre Courbot <gnurou@gmail.com>
      Cc: stable@vger.kernel.org
      Fixes: 10cf4899 ("gpiolib: tighten up ACPI legacy gpio lookups")
      Signed-off-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Acked-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Reviewed-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      7df89e92
  22. 16 2月, 2016 1 次提交
  23. 01 1月, 2016 1 次提交
  24. 14 12月, 2015 1 次提交