History

Merge tag 'mmc-v4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc

Pull MMC updates from Ulf Hansson: "MMC core: - Decrease polling rate for erase/trim/discard - Allow non-sleeping GPIOs for card detect - Improve mmc block removal path - Enable support for mmc_sw_reset() for SDIO cards - Add mmc_sw_reset() to allow users to do a soft reset of the card - Allow power delay to be tunable via DT - Allow card detect debounce delay to be tunable via DT - Enable new quirk to limit clock rate for Marvell 8887 chip - Don't show eMMC RPMB and BOOT areas in /proc/partitions - Add capability to avoid 3.3V signaling for fragile HWs MMC host: - Improve/fixup support for handle highmem pages - Remove depends on HAS_DMA in case of platform dependency - mvsdio: Enable support for erase/trim/discard - rtsx_usb: Enable support for erase/trim/discard - renesas_sdhi: Fix WP logic regressions - renesas_sdhi: Add r8a77965 support - renesas_sdhi: Add R8A77980 to whitelist - meson: Add optional support for device reset - meson: Add support for the Meson-AXG platform - dw_mmc: Add new driver for BlueField DW variant - mediatek: Add support for 64G DRAM DMA - sunxi: Deploy runtime PM support - jz4740: Add support for JZ4780 - jz4740: Enable support for DT based platforms - sdhci: Various improvement to timeout handling - sdhci: Disable support for HS200/HS400/UHS when no 1.8V support - sdhci-omap: Add support for controller in k2g SoC - sdhci-omap: Add workarounds for a couple of Erratas - sdhci-omap: Enable support for generic sdhci DT properties - sdhci-cadence: Re-send tune request to deal with errata - sdhci-pci: Fix 3.3V voltage switch for some BYT-based Intel controllers - sdhci-pci: Avoid 3.3V signaling on some NI 904x - sdhci-esdhc-imx: Use watermark levels for PIO access - sdhci-msm: Improve card detection handling - sdhci-msm: Add support voltage pad switching" * tag 'mmc-v4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: (104 commits) mmc: renesas_sdhi: really fix WP logic regressions mmc: mvsdio: Enable MMC_CAP_ERASE mmc: mvsdio: Respect card busy time out from mmc core mmc: sdhci-msm: Remove NO_CARD_NO_RESET quirk mmc: sunxi: Use ifdef rather than __maybe_unused mmc: mxmmc: Use ifdef rather than __maybe_unused mmc: mxmmc: include linux/highmem.h mmc: sunxi: mark PM functions as __maybe_unused mmc: Throttle calls to MMC_SEND_STATUS during mmc_do_erase() mmc: au1xmmc: handle highmem pages mmc: Allow non-sleeping GPIO cd mmc: sdhci-*: Don't emit error msg if sdhci_add_host() fails mmc: sd: Define name for default speed dtr mmc: core: Move calls to ->prepare_hs400_tuning() closer to mmc code mmc: sdhci-xenon: use match_string() helper mmc: wbsd: handle highmem pages mmc: ushc: handle highmem pages mmc: mxcmmc: handle highmem pages mmc: atmel-mci: use sg_copy_{from,to}_buffer mmc: android-goldfish: use sg_copy_{from,to}_buffer ...

Linus Torvalds committed 8 years ago

Commit f60342f2 parents 5231804 ef5332c66 files · +1382 −431Browse files

Unified · Split

66 files
  1. Documentation/devicetree/bindings/mmc/amlogic,meson-gx.txt +3 −0
  2. Documentation/devicetree/bindings/mmc/bluefield-dw-mshc.txt +29 −0
  3. Documentation/devicetree/bindings/mmc/jz4740.txt +38 −0
  4. Documentation/devicetree/bindings/mmc/mmc.txt +6 −0
  5. Documentation/devicetree/bindings/mmc/sdhci-omap.txt +7 −0
  6. Documentation/devicetree/bindings/mmc/tmio_mmc.txt +2 −0
  7. arch/mips/boot/dts/ingenic/ci20.dts +34 −0
  8. arch/mips/boot/dts/ingenic/jz4780.dtsi +52 −0
  9. arch/mips/configs/ci20_defconfig +4 −0
  10. drivers/mmc/core/block.c +7 −4
  11. drivers/mmc/core/card.h +6 −0
  12. drivers/mmc/core/core.c +50 −17
  13. drivers/mmc/core/core.h +3 −1
  14. drivers/mmc/core/host.c +11 −5
  15. drivers/mmc/core/mmc.c +14 −2
  16. drivers/mmc/core/pwrseq_simple.c +9 −5
  17. drivers/mmc/core/quirks.h +3 −0
  18. drivers/mmc/core/sd.c +10 −2
  19. drivers/mmc/core/sdio.c +47 −23
  20. drivers/mmc/core/slot-gpio.c +16 −6
  21. drivers/mmc/host/Kconfig +18 −14
  22. drivers/mmc/host/Makefile +1 −0
  23. drivers/mmc/host/android-goldfish.c +4 −4
  24. drivers/mmc/host/atmel-mci.c +9 −12
  25. drivers/mmc/host/au1xmmc.c +8 −4
  26. drivers/mmc/host/davinci_mmc.c +2 −4
  27. drivers/mmc/host/dw_mmc-bluefield.c +81 −0
  28. drivers/mmc/host/dw_mmc-rockchip.c +2 −3
  29. drivers/mmc/host/dw_mmc.c +4 −0
  30. drivers/mmc/host/jz4740_mmc.c +138 −65
  31. drivers/mmc/host/meson-gx-mmc.c +61 −11
  32. drivers/mmc/host/mmci.c +0 −5
  33. drivers/mmc/host/mtk-sd.c +51 −12
  34. drivers/mmc/host/mvsdio.c +5 −1
  35. drivers/mmc/host/mxcmmc.c +16 −6
  36. drivers/mmc/host/renesas_sdhi_core.c +5 −0
  37. drivers/mmc/host/renesas_sdhi_internal_dmac.c +17 −15
  38. drivers/mmc/host/renesas_sdhi_sys_dmac.c +3 −0
  39. drivers/mmc/host/rtsx_usb_sdmmc.c +4 −15
  40. drivers/mmc/host/sdhci-bcm-kona.c +1 −3
  41. drivers/mmc/host/sdhci-cadence.c +18 −4
  42. drivers/mmc/host/sdhci-esdhc-imx.c +22 −0
  43. drivers/mmc/host/sdhci-msm.c +82 −3
  44. drivers/mmc/host/sdhci-of-arasan.c +4 −5
  45. drivers/mmc/host/sdhci-omap.c +81 −11
  46. drivers/mmc/host/sdhci-pci-core.c +31 −7
  47. drivers/mmc/host/sdhci-pci.h +1 −0
  48. drivers/mmc/host/sdhci-pic32.c +1 −3
  49. drivers/mmc/host/sdhci-pxav2.c +1 −3
  50. drivers/mmc/host/sdhci-pxav3.c +1 −3
  51. drivers/mmc/host/sdhci-s3c.c +1 −3
  52. drivers/mmc/host/sdhci-spear.c +1 −3
  53. drivers/mmc/host/sdhci-st.c +1 −3
  54. drivers/mmc/host/sdhci-tegra.c +1 −1
  55. drivers/mmc/host/sdhci-xenon-phy.c +3 −8
  56. drivers/mmc/host/sdhci.c +119 −29
  57. drivers/mmc/host/sdhci.h +15 −0
  58. drivers/mmc/host/sunxi-mmc.c +124 −63
  59. drivers/mmc/host/ushc.c +3 −1
  60. drivers/mmc/host/wbsd.c +30 −38
  61. drivers/mmc/host/wmt-sdmmc.c +2 −4
  62. include/dt-bindings/dma/jz4780-dma.h +49 −0
  63. include/linux/mmc/card.h +2 −0
  64. include/linux/mmc/core.h +1 −0
  65. include/linux/mmc/host.h +6 −0
  66. include/linux/mmc/sdio_ids.h +1 −0
Documentation/devicetree/bindings/mmc/amlogic,meson-gx.txt+3−0
@@ -12,6 +12,7 @@ Required properties: · 11 unmodified lines
1212 - "amlogic,meson-gxbb-mmc"
1313 - "amlogic,meson-gxl-mmc"
1414 - "amlogic,meson-gxm-mmc"
15+ - "amlogic,meson-axg-mmc"
1516 - clocks : A list of phandle + clock-specifier pairs for the clocks listed in clock-names.
1617 - clock-names: Should contain the following:
1718 "core" - Main peripheral bus clock
@@ -19,6 +20,7 @@ Required properties: · 1 unmodified line
1920 "clkin1" - Other parent clock of internal mux
2021 The driver has an internal mux clock which switches between clkin0 and clkin1 depending on the
2122 clock rate requested by the MMC core.
23+- resets : phandle of the internal reset line
2224
2325 Example:
2426
@@ -29,4 +31,5 @@ Example: · 4 unmodified lines
2931 clocks = <&clkc CLKID_SD_EMMC_A>, <&xtal>, <&clkc CLKID_FCLK_DIV2>;
3032 clock-names = "core", "clkin0", "clkin1";
3133 pinctrl-0 = <&emmc_pins>;
34+ resets = <&reset RESET_SD_EMMC_A>;
3235 };
Documentation/devicetree/bindings/mmc/bluefield-dw-mshc.txt+29−0
@@ -0,0 +1,29 @@
1+* Mellanox Bluefield SoC specific extensions to the Synopsys Designware
2+ Mobile Storage Host Controller
3+
4+Read synopsys-dw-mshc.txt for more details
5+
6+The Synopsys designware mobile storage host controller is used to interface
7+a SoC with storage medium such as eMMC or SD/MMC cards. This file documents
8+differences between the core Synopsys dw mshc controller properties described
9+by synopsys-dw-mshc.txt and the properties used by the Mellanox Bluefield SoC
10+specific extensions to the Synopsys Designware Mobile Storage Host Controller.
11+
12+Required Properties:
13+
14+* compatible: should be one of the following.
15+ - "mellanox,bluefield-dw-mshc": for controllers with Mellanox Bluefield SoC
16+ specific extensions.
17+
18+Example:
19+
20+ /* Mellanox Bluefield SoC MMC */
21+ mmc@6008000 {
22+ compatible = "mellanox,bluefield-dw-mshc";
23+ reg = <0x6008000 0x400>;
24+ interrupts = <32>;
25+ fifo-depth = <0x100>;
26+ clock-frequency = <24000000>;
27+ bus-width = <8>;
28+ cap-mmc-highspeed;
29+ };
Documentation/devicetree/bindings/mmc/jz4740.txt+38−0
@@ -0,0 +1,38 @@
1+* Ingenic JZ47xx MMC controllers
2+
3+This file documents the device tree properties used for the MMC controller in
4+Ingenic JZ4740/JZ4780 SoCs. These are in addition to the core MMC properties
5+described in mmc.txt.
6+
7+Required properties:
8+- compatible: Should be one of the following:
9+ - "ingenic,jz4740-mmc" for the JZ4740
10+ - "ingenic,jz4780-mmc" for the JZ4780
11+- reg: Should contain the MMC controller registers location and length.
12+- interrupts: Should contain the interrupt specifier of the MMC controller.
13+- clocks: Clock for the MMC controller.
14+
15+Optional properties:
16+- dmas: List of DMA specifiers with the controller specific format
17+ as described in the generic DMA client binding. A tx and rx
18+ specifier is required.
19+- dma-names: RX and TX DMA request names.
20+ Should be "rx" and "tx", in that order.
21+
22+For additional details on DMA client bindings see ../dma/dma.txt.
23+
24+Example:
25+
26+mmc0: mmc@13450000 {
27+ compatible = "ingenic,jz4780-mmc";
28+ reg = <0x13450000 0x1000>;
29+
30+ interrupt-parent = <&intc>;
31+ interrupts = <37>;
32+
33+ clocks = <&cgu JZ4780_CLK_MSC0>;
34+ clock-names = "mmc";
35+
36+ dmas = <&dma JZ4780_DMA_MSC0_RX 0xffffffff>, <&dma JZ4780_DMA_MSC0_TX 0xffffffff>;
37+ dma-names = "rx", "tx";
38+};
Documentation/devicetree/bindings/mmc/mmc.txt+6−0
@@ -19,6 +19,8 @@ Optional properties: · 18 unmodified lines
1919 - wp-gpios: Specify GPIOs for write protection, see gpio binding
2020 - cd-inverted: when present, polarity on the CD line is inverted. See the note
2121 below for the case, when a GPIO is used for the CD line
22+- cd-debounce-delay-ms: Set delay time before detecting card after card insert interrupt.
23+ It's only valid when cd-gpios is present.
2224 - wp-inverted: when present, polarity on the WP line is inverted. See the note
2325 below for the case, when a GPIO is used for the WP line
2426 - disable-wp: When set no physical WP line is present. This property should
@@ -56,6 +58,10 @@ Optional properties: · 31 unmodified lines
5658 - fixed-emmc-driver-type: for non-removable eMMC, enforce this driver type.
5759 The value <n> is the driver type as specified in the eMMC specification
5860 (table 206 in spec version 5.1).
61+- post-power-on-delay-ms : It was invented for MMC pwrseq-simple which could
62+ be referred to mmc-pwrseq-simple.txt. But now it's reused as a tunable delay
63+ waiting for I/O signalling and card power supply to be stable, regardless of
64+ whether pwrseq-simple is used. Default to 10ms if no available.
5965
6066 *NOTE* on CD and WP polarity. To use common for all SD/MMC host controllers line
6167 polarity properties, we have to fix the meaning of the "normal" and "inverted"
Documentation/devicetree/bindings/mmc/sdhci-omap.txt+7−0
@@ -4,7 +4,14 @@ Refer to mmc.txt for standard MMC bindings. · 3 unmodified lines
44
55 Required properties:
66 - compatible: Should be "ti,dra7-sdhci" for DRA7 and DRA72 controllers
7+ Should be "ti,k2g-sdhci" for K2G
78 - ti,hwmods: Must be "mmc<n>", <n> is controller instance starting 1
9+ (Not required for K2G).
10+- pinctrl-names: Should be subset of "default", "hs", "sdr12", "sdr25", "sdr50",
11+ "ddr50-rev11", "sdr104-rev11", "ddr50", "sdr104",
12+ "ddr_1_8v-rev11", "ddr_1_8v" or "ddr_3_3v", "hs200_1_8v-rev11",
13+ "hs200_1_8v",
14+- pinctrl-<n> : Pinctrl states as described in bindings/pinctrl/pinctrl-bindings.txt
815
916 Example:
1017 mmc1: mmc@4809c000 {
Documentation/devicetree/bindings/mmc/tmio_mmc.txt+2−0
@@ -26,6 +26,8 @@ Required properties: · 25 unmodified lines
2626 "renesas,sdhi-r8a7794" - SDHI IP on R8A7794 SoC
2727 "renesas,sdhi-r8a7795" - SDHI IP on R8A7795 SoC
2828 "renesas,sdhi-r8a7796" - SDHI IP on R8A7796 SoC
29+ "renesas,sdhi-r8a77965" - SDHI IP on R8A77965 SoC
30+ "renesas,sdhi-r8a77980" - SDHI IP on R8A77980 SoC
2931 "renesas,sdhi-r8a77995" - SDHI IP on R8A77995 SoC
3032 "renesas,sdhi-shmobile" - a generic sh-mobile SDHI controller
3133 "renesas,rcar-gen1-sdhi" - a generic R-Car Gen1 SDHI controller
arch/mips/boot/dts/ingenic/ci20.dts+34−0
@@ -36,6 +36,28 @@ · 35 unmodified lines
3636 clock-frequency = <48000000>;
3737 };
3838
39+&mmc0 {
40+ status = "okay";
41+
42+ bus-width = <4>;
43+ max-frequency = <50000000>;
44+
45+ pinctrl-names = "default";
46+ pinctrl-0 = <&pins_mmc0>;
47+
48+ cd-gpios = <&gpf 20 GPIO_ACTIVE_LOW>;
49+};
50+
51+&mmc1 {
52+ status = "okay";
53+
54+ bus-width = <4>;
55+ max-frequency = <50000000>;
56+
57+ pinctrl-names = "default";
58+ pinctrl-0 = <&pins_mmc1>;
59+};
60+
3961 &uart0 {
4062 status = "okay";
4163
@@ -203,4 +225,16 @@ · 161 unmodified lines
203225 groups = "nemc-cs6";
204226 bias-disable;
205227 };
228+
229+ pins_mmc0: mmc0 {
230+ function = "mmc0";
231+ groups = "mmc0-1bit-e", "mmc0-4bit-e";
232+ bias-disable;
233+ };
234+
235+ pins_mmc1: mmc1 {
236+ function = "mmc1";
237+ groups = "mmc1-1bit-d", "mmc1-4bit-d";
238+ bias-disable;
239+ };
206240 };
arch/mips/boot/dts/ingenic/jz4780.dtsi+52−0
@@ -1,5 +1,6 @@
11 // SPDX-License-Identifier: GPL-2.0
22 #include <dt-bindings/clock/jz4780-cgu.h>
3+#include <dt-bindings/dma/jz4780-dma.h>
34
45 / {
56 #address-cells = <1>;
@@ -241,6 +242,57 @@ · 235 unmodified lines
241242 status = "disabled";
242243 };
243244
245+ dma: dma@13420000 {
246+ compatible = "ingenic,jz4780-dma";
247+ reg = <0x13420000 0x10000>;
248+ #dma-cells = <2>;
249+
250+ interrupt-parent = <&intc>;
251+ interrupts = <10>;
252+
253+ clocks = <&cgu JZ4780_CLK_PDMA>;
254+ };
255+
256+ mmc0: mmc@13450000 {
257+ compatible = "ingenic,jz4780-mmc";
258+ reg = <0x13450000 0x1000>;
259+
260+ interrupt-parent = <&intc>;
261+ interrupts = <37>;
262+
263+ clocks = <&cgu JZ4780_CLK_MSC0>;
264+ clock-names = "mmc";
265+
266+ cap-sd-highspeed;
267+ cap-mmc-highspeed;
268+ cap-sdio-irq;
269+ dmas = <&dma JZ4780_DMA_MSC0_RX 0xffffffff>,
270+ <&dma JZ4780_DMA_MSC0_TX 0xffffffff>;
271+ dma-names = "rx", "tx";
272+
273+ status = "disabled";
274+ };
275+
276+ mmc1: mmc@13460000 {
277+ compatible = "ingenic,jz4780-mmc";
278+ reg = <0x13460000 0x1000>;
279+
280+ interrupt-parent = <&intc>;
281+ interrupts = <36>;
282+
283+ clocks = <&cgu JZ4780_CLK_MSC1>;
284+ clock-names = "mmc";
285+
286+ cap-sd-highspeed;
287+ cap-mmc-highspeed;
288+ cap-sdio-irq;
289+ dmas = <&dma JZ4780_DMA_MSC1_RX 0xffffffff>,
290+ <&dma JZ4780_DMA_MSC1_TX 0xffffffff>;
291+ dma-names = "rx", "tx";
292+
293+ status = "disabled";
294+ };
295+
244296 bch: bch@134d0000 {
245297 compatible = "ingenic,jz4780-bch";
246298 reg = <0x134d0000 0x10000>;
arch/mips/configs/ci20_defconfig+4−0
@@ -104,10 +104,14 @@ CONFIG_REGULATOR_FIXED_VOLTAGE=y · 103 unmodified lines
104104 # CONFIG_HID is not set
105105 # CONFIG_USB_SUPPORT is not set
106106 CONFIG_MMC=y
107+CONFIG_MMC_JZ4740=y
107108 CONFIG_RTC_CLASS=y
108109 CONFIG_RTC_DRV_JZ4740=y
110+CONFIG_DMADEVICES=y
111+CONFIG_DMA_JZ4780=y
109112 # CONFIG_IOMMU_SUPPORT is not set
110113 CONFIG_MEMORY=y
114+CONFIG_EXT4_FS=y
111115 # CONFIG_DNOTIFY is not set
112116 CONFIG_PROC_KCORE=y
113117 # CONFIG_PROC_PAGE_MONITOR is not set
drivers/mmc/core/block.c+7−4
@@ -2351,7 +2351,8 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, · 2350 unmodified lines
23512351 set_disk_ro(md->disk, md->read_only || default_ro);
23522352 md->disk->flags = GENHD_FL_EXT_DEVT;
23532353 if (area_type & (MMC_BLK_DATA_AREA_RPMB | MMC_BLK_DATA_AREA_BOOT))
2354− md->disk->flags |= GENHD_FL_NO_PART_SCAN;
2354+ md->disk->flags |= GENHD_FL_NO_PART_SCAN
2355+ | GENHD_FL_SUPPRESS_PARTITION_INFO;
23552356
23562357 /*
23572358 * As discussed on lkml, GENHD_FL_REMOVABLE should:
@@ -2965,9 +2966,11 @@ static void mmc_blk_remove(struct mmc_card *card) · 607 unmodified lines
29652966 mmc_blk_remove_debugfs(card, md);
29662967 mmc_blk_remove_parts(card, md);
29672968 pm_runtime_get_sync(&card->dev);
2968− mmc_claim_host(card->host);
2969− mmc_blk_part_switch(card, md->part_type);
2970− mmc_release_host(card->host);
2969+ if (md->part_curr != md->part_type) {
2970+ mmc_claim_host(card->host);
2971+ mmc_blk_part_switch(card, md->part_type);
2972+ mmc_release_host(card->host);
2973+ }
29712974 if (card->type != MMC_TYPE_SD_COMBO)
29722975 pm_runtime_disable(&card->dev);
29732976 pm_runtime_put_noidle(&card->dev);
drivers/mmc/core/card.h+6−0
@@ -149,6 +149,12 @@ static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data) · 148 unmodified lines
149149 card->quirks &= ~data;
150150 }
151151
152+static inline void __maybe_unused add_limit_rate_quirk(struct mmc_card *card,
153+ int data)
154+{
155+ card->quirk_max_rate = data;
156+}
157+
152158 /*
153159 * Quirk add/remove for MMC products.
154160 */
drivers/mmc/core/core.c+50−17
@@ -50,9 +50,6 @@ · 49 unmodified lines
5050 #include "sd_ops.h"
5151 #include "sdio_ops.h"
5252
53−/* If the device is not responding */
54−#define MMC_CORE_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */
55−
5653 /* The max erase timeout, used when host->max_busy_timeout isn't specified */
5754 #define MMC_ERASE_TIMEOUT_MS (60 * 1000) /* 60 s */
5855
@@ -1484,6 +1481,17 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage) · 1425 unmodified lines
14841481
14851482 }
14861483
1484+void mmc_set_initial_signal_voltage(struct mmc_host *host)
1485+{
1486+ /* Try to set signal voltage to 3.3V but fall back to 1.8v or 1.2v */
1487+ if (!mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330))
1488+ dev_dbg(mmc_dev(host), "Initial signal voltage of 3.3v\n");
1489+ else if (!mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180))
1490+ dev_dbg(mmc_dev(host), "Initial signal voltage of 1.8v\n");
1491+ else if (!mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120))
1492+ dev_dbg(mmc_dev(host), "Initial signal voltage of 1.2v\n");
1493+}
1494+
14871495 int mmc_host_set_uhs_voltage(struct mmc_host *host)
14881496 {
14891497 u32 clock;
@@ -1646,19 +1654,13 @@ void mmc_power_up(struct mmc_host *host, u32 ocr) · 156 unmodified lines
16461654 /* Set initial state and call mmc_set_ios */
16471655 mmc_set_initial_state(host);
16481656
1649− /* Try to set signal voltage to 3.3V but fall back to 1.8v or 1.2v */
1650− if (!mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330))
1651− dev_dbg(mmc_dev(host), "Initial signal voltage of 3.3v\n");
1652− else if (!mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180))
1653− dev_dbg(mmc_dev(host), "Initial signal voltage of 1.8v\n");
1654− else if (!mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120))
1655− dev_dbg(mmc_dev(host), "Initial signal voltage of 1.2v\n");
1657+ mmc_set_initial_signal_voltage(host);
16561658
16571659 /*
16581660 * This delay should be sufficient to allow the power supply
16591661 * to reach the minimum voltage.
16601662 */
1661− mmc_delay(10);
1663+ mmc_delay(host->ios.power_delay_ms);
16621664
16631665 mmc_pwrseq_post_power_on(host);
16641666
@@ -1671,7 +1673,7 @@ void mmc_power_up(struct mmc_host *host, u32 ocr) · 6 unmodified lines
16711673 * This delay must be at least 74 clock sizes, or 1 ms, or the
16721674 * time required to reach a stable voltage.
16731675 */
1674− mmc_delay(10);
1676+ mmc_delay(host->ios.power_delay_ms);
16751677 }
16761678
16771679 void mmc_power_off(struct mmc_host *host)
@@ -1967,6 +1969,7 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from, · 289 unmodified lines
19671969 unsigned int qty = 0, busy_timeout = 0;
19681970 bool use_r1b_resp = false;
19691971 unsigned long timeout;
1972+ int loop_udelay=64, udelay_max=32768;
19701973 int err;
19711974
19721975 mmc_retune_hold(card->host);
@@ -2091,9 +2094,15 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from, · 118 unmodified lines
20912094 err = -EIO;
20922095 goto out;
20932096 }
2097+ if ((cmd.resp[0] & R1_READY_FOR_DATA) &&
2098+ R1_CURRENT_STATE(cmd.resp[0]) != R1_STATE_PRG)
2099+ break;
2100+
2101+ usleep_range(loop_udelay, loop_udelay*2);
2102+ if (loop_udelay < udelay_max)
2103+ loop_udelay *= 2;
2104+ } while (1);
20942105
2095− } while (!(cmd.resp[0] & R1_READY_FOR_DATA) ||
2096− (R1_CURRENT_STATE(cmd.resp[0]) == R1_STATE_PRG));
20972106 out:
20982107 mmc_retune_release(card->host);
20992108 return err;
@@ -2435,22 +2444,46 @@ int mmc_hw_reset(struct mmc_host *host) · 335 unmodified lines
24352444 return -EINVAL;
24362445
24372446 mmc_bus_get(host);
2438− if (!host->bus_ops || host->bus_dead || !host->bus_ops->reset) {
2447+ if (!host->bus_ops || host->bus_dead || !host->bus_ops->hw_reset) {
24392448 mmc_bus_put(host);
24402449 return -EOPNOTSUPP;
24412450 }
24422451
2443− ret = host->bus_ops->reset(host);
2452+ ret = host->bus_ops->hw_reset(host);
24442453 mmc_bus_put(host);
24452454
24462455 if (ret)
2447− pr_warn("%s: tried to reset card, got error %d\n",
2456+ pr_warn("%s: tried to HW reset card, got error %d\n",
24482457 mmc_hostname(host), ret);
24492458
24502459 return ret;
24512460 }
24522461 EXPORT_SYMBOL(mmc_hw_reset);
24532462
2463+int mmc_sw_reset(struct mmc_host *host)
2464+{
2465+ int ret;
2466+
2467+ if (!host->card)
2468+ return -EINVAL;
2469+
2470+ mmc_bus_get(host);
2471+ if (!host->bus_ops || host->bus_dead || !host->bus_ops->sw_reset) {
2472+ mmc_bus_put(host);
2473+ return -EOPNOTSUPP;
2474+ }
2475+
2476+ ret = host->bus_ops->sw_reset(host);
2477+ mmc_bus_put(host);
2478+
2479+ if (ret)
2480+ pr_warn("%s: tried to SW reset card, got error %d\n",
2481+ mmc_hostname(host), ret);
2482+
2483+ return ret;
2484+}
2485+EXPORT_SYMBOL(mmc_sw_reset);
2486+
24542487 static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
24552488 {
24562489 host->f_init = freq;
drivers/mmc/core/core.h+3−1
@@ -32,7 +32,8 @@ struct mmc_bus_ops { · 31 unmodified lines
3232 int (*power_restore)(struct mmc_host *);
3333 int (*alive)(struct mmc_host *);
3434 int (*shutdown)(struct mmc_host *);
35− int (*reset)(struct mmc_host *);
35+ int (*hw_reset)(struct mmc_host *);
36+ int (*sw_reset)(struct mmc_host *);
3637 };
3738
3839 void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops);
@@ -51,6 +52,7 @@ u32 mmc_select_voltage(struct mmc_host *host, u32 ocr); · 12 unmodified lines
5152 int mmc_set_uhs_voltage(struct mmc_host *host, u32 ocr);
5253 int mmc_host_set_uhs_voltage(struct mmc_host *host);
5354 int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage);
55+void mmc_set_initial_signal_voltage(struct mmc_host *host);
5456 void mmc_set_timing(struct mmc_host *host, unsigned int timing);
5557 void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type);
5658 int mmc_select_drive_strength(struct mmc_card *card, unsigned int max_dtr,
drivers/mmc/core/host.c+11−5
@@ -143,9 +143,6 @@ int mmc_retune(struct mmc_host *host) · 142 unmodified lines
143143 goto out;
144144
145145 return_to_hs400 = true;
146−
147− if (host->ops->prepare_hs400_tuning)
148− host->ops->prepare_hs400_tuning(host, &host->ios);
149146 }
150147
151148 err = mmc_execute_tuning(host->card);
@@ -179,7 +176,7 @@ static void mmc_retune_timer(struct timer_list *t) · 27 unmodified lines
179176 int mmc_of_parse(struct mmc_host *host)
180177 {
181178 struct device *dev = host->parent;
182− u32 bus_width, drv_type;
179+ u32 bus_width, drv_type, cd_debounce_delay_ms;
183180 int ret;
184181 bool cd_cap_invert, cd_gpio_invert = false;
185182 bool ro_cap_invert, ro_gpio_invert = false;
@@ -230,11 +227,16 @@ int mmc_of_parse(struct mmc_host *host) · 44 unmodified lines
230227 } else {
231228 cd_cap_invert = device_property_read_bool(dev, "cd-inverted");
232229
230+ if (device_property_read_u32(dev, "cd-debounce-delay-ms",
231+ &cd_debounce_delay_ms))
232+ cd_debounce_delay_ms = 200;
233+
233234 if (device_property_read_bool(dev, "broken-cd"))
234235 host->caps |= MMC_CAP_NEEDS_POLL;
235236
236237 ret = mmc_gpiod_request_cd(host, "cd", 0, true,
237− 0, &cd_gpio_invert);
238+ cd_debounce_delay_ms,
239+ &cd_gpio_invert);
238240 if (!ret)
239241 dev_info(host->parent, "Got CD GPIO\n");
240242 else if (ret != -ENOENT && ret != -ENOSYS)
@@ -338,6 +340,9 @@ int mmc_of_parse(struct mmc_host *host) · 97 unmodified lines
338340 host->dsr_req = 0;
339341 }
340342
343+ device_property_read_u32(dev, "post-power-on-delay-ms",
344+ &host->ios.power_delay_ms);
345+
341346 return mmc_pwrseq_alloc(host);
342347 }
343348
@@ -403,6 +408,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) · 59 unmodified lines
403408 host->max_blk_count = PAGE_SIZE / 512;
404409
405410 host->fixed_drv_type = -EINVAL;
411+ host->ios.power_delay_ms = 10;
406412
407413 return host;
408414 }
drivers/mmc/core/mmc.c+14−2
@@ -1282,6 +1282,10 @@ int mmc_hs400_to_hs200(struct mmc_card *card) · 1281 unmodified lines
12821282
12831283 mmc_set_bus_speed(card);
12841284
1285+ /* Prepare tuning for HS400 mode. */
1286+ if (host->ops->prepare_hs400_tuning)
1287+ host->ops->prepare_hs400_tuning(host, &host->ios);
1288+
12851289 return 0;
12861290
12871291 out_err:
@@ -1830,6 +1834,14 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, · 542 unmodified lines
18301834 }
18311835 }
18321836
1837+ if (host->caps2 & MMC_CAP2_AVOID_3_3V &&
1838+ host->ios.signal_voltage == MMC_SIGNAL_VOLTAGE_330) {
1839+ pr_err("%s: Host failed to negotiate down from 3.3V\n",
1840+ mmc_hostname(host));
1841+ err = -EINVAL;
1842+ goto free_card;
1843+ }
1844+
18331845 if (!oldcard)
18341846 host->card = card;
18351847
@@ -2117,7 +2129,7 @@ static int mmc_can_reset(struct mmc_card *card) · 281 unmodified lines
21172129 return 1;
21182130 }
21192131
2120−static int mmc_reset(struct mmc_host *host)
2132+static int _mmc_hw_reset(struct mmc_host *host)
21212133 {
21222134 struct mmc_card *card = host->card;
21232135
@@ -2151,7 +2163,7 @@ static const struct mmc_bus_ops mmc_ops = { · 27 unmodified lines
21512163 .runtime_resume = mmc_runtime_resume,
21522164 .alive = mmc_alive,
21532165 .shutdown = mmc_shutdown,
2154− .reset = mmc_reset,
2166+ .hw_reset = _mmc_hw_reset,
21552167 };
21562168
21572169 /*
drivers/mmc/core/pwrseq_simple.c+9−5
@@ -40,14 +40,18 @@ static void mmc_pwrseq_simple_set_gpios_value(struct mmc_pwrseq_simple *pwrseq, · 39 unmodified lines
4040 struct gpio_descs *reset_gpios = pwrseq->reset_gpios;
4141
4242 if (!IS_ERR(reset_gpios)) {
43− int i;
44− int values[reset_gpios->ndescs];
43+ int i, *values;
44+ int nvalues = reset_gpios->ndescs;
4545
46− for (i = 0; i < reset_gpios->ndescs; i++)
46+ values = kmalloc_array(nvalues, sizeof(int), GFP_KERNEL);
47+ if (!values)
48+ return;
49+
50+ for (i = 0; i < nvalues; i++)
4751 values[i] = value;
4852
49− gpiod_set_array_value_cansleep(
50− reset_gpios->ndescs, reset_gpios->desc, values);
53+ gpiod_set_array_value_cansleep(nvalues, reset_gpios->desc, values);
54+ kfree(values);
5155 }
5256 }
5357
drivers/mmc/core/quirks.h+3−0
@@ -132,6 +132,9 @@ static const struct mmc_fixup sdio_fixup_methods[] = { · 131 unmodified lines
132132 SDIO_FIXUP(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8797_F0,
133133 add_quirk, MMC_QUIRK_BROKEN_IRQ_POLLING),
134134
135+ SDIO_FIXUP(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8887WLAN,
136+ add_limit_rate_quirk, 150000000),
137+
135138 END_FIXUP
136139 };
137140
drivers/mmc/core/sd.c+10−2
@@ -1058,6 +1058,14 @@ retry: · 1057 unmodified lines
10581058 mmc_set_bus_width(host, MMC_BUS_WIDTH_4);
10591059 }
10601060 }
1061+
1062+ if (host->caps2 & MMC_CAP2_AVOID_3_3V &&
1063+ host->ios.signal_voltage == MMC_SIGNAL_VOLTAGE_330) {
1064+ pr_err("%s: Host failed to negotiate down from 3.3V\n",
1065+ mmc_hostname(host));
1066+ err = -EINVAL;
1067+ goto free_card;
1068+ }
10611069 done:
10621070 host->card = card;
10631071 return 0;
@@ -1214,7 +1222,7 @@ static int mmc_sd_runtime_resume(struct mmc_host *host) · 150 unmodified lines
12141222 return 0;
12151223 }
12161224
1217−static int mmc_sd_reset(struct mmc_host *host)
1225+static int mmc_sd_hw_reset(struct mmc_host *host)
12181226 {
12191227 mmc_power_cycle(host, host->card->ocr);
12201228 return mmc_sd_init_card(host, host->card->ocr, host->card);
@@ -1229,7 +1237,7 @@ static const struct mmc_bus_ops mmc_sd_ops = { · 8 unmodified lines
12291237 .resume = mmc_sd_resume,
12301238 .alive = mmc_sd_alive,
12311239 .shutdown = mmc_sd_suspend,
1232− .reset = mmc_sd_reset,
1240+ .hw_reset = mmc_sd_hw_reset,
12331241 };
12341242
12351243 /*
drivers/mmc/core/sdio.c+47−23
@@ -444,6 +444,7 @@ static int sdio_set_bus_speed_mode(struct mmc_card *card) · 443 unmodified lines
444444 unsigned int bus_speed, timing;
445445 int err;
446446 unsigned char speed;
447+ unsigned int max_rate;
447448
448449 /*
449450 * If the host doesn't support any of the UHS-I modes, fallback on
@@ -500,9 +501,12 @@ static int sdio_set_bus_speed_mode(struct mmc_card *card) · 50 unmodified lines
500501 if (err)
501502 return err;
502503
504+ max_rate = min_not_zero(card->quirk_max_rate,
505+ card->sw_caps.uhs_max_dtr);
506+
503507 if (bus_speed) {
504508 mmc_set_timing(card->host, timing);
505− mmc_set_clock(card->host, card->sw_caps.uhs_max_dtr);
509+ mmc_set_clock(card->host, max_rate);
506510 }
507511
508512 return 0;
@@ -788,6 +792,14 @@ try_again: · 279 unmodified lines
788792 if (err)
789793 goto remove;
790794 }
795+
796+ if (host->caps2 & MMC_CAP2_AVOID_3_3V &&
797+ host->ios.signal_voltage == MMC_SIGNAL_VOLTAGE_330) {
798+ pr_err("%s: Host failed to negotiate down from 3.3V\n",
799+ mmc_hostname(host));
800+ err = -EINVAL;
801+ goto remove;
802+ }
791803 finish:
792804 if (!oldcard)
793805 host->card = card;
@@ -801,6 +813,22 @@ err: · 7 unmodified lines
801813 return err;
802814 }
803815
816+static int mmc_sdio_reinit_card(struct mmc_host *host, bool powered_resume)
817+{
818+ int ret;
819+
820+ sdio_reset(host);
821+ mmc_go_idle(host);
822+ mmc_send_if_cond(host, host->card->ocr);
823+
824+ ret = mmc_send_io_op_cond(host, 0, NULL);
825+ if (ret)
826+ return ret;
827+
828+ return mmc_sdio_init_card(host, host->card->ocr, host->card,
829+ powered_resume);
830+}
831+
804832 /*
805833 * Host is being removed. Free up the current card.
806834 */
@@ -948,14 +976,7 @@ static int mmc_sdio_resume(struct mmc_host *host) · 141 unmodified lines
948976
949977 /* No need to reinitialize powered-resumed nonremovable cards */
950978 if (mmc_card_is_removable(host) || !mmc_card_keep_power(host)) {
951− sdio_reset(host);
952− mmc_go_idle(host);
953− mmc_send_if_cond(host, host->card->ocr);
954− err = mmc_send_io_op_cond(host, 0, NULL);
955− if (!err)
956− err = mmc_sdio_init_card(host, host->card->ocr,
957− host->card,
958− mmc_card_keep_power(host));
979+ err = mmc_sdio_reinit_card(host, mmc_card_keep_power(host));
959980 } else if (mmc_card_keep_power(host) && mmc_card_wake_sdio_irq(host)) {
960981 /* We may have switched to 1-bit mode during suspend */
961982 err = sdio_enable_4bit_bus(host->card);
@@ -978,8 +999,6 @@ static int mmc_sdio_power_restore(struct mmc_host *host) · 16 unmodified lines
978999 {
9791000 int ret;
9801001
981− mmc_claim_host(host);
982−
9831002 /*
9841003 * Reset the card by performing the same steps that are taken by
9851004 * mmc_rescan_try_freq() and mmc_attach_sdio() during a "normal" probe.
@@ -997,20 +1016,12 @@ static int mmc_sdio_power_restore(struct mmc_host *host) · 11 unmodified lines
9971016 *
9981017 */
9991018
1000− sdio_reset(host);
1001− mmc_go_idle(host);
1002− mmc_send_if_cond(host, host->card->ocr);
1003−
1004− ret = mmc_send_io_op_cond(host, 0, NULL);
1005− if (ret)
1006− goto out;
1019+ mmc_claim_host(host);
10071020
1008− ret = mmc_sdio_init_card(host, host->card->ocr, host->card,
1009− mmc_card_keep_power(host));
1021+ ret = mmc_sdio_reinit_card(host, mmc_card_keep_power(host));
10101022 if (!ret && host->sdio_irqs)
10111023 mmc_signal_sdio_irq(host);
10121024
1013−out:
10141025 mmc_release_host(host);
10151026
10161027 return ret;
@@ -1039,12 +1050,24 @@ static int mmc_sdio_runtime_resume(struct mmc_host *host) · 22 unmodified lines
10391050 return ret;
10401051 }
10411052
1042−static int mmc_sdio_reset(struct mmc_host *host)
1053+static int mmc_sdio_hw_reset(struct mmc_host *host)
10431054 {
10441055 mmc_power_cycle(host, host->card->ocr);
10451056 return mmc_sdio_power_restore(host);
10461057 }
10471058
1059+static int mmc_sdio_sw_reset(struct mmc_host *host)
1060+{
1061+ mmc_set_clock(host, host->f_init);
1062+ sdio_reset(host);
1063+ mmc_go_idle(host);
1064+
1065+ mmc_set_initial_state(host);
1066+ mmc_set_initial_signal_voltage(host);
1067+
1068+ return mmc_sdio_reinit_card(host, 0);
1069+}
1070+
10481071 static const struct mmc_bus_ops mmc_sdio_ops = {
10491072 .remove = mmc_sdio_remove,
10501073 .detect = mmc_sdio_detect,
@@ -1055,7 +1078,8 @@ static const struct mmc_bus_ops mmc_sdio_ops = { · 4 unmodified lines
10551078 .runtime_resume = mmc_sdio_runtime_resume,
10561079 .power_restore = mmc_sdio_power_restore,
10571080 .alive = mmc_sdio_alive,
1058− .reset = mmc_sdio_reset,
1081+ .hw_reset = mmc_sdio_hw_reset,
1082+ .sw_reset = mmc_sdio_sw_reset,
10591083 };
10601084
10611085
drivers/mmc/core/slot-gpio.c+16−6
@@ -28,15 +28,17 @@ struct mmc_gpio { · 27 unmodified lines
2828 irqreturn_t (*cd_gpio_isr)(int irq, void *dev_id);
2929 char *ro_label;
3030 char cd_label[0];
31+ u32 cd_debounce_delay_ms;
3132 };
3233
3334 static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id)
3435 {
3536 /* Schedule a card detection after a debounce timeout */
3637 struct mmc_host *host = dev_id;
38+ struct mmc_gpio *ctx = host->slot.handler_priv;
3739
3840 host->trigger_card_event = true;
39− mmc_detect_change(host, msecs_to_jiffies(200));
41+ mmc_detect_change(host, msecs_to_jiffies(ctx->cd_debounce_delay_ms));
4042
4143 return IRQ_HANDLED;
4244 }
@@ -49,6 +51,7 @@ int mmc_gpio_alloc(struct mmc_host *host) · 6 unmodified lines
4951
5052 if (ctx) {
5153 ctx->ro_label = ctx->cd_label + len;
54+ ctx->cd_debounce_delay_ms = 200;
5255 snprintf(ctx->cd_label, len, "%s cd", dev_name(host->parent));
5356 snprintf(ctx->ro_label, len, "%s ro", dev_name(host->parent));
5457 host->slot.handler_priv = ctx;
@@ -76,15 +79,22 @@ EXPORT_SYMBOL(mmc_gpio_get_ro); · 21 unmodified lines
7679 int mmc_gpio_get_cd(struct mmc_host *host)
7780 {
7881 struct mmc_gpio *ctx = host->slot.handler_priv;
82+ int cansleep;
7983
8084 if (!ctx || !ctx->cd_gpio)
8185 return -ENOSYS;
8286
83− if (ctx->override_cd_active_level)
84− return !gpiod_get_raw_value_cansleep(ctx->cd_gpio) ^
85− !!(host->caps2 & MMC_CAP2_CD_ACTIVE_HIGH);
87+ cansleep = gpiod_cansleep(ctx->cd_gpio);
88+ if (ctx->override_cd_active_level) {
89+ int value = cansleep ?
90+ gpiod_get_raw_value_cansleep(ctx->cd_gpio) :
91+ gpiod_get_raw_value(ctx->cd_gpio);
92+ return !value ^ !!(host->caps2 & MMC_CAP2_CD_ACTIVE_HIGH);
93+ }
8694
87− return gpiod_get_value_cansleep(ctx->cd_gpio);
95+ return cansleep ?
96+ gpiod_get_value_cansleep(ctx->cd_gpio) :
97+ gpiod_get_value(ctx->cd_gpio);
8898 }
8999 EXPORT_SYMBOL(mmc_gpio_get_cd);
90100
@@ -261,7 +271,7 @@ int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id, · 170 unmodified lines
261271 if (debounce) {
262272 ret = gpiod_set_debounce(desc, debounce);
263273 if (ret < 0)
264− return ret;
274+ ctx->cd_debounce_delay_ms = debounce;
265275 }
266276
267277 if (gpio_invert)
drivers/mmc/host/Kconfig+18−14
@@ -345,11 +345,11 @@ config MMC_SDHCI_IPROC · 344 unmodified lines
345345 If unsure, say N.
346346
347347 config MMC_MESON_GX
348− tristate "Amlogic S905/GX* SD/MMC Host Controller support"
348+ tristate "Amlogic S905/GX*/AXG SD/MMC Host Controller support"
349349 depends on ARCH_MESON && MMC
350350 help
351351 This selects support for the Amlogic SD/MMC Host Controller
352− found on the S905/GX* family of SoCs. This controller is
352+ found on the S905/GX*/AXG family of SoCs. This controller is
353353 MMC 5.1 compliant and supports SD, eMMC and SDIO interfaces.
354354
355355 If you have a controller with this interface, say Y here.
@@ -358,7 +358,6 @@ config MMC_MESON_MX_SDIO · 2 unmodified lines
358358 tristate "Amlogic Meson6/Meson8/Meson8b SD/MMC Host Controller support"
359359 depends on ARCH_MESON || COMPILE_TEST
360360 depends on COMMON_CLK
361− depends on HAS_DMA
362361 depends on OF
363362 help
364363 This selects support for the SD/MMC Host Controller on
@@ -401,7 +400,6 @@ config MMC_OMAP · 36 unmodified lines
401400
402401 config MMC_OMAP_HS
403402 tristate "TI OMAP High Speed Multimedia Card Interface support"
404− depends on HAS_DMA
405403 depends on ARCH_OMAP2PLUS || ARCH_KEYSTONE || COMPILE_TEST
406404 help
407405 This selects the TI OMAP High Speed Multimedia card Interface.
@@ -511,7 +509,6 @@ config MMC_DAVINCI · 103 unmodified lines
511509
512510 config MMC_GOLDFISH
513511 tristate "goldfish qemu Multimedia Card Interface support"
514− depends on HAS_DMA
515512 depends on GOLDFISH || COMPILE_TEST
516513 help
517514 This selects the Goldfish Multimedia card Interface emulation
@@ -605,7 +602,7 @@ config MMC_SDHI · 87 unmodified lines
605602
606603 config MMC_SDHI_SYS_DMAC
607604 tristate "DMA for SDHI SD/SDIO controllers using SYS-DMAC"
608− depends on MMC_SDHI && HAS_DMA
605+ depends on MMC_SDHI
609606 default MMC_SDHI if (SUPERH || ARM)
610607 help
611608 This provides DMA support for SDHI SD/SDIO controllers
@@ -615,7 +612,7 @@ config MMC_SDHI_SYS_DMAC · 3 unmodified lines
615612 config MMC_SDHI_INTERNAL_DMAC
616613 tristate "DMA for SDHI SD/SDIO controllers using on-chip bus mastering"
617614 depends on ARM64 || COMPILE_TEST
618− depends on MMC_SDHI && HAS_DMA
615+ depends on MMC_SDHI
619616 default MMC_SDHI if ARM64
620617 help
621618 This provides DMA support for SDHI SD/SDIO controllers
@@ -669,7 +666,6 @@ config MMC_CAVIUM_THUNDERX · 47 unmodified lines
669666
670667 config MMC_DW
671668 tristate "Synopsys DesignWare Memory Card Interface"
672− depends on HAS_DMA
673669 depends on ARC || ARM || ARM64 || MIPS || COMPILE_TEST
674670 help
675671 This selects support for the Synopsys DesignWare Mobile Storage IP
@@ -690,6 +686,15 @@ config MMC_DW_PLTFM · 14 unmodified lines
690686
691687 If unsure, say Y.
692688
689+config MMC_DW_BLUEFIELD
690+ tristate "BlueField specific extensions for Synopsys DW Memory Card Interface"
691+ depends on MMC_DW
692+ select MMC_DW_PLTFM
693+ help
694+ This selects support for Mellanox BlueField SoC specific extensions to
695+ the Synopsys DesignWare Memory Card Interface driver. Select this
696+ option for platforms based on Mellanox BlueField SoC's.
697+
693698 config MMC_DW_EXYNOS
694699 tristate "Exynos specific extensions for Synopsys DW Memory Card Interface"
695700 depends on MMC_DW
@@ -748,7 +753,6 @@ config MMC_DW_ZX · 52 unmodified lines
748753
749754 config MMC_SH_MMCIF
750755 tristate "SuperH Internal MMCIF support"
751− depends on HAS_DMA
752756 depends on SUPERH || ARCH_RENESAS || COMPILE_TEST
753757 help
754758 This selects the MMC Host Interface controller (MMCIF) found in various
@@ -756,11 +760,12 @@ config MMC_SH_MMCIF · 1 unmodified line
756760
757761
758762 config MMC_JZ4740
759− tristate "JZ4740 SD/Multimedia Card Interface support"
760− depends on MACH_JZ4740
763+ tristate "Ingenic JZ47xx SD/Multimedia Card Interface support"
764+ depends on MACH_JZ4740 || MACH_JZ4780
761765 help
762− This selects support for the SD/MMC controller on Ingenic JZ4740
763− SoCs.
766+ This selects support for the SD/MMC controller on Ingenic
767+ JZ4740, JZ4750, JZ4770 and JZ4780 SoCs.
768+
764769 If you have a board based on such a SoC and with a SD/MMC slot,
765770 say Y or M here.
766771
@@ -868,7 +873,6 @@ config MMC_TOSHIBA_PCI · 101 unmodified lines
868873 config MMC_BCM2835
869874 tristate "Broadcom BCM2835 SDHOST MMC Controller support"
870875 depends on ARCH_BCM2835 || COMPILE_TEST
871− depends on HAS_DMA
872876 help
873877 This selects the BCM2835 SDHOST MMC controller. If you have
874878 a BCM2835 platform with SD or MMC devices, say Y or M here.
drivers/mmc/host/Makefile+1−0
@@ -49,6 +49,7 @@ thunderx-mmc-objs := cavium.o cavium-thunderx.o · 48 unmodified lines
4949 obj-$(CONFIG_MMC_CAVIUM_THUNDERX) += thunderx-mmc.o
5050 obj-$(CONFIG_MMC_DW) += dw_mmc.o
5151 obj-$(CONFIG_MMC_DW_PLTFM) += dw_mmc-pltfm.o
52+obj-$(CONFIG_MMC_DW_BLUEFIELD) += dw_mmc-bluefield.o
5253 obj-$(CONFIG_MMC_DW_EXYNOS) += dw_mmc-exynos.o
5354 obj-$(CONFIG_MMC_DW_HI3798CV200) += dw_mmc-hi3798cv200.o
5455 obj-$(CONFIG_MMC_DW_K3) += dw_mmc-k3.o
drivers/mmc/host/android-goldfish.c+4−4
@@ -217,8 +217,8 @@ static void goldfish_mmc_xfer_done(struct goldfish_mmc_host *host, · 216 unmodified lines
217217 * We don't really have DMA, so we need
218218 * to copy from our platform driver buffer
219219 */
220− uint8_t *dest = (uint8_t *)sg_virt(data->sg);
221− memcpy(dest, host->virt_base, data->sg->length);
220+ sg_copy_to_buffer(data->sg, 1, host->virt_base,
221+ data->sg->length);
222222 }
223223 host->data->bytes_xfered += data->sg->length;
224224 dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->sg_len,
@@ -393,8 +393,8 @@ static void goldfish_mmc_prepare_data(struct goldfish_mmc_host *host, · 168 unmodified lines
393393 * We don't really have DMA, so we need to copy to our
394394 * platform driver buffer
395395 */
396− const uint8_t *src = (uint8_t *)sg_virt(data->sg);
397− memcpy(host->virt_base, src, data->sg->length);
396+ sg_copy_from_buffer(data->sg, 1, host->virt_base,
397+ data->sg->length);
398398 }
399399 }
400400
drivers/mmc/host/atmel-mci.c+9−12
@@ -1967,7 +1967,6 @@ static void atmci_tasklet_func(unsigned long priv) · 1966 unmodified lines
19671967 static void atmci_read_data_pio(struct atmel_mci *host)
19681968 {
19691969 struct scatterlist *sg = host->sg;
1970− void *buf = sg_virt(sg);
19711970 unsigned int offset = host->pio_offset;
19721971 struct mmc_data *data = host->data;
19731972 u32 value;
@@ -1977,7 +1976,7 @@ static void atmci_read_data_pio(struct atmel_mci *host) · 3 unmodified lines
19771976 do {
19781977 value = atmci_readl(host, ATMCI_RDR);
19791978 if (likely(offset + 4 <= sg->length)) {
1980− put_unaligned(value, (u32 *)(buf + offset));
1979+ sg_pcopy_to_buffer(sg, 1, &value, sizeof(u32), offset);
19811980
19821981 offset += 4;
19831982 nbytes += 4;
@@ -1990,11 +1989,11 @@ static void atmci_read_data_pio(struct atmel_mci *host) · 6 unmodified lines
19901989 goto done;
19911990
19921991 offset = 0;
1993− buf = sg_virt(sg);
19941992 }
19951993 } else {
19961994 unsigned int remaining = sg->length - offset;
1997− memcpy(buf + offset, &value, remaining);
1995+
1996+ sg_pcopy_to_buffer(sg, 1, &value, remaining, offset);
19981997 nbytes += remaining;
19991998
20001999 flush_dcache_page(sg_page(sg));
@@ -2004,8 +2003,8 @@ static void atmci_read_data_pio(struct atmel_mci *host) · 3 unmodified lines
20042003 goto done;
20052004
20062005 offset = 4 - remaining;
2007− buf = sg_virt(sg);
2008− memcpy(buf, (u8 *)&value + remaining, offset);
2006+ sg_pcopy_to_buffer(sg, 1, (u8 *)&value + remaining,
2007+ offset, 0);
20092008 nbytes += offset;
20102009 }
20112010
@@ -2035,7 +2034,6 @@ done: · 23 unmodified lines
20352034 static void atmci_write_data_pio(struct atmel_mci *host)
20362035 {
20372036 struct scatterlist *sg = host->sg;
2038− void *buf = sg_virt(sg);
20392037 unsigned int offset = host->pio_offset;
20402038 struct mmc_data *data = host->data;
20412039 u32 value;
@@ -2044,7 +2042,7 @@ static void atmci_write_data_pio(struct atmel_mci *host) · 2 unmodified lines
20442042
20452043 do {
20462044 if (likely(offset + 4 <= sg->length)) {
2047− value = get_unaligned((u32 *)(buf + offset));
2045+ sg_pcopy_from_buffer(sg, 1, &value, sizeof(u32), offset);
20482046 atmci_writel(host, ATMCI_TDR, value);
20492047
20502048 offset += 4;
@@ -2056,13 +2054,12 @@ static void atmci_write_data_pio(struct atmel_mci *host) · 5 unmodified lines
20562054 goto done;
20572055
20582056 offset = 0;
2059− buf = sg_virt(sg);
20602057 }
20612058 } else {
20622059 unsigned int remaining = sg->length - offset;
20632060
20642061 value = 0;
2065− memcpy(&value, buf + offset, remaining);
2062+ sg_pcopy_from_buffer(sg, 1, &value, remaining, offset);
20662063 nbytes += remaining;
20672064
20682065 host->sg = sg = sg_next(sg);
@@ -2073,8 +2070,8 @@ static void atmci_write_data_pio(struct atmel_mci *host) · 4 unmodified lines
20732070 }
20742071
20752072 offset = 4 - remaining;
2076− buf = sg_virt(sg);
2077− memcpy((u8 *)&value + remaining, buf, offset);
2073+ sg_pcopy_from_buffer(sg, 1, (u8 *)&value + remaining,
2074+ offset, 0);
20782075 atmci_writel(host, ATMCI_TDR, value);
20792076 nbytes += offset;
20802077 }
drivers/mmc/host/au1xmmc.c+8−4
@@ -40,6 +40,7 @@ · 39 unmodified lines
4040 #include <linux/interrupt.h>
4141 #include <linux/dma-mapping.h>
4242 #include <linux/scatterlist.h>
43+#include <linux/highmem.h>
4344 #include <linux/leds.h>
4445 #include <linux/mmc/host.h>
4546 #include <linux/slab.h>
@@ -405,7 +406,7 @@ static void au1xmmc_send_pio(struct au1xmmc_host *host) · 359 unmodified lines
405406
406407 /* This is the pointer to the data buffer */
407408 sg = &data->sg[host->pio.index];
408− sg_ptr = sg_virt(sg) + host->pio.offset;
409+ sg_ptr = kmap_atomic(sg_page(sg)) + sg->offset + host->pio.offset;
409410
410411 /* This is the space left inside the buffer */
411412 sg_len = data->sg[host->pio.index].length - host->pio.offset;
@@ -421,11 +422,12 @@ static void au1xmmc_send_pio(struct au1xmmc_host *host) · 9 unmodified lines
421422 if (!(status & SD_STATUS_TH))
422423 break;
423424
424− val = *sg_ptr++;
425+ val = sg_ptr[count];
425426
426427 __raw_writel((unsigned long)val, HOST_TXPORT(host));
427428 wmb(); /* drain writebuffer */
428429 }
430+ kunmap_atomic(sg_ptr);
429431
430432 host->pio.len -= count;
431433 host->pio.offset += count;
@@ -462,7 +464,7 @@ static void au1xmmc_receive_pio(struct au1xmmc_host *host) · 30 unmodified lines
462464
463465 if (host->pio.index < host->dma.len) {
464466 sg = &data->sg[host->pio.index];
465− sg_ptr = sg_virt(sg) + host->pio.offset;
467+ sg_ptr = kmap_atomic(sg_page(sg)) + sg->offset + host->pio.offset;
466468
467469 /* This is the space left inside the buffer */
468470 sg_len = sg_dma_len(&data->sg[host->pio.index]) - host->pio.offset;
@@ -501,8 +503,10 @@ static void au1xmmc_receive_pio(struct au1xmmc_host *host) · 32 unmodified lines
501503 val = __raw_readl(HOST_RXPORT(host));
502504
503505 if (sg_ptr)
504− *sg_ptr++ = (unsigned char)(val & 0xFF);
506+ sg_ptr[count] = (unsigned char)(val & 0xFF);
505507 }
508+ if (sg_ptr)
509+ kunmap_atomic(sg_ptr);
506510
507511 host->pio.len -= count;
508512 host->pio.offset += count;
drivers/mmc/host/davinci_mmc.c+2−4
@@ -1377,8 +1377,7 @@ static int __exit davinci_mmcsd_remove(struct platform_device *pdev) · 1376 unmodified lines
13771377 #ifdef CONFIG_PM
13781378 static int davinci_mmcsd_suspend(struct device *dev)
13791379 {
1380− struct platform_device *pdev = to_platform_device(dev);
1381− struct mmc_davinci_host *host = platform_get_drvdata(pdev);
1380+ struct mmc_davinci_host *host = dev_get_drvdata(dev);
13821381
13831382 writel(0, host->base + DAVINCI_MMCIM);
13841383 mmc_davinci_reset_ctrl(host, 1);
@@ -1389,8 +1388,7 @@ static int davinci_mmcsd_suspend(struct device *dev) · 4 unmodified lines
13891388
13901389 static int davinci_mmcsd_resume(struct device *dev)
13911390 {
1392− struct platform_device *pdev = to_platform_device(dev);
1393− struct mmc_davinci_host *host = platform_get_drvdata(pdev);
1391+ struct mmc_davinci_host *host = dev_get_drvdata(dev);
13941392
13951393 clk_enable(host->clk);
13961394 mmc_davinci_reset_ctrl(host, 0);
drivers/mmc/host/dw_mmc-bluefield.c+81−0
@@ -0,0 +1,81 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Copyright (C) 2018 Mellanox Technologies.
4+ *
5+ * This program is free software; you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License as published by
7+ * the Free Software Foundation; either version 2 of the License, or
8+ * (at your option) any later version.
9+ */
10+
11+#include <linux/bitfield.h>
12+#include <linux/bitops.h>
13+#include <linux/mmc/host.h>
14+#include <linux/mmc/mmc.h>
15+#include <linux/module.h>
16+#include <linux/of.h>
17+#include <linux/platform_device.h>
18+#include <linux/pm_runtime.h>
19+
20+#include "dw_mmc.h"
21+#include "dw_mmc-pltfm.h"
22+
23+#define UHS_REG_EXT_SAMPLE_MASK GENMASK(22, 16)
24+#define UHS_REG_EXT_DRIVE_MASK GENMASK(29, 23)
25+#define BLUEFIELD_UHS_REG_EXT_SAMPLE 2
26+#define BLUEFIELD_UHS_REG_EXT_DRIVE 4
27+
28+static void dw_mci_bluefield_set_ios(struct dw_mci *host, struct mmc_ios *ios)
29+{
30+ u32 reg;
31+
32+ /* Update the Drive and Sample fields in register UHS_REG_EXT. */
33+ reg = mci_readl(host, UHS_REG_EXT);
34+ reg &= ~UHS_REG_EXT_SAMPLE_MASK;
35+ reg |= FIELD_PREP(UHS_REG_EXT_SAMPLE_MASK,
36+ BLUEFIELD_UHS_REG_EXT_SAMPLE);
37+ reg &= ~UHS_REG_EXT_DRIVE_MASK;
38+ reg |= FIELD_PREP(UHS_REG_EXT_DRIVE_MASK, BLUEFIELD_UHS_REG_EXT_DRIVE);
39+ mci_writel(host, UHS_REG_EXT, reg);
40+}
41+
42+static const struct dw_mci_drv_data bluefield_drv_data = {
43+ .set_ios = dw_mci_bluefield_set_ios
44+};
45+
46+static const struct of_device_id dw_mci_bluefield_match[] = {
47+ { .compatible = "mellanox,bluefield-dw-mshc",
48+ .data = &bluefield_drv_data },
49+ {},
50+};
51+MODULE_DEVICE_TABLE(of, dw_mci_bluefield_match);
52+
53+static int dw_mci_bluefield_probe(struct platform_device *pdev)
54+{
55+ const struct dw_mci_drv_data *drv_data = NULL;
56+ const struct of_device_id *match;
57+
58+ if (pdev->dev.of_node) {
59+ match = of_match_node(dw_mci_bluefield_match,
60+ pdev->dev.of_node);
61+ drv_data = match->data;
62+ }
63+
64+ return dw_mci_pltfm_register(pdev, drv_data);
65+}
66+
67+static struct platform_driver dw_mci_bluefield_pltfm_driver = {
68+ .probe = dw_mci_bluefield_probe,
69+ .remove = dw_mci_pltfm_remove,
70+ .driver = {
71+ .name = "dwmmc_bluefield",
72+ .of_match_table = dw_mci_bluefield_match,
73+ .pm = &dw_mci_pltfm_pmops,
74+ },
75+};
76+
77+module_platform_driver(dw_mci_bluefield_pltfm_driver);
78+
79+MODULE_DESCRIPTION("BlueField DW Multimedia Card driver");
80+MODULE_AUTHOR("Mellanox Technologies");
81+MODULE_LICENSE("GPL v2");
drivers/mmc/host/dw_mmc-rockchip.c+2−3
@@ -44,9 +44,8 @@ static void dw_mci_rk3288_set_ios(struct dw_mci *host, struct mmc_ios *ios) · 43 unmodified lines
4444 * bus_hz = cclkin / RK3288_CLKGEN_DIV
4545 * ios->clock = (div == 0) ? bus_hz : (bus_hz / (2 * div))
4646 *
47− * Note: div can only be 0 or 1
48− * if DDR50 8bit mode(only emmc work in 8bit mode),
49− * div must be set 1
47+ * Note: div can only be 0 or 1, but div must be set to 1 for eMMC
48+ * DDR52 8-bit mode.
5049 */
5150 if (ios->bus_width == MMC_BUS_WIDTH_8 &&
5251 ios->timing == MMC_TIMING_MMC_DDR52)
drivers/mmc/host/dw_mmc.c+4−0
@@ -1230,6 +1230,8 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit) · 1229 unmodified lines
12301230 if (host->state == STATE_WAITING_CMD11_DONE)
12311231 sdmmc_cmd_bits |= SDMMC_CMD_VOLT_SWITCH;
12321232
1233+ slot->mmc->actual_clock = 0;
1234+
12331235 if (!clock) {
12341236 mci_writel(host, CLKENA, 0);
12351237 mci_send_cmd(slot, sdmmc_cmd_bits, 0);
@@ -1288,6 +1290,8 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit) · 52 unmodified lines
12881290
12891291 /* keep the last clock value that was requested from core */
12901292 slot->__clk_old = clock;
1293+ slot->mmc->actual_clock = div ? ((host->bus_hz / div) >> 1) :
1294+ host->bus_hz;
12911295 }
12921296
12931297 host->current_speed = clock;
drivers/mmc/host/jz4740_mmc.c+138−65
@@ -1,5 +1,7 @@
11 /*
22 * Copyright (C) 2009-2010, Lars-Peter Clausen <lars@metafoo.de>
3+ * Copyright (C) 2013, Imagination Technologies
4+ *
35 * JZ4740 SD/MMC controller driver
46 *
57 * This program is free software; you can redistribute it and/or modify it
@@ -13,24 +15,25 @@ · 7 unmodified lines
1315 *
1416 */
1517
16−#include <linux/mmc/host.h>
17−#include <linux/mmc/slot-gpio.h>
18+#include <linux/bitops.h>
19+#include <linux/clk.h>
20+#include <linux/delay.h>
21+#include <linux/dmaengine.h>
22+#include <linux/dma-mapping.h>
1823 #include <linux/err.h>
24+#include <linux/gpio.h>
25+#include <linux/interrupt.h>
1926 #include <linux/io.h>
2027 #include <linux/irq.h>
21−#include <linux/interrupt.h>
28+#include <linux/mmc/host.h>
29+#include <linux/mmc/slot-gpio.h>
2230 #include <linux/module.h>
31+#include <linux/of_device.h>
2332 #include <linux/pinctrl/consumer.h>
2433 #include <linux/platform_device.h>
25−#include <linux/delay.h>
2634 #include <linux/scatterlist.h>
27−#include <linux/clk.h>
2835
29−#include <linux/bitops.h>
30−#include <linux/gpio.h>
3136 #include <asm/cacheflush.h>
32−#include <linux/dma-mapping.h>
33−#include <linux/dmaengine.h>
3437
3538 #include <asm/mach-jz4740/dma.h>
3639 #include <asm/mach-jz4740/jz4740_mmc.h>
@@ -51,6 +54,7 @@ · 14 unmodified lines
5154 #define JZ_REG_MMC_RESP_FIFO 0x34
5255 #define JZ_REG_MMC_RXFIFO 0x38
5356 #define JZ_REG_MMC_TXFIFO 0x3C
57+#define JZ_REG_MMC_DMAC 0x44
5458
5559 #define JZ_MMC_STRPCL_EXIT_MULTIPLE BIT(7)
5660 #define JZ_MMC_STRPCL_EXIT_TRANSFER BIT(6)
@@ -104,9 +108,17 @@ · 47 unmodified lines
104108 #define JZ_MMC_IRQ_PRG_DONE BIT(1)
105109 #define JZ_MMC_IRQ_DATA_TRAN_DONE BIT(0)
106110
111+#define JZ_MMC_DMAC_DMA_SEL BIT(1)
112+#define JZ_MMC_DMAC_DMA_EN BIT(0)
107113
108114 #define JZ_MMC_CLK_RATE 24000000
109115
116+enum jz4740_mmc_version {
117+ JZ_MMC_JZ4740,
118+ JZ_MMC_JZ4750,
119+ JZ_MMC_JZ4780,
120+};
121+
110122 enum jz4740_mmc_state {
111123 JZ4740_MMC_STATE_READ_RESPONSE,
112124 JZ4740_MMC_STATE_TRANSFER_DATA,
@@ -125,6 +137,8 @@ struct jz4740_mmc_host { · 12 unmodified lines
125137 struct jz4740_mmc_platform_data *pdata;
126138 struct clk *clk;
127139
140+ enum jz4740_mmc_version version;
141+
128142 int irq;
129143 int card_detect_irq;
130144
@@ -137,7 +151,7 @@ struct jz4740_mmc_host { · 6 unmodified lines
137151
138152 uint32_t cmdat;
139153
140− uint16_t irq_mask;
154+ uint32_t irq_mask;
141155
142156 spinlock_t lock;
143157
@@ -159,6 +173,32 @@ struct jz4740_mmc_host { · 15 unmodified lines
159173 #define JZ4740_MMC_FIFO_HALF_SIZE 8
160174 };
161175
176+static void jz4740_mmc_write_irq_mask(struct jz4740_mmc_host *host,
177+ uint32_t val)
178+{
179+ if (host->version >= JZ_MMC_JZ4750)
180+ return writel(val, host->base + JZ_REG_MMC_IMASK);
181+ else
182+ return writew(val, host->base + JZ_REG_MMC_IMASK);
183+}
184+
185+static void jz4740_mmc_write_irq_reg(struct jz4740_mmc_host *host,
186+ uint32_t val)
187+{
188+ if (host->version >= JZ_MMC_JZ4780)
189+ return writel(val, host->base + JZ_REG_MMC_IREG);
190+ else
191+ return writew(val, host->base + JZ_REG_MMC_IREG);
192+}
193+
194+static uint32_t jz4740_mmc_read_irq_reg(struct jz4740_mmc_host *host)
195+{
196+ if (host->version >= JZ_MMC_JZ4780)
197+ return readl(host->base + JZ_REG_MMC_IREG);
198+ else
199+ return readw(host->base + JZ_REG_MMC_IREG);
200+}
201+
162202 /*----------------------------------------------------------------------------*/
163203 /* DMA infrastructure */
164204
@@ -173,31 +213,23 @@ static void jz4740_mmc_release_dma_channels(struct jz4740_mmc_host *host) · 8 unmodified lines
173213
174214 static int jz4740_mmc_acquire_dma_channels(struct jz4740_mmc_host *host)
175215 {
176− dma_cap_mask_t mask;
177−
178− dma_cap_zero(mask);
179− dma_cap_set(DMA_SLAVE, mask);
180−
181− host->dma_tx = dma_request_channel(mask, NULL, host);
182− if (!host->dma_tx) {
216+ host->dma_tx = dma_request_chan(mmc_dev(host->mmc), "tx");
217+ if (IS_ERR(host->dma_tx)) {
183218 dev_err(mmc_dev(host->mmc), "Failed to get dma_tx channel\n");
184− return -ENODEV;
219+ return PTR_ERR(host->dma_tx);
185220 }
186221
187− host->dma_rx = dma_request_channel(mask, NULL, host);
188− if (!host->dma_rx) {
222+ host->dma_rx = dma_request_chan(mmc_dev(host->mmc), "rx");
223+ if (IS_ERR(host->dma_rx)) {
189224 dev_err(mmc_dev(host->mmc), "Failed to get dma_rx channel\n");
190− goto free_master_write;
225+ dma_release_channel(host->dma_tx);
226+ return PTR_ERR(host->dma_rx);
191227 }
192228
193229 /* Initialize DMA pre request cookie */
194230 host->next_data.cookie = 1;
195231
196232 return 0;
197−
198−free_master_write:
199− dma_release_channel(host->dma_tx);
200− return -ENODEV;
201233 }
202234
203235 static inline struct dma_chan *jz4740_mmc_get_dma_chan(struct jz4740_mmc_host *host,
@@ -363,7 +395,7 @@ static void jz4740_mmc_set_irq_enabled(struct jz4740_mmc_host *host, · 159 unmodified lines
363395 else
364396 host->irq_mask |= irq;
365397
366− writew(host->irq_mask, host->base + JZ_REG_MMC_IMASK);
398+ jz4740_mmc_write_irq_mask(host, host->irq_mask);
367399 spin_unlock_irqrestore(&host->lock, flags);
368400 }
369401
@@ -415,10 +447,10 @@ static unsigned int jz4740_mmc_poll_irq(struct jz4740_mmc_host *host, · 45 unmodified lines
415447 unsigned int irq)
416448 {
417449 unsigned int timeout = 0x800;
418− uint16_t status;
450+ uint32_t status;
419451
420452 do {
421− status = readw(host->base + JZ_REG_MMC_IREG);
453+ status = jz4740_mmc_read_irq_reg(host);
422454 } while (!(status & irq) && --timeout);
423455
424456 if (timeout == 0) {
@@ -518,7 +550,7 @@ static bool jz4740_mmc_read_data(struct jz4740_mmc_host *host, · 93 unmodified lines
518550 void __iomem *fifo_addr = host->base + JZ_REG_MMC_RXFIFO;
519551 uint32_t *buf;
520552 uint32_t d;
521− uint16_t status;
553+ uint32_t status;
522554 size_t i, j;
523555 unsigned int timeout;
524556
@@ -654,8 +686,25 @@ static void jz4740_mmc_send_command(struct jz4740_mmc_host *host, · 129 unmodified lines
654686 cmdat |= JZ_MMC_CMDAT_DATA_EN;
655687 if (cmd->data->flags & MMC_DATA_WRITE)
656688 cmdat |= JZ_MMC_CMDAT_WRITE;
657− if (host->use_dma)
658− cmdat |= JZ_MMC_CMDAT_DMA_EN;
689+ if (host->use_dma) {
690+ /*
691+ * The 4780's MMC controller has integrated DMA ability
692+ * in addition to being able to use the external DMA
693+ * controller. It moves DMA control bits to a separate
694+ * register. The DMA_SEL bit chooses the external
695+ * controller over the integrated one. Earlier SoCs
696+ * can only use the external controller, and have a
697+ * single DMA enable bit in CMDAT.
698+ */
699+ if (host->version >= JZ_MMC_JZ4780) {
700+ writel(JZ_MMC_DMAC_DMA_EN | JZ_MMC_DMAC_DMA_SEL,
701+ host->base + JZ_REG_MMC_DMAC);
702+ } else {
703+ cmdat |= JZ_MMC_CMDAT_DMA_EN;
704+ }
705+ } else if (host->version >= JZ_MMC_JZ4780) {
706+ writel(0, host->base + JZ_REG_MMC_DMAC);
707+ }
659708
660709 writew(cmd->data->blksz, host->base + JZ_REG_MMC_BLKLEN);
661710 writew(cmd->data->blocks, host->base + JZ_REG_MMC_NOB);
@@ -736,7 +785,7 @@ static irqreturn_t jz_mmc_irq_worker(int irq, void *devid) · 74 unmodified lines
736785 host->state = JZ4740_MMC_STATE_SEND_STOP;
737786 break;
738787 }
739− writew(JZ_MMC_IRQ_DATA_TRAN_DONE, host->base + JZ_REG_MMC_IREG);
788+ jz4740_mmc_write_irq_reg(host, JZ_MMC_IRQ_DATA_TRAN_DONE);
740789
741790 case JZ4740_MMC_STATE_SEND_STOP:
742791 if (!req->stop)
@@ -766,9 +815,10 @@ static irqreturn_t jz_mmc_irq(int irq, void *devid) · 23 unmodified lines
766815 {
767816 struct jz4740_mmc_host *host = devid;
768817 struct mmc_command *cmd = host->cmd;
769− uint16_t irq_reg, status, tmp;
818+ uint32_t irq_reg, status, tmp;
770819
771− irq_reg = readw(host->base + JZ_REG_MMC_IREG);
820+ status = readl(host->base + JZ_REG_MMC_STATUS);
821+ irq_reg = jz4740_mmc_read_irq_reg(host);
772822
773823 tmp = irq_reg;
774824 irq_reg &= ~host->irq_mask;
@@ -777,10 +827,10 @@ static irqreturn_t jz_mmc_irq(int irq, void *devid) · 2 unmodified lines
777827 JZ_MMC_IRQ_PRG_DONE | JZ_MMC_IRQ_DATA_TRAN_DONE);
778828
779829 if (tmp != irq_reg)
780− writew(tmp & ~irq_reg, host->base + JZ_REG_MMC_IREG);
830+ jz4740_mmc_write_irq_reg(host, tmp & ~irq_reg);
781831
782832 if (irq_reg & JZ_MMC_IRQ_SDIO) {
783− writew(JZ_MMC_IRQ_SDIO, host->base + JZ_REG_MMC_IREG);
833+ jz4740_mmc_write_irq_reg(host, JZ_MMC_IRQ_SDIO);
784834 mmc_signal_sdio_irq(host->mmc);
785835 irq_reg &= ~JZ_MMC_IRQ_SDIO;
786836 }
@@ -789,8 +839,6 @@ static irqreturn_t jz_mmc_irq(int irq, void *devid) · 2 unmodified lines
789839 if (test_and_clear_bit(0, &host->waiting)) {
790840 del_timer(&host->timeout_timer);
791841
792− status = readl(host->base + JZ_REG_MMC_STATUS);
793−
794842 if (status & JZ_MMC_STATUS_TIMEOUT_RES) {
795843 cmd->error = -ETIMEDOUT;
796844 } else if (status & JZ_MMC_STATUS_CRC_RES_ERR) {
@@ -803,7 +851,7 @@ static irqreturn_t jz_mmc_irq(int irq, void *devid) · 6 unmodified lines
803851 }
804852
805853 jz4740_mmc_set_irq_enabled(host, irq_reg, false);
806− writew(irq_reg, host->base + JZ_REG_MMC_IREG);
854+ jz4740_mmc_write_irq_reg(host, irq_reg);
807855
808856 return IRQ_WAKE_THREAD;
809857 }
@@ -818,7 +866,7 @@ static int jz4740_mmc_set_clock_rate(struct jz4740_mmc_host *host, int rate) · 8 unmodified lines
818866 int real_rate;
819867
820868 jz4740_mmc_clock_disable(host);
821− clk_set_rate(host->clk, JZ_MMC_CLK_RATE);
869+ clk_set_rate(host->clk, host->mmc->f_max);
822870
823871 real_rate = clk_get_rate(host->clk);
824872
@@ -837,9 +885,7 @@ static void jz4740_mmc_request(struct mmc_host *mmc, struct mmc_request *req) · 12 unmodified lines
837885
838886 host->req = req;
839887
840− writew(0xffff, host->base + JZ_REG_MMC_IREG);
841−
842− writew(JZ_MMC_IRQ_END_CMD_RES, host->base + JZ_REG_MMC_IREG);
888+ jz4740_mmc_write_irq_reg(host, ~0);
843889 jz4740_mmc_set_irq_enabled(host, JZ_MMC_IRQ_END_CMD_RES, true);
844890
845891 host->state = JZ4740_MMC_STATE_READ_RESPONSE;
@@ -857,7 +903,7 @@ static void jz4740_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) · 11 unmodified lines
857903 switch (ios->power_mode) {
858904 case MMC_POWER_UP:
859905 jz4740_mmc_reset(host);
860− if (gpio_is_valid(host->pdata->gpio_power))
906+ if (host->pdata && gpio_is_valid(host->pdata->gpio_power))
861907 gpio_set_value(host->pdata->gpio_power,
862908 !host->pdata->power_active_low);
863909 host->cmdat |= JZ_MMC_CMDAT_INIT;
@@ -866,7 +912,7 @@ static void jz4740_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) · 2 unmodified lines
866912 case MMC_POWER_ON:
867913 break;
868914 default:
869− if (gpio_is_valid(host->pdata->gpio_power))
915+ if (host->pdata && gpio_is_valid(host->pdata->gpio_power))
870916 gpio_set_value(host->pdata->gpio_power,
871917 host->pdata->power_active_low);
872918 clk_disable_unprepare(host->clk);
@@ -926,7 +972,7 @@ static int jz4740_mmc_request_gpio(struct device *dev, int gpio, · 53 unmodified lines
926972 static int jz4740_mmc_request_gpios(struct mmc_host *mmc,
927973 struct platform_device *pdev)
928974 {
929− struct jz4740_mmc_platform_data *pdata = pdev->dev.platform_data;
975+ struct jz4740_mmc_platform_data *pdata = dev_get_platdata(&pdev->dev);
930976 int ret = 0;
931977
932978 if (!pdata)
@@ -955,7 +1001,7 @@ static int jz4740_mmc_request_gpios(struct mmc_host *mmc, · 22 unmodified lines
9551001
9561002 static void jz4740_mmc_free_gpios(struct platform_device *pdev)
9571003 {
958− struct jz4740_mmc_platform_data *pdata = pdev->dev.platform_data;
1004+ struct jz4740_mmc_platform_data *pdata = dev_get_platdata(&pdev->dev);
9591005
9601006 if (!pdata)
9611007 return;
@@ -964,14 +1010,22 @@ static void jz4740_mmc_free_gpios(struct platform_device *pdev) · 2 unmodified lines
9641010 gpio_free(pdata->gpio_power);
9651011 }
9661012
1013+static const struct of_device_id jz4740_mmc_of_match[] = {
1014+ { .compatible = "ingenic,jz4740-mmc", .data = (void *) JZ_MMC_JZ4740 },
1015+ { .compatible = "ingenic,jz4780-mmc", .data = (void *) JZ_MMC_JZ4780 },
1016+ {},
1017+};
1018+MODULE_DEVICE_TABLE(of, jz4740_mmc_of_match);
1019+
9671020 static int jz4740_mmc_probe(struct platform_device* pdev)
9681021 {
9691022 int ret;
9701023 struct mmc_host *mmc;
9711024 struct jz4740_mmc_host *host;
1025+ const struct of_device_id *match;
9721026 struct jz4740_mmc_platform_data *pdata;
9731027
974− pdata = pdev->dev.platform_data;
1028+ pdata = dev_get_platdata(&pdev->dev);
9751029
9761030 mmc = mmc_alloc_host(sizeof(struct jz4740_mmc_host), &pdev->dev);
9771031 if (!mmc) {
@@ -982,6 +1036,27 @@ static int jz4740_mmc_probe(struct platform_device* pdev) · 4 unmodified lines
9821036 host = mmc_priv(mmc);
9831037 host->pdata = pdata;
9841038
1039+ match = of_match_device(jz4740_mmc_of_match, &pdev->dev);
1040+ if (match) {
1041+ host->version = (enum jz4740_mmc_version)match->data;
1042+ ret = mmc_of_parse(mmc);
1043+ if (ret) {
1044+ if (ret != -EPROBE_DEFER)
1045+ dev_err(&pdev->dev,
1046+ "could not parse of data: %d\n", ret);
1047+ goto err_free_host;
1048+ }
1049+ } else {
1050+ /* JZ4740 should be the only one using legacy probe */
1051+ host->version = JZ_MMC_JZ4740;
1052+ mmc->caps |= MMC_CAP_SDIO_IRQ;
1053+ if (!(pdata && pdata->data_1bit))
1054+ mmc->caps |= MMC_CAP_4_BIT_DATA;
1055+ ret = jz4740_mmc_request_gpios(mmc, pdev);
1056+ if (ret)
1057+ goto err_free_host;
1058+ }
1059+
9851060 host->irq = platform_get_irq(pdev, 0);
9861061 if (host->irq < 0) {
9871062 ret = host->irq;
@@ -1004,16 +1079,11 @@ static int jz4740_mmc_probe(struct platform_device* pdev) · 16 unmodified lines
10041079 goto err_free_host;
10051080 }
10061081
1007− ret = jz4740_mmc_request_gpios(mmc, pdev);
1008− if (ret)
1009− goto err_release_dma;
1010−
10111082 mmc->ops = &jz4740_mmc_ops;
1012− mmc->f_min = JZ_MMC_CLK_RATE / 128;
1013− mmc->f_max = JZ_MMC_CLK_RATE;
1083+ if (!mmc->f_max)
1084+ mmc->f_max = JZ_MMC_CLK_RATE;
1085+ mmc->f_min = mmc->f_max / 128;
10141086 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
1015− mmc->caps = (pdata && pdata->data_1bit) ? 0 : MMC_CAP_4_BIT_DATA;
1016− mmc->caps |= MMC_CAP_SDIO_IRQ;
10171087
10181088 mmc->max_blk_size = (1 << 10) - 1;
10191089 mmc->max_blk_count = (1 << 15) - 1;
@@ -1025,7 +1095,9 @@ static int jz4740_mmc_probe(struct platform_device* pdev) · 5 unmodified lines
10251095 host->mmc = mmc;
10261096 host->pdev = pdev;
10271097 spin_lock_init(&host->lock);
1028− host->irq_mask = 0xffff;
1098+ host->irq_mask = ~0;
1099+
1100+ jz4740_mmc_reset(host);
10291101
10301102 ret = request_threaded_irq(host->irq, jz_mmc_irq, jz_mmc_irq_worker, 0,
10311103 dev_name(&pdev->dev), host);
@@ -1034,20 +1106,20 @@ static int jz4740_mmc_probe(struct platform_device* pdev) · 2 unmodified lines
10341106 goto err_free_gpios;
10351107 }
10361108
1037− jz4740_mmc_reset(host);
10381109 jz4740_mmc_clock_disable(host);
10391110 timer_setup(&host->timeout_timer, jz4740_mmc_timeout, 0);
10401111
1041− host->use_dma = true;
1042− if (host->use_dma && jz4740_mmc_acquire_dma_channels(host) != 0)
1043− host->use_dma = false;
1112+ ret = jz4740_mmc_acquire_dma_channels(host);
1113+ if (ret == -EPROBE_DEFER)
1114+ goto err_free_irq;
1115+ host->use_dma = !ret;
10441116
10451117 platform_set_drvdata(pdev, host);
10461118 ret = mmc_add_host(mmc);
10471119
10481120 if (ret) {
10491121 dev_err(&pdev->dev, "Failed to add mmc host: %d\n", ret);
1050− goto err_free_irq;
1122+ goto err_release_dma;
10511123 }
10521124 dev_info(&pdev->dev, "JZ SD/MMC card driver registered\n");
10531125
@@ -1057,13 +1129,13 @@ static int jz4740_mmc_probe(struct platform_device* pdev) · 3 unmodified lines
10571129
10581130 return 0;
10591131
1132+err_release_dma:
1133+ if (host->use_dma)
1134+ jz4740_mmc_release_dma_channels(host);
10601135 err_free_irq:
10611136 free_irq(host->irq, host);
10621137 err_free_gpios:
10631138 jz4740_mmc_free_gpios(pdev);
1064−err_release_dma:
1065− if (host->use_dma)
1066− jz4740_mmc_release_dma_channels(host);
10671139 err_free_host:
10681140 mmc_free_host(mmc);
10691141
@@ -1116,6 +1188,7 @@ static struct platform_driver jz4740_mmc_driver = { · 46 unmodified lines
11161188 .remove = jz4740_mmc_remove,
11171189 .driver = {
11181190 .name = "jz4740-mmc",
1191+ .of_match_table = of_match_ptr(jz4740_mmc_of_match),
11191192 .pm = JZ4740_MMC_PM_OPS,
11201193 },
11211194 };
drivers/mmc/host/meson-gx-mmc.c+61−11
@@ -35,6 +35,7 @@ · 34 unmodified lines
3535 #include <linux/clk.h>
3636 #include <linux/clk-provider.h>
3737 #include <linux/regulator/consumer.h>
38+#include <linux/reset.h>
3839 #include <linux/interrupt.h>
3940 #include <linux/bitfield.h>
4041 #include <linux/pinctrl/consumer.h>
@@ -47,15 +48,29 @@ · 6 unmodified lines
4748 #define CLK_CORE_PHASE_MASK GENMASK(9, 8)
4849 #define CLK_TX_PHASE_MASK GENMASK(11, 10)
4950 #define CLK_RX_PHASE_MASK GENMASK(13, 12)
50−#define CLK_TX_DELAY_MASK GENMASK(19, 16)
51−#define CLK_RX_DELAY_MASK GENMASK(23, 20)
51+#define CLK_V2_TX_DELAY_MASK GENMASK(19, 16)
52+#define CLK_V2_RX_DELAY_MASK GENMASK(23, 20)
53+#define CLK_V2_ALWAYS_ON BIT(24)
54+
55+#define CLK_V3_TX_DELAY_MASK GENMASK(21, 16)
56+#define CLK_V3_RX_DELAY_MASK GENMASK(27, 22)
57+#define CLK_V3_ALWAYS_ON BIT(28)
58+
5259 #define CLK_DELAY_STEP_PS 200
5360 #define CLK_PHASE_STEP 30
5461 #define CLK_PHASE_POINT_NUM (360 / CLK_PHASE_STEP)
55−#define CLK_ALWAYS_ON BIT(24)
62+
63+#define CLK_TX_DELAY_MASK(h) (h->data->tx_delay_mask)
64+#define CLK_RX_DELAY_MASK(h) (h->data->rx_delay_mask)
65+#define CLK_ALWAYS_ON(h) (h->data->always_on)
5666
5767 #define SD_EMMC_DELAY 0x4
5868 #define SD_EMMC_ADJUST 0x8
69+
70+#define SD_EMMC_DELAY1 0x4
71+#define SD_EMMC_DELAY2 0x8
72+#define SD_EMMC_V3_ADJUST 0xc
73+
5974 #define SD_EMMC_CALOUT 0x10
6075 #define SD_EMMC_START 0x40
6176 #define START_DESC_INIT BIT(0)
@@ -122,6 +137,12 @@ · 60 unmodified lines
122137
123138 #define MUX_CLK_NUM_PARENTS 2
124139
140+struct meson_mmc_data {
141+ unsigned int tx_delay_mask;
142+ unsigned int rx_delay_mask;
143+ unsigned int always_on;
144+};
145+
125146 struct sd_emmc_desc {
126147 u32 cmd_cfg;
127148 u32 cmd_arg;
@@ -131,6 +152,7 @@ struct sd_emmc_desc { · 3 unmodified lines
131152
132153 struct meson_host {
133154 struct device *dev;
155+ struct meson_mmc_data *data;
134156 struct mmc_host *mmc;
135157 struct mmc_command *cmd;
136158
@@ -474,7 +496,7 @@ static int meson_mmc_clk_init(struct meson_host *host) · 337 unmodified lines
474496
475497 /* init SD_EMMC_CLOCK to sane defaults w/min clock rate */
476498 clk_reg = 0;
477− clk_reg |= CLK_ALWAYS_ON;
499+ clk_reg |= CLK_ALWAYS_ON(host);
478500 clk_reg |= CLK_DIV_MASK;
479501 writel(clk_reg, host->regs + SD_EMMC_CLOCK);
480502
@@ -574,7 +596,7 @@ static int meson_mmc_clk_init(struct meson_host *host) · 93 unmodified lines
574596
575597 tx->reg = host->regs + SD_EMMC_CLOCK;
576598 tx->phase_mask = CLK_TX_PHASE_MASK;
577− tx->delay_mask = CLK_TX_DELAY_MASK;
599+ tx->delay_mask = CLK_TX_DELAY_MASK(host);
578600 tx->delay_step_ps = CLK_DELAY_STEP_PS;
579601 tx->hw.init = &init;
580602
@@ -597,7 +619,7 @@ static int meson_mmc_clk_init(struct meson_host *host) · 16 unmodified lines
597619
598620 rx->reg = host->regs + SD_EMMC_CLOCK;
599621 rx->phase_mask = CLK_RX_PHASE_MASK;
600− rx->delay_mask = CLK_RX_DELAY_MASK;
622+ rx->delay_mask = CLK_RX_DELAY_MASK(host);
601623 rx->delay_step_ps = CLK_DELAY_STEP_PS;
602624 rx->hw.init = &init;
603625
@@ -1184,6 +1206,21 @@ static int meson_mmc_probe(struct platform_device *pdev) · 580 unmodified lines
11841206 goto free_host;
11851207 }
11861208
1209+ host->data = (struct meson_mmc_data *)
1210+ of_device_get_match_data(&pdev->dev);
1211+ if (!host->data) {
1212+ ret = -EINVAL;
1213+ goto free_host;
1214+ }
1215+
1216+ ret = device_reset_optional(&pdev->dev);
1217+ if (ret) {
1218+ if (ret != -EPROBE_DEFER)
1219+ dev_err(&pdev->dev, "device reset failed: %d\n", ret);
1220+
1221+ return ret;
1222+ }
1223+
11871224 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
11881225 host->regs = devm_ioremap_resource(&pdev->dev, res);
11891226 if (IS_ERR(host->regs)) {
@@ -1315,11 +1352,24 @@ static int meson_mmc_remove(struct platform_device *pdev) · 125 unmodified lines
13151352 return 0;
13161353 }
13171354
1355+static const struct meson_mmc_data meson_gx_data = {
1356+ .tx_delay_mask = CLK_V2_TX_DELAY_MASK,
1357+ .rx_delay_mask = CLK_V2_RX_DELAY_MASK,
1358+ .always_on = CLK_V2_ALWAYS_ON,
1359+};
1360+
1361+static const struct meson_mmc_data meson_axg_data = {
1362+ .tx_delay_mask = CLK_V3_TX_DELAY_MASK,
1363+ .rx_delay_mask = CLK_V3_RX_DELAY_MASK,
1364+ .always_on = CLK_V3_ALWAYS_ON,
1365+};
1366+
13181367 static const struct of_device_id meson_mmc_of_match[] = {
1319− { .compatible = "amlogic,meson-gx-mmc", },
1320− { .compatible = "amlogic,meson-gxbb-mmc", },
1321− { .compatible = "amlogic,meson-gxl-mmc", },
1322− { .compatible = "amlogic,meson-gxm-mmc", },
1368+ { .compatible = "amlogic,meson-gx-mmc", .data = &meson_gx_data },
1369+ { .compatible = "amlogic,meson-gxbb-mmc", .data = &meson_gx_data },
1370+ { .compatible = "amlogic,meson-gxl-mmc", .data = &meson_gx_data },
1371+ { .compatible = "amlogic,meson-gxm-mmc", .data = &meson_gx_data },
1372+ { .compatible = "amlogic,meson-axg-mmc", .data = &meson_axg_data },
13231373 {}
13241374 };
13251375 MODULE_DEVICE_TABLE(of, meson_mmc_of_match);
@@ -1335,6 +1385,6 @@ static struct platform_driver meson_mmc_driver = { · 9 unmodified lines
13351385
13361386 module_platform_driver(meson_mmc_driver);
13371387
1338−MODULE_DESCRIPTION("Amlogic S905*/GX* SD/eMMC driver");
1388+MODULE_DESCRIPTION("Amlogic S905*/GX*/AXG SD/eMMC driver");
13391389 MODULE_AUTHOR("Kevin Hilman <khilman@baylibre.com>");
13401390 MODULE_LICENSE("GPL v2");
drivers/mmc/host/mmci.c+0−5
@@ -1253,15 +1253,12 @@ static irqreturn_t mmci_pio_irq(int irq, void *dev_id) · 1252 unmodified lines
12531253 struct sg_mapping_iter *sg_miter = &host->sg_miter;
12541254 struct variant_data *variant = host->variant;
12551255 void __iomem *base = host->base;
1256− unsigned long flags;
12571256 u32 status;
12581257
12591258 status = readl(base + MMCISTATUS);
12601259
12611260 dev_dbg(mmc_dev(host->mmc), "irq1 (pio) %08x\n", status);
12621261
1263− local_irq_save(flags);
1264−
12651262 do {
12661263 unsigned int remain, len;
12671264 char *buffer;
@@ -1301,8 +1298,6 @@ static irqreturn_t mmci_pio_irq(int irq, void *dev_id) · 33 unmodified lines
13011298
13021299 sg_miter_stop(sg_miter);
13031300
1304− local_irq_restore(flags);
1305−
13061301 /*
13071302 * If we have less than the fifo 'half-full' threshold to transfer,
13081303 * trigger a PIO interrupt as soon as any data is available.
drivers/mmc/host/mtk-sd.c+51−12
@@ -19,6 +19,7 @@ · 18 unmodified lines
1919 #include <linux/ioport.h>
2020 #include <linux/irq.h>
2121 #include <linux/of_address.h>
22+#include <linux/of_device.h>
2223 #include <linux/of_irq.h>
2324 #include <linux/of_gpio.h>
2425 #include <linux/pinctrl/consumer.h>
@@ -70,6 +71,7 @@ · 45 unmodified lines
7071 #define SDC_ADV_CFG0 0x64
7172 #define EMMC_IOCON 0x7c
7273 #define SDC_ACMD_RESP 0x80
74+#define DMA_SA_H4BIT 0x8c
7375 #define MSDC_DMA_SA 0x90
7476 #define MSDC_DMA_CTRL 0x98
7577 #define MSDC_DMA_CFG 0x9c
@@ -194,6 +196,9 @@ · 118 unmodified lines
194196 /* SDC_ADV_CFG0 mask */
195197 #define SDC_RX_ENHANCE_EN (0x1 << 20) /* RW */
196198
199+/* DMA_SA_H4BIT mask */
200+#define DMA_ADDR_HIGH_4BIT (0xf << 0) /* RW */
201+
197202 /* MSDC_DMA_CTRL mask */
198203 #define MSDC_DMA_CTRL_START (0x1 << 0) /* W */
199204 #define MSDC_DMA_CTRL_STOP (0x1 << 1) /* W */
@@ -227,6 +232,7 @@ · 27 unmodified lines
227232
228233 #define MSDC_PATCH_BIT2_CFGRESP (0x1 << 15) /* RW */
229234 #define MSDC_PATCH_BIT2_CFGCRCSTS (0x1 << 28) /* RW */
235+#define MSDC_PB2_SUPPORT_64G (0x1 << 1) /* RW */
230236 #define MSDC_PB2_RESPWAIT (0x3 << 2) /* RW */
231237 #define MSDC_PB2_RESPSTSENSEL (0x7 << 16) /* RW */
232238 #define MSDC_PB2_CRCSTSENSEL (0x7 << 29) /* RW */
@@ -280,6 +286,8 @@ struct mt_gpdma_desc { · 47 unmodified lines
280286 #define GPDMA_DESC_BDP (0x1 << 1)
281287 #define GPDMA_DESC_CHECKSUM (0xff << 8) /* bit8 ~ bit15 */
282288 #define GPDMA_DESC_INT (0x1 << 16)
289+#define GPDMA_DESC_NEXT_H4 (0xf << 24)
290+#define GPDMA_DESC_PTR_H4 (0xf << 28)
283291 u32 next;
284292 u32 ptr;
285293 u32 gpd_data_len;
@@ -296,6 +304,8 @@ struct mt_bdma_desc { · 10 unmodified lines
296304 #define BDMA_DESC_CHECKSUM (0xff << 8) /* bit8 ~ bit15 */
297305 #define BDMA_DESC_BLKPAD (0x1 << 17)
298306 #define BDMA_DESC_DWPAD (0x1 << 18)
307+#define BDMA_DESC_NEXT_H4 (0xf << 24)
308+#define BDMA_DESC_PTR_H4 (0xf << 28)
299309 u32 next;
300310 u32 ptr;
301311 u32 bd_data_len;
@@ -334,6 +344,7 @@ struct mtk_mmc_compatible { · 32 unmodified lines
334344 bool busy_check;
335345 bool stop_clk_fix;
336346 bool enhance_rx;
347+ bool support_64g;
337348 };
338349
339350 struct msdc_tune_para {
@@ -403,6 +414,7 @@ static const struct mtk_mmc_compatible mt8135_compat = { · 63 unmodified lines
403414 .busy_check = false,
404415 .stop_clk_fix = false,
405416 .enhance_rx = false,
417+ .support_64g = false,
406418 };
407419
408420 static const struct mtk_mmc_compatible mt8173_compat = {
@@ -414,6 +426,7 @@ static const struct mtk_mmc_compatible mt8173_compat = { · 5 unmodified lines
414426 .busy_check = false,
415427 .stop_clk_fix = false,
416428 .enhance_rx = false,
429+ .support_64g = false,
417430 };
418431
419432 static const struct mtk_mmc_compatible mt2701_compat = {
@@ -425,6 +438,7 @@ static const struct mtk_mmc_compatible mt2701_compat = { · 5 unmodified lines
425438 .busy_check = false,
426439 .stop_clk_fix = false,
427440 .enhance_rx = false,
441+ .support_64g = false,
428442 };
429443
430444 static const struct mtk_mmc_compatible mt2712_compat = {
@@ -436,6 +450,7 @@ static const struct mtk_mmc_compatible mt2712_compat = { · 5 unmodified lines
436450 .busy_check = true,
437451 .stop_clk_fix = true,
438452 .enhance_rx = true,
453+ .support_64g = true,
439454 };
440455
441456 static const struct mtk_mmc_compatible mt7622_compat = {
@@ -447,6 +462,7 @@ static const struct mtk_mmc_compatible mt7622_compat = { · 5 unmodified lines
447462 .busy_check = true,
448463 .stop_clk_fix = true,
449464 .enhance_rx = true,
465+ .support_64g = false,
450466 };
451467
452468 static const struct of_device_id msdc_of_ids[] = {
@@ -556,7 +572,12 @@ static inline void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma, · 103 unmodified lines
556572 /* init bd */
557573 bd[j].bd_info &= ~BDMA_DESC_BLKPAD;
558574 bd[j].bd_info &= ~BDMA_DESC_DWPAD;
559− bd[j].ptr = (u32)dma_address;
575+ bd[j].ptr = lower_32_bits(dma_address);
576+ if (host->dev_comp->support_64g) {
577+ bd[j].bd_info &= ~BDMA_DESC_PTR_H4;
578+ bd[j].bd_info |= (upper_32_bits(dma_address) & 0xf)
579+ << 28;
580+ }
560581 bd[j].bd_data_len &= ~BDMA_DESC_BUFLEN;
561582 bd[j].bd_data_len |= (dma_len & BDMA_DESC_BUFLEN);
562583
@@ -575,7 +596,10 @@ static inline void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma, · 12 unmodified lines
575596 dma_ctrl &= ~(MSDC_DMA_CTRL_BRUSTSZ | MSDC_DMA_CTRL_MODE);
576597 dma_ctrl |= (MSDC_BURST_64B << 12 | 1 << 8);
577598 writel_relaxed(dma_ctrl, host->base + MSDC_DMA_CTRL);
578− writel((u32)dma->gpd_addr, host->base + MSDC_DMA_SA);
599+ if (host->dev_comp->support_64g)
600+ sdr_set_field(host->base + DMA_SA_H4BIT, DMA_ADDR_HIGH_4BIT,
601+ upper_32_bits(dma->gpd_addr) & 0xf);
602+ writel(lower_32_bits(dma->gpd_addr), host->base + MSDC_DMA_SA);
579603 }
580604
581605 static void msdc_prepare_data(struct msdc_host *host, struct mmc_request *mrq)
@@ -1366,6 +1390,9 @@ static void msdc_init_hw(struct msdc_host *host) · 784 unmodified lines
13661390 MSDC_PATCH_BIT2_CFGCRCSTS);
13671391 }
13681392
1393+ if (host->dev_comp->support_64g)
1394+ sdr_set_bits(host->base + MSDC_PATCH_BIT2,
1395+ MSDC_PB2_SUPPORT_64G);
13691396 if (host->dev_comp->data_tune) {
13701397 sdr_set_bits(host->base + tune_reg,
13711398 MSDC_PAD_TUNE_RD_SEL | MSDC_PAD_TUNE_CMD_SEL);
@@ -1407,19 +1434,32 @@ static void msdc_init_gpd_bd(struct msdc_host *host, struct msdc_dma *dma) · 35 unmodified lines
14071434 {
14081435 struct mt_gpdma_desc *gpd = dma->gpd;
14091436 struct mt_bdma_desc *bd = dma->bd;
1437+ dma_addr_t dma_addr;
14101438 int i;
14111439
14121440 memset(gpd, 0, sizeof(struct mt_gpdma_desc) * 2);
14131441
1442+ dma_addr = dma->gpd_addr + sizeof(struct mt_gpdma_desc);
14141443 gpd->gpd_info = GPDMA_DESC_BDP; /* hwo, cs, bd pointer */
1415− gpd->ptr = (u32)dma->bd_addr; /* physical address */
14161444 /* gpd->next is must set for desc DMA
14171445 * That's why must alloc 2 gpd structure.
14181446 */
1419− gpd->next = (u32)dma->gpd_addr + sizeof(struct mt_gpdma_desc);
1447+ gpd->next = lower_32_bits(dma_addr);
1448+ if (host->dev_comp->support_64g)
1449+ gpd->gpd_info |= (upper_32_bits(dma_addr) & 0xf) << 24;
1450+
1451+ dma_addr = dma->bd_addr;
1452+ gpd->ptr = lower_32_bits(dma->bd_addr); /* physical address */
1453+ if (host->dev_comp->support_64g)
1454+ gpd->gpd_info |= (upper_32_bits(dma_addr) & 0xf) << 28;
1455+
14201456 memset(bd, 0, sizeof(struct mt_bdma_desc) * MAX_BD_NUM);
1421− for (i = 0; i < (MAX_BD_NUM - 1); i++)
1422− bd[i].next = (u32)dma->bd_addr + sizeof(*bd) * (i + 1);
1457+ for (i = 0; i < (MAX_BD_NUM - 1); i++) {
1458+ dma_addr = dma->bd_addr + sizeof(*bd) * (i + 1);
1459+ bd[i].next = lower_32_bits(dma_addr);
1460+ if (host->dev_comp->support_64g)
1461+ bd[i].bd_info |= (upper_32_bits(dma_addr) & 0xf) << 24;
1462+ }
14231463 }
14241464
14251465 static void msdc_ops_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
@@ -1820,7 +1860,6 @@ static int msdc_drv_probe(struct platform_device *pdev) · 394 unmodified lines
18201860 struct mmc_host *mmc;
18211861 struct msdc_host *host;
18221862 struct resource *res;
1823− const struct of_device_id *of_id;
18241863 int ret;
18251864
18261865 if (!pdev->dev.of_node) {
@@ -1828,9 +1867,6 @@ static int msdc_drv_probe(struct platform_device *pdev) · 1 unmodified line
18281867 return -EINVAL;
18291868 }
18301869
1831− of_id = of_match_node(msdc_of_ids, pdev->dev.of_node);
1832− if (!of_id)
1833− return -EINVAL;
18341870 /* Allocate MMC host for this device */
18351871 mmc = mmc_alloc_host(sizeof(struct msdc_host), &pdev->dev);
18361872 if (!mmc)
@@ -1899,7 +1935,7 @@ static int msdc_drv_probe(struct platform_device *pdev) · 62 unmodified lines
18991935 msdc_of_property_parse(pdev, host);
19001936
19011937 host->dev = &pdev->dev;
1902− host->dev_comp = of_id->data;
1938+ host->dev_comp = of_device_get_match_data(&pdev->dev);
19031939 host->mmc = mmc;
19041940 host->src_clk_freq = clk_get_rate(host->src_clk);
19051941 /* Set host parameters to mmc */
@@ -1916,7 +1952,10 @@ static int msdc_drv_probe(struct platform_device *pdev) · 10 unmodified lines
19161952 mmc->max_blk_size = 2048;
19171953 mmc->max_req_size = 512 * 1024;
19181954 mmc->max_blk_count = mmc->max_req_size / 512;
1919− host->dma_mask = DMA_BIT_MASK(32);
1955+ if (host->dev_comp->support_64g)
1956+ host->dma_mask = DMA_BIT_MASK(36);
1957+ else
1958+ host->dma_mask = DMA_BIT_MASK(32);
19201959 mmc_dev(mmc)->dma_mask = &host->dma_mask;
19211960
19221961 host->timeout_clks = 3 * 1048576;
drivers/mmc/host/mvsdio.c+5−1
@@ -143,6 +143,7 @@ static void mvsd_request(struct mmc_host *mmc, struct mmc_request *mrq) · 142 unmodified lines
143143 struct mmc_command *cmd = mrq->cmd;
144144 u32 cmdreg = 0, xfer = 0, intr = 0;
145145 unsigned long flags;
146+ unsigned int timeout;
146147
147148 BUG_ON(host->mrq != NULL);
148149 host->mrq = mrq;
@@ -234,7 +235,8 @@ static void mvsd_request(struct mmc_host *mmc, struct mmc_request *mrq) · 85 unmodified lines
234235 mvsd_write(MVSD_NOR_INTR_EN, host->intr_en);
235236 mvsd_write(MVSD_ERR_INTR_EN, 0xffff);
236237
237− mod_timer(&host->timer, jiffies + 5 * HZ);
238+ timeout = cmd->busy_timeout ? cmd->busy_timeout : 5000;
239+ mod_timer(&host->timer, jiffies + msecs_to_jiffies(timeout));
238240
239241 spin_unlock_irqrestore(&host->lock, flags);
240242 }
@@ -755,6 +757,8 @@ static int mvsd_probe(struct platform_device *pdev) · 514 unmodified lines
755757 if (maxfreq)
756758 mmc->f_max = maxfreq;
757759
760+ mmc->caps |= MMC_CAP_ERASE;
761+
758762 spin_lock_init(&host->lock);
759763
760764 host->base = devm_ioremap_resource(&pdev->dev, r);
drivers/mmc/host/mxcmmc.c+16−6
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 #include <linux/init.h>
2222 #include <linux/ioport.h>
2323 #include <linux/platform_device.h>
24+#include <linux/highmem.h>
2425 #include <linux/interrupt.h>
2526 #include <linux/irq.h>
2627 #include <linux/blkdev.h>
@@ -291,8 +292,10 @@ static void mxcmci_swap_buffers(struct mmc_data *data) · 264 unmodified lines
291292 struct scatterlist *sg;
292293 int i;
293294
294− for_each_sg(data->sg, sg, data->sg_len, i)
295− buffer_swap32(sg_virt(sg), sg->length);
295+ for_each_sg(data->sg, sg, data->sg_len, i) {
296+ void *buf = kmap_atomic(sg_page(sg) + sg->offset;
297+ buffer_swap32(buf, sg->length);
298+ kunmap_atomic(buf);
296299 }
297300 #else
298301 static inline void mxcmci_swap_buffers(struct mmc_data *data) {}
@@ -609,6 +612,7 @@ static int mxcmci_transfer_data(struct mxcmci_host *host) · 310 unmodified lines
609612 {
610613 struct mmc_data *data = host->req->data;
611614 struct scatterlist *sg;
615+ void *buf;
612616 int stat, i;
613617
614618 host->data = data;
@@ -616,14 +620,18 @@ static int mxcmci_transfer_data(struct mxcmci_host *host) · 1 unmodified line
616620
617621 if (data->flags & MMC_DATA_READ) {
618622 for_each_sg(data->sg, sg, data->sg_len, i) {
619− stat = mxcmci_pull(host, sg_virt(sg), sg->length);
623+ buf = kmap_atomic(sg_page(sg) + sg->offset);
624+ stat = mxcmci_pull(host, buf, sg->length);
625+ kunmap(buf);
620626 if (stat)
621627 return stat;
622628 host->datasize += sg->length;
623629 }
624630 } else {
625631 for_each_sg(data->sg, sg, data->sg_len, i) {
626− stat = mxcmci_push(host, sg_virt(sg), sg->length);
632+ buf = kmap_atomic(sg_page(sg) + sg->offset);
633+ stat = mxcmci_push(host, buf, sg->length);
634+ kunmap(buf);
627635 if (stat)
628636 return stat;
629637 host->datasize += sg->length;
@@ -1206,7 +1214,8 @@ static int mxcmci_remove(struct platform_device *pdev) · 576 unmodified lines
12061214 return 0;
12071215 }
12081216
1209−static int __maybe_unused mxcmci_suspend(struct device *dev)
1217+#ifdef CONFIG_PM_SLEEP
1218+static int mxcmci_suspend(struct device *dev)
12101219 {
12111220 struct mmc_host *mmc = dev_get_drvdata(dev);
12121221 struct mxcmci_host *host = mmc_priv(mmc);
@@ -1216,7 +1225,7 @@ static int __maybe_unused mxcmci_suspend(struct device *dev) · 3 unmodified lines
12161225 return 0;
12171226 }
12181227
1219−static int __maybe_unused mxcmci_resume(struct device *dev)
1228+static int mxcmci_resume(struct device *dev)
12201229 {
12211230 struct mmc_host *mmc = dev_get_drvdata(dev);
12221231 struct mxcmci_host *host = mmc_priv(mmc);
@@ -1232,6 +1241,7 @@ static int __maybe_unused mxcmci_resume(struct device *dev) · 9 unmodified lines
12321241
12331242 return ret;
12341243 }
1244+#endif
12351245
12361246 static SIMPLE_DEV_PM_OPS(mxcmci_pm_ops, mxcmci_suspend, mxcmci_resume);
12371247
drivers/mmc/host/renesas_sdhi_core.c+5−0
@@ -28,6 +28,7 @@ · 27 unmodified lines
2828 #include <linux/of_device.h>
2929 #include <linux/platform_device.h>
3030 #include <linux/mmc/host.h>
31+#include <linux/mmc/slot-gpio.h>
3132 #include <linux/mfd/tmio.h>
3233 #include <linux/sh_dma.h>
3334 #include <linux/delay.h>
@@ -534,6 +535,10 @@ int renesas_sdhi_probe(struct platform_device *pdev, · 500 unmodified lines
534535 host->multi_io_quirk = renesas_sdhi_multi_io_quirk;
535536 host->dma_ops = dma_ops;
536537
538+ /* For some SoC, we disable internal WP. GPIO may override this */
539+ if (mmc_can_gpio_ro(host->mmc))
540+ mmc_data->capabilities2 &= ~MMC_CAP2_NO_WRITE_PROTECT;
541+
537542 /* SDR speeds are only available on Gen2+ */
538543 if (mmc_data->flags & TMIO_MMC_MIN_RCAR2) {
539544 /* card_busy caused issues on r8a73a4 (pre-Gen2) CD-less SDHI */
drivers/mmc/host/renesas_sdhi_internal_dmac.c+17−15
@@ -87,11 +87,12 @@ static const struct renesas_sdhi_of_data of_rcar_gen3_compatible = { · 86 unmodified lines
8787 TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,
8888 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
8989 MMC_CAP_CMD23,
90+ .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
9091 .bus_shift = 2,
9192 .scc_offset = 0x1000,
9293 .taps = rcar_gen3_scc_taps,
9394 .taps_num = ARRAY_SIZE(rcar_gen3_scc_taps),
94− /* Gen3 SDHI DMAC can handle 0xffffffff blk count, but seg = 1 */
95+ /* DMAC can handle 0xffffffff blk count but only 1 segment */
9596 .max_blk_count = 0xffffffff,
9697 .max_segs = 1,
9798 };
@@ -157,38 +158,34 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, · 59 unmodified lines
157158 {
158159 struct scatterlist *sg = host->sg_ptr;
159160 u32 dtran_mode = DTRAN_MODE_BUS_WID_TH | DTRAN_MODE_ADDR_MODE;
160− enum dma_data_direction dir;
161− int ret;
162161
163− /* This DMAC cannot handle if sg_len is not 1 */
164− WARN_ON(host->sg_len > 1);
162+ if (!dma_map_sg(&host->pdev->dev, sg, host->sg_len,
163+ mmc_get_dma_dir(data)))
164+ goto force_pio;
165165
166166 /* This DMAC cannot handle if buffer is not 8-bytes alignment */
167− if (!IS_ALIGNED(sg->offset, 8))
167+ if (!IS_ALIGNED(sg_dma_address(sg), 8)) {
168+ dma_unmap_sg(&host->pdev->dev, sg, host->sg_len,
169+ mmc_get_dma_dir(data));
168170 goto force_pio;
171+ }
169172
170173 if (data->flags & MMC_DATA_READ) {
171174 dtran_mode |= DTRAN_MODE_CH_NUM_CH1;
172− dir = DMA_FROM_DEVICE;
173175 if (test_bit(SDHI_INTERNAL_DMAC_ONE_RX_ONLY, &global_flags) &&
174176 test_and_set_bit(SDHI_INTERNAL_DMAC_RX_IN_USE, &global_flags))
175177 goto force_pio;
176178 } else {
177179 dtran_mode |= DTRAN_MODE_CH_NUM_CH0;
178− dir = DMA_TO_DEVICE;
179180 }
180181
181− ret = dma_map_sg(&host->pdev->dev, sg, host->sg_len, dir);
182− if (ret == 0)
183− goto force_pio;
184−
185182 renesas_sdhi_internal_dmac_enable_dma(host, true);
186183
187184 /* set dma parameters */
188185 renesas_sdhi_internal_dmac_dm_write(host, DM_CM_DTRAN_MODE,
189186 dtran_mode);
190187 renesas_sdhi_internal_dmac_dm_write(host, DM_DTRAN_ADDR,
191− sg->dma_address);
188+ sg_dma_address(sg));
192189
193190 return;
194191
@@ -272,12 +269,17 @@ static const struct tmio_mmc_dma_ops renesas_sdhi_internal_dmac_dma_ops = { · 77 unmodified lines
272269 * implementation as others may use a different implementation.
273270 */
274271 static const struct soc_device_attribute gen3_soc_whitelist[] = {
272+ /* specific ones */
275273 { .soc_id = "r8a7795", .revision = "ES1.*",
276274 .data = (void *)BIT(SDHI_INTERNAL_DMAC_ONE_RX_ONLY) },
277− { .soc_id = "r8a7795", .revision = "ES2.0" },
278275 { .soc_id = "r8a7796", .revision = "ES1.0",
279276 .data = (void *)BIT(SDHI_INTERNAL_DMAC_ONE_RX_ONLY) },
280− { .soc_id = "r8a77995", .revision = "ES1.0" },
277+ /* generic ones */
278+ { .soc_id = "r8a7795" },
279+ { .soc_id = "r8a7796" },
280+ { .soc_id = "r8a77965" },
281+ { .soc_id = "r8a77980" },
282+ { .soc_id = "r8a77995" },
281283 { /* sentinel */ }
282284 };
283285
drivers/mmc/host/renesas_sdhi_sys_dmac.c+3−0
@@ -42,6 +42,7 @@ static const struct renesas_sdhi_of_data of_rz_compatible = { · 41 unmodified lines
4242 static const struct renesas_sdhi_of_data of_rcar_gen1_compatible = {
4343 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL,
4444 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
45+ .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
4546 };
4647
4748 /* Definitions for sampling clocks */
@@ -61,6 +62,7 @@ static const struct renesas_sdhi_of_data of_rcar_gen2_compatible = { · 13 unmodified lines
6162 TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,
6263 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
6364 MMC_CAP_CMD23,
65+ .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
6466 .dma_buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES,
6567 .dma_rx_offset = 0x2000,
6668 .scc_offset = 0x0300,
@@ -81,6 +83,7 @@ static const struct renesas_sdhi_of_data of_rcar_gen3_compatible = { · 14 unmodified lines
8183 TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,
8284 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
8385 MMC_CAP_CMD23,
86+ .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
8487 .bus_shift = 2,
8588 .scc_offset = 0x1000,
8689 .taps = rcar_gen3_scc_taps,
drivers/mmc/host/rtsx_usb_sdmmc.c+4−15
@@ -26,7 +26,6 @@ · 25 unmodified lines
2626 #include <linux/mmc/host.h>
2727 #include <linux/mmc/mmc.h>
2828 #include <linux/mmc/sd.h>
29−#include <linux/mmc/sdio.h>
3029 #include <linux/mmc/card.h>
3130 #include <linux/scatterlist.h>
3231 #include <linux/pm_runtime.h>
@@ -343,7 +342,7 @@ static void sd_send_cmd_get_rsp(struct rtsx_usb_sdmmc *host, · 310 unmodified lines
343342 }
344343
345344 if (rsp_type == SD_RSP_TYPE_R1b)
346− timeout = 3000;
345+ timeout = cmd->busy_timeout ? cmd->busy_timeout : 3000;
347346
348347 if (cmd->opcode == SD_SWITCH_VOLTAGE) {
349348 err = rtsx_usb_write_register(ucr, SD_BUS_STAT,
@@ -839,17 +838,6 @@ static void sdmmc_request(struct mmc_host *mmc, struct mmc_request *mrq) · 489 unmodified lines
839838 goto finish_detect_card;
840839 }
841840
842− /*
843− * Reject SDIO CMDs to speed up card identification
844− * since unsupported
845− */
846− if (cmd->opcode == SD_IO_SEND_OP_COND ||
847− cmd->opcode == SD_IO_RW_DIRECT ||
848− cmd->opcode == SD_IO_RW_EXTENDED) {
849− cmd->error = -EINVAL;
850− goto finish;
851− }
852−
853841 mutex_lock(&ucr->dev_mutex);
854842
855843 mutex_lock(&host->host_mutex);
@@ -1332,8 +1320,9 @@ static void rtsx_usb_init_host(struct rtsx_usb_sdmmc *host) · 476 unmodified lines
13321320 mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SD_HIGHSPEED |
13331321 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_BUS_WIDTH_TEST |
13341322 MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 |
1335− MMC_CAP_NEEDS_POLL;
1336− mmc->caps2 = MMC_CAP2_NO_PRESCAN_POWERUP | MMC_CAP2_FULL_PWR_CYCLE;
1323+ MMC_CAP_NEEDS_POLL | MMC_CAP_ERASE;
1324+ mmc->caps2 = MMC_CAP2_NO_PRESCAN_POWERUP | MMC_CAP2_FULL_PWR_CYCLE |
1325+ MMC_CAP2_NO_SDIO;
13371326
13381327 mmc->max_current_330 = 400;
13391328 mmc->max_current_180 = 800;
drivers/mmc/host/sdhci-bcm-kona.c+1−3
@@ -284,10 +284,8 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev) · 283 unmodified lines
284284 sdhci_bcm_kona_sd_init(host);
285285
286286 ret = sdhci_add_host(host);
287− if (ret) {
288− dev_err(dev, "Failed sdhci_add_host\n");
287+ if (ret)
289288 goto err_reset;
290− }
291289
292290 /* if device is eMMC, emulate card insert right here */
293291 if (!mmc_card_is_removable(host->mmc)) {
drivers/mmc/host/sdhci-cadence.c+18−4
@@ -253,6 +253,7 @@ static int sdhci_cdns_set_tune_val(struct sdhci_host *host, unsigned int val) · 252 unmodified lines
253253 struct sdhci_cdns_priv *priv = sdhci_cdns_priv(host);
254254 void __iomem *reg = priv->hrs_addr + SDHCI_CDNS_HRS06;
255255 u32 tmp;
256+ int i, ret;
256257
257258 if (WARN_ON(!FIELD_FIT(SDHCI_CDNS_HRS06_TUNE, val)))
258259 return -EINVAL;
@@ -260,11 +261,24 @@ static int sdhci_cdns_set_tune_val(struct sdhci_host *host, unsigned int val) · 1 unmodified line
260261 tmp = readl(reg);
261262 tmp &= ~SDHCI_CDNS_HRS06_TUNE;
262263 tmp |= FIELD_PREP(SDHCI_CDNS_HRS06_TUNE, val);
263− tmp |= SDHCI_CDNS_HRS06_TUNE_UP;
264− writel(tmp, reg);
265264
266− return readl_poll_timeout(reg, tmp, !(tmp & SDHCI_CDNS_HRS06_TUNE_UP),
267− 0, 1);
265+ /*
266+ * Workaround for IP errata:
267+ * The IP6116 SD/eMMC PHY design has a timing issue on receive data
268+ * path. Send tune request twice.
269+ */
270+ for (i = 0; i < 2; i++) {
271+ tmp |= SDHCI_CDNS_HRS06_TUNE_UP;
272+ writel(tmp, reg);
273+
274+ ret = readl_poll_timeout(reg, tmp,
275+ !(tmp & SDHCI_CDNS_HRS06_TUNE_UP),
276+ 0, 1);
277+ if (ret)
278+ return ret;
279+ }
280+
281+ return 0;
268282 }
269283
270284 static int sdhci_cdns_execute_tuning(struct mmc_host *mmc, u32 opcode)
drivers/mmc/host/sdhci-esdhc-imx.c+22−0
@@ -41,6 +41,12 @@ · 40 unmodified lines
4141 #define ESDHC_VENDOR_SPEC_FRC_SDCLK_ON (1 << 8)
4242 #define ESDHC_WTMK_LVL 0x44
4343 #define ESDHC_WTMK_DEFAULT_VAL 0x10401040
44+#define ESDHC_WTMK_LVL_RD_WML_MASK 0x000000FF
45+#define ESDHC_WTMK_LVL_RD_WML_SHIFT 0
46+#define ESDHC_WTMK_LVL_WR_WML_MASK 0x00FF0000
47+#define ESDHC_WTMK_LVL_WR_WML_SHIFT 16
48+#define ESDHC_WTMK_LVL_WML_VAL_DEF 64
49+#define ESDHC_WTMK_LVL_WML_VAL_MAX 128
4450 #define ESDHC_MIX_CTRL 0x48
4551 #define ESDHC_MIX_CTRL_DDREN (1 << 3)
4652 #define ESDHC_MIX_CTRL_AC23EN (1 << 7)
@@ -516,6 +522,7 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg) · 469 unmodified lines
516522 }
517523
518524 if (esdhc_is_usdhc(imx_data)) {
525+ u32 wml;
519526 u32 m = readl(host->ioaddr + ESDHC_MIX_CTRL);
520527 /* Swap AC23 bit */
521528 if (val & SDHCI_TRNS_AUTO_CMD23) {
@@ -524,6 +531,21 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg) · 2 unmodified lines
524531 }
525532 m = val | (m & ~ESDHC_MIX_CTRL_SDHCI_MASK);
526533 writel(m, host->ioaddr + ESDHC_MIX_CTRL);
534+
535+ /* Set watermark levels for PIO access to maximum value
536+ * (128 words) to accommodate full 512 bytes buffer.
537+ * For DMA access restore the levels to default value.
538+ */
539+ m = readl(host->ioaddr + ESDHC_WTMK_LVL);
540+ if (val & SDHCI_TRNS_DMA)
541+ wml = ESDHC_WTMK_LVL_WML_VAL_DEF;
542+ else
543+ wml = ESDHC_WTMK_LVL_WML_VAL_MAX;
544+ m &= ~(ESDHC_WTMK_LVL_RD_WML_MASK |
545+ ESDHC_WTMK_LVL_WR_WML_MASK);
546+ m |= (wml << ESDHC_WTMK_LVL_RD_WML_SHIFT) |
547+ (wml << ESDHC_WTMK_LVL_WR_WML_SHIFT);
548+ writel(m, host->ioaddr + ESDHC_WTMK_LVL);
527549 } else {
528550 /*
529551 * Postpone this write, we must do it together with a
drivers/mmc/host/sdhci-msm.c+82−3
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 #include <linux/pm_runtime.h>
2222 #include <linux/slab.h>
2323 #include <linux/iopoll.h>
24+#include <linux/regulator/consumer.h>
2425
2526 #include "sdhci-pltfm.h"
2627
@@ -77,10 +78,16 @@ · 50 unmodified lines
7778 #define CORE_HC_MCLK_SEL_DFLT (2 << 8)
7879 #define CORE_HC_MCLK_SEL_HS400 (3 << 8)
7980 #define CORE_HC_MCLK_SEL_MASK (3 << 8)
81+#define CORE_IO_PAD_PWR_SWITCH_EN (1 << 15)
82+#define CORE_IO_PAD_PWR_SWITCH (1 << 16)
8083 #define CORE_HC_SELECT_IN_EN BIT(18)
8184 #define CORE_HC_SELECT_IN_HS400 (6 << 19)
8285 #define CORE_HC_SELECT_IN_MASK (7 << 19)
8386
87+#define CORE_3_0V_SUPPORT (1 << 25)
88+#define CORE_1_8V_SUPPORT (1 << 26)
89+#define CORE_VOLT_SUPPORT (CORE_3_0V_SUPPORT | CORE_1_8V_SUPPORT)
90+
8491 #define CORE_CSR_CDC_CTLR_CFG0 0x130
8592 #define CORE_SW_TRIG_FULL_CALIB BIT(16)
8693 #define CORE_HW_AUTOCAL_ENA BIT(17)
@@ -148,6 +155,7 @@ struct sdhci_msm_host { · 61 unmodified lines
148155 u32 curr_io_level;
149156 wait_queue_head_t pwr_irq_wait;
150157 bool pwr_irq_flag;
158+ u32 caps_0;
151159 };
152160
153161 static unsigned int msm_get_clock_rate_for_bus_mode(struct sdhci_host *host,
@@ -1103,8 +1111,8 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq) · 949 unmodified lines
11031111 struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
11041112 u32 irq_status, irq_ack = 0;
11051113 int retry = 10;
1106− int pwr_state = 0, io_level = 0;
1107−
1114+ u32 pwr_state = 0, io_level = 0;
1115+ u32 config;
11081116
11091117 irq_status = readl_relaxed(msm_host->core_mem + CORE_PWRCTL_STATUS);
11101118 irq_status &= INT_MASK;
@@ -1161,6 +1169,38 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq) · 50 unmodified lines
11611169 */
11621170 writel_relaxed(irq_ack, msm_host->core_mem + CORE_PWRCTL_CTL);
11631171
1172+ /*
1173+ * If we don't have info regarding the voltage levels supported by
1174+ * regulators, don't change the IO PAD PWR SWITCH.
1175+ */
1176+ if (msm_host->caps_0 & CORE_VOLT_SUPPORT) {
1177+ u32 new_config;
1178+ /*
1179+ * We should unset IO PAD PWR switch only if the register write
1180+ * can set IO lines high and the regulator also switches to 3 V.
1181+ * Else, we should keep the IO PAD PWR switch set.
1182+ * This is applicable to certain targets where eMMC vccq supply
1183+ * is only 1.8V. In such targets, even during REQ_IO_HIGH, the
1184+ * IO PAD PWR switch must be kept set to reflect actual
1185+ * regulator voltage. This way, during initialization of
1186+ * controllers with only 1.8V, we will set the IO PAD bit
1187+ * without waiting for a REQ_IO_LOW.
1188+ */
1189+ config = readl_relaxed(host->ioaddr + CORE_VENDOR_SPEC);
1190+ new_config = config;
1191+
1192+ if ((io_level & REQ_IO_HIGH) &&
1193+ (msm_host->caps_0 & CORE_3_0V_SUPPORT))
1194+ new_config &= ~CORE_IO_PAD_PWR_SWITCH;
1195+ else if ((io_level & REQ_IO_LOW) ||
1196+ (msm_host->caps_0 & CORE_1_8V_SUPPORT))
1197+ new_config |= CORE_IO_PAD_PWR_SWITCH;
1198+
1199+ if (config ^ new_config)
1200+ writel_relaxed(new_config,
1201+ host->ioaddr + CORE_VENDOR_SPEC);
1202+ }
1203+
11641204 if (pwr_state)
11651205 msm_host->curr_pwr_state = pwr_state;
11661206 if (io_level)
@@ -1313,6 +1353,45 @@ static void sdhci_msm_writeb(struct sdhci_host *host, u8 val, int reg) · 146 unmodified lines
13131353 sdhci_msm_check_power_status(host, req_type);
13141354 }
13151355
1356+static void sdhci_msm_set_regulator_caps(struct sdhci_msm_host *msm_host)
1357+{
1358+ struct mmc_host *mmc = msm_host->mmc;
1359+ struct regulator *supply = mmc->supply.vqmmc;
1360+ u32 caps = 0, config;
1361+ struct sdhci_host *host = mmc_priv(mmc);
1362+
1363+ if (!IS_ERR(mmc->supply.vqmmc)) {
1364+ if (regulator_is_supported_voltage(supply, 1700000, 1950000))
1365+ caps |= CORE_1_8V_SUPPORT;
1366+ if (regulator_is_supported_voltage(supply, 2700000, 3600000))
1367+ caps |= CORE_3_0V_SUPPORT;
1368+
1369+ if (!caps)
1370+ pr_warn("%s: 1.8/3V not supported for vqmmc\n",
1371+ mmc_hostname(mmc));
1372+ }
1373+
1374+ if (caps) {
1375+ /*
1376+ * Set the PAD_PWR_SWITCH_EN bit so that the PAD_PWR_SWITCH
1377+ * bit can be used as required later on.
1378+ */
1379+ u32 io_level = msm_host->curr_io_level;
1380+
1381+ config = readl_relaxed(host->ioaddr + CORE_VENDOR_SPEC);
1382+ config |= CORE_IO_PAD_PWR_SWITCH_EN;
1383+
1384+ if ((io_level & REQ_IO_HIGH) && (caps & CORE_3_0V_SUPPORT))
1385+ config &= ~CORE_IO_PAD_PWR_SWITCH;
1386+ else if ((io_level & REQ_IO_LOW) || (caps & CORE_1_8V_SUPPORT))
1387+ config |= CORE_IO_PAD_PWR_SWITCH;
1388+
1389+ writel_relaxed(config, host->ioaddr + CORE_VENDOR_SPEC);
1390+ }
1391+ msm_host->caps_0 |= caps;
1392+ pr_debug("%s: supported caps: 0x%08x\n", mmc_hostname(mmc), caps);
1393+}
1394+
13161395 static const struct of_device_id sdhci_msm_dt_match[] = {
13171396 { .compatible = "qcom,sdhci-msm-v4" },
13181397 {},
@@ -1333,7 +1412,6 @@ static const struct sdhci_ops sdhci_msm_ops = { · 14 unmodified lines
13331412
13341413 static const struct sdhci_pltfm_data sdhci_msm_pdata = {
13351414 .quirks = SDHCI_QUIRK_BROKEN_CARD_DETECTION |
1336− SDHCI_QUIRK_NO_CARD_NO_RESET |
13371415 SDHCI_QUIRK_SINGLE_POWER_WRITE |
13381416 SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN,
13391417 .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
@@ -1530,6 +1608,7 @@ static int sdhci_msm_probe(struct platform_device *pdev) · 190 unmodified lines
15301608 ret = sdhci_add_host(host);
15311609 if (ret)
15321610 goto pm_runtime_disable;
1611+ sdhci_msm_set_regulator_caps(msm_host);
15331612
15341613 pm_runtime_mark_last_busy(&pdev->dev);
15351614 pm_runtime_put_autosuspend(&pdev->dev);
drivers/mmc/host/sdhci-of-arasan.c+4−5
@@ -290,7 +290,8 @@ static const struct sdhci_pltfm_data sdhci_arasan_pdata = { · 289 unmodified lines
290290 .ops = &sdhci_arasan_ops,
291291 .quirks = SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN,
292292 .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN |
293− SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN,
293+ SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN |
294+ SDHCI_QUIRK2_STOP_WITH_TC,
294295 };
295296
296297 static u32 sdhci_arasan_cqhci_irq(struct sdhci_host *host, u32 intmask)
@@ -359,8 +360,7 @@ static const struct sdhci_pltfm_data sdhci_arasan_cqe_pdata = { · 62 unmodified lines
359360 */
360361 static int sdhci_arasan_suspend(struct device *dev)
361362 {
362− struct platform_device *pdev = to_platform_device(dev);
363− struct sdhci_host *host = platform_get_drvdata(pdev);
363+ struct sdhci_host *host = dev_get_drvdata(dev);
364364 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
365365 struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
366366 int ret;
@@ -403,8 +403,7 @@ static int sdhci_arasan_suspend(struct device *dev) · 36 unmodified lines
403403 */
404404 static int sdhci_arasan_resume(struct device *dev)
405405 {
406− struct platform_device *pdev = to_platform_device(dev);
407− struct sdhci_host *host = platform_get_drvdata(pdev);
406+ struct sdhci_host *host = dev_get_drvdata(dev);
408407 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
409408 struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
410409 int ret;
drivers/mmc/host/sdhci-omap.c+81−11
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 #include <linux/pm_runtime.h>
2727 #include <linux/regulator/consumer.h>
2828 #include <linux/pinctrl/consumer.h>
29+#include <linux/sys_soc.h>
2930
3031 #include "sdhci-pltfm.h"
3132
@@ -35,6 +36,7 @@ · 3 unmodified lines
3536 #define CON_DDR BIT(19)
3637 #define CON_CLKEXTFREE BIT(16)
3738 #define CON_PADEN BIT(15)
39+#define CON_CTPL BIT(11)
3840 #define CON_INIT BIT(1)
3941 #define CON_OD BIT(0)
4042
@@ -100,6 +102,7 @@ struct sdhci_omap_data { · 59 unmodified lines
100102 };
101103
102104 struct sdhci_omap_host {
105+ char *version;
103106 void __iomem *base;
104107 struct device *dev;
105108 struct regulator *pbias;
@@ -224,6 +227,23 @@ static void sdhci_omap_conf_bus_power(struct sdhci_omap_host *omap_host, · 118 unmodified lines
224227 }
225228 }
226229
230+static void sdhci_omap_enable_sdio_irq(struct mmc_host *mmc, int enable)
231+{
232+ struct sdhci_host *host = mmc_priv(mmc);
233+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
234+ struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host);
235+ u32 reg;
236+
237+ reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON);
238+ if (enable)
239+ reg |= (CON_CTPL | CON_CLKEXTFREE);
240+ else
241+ reg &= ~(CON_CTPL | CON_CLKEXTFREE);
242+ sdhci_omap_writel(omap_host, SDHCI_OMAP_CON, reg);
243+
244+ sdhci_enable_sdio_irq(mmc, enable);
245+}
246+
227247 static inline void sdhci_omap_set_dll(struct sdhci_omap_host *omap_host,
228248 int count)
229249 {
@@ -713,10 +733,15 @@ static const struct sdhci_pltfm_data sdhci_omap_pdata = { · 483 unmodified lines
713733 SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC,
714734 .quirks2 = SDHCI_QUIRK2_ACMD23_BROKEN |
715735 SDHCI_QUIRK2_PRESET_VALUE_BROKEN |
716− SDHCI_QUIRK2_RSP_136_HAS_CRC,
736+ SDHCI_QUIRK2_RSP_136_HAS_CRC |
737+ SDHCI_QUIRK2_DISABLE_HW_TIMEOUT,
717738 .ops = &sdhci_omap_ops,
718739 };
719740
741+static const struct sdhci_omap_data k2g_data = {
742+ .offset = 0x200,
743+};
744+
720745 static const struct sdhci_omap_data dra7_data = {
721746 .offset = 0x200,
722747 .flags = SDHCI_OMAP_REQUIRE_IODELAY,
@@ -724,6 +749,7 @@ static const struct sdhci_omap_data dra7_data = { · 1 unmodified line
724749
725750 static const struct of_device_id omap_sdhci_match[] = {
726751 { .compatible = "ti,dra7-sdhci", .data = &dra7_data },
752+ { .compatible = "ti,k2g-sdhci", .data = &k2g_data },
727753 {},
728754 };
729755 MODULE_DEVICE_TABLE(of, omap_sdhci_match);
@@ -733,12 +759,21 @@ static struct pinctrl_state · 3 unmodified lines
733759 u32 *caps, u32 capmask)
734760 {
735761 struct device *dev = omap_host->dev;
762+ char *version = omap_host->version;
736763 struct pinctrl_state *pinctrl_state = ERR_PTR(-ENODEV);
764+ char str[20];
737765
738766 if (!(*caps & capmask))
739767 goto ret;
740768
741− pinctrl_state = pinctrl_lookup_state(omap_host->pinctrl, mode);
769+ if (version) {
770+ snprintf(str, 20, "%s-%s", mode, version);
771+ pinctrl_state = pinctrl_lookup_state(omap_host->pinctrl, str);
772+ }
773+
774+ if (IS_ERR(pinctrl_state))
775+ pinctrl_state = pinctrl_lookup_state(omap_host->pinctrl, mode);
776+
742777 if (IS_ERR(pinctrl_state)) {
743778 dev_err(dev, "no pinctrl state for %s mode", mode);
744779 *caps &= ~capmask;
@@ -807,8 +842,15 @@ static int sdhci_omap_config_iodelay_pinctrl_state(struct sdhci_omap_host · 62 unmodified lines
807842
808843 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "ddr_1_8v", caps,
809844 MMC_CAP_1_8V_DDR);
810− if (!IS_ERR(state))
845+ if (!IS_ERR(state)) {
811846 pinctrl_state[MMC_TIMING_MMC_DDR52] = state;
847+ } else {
848+ state = sdhci_omap_iodelay_pinctrl_state(omap_host, "ddr_3_3v",
849+ caps,
850+ MMC_CAP_3_3V_DDR);
851+ if (!IS_ERR(state))
852+ pinctrl_state[MMC_TIMING_MMC_DDR52] = state;
853+ }
812854
813855 state = sdhci_omap_iodelay_pinctrl_state(omap_host, "hs", caps,
814856 MMC_CAP_SD_HIGHSPEED);
@@ -830,6 +872,16 @@ static int sdhci_omap_config_iodelay_pinctrl_state(struct sdhci_omap_host · 15 unmodified lines
830872 return 0;
831873 }
832874
875+static const struct soc_device_attribute sdhci_omap_soc_devices[] = {
876+ {
877+ .machine = "DRA7[45]*",
878+ .revision = "ES1.[01]",
879+ },
880+ {
881+ /* sentinel */
882+ }
883+};
884+
833885 static int sdhci_omap_probe(struct platform_device *pdev)
834886 {
835887 int ret;
@@ -841,6 +893,7 @@ static int sdhci_omap_probe(struct platform_device *pdev) · 5 unmodified lines
841893 struct mmc_host *mmc;
842894 const struct of_device_id *match;
843895 struct sdhci_omap_data *data;
896+ const struct soc_device_attribute *soc;
844897
845898 match = of_match_device(omap_sdhci_match, dev);
846899 if (!match)
@@ -871,10 +924,22 @@ static int sdhci_omap_probe(struct platform_device *pdev) · 24 unmodified lines
871924 host->ioaddr += offset;
872925
873926 mmc = host->mmc;
927+ sdhci_get_of_property(pdev);
874928 ret = mmc_of_parse(mmc);
875929 if (ret)
876930 goto err_pltfm_free;
877931
932+ soc = soc_device_match(sdhci_omap_soc_devices);
933+ if (soc) {
934+ omap_host->version = "rev11";
935+ if (!strcmp(dev_name(dev), "4809c000.mmc"))
936+ mmc->f_max = 96000000;
937+ if (!strcmp(dev_name(dev), "480b4000.mmc"))
938+ mmc->f_max = 48000000;
939+ if (!strcmp(dev_name(dev), "480ad000.mmc"))
940+ mmc->f_max = 48000000;
941+ }
942+
878943 pltfm_host->clk = devm_clk_get(dev, "fck");
879944 if (IS_ERR(pltfm_host->clk)) {
880945 ret = PTR_ERR(pltfm_host->clk);
@@ -916,26 +981,31 @@ static int sdhci_omap_probe(struct platform_device *pdev) · 35 unmodified lines
916981 goto err_put_sync;
917982 }
918983
919− ret = sdhci_omap_config_iodelay_pinctrl_state(omap_host);
920− if (ret)
921− goto err_put_sync;
922−
923984 host->mmc_host_ops.get_ro = mmc_gpio_get_ro;
924985 host->mmc_host_ops.start_signal_voltage_switch =
925986 sdhci_omap_start_signal_voltage_switch;
926987 host->mmc_host_ops.set_ios = sdhci_omap_set_ios;
927988 host->mmc_host_ops.card_busy = sdhci_omap_card_busy;
928989 host->mmc_host_ops.execute_tuning = sdhci_omap_execute_tuning;
990+ host->mmc_host_ops.enable_sdio_irq = sdhci_omap_enable_sdio_irq;
929991
930− sdhci_read_caps(host);
931− host->caps |= SDHCI_CAN_DO_ADMA2;
932−
933− ret = sdhci_add_host(host);
992+ ret = sdhci_setup_host(host);
934993 if (ret)
935994 goto err_put_sync;
936995
996+ ret = sdhci_omap_config_iodelay_pinctrl_state(omap_host);
997+ if (ret)
998+ goto err_cleanup_host;
999+
1000+ ret = __sdhci_add_host(host);
1001+ if (ret)
1002+ goto err_cleanup_host;
1003+
9371004 return 0;
9381005
1006+err_cleanup_host:
1007+ sdhci_cleanup_host(host);
1008+
9391009 err_put_sync:
9401010 pm_runtime_put_sync(dev);
9411011
drivers/mmc/host/sdhci-pci-core.c+31−7
@@ -453,6 +453,7 @@ static const struct sdhci_pci_fixes sdhci_intel_pch_sdio = { · 452 unmodified lines
453453 enum {
454454 INTEL_DSM_FNS = 0,
455455 INTEL_DSM_V18_SWITCH = 3,
456+ INTEL_DSM_V33_SWITCH = 4,
456457 INTEL_DSM_DRV_STRENGTH = 9,
457458 INTEL_DSM_D3_RETUNE = 10,
458459 };
@@ -620,17 +621,37 @@ static void intel_hs400_enhanced_strobe(struct mmc_host *mmc, · 161 unmodified lines
620621 sdhci_writel(host, val, INTEL_HS400_ES_REG);
621622 }
622623
623−static void sdhci_intel_voltage_switch(struct sdhci_host *host)
624+static int intel_start_signal_voltage_switch(struct mmc_host *mmc,
625+ struct mmc_ios *ios)
624626 {
627+ struct device *dev = mmc_dev(mmc);
628+ struct sdhci_host *host = mmc_priv(mmc);
625629 struct sdhci_pci_slot *slot = sdhci_priv(host);
626630 struct intel_host *intel_host = sdhci_pci_priv(slot);
627− struct device *dev = &slot->chip->pdev->dev;
631+ unsigned int fn;
628632 u32 result = 0;
629633 int err;
630634
631− err = intel_dsm(intel_host, dev, INTEL_DSM_V18_SWITCH, &result);
632− pr_debug("%s: %s DSM error %d result %u\n",
633− mmc_hostname(host->mmc), __func__, err, result);
635+ err = sdhci_start_signal_voltage_switch(mmc, ios);
636+ if (err)
637+ return err;
638+
639+ switch (ios->signal_voltage) {
640+ case MMC_SIGNAL_VOLTAGE_330:
641+ fn = INTEL_DSM_V33_SWITCH;
642+ break;
643+ case MMC_SIGNAL_VOLTAGE_180:
644+ fn = INTEL_DSM_V18_SWITCH;
645+ break;
646+ default:
647+ return 0;
648+ }
649+
650+ err = intel_dsm(intel_host, dev, fn, &result);
651+ pr_debug("%s: %s DSM fn %u error %d result %u\n",
652+ mmc_hostname(mmc), __func__, fn, err, result);
653+
654+ return 0;
634655 }
635656
636657 static const struct sdhci_ops sdhci_intel_byt_ops = {
@@ -641,7 +662,6 @@ static const struct sdhci_ops sdhci_intel_byt_ops = { · 4 unmodified lines
641662 .reset = sdhci_reset,
642663 .set_uhs_signaling = sdhci_set_uhs_signaling,
643664 .hw_reset = sdhci_pci_hw_reset,
644− .voltage_switch = sdhci_intel_voltage_switch,
645665 };
646666
647667 static const struct sdhci_ops sdhci_intel_glk_ops = {
@@ -652,7 +672,6 @@ static const struct sdhci_ops sdhci_intel_glk_ops = { · 4 unmodified lines
652672 .reset = sdhci_reset,
653673 .set_uhs_signaling = sdhci_set_uhs_signaling,
654674 .hw_reset = sdhci_pci_hw_reset,
655− .voltage_switch = sdhci_intel_voltage_switch,
656675 .irq = sdhci_cqhci_irq,
657676 };
658677
@@ -691,6 +710,7 @@ static void byt_probe_slot(struct sdhci_pci_slot *slot) · 32 unmodified lines
691710 byt_read_dsm(slot);
692711
693712 ops->execute_tuning = intel_execute_tuning;
713+ ops->start_signal_voltage_switch = intel_start_signal_voltage_switch;
694714 }
695715
696716 static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot)
@@ -832,6 +852,10 @@ static int byt_sd_probe_slot(struct sdhci_pci_slot *slot) · 135 unmodified lines
832852 slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_GLK_SD)
833853 slot->host->mmc_host_ops.get_cd = bxt_get_cd;
834854
855+ if (slot->chip->pdev->subsystem_vendor == PCI_VENDOR_ID_NI &&
856+ slot->chip->pdev->subsystem_device == PCI_SUBDEVICE_ID_NI_78E3)
857+ slot->host->mmc->caps2 |= MMC_CAP2_AVOID_3_3V;
858+
835859 return 0;
836860 }
837861
drivers/mmc/host/sdhci-pci.h+1−0
@@ -54,6 +54,7 @@ · 53 unmodified lines
5454 #define PCI_DEVICE_ID_REALTEK_5250 0x5250
5555
5656 #define PCI_SUBDEVICE_ID_NI_7884 0x7884
57+#define PCI_SUBDEVICE_ID_NI_78E3 0x78e3
5758
5859 #define PCI_VENDOR_ID_ARASAN 0x16e6
5960 #define PCI_DEVICE_ID_ARASAN_PHY_EMMC 0x0670
drivers/mmc/host/sdhci-pic32.c+1−3
@@ -200,10 +200,8 @@ static int pic32_sdhci_probe(struct platform_device *pdev) · 199 unmodified lines
200200 }
201201
202202 ret = sdhci_add_host(host);
203− if (ret) {
204− dev_err(&pdev->dev, "error adding host\n");
203+ if (ret)
205204 goto err_base_clk;
206− }
207205
208206 dev_info(&pdev->dev, "Successfully added sdhci host\n");
209207 return 0;
drivers/mmc/host/sdhci-pxav2.c+1−3
@@ -221,10 +221,8 @@ static int sdhci_pxav2_probe(struct platform_device *pdev) · 220 unmodified lines
221221 host->ops = &pxav2_sdhci_ops;
222222
223223 ret = sdhci_add_host(host);
224− if (ret) {
225− dev_err(&pdev->dev, "failed to add host\n");
224+ if (ret)
226225 goto disable_clk;
227− }
228226
229227 return 0;
230228
drivers/mmc/host/sdhci-pxav3.c+1−3
@@ -472,10 +472,8 @@ static int sdhci_pxav3_probe(struct platform_device *pdev) · 471 unmodified lines
472472 pm_suspend_ignore_children(&pdev->dev, 1);
473473
474474 ret = sdhci_add_host(host);
475− if (ret) {
476− dev_err(&pdev->dev, "failed to add host\n");
475+ if (ret)
477476 goto err_add_host;
478− }
479477
480478 if (host->mmc->pm_caps & MMC_PM_WAKE_SDIO_IRQ)
481479 device_init_wakeup(&pdev->dev, 1);
drivers/mmc/host/sdhci-s3c.c+1−3
@@ -655,10 +655,8 @@ static int sdhci_s3c_probe(struct platform_device *pdev) · 654 unmodified lines
655655 goto err_req_regs;
656656
657657 ret = sdhci_add_host(host);
658− if (ret) {
659− dev_err(dev, "sdhci_add_host() failed\n");
658+ if (ret)
660659 goto err_req_regs;
661− }
662660
663661 #ifdef CONFIG_PM
664662 if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
drivers/mmc/host/sdhci-spear.c+1−3
@@ -126,10 +126,8 @@ static int sdhci_probe(struct platform_device *pdev) · 125 unmodified lines
126126 }
127127
128128 ret = sdhci_add_host(host);
129− if (ret) {
130− dev_dbg(&pdev->dev, "error adding host\n");
129+ if (ret)
131130 goto disable_clk;
132− }
133131
134132 platform_set_drvdata(pdev, host);
135133
drivers/mmc/host/sdhci-st.c+1−3
@@ -422,10 +422,8 @@ static int sdhci_st_probe(struct platform_device *pdev) · 421 unmodified lines
422422 st_mmcss_cconfig(np, host);
423423
424424 ret = sdhci_add_host(host);
425− if (ret) {
426− dev_err(&pdev->dev, "Failed sdhci_add_host\n");
425+ if (ret)
427426 goto err_out;
428− }
429427
430428 host_version = readw_relaxed((host->ioaddr + SDHCI_HOST_VERSION));
431429
drivers/mmc/host/sdhci-tegra.c+1−1
@@ -231,7 +231,7 @@ static void tegra_sdhci_set_uhs_signaling(struct sdhci_host *host, · 230 unmodified lines
231231 if (timing == MMC_TIMING_UHS_DDR50)
232232 tegra_host->ddr_signaling = true;
233233
234− return sdhci_set_uhs_signaling(host, timing);
234+ sdhci_set_uhs_signaling(host, timing);
235235 }
236236
237237 static unsigned int tegra_sdhci_get_max_clock(struct sdhci_host *host)
drivers/mmc/host/sdhci-xenon-phy.c+3−8
@@ -814,15 +814,10 @@ static int xenon_add_phy(struct device_node *np, struct sdhci_host *host, · 813 unmodified lines
814814 {
815815 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
816816 struct xenon_priv *priv = sdhci_pltfm_priv(pltfm_host);
817− int i, ret;
817+ int ret;
818818
819− for (i = 0; i < NR_PHY_TYPES; i++) {
820− if (!strcmp(phy_name, phy_types[i])) {
821− priv->phy_type = i;
822− break;
823− }
824− }
825− if (i == NR_PHY_TYPES) {
819+ priv->phy_type = match_string(phy_types, NR_PHY_TYPES, phy_name);
820+ if (priv->phy_type < 0) {
826821 dev_err(mmc_dev(host->mmc),
827822 "Unable to determine PHY name %s. Use default eMMC 5.1 PHY\n",
828823 phy_name);
drivers/mmc/host/sdhci.c+119−29
@@ -709,29 +709,16 @@ static u32 sdhci_sdma_address(struct sdhci_host *host) · 708 unmodified lines
709709 return sg_dma_address(host->data->sg);
710710 }
711711
712−static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd)
712+static unsigned int sdhci_target_timeout(struct sdhci_host *host,
713+ struct mmc_command *cmd,
714+ struct mmc_data *data)
713715 {
714− u8 count;
715− struct mmc_data *data = cmd->data;
716− unsigned target_timeout, current_timeout;
717−
718− /*
719− * If the host controller provides us with an incorrect timeout
720− * value, just skip the check and use 0xE. The hardware may take
721− * longer to time out, but that's much better than having a too-short
722− * timeout value.
723− */
724− if (host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL)
725− return 0xE;
726−
727− /* Unspecified timeout, assume max */
728− if (!data && !cmd->busy_timeout)
729− return 0xE;
716+ unsigned int target_timeout;
730717
731718 /* timeout in us */
732− if (!data)
719+ if (!data) {
733720 target_timeout = cmd->busy_timeout * 1000;
734− else {
721+ } else {
735722 target_timeout = DIV_ROUND_UP(data->timeout_ns, 1000);
736723 if (host->clock && data->timeout_clks) {
737724 unsigned long long val;
@@ -748,6 +735,67 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd) · 10 unmodified lines
748735 }
749736 }
750737
738+ return target_timeout;
739+}
740+
741+static void sdhci_calc_sw_timeout(struct sdhci_host *host,
742+ struct mmc_command *cmd)
743+{
744+ struct mmc_data *data = cmd->data;
745+ struct mmc_host *mmc = host->mmc;
746+ struct mmc_ios *ios = &mmc->ios;
747+ unsigned char bus_width = 1 << ios->bus_width;
748+ unsigned int blksz;
749+ unsigned int freq;
750+ u64 target_timeout;
751+ u64 transfer_time;
752+
753+ target_timeout = sdhci_target_timeout(host, cmd, data);
754+ target_timeout *= NSEC_PER_USEC;
755+
756+ if (data) {
757+ blksz = data->blksz;
758+ freq = host->mmc->actual_clock ? : host->clock;
759+ transfer_time = (u64)blksz * NSEC_PER_SEC * (8 / bus_width);
760+ do_div(transfer_time, freq);
761+ /* multiply by '2' to account for any unknowns */
762+ transfer_time = transfer_time * 2;
763+ /* calculate timeout for the entire data */
764+ host->data_timeout = data->blocks * target_timeout +
765+ transfer_time;
766+ } else {
767+ host->data_timeout = target_timeout;
768+ }
769+
770+ if (host->data_timeout)
771+ host->data_timeout += MMC_CMD_TRANSFER_TIME;
772+}
773+
774+static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd,
775+ bool *too_big)
776+{
777+ u8 count;
778+ struct mmc_data *data = cmd->data;
779+ unsigned target_timeout, current_timeout;
780+
781+ *too_big = true;
782+
783+ /*
784+ * If the host controller provides us with an incorrect timeout
785+ * value, just skip the check and use 0xE. The hardware may take
786+ * longer to time out, but that's much better than having a too-short
787+ * timeout value.
788+ */
789+ if (host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL)
790+ return 0xE;
791+
792+ /* Unspecified timeout, assume max */
793+ if (!data && !cmd->busy_timeout)
794+ return 0xE;
795+
796+ /* timeout in us */
797+ target_timeout = sdhci_target_timeout(host, cmd, data);
798+
751799 /*
752800 * Figure out needed cycles.
753801 * We do this in steps in order to fit inside a 32 bit int.
@@ -768,9 +816,12 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd) · 14 unmodified lines
768816 }
769817
770818 if (count >= 0xF) {
771− DBG("Too large timeout 0x%x requested for CMD%d!\n",
772− count, cmd->opcode);
819+ if (!(host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT))
820+ DBG("Too large timeout 0x%x requested for CMD%d!\n",
821+ count, cmd->opcode);
773822 count = 0xE;
823+ } else {
824+ *too_big = false;
774825 }
775826
776827 return count;
@@ -790,6 +841,16 @@ static void sdhci_set_transfer_irqs(struct sdhci_host *host) · 13 unmodified lines
790841 sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
791842 }
792843
844+static void sdhci_set_data_timeout_irq(struct sdhci_host *host, bool enable)
845+{
846+ if (enable)
847+ host->ier |= SDHCI_INT_DATA_TIMEOUT;
848+ else
849+ host->ier &= ~SDHCI_INT_DATA_TIMEOUT;
850+ sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
851+ sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
852+}
853+
793854 static void sdhci_set_timeout(struct sdhci_host *host, struct mmc_command *cmd)
794855 {
795856 u8 count;
@@ -797,7 +858,18 @@ static void sdhci_set_timeout(struct sdhci_host *host, struct mmc_command *cmd) · 1 unmodified line
797858 if (host->ops->set_timeout) {
798859 host->ops->set_timeout(host, cmd);
799860 } else {
800− count = sdhci_calc_timeout(host, cmd);
861+ bool too_big = false;
862+
863+ count = sdhci_calc_timeout(host, cmd, &too_big);
864+
865+ if (too_big &&
866+ host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT) {
867+ sdhci_calc_sw_timeout(host, cmd);
868+ sdhci_set_data_timeout_irq(host, false);
869+ } else if (!(host->ier & SDHCI_INT_DATA_TIMEOUT)) {
870+ sdhci_set_data_timeout_irq(host, true);
871+ }
872+
801873 sdhci_writeb(host, count, SDHCI_TIMEOUT_CONTROL);
802874 }
803875 }
@@ -807,6 +879,8 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) · 3 unmodified lines
807879 u8 ctrl;
808880 struct mmc_data *data = cmd->data;
809881
882+ host->data_timeout = 0;
883+
810884 if (sdhci_data_line_cmd(cmd))
811885 sdhci_set_timeout(host, cmd);
812886
@@ -1160,13 +1234,6 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) · 347 unmodified lines
11601234 mdelay(1);
11611235 }
11621236
1163− timeout = jiffies;
1164− if (!cmd->data && cmd->busy_timeout > 9000)
1165− timeout += DIV_ROUND_UP(cmd->busy_timeout, 1000) * HZ + HZ;
1166− else
1167− timeout += 10 * HZ;
1168− sdhci_mod_timer(host, cmd->mrq, timeout);
1169−
11701237 host->cmd = cmd;
11711238 if (sdhci_data_line_cmd(cmd)) {
11721239 WARN_ON(host->data_cmd);
@@ -1206,6 +1273,15 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) · 33 unmodified lines
12061273 cmd->opcode == MMC_SEND_TUNING_BLOCK_HS200)
12071274 flags |= SDHCI_CMD_DATA;
12081275
1276+ timeout = jiffies;
1277+ if (host->data_timeout)
1278+ timeout += nsecs_to_jiffies(host->data_timeout);
1279+ else if (!cmd->data && cmd->busy_timeout > 9000)
1280+ timeout += DIV_ROUND_UP(cmd->busy_timeout, 1000) * HZ + HZ;
1281+ else
1282+ timeout += 10 * HZ;
1283+ sdhci_mod_timer(host, cmd->mrq, timeout);
1284+
12091285 sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND);
12101286 }
12111287 EXPORT_SYMBOL_GPL(sdhci_send_command);
@@ -3616,6 +3692,10 @@ int sdhci_setup_host(struct sdhci_host *host) · 2404 unmodified lines
36163692 mmc->max_busy_timeout /= host->timeout_clk;
36173693 }
36183694
3695+ if (host->quirks2 & SDHCI_QUIRK2_DISABLE_HW_TIMEOUT &&
3696+ !host->ops->get_max_timeout_count)
3697+ mmc->max_busy_timeout = 0;
3698+
36193699 mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23;
36203700 mmc->caps2 |= MMC_CAP2_SDIO_IRQ_NOTHREAD;
36213701
@@ -3672,6 +3752,16 @@ int sdhci_setup_host(struct sdhci_host *host) · 50 unmodified lines
36723752 if (host->quirks2 & SDHCI_QUIRK2_NO_1_8_V) {
36733753 host->caps1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 |
36743754 SDHCI_SUPPORT_DDR50);
3755+ /*
3756+ * The SDHCI controller in a SoC might support HS200/HS400
3757+ * (indicated using mmc-hs200-1_8v/mmc-hs400-1_8v dt property),
3758+ * but if the board is modeled such that the IO lines are not
3759+ * connected to 1.8v then HS200/HS400 cannot be supported.
3760+ * Disable HS200/HS400 if the board does not have 1.8v connected
3761+ * to the IO lines. (Applicable for other modes in 1.8v)
3762+ */
3763+ mmc->caps2 &= ~(MMC_CAP2_HSX00_1_8V | MMC_CAP2_HS400_ES);
3764+ mmc->caps &= ~(MMC_CAP_1_8V_DDR | MMC_CAP_UHS);
36753765 }
36763766
36773767 /* Any UHS-I mode in caps implies SDR12 and SDR25 support. */
drivers/mmc/host/sdhci.h+15−0
@@ -332,6 +332,14 @@ struct sdhci_adma2_64_desc { · 331 unmodified lines
332332 /* Allow for a a command request and a data request at the same time */
333333 #define SDHCI_MAX_MRQS 2
334334
335+/*
336+ * 48bit command and 136 bit response in 100KHz clock could take upto 2.48ms.
337+ * However since the start time of the command, the time between
338+ * command and response, and the time between response and start of data is
339+ * not known, set the command transfer time to 10ms.
340+ */
341+#define MMC_CMD_TRANSFER_TIME (10 * NSEC_PER_MSEC) /* max 10 ms */
342+
335343 enum sdhci_cookie {
336344 COOKIE_UNMAPPED,
337345 COOKIE_PRE_MAPPED, /* mapped by sdhci_pre_req() */
@@ -437,6 +445,11 @@ struct sdhci_host { · 99 unmodified lines
437445 #define SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN (1<<15)
438446 /* Controller has CRC in 136 bit Command Response */
439447 #define SDHCI_QUIRK2_RSP_136_HAS_CRC (1<<16)
448+/*
449+ * Disable HW timeout if the requested timeout is more than the maximum
450+ * obtainable timeout.
451+ */
452+#define SDHCI_QUIRK2_DISABLE_HW_TIMEOUT (1<<17)
440453
441454 int irq; /* Device IRQ */
442455 void __iomem *ioaddr; /* Mapped address */
@@ -550,6 +563,8 @@ struct sdhci_host { · 107 unmodified lines
550563 /* Host SDMA buffer boundary. */
551564 u32 sdma_boundary;
552565
566+ u64 data_timeout;
567+
553568 unsigned long private[0] ____cacheline_aligned;
554569 };
555570
drivers/mmc/host/sunxi-mmc.c+124−63
@@ -13,36 +13,34 @@ · 12 unmodified lines
1313 * the License, or (at your option) any later version.
1414 */
1515
16−#include <linux/kernel.h>
17−#include <linux/module.h>
18−#include <linux/io.h>
19−#include <linux/device.h>
20−#include <linux/interrupt.h>
21−#include <linux/delay.h>
22−#include <linux/err.h>
23−
2416 #include <linux/clk.h>
2517 #include <linux/clk/sunxi-ng.h>
26−#include <linux/gpio.h>
27−#include <linux/platform_device.h>
28−#include <linux/spinlock.h>
29−#include <linux/scatterlist.h>
18+#include <linux/delay.h>
19+#include <linux/device.h>
3020 #include <linux/dma-mapping.h>
31−#include <linux/slab.h>
32−#include <linux/reset.h>
33−#include <linux/regulator/consumer.h>
34−
35−#include <linux/of_address.h>
36−#include <linux/of_gpio.h>
37−#include <linux/of_platform.h>
38−
21+#include <linux/err.h>
22+#include <linux/gpio.h>
23+#include <linux/interrupt.h>
24+#include <linux/io.h>
25+#include <linux/kernel.h>
26+#include <linux/mmc/card.h>
27+#include <linux/mmc/core.h>
3928 #include <linux/mmc/host.h>
29+#include <linux/mmc/mmc.h>
4030 #include <linux/mmc/sd.h>
4131 #include <linux/mmc/sdio.h>
42−#include <linux/mmc/mmc.h>
43−#include <linux/mmc/core.h>
44−#include <linux/mmc/card.h>
4532 #include <linux/mmc/slot-gpio.h>
33+#include <linux/module.h>
34+#include <linux/of_address.h>
35+#include <linux/of_gpio.h>
36+#include <linux/of_platform.h>
37+#include <linux/platform_device.h>
38+#include <linux/pm_runtime.h>
39+#include <linux/regulator/consumer.h>
40+#include <linux/reset.h>
41+#include <linux/scatterlist.h>
42+#include <linux/slab.h>
43+#include <linux/spinlock.h>
4644
4745 /* register offset definitions */
4846 #define SDXC_REG_GCTRL (0x00) /* SMC Global Control Register */
@@ -322,10 +320,9 @@ static int sunxi_mmc_reset_host(struct sunxi_mmc_host *host) · 273 unmodified lines
322320 return 0;
323321 }
324322
325−static int sunxi_mmc_init_host(struct mmc_host *mmc)
323+static int sunxi_mmc_init_host(struct sunxi_mmc_host *host)
326324 {
327325 u32 rval;
328− struct sunxi_mmc_host *host = mmc_priv(mmc);
329326
330327 if (sunxi_mmc_reset_host(host))
331328 return -EIO;
@@ -859,17 +856,48 @@ static int sunxi_mmc_clk_set_rate(struct sunxi_mmc_host *host, · 527 unmodified lines
859856 return 0;
860857 }
861858
862−static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
859+static void sunxi_mmc_set_bus_width(struct sunxi_mmc_host *host,
860+ unsigned char width)
861+{
862+ switch (width) {
863+ case MMC_BUS_WIDTH_1:
864+ mmc_writel(host, REG_WIDTH, SDXC_WIDTH1);
865+ break;
866+ case MMC_BUS_WIDTH_4:
867+ mmc_writel(host, REG_WIDTH, SDXC_WIDTH4);
868+ break;
869+ case MMC_BUS_WIDTH_8:
870+ mmc_writel(host, REG_WIDTH, SDXC_WIDTH8);
871+ break;
872+ }
873+}
874+
875+static void sunxi_mmc_set_clk(struct sunxi_mmc_host *host, struct mmc_ios *ios)
863876 {
864− struct sunxi_mmc_host *host = mmc_priv(mmc);
865877 u32 rval;
866878
867− /* Set the power state */
868− switch (ios->power_mode) {
869− case MMC_POWER_ON:
870− break;
879+ /* set ddr mode */
880+ rval = mmc_readl(host, REG_GCTRL);
881+ if (ios->timing == MMC_TIMING_UHS_DDR50 ||
882+ ios->timing == MMC_TIMING_MMC_DDR52)
883+ rval |= SDXC_DDR_MODE;
884+ else
885+ rval &= ~SDXC_DDR_MODE;
886+ mmc_writel(host, REG_GCTRL, rval);
887+
888+ host->ferror = sunxi_mmc_clk_set_rate(host, ios);
889+ /* Android code had a usleep_range(50000, 55000); here */
890+}
871891
892+static void sunxi_mmc_card_power(struct sunxi_mmc_host *host,
893+ struct mmc_ios *ios)
894+{
895+ struct mmc_host *mmc = host->mmc;
896+
897+ switch (ios->power_mode) {
872898 case MMC_POWER_UP:
899+ dev_dbg(mmc_dev(mmc), "Powering card up\n");
900+
873901 if (!IS_ERR(mmc->supply.vmmc)) {
874902 host->ferror = mmc_regulator_set_ocr(mmc,
875903 mmc->supply.vmmc,
@@ -887,53 +915,33 @@ static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) · 11 unmodified lines
887915 }
888916 host->vqmmc_enabled = true;
889917 }
890−
891− host->ferror = sunxi_mmc_init_host(mmc);
892− if (host->ferror)
893− return;
894−
895− dev_dbg(mmc_dev(mmc), "power on!\n");
896918 break;
897919
898920 case MMC_POWER_OFF:
899− dev_dbg(mmc_dev(mmc), "power off!\n");
900− sunxi_mmc_reset_host(host);
921+ dev_dbg(mmc_dev(mmc), "Powering card off\n");
922+
901923 if (!IS_ERR(mmc->supply.vmmc))
902924 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
903925
904926 if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled)
905927 regulator_disable(mmc->supply.vqmmc);
928+
906929 host->vqmmc_enabled = false;
907930 break;
908− }
909931
910− /* set bus width */
911− switch (ios->bus_width) {
912− case MMC_BUS_WIDTH_1:
913− mmc_writel(host, REG_WIDTH, SDXC_WIDTH1);
914− break;
915− case MMC_BUS_WIDTH_4:
916− mmc_writel(host, REG_WIDTH, SDXC_WIDTH4);
917− break;
918− case MMC_BUS_WIDTH_8:
919− mmc_writel(host, REG_WIDTH, SDXC_WIDTH8);
932+ default:
933+ dev_dbg(mmc_dev(mmc), "Ignoring unknown card power state\n");
920934 break;
921935 }
936+}
922937
923− /* set ddr mode */
924− rval = mmc_readl(host, REG_GCTRL);
925− if (ios->timing == MMC_TIMING_UHS_DDR50 ||
926− ios->timing == MMC_TIMING_MMC_DDR52)
927− rval |= SDXC_DDR_MODE;
928− else
929− rval &= ~SDXC_DDR_MODE;
930− mmc_writel(host, REG_GCTRL, rval);
938+static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
939+{
940+ struct sunxi_mmc_host *host = mmc_priv(mmc);
931941
932− /* set up clock */
933− if (ios->power_mode) {
934− host->ferror = sunxi_mmc_clk_set_rate(host, ios);
935− /* Android code had a usleep_range(50000, 55000); here */
936− }
942+ sunxi_mmc_card_power(host, ios);
943+ sunxi_mmc_set_bus_width(host, ios->bus_width);
944+ sunxi_mmc_set_clk(host, ios);
937945 }
938946
939947 static int sunxi_mmc_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
@@ -955,6 +963,9 @@ static void sunxi_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable) · 15 unmodified lines
955963 unsigned long flags;
956964 u32 imask;
957965
966+ if (enable)
967+ pm_runtime_get_noresume(host->dev);
968+
958969 spin_lock_irqsave(&host->lock, flags);
959970
960971 imask = mmc_readl(host, REG_IMASK);
@@ -967,6 +978,9 @@ static void sunxi_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable) · 6 unmodified lines
967978 }
968979 mmc_writel(host, REG_IMASK, imask);
969980 spin_unlock_irqrestore(&host->lock, flags);
981+
982+ if (!enable)
983+ pm_runtime_put_noidle(host->mmc->parent);
970984 }
971985
972986 static void sunxi_mmc_hw_reset(struct mmc_host *mmc)
@@ -1380,6 +1394,15 @@ static int sunxi_mmc_probe(struct platform_device *pdev) · 407 unmodified lines
13801394 if (ret)
13811395 goto error_free_dma;
13821396
1397+ ret = sunxi_mmc_init_host(host);
1398+ if (ret)
1399+ goto error_free_dma;
1400+
1401+ pm_runtime_set_active(&pdev->dev);
1402+ pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
1403+ pm_runtime_use_autosuspend(&pdev->dev);
1404+ pm_runtime_enable(&pdev->dev);
1405+
13831406 ret = mmc_add_host(mmc);
13841407 if (ret)
13851408 goto error_free_dma;
@@ -1400,6 +1423,7 @@ static int sunxi_mmc_remove(struct platform_device *pdev) · 14 unmodified lines
14001423 struct sunxi_mmc_host *host = mmc_priv(mmc);
14011424
14021425 mmc_remove_host(mmc);
1426+ pm_runtime_force_suspend(&pdev->dev);
14031427 disable_irq(host->irq);
14041428 sunxi_mmc_disable(host);
14051429 dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
@@ -1408,10 +1432,47 @@ static int sunxi_mmc_remove(struct platform_device *pdev) · 2 unmodified lines
14081432 return 0;
14091433 }
14101434
1435+#ifdef CONFIG_PM
1436+static int sunxi_mmc_runtime_resume(struct device *dev)
1437+{
1438+ struct mmc_host *mmc = dev_get_drvdata(dev);
1439+ struct sunxi_mmc_host *host = mmc_priv(mmc);
1440+ int ret;
1441+
1442+ ret = sunxi_mmc_enable(host);
1443+ if (ret)
1444+ return ret;
1445+
1446+ sunxi_mmc_init_host(host);
1447+ sunxi_mmc_set_bus_width(host, mmc->ios.bus_width);
1448+ sunxi_mmc_set_clk(host, &mmc->ios);
1449+
1450+ return 0;
1451+}
1452+
1453+static int sunxi_mmc_runtime_suspend(struct device *dev)
1454+{
1455+ struct mmc_host *mmc = dev_get_drvdata(dev);
1456+ struct sunxi_mmc_host *host = mmc_priv(mmc);
1457+
1458+ sunxi_mmc_reset_host(host);
1459+ sunxi_mmc_disable(host);
1460+
1461+ return 0;
1462+}
1463+#endif
1464+
1465+static const struct dev_pm_ops sunxi_mmc_pm_ops = {
1466+ SET_RUNTIME_PM_OPS(sunxi_mmc_runtime_suspend,
1467+ sunxi_mmc_runtime_resume,
1468+ NULL)
1469+};
1470+
14111471 static struct platform_driver sunxi_mmc_driver = {
14121472 .driver = {
14131473 .name = "sunxi-mmc",
14141474 .of_match_table = of_match_ptr(sunxi_mmc_of_match),
1475+ .pm = &sunxi_mmc_pm_ops,
14151476 },
14161477 .probe = sunxi_mmc_probe,
14171478 .remove = sunxi_mmc_remove,
drivers/mmc/host/ushc.c+3−1
@@ -300,8 +300,10 @@ static void ushc_request(struct mmc_host *mmc, struct mmc_request *req) · 299 unmodified lines
300300 pipe = usb_sndbulkpipe(ushc->usb_dev, 2);
301301
302302 usb_fill_bulk_urb(ushc->data_urb, ushc->usb_dev, pipe,
303− sg_virt(data->sg), data->sg->length,
303+ NULL, data->sg->length,
304304 data_callback, ushc);
305+ ushc->data_urb->num_sgs = 1;
306+ ushc->data_urb->sg = data->sg;
305307 ret = usb_submit_urb(ushc->data_urb, GFP_ATOMIC);
306308 if (ret < 0)
307309 goto out;
drivers/mmc/host/wbsd.c+30−38
@@ -268,43 +268,29 @@ static inline int wbsd_next_sg(struct wbsd_host *host) · 267 unmodified lines
268268 return host->num_sg;
269269 }
270270
271−static inline char *wbsd_sg_to_buffer(struct wbsd_host *host)
271+static inline char *wbsd_map_sg(struct wbsd_host *host)
272272 {
273− return sg_virt(host->cur_sg);
273+ return kmap_atomic(sg_page(host->cur_sg)) + host->cur_sg->offset;
274274 }
275275
276276 static inline void wbsd_sg_to_dma(struct wbsd_host *host, struct mmc_data *data)
277277 {
278− unsigned int len, i;
279− struct scatterlist *sg;
280− char *dmabuf = host->dma_buffer;
281− char *sgbuf;
282−
283− sg = data->sg;
284− len = data->sg_len;
285−
286− for (i = 0; i < len; i++) {
287− sgbuf = sg_virt(&sg[i]);
288− memcpy(dmabuf, sgbuf, sg[i].length);
289− dmabuf += sg[i].length;
290− }
278+ size_t len = 0;
279+ int i;
280+
281+ for (i = 0; i < data->sg_len; i++)
282+ len += data->sg[i].length;
283+ sg_copy_to_buffer(data->sg, data->sg_len, host->dma_buffer, len);
291284 }
292285
293286 static inline void wbsd_dma_to_sg(struct wbsd_host *host, struct mmc_data *data)
294287 {
295− unsigned int len, i;
296− struct scatterlist *sg;
297− char *dmabuf = host->dma_buffer;
298− char *sgbuf;
299−
300− sg = data->sg;
301− len = data->sg_len;
302−
303− for (i = 0; i < len; i++) {
304− sgbuf = sg_virt(&sg[i]);
305− memcpy(sgbuf, dmabuf, sg[i].length);
306− dmabuf += sg[i].length;
307− }
288+ size_t len = 0;
289+ int i;
290+
291+ for (i = 0; i < data->sg_len; i++)
292+ len += data->sg[i].length;
293+ sg_copy_from_buffer(data->sg, data->sg_len, host->dma_buffer, len);
308294 }
309295
310296 /*
@@ -418,7 +404,7 @@ static void wbsd_empty_fifo(struct wbsd_host *host) · 107 unmodified lines
418404 {
419405 struct mmc_data *data = host->mrq->cmd->data;
420406 char *buffer;
421− int i, fsr, fifo;
407+ int i, idx, fsr, fifo;
422408
423409 /*
424410 * Handle excessive data.
@@ -426,7 +412,8 @@ static void wbsd_empty_fifo(struct wbsd_host *host) · 1 unmodified line
426412 if (host->num_sg == 0)
427413 return;
428414
429− buffer = wbsd_sg_to_buffer(host) + host->offset;
415+ buffer = wbsd_map_sg(host) + host->offset;
416+ idx = 0;
430417
431418 /*
432419 * Drain the fifo. This has a tendency to loop longer
@@ -445,8 +432,7 @@ static void wbsd_empty_fifo(struct wbsd_host *host) · 12 unmodified lines
445432 fifo = 1;
446433
447434 for (i = 0; i < fifo; i++) {
448− *buffer = inb(host->base + WBSD_DFR);
449− buffer++;
435+ buffer[idx++] = inb(host->base + WBSD_DFR);
450436 host->offset++;
451437 host->remain--;
452438
@@ -456,16 +442,19 @@ static void wbsd_empty_fifo(struct wbsd_host *host) · 3 unmodified lines
456442 * End of scatter list entry?
457443 */
458444 if (host->remain == 0) {
445+ kunmap_atomic(buffer);
459446 /*
460447 * Get next entry. Check if last.
461448 */
462449 if (!wbsd_next_sg(host))
463450 return;
464451
465− buffer = wbsd_sg_to_buffer(host);
452+ buffer = wbsd_map_sg(host);
453+ idx = 0;
466454 }
467455 }
468456 }
457+ kunmap_atomic(buffer);
469458
470459 /*
471460 * This is a very dirty hack to solve a
@@ -480,7 +469,7 @@ static void wbsd_fill_fifo(struct wbsd_host *host) · 8 unmodified lines
480469 {
481470 struct mmc_data *data = host->mrq->cmd->data;
482471 char *buffer;
483− int i, fsr, fifo;
472+ int i, idx, fsr, fifo;
484473
485474 /*
486475 * Check that we aren't being called after the
@@ -489,7 +478,8 @@ static void wbsd_fill_fifo(struct wbsd_host *host) · 2 unmodified lines
489478 if (host->num_sg == 0)
490479 return;
491480
492− buffer = wbsd_sg_to_buffer(host) + host->offset;
481+ buffer = wbsd_map_sg(host) + host->offset;
482+ idx = 0;
493483
494484 /*
495485 * Fill the fifo. This has a tendency to loop longer
@@ -508,8 +498,7 @@ static void wbsd_fill_fifo(struct wbsd_host *host) · 12 unmodified lines
508498 fifo = 15;
509499
510500 for (i = 16; i > fifo; i--) {
511− outb(*buffer, host->base + WBSD_DFR);
512− buffer++;
501+ outb(buffer[idx], host->base + WBSD_DFR);
513502 host->offset++;
514503 host->remain--;
515504
@@ -519,16 +508,19 @@ static void wbsd_fill_fifo(struct wbsd_host *host) · 3 unmodified lines
519508 * End of scatter list entry?
520509 */
521510 if (host->remain == 0) {
511+ kunmap_atomic(buffer);
522512 /*
523513 * Get next entry. Check if last.
524514 */
525515 if (!wbsd_next_sg(host))
526516 return;
527517
528− buffer = wbsd_sg_to_buffer(host);
518+ buffer = wbsd_map_sg(host);
519+ idx = 0;
529520 }
530521 }
531522 }
523+ kunmap_atomic(buffer);
532524
533525 /*
534526 * The controller stops sending interrupts for
drivers/mmc/host/wmt-sdmmc.c+2−4
@@ -928,8 +928,7 @@ static int wmt_mci_remove(struct platform_device *pdev) · 927 unmodified lines
928928 static int wmt_mci_suspend(struct device *dev)
929929 {
930930 u32 reg_tmp;
931− struct platform_device *pdev = to_platform_device(dev);
932− struct mmc_host *mmc = platform_get_drvdata(pdev);
931+ struct mmc_host *mmc = dev_get_drvdata(dev);
933932 struct wmt_mci_priv *priv;
934933
935934 if (!mmc)
@@ -953,8 +952,7 @@ static int wmt_mci_suspend(struct device *dev) · 17 unmodified lines
953952 static int wmt_mci_resume(struct device *dev)
954953 {
955954 u32 reg_tmp;
956− struct platform_device *pdev = to_platform_device(dev);
957− struct mmc_host *mmc = platform_get_drvdata(pdev);
955+ struct mmc_host *mmc = dev_get_drvdata(dev);
958956 struct wmt_mci_priv *priv;
959957
960958 if (mmc) {
include/dt-bindings/dma/jz4780-dma.h+49−0
@@ -0,0 +1,49 @@
1+#ifndef __DT_BINDINGS_DMA_JZ4780_DMA_H__
2+#define __DT_BINDINGS_DMA_JZ4780_DMA_H__
3+
4+/*
5+ * Request type numbers for the JZ4780 DMA controller (written to the DRTn
6+ * register for the channel).
7+ */
8+#define JZ4780_DMA_I2S1_TX 0x4
9+#define JZ4780_DMA_I2S1_RX 0x5
10+#define JZ4780_DMA_I2S0_TX 0x6
11+#define JZ4780_DMA_I2S0_RX 0x7
12+#define JZ4780_DMA_AUTO 0x8
13+#define JZ4780_DMA_SADC_RX 0x9
14+#define JZ4780_DMA_UART4_TX 0xc
15+#define JZ4780_DMA_UART4_RX 0xd
16+#define JZ4780_DMA_UART3_TX 0xe
17+#define JZ4780_DMA_UART3_RX 0xf
18+#define JZ4780_DMA_UART2_TX 0x10
19+#define JZ4780_DMA_UART2_RX 0x11
20+#define JZ4780_DMA_UART1_TX 0x12
21+#define JZ4780_DMA_UART1_RX 0x13
22+#define JZ4780_DMA_UART0_TX 0x14
23+#define JZ4780_DMA_UART0_RX 0x15
24+#define JZ4780_DMA_SSI0_TX 0x16
25+#define JZ4780_DMA_SSI0_RX 0x17
26+#define JZ4780_DMA_SSI1_TX 0x18
27+#define JZ4780_DMA_SSI1_RX 0x19
28+#define JZ4780_DMA_MSC0_TX 0x1a
29+#define JZ4780_DMA_MSC0_RX 0x1b
30+#define JZ4780_DMA_MSC1_TX 0x1c
31+#define JZ4780_DMA_MSC1_RX 0x1d
32+#define JZ4780_DMA_MSC2_TX 0x1e
33+#define JZ4780_DMA_MSC2_RX 0x1f
34+#define JZ4780_DMA_PCM0_TX 0x20
35+#define JZ4780_DMA_PCM0_RX 0x21
36+#define JZ4780_DMA_SMB0_TX 0x24
37+#define JZ4780_DMA_SMB0_RX 0x25
38+#define JZ4780_DMA_SMB1_TX 0x26
39+#define JZ4780_DMA_SMB1_RX 0x27
40+#define JZ4780_DMA_SMB2_TX 0x28
41+#define JZ4780_DMA_SMB2_RX 0x29
42+#define JZ4780_DMA_SMB3_TX 0x2a
43+#define JZ4780_DMA_SMB3_RX 0x2b
44+#define JZ4780_DMA_SMB4_TX 0x2c
45+#define JZ4780_DMA_SMB4_RX 0x2d
46+#define JZ4780_DMA_DES_TX 0x2e
47+#define JZ4780_DMA_DES_RX 0x2f
48+
49+#endif /* __DT_BINDINGS_DMA_JZ4780_DMA_H__ */
include/linux/mmc/card.h+2−0
@@ -156,6 +156,7 @@ struct sd_switch_caps { · 155 unmodified lines
156156 #define UHS_DDR50_MAX_DTR 50000000
157157 #define UHS_SDR25_MAX_DTR UHS_DDR50_MAX_DTR
158158 #define UHS_SDR12_MAX_DTR 25000000
159+#define DEFAULT_SPEED_MAX_DTR UHS_SDR12_MAX_DTR
159160 unsigned int sd3_bus_mode;
160161 #define UHS_SDR12_BUS_SPEED 0
161162 #define HIGH_SPEED_BUS_SPEED 1
@@ -252,6 +253,7 @@ struct mmc_card { · 90 unmodified lines
252253 #define MMC_TYPE_SD_COMBO 3 /* SD combo (IO+mem) card */
253254 unsigned int state; /* (our) card state */
254255 unsigned int quirks; /* card quirks */
256+ unsigned int quirk_max_rate; /* max rate set by quirks */
255257 #define MMC_QUIRK_LENIENT_FN0 (1<<0) /* allow SDIO FN0 writes outside of the VS CCCR range */
256258 #define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1) /* use func->cur_blksize */
257259 /* for byte mode */
include/linux/mmc/core.h+1−0
@@ -177,6 +177,7 @@ int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, · 176 unmodified lines
177177 int retries);
178178
179179 int mmc_hw_reset(struct mmc_host *host);
180+int mmc_sw_reset(struct mmc_host *host);
180181 void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card);
181182
182183 #endif /* LINUX_MMC_CORE_H */
include/linux/mmc/host.h+6−0
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 struct mmc_ios {
2323 unsigned int clock; /* clock rate */
2424 unsigned short vdd;
25+ unsigned int power_delay_ms; /* waiting for stable power */
2526
2627 /* vdd stores the bit number of the selected voltage range from below. */
2728
@@ -320,6 +321,9 @@ struct mmc_host { · 292 unmodified lines
320321 #define MMC_CAP_UHS_SDR50 (1 << 18) /* Host supports UHS SDR50 mode */
321322 #define MMC_CAP_UHS_SDR104 (1 << 19) /* Host supports UHS SDR104 mode */
322323 #define MMC_CAP_UHS_DDR50 (1 << 20) /* Host supports UHS DDR50 mode */
324+#define MMC_CAP_UHS (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | \
325+ MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | \
326+ MMC_CAP_UHS_DDR50)
323327 /* (1 << 21) is free for reuse */
324328 #define MMC_CAP_DRIVER_TYPE_A (1 << 23) /* Host supports Driver Type A */
325329 #define MMC_CAP_DRIVER_TYPE_C (1 << 24) /* Host supports Driver Type C */
@@ -345,6 +349,7 @@ struct mmc_host { · 19 unmodified lines
345349 #define MMC_CAP2_HS400_1_2V (1 << 16) /* Can support HS400 1.2V */
346350 #define MMC_CAP2_HS400 (MMC_CAP2_HS400_1_8V | \
347351 MMC_CAP2_HS400_1_2V)
352+#define MMC_CAP2_HSX00_1_8V (MMC_CAP2_HS200_1_8V_SDR | MMC_CAP2_HS400_1_8V)
348353 #define MMC_CAP2_HSX00_1_2V (MMC_CAP2_HS200_1_2V_SDR | MMC_CAP2_HS400_1_2V)
349354 #define MMC_CAP2_SDIO_IRQ_NOTHREAD (1 << 17)
350355 #define MMC_CAP2_NO_WRITE_PROTECT (1 << 18) /* No physical write protect pin, assume that card is always read-write */
@@ -354,6 +359,7 @@ struct mmc_host { · 3 unmodified lines
354359 #define MMC_CAP2_NO_MMC (1 << 22) /* Do not send (e)MMC commands during initialization */
355360 #define MMC_CAP2_CQE (1 << 23) /* Has eMMC command queue engine */
356361 #define MMC_CAP2_CQE_DCMD (1 << 24) /* CQE can issue a direct command */
362+#define MMC_CAP2_AVOID_3_3V (1 << 25) /* Host must negotiate down from 3.3V */
357363
358364 int fixed_drv_type; /* fixed driver type for non-removable media */
359365
include/linux/mmc/sdio_ids.h+1−0
@@ -55,6 +55,7 @@ · 54 unmodified lines
5555 #define SDIO_DEVICE_ID_MARVELL_8688WLAN 0x9104
5656 #define SDIO_DEVICE_ID_MARVELL_8688BT 0x9105
5757 #define SDIO_DEVICE_ID_MARVELL_8797_F0 0x9128
58+#define SDIO_DEVICE_ID_MARVELL_8887WLAN 0x9134
5859
5960 #define SDIO_VENDOR_ID_SIANO 0x039a
6061 #define SDIO_DEVICE_ID_SIANO_NOVA_B0 0x0201

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t