aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaehoon Chung <jh80.chung@samsung.com>2017-06-05 00:41:31 -0400
committerUlf Hansson <ulf.hansson@linaro.org>2017-06-29 11:14:09 -0400
commit58870241a67453be7dc9ab368d5a0cdc9c404616 (patch)
tree272982c33350a5d04e2923a5b86a5ddb7f7bcd5f
parentd30a8f7bdf6498e47bd3a6f31e5028f239deb208 (diff)
mmc: dw_mmc: remove the loop about finding slots
dwmmc controller has used the only one slot. It doesn't need to check the other slots. Remove the loop about finding slots. Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com> Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/host/dw_mmc.c115
1 files changed, 36 insertions, 79 deletions
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 97fab9bb3db8..1b415da82754 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -2563,26 +2563,21 @@ static void dw_mci_cmd_interrupt(struct dw_mci *host, u32 status)
2563 2563
2564static void dw_mci_handle_cd(struct dw_mci *host) 2564static void dw_mci_handle_cd(struct dw_mci *host)
2565{ 2565{
2566 int i; 2566 int i = 0;
2567 2567 struct dw_mci_slot *slot = host->slot[i];
2568 for (i = 0; i < host->num_slots; i++) {
2569 struct dw_mci_slot *slot = host->slot[i];
2570
2571 if (!slot)
2572 continue;
2573 2568
2574 if (slot->mmc->ops->card_event) 2569 if (slot->mmc->ops->card_event)
2575 slot->mmc->ops->card_event(slot->mmc); 2570 slot->mmc->ops->card_event(slot->mmc);
2576 mmc_detect_change(slot->mmc, 2571 mmc_detect_change(slot->mmc,
2577 msecs_to_jiffies(host->pdata->detect_delay_ms)); 2572 msecs_to_jiffies(host->pdata->detect_delay_ms));
2578 }
2579} 2573}
2580 2574
2581static irqreturn_t dw_mci_interrupt(int irq, void *dev_id) 2575static irqreturn_t dw_mci_interrupt(int irq, void *dev_id)
2582{ 2576{
2583 struct dw_mci *host = dev_id; 2577 struct dw_mci *host = dev_id;
2584 u32 pending; 2578 u32 pending;
2585 int i; 2579 int i = 0;
2580 struct dw_mci_slot *slot = host->slot[i];
2586 2581
2587 pending = mci_readl(host, MINTSTS); /* read-only mask reg */ 2582 pending = mci_readl(host, MINTSTS); /* read-only mask reg */
2588 2583
@@ -2659,19 +2654,11 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id)
2659 dw_mci_handle_cd(host); 2654 dw_mci_handle_cd(host);
2660 } 2655 }
2661 2656
2662 /* Handle SDIO Interrupts */ 2657 if (pending & SDMMC_INT_SDIO(slot->sdio_id)) {
2663 for (i = 0; i < host->num_slots; i++) { 2658 mci_writel(host, RINTSTS,
2664 struct dw_mci_slot *slot = host->slot[i]; 2659 SDMMC_INT_SDIO(slot->sdio_id));
2665 2660 __dw_mci_enable_sdio_irq(slot, 0);
2666 if (!slot) 2661 sdio_signal_irq(slot->mmc);
2667 continue;
2668
2669 if (pending & SDMMC_INT_SDIO(slot->sdio_id)) {
2670 mci_writel(host, RINTSTS,
2671 SDMMC_INT_SDIO(slot->sdio_id));
2672 __dw_mci_enable_sdio_irq(slot, 0);
2673 sdio_signal_irq(slot->mmc);
2674 }
2675 } 2662 }
2676 2663
2677 } 2664 }
@@ -3011,29 +2998,24 @@ static void dw_mci_enable_cd(struct dw_mci *host)
3011{ 2998{
3012 unsigned long irqflags; 2999 unsigned long irqflags;
3013 u32 temp; 3000 u32 temp;
3014 int i; 3001 int i = 0;
3015 struct dw_mci_slot *slot; 3002 struct dw_mci_slot *slot;
3016 3003
3017 /* 3004 /*
3018 * No need for CD if all slots have a non-error GPIO 3005 * No need for CD if all slots have a non-error GPIO
3019 * as well as broken card detection is found. 3006 * as well as broken card detection is found.
3020 */ 3007 */
3021 for (i = 0; i < host->num_slots; i++) { 3008 slot = host->slot[i];
3022 slot = host->slot[i]; 3009 if (slot->mmc->caps & MMC_CAP_NEEDS_POLL)
3023 if (slot->mmc->caps & MMC_CAP_NEEDS_POLL)
3024 return;
3025
3026 if (mmc_gpio_get_cd(slot->mmc) < 0)
3027 break;
3028 }
3029 if (i == host->num_slots)
3030 return; 3010 return;
3031 3011
3032 spin_lock_irqsave(&host->irq_lock, irqflags); 3012 if (mmc_gpio_get_cd(slot->mmc) < 0) {
3033 temp = mci_readl(host, INTMASK); 3013 spin_lock_irqsave(&host->irq_lock, irqflags);
3034 temp |= SDMMC_INT_CD; 3014 temp = mci_readl(host, INTMASK);
3035 mci_writel(host, INTMASK, temp); 3015 temp |= SDMMC_INT_CD;
3036 spin_unlock_irqrestore(&host->irq_lock, irqflags); 3016 mci_writel(host, INTMASK, temp);
3017 spin_unlock_irqrestore(&host->irq_lock, irqflags);
3018 }
3037} 3019}
3038 3020
3039int dw_mci_probe(struct dw_mci *host) 3021int dw_mci_probe(struct dw_mci *host)
@@ -3041,7 +3023,6 @@ int dw_mci_probe(struct dw_mci *host)
3041 const struct dw_mci_drv_data *drv_data = host->drv_data; 3023 const struct dw_mci_drv_data *drv_data = host->drv_data;
3042 int width, i, ret = 0; 3024 int width, i, ret = 0;
3043 u32 fifo_size; 3025 u32 fifo_size;
3044 int init_slots = 0;
3045 3026
3046 if (!host->pdata) { 3027 if (!host->pdata) {
3047 host->pdata = dw_mci_parse_dt(host); 3028 host->pdata = dw_mci_parse_dt(host);
@@ -3205,13 +3186,6 @@ int dw_mci_probe(struct dw_mci *host)
3205 goto err_dmaunmap; 3186 goto err_dmaunmap;
3206 3187
3207 /* 3188 /*
3208 * Even though dwmmc IP is provided the multiple slots,
3209 * there is no use case in mmc subsystem.
3210 * dwmmc host controller needs to initialize the one slot per an IP.
3211 */
3212 host->num_slots = 1;
3213
3214 /*
3215 * Enable interrupts for command done, data over, data empty, 3189 * Enable interrupts for command done, data over, data empty,
3216 * receive ready and error such as transmit, receive timeout, crc error 3190 * receive ready and error such as transmit, receive timeout, crc error
3217 */ 3191 */
@@ -3226,20 +3200,9 @@ int dw_mci_probe(struct dw_mci *host)
3226 host->irq, width, fifo_size); 3200 host->irq, width, fifo_size);
3227 3201
3228 /* We need at least one slot to succeed */ 3202 /* We need at least one slot to succeed */
3229 for (i = 0; i < host->num_slots; i++) { 3203 ret = dw_mci_init_slot(host, 0);
3230 ret = dw_mci_init_slot(host, i); 3204 if (ret) {
3231 if (ret) 3205 dev_dbg(host->dev, "slot %d init failed\n", i);
3232 dev_dbg(host->dev, "slot %d init failed\n", i);
3233 else
3234 init_slots++;
3235 }
3236
3237 if (init_slots) {
3238 dev_info(host->dev, "%d slots initialized\n", init_slots);
3239 } else {
3240 dev_dbg(host->dev,
3241 "attempted to initialize %d slots, but failed on all\n",
3242 host->num_slots);
3243 goto err_dmaunmap; 3206 goto err_dmaunmap;
3244 } 3207 }
3245 3208
@@ -3267,13 +3230,11 @@ EXPORT_SYMBOL(dw_mci_probe);
3267 3230
3268void dw_mci_remove(struct dw_mci *host) 3231void dw_mci_remove(struct dw_mci *host)
3269{ 3232{
3270 int i; 3233 int i = 0;
3271 3234
3272 for (i = 0; i < host->num_slots; i++) { 3235 dev_dbg(host->dev, "remove slot %d\n", i);
3273 dev_dbg(host->dev, "remove slot %d\n", i); 3236 if (host->slot[i])
3274 if (host->slot[i]) 3237 dw_mci_cleanup_slot(host->slot[i], i);
3275 dw_mci_cleanup_slot(host->slot[i], i);
3276 }
3277 3238
3278 mci_writel(host, RINTSTS, 0xFFFFFFFF); 3239 mci_writel(host, RINTSTS, 0xFFFFFFFF);
3279 mci_writel(host, INTMASK, 0); /* disable all mmc interrupt first */ 3240 mci_writel(host, INTMASK, 0); /* disable all mmc interrupt first */
@@ -3316,8 +3277,9 @@ EXPORT_SYMBOL(dw_mci_runtime_suspend);
3316 3277
3317int dw_mci_runtime_resume(struct device *dev) 3278int dw_mci_runtime_resume(struct device *dev)
3318{ 3279{
3319 int i, ret = 0; 3280 int i = 0, ret = 0;
3320 struct dw_mci *host = dev_get_drvdata(dev); 3281 struct dw_mci *host = dev_get_drvdata(dev);
3282 struct dw_mci_slot *slot = host->slot[i];
3321 3283
3322 if (host->cur_slot && 3284 if (host->cur_slot &&
3323 (mmc_can_gpio_cd(host->cur_slot->mmc) || 3285 (mmc_can_gpio_cd(host->cur_slot->mmc) ||
@@ -3356,17 +3318,12 @@ int dw_mci_runtime_resume(struct device *dev)
3356 DW_MCI_ERROR_FLAGS); 3318 DW_MCI_ERROR_FLAGS);
3357 mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); 3319 mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE);
3358 3320
3359 for (i = 0; i < host->num_slots; i++) {
3360 struct dw_mci_slot *slot = host->slot[i];
3361 3321
3362 if (!slot) 3322 if (slot->mmc->pm_flags & MMC_PM_KEEP_POWER)
3363 continue; 3323 dw_mci_set_ios(slot->mmc, &slot->mmc->ios);
3364 if (slot->mmc->pm_flags & MMC_PM_KEEP_POWER)
3365 dw_mci_set_ios(slot->mmc, &slot->mmc->ios);
3366 3324
3367 /* Force setup bus to guarantee available clock output */ 3325 /* Force setup bus to guarantee available clock output */
3368 dw_mci_setup_bus(slot, true); 3326 dw_mci_setup_bus(slot, true);
3369 }
3370 3327
3371 /* Now that slots are all setup, we can enable card detect */ 3328 /* Now that slots are all setup, we can enable card detect */
3372 dw_mci_enable_cd(host); 3329 dw_mci_enable_cd(host);