MMC Driver RFC

From: Richard Purdie
Date: Wed Jan 12 2005 - 16:23:38 EST


I've been working on enabling the MMC/SD card slot on the Sharp SL-C7xx series. I've come across the following issues and would appreciate comments:

1. Card Detection Interrupts

The MMC code completely misses card removals on my test hardware as when the interrupt triggers electrical contact is still fully functional.

The PXA code calls mmc_detect_change() whenever an interrupt is detected. The MMC core then does a schedule_work(&host->detect). The problem is that when the interrupt is generated, the card may not be 100% inserted or 100% removed. Given the mechanical nature of insertions and removals, electrical contact is possible for a while after removal has been started (and a while before insertion is complete).

My proposed solution is to change the above code to schedule_delayed_work(&host->detect, HZ/4). Waiting 1/4 of a second after an event for things to stabilise makes my test hardware completely functional. It also makes a lot of sense in general as far as I can see. Patch attached.

2. Card Initialisation Problems

One of my cards works fine. The other works when I enable debug and doesn't when I don't. I suspect the delay while it does a printk gives something time to happen that doesn't normally when running at full speed!

I suspect this is related to the 1ms wait that was added to mmc_setup() as per comments. Is there any documentation which tells us exactly what timings we should be aiming for here? Has anyone else has problems like this?

3. SD Support

Ian Molton seems to have added SD support to handhelds.org's kernel. I'm still trying to contact him to discuss this but the following patch enables SD cards to work for me:
http://www.rpsys.net/openzaurus/2.6.11-rc1/mmc_sd-r1.patch

Was there a reason why SD support wasn't included in the original driver? Would something like this patch be accepted into the kernel (I realise it has some rough edges). I'd probably remove the attempt at 4 bit support until a mainstream driver supported that...

Richard

Attachment: mmc_delay-r0.patch
Description: Binary data