MMC Controller driver for PXA255
Jacques Fourie
jacques.fourie at gmail.com
Mon Sep 1 09:58:49 UTC 2008
>> On Fri, 29 Aug 2008 18:20:16 +0200
>> "Jacques Fourie" <jacques.fourie at gmail.com> mentioned:
>>
>>> Hi,
>>>
>>> I've written a driver for the MMC controller found on the Intel Xscale
>>> PXA255 (as found on the Gumstix Connex). It seems to work OK - I've
>>> tested with a range of SD cards. The driver works in PIO mode (still
>>> busy to debug some DMA issues) and on my Gumstix Connex I get around
>>> 400kB/s. If anyone wants to review the code for inclusion let me know
>>> and I'll be happy to provide it.
>>>
>>
>> Great work!
>> Upload it somewhere or post here, so we can take a look.
>>
>> Thanks!
>> --
>> Stanislav Sedov
>> ST4096-RIPE
>>
> Hi,
>
> I previously sent Warner some mods but forgot to cc the list. Here is
> a diff against current (svn revision 182470). I also made some minor
> mods to the mmc stack that I'll post as soon as I've cleaned them up -
> they contain a lot of extra printf's at the moment.
>
> Jacques
>
Here is a diff against mmc.c that contains my mods to the mmc stack.
Very minor - I've added support for retrying commands. Some SD cards
that I've tested with requires one extra ACMD_SD_SEND_OP_COND so I've
included that as well.
Jacques
-------------- next part --------------
--- fbsd_current_20080830/src/sys/dev/mmc/mmc.c 2008-08-30 08:45:11.000000000 +0200
+++ fbsd_jf_priv/src/sys/dev/mmc/mmc.c 2008-09-01 11:35:39.000000000 +0200
@@ -51,7 +51,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/dev/mmc/mmc.c 170337 2007-06-05 17:04:44Z imp $");
+__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
@@ -258,13 +258,22 @@
mmc_wakeup(struct mmc_request *req)
{
struct mmc_softc *sc;
+ struct mmc_command *cmd = req->cmd;
// printf("Wakeup for req %p done_data %p\n", req, req->done_data);
sc = (struct mmc_softc *)req->done_data;
MMC_LOCK(sc);
- req->flags |= MMC_REQ_DONE;
- wakeup(req);
- MMC_UNLOCK(sc);
+ if (cmd->error && cmd->retries) {
+ cmd->retries--;
+ cmd->error = 0;
+ MMC_UNLOCK(sc);
+ MMCBR_REQUEST(device_get_parent(sc->dev), sc->dev, req);
+ }
+ else {
+ req->flags |= MMC_REQ_DONE;
+ wakeup(req);
+ MMC_UNLOCK(sc);
+ }
}
static int
@@ -556,7 +565,7 @@
cmd.opcode = MMC_ALL_SEND_CID;
cmd.arg = 0;
cmd.flags = MMC_RSP_R2 | MMC_CMD_BCR;
- err = mmc_wait_for_cmd(sc, &cmd, 0);
+ err = mmc_wait_for_cmd(sc, &cmd, CMD_RETRIES);
memcpy(rawcid, cmd.resp, 4 * sizeof(uint32_t));
return (err);
}
@@ -570,7 +579,7 @@
cmd.opcode = MMC_SEND_CSD;
cmd.arg = rca << 16;
cmd.flags = MMC_RSP_R2 | MMC_CMD_BCR;
- err = mmc_wait_for_cmd(sc, &cmd, 0);
+ err = mmc_wait_for_cmd(sc, &cmd, CMD_RETRIES);
memcpy(rawcid, cmd.resp, 4 * sizeof(uint32_t));
return (err);
}
@@ -584,7 +593,7 @@
cmd.opcode = SD_SEND_RELATIVE_ADDR;
cmd.arg = 0;
cmd.flags = MMC_RSP_R6 | MMC_CMD_BCR;
- err = mmc_wait_for_cmd(sc, &cmd, 0);
+ err = mmc_wait_for_cmd(sc, &cmd, CMD_RETRIES);
*resp = cmd.resp[0];
return (err);
}
@@ -664,12 +673,16 @@
/*
* Reselect the cards after we've idled them above.
*/
- if (mmcbr_get_mode(dev) == mode_sd)
- mmc_send_app_op_cond(sc, mmcbr_get_ocr(dev), NULL);
+ if (mmcbr_get_mode(dev) == mode_sd) {
+ int i;
+
+ for (i = 0; i < 2; i++)
+ mmc_send_app_op_cond(sc, mmcbr_get_ocr(dev), NULL);
+ }
else
mmc_send_op_cond(sc, mmcbr_get_ocr(dev), NULL);
mmc_discover_cards(sc);
-
+
mmcbr_set_bus_mode(dev, pushpull);
mmcbr_update_ios(dev);
bus_generic_attach(dev);
@@ -790,4 +803,5 @@
DRIVER_MODULE(mmc, at91_mci, mmc_driver, mmc_devclass, 0, 0);
+DRIVER_MODULE(mmc, pxa_mci, mmc_driver, mmc_devclass, 0, 0);
DRIVER_MODULE(mmc, sdh, mmc_driver, mmc_devclass, 0, 0);
More information about the freebsd-arm
mailing list