.. | .. |
---|
124 | 124 | EXPORT_SYMBOL(rv1106_sdmmc_put_lock); |
---|
125 | 125 | #endif |
---|
126 | 126 | |
---|
| 127 | +#define RV1106_RAMDON_DATA_SIZE 508 |
---|
| 128 | + |
---|
127 | 129 | #if defined(CONFIG_DEBUG_FS) |
---|
128 | 130 | static int dw_mci_req_show(struct seq_file *s, void *v) |
---|
129 | 131 | { |
---|
.. | .. |
---|
525 | 527 | tasklet_schedule(&host->tasklet); |
---|
526 | 528 | } |
---|
527 | 529 | |
---|
528 | | - if (host->need_xfer_timer && |
---|
529 | | - host->dir_status == DW_MCI_RECV_STATUS) |
---|
| 530 | + if (host->need_xfer_timer) |
---|
530 | 531 | del_timer(&host->xfer_timer); |
---|
531 | 532 | } |
---|
532 | 533 | |
---|
.. | .. |
---|
739 | 740 | if (host->is_rv1106_sd && (data->flags & MMC_DATA_WRITE)) { |
---|
740 | 741 | desc->des0 = desc_last->des0; |
---|
741 | 742 | desc->des2 = desc_last->des2; |
---|
742 | | - desc->des1 = 0x8; /* Random dirty data for last one desc */ |
---|
| 743 | + desc->des1 = RV1106_RAMDON_DATA_SIZE; /* Random dirty data for last one desc */ |
---|
743 | 744 | desc_last = desc; |
---|
744 | 745 | } |
---|
745 | 746 | |
---|
.. | .. |
---|
1447 | 1448 | return; |
---|
1448 | 1449 | } |
---|
1449 | 1450 | |
---|
1450 | | - if (host->is_rv1106_sd) { |
---|
1451 | | - u32 reg; |
---|
1452 | | - |
---|
1453 | | - readl_poll_timeout(host->regs + SDMMC_STATUS, reg, |
---|
1454 | | - reg & BIT(2), USEC_PER_MSEC, 500 * USEC_PER_MSEC); |
---|
1455 | | - } |
---|
1456 | | - |
---|
1457 | 1451 | spin_lock_bh(&host->lock); |
---|
1458 | 1452 | |
---|
1459 | 1453 | if (host->is_rv1106_sd) |
---|
.. | .. |
---|
1468 | 1462 | { |
---|
1469 | 1463 | struct dw_mci_slot *slot = mmc_priv(mmc); |
---|
1470 | 1464 | const struct dw_mci_drv_data *drv_data = slot->host->drv_data; |
---|
1471 | | - u32 regs; |
---|
| 1465 | + u32 regs, power_off_delay; |
---|
1472 | 1466 | int ret; |
---|
1473 | 1467 | |
---|
1474 | 1468 | switch (ios->bus_width) { |
---|
.. | .. |
---|
1507 | 1501 | |
---|
1508 | 1502 | switch (ios->power_mode) { |
---|
1509 | 1503 | case MMC_POWER_UP: |
---|
1510 | | - if (!IS_ERR_OR_NULL(slot->host->pinctrl)) |
---|
1511 | | - pinctrl_select_state(slot->host->pinctrl, slot->host->idle_state); |
---|
| 1504 | + if (dw_mci_get_cd(mmc) && !IS_ERR_OR_NULL(slot->host->pinctrl)) { |
---|
| 1505 | + if (!pinctrl_select_state(slot->host->pinctrl, slot->host->idle_state)) { |
---|
| 1506 | + if (device_property_read_u32(slot->host->dev, "power-off-delay-ms", |
---|
| 1507 | + &power_off_delay)) |
---|
| 1508 | + power_off_delay = 200; |
---|
| 1509 | + msleep(power_off_delay); |
---|
| 1510 | + } |
---|
| 1511 | + } |
---|
1512 | 1512 | |
---|
1513 | 1513 | if (!IS_ERR(mmc->supply.vmmc)) { |
---|
1514 | 1514 | ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, |
---|
.. | .. |
---|
1543 | 1543 | slot->host->vqmmc_enabled = true; |
---|
1544 | 1544 | } |
---|
1545 | 1545 | |
---|
| 1546 | +#ifndef CONFIG_ROCKCHIP_THUNDER_BOOT_MMC |
---|
1546 | 1547 | /* Reset our state machine after powering on */ |
---|
1547 | 1548 | dw_mci_ctrl_reset(slot->host, |
---|
1548 | 1549 | SDMMC_CTRL_ALL_RESET_FLAGS); |
---|
| 1550 | +#endif |
---|
1549 | 1551 | } |
---|
1550 | 1552 | |
---|
1551 | 1553 | /* Adjust clock / bus width after power is up */ |
---|
.. | .. |
---|
1868 | 1870 | |
---|
1869 | 1871 | WARN_ON(host->cmd || host->data); |
---|
1870 | 1872 | |
---|
| 1873 | + if (host->need_xfer_timer) |
---|
| 1874 | + del_timer(&host->xfer_timer); |
---|
| 1875 | + |
---|
1871 | 1876 | host->slot->mrq = NULL; |
---|
1872 | 1877 | host->mrq = NULL; |
---|
1873 | 1878 | if (!list_empty(&host->queue)) { |
---|
.. | .. |
---|
2013 | 2018 | host->bus_hz); |
---|
2014 | 2019 | |
---|
2015 | 2020 | /* add a bit spare time */ |
---|
2016 | | - xfer_ms += 100; |
---|
2017 | | - |
---|
| 2021 | + if (host->dir_status == DW_MCI_RECV_STATUS) |
---|
| 2022 | + xfer_ms += 100; |
---|
| 2023 | + else |
---|
| 2024 | + xfer_ms += 2500; |
---|
2018 | 2025 | spin_lock_irqsave(&host->irq_lock, irqflags); |
---|
2019 | 2026 | if (!test_bit(EVENT_XFER_COMPLETE, &host->pending_events)) |
---|
2020 | 2027 | mod_timer(&host->xfer_timer, |
---|
.. | .. |
---|
2149 | 2156 | send_stop_abort(host, data); |
---|
2150 | 2157 | dw_mci_stop_dma(host); |
---|
2151 | 2158 | state = STATE_DATA_ERROR; |
---|
| 2159 | + if (host->dir_status == DW_MCI_SEND_STATUS) { |
---|
| 2160 | + data->bytes_xfered = 0; |
---|
| 2161 | + data->error = -ETIMEDOUT; |
---|
| 2162 | + host->data = NULL; |
---|
| 2163 | + dw_mci_request_end(host, mrq); |
---|
| 2164 | + goto unlock; |
---|
| 2165 | + } |
---|
2152 | 2166 | break; |
---|
2153 | 2167 | } |
---|
2154 | 2168 | |
---|
.. | .. |
---|
2160 | 2174 | */ |
---|
2161 | 2175 | if (host->dir_status == DW_MCI_RECV_STATUS) |
---|
2162 | 2176 | dw_mci_set_drto(host); |
---|
2163 | | - if (host->need_xfer_timer && |
---|
2164 | | - host->dir_status == DW_MCI_RECV_STATUS) |
---|
| 2177 | + if (host->need_xfer_timer) |
---|
2165 | 2178 | dw_mci_set_xfer_timeout(host); |
---|
2166 | 2179 | break; |
---|
2167 | 2180 | } |
---|
.. | .. |
---|
2203 | 2216 | */ |
---|
2204 | 2217 | if (host->dir_status == DW_MCI_RECV_STATUS) |
---|
2205 | 2218 | dw_mci_set_drto(host); |
---|
| 2219 | + if (host->need_xfer_timer && host->dir_status == DW_MCI_SEND_STATUS) |
---|
| 2220 | + dw_mci_set_xfer_timeout(host); |
---|
2206 | 2221 | break; |
---|
2207 | 2222 | } |
---|
2208 | 2223 | |
---|
.. | .. |
---|
2219 | 2234 | } |
---|
2220 | 2235 | |
---|
2221 | 2236 | /* stop command for open-ended transfer*/ |
---|
2222 | | - if (data->stop) |
---|
| 2237 | + if (data->stop) { |
---|
| 2238 | + if (host->is_rv1106_sd && (data->flags & MMC_DATA_WRITE)) { |
---|
| 2239 | + int fifo_count; |
---|
| 2240 | + |
---|
| 2241 | + if (readl_poll_timeout_atomic(host->regs + SDMMC_STATUS, fifo_count, |
---|
| 2242 | + ((fifo_count >> 17) & 0x7FF) <= RV1106_RAMDON_DATA_SIZE / 4, |
---|
| 2243 | + 0, 5000 * USEC_PER_MSEC)) |
---|
| 2244 | + data->error = -ETIMEDOUT; |
---|
| 2245 | + udelay(1); |
---|
| 2246 | + dw_mci_reset(host); |
---|
| 2247 | + } |
---|
2223 | 2248 | send_stop_abort(host, data); |
---|
| 2249 | + } |
---|
2224 | 2250 | } else { |
---|
2225 | 2251 | /* |
---|
2226 | 2252 | * If we don't have a command complete now we'll |
---|
.. | .. |
---|
2751 | 2777 | del_timer(&host->cto_timer); |
---|
2752 | 2778 | mci_writel(host, RINTSTS, DW_MCI_CMD_ERROR_FLAGS); |
---|
2753 | 2779 | host->cmd_status = pending; |
---|
2754 | | - if ((host->need_xfer_timer) && |
---|
2755 | | - host->dir_status == DW_MCI_RECV_STATUS) |
---|
| 2780 | + if (host->need_xfer_timer) |
---|
2756 | 2781 | del_timer(&host->xfer_timer); |
---|
2757 | 2782 | smp_wmb(); /* drain writebuffer */ |
---|
2758 | 2783 | set_bit(EVENT_CMD_COMPLETE, &host->pending_events); |
---|
.. | .. |
---|
3657 | 3682 | mci_writel(host, INTMASK, ret); |
---|
3658 | 3683 | } |
---|
3659 | 3684 | |
---|
3660 | | - if (host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER) |
---|
| 3685 | + if (host->slot && host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER) |
---|
3661 | 3686 | dw_mci_set_ios(host->slot->mmc, &host->slot->mmc->ios); |
---|
3662 | 3687 | |
---|
3663 | 3688 | /* Force setup bus to guarantee available clock output */ |
---|