Re: [PATCH v6 1/3] mmc: omap_hsmmc: Enable SDIO IRQ.

2013-12-20 Thread Tony Lindgren
* Andreas Fenkart  [131216 03:29]:
> For now, only support SDIO interrupt if we are booted with
> DT. This is because some platforms need special quirks. And
> we don't want to add new legacy mux platform init code
> callbacks any longer as we are moving to DT based booting
> anyways.
> 
> Signed-off-by: Andreas Fenkart 

Acked-by: Tony Lindgren 
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 1/3] mmc: omap_hsmmc: Enable SDIO IRQ.

2013-12-16 Thread Andreas Fenkart
For now, only support SDIO interrupt if we are booted with
DT. This is because some platforms need special quirks. And
we don't want to add new legacy mux platform init code
callbacks any longer as we are moving to DT based booting
anyways.

Signed-off-by: Andreas Fenkart 
---
 drivers/mmc/host/omap_hsmmc.c  |  109 
 include/linux/platform_data/mmc-omap.h |1 +
 2 files changed, 97 insertions(+), 13 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 8be5c9f..c197028 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -131,6 +131,7 @@ static void apply_clk_hack(struct device *dev)
 #define TC_EN  (1 << 1)
 #define BWR_EN (1 << 4)
 #define BRR_EN (1 << 5)
+#define CIRQ_EN(1 << 8)
 #define ERR_EN (1 << 15)
 #define CTO_EN (1 << 16)
 #define CCRC_EN(1 << 17)
@@ -215,6 +216,9 @@ struct omap_hsmmc_host {
int reqs_blocked;
int use_reg;
int req_in_progress;
+   int flags;
+#define HSMMC_SDIO_IRQ_ENABLED (1 << 0)/* SDIO irq enabled */
+
struct omap_hsmmc_next  next_data;
struct  omap_mmc_platform_data  *pdata;
 };
@@ -495,27 +499,40 @@ static void omap_hsmmc_stop_clock(struct omap_hsmmc_host 
*host)
 static void omap_hsmmc_enable_irq(struct omap_hsmmc_host *host,
  struct mmc_command *cmd)
 {
-   unsigned int irq_mask;
+   u32 irq_mask = INT_EN_MASK;
+   unsigned long flags;
 
if (host->use_dma)
-   irq_mask = INT_EN_MASK & ~(BRR_EN | BWR_EN);
-   else
-   irq_mask = INT_EN_MASK;
+   irq_mask &= ~(BRR_EN | BWR_EN);
 
/* Disable timeout for erases */
if (cmd->opcode == MMC_ERASE)
irq_mask &= ~DTO_EN;
 
+   spin_lock_irqsave(&host->irq_lock, flags);
OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
OMAP_HSMMC_WRITE(host->base, ISE, irq_mask);
+
+   /* latch pending CIRQ, but don't signal */
+   if (host->flags & HSMMC_SDIO_IRQ_ENABLED)
+   irq_mask |= CIRQ_EN;
OMAP_HSMMC_WRITE(host->base, IE, irq_mask);
+   spin_unlock_irqrestore(&host->irq_lock, flags);
 }
 
 static void omap_hsmmc_disable_irq(struct omap_hsmmc_host *host)
 {
-   OMAP_HSMMC_WRITE(host->base, ISE, 0);
-   OMAP_HSMMC_WRITE(host->base, IE, 0);
+   u32 irq_mask = 0;
+   unsigned long flags;
+
+   spin_lock_irqsave(&host->irq_lock, flags);
+   /* no transfer running, need to signal cirq if enabled */
+   if (host->flags & HSMMC_SDIO_IRQ_ENABLED)
+   irq_mask |= CIRQ_EN;
+   OMAP_HSMMC_WRITE(host->base, ISE, irq_mask);
+   OMAP_HSMMC_WRITE(host->base, IE, irq_mask);
OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
+   spin_unlock_irqrestore(&host->irq_lock, flags);
 }
 
 /* Calculate divisor for the given clock frequency */
@@ -1078,8 +1095,12 @@ static irqreturn_t omap_hsmmc_irq(int irq, void *dev_id)
int status;
 
status = OMAP_HSMMC_READ(host->base, STAT);
-   while (status & INT_EN_MASK && host->req_in_progress) {
-   omap_hsmmc_do_irq(host, status);
+   while (status & (INT_EN_MASK | CIRQ_EN)) {
+   if (host->req_in_progress)
+   omap_hsmmc_do_irq(host, status);
+
+   if (status & CIRQ_EN)
+   mmc_signal_sdio_irq(host->mmc);
 
/* Flush posted write */
status = OMAP_HSMMC_READ(host->base, STAT);
@@ -1591,6 +1612,37 @@ static void omap_hsmmc_init_card(struct mmc_host *mmc, 
struct mmc_card *card)
mmc_slot(host).init_card(card);
 }
 
+static void omap_hsmmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
+{
+   struct omap_hsmmc_host *host = mmc_priv(mmc);
+   u32 irq_mask;
+   unsigned long flags;
+
+   spin_lock_irqsave(&host->irq_lock, flags);
+
+   irq_mask = OMAP_HSMMC_READ(host->base, ISE);
+   if (enable) {
+   host->flags |= HSMMC_SDIO_IRQ_ENABLED;
+   irq_mask |= CIRQ_EN;
+   } else {
+   host->flags &= ~HSMMC_SDIO_IRQ_ENABLED;
+   irq_mask &= ~CIRQ_EN;
+   }
+   OMAP_HSMMC_WRITE(host->base, IE, irq_mask);
+
+   /*
+* if enable, piggy back detection on current request
+* but always disable immediately
+*/
+   if (!host->req_in_progress || !enable)
+   OMAP_HSMMC_WRITE(host->base, ISE, irq_mask);
+
+   /* flush posted write */
+   OMAP_HSMMC_READ(host->base, IE);
+
+   spin_unlock_irqrestore(&host->irq_lock, flags);
+}
+
 static void omap_hsmmc_conf_bus_power(struct omap_hsmmc_host *host)
 {
u32 hctl, capa, value;
@@ -1643,7 +1695,7 @@ static const struct