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
7title: Broadcom IPROC SDHCI controller
8
9maintainers:
10 - Ray Jui <ray.jui@broadcom.com>
11 - Scott Branden <scott.branden@broadcom.com>
12 - Nicolas Saenz Julienne <nsaenz@kernel.org>
13
14allOf:
15 - $ref: mmc-controller.yaml#
16
17properties:
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
40required:
41 - compatible
42 - reg
43 - interrupts
44 - clocks
45
46unevaluatedProperties: false
47
48examples:
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 @@
1Broadcom IPROC SDHCI controller
2
3This file documents differences between the core properties described
4by mmc.txt and the properties that represent the IPROC SDHCI controller.
5
6Required 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
13Use brcm2835-sdhci for the eMMC controller on the BCM2835 (Raspberry Pi) and
14bcm2711-emmc2 for the additional eMMC2 controller on BCM2711.
15
16Use sdhci-iproc-cygnus for Broadcom SDHCI Controllers
17restricted to 32bit host accesses to SDHCI registers.
18
19Use sdhci-iproc for Broadcom SDHCI Controllers that allow standard
208, 16, 32-bit host access to SDHCI register.
21
22- clocks : The clock feeding the SDHCI controller.
23
24Optional properties:
25 - sdhci,auto-cmd12: specifies that controller should use auto CMD12.
26
27Example:
28
29sdhci0: 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
103 Only eMMC HS400 mode need to take care of this property.103 Only eMMC HS400 mode need to take care of this property.
104 default: 0104 default: 0
105 105
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
106required:126required:
107 - compatible127 - compatible
108 - reg128 - 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
5 5
6Required properties:6Required properties:
7- spi-max-frequency : maximum frequency for this device (Hz).7- 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.
11 8
12Optional properties:9Optional 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.
13- gpios : may specify GPIOs in this order: Card-Detect GPIO,13- gpios : may specify GPIOs in this order: Card-Detect GPIO,
14 Write-Protect GPIO. Note that this does not follow the14 Write-Protect GPIO. Note that this does not follow the
15 binding from mmc.txt, for historical reasons.15 binding from mmc.txt, for historical reasons.
Documentation/devicetree/bindings/mmc/mtk-sd.yaml+1−0
@@ -31,6 +31,7 @@ properties: · 30 unmodified lines
31 - const: mediatek,mt2701-mmc31 - const: mediatek,mt2701-mmc
32 - items:32 - items:
33 - const: mediatek,mt8192-mmc33 - const: mediatek,mt8192-mmc
34 - const: mediatek,mt8195-mmc
34 - const: mediatek,mt8183-mmc35 - const: mediatek,mt8183-mmc
35 36
36 clocks:37 clocks:
Documentation/devicetree/bindings/mmc/sdhci-of-dwcmshc.txt+0−20
@@ -1,20 +0,0 @@
1* Synopsys DesignWare Cores Mobile Storage Host Controller
2
3Required 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
13Example:
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
7title: Synopsys Designware Mobile Storage Host Controller Binding
8
9maintainers:
10 - Ulf Hansson <ulf.hansson@linaro.org>
11 - Jisheng Zhang <Jisheng.Zhang@synaptics.com>
12
13allOf:
14 - $ref: mmc-controller.yaml#
15
16properties:
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
54required:
55 - compatible
56 - reg
57 - interrupts
58 - clocks
59 - clock-names
60
61unevaluatedProperties: false
62
63examples:
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
331 sizeof(struct ms_id_register));331 sizeof(struct ms_id_register));
332 *mrq = &card->current_mrq;332 *mrq = &card->current_mrq;
333 return 0;333 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;
345 }334 }
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;
346}345}
347 346
348static int h_memstick_set_rw_addr(struct memstick_dev *card,347static 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
1382 1382
1383 new_msb->card = card;1383 new_msb->card = card;
1384 memstick_set_drvdata(card, new_msb);1384 memstick_set_drvdata(card, new_msb);
1385 if (mspro_block_init_card(card))1385 rc = mspro_block_init_card(card);
1386 if (rc)
1386 goto out_free;1387 goto out_free;
1387 1388
1388 for (cnt = 0; new_msb->attr_group.attrs[cnt]1389 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
359/* Flushes the temporary FIFO used to make aligned DWORD writes */359/* Flushes the temporary FIFO used to make aligned DWORD writes */
360static void r592_flush_fifo_write(struct r592_device *dev)360static void r592_flush_fifo_write(struct r592_device *dev)
361{361{
362 int ret;
362 u8 buffer[4] = { 0 };363 u8 buffer[4] = { 0 };
363 int len;
364 364
365 if (kfifo_is_empty(&dev->pio_fifo))365 if (kfifo_is_empty(&dev->pio_fifo))
366 return;366 return;
367 367
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;
369 r592_write_reg_raw_be(dev, R592_FIFO_PIO, *(u32 *)buffer);371 r592_write_reg_raw_be(dev, R592_FIFO_PIO, *(u32 *)buffer);
370}372}
371 373
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
539 539
540 if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_SANITIZE_START) &&540 if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_SANITIZE_START) &&
541 (cmd.opcode == MMC_SWITCH))541 (cmd.opcode == MMC_SWITCH))
542 return mmc_sanitize(card);542 return mmc_sanitize(card, idata->ic.cmd_timeout_ms);
543 543
544 mmc_wait_for_req(card->host, &mrq);544 mmc_wait_for_req(card->host, &mrq);
545 545
@@ -572,6 +572,18 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md, · 26 unmodified lines
572 main_md->part_curr = value & EXT_CSD_PART_CONFIG_ACC_MASK;572 main_md->part_curr = value & EXT_CSD_PART_CONFIG_ACC_MASK;
573 }573 }
574 574
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
575 /*587 /*
576 * According to the SD specs, some commands require a delay after588 * According to the SD specs, some commands require a delay after
577 * issuing the command.589 * issuing the command.
@@ -947,7 +959,7 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host, · 369 unmodified lines
947 md->reset_done |= type;959 md->reset_done |= type;
948 err = mmc_hw_reset(host);960 err = mmc_hw_reset(host);
949 /* Ensure we switch back to the correct partition */961 /* Ensure we switch back to the correct partition */
950 if (err != -EOPNOTSUPP) {962 if (err) {
951 struct mmc_blk_data *main_md =963 struct mmc_blk_data *main_md =
952 dev_get_drvdata(&host->card->dev);964 dev_get_drvdata(&host->card->dev);
953 int part_err;965 int part_err;
@@ -1933,8 +1945,9 @@ static void mmc_blk_hsq_req_done(struct mmc_request *mrq) · 979 unmodified lines
1933void mmc_blk_mq_complete(struct request *req)1945void mmc_blk_mq_complete(struct request *req)
1934{1946{
1935 struct mmc_queue *mq = req->q->queuedata;1947 struct mmc_queue *mq = req->q->queuedata;
1948 struct mmc_host *host = mq->card->host;
1936 1949
1937 if (mq->use_cqe)1950 if (host->cqe_enabled)
1938 mmc_blk_cqe_complete_rq(mq, req);1951 mmc_blk_cqe_complete_rq(mq, req);
1939 else if (likely(!blk_should_fake_timeout(req->q)))1952 else if (likely(!blk_should_fake_timeout(req->q)))
1940 mmc_blk_mq_complete_rq(mq, req);1953 mmc_blk_mq_complete_rq(mq, req);
@@ -2179,7 +2192,7 @@ out_post_req: · 238 unmodified lines
2179 2192
2180static int mmc_blk_wait_for_idle(struct mmc_queue *mq, struct mmc_host *host)2193static int mmc_blk_wait_for_idle(struct mmc_queue *mq, struct mmc_host *host)
2181{2194{
2182 if (mq->use_cqe)2195 if (host->cqe_enabled)
2183 return host->cqe_ops->cqe_wait_for_idle(host);2196 return host->cqe_ops->cqe_wait_for_idle(host);
2184 2197
2185 return mmc_blk_rw_wait(mq, NULL);2198 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
2224 case MMC_ISSUE_ASYNC:2237 case MMC_ISSUE_ASYNC:
2225 switch (req_op(req)) {2238 switch (req_op(req)) {
2226 case REQ_OP_FLUSH:2239 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 }
2227 ret = mmc_blk_cqe_issue_flush(mq, req);2244 ret = mmc_blk_cqe_issue_flush(mq, req);
2228 break;2245 break;
2229 case REQ_OP_READ:2246 case REQ_OP_READ:
2230 case REQ_OP_WRITE:2247 case REQ_OP_WRITE:
2231 if (mq->use_cqe)2248 if (host->cqe_enabled)
2232 ret = mmc_blk_cqe_issue_rw_rq(mq, req);2249 ret = mmc_blk_cqe_issue_rw_rq(mq, req);
2233 else2250 else
2234 ret = mmc_blk_mq_issue_rw_rq(mq, req);2251 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
2261{2278{
2262 struct mmc_blk_data *md;2279 struct mmc_blk_data *md;
2263 int devidx, ret;2280 int devidx, ret;
2281 char cap_str[10];
2264 2282
2265 devidx = ida_simple_get(&mmc_blk_ida, 0, max_devices, GFP_KERNEL);2283 devidx = ida_simple_get(&mmc_blk_ida, 0, max_devices, GFP_KERNEL);
2266 if (devidx < 0) {2284 if (devidx < 0) {
@@ -2365,6 +2383,12 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, · 98 unmodified lines
2365 blk_queue_write_cache(md->queue.queue, true, true);2383 blk_queue_write_cache(md->queue.queue, true, true);
2366 }2384 }
2367 2385
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
2368 return md;2392 return md;
2369 2393
2370 err_putdisk:2394 err_putdisk:
@@ -2407,7 +2431,6 @@ static int mmc_blk_alloc_part(struct mmc_card *card, · 36 unmodified lines
2407 const char *subname,2431 const char *subname,
2408 int area_type)2432 int area_type)
2409{2433{
2410 char cap_str[10];
2411 struct mmc_blk_data *part_md;2434 struct mmc_blk_data *part_md;
2412 2435
2413 part_md = mmc_blk_alloc_req(card, disk_to_dev(md->disk), size, default_ro,2436 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
2417 part_md->part_type = part_type;2440 part_md->part_type = part_type;
2418 list_add(&part_md->part, &md->part);2441 list_add(&part_md->part, &md->part);
2419 2442
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);
2425 return 0;2443 return 0;
2426}2444}
2427 2445
@@ -2558,9 +2576,8 @@ static int mmc_blk_alloc_rpmb_part(struct mmc_card *card, · 130 unmodified lines
2558 string_get_size((u64)size, 512, STRING_UNITS_2,2576 string_get_size((u64)size, 512, STRING_UNITS_2,
2559 cap_str, sizeof(cap_str));2577 cap_str, sizeof(cap_str));
2560 2578
2561 pr_info("%s: %s %s partition %u %s, chardev (%d:%d)\n",2579 pr_info("%s: %s %s %s, chardev (%d:%d)\n",
2562 rpmb_name, mmc_card_id(card),2580 rpmb_name, mmc_card_id(card), mmc_card_name(card), cap_str,
2563 mmc_card_name(card), EXT_CSD_PART_CONFIG_ACC_RPMB, cap_str,
2564 MAJOR(mmc_rpmb_devt), rpmb->id);2581 MAJOR(mmc_rpmb_devt), rpmb->id);
2565 2582
2566 return 0;2583 return 0;
@@ -2876,7 +2893,7 @@ static void mmc_blk_remove_debugfs(struct mmc_card *card, · 309 unmodified lines
2876static int mmc_blk_probe(struct mmc_card *card)2893static int mmc_blk_probe(struct mmc_card *card)
2877{2894{
2878 struct mmc_blk_data *md, *part_md;2895 struct mmc_blk_data *md, *part_md;
2879 char cap_str[10];2896 int ret = 0;
2880 2897
2881 /*2898 /*
2882 * Check that the card supports the command class(es) we need.2899 * 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
2888 2905
2889 card->complete_wq = alloc_workqueue("mmc_complete",2906 card->complete_wq = alloc_workqueue("mmc_complete",
2890 WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);2907 WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
2891 if (unlikely(!card->complete_wq)) {2908 if (!card->complete_wq) {
2892 pr_err("Failed to create mmc completion workqueue");2909 pr_err("Failed to create mmc completion workqueue");
2893 return -ENOMEM;2910 return -ENOMEM;
2894 }2911 }
2895 2912
2896 md = mmc_blk_alloc(card);2913 md = mmc_blk_alloc(card);
2897 if (IS_ERR(md))2914 if (IS_ERR(md)) {
2898 return PTR_ERR(md);2915 ret = PTR_ERR(md);
2899 2916 goto out_free;
2900 string_get_size((u64)get_capacity(md->disk), 512, STRING_UNITS_2,2917 }
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)" : "");
2905 2918
2906 if (mmc_blk_alloc_parts(card, md))2919 ret = mmc_blk_alloc_parts(card, md);
2920 if (ret)
2907 goto out;2921 goto out;
2908 2922
2909 dev_set_drvdata(&card->dev, md);2923 dev_set_drvdata(&card->dev, md);
2910 2924
2911 if (mmc_add_disk(md))2925 ret = mmc_add_disk(md);
2926 if (ret)
2912 goto out;2927 goto out;
2913 2928
2914 list_for_each_entry(part_md, &md->part, part) {2929 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)
2916 goto out;2932 goto out;
2917 }2933 }
2918 2934
@@ -2933,10 +2949,12 @@ static int mmc_blk_probe(struct mmc_card *card) · 14 unmodified lines
2933 2949
2934 return 0;2950 return 0;
2935 2951
2936 out:2952out:
2937 mmc_blk_remove_parts(card, md);2953 mmc_blk_remove_parts(card, md);
2938 mmc_blk_remove_req(md);2954 mmc_blk_remove_req(md);
2939 return 0;2955out_free:
2956 destroy_workqueue(card->complete_wq);
2957 return ret;
2940}2958}
2941 2959
2942static void mmc_blk_remove(struct mmc_card *card)2960static 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
1207 1207
1208 err = mmc_wait_for_cmd(host, &cmd, 0);1208 err = mmc_wait_for_cmd(host, &cmd, 0);
1209 if (err)1209 if (err)
1210 return err;1210 goto power_cycle;
1211 1211
1212 if (!mmc_host_is_spi(host) && (cmd.resp[0] & R1_ERROR))1212 if (!mmc_host_is_spi(host) && (cmd.resp[0] & R1_ERROR))
1213 return -EIO;1213 return -EIO;
@@ -1377,63 +1377,13 @@ void mmc_power_cycle(struct mmc_host *host, u32 ocr) · 163 unmodified lines
1377 mmc_power_up(host, ocr);1377 mmc_power_up(host, ocr);
1378}1378}
1379 1379
1380/*
1381 * Cleanup when the last reference to the bus operator is dropped.
1382 */
1383static 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 */
1393static 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 */
1406static 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
1417/*1380/*
1418 * Assign a mmc bus handler to a host. Only one bus handler may control a1381 * Assign a mmc bus handler to a host. Only one bus handler may control a
1419 * host at any given time.1382 * host at any given time.
1420 */1383 */
1421void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops)1384void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops)
1422{1385{
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
1432 host->bus_ops = ops;1386 host->bus_ops = ops;
1433 host->bus_refs = 1;
1434 host->bus_dead = 0;
1435
1436 spin_unlock_irqrestore(&host->lock, flags);
1437}1387}
1438 1388
1439/*1389/*
@@ -1441,18 +1391,7 @@ void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops) · 1 unmodified line
1441 */1391 */
1442void mmc_detach_bus(struct mmc_host *host)1392void mmc_detach_bus(struct mmc_host *host)
1443{1393{
1444 unsigned long flags;1394 host->bus_ops = NULL;
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);
1456}1395}
1457 1396
1458void _mmc_detect_change(struct mmc_host *host, unsigned long delay, bool cd_irq)1397void _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
2080{2019{
2081 int ret;2020 int ret;
2082 2021
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
2092 ret = host->bus_ops->hw_reset(host);2022 ret = host->bus_ops->hw_reset(host);
2093 mmc_bus_put(host);
2094
2095 if (ret < 0)2023 if (ret < 0)
2096 pr_warn("%s: tried to HW reset card, got error %d\n",2024 pr_warn("%s: tried to HW reset card, got error %d\n",
2097 mmc_hostname(host), ret);2025 mmc_hostname(host), ret);
@@ -2104,18 +2032,10 @@ int mmc_sw_reset(struct mmc_host *host) · 6 unmodified lines
2104{2032{
2105 int ret;2033 int ret;
2106 2034
2107 if (!host->card)2035 if (!host->bus_ops->sw_reset)
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);
2113 return -EOPNOTSUPP;2036 return -EOPNOTSUPP;
2114 }
2115 2037
2116 ret = host->bus_ops->sw_reset(host);2038 ret = host->bus_ops->sw_reset(host);
2117 mmc_bus_put(host);
2118
2119 if (ret)2039 if (ret)
2120 pr_warn("%s: tried to SW reset card, got error %d\n",2040 pr_warn("%s: tried to SW reset card, got error %d\n",
2121 mmc_hostname(host), ret);2041 mmc_hostname(host), ret);
@@ -2263,32 +2183,15 @@ void mmc_rescan(struct work_struct *work) · 141 unmodified lines
2263 host->trigger_card_event = false;2183 host->trigger_card_event = false;
2264 }2184 }
2265 2185
2266 mmc_bus_get(host);
2267
2268 /* Verify a registered card to be functional, else remove it. */2186 /* Verify a registered card to be functional, else remove it. */
2269 if (host->bus_ops && !host->bus_dead)2187 if (host->bus_ops)
2270 host->bus_ops->detect(host);2188 host->bus_ops->detect(host);
2271 2189
2272 host->detect_change = 0;2190 host->detect_change = 0;
2273 2191
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
2281 /* if there still is a card present, stop here */2192 /* if there still is a card present, stop here */
2282 if (host->bus_ops != NULL) {2193 if (host->bus_ops != NULL)
2283 mmc_bus_put(host);
2284 goto out;2194 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);
2292 2195
2293 mmc_claim_host(host);2196 mmc_claim_host(host);
2294 if (mmc_card_is_removable(host) && host->ops->get_cd &&2197 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
2351 /* clear pm flags now and let card drivers set them as needed */2254 /* clear pm flags now and let card drivers set them as needed */
2352 host->pm_flags = 0;2255 host->pm_flags = 0;
2353 2256
2354 mmc_bus_get(host);2257 if (host->bus_ops) {
2355 if (host->bus_ops && !host->bus_dead) {
2356 /* Calling bus_ops->remove() with a claimed host can deadlock */2258 /* Calling bus_ops->remove() with a claimed host can deadlock */
2357 host->bus_ops->remove(host);2259 host->bus_ops->remove(host);
2358 mmc_claim_host(host);2260 mmc_claim_host(host);
2359 mmc_detach_bus(host);2261 mmc_detach_bus(host);
2360 mmc_power_off(host);2262 mmc_power_off(host);
2361 mmc_release_host(host);2263 mmc_release_host(host);
2362 mmc_bus_put(host);
2363 return;2264 return;
2364 }2265 }
2365 mmc_bus_put(host);
2366 2266
2367 mmc_claim_host(host);2267 mmc_claim_host(host);
2368 mmc_power_off(host);2268 mmc_power_off(host);
2369 mmc_release_host(host);2269 mmc_release_host(host);
2370}2270}
2371 2271
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*/
2377static 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
2434void 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
2440void mmc_unregister_pm_notifier(struct mmc_host *host)
2441{
2442 unregister_pm_notifier(&host->pm_notify);
2443}
2444#endif
2445
2446static int __init mmc_init(void)2272static int __init mmc_init(void)
2447{2273{
2448 int ret;2274 int ret;
drivers/mmc/core/core.h+9−8
@@ -29,6 +29,7 @@ struct mmc_bus_ops { · 28 unmodified lines
29 int (*shutdown)(struct mmc_host *);29 int (*shutdown)(struct mmc_host *);
30 int (*hw_reset)(struct mmc_host *);30 int (*hw_reset)(struct mmc_host *);
31 int (*sw_reset)(struct mmc_host *);31 int (*sw_reset)(struct mmc_host *);
32 bool (*cache_enabled)(struct mmc_host *);
32};33};
33 34
34void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops);35void 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
93int mmc_hs200_to_hs400(struct mmc_card *card);94int mmc_hs200_to_hs400(struct mmc_card *card);
94int mmc_hs400_to_hs200(struct mmc_card *card);95int mmc_hs400_to_hs200(struct mmc_card *card);
95 96
96#ifdef CONFIG_PM_SLEEP
97void mmc_register_pm_notifier(struct mmc_host *host);
98void mmc_unregister_pm_notifier(struct mmc_host *host);
99#else
100static inline void mmc_register_pm_notifier(struct mmc_host *host) { }
101static inline void mmc_unregister_pm_notifier(struct mmc_host *host) { }
102#endif
103
104void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq);97void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq);
105bool mmc_is_req_done(struct mmc_host *host, struct mmc_request *mrq);98bool mmc_is_req_done(struct mmc_host *host, struct mmc_request *mrq);
106 99
@@ -171,4 +164,12 @@ static inline void mmc_post_req(struct mmc_host *host, struct mmc_request *mrq, · 64 unmodified lines
171 host->ops->post_req(host, mrq, err);164 host->ops->post_req(host, mrq, err);
172}165}
173 166
167static 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
174#endif175#endif
drivers/mmc/core/host.c+71−19
@@ -35,6 +35,42 @@ · 34 unmodified lines
35 35
36static DEFINE_IDA(mmc_host_ida);36static DEFINE_IDA(mmc_host_ida);
37 37
38#ifdef CONFIG_PM_SLEEP
39static 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
57static 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
64static 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
38static void mmc_host_classdev_release(struct device *dev)74static void mmc_host_classdev_release(struct device *dev)
39{75{
40 struct mmc_host *host = cls_dev_to_mmc_host(dev);76 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
46static struct class mmc_host_class = {82static struct class mmc_host_class = {
47 .name = "mmc_host",83 .name = "mmc_host",
48 .dev_release = mmc_host_classdev_release,84 .dev_release = mmc_host_classdev_release,
85 .pm = MMC_HOST_CLASS_DEV_PM_OPS,
49};86};
50 87
51int mmc_register_host_class(void)88int 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
209EXPORT_SYMBOL(mmc_of_parse_clk_phase);246EXPORT_SYMBOL(mmc_of_parse_clk_phase);
210 247
211/**248/**
212 * mmc_of_parse() - parse host's device-tree node249 * mmc_of_parse() - parse host's device properties
213 * @host: host whose node should be parsed.250 * @host: host whose properties should be parsed.
214 *251 *
215 * To keep the rest of the MMC subsystem unaware of whether DT has been252 * To keep the rest of the MMC subsystem unaware of whether DT has been
216 * used to to instantiate and configure this host instance or not, we253 * used to to instantiate and configure this host instance or not, we
@@ -379,44 +416,62 @@ EXPORT_SYMBOL(mmc_of_parse); · 162 unmodified lines
379 416
380/**417/**
381 * mmc_of_parse_voltage - return mask of supported voltages418 * 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.
383 * @mask: mask of voltages available for MMC/SD/SDIO420 * @mask: mask of voltages available for MMC/SD/SDIO
384 *421 *
385 * Parse the "voltage-ranges" DT property, returning zero if it is not422 * Parse the "voltage-ranges" property, returning zero if it is not
386 * found, negative errno if the voltage-range specification is invalid,423 * found, negative errno if the voltage-range specification is invalid,
387 * or one if the voltage-range is specified and successfully parsed.424 * or one if the voltage-range is specified and successfully parsed.
388 */425 */
389int mmc_of_parse_voltage(struct device_node *np, u32 *mask)426int mmc_of_parse_voltage(struct mmc_host *host, u32 *mask)
390{427{
391 const u32 *voltage_ranges;428 const char *prop = "voltage-ranges";
429 struct device *dev = host->parent;
430 u32 *voltage_ranges;
392 int num_ranges, i;431 int num_ranges, i;
432 int ret;
393 433
394 voltage_ranges = of_get_property(np, "voltage-ranges", &num_ranges);434 if (!device_property_present(dev, prop)) {
395 if (!voltage_ranges) {435 dev_dbg(dev, "%s unspecified\n", prop);
396 pr_debug("%pOF: voltage-ranges unspecified\n", np);
397 return 0;436 return 0;
398 }437 }
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;
400 if (!num_ranges) {444 if (!num_ranges) {
401 pr_err("%pOF: voltage-ranges empty\n", np);445 dev_err(dev, "%s empty\n", prop);
402 return -EINVAL;446 return -EINVAL;
403 }447 }
404 448
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
405 for (i = 0; i < num_ranges; i++) {459 for (i = 0; i < num_ranges; i++) {
406 const int j = i * 2;460 const int j = i * 2;
407 u32 ocr_mask;461 u32 ocr_mask;
408 462
409 ocr_mask = mmc_vddrange_to_ocrmask(463 ocr_mask = mmc_vddrange_to_ocrmask(voltage_ranges[j + 0],
410 be32_to_cpu(voltage_ranges[j]),464 voltage_ranges[j + 1]);
411 be32_to_cpu(voltage_ranges[j + 1]));
412 if (!ocr_mask) {465 if (!ocr_mask) {
413 pr_err("%pOF: voltage-range #%d is invalid\n",466 dev_err(dev, "range #%d in %s is invalid\n", i, prop);
414 np, i);467 kfree(voltage_ranges);
415 return -EINVAL;468 return -EINVAL;
416 }469 }
417 *mask |= ocr_mask;470 *mask |= ocr_mask;
418 }471 }
419 472
473 kfree(voltage_ranges);
474
420 return 1;475 return 1;
421}476}
422EXPORT_SYMBOL(mmc_of_parse_voltage);477EXPORT_SYMBOL(mmc_of_parse_voltage);
@@ -538,8 +593,6 @@ int mmc_add_host(struct mmc_host *host) · 115 unmodified lines
538#endif593#endif
539 594
540 mmc_start_host(host);595 mmc_start_host(host);
541 mmc_register_pm_notifier(host);
542
543 return 0;596 return 0;
544}597}
545 598
@@ -555,7 +608,6 @@ EXPORT_SYMBOL(mmc_add_host); · 9 unmodified lines
555 */608 */
556void mmc_remove_host(struct mmc_host *host)609void mmc_remove_host(struct mmc_host *host)
557{610{
558 mmc_unregister_pm_notifier(host);
559 mmc_stop_host(host);611 mmc_stop_host(host);
560 612
561#ifdef CONFIG_DEBUG_FS613#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
1068 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,1068 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1069 EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS,1069 EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS,
1070 card->ext_csd.generic_cmd6_time, MMC_TIMING_MMC_HS,1070 card->ext_csd.generic_cmd6_time, MMC_TIMING_MMC_HS,
1071 true, true);1071 true, true, MMC_CMD_RETRIES);
1072 if (err)1072 if (err)
1073 pr_warn("%s: switch to high-speed failed, err:%d\n",1073 pr_warn("%s: switch to high-speed failed, err:%d\n",
1074 mmc_hostname(card->host), err);1074 mmc_hostname(card->host), err);
@@ -1100,7 +1100,7 @@ static int mmc_select_hs_ddr(struct mmc_card *card) · 25 unmodified lines
1100 ext_csd_bits,1100 ext_csd_bits,
1101 card->ext_csd.generic_cmd6_time,1101 card->ext_csd.generic_cmd6_time,
1102 MMC_TIMING_MMC_DDR52,1102 MMC_TIMING_MMC_DDR52,
1103 true, true);1103 true, true, MMC_CMD_RETRIES);
1104 if (err) {1104 if (err) {
1105 pr_err("%s: switch to bus width %d ddr failed\n",1105 pr_err("%s: switch to bus width %d ddr failed\n",
1106 mmc_hostname(host), 1 << bus_width);1106 mmc_hostname(host), 1 << bus_width);
@@ -1168,7 +1168,7 @@ static int mmc_select_hs400(struct mmc_card *card) · 61 unmodified lines
1168 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,1168 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1169 EXT_CSD_HS_TIMING, val,1169 EXT_CSD_HS_TIMING, val,
1170 card->ext_csd.generic_cmd6_time, 0,1170 card->ext_csd.generic_cmd6_time, 0,
1171 false, true);1171 false, true, MMC_CMD_RETRIES);
1172 if (err) {1172 if (err) {
1173 pr_err("%s: switch to high-speed from hs200 failed, err:%d\n",1173 pr_err("%s: switch to high-speed from hs200 failed, err:%d\n",
1174 mmc_hostname(host), err);1174 mmc_hostname(host), err);
@@ -1210,7 +1210,7 @@ static int mmc_select_hs400(struct mmc_card *card) · 35 unmodified lines
1210 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,1210 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1211 EXT_CSD_HS_TIMING, val,1211 EXT_CSD_HS_TIMING, val,
1212 card->ext_csd.generic_cmd6_time, 0,1212 card->ext_csd.generic_cmd6_time, 0,
1213 false, true);1213 false, true, MMC_CMD_RETRIES);
1214 if (err) {1214 if (err) {
1215 pr_err("%s: switch to hs400 failed, err:%d\n",1215 pr_err("%s: switch to hs400 failed, err:%d\n",
1216 mmc_hostname(host), err);1216 mmc_hostname(host), err);
@@ -1256,7 +1256,7 @@ int mmc_hs400_to_hs200(struct mmc_card *card) · 39 unmodified lines
1256 val = EXT_CSD_TIMING_HS;1256 val = EXT_CSD_TIMING_HS;
1257 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,1257 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
1258 val, card->ext_csd.generic_cmd6_time, 0,1258 val, card->ext_csd.generic_cmd6_time, 0,
1259 false, true);1259 false, true, MMC_CMD_RETRIES);
1260 if (err)1260 if (err)
1261 goto out_err;1261 goto out_err;
1262 1262
@@ -1272,7 +1272,7 @@ int mmc_hs400_to_hs200(struct mmc_card *card) · 9 unmodified lines
1272 /* Switch HS DDR to HS */1272 /* Switch HS DDR to HS */
1273 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH,1273 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH,
1274 EXT_CSD_BUS_WIDTH_8, card->ext_csd.generic_cmd6_time,1274 EXT_CSD_BUS_WIDTH_8, card->ext_csd.generic_cmd6_time,
1275 0, false, true);1275 0, false, true, MMC_CMD_RETRIES);
1276 if (err)1276 if (err)
1277 goto out_err;1277 goto out_err;
1278 1278
@@ -1287,7 +1287,7 @@ int mmc_hs400_to_hs200(struct mmc_card *card) · 8 unmodified lines
1287 card->drive_strength << EXT_CSD_DRV_STR_SHIFT;1287 card->drive_strength << EXT_CSD_DRV_STR_SHIFT;
1288 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,1288 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
1289 val, card->ext_csd.generic_cmd6_time, 0,1289 val, card->ext_csd.generic_cmd6_time, 0,
1290 false, true);1290 false, true, MMC_CMD_RETRIES);
1291 if (err)1291 if (err)
1292 goto out_err;1292 goto out_err;
1293 1293
@@ -1371,7 +1371,7 @@ static int mmc_select_hs400es(struct mmc_card *card) · 77 unmodified lines
1371 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,1371 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1372 EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS,1372 EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS,
1373 card->ext_csd.generic_cmd6_time, 0,1373 card->ext_csd.generic_cmd6_time, 0,
1374 false, true);1374 false, true, MMC_CMD_RETRIES);
1375 if (err) {1375 if (err) {
1376 pr_err("%s: switch to hs for hs400es failed, err:%d\n",1376 pr_err("%s: switch to hs for hs400es failed, err:%d\n",
1377 mmc_hostname(host), err);1377 mmc_hostname(host), err);
@@ -1405,7 +1405,7 @@ static int mmc_select_hs400es(struct mmc_card *card) · 27 unmodified lines
1405 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,1405 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1406 EXT_CSD_HS_TIMING, val,1406 EXT_CSD_HS_TIMING, val,
1407 card->ext_csd.generic_cmd6_time, 0,1407 card->ext_csd.generic_cmd6_time, 0,
1408 false, true);1408 false, true, MMC_CMD_RETRIES);
1409 if (err) {1409 if (err) {
1410 pr_err("%s: switch to hs400es failed, err:%d\n",1410 pr_err("%s: switch to hs400es failed, err:%d\n",
1411 mmc_hostname(host), err);1411 mmc_hostname(host), err);
@@ -1470,7 +1470,7 @@ static int mmc_select_hs200(struct mmc_card *card) · 58 unmodified lines
1470 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,1470 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1471 EXT_CSD_HS_TIMING, val,1471 EXT_CSD_HS_TIMING, val,
1472 card->ext_csd.generic_cmd6_time, 0,1472 card->ext_csd.generic_cmd6_time, 0,
1473 false, true);1473 false, true, MMC_CMD_RETRIES);
1474 if (err)1474 if (err)
1475 goto err;1475 goto err;
1476 old_timing = host->ios.timing;1476 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
1975 1975
1976 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,1976 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1977 EXT_CSD_POWER_OFF_NOTIFICATION,1977 EXT_CSD_POWER_OFF_NOTIFICATION,
1978 notify_type, timeout, 0, false, false);1978 notify_type, timeout, 0, false, false, MMC_CMD_RETRIES);
1979 if (err)1979 if (err)
1980 pr_err("%s: Power Off Notification timed out, %u\n",1980 pr_err("%s: Power Off Notification timed out, %u\n",
1981 mmc_hostname(card->host), timeout);1981 mmc_hostname(card->host), timeout);
@@ -2029,6 +2029,12 @@ static void mmc_detect(struct mmc_host *host) · 47 unmodified lines
2029 }2029 }
2030}2030}
2031 2031
2032static 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
2032static int _mmc_suspend(struct mmc_host *host, bool is_suspend)2038static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
2033{2039{
2034 int err = 0;2040 int err = 0;
@@ -2208,6 +2214,7 @@ static const struct mmc_bus_ops mmc_ops = { · 173 unmodified lines
2208 .alive = mmc_alive,2214 .alive = mmc_alive,
2209 .shutdown = mmc_shutdown,2215 .shutdown = mmc_shutdown,
2210 .hw_reset = _mmc_hw_reset,2216 .hw_reset = _mmc_hw_reset,
2217 .cache_enabled = _mmc_cache_enabled,
2211};2218};
2212 2219
2213/*2220/*
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
296 return 0;296 return 0;
297}297}
298 298
299static int mmc_spi_send_csd(struct mmc_host *host, u32 *csd)299static int mmc_spi_send_cxd(struct mmc_host *host, u32 *cxd, u32 opcode)
300{300{
301 int ret, i;301 int ret, i;
302 __be32 *csd_tmp;302 __be32 *cxd_tmp;
303 303
304 csd_tmp = kzalloc(16, GFP_KERNEL);304 cxd_tmp = kzalloc(16, GFP_KERNEL);
305 if (!csd_tmp)305 if (!cxd_tmp)
306 return -ENOMEM;306 return -ENOMEM;
307 307
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);
309 if (ret)309 if (ret)
310 goto err;310 goto err;
311 311
312 for (i = 0; i < 4; i++)312 for (i = 0; i < 4; i++)
313 csd[i] = be32_to_cpu(csd_tmp[i]);313 cxd[i] = be32_to_cpu(cxd_tmp[i]);
314 314
315err:315err:
316 kfree(csd_tmp);316 kfree(cxd_tmp);
317 return ret;317 return ret;
318}318}
319 319
320int mmc_send_csd(struct mmc_card *card, u32 *csd)320int mmc_send_csd(struct mmc_card *card, u32 *csd)
321{321{
322 if (mmc_host_is_spi(card->host))322 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);
324 324
325 return mmc_send_cxd_native(card->host, card->rca << 16, csd,325 return mmc_send_cxd_native(card->host, card->rca << 16, csd,
326 MMC_SEND_CSD);326 MMC_SEND_CSD);
327}327}
328 328
329static 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
345err:
346 kfree(cid_tmp);
347 return ret;
348}
349
350int mmc_send_cid(struct mmc_host *host, u32 *cid)329int mmc_send_cid(struct mmc_host *host, u32 *cid)
351{330{
352 if (mmc_host_is_spi(host))331 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);
354 333
355 return mmc_send_cxd_native(host, 0, cid, MMC_ALL_SEND_CID);334 return mmc_send_cxd_native(host, 0, cid, MMC_ALL_SEND_CID);
356}335}
@@ -553,12 +532,13 @@ int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, · 196 unmodified lines
553 * @timing: new timing to change to532 * @timing: new timing to change to
554 * @send_status: send status cmd to poll for busy533 * @send_status: send status cmd to poll for busy
555 * @retry_crc_err: retry when CRC errors when polling with CMD13 for busy534 * @retry_crc_err: retry when CRC errors when polling with CMD13 for busy
535 * @retries: number of retries
556 *536 *
557 * Modifies the EXT_CSD register for selected card.537 * Modifies the EXT_CSD register for selected card.
558 */538 */
559int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,539int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
560 unsigned int timeout_ms, unsigned char timing,540 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)
562{542{
563 struct mmc_host *host = card->host;543 struct mmc_host *host = card->host;
564 int err;544 int err;
@@ -598,7 +578,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, · 33 unmodified lines
598 cmd.flags |= MMC_RSP_SPI_R1 | MMC_RSP_R1;578 cmd.flags |= MMC_RSP_SPI_R1 | MMC_RSP_R1;
599 }579 }
600 580
601 err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);581 err = mmc_wait_for_cmd(host, &cmd, retries);
602 if (err)582 if (err)
603 goto out;583 goto out;
604 584
@@ -633,7 +613,7 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, · 28 unmodified lines
633 unsigned int timeout_ms)613 unsigned int timeout_ms)
634{614{
635 return __mmc_switch(card, set, index, value, timeout_ms, 0,615 return __mmc_switch(card, set, index, value, timeout_ms, 0,
636 true, false);616 true, false, MMC_CMD_RETRIES);
637}617}
638EXPORT_SYMBOL_GPL(mmc_switch);618EXPORT_SYMBOL_GPL(mmc_switch);
639 619
@@ -988,9 +968,7 @@ int mmc_flush_cache(struct mmc_card *card) · 348 unmodified lines
988{968{
989 int err = 0;969 int err = 0;
990 970
991 if (mmc_card_mmc(card) &&971 if (mmc_cache_enabled(card->host)) {
992 (card->ext_csd.cache_size > 0) &&
993 (card->ext_csd.cache_ctrl & 1)) {
994 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,972 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
995 EXT_CSD_FLUSH_CACHE, 1,973 EXT_CSD_FLUSH_CACHE, 1,
996 MMC_CACHE_FLUSH_TIMEOUT_MS);974 MMC_CACHE_FLUSH_TIMEOUT_MS);
@@ -1031,7 +1009,7 @@ int mmc_cmdq_disable(struct mmc_card *card) · 34 unmodified lines
1031}1009}
1032EXPORT_SYMBOL_GPL(mmc_cmdq_disable);1010EXPORT_SYMBOL_GPL(mmc_cmdq_disable);
1033 1011
1034int mmc_sanitize(struct mmc_card *card)1012int mmc_sanitize(struct mmc_card *card, unsigned int timeout_ms)
1035{1013{
1036 struct mmc_host *host = card->host;1014 struct mmc_host *host = card->host;
1037 int err;1015 int err;
@@ -1041,12 +1019,15 @@ int mmc_sanitize(struct mmc_card *card) · 3 unmodified lines
1041 return -EOPNOTSUPP;1019 return -EOPNOTSUPP;
1042 }1020 }
1043 1021
1022 if (!timeout_ms)
1023 timeout_ms = MMC_SANITIZE_TIMEOUT_MS;
1024
1044 pr_debug("%s: Sanitize in progress...\n", mmc_hostname(host));1025 pr_debug("%s: Sanitize in progress...\n", mmc_hostname(host));
1045 1026
1046 mmc_retune_hold(host);1027 mmc_retune_hold(host);
1047 1028
1048 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_SANITIZE_START,1029 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_SANITIZE_START,
1049 1, MMC_SANITIZE_TIMEOUT_MS);1030 1, timeout_ms, 0, true, false, 0);
1050 if (err)1031 if (err)
1051 pr_err("%s: Sanitize failed err=%d\n", mmc_hostname(host), err);1032 pr_err("%s: Sanitize failed err=%d\n", mmc_hostname(host), err);
1052 1033
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
39 enum mmc_busy_cmd busy_cmd);39 enum mmc_busy_cmd busy_cmd);
40int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,40int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
41 unsigned int timeout_ms, unsigned char timing,41 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);
43int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,43int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
44 unsigned int timeout_ms);44 unsigned int timeout_ms);
45void mmc_run_bkops(struct mmc_card *card);45void mmc_run_bkops(struct mmc_card *card);
46int mmc_flush_cache(struct mmc_card *card);46int mmc_flush_cache(struct mmc_card *card);
47int mmc_cmdq_enable(struct mmc_card *card);47int mmc_cmdq_enable(struct mmc_card *card);
48int mmc_cmdq_disable(struct mmc_card *card);48int mmc_cmdq_disable(struct mmc_card *card);
49int mmc_sanitize(struct mmc_card *card);49int mmc_sanitize(struct mmc_card *card, unsigned int timeout_ms);
50 50
51#endif51#endif
52 52
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
60{60{
61 struct mmc_host *host = mq->card->host;61 struct mmc_host *host = mq->card->host;
62 62
63 if (mq->use_cqe && !host->hsq_enabled)63 if (host->cqe_enabled && !host->hsq_enabled)
64 return mmc_cqe_issue_type(host, req);64 return mmc_cqe_issue_type(host, req);
65 65
66 if (req_op(req) == REQ_OP_READ || req_op(req) == REQ_OP_WRITE)66 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
127 bool ignore_tout;127 bool ignore_tout;
128 128
129 spin_lock_irqsave(&mq->lock, flags);129 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;
131 spin_unlock_irqrestore(&mq->lock, flags);131 spin_unlock_irqrestore(&mq->lock, flags);
132 132
133 return ignore_tout ? BLK_EH_RESET_TIMER : mmc_cqe_timed_out(req);133 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
144 144
145 mq->in_recovery = true;145 mq->in_recovery = true;
146 146
147 if (mq->use_cqe && !host->hsq_enabled)147 if (host->cqe_enabled && !host->hsq_enabled)
148 mmc_blk_cqe_recovery(mq);148 mmc_blk_cqe_recovery(mq);
149 else149 else
150 mmc_blk_mq_recovery(mq);150 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
315 if (get_card)315 if (get_card)
316 mmc_get_card(card, &mq->ctx);316 mmc_get_card(card, &mq->ctx);
317 317
318 if (mq->use_cqe) {318 if (host->cqe_enabled) {
319 host->retune_now = host->need_retune && cqe_retune_ok &&319 host->retune_now = host->need_retune && cqe_retune_ok &&
320 !host->hold_retune;320 !host->hold_retune;
321 }321 }
@@ -430,7 +430,6 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card) · 108 unmodified lines
430 int ret;430 int ret;
431 431
432 mq->card = card;432 mq->card = card;
433 mq->use_cqe = host->cqe_enabled;
434 433
435 spin_lock_init(&mq->lock);434 spin_lock_init(&mq->lock);
436 435
@@ -440,7 +439,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card) · 3 unmodified lines
440 * The queue depth for CQE must match the hardware because the request439 * The queue depth for CQE must match the hardware because the request
441 * tag is used to index the hardware queue.440 * tag is used to index the hardware queue.
442 */441 */
443 if (mq->use_cqe && !host->hsq_enabled)442 if (host->cqe_enabled && !host->hsq_enabled)
444 mq->tag_set.queue_depth =443 mq->tag_set.queue_depth =
445 min_t(int, card->ext_csd.cmdq_depth, host->cqe_qdepth);444 min_t(int, card->ext_csd.cmdq_depth, host->cqe_qdepth);
446 else445 else
drivers/mmc/core/queue.h+0−1
@@ -82,7 +82,6 @@ struct mmc_queue { · 81 unmodified lines
82 unsigned int cqe_busy;82 unsigned int cqe_busy;
83#define MMC_CQE_DCMD_BUSY BIT(0)83#define MMC_CQE_DCMD_BUSY BIT(0)
84 bool busy;84 bool busy;
85 bool use_cqe;
86 bool recovery_needed;85 bool recovery_needed;
87 bool in_recovery;86 bool in_recovery;
88 bool rw_wait;87 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
135 csd->erase_size = UNSTUFF_BITS(resp, 39, 7) + 1;135 csd->erase_size = UNSTUFF_BITS(resp, 39, 7) + 1;
136 csd->erase_size <<= csd->write_blkbits - 9;136 csd->erase_size <<= csd->write_blkbits - 9;
137 }137 }
138
139 if (UNSTUFF_BITS(resp, 13, 1))
140 mmc_card_set_readonly(card);
138 break;141 break;
139 case 1:142 case 1:
140 /*143 /*
@@ -169,6 +172,9 @@ static int mmc_decode_csd(struct mmc_card *card) · 28 unmodified lines
169 csd->write_blkbits = 9;172 csd->write_blkbits = 9;
170 csd->write_partial = 0;173 csd->write_partial = 0;
171 csd->erase_size = 1;174 csd->erase_size = 1;
175
176 if (UNSTUFF_BITS(resp, 13, 1))
177 mmc_card_set_readonly(card);
172 break;178 break;
173 default:179 default:
174 pr_err("%s: unrecognised CSD structure version %d\n",180 pr_err("%s: unrecognised CSD structure version %d\n",
drivers/mmc/core/sdio.c+22−6
@@ -985,21 +985,37 @@ out: · 984 unmodified lines
985 */985 */
986static int mmc_sdio_pre_suspend(struct mmc_host *host)986static int mmc_sdio_pre_suspend(struct mmc_host *host)
987{987{
988 int i, err = 0;988 int i;
989 989
990 for (i = 0; i < host->card->sdio_funcs; i++) {990 for (i = 0; i < host->card->sdio_funcs; i++) {
991 struct sdio_func *func = host->card->sdio_func[i];991 struct sdio_func *func = host->card->sdio_func[i];
992 if (func && sdio_func_present(func) && func->dev.driver) {992 if (func && sdio_func_present(func) && func->dev.driver) {
993 const struct dev_pm_ops *pmops = func->dev.driver->pm;993 const struct dev_pm_ops *pmops = func->dev.driver->pm;
994 if (!pmops || !pmops->suspend || !pmops->resume) {994 if (!pmops || !pmops->suspend || !pmops->resume)
995 /* force removal of entire card in that case */995 /* force removal of entire card in that case */
996 err = -ENOSYS;996 goto remove;
997 break;
998 }
999 }997 }
1000 }998 }
1001 999
1002 return err;1000 return 0;
1001
1002remove:
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;
1003}1019}
1004 1020
1005/*1021/*
drivers/mmc/host/Kconfig+2−0
@@ -278,6 +278,7 @@ config MMC_SDHCI_ESDHC_IMX · 277 unmodified lines
278 tristate "SDHCI support for the Freescale eSDHC/uSDHC i.MX controller"278 tristate "SDHCI support for the Freescale eSDHC/uSDHC i.MX controller"
279 depends on ARCH_MXC || COMPILE_TEST279 depends on ARCH_MXC || COMPILE_TEST
280 depends on MMC_SDHCI_PLTFM280 depends on MMC_SDHCI_PLTFM
281 depends on OF
281 select MMC_SDHCI_IO_ACCESSORS282 select MMC_SDHCI_IO_ACCESSORS
282 select MMC_CQHCI283 select MMC_CQHCI
283 help284 help
@@ -707,6 +708,7 @@ config MMC_SDHI · 423 unmodified lines
707 tristate "Renesas SDHI SD/SDIO controller support"708 tristate "Renesas SDHI SD/SDIO controller support"
708 depends on SUPERH || ARCH_RENESAS || COMPILE_TEST709 depends on SUPERH || ARCH_RENESAS || COMPILE_TEST
709 select MMC_TMIO_CORE710 select MMC_TMIO_CORE
711 select RESET_CONTROLLER if ARCH_RENESAS
710 help712 help
711 This provides support for the SDHI SD/SDIO controller found in713 This provides support for the SDHI SD/SDIO controller found in
712 Renesas SuperH, ARM and ARM64 based SoCs714 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
34obj-$(CONFIG_MMC_MVSDIO) += mvsdio.o34obj-$(CONFIG_MMC_MVSDIO) += mvsdio.o
35obj-$(CONFIG_MMC_DAVINCI) += davinci_mmc.o35obj-$(CONFIG_MMC_DAVINCI) += davinci_mmc.o
36obj-$(CONFIG_MMC_SPI) += mmc_spi.o36obj-$(CONFIG_MMC_SPI) += mmc_spi.o
37ifeq ($(CONFIG_OF),y)
38obj-$(CONFIG_MMC_SPI) += of_mmc_spi.o37obj-$(CONFIG_MMC_SPI) += of_mmc_spi.o
39endif
40obj-$(CONFIG_MMC_S3C) += s3cmci.o38obj-$(CONFIG_MMC_S3C) += s3cmci.o
41obj-$(CONFIG_MMC_SDRICOH_CS) += sdricoh_cs.o39obj-$(CONFIG_MMC_SDRICOH_CS) += sdricoh_cs.o
42obj-$(CONFIG_MMC_TMIO) += tmio_mmc.o40obj-$(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
656 656
657 if (!mrq->data || !mrq->data->sg || !mrq->data->sg_len ||657 if (!mrq->data || !mrq->data->sg || !mrq->data->sg_len ||
658 !mrq->stop || mrq->stop->opcode != MMC_STOP_TRANSMISSION) {658 !mrq->stop || mrq->stop->opcode != MMC_STOP_TRANSMISSION) {
659 dev_err(&mmc->card->dev,659 dev_err(&mmc->card->dev, "Error: %s no data\n", __func__);
660 "Error: cmv_mmc_dma_request no data\n");
661 goto error;660 goto error;
662 }661 }
663 662
drivers/mmc/host/dw_mmc-k3.c+1−1
@@ -1,7 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0-or-later1// SPDX-License-Identifier: GPL-2.0-or-later
2/*2/*
3 * Copyright (c) 2013 Linaro Ltd.3 * Copyright (c) 2013 Linaro Ltd.
4 * Copyright (c) 2013 Hisilicon Limited.4 * Copyright (c) 2013 HiSilicon Limited.
5 */5 */
6 6
7#include <linux/bitops.h>7#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
61 }61 }
62 62
63 /* Make sure we use phases which we can enumerate with */63 /* 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)
65 clk_set_phase(priv->sample_clk, priv->default_sample_phase);65 clk_set_phase(priv->sample_clk, priv->default_sample_phase);
66 66
67 /*67 /*
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
2606{2606{
2607 struct dw_mci_slot *slot = host->slot;2607 struct dw_mci_slot *slot = host->slot;
2608 2608
2609 if (slot->mmc->ops->card_event)
2610 slot->mmc->ops->card_event(slot->mmc);
2611 mmc_detect_change(slot->mmc,2609 mmc_detect_change(slot->mmc,
2612 msecs_to_jiffies(host->pdata->detect_delay_ms));2610 msecs_to_jiffies(host->pdata->detect_delay_ms));
2613}2611}
@@ -3095,10 +3093,8 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) · 481 unmodified lines
3095 3093
3096 /* find reset controller when exist */3094 /* find reset controller when exist */
3097 pdata->rstc = devm_reset_control_get_optional_exclusive(dev, "reset");3095 pdata->rstc = devm_reset_control_get_optional_exclusive(dev, "reset");
3098 if (IS_ERR(pdata->rstc)) {3096 if (IS_ERR(pdata->rstc))
3099 if (PTR_ERR(pdata->rstc) == -EPROBE_DEFER)3097 return ERR_CAST(pdata->rstc);
3100 return ERR_PTR(-EPROBE_DEFER);
3101 }
3102 3098
3103 if (device_property_read_u32(dev, "fifo-depth", &pdata->fifo_depth))3099 if (device_property_read_u32(dev, "fifo-depth", &pdata->fifo_depth))
3104 dev_info(dev,3100 dev_info(dev,
@@ -3204,7 +3200,7 @@ int dw_mci_probe(struct dw_mci *host) · 99 unmodified lines
3204 goto err_clk_ciu;3200 goto err_clk_ciu;
3205 }3201 }
3206 3202
3207 if (!IS_ERR(host->pdata->rstc)) {3203 if (host->pdata->rstc) {
3208 reset_control_assert(host->pdata->rstc);3204 reset_control_assert(host->pdata->rstc);
3209 usleep_range(10, 50);3205 usleep_range(10, 50);
3210 reset_control_deassert(host->pdata->rstc);3206 reset_control_deassert(host->pdata->rstc);
@@ -3344,8 +3340,7 @@ err_dmaunmap: · 133 unmodified lines
3344 if (host->use_dma && host->dma_ops->exit)3340 if (host->use_dma && host->dma_ops->exit)
3345 host->dma_ops->exit(host);3341 host->dma_ops->exit(host);
3346 3342
3347 if (!IS_ERR(host->pdata->rstc))3343 reset_control_assert(host->pdata->rstc);
3348 reset_control_assert(host->pdata->rstc);
3349 3344
3350err_clk_ciu:3345err_clk_ciu:
3351 clk_disable_unprepare(host->ciu_clk);3346 clk_disable_unprepare(host->ciu_clk);
@@ -3373,8 +3368,7 @@ void dw_mci_remove(struct dw_mci *host) · 21 unmodified lines
3373 if (host->use_dma && host->dma_ops->exit)3368 if (host->use_dma && host->dma_ops->exit)
3374 host->dma_ops->exit(host);3369 host->dma_ops->exit(host);
3375 3370
3376 if (!IS_ERR(host->pdata->rstc))3371 reset_control_assert(host->pdata->rstc);
3377 reset_control_assert(host->pdata->rstc);
3378 3372
3379 clk_disable_unprepare(host->ciu_clk);3373 clk_disable_unprepare(host->ciu_clk);
3380 clk_disable_unprepare(host->biu_clk);3374 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
1397 1397
1398 host->ones = ones;1398 host->ones = ones;
1399 1399
1400 dev_set_drvdata(&spi->dev, mmc);
1401
1400 /* Platform data is used to hook up things like card sensing1402 /* Platform data is used to hook up things like card sensing
1401 * and power switching gpios.1403 * and power switching gpios.
1402 */1404 */
@@ -1413,8 +1415,6 @@ static int mmc_spi_probe(struct spi_device *spi) · 10 unmodified lines
1413 host->powerup_msecs = 250;1415 host->powerup_msecs = 250;
1414 }1416 }
1415 1417
1416 dev_set_drvdata(&spi->dev, mmc);
1417
1418 /* preallocate dma buffers */1418 /* preallocate dma buffers */
1419 host->data = kmalloc(sizeof(*host->data), GFP_KERNEL);1419 host->data = kmalloc(sizeof(*host->data), GFP_KERNEL);
1420 if (!host->data)1420 if (!host->data)
@@ -1494,8 +1494,8 @@ fail_glue_init: · 73 unmodified lines
1494fail_dma:1494fail_dma:
1495 kfree(host->data);1495 kfree(host->data);
1496fail_nobuf1:1496fail_nobuf1:
1497 mmc_free_host(mmc);
1498 mmc_spi_put_pdata(spi);1497 mmc_spi_put_pdata(spi);
1498 mmc_free_host(mmc);
1499nomem:1499nomem:
1500 kfree(ones);1500 kfree(ones);
1501 return status;1501 return status;
@@ -1518,8 +1518,8 @@ static int mmc_spi_remove(struct spi_device *spi) · 16 unmodified lines
1518 kfree(host->ones);1518 kfree(host->ones);
1519 1519
1520 spi->max_speed_hz = mmc->f_max;1520 spi->max_speed_hz = mmc->f_max;
1521 mmc_free_host(mmc);
1522 mmc_spi_put_pdata(spi);1521 mmc_spi_put_pdata(spi);
1522 mmc_free_host(mmc);
1523 return 0;1523 return 0;
1524}1524}
1525 1525
drivers/mmc/host/moxart-mmc.c+4−6
@@ -257,7 +257,6 @@ static void moxart_dma_complete(void *param) · 256 unmodified lines
257static void moxart_transfer_dma(struct mmc_data *data, struct moxart_host *host)257static void moxart_transfer_dma(struct mmc_data *data, struct moxart_host *host)
258{258{
259 u32 len, dir_slave;259 u32 len, dir_slave;
260 long dma_time;
261 struct dma_async_tx_descriptor *desc = NULL;260 struct dma_async_tx_descriptor *desc = NULL;
262 struct dma_chan *dma_chan;261 struct dma_chan *dma_chan;
263 262
@@ -294,8 +293,8 @@ static void moxart_transfer_dma(struct mmc_data *data, struct moxart_host *host) · 30 unmodified lines
294 293
295 data->bytes_xfered += host->data_remain;294 data->bytes_xfered += host->data_remain;
296 295
297 dma_time = wait_for_completion_interruptible_timeout(296 wait_for_completion_interruptible_timeout(&host->dma_complete,
298 &host->dma_complete, host->timeout);297 host->timeout);
299 298
300 dma_unmap_sg(dma_chan->device->dev,299 dma_unmap_sg(dma_chan->device->dev,
301 data->sg, data->sg_len,300 data->sg, data->sg_len,
@@ -395,7 +394,6 @@ static void moxart_prepare_data(struct moxart_host *host) · 93 unmodified lines
395static void moxart_request(struct mmc_host *mmc, struct mmc_request *mrq)394static void moxart_request(struct mmc_host *mmc, struct mmc_request *mrq)
396{395{
397 struct moxart_host *host = mmc_priv(mmc);396 struct moxart_host *host = mmc_priv(mmc);
398 long pio_time;
399 unsigned long flags;397 unsigned long flags;
400 u32 status;398 u32 status;
401 399
@@ -431,8 +429,8 @@ static void moxart_request(struct mmc_host *mmc, struct mmc_request *mrq) · 29 unmodified lines
431 spin_unlock_irqrestore(&host->lock, flags);429 spin_unlock_irqrestore(&host->lock, flags);
432 430
433 /* PIO transfers start from interrupt. */431 /* PIO transfers start from interrupt. */
434 pio_time = wait_for_completion_interruptible_timeout(432 wait_for_completion_interruptible_timeout(&host->pio_complete,
435 &host->pio_complete, host->timeout);433 host->timeout);
436 434
437 spin_lock_irqsave(&host->lock, flags);435 spin_lock_irqsave(&host->lock, flags);
438 }436 }
drivers/mmc/host/of_mmc_spi.c+6−12
@@ -19,11 +19,6 @@ · 18 unmodified lines
19#include <linux/mmc/core.h>19#include <linux/mmc/core.h>
20#include <linux/mmc/host.h>20#include <linux/mmc/host.h>
21 21
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
27MODULE_LICENSE("GPL");22MODULE_LICENSE("GPL");
28 23
29struct of_mmc_spi {24struct of_mmc_spi {
@@ -54,22 +49,22 @@ static void of_mmc_spi_exit(struct device *dev, void *mmc) · 24 unmodified lines
54 49
55struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)50struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
56{51{
52 struct mmc_host *mmc = dev_get_drvdata(&spi->dev);
57 struct device *dev = &spi->dev;53 struct device *dev = &spi->dev;
58 struct device_node *np = dev->of_node;
59 struct of_mmc_spi *oms;54 struct of_mmc_spi *oms;
60 55
61 if (dev->platform_data || !np)56 if (dev->platform_data || !dev_fwnode(dev))
62 return dev->platform_data;57 return dev->platform_data;
63 58
64 oms = kzalloc(sizeof(*oms), GFP_KERNEL);59 oms = kzalloc(sizeof(*oms), GFP_KERNEL);
65 if (!oms)60 if (!oms)
66 return NULL;61 return NULL;
67 62
68 if (mmc_of_parse_voltage(np, &oms->pdata.ocr_mask) <= 0)63 if (mmc_of_parse_voltage(mmc, &oms->pdata.ocr_mask) < 0)
69 goto err_ocr;64 goto err_ocr;
70 65
71 oms->detect_irq = irq_of_parse_and_map(np, 0);66 oms->detect_irq = spi->irq;
72 if (oms->detect_irq != 0) {67 if (oms->detect_irq > 0) {
73 oms->pdata.init = of_mmc_spi_init;68 oms->pdata.init = of_mmc_spi_init;
74 oms->pdata.exit = of_mmc_spi_exit;69 oms->pdata.exit = of_mmc_spi_exit;
75 } else {70 } else {
@@ -87,10 +82,9 @@ EXPORT_SYMBOL(mmc_spi_get_pdata); · 11 unmodified lines
87void mmc_spi_put_pdata(struct spi_device *spi)82void mmc_spi_put_pdata(struct spi_device *spi)
88{83{
89 struct device *dev = &spi->dev;84 struct device *dev = &spi->dev;
90 struct device_node *np = dev->of_node;
91 struct of_mmc_spi *oms = to_of_mmc_spi(dev);85 struct of_mmc_spi *oms = to_of_mmc_spi(dev);
92 86
93 if (!dev->platform_data || !np)87 if (!dev->platform_data || !dev_fwnode(dev))
94 return;88 return;
95 89
96 kfree(oms);90 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
581 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);581 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
582 owl_host->base = devm_ioremap_resource(&pdev->dev, res);582 owl_host->base = devm_ioremap_resource(&pdev->dev, res);
583 if (IS_ERR(owl_host->base)) {583 if (IS_ERR(owl_host->base)) {
584 dev_err(&pdev->dev, "Failed to remap registers\n");
585 ret = PTR_ERR(owl_host->base);584 ret = PTR_ERR(owl_host->base);
586 goto err_free_host;585 goto err_free_host;
587 }586 }
drivers/mmc/host/renesas_sdhi.h+2−0
@@ -70,6 +70,8 @@ struct renesas_sdhi { · 69 unmodified lines
70 DECLARE_BITMAP(smpcmp, BITS_PER_LONG);70 DECLARE_BITMAP(smpcmp, BITS_PER_LONG);
71 unsigned int tap_num;71 unsigned int tap_num;
72 unsigned int tap_set;72 unsigned int tap_set;
73
74 struct reset_control *rstc;
73};75};
74 76
75#define host_to_priv(host) \77#define host_to_priv(host) \
drivers/mmc/host/renesas_sdhi_core.c+28−10
@@ -20,6 +20,7 @@ · 19 unmodified lines
20 20
21#include <linux/clk.h>21#include <linux/clk.h>
22#include <linux/delay.h>22#include <linux/delay.h>
23#include <linux/iopoll.h>
23#include <linux/kernel.h>24#include <linux/kernel.h>
24#include <linux/mfd/tmio.h>25#include <linux/mfd/tmio.h>
25#include <linux/mmc/host.h>26#include <linux/mmc/host.h>
@@ -32,6 +33,7 @@ · 6 unmodified lines
32#include <linux/platform_device.h>33#include <linux/platform_device.h>
33#include <linux/pm_domain.h>34#include <linux/pm_domain.h>
34#include <linux/regulator/consumer.h>35#include <linux/regulator/consumer.h>
36#include <linux/reset.h>
35#include <linux/sh_dma.h>37#include <linux/sh_dma.h>
36#include <linux/slab.h>38#include <linux/slab.h>
37#include <linux/sys_soc.h>39#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
557 return 0;559 return 0;
558}560}
559 561
562static 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
560/* only populated for TMIO_MMC_MIN_RCAR2 */573/* only populated for TMIO_MMC_MIN_RCAR2 */
561static void renesas_sdhi_reset(struct tmio_mmc_host *host)574static void renesas_sdhi_reset(struct tmio_mmc_host *host)
562{575{
563 struct renesas_sdhi *priv = host_to_priv(host);576 struct renesas_sdhi *priv = host_to_priv(host);
577 int ret;
564 u16 val;578 u16 val;
565 579
566 if (priv->scc_ctl) {580 if (priv->rstc) {
567 renesas_sdhi_disable_scc(host->mmc);581 reset_control_reset(priv->rstc);
568 renesas_sdhi_reset_hs400_mode(host, priv);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);
569 priv->needs_adjust_hs400 = false;585 priv->needs_adjust_hs400 = false;
570 586 renesas_sdhi_set_clock(host, host->clk_cache);
571 sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL,587 } else if (priv->scc_ctl) {
572 ~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN &588 renesas_sdhi_scc_reset(host, priv);
573 sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL));
574 }589 }
575 590
576 sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, TMIO_MASK_INIT_RCAR2);
577
578 if (sd_ctrl_read16(host, CTL_VERSION) >= SDHI_VER_GEN3_SD) {591 if (sd_ctrl_read16(host, CTL_VERSION) >= SDHI_VER_GEN3_SD) {
579 val = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT);592 val = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT);
580 val |= CARD_OPT_EXTOP;593 val |= CARD_OPT_EXTOP;
@@ -691,7 +704,7 @@ static int renesas_sdhi_execute_tuning(struct mmc_host *mmc, u32 opcode) · 110 unmodified lines
691 704
692 ret = renesas_sdhi_select_tuning(host);705 ret = renesas_sdhi_select_tuning(host);
693 if (ret < 0)706 if (ret < 0)
694 renesas_sdhi_reset(host);707 renesas_sdhi_scc_reset(host, priv);
695 return ret;708 return ret;
696}709}
697 710
@@ -1034,6 +1047,7 @@ int renesas_sdhi_probe(struct platform_device *pdev, · 336 unmodified lines
1034 host->ops.start_signal_voltage_switch =1047 host->ops.start_signal_voltage_switch =
1035 renesas_sdhi_start_signal_voltage_switch;1048 renesas_sdhi_start_signal_voltage_switch;
1036 host->sdcard_irq_setbit_mask = TMIO_STAT_ALWAYS_SET_27;1049 host->sdcard_irq_setbit_mask = TMIO_STAT_ALWAYS_SET_27;
1050 host->sdcard_irq_mask_all = TMIO_MASK_ALL_RCAR2;
1037 host->reset = renesas_sdhi_reset;1051 host->reset = renesas_sdhi_reset;
1038 }1052 }
1039 1053
@@ -1076,6 +1090,10 @@ int renesas_sdhi_probe(struct platform_device *pdev, · 36 unmodified lines
1076 if (ret)1090 if (ret)
1077 goto efree;1091 goto efree;
1078 1092
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
1079 ver = sd_ctrl_read16(host, CTL_VERSION);1097 ver = sd_ctrl_read16(host, CTL_VERSION);
1080 /* GEN2_SDR104 is first known SDHI to use 32bit block count */1098 /* GEN2_SDR104 is first known SDHI to use 32bit block count */
1081 if (ver < SDHI_VER_GEN2_SDR104 && mmc_data->max_blk_count > U16_MAX)1099 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
97 TMIO_MMC_HAVE_CBSY,97 TMIO_MMC_HAVE_CBSY,
98 .tmio_ocr_mask = MMC_VDD_32_33,98 .tmio_ocr_mask = MMC_VDD_32_33,
99 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |99 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
100 MMC_CAP_CMD23,100 MMC_CAP_CMD23 | MMC_CAP_WAIT_WHILE_BUSY,
101 .bus_shift = 2,101 .bus_shift = 2,
102 .scc_offset = 0 - 0x1000,102 .scc_offset = 0 - 0x1000,
103 .taps = rcar_gen3_scc_taps,103 .taps = rcar_gen3_scc_taps,
@@ -111,7 +111,7 @@ static const struct renesas_sdhi_of_data of_rcar_gen3_compatible = { · 7 unmodified lines
111 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL |111 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL |
112 TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,112 TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,
113 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |113 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
114 MMC_CAP_CMD23,114 MMC_CAP_CMD23 | MMC_CAP_WAIT_WHILE_BUSY,
115 .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT | MMC_CAP2_MERGE_CAPABLE,115 .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT | MMC_CAP2_MERGE_CAPABLE,
116 .bus_shift = 2,116 .bus_shift = 2,
117 .scc_offset = 0x1000,117 .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
33 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_32BIT_DATA_PORT |33 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_32BIT_DATA_PORT |
34 TMIO_MMC_HAVE_CBSY,34 TMIO_MMC_HAVE_CBSY,
35 .tmio_ocr_mask = MMC_VDD_32_33,35 .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,
37};38};
38 39
39static const struct renesas_sdhi_of_data of_rcar_gen1_compatible = {40static const struct renesas_sdhi_of_data of_rcar_gen1_compatible = {
40 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL,41 .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,
42 .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,44 .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
43};45};
44 46
@@ -58,7 +60,7 @@ static const struct renesas_sdhi_of_data of_rcar_gen2_compatible = { · 13 unmodified lines
58 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL |60 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL |
59 TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,61 TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2,
60 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |62 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
61 MMC_CAP_CMD23,63 MMC_CAP_CMD23 | MMC_CAP_WAIT_WHILE_BUSY,
62 .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,64 .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT,
63 .dma_buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES,65 .dma_buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES,
64 .dma_rx_offset = 0x2000,66 .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
772 { "QCOM8051", NULL, &sdhci_acpi_slot_qcom_sd_3v },772 { "QCOM8051", NULL, &sdhci_acpi_slot_qcom_sd_3v },
773 { "QCOM8052", NULL, &sdhci_acpi_slot_qcom_sd },773 { "QCOM8052", NULL, &sdhci_acpi_slot_qcom_sd },
774 { "AMDI0040", NULL, &sdhci_acpi_slot_amd_emmc },774 { "AMDI0040", NULL, &sdhci_acpi_slot_amd_emmc },
775 { "AMDI0041", NULL, &sdhci_acpi_slot_amd_emmc },
775 { },776 { },
776};777};
777 778
@@ -789,6 +790,7 @@ static const struct acpi_device_id sdhci_acpi_ids[] = { · 11 unmodified lines
789 { "QCOM8051" },790 { "QCOM8051" },
790 { "QCOM8052" },791 { "QCOM8052" },
791 { "AMDI0040" },792 { "AMDI0040" },
793 { "AMDI0041" },
792 { },794 { },
793};795};
794MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids);796MODULE_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
199 if (dma64) {199 if (dma64) {
200 dev_dbg(mmc_dev(host->mmc), "Using 64 bit DMA\n");200 dev_dbg(mmc_dev(host->mmc), "Using 64 bit DMA\n");
201 cq_host->caps |= CQHCI_TASK_DESC_SZ_128;201 cq_host->caps |= CQHCI_TASK_DESC_SZ_128;
202 cq_host->quirks |= CQHCI_QUIRK_SHORT_TXFR_DESC_SZ;
203 }202 }
204 203
205 ret = cqhci_init(cq_host, host->mmc, dma64);204 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
434 * Do not advertise faster UHS modes if there are no434 * Do not advertise faster UHS modes if there are no
435 * pinctrl states for 100MHz/200MHz.435 * pinctrl states for 100MHz/200MHz.
436 */436 */
437 if (IS_ERR_OR_NULL(imx_data->pins_100mhz) ||437 if (IS_ERR_OR_NULL(imx_data->pins_100mhz))
438 IS_ERR_OR_NULL(imx_data->pins_200mhz))438 val &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_DDR50);
439 val &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_DDR50439 if (IS_ERR_OR_NULL(imx_data->pins_200mhz))
440 | SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_HS400);440 val &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_HS400);
441 }441 }
442 }442 }
443 443
@@ -1453,7 +1453,6 @@ static const struct cqhci_host_ops esdhc_cqhci_ops = { · 1009 unmodified lines
1453 .dumpregs = esdhc_sdhci_dumpregs,1453 .dumpregs = esdhc_sdhci_dumpregs,
1454};1454};
1455 1455
1456#ifdef CONFIG_OF
1457static int1456static int
1458sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,1457sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
1459 struct sdhci_host *host,1458 struct sdhci_host *host,
@@ -1486,9 +1485,9 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, · 26 unmodified lines
1486 if (of_property_read_u32(np, "fsl,delay-line", &boarddata->delay_line))1485 if (of_property_read_u32(np, "fsl,delay-line", &boarddata->delay_line))
1487 boarddata->delay_line = 0;1486 boarddata->delay_line = 0;
1488 1487
1489 mmc_of_parse_voltage(np, &host->ocr_mask);1488 mmc_of_parse_voltage(host->mmc, &host->ocr_mask);
1490 1489
1491 if (esdhc_is_usdhc(imx_data)) {1490 if (esdhc_is_usdhc(imx_data) && !IS_ERR(imx_data->pinctrl)) {
1492 imx_data->pins_100mhz = pinctrl_lookup_state(imx_data->pinctrl,1491 imx_data->pins_100mhz = pinctrl_lookup_state(imx_data->pinctrl,
1493 ESDHC_PINCTRL_STATE_100MHZ);1492 ESDHC_PINCTRL_STATE_100MHZ);
1494 imx_data->pins_200mhz = pinctrl_lookup_state(imx_data->pinctrl,1493 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
1505 1504
1506 return 0;1505 return 0;
1507}1506}
1508#else
1509static inline int
1510sdhci_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
1517 1507
1518static int sdhci_esdhc_imx_probe(struct platform_device *pdev)1508static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
1519{1509{
1520 const struct of_device_id *of_id =
1521 of_match_device(imx_esdhc_dt_ids, &pdev->dev);
1522 struct sdhci_pltfm_host *pltfm_host;1510 struct sdhci_pltfm_host *pltfm_host;
1523 struct sdhci_host *host;1511 struct sdhci_host *host;
1524 struct cqhci_host *cq_host;1512 struct cqhci_host *cq_host;
@@ -1534,7 +1522,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) · 9 unmodified lines
1534 1522
1535 imx_data = sdhci_pltfm_priv(pltfm_host);1523 imx_data = sdhci_pltfm_priv(pltfm_host);
1536 1524
1537 imx_data->socdata = of_id->data;1525 imx_data->socdata = device_get_match_data(&pdev->dev);
1538 1526
1539 if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS)1527 if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS)
1540 cpu_latency_qos_add_request(&imx_data->pm_qos_req, 0);1528 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
367 struct pltfm_mcf_data *mcf_data)367 struct pltfm_mcf_data *mcf_data)
368{368{
369 struct mcf_esdhc_platform_data *plat_data;369 struct mcf_esdhc_platform_data *plat_data;
370 struct device *dev = mmc_dev(host->mmc);
370 371
371 if (!host->mmc->parent->platform_data) {372 if (!dev->platform_data) {
372 dev_err(mmc_dev(host->mmc), "no platform data!\n");373 dev_err(dev, "no platform data!\n");
373 return -EINVAL;374 return -EINVAL;
374 }375 }
375 376
376 plat_data = (struct mcf_esdhc_platform_data *)377 plat_data = (struct mcf_esdhc_platform_data *)dev->platform_data;
377 host->mmc->parent->platform_data;
378 378
379 /* Card_detect */379 /* Card_detect */
380 switch (plat_data->cd_type) {380 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
1863 struct mmc_host *mmc = msm_host->mmc;1863 struct mmc_host *mmc = msm_host->mmc;
1864 struct device *dev = mmc_dev(mmc);1864 struct device *dev = mmc_dev(mmc);
1865 struct resource *res;1865 struct resource *res;
1866 int err;
1867 1866
1868 if (!(cqhci_readl(cq_host, CQHCI_CAP) & CQHCI_CAP_CS))1867 if (!(cqhci_readl(cq_host, CQHCI_CAP) & CQHCI_CAP_CS))
1869 return 0;1868 return 0;
@@ -1881,11 +1880,8 @@ static int sdhci_msm_ice_init(struct sdhci_msm_host *msm_host, · 11 unmodified lines
1881 }1880 }
1882 1881
1883 msm_host->ice_mem = devm_ioremap_resource(dev, res);1882 msm_host->ice_mem = devm_ioremap_resource(dev, res);
1884 if (IS_ERR(msm_host->ice_mem)) {1883 if (IS_ERR(msm_host->ice_mem))
1885 err = PTR_ERR(msm_host->ice_mem);1884 return PTR_ERR(msm_host->ice_mem);
1886 dev_err(dev, "Failed to map ICE registers; err=%d\n", err);
1887 return err;
1888 }
1889 1885
1890 if (!sdhci_msm_ice_supported(msm_host))1886 if (!sdhci_msm_ice_supported(msm_host))
1891 goto disable;1887 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
181 struct aspeed_sdhci *sdhci;181 struct aspeed_sdhci *sdhci;
182 struct device *dev;182 struct device *dev;
183 183
184 dev = host->mmc->parent;184 dev = mmc_dev(host->mmc);
185 sdhci = sdhci_pltfm_priv(sdhci_priv(host));185 sdhci = sdhci_pltfm_priv(sdhci_priv(host));
186 186
187 if (!sdhci->phase_desc)187 if (!sdhci->phase_desc)
drivers/mmc/host/sdhci-of-dwcmshc.c+292−21
@@ -7,11 +7,14 @@ · 6 unmodified lines
7 * Author: Jisheng Zhang <jszhang@kernel.org>7 * Author: Jisheng Zhang <jszhang@kernel.org>
8 */8 */
9 9
10#include <linux/acpi.h>
10#include <linux/clk.h>11#include <linux/clk.h>
11#include <linux/dma-mapping.h>12#include <linux/dma-mapping.h>
13#include <linux/iopoll.h>
12#include <linux/kernel.h>14#include <linux/kernel.h>
13#include <linux/module.h>15#include <linux/module.h>
14#include <linux/of.h>16#include <linux/of.h>
17#include <linux/of_device.h>
15#include <linux/sizes.h>18#include <linux/sizes.h>
16 19
17#include "sdhci-pltfm.h"20#include "sdhci-pltfm.h"
@@ -21,11 +24,52 @@ · 3 unmodified lines
21/* DWCMSHC specific Mode Select value */24/* DWCMSHC specific Mode Select value */
22#define DWCMSHC_CTRL_HS400 0x725#define DWCMSHC_CTRL_HS400 0x7
23 26
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
24#define BOUNDARY_OK(addr, len) \60#define BOUNDARY_OK(addr, len) \
25 ((addr | (SZ_128M - 1)) == ((addr + len - 1) | (SZ_128M - 1)))61 ((addr | (SZ_128M - 1)) == ((addr + len - 1) | (SZ_128M - 1)))
26 62
63struct rk3568_priv {
64 /* Rockchip specified optional clocks */
65 struct clk_bulk_data rockchip_clks[RK3568_MAX_CLKS];
66 u8 txclk_tapnum;
67};
68
27struct dwcmshc_priv {69struct dwcmshc_priv {
28 struct clk *bus_clk;70 struct clk *bus_clk;
71 int vendor_specific_area1; /* P_VENDOR_SPECIFIC_AREA reg */
72 void *priv; /* pointer to SoC private stuff */
29};73};
30 74
31/*75/*
@@ -51,6 +95,16 @@ static void dwcmshc_adma_write_desc(struct sdhci_host *host, void **desc, · 19 unmodified lines
51 sdhci_adma_write_desc(host, desc, addr, len, cmd);95 sdhci_adma_write_desc(host, desc, addr, len, cmd);
52}96}
53 97
98static 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
54static void dwcmshc_check_auto_cmd23(struct mmc_host *mmc,108static void dwcmshc_check_auto_cmd23(struct mmc_host *mmc,
55 struct mmc_request *mrq)109 struct mmc_request *mrq)
56{110{
@@ -100,10 +154,120 @@ static void dwcmshc_set_uhs_signaling(struct sdhci_host *host, · 43 unmodified lines
100 sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);154 sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
101}155}
102 156
157static 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
175static 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
103static const struct sdhci_ops sdhci_dwcmshc_ops = {258static const struct sdhci_ops sdhci_dwcmshc_ops = {
104 .set_clock = sdhci_set_clock,259 .set_clock = sdhci_set_clock,
105 .set_bus_width = sdhci_set_bus_width,260 .set_bus_width = sdhci_set_bus_width,
106 .set_uhs_signaling = dwcmshc_set_uhs_signaling,261 .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
267static 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,
107 .get_max_clock = sdhci_pltfm_clk_get_max_clock,271 .get_max_clock = sdhci_pltfm_clk_get_max_clock,
108 .reset = sdhci_reset,272 .reset = sdhci_reset,
109 .adma_write_desc = dwcmshc_adma_write_desc,273 .adma_write_desc = dwcmshc_adma_write_desc,
@@ -115,15 +279,86 @@ static const struct sdhci_pltfm_data sdhci_dwcmshc_pdata = { · 5 unmodified lines
115 .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN,279 .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
116};280};
117 281
282static 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
290static 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
324static 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};
335MODULE_DEVICE_TABLE(of, sdhci_dwcmshc_dt_ids);
336
337#ifdef CONFIG_ACPI
338static const struct acpi_device_id sdhci_dwcmshc_acpi_ids[] = {
339 { .id = "MLNXBF30" },
340 {}
341};
342#endif
343
118static int dwcmshc_probe(struct platform_device *pdev)344static int dwcmshc_probe(struct platform_device *pdev)
119{345{
346 struct device *dev = &pdev->dev;
120 struct sdhci_pltfm_host *pltfm_host;347 struct sdhci_pltfm_host *pltfm_host;
121 struct sdhci_host *host;348 struct sdhci_host *host;
122 struct dwcmshc_priv *priv;349 struct dwcmshc_priv *priv;
350 struct rk3568_priv *rk_priv = NULL;
351 const struct sdhci_pltfm_data *pltfm_data;
123 int err;352 int err;
124 u32 extra;353 u32 extra;
125 354
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,
127 sizeof(struct dwcmshc_priv));362 sizeof(struct dwcmshc_priv));
128 if (IS_ERR(host))363 if (IS_ERR(host))
129 return PTR_ERR(host);364 return PTR_ERR(host);
@@ -131,7 +366,7 @@ static int dwcmshc_probe(struct platform_device *pdev) · 1 unmodified line
131 /*366 /*
132 * extra adma table cnt for cross 128M boundary handling.367 * extra adma table cnt for cross 128M boundary handling.
133 */368 */
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);
135 if (extra > SDHCI_MAX_SEGS)370 if (extra > SDHCI_MAX_SEGS)
136 extra = SDHCI_MAX_SEGS;371 extra = SDHCI_MAX_SEGS;
137 host->adma_table_cnt += extra;372 host->adma_table_cnt += extra;
@@ -139,19 +374,21 @@ static int dwcmshc_probe(struct platform_device *pdev) · 1 unmodified line
139 pltfm_host = sdhci_priv(host);374 pltfm_host = sdhci_priv(host);
140 priv = sdhci_pltfm_priv(pltfm_host);375 priv = sdhci_pltfm_priv(pltfm_host);
141 376
142 pltfm_host->clk = devm_clk_get(&pdev->dev, "core");377 if (dev->of_node) {
143 if (IS_ERR(pltfm_host->clk)) {378 pltfm_host->clk = devm_clk_get(dev, "core");
144 err = PTR_ERR(pltfm_host->clk);379 if (IS_ERR(pltfm_host->clk)) {
145 dev_err(&pdev->dev, "failed to get core clk: %d\n", err);380 err = PTR_ERR(pltfm_host->clk);
146 goto free_pltfm;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);
147 }391 }
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);
155 392
156 err = mmc_of_parse(host->mmc);393 err = mmc_of_parse(host->mmc);
157 if (err)394 if (err)
@@ -159,7 +396,27 @@ static int dwcmshc_probe(struct platform_device *pdev) · 1 unmodified line
159 396
160 sdhci_get_of_property(pdev);397 sdhci_get_of_property(pdev);
161 398
399 priv->vendor_specific_area1 =
400 sdhci_readl(host, DWCMSHC_P_VENDOR_AREA1) & DWCMSHC_AREA1_MASK;
401
162 host->mmc_host_ops.request = dwcmshc_request;402 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;
163 420
164 err = sdhci_add_host(host);421 err = sdhci_add_host(host);
165 if (err)422 if (err)
@@ -170,6 +427,9 @@ static int dwcmshc_probe(struct platform_device *pdev) · 4 unmodified lines
170err_clk:427err_clk:
171 clk_disable_unprepare(pltfm_host->clk);428 clk_disable_unprepare(pltfm_host->clk);
172 clk_disable_unprepare(priv->bus_clk);429 clk_disable_unprepare(priv->bus_clk);
430 if (rk_priv)
431 clk_bulk_disable_unprepare(RK3568_MAX_CLKS,
432 rk_priv->rockchip_clks);
173free_pltfm:433free_pltfm:
174 sdhci_pltfm_free(pdev);434 sdhci_pltfm_free(pdev);
175 return err;435 return err;
@@ -180,12 +440,15 @@ static int dwcmshc_remove(struct platform_device *pdev) · 4 unmodified lines
180 struct sdhci_host *host = platform_get_drvdata(pdev);440 struct sdhci_host *host = platform_get_drvdata(pdev);
181 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);441 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
182 struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host);442 struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host);
443 struct rk3568_priv *rk_priv = priv->priv;
183 444
184 sdhci_remove_host(host, 0);445 sdhci_remove_host(host, 0);
185 446
186 clk_disable_unprepare(pltfm_host->clk);447 clk_disable_unprepare(pltfm_host->clk);
187 clk_disable_unprepare(priv->bus_clk);448 clk_disable_unprepare(priv->bus_clk);
188 449 if (rk_priv)
450 clk_bulk_disable_unprepare(RK3568_MAX_CLKS,
451 rk_priv->rockchip_clks);
189 sdhci_pltfm_free(pdev);452 sdhci_pltfm_free(pdev);
190 453
191 return 0;454 return 0;
@@ -197,6 +460,7 @@ static int dwcmshc_suspend(struct device *dev) · 5 unmodified lines
197 struct sdhci_host *host = dev_get_drvdata(dev);460 struct sdhci_host *host = dev_get_drvdata(dev);
198 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);461 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
199 struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host);462 struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host);
463 struct rk3568_priv *rk_priv = priv->priv;
200 int ret;464 int ret;
201 465
202 ret = sdhci_suspend_host(host);466 ret = sdhci_suspend_host(host);
@@ -207,6 +471,10 @@ static int dwcmshc_suspend(struct device *dev) · 4 unmodified lines
207 if (!IS_ERR(priv->bus_clk))471 if (!IS_ERR(priv->bus_clk))
208 clk_disable_unprepare(priv->bus_clk);472 clk_disable_unprepare(priv->bus_clk);
209 473
474 if (rk_priv)
475 clk_bulk_disable_unprepare(RK3568_MAX_CLKS,
476 rk_priv->rockchip_clks);
477
210 return ret;478 return ret;
211}479}
212 480
@@ -215,6 +483,7 @@ static int dwcmshc_resume(struct device *dev) · 2 unmodified lines
215 struct sdhci_host *host = dev_get_drvdata(dev);483 struct sdhci_host *host = dev_get_drvdata(dev);
216 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);484 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
217 struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host);485 struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host);
486 struct rk3568_priv *rk_priv = priv->priv;
218 int ret;487 int ret;
219 488
220 ret = clk_prepare_enable(pltfm_host->clk);489 ret = clk_prepare_enable(pltfm_host->clk);
@@ -227,23 +496,25 @@ static int dwcmshc_resume(struct device *dev) · 6 unmodified lines
227 return ret;496 return ret;
228 }497 }
229 498
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
230 return sdhci_resume_host(host);506 return sdhci_resume_host(host);
231}507}
232#endif508#endif
233 509
234static SIMPLE_DEV_PM_OPS(dwcmshc_pmops, dwcmshc_suspend, dwcmshc_resume);510static SIMPLE_DEV_PM_OPS(dwcmshc_pmops, dwcmshc_suspend, dwcmshc_resume);
235 511
236static const struct of_device_id sdhci_dwcmshc_dt_ids[] = {
237 { .compatible = "snps,dwcmshc-sdhci" },
238 {}
239};
240MODULE_DEVICE_TABLE(of, sdhci_dwcmshc_dt_ids);
241
242static struct platform_driver sdhci_dwcmshc_driver = {512static struct platform_driver sdhci_dwcmshc_driver = {
243 .driver = {513 .driver = {
244 .name = "sdhci-dwcmshc",514 .name = "sdhci-dwcmshc",
245 .probe_type = PROBE_PREFER_ASYNCHRONOUS,515 .probe_type = PROBE_PREFER_ASYNCHRONOUS,
246 .of_match_table = sdhci_dwcmshc_dt_ids,516 .of_match_table = sdhci_dwcmshc_dt_ids,
517 .acpi_match_table = ACPI_PTR(sdhci_dwcmshc_acpi_ids),
247 .pm = &dwcmshc_pmops,518 .pm = &dwcmshc_pmops,
248 },519 },
249 .probe = dwcmshc_probe,520 .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
1489 if (ret)1489 if (ret)
1490 goto err;1490 goto err;
1491 1491
1492 mmc_of_parse_voltage(np, &host->ocr_mask);1492 mmc_of_parse_voltage(host->mmc, &host->ocr_mask);
1493 1493
1494 ret = sdhci_add_host(host);1494 ret = sdhci_add_host(host);
1495 if (ret)1495 if (ret)
drivers/mmc/host/sdhci-pci-core.c+30−1
@@ -516,6 +516,7 @@ struct intel_host { · 515 unmodified lines
516 int drv_strength;516 int drv_strength;
517 bool d3_retune;517 bool d3_retune;
518 bool rpm_retune_ok;518 bool rpm_retune_ok;
519 bool needs_pwr_off;
519 u32 glk_rx_ctrl1;520 u32 glk_rx_ctrl1;
520 u32 glk_tun_val;521 u32 glk_tun_val;
521 u32 active_ltr;522 u32 active_ltr;
@@ -643,9 +644,25 @@ out: · 121 unmodified lines
643static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,644static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
644 unsigned short vdd)645 unsigned short vdd)
645{646{
647 struct sdhci_pci_slot *slot = sdhci_priv(host);
648 struct intel_host *intel_host = sdhci_pci_priv(slot);
646 int cntr;649 int cntr;
647 u8 reg;650 u8 reg;
648 651
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
649 sdhci_set_power(host, mode, vdd);666 sdhci_set_power(host, mode, vdd);
650 667
651 if (mode == MMC_POWER_OFF)668 if (mode == MMC_POWER_OFF)
@@ -958,7 +975,7 @@ static int glk_emmc_probe_slot(struct sdhci_pci_slot *slot) · 306 unmodified lines
958 slot->host->mmc->caps2 |= MMC_CAP2_CQE;975 slot->host->mmc->caps2 |= MMC_CAP2_CQE;
959 976
960 if (slot->chip->pdev->device != PCI_DEVICE_ID_INTEL_GLK_EMMC) {977 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;
962 slot->host->mmc_host_ops.hs400_enhanced_strobe =979 slot->host->mmc_host_ops.hs400_enhanced_strobe =
963 intel_hs400_enhanced_strobe;980 intel_hs400_enhanced_strobe;
964 slot->host->mmc->caps2 |= MMC_CAP2_CQE_DCMD;981 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
1135 return 0;1152 return 0;
1136}1153}
1137 1154
1155static 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
1138static int byt_sd_probe_slot(struct sdhci_pci_slot *slot)1163static int byt_sd_probe_slot(struct sdhci_pci_slot *slot)
1139{1164{
1140 byt_probe_slot(slot);1165 byt_probe_slot(slot);
@@ -1152,6 +1177,8 @@ static int byt_sd_probe_slot(struct sdhci_pci_slot *slot) · 11 unmodified lines
1152 slot->chip->pdev->subsystem_device == PCI_SUBDEVICE_ID_NI_78E3)1177 slot->chip->pdev->subsystem_device == PCI_SUBDEVICE_ID_NI_78E3)
1153 slot->host->mmc->caps2 |= MMC_CAP2_AVOID_3_3V;1178 slot->host->mmc->caps2 |= MMC_CAP2_AVOID_3_3V;
1154 1179
1180 byt_needs_pwr_off(slot);
1181
1155 return 0;1182 return 0;
1156}1183}
1157 1184
@@ -1903,6 +1930,8 @@ static const struct pci_device_id pci_ids[] = { · 745 unmodified lines
1903 SDHCI_PCI_DEVICE(INTEL, CMLH_SD, intel_byt_sd),1930 SDHCI_PCI_DEVICE(INTEL, CMLH_SD, intel_byt_sd),
1904 SDHCI_PCI_DEVICE(INTEL, JSL_EMMC, intel_glk_emmc),1931 SDHCI_PCI_DEVICE(INTEL, JSL_EMMC, intel_glk_emmc),
1905 SDHCI_PCI_DEVICE(INTEL, JSL_SD, intel_byt_sd),1932 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),
1906 SDHCI_PCI_DEVICE(O2, 8120, o2),1935 SDHCI_PCI_DEVICE(O2, 8120, o2),
1907 SDHCI_PCI_DEVICE(O2, 8220, o2),1936 SDHCI_PCI_DEVICE(O2, 8220, o2),
1908 SDHCI_PCI_DEVICE(O2, 8221, o2),1937 SDHCI_PCI_DEVICE(O2, 8221, o2),
drivers/mmc/host/sdhci-pci-gli.c+43−3
@@ -22,6 +22,10 @@ · 21 unmodified lines
22#define GLI_9750_WT_EN_ON 0x122#define GLI_9750_WT_EN_ON 0x1
23#define GLI_9750_WT_EN_OFF 0x023#define GLI_9750_WT_EN_OFF 0x0
24 24
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
25#define SDHCI_GLI_9750_DRIVING 0x86029#define SDHCI_GLI_9750_DRIVING 0x860
26#define SDHCI_GLI_9750_DRIVING_1 GENMASK(11, 0)30#define SDHCI_GLI_9750_DRIVING_1 GENMASK(11, 0)
27#define SDHCI_GLI_9750_DRIVING_2 GENMASK(27, 26)31#define SDHCI_GLI_9750_DRIVING_2 GENMASK(27, 26)
@@ -90,7 +94,7 @@ · 62 unmodified lines
90 94
91#define PCIE_GLI_9763E_CFG2 0x8A495#define PCIE_GLI_9763E_CFG2 0x8A4
92#define GLI_9763E_CFG2_L1DLY GENMASK(28, 19)96#define GLI_9763E_CFG2_L1DLY GENMASK(28, 19)
93#define GLI_9763E_CFG2_L1DLY_MAX 0x3FF97#define GLI_9763E_CFG2_L1DLY_MID 0x50
94 98
95#define PCIE_GLI_9763E_MMC_CTRL 0x96099#define PCIE_GLI_9763E_MMC_CTRL 0x960
96#define GLI_9763E_HS400_SLOW BIT(3)100#define GLI_9763E_HS400_SLOW BIT(3)
@@ -113,6 +117,10 @@ · 16 unmodified lines
113#define PCI_GLI_9755_LFCLK GENMASK(14, 12)117#define PCI_GLI_9755_LFCLK GENMASK(14, 12)
114#define PCI_GLI_9755_DMACLK BIT(29)118#define PCI_GLI_9755_DMACLK BIT(29)
115 119
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
116#define PCI_GLI_9755_PLL 0x64124#define PCI_GLI_9755_PLL 0x64
117#define PCI_GLI_9755_PLL_LDIV GENMASK(9, 0)125#define PCI_GLI_9755_PLL_LDIV GENMASK(9, 0)
118#define PCI_GLI_9755_PLL_PDIV GENMASK(14, 12)126#define PCI_GLI_9755_PLL_PDIV GENMASK(14, 12)
@@ -123,6 +131,9 @@ · 4 unmodified lines
123#define PCI_GLI_9755_PLLSSC 0x68131#define PCI_GLI_9755_PLLSSC 0x68
124#define PCI_GLI_9755_PLLSSC_PPM GENMASK(15, 0)132#define PCI_GLI_9755_PLLSSC_PPM GENMASK(15, 0)
125 133
134#define PCI_GLI_9755_SerDes 0x70
135#define PCI_GLI_9755_SCP_DIS BIT(19)
136
126#define GLI_MAX_TUNING_LOOP 40137#define GLI_MAX_TUNING_LOOP 40
127 138
128/* Genesys Logic chipset */139/* Genesys Logic chipset */
@@ -405,6 +416,22 @@ static void sdhci_gl9750_set_clock(struct sdhci_host *host, unsigned int clock) · 276 unmodified lines
405 sdhci_enable_clk(host, clk);416 sdhci_enable_clk(host, clk);
406}417}
407 418
419static 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
408static void gli_pcie_enable_msi(struct sdhci_pci_slot *slot)435static void gli_pcie_enable_msi(struct sdhci_pci_slot *slot)
409{436{
410 int ret;437 int ret;
@@ -547,6 +574,18 @@ static void gl9755_hw_setting(struct sdhci_pci_slot *slot) · 136 unmodified lines
547 value &= ~PCI_GLI_9755_DMACLK;574 value &= ~PCI_GLI_9755_DMACLK;
548 pci_write_config_dword(pdev, PCI_GLI_9755_PECONF, value);575 pci_write_config_dword(pdev, PCI_GLI_9755_PECONF, value);
549 576
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
550 gl9755_wt_off(pdev);589 gl9755_wt_off(pdev);
551}590}
552 591
@@ -554,6 +593,7 @@ static int gli_probe_slot_gl9750(struct sdhci_pci_slot *slot) · 1 unmodified line
554{593{
555 struct sdhci_host *host = slot->host;594 struct sdhci_host *host = slot->host;
556 595
596 gl9750_hw_setting(host);
557 gli_pcie_enable_msi(slot);597 gli_pcie_enable_msi(slot);
558 slot->host->mmc->caps2 |= MMC_CAP2_NO_SDIO;598 slot->host->mmc->caps2 |= MMC_CAP2_NO_SDIO;
559 sdhci_enable_v4_mode(host);599 sdhci_enable_v4_mode(host);
@@ -802,8 +842,8 @@ static void gli_set_gl9763e(struct sdhci_pci_slot *slot) · 242 unmodified lines
802 842
803 pci_read_config_dword(pdev, PCIE_GLI_9763E_CFG2, &value);843 pci_read_config_dword(pdev, PCIE_GLI_9763E_CFG2, &value);
804 value &= ~GLI_9763E_CFG2_L1DLY;844 value &= ~GLI_9763E_CFG2_L1DLY;
805 /* set ASPM L1 entry delay to 260us */845 /* set ASPM L1 entry delay to 20us */
806 value |= FIELD_PREP(GLI_9763E_CFG2_L1DLY, GLI_9763E_CFG2_L1DLY_MAX);846 value |= FIELD_PREP(GLI_9763E_CFG2_L1DLY, GLI_9763E_CFG2_L1DLY_MID);
807 pci_write_config_dword(pdev, PCIE_GLI_9763E_CFG2, value);847 pci_write_config_dword(pdev, PCIE_GLI_9763E_CFG2, value);
808 848
809 pci_read_config_dword(pdev, PCIE_GLI_9763E_CLKRXDLY, &value);849 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
706 ret = pci_read_config_dword(chip->pdev,706 ret = pci_read_config_dword(chip->pdev,
707 O2_SD_FUNC_REG0,707 O2_SD_FUNC_REG0,
708 &scratch_32);708 &scratch_32);
709 if (ret)
710 return ret;
709 scratch_32 = ((scratch_32 & 0xFF000000) >> 24);711 scratch_32 = ((scratch_32 & 0xFF000000) >> 24);
710 712
711 /* Check Whether subId is 0x11 or 0x12 */713 /* 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
716 ret = pci_read_config_dword(chip->pdev,718 ret = pci_read_config_dword(chip->pdev,
717 O2_SD_FUNC_REG4,719 O2_SD_FUNC_REG4,
718 &scratch_32);720 &scratch_32);
721 if (ret)
722 return ret;
719 723
720 /* Enable Base Clk setting change */724 /* Enable Base Clk setting change */
721 scratch_32 |= O2_SD_FREG4_ENABLE_CLK_SET;725 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
795 799
796 ret = pci_read_config_dword(chip->pdev,800 ret = pci_read_config_dword(chip->pdev,
797 O2_SD_PLL_SETTING, &scratch_32);801 O2_SD_PLL_SETTING, &scratch_32);
802 if (ret)
803 return ret;
798 804
799 if ((scratch_32 & 0xff000000) == 0x01000000) {805 if ((scratch_32 & 0xff000000) == 0x01000000) {
800 scratch_32 &= 0x0000FFFF;806 scratch_32 &= 0x0000FFFF;
@@ -812,6 +818,8 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) · 11 unmodified lines
812 ret = pci_read_config_dword(chip->pdev,818 ret = pci_read_config_dword(chip->pdev,
813 O2_SD_FUNC_REG4,819 O2_SD_FUNC_REG4,
814 &scratch_32);820 &scratch_32);
821 if (ret)
822 return ret;
815 scratch_32 |= (1 << 22);823 scratch_32 |= (1 << 22);
816 pci_write_config_dword(chip->pdev,824 pci_write_config_dword(chip->pdev,
817 O2_SD_FUNC_REG4, scratch_32);825 O2_SD_FUNC_REG4, scratch_32);
drivers/mmc/host/sdhci-pci.h+2−0
@@ -57,6 +57,8 @@ · 56 unmodified lines
57#define PCI_DEVICE_ID_INTEL_CMLH_SD 0x06f557#define PCI_DEVICE_ID_INTEL_CMLH_SD 0x06f5
58#define PCI_DEVICE_ID_INTEL_JSL_EMMC 0x4dc458#define PCI_DEVICE_ID_INTEL_JSL_EMMC 0x4dc4
59#define PCI_DEVICE_ID_INTEL_JSL_SD 0x4df859#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
60 62
61#define PCI_DEVICE_ID_SYSKONNECT_8000 0x800063#define PCI_DEVICE_ID_SYSKONNECT_8000 0x8000
62#define PCI_DEVICE_ID_VIA_95D0 0x95d064#define PCI_DEVICE_ID_VIA_95D0 0x95d0
drivers/mmc/host/sdhci-s3c.c+8−14
@@ -20,6 +20,7 @@ · 19 unmodified lines
20#include <linux/gpio.h>20#include <linux/gpio.h>
21#include <linux/module.h>21#include <linux/module.h>
22#include <linux/of.h>22#include <linux/of.h>
23#include <linux/of_device.h>
23#include <linux/of_gpio.h>24#include <linux/of_gpio.h>
24#include <linux/pm.h>25#include <linux/pm.h>
25#include <linux/pm_runtime.h>26#include <linux/pm_runtime.h>
@@ -129,7 +130,7 @@ struct sdhci_s3c { · 103 unmodified lines
129};130};
130 131
131/**132/**
132 * struct sdhci_s3c_driver_data - S3C SDHCI platform specific driver data133 * struct sdhci_s3c_drv_data - S3C SDHCI platform specific driver data
133 * @sdhci_quirks: sdhci host specific quirks.134 * @sdhci_quirks: sdhci host specific quirks.
134 * @no_divider: no or non-standard internal clock divider.135 * @no_divider: no or non-standard internal clock divider.
135 *136 *
@@ -461,28 +462,21 @@ static int sdhci_s3c_parse_dt(struct device *dev, · 325 unmodified lines
461}462}
462#endif463#endif
463 464
464#ifdef CONFIG_OF465static inline const struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data(
465static const struct of_device_id sdhci_s3c_dt_match[];
466#endif
467
468static inline struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data(
469 struct platform_device *pdev)466 struct platform_device *pdev)
470{467{
471#ifdef CONFIG_OF468#ifdef CONFIG_OF
472 if (pdev->dev.of_node) {469 if (pdev->dev.of_node)
473 const struct of_device_id *match;470 return of_device_get_match_data(&pdev->dev);
474 match = of_match_node(sdhci_s3c_dt_match, pdev->dev.of_node);
475 return (struct sdhci_s3c_drv_data *)match->data;
476 }
477#endif471#endif
478 return (struct sdhci_s3c_drv_data *)472 return (const struct sdhci_s3c_drv_data *)
479 platform_get_device_id(pdev)->driver_data;473 platform_get_device_id(pdev)->driver_data;
480}474}
481 475
482static int sdhci_s3c_probe(struct platform_device *pdev)476static int sdhci_s3c_probe(struct platform_device *pdev)
483{477{
484 struct s3c_sdhci_platdata *pdata;478 struct s3c_sdhci_platdata *pdata;
485 struct sdhci_s3c_drv_data *drv_data;479 const struct sdhci_s3c_drv_data *drv_data;
486 struct device *dev = &pdev->dev;480 struct device *dev = &pdev->dev;
487 struct sdhci_host *host;481 struct sdhci_host *host;
488 struct sdhci_s3c *sc;482 struct sdhci_s3c *sc;
@@ -767,7 +761,7 @@ static const struct platform_device_id sdhci_s3c_driver_ids[] = { · 278 unmodified lines
767MODULE_DEVICE_TABLE(platform, sdhci_s3c_driver_ids);761MODULE_DEVICE_TABLE(platform, sdhci_s3c_driver_ids);
768 762
769#ifdef CONFIG_OF763#ifdef CONFIG_OF
770static struct sdhci_s3c_drv_data exynos4_sdhci_drv_data = {764static const struct sdhci_s3c_drv_data exynos4_sdhci_drv_data = {
771 .no_divider = true,765 .no_divider = true,
772};766};
773 767
drivers/mmc/host/sdhci-st.c+8−15
@@ -362,11 +362,10 @@ static int sdhci_st_probe(struct platform_device *pdev) · 361 unmodified lines
362 if (IS_ERR(icnclk))362 if (IS_ERR(icnclk))
363 icnclk = NULL;363 icnclk = NULL;
364 364
365 rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);365 rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
366 if (IS_ERR(rstc))366 if (IS_ERR(rstc))
367 rstc = NULL;367 return PTR_ERR(rstc);
368 else368 reset_control_deassert(rstc);
369 reset_control_deassert(rstc);
370 369
371 host = sdhci_pltfm_init(pdev, &sdhci_st_pdata, sizeof(*pdata));370 host = sdhci_pltfm_init(pdev, &sdhci_st_pdata, sizeof(*pdata));
372 if (IS_ERR(host)) {371 if (IS_ERR(host)) {
@@ -401,10 +400,8 @@ static int sdhci_st_probe(struct platform_device *pdev) · 28 unmodified lines
401 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,400 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
402 "top-mmc-delay");401 "top-mmc-delay");
403 pdata->top_ioaddr = devm_ioremap_resource(&pdev->dev, res);402 pdata->top_ioaddr = devm_ioremap_resource(&pdev->dev, res);
404 if (IS_ERR(pdata->top_ioaddr)) {403 if (IS_ERR(pdata->top_ioaddr))
405 dev_warn(&pdev->dev, "FlashSS Top Dly registers not available");
406 pdata->top_ioaddr = NULL;404 pdata->top_ioaddr = NULL;
407 }
408 405
409 pltfm_host->clk = clk;406 pltfm_host->clk = clk;
410 pdata->icnclk = icnclk;407 pdata->icnclk = icnclk;
@@ -432,8 +429,7 @@ err_icnclk: · 21 unmodified lines
432err_of:429err_of:
433 sdhci_pltfm_free(pdev);430 sdhci_pltfm_free(pdev);
434err_pltfm_init:431err_pltfm_init:
435 if (rstc)432 reset_control_assert(rstc);
436 reset_control_assert(rstc);
437 433
438 return ret;434 return ret;
439}435}
@@ -450,8 +446,7 @@ static int sdhci_st_remove(struct platform_device *pdev) · 10 unmodified lines
450 446
451 clk_disable_unprepare(pdata->icnclk);447 clk_disable_unprepare(pdata->icnclk);
452 448
453 if (rstc)449 reset_control_assert(rstc);
454 reset_control_assert(rstc);
455 450
456 return ret;451 return ret;
457}452}
@@ -471,8 +466,7 @@ static int sdhci_st_suspend(struct device *dev) · 13 unmodified lines
471 if (ret)466 if (ret)
472 goto out;467 goto out;
473 468
474 if (pdata->rstc)469 reset_control_assert(pdata->rstc);
475 reset_control_assert(pdata->rstc);
476 470
477 clk_disable_unprepare(pdata->icnclk);471 clk_disable_unprepare(pdata->icnclk);
478 clk_disable_unprepare(pltfm_host->clk);472 clk_disable_unprepare(pltfm_host->clk);
@@ -498,8 +492,7 @@ static int sdhci_st_resume(struct device *dev) · 19 unmodified lines
498 return ret;492 return ret;
499 }493 }
500 494
501 if (pdata->rstc)495 reset_control_deassert(pdata->rstc);
502 reset_control_deassert(pdata->rstc);
503 496
504 st_mmcss_cconfig(np, host);497 st_mmcss_cconfig(np, host);
505 498
drivers/mmc/host/sdhci-tegra.c+49−17
@@ -119,6 +119,10 @@ · 118 unmodified lines
119/* SDMMC CQE Base Address for Tegra Host Ver 4.1 and Higher */119/* SDMMC CQE Base Address for Tegra Host Ver 4.1 and Higher */
120#define SDHCI_TEGRA_CQE_BASE_ADDR 0xF000120#define SDHCI_TEGRA_CQE_BASE_ADDR 0xF000
121 121
122#define SDHCI_TEGRA_CQE_TRNS_MODE (SDHCI_TRNS_MULTI | \
123 SDHCI_TRNS_BLK_CNT_EN | \
124 SDHCI_TRNS_DMA)
125
122struct sdhci_tegra_soc_data {126struct sdhci_tegra_soc_data {
123 const struct sdhci_pltfm_data *pdata;127 const struct sdhci_pltfm_data *pdata;
124 u64 dma_mask;128 u64 dma_mask;
@@ -596,49 +600,49 @@ static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host *host) · 471 unmodified lines
596 &tegra_host->autocal_offsets;600 &tegra_host->autocal_offsets;
597 int err;601 int err;
598 602
599 err = device_property_read_u32(host->mmc->parent,603 err = device_property_read_u32(mmc_dev(host->mmc),
600 "nvidia,pad-autocal-pull-up-offset-3v3",604 "nvidia,pad-autocal-pull-up-offset-3v3",
601 &autocal->pull_up_3v3);605 &autocal->pull_up_3v3);
602 if (err)606 if (err)
603 autocal->pull_up_3v3 = 0;607 autocal->pull_up_3v3 = 0;
604 608
605 err = device_property_read_u32(host->mmc->parent,609 err = device_property_read_u32(mmc_dev(host->mmc),
606 "nvidia,pad-autocal-pull-down-offset-3v3",610 "nvidia,pad-autocal-pull-down-offset-3v3",
607 &autocal->pull_down_3v3);611 &autocal->pull_down_3v3);
608 if (err)612 if (err)
609 autocal->pull_down_3v3 = 0;613 autocal->pull_down_3v3 = 0;
610 614
611 err = device_property_read_u32(host->mmc->parent,615 err = device_property_read_u32(mmc_dev(host->mmc),
612 "nvidia,pad-autocal-pull-up-offset-1v8",616 "nvidia,pad-autocal-pull-up-offset-1v8",
613 &autocal->pull_up_1v8);617 &autocal->pull_up_1v8);
614 if (err)618 if (err)
615 autocal->pull_up_1v8 = 0;619 autocal->pull_up_1v8 = 0;
616 620
617 err = device_property_read_u32(host->mmc->parent,621 err = device_property_read_u32(mmc_dev(host->mmc),
618 "nvidia,pad-autocal-pull-down-offset-1v8",622 "nvidia,pad-autocal-pull-down-offset-1v8",
619 &autocal->pull_down_1v8);623 &autocal->pull_down_1v8);
620 if (err)624 if (err)
621 autocal->pull_down_1v8 = 0;625 autocal->pull_down_1v8 = 0;
622 626
623 err = device_property_read_u32(host->mmc->parent,627 err = device_property_read_u32(mmc_dev(host->mmc),
624 "nvidia,pad-autocal-pull-up-offset-sdr104",628 "nvidia,pad-autocal-pull-up-offset-sdr104",
625 &autocal->pull_up_sdr104);629 &autocal->pull_up_sdr104);
626 if (err)630 if (err)
627 autocal->pull_up_sdr104 = autocal->pull_up_1v8;631 autocal->pull_up_sdr104 = autocal->pull_up_1v8;
628 632
629 err = device_property_read_u32(host->mmc->parent,633 err = device_property_read_u32(mmc_dev(host->mmc),
630 "nvidia,pad-autocal-pull-down-offset-sdr104",634 "nvidia,pad-autocal-pull-down-offset-sdr104",
631 &autocal->pull_down_sdr104);635 &autocal->pull_down_sdr104);
632 if (err)636 if (err)
633 autocal->pull_down_sdr104 = autocal->pull_down_1v8;637 autocal->pull_down_sdr104 = autocal->pull_down_1v8;
634 638
635 err = device_property_read_u32(host->mmc->parent,639 err = device_property_read_u32(mmc_dev(host->mmc),
636 "nvidia,pad-autocal-pull-up-offset-hs400",640 "nvidia,pad-autocal-pull-up-offset-hs400",
637 &autocal->pull_up_hs400);641 &autocal->pull_up_hs400);
638 if (err)642 if (err)
639 autocal->pull_up_hs400 = autocal->pull_up_1v8;643 autocal->pull_up_hs400 = autocal->pull_up_1v8;
640 644
641 err = device_property_read_u32(host->mmc->parent,645 err = device_property_read_u32(mmc_dev(host->mmc),
642 "nvidia,pad-autocal-pull-down-offset-hs400",646 "nvidia,pad-autocal-pull-down-offset-hs400",
643 &autocal->pull_down_hs400);647 &autocal->pull_down_hs400);
644 if (err)648 if (err)
@@ -653,7 +657,7 @@ static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host *host) · 8 unmodified lines
653 if (!(tegra_host->soc_data->nvquirks & NVQUIRK_NEEDS_PAD_CONTROL))657 if (!(tegra_host->soc_data->nvquirks & NVQUIRK_NEEDS_PAD_CONTROL))
654 return;658 return;
655 659
656 err = device_property_read_u32(host->mmc->parent,660 err = device_property_read_u32(mmc_dev(host->mmc),
657 "nvidia,pad-autocal-pull-up-offset-3v3-timeout",661 "nvidia,pad-autocal-pull-up-offset-3v3-timeout",
658 &autocal->pull_up_3v3_timeout);662 &autocal->pull_up_3v3_timeout);
659 if (err) {663 if (err) {
@@ -664,7 +668,7 @@ static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host *host) · 4 unmodified lines
664 autocal->pull_up_3v3_timeout = 0;668 autocal->pull_up_3v3_timeout = 0;
665 }669 }
666 670
667 err = device_property_read_u32(host->mmc->parent,671 err = device_property_read_u32(mmc_dev(host->mmc),
668 "nvidia,pad-autocal-pull-down-offset-3v3-timeout",672 "nvidia,pad-autocal-pull-down-offset-3v3-timeout",
669 &autocal->pull_down_3v3_timeout);673 &autocal->pull_down_3v3_timeout);
670 if (err) {674 if (err) {
@@ -675,7 +679,7 @@ static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host *host) · 4 unmodified lines
675 autocal->pull_down_3v3_timeout = 0;679 autocal->pull_down_3v3_timeout = 0;
676 }680 }
677 681
678 err = device_property_read_u32(host->mmc->parent,682 err = device_property_read_u32(mmc_dev(host->mmc),
679 "nvidia,pad-autocal-pull-up-offset-1v8-timeout",683 "nvidia,pad-autocal-pull-up-offset-1v8-timeout",
680 &autocal->pull_up_1v8_timeout);684 &autocal->pull_up_1v8_timeout);
681 if (err) {685 if (err) {
@@ -686,7 +690,7 @@ static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host *host) · 4 unmodified lines
686 autocal->pull_up_1v8_timeout = 0;690 autocal->pull_up_1v8_timeout = 0;
687 }691 }
688 692
689 err = device_property_read_u32(host->mmc->parent,693 err = device_property_read_u32(mmc_dev(host->mmc),
690 "nvidia,pad-autocal-pull-down-offset-1v8-timeout",694 "nvidia,pad-autocal-pull-down-offset-1v8-timeout",
691 &autocal->pull_down_1v8_timeout);695 &autocal->pull_down_1v8_timeout);
692 if (err) {696 if (err) {
@@ -720,17 +724,17 @@ static void tegra_sdhci_parse_tap_and_trim(struct sdhci_host *host) · 27 unmodified lines
720 struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host);724 struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host);
721 int err;725 int err;
722 726
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",
724 &tegra_host->default_tap);728 &tegra_host->default_tap);
725 if (err)729 if (err)
726 tegra_host->default_tap = 0;730 tegra_host->default_tap = 0;
727 731
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",
729 &tegra_host->default_trim);733 &tegra_host->default_trim);
730 if (err)734 if (err)
731 tegra_host->default_trim = 0;735 tegra_host->default_trim = 0;
732 736
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",
734 &tegra_host->dqs_trim);738 &tegra_host->dqs_trim);
735 if (err)739 if (err)
736 tegra_host->dqs_trim = 0x11;740 tegra_host->dqs_trim = 0x11;
@@ -741,7 +745,7 @@ static void tegra_sdhci_parse_dt(struct sdhci_host *host) · 4 unmodified lines
741 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);745 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
742 struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host);746 struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host);
743 747
744 if (device_property_read_bool(host->mmc->parent, "supports-cqe"))748 if (device_property_read_bool(mmc_dev(host->mmc), "supports-cqe"))
745 tegra_host->enable_hwcq = true;749 tegra_host->enable_hwcq = true;
746 else750 else
747 tegra_host->enable_hwcq = false;751 tegra_host->enable_hwcq = false;
@@ -1156,6 +1160,7 @@ static void tegra_sdhci_voltage_switch(struct sdhci_host *host) · 408 unmodified lines
1156static void tegra_cqhci_writel(struct cqhci_host *cq_host, u32 val, int reg)1160static void tegra_cqhci_writel(struct cqhci_host *cq_host, u32 val, int reg)
1157{1161{
1158 struct mmc_host *mmc = cq_host->mmc;1162 struct mmc_host *mmc = cq_host->mmc;
1163 struct sdhci_host *host = mmc_priv(mmc);
1159 u8 ctrl;1164 u8 ctrl;
1160 ktime_t timeout;1165 ktime_t timeout;
1161 bool timed_out;1166 bool timed_out;
@@ -1170,6 +1175,7 @@ static void tegra_cqhci_writel(struct cqhci_host *cq_host, u32 val, int reg) · 8 unmodified lines
1170 */1175 */
1171 if (reg == CQHCI_CTL && !(val & CQHCI_HALT) &&1176 if (reg == CQHCI_CTL && !(val & CQHCI_HALT) &&
1172 cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT) {1177 cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT) {
1178 sdhci_writew(host, SDHCI_TEGRA_CQE_TRNS_MODE, SDHCI_TRANSFER_MODE);
1173 sdhci_cqe_enable(mmc);1179 sdhci_cqe_enable(mmc);
1174 writel(val, cq_host->mmio + reg);1180 writel(val, cq_host->mmio + reg);
1175 timeout = ktime_add_us(ktime_get(), 50);1181 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
1205static void sdhci_tegra_cqe_enable(struct mmc_host *mmc)1211static void sdhci_tegra_cqe_enable(struct mmc_host *mmc)
1206{1212{
1207 struct cqhci_host *cq_host = mmc->cqe_private;1213 struct cqhci_host *cq_host = mmc->cqe_private;
1214 struct sdhci_host *host = mmc_priv(mmc);
1208 u32 val;1215 u32 val;
1209 1216
1210 /*1217 /*
@@ -1218,6 +1225,7 @@ static void sdhci_tegra_cqe_enable(struct mmc_host *mmc) · 7 unmodified lines
1218 if (val & CQHCI_ENABLE)1225 if (val & CQHCI_ENABLE)
1219 cqhci_writel(cq_host, (val & ~CQHCI_ENABLE),1226 cqhci_writel(cq_host, (val & ~CQHCI_ENABLE),
1220 CQHCI_CFG);1227 CQHCI_CFG);
1228 sdhci_writew(host, SDHCI_TEGRA_CQE_TRNS_MODE, SDHCI_TRANSFER_MODE);
1221 sdhci_cqe_enable(mmc);1229 sdhci_cqe_enable(mmc);
1222 if (val & CQHCI_ENABLE)1230 if (val & CQHCI_ENABLE)
1223 cqhci_writel(cq_host, val, CQHCI_CFG);1231 cqhci_writel(cq_host, val, CQHCI_CFG);
@@ -1281,12 +1289,36 @@ static void tegra_sdhci_set_timeout(struct sdhci_host *host, · 57 unmodified lines
1281 __sdhci_set_timeout(host, cmd);1289 __sdhci_set_timeout(host, cmd);
1282}1290}
1283 1291
1292static 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
1302static 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
1284static const struct cqhci_host_ops sdhci_tegra_cqhci_ops = {1314static const struct cqhci_host_ops sdhci_tegra_cqhci_ops = {
1285 .write_l = tegra_cqhci_writel,1315 .write_l = tegra_cqhci_writel,
1286 .enable = sdhci_tegra_cqe_enable,1316 .enable = sdhci_tegra_cqe_enable,
1287 .disable = sdhci_cqe_disable,1317 .disable = sdhci_cqe_disable,
1288 .dumpregs = sdhci_tegra_dumpregs,1318 .dumpregs = sdhci_tegra_dumpregs,
1289 .update_dcmd_desc = sdhci_tegra_update_dcmd_desc,1319 .update_dcmd_desc = sdhci_tegra_update_dcmd_desc,
1320 .pre_enable = sdhci_tegra_cqe_pre_enable,
1321 .post_disable = sdhci_tegra_cqe_post_disable,
1290};1322};
1291 1323
1292static int tegra_sdhci_set_dma_mask(struct sdhci_host *host)1324static 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
1529 1561
1530 host->mmc->caps2 |= MMC_CAP2_CQE | MMC_CAP2_CQE_DCMD;1562 host->mmc->caps2 |= MMC_CAP2_CQE | MMC_CAP2_CQE_DCMD;
1531 1563
1532 cq_host = devm_kzalloc(host->mmc->parent,1564 cq_host = devm_kzalloc(mmc_dev(host->mmc),
1533 sizeof(*cq_host), GFP_KERNEL);1565 sizeof(*cq_host), GFP_KERNEL);
1534 if (!cq_host) {1566 if (!cq_host) {
1535 ret = -ENOMEM;1567 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
188 if (host->bus_on)188 if (host->bus_on)
189 return;189 return;
190 host->bus_on = true;190 host->bus_on = true;
191 pm_runtime_get_noresume(host->mmc->parent);191 pm_runtime_get_noresume(mmc_dev(host->mmc));
192}192}
193 193
194static void sdhci_runtime_pm_bus_off(struct sdhci_host *host)194static 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
196 if (!host->bus_on)196 if (!host->bus_on)
197 return;197 return;
198 host->bus_on = false;198 host->bus_on = false;
199 pm_runtime_put_noidle(host->mmc->parent);199 pm_runtime_put_noidle(mmc_dev(host->mmc));
200}200}
201 201
202void sdhci_reset(struct sdhci_host *host, u8 mask)202void 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
648 }648 }
649 }649 }
650 /* Switch ownership to the DMA */650 /* Switch ownership to the DMA */
651 dma_sync_single_for_device(host->mmc->parent,651 dma_sync_single_for_device(mmc_dev(host->mmc),
652 host->bounce_addr,652 host->bounce_addr,
653 host->bounce_buffer_size,653 host->bounce_buffer_size,
654 mmc_get_dma_dir(data));654 mmc_get_dma_dir(data));
@@ -907,7 +907,7 @@ static void sdhci_calc_sw_timeout(struct sdhci_host *host, · 252 unmodified lines
907 907
908 if (data) {908 if (data) {
909 blksz = data->blksz;909 blksz = data->blksz;
910 freq = host->mmc->actual_clock ? : host->clock;910 freq = mmc->actual_clock ? : host->clock;
911 transfer_time = (u64)blksz * NSEC_PER_SEC * (8 / bus_width);911 transfer_time = (u64)blksz * NSEC_PER_SEC * (8 / bus_width);
912 do_div(transfer_time, freq);912 do_div(transfer_time, freq);
913 /* multiply by '2' to account for any unknowns */913 /* 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
1176 int ret = 0;1176 int ret = 0;
1177 struct mmc_host *mmc = host->mmc;1177 struct mmc_host *mmc = host->mmc;
1178 1178
1179 host->tx_chan = dma_request_chan(mmc->parent, "tx");1179 host->tx_chan = dma_request_chan(mmc_dev(mmc), "tx");
1180 if (IS_ERR(host->tx_chan)) {1180 if (IS_ERR(host->tx_chan)) {
1181 ret = PTR_ERR(host->tx_chan);1181 ret = PTR_ERR(host->tx_chan);
1182 if (ret != -EPROBE_DEFER)1182 if (ret != -EPROBE_DEFER)
@@ -1185,7 +1185,7 @@ static int sdhci_external_dma_init(struct sdhci_host *host) · 2 unmodified lines
1185 return ret;1185 return ret;
1186 }1186 }
1187 1187
1188 host->rx_chan = dma_request_chan(mmc->parent, "rx");1188 host->rx_chan = dma_request_chan(mmc_dev(mmc), "rx");
1189 if (IS_ERR(host->rx_chan)) {1189 if (IS_ERR(host->rx_chan)) {
1190 if (host->tx_chan) {1190 if (host->tx_chan) {
1191 dma_release_channel(host->tx_chan);1191 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
2269 2269
2270 if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK &&2270 if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK &&
2271 host->clock) {2271 host->clock) {
2272 host->timeout_clk = host->mmc->actual_clock ?2272 host->timeout_clk = mmc->actual_clock ?
2273 host->mmc->actual_clock / 1000 :2273 mmc->actual_clock / 1000 :
2274 host->clock / 1000;2274 host->clock / 1000;
2275 host->mmc->max_busy_timeout =2275 mmc->max_busy_timeout =
2276 host->ops->get_max_timeout_count ?2276 host->ops->get_max_timeout_count ?
2277 host->ops->get_max_timeout_count(host) :2277 host->ops->get_max_timeout_count(host) :
2278 1 << 27;2278 1 << 27;
2279 host->mmc->max_busy_timeout /= host->timeout_clk;2279 mmc->max_busy_timeout /= host->timeout_clk;
2280 }2280 }
2281 }2281 }
2282 2282
@@ -2399,7 +2399,7 @@ static int sdhci_get_cd(struct mmc_host *mmc) · 116 unmodified lines
2399 return 0;2399 return 0;
2400 2400
2401 /* If nonremovable, assume that the card is always present. */2401 /* If nonremovable, assume that the card is always present. */
2402 if (!mmc_card_is_removable(host->mmc))2402 if (!mmc_card_is_removable(mmc))
2403 return 1;2403 return 1;
2404 2404
2405 /*2405 /*
@@ -2489,14 +2489,14 @@ void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable) · 83 unmodified lines
2489 unsigned long flags;2489 unsigned long flags;
2490 2490
2491 if (enable)2491 if (enable)
2492 pm_runtime_get_noresume(host->mmc->parent);2492 pm_runtime_get_noresume(mmc_dev(mmc));
2493 2493
2494 spin_lock_irqsave(&host->lock, flags);2494 spin_lock_irqsave(&host->lock, flags);
2495 sdhci_enable_sdio_irq_nolock(host, enable);2495 sdhci_enable_sdio_irq_nolock(host, enable);
2496 spin_unlock_irqrestore(&host->lock, flags);2496 spin_unlock_irqrestore(&host->lock, flags);
2497 2497
2498 if (!enable)2498 if (!enable)
2499 pm_runtime_put_noidle(host->mmc->parent);2499 pm_runtime_put_noidle(mmc_dev(mmc));
2500}2500}
2501EXPORT_SYMBOL_GPL(sdhci_enable_sdio_irq);2501EXPORT_SYMBOL_GPL(sdhci_enable_sdio_irq);
2502 2502
@@ -2837,7 +2837,7 @@ int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) · 334 unmodified lines
2837 goto out;2837 goto out;
2838 }2838 }
2839 2839
2840 host->mmc->retune_period = tuning_count;2840 mmc->retune_period = tuning_count;
2841 2841
2842 if (host->tuning_delay < 0)2842 if (host->tuning_delay < 0)
2843 host->tuning_delay = opcode == MMC_SEND_TUNING_BLOCK;2843 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
2886static void sdhci_post_req(struct mmc_host *mmc, struct mmc_request *mrq,2886static void sdhci_post_req(struct mmc_host *mmc, struct mmc_request *mrq,
2887 int err)2887 int err)
2888{2888{
2889 struct sdhci_host *host = mmc_priv(mmc);
2890 struct mmc_data *data = mrq->data;2889 struct mmc_data *data = mrq->data;
2891 2890
2892 if (data->host_cookie != COOKIE_UNMAPPED)2891 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,
2894 mmc_get_dma_dir(data));2893 mmc_get_dma_dir(data));
2895 2894
2896 data->host_cookie = COOKIE_UNMAPPED;2895 data->host_cookie = COOKIE_UNMAPPED;
@@ -2941,9 +2940,9 @@ static void sdhci_card_event(struct mmc_host *mmc) · 44 unmodified lines
2941 /* Check sdhci_has_requests() first in case we are runtime suspended */2940 /* Check sdhci_has_requests() first in case we are runtime suspended */
2942 if (sdhci_has_requests(host) && !present) {2941 if (sdhci_has_requests(host) && !present) {
2943 pr_err("%s: Card removed during transfer!\n",2942 pr_err("%s: Card removed during transfer!\n",
2944 mmc_hostname(host->mmc));2943 mmc_hostname(mmc));
2945 pr_err("%s: Resetting controller.\n",2944 pr_err("%s: Resetting controller.\n",
2946 mmc_hostname(host->mmc));2945 mmc_hostname(mmc));
2947 2946
2948 sdhci_do_reset(host, SDHCI_RESET_CMD);2947 sdhci_do_reset(host, SDHCI_RESET_CMD);
2949 sdhci_do_reset(host, SDHCI_RESET_DATA);2948 sdhci_do_reset(host, SDHCI_RESET_DATA);
@@ -2996,6 +2995,37 @@ static bool sdhci_request_done(struct sdhci_host *host) · 46 unmodified lines
2996 return true;2995 return true;
2997 }2996 }
2998 2997
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
2999 /*3029 /*
3000 * Always unmap the data buffers if they were mapped by3030 * Always unmap the data buffers if they were mapped by
3001 * sdhci_prepare_data() whenever we finish with a request.3031 * 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
3033 length = host->bounce_buffer_size;3063 length = host->bounce_buffer_size;
3034 }3064 }
3035 dma_sync_single_for_cpu(3065 dma_sync_single_for_cpu(
3036 host->mmc->parent,3066 mmc_dev(host->mmc),
3037 host->bounce_addr,3067 host->bounce_addr,
3038 host->bounce_buffer_size,3068 host->bounce_buffer_size,
3039 DMA_FROM_DEVICE);3069 DMA_FROM_DEVICE);
@@ -3044,7 +3074,7 @@ static bool sdhci_request_done(struct sdhci_host *host) · 4 unmodified lines
3044 } else {3074 } else {
3045 /* No copying, just switch ownership */3075 /* No copying, just switch ownership */
3046 dma_sync_single_for_cpu(3076 dma_sync_single_for_cpu(
3047 host->mmc->parent,3077 mmc_dev(host->mmc),
3048 host->bounce_addr,3078 host->bounce_addr,
3049 host->bounce_buffer_size,3079 host->bounce_buffer_size,
3050 mmc_get_dma_dir(data));3080 mmc_get_dma_dir(data));
@@ -3059,35 +3089,6 @@ static bool sdhci_request_done(struct sdhci_host *host) · 8 unmodified lines
3059 }3089 }
3060 }3090 }
3061 3091
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
3091 host->mrqs_done[i] = NULL;3092 host->mrqs_done[i] = NULL;
3092 3093
3093 spin_unlock_irqrestore(&host->lock, flags);3094 spin_unlock_irqrestore(&host->lock, flags);
@@ -3675,7 +3676,7 @@ int sdhci_resume_host(struct sdhci_host *host) · 581 unmodified lines
3675 host->ops->enable_dma(host);3676 host->ops->enable_dma(host);
3676 }3677 }
3677 3678
3678 if ((host->mmc->pm_flags & MMC_PM_KEEP_POWER) &&3679 if ((mmc->pm_flags & MMC_PM_KEEP_POWER) &&
3679 (host->quirks2 & SDHCI_QUIRK2_HOST_OFF_CARD_ON)) {3680 (host->quirks2 & SDHCI_QUIRK2_HOST_OFF_CARD_ON)) {
3680 /* Card keeps power but host controller does not */3681 /* Card keeps power but host controller does not */
3681 sdhci_init(host, 0);3682 sdhci_init(host, 0);
@@ -3683,7 +3684,7 @@ int sdhci_resume_host(struct sdhci_host *host) · 1 unmodified line
3683 host->clock = 0;3684 host->clock = 0;
3684 mmc->ops->set_ios(mmc, &mmc->ios);3685 mmc->ops->set_ios(mmc, &mmc->ios);
3685 } else {3686 } else {
3686 sdhci_init(host, (host->mmc->pm_flags & MMC_PM_KEEP_POWER));3687 sdhci_init(host, (mmc->pm_flags & MMC_PM_KEEP_POWER));
3687 }3688 }
3688 3689
3689 if (host->irq_wake_enabled) {3690 if (host->irq_wake_enabled) {
@@ -3691,7 +3692,7 @@ int sdhci_resume_host(struct sdhci_host *host) · 1 unmodified line
3691 } else {3692 } else {
3692 ret = request_threaded_irq(host->irq, sdhci_irq,3693 ret = request_threaded_irq(host->irq, sdhci_irq,
3693 sdhci_thread_irq, IRQF_SHARED,3694 sdhci_thread_irq, IRQF_SHARED,
3694 mmc_hostname(host->mmc), host);3695 mmc_hostname(mmc), host);
3695 if (ret)3696 if (ret)
3696 return ret;3697 return ret;
3697 }3698 }
@@ -4052,7 +4053,7 @@ static void sdhci_allocate_bounce_buffer(struct sdhci_host *host) · 354 unmodified lines
4052 * speedups by the help of a bounce buffer to group scattered4053 * speedups by the help of a bounce buffer to group scattered
4053 * reads/writes together.4054 * reads/writes together.
4054 */4055 */
4055 host->bounce_buffer = devm_kmalloc(mmc->parent,4056 host->bounce_buffer = devm_kmalloc(mmc_dev(mmc),
4056 bounce_size,4057 bounce_size,
4057 GFP_KERNEL);4058 GFP_KERNEL);
4058 if (!host->bounce_buffer) {4059 if (!host->bounce_buffer) {
@@ -4066,11 +4067,11 @@ static void sdhci_allocate_bounce_buffer(struct sdhci_host *host) · 7 unmodified lines
4066 return;4067 return;
4067 }4068 }
4068 4069
4069 host->bounce_addr = dma_map_single(mmc->parent,4070 host->bounce_addr = dma_map_single(mmc_dev(mmc),
4070 host->bounce_buffer,4071 host->bounce_buffer,
4071 bounce_size,4072 bounce_size,
4072 DMA_BIDIRECTIONAL);4073 DMA_BIDIRECTIONAL);
4073 ret = dma_mapping_error(mmc->parent, host->bounce_addr);4074 ret = dma_mapping_error(mmc_dev(mmc), host->bounce_addr);
4074 if (ret)4075 if (ret)
4075 /* Again fall back to max_segs == 1 */4076 /* Again fall back to max_segs == 1 */
4076 return;4077 return;
@@ -4378,7 +4379,7 @@ int sdhci_setup_host(struct sdhci_host *host) · 301 unmodified lines
4378 4379
4379 if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) &&4380 if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) &&
4380 mmc_card_is_removable(mmc) &&4381 mmc_card_is_removable(mmc) &&
4381 mmc_gpio_get_cd(host->mmc) < 0)4382 mmc_gpio_get_cd(mmc) < 0)
4382 mmc->caps |= MMC_CAP_NEEDS_POLL;4383 mmc->caps |= MMC_CAP_NEEDS_POLL;
4383 4384
4384 if (!IS_ERR(mmc->supply.vqmmc)) {4385 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
558 struct cqhci_host *cq_host;558 struct cqhci_host *cq_host;
559 int ret;559 int ret;
560 560
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),
562 GFP_KERNEL);562 GFP_KERNEL);
563 if (!cq_host)563 if (!cq_host)
564 return -ENOMEM;564 return -ENOMEM;
drivers/mmc/host/tmio_mmc.h+2−1
@@ -100,8 +100,8 @@ · 99 unmodified lines
100 100
101/* Define some IRQ masks */101/* Define some IRQ masks */
102/* This is the mask used at reset by the chip */102/* This is the mask used at reset by the chip */
103#define TMIO_MASK_INIT_RCAR2 0x8b7f031d /* Initial value for R-Car Gen2+ */
104#define TMIO_MASK_ALL 0x837f031d103#define TMIO_MASK_ALL 0x837f031d
104#define TMIO_MASK_ALL_RCAR2 0x8b7f031d
105#define TMIO_MASK_READOP (TMIO_STAT_RXRDY | TMIO_STAT_DATAEND)105#define TMIO_MASK_READOP (TMIO_STAT_RXRDY | TMIO_STAT_DATAEND)
106#define TMIO_MASK_WRITEOP (TMIO_STAT_TXRQ | TMIO_STAT_DATAEND)106#define TMIO_MASK_WRITEOP (TMIO_STAT_TXRQ | TMIO_STAT_DATAEND)
107#define TMIO_MASK_CMD (TMIO_STAT_CMDRESPEND | TMIO_STAT_CMDTIMEOUT | \107#define TMIO_MASK_CMD (TMIO_STAT_CMDRESPEND | TMIO_STAT_CMDTIMEOUT | \
@@ -164,6 +164,7 @@ struct tmio_mmc_host { · 56 unmodified lines
164 u32 sdio_irq_mask;164 u32 sdio_irq_mask;
165 unsigned int clk_cache;165 unsigned int clk_cache;
166 u32 sdcard_irq_setbit_mask;166 u32 sdcard_irq_setbit_mask;
167 u32 sdcard_irq_mask_all;
167 168
168 spinlock_t lock; /* protect host private data */169 spinlock_t lock; /* protect host private data */
169 unsigned long last_req_ts;170 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
164 }164 }
165}165}
166 166
167static 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
167static void tmio_mmc_reset(struct tmio_mmc_host *host)182static void tmio_mmc_reset(struct tmio_mmc_host *host)
168{183{
169 /* FIXME - should we set stop clock reg here */184 /* 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
172 sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);187 sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);
173 usleep_range(10000, 11000);188 usleep_range(10000, 11000);
174 189
190 tmio_mmc_abort_dma(host);
191
175 if (host->reset)192 if (host->reset)
176 host->reset(host);193 host->reset(host);
177 194
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);
179 199
180 if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) {200 if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) {
181 sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);201 sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
182 sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001);202 sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001);
183 }203 }
204
205 if (host->mmc->card)
206 mmc_retune_needed(host->mmc);
184}207}
185 208
186static void tmio_mmc_reset_work(struct work_struct *work)209static 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
874 host->set_pwr(host->pdev, 0);897 host->set_pwr(host->pdev, 0);
875}898}
876 899
877static 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
892static unsigned int tmio_mmc_get_timeout_cycles(struct tmio_mmc_host *host)900static unsigned int tmio_mmc_get_timeout_cycles(struct tmio_mmc_host *host)
893{901{
894 u16 val = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT);902 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
1160 mmc->caps & MMC_CAP_NEEDS_POLL ||1168 mmc->caps & MMC_CAP_NEEDS_POLL ||
1161 !mmc_card_is_removable(mmc));1169 !mmc_card_is_removable(mmc));
1162 1170
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
1172 /*1171 /*
1173 * While using internal tmio hardware logic for card detection, we need1172 * While using internal tmio hardware logic for card detection, we need
1174 * to ensure it stays powered for it to work.1173 * 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
1180 if (pdata->flags & TMIO_MMC_SDIO_IRQ)1179 if (pdata->flags & TMIO_MMC_SDIO_IRQ)
1181 _host->sdio_irq_mask = TMIO_SDIO_MASK_ALL;1180 _host->sdio_irq_mask = TMIO_SDIO_MASK_ALL;
1182 1181
1182 if (!_host->sdcard_irq_mask_all)
1183 _host->sdcard_irq_mask_all = TMIO_MASK_ALL;
1184
1183 _host->set_clock(_host, 0);1185 _host->set_clock(_host, 0);
1184 tmio_mmc_reset(_host);1186 tmio_mmc_reset(_host);
1185 1187
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
1189 if (_host->native_hotplug)1188 if (_host->native_hotplug)
1190 tmio_mmc_enable_mmc_irqs(_host,1189 tmio_mmc_enable_mmc_irqs(_host,
1191 TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);1190 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
1238 cancel_work_sync(&host->done);1237 cancel_work_sync(&host->done);
1239 cancel_delayed_work_sync(&host->delayed_reset_work);1238 cancel_delayed_work_sync(&host->delayed_reset_work);
1240 tmio_mmc_release_dma(host);1239 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);
1242 1241
1243 if (host->native_hotplug)1242 if (host->native_hotplug)
1244 pm_runtime_put_noidle(&pdev->dev);1243 pm_runtime_put_noidle(&pdev->dev);
@@ -1268,7 +1267,7 @@ int tmio_mmc_host_runtime_suspend(struct device *dev) · 23 unmodified lines
1268{1267{
1269 struct tmio_mmc_host *host = dev_get_drvdata(dev);1268 struct tmio_mmc_host *host = dev_get_drvdata(dev);
1270 1269
1271 tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL);1270 tmio_mmc_disable_mmc_irqs(host, host->sdcard_irq_mask_all);
1272 1271
1273 if (host->clk_cache)1272 if (host->clk_cache)
1274 host->set_clock(host, 0);1273 host->set_clock(host, 0);
@@ -1295,8 +1294,6 @@ int tmio_mmc_host_runtime_resume(struct device *dev) · 20 unmodified lines
1295 1294
1296 tmio_mmc_enable_dma(host, true);1295 tmio_mmc_enable_dma(host, true);
1297 1296
1298 mmc_retune_needed(host->mmc);
1299
1300 return 0;1297 return 0;
1301}1298}
1302EXPORT_SYMBOL_GPL(tmio_mmc_host_runtime_resume);1299EXPORT_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
635 635
636 ret = tmio_mmc_host_probe(host);636 ret = tmio_mmc_host_probe(host);
637 if (ret)637 if (ret)
638 goto free_host;638 goto disable_clk;
639 639
640 ret = devm_request_irq(dev, irq, tmio_mmc_irq, IRQF_SHARED,640 ret = devm_request_irq(dev, irq, tmio_mmc_irq, IRQF_SHARED,
641 dev_name(dev), host);641 dev_name(dev), host);
@@ -646,6 +646,8 @@ static int uniphier_sd_probe(struct platform_device *pdev) · 4 unmodified lines
646 646
647remove_host:647remove_host:
648 tmio_mmc_host_remove(host);648 tmio_mmc_host_remove(host);
649disable_clk:
650 uniphier_sd_clk_disable(host);
649free_host:651free_host:
650 tmio_mmc_host_free(host);652 tmio_mmc_host_free(host);
651 653
@@ -658,6 +660,7 @@ static int uniphier_sd_remove(struct platform_device *pdev) · 6 unmodified lines
658 660
659 tmio_mmc_host_remove(host);661 tmio_mmc_host_remove(host);
660 uniphier_sd_clk_disable(host);662 uniphier_sd_clk_disable(host);
663 tmio_mmc_host_free(host);
661 664
662 return 0;665 return 0;
663}666}
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
1271static int __maybe_unused via_sd_resume(struct device *dev)1271static int __maybe_unused via_sd_resume(struct device *dev)
1272{1272{
1273 struct via_crdr_mmc_host *sdhost;1273 struct via_crdr_mmc_host *sdhost;
1274 int ret = 0;
1275 u8 gatt;1274 u8 gatt;
1276 1275
1277 sdhost = dev_get_drvdata(dev);1276 sdhost = dev_get_drvdata(dev);
@@ -1292,7 +1291,7 @@ static int __maybe_unused via_sd_resume(struct device *dev) · 14 unmodified lines
1292 via_restore_pcictrlreg(sdhost);1291 via_restore_pcictrlreg(sdhost);
1293 via_init_sdc_pm(sdhost);1292 via_init_sdc_pm(sdhost);
1294 1293
1295 return ret;1294 return 0;
1296}1295}
1297 1296
1298static SIMPLE_DEV_PM_OPS(via_sd_pm_ops, via_sd_suspend, via_sd_resume);1297static 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
302 u32 ocr_avail_sdio; /* SDIO-specific OCR */302 u32 ocr_avail_sdio; /* SDIO-specific OCR */
303 u32 ocr_avail_sd; /* SD-specific OCR */303 u32 ocr_avail_sd; /* SD-specific OCR */
304 u32 ocr_avail_mmc; /* MMC-specific OCR */304 u32 ocr_avail_mmc; /* MMC-specific OCR */
305#ifdef CONFIG_PM_SLEEP
306 struct notifier_block pm_notify;
307#endif
308 struct wakeup_source *ws; /* Enable consume of uevents */305 struct wakeup_source *ws; /* Enable consume of uevents */
309 u32 max_current_330;306 u32 max_current_330;
310 u32 max_current_300;307 u32 max_current_300;
@@ -423,7 +420,6 @@ struct mmc_host { · 112 unmodified lines
423 /* group bitfields together to minimize padding */420 /* group bitfields together to minimize padding */
424 unsigned int use_spi_crc:1;421 unsigned int use_spi_crc:1;
425 unsigned int claimed:1; /* host exclusively claimed */422 unsigned int claimed:1; /* host exclusively claimed */
426 unsigned int bus_dead:1; /* bus has been released */
427 unsigned int doing_init_tune:1; /* initial tuning in progress */423 unsigned int doing_init_tune:1; /* initial tuning in progress */
428 unsigned int can_retune:1; /* re-tuning can be used */424 unsigned int can_retune:1; /* re-tuning can be used */
429 unsigned int doing_retune:1; /* re-tuning in progress */425 unsigned int doing_retune:1; /* re-tuning in progress */
@@ -454,7 +450,6 @@ struct mmc_host { · 24 unmodified lines
454 struct mmc_slot slot;450 struct mmc_slot slot;
455 451
456 const struct mmc_bus_ops *bus_ops; /* current bus driver */452 const struct mmc_bus_ops *bus_ops; /* current bus driver */
457 unsigned int bus_refs; /* reference counter */
458 453
459 unsigned int sdio_irqs;454 unsigned int sdio_irqs;
460 struct task_struct *sdio_irq_thread;455 struct task_struct *sdio_irq_thread;
@@ -514,7 +509,7 @@ void mmc_free_host(struct mmc_host *); · 53 unmodified lines
514void mmc_of_parse_clk_phase(struct mmc_host *host,509void mmc_of_parse_clk_phase(struct mmc_host *host,
515 struct mmc_clk_phase_map *map);510 struct mmc_clk_phase_map *map);
516int mmc_of_parse(struct mmc_host *host);511int mmc_of_parse(struct mmc_host *host);
517int mmc_of_parse_voltage(struct device_node *np, u32 *mask);512int mmc_of_parse_voltage(struct mmc_host *host, u32 *mask);
518 513
519static inline void *mmc_priv(struct mmc_host *host)514static inline void *mmc_priv(struct mmc_host *host)
520{515{
include/linux/mmc/sdio.h+1−1
@@ -82,7 +82,7 @@ · 81 unmodified lines
82#define SDIO_SD_REV_1_01 0 /* SD Physical Spec Version 1.01 */82#define SDIO_SD_REV_1_01 0 /* SD Physical Spec Version 1.01 */
83#define SDIO_SD_REV_1_10 1 /* SD Physical Spec Version 1.10 */83#define SDIO_SD_REV_1_10 1 /* SD Physical Spec Version 1.10 */
84#define SDIO_SD_REV_2_00 2 /* SD Physical Spec Version 2.00 */84#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 */
86 86
87#define SDIO_CCCR_IOEx 0x0287#define SDIO_CCCR_IOEx 0x02
88#define SDIO_CCCR_IORx 0x0388#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
35 void (*setpower)(struct device *, unsigned int maskval);35 void (*setpower)(struct device *, unsigned int maskval);
36};36};
37 37
38#ifdef CONFIG_OF
39extern struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi);38extern struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi);
40extern void mmc_spi_put_pdata(struct spi_device *spi);39extern void mmc_spi_put_pdata(struct spi_device *spi);
41#else
42static inline struct mmc_spi_platform_data *
43mmc_spi_get_pdata(struct spi_device *spi)
44{
45 return spi->dev.platform_data;
46}
47static inline void mmc_spi_put_pdata(struct spi_device *spi) {}
48#endif /* CONFIG_OF */
49 40
50#endif /* __LINUX_SPI_MMC_SPI_H */41#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