Re: [PATCH 0/2] mmc: omap_hsmmc: support SDIO cards (#2)

2010-10-06 Thread David Vrabel
Madhusudhan Chikkature wrote:
> 
> This version should apply fine on the latest kernel. I did a sanity test of
> MMC/SD cards on OMAP4 SDP.

This /looks/ okay to me, but I can't test it.

> From 08b77fd388f19f5df3758a2c59dcdec280f373c8 Mon Sep 17 00:00:00 2001
> From: David Vrabel 
> Date: Wed, 6 Oct 2010 12:39:18 -0500
> Subject: [PATCH 1/2] mmc: omap_hsmmc: enable SDIO card interrupts
> 
[...]
> 
> The writes to STAT and ISE when starting a command are unnecessary and
> have been removed.

Remove this last paragraph from the description as it isn't applicable
any more.

David
-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ http://www.csr.com/


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number 4187346, registered office Churchill House, Cambridge 
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
--
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


Re: [PATCH 0/2] mmc: omap_hsmmc: support SDIO cards (#2)

2010-08-31 Thread David Vrabel
On 27/08/2010 20:22, Chris Ball wrote:
> Hi David,
> 
> On Mon, Feb 22, 2010 at 02:24:17PM +0000, David Vrabel wrote:
>> These patches add support for SDIO cards to the omap_hsmmc driver.
>> Power management changes to prevent SDIO cards from being turned off
>> and losing all state, and card interrupts.
>>
>> I've been unable to test these exact patches as I only have an N900 for 
>> testing and the N900 support in mainline is incomplete.
>>
>> Changes since v1:
>> - (hopefully) get all cards working again by removing a second call to
>>   read MMCi_STAT in the interrupt handler.
>> - flush posted writes after enabling/disabling SDIO interrupts.
>> - tweak the FIXME commit on disabling FCLK to better match what really
>>   going on (at least I think so anyway).
>>
>> David Vrabel (2):
>>   mmc: omap_hsmmc: don't turn SDIO cards off when idle
>>   mmc: omap_hsmmc: enable SDIO card interrupts
> 
> Looks like this patchset wasn't merged.  Mike Rapoport replied with a 
> fix for libertas.  Would you like to resubmit it?

I thought Madhu had picked this up and was going to submit it.

Regardless of whether that is the case, I think it needs to be submitted
by someone who can run mainline kernels (I can't) and ideally someone
who can test it with SDIO cards.

David
--
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


Re: [PATCH] musb: Add workqueue for URB giveback

2010-02-26 Thread David Vrabel
Ajay Kumar Gupta wrote:
> Current musb host driver does the giveback of completed urb first and
> then start the next request. This is significantly affecting the streaming
> from an USB camera wherein we observe huge delay between the two IN tokens
> from musb host. This is due to the fact that UVC driver is doing decoding
> and further processing in giveback context.
> 
> The patch tries to defer the giveback part to a workqueue and continues
> with the start of new request in completion path.

Suggest allocating a per-urb structure when a new URB is enqueued.  This
structure contains the completion/giveback work item.  This avoids
having to a) allocate memory on completion; b) create a second queue
structure.

David
-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ http://www.csr.com/


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number 4187346, registered office Churchill House, Cambridge 
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
--
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


Re: [PATCH 0/2] mmc: omap_hsmmc: support SDIO cards (#2)

2010-02-22 Thread David Vrabel
Felipe Contreras wrote:
> On Mon, Feb 22, 2010 at 4:24 PM, David Vrabel  wrote:
>> These patches add support for SDIO cards to the omap_hsmmc driver.
>> Power management changes to prevent SDIO cards from being turned off
>> and losing all state, and card interrupts.
>>
>> I've been unable to test these exact patches as I only have an N900 for
>> testing and the N900 support in mainline is incomplete.
> 
> Can't you get the source code with 'apt-get source' in Maemo SDK? It's
> a tarball but at least it's something.

I have SDIO cards tested and working on the N900 with the Fremantle
kernel but that's a modified 2.6.28 kernel.  These patches are for
mainline and there are differences between mainline and the fremantle
kernel that means they need different patches.

David
-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ http://www.csr.com/


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number 4187346, registered office Churchill House, Cambridge 
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
--
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


Re: [PATCH 3/3] mmc: omap_hsmmc: enable SDIO card interrupts

2010-02-22 Thread David Vrabel
Madhusudhan wrote:
> 
> A little bit of rearranging the David's changes to the irq handler gets the
> MMC/SD cards to work fine again. Changes are shown in the attached patch for
> now and it should not hurt the CIRQ handling as well. 

This breaks detecting card interrupts unless a command is in progress.

>>> +   status = OMAP_HSMMC_READ(host->base, STAT);
>>> +   OMAP_HSMMC_WRITE(host->base, STAT, status);
>>> +   OMAP_HSMMC_READ(host->base, STAT); /* Flush posted write. */
>>> +
>>> +   if (status & CIRQ)
>>> +   card_irq = true;
>>> +
>>> +   if (host->mrq == NULL)
>>> +   goto out;
>>>
>>> data = host->data;
>>> status = OMAP_HSMMC_READ(host->base, STAT);

This line is the real problem.  We re-read MMCi_STAT after acknowledging
 (clearing) it.

Please see the version #2 of the patchset.

David
-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ http://www.csr.com/


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number 4187346, registered office Churchill House, Cambridge 
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
--
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 2/2] mmc: omap_hsmmc: enable SDIO card interrupts

2010-02-22 Thread David Vrabel
Enable 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.

The writes to STAT and ISE when starting a command are unnecessary and
have been removed.

Signed-off-by: David Vrabel 
---
 drivers/mmc/host/omap_hsmmc.c |  102 
 1 files changed, 71 insertions(+), 31 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 323a0e8..278b551 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -64,6 +64,7 @@
 #define SDVS_MASK  0x0E00
 #define SDVSCLR0xF1FF
 #define SDVSDET0x0400
+#define ENAWAKEUP  (1 << 2)
 #define AUTOIDLE   0x1
 #define SDBP   (1 << 8)
 #define DTO0xe
@@ -74,9 +75,11 @@
 #define CLKD_SHIFT 6
 #define DTO_MASK   0x000F
 #define DTO_SHIFT  16
+#define CIRQ_ENABLE(1 << 8)
 #define INT_EN_MASK0x307F0033
 #define BWR_ENABLE (1 << 4)
 #define BRR_ENABLE (1 << 5)
+#define CTPL   (1 << 11)
 #define INIT_STREAM(1 << 1)
 #define DP_SELECT  (1 << 21)
 #define DDIR   (1 << 4)
@@ -84,10 +87,12 @@
 #define MSBS   (1 << 5)
 #define BCE(1 << 1)
 #define FOUR_BIT   (1 << 1)
+#define IWE(1 << 24)
 #define DW8(1 << 5)
 #define CC 0x1
 #define TC 0x02
 #define OD 0x1
+#define CIRQ   (1 << 8)
 #define ERR(1 << 15)
 #define CMD_TIMEOUT(1 << 16)
 #define DATA_TIMEOUT   (1 << 20)
@@ -227,7 +232,7 @@ static int omap_hsmmc_context_restore(struct 
omap_hsmmc_host *host)
;
 
OMAP_HSMMC_WRITE(host->base, SYSCONFIG,
-   OMAP_HSMMC_READ(host->base, SYSCONFIG) | AUTOIDLE);
+   OMAP_HSMMC_READ(host->base, SYSCONFIG) | AUTOIDLE | 
ENAWAKEUP);
 
if (host->id == OMAP_MMC1_DEVID) {
if (host->power_mode != MMC_POWER_OFF &&
@@ -242,7 +247,7 @@ static int omap_hsmmc_context_restore(struct 
omap_hsmmc_host *host)
}
 
OMAP_HSMMC_WRITE(host->base, HCTL,
-   OMAP_HSMMC_READ(host->base, HCTL) | hctl);
+   OMAP_HSMMC_READ(host->base, HCTL) | hctl | IWE);
 
OMAP_HSMMC_WRITE(host->base, CAPA,
OMAP_HSMMC_READ(host->base, CAPA) | capa);
@@ -256,7 +261,7 @@ static int omap_hsmmc_context_restore(struct 
omap_hsmmc_host *host)
;
 
OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
-   OMAP_HSMMC_WRITE(host->base, ISE, INT_EN_MASK);
+   OMAP_HSMMC_WRITE(host->base, ISE, INT_EN_MASK | CIRQ);
OMAP_HSMMC_WRITE(host->base, IE, INT_EN_MASK);
 
/* Do not initialize card-specific things if the power is off */
@@ -425,12 +430,6 @@ omap_hsmmc_start_command(struct omap_hsmmc_host *host, 
struct mmc_command *cmd,
mmc_hostname(host->mmc), cmd->opcode, cmd->arg);
host->cmd = cmd;
 
-   /*
-* Clear status bits and enable interrupts
-*/
-   OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
-   OMAP_HSMMC_WRITE(host->base, ISE, INT_EN_MASK);
-
if (host->use_dma)
OMAP_HSMMC_WRITE(host->base, IE,
 INT_EN_MASK & ~(BRR_ENABLE | BWR_ENABLE));
@@ -637,23 +636,26 @@ static irqreturn_t omap_hsmmc_irq(int irq, void *dev_id)
 {
struct omap_hsmmc_host *host = dev_id;
struct mmc_data *data;
-   int end_cmd = 0, end_trans = 0, status;
+   u32 status;
+   int end_cmd = 0, end_trans = 0;
+   bool card_irq = false;
 
spin_lock(&host->irq_lock);
 
-   if (host->mrq == NULL) {
-   OMAP_HSMMC_WRITE(host->base, STAT,
-   OMAP_HSMMC_READ(host->base, STAT));
-   /* Flush posted write */
-   OMAP_HSMMC_READ(host->base, STAT);
-   spin_unlock(&host->irq_lock);
-   return IRQ_HANDLED;
-   }
-
-   data = host->data;
status = OMAP_HSMMC_READ(host->base, STAT);
+   OMAP_HSMMC_WRITE(host->base, STAT, status);
+   OMAP_HSMMC_READ(host->base, STAT); /* Flush posted write. */
+
dev_dbg(mmc_dev(host->mmc), &qu

[PATCH 1/2] mmc: omap_hsmmc: don't turn SDIO cards off when idle

2010-02-22 Thread David Vrabel
Don't turn SDIO cards off to save power.  Doing so will lose all
internal state in the card.

Signed-off-by: David Vrabel 
---
 drivers/mmc/host/omap_hsmmc.c |   12 
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 4b23225..323a0e8 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1366,8 +1367,12 @@ static int omap_hsmmc_sleep_to_off(struct 
omap_hsmmc_host *host)
  mmc_slot(host).card_detect ||
  (mmc_slot(host).get_cover_state &&
   mmc_slot(host).get_cover_state(host->dev, host->slot_id {
-   mmc_release_host(host->mmc);
-   return 0;
+   goto out;
+   }
+
+   /* Don't turn SDIO cards off. */
+   if (host->mmc->card && mmc_card_sdio(host->mmc->card)) {
+   goto out;
}
 
mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
@@ -1378,9 +1383,8 @@ static int omap_hsmmc_sleep_to_off(struct omap_hsmmc_host 
*host)
host->dpm_state == CARDSLEEP ? "CARDSLEEP" : "REGSLEEP");
 
host->dpm_state = OFF;
-
+out:
mmc_release_host(host->mmc);
-
return 0;
 }
 
-- 
1.6.3.3

--
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 0/2] mmc: omap_hsmmc: support SDIO cards (#2)

2010-02-22 Thread David Vrabel
These patches add support for SDIO cards to the omap_hsmmc driver.
Power management changes to prevent SDIO cards from being turned off
and losing all state, and card interrupts.

I've been unable to test these exact patches as I only have an N900 for 
testing and the N900 support in mainline is incomplete.

Changes since v1:
- (hopefully) get all cards working again by removing a second call to
  read MMCi_STAT in the interrupt handler.
- flush posted writes after enabling/disabling SDIO interrupts.
- tweak the FIXME commit on disabling FCLK to better match what really
  going on (at least I think so anyway).

David Vrabel (2):
  mmc: omap_hsmmc: don't turn SDIO cards off when idle
  mmc: omap_hsmmc: enable SDIO card interrupts

 drivers/mmc/host/omap_hsmmc.c |  114 -
 1 files changed, 79 insertions(+), 35 deletions(-)

--
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


Re: [PATCH 0/3] mmc: omap_hsmmc: support SDIO cards

2010-02-18 Thread David Vrabel
Mike Rapoport wrote:
> 
> Reverting this hunk and reverting/adjusting changes to IRQ handler makes
> SD card recognizable again. No luck with SDIO interrupts though...

Your card might need CLKEXTFREE enabled in MMCHSi_CON if it cannot
generate card interrupts asynchronously.  If that doesn't help you'll
have to see if one of the TI people has any suggestions.

David
-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ http://www.csr.com/


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number 4187346, registered office Churchill House, Cambridge 
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
--
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


Re: [PATCH 3/3] mmc: omap_hsmmc: enable SDIO card interrupts

2010-02-18 Thread David Vrabel
Paul Walmsley wrote:
> 
> Perhaps I'm misunderstanding what you're referring to, but it seems there 
> is some confusion as to what target smart-idle mode does.

The TI OMAP 34xx TRM is the one of the most obtuse document I've had to
read.  An even after multiple reads of relevant sections it still
doesn't make sense.  Parts are contradictory, parts are poorly explained
and some bit are just plain incorrect.

I don't have time to sort out any of this properly -- it works well
enough for me.

David
-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ http://www.csr.com/


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number 4187346, registered office Churchill House, Cambridge 
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
--
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


Re: [PATCH 3/3] mmc: omap_hsmmc: enable SDIO card interrupts

2010-02-18 Thread David Vrabel
Madhusudhan wrote:
> 
> My question was more related to the idle path. In a scenario where
> you start using the SDIO functionality and after some time you leave
> the SDIO card idle, does the FCLK still remain enabled? Or do you see
> that sdio_irq_thread exits and disables the FCLK?

What do you mean by "leave the SDIO card idle"?

David
-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ http://www.csr.com/


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number 4187346, registered office Churchill House, Cambridge 
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
--
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


Re: [PATCH 3/3] mmc: omap_hsmmc: enable SDIO card interrupts

2010-02-17 Thread David Vrabel

Madhusudhan wrote:



-Original Message-
From: David Vrabel [mailto:david.vra...@csr.com]
Sent: Wednesday, February 10, 2010 5:52 AM
To: linux-...@vger.kernel.org
Cc: David Vrabel; linux-omap@vger.kernel.org; madhu...@ti.com
Subject: [PATCH 3/3] mmc: omap_hsmmc: enable SDIO card interrupts

Enable the use of SDIO card interrupts.  This requires setting ENAWAKEUP
in SYSCONFIG and IWE in HTCL to allow the MMC block to wake-up when in
smart-idle mode.

FCLK must be enabled while SDIO interrupts are enabled or the MMC block
won't wake-up.



I am curious to know the system behavior with this patch. Does the FCLK
remain enabled forever if a SDIO card is detected on the bus?


Only if card interrupts are enabled.  The card irq is disabled when the 
sdio_irq_thread exits.


This is why I think that smart-idle mode needs to be used (it's turned
on by default on the MMC controller) but I don't understand the
clock/clockdomain code to see if that's doing the right thing.

If smart-idle mode is used then we don't need to disable FCLK manually 
to save power.  This will simplify the driver a bit.


David
--
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


Re: [PATCH 3/3] mmc: omap_hsmmc: enable SDIO card interrupts

2010-02-17 Thread David Vrabel
David Vrabel wrote:
> 
> +static void omap_hsmmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
> +{
> + struct omap_hsmmc_host *host = mmc_priv(mmc);
> + u32 ie, con;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&host->irq_lock, flags);
> +
> + /*
> +  * When interrupts are enabled, CTPL must be set to enable
> +  * DAT1 input buffer (or the card interrupt is always
> +  * asserted) and FCLK must be enabled else wakeup does not
> +  * work.
> +  *
> +  * FIXME: the power save code probably shouldn't be playing
> +  * with FCLK and allow the clock subsystem to put it into
> +  * smart-idle mode instead.
> +  */
> + con = OMAP_HSMMC_READ(host->base, CON);
> + ie = OMAP_HSMMC_READ(host->base, IE);
> + if (enable) {
> + clk_enable(host->fclk);
> + ie |= CIRQ_ENABLE;
> + con |= CTPL;
> + } else {
> + clk_disable(host->fclk);
> + ie &= ~CIRQ_ENABLE;
> + con &= ~CTPL;
> + }
> + OMAP_HSMMC_WRITE(host->base, CON, con);
> + OMAP_HSMMC_WRITE(host->base, IE, ie);
> +
> + spin_unlock_irqrestore(&host->irq_lock, flags);
> +}

This isn't doing a posted write flush but when it's added this ends up
looking like:

spin_lock_irqsave(&host->lock, flags);

/*
 * When interrupts are enabled, CTPL must be set to enable
 * DAT1 input buffer (or the card interrupt is always
 * asserted) and FCLK must be enabled else wakeup does not
 * work.  Take care to disable FCLK after all the register
 * accesses as they might not complete if FCLK is off.
 *
 * FIXME: the power save code probably shouldn't be playing
 * with FCLK and allow the clock subsystem to put it into
 * smart-idle mode instead.
 */
con = OMAP_HSMMC_READ(host->base, CON);
ie = OMAP_HSMMC_READ(host->base, IE);
if (enable) {
clk_enable(host->fclk);
ie |= CIRQ_ENABLE;
con |= CTPL;
} else {
ie &= ~CIRQ_ENABLE;
con &= ~CTPL;
}
OMAP_HSMMC_WRITE(host->base, CON, con);
OMAP_HSMMC_WRITE(host->base, IE, ie);
OMAP_HSMMC_READ(host->base, IE); /* flush posted write */
if (!enable) {
    clk_disable(host->fclk);
}

spin_unlock_irqrestore(&host->lock, flags);

Could someone from TI could comment on why disabling FCLK affects
register read?

David
-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ http://www.csr.com/


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number 4187346, registered office Churchill House, Cambridge 
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
--
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


Re: [PATCH 1/3] mmc: omap_hsmmc: use packet sync'd DMA

2010-02-17 Thread David Vrabel
Madhusudhan wrote:
> 
>> -Original Message-
>> From: David Vrabel [mailto:david.vra...@csr.com]
>> Sent: Wednesday, February 10, 2010 5:52 AM
>> To: linux-...@vger.kernel.org
>> Cc: David Vrabel; linux-omap@vger.kernel.org; madhu...@ti.com
>> Subject: [PATCH 1/3] mmc: omap_hsmmc: use packet sync'd DMA
>>
>> Use packet sync'd DMA in the omap_hsmmc driver to avoid the
>> restriction that transfers must be a multiple of the block size.  This
>> is required for byte-mode transfers to SDIO cards.
>>
> What is the typical scenario here? Is it IO_RW_EXTENDED with block_mode
> turned off? 

This patch isn't necessary.  With byte mode transfers you get a single
sg element and the transfer's block size is set to the length of the
transfer so frame sync mode works fine.

David
-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ http://www.csr.com/


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number 4187346, registered office Churchill House, Cambridge 
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
--
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


Re: [PATCH 0/3] mmc: omap_hsmmc: support SDIO cards

2010-02-11 Thread David Vrabel
Mike Rapoport wrote:
> 
> I've started to apply the patches one by one and after the first patch
> is applied, the SD card works Ok, but libertas fails to initialize with
> the following messages:
> 
>> modprobe libertas_sdio
> [   82.233489] lib80211: common routines for IEEE802.11 drivers
> [   82.833251] cfg80211: Calling CRDA to update world regulatory domain
> [   83.327911] libertas_sdio: Libertas SDIO driver
> [   83.332489] libertas_sdio: Copyright Pierre Ossman
> [   83.348510] libertas_sdio mmc1:0001:1: firmware: requesting
> sd8686_helper.bin
> [   83.497619] libertas_sdio mmc1:0001:1: firmware: requesting sd8686.bin
> [   83.679229] DMA synchronization event drop occurred with device 47

What block size are you using?  It looks like you're using something
less than 512. I've checked the spec again and the DMA packet size
should be the block size in words (and not the FIFO depth).

Also, keep in mind that the buffers for transfers must begin and end on
a word boundary.  The OMAP's DMA controller can only transfer whole
words to the MMC FIFO.

David
-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ http://www.csr.com/


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number 4187346, registered office Churchill House, Cambridge 
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
--
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


Re: [PATCH 0/3] mmc: omap_hsmmc: support SDIO cards

2010-02-11 Thread David Vrabel
Mike Rapoport wrote:
> Hi David,
> 
> David Vrabel wrote:
>> These patches add support for SDIO cards to the omap_hsmmc driver.  Less
>> restrictions on the sizes of transfers, power management changes to 
>> prevent SDIO cards from being turned off and losing all state, and card
>> interrupts.
>>
>> I've been unable to test these exact patches as I only have an N900 for 
>> testing and the N900 support in mainline is incomplete.
> 
> I've tried your patches on CM-T35 that has 8686 SDIO and the result was
> absence of MMC/SDIO devices at all :( Morover, kmmcd hangs:
> 
> [  399.427764] INFO: task kmmcd:149 blocked for more than 120 seconds.
> [...]
> [  399.485290] [] (mmc_wait_for_cmd+0x64/0x74) from
> [] (mmc_go_idle+0x60/0xac)

I suspect interrupts aren't enabled correctly as this command does not
complete.  Try reverting this hunk.

@@ -426,12 +431,6 @@ omap_hsmmc_start_command(struct omap_hsmmc_host
*host, struct mmc_command *cmd,
mmc_hostname(host->mmc), cmd->opcode, cmd->arg);
host->cmd = cmd;

-   /*
-* Clear status bits and enable interrupts
-*/
-   OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
-   OMAP_HSMMC_WRITE(host->base, ISE, INT_EN_MASK);
-
if (host->use_dma)
OMAP_HSMMC_WRITE(host->base, IE,
 INT_EN_MASK & ~(BRR_ENABLE | BWR_ENABLE));

David
-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ http://www.csr.com/


Member of the CSR plc group of companies. CSR plc registered in England and 
Wales, registered number 4187346, registered office Churchill House, Cambridge 
Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
--
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 3/3] mmc: omap_hsmmc: enable SDIO card interrupts

2010-02-10 Thread David Vrabel
Enable the use of SDIO card interrupts.  This requires setting ENAWAKEUP
in SYSCONFIG and IWE in HTCL to allow the MMC block to wake-up when in
smart-idle mode.

FCLK must be enabled while SDIO interrupts are enabled or the MMC block
won't wake-up.

The writes to STAT and ISE when starting a command are unnecessary and
have been removed.

Signed-off-by: David Vrabel 
---
As noted in the FIXME comment, I think the correct thing to do is to
always leave FCLK enabled.  The clock/clockdomain subsystems should be
configuring smart-idle mode making explicit calls to disable FCLK
unnecessary.  I couldn't follow the clock subsystem to see if it was
actually doing this, though.
---
 drivers/mmc/host/omap_hsmmc.c |   94 -
 1 files changed, 65 insertions(+), 29 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index e6d8cb3..ad0f867 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -64,6 +64,7 @@
 #define SDVS_MASK  0x0E00
 #define SDVSCLR0xF1FF
 #define SDVSDET0x0400
+#define ENAWAKEUP  (1 << 2)
 #define AUTOIDLE   0x1
 #define SDBP   (1 << 8)
 #define DTO0xe
@@ -74,9 +75,11 @@
 #define CLKD_SHIFT 6
 #define DTO_MASK   0x000F
 #define DTO_SHIFT  16
+#define CIRQ_ENABLE(1 << 8)
 #define INT_EN_MASK0x307F0033
 #define BWR_ENABLE (1 << 4)
 #define BRR_ENABLE (1 << 5)
+#define CTPL   (1 << 11)
 #define INIT_STREAM(1 << 1)
 #define DP_SELECT  (1 << 21)
 #define DDIR   (1 << 4)
@@ -84,10 +87,12 @@
 #define MSBS   (1 << 5)
 #define BCE(1 << 1)
 #define FOUR_BIT   (1 << 1)
+#define IWE(1 << 24)
 #define DW8(1 << 5)
 #define CC 0x1
 #define TC 0x02
 #define OD 0x1
+#define CIRQ   (1 << 8)
 #define ERR(1 << 15)
 #define CMD_TIMEOUT(1 << 16)
 #define DATA_TIMEOUT   (1 << 20)
@@ -228,7 +233,7 @@ static int omap_hsmmc_context_restore(struct 
omap_hsmmc_host *host)
;
 
OMAP_HSMMC_WRITE(host->base, SYSCONFIG,
-   OMAP_HSMMC_READ(host->base, SYSCONFIG) | AUTOIDLE);
+   OMAP_HSMMC_READ(host->base, SYSCONFIG) | AUTOIDLE | 
ENAWAKEUP);
 
if (host->id == OMAP_MMC1_DEVID) {
if (host->power_mode != MMC_POWER_OFF &&
@@ -243,7 +248,7 @@ static int omap_hsmmc_context_restore(struct 
omap_hsmmc_host *host)
}
 
OMAP_HSMMC_WRITE(host->base, HCTL,
-   OMAP_HSMMC_READ(host->base, HCTL) | hctl);
+   OMAP_HSMMC_READ(host->base, HCTL) | hctl | IWE);
 
OMAP_HSMMC_WRITE(host->base, CAPA,
OMAP_HSMMC_READ(host->base, CAPA) | capa);
@@ -257,7 +262,7 @@ static int omap_hsmmc_context_restore(struct 
omap_hsmmc_host *host)
;
 
OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
-   OMAP_HSMMC_WRITE(host->base, ISE, INT_EN_MASK);
+   OMAP_HSMMC_WRITE(host->base, ISE, INT_EN_MASK | CIRQ);
OMAP_HSMMC_WRITE(host->base, IE, INT_EN_MASK);
 
/* Do not initialize card-specific things if the power is off */
@@ -426,12 +431,6 @@ omap_hsmmc_start_command(struct omap_hsmmc_host *host, 
struct mmc_command *cmd,
mmc_hostname(host->mmc), cmd->opcode, cmd->arg);
host->cmd = cmd;
 
-   /*
-* Clear status bits and enable interrupts
-*/
-   OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
-   OMAP_HSMMC_WRITE(host->base, ISE, INT_EN_MASK);
-
if (host->use_dma)
OMAP_HSMMC_WRITE(host->base, IE,
 INT_EN_MASK & ~(BRR_ENABLE | BWR_ENABLE));
@@ -638,18 +637,21 @@ static irqreturn_t omap_hsmmc_irq(int irq, void *dev_id)
 {
struct omap_hsmmc_host *host = dev_id;
struct mmc_data *data;
-   int end_cmd = 0, end_trans = 0, status;
+   u32 status;
+   int end_cmd = 0, end_trans = 0;
+   bool card_irq = false;
 
spin_lock(&host->irq_lock);
 
-   if (host->mrq == NULL) {
-   OMAP_HSMMC_WRITE(host->base, STAT,
-   OMAP_HSMMC_READ(host->base, STAT));
-   /* Flush posted write */
-   OMAP_HSMMC_READ(host->base, STAT);
-   spin_unlock(&host->irq_lock);
-   return IRQ_HANDLED;
-   }
+   status = OMAP_HSMMC_READ(host->base, STAT);
+   OMA

[PATCH 2/3] mmc: omap_hsmmc: don't turn SDIO cards off when idle

2010-02-10 Thread David Vrabel
Don't turn SDIO cards off to save power.  Doing so will lose all
internal state in the card.

Signed-off-by: David Vrabel 
---
 drivers/mmc/host/omap_hsmmc.c |   12 
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index e7142a2..e6d8cb3 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1359,8 +1360,12 @@ static int omap_hsmmc_sleep_to_off(struct 
omap_hsmmc_host *host)
  mmc_slot(host).card_detect ||
  (mmc_slot(host).get_cover_state &&
   mmc_slot(host).get_cover_state(host->dev, host->slot_id {
-   mmc_release_host(host->mmc);
-   return 0;
+   goto out;
+   }
+
+   /* Don't turn SDIO cards off. */
+   if (host->mmc->card && mmc_card_sdio(host->mmc->card)) {
+   goto out;
}
 
mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
@@ -1371,9 +1376,8 @@ static int omap_hsmmc_sleep_to_off(struct omap_hsmmc_host 
*host)
host->dpm_state == CARDSLEEP ? "CARDSLEEP" : "REGSLEEP");
 
host->dpm_state = OFF;
-
+out:
mmc_release_host(host->mmc);
-
return 0;
 }
 
-- 
1.6.3.3

--
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 1/3] mmc: omap_hsmmc: use packet sync'd DMA

2010-02-10 Thread David Vrabel
Use packet sync'd DMA in the omap_hsmmc driver to avoid the
restriction that transfers must be a multiple of the block size.  This
is required for byte-mode transfers to SDIO cards.

Signed-off-by: David Vrabel 
---
 drivers/mmc/host/omap_hsmmc.c |   17 +
 1 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 4b23225..e7142a2 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -114,6 +114,7 @@
 
 #define MMC_TIMEOUT_MS 20
 #define OMAP_MMC_MASTER_CLOCK  9600
+#define OMAP_HSMMC_FIFO_WORDS  (512/4)
 #define DRIVER_NAME"mmci-omap-hs"
 
 /* Timeouts for entering power saving states on inactivity, msec */
@@ -887,12 +888,12 @@ static void omap_hsmmc_config_dma_params(struct 
omap_hsmmc_host *host,
dma_ch = host->dma_ch;
if (data->flags & MMC_DATA_WRITE) {
omap_set_dma_dest_params(dma_ch, 0, OMAP_DMA_AMODE_CONSTANT,
-   (host->mapbase + OMAP_HSMMC_DATA), 0, 0);
+   (host->mapbase + OMAP_HSMMC_DATA), 0, 
OMAP_HSMMC_FIFO_WORDS);
omap_set_dma_src_params(dma_ch, 0, OMAP_DMA_AMODE_POST_INC,
sg_dma_address(sgl), 0, 0);
} else {
omap_set_dma_src_params(dma_ch, 0, OMAP_DMA_AMODE_CONSTANT,
-   (host->mapbase + OMAP_HSMMC_DATA), 0, 0);
+   (host->mapbase + OMAP_HSMMC_DATA), 0, 
OMAP_HSMMC_FIFO_WORDS);
omap_set_dma_dest_params(dma_ch, 0, OMAP_DMA_AMODE_POST_INC,
sg_dma_address(sgl), 0, 0);
}
@@ -901,7 +902,7 @@ static void omap_hsmmc_config_dma_params(struct 
omap_hsmmc_host *host,
nblk = sg_dma_len(sgl) / blksz;
 
omap_set_dma_transfer_params(dma_ch, OMAP_DMA_DATA_TYPE_S32,
-   blksz / 4, nblk, OMAP_DMA_SYNC_FRAME,
+   blksz / 4, nblk, OMAP_DMA_SYNC_PACKET,
omap_hsmmc_get_dma_sync_dev(host, data),
!(data->flags & MMC_DATA_WRITE));
 
@@ -944,17 +945,9 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void 
*data)
 static int omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host,
struct mmc_request *req)
 {
-   int dma_ch = 0, ret = 0, err = 1, i;
+   int dma_ch = 0, ret = 0, err = 1;
struct mmc_data *data = req->data;
 
-   /* Sanity check: all the SG entries must be aligned by block size. */
-   for (i = 0; i < data->sg_len; i++) {
-   struct scatterlist *sgl;
-
-   sgl = data->sg + i;
-   if (sgl->length % data->blksz)
-   return -EINVAL;
-   }
if ((data->blksz % 4) != 0)
/* REVISIT: The MMC buffer increments only when MSB is written.
 * Return error for blksz which is non multiple of four.
-- 
1.6.3.3

--
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 0/3] mmc: omap_hsmmc: support SDIO cards

2010-02-10 Thread David Vrabel
These patches add support for SDIO cards to the omap_hsmmc driver.  Less
restrictions on the sizes of transfers, power management changes to 
prevent SDIO cards from being turned off and losing all state, and card
interrupts.

I've been unable to test these exact patches as I only have an N900 for 
testing and the N900 support in mainline is incomplete.

David Vrabel (3):
  mmc: omap_hsmmc: use packet sync'd DMA
  mmc: omap_hsmmc: don't turn SDIO cards off when idle
  mmc: omap_hsmmc: enable SDIO card interrupts

 drivers/mmc/host/omap_hsmmc.c |  123 ++---
 1 files changed, 78 insertions(+), 45 deletions(-)

-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ http://www.csr.com/

--
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