Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'mmc-v3.17-1' of git://git.linaro.org/people/ulf.hansson/mmc

Pull MMC updates from Ulf Hansson:
"Me and Chris Ball decided to try out using my MMC tree as the primary
one, to simplify handling of patches.

This pull does thus contains all the MMC patches for 3.17 rc1, no pull
from Chris this time.

Details:

MMC core:
- forward compatibility for eMMC
- fix some blacklisted cards with broken secure discard

MMC host:
- mmci: Add support for Qualcomm variant
- mmci: Fix regression for arm_variant
- sdhci: Various fixes and cleanups
- sdhci: Improve external VDD regulator support
- sdhci: Support for DDR50 1.8V mode for BayTrail
- sdhci-st: Add driver for ST SDHCI controller
- sh-mmcif: DMA fixes
- omap_hsmmc: Add support for SDIO interrupts
- sdhci-pci: Add support for Intel Quark X1000
- dw_mmc: Update the reset sequence
- s3cmci: port DMA code to dmaengine API"

* tag 'mmc-v3.17-1' of git://git.linaro.org/people/ulf.hansson/mmc: (67 commits)
mmc: dw_mmc: modify the dt-binding for removing slot-node and supports-highspeed
mmc: dw_mmc: Slot quirk "disable-wp" is deprecated.
mmc: mmci: Reverse IRQ handling for the arm_variant
mmc: mmci: Move all CMD irq handling to mmci_cmd_irq()
mmc: mmci: Remove redundant check of status for DATA irq
mmc: dw_mmc: change to use recommended reset procedure
mmc: sdhci-pxav3: Use devm_* managed helpers
mmc: tmio: Configure DMA slave bus width
mmc: sh_mmcif: Configure DMA slave bus width
mmc: sh_mmcif: Fix DMA slave address configuration
mmc: sh_mmcif: Document DT bindings
mmc: sdhci-pci: remove PCI PM functions in suspend/resume callback
mmc: Do not advertise secure discard if it is blacklisted
mmc: sdhci-msm: Get COMPILE_TEST support
mmc: sdhci-msm: Remove unnecessary header file inclusion
mmc: sdhci-msm: Fix the binding example
mmc: sdhci: add DDR50 1.8V mode support for BayTrail eMMC Controller
mmc: sdhci: Preset value not supported in Baytrail eMMC
mmc: MMC_USDHI6ROL0 should depend on HAS_DMA
mmc: MMC_SH_MMCIF should depend on HAS_DMA
...

+1050 -471
+5 -12
Documentation/devicetree/bindings/mmc/exynos-dw-mshc.txt
··· 46 46 - if CIU clock divider value is 0 (that is divide by 1), both tx and rx 47 47 phase shift clocks should be 0. 48 48 49 - Required properties for a slot: 49 + Required properties for a slot (Deprecated - Recommend to use one slot per host): 50 50 51 51 * gpios: specifies a list of gpios used for command, clock and data bus. The 52 52 first gpio is the command line and the second gpio is the clock line. The 53 53 rest of the gpios (depending on the bus-width property) are the data lines in 54 54 no particular order. The format of the gpio specifier depends on the gpio 55 55 controller. 56 + (Deprecated - Refer to Documentation/devicetree/binding/pinctrl/samsung-pinctrl.txt) 56 57 57 58 Example: 58 59 ··· 70 69 71 70 dwmmc0@12200000 { 72 71 num-slots = <1>; 73 - supports-highspeed; 72 + cap-mmc-highspeed; 73 + cap-sd-highspeed; 74 74 broken-cd; 75 75 fifo-depth = <0x80>; 76 76 card-detect-delay = <200>; 77 77 samsung,dw-mshc-ciu-div = <3>; 78 78 samsung,dw-mshc-sdr-timing = <2 3>; 79 79 samsung,dw-mshc-ddr-timing = <1 2>; 80 - 81 - slot@0 { 82 - reg = <0>; 83 - bus-width = <8>; 84 - gpios = <&gpc0 0 2 0 3>, <&gpc0 1 2 0 3>, 85 - <&gpc1 0 2 3 3>, <&gpc1 1 2 3 3>, 86 - <&gpc1 2 2 3 3>, <&gpc1 3 2 3 3>, 87 - <&gpc0 3 2 3 3>, <&gpc0 4 2 3 3>, 88 - <&gpc0 5 2 3 3>, <&gpc0 6 2 3 3>; 89 - }; 80 + bus-width = <8>; 90 81 };
+5 -7
Documentation/devicetree/bindings/mmc/k3-dw-mshc.txt
··· 34 34 num-slots = <1>; 35 35 vmmc-supply = <&ldo12>; 36 36 fifo-depth = <0x100>; 37 - supports-highspeed; 38 37 pinctrl-names = "default"; 39 38 pinctrl-0 = <&sd_pmx_pins &sd_cfg_func1 &sd_cfg_func2>; 40 - slot@0 { 41 - reg = <0>; 42 - bus-width = <4>; 43 - disable-wp; 44 - cd-gpios = <&gpio10 3 0>; 45 - }; 39 + bus-width = <4>; 40 + disable-wp; 41 + cd-gpios = <&gpio10 3 0>; 42 + cap-mmc-highspeed; 43 + cap-sd-highspeed; 46 44 };
+2 -2
Documentation/devicetree/bindings/mmc/mmc.txt
··· 34 34 - cap-power-off-card: powering off the card is safe 35 35 - cap-sdio-irq: enable SDIO IRQ signalling on this interface 36 36 - full-pwr-cycle: full power cycle of the card is supported 37 - - mmc-highspeed-ddr-1_8v: eMMC high-speed DDR mode(1.8V I/O) is supported 38 - - mmc-highspeed-ddr-1_2v: eMMC high-speed DDR mode(1.2V I/O) is supported 37 + - mmc-ddr-1_8v: eMMC high-speed DDR mode(1.8V I/O) is supported 38 + - mmc-ddr-1_2v: eMMC high-speed DDR mode(1.2V I/O) is supported 39 39 - mmc-hs200-1_8v: eMMC HS200 mode(1.8V I/O) is supported 40 40 - mmc-hs200-1_2v: eMMC HS200 mode(1.2V I/O) is supported 41 41 - mmc-hs400-1_8v: eMMC HS400 mode(1.8V I/O) is supported
+32
Documentation/devicetree/bindings/mmc/renesas,mmcif.txt
··· 1 + * Renesas Multi Media Card Interface (MMCIF) Controller 2 + 3 + This file documents differences between the core properties in mmc.txt 4 + and the properties used by the MMCIF device. 5 + 6 + 7 + Required properties: 8 + 9 + - compatible: must contain one of the following 10 + - "renesas,mmcif-r8a7740" for the MMCIF found in r8a7740 SoCs 11 + - "renesas,mmcif-r8a7790" for the MMCIF found in r8a7790 SoCs 12 + - "renesas,mmcif-r8a7791" for the MMCIF found in r8a7791 SoCs 13 + - "renesas,sh-mmcif" for the generic MMCIF 14 + 15 + - clocks: reference to the functional clock 16 + 17 + - dmas: reference to the DMA channels, one per channel name listed in the 18 + dma-names property. 19 + - dma-names: must contain "tx" for the transmit DMA channel and "rx" for the 20 + receive DMA channel. 21 + 22 + 23 + Example: R8A7790 (R-Car H2) MMCIF0 24 + 25 + mmcif0: mmc@ee200000 { 26 + compatible = "renesas,mmcif-r8a7790", "renesas,sh-mmcif"; 27 + reg = <0 0xee200000 0 0x80>; 28 + interrupts = <0 169 IRQ_TYPE_LEVEL_HIGH>; 29 + clocks = <&mstp3_clks R8A7790_CLK_MMCIF0>; 30 + dmas = <&dmac0 0xd1>, <&dmac0 0xd2>; 31 + dma-names = "tx", "rx"; 32 + };
+4 -4
Documentation/devicetree/bindings/mmc/sdhci-msm.txt
··· 27 27 bus-width = <8>; 28 28 non-removable; 29 29 30 - vmmc = <&pm8941_l20>; 31 - vqmmc = <&pm8941_s3>; 30 + vmmc-supply = <&pm8941_l20>; 31 + vqmmc-supply = <&pm8941_s3>; 32 32 33 33 pinctrl-names = "default"; 34 34 pinctrl-0 = <&sdc1_clk &sdc1_cmd &sdc1_data>; ··· 44 44 bus-width = <4>; 45 45 cd-gpios = <&msmgpio 62 0x1>; 46 46 47 - vmmc = <&pm8941_l21>; 48 - vqmmc = <&pm8941_l13>; 47 + vmmc-supply = <&pm8941_l21>; 48 + vqmmc-supply = <&pm8941_l13>; 49 49 50 50 pinctrl-names = "default"; 51 51 pinctrl-0 = <&sdc2_clk &sdc2_cmd &sdc2_data>;
+33
Documentation/devicetree/bindings/mmc/sdhci-st.txt
··· 1 + * STMicroelectronics sdhci-st MMC/SD controller 2 + 3 + This file documents the differences between the core properties in 4 + Documentation/devicetree/bindings/mmc/mmc.txt and the properties 5 + used by the sdhci-st driver. 6 + 7 + Required properties: 8 + - compatible : Must be "st,sdhci" 9 + - clock-names : Should be "mmc" 10 + See: Documentation/devicetree/bindings/resource-names.txt 11 + - clocks : Phandle of the clock used by the sdhci controler 12 + See: Documentation/devicetree/bindings/clock/clock-bindings.txt 13 + 14 + Optional properties: 15 + - non-removable: non-removable slot 16 + See: Documentation/devicetree/bindings/mmc/mmc.txt 17 + - bus-width: Number of data lines 18 + See: Documentation/devicetree/bindings/mmc/mmc.txt 19 + 20 + Example: 21 + 22 + mmc0: sdhci@fe81e000 { 23 + compatible = "st,sdhci"; 24 + status = "disabled"; 25 + reg = <0xfe81e000 0x1000>; 26 + interrupts = <GIC_SPI 127 IRQ_TYPE_NONE>; 27 + interrupt-names = "mmcirq"; 28 + pinctrl-names = "default"; 29 + pinctrl-0 = <&pinctrl_mmc0>; 30 + clock-names = "mmc"; 31 + clocks = <&clk_s_a1_ls 1>; 32 + bus-width = <8> 33 + };
+5 -7
Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt
··· 67 67 * card-detect-delay: Delay in milli-seconds before detecting card after card 68 68 insert event. The default value is 0. 69 69 70 - * supports-highspeed: Enables support for high speed cards (up to 50MHz) 70 + * supports-highspeed (DEPRECATED): Enables support for high speed cards (up to 50MHz) 71 + (use "cap-mmc-highspeed" or "cap-sd-highspeed" instead) 71 72 72 73 * broken-cd: as documented in mmc core bindings. 73 74 ··· 99 98 clock-frequency = <400000000>; 100 99 clock-freq-min-max = <400000 200000000>; 101 100 num-slots = <1>; 102 - supports-highspeed; 103 101 broken-cd; 104 102 fifo-depth = <0x80>; 105 103 card-detect-delay = <200>; 106 104 vmmc-supply = <&buck8>; 107 - 108 - slot@0 { 109 - reg = <0>; 110 - bus-width = <8>; 111 - }; 105 + bus-width = <8>; 106 + cap-mmc-highspeed; 107 + cap-sd-highspeed; 112 108 };
+54
Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
··· 12 12 Should be "ti,omap3-hsmmc", for OMAP3 controllers 13 13 Should be "ti,omap3-pre-es3-hsmmc" for OMAP3 controllers pre ES3.0 14 14 Should be "ti,omap4-hsmmc", for OMAP4 controllers 15 + Should be "ti,am33xx-hsmmc", for AM335x controllers 15 16 - ti,hwmods: Must be "mmc<n>", n is controller instance starting 1 16 17 17 18 Optional properties: ··· 56 55 dmas = <&edma 24 57 56 &edma 25>; 58 57 dma-names = "tx", "rx"; 58 + }; 59 + 60 + [workaround for missing swakeup on am33xx] 61 + 62 + This SOC is missing the swakeup line, it will not detect SDIO irq 63 + while in suspend. 64 + 65 + ------ 66 + | PRCM | 67 + ------ 68 + ^ | 69 + swakeup | | fclk 70 + | v 71 + ------ ------- ----- 72 + | card | -- CIRQ --> | hsmmc | -- IRQ --> | CPU | 73 + ------ ------- ----- 74 + 75 + In suspend the fclk is off and the module is disfunctional. Even register reads 76 + will fail. A small logic in the host will request fclk restore, when an 77 + external event is detected. Once the clock is restored, the host detects the 78 + event normally. Since am33xx doesn't have this line it never wakes from 79 + suspend. 80 + 81 + The workaround is to reconfigure the dat1 line as a GPIO upon suspend. To make 82 + this work, we need to set the named pinctrl states "default" and "idle". 83 + Prepare idle to remux dat1 as a gpio, and default to remux it back as sdio 84 + dat1. The MMC driver will then toggle between idle and default state during 85 + runtime. 86 + 87 + In summary: 88 + 1. select matching 'compatible' section, see example below. 89 + 2. specify pinctrl states "default" and "idle", "sleep" is optional. 90 + 3. specify the gpio irq used for detecting sdio irq in suspend 91 + 92 + If configuration is incomplete, a warning message is emitted "falling back to 93 + polling". Also check the "sdio irq mode" in /sys/kernel/debug/mmc0/regs. Mind 94 + not every application needs SDIO irq, e.g. MMC cards. 95 + 96 + mmc1: mmc@48060100 { 97 + compatible = "ti,am33xx-hsmmc"; 98 + ... 99 + pinctrl-names = "default", "idle", "sleep" 100 + pinctrl-0 = <&mmc1_pins>; 101 + pinctrl-1 = <&mmc1_idle>; 102 + pinctrl-2 = <&mmc1_sleep>; 103 + ... 104 + interrupts-extended = <&intc 64 &gpio2 28 0>; 105 + }; 106 + 107 + mmc1_idle : pinmux_cirq_pin { 108 + pinctrl-single,pins = < 109 + 0x0f8 0x3f /* GPIO2_28 */ 110 + >; 59 111 };
+1
Documentation/devicetree/bindings/mmc/tmio_mmc.txt
··· 18 18 "renesas,sdhi-r8a7778" - SDHI IP on R8A7778 SoC 19 19 "renesas,sdhi-r8a7779" - SDHI IP on R8A7779 SoC 20 20 "renesas,sdhi-r8a7790" - SDHI IP on R8A7790 SoC 21 + "renesas,sdhi-r8a7791" - SDHI IP on R8A7791 SoC 21 22 22 23 Optional properties: 23 24 - toshiba,mmc-wrprotect-disable: write-protect detection is unavailable
+3 -3
drivers/mmc/card/block.c
··· 2028 2028 /* complete ongoing async transfer before issuing discard */ 2029 2029 if (card->host->areq) 2030 2030 mmc_blk_issue_rw_rq(mq, NULL); 2031 - if (req->cmd_flags & REQ_SECURE && 2032 - !(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN)) 2031 + if (req->cmd_flags & REQ_SECURE) 2033 2032 ret = mmc_blk_issue_secdiscard_rq(mq, req); 2034 2033 else 2035 2034 ret = mmc_blk_issue_discard_rq(mq, req); ··· 2431 2432 if (!(card->csd.cmdclass & CCC_BLOCK_READ)) 2432 2433 return -ENODEV; 2433 2434 2435 + mmc_fixup_device(card, blk_fixups); 2436 + 2434 2437 md = mmc_blk_alloc(card); 2435 2438 if (IS_ERR(md)) 2436 2439 return PTR_ERR(md); ··· 2447 2446 goto out; 2448 2447 2449 2448 mmc_set_drvdata(card, md); 2450 - mmc_fixup_device(card, blk_fixups); 2451 2449 2452 2450 if (mmc_add_disk(md)) 2453 2451 goto out;
+1 -9
drivers/mmc/core/bus.c
··· 180 180 #endif 181 181 182 182 #ifdef CONFIG_PM_RUNTIME 183 - 184 183 static int mmc_runtime_suspend(struct device *dev) 185 184 { 186 185 struct mmc_card *card = mmc_dev_to_card(dev); ··· 195 196 196 197 return host->bus_ops->runtime_resume(host); 197 198 } 198 - 199 - static int mmc_runtime_idle(struct device *dev) 200 - { 201 - return 0; 202 - } 203 - 204 199 #endif /* !CONFIG_PM_RUNTIME */ 205 200 206 201 static const struct dev_pm_ops mmc_bus_pm_ops = { 207 - SET_RUNTIME_PM_OPS(mmc_runtime_suspend, mmc_runtime_resume, 208 - mmc_runtime_idle) 202 + SET_RUNTIME_PM_OPS(mmc_runtime_suspend, mmc_runtime_resume, NULL) 209 203 SET_SYSTEM_SLEEP_PM_OPS(mmc_bus_suspend, mmc_bus_resume) 210 204 }; 211 205
+2 -1
drivers/mmc/core/core.c
··· 2102 2102 2103 2103 int mmc_can_secure_erase_trim(struct mmc_card *card) 2104 2104 { 2105 - if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN) 2105 + if ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN) && 2106 + !(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN)) 2106 2107 return 1; 2107 2108 return 0; 2108 2109 }
+5 -6
drivers/mmc/core/mmc.c
··· 324 324 } 325 325 } 326 326 327 + /* 328 + * The EXT_CSD format is meant to be forward compatible. As long 329 + * as CSD_STRUCTURE does not change, all values for EXT_CSD_REV 330 + * are authorized, see JEDEC JESD84-B50 section B.8. 331 + */ 327 332 card->ext_csd.rev = ext_csd[EXT_CSD_REV]; 328 - if (card->ext_csd.rev > 7) { 329 - pr_err("%s: unrecognised EXT_CSD revision %d\n", 330 - mmc_hostname(card->host), card->ext_csd.rev); 331 - err = -EINVAL; 332 - goto out; 333 - } 334 333 335 334 card->ext_csd.raw_sectors[0] = ext_csd[EXT_CSD_SEC_CNT + 0]; 336 335 card->ext_csd.raw_sectors[1] = ext_csd[EXT_CSD_SEC_CNT + 1];
+1 -1
drivers/mmc/core/quirks.c
··· 91 91 (f->cis_device == card->cis.device || 92 92 f->cis_device == (u16) SDIO_ANY_ID) && 93 93 rev >= f->rev_start && rev <= f->rev_end) { 94 - dev_dbg(&card->dev, "calling %pF\n", f->vendor_fixup); 94 + dev_dbg(&card->dev, "calling %pf\n", f->vendor_fixup); 95 95 f->vendor_fixup(card, f->data); 96 96 } 97 97 }
+3
drivers/mmc/core/sd_ops.c
··· 184 184 mmc_delay(10); 185 185 } 186 186 187 + if (!i) 188 + pr_err("%s: card never left busy state\n", mmc_hostname(host)); 189 + 187 190 if (rocr && !mmc_host_is_spi(host)) 188 191 *rocr = cmd.resp[0]; 189 192
+17 -11
drivers/mmc/host/Kconfig
··· 290 290 be found on some embedded hardware such as UC-7112-LX. 291 291 If you have a controller with this interface, say Y here. 292 292 293 + config MMC_SDHCI_ST 294 + tristate "SDHCI support on STMicroelectronics SoC" 295 + depends on ARCH_STI 296 + depends on MMC_SDHCI_PLTFM 297 + select MMC_SDHCI_IO_ACCESSORS 298 + help 299 + This selects the Secure Digital Host Controller Interface in 300 + STMicroelectronics SoCs. 301 + 302 + If you have a controller with this interface, say Y or M here. 303 + If unsure, say N. 304 + 293 305 config MMC_OMAP 294 306 tristate "TI OMAP Multimedia Card Interface support" 295 307 depends on ARCH_OMAP ··· 315 303 316 304 config MMC_OMAP_HS 317 305 tristate "TI OMAP High Speed Multimedia Card Interface support" 306 + depends on HAS_DMA 318 307 depends on ARCH_OMAP2PLUS || COMPILE_TEST 319 308 help 320 309 This selects the TI OMAP High Speed Multimedia card Interface. ··· 356 343 357 344 config MMC_SDHCI_MSM 358 345 tristate "Qualcomm SDHCI Controller Support" 359 - depends on ARCH_QCOM 346 + depends on ARCH_QCOM || (ARM && COMPILE_TEST) 360 347 depends on MMC_SDHCI_PLTFM 361 348 help 362 349 This selects the Secure Digital Host Controller Interface (SDHCI) ··· 453 440 config MMC_S3C 454 441 tristate "Samsung S3C SD/MMC Card Interface support" 455 442 depends on ARCH_S3C24XX 443 + depends on S3C24XX_DMAC 456 444 help 457 445 This selects a driver for the MCI interface found in 458 446 Samsung's S3C2410, S3C2412, S3C2440, S3C2442 CPUs. ··· 490 476 Currently, the DMA support in this driver seems to not be 491 477 working properly and needs to be debugged before this 492 478 option is useful. 493 - 494 - config MMC_S3C_PIODMA 495 - bool "Support for both PIO and DMA" 496 - help 497 - Compile both the PIO and DMA transfer routines into the 498 - driver and let the platform select at run-time which one 499 - is best. 500 - 501 - See notes for the DMA option. 502 479 503 480 endchoice 504 481 ··· 628 623 629 624 config MMC_SH_MMCIF 630 625 tristate "SuperH Internal MMCIF support" 631 - depends on MMC_BLOCK 626 + depends on MMC_BLOCK && HAS_DMA 632 627 depends on SUPERH || ARCH_SHMOBILE || COMPILE_TEST 633 628 help 634 629 This selects the MMC Host Interface controller (MMCIF). ··· 702 697 703 698 config MMC_USDHI6ROL0 704 699 tristate "Renesas USDHI6ROL0 SD/SDIO Host Controller support" 700 + depends on HAS_DMA 705 701 help 706 702 This selects support for the Renesas USDHI6ROL0 SD/SDIO 707 703 Host Controller
+1
drivers/mmc/host/Makefile
··· 68 68 obj-$(CONFIG_MMC_SDHCI_BCM_KONA) += sdhci-bcm-kona.o 69 69 obj-$(CONFIG_MMC_SDHCI_BCM2835) += sdhci-bcm2835.o 70 70 obj-$(CONFIG_MMC_SDHCI_MSM) += sdhci-msm.o 71 + obj-$(CONFIG_MMC_SDHCI_ST) += sdhci-st.o 71 72 72 73 ifeq ($(CONFIG_CB710_DEBUG),y) 73 74 CFLAGS-cb710-mmc += -DDEBUG
+73 -25
drivers/mmc/host/dw_mmc.c
··· 111 111 0xff, 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, 112 112 }; 113 113 114 - static inline bool dw_mci_fifo_reset(struct dw_mci *host); 115 - static inline bool dw_mci_ctrl_all_reset(struct dw_mci *host); 114 + static bool dw_mci_reset(struct dw_mci *host); 116 115 117 116 #if defined(CONFIG_DEBUG_FS) 118 117 static int dw_mci_req_show(struct seq_file *s, void *v) ··· 996 997 int gpio_ro = mmc_gpio_get_ro(mmc); 997 998 998 999 /* Use platform get_ro function, else try on board write protect */ 999 - if (slot->quirks & DW_MCI_SLOT_QUIRK_NO_WRITE_PROTECT) 1000 + if ((slot->quirks & DW_MCI_SLOT_QUIRK_NO_WRITE_PROTECT) || 1001 + (slot->host->quirks & DW_MCI_QUIRK_NO_WRITE_PROTECT)) 1000 1002 read_only = 0; 1001 1003 else if (!IS_ERR_VALUE(gpio_ro)) 1002 1004 read_only = gpio_ro; ··· 1235 1235 * After an error, there may be data lingering 1236 1236 * in the FIFO 1237 1237 */ 1238 - dw_mci_fifo_reset(host); 1238 + dw_mci_reset(host); 1239 1239 } else { 1240 1240 data->bytes_xfered = data->blocks * data->blksz; 1241 1241 data->error = 0; ··· 1352 1352 1353 1353 /* CMD error in data command */ 1354 1354 if (mrq->cmd->error && mrq->data) 1355 - dw_mci_fifo_reset(host); 1355 + dw_mci_reset(host); 1356 1356 1357 1357 host->cmd = NULL; 1358 1358 host->data = NULL; ··· 1963 1963 } 1964 1964 1965 1965 /* Power down slot */ 1966 - if (present == 0) { 1967 - /* Clear down the FIFO */ 1968 - dw_mci_fifo_reset(host); 1969 - #ifdef CONFIG_MMC_DW_IDMAC 1970 - dw_mci_idmac_reset(host); 1971 - #endif 1972 - 1973 - } 1966 + if (present == 0) 1967 + dw_mci_reset(host); 1974 1968 1975 1969 spin_unlock_bh(&host->lock); 1976 1970 ··· 2015 2021 2016 2022 /* get quirks */ 2017 2023 for (idx = 0; idx < ARRAY_SIZE(of_slot_quirks); idx++) 2018 - if (of_get_property(np, of_slot_quirks[idx].quirk, NULL)) 2024 + if (of_get_property(np, of_slot_quirks[idx].quirk, NULL)) { 2025 + dev_warn(dev, "Slot quirk %s is deprecated\n", 2026 + of_slot_quirks[idx].quirk); 2019 2027 quirks |= of_slot_quirks[idx].id; 2028 + } 2020 2029 2021 2030 return quirks; 2022 2031 } ··· 2205 2208 return false; 2206 2209 } 2207 2210 2208 - static inline bool dw_mci_fifo_reset(struct dw_mci *host) 2211 + static bool dw_mci_reset(struct dw_mci *host) 2209 2212 { 2213 + u32 flags = SDMMC_CTRL_RESET | SDMMC_CTRL_FIFO_RESET; 2214 + bool ret = false; 2215 + 2210 2216 /* 2211 2217 * Reseting generates a block interrupt, hence setting 2212 2218 * the scatter-gather pointer to NULL. ··· 2219 2219 host->sg = NULL; 2220 2220 } 2221 2221 2222 - return dw_mci_ctrl_reset(host, SDMMC_CTRL_FIFO_RESET); 2223 - } 2222 + if (host->use_dma) 2223 + flags |= SDMMC_CTRL_DMA_RESET; 2224 2224 2225 - static inline bool dw_mci_ctrl_all_reset(struct dw_mci *host) 2226 - { 2227 - return dw_mci_ctrl_reset(host, 2228 - SDMMC_CTRL_FIFO_RESET | 2229 - SDMMC_CTRL_RESET | 2230 - SDMMC_CTRL_DMA_RESET); 2225 + if (dw_mci_ctrl_reset(host, flags)) { 2226 + /* 2227 + * In all cases we clear the RAWINTS register to clear any 2228 + * interrupts. 2229 + */ 2230 + mci_writel(host, RINTSTS, 0xFFFFFFFF); 2231 + 2232 + /* if using dma we wait for dma_req to clear */ 2233 + if (host->use_dma) { 2234 + unsigned long timeout = jiffies + msecs_to_jiffies(500); 2235 + u32 status; 2236 + do { 2237 + status = mci_readl(host, STATUS); 2238 + if (!(status & SDMMC_STATUS_DMA_REQ)) 2239 + break; 2240 + cpu_relax(); 2241 + } while (time_before(jiffies, timeout)); 2242 + 2243 + if (status & SDMMC_STATUS_DMA_REQ) { 2244 + dev_err(host->dev, 2245 + "%s: Timeout waiting for dma_req to " 2246 + "clear during reset\n", __func__); 2247 + goto ciu_out; 2248 + } 2249 + 2250 + /* when using DMA next we reset the fifo again */ 2251 + if (!dw_mci_ctrl_reset(host, SDMMC_CTRL_FIFO_RESET)) 2252 + goto ciu_out; 2253 + } 2254 + } else { 2255 + /* if the controller reset bit did clear, then set clock regs */ 2256 + if (!(mci_readl(host, CTRL) & SDMMC_CTRL_RESET)) { 2257 + dev_err(host->dev, "%s: fifo/dma reset bits didn't " 2258 + "clear but ciu was reset, doing clock update\n", 2259 + __func__); 2260 + goto ciu_out; 2261 + } 2262 + } 2263 + 2264 + #if IS_ENABLED(CONFIG_MMC_DW_IDMAC) 2265 + /* It is also recommended that we reset and reprogram idmac */ 2266 + dw_mci_idmac_reset(host); 2267 + #endif 2268 + 2269 + ret = true; 2270 + 2271 + ciu_out: 2272 + /* After a CTRL reset we need to have CIU set clock registers */ 2273 + mci_send_cmd(host->cur_slot, SDMMC_CMD_UPD_CLK, 0); 2274 + 2275 + return ret; 2231 2276 } 2232 2277 2233 2278 #ifdef CONFIG_OF ··· 2283 2238 { 2284 2239 .quirk = "broken-cd", 2285 2240 .id = DW_MCI_QUIRK_BROKEN_CARD_DETECTION, 2241 + }, { 2242 + .quirk = "disable-wp", 2243 + .id = DW_MCI_QUIRK_NO_WRITE_PROTECT, 2286 2244 }, 2287 2245 }; 2288 2246 ··· 2473 2425 } 2474 2426 2475 2427 /* Reset all blocks */ 2476 - if (!dw_mci_ctrl_all_reset(host)) 2428 + if (!dw_mci_ctrl_reset(host, SDMMC_CTRL_ALL_RESET_FLAGS)) 2477 2429 return -ENODEV; 2478 2430 2479 2431 host->dma_ops = host->pdata->dma_ops; ··· 2660 2612 } 2661 2613 } 2662 2614 2663 - if (!dw_mci_ctrl_all_reset(host)) { 2615 + if (!dw_mci_ctrl_reset(host, SDMMC_CTRL_ALL_RESET_FLAGS)) { 2664 2616 ret = -ENODEV; 2665 2617 return ret; 2666 2618 }
+5
drivers/mmc/host/dw_mmc.h
··· 129 129 #define SDMMC_CMD_INDX(n) ((n) & 0x1F) 130 130 /* Status register defines */ 131 131 #define SDMMC_GET_FCNT(x) (((x)>>17) & 0x1FFF) 132 + #define SDMMC_STATUS_DMA_REQ BIT(31) 132 133 /* FIFOTH register defines */ 133 134 #define SDMMC_SET_FIFOTH(m, r, t) (((m) & 0x7) << 28 | \ 134 135 ((r) & 0xFFF) << 16 | \ ··· 150 149 #define SDMMC_GET_VERID(x) ((x) & 0xFFFF) 151 150 /* Card read threshold */ 152 151 #define SDMMC_SET_RD_THLD(v, x) (((v) & 0x1FFF) << 16 | (x)) 152 + 153 + /* All ctrl reset bits */ 154 + #define SDMMC_CTRL_ALL_RESET_FLAGS \ 155 + (SDMMC_CTRL_RESET | SDMMC_CTRL_FIFO_RESET | SDMMC_CTRL_DMA_RESET) 153 156 154 157 /* Register access macros */ 155 158 #define mci_readl(dev, reg) \
+140 -28
drivers/mmc/host/mmci.c
··· 52 52 * struct variant_data - MMCI variant-specific quirks 53 53 * @clkreg: default value for MCICLOCK register 54 54 * @clkreg_enable: enable value for MMCICLOCK register 55 + * @clkreg_8bit_bus_enable: enable value for 8 bit bus 56 + * @clkreg_neg_edge_enable: enable value for inverted data/cmd output 55 57 * @datalength_bits: number of bits in the MMCIDATALENGTH register 56 58 * @fifosize: number of bytes that can be written when MMCI_TXFIFOEMPTY 57 59 * is asserted (likewise for RX) 58 60 * @fifohalfsize: number of bytes that can be written when MCI_TXFIFOHALFEMPTY 59 61 * is asserted (likewise for RX) 62 + * @data_cmd_enable: enable value for data commands. 60 63 * @sdio: variant supports SDIO 61 64 * @st_clkdiv: true if using a ST-specific clock divider algorithm 65 + * @datactrl_mask_ddrmode: ddr mode mask in datactrl register. 62 66 * @blksz_datactrl16: true if Block size is at b16..b30 position in datactrl register 67 + * @blksz_datactrl4: true if Block size is at b4..b16 position in datactrl 68 + * register 63 69 * @pwrreg_powerup: power up value for MMCIPOWER register 70 + * @f_max: maximum clk frequency supported by the controller. 64 71 * @signal_direction: input/out direction of bus signals can be indicated 65 72 * @pwrreg_clkgate: MMCIPOWER register must be used to gate the clock 66 73 * @busy_detect: true if busy detection on dat0 is supported 67 74 * @pwrreg_nopower: bits in MMCIPOWER don't controls ext. power supply 75 + * @explicit_mclk_control: enable explicit mclk control in driver. 76 + * @qcom_fifo: enables qcom specific fifo pio read logic. 77 + * @reversed_irq_handling: handle data irq before cmd irq. 68 78 */ 69 79 struct variant_data { 70 80 unsigned int clkreg; 71 81 unsigned int clkreg_enable; 82 + unsigned int clkreg_8bit_bus_enable; 83 + unsigned int clkreg_neg_edge_enable; 72 84 unsigned int datalength_bits; 73 85 unsigned int fifosize; 74 86 unsigned int fifohalfsize; 87 + unsigned int data_cmd_enable; 88 + unsigned int datactrl_mask_ddrmode; 75 89 bool sdio; 76 90 bool st_clkdiv; 77 91 bool blksz_datactrl16; 92 + bool blksz_datactrl4; 78 93 u32 pwrreg_powerup; 94 + u32 f_max; 79 95 bool signal_direction; 80 96 bool pwrreg_clkgate; 81 97 bool busy_detect; 82 98 bool pwrreg_nopower; 99 + bool explicit_mclk_control; 100 + bool qcom_fifo; 101 + bool reversed_irq_handling; 83 102 }; 84 103 85 104 static struct variant_data variant_arm = { ··· 106 87 .fifohalfsize = 8 * 4, 107 88 .datalength_bits = 16, 108 89 .pwrreg_powerup = MCI_PWR_UP, 90 + .f_max = 100000000, 91 + .reversed_irq_handling = true, 109 92 }; 110 93 111 94 static struct variant_data variant_arm_extended_fifo = { ··· 115 94 .fifohalfsize = 64 * 4, 116 95 .datalength_bits = 16, 117 96 .pwrreg_powerup = MCI_PWR_UP, 97 + .f_max = 100000000, 118 98 }; 119 99 120 100 static struct variant_data variant_arm_extended_fifo_hwfc = { ··· 124 102 .clkreg_enable = MCI_ARM_HWFCEN, 125 103 .datalength_bits = 16, 126 104 .pwrreg_powerup = MCI_PWR_UP, 105 + .f_max = 100000000, 127 106 }; 128 107 129 108 static struct variant_data variant_u300 = { 130 109 .fifosize = 16 * 4, 131 110 .fifohalfsize = 8 * 4, 132 111 .clkreg_enable = MCI_ST_U300_HWFCEN, 112 + .clkreg_8bit_bus_enable = MCI_ST_8BIT_BUS, 133 113 .datalength_bits = 16, 134 114 .sdio = true, 135 115 .pwrreg_powerup = MCI_PWR_ON, 116 + .f_max = 100000000, 136 117 .signal_direction = true, 137 118 .pwrreg_clkgate = true, 138 119 .pwrreg_nopower = true, ··· 149 124 .sdio = true, 150 125 .st_clkdiv = true, 151 126 .pwrreg_powerup = MCI_PWR_ON, 127 + .f_max = 100000000, 152 128 .signal_direction = true, 153 129 .pwrreg_clkgate = true, 154 130 .pwrreg_nopower = true, ··· 160 134 .fifohalfsize = 8 * 4, 161 135 .clkreg = MCI_CLK_ENABLE, 162 136 .clkreg_enable = MCI_ST_UX500_HWFCEN, 137 + .clkreg_8bit_bus_enable = MCI_ST_8BIT_BUS, 138 + .clkreg_neg_edge_enable = MCI_ST_UX500_NEG_EDGE, 163 139 .datalength_bits = 24, 164 140 .sdio = true, 165 141 .st_clkdiv = true, 166 142 .pwrreg_powerup = MCI_PWR_ON, 143 + .f_max = 100000000, 167 144 .signal_direction = true, 168 145 .pwrreg_clkgate = true, 169 146 .busy_detect = true, ··· 178 149 .fifohalfsize = 8 * 4, 179 150 .clkreg = MCI_CLK_ENABLE, 180 151 .clkreg_enable = MCI_ST_UX500_HWFCEN, 152 + .clkreg_8bit_bus_enable = MCI_ST_8BIT_BUS, 153 + .clkreg_neg_edge_enable = MCI_ST_UX500_NEG_EDGE, 154 + .datactrl_mask_ddrmode = MCI_ST_DPSM_DDRMODE, 181 155 .datalength_bits = 24, 182 156 .sdio = true, 183 157 .st_clkdiv = true, 184 158 .blksz_datactrl16 = true, 185 159 .pwrreg_powerup = MCI_PWR_ON, 160 + .f_max = 100000000, 186 161 .signal_direction = true, 187 162 .pwrreg_clkgate = true, 188 163 .busy_detect = true, 189 164 .pwrreg_nopower = true, 165 + }; 166 + 167 + static struct variant_data variant_qcom = { 168 + .fifosize = 16 * 4, 169 + .fifohalfsize = 8 * 4, 170 + .clkreg = MCI_CLK_ENABLE, 171 + .clkreg_enable = MCI_QCOM_CLK_FLOWENA | 172 + MCI_QCOM_CLK_SELECT_IN_FBCLK, 173 + .clkreg_8bit_bus_enable = MCI_QCOM_CLK_WIDEBUS_8, 174 + .datactrl_mask_ddrmode = MCI_QCOM_CLK_SELECT_IN_DDR_MODE, 175 + .data_cmd_enable = MCI_QCOM_CSPM_DATCMD, 176 + .blksz_datactrl4 = true, 177 + .datalength_bits = 24, 178 + .pwrreg_powerup = MCI_PWR_UP, 179 + .f_max = 208000000, 180 + .explicit_mclk_control = true, 181 + .qcom_fifo = true, 190 182 }; 191 183 192 184 static int mmci_card_busy(struct mmc_host *mmc) ··· 310 260 host->cclk = 0; 311 261 312 262 if (desired) { 313 - if (desired >= host->mclk) { 263 + if (variant->explicit_mclk_control) { 264 + host->cclk = host->mclk; 265 + } else if (desired >= host->mclk) { 314 266 clk = MCI_CLK_BYPASS; 315 267 if (variant->st_clkdiv) 316 268 clk |= MCI_ST_UX500_NEG_EDGE; ··· 351 299 if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_4) 352 300 clk |= MCI_4BIT_BUS; 353 301 if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_8) 354 - clk |= MCI_ST_8BIT_BUS; 302 + clk |= variant->clkreg_8bit_bus_enable; 355 303 356 304 if (host->mmc->ios.timing == MMC_TIMING_UHS_DDR50 || 357 305 host->mmc->ios.timing == MMC_TIMING_MMC_DDR52) 358 - clk |= MCI_ST_UX500_NEG_EDGE; 306 + clk |= variant->clkreg_neg_edge_enable; 359 307 360 308 mmci_write_clkreg(host, clk); 361 309 } ··· 771 719 data->bytes_xfered = 0; 772 720 773 721 clks = (unsigned long long)data->timeout_ns * host->cclk; 774 - do_div(clks, 1000000000UL); 722 + do_div(clks, NSEC_PER_SEC); 775 723 776 724 timeout = data->timeout_clks + (unsigned int)clks; 777 725 ··· 784 732 785 733 if (variant->blksz_datactrl16) 786 734 datactrl = MCI_DPSM_ENABLE | (data->blksz << 16); 735 + else if (variant->blksz_datactrl4) 736 + datactrl = MCI_DPSM_ENABLE | (data->blksz << 4); 787 737 else 788 738 datactrl = MCI_DPSM_ENABLE | blksz_bits << 4; 789 739 ··· 821 767 822 768 if (host->mmc->ios.timing == MMC_TIMING_UHS_DDR50 || 823 769 host->mmc->ios.timing == MMC_TIMING_MMC_DDR52) 824 - datactrl |= MCI_ST_DPSM_DDRMODE; 770 + datactrl |= variant->datactrl_mask_ddrmode; 825 771 826 772 /* 827 773 * Attempt to use DMA operation mode, if this ··· 866 812 867 813 if (readl(base + MMCICOMMAND) & MCI_CPSM_ENABLE) { 868 814 writel(0, base + MMCICOMMAND); 869 - udelay(1); 815 + mmci_reg_delay(host); 870 816 } 871 817 872 818 c |= cmd->opcode | MCI_CPSM_ENABLE; ··· 878 824 if (/*interrupt*/0) 879 825 c |= MCI_CPSM_INTERRUPT; 880 826 827 + if (mmc_cmd_type(cmd) == MMC_CMD_ADTC) 828 + c |= host->variant->data_cmd_enable; 829 + 881 830 host->cmd = cmd; 882 831 883 832 writel(cmd->arg, base + MMCIARGUMENT); ··· 891 834 mmci_data_irq(struct mmci_host *host, struct mmc_data *data, 892 835 unsigned int status) 893 836 { 837 + /* Make sure we have data to handle */ 838 + if (!data) 839 + return; 840 + 894 841 /* First check for errors */ 895 842 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_STARTBITERR| 896 843 MCI_TXUNDERRUN|MCI_RXOVERRUN)) { ··· 963 902 unsigned int status) 964 903 { 965 904 void __iomem *base = host->base; 966 - bool sbc = (cmd == host->mrq->sbc); 967 - bool busy_resp = host->variant->busy_detect && 968 - (cmd->flags & MMC_RSP_BUSY); 905 + bool sbc, busy_resp; 906 + 907 + if (!cmd) 908 + return; 909 + 910 + sbc = (cmd == host->mrq->sbc); 911 + busy_resp = host->variant->busy_detect && (cmd->flags & MMC_RSP_BUSY); 912 + 913 + if (!((status|host->busy_status) & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT| 914 + MCI_CMDSENT|MCI_CMDRESPEND))) 915 + return; 969 916 970 917 /* Check if we need to wait for busy completion. */ 971 918 if (host->busy_status && (status & MCI_ST_CARDBUSY)) ··· 1026 957 } 1027 958 } 1028 959 960 + static int mmci_get_rx_fifocnt(struct mmci_host *host, u32 status, int remain) 961 + { 962 + return remain - (readl(host->base + MMCIFIFOCNT) << 2); 963 + } 964 + 965 + static int mmci_qcom_get_rx_fifocnt(struct mmci_host *host, u32 status, int r) 966 + { 967 + /* 968 + * on qcom SDCC4 only 8 words are used in each burst so only 8 addresses 969 + * from the fifo range should be used 970 + */ 971 + if (status & MCI_RXFIFOHALFFULL) 972 + return host->variant->fifohalfsize; 973 + else if (status & MCI_RXDATAAVLBL) 974 + return 4; 975 + 976 + return 0; 977 + } 978 + 1029 979 static int mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int remain) 1030 980 { 1031 981 void __iomem *base = host->base; 1032 982 char *ptr = buffer; 1033 - u32 status; 983 + u32 status = readl(host->base + MMCISTATUS); 1034 984 int host_remain = host->size; 1035 985 1036 986 do { 1037 - int count = host_remain - (readl(base + MMCIFIFOCNT) << 2); 987 + int count = host->get_rx_fifocnt(host, status, host_remain); 1038 988 1039 989 if (count > remain) 1040 990 count = remain; ··· 1220 1132 spin_lock(&host->lock); 1221 1133 1222 1134 do { 1223 - struct mmc_command *cmd; 1224 - struct mmc_data *data; 1225 - 1226 1135 status = readl(host->base + MMCISTATUS); 1227 1136 1228 1137 if (host->singleirq) { ··· 1239 1154 1240 1155 dev_dbg(mmc_dev(host->mmc), "irq0 (data+cmd) %08x\n", status); 1241 1156 1242 - cmd = host->cmd; 1243 - if ((status|host->busy_status) & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT| 1244 - MCI_CMDSENT|MCI_CMDRESPEND) && cmd) 1245 - mmci_cmd_irq(host, cmd, status); 1246 - 1247 - data = host->data; 1248 - if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_STARTBITERR| 1249 - MCI_TXUNDERRUN|MCI_RXOVERRUN|MCI_DATAEND| 1250 - MCI_DATABLOCKEND) && data) 1251 - mmci_data_irq(host, data, status); 1157 + if (host->variant->reversed_irq_handling) { 1158 + mmci_data_irq(host, host->data, status); 1159 + mmci_cmd_irq(host, host->cmd, status); 1160 + } else { 1161 + mmci_cmd_irq(host, host->cmd, status); 1162 + mmci_data_irq(host, host->data, status); 1163 + } 1252 1164 1253 1165 /* Don't poll for busy completion in irq context. */ 1254 1166 if (host->busy_status) ··· 1377 1295 */ 1378 1296 if (!ios->clock && variant->pwrreg_clkgate) 1379 1297 pwr &= ~MCI_PWR_ON; 1298 + 1299 + if (host->variant->explicit_mclk_control && 1300 + ios->clock != host->clock_cache) { 1301 + ret = clk_set_rate(host->clk, ios->clock); 1302 + if (ret < 0) 1303 + dev_err(mmc_dev(host->mmc), 1304 + "Error setting clock rate (%d)\n", ret); 1305 + else 1306 + host->mclk = clk_get_rate(host->clk); 1307 + } 1308 + host->clock_cache = ios->clock; 1380 1309 1381 1310 spin_lock_irqsave(&host->lock, flags); 1382 1311 ··· 1536 1443 if (ret) 1537 1444 goto host_free; 1538 1445 1446 + if (variant->qcom_fifo) 1447 + host->get_rx_fifocnt = mmci_qcom_get_rx_fifocnt; 1448 + else 1449 + host->get_rx_fifocnt = mmci_get_rx_fifocnt; 1450 + 1539 1451 host->plat = plat; 1540 1452 host->variant = variant; 1541 1453 host->mclk = clk_get_rate(host->clk); ··· 1549 1451 * so we try to adjust the clock down to this, 1550 1452 * (if possible). 1551 1453 */ 1552 - if (host->mclk > 100000000) { 1553 - ret = clk_set_rate(host->clk, 100000000); 1454 + if (host->mclk > variant->f_max) { 1455 + ret = clk_set_rate(host->clk, variant->f_max); 1554 1456 if (ret < 0) 1555 1457 goto clk_disable; 1556 1458 host->mclk = clk_get_rate(host->clk); ··· 1569 1471 * The ARM and ST versions of the block have slightly different 1570 1472 * clock divider equations which means that the minimum divider 1571 1473 * differs too. 1474 + * on Qualcomm like controllers get the nearest minimum clock to 100Khz 1572 1475 */ 1573 1476 if (variant->st_clkdiv) 1574 1477 mmc->f_min = DIV_ROUND_UP(host->mclk, 257); 1478 + else if (variant->explicit_mclk_control) 1479 + mmc->f_min = clk_round_rate(host->clk, 100000); 1575 1480 else 1576 1481 mmc->f_min = DIV_ROUND_UP(host->mclk, 512); 1577 1482 /* ··· 1584 1483 * the block, of course. 1585 1484 */ 1586 1485 if (mmc->f_max) 1587 - mmc->f_max = min(host->mclk, mmc->f_max); 1486 + mmc->f_max = variant->explicit_mclk_control ? 1487 + min(variant->f_max, mmc->f_max) : 1488 + min(host->mclk, mmc->f_max); 1588 1489 else 1589 - mmc->f_max = min(host->mclk, fmax); 1490 + mmc->f_max = variant->explicit_mclk_control ? 1491 + fmax : min(host->mclk, fmax); 1492 + 1493 + 1590 1494 dev_dbg(mmc_dev(mmc), "clocking block at %u Hz\n", mmc->f_max); 1591 1495 1592 1496 /* Get regulators and the supported OCR mask */ ··· 1857 1751 .id = 0x10480180, 1858 1752 .mask = 0xf0ffffff, 1859 1753 .data = &variant_ux500v2, 1754 + }, 1755 + /* Qualcomm variants */ 1756 + { 1757 + .id = 0x00051180, 1758 + .mask = 0x000fffff, 1759 + .data = &variant_qcom, 1860 1760 }, 1861 1761 { 0, 0 }, 1862 1762 };
+20
drivers/mmc/host/mmci.h
··· 41 41 /* Modified PL180 on Versatile Express platform */ 42 42 #define MCI_ARM_HWFCEN (1 << 12) 43 43 44 + /* Modified on Qualcomm Integrations */ 45 + #define MCI_QCOM_CLK_WIDEBUS_8 (BIT(10) | BIT(11)) 46 + #define MCI_QCOM_CLK_FLOWENA BIT(12) 47 + #define MCI_QCOM_CLK_INVERTOUT BIT(13) 48 + 49 + /* select in latch data and command in */ 50 + #define MCI_QCOM_CLK_SELECT_IN_FBCLK BIT(15) 51 + #define MCI_QCOM_CLK_SELECT_IN_DDR_MODE (BIT(14) | BIT(15)) 52 + 44 53 #define MMCIARGUMENT 0x008 45 54 #define MMCICOMMAND 0x00c 46 55 #define MCI_CPSM_RESPONSE (1 << 6) ··· 62 53 #define MCI_ST_ENCMD_COMPL (1 << 12) 63 54 #define MCI_ST_NIEN (1 << 13) 64 55 #define MCI_ST_CE_ATACMD (1 << 14) 56 + 57 + /* Modified on Qualcomm Integrations */ 58 + #define MCI_QCOM_CSPM_DATCMD BIT(12) 59 + #define MCI_QCOM_CSPM_MCIABORT BIT(13) 60 + #define MCI_QCOM_CSPM_CCSENABLE BIT(14) 61 + #define MCI_QCOM_CSPM_CCSDISABLE BIT(15) 62 + #define MCI_QCOM_CSPM_AUTO_CMD19 BIT(16) 63 + #define MCI_QCOM_CSPM_AUTO_CMD21 BIT(21) 65 64 66 65 #define MMCIRESPCMD 0x010 67 66 #define MMCIRESPONSE0 0x014 ··· 208 191 spinlock_t lock; 209 192 210 193 unsigned int mclk; 194 + /* cached value of requested clk in set_ios */ 195 + unsigned int clock_cache; 211 196 unsigned int cclk; 212 197 u32 pwr_reg; 213 198 u32 pwr_reg_add; ··· 229 210 /* pio stuff */ 230 211 struct sg_mapping_iter sg_miter; 231 212 unsigned int size; 213 + int (*get_rx_fifocnt)(struct mmci_host *h, u32 status, int remain); 232 214 233 215 #ifdef CONFIG_DMA_ENGINE 234 216 /* DMA stuff */
-1
drivers/mmc/host/moxart-mmc.c
··· 13 13 * warranty of any kind, whether express or implied. 14 14 */ 15 15 16 - #include <linux/version.h> 17 16 #include <linux/module.h> 18 17 #include <linux/init.h> 19 18 #include <linux/platform_device.h>
+2 -1
drivers/mmc/host/mxs-mmc.c
··· 86 86 if (ret >= 0) 87 87 return ret; 88 88 89 - present = !(readl(ssp->base + HW_SSP_STATUS(ssp)) & 89 + present = mmc->caps & MMC_CAP_NEEDS_POLL || 90 + !(readl(ssp->base + HW_SSP_STATUS(ssp)) & 90 91 BM_SSP_STATUS_CARD_DETECT); 91 92 92 93 if (mmc->caps2 & MMC_CAP2_CD_ACTIVE_HIGH)
+262 -21
drivers/mmc/host/omap_hsmmc.c
··· 29 29 #include <linux/timer.h> 30 30 #include <linux/clk.h> 31 31 #include <linux/of.h> 32 + #include <linux/of_irq.h> 32 33 #include <linux/of_gpio.h> 33 34 #include <linux/of_device.h> 34 35 #include <linux/omap-dmaengine.h> ··· 37 36 #include <linux/mmc/core.h> 38 37 #include <linux/mmc/mmc.h> 39 38 #include <linux/io.h> 39 + #include <linux/irq.h> 40 40 #include <linux/gpio.h> 41 41 #include <linux/regulator/consumer.h> 42 42 #include <linux/pinctrl/consumer.h> ··· 56 54 #define OMAP_HSMMC_RSP54 0x0118 57 55 #define OMAP_HSMMC_RSP76 0x011C 58 56 #define OMAP_HSMMC_DATA 0x0120 57 + #define OMAP_HSMMC_PSTATE 0x0124 59 58 #define OMAP_HSMMC_HCTL 0x0128 60 59 #define OMAP_HSMMC_SYSCTL 0x012C 61 60 #define OMAP_HSMMC_STAT 0x0130 ··· 94 91 #define BCE (1 << 1) 95 92 #define FOUR_BIT (1 << 1) 96 93 #define HSPE (1 << 2) 94 + #define IWE (1 << 24) 97 95 #define DDR (1 << 19) 96 + #define CLKEXTFREE (1 << 16) 97 + #define CTPL (1 << 11) 98 98 #define DW8 (1 << 5) 99 99 #define OD 0x1 100 100 #define STAT_CLEAR 0xFFFFFFFF ··· 107 101 #define SRD (1 << 26) 108 102 #define SOFTRESET (1 << 1) 109 103 104 + /* PSTATE */ 105 + #define DLEV_DAT(x) (1 << (20 + (x))) 106 + 110 107 /* Interrupt masks for IE and ISE register */ 111 108 #define CC_EN (1 << 0) 112 109 #define TC_EN (1 << 1) 113 110 #define BWR_EN (1 << 4) 114 111 #define BRR_EN (1 << 5) 112 + #define CIRQ_EN (1 << 8) 115 113 #define ERR_EN (1 << 15) 116 114 #define CTO_EN (1 << 16) 117 115 #define CCRC_EN (1 << 17) ··· 150 140 #define VDD_3V0 3000000 /* 300000 uV */ 151 141 #define VDD_165_195 (ffs(MMC_VDD_165_195) - 1) 152 142 153 - #define AUTO_CMD23 (1 << 1) /* Auto CMD23 support */ 154 143 /* 155 144 * One controller can have multiple slots, like on some omap boards using 156 145 * omap.c controller driver. Luckily this is not currently done on any known ··· 203 194 u32 sysctl; 204 195 u32 capa; 205 196 int irq; 197 + int wake_irq; 206 198 int use_dma, dma_ch; 207 199 struct dma_chan *tx_chan; 208 200 struct dma_chan *rx_chan; ··· 216 206 int req_in_progress; 217 207 unsigned long clk_rate; 218 208 unsigned int flags; 209 + #define AUTO_CMD23 (1 << 0) /* Auto CMD23 support */ 210 + #define HSMMC_SDIO_IRQ_ENABLED (1 << 1) /* SDIO irq enabled */ 211 + #define HSMMC_WAKE_IRQ_ENABLED (1 << 2) 219 212 struct omap_hsmmc_next next_data; 220 213 struct omap_mmc_platform_data *pdata; 221 214 }; ··· 523 510 static void omap_hsmmc_enable_irq(struct omap_hsmmc_host *host, 524 511 struct mmc_command *cmd) 525 512 { 526 - unsigned int irq_mask; 513 + u32 irq_mask = INT_EN_MASK; 514 + unsigned long flags; 527 515 528 516 if (host->use_dma) 529 - irq_mask = INT_EN_MASK & ~(BRR_EN | BWR_EN); 530 - else 531 - irq_mask = INT_EN_MASK; 517 + irq_mask &= ~(BRR_EN | BWR_EN); 532 518 533 519 /* Disable timeout for erases */ 534 520 if (cmd->opcode == MMC_ERASE) 535 521 irq_mask &= ~DTO_EN; 536 522 523 + spin_lock_irqsave(&host->irq_lock, flags); 537 524 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); 538 525 OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); 526 + 527 + /* latch pending CIRQ, but don't signal MMC core */ 528 + if (host->flags & HSMMC_SDIO_IRQ_ENABLED) 529 + irq_mask |= CIRQ_EN; 539 530 OMAP_HSMMC_WRITE(host->base, IE, irq_mask); 531 + spin_unlock_irqrestore(&host->irq_lock, flags); 540 532 } 541 533 542 534 static void omap_hsmmc_disable_irq(struct omap_hsmmc_host *host) 543 535 { 544 - OMAP_HSMMC_WRITE(host->base, ISE, 0); 545 - OMAP_HSMMC_WRITE(host->base, IE, 0); 536 + u32 irq_mask = 0; 537 + unsigned long flags; 538 + 539 + spin_lock_irqsave(&host->irq_lock, flags); 540 + /* no transfer running but need to keep cirq if enabled */ 541 + if (host->flags & HSMMC_SDIO_IRQ_ENABLED) 542 + irq_mask |= CIRQ_EN; 543 + OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); 544 + OMAP_HSMMC_WRITE(host->base, IE, irq_mask); 546 545 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); 546 + spin_unlock_irqrestore(&host->irq_lock, flags); 547 547 } 548 548 549 549 /* Calculate divisor for the given clock frequency */ ··· 693 667 capa = VS18; 694 668 } 695 669 670 + if (host->mmc->caps & MMC_CAP_SDIO_IRQ) 671 + hctl |= IWE; 672 + 696 673 OMAP_HSMMC_WRITE(host->base, HCTL, 697 674 OMAP_HSMMC_READ(host->base, HCTL) | hctl); 698 675 ··· 710 681 && time_before(jiffies, timeout)) 711 682 ; 712 683 713 - omap_hsmmc_disable_irq(host); 684 + OMAP_HSMMC_WRITE(host->base, ISE, 0); 685 + OMAP_HSMMC_WRITE(host->base, IE, 0); 686 + OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); 714 687 715 688 /* Do not initialize card-specific things if the power is off */ 716 689 if (host->power_mode == MMC_POWER_OFF) ··· 1149 1118 int status; 1150 1119 1151 1120 status = OMAP_HSMMC_READ(host->base, STAT); 1152 - while (status & INT_EN_MASK && host->req_in_progress) { 1153 - omap_hsmmc_do_irq(host, status); 1121 + while (status & (INT_EN_MASK | CIRQ_EN)) { 1122 + if (host->req_in_progress) 1123 + omap_hsmmc_do_irq(host, status); 1124 + 1125 + if (status & CIRQ_EN) 1126 + mmc_signal_sdio_irq(host->mmc); 1154 1127 1155 1128 /* Flush posted write */ 1156 1129 status = OMAP_HSMMC_READ(host->base, STAT); 1157 1130 } 1131 + 1132 + return IRQ_HANDLED; 1133 + } 1134 + 1135 + static irqreturn_t omap_hsmmc_wake_irq(int irq, void *dev_id) 1136 + { 1137 + struct omap_hsmmc_host *host = dev_id; 1138 + 1139 + /* cirq is level triggered, disable to avoid infinite loop */ 1140 + spin_lock(&host->irq_lock); 1141 + if (host->flags & HSMMC_WAKE_IRQ_ENABLED) { 1142 + disable_irq_nosync(host->wake_irq); 1143 + host->flags &= ~HSMMC_WAKE_IRQ_ENABLED; 1144 + } 1145 + spin_unlock(&host->irq_lock); 1146 + pm_request_resume(host->dev); /* no use counter */ 1158 1147 1159 1148 return IRQ_HANDLED; 1160 1149 } ··· 1690 1639 mmc_slot(host).init_card(card); 1691 1640 } 1692 1641 1642 + static void omap_hsmmc_enable_sdio_irq(struct mmc_host *mmc, int enable) 1643 + { 1644 + struct omap_hsmmc_host *host = mmc_priv(mmc); 1645 + u32 irq_mask, con; 1646 + unsigned long flags; 1647 + 1648 + spin_lock_irqsave(&host->irq_lock, flags); 1649 + 1650 + con = OMAP_HSMMC_READ(host->base, CON); 1651 + irq_mask = OMAP_HSMMC_READ(host->base, ISE); 1652 + if (enable) { 1653 + host->flags |= HSMMC_SDIO_IRQ_ENABLED; 1654 + irq_mask |= CIRQ_EN; 1655 + con |= CTPL | CLKEXTFREE; 1656 + } else { 1657 + host->flags &= ~HSMMC_SDIO_IRQ_ENABLED; 1658 + irq_mask &= ~CIRQ_EN; 1659 + con &= ~(CTPL | CLKEXTFREE); 1660 + } 1661 + OMAP_HSMMC_WRITE(host->base, CON, con); 1662 + OMAP_HSMMC_WRITE(host->base, IE, irq_mask); 1663 + 1664 + /* 1665 + * if enable, piggy back detection on current request 1666 + * but always disable immediately 1667 + */ 1668 + if (!host->req_in_progress || !enable) 1669 + OMAP_HSMMC_WRITE(host->base, ISE, irq_mask); 1670 + 1671 + /* flush posted write */ 1672 + OMAP_HSMMC_READ(host->base, IE); 1673 + 1674 + spin_unlock_irqrestore(&host->irq_lock, flags); 1675 + } 1676 + 1677 + static int omap_hsmmc_configure_wake_irq(struct omap_hsmmc_host *host) 1678 + { 1679 + struct mmc_host *mmc = host->mmc; 1680 + int ret; 1681 + 1682 + /* 1683 + * For omaps with wake-up path, wakeirq will be irq from pinctrl and 1684 + * for other omaps, wakeirq will be from GPIO (dat line remuxed to 1685 + * gpio). wakeirq is needed to detect sdio irq in runtime suspend state 1686 + * with functional clock disabled. 1687 + */ 1688 + if (!host->dev->of_node || !host->wake_irq) 1689 + return -ENODEV; 1690 + 1691 + /* Prevent auto-enabling of IRQ */ 1692 + irq_set_status_flags(host->wake_irq, IRQ_NOAUTOEN); 1693 + ret = devm_request_irq(host->dev, host->wake_irq, omap_hsmmc_wake_irq, 1694 + IRQF_TRIGGER_LOW | IRQF_ONESHOT, 1695 + mmc_hostname(mmc), host); 1696 + if (ret) { 1697 + dev_err(mmc_dev(host->mmc), "Unable to request wake IRQ\n"); 1698 + goto err; 1699 + } 1700 + 1701 + /* 1702 + * Some omaps don't have wake-up path from deeper idle states 1703 + * and need to remux SDIO DAT1 to GPIO for wake-up from idle. 1704 + */ 1705 + if (host->pdata->controller_flags & OMAP_HSMMC_SWAKEUP_MISSING) { 1706 + struct pinctrl *p = devm_pinctrl_get(host->dev); 1707 + if (!p) { 1708 + ret = -ENODEV; 1709 + goto err_free_irq; 1710 + } 1711 + if (IS_ERR(pinctrl_lookup_state(p, PINCTRL_STATE_DEFAULT))) { 1712 + dev_info(host->dev, "missing default pinctrl state\n"); 1713 + devm_pinctrl_put(p); 1714 + ret = -EINVAL; 1715 + goto err_free_irq; 1716 + } 1717 + 1718 + if (IS_ERR(pinctrl_lookup_state(p, PINCTRL_STATE_IDLE))) { 1719 + dev_info(host->dev, "missing idle pinctrl state\n"); 1720 + devm_pinctrl_put(p); 1721 + ret = -EINVAL; 1722 + goto err_free_irq; 1723 + } 1724 + devm_pinctrl_put(p); 1725 + } 1726 + 1727 + OMAP_HSMMC_WRITE(host->base, HCTL, 1728 + OMAP_HSMMC_READ(host->base, HCTL) | IWE); 1729 + return 0; 1730 + 1731 + err_free_irq: 1732 + devm_free_irq(host->dev, host->wake_irq, host); 1733 + err: 1734 + dev_warn(host->dev, "no SDIO IRQ support, falling back to polling\n"); 1735 + host->wake_irq = 0; 1736 + return ret; 1737 + } 1738 + 1693 1739 static void omap_hsmmc_conf_bus_power(struct omap_hsmmc_host *host) 1694 1740 { 1695 1741 u32 hctl, capa, value; ··· 1839 1691 .get_cd = omap_hsmmc_get_cd, 1840 1692 .get_ro = omap_hsmmc_get_ro, 1841 1693 .init_card = omap_hsmmc_init_card, 1842 - /* NYET -- enable_sdio_irq */ 1694 + .enable_sdio_irq = omap_hsmmc_enable_sdio_irq, 1843 1695 }; 1844 1696 1845 1697 #ifdef CONFIG_DEBUG_FS ··· 1849 1701 struct mmc_host *mmc = s->private; 1850 1702 struct omap_hsmmc_host *host = mmc_priv(mmc); 1851 1703 1852 - seq_printf(s, "mmc%d:\n ctx_loss:\t%d\n\nregs:\n", 1853 - mmc->index, host->context_loss); 1704 + seq_printf(s, "mmc%d:\n", mmc->index); 1705 + seq_printf(s, "sdio irq mode\t%s\n", 1706 + (mmc->caps & MMC_CAP_SDIO_IRQ) ? "interrupt" : "polling"); 1707 + 1708 + if (mmc->caps & MMC_CAP_SDIO_IRQ) { 1709 + seq_printf(s, "sdio irq \t%s\n", 1710 + (host->flags & HSMMC_SDIO_IRQ_ENABLED) ? "enabled" 1711 + : "disabled"); 1712 + } 1713 + seq_printf(s, "ctx_loss:\t%d\n", host->context_loss); 1854 1714 1855 1715 pm_runtime_get_sync(host->dev); 1856 - 1716 + seq_puts(s, "\nregs:\n"); 1857 1717 seq_printf(s, "CON:\t\t0x%08x\n", 1858 1718 OMAP_HSMMC_READ(host->base, CON)); 1719 + seq_printf(s, "PSTATE:\t\t0x%08x\n", 1720 + OMAP_HSMMC_READ(host->base, PSTATE)); 1859 1721 seq_printf(s, "HCTL:\t\t0x%08x\n", 1860 1722 OMAP_HSMMC_READ(host->base, HCTL)); 1861 1723 seq_printf(s, "SYSCTL:\t\t0x%08x\n", ··· 1919 1761 static const struct omap_mmc_of_data omap4_mmc_of_data = { 1920 1762 .reg_offset = 0x100, 1921 1763 }; 1764 + static const struct omap_mmc_of_data am33xx_mmc_of_data = { 1765 + .reg_offset = 0x100, 1766 + .controller_flags = OMAP_HSMMC_SWAKEUP_MISSING, 1767 + }; 1922 1768 1923 1769 static const struct of_device_id omap_mmc_of_match[] = { 1924 1770 { ··· 1938 1776 { 1939 1777 .compatible = "ti,omap4-hsmmc", 1940 1778 .data = &omap4_mmc_of_data, 1779 + }, 1780 + { 1781 + .compatible = "ti,am33xx-hsmmc", 1782 + .data = &am33xx_mmc_of_data, 1941 1783 }, 1942 1784 {}, 1943 1785 }; ··· 2016 1850 const struct of_device_id *match; 2017 1851 dma_cap_mask_t mask; 2018 1852 unsigned tx_req, rx_req; 2019 - struct pinctrl *pinctrl; 2020 1853 const struct omap_mmc_of_data *data; 2021 1854 void __iomem *base; 2022 1855 ··· 2077 1912 host->pbias_enabled = 0; 2078 1913 2079 1914 platform_set_drvdata(pdev, host); 1915 + 1916 + if (pdev->dev.of_node) 1917 + host->wake_irq = irq_of_parse_and_map(pdev->dev.of_node, 1); 2080 1918 2081 1919 mmc->ops = &omap_hsmmc_ops; 2082 1920 ··· 2229 2061 2230 2062 omap_hsmmc_disable_irq(host); 2231 2063 2232 - pinctrl = devm_pinctrl_get_select_default(&pdev->dev); 2233 - if (IS_ERR(pinctrl)) 2234 - dev_warn(&pdev->dev, 2235 - "pins are not configured from the driver\n"); 2064 + /* 2065 + * For now, only support SDIO interrupt if we have a separate 2066 + * wake-up interrupt configured from device tree. This is because 2067 + * the wake-up interrupt is needed for idle state and some 2068 + * platforms need special quirks. And we don't want to add new 2069 + * legacy mux platform init code callbacks any longer as we 2070 + * are moving to DT based booting anyways. 2071 + */ 2072 + ret = omap_hsmmc_configure_wake_irq(host); 2073 + if (!ret) 2074 + mmc->caps |= MMC_CAP_SDIO_IRQ; 2236 2075 2237 2076 omap_hsmmc_protect_card(host); 2238 2077 ··· 2345 2170 pm_runtime_get_sync(host->dev); 2346 2171 2347 2172 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) { 2348 - omap_hsmmc_disable_irq(host); 2173 + OMAP_HSMMC_WRITE(host->base, ISE, 0); 2174 + OMAP_HSMMC_WRITE(host->base, IE, 0); 2175 + OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); 2349 2176 OMAP_HSMMC_WRITE(host->base, HCTL, 2350 2177 OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP); 2351 2178 } 2179 + 2180 + /* do not wake up due to sdio irq */ 2181 + if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) && 2182 + !(host->mmc->pm_flags & MMC_PM_WAKE_SDIO_IRQ)) 2183 + disable_irq(host->wake_irq); 2352 2184 2353 2185 if (host->dbclk) 2354 2186 clk_disable_unprepare(host->dbclk); ··· 2382 2200 2383 2201 omap_hsmmc_protect_card(host); 2384 2202 2203 + if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) && 2204 + !(host->mmc->pm_flags & MMC_PM_WAKE_SDIO_IRQ)) 2205 + enable_irq(host->wake_irq); 2206 + 2385 2207 pm_runtime_mark_last_busy(host->dev); 2386 2208 pm_runtime_put_autosuspend(host->dev); 2387 2209 return 0; ··· 2401 2215 static int omap_hsmmc_runtime_suspend(struct device *dev) 2402 2216 { 2403 2217 struct omap_hsmmc_host *host; 2218 + unsigned long flags; 2219 + int ret = 0; 2404 2220 2405 2221 host = platform_get_drvdata(to_platform_device(dev)); 2406 2222 omap_hsmmc_context_save(host); 2407 2223 dev_dbg(dev, "disabled\n"); 2408 2224 2409 - return 0; 2225 + spin_lock_irqsave(&host->irq_lock, flags); 2226 + if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) && 2227 + (host->flags & HSMMC_SDIO_IRQ_ENABLED)) { 2228 + /* disable sdio irq handling to prevent race */ 2229 + OMAP_HSMMC_WRITE(host->base, ISE, 0); 2230 + OMAP_HSMMC_WRITE(host->base, IE, 0); 2231 + 2232 + if (!(OMAP_HSMMC_READ(host->base, PSTATE) & DLEV_DAT(1))) { 2233 + /* 2234 + * dat1 line low, pending sdio irq 2235 + * race condition: possible irq handler running on 2236 + * multi-core, abort 2237 + */ 2238 + dev_dbg(dev, "pending sdio irq, abort suspend\n"); 2239 + OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); 2240 + OMAP_HSMMC_WRITE(host->base, ISE, CIRQ_EN); 2241 + OMAP_HSMMC_WRITE(host->base, IE, CIRQ_EN); 2242 + pm_runtime_mark_last_busy(dev); 2243 + ret = -EBUSY; 2244 + goto abort; 2245 + } 2246 + 2247 + pinctrl_pm_select_idle_state(dev); 2248 + 2249 + WARN_ON(host->flags & HSMMC_WAKE_IRQ_ENABLED); 2250 + enable_irq(host->wake_irq); 2251 + host->flags |= HSMMC_WAKE_IRQ_ENABLED; 2252 + } else { 2253 + pinctrl_pm_select_idle_state(dev); 2254 + } 2255 + 2256 + abort: 2257 + spin_unlock_irqrestore(&host->irq_lock, flags); 2258 + return ret; 2410 2259 } 2411 2260 2412 2261 static int omap_hsmmc_runtime_resume(struct device *dev) 2413 2262 { 2414 2263 struct omap_hsmmc_host *host; 2264 + unsigned long flags; 2415 2265 2416 2266 host = platform_get_drvdata(to_platform_device(dev)); 2417 2267 omap_hsmmc_context_restore(host); 2418 2268 dev_dbg(dev, "enabled\n"); 2419 2269 2270 + spin_lock_irqsave(&host->irq_lock, flags); 2271 + if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) && 2272 + (host->flags & HSMMC_SDIO_IRQ_ENABLED)) { 2273 + /* sdio irq flag can't change while in runtime suspend */ 2274 + if (host->flags & HSMMC_WAKE_IRQ_ENABLED) { 2275 + disable_irq_nosync(host->wake_irq); 2276 + host->flags &= ~HSMMC_WAKE_IRQ_ENABLED; 2277 + } 2278 + 2279 + pinctrl_pm_select_default_state(host->dev); 2280 + 2281 + /* irq lost, if pinmux incorrect */ 2282 + OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR); 2283 + OMAP_HSMMC_WRITE(host->base, ISE, CIRQ_EN); 2284 + OMAP_HSMMC_WRITE(host->base, IE, CIRQ_EN); 2285 + } else { 2286 + pinctrl_pm_select_default_state(host->dev); 2287 + } 2288 + spin_unlock_irqrestore(&host->irq_lock, flags); 2420 2289 return 0; 2421 2290 } 2422 2291
+53 -133
drivers/mmc/host/s3cmci.c
··· 12 12 */ 13 13 14 14 #include <linux/module.h> 15 + #include <linux/dmaengine.h> 15 16 #include <linux/dma-mapping.h> 16 17 #include <linux/clk.h> 17 18 #include <linux/mmc/host.h> ··· 28 27 #include <mach/dma.h> 29 28 #include <mach/gpio-samsung.h> 30 29 30 + #include <linux/platform_data/dma-s3c24xx.h> 31 31 #include <linux/platform_data/mmc-s3cmci.h> 32 32 33 33 #include "s3cmci.h" ··· 142 140 dev_dbg(&host->pdev->dev, args); \ 143 141 } while (0) 144 142 145 - static struct s3c2410_dma_client s3cmci_dma_client = { 146 - .name = "s3c-mci", 147 - }; 148 - 149 143 static void finalize_request(struct s3cmci_host *host); 150 144 static void s3cmci_send_request(struct mmc_host *mmc); 151 145 static void s3cmci_reset(struct s3cmci_host *host); ··· 254 256 { 255 257 #ifdef CONFIG_MMC_S3C_PIO 256 258 return false; 257 - #elif defined(CONFIG_MMC_S3C_DMA) 259 + #else /* CONFIG_MMC_S3C_DMA */ 258 260 return true; 259 - #else 260 - return host->dodma; 261 - #endif 262 - } 263 - 264 - /** 265 - * s3cmci_host_canpio - return true if host has pio code available 266 - * 267 - * Return true if the driver has been compiled with the PIO support code 268 - * available. 269 - */ 270 - static inline bool s3cmci_host_canpio(void) 271 - { 272 - #ifdef CONFIG_MMC_S3C_PIO 273 - return true; 274 - #else 275 - return false; 276 261 #endif 277 262 } 278 263 ··· 822 841 return IRQ_HANDLED; 823 842 } 824 843 825 - static void s3cmci_dma_done_callback(struct s3c2410_dma_chan *dma_ch, 826 - void *buf_id, int size, 827 - enum s3c2410_dma_buffresult result) 844 + static void s3cmci_dma_done_callback(void *arg) 828 845 { 829 - struct s3cmci_host *host = buf_id; 846 + struct s3cmci_host *host = arg; 830 847 unsigned long iflags; 831 - u32 mci_csta, mci_dsta, mci_fsta, mci_dcnt; 832 - 833 - mci_csta = readl(host->base + S3C2410_SDICMDSTAT); 834 - mci_dsta = readl(host->base + S3C2410_SDIDSTA); 835 - mci_fsta = readl(host->base + S3C2410_SDIFSTA); 836 - mci_dcnt = readl(host->base + S3C2410_SDIDCNT); 837 848 838 849 BUG_ON(!host->mrq); 839 850 BUG_ON(!host->mrq->data); 840 - BUG_ON(!host->dmatogo); 841 851 842 852 spin_lock_irqsave(&host->complete_lock, iflags); 843 853 844 - if (result != S3C2410_RES_OK) { 845 - dbg(host, dbg_fail, "DMA FAILED: csta=0x%08x dsta=0x%08x " 846 - "fsta=0x%08x dcnt:0x%08x result:0x%08x toGo:%u\n", 847 - mci_csta, mci_dsta, mci_fsta, 848 - mci_dcnt, result, host->dmatogo); 849 - 850 - goto fail_request; 851 - } 852 - 853 - host->dmatogo--; 854 - if (host->dmatogo) { 855 - dbg(host, dbg_dma, "DMA DONE Size:%i DSTA:[%08x] " 856 - "DCNT:[%08x] toGo:%u\n", 857 - size, mci_dsta, mci_dcnt, host->dmatogo); 858 - 859 - goto out; 860 - } 861 - 862 - dbg(host, dbg_dma, "DMA FINISHED Size:%i DSTA:%08x DCNT:%08x\n", 863 - size, mci_dsta, mci_dcnt); 854 + dbg(host, dbg_dma, "DMA FINISHED\n"); 864 855 865 856 host->dma_complete = 1; 866 857 host->complete_what = COMPLETION_FINALIZE; 867 858 868 - out: 869 859 tasklet_schedule(&host->pio_tasklet); 870 860 spin_unlock_irqrestore(&host->complete_lock, iflags); 871 - return; 872 861 873 - fail_request: 874 - host->mrq->data->error = -EINVAL; 875 - host->complete_what = COMPLETION_FINALIZE; 876 - clear_imask(host); 877 - 878 - goto out; 879 862 } 880 863 881 864 static void finalize_request(struct s3cmci_host *host) ··· 911 966 * DMA channel and the fifo to clear out any garbage. */ 912 967 if (mrq->data->error != 0) { 913 968 if (s3cmci_host_usedma(host)) 914 - s3c2410_dma_ctrl(host->dma, S3C2410_DMAOP_FLUSH); 969 + dmaengine_terminate_all(host->dma); 915 970 916 971 if (host->is2440) { 917 972 /* Clear failure register and reset fifo. */ ··· 935 990 936 991 s3cmci_check_sdio_irq(host); 937 992 mmc_request_done(host->mmc, mrq); 938 - } 939 - 940 - static void s3cmci_dma_setup(struct s3cmci_host *host, 941 - enum dma_data_direction source) 942 - { 943 - static enum dma_data_direction last_source = -1; 944 - static int setup_ok; 945 - 946 - if (last_source == source) 947 - return; 948 - 949 - last_source = source; 950 - 951 - s3c2410_dma_devconfig(host->dma, source, 952 - host->mem->start + host->sdidata); 953 - 954 - if (!setup_ok) { 955 - s3c2410_dma_config(host->dma, 4); 956 - s3c2410_dma_set_buffdone_fn(host->dma, 957 - s3cmci_dma_done_callback); 958 - s3c2410_dma_setflags(host->dma, S3C2410_DMAF_AUTOSTART); 959 - setup_ok = 1; 960 - } 961 993 } 962 994 963 995 static void s3cmci_send_command(struct s3cmci_host *host, ··· 1084 1162 1085 1163 static int s3cmci_prepare_dma(struct s3cmci_host *host, struct mmc_data *data) 1086 1164 { 1087 - int dma_len, i; 1088 1165 int rw = data->flags & MMC_DATA_WRITE; 1166 + struct dma_async_tx_descriptor *desc; 1167 + struct dma_slave_config conf = { 1168 + .src_addr = host->mem->start + host->sdidata, 1169 + .dst_addr = host->mem->start + host->sdidata, 1170 + .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, 1171 + .dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, 1172 + }; 1089 1173 1090 1174 BUG_ON((data->flags & BOTH_DIR) == BOTH_DIR); 1091 1175 1092 - s3cmci_dma_setup(host, rw ? DMA_TO_DEVICE : DMA_FROM_DEVICE); 1093 - s3c2410_dma_ctrl(host->dma, S3C2410_DMAOP_FLUSH); 1176 + /* Restore prescaler value */ 1177 + writel(host->prescaler, host->base + S3C2410_SDIPRE); 1094 1178 1095 - dma_len = dma_map_sg(mmc_dev(host->mmc), data->sg, data->sg_len, 1179 + if (!rw) 1180 + conf.direction = DMA_DEV_TO_MEM; 1181 + else 1182 + conf.direction = DMA_MEM_TO_DEV; 1183 + 1184 + dma_map_sg(mmc_dev(host->mmc), data->sg, data->sg_len, 1096 1185 rw ? DMA_TO_DEVICE : DMA_FROM_DEVICE); 1097 1186 1098 - if (dma_len == 0) 1099 - return -ENOMEM; 1100 - 1101 - host->dma_complete = 0; 1102 - host->dmatogo = dma_len; 1103 - 1104 - for (i = 0; i < dma_len; i++) { 1105 - int res; 1106 - 1107 - dbg(host, dbg_dma, "enqueue %i: %08x@%u\n", i, 1108 - sg_dma_address(&data->sg[i]), 1109 - sg_dma_len(&data->sg[i])); 1110 - 1111 - res = s3c2410_dma_enqueue(host->dma, host, 1112 - sg_dma_address(&data->sg[i]), 1113 - sg_dma_len(&data->sg[i])); 1114 - 1115 - if (res) { 1116 - s3c2410_dma_ctrl(host->dma, S3C2410_DMAOP_FLUSH); 1117 - return -EBUSY; 1118 - } 1119 - } 1120 - 1121 - s3c2410_dma_ctrl(host->dma, S3C2410_DMAOP_START); 1187 + dmaengine_slave_config(host->dma, &conf); 1188 + desc = dmaengine_prep_slave_sg(host->dma, data->sg, data->sg_len, 1189 + conf.direction, 1190 + DMA_CTRL_ACK | DMA_PREP_INTERRUPT); 1191 + if (!desc) 1192 + goto unmap_exit; 1193 + desc->callback = s3cmci_dma_done_callback; 1194 + desc->callback_param = host; 1195 + dmaengine_submit(desc); 1196 + dma_async_issue_pending(host->dma); 1122 1197 1123 1198 return 0; 1199 + 1200 + unmap_exit: 1201 + dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, 1202 + rw ? DMA_TO_DEVICE : DMA_FROM_DEVICE); 1203 + return -ENOMEM; 1124 1204 } 1125 1205 1126 1206 static void s3cmci_send_request(struct mmc_host *mmc) ··· 1600 1676 host->complete_what = COMPLETION_NONE; 1601 1677 host->pio_active = XFER_NONE; 1602 1678 1603 - #ifdef CONFIG_MMC_S3C_PIODMA 1604 - host->dodma = host->pdata->use_dma; 1605 - #endif 1606 - 1607 1679 host->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1608 1680 if (!host->mem) { 1609 1681 dev_err(&pdev->dev, ··· 1685 1765 /* depending on the dma state, get a dma channel to use. */ 1686 1766 1687 1767 if (s3cmci_host_usedma(host)) { 1688 - host->dma = s3c2410_dma_request(DMACH_SDI, &s3cmci_dma_client, 1689 - host); 1690 - if (host->dma < 0) { 1768 + dma_cap_mask_t mask; 1769 + 1770 + dma_cap_zero(mask); 1771 + dma_cap_set(DMA_SLAVE, mask); 1772 + 1773 + host->dma = dma_request_slave_channel_compat(mask, 1774 + s3c24xx_dma_filter, (void *)DMACH_SDI, &pdev->dev, "rx-tx"); 1775 + if (!host->dma) { 1691 1776 dev_err(&pdev->dev, "cannot get DMA channel.\n"); 1692 - if (!s3cmci_host_canpio()) { 1693 - ret = -EBUSY; 1694 - goto probe_free_gpio_wp; 1695 - } else { 1696 - dev_warn(&pdev->dev, "falling back to PIO.\n"); 1697 - host->dodma = 0; 1698 - } 1777 + ret = -EBUSY; 1778 + goto probe_free_gpio_wp; 1699 1779 } 1700 1780 } 1701 1781 ··· 1707 1787 goto probe_free_dma; 1708 1788 } 1709 1789 1710 - ret = clk_enable(host->clk); 1790 + ret = clk_prepare_enable(host->clk); 1711 1791 if (ret) { 1712 1792 dev_err(&pdev->dev, "failed to enable clock source.\n"); 1713 1793 goto clk_free; ··· 1736 1816 mmc->max_segs = 128; 1737 1817 1738 1818 dbg(host, dbg_debug, 1739 - "probe: mode:%s mapped mci_base:%p irq:%u irq_cd:%u dma:%u.\n", 1819 + "probe: mode:%s mapped mci_base:%p irq:%u irq_cd:%u dma:%p.\n", 1740 1820 (host->is2440?"2440":""), 1741 1821 host->base, host->irq, host->irq_cd, host->dma); 1742 1822 ··· 1765 1845 s3cmci_cpufreq_deregister(host); 1766 1846 1767 1847 free_dmabuf: 1768 - clk_disable(host->clk); 1848 + clk_disable_unprepare(host->clk); 1769 1849 1770 1850 clk_free: 1771 1851 clk_put(host->clk); 1772 1852 1773 1853 probe_free_dma: 1774 1854 if (s3cmci_host_usedma(host)) 1775 - s3c2410_dma_free(host->dma, &s3cmci_dma_client); 1855 + dma_release_channel(host->dma); 1776 1856 1777 1857 probe_free_gpio_wp: 1778 1858 if (!host->pdata->no_wprotect) ··· 1817 1897 s3cmci_debugfs_remove(host); 1818 1898 s3cmci_cpufreq_deregister(host); 1819 1899 mmc_remove_host(mmc); 1820 - clk_disable(host->clk); 1900 + clk_disable_unprepare(host->clk); 1821 1901 } 1822 1902 1823 1903 static int s3cmci_remove(struct platform_device *pdev) ··· 1834 1914 tasklet_disable(&host->pio_tasklet); 1835 1915 1836 1916 if (s3cmci_host_usedma(host)) 1837 - s3c2410_dma_free(host->dma, &s3cmci_dma_client); 1917 + dma_release_channel(host->dma); 1838 1918 1839 1919 free_irq(host->irq, host); 1840 1920
+1 -3
drivers/mmc/host/s3cmci.h
··· 26 26 void __iomem *base; 27 27 int irq; 28 28 int irq_cd; 29 - int dma; 29 + struct dma_chan *dma; 30 30 31 31 unsigned long clk_rate; 32 32 unsigned long clk_div; ··· 36 36 int is2440; 37 37 unsigned sdiimsk; 38 38 unsigned sdidata; 39 - int dodma; 40 - int dmatogo; 41 39 42 40 bool irq_disabled; 43 41 bool irq_enabled;
+3 -1
drivers/mmc/host/sdhci-acpi.c
··· 124 124 125 125 static const struct sdhci_acpi_slot sdhci_acpi_slot_int_emmc = { 126 126 .chip = &sdhci_acpi_chip_int, 127 - .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE | MMC_CAP_HW_RESET, 127 + .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE | 128 + MMC_CAP_HW_RESET | MMC_CAP_1_8V_DDR, 128 129 .caps2 = MMC_CAP2_HC_ERASE_SZ, 129 130 .flags = SDHCI_ACPI_RUNTIME_PM, 131 + .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, 130 132 }; 131 133 132 134 static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sdio = {
-1
drivers/mmc/host/sdhci-msm.c
··· 16 16 17 17 #include <linux/module.h> 18 18 #include <linux/of_device.h> 19 - #include <linux/regulator/consumer.h> 20 19 #include <linux/delay.h> 21 20 #include <linux/mmc/mmc.h> 22 21 #include <linux/slab.h>
+20 -18
drivers/mmc/host/sdhci-pci.c
··· 103 103 SDHCI_QUIRK_BROKEN_TIMEOUT_VAL, 104 104 }; 105 105 106 + static const struct sdhci_pci_fixes sdhci_intel_qrk = { 107 + .quirks = SDHCI_QUIRK_NO_HISPD_BIT, 108 + }; 109 + 106 110 static int mrst_hc_probe_slot(struct sdhci_pci_slot *slot) 107 111 { 108 112 slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA; ··· 268 264 static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot) 269 265 { 270 266 slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE | 271 - MMC_CAP_HW_RESET; 267 + MMC_CAP_HW_RESET | MMC_CAP_1_8V_DDR; 272 268 slot->host->mmc->caps2 |= MMC_CAP2_HC_ERASE_SZ; 273 269 slot->hw_reset = sdhci_pci_int_hw_reset; 274 270 return 0; ··· 283 279 static const struct sdhci_pci_fixes sdhci_intel_byt_emmc = { 284 280 .allow_runtime_pm = true, 285 281 .probe_slot = byt_emmc_probe_slot, 282 + .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, 286 283 }; 287 284 288 285 static const struct sdhci_pci_fixes sdhci_intel_byt_sdio = { ··· 758 753 759 754 { 760 755 .vendor = PCI_VENDOR_ID_INTEL, 756 + .device = PCI_DEVICE_ID_INTEL_QRK_SD, 757 + .subvendor = PCI_ANY_ID, 758 + .subdevice = PCI_ANY_ID, 759 + .driver_data = (kernel_ulong_t)&sdhci_intel_qrk, 760 + }, 761 + 762 + { 763 + .vendor = PCI_VENDOR_ID_INTEL, 761 764 .device = PCI_DEVICE_ID_INTEL_MRST_SD0, 762 765 .subvendor = PCI_ANY_ID, 763 766 .subdevice = PCI_ANY_ID, ··· 1143 1130 goto err_pci_suspend; 1144 1131 } 1145 1132 1146 - pci_save_state(pdev); 1147 1133 if (pm_flags & MMC_PM_KEEP_POWER) { 1148 - if (pm_flags & MMC_PM_WAKE_SDIO_IRQ) { 1149 - pci_pme_active(pdev, true); 1150 - pci_enable_wake(pdev, PCI_D3hot, 1); 1151 - } 1152 - pci_set_power_state(pdev, PCI_D3hot); 1153 - } else { 1154 - pci_enable_wake(pdev, PCI_D3hot, 0); 1155 - pci_disable_device(pdev); 1156 - pci_set_power_state(pdev, PCI_D3hot); 1157 - } 1134 + if (pm_flags & MMC_PM_WAKE_SDIO_IRQ) 1135 + device_init_wakeup(dev, true); 1136 + else 1137 + device_init_wakeup(dev, false); 1138 + } else 1139 + device_init_wakeup(dev, false); 1158 1140 1159 1141 return 0; 1160 1142 ··· 1169 1161 chip = pci_get_drvdata(pdev); 1170 1162 if (!chip) 1171 1163 return 0; 1172 - 1173 - pci_set_power_state(pdev, PCI_D0); 1174 - pci_restore_state(pdev); 1175 - ret = pci_enable_device(pdev); 1176 - if (ret) 1177 - return ret; 1178 1164 1179 1165 if (chip->fixes && chip->fixes->resume) { 1180 1166 ret = chip->fixes->resume(chip);
+1
drivers/mmc/host/sdhci-pci.h
··· 17 17 #define PCI_DEVICE_ID_INTEL_CLV_SDIO2 0x08fb 18 18 #define PCI_DEVICE_ID_INTEL_CLV_EMMC0 0x08e5 19 19 #define PCI_DEVICE_ID_INTEL_CLV_EMMC1 0x08e6 20 + #define PCI_DEVICE_ID_INTEL_QRK_SD 0x08A7 20 21 21 22 /* 22 23 * PCI registers
+3 -10
drivers/mmc/host/sdhci-pxav3.c
··· 288 288 int ret; 289 289 struct clk *clk; 290 290 291 - pxa = kzalloc(sizeof(struct sdhci_pxa), GFP_KERNEL); 291 + pxa = devm_kzalloc(&pdev->dev, sizeof(struct sdhci_pxa), GFP_KERNEL); 292 292 if (!pxa) 293 293 return -ENOMEM; 294 294 295 295 host = sdhci_pltfm_init(pdev, &sdhci_pxav3_pdata, 0); 296 - if (IS_ERR(host)) { 297 - kfree(pxa); 296 + if (IS_ERR(host)) 298 297 return PTR_ERR(host); 299 - } 300 298 301 299 if (of_device_is_compatible(np, "marvell,armada-380-sdhci")) { 302 300 ret = mv_conf_mbus_windows(pdev, mv_mbus_dram_info()); ··· 306 308 pltfm_host = sdhci_priv(host); 307 309 pltfm_host->priv = pxa; 308 310 309 - clk = clk_get(dev, NULL); 311 + clk = devm_clk_get(dev, NULL); 310 312 if (IS_ERR(clk)) { 311 313 dev_err(dev, "failed to get io clock\n"); 312 314 ret = PTR_ERR(clk); ··· 387 389 pm_runtime_put_sync(&pdev->dev); 388 390 pm_runtime_disable(&pdev->dev); 389 391 clk_disable_unprepare(clk); 390 - clk_put(clk); 391 392 err_clk_get: 392 393 err_mbus_win: 393 394 sdhci_pltfm_free(pdev); 394 - kfree(pxa); 395 395 return ret; 396 396 } 397 397 ··· 397 401 { 398 402 struct sdhci_host *host = platform_get_drvdata(pdev); 399 403 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 400 - struct sdhci_pxa *pxa = pltfm_host->priv; 401 404 402 405 pm_runtime_get_sync(&pdev->dev); 403 406 sdhci_remove_host(host, 1); 404 407 pm_runtime_disable(&pdev->dev); 405 408 406 409 clk_disable_unprepare(pltfm_host->clk); 407 - clk_put(pltfm_host->clk); 408 410 409 411 sdhci_pltfm_free(pdev); 410 - kfree(pxa); 411 412 412 413 return 0; 413 414 }
+176
drivers/mmc/host/sdhci-st.c
··· 1 + /* 2 + * Support for SDHCI on STMicroelectronics SoCs 3 + * 4 + * Copyright (C) 2014 STMicroelectronics Ltd 5 + * Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> 6 + * Contributors: Peter Griffin <peter.griffin@linaro.org> 7 + * 8 + * Based on sdhci-cns3xxx.c 9 + * 10 + * This program is free software; you can redistribute it and/or modify 11 + * it under the terms of the GNU General Public License version 2 as 12 + * published by the Free Software Foundation. 13 + * 14 + * This program is distributed in the hope that it will be useful, 15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 + * GNU General Public License for more details. 18 + * 19 + */ 20 + 21 + #include <linux/io.h> 22 + #include <linux/of.h> 23 + #include <linux/module.h> 24 + #include <linux/err.h> 25 + #include <linux/mmc/host.h> 26 + 27 + #include "sdhci-pltfm.h" 28 + 29 + static u32 sdhci_st_readl(struct sdhci_host *host, int reg) 30 + { 31 + u32 ret; 32 + 33 + switch (reg) { 34 + case SDHCI_CAPABILITIES: 35 + ret = readl_relaxed(host->ioaddr + reg); 36 + /* Support 3.3V and 1.8V */ 37 + ret &= ~SDHCI_CAN_VDD_300; 38 + break; 39 + default: 40 + ret = readl_relaxed(host->ioaddr + reg); 41 + } 42 + return ret; 43 + } 44 + 45 + static const struct sdhci_ops sdhci_st_ops = { 46 + .get_max_clock = sdhci_pltfm_clk_get_max_clock, 47 + .set_clock = sdhci_set_clock, 48 + .set_bus_width = sdhci_set_bus_width, 49 + .read_l = sdhci_st_readl, 50 + .reset = sdhci_reset, 51 + }; 52 + 53 + static const struct sdhci_pltfm_data sdhci_st_pdata = { 54 + .ops = &sdhci_st_ops, 55 + .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC | 56 + SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, 57 + }; 58 + 59 + 60 + static int sdhci_st_probe(struct platform_device *pdev) 61 + { 62 + struct sdhci_host *host; 63 + struct sdhci_pltfm_host *pltfm_host; 64 + struct clk *clk; 65 + int ret = 0; 66 + u16 host_version; 67 + 68 + clk = devm_clk_get(&pdev->dev, "mmc"); 69 + if (IS_ERR(clk)) { 70 + dev_err(&pdev->dev, "Peripheral clk not found\n"); 71 + return PTR_ERR(clk); 72 + } 73 + 74 + host = sdhci_pltfm_init(pdev, &sdhci_st_pdata, 0); 75 + if (IS_ERR(host)) { 76 + dev_err(&pdev->dev, "Failed sdhci_pltfm_init\n"); 77 + return PTR_ERR(host); 78 + } 79 + 80 + ret = mmc_of_parse(host->mmc); 81 + 82 + if (ret) { 83 + dev_err(&pdev->dev, "Failed mmc_of_parse\n"); 84 + return ret; 85 + } 86 + 87 + clk_prepare_enable(clk); 88 + 89 + pltfm_host = sdhci_priv(host); 90 + pltfm_host->clk = clk; 91 + 92 + ret = sdhci_add_host(host); 93 + if (ret) { 94 + dev_err(&pdev->dev, "Failed sdhci_add_host\n"); 95 + goto err_out; 96 + } 97 + 98 + platform_set_drvdata(pdev, host); 99 + 100 + host_version = readw_relaxed((host->ioaddr + SDHCI_HOST_VERSION)); 101 + 102 + dev_info(&pdev->dev, "SDHCI ST Initialised: Host Version: 0x%x Vendor Version 0x%x\n", 103 + ((host_version & SDHCI_SPEC_VER_MASK) >> SDHCI_SPEC_VER_SHIFT), 104 + ((host_version & SDHCI_VENDOR_VER_MASK) >> 105 + SDHCI_VENDOR_VER_SHIFT)); 106 + 107 + return 0; 108 + 109 + err_out: 110 + clk_disable_unprepare(clk); 111 + sdhci_pltfm_free(pdev); 112 + 113 + return ret; 114 + } 115 + 116 + static int sdhci_st_remove(struct platform_device *pdev) 117 + { 118 + struct sdhci_host *host = platform_get_drvdata(pdev); 119 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 120 + 121 + clk_disable_unprepare(pltfm_host->clk); 122 + 123 + return sdhci_pltfm_unregister(pdev); 124 + } 125 + 126 + #ifdef CONFIG_PM_SLEEP 127 + static int sdhci_st_suspend(struct device *dev) 128 + { 129 + struct sdhci_host *host = dev_get_drvdata(dev); 130 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 131 + int ret = sdhci_suspend_host(host); 132 + 133 + if (ret) 134 + goto out; 135 + 136 + clk_disable_unprepare(pltfm_host->clk); 137 + out: 138 + return ret; 139 + } 140 + 141 + static int sdhci_st_resume(struct device *dev) 142 + { 143 + struct sdhci_host *host = dev_get_drvdata(dev); 144 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 145 + 146 + clk_prepare_enable(pltfm_host->clk); 147 + 148 + return sdhci_resume_host(host); 149 + } 150 + #endif 151 + 152 + static SIMPLE_DEV_PM_OPS(sdhci_st_pmops, sdhci_st_suspend, sdhci_st_resume); 153 + 154 + static const struct of_device_id st_sdhci_match[] = { 155 + { .compatible = "st,sdhci" }, 156 + {}, 157 + }; 158 + 159 + MODULE_DEVICE_TABLE(of, st_sdhci_match); 160 + 161 + static struct platform_driver sdhci_st_driver = { 162 + .probe = sdhci_st_probe, 163 + .remove = sdhci_st_remove, 164 + .driver = { 165 + .name = "sdhci-st", 166 + .pm = &sdhci_st_pmops, 167 + .of_match_table = of_match_ptr(st_sdhci_match), 168 + }, 169 + }; 170 + 171 + module_platform_driver(sdhci_st_driver); 172 + 173 + MODULE_DESCRIPTION("SDHCI driver for STMicroelectronics SoCs"); 174 + MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>"); 175 + MODULE_LICENSE("GPL v2"); 176 + MODULE_ALIAS("platform:st-sdhci");
-2
drivers/mmc/host/sdhci-tegra.c
··· 26 26 #include <linux/mmc/host.h> 27 27 #include <linux/mmc/slot-gpio.h> 28 28 29 - #include <asm/gpio.h> 30 - 31 29 #include "sdhci-pltfm.h" 32 30 33 31 /* Tegra SDHOST controller vendor register definitions */
+58 -86
drivers/mmc/host/sdhci.c
··· 1223 1223 static void sdhci_set_power(struct sdhci_host *host, unsigned char mode, 1224 1224 unsigned short vdd) 1225 1225 { 1226 + struct mmc_host *mmc = host->mmc; 1226 1227 u8 pwr = 0; 1228 + 1229 + if (!IS_ERR(mmc->supply.vmmc)) { 1230 + spin_unlock_irq(&host->lock); 1231 + mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); 1232 + spin_lock_irq(&host->lock); 1233 + return; 1234 + } 1227 1235 1228 1236 if (mode != MMC_POWER_OFF) { 1229 1237 switch (1 << vdd) { ··· 1290 1282 */ 1291 1283 if (host->quirks & SDHCI_QUIRK_DELAY_AFTER_POWER) 1292 1284 mdelay(10); 1293 - } 1294 - 1295 - if (host->vmmc) { 1296 - spin_unlock_irq(&host->lock); 1297 - mmc_regulator_set_ocr(host->mmc, host->vmmc, vdd); 1298 - spin_lock_irq(&host->lock); 1299 1285 } 1300 1286 } 1301 1287 ··· 1442 1440 { 1443 1441 unsigned long flags; 1444 1442 u8 ctrl; 1443 + struct mmc_host *mmc = host->mmc; 1445 1444 1446 1445 spin_lock_irqsave(&host->lock, flags); 1447 1446 1448 1447 if (host->flags & SDHCI_DEVICE_DEAD) { 1449 1448 spin_unlock_irqrestore(&host->lock, flags); 1450 - if (host->vmmc && ios->power_mode == MMC_POWER_OFF) 1451 - mmc_regulator_set_ocr(host->mmc, host->vmmc, 0); 1449 + if (!IS_ERR(mmc->supply.vmmc) && 1450 + ios->power_mode == MMC_POWER_OFF) 1451 + mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0); 1452 1452 return; 1453 1453 } 1454 1454 ··· 1533 1529 /* Re-enable SD Clock */ 1534 1530 host->ops->set_clock(host, host->clock); 1535 1531 } 1536 - 1537 1532 1538 1533 /* Reset SD Clock Enable */ 1539 1534 clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); ··· 1710 1707 static int sdhci_do_start_signal_voltage_switch(struct sdhci_host *host, 1711 1708 struct mmc_ios *ios) 1712 1709 { 1710 + struct mmc_host *mmc = host->mmc; 1713 1711 u16 ctrl; 1714 1712 int ret; 1715 1713 ··· 1729 1725 ctrl &= ~SDHCI_CTRL_VDD_180; 1730 1726 sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); 1731 1727 1732 - if (host->vqmmc) { 1733 - ret = regulator_set_voltage(host->vqmmc, 2700000, 3600000); 1728 + if (!IS_ERR(mmc->supply.vqmmc)) { 1729 + ret = regulator_set_voltage(mmc->supply.vqmmc, 2700000, 1730 + 3600000); 1734 1731 if (ret) { 1735 1732 pr_warning("%s: Switching to 3.3V signalling voltage " 1736 - " failed\n", mmc_hostname(host->mmc)); 1733 + " failed\n", mmc_hostname(mmc)); 1737 1734 return -EIO; 1738 1735 } 1739 1736 } ··· 1747 1742 return 0; 1748 1743 1749 1744 pr_warning("%s: 3.3V regulator output did not became stable\n", 1750 - mmc_hostname(host->mmc)); 1745 + mmc_hostname(mmc)); 1751 1746 1752 1747 return -EAGAIN; 1753 1748 case MMC_SIGNAL_VOLTAGE_180: 1754 - if (host->vqmmc) { 1755 - ret = regulator_set_voltage(host->vqmmc, 1749 + if (!IS_ERR(mmc->supply.vqmmc)) { 1750 + ret = regulator_set_voltage(mmc->supply.vqmmc, 1756 1751 1700000, 1950000); 1757 1752 if (ret) { 1758 1753 pr_warning("%s: Switching to 1.8V signalling voltage " 1759 - " failed\n", mmc_hostname(host->mmc)); 1754 + " failed\n", mmc_hostname(mmc)); 1760 1755 return -EIO; 1761 1756 } 1762 1757 } ··· 1768 1763 ctrl |= SDHCI_CTRL_VDD_180; 1769 1764 sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); 1770 1765 1771 - /* Wait for 5ms */ 1772 - usleep_range(5000, 5500); 1773 - 1774 1766 /* 1.8V regulator output should be stable within 5 ms */ 1775 1767 ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); 1776 1768 if (ctrl & SDHCI_CTRL_VDD_180) 1777 1769 return 0; 1778 1770 1779 1771 pr_warning("%s: 1.8V regulator output did not became stable\n", 1780 - mmc_hostname(host->mmc)); 1772 + mmc_hostname(mmc)); 1781 1773 1782 1774 return -EAGAIN; 1783 1775 case MMC_SIGNAL_VOLTAGE_120: 1784 - if (host->vqmmc) { 1785 - ret = regulator_set_voltage(host->vqmmc, 1100000, 1300000); 1776 + if (!IS_ERR(mmc->supply.vqmmc)) { 1777 + ret = regulator_set_voltage(mmc->supply.vqmmc, 1100000, 1778 + 1300000); 1786 1779 if (ret) { 1787 1780 pr_warning("%s: Switching to 1.2V signalling voltage " 1788 - " failed\n", mmc_hostname(host->mmc)); 1781 + " failed\n", mmc_hostname(mmc)); 1789 1782 return -EIO; 1790 1783 } 1791 1784 } ··· 2646 2643 int sdhci_runtime_suspend_host(struct sdhci_host *host) 2647 2644 { 2648 2645 unsigned long flags; 2649 - int ret = 0; 2650 2646 2651 2647 /* Disable tuning since we are suspending */ 2652 2648 if (host->flags & SDHCI_USING_RETUNING_TIMER) { ··· 2665 2663 host->runtime_suspended = true; 2666 2664 spin_unlock_irqrestore(&host->lock, flags); 2667 2665 2668 - return ret; 2666 + return 0; 2669 2667 } 2670 2668 EXPORT_SYMBOL_GPL(sdhci_runtime_suspend_host); 2671 2669 2672 2670 int sdhci_runtime_resume_host(struct sdhci_host *host) 2673 2671 { 2674 2672 unsigned long flags; 2675 - int ret = 0, host_flags = host->flags; 2673 + int host_flags = host->flags; 2676 2674 2677 2675 if (host_flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) { 2678 2676 if (host->ops->enable_dma) ··· 2711 2709 2712 2710 spin_unlock_irqrestore(&host->lock, flags); 2713 2711 2714 - return ret; 2712 + return 0; 2715 2713 } 2716 2714 EXPORT_SYMBOL_GPL(sdhci_runtime_resume_host); 2717 2715 ··· 2822 2820 * (128) and potentially one alignment transfer for 2823 2821 * each of those entries. 2824 2822 */ 2825 - host->adma_desc = dma_alloc_coherent(mmc_dev(host->mmc), 2823 + host->adma_desc = dma_alloc_coherent(mmc_dev(mmc), 2826 2824 ADMA_SIZE, &host->adma_addr, 2827 2825 GFP_KERNEL); 2828 2826 host->align_buffer = kmalloc(128 * 4, GFP_KERNEL); 2829 2827 if (!host->adma_desc || !host->align_buffer) { 2830 - dma_free_coherent(mmc_dev(host->mmc), ADMA_SIZE, 2828 + dma_free_coherent(mmc_dev(mmc), ADMA_SIZE, 2831 2829 host->adma_desc, host->adma_addr); 2832 2830 kfree(host->align_buffer); 2833 2831 pr_warning("%s: Unable to allocate ADMA " ··· 2840 2838 pr_warning("%s: unable to allocate aligned ADMA descriptor\n", 2841 2839 mmc_hostname(mmc)); 2842 2840 host->flags &= ~SDHCI_USE_ADMA; 2843 - dma_free_coherent(mmc_dev(host->mmc), ADMA_SIZE, 2841 + dma_free_coherent(mmc_dev(mmc), ADMA_SIZE, 2844 2842 host->adma_desc, host->adma_addr); 2845 2843 kfree(host->align_buffer); 2846 2844 host->adma_desc = NULL; ··· 2855 2853 */ 2856 2854 if (!(host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA))) { 2857 2855 host->dma_mask = DMA_BIT_MASK(64); 2858 - mmc_dev(host->mmc)->dma_mask = &host->dma_mask; 2856 + mmc_dev(mmc)->dma_mask = &host->dma_mask; 2859 2857 } 2860 2858 2861 2859 if (host->version >= SDHCI_SPEC_300) ··· 2961 2959 mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED; 2962 2960 2963 2961 if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) && 2964 - !(host->mmc->caps & MMC_CAP_NONREMOVABLE)) 2962 + !(mmc->caps & MMC_CAP_NONREMOVABLE)) 2965 2963 mmc->caps |= MMC_CAP_NEEDS_POLL; 2966 2964 2965 + /* If there are external regulators, get them */ 2966 + if (mmc_regulator_get_supply(mmc) == -EPROBE_DEFER) 2967 + return -EPROBE_DEFER; 2968 + 2967 2969 /* If vqmmc regulator and no 1.8V signalling, then there's no UHS */ 2968 - host->vqmmc = regulator_get_optional(mmc_dev(mmc), "vqmmc"); 2969 - if (IS_ERR_OR_NULL(host->vqmmc)) { 2970 - if (PTR_ERR(host->vqmmc) < 0) { 2971 - pr_info("%s: no vqmmc regulator found\n", 2972 - mmc_hostname(mmc)); 2973 - host->vqmmc = NULL; 2974 - } 2975 - } else { 2976 - ret = regulator_enable(host->vqmmc); 2977 - if (!regulator_is_supported_voltage(host->vqmmc, 1700000, 2978 - 1950000)) 2970 + if (!IS_ERR(mmc->supply.vqmmc)) { 2971 + ret = regulator_enable(mmc->supply.vqmmc); 2972 + if (!regulator_is_supported_voltage(mmc->supply.vqmmc, 1700000, 2973 + 1950000)) 2979 2974 caps[1] &= ~(SDHCI_SUPPORT_SDR104 | 2980 2975 SDHCI_SUPPORT_SDR50 | 2981 2976 SDHCI_SUPPORT_DDR50); 2982 2977 if (ret) { 2983 2978 pr_warn("%s: Failed to enable vqmmc regulator: %d\n", 2984 2979 mmc_hostname(mmc), ret); 2985 - host->vqmmc = NULL; 2980 + mmc->supply.vqmmc = NULL; 2986 2981 } 2987 2982 } 2988 2983 ··· 3040 3041 3041 3042 ocr_avail = 0; 3042 3043 3043 - host->vmmc = regulator_get_optional(mmc_dev(mmc), "vmmc"); 3044 - if (IS_ERR_OR_NULL(host->vmmc)) { 3045 - if (PTR_ERR(host->vmmc) < 0) { 3046 - pr_info("%s: no vmmc regulator found\n", 3047 - mmc_hostname(mmc)); 3048 - host->vmmc = NULL; 3049 - } 3050 - } 3051 - 3052 - #ifdef CONFIG_REGULATOR 3053 - /* 3054 - * Voltage range check makes sense only if regulator reports 3055 - * any voltage value. 3056 - */ 3057 - if (host->vmmc && regulator_get_voltage(host->vmmc) > 0) { 3058 - ret = regulator_is_supported_voltage(host->vmmc, 2700000, 3059 - 3600000); 3060 - if ((ret <= 0) || (!(caps[0] & SDHCI_CAN_VDD_330))) 3061 - caps[0] &= ~SDHCI_CAN_VDD_330; 3062 - if ((ret <= 0) || (!(caps[0] & SDHCI_CAN_VDD_300))) 3063 - caps[0] &= ~SDHCI_CAN_VDD_300; 3064 - ret = regulator_is_supported_voltage(host->vmmc, 1700000, 3065 - 1950000); 3066 - if ((ret <= 0) || (!(caps[0] & SDHCI_CAN_VDD_180))) 3067 - caps[0] &= ~SDHCI_CAN_VDD_180; 3068 - } 3069 - #endif /* CONFIG_REGULATOR */ 3070 - 3071 3044 /* 3072 3045 * According to SD Host Controller spec v3.00, if the Host System 3073 3046 * can afford more than 150mA, Host Driver should set XPC to 1. Also ··· 3048 3077 * value. 3049 3078 */ 3050 3079 max_current_caps = sdhci_readl(host, SDHCI_MAX_CURRENT); 3051 - if (!max_current_caps && host->vmmc) { 3052 - u32 curr = regulator_get_current_limit(host->vmmc); 3080 + if (!max_current_caps && !IS_ERR(mmc->supply.vmmc)) { 3081 + u32 curr = regulator_get_current_limit(mmc->supply.vmmc); 3053 3082 if (curr > 0) { 3054 3083 3055 3084 /* convert to SDHCI_MAX_CURRENT format */ ··· 3089 3118 SDHCI_MAX_CURRENT_MULTIPLIER; 3090 3119 } 3091 3120 3121 + /* If OCR set by external regulators, use it instead */ 3122 + if (mmc->ocr_avail) 3123 + ocr_avail = mmc->ocr_avail; 3124 + 3092 3125 if (host->ocr_mask) 3093 - ocr_avail = host->ocr_mask; 3126 + ocr_avail &= host->ocr_mask; 3094 3127 3095 3128 mmc->ocr_avail = ocr_avail; 3096 3129 mmc->ocr_avail_sdio = ocr_avail; ··· 3248 3273 3249 3274 void sdhci_remove_host(struct sdhci_host *host, int dead) 3250 3275 { 3276 + struct mmc_host *mmc = host->mmc; 3251 3277 unsigned long flags; 3252 3278 3253 3279 if (dead) { ··· 3258 3282 3259 3283 if (host->mrq) { 3260 3284 pr_err("%s: Controller removed during " 3261 - " transfer!\n", mmc_hostname(host->mmc)); 3285 + " transfer!\n", mmc_hostname(mmc)); 3262 3286 3263 3287 host->mrq->cmd->error = -ENOMEDIUM; 3264 3288 tasklet_schedule(&host->finish_tasklet); ··· 3269 3293 3270 3294 sdhci_disable_card_detection(host); 3271 3295 3272 - mmc_remove_host(host->mmc); 3296 + mmc_remove_host(mmc); 3273 3297 3274 3298 #ifdef SDHCI_USE_LEDS_CLASS 3275 3299 led_classdev_unregister(&host->led); ··· 3286 3310 3287 3311 tasklet_kill(&host->finish_tasklet); 3288 3312 3289 - if (host->vmmc) { 3290 - regulator_disable(host->vmmc); 3291 - regulator_put(host->vmmc); 3292 - } 3313 + if (!IS_ERR(mmc->supply.vmmc)) 3314 + regulator_disable(mmc->supply.vmmc); 3293 3315 3294 - if (host->vqmmc) { 3295 - regulator_disable(host->vqmmc); 3296 - regulator_put(host->vqmmc); 3297 - } 3316 + if (!IS_ERR(mmc->supply.vqmmc)) 3317 + regulator_disable(mmc->supply.vqmmc); 3298 3318 3299 3319 if (host->adma_desc) 3300 - dma_free_coherent(mmc_dev(host->mmc), ADMA_SIZE, 3320 + dma_free_coherent(mmc_dev(mmc), ADMA_SIZE, 3301 3321 host->adma_desc, host->adma_addr); 3302 3322 kfree(host->align_buffer); 3303 3323
+38 -58
drivers/mmc/host/sh_mmcif.c
··· 386 386 struct sh_mmcif_plat_data *pdata, 387 387 enum dma_transfer_direction direction) 388 388 { 389 - struct dma_slave_config cfg; 389 + struct dma_slave_config cfg = { 0, }; 390 390 struct dma_chan *chan; 391 391 unsigned int slave_id; 392 392 struct resource *res; ··· 417 417 /* In the OF case the driver will get the slave ID from the DT */ 418 418 cfg.slave_id = slave_id; 419 419 cfg.direction = direction; 420 - cfg.dst_addr = res->start + MMCIF_CE_DATA; 421 - cfg.src_addr = 0; 420 + 421 + if (direction == DMA_DEV_TO_MEM) { 422 + cfg.src_addr = res->start + MMCIF_CE_DATA; 423 + cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 424 + } else { 425 + cfg.dst_addr = res->start + MMCIF_CE_DATA; 426 + cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 427 + } 428 + 422 429 ret = dmaengine_slave_config(chan, &cfg); 423 430 if (ret < 0) { 424 431 dma_release_channel(chan); ··· 1385 1378 dev_err(&pdev->dev, "Get irq error\n"); 1386 1379 return -ENXIO; 1387 1380 } 1381 + 1388 1382 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1389 - if (!res) { 1390 - dev_err(&pdev->dev, "platform_get_resource error.\n"); 1391 - return -ENXIO; 1392 - } 1393 - reg = ioremap(res->start, resource_size(res)); 1394 - if (!reg) { 1395 - dev_err(&pdev->dev, "ioremap error.\n"); 1396 - return -ENOMEM; 1397 - } 1383 + reg = devm_ioremap_resource(&pdev->dev, res); 1384 + if (IS_ERR(reg)) 1385 + return PTR_ERR(reg); 1398 1386 1399 1387 mmc = mmc_alloc_host(sizeof(struct sh_mmcif_host), &pdev->dev); 1400 - if (!mmc) { 1401 - ret = -ENOMEM; 1402 - goto ealloch; 1403 - } 1388 + if (!mmc) 1389 + return -ENOMEM; 1404 1390 1405 1391 ret = mmc_of_parse(mmc); 1406 1392 if (ret < 0) 1407 - goto eofparse; 1393 + goto err_host; 1408 1394 1409 1395 host = mmc_priv(mmc); 1410 1396 host->mmc = mmc; ··· 1427 1427 pm_runtime_enable(&pdev->dev); 1428 1428 host->power = false; 1429 1429 1430 - host->hclk = clk_get(&pdev->dev, NULL); 1430 + host->hclk = devm_clk_get(&pdev->dev, NULL); 1431 1431 if (IS_ERR(host->hclk)) { 1432 1432 ret = PTR_ERR(host->hclk); 1433 1433 dev_err(&pdev->dev, "cannot get clock: %d\n", ret); 1434 - goto eclkget; 1434 + goto err_pm; 1435 1435 } 1436 1436 ret = sh_mmcif_clk_update(host); 1437 1437 if (ret < 0) 1438 - goto eclkupdate; 1438 + goto err_pm; 1439 1439 1440 1440 ret = pm_runtime_resume(&pdev->dev); 1441 1441 if (ret < 0) 1442 - goto eresume; 1442 + goto err_clk; 1443 1443 1444 1444 INIT_DELAYED_WORK(&host->timeout_work, mmcif_timeout_work); 1445 1445 ··· 1447 1447 sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, MASK_ALL); 1448 1448 1449 1449 name = irq[1] < 0 ? dev_name(&pdev->dev) : "sh_mmc:error"; 1450 - ret = request_threaded_irq(irq[0], sh_mmcif_intr, sh_mmcif_irqt, 0, name, host); 1450 + ret = devm_request_threaded_irq(&pdev->dev, irq[0], sh_mmcif_intr, 1451 + sh_mmcif_irqt, 0, name, host); 1451 1452 if (ret) { 1452 1453 dev_err(&pdev->dev, "request_irq error (%s)\n", name); 1453 - goto ereqirq0; 1454 + goto err_clk; 1454 1455 } 1455 1456 if (irq[1] >= 0) { 1456 - ret = request_threaded_irq(irq[1], sh_mmcif_intr, sh_mmcif_irqt, 1457 - 0, "sh_mmc:int", host); 1457 + ret = devm_request_threaded_irq(&pdev->dev, irq[1], 1458 + sh_mmcif_intr, sh_mmcif_irqt, 1459 + 0, "sh_mmc:int", host); 1458 1460 if (ret) { 1459 1461 dev_err(&pdev->dev, "request_irq error (sh_mmc:int)\n"); 1460 - goto ereqirq1; 1462 + goto err_clk; 1461 1463 } 1462 1464 } 1463 1465 1464 1466 if (pd && pd->use_cd_gpio) { 1465 1467 ret = mmc_gpio_request_cd(mmc, pd->cd_gpio, 0); 1466 1468 if (ret < 0) 1467 - goto erqcd; 1469 + goto err_clk; 1468 1470 } 1469 1471 1470 1472 mutex_init(&host->thread_lock); 1471 1473 1472 - clk_disable_unprepare(host->hclk); 1473 1474 ret = mmc_add_host(mmc); 1474 1475 if (ret < 0) 1475 - goto emmcaddh; 1476 + goto err_clk; 1476 1477 1477 1478 dev_pm_qos_expose_latency_limit(&pdev->dev, 100); 1478 1479 1479 - dev_info(&pdev->dev, "driver version %s\n", DRIVER_VERSION); 1480 - dev_dbg(&pdev->dev, "chip ver H'%04x\n", 1481 - sh_mmcif_readl(host->addr, MMCIF_CE_VERSION) & 0x0000ffff); 1480 + dev_info(&pdev->dev, "Chip version 0x%04x, clock rate %luMHz\n", 1481 + sh_mmcif_readl(host->addr, MMCIF_CE_VERSION) & 0xffff, 1482 + clk_get_rate(host->hclk) / 1000000UL); 1483 + 1484 + clk_disable_unprepare(host->hclk); 1482 1485 return ret; 1483 1486 1484 - emmcaddh: 1485 - erqcd: 1486 - if (irq[1] >= 0) 1487 - free_irq(irq[1], host); 1488 - ereqirq1: 1489 - free_irq(irq[0], host); 1490 - ereqirq0: 1491 - pm_runtime_suspend(&pdev->dev); 1492 - eresume: 1487 + err_clk: 1493 1488 clk_disable_unprepare(host->hclk); 1494 - eclkupdate: 1495 - clk_put(host->hclk); 1496 - eclkget: 1489 + err_pm: 1497 1490 pm_runtime_disable(&pdev->dev); 1498 - eofparse: 1491 + err_host: 1499 1492 mmc_free_host(mmc); 1500 - ealloch: 1501 - iounmap(reg); 1502 1493 return ret; 1503 1494 } 1504 1495 1505 1496 static int sh_mmcif_remove(struct platform_device *pdev) 1506 1497 { 1507 1498 struct sh_mmcif_host *host = platform_get_drvdata(pdev); 1508 - int irq[2]; 1509 1499 1510 1500 host->dying = true; 1511 1501 clk_prepare_enable(host->hclk); ··· 1512 1522 * (a query on the linux-mmc mailing list didn't bring any replies). 1513 1523 */ 1514 1524 cancel_delayed_work_sync(&host->timeout_work); 1515 - 1516 - if (host->addr) 1517 - iounmap(host->addr); 1518 - 1519 - irq[0] = platform_get_irq(pdev, 0); 1520 - irq[1] = platform_get_irq(pdev, 1); 1521 - 1522 - free_irq(irq[0], host); 1523 - if (irq[1] >= 0) 1524 - free_irq(irq[1], host); 1525 1525 1526 1526 clk_disable_unprepare(host->hclk); 1527 1527 mmc_free_host(host->mmc);
+2
drivers/mmc/host/tmio_mmc_dma.c
··· 294 294 cfg.slave_id = pdata->dma->slave_id_tx; 295 295 cfg.direction = DMA_MEM_TO_DEV; 296 296 cfg.dst_addr = res->start + (CTL_SD_DATA_PORT << host->pdata->bus_shift); 297 + cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; 297 298 cfg.src_addr = 0; 298 299 ret = dmaengine_slave_config(host->chan_tx, &cfg); 299 300 if (ret < 0) ··· 313 312 cfg.slave_id = pdata->dma->slave_id_rx; 314 313 cfg.direction = DMA_DEV_TO_MEM; 315 314 cfg.src_addr = cfg.dst_addr; 315 + cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; 316 316 cfg.dst_addr = 0; 317 317 ret = dmaengine_slave_config(host->chan_rx, &cfg); 318 318 if (ret < 0)
+16 -17
drivers/mmc/host/wmt-sdmmc.c
··· 72 72 #define BM_SPI_CS 0x20 73 73 #define BM_SD_POWER 0x40 74 74 #define BM_SOFT_RESET 0x80 75 - #define BM_ONEBIT_MASK 0xFD 76 75 77 76 /* SDMMC_BLKLEN bit fields */ 78 77 #define BLKL_CRCERR_ABORT 0x0800 ··· 119 120 #define STS2_DATARSP_BUSY 0x20 120 121 #define STS2_DIS_FORCECLK 0x80 121 122 123 + /* SDMMC_EXTCTRL bit fields */ 124 + #define EXT_EIGHTBIT 0x04 122 125 123 126 /* MMC/SD DMA Controller Registers */ 124 127 #define SDDMA_GCR 0x100 ··· 673 672 static void wmt_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) 674 673 { 675 674 struct wmt_mci_priv *priv; 676 - u32 reg_tmp; 675 + u32 busmode, extctrl; 677 676 678 677 priv = mmc_priv(mmc); 679 678 ··· 688 687 if (ios->clock != 0) 689 688 clk_set_rate(priv->clk_sdmmc, ios->clock); 690 689 690 + busmode = readb(priv->sdmmc_base + SDMMC_BUSMODE); 691 + extctrl = readb(priv->sdmmc_base + SDMMC_EXTCTRL); 692 + 693 + busmode &= ~(BM_EIGHTBIT_MODE | BM_FOURBIT_MODE); 694 + extctrl &= ~EXT_EIGHTBIT; 695 + 691 696 switch (ios->bus_width) { 692 697 case MMC_BUS_WIDTH_8: 693 - reg_tmp = readb(priv->sdmmc_base + SDMMC_EXTCTRL); 694 - writeb(reg_tmp | 0x04, priv->sdmmc_base + SDMMC_EXTCTRL); 698 + busmode |= BM_EIGHTBIT_MODE; 699 + extctrl |= EXT_EIGHTBIT; 695 700 break; 696 701 case MMC_BUS_WIDTH_4: 697 - reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE); 698 - writeb(reg_tmp | BM_FOURBIT_MODE, priv->sdmmc_base + 699 - SDMMC_BUSMODE); 700 - 701 - reg_tmp = readb(priv->sdmmc_base + SDMMC_EXTCTRL); 702 - writeb(reg_tmp & 0xFB, priv->sdmmc_base + SDMMC_EXTCTRL); 702 + busmode |= BM_FOURBIT_MODE; 703 703 break; 704 704 case MMC_BUS_WIDTH_1: 705 - reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE); 706 - writeb(reg_tmp & BM_ONEBIT_MASK, priv->sdmmc_base + 707 - SDMMC_BUSMODE); 708 - 709 - reg_tmp = readb(priv->sdmmc_base + SDMMC_EXTCTRL); 710 - writeb(reg_tmp & 0xFB, priv->sdmmc_base + SDMMC_EXTCTRL); 711 705 break; 712 706 } 707 + 708 + writeb(busmode, priv->sdmmc_base + SDMMC_BUSMODE); 709 + writeb(extctrl, priv->sdmmc_base + SDMMC_EXTCTRL); 713 710 } 714 711 715 712 static int wmt_mci_get_ro(struct mmc_host *mmc) ··· 829 830 goto fail3; 830 831 } 831 832 832 - ret = request_irq(dma_irq, wmt_mci_dma_isr, 32, "sdmmc", priv); 833 + ret = request_irq(dma_irq, wmt_mci_dma_isr, 0, "sdmmc", priv); 833 834 if (ret) { 834 835 dev_err(&pdev->dev, "Register DMA IRQ fail\n"); 835 836 goto fail4;
+2
include/linux/mmc/dw_mmc.h
··· 213 213 #define DW_MCI_QUIRK_HIGHSPEED BIT(2) 214 214 /* Unreliable card detection */ 215 215 #define DW_MCI_QUIRK_BROKEN_CARD_DETECTION BIT(3) 216 + /* No write protect */ 217 + #define DW_MCI_QUIRK_NO_WRITE_PROTECT BIT(4) 216 218 217 219 /* Slot level quirks */ 218 220 /* This slot has no write protect */
-3
include/linux/mmc/sdhci.h
··· 104 104 105 105 const struct sdhci_ops *ops; /* Low level hw interface */ 106 106 107 - struct regulator *vmmc; /* Power regulator (vmmc) */ 108 - struct regulator *vqmmc; /* Signaling regulator (vccq) */ 109 - 110 107 /* Internal data */ 111 108 struct mmc_host *mmc; /* MMC structure */ 112 109 u64 dma_mask; /* custom DMA mask */
+1
include/linux/platform_data/mmc-omap.h
··· 28 28 */ 29 29 #define OMAP_HSMMC_SUPPORTS_DUAL_VOLT BIT(0) 30 30 #define OMAP_HSMMC_BROKEN_MULTIBLOCK_READ BIT(1) 31 + #define OMAP_HSMMC_SWAKEUP_MISSING BIT(2) 31 32 32 33 struct mmc_card; 33 34