Commit Graph

1433 Commits

Author SHA1 Message Date
Kevin Cernekee
26f1112695 CHROMIUM: gpio / ACPI: Fix duplicate calls to acpi_gpiochip_*_interrupts()
Commit 4d5b94cf65 ("BACKPORT: gpio / ACPI: Move event handling
registration to gpiolib irqchip helpers") moved the ACPI interrupt
request/free calls into the gpiolib helper functions,
gpiochip_irqchip_add() and acpi_gpiochip_remove().  The former function
is called by pinctrl-pistachio.c, so there is no need to call it from
acpi_gpiochip_request_interrupts() anymore.  And in fact, since the
argument type changed from struct acpi_gpio_chip * to struct gpio_chip *,
the current code is incorrect:

    drivers/gpio/gpiolib-acpi.c: In function 'acpi_gpiochip_add':
    drivers/gpio/gpiolib-acpi.c:386:2: warning: passing argument 1 of 'acpi_gpiochip_request_interrupts' from incompatible pointer type
      acpi_gpiochip_request_interrupts(acpi_gpio);
      ^
    drivers/gpio/gpiolib-acpi.c:218:6: note: expected 'struct gpio_chip *' but argument is of type 'struct acpi_gpio_chip *'
     void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)

BUG=chrome-os-partner:30840
TEST=builds without warnings

Change-Id: I730ae9e3fd31d09edd84596554e4390ab4bb0a06
Signed-off-by: Kevin Cernekee <cernekee@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/255246
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
2015-03-03 21:39:00 +00:00
Jarkko Nikula
7664e843e3 BACKPORT: gpio: Fix potential NULL handler data in chained irqchip handler
There is possibility with misconfigured pins that interrupt occurs instantly
after setting irq_set_chained_handler() in gpiochip_set_chained_irqchip().
Now if handler gets called before irq_set_handler_data() the handler gets
NULL handler data.

Fix this by moving irq_set_handler_data() call before
irq_set_chained_handler() in gpiochip_set_chained_irqchip().

Cc: Stable <stable@vger.kernel.org> # 3.15+
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
(cherry picked from commit 324b039878)
[abrestic: resolved merge conflict as was done upstream]
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I9adcff381bf164082776aa7aed81f34f24dc4e38
Reviewed-on: https://chromium-review.googlesource.com/238917
Reviewed-by: Olof Johansson <olofj@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
2015-01-26 14:31:05 +00:00
Linus Walleij
fe3a652adf BACKPORT: gpio: handle also nested irqchips in the chained handler set-up
To unify how we connect cascaded IRQ chips to parent IRQs, if
NULL us passed as handler to the gpiochip_set_chained_irqchip()
function, assume the chips is nested rather than chained, and
we still get the parent set up correctly by way of this function
call.

Alter the drivers for tc3589x and stmpe to use this to set up
their chained handlers as a demonstration of the usage.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 3f97d5fcf9)
[abrestic: dropped updates to tc3589x and stmpe drivers]
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I05efd00204fbedc977078ab03ba4c805f757a65b
Reviewed-on: https://chromium-review.googlesource.com/238916
Reviewed-by: Olof Johansson <olofj@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
2015-01-26 14:30:59 +00:00
Linus Walleij
3510db0a74 UPSTREAM: gpio: set parent irq on chained handlers
If the IRQ from the parent is nested the IRQ may need to be
resent under certain conditions. Currently the chained IRQ
handler in gpiolib does not handle connecting nested IRQs
but it is conceptually correct to indicate the actual parent
IRQ.

Reported-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reported-by: Lothar Waßmann <LW@karo-electronics.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 83141a7719)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I0bcb799aaf5ff3e70db27e3c49c23961cbb30d01
Reviewed-on: https://chromium-review.googlesource.com/238915
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:59:54 +00:00
Grygorii Strashko
824b2e99d2 UPSTREAM: gpiolib: irqchip: use irq_find_mapping while removing irqchip
There is no guarantee that VIRQs will be allocated sequentially
for gpio irqchip in gpiochip_irqchip_add().
Therefore, it's unsafe to dispose VIRQ in gpiochip_irqchip_remove()
basing on index relatively to stored irq_base value.

Hence, use irq_find_mapping for VIRQ finding  in gpiochip_irqchip_remove()
instead of irq_base + index.

Reported-by: Wang, Yalin <Yalin.Wang@sonymobile.com>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit e3893386b9)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I26a59d615fb89e18c27ea412896a08981e9f8314
Reviewed-on: https://chromium-review.googlesource.com/238914
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:59:40 +00:00
Octavian Purdila
62d2946c06 UPSTREAM: gpiolib: add irq_not_threaded flag to gpio_chip
Some GPIO chips (e.g. the DLN2 USB adapter) have blocking get/set
operation but do not need a threaded irq handler.

Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 295494af06)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: Id41893538d41e6f3cb33df0ace269a76504144b8
Reviewed-on: https://chromium-review.googlesource.com/238913
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:59:25 +00:00
Mika Westerberg
4d5b94cf65 BACKPORT: gpio / ACPI: Move event handling registration to gpiolib irqchip helpers
Since now we have irqchip helpers that the GPIO chip drivers are supposed
to use if possible, we can move the registration of ACPI events to happen
in these helpers. This seems to be more natural place and might encourage
GPIO chip driver writers to take advantage of the irqchip helpers.

We make the functions available to GPIO chip drivers via private gpiolib.h,
just in case generic irqchip helpers are not suitable.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit afa82fab5e)
[abrestic: fixed conflict due to introduction of ACPI GPIO operating
 regions upstream]
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I12288d5bd8f4b4c69c086341695210bfe709265e
Reviewed-on: https://chromium-review.googlesource.com/238912
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:59:09 +00:00
Alexandre Courbot
db267eaee2 BACKPORT: gpio: remove gpiod_lock/unlock_as_irq()
gpio_lock/unlock_as_irq() are working with (chip, offset) arguments and
are thus not using the old integer namespace. Therefore, there is no
reason to have gpiod variants of these functions working with
descriptors, especially since the (chip, offset) tuple is more suitable
to the users of these functions (GPIO drivers, whereas GPIO descriptors
are targeted at GPIO consumers).

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit d74be6dfea)
[abrestic: fixed conflicts due to split of gpiolib.c into separate
 files upstream]
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I91a0fe4a42c8b2d92c9879f8aa5993bcd8556767
Reviewed-on: https://chromium-review.googlesource.com/238911
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:58:55 +00:00
Linus Walleij
462d97d753 UPSTREAM: gpio: do not set up hardware for IRQ_TYPE_NONE
Some GPIO irqchip drivers exploit the irqdomain mapping
function to set up the IRQ default type in the hardware,
make sure that if we pass IRQ_TYPE_NONE, no hardware setup
whatsoever takes place (this should be the norm) until
later when the IRQ gets utilized.

Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: linux-omap <linux-omap@vger.kernel.org>
Tested-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Tested-by: Javier Martinez Canillas <javier@dowhile0.org>
Tested-by: Nishanth Menon <nm@ti.com>
Acked-by: Nishanth Menon <nm@ti.com>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 1333b90f33)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I8b54f38cf331927c90e5c75eaec861eba8f28892
Reviewed-on: https://chromium-review.googlesource.com/238908
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:57:59 +00:00
Linus Walleij
a1a865bf89 UPSTREAM: gpiolib: of: remove gpio_to_desc() usage
As demonstrated by commit
390d82e312
"gpiolib: ACPI: remove gpio_to_desc() usage"

gpio_to_desc() must die. Replace one of its usage by the
newly-introduced gpiochip_get_desc() function.

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit ccd9726e05)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I7dcf314dc05af5b27ccf819f9740f747bc232686
Reviewed-on: https://chromium-review.googlesource.com/238907
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:57:41 +00:00
Alexandre Courbot
c80964312e UPSTREAM: gpiolib: ACPI: remove gpio_to_desc() usage
gpio_to_desc() must die. Replace one of its usage by the
newly-introduced gpiochip_get_desc() function.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 390d82e312)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: If7d540395b382bac8e079d9b0ecabd57442cbda4
Reviewed-on: https://chromium-review.googlesource.com/238906
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:57:20 +00:00
Linus Walleij
cda41268e1 UPSTREAM: gpio: put GPIO IRQs into their own lock class
Another feature that is duplicated in a number of GPIO irqchips
is that these cascades IRQs are assigned their own lock class
so as to avoid warnings about lockdep recursions. Do this also
in the generic GPIO irqchip helpers for smooth transition to
this core infrastructure.

Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit e45d1c80c0)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I09edcb5ddc8f1b1f16a3230f71c8312a3a2bc2ee
Reviewed-on: https://chromium-review.googlesource.com/238905
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:57:01 +00:00
Linus Walleij
ad3aa9930c UPSTREAM: gpio: support threaded interrupts in irqchip helpers
Some off-chip GPIO expanders need to be communicated by I2C or
SPI traffic, but may still support IRQs. By the sleeping nature
of such buses, such IRQ handlers need to be threaded. Support
such handlers in the gpiochip irqchip helpers by flagging IRQs
as threaded if the .can_sleep property of the gpiochip is
true.

Helpfully deny registration of chained IRQ handlers if the
.can_sleep property is set, as such chips will invariably need
a nested handler rather than a chained handler.

Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 1c8732bb03)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I7d4e53c668470c9282054ddcfa825e43181246fb
Reviewed-on: https://chromium-review.googlesource.com/238904
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:56:46 +00:00
Mika Westerberg
f85fe74cff UPSTREAM: gpio / ACPI: Don't crash on NULL chip->dev
Commit aa92b6f689 (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: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Tested-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Tested-by: Josh Boyer <jwboyer@fedoraproject.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit e9595f84a6)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: Icf8756aa8eee6a73dea274002e66ad34681e116a
Reviewed-on: https://chromium-review.googlesource.com/238903
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:56:28 +00:00
Linus Walleij
68aa88da80 UPSTREAM: gpio: set data first, then chip and handler
During irq mapping, in irq_set_chip_and_handler() the process
of setting this up may incur calls to lock the irqchip, which
in turn may need to dereference and use the chip data. So set
the data first, then set the chip and handler.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 7633fb959b)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I57dd0f56a660eef091b95d286e5cd68d22d2d3c9
Reviewed-on: https://chromium-review.googlesource.com/238902
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:56:21 +00:00
Linus Walleij
4a74918b8b UPSTREAM: gpio: unmap gpio irqs properly
When using the irqchip helper inside the gpiolib, make sure
the IRQs are unmapped/disposed before the irqdomain is removed
as part of removing the gpiochip.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit c3626fdea0)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I4a35e0071a7d4a30dcab0d9ab36a85cb048c64e4
Reviewed-on: https://chromium-review.googlesource.com/238901
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:55:54 +00:00
Linus Walleij
94c7e87013 UPSTREAM: gpio: add IRQ chip helpers in gpiolib
This provides a function gpiochip_irqchip_add() to set
up an irqchip for a GPIO controller, and a function
gpiochip_set_chained_irqchip() to chain it to a parent
irqchip.

Most GPIOs are of the type where a number of lines form
a cascaded interrupt controller chained onto
the primary system interrupt controller (or further down the
chain) so let's add this helper and factor the code to
request the lines to be used as IRQs, the .to_irq() function
and the irqdomain into the core as well.

Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 1425052097)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I36ccc73610ccad29c2c7ee5a69746770223b0293
Reviewed-on: https://chromium-review.googlesource.com/238900
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:55:27 +00:00
Mika Westerberg
fa06368cf5 UPSTREAM: gpio / ACPI: Rework ACPI GPIO event handling
The current ACPI GPIO event handling code was never tested against real
hardware with functioning GPIO triggered events (at the time such hardware
wasn't available). Thus it misses certain things like requesting the GPIOs
properly, passing correct flags to the interrupt handler and so on.

This patch reworks ACPI GPIO event handling so that we:

 1) Use struct acpi_gpio_event for all GPIO signaled events.
 2) Switch to use GPIO descriptor API and request GPIOs by calling
    gpiochip_request_own_desc() that we added in a previous patch.
 3) Pass proper flags from ACPI GPIO resource to request_threaded_irq().

Also instead of open-coding the _AEI iteration loop we can use
acpi_walk_resources(). This simplifies the code a bit and fixes memory leak
that was caused by missing kfree() for buffer returned by
acpi_get_event_resources().

Since the remove path now calls gpiochip_free_own_desc() which takes GPIO
spinlock we need to call acpi_gpiochip_remove() outside of that lock
(analogous to acpi_gpiochip_add() path where the lock is released before
those funtions are called).

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 6072b9dcf9)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: Ib9b42dc0f07a81c3ba9ba6dab374092aa7cbe916
Reviewed-on: https://chromium-review.googlesource.com/238839
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:55:17 +00:00
Mika Westerberg
70b14859e9 UPSTREAM: gpio / ACPI: Rename acpi_gpio_evt_pin to acpi_gpio_event
In order to consolidate _Exx, _Lxx and _EVT to use the same structure make
the structure name to reflect that we are dealing with any event, not just
_EVT.

This is just rename, no functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 4b01a14bac)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I26b343a6648373a0ee0119d9a05b8ced706394af
Reviewed-on: https://chromium-review.googlesource.com/238838
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:55:10 +00:00
Mika Westerberg
b28fd29cb7 BACKPORT: gpio / ACPI: Allocate ACPI specific data directly in acpi_gpiochip_add()
We are going to add more ACPI specific data to accompany GPIO chip so
instead of allocating it per each use-case we allocate it once when
acpi_gpiochip_add() is called and release it when acpi_gpiochip_remove() is
called.

Doing this allows us to add more ACPI specific data by merely adding new
fields to struct acpi_gpio_chip.

In addition we embed evt_pins member directly to the structure instead of
having it as a pointer. This simplifies the code a bit since we don't need
to check against NULL.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit aa92b6f689)
[abrestic: fixed compile error from missing semicolon]
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I1e34126ada81ff3cf66d942e32fd8b7d52f39593
Reviewed-on: https://chromium-review.googlesource.com/238837
Reviewed-by: Andrew Bresticker <abrestic@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-23 19:55:03 +00:00
Mika Westerberg
997478ffda UPSTREAM: gpiolib: Allow GPIO chips to request their own GPIOs
Sometimes it is useful to allow GPIO chips themselves to request GPIOs they
own through gpiolib API. One use case is ACPI ASL code that should be able
to toggle GPIOs through GPIO operation regions.

We can't use gpio_request() because it will pin the module to the kernel
forever (it calls try_module_get()). To solve this we move module refcount
manipulation to gpiod_request() and let __gpiod_request() handle the actual
request. This changes the sequence a bit as now try_module_get() is called
outside of gpio_lock (I think this is safe, try_module_get() handles
serialization it needs already).

Then we provide gpiolib internal functions gpiochip_request/free_own_desc()
that do the same as gpio_request() but don't manipulate module refrence
count. This allows the GPIO chip driver to request and free descriptors it
owns without being pinned to the kernel forever.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit 77c2d7929d)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I08296d1b7bc3a1d59234fd1ea6719bcc304b30d0
Reviewed-on: https://chromium-review.googlesource.com/238836
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
2015-01-22 21:14:46 +00:00
Linus Walleij
630a1a988b UPSTREAM: gpio: remove misleading documentation
It is currently debated where the functions to lock a certain
GPIO line as used for IRQs should be called. Delete all
misleading documentation.

Reported-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit f438acdf3d)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: I2cbe0bd8e14a67eb6be3271bba8ab32c0613e018
Reviewed-on: https://chromium-review.googlesource.com/238835
Reviewed-by: Olof Johansson <olofj@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
2015-01-17 01:00:15 +00:00
Alexandre Courbot
24baa32b46 UPSTREAM: gpiolib: add gpiochip_get_desc() driver function
Some drivers dealing with a gpio_chip might need to act on its
descriptors directly; one example is pinctrl drivers that need to lock a
GPIO for being used as IRQ using gpiod_lock_as_irq().

This patch exports a gpiochip_get_desc() function that returns the
GPIO descriptor at the requested index. It also sweeps the
gpio_to_chip() function out of the consumer interface since any holder
of a gpio_chip reference can manipulate its GPIOs way beyond what a
consumer should be allowed to do.

As a result, gpio_chip is not visible anymore to simple GPIO consumers.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit bb1e88ccb7)
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

BUG=chrome-os-partner:30840
TEST=builds

Change-Id: Ie34b086797aa45efebc7c4eeffeb42f7b2ef9684
Reviewed-on: https://chromium-review.googlesource.com/238834
Reviewed-by: Olof Johansson <olofj@chromium.org>
Commit-Queue: Andrew Bresticker <abrestic@chromium.org>
Tested-by: Andrew Bresticker <abrestic@chromium.org>
2015-01-17 01:00:06 +00:00
Tuomas Tynkkynen
4f4e3f7d60 CHROMIUM: gpio: tegra: Move suspend callbacks to noirq phase
Without this the system hangs during LP0 resume when the kernel
resumes GPIO interrupts.

BUG=chrome-os-partner:31211
TEST=suspend/resume from LP0

Change-Id: I6afe6a9af9b877cafc6845ebc027288456e34329
Signed-off-by: Tuomas Tynkkynen <ttynkkynen@nvidia.com>
Signed-off-by: Joseph Lo <josephl@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/215533
Reviewed-by: David Riley <davidriley@chromium.org>
2014-10-27 07:06:39 +00:00
Kumar Gala
4bb4c5c13c UPSTREAM: gpio: msm: switch Kconfig to ARCH_QCOM depends
We've split Qualcomm MSM support into legacy and multiplatform.  The gpio
msm-v2 driver is only relevant on the multiplatform supported SoCs so
switch the Kconfig depends to ARCH_QCOM.

CC: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Alexandre Courbot <gnurou@gmail.com>
Signed-off-by: Kumar Gala <galak@codeaurora.org>
(cherry picked from commit add798a40a)
BUG=chrome-os-partner:31587
TEST=build/boot on AP-148 and storm P0

Signed-off-by: Grant Grundler <grundler@chromium.org>

Change-Id: I70aac13c5ab46d79a97794b034e1a31194e4a414
Reviewed-on: https://chromium-review.googlesource.com/214905
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: Grant Grundler <grundler@chromium.org>
Commit-Queue: Grant Grundler <grundler@chromium.org>
2014-08-29 21:57:26 +00:00
Philipp Zabel
fe36a4764b UPSTREAM: gpio: make gpiod_direction_output take a logical value
The documentation was not clear about whether
gpio_direction_output should take a logical value or the physical
level on the output line, i.e. whether the ACTIVE_LOW status
would be taken into account.

This converts gpiod_direction_output to use the logical level
and adds a new gpiod_direction_output_raw for the raw value.

BUG=chrome-os-partner:31528
TEST=gpio-restart changes do not reboot machine at boot

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit ef70bbe1aa)
Signed-off-by: David Riley <davidriley@chromium.org>

Change-Id: Ib9c6eb77a2f8fbba9be00032a50fbef63c440d81
Reviewed-on: https://chromium-review.googlesource.com/214278
Reviewed-by: Olof Johansson <olofj@chromium.org>
Tested-by: David Riley <davidriley@chromium.org>
Commit-Queue: David Riley <davidriley@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Anatol Pomazau <anatol@google.com>
2014-08-28 01:33:20 +00:00
Yunlian Jiang
6559b5ac16 gpio: remove __DATE__ and __TIME__ macro.
Kernel enables the '-Werror=date-time' for gcc 4.9. And these two
macros causes the problem.

Signed-off-by: Yunlian Jiang <yunlian@google.com>
BUG=chromium:392001
TEST=the warning is gone.

Change-Id: I56145bcf9228df8e93fc624e892f843716336101
Reviewed-on: https://chromium-review.googlesource.com/206949
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Olof Johansson <olofj@chromium.org>
Commit-Queue: Yunlian Jiang <yunlian@chromium.org>
Tested-by: Yunlian Jiang <yunlian@chromium.org>
2014-07-08 21:30:40 +00:00
Duncan Laurie
770a0464a7 CHROMIUM: gpio: Add PantherPoint NM70 and HM70 device IDs
These are used by upcoming devices and without it crossystem is
unable to read GPIO values on the chipset.

BUG=chrome-os-partner:11540,chrome-os-partner:11323
TEST=manual test on Parrot device

1) Verify that a GPIO can be exported and read:
> echo $(( 160 + 70 )) > /sys/class/gpio/export
> cat /sys/class/gpio/gpio$(( 160 + 70 ))/value
0

2) Verify that crossystem does not report any errors:
> crossystem | grep -c error
0

Change-Id: Iebdc2396bf401c6df6b7802cbd05832b53f0e0c3
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28183
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2014-05-14 17:55:10 -07:00
Vadim Bendebury
3c85d71be3 CHROMIUM: gpio: nm10: add device IDs of IVB LPC variants
These PCI device IDs describe various variants of the Ivy Bridge
chipset South Bridge LPC device (00:1f.0), which includes the GPIO
controller.

BUG=none
TEST=manual
      . with this fix the driver installs on the most recent hardware
        where it was failing to install before

Change-Id: Iaff6c1f1bdc7ec977329b0693e672d302824fa58
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/22517
Reviewed-by: Olof Johansson <olofj@chromium.org>
2014-05-14 17:55:03 -07:00
Vadim Bendebury
927726e344 CHROMIUM: gpio: nm10: fix driver removal problem
The order of operations in the driver remove method is wrong, which
prevents the driver from de-installing.

BUG=none
TEST=manual

  . try 'rmmod nm10_gpio' and 'modprobe nm10_gpio' a few times in a
    row, check the dmesg output to see that the driver installs and
    removes cleanly

Change-Id: I7ab5161f224722f4f23fec97c99116184959a64e
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/19019
Reviewed-by: Olof Johansson <olofj@chromium.org>
Reviewed-by: Mandeep Singh Baines <msb@chromium.org>
2014-05-14 17:55:02 -07:00
Vadim Bendebury
195ea08336 Add Panther Point to the list of gpio controllers
The nm10 gpio driver is being modified to recognize the Panther Point
LPC device as one of valid GPIO controllers.

BUG=chrome-os-partner:8612
TEST=manual
 . build the new kernel
 . observe that the gpio driver gets installed:
    localhost ~ # dmesg | grep gpio
    [    7.020200] nm10_gpio version 0.04 built on Mar 22 2012 at 20:47:08
    [    7.020220] gpiochip_find_base: found new base at 160
 . enable the write protect GPIO (#57)
    localhost ~ # echo 217 > /sys/class/gpio/export
 . examine its value
    localhost ~ # cat /sys/class/gpio/gpio217/value
    0
 . short the pins and examine the value again
   localhost ~ # cat /sys/class/gpio/gpio217/value
   1
 . observe value change when the pins status changes

Change-Id: Idf354a64d5b964a37ee72b8e14fcedd3aab83654
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/18928
2014-05-14 17:54:59 -07:00
Sameer Nanda
bc886deab5 CHROMIUM: nm10_gpio: support up to 96 GPIOs
The Intel 6 Series chipset supports 96 GPIOs while NM10 supports 64.
Added support for 64 or 96 GPIOs based on device ID.

BUG=chrome-os-partner:5368
TEST=run crossystem and ensure that the current values of dev, recovery and
write protect switches are correctly reported.

Change-Id: I60f778117349766a82867db664765911e27bc9e2
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/7004
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2014-04-03 17:16:12 -07:00
Sameer Nanda
78e17d48e4 CHROMIUM: nm10_gpio: support additional LPC IDs
Adding more LPC device IDs of the Intel 6 Series and C200 Series
chipsets.

This has been tested and works on HM65 and HM67 variants.

BUG=none
TEST=run crossystem and ensure that the current values of recovery and
dev switches are correct

Change-Id: I895fca9bd5c23caeb2b4a3b06bbb20bc46d8691a
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/5682
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2014-04-03 17:16:10 -07:00
Sameer Nanda
533786a142 CHROMIUM: gpio: nm10_gpio: Add device ID of Intel HM65 chipset
The GPIO access mechanism on the HM65 PCH is the same a NM10. Simply
adding the device ID of HM65 to this driver instead of writing a new
driver that essentially does the same thing.

BUG=chrome-os-partner:4977
TEST=crossystem should report the correct values of recoverysw_cur and
devsw_cur with this driver in place,

Change-Id: I5bb0082b77dc4dec8739f9e24d92be485e3f28ae
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/4272
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Olof Johansson <olofj@chromium.org>
2014-04-03 17:16:10 -07:00
vbendeb
51e38fe318 CHROMIUM: gpio: nm10: Add ability to change gpio directions.
This CL adds nm10_gpio.c driver methods to allow changing of
GPIO pin directions. The driver code is being refactored to
separate common input parameters check.

Once the new methods are added, the gpiolib.c layer adss the
appropriate attribute (direction) to every enabled nm10 gpio
pin in /sys/class/gpio.

Writing "in" or "out" into the direction attribute sets the
pin's direction.

Change-Id: I4116542c7424dfb7f5c6fdc35930caf0a5d2e11b

BUG=chrome-os-partner:970 chromium-os:3612
TEST=see below

1. Install the new driver version on the system
2. Enable all GPIO pins
localhost tmp # i=0; while [ "$i" != "64" ] ; do gpio=$(expr $i \+ 192) ; i=$(expr $i \+ 1) ; echo $gpio > /sys/class/gpio/export ; done

2. define a shell function to display gpio pins' status:
gpiodump() {  i=0; while [ "$i" != "64" ]; do gpio=$(expr $i \+ 192) ;  i=$(expr $i \+ 1) ; cat /sys/class/gpio/gpio$gpio/value ; done | awk '{ if (i == 8) {print ""; i = 0;}  printf " %s", $1; i = i + 1}  END { print "" }' ; }

3. Set the recovery mode pin direction to output:
localhost tmp # echo out > /sys/class/gpio/gpio230/direction

4. Run gpiodump with the button pressed and released,
observe that there is no difference in the output.

5. Set the recovery mode pin direction to input:
localhost tmp # echo in > /sys/class/gpio/gpio230/direction

6. Run gpiodump with the button released and the pressed,
observe that there is difference in the output value of pin38:
localhost tmp # gpiodump
 0 0 0 0 0 1 1 0
 0 0 0 0 0 1 0 0
 0 0 0 0 0 0 0 0
 0 0 0 1 1 0 0 0
 0 1 0 0 0 0 1 0
 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0
localhost tmp # gpiodump
 0 0 0 0 0 1 1 0
 0 0 0 0 0 1 0 0
 0 0 0 0 0 0 0 0
 0 0 0 1 1 0 0 0
 0 1 0 0 0 0 0 0
 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0

Signed-off-by: Vadim Bendebury <vbendeb@google.com>

Review URL: http://codereview.chromium.org/3333016
2014-04-03 17:16:00 -07:00
Olof Johansson
ddfe3a5594 CHROMIUM: NM10 gpio driver
See the driver file header for implementation details.

Tested on an ST8 as follows
^^^^^^^^^^^^^^^^^^^^^^^^^^^

localhost ~ # cd /tmp
localhost tmp # scp <user@host>:<path>/nm10_gpio.ko .
localhost tmp # ls /sys/class/gpio/
export  unexport
localhost tmp # insmod nm10_gpio.ko
localhost tmp # ls /sys/class/gpio/
export  gpiochip192  unexport
localhost tmp # i=0; while [ "$i" != "64" ]
> do
> gpio=$(expr $i \+ 192)
>  i=$(expr $i \+ 1)
>  echo $gpio > /sys/class/gpio/export
> done
localhost tmp # ls /sys/class/gpio/
export   gpio195  gpio199  gpio203
gpio207  gpio211  gpio215  gpio219
gpio223  gpio227  gpio231  gpio235
gpio239  gpio243  gpio247  gpio251
gpio255  gpio192  gpio196  gpio200
gpio204  gpio208  gpio212  gpio216
gpio220  gpio224  gpio228  gpio232
gpio236  gpio240  gpio244  gpio248
gpio252  gpiochip192 gpio193  gpio197
gpio201  gpio205  gpio209  gpio213
gpio217  gpio221  gpio225  gpio229
gpio233  gpio237  gpio241  gpio245
gpio249  gpio253  unexport gpio194
gpio198  gpio202  gpio206  gpio210
gpio214  gpio218  gpio222  gpio226
gpio230  gpio234  gpio238  gpio242
gpio246  gpio250  gpio254
localhost tmp #
localhost tmp # gpiodump() {
> i=0; while [ "$i" != "64" ]
> do
>  gpio=$(expr $i \+ 192)
>  i=$(expr $i \+ 1)
>  cat /sys/class/gpio/gpio$gpio/value
> done | awk \
> '{ if (i == 8) {print ""; i = 0;} \
> printf " %s", $1; i = i + 1} \
> END { print "" }'
> }
localhost tmp # gpiodump
 1 1 0 1 0 1 1 0
 1 1 1 0 1 1 1 1
 0 0 0 0 0 0 1 0
 0 0 0 0 0 0 0 0
 0 1 1 0 1 0 1 1
 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0
localhost tmp # gpiodump
 1 1 0 1 0 1 0 0
 1 1 1 0 1 1 1 1
 0 0 0 0 0 0 1 0
 0 0 0 0 0 0 0 0
 0 1 1 0 1 0 1 1
 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0
localhost tmp #
localhost tmp # i=0; while [ "$i" != "64" ]
> do
> gpio=$(expr $i \+ 192)
>  i=$(expr $i \+ 1)
>  echo $gpio > /sys/class/gpio/unexport
> done
localhost tmp # ls /sys/class/gpio/
export  gpiochip192  unexport
localhost tmp # rmmod nm10_gpio.ko
localhost tmp # ls /sys/class/gpio/
export  unexport
localhost tmp # dmesg | tail -3
[ 5476.917362] nm10_gpio version 0.04 built on May 26 2010 at 14:37:58
[ 5476.917390] gpiochip_find_base: found new base at 192
[ 5995.995601] nm10_gpio base 192 removed
localhost tmp #

Review URL: http://codereview.chromium.org/2231003

Change-Id: I926059e092ca7a61701b8952a3c4029521736af3
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
[olof: build fix]
[sonnyrao: remove __devinit to fix build]
Signed-off-by: Olof Johansson <olof@lixom.net>
2014-04-03 17:15:58 -07:00
Axel Lin
90d16a43d5 gpio: tb10x: GPIO_TB10X needs to select GENERIC_IRQ_CHIP
gpio-tb10x driver uses generic irq chip APIs (irq_alloc_domain_generic_chips,
irq_remove_generic_chip), so it needs to select GENERIC_IRQ_CHIP to avoid build
error.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-02-05 11:13:59 +01:00
Axel Lin
21708c991e gpio: clps711x: Add module alias to support module auto loading
commit 55fe14ab87 "GPIO: clps711x: Rewrite driver for using generic GPIO code"
allows this driver to be built as a module.
Thus add module alias to support module auto loading.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-02-05 11:04:20 +01:00
Markus Mayer
6f587c9f7b gpio: bcm281xx: Update MODULE_AUTHOR
Add Broadcom's upstreaming mailing list address to MODULE_AUTHOR.

Signed-off-by: Markus Mayer <markus.mayer@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-02-05 10:59:18 +01:00
xinhui.pan
84a34575fe gpio: intel-mid: fix the incorrect return of idle callback
intel_gpio_runtime_idle should return correct error code if it do fail.
make it more correct even though -EBUSY is the most possible return value.

Signed-off-by: bo.he <bo.he@intel.com>
Signed-off-by: xinhui.pan <xinhuiX.pan@intel.com>
Signed-off-by: David Cohen <david.a.cohen@linux.intel.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-02-05 10:37:06 +01:00
Baruch Siach
cffcc92e96 gpio: xtensa: fix build when XCHAL_HAVE_CP is 0
In xtensa coprocessors may exist without coprocessor context, i.e. they cannot
be disabled/enabled. In this case the RSR_CPENABLE/WSR_CPENABLE are undefined,
thus breaking the build. Fix the build by adding dummy versions of
enable_cp/disable_cp in this case.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-02-03 09:11:45 +01:00
Linus Torvalds
0ba3307a8e Merge tag 'drivers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull ARM driver updates from Olof Johansson:
 "Updates of SoC-near drivers and other driver updates that makes more
  sense to take through our tree.

  The largest part of this is a conversion of device registration for
  some renesas shmobile/sh devices over to use resources.  This has
  required coordination with the corresponding arch/sh changes, and
  we've agreed to merge the arch/sh changes through our tree.

  Added in this branch is support for Trusted Foundations secure
  firmware, which is what is used on many of the commercial Nvidia Tegra
  products that are in the market, including the Nvidia Shield.  The
  code is local to arch/arm at this time since it's uncertain whether it
  will be shared with arm64 longer-term, if needed we will refactor
  later.

  A couple of new RTC drivers used on ARM boards, merged through our
  tree on request by the RTC maintainer.

  ... plus a bunch of smaller updates across the board, gpio conversions
  for davinci, etc"

* tag 'drivers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (45 commits)
  watchdog: davinci: rename platform driver to davinci-wdt
  tty: serial: Limit msm_serial_hs driver to platforms that use it
  mmc: msm_sdcc: Limit driver to platforms that use it
  usb: phy: msm: Move mach dependent code to platform data
  clk: versatile: fixup IM-PD1 clock implementation
  clk: versatile: pass a name to ICST clock provider
  ARM: integrator: pass parent IRQ to the SIC
  irqchip: versatile FPGA: support cascaded interrupts from DT
  gpio: davinci: don't create irq_domain in case of unbanked irqs
  gpio: davinci: use chained_irq_enter/chained_irq_exit API
  gpio: davinci: add OF support
  gpio: davinci: remove unused variable intc_irq_num
  gpio: davinci: convert to use irqdomain support.
  gpio: introduce GPIO_DAVINCI kconfig option
  gpio: davinci: get rid of DAVINCI_N_GPIO
  gpio: davinci: use {readl|writel}_relaxed() instead of __raw_*
  serial: sh-sci: Add OF support
  serial: sh-sci: Add device tree bindings documentation
  serial: sh-sci: Remove platform data mapbase and irqs fields
  serial: sh-sci: Remove platform data scbrr_algo_id field
  ...
2014-01-23 18:49:36 -08:00
Linus Torvalds
ac26663572 Merge tag 'mfd-3.14-1' of git://git.linaro.org/people/ljones/mfd
Pull MFD changes from Lee Jones:
 "New drivers
   - Samsung Maxim 14577; Micro USB, Regulator, IRQ Controller and
     Battery Charger
   - TI/National Semiconductor LP3943 I2C GPIO Expander and PWM
     Generator

  Existing driver adaptions
   - Expansion of Wolfson Arizona DSP and High-Pass filter controls
   - TI TWL6040 default Regmap support and Regcache addition/bypass
   - Some nice Smatch catch fixes
   - Conversion of TI OMAP-USB and TI TWL6030 to endian neutralness
   - ChromeOS EC timing (delay) adaptions and added dependency on OF
   - Many constifications of 'struct {mfd_cell,regmap_irq,et.al}'
   - Watchdog support added for NVIDIA AS3722
   - Convert functions to static in TI AM335x
   - Realigned previously defeated functionality in TI AM335x
   - IIO ADC-TSC concurrency dead-lock/timeout resolution
   - Addition of Power Management and Clock support for Samsung core
   - DEFINE_PCI_DEVICE_TABLE macro removal from MFD Subsystem
   - Greater use of irqdomain functionality in ST-E AB8500
   - Removal of 'include/linux/mfd/abx500/ab8500-gpio.h'
   - Wolfson WM831x PMIC Power Management changes s/poweroff/shutdown/
   - Device Tree documentation added for TI/Nat Semi LP3943
   - Version detection and voltage tables for TI TPS6586x PMIC devices
   - Simplification of Freescale MC13XXX (de-)initialisation routines
   - Clean-up and simplification of the Realtek parent driver
   - Added support for RTL8402 Realtek PCI-Express card reader
   - Resource leak fix for Maxim 77686
   - Possible suspend BUG() fix in OMAP USB TLL
   - Support for new Wolfson WM5110 Revision (D)
   - Testing of automatic assignment of of_node in mfd_add_device()
   - Reversion of the above when it started to cause issues
   - Remove legacy Platform Data from;
              TI TWL Core, Qualcomm SSBI and ST-E ABx500 Pinctrl
   - Clean-ups; tabbing issues, function name changes, 'drvdata = NULL'
              removal, unused uninitialised warning mitigation, error
              message clarity, removal of redundant/duplicate checks,
              licensing (GPL -> GPL2), coding consistency, duplicate
              function declaration, ret checks, commit corrections,
              redundant of_match_ptr() helper removal, spelling,
              #if-deffery removal and header guards name changes"

* tag 'mfd-3.14-1' of git://git.linaro.org/people/ljones/mfd: (78 commits)
  mfd: wm5110: Add register patch for rev D chip
  mfd: omap-usb-tll: Don't hold lock during pm_runtime_get/put_sync()
  gpio: lp3943: Remove redundant of_match_ptr helper
  mfd: sta2x11-mfd: Use named constants for pci_power_t values
  Documentation: mfd: Fix LDO index in s2mps11.txt
  mfd: Cleanup mfd-mcp-sa11x0.h header
  mfd: max8997: Use "IS_ENABLED(CONFIG_OF)" for DT code.
  mfd: twl6030: Fix endianness problem in IRQ handler
  mfd: sec-core: Add cells for S5M8767-clocks
  mfd: max14577: Remove redundant of_match_ptr helper
  mfd: twl6040: Fix sparse non static symbol warning
  mfd: Revert "mfd: Always assign of_node in mfd_add_device()"
  mfd: rtsx: Fix sparse non static symbol warning
  mfd: max77693: Set proper maximum register for MUIC regmap
  mfd: max77686: Fix regmap resource leak on driver remove
  mfd: Represent correct filenames in file headers
  mfd: rtsx: Add support for card reader rtl8402
  mfd: rtsx: Add set pull control macro and simplify rtl8411
  mfd: max8997: Enforce mfd_add_devices() return value check
  mfd: mc13xxx: Simplify probe() & remove()
  ...
2014-01-21 10:58:17 -08:00
Linus Torvalds
8e50966072 Merge tag 'gpio-v3.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO tree bulk changes from Linus Walleij:
 "A big set this merge window, as we have much going on in this
  subsystem.  The changes to other subsystems (notably a slew of ARM
  machines as I am doing away with their custom APIs) have all been
  ACKed to the extent possible.

  Major changes this time:

   - Some core improvements and cleanups to the new GPIO descriptor API.
     This seems to be working now so we can start the exodus to this
     API, moving gradually away from the global GPIO numberspace.

   - Incremental improvements to the ACPI GPIO core, and move the few
     GPIO ACPI clients we have to the GPIO descriptor API right *now*
     before we go any further.  We actually managed to contain this
     *before* we started to litter the kernel with yet another hackish
     global numberspace for the ACPI GPIOs, which is a big win.

   - The RFkill GPIO driver and all platforms using it have been
     migrated to use the GPIO descriptors rather than fixed number
     assignments.  Tegra machine has been migrated as part of this.

   - New drivers for MOXA ART, Xtensa GPIO32 and SMSC SCH311x.  Those
     should be really good examples of how I expect a nice GPIO driver
     to look these days.

   - Do away with custom GPIO implementations on a major part of the ARM
     machines: ks8695, lpc32xx, mv78xx0.  Make a first step towards the
     same in the horribly convoluted Samsung S3C include forest.  We
     expect to continue to clean this up as we move forward.

   - Flag GPIO lines used for IRQ on adnp, bcm-kona, em, intel-mid and
     lynxpoint.

     This makes the GPIOlib core aware that a certain GPIO line is used
     for IRQs and can then enforce some semantics such as disallowing a
     GPIO line marked as in use for IRQ to be switched to output mode.

   - Drop all use of irq_set_chip_and_handler_name().  The name provided
     in these cases were just unhelpful tags like "mux" or "demux".

   - Extend the MCP23s08 driver to handle interrupts.

   - Minor incremental improvements for rcar, lynxpoint, em 74x164 and
     msm drivers.

   - Some non-urgent bug fixes here and there, duplicate #includes and
     that usual kind of cleanups"

Fix up broken Kconfig file manually to make this all compile.

* tag 'gpio-v3.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (71 commits)
  gpio: mcp23s08: fix casting caused build warning
  gpio: mcp23s08: depend on OF_GPIO
  gpio: mcp23s08: Add irq functionality for i2c chips
  ARM: S5P[v210|c100|64x0]: Fix build error
  gpio: pxa: clamp gpio get value to [0,1]
  ARM: s3c24xx: explicit dependency on <plat/gpio-cfg.h>
  ARM: S3C[24|64]xx: move includes back under <mach/> scope
  Documentation / ACPI: update to GPIO descriptor API
  gpio / ACPI: get rid of acpi_gpio.h
  gpio / ACPI: register to ACPI events automatically
  mmc: sdhci-acpi: convert to use GPIO descriptor API
  ARM: s3c24xx: fix build error
  gpio: f7188x: set can_sleep attribute
  gpio: samsung: Update documentation
  gpio: samsung: Remove hardware.h inclusion
  gpio: xtensa: depend on HAVE_XTENSA_GPIO32
  gpio: clps711x: Enable driver compilation with COMPILE_TEST
  gpio: clps711x: Use of_match_ptr()
  net: rfkill: gpio: convert to descriptor-based GPIO interface
  leds: s3c24xx: Fix build failure
  ...
2014-01-21 10:09:12 -08:00
Sachin Kamat
3b1ba0cbcc gpio: lp3943: Remove redundant of_match_ptr helper
'lp3943_gpio_of_match' is always compiled in. Hence the
helper macro is not needed.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-01-21 08:29:00 +00:00
Milo Kim
0cc59b9d98 gpio: add LP3943 I2C GPIO expander driver
This is one of LP3943 MFD driver.
LP3943 is configurable as a GPIO expander, up to 16 GPIOs.

* Application note: how to configure LP3943 as a GPIO expander
  http://www.ti.com/lit/an/snva287a/snva287a.pdf

* Supported GPIO controller operations
  request, free, direction_input, direction_output, get and set

* GPIO direction register not supported
  LP3943 doesn't have the GPIO direction register. It only provides input and
  output status registers.
  So, private data for the direction should be handled manually.
  This variable is updated whenever the direction is changed and
  used in 'get' operation.

* Pin assignment
  A driver data, 'pin_used' is checked when a GPIO is requested.
  If the GPIO is already assigned, then returns as failure.
  If the GPIO is available, 'pin_used' is set.
  When the GPIO is not used anymore, then it is cleared.
  It is defined as unsigned long type for atomic bit operation APIs,
  but only LSB 16bits are used because LP3943 has 16 outputs.

Signed-off-by: Milo Kim <milo.kim@ti.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-01-21 08:27:57 +00:00
SeongJae Park
de755c3305 gpio: mcp23s08: fix casting caused build warning
Signed-off-by: SeongJae Park <sj38.park@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-01-20 09:10:03 +01:00
Linus Walleij
01d7004181 gpio: mcp23s08: depend on OF_GPIO
The MCP drivers fails to compile on trial builds due to missing
Kconfig dependency on OF_GPIO. Fix it.

Cc: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-01-20 09:07:34 +01:00
Lars Poeschel
4e47f91bf7 gpio: mcp23s08: Add irq functionality for i2c chips
This adds interrupt functionality for i2c chips to the driver.
They can act as a interrupt-controller and generate interrupts, if
the inputs change.
This is tested with a mcp23017 chip on an arm based platform.

v3:
- be a bit more clear that the irq functionality is also available
  on spi versions of the chips, but the linux driver does not support
  this yet

v2:
- some more word about irq-mirror property in binding doc
- use of_read_bool instead of of_find_property for
  "interrupt-contrller" and "irq-mirror"
- cache the "interrupt-controller" for remove function
- do set the irq-mirror bit only if device is marked as
  interrupt-controller
- do create the irq mapping and setup of irq_desc of all possible
  interrupts in probe path instead of in gpio_to_irq
- mark gpios as in use as interrupts in irq in irq_startup and
  unlock it in irq_shutdown
- rename virq to child_irq
- remove dev argument from mcp23s08_irq_setup function
- move gpiochip_add before mcp23s08_irq_setup in probe path

Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-01-17 15:30:14 +01:00
Sachin Kamat
785acec3ee ARM: S5P[v210|c100|64x0]: Fix build error
gpio-samsung.h header file introduced by commit 93177be0910c
("ARM: S3C[24|64]xx: move includes back under <mach/> scope")
is required only by S3C[24|64]xx machines. Include them conditionally
to avoid the following build errors for other machine configurations.
drivers/gpio/gpio-samsung.c:35:31: fatal error: mach/gpio-samsung.h: No such file or directory
arch/arm/plat-samsung/pm-gpio.c:22:31: fatal error: mach/gpio-samsung.h: No such file or directory

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2014-01-15 13:48:06 +01:00