2 * Copyright (C) 2010 Google, Inc.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
15 #include <linux/delay.h>
16 #include <linux/err.h>
17 #include <linux/module.h>
18 #include <linux/init.h>
19 #include <linux/iopoll.h>
20 #include <linux/platform_device.h>
21 #include <linux/clk.h>
24 #include <linux/of_device.h>
25 #include <linux/pinctrl/consumer.h>
26 #include <linux/regulator/consumer.h>
27 #include <linux/reset.h>
28 #include <linux/mmc/card.h>
29 #include <linux/mmc/host.h>
30 #include <linux/mmc/mmc.h>
31 #include <linux/mmc/slot-gpio.h>
32 #include <linux/gpio/consumer.h>
33 #include <linux/ktime.h>
35 #include "sdhci-pltfm.h"
37 /* Tegra SDHOST controller vendor register definitions */
38 #define SDHCI_TEGRA_VENDOR_CLOCK_CTRL 0x100
39 #define SDHCI_CLOCK_CTRL_TAP_MASK 0x00ff0000
40 #define SDHCI_CLOCK_CTRL_TAP_SHIFT 16
41 #define SDHCI_CLOCK_CTRL_TRIM_MASK 0x1f000000
42 #define SDHCI_CLOCK_CTRL_TRIM_SHIFT 24
43 #define SDHCI_CLOCK_CTRL_SDR50_TUNING_OVERRIDE BIT(5)
44 #define SDHCI_CLOCK_CTRL_PADPIPE_CLKEN_OVERRIDE BIT(3)
45 #define SDHCI_CLOCK_CTRL_SPI_MODE_CLKEN_OVERRIDE BIT(2)
47 #define SDHCI_TEGRA_VENDOR_SYS_SW_CTRL 0x104
48 #define SDHCI_TEGRA_SYS_SW_CTRL_ENHANCED_STROBE BIT(31)
50 #define SDHCI_TEGRA_VENDOR_CAP_OVERRIDES 0x10c
51 #define SDHCI_TEGRA_CAP_OVERRIDES_DQS_TRIM_MASK 0x00003f00
52 #define SDHCI_TEGRA_CAP_OVERRIDES_DQS_TRIM_SHIFT 8
54 #define SDHCI_TEGRA_VENDOR_MISC_CTRL 0x120
55 #define SDHCI_MISC_CTRL_ENABLE_SDR104 0x8
56 #define SDHCI_MISC_CTRL_ENABLE_SDR50 0x10
57 #define SDHCI_MISC_CTRL_ENABLE_SDHCI_SPEC_300 0x20
58 #define SDHCI_MISC_CTRL_ENABLE_DDR50 0x200
60 #define SDHCI_TEGRA_VENDOR_DLLCAL_CFG 0x1b0
61 #define SDHCI_TEGRA_DLLCAL_CALIBRATE BIT(31)
63 #define SDHCI_TEGRA_VENDOR_DLLCAL_STA 0x1bc
64 #define SDHCI_TEGRA_DLLCAL_STA_ACTIVE BIT(31)
66 #define SDHCI_VNDR_TUN_CTRL0_0 0x1c0
67 #define SDHCI_VNDR_TUN_CTRL0_TUN_HW_TAP 0x20000
69 #define SDHCI_TEGRA_AUTO_CAL_CONFIG 0x1e4
70 #define SDHCI_AUTO_CAL_START BIT(31)
71 #define SDHCI_AUTO_CAL_ENABLE BIT(29)
72 #define SDHCI_AUTO_CAL_PDPU_OFFSET_MASK 0x0000ffff
74 #define SDHCI_TEGRA_SDMEM_COMP_PADCTRL 0x1e0
75 #define SDHCI_TEGRA_SDMEM_COMP_PADCTRL_VREF_SEL_MASK 0x0000000f
76 #define SDHCI_TEGRA_SDMEM_COMP_PADCTRL_VREF_SEL_VAL 0x7
77 #define SDHCI_TEGRA_SDMEM_COMP_PADCTRL_E_INPUT_E_PWRD BIT(31)
79 #define SDHCI_TEGRA_AUTO_CAL_STATUS 0x1ec
80 #define SDHCI_TEGRA_AUTO_CAL_ACTIVE BIT(31)
82 #define NVQUIRK_FORCE_SDHCI_SPEC_200 BIT(0)
83 #define NVQUIRK_ENABLE_BLOCK_GAP_DET BIT(1)
84 #define NVQUIRK_ENABLE_SDHCI_SPEC_300 BIT(2)
85 #define NVQUIRK_ENABLE_SDR50 BIT(3)
86 #define NVQUIRK_ENABLE_SDR104 BIT(4)
87 #define NVQUIRK_ENABLE_DDR50 BIT(5)
88 #define NVQUIRK_HAS_PADCALIB BIT(6)
89 #define NVQUIRK_NEEDS_PAD_CONTROL BIT(7)
90 #define NVQUIRK_DIS_CARD_CLK_CONFIG_TAP BIT(8)
92 struct sdhci_tegra_soc_data
{
93 const struct sdhci_pltfm_data
*pdata
;
97 /* Magic pull up and pull down pad calibration offsets */
98 struct sdhci_tegra_autocal_offsets
{
101 u32 pull_up_3v3_timeout
;
102 u32 pull_down_3v3_timeout
;
105 u32 pull_up_1v8_timeout
;
106 u32 pull_down_1v8_timeout
;
108 u32 pull_down_sdr104
;
114 const struct sdhci_tegra_soc_data
*soc_data
;
115 struct gpio_desc
*power_gpio
;
117 bool pad_calib_required
;
118 bool pad_control_available
;
120 struct reset_control
*rst
;
121 struct pinctrl
*pinctrl_sdmmc
;
122 struct pinctrl_state
*pinctrl_state_3v3
;
123 struct pinctrl_state
*pinctrl_state_1v8
;
125 struct sdhci_tegra_autocal_offsets autocal_offsets
;
133 static u16
tegra_sdhci_readw(struct sdhci_host
*host
, int reg
)
135 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
136 struct sdhci_tegra
*tegra_host
= sdhci_pltfm_priv(pltfm_host
);
137 const struct sdhci_tegra_soc_data
*soc_data
= tegra_host
->soc_data
;
139 if (unlikely((soc_data
->nvquirks
& NVQUIRK_FORCE_SDHCI_SPEC_200
) &&
140 (reg
== SDHCI_HOST_VERSION
))) {
141 /* Erratum: Version register is invalid in HW. */
142 return SDHCI_SPEC_200
;
145 return readw(host
->ioaddr
+ reg
);
148 static void tegra_sdhci_writew(struct sdhci_host
*host
, u16 val
, int reg
)
150 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
153 case SDHCI_TRANSFER_MODE
:
155 * Postpone this write, we must do it together with a
156 * command write that is down below.
158 pltfm_host
->xfer_mode_shadow
= val
;
161 writel((val
<< 16) | pltfm_host
->xfer_mode_shadow
,
162 host
->ioaddr
+ SDHCI_TRANSFER_MODE
);
166 writew(val
, host
->ioaddr
+ reg
);
169 static void tegra_sdhci_writel(struct sdhci_host
*host
, u32 val
, int reg
)
171 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
172 struct sdhci_tegra
*tegra_host
= sdhci_pltfm_priv(pltfm_host
);
173 const struct sdhci_tegra_soc_data
*soc_data
= tegra_host
->soc_data
;
175 /* Seems like we're getting spurious timeout and crc errors, so
176 * disable signalling of them. In case of real errors software
177 * timers should take care of eventually detecting them.
179 if (unlikely(reg
== SDHCI_SIGNAL_ENABLE
))
180 val
&= ~(SDHCI_INT_TIMEOUT
|SDHCI_INT_CRC
);
182 writel(val
, host
->ioaddr
+ reg
);
184 if (unlikely((soc_data
->nvquirks
& NVQUIRK_ENABLE_BLOCK_GAP_DET
) &&
185 (reg
== SDHCI_INT_ENABLE
))) {
186 /* Erratum: Must enable block gap interrupt detection */
187 u8 gap_ctrl
= readb(host
->ioaddr
+ SDHCI_BLOCK_GAP_CONTROL
);
188 if (val
& SDHCI_INT_CARD_INT
)
192 writeb(gap_ctrl
, host
->ioaddr
+ SDHCI_BLOCK_GAP_CONTROL
);
196 static bool tegra_sdhci_configure_card_clk(struct sdhci_host
*host
, bool enable
)
201 reg
= sdhci_readw(host
, SDHCI_CLOCK_CONTROL
);
202 status
= !!(reg
& SDHCI_CLOCK_CARD_EN
);
204 if (status
== enable
)
208 reg
|= SDHCI_CLOCK_CARD_EN
;
210 reg
&= ~SDHCI_CLOCK_CARD_EN
;
212 sdhci_writew(host
, reg
, SDHCI_CLOCK_CONTROL
);
217 static void tegra210_sdhci_writew(struct sdhci_host
*host
, u16 val
, int reg
)
219 bool is_tuning_cmd
= 0;
223 if (reg
== SDHCI_COMMAND
) {
224 cmd
= SDHCI_GET_CMD(val
);
225 is_tuning_cmd
= cmd
== MMC_SEND_TUNING_BLOCK
||
226 cmd
== MMC_SEND_TUNING_BLOCK_HS200
;
230 clk_enabled
= tegra_sdhci_configure_card_clk(host
, 0);
232 writew(val
, host
->ioaddr
+ reg
);
236 tegra_sdhci_configure_card_clk(host
, clk_enabled
);
240 static unsigned int tegra_sdhci_get_ro(struct sdhci_host
*host
)
242 return mmc_gpio_get_ro(host
->mmc
);
245 static bool tegra_sdhci_is_pad_and_regulator_valid(struct sdhci_host
*host
)
247 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
248 struct sdhci_tegra
*tegra_host
= sdhci_pltfm_priv(pltfm_host
);
249 int has_1v8
, has_3v3
;
252 * The SoCs which have NVQUIRK_NEEDS_PAD_CONTROL require software pad
253 * voltage configuration in order to perform voltage switching. This
254 * means that valid pinctrl info is required on SDHCI instances capable
255 * of performing voltage switching. Whether or not an SDHCI instance is
256 * capable of voltage switching is determined based on the regulator.
259 if (!(tegra_host
->soc_data
->nvquirks
& NVQUIRK_NEEDS_PAD_CONTROL
))
262 if (IS_ERR(host
->mmc
->supply
.vqmmc
))
265 has_1v8
= regulator_is_supported_voltage(host
->mmc
->supply
.vqmmc
,
268 has_3v3
= regulator_is_supported_voltage(host
->mmc
->supply
.vqmmc
,
271 if (has_1v8
== 1 && has_3v3
== 1)
272 return tegra_host
->pad_control_available
;
274 /* Fixed voltage, no pad control required. */
278 static void tegra_sdhci_set_tap(struct sdhci_host
*host
, unsigned int tap
)
280 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
281 struct sdhci_tegra
*tegra_host
= sdhci_pltfm_priv(pltfm_host
);
282 const struct sdhci_tegra_soc_data
*soc_data
= tegra_host
->soc_data
;
283 bool card_clk_enabled
= false;
287 * Touching the tap values is a bit tricky on some SoC generations.
288 * The quirk enables a workaround for a glitch that sometimes occurs if
289 * the tap values are changed.
292 if (soc_data
->nvquirks
& NVQUIRK_DIS_CARD_CLK_CONFIG_TAP
)
293 card_clk_enabled
= tegra_sdhci_configure_card_clk(host
, false);
295 reg
= sdhci_readl(host
, SDHCI_TEGRA_VENDOR_CLOCK_CTRL
);
296 reg
&= ~SDHCI_CLOCK_CTRL_TAP_MASK
;
297 reg
|= tap
<< SDHCI_CLOCK_CTRL_TAP_SHIFT
;
298 sdhci_writel(host
, reg
, SDHCI_TEGRA_VENDOR_CLOCK_CTRL
);
300 if (soc_data
->nvquirks
& NVQUIRK_DIS_CARD_CLK_CONFIG_TAP
&&
303 sdhci_reset(host
, SDHCI_RESET_CMD
| SDHCI_RESET_DATA
);
304 tegra_sdhci_configure_card_clk(host
, card_clk_enabled
);
308 static void tegra_sdhci_hs400_enhanced_strobe(struct mmc_host
*mmc
,
311 struct sdhci_host
*host
= mmc_priv(mmc
);
314 val
= sdhci_readl(host
, SDHCI_TEGRA_VENDOR_SYS_SW_CTRL
);
316 if (ios
->enhanced_strobe
)
317 val
|= SDHCI_TEGRA_SYS_SW_CTRL_ENHANCED_STROBE
;
319 val
&= ~SDHCI_TEGRA_SYS_SW_CTRL_ENHANCED_STROBE
;
321 sdhci_writel(host
, val
, SDHCI_TEGRA_VENDOR_SYS_SW_CTRL
);
325 static void tegra_sdhci_reset(struct sdhci_host
*host
, u8 mask
)
327 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
328 struct sdhci_tegra
*tegra_host
= sdhci_pltfm_priv(pltfm_host
);
329 const struct sdhci_tegra_soc_data
*soc_data
= tegra_host
->soc_data
;
330 u32 misc_ctrl
, clk_ctrl
, pad_ctrl
;
332 sdhci_reset(host
, mask
);
334 if (!(mask
& SDHCI_RESET_ALL
))
337 tegra_sdhci_set_tap(host
, tegra_host
->default_tap
);
339 misc_ctrl
= sdhci_readl(host
, SDHCI_TEGRA_VENDOR_MISC_CTRL
);
340 clk_ctrl
= sdhci_readl(host
, SDHCI_TEGRA_VENDOR_CLOCK_CTRL
);
342 misc_ctrl
&= ~(SDHCI_MISC_CTRL_ENABLE_SDHCI_SPEC_300
|
343 SDHCI_MISC_CTRL_ENABLE_SDR50
|
344 SDHCI_MISC_CTRL_ENABLE_DDR50
|
345 SDHCI_MISC_CTRL_ENABLE_SDR104
);
347 clk_ctrl
&= ~(SDHCI_CLOCK_CTRL_TRIM_MASK
|
348 SDHCI_CLOCK_CTRL_SPI_MODE_CLKEN_OVERRIDE
);
350 if (tegra_sdhci_is_pad_and_regulator_valid(host
)) {
351 /* Erratum: Enable SDHCI spec v3.00 support */
352 if (soc_data
->nvquirks
& NVQUIRK_ENABLE_SDHCI_SPEC_300
)
353 misc_ctrl
|= SDHCI_MISC_CTRL_ENABLE_SDHCI_SPEC_300
;
354 /* Advertise UHS modes as supported by host */
355 if (soc_data
->nvquirks
& NVQUIRK_ENABLE_SDR50
)
356 misc_ctrl
|= SDHCI_MISC_CTRL_ENABLE_SDR50
;
357 if (soc_data
->nvquirks
& NVQUIRK_ENABLE_DDR50
)
358 misc_ctrl
|= SDHCI_MISC_CTRL_ENABLE_DDR50
;
359 if (soc_data
->nvquirks
& NVQUIRK_ENABLE_SDR104
)
360 misc_ctrl
|= SDHCI_MISC_CTRL_ENABLE_SDR104
;
361 if (soc_data
->nvquirks
& SDHCI_MISC_CTRL_ENABLE_SDR50
)
362 clk_ctrl
|= SDHCI_CLOCK_CTRL_SDR50_TUNING_OVERRIDE
;
365 clk_ctrl
|= tegra_host
->default_trim
<< SDHCI_CLOCK_CTRL_TRIM_SHIFT
;
367 sdhci_writel(host
, misc_ctrl
, SDHCI_TEGRA_VENDOR_MISC_CTRL
);
368 sdhci_writel(host
, clk_ctrl
, SDHCI_TEGRA_VENDOR_CLOCK_CTRL
);
370 if (soc_data
->nvquirks
& NVQUIRK_HAS_PADCALIB
) {
371 pad_ctrl
= sdhci_readl(host
, SDHCI_TEGRA_SDMEM_COMP_PADCTRL
);
372 pad_ctrl
&= ~SDHCI_TEGRA_SDMEM_COMP_PADCTRL_VREF_SEL_MASK
;
373 pad_ctrl
|= SDHCI_TEGRA_SDMEM_COMP_PADCTRL_VREF_SEL_VAL
;
374 sdhci_writel(host
, pad_ctrl
, SDHCI_TEGRA_SDMEM_COMP_PADCTRL
);
376 tegra_host
->pad_calib_required
= true;
379 tegra_host
->ddr_signaling
= false;
382 static void tegra_sdhci_configure_cal_pad(struct sdhci_host
*host
, bool enable
)
387 * Enable or disable the additional I/O pad used by the drive strength
388 * calibration process.
390 val
= sdhci_readl(host
, SDHCI_TEGRA_SDMEM_COMP_PADCTRL
);
393 val
|= SDHCI_TEGRA_SDMEM_COMP_PADCTRL_E_INPUT_E_PWRD
;
395 val
&= ~SDHCI_TEGRA_SDMEM_COMP_PADCTRL_E_INPUT_E_PWRD
;
397 sdhci_writel(host
, val
, SDHCI_TEGRA_SDMEM_COMP_PADCTRL
);
403 static void tegra_sdhci_set_pad_autocal_offset(struct sdhci_host
*host
,
408 reg
= sdhci_readl(host
, SDHCI_TEGRA_AUTO_CAL_CONFIG
);
409 reg
&= ~SDHCI_AUTO_CAL_PDPU_OFFSET_MASK
;
411 sdhci_writel(host
, reg
, SDHCI_TEGRA_AUTO_CAL_CONFIG
);
414 static void tegra_sdhci_pad_autocalib(struct sdhci_host
*host
)
416 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
417 struct sdhci_tegra
*tegra_host
= sdhci_pltfm_priv(pltfm_host
);
418 struct sdhci_tegra_autocal_offsets offsets
=
419 tegra_host
->autocal_offsets
;
420 struct mmc_ios
*ios
= &host
->mmc
->ios
;
421 bool card_clk_enabled
;
426 switch (ios
->timing
) {
427 case MMC_TIMING_UHS_SDR104
:
428 pdpu
= offsets
.pull_down_sdr104
<< 8 | offsets
.pull_up_sdr104
;
430 case MMC_TIMING_MMC_HS400
:
431 pdpu
= offsets
.pull_down_hs400
<< 8 | offsets
.pull_up_hs400
;
434 if (ios
->signal_voltage
== MMC_SIGNAL_VOLTAGE_180
)
435 pdpu
= offsets
.pull_down_1v8
<< 8 | offsets
.pull_up_1v8
;
437 pdpu
= offsets
.pull_down_3v3
<< 8 | offsets
.pull_up_3v3
;
440 tegra_sdhci_set_pad_autocal_offset(host
, pdpu
);
442 card_clk_enabled
= tegra_sdhci_configure_card_clk(host
, false);
444 tegra_sdhci_configure_cal_pad(host
, true);
446 reg
= sdhci_readl(host
, SDHCI_TEGRA_AUTO_CAL_CONFIG
);
447 reg
|= SDHCI_AUTO_CAL_ENABLE
| SDHCI_AUTO_CAL_START
;
448 sdhci_writel(host
, reg
, SDHCI_TEGRA_AUTO_CAL_CONFIG
);
452 ret
= readl_poll_timeout(host
->ioaddr
+ SDHCI_TEGRA_AUTO_CAL_STATUS
,
453 reg
, !(reg
& SDHCI_TEGRA_AUTO_CAL_ACTIVE
),
456 tegra_sdhci_configure_cal_pad(host
, false);
458 tegra_sdhci_configure_card_clk(host
, card_clk_enabled
);
461 dev_err(mmc_dev(host
->mmc
), "Pad autocal timed out\n");
463 if (ios
->signal_voltage
== MMC_SIGNAL_VOLTAGE_180
)
464 pdpu
= offsets
.pull_down_1v8_timeout
<< 8 |
465 offsets
.pull_up_1v8_timeout
;
467 pdpu
= offsets
.pull_down_3v3_timeout
<< 8 |
468 offsets
.pull_up_3v3_timeout
;
470 /* Disable automatic calibration and use fixed offsets */
471 reg
= sdhci_readl(host
, SDHCI_TEGRA_AUTO_CAL_CONFIG
);
472 reg
&= ~SDHCI_AUTO_CAL_ENABLE
;
473 sdhci_writel(host
, reg
, SDHCI_TEGRA_AUTO_CAL_CONFIG
);
475 tegra_sdhci_set_pad_autocal_offset(host
, pdpu
);
479 static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host
*host
)
481 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
482 struct sdhci_tegra
*tegra_host
= sdhci_pltfm_priv(pltfm_host
);
483 struct sdhci_tegra_autocal_offsets
*autocal
=
484 &tegra_host
->autocal_offsets
;
487 err
= device_property_read_u32(host
->mmc
->parent
,
488 "nvidia,pad-autocal-pull-up-offset-3v3",
489 &autocal
->pull_up_3v3
);
491 autocal
->pull_up_3v3
= 0;
493 err
= device_property_read_u32(host
->mmc
->parent
,
494 "nvidia,pad-autocal-pull-down-offset-3v3",
495 &autocal
->pull_down_3v3
);
497 autocal
->pull_down_3v3
= 0;
499 err
= device_property_read_u32(host
->mmc
->parent
,
500 "nvidia,pad-autocal-pull-up-offset-1v8",
501 &autocal
->pull_up_1v8
);
503 autocal
->pull_up_1v8
= 0;
505 err
= device_property_read_u32(host
->mmc
->parent
,
506 "nvidia,pad-autocal-pull-down-offset-1v8",
507 &autocal
->pull_down_1v8
);
509 autocal
->pull_down_1v8
= 0;
511 err
= device_property_read_u32(host
->mmc
->parent
,
512 "nvidia,pad-autocal-pull-up-offset-3v3-timeout",
513 &autocal
->pull_up_3v3
);
515 autocal
->pull_up_3v3_timeout
= 0;
517 err
= device_property_read_u32(host
->mmc
->parent
,
518 "nvidia,pad-autocal-pull-down-offset-3v3-timeout",
519 &autocal
->pull_down_3v3
);
521 autocal
->pull_down_3v3_timeout
= 0;
523 err
= device_property_read_u32(host
->mmc
->parent
,
524 "nvidia,pad-autocal-pull-up-offset-1v8-timeout",
525 &autocal
->pull_up_1v8
);
527 autocal
->pull_up_1v8_timeout
= 0;
529 err
= device_property_read_u32(host
->mmc
->parent
,
530 "nvidia,pad-autocal-pull-down-offset-1v8-timeout",
531 &autocal
->pull_down_1v8
);
533 autocal
->pull_down_1v8_timeout
= 0;
535 err
= device_property_read_u32(host
->mmc
->parent
,
536 "nvidia,pad-autocal-pull-up-offset-sdr104",
537 &autocal
->pull_up_sdr104
);
539 autocal
->pull_up_sdr104
= autocal
->pull_up_1v8
;
541 err
= device_property_read_u32(host
->mmc
->parent
,
542 "nvidia,pad-autocal-pull-down-offset-sdr104",
543 &autocal
->pull_down_sdr104
);
545 autocal
->pull_down_sdr104
= autocal
->pull_down_1v8
;
547 err
= device_property_read_u32(host
->mmc
->parent
,
548 "nvidia,pad-autocal-pull-up-offset-hs400",
549 &autocal
->pull_up_hs400
);
551 autocal
->pull_up_hs400
= autocal
->pull_up_1v8
;
553 err
= device_property_read_u32(host
->mmc
->parent
,
554 "nvidia,pad-autocal-pull-down-offset-hs400",
555 &autocal
->pull_down_hs400
);
557 autocal
->pull_down_hs400
= autocal
->pull_down_1v8
;
560 static void tegra_sdhci_request(struct mmc_host
*mmc
, struct mmc_request
*mrq
)
562 struct sdhci_host
*host
= mmc_priv(mmc
);
563 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
564 struct sdhci_tegra
*tegra_host
= sdhci_pltfm_priv(pltfm_host
);
565 ktime_t since_calib
= ktime_sub(ktime_get(), tegra_host
->last_calib
);
567 /* 100 ms calibration interval is specified in the TRM */
568 if (ktime_to_ms(since_calib
) > 100) {
569 tegra_sdhci_pad_autocalib(host
);
570 tegra_host
->last_calib
= ktime_get();
573 sdhci_request(mmc
, mrq
);
576 static void tegra_sdhci_parse_tap_and_trim(struct sdhci_host
*host
)
578 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
579 struct sdhci_tegra
*tegra_host
= sdhci_pltfm_priv(pltfm_host
);
582 err
= device_property_read_u32(host
->mmc
->parent
, "nvidia,default-tap",
583 &tegra_host
->default_tap
);
585 tegra_host
->default_tap
= 0;
587 err
= device_property_read_u32(host
->mmc
->parent
, "nvidia,default-trim",
588 &tegra_host
->default_trim
);
590 tegra_host
->default_trim
= 0;
592 err
= device_property_read_u32(host
->mmc
->parent
, "nvidia,dqs-trim",
593 &tegra_host
->dqs_trim
);
595 tegra_host
->dqs_trim
= 0x11;
598 static void tegra_sdhci_set_clock(struct sdhci_host
*host
, unsigned int clock
)
600 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
601 struct sdhci_tegra
*tegra_host
= sdhci_pltfm_priv(pltfm_host
);
602 unsigned long host_clk
;
605 return sdhci_set_clock(host
, clock
);
608 * In DDR50/52 modes the Tegra SDHCI controllers require the SDHCI
609 * divider to be configured to divided the host clock by two. The SDHCI
610 * clock divider is calculated as part of sdhci_set_clock() by
611 * sdhci_calc_clk(). The divider is calculated from host->max_clk and
612 * the requested clock rate.
614 * By setting the host->max_clk to clock * 2 the divider calculation
615 * will always result in the correct value for DDR50/52 modes,
616 * regardless of clock rate rounding, which may happen if the value
617 * from clk_get_rate() is used.
619 host_clk
= tegra_host
->ddr_signaling
? clock
* 2 : clock
;
620 clk_set_rate(pltfm_host
->clk
, host_clk
);
621 if (tegra_host
->ddr_signaling
)
622 host
->max_clk
= host_clk
;
624 host
->max_clk
= clk_get_rate(pltfm_host
->clk
);
626 sdhci_set_clock(host
, clock
);
628 if (tegra_host
->pad_calib_required
) {
629 tegra_sdhci_pad_autocalib(host
);
630 tegra_host
->pad_calib_required
= false;
634 static unsigned int tegra_sdhci_get_max_clock(struct sdhci_host
*host
)
636 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
638 return clk_round_rate(pltfm_host
->clk
, UINT_MAX
);
641 static void tegra_sdhci_set_dqs_trim(struct sdhci_host
*host
, u8 trim
)
645 val
= sdhci_readl(host
, SDHCI_TEGRA_VENDOR_CAP_OVERRIDES
);
646 val
&= ~SDHCI_TEGRA_CAP_OVERRIDES_DQS_TRIM_MASK
;
647 val
|= trim
<< SDHCI_TEGRA_CAP_OVERRIDES_DQS_TRIM_SHIFT
;
648 sdhci_writel(host
, val
, SDHCI_TEGRA_VENDOR_CAP_OVERRIDES
);
651 static void tegra_sdhci_hs400_dll_cal(struct sdhci_host
*host
)
656 reg
= sdhci_readl(host
, SDHCI_TEGRA_VENDOR_DLLCAL_CFG
);
657 reg
|= SDHCI_TEGRA_DLLCAL_CALIBRATE
;
658 sdhci_writel(host
, reg
, SDHCI_TEGRA_VENDOR_DLLCAL_CFG
);
660 /* 1 ms sleep, 5 ms timeout */
661 err
= readl_poll_timeout(host
->ioaddr
+ SDHCI_TEGRA_VENDOR_DLLCAL_STA
,
662 reg
, !(reg
& SDHCI_TEGRA_DLLCAL_STA_ACTIVE
),
665 dev_err(mmc_dev(host
->mmc
),
666 "HS400 delay line calibration timed out\n");
669 static void tegra_sdhci_set_uhs_signaling(struct sdhci_host
*host
,
672 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
673 struct sdhci_tegra
*tegra_host
= sdhci_pltfm_priv(pltfm_host
);
674 bool set_default_tap
= false;
675 bool set_dqs_trim
= false;
676 bool do_hs400_dll_cal
= false;
679 case MMC_TIMING_UHS_SDR50
:
680 case MMC_TIMING_UHS_SDR104
:
681 case MMC_TIMING_MMC_HS200
:
682 /* Don't set default tap on tunable modes. */
684 case MMC_TIMING_MMC_HS400
:
686 do_hs400_dll_cal
= true;
688 case MMC_TIMING_MMC_DDR52
:
689 case MMC_TIMING_UHS_DDR50
:
690 tegra_host
->ddr_signaling
= true;
691 set_default_tap
= true;
694 set_default_tap
= true;
698 sdhci_set_uhs_signaling(host
, timing
);
700 tegra_sdhci_pad_autocalib(host
);
703 tegra_sdhci_set_tap(host
, tegra_host
->default_tap
);
706 tegra_sdhci_set_dqs_trim(host
, tegra_host
->dqs_trim
);
708 if (do_hs400_dll_cal
)
709 tegra_sdhci_hs400_dll_cal(host
);
712 static int tegra_sdhci_execute_tuning(struct sdhci_host
*host
, u32 opcode
)
714 unsigned int min
, max
;
717 * Start search for minimum tap value at 10, as smaller values are
718 * may wrongly be reported as working but fail at higher speeds,
719 * according to the TRM.
723 tegra_sdhci_set_tap(host
, min
);
724 if (!mmc_send_tuning(host
->mmc
, opcode
, NULL
))
729 /* Find the maximum tap value that still passes. */
732 tegra_sdhci_set_tap(host
, max
);
733 if (mmc_send_tuning(host
->mmc
, opcode
, NULL
)) {
740 /* The TRM states the ideal tap value is at 75% in the passing range. */
741 tegra_sdhci_set_tap(host
, min
+ ((max
- min
) * 3 / 4));
743 return mmc_send_tuning(host
->mmc
, opcode
, NULL
);
746 static int tegra_sdhci_set_padctrl(struct sdhci_host
*host
, int voltage
)
748 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
749 struct sdhci_tegra
*tegra_host
= sdhci_pltfm_priv(pltfm_host
);
752 if (!tegra_host
->pad_control_available
)
755 if (voltage
== MMC_SIGNAL_VOLTAGE_180
) {
756 ret
= pinctrl_select_state(tegra_host
->pinctrl_sdmmc
,
757 tegra_host
->pinctrl_state_1v8
);
759 dev_err(mmc_dev(host
->mmc
),
760 "setting 1.8V failed, ret: %d\n", ret
);
762 ret
= pinctrl_select_state(tegra_host
->pinctrl_sdmmc
,
763 tegra_host
->pinctrl_state_3v3
);
765 dev_err(mmc_dev(host
->mmc
),
766 "setting 3.3V failed, ret: %d\n", ret
);
772 static int sdhci_tegra_start_signal_voltage_switch(struct mmc_host
*mmc
,
775 struct sdhci_host
*host
= mmc_priv(mmc
);
776 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
777 struct sdhci_tegra
*tegra_host
= sdhci_pltfm_priv(pltfm_host
);
780 if (ios
->signal_voltage
== MMC_SIGNAL_VOLTAGE_330
) {
781 ret
= tegra_sdhci_set_padctrl(host
, ios
->signal_voltage
);
784 ret
= sdhci_start_signal_voltage_switch(mmc
, ios
);
785 } else if (ios
->signal_voltage
== MMC_SIGNAL_VOLTAGE_180
) {
786 ret
= sdhci_start_signal_voltage_switch(mmc
, ios
);
789 ret
= tegra_sdhci_set_padctrl(host
, ios
->signal_voltage
);
792 if (tegra_host
->pad_calib_required
)
793 tegra_sdhci_pad_autocalib(host
);
798 static int tegra_sdhci_init_pinctrl_info(struct device
*dev
,
799 struct sdhci_tegra
*tegra_host
)
801 tegra_host
->pinctrl_sdmmc
= devm_pinctrl_get(dev
);
802 if (IS_ERR(tegra_host
->pinctrl_sdmmc
)) {
803 dev_dbg(dev
, "No pinctrl info, err: %ld\n",
804 PTR_ERR(tegra_host
->pinctrl_sdmmc
));
808 tegra_host
->pinctrl_state_3v3
=
809 pinctrl_lookup_state(tegra_host
->pinctrl_sdmmc
, "sdmmc-3v3");
810 if (IS_ERR(tegra_host
->pinctrl_state_3v3
)) {
811 dev_warn(dev
, "Missing 3.3V pad state, err: %ld\n",
812 PTR_ERR(tegra_host
->pinctrl_state_3v3
));
816 tegra_host
->pinctrl_state_1v8
=
817 pinctrl_lookup_state(tegra_host
->pinctrl_sdmmc
, "sdmmc-1v8");
818 if (IS_ERR(tegra_host
->pinctrl_state_1v8
)) {
819 dev_warn(dev
, "Missing 1.8V pad state, err: %ld\n",
820 PTR_ERR(tegra_host
->pinctrl_state_1v8
));
824 tegra_host
->pad_control_available
= true;
829 static void tegra_sdhci_voltage_switch(struct sdhci_host
*host
)
831 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
832 struct sdhci_tegra
*tegra_host
= sdhci_pltfm_priv(pltfm_host
);
833 const struct sdhci_tegra_soc_data
*soc_data
= tegra_host
->soc_data
;
835 if (soc_data
->nvquirks
& NVQUIRK_HAS_PADCALIB
)
836 tegra_host
->pad_calib_required
= true;
839 static const struct sdhci_ops tegra_sdhci_ops
= {
840 .get_ro
= tegra_sdhci_get_ro
,
841 .read_w
= tegra_sdhci_readw
,
842 .write_l
= tegra_sdhci_writel
,
843 .set_clock
= tegra_sdhci_set_clock
,
844 .set_bus_width
= sdhci_set_bus_width
,
845 .reset
= tegra_sdhci_reset
,
846 .platform_execute_tuning
= tegra_sdhci_execute_tuning
,
847 .set_uhs_signaling
= tegra_sdhci_set_uhs_signaling
,
848 .voltage_switch
= tegra_sdhci_voltage_switch
,
849 .get_max_clock
= tegra_sdhci_get_max_clock
,
852 static const struct sdhci_pltfm_data sdhci_tegra20_pdata
= {
853 .quirks
= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL
|
854 SDHCI_QUIRK_SINGLE_POWER_WRITE
|
855 SDHCI_QUIRK_NO_HISPD_BIT
|
856 SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC
|
857 SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN
,
858 .ops
= &tegra_sdhci_ops
,
861 static const struct sdhci_tegra_soc_data soc_data_tegra20
= {
862 .pdata
= &sdhci_tegra20_pdata
,
863 .nvquirks
= NVQUIRK_FORCE_SDHCI_SPEC_200
|
864 NVQUIRK_ENABLE_BLOCK_GAP_DET
,
867 static const struct sdhci_pltfm_data sdhci_tegra30_pdata
= {
868 .quirks
= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL
|
869 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK
|
870 SDHCI_QUIRK_SINGLE_POWER_WRITE
|
871 SDHCI_QUIRK_NO_HISPD_BIT
|
872 SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC
|
873 SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN
,
874 .quirks2
= SDHCI_QUIRK2_PRESET_VALUE_BROKEN
|
875 SDHCI_QUIRK2_BROKEN_HS200
|
877 * Auto-CMD23 leads to "Got command interrupt 0x00010000 even
878 * though no command operation was in progress."
880 * The exact reason is unknown, as the same hardware seems
881 * to support Auto CMD23 on a downstream 3.1 kernel.
883 SDHCI_QUIRK2_ACMD23_BROKEN
,
884 .ops
= &tegra_sdhci_ops
,
887 static const struct sdhci_tegra_soc_data soc_data_tegra30
= {
888 .pdata
= &sdhci_tegra30_pdata
,
889 .nvquirks
= NVQUIRK_ENABLE_SDHCI_SPEC_300
|
890 NVQUIRK_ENABLE_SDR50
|
891 NVQUIRK_ENABLE_SDR104
|
892 NVQUIRK_HAS_PADCALIB
,
895 static const struct sdhci_ops tegra114_sdhci_ops
= {
896 .get_ro
= tegra_sdhci_get_ro
,
897 .read_w
= tegra_sdhci_readw
,
898 .write_w
= tegra_sdhci_writew
,
899 .write_l
= tegra_sdhci_writel
,
900 .set_clock
= tegra_sdhci_set_clock
,
901 .set_bus_width
= sdhci_set_bus_width
,
902 .reset
= tegra_sdhci_reset
,
903 .platform_execute_tuning
= tegra_sdhci_execute_tuning
,
904 .set_uhs_signaling
= tegra_sdhci_set_uhs_signaling
,
905 .voltage_switch
= tegra_sdhci_voltage_switch
,
906 .get_max_clock
= tegra_sdhci_get_max_clock
,
909 static const struct sdhci_pltfm_data sdhci_tegra114_pdata
= {
910 .quirks
= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL
|
911 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK
|
912 SDHCI_QUIRK_SINGLE_POWER_WRITE
|
913 SDHCI_QUIRK_NO_HISPD_BIT
|
914 SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC
|
915 SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN
,
916 .quirks2
= SDHCI_QUIRK2_PRESET_VALUE_BROKEN
,
917 .ops
= &tegra114_sdhci_ops
,
920 static const struct sdhci_tegra_soc_data soc_data_tegra114
= {
921 .pdata
= &sdhci_tegra114_pdata
,
924 static const struct sdhci_pltfm_data sdhci_tegra124_pdata
= {
925 .quirks
= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL
|
926 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK
|
927 SDHCI_QUIRK_SINGLE_POWER_WRITE
|
928 SDHCI_QUIRK_NO_HISPD_BIT
|
929 SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC
|
930 SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN
,
931 .quirks2
= SDHCI_QUIRK2_PRESET_VALUE_BROKEN
|
933 * The TRM states that the SD/MMC controller found on
934 * Tegra124 can address 34 bits (the maximum supported by
935 * the Tegra memory controller), but tests show that DMA
936 * to or from above 4 GiB doesn't work. This is possibly
937 * caused by missing programming, though it's not obvious
938 * what sequence is required. Mark 64-bit DMA broken for
939 * now to fix this for existing users (e.g. Nyan boards).
941 SDHCI_QUIRK2_BROKEN_64_BIT_DMA
,
942 .ops
= &tegra114_sdhci_ops
,
945 static const struct sdhci_tegra_soc_data soc_data_tegra124
= {
946 .pdata
= &sdhci_tegra124_pdata
,
949 static const struct sdhci_ops tegra210_sdhci_ops
= {
950 .get_ro
= tegra_sdhci_get_ro
,
951 .read_w
= tegra_sdhci_readw
,
952 .write_w
= tegra210_sdhci_writew
,
953 .write_l
= tegra_sdhci_writel
,
954 .set_clock
= tegra_sdhci_set_clock
,
955 .set_bus_width
= sdhci_set_bus_width
,
956 .reset
= tegra_sdhci_reset
,
957 .set_uhs_signaling
= tegra_sdhci_set_uhs_signaling
,
958 .voltage_switch
= tegra_sdhci_voltage_switch
,
959 .get_max_clock
= tegra_sdhci_get_max_clock
,
962 static const struct sdhci_pltfm_data sdhci_tegra210_pdata
= {
963 .quirks
= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL
|
964 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK
|
965 SDHCI_QUIRK_SINGLE_POWER_WRITE
|
966 SDHCI_QUIRK_NO_HISPD_BIT
|
967 SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC
|
968 SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN
,
969 .quirks2
= SDHCI_QUIRK2_PRESET_VALUE_BROKEN
,
970 .ops
= &tegra210_sdhci_ops
,
973 static const struct sdhci_tegra_soc_data soc_data_tegra210
= {
974 .pdata
= &sdhci_tegra210_pdata
,
975 .nvquirks
= NVQUIRK_NEEDS_PAD_CONTROL
|
976 NVQUIRK_HAS_PADCALIB
|
977 NVQUIRK_DIS_CARD_CLK_CONFIG_TAP
|
978 NVQUIRK_ENABLE_SDR50
|
979 NVQUIRK_ENABLE_SDR104
,
982 static const struct sdhci_ops tegra186_sdhci_ops
= {
983 .get_ro
= tegra_sdhci_get_ro
,
984 .read_w
= tegra_sdhci_readw
,
985 .write_l
= tegra_sdhci_writel
,
986 .set_clock
= tegra_sdhci_set_clock
,
987 .set_bus_width
= sdhci_set_bus_width
,
988 .reset
= tegra_sdhci_reset
,
989 .set_uhs_signaling
= tegra_sdhci_set_uhs_signaling
,
990 .voltage_switch
= tegra_sdhci_voltage_switch
,
991 .get_max_clock
= tegra_sdhci_get_max_clock
,
994 static const struct sdhci_pltfm_data sdhci_tegra186_pdata
= {
995 .quirks
= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL
|
996 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK
|
997 SDHCI_QUIRK_SINGLE_POWER_WRITE
|
998 SDHCI_QUIRK_NO_HISPD_BIT
|
999 SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC
|
1000 SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN
,
1001 .quirks2
= SDHCI_QUIRK2_PRESET_VALUE_BROKEN
|
1002 /* SDHCI controllers on Tegra186 support 40-bit addressing.
1003 * IOVA addresses are 48-bit wide on Tegra186.
1004 * With 64-bit dma mask used for SDHCI, accesses can
1005 * be broken. Disable 64-bit dma, which would fall back
1006 * to 32-bit dma mask. Ideally 40-bit dma mask would work,
1007 * But it is not supported as of now.
1009 SDHCI_QUIRK2_BROKEN_64_BIT_DMA
,
1010 .ops
= &tegra186_sdhci_ops
,
1013 static const struct sdhci_tegra_soc_data soc_data_tegra186
= {
1014 .pdata
= &sdhci_tegra186_pdata
,
1015 .nvquirks
= NVQUIRK_NEEDS_PAD_CONTROL
|
1016 NVQUIRK_HAS_PADCALIB
|
1017 NVQUIRK_DIS_CARD_CLK_CONFIG_TAP
|
1018 NVQUIRK_ENABLE_SDR50
|
1019 NVQUIRK_ENABLE_SDR104
,
1022 static const struct of_device_id sdhci_tegra_dt_match
[] = {
1023 { .compatible
= "nvidia,tegra186-sdhci", .data
= &soc_data_tegra186
},
1024 { .compatible
= "nvidia,tegra210-sdhci", .data
= &soc_data_tegra210
},
1025 { .compatible
= "nvidia,tegra124-sdhci", .data
= &soc_data_tegra124
},
1026 { .compatible
= "nvidia,tegra114-sdhci", .data
= &soc_data_tegra114
},
1027 { .compatible
= "nvidia,tegra30-sdhci", .data
= &soc_data_tegra30
},
1028 { .compatible
= "nvidia,tegra20-sdhci", .data
= &soc_data_tegra20
},
1031 MODULE_DEVICE_TABLE(of
, sdhci_tegra_dt_match
);
1033 static int sdhci_tegra_probe(struct platform_device
*pdev
)
1035 const struct of_device_id
*match
;
1036 const struct sdhci_tegra_soc_data
*soc_data
;
1037 struct sdhci_host
*host
;
1038 struct sdhci_pltfm_host
*pltfm_host
;
1039 struct sdhci_tegra
*tegra_host
;
1043 match
= of_match_device(sdhci_tegra_dt_match
, &pdev
->dev
);
1046 soc_data
= match
->data
;
1048 host
= sdhci_pltfm_init(pdev
, soc_data
->pdata
, sizeof(*tegra_host
));
1050 return PTR_ERR(host
);
1051 pltfm_host
= sdhci_priv(host
);
1053 tegra_host
= sdhci_pltfm_priv(pltfm_host
);
1054 tegra_host
->ddr_signaling
= false;
1055 tegra_host
->pad_calib_required
= false;
1056 tegra_host
->pad_control_available
= false;
1057 tegra_host
->soc_data
= soc_data
;
1059 if (soc_data
->nvquirks
& NVQUIRK_NEEDS_PAD_CONTROL
) {
1060 rc
= tegra_sdhci_init_pinctrl_info(&pdev
->dev
, tegra_host
);
1062 host
->mmc_host_ops
.start_signal_voltage_switch
=
1063 sdhci_tegra_start_signal_voltage_switch
;
1066 /* Hook to periodically rerun pad calibration */
1067 if (soc_data
->nvquirks
& NVQUIRK_HAS_PADCALIB
)
1068 host
->mmc_host_ops
.request
= tegra_sdhci_request
;
1070 host
->mmc_host_ops
.hs400_enhanced_strobe
=
1071 tegra_sdhci_hs400_enhanced_strobe
;
1073 rc
= mmc_of_parse(host
->mmc
);
1077 if (tegra_host
->soc_data
->nvquirks
& NVQUIRK_ENABLE_DDR50
)
1078 host
->mmc
->caps
|= MMC_CAP_1_8V_DDR
;
1080 tegra_sdhci_parse_pad_autocal_dt(host
);
1082 tegra_sdhci_parse_tap_and_trim(host
);
1084 tegra_host
->power_gpio
= devm_gpiod_get_optional(&pdev
->dev
, "power",
1086 if (IS_ERR(tegra_host
->power_gpio
)) {
1087 rc
= PTR_ERR(tegra_host
->power_gpio
);
1091 clk
= devm_clk_get(mmc_dev(host
->mmc
), NULL
);
1093 dev_err(mmc_dev(host
->mmc
), "clk err\n");
1097 clk_prepare_enable(clk
);
1098 pltfm_host
->clk
= clk
;
1100 tegra_host
->rst
= devm_reset_control_get_exclusive(&pdev
->dev
,
1102 if (IS_ERR(tegra_host
->rst
)) {
1103 rc
= PTR_ERR(tegra_host
->rst
);
1104 dev_err(&pdev
->dev
, "failed to get reset control: %d\n", rc
);
1108 rc
= reset_control_assert(tegra_host
->rst
);
1112 usleep_range(2000, 4000);
1114 rc
= reset_control_deassert(tegra_host
->rst
);
1118 usleep_range(2000, 4000);
1120 rc
= sdhci_add_host(host
);
1127 reset_control_assert(tegra_host
->rst
);
1129 clk_disable_unprepare(pltfm_host
->clk
);
1133 sdhci_pltfm_free(pdev
);
1137 static int sdhci_tegra_remove(struct platform_device
*pdev
)
1139 struct sdhci_host
*host
= platform_get_drvdata(pdev
);
1140 struct sdhci_pltfm_host
*pltfm_host
= sdhci_priv(host
);
1141 struct sdhci_tegra
*tegra_host
= sdhci_pltfm_priv(pltfm_host
);
1143 sdhci_remove_host(host
, 0);
1145 reset_control_assert(tegra_host
->rst
);
1146 usleep_range(2000, 4000);
1147 clk_disable_unprepare(pltfm_host
->clk
);
1149 sdhci_pltfm_free(pdev
);
1154 static struct platform_driver sdhci_tegra_driver
= {
1156 .name
= "sdhci-tegra",
1157 .of_match_table
= sdhci_tegra_dt_match
,
1158 .pm
= &sdhci_pltfm_pmops
,
1160 .probe
= sdhci_tegra_probe
,
1161 .remove
= sdhci_tegra_remove
,
1164 module_platform_driver(sdhci_tegra_driver
);
1166 MODULE_DESCRIPTION("SDHCI driver for Tegra");
1167 MODULE_AUTHOR("Google, Inc.");
1168 MODULE_LICENSE("GPL v2");