History

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

Pull MMC and MEMSTICK updates from Ulf Hansson: "MMC core: - Fix hanging on I/O during system suspend for removable cards - Set read only for SD cards with permanent write protect bit - Power cycle the SD/SDIO card if CMD11 fails for UHS voltage - Issue a cache flush for eMMC only when it's enabled - Adopt to updated cache ctrl settings for eMMC from MMC ioctls - Use use device property API when parsing voltages - Don't retry eMMC sanitize cmds - Use the timeout from the MMC ioctl for eMMC santize cmds MMC host: - mmc_spi: Make of_mmc_spi.c resource provider agnostic - mmc_spi: Use polling for card detect even without voltage-ranges - sdhci: Check for reset prior to DMA address unmap - sdhci-acpi: Add support for the AMDI0041 eMMC controller variant - sdhci-esdhc-imx: Depending on OF Kconfig and cleanup code - sdhci-pci: Add PCI IDs for Intel LKF - sdhci-pci: Fix initialization of some SD cards for Intel BYT - sdhci-pci-gli: Various improvements for GL97xx variants - sdhci-of-dwcmshc: Enable support for MMC_CAP_WAIT_WHILE_BUSY - sdhci-of-dwcmshc: Add ACPI support for BlueField-3 SoC - sdhci-of-dwcmshc: Add Rockchip platform support - tmio/renesas_sdhi: Extend support for reset and use a reset controller - tmio/renesas_sdhi: Enable support for MMC_CAP_WAIT_WHILE_BUSY - tmio/renesas_sdhi: Various improvements MEMSTICK: - Minor improvements/cleanups" * tag 'mmc-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: (79 commits) mmc: block: Issue a cache flush only when it's enabled memstick: r592: ignore kfifo_out() return code again mmc: block: Update ext_csd.cache_ctrl if it was written mmc: mmc_spi: Make of_mmc_spi.c resource provider agnostic mmc: mmc_spi: Use already parsed IRQ mmc: mmc_spi: Drop unused NO_IRQ definition mmc: mmc_spi: Set up polling even if voltage-ranges is not present mmc: core: Convert mmc_of_parse_voltage() to use device property API mmc: core: Correct descriptions in mmc_of_parse() mmc: dw_mmc-rockchip: Just set default sample value for legacy mode mmc: sdhci-s3c: constify uses of driver/match data mmc: sdhci-s3c: correct kerneldoc of sdhci_s3c_drv_data mmc: sdhci-s3c: simplify getting of_device_id match data mmc: tmio: always restore irq register mmc: sdhci-pci-gli: Enlarge ASPM L1 entry delay of GL975x mmc: core: Let eMMC sanitize not retry in case of timeout/failure mmc: core: Add a retries parameter to __mmc_switch function memstick: r592: remove unused variable mmc: sdhci-st: Remove unnecessary error log mmc: sdhci-msm: Remove unnecessary error log ...

Linus Torvalds committed 5 years ago

Commit be18cd12 parents 6fa09d3 97fce1259 files · +1010 −642Browse files

Unified · Split

59 files
  1. Documentation/devicetree/bindings/mmc/brcm,iproc-sdhci.yaml +63 −0
  2. Documentation/devicetree/bindings/mmc/brcm,sdhci-iproc.txt +0 −37
  3. Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml +20 −0
  4. Documentation/devicetree/bindings/mmc/mmc-spi-slot.txt +3 −3
  5. Documentation/devicetree/bindings/mmc/mtk-sd.yaml +1 −0
  6. Documentation/devicetree/bindings/mmc/sdhci-of-dwcmshc.txt +0 −20
  7. Documentation/devicetree/bindings/mmc/snps,dwcmshc-sdhci.yaml +87 −0
  8. drivers/memstick/core/memstick.c +10 −11
  9. drivers/memstick/core/mspro_block.c +2 −1
  10. drivers/memstick/host/r592.c +4 −2
  11. drivers/mmc/core/block.c +47 −29
  12. drivers/mmc/core/core.c +6 −180
  13. drivers/mmc/core/core.h +9 −8
  14. drivers/mmc/core/host.c +71 −19
  15. drivers/mmc/core/mmc.c +18 −11
  16. drivers/mmc/core/mmc_ops.c +20 −39
  17. drivers/mmc/core/mmc_ops.h +2 −2
  18. drivers/mmc/core/queue.c +5 −6
  19. drivers/mmc/core/queue.h +0 −1
  20. drivers/mmc/core/sd.c +6 −0
  21. drivers/mmc/core/sdio.c +22 −6
  22. drivers/mmc/host/Kconfig +2 −0
  23. drivers/mmc/host/Makefile +0 −2
  24. drivers/mmc/host/cavium.c +1 −2
  25. drivers/mmc/host/dw_mmc-k3.c +1 −1
  26. drivers/mmc/host/dw_mmc-rockchip.c +1 −1
  27. drivers/mmc/host/dw_mmc.c +5 −11
  28. drivers/mmc/host/mmc_spi.c +4 −4
  29. drivers/mmc/host/moxart-mmc.c +4 −6
  30. drivers/mmc/host/of_mmc_spi.c +6 −12
  31. drivers/mmc/host/owl-mmc.c +0 −1
  32. drivers/mmc/host/renesas_sdhi.h +2 −0
  33. drivers/mmc/host/renesas_sdhi_core.c +28 −10
  34. drivers/mmc/host/renesas_sdhi_internal_dmac.c +2 −2
  35. drivers/mmc/host/renesas_sdhi_sys_dmac.c +5 −3
  36. drivers/mmc/host/sdhci-acpi.c +2 −0
  37. drivers/mmc/host/sdhci-brcmstb.c +0 −1
  38. drivers/mmc/host/sdhci-esdhc-imx.c +7 −19
  39. drivers/mmc/host/sdhci-esdhc-mcf.c +4 −4
  40. drivers/mmc/host/sdhci-msm.c +2 −6
  41. drivers/mmc/host/sdhci-of-aspeed.c +1 −1
  42. drivers/mmc/host/sdhci-of-dwcmshc.c +292 −21
  43. drivers/mmc/host/sdhci-of-esdhc.c +1 −1
  44. drivers/mmc/host/sdhci-pci-core.c +30 −1
  45. drivers/mmc/host/sdhci-pci-gli.c +43 −3
  46. drivers/mmc/host/sdhci-pci-o2micro.c +8 −0
  47. drivers/mmc/host/sdhci-pci.h +2 −0
  48. drivers/mmc/host/sdhci-s3c.c +8 −14
  49. drivers/mmc/host/sdhci-st.c +8 −15
  50. drivers/mmc/host/sdhci-tegra.c +49 −17
  51. drivers/mmc/host/sdhci.c +57 −56
  52. drivers/mmc/host/sdhci_am654.c +1 −1
  53. drivers/mmc/host/tmio_mmc.h +2 −1
  54. drivers/mmc/host/tmio_mmc_core.c +29 −32
  55. drivers/mmc/host/uniphier-sd.c +4 −1
  56. drivers/mmc/host/via-sdmmc.c +1 −2
  57. include/linux/mmc/host.h +1 −6
  58. include/linux/mmc/sdio.h +1 −1
  59. include/linux/spi/mmc_spi.h +0 −9
Documentation/devicetree/bindings/mmc/brcm,iproc-sdhci.yaml+63−0
@@ -0,0 +1,63 @@
1+# SPDX-License-Identifier: GPL-2.0
2+%YAML 1.2
3+---
4+$id: http://devicetree.org/schemas/mmc/brcm,iproc-sdhci.yaml#
5+$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+title: Broadcom IPROC SDHCI controller
8+
9+maintainers:
10+ - Ray Jui <ray.jui@broadcom.com>
11+ - Scott Branden <scott.branden@broadcom.com>
12+ - Nicolas Saenz Julienne <nsaenz@kernel.org>
13+
14+allOf:
15+ - $ref: mmc-controller.yaml#
16+
17+properties:
18+ compatible:
19+ enum:
20+ - brcm,bcm2835-sdhci
21+ - brcm,bcm2711-emmc2
22+ - brcm,sdhci-iproc-cygnus
23+ - brcm,sdhci-iproc
24+
25+ reg:
26+ minItems: 1
27+
28+ interrupts:
29+ maxItems: 1
30+
31+ clocks:
32+ maxItems: 1
33+ description:
34+ Handle to core clock for the sdhci controller.
35+
36+ sdhci,auto-cmd12:
37+ type: boolean
38+ description: Specifies that controller should use auto CMD12
39+
40+required:
41+ - compatible
42+ - reg
43+ - interrupts
44+ - clocks
45+
46+unevaluatedProperties: false
47+
48+examples:
49+ - |
50+ #include <dt-bindings/interrupt-controller/irq.h>
51+ #include <dt-bindings/interrupt-controller/arm-gic.h>
52+ #include <dt-bindings/clock/bcm-cygnus.h>
53+
54+ mmc@18041000 {
55+ compatible = "brcm,sdhci-iproc-cygnus";
56+ reg = <0x18041000 0x100>;
57+ interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
58+ clocks = <&lcpll0_clks BCM_CYGNUS_LCPLL0_SDIO_CLK>;
59+ bus-width = <4>;
60+ sdhci,auto-cmd12;
61+ no-1-8-v;
62+ };
63+...
Documentation/devicetree/bindings/mmc/brcm,sdhci-iproc.txt+0−37
@@ -1,37 +0,0 @@
1−Broadcom IPROC SDHCI controller
2−
3−This file documents differences between the core properties described
4−by mmc.txt and the properties that represent the IPROC SDHCI controller.
5−
6−Required properties:
7−- compatible : Should be one of the following
8− "brcm,bcm2835-sdhci"
9− "brcm,bcm2711-emmc2"
10− "brcm,sdhci-iproc-cygnus"
11− "brcm,sdhci-iproc"
12−
13−Use brcm2835-sdhci for the eMMC controller on the BCM2835 (Raspberry Pi) and
14−bcm2711-emmc2 for the additional eMMC2 controller on BCM2711.
15−
16−Use sdhci-iproc-cygnus for Broadcom SDHCI Controllers
17−restricted to 32bit host accesses to SDHCI registers.
18−
19−Use sdhci-iproc for Broadcom SDHCI Controllers that allow standard
20−8, 16, 32-bit host access to SDHCI register.
21−
22−- clocks : The clock feeding the SDHCI controller.
23−
24−Optional properties:
25− - sdhci,auto-cmd12: specifies that controller should use auto CMD12.
26−
27−Example:
28−
29−sdhci0: sdhci@18041000 {
30− compatible = "brcm,sdhci-iproc-cygnus";
31− reg = <0x18041000 0x100>;
32− interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
33− clocks = <&lcpll0_clks BCM_CYGNUS_LCPLL0_SDIO_CLK>;
34− bus-width = <4>;
35− sdhci,auto-cmd12;
36− no-1-8-v;
37−};
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml+20−0
@@ -103,6 +103,26 @@ properties: · 102 unmodified lines
103103 Only eMMC HS400 mode need to take care of this property.
104104 default: 0
105105
106+ clocks:
107+ maxItems: 3
108+ description:
109+ Handle clocks for the sdhc controller.
110+
111+ clock-names:
112+ items:
113+ - const: ipg
114+ - const: ahb
115+ - const: per
116+
117+ pinctrl-names:
118+ minItems: 1
119+ maxItems: 4
120+ items:
121+ - const: default
122+ - const: state_100mhz
123+ - const: state_200mhz
124+ - const: sleep
125+
106126 required:
107127 - compatible
108128 - reg
Documentation/devicetree/bindings/mmc/mmc-spi-slot.txt+3−3
@@ -5,11 +5,11 @@ by mmc.txt and the properties used by the mmc_spi driver. · 4 unmodified lines
55
66 Required properties:
77 - spi-max-frequency : maximum frequency for this device (Hz).
8−- voltage-ranges : two cells are required, first cell specifies minimum
9− slot voltage (mV), second cell specifies maximum slot voltage (mV).
10− Several ranges could be specified.
118
129 Optional properties:
10+- voltage-ranges : two cells are required, first cell specifies minimum
11+ slot voltage (mV), second cell specifies maximum slot voltage (mV).
12+ Several ranges could be specified. If not provided, 3.2v..3.4v is assumed.
1313 - gpios : may specify GPIOs in this order: Card-Detect GPIO,
1414 Write-Protect GPIO. Note that this does not follow the
1515 binding from mmc.txt, for historical reasons.
Documentation/devicetree/bindings/mmc/mtk-sd.yaml+1−0
@@ -31,6 +31,7 @@ properties: · 30 unmodified lines
3131 - const: mediatek,mt2701-mmc
3232 - items:
3333 - const: mediatek,mt8192-mmc
34+ - const: mediatek,mt8195-mmc
3435 - const: mediatek,mt8183-mmc
3536
3637 clocks:
Documentation/devicetree/bindings/mmc/sdhci-of-dwcmshc.txt+0−20
@@ -1,20 +0,0 @@
1−* Synopsys DesignWare Cores Mobile Storage Host Controller
2−
3−Required properties:
4−- compatible: should be one of the following:
5− "snps,dwcmshc-sdhci"
6−- reg: offset and length of the register set for the device.
7−- interrupts: a single interrupt specifier.
8−- clocks: Array of clocks required for SDHCI; requires at least one for
9− core clock.
10−- clock-names: Array of names corresponding to clocks property; shall be
11− "core" for core clock and "bus" for optional bus clock.
12−
13−Example:
14− sdhci2: sdhci@aa0000 {
15− compatible = "snps,dwcmshc-sdhci";
16− reg = <0xaa0000 0x1000>;
17− interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
18− clocks = <&emmcclk>;
19− bus-width = <8>;
20− }
Documentation/devicetree/bindings/mmc/snps,dwcmshc-sdhci.yaml+87−0
@@ -0,0 +1,87 @@
1+# SPDX-License-Identifier: GPL-2.0-only
2+%YAML 1.2
3+---
4+$id: http://devicetree.org/schemas/mmc/snps,dwcmshc-sdhci.yaml#
5+$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+title: Synopsys Designware Mobile Storage Host Controller Binding
8+
9+maintainers:
10+ - Ulf Hansson <ulf.hansson@linaro.org>
11+ - Jisheng Zhang <Jisheng.Zhang@synaptics.com>
12+
13+allOf:
14+ - $ref: mmc-controller.yaml#
15+
16+properties:
17+ compatible:
18+ enum:
19+ - rockchip,rk3568-dwcmshc
20+ - snps,dwcmshc-sdhci
21+
22+ reg:
23+ minItems: 1
24+ items:
25+ - description: Offset and length of the register set for the device
26+
27+ interrupts:
28+ maxItems: 1
29+
30+ clocks:
31+ minItems: 1
32+ items:
33+ - description: core clock
34+ - description: bus clock for optional
35+ - description: axi clock for rockchip specified
36+ - description: block clock for rockchip specified
37+ - description: timer clock for rockchip specified
38+
39+
40+ clock-names:
41+ minItems: 1
42+ items:
43+ - const: core
44+ - const: bus
45+ - const: axi
46+ - const: block
47+ - const: timer
48+
49+ rockchip,txclk-tapnum:
50+ description: Specify the number of delay for tx sampling.
51+ $ref: /schemas/types.yaml#/definitions/uint8
52+
53+
54+required:
55+ - compatible
56+ - reg
57+ - interrupts
58+ - clocks
59+ - clock-names
60+
61+unevaluatedProperties: false
62+
63+examples:
64+ - |
65+ mmc@fe310000 {
66+ compatible = "rockchip,rk3568-dwcmshc";
67+ reg = <0xfe310000 0x10000>;
68+ interrupts = <0 25 0x4>;
69+ clocks = <&cru 17>, <&cru 18>, <&cru 19>, <&cru 20>, <&cru 21>;
70+ clock-names = "core", "bus", "axi", "block", "timer";
71+ bus-width = <8>;
72+ #address-cells = <1>;
73+ #size-cells = <0>;
74+ };
75+ - |
76+ mmc@aa0000 {
77+ compatible = "snps,dwcmshc-sdhci";
78+ reg = <0xaa000 0x1000>;
79+ interrupts = <0 25 0x4>;
80+ clocks = <&cru 17>, <&cru 18>;
81+ clock-names = "core", "bus";
82+ bus-width = <8>;
83+ #address-cells = <1>;
84+ #size-cells = <0>;
85+ };
86+
87+...
drivers/memstick/core/memstick.c+10−11
@@ -331,18 +331,17 @@ static int h_memstick_read_dev_id(struct memstick_dev *card, · 330 unmodified lines
331331 sizeof(struct ms_id_register));
332332 *mrq = &card->current_mrq;
333333 return 0;
334− } else {
335− if (!(*mrq)->error) {
336− memcpy(&id_reg, (*mrq)->data, sizeof(id_reg));
337− card->id.match_flags = MEMSTICK_MATCH_ALL;
338− card->id.type = id_reg.type;
339− card->id.category = id_reg.category;
340− card->id.class = id_reg.class;
341− dev_dbg(&card->dev, "if_mode = %02x\n", id_reg.if_mode);
342− }
343− complete(&card->mrq_complete);
344− return -EAGAIN;
345334 }
335+ if (!(*mrq)->error) {
336+ memcpy(&id_reg, (*mrq)->data, sizeof(id_reg));
337+ card->id.match_flags = MEMSTICK_MATCH_ALL;
338+ card->id.type = id_reg.type;
339+ card->id.category = id_reg.category;
340+ card->id.class = id_reg.class;
341+ dev_dbg(&card->dev, "if_mode = %02x\n", id_reg.if_mode);
342+ }
343+ complete(&card->mrq_complete);
344+ return -EAGAIN;
346345 }
347346
348347 static int h_memstick_set_rw_addr(struct memstick_dev *card,
drivers/memstick/core/mspro_block.c+2−1
@@ -1382,7 +1382,8 @@ static int mspro_block_resume(struct memstick_dev *card) · 1381 unmodified lines
13821382
13831383 new_msb->card = card;
13841384 memstick_set_drvdata(card, new_msb);
1385− if (mspro_block_init_card(card))
1385+ rc = mspro_block_init_card(card);
1386+ if (rc)
13861387 goto out_free;
13871388
13881389 for (cnt = 0; new_msb->attr_group.attrs[cnt]
drivers/memstick/host/r592.c+4−2
@@ -359,13 +359,15 @@ static void r592_write_fifo_pio(struct r592_device *dev, · 358 unmodified lines
359359 /* Flushes the temporary FIFO used to make aligned DWORD writes */
360360 static void r592_flush_fifo_write(struct r592_device *dev)
361361 {
362+ int ret;
362363 u8 buffer[4] = { 0 };
363− int len;
364364
365365 if (kfifo_is_empty(&dev->pio_fifo))
366366 return;
367367
368− len = kfifo_out(&dev->pio_fifo, buffer, 4);
368+ ret = kfifo_out(&dev->pio_fifo, buffer, 4);
369+ /* intentionally ignore __must_check return code */
370+ (void)ret;
369371 r592_write_reg_raw_be(dev, R592_FIFO_PIO, *(u32 *)buffer);
370372 }
371373
drivers/mmc/core/block.c+47−29
@@ -539,7 +539,7 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md, · 538 unmodified lines
539539
540540 if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_SANITIZE_START) &&
541541 (cmd.opcode == MMC_SWITCH))
542− return mmc_sanitize(card);
542+ return mmc_sanitize(card, idata->ic.cmd_timeout_ms);
543543
544544 mmc_wait_for_req(card->host, &mrq);
545545
@@ -572,6 +572,18 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md, · 26 unmodified lines
572572 main_md->part_curr = value & EXT_CSD_PART_CONFIG_ACC_MASK;
573573 }
574574
575+ /*
576+ * Make sure to update CACHE_CTRL in case it was changed. The cache
577+ * will get turned back on if the card is re-initialized, e.g.
578+ * suspend/resume or hw reset in recovery.
579+ */
580+ if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_CACHE_CTRL) &&
581+ (cmd.opcode == MMC_SWITCH)) {
582+ u8 value = MMC_EXTRACT_VALUE_FROM_ARG(cmd.arg) & 1;
583+
584+ card->ext_csd.cache_ctrl = value;
585+ }
586+
575587 /*
576588 * According to the SD specs, some commands require a delay after
577589 * issuing the command.
@@ -947,7 +959,7 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host, · 369 unmodified lines
947959 md->reset_done |= type;
948960 err = mmc_hw_reset(host);
949961 /* Ensure we switch back to the correct partition */
950− if (err != -EOPNOTSUPP) {
962+ if (err) {
951963 struct mmc_blk_data *main_md =
952964 dev_get_drvdata(&host->card->dev);
953965 int part_err;
@@ -1933,8 +1945,9 @@ static void mmc_blk_hsq_req_done(struct mmc_request *mrq) · 979 unmodified lines
19331945 void mmc_blk_mq_complete(struct request *req)
19341946 {
19351947 struct mmc_queue *mq = req->q->queuedata;
1948+ struct mmc_host *host = mq->card->host;
19361949
1937− if (mq->use_cqe)
1950+ if (host->cqe_enabled)
19381951 mmc_blk_cqe_complete_rq(mq, req);
19391952 else if (likely(!blk_should_fake_timeout(req->q)))
19401953 mmc_blk_mq_complete_rq(mq, req);
@@ -2179,7 +2192,7 @@ out_post_req: · 238 unmodified lines
21792192
21802193 static int mmc_blk_wait_for_idle(struct mmc_queue *mq, struct mmc_host *host)
21812194 {
2182− if (mq->use_cqe)
2195+ if (host->cqe_enabled)
21832196 return host->cqe_ops->cqe_wait_for_idle(host);
21842197
21852198 return mmc_blk_rw_wait(mq, NULL);
@@ -2224,11 +2237,15 @@ enum mmc_issued mmc_blk_mq_issue_rq(struct mmc_queue *mq, struct request *req) · 38 unmodified lines
22242237 case MMC_ISSUE_ASYNC:
22252238 switch (req_op(req)) {
22262239 case REQ_OP_FLUSH:
2240+ if (!mmc_cache_enabled(host)) {
2241+ blk_mq_end_request(req, BLK_STS_OK);
2242+ return MMC_REQ_FINISHED;
2243+ }
22272244 ret = mmc_blk_cqe_issue_flush(mq, req);
22282245 break;
22292246 case REQ_OP_READ:
22302247 case REQ_OP_WRITE:
2231− if (mq->use_cqe)
2248+ if (host->cqe_enabled)
22322249 ret = mmc_blk_cqe_issue_rw_rq(mq, req);
22332250 else
22342251 ret = mmc_blk_mq_issue_rw_rq(mq, req);
@@ -2261,6 +2278,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, · 26 unmodified lines
22612278 {
22622279 struct mmc_blk_data *md;
22632280 int devidx, ret;
2281+ char cap_str[10];
22642282
22652283 devidx = ida_simple_get(&mmc_blk_ida, 0, max_devices, GFP_KERNEL);
22662284 if (devidx < 0) {
@@ -2365,6 +2383,12 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, · 98 unmodified lines
23652383 blk_queue_write_cache(md->queue.queue, true, true);
23662384 }
23672385
2386+ string_get_size((u64)size, 512, STRING_UNITS_2,
2387+ cap_str, sizeof(cap_str));
2388+ pr_info("%s: %s %s %s %s\n",
2389+ md->disk->disk_name, mmc_card_id(card), mmc_card_name(card),
2390+ cap_str, md->read_only ? "(ro)" : "");
2391+
23682392 return md;
23692393
23702394 err_putdisk:
@@ -2407,7 +2431,6 @@ static int mmc_blk_alloc_part(struct mmc_card *card, · 36 unmodified lines
24072431 const char *subname,
24082432 int area_type)
24092433 {
2410− char cap_str[10];
24112434 struct mmc_blk_data *part_md;
24122435
24132436 part_md = mmc_blk_alloc_req(card, disk_to_dev(md->disk), size, default_ro,
@@ -2417,11 +2440,6 @@ static int mmc_blk_alloc_part(struct mmc_card *card, · 3 unmodified lines
24172440 part_md->part_type = part_type;
24182441 list_add(&part_md->part, &md->part);
24192442
2420− string_get_size((u64)get_capacity(part_md->disk), 512, STRING_UNITS_2,
2421− cap_str, sizeof(cap_str));
2422− pr_info("%s: %s %s partition %u %s\n",
2423− part_md->disk->disk_name, mmc_card_id(card),
2424− mmc_card_name(card), part_md->part_type, cap_str);
24252443 return 0;
24262444 }
24272445
@@ -2558,9 +2576,8 @@ static int mmc_blk_alloc_rpmb_part(struct mmc_card *card, · 130 unmodified lines
25582576 string_get_size((u64)size, 512, STRING_UNITS_2,
25592577 cap_str, sizeof(cap_str));
25602578
2561− pr_info("%s: %s %s partition %u %s, chardev (%d:%d)\n",
2562− rpmb_name, mmc_card_id(card),
2563− mmc_card_name(card), EXT_CSD_PART_CONFIG_ACC_RPMB, cap_str,
2579+ pr_info("%s: %s %s %s, chardev (%d:%d)\n",
2580+ rpmb_name, mmc_card_id(card), mmc_card_name(card), cap_str,
25642581 MAJOR(mmc_rpmb_devt), rpmb->id);
25652582
25662583 return 0;
@@ -2876,7 +2893,7 @@ static void mmc_blk_remove_debugfs(struct mmc_card *card, · 309 unmodified lines
28762893 static int mmc_blk_probe(struct mmc_card *card)
28772894 {
28782895 struct mmc_blk_data *md, *part_md;
2879− char cap_str[10];
2896+ int ret = 0;
28802897
28812898 /*
28822899 * Check that the card supports the command class(es) we need.
@@ -2888,31 +2905,30 @@ static int mmc_blk_probe(struct mmc_card *card) · 5 unmodified lines
28882905
28892906 card->complete_wq = alloc_workqueue("mmc_complete",
28902907 WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
2891− if (unlikely(!card->complete_wq)) {
2908+ if (!card->complete_wq) {
28922909 pr_err("Failed to create mmc completion workqueue");
28932910 return -ENOMEM;
28942911 }
28952912
28962913 md = mmc_blk_alloc(card);
2897− if (IS_ERR(md))
2898− return PTR_ERR(md);
2899−
2900− string_get_size((u64)get_capacity(md->disk), 512, STRING_UNITS_2,
2901− cap_str, sizeof(cap_str));
2902− pr_info("%s: %s %s %s %s\n",
2903− md->disk->disk_name, mmc_card_id(card), mmc_card_name(card),
2904− cap_str, md->read_only ? "(ro)" : "");
2914+ if (IS_ERR(md)) {
2915+ ret = PTR_ERR(md);
2916+ goto out_free;
2917+ }
29052918
2906− if (mmc_blk_alloc_parts(card, md))
2919+ ret = mmc_blk_alloc_parts(card, md);
2920+ if (ret)
29072921 goto out;
29082922
29092923 dev_set_drvdata(&card->dev, md);
29102924
2911− if (mmc_add_disk(md))
2925+ ret = mmc_add_disk(md);
2926+ if (ret)
29122927 goto out;
29132928
29142929 list_for_each_entry(part_md, &md->part, part) {
2915− if (mmc_add_disk(part_md))
2930+ ret = mmc_add_disk(part_md);
2931+ if (ret)
29162932 goto out;
29172933 }
29182934
@@ -2933,10 +2949,12 @@ static int mmc_blk_probe(struct mmc_card *card) · 14 unmodified lines
29332949
29342950 return 0;
29352951
2936− out:
2952+out:
29372953 mmc_blk_remove_parts(card, md);
29382954 mmc_blk_remove_req(md);
2939− return 0;
2955+out_free:
2956+ destroy_workqueue(card->complete_wq);
2957+ return ret;
29402958 }
29412959
29422960 static void mmc_blk_remove(struct mmc_card *card)
drivers/mmc/core/core.c+6−180
@@ -1207,7 +1207,7 @@ int mmc_set_uhs_voltage(struct mmc_host *host, u32 ocr) · 1206 unmodified lines
12071207
12081208 err = mmc_wait_for_cmd(host, &cmd, 0);
12091209 if (err)
1210− return err;
1210+ goto power_cycle;
12111211
12121212 if (!mmc_host_is_spi(host) && (cmd.resp[0] & R1_ERROR))
12131213 return -EIO;
@@ -1377,63 +1377,13 @@ void mmc_power_cycle(struct mmc_host *host, u32 ocr) · 163 unmodified lines
13771377 mmc_power_up(host, ocr);
13781378 }
13791379
1380−/*
1381− * Cleanup when the last reference to the bus operator is dropped.
1382− */
1383−static void __mmc_release_bus(struct mmc_host *host)
1384−{
1385− WARN_ON(!host->bus_dead);
1386−
1387− host->bus_ops = NULL;
1388−}
1389−
1390−/*
1391− * Increase reference count of bus operator
1392− */
1393−static inline void mmc_bus_get(struct mmc_host *host)
1394−{
1395− unsigned long flags;
1396−
1397− spin_lock_irqsave(&host->lock, flags);
1398− host->bus_refs++;
1399− spin_unlock_irqrestore(&host->lock, flags);
1400−}
1401−
1402−/*
1403− * Decrease reference count of bus operator and free it if
1404− * it is the last reference.
1405− */
1406−static inline void mmc_bus_put(struct mmc_host *host)
1407−{
1408− unsigned long flags;
1409−
1410− spin_lock_irqsave(&host->lock, flags);
1411− host->bus_refs--;
1412− if ((host->bus_refs == 0) && host->bus_ops)
1413− __mmc_release_bus(host);
1414− spin_unlock_irqrestore(&host->lock, flags);
1415−}
1416−
14171380 /*
14181381 * Assign a mmc bus handler to a host. Only one bus handler may control a
14191382 * host at any given time.
14201383 */
14211384 void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops)
14221385 {
1423− unsigned long flags;
1424−
1425− WARN_ON(!host->claimed);
1426−
1427− spin_lock_irqsave(&host->lock, flags);
1428−
1429− WARN_ON(host->bus_ops);
1430− WARN_ON(host->bus_refs);
1431−
14321386 host->bus_ops = ops;
1433− host->bus_refs = 1;
1434− host->bus_dead = 0;
1435−
1436− spin_unlock_irqrestore(&host->lock, flags);
14371387 }
14381388
14391389 /*
@@ -1441,18 +1391,7 @@ void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops) · 1 unmodified line
14411391 */
14421392 void mmc_detach_bus(struct mmc_host *host)
14431393 {
1444− unsigned long flags;
1445−
1446− WARN_ON(!host->claimed);
1447− WARN_ON(!host->bus_ops);
1448−
1449− spin_lock_irqsave(&host->lock, flags);
1450−
1451− host->bus_dead = 1;
1452−
1453− spin_unlock_irqrestore(&host->lock, flags);
1454−
1455− mmc_bus_put(host);
1394+ host->bus_ops = NULL;
14561395 }
14571396
14581397 void _mmc_detect_change(struct mmc_host *host, unsigned long delay, bool cd_irq)
@@ -2080,18 +2019,7 @@ int mmc_hw_reset(struct mmc_host *host) · 621 unmodified lines
20802019 {
20812020 int ret;
20822021
2083− if (!host->card)
2084− return -EINVAL;
2085−
2086− mmc_bus_get(host);
2087− if (!host->bus_ops || host->bus_dead || !host->bus_ops->hw_reset) {
2088− mmc_bus_put(host);
2089− return -EOPNOTSUPP;
2090− }
2091−
20922022 ret = host->bus_ops->hw_reset(host);
2093− mmc_bus_put(host);
2094−
20952023 if (ret < 0)
20962024 pr_warn("%s: tried to HW reset card, got error %d\n",
20972025 mmc_hostname(host), ret);
@@ -2104,18 +2032,10 @@ int mmc_sw_reset(struct mmc_host *host) · 6 unmodified lines
21042032 {
21052033 int ret;
21062034
2107− if (!host->card)
2108− return -EINVAL;
2109−
2110− mmc_bus_get(host);
2111− if (!host->bus_ops || host->bus_dead || !host->bus_ops->sw_reset) {
2112− mmc_bus_put(host);
2035+ if (!host->bus_ops->sw_reset)
21132036 return -EOPNOTSUPP;
2114− }
21152037
21162038 ret = host->bus_ops->sw_reset(host);
2117− mmc_bus_put(host);
2118−
21192039 if (ret)
21202040 pr_warn("%s: tried to SW reset card, got error %d\n",
21212041 mmc_hostname(host), ret);
@@ -2263,32 +2183,15 @@ void mmc_rescan(struct work_struct *work) · 141 unmodified lines
22632183 host->trigger_card_event = false;
22642184 }
22652185
2266− mmc_bus_get(host);
2267−
22682186 /* Verify a registered card to be functional, else remove it. */
2269− if (host->bus_ops && !host->bus_dead)
2187+ if (host->bus_ops)
22702188 host->bus_ops->detect(host);
22712189
22722190 host->detect_change = 0;
22732191
2274− /*
2275− * Let mmc_bus_put() free the bus/bus_ops if we've found that
2276− * the card is no longer present.
2277− */
2278− mmc_bus_put(host);
2279− mmc_bus_get(host);
2280−
22812192 /* if there still is a card present, stop here */
2282− if (host->bus_ops != NULL) {
2283− mmc_bus_put(host);
2193+ if (host->bus_ops != NULL)
22842194 goto out;
2285− }
2286−
2287− /*
2288− * Only we can add a new handler, so it's safe to
2289− * release the lock here.
2290− */
2291− mmc_bus_put(host);
22922195
22932196 mmc_claim_host(host);
22942197 if (mmc_card_is_removable(host) && host->ops->get_cd &&
@@ -2351,98 +2254,21 @@ void mmc_stop_host(struct mmc_host *host) · 56 unmodified lines
23512254 /* clear pm flags now and let card drivers set them as needed */
23522255 host->pm_flags = 0;
23532256
2354− mmc_bus_get(host);
2355− if (host->bus_ops && !host->bus_dead) {
2257+ if (host->bus_ops) {
23562258 /* Calling bus_ops->remove() with a claimed host can deadlock */
23572259 host->bus_ops->remove(host);
23582260 mmc_claim_host(host);
23592261 mmc_detach_bus(host);
23602262 mmc_power_off(host);
23612263 mmc_release_host(host);
2362− mmc_bus_put(host);
23632264 return;
23642265 }
2365− mmc_bus_put(host);
23662266
23672267 mmc_claim_host(host);
23682268 mmc_power_off(host);
23692269 mmc_release_host(host);
23702270 }
23712271
2372−#ifdef CONFIG_PM_SLEEP
2373−/* Do the card removal on suspend if card is assumed removeable
2374− * Do that in pm notifier while userspace isn't yet frozen, so we will be able
2375− to sync the card.
2376−*/
2377−static int mmc_pm_notify(struct notifier_block *notify_block,
2378− unsigned long mode, void *unused)
2379−{
2380− struct mmc_host *host = container_of(
2381− notify_block, struct mmc_host, pm_notify);
2382− unsigned long flags;
2383− int err = 0;
2384−
2385− switch (mode) {
2386− case PM_HIBERNATION_PREPARE:
2387− case PM_SUSPEND_PREPARE:
2388− case PM_RESTORE_PREPARE:
2389− spin_lock_irqsave(&host->lock, flags);
2390− host->rescan_disable = 1;
2391− spin_unlock_irqrestore(&host->lock, flags);
2392− cancel_delayed_work_sync(&host->detect);
2393−
2394− if (!host->bus_ops)
2395− break;
2396−
2397− /* Validate prerequisites for suspend */
2398− if (host->bus_ops->pre_suspend)
2399− err = host->bus_ops->pre_suspend(host);
2400− if (!err)
2401− break;
2402−
2403− if (!mmc_card_is_removable(host)) {
2404− dev_warn(mmc_dev(host),
2405− "pre_suspend failed for non-removable host: "
2406− "%d\n", err);
2407− /* Avoid removing non-removable hosts */
2408− break;
2409− }
2410−
2411− /* Calling bus_ops->remove() with a claimed host can deadlock */
2412− host->bus_ops->remove(host);
2413− mmc_claim_host(host);
2414− mmc_detach_bus(host);
2415− mmc_power_off(host);
2416− mmc_release_host(host);
2417− host->pm_flags = 0;
2418− break;
2419−
2420− case PM_POST_SUSPEND:
2421− case PM_POST_HIBERNATION:
2422− case PM_POST_RESTORE:
2423−
2424− spin_lock_irqsave(&host->lock, flags);
2425− host->rescan_disable = 0;
2426− spin_unlock_irqrestore(&host->lock, flags);
2427− _mmc_detect_change(host, 0, false);
2428−
2429− }
2430−
2431− return 0;
2432−}
2433−
2434−void mmc_register_pm_notifier(struct mmc_host *host)
2435−{
2436− host->pm_notify.notifier_call = mmc_pm_notify;
2437− register_pm_notifier(&host->pm_notify);
2438−}
2439−
2440−void mmc_unregister_pm_notifier(struct mmc_host *host)
2441−{
2442− unregister_pm_notifier(&host->pm_notify);
2443−}
2444−#endif
2445−
24462272 static int __init mmc_init(void)
24472273 {
24482274 int ret;
drivers/mmc/core/core.h+9−8
@@ -29,6 +29,7 @@ struct mmc_bus_ops { · 28 unmodified lines
2929 int (*shutdown)(struct mmc_host *);
3030 int (*hw_reset)(struct mmc_host *);
3131 int (*sw_reset)(struct mmc_host *);
32+ bool (*cache_enabled)(struct mmc_host *);
3233 };
3334
3435 void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops);
@@ -93,14 +94,6 @@ int mmc_execute_tuning(struct mmc_card *card); · 58 unmodified lines
9394 int mmc_hs200_to_hs400(struct mmc_card *card);
9495 int mmc_hs400_to_hs200(struct mmc_card *card);
9596
96−#ifdef CONFIG_PM_SLEEP
97−void mmc_register_pm_notifier(struct mmc_host *host);
98−void mmc_unregister_pm_notifier(struct mmc_host *host);
99−#else
100−static inline void mmc_register_pm_notifier(struct mmc_host *host) { }
101−static inline void mmc_unregister_pm_notifier(struct mmc_host *host) { }
102−#endif
103−
10497 void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq);
10598 bool mmc_is_req_done(struct mmc_host *host, struct mmc_request *mrq);
10699
@@ -171,4 +164,12 @@ static inline void mmc_post_req(struct mmc_host *host, struct mmc_request *mrq, · 64 unmodified lines
171164 host->ops->post_req(host, mrq, err);
172165 }
173166
167+static inline bool mmc_cache_enabled(struct mmc_host *host)
168+{
169+ if (host->bus_ops->cache_enabled)
170+ return host->bus_ops->cache_enabled(host);
171+
172+ return false;
173+}
174+
174175 #endif
drivers/mmc/core/host.c+71−19
@@ -35,6 +35,42 @@ · 34 unmodified lines
3535
3636 static DEFINE_IDA(mmc_host_ida);
3737
38+#ifdef CONFIG_PM_SLEEP
39+static int mmc_host_class_prepare(struct device *dev)
40+{
41+ struct mmc_host *host = cls_dev_to_mmc_host(dev);
42+
43+ /*
44+ * It's safe to access the bus_ops pointer, as both userspace and the
45+ * workqueue for detecting cards are frozen at this point.
46+ */
47+ if (!host->bus_ops)
48+ return 0;
49+
50+ /* Validate conditions for system suspend. */
51+ if (host->bus_ops->pre_suspend)
52+ return host->bus_ops->pre_suspend(host);
53+
54+ return 0;
55+}
56+
57+static void mmc_host_class_complete(struct device *dev)
58+{
59+ struct mmc_host *host = cls_dev_to_mmc_host(dev);
60+
61+ _mmc_detect_change(host, 0, false);
62+}
63+
64+static const struct dev_pm_ops mmc_host_class_dev_pm_ops = {
65+ .prepare = mmc_host_class_prepare,
66+ .complete = mmc_host_class_complete,
67+};
68+
69+#define MMC_HOST_CLASS_DEV_PM_OPS (&mmc_host_class_dev_pm_ops)
70+#else
71+#define MMC_HOST_CLASS_DEV_PM_OPS NULL
72+#endif
73+
3874 static void mmc_host_classdev_release(struct device *dev)
3975 {
4076 struct mmc_host *host = cls_dev_to_mmc_host(dev);
@@ -46,6 +82,7 @@ static void mmc_host_classdev_release(struct device *dev) · 5 unmodified lines
4682 static struct class mmc_host_class = {
4783 .name = "mmc_host",
4884 .dev_release = mmc_host_classdev_release,
85+ .pm = MMC_HOST_CLASS_DEV_PM_OPS,
4986 };
5087
5188 int mmc_register_host_class(void)
@@ -209,8 +246,8 @@ mmc_of_parse_clk_phase(struct mmc_host *host, struct mmc_clk_phase_map *map) · 157 unmodified lines
209246 EXPORT_SYMBOL(mmc_of_parse_clk_phase);
210247
211248 /**
212− * mmc_of_parse() - parse host's device-tree node
213− * @host: host whose node should be parsed.
249+ * mmc_of_parse() - parse host's device properties
250+ * @host: host whose properties should be parsed.
214251 *
215252 * To keep the rest of the MMC subsystem unaware of whether DT has been
216253 * used to to instantiate and configure this host instance or not, we
@@ -379,44 +416,62 @@ EXPORT_SYMBOL(mmc_of_parse); · 162 unmodified lines
379416
380417 /**
381418 * mmc_of_parse_voltage - return mask of supported voltages
382− * @np: The device node need to be parsed.
419+ * @host: host whose properties should be parsed.
383420 * @mask: mask of voltages available for MMC/SD/SDIO
384421 *
385− * Parse the "voltage-ranges" DT property, returning zero if it is not
422+ * Parse the "voltage-ranges" property, returning zero if it is not
386423 * found, negative errno if the voltage-range specification is invalid,
387424 * or one if the voltage-range is specified and successfully parsed.
388425 */
389−int mmc_of_parse_voltage(struct device_node *np, u32 *mask)
426+int mmc_of_parse_voltage(struct mmc_host *host, u32 *mask)
390427 {
391− const u32 *voltage_ranges;
428+ const char *prop = "voltage-ranges";
429+ struct device *dev = host->parent;
430+ u32 *voltage_ranges;
392431 int num_ranges, i;
432+ int ret;
393433
394− voltage_ranges = of_get_property(np, "voltage-ranges", &num_ranges);
395− if (!voltage_ranges) {
396− pr_debug("%pOF: voltage-ranges unspecified\n", np);
434+ if (!device_property_present(dev, prop)) {
435+ dev_dbg(dev, "%s unspecified\n", prop);
397436 return 0;
398437 }
399− num_ranges = num_ranges / sizeof(*voltage_ranges) / 2;
438+
439+ ret = device_property_count_u32(dev, prop);
440+ if (ret < 0)
441+ return ret;
442+
443+ num_ranges = ret / 2;
400444 if (!num_ranges) {
401− pr_err("%pOF: voltage-ranges empty\n", np);
445+ dev_err(dev, "%s empty\n", prop);
402446 return -EINVAL;
403447 }
404448
449+ voltage_ranges = kcalloc(2 * num_ranges, sizeof(*voltage_ranges), GFP_KERNEL);
450+ if (!voltage_ranges)
451+ return -ENOMEM;
452+
453+ ret = device_property_read_u32_array(dev, prop, voltage_ranges, 2 * num_ranges);
454+ if (ret) {
455+ kfree(voltage_ranges);
456+ return ret;
457+ }
458+
405459 for (i = 0; i < num_ranges; i++) {
406460 const int j = i * 2;
407461 u32 ocr_mask;
408462
409− ocr_mask = mmc_vddrange_to_ocrmask(
410− be32_to_cpu(voltage_ranges[j]),
411− be32_to_cpu(voltage_ranges[j + 1]));
463+ ocr_mask = mmc_vddrange_to_ocrmask(voltage_ranges[j + 0],
464+ voltage_ranges[j + 1]);
412465 if (!ocr_mask) {
413− pr_err("%pOF: voltage-range #%d is invalid\n",
414− np, i);
466+ dev_err(dev, "range #%d in %s is invalid\n", i, prop);
467+ kfree(voltage_ranges);
415468 return -EINVAL;
416469 }
417470 *mask |= ocr_mask;
418471 }
419472
473+ kfree(voltage_ranges);
474+
420475 return 1;
421476 }
422477 EXPORT_SYMBOL(mmc_of_parse_voltage);
@@ -538,8 +593,6 @@ int mmc_add_host(struct mmc_host *host) · 115 unmodified lines
538593 #endif
539594
540595 mmc_start_host(host);
541− mmc_register_pm_notifier(host);
542−
543596 return 0;
544597 }
545598
@@ -555,7 +608,6 @@ EXPORT_SYMBOL(mmc_add_host); · 9 unmodified lines
555608 */
556609 void mmc_remove_host(struct mmc_host *host)
557610 {
558− mmc_unregister_pm_notifier(host);
559611 mmc_stop_host(host);
560612
561613 #ifdef CONFIG_DEBUG_FS
drivers/mmc/core/mmc.c+18−11
@@ -1068,7 +1068,7 @@ static int mmc_select_hs(struct mmc_card *card) · 1067 unmodified lines
10681068 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
10691069 EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS,
10701070 card->ext_csd.generic_cmd6_time, MMC_TIMING_MMC_HS,
1071− true, true);
1071+ true, true, MMC_CMD_RETRIES);
10721072 if (err)
10731073 pr_warn("%s: switch to high-speed failed, err:%d\n",
10741074 mmc_hostname(card->host), err);
@@ -1100,7 +1100,7 @@ static int mmc_select_hs_ddr(struct mmc_card *card) · 25 unmodified lines
11001100 ext_csd_bits,
11011101 card->ext_csd.generic_cmd6_time,
11021102 MMC_TIMING_MMC_DDR52,
1103− true, true);
1103+ true, true, MMC_CMD_RETRIES);
11041104 if (err) {
11051105 pr_err("%s: switch to bus width %d ddr failed\n",
11061106 mmc_hostname(host), 1 << bus_width);
@@ -1168,7 +1168,7 @@ static int mmc_select_hs400(struct mmc_card *card) · 61 unmodified lines
11681168 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
11691169 EXT_CSD_HS_TIMING, val,
11701170 card->ext_csd.generic_cmd6_time, 0,
1171− false, true);
1171+ false, true, MMC_CMD_RETRIES);
11721172 if (err) {
11731173 pr_err("%s: switch to high-speed from hs200 failed, err:%d\n",
11741174 mmc_hostname(host), err);
@@ -1210,7 +1210,7 @@ static int mmc_select_hs400(struct mmc_card *card) · 35 unmodified lines
12101210 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
12111211 EXT_CSD_HS_TIMING, val,
12121212 card->ext_csd.generic_cmd6_time, 0,
1213− false, true);
1213+ false, true, MMC_CMD_RETRIES);
12141214 if (err) {
12151215 pr_err("%s: switch to hs400 failed, err:%d\n",
12161216 mmc_hostname(host), err);
@@ -1256,7 +1256,7 @@ int mmc_hs400_to_hs200(struct mmc_card *card) · 39 unmodified lines
12561256 val = EXT_CSD_TIMING_HS;
12571257 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
12581258 val, card->ext_csd.generic_cmd6_time, 0,
1259− false, true);
1259+ false, true, MMC_CMD_RETRIES);
12601260 if (err)
12611261 goto out_err;
12621262
@@ -1272,7 +1272,7 @@ int mmc_hs400_to_hs200(struct mmc_card *card) · 9 unmodified lines
12721272 /* Switch HS DDR to HS */
12731273 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH,
12741274 EXT_CSD_BUS_WIDTH_8, card->ext_csd.generic_cmd6_time,
1275− 0, false, true);
1275+ 0, false, true, MMC_CMD_RETRIES);
12761276 if (err)
12771277 goto out_err;
12781278
@@ -1287,7 +1287,7 @@ int mmc_hs400_to_hs200(struct mmc_card *card) · 8 unmodified lines
12871287 card->drive_strength << EXT_CSD_DRV_STR_SHIFT;
12881288 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
12891289 val, card->ext_csd.generic_cmd6_time, 0,
1290− false, true);
1290+ false, true, MMC_CMD_RETRIES);
12911291 if (err)
12921292 goto out_err;
12931293
@@ -1371,7 +1371,7 @@ static int mmc_select_hs400es(struct mmc_card *card) · 77 unmodified lines
13711371 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
13721372 EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS,
13731373 card->ext_csd.generic_cmd6_time, 0,
1374− false, true);
1374+ false, true, MMC_CMD_RETRIES);
13751375 if (err) {
13761376 pr_err("%s: switch to hs for hs400es failed, err:%d\n",
13771377 mmc_hostname(host), err);
@@ -1405,7 +1405,7 @@ static int mmc_select_hs400es(struct mmc_card *card) · 27 unmodified lines
14051405 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
14061406 EXT_CSD_HS_TIMING, val,
14071407 card->ext_csd.generic_cmd6_time, 0,
1408− false, true);
1408+ false, true, MMC_CMD_RETRIES);
14091409 if (err) {
14101410 pr_err("%s: switch to hs400es failed, err:%d\n",
14111411 mmc_hostname(host), err);
@@ -1470,7 +1470,7 @@ static int mmc_select_hs200(struct mmc_card *card) · 58 unmodified lines
14701470 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
14711471 EXT_CSD_HS_TIMING, val,
14721472 card->ext_csd.generic_cmd6_time, 0,
1473− false, true);
1473+ false, true, MMC_CMD_RETRIES);
14741474 if (err)
14751475 goto err;
14761476 old_timing = host->ios.timing;
@@ -1975,7 +1975,7 @@ static int mmc_poweroff_notify(struct mmc_card *card, unsigned int notify_type) · 498 unmodified lines
19751975
19761976 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
19771977 EXT_CSD_POWER_OFF_NOTIFICATION,
1978− notify_type, timeout, 0, false, false);
1978+ notify_type, timeout, 0, false, false, MMC_CMD_RETRIES);
19791979 if (err)
19801980 pr_err("%s: Power Off Notification timed out, %u\n",
19811981 mmc_hostname(card->host), timeout);
@@ -2029,6 +2029,12 @@ static void mmc_detect(struct mmc_host *host) · 47 unmodified lines
20292029 }
20302030 }
20312031
2032+static bool _mmc_cache_enabled(struct mmc_host *host)
2033+{
2034+ return host->card->ext_csd.cache_size > 0 &&
2035+ host->card->ext_csd.cache_ctrl & 1;
2036+}
2037+
20322038 static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
20332039 {
20342040 int err = 0;
@@ -2208,6 +2214,7 @@ static const struct mmc_bus_ops mmc_ops = { · 173 unmodified lines
22082214 .alive = mmc_alive,
22092215 .shutdown = mmc_shutdown,
22102216 .hw_reset = _mmc_hw_reset,
2217+ .cache_enabled = _mmc_cache_enabled,
22112218 };
22122219
22132220 /*
drivers/mmc/core/mmc_ops.c+20−39
@@ -296,61 +296,40 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host, · 295 unmodified lines
296296 return 0;
297297 }
298298
299−static int mmc_spi_send_csd(struct mmc_host *host, u32 *csd)
299+static int mmc_spi_send_cxd(struct mmc_host *host, u32 *cxd, u32 opcode)
300300 {
301301 int ret, i;
302− __be32 *csd_tmp;
302+ __be32 *cxd_tmp;
303303
304− csd_tmp = kzalloc(16, GFP_KERNEL);
305− if (!csd_tmp)
304+ cxd_tmp = kzalloc(16, GFP_KERNEL);
305+ if (!cxd_tmp)
306306 return -ENOMEM;
307307
308− ret = mmc_send_cxd_data(NULL, host, MMC_SEND_CSD, csd_tmp, 16);
308+ ret = mmc_send_cxd_data(NULL, host, opcode, cxd_tmp, 16);
309309 if (ret)
310310 goto err;
311311
312312 for (i = 0; i < 4; i++)
313− csd[i] = be32_to_cpu(csd_tmp[i]);
313+ cxd[i] = be32_to_cpu(cxd_tmp[i]);
314314
315315 err:
316− kfree(csd_tmp);
316+ kfree(cxd_tmp);
317317 return ret;
318318 }
319319
320320 int mmc_send_csd(struct mmc_card *card, u32 *csd)
321321 {
322322 if (mmc_host_is_spi(card->host))
323− return mmc_spi_send_csd(card->host, csd);
323+ return mmc_spi_send_cxd(card->host, csd, MMC_SEND_CSD);
324324
325325 return mmc_send_cxd_native(card->host, card->rca << 16, csd,
326326 MMC_SEND_CSD);
327327 }
328328
329−static int mmc_spi_send_cid(struct mmc_host *host, u32 *cid)
330−{
331− int ret, i;
332− __be32 *cid_tmp;
333−
334− cid_tmp = kzalloc(16, GFP_KERNEL);
335− if (!cid_tmp)
336− return -ENOMEM;
337−
338− ret = mmc_send_cxd_data(NULL, host, MMC_SEND_CID, cid_tmp, 16);
339− if (ret)
340− goto err;
341−
342− for (i = 0; i < 4; i++)
343− cid[i] = be32_to_cpu(cid_tmp[i]);
344−
345−err:
346− kfree(cid_tmp);
347− return ret;
348−}
349−
350329 int mmc_send_cid(struct mmc_host *host, u32 *cid)
351330 {
352331 if (mmc_host_is_spi(host))
353− return mmc_spi_send_cid(host, cid);
332+ return mmc_spi_send_cxd(host, cid, MMC_SEND_CID);
354333
355334 return mmc_send_cxd_native(host, 0, cid, MMC_ALL_SEND_CID);
356335 }
@@ -553,12 +532,13 @@ int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, · 196 unmodified lines
553532 * @timing: new timing to change to
554533 * @send_status: send status cmd to poll for busy
555534 * @retry_crc_err: retry when CRC errors when polling with CMD13 for busy
535+ * @retries: number of retries
556536 *
557537 * Modifies the EXT_CSD register for selected card.
558538 */
559539 int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
560540 unsigned int timeout_ms, unsigned char timing,
561− bool send_status, bool retry_crc_err)
541+ bool send_status, bool retry_crc_err, unsigned int retries)
562542 {
563543 struct mmc_host *host = card->host;
564544 int err;
@@ -598,7 +578,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, · 33 unmodified lines
598578 cmd.flags |= MMC_RSP_SPI_R1 | MMC_RSP_R1;
599579 }
600580
601− err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
581+ err = mmc_wait_for_cmd(host, &cmd, retries);
602582 if (err)
603583 goto out;
604584
@@ -633,7 +613,7 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, · 28 unmodified lines
633613 unsigned int timeout_ms)
634614 {
635615 return __mmc_switch(card, set, index, value, timeout_ms, 0,
636− true, false);
616+ true, false, MMC_CMD_RETRIES);
637617 }
638618 EXPORT_SYMBOL_GPL(mmc_switch);
639619
@@ -988,9 +968,7 @@ int mmc_flush_cache(struct mmc_card *card) · 348 unmodified lines
988968 {
989969 int err = 0;
990970
991− if (mmc_card_mmc(card) &&
992− (card->ext_csd.cache_size > 0) &&
993− (card->ext_csd.cache_ctrl & 1)) {
971+ if (mmc_cache_enabled(card->host)) {
994972 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
995973 EXT_CSD_FLUSH_CACHE, 1,
996974 MMC_CACHE_FLUSH_TIMEOUT_MS);
@@ -1031,7 +1009,7 @@ int mmc_cmdq_disable(struct mmc_card *card) · 34 unmodified lines
10311009 }
10321010 EXPORT_SYMBOL_GPL(mmc_cmdq_disable);
10331011
1034−int mmc_sanitize(struct mmc_card *card)
1012+int mmc_sanitize(struct mmc_card *card, unsigned int timeout_ms)
10351013 {
10361014 struct mmc_host *host = card->host;
10371015 int err;
@@ -1041,12 +1019,15 @@ int mmc_sanitize(struct mmc_card *card) · 3 unmodified lines
10411019 return -EOPNOTSUPP;
10421020 }
10431021
1022+ if (!timeout_ms)
1023+ timeout_ms = MMC_SANITIZE_TIMEOUT_MS;
1024+
10441025 pr_debug("%s: Sanitize in progress...\n", mmc_hostname(host));
10451026
10461027 mmc_retune_hold(host);
10471028
1048− err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_SANITIZE_START,
1049− 1, MMC_SANITIZE_TIMEOUT_MS);
1029+ err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_SANITIZE_START,
1030+ 1, timeout_ms, 0, true, false, 0);
10501031 if (err)
10511032 pr_err("%s: Sanitize failed err=%d\n", mmc_hostname(host), err);
10521033
drivers/mmc/core/mmc_ops.h+2−2
@@ -39,14 +39,14 @@ int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, · 38 unmodified lines
3939 enum mmc_busy_cmd busy_cmd);
4040 int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
4141 unsigned int timeout_ms, unsigned char timing,
42− bool send_status, bool retry_crc_err);
42+ bool send_status, bool retry_crc_err, unsigned int retries);
4343 int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
4444 unsigned int timeout_ms);
4545 void mmc_run_bkops(struct mmc_card *card);
4646 int mmc_flush_cache(struct mmc_card *card);
4747 int mmc_cmdq_enable(struct mmc_card *card);
4848 int mmc_cmdq_disable(struct mmc_card *card);
49−int mmc_sanitize(struct mmc_card *card);
49+int mmc_sanitize(struct mmc_card *card, unsigned int timeout_ms);
5050
5151 #endif
5252
drivers/mmc/core/queue.c+5−6
@@ -60,7 +60,7 @@ enum mmc_issue_type mmc_issue_type(struct mmc_queue *mq, struct request *req) · 59 unmodified lines
6060 {
6161 struct mmc_host *host = mq->card->host;
6262
63− if (mq->use_cqe && !host->hsq_enabled)
63+ if (host->cqe_enabled && !host->hsq_enabled)
6464 return mmc_cqe_issue_type(host, req);
6565
6666 if (req_op(req) == REQ_OP_READ || req_op(req) == REQ_OP_WRITE)
@@ -127,7 +127,7 @@ static enum blk_eh_timer_return mmc_mq_timed_out(struct request *req, · 60 unmodified lines
127127 bool ignore_tout;
128128
129129 spin_lock_irqsave(&mq->lock, flags);
130− ignore_tout = mq->recovery_needed || !mq->use_cqe || host->hsq_enabled;
130+ ignore_tout = mq->recovery_needed || !host->cqe_enabled || host->hsq_enabled;
131131 spin_unlock_irqrestore(&mq->lock, flags);
132132
133133 return ignore_tout ? BLK_EH_RESET_TIMER : mmc_cqe_timed_out(req);
@@ -144,7 +144,7 @@ static void mmc_mq_recovery_handler(struct work_struct *work) · 10 unmodified lines
144144
145145 mq->in_recovery = true;
146146
147− if (mq->use_cqe && !host->hsq_enabled)
147+ if (host->cqe_enabled && !host->hsq_enabled)
148148 mmc_blk_cqe_recovery(mq);
149149 else
150150 mmc_blk_mq_recovery(mq);
@@ -315,7 +315,7 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx, · 164 unmodified lines
315315 if (get_card)
316316 mmc_get_card(card, &mq->ctx);
317317
318− if (mq->use_cqe) {
318+ if (host->cqe_enabled) {
319319 host->retune_now = host->need_retune && cqe_retune_ok &&
320320 !host->hold_retune;
321321 }
@@ -430,7 +430,6 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card) · 108 unmodified lines
430430 int ret;
431431
432432 mq->card = card;
433− mq->use_cqe = host->cqe_enabled;
434433
435434 spin_lock_init(&mq->lock);
436435
@@ -440,7 +439,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card) · 3 unmodified lines
440439 * The queue depth for CQE must match the hardware because the request
441440 * tag is used to index the hardware queue.
442441 */
443− if (mq->use_cqe && !host->hsq_enabled)
442+ if (host->cqe_enabled && !host->hsq_enabled)
444443 mq->tag_set.queue_depth =
445444 min_t(int, card->ext_csd.cmdq_depth, host->cqe_qdepth);
446445 else
drivers/mmc/core/queue.h+0−1
@@ -82,7 +82,6 @@ struct mmc_queue { · 81 unmodified lines
8282 unsigned int cqe_busy;
8383 #define MMC_CQE_DCMD_BUSY BIT(0)
8484 bool busy;
85− bool use_cqe;
8685 bool recovery_needed;
8786 bool in_recovery;
8887 bool rw_wait;
drivers/mmc/core/sd.c+6−0
@@ -135,6 +135,9 @@ static int mmc_decode_csd(struct mmc_card *card) · 134 unmodified lines
135135 csd->erase_size = UNSTUFF_BITS(resp, 39, 7) + 1;
136136 csd->erase_size <<= csd->write_blkbits - 9;
137137 }
138+
139+ if (UNSTUFF_BITS(resp, 13, 1))
140+ mmc_card_set_readonly(card);
138141 break;
139142 case 1:
140143 /*
@@ -169,6 +172,9 @@ static int mmc_decode_csd(struct mmc_card *card) · 28 unmodified lines
169172 csd->write_blkbits = 9;
170173 csd->write_partial = 0;
171174 csd->erase_size = 1;
175+
176+ if (UNSTUFF_BITS(resp, 13, 1))
177+ mmc_card_set_readonly(card);
172178 break;
173179 default:
174180 pr_err("%s: unrecognised CSD structure version %d\n",
drivers/mmc/core/sdio.c+22−6
@@ -985,21 +985,37 @@ out: · 984 unmodified lines
985985 */
986986 static int mmc_sdio_pre_suspend(struct mmc_host *host)
987987 {
988− int i, err = 0;
988+ int i;
989989
990990 for (i = 0; i < host->card->sdio_funcs; i++) {
991991 struct sdio_func *func = host->card->sdio_func[i];
992992 if (func && sdio_func_present(func) && func->dev.driver) {
993993 const struct dev_pm_ops *pmops = func->dev.driver->pm;
994− if (!pmops || !pmops->suspend || !pmops->resume) {
994+ if (!pmops || !pmops->suspend || !pmops->resume)
995995 /* force removal of entire card in that case */
996− err = -ENOSYS;
997− break;
998− }
996+ goto remove;
999997 }
1000998 }
1001999
1002− return err;
1000+ return 0;
1001+
1002+remove:
1003+ if (!mmc_card_is_removable(host)) {
1004+ dev_warn(mmc_dev(host),
1005+ "missing suspend/resume ops for non-removable SDIO card\n");
1006+ /* Don't remove a non-removable card - we can't re-detect it. */
1007+ return 0;
1008+ }
1009+
1010+ /* Remove the SDIO card and let it be re-detected later on. */
1011+ mmc_sdio_remove(host);
1012+ mmc_claim_host(host);
1013+ mmc_detach_bus(host);
1014+ mmc_power_off(host);
1015+ mmc_release_host(host);
1016+ host->pm_flags = 0;
1017+
1018+ return 0;
10031019 }
10041020
10051021 /*
drivers/mmc/host/Kconfig+2−0
@@ -278,6 +278,7 @@ config MMC_SDHCI_ESDHC_IMX · 277 unmodified lines
278278 tristate "SDHCI support for the Freescale eSDHC/uSDHC i.MX controller"
279279 depends on ARCH_MXC || COMPILE_TEST
280280 depends on MMC_SDHCI_PLTFM
281+ depends on OF
281282 select MMC_SDHCI_IO_ACCESSORS
282283 select MMC_CQHCI
283284 help
@@ -707,6 +708,7 @@ config MMC_SDHI · 423 unmodified lines
707708 tristate "Renesas SDHI SD/SDIO controller support"
708709 depends on SUPERH || ARCH_RENESAS || COMPILE_TEST
709710 select MMC_TMIO_CORE
711+ select RESET_CONTROLLER if ARCH_RENESAS
710712 help
711713 This provides support for the SDHI SD/SDIO controller found in
712714 Renesas SuperH, ARM and ARM64 based SoCs
drivers/mmc/host/Makefile+0−2
@@ -34,9 +34,7 @@ obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o · 33 unmodified lines
3434 obj-$(CONFIG_MMC_MVSDIO) += mvsdio.o
3535 obj-$(CONFIG_MMC_DAVINCI) += davinci_mmc.o
3636 obj-$(CONFIG_MMC_SPI) += mmc_spi.o
37−ifeq ($(CONFIG_OF),y)
3837 obj-$(CONFIG_MMC_SPI) += of_mmc_spi.o
39−endif
4038 obj-$(CONFIG_MMC_S3C) += s3cmci.o
4139 obj-$(CONFIG_MMC_SDRICOH_CS) += sdricoh_cs.o
4240 obj-$(CONFIG_MMC_TMIO) += tmio_mmc.o
drivers/mmc/host/cavium.c+1−2
@@ -656,8 +656,7 @@ static void cvm_mmc_dma_request(struct mmc_host *mmc, · 655 unmodified lines
656656
657657 if (!mrq->data || !mrq->data->sg || !mrq->data->sg_len ||
658658 !mrq->stop || mrq->stop->opcode != MMC_STOP_TRANSMISSION) {
659− dev_err(&mmc->card->dev,
660− "Error: cmv_mmc_dma_request no data\n");
659+ dev_err(&mmc->card->dev, "Error: %s no data\n", __func__);
661660 goto error;
662661 }
663662
drivers/mmc/host/dw_mmc-k3.c+1−1
@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: GPL-2.0-or-later
22 /*
33 * Copyright (c) 2013 Linaro Ltd.
4− * Copyright (c) 2013 Hisilicon Limited.
4+ * Copyright (c) 2013 HiSilicon Limited.
55 */
66
77 #include <linux/bitops.h>
drivers/mmc/host/dw_mmc-rockchip.c+1−1
@@ -61,7 +61,7 @@ static void dw_mci_rk3288_set_ios(struct dw_mci *host, struct mmc_ios *ios) · 60 unmodified lines
6161 }
6262
6363 /* Make sure we use phases which we can enumerate with */
64− if (!IS_ERR(priv->sample_clk))
64+ if (!IS_ERR(priv->sample_clk) && ios->timing <= MMC_TIMING_SD_HS)
6565 clk_set_phase(priv->sample_clk, priv->default_sample_phase);
6666
6767 /*
drivers/mmc/host/dw_mmc.c+5−11
@@ -2606,8 +2606,6 @@ static void dw_mci_handle_cd(struct dw_mci *host) · 2605 unmodified lines
26062606 {
26072607 struct dw_mci_slot *slot = host->slot;
26082608
2609− if (slot->mmc->ops->card_event)
2610− slot->mmc->ops->card_event(slot->mmc);
26112609 mmc_detect_change(slot->mmc,
26122610 msecs_to_jiffies(host->pdata->detect_delay_ms));
26132611 }
@@ -3095,10 +3093,8 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) · 481 unmodified lines
30953093
30963094 /* find reset controller when exist */
30973095 pdata->rstc = devm_reset_control_get_optional_exclusive(dev, "reset");
3098− if (IS_ERR(pdata->rstc)) {
3099− if (PTR_ERR(pdata->rstc) == -EPROBE_DEFER)
3100− return ERR_PTR(-EPROBE_DEFER);
3101− }
3096+ if (IS_ERR(pdata->rstc))
3097+ return ERR_CAST(pdata->rstc);
31023098
31033099 if (device_property_read_u32(dev, "fifo-depth", &pdata->fifo_depth))
31043100 dev_info(dev,
@@ -3204,7 +3200,7 @@ int dw_mci_probe(struct dw_mci *host) · 99 unmodified lines
32043200 goto err_clk_ciu;
32053201 }
32063202
3207− if (!IS_ERR(host->pdata->rstc)) {
3203+ if (host->pdata->rstc) {
32083204 reset_control_assert(host->pdata->rstc);
32093205 usleep_range(10, 50);
32103206 reset_control_deassert(host->pdata->rstc);
@@ -3344,8 +3340,7 @@ err_dmaunmap: · 133 unmodified lines
33443340 if (host->use_dma && host->dma_ops->exit)
33453341 host->dma_ops->exit(host);
33463342
3347− if (!IS_ERR(host->pdata->rstc))
3348− reset_control_assert(host->pdata->rstc);
3343+ reset_control_assert(host->pdata->rstc);
33493344
33503345 err_clk_ciu:
33513346 clk_disable_unprepare(host->ciu_clk);
@@ -3373,8 +3368,7 @@ void dw_mci_remove(struct dw_mci *host) · 21 unmodified lines
33733368 if (host->use_dma && host->dma_ops->exit)
33743369 host->dma_ops->exit(host);
33753370
3376− if (!IS_ERR(host->pdata->rstc))
3377− reset_control_assert(host->pdata->rstc);
3371+ reset_control_assert(host->pdata->rstc);
33783372
33793373 clk_disable_unprepare(host->ciu_clk);
33803374 clk_disable_unprepare(host->biu_clk);
drivers/mmc/host/mmc_spi.c+4−4
@@ -1397,6 +1397,8 @@ static int mmc_spi_probe(struct spi_device *spi) · 1396 unmodified lines
13971397
13981398 host->ones = ones;
13991399
1400+ dev_set_drvdata(&spi->dev, mmc);
1401+
14001402 /* Platform data is used to hook up things like card sensing
14011403 * and power switching gpios.
14021404 */
@@ -1413,8 +1415,6 @@ static int mmc_spi_probe(struct spi_device *spi) · 10 unmodified lines
14131415 host->powerup_msecs = 250;
14141416 }
14151417
1416− dev_set_drvdata(&spi->dev, mmc);
1417−
14181418 /* preallocate dma buffers */
14191419 host->data = kmalloc(sizeof(*host->data), GFP_KERNEL);
14201420 if (!host->data)
@@ -1494,8 +1494,8 @@ fail_glue_init: · 73 unmodified lines
14941494 fail_dma:
14951495 kfree(host->data);
14961496 fail_nobuf1:
1497− mmc_free_host(mmc);
14981497 mmc_spi_put_pdata(spi);
1498+ mmc_free_host(mmc);
14991499 nomem:
15001500 kfree(ones);
15011501 return status;
@@ -1518,8 +1518,8 @@ static int mmc_spi_remove(struct spi_device *spi) · 16 unmodified lines
15181518 kfree(host->ones);
15191519
15201520 spi->max_speed_hz = mmc->f_max;
1521− mmc_free_host(mmc);
15221521 mmc_spi_put_pdata(spi);
1522+ mmc_free_host(mmc);
15231523 return 0;
15241524 }
15251525
drivers/mmc/host/moxart-mmc.c+4−6
@@ -257,7 +257,6 @@ static void moxart_dma_complete(void *param) · 256 unmodified lines
257257 static void moxart_transfer_dma(struct mmc_data *data, struct moxart_host *host)
258258 {
259259 u32 len, dir_slave;
260− long dma_time;
261260 struct dma_async_tx_descriptor *desc = NULL;
262261 struct dma_chan *dma_chan;
263262
@@ -294,8 +293,8 @@ static void moxart_transfer_dma(struct mmc_data *data, struct moxart_host *host) · 30 unmodified lines
294293
295294 data->bytes_xfered += host->data_remain;
296295
297− dma_time = wait_for_completion_interruptible_timeout(
298− &host->dma_complete, host->timeout);
296+ wait_for_completion_interruptible_timeout(&host->dma_complete,
297+ host->timeout);
299298
300299 dma_unmap_sg(dma_chan->device->dev,
301300 data->sg, data->sg_len,
@@ -395,7 +394,6 @@ static void moxart_prepare_data(struct moxart_host *host) · 93 unmodified lines
395394 static void moxart_request(struct mmc_host *mmc, struct mmc_request *mrq)
396395 {
397396 struct moxart_host *host = mmc_priv(mmc);
398− long pio_time;
399397 unsigned long flags;
400398 u32 status;
401399
@@ -431,8 +429,8 @@ static void moxart_request(struct mmc_host *mmc, struct mmc_request *mrq) · 29 unmodified lines
431429 spin_unlock_irqrestore(&host->lock, flags);
432430
433431 /* PIO transfers start from interrupt. */
434− pio_time = wait_for_completion_interruptible_timeout(
435− &host->pio_complete, host->timeout);
432+ wait_for_completion_interruptible_timeout(&host->pio_complete,
433+ host->timeout);
436434
437435 spin_lock_irqsave(&host->lock, flags);
438436 }
drivers/mmc/host/of_mmc_spi.c+6−12
@@ -19,11 +19,6 @@ · 18 unmodified lines
1919 #include <linux/mmc/core.h>
2020 #include <linux/mmc/host.h>
2121
22−/* For archs that don't support NO_IRQ (such as mips), provide a dummy value */
23−#ifndef NO_IRQ
24−#define NO_IRQ 0
25−#endif
26−
2722 MODULE_LICENSE("GPL");
2823
2924 struct of_mmc_spi {
@@ -54,22 +49,22 @@ static void of_mmc_spi_exit(struct device *dev, void *mmc) · 24 unmodified lines
5449
5550 struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
5651 {
52+ struct mmc_host *mmc = dev_get_drvdata(&spi->dev);
5753 struct device *dev = &spi->dev;
58− struct device_node *np = dev->of_node;
5954 struct of_mmc_spi *oms;
6055
61− if (dev->platform_data || !np)
56+ if (dev->platform_data || !dev_fwnode(dev))
6257 return dev->platform_data;
6358
6459 oms = kzalloc(sizeof(*oms), GFP_KERNEL);
6560 if (!oms)
6661 return NULL;
6762
68− if (mmc_of_parse_voltage(np, &oms->pdata.ocr_mask) <= 0)
63+ if (mmc_of_parse_voltage(mmc, &oms->pdata.ocr_mask) < 0)
6964 goto err_ocr;
7065
71− oms->detect_irq = irq_of_parse_and_map(np, 0);
72− if (oms->detect_irq != 0) {
66+ oms->detect_irq = spi->irq;
67+ if (oms->detect_irq > 0) {
7368 oms->pdata.init = of_mmc_spi_init;
7469 oms->pdata.exit = of_mmc_spi_exit;
7570 } else {
@@ -87,10 +82,9 @@ EXPORT_SYMBOL(mmc_spi_get_pdata); · 11 unmodified lines
8782 void mmc_spi_put_pdata(struct spi_device *spi)
8883 {
8984 struct device *dev = &spi->dev;
90− struct device_node *np = dev->of_node;
9185 struct of_mmc_spi *oms = to_of_mmc_spi(dev);
9286
93− if (!dev->platform_data || !np)
87+ if (!dev->platform_data || !dev_fwnode(dev))
9488 return;
9589
9690 kfree(oms);
drivers/mmc/host/owl-mmc.c+0−1
@@ -581,7 +581,6 @@ static int owl_mmc_probe(struct platform_device *pdev) · 580 unmodified lines
581581 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
582582 owl_host->base = devm_ioremap_resource(&pdev->dev, res);
583583 if (IS_ERR(owl_host->base)) {
584− dev_err(&pdev->dev, "Failed to remap registers\n");
585584 ret = PTR_ERR(owl_host->base);
586585 goto err_free_host;
587586 }
drivers/mmc/host/renesas_sdhi.h+2−0
@@ -70,6 +70,8 @@ struct renesas_sdhi { · 69 unmodified lines
7070 DECLARE_BITMAP(smpcmp, BITS_PER_LONG);
7171 unsigned int tap_num;
7272 unsigned int tap_set;
73+
74+ struct reset_control *rstc;
7375 };
7476
7577 #define host_to_priv(host) \
drivers/mmc/host/renesas_sdhi_core.c+28−10
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020
2121 #include <linux/clk.h>
2222 #include <linux/delay.h>
23+#include <linux/iopoll.h>
2324 #include <linux/kernel.h>
2425 #include <linux/mfd/tmio.h>
2526 #include <linux/mmc/host.h>
@@ -32,6 +33,7 @@ · 6 unmodified lines
3233 #include <linux/platform_device.h>
3334 #include <linux/pm_domain.h>
3435 #include <linux/regulator/consumer.h>
36+#include <linux/reset.h>
3537 #include <linux/sh_dma.h>
3638 #include <linux/slab.h>
3739 #include <linux/sys_soc.h>
@@ -557,24 +559,35 @@ static int renesas_sdhi_prepare_hs400_tuning(struct mmc_host *mmc, struct mmc_io · 519 unmodified lines
557559 return 0;
558560 }
559561
562+static void renesas_sdhi_scc_reset(struct tmio_mmc_host *host, struct renesas_sdhi *priv)
563+{
564+ renesas_sdhi_disable_scc(host->mmc);
565+ renesas_sdhi_reset_hs400_mode(host, priv);
566+ priv->needs_adjust_hs400 = false;
567+
568+ sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL,
569+ ~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN &
570+ sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL));
571+}
572+
560573 /* only populated for TMIO_MMC_MIN_RCAR2 */
561574 static void renesas_sdhi_reset(struct tmio_mmc_host *host)
562575 {
563576 struct renesas_sdhi *priv = host_to_priv(host);
577+ int ret;
564578 u16 val;
565579
566− if (priv->scc_ctl) {
567− renesas_sdhi_disable_scc(host->mmc);
568− renesas_sdhi_reset_hs400_mode(host, priv);
580+ if (priv->rstc) {
581+ reset_control_reset(priv->rstc);
582+ /* Unknown why but without polling reset status, it will hang */
583+ read_poll_timeout(reset_control_status, ret, ret == 0, 1, 100,
584+ false, priv->rstc);
569585 priv->needs_adjust_hs400 = false;
570−
571− sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL,
572− ~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN &
573− sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL));
586+ renesas_sdhi_set_clock(host, host->clk_cache);
587+ } else if (priv->scc_ctl) {
588+ renesas_sdhi_scc_reset(host, priv);
574589 }
575590
576− sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, TMIO_MASK_INIT_RCAR2);
577−
578591 if (sd_ctrl_read16(host, CTL_VERSION) >= SDHI_VER_GEN3_SD) {
579592 val = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT);
580593 val |= CARD_OPT_EXTOP;
@@ -691,7 +704,7 @@ static int renesas_sdhi_execute_tuning(struct mmc_host *mmc, u32 opcode) · 110 unmodified lines
691704
692705 ret = renesas_sdhi_select_tuning(host);
693706 if (ret < 0)
694− renesas_sdhi_reset(host);
707+ renesas_sdhi_scc_reset(host, priv);
695708 return ret;
696709 }
697710
@@ -1034,6 +1047,7 @@ int renesas_sdhi_probe(struct platform_device *pdev, · 336 unmodified lines
10341047 host->ops.start_signal_voltage_switch =
10351048 renesas_sdhi_start_signal_voltage_switch;
10361049 host->sdcard_irq_setbit_mask = TMIO_STAT_ALWAYS_SET_27;
1050+ host->sdcard_irq_mask_all = TMIO_MASK_ALL_RCAR2;
10371051 host->reset = renesas_sdhi_reset;
10381052 }
10391053
@@ -1076,6 +1090,10 @@ int renesas_sdhi_probe(struct platform_device *pdev, · 36 unmodified lines
10761090 if (ret)
10771091 goto efree;
10781092
1093+ priv->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
1094+ if (IS_ERR(priv->rstc))
1095+ return PTR_ERR(priv->rstc);
1096+
10791097 ver = sd_ctrl_read16(host, CTL_VERSION);
10801098 /* GEN2_SDR104 is first known SDHI to use 32bit block count */
10811099 if (ver < SDHI_VER_GEN2_SDR104 && mmc_data->max_blk_count > U16_MAX)
drivers/mmc/host/renesas_sdhi_internal_dmac.c+2−2
@@ -97,7 +97,7 @@ static const struct renesas_sdhi_of_data of_rza2_compatible = { · 96 unmodified lines
9797 TMIO_MMC_HAVE_CBSY,
9898 .tmio_ocr_mask = MMC_VDD_32_33,
9999 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
100− MMC_CAP_CMD23,
100+ MMC_CAP_CMD23 | MMC_CAP_WAIT_WHILE_BUSY,
101101 .bus_shift = 2,
102102 .scc_offset = 0 - 0x1000,
103103 .taps = rcar_gen3_scc_taps,
@@ -111,7 +111,7 @@ static const struct renesas_sdhi_of_data of_rcar_gen3_compatible = { · 7 unmodified lines
111111 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL |
112112 TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,
113113 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
114− MMC_CAP_CMD23,
114+ MMC_CAP_CMD23 | MMC_CAP_WAIT_WHILE_BUSY,
115115 .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT | MMC_CAP2_MERGE_CAPABLE,
116116 .bus_shift = 2,
117117 .scc_offset = 0x1000,
drivers/mmc/host/renesas_sdhi_sys_dmac.c+5−3
@@ -33,12 +33,14 @@ static const struct renesas_sdhi_of_data of_rz_compatible = { · 32 unmodified lines
3333 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_32BIT_DATA_PORT |
3434 TMIO_MMC_HAVE_CBSY,
3535 .tmio_ocr_mask = MMC_VDD_32_33,
36− .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
36+ .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
37+ MMC_CAP_WAIT_WHILE_BUSY,
3738 };
3839
3940 static const struct renesas_sdhi_of_data of_rcar_gen1_compatible = {
4041 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL,
41− .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
42+ .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
43+ MMC_CAP_WAIT_WHILE_BUSY,
4244 .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
4345 };
4446
@@ -58,7 +60,7 @@ static const struct renesas_sdhi_of_data of_rcar_gen2_compatible = { · 13 unmodified lines
5860 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL |
5961 TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,
6062 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
61− MMC_CAP_CMD23,
63+ MMC_CAP_CMD23 | MMC_CAP_WAIT_WHILE_BUSY,
6264 .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
6365 .dma_buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES,
6466 .dma_rx_offset = 0x2000,
drivers/mmc/host/sdhci-acpi.c+2−0
@@ -772,6 +772,7 @@ static const struct sdhci_acpi_uid_slot sdhci_acpi_uids[] = { · 771 unmodified lines
772772 { "QCOM8051", NULL, &sdhci_acpi_slot_qcom_sd_3v },
773773 { "QCOM8052", NULL, &sdhci_acpi_slot_qcom_sd },
774774 { "AMDI0040", NULL, &sdhci_acpi_slot_amd_emmc },
775+ { "AMDI0041", NULL, &sdhci_acpi_slot_amd_emmc },
775776 { },
776777 };
777778
@@ -789,6 +790,7 @@ static const struct acpi_device_id sdhci_acpi_ids[] = { · 11 unmodified lines
789790 { "QCOM8051" },
790791 { "QCOM8052" },
791792 { "AMDI0040" },
793+ { "AMDI0041" },
792794 { },
793795 };
794796 MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids);
drivers/mmc/host/sdhci-brcmstb.c+0−1
@@ -199,7 +199,6 @@ static int sdhci_brcmstb_add_host(struct sdhci_host *host, · 198 unmodified lines
199199 if (dma64) {
200200 dev_dbg(mmc_dev(host->mmc), "Using 64 bit DMA\n");
201201 cq_host->caps |= CQHCI_TASK_DESC_SZ_128;
202− cq_host->quirks |= CQHCI_QUIRK_SHORT_TXFR_DESC_SZ;
203202 }
204203
205204 ret = cqhci_init(cq_host, host->mmc, dma64);
drivers/mmc/host/sdhci-esdhc-imx.c+7−19
@@ -434,10 +434,10 @@ static u32 esdhc_readl_le(struct sdhci_host *host, int reg) · 433 unmodified lines
434434 * Do not advertise faster UHS modes if there are no
435435 * pinctrl states for 100MHz/200MHz.
436436 */
437− if (IS_ERR_OR_NULL(imx_data->pins_100mhz) ||
438− IS_ERR_OR_NULL(imx_data->pins_200mhz))
439− val &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_DDR50
440− | SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_HS400);
437+ if (IS_ERR_OR_NULL(imx_data->pins_100mhz))
438+ val &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_DDR50);
439+ if (IS_ERR_OR_NULL(imx_data->pins_200mhz))
440+ val &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_HS400);
441441 }
442442 }
443443
@@ -1453,7 +1453,6 @@ static const struct cqhci_host_ops esdhc_cqhci_ops = { · 1009 unmodified lines
14531453 .dumpregs = esdhc_sdhci_dumpregs,
14541454 };
14551455
1456−#ifdef CONFIG_OF
14571456 static int
14581457 sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
14591458 struct sdhci_host *host,
@@ -1486,9 +1485,9 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, · 26 unmodified lines
14861485 if (of_property_read_u32(np, "fsl,delay-line", &boarddata->delay_line))
14871486 boarddata->delay_line = 0;
14881487
1489− mmc_of_parse_voltage(np, &host->ocr_mask);
1488+ mmc_of_parse_voltage(host->mmc, &host->ocr_mask);
14901489
1491− if (esdhc_is_usdhc(imx_data)) {
1490+ if (esdhc_is_usdhc(imx_data) && !IS_ERR(imx_data->pinctrl)) {
14921491 imx_data->pins_100mhz = pinctrl_lookup_state(imx_data->pinctrl,
14931492 ESDHC_PINCTRL_STATE_100MHZ);
14941493 imx_data->pins_200mhz = pinctrl_lookup_state(imx_data->pinctrl,
@@ -1505,20 +1504,9 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, · 10 unmodified lines
15051504
15061505 return 0;
15071506 }
1508−#else
1509−static inline int
1510−sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
1511− struct sdhci_host *host,
1512− struct pltfm_imx_data *imx_data)
1513−{
1514− return -ENODEV;
1515−}
1516−#endif
15171507
15181508 static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
15191509 {
1520− const struct of_device_id *of_id =
1521− of_match_device(imx_esdhc_dt_ids, &pdev->dev);
15221510 struct sdhci_pltfm_host *pltfm_host;
15231511 struct sdhci_host *host;
15241512 struct cqhci_host *cq_host;
@@ -1534,7 +1522,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) · 9 unmodified lines
15341522
15351523 imx_data = sdhci_pltfm_priv(pltfm_host);
15361524
1537− imx_data->socdata = of_id->data;
1525+ imx_data->socdata = device_get_match_data(&pdev->dev);
15381526
15391527 if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS)
15401528 cpu_latency_qos_add_request(&imx_data->pm_qos_req, 0);
drivers/mmc/host/sdhci-esdhc-mcf.c+4−4
@@ -367,14 +367,14 @@ static int esdhc_mcf_plat_init(struct sdhci_host *host, · 366 unmodified lines
367367 struct pltfm_mcf_data *mcf_data)
368368 {
369369 struct mcf_esdhc_platform_data *plat_data;
370+ struct device *dev = mmc_dev(host->mmc);
370371
371− if (!host->mmc->parent->platform_data) {
372− dev_err(mmc_dev(host->mmc), "no platform data!\n");
372+ if (!dev->platform_data) {
373+ dev_err(dev, "no platform data!\n");
373374 return -EINVAL;
374375 }
375376
376− plat_data = (struct mcf_esdhc_platform_data *)
377− host->mmc->parent->platform_data;
377+ plat_data = (struct mcf_esdhc_platform_data *)dev->platform_data;
378378
379379 /* Card_detect */
380380 switch (plat_data->cd_type) {
drivers/mmc/host/sdhci-msm.c+2−6
@@ -1863,7 +1863,6 @@ static int sdhci_msm_ice_init(struct sdhci_msm_host *msm_host, · 1862 unmodified lines
18631863 struct mmc_host *mmc = msm_host->mmc;
18641864 struct device *dev = mmc_dev(mmc);
18651865 struct resource *res;
1866− int err;
18671866
18681867 if (!(cqhci_readl(cq_host, CQHCI_CAP) & CQHCI_CAP_CS))
18691868 return 0;
@@ -1881,11 +1880,8 @@ static int sdhci_msm_ice_init(struct sdhci_msm_host *msm_host, · 11 unmodified lines
18811880 }
18821881
18831882 msm_host->ice_mem = devm_ioremap_resource(dev, res);
1884− if (IS_ERR(msm_host->ice_mem)) {
1885− err = PTR_ERR(msm_host->ice_mem);
1886− dev_err(dev, "Failed to map ICE registers; err=%d\n", err);
1887− return err;
1888− }
1883+ if (IS_ERR(msm_host->ice_mem))
1884+ return PTR_ERR(msm_host->ice_mem);
18891885
18901886 if (!sdhci_msm_ice_supported(msm_host))
18911887 goto disable;
drivers/mmc/host/sdhci-of-aspeed.c+1−1
@@ -181,7 +181,7 @@ aspeed_sdhci_configure_phase(struct sdhci_host *host, unsigned long rate) · 180 unmodified lines
181181 struct aspeed_sdhci *sdhci;
182182 struct device *dev;
183183
184− dev = host->mmc->parent;
184+ dev = mmc_dev(host->mmc);
185185 sdhci = sdhci_pltfm_priv(sdhci_priv(host));
186186
187187 if (!sdhci->phase_desc)
drivers/mmc/host/sdhci-of-dwcmshc.c+292−21
@@ -7,11 +7,14 @@ · 6 unmodified lines
77 * Author: Jisheng Zhang <jszhang@kernel.org>
88 */
99
10+#include <linux/acpi.h>
1011 #include <linux/clk.h>
1112 #include <linux/dma-mapping.h>
13+#include <linux/iopoll.h>
1214 #include <linux/kernel.h>
1315 #include <linux/module.h>
1416 #include <linux/of.h>
17+#include <linux/of_device.h>
1518 #include <linux/sizes.h>
1619
1720 #include "sdhci-pltfm.h"
@@ -21,11 +24,52 @@ · 3 unmodified lines
2124 /* DWCMSHC specific Mode Select value */
2225 #define DWCMSHC_CTRL_HS400 0x7
2326
27+/* DWC IP vendor area 1 pointer */
28+#define DWCMSHC_P_VENDOR_AREA1 0xe8
29+#define DWCMSHC_AREA1_MASK GENMASK(11, 0)
30+/* Offset inside the vendor area 1 */
31+#define DWCMSHC_HOST_CTRL3 0x8
32+#define DWCMSHC_EMMC_CONTROL 0x2c
33+#define DWCMSHC_ENHANCED_STROBE BIT(8)
34+#define DWCMSHC_EMMC_ATCTRL 0x40
35+
36+/* Rockchip specific Registers */
37+#define DWCMSHC_EMMC_DLL_CTRL 0x800
38+#define DWCMSHC_EMMC_DLL_RXCLK 0x804
39+#define DWCMSHC_EMMC_DLL_TXCLK 0x808
40+#define DWCMSHC_EMMC_DLL_STRBIN 0x80c
41+#define DLL_STRBIN_TAPNUM_FROM_SW BIT(24)
42+#define DWCMSHC_EMMC_DLL_STATUS0 0x840
43+#define DWCMSHC_EMMC_DLL_START BIT(0)
44+#define DWCMSHC_EMMC_DLL_LOCKED BIT(8)
45+#define DWCMSHC_EMMC_DLL_TIMEOUT BIT(9)
46+#define DWCMSHC_EMMC_DLL_RXCLK_SRCSEL 29
47+#define DWCMSHC_EMMC_DLL_START_POINT 16
48+#define DWCMSHC_EMMC_DLL_INC 8
49+#define DWCMSHC_EMMC_DLL_DLYENA BIT(27)
50+#define DLL_TXCLK_TAPNUM_DEFAULT 0x8
51+#define DLL_STRBIN_TAPNUM_DEFAULT 0x8
52+#define DLL_TXCLK_TAPNUM_FROM_SW BIT(24)
53+#define DLL_RXCLK_NO_INVERTER 1
54+#define DLL_RXCLK_INVERTER 0
55+#define DLL_LOCK_WO_TMOUT(x) \
56+ ((((x) & DWCMSHC_EMMC_DLL_LOCKED) == DWCMSHC_EMMC_DLL_LOCKED) && \
57+ (((x) & DWCMSHC_EMMC_DLL_TIMEOUT) == 0))
58+#define RK3568_MAX_CLKS 3
59+
2460 #define BOUNDARY_OK(addr, len) \
2561 ((addr | (SZ_128M - 1)) == ((addr + len - 1) | (SZ_128M - 1)))
2662
63+struct rk3568_priv {
64+ /* Rockchip specified optional clocks */
65+ struct clk_bulk_data rockchip_clks[RK3568_MAX_CLKS];
66+ u8 txclk_tapnum;
67+};
68+
2769 struct dwcmshc_priv {
2870 struct clk *bus_clk;
71+ int vendor_specific_area1; /* P_VENDOR_SPECIFIC_AREA reg */
72+ void *priv; /* pointer to SoC private stuff */
2973 };
3074
3175 /*
@@ -51,6 +95,16 @@ static void dwcmshc_adma_write_desc(struct sdhci_host *host, void **desc, · 19 unmodified lines
5195 sdhci_adma_write_desc(host, desc, addr, len, cmd);
5296 }
5397
98+static unsigned int dwcmshc_get_max_clock(struct sdhci_host *host)
99+{
100+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
101+
102+ if (pltfm_host->clk)
103+ return sdhci_pltfm_clk_get_max_clock(host);
104+ else
105+ return pltfm_host->clock;
106+}
107+
54108 static void dwcmshc_check_auto_cmd23(struct mmc_host *mmc,
55109 struct mmc_request *mrq)
56110 {
@@ -100,10 +154,120 @@ static void dwcmshc_set_uhs_signaling(struct sdhci_host *host, · 43 unmodified lines
100154 sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
101155 }
102156
157+static void dwcmshc_hs400_enhanced_strobe(struct mmc_host *mmc,
158+ struct mmc_ios *ios)
159+{
160+ u32 vendor;
161+ struct sdhci_host *host = mmc_priv(mmc);
162+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
163+ struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host);
164+ int reg = priv->vendor_specific_area1 + DWCMSHC_EMMC_CONTROL;
165+
166+ vendor = sdhci_readl(host, reg);
167+ if (ios->enhanced_strobe)
168+ vendor |= DWCMSHC_ENHANCED_STROBE;
169+ else
170+ vendor &= ~DWCMSHC_ENHANCED_STROBE;
171+
172+ sdhci_writel(host, vendor, reg);
173+}
174+
175+static void dwcmshc_rk3568_set_clock(struct sdhci_host *host, unsigned int clock)
176+{
177+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
178+ struct dwcmshc_priv *dwc_priv = sdhci_pltfm_priv(pltfm_host);
179+ struct rk3568_priv *priv = dwc_priv->priv;
180+ u8 txclk_tapnum = DLL_TXCLK_TAPNUM_DEFAULT;
181+ u32 extra, reg;
182+ int err;
183+
184+ host->mmc->actual_clock = 0;
185+
186+ /*
187+ * DO NOT TOUCH THIS SETTING. RX clk inverter unit is enabled
188+ * by default, but it shouldn't be enabled. We should anyway
189+ * disable it before issuing any cmds.
190+ */
191+ extra = DWCMSHC_EMMC_DLL_DLYENA |
192+ DLL_RXCLK_NO_INVERTER << DWCMSHC_EMMC_DLL_RXCLK_SRCSEL;
193+ sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_RXCLK);
194+
195+ if (clock == 0)
196+ return;
197+
198+ /* Rockchip platform only support 375KHz for identify mode */
199+ if (clock <= 400000)
200+ clock = 375000;
201+
202+ err = clk_set_rate(pltfm_host->clk, clock);
203+ if (err)
204+ dev_err(mmc_dev(host->mmc), "fail to set clock %d", clock);
205+
206+ sdhci_set_clock(host, clock);
207+
208+ /* Disable cmd conflict check */
209+ reg = dwc_priv->vendor_specific_area1 + DWCMSHC_HOST_CTRL3;
210+ extra = sdhci_readl(host, reg);
211+ extra &= ~BIT(0);
212+ sdhci_writel(host, extra, reg);
213+
214+ if (clock <= 400000) {
215+ /* Disable DLL to reset sample clock */
216+ sdhci_writel(host, 0, DWCMSHC_EMMC_DLL_CTRL);
217+ return;
218+ }
219+
220+ /* Reset DLL */
221+ sdhci_writel(host, BIT(1), DWCMSHC_EMMC_DLL_CTRL);
222+ udelay(1);
223+ sdhci_writel(host, 0x0, DWCMSHC_EMMC_DLL_CTRL);
224+
225+ /* Init DLL settings */
226+ extra = 0x5 << DWCMSHC_EMMC_DLL_START_POINT |
227+ 0x2 << DWCMSHC_EMMC_DLL_INC |
228+ DWCMSHC_EMMC_DLL_START;
229+ sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_CTRL);
230+ err = readl_poll_timeout(host->ioaddr + DWCMSHC_EMMC_DLL_STATUS0,
231+ extra, DLL_LOCK_WO_TMOUT(extra), 1,
232+ 500 * USEC_PER_MSEC);
233+ if (err) {
234+ dev_err(mmc_dev(host->mmc), "DLL lock timeout!\n");
235+ return;
236+ }
237+
238+ extra = 0x1 << 16 | /* tune clock stop en */
239+ 0x2 << 17 | /* pre-change delay */
240+ 0x3 << 19; /* post-change delay */
241+ sdhci_writel(host, extra, dwc_priv->vendor_specific_area1 + DWCMSHC_EMMC_ATCTRL);
242+
243+ if (host->mmc->ios.timing == MMC_TIMING_MMC_HS200 ||
244+ host->mmc->ios.timing == MMC_TIMING_MMC_HS400)
245+ txclk_tapnum = priv->txclk_tapnum;
246+
247+ extra = DWCMSHC_EMMC_DLL_DLYENA |
248+ DLL_TXCLK_TAPNUM_FROM_SW |
249+ txclk_tapnum;
250+ sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_TXCLK);
251+
252+ extra = DWCMSHC_EMMC_DLL_DLYENA |
253+ DLL_STRBIN_TAPNUM_DEFAULT |
254+ DLL_STRBIN_TAPNUM_FROM_SW;
255+ sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_STRBIN);
256+}
257+
103258 static const struct sdhci_ops sdhci_dwcmshc_ops = {
104259 .set_clock = sdhci_set_clock,
105260 .set_bus_width = sdhci_set_bus_width,
106261 .set_uhs_signaling = dwcmshc_set_uhs_signaling,
262+ .get_max_clock = dwcmshc_get_max_clock,
263+ .reset = sdhci_reset,
264+ .adma_write_desc = dwcmshc_adma_write_desc,
265+};
266+
267+static const struct sdhci_ops sdhci_dwcmshc_rk3568_ops = {
268+ .set_clock = dwcmshc_rk3568_set_clock,
269+ .set_bus_width = sdhci_set_bus_width,
270+ .set_uhs_signaling = dwcmshc_set_uhs_signaling,
107271 .get_max_clock = sdhci_pltfm_clk_get_max_clock,
108272 .reset = sdhci_reset,
109273 .adma_write_desc = dwcmshc_adma_write_desc,
@@ -115,15 +279,86 @@ static const struct sdhci_pltfm_data sdhci_dwcmshc_pdata = { · 5 unmodified lines
115279 .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
116280 };
117281
282+static const struct sdhci_pltfm_data sdhci_dwcmshc_rk3568_pdata = {
283+ .ops = &sdhci_dwcmshc_rk3568_ops,
284+ .quirks = SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN |
285+ SDHCI_QUIRK_BROKEN_TIMEOUT_VAL,
286+ .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN |
287+ SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN,
288+};
289+
290+static int dwcmshc_rk3568_init(struct sdhci_host *host, struct dwcmshc_priv *dwc_priv)
291+{
292+ int err;
293+ struct rk3568_priv *priv = dwc_priv->priv;
294+
295+ priv->rockchip_clks[0].id = "axi";
296+ priv->rockchip_clks[1].id = "block";
297+ priv->rockchip_clks[2].id = "timer";
298+ err = devm_clk_bulk_get_optional(mmc_dev(host->mmc), RK3568_MAX_CLKS,
299+ priv->rockchip_clks);
300+ if (err) {
301+ dev_err(mmc_dev(host->mmc), "failed to get clocks %d\n", err);
302+ return err;
303+ }
304+
305+ err = clk_bulk_prepare_enable(RK3568_MAX_CLKS, priv->rockchip_clks);
306+ if (err) {
307+ dev_err(mmc_dev(host->mmc), "failed to enable clocks %d\n", err);
308+ return err;
309+ }
310+
311+ if (of_property_read_u8(mmc_dev(host->mmc)->of_node, "rockchip,txclk-tapnum",
312+ &priv->txclk_tapnum))
313+ priv->txclk_tapnum = DLL_TXCLK_TAPNUM_DEFAULT;
314+
315+ /* Disable cmd conflict check */
316+ sdhci_writel(host, 0x0, dwc_priv->vendor_specific_area1 + DWCMSHC_HOST_CTRL3);
317+ /* Reset previous settings */
318+ sdhci_writel(host, 0, DWCMSHC_EMMC_DLL_TXCLK);
319+ sdhci_writel(host, 0, DWCMSHC_EMMC_DLL_STRBIN);
320+
321+ return 0;
322+}
323+
324+static const struct of_device_id sdhci_dwcmshc_dt_ids[] = {
325+ {
326+ .compatible = "rockchip,rk3568-dwcmshc",
327+ .data = &sdhci_dwcmshc_rk3568_pdata,
328+ },
329+ {
330+ .compatible = "snps,dwcmshc-sdhci",
331+ .data = &sdhci_dwcmshc_pdata,
332+ },
333+ {},
334+};
335+MODULE_DEVICE_TABLE(of, sdhci_dwcmshc_dt_ids);
336+
337+#ifdef CONFIG_ACPI
338+static const struct acpi_device_id sdhci_dwcmshc_acpi_ids[] = {
339+ { .id = "MLNXBF30" },
340+ {}
341+};
342+#endif
343+
118344 static int dwcmshc_probe(struct platform_device *pdev)
119345 {
346+ struct device *dev = &pdev->dev;
120347 struct sdhci_pltfm_host *pltfm_host;
121348 struct sdhci_host *host;
122349 struct dwcmshc_priv *priv;
350+ struct rk3568_priv *rk_priv = NULL;
351+ const struct sdhci_pltfm_data *pltfm_data;
123352 int err;
124353 u32 extra;
125354
126− host = sdhci_pltfm_init(pdev, &sdhci_dwcmshc_pdata,
355+ pltfm_data = of_device_get_match_data(&pdev->dev);
356+ if (!pltfm_data) {
357+ dev_err(&pdev->dev, "Error: No device match data found\n");
358+ return -ENODEV;
359+ }
360+
361+ host = sdhci_pltfm_init(pdev, pltfm_data,
127362 sizeof(struct dwcmshc_priv));
128363 if (IS_ERR(host))
129364 return PTR_ERR(host);
@@ -131,7 +366,7 @@ static int dwcmshc_probe(struct platform_device *pdev) · 1 unmodified line
131366 /*
132367 * extra adma table cnt for cross 128M boundary handling.
133368 */
134− extra = DIV_ROUND_UP_ULL(dma_get_required_mask(&pdev->dev), SZ_128M);
369+ extra = DIV_ROUND_UP_ULL(dma_get_required_mask(dev), SZ_128M);
135370 if (extra > SDHCI_MAX_SEGS)
136371 extra = SDHCI_MAX_SEGS;
137372 host->adma_table_cnt += extra;
@@ -139,19 +374,21 @@ static int dwcmshc_probe(struct platform_device *pdev) · 1 unmodified line
139374 pltfm_host = sdhci_priv(host);
140375 priv = sdhci_pltfm_priv(pltfm_host);
141376
142− pltfm_host->clk = devm_clk_get(&pdev->dev, "core");
143− if (IS_ERR(pltfm_host->clk)) {
144− err = PTR_ERR(pltfm_host->clk);
145− dev_err(&pdev->dev, "failed to get core clk: %d\n", err);
146− goto free_pltfm;
377+ if (dev->of_node) {
378+ pltfm_host->clk = devm_clk_get(dev, "core");
379+ if (IS_ERR(pltfm_host->clk)) {
380+ err = PTR_ERR(pltfm_host->clk);
381+ dev_err(dev, "failed to get core clk: %d\n", err);
382+ goto free_pltfm;
383+ }
384+ err = clk_prepare_enable(pltfm_host->clk);
385+ if (err)
386+ goto free_pltfm;
387+
388+ priv->bus_clk = devm_clk_get(dev, "bus");
389+ if (!IS_ERR(priv->bus_clk))
390+ clk_prepare_enable(priv->bus_clk);
147391 }
148− err = clk_prepare_enable(pltfm_host->clk);
149− if (err)
150− goto free_pltfm;
151−
152− priv->bus_clk = devm_clk_get(&pdev->dev, "bus");
153− if (!IS_ERR(priv->bus_clk))
154− clk_prepare_enable(priv->bus_clk);
155392
156393 err = mmc_of_parse(host->mmc);
157394 if (err)
@@ -159,7 +396,27 @@ static int dwcmshc_probe(struct platform_device *pdev) · 1 unmodified line
159396
160397 sdhci_get_of_property(pdev);
161398
399+ priv->vendor_specific_area1 =
400+ sdhci_readl(host, DWCMSHC_P_VENDOR_AREA1) & DWCMSHC_AREA1_MASK;
401+
162402 host->mmc_host_ops.request = dwcmshc_request;
403+ host->mmc_host_ops.hs400_enhanced_strobe = dwcmshc_hs400_enhanced_strobe;
404+
405+ if (pltfm_data == &sdhci_dwcmshc_rk3568_pdata) {
406+ rk_priv = devm_kzalloc(&pdev->dev, sizeof(struct rk3568_priv), GFP_KERNEL);
407+ if (!rk_priv) {
408+ err = -ENOMEM;
409+ goto err_clk;
410+ }
411+
412+ priv->priv = rk_priv;
413+
414+ err = dwcmshc_rk3568_init(host, priv);
415+ if (err)
416+ goto err_clk;
417+ }
418+
419+ host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY;
163420
164421 err = sdhci_add_host(host);
165422 if (err)
@@ -170,6 +427,9 @@ static int dwcmshc_probe(struct platform_device *pdev) · 4 unmodified lines
170427 err_clk:
171428 clk_disable_unprepare(pltfm_host->clk);
172429 clk_disable_unprepare(priv->bus_clk);
430+ if (rk_priv)
431+ clk_bulk_disable_unprepare(RK3568_MAX_CLKS,
432+ rk_priv->rockchip_clks);
173433 free_pltfm:
174434 sdhci_pltfm_free(pdev);
175435 return err;
@@ -180,12 +440,15 @@ static int dwcmshc_remove(struct platform_device *pdev) · 4 unmodified lines
180440 struct sdhci_host *host = platform_get_drvdata(pdev);
181441 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
182442 struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host);
443+ struct rk3568_priv *rk_priv = priv->priv;
183444
184445 sdhci_remove_host(host, 0);
185446
186447 clk_disable_unprepare(pltfm_host->clk);
187448 clk_disable_unprepare(priv->bus_clk);
188−
449+ if (rk_priv)
450+ clk_bulk_disable_unprepare(RK3568_MAX_CLKS,
451+ rk_priv->rockchip_clks);
189452 sdhci_pltfm_free(pdev);
190453
191454 return 0;
@@ -197,6 +460,7 @@ static int dwcmshc_suspend(struct device *dev) · 5 unmodified lines
197460 struct sdhci_host *host = dev_get_drvdata(dev);
198461 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
199462 struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host);
463+ struct rk3568_priv *rk_priv = priv->priv;
200464 int ret;
201465
202466 ret = sdhci_suspend_host(host);
@@ -207,6 +471,10 @@ static int dwcmshc_suspend(struct device *dev) · 4 unmodified lines
207471 if (!IS_ERR(priv->bus_clk))
208472 clk_disable_unprepare(priv->bus_clk);
209473
474+ if (rk_priv)
475+ clk_bulk_disable_unprepare(RK3568_MAX_CLKS,
476+ rk_priv->rockchip_clks);
477+
210478 return ret;
211479 }
212480
@@ -215,6 +483,7 @@ static int dwcmshc_resume(struct device *dev) · 2 unmodified lines
215483 struct sdhci_host *host = dev_get_drvdata(dev);
216484 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
217485 struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host);
486+ struct rk3568_priv *rk_priv = priv->priv;
218487 int ret;
219488
220489 ret = clk_prepare_enable(pltfm_host->clk);
@@ -227,23 +496,25 @@ static int dwcmshc_resume(struct device *dev) · 6 unmodified lines
227496 return ret;
228497 }
229498
499+ if (rk_priv) {
500+ ret = clk_bulk_prepare_enable(RK3568_MAX_CLKS,
501+ rk_priv->rockchip_clks);
502+ if (ret)
503+ return ret;
504+ }
505+
230506 return sdhci_resume_host(host);
231507 }
232508 #endif
233509
234510 static SIMPLE_DEV_PM_OPS(dwcmshc_pmops, dwcmshc_suspend, dwcmshc_resume);
235511
236−static const struct of_device_id sdhci_dwcmshc_dt_ids[] = {
237− { .compatible = "snps,dwcmshc-sdhci" },
238− {}
239−};
240−MODULE_DEVICE_TABLE(of, sdhci_dwcmshc_dt_ids);
241−
242512 static struct platform_driver sdhci_dwcmshc_driver = {
243513 .driver = {
244514 .name = "sdhci-dwcmshc",
245515 .probe_type = PROBE_PREFER_ASYNCHRONOUS,
246516 .of_match_table = sdhci_dwcmshc_dt_ids,
517+ .acpi_match_table = ACPI_PTR(sdhci_dwcmshc_acpi_ids),
247518 .pm = &dwcmshc_pmops,
248519 },
249520 .probe = dwcmshc_probe,
drivers/mmc/host/sdhci-of-esdhc.c+1−1
@@ -1489,7 +1489,7 @@ static int sdhci_esdhc_probe(struct platform_device *pdev) · 1488 unmodified lines
14891489 if (ret)
14901490 goto err;
14911491
1492− mmc_of_parse_voltage(np, &host->ocr_mask);
1492+ mmc_of_parse_voltage(host->mmc, &host->ocr_mask);
14931493
14941494 ret = sdhci_add_host(host);
14951495 if (ret)
drivers/mmc/host/sdhci-pci-core.c+30−1
@@ -516,6 +516,7 @@ struct intel_host { · 515 unmodified lines
516516 int drv_strength;
517517 bool d3_retune;
518518 bool rpm_retune_ok;
519+ bool needs_pwr_off;
519520 u32 glk_rx_ctrl1;
520521 u32 glk_tun_val;
521522 u32 active_ltr;
@@ -643,9 +644,25 @@ out: · 121 unmodified lines
643644 static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
644645 unsigned short vdd)
645646 {
647+ struct sdhci_pci_slot *slot = sdhci_priv(host);
648+ struct intel_host *intel_host = sdhci_pci_priv(slot);
646649 int cntr;
647650 u8 reg;
648651
652+ /*
653+ * Bus power may control card power, but a full reset still may not
654+ * reset the power, whereas a direct write to SDHCI_POWER_CONTROL can.
655+ * That might be needed to initialize correctly, if the card was left
656+ * powered on previously.
657+ */
658+ if (intel_host->needs_pwr_off) {
659+ intel_host->needs_pwr_off = false;
660+ if (mode != MMC_POWER_OFF) {
661+ sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);
662+ usleep_range(10000, 12500);
663+ }
664+ }
665+
649666 sdhci_set_power(host, mode, vdd);
650667
651668 if (mode == MMC_POWER_OFF)
@@ -958,7 +975,7 @@ static int glk_emmc_probe_slot(struct sdhci_pci_slot *slot) · 306 unmodified lines
958975 slot->host->mmc->caps2 |= MMC_CAP2_CQE;
959976
960977 if (slot->chip->pdev->device != PCI_DEVICE_ID_INTEL_GLK_EMMC) {
961− slot->host->mmc->caps2 |= MMC_CAP2_HS400_ES,
978+ slot->host->mmc->caps2 |= MMC_CAP2_HS400_ES;
962979 slot->host->mmc_host_ops.hs400_enhanced_strobe =
963980 intel_hs400_enhanced_strobe;
964981 slot->host->mmc->caps2 |= MMC_CAP2_CQE_DCMD;
@@ -1135,6 +1152,14 @@ static int byt_sdio_probe_slot(struct sdhci_pci_slot *slot) · 170 unmodified lines
11351152 return 0;
11361153 }
11371154
1155+static void byt_needs_pwr_off(struct sdhci_pci_slot *slot)
1156+{
1157+ struct intel_host *intel_host = sdhci_pci_priv(slot);
1158+ u8 reg = sdhci_readb(slot->host, SDHCI_POWER_CONTROL);
1159+
1160+ intel_host->needs_pwr_off = reg & SDHCI_POWER_ON;
1161+}
1162+
11381163 static int byt_sd_probe_slot(struct sdhci_pci_slot *slot)
11391164 {
11401165 byt_probe_slot(slot);
@@ -1152,6 +1177,8 @@ static int byt_sd_probe_slot(struct sdhci_pci_slot *slot) · 11 unmodified lines
11521177 slot->chip->pdev->subsystem_device == PCI_SUBDEVICE_ID_NI_78E3)
11531178 slot->host->mmc->caps2 |= MMC_CAP2_AVOID_3_3V;
11541179
1180+ byt_needs_pwr_off(slot);
1181+
11551182 return 0;
11561183 }
11571184
@@ -1903,6 +1930,8 @@ static const struct pci_device_id pci_ids[] = { · 745 unmodified lines
19031930 SDHCI_PCI_DEVICE(INTEL, CMLH_SD, intel_byt_sd),
19041931 SDHCI_PCI_DEVICE(INTEL, JSL_EMMC, intel_glk_emmc),
19051932 SDHCI_PCI_DEVICE(INTEL, JSL_SD, intel_byt_sd),
1933+ SDHCI_PCI_DEVICE(INTEL, LKF_EMMC, intel_glk_emmc),
1934+ SDHCI_PCI_DEVICE(INTEL, LKF_SD, intel_byt_sd),
19061935 SDHCI_PCI_DEVICE(O2, 8120, o2),
19071936 SDHCI_PCI_DEVICE(O2, 8220, o2),
19081937 SDHCI_PCI_DEVICE(O2, 8221, o2),
drivers/mmc/host/sdhci-pci-gli.c+43−3
@@ -22,6 +22,10 @@ · 21 unmodified lines
2222 #define GLI_9750_WT_EN_ON 0x1
2323 #define GLI_9750_WT_EN_OFF 0x0
2424
25+#define SDHCI_GLI_9750_CFG2 0x848
26+#define SDHCI_GLI_9750_CFG2_L1DLY GENMASK(28, 24)
27+#define GLI_9750_CFG2_L1DLY_VALUE 0x1F
28+
2529 #define SDHCI_GLI_9750_DRIVING 0x860
2630 #define SDHCI_GLI_9750_DRIVING_1 GENMASK(11, 0)
2731 #define SDHCI_GLI_9750_DRIVING_2 GENMASK(27, 26)
@@ -90,7 +94,7 @@ · 62 unmodified lines
9094
9195 #define PCIE_GLI_9763E_CFG2 0x8A4
9296 #define GLI_9763E_CFG2_L1DLY GENMASK(28, 19)
93−#define GLI_9763E_CFG2_L1DLY_MAX 0x3FF
97+#define GLI_9763E_CFG2_L1DLY_MID 0x50
9498
9599 #define PCIE_GLI_9763E_MMC_CTRL 0x960
96100 #define GLI_9763E_HS400_SLOW BIT(3)
@@ -113,6 +117,10 @@ · 16 unmodified lines
113117 #define PCI_GLI_9755_LFCLK GENMASK(14, 12)
114118 #define PCI_GLI_9755_DMACLK BIT(29)
115119
120+#define PCI_GLI_9755_CFG2 0x48
121+#define PCI_GLI_9755_CFG2_L1DLY GENMASK(28, 24)
122+#define GLI_9755_CFG2_L1DLY_VALUE 0x1F
123+
116124 #define PCI_GLI_9755_PLL 0x64
117125 #define PCI_GLI_9755_PLL_LDIV GENMASK(9, 0)
118126 #define PCI_GLI_9755_PLL_PDIV GENMASK(14, 12)
@@ -123,6 +131,9 @@ · 4 unmodified lines
123131 #define PCI_GLI_9755_PLLSSC 0x68
124132 #define PCI_GLI_9755_PLLSSC_PPM GENMASK(15, 0)
125133
134+#define PCI_GLI_9755_SerDes 0x70
135+#define PCI_GLI_9755_SCP_DIS BIT(19)
136+
126137 #define GLI_MAX_TUNING_LOOP 40
127138
128139 /* Genesys Logic chipset */
@@ -405,6 +416,22 @@ static void sdhci_gl9750_set_clock(struct sdhci_host *host, unsigned int clock) · 276 unmodified lines
405416 sdhci_enable_clk(host, clk);
406417 }
407418
419+static void gl9750_hw_setting(struct sdhci_host *host)
420+{
421+ u32 value;
422+
423+ gl9750_wt_on(host);
424+
425+ value = sdhci_readl(host, SDHCI_GLI_9750_CFG2);
426+ value &= ~SDHCI_GLI_9750_CFG2_L1DLY;
427+ /* set ASPM L1 entry delay to 7.9us */
428+ value |= FIELD_PREP(SDHCI_GLI_9750_CFG2_L1DLY,
429+ GLI_9750_CFG2_L1DLY_VALUE);
430+ sdhci_writel(host, value, SDHCI_GLI_9750_CFG2);
431+
432+ gl9750_wt_off(host);
433+}
434+
408435 static void gli_pcie_enable_msi(struct sdhci_pci_slot *slot)
409436 {
410437 int ret;
@@ -547,6 +574,18 @@ static void gl9755_hw_setting(struct sdhci_pci_slot *slot) · 136 unmodified lines
547574 value &= ~PCI_GLI_9755_DMACLK;
548575 pci_write_config_dword(pdev, PCI_GLI_9755_PECONF, value);
549576
577+ /* enable short circuit protection */
578+ pci_read_config_dword(pdev, PCI_GLI_9755_SerDes, &value);
579+ value &= ~PCI_GLI_9755_SCP_DIS;
580+ pci_write_config_dword(pdev, PCI_GLI_9755_SerDes, value);
581+
582+ pci_read_config_dword(pdev, PCI_GLI_9755_CFG2, &value);
583+ value &= ~PCI_GLI_9755_CFG2_L1DLY;
584+ /* set ASPM L1 entry delay to 7.9us */
585+ value |= FIELD_PREP(PCI_GLI_9755_CFG2_L1DLY,
586+ GLI_9755_CFG2_L1DLY_VALUE);
587+ pci_write_config_dword(pdev, PCI_GLI_9755_CFG2, value);
588+
550589 gl9755_wt_off(pdev);
551590 }
552591
@@ -554,6 +593,7 @@ static int gli_probe_slot_gl9750(struct sdhci_pci_slot *slot) · 1 unmodified line
554593 {
555594 struct sdhci_host *host = slot->host;
556595
596+ gl9750_hw_setting(host);
557597 gli_pcie_enable_msi(slot);
558598 slot->host->mmc->caps2 |= MMC_CAP2_NO_SDIO;
559599 sdhci_enable_v4_mode(host);
@@ -802,8 +842,8 @@ static void gli_set_gl9763e(struct sdhci_pci_slot *slot) · 242 unmodified lines
802842
803843 pci_read_config_dword(pdev, PCIE_GLI_9763E_CFG2, &value);
804844 value &= ~GLI_9763E_CFG2_L1DLY;
805− /* set ASPM L1 entry delay to 260us */
806− value |= FIELD_PREP(GLI_9763E_CFG2_L1DLY, GLI_9763E_CFG2_L1DLY_MAX);
845+ /* set ASPM L1 entry delay to 20us */
846+ value |= FIELD_PREP(GLI_9763E_CFG2_L1DLY, GLI_9763E_CFG2_L1DLY_MID);
807847 pci_write_config_dword(pdev, PCIE_GLI_9763E_CFG2, value);
808848
809849 pci_read_config_dword(pdev, PCIE_GLI_9763E_CLKRXDLY, &value);
drivers/mmc/host/sdhci-pci-o2micro.c+8−0
@@ -706,6 +706,8 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) · 705 unmodified lines
706706 ret = pci_read_config_dword(chip->pdev,
707707 O2_SD_FUNC_REG0,
708708 &scratch_32);
709+ if (ret)
710+ return ret;
709711 scratch_32 = ((scratch_32 & 0xFF000000) >> 24);
710712
711713 /* Check Whether subId is 0x11 or 0x12 */
@@ -716,6 +718,8 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) · 4 unmodified lines
716718 ret = pci_read_config_dword(chip->pdev,
717719 O2_SD_FUNC_REG4,
718720 &scratch_32);
721+ if (ret)
722+ return ret;
719723
720724 /* Enable Base Clk setting change */
721725 scratch_32 |= O2_SD_FREG4_ENABLE_CLK_SET;
@@ -795,6 +799,8 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) · 73 unmodified lines
795799
796800 ret = pci_read_config_dword(chip->pdev,
797801 O2_SD_PLL_SETTING, &scratch_32);
802+ if (ret)
803+ return ret;
798804
799805 if ((scratch_32 & 0xff000000) == 0x01000000) {
800806 scratch_32 &= 0x0000FFFF;
@@ -812,6 +818,8 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) · 11 unmodified lines
812818 ret = pci_read_config_dword(chip->pdev,
813819 O2_SD_FUNC_REG4,
814820 &scratch_32);
821+ if (ret)
822+ return ret;
815823 scratch_32 |= (1 << 22);
816824 pci_write_config_dword(chip->pdev,
817825 O2_SD_FUNC_REG4, scratch_32);
drivers/mmc/host/sdhci-pci.h+2−0
@@ -57,6 +57,8 @@ · 56 unmodified lines
5757 #define PCI_DEVICE_ID_INTEL_CMLH_SD 0x06f5
5858 #define PCI_DEVICE_ID_INTEL_JSL_EMMC 0x4dc4
5959 #define PCI_DEVICE_ID_INTEL_JSL_SD 0x4df8
60+#define PCI_DEVICE_ID_INTEL_LKF_EMMC 0x98c4
61+#define PCI_DEVICE_ID_INTEL_LKF_SD 0x98f8
6062
6163 #define PCI_DEVICE_ID_SYSKONNECT_8000 0x8000
6264 #define PCI_DEVICE_ID_VIA_95D0 0x95d0
drivers/mmc/host/sdhci-s3c.c+8−14
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 #include <linux/gpio.h>
2121 #include <linux/module.h>
2222 #include <linux/of.h>
23+#include <linux/of_device.h>
2324 #include <linux/of_gpio.h>
2425 #include <linux/pm.h>
2526 #include <linux/pm_runtime.h>
@@ -129,7 +130,7 @@ struct sdhci_s3c { · 103 unmodified lines
129130 };
130131
131132 /**
132− * struct sdhci_s3c_driver_data - S3C SDHCI platform specific driver data
133+ * struct sdhci_s3c_drv_data - S3C SDHCI platform specific driver data
133134 * @sdhci_quirks: sdhci host specific quirks.
134135 * @no_divider: no or non-standard internal clock divider.
135136 *
@@ -461,28 +462,21 @@ static int sdhci_s3c_parse_dt(struct device *dev, · 325 unmodified lines
461462 }
462463 #endif
463464
464−#ifdef CONFIG_OF
465−static const struct of_device_id sdhci_s3c_dt_match[];
466−#endif
467−
468−static inline struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data(
465+static inline const struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data(
469466 struct platform_device *pdev)
470467 {
471468 #ifdef CONFIG_OF
472− if (pdev->dev.of_node) {
473− const struct of_device_id *match;
474− match = of_match_node(sdhci_s3c_dt_match, pdev->dev.of_node);
475− return (struct sdhci_s3c_drv_data *)match->data;
476− }
469+ if (pdev->dev.of_node)
470+ return of_device_get_match_data(&pdev->dev);
477471 #endif
478− return (struct sdhci_s3c_drv_data *)
472+ return (const struct sdhci_s3c_drv_data *)
479473 platform_get_device_id(pdev)->driver_data;
480474 }
481475
482476 static int sdhci_s3c_probe(struct platform_device *pdev)
483477 {
484478 struct s3c_sdhci_platdata *pdata;
485− struct sdhci_s3c_drv_data *drv_data;
479+ const struct sdhci_s3c_drv_data *drv_data;
486480 struct device *dev = &pdev->dev;
487481 struct sdhci_host *host;
488482 struct sdhci_s3c *sc;
@@ -767,7 +761,7 @@ static const struct platform_device_id sdhci_s3c_driver_ids[] = { · 278 unmodified lines
767761 MODULE_DEVICE_TABLE(platform, sdhci_s3c_driver_ids);
768762
769763 #ifdef CONFIG_OF
770−static struct sdhci_s3c_drv_data exynos4_sdhci_drv_data = {
764+static const struct sdhci_s3c_drv_data exynos4_sdhci_drv_data = {
771765 .no_divider = true,
772766 };
773767
drivers/mmc/host/sdhci-st.c+8−15
@@ -362,11 +362,10 @@ static int sdhci_st_probe(struct platform_device *pdev) · 361 unmodified lines
362362 if (IS_ERR(icnclk))
363363 icnclk = NULL;
364364
365− rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
365+ rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
366366 if (IS_ERR(rstc))
367− rstc = NULL;
368− else
369− reset_control_deassert(rstc);
367+ return PTR_ERR(rstc);
368+ reset_control_deassert(rstc);
370369
371370 host = sdhci_pltfm_init(pdev, &sdhci_st_pdata, sizeof(*pdata));
372371 if (IS_ERR(host)) {
@@ -401,10 +400,8 @@ static int sdhci_st_probe(struct platform_device *pdev) · 28 unmodified lines
401400 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
402401 "top-mmc-delay");
403402 pdata->top_ioaddr = devm_ioremap_resource(&pdev->dev, res);
404− if (IS_ERR(pdata->top_ioaddr)) {
405− dev_warn(&pdev->dev, "FlashSS Top Dly registers not available");
403+ if (IS_ERR(pdata->top_ioaddr))
406404 pdata->top_ioaddr = NULL;
407− }
408405
409406 pltfm_host->clk = clk;
410407 pdata->icnclk = icnclk;
@@ -432,8 +429,7 @@ err_icnclk: · 21 unmodified lines
432429 err_of:
433430 sdhci_pltfm_free(pdev);
434431 err_pltfm_init:
435− if (rstc)
436− reset_control_assert(rstc);
432+ reset_control_assert(rstc);
437433
438434 return ret;
439435 }
@@ -450,8 +446,7 @@ static int sdhci_st_remove(struct platform_device *pdev) · 10 unmodified lines
450446
451447 clk_disable_unprepare(pdata->icnclk);
452448
453− if (rstc)
454− reset_control_assert(rstc);
449+ reset_control_assert(rstc);
455450
456451 return ret;
457452 }
@@ -471,8 +466,7 @@ static int sdhci_st_suspend(struct device *dev) · 13 unmodified lines
471466 if (ret)
472467 goto out;
473468
474− if (pdata->rstc)
475− reset_control_assert(pdata->rstc);
469+ reset_control_assert(pdata->rstc);
476470
477471 clk_disable_unprepare(pdata->icnclk);
478472 clk_disable_unprepare(pltfm_host->clk);
@@ -498,8 +492,7 @@ static int sdhci_st_resume(struct device *dev) · 19 unmodified lines
498492 return ret;
499493 }
500494
501− if (pdata->rstc)
502− reset_control_deassert(pdata->rstc);
495+ reset_control_deassert(pdata->rstc);
503496
504497 st_mmcss_cconfig(np, host);
505498
drivers/mmc/host/sdhci-tegra.c+49−17
@@ -119,6 +119,10 @@ · 118 unmodified lines
119119 /* SDMMC CQE Base Address for Tegra Host Ver 4.1 and Higher */
120120 #define SDHCI_TEGRA_CQE_BASE_ADDR 0xF000
121121
122+#define SDHCI_TEGRA_CQE_TRNS_MODE (SDHCI_TRNS_MULTI | \
123+ SDHCI_TRNS_BLK_CNT_EN | \
124+ SDHCI_TRNS_DMA)
125+
122126 struct sdhci_tegra_soc_data {
123127 const struct sdhci_pltfm_data *pdata;
124128 u64 dma_mask;
@@ -596,49 +600,49 @@ static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host *host) · 471 unmodified lines
596600 &tegra_host->autocal_offsets;
597601 int err;
598602
599− err = device_property_read_u32(host->mmc->parent,
603+ err = device_property_read_u32(mmc_dev(host->mmc),
600604 "nvidia,pad-autocal-pull-up-offset-3v3",
601605 &autocal->pull_up_3v3);
602606 if (err)
603607 autocal->pull_up_3v3 = 0;
604608
605− err = device_property_read_u32(host->mmc->parent,
609+ err = device_property_read_u32(mmc_dev(host->mmc),
606610 "nvidia,pad-autocal-pull-down-offset-3v3",
607611 &autocal->pull_down_3v3);
608612 if (err)
609613 autocal->pull_down_3v3 = 0;
610614
611− err = device_property_read_u32(host->mmc->parent,
615+ err = device_property_read_u32(mmc_dev(host->mmc),
612616 "nvidia,pad-autocal-pull-up-offset-1v8",
613617 &autocal->pull_up_1v8);
614618 if (err)
615619 autocal->pull_up_1v8 = 0;
616620
617− err = device_property_read_u32(host->mmc->parent,
621+ err = device_property_read_u32(mmc_dev(host->mmc),
618622 "nvidia,pad-autocal-pull-down-offset-1v8",
619623 &autocal->pull_down_1v8);
620624 if (err)
621625 autocal->pull_down_1v8 = 0;
622626
623− err = device_property_read_u32(host->mmc->parent,
627+ err = device_property_read_u32(mmc_dev(host->mmc),
624628 "nvidia,pad-autocal-pull-up-offset-sdr104",
625629 &autocal->pull_up_sdr104);
626630 if (err)
627631 autocal->pull_up_sdr104 = autocal->pull_up_1v8;
628632
629− err = device_property_read_u32(host->mmc->parent,
633+ err = device_property_read_u32(mmc_dev(host->mmc),
630634 "nvidia,pad-autocal-pull-down-offset-sdr104",
631635 &autocal->pull_down_sdr104);
632636 if (err)
633637 autocal->pull_down_sdr104 = autocal->pull_down_1v8;
634638
635− err = device_property_read_u32(host->mmc->parent,
639+ err = device_property_read_u32(mmc_dev(host->mmc),
636640 "nvidia,pad-autocal-pull-up-offset-hs400",
637641 &autocal->pull_up_hs400);
638642 if (err)
639643 autocal->pull_up_hs400 = autocal->pull_up_1v8;
640644
641− err = device_property_read_u32(host->mmc->parent,
645+ err = device_property_read_u32(mmc_dev(host->mmc),
642646 "nvidia,pad-autocal-pull-down-offset-hs400",
643647 &autocal->pull_down_hs400);
644648 if (err)
@@ -653,7 +657,7 @@ static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host *host) · 8 unmodified lines
653657 if (!(tegra_host->soc_data->nvquirks & NVQUIRK_NEEDS_PAD_CONTROL))
654658 return;
655659
656− err = device_property_read_u32(host->mmc->parent,
660+ err = device_property_read_u32(mmc_dev(host->mmc),
657661 "nvidia,pad-autocal-pull-up-offset-3v3-timeout",
658662 &autocal->pull_up_3v3_timeout);
659663 if (err) {
@@ -664,7 +668,7 @@ static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host *host) · 4 unmodified lines
664668 autocal->pull_up_3v3_timeout = 0;
665669 }
666670
667− err = device_property_read_u32(host->mmc->parent,
671+ err = device_property_read_u32(mmc_dev(host->mmc),
668672 "nvidia,pad-autocal-pull-down-offset-3v3-timeout",
669673 &autocal->pull_down_3v3_timeout);
670674 if (err) {
@@ -675,7 +679,7 @@ static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host *host) · 4 unmodified lines
675679 autocal->pull_down_3v3_timeout = 0;
676680 }
677681
678− err = device_property_read_u32(host->mmc->parent,
682+ err = device_property_read_u32(mmc_dev(host->mmc),
679683 "nvidia,pad-autocal-pull-up-offset-1v8-timeout",
680684 &autocal->pull_up_1v8_timeout);
681685 if (err) {
@@ -686,7 +690,7 @@ static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host *host) · 4 unmodified lines
686690 autocal->pull_up_1v8_timeout = 0;
687691 }
688692
689− err = device_property_read_u32(host->mmc->parent,
693+ err = device_property_read_u32(mmc_dev(host->mmc),
690694 "nvidia,pad-autocal-pull-down-offset-1v8-timeout",
691695 &autocal->pull_down_1v8_timeout);
692696 if (err) {
@@ -720,17 +724,17 @@ static void tegra_sdhci_parse_tap_and_trim(struct sdhci_host *host) · 27 unmodified lines
720724 struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host);
721725 int err;
722726
723− err = device_property_read_u32(host->mmc->parent, "nvidia,default-tap",
727+ err = device_property_read_u32(mmc_dev(host->mmc), "nvidia,default-tap",
724728 &tegra_host->default_tap);
725729 if (err)
726730 tegra_host->default_tap = 0;
727731
728− err = device_property_read_u32(host->mmc->parent, "nvidia,default-trim",
732+ err = device_property_read_u32(mmc_dev(host->mmc), "nvidia,default-trim",
729733 &tegra_host->default_trim);
730734 if (err)
731735 tegra_host->default_trim = 0;
732736
733− err = device_property_read_u32(host->mmc->parent, "nvidia,dqs-trim",
737+ err = device_property_read_u32(mmc_dev(host->mmc), "nvidia,dqs-trim",
734738 &tegra_host->dqs_trim);
735739 if (err)
736740 tegra_host->dqs_trim = 0x11;
@@ -741,7 +745,7 @@ static void tegra_sdhci_parse_dt(struct sdhci_host *host) · 4 unmodified lines
741745 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
742746 struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host);
743747
744− if (device_property_read_bool(host->mmc->parent, "supports-cqe"))
748+ if (device_property_read_bool(mmc_dev(host->mmc), "supports-cqe"))
745749 tegra_host->enable_hwcq = true;
746750 else
747751 tegra_host->enable_hwcq = false;
@@ -1156,6 +1160,7 @@ static void tegra_sdhci_voltage_switch(struct sdhci_host *host) · 408 unmodified lines
11561160 static void tegra_cqhci_writel(struct cqhci_host *cq_host, u32 val, int reg)
11571161 {
11581162 struct mmc_host *mmc = cq_host->mmc;
1163+ struct sdhci_host *host = mmc_priv(mmc);
11591164 u8 ctrl;
11601165 ktime_t timeout;
11611166 bool timed_out;
@@ -1170,6 +1175,7 @@ static void tegra_cqhci_writel(struct cqhci_host *cq_host, u32 val, int reg) · 8 unmodified lines
11701175 */
11711176 if (reg == CQHCI_CTL && !(val & CQHCI_HALT) &&
11721177 cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT) {
1178+ sdhci_writew(host, SDHCI_TEGRA_CQE_TRNS_MODE, SDHCI_TRANSFER_MODE);
11731179 sdhci_cqe_enable(mmc);
11741180 writel(val, cq_host->mmio + reg);
11751181 timeout = ktime_add_us(ktime_get(), 50);
@@ -1205,6 +1211,7 @@ static void sdhci_tegra_update_dcmd_desc(struct mmc_host *mmc, · 29 unmodified lines
12051211 static void sdhci_tegra_cqe_enable(struct mmc_host *mmc)
12061212 {
12071213 struct cqhci_host *cq_host = mmc->cqe_private;
1214+ struct sdhci_host *host = mmc_priv(mmc);
12081215 u32 val;
12091216
12101217 /*
@@ -1218,6 +1225,7 @@ static void sdhci_tegra_cqe_enable(struct mmc_host *mmc) · 7 unmodified lines
12181225 if (val & CQHCI_ENABLE)
12191226 cqhci_writel(cq_host, (val & ~CQHCI_ENABLE),
12201227 CQHCI_CFG);
1228+ sdhci_writew(host, SDHCI_TEGRA_CQE_TRNS_MODE, SDHCI_TRANSFER_MODE);
12211229 sdhci_cqe_enable(mmc);
12221230 if (val & CQHCI_ENABLE)
12231231 cqhci_writel(cq_host, val, CQHCI_CFG);
@@ -1281,12 +1289,36 @@ static void tegra_sdhci_set_timeout(struct sdhci_host *host, · 57 unmodified lines
12811289 __sdhci_set_timeout(host, cmd);
12821290 }
12831291
1292+static void sdhci_tegra_cqe_pre_enable(struct mmc_host *mmc)
1293+{
1294+ struct cqhci_host *cq_host = mmc->cqe_private;
1295+ u32 reg;
1296+
1297+ reg = cqhci_readl(cq_host, CQHCI_CFG);
1298+ reg |= CQHCI_ENABLE;
1299+ cqhci_writel(cq_host, reg, CQHCI_CFG);
1300+}
1301+
1302+static void sdhci_tegra_cqe_post_disable(struct mmc_host *mmc)
1303+{
1304+ struct cqhci_host *cq_host = mmc->cqe_private;
1305+ struct sdhci_host *host = mmc_priv(mmc);
1306+ u32 reg;
1307+
1308+ reg = cqhci_readl(cq_host, CQHCI_CFG);
1309+ reg &= ~CQHCI_ENABLE;
1310+ cqhci_writel(cq_host, reg, CQHCI_CFG);
1311+ sdhci_writew(host, 0x0, SDHCI_TRANSFER_MODE);
1312+}
1313+
12841314 static const struct cqhci_host_ops sdhci_tegra_cqhci_ops = {
12851315 .write_l = tegra_cqhci_writel,
12861316 .enable = sdhci_tegra_cqe_enable,
12871317 .disable = sdhci_cqe_disable,
12881318 .dumpregs = sdhci_tegra_dumpregs,
12891319 .update_dcmd_desc = sdhci_tegra_update_dcmd_desc,
1320+ .pre_enable = sdhci_tegra_cqe_pre_enable,
1321+ .post_disable = sdhci_tegra_cqe_post_disable,
12901322 };
12911323
12921324 static int tegra_sdhci_set_dma_mask(struct sdhci_host *host)
@@ -1529,7 +1561,7 @@ static int sdhci_tegra_add_host(struct sdhci_host *host) · 236 unmodified lines
15291561
15301562 host->mmc->caps2 |= MMC_CAP2_CQE | MMC_CAP2_CQE_DCMD;
15311563
1532− cq_host = devm_kzalloc(host->mmc->parent,
1564+ cq_host = devm_kzalloc(mmc_dev(host->mmc),
15331565 sizeof(*cq_host), GFP_KERNEL);
15341566 if (!cq_host) {
15351567 ret = -ENOMEM;
drivers/mmc/host/sdhci.c+57−56
@@ -188,7 +188,7 @@ static void sdhci_runtime_pm_bus_on(struct sdhci_host *host) · 187 unmodified lines
188188 if (host->bus_on)
189189 return;
190190 host->bus_on = true;
191− pm_runtime_get_noresume(host->mmc->parent);
191+ pm_runtime_get_noresume(mmc_dev(host->mmc));
192192 }
193193
194194 static void sdhci_runtime_pm_bus_off(struct sdhci_host *host)
@@ -196,7 +196,7 @@ static void sdhci_runtime_pm_bus_off(struct sdhci_host *host) · 1 unmodified line
196196 if (!host->bus_on)
197197 return;
198198 host->bus_on = false;
199− pm_runtime_put_noidle(host->mmc->parent);
199+ pm_runtime_put_noidle(mmc_dev(host->mmc));
200200 }
201201
202202 void sdhci_reset(struct sdhci_host *host, u8 mask)
@@ -648,7 +648,7 @@ static int sdhci_pre_dma_transfer(struct sdhci_host *host, · 445 unmodified lines
648648 }
649649 }
650650 /* Switch ownership to the DMA */
651− dma_sync_single_for_device(host->mmc->parent,
651+ dma_sync_single_for_device(mmc_dev(host->mmc),
652652 host->bounce_addr,
653653 host->bounce_buffer_size,
654654 mmc_get_dma_dir(data));
@@ -907,7 +907,7 @@ static void sdhci_calc_sw_timeout(struct sdhci_host *host, · 252 unmodified lines
907907
908908 if (data) {
909909 blksz = data->blksz;
910− freq = host->mmc->actual_clock ? : host->clock;
910+ freq = mmc->actual_clock ? : host->clock;
911911 transfer_time = (u64)blksz * NSEC_PER_SEC * (8 / bus_width);
912912 do_div(transfer_time, freq);
913913 /* multiply by '2' to account for any unknowns */
@@ -1176,7 +1176,7 @@ static int sdhci_external_dma_init(struct sdhci_host *host) · 262 unmodified lines
11761176 int ret = 0;
11771177 struct mmc_host *mmc = host->mmc;
11781178
1179− host->tx_chan = dma_request_chan(mmc->parent, "tx");
1179+ host->tx_chan = dma_request_chan(mmc_dev(mmc), "tx");
11801180 if (IS_ERR(host->tx_chan)) {
11811181 ret = PTR_ERR(host->tx_chan);
11821182 if (ret != -EPROBE_DEFER)
@@ -1185,7 +1185,7 @@ static int sdhci_external_dma_init(struct sdhci_host *host) · 2 unmodified lines
11851185 return ret;
11861186 }
11871187
1188− host->rx_chan = dma_request_chan(mmc->parent, "rx");
1188+ host->rx_chan = dma_request_chan(mmc_dev(mmc), "rx");
11891189 if (IS_ERR(host->rx_chan)) {
11901190 if (host->tx_chan) {
11911191 dma_release_channel(host->tx_chan);
@@ -2269,14 +2269,14 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) · 1077 unmodified lines
22692269
22702270 if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK &&
22712271 host->clock) {
2272− host->timeout_clk = host->mmc->actual_clock ?
2273− host->mmc->actual_clock / 1000 :
2272+ host->timeout_clk = mmc->actual_clock ?
2273+ mmc->actual_clock / 1000 :
22742274 host->clock / 1000;
2275− host->mmc->max_busy_timeout =
2275+ mmc->max_busy_timeout =
22762276 host->ops->get_max_timeout_count ?
22772277 host->ops->get_max_timeout_count(host) :
22782278 1 << 27;
2279− host->mmc->max_busy_timeout /= host->timeout_clk;
2279+ mmc->max_busy_timeout /= host->timeout_clk;
22802280 }
22812281 }
22822282
@@ -2399,7 +2399,7 @@ static int sdhci_get_cd(struct mmc_host *mmc) · 116 unmodified lines
23992399 return 0;
24002400
24012401 /* If nonremovable, assume that the card is always present. */
2402− if (!mmc_card_is_removable(host->mmc))
2402+ if (!mmc_card_is_removable(mmc))
24032403 return 1;
24042404
24052405 /*
@@ -2489,14 +2489,14 @@ void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable) · 83 unmodified lines
24892489 unsigned long flags;
24902490
24912491 if (enable)
2492− pm_runtime_get_noresume(host->mmc->parent);
2492+ pm_runtime_get_noresume(mmc_dev(mmc));
24932493
24942494 spin_lock_irqsave(&host->lock, flags);
24952495 sdhci_enable_sdio_irq_nolock(host, enable);
24962496 spin_unlock_irqrestore(&host->lock, flags);
24972497
24982498 if (!enable)
2499− pm_runtime_put_noidle(host->mmc->parent);
2499+ pm_runtime_put_noidle(mmc_dev(mmc));
25002500 }
25012501 EXPORT_SYMBOL_GPL(sdhci_enable_sdio_irq);
25022502
@@ -2837,7 +2837,7 @@ int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) · 334 unmodified lines
28372837 goto out;
28382838 }
28392839
2840− host->mmc->retune_period = tuning_count;
2840+ mmc->retune_period = tuning_count;
28412841
28422842 if (host->tuning_delay < 0)
28432843 host->tuning_delay = opcode == MMC_SEND_TUNING_BLOCK;
@@ -2886,11 +2886,10 @@ static void sdhci_enable_preset_value(struct sdhci_host *host, bool enable) · 42 unmodified lines
28862886 static void sdhci_post_req(struct mmc_host *mmc, struct mmc_request *mrq,
28872887 int err)
28882888 {
2889− struct sdhci_host *host = mmc_priv(mmc);
28902889 struct mmc_data *data = mrq->data;
28912890
28922891 if (data->host_cookie != COOKIE_UNMAPPED)
2893− dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
2892+ dma_unmap_sg(mmc_dev(mmc), data->sg, data->sg_len,
28942893 mmc_get_dma_dir(data));
28952894
28962895 data->host_cookie = COOKIE_UNMAPPED;
@@ -2941,9 +2940,9 @@ static void sdhci_card_event(struct mmc_host *mmc) · 44 unmodified lines
29412940 /* Check sdhci_has_requests() first in case we are runtime suspended */
29422941 if (sdhci_has_requests(host) && !present) {
29432942 pr_err("%s: Card removed during transfer!\n",
2944− mmc_hostname(host->mmc));
2943+ mmc_hostname(mmc));
29452944 pr_err("%s: Resetting controller.\n",
2946− mmc_hostname(host->mmc));
2945+ mmc_hostname(mmc));
29472946
29482947 sdhci_do_reset(host, SDHCI_RESET_CMD);
29492948 sdhci_do_reset(host, SDHCI_RESET_DATA);
@@ -2996,6 +2995,37 @@ static bool sdhci_request_done(struct sdhci_host *host) · 46 unmodified lines
29962995 return true;
29972996 }
29982997
2998+ /*
2999+ * The controller needs a reset of internal state machines
3000+ * upon error conditions.
3001+ */
3002+ if (sdhci_needs_reset(host, mrq)) {
3003+ /*
3004+ * Do not finish until command and data lines are available for
3005+ * reset. Note there can only be one other mrq, so it cannot
3006+ * also be in mrqs_done, otherwise host->cmd and host->data_cmd
3007+ * would both be null.
3008+ */
3009+ if (host->cmd || host->data_cmd) {
3010+ spin_unlock_irqrestore(&host->lock, flags);
3011+ return true;
3012+ }
3013+
3014+ /* Some controllers need this kick or reset won't work here */
3015+ if (host->quirks & SDHCI_QUIRK_CLOCK_BEFORE_RESET)
3016+ /* This is to force an update */
3017+ host->ops->set_clock(host, host->clock);
3018+
3019+ /*
3020+ * Spec says we should do both at the same time, but Ricoh
3021+ * controllers do not like that.
3022+ */
3023+ sdhci_do_reset(host, SDHCI_RESET_CMD);
3024+ sdhci_do_reset(host, SDHCI_RESET_DATA);
3025+
3026+ host->pending_reset = false;
3027+ }
3028+
29993029 /*
30003030 * Always unmap the data buffers if they were mapped by
30013031 * sdhci_prepare_data() whenever we finish with a request.
@@ -3033,7 +3063,7 @@ static bool sdhci_request_done(struct sdhci_host *host) · 31 unmodified lines
30333063 length = host->bounce_buffer_size;
30343064 }
30353065 dma_sync_single_for_cpu(
3036− host->mmc->parent,
3066+ mmc_dev(host->mmc),
30373067 host->bounce_addr,
30383068 host->bounce_buffer_size,
30393069 DMA_FROM_DEVICE);
@@ -3044,7 +3074,7 @@ static bool sdhci_request_done(struct sdhci_host *host) · 4 unmodified lines
30443074 } else {
30453075 /* No copying, just switch ownership */
30463076 dma_sync_single_for_cpu(
3047− host->mmc->parent,
3077+ mmc_dev(host->mmc),
30483078 host->bounce_addr,
30493079 host->bounce_buffer_size,
30503080 mmc_get_dma_dir(data));
@@ -3059,35 +3089,6 @@ static bool sdhci_request_done(struct sdhci_host *host) · 8 unmodified lines
30593089 }
30603090 }
30613091
3062− /*
3063− * The controller needs a reset of internal state machines
3064− * upon error conditions.
3065− */
3066− if (sdhci_needs_reset(host, mrq)) {
3067− /*
3068− * Do not finish until command and data lines are available for
3069− * reset. Note there can only be one other mrq, so it cannot
3070− * also be in mrqs_done, otherwise host->cmd and host->data_cmd
3071− * would both be null.
3072− */
3073− if (host->cmd || host->data_cmd) {
3074− spin_unlock_irqrestore(&host->lock, flags);
3075− return true;
3076− }
3077−
3078− /* Some controllers need this kick or reset won't work here */
3079− if (host->quirks & SDHCI_QUIRK_CLOCK_BEFORE_RESET)
3080− /* This is to force an update */
3081− host->ops->set_clock(host, host->clock);
3082−
3083− /* Spec says we should do both at the same time, but Ricoh
3084− controllers do not like that. */
3085− sdhci_do_reset(host, SDHCI_RESET_CMD);
3086− sdhci_do_reset(host, SDHCI_RESET_DATA);
3087−
3088− host->pending_reset = false;
3089− }
3090−
30913092 host->mrqs_done[i] = NULL;
30923093
30933094 spin_unlock_irqrestore(&host->lock, flags);
@@ -3675,7 +3676,7 @@ int sdhci_resume_host(struct sdhci_host *host) · 581 unmodified lines
36753676 host->ops->enable_dma(host);
36763677 }
36773678
3678− if ((host->mmc->pm_flags & MMC_PM_KEEP_POWER) &&
3679+ if ((mmc->pm_flags & MMC_PM_KEEP_POWER) &&
36793680 (host->quirks2 & SDHCI_QUIRK2_HOST_OFF_CARD_ON)) {
36803681 /* Card keeps power but host controller does not */
36813682 sdhci_init(host, 0);
@@ -3683,7 +3684,7 @@ int sdhci_resume_host(struct sdhci_host *host) · 1 unmodified line
36833684 host->clock = 0;
36843685 mmc->ops->set_ios(mmc, &mmc->ios);
36853686 } else {
3686− sdhci_init(host, (host->mmc->pm_flags & MMC_PM_KEEP_POWER));
3687+ sdhci_init(host, (mmc->pm_flags & MMC_PM_KEEP_POWER));
36873688 }
36883689
36893690 if (host->irq_wake_enabled) {
@@ -3691,7 +3692,7 @@ int sdhci_resume_host(struct sdhci_host *host) · 1 unmodified line
36913692 } else {
36923693 ret = request_threaded_irq(host->irq, sdhci_irq,
36933694 sdhci_thread_irq, IRQF_SHARED,
3694− mmc_hostname(host->mmc), host);
3695+ mmc_hostname(mmc), host);
36953696 if (ret)
36963697 return ret;
36973698 }
@@ -4052,7 +4053,7 @@ static void sdhci_allocate_bounce_buffer(struct sdhci_host *host) · 354 unmodified lines
40524053 * speedups by the help of a bounce buffer to group scattered
40534054 * reads/writes together.
40544055 */
4055− host->bounce_buffer = devm_kmalloc(mmc->parent,
4056+ host->bounce_buffer = devm_kmalloc(mmc_dev(mmc),
40564057 bounce_size,
40574058 GFP_KERNEL);
40584059 if (!host->bounce_buffer) {
@@ -4066,11 +4067,11 @@ static void sdhci_allocate_bounce_buffer(struct sdhci_host *host) · 7 unmodified lines
40664067 return;
40674068 }
40684069
4069− host->bounce_addr = dma_map_single(mmc->parent,
4070+ host->bounce_addr = dma_map_single(mmc_dev(mmc),
40704071 host->bounce_buffer,
40714072 bounce_size,
40724073 DMA_BIDIRECTIONAL);
4073− ret = dma_mapping_error(mmc->parent, host->bounce_addr);
4074+ ret = dma_mapping_error(mmc_dev(mmc), host->bounce_addr);
40744075 if (ret)
40754076 /* Again fall back to max_segs == 1 */
40764077 return;
@@ -4378,7 +4379,7 @@ int sdhci_setup_host(struct sdhci_host *host) · 301 unmodified lines
43784379
43794380 if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) &&
43804381 mmc_card_is_removable(mmc) &&
4381− mmc_gpio_get_cd(host->mmc) < 0)
4382+ mmc_gpio_get_cd(mmc) < 0)
43824383 mmc->caps |= MMC_CAP_NEEDS_POLL;
43834384
43844385 if (!IS_ERR(mmc->supply.vqmmc)) {
drivers/mmc/host/sdhci_am654.c+1−1
@@ -558,7 +558,7 @@ static int sdhci_am654_cqe_add_host(struct sdhci_host *host) · 557 unmodified lines
558558 struct cqhci_host *cq_host;
559559 int ret;
560560
561− cq_host = devm_kzalloc(host->mmc->parent, sizeof(struct cqhci_host),
561+ cq_host = devm_kzalloc(mmc_dev(host->mmc), sizeof(struct cqhci_host),
562562 GFP_KERNEL);
563563 if (!cq_host)
564564 return -ENOMEM;
drivers/mmc/host/tmio_mmc.h+2−1
@@ -100,8 +100,8 @@ · 99 unmodified lines
100100
101101 /* Define some IRQ masks */
102102 /* This is the mask used at reset by the chip */
103−#define TMIO_MASK_INIT_RCAR2 0x8b7f031d /* Initial value for R-Car Gen2+ */
104103 #define TMIO_MASK_ALL 0x837f031d
104+#define TMIO_MASK_ALL_RCAR2 0x8b7f031d
105105 #define TMIO_MASK_READOP (TMIO_STAT_RXRDY | TMIO_STAT_DATAEND)
106106 #define TMIO_MASK_WRITEOP (TMIO_STAT_TXRQ | TMIO_STAT_DATAEND)
107107 #define TMIO_MASK_CMD (TMIO_STAT_CMDRESPEND | TMIO_STAT_CMDTIMEOUT | \
@@ -164,6 +164,7 @@ struct tmio_mmc_host { · 56 unmodified lines
164164 u32 sdio_irq_mask;
165165 unsigned int clk_cache;
166166 u32 sdcard_irq_setbit_mask;
167+ u32 sdcard_irq_mask_all;
167168
168169 spinlock_t lock; /* protect host private data */
169170 unsigned long last_req_ts;
drivers/mmc/host/tmio_mmc_core.c+29−32
@@ -164,6 +164,21 @@ static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable) · 163 unmodified lines
164164 }
165165 }
166166
167+static void tmio_mmc_set_bus_width(struct tmio_mmc_host *host,
168+ unsigned char bus_width)
169+{
170+ u16 reg = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT)
171+ & ~(CARD_OPT_WIDTH | CARD_OPT_WIDTH8);
172+
173+ /* reg now applies to MMC_BUS_WIDTH_4 */
174+ if (bus_width == MMC_BUS_WIDTH_1)
175+ reg |= CARD_OPT_WIDTH;
176+ else if (bus_width == MMC_BUS_WIDTH_8)
177+ reg |= CARD_OPT_WIDTH8;
178+
179+ sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, reg);
180+}
181+
167182 static void tmio_mmc_reset(struct tmio_mmc_host *host)
168183 {
169184 /* FIXME - should we set stop clock reg here */
@@ -172,15 +187,23 @@ static void tmio_mmc_reset(struct tmio_mmc_host *host) · 2 unmodified lines
172187 sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);
173188 usleep_range(10000, 11000);
174189
190+ tmio_mmc_abort_dma(host);
191+
175192 if (host->reset)
176193 host->reset(host);
177194
178− tmio_mmc_abort_dma(host);
195+ sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, host->sdcard_irq_mask_all);
196+ host->sdcard_irq_mask = host->sdcard_irq_mask_all;
197+
198+ tmio_mmc_set_bus_width(host, host->mmc->ios.bus_width);
179199
180200 if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) {
181201 sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
182202 sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001);
183203 }
204+
205+ if (host->mmc->card)
206+ mmc_retune_needed(host->mmc);
184207 }
185208
186209 static void tmio_mmc_reset_work(struct work_struct *work)
@@ -874,21 +897,6 @@ static void tmio_mmc_power_off(struct tmio_mmc_host *host) · 687 unmodified lines
874897 host->set_pwr(host->pdev, 0);
875898 }
876899
877−static void tmio_mmc_set_bus_width(struct tmio_mmc_host *host,
878− unsigned char bus_width)
879−{
880− u16 reg = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT)
881− & ~(CARD_OPT_WIDTH | CARD_OPT_WIDTH8);
882−
883− /* reg now applies to MMC_BUS_WIDTH_4 */
884− if (bus_width == MMC_BUS_WIDTH_1)
885− reg |= CARD_OPT_WIDTH;
886− else if (bus_width == MMC_BUS_WIDTH_8)
887− reg |= CARD_OPT_WIDTH8;
888−
889− sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, reg);
890−}
891−
892900 static unsigned int tmio_mmc_get_timeout_cycles(struct tmio_mmc_host *host)
893901 {
894902 u16 val = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT);
@@ -1160,15 +1168,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) · 265 unmodified lines
11601168 mmc->caps & MMC_CAP_NEEDS_POLL ||
11611169 !mmc_card_is_removable(mmc));
11621170
1163− /*
1164− * On Gen2+, eMMC with NONREMOVABLE currently fails because native
1165− * hotplug gets disabled. It seems RuntimePM related yet we need further
1166− * research. Since we are planning a PM overhaul anyway, let's enforce
1167− * for now the device being active by enabling native hotplug always.
1168− */
1169− if (pdata->flags & TMIO_MMC_MIN_RCAR2)
1170− _host->native_hotplug = true;
1171−
11721171 /*
11731172 * While using internal tmio hardware logic for card detection, we need
11741173 * to ensure it stays powered for it to work.
@@ -1180,12 +1179,12 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) · 5 unmodified lines
11801179 if (pdata->flags & TMIO_MMC_SDIO_IRQ)
11811180 _host->sdio_irq_mask = TMIO_SDIO_MASK_ALL;
11821181
1182+ if (!_host->sdcard_irq_mask_all)
1183+ _host->sdcard_irq_mask_all = TMIO_MASK_ALL;
1184+
11831185 _host->set_clock(_host, 0);
11841186 tmio_mmc_reset(_host);
11851187
1186− _host->sdcard_irq_mask = sd_ctrl_read16_and_16_as_32(_host, CTL_IRQ_MASK);
1187− tmio_mmc_disable_mmc_irqs(_host, TMIO_MASK_ALL);
1188−
11891188 if (_host->native_hotplug)
11901189 tmio_mmc_enable_mmc_irqs(_host,
11911190 TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
@@ -1238,7 +1237,7 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host) · 46 unmodified lines
12381237 cancel_work_sync(&host->done);
12391238 cancel_delayed_work_sync(&host->delayed_reset_work);
12401239 tmio_mmc_release_dma(host);
1241− tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL);
1240+ tmio_mmc_disable_mmc_irqs(host, host->sdcard_irq_mask_all);
12421241
12431242 if (host->native_hotplug)
12441243 pm_runtime_put_noidle(&pdev->dev);
@@ -1268,7 +1267,7 @@ int tmio_mmc_host_runtime_suspend(struct device *dev) · 23 unmodified lines
12681267 {
12691268 struct tmio_mmc_host *host = dev_get_drvdata(dev);
12701269
1271− tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL);
1270+ tmio_mmc_disable_mmc_irqs(host, host->sdcard_irq_mask_all);
12721271
12731272 if (host->clk_cache)
12741273 host->set_clock(host, 0);
@@ -1295,8 +1294,6 @@ int tmio_mmc_host_runtime_resume(struct device *dev) · 20 unmodified lines
12951294
12961295 tmio_mmc_enable_dma(host, true);
12971296
1298− mmc_retune_needed(host->mmc);
1299−
13001297 return 0;
13011298 }
13021299 EXPORT_SYMBOL_GPL(tmio_mmc_host_runtime_resume);
drivers/mmc/host/uniphier-sd.c+4−1
@@ -635,7 +635,7 @@ static int uniphier_sd_probe(struct platform_device *pdev) · 634 unmodified lines
635635
636636 ret = tmio_mmc_host_probe(host);
637637 if (ret)
638− goto free_host;
638+ goto disable_clk;
639639
640640 ret = devm_request_irq(dev, irq, tmio_mmc_irq, IRQF_SHARED,
641641 dev_name(dev), host);
@@ -646,6 +646,8 @@ static int uniphier_sd_probe(struct platform_device *pdev) · 4 unmodified lines
646646
647647 remove_host:
648648 tmio_mmc_host_remove(host);
649+disable_clk:
650+ uniphier_sd_clk_disable(host);
649651 free_host:
650652 tmio_mmc_host_free(host);
651653
@@ -658,6 +660,7 @@ static int uniphier_sd_remove(struct platform_device *pdev) · 6 unmodified lines
658660
659661 tmio_mmc_host_remove(host);
660662 uniphier_sd_clk_disable(host);
663+ tmio_mmc_host_free(host);
661664
662665 return 0;
663666 }
drivers/mmc/host/via-sdmmc.c+1−2
@@ -1271,7 +1271,6 @@ static int __maybe_unused via_sd_suspend(struct device *dev) · 1270 unmodified lines
12711271 static int __maybe_unused via_sd_resume(struct device *dev)
12721272 {
12731273 struct via_crdr_mmc_host *sdhost;
1274− int ret = 0;
12751274 u8 gatt;
12761275
12771276 sdhost = dev_get_drvdata(dev);
@@ -1292,7 +1291,7 @@ static int __maybe_unused via_sd_resume(struct device *dev) · 14 unmodified lines
12921291 via_restore_pcictrlreg(sdhost);
12931292 via_init_sdc_pm(sdhost);
12941293
1295− return ret;
1294+ return 0;
12961295 }
12971296
12981297 static SIMPLE_DEV_PM_OPS(via_sd_pm_ops, via_sd_suspend, via_sd_resume);
include/linux/mmc/host.h+1−6
@@ -302,9 +302,6 @@ struct mmc_host { · 301 unmodified lines
302302 u32 ocr_avail_sdio; /* SDIO-specific OCR */
303303 u32 ocr_avail_sd; /* SD-specific OCR */
304304 u32 ocr_avail_mmc; /* MMC-specific OCR */
305−#ifdef CONFIG_PM_SLEEP
306− struct notifier_block pm_notify;
307−#endif
308305 struct wakeup_source *ws; /* Enable consume of uevents */
309306 u32 max_current_330;
310307 u32 max_current_300;
@@ -423,7 +420,6 @@ struct mmc_host { · 112 unmodified lines
423420 /* group bitfields together to minimize padding */
424421 unsigned int use_spi_crc:1;
425422 unsigned int claimed:1; /* host exclusively claimed */
426− unsigned int bus_dead:1; /* bus has been released */
427423 unsigned int doing_init_tune:1; /* initial tuning in progress */
428424 unsigned int can_retune:1; /* re-tuning can be used */
429425 unsigned int doing_retune:1; /* re-tuning in progress */
@@ -454,7 +450,6 @@ struct mmc_host { · 24 unmodified lines
454450 struct mmc_slot slot;
455451
456452 const struct mmc_bus_ops *bus_ops; /* current bus driver */
457− unsigned int bus_refs; /* reference counter */
458453
459454 unsigned int sdio_irqs;
460455 struct task_struct *sdio_irq_thread;
@@ -514,7 +509,7 @@ void mmc_free_host(struct mmc_host *); · 53 unmodified lines
514509 void mmc_of_parse_clk_phase(struct mmc_host *host,
515510 struct mmc_clk_phase_map *map);
516511 int mmc_of_parse(struct mmc_host *host);
517−int mmc_of_parse_voltage(struct device_node *np, u32 *mask);
512+int mmc_of_parse_voltage(struct mmc_host *host, u32 *mask);
518513
519514 static inline void *mmc_priv(struct mmc_host *host)
520515 {
include/linux/mmc/sdio.h+1−1
@@ -82,7 +82,7 @@ · 81 unmodified lines
8282 #define SDIO_SD_REV_1_01 0 /* SD Physical Spec Version 1.01 */
8383 #define SDIO_SD_REV_1_10 1 /* SD Physical Spec Version 1.10 */
8484 #define SDIO_SD_REV_2_00 2 /* SD Physical Spec Version 2.00 */
85−#define SDIO_SD_REV_3_00 3 /* SD Physical Spev Version 3.00 */
85+#define SDIO_SD_REV_3_00 3 /* SD Physical Spec Version 3.00 */
8686
8787 #define SDIO_CCCR_IOEx 0x02
8888 #define SDIO_CCCR_IORx 0x03
include/linux/spi/mmc_spi.h+0−9
@@ -35,16 +35,7 @@ struct mmc_spi_platform_data { · 34 unmodified lines
3535 void (*setpower)(struct device *, unsigned int maskval);
3636 };
3737
38−#ifdef CONFIG_OF
3938 extern struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi);
4039 extern void mmc_spi_put_pdata(struct spi_device *spi);
41−#else
42−static inline struct mmc_spi_platform_data *
43−mmc_spi_get_pdata(struct spi_device *spi)
44−{
45− return spi->dev.platform_data;
46−}
47−static inline void mmc_spi_put_pdata(struct spi_device *spi) {}
48−#endif /* CONFIG_OF */
4940
5041 #endif /* __LINUX_SPI_MMC_SPI_H */

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