diff options
Diffstat (limited to 'drivers/mmc/host/bfin_sdh.c')
-rw-r--r-- | drivers/mmc/host/bfin_sdh.c | 210 |
1 files changed, 139 insertions, 71 deletions
diff --git a/drivers/mmc/host/bfin_sdh.c b/drivers/mmc/host/bfin_sdh.c index a17dd7363ceb..b9b463eca1ec 100644 --- a/drivers/mmc/host/bfin_sdh.c +++ b/drivers/mmc/host/bfin_sdh.c | |||
@@ -24,9 +24,7 @@ | |||
24 | #include <asm/portmux.h> | 24 | #include <asm/portmux.h> |
25 | #include <asm/bfin_sdh.h> | 25 | #include <asm/bfin_sdh.h> |
26 | 26 | ||
27 | #if defined(CONFIG_BF51x) | 27 | #if defined(CONFIG_BF51x) || defined(__ADSPBF60x__) |
28 | #define bfin_read_SDH_PWR_CTL bfin_read_RSI_PWR_CTL | ||
29 | #define bfin_write_SDH_PWR_CTL bfin_write_RSI_PWR_CTL | ||
30 | #define bfin_read_SDH_CLK_CTL bfin_read_RSI_CLK_CTL | 28 | #define bfin_read_SDH_CLK_CTL bfin_read_RSI_CLK_CTL |
31 | #define bfin_write_SDH_CLK_CTL bfin_write_RSI_CLK_CTL | 29 | #define bfin_write_SDH_CLK_CTL bfin_write_RSI_CLK_CTL |
32 | #define bfin_write_SDH_ARGUMENT bfin_write_RSI_ARGUMENT | 30 | #define bfin_write_SDH_ARGUMENT bfin_write_RSI_ARGUMENT |
@@ -45,8 +43,16 @@ | |||
45 | #define bfin_write_SDH_E_STATUS bfin_write_RSI_E_STATUS | 43 | #define bfin_write_SDH_E_STATUS bfin_write_RSI_E_STATUS |
46 | #define bfin_read_SDH_STATUS bfin_read_RSI_STATUS | 44 | #define bfin_read_SDH_STATUS bfin_read_RSI_STATUS |
47 | #define bfin_write_SDH_MASK0 bfin_write_RSI_MASK0 | 45 | #define bfin_write_SDH_MASK0 bfin_write_RSI_MASK0 |
46 | #define bfin_write_SDH_E_MASK bfin_write_RSI_E_MASK | ||
48 | #define bfin_read_SDH_CFG bfin_read_RSI_CFG | 47 | #define bfin_read_SDH_CFG bfin_read_RSI_CFG |
49 | #define bfin_write_SDH_CFG bfin_write_RSI_CFG | 48 | #define bfin_write_SDH_CFG bfin_write_RSI_CFG |
49 | # if defined(__ADSPBF60x__) | ||
50 | # define bfin_read_SDH_BLK_SIZE bfin_read_RSI_BLKSZ | ||
51 | # define bfin_write_SDH_BLK_SIZE bfin_write_RSI_BLKSZ | ||
52 | # else | ||
53 | # define bfin_read_SDH_PWR_CTL bfin_read_RSI_PWR_CTL | ||
54 | # define bfin_write_SDH_PWR_CTL bfin_write_RSI_PWR_CTL | ||
55 | # endif | ||
50 | #endif | 56 | #endif |
51 | 57 | ||
52 | struct sdh_host { | 58 | struct sdh_host { |
@@ -62,6 +68,7 @@ struct sdh_host { | |||
62 | dma_addr_t sg_dma; | 68 | dma_addr_t sg_dma; |
63 | int dma_len; | 69 | int dma_len; |
64 | 70 | ||
71 | unsigned long sclk; | ||
65 | unsigned int imask; | 72 | unsigned int imask; |
66 | unsigned int power_mode; | 73 | unsigned int power_mode; |
67 | unsigned int clk_div; | 74 | unsigned int clk_div; |
@@ -127,11 +134,15 @@ static int sdh_setup_data(struct sdh_host *host, struct mmc_data *data) | |||
127 | /* Only supports power-of-2 block size */ | 134 | /* Only supports power-of-2 block size */ |
128 | if (data->blksz & (data->blksz - 1)) | 135 | if (data->blksz & (data->blksz - 1)) |
129 | return -EINVAL; | 136 | return -EINVAL; |
137 | #ifndef RSI_BLKSZ | ||
130 | data_ctl |= ((ffs(data->blksz) - 1) << 4); | 138 | data_ctl |= ((ffs(data->blksz) - 1) << 4); |
139 | #else | ||
140 | bfin_write_SDH_BLK_SIZE(data->blksz); | ||
141 | #endif | ||
131 | 142 | ||
132 | bfin_write_SDH_DATA_CTL(data_ctl); | 143 | bfin_write_SDH_DATA_CTL(data_ctl); |
133 | /* the time of a host clock period in ns */ | 144 | /* the time of a host clock period in ns */ |
134 | cycle_ns = 1000000000 / (get_sclk() / (2 * (host->clk_div + 1))); | 145 | cycle_ns = 1000000000 / (host->sclk / (2 * (host->clk_div + 1))); |
135 | timeout = data->timeout_ns / cycle_ns; | 146 | timeout = data->timeout_ns / cycle_ns; |
136 | timeout += data->timeout_clks; | 147 | timeout += data->timeout_clks; |
137 | bfin_write_SDH_DATA_TIMER(timeout); | 148 | bfin_write_SDH_DATA_TIMER(timeout); |
@@ -145,8 +156,13 @@ static int sdh_setup_data(struct sdh_host *host, struct mmc_data *data) | |||
145 | 156 | ||
146 | sdh_enable_stat_irq(host, (DAT_CRC_FAIL | DAT_TIME_OUT | DAT_END)); | 157 | sdh_enable_stat_irq(host, (DAT_CRC_FAIL | DAT_TIME_OUT | DAT_END)); |
147 | host->dma_len = dma_map_sg(mmc_dev(host->mmc), data->sg, data->sg_len, host->dma_dir); | 158 | host->dma_len = dma_map_sg(mmc_dev(host->mmc), data->sg, data->sg_len, host->dma_dir); |
148 | #if defined(CONFIG_BF54x) | 159 | #if defined(CONFIG_BF54x) || defined(CONFIG_BF60x) |
149 | dma_cfg |= DMAFLOW_ARRAY | NDSIZE_5 | RESTART | WDSIZE_32 | DMAEN; | 160 | dma_cfg |= DMAFLOW_ARRAY | RESTART | WDSIZE_32 | DMAEN; |
161 | # ifdef RSI_BLKSZ | ||
162 | dma_cfg |= PSIZE_32 | NDSIZE_3; | ||
163 | # else | ||
164 | dma_cfg |= NDSIZE_5; | ||
165 | # endif | ||
150 | { | 166 | { |
151 | struct scatterlist *sg; | 167 | struct scatterlist *sg; |
152 | int i; | 168 | int i; |
@@ -156,7 +172,7 @@ static int sdh_setup_data(struct sdh_host *host, struct mmc_data *data) | |||
156 | host->sg_cpu[i].x_count = sg_dma_len(sg) / 4; | 172 | host->sg_cpu[i].x_count = sg_dma_len(sg) / 4; |
157 | host->sg_cpu[i].x_modify = 4; | 173 | host->sg_cpu[i].x_modify = 4; |
158 | dev_dbg(mmc_dev(host->mmc), "%d: start_addr:0x%lx, " | 174 | dev_dbg(mmc_dev(host->mmc), "%d: start_addr:0x%lx, " |
159 | "cfg:0x%x, x_count:0x%x, x_modify:0x%x\n", | 175 | "cfg:0x%lx, x_count:0x%lx, x_modify:0x%lx\n", |
160 | i, host->sg_cpu[i].start_addr, | 176 | i, host->sg_cpu[i].start_addr, |
161 | host->sg_cpu[i].cfg, host->sg_cpu[i].x_count, | 177 | host->sg_cpu[i].cfg, host->sg_cpu[i].x_count, |
162 | host->sg_cpu[i].x_modify); | 178 | host->sg_cpu[i].x_modify); |
@@ -172,6 +188,7 @@ static int sdh_setup_data(struct sdh_host *host, struct mmc_data *data) | |||
172 | set_dma_curr_desc_addr(host->dma_ch, (unsigned long *)host->sg_dma); | 188 | set_dma_curr_desc_addr(host->dma_ch, (unsigned long *)host->sg_dma); |
173 | set_dma_x_count(host->dma_ch, 0); | 189 | set_dma_x_count(host->dma_ch, 0); |
174 | set_dma_x_modify(host->dma_ch, 0); | 190 | set_dma_x_modify(host->dma_ch, 0); |
191 | SSYNC(); | ||
175 | set_dma_config(host->dma_ch, dma_cfg); | 192 | set_dma_config(host->dma_ch, dma_cfg); |
176 | #elif defined(CONFIG_BF51x) | 193 | #elif defined(CONFIG_BF51x) |
177 | /* RSI DMA doesn't work in array mode */ | 194 | /* RSI DMA doesn't work in array mode */ |
@@ -179,6 +196,7 @@ static int sdh_setup_data(struct sdh_host *host, struct mmc_data *data) | |||
179 | set_dma_start_addr(host->dma_ch, sg_dma_address(&data->sg[0])); | 196 | set_dma_start_addr(host->dma_ch, sg_dma_address(&data->sg[0])); |
180 | set_dma_x_count(host->dma_ch, length / 4); | 197 | set_dma_x_count(host->dma_ch, length / 4); |
181 | set_dma_x_modify(host->dma_ch, 4); | 198 | set_dma_x_modify(host->dma_ch, 4); |
199 | SSYNC(); | ||
182 | set_dma_config(host->dma_ch, dma_cfg); | 200 | set_dma_config(host->dma_ch, dma_cfg); |
183 | #endif | 201 | #endif |
184 | bfin_write_SDH_DATA_CTL(bfin_read_SDH_DATA_CTL() | DTX_DMA_E | DTX_E); | 202 | bfin_write_SDH_DATA_CTL(bfin_read_SDH_DATA_CTL() | DTX_DMA_E | DTX_E); |
@@ -296,7 +314,6 @@ static int sdh_data_done(struct sdh_host *host, unsigned int stat) | |||
296 | else | 314 | else |
297 | data->bytes_xfered = 0; | 315 | data->bytes_xfered = 0; |
298 | 316 | ||
299 | sdh_disable_stat_irq(host, DAT_END | DAT_TIME_OUT | DAT_CRC_FAIL | RX_OVERRUN | TX_UNDERRUN); | ||
300 | bfin_write_SDH_STATUS_CLR(DAT_END_STAT | DAT_TIMEOUT_STAT | \ | 317 | bfin_write_SDH_STATUS_CLR(DAT_END_STAT | DAT_TIMEOUT_STAT | \ |
301 | DAT_CRC_FAIL_STAT | DAT_BLK_END_STAT | RX_OVERRUN | TX_UNDERRUN); | 318 | DAT_CRC_FAIL_STAT | DAT_BLK_END_STAT | RX_OVERRUN | TX_UNDERRUN); |
302 | bfin_write_SDH_DATA_CTL(0); | 319 | bfin_write_SDH_DATA_CTL(0); |
@@ -321,74 +338,115 @@ static void sdh_request(struct mmc_host *mmc, struct mmc_request *mrq) | |||
321 | dev_dbg(mmc_dev(host->mmc), "%s enter, mrp:%p, cmd:%p\n", __func__, mrq, mrq->cmd); | 338 | dev_dbg(mmc_dev(host->mmc), "%s enter, mrp:%p, cmd:%p\n", __func__, mrq, mrq->cmd); |
322 | WARN_ON(host->mrq != NULL); | 339 | WARN_ON(host->mrq != NULL); |
323 | 340 | ||
341 | spin_lock(&host->lock); | ||
324 | host->mrq = mrq; | 342 | host->mrq = mrq; |
325 | host->data = mrq->data; | 343 | host->data = mrq->data; |
326 | 344 | ||
327 | if (mrq->data && mrq->data->flags & MMC_DATA_READ) { | 345 | if (mrq->data && mrq->data->flags & MMC_DATA_READ) { |
328 | ret = sdh_setup_data(host, mrq->data); | 346 | ret = sdh_setup_data(host, mrq->data); |
329 | if (ret) | 347 | if (ret) |
330 | return; | 348 | goto data_err; |
331 | } | 349 | } |
332 | 350 | ||
333 | sdh_start_cmd(host, mrq->cmd); | 351 | sdh_start_cmd(host, mrq->cmd); |
352 | data_err: | ||
353 | spin_unlock(&host->lock); | ||
334 | } | 354 | } |
335 | 355 | ||
336 | static void sdh_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | 356 | static void sdh_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) |
337 | { | 357 | { |
338 | struct sdh_host *host; | 358 | struct sdh_host *host; |
339 | unsigned long flags; | ||
340 | u16 clk_ctl = 0; | 359 | u16 clk_ctl = 0; |
360 | #ifndef RSI_BLKSZ | ||
341 | u16 pwr_ctl = 0; | 361 | u16 pwr_ctl = 0; |
362 | #endif | ||
342 | u16 cfg; | 363 | u16 cfg; |
343 | host = mmc_priv(mmc); | 364 | host = mmc_priv(mmc); |
344 | 365 | ||
345 | spin_lock_irqsave(&host->lock, flags); | 366 | spin_lock(&host->lock); |
346 | if (ios->clock) { | ||
347 | unsigned long sys_clk, ios_clk; | ||
348 | unsigned char clk_div; | ||
349 | ios_clk = 2 * ios->clock; | ||
350 | sys_clk = get_sclk(); | ||
351 | clk_div = sys_clk / ios_clk; | ||
352 | if (sys_clk % ios_clk == 0) | ||
353 | clk_div -= 1; | ||
354 | clk_div = min_t(unsigned char, clk_div, 0xFF); | ||
355 | clk_ctl |= clk_div; | ||
356 | clk_ctl |= CLK_E; | ||
357 | host->clk_div = clk_div; | ||
358 | } else | ||
359 | sdh_stop_clock(host); | ||
360 | |||
361 | if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) | ||
362 | #ifdef CONFIG_SDH_BFIN_MISSING_CMD_PULLUP_WORKAROUND | ||
363 | pwr_ctl |= ROD_CTL; | ||
364 | #else | ||
365 | pwr_ctl |= SD_CMD_OD | ROD_CTL; | ||
366 | #endif | ||
367 | 367 | ||
368 | if (ios->bus_width == MMC_BUS_WIDTH_4) { | 368 | cfg = bfin_read_SDH_CFG(); |
369 | cfg = bfin_read_SDH_CFG(); | 369 | cfg |= MWE; |
370 | switch (ios->bus_width) { | ||
371 | case MMC_BUS_WIDTH_4: | ||
372 | #ifndef RSI_BLKSZ | ||
370 | cfg &= ~PD_SDDAT3; | 373 | cfg &= ~PD_SDDAT3; |
374 | #endif | ||
371 | cfg |= PUP_SDDAT3; | 375 | cfg |= PUP_SDDAT3; |
372 | /* Enable 4 bit SDIO */ | 376 | /* Enable 4 bit SDIO */ |
373 | cfg |= (SD4E | MWE); | 377 | cfg |= SD4E; |
374 | bfin_write_SDH_CFG(cfg); | 378 | clk_ctl |= WIDE_BUS_4; |
375 | clk_ctl |= WIDE_BUS; | 379 | break; |
376 | } else { | 380 | case MMC_BUS_WIDTH_8: |
377 | cfg = bfin_read_SDH_CFG(); | 381 | #ifndef RSI_BLKSZ |
378 | cfg |= MWE; | 382 | cfg &= ~PD_SDDAT3; |
379 | bfin_write_SDH_CFG(cfg); | 383 | #endif |
384 | cfg |= PUP_SDDAT3; | ||
385 | /* Disable 4 bit SDIO */ | ||
386 | cfg &= ~SD4E; | ||
387 | clk_ctl |= BYTE_BUS_8; | ||
388 | break; | ||
389 | default: | ||
390 | cfg &= ~PUP_SDDAT3; | ||
391 | /* Disable 4 bit SDIO */ | ||
392 | cfg &= ~SD4E; | ||
380 | } | 393 | } |
381 | 394 | ||
382 | bfin_write_SDH_CLK_CTL(clk_ctl); | ||
383 | |||
384 | host->power_mode = ios->power_mode; | 395 | host->power_mode = ios->power_mode; |
385 | if (ios->power_mode == MMC_POWER_ON) | 396 | #ifndef RSI_BLKSZ |
397 | if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) { | ||
398 | pwr_ctl |= ROD_CTL; | ||
399 | # ifndef CONFIG_SDH_BFIN_MISSING_CMD_PULLUP_WORKAROUND | ||
400 | pwr_ctl |= SD_CMD_OD; | ||
401 | # endif | ||
402 | } | ||
403 | |||
404 | if (ios->power_mode != MMC_POWER_OFF) | ||
386 | pwr_ctl |= PWR_ON; | 405 | pwr_ctl |= PWR_ON; |
406 | else | ||
407 | pwr_ctl &= ~PWR_ON; | ||
387 | 408 | ||
388 | bfin_write_SDH_PWR_CTL(pwr_ctl); | 409 | bfin_write_SDH_PWR_CTL(pwr_ctl); |
410 | #else | ||
411 | # ifndef CONFIG_SDH_BFIN_MISSING_CMD_PULLUP_WORKAROUND | ||
412 | if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) | ||
413 | cfg |= SD_CMD_OD; | ||
414 | else | ||
415 | cfg &= ~SD_CMD_OD; | ||
416 | # endif | ||
417 | |||
418 | |||
419 | if (ios->power_mode != MMC_POWER_OFF) | ||
420 | cfg |= PWR_ON; | ||
421 | else | ||
422 | cfg &= ~PWR_ON; | ||
423 | |||
424 | bfin_write_SDH_CFG(cfg); | ||
425 | #endif | ||
389 | SSYNC(); | 426 | SSYNC(); |
390 | 427 | ||
391 | spin_unlock_irqrestore(&host->lock, flags); | 428 | if (ios->power_mode == MMC_POWER_ON && ios->clock) { |
429 | unsigned char clk_div; | ||
430 | clk_div = (get_sclk() / ios->clock - 1) / 2; | ||
431 | clk_div = min_t(unsigned char, clk_div, 0xFF); | ||
432 | clk_ctl |= clk_div; | ||
433 | clk_ctl |= CLK_E; | ||
434 | host->clk_div = clk_div; | ||
435 | bfin_write_SDH_CLK_CTL(clk_ctl); | ||
436 | |||
437 | } else | ||
438 | sdh_stop_clock(host); | ||
439 | |||
440 | /* set up sdh interrupt mask*/ | ||
441 | if (ios->power_mode == MMC_POWER_ON) | ||
442 | bfin_write_SDH_MASK0(DAT_END | DAT_TIME_OUT | DAT_CRC_FAIL | | ||
443 | RX_OVERRUN | TX_UNDERRUN | CMD_SENT | CMD_RESP_END | | ||
444 | CMD_TIME_OUT | CMD_CRC_FAIL); | ||
445 | else | ||
446 | bfin_write_SDH_MASK0(0); | ||
447 | SSYNC(); | ||
448 | |||
449 | spin_unlock(&host->lock); | ||
392 | 450 | ||
393 | dev_dbg(mmc_dev(host->mmc), "SDH: clk_div = 0x%x actual clock:%ld expected clock:%d\n", | 451 | dev_dbg(mmc_dev(host->mmc), "SDH: clk_div = 0x%x actual clock:%ld expected clock:%d\n", |
394 | host->clk_div, | 452 | host->clk_div, |
@@ -405,7 +463,7 @@ static irqreturn_t sdh_dma_irq(int irq, void *devid) | |||
405 | { | 463 | { |
406 | struct sdh_host *host = devid; | 464 | struct sdh_host *host = devid; |
407 | 465 | ||
408 | dev_dbg(mmc_dev(host->mmc), "%s enter, irq_stat: 0x%04x\n", __func__, | 466 | dev_dbg(mmc_dev(host->mmc), "%s enter, irq_stat: 0x%04lx\n", __func__, |
409 | get_dma_curr_irqstat(host->dma_ch)); | 467 | get_dma_curr_irqstat(host->dma_ch)); |
410 | clear_dma_irqstat(host->dma_ch); | 468 | clear_dma_irqstat(host->dma_ch); |
411 | SSYNC(); | 469 | SSYNC(); |
@@ -420,6 +478,9 @@ static irqreturn_t sdh_stat_irq(int irq, void *devid) | |||
420 | int handled = 0; | 478 | int handled = 0; |
421 | 479 | ||
422 | dev_dbg(mmc_dev(host->mmc), "%s enter\n", __func__); | 480 | dev_dbg(mmc_dev(host->mmc), "%s enter\n", __func__); |
481 | |||
482 | spin_lock(&host->lock); | ||
483 | |||
423 | status = bfin_read_SDH_E_STATUS(); | 484 | status = bfin_read_SDH_E_STATUS(); |
424 | if (status & SD_CARD_DET) { | 485 | if (status & SD_CARD_DET) { |
425 | mmc_detect_change(host->mmc, 0); | 486 | mmc_detect_change(host->mmc, 0); |
@@ -437,11 +498,30 @@ static irqreturn_t sdh_stat_irq(int irq, void *devid) | |||
437 | if (status & (DAT_END | DAT_TIME_OUT | DAT_CRC_FAIL | RX_OVERRUN | TX_UNDERRUN)) | 498 | if (status & (DAT_END | DAT_TIME_OUT | DAT_CRC_FAIL | RX_OVERRUN | TX_UNDERRUN)) |
438 | handled |= sdh_data_done(host, status); | 499 | handled |= sdh_data_done(host, status); |
439 | 500 | ||
501 | spin_unlock(&host->lock); | ||
502 | |||
440 | dev_dbg(mmc_dev(host->mmc), "%s exit\n\n", __func__); | 503 | dev_dbg(mmc_dev(host->mmc), "%s exit\n\n", __func__); |
441 | 504 | ||
442 | return IRQ_RETVAL(handled); | 505 | return IRQ_RETVAL(handled); |
443 | } | 506 | } |
444 | 507 | ||
508 | static void sdh_reset(void) | ||
509 | { | ||
510 | #if defined(CONFIG_BF54x) | ||
511 | /* Secure Digital Host shares DMA with Nand controller */ | ||
512 | bfin_write_DMAC1_PERIMUX(bfin_read_DMAC1_PERIMUX() | 0x1); | ||
513 | #endif | ||
514 | |||
515 | bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN); | ||
516 | SSYNC(); | ||
517 | |||
518 | /* Disable card inserting detection pin. set MMC_CAP_NEEDS_POLL, and | ||
519 | * mmc stack will do the detection. | ||
520 | */ | ||
521 | bfin_write_SDH_CFG((bfin_read_SDH_CFG() & 0x1F) | (PUP_SDDAT | PUP_SDDAT3)); | ||
522 | SSYNC(); | ||
523 | } | ||
524 | |||
445 | static int __devinit sdh_probe(struct platform_device *pdev) | 525 | static int __devinit sdh_probe(struct platform_device *pdev) |
446 | { | 526 | { |
447 | struct mmc_host *mmc; | 527 | struct mmc_host *mmc; |
@@ -462,8 +542,16 @@ static int __devinit sdh_probe(struct platform_device *pdev) | |||
462 | } | 542 | } |
463 | 543 | ||
464 | mmc->ops = &sdh_ops; | 544 | mmc->ops = &sdh_ops; |
465 | mmc->max_segs = 32; | 545 | #if defined(CONFIG_BF51x) |
546 | mmc->max_segs = 1; | ||
547 | #else | ||
548 | mmc->max_segs = PAGE_SIZE / sizeof(struct dma_desc_array); | ||
549 | #endif | ||
550 | #ifdef RSI_BLKSZ | ||
551 | mmc->max_seg_size = -1; | ||
552 | #else | ||
466 | mmc->max_seg_size = 1 << 16; | 553 | mmc->max_seg_size = 1 << 16; |
554 | #endif | ||
467 | mmc->max_blk_size = 1 << 11; | 555 | mmc->max_blk_size = 1 << 11; |
468 | mmc->max_blk_count = 1 << 11; | 556 | mmc->max_blk_count = 1 << 11; |
469 | mmc->max_req_size = PAGE_SIZE; | 557 | mmc->max_req_size = PAGE_SIZE; |
@@ -473,6 +561,7 @@ static int __devinit sdh_probe(struct platform_device *pdev) | |||
473 | mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_NEEDS_POLL; | 561 | mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_NEEDS_POLL; |
474 | host = mmc_priv(mmc); | 562 | host = mmc_priv(mmc); |
475 | host->mmc = mmc; | 563 | host->mmc = mmc; |
564 | host->sclk = get_sclk(); | ||
476 | 565 | ||
477 | spin_lock_init(&host->lock); | 566 | spin_lock_init(&host->lock); |
478 | host->irq = drv_data->irq_int0; | 567 | host->irq = drv_data->irq_int0; |
@@ -497,7 +586,6 @@ static int __devinit sdh_probe(struct platform_device *pdev) | |||
497 | } | 586 | } |
498 | 587 | ||
499 | platform_set_drvdata(pdev, mmc); | 588 | platform_set_drvdata(pdev, mmc); |
500 | mmc_add_host(mmc); | ||
501 | 589 | ||
502 | ret = request_irq(host->irq, sdh_stat_irq, 0, "SDH Status IRQ", host); | 590 | ret = request_irq(host->irq, sdh_stat_irq, 0, "SDH Status IRQ", host); |
503 | if (ret) { | 591 | if (ret) { |
@@ -510,20 +598,10 @@ static int __devinit sdh_probe(struct platform_device *pdev) | |||
510 | dev_err(&pdev->dev, "unable to request peripheral pins\n"); | 598 | dev_err(&pdev->dev, "unable to request peripheral pins\n"); |
511 | goto out4; | 599 | goto out4; |
512 | } | 600 | } |
513 | #if defined(CONFIG_BF54x) | ||
514 | /* Secure Digital Host shares DMA with Nand controller */ | ||
515 | bfin_write_DMAC1_PERIMUX(bfin_read_DMAC1_PERIMUX() | 0x1); | ||
516 | #endif | ||
517 | |||
518 | bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN); | ||
519 | SSYNC(); | ||
520 | 601 | ||
521 | /* Disable card inserting detection pin. set MMC_CAP_NEES_POLL, and | 602 | sdh_reset(); |
522 | * mmc stack will do the detection. | ||
523 | */ | ||
524 | bfin_write_SDH_CFG((bfin_read_SDH_CFG() & 0x1F) | (PUP_SDDAT | PUP_SDDAT3)); | ||
525 | SSYNC(); | ||
526 | 603 | ||
604 | mmc_add_host(mmc); | ||
527 | return 0; | 605 | return 0; |
528 | 606 | ||
529 | out4: | 607 | out4: |
@@ -571,7 +649,6 @@ static int sdh_suspend(struct platform_device *dev, pm_message_t state) | |||
571 | if (mmc) | 649 | if (mmc) |
572 | ret = mmc_suspend_host(mmc); | 650 | ret = mmc_suspend_host(mmc); |
573 | 651 | ||
574 | bfin_write_SDH_PWR_CTL(bfin_read_SDH_PWR_CTL() & ~PWR_ON); | ||
575 | peripheral_free_list(drv_data->pin_req); | 652 | peripheral_free_list(drv_data->pin_req); |
576 | 653 | ||
577 | return ret; | 654 | return ret; |
@@ -589,16 +666,7 @@ static int sdh_resume(struct platform_device *dev) | |||
589 | return ret; | 666 | return ret; |
590 | } | 667 | } |
591 | 668 | ||
592 | bfin_write_SDH_PWR_CTL(bfin_read_SDH_PWR_CTL() | PWR_ON); | 669 | sdh_reset(); |
593 | #if defined(CONFIG_BF54x) | ||
594 | /* Secure Digital Host shares DMA with Nand controller */ | ||
595 | bfin_write_DMAC1_PERIMUX(bfin_read_DMAC1_PERIMUX() | 0x1); | ||
596 | #endif | ||
597 | bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN); | ||
598 | SSYNC(); | ||
599 | |||
600 | bfin_write_SDH_CFG((bfin_read_SDH_CFG() & 0x1F) | (PUP_SDDAT | PUP_SDDAT3)); | ||
601 | SSYNC(); | ||
602 | 670 | ||
603 | if (mmc) | 671 | if (mmc) |
604 | ret = mmc_resume_host(mmc); | 672 | ret = mmc_resume_host(mmc); |