aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core/mmc.c
diff options
context:
space:
mode:
authorPierre Ossman <drzeus@drzeus.cx>2007-05-01 09:08:30 -0400
committerPierre Ossman <drzeus@drzeus.cx>2007-05-01 09:08:30 -0400
commit89a73cf52ba2ae4402c53487b71ec4475544f139 (patch)
tree9ac38faa312bb5127dee2381d6c0923fe94192b1 /drivers/mmc/core/mmc.c
parent1addfcdbe4b23a20f28a097c2469d9f0c21bef23 (diff)
mmc: separate out reading EXT_CSD
Separate the reading and decoding of the EXT_CSD register with the actions taken on it. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc/core/mmc.c')
-rw-r--r--drivers/mmc/core/mmc.c75
1 files changed, 35 insertions, 40 deletions
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index c2e120b11bef..47449e870131 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -152,10 +152,9 @@ static void mmc_decode_csd(struct mmc_card *card)
152} 152}
153 153
154/* 154/*
155 * Read and decode extended CSD. Switch to high-speed and wide bus 155 * Read and decode extended CSD.
156 * if supported.
157 */ 156 */
158static int mmc_process_ext_csd(struct mmc_card *card) 157static int mmc_read_ext_csd(struct mmc_card *card)
159{ 158{
160 int err; 159 int err;
161 u8 *ext_csd; 160 u8 *ext_csd;
@@ -223,39 +222,6 @@ static int mmc_process_ext_csd(struct mmc_card *card)
223 goto out; 222 goto out;
224 } 223 }
225 224
226 if (card->host->caps & MMC_CAP_MMC_HIGHSPEED) {
227 /* Activate highspeed support. */
228 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
229 EXT_CSD_HS_TIMING, 1);
230 if (err != MMC_ERR_NONE) {
231 printk(KERN_WARNING "%s: failed to switch "
232 "card to mmc v4 high-speed mode.\n",
233 mmc_hostname(card->host));
234 err = MMC_ERR_NONE;
235 goto out;
236 }
237
238 mmc_card_set_highspeed(card);
239
240 mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
241 }
242
243 /* Check for host support for wide-bus modes. */
244 if (card->host->caps & MMC_CAP_4_BIT_DATA) {
245 /* Activate 4-bit support. */
246 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
247 EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_4);
248 if (err != MMC_ERR_NONE) {
249 printk(KERN_WARNING "%s: failed to switch "
250 "card to mmc v4 4-bit bus mode.\n",
251 mmc_hostname(card->host));
252 err = MMC_ERR_NONE;
253 goto out;
254 }
255
256 mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4);
257 }
258
259out: 225out:
260 kfree(ext_csd); 226 kfree(ext_csd);
261 227
@@ -391,19 +357,35 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr)
391 mmc_decode_cid(card); 357 mmc_decode_cid(card);
392 358
393 /* 359 /*
394 * Fetch and process extened CSD. 360 * Select card, as all following commands rely on that.
395 * This will switch into high-speed and wide bus modes,
396 * as available.
397 */ 361 */
398 err = mmc_select_card(card); 362 err = mmc_select_card(card);
399 if (err != MMC_ERR_NONE) 363 if (err != MMC_ERR_NONE)
400 goto free_card; 364 goto free_card;
401 365
402 err = mmc_process_ext_csd(card); 366 /*
367 * Fetch and process extened CSD.
368 */
369 err = mmc_read_ext_csd(card);
403 if (err != MMC_ERR_NONE) 370 if (err != MMC_ERR_NONE)
404 goto free_card; 371 goto free_card;
405 372
406 /* 373 /*
374 * Activate high speed (if supported)
375 */
376 if ((card->ext_csd.hs_max_dtr != 0) &&
377 (host->caps & MMC_CAP_MMC_HIGHSPEED)) {
378 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
379 EXT_CSD_HS_TIMING, 1);
380 if (err != MMC_ERR_NONE)
381 goto free_card;
382
383 mmc_card_set_highspeed(card);
384
385 mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
386 }
387
388 /*
407 * Compute bus speed. 389 * Compute bus speed.
408 */ 390 */
409 max_dtr = (unsigned int)-1; 391 max_dtr = (unsigned int)-1;
@@ -417,6 +399,19 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr)
417 399
418 mmc_set_clock(host, max_dtr); 400 mmc_set_clock(host, max_dtr);
419 401
402 /*
403 * Activate wide bus (if supported).
404 */
405 if ((card->csd.mmca_vsn >= CSD_SPEC_VER_4) &&
406 (host->caps & MMC_CAP_4_BIT_DATA)) {
407 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
408 EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_4);
409 if (err != MMC_ERR_NONE)
410 goto free_card;
411
412 mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4);
413 }
414
420 host->card = card; 415 host->card = card;
421 416
422 mmc_release_host(host); 417 mmc_release_host(host);