Merge tag 'mmc-v5.4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc

Pull more MMC updates from Ulf Hansson:
"A couple more updates/fixes for MMC:

- sdhci-pci: Add Genesys Logic GL975x support

- sdhci-tegra: Recover loss in throughput for DMA

- sdhci-of-esdhc: Fix DMA bug"

* tag 'mmc-v5.4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc:
mmc: host: sdhci-pci: Add Genesys Logic GL975x support
mmc: tegra: Implement ->set_dma_mask()
mmc: sdhci: Let drivers define their DMA mask
mmc: sdhci-of-esdhc: set DMA snooping based on DMA coherence
mmc: sdhci: improve ADMA error reporting

+1
drivers/mmc/host/Kconfig
··· 94 94 depends on MMC_SDHCI && PCI 95 95 select MMC_CQHCI 96 96 select IOSF_MBI if X86 97 + select MMC_SDHCI_IO_ACCESSORS 97 98 help 98 99 This selects the PCI Secure Digital Host Controller Interface. 99 100 Most controllers found today are PCI devices.
+1 -1
drivers/mmc/host/Makefile
··· 13 13 obj-$(CONFIG_MMC_SDHCI) += sdhci.o 14 14 obj-$(CONFIG_MMC_SDHCI_PCI) += sdhci-pci.o 15 15 sdhci-pci-y += sdhci-pci-core.o sdhci-pci-o2micro.o sdhci-pci-arasan.o \ 16 - sdhci-pci-dwc-mshc.o 16 + sdhci-pci-dwc-mshc.o sdhci-pci-gli.o 17 17 obj-$(subst m,y,$(CONFIG_MMC_SDHCI_PCI)) += sdhci-pci-data.o 18 18 obj-$(CONFIG_MMC_SDHCI_ACPI) += sdhci-acpi.o 19 19 obj-$(CONFIG_MMC_SDHCI_PXAV3) += sdhci-pxav3.o
+6 -1
drivers/mmc/host/sdhci-of-esdhc.c
··· 495 495 dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40)); 496 496 497 497 value = sdhci_readl(host, ESDHC_DMA_SYSCTL); 498 - value |= ESDHC_DMA_SNOOP; 498 + 499 + if (of_dma_is_coherent(dev->of_node)) 500 + value |= ESDHC_DMA_SNOOP; 501 + else 502 + value &= ~ESDHC_DMA_SNOOP; 503 + 499 504 sdhci_writel(host, value, ESDHC_DMA_SYSCTL); 500 505 return 0; 501 506 }
+2
drivers/mmc/host/sdhci-pci-core.c
··· 1685 1685 SDHCI_PCI_DEVICE(O2, SEABIRD1, o2), 1686 1686 SDHCI_PCI_DEVICE(ARASAN, PHY_EMMC, arasan), 1687 1687 SDHCI_PCI_DEVICE(SYNOPSYS, DWC_MSHC, snps), 1688 + SDHCI_PCI_DEVICE(GLI, 9750, gl9750), 1689 + SDHCI_PCI_DEVICE(GLI, 9755, gl9755), 1688 1690 SDHCI_PCI_DEVICE_CLASS(AMD, SYSTEM_SDHCI, PCI_CLASS_MASK, amd), 1689 1691 /* Generic SD host controller */ 1690 1692 {PCI_DEVICE_CLASS(SYSTEM_SDHCI, PCI_CLASS_MASK)},
+352
drivers/mmc/host/sdhci-pci-gli.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Copyright (C) 2019 Genesys Logic, Inc. 4 + * 5 + * Authors: Ben Chuang <ben.chuang@genesyslogic.com.tw> 6 + * 7 + * Version: v0.9.0 (2019-08-08) 8 + */ 9 + 10 + #include <linux/bitfield.h> 11 + #include <linux/bits.h> 12 + #include <linux/pci.h> 13 + #include <linux/mmc/mmc.h> 14 + #include <linux/delay.h> 15 + #include "sdhci.h" 16 + #include "sdhci-pci.h" 17 + 18 + /* Genesys Logic extra registers */ 19 + #define SDHCI_GLI_9750_WT 0x800 20 + #define SDHCI_GLI_9750_WT_EN BIT(0) 21 + #define GLI_9750_WT_EN_ON 0x1 22 + #define GLI_9750_WT_EN_OFF 0x0 23 + 24 + #define SDHCI_GLI_9750_DRIVING 0x860 25 + #define SDHCI_GLI_9750_DRIVING_1 GENMASK(11, 0) 26 + #define SDHCI_GLI_9750_DRIVING_2 GENMASK(27, 26) 27 + #define GLI_9750_DRIVING_1_VALUE 0xFFF 28 + #define GLI_9750_DRIVING_2_VALUE 0x3 29 + 30 + #define SDHCI_GLI_9750_PLL 0x864 31 + #define SDHCI_GLI_9750_PLL_TX2_INV BIT(23) 32 + #define SDHCI_GLI_9750_PLL_TX2_DLY GENMASK(22, 20) 33 + #define GLI_9750_PLL_TX2_INV_VALUE 0x1 34 + #define GLI_9750_PLL_TX2_DLY_VALUE 0x0 35 + 36 + #define SDHCI_GLI_9750_SW_CTRL 0x874 37 + #define SDHCI_GLI_9750_SW_CTRL_4 GENMASK(7, 6) 38 + #define GLI_9750_SW_CTRL_4_VALUE 0x3 39 + 40 + #define SDHCI_GLI_9750_MISC 0x878 41 + #define SDHCI_GLI_9750_MISC_TX1_INV BIT(2) 42 + #define SDHCI_GLI_9750_MISC_RX_INV BIT(3) 43 + #define SDHCI_GLI_9750_MISC_TX1_DLY GENMASK(6, 4) 44 + #define GLI_9750_MISC_TX1_INV_VALUE 0x0 45 + #define GLI_9750_MISC_RX_INV_ON 0x1 46 + #define GLI_9750_MISC_RX_INV_OFF 0x0 47 + #define GLI_9750_MISC_RX_INV_VALUE GLI_9750_MISC_RX_INV_OFF 48 + #define GLI_9750_MISC_TX1_DLY_VALUE 0x5 49 + 50 + #define SDHCI_GLI_9750_TUNING_CONTROL 0x540 51 + #define SDHCI_GLI_9750_TUNING_CONTROL_EN BIT(4) 52 + #define GLI_9750_TUNING_CONTROL_EN_ON 0x1 53 + #define GLI_9750_TUNING_CONTROL_EN_OFF 0x0 54 + #define SDHCI_GLI_9750_TUNING_CONTROL_GLITCH_1 BIT(16) 55 + #define SDHCI_GLI_9750_TUNING_CONTROL_GLITCH_2 GENMASK(20, 19) 56 + #define GLI_9750_TUNING_CONTROL_GLITCH_1_VALUE 0x1 57 + #define GLI_9750_TUNING_CONTROL_GLITCH_2_VALUE 0x2 58 + 59 + #define SDHCI_GLI_9750_TUNING_PARAMETERS 0x544 60 + #define SDHCI_GLI_9750_TUNING_PARAMETERS_RX_DLY GENMASK(2, 0) 61 + #define GLI_9750_TUNING_PARAMETERS_RX_DLY_VALUE 0x1 62 + 63 + #define GLI_MAX_TUNING_LOOP 40 64 + 65 + /* Genesys Logic chipset */ 66 + static inline void gl9750_wt_on(struct sdhci_host *host) 67 + { 68 + u32 wt_value; 69 + u32 wt_enable; 70 + 71 + wt_value = sdhci_readl(host, SDHCI_GLI_9750_WT); 72 + wt_enable = FIELD_GET(SDHCI_GLI_9750_WT_EN, wt_value); 73 + 74 + if (wt_enable == GLI_9750_WT_EN_ON) 75 + return; 76 + 77 + wt_value &= ~SDHCI_GLI_9750_WT_EN; 78 + wt_value |= FIELD_PREP(SDHCI_GLI_9750_WT_EN, GLI_9750_WT_EN_ON); 79 + 80 + sdhci_writel(host, wt_value, SDHCI_GLI_9750_WT); 81 + } 82 + 83 + static inline void gl9750_wt_off(struct sdhci_host *host) 84 + { 85 + u32 wt_value; 86 + u32 wt_enable; 87 + 88 + wt_value = sdhci_readl(host, SDHCI_GLI_9750_WT); 89 + wt_enable = FIELD_GET(SDHCI_GLI_9750_WT_EN, wt_value); 90 + 91 + if (wt_enable == GLI_9750_WT_EN_OFF) 92 + return; 93 + 94 + wt_value &= ~SDHCI_GLI_9750_WT_EN; 95 + wt_value |= FIELD_PREP(SDHCI_GLI_9750_WT_EN, GLI_9750_WT_EN_OFF); 96 + 97 + sdhci_writel(host, wt_value, SDHCI_GLI_9750_WT); 98 + } 99 + 100 + static void gli_set_9750(struct sdhci_host *host) 101 + { 102 + u32 driving_value; 103 + u32 pll_value; 104 + u32 sw_ctrl_value; 105 + u32 misc_value; 106 + u32 parameter_value; 107 + u32 control_value; 108 + u16 ctrl2; 109 + 110 + gl9750_wt_on(host); 111 + 112 + driving_value = sdhci_readl(host, SDHCI_GLI_9750_DRIVING); 113 + pll_value = sdhci_readl(host, SDHCI_GLI_9750_PLL); 114 + sw_ctrl_value = sdhci_readl(host, SDHCI_GLI_9750_SW_CTRL); 115 + misc_value = sdhci_readl(host, SDHCI_GLI_9750_MISC); 116 + parameter_value = sdhci_readl(host, SDHCI_GLI_9750_TUNING_PARAMETERS); 117 + control_value = sdhci_readl(host, SDHCI_GLI_9750_TUNING_CONTROL); 118 + 119 + driving_value &= ~(SDHCI_GLI_9750_DRIVING_1); 120 + driving_value &= ~(SDHCI_GLI_9750_DRIVING_2); 121 + driving_value |= FIELD_PREP(SDHCI_GLI_9750_DRIVING_1, 122 + GLI_9750_DRIVING_1_VALUE); 123 + driving_value |= FIELD_PREP(SDHCI_GLI_9750_DRIVING_2, 124 + GLI_9750_DRIVING_2_VALUE); 125 + sdhci_writel(host, driving_value, SDHCI_GLI_9750_DRIVING); 126 + 127 + sw_ctrl_value &= ~SDHCI_GLI_9750_SW_CTRL_4; 128 + sw_ctrl_value |= FIELD_PREP(SDHCI_GLI_9750_SW_CTRL_4, 129 + GLI_9750_SW_CTRL_4_VALUE); 130 + sdhci_writel(host, sw_ctrl_value, SDHCI_GLI_9750_SW_CTRL); 131 + 132 + /* reset the tuning flow after reinit and before starting tuning */ 133 + pll_value &= ~SDHCI_GLI_9750_PLL_TX2_INV; 134 + pll_value &= ~SDHCI_GLI_9750_PLL_TX2_DLY; 135 + pll_value |= FIELD_PREP(SDHCI_GLI_9750_PLL_TX2_INV, 136 + GLI_9750_PLL_TX2_INV_VALUE); 137 + pll_value |= FIELD_PREP(SDHCI_GLI_9750_PLL_TX2_DLY, 138 + GLI_9750_PLL_TX2_DLY_VALUE); 139 + 140 + misc_value &= ~SDHCI_GLI_9750_MISC_TX1_INV; 141 + misc_value &= ~SDHCI_GLI_9750_MISC_RX_INV; 142 + misc_value &= ~SDHCI_GLI_9750_MISC_TX1_DLY; 143 + misc_value |= FIELD_PREP(SDHCI_GLI_9750_MISC_TX1_INV, 144 + GLI_9750_MISC_TX1_INV_VALUE); 145 + misc_value |= FIELD_PREP(SDHCI_GLI_9750_MISC_RX_INV, 146 + GLI_9750_MISC_RX_INV_VALUE); 147 + misc_value |= FIELD_PREP(SDHCI_GLI_9750_MISC_TX1_DLY, 148 + GLI_9750_MISC_TX1_DLY_VALUE); 149 + 150 + parameter_value &= ~SDHCI_GLI_9750_TUNING_PARAMETERS_RX_DLY; 151 + parameter_value |= FIELD_PREP(SDHCI_GLI_9750_TUNING_PARAMETERS_RX_DLY, 152 + GLI_9750_TUNING_PARAMETERS_RX_DLY_VALUE); 153 + 154 + control_value &= ~SDHCI_GLI_9750_TUNING_CONTROL_GLITCH_1; 155 + control_value &= ~SDHCI_GLI_9750_TUNING_CONTROL_GLITCH_2; 156 + control_value |= FIELD_PREP(SDHCI_GLI_9750_TUNING_CONTROL_GLITCH_1, 157 + GLI_9750_TUNING_CONTROL_GLITCH_1_VALUE); 158 + control_value |= FIELD_PREP(SDHCI_GLI_9750_TUNING_CONTROL_GLITCH_2, 159 + GLI_9750_TUNING_CONTROL_GLITCH_2_VALUE); 160 + 161 + sdhci_writel(host, pll_value, SDHCI_GLI_9750_PLL); 162 + sdhci_writel(host, misc_value, SDHCI_GLI_9750_MISC); 163 + 164 + /* disable tuned clk */ 165 + ctrl2 = sdhci_readw(host, SDHCI_HOST_CONTROL2); 166 + ctrl2 &= ~SDHCI_CTRL_TUNED_CLK; 167 + sdhci_writew(host, ctrl2, SDHCI_HOST_CONTROL2); 168 + 169 + /* enable tuning parameters control */ 170 + control_value &= ~SDHCI_GLI_9750_TUNING_CONTROL_EN; 171 + control_value |= FIELD_PREP(SDHCI_GLI_9750_TUNING_CONTROL_EN, 172 + GLI_9750_TUNING_CONTROL_EN_ON); 173 + sdhci_writel(host, control_value, SDHCI_GLI_9750_TUNING_CONTROL); 174 + 175 + /* write tuning parameters */ 176 + sdhci_writel(host, parameter_value, SDHCI_GLI_9750_TUNING_PARAMETERS); 177 + 178 + /* disable tuning parameters control */ 179 + control_value &= ~SDHCI_GLI_9750_TUNING_CONTROL_EN; 180 + control_value |= FIELD_PREP(SDHCI_GLI_9750_TUNING_CONTROL_EN, 181 + GLI_9750_TUNING_CONTROL_EN_OFF); 182 + sdhci_writel(host, control_value, SDHCI_GLI_9750_TUNING_CONTROL); 183 + 184 + /* clear tuned clk */ 185 + ctrl2 = sdhci_readw(host, SDHCI_HOST_CONTROL2); 186 + ctrl2 &= ~SDHCI_CTRL_TUNED_CLK; 187 + sdhci_writew(host, ctrl2, SDHCI_HOST_CONTROL2); 188 + 189 + gl9750_wt_off(host); 190 + } 191 + 192 + static void gli_set_9750_rx_inv(struct sdhci_host *host, bool b) 193 + { 194 + u32 misc_value; 195 + 196 + gl9750_wt_on(host); 197 + 198 + misc_value = sdhci_readl(host, SDHCI_GLI_9750_MISC); 199 + misc_value &= ~SDHCI_GLI_9750_MISC_RX_INV; 200 + if (b) { 201 + misc_value |= FIELD_PREP(SDHCI_GLI_9750_MISC_RX_INV, 202 + GLI_9750_MISC_RX_INV_ON); 203 + } else { 204 + misc_value |= FIELD_PREP(SDHCI_GLI_9750_MISC_RX_INV, 205 + GLI_9750_MISC_RX_INV_OFF); 206 + } 207 + sdhci_writel(host, misc_value, SDHCI_GLI_9750_MISC); 208 + 209 + gl9750_wt_off(host); 210 + } 211 + 212 + static int __sdhci_execute_tuning_9750(struct sdhci_host *host, u32 opcode) 213 + { 214 + int i; 215 + int rx_inv; 216 + 217 + for (rx_inv = 0; rx_inv < 2; rx_inv++) { 218 + gli_set_9750_rx_inv(host, !!rx_inv); 219 + sdhci_start_tuning(host); 220 + 221 + for (i = 0; i < GLI_MAX_TUNING_LOOP; i++) { 222 + u16 ctrl; 223 + 224 + sdhci_send_tuning(host, opcode); 225 + 226 + if (!host->tuning_done) { 227 + sdhci_abort_tuning(host, opcode); 228 + break; 229 + } 230 + 231 + ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); 232 + if (!(ctrl & SDHCI_CTRL_EXEC_TUNING)) { 233 + if (ctrl & SDHCI_CTRL_TUNED_CLK) 234 + return 0; /* Success! */ 235 + break; 236 + } 237 + } 238 + } 239 + if (!host->tuning_done) { 240 + pr_info("%s: Tuning timeout, falling back to fixed sampling clock\n", 241 + mmc_hostname(host->mmc)); 242 + return -ETIMEDOUT; 243 + } 244 + 245 + pr_info("%s: Tuning failed, falling back to fixed sampling clock\n", 246 + mmc_hostname(host->mmc)); 247 + sdhci_reset_tuning(host); 248 + 249 + return -EAGAIN; 250 + } 251 + 252 + static int gl9750_execute_tuning(struct sdhci_host *host, u32 opcode) 253 + { 254 + host->mmc->retune_period = 0; 255 + if (host->tuning_mode == SDHCI_TUNING_MODE_1) 256 + host->mmc->retune_period = host->tuning_count; 257 + 258 + gli_set_9750(host); 259 + host->tuning_err = __sdhci_execute_tuning_9750(host, opcode); 260 + sdhci_end_tuning(host); 261 + 262 + return 0; 263 + } 264 + 265 + static int gli_probe_slot_gl9750(struct sdhci_pci_slot *slot) 266 + { 267 + struct sdhci_host *host = slot->host; 268 + 269 + slot->host->mmc->caps2 |= MMC_CAP2_NO_SDIO; 270 + sdhci_enable_v4_mode(host); 271 + 272 + return 0; 273 + } 274 + 275 + static int gli_probe_slot_gl9755(struct sdhci_pci_slot *slot) 276 + { 277 + struct sdhci_host *host = slot->host; 278 + 279 + slot->host->mmc->caps2 |= MMC_CAP2_NO_SDIO; 280 + sdhci_enable_v4_mode(host); 281 + 282 + return 0; 283 + } 284 + 285 + static void sdhci_gli_voltage_switch(struct sdhci_host *host) 286 + { 287 + /* 288 + * According to Section 3.6.1 signal voltage switch procedure in 289 + * SD Host Controller Simplified Spec. 4.20, steps 6~8 are as 290 + * follows: 291 + * (6) Set 1.8V Signal Enable in the Host Control 2 register. 292 + * (7) Wait 5ms. 1.8V voltage regulator shall be stable within this 293 + * period. 294 + * (8) If 1.8V Signal Enable is cleared by Host Controller, go to 295 + * step (12). 296 + * 297 + * Wait 5ms after set 1.8V signal enable in Host Control 2 register 298 + * to ensure 1.8V signal enable bit is set by GL9750/GL9755. 299 + */ 300 + usleep_range(5000, 5500); 301 + } 302 + 303 + static void sdhci_gl9750_reset(struct sdhci_host *host, u8 mask) 304 + { 305 + sdhci_reset(host, mask); 306 + gli_set_9750(host); 307 + } 308 + 309 + static u32 sdhci_gl9750_readl(struct sdhci_host *host, int reg) 310 + { 311 + u32 value; 312 + 313 + value = readl(host->ioaddr + reg); 314 + if (unlikely(reg == SDHCI_MAX_CURRENT && !(value & 0xff))) 315 + value |= 0xc8; 316 + 317 + return value; 318 + } 319 + 320 + static const struct sdhci_ops sdhci_gl9755_ops = { 321 + .set_clock = sdhci_set_clock, 322 + .enable_dma = sdhci_pci_enable_dma, 323 + .set_bus_width = sdhci_set_bus_width, 324 + .reset = sdhci_reset, 325 + .set_uhs_signaling = sdhci_set_uhs_signaling, 326 + .voltage_switch = sdhci_gli_voltage_switch, 327 + }; 328 + 329 + const struct sdhci_pci_fixes sdhci_gl9755 = { 330 + .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, 331 + .quirks2 = SDHCI_QUIRK2_BROKEN_DDR50, 332 + .probe_slot = gli_probe_slot_gl9755, 333 + .ops = &sdhci_gl9755_ops, 334 + }; 335 + 336 + static const struct sdhci_ops sdhci_gl9750_ops = { 337 + .read_l = sdhci_gl9750_readl, 338 + .set_clock = sdhci_set_clock, 339 + .enable_dma = sdhci_pci_enable_dma, 340 + .set_bus_width = sdhci_set_bus_width, 341 + .reset = sdhci_gl9750_reset, 342 + .set_uhs_signaling = sdhci_set_uhs_signaling, 343 + .voltage_switch = sdhci_gli_voltage_switch, 344 + .platform_execute_tuning = gl9750_execute_tuning, 345 + }; 346 + 347 + const struct sdhci_pci_fixes sdhci_gl9750 = { 348 + .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, 349 + .quirks2 = SDHCI_QUIRK2_BROKEN_DDR50, 350 + .probe_slot = gli_probe_slot_gl9750, 351 + .ops = &sdhci_gl9750_ops, 352 + };
+5
drivers/mmc/host/sdhci-pci.h
··· 68 68 69 69 #define PCI_DEVICE_ID_SYNOPSYS_DWC_MSHC 0xc202 70 70 71 + #define PCI_DEVICE_ID_GLI_9755 0x9755 72 + #define PCI_DEVICE_ID_GLI_9750 0x9750 73 + 71 74 /* 72 75 * PCI device class and mask 73 76 */ ··· 191 188 extern const struct sdhci_pci_fixes sdhci_arasan; 192 189 extern const struct sdhci_pci_fixes sdhci_snps; 193 190 extern const struct sdhci_pci_fixes sdhci_o2; 191 + extern const struct sdhci_pci_fixes sdhci_gl9750; 192 + extern const struct sdhci_pci_fixes sdhci_gl9755; 194 193 195 194 #endif /* __SDHCI_PCI_H */
+28 -20
drivers/mmc/host/sdhci-tegra.c
··· 4 4 */ 5 5 6 6 #include <linux/delay.h> 7 + #include <linux/dma-mapping.h> 7 8 #include <linux/err.h> 8 9 #include <linux/module.h> 9 10 #include <linux/init.h> ··· 105 104 106 105 struct sdhci_tegra_soc_data { 107 106 const struct sdhci_pltfm_data *pdata; 107 + u64 dma_mask; 108 108 u32 nvquirks; 109 109 u8 min_tap_delay; 110 110 u8 max_tap_delay; ··· 1235 1233 .update_dcmd_desc = sdhci_tegra_update_dcmd_desc, 1236 1234 }; 1237 1235 1236 + static int tegra_sdhci_set_dma_mask(struct sdhci_host *host) 1237 + { 1238 + struct sdhci_pltfm_host *platform = sdhci_priv(host); 1239 + struct sdhci_tegra *tegra = sdhci_pltfm_priv(platform); 1240 + const struct sdhci_tegra_soc_data *soc = tegra->soc_data; 1241 + struct device *dev = mmc_dev(host->mmc); 1242 + 1243 + if (soc->dma_mask) 1244 + return dma_set_mask_and_coherent(dev, soc->dma_mask); 1245 + 1246 + return 0; 1247 + } 1248 + 1238 1249 static const struct sdhci_ops tegra_sdhci_ops = { 1239 1250 .get_ro = tegra_sdhci_get_ro, 1240 1251 .read_w = tegra_sdhci_readw, 1241 1252 .write_l = tegra_sdhci_writel, 1242 1253 .set_clock = tegra_sdhci_set_clock, 1254 + .set_dma_mask = tegra_sdhci_set_dma_mask, 1243 1255 .set_bus_width = sdhci_set_bus_width, 1244 1256 .reset = tegra_sdhci_reset, 1245 1257 .platform_execute_tuning = tegra_sdhci_execute_tuning, ··· 1273 1257 1274 1258 static const struct sdhci_tegra_soc_data soc_data_tegra20 = { 1275 1259 .pdata = &sdhci_tegra20_pdata, 1260 + .dma_mask = DMA_BIT_MASK(32), 1276 1261 .nvquirks = NVQUIRK_FORCE_SDHCI_SPEC_200 | 1277 1262 NVQUIRK_ENABLE_BLOCK_GAP_DET, 1278 1263 }; ··· 1300 1283 1301 1284 static const struct sdhci_tegra_soc_data soc_data_tegra30 = { 1302 1285 .pdata = &sdhci_tegra30_pdata, 1286 + .dma_mask = DMA_BIT_MASK(32), 1303 1287 .nvquirks = NVQUIRK_ENABLE_SDHCI_SPEC_300 | 1304 1288 NVQUIRK_ENABLE_SDR50 | 1305 1289 NVQUIRK_ENABLE_SDR104 | ··· 1313 1295 .write_w = tegra_sdhci_writew, 1314 1296 .write_l = tegra_sdhci_writel, 1315 1297 .set_clock = tegra_sdhci_set_clock, 1298 + .set_dma_mask = tegra_sdhci_set_dma_mask, 1316 1299 .set_bus_width = sdhci_set_bus_width, 1317 1300 .reset = tegra_sdhci_reset, 1318 1301 .platform_execute_tuning = tegra_sdhci_execute_tuning, ··· 1335 1316 1336 1317 static const struct sdhci_tegra_soc_data soc_data_tegra114 = { 1337 1318 .pdata = &sdhci_tegra114_pdata, 1319 + .dma_mask = DMA_BIT_MASK(32), 1338 1320 }; 1339 1321 1340 1322 static const struct sdhci_pltfm_data sdhci_tegra124_pdata = { ··· 1345 1325 SDHCI_QUIRK_NO_HISPD_BIT | 1346 1326 SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC | 1347 1327 SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, 1348 - .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | 1349 - /* 1350 - * The TRM states that the SD/MMC controller found on 1351 - * Tegra124 can address 34 bits (the maximum supported by 1352 - * the Tegra memory controller), but tests show that DMA 1353 - * to or from above 4 GiB doesn't work. This is possibly 1354 - * caused by missing programming, though it's not obvious 1355 - * what sequence is required. Mark 64-bit DMA broken for 1356 - * now to fix this for existing users (e.g. Nyan boards). 1357 - */ 1358 - SDHCI_QUIRK2_BROKEN_64_BIT_DMA, 1328 + .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, 1359 1329 .ops = &tegra114_sdhci_ops, 1360 1330 }; 1361 1331 1362 1332 static const struct sdhci_tegra_soc_data soc_data_tegra124 = { 1363 1333 .pdata = &sdhci_tegra124_pdata, 1334 + .dma_mask = DMA_BIT_MASK(34), 1364 1335 }; 1365 1336 1366 1337 static const struct sdhci_ops tegra210_sdhci_ops = { ··· 1360 1349 .write_w = tegra210_sdhci_writew, 1361 1350 .write_l = tegra_sdhci_writel, 1362 1351 .set_clock = tegra_sdhci_set_clock, 1352 + .set_dma_mask = tegra_sdhci_set_dma_mask, 1363 1353 .set_bus_width = sdhci_set_bus_width, 1364 1354 .reset = tegra_sdhci_reset, 1365 1355 .set_uhs_signaling = tegra_sdhci_set_uhs_signaling, ··· 1381 1369 1382 1370 static const struct sdhci_tegra_soc_data soc_data_tegra210 = { 1383 1371 .pdata = &sdhci_tegra210_pdata, 1372 + .dma_mask = DMA_BIT_MASK(34), 1384 1373 .nvquirks = NVQUIRK_NEEDS_PAD_CONTROL | 1385 1374 NVQUIRK_HAS_PADCALIB | 1386 1375 NVQUIRK_DIS_CARD_CLK_CONFIG_TAP | ··· 1396 1383 .read_w = tegra_sdhci_readw, 1397 1384 .write_l = tegra_sdhci_writel, 1398 1385 .set_clock = tegra_sdhci_set_clock, 1386 + .set_dma_mask = tegra_sdhci_set_dma_mask, 1399 1387 .set_bus_width = sdhci_set_bus_width, 1400 1388 .reset = tegra_sdhci_reset, 1401 1389 .set_uhs_signaling = tegra_sdhci_set_uhs_signaling, ··· 1412 1398 SDHCI_QUIRK_NO_HISPD_BIT | 1413 1399 SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC | 1414 1400 SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, 1415 - .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | 1416 - /* SDHCI controllers on Tegra186 support 40-bit addressing. 1417 - * IOVA addresses are 48-bit wide on Tegra186. 1418 - * With 64-bit dma mask used for SDHCI, accesses can 1419 - * be broken. Disable 64-bit dma, which would fall back 1420 - * to 32-bit dma mask. Ideally 40-bit dma mask would work, 1421 - * But it is not supported as of now. 1422 - */ 1423 - SDHCI_QUIRK2_BROKEN_64_BIT_DMA, 1401 + .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, 1424 1402 .ops = &tegra186_sdhci_ops, 1425 1403 }; 1426 1404 1427 1405 static const struct sdhci_tegra_soc_data soc_data_tegra186 = { 1428 1406 .pdata = &sdhci_tegra186_pdata, 1407 + .dma_mask = DMA_BIT_MASK(40), 1429 1408 .nvquirks = NVQUIRK_NEEDS_PAD_CONTROL | 1430 1409 NVQUIRK_HAS_PADCALIB | 1431 1410 NVQUIRK_DIS_CARD_CLK_CONFIG_TAP | ··· 1431 1424 1432 1425 static const struct sdhci_tegra_soc_data soc_data_tegra194 = { 1433 1426 .pdata = &sdhci_tegra186_pdata, 1427 + .dma_mask = DMA_BIT_MASK(39), 1434 1428 .nvquirks = NVQUIRK_NEEDS_PAD_CONTROL | 1435 1429 NVQUIRK_HAS_PADCALIB | 1436 1430 NVQUIRK_DIS_CARD_CLK_CONFIG_TAP |
+14 -13
drivers/mmc/host/sdhci.c
··· 2874 2874 static void sdhci_adma_show_error(struct sdhci_host *host) 2875 2875 { 2876 2876 void *desc = host->adma_table; 2877 + dma_addr_t dma = host->adma_addr; 2877 2878 2878 2879 sdhci_dumpregs(host); 2879 2880 ··· 2882 2881 struct sdhci_adma2_64_desc *dma_desc = desc; 2883 2882 2884 2883 if (host->flags & SDHCI_USE_64_BIT_DMA) 2885 - DBG("%p: DMA 0x%08x%08x, LEN 0x%04x, Attr=0x%02x\n", 2886 - desc, le32_to_cpu(dma_desc->addr_hi), 2884 + SDHCI_DUMP("%08llx: DMA 0x%08x%08x, LEN 0x%04x, Attr=0x%02x\n", 2885 + (unsigned long long)dma, 2886 + le32_to_cpu(dma_desc->addr_hi), 2887 2887 le32_to_cpu(dma_desc->addr_lo), 2888 2888 le16_to_cpu(dma_desc->len), 2889 2889 le16_to_cpu(dma_desc->cmd)); 2890 2890 else 2891 - DBG("%p: DMA 0x%08x, LEN 0x%04x, Attr=0x%02x\n", 2892 - desc, le32_to_cpu(dma_desc->addr_lo), 2891 + SDHCI_DUMP("%08llx: DMA 0x%08x, LEN 0x%04x, Attr=0x%02x\n", 2892 + (unsigned long long)dma, 2893 + le32_to_cpu(dma_desc->addr_lo), 2893 2894 le16_to_cpu(dma_desc->len), 2894 2895 le16_to_cpu(dma_desc->cmd)); 2895 2896 2896 2897 desc += host->desc_sz; 2898 + dma += host->desc_sz; 2897 2899 2898 2900 if (dma_desc->cmd & cpu_to_le16(ADMA2_END)) 2899 2901 break; ··· 2972 2968 != MMC_BUS_TEST_R) 2973 2969 host->data->error = -EILSEQ; 2974 2970 else if (intmask & SDHCI_INT_ADMA_ERROR) { 2975 - pr_err("%s: ADMA error\n", mmc_hostname(host->mmc)); 2971 + pr_err("%s: ADMA error: 0x%08x\n", mmc_hostname(host->mmc), 2972 + intmask); 2976 2973 sdhci_adma_show_error(host); 2977 2974 host->data->error = -EIO; 2978 2975 if (host->ops->adma_workaround) ··· 3781 3776 host->flags &= ~SDHCI_USE_ADMA; 3782 3777 } 3783 3778 3784 - /* 3785 - * It is assumed that a 64-bit capable device has set a 64-bit DMA mask 3786 - * and *must* do 64-bit DMA. A driver has the opportunity to change 3787 - * that during the first call to ->enable_dma(). Similarly 3788 - * SDHCI_QUIRK2_BROKEN_64_BIT_DMA must be left to the drivers to 3789 - * implement. 3790 - */ 3791 3779 if (sdhci_can_64bit_dma(host)) 3792 3780 host->flags |= SDHCI_USE_64_BIT_DMA; 3793 3781 3794 3782 if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) { 3795 - ret = sdhci_set_dma_mask(host); 3783 + if (host->ops->set_dma_mask) 3784 + ret = host->ops->set_dma_mask(host); 3785 + else 3786 + ret = sdhci_set_dma_mask(host); 3796 3787 3797 3788 if (!ret && host->ops->enable_dma) 3798 3789 ret = host->ops->enable_dma(host);
+1
drivers/mmc/host/sdhci.h
··· 622 622 623 623 u32 (*irq)(struct sdhci_host *host, u32 intmask); 624 624 625 + int (*set_dma_mask)(struct sdhci_host *host); 625 626 int (*enable_dma)(struct sdhci_host *host); 626 627 unsigned int (*get_max_clock)(struct sdhci_host *host); 627 628 unsigned int (*get_min_clock)(struct sdhci_host *host);