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 130a2a1fed8SSeungwon Jeon host->bus_hz /= (priv->ciu_div + 1); 131a2a1fed8SSeungwon Jeon 132c3665006SThomas Abraham return 0; 133c3665006SThomas Abraham } 134c3665006SThomas Abraham 13580113132SSeungwon Jeon static void dw_mci_exynos_set_clksel_timing(struct dw_mci *host, u32 timing) 13680113132SSeungwon Jeon { 13780113132SSeungwon Jeon struct dw_mci_exynos_priv_data *priv = host->priv; 13880113132SSeungwon Jeon u32 clksel; 13980113132SSeungwon Jeon 14080113132SSeungwon Jeon if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 14191e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 14291e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 14380113132SSeungwon Jeon clksel = mci_readl(host, CLKSEL64); 14480113132SSeungwon Jeon else 14580113132SSeungwon Jeon clksel = mci_readl(host, CLKSEL); 14680113132SSeungwon Jeon 14780113132SSeungwon Jeon clksel = (clksel & ~SDMMC_CLKSEL_TIMING_MASK) | timing; 14880113132SSeungwon Jeon 14980113132SSeungwon Jeon if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 15091e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 15191e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 15280113132SSeungwon Jeon mci_writel(host, CLKSEL64, clksel); 15380113132SSeungwon Jeon else 15480113132SSeungwon Jeon mci_writel(host, CLKSEL, clksel); 155aaaaeb7aSJaehoon Chung 156aaaaeb7aSJaehoon Chung /* 157aaaaeb7aSJaehoon Chung * Exynos4412 and Exynos5250 extends the use of CMD register with the 158aaaaeb7aSJaehoon Chung * use of bit 29 (which is reserved on standard MSHC controllers) for 159aaaaeb7aSJaehoon Chung * optionally bypassing the HOLD register for command and data. The 160aaaaeb7aSJaehoon Chung * HOLD register should be bypassed in case there is no phase shift 161aaaaeb7aSJaehoon Chung * applied on CMD/DATA that is sent to the card. 162aaaaeb7aSJaehoon Chung */ 16342f989c0SJaehoon Chung if (!SDMMC_CLKSEL_GET_DRV_WD3(clksel) && host->slot) 16442f989c0SJaehoon Chung set_bit(DW_MMC_CARD_NO_USE_HOLD, &host->slot->flags); 16580113132SSeungwon Jeon } 16680113132SSeungwon Jeon 167cf5237efSShawn Lin #ifdef CONFIG_PM 168cf5237efSShawn Lin static int dw_mci_exynos_runtime_resume(struct device *dev) 169e2c63599SDoug Anderson { 170e2c63599SDoug Anderson struct dw_mci *host = dev_get_drvdata(dev); 171e22842ddSJaehoon Chung int ret; 172e22842ddSJaehoon Chung 173e22842ddSJaehoon Chung ret = dw_mci_runtime_resume(dev); 174e22842ddSJaehoon Chung if (ret) 175e22842ddSJaehoon Chung return ret; 176e2c63599SDoug Anderson 1775659eeadSJaehoon Chung dw_mci_exynos_config_smu(host); 178e22842ddSJaehoon Chung 179e22842ddSJaehoon Chung return ret; 180e2c63599SDoug Anderson } 181ecf7c7c5SMarek Szyprowski #endif /* CONFIG_PM */ 182ecf7c7c5SMarek Szyprowski 183ecf7c7c5SMarek Szyprowski #ifdef CONFIG_PM_SLEEP 184ecf7c7c5SMarek Szyprowski /** 185ecf7c7c5SMarek Szyprowski * dw_mci_exynos_suspend_noirq - Exynos-specific suspend code 186306c59cbSLee Jones * @dev: Device to suspend (this device) 187ecf7c7c5SMarek Szyprowski * 188ecf7c7c5SMarek Szyprowski * This ensures that device will be in runtime active state in 189ecf7c7c5SMarek Szyprowski * dw_mci_exynos_resume_noirq after calling pm_runtime_force_resume() 190ecf7c7c5SMarek Szyprowski */ 191ecf7c7c5SMarek Szyprowski static int dw_mci_exynos_suspend_noirq(struct device *dev) 192ecf7c7c5SMarek Szyprowski { 193ecf7c7c5SMarek Szyprowski pm_runtime_get_noresume(dev); 194ecf7c7c5SMarek Szyprowski return pm_runtime_force_suspend(dev); 195ecf7c7c5SMarek Szyprowski } 196e2c63599SDoug Anderson 197e2c63599SDoug Anderson /** 198e2c63599SDoug Anderson * dw_mci_exynos_resume_noirq - Exynos-specific resume code 199306c59cbSLee Jones * @dev: Device to resume (this device) 200e2c63599SDoug Anderson * 201e2c63599SDoug Anderson * On exynos5420 there is a silicon errata that will sometimes leave the 202e2c63599SDoug Anderson * WAKEUP_INT bit in the CLKSEL register asserted. This bit is 1 to indicate 203e2c63599SDoug Anderson * that it fired and we can clear it by writing a 1 back. Clear it to prevent 204e2c63599SDoug Anderson * interrupts from going off constantly. 205e2c63599SDoug Anderson * 206e2c63599SDoug Anderson * We run this code on all exynos variants because it doesn't hurt. 207e2c63599SDoug Anderson */ 208e2c63599SDoug Anderson static int dw_mci_exynos_resume_noirq(struct device *dev) 209e2c63599SDoug Anderson { 210e2c63599SDoug Anderson struct dw_mci *host = dev_get_drvdata(dev); 21189ad2be7SAbhilash Kesavan struct dw_mci_exynos_priv_data *priv = host->priv; 212e2c63599SDoug Anderson u32 clksel; 213ecf7c7c5SMarek Szyprowski int ret; 214ecf7c7c5SMarek Szyprowski 215ecf7c7c5SMarek Szyprowski ret = pm_runtime_force_resume(dev); 216ecf7c7c5SMarek Szyprowski if (ret) 217ecf7c7c5SMarek Szyprowski return ret; 218e2c63599SDoug Anderson 21989ad2be7SAbhilash Kesavan if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 22091e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 22191e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 22289ad2be7SAbhilash Kesavan clksel = mci_readl(host, CLKSEL64); 22389ad2be7SAbhilash Kesavan else 224e2c63599SDoug Anderson clksel = mci_readl(host, CLKSEL); 22589ad2be7SAbhilash Kesavan 22689ad2be7SAbhilash Kesavan if (clksel & SDMMC_CLKSEL_WAKEUP_INT) { 22789ad2be7SAbhilash Kesavan if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 22891e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 22991e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 23089ad2be7SAbhilash Kesavan mci_writel(host, CLKSEL64, clksel); 23189ad2be7SAbhilash Kesavan else 232e2c63599SDoug Anderson mci_writel(host, CLKSEL, clksel); 23389ad2be7SAbhilash Kesavan } 234e2c63599SDoug Anderson 235ecf7c7c5SMarek Szyprowski pm_runtime_put(dev); 236ecf7c7c5SMarek Szyprowski 237e2c63599SDoug Anderson return 0; 238e2c63599SDoug Anderson } 239ecf7c7c5SMarek Szyprowski #endif /* CONFIG_PM_SLEEP */ 240e2c63599SDoug Anderson 24180113132SSeungwon Jeon static void dw_mci_exynos_config_hs400(struct dw_mci *host, u32 timing) 242c3665006SThomas Abraham { 243c3665006SThomas Abraham struct dw_mci_exynos_priv_data *priv = host->priv; 24480113132SSeungwon Jeon u32 dqs, strobe; 245c3665006SThomas Abraham 24680113132SSeungwon Jeon /* 24780113132SSeungwon Jeon * Not supported to configure register 24880113132SSeungwon Jeon * related to HS400 24980113132SSeungwon Jeon */ 25091e2ca22SMårten Lindahl if ((priv->ctrl_type < DW_MCI_TYPE_EXYNOS5420) || 25191e2ca22SMårten Lindahl (priv->ctrl_type == DW_MCI_TYPE_ARTPEC8)) { 252941a659fSKrzysztof Kozlowski if (timing == MMC_TIMING_MMC_HS400) 253941a659fSKrzysztof Kozlowski dev_warn(host->dev, 254941a659fSKrzysztof Kozlowski "cannot configure HS400, unsupported chipset\n"); 25580113132SSeungwon Jeon return; 256941a659fSKrzysztof Kozlowski } 25780113132SSeungwon Jeon 25880113132SSeungwon Jeon dqs = priv->saved_dqs_en; 25980113132SSeungwon Jeon strobe = priv->saved_strobe_ctrl; 26080113132SSeungwon Jeon 26180113132SSeungwon Jeon if (timing == MMC_TIMING_MMC_HS400) { 26280113132SSeungwon Jeon dqs |= DATA_STROBE_EN; 26380113132SSeungwon Jeon strobe = DQS_CTRL_RD_DELAY(strobe, priv->dqs_delay); 26432b64b03SAnand Moon } else if (timing == MMC_TIMING_UHS_SDR104) { 26532b64b03SAnand Moon dqs &= 0xffffff00; 266c6d9dedaSSeungwon Jeon } else { 26780113132SSeungwon Jeon dqs &= ~DATA_STROBE_EN; 268c3665006SThomas Abraham } 269c3665006SThomas Abraham 27080113132SSeungwon Jeon mci_writel(host, HS400_DQS_EN, dqs); 27180113132SSeungwon Jeon mci_writel(host, HS400_DLINE_CTRL, strobe); 27280113132SSeungwon Jeon } 27380113132SSeungwon Jeon 27480113132SSeungwon Jeon static void dw_mci_exynos_adjust_clock(struct dw_mci *host, unsigned int wanted) 27580113132SSeungwon Jeon { 27680113132SSeungwon Jeon struct dw_mci_exynos_priv_data *priv = host->priv; 27780113132SSeungwon Jeon unsigned long actual; 27880113132SSeungwon Jeon u8 div; 27980113132SSeungwon Jeon int ret; 280a2a1fed8SSeungwon Jeon /* 281a2a1fed8SSeungwon Jeon * Don't care if wanted clock is zero or 282a2a1fed8SSeungwon Jeon * ciu clock is unavailable 283a2a1fed8SSeungwon Jeon */ 284a2a1fed8SSeungwon Jeon if (!wanted || IS_ERR(host->ciu_clk)) 285c6d9dedaSSeungwon Jeon return; 286c6d9dedaSSeungwon Jeon 287c6d9dedaSSeungwon Jeon /* Guaranteed minimum frequency for cclkin */ 288c6d9dedaSSeungwon Jeon if (wanted < EXYNOS_CCLKIN_MIN) 289c6d9dedaSSeungwon Jeon wanted = EXYNOS_CCLKIN_MIN; 290c6d9dedaSSeungwon Jeon 29180113132SSeungwon Jeon if (wanted == priv->cur_speed) 29280113132SSeungwon Jeon return; 29380113132SSeungwon Jeon 29480113132SSeungwon Jeon div = dw_mci_exynos_get_ciu_div(host); 29580113132SSeungwon Jeon ret = clk_set_rate(host->ciu_clk, wanted * div); 296c6d9dedaSSeungwon Jeon if (ret) 297c6d9dedaSSeungwon Jeon dev_warn(host->dev, 298c6d9dedaSSeungwon Jeon "failed to set clk-rate %u error: %d\n", 299c6d9dedaSSeungwon Jeon wanted * div, ret); 300c6d9dedaSSeungwon Jeon actual = clk_get_rate(host->ciu_clk); 301c6d9dedaSSeungwon Jeon host->bus_hz = actual / div; 302c6d9dedaSSeungwon Jeon priv->cur_speed = wanted; 303c6d9dedaSSeungwon Jeon host->current_speed = 0; 304c6d9dedaSSeungwon Jeon } 30580113132SSeungwon Jeon 30680113132SSeungwon Jeon static void dw_mci_exynos_set_ios(struct dw_mci *host, struct mmc_ios *ios) 30780113132SSeungwon Jeon { 30880113132SSeungwon Jeon struct dw_mci_exynos_priv_data *priv = host->priv; 30980113132SSeungwon Jeon unsigned int wanted = ios->clock; 31080113132SSeungwon Jeon u32 timing = ios->timing, clksel; 31180113132SSeungwon Jeon 31280113132SSeungwon Jeon switch (timing) { 31380113132SSeungwon Jeon case MMC_TIMING_MMC_HS400: 31480113132SSeungwon Jeon /* Update tuned sample timing */ 31580113132SSeungwon Jeon clksel = SDMMC_CLKSEL_UP_SAMPLE( 31680113132SSeungwon Jeon priv->hs400_timing, priv->tuned_sample); 31780113132SSeungwon Jeon wanted <<= 1; 31880113132SSeungwon Jeon break; 31980113132SSeungwon Jeon case MMC_TIMING_MMC_DDR52: 32080113132SSeungwon Jeon clksel = priv->ddr_timing; 32180113132SSeungwon Jeon /* Should be double rate for DDR mode */ 32280113132SSeungwon Jeon if (ios->bus_width == MMC_BUS_WIDTH_8) 32380113132SSeungwon Jeon wanted <<= 1; 32480113132SSeungwon Jeon break; 32532b64b03SAnand Moon case MMC_TIMING_UHS_SDR104: 32632b64b03SAnand Moon case MMC_TIMING_UHS_SDR50: 32732b64b03SAnand Moon clksel = (priv->sdr_timing & 0xfff8ffff) | 32832b64b03SAnand Moon (priv->ciu_div << 16); 32932b64b03SAnand Moon break; 33032b64b03SAnand Moon case MMC_TIMING_UHS_DDR50: 33132b64b03SAnand Moon clksel = (priv->ddr_timing & 0xfff8ffff) | 33232b64b03SAnand Moon (priv->ciu_div << 16); 33332b64b03SAnand Moon break; 33480113132SSeungwon Jeon default: 33580113132SSeungwon Jeon clksel = priv->sdr_timing; 33680113132SSeungwon Jeon } 33780113132SSeungwon Jeon 33880113132SSeungwon Jeon /* Set clock timing for the requested speed mode*/ 33980113132SSeungwon Jeon dw_mci_exynos_set_clksel_timing(host, clksel); 34080113132SSeungwon Jeon 34180113132SSeungwon Jeon /* Configure setting for HS400 */ 34280113132SSeungwon Jeon dw_mci_exynos_config_hs400(host, timing); 34380113132SSeungwon Jeon 34480113132SSeungwon Jeon /* Configure clock rate */ 34580113132SSeungwon Jeon dw_mci_exynos_adjust_clock(host, wanted); 346c6d9dedaSSeungwon Jeon } 347c6d9dedaSSeungwon Jeon 348c3665006SThomas Abraham static int dw_mci_exynos_parse_dt(struct dw_mci *host) 349c3665006SThomas Abraham { 350e6c784edSYuvaraj Kumar C D struct dw_mci_exynos_priv_data *priv; 351c3665006SThomas Abraham struct device_node *np = host->dev->of_node; 352c3665006SThomas Abraham u32 timing[2]; 353c3665006SThomas Abraham u32 div = 0; 354e6c784edSYuvaraj Kumar C D int idx; 355c3665006SThomas Abraham int ret; 356c3665006SThomas Abraham 357e6c784edSYuvaraj Kumar C D priv = devm_kzalloc(host->dev, sizeof(*priv), GFP_KERNEL); 358bf3707eaSBeomho Seo if (!priv) 359e6c784edSYuvaraj Kumar C D return -ENOMEM; 360e6c784edSYuvaraj Kumar C D 361e6c784edSYuvaraj Kumar C D for (idx = 0; idx < ARRAY_SIZE(exynos_compat); idx++) { 362e6c784edSYuvaraj Kumar C D if (of_device_is_compatible(np, exynos_compat[idx].compatible)) 363e6c784edSYuvaraj Kumar C D priv->ctrl_type = exynos_compat[idx].ctrl_type; 364e6c784edSYuvaraj Kumar C D } 365e6c784edSYuvaraj Kumar C D 366c6d9dedaSSeungwon Jeon if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS4412) 367c6d9dedaSSeungwon Jeon priv->ciu_div = EXYNOS4412_FIXED_CIU_CLK_DIV - 1; 368c6d9dedaSSeungwon Jeon else if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS4210) 369c6d9dedaSSeungwon Jeon priv->ciu_div = EXYNOS4210_FIXED_CIU_CLK_DIV - 1; 370c6d9dedaSSeungwon Jeon else { 371c3665006SThomas Abraham of_property_read_u32(np, "samsung,dw-mshc-ciu-div", &div); 372c3665006SThomas Abraham priv->ciu_div = div; 373c6d9dedaSSeungwon Jeon } 374c3665006SThomas Abraham 375c3665006SThomas Abraham ret = of_property_read_u32_array(np, 376c3665006SThomas Abraham "samsung,dw-mshc-sdr-timing", timing, 2); 377c3665006SThomas Abraham if (ret) 378c3665006SThomas Abraham return ret; 379c3665006SThomas Abraham 3802d9f0bd1SYuvaraj Kumar C D priv->sdr_timing = SDMMC_CLKSEL_TIMING(timing[0], timing[1], div); 3812d9f0bd1SYuvaraj Kumar C D 382c3665006SThomas Abraham ret = of_property_read_u32_array(np, 383c3665006SThomas Abraham "samsung,dw-mshc-ddr-timing", timing, 2); 384c3665006SThomas Abraham if (ret) 385c3665006SThomas Abraham return ret; 386c3665006SThomas Abraham 387c3665006SThomas Abraham priv->ddr_timing = SDMMC_CLKSEL_TIMING(timing[0], timing[1], div); 38880113132SSeungwon Jeon 38980113132SSeungwon Jeon ret = of_property_read_u32_array(np, 39080113132SSeungwon Jeon "samsung,dw-mshc-hs400-timing", timing, 2); 39180113132SSeungwon Jeon if (!ret && of_property_read_u32(np, 39280113132SSeungwon Jeon "samsung,read-strobe-delay", &priv->dqs_delay)) 39380113132SSeungwon Jeon dev_dbg(host->dev, 39480113132SSeungwon Jeon "read-strobe-delay is not found, assuming usage of default value\n"); 39580113132SSeungwon Jeon 39680113132SSeungwon Jeon priv->hs400_timing = SDMMC_CLKSEL_TIMING(timing[0], timing[1], 39780113132SSeungwon Jeon HS400_FIXED_CIU_CLK_DIV); 398e6c784edSYuvaraj Kumar C D host->priv = priv; 399c3665006SThomas Abraham return 0; 400c3665006SThomas Abraham } 401c3665006SThomas Abraham 402c537a1c5SSeungwon Jeon static inline u8 dw_mci_exynos_get_clksmpl(struct dw_mci *host) 403c537a1c5SSeungwon Jeon { 40489ad2be7SAbhilash Kesavan struct dw_mci_exynos_priv_data *priv = host->priv; 40589ad2be7SAbhilash Kesavan 40689ad2be7SAbhilash Kesavan if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 40791e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 40891e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 40989ad2be7SAbhilash Kesavan return SDMMC_CLKSEL_CCLK_SAMPLE(mci_readl(host, CLKSEL64)); 41089ad2be7SAbhilash Kesavan else 411c537a1c5SSeungwon Jeon return SDMMC_CLKSEL_CCLK_SAMPLE(mci_readl(host, CLKSEL)); 412c537a1c5SSeungwon Jeon } 413c537a1c5SSeungwon Jeon 414c537a1c5SSeungwon Jeon static inline void dw_mci_exynos_set_clksmpl(struct dw_mci *host, u8 sample) 415c537a1c5SSeungwon Jeon { 416c537a1c5SSeungwon Jeon u32 clksel; 41789ad2be7SAbhilash Kesavan struct dw_mci_exynos_priv_data *priv = host->priv; 41889ad2be7SAbhilash Kesavan 41989ad2be7SAbhilash Kesavan if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 42091e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 42191e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 42289ad2be7SAbhilash Kesavan clksel = mci_readl(host, CLKSEL64); 42389ad2be7SAbhilash Kesavan else 424c537a1c5SSeungwon Jeon clksel = mci_readl(host, CLKSEL); 42580113132SSeungwon Jeon clksel = SDMMC_CLKSEL_UP_SAMPLE(clksel, sample); 42689ad2be7SAbhilash Kesavan if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 42791e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 42891e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 42989ad2be7SAbhilash Kesavan mci_writel(host, CLKSEL64, clksel); 43089ad2be7SAbhilash Kesavan else 431c537a1c5SSeungwon Jeon mci_writel(host, CLKSEL, clksel); 432c537a1c5SSeungwon Jeon } 433c537a1c5SSeungwon Jeon 434c537a1c5SSeungwon Jeon static inline u8 dw_mci_exynos_move_next_clksmpl(struct dw_mci *host) 435c537a1c5SSeungwon Jeon { 43689ad2be7SAbhilash Kesavan struct dw_mci_exynos_priv_data *priv = host->priv; 437c537a1c5SSeungwon Jeon u32 clksel; 438c537a1c5SSeungwon Jeon u8 sample; 439c537a1c5SSeungwon Jeon 44089ad2be7SAbhilash Kesavan if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 44191e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 44291e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 44389ad2be7SAbhilash Kesavan clksel = mci_readl(host, CLKSEL64); 44489ad2be7SAbhilash Kesavan else 445c537a1c5SSeungwon Jeon clksel = mci_readl(host, CLKSEL); 44680113132SSeungwon Jeon 447c537a1c5SSeungwon Jeon sample = (clksel + 1) & 0x7; 44880113132SSeungwon Jeon clksel = SDMMC_CLKSEL_UP_SAMPLE(clksel, sample); 44980113132SSeungwon Jeon 45089ad2be7SAbhilash Kesavan if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS7 || 45191e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_EXYNOS7_SMU || 45291e2ca22SMårten Lindahl priv->ctrl_type == DW_MCI_TYPE_ARTPEC8) 45389ad2be7SAbhilash Kesavan mci_writel(host, CLKSEL64, clksel); 45489ad2be7SAbhilash Kesavan else 455c537a1c5SSeungwon Jeon mci_writel(host, CLKSEL, clksel); 45680113132SSeungwon Jeon 457c537a1c5SSeungwon Jeon return sample; 458c537a1c5SSeungwon Jeon } 459c537a1c5SSeungwon Jeon 460c3ed0284SColin Ian King static s8 dw_mci_exynos_get_best_clksmpl(u8 candidates) 461c537a1c5SSeungwon Jeon { 462c537a1c5SSeungwon Jeon const u8 iter = 8; 463c537a1c5SSeungwon Jeon u8 __c; 464c537a1c5SSeungwon Jeon s8 i, loc = -1; 465c537a1c5SSeungwon Jeon 466c537a1c5SSeungwon Jeon for (i = 0; i < iter; i++) { 467c3ed0284SColin Ian King __c = ror8(candidates, i); 468c537a1c5SSeungwon Jeon if ((__c & 0xc7) == 0xc7) { 469c537a1c5SSeungwon Jeon loc = i; 470c537a1c5SSeungwon Jeon goto out; 471c537a1c5SSeungwon Jeon } 472c537a1c5SSeungwon Jeon } 473c537a1c5SSeungwon Jeon 474c537a1c5SSeungwon Jeon for (i = 0; i < iter; i++) { 475c3ed0284SColin Ian King __c = ror8(candidates, i); 476c537a1c5SSeungwon Jeon if ((__c & 0x83) == 0x83) { 477c537a1c5SSeungwon Jeon loc = i; 478c537a1c5SSeungwon Jeon goto out; 479c537a1c5SSeungwon Jeon } 480c537a1c5SSeungwon Jeon } 481c537a1c5SSeungwon Jeon 482697542bcSJaehoon Chung /* 483697542bcSJaehoon Chung * If there is no cadiates value, then it needs to return -EIO. 484c3ed0284SColin Ian King * If there are candidates values and don't find bset clk sample value, 485c3ed0284SColin Ian King * then use a first candidates clock sample value. 486697542bcSJaehoon Chung */ 487697542bcSJaehoon Chung for (i = 0; i < iter; i++) { 488c3ed0284SColin Ian King __c = ror8(candidates, i); 489697542bcSJaehoon Chung if ((__c & 0x1) == 0x1) { 490697542bcSJaehoon Chung loc = i; 491697542bcSJaehoon Chung goto out; 492697542bcSJaehoon Chung } 493697542bcSJaehoon Chung } 494c537a1c5SSeungwon Jeon out: 495c537a1c5SSeungwon Jeon return loc; 496c537a1c5SSeungwon Jeon } 497c537a1c5SSeungwon Jeon 4989979dbe5SChaotian Jing static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot, u32 opcode) 499c537a1c5SSeungwon Jeon { 500c537a1c5SSeungwon Jeon struct dw_mci *host = slot->host; 50180113132SSeungwon Jeon struct dw_mci_exynos_priv_data *priv = host->priv; 502c537a1c5SSeungwon Jeon struct mmc_host *mmc = slot->mmc; 503c3ed0284SColin Ian King u8 start_smpl, smpl, candidates = 0; 504479cb7cfSColin Ian King s8 found; 505c537a1c5SSeungwon Jeon int ret = 0; 506c537a1c5SSeungwon Jeon 507c537a1c5SSeungwon Jeon start_smpl = dw_mci_exynos_get_clksmpl(host); 508c537a1c5SSeungwon Jeon 509c537a1c5SSeungwon Jeon do { 510c537a1c5SSeungwon Jeon mci_writel(host, TMOUT, ~0); 511c537a1c5SSeungwon Jeon smpl = dw_mci_exynos_move_next_clksmpl(host); 512c537a1c5SSeungwon Jeon 5139979dbe5SChaotian Jing if (!mmc_send_tuning(mmc, opcode, NULL)) 514c3ed0284SColin Ian King candidates |= (1 << smpl); 5156c2c6506SUlf Hansson 516c537a1c5SSeungwon Jeon } while (start_smpl != smpl); 517c537a1c5SSeungwon Jeon 518c3ed0284SColin Ian King found = dw_mci_exynos_get_best_clksmpl(candidates); 51980113132SSeungwon Jeon if (found >= 0) { 520c537a1c5SSeungwon Jeon dw_mci_exynos_set_clksmpl(host, found); 52180113132SSeungwon Jeon priv->tuned_sample = found; 52280113132SSeungwon Jeon } else { 523c537a1c5SSeungwon Jeon ret = -EIO; 524697542bcSJaehoon Chung dev_warn(&mmc->class_dev, 525c3ed0284SColin Ian King "There is no candidates value about clksmpl!\n"); 52680113132SSeungwon Jeon } 527c537a1c5SSeungwon Jeon 528c537a1c5SSeungwon Jeon return ret; 529c537a1c5SSeungwon Jeon } 530c537a1c5SSeungwon Jeon 531c22f5e1bSWu Fengguang static int dw_mci_exynos_prepare_hs400_tuning(struct dw_mci *host, 53280113132SSeungwon Jeon struct mmc_ios *ios) 53380113132SSeungwon Jeon { 53480113132SSeungwon Jeon struct dw_mci_exynos_priv_data *priv = host->priv; 53580113132SSeungwon Jeon 53680113132SSeungwon Jeon dw_mci_exynos_set_clksel_timing(host, priv->hs400_timing); 53780113132SSeungwon Jeon dw_mci_exynos_adjust_clock(host, (ios->clock) << 1); 53880113132SSeungwon Jeon 53980113132SSeungwon Jeon return 0; 54080113132SSeungwon Jeon } 54180113132SSeungwon Jeon 542*25d5417aSMårten Lindahl static void dw_mci_exynos_set_data_timeout(struct dw_mci *host, 543*25d5417aSMårten Lindahl unsigned int timeout_ns) 544*25d5417aSMårten Lindahl { 545*25d5417aSMårten Lindahl u32 clk_div, tmout; 546*25d5417aSMårten Lindahl u64 tmp; 547*25d5417aSMårten Lindahl unsigned int tmp2; 548*25d5417aSMårten Lindahl 549*25d5417aSMårten Lindahl clk_div = (mci_readl(host, CLKDIV) & 0xFF) * 2; 550*25d5417aSMårten Lindahl if (clk_div == 0) 551*25d5417aSMårten Lindahl clk_div = 1; 552*25d5417aSMårten Lindahl 553*25d5417aSMårten Lindahl tmp = DIV_ROUND_UP_ULL((u64)timeout_ns * host->bus_hz, NSEC_PER_SEC); 554*25d5417aSMårten Lindahl tmp = DIV_ROUND_UP_ULL(tmp, clk_div); 555*25d5417aSMårten Lindahl 556*25d5417aSMårten Lindahl /* TMOUT[7:0] (RESPONSE_TIMEOUT) */ 557*25d5417aSMårten Lindahl tmout = 0xFF; /* Set maximum */ 558*25d5417aSMårten Lindahl 559*25d5417aSMårten Lindahl /* 560*25d5417aSMårten Lindahl * Extended HW timer (max = 0x6FFFFF2): 561*25d5417aSMårten Lindahl * ((TMOUT[10:8] - 1) * 0xFFFFFF + TMOUT[31:11] * 8) 562*25d5417aSMårten Lindahl */ 563*25d5417aSMårten Lindahl if (!tmp || tmp > 0x6FFFFF2) 564*25d5417aSMårten Lindahl tmout |= (0xFFFFFF << 8); 565*25d5417aSMårten Lindahl else { 566*25d5417aSMårten Lindahl /* TMOUT[10:8] */ 567*25d5417aSMårten Lindahl tmp2 = (((unsigned int)tmp / 0xFFFFFF) + 1) & 0x7; 568*25d5417aSMårten Lindahl tmout |= tmp2 << 8; 569*25d5417aSMårten Lindahl 570*25d5417aSMårten Lindahl /* TMOUT[31:11] */ 571*25d5417aSMårten Lindahl tmp = tmp - ((tmp2 - 1) * 0xFFFFFF); 572*25d5417aSMårten Lindahl tmout |= (tmp & 0xFFFFF8) << 8; 573*25d5417aSMårten Lindahl } 574*25d5417aSMårten Lindahl 575*25d5417aSMårten Lindahl mci_writel(host, TMOUT, tmout); 576*25d5417aSMårten Lindahl dev_dbg(host->dev, "timeout_ns: %u => TMOUT[31:8]: %#08x", 577*25d5417aSMårten Lindahl timeout_ns, tmout >> 8); 578*25d5417aSMårten Lindahl } 579*25d5417aSMårten Lindahl 580*25d5417aSMårten Lindahl static u32 dw_mci_exynos_get_drto_clks(struct dw_mci *host) 581*25d5417aSMårten Lindahl { 582*25d5417aSMårten Lindahl u32 drto_clks; 583*25d5417aSMårten Lindahl 584*25d5417aSMårten Lindahl drto_clks = mci_readl(host, TMOUT) >> 8; 585*25d5417aSMårten Lindahl 586*25d5417aSMårten Lindahl return (((drto_clks & 0x7) - 1) * 0xFFFFFF) + ((drto_clks & 0xFFFFF8)); 587*25d5417aSMårten Lindahl } 588*25d5417aSMårten Lindahl 5890f6e73d0SDongjin Kim /* Common capabilities of Exynos4/Exynos5 SoC */ 5900f6e73d0SDongjin Kim static unsigned long exynos_dwmmc_caps[4] = { 591a13e8ef6SJohn Keeping MMC_CAP_1_8V_DDR | MMC_CAP_8_BIT_DATA, 592a13e8ef6SJohn Keeping 0, 593a13e8ef6SJohn Keeping 0, 594a13e8ef6SJohn Keeping 0, 595c3665006SThomas Abraham }; 596c3665006SThomas Abraham 5970f6e73d0SDongjin Kim static const struct dw_mci_drv_data exynos_drv_data = { 5980f6e73d0SDongjin Kim .caps = exynos_dwmmc_caps, 5990d84b9e5SShawn Lin .num_caps = ARRAY_SIZE(exynos_dwmmc_caps), 600a13e8ef6SJohn Keeping .common_caps = MMC_CAP_CMD23, 601c3665006SThomas Abraham .init = dw_mci_exynos_priv_init, 602c3665006SThomas Abraham .set_ios = dw_mci_exynos_set_ios, 603c3665006SThomas Abraham .parse_dt = dw_mci_exynos_parse_dt, 604c537a1c5SSeungwon Jeon .execute_tuning = dw_mci_exynos_execute_tuning, 60580113132SSeungwon Jeon .prepare_hs400_tuning = dw_mci_exynos_prepare_hs400_tuning, 606c3665006SThomas Abraham }; 607c3665006SThomas Abraham 60891e2ca22SMårten Lindahl static const struct dw_mci_drv_data artpec_drv_data = { 60991e2ca22SMårten Lindahl .common_caps = MMC_CAP_CMD23, 61091e2ca22SMårten Lindahl .init = dw_mci_exynos_priv_init, 61191e2ca22SMårten Lindahl .set_ios = dw_mci_exynos_set_ios, 61291e2ca22SMårten Lindahl .parse_dt = dw_mci_exynos_parse_dt, 61391e2ca22SMårten Lindahl .execute_tuning = dw_mci_exynos_execute_tuning, 614*25d5417aSMårten Lindahl .set_data_timeout = dw_mci_exynos_set_data_timeout, 615*25d5417aSMårten Lindahl .get_drto_clks = dw_mci_exynos_get_drto_clks, 61691e2ca22SMårten Lindahl }; 61791e2ca22SMårten Lindahl 618c3665006SThomas Abraham static const struct of_device_id dw_mci_exynos_match[] = { 6190f6e73d0SDongjin Kim { .compatible = "samsung,exynos4412-dw-mshc", 6200f6e73d0SDongjin Kim .data = &exynos_drv_data, }, 621c3665006SThomas Abraham { .compatible = "samsung,exynos5250-dw-mshc", 6220f6e73d0SDongjin Kim .data = &exynos_drv_data, }, 62300fd041bSYuvaraj Kumar C D { .compatible = "samsung,exynos5420-dw-mshc", 62400fd041bSYuvaraj Kumar C D .data = &exynos_drv_data, }, 6256bce431cSYuvaraj Kumar C D { .compatible = "samsung,exynos5420-dw-mshc-smu", 6266bce431cSYuvaraj Kumar C D .data = &exynos_drv_data, }, 62789ad2be7SAbhilash Kesavan { .compatible = "samsung,exynos7-dw-mshc", 62889ad2be7SAbhilash Kesavan .data = &exynos_drv_data, }, 62989ad2be7SAbhilash Kesavan { .compatible = "samsung,exynos7-dw-mshc-smu", 63089ad2be7SAbhilash Kesavan .data = &exynos_drv_data, }, 63191e2ca22SMårten Lindahl { .compatible = "axis,artpec8-dw-mshc", 63291e2ca22SMårten Lindahl .data = &artpec_drv_data, }, 633c3665006SThomas Abraham {}, 634c3665006SThomas Abraham }; 635517cb9f1SArnd Bergmann MODULE_DEVICE_TABLE(of, dw_mci_exynos_match); 636c3665006SThomas Abraham 6379665f7f2SSachin Kamat static int dw_mci_exynos_probe(struct platform_device *pdev) 638c3665006SThomas Abraham { 6398e2b36eaSArnd Bergmann const struct dw_mci_drv_data *drv_data; 640c3665006SThomas Abraham const struct of_device_id *match; 6419b93d392SJoonyoung Shim int ret; 642c3665006SThomas Abraham 643c3665006SThomas Abraham match = of_match_node(dw_mci_exynos_match, pdev->dev.of_node); 644c3665006SThomas Abraham drv_data = match->data; 6459b93d392SJoonyoung Shim 6469b93d392SJoonyoung Shim pm_runtime_get_noresume(&pdev->dev); 6479b93d392SJoonyoung Shim pm_runtime_set_active(&pdev->dev); 6489b93d392SJoonyoung Shim pm_runtime_enable(&pdev->dev); 6499b93d392SJoonyoung Shim 6509b93d392SJoonyoung Shim ret = dw_mci_pltfm_register(pdev, drv_data); 6519b93d392SJoonyoung Shim if (ret) { 6529b93d392SJoonyoung Shim pm_runtime_disable(&pdev->dev); 6539b93d392SJoonyoung Shim pm_runtime_set_suspended(&pdev->dev); 6549b93d392SJoonyoung Shim pm_runtime_put_noidle(&pdev->dev); 6559b93d392SJoonyoung Shim 6569b93d392SJoonyoung Shim return ret; 6579b93d392SJoonyoung Shim } 6589b93d392SJoonyoung Shim 6599b93d392SJoonyoung Shim return 0; 6609b93d392SJoonyoung Shim } 6619b93d392SJoonyoung Shim 6629b93d392SJoonyoung Shim static int dw_mci_exynos_remove(struct platform_device *pdev) 6639b93d392SJoonyoung Shim { 6649b93d392SJoonyoung Shim pm_runtime_disable(&pdev->dev); 6659b93d392SJoonyoung Shim pm_runtime_set_suspended(&pdev->dev); 6669b93d392SJoonyoung Shim pm_runtime_put_noidle(&pdev->dev); 6679b93d392SJoonyoung Shim 6689b93d392SJoonyoung Shim return dw_mci_pltfm_remove(pdev); 669c3665006SThomas Abraham } 670c3665006SThomas Abraham 67115a2e2abSSachin Kamat static const struct dev_pm_ops dw_mci_exynos_pmops = { 672ecf7c7c5SMarek Szyprowski SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(dw_mci_exynos_suspend_noirq, 673ecf7c7c5SMarek Szyprowski dw_mci_exynos_resume_noirq) 674cf5237efSShawn Lin SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend, 675cf5237efSShawn Lin dw_mci_exynos_runtime_resume, 676cf5237efSShawn Lin NULL) 677e2c63599SDoug Anderson }; 678e2c63599SDoug Anderson 679c3665006SThomas Abraham static struct platform_driver dw_mci_exynos_pltfm_driver = { 680c3665006SThomas Abraham .probe = dw_mci_exynos_probe, 6819b93d392SJoonyoung Shim .remove = dw_mci_exynos_remove, 682c3665006SThomas Abraham .driver = { 683c3665006SThomas Abraham .name = "dwmmc_exynos", 68421b2cec6SDouglas Anderson .probe_type = PROBE_PREFER_ASYNCHRONOUS, 68520183d50SSachin Kamat .of_match_table = dw_mci_exynos_match, 686e2c63599SDoug Anderson .pm = &dw_mci_exynos_pmops, 687c3665006SThomas Abraham }, 688c3665006SThomas Abraham }; 689c3665006SThomas Abraham 690c3665006SThomas Abraham module_platform_driver(dw_mci_exynos_pltfm_driver); 691c3665006SThomas Abraham 692c3665006SThomas Abraham MODULE_DESCRIPTION("Samsung Specific DW-MSHC Driver Extension"); 693c3665006SThomas Abraham MODULE_AUTHOR("Thomas Abraham <thomas.ab@samsung.com"); 694c3665006SThomas Abraham MODULE_LICENSE("GPL v2"); 6952fc546fdSZhangfei Gao MODULE_ALIAS("platform:dwmmc_exynos"); 696