diff options
author | Sonic Zhang <sonic.zhang@analog.com> | 2012-08-08 00:13:32 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2012-09-04 13:58:18 -0400 |
commit | 4ffdcf0469f1e7e47476ee410e8dfbc6aba61b65 (patch) | |
tree | 53ddf5d1db62878ef37460a5f2bcbf49a3169424 | |
parent | 0462566b1e3129b2920b63b62a653b70a1bc36fa (diff) |
mmc: bfin_sdh: Add support for new RSI controller in bf60x
In BF60x RSI controller:
1) MMR read/write width differs.
2) PWR and CTL MMRs are merged to together.
3) ROD and PD_DAT3 bit masks are obsolete.
4) New RSI block size MMR is defined.
5) The definition of DMA descriptor set size is changed.
6) set_ios should powers up controller in 2 steps.
In addition, this patch cleans up the spin locks.
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r-- | drivers/mmc/host/bfin_sdh.c | 180 |
1 files changed, 128 insertions, 52 deletions
diff --git a/drivers/mmc/host/bfin_sdh.c b/drivers/mmc/host/bfin_sdh.c index 56a10938b44a..f47526f09271 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,6 +498,8 @@ 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); |
@@ -462,12 +525,16 @@ static int __devinit sdh_probe(struct platform_device *pdev) | |||
462 | } | 525 | } |
463 | 526 | ||
464 | mmc->ops = &sdh_ops; | 527 | mmc->ops = &sdh_ops; |
465 | #if defined(CONFIG_BF54x) | 528 | #if defined(CONFIG_BF51x) |
466 | mmc->max_segs = 32; | ||
467 | #elif defined(CONFIG_BF51x) | ||
468 | mmc->max_segs = 1; | 529 | mmc->max_segs = 1; |
530 | #else | ||
531 | mmc->max_segs = PAGE_SIZE / sizeof(struct dma_desc_array); | ||
469 | #endif | 532 | #endif |
533 | #ifdef RSI_BLKSZ | ||
534 | mmc->max_seg_size = -1; | ||
535 | #else | ||
470 | mmc->max_seg_size = 1 << 16; | 536 | mmc->max_seg_size = 1 << 16; |
537 | #endif | ||
471 | mmc->max_blk_size = 1 << 11; | 538 | mmc->max_blk_size = 1 << 11; |
472 | mmc->max_blk_count = 1 << 11; | 539 | mmc->max_blk_count = 1 << 11; |
473 | mmc->max_req_size = PAGE_SIZE; | 540 | mmc->max_req_size = PAGE_SIZE; |
@@ -477,6 +544,7 @@ static int __devinit sdh_probe(struct platform_device *pdev) | |||
477 | mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_NEEDS_POLL; | 544 | mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_NEEDS_POLL; |
478 | host = mmc_priv(mmc); | 545 | host = mmc_priv(mmc); |
479 | host->mmc = mmc; | 546 | host->mmc = mmc; |
547 | host->sclk = get_sclk(); | ||
480 | 548 | ||
481 | spin_lock_init(&host->lock); | 549 | spin_lock_init(&host->lock); |
482 | host->irq = drv_data->irq_int0; | 550 | host->irq = drv_data->irq_int0; |
@@ -501,7 +569,6 @@ static int __devinit sdh_probe(struct platform_device *pdev) | |||
501 | } | 569 | } |
502 | 570 | ||
503 | platform_set_drvdata(pdev, mmc); | 571 | platform_set_drvdata(pdev, mmc); |
504 | mmc_add_host(mmc); | ||
505 | 572 | ||
506 | ret = request_irq(host->irq, sdh_stat_irq, 0, "SDH Status IRQ", host); | 573 | ret = request_irq(host->irq, sdh_stat_irq, 0, "SDH Status IRQ", host); |
507 | if (ret) { | 574 | if (ret) { |
@@ -522,12 +589,13 @@ static int __devinit sdh_probe(struct platform_device *pdev) | |||
522 | bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN); | 589 | bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN); |
523 | SSYNC(); | 590 | SSYNC(); |
524 | 591 | ||
525 | /* Disable card inserting detection pin. set MMC_CAP_NEES_POLL, and | 592 | /* Disable card inserting detection pin. set MMC_CAP_NEEDS_POLL, and |
526 | * mmc stack will do the detection. | 593 | * mmc stack will do the detection. |
527 | */ | 594 | */ |
528 | bfin_write_SDH_CFG((bfin_read_SDH_CFG() & 0x1F) | (PUP_SDDAT | PUP_SDDAT3)); | 595 | bfin_write_SDH_CFG((bfin_read_SDH_CFG() & 0x1F) | (PUP_SDDAT | PUP_SDDAT3)); |
529 | SSYNC(); | 596 | SSYNC(); |
530 | 597 | ||
598 | mmc_add_host(mmc); | ||
531 | return 0; | 599 | return 0; |
532 | 600 | ||
533 | out4: | 601 | out4: |
@@ -575,7 +643,11 @@ static int sdh_suspend(struct platform_device *dev, pm_message_t state) | |||
575 | if (mmc) | 643 | if (mmc) |
576 | ret = mmc_suspend_host(mmc); | 644 | ret = mmc_suspend_host(mmc); |
577 | 645 | ||
646 | #ifndef RSI_BLKSZ | ||
578 | bfin_write_SDH_PWR_CTL(bfin_read_SDH_PWR_CTL() & ~PWR_ON); | 647 | bfin_write_SDH_PWR_CTL(bfin_read_SDH_PWR_CTL() & ~PWR_ON); |
648 | #else | ||
649 | bfin_write_SDH_CFG(bfin_read_SDH_CFG() & ~PWR_ON); | ||
650 | #endif | ||
579 | peripheral_free_list(drv_data->pin_req); | 651 | peripheral_free_list(drv_data->pin_req); |
580 | 652 | ||
581 | return ret; | 653 | return ret; |
@@ -593,12 +665,16 @@ static int sdh_resume(struct platform_device *dev) | |||
593 | return ret; | 665 | return ret; |
594 | } | 666 | } |
595 | 667 | ||
596 | bfin_write_SDH_PWR_CTL(bfin_read_SDH_PWR_CTL() | PWR_ON); | ||
597 | #if defined(CONFIG_BF54x) | 668 | #if defined(CONFIG_BF54x) |
598 | /* Secure Digital Host shares DMA with Nand controller */ | 669 | /* Secure Digital Host shares DMA with Nand controller */ |
599 | bfin_write_DMAC1_PERIMUX(bfin_read_DMAC1_PERIMUX() | 0x1); | 670 | bfin_write_DMAC1_PERIMUX(bfin_read_DMAC1_PERIMUX() | 0x1); |
600 | #endif | 671 | #endif |
672 | #ifndef RSI_BLKSZ | ||
673 | bfin_write_SDH_PWR_CTL(bfin_read_SDH_PWR_CTL() | PWR_ON); | ||
601 | bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN); | 674 | bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN); |
675 | #else | ||
676 | bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN | PWR_ON); | ||
677 | #endif | ||
602 | SSYNC(); | 678 | SSYNC(); |
603 | 679 | ||
604 | bfin_write_SDH_CFG((bfin_read_SDH_CFG() & 0x1F) | (PUP_SDDAT | PUP_SDDAT3)); | 680 | bfin_write_SDH_CFG((bfin_read_SDH_CFG() & 0x1F) | (PUP_SDDAT | PUP_SDDAT3)); |