Enable CONFIG_DYNAMIC_DEBUG

Signed-off-by: Shahar Levi <shahar_levi@ti.com>
Enable asynchronous interrupt throughout

To keep Interrupt enabled outside transaction.

Signed-off-by: Sourav Poddar <sourav.poddar@ti.com>
Signed-off-by: Eliad Peller <eliad@wizery.com>
Enable Asynchronous Int featute for SDIO host

Enble the use of SDIO card interrupts.

FCLK must be enabled while SDIO interrupts are enabled or the MMC
module won't wake-up (even though ENAWAKEUP in SYSCONFIG and IWE in
HTCL have been set).  Enabling the MMC module to wake-up would require
configuring the MMC module (and the mmci_dat[1] GPIO when the CORE
power domain is OFF) as wake-up sources in the PRCM.

Conditional check is also used to set registers for
inabnd interrupt differently.

Signed-off-by: Sourav Poddar <sourav.poddar@ti.com>
[Eliad: Fix omap_hsmmc_enable_sdio_irq prototype]
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Ido Reis <idor@ti.com>
Support to keep cards always on

To keep cards always ON and to make mmc_release_host
call only once.

Signed-off-by: Sourav Poddar <sourav.poddar@ti.com>
Signed-off-by: Eliad Peller <eliad@wizery.com>
add MMC_CAP_ASYNC_SDIO_IRQ

additionaly, move MMC_CAP_SDIO_IRQ support declaration to board file,
rather than the generic omap_hsmmc.

Signed-off-by: Eliad Peller <eliad@wizery.com>
support SDIO Interrupt Extensions

Check for Support Asynchronous Interrupt (SAI), and
enable set Enable Asynchrounous Interrupt (EAI) if supported.

Signed-off-by: Eliad Peller <eliad@wizery.com>
Write to Interrupt Signal Enable (ISE) as well

We want the Card Interrupt to trigger an irq (in addition
to setting the correct CIRQ bit in the status register)

Signed-off-by: Eliad Peller <eliad@wizery.com>
omap_hsmmc: Handle async inband interrupts between requests

omap_hsmmc_do_irq rejects any interrupts if a request is not in
progress. This includes asynchronous inband interrupts which are valid
in this case.

Fix this by handling CIRQ events before clearing any potential spurious
interrupts.

Signed-off-by: Eliad Peller <eliad@wizery.com>
omap_hsmmc: Handle sdio interrupts when clocks are disabled *PRELIMINARY*

When the mmc host disables its internal clocks, it can no longer detect
sdio interrupts on dat1. To continue being able to serve such interrupts,
dat1 should be remuxed to the relevant gpio and handled as an irq source.

The interrupt handler should be run in process context, as enable_sdio_irq
might sleep. Thus, a threaded irq is used for this purpose.

Signed-off-by: Ido Yariv <ido@wizery.com>
Signed-off-by: Eliad Peller <eliad@wizery.com>
board-4430: Add support for mmc5/dat1 irq source *PRELIMINARY*

Set dat1_gpio and implement a remuxing function for using mmc5/dat1 as an
irq source by omap_hsmmc

Signed-off-by: Ido Yariv <ido@wizery.com>
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Ido Reis <idor@ti.com>
board-4430: set mmc/dat1 wakeup enable

Signed-off-by: Eliad Peller <eliad@wizery.com>
sdio: add sdio_enable_irq/sdio_disable_irq functions

In some cases, we'd like to disable the irq, without stopping
the handler thread, as this is our own context (i.e. doing
something similar to disable_irq_nosync).

Add sdio_enable_irq/sdio_disable_irq functions, that only
configure the irq, without touching the handler.

Signed-off-by: Eliad Peller <eliad@wizery.com>
sync include/linux/wl12xx.h

Needed in order to update the platform data struct

Signed-off-by: Eliad Peller <eliad@wizery.com>
mmc: Toggle power while host is claimed

Runtime PM ops might be called when the host isn't claimed. This can be
problematic, as the mmc disable/enable callbacks might be called
concurrently.

Fix this by claiming the host before calling mmc_power_*_host. Since
it's perfectly fine to claim a host more than once by the same task, it
should be safe to do even if the runtime PM functions are called with
the host claimed.

Signed-off-by: Ido Yariv <ido@wizery.com>
Signed-off-by: Ido Reis <idor@ti.com>
Signed-off-by: Eliad Peller <eliad@wizery.com>
sdio: Add support for lock-less interrupt handlers *EXPERIMENTAL*

SDIO interrupt handlers are called with the host being claimed. Some
drivers may normally claim the host after acquiring a different lock.
This means that the interrupt handler may not acquire this lock, as the
locking order will be incorrect.

Add support for lock-less interrupt handlers, which will be called
without the host being claimed.

Signed-off-by: Ido Reis <idor@ti.com>
Signed-off-by: Eliad Peller <eliad@wizery.com>
sdio: Add lock-less handlers host claiming function *EXPERIMENTAL*

Lock-less handlers which are called without the host being claimed
probably need to claim the host by themselves. In order to avoid a
race with sdio_release_irq, add support for claiming the host and
aborting the claim when the sdio irq is freed.

Signed-off-by: Eliad Peller <eliad@wizery.com>
PM: fix might_sleep_if in __pm_runtime_idle

commit b1d0d5f ("PM: runtime: add might_sleep to PM runtime functions")
added might_sleep_if() checks for __pm_runtime_* functions. But while
__pm_runtime_suspend/resume checked dev->power.irq_safe (which allows
using these functions in atomic context), __pm_runtime_idle missed
that check.

[Note that this bug doesn't exist in the upstreamed commit (311aab7
"PM / Runtime: Add might_sleep() to runtime PM functions")]

Signed-off-by: Eliad Peller <eliad@wizery.com>
mmc: omap_hsmmc: set pm_runtime_irq_safe

Declare the pm runtime handlers as safe to run
in atomic context (it's in fact being called
from mmc_signal_sdio_irq() in irq context)

Signed-off-by: Eliad Peller <eliad@wizery.com>
add CIRQ_ENABLE to irq_mask if IBI is supported

Signed-off-by: Eliad Peller <eliad@wizery.com>
mmc: omap_hsmmc: Avoid spurious interrupts in dat1 handler

*** HACK ***

For some reason, probably because we request/free the interrupt handler each
time, we sometimes get spurious interrupts.
Some SDIO devices may enter low power mode. In this case, it might not be
possible to read the pending interrupts register, as the SDIO layer might not
be fully operational.
Check the gpio line before actually handling the interrupt.

TODO:
- Find out the root cause for the spruious interrupts
- Consider enabling/disabling the interrupt handler instead of
  requesting/freeing. This should be done regardless of this specific problem.

Signed-off-by: Ido Yariv <ido@wizery.com>