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 ...
Unified · Split
| @@ -0,0 +1,63 @@ | ||
| 1 | +# SPDX-License-Identifier: GPL-2.0 | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/mmc/brcm,iproc-sdhci.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: Broadcom IPROC SDHCI controller | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Ray Jui <ray.jui@broadcom.com> | |
| 11 | + - Scott Branden <scott.branden@broadcom.com> | |
| 12 | + - Nicolas Saenz Julienne <nsaenz@kernel.org> | |
| 13 | + | |
| 14 | +allOf: | |
| 15 | + - $ref: mmc-controller.yaml# | |
| 16 | + | |
| 17 | +properties: | |
| 18 | + compatible: | |
| 19 | + enum: | |
| 20 | + - brcm,bcm2835-sdhci | |
| 21 | + - brcm,bcm2711-emmc2 | |
| 22 | + - brcm,sdhci-iproc-cygnus | |
| 23 | + - brcm,sdhci-iproc | |
| 24 | + | |
| 25 | + reg: | |
| 26 | + minItems: 1 | |
| 27 | + | |
| 28 | + interrupts: | |
| 29 | + maxItems: 1 | |
| 30 | + | |
| 31 | + clocks: | |
| 32 | + maxItems: 1 | |
| 33 | + description: | |
| 34 | + Handle to core clock for the sdhci controller. | |
| 35 | + | |
| 36 | + sdhci,auto-cmd12: | |
| 37 | + type: boolean | |
| 38 | + description: Specifies that controller should use auto CMD12 | |
| 39 | + | |
| 40 | +required: | |
| 41 | + - compatible | |
| 42 | + - reg | |
| 43 | + - interrupts | |
| 44 | + - clocks | |
| 45 | + | |
| 46 | +unevaluatedProperties: false | |
| 47 | + | |
| 48 | +examples: | |
| 49 | + - | | |
| 50 | + #include <dt-bindings/interrupt-controller/irq.h> | |
| 51 | + #include <dt-bindings/interrupt-controller/arm-gic.h> | |
| 52 | + #include <dt-bindings/clock/bcm-cygnus.h> | |
| 53 | + | |
| 54 | + mmc@18041000 { | |
| 55 | + compatible = "brcm,sdhci-iproc-cygnus"; | |
| 56 | + reg = <0x18041000 0x100>; | |
| 57 | + interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>; | |
| 58 | + clocks = <&lcpll0_clks BCM_CYGNUS_LCPLL0_SDIO_CLK>; | |
| 59 | + bus-width = <4>; | |
| 60 | + sdhci,auto-cmd12; | |
| 61 | + no-1-8-v; | |
| 62 | + }; | |
| 63 | +... | |
| @@ -1,37 +0,0 @@ | ||
| 1 | −Broadcom IPROC SDHCI controller | |
| 2 | − | |
| 3 | −This file documents differences between the core properties described | |
| 4 | −by mmc.txt and the properties that represent the IPROC SDHCI controller. | |
| 5 | − | |
| 6 | −Required properties: | |
| 7 | −- compatible : Should be one of the following | |
| 8 | − "brcm,bcm2835-sdhci" | |
| 9 | − "brcm,bcm2711-emmc2" | |
| 10 | − "brcm,sdhci-iproc-cygnus" | |
| 11 | − "brcm,sdhci-iproc" | |
| 12 | − | |
| 13 | −Use brcm2835-sdhci for the eMMC controller on the BCM2835 (Raspberry Pi) and | |
| 14 | −bcm2711-emmc2 for the additional eMMC2 controller on BCM2711. | |
| 15 | − | |
| 16 | −Use sdhci-iproc-cygnus for Broadcom SDHCI Controllers | |
| 17 | −restricted to 32bit host accesses to SDHCI registers. | |
| 18 | − | |
| 19 | −Use sdhci-iproc for Broadcom SDHCI Controllers that allow standard | |
| 20 | −8, 16, 32-bit host access to SDHCI register. | |
| 21 | − | |
| 22 | −- clocks : The clock feeding the SDHCI controller. | |
| 23 | − | |
| 24 | −Optional properties: | |
| 25 | − - sdhci,auto-cmd12: specifies that controller should use auto CMD12. | |
| 26 | − | |
| 27 | −Example: | |
| 28 | − | |
| 29 | −sdhci0: sdhci@18041000 { | |
| 30 | − compatible = "brcm,sdhci-iproc-cygnus"; | |
| 31 | − reg = <0x18041000 0x100>; | |
| 32 | − interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>; | |
| 33 | − clocks = <&lcpll0_clks BCM_CYGNUS_LCPLL0_SDIO_CLK>; | |
| 34 | − bus-width = <4>; | |
| 35 | − sdhci,auto-cmd12; | |
| 36 | − no-1-8-v; | |
| 37 | −}; | |
| @@ -103,6 +103,26 @@ properties: · 102 unmodified lines | ||
| 103 | 103 | Only eMMC HS400 mode need to take care of this property. |
| 104 | 104 | 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 | + | |
| 106 | 126 | required: |
| 107 | 127 | - compatible |
| 108 | 128 | - reg |
| @@ -5,11 +5,11 @@ by mmc.txt and the properties used by the mmc_spi driver. · 4 unmodified lines | ||
| 5 | 5 | |
| 6 | 6 | Required properties: |
| 7 | 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 | |
| 12 | 9 | Optional properties: |
| 10 | +- voltage-ranges : two cells are required, first cell specifies minimum | |
| 11 | + slot voltage (mV), second cell specifies maximum slot voltage (mV). | |
| 12 | + Several ranges could be specified. If not provided, 3.2v..3.4v is assumed. | |
| 13 | 13 | - gpios : may specify GPIOs in this order: Card-Detect GPIO, |
| 14 | 14 | Write-Protect GPIO. Note that this does not follow the |
| 15 | 15 | binding from mmc.txt, for historical reasons. |
| @@ -31,6 +31,7 @@ properties: · 30 unmodified lines | ||
| 31 | 31 | - const: mediatek,mt2701-mmc |
| 32 | 32 | - items: |
| 33 | 33 | - const: mediatek,mt8192-mmc |
| 34 | + - const: mediatek,mt8195-mmc | |
| 34 | 35 | - const: mediatek,mt8183-mmc |
| 35 | 36 | |
| 36 | 37 | clocks: |
| @@ -1,20 +0,0 @@ | ||
| 1 | −* Synopsys DesignWare Cores Mobile Storage Host Controller | |
| 2 | − | |
| 3 | −Required properties: | |
| 4 | −- compatible: should be one of the following: | |
| 5 | − "snps,dwcmshc-sdhci" | |
| 6 | −- reg: offset and length of the register set for the device. | |
| 7 | −- interrupts: a single interrupt specifier. | |
| 8 | −- clocks: Array of clocks required for SDHCI; requires at least one for | |
| 9 | − core clock. | |
| 10 | −- clock-names: Array of names corresponding to clocks property; shall be | |
| 11 | − "core" for core clock and "bus" for optional bus clock. | |
| 12 | − | |
| 13 | −Example: | |
| 14 | − sdhci2: sdhci@aa0000 { | |
| 15 | − compatible = "snps,dwcmshc-sdhci"; | |
| 16 | − reg = <0xaa0000 0x1000>; | |
| 17 | − interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>; | |
| 18 | − clocks = <&emmcclk>; | |
| 19 | − bus-width = <8>; | |
| 20 | − } | |
| @@ -0,0 +1,87 @@ | ||
| 1 | +# SPDX-License-Identifier: GPL-2.0-only | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/mmc/snps,dwcmshc-sdhci.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: Synopsys Designware Mobile Storage Host Controller Binding | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Ulf Hansson <ulf.hansson@linaro.org> | |
| 11 | + - Jisheng Zhang <Jisheng.Zhang@synaptics.com> | |
| 12 | + | |
| 13 | +allOf: | |
| 14 | + - $ref: mmc-controller.yaml# | |
| 15 | + | |
| 16 | +properties: | |
| 17 | + compatible: | |
| 18 | + enum: | |
| 19 | + - rockchip,rk3568-dwcmshc | |
| 20 | + - snps,dwcmshc-sdhci | |
| 21 | + | |
| 22 | + reg: | |
| 23 | + minItems: 1 | |
| 24 | + items: | |
| 25 | + - description: Offset and length of the register set for the device | |
| 26 | + | |
| 27 | + interrupts: | |
| 28 | + maxItems: 1 | |
| 29 | + | |
| 30 | + clocks: | |
| 31 | + minItems: 1 | |
| 32 | + items: | |
| 33 | + - description: core clock | |
| 34 | + - description: bus clock for optional | |
| 35 | + - description: axi clock for rockchip specified | |
| 36 | + - description: block clock for rockchip specified | |
| 37 | + - description: timer clock for rockchip specified | |
| 38 | + | |
| 39 | + | |
| 40 | + clock-names: | |
| 41 | + minItems: 1 | |
| 42 | + items: | |
| 43 | + - const: core | |
| 44 | + - const: bus | |
| 45 | + - const: axi | |
| 46 | + - const: block | |
| 47 | + - const: timer | |
| 48 | + | |
| 49 | + rockchip,txclk-tapnum: | |
| 50 | + description: Specify the number of delay for tx sampling. | |
| 51 | + $ref: /schemas/types.yaml#/definitions/uint8 | |
| 52 | + | |
| 53 | + | |
| 54 | +required: | |
| 55 | + - compatible | |
| 56 | + - reg | |
| 57 | + - interrupts | |
| 58 | + - clocks | |
| 59 | + - clock-names | |
| 60 | + | |
| 61 | +unevaluatedProperties: false | |
| 62 | + | |
| 63 | +examples: | |
| 64 | + - | | |
| 65 | + mmc@fe310000 { | |
| 66 | + compatible = "rockchip,rk3568-dwcmshc"; | |
| 67 | + reg = <0xfe310000 0x10000>; | |
| 68 | + interrupts = <0 25 0x4>; | |
| 69 | + clocks = <&cru 17>, <&cru 18>, <&cru 19>, <&cru 20>, <&cru 21>; | |
| 70 | + clock-names = "core", "bus", "axi", "block", "timer"; | |
| 71 | + bus-width = <8>; | |
| 72 | + #address-cells = <1>; | |
| 73 | + #size-cells = <0>; | |
| 74 | + }; | |
| 75 | + - | | |
| 76 | + mmc@aa0000 { | |
| 77 | + compatible = "snps,dwcmshc-sdhci"; | |
| 78 | + reg = <0xaa000 0x1000>; | |
| 79 | + interrupts = <0 25 0x4>; | |
| 80 | + clocks = <&cru 17>, <&cru 18>; | |
| 81 | + clock-names = "core", "bus"; | |
| 82 | + bus-width = <8>; | |
| 83 | + #address-cells = <1>; | |
| 84 | + #size-cells = <0>; | |
| 85 | + }; | |
| 86 | + | |
| 87 | +... | |
| @@ -331,18 +331,17 @@ static int h_memstick_read_dev_id(struct memstick_dev *card, · 330 unmodified lines | ||
| 331 | 331 | sizeof(struct ms_id_register)); |
| 332 | 332 | *mrq = &card->current_mrq; |
| 333 | 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 | |
| 348 | 347 | static int h_memstick_set_rw_addr(struct memstick_dev *card, |
| @@ -1382,7 +1382,8 @@ static int mspro_block_resume(struct memstick_dev *card) · 1381 unmodified lines | ||
| 1382 | 1382 | |
| 1383 | 1383 | new_msb->card = card; |
| 1384 | 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 | 1387 | goto out_free; |
| 1387 | 1388 | |
| 1388 | 1389 | for (cnt = 0; new_msb->attr_group.attrs[cnt] |
| @@ -359,13 +359,15 @@ static void r592_write_fifo_pio(struct r592_device *dev, · 358 unmodified lines | ||
| 359 | 359 | /* Flushes the temporary FIFO used to make aligned DWORD writes */ |
| 360 | 360 | static void r592_flush_fifo_write(struct r592_device *dev) |
| 361 | 361 | { |
| 362 | + int ret; | |
| 362 | 363 | u8 buffer[4] = { 0 }; |
| 363 | − int len; | |
| 364 | 364 | |
| 365 | 365 | if (kfifo_is_empty(&dev->pio_fifo)) |
| 366 | 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 | 371 | r592_write_reg_raw_be(dev, R592_FIFO_PIO, *(u32 *)buffer); |
| 370 | 372 | } |
| 371 | 373 | |
| @@ -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 | 540 | if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_SANITIZE_START) && |
| 541 | 541 | (cmd.opcode == MMC_SWITCH)) |
| 542 | − return mmc_sanitize(card); | |
| 542 | + return mmc_sanitize(card, idata->ic.cmd_timeout_ms); | |
| 543 | 543 | |
| 544 | 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 | 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 | 588 | * According to the SD specs, some commands require a delay after |
| 577 | 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 | 959 | md->reset_done |= type; |
| 948 | 960 | err = mmc_hw_reset(host); |
| 949 | 961 | /* Ensure we switch back to the correct partition */ |
| 950 | − if (err != -EOPNOTSUPP) { | |
| 962 | + if (err) { | |
| 951 | 963 | struct mmc_blk_data *main_md = |
| 952 | 964 | dev_get_drvdata(&host->card->dev); |
| 953 | 965 | int part_err; |
| @@ -1933,8 +1945,9 @@ static void mmc_blk_hsq_req_done(struct mmc_request *mrq) · 979 unmodified lines | ||
| 1933 | 1945 | void mmc_blk_mq_complete(struct request *req) |
| 1934 | 1946 | { |
| 1935 | 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 | 1951 | mmc_blk_cqe_complete_rq(mq, req); |
| 1939 | 1952 | else if (likely(!blk_should_fake_timeout(req->q))) |
| 1940 | 1953 | mmc_blk_mq_complete_rq(mq, req); |
| @@ -2179,7 +2192,7 @@ out_post_req: · 238 unmodified lines | ||
| 2179 | 2192 | |
| 2180 | 2193 | static 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 | 2196 | return host->cqe_ops->cqe_wait_for_idle(host); |
| 2184 | 2197 | |
| 2185 | 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 | 2237 | case MMC_ISSUE_ASYNC: |
| 2225 | 2238 | switch (req_op(req)) { |
| 2226 | 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 | 2244 | ret = mmc_blk_cqe_issue_flush(mq, req); |
| 2228 | 2245 | break; |
| 2229 | 2246 | case REQ_OP_READ: |
| 2230 | 2247 | case REQ_OP_WRITE: |
| 2231 | − if (mq->use_cqe) | |
| 2248 | + if (host->cqe_enabled) | |
| 2232 | 2249 | ret = mmc_blk_cqe_issue_rw_rq(mq, req); |
| 2233 | 2250 | else |
| 2234 | 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 | 2279 | struct mmc_blk_data *md; |
| 2263 | 2280 | int devidx, ret; |
| 2281 | + char cap_str[10]; | |
| 2264 | 2282 | |
| 2265 | 2283 | devidx = ida_simple_get(&mmc_blk_ida, 0, max_devices, GFP_KERNEL); |
| 2266 | 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 | 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 | 2392 | return md; |
| 2369 | 2393 | |
| 2370 | 2394 | err_putdisk: |
| @@ -2407,7 +2431,6 @@ static int mmc_blk_alloc_part(struct mmc_card *card, · 36 unmodified lines | ||
| 2407 | 2431 | const char *subname, |
| 2408 | 2432 | int area_type) |
| 2409 | 2433 | { |
| 2410 | − char cap_str[10]; | |
| 2411 | 2434 | struct mmc_blk_data *part_md; |
| 2412 | 2435 | |
| 2413 | 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 | 2440 | part_md->part_type = part_type; |
| 2418 | 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 | 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 | 2576 | string_get_size((u64)size, 512, STRING_UNITS_2, |
| 2559 | 2577 | cap_str, sizeof(cap_str)); |
| 2560 | 2578 | |
| 2561 | − pr_info("%s: %s %s partition %u %s, chardev (%d:%d)\n", | |
| 2562 | − rpmb_name, mmc_card_id(card), | |
| 2563 | − mmc_card_name(card), EXT_CSD_PART_CONFIG_ACC_RPMB, cap_str, | |
| 2579 | + pr_info("%s: %s %s %s, chardev (%d:%d)\n", | |
| 2580 | + rpmb_name, mmc_card_id(card), mmc_card_name(card), cap_str, | |
| 2564 | 2581 | MAJOR(mmc_rpmb_devt), rpmb->id); |
| 2565 | 2582 | |
| 2566 | 2583 | return 0; |
| @@ -2876,7 +2893,7 @@ static void mmc_blk_remove_debugfs(struct mmc_card *card, · 309 unmodified lines | ||
| 2876 | 2893 | static int mmc_blk_probe(struct mmc_card *card) |
| 2877 | 2894 | { |
| 2878 | 2895 | struct mmc_blk_data *md, *part_md; |
| 2879 | − char cap_str[10]; | |
| 2896 | + int ret = 0; | |
| 2880 | 2897 | |
| 2881 | 2898 | /* |
| 2882 | 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 | 2906 | card->complete_wq = alloc_workqueue("mmc_complete", |
| 2890 | 2907 | WQ_MEM_RECLAIM | WQ_HIGHPRI, 0); |
| 2891 | − if (unlikely(!card->complete_wq)) { | |
| 2908 | + if (!card->complete_wq) { | |
| 2892 | 2909 | pr_err("Failed to create mmc completion workqueue"); |
| 2893 | 2910 | return -ENOMEM; |
| 2894 | 2911 | } |
| 2895 | 2912 | |
| 2896 | 2913 | md = mmc_blk_alloc(card); |
| 2897 | − if (IS_ERR(md)) | |
| 2898 | − return PTR_ERR(md); | |
| 2899 | − | |
| 2900 | − string_get_size((u64)get_capacity(md->disk), 512, STRING_UNITS_2, | |
| 2901 | − cap_str, sizeof(cap_str)); | |
| 2902 | − pr_info("%s: %s %s %s %s\n", | |
| 2903 | − md->disk->disk_name, mmc_card_id(card), mmc_card_name(card), | |
| 2904 | − cap_str, md->read_only ? "(ro)" : ""); | |
| 2914 | + if (IS_ERR(md)) { | |
| 2915 | + ret = PTR_ERR(md); | |
| 2916 | + goto out_free; | |
| 2917 | + } | |
| 2905 | 2918 | |
| 2906 | − if (mmc_blk_alloc_parts(card, md)) | |
| 2919 | + ret = mmc_blk_alloc_parts(card, md); | |
| 2920 | + if (ret) | |
| 2907 | 2921 | goto out; |
| 2908 | 2922 | |
| 2909 | 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 | 2927 | goto out; |
| 2913 | 2928 | |
| 2914 | 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 | 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 | 2950 | return 0; |
| 2935 | 2951 | |
| 2936 | − out: | |
| 2952 | +out: | |
| 2937 | 2953 | mmc_blk_remove_parts(card, md); |
| 2938 | 2954 | mmc_blk_remove_req(md); |
| 2939 | − return 0; | |
| 2955 | +out_free: | |
| 2956 | + destroy_workqueue(card->complete_wq); | |
| 2957 | + return ret; | |
| 2940 | 2958 | } |
| 2941 | 2959 | |
| 2942 | 2960 | static void mmc_blk_remove(struct mmc_card *card) |
| @@ -1207,7 +1207,7 @@ int mmc_set_uhs_voltage(struct mmc_host *host, u32 ocr) · 1206 unmodified lines | ||
| 1207 | 1207 | |
| 1208 | 1208 | err = mmc_wait_for_cmd(host, &cmd, 0); |
| 1209 | 1209 | if (err) |
| 1210 | − return err; | |
| 1210 | + goto power_cycle; | |
| 1211 | 1211 | |
| 1212 | 1212 | if (!mmc_host_is_spi(host) && (cmd.resp[0] & R1_ERROR)) |
| 1213 | 1213 | return -EIO; |
| @@ -1377,63 +1377,13 @@ void mmc_power_cycle(struct mmc_host *host, u32 ocr) · 163 unmodified lines | ||
| 1377 | 1377 | mmc_power_up(host, ocr); |
| 1378 | 1378 | } |
| 1379 | 1379 | |
| 1380 | −/* | |
| 1381 | − * Cleanup when the last reference to the bus operator is dropped. | |
| 1382 | − */ | |
| 1383 | −static void __mmc_release_bus(struct mmc_host *host) | |
| 1384 | −{ | |
| 1385 | − WARN_ON(!host->bus_dead); | |
| 1386 | − | |
| 1387 | − host->bus_ops = NULL; | |
| 1388 | −} | |
| 1389 | − | |
| 1390 | −/* | |
| 1391 | − * Increase reference count of bus operator | |
| 1392 | − */ | |
| 1393 | −static inline void mmc_bus_get(struct mmc_host *host) | |
| 1394 | −{ | |
| 1395 | − unsigned long flags; | |
| 1396 | − | |
| 1397 | − spin_lock_irqsave(&host->lock, flags); | |
| 1398 | − host->bus_refs++; | |
| 1399 | − spin_unlock_irqrestore(&host->lock, flags); | |
| 1400 | −} | |
| 1401 | − | |
| 1402 | −/* | |
| 1403 | − * Decrease reference count of bus operator and free it if | |
| 1404 | − * it is the last reference. | |
| 1405 | − */ | |
| 1406 | −static inline void mmc_bus_put(struct mmc_host *host) | |
| 1407 | −{ | |
| 1408 | − unsigned long flags; | |
| 1409 | − | |
| 1410 | − spin_lock_irqsave(&host->lock, flags); | |
| 1411 | − host->bus_refs--; | |
| 1412 | − if ((host->bus_refs == 0) && host->bus_ops) | |
| 1413 | − __mmc_release_bus(host); | |
| 1414 | − spin_unlock_irqrestore(&host->lock, flags); | |
| 1415 | −} | |
| 1416 | − | |
| 1417 | 1380 | /* |
| 1418 | 1381 | * Assign a mmc bus handler to a host. Only one bus handler may control a |
| 1419 | 1382 | * host at any given time. |
| 1420 | 1383 | */ |
| 1421 | 1384 | void 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 | 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 | */ |
| 1442 | 1392 | void mmc_detach_bus(struct mmc_host *host) |
| 1443 | 1393 | { |
| 1444 | − unsigned long flags; | |
| 1445 | − | |
| 1446 | − WARN_ON(!host->claimed); | |
| 1447 | − WARN_ON(!host->bus_ops); | |
| 1448 | − | |
| 1449 | − spin_lock_irqsave(&host->lock, flags); | |
| 1450 | − | |
| 1451 | − host->bus_dead = 1; | |
| 1452 | − | |
| 1453 | − spin_unlock_irqrestore(&host->lock, flags); | |
| 1454 | − | |
| 1455 | − mmc_bus_put(host); | |
| 1394 | + host->bus_ops = NULL; | |
| 1456 | 1395 | } |
| 1457 | 1396 | |
| 1458 | 1397 | void _mmc_detect_change(struct mmc_host *host, unsigned long delay, bool cd_irq) |
| @@ -2080,18 +2019,7 @@ int mmc_hw_reset(struct mmc_host *host) · 621 unmodified lines | ||
| 2080 | 2019 | { |
| 2081 | 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 | 2022 | ret = host->bus_ops->hw_reset(host); |
| 2093 | − mmc_bus_put(host); | |
| 2094 | − | |
| 2095 | 2023 | if (ret < 0) |
| 2096 | 2024 | pr_warn("%s: tried to HW reset card, got error %d\n", |
| 2097 | 2025 | mmc_hostname(host), ret); |
| @@ -2104,18 +2032,10 @@ int mmc_sw_reset(struct mmc_host *host) · 6 unmodified lines | ||
| 2104 | 2032 | { |
| 2105 | 2033 | int ret; |
| 2106 | 2034 | |
| 2107 | − if (!host->card) | |
| 2108 | − return -EINVAL; | |
| 2109 | − | |
| 2110 | − mmc_bus_get(host); | |
| 2111 | − if (!host->bus_ops || host->bus_dead || !host->bus_ops->sw_reset) { | |
| 2112 | − mmc_bus_put(host); | |
| 2035 | + if (!host->bus_ops->sw_reset) | |
| 2113 | 2036 | return -EOPNOTSUPP; |
| 2114 | − } | |
| 2115 | 2037 | |
| 2116 | 2038 | ret = host->bus_ops->sw_reset(host); |
| 2117 | − mmc_bus_put(host); | |
| 2118 | − | |
| 2119 | 2039 | if (ret) |
| 2120 | 2040 | pr_warn("%s: tried to SW reset card, got error %d\n", |
| 2121 | 2041 | mmc_hostname(host), ret); |
| @@ -2263,32 +2183,15 @@ void mmc_rescan(struct work_struct *work) · 141 unmodified lines | ||
| 2263 | 2183 | host->trigger_card_event = false; |
| 2264 | 2184 | } |
| 2265 | 2185 | |
| 2266 | − mmc_bus_get(host); | |
| 2267 | − | |
| 2268 | 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 | 2188 | host->bus_ops->detect(host); |
| 2271 | 2189 | |
| 2272 | 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 | 2192 | /* if there still is a card present, stop here */ |
| 2282 | − if (host->bus_ops != NULL) { | |
| 2283 | − mmc_bus_put(host); | |
| 2193 | + if (host->bus_ops != NULL) | |
| 2284 | 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 | 2196 | mmc_claim_host(host); |
| 2294 | 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 | 2254 | /* clear pm flags now and let card drivers set them as needed */ |
| 2352 | 2255 | host->pm_flags = 0; |
| 2353 | 2256 | |
| 2354 | − mmc_bus_get(host); | |
| 2355 | − if (host->bus_ops && !host->bus_dead) { | |
| 2257 | + if (host->bus_ops) { | |
| 2356 | 2258 | /* Calling bus_ops->remove() with a claimed host can deadlock */ |
| 2357 | 2259 | host->bus_ops->remove(host); |
| 2358 | 2260 | mmc_claim_host(host); |
| 2359 | 2261 | mmc_detach_bus(host); |
| 2360 | 2262 | mmc_power_off(host); |
| 2361 | 2263 | mmc_release_host(host); |
| 2362 | − mmc_bus_put(host); | |
| 2363 | 2264 | return; |
| 2364 | 2265 | } |
| 2365 | − mmc_bus_put(host); | |
| 2366 | 2266 | |
| 2367 | 2267 | mmc_claim_host(host); |
| 2368 | 2268 | mmc_power_off(host); |
| 2369 | 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 | −*/ | |
| 2377 | −static int mmc_pm_notify(struct notifier_block *notify_block, | |
| 2378 | − unsigned long mode, void *unused) | |
| 2379 | −{ | |
| 2380 | − struct mmc_host *host = container_of( | |
| 2381 | − notify_block, struct mmc_host, pm_notify); | |
| 2382 | − unsigned long flags; | |
| 2383 | − int err = 0; | |
| 2384 | − | |
| 2385 | − switch (mode) { | |
| 2386 | − case PM_HIBERNATION_PREPARE: | |
| 2387 | − case PM_SUSPEND_PREPARE: | |
| 2388 | − case PM_RESTORE_PREPARE: | |
| 2389 | − spin_lock_irqsave(&host->lock, flags); | |
| 2390 | − host->rescan_disable = 1; | |
| 2391 | − spin_unlock_irqrestore(&host->lock, flags); | |
| 2392 | − cancel_delayed_work_sync(&host->detect); | |
| 2393 | − | |
| 2394 | − if (!host->bus_ops) | |
| 2395 | − break; | |
| 2396 | − | |
| 2397 | − /* Validate prerequisites for suspend */ | |
| 2398 | − if (host->bus_ops->pre_suspend) | |
| 2399 | − err = host->bus_ops->pre_suspend(host); | |
| 2400 | − if (!err) | |
| 2401 | − break; | |
| 2402 | − | |
| 2403 | − if (!mmc_card_is_removable(host)) { | |
| 2404 | − dev_warn(mmc_dev(host), | |
| 2405 | − "pre_suspend failed for non-removable host: " | |
| 2406 | − "%d\n", err); | |
| 2407 | − /* Avoid removing non-removable hosts */ | |
| 2408 | − break; | |
| 2409 | − } | |
| 2410 | − | |
| 2411 | − /* Calling bus_ops->remove() with a claimed host can deadlock */ | |
| 2412 | − host->bus_ops->remove(host); | |
| 2413 | − mmc_claim_host(host); | |
| 2414 | − mmc_detach_bus(host); | |
| 2415 | − mmc_power_off(host); | |
| 2416 | − mmc_release_host(host); | |
| 2417 | − host->pm_flags = 0; | |
| 2418 | − break; | |
| 2419 | − | |
| 2420 | − case PM_POST_SUSPEND: | |
| 2421 | − case PM_POST_HIBERNATION: | |
| 2422 | − case PM_POST_RESTORE: | |
| 2423 | − | |
| 2424 | − spin_lock_irqsave(&host->lock, flags); | |
| 2425 | − host->rescan_disable = 0; | |
| 2426 | − spin_unlock_irqrestore(&host->lock, flags); | |
| 2427 | − _mmc_detect_change(host, 0, false); | |
| 2428 | − | |
| 2429 | − } | |
| 2430 | − | |
| 2431 | − return 0; | |
| 2432 | −} | |
| 2433 | − | |
| 2434 | −void mmc_register_pm_notifier(struct mmc_host *host) | |
| 2435 | −{ | |
| 2436 | − host->pm_notify.notifier_call = mmc_pm_notify; | |
| 2437 | − register_pm_notifier(&host->pm_notify); | |
| 2438 | −} | |
| 2439 | − | |
| 2440 | −void mmc_unregister_pm_notifier(struct mmc_host *host) | |
| 2441 | −{ | |
| 2442 | − unregister_pm_notifier(&host->pm_notify); | |
| 2443 | −} | |
| 2444 | −#endif | |
| 2445 | − | |
| 2446 | 2272 | static int __init mmc_init(void) |
| 2447 | 2273 | { |
| 2448 | 2274 | int ret; |
| @@ -29,6 +29,7 @@ struct mmc_bus_ops { · 28 unmodified lines | ||
| 29 | 29 | int (*shutdown)(struct mmc_host *); |
| 30 | 30 | int (*hw_reset)(struct mmc_host *); |
| 31 | 31 | int (*sw_reset)(struct mmc_host *); |
| 32 | + bool (*cache_enabled)(struct mmc_host *); | |
| 32 | 33 | }; |
| 33 | 34 | |
| 34 | 35 | void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops); |
| @@ -93,14 +94,6 @@ int mmc_execute_tuning(struct mmc_card *card); · 58 unmodified lines | ||
| 93 | 94 | int mmc_hs200_to_hs400(struct mmc_card *card); |
| 94 | 95 | int mmc_hs400_to_hs200(struct mmc_card *card); |
| 95 | 96 | |
| 96 | −#ifdef CONFIG_PM_SLEEP | |
| 97 | −void mmc_register_pm_notifier(struct mmc_host *host); | |
| 98 | −void mmc_unregister_pm_notifier(struct mmc_host *host); | |
| 99 | −#else | |
| 100 | −static inline void mmc_register_pm_notifier(struct mmc_host *host) { } | |
| 101 | −static inline void mmc_unregister_pm_notifier(struct mmc_host *host) { } | |
| 102 | −#endif | |
| 103 | − | |
| 104 | 97 | void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq); |
| 105 | 98 | bool 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 | 164 | host->ops->post_req(host, mrq, err); |
| 172 | 165 | } |
| 173 | 166 | |
| 167 | +static inline bool mmc_cache_enabled(struct mmc_host *host) | |
| 168 | +{ | |
| 169 | + if (host->bus_ops->cache_enabled) | |
| 170 | + return host->bus_ops->cache_enabled(host); | |
| 171 | + | |
| 172 | + return false; | |
| 173 | +} | |
| 174 | + | |
| 174 | 175 | #endif |
| @@ -35,6 +35,42 @@ · 34 unmodified lines | ||
| 35 | 35 | |
| 36 | 36 | static DEFINE_IDA(mmc_host_ida); |
| 37 | 37 | |
| 38 | +#ifdef CONFIG_PM_SLEEP | |
| 39 | +static int mmc_host_class_prepare(struct device *dev) | |
| 40 | +{ | |
| 41 | + struct mmc_host *host = cls_dev_to_mmc_host(dev); | |
| 42 | + | |
| 43 | + /* | |
| 44 | + * It's safe to access the bus_ops pointer, as both userspace and the | |
| 45 | + * workqueue for detecting cards are frozen at this point. | |
| 46 | + */ | |
| 47 | + if (!host->bus_ops) | |
| 48 | + return 0; | |
| 49 | + | |
| 50 | + /* Validate conditions for system suspend. */ | |
| 51 | + if (host->bus_ops->pre_suspend) | |
| 52 | + return host->bus_ops->pre_suspend(host); | |
| 53 | + | |
| 54 | + return 0; | |
| 55 | +} | |
| 56 | + | |
| 57 | +static void mmc_host_class_complete(struct device *dev) | |
| 58 | +{ | |
| 59 | + struct mmc_host *host = cls_dev_to_mmc_host(dev); | |
| 60 | + | |
| 61 | + _mmc_detect_change(host, 0, false); | |
| 62 | +} | |
| 63 | + | |
| 64 | +static const struct dev_pm_ops mmc_host_class_dev_pm_ops = { | |
| 65 | + .prepare = mmc_host_class_prepare, | |
| 66 | + .complete = mmc_host_class_complete, | |
| 67 | +}; | |
| 68 | + | |
| 69 | +#define MMC_HOST_CLASS_DEV_PM_OPS (&mmc_host_class_dev_pm_ops) | |
| 70 | +#else | |
| 71 | +#define MMC_HOST_CLASS_DEV_PM_OPS NULL | |
| 72 | +#endif | |
| 73 | + | |
| 38 | 74 | static void mmc_host_classdev_release(struct device *dev) |
| 39 | 75 | { |
| 40 | 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 | ||
| 46 | 82 | static struct class mmc_host_class = { |
| 47 | 83 | .name = "mmc_host", |
| 48 | 84 | .dev_release = mmc_host_classdev_release, |
| 85 | + .pm = MMC_HOST_CLASS_DEV_PM_OPS, | |
| 49 | 86 | }; |
| 50 | 87 | |
| 51 | 88 | int mmc_register_host_class(void) |
| @@ -209,8 +246,8 @@ mmc_of_parse_clk_phase(struct mmc_host *host, struct mmc_clk_phase_map *map) · 157 unmodified lines | ||
| 209 | 246 | EXPORT_SYMBOL(mmc_of_parse_clk_phase); |
| 210 | 247 | |
| 211 | 248 | /** |
| 212 | − * mmc_of_parse() - parse host's device-tree node | |
| 213 | − * @host: host whose node should be parsed. | |
| 249 | + * mmc_of_parse() - parse host's device properties | |
| 250 | + * @host: host whose properties should be parsed. | |
| 214 | 251 | * |
| 215 | 252 | * To keep the rest of the MMC subsystem unaware of whether DT has been |
| 216 | 253 | * 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 | 418 | * 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 | 420 | * @mask: mask of voltages available for MMC/SD/SDIO |
| 384 | 421 | * |
| 385 | − * Parse the "voltage-ranges" DT property, returning zero if it is not | |
| 422 | + * Parse the "voltage-ranges" property, returning zero if it is not | |
| 386 | 423 | * found, negative errno if the voltage-range specification is invalid, |
| 387 | 424 | * or one if the voltage-range is specified and successfully parsed. |
| 388 | 425 | */ |
| 389 | −int mmc_of_parse_voltage(struct device_node *np, u32 *mask) | |
| 426 | +int 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 | 431 | int num_ranges, i; |
| 432 | + int ret; | |
| 393 | 433 | |
| 394 | − voltage_ranges = of_get_property(np, "voltage-ranges", &num_ranges); | |
| 395 | − if (!voltage_ranges) { | |
| 396 | − pr_debug("%pOF: voltage-ranges unspecified\n", np); | |
| 434 | + if (!device_property_present(dev, prop)) { | |
| 435 | + dev_dbg(dev, "%s unspecified\n", prop); | |
| 397 | 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 | 444 | if (!num_ranges) { |
| 401 | − pr_err("%pOF: voltage-ranges empty\n", np); | |
| 445 | + dev_err(dev, "%s empty\n", prop); | |
| 402 | 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 | 459 | for (i = 0; i < num_ranges; i++) { |
| 406 | 460 | const int j = i * 2; |
| 407 | 461 | u32 ocr_mask; |
| 408 | 462 | |
| 409 | − ocr_mask = mmc_vddrange_to_ocrmask( | |
| 410 | − be32_to_cpu(voltage_ranges[j]), | |
| 411 | − be32_to_cpu(voltage_ranges[j + 1])); | |
| 463 | + ocr_mask = mmc_vddrange_to_ocrmask(voltage_ranges[j + 0], | |
| 464 | + voltage_ranges[j + 1]); | |
| 412 | 465 | if (!ocr_mask) { |
| 413 | − pr_err("%pOF: voltage-range #%d is invalid\n", | |
| 414 | − np, i); | |
| 466 | + dev_err(dev, "range #%d in %s is invalid\n", i, prop); | |
| 467 | + kfree(voltage_ranges); | |
| 415 | 468 | return -EINVAL; |
| 416 | 469 | } |
| 417 | 470 | *mask |= ocr_mask; |
| 418 | 471 | } |
| 419 | 472 | |
| 473 | + kfree(voltage_ranges); | |
| 474 | + | |
| 420 | 475 | return 1; |
| 421 | 476 | } |
| 422 | 477 | EXPORT_SYMBOL(mmc_of_parse_voltage); |
| @@ -538,8 +593,6 @@ int mmc_add_host(struct mmc_host *host) · 115 unmodified lines | ||
| 538 | 593 | #endif |
| 539 | 594 | |
| 540 | 595 | mmc_start_host(host); |
| 541 | − mmc_register_pm_notifier(host); | |
| 542 | − | |
| 543 | 596 | return 0; |
| 544 | 597 | } |
| 545 | 598 | |
| @@ -555,7 +608,6 @@ EXPORT_SYMBOL(mmc_add_host); · 9 unmodified lines | ||
| 555 | 608 | */ |
| 556 | 609 | void mmc_remove_host(struct mmc_host *host) |
| 557 | 610 | { |
| 558 | − mmc_unregister_pm_notifier(host); | |
| 559 | 611 | mmc_stop_host(host); |
| 560 | 612 | |
| 561 | 613 | #ifdef CONFIG_DEBUG_FS |
| @@ -1068,7 +1068,7 @@ static int mmc_select_hs(struct mmc_card *card) · 1067 unmodified lines | ||
| 1068 | 1068 | err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
| 1069 | 1069 | EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS, |
| 1070 | 1070 | card->ext_csd.generic_cmd6_time, MMC_TIMING_MMC_HS, |
| 1071 | − true, true); | |
| 1071 | + true, true, MMC_CMD_RETRIES); | |
| 1072 | 1072 | if (err) |
| 1073 | 1073 | pr_warn("%s: switch to high-speed failed, err:%d\n", |
| 1074 | 1074 | mmc_hostname(card->host), err); |
| @@ -1100,7 +1100,7 @@ static int mmc_select_hs_ddr(struct mmc_card *card) · 25 unmodified lines | ||
| 1100 | 1100 | ext_csd_bits, |
| 1101 | 1101 | card->ext_csd.generic_cmd6_time, |
| 1102 | 1102 | MMC_TIMING_MMC_DDR52, |
| 1103 | − true, true); | |
| 1103 | + true, true, MMC_CMD_RETRIES); | |
| 1104 | 1104 | if (err) { |
| 1105 | 1105 | pr_err("%s: switch to bus width %d ddr failed\n", |
| 1106 | 1106 | mmc_hostname(host), 1 << bus_width); |
| @@ -1168,7 +1168,7 @@ static int mmc_select_hs400(struct mmc_card *card) · 61 unmodified lines | ||
| 1168 | 1168 | err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
| 1169 | 1169 | EXT_CSD_HS_TIMING, val, |
| 1170 | 1170 | card->ext_csd.generic_cmd6_time, 0, |
| 1171 | − false, true); | |
| 1171 | + false, true, MMC_CMD_RETRIES); | |
| 1172 | 1172 | if (err) { |
| 1173 | 1173 | pr_err("%s: switch to high-speed from hs200 failed, err:%d\n", |
| 1174 | 1174 | mmc_hostname(host), err); |
| @@ -1210,7 +1210,7 @@ static int mmc_select_hs400(struct mmc_card *card) · 35 unmodified lines | ||
| 1210 | 1210 | err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
| 1211 | 1211 | EXT_CSD_HS_TIMING, val, |
| 1212 | 1212 | card->ext_csd.generic_cmd6_time, 0, |
| 1213 | − false, true); | |
| 1213 | + false, true, MMC_CMD_RETRIES); | |
| 1214 | 1214 | if (err) { |
| 1215 | 1215 | pr_err("%s: switch to hs400 failed, err:%d\n", |
| 1216 | 1216 | mmc_hostname(host), err); |
| @@ -1256,7 +1256,7 @@ int mmc_hs400_to_hs200(struct mmc_card *card) · 39 unmodified lines | ||
| 1256 | 1256 | val = EXT_CSD_TIMING_HS; |
| 1257 | 1257 | err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, |
| 1258 | 1258 | val, card->ext_csd.generic_cmd6_time, 0, |
| 1259 | − false, true); | |
| 1259 | + false, true, MMC_CMD_RETRIES); | |
| 1260 | 1260 | if (err) |
| 1261 | 1261 | goto out_err; |
| 1262 | 1262 | |
| @@ -1272,7 +1272,7 @@ int mmc_hs400_to_hs200(struct mmc_card *card) · 9 unmodified lines | ||
| 1272 | 1272 | /* Switch HS DDR to HS */ |
| 1273 | 1273 | err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH, |
| 1274 | 1274 | EXT_CSD_BUS_WIDTH_8, card->ext_csd.generic_cmd6_time, |
| 1275 | − 0, false, true); | |
| 1275 | + 0, false, true, MMC_CMD_RETRIES); | |
| 1276 | 1276 | if (err) |
| 1277 | 1277 | goto out_err; |
| 1278 | 1278 | |
| @@ -1287,7 +1287,7 @@ int mmc_hs400_to_hs200(struct mmc_card *card) · 8 unmodified lines | ||
| 1287 | 1287 | card->drive_strength << EXT_CSD_DRV_STR_SHIFT; |
| 1288 | 1288 | err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, |
| 1289 | 1289 | val, card->ext_csd.generic_cmd6_time, 0, |
| 1290 | − false, true); | |
| 1290 | + false, true, MMC_CMD_RETRIES); | |
| 1291 | 1291 | if (err) |
| 1292 | 1292 | goto out_err; |
| 1293 | 1293 | |
| @@ -1371,7 +1371,7 @@ static int mmc_select_hs400es(struct mmc_card *card) · 77 unmodified lines | ||
| 1371 | 1371 | err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
| 1372 | 1372 | EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS, |
| 1373 | 1373 | card->ext_csd.generic_cmd6_time, 0, |
| 1374 | − false, true); | |
| 1374 | + false, true, MMC_CMD_RETRIES); | |
| 1375 | 1375 | if (err) { |
| 1376 | 1376 | pr_err("%s: switch to hs for hs400es failed, err:%d\n", |
| 1377 | 1377 | mmc_hostname(host), err); |
| @@ -1405,7 +1405,7 @@ static int mmc_select_hs400es(struct mmc_card *card) · 27 unmodified lines | ||
| 1405 | 1405 | err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
| 1406 | 1406 | EXT_CSD_HS_TIMING, val, |
| 1407 | 1407 | card->ext_csd.generic_cmd6_time, 0, |
| 1408 | − false, true); | |
| 1408 | + false, true, MMC_CMD_RETRIES); | |
| 1409 | 1409 | if (err) { |
| 1410 | 1410 | pr_err("%s: switch to hs400es failed, err:%d\n", |
| 1411 | 1411 | mmc_hostname(host), err); |
| @@ -1470,7 +1470,7 @@ static int mmc_select_hs200(struct mmc_card *card) · 58 unmodified lines | ||
| 1470 | 1470 | err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
| 1471 | 1471 | EXT_CSD_HS_TIMING, val, |
| 1472 | 1472 | card->ext_csd.generic_cmd6_time, 0, |
| 1473 | − false, true); | |
| 1473 | + false, true, MMC_CMD_RETRIES); | |
| 1474 | 1474 | if (err) |
| 1475 | 1475 | goto err; |
| 1476 | 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 | 1976 | err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
| 1977 | 1977 | EXT_CSD_POWER_OFF_NOTIFICATION, |
| 1978 | − notify_type, timeout, 0, false, false); | |
| 1978 | + notify_type, timeout, 0, false, false, MMC_CMD_RETRIES); | |
| 1979 | 1979 | if (err) |
| 1980 | 1980 | pr_err("%s: Power Off Notification timed out, %u\n", |
| 1981 | 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 | |
| 2032 | +static bool _mmc_cache_enabled(struct mmc_host *host) | |
| 2033 | +{ | |
| 2034 | + return host->card->ext_csd.cache_size > 0 && | |
| 2035 | + host->card->ext_csd.cache_ctrl & 1; | |
| 2036 | +} | |
| 2037 | + | |
| 2032 | 2038 | static int _mmc_suspend(struct mmc_host *host, bool is_suspend) |
| 2033 | 2039 | { |
| 2034 | 2040 | int err = 0; |
| @@ -2208,6 +2214,7 @@ static const struct mmc_bus_ops mmc_ops = { · 173 unmodified lines | ||
| 2208 | 2214 | .alive = mmc_alive, |
| 2209 | 2215 | .shutdown = mmc_shutdown, |
| 2210 | 2216 | .hw_reset = _mmc_hw_reset, |
| 2217 | + .cache_enabled = _mmc_cache_enabled, | |
| 2211 | 2218 | }; |
| 2212 | 2219 | |
| 2213 | 2220 | /* |
| @@ -296,61 +296,40 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host, · 295 unmodified lines | ||
| 296 | 296 | return 0; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | −static int mmc_spi_send_csd(struct mmc_host *host, u32 *csd) | |
| 299 | +static int mmc_spi_send_cxd(struct mmc_host *host, u32 *cxd, u32 opcode) | |
| 300 | 300 | { |
| 301 | 301 | int ret, i; |
| 302 | − __be32 *csd_tmp; | |
| 302 | + __be32 *cxd_tmp; | |
| 303 | 303 | |
| 304 | − csd_tmp = kzalloc(16, GFP_KERNEL); | |
| 305 | − if (!csd_tmp) | |
| 304 | + cxd_tmp = kzalloc(16, GFP_KERNEL); | |
| 305 | + if (!cxd_tmp) | |
| 306 | 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 | 309 | if (ret) |
| 310 | 310 | goto err; |
| 311 | 311 | |
| 312 | 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 | |
| 315 | 315 | err: |
| 316 | − kfree(csd_tmp); | |
| 316 | + kfree(cxd_tmp); | |
| 317 | 317 | return ret; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | int mmc_send_csd(struct mmc_card *card, u32 *csd) |
| 321 | 321 | { |
| 322 | 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 | 325 | return mmc_send_cxd_native(card->host, card->rca << 16, csd, |
| 326 | 326 | MMC_SEND_CSD); |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | −static int mmc_spi_send_cid(struct mmc_host *host, u32 *cid) | |
| 330 | −{ | |
| 331 | − int ret, i; | |
| 332 | − __be32 *cid_tmp; | |
| 333 | − | |
| 334 | − cid_tmp = kzalloc(16, GFP_KERNEL); | |
| 335 | − if (!cid_tmp) | |
| 336 | − return -ENOMEM; | |
| 337 | − | |
| 338 | − ret = mmc_send_cxd_data(NULL, host, MMC_SEND_CID, cid_tmp, 16); | |
| 339 | − if (ret) | |
| 340 | − goto err; | |
| 341 | − | |
| 342 | − for (i = 0; i < 4; i++) | |
| 343 | − cid[i] = be32_to_cpu(cid_tmp[i]); | |
| 344 | − | |
| 345 | −err: | |
| 346 | − kfree(cid_tmp); | |
| 347 | − return ret; | |
| 348 | −} | |
| 349 | − | |
| 350 | 329 | int mmc_send_cid(struct mmc_host *host, u32 *cid) |
| 351 | 330 | { |
| 352 | 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 | 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 | 532 | * @timing: new timing to change to |
| 554 | 533 | * @send_status: send status cmd to poll for busy |
| 555 | 534 | * @retry_crc_err: retry when CRC errors when polling with CMD13 for busy |
| 535 | + * @retries: number of retries | |
| 556 | 536 | * |
| 557 | 537 | * Modifies the EXT_CSD register for selected card. |
| 558 | 538 | */ |
| 559 | 539 | int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, |
| 560 | 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 | 543 | struct mmc_host *host = card->host; |
| 564 | 544 | int err; |
| @@ -598,7 +578,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, · 33 unmodified lines | ||
| 598 | 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 | 582 | if (err) |
| 603 | 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 | 613 | unsigned int timeout_ms) |
| 634 | 614 | { |
| 635 | 615 | return __mmc_switch(card, set, index, value, timeout_ms, 0, |
| 636 | − true, false); | |
| 616 | + true, false, MMC_CMD_RETRIES); | |
| 637 | 617 | } |
| 638 | 618 | EXPORT_SYMBOL_GPL(mmc_switch); |
| 639 | 619 | |
| @@ -988,9 +968,7 @@ int mmc_flush_cache(struct mmc_card *card) · 348 unmodified lines | ||
| 988 | 968 | { |
| 989 | 969 | int err = 0; |
| 990 | 970 | |
| 991 | − if (mmc_card_mmc(card) && | |
| 992 | − (card->ext_csd.cache_size > 0) && | |
| 993 | − (card->ext_csd.cache_ctrl & 1)) { | |
| 971 | + if (mmc_cache_enabled(card->host)) { | |
| 994 | 972 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
| 995 | 973 | EXT_CSD_FLUSH_CACHE, 1, |
| 996 | 974 | MMC_CACHE_FLUSH_TIMEOUT_MS); |
| @@ -1031,7 +1009,7 @@ int mmc_cmdq_disable(struct mmc_card *card) · 34 unmodified lines | ||
| 1031 | 1009 | } |
| 1032 | 1010 | EXPORT_SYMBOL_GPL(mmc_cmdq_disable); |
| 1033 | 1011 | |
| 1034 | −int mmc_sanitize(struct mmc_card *card) | |
| 1012 | +int mmc_sanitize(struct mmc_card *card, unsigned int timeout_ms) | |
| 1035 | 1013 | { |
| 1036 | 1014 | struct mmc_host *host = card->host; |
| 1037 | 1015 | int err; |
| @@ -1041,12 +1019,15 @@ int mmc_sanitize(struct mmc_card *card) · 3 unmodified lines | ||
| 1041 | 1019 | return -EOPNOTSUPP; |
| 1042 | 1020 | } |
| 1043 | 1021 | |
| 1022 | + if (!timeout_ms) | |
| 1023 | + timeout_ms = MMC_SANITIZE_TIMEOUT_MS; | |
| 1024 | + | |
| 1044 | 1025 | pr_debug("%s: Sanitize in progress...\n", mmc_hostname(host)); |
| 1045 | 1026 | |
| 1046 | 1027 | mmc_retune_hold(host); |
| 1047 | 1028 | |
| 1048 | − err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_SANITIZE_START, | |
| 1049 | − 1, MMC_SANITIZE_TIMEOUT_MS); | |
| 1029 | + err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_SANITIZE_START, | |
| 1030 | + 1, timeout_ms, 0, true, false, 0); | |
| 1050 | 1031 | if (err) |
| 1051 | 1032 | pr_err("%s: Sanitize failed err=%d\n", mmc_hostname(host), err); |
| 1052 | 1033 | |
| @@ -39,14 +39,14 @@ int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms, · 38 unmodified lines | ||
| 39 | 39 | enum mmc_busy_cmd busy_cmd); |
| 40 | 40 | int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, |
| 41 | 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); | |
| 43 | 43 | int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, |
| 44 | 44 | unsigned int timeout_ms); |
| 45 | 45 | void mmc_run_bkops(struct mmc_card *card); |
| 46 | 46 | int mmc_flush_cache(struct mmc_card *card); |
| 47 | 47 | int mmc_cmdq_enable(struct mmc_card *card); |
| 48 | 48 | int mmc_cmdq_disable(struct mmc_card *card); |
| 49 | −int mmc_sanitize(struct mmc_card *card); | |
| 49 | +int mmc_sanitize(struct mmc_card *card, unsigned int timeout_ms); | |
| 50 | 50 | |
| 51 | 51 | #endif |
| 52 | 52 | |
| @@ -60,7 +60,7 @@ enum mmc_issue_type mmc_issue_type(struct mmc_queue *mq, struct request *req) · 59 unmodified lines | ||
| 60 | 60 | { |
| 61 | 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 | 64 | return mmc_cqe_issue_type(host, req); |
| 65 | 65 | |
| 66 | 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 | 127 | bool ignore_tout; |
| 128 | 128 | |
| 129 | 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 | 131 | spin_unlock_irqrestore(&mq->lock, flags); |
| 132 | 132 | |
| 133 | 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 | 145 | mq->in_recovery = true; |
| 146 | 146 | |
| 147 | − if (mq->use_cqe && !host->hsq_enabled) | |
| 147 | + if (host->cqe_enabled && !host->hsq_enabled) | |
| 148 | 148 | mmc_blk_cqe_recovery(mq); |
| 149 | 149 | else |
| 150 | 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 | 315 | if (get_card) |
| 316 | 316 | mmc_get_card(card, &mq->ctx); |
| 317 | 317 | |
| 318 | − if (mq->use_cqe) { | |
| 318 | + if (host->cqe_enabled) { | |
| 319 | 319 | host->retune_now = host->need_retune && cqe_retune_ok && |
| 320 | 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 | 430 | int ret; |
| 431 | 431 | |
| 432 | 432 | mq->card = card; |
| 433 | − mq->use_cqe = host->cqe_enabled; | |
| 434 | 433 | |
| 435 | 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 | 439 | * The queue depth for CQE must match the hardware because the request |
| 441 | 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 | 443 | mq->tag_set.queue_depth = |
| 445 | 444 | min_t(int, card->ext_csd.cmdq_depth, host->cqe_qdepth); |
| 446 | 445 | else |
| @@ -82,7 +82,6 @@ struct mmc_queue { · 81 unmodified lines | ||
| 82 | 82 | unsigned int cqe_busy; |
| 83 | 83 | #define MMC_CQE_DCMD_BUSY BIT(0) |
| 84 | 84 | bool busy; |
| 85 | − bool use_cqe; | |
| 86 | 85 | bool recovery_needed; |
| 87 | 86 | bool in_recovery; |
| 88 | 87 | bool rw_wait; |
| @@ -135,6 +135,9 @@ static int mmc_decode_csd(struct mmc_card *card) · 134 unmodified lines | ||
| 135 | 135 | csd->erase_size = UNSTUFF_BITS(resp, 39, 7) + 1; |
| 136 | 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 | 141 | break; |
| 139 | 142 | case 1: |
| 140 | 143 | /* |
| @@ -169,6 +172,9 @@ static int mmc_decode_csd(struct mmc_card *card) · 28 unmodified lines | ||
| 169 | 172 | csd->write_blkbits = 9; |
| 170 | 173 | csd->write_partial = 0; |
| 171 | 174 | csd->erase_size = 1; |
| 175 | + | |
| 176 | + if (UNSTUFF_BITS(resp, 13, 1)) | |
| 177 | + mmc_card_set_readonly(card); | |
| 172 | 178 | break; |
| 173 | 179 | default: |
| 174 | 180 | pr_err("%s: unrecognised CSD structure version %d\n", |
| @@ -985,21 +985,37 @@ out: · 984 unmodified lines | ||
| 985 | 985 | */ |
| 986 | 986 | static int mmc_sdio_pre_suspend(struct mmc_host *host) |
| 987 | 987 | { |
| 988 | − int i, err = 0; | |
| 988 | + int i; | |
| 989 | 989 | |
| 990 | 990 | for (i = 0; i < host->card->sdio_funcs; i++) { |
| 991 | 991 | struct sdio_func *func = host->card->sdio_func[i]; |
| 992 | 992 | if (func && sdio_func_present(func) && func->dev.driver) { |
| 993 | 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 | 995 | /* force removal of entire card in that case */ |
| 996 | − err = -ENOSYS; | |
| 997 | − break; | |
| 998 | − } | |
| 996 | + goto remove; | |
| 999 | 997 | } |
| 1000 | 998 | } |
| 1001 | 999 | |
| 1002 | − return err; | |
| 1000 | + return 0; | |
| 1001 | + | |
| 1002 | +remove: | |
| 1003 | + if (!mmc_card_is_removable(host)) { | |
| 1004 | + dev_warn(mmc_dev(host), | |
| 1005 | + "missing suspend/resume ops for non-removable SDIO card\n"); | |
| 1006 | + /* Don't remove a non-removable card - we can't re-detect it. */ | |
| 1007 | + return 0; | |
| 1008 | + } | |
| 1009 | + | |
| 1010 | + /* Remove the SDIO card and let it be re-detected later on. */ | |
| 1011 | + mmc_sdio_remove(host); | |
| 1012 | + mmc_claim_host(host); | |
| 1013 | + mmc_detach_bus(host); | |
| 1014 | + mmc_power_off(host); | |
| 1015 | + mmc_release_host(host); | |
| 1016 | + host->pm_flags = 0; | |
| 1017 | + | |
| 1018 | + return 0; | |
| 1003 | 1019 | } |
| 1004 | 1020 | |
| 1005 | 1021 | /* |
| @@ -278,6 +278,7 @@ config MMC_SDHCI_ESDHC_IMX · 277 unmodified lines | ||
| 278 | 278 | tristate "SDHCI support for the Freescale eSDHC/uSDHC i.MX controller" |
| 279 | 279 | depends on ARCH_MXC || COMPILE_TEST |
| 280 | 280 | depends on MMC_SDHCI_PLTFM |
| 281 | + depends on OF | |
| 281 | 282 | select MMC_SDHCI_IO_ACCESSORS |
| 282 | 283 | select MMC_CQHCI |
| 283 | 284 | help |
| @@ -707,6 +708,7 @@ config MMC_SDHI · 423 unmodified lines | ||
| 707 | 708 | tristate "Renesas SDHI SD/SDIO controller support" |
| 708 | 709 | depends on SUPERH || ARCH_RENESAS || COMPILE_TEST |
| 709 | 710 | select MMC_TMIO_CORE |
| 711 | + select RESET_CONTROLLER if ARCH_RENESAS | |
| 710 | 712 | help |
| 711 | 713 | This provides support for the SDHI SD/SDIO controller found in |
| 712 | 714 | Renesas SuperH, ARM and ARM64 based SoCs |
| @@ -34,9 +34,7 @@ obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o · 33 unmodified lines | ||
| 34 | 34 | obj-$(CONFIG_MMC_MVSDIO) += mvsdio.o |
| 35 | 35 | obj-$(CONFIG_MMC_DAVINCI) += davinci_mmc.o |
| 36 | 36 | obj-$(CONFIG_MMC_SPI) += mmc_spi.o |
| 37 | −ifeq ($(CONFIG_OF),y) | |
| 38 | 37 | obj-$(CONFIG_MMC_SPI) += of_mmc_spi.o |
| 39 | −endif | |
| 40 | 38 | obj-$(CONFIG_MMC_S3C) += s3cmci.o |
| 41 | 39 | obj-$(CONFIG_MMC_SDRICOH_CS) += sdricoh_cs.o |
| 42 | 40 | obj-$(CONFIG_MMC_TMIO) += tmio_mmc.o |
| @@ -656,8 +656,7 @@ static void cvm_mmc_dma_request(struct mmc_host *mmc, · 655 unmodified lines | ||
| 656 | 656 | |
| 657 | 657 | if (!mrq->data || !mrq->data->sg || !mrq->data->sg_len || |
| 658 | 658 | !mrq->stop || mrq->stop->opcode != MMC_STOP_TRANSMISSION) { |
| 659 | − dev_err(&mmc->card->dev, | |
| 660 | − "Error: cmv_mmc_dma_request no data\n"); | |
| 659 | + dev_err(&mmc->card->dev, "Error: %s no data\n", __func__); | |
| 661 | 660 | goto error; |
| 662 | 661 | } |
| 663 | 662 | |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | 2 | /* |
| 3 | 3 | * Copyright (c) 2013 Linaro Ltd. |
| 4 | − * Copyright (c) 2013 Hisilicon Limited. | |
| 4 | + * Copyright (c) 2013 HiSilicon Limited. | |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | #include <linux/bitops.h> |
| @@ -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 | 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 | 65 | clk_set_phase(priv->sample_clk, priv->default_sample_phase); |
| 66 | 66 | |
| 67 | 67 | /* |
| @@ -2606,8 +2606,6 @@ static void dw_mci_handle_cd(struct dw_mci *host) · 2605 unmodified lines | ||
| 2606 | 2606 | { |
| 2607 | 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 | 2609 | mmc_detect_change(slot->mmc, |
| 2612 | 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 | 3094 | /* find reset controller when exist */ |
| 3097 | 3095 | pdata->rstc = devm_reset_control_get_optional_exclusive(dev, "reset"); |
| 3098 | − if (IS_ERR(pdata->rstc)) { | |
| 3099 | − if (PTR_ERR(pdata->rstc) == -EPROBE_DEFER) | |
| 3100 | − return ERR_PTR(-EPROBE_DEFER); | |
| 3101 | − } | |
| 3096 | + if (IS_ERR(pdata->rstc)) | |
| 3097 | + return ERR_CAST(pdata->rstc); | |
| 3102 | 3098 | |
| 3103 | 3099 | if (device_property_read_u32(dev, "fifo-depth", &pdata->fifo_depth)) |
| 3104 | 3100 | dev_info(dev, |
| @@ -3204,7 +3200,7 @@ int dw_mci_probe(struct dw_mci *host) · 99 unmodified lines | ||
| 3204 | 3200 | goto err_clk_ciu; |
| 3205 | 3201 | } |
| 3206 | 3202 | |
| 3207 | − if (!IS_ERR(host->pdata->rstc)) { | |
| 3203 | + if (host->pdata->rstc) { | |
| 3208 | 3204 | reset_control_assert(host->pdata->rstc); |
| 3209 | 3205 | usleep_range(10, 50); |
| 3210 | 3206 | reset_control_deassert(host->pdata->rstc); |
| @@ -3344,8 +3340,7 @@ err_dmaunmap: · 133 unmodified lines | ||
| 3344 | 3340 | if (host->use_dma && host->dma_ops->exit) |
| 3345 | 3341 | host->dma_ops->exit(host); |
| 3346 | 3342 | |
| 3347 | − if (!IS_ERR(host->pdata->rstc)) | |
| 3348 | − reset_control_assert(host->pdata->rstc); | |
| 3343 | + reset_control_assert(host->pdata->rstc); | |
| 3349 | 3344 | |
| 3350 | 3345 | err_clk_ciu: |
| 3351 | 3346 | clk_disable_unprepare(host->ciu_clk); |
| @@ -3373,8 +3368,7 @@ void dw_mci_remove(struct dw_mci *host) · 21 unmodified lines | ||
| 3373 | 3368 | if (host->use_dma && host->dma_ops->exit) |
| 3374 | 3369 | host->dma_ops->exit(host); |
| 3375 | 3370 | |
| 3376 | − if (!IS_ERR(host->pdata->rstc)) | |
| 3377 | − reset_control_assert(host->pdata->rstc); | |
| 3371 | + reset_control_assert(host->pdata->rstc); | |
| 3378 | 3372 | |
| 3379 | 3373 | clk_disable_unprepare(host->ciu_clk); |
| 3380 | 3374 | clk_disable_unprepare(host->biu_clk); |
| @@ -1397,6 +1397,8 @@ static int mmc_spi_probe(struct spi_device *spi) · 1396 unmodified lines | ||
| 1397 | 1397 | |
| 1398 | 1398 | host->ones = ones; |
| 1399 | 1399 | |
| 1400 | + dev_set_drvdata(&spi->dev, mmc); | |
| 1401 | + | |
| 1400 | 1402 | /* Platform data is used to hook up things like card sensing |
| 1401 | 1403 | * and power switching gpios. |
| 1402 | 1404 | */ |
| @@ -1413,8 +1415,6 @@ static int mmc_spi_probe(struct spi_device *spi) · 10 unmodified lines | ||
| 1413 | 1415 | host->powerup_msecs = 250; |
| 1414 | 1416 | } |
| 1415 | 1417 | |
| 1416 | − dev_set_drvdata(&spi->dev, mmc); | |
| 1417 | − | |
| 1418 | 1418 | /* preallocate dma buffers */ |
| 1419 | 1419 | host->data = kmalloc(sizeof(*host->data), GFP_KERNEL); |
| 1420 | 1420 | if (!host->data) |
| @@ -1494,8 +1494,8 @@ fail_glue_init: · 73 unmodified lines | ||
| 1494 | 1494 | fail_dma: |
| 1495 | 1495 | kfree(host->data); |
| 1496 | 1496 | fail_nobuf1: |
| 1497 | − mmc_free_host(mmc); | |
| 1498 | 1497 | mmc_spi_put_pdata(spi); |
| 1498 | + mmc_free_host(mmc); | |
| 1499 | 1499 | nomem: |
| 1500 | 1500 | kfree(ones); |
| 1501 | 1501 | return status; |
| @@ -1518,8 +1518,8 @@ static int mmc_spi_remove(struct spi_device *spi) · 16 unmodified lines | ||
| 1518 | 1518 | kfree(host->ones); |
| 1519 | 1519 | |
| 1520 | 1520 | spi->max_speed_hz = mmc->f_max; |
| 1521 | − mmc_free_host(mmc); | |
| 1522 | 1521 | mmc_spi_put_pdata(spi); |
| 1522 | + mmc_free_host(mmc); | |
| 1523 | 1523 | return 0; |
| 1524 | 1524 | } |
| 1525 | 1525 | |
| @@ -257,7 +257,6 @@ static void moxart_dma_complete(void *param) · 256 unmodified lines | ||
| 257 | 257 | static void moxart_transfer_dma(struct mmc_data *data, struct moxart_host *host) |
| 258 | 258 | { |
| 259 | 259 | u32 len, dir_slave; |
| 260 | − long dma_time; | |
| 261 | 260 | struct dma_async_tx_descriptor *desc = NULL; |
| 262 | 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 | 294 | data->bytes_xfered += host->data_remain; |
| 296 | 295 | |
| 297 | − dma_time = wait_for_completion_interruptible_timeout( | |
| 298 | − &host->dma_complete, host->timeout); | |
| 296 | + wait_for_completion_interruptible_timeout(&host->dma_complete, | |
| 297 | + host->timeout); | |
| 299 | 298 | |
| 300 | 299 | dma_unmap_sg(dma_chan->device->dev, |
| 301 | 300 | data->sg, data->sg_len, |
| @@ -395,7 +394,6 @@ static void moxart_prepare_data(struct moxart_host *host) · 93 unmodified lines | ||
| 395 | 394 | static void moxart_request(struct mmc_host *mmc, struct mmc_request *mrq) |
| 396 | 395 | { |
| 397 | 396 | struct moxart_host *host = mmc_priv(mmc); |
| 398 | − long pio_time; | |
| 399 | 397 | unsigned long flags; |
| 400 | 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 | 429 | spin_unlock_irqrestore(&host->lock, flags); |
| 432 | 430 | |
| 433 | 431 | /* PIO transfers start from interrupt. */ |
| 434 | − pio_time = wait_for_completion_interruptible_timeout( | |
| 435 | − &host->pio_complete, host->timeout); | |
| 432 | + wait_for_completion_interruptible_timeout(&host->pio_complete, | |
| 433 | + host->timeout); | |
| 436 | 434 | |
| 437 | 435 | spin_lock_irqsave(&host->lock, flags); |
| 438 | 436 | } |
| @@ -19,11 +19,6 @@ · 18 unmodified lines | ||
| 19 | 19 | #include <linux/mmc/core.h> |
| 20 | 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 | − | |
| 27 | 22 | MODULE_LICENSE("GPL"); |
| 28 | 23 | |
| 29 | 24 | struct of_mmc_spi { |
| @@ -54,22 +49,22 @@ static void of_mmc_spi_exit(struct device *dev, void *mmc) · 24 unmodified lines | ||
| 54 | 49 | |
| 55 | 50 | struct 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 | 53 | struct device *dev = &spi->dev; |
| 58 | − struct device_node *np = dev->of_node; | |
| 59 | 54 | struct of_mmc_spi *oms; |
| 60 | 55 | |
| 61 | − if (dev->platform_data || !np) | |
| 56 | + if (dev->platform_data || !dev_fwnode(dev)) | |
| 62 | 57 | return dev->platform_data; |
| 63 | 58 | |
| 64 | 59 | oms = kzalloc(sizeof(*oms), GFP_KERNEL); |
| 65 | 60 | if (!oms) |
| 66 | 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 | 64 | goto err_ocr; |
| 70 | 65 | |
| 71 | − oms->detect_irq = irq_of_parse_and_map(np, 0); | |
| 72 | − if (oms->detect_irq != 0) { | |
| 66 | + oms->detect_irq = spi->irq; | |
| 67 | + if (oms->detect_irq > 0) { | |
| 73 | 68 | oms->pdata.init = of_mmc_spi_init; |
| 74 | 69 | oms->pdata.exit = of_mmc_spi_exit; |
| 75 | 70 | } else { |
| @@ -87,10 +82,9 @@ EXPORT_SYMBOL(mmc_spi_get_pdata); · 11 unmodified lines | ||
| 87 | 82 | void mmc_spi_put_pdata(struct spi_device *spi) |
| 88 | 83 | { |
| 89 | 84 | struct device *dev = &spi->dev; |
| 90 | − struct device_node *np = dev->of_node; | |
| 91 | 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 | 88 | return; |
| 95 | 89 | |
| 96 | 90 | kfree(oms); |
| @@ -581,7 +581,6 @@ static int owl_mmc_probe(struct platform_device *pdev) · 580 unmodified lines | ||
| 581 | 581 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 582 | 582 | owl_host->base = devm_ioremap_resource(&pdev->dev, res); |
| 583 | 583 | if (IS_ERR(owl_host->base)) { |
| 584 | − dev_err(&pdev->dev, "Failed to remap registers\n"); | |
| 585 | 584 | ret = PTR_ERR(owl_host->base); |
| 586 | 585 | goto err_free_host; |
| 587 | 586 | } |
| @@ -70,6 +70,8 @@ struct renesas_sdhi { · 69 unmodified lines | ||
| 70 | 70 | DECLARE_BITMAP(smpcmp, BITS_PER_LONG); |
| 71 | 71 | unsigned int tap_num; |
| 72 | 72 | unsigned int tap_set; |
| 73 | + | |
| 74 | + struct reset_control *rstc; | |
| 73 | 75 | }; |
| 74 | 76 | |
| 75 | 77 | #define host_to_priv(host) \ |
| @@ -20,6 +20,7 @@ · 19 unmodified lines | ||
| 20 | 20 | |
| 21 | 21 | #include <linux/clk.h> |
| 22 | 22 | #include <linux/delay.h> |
| 23 | +#include <linux/iopoll.h> | |
| 23 | 24 | #include <linux/kernel.h> |
| 24 | 25 | #include <linux/mfd/tmio.h> |
| 25 | 26 | #include <linux/mmc/host.h> |
| @@ -32,6 +33,7 @@ · 6 unmodified lines | ||
| 32 | 33 | #include <linux/platform_device.h> |
| 33 | 34 | #include <linux/pm_domain.h> |
| 34 | 35 | #include <linux/regulator/consumer.h> |
| 36 | +#include <linux/reset.h> | |
| 35 | 37 | #include <linux/sh_dma.h> |
| 36 | 38 | #include <linux/slab.h> |
| 37 | 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 | 559 | return 0; |
| 558 | 560 | } |
| 559 | 561 | |
| 562 | +static void renesas_sdhi_scc_reset(struct tmio_mmc_host *host, struct renesas_sdhi *priv) | |
| 563 | +{ | |
| 564 | + renesas_sdhi_disable_scc(host->mmc); | |
| 565 | + renesas_sdhi_reset_hs400_mode(host, priv); | |
| 566 | + priv->needs_adjust_hs400 = false; | |
| 567 | + | |
| 568 | + sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL, | |
| 569 | + ~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN & | |
| 570 | + sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL)); | |
| 571 | +} | |
| 572 | + | |
| 560 | 573 | /* only populated for TMIO_MMC_MIN_RCAR2 */ |
| 561 | 574 | static void renesas_sdhi_reset(struct tmio_mmc_host *host) |
| 562 | 575 | { |
| 563 | 576 | struct renesas_sdhi *priv = host_to_priv(host); |
| 577 | + int ret; | |
| 564 | 578 | u16 val; |
| 565 | 579 | |
| 566 | − if (priv->scc_ctl) { | |
| 567 | − renesas_sdhi_disable_scc(host->mmc); | |
| 568 | − renesas_sdhi_reset_hs400_mode(host, priv); | |
| 580 | + if (priv->rstc) { | |
| 581 | + reset_control_reset(priv->rstc); | |
| 582 | + /* Unknown why but without polling reset status, it will hang */ | |
| 583 | + read_poll_timeout(reset_control_status, ret, ret == 0, 1, 100, | |
| 584 | + false, priv->rstc); | |
| 569 | 585 | priv->needs_adjust_hs400 = false; |
| 570 | − | |
| 571 | − sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL, | |
| 572 | − ~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN & | |
| 573 | − sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL)); | |
| 586 | + renesas_sdhi_set_clock(host, host->clk_cache); | |
| 587 | + } else if (priv->scc_ctl) { | |
| 588 | + renesas_sdhi_scc_reset(host, priv); | |
| 574 | 589 | } |
| 575 | 590 | |
| 576 | − sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, TMIO_MASK_INIT_RCAR2); | |
| 577 | − | |
| 578 | 591 | if (sd_ctrl_read16(host, CTL_VERSION) >= SDHI_VER_GEN3_SD) { |
| 579 | 592 | val = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT); |
| 580 | 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 | 705 | ret = renesas_sdhi_select_tuning(host); |
| 693 | 706 | if (ret < 0) |
| 694 | − renesas_sdhi_reset(host); | |
| 707 | + renesas_sdhi_scc_reset(host, priv); | |
| 695 | 708 | return ret; |
| 696 | 709 | } |
| 697 | 710 | |
| @@ -1034,6 +1047,7 @@ int renesas_sdhi_probe(struct platform_device *pdev, · 336 unmodified lines | ||
| 1034 | 1047 | host->ops.start_signal_voltage_switch = |
| 1035 | 1048 | renesas_sdhi_start_signal_voltage_switch; |
| 1036 | 1049 | host->sdcard_irq_setbit_mask = TMIO_STAT_ALWAYS_SET_27; |
| 1050 | + host->sdcard_irq_mask_all = TMIO_MASK_ALL_RCAR2; | |
| 1037 | 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 | 1090 | if (ret) |
| 1077 | 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 | 1097 | ver = sd_ctrl_read16(host, CTL_VERSION); |
| 1080 | 1098 | /* GEN2_SDR104 is first known SDHI to use 32bit block count */ |
| 1081 | 1099 | if (ver < SDHI_VER_GEN2_SDR104 && mmc_data->max_blk_count > U16_MAX) |
| @@ -97,7 +97,7 @@ static const struct renesas_sdhi_of_data of_rza2_compatible = { · 96 unmodified lines | ||
| 97 | 97 | TMIO_MMC_HAVE_CBSY, |
| 98 | 98 | .tmio_ocr_mask = MMC_VDD_32_33, |
| 99 | 99 | .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | |
| 100 | − MMC_CAP_CMD23, | |
| 100 | + MMC_CAP_CMD23 | MMC_CAP_WAIT_WHILE_BUSY, | |
| 101 | 101 | .bus_shift = 2, |
| 102 | 102 | .scc_offset = 0 - 0x1000, |
| 103 | 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 | 111 | .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL | |
| 112 | 112 | TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2, |
| 113 | 113 | .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | |
| 114 | − MMC_CAP_CMD23, | |
| 114 | + MMC_CAP_CMD23 | MMC_CAP_WAIT_WHILE_BUSY, | |
| 115 | 115 | .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT | MMC_CAP2_MERGE_CAPABLE, |
| 116 | 116 | .bus_shift = 2, |
| 117 | 117 | .scc_offset = 0x1000, |
| @@ -33,12 +33,14 @@ static const struct renesas_sdhi_of_data of_rz_compatible = { · 32 unmodified lines | ||
| 33 | 33 | .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_32BIT_DATA_PORT | |
| 34 | 34 | TMIO_MMC_HAVE_CBSY, |
| 35 | 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 | |
| 39 | 40 | static const struct renesas_sdhi_of_data of_rcar_gen1_compatible = { |
| 40 | 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 | 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 | 60 | .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL | |
| 59 | 61 | TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2, |
| 60 | 62 | .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | |
| 61 | − MMC_CAP_CMD23, | |
| 63 | + MMC_CAP_CMD23 | MMC_CAP_WAIT_WHILE_BUSY, | |
| 62 | 64 | .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT, |
| 63 | 65 | .dma_buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES, |
| 64 | 66 | .dma_rx_offset = 0x2000, |
| @@ -772,6 +772,7 @@ static const struct sdhci_acpi_uid_slot sdhci_acpi_uids[] = { · 771 unmodified lines | ||
| 772 | 772 | { "QCOM8051", NULL, &sdhci_acpi_slot_qcom_sd_3v }, |
| 773 | 773 | { "QCOM8052", NULL, &sdhci_acpi_slot_qcom_sd }, |
| 774 | 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 | 790 | { "QCOM8051" }, |
| 790 | 791 | { "QCOM8052" }, |
| 791 | 792 | { "AMDI0040" }, |
| 793 | + { "AMDI0041" }, | |
| 792 | 794 | { }, |
| 793 | 795 | }; |
| 794 | 796 | MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids); |
| @@ -199,7 +199,6 @@ static int sdhci_brcmstb_add_host(struct sdhci_host *host, · 198 unmodified lines | ||
| 199 | 199 | if (dma64) { |
| 200 | 200 | dev_dbg(mmc_dev(host->mmc), "Using 64 bit DMA\n"); |
| 201 | 201 | cq_host->caps |= CQHCI_TASK_DESC_SZ_128; |
| 202 | − cq_host->quirks |= CQHCI_QUIRK_SHORT_TXFR_DESC_SZ; | |
| 203 | 202 | } |
| 204 | 203 | |
| 205 | 204 | ret = cqhci_init(cq_host, host->mmc, dma64); |
| @@ -434,10 +434,10 @@ static u32 esdhc_readl_le(struct sdhci_host *host, int reg) · 433 unmodified lines | ||
| 434 | 434 | * Do not advertise faster UHS modes if there are no |
| 435 | 435 | * pinctrl states for 100MHz/200MHz. |
| 436 | 436 | */ |
| 437 | − if (IS_ERR_OR_NULL(imx_data->pins_100mhz) || | |
| 438 | − IS_ERR_OR_NULL(imx_data->pins_200mhz)) | |
| 439 | − val &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_DDR50 | |
| 440 | − | SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_HS400); | |
| 437 | + if (IS_ERR_OR_NULL(imx_data->pins_100mhz)) | |
| 438 | + val &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_DDR50); | |
| 439 | + if (IS_ERR_OR_NULL(imx_data->pins_200mhz)) | |
| 440 | + val &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_HS400); | |
| 441 | 441 | } |
| 442 | 442 | } |
| 443 | 443 | |
| @@ -1453,7 +1453,6 @@ static const struct cqhci_host_ops esdhc_cqhci_ops = { · 1009 unmodified lines | ||
| 1453 | 1453 | .dumpregs = esdhc_sdhci_dumpregs, |
| 1454 | 1454 | }; |
| 1455 | 1455 | |
| 1456 | −#ifdef CONFIG_OF | |
| 1457 | 1456 | static int |
| 1458 | 1457 | sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, |
| 1459 | 1458 | struct sdhci_host *host, |
| @@ -1486,9 +1485,9 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, · 26 unmodified lines | ||
| 1486 | 1485 | if (of_property_read_u32(np, "fsl,delay-line", &boarddata->delay_line)) |
| 1487 | 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 | 1491 | imx_data->pins_100mhz = pinctrl_lookup_state(imx_data->pinctrl, |
| 1493 | 1492 | ESDHC_PINCTRL_STATE_100MHZ); |
| 1494 | 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 | 1505 | return 0; |
| 1507 | 1506 | } |
| 1508 | −#else | |
| 1509 | −static inline int | |
| 1510 | −sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, | |
| 1511 | − struct sdhci_host *host, | |
| 1512 | − struct pltfm_imx_data *imx_data) | |
| 1513 | −{ | |
| 1514 | − return -ENODEV; | |
| 1515 | −} | |
| 1516 | −#endif | |
| 1517 | 1507 | |
| 1518 | 1508 | static 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 | 1510 | struct sdhci_pltfm_host *pltfm_host; |
| 1523 | 1511 | struct sdhci_host *host; |
| 1524 | 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 | 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 | 1527 | if (imx_data->socdata->flags & ESDHC_FLAG_PMQOS) |
| 1540 | 1528 | cpu_latency_qos_add_request(&imx_data->pm_qos_req, 0); |
| @@ -367,14 +367,14 @@ static int esdhc_mcf_plat_init(struct sdhci_host *host, · 366 unmodified lines | ||
| 367 | 367 | struct pltfm_mcf_data *mcf_data) |
| 368 | 368 | { |
| 369 | 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 | − dev_err(mmc_dev(host->mmc), "no platform data!\n"); | |
| 372 | + if (!dev->platform_data) { | |
| 373 | + dev_err(dev, "no platform data!\n"); | |
| 373 | 374 | return -EINVAL; |
| 374 | 375 | } |
| 375 | 376 | |
| 376 | − plat_data = (struct mcf_esdhc_platform_data *) | |
| 377 | − host->mmc->parent->platform_data; | |
| 377 | + plat_data = (struct mcf_esdhc_platform_data *)dev->platform_data; | |
| 378 | 378 | |
| 379 | 379 | /* Card_detect */ |
| 380 | 380 | switch (plat_data->cd_type) { |
| @@ -1863,7 +1863,6 @@ static int sdhci_msm_ice_init(struct sdhci_msm_host *msm_host, · 1862 unmodified lines | ||
| 1863 | 1863 | struct mmc_host *mmc = msm_host->mmc; |
| 1864 | 1864 | struct device *dev = mmc_dev(mmc); |
| 1865 | 1865 | struct resource *res; |
| 1866 | − int err; | |
| 1867 | 1866 | |
| 1868 | 1867 | if (!(cqhci_readl(cq_host, CQHCI_CAP) & CQHCI_CAP_CS)) |
| 1869 | 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 | 1882 | msm_host->ice_mem = devm_ioremap_resource(dev, res); |
| 1884 | − if (IS_ERR(msm_host->ice_mem)) { | |
| 1885 | − err = PTR_ERR(msm_host->ice_mem); | |
| 1886 | − dev_err(dev, "Failed to map ICE registers; err=%d\n", err); | |
| 1887 | − return err; | |
| 1888 | − } | |
| 1883 | + if (IS_ERR(msm_host->ice_mem)) | |
| 1884 | + return PTR_ERR(msm_host->ice_mem); | |
| 1889 | 1885 | |
| 1890 | 1886 | if (!sdhci_msm_ice_supported(msm_host)) |
| 1891 | 1887 | goto disable; |
| @@ -181,7 +181,7 @@ aspeed_sdhci_configure_phase(struct sdhci_host *host, unsigned long rate) · 180 unmodified lines | ||
| 181 | 181 | struct aspeed_sdhci *sdhci; |
| 182 | 182 | struct device *dev; |
| 183 | 183 | |
| 184 | − dev = host->mmc->parent; | |
| 184 | + dev = mmc_dev(host->mmc); | |
| 185 | 185 | sdhci = sdhci_pltfm_priv(sdhci_priv(host)); |
| 186 | 186 | |
| 187 | 187 | if (!sdhci->phase_desc) |
| @@ -7,11 +7,14 @@ · 6 unmodified lines | ||
| 7 | 7 | * Author: Jisheng Zhang <jszhang@kernel.org> |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | +#include <linux/acpi.h> | |
| 10 | 11 | #include <linux/clk.h> |
| 11 | 12 | #include <linux/dma-mapping.h> |
| 13 | +#include <linux/iopoll.h> | |
| 12 | 14 | #include <linux/kernel.h> |
| 13 | 15 | #include <linux/module.h> |
| 14 | 16 | #include <linux/of.h> |
| 17 | +#include <linux/of_device.h> | |
| 15 | 18 | #include <linux/sizes.h> |
| 16 | 19 | |
| 17 | 20 | #include "sdhci-pltfm.h" |
| @@ -21,11 +24,52 @@ · 3 unmodified lines | ||
| 21 | 24 | /* DWCMSHC specific Mode Select value */ |
| 22 | 25 | #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 | 60 | #define BOUNDARY_OK(addr, len) \ |
| 25 | 61 | ((addr | (SZ_128M - 1)) == ((addr + len - 1) | (SZ_128M - 1))) |
| 26 | 62 | |
| 63 | +struct rk3568_priv { | |
| 64 | + /* Rockchip specified optional clocks */ | |
| 65 | + struct clk_bulk_data rockchip_clks[RK3568_MAX_CLKS]; | |
| 66 | + u8 txclk_tapnum; | |
| 67 | +}; | |
| 68 | + | |
| 27 | 69 | struct dwcmshc_priv { |
| 28 | 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 | 95 | sdhci_adma_write_desc(host, desc, addr, len, cmd); |
| 52 | 96 | } |
| 53 | 97 | |
| 98 | +static unsigned int dwcmshc_get_max_clock(struct sdhci_host *host) | |
| 99 | +{ | |
| 100 | + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | |
| 101 | + | |
| 102 | + if (pltfm_host->clk) | |
| 103 | + return sdhci_pltfm_clk_get_max_clock(host); | |
| 104 | + else | |
| 105 | + return pltfm_host->clock; | |
| 106 | +} | |
| 107 | + | |
| 54 | 108 | static void dwcmshc_check_auto_cmd23(struct mmc_host *mmc, |
| 55 | 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 | 154 | sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2); |
| 101 | 155 | } |
| 102 | 156 | |
| 157 | +static void dwcmshc_hs400_enhanced_strobe(struct mmc_host *mmc, | |
| 158 | + struct mmc_ios *ios) | |
| 159 | +{ | |
| 160 | + u32 vendor; | |
| 161 | + struct sdhci_host *host = mmc_priv(mmc); | |
| 162 | + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | |
| 163 | + struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); | |
| 164 | + int reg = priv->vendor_specific_area1 + DWCMSHC_EMMC_CONTROL; | |
| 165 | + | |
| 166 | + vendor = sdhci_readl(host, reg); | |
| 167 | + if (ios->enhanced_strobe) | |
| 168 | + vendor |= DWCMSHC_ENHANCED_STROBE; | |
| 169 | + else | |
| 170 | + vendor &= ~DWCMSHC_ENHANCED_STROBE; | |
| 171 | + | |
| 172 | + sdhci_writel(host, vendor, reg); | |
| 173 | +} | |
| 174 | + | |
| 175 | +static void dwcmshc_rk3568_set_clock(struct sdhci_host *host, unsigned int clock) | |
| 176 | +{ | |
| 177 | + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | |
| 178 | + struct dwcmshc_priv *dwc_priv = sdhci_pltfm_priv(pltfm_host); | |
| 179 | + struct rk3568_priv *priv = dwc_priv->priv; | |
| 180 | + u8 txclk_tapnum = DLL_TXCLK_TAPNUM_DEFAULT; | |
| 181 | + u32 extra, reg; | |
| 182 | + int err; | |
| 183 | + | |
| 184 | + host->mmc->actual_clock = 0; | |
| 185 | + | |
| 186 | + /* | |
| 187 | + * DO NOT TOUCH THIS SETTING. RX clk inverter unit is enabled | |
| 188 | + * by default, but it shouldn't be enabled. We should anyway | |
| 189 | + * disable it before issuing any cmds. | |
| 190 | + */ | |
| 191 | + extra = DWCMSHC_EMMC_DLL_DLYENA | | |
| 192 | + DLL_RXCLK_NO_INVERTER << DWCMSHC_EMMC_DLL_RXCLK_SRCSEL; | |
| 193 | + sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_RXCLK); | |
| 194 | + | |
| 195 | + if (clock == 0) | |
| 196 | + return; | |
| 197 | + | |
| 198 | + /* Rockchip platform only support 375KHz for identify mode */ | |
| 199 | + if (clock <= 400000) | |
| 200 | + clock = 375000; | |
| 201 | + | |
| 202 | + err = clk_set_rate(pltfm_host->clk, clock); | |
| 203 | + if (err) | |
| 204 | + dev_err(mmc_dev(host->mmc), "fail to set clock %d", clock); | |
| 205 | + | |
| 206 | + sdhci_set_clock(host, clock); | |
| 207 | + | |
| 208 | + /* Disable cmd conflict check */ | |
| 209 | + reg = dwc_priv->vendor_specific_area1 + DWCMSHC_HOST_CTRL3; | |
| 210 | + extra = sdhci_readl(host, reg); | |
| 211 | + extra &= ~BIT(0); | |
| 212 | + sdhci_writel(host, extra, reg); | |
| 213 | + | |
| 214 | + if (clock <= 400000) { | |
| 215 | + /* Disable DLL to reset sample clock */ | |
| 216 | + sdhci_writel(host, 0, DWCMSHC_EMMC_DLL_CTRL); | |
| 217 | + return; | |
| 218 | + } | |
| 219 | + | |
| 220 | + /* Reset DLL */ | |
| 221 | + sdhci_writel(host, BIT(1), DWCMSHC_EMMC_DLL_CTRL); | |
| 222 | + udelay(1); | |
| 223 | + sdhci_writel(host, 0x0, DWCMSHC_EMMC_DLL_CTRL); | |
| 224 | + | |
| 225 | + /* Init DLL settings */ | |
| 226 | + extra = 0x5 << DWCMSHC_EMMC_DLL_START_POINT | | |
| 227 | + 0x2 << DWCMSHC_EMMC_DLL_INC | | |
| 228 | + DWCMSHC_EMMC_DLL_START; | |
| 229 | + sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_CTRL); | |
| 230 | + err = readl_poll_timeout(host->ioaddr + DWCMSHC_EMMC_DLL_STATUS0, | |
| 231 | + extra, DLL_LOCK_WO_TMOUT(extra), 1, | |
| 232 | + 500 * USEC_PER_MSEC); | |
| 233 | + if (err) { | |
| 234 | + dev_err(mmc_dev(host->mmc), "DLL lock timeout!\n"); | |
| 235 | + return; | |
| 236 | + } | |
| 237 | + | |
| 238 | + extra = 0x1 << 16 | /* tune clock stop en */ | |
| 239 | + 0x2 << 17 | /* pre-change delay */ | |
| 240 | + 0x3 << 19; /* post-change delay */ | |
| 241 | + sdhci_writel(host, extra, dwc_priv->vendor_specific_area1 + DWCMSHC_EMMC_ATCTRL); | |
| 242 | + | |
| 243 | + if (host->mmc->ios.timing == MMC_TIMING_MMC_HS200 || | |
| 244 | + host->mmc->ios.timing == MMC_TIMING_MMC_HS400) | |
| 245 | + txclk_tapnum = priv->txclk_tapnum; | |
| 246 | + | |
| 247 | + extra = DWCMSHC_EMMC_DLL_DLYENA | | |
| 248 | + DLL_TXCLK_TAPNUM_FROM_SW | | |
| 249 | + txclk_tapnum; | |
| 250 | + sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_TXCLK); | |
| 251 | + | |
| 252 | + extra = DWCMSHC_EMMC_DLL_DLYENA | | |
| 253 | + DLL_STRBIN_TAPNUM_DEFAULT | | |
| 254 | + DLL_STRBIN_TAPNUM_FROM_SW; | |
| 255 | + sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_STRBIN); | |
| 256 | +} | |
| 257 | + | |
| 103 | 258 | static const struct sdhci_ops sdhci_dwcmshc_ops = { |
| 104 | 259 | .set_clock = sdhci_set_clock, |
| 105 | 260 | .set_bus_width = sdhci_set_bus_width, |
| 106 | 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 | + | |
| 267 | +static const struct sdhci_ops sdhci_dwcmshc_rk3568_ops = { | |
| 268 | + .set_clock = dwcmshc_rk3568_set_clock, | |
| 269 | + .set_bus_width = sdhci_set_bus_width, | |
| 270 | + .set_uhs_signaling = dwcmshc_set_uhs_signaling, | |
| 107 | 271 | .get_max_clock = sdhci_pltfm_clk_get_max_clock, |
| 108 | 272 | .reset = sdhci_reset, |
| 109 | 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 | 279 | .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, |
| 116 | 280 | }; |
| 117 | 281 | |
| 282 | +static const struct sdhci_pltfm_data sdhci_dwcmshc_rk3568_pdata = { | |
| 283 | + .ops = &sdhci_dwcmshc_rk3568_ops, | |
| 284 | + .quirks = SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN | | |
| 285 | + SDHCI_QUIRK_BROKEN_TIMEOUT_VAL, | |
| 286 | + .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | | |
| 287 | + SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN, | |
| 288 | +}; | |
| 289 | + | |
| 290 | +static int dwcmshc_rk3568_init(struct sdhci_host *host, struct dwcmshc_priv *dwc_priv) | |
| 291 | +{ | |
| 292 | + int err; | |
| 293 | + struct rk3568_priv *priv = dwc_priv->priv; | |
| 294 | + | |
| 295 | + priv->rockchip_clks[0].id = "axi"; | |
| 296 | + priv->rockchip_clks[1].id = "block"; | |
| 297 | + priv->rockchip_clks[2].id = "timer"; | |
| 298 | + err = devm_clk_bulk_get_optional(mmc_dev(host->mmc), RK3568_MAX_CLKS, | |
| 299 | + priv->rockchip_clks); | |
| 300 | + if (err) { | |
| 301 | + dev_err(mmc_dev(host->mmc), "failed to get clocks %d\n", err); | |
| 302 | + return err; | |
| 303 | + } | |
| 304 | + | |
| 305 | + err = clk_bulk_prepare_enable(RK3568_MAX_CLKS, priv->rockchip_clks); | |
| 306 | + if (err) { | |
| 307 | + dev_err(mmc_dev(host->mmc), "failed to enable clocks %d\n", err); | |
| 308 | + return err; | |
| 309 | + } | |
| 310 | + | |
| 311 | + if (of_property_read_u8(mmc_dev(host->mmc)->of_node, "rockchip,txclk-tapnum", | |
| 312 | + &priv->txclk_tapnum)) | |
| 313 | + priv->txclk_tapnum = DLL_TXCLK_TAPNUM_DEFAULT; | |
| 314 | + | |
| 315 | + /* Disable cmd conflict check */ | |
| 316 | + sdhci_writel(host, 0x0, dwc_priv->vendor_specific_area1 + DWCMSHC_HOST_CTRL3); | |
| 317 | + /* Reset previous settings */ | |
| 318 | + sdhci_writel(host, 0, DWCMSHC_EMMC_DLL_TXCLK); | |
| 319 | + sdhci_writel(host, 0, DWCMSHC_EMMC_DLL_STRBIN); | |
| 320 | + | |
| 321 | + return 0; | |
| 322 | +} | |
| 323 | + | |
| 324 | +static const struct of_device_id sdhci_dwcmshc_dt_ids[] = { | |
| 325 | + { | |
| 326 | + .compatible = "rockchip,rk3568-dwcmshc", | |
| 327 | + .data = &sdhci_dwcmshc_rk3568_pdata, | |
| 328 | + }, | |
| 329 | + { | |
| 330 | + .compatible = "snps,dwcmshc-sdhci", | |
| 331 | + .data = &sdhci_dwcmshc_pdata, | |
| 332 | + }, | |
| 333 | + {}, | |
| 334 | +}; | |
| 335 | +MODULE_DEVICE_TABLE(of, sdhci_dwcmshc_dt_ids); | |
| 336 | + | |
| 337 | +#ifdef CONFIG_ACPI | |
| 338 | +static const struct acpi_device_id sdhci_dwcmshc_acpi_ids[] = { | |
| 339 | + { .id = "MLNXBF30" }, | |
| 340 | + {} | |
| 341 | +}; | |
| 342 | +#endif | |
| 343 | + | |
| 118 | 344 | static int dwcmshc_probe(struct platform_device *pdev) |
| 119 | 345 | { |
| 346 | + struct device *dev = &pdev->dev; | |
| 120 | 347 | struct sdhci_pltfm_host *pltfm_host; |
| 121 | 348 | struct sdhci_host *host; |
| 122 | 349 | struct dwcmshc_priv *priv; |
| 350 | + struct rk3568_priv *rk_priv = NULL; | |
| 351 | + const struct sdhci_pltfm_data *pltfm_data; | |
| 123 | 352 | int err; |
| 124 | 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 | 362 | sizeof(struct dwcmshc_priv)); |
| 128 | 363 | if (IS_ERR(host)) |
| 129 | 364 | return PTR_ERR(host); |
| @@ -131,7 +366,7 @@ static int dwcmshc_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 131 | 366 | /* |
| 132 | 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 | 370 | if (extra > SDHCI_MAX_SEGS) |
| 136 | 371 | extra = SDHCI_MAX_SEGS; |
| 137 | 372 | host->adma_table_cnt += extra; |
| @@ -139,19 +374,21 @@ static int dwcmshc_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 139 | 374 | pltfm_host = sdhci_priv(host); |
| 140 | 375 | priv = sdhci_pltfm_priv(pltfm_host); |
| 141 | 376 | |
| 142 | − pltfm_host->clk = devm_clk_get(&pdev->dev, "core"); | |
| 143 | − if (IS_ERR(pltfm_host->clk)) { | |
| 144 | − err = PTR_ERR(pltfm_host->clk); | |
| 145 | − dev_err(&pdev->dev, "failed to get core clk: %d\n", err); | |
| 146 | − goto free_pltfm; | |
| 377 | + if (dev->of_node) { | |
| 378 | + pltfm_host->clk = devm_clk_get(dev, "core"); | |
| 379 | + if (IS_ERR(pltfm_host->clk)) { | |
| 380 | + err = PTR_ERR(pltfm_host->clk); | |
| 381 | + dev_err(dev, "failed to get core clk: %d\n", err); | |
| 382 | + goto free_pltfm; | |
| 383 | + } | |
| 384 | + err = clk_prepare_enable(pltfm_host->clk); | |
| 385 | + if (err) | |
| 386 | + goto free_pltfm; | |
| 387 | + | |
| 388 | + priv->bus_clk = devm_clk_get(dev, "bus"); | |
| 389 | + if (!IS_ERR(priv->bus_clk)) | |
| 390 | + clk_prepare_enable(priv->bus_clk); | |
| 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 | 393 | err = mmc_of_parse(host->mmc); |
| 157 | 394 | if (err) |
| @@ -159,7 +396,27 @@ static int dwcmshc_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 159 | 396 | |
| 160 | 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 | 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 | 421 | err = sdhci_add_host(host); |
| 165 | 422 | if (err) |
| @@ -170,6 +427,9 @@ static int dwcmshc_probe(struct platform_device *pdev) · 4 unmodified lines | ||
| 170 | 427 | err_clk: |
| 171 | 428 | clk_disable_unprepare(pltfm_host->clk); |
| 172 | 429 | clk_disable_unprepare(priv->bus_clk); |
| 430 | + if (rk_priv) | |
| 431 | + clk_bulk_disable_unprepare(RK3568_MAX_CLKS, | |
| 432 | + rk_priv->rockchip_clks); | |
| 173 | 433 | free_pltfm: |
| 174 | 434 | sdhci_pltfm_free(pdev); |
| 175 | 435 | return err; |
| @@ -180,12 +440,15 @@ static int dwcmshc_remove(struct platform_device *pdev) · 4 unmodified lines | ||
| 180 | 440 | struct sdhci_host *host = platform_get_drvdata(pdev); |
| 181 | 441 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 182 | 442 | struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); |
| 443 | + struct rk3568_priv *rk_priv = priv->priv; | |
| 183 | 444 | |
| 184 | 445 | sdhci_remove_host(host, 0); |
| 185 | 446 | |
| 186 | 447 | clk_disable_unprepare(pltfm_host->clk); |
| 187 | 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 | 452 | sdhci_pltfm_free(pdev); |
| 190 | 453 | |
| 191 | 454 | return 0; |
| @@ -197,6 +460,7 @@ static int dwcmshc_suspend(struct device *dev) · 5 unmodified lines | ||
| 197 | 460 | struct sdhci_host *host = dev_get_drvdata(dev); |
| 198 | 461 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 199 | 462 | struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); |
| 463 | + struct rk3568_priv *rk_priv = priv->priv; | |
| 200 | 464 | int ret; |
| 201 | 465 | |
| 202 | 466 | ret = sdhci_suspend_host(host); |
| @@ -207,6 +471,10 @@ static int dwcmshc_suspend(struct device *dev) · 4 unmodified lines | ||
| 207 | 471 | if (!IS_ERR(priv->bus_clk)) |
| 208 | 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 | 478 | return ret; |
| 211 | 479 | } |
| 212 | 480 | |
| @@ -215,6 +483,7 @@ static int dwcmshc_resume(struct device *dev) · 2 unmodified lines | ||
| 215 | 483 | struct sdhci_host *host = dev_get_drvdata(dev); |
| 216 | 484 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 217 | 485 | struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); |
| 486 | + struct rk3568_priv *rk_priv = priv->priv; | |
| 218 | 487 | int ret; |
| 219 | 488 | |
| 220 | 489 | ret = clk_prepare_enable(pltfm_host->clk); |
| @@ -227,23 +496,25 @@ static int dwcmshc_resume(struct device *dev) · 6 unmodified lines | ||
| 227 | 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 | 506 | return sdhci_resume_host(host); |
| 231 | 507 | } |
| 232 | 508 | #endif |
| 233 | 509 | |
| 234 | 510 | static SIMPLE_DEV_PM_OPS(dwcmshc_pmops, dwcmshc_suspend, dwcmshc_resume); |
| 235 | 511 | |
| 236 | −static const struct of_device_id sdhci_dwcmshc_dt_ids[] = { | |
| 237 | − { .compatible = "snps,dwcmshc-sdhci" }, | |
| 238 | − {} | |
| 239 | −}; | |
| 240 | −MODULE_DEVICE_TABLE(of, sdhci_dwcmshc_dt_ids); | |
| 241 | − | |
| 242 | 512 | static struct platform_driver sdhci_dwcmshc_driver = { |
| 243 | 513 | .driver = { |
| 244 | 514 | .name = "sdhci-dwcmshc", |
| 245 | 515 | .probe_type = PROBE_PREFER_ASYNCHRONOUS, |
| 246 | 516 | .of_match_table = sdhci_dwcmshc_dt_ids, |
| 517 | + .acpi_match_table = ACPI_PTR(sdhci_dwcmshc_acpi_ids), | |
| 247 | 518 | .pm = &dwcmshc_pmops, |
| 248 | 519 | }, |
| 249 | 520 | .probe = dwcmshc_probe, |
| @@ -1489,7 +1489,7 @@ static int sdhci_esdhc_probe(struct platform_device *pdev) · 1488 unmodified lines | ||
| 1489 | 1489 | if (ret) |
| 1490 | 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 | 1494 | ret = sdhci_add_host(host); |
| 1495 | 1495 | if (ret) |
| @@ -516,6 +516,7 @@ struct intel_host { · 515 unmodified lines | ||
| 516 | 516 | int drv_strength; |
| 517 | 517 | bool d3_retune; |
| 518 | 518 | bool rpm_retune_ok; |
| 519 | + bool needs_pwr_off; | |
| 519 | 520 | u32 glk_rx_ctrl1; |
| 520 | 521 | u32 glk_tun_val; |
| 521 | 522 | u32 active_ltr; |
| @@ -643,9 +644,25 @@ out: · 121 unmodified lines | ||
| 643 | 644 | static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode, |
| 644 | 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 | 649 | int cntr; |
| 647 | 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 | 666 | sdhci_set_power(host, mode, vdd); |
| 650 | 667 | |
| 651 | 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 | 975 | slot->host->mmc->caps2 |= MMC_CAP2_CQE; |
| 959 | 976 | |
| 960 | 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 | 979 | slot->host->mmc_host_ops.hs400_enhanced_strobe = |
| 963 | 980 | intel_hs400_enhanced_strobe; |
| 964 | 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 | 1152 | return 0; |
| 1136 | 1153 | } |
| 1137 | 1154 | |
| 1155 | +static void byt_needs_pwr_off(struct sdhci_pci_slot *slot) | |
| 1156 | +{ | |
| 1157 | + struct intel_host *intel_host = sdhci_pci_priv(slot); | |
| 1158 | + u8 reg = sdhci_readb(slot->host, SDHCI_POWER_CONTROL); | |
| 1159 | + | |
| 1160 | + intel_host->needs_pwr_off = reg & SDHCI_POWER_ON; | |
| 1161 | +} | |
| 1162 | + | |
| 1138 | 1163 | static int byt_sd_probe_slot(struct sdhci_pci_slot *slot) |
| 1139 | 1164 | { |
| 1140 | 1165 | byt_probe_slot(slot); |
| @@ -1152,6 +1177,8 @@ static int byt_sd_probe_slot(struct sdhci_pci_slot *slot) · 11 unmodified lines | ||
| 1152 | 1177 | slot->chip->pdev->subsystem_device == PCI_SUBDEVICE_ID_NI_78E3) |
| 1153 | 1178 | slot->host->mmc->caps2 |= MMC_CAP2_AVOID_3_3V; |
| 1154 | 1179 | |
| 1180 | + byt_needs_pwr_off(slot); | |
| 1181 | + | |
| 1155 | 1182 | return 0; |
| 1156 | 1183 | } |
| 1157 | 1184 | |
| @@ -1903,6 +1930,8 @@ static const struct pci_device_id pci_ids[] = { · 745 unmodified lines | ||
| 1903 | 1930 | SDHCI_PCI_DEVICE(INTEL, CMLH_SD, intel_byt_sd), |
| 1904 | 1931 | SDHCI_PCI_DEVICE(INTEL, JSL_EMMC, intel_glk_emmc), |
| 1905 | 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 | 1935 | SDHCI_PCI_DEVICE(O2, 8120, o2), |
| 1907 | 1936 | SDHCI_PCI_DEVICE(O2, 8220, o2), |
| 1908 | 1937 | SDHCI_PCI_DEVICE(O2, 8221, o2), |
| @@ -22,6 +22,10 @@ · 21 unmodified lines | ||
| 22 | 22 | #define GLI_9750_WT_EN_ON 0x1 |
| 23 | 23 | #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 | 29 | #define SDHCI_GLI_9750_DRIVING 0x860 |
| 26 | 30 | #define SDHCI_GLI_9750_DRIVING_1 GENMASK(11, 0) |
| 27 | 31 | #define SDHCI_GLI_9750_DRIVING_2 GENMASK(27, 26) |
| @@ -90,7 +94,7 @@ · 62 unmodified lines | ||
| 90 | 94 | |
| 91 | 95 | #define PCIE_GLI_9763E_CFG2 0x8A4 |
| 92 | 96 | #define GLI_9763E_CFG2_L1DLY GENMASK(28, 19) |
| 93 | −#define GLI_9763E_CFG2_L1DLY_MAX 0x3FF | |
| 97 | +#define GLI_9763E_CFG2_L1DLY_MID 0x50 | |
| 94 | 98 | |
| 95 | 99 | #define PCIE_GLI_9763E_MMC_CTRL 0x960 |
| 96 | 100 | #define GLI_9763E_HS400_SLOW BIT(3) |
| @@ -113,6 +117,10 @@ · 16 unmodified lines | ||
| 113 | 117 | #define PCI_GLI_9755_LFCLK GENMASK(14, 12) |
| 114 | 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 | 124 | #define PCI_GLI_9755_PLL 0x64 |
| 117 | 125 | #define PCI_GLI_9755_PLL_LDIV GENMASK(9, 0) |
| 118 | 126 | #define PCI_GLI_9755_PLL_PDIV GENMASK(14, 12) |
| @@ -123,6 +131,9 @@ · 4 unmodified lines | ||
| 123 | 131 | #define PCI_GLI_9755_PLLSSC 0x68 |
| 124 | 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 | 137 | #define GLI_MAX_TUNING_LOOP 40 |
| 127 | 138 | |
| 128 | 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 | 416 | sdhci_enable_clk(host, clk); |
| 406 | 417 | } |
| 407 | 418 | |
| 419 | +static void gl9750_hw_setting(struct sdhci_host *host) | |
| 420 | +{ | |
| 421 | + u32 value; | |
| 422 | + | |
| 423 | + gl9750_wt_on(host); | |
| 424 | + | |
| 425 | + value = sdhci_readl(host, SDHCI_GLI_9750_CFG2); | |
| 426 | + value &= ~SDHCI_GLI_9750_CFG2_L1DLY; | |
| 427 | + /* set ASPM L1 entry delay to 7.9us */ | |
| 428 | + value |= FIELD_PREP(SDHCI_GLI_9750_CFG2_L1DLY, | |
| 429 | + GLI_9750_CFG2_L1DLY_VALUE); | |
| 430 | + sdhci_writel(host, value, SDHCI_GLI_9750_CFG2); | |
| 431 | + | |
| 432 | + gl9750_wt_off(host); | |
| 433 | +} | |
| 434 | + | |
| 408 | 435 | static void gli_pcie_enable_msi(struct sdhci_pci_slot *slot) |
| 409 | 436 | { |
| 410 | 437 | int ret; |
| @@ -547,6 +574,18 @@ static void gl9755_hw_setting(struct sdhci_pci_slot *slot) · 136 unmodified lines | ||
| 547 | 574 | value &= ~PCI_GLI_9755_DMACLK; |
| 548 | 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 | 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 | 594 | struct sdhci_host *host = slot->host; |
| 556 | 595 | |
| 596 | + gl9750_hw_setting(host); | |
| 557 | 597 | gli_pcie_enable_msi(slot); |
| 558 | 598 | slot->host->mmc->caps2 |= MMC_CAP2_NO_SDIO; |
| 559 | 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 | 843 | pci_read_config_dword(pdev, PCIE_GLI_9763E_CFG2, &value); |
| 804 | 844 | value &= ~GLI_9763E_CFG2_L1DLY; |
| 805 | − /* set ASPM L1 entry delay to 260us */ | |
| 806 | − value |= FIELD_PREP(GLI_9763E_CFG2_L1DLY, GLI_9763E_CFG2_L1DLY_MAX); | |
| 845 | + /* set ASPM L1 entry delay to 20us */ | |
| 846 | + value |= FIELD_PREP(GLI_9763E_CFG2_L1DLY, GLI_9763E_CFG2_L1DLY_MID); | |
| 807 | 847 | pci_write_config_dword(pdev, PCIE_GLI_9763E_CFG2, value); |
| 808 | 848 | |
| 809 | 849 | pci_read_config_dword(pdev, PCIE_GLI_9763E_CLKRXDLY, &value); |
| @@ -706,6 +706,8 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) · 705 unmodified lines | ||
| 706 | 706 | ret = pci_read_config_dword(chip->pdev, |
| 707 | 707 | O2_SD_FUNC_REG0, |
| 708 | 708 | &scratch_32); |
| 709 | + if (ret) | |
| 710 | + return ret; | |
| 709 | 711 | scratch_32 = ((scratch_32 & 0xFF000000) >> 24); |
| 710 | 712 | |
| 711 | 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 | 718 | ret = pci_read_config_dword(chip->pdev, |
| 717 | 719 | O2_SD_FUNC_REG4, |
| 718 | 720 | &scratch_32); |
| 721 | + if (ret) | |
| 722 | + return ret; | |
| 719 | 723 | |
| 720 | 724 | /* Enable Base Clk setting change */ |
| 721 | 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 | 800 | ret = pci_read_config_dword(chip->pdev, |
| 797 | 801 | O2_SD_PLL_SETTING, &scratch_32); |
| 802 | + if (ret) | |
| 803 | + return ret; | |
| 798 | 804 | |
| 799 | 805 | if ((scratch_32 & 0xff000000) == 0x01000000) { |
| 800 | 806 | scratch_32 &= 0x0000FFFF; |
| @@ -812,6 +818,8 @@ static int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) · 11 unmodified lines | ||
| 812 | 818 | ret = pci_read_config_dword(chip->pdev, |
| 813 | 819 | O2_SD_FUNC_REG4, |
| 814 | 820 | &scratch_32); |
| 821 | + if (ret) | |
| 822 | + return ret; | |
| 815 | 823 | scratch_32 |= (1 << 22); |
| 816 | 824 | pci_write_config_dword(chip->pdev, |
| 817 | 825 | O2_SD_FUNC_REG4, scratch_32); |
| @@ -57,6 +57,8 @@ · 56 unmodified lines | ||
| 57 | 57 | #define PCI_DEVICE_ID_INTEL_CMLH_SD 0x06f5 |
| 58 | 58 | #define PCI_DEVICE_ID_INTEL_JSL_EMMC 0x4dc4 |
| 59 | 59 | #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 | 63 | #define PCI_DEVICE_ID_SYSKONNECT_8000 0x8000 |
| 62 | 64 | #define PCI_DEVICE_ID_VIA_95D0 0x95d0 |
| @@ -20,6 +20,7 @@ · 19 unmodified lines | ||
| 20 | 20 | #include <linux/gpio.h> |
| 21 | 21 | #include <linux/module.h> |
| 22 | 22 | #include <linux/of.h> |
| 23 | +#include <linux/of_device.h> | |
| 23 | 24 | #include <linux/of_gpio.h> |
| 24 | 25 | #include <linux/pm.h> |
| 25 | 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 data | |
| 133 | + * struct sdhci_s3c_drv_data - S3C SDHCI platform specific driver data | |
| 133 | 134 | * @sdhci_quirks: sdhci host specific quirks. |
| 134 | 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 | 463 | #endif |
| 463 | 464 | |
| 464 | −#ifdef CONFIG_OF | |
| 465 | −static const struct of_device_id sdhci_s3c_dt_match[]; | |
| 466 | −#endif | |
| 467 | − | |
| 468 | −static inline struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data( | |
| 465 | +static inline const struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data( | |
| 469 | 466 | struct platform_device *pdev) |
| 470 | 467 | { |
| 471 | 468 | #ifdef CONFIG_OF |
| 472 | − if (pdev->dev.of_node) { | |
| 473 | − const struct of_device_id *match; | |
| 474 | − match = of_match_node(sdhci_s3c_dt_match, pdev->dev.of_node); | |
| 475 | − return (struct sdhci_s3c_drv_data *)match->data; | |
| 476 | − } | |
| 469 | + if (pdev->dev.of_node) | |
| 470 | + return of_device_get_match_data(&pdev->dev); | |
| 477 | 471 | #endif |
| 478 | − return (struct sdhci_s3c_drv_data *) | |
| 472 | + return (const struct sdhci_s3c_drv_data *) | |
| 479 | 473 | platform_get_device_id(pdev)->driver_data; |
| 480 | 474 | } |
| 481 | 475 | |
| 482 | 476 | static int sdhci_s3c_probe(struct platform_device *pdev) |
| 483 | 477 | { |
| 484 | 478 | struct s3c_sdhci_platdata *pdata; |
| 485 | − struct sdhci_s3c_drv_data *drv_data; | |
| 479 | + const struct sdhci_s3c_drv_data *drv_data; | |
| 486 | 480 | struct device *dev = &pdev->dev; |
| 487 | 481 | struct sdhci_host *host; |
| 488 | 482 | struct sdhci_s3c *sc; |
| @@ -767,7 +761,7 @@ static const struct platform_device_id sdhci_s3c_driver_ids[] = { · 278 unmodified lines | ||
| 767 | 761 | MODULE_DEVICE_TABLE(platform, sdhci_s3c_driver_ids); |
| 768 | 762 | |
| 769 | 763 | #ifdef CONFIG_OF |
| 770 | −static struct sdhci_s3c_drv_data exynos4_sdhci_drv_data = { | |
| 764 | +static const struct sdhci_s3c_drv_data exynos4_sdhci_drv_data = { | |
| 771 | 765 | .no_divider = true, |
| 772 | 766 | }; |
| 773 | 767 | |
| @@ -362,11 +362,10 @@ static int sdhci_st_probe(struct platform_device *pdev) · 361 unmodified lines | ||
| 362 | 362 | if (IS_ERR(icnclk)) |
| 363 | 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 | 366 | if (IS_ERR(rstc)) |
| 367 | − rstc = NULL; | |
| 368 | − else | |
| 369 | − reset_control_deassert(rstc); | |
| 367 | + return PTR_ERR(rstc); | |
| 368 | + reset_control_deassert(rstc); | |
| 370 | 369 | |
| 371 | 370 | host = sdhci_pltfm_init(pdev, &sdhci_st_pdata, sizeof(*pdata)); |
| 372 | 371 | if (IS_ERR(host)) { |
| @@ -401,10 +400,8 @@ static int sdhci_st_probe(struct platform_device *pdev) · 28 unmodified lines | ||
| 401 | 400 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, |
| 402 | 401 | "top-mmc-delay"); |
| 403 | 402 | pdata->top_ioaddr = devm_ioremap_resource(&pdev->dev, res); |
| 404 | − if (IS_ERR(pdata->top_ioaddr)) { | |
| 405 | − dev_warn(&pdev->dev, "FlashSS Top Dly registers not available"); | |
| 403 | + if (IS_ERR(pdata->top_ioaddr)) | |
| 406 | 404 | pdata->top_ioaddr = NULL; |
| 407 | − } | |
| 408 | 405 | |
| 409 | 406 | pltfm_host->clk = clk; |
| 410 | 407 | pdata->icnclk = icnclk; |
| @@ -432,8 +429,7 @@ err_icnclk: · 21 unmodified lines | ||
| 432 | 429 | err_of: |
| 433 | 430 | sdhci_pltfm_free(pdev); |
| 434 | 431 | err_pltfm_init: |
| 435 | − if (rstc) | |
| 436 | − reset_control_assert(rstc); | |
| 432 | + reset_control_assert(rstc); | |
| 437 | 433 | |
| 438 | 434 | return ret; |
| 439 | 435 | } |
| @@ -450,8 +446,7 @@ static int sdhci_st_remove(struct platform_device *pdev) · 10 unmodified lines | ||
| 450 | 446 | |
| 451 | 447 | clk_disable_unprepare(pdata->icnclk); |
| 452 | 448 | |
| 453 | − if (rstc) | |
| 454 | − reset_control_assert(rstc); | |
| 449 | + reset_control_assert(rstc); | |
| 455 | 450 | |
| 456 | 451 | return ret; |
| 457 | 452 | } |
| @@ -471,8 +466,7 @@ static int sdhci_st_suspend(struct device *dev) · 13 unmodified lines | ||
| 471 | 466 | if (ret) |
| 472 | 467 | goto out; |
| 473 | 468 | |
| 474 | − if (pdata->rstc) | |
| 475 | − reset_control_assert(pdata->rstc); | |
| 469 | + reset_control_assert(pdata->rstc); | |
| 476 | 470 | |
| 477 | 471 | clk_disable_unprepare(pdata->icnclk); |
| 478 | 472 | clk_disable_unprepare(pltfm_host->clk); |
| @@ -498,8 +492,7 @@ static int sdhci_st_resume(struct device *dev) · 19 unmodified lines | ||
| 498 | 492 | return ret; |
| 499 | 493 | } |
| 500 | 494 | |
| 501 | − if (pdata->rstc) | |
| 502 | − reset_control_deassert(pdata->rstc); | |
| 495 | + reset_control_deassert(pdata->rstc); | |
| 503 | 496 | |
| 504 | 497 | st_mmcss_cconfig(np, host); |
| 505 | 498 | |
| @@ -119,6 +119,10 @@ · 118 unmodified lines | ||
| 119 | 119 | /* SDMMC CQE Base Address for Tegra Host Ver 4.1 and Higher */ |
| 120 | 120 | #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 | + | |
| 122 | 126 | struct sdhci_tegra_soc_data { |
| 123 | 127 | const struct sdhci_pltfm_data *pdata; |
| 124 | 128 | u64 dma_mask; |
| @@ -596,49 +600,49 @@ static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host *host) · 471 unmodified lines | ||
| 596 | 600 | &tegra_host->autocal_offsets; |
| 597 | 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 | 604 | "nvidia,pad-autocal-pull-up-offset-3v3", |
| 601 | 605 | &autocal->pull_up_3v3); |
| 602 | 606 | if (err) |
| 603 | 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 | 610 | "nvidia,pad-autocal-pull-down-offset-3v3", |
| 607 | 611 | &autocal->pull_down_3v3); |
| 608 | 612 | if (err) |
| 609 | 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 | 616 | "nvidia,pad-autocal-pull-up-offset-1v8", |
| 613 | 617 | &autocal->pull_up_1v8); |
| 614 | 618 | if (err) |
| 615 | 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 | 622 | "nvidia,pad-autocal-pull-down-offset-1v8", |
| 619 | 623 | &autocal->pull_down_1v8); |
| 620 | 624 | if (err) |
| 621 | 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 | 628 | "nvidia,pad-autocal-pull-up-offset-sdr104", |
| 625 | 629 | &autocal->pull_up_sdr104); |
| 626 | 630 | if (err) |
| 627 | 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 | 634 | "nvidia,pad-autocal-pull-down-offset-sdr104", |
| 631 | 635 | &autocal->pull_down_sdr104); |
| 632 | 636 | if (err) |
| 633 | 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 | 640 | "nvidia,pad-autocal-pull-up-offset-hs400", |
| 637 | 641 | &autocal->pull_up_hs400); |
| 638 | 642 | if (err) |
| 639 | 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 | 646 | "nvidia,pad-autocal-pull-down-offset-hs400", |
| 643 | 647 | &autocal->pull_down_hs400); |
| 644 | 648 | if (err) |
| @@ -653,7 +657,7 @@ static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host *host) · 8 unmodified lines | ||
| 653 | 657 | if (!(tegra_host->soc_data->nvquirks & NVQUIRK_NEEDS_PAD_CONTROL)) |
| 654 | 658 | return; |
| 655 | 659 | |
| 656 | − err = device_property_read_u32(host->mmc->parent, | |
| 660 | + err = device_property_read_u32(mmc_dev(host->mmc), | |
| 657 | 661 | "nvidia,pad-autocal-pull-up-offset-3v3-timeout", |
| 658 | 662 | &autocal->pull_up_3v3_timeout); |
| 659 | 663 | if (err) { |
| @@ -664,7 +668,7 @@ static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host *host) · 4 unmodified lines | ||
| 664 | 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 | 672 | "nvidia,pad-autocal-pull-down-offset-3v3-timeout", |
| 669 | 673 | &autocal->pull_down_3v3_timeout); |
| 670 | 674 | if (err) { |
| @@ -675,7 +679,7 @@ static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host *host) · 4 unmodified lines | ||
| 675 | 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 | 683 | "nvidia,pad-autocal-pull-up-offset-1v8-timeout", |
| 680 | 684 | &autocal->pull_up_1v8_timeout); |
| 681 | 685 | if (err) { |
| @@ -686,7 +690,7 @@ static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host *host) · 4 unmodified lines | ||
| 686 | 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 | 694 | "nvidia,pad-autocal-pull-down-offset-1v8-timeout", |
| 691 | 695 | &autocal->pull_down_1v8_timeout); |
| 692 | 696 | if (err) { |
| @@ -720,17 +724,17 @@ static void tegra_sdhci_parse_tap_and_trim(struct sdhci_host *host) · 27 unmodified lines | ||
| 720 | 724 | struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host); |
| 721 | 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 | 728 | &tegra_host->default_tap); |
| 725 | 729 | if (err) |
| 726 | 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 | 733 | &tegra_host->default_trim); |
| 730 | 734 | if (err) |
| 731 | 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 | 738 | &tegra_host->dqs_trim); |
| 735 | 739 | if (err) |
| 736 | 740 | tegra_host->dqs_trim = 0x11; |
| @@ -741,7 +745,7 @@ static void tegra_sdhci_parse_dt(struct sdhci_host *host) · 4 unmodified lines | ||
| 741 | 745 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 742 | 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 | 749 | tegra_host->enable_hwcq = true; |
| 746 | 750 | else |
| 747 | 751 | tegra_host->enable_hwcq = false; |
| @@ -1156,6 +1160,7 @@ static void tegra_sdhci_voltage_switch(struct sdhci_host *host) · 408 unmodified lines | ||
| 1156 | 1160 | static void tegra_cqhci_writel(struct cqhci_host *cq_host, u32 val, int reg) |
| 1157 | 1161 | { |
| 1158 | 1162 | struct mmc_host *mmc = cq_host->mmc; |
| 1163 | + struct sdhci_host *host = mmc_priv(mmc); | |
| 1159 | 1164 | u8 ctrl; |
| 1160 | 1165 | ktime_t timeout; |
| 1161 | 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 | 1176 | if (reg == CQHCI_CTL && !(val & CQHCI_HALT) && |
| 1172 | 1177 | cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT) { |
| 1178 | + sdhci_writew(host, SDHCI_TEGRA_CQE_TRNS_MODE, SDHCI_TRANSFER_MODE); | |
| 1173 | 1179 | sdhci_cqe_enable(mmc); |
| 1174 | 1180 | writel(val, cq_host->mmio + reg); |
| 1175 | 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 | ||
| 1205 | 1211 | static void sdhci_tegra_cqe_enable(struct mmc_host *mmc) |
| 1206 | 1212 | { |
| 1207 | 1213 | struct cqhci_host *cq_host = mmc->cqe_private; |
| 1214 | + struct sdhci_host *host = mmc_priv(mmc); | |
| 1208 | 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 | 1225 | if (val & CQHCI_ENABLE) |
| 1219 | 1226 | cqhci_writel(cq_host, (val & ~CQHCI_ENABLE), |
| 1220 | 1227 | CQHCI_CFG); |
| 1228 | + sdhci_writew(host, SDHCI_TEGRA_CQE_TRNS_MODE, SDHCI_TRANSFER_MODE); | |
| 1221 | 1229 | sdhci_cqe_enable(mmc); |
| 1222 | 1230 | if (val & CQHCI_ENABLE) |
| 1223 | 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 | 1289 | __sdhci_set_timeout(host, cmd); |
| 1282 | 1290 | } |
| 1283 | 1291 | |
| 1292 | +static void sdhci_tegra_cqe_pre_enable(struct mmc_host *mmc) | |
| 1293 | +{ | |
| 1294 | + struct cqhci_host *cq_host = mmc->cqe_private; | |
| 1295 | + u32 reg; | |
| 1296 | + | |
| 1297 | + reg = cqhci_readl(cq_host, CQHCI_CFG); | |
| 1298 | + reg |= CQHCI_ENABLE; | |
| 1299 | + cqhci_writel(cq_host, reg, CQHCI_CFG); | |
| 1300 | +} | |
| 1301 | + | |
| 1302 | +static void sdhci_tegra_cqe_post_disable(struct mmc_host *mmc) | |
| 1303 | +{ | |
| 1304 | + struct cqhci_host *cq_host = mmc->cqe_private; | |
| 1305 | + struct sdhci_host *host = mmc_priv(mmc); | |
| 1306 | + u32 reg; | |
| 1307 | + | |
| 1308 | + reg = cqhci_readl(cq_host, CQHCI_CFG); | |
| 1309 | + reg &= ~CQHCI_ENABLE; | |
| 1310 | + cqhci_writel(cq_host, reg, CQHCI_CFG); | |
| 1311 | + sdhci_writew(host, 0x0, SDHCI_TRANSFER_MODE); | |
| 1312 | +} | |
| 1313 | + | |
| 1284 | 1314 | static const struct cqhci_host_ops sdhci_tegra_cqhci_ops = { |
| 1285 | 1315 | .write_l = tegra_cqhci_writel, |
| 1286 | 1316 | .enable = sdhci_tegra_cqe_enable, |
| 1287 | 1317 | .disable = sdhci_cqe_disable, |
| 1288 | 1318 | .dumpregs = sdhci_tegra_dumpregs, |
| 1289 | 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 | |
| 1292 | 1324 | static int tegra_sdhci_set_dma_mask(struct sdhci_host *host) |
| @@ -1529,7 +1561,7 @@ static int sdhci_tegra_add_host(struct sdhci_host *host) · 236 unmodified lines | ||
| 1529 | 1561 | |
| 1530 | 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 | 1565 | sizeof(*cq_host), GFP_KERNEL); |
| 1534 | 1566 | if (!cq_host) { |
| 1535 | 1567 | ret = -ENOMEM; |
| @@ -188,7 +188,7 @@ static void sdhci_runtime_pm_bus_on(struct sdhci_host *host) · 187 unmodified lines | ||
| 188 | 188 | if (host->bus_on) |
| 189 | 189 | return; |
| 190 | 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 | |
| 194 | 194 | static void sdhci_runtime_pm_bus_off(struct sdhci_host *host) |
| @@ -196,7 +196,7 @@ static void sdhci_runtime_pm_bus_off(struct sdhci_host *host) · 1 unmodified line | ||
| 196 | 196 | if (!host->bus_on) |
| 197 | 197 | return; |
| 198 | 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 | |
| 202 | 202 | void sdhci_reset(struct sdhci_host *host, u8 mask) |
| @@ -648,7 +648,7 @@ static int sdhci_pre_dma_transfer(struct sdhci_host *host, · 445 unmodified lines | ||
| 648 | 648 | } |
| 649 | 649 | } |
| 650 | 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 | 652 | host->bounce_addr, |
| 653 | 653 | host->bounce_buffer_size, |
| 654 | 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 | 908 | if (data) { |
| 909 | 909 | blksz = data->blksz; |
| 910 | − freq = host->mmc->actual_clock ? : host->clock; | |
| 910 | + freq = mmc->actual_clock ? : host->clock; | |
| 911 | 911 | transfer_time = (u64)blksz * NSEC_PER_SEC * (8 / bus_width); |
| 912 | 912 | do_div(transfer_time, freq); |
| 913 | 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 | 1176 | int ret = 0; |
| 1177 | 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 | 1180 | if (IS_ERR(host->tx_chan)) { |
| 1181 | 1181 | ret = PTR_ERR(host->tx_chan); |
| 1182 | 1182 | if (ret != -EPROBE_DEFER) |
| @@ -1185,7 +1185,7 @@ static int sdhci_external_dma_init(struct sdhci_host *host) · 2 unmodified lines | ||
| 1185 | 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 | 1189 | if (IS_ERR(host->rx_chan)) { |
| 1190 | 1190 | if (host->tx_chan) { |
| 1191 | 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 | 2270 | if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK && |
| 2271 | 2271 | host->clock) { |
| 2272 | − host->timeout_clk = host->mmc->actual_clock ? | |
| 2273 | − host->mmc->actual_clock / 1000 : | |
| 2272 | + host->timeout_clk = mmc->actual_clock ? | |
| 2273 | + mmc->actual_clock / 1000 : | |
| 2274 | 2274 | host->clock / 1000; |
| 2275 | − host->mmc->max_busy_timeout = | |
| 2275 | + mmc->max_busy_timeout = | |
| 2276 | 2276 | host->ops->get_max_timeout_count ? |
| 2277 | 2277 | host->ops->get_max_timeout_count(host) : |
| 2278 | 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 | 2399 | return 0; |
| 2400 | 2400 | |
| 2401 | 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 | 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 | 2489 | unsigned long flags; |
| 2490 | 2490 | |
| 2491 | 2491 | if (enable) |
| 2492 | − pm_runtime_get_noresume(host->mmc->parent); | |
| 2492 | + pm_runtime_get_noresume(mmc_dev(mmc)); | |
| 2493 | 2493 | |
| 2494 | 2494 | spin_lock_irqsave(&host->lock, flags); |
| 2495 | 2495 | sdhci_enable_sdio_irq_nolock(host, enable); |
| 2496 | 2496 | spin_unlock_irqrestore(&host->lock, flags); |
| 2497 | 2497 | |
| 2498 | 2498 | if (!enable) |
| 2499 | − pm_runtime_put_noidle(host->mmc->parent); | |
| 2499 | + pm_runtime_put_noidle(mmc_dev(mmc)); | |
| 2500 | 2500 | } |
| 2501 | 2501 | EXPORT_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 | 2837 | goto out; |
| 2838 | 2838 | } |
| 2839 | 2839 | |
| 2840 | − host->mmc->retune_period = tuning_count; | |
| 2840 | + mmc->retune_period = tuning_count; | |
| 2841 | 2841 | |
| 2842 | 2842 | if (host->tuning_delay < 0) |
| 2843 | 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 | ||
| 2886 | 2886 | static void sdhci_post_req(struct mmc_host *mmc, struct mmc_request *mrq, |
| 2887 | 2887 | int err) |
| 2888 | 2888 | { |
| 2889 | − struct sdhci_host *host = mmc_priv(mmc); | |
| 2890 | 2889 | struct mmc_data *data = mrq->data; |
| 2891 | 2890 | |
| 2892 | 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 | 2893 | mmc_get_dma_dir(data)); |
| 2895 | 2894 | |
| 2896 | 2895 | data->host_cookie = COOKIE_UNMAPPED; |
| @@ -2941,9 +2940,9 @@ static void sdhci_card_event(struct mmc_host *mmc) · 44 unmodified lines | ||
| 2941 | 2940 | /* Check sdhci_has_requests() first in case we are runtime suspended */ |
| 2942 | 2941 | if (sdhci_has_requests(host) && !present) { |
| 2943 | 2942 | pr_err("%s: Card removed during transfer!\n", |
| 2944 | − mmc_hostname(host->mmc)); | |
| 2943 | + mmc_hostname(mmc)); | |
| 2945 | 2944 | pr_err("%s: Resetting controller.\n", |
| 2946 | − mmc_hostname(host->mmc)); | |
| 2945 | + mmc_hostname(mmc)); | |
| 2947 | 2946 | |
| 2948 | 2947 | sdhci_do_reset(host, SDHCI_RESET_CMD); |
| 2949 | 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 | 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 | 3030 | * Always unmap the data buffers if they were mapped by |
| 3001 | 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 | 3063 | length = host->bounce_buffer_size; |
| 3034 | 3064 | } |
| 3035 | 3065 | dma_sync_single_for_cpu( |
| 3036 | − host->mmc->parent, | |
| 3066 | + mmc_dev(host->mmc), | |
| 3037 | 3067 | host->bounce_addr, |
| 3038 | 3068 | host->bounce_buffer_size, |
| 3039 | 3069 | DMA_FROM_DEVICE); |
| @@ -3044,7 +3074,7 @@ static bool sdhci_request_done(struct sdhci_host *host) · 4 unmodified lines | ||
| 3044 | 3074 | } else { |
| 3045 | 3075 | /* No copying, just switch ownership */ |
| 3046 | 3076 | dma_sync_single_for_cpu( |
| 3047 | − host->mmc->parent, | |
| 3077 | + mmc_dev(host->mmc), | |
| 3048 | 3078 | host->bounce_addr, |
| 3049 | 3079 | host->bounce_buffer_size, |
| 3050 | 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 | 3092 | host->mrqs_done[i] = NULL; |
| 3092 | 3093 | |
| 3093 | 3094 | spin_unlock_irqrestore(&host->lock, flags); |
| @@ -3675,7 +3676,7 @@ int sdhci_resume_host(struct sdhci_host *host) · 581 unmodified lines | ||
| 3675 | 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 | 3680 | (host->quirks2 & SDHCI_QUIRK2_HOST_OFF_CARD_ON)) { |
| 3680 | 3681 | /* Card keeps power but host controller does not */ |
| 3681 | 3682 | sdhci_init(host, 0); |
| @@ -3683,7 +3684,7 @@ int sdhci_resume_host(struct sdhci_host *host) · 1 unmodified line | ||
| 3683 | 3684 | host->clock = 0; |
| 3684 | 3685 | mmc->ops->set_ios(mmc, &mmc->ios); |
| 3685 | 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 | 3690 | if (host->irq_wake_enabled) { |
| @@ -3691,7 +3692,7 @@ int sdhci_resume_host(struct sdhci_host *host) · 1 unmodified line | ||
| 3691 | 3692 | } else { |
| 3692 | 3693 | ret = request_threaded_irq(host->irq, sdhci_irq, |
| 3693 | 3694 | sdhci_thread_irq, IRQF_SHARED, |
| 3694 | − mmc_hostname(host->mmc), host); | |
| 3695 | + mmc_hostname(mmc), host); | |
| 3695 | 3696 | if (ret) |
| 3696 | 3697 | return ret; |
| 3697 | 3698 | } |
| @@ -4052,7 +4053,7 @@ static void sdhci_allocate_bounce_buffer(struct sdhci_host *host) · 354 unmodified lines | ||
| 4052 | 4053 | * speedups by the help of a bounce buffer to group scattered |
| 4053 | 4054 | * reads/writes together. |
| 4054 | 4055 | */ |
| 4055 | − host->bounce_buffer = devm_kmalloc(mmc->parent, | |
| 4056 | + host->bounce_buffer = devm_kmalloc(mmc_dev(mmc), | |
| 4056 | 4057 | bounce_size, |
| 4057 | 4058 | GFP_KERNEL); |
| 4058 | 4059 | if (!host->bounce_buffer) { |
| @@ -4066,11 +4067,11 @@ static void sdhci_allocate_bounce_buffer(struct sdhci_host *host) · 7 unmodified lines | ||
| 4066 | 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 | 4071 | host->bounce_buffer, |
| 4071 | 4072 | bounce_size, |
| 4072 | 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 | 4075 | if (ret) |
| 4075 | 4076 | /* Again fall back to max_segs == 1 */ |
| 4076 | 4077 | return; |
| @@ -4378,7 +4379,7 @@ int sdhci_setup_host(struct sdhci_host *host) · 301 unmodified lines | ||
| 4378 | 4379 | |
| 4379 | 4380 | if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) && |
| 4380 | 4381 | mmc_card_is_removable(mmc) && |
| 4381 | − mmc_gpio_get_cd(host->mmc) < 0) | |
| 4382 | + mmc_gpio_get_cd(mmc) < 0) | |
| 4382 | 4383 | mmc->caps |= MMC_CAP_NEEDS_POLL; |
| 4383 | 4384 | |
| 4384 | 4385 | if (!IS_ERR(mmc->supply.vqmmc)) { |
| @@ -558,7 +558,7 @@ static int sdhci_am654_cqe_add_host(struct sdhci_host *host) · 557 unmodified lines | ||
| 558 | 558 | struct cqhci_host *cq_host; |
| 559 | 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 | 562 | GFP_KERNEL); |
| 563 | 563 | if (!cq_host) |
| 564 | 564 | return -ENOMEM; |
| @@ -100,8 +100,8 @@ · 99 unmodified lines | ||
| 100 | 100 | |
| 101 | 101 | /* Define some IRQ masks */ |
| 102 | 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 | 103 | #define TMIO_MASK_ALL 0x837f031d |
| 104 | +#define TMIO_MASK_ALL_RCAR2 0x8b7f031d | |
| 105 | 105 | #define TMIO_MASK_READOP (TMIO_STAT_RXRDY | TMIO_STAT_DATAEND) |
| 106 | 106 | #define TMIO_MASK_WRITEOP (TMIO_STAT_TXRQ | TMIO_STAT_DATAEND) |
| 107 | 107 | #define TMIO_MASK_CMD (TMIO_STAT_CMDRESPEND | TMIO_STAT_CMDTIMEOUT | \ |
| @@ -164,6 +164,7 @@ struct tmio_mmc_host { · 56 unmodified lines | ||
| 164 | 164 | u32 sdio_irq_mask; |
| 165 | 165 | unsigned int clk_cache; |
| 166 | 166 | u32 sdcard_irq_setbit_mask; |
| 167 | + u32 sdcard_irq_mask_all; | |
| 167 | 168 | |
| 168 | 169 | spinlock_t lock; /* protect host private data */ |
| 169 | 170 | unsigned long last_req_ts; |
| @@ -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 | |
| 167 | +static void tmio_mmc_set_bus_width(struct tmio_mmc_host *host, | |
| 168 | + unsigned char bus_width) | |
| 169 | +{ | |
| 170 | + u16 reg = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT) | |
| 171 | + & ~(CARD_OPT_WIDTH | CARD_OPT_WIDTH8); | |
| 172 | + | |
| 173 | + /* reg now applies to MMC_BUS_WIDTH_4 */ | |
| 174 | + if (bus_width == MMC_BUS_WIDTH_1) | |
| 175 | + reg |= CARD_OPT_WIDTH; | |
| 176 | + else if (bus_width == MMC_BUS_WIDTH_8) | |
| 177 | + reg |= CARD_OPT_WIDTH8; | |
| 178 | + | |
| 179 | + sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, reg); | |
| 180 | +} | |
| 181 | + | |
| 167 | 182 | static void tmio_mmc_reset(struct tmio_mmc_host *host) |
| 168 | 183 | { |
| 169 | 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 | 187 | sd_ctrl_write16(host, CTL_RESET_SD, 0x0001); |
| 173 | 188 | usleep_range(10000, 11000); |
| 174 | 189 | |
| 190 | + tmio_mmc_abort_dma(host); | |
| 191 | + | |
| 175 | 192 | if (host->reset) |
| 176 | 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 | 200 | if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) { |
| 181 | 201 | sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask); |
| 182 | 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 | |
| 186 | 209 | static void tmio_mmc_reset_work(struct work_struct *work) |
| @@ -874,21 +897,6 @@ static void tmio_mmc_power_off(struct tmio_mmc_host *host) · 687 unmodified lines | ||
| 874 | 897 | host->set_pwr(host->pdev, 0); |
| 875 | 898 | } |
| 876 | 899 | |
| 877 | −static void tmio_mmc_set_bus_width(struct tmio_mmc_host *host, | |
| 878 | − unsigned char bus_width) | |
| 879 | −{ | |
| 880 | − u16 reg = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT) | |
| 881 | − & ~(CARD_OPT_WIDTH | CARD_OPT_WIDTH8); | |
| 882 | − | |
| 883 | − /* reg now applies to MMC_BUS_WIDTH_4 */ | |
| 884 | − if (bus_width == MMC_BUS_WIDTH_1) | |
| 885 | − reg |= CARD_OPT_WIDTH; | |
| 886 | − else if (bus_width == MMC_BUS_WIDTH_8) | |
| 887 | − reg |= CARD_OPT_WIDTH8; | |
| 888 | − | |
| 889 | − sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, reg); | |
| 890 | −} | |
| 891 | − | |
| 892 | 900 | static unsigned int tmio_mmc_get_timeout_cycles(struct tmio_mmc_host *host) |
| 893 | 901 | { |
| 894 | 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 | 1168 | mmc->caps & MMC_CAP_NEEDS_POLL || |
| 1161 | 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 | 1172 | * While using internal tmio hardware logic for card detection, we need |
| 1174 | 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 | 1179 | if (pdata->flags & TMIO_MMC_SDIO_IRQ) |
| 1181 | 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 | 1185 | _host->set_clock(_host, 0); |
| 1184 | 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 | 1188 | if (_host->native_hotplug) |
| 1190 | 1189 | tmio_mmc_enable_mmc_irqs(_host, |
| 1191 | 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 | 1237 | cancel_work_sync(&host->done); |
| 1239 | 1238 | cancel_delayed_work_sync(&host->delayed_reset_work); |
| 1240 | 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 | 1242 | if (host->native_hotplug) |
| 1244 | 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 | 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 | 1272 | if (host->clk_cache) |
| 1274 | 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 | 1295 | tmio_mmc_enable_dma(host, true); |
| 1297 | 1296 | |
| 1298 | − mmc_retune_needed(host->mmc); | |
| 1299 | − | |
| 1300 | 1297 | return 0; |
| 1301 | 1298 | } |
| 1302 | 1299 | EXPORT_SYMBOL_GPL(tmio_mmc_host_runtime_resume); |
| @@ -635,7 +635,7 @@ static int uniphier_sd_probe(struct platform_device *pdev) · 634 unmodified lines | ||
| 635 | 635 | |
| 636 | 636 | ret = tmio_mmc_host_probe(host); |
| 637 | 637 | if (ret) |
| 638 | − goto free_host; | |
| 638 | + goto disable_clk; | |
| 639 | 639 | |
| 640 | 640 | ret = devm_request_irq(dev, irq, tmio_mmc_irq, IRQF_SHARED, |
| 641 | 641 | dev_name(dev), host); |
| @@ -646,6 +646,8 @@ static int uniphier_sd_probe(struct platform_device *pdev) · 4 unmodified lines | ||
| 646 | 646 | |
| 647 | 647 | remove_host: |
| 648 | 648 | tmio_mmc_host_remove(host); |
| 649 | +disable_clk: | |
| 650 | + uniphier_sd_clk_disable(host); | |
| 649 | 651 | free_host: |
| 650 | 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 | 661 | tmio_mmc_host_remove(host); |
| 660 | 662 | uniphier_sd_clk_disable(host); |
| 663 | + tmio_mmc_host_free(host); | |
| 661 | 664 | |
| 662 | 665 | return 0; |
| 663 | 666 | } |
| @@ -1271,7 +1271,6 @@ static int __maybe_unused via_sd_suspend(struct device *dev) · 1270 unmodified lines | ||
| 1271 | 1271 | static int __maybe_unused via_sd_resume(struct device *dev) |
| 1272 | 1272 | { |
| 1273 | 1273 | struct via_crdr_mmc_host *sdhost; |
| 1274 | − int ret = 0; | |
| 1275 | 1274 | u8 gatt; |
| 1276 | 1275 | |
| 1277 | 1276 | sdhost = dev_get_drvdata(dev); |
| @@ -1292,7 +1291,7 @@ static int __maybe_unused via_sd_resume(struct device *dev) · 14 unmodified lines | ||
| 1292 | 1291 | via_restore_pcictrlreg(sdhost); |
| 1293 | 1292 | via_init_sdc_pm(sdhost); |
| 1294 | 1293 | |
| 1295 | − return ret; | |
| 1294 | + return 0; | |
| 1296 | 1295 | } |
| 1297 | 1296 | |
| 1298 | 1297 | static SIMPLE_DEV_PM_OPS(via_sd_pm_ops, via_sd_suspend, via_sd_resume); |
| @@ -302,9 +302,6 @@ struct mmc_host { · 301 unmodified lines | ||
| 302 | 302 | u32 ocr_avail_sdio; /* SDIO-specific OCR */ |
| 303 | 303 | u32 ocr_avail_sd; /* SD-specific OCR */ |
| 304 | 304 | u32 ocr_avail_mmc; /* MMC-specific OCR */ |
| 305 | −#ifdef CONFIG_PM_SLEEP | |
| 306 | − struct notifier_block pm_notify; | |
| 307 | −#endif | |
| 308 | 305 | struct wakeup_source *ws; /* Enable consume of uevents */ |
| 309 | 306 | u32 max_current_330; |
| 310 | 307 | u32 max_current_300; |
| @@ -423,7 +420,6 @@ struct mmc_host { · 112 unmodified lines | ||
| 423 | 420 | /* group bitfields together to minimize padding */ |
| 424 | 421 | unsigned int use_spi_crc:1; |
| 425 | 422 | unsigned int claimed:1; /* host exclusively claimed */ |
| 426 | − unsigned int bus_dead:1; /* bus has been released */ | |
| 427 | 423 | unsigned int doing_init_tune:1; /* initial tuning in progress */ |
| 428 | 424 | unsigned int can_retune:1; /* re-tuning can be used */ |
| 429 | 425 | unsigned int doing_retune:1; /* re-tuning in progress */ |
| @@ -454,7 +450,6 @@ struct mmc_host { · 24 unmodified lines | ||
| 454 | 450 | struct mmc_slot slot; |
| 455 | 451 | |
| 456 | 452 | const struct mmc_bus_ops *bus_ops; /* current bus driver */ |
| 457 | − unsigned int bus_refs; /* reference counter */ | |
| 458 | 453 | |
| 459 | 454 | unsigned int sdio_irqs; |
| 460 | 455 | struct task_struct *sdio_irq_thread; |
| @@ -514,7 +509,7 @@ void mmc_free_host(struct mmc_host *); · 53 unmodified lines | ||
| 514 | 509 | void mmc_of_parse_clk_phase(struct mmc_host *host, |
| 515 | 510 | struct mmc_clk_phase_map *map); |
| 516 | 511 | int mmc_of_parse(struct mmc_host *host); |
| 517 | −int mmc_of_parse_voltage(struct device_node *np, u32 *mask); | |
| 512 | +int mmc_of_parse_voltage(struct mmc_host *host, u32 *mask); | |
| 518 | 513 | |
| 519 | 514 | static inline void *mmc_priv(struct mmc_host *host) |
| 520 | 515 | { |
| @@ -82,7 +82,7 @@ · 81 unmodified lines | ||
| 82 | 82 | #define SDIO_SD_REV_1_01 0 /* SD Physical Spec Version 1.01 */ |
| 83 | 83 | #define SDIO_SD_REV_1_10 1 /* SD Physical Spec Version 1.10 */ |
| 84 | 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 | 87 | #define SDIO_CCCR_IOEx 0x02 |
| 88 | 88 | #define SDIO_CCCR_IORx 0x03 |
| @@ -35,16 +35,7 @@ struct mmc_spi_platform_data { · 34 unmodified lines | ||
| 35 | 35 | void (*setpower)(struct device *, unsigned int maskval); |
| 36 | 36 | }; |
| 37 | 37 | |
| 38 | −#ifdef CONFIG_OF | |
| 39 | 38 | extern struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi); |
| 40 | 39 | extern void mmc_spi_put_pdata(struct spi_device *spi); |
| 41 | −#else | |
| 42 | −static inline struct mmc_spi_platform_data * | |
| 43 | −mmc_spi_get_pdata(struct spi_device *spi) | |
| 44 | −{ | |
| 45 | − return spi->dev.platform_data; | |
| 46 | −} | |
| 47 | −static inline void mmc_spi_put_pdata(struct spi_device *spi) {} | |
| 48 | −#endif /* CONFIG_OF */ | |
| 49 | 40 | |
| 50 | 41 | #endif /* __LINUX_SPI_MMC_SPI_H */ |