12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 2c3665006SThomas Abraham /* 3c3665006SThomas Abraham * Exynos Specific Extensions for Synopsys DW Multimedia Card Interface driver 4c3665006SThomas Abraham * 5c3665006SThomas Abraham * Copyright (C) 2012, Samsung Electronics Co., Ltd. 6c3665006SThomas Abraham */ 7c3665006SThomas Abraham 8c3665006SThomas Abraham #include <linux/module.h> 9c3665006SThomas Abraham #include <linux/platform_device.h> 10c3665006SThomas Abraham #include <linux/clk.h> 11c3665006SThomas Abraham #include <linux/mmc/host.h> 12c537a1c5SSeungwon Jeon #include <linux/mmc/mmc.h> 13c3665006SThomas Abraham #include <linux/of.h> 14c3665006SThomas Abraham #include <linux/of_gpio.h> 15cf5237efSShawn Lin #include <linux/pm_runtime.h> 16c537a1c5SSeungwon Jeon #include <linux/slab.h> 17c3665006SThomas Abraham 18c3665006SThomas Abraham #include "dw_mmc.h" 19c3665006SThomas Abraham #include "dw_mmc-pltfm.h" 200b5fce48SSeungwon Jeon #include "dw_mmc-exynos.h" 21c6d9dedaSSeungwon Jeon 22c3665006SThomas Abraham /* Variations in Exynos specific dw-mshc controller */ 23c3665006SThomas Abraham enum dw_mci_exynos_type { 24c3665006SThomas Abraham DW_MCI_TYPE_EXYNOS4210, 25c3665006SThomas Abraham DW_MCI_TYPE_EXYNOS4412, 26c3665006SThomas Abraham DW_MCI_TYPE_EXYNOS5250, 2700fd041bSYuvaraj Kumar C D DW_MCI_TYPE_EXYNOS5420, 286bce431cSYuvaraj Kumar C D DW_MCI_TYPE_EXYNOS5420_SMU, 2989ad2be7SAbhilash Kesavan DW_MCI_TYPE_EXYNOS7, 3089ad2be7SAbhilash Kesavan DW_MCI_TYPE_EXYNOS7_SMU, 3191e2ca22SMårten Lindahl DW_MCI_TYPE_ARTPEC8, 32c3665006SThomas Abraham }; 33c3665006SThomas Abraham 34c3665006SThomas Abraham /* Exynos implementation specific driver private data */ 35c3665006SThomas Abraham struct dw_mci_exynos_priv_data { 36c3665006SThomas Abraham enum dw_mci_exynos_type ctrl_type; 37c3665006SThomas Abraham u8 ciu_div; 38c3665006SThomas Abraham u32 sdr_timing; 39c3665006SThomas Abraham u32 ddr_timing; 4080113132SSeungwon Jeon u32 hs400_timing; 4180113132SSeungwon Jeon u32 tuned_sample; 42c6d9dedaSSeungwon Jeon u32 cur_speed; 4380113132SSeungwon Jeon u32 dqs_delay; 4480113132SSeungwon Jeon u32 saved_dqs_en; 4580113132SSeungwon Jeon u32 saved_strobe_ctrl; 46c3665006SThomas Abraham }; 47c3665006SThomas Abraham 48c3665006SThomas Abraham static struct dw_mci_exynos_compatible { 49c3665006SThomas Abraham char *compatible; 50c3665006SThomas Abraham enum dw_mci_exynos_type ctrl_type; 51c3665006SThomas Abraham } exynos_compat[] = { 52c3665006SThomas Abraham { 53c3665006SThomas Abraham .compatible = "samsung,exynos4210-dw-mshc", 54c3665006SThomas Abraham .ctrl_type = DW_MCI_TYPE_EXYNOS4210, 55c3665006SThomas Abraham }, { 56c3665006SThomas Abraham .compatible = "samsung,exynos4412-dw-mshc", 57c3665006SThomas Abraham .ctrl_type = DW_MCI_TYPE_EXYNOS4412, 58c3665006SThomas Abraham }, { 59c3665006SThomas Abraham .compatible = "samsung,exynos5250-dw-mshc", 60c3665006SThomas Abraham .ctrl_type = DW_MCI_TYPE_EXYNOS5250, 6100fd041bSYuvaraj Kumar C D }, { 6200fd041bSYuvaraj Kumar C D .compatible = "samsung,exynos5420-dw-mshc", 6300fd041bSYuvaraj Kumar C D .ctrl_type = DW_MCI_TYPE_EXYNOS5420, 646bce431cSYuvaraj Kumar C D }, { 656bce431cSYuvaraj Kumar C D .compatible = "samsung,exynos5420-dw-mshc-smu", 666bce431cSYuvaraj Kumar C D .ctrl_type = DW_MCI_TYPE_EXYNOS5420_SMU, 6789ad2be7SAbhilash Kesavan }, { 6889ad2be7SAbhilash Kesavan .compatible = "samsung,exynos7-dw-mshc", 6989ad2be7SAbhilash Kesavan .ctrl_type = DW_MCI_TYPE_EXYNOS7, 7089ad2be7SAbhilash Kesavan }, { 7189ad2be7SAbhilash Kesavan .compatible = "samsung,exynos7-dw-mshc-smu", 7289ad2be7SAbhilash Kesavan .ctrl_type = DW_MCI_TYPE_EXYNOS7_SMU, 7391e2ca22SMårten Lindahl }, { 7491e2ca22SMårten Lindahl .compatible = "axis,artpec8-dw-mshc", 7591e2ca22SMårten Lindahl .ctrl_type = DW_MCI_TYPE_ARTPEC8, 76c3665006SThomas Abraham }, 77c3665006SThomas Abraham }; 78c3665006SThomas Abraham 7980113132SSeungwon Jeon static inline u8 dw_mci_exynos_get_ciu_div(struct dw_mci *host) 8080113132SSeungwon Jeon { 8180113132SSeungwon Jeon struct dw_mci_exynos_priv_data *priv = host->priv; 8280113132SSeungwon Jeon 8380113132SSeungwon Jeon if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS4412) 8480113132SSeungwon Jeon return EXYNOS4412_FIXED_CIU_CLK_DIV; 8580113132SSeungwon Jeon else if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS4210) 8680113132SSeungwon Jeon return EXYNOS4210_FIXED_CIU_CLK_DIV; 8780113132SSeungwon Jeon else if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 8891e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 8991e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 9080113132SSeungwon Jeon return SDMMC_CLKSEL_GET_DIV(mci_readl(host, CLKSEL64)) + 1; 9180113132SSeungwon Jeon else 9280113132SSeungwon Jeon return SDMMC_CLKSEL_GET_DIV(mci_readl(host, CLKSEL)) + 1; 9380113132SSeungwon Jeon } 9480113132SSeungwon Jeon 955659eeadSJaehoon Chung static void dw_mci_exynos_config_smu(struct dw_mci *host) 96c3665006SThomas Abraham { 97e6c784edSYuvaraj Kumar C D struct dw_mci_exynos_priv_data *priv = host->priv; 98c3665006SThomas Abraham 995659eeadSJaehoon Chung /* 1005659eeadSJaehoon Chung * If Exynos is provided the Security management, 1015659eeadSJaehoon Chung * set for non-ecryption mode at this time. 1025659eeadSJaehoon Chung */ 10389ad2be7SAbhilash Kesavan if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS5420_SMU || 10489ad2be7SAbhilash Kesavan priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU) { 1056bce431cSYuvaraj Kumar C D mci_writel(host, MPSBEGIN0, 0); 1060b5fce48SSeungwon Jeon mci_writel(host, MPSEND0, SDMMC_ENDING_SEC_NR_MAX); 1070b5fce48SSeungwon Jeon mci_writel(host, MPSCTRL0, SDMMC_MPSCTRL_SECURE_WRITE_BIT | 1080b5fce48SSeungwon Jeon SDMMC_MPSCTRL_NON_SECURE_READ_BIT | 1090b5fce48SSeungwon Jeon SDMMC_MPSCTRL_VALID | 1100b5fce48SSeungwon Jeon SDMMC_MPSCTRL_NON_SECURE_WRITE_BIT); 1116bce431cSYuvaraj Kumar C D } 1125659eeadSJaehoon Chung } 1135659eeadSJaehoon Chung 1145659eeadSJaehoon Chung static int dw_mci_exynos_priv_init(struct dw_mci *host) 1155659eeadSJaehoon Chung { 1165659eeadSJaehoon Chung struct dw_mci_exynos_priv_data *priv = host->priv; 1175659eeadSJaehoon Chung 1185659eeadSJaehoon Chung dw_mci_exynos_config_smu(host); 1196bce431cSYuvaraj Kumar C D 12080113132SSeungwon Jeon if (priv->ctrl_type >= DW_MCI_TYPE_EXYNOS5420) { 12180113132SSeungwon Jeon priv->saved_strobe_ctrl = mci_readl(host, HS400_DLINE_CTRL); 12280113132SSeungwon Jeon priv->saved_dqs_en = mci_readl(host, HS400_DQS_EN); 12380113132SSeungwon Jeon priv->saved_dqs_en |= AXI_NON_BLOCKING_WR; 12480113132SSeungwon Jeon mci_writel(host, HS400_DQS_EN, priv->saved_dqs_en); 12580113132SSeungwon Jeon if (!priv->dqs_delay) 12680113132SSeungwon Jeon priv->dqs_delay = 12780113132SSeungwon Jeon DQS_CTRL_GET_RD_DELAY(priv->saved_strobe_ctrl); 12880113132SSeungwon Jeon } 12980113132SSeungwon Jeon 130*1a6fe7bbSMårten Lindahl if (priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) { 131*1a6fe7bbSMårten Lindahl /* Quirk needed for the ARTPEC-8 SoC */ 132*1a6fe7bbSMårten Lindahl host->quirks |= DW_MMC_QUIRK_EXTENDED_TMOUT; 133*1a6fe7bbSMårten Lindahl } 134*1a6fe7bbSMårten Lindahl 135a2a1fed8SSeungwon Jeon host->bus_hz /= (priv->ciu_div + 1); 136a2a1fed8SSeungwon Jeon 137c3665006SThomas Abraham return 0; 138c3665006SThomas Abraham } 139c3665006SThomas Abraham 14080113132SSeungwon Jeon static void dw_mci_exynos_set_clksel_timing(struct dw_mci *host, u32 timing) 14180113132SSeungwon Jeon { 14280113132SSeungwon Jeon struct dw_mci_exynos_priv_data *priv = host->priv; 14380113132SSeungwon Jeon u32 clksel; 14480113132SSeungwon Jeon 14580113132SSeungwon Jeon if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 14691e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 14791e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 14880113132SSeungwon Jeon clksel = mci_readl(host, CLKSEL64); 14980113132SSeungwon Jeon else 15080113132SSeungwon Jeon clksel = mci_readl(host, CLKSEL); 15180113132SSeungwon Jeon 15280113132SSeungwon Jeon clksel = (clksel & ~SDMMC_CLKSEL_TIMING_MASK) | timing; 15380113132SSeungwon Jeon 15480113132SSeungwon Jeon if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 15591e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 15691e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 15780113132SSeungwon Jeon mci_writel(host, CLKSEL64, clksel); 15880113132SSeungwon Jeon else 15980113132SSeungwon Jeon mci_writel(host, CLKSEL, clksel); 160aaaaeb7aSJaehoon Chung 161aaaaeb7aSJaehoon Chung /* 162aaaaeb7aSJaehoon Chung * Exynos4412 and Exynos5250 extends the use of CMD register with the 163aaaaeb7aSJaehoon Chung * use of bit 29 (which is reserved on standard MSHC controllers) for 164aaaaeb7aSJaehoon Chung * optionally bypassing the HOLD register for command and data. The 165aaaaeb7aSJaehoon Chung * HOLD register should be bypassed in case there is no phase shift 166aaaaeb7aSJaehoon Chung * applied on CMD/DATA that is sent to the card. 167aaaaeb7aSJaehoon Chung */ 16842f989c0SJaehoon Chung if (!SDMMC_CLKSEL_GET_DRV_WD3(clksel) && host->slot) 16942f989c0SJaehoon Chung set_bit(DW_MMC_CARD_NO_USE_HOLD, &host->slot->flags); 17080113132SSeungwon Jeon } 17180113132SSeungwon Jeon 172cf5237efSShawn Lin #ifdef CONFIG_PM 173cf5237efSShawn Lin static int dw_mci_exynos_runtime_resume(struct device *dev) 174e2c63599SDoug Anderson { 175e2c63599SDoug Anderson struct dw_mci *host = dev_get_drvdata(dev); 176e22842ddSJaehoon Chung int ret; 177e22842ddSJaehoon Chung 178e22842ddSJaehoon Chung ret = dw_mci_runtime_resume(dev); 179e22842ddSJaehoon Chung if (ret) 180e22842ddSJaehoon Chung return ret; 181e2c63599SDoug Anderson 1825659eeadSJaehoon Chung dw_mci_exynos_config_smu(host); 183e22842ddSJaehoon Chung 184e22842ddSJaehoon Chung return ret; 185e2c63599SDoug Anderson } 186ecf7c7c5SMarek Szyprowski #endif /* CONFIG_PM */ 187ecf7c7c5SMarek Szyprowski 188ecf7c7c5SMarek Szyprowski #ifdef CONFIG_PM_SLEEP 189ecf7c7c5SMarek Szyprowski /** 190ecf7c7c5SMarek Szyprowski * dw_mci_exynos_suspend_noirq - Exynos-specific suspend code 191306c59cbSLee Jones * @dev: Device to suspend (this device) 192ecf7c7c5SMarek Szyprowski * 193ecf7c7c5SMarek Szyprowski * This ensures that device will be in runtime active state in 194ecf7c7c5SMarek Szyprowski * dw_mci_exynos_resume_noirq after calling pm_runtime_force_resume() 195ecf7c7c5SMarek Szyprowski */ 196ecf7c7c5SMarek Szyprowski static int dw_mci_exynos_suspend_noirq(struct device *dev) 197ecf7c7c5SMarek Szyprowski { 198ecf7c7c5SMarek Szyprowski pm_runtime_get_noresume(dev); 199ecf7c7c5SMarek Szyprowski return pm_runtime_force_suspend(dev); 200ecf7c7c5SMarek Szyprowski } 201e2c63599SDoug Anderson 202e2c63599SDoug Anderson /** 203e2c63599SDoug Anderson * dw_mci_exynos_resume_noirq - Exynos-specific resume code 204306c59cbSLee Jones * @dev: Device to resume (this device) 205e2c63599SDoug Anderson * 206e2c63599SDoug Anderson * On exynos5420 there is a silicon errata that will sometimes leave the 207e2c63599SDoug Anderson * WAKEUP_INT bit in the CLKSEL register asserted. This bit is 1 to indicate 208e2c63599SDoug Anderson * that it fired and we can clear it by writing a 1 back. Clear it to prevent 209e2c63599SDoug Anderson * interrupts from going off constantly. 210e2c63599SDoug Anderson * 211e2c63599SDoug Anderson * We run this code on all exynos variants because it doesn't hurt. 212e2c63599SDoug Anderson */ 213e2c63599SDoug Anderson static int dw_mci_exynos_resume_noirq(struct device *dev) 214e2c63599SDoug Anderson { 215e2c63599SDoug Anderson struct dw_mci *host = dev_get_drvdata(dev); 21689ad2be7SAbhilash Kesavan struct dw_mci_exynos_priv_data *priv = host->priv; 217e2c63599SDoug Anderson u32 clksel; 218ecf7c7c5SMarek Szyprowski int ret; 219ecf7c7c5SMarek Szyprowski 220ecf7c7c5SMarek Szyprowski ret = pm_runtime_force_resume(dev); 221ecf7c7c5SMarek Szyprowski if (ret) 222ecf7c7c5SMarek Szyprowski return ret; 223e2c63599SDoug Anderson 22489ad2be7SAbhilash Kesavan if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 22591e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 22691e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 22789ad2be7SAbhilash Kesavan clksel = mci_readl(host, CLKSEL64); 22889ad2be7SAbhilash Kesavan else 229e2c63599SDoug Anderson clksel = mci_readl(host, CLKSEL); 23089ad2be7SAbhilash Kesavan 23189ad2be7SAbhilash Kesavan if (clksel & SDMMC_CLKSEL_WAKEUP_INT) { 23289ad2be7SAbhilash Kesavan if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 23391e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 23491e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 23589ad2be7SAbhilash Kesavan mci_writel(host, CLKSEL64, clksel); 23689ad2be7SAbhilash Kesavan else 237e2c63599SDoug Anderson mci_writel(host, CLKSEL, clksel); 23889ad2be7SAbhilash Kesavan } 239e2c63599SDoug Anderson 240ecf7c7c5SMarek Szyprowski pm_runtime_put(dev); 241ecf7c7c5SMarek Szyprowski 242e2c63599SDoug Anderson return 0; 243e2c63599SDoug Anderson } 244ecf7c7c5SMarek Szyprowski #endif /* CONFIG_PM_SLEEP */ 245e2c63599SDoug Anderson 24680113132SSeungwon Jeon static void dw_mci_exynos_config_hs400(struct dw_mci *host, u32 timing) 247c3665006SThomas Abraham { 248c3665006SThomas Abraham struct dw_mci_exynos_priv_data *priv = host->priv; 24980113132SSeungwon Jeon u32 dqs, strobe; 250c3665006SThomas Abraham 25180113132SSeungwon Jeon /* 25280113132SSeungwon Jeon * Not supported to configure register 25380113132SSeungwon Jeon * related to HS400 25480113132SSeungwon Jeon */ 25591e2ca22SMårten Lindahl if ((priv->ctrl_type < DW_MCI_TYPE_EXYNOS5420) || 25691e2ca22SMårten Lindahl (priv->ctrl_type == DW_MCI_TYPE_ARTPEC8)) { 257941a659fSKrzysztof Kozlowski if (timing == MMC_TIMING_MMC_HS400) 258941a659fSKrzysztof Kozlowski dev_warn(host->dev, 259941a659fSKrzysztof Kozlowski "cannot configure HS400, unsupported chipset\n"); 26080113132SSeungwon Jeon return; 261941a659fSKrzysztof Kozlowski } 26280113132SSeungwon Jeon 26380113132SSeungwon Jeon dqs = priv->saved_dqs_en; 26480113132SSeungwon Jeon strobe = priv->saved_strobe_ctrl; 26580113132SSeungwon Jeon 26680113132SSeungwon Jeon if (timing == MMC_TIMING_MMC_HS400) { 26780113132SSeungwon Jeon dqs |= DATA_STROBE_EN; 26880113132SSeungwon Jeon strobe = DQS_CTRL_RD_DELAY(strobe, priv->dqs_delay); 26932b64b03SAnand Moon } else if (timing == MMC_TIMING_UHS_SDR104) { 27032b64b03SAnand Moon dqs &= 0xffffff00; 271c6d9dedaSSeungwon Jeon } else { 27280113132SSeungwon Jeon dqs &= ~DATA_STROBE_EN; 273c3665006SThomas Abraham } 274c3665006SThomas Abraham 27580113132SSeungwon Jeon mci_writel(host, HS400_DQS_EN, dqs); 27680113132SSeungwon Jeon mci_writel(host, HS400_DLINE_CTRL, strobe); 27780113132SSeungwon Jeon } 27880113132SSeungwon Jeon 27980113132SSeungwon Jeon static void dw_mci_exynos_adjust_clock(struct dw_mci *host, unsigned int wanted) 28080113132SSeungwon Jeon { 28180113132SSeungwon Jeon struct dw_mci_exynos_priv_data *priv = host->priv; 28280113132SSeungwon Jeon unsigned long actual; 28380113132SSeungwon Jeon u8 div; 28480113132SSeungwon Jeon int ret; 285a2a1fed8SSeungwon Jeon /* 286a2a1fed8SSeungwon Jeon * Don't care if wanted clock is zero or 287a2a1fed8SSeungwon Jeon * ciu clock is unavailable 288a2a1fed8SSeungwon Jeon */ 289a2a1fed8SSeungwon Jeon if (!wanted || IS_ERR(host->ciu_clk)) 290c6d9dedaSSeungwon Jeon return; 291c6d9dedaSSeungwon Jeon 292c6d9dedaSSeungwon Jeon /* Guaranteed minimum frequency for cclkin */ 293c6d9dedaSSeungwon Jeon if (wanted < EXYNOS_CCLKIN_MIN) 294c6d9dedaSSeungwon Jeon wanted = EXYNOS_CCLKIN_MIN; 295c6d9dedaSSeungwon Jeon 29680113132SSeungwon Jeon if (wanted == priv->cur_speed) 29780113132SSeungwon Jeon return; 29880113132SSeungwon Jeon 29980113132SSeungwon Jeon div = dw_mci_exynos_get_ciu_div(host); 30080113132SSeungwon Jeon ret = clk_set_rate(host->ciu_clk, wanted * div); 301c6d9dedaSSeungwon Jeon if (ret) 302c6d9dedaSSeungwon Jeon dev_warn(host->dev, 303c6d9dedaSSeungwon Jeon "failed to set clk-rate %u error: %d\n", 304c6d9dedaSSeungwon Jeon wanted * div, ret); 305c6d9dedaSSeungwon Jeon actual = clk_get_rate(host->ciu_clk); 306c6d9dedaSSeungwon Jeon host->bus_hz = actual / div; 307c6d9dedaSSeungwon Jeon priv->cur_speed = wanted; 308c6d9dedaSSeungwon Jeon host->current_speed = 0; 309c6d9dedaSSeungwon Jeon } 31080113132SSeungwon Jeon 31180113132SSeungwon Jeon static void dw_mci_exynos_set_ios(struct dw_mci *host, struct mmc_ios *ios) 31280113132SSeungwon Jeon { 31380113132SSeungwon Jeon struct dw_mci_exynos_priv_data *priv = host->priv; 31480113132SSeungwon Jeon unsigned int wanted = ios->clock; 31580113132SSeungwon Jeon u32 timing = ios->timing, clksel; 31680113132SSeungwon Jeon 31780113132SSeungwon Jeon switch (timing) { 31880113132SSeungwon Jeon case MMC_TIMING_MMC_HS400: 31980113132SSeungwon Jeon /* Update tuned sample timing */ 32080113132SSeungwon Jeon clksel = SDMMC_CLKSEL_UP_SAMPLE( 32180113132SSeungwon Jeon priv->hs400_timing, priv->tuned_sample); 32280113132SSeungwon Jeon wanted <<= 1; 32380113132SSeungwon Jeon break; 32480113132SSeungwon Jeon case MMC_TIMING_MMC_DDR52: 32580113132SSeungwon Jeon clksel = priv->ddr_timing; 32680113132SSeungwon Jeon /* Should be double rate for DDR mode */ 32780113132SSeungwon Jeon if (ios->bus_width == MMC_BUS_WIDTH_8) 32880113132SSeungwon Jeon wanted <<= 1; 32980113132SSeungwon Jeon break; 33032b64b03SAnand Moon case MMC_TIMING_UHS_SDR104: 33132b64b03SAnand Moon case MMC_TIMING_UHS_SDR50: 33232b64b03SAnand Moon clksel = (priv->sdr_timing & 0xfff8ffff) | 33332b64b03SAnand Moon (priv->ciu_div << 16); 33432b64b03SAnand Moon break; 33532b64b03SAnand Moon case MMC_TIMING_UHS_DDR50: 33632b64b03SAnand Moon clksel = (priv->ddr_timing & 0xfff8ffff) | 33732b64b03SAnand Moon (priv->ciu_div << 16); 33832b64b03SAnand Moon break; 33980113132SSeungwon Jeon default: 34080113132SSeungwon Jeon clksel = priv->sdr_timing; 34180113132SSeungwon Jeon } 34280113132SSeungwon Jeon 34380113132SSeungwon Jeon /* Set clock timing for the requested speed mode*/ 34480113132SSeungwon Jeon dw_mci_exynos_set_clksel_timing(host, clksel); 34580113132SSeungwon Jeon 34680113132SSeungwon Jeon /* Configure setting for HS400 */ 34780113132SSeungwon Jeon dw_mci_exynos_config_hs400(host, timing); 34880113132SSeungwon Jeon 34980113132SSeungwon Jeon /* Configure clock rate */ 35080113132SSeungwon Jeon dw_mci_exynos_adjust_clock(host, wanted); 351c6d9dedaSSeungwon Jeon } 352c6d9dedaSSeungwon Jeon 353c3665006SThomas Abraham static int dw_mci_exynos_parse_dt(struct dw_mci *host) 354c3665006SThomas Abraham { 355e6c784edSYuvaraj Kumar C D struct dw_mci_exynos_priv_data *priv; 356c3665006SThomas Abraham struct device_node *np = host->dev->of_node; 357c3665006SThomas Abraham u32 timing[2]; 358c3665006SThomas Abraham u32 div = 0; 359e6c784edSYuvaraj Kumar C D int idx; 360c3665006SThomas Abraham int ret; 361c3665006SThomas Abraham 362e6c784edSYuvaraj Kumar C D priv = devm_kzalloc(host->dev, sizeof(*priv), GFP_KERNEL); 363bf3707eaSBeomho Seo if (!priv) 364e6c784edSYuvaraj Kumar C D return -ENOMEM; 365e6c784edSYuvaraj Kumar C D 366e6c784edSYuvaraj Kumar C D for (idx = 0; idx < ARRAY_SIZE(exynos_compat); idx++) { 367e6c784edSYuvaraj Kumar C D if (of_device_is_compatible(np, exynos_compat[idx].compatible)) 368e6c784edSYuvaraj Kumar C D priv->ctrl_type = exynos_compat[idx].ctrl_type; 369e6c784edSYuvaraj Kumar C D } 370e6c784edSYuvaraj Kumar C D 371c6d9dedaSSeungwon Jeon if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS4412) 372c6d9dedaSSeungwon Jeon priv->ciu_div = EXYNOS4412_FIXED_CIU_CLK_DIV - 1; 373c6d9dedaSSeungwon Jeon else if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS4210) 374c6d9dedaSSeungwon Jeon priv->ciu_div = EXYNOS4210_FIXED_CIU_CLK_DIV - 1; 375c6d9dedaSSeungwon Jeon else { 376c3665006SThomas Abraham of_property_read_u32(np, "samsung,dw-mshc-ciu-div", &div); 377c3665006SThomas Abraham priv->ciu_div = div; 378c6d9dedaSSeungwon Jeon } 379c3665006SThomas Abraham 380c3665006SThomas Abraham ret = of_property_read_u32_array(np, 381c3665006SThomas Abraham "samsung,dw-mshc-sdr-timing", timing, 2); 382c3665006SThomas Abraham if (ret) 383c3665006SThomas Abraham return ret; 384c3665006SThomas Abraham 3852d9f0bd1SYuvaraj Kumar C D priv->sdr_timing = SDMMC_CLKSEL_TIMING(timing[0], timing[1], div); 3862d9f0bd1SYuvaraj Kumar C D 387c3665006SThomas Abraham ret = of_property_read_u32_array(np, 388c3665006SThomas Abraham "samsung,dw-mshc-ddr-timing", timing, 2); 389c3665006SThomas Abraham if (ret) 390c3665006SThomas Abraham return ret; 391c3665006SThomas Abraham 392c3665006SThomas Abraham priv->ddr_timing = SDMMC_CLKSEL_TIMING(timing[0], timing[1], div); 39380113132SSeungwon Jeon 39480113132SSeungwon Jeon ret = of_property_read_u32_array(np, 39580113132SSeungwon Jeon "samsung,dw-mshc-hs400-timing", timing, 2); 39680113132SSeungwon Jeon if (!ret && of_property_read_u32(np, 39780113132SSeungwon Jeon "samsung,read-strobe-delay", &priv->dqs_delay)) 39880113132SSeungwon Jeon dev_dbg(host->dev, 39980113132SSeungwon Jeon "read-strobe-delay is not found, assuming usage of default value\n"); 40080113132SSeungwon Jeon 40180113132SSeungwon Jeon priv->hs400_timing = SDMMC_CLKSEL_TIMING(timing[0], timing[1], 40280113132SSeungwon Jeon HS400_FIXED_CIU_CLK_DIV); 403e6c784edSYuvaraj Kumar C D host->priv = priv; 404c3665006SThomas Abraham return 0; 405c3665006SThomas Abraham } 406c3665006SThomas Abraham 407c537a1c5SSeungwon Jeon static inline u8 dw_mci_exynos_get_clksmpl(struct dw_mci *host) 408c537a1c5SSeungwon Jeon { 40989ad2be7SAbhilash Kesavan struct dw_mci_exynos_priv_data *priv = host->priv; 41089ad2be7SAbhilash Kesavan 41189ad2be7SAbhilash Kesavan if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 41291e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 41391e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 41489ad2be7SAbhilash Kesavan return SDMMC_CLKSEL_CCLK_SAMPLE(mci_readl(host, CLKSEL64)); 41589ad2be7SAbhilash Kesavan else 416c537a1c5SSeungwon Jeon return SDMMC_CLKSEL_CCLK_SAMPLE(mci_readl(host, CLKSEL)); 417c537a1c5SSeungwon Jeon } 418c537a1c5SSeungwon Jeon 419c537a1c5SSeungwon Jeon static inline void dw_mci_exynos_set_clksmpl(struct dw_mci *host, u8 sample) 420c537a1c5SSeungwon Jeon { 421c537a1c5SSeungwon Jeon u32 clksel; 42289ad2be7SAbhilash Kesavan struct dw_mci_exynos_priv_data *priv = host->priv; 42389ad2be7SAbhilash Kesavan 42489ad2be7SAbhilash Kesavan if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 42591e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 42691e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 42789ad2be7SAbhilash Kesavan clksel = mci_readl(host, CLKSEL64); 42889ad2be7SAbhilash Kesavan else 429c537a1c5SSeungwon Jeon clksel = mci_readl(host, CLKSEL); 43080113132SSeungwon Jeon clksel = SDMMC_CLKSEL_UP_SAMPLE(clksel, sample); 43189ad2be7SAbhilash Kesavan if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 43291e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 43391e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 43489ad2be7SAbhilash Kesavan mci_writel(host, CLKSEL64, clksel); 43589ad2be7SAbhilash Kesavan else 436c537a1c5SSeungwon Jeon mci_writel(host, CLKSEL, clksel); 437c537a1c5SSeungwon Jeon } 438c537a1c5SSeungwon Jeon 439c537a1c5SSeungwon Jeon static inline u8 dw_mci_exynos_move_next_clksmpl(struct dw_mci *host) 440c537a1c5SSeungwon Jeon { 44189ad2be7SAbhilash Kesavan struct dw_mci_exynos_priv_data *priv = host->priv; 442c537a1c5SSeungwon Jeon u32 clksel; 443c537a1c5SSeungwon Jeon u8 sample; 444c537a1c5SSeungwon Jeon 44589ad2be7SAbhilash Kesavan if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 44691e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 44791e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 44889ad2be7SAbhilash Kesavan clksel = mci_readl(host, CLKSEL64); 44989ad2be7SAbhilash Kesavan else 450c537a1c5SSeungwon Jeon clksel = mci_readl(host, CLKSEL); 45180113132SSeungwon Jeon 452c537a1c5SSeungwon Jeon sample = (clksel + 1) & 0x7; 45380113132SSeungwon Jeon clksel = SDMMC_CLKSEL_UP_SAMPLE(clksel, sample); 45480113132SSeungwon Jeon 45589ad2be7SAbhilash Kesavan if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 45691e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 45791e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 45889ad2be7SAbhilash Kesavan mci_writel(host, CLKSEL64, clksel); 45989ad2be7SAbhilash Kesavan else 460c537a1c5SSeungwon Jeon mci_writel(host, CLKSEL, clksel); 46180113132SSeungwon Jeon 462c537a1c5SSeungwon Jeon return sample; 463c537a1c5SSeungwon Jeon } 464c537a1c5SSeungwon Jeon 465c3ed0284SColin Ian King static s8 dw_mci_exynos_get_best_clksmpl(u8 candidates) 466c537a1c5SSeungwon Jeon { 467c537a1c5SSeungwon Jeon const u8 iter = 8; 468c537a1c5SSeungwon Jeon u8 __c; 469c537a1c5SSeungwon Jeon s8 i, loc = -1; 470c537a1c5SSeungwon Jeon 471c537a1c5SSeungwon Jeon for (i = 0; i < iter; i++) { 472c3ed0284SColin Ian King __c = ror8(candidates, i); 473c537a1c5SSeungwon Jeon if ((__c & 0xc7) == 0xc7) { 474c537a1c5SSeungwon Jeon loc = i; 475c537a1c5SSeungwon Jeon goto out; 476c537a1c5SSeungwon Jeon } 477c537a1c5SSeungwon Jeon } 478c537a1c5SSeungwon Jeon 479c537a1c5SSeungwon Jeon for (i = 0; i < iter; i++) { 480c3ed0284SColin Ian King __c = ror8(candidates, i); 481c537a1c5SSeungwon Jeon if ((__c & 0x83) == 0x83) { 482c537a1c5SSeungwon Jeon loc = i; 483c537a1c5SSeungwon Jeon goto out; 484c537a1c5SSeungwon Jeon } 485c537a1c5SSeungwon Jeon } 486c537a1c5SSeungwon Jeon 487697542bcSJaehoon Chung /* 488697542bcSJaehoon Chung * If there is no cadiates value, then it needs to return -EIO. 489c3ed0284SColin Ian King * If there are candidates values and don't find bset clk sample value, 490c3ed0284SColin Ian King * then use a first candidates clock sample value. 491697542bcSJaehoon Chung */ 492697542bcSJaehoon Chung for (i = 0; i < iter; i++) { 493c3ed0284SColin Ian King __c = ror8(candidates, i); 494697542bcSJaehoon Chung if ((__c & 0x1) == 0x1) { 495697542bcSJaehoon Chung loc = i; 496697542bcSJaehoon Chung goto out; 497697542bcSJaehoon Chung } 498697542bcSJaehoon Chung } 499c537a1c5SSeungwon Jeon out: 500c537a1c5SSeungwon Jeon return loc; 501c537a1c5SSeungwon Jeon } 502c537a1c5SSeungwon Jeon 5039979dbe5SChaotian Jing static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot, u32 opcode) 504c537a1c5SSeungwon Jeon { 505c537a1c5SSeungwon Jeon struct dw_mci *host = slot->host; 50680113132SSeungwon Jeon struct dw_mci_exynos_priv_data *priv = host->priv; 507c537a1c5SSeungwon Jeon struct mmc_host *mmc = slot->mmc; 508c3ed0284SColin Ian King u8 start_smpl, smpl, candidates = 0; 509479cb7cfSColin Ian King s8 found; 510c537a1c5SSeungwon Jeon int ret = 0; 511c537a1c5SSeungwon Jeon 512c537a1c5SSeungwon Jeon start_smpl = dw_mci_exynos_get_clksmpl(host); 513c537a1c5SSeungwon Jeon 514c537a1c5SSeungwon Jeon do { 515c537a1c5SSeungwon Jeon mci_writel(host, TMOUT, ~0); 516c537a1c5SSeungwon Jeon smpl = dw_mci_exynos_move_next_clksmpl(host); 517c537a1c5SSeungwon Jeon 5189979dbe5SChaotian Jing if (!mmc_send_tuning(mmc, opcode, NULL)) 519c3ed0284SColin Ian King candidates |= (1 << smpl); 5206c2c6506SUlf Hansson 521c537a1c5SSeungwon Jeon } while (start_smpl != smpl); 522c537a1c5SSeungwon Jeon 523c3ed0284SColin Ian King found = dw_mci_exynos_get_best_clksmpl(candidates); 52480113132SSeungwon Jeon if (found >= 0) { 525c537a1c5SSeungwon Jeon dw_mci_exynos_set_clksmpl(host, found); 52680113132SSeungwon Jeon priv->tuned_sample = found; 52780113132SSeungwon Jeon } else { 528c537a1c5SSeungwon Jeon ret = -EIO; 529697542bcSJaehoon Chung dev_warn(&mmc->class_dev, 530c3ed0284SColin Ian King "There is no candidates value about clksmpl!\n"); 53180113132SSeungwon Jeon } 532c537a1c5SSeungwon Jeon 533c537a1c5SSeungwon Jeon return ret; 534c537a1c5SSeungwon Jeon } 535c537a1c5SSeungwon Jeon 536c22f5e1bSWu Fengguang static int dw_mci_exynos_prepare_hs400_tuning(struct dw_mci *host, 53780113132SSeungwon Jeon struct mmc_ios *ios) 53880113132SSeungwon Jeon { 53980113132SSeungwon Jeon struct dw_mci_exynos_priv_data *priv = host->priv; 54080113132SSeungwon Jeon 54180113132SSeungwon Jeon dw_mci_exynos_set_clksel_timing(host, priv->hs400_timing); 54280113132SSeungwon Jeon dw_mci_exynos_adjust_clock(host, (ios->clock) << 1); 54380113132SSeungwon Jeon 54480113132SSeungwon Jeon return 0; 54580113132SSeungwon Jeon } 54680113132SSeungwon Jeon 54725d5417aSMårten Lindahl static void dw_mci_exynos_set_data_timeout(struct dw_mci *host, 54825d5417aSMårten Lindahl unsigned int timeout_ns) 54925d5417aSMårten Lindahl { 55025d5417aSMårten Lindahl u32 clk_div, tmout; 55125d5417aSMårten Lindahl u64 tmp; 55225d5417aSMårten Lindahl unsigned int tmp2; 55325d5417aSMårten Lindahl 55425d5417aSMårten Lindahl clk_div = (mci_readl(host, CLKDIV) & 0xFF) * 2; 55525d5417aSMårten Lindahl if (clk_div == 0) 55625d5417aSMårten Lindahl clk_div = 1; 55725d5417aSMårten Lindahl 55825d5417aSMårten Lindahl tmp = DIV_ROUND_UP_ULL((u64)timeout_ns * host->bus_hz, NSEC_PER_SEC); 55925d5417aSMårten Lindahl tmp = DIV_ROUND_UP_ULL(tmp, clk_div); 56025d5417aSMårten Lindahl 56125d5417aSMårten Lindahl /* TMOUT[7:0] (RESPONSE_TIMEOUT) */ 56225d5417aSMårten Lindahl tmout = 0xFF; /* Set maximum */ 56325d5417aSMårten Lindahl 56425d5417aSMårten Lindahl /* 56525d5417aSMårten Lindahl * Extended HW timer (max = 0x6FFFFF2): 56625d5417aSMårten Lindahl * ((TMOUT[10:8] - 1) * 0xFFFFFF + TMOUT[31:11] * 8) 56725d5417aSMårten Lindahl */ 56825d5417aSMårten Lindahl if (!tmp || tmp > 0x6FFFFF2) 56925d5417aSMårten Lindahl tmout |= (0xFFFFFF << 8); 57025d5417aSMårten Lindahl else { 57125d5417aSMårten Lindahl /* TMOUT[10:8] */ 57225d5417aSMårten Lindahl tmp2 = (((unsigned int)tmp / 0xFFFFFF) + 1) & 0x7; 57325d5417aSMårten Lindahl tmout |= tmp2 << 8; 57425d5417aSMårten Lindahl 57525d5417aSMårten Lindahl /* TMOUT[31:11] */ 57625d5417aSMårten Lindahl tmp = tmp - ((tmp2 - 1) * 0xFFFFFF); 57725d5417aSMårten Lindahl tmout |= (tmp & 0xFFFFF8) << 8; 57825d5417aSMårten Lindahl } 57925d5417aSMårten Lindahl 58025d5417aSMårten Lindahl mci_writel(host, TMOUT, tmout); 58125d5417aSMårten Lindahl dev_dbg(host->dev, "timeout_ns: %u => TMOUT[31:8]: %#08x", 58225d5417aSMårten Lindahl timeout_ns, tmout >> 8); 58325d5417aSMårten Lindahl } 58425d5417aSMårten Lindahl 58525d5417aSMårten Lindahl static u32 dw_mci_exynos_get_drto_clks(struct dw_mci *host) 58625d5417aSMårten Lindahl { 58725d5417aSMårten Lindahl u32 drto_clks; 58825d5417aSMårten Lindahl 58925d5417aSMårten Lindahl drto_clks = mci_readl(host, TMOUT) >> 8; 59025d5417aSMårten Lindahl 59125d5417aSMårten Lindahl return (((drto_clks & 0x7) - 1) * 0xFFFFFF) + ((drto_clks & 0xFFFFF8)); 59225d5417aSMårten Lindahl } 59325d5417aSMårten Lindahl 5940f6e73d0SDongjin Kim /* Common capabilities of Exynos4/Exynos5 SoC */ 5950f6e73d0SDongjin Kim static unsigned long exynos_dwmmc_caps[4] = { 596a13e8ef6SJohn Keeping MMC_CAP_1_8V_DDR | MMC_CAP_8_BIT_DATA, 597a13e8ef6SJohn Keeping 0, 598a13e8ef6SJohn Keeping 0, 599a13e8ef6SJohn Keeping 0, 600c3665006SThomas Abraham }; 601c3665006SThomas Abraham 6020f6e73d0SDongjin Kim static const struct dw_mci_drv_data exynos_drv_data = { 6030f6e73d0SDongjin Kim .caps = exynos_dwmmc_caps, 6040d84b9e5SShawn Lin .num_caps = ARRAY_SIZE(exynos_dwmmc_caps), 605a13e8ef6SJohn Keeping .common_caps = MMC_CAP_CMD23, 606c3665006SThomas Abraham .init = dw_mci_exynos_priv_init, 607c3665006SThomas Abraham .set_ios = dw_mci_exynos_set_ios, 608c3665006SThomas Abraham .parse_dt = dw_mci_exynos_parse_dt, 609c537a1c5SSeungwon Jeon .execute_tuning = dw_mci_exynos_execute_tuning, 61080113132SSeungwon Jeon .prepare_hs400_tuning = dw_mci_exynos_prepare_hs400_tuning, 611c3665006SThomas Abraham }; 612c3665006SThomas Abraham 61391e2ca22SMårten Lindahl static const struct dw_mci_drv_data artpec_drv_data = { 61491e2ca22SMårten Lindahl .common_caps = MMC_CAP_CMD23, 61591e2ca22SMårten Lindahl .init = dw_mci_exynos_priv_init, 61691e2ca22SMårten Lindahl .set_ios = dw_mci_exynos_set_ios, 61791e2ca22SMårten Lindahl .parse_dt = dw_mci_exynos_parse_dt, 61891e2ca22SMårten Lindahl .execute_tuning = dw_mci_exynos_execute_tuning, 61925d5417aSMårten Lindahl .set_data_timeout = dw_mci_exynos_set_data_timeout, 62025d5417aSMårten Lindahl .get_drto_clks = dw_mci_exynos_get_drto_clks, 62191e2ca22SMårten Lindahl }; 62291e2ca22SMårten Lindahl 623c3665006SThomas Abraham static const struct of_device_id dw_mci_exynos_match[] = { 6240f6e73d0SDongjin Kim { .compatible = "samsung,exynos4412-dw-mshc", 6250f6e73d0SDongjin Kim .data = &exynos_drv_data, }, 626c3665006SThomas Abraham { .compatible = "samsung,exynos5250-dw-mshc", 6270f6e73d0SDongjin Kim .data = &exynos_drv_data, }, 62800fd041bSYuvaraj Kumar C D { .compatible = "samsung,exynos5420-dw-mshc", 62900fd041bSYuvaraj Kumar C D .data = &exynos_drv_data, }, 6306bce431cSYuvaraj Kumar C D { .compatible = "samsung,exynos5420-dw-mshc-smu", 6316bce431cSYuvaraj Kumar C D .data = &exynos_drv_data, }, 63289ad2be7SAbhilash Kesavan { .compatible = "samsung,exynos7-dw-mshc", 63389ad2be7SAbhilash Kesavan .data = &exynos_drv_data, }, 63489ad2be7SAbhilash Kesavan { .compatible = "samsung,exynos7-dw-mshc-smu", 63589ad2be7SAbhilash Kesavan .data = &exynos_drv_data, }, 63691e2ca22SMårten Lindahl { .compatible = "axis,artpec8-dw-mshc", 63791e2ca22SMårten Lindahl .data = &artpec_drv_data, }, 638c3665006SThomas Abraham {}, 639c3665006SThomas Abraham }; 640517cb9f1SArnd Bergmann MODULE_DEVICE_TABLE(of, dw_mci_exynos_match); 641c3665006SThomas Abraham 6429665f7f2SSachin Kamat static int dw_mci_exynos_probe(struct platform_device *pdev) 643c3665006SThomas Abraham { 6448e2b36eaSArnd Bergmann const struct dw_mci_drv_data *drv_data; 645c3665006SThomas Abraham const struct of_device_id *match; 6469b93d392SJoonyoung Shim int ret; 647c3665006SThomas Abraham 648c3665006SThomas Abraham match = of_match_node(dw_mci_exynos_match, pdev->dev.of_node); 649c3665006SThomas Abraham drv_data = match->data; 6509b93d392SJoonyoung Shim 6519b93d392SJoonyoung Shim pm_runtime_get_noresume(&pdev->dev); 6529b93d392SJoonyoung Shim pm_runtime_set_active(&pdev->dev); 6539b93d392SJoonyoung Shim pm_runtime_enable(&pdev->dev); 6549b93d392SJoonyoung Shim 6559b93d392SJoonyoung Shim ret = dw_mci_pltfm_register(pdev, drv_data); 6569b93d392SJoonyoung Shim if (ret) { 6579b93d392SJoonyoung Shim pm_runtime_disable(&pdev->dev); 6589b93d392SJoonyoung Shim pm_runtime_set_suspended(&pdev->dev); 6599b93d392SJoonyoung Shim pm_runtime_put_noidle(&pdev->dev); 6609b93d392SJoonyoung Shim 6619b93d392SJoonyoung Shim return ret; 6629b93d392SJoonyoung Shim } 6639b93d392SJoonyoung Shim 6649b93d392SJoonyoung Shim return 0; 6659b93d392SJoonyoung Shim } 6669b93d392SJoonyoung Shim 6679b93d392SJoonyoung Shim static int dw_mci_exynos_remove(struct platform_device *pdev) 6689b93d392SJoonyoung Shim { 6699b93d392SJoonyoung Shim pm_runtime_disable(&pdev->dev); 6709b93d392SJoonyoung Shim pm_runtime_set_suspended(&pdev->dev); 6719b93d392SJoonyoung Shim pm_runtime_put_noidle(&pdev->dev); 6729b93d392SJoonyoung Shim 6739b93d392SJoonyoung Shim return dw_mci_pltfm_remove(pdev); 674c3665006SThomas Abraham } 675c3665006SThomas Abraham 67615a2e2abSSachin Kamat static const struct dev_pm_ops dw_mci_exynos_pmops = { 677ecf7c7c5SMarek Szyprowski SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(dw_mci_exynos_suspend_noirq, 678ecf7c7c5SMarek Szyprowski dw_mci_exynos_resume_noirq) 679cf5237efSShawn Lin SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend, 680cf5237efSShawn Lin dw_mci_exynos_runtime_resume, 681cf5237efSShawn Lin NULL) 682e2c63599SDoug Anderson }; 683e2c63599SDoug Anderson 684c3665006SThomas Abraham static struct platform_driver dw_mci_exynos_pltfm_driver = { 685c3665006SThomas Abraham .probe = dw_mci_exynos_probe, 6869b93d392SJoonyoung Shim .remove = dw_mci_exynos_remove, 687c3665006SThomas Abraham .driver = { 688c3665006SThomas Abraham .name = "dwmmc_exynos", 68921b2cec6SDouglas Anderson .probe_type = PROBE_PREFER_ASYNCHRONOUS, 69020183d50SSachin Kamat .of_match_table = dw_mci_exynos_match, 691e2c63599SDoug Anderson .pm = &dw_mci_exynos_pmops, 692c3665006SThomas Abraham }, 693c3665006SThomas Abraham }; 694c3665006SThomas Abraham 695c3665006SThomas Abraham module_platform_driver(dw_mci_exynos_pltfm_driver); 696c3665006SThomas Abraham 697c3665006SThomas Abraham MODULE_DESCRIPTION("Samsung Specific DW-MSHC Driver Extension"); 698c3665006SThomas Abraham MODULE_AUTHOR("Thomas Abraham <thomas.ab@samsung.com"); 699c3665006SThomas Abraham MODULE_LICENSE("GPL v2"); 7002fc546fdSZhangfei Gao MODULE_ALIAS("platform:dwmmc_exynos"); 701