Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 53586
b: refs/heads/master
c: 89a73cf
h: refs/heads/master
v: v3
  • Loading branch information
Pierre Ossman committed May 1, 2007
1 parent 31a851d commit aed07ad
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 41 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1addfcdbe4b23a20f28a097c2469d9f0c21bef23
refs/heads/master: 89a73cf52ba2ae4402c53487b71ec4475544f139
75 changes: 35 additions & 40 deletions trunk/drivers/mmc/core/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,9 @@ static void mmc_decode_csd(struct mmc_card *card)
}

/*
* Read and decode extended CSD. Switch to high-speed and wide bus
* if supported.
* Read and decode extended CSD.
*/
static int mmc_process_ext_csd(struct mmc_card *card)
static int mmc_read_ext_csd(struct mmc_card *card)
{
int err;
u8 *ext_csd;
Expand Down Expand Up @@ -223,39 +222,6 @@ static int mmc_process_ext_csd(struct mmc_card *card)
goto out;
}

if (card->host->caps & MMC_CAP_MMC_HIGHSPEED) {
/* Activate highspeed support. */
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_HS_TIMING, 1);
if (err != MMC_ERR_NONE) {
printk(KERN_WARNING "%s: failed to switch "
"card to mmc v4 high-speed mode.\n",
mmc_hostname(card->host));
err = MMC_ERR_NONE;
goto out;
}

mmc_card_set_highspeed(card);

mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
}

/* Check for host support for wide-bus modes. */
if (card->host->caps & MMC_CAP_4_BIT_DATA) {
/* Activate 4-bit support. */
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_4);
if (err != MMC_ERR_NONE) {
printk(KERN_WARNING "%s: failed to switch "
"card to mmc v4 4-bit bus mode.\n",
mmc_hostname(card->host));
err = MMC_ERR_NONE;
goto out;
}

mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4);
}

out:
kfree(ext_csd);

Expand Down Expand Up @@ -391,18 +357,34 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr)
mmc_decode_cid(card);

/*
* Fetch and process extened CSD.
* This will switch into high-speed and wide bus modes,
* as available.
* Select card, as all following commands rely on that.
*/
err = mmc_select_card(card);
if (err != MMC_ERR_NONE)
goto free_card;

err = mmc_process_ext_csd(card);
/*
* Fetch and process extened CSD.
*/
err = mmc_read_ext_csd(card);
if (err != MMC_ERR_NONE)
goto free_card;

/*
* Activate high speed (if supported)
*/
if ((card->ext_csd.hs_max_dtr != 0) &&
(host->caps & MMC_CAP_MMC_HIGHSPEED)) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_HS_TIMING, 1);
if (err != MMC_ERR_NONE)
goto free_card;

mmc_card_set_highspeed(card);

mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
}

/*
* Compute bus speed.
*/
Expand All @@ -417,6 +399,19 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr)

mmc_set_clock(host, max_dtr);

/*
* Activate wide bus (if supported).
*/
if ((card->csd.mmca_vsn >= CSD_SPEC_VER_4) &&
(host->caps & MMC_CAP_4_BIT_DATA)) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_4);
if (err != MMC_ERR_NONE)
goto free_card;

mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4);
}

host->card = card;

mmc_release_host(host);
Expand Down

0 comments on commit aed07ad

Please sign in to comment.