Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1 | /* |
| 2 | * drivers/mmc/host/sdhci-msm.c - Qualcomm SDHCI Platform driver |
| 3 | * |
| 4 | * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 and |
| 8 | * only version 2 as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/of_device.h> |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 19 | #include <linux/delay.h> |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 20 | #include <linux/mmc/mmc.h> |
Pramod Gurav | 67e6db1 | 2016-10-21 12:12:04 +0530 | [diff] [blame] | 21 | #include <linux/pm_runtime.h> |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 22 | #include <linux/slab.h> |
Ritesh Harjani | cc392c5 | 2016-11-21 12:07:25 +0530 | [diff] [blame] | 23 | #include <linux/iopoll.h> |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 24 | |
| 25 | #include "sdhci-pltfm.h" |
| 26 | |
Georgi Djakov | 3a3ad3e | 2015-03-23 18:47:29 +0200 | [diff] [blame] | 27 | #define CORE_MCI_VERSION 0x50 |
| 28 | #define CORE_VERSION_MAJOR_SHIFT 28 |
| 29 | #define CORE_VERSION_MAJOR_MASK (0xf << CORE_VERSION_MAJOR_SHIFT) |
| 30 | #define CORE_VERSION_MINOR_MASK 0xff |
| 31 | |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 32 | #define CORE_HC_MODE 0x78 |
| 33 | #define HC_MODE_EN 0x1 |
| 34 | #define CORE_POWER 0x0 |
| 35 | #define CORE_SW_RST BIT(7) |
Venkat Gopalakrishnan | ff06ce4 | 2016-11-21 12:07:23 +0530 | [diff] [blame] | 36 | #define FF_CLK_SW_RST_DIS BIT(13) |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 37 | |
Georgi Djakov | ad81d38 | 2016-06-24 18:07:14 +0300 | [diff] [blame] | 38 | #define CORE_PWRCTL_STATUS 0xdc |
| 39 | #define CORE_PWRCTL_MASK 0xe0 |
| 40 | #define CORE_PWRCTL_CLEAR 0xe4 |
| 41 | #define CORE_PWRCTL_CTL 0xe8 |
| 42 | #define CORE_PWRCTL_BUS_OFF BIT(0) |
| 43 | #define CORE_PWRCTL_BUS_ON BIT(1) |
| 44 | #define CORE_PWRCTL_IO_LOW BIT(2) |
| 45 | #define CORE_PWRCTL_IO_HIGH BIT(3) |
| 46 | #define CORE_PWRCTL_BUS_SUCCESS BIT(0) |
| 47 | #define CORE_PWRCTL_IO_SUCCESS BIT(2) |
| 48 | #define REQ_BUS_OFF BIT(0) |
| 49 | #define REQ_BUS_ON BIT(1) |
| 50 | #define REQ_IO_LOW BIT(2) |
| 51 | #define REQ_IO_HIGH BIT(3) |
| 52 | #define INT_MASK 0xf |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 53 | #define MAX_PHASES 16 |
| 54 | #define CORE_DLL_LOCK BIT(7) |
Ritesh Harjani | 02e4293 | 2016-11-21 12:07:26 +0530 | [diff] [blame] | 55 | #define CORE_DDR_DLL_LOCK BIT(11) |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 56 | #define CORE_DLL_EN BIT(16) |
| 57 | #define CORE_CDR_EN BIT(17) |
| 58 | #define CORE_CK_OUT_EN BIT(18) |
| 59 | #define CORE_CDR_EXT_EN BIT(19) |
| 60 | #define CORE_DLL_PDN BIT(29) |
| 61 | #define CORE_DLL_RST BIT(30) |
| 62 | #define CORE_DLL_CONFIG 0x100 |
Ritesh Harjani | cc392c5 | 2016-11-21 12:07:25 +0530 | [diff] [blame] | 63 | #define CORE_CMD_DAT_TRACK_SEL BIT(0) |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 64 | #define CORE_DLL_STATUS 0x108 |
| 65 | |
Venkat Gopalakrishnan | 8373635 | 2016-11-21 12:07:16 +0530 | [diff] [blame] | 66 | #define CORE_DLL_CONFIG_2 0x1b4 |
Ritesh Harjani | 02e4293 | 2016-11-21 12:07:26 +0530 | [diff] [blame] | 67 | #define CORE_DDR_CAL_EN BIT(0) |
Venkat Gopalakrishnan | 8373635 | 2016-11-21 12:07:16 +0530 | [diff] [blame] | 68 | #define CORE_FLL_CYCLE_CNT BIT(18) |
| 69 | #define CORE_DLL_CLOCK_DISABLE BIT(21) |
| 70 | |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 71 | #define CORE_VENDOR_SPEC 0x10c |
Venkat Gopalakrishnan | 5574ddc | 2017-01-10 12:30:48 +0530 | [diff] [blame] | 72 | #define CORE_VENDOR_SPEC_POR_VAL 0xa1c |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 73 | #define CORE_CLK_PWRSAVE BIT(1) |
Venkat Gopalakrishnan | ff06ce4 | 2016-11-21 12:07:23 +0530 | [diff] [blame] | 74 | #define CORE_HC_MCLK_SEL_DFLT (2 << 8) |
| 75 | #define CORE_HC_MCLK_SEL_HS400 (3 << 8) |
| 76 | #define CORE_HC_MCLK_SEL_MASK (3 << 8) |
| 77 | #define CORE_HC_SELECT_IN_EN BIT(18) |
| 78 | #define CORE_HC_SELECT_IN_HS400 (6 << 19) |
| 79 | #define CORE_HC_SELECT_IN_MASK (7 << 19) |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 80 | |
Ritesh Harjani | cc392c5 | 2016-11-21 12:07:25 +0530 | [diff] [blame] | 81 | #define CORE_CSR_CDC_CTLR_CFG0 0x130 |
| 82 | #define CORE_SW_TRIG_FULL_CALIB BIT(16) |
| 83 | #define CORE_HW_AUTOCAL_ENA BIT(17) |
| 84 | |
| 85 | #define CORE_CSR_CDC_CTLR_CFG1 0x134 |
| 86 | #define CORE_CSR_CDC_CAL_TIMER_CFG0 0x138 |
| 87 | #define CORE_TIMER_ENA BIT(16) |
| 88 | |
| 89 | #define CORE_CSR_CDC_CAL_TIMER_CFG1 0x13C |
| 90 | #define CORE_CSR_CDC_REFCOUNT_CFG 0x140 |
| 91 | #define CORE_CSR_CDC_COARSE_CAL_CFG 0x144 |
| 92 | #define CORE_CDC_OFFSET_CFG 0x14C |
| 93 | #define CORE_CSR_CDC_DELAY_CFG 0x150 |
| 94 | #define CORE_CDC_SLAVE_DDA_CFG 0x160 |
| 95 | #define CORE_CSR_CDC_STATUS0 0x164 |
| 96 | #define CORE_CALIBRATION_DONE BIT(0) |
| 97 | |
| 98 | #define CORE_CDC_ERROR_CODE_MASK 0x7000000 |
| 99 | |
| 100 | #define CORE_CSR_CDC_GEN_CFG 0x178 |
| 101 | #define CORE_CDC_SWITCH_BYPASS_OFF BIT(0) |
| 102 | #define CORE_CDC_SWITCH_RC_EN BIT(1) |
| 103 | |
| 104 | #define CORE_DDR_200_CFG 0x184 |
| 105 | #define CORE_CDC_T4_DLY_SEL BIT(0) |
Ritesh Harjani | 44bf231 | 2017-01-10 12:30:52 +0530 | [diff] [blame^] | 106 | #define CORE_CMDIN_RCLK_EN BIT(1) |
Ritesh Harjani | cc392c5 | 2016-11-21 12:07:25 +0530 | [diff] [blame] | 107 | #define CORE_START_CDC_TRAFFIC BIT(6) |
Ritesh Harjani | 02e4293 | 2016-11-21 12:07:26 +0530 | [diff] [blame] | 108 | #define CORE_VENDOR_SPEC3 0x1b0 |
| 109 | #define CORE_PWRSAVE_DLL BIT(3) |
| 110 | |
| 111 | #define CORE_DDR_CONFIG 0x1b8 |
| 112 | #define DDR_CONFIG_POR_VAL 0x80040853 |
Ritesh Harjani | cc392c5 | 2016-11-21 12:07:25 +0530 | [diff] [blame] | 113 | |
Georgi Djakov | 3a3ad3e | 2015-03-23 18:47:29 +0200 | [diff] [blame] | 114 | #define CORE_VENDOR_SPEC_CAPABILITIES0 0x11c |
| 115 | |
Ritesh Harjani | abf270e | 2016-11-21 12:07:24 +0530 | [diff] [blame] | 116 | #define INVALID_TUNING_PHASE -1 |
Ritesh Harjani | 80031bd | 2016-11-21 12:07:17 +0530 | [diff] [blame] | 117 | #define SDHCI_MSM_MIN_CLOCK 400000 |
Venkat Gopalakrishnan | ff06ce4 | 2016-11-21 12:07:23 +0530 | [diff] [blame] | 118 | #define CORE_FREQ_100MHZ (100 * 1000 * 1000) |
Ritesh Harjani | 80031bd | 2016-11-21 12:07:17 +0530 | [diff] [blame] | 119 | |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 120 | #define CDR_SELEXT_SHIFT 20 |
| 121 | #define CDR_SELEXT_MASK (0xf << CDR_SELEXT_SHIFT) |
| 122 | #define CMUX_SHIFT_PHASE_SHIFT 24 |
| 123 | #define CMUX_SHIFT_PHASE_MASK (7 << CMUX_SHIFT_PHASE_SHIFT) |
| 124 | |
Pramod Gurav | 67e6db1 | 2016-10-21 12:12:04 +0530 | [diff] [blame] | 125 | #define MSM_MMC_AUTOSUSPEND_DELAY_MS 50 |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 126 | struct sdhci_msm_host { |
| 127 | struct platform_device *pdev; |
| 128 | void __iomem *core_mem; /* MSM SDCC mapped address */ |
Georgi Djakov | ad81d38 | 2016-06-24 18:07:14 +0300 | [diff] [blame] | 129 | int pwr_irq; /* power irq */ |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 130 | struct clk *clk; /* main SD/MMC bus clock */ |
| 131 | struct clk *pclk; /* SDHC peripheral bus clock */ |
| 132 | struct clk *bus_clk; /* SDHC bus voter clock */ |
Venkat Gopalakrishnan | 8373635 | 2016-11-21 12:07:16 +0530 | [diff] [blame] | 133 | struct clk *xo_clk; /* TCXO clk needed for FLL feature of cm_dll*/ |
Ritesh Harjani | edc609f | 2016-11-21 12:07:20 +0530 | [diff] [blame] | 134 | unsigned long clk_rate; |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 135 | struct mmc_host *mmc; |
Venkat Gopalakrishnan | 8373635 | 2016-11-21 12:07:16 +0530 | [diff] [blame] | 136 | bool use_14lpp_dll_reset; |
Venkat Gopalakrishnan | ff06ce4 | 2016-11-21 12:07:23 +0530 | [diff] [blame] | 137 | bool tuning_done; |
| 138 | bool calibration_done; |
Ritesh Harjani | abf270e | 2016-11-21 12:07:24 +0530 | [diff] [blame] | 139 | u8 saved_tuning_phase; |
Ritesh Harjani | 02e4293 | 2016-11-21 12:07:26 +0530 | [diff] [blame] | 140 | bool use_cdclp533; |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 141 | }; |
| 142 | |
Ritesh Harjani | 0fb8a3d | 2017-01-10 12:30:46 +0530 | [diff] [blame] | 143 | static unsigned int msm_get_clock_rate_for_bus_mode(struct sdhci_host *host, |
| 144 | unsigned int clock) |
| 145 | { |
| 146 | struct mmc_ios ios = host->mmc->ios; |
| 147 | /* |
| 148 | * The SDHC requires internal clock frequency to be double the |
| 149 | * actual clock that will be set for DDR mode. The controller |
| 150 | * uses the faster clock(100/400MHz) for some of its parts and |
| 151 | * send the actual required clock (50/200MHz) to the card. |
| 152 | */ |
| 153 | if (ios.timing == MMC_TIMING_UHS_DDR50 || |
| 154 | ios.timing == MMC_TIMING_MMC_DDR52 || |
Ritesh Harjani | d7507aa | 2017-01-10 12:30:51 +0530 | [diff] [blame] | 155 | ios.timing == MMC_TIMING_MMC_HS400 || |
| 156 | host->flags & SDHCI_HS400_TUNING) |
Ritesh Harjani | 0fb8a3d | 2017-01-10 12:30:46 +0530 | [diff] [blame] | 157 | clock *= 2; |
| 158 | return clock; |
| 159 | } |
| 160 | |
| 161 | static void msm_set_clock_rate_for_bus_mode(struct sdhci_host *host, |
| 162 | unsigned int clock) |
| 163 | { |
| 164 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 165 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); |
| 166 | struct mmc_ios curr_ios = host->mmc->ios; |
| 167 | int rc; |
| 168 | |
| 169 | clock = msm_get_clock_rate_for_bus_mode(host, clock); |
| 170 | rc = clk_set_rate(msm_host->clk, clock); |
| 171 | if (rc) { |
| 172 | pr_err("%s: Failed to set clock at rate %u at timing %d\n", |
| 173 | mmc_hostname(host->mmc), clock, |
| 174 | curr_ios.timing); |
| 175 | return; |
| 176 | } |
| 177 | msm_host->clk_rate = clock; |
| 178 | pr_debug("%s: Setting clock at rate %lu at timing %d\n", |
| 179 | mmc_hostname(host->mmc), clk_get_rate(msm_host->clk), |
| 180 | curr_ios.timing); |
| 181 | } |
| 182 | |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 183 | /* Platform specific tuning */ |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 184 | static inline int msm_dll_poll_ck_out_en(struct sdhci_host *host, u8 poll) |
| 185 | { |
| 186 | u32 wait_cnt = 50; |
| 187 | u8 ck_out_en; |
| 188 | struct mmc_host *mmc = host->mmc; |
| 189 | |
| 190 | /* Poll for CK_OUT_EN bit. max. poll time = 50us */ |
| 191 | ck_out_en = !!(readl_relaxed(host->ioaddr + CORE_DLL_CONFIG) & |
| 192 | CORE_CK_OUT_EN); |
| 193 | |
| 194 | while (ck_out_en != poll) { |
| 195 | if (--wait_cnt == 0) { |
| 196 | dev_err(mmc_dev(mmc), "%s: CK_OUT_EN bit is not %d\n", |
| 197 | mmc_hostname(mmc), poll); |
| 198 | return -ETIMEDOUT; |
| 199 | } |
| 200 | udelay(1); |
| 201 | |
| 202 | ck_out_en = !!(readl_relaxed(host->ioaddr + CORE_DLL_CONFIG) & |
| 203 | CORE_CK_OUT_EN); |
| 204 | } |
| 205 | |
| 206 | return 0; |
| 207 | } |
| 208 | |
| 209 | static int msm_config_cm_dll_phase(struct sdhci_host *host, u8 phase) |
| 210 | { |
| 211 | int rc; |
| 212 | static const u8 grey_coded_phase_table[] = { |
| 213 | 0x0, 0x1, 0x3, 0x2, 0x6, 0x7, 0x5, 0x4, |
| 214 | 0xc, 0xd, 0xf, 0xe, 0xa, 0xb, 0x9, 0x8 |
| 215 | }; |
| 216 | unsigned long flags; |
| 217 | u32 config; |
| 218 | struct mmc_host *mmc = host->mmc; |
| 219 | |
Ritesh Harjani | abf270e | 2016-11-21 12:07:24 +0530 | [diff] [blame] | 220 | if (phase > 0xf) |
| 221 | return -EINVAL; |
| 222 | |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 223 | spin_lock_irqsave(&host->lock, flags); |
| 224 | |
| 225 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG); |
| 226 | config &= ~(CORE_CDR_EN | CORE_CK_OUT_EN); |
| 227 | config |= (CORE_CDR_EXT_EN | CORE_DLL_EN); |
| 228 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG); |
| 229 | |
| 230 | /* Wait until CK_OUT_EN bit of DLL_CONFIG register becomes '0' */ |
| 231 | rc = msm_dll_poll_ck_out_en(host, 0); |
| 232 | if (rc) |
| 233 | goto err_out; |
| 234 | |
| 235 | /* |
| 236 | * Write the selected DLL clock output phase (0 ... 15) |
| 237 | * to CDR_SELEXT bit field of DLL_CONFIG register. |
| 238 | */ |
| 239 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG); |
| 240 | config &= ~CDR_SELEXT_MASK; |
| 241 | config |= grey_coded_phase_table[phase] << CDR_SELEXT_SHIFT; |
| 242 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG); |
| 243 | |
Ritesh Harjani | 29301f4 | 2016-11-21 12:07:13 +0530 | [diff] [blame] | 244 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG); |
| 245 | config |= CORE_CK_OUT_EN; |
| 246 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG); |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 247 | |
| 248 | /* Wait until CK_OUT_EN bit of DLL_CONFIG register becomes '1' */ |
| 249 | rc = msm_dll_poll_ck_out_en(host, 1); |
| 250 | if (rc) |
| 251 | goto err_out; |
| 252 | |
| 253 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG); |
| 254 | config |= CORE_CDR_EN; |
| 255 | config &= ~CORE_CDR_EXT_EN; |
| 256 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG); |
| 257 | goto out; |
| 258 | |
| 259 | err_out: |
| 260 | dev_err(mmc_dev(mmc), "%s: Failed to set DLL phase: %d\n", |
| 261 | mmc_hostname(mmc), phase); |
| 262 | out: |
| 263 | spin_unlock_irqrestore(&host->lock, flags); |
| 264 | return rc; |
| 265 | } |
| 266 | |
| 267 | /* |
| 268 | * Find out the greatest range of consecuitive selected |
| 269 | * DLL clock output phases that can be used as sampling |
| 270 | * setting for SD3.0 UHS-I card read operation (in SDR104 |
Venkat Gopalakrishnan | ff06ce4 | 2016-11-21 12:07:23 +0530 | [diff] [blame] | 271 | * timing mode) or for eMMC4.5 card read operation (in |
| 272 | * HS400/HS200 timing mode). |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 273 | * Select the 3/4 of the range and configure the DLL with the |
| 274 | * selected DLL clock output phase. |
| 275 | */ |
| 276 | |
| 277 | static int msm_find_most_appropriate_phase(struct sdhci_host *host, |
| 278 | u8 *phase_table, u8 total_phases) |
| 279 | { |
| 280 | int ret; |
| 281 | u8 ranges[MAX_PHASES][MAX_PHASES] = { {0}, {0} }; |
| 282 | u8 phases_per_row[MAX_PHASES] = { 0 }; |
| 283 | int row_index = 0, col_index = 0, selected_row_index = 0, curr_max = 0; |
| 284 | int i, cnt, phase_0_raw_index = 0, phase_15_raw_index = 0; |
| 285 | bool phase_0_found = false, phase_15_found = false; |
| 286 | struct mmc_host *mmc = host->mmc; |
| 287 | |
| 288 | if (!total_phases || (total_phases > MAX_PHASES)) { |
| 289 | dev_err(mmc_dev(mmc), "%s: Invalid argument: total_phases=%d\n", |
| 290 | mmc_hostname(mmc), total_phases); |
| 291 | return -EINVAL; |
| 292 | } |
| 293 | |
| 294 | for (cnt = 0; cnt < total_phases; cnt++) { |
| 295 | ranges[row_index][col_index] = phase_table[cnt]; |
| 296 | phases_per_row[row_index] += 1; |
| 297 | col_index++; |
| 298 | |
| 299 | if ((cnt + 1) == total_phases) { |
| 300 | continue; |
| 301 | /* check if next phase in phase_table is consecutive or not */ |
| 302 | } else if ((phase_table[cnt] + 1) != phase_table[cnt + 1]) { |
| 303 | row_index++; |
| 304 | col_index = 0; |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | if (row_index >= MAX_PHASES) |
| 309 | return -EINVAL; |
| 310 | |
| 311 | /* Check if phase-0 is present in first valid window? */ |
| 312 | if (!ranges[0][0]) { |
| 313 | phase_0_found = true; |
| 314 | phase_0_raw_index = 0; |
| 315 | /* Check if cycle exist between 2 valid windows */ |
| 316 | for (cnt = 1; cnt <= row_index; cnt++) { |
| 317 | if (phases_per_row[cnt]) { |
| 318 | for (i = 0; i < phases_per_row[cnt]; i++) { |
| 319 | if (ranges[cnt][i] == 15) { |
| 320 | phase_15_found = true; |
| 321 | phase_15_raw_index = cnt; |
| 322 | break; |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | /* If 2 valid windows form cycle then merge them as single window */ |
| 330 | if (phase_0_found && phase_15_found) { |
| 331 | /* number of phases in raw where phase 0 is present */ |
| 332 | u8 phases_0 = phases_per_row[phase_0_raw_index]; |
| 333 | /* number of phases in raw where phase 15 is present */ |
| 334 | u8 phases_15 = phases_per_row[phase_15_raw_index]; |
| 335 | |
| 336 | if (phases_0 + phases_15 >= MAX_PHASES) |
| 337 | /* |
| 338 | * If there are more than 1 phase windows then total |
| 339 | * number of phases in both the windows should not be |
| 340 | * more than or equal to MAX_PHASES. |
| 341 | */ |
| 342 | return -EINVAL; |
| 343 | |
| 344 | /* Merge 2 cyclic windows */ |
| 345 | i = phases_15; |
| 346 | for (cnt = 0; cnt < phases_0; cnt++) { |
| 347 | ranges[phase_15_raw_index][i] = |
| 348 | ranges[phase_0_raw_index][cnt]; |
| 349 | if (++i >= MAX_PHASES) |
| 350 | break; |
| 351 | } |
| 352 | |
| 353 | phases_per_row[phase_0_raw_index] = 0; |
| 354 | phases_per_row[phase_15_raw_index] = phases_15 + phases_0; |
| 355 | } |
| 356 | |
| 357 | for (cnt = 0; cnt <= row_index; cnt++) { |
| 358 | if (phases_per_row[cnt] > curr_max) { |
| 359 | curr_max = phases_per_row[cnt]; |
| 360 | selected_row_index = cnt; |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | i = (curr_max * 3) / 4; |
| 365 | if (i) |
| 366 | i--; |
| 367 | |
| 368 | ret = ranges[selected_row_index][i]; |
| 369 | |
| 370 | if (ret >= MAX_PHASES) { |
| 371 | ret = -EINVAL; |
| 372 | dev_err(mmc_dev(mmc), "%s: Invalid phase selected=%d\n", |
| 373 | mmc_hostname(mmc), ret); |
| 374 | } |
| 375 | |
| 376 | return ret; |
| 377 | } |
| 378 | |
| 379 | static inline void msm_cm_dll_set_freq(struct sdhci_host *host) |
| 380 | { |
| 381 | u32 mclk_freq = 0, config; |
| 382 | |
| 383 | /* Program the MCLK value to MCLK_FREQ bit field */ |
| 384 | if (host->clock <= 112000000) |
| 385 | mclk_freq = 0; |
| 386 | else if (host->clock <= 125000000) |
| 387 | mclk_freq = 1; |
| 388 | else if (host->clock <= 137000000) |
| 389 | mclk_freq = 2; |
| 390 | else if (host->clock <= 150000000) |
| 391 | mclk_freq = 3; |
| 392 | else if (host->clock <= 162000000) |
| 393 | mclk_freq = 4; |
| 394 | else if (host->clock <= 175000000) |
| 395 | mclk_freq = 5; |
| 396 | else if (host->clock <= 187000000) |
| 397 | mclk_freq = 6; |
| 398 | else if (host->clock <= 200000000) |
| 399 | mclk_freq = 7; |
| 400 | |
| 401 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG); |
| 402 | config &= ~CMUX_SHIFT_PHASE_MASK; |
| 403 | config |= mclk_freq << CMUX_SHIFT_PHASE_SHIFT; |
| 404 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG); |
| 405 | } |
| 406 | |
| 407 | /* Initialize the DLL (Programmable Delay Line) */ |
| 408 | static int msm_init_cm_dll(struct sdhci_host *host) |
| 409 | { |
| 410 | struct mmc_host *mmc = host->mmc; |
Venkat Gopalakrishnan | 8373635 | 2016-11-21 12:07:16 +0530 | [diff] [blame] | 411 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 412 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 413 | int wait_cnt = 50; |
| 414 | unsigned long flags; |
Ritesh Harjani | 29301f4 | 2016-11-21 12:07:13 +0530 | [diff] [blame] | 415 | u32 config; |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 416 | |
| 417 | spin_lock_irqsave(&host->lock, flags); |
| 418 | |
| 419 | /* |
| 420 | * Make sure that clock is always enabled when DLL |
| 421 | * tuning is in progress. Keeping PWRSAVE ON may |
| 422 | * turn off the clock. |
| 423 | */ |
Ritesh Harjani | 29301f4 | 2016-11-21 12:07:13 +0530 | [diff] [blame] | 424 | config = readl_relaxed(host->ioaddr + CORE_VENDOR_SPEC); |
| 425 | config &= ~CORE_CLK_PWRSAVE; |
| 426 | writel_relaxed(config, host->ioaddr + CORE_VENDOR_SPEC); |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 427 | |
Venkat Gopalakrishnan | 8373635 | 2016-11-21 12:07:16 +0530 | [diff] [blame] | 428 | if (msm_host->use_14lpp_dll_reset) { |
| 429 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG); |
| 430 | config &= ~CORE_CK_OUT_EN; |
| 431 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG); |
| 432 | |
| 433 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG_2); |
| 434 | config |= CORE_DLL_CLOCK_DISABLE; |
| 435 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG_2); |
| 436 | } |
| 437 | |
Ritesh Harjani | 29301f4 | 2016-11-21 12:07:13 +0530 | [diff] [blame] | 438 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG); |
| 439 | config |= CORE_DLL_RST; |
| 440 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG); |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 441 | |
Ritesh Harjani | 29301f4 | 2016-11-21 12:07:13 +0530 | [diff] [blame] | 442 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG); |
| 443 | config |= CORE_DLL_PDN; |
| 444 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG); |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 445 | msm_cm_dll_set_freq(host); |
| 446 | |
Venkat Gopalakrishnan | 8373635 | 2016-11-21 12:07:16 +0530 | [diff] [blame] | 447 | if (msm_host->use_14lpp_dll_reset && |
| 448 | !IS_ERR_OR_NULL(msm_host->xo_clk)) { |
| 449 | u32 mclk_freq = 0; |
| 450 | |
| 451 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG_2); |
| 452 | config &= CORE_FLL_CYCLE_CNT; |
| 453 | if (config) |
| 454 | mclk_freq = DIV_ROUND_CLOSEST_ULL((host->clock * 8), |
| 455 | clk_get_rate(msm_host->xo_clk)); |
| 456 | else |
| 457 | mclk_freq = DIV_ROUND_CLOSEST_ULL((host->clock * 4), |
| 458 | clk_get_rate(msm_host->xo_clk)); |
| 459 | |
| 460 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG_2); |
| 461 | config &= ~(0xFF << 10); |
| 462 | config |= mclk_freq << 10; |
| 463 | |
| 464 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG_2); |
| 465 | /* wait for 5us before enabling DLL clock */ |
| 466 | udelay(5); |
| 467 | } |
| 468 | |
Ritesh Harjani | 29301f4 | 2016-11-21 12:07:13 +0530 | [diff] [blame] | 469 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG); |
| 470 | config &= ~CORE_DLL_RST; |
| 471 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG); |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 472 | |
Ritesh Harjani | 29301f4 | 2016-11-21 12:07:13 +0530 | [diff] [blame] | 473 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG); |
| 474 | config &= ~CORE_DLL_PDN; |
| 475 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG); |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 476 | |
Venkat Gopalakrishnan | 8373635 | 2016-11-21 12:07:16 +0530 | [diff] [blame] | 477 | if (msm_host->use_14lpp_dll_reset) { |
| 478 | msm_cm_dll_set_freq(host); |
| 479 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG_2); |
| 480 | config &= ~CORE_DLL_CLOCK_DISABLE; |
| 481 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG_2); |
| 482 | } |
| 483 | |
Ritesh Harjani | 29301f4 | 2016-11-21 12:07:13 +0530 | [diff] [blame] | 484 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG); |
| 485 | config |= CORE_DLL_EN; |
| 486 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG); |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 487 | |
Ritesh Harjani | 29301f4 | 2016-11-21 12:07:13 +0530 | [diff] [blame] | 488 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG); |
| 489 | config |= CORE_CK_OUT_EN; |
| 490 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG); |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 491 | |
| 492 | /* Wait until DLL_LOCK bit of DLL_STATUS register becomes '1' */ |
| 493 | while (!(readl_relaxed(host->ioaddr + CORE_DLL_STATUS) & |
| 494 | CORE_DLL_LOCK)) { |
| 495 | /* max. wait for 50us sec for LOCK bit to be set */ |
| 496 | if (--wait_cnt == 0) { |
| 497 | dev_err(mmc_dev(mmc), "%s: DLL failed to LOCK\n", |
| 498 | mmc_hostname(mmc)); |
| 499 | spin_unlock_irqrestore(&host->lock, flags); |
| 500 | return -ETIMEDOUT; |
| 501 | } |
| 502 | udelay(1); |
| 503 | } |
| 504 | |
| 505 | spin_unlock_irqrestore(&host->lock, flags); |
| 506 | return 0; |
| 507 | } |
| 508 | |
Ritesh Harjani | b54aaa8 | 2017-01-10 12:30:45 +0530 | [diff] [blame] | 509 | static void msm_hc_select_default(struct sdhci_host *host) |
| 510 | { |
| 511 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 512 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); |
| 513 | u32 config; |
| 514 | |
| 515 | if (!msm_host->use_cdclp533) { |
| 516 | config = readl_relaxed(host->ioaddr + |
| 517 | CORE_VENDOR_SPEC3); |
| 518 | config &= ~CORE_PWRSAVE_DLL; |
| 519 | writel_relaxed(config, host->ioaddr + |
| 520 | CORE_VENDOR_SPEC3); |
| 521 | } |
| 522 | |
| 523 | config = readl_relaxed(host->ioaddr + CORE_VENDOR_SPEC); |
| 524 | config &= ~CORE_HC_MCLK_SEL_MASK; |
| 525 | config |= CORE_HC_MCLK_SEL_DFLT; |
| 526 | writel_relaxed(config, host->ioaddr + CORE_VENDOR_SPEC); |
| 527 | |
| 528 | /* |
| 529 | * Disable HC_SELECT_IN to be able to use the UHS mode select |
| 530 | * configuration from Host Control2 register for all other |
| 531 | * modes. |
| 532 | * Write 0 to HC_SELECT_IN and HC_SELECT_IN_EN field |
| 533 | * in VENDOR_SPEC_FUNC |
| 534 | */ |
| 535 | config = readl_relaxed(host->ioaddr + CORE_VENDOR_SPEC); |
| 536 | config &= ~CORE_HC_SELECT_IN_EN; |
| 537 | config &= ~CORE_HC_SELECT_IN_MASK; |
| 538 | writel_relaxed(config, host->ioaddr + CORE_VENDOR_SPEC); |
| 539 | |
| 540 | /* |
| 541 | * Make sure above writes impacting free running MCLK are completed |
| 542 | * before changing the clk_rate at GCC. |
| 543 | */ |
| 544 | wmb(); |
| 545 | } |
| 546 | |
| 547 | static void msm_hc_select_hs400(struct sdhci_host *host) |
| 548 | { |
| 549 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 550 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); |
Ritesh Harjani | 44bf231 | 2017-01-10 12:30:52 +0530 | [diff] [blame^] | 551 | struct mmc_ios ios = host->mmc->ios; |
Ritesh Harjani | b54aaa8 | 2017-01-10 12:30:45 +0530 | [diff] [blame] | 552 | u32 config, dll_lock; |
| 553 | int rc; |
| 554 | |
| 555 | /* Select the divided clock (free running MCLK/2) */ |
| 556 | config = readl_relaxed(host->ioaddr + CORE_VENDOR_SPEC); |
| 557 | config &= ~CORE_HC_MCLK_SEL_MASK; |
| 558 | config |= CORE_HC_MCLK_SEL_HS400; |
| 559 | |
| 560 | writel_relaxed(config, host->ioaddr + CORE_VENDOR_SPEC); |
| 561 | /* |
| 562 | * Select HS400 mode using the HC_SELECT_IN from VENDOR SPEC |
| 563 | * register |
| 564 | */ |
Ritesh Harjani | 44bf231 | 2017-01-10 12:30:52 +0530 | [diff] [blame^] | 565 | if ((msm_host->tuning_done || ios.enhanced_strobe) && |
| 566 | !msm_host->calibration_done) { |
Ritesh Harjani | b54aaa8 | 2017-01-10 12:30:45 +0530 | [diff] [blame] | 567 | config = readl_relaxed(host->ioaddr + CORE_VENDOR_SPEC); |
| 568 | config |= CORE_HC_SELECT_IN_HS400; |
| 569 | config |= CORE_HC_SELECT_IN_EN; |
| 570 | writel_relaxed(config, host->ioaddr + CORE_VENDOR_SPEC); |
| 571 | } |
| 572 | if (!msm_host->clk_rate && !msm_host->use_cdclp533) { |
| 573 | /* |
| 574 | * Poll on DLL_LOCK or DDR_DLL_LOCK bits in |
| 575 | * CORE_DLL_STATUS to be set. This should get set |
| 576 | * within 15 us at 200 MHz. |
| 577 | */ |
| 578 | rc = readl_relaxed_poll_timeout(host->ioaddr + |
| 579 | CORE_DLL_STATUS, |
| 580 | dll_lock, |
| 581 | (dll_lock & |
| 582 | (CORE_DLL_LOCK | |
| 583 | CORE_DDR_DLL_LOCK)), 10, |
| 584 | 1000); |
| 585 | if (rc == -ETIMEDOUT) |
| 586 | pr_err("%s: Unable to get DLL_LOCK/DDR_DLL_LOCK, dll_status: 0x%08x\n", |
| 587 | mmc_hostname(host->mmc), dll_lock); |
| 588 | } |
| 589 | /* |
| 590 | * Make sure above writes impacting free running MCLK are completed |
| 591 | * before changing the clk_rate at GCC. |
| 592 | */ |
| 593 | wmb(); |
| 594 | } |
| 595 | |
| 596 | /* |
| 597 | * sdhci_msm_hc_select_mode :- In general all timing modes are |
| 598 | * controlled via UHS mode select in Host Control2 register. |
| 599 | * eMMC specific HS200/HS400 doesn't have their respective modes |
| 600 | * defined here, hence we use these values. |
| 601 | * |
| 602 | * HS200 - SDR104 (Since they both are equivalent in functionality) |
| 603 | * HS400 - This involves multiple configurations |
| 604 | * Initially SDR104 - when tuning is required as HS200 |
| 605 | * Then when switching to DDR @ 400MHz (HS400) we use |
| 606 | * the vendor specific HC_SELECT_IN to control the mode. |
| 607 | * |
| 608 | * In addition to controlling the modes we also need to select the |
| 609 | * correct input clock for DLL depending on the mode. |
| 610 | * |
| 611 | * HS400 - divided clock (free running MCLK/2) |
| 612 | * All other modes - default (free running MCLK) |
| 613 | */ |
| 614 | void sdhci_msm_hc_select_mode(struct sdhci_host *host) |
| 615 | { |
| 616 | struct mmc_ios ios = host->mmc->ios; |
| 617 | |
Ritesh Harjani | d7507aa | 2017-01-10 12:30:51 +0530 | [diff] [blame] | 618 | if (ios.timing == MMC_TIMING_MMC_HS400 || |
| 619 | host->flags & SDHCI_HS400_TUNING) |
Ritesh Harjani | b54aaa8 | 2017-01-10 12:30:45 +0530 | [diff] [blame] | 620 | msm_hc_select_hs400(host); |
| 621 | else |
| 622 | msm_hc_select_default(host); |
| 623 | } |
| 624 | |
Ritesh Harjani | cc392c5 | 2016-11-21 12:07:25 +0530 | [diff] [blame] | 625 | static int sdhci_msm_cdclp533_calibration(struct sdhci_host *host) |
| 626 | { |
| 627 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 628 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); |
| 629 | u32 config, calib_done; |
| 630 | int ret; |
| 631 | |
| 632 | pr_debug("%s: %s: Enter\n", mmc_hostname(host->mmc), __func__); |
| 633 | |
| 634 | /* |
| 635 | * Retuning in HS400 (DDR mode) will fail, just reset the |
| 636 | * tuning block and restore the saved tuning phase. |
| 637 | */ |
| 638 | ret = msm_init_cm_dll(host); |
| 639 | if (ret) |
| 640 | goto out; |
| 641 | |
| 642 | /* Set the selected phase in delay line hw block */ |
| 643 | ret = msm_config_cm_dll_phase(host, msm_host->saved_tuning_phase); |
| 644 | if (ret) |
| 645 | goto out; |
| 646 | |
| 647 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG); |
| 648 | config |= CORE_CMD_DAT_TRACK_SEL; |
| 649 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG); |
| 650 | |
| 651 | config = readl_relaxed(host->ioaddr + CORE_DDR_200_CFG); |
| 652 | config &= ~CORE_CDC_T4_DLY_SEL; |
| 653 | writel_relaxed(config, host->ioaddr + CORE_DDR_200_CFG); |
| 654 | |
| 655 | config = readl_relaxed(host->ioaddr + CORE_CSR_CDC_GEN_CFG); |
| 656 | config &= ~CORE_CDC_SWITCH_BYPASS_OFF; |
| 657 | writel_relaxed(config, host->ioaddr + CORE_CSR_CDC_GEN_CFG); |
| 658 | |
| 659 | config = readl_relaxed(host->ioaddr + CORE_CSR_CDC_GEN_CFG); |
| 660 | config |= CORE_CDC_SWITCH_RC_EN; |
| 661 | writel_relaxed(config, host->ioaddr + CORE_CSR_CDC_GEN_CFG); |
| 662 | |
| 663 | config = readl_relaxed(host->ioaddr + CORE_DDR_200_CFG); |
| 664 | config &= ~CORE_START_CDC_TRAFFIC; |
| 665 | writel_relaxed(config, host->ioaddr + CORE_DDR_200_CFG); |
| 666 | |
| 667 | /* |
| 668 | * Perform CDC Register Initialization Sequence |
| 669 | * |
| 670 | * CORE_CSR_CDC_CTLR_CFG0 0x11800EC |
| 671 | * CORE_CSR_CDC_CTLR_CFG1 0x3011111 |
| 672 | * CORE_CSR_CDC_CAL_TIMER_CFG0 0x1201000 |
| 673 | * CORE_CSR_CDC_CAL_TIMER_CFG1 0x4 |
| 674 | * CORE_CSR_CDC_REFCOUNT_CFG 0xCB732020 |
| 675 | * CORE_CSR_CDC_COARSE_CAL_CFG 0xB19 |
| 676 | * CORE_CSR_CDC_DELAY_CFG 0x3AC |
| 677 | * CORE_CDC_OFFSET_CFG 0x0 |
| 678 | * CORE_CDC_SLAVE_DDA_CFG 0x16334 |
| 679 | */ |
| 680 | |
| 681 | writel_relaxed(0x11800EC, host->ioaddr + CORE_CSR_CDC_CTLR_CFG0); |
| 682 | writel_relaxed(0x3011111, host->ioaddr + CORE_CSR_CDC_CTLR_CFG1); |
| 683 | writel_relaxed(0x1201000, host->ioaddr + CORE_CSR_CDC_CAL_TIMER_CFG0); |
| 684 | writel_relaxed(0x4, host->ioaddr + CORE_CSR_CDC_CAL_TIMER_CFG1); |
| 685 | writel_relaxed(0xCB732020, host->ioaddr + CORE_CSR_CDC_REFCOUNT_CFG); |
| 686 | writel_relaxed(0xB19, host->ioaddr + CORE_CSR_CDC_COARSE_CAL_CFG); |
Subhash Jadavani | 083c9aa | 2017-01-10 12:30:49 +0530 | [diff] [blame] | 687 | writel_relaxed(0x4E2, host->ioaddr + CORE_CSR_CDC_DELAY_CFG); |
Ritesh Harjani | cc392c5 | 2016-11-21 12:07:25 +0530 | [diff] [blame] | 688 | writel_relaxed(0x0, host->ioaddr + CORE_CDC_OFFSET_CFG); |
| 689 | writel_relaxed(0x16334, host->ioaddr + CORE_CDC_SLAVE_DDA_CFG); |
| 690 | |
| 691 | /* CDC HW Calibration */ |
| 692 | |
| 693 | config = readl_relaxed(host->ioaddr + CORE_CSR_CDC_CTLR_CFG0); |
| 694 | config |= CORE_SW_TRIG_FULL_CALIB; |
| 695 | writel_relaxed(config, host->ioaddr + CORE_CSR_CDC_CTLR_CFG0); |
| 696 | |
| 697 | config = readl_relaxed(host->ioaddr + CORE_CSR_CDC_CTLR_CFG0); |
| 698 | config &= ~CORE_SW_TRIG_FULL_CALIB; |
| 699 | writel_relaxed(config, host->ioaddr + CORE_CSR_CDC_CTLR_CFG0); |
| 700 | |
| 701 | config = readl_relaxed(host->ioaddr + CORE_CSR_CDC_CTLR_CFG0); |
| 702 | config |= CORE_HW_AUTOCAL_ENA; |
| 703 | writel_relaxed(config, host->ioaddr + CORE_CSR_CDC_CTLR_CFG0); |
| 704 | |
| 705 | config = readl_relaxed(host->ioaddr + CORE_CSR_CDC_CAL_TIMER_CFG0); |
| 706 | config |= CORE_TIMER_ENA; |
| 707 | writel_relaxed(config, host->ioaddr + CORE_CSR_CDC_CAL_TIMER_CFG0); |
| 708 | |
| 709 | ret = readl_relaxed_poll_timeout(host->ioaddr + CORE_CSR_CDC_STATUS0, |
| 710 | calib_done, |
| 711 | (calib_done & CORE_CALIBRATION_DONE), |
| 712 | 1, 50); |
| 713 | |
| 714 | if (ret == -ETIMEDOUT) { |
| 715 | pr_err("%s: %s: CDC calibration was not completed\n", |
| 716 | mmc_hostname(host->mmc), __func__); |
| 717 | goto out; |
| 718 | } |
| 719 | |
| 720 | ret = readl_relaxed(host->ioaddr + CORE_CSR_CDC_STATUS0) |
| 721 | & CORE_CDC_ERROR_CODE_MASK; |
| 722 | if (ret) { |
| 723 | pr_err("%s: %s: CDC error code %d\n", |
| 724 | mmc_hostname(host->mmc), __func__, ret); |
| 725 | ret = -EINVAL; |
| 726 | goto out; |
| 727 | } |
| 728 | |
| 729 | config = readl_relaxed(host->ioaddr + CORE_DDR_200_CFG); |
| 730 | config |= CORE_START_CDC_TRAFFIC; |
| 731 | writel_relaxed(config, host->ioaddr + CORE_DDR_200_CFG); |
| 732 | out: |
| 733 | pr_debug("%s: %s: Exit, ret %d\n", mmc_hostname(host->mmc), |
| 734 | __func__, ret); |
| 735 | return ret; |
| 736 | } |
| 737 | |
Ritesh Harjani | 02e4293 | 2016-11-21 12:07:26 +0530 | [diff] [blame] | 738 | static int sdhci_msm_cm_dll_sdc4_calibration(struct sdhci_host *host) |
| 739 | { |
Ritesh Harjani | 44bf231 | 2017-01-10 12:30:52 +0530 | [diff] [blame^] | 740 | struct mmc_host *mmc = host->mmc; |
Ritesh Harjani | 02e4293 | 2016-11-21 12:07:26 +0530 | [diff] [blame] | 741 | u32 dll_status, config; |
| 742 | int ret; |
| 743 | |
| 744 | pr_debug("%s: %s: Enter\n", mmc_hostname(host->mmc), __func__); |
| 745 | |
| 746 | /* |
| 747 | * Currently the CORE_DDR_CONFIG register defaults to desired |
| 748 | * configuration on reset. Currently reprogramming the power on |
| 749 | * reset (POR) value in case it might have been modified by |
| 750 | * bootloaders. In the future, if this changes, then the desired |
| 751 | * values will need to be programmed appropriately. |
| 752 | */ |
| 753 | writel_relaxed(DDR_CONFIG_POR_VAL, host->ioaddr + CORE_DDR_CONFIG); |
| 754 | |
Ritesh Harjani | 44bf231 | 2017-01-10 12:30:52 +0530 | [diff] [blame^] | 755 | if (mmc->ios.enhanced_strobe) { |
| 756 | config = readl_relaxed(host->ioaddr + CORE_DDR_200_CFG); |
| 757 | config |= CORE_CMDIN_RCLK_EN; |
| 758 | writel_relaxed(config, host->ioaddr + CORE_DDR_200_CFG); |
| 759 | } |
| 760 | |
Ritesh Harjani | 02e4293 | 2016-11-21 12:07:26 +0530 | [diff] [blame] | 761 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG_2); |
| 762 | config |= CORE_DDR_CAL_EN; |
| 763 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG_2); |
| 764 | |
| 765 | ret = readl_relaxed_poll_timeout(host->ioaddr + CORE_DLL_STATUS, |
| 766 | dll_status, |
| 767 | (dll_status & CORE_DDR_DLL_LOCK), |
| 768 | 10, 1000); |
| 769 | |
| 770 | if (ret == -ETIMEDOUT) { |
| 771 | pr_err("%s: %s: CM_DLL_SDC4 calibration was not completed\n", |
| 772 | mmc_hostname(host->mmc), __func__); |
| 773 | goto out; |
| 774 | } |
| 775 | |
| 776 | config = readl_relaxed(host->ioaddr + CORE_VENDOR_SPEC3); |
| 777 | config |= CORE_PWRSAVE_DLL; |
| 778 | writel_relaxed(config, host->ioaddr + CORE_VENDOR_SPEC3); |
| 779 | |
| 780 | /* |
| 781 | * Drain writebuffer to ensure above DLL calibration |
| 782 | * and PWRSAVE DLL is enabled. |
| 783 | */ |
| 784 | wmb(); |
| 785 | out: |
| 786 | pr_debug("%s: %s: Exit, ret %d\n", mmc_hostname(host->mmc), |
| 787 | __func__, ret); |
| 788 | return ret; |
| 789 | } |
| 790 | |
| 791 | static int sdhci_msm_hs400_dll_calibration(struct sdhci_host *host) |
| 792 | { |
| 793 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 794 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); |
Ritesh Harjani | 44bf231 | 2017-01-10 12:30:52 +0530 | [diff] [blame^] | 795 | struct mmc_host *mmc = host->mmc; |
Ritesh Harjani | 02e4293 | 2016-11-21 12:07:26 +0530 | [diff] [blame] | 796 | int ret; |
| 797 | u32 config; |
| 798 | |
| 799 | pr_debug("%s: %s: Enter\n", mmc_hostname(host->mmc), __func__); |
| 800 | |
| 801 | /* |
| 802 | * Retuning in HS400 (DDR mode) will fail, just reset the |
| 803 | * tuning block and restore the saved tuning phase. |
| 804 | */ |
| 805 | ret = msm_init_cm_dll(host); |
| 806 | if (ret) |
| 807 | goto out; |
| 808 | |
Ritesh Harjani | 44bf231 | 2017-01-10 12:30:52 +0530 | [diff] [blame^] | 809 | if (!mmc->ios.enhanced_strobe) { |
| 810 | /* Set the selected phase in delay line hw block */ |
| 811 | ret = msm_config_cm_dll_phase(host, |
| 812 | msm_host->saved_tuning_phase); |
| 813 | if (ret) |
| 814 | goto out; |
| 815 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG); |
| 816 | config |= CORE_CMD_DAT_TRACK_SEL; |
| 817 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG); |
| 818 | } |
Ritesh Harjani | 02e4293 | 2016-11-21 12:07:26 +0530 | [diff] [blame] | 819 | |
Ritesh Harjani | 02e4293 | 2016-11-21 12:07:26 +0530 | [diff] [blame] | 820 | if (msm_host->use_cdclp533) |
| 821 | ret = sdhci_msm_cdclp533_calibration(host); |
| 822 | else |
| 823 | ret = sdhci_msm_cm_dll_sdc4_calibration(host); |
| 824 | out: |
| 825 | pr_debug("%s: %s: Exit, ret %d\n", mmc_hostname(host->mmc), |
| 826 | __func__, ret); |
| 827 | return ret; |
| 828 | } |
| 829 | |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 830 | static int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode) |
| 831 | { |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 832 | int tuning_seq_cnt = 3; |
Ulf Hansson | 33d7393 | 2014-12-05 12:59:41 +0100 | [diff] [blame] | 833 | u8 phase, tuned_phases[16], tuned_phase_cnt = 0; |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 834 | int rc; |
| 835 | struct mmc_host *mmc = host->mmc; |
| 836 | struct mmc_ios ios = host->mmc->ios; |
Ritesh Harjani | abf270e | 2016-11-21 12:07:24 +0530 | [diff] [blame] | 837 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 838 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 839 | |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 840 | /* |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 841 | * Tuning is required for SDR104, HS200 and HS400 cards and |
| 842 | * if clock frequency is greater than 100MHz in these modes. |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 843 | */ |
Venkat Gopalakrishnan | ff06ce4 | 2016-11-21 12:07:23 +0530 | [diff] [blame] | 844 | if (host->clock <= CORE_FREQ_100MHZ || |
| 845 | !(ios.timing == MMC_TIMING_MMC_HS400 || |
| 846 | ios.timing == MMC_TIMING_MMC_HS200 || |
| 847 | ios.timing == MMC_TIMING_UHS_SDR104)) |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 848 | return 0; |
| 849 | |
Ritesh Harjani | d7507aa | 2017-01-10 12:30:51 +0530 | [diff] [blame] | 850 | /* |
| 851 | * For HS400 tuning in HS200 timing requires: |
| 852 | * - select MCLK/2 in VENDOR_SPEC |
| 853 | * - program MCLK to 400MHz (or nearest supported) in GCC |
| 854 | */ |
| 855 | if (host->flags & SDHCI_HS400_TUNING) { |
| 856 | sdhci_msm_hc_select_mode(host); |
| 857 | msm_set_clock_rate_for_bus_mode(host, ios.clock); |
| 858 | } |
| 859 | |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 860 | retry: |
| 861 | /* First of all reset the tuning block */ |
| 862 | rc = msm_init_cm_dll(host); |
| 863 | if (rc) |
Ulf Hansson | 33d7393 | 2014-12-05 12:59:41 +0100 | [diff] [blame] | 864 | return rc; |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 865 | |
| 866 | phase = 0; |
| 867 | do { |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 868 | /* Set the phase in delay line hw block */ |
| 869 | rc = msm_config_cm_dll_phase(host, phase); |
| 870 | if (rc) |
Ulf Hansson | 33d7393 | 2014-12-05 12:59:41 +0100 | [diff] [blame] | 871 | return rc; |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 872 | |
Ritesh Harjani | abf270e | 2016-11-21 12:07:24 +0530 | [diff] [blame] | 873 | msm_host->saved_tuning_phase = phase; |
Chaotian Jing | 9979dbe | 2015-10-27 14:24:28 +0800 | [diff] [blame] | 874 | rc = mmc_send_tuning(mmc, opcode, NULL); |
Ulf Hansson | 33d7393 | 2014-12-05 12:59:41 +0100 | [diff] [blame] | 875 | if (!rc) { |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 876 | /* Tuning is successful at this tuning point */ |
| 877 | tuned_phases[tuned_phase_cnt++] = phase; |
| 878 | dev_dbg(mmc_dev(mmc), "%s: Found good phase = %d\n", |
| 879 | mmc_hostname(mmc), phase); |
| 880 | } |
| 881 | } while (++phase < ARRAY_SIZE(tuned_phases)); |
| 882 | |
| 883 | if (tuned_phase_cnt) { |
| 884 | rc = msm_find_most_appropriate_phase(host, tuned_phases, |
| 885 | tuned_phase_cnt); |
| 886 | if (rc < 0) |
Ulf Hansson | 33d7393 | 2014-12-05 12:59:41 +0100 | [diff] [blame] | 887 | return rc; |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 888 | else |
| 889 | phase = rc; |
| 890 | |
| 891 | /* |
| 892 | * Finally set the selected phase in delay |
| 893 | * line hw block. |
| 894 | */ |
| 895 | rc = msm_config_cm_dll_phase(host, phase); |
| 896 | if (rc) |
Ulf Hansson | 33d7393 | 2014-12-05 12:59:41 +0100 | [diff] [blame] | 897 | return rc; |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 898 | dev_dbg(mmc_dev(mmc), "%s: Setting the tuning phase to %d\n", |
| 899 | mmc_hostname(mmc), phase); |
| 900 | } else { |
| 901 | if (--tuning_seq_cnt) |
| 902 | goto retry; |
| 903 | /* Tuning failed */ |
| 904 | dev_dbg(mmc_dev(mmc), "%s: No tuning point found\n", |
| 905 | mmc_hostname(mmc)); |
| 906 | rc = -EIO; |
| 907 | } |
| 908 | |
Venkat Gopalakrishnan | ff06ce4 | 2016-11-21 12:07:23 +0530 | [diff] [blame] | 909 | if (!rc) |
| 910 | msm_host->tuning_done = true; |
Georgi Djakov | 415b5a7 | 2014-03-10 17:37:13 +0200 | [diff] [blame] | 911 | return rc; |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 912 | } |
| 913 | |
Ritesh Harjani | db9bd16 | 2017-01-10 12:30:47 +0530 | [diff] [blame] | 914 | /* |
| 915 | * sdhci_msm_hs400 - Calibrate the DLL for HS400 bus speed mode operation. |
Ritesh Harjani | 44bf231 | 2017-01-10 12:30:52 +0530 | [diff] [blame^] | 916 | * This needs to be done for both tuning and enhanced_strobe mode. |
Ritesh Harjani | db9bd16 | 2017-01-10 12:30:47 +0530 | [diff] [blame] | 917 | * DLL operation is only needed for clock > 100MHz. For clock <= 100MHz |
| 918 | * fixed feedback clock is used. |
| 919 | */ |
| 920 | static void sdhci_msm_hs400(struct sdhci_host *host, struct mmc_ios *ios) |
| 921 | { |
| 922 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 923 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); |
| 924 | int ret; |
| 925 | |
| 926 | if (host->clock > CORE_FREQ_100MHZ && |
Ritesh Harjani | 44bf231 | 2017-01-10 12:30:52 +0530 | [diff] [blame^] | 927 | (msm_host->tuning_done || ios->enhanced_strobe) && |
| 928 | !msm_host->calibration_done) { |
Ritesh Harjani | db9bd16 | 2017-01-10 12:30:47 +0530 | [diff] [blame] | 929 | ret = sdhci_msm_hs400_dll_calibration(host); |
| 930 | if (!ret) |
| 931 | msm_host->calibration_done = true; |
| 932 | else |
| 933 | pr_err("%s: Failed to calibrate DLL for hs400 mode (%d)\n", |
| 934 | mmc_hostname(host->mmc), ret); |
| 935 | } |
| 936 | } |
| 937 | |
Ritesh Harjani | ee32067 | 2016-07-19 17:52:25 +0300 | [diff] [blame] | 938 | static void sdhci_msm_set_uhs_signaling(struct sdhci_host *host, |
| 939 | unsigned int uhs) |
| 940 | { |
| 941 | struct mmc_host *mmc = host->mmc; |
Venkat Gopalakrishnan | ff06ce4 | 2016-11-21 12:07:23 +0530 | [diff] [blame] | 942 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 943 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); |
Ritesh Harjani | ee32067 | 2016-07-19 17:52:25 +0300 | [diff] [blame] | 944 | u16 ctrl_2; |
Venkat Gopalakrishnan | ff06ce4 | 2016-11-21 12:07:23 +0530 | [diff] [blame] | 945 | u32 config; |
Ritesh Harjani | ee32067 | 2016-07-19 17:52:25 +0300 | [diff] [blame] | 946 | |
| 947 | ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL2); |
| 948 | /* Select Bus Speed Mode for host */ |
| 949 | ctrl_2 &= ~SDHCI_CTRL_UHS_MASK; |
| 950 | switch (uhs) { |
| 951 | case MMC_TIMING_UHS_SDR12: |
| 952 | ctrl_2 |= SDHCI_CTRL_UHS_SDR12; |
| 953 | break; |
| 954 | case MMC_TIMING_UHS_SDR25: |
| 955 | ctrl_2 |= SDHCI_CTRL_UHS_SDR25; |
| 956 | break; |
| 957 | case MMC_TIMING_UHS_SDR50: |
| 958 | ctrl_2 |= SDHCI_CTRL_UHS_SDR50; |
| 959 | break; |
Venkat Gopalakrishnan | ff06ce4 | 2016-11-21 12:07:23 +0530 | [diff] [blame] | 960 | case MMC_TIMING_MMC_HS400: |
Ritesh Harjani | ee32067 | 2016-07-19 17:52:25 +0300 | [diff] [blame] | 961 | case MMC_TIMING_MMC_HS200: |
| 962 | case MMC_TIMING_UHS_SDR104: |
| 963 | ctrl_2 |= SDHCI_CTRL_UHS_SDR104; |
| 964 | break; |
| 965 | case MMC_TIMING_UHS_DDR50: |
| 966 | case MMC_TIMING_MMC_DDR52: |
| 967 | ctrl_2 |= SDHCI_CTRL_UHS_DDR50; |
| 968 | break; |
| 969 | } |
| 970 | |
| 971 | /* |
| 972 | * When clock frequency is less than 100MHz, the feedback clock must be |
| 973 | * provided and DLL must not be used so that tuning can be skipped. To |
| 974 | * provide feedback clock, the mode selection can be any value less |
| 975 | * than 3'b011 in bits [2:0] of HOST CONTROL2 register. |
| 976 | */ |
Venkat Gopalakrishnan | ff06ce4 | 2016-11-21 12:07:23 +0530 | [diff] [blame] | 977 | if (host->clock <= CORE_FREQ_100MHZ) { |
| 978 | if (uhs == MMC_TIMING_MMC_HS400 || |
| 979 | uhs == MMC_TIMING_MMC_HS200 || |
| 980 | uhs == MMC_TIMING_UHS_SDR104) |
| 981 | ctrl_2 &= ~SDHCI_CTRL_UHS_MASK; |
| 982 | /* |
| 983 | * DLL is not required for clock <= 100MHz |
| 984 | * Thus, make sure DLL it is disabled when not required |
| 985 | */ |
| 986 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG); |
| 987 | config |= CORE_DLL_RST; |
| 988 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG); |
| 989 | |
| 990 | config = readl_relaxed(host->ioaddr + CORE_DLL_CONFIG); |
| 991 | config |= CORE_DLL_PDN; |
| 992 | writel_relaxed(config, host->ioaddr + CORE_DLL_CONFIG); |
| 993 | |
| 994 | /* |
| 995 | * The DLL needs to be restored and CDCLP533 recalibrated |
| 996 | * when the clock frequency is set back to 400MHz. |
| 997 | */ |
| 998 | msm_host->calibration_done = false; |
| 999 | } |
Ritesh Harjani | ee32067 | 2016-07-19 17:52:25 +0300 | [diff] [blame] | 1000 | |
| 1001 | dev_dbg(mmc_dev(mmc), "%s: clock=%u uhs=%u ctrl_2=0x%x\n", |
| 1002 | mmc_hostname(host->mmc), host->clock, uhs, ctrl_2); |
| 1003 | sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2); |
Ritesh Harjani | cc392c5 | 2016-11-21 12:07:25 +0530 | [diff] [blame] | 1004 | |
| 1005 | spin_unlock_irq(&host->lock); |
Ritesh Harjani | db9bd16 | 2017-01-10 12:30:47 +0530 | [diff] [blame] | 1006 | |
| 1007 | if (mmc->ios.timing == MMC_TIMING_MMC_HS400) |
| 1008 | sdhci_msm_hs400(host, &mmc->ios); |
| 1009 | |
Ritesh Harjani | cc392c5 | 2016-11-21 12:07:25 +0530 | [diff] [blame] | 1010 | spin_lock_irq(&host->lock); |
Ritesh Harjani | ee32067 | 2016-07-19 17:52:25 +0300 | [diff] [blame] | 1011 | } |
| 1012 | |
Georgi Djakov | ad81d38 | 2016-06-24 18:07:14 +0300 | [diff] [blame] | 1013 | static void sdhci_msm_voltage_switch(struct sdhci_host *host) |
| 1014 | { |
| 1015 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 1016 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); |
| 1017 | u32 irq_status, irq_ack = 0; |
| 1018 | |
| 1019 | irq_status = readl_relaxed(msm_host->core_mem + CORE_PWRCTL_STATUS); |
| 1020 | irq_status &= INT_MASK; |
| 1021 | |
| 1022 | writel_relaxed(irq_status, msm_host->core_mem + CORE_PWRCTL_CLEAR); |
| 1023 | |
| 1024 | if (irq_status & (CORE_PWRCTL_BUS_ON | CORE_PWRCTL_BUS_OFF)) |
| 1025 | irq_ack |= CORE_PWRCTL_BUS_SUCCESS; |
| 1026 | if (irq_status & (CORE_PWRCTL_IO_LOW | CORE_PWRCTL_IO_HIGH)) |
| 1027 | irq_ack |= CORE_PWRCTL_IO_SUCCESS; |
| 1028 | |
| 1029 | /* |
| 1030 | * The driver has to acknowledge the interrupt, switch voltages and |
| 1031 | * report back if it succeded or not to this register. The voltage |
| 1032 | * switches are handled by the sdhci core, so just report success. |
| 1033 | */ |
| 1034 | writel_relaxed(irq_ack, msm_host->core_mem + CORE_PWRCTL_CTL); |
| 1035 | } |
| 1036 | |
| 1037 | static irqreturn_t sdhci_msm_pwr_irq(int irq, void *data) |
| 1038 | { |
| 1039 | struct sdhci_host *host = (struct sdhci_host *)data; |
| 1040 | |
| 1041 | sdhci_msm_voltage_switch(host); |
| 1042 | |
| 1043 | return IRQ_HANDLED; |
| 1044 | } |
| 1045 | |
Ritesh Harjani | 80031bd | 2016-11-21 12:07:17 +0530 | [diff] [blame] | 1046 | static unsigned int sdhci_msm_get_max_clock(struct sdhci_host *host) |
| 1047 | { |
| 1048 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 1049 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); |
| 1050 | |
| 1051 | return clk_round_rate(msm_host->clk, ULONG_MAX); |
| 1052 | } |
| 1053 | |
| 1054 | static unsigned int sdhci_msm_get_min_clock(struct sdhci_host *host) |
| 1055 | { |
| 1056 | return SDHCI_MSM_MIN_CLOCK; |
| 1057 | } |
| 1058 | |
Ritesh Harjani | edc609f | 2016-11-21 12:07:20 +0530 | [diff] [blame] | 1059 | /** |
| 1060 | * __sdhci_msm_set_clock - sdhci_msm clock control. |
| 1061 | * |
| 1062 | * Description: |
| 1063 | * MSM controller does not use internal divider and |
| 1064 | * instead directly control the GCC clock as per |
| 1065 | * HW recommendation. |
| 1066 | **/ |
| 1067 | void __sdhci_msm_set_clock(struct sdhci_host *host, unsigned int clock) |
| 1068 | { |
| 1069 | u16 clk; |
| 1070 | /* |
| 1071 | * Keep actual_clock as zero - |
| 1072 | * - since there is no divider used so no need of having actual_clock. |
| 1073 | * - MSM controller uses SDCLK for data timeout calculation. If |
| 1074 | * actual_clock is zero, host->clock is taken for calculation. |
| 1075 | */ |
| 1076 | host->mmc->actual_clock = 0; |
| 1077 | |
| 1078 | sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL); |
| 1079 | |
| 1080 | if (clock == 0) |
| 1081 | return; |
| 1082 | |
| 1083 | /* |
| 1084 | * MSM controller do not use clock divider. |
| 1085 | * Thus read SDHCI_CLOCK_CONTROL and only enable |
| 1086 | * clock with no divider value programmed. |
| 1087 | */ |
| 1088 | clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); |
| 1089 | sdhci_enable_clk(host, clk); |
| 1090 | } |
| 1091 | |
| 1092 | /* sdhci_msm_set_clock - Called with (host->lock) spinlock held. */ |
| 1093 | static void sdhci_msm_set_clock(struct sdhci_host *host, unsigned int clock) |
| 1094 | { |
| 1095 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 1096 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); |
Ritesh Harjani | edc609f | 2016-11-21 12:07:20 +0530 | [diff] [blame] | 1097 | |
| 1098 | if (!clock) { |
| 1099 | msm_host->clk_rate = clock; |
| 1100 | goto out; |
| 1101 | } |
| 1102 | |
| 1103 | spin_unlock_irq(&host->lock); |
Venkat Gopalakrishnan | ff06ce4 | 2016-11-21 12:07:23 +0530 | [diff] [blame] | 1104 | |
Ritesh Harjani | b54aaa8 | 2017-01-10 12:30:45 +0530 | [diff] [blame] | 1105 | sdhci_msm_hc_select_mode(host); |
Ritesh Harjani | edc609f | 2016-11-21 12:07:20 +0530 | [diff] [blame] | 1106 | |
Ritesh Harjani | 0fb8a3d | 2017-01-10 12:30:46 +0530 | [diff] [blame] | 1107 | msm_set_clock_rate_for_bus_mode(host, clock); |
Ritesh Harjani | edc609f | 2016-11-21 12:07:20 +0530 | [diff] [blame] | 1108 | |
Ritesh Harjani | edc609f | 2016-11-21 12:07:20 +0530 | [diff] [blame] | 1109 | spin_lock_irq(&host->lock); |
| 1110 | out: |
| 1111 | __sdhci_msm_set_clock(host, clock); |
| 1112 | } |
| 1113 | |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1114 | static const struct of_device_id sdhci_msm_dt_match[] = { |
| 1115 | { .compatible = "qcom,sdhci-msm-v4" }, |
| 1116 | {}, |
| 1117 | }; |
| 1118 | |
| 1119 | MODULE_DEVICE_TABLE(of, sdhci_msm_dt_match); |
| 1120 | |
Jisheng Zhang | a50396a | 2016-02-16 21:08:21 +0800 | [diff] [blame] | 1121 | static const struct sdhci_ops sdhci_msm_ops = { |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1122 | .platform_execute_tuning = sdhci_msm_execute_tuning, |
Stephen Boyd | ed1761d | 2014-06-10 11:27:19 -0700 | [diff] [blame] | 1123 | .reset = sdhci_reset, |
Ritesh Harjani | edc609f | 2016-11-21 12:07:20 +0530 | [diff] [blame] | 1124 | .set_clock = sdhci_msm_set_clock, |
Ritesh Harjani | 80031bd | 2016-11-21 12:07:17 +0530 | [diff] [blame] | 1125 | .get_min_clock = sdhci_msm_get_min_clock, |
| 1126 | .get_max_clock = sdhci_msm_get_max_clock, |
Stephen Boyd | ed1761d | 2014-06-10 11:27:19 -0700 | [diff] [blame] | 1127 | .set_bus_width = sdhci_set_bus_width, |
Ritesh Harjani | ee32067 | 2016-07-19 17:52:25 +0300 | [diff] [blame] | 1128 | .set_uhs_signaling = sdhci_msm_set_uhs_signaling, |
Georgi Djakov | ad81d38 | 2016-06-24 18:07:14 +0300 | [diff] [blame] | 1129 | .voltage_switch = sdhci_msm_voltage_switch, |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1130 | }; |
| 1131 | |
Jisheng Zhang | a50396a | 2016-02-16 21:08:21 +0800 | [diff] [blame] | 1132 | static const struct sdhci_pltfm_data sdhci_msm_pdata = { |
| 1133 | .quirks = SDHCI_QUIRK_BROKEN_CARD_DETECTION | |
Georgi Djakov | 9718f84 | 2016-06-24 19:24:59 +0300 | [diff] [blame] | 1134 | SDHCI_QUIRK_NO_CARD_NO_RESET | |
Ritesh Harjani | a0e3142 | 2016-11-21 12:07:18 +0530 | [diff] [blame] | 1135 | SDHCI_QUIRK_SINGLE_POWER_WRITE | |
| 1136 | SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, |
| 1137 | .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, |
Jisheng Zhang | a50396a | 2016-02-16 21:08:21 +0800 | [diff] [blame] | 1138 | .ops = &sdhci_msm_ops, |
| 1139 | }; |
| 1140 | |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1141 | static int sdhci_msm_probe(struct platform_device *pdev) |
| 1142 | { |
| 1143 | struct sdhci_host *host; |
| 1144 | struct sdhci_pltfm_host *pltfm_host; |
| 1145 | struct sdhci_msm_host *msm_host; |
| 1146 | struct resource *core_memres; |
| 1147 | int ret; |
Georgi Djakov | 3a3ad3e | 2015-03-23 18:47:29 +0200 | [diff] [blame] | 1148 | u16 host_version, core_minor; |
Ritesh Harjani | 29301f4 | 2016-11-21 12:07:13 +0530 | [diff] [blame] | 1149 | u32 core_version, config; |
Georgi Djakov | 3a3ad3e | 2015-03-23 18:47:29 +0200 | [diff] [blame] | 1150 | u8 core_major; |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1151 | |
Jisheng Zhang | 6f69953 | 2016-02-16 21:08:22 +0800 | [diff] [blame] | 1152 | host = sdhci_pltfm_init(pdev, &sdhci_msm_pdata, sizeof(*msm_host)); |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1153 | if (IS_ERR(host)) |
| 1154 | return PTR_ERR(host); |
| 1155 | |
| 1156 | pltfm_host = sdhci_priv(host); |
Jisheng Zhang | 6f69953 | 2016-02-16 21:08:22 +0800 | [diff] [blame] | 1157 | msm_host = sdhci_pltfm_priv(pltfm_host); |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1158 | msm_host->mmc = host->mmc; |
| 1159 | msm_host->pdev = pdev; |
| 1160 | |
| 1161 | ret = mmc_of_parse(host->mmc); |
| 1162 | if (ret) |
| 1163 | goto pltfm_free; |
| 1164 | |
| 1165 | sdhci_get_of_property(pdev); |
| 1166 | |
Ritesh Harjani | abf270e | 2016-11-21 12:07:24 +0530 | [diff] [blame] | 1167 | msm_host->saved_tuning_phase = INVALID_TUNING_PHASE; |
| 1168 | |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1169 | /* Setup SDCC bus voter clock. */ |
| 1170 | msm_host->bus_clk = devm_clk_get(&pdev->dev, "bus"); |
| 1171 | if (!IS_ERR(msm_host->bus_clk)) { |
| 1172 | /* Vote for max. clk rate for max. performance */ |
| 1173 | ret = clk_set_rate(msm_host->bus_clk, INT_MAX); |
| 1174 | if (ret) |
| 1175 | goto pltfm_free; |
| 1176 | ret = clk_prepare_enable(msm_host->bus_clk); |
| 1177 | if (ret) |
| 1178 | goto pltfm_free; |
| 1179 | } |
| 1180 | |
| 1181 | /* Setup main peripheral bus clock */ |
| 1182 | msm_host->pclk = devm_clk_get(&pdev->dev, "iface"); |
| 1183 | if (IS_ERR(msm_host->pclk)) { |
| 1184 | ret = PTR_ERR(msm_host->pclk); |
Colin Ian King | 2801b95 | 2016-06-23 10:52:05 +0100 | [diff] [blame] | 1185 | dev_err(&pdev->dev, "Peripheral clk setup failed (%d)\n", ret); |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1186 | goto bus_clk_disable; |
| 1187 | } |
| 1188 | |
| 1189 | ret = clk_prepare_enable(msm_host->pclk); |
| 1190 | if (ret) |
| 1191 | goto bus_clk_disable; |
| 1192 | |
| 1193 | /* Setup SDC MMC clock */ |
| 1194 | msm_host->clk = devm_clk_get(&pdev->dev, "core"); |
| 1195 | if (IS_ERR(msm_host->clk)) { |
| 1196 | ret = PTR_ERR(msm_host->clk); |
| 1197 | dev_err(&pdev->dev, "SDC MMC clk setup failed (%d)\n", ret); |
| 1198 | goto pclk_disable; |
| 1199 | } |
| 1200 | |
Venkat Gopalakrishnan | 8373635 | 2016-11-21 12:07:16 +0530 | [diff] [blame] | 1201 | /* |
| 1202 | * xo clock is needed for FLL feature of cm_dll. |
| 1203 | * In case if xo clock is not mentioned in DT, warn and proceed. |
| 1204 | */ |
| 1205 | msm_host->xo_clk = devm_clk_get(&pdev->dev, "xo"); |
| 1206 | if (IS_ERR(msm_host->xo_clk)) { |
| 1207 | ret = PTR_ERR(msm_host->xo_clk); |
| 1208 | dev_warn(&pdev->dev, "TCXO clk not present (%d)\n", ret); |
| 1209 | } |
| 1210 | |
Ivan T. Ivanov | 951b8c8 | 2015-07-06 14:53:38 +0300 | [diff] [blame] | 1211 | /* Vote for maximum clock rate for maximum performance */ |
| 1212 | ret = clk_set_rate(msm_host->clk, INT_MAX); |
| 1213 | if (ret) |
| 1214 | dev_warn(&pdev->dev, "core clock boost failed\n"); |
| 1215 | |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1216 | ret = clk_prepare_enable(msm_host->clk); |
| 1217 | if (ret) |
| 1218 | goto pclk_disable; |
| 1219 | |
| 1220 | core_memres = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
| 1221 | msm_host->core_mem = devm_ioremap_resource(&pdev->dev, core_memres); |
| 1222 | |
| 1223 | if (IS_ERR(msm_host->core_mem)) { |
| 1224 | dev_err(&pdev->dev, "Failed to remap registers\n"); |
| 1225 | ret = PTR_ERR(msm_host->core_mem); |
| 1226 | goto clk_disable; |
| 1227 | } |
| 1228 | |
Venkat Gopalakrishnan | 5574ddc | 2017-01-10 12:30:48 +0530 | [diff] [blame] | 1229 | /* Reset the vendor spec register to power on reset state */ |
| 1230 | writel_relaxed(CORE_VENDOR_SPEC_POR_VAL, |
| 1231 | host->ioaddr + CORE_VENDOR_SPEC); |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1232 | |
| 1233 | /* Set HC_MODE_EN bit in HC_MODE register */ |
| 1234 | writel_relaxed(HC_MODE_EN, (msm_host->core_mem + CORE_HC_MODE)); |
| 1235 | |
Venkat Gopalakrishnan | ff06ce4 | 2016-11-21 12:07:23 +0530 | [diff] [blame] | 1236 | config = readl_relaxed(msm_host->core_mem + CORE_HC_MODE); |
| 1237 | config |= FF_CLK_SW_RST_DIS; |
| 1238 | writel_relaxed(config, msm_host->core_mem + CORE_HC_MODE); |
| 1239 | |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1240 | host_version = readw_relaxed((host->ioaddr + SDHCI_HOST_VERSION)); |
| 1241 | dev_dbg(&pdev->dev, "Host Version: 0x%x Vendor Version 0x%x\n", |
| 1242 | host_version, ((host_version & SDHCI_VENDOR_VER_MASK) >> |
| 1243 | SDHCI_VENDOR_VER_SHIFT)); |
| 1244 | |
Georgi Djakov | 3a3ad3e | 2015-03-23 18:47:29 +0200 | [diff] [blame] | 1245 | core_version = readl_relaxed(msm_host->core_mem + CORE_MCI_VERSION); |
| 1246 | core_major = (core_version & CORE_VERSION_MAJOR_MASK) >> |
| 1247 | CORE_VERSION_MAJOR_SHIFT; |
| 1248 | core_minor = core_version & CORE_VERSION_MINOR_MASK; |
| 1249 | dev_dbg(&pdev->dev, "MCI Version: 0x%08x, major: 0x%04x, minor: 0x%02x\n", |
| 1250 | core_version, core_major, core_minor); |
| 1251 | |
Venkat Gopalakrishnan | 8373635 | 2016-11-21 12:07:16 +0530 | [diff] [blame] | 1252 | if (core_major == 1 && core_minor >= 0x42) |
| 1253 | msm_host->use_14lpp_dll_reset = true; |
| 1254 | |
Georgi Djakov | 3a3ad3e | 2015-03-23 18:47:29 +0200 | [diff] [blame] | 1255 | /* |
Ritesh Harjani | 02e4293 | 2016-11-21 12:07:26 +0530 | [diff] [blame] | 1256 | * SDCC 5 controller with major version 1, minor version 0x34 and later |
| 1257 | * with HS 400 mode support will use CM DLL instead of CDC LP 533 DLL. |
| 1258 | */ |
| 1259 | if (core_major == 1 && core_minor < 0x34) |
| 1260 | msm_host->use_cdclp533 = true; |
| 1261 | |
| 1262 | /* |
Georgi Djakov | 3a3ad3e | 2015-03-23 18:47:29 +0200 | [diff] [blame] | 1263 | * Support for some capabilities is not advertised by newer |
| 1264 | * controller versions and must be explicitly enabled. |
| 1265 | */ |
| 1266 | if (core_major >= 1 && core_minor != 0x11 && core_minor != 0x12) { |
Ritesh Harjani | 29301f4 | 2016-11-21 12:07:13 +0530 | [diff] [blame] | 1267 | config = readl_relaxed(host->ioaddr + SDHCI_CAPABILITIES); |
| 1268 | config |= SDHCI_CAN_VDD_300 | SDHCI_CAN_DO_8BIT; |
| 1269 | writel_relaxed(config, host->ioaddr + |
Georgi Djakov | 3a3ad3e | 2015-03-23 18:47:29 +0200 | [diff] [blame] | 1270 | CORE_VENDOR_SPEC_CAPABILITIES0); |
| 1271 | } |
| 1272 | |
Georgi Djakov | ad81d38 | 2016-06-24 18:07:14 +0300 | [diff] [blame] | 1273 | /* Setup IRQ for handling power/voltage tasks with PMIC */ |
| 1274 | msm_host->pwr_irq = platform_get_irq_byname(pdev, "pwr_irq"); |
| 1275 | if (msm_host->pwr_irq < 0) { |
| 1276 | dev_err(&pdev->dev, "Get pwr_irq failed (%d)\n", |
| 1277 | msm_host->pwr_irq); |
Wei Yongjun | d1f63f0 | 2016-10-26 15:04:41 +0000 | [diff] [blame] | 1278 | ret = msm_host->pwr_irq; |
Georgi Djakov | ad81d38 | 2016-06-24 18:07:14 +0300 | [diff] [blame] | 1279 | goto clk_disable; |
| 1280 | } |
| 1281 | |
| 1282 | ret = devm_request_threaded_irq(&pdev->dev, msm_host->pwr_irq, NULL, |
| 1283 | sdhci_msm_pwr_irq, IRQF_ONESHOT, |
| 1284 | dev_name(&pdev->dev), host); |
| 1285 | if (ret) { |
| 1286 | dev_err(&pdev->dev, "Request IRQ failed (%d)\n", ret); |
| 1287 | goto clk_disable; |
| 1288 | } |
| 1289 | |
Pramod Gurav | 67e6db1 | 2016-10-21 12:12:04 +0530 | [diff] [blame] | 1290 | pm_runtime_get_noresume(&pdev->dev); |
| 1291 | pm_runtime_set_active(&pdev->dev); |
| 1292 | pm_runtime_enable(&pdev->dev); |
| 1293 | pm_runtime_set_autosuspend_delay(&pdev->dev, |
| 1294 | MSM_MMC_AUTOSUSPEND_DELAY_MS); |
| 1295 | pm_runtime_use_autosuspend(&pdev->dev); |
| 1296 | |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1297 | ret = sdhci_add_host(host); |
| 1298 | if (ret) |
Pramod Gurav | 67e6db1 | 2016-10-21 12:12:04 +0530 | [diff] [blame] | 1299 | goto pm_runtime_disable; |
| 1300 | |
| 1301 | pm_runtime_mark_last_busy(&pdev->dev); |
| 1302 | pm_runtime_put_autosuspend(&pdev->dev); |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1303 | |
| 1304 | return 0; |
| 1305 | |
Pramod Gurav | 67e6db1 | 2016-10-21 12:12:04 +0530 | [diff] [blame] | 1306 | pm_runtime_disable: |
| 1307 | pm_runtime_disable(&pdev->dev); |
| 1308 | pm_runtime_set_suspended(&pdev->dev); |
| 1309 | pm_runtime_put_noidle(&pdev->dev); |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1310 | clk_disable: |
| 1311 | clk_disable_unprepare(msm_host->clk); |
| 1312 | pclk_disable: |
| 1313 | clk_disable_unprepare(msm_host->pclk); |
| 1314 | bus_clk_disable: |
| 1315 | if (!IS_ERR(msm_host->bus_clk)) |
| 1316 | clk_disable_unprepare(msm_host->bus_clk); |
| 1317 | pltfm_free: |
| 1318 | sdhci_pltfm_free(pdev); |
| 1319 | return ret; |
| 1320 | } |
| 1321 | |
| 1322 | static int sdhci_msm_remove(struct platform_device *pdev) |
| 1323 | { |
| 1324 | struct sdhci_host *host = platform_get_drvdata(pdev); |
| 1325 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
Jisheng Zhang | 6f69953 | 2016-02-16 21:08:22 +0800 | [diff] [blame] | 1326 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1327 | int dead = (readl_relaxed(host->ioaddr + SDHCI_INT_STATUS) == |
| 1328 | 0xffffffff); |
| 1329 | |
| 1330 | sdhci_remove_host(host, dead); |
Pramod Gurav | 67e6db1 | 2016-10-21 12:12:04 +0530 | [diff] [blame] | 1331 | |
| 1332 | pm_runtime_get_sync(&pdev->dev); |
| 1333 | pm_runtime_disable(&pdev->dev); |
| 1334 | pm_runtime_put_noidle(&pdev->dev); |
| 1335 | |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1336 | clk_disable_unprepare(msm_host->clk); |
| 1337 | clk_disable_unprepare(msm_host->pclk); |
| 1338 | if (!IS_ERR(msm_host->bus_clk)) |
| 1339 | clk_disable_unprepare(msm_host->bus_clk); |
Jisheng Zhang | 6f69953 | 2016-02-16 21:08:22 +0800 | [diff] [blame] | 1340 | sdhci_pltfm_free(pdev); |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1341 | return 0; |
| 1342 | } |
| 1343 | |
Pramod Gurav | 67e6db1 | 2016-10-21 12:12:04 +0530 | [diff] [blame] | 1344 | #ifdef CONFIG_PM |
| 1345 | static int sdhci_msm_runtime_suspend(struct device *dev) |
| 1346 | { |
| 1347 | struct sdhci_host *host = dev_get_drvdata(dev); |
| 1348 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 1349 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); |
| 1350 | |
| 1351 | clk_disable_unprepare(msm_host->clk); |
| 1352 | clk_disable_unprepare(msm_host->pclk); |
| 1353 | |
| 1354 | return 0; |
| 1355 | } |
| 1356 | |
| 1357 | static int sdhci_msm_runtime_resume(struct device *dev) |
| 1358 | { |
| 1359 | struct sdhci_host *host = dev_get_drvdata(dev); |
| 1360 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 1361 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); |
| 1362 | int ret; |
| 1363 | |
| 1364 | ret = clk_prepare_enable(msm_host->clk); |
| 1365 | if (ret) { |
| 1366 | dev_err(dev, "clk_enable failed for core_clk: %d\n", ret); |
| 1367 | return ret; |
| 1368 | } |
| 1369 | ret = clk_prepare_enable(msm_host->pclk); |
| 1370 | if (ret) { |
| 1371 | dev_err(dev, "clk_enable failed for iface_clk: %d\n", ret); |
| 1372 | clk_disable_unprepare(msm_host->clk); |
| 1373 | return ret; |
| 1374 | } |
| 1375 | |
| 1376 | return 0; |
| 1377 | } |
| 1378 | #endif |
| 1379 | |
| 1380 | static const struct dev_pm_ops sdhci_msm_pm_ops = { |
| 1381 | SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, |
| 1382 | pm_runtime_force_resume) |
| 1383 | SET_RUNTIME_PM_OPS(sdhci_msm_runtime_suspend, |
| 1384 | sdhci_msm_runtime_resume, |
| 1385 | NULL) |
| 1386 | }; |
| 1387 | |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1388 | static struct platform_driver sdhci_msm_driver = { |
| 1389 | .probe = sdhci_msm_probe, |
| 1390 | .remove = sdhci_msm_remove, |
| 1391 | .driver = { |
| 1392 | .name = "sdhci_msm", |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1393 | .of_match_table = sdhci_msm_dt_match, |
Pramod Gurav | 67e6db1 | 2016-10-21 12:12:04 +0530 | [diff] [blame] | 1394 | .pm = &sdhci_msm_pm_ops, |
Georgi Djakov | 0eb0d9f | 2014-03-10 17:37:12 +0200 | [diff] [blame] | 1395 | }, |
| 1396 | }; |
| 1397 | |
| 1398 | module_platform_driver(sdhci_msm_driver); |
| 1399 | |
| 1400 | MODULE_DESCRIPTION("Qualcomm Secure Digital Host Controller Interface driver"); |
| 1401 | MODULE_LICENSE("GPL v2"); |