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

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

Pull MMC updates from Ulf Hansson:
"MMC core:
- Add support for the asynchronous SDIO wakeup interrupts
- Skip redundant evaluation of eMMC HS400 caps when no-MMC-cap
- Add support to store error stats from host drivers
- Extend debugfs to show error stats from host drivers
- Add single I/O read support in the recovery path for 4k sector cards

MMC host:
- dw_mmc-exynos: Convert corresponding DT bindings to the dtschema
- dw_mmc-rockchip: Add support for the Rockchip RV1126 variant
- mmc_spi: Convert corresponding DT bindings to the dtschema
- mtk-sd: Extend support for interrupts/pinctrls for SDIO low-power mode
- mtk-sd: Add support for SDIO wake irqs
- mtk-sd: Add support for the Mediatek MT8188 variant
- renesas_sdhi: Drop redundant manual tap correction for newer SoCs
- renesas_sdhi: Add support for the R-Car S4-8 and generic Gen4 variants
- sdhci/cqhci: Add support to capture stats from host errors
- sdhci-brcmstb: Add ability to increase max clock rate for SDIO on 72116b0
- sdhci-msm: Add support for the MSM8998 and SM8450 variant
- sdhci-of-at91: Fixup UHS-I mode by rewriting of MC1R
- sdhci-of-dwcmshc: Add support for the Rockchip rk3588 variant
- sdhci-of-dwcmshc: Enable reset support for the Rockchip variants
- sdhci-pci-gli: Improve I/O read/write performance for GL9763E
- sdhci-s3c: Convert corresponding DT bindings to the dtschema
- tmio: Avoid glitches when resetting

MEMSTICK core:
- A couple of minor fixes and cleanups"

* tag 'mmc-v5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: (61 commits)
mmc: mediatek: add support for SDIO eint wakup IRQ
mmc: core: Add support for SDIO wakeup interrupt
dt-bindings: mmc: mtk-sd: extend interrupts and pinctrls properties
dt-bindings: mmc: rockchip-dw-mshc: Document Rockchip RV1126
mmc: renesas_sdhi: newer SoCs don't need manual tap correction
mmc: cavium-thunderx: Add of_node_put() when breaking out of loop
mmc: cavium-octeon: Add of_node_put() when breaking out of loop
mmc: core: quirks: Add of_node_put() when breaking out of loop
mmc: sdhci-brcmstb: use clk_get_rate(base_clk) in PM resume
dt-bindings: mmc: sdhci-msm: Document the SM8450 compatible
mmc: sdhci-msm: drop redundant of_device_id entries
dt-bindings: mmc: sdhci-msm: add MSM8998
mmc: block: Add single read for 4k sector cards
mmc: mxcmmc: Use mmc_card_sdio macro
mmc: core: Use mmc_card_* macro and add a new for the sd_combo type
dt-bindings: mmc: sdhci-msm: constrain reg-names per variants
dt-bindings: mmc: sdhci-msm: fix reg-names entries
dt-bindings: mmc: Add compatible for MediaTek MT8188
dt-bindings: mmc: sdhci-msm: document resets
mmc: sdhci-of-at91: fix set_uhs_signaling rewriting of MC1R
...

+1152 -362
+26 -6
Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml
··· 10 10 - Al Cooper <alcooperx@gmail.com> 11 11 - Florian Fainelli <f.fainelli@gmail.com> 12 12 13 - allOf: 14 - - $ref: mmc-controller.yaml# 15 - 16 13 properties: 17 14 compatible: 18 15 oneOf: ··· 39 42 maxItems: 1 40 43 41 44 clocks: 42 - maxItems: 1 43 - description: 44 - handle to core clock for the sdhci controller. 45 + minItems: 1 46 + items: 47 + - description: handle to core clock for the sdhci controller 48 + - description: handle to improved 150Mhz clock for sdhci controller (Optional clock) 45 49 46 50 clock-names: 51 + minItems: 1 47 52 items: 48 53 - const: sw_sdio 54 + - const: sdio_freq # Optional clock 55 + 56 + clock-frequency: 57 + description: 58 + Maximum operating frequency of sdio_freq sdhci controller clock 59 + $ref: /schemas/types.yaml#/definitions/uint32 60 + minimum: 100000000 61 + maximum: 150000000 49 62 50 63 sdhci,auto-cmd12: 51 64 type: boolean 52 65 description: Specifies that controller should use auto CMD12 66 + 67 + allOf: 68 + - $ref: mmc-controller.yaml# 69 + - if: 70 + properties: 71 + clock-names: 72 + contains: 73 + const: sdio_freq 74 + 75 + then: 76 + required: 77 + - clock-frequency 53 78 54 79 required: 55 80 - compatible 56 81 - reg 57 82 - interrupts 58 83 - clocks 84 + - clock-names 59 85 60 86 unevaluatedProperties: false 61 87
-94
Documentation/devicetree/bindings/mmc/exynos-dw-mshc.txt
··· 1 - * Samsung Exynos specific extensions to the Synopsys Designware Mobile 2 - Storage Host Controller 3 - 4 - The Synopsys designware mobile storage host controller is used to interface 5 - a SoC with storage medium such as eMMC or SD/MMC cards. This file documents 6 - differences between the core Synopsys dw mshc controller properties described 7 - by synopsys-dw-mshc.txt and the properties used by the Samsung Exynos specific 8 - extensions to the Synopsys Designware Mobile Storage Host Controller. 9 - 10 - Required Properties: 11 - 12 - * compatible: should be 13 - - "samsung,exynos4210-dw-mshc": for controllers with Samsung Exynos4210 14 - specific extensions. 15 - - "samsung,exynos4412-dw-mshc": for controllers with Samsung Exynos4412 16 - specific extensions. 17 - - "samsung,exynos5250-dw-mshc": for controllers with Samsung Exynos5250 18 - specific extensions. 19 - - "samsung,exynos5420-dw-mshc": for controllers with Samsung Exynos5420 20 - specific extensions. 21 - - "samsung,exynos7-dw-mshc": for controllers with Samsung Exynos7 22 - specific extensions. 23 - - "samsung,exynos7-dw-mshc-smu": for controllers with Samsung Exynos7 24 - specific extensions having an SMU. 25 - - "axis,artpec8-dw-mshc": for controllers with ARTPEC-8 specific 26 - extensions. 27 - 28 - * samsung,dw-mshc-ciu-div: Specifies the divider value for the card interface 29 - unit (ciu) clock. This property is applicable only for Exynos5 SoC's and 30 - ignored for Exynos4 SoC's. The valid range of divider value is 0 to 7. 31 - 32 - * samsung,dw-mshc-sdr-timing: Specifies the value of CIU clock phase shift value 33 - in transmit mode and CIU clock phase shift value in receive mode for single 34 - data rate mode operation. Refer notes below for the order of the cells and the 35 - valid values. 36 - 37 - * samsung,dw-mshc-ddr-timing: Specifies the value of CUI clock phase shift value 38 - in transmit mode and CIU clock phase shift value in receive mode for double 39 - data rate mode operation. Refer notes below for the order of the cells and the 40 - valid values. 41 - * samsung,dw-mshc-hs400-timing: Specifies the value of CIU TX and RX clock phase 42 - shift value for hs400 mode operation. 43 - 44 - Notes for the sdr-timing and ddr-timing values: 45 - 46 - The order of the cells should be 47 - - First Cell: CIU clock phase shift value for tx mode. 48 - - Second Cell: CIU clock phase shift value for rx mode. 49 - 50 - Valid values for SDR and DDR CIU clock timing for Exynos5250: 51 - - valid value for tx phase shift and rx phase shift is 0 to 7. 52 - - when CIU clock divider value is set to 3, all possible 8 phase shift 53 - values can be used. 54 - - if CIU clock divider value is 0 (that is divide by 1), both tx and rx 55 - phase shift clocks should be 0. 56 - 57 - * samsung,read-strobe-delay: RCLK (Data strobe) delay to control HS400 mode 58 - (Latency value for delay line in Read path) 59 - 60 - Required properties for a slot (Deprecated - Recommend to use one slot per host): 61 - 62 - * gpios: specifies a list of gpios used for command, clock and data bus. The 63 - first gpio is the command line and the second gpio is the clock line. The 64 - rest of the gpios (depending on the bus-width property) are the data lines in 65 - no particular order. The format of the gpio specifier depends on the gpio 66 - controller. 67 - (Deprecated - Refer to Documentation/devicetree/bindings/pinctrl/samsung-pinctrl.txt) 68 - 69 - Example: 70 - 71 - The MSHC controller node can be split into two portions, SoC specific and 72 - board specific portions as listed below. 73 - 74 - dwmmc0@12200000 { 75 - compatible = "samsung,exynos5250-dw-mshc"; 76 - reg = <0x12200000 0x1000>; 77 - interrupts = <0 75 0>; 78 - #address-cells = <1>; 79 - #size-cells = <0>; 80 - }; 81 - 82 - dwmmc0@12200000 { 83 - cap-mmc-highspeed; 84 - cap-sd-highspeed; 85 - broken-cd; 86 - fifo-depth = <0x80>; 87 - card-detect-delay = <200>; 88 - samsung,dw-mshc-ciu-div = <3>; 89 - samsung,dw-mshc-sdr-timing = <2 3>; 90 - samsung,dw-mshc-ddr-timing = <1 2>; 91 - samsung,dw-mshc-hs400-timing = <0 2>; 92 - samsung,read-strobe-delay = <90>; 93 - bus-width = <8>; 94 - };
-29
Documentation/devicetree/bindings/mmc/mmc-spi-slot.txt
··· 1 - MMC/SD/SDIO slot directly connected to a SPI bus 2 - 3 - This file documents differences between the core properties described 4 - by mmc.txt and the properties used by the mmc_spi driver. 5 - 6 - Required properties: 7 - - spi-max-frequency : maximum frequency for this device (Hz). 8 - 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 - - gpios : may specify GPIOs in this order: Card-Detect GPIO, 14 - Write-Protect GPIO. Note that this does not follow the 15 - binding from mmc.txt, for historical reasons. 16 - 17 - Example: 18 - 19 - mmc-slot@0 { 20 - compatible = "fsl,mpc8323rdb-mmc-slot", 21 - "mmc-spi-slot"; 22 - reg = <0>; 23 - gpios = <&qe_pio_d 14 1 24 - &qe_pio_d 15 0>; 25 - voltage-ranges = <3300 3300>; 26 - spi-max-frequency = <50000000>; 27 - interrupts = <42>; 28 - interrupt-parent = <&PIC>; 29 - };
+77
Documentation/devicetree/bindings/mmc/mmc-spi-slot.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/mmc/mmc-spi-slot.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: MMC/SD/SDIO slot directly connected to a SPI bus 8 + 9 + maintainers: 10 + - Ulf Hansson <ulf.hansson@linaro.org> 11 + 12 + allOf: 13 + - $ref: "mmc-controller.yaml" 14 + - $ref: /schemas/spi/spi-peripheral-props.yaml 15 + 16 + description: | 17 + The extra properties used by an mmc connected via SPI. 18 + 19 + properties: 20 + compatible: 21 + const: mmc-spi-slot 22 + 23 + reg: 24 + maxItems: 1 25 + 26 + spi-max-frequency: true 27 + 28 + interrupts: 29 + maxItems: 1 30 + 31 + voltage-ranges: 32 + $ref: /schemas/types.yaml#/definitions/uint32-array 33 + description: | 34 + Two cells are required, first cell specifies minimum slot voltage (mV), 35 + second cell specifies maximum slot voltage (mV). 36 + items: 37 + - description: | 38 + value for minimum slot voltage in mV 39 + default: 3200 40 + - description: | 41 + value for maximum slot voltage in mV 42 + default: 3400 43 + 44 + gpios: 45 + description: | 46 + For historical reasons, this does not follow the generic mmc-controller 47 + binding. 48 + minItems: 1 49 + items: 50 + - description: Card-Detect GPIO 51 + - description: Write-Protect GPIO 52 + 53 + required: 54 + - compatible 55 + - reg 56 + - spi-max-frequency 57 + 58 + unevaluatedProperties: false 59 + 60 + examples: 61 + - | 62 + #include <dt-bindings/gpio/gpio.h> 63 + spi { 64 + #address-cells = <1>; 65 + #size-cells = <0>; 66 + mmc@0 { 67 + compatible = "mmc-spi-slot"; 68 + reg = <0>; 69 + gpios = <&gpio 14 GPIO_ACTIVE_LOW>, <&gpio 15 GPIO_ACTIVE_HIGH>; 70 + voltage-ranges = <3300 3300>; 71 + spi-max-frequency = <50000000>; 72 + interrupts = <42>; 73 + interrupt-parent = <&PIC>; 74 + }; 75 + }; 76 + 77 + ...
+54 -8
Documentation/devicetree/bindings/mmc/mtk-sd.yaml
··· 30 30 - const: mediatek,mt7623-mmc 31 31 - const: mediatek,mt2701-mmc 32 32 - items: 33 - - const: mediatek,mt8186-mmc 34 - - const: mediatek,mt8183-mmc 35 - - items: 36 - - const: mediatek,mt8192-mmc 37 - - const: mediatek,mt8183-mmc 38 - - items: 39 - - const: mediatek,mt8195-mmc 33 + - enum: 34 + - mediatek,mt8186-mmc 35 + - mediatek,mt8188-mmc 36 + - mediatek,mt8192-mmc 37 + - mediatek,mt8195-mmc 40 38 - const: mediatek,mt8183-mmc 41 39 42 40 reg: ··· 70 72 - const: ahb_cg 71 73 72 74 interrupts: 73 - maxItems: 1 75 + description: 76 + Should at least contain MSDC GIC interrupt. To support SDIO in-band wakeup, an extended 77 + interrupt is required and be configured as wakeup source irq. 78 + minItems: 1 79 + maxItems: 2 80 + 81 + interrupt-names: 82 + items: 83 + - const: msdc 84 + - const: sdio_wakeup 74 85 75 86 pinctrl-names: 87 + description: 88 + Should at least contain default and state_uhs. To support SDIO in-band wakeup, dat1 pin 89 + will be switched between GPIO mode and SDIO DAT1 mode, state_eint is mandatory in this 90 + scenario. 91 + minItems: 2 76 92 items: 77 93 - const: default 78 94 - const: state_uhs 95 + - const: state_eint 79 96 80 97 pinctrl-0: 81 98 description: ··· 100 87 pinctrl-1: 101 88 description: 102 89 should contain uhs mode pin ctrl. 90 + maxItems: 1 91 + 92 + pinctrl-2: 93 + description: 94 + should switch dat1 pin to GPIO mode. 103 95 maxItems: 1 104 96 105 97 assigned-clocks: ··· 224 206 mediatek,hs200-cmd-int-delay = <26>; 225 207 mediatek,hs400-cmd-int-delay = <14>; 226 208 mediatek,hs400-cmd-resp-sel-rising; 209 + }; 210 + 211 + mmc3: mmc@11260000 { 212 + compatible = "mediatek,mt8173-mmc"; 213 + reg = <0x11260000 0x1000>; 214 + clock-names = "source", "hclk"; 215 + clocks = <&pericfg CLK_PERI_MSDC30_3>, 216 + <&topckgen CLK_TOP_MSDC50_2_H_SEL>; 217 + interrupt-names = "msdc", "sdio_wakeup"; 218 + interrupts-extended = <&gic GIC_SPI 74 IRQ_TYPE_LEVEL_LOW 0>, 219 + <&pio 23 IRQ_TYPE_LEVEL_LOW>; 220 + pinctrl-names = "default", "state_uhs", "state_eint"; 221 + pinctrl-0 = <&mmc2_pins_default>; 222 + pinctrl-1 = <&mmc2_pins_uhs>; 223 + pinctrl-2 = <&mmc2_pins_eint>; 224 + bus-width = <4>; 225 + max-frequency = <200000000>; 226 + cap-sd-highspeed; 227 + sd-uhs-sdr104; 228 + keep-power-in-suspend; 229 + wakeup-source; 230 + cap-sdio-irq; 231 + no-mmc; 232 + no-sd; 233 + non-removable; 234 + vmmc-supply = <&sdio_fixed_3v3>; 235 + vqmmc-supply = <&mt6397_vgp3_reg>; 236 + mmc-pwrseq = <&wifi_pwrseq>; 227 237 }; 228 238 229 239 ...
+6 -1
Documentation/devicetree/bindings/mmc/renesas,sdhi.yaml
··· 56 56 - renesas,sdhi-r8a77980 # R-Car V3H 57 57 - renesas,sdhi-r8a77990 # R-Car E3 58 58 - renesas,sdhi-r8a77995 # R-Car D3 59 - - renesas,sdhi-r8a779a0 # R-Car V3U 60 59 - renesas,sdhi-r9a07g043 # RZ/G2UL 61 60 - renesas,sdhi-r9a07g044 # RZ/G2{L,LC} 62 61 - renesas,sdhi-r9a07g054 # RZ/V2L 63 62 - const: renesas,rcar-gen3-sdhi # R-Car Gen3 or RZ/G2 63 + - items: 64 + - enum: 65 + - renesas,sdhi-r8a779a0 # R-Car V3U 66 + - renesas,sdhi-r8a779f0 # R-Car S4-8 67 + - const: renesas,rcar-gen4-sdhi # R-Car Gen4 64 68 65 69 reg: 66 70 maxItems: 1 ··· 145 141 enum: 146 142 - renesas,rcar-gen2-sdhi 147 143 - renesas,rcar-gen3-sdhi 144 + - renesas,rcar-gen4-sdhi 148 145 then: 149 146 properties: 150 147 clocks:
+1
Documentation/devicetree/bindings/mmc/rockchip-dw-mshc.yaml
··· 39 39 - rockchip,rk3399-dw-mshc 40 40 - rockchip,rk3568-dw-mshc 41 41 - rockchip,rv1108-dw-mshc 42 + - rockchip,rv1126-dw-mshc 42 43 - const: rockchip,rk3288-dw-mshc 43 44 44 45 reg:
+160
Documentation/devicetree/bindings/mmc/samsung,exynos-dw-mshc.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/mmc/samsung,exynos-dw-mshc.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: 8 + Samsung Exynos SoC specific extensions to the Synopsys Designware Mobile 9 + Storage Host Controller 10 + 11 + maintainers: 12 + - Jaehoon Chung <jh80.chung@samsung.com> 13 + - Krzysztof Kozlowski <krzk@kernel.org> 14 + 15 + properties: 16 + compatible: 17 + enum: 18 + - samsung,exynos4210-dw-mshc 19 + - samsung,exynos4412-dw-mshc 20 + - samsung,exynos5250-dw-mshc 21 + - samsung,exynos5420-dw-mshc 22 + - samsung,exynos5420-dw-mshc-smu 23 + - samsung,exynos7-dw-mshc 24 + - samsung,exynos7-dw-mshc-smu 25 + - axis,artpec8-dw-mshc 26 + 27 + reg: 28 + maxItems: 1 29 + 30 + interrupts: 31 + maxItems: 1 32 + 33 + clocks: 34 + maxItems: 2 35 + description: 36 + Handle to "biu" and "ciu" clocks for the 37 + bus interface unit clock and the card interface unit clock. 38 + 39 + clock-names: 40 + items: 41 + - const: biu 42 + - const: ciu 43 + 44 + samsung,dw-mshc-ciu-div: 45 + $ref: /schemas/types.yaml#/definitions/uint32 46 + minimum: 0 47 + maximum: 7 48 + description: 49 + The divider value for the card interface unit (ciu) clock. 50 + 51 + samsung,dw-mshc-ddr-timing: 52 + $ref: /schemas/types.yaml#/definitions/uint32-array 53 + items: 54 + - description: CIU clock phase shift value for tx mode 55 + minimum: 0 56 + maximum: 7 57 + - description: CIU clock phase shift value for rx mode 58 + minimum: 0 59 + maximum: 7 60 + description: 61 + The value of CUI clock phase shift value in transmit mode and CIU clock 62 + phase shift value in receive mode for double data rate mode operation. 63 + See also samsung,dw-mshc-hs400-timing property. 64 + 65 + samsung,dw-mshc-hs400-timing: 66 + $ref: /schemas/types.yaml#/definitions/uint32-array 67 + items: 68 + - description: CIU clock phase shift value for tx mode 69 + minimum: 0 70 + maximum: 7 71 + - description: CIU clock phase shift value for rx mode 72 + minimum: 0 73 + maximum: 7 74 + description: | 75 + The value of CIU TX and RX clock phase shift value for HS400 mode 76 + operation. 77 + Valid values for SDR and DDR CIU clock timing:: 78 + - valid value for tx phase shift and rx phase shift is 0 to 7. 79 + - when CIU clock divider value is set to 3, all possible 8 phase shift 80 + values can be used. 81 + - if CIU clock divider value is 0 (that is divide by 1), both tx and rx 82 + phase shift clocks should be 0. 83 + If missing, values from samsung,dw-mshc-ddr-timing property are used. 84 + 85 + samsung,dw-mshc-sdr-timing: 86 + $ref: /schemas/types.yaml#/definitions/uint32-array 87 + items: 88 + - description: CIU clock phase shift value for tx mode 89 + minimum: 0 90 + maximum: 7 91 + - description: CIU clock phase shift value for rx mode 92 + minimum: 0 93 + maximum: 7 94 + description: 95 + The value of CIU clock phase shift value in transmit mode and CIU clock 96 + phase shift value in receive mode for single data rate mode operation. 97 + See also samsung,dw-mshc-hs400-timing property. 98 + 99 + samsung,read-strobe-delay: 100 + $ref: /schemas/types.yaml#/definitions/uint32 101 + description: 102 + RCLK (Data strobe) delay to control HS400 mode (Latency value for delay 103 + line in Read path). If missing, default from hardware is used. 104 + 105 + required: 106 + - compatible 107 + - reg 108 + - interrupts 109 + - clocks 110 + - clock-names 111 + - samsung,dw-mshc-ddr-timing 112 + - samsung,dw-mshc-sdr-timing 113 + 114 + allOf: 115 + - $ref: "synopsys-dw-mshc-common.yaml#" 116 + - if: 117 + properties: 118 + compatible: 119 + contains: 120 + enum: 121 + - samsung,exynos5250-dw-mshc 122 + - samsung,exynos5420-dw-mshc 123 + - samsung,exynos7-dw-mshc 124 + - samsung,exynos7-dw-mshc-smu 125 + - axis,artpec8-dw-mshc 126 + then: 127 + required: 128 + - samsung,dw-mshc-ciu-div 129 + 130 + unevaluatedProperties: false 131 + 132 + examples: 133 + - | 134 + #include <dt-bindings/clock/exynos5420.h> 135 + #include <dt-bindings/interrupt-controller/arm-gic.h> 136 + 137 + mmc@12220000 { 138 + compatible = "samsung,exynos5420-dw-mshc"; 139 + interrupts = <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>; 140 + #address-cells = <1>; 141 + #size-cells = <0>; 142 + reg = <0x12220000 0x1000>; 143 + clocks = <&clock CLK_MMC2>, <&clock CLK_SCLK_MMC2>; 144 + clock-names = "biu", "ciu"; 145 + fifo-depth = <0x40>; 146 + card-detect-delay = <200>; 147 + samsung,dw-mshc-ciu-div = <3>; 148 + samsung,dw-mshc-sdr-timing = <0 4>; 149 + samsung,dw-mshc-ddr-timing = <0 2>; 150 + pinctrl-names = "default"; 151 + pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_cd &sd2_wp &sd2_bus1 &sd2_bus4>; 152 + bus-width = <4>; 153 + cap-sd-highspeed; 154 + max-frequency = <200000000>; 155 + vmmc-supply = <&ldo19_reg>; 156 + vqmmc-supply = <&ldo13_reg>; 157 + sd-uhs-sdr50; 158 + sd-uhs-sdr104; 159 + sd-uhs-ddr50; 160 + };
+81
Documentation/devicetree/bindings/mmc/samsung,s3c6410-sdhci.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/mmc/samsung,s3c6410-sdhci.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Samsung SoC SDHCI Controller 8 + 9 + maintainers: 10 + - Jaehoon Chung <jh80.chung@samsung.com> 11 + - Krzysztof Kozlowski <krzk@kernel.org> 12 + 13 + properties: 14 + compatible: 15 + enum: 16 + - samsung,s3c6410-sdhci 17 + - samsung,exynos4210-sdhci 18 + 19 + reg: 20 + maxItems: 1 21 + 22 + clocks: 23 + minItems: 2 24 + maxItems: 5 25 + 26 + clock-names: 27 + minItems: 2 28 + items: 29 + - const: hsmmc 30 + - pattern: "^mmc_busclk.[0-3]$" 31 + - pattern: "^mmc_busclk.[0-3]$" 32 + - pattern: "^mmc_busclk.[0-3]$" 33 + - pattern: "^mmc_busclk.[0-3]$" 34 + 35 + interrupts: 36 + maxItems: 1 37 + 38 + required: 39 + - compatible 40 + - reg 41 + - interrupts 42 + - clocks 43 + - clock-names 44 + 45 + allOf: 46 + - $ref: mmc-controller.yaml# 47 + - if: 48 + properties: 49 + compatible: 50 + contains: 51 + enum: 52 + - samsung,exynos4210-sdhci 53 + then: 54 + properties: 55 + clocks: 56 + maxItems: 2 57 + clock-names: 58 + items: 59 + - const: hsmmc 60 + - const: mmc_busclk.2 61 + 62 + unevaluatedProperties: false 63 + 64 + examples: 65 + - | 66 + #include <dt-bindings/clock/exynos4.h> 67 + #include <dt-bindings/gpio/gpio.h> 68 + #include <dt-bindings/interrupt-controller/arm-gic.h> 69 + 70 + mmc@12510000 { 71 + compatible = "samsung,exynos4210-sdhci"; 72 + reg = <0x12510000 0x100>; 73 + interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>; 74 + clocks = <&clock CLK_SDMMC0>, <&clock CLK_SCLK_MMC0>; 75 + clock-names = "hsmmc", "mmc_busclk.2"; 76 + bus-width = <4>; 77 + cd-gpios = <&gpx3 4 GPIO_ACTIVE_LOW>; 78 + pinctrl-0 = <&sd2_clk &sd2_cmd &sd2_bus4 &sdhci2_cd>; 79 + pinctrl-names = "default"; 80 + vmmc-supply = <&ldo21_reg>; 81 + };
-32
Documentation/devicetree/bindings/mmc/samsung-sdhci.txt
··· 1 - * Samsung's SDHCI Controller device tree bindings 2 - 3 - Samsung's SDHCI controller is used as a connectivity interface with external 4 - MMC, SD and eMMC storage mediums. This file documents differences between the 5 - core mmc properties described by mmc.txt and the properties used by the 6 - Samsung implementation of the SDHCI controller. 7 - 8 - Required SoC Specific Properties: 9 - - compatible: should be one of the following 10 - - "samsung,s3c6410-sdhci": For controllers compatible with s3c6410 sdhci 11 - controller. 12 - - "samsung,exynos4210-sdhci": For controllers compatible with Exynos4 sdhci 13 - controller. 14 - 15 - Required Board Specific Properties: 16 - - pinctrl-0: Should specify pin control groups used for this controller. 17 - - pinctrl-names: Should contain only one value - "default". 18 - 19 - Example: 20 - sdhci@12530000 { 21 - compatible = "samsung,exynos4210-sdhci"; 22 - reg = <0x12530000 0x100>; 23 - interrupts = <0 75 0>; 24 - bus-width = <4>; 25 - cd-gpios = <&gpk2 2 0>; 26 - pinctrl-names = "default"; 27 - pinctrl-0 = <&sd0_clk &sd0_cmd &sd0_bus4>; 28 - }; 29 - 30 - Note: This example shows both SoC specific and board specific properties 31 - in a single device node. The properties can be actually be separated 32 - into SoC specific node and board specific node.
+69 -13
Documentation/devicetree/bindings/mmc/sdhci-msm.yaml
··· 17 17 properties: 18 18 compatible: 19 19 oneOf: 20 + - enum: 21 + - qcom,sdhci-msm-v4 22 + deprecated: true 20 23 - items: 21 24 - enum: 22 25 - qcom,apq8084-sdhci ··· 30 27 - qcom,msm8992-sdhci 31 28 - qcom,msm8994-sdhci 32 29 - qcom,msm8996-sdhci 30 + - qcom,msm8998-sdhci 31 + - const: qcom,sdhci-msm-v4 # for sdcc versions less than 5.0 32 + - items: 33 + - enum: 33 34 - qcom,qcs404-sdhci 34 35 - qcom,sc7180-sdhci 35 36 - qcom,sc7280-sdhci ··· 45 38 - qcom,sm6350-sdhci 46 39 - qcom,sm8150-sdhci 47 40 - qcom,sm8250-sdhci 48 - - enum: 49 - - qcom,sdhci-msm-v4 # for sdcc versions less than 5.0 50 - - qcom,sdhci-msm-v5 # for sdcc version 5.0 51 - - items: 52 - - const: qcom,sdhci-msm-v4 # Deprecated (only for backward compatibility) 53 - # for sdcc versions less than 5.0 41 + - qcom,sm8450-sdhci 42 + - const: qcom,sdhci-msm-v5 # for sdcc version 5.0 54 43 55 44 reg: 56 45 minItems: 1 57 - items: 58 - - description: Host controller register map 59 - - description: SD Core register map 60 - - description: CQE register map 61 - - description: Inline Crypto Engine register map 46 + maxItems: 4 47 + 48 + reg-names: 49 + minItems: 1 50 + maxItems: 4 62 51 63 52 clocks: 64 53 minItems: 3 ··· 96 93 description: 97 94 Should specify pin control groups used for this controller. 98 95 96 + resets: 97 + maxItems: 1 98 + 99 99 qcom,ddr-config: 100 100 $ref: /schemas/types.yaml#/definitions/uint32 101 101 description: platform specific settings for DDR_CONFIG reg. ··· 127 121 description: A phandle to sdhci power domain node 128 122 maxItems: 1 129 123 124 + mmc-ddr-1_8v: true 125 + 126 + mmc-hs200-1_8v: true 127 + 128 + mmc-hs400-1_8v: true 129 + 130 + bus-width: true 131 + 132 + max-frequency: true 133 + 130 134 patternProperties: 131 135 '^opp-table(-[a-z0-9]+)?$': 132 136 if: ··· 156 140 - clock-names 157 141 - interrupts 158 142 159 - additionalProperties: true 143 + allOf: 144 + - $ref: mmc-controller.yaml# 145 + 146 + - if: 147 + properties: 148 + compatible: 149 + contains: 150 + enum: 151 + - qcom,sdhci-msm-v4 152 + then: 153 + properties: 154 + reg: 155 + minItems: 2 156 + items: 157 + - description: Host controller register map 158 + - description: SD Core register map 159 + - description: CQE register map 160 + - description: Inline Crypto Engine register map 161 + reg-names: 162 + minItems: 2 163 + items: 164 + - const: hc 165 + - const: core 166 + - const: cqhci 167 + - const: ice 168 + else: 169 + properties: 170 + reg: 171 + minItems: 1 172 + items: 173 + - description: Host controller register map 174 + - description: CQE register map 175 + - description: Inline Crypto Engine register map 176 + reg-names: 177 + minItems: 1 178 + items: 179 + - const: hc 180 + - const: cqhci 181 + - const: ice 182 + 183 + unevaluatedProperties: false 160 184 161 185 examples: 162 186 - | ··· 205 149 #include <dt-bindings/clock/qcom,rpmh.h> 206 150 #include <dt-bindings/power/qcom-rpmpd.h> 207 151 208 - sdhc_2: sdhci@8804000 { 152 + sdhc_2: mmc@8804000 { 209 153 compatible = "qcom,sm8250-sdhci", "qcom,sdhci-msm-v5"; 210 154 reg = <0 0x08804000 0 0x1000>; 211 155
+8 -7
drivers/memstick/core/ms_block.c
··· 1341 1341 msb->zone_count = msb->block_count / MS_BLOCKS_IN_ZONE; 1342 1342 msb->logical_block_count = msb->zone_count * 496 - 2; 1343 1343 1344 - msb->used_blocks_bitmap = kzalloc(msb->block_count / 8, GFP_KERNEL); 1345 - msb->erased_blocks_bitmap = kzalloc(msb->block_count / 8, GFP_KERNEL); 1344 + msb->used_blocks_bitmap = bitmap_zalloc(msb->block_count, GFP_KERNEL); 1345 + msb->erased_blocks_bitmap = bitmap_zalloc(msb->block_count, GFP_KERNEL); 1346 1346 msb->lba_to_pba_table = 1347 1347 kmalloc_array(msb->logical_block_count, sizeof(u16), 1348 1348 GFP_KERNEL); 1349 1349 1350 1350 if (!msb->used_blocks_bitmap || !msb->lba_to_pba_table || 1351 1351 !msb->erased_blocks_bitmap) { 1352 - kfree(msb->used_blocks_bitmap); 1352 + bitmap_free(msb->used_blocks_bitmap); 1353 + bitmap_free(msb->erased_blocks_bitmap); 1353 1354 kfree(msb->lba_to_pba_table); 1354 - kfree(msb->erased_blocks_bitmap); 1355 1355 return -ENOMEM; 1356 1356 } 1357 1357 ··· 1946 1946 static void msb_data_clear(struct msb_data *msb) 1947 1947 { 1948 1948 kfree(msb->boot_page); 1949 - kfree(msb->used_blocks_bitmap); 1949 + bitmap_free(msb->used_blocks_bitmap); 1950 + bitmap_free(msb->erased_blocks_bitmap); 1950 1951 kfree(msb->lba_to_pba_table); 1951 1952 kfree(msb->cache); 1952 1953 msb->card = NULL; ··· 2244 2243 goto out; 2245 2244 2246 2245 if (msb->block_count != new_msb->block_count || 2247 - memcmp(msb->used_blocks_bitmap, new_msb->used_blocks_bitmap, 2248 - msb->block_count / 8)) 2246 + !bitmap_equal(msb->used_blocks_bitmap, new_msb->used_blocks_bitmap, 2247 + msb->block_count)) 2249 2248 goto out; 2250 2249 2251 2250 card_dead = false;
+16 -16
drivers/mmc/core/block.c
··· 176 176 unsigned int part_type); 177 177 static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, 178 178 struct mmc_card *card, 179 - int disable_multi, 179 + int recovery_mode, 180 180 struct mmc_queue *mq); 181 181 static void mmc_blk_hsq_req_done(struct mmc_request *mrq); 182 182 ··· 1302 1302 } 1303 1303 1304 1304 static void mmc_blk_data_prep(struct mmc_queue *mq, struct mmc_queue_req *mqrq, 1305 - int disable_multi, bool *do_rel_wr_p, 1305 + int recovery_mode, bool *do_rel_wr_p, 1306 1306 bool *do_data_tag_p) 1307 1307 { 1308 1308 struct mmc_blk_data *md = mq->blkdata; ··· 1368 1368 brq->data.blocks--; 1369 1369 1370 1370 /* 1371 - * After a read error, we redo the request one sector 1371 + * After a read error, we redo the request one (native) sector 1372 1372 * at a time in order to accurately determine which 1373 1373 * sectors can be read successfully. 1374 1374 */ 1375 - if (disable_multi) 1376 - brq->data.blocks = 1; 1375 + if (recovery_mode) 1376 + brq->data.blocks = queue_physical_block_size(mq->queue) >> 9; 1377 1377 1378 1378 /* 1379 1379 * Some controllers have HW issues while operating ··· 1590 1590 1591 1591 static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, 1592 1592 struct mmc_card *card, 1593 - int disable_multi, 1593 + int recovery_mode, 1594 1594 struct mmc_queue *mq) 1595 1595 { 1596 1596 u32 readcmd, writecmd; ··· 1599 1599 struct mmc_blk_data *md = mq->blkdata; 1600 1600 bool do_rel_wr, do_data_tag; 1601 1601 1602 - mmc_blk_data_prep(mq, mqrq, disable_multi, &do_rel_wr, &do_data_tag); 1602 + mmc_blk_data_prep(mq, mqrq, recovery_mode, &do_rel_wr, &do_data_tag); 1603 1603 1604 1604 brq->mrq.cmd = &brq->cmd; 1605 1605 ··· 1690 1690 1691 1691 #define MMC_READ_SINGLE_RETRIES 2 1692 1692 1693 - /* Single sector read during recovery */ 1693 + /* Single (native) sector read during recovery */ 1694 1694 static void mmc_blk_read_single(struct mmc_queue *mq, struct request *req) 1695 1695 { 1696 1696 struct mmc_queue_req *mqrq = req_to_mmc_queue_req(req); ··· 1698 1698 struct mmc_card *card = mq->card; 1699 1699 struct mmc_host *host = card->host; 1700 1700 blk_status_t error = BLK_STS_OK; 1701 + size_t bytes_per_read = queue_physical_block_size(mq->queue); 1701 1702 1702 1703 do { 1703 1704 u32 status; ··· 1733 1732 else 1734 1733 error = BLK_STS_OK; 1735 1734 1736 - } while (blk_update_request(req, error, 512)); 1735 + } while (blk_update_request(req, error, bytes_per_read)); 1737 1736 1738 1737 return; 1739 1738 1740 1739 error_exit: 1741 1740 mrq->data->bytes_xfered = 0; 1742 - blk_update_request(req, BLK_STS_IOERR, 512); 1741 + blk_update_request(req, BLK_STS_IOERR, bytes_per_read); 1743 1742 /* Let it try the remaining request again */ 1744 1743 if (mqrq->retries > MMC_MAX_RETRIES - 1) 1745 1744 mqrq->retries = MMC_MAX_RETRIES - 1; ··· 1880 1879 return; 1881 1880 } 1882 1881 1883 - /* FIXME: Missing single sector read for large sector size */ 1884 - if (!mmc_large_sector(card) && rq_data_dir(req) == READ && 1885 - brq->data.blocks > 1) { 1886 - /* Read one sector at a time */ 1882 + if (rq_data_dir(req) == READ && brq->data.blocks > 1883 + queue_physical_block_size(mq->queue) >> 9) { 1884 + /* Read one (native) sector at a time */ 1887 1885 mmc_blk_read_single(mq, req); 1888 1886 return; 1889 1887 } ··· 2988 2988 * Don't enable runtime PM for SD-combo cards here. Leave that 2989 2989 * decision to be taken during the SDIO init sequence instead. 2990 2990 */ 2991 - if (card->type != MMC_TYPE_SD_COMBO) { 2991 + if (!mmc_card_sd_combo(card)) { 2992 2992 pm_runtime_set_active(&card->dev); 2993 2993 pm_runtime_enable(&card->dev); 2994 2994 } ··· 3015 3015 mmc_blk_part_switch(card, md->part_type); 3016 3016 mmc_release_host(card->host); 3017 3017 } 3018 - if (card->type != MMC_TYPE_SD_COMBO) 3018 + if (!mmc_card_sd_combo(card)) 3019 3019 pm_runtime_disable(&card->dev); 3020 3020 pm_runtime_put_noidle(&card->dev); 3021 3021 mmc_blk_remove_req(md);
+2 -2
drivers/mmc/core/bus.c
··· 85 85 return retval; 86 86 } 87 87 88 - if (card->type == MMC_TYPE_SDIO || card->type == MMC_TYPE_SD_COMBO) { 88 + if (mmc_card_sdio(card) || mmc_card_sd_combo(card)) { 89 89 retval = add_uevent_var(env, "SDIO_ID=%04X:%04X", 90 90 card->cis.vendor, card->cis.device); 91 91 if (retval) ··· 107 107 * SDIO (non-combo) cards are not handled by mmc_block driver and do not 108 108 * have accessible CID register which used by mmc_card_name() function. 109 109 */ 110 - if (card->type == MMC_TYPE_SDIO) 110 + if (mmc_card_sdio(card)) 111 111 return 0; 112 112 113 113 retval = add_uevent_var(env, "MMC_NAME=%s", mmc_card_name(card));
+9 -1
drivers/mmc/core/core.c
··· 943 943 } 944 944 945 945 /* Only print error when we don't check for card removal */ 946 - if (!host->detect_change) 946 + if (!host->detect_change) { 947 947 pr_err("%s: tuning execution failed: %d\n", 948 948 mmc_hostname(host), err); 949 + mmc_debugfs_err_stats_inc(host, MMC_ERR_TUNING); 950 + } 949 951 950 952 return err; 951 953 } ··· 2246 2244 if (freqs[i] <= host->f_min) 2247 2245 break; 2248 2246 } 2247 + 2248 + /* 2249 + * Ignore the command timeout errors observed during 2250 + * the card init as those are excepted. 2251 + */ 2252 + host->err_stats[MMC_ERR_CMD_TIMEOUT] = 0; 2249 2253 mmc_release_host(host); 2250 2254 2251 2255 out:
+80
drivers/mmc/core/debugfs.c
··· 223 223 DEFINE_DEBUGFS_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set, 224 224 "%llu\n"); 225 225 226 + static int mmc_err_state_get(void *data, u64 *val) 227 + { 228 + struct mmc_host *host = data; 229 + int i; 230 + 231 + if (!host) 232 + return -EINVAL; 233 + 234 + *val = 0; 235 + for (i = 0; i < MMC_ERR_MAX; i++) { 236 + if (host->err_stats[i]) { 237 + *val = 1; 238 + break; 239 + } 240 + } 241 + 242 + return 0; 243 + } 244 + 245 + DEFINE_DEBUGFS_ATTRIBUTE(mmc_err_state, mmc_err_state_get, NULL, "%llu\n"); 246 + 247 + static int mmc_err_stats_show(struct seq_file *file, void *data) 248 + { 249 + struct mmc_host *host = (struct mmc_host *)file->private; 250 + const char *desc[MMC_ERR_MAX] = { 251 + [MMC_ERR_CMD_TIMEOUT] = "Command Timeout Occurred", 252 + [MMC_ERR_CMD_CRC] = "Command CRC Errors Occurred", 253 + [MMC_ERR_DAT_TIMEOUT] = "Data Timeout Occurred", 254 + [MMC_ERR_DAT_CRC] = "Data CRC Errors Occurred", 255 + [MMC_ERR_AUTO_CMD] = "Auto-Cmd Error Occurred", 256 + [MMC_ERR_ADMA] = "ADMA Error Occurred", 257 + [MMC_ERR_TUNING] = "Tuning Error Occurred", 258 + [MMC_ERR_CMDQ_RED] = "CMDQ RED Errors", 259 + [MMC_ERR_CMDQ_GCE] = "CMDQ GCE Errors", 260 + [MMC_ERR_CMDQ_ICCE] = "CMDQ ICCE Errors", 261 + [MMC_ERR_REQ_TIMEOUT] = "Request Timedout", 262 + [MMC_ERR_CMDQ_REQ_TIMEOUT] = "CMDQ Request Timedout", 263 + [MMC_ERR_ICE_CFG] = "ICE Config Errors", 264 + [MMC_ERR_CTRL_TIMEOUT] = "Controller Timedout errors", 265 + [MMC_ERR_UNEXPECTED_IRQ] = "Unexpected IRQ errors", 266 + }; 267 + int i; 268 + 269 + for (i = 0; i < MMC_ERR_MAX; i++) { 270 + if (desc[i]) 271 + seq_printf(file, "# %s:\t %d\n", 272 + desc[i], host->err_stats[i]); 273 + } 274 + 275 + return 0; 276 + } 277 + 278 + static int mmc_err_stats_open(struct inode *inode, struct file *file) 279 + { 280 + return single_open(file, mmc_err_stats_show, inode->i_private); 281 + } 282 + 283 + static ssize_t mmc_err_stats_write(struct file *filp, const char __user *ubuf, 284 + size_t cnt, loff_t *ppos) 285 + { 286 + struct mmc_host *host = filp->f_mapping->host->i_private; 287 + 288 + pr_debug("%s: Resetting MMC error statistics\n", __func__); 289 + memset(host->err_stats, 0, sizeof(host->err_stats)); 290 + 291 + return cnt; 292 + } 293 + 294 + static const struct file_operations mmc_err_stats_fops = { 295 + .open = mmc_err_stats_open, 296 + .read = seq_read, 297 + .write = mmc_err_stats_write, 298 + .release = single_release, 299 + }; 300 + 226 301 void mmc_add_host_debugfs(struct mmc_host *host) 227 302 { 228 303 struct dentry *root; ··· 310 235 debugfs_create_x32("caps2", S_IRUSR, root, &host->caps2); 311 236 debugfs_create_file_unsafe("clock", S_IRUSR | S_IWUSR, root, host, 312 237 &mmc_clock_fops); 238 + 239 + debugfs_create_file_unsafe("err_state", 0600, root, host, 240 + &mmc_err_state); 241 + debugfs_create_file("err_stats", 0600, root, host, 242 + &mmc_err_stats_fops); 313 243 314 244 #ifdef CONFIG_FAIL_MMC_REQUEST 315 245 if (fail_request)
+1 -1
drivers/mmc/core/host.c
··· 599 599 } 600 600 601 601 if (caps2 & (MMC_CAP2_HS400_ES | MMC_CAP2_HS400) && 602 - !(caps & MMC_CAP_8_BIT_DATA)) { 602 + !(caps & MMC_CAP_8_BIT_DATA) && !(caps2 & MMC_CAP2_NO_MMC)) { 603 603 dev_warn(dev, "drop HS400 support since no 8-bit bus\n"); 604 604 host->caps2 = caps2 & ~MMC_CAP2_HS400_ES & ~MMC_CAP2_HS400; 605 605 }
+3 -1
drivers/mmc/core/quirks.h
··· 163 163 struct device_node *np; 164 164 165 165 for_each_child_of_node(mmc_dev(card->host)->of_node, np) { 166 - if (of_device_is_compatible(np, compatible)) 166 + if (of_device_is_compatible(np, compatible)) { 167 + of_node_put(np); 167 168 return true; 169 + } 168 170 } 169 171 170 172 return false;
+2 -2
drivers/mmc/core/sd.c
··· 793 793 attr == &dev_attr_info2.attr || 794 794 attr == &dev_attr_info3.attr || 795 795 attr == &dev_attr_info4.attr 796 - ) && card->type != MMC_TYPE_SD_COMBO) 796 + ) &&!mmc_card_sd_combo(card)) 797 797 return 0; 798 798 799 799 return attr->mode; ··· 870 870 * the CCS bit is set as well. We deliberately deviate from the spec in 871 871 * regards to this, which allows UHS-I to be supported for SDSC cards. 872 872 */ 873 - if (!mmc_host_is_spi(host) && rocr && (*rocr & 0x01000000)) { 873 + if (!mmc_host_is_spi(host) && rocr && (*rocr & SD_ROCR_S18A)) { 874 874 err = mmc_set_uhs_voltage(host, pocr); 875 875 if (err == -EAGAIN) { 876 876 retries--;
+22 -8
drivers/mmc/core/sdio.c
··· 226 226 card->sw_caps.sd3_drv_type |= SD_DRIVER_TYPE_C; 227 227 if (data & SDIO_DRIVE_SDTD) 228 228 card->sw_caps.sd3_drv_type |= SD_DRIVER_TYPE_D; 229 + 230 + ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTERRUPT_EXT, 0, &data); 231 + if (ret) 232 + goto out; 233 + 234 + if (data & SDIO_INTERRUPT_EXT_SAI) { 235 + data |= SDIO_INTERRUPT_EXT_EAI; 236 + ret = mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_INTERRUPT_EXT, 237 + data, NULL); 238 + if (ret) 239 + goto out; 240 + 241 + card->cccr.enable_async_irq = 1; 242 + } 229 243 } 230 244 231 245 /* if no uhs mode ensure we check for high speed */ ··· 349 335 { 350 336 int err; 351 337 352 - if (card->type == MMC_TYPE_SDIO) 338 + if (mmc_card_sdio(card)) 353 339 goto out; 354 340 355 341 if (!(card->host->caps & MMC_CAP_4_BIT_DATA)) ··· 374 360 err = sdio_enable_wide(card); 375 361 if (err <= 0) 376 362 return err; 377 - if (card->type == MMC_TYPE_SDIO) 363 + if (mmc_card_sdio(card)) 378 364 goto out; 379 365 380 366 if (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4) { ··· 429 415 int ret; 430 416 431 417 ret = mmc_sdio_switch_hs(card, true); 432 - if (ret <= 0 || card->type == MMC_TYPE_SDIO) 418 + if (ret <= 0 || mmc_card_sdio(card)) 433 419 return ret; 434 420 435 421 ret = mmc_sd_switch_hs(card); ··· 455 441 max_dtr = card->cis.max_dtr; 456 442 } 457 443 458 - if (card->type == MMC_TYPE_SD_COMBO) 444 + if (mmc_card_sd_combo(card)) 459 445 max_dtr = min(max_dtr, mmc_sd_get_max_clock(card)); 460 446 461 447 return max_dtr; ··· 703 689 mmc_sd_get_cid(host, ocr & rocr, card->raw_cid, NULL) == 0) { 704 690 card->type = MMC_TYPE_SD_COMBO; 705 691 706 - if (oldcard && (oldcard->type != MMC_TYPE_SD_COMBO || 692 + if (oldcard && (!mmc_card_sd_combo(oldcard) || 707 693 memcmp(card->raw_cid, oldcard->raw_cid, sizeof(card->raw_cid)) != 0)) { 708 694 err = -ENOENT; 709 695 goto mismatch; ··· 711 697 } else { 712 698 card->type = MMC_TYPE_SDIO; 713 699 714 - if (oldcard && oldcard->type != MMC_TYPE_SDIO) { 700 + if (oldcard && !mmc_card_sdio(oldcard)) { 715 701 err = -ENOENT; 716 702 goto mismatch; 717 703 } ··· 768 754 /* 769 755 * Read CSD, before selecting the card 770 756 */ 771 - if (!oldcard && card->type == MMC_TYPE_SD_COMBO) { 757 + if (!oldcard && mmc_card_sd_combo(card)) { 772 758 err = mmc_sd_get_csd(card); 773 759 if (err) 774 760 goto remove; ··· 841 827 842 828 mmc_fixup_device(card, sdio_fixup_methods); 843 829 844 - if (card->type == MMC_TYPE_SD_COMBO) { 830 + if (mmc_card_sd_combo(card)) { 845 831 err = mmc_sd_setup_card(host, card, oldcard != NULL); 846 832 /* handle as SDIO-only card if memory init failed */ 847 833 if (err) {
+1
drivers/mmc/host/cavium-octeon.c
··· 277 277 if (ret) { 278 278 dev_err(&pdev->dev, "Error populating slots\n"); 279 279 octeon_mmc_set_shared_power(host, 0); 280 + of_node_put(cn); 280 281 goto error; 281 282 } 282 283 i++;
+3 -1
drivers/mmc/host/cavium-thunderx.c
··· 142 142 continue; 143 143 144 144 ret = cvm_mmc_of_slot_probe(&host->slot_pdev[i]->dev, host); 145 - if (ret) 145 + if (ret) { 146 + of_node_put(child_node); 146 147 goto error; 148 + } 147 149 } 148 150 i++; 149 151 }
+8 -1
drivers/mmc/host/cqhci-core.c
··· 822 822 pr_debug("%s: cqhci: IRQ status: 0x%08x\n", mmc_hostname(mmc), status); 823 823 824 824 if ((status & (CQHCI_IS_RED | CQHCI_IS_GCE | CQHCI_IS_ICCE)) || 825 - cmd_error || data_error) 825 + cmd_error || data_error) { 826 + if (status & CQHCI_IS_RED) 827 + mmc_debugfs_err_stats_inc(mmc, MMC_ERR_CMDQ_RED); 828 + if (status & CQHCI_IS_GCE) 829 + mmc_debugfs_err_stats_inc(mmc, MMC_ERR_CMDQ_GCE); 830 + if (status & CQHCI_IS_ICCE) 831 + mmc_debugfs_err_stats_inc(mmc, MMC_ERR_CMDQ_ICCE); 826 832 cqhci_error_irq(mmc, status, cmd_error, data_error); 833 + } 827 834 828 835 if (status & CQHCI_IS_TCC) { 829 836 /* read TCN and complete the request */
+3 -1
drivers/mmc/host/dw_mmc-exynos.c
··· 670 670 pm_runtime_set_suspended(&pdev->dev); 671 671 pm_runtime_put_noidle(&pdev->dev); 672 672 673 - return dw_mci_pltfm_remove(pdev); 673 + dw_mci_pltfm_remove(pdev); 674 + 675 + return 0; 674 676 } 675 677 676 678 static const struct dev_pm_ops dw_mci_exynos_pmops = {
+3 -1
drivers/mmc/host/dw_mmc-hi3798cv200.c
··· 179 179 clk_disable_unprepare(priv->drive_clk); 180 180 clk_disable_unprepare(priv->sample_clk); 181 181 182 - return dw_mci_pltfm_remove(pdev); 182 + dw_mci_pltfm_remove(pdev); 183 + 184 + return 0; 183 185 } 184 186 185 187 static const struct of_device_id dw_mci_hi3798cv200_match[] = {
+3 -1
drivers/mmc/host/dw_mmc-rockchip.c
··· 377 377 pm_runtime_disable(&pdev->dev); 378 378 pm_runtime_put_noidle(&pdev->dev); 379 379 380 - return dw_mci_pltfm_remove(pdev); 380 + dw_mci_pltfm_remove(pdev); 381 + 382 + return 0; 381 383 } 382 384 383 385 static const struct dev_pm_ops dw_mci_rockchip_dev_pm_ops = {
+1 -1
drivers/mmc/host/mmci.c
··· 762 762 763 763 /* 764 764 * If only an RX channel is specified, the driver will 765 - * attempt to use it bidirectionally, however if it is 765 + * attempt to use it bidirectionally, however if it 766 766 * is specified but cannot be located, DMA will be disabled. 767 767 */ 768 768 if (dmae->rx_channel && !dmae->tx_channel)
+81 -7
drivers/mmc/host/mtk-sd.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 /* 3 - * Copyright (c) 2014-2015 MediaTek Inc. 3 + * Copyright (c) 2014-2015, 2022 MediaTek Inc. 4 4 * Author: Chaotian.Jing <chaotian.jing@mediatek.com> 5 5 */ 6 6 ··· 20 20 #include <linux/platform_device.h> 21 21 #include <linux/pm.h> 22 22 #include <linux/pm_runtime.h> 23 + #include <linux/pm_wakeirq.h> 23 24 #include <linux/regulator/consumer.h> 24 25 #include <linux/slab.h> 25 26 #include <linux/spinlock.h> ··· 441 440 struct pinctrl *pinctrl; 442 441 struct pinctrl_state *pins_default; 443 442 struct pinctrl_state *pins_uhs; 443 + struct pinctrl_state *pins_eint; 444 444 struct delayed_work req_timeout; 445 445 int irq; /* host interrupt */ 446 + int eint_irq; /* interrupt from sdio device for waking up system */ 446 447 struct reset_control *reset; 447 448 448 449 struct clk *src_clk; /* msdc source clock */ ··· 1524 1521 1525 1522 static void msdc_enable_sdio_irq(struct mmc_host *mmc, int enb) 1526 1523 { 1527 - unsigned long flags; 1528 1524 struct msdc_host *host = mmc_priv(mmc); 1525 + unsigned long flags; 1526 + int ret; 1529 1527 1530 1528 spin_lock_irqsave(&host->lock, flags); 1531 1529 __msdc_enable_sdio_irq(host, enb); 1532 1530 spin_unlock_irqrestore(&host->lock, flags); 1533 1531 1534 - if (enb) 1535 - pm_runtime_get_noresume(host->dev); 1536 - else 1537 - pm_runtime_put_noidle(host->dev); 1532 + if (mmc_card_enable_async_irq(mmc->card) && host->pins_eint) { 1533 + if (enb) { 1534 + /* 1535 + * In dev_pm_set_dedicated_wake_irq_reverse(), eint pin will be set to 1536 + * GPIO mode. We need to restore it to SDIO DAT1 mode after that. 1537 + * Since the current pinstate is pins_uhs, to ensure pinctrl select take 1538 + * affect successfully, we change the pinstate to pins_eint firstly. 1539 + */ 1540 + pinctrl_select_state(host->pinctrl, host->pins_eint); 1541 + ret = dev_pm_set_dedicated_wake_irq_reverse(host->dev, host->eint_irq); 1542 + 1543 + if (ret) { 1544 + dev_err(host->dev, "Failed to register SDIO wakeup irq!\n"); 1545 + host->pins_eint = NULL; 1546 + pm_runtime_get_noresume(host->dev); 1547 + } else { 1548 + dev_dbg(host->dev, "SDIO eint irq: %d!\n", host->eint_irq); 1549 + } 1550 + 1551 + pinctrl_select_state(host->pinctrl, host->pins_uhs); 1552 + } else { 1553 + dev_pm_clear_wake_irq(host->dev); 1554 + } 1555 + } else { 1556 + if (enb) { 1557 + /* Ensure host->pins_eint is NULL */ 1558 + host->pins_eint = NULL; 1559 + pm_runtime_get_noresume(host->dev); 1560 + } else { 1561 + pm_runtime_put_noidle(host->dev); 1562 + } 1563 + } 1538 1564 } 1539 1565 1540 1566 static irqreturn_t msdc_cmdq_irq(struct msdc_host *host, u32 intsts) ··· 2351 2319 else 2352 2320 val = readl(host->base + PAD_DS_TUNE); 2353 2321 2354 - dev_info(host->dev, "Fianl PAD_DS_TUNE: 0x%x\n", val); 2322 + dev_info(host->dev, "Final PAD_DS_TUNE: 0x%x\n", val); 2355 2323 2356 2324 return 0; 2357 2325 ··· 2667 2635 goto host_free; 2668 2636 } 2669 2637 2638 + /* Support for SDIO eint irq ? */ 2639 + if ((mmc->pm_caps & MMC_PM_WAKE_SDIO_IRQ) && (mmc->pm_caps & MMC_PM_KEEP_POWER)) { 2640 + host->eint_irq = platform_get_irq_byname(pdev, "sdio_wakeup"); 2641 + if (host->eint_irq > 0) { 2642 + host->pins_eint = pinctrl_lookup_state(host->pinctrl, "state_eint"); 2643 + if (IS_ERR(host->pins_eint)) { 2644 + dev_err(&pdev->dev, "Cannot find pinctrl eint!\n"); 2645 + host->pins_eint = NULL; 2646 + } else { 2647 + device_init_wakeup(&pdev->dev, true); 2648 + } 2649 + } 2650 + } 2651 + 2670 2652 msdc_of_property_parse(pdev, host); 2671 2653 2672 2654 host->dev = &pdev->dev; ··· 2895 2849 struct msdc_host *host = mmc_priv(mmc); 2896 2850 2897 2851 msdc_save_reg(host); 2852 + 2853 + if (sdio_irq_claimed(mmc)) { 2854 + if (host->pins_eint) { 2855 + disable_irq(host->irq); 2856 + pinctrl_select_state(host->pinctrl, host->pins_eint); 2857 + } 2858 + 2859 + __msdc_enable_sdio_irq(host, 0); 2860 + } 2898 2861 msdc_gate_clock(host); 2899 2862 return 0; 2900 2863 } ··· 2919 2864 return ret; 2920 2865 2921 2866 msdc_restore_reg(host); 2867 + 2868 + if (sdio_irq_claimed(mmc) && host->pins_eint) { 2869 + pinctrl_select_state(host->pinctrl, host->pins_uhs); 2870 + enable_irq(host->irq); 2871 + } 2922 2872 return 0; 2923 2873 } 2924 2874 2925 2875 static int __maybe_unused msdc_suspend(struct device *dev) 2926 2876 { 2927 2877 struct mmc_host *mmc = dev_get_drvdata(dev); 2878 + struct msdc_host *host = mmc_priv(mmc); 2928 2879 int ret; 2929 2880 2930 2881 if (mmc->caps2 & MMC_CAP2_CQE) { ··· 2939 2878 return ret; 2940 2879 } 2941 2880 2881 + /* 2882 + * Bump up runtime PM usage counter otherwise dev->power.needs_force_resume will 2883 + * not be marked as 1, pm_runtime_force_resume() will go out directly. 2884 + */ 2885 + if (sdio_irq_claimed(mmc) && host->pins_eint) 2886 + pm_runtime_get_noresume(dev); 2887 + 2942 2888 return pm_runtime_force_suspend(dev); 2943 2889 } 2944 2890 2945 2891 static int __maybe_unused msdc_resume(struct device *dev) 2946 2892 { 2893 + struct mmc_host *mmc = dev_get_drvdata(dev); 2894 + struct msdc_host *host = mmc_priv(mmc); 2895 + 2896 + if (sdio_irq_claimed(mmc) && host->pins_eint) 2897 + pm_runtime_put_noidle(dev); 2898 + 2947 2899 return pm_runtime_force_resume(dev); 2948 2900 } 2949 2901
+2 -2
drivers/mmc/host/mxcmmc.c
··· 923 923 * One way to prevent this is to only allow 1-bit transfers. 924 924 */ 925 925 926 - if (is_imx31_mmc(mxcmci) && card->type == MMC_TYPE_SDIO) 926 + if (is_imx31_mmc(mxcmci) && mmc_card_sdio(card)) 927 927 host->caps &= ~MMC_CAP_4_BIT_DATA; 928 928 else 929 929 host->caps |= MMC_CAP_4_BIT_DATA; ··· 1025 1025 mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; 1026 1026 mmc->max_seg_size = mmc->max_req_size; 1027 1027 1028 - host->devtype = (enum mxcmci_type)of_device_get_match_data(&pdev->dev); 1028 + host->devtype = (uintptr_t)of_device_get_match_data(&pdev->dev); 1029 1029 1030 1030 /* adjust max_segs after devtype detection */ 1031 1031 if (!is_mpc512x_mmc(host))
+1
drivers/mmc/host/renesas_sdhi.h
··· 43 43 bool hs400_4taps; 44 44 bool fixed_addr_mode; 45 45 bool dma_one_rx_only; 46 + bool manual_tap_correction; 46 47 u32 hs400_bad_taps; 47 48 const u8 (*hs400_calib_table)[SDHI_CALIB_TABLE_MAX]; 48 49 };
+20 -22
drivers/mmc/host/renesas_sdhi_core.c
··· 49 49 #define HOST_MODE_GEN3_32BIT (HOST_MODE_GEN3_WMODE | HOST_MODE_GEN3_BUSWIDTH) 50 50 #define HOST_MODE_GEN3_64BIT 0 51 51 52 - #define CTL_SDIF_MODE 0xe6 53 - #define SDIF_MODE_HS400 BIT(0) 54 - 55 52 #define SDHI_VER_GEN2_SDR50 0x490c 56 53 #define SDHI_VER_RZ_A1 0x820b 57 54 /* very old datasheets said 0x490c for SDR104, too. They are wrong! */ ··· 380 383 sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_DT2FF, 381 384 priv->scc_tappos_hs400); 382 385 383 - /* Gen3 can't do automatic tap correction with HS400, so disable it */ 384 - if (sd_ctrl_read16(host, CTL_VERSION) == SDHI_VER_GEN3_SDMMC) 386 + if (priv->quirks && priv->quirks->manual_tap_correction) 385 387 sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL, 386 388 ~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN & 387 389 sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL)); ··· 558 562 } 559 563 560 564 /* only populated for TMIO_MMC_MIN_RCAR2 */ 561 - static void renesas_sdhi_reset(struct tmio_mmc_host *host) 565 + static void renesas_sdhi_reset(struct tmio_mmc_host *host, bool preserve) 562 566 { 563 567 struct renesas_sdhi *priv = host_to_priv(host); 564 568 int ret; 565 569 u16 val; 566 570 567 - if (priv->rstc) { 568 - reset_control_reset(priv->rstc); 569 - /* Unknown why but without polling reset status, it will hang */ 570 - read_poll_timeout(reset_control_status, ret, ret == 0, 1, 100, 571 - false, priv->rstc); 572 - /* At least SDHI_VER_GEN2_SDR50 needs manual release of reset */ 573 - sd_ctrl_write16(host, CTL_RESET_SD, 0x0001); 574 - priv->needs_adjust_hs400 = false; 575 - renesas_sdhi_set_clock(host, host->clk_cache); 576 - } else if (priv->scc_ctl) { 577 - renesas_sdhi_scc_reset(host, priv); 571 + if (!preserve) { 572 + if (priv->rstc) { 573 + reset_control_reset(priv->rstc); 574 + /* Unknown why but without polling reset status, it will hang */ 575 + read_poll_timeout(reset_control_status, ret, ret == 0, 1, 100, 576 + false, priv->rstc); 577 + /* At least SDHI_VER_GEN2_SDR50 needs manual release of reset */ 578 + sd_ctrl_write16(host, CTL_RESET_SD, 0x0001); 579 + priv->needs_adjust_hs400 = false; 580 + renesas_sdhi_set_clock(host, host->clk_cache); 581 + } else if (priv->scc_ctl) { 582 + renesas_sdhi_scc_reset(host, priv); 583 + } 578 584 } 579 585 580 586 if (sd_ctrl_read16(host, CTL_VERSION) >= SDHI_VER_GEN3_SD) { ··· 717 719 sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSREQ, 0); 718 720 719 721 /* Change TAP position according to correction status */ 720 - if (sd_ctrl_read16(host, CTL_VERSION) == SDHI_VER_GEN3_SDMMC && 722 + if (priv->quirks && priv->quirks->manual_tap_correction && 721 723 host->mmc->ios.timing == MMC_TIMING_MMC_HS400) { 722 724 u32 bad_taps = priv->quirks ? priv->quirks->hs400_bad_taps : 0; 723 725 /* ··· 936 938 if (IS_ERR(priv->clk_cd)) 937 939 return dev_err_probe(&pdev->dev, PTR_ERR(priv->clk_cd), "cannot get cd clock"); 938 940 941 + priv->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); 942 + if (IS_ERR(priv->rstc)) 943 + return PTR_ERR(priv->rstc); 944 + 939 945 priv->pinctrl = devm_pinctrl_get(&pdev->dev); 940 946 if (!IS_ERR(priv->pinctrl)) { 941 947 priv->pins_default = pinctrl_lookup_state(priv->pinctrl, ··· 1031 1029 ret = renesas_sdhi_clk_enable(host); 1032 1030 if (ret) 1033 1031 goto efree; 1034 - 1035 - priv->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); 1036 - if (IS_ERR(priv->rstc)) 1037 - return PTR_ERR(priv->rstc); 1038 1032 1039 1033 ver = sd_ctrl_read16(host, CTL_VERSION); 1040 1034 /* GEN2_SDR104 is first known SDHI to use 32bit block count */
+9 -2
drivers/mmc/host/renesas_sdhi_internal_dmac.c
··· 170 170 static const struct renesas_sdhi_quirks sdhi_quirks_4tap = { 171 171 .hs400_4taps = true, 172 172 .hs400_bad_taps = BIT(2) | BIT(3) | BIT(6) | BIT(7), 173 + .manual_tap_correction = true, 173 174 }; 174 175 175 176 static const struct renesas_sdhi_quirks sdhi_quirks_nohs400 = { ··· 183 182 184 183 static const struct renesas_sdhi_quirks sdhi_quirks_bad_taps1357 = { 185 184 .hs400_bad_taps = BIT(1) | BIT(3) | BIT(5) | BIT(7), 185 + .manual_tap_correction = true, 186 186 }; 187 187 188 188 static const struct renesas_sdhi_quirks sdhi_quirks_bad_taps2367 = { 189 189 .hs400_bad_taps = BIT(2) | BIT(3) | BIT(6) | BIT(7), 190 + .manual_tap_correction = true, 190 191 }; 191 192 192 193 static const struct renesas_sdhi_quirks sdhi_quirks_r8a7796_es13 = { 193 194 .hs400_4taps = true, 194 195 .hs400_bad_taps = BIT(2) | BIT(3) | BIT(6) | BIT(7), 195 196 .hs400_calib_table = r8a7796_es13_calib_table, 197 + .manual_tap_correction = true, 196 198 }; 197 199 198 200 static const struct renesas_sdhi_quirks sdhi_quirks_r8a77965 = { 199 201 .hs400_bad_taps = BIT(2) | BIT(3) | BIT(6) | BIT(7), 200 202 .hs400_calib_table = r8a77965_calib_table, 203 + .manual_tap_correction = true, 201 204 }; 202 205 203 206 static const struct renesas_sdhi_quirks sdhi_quirks_r8a77990 = { 204 207 .hs400_calib_table = r8a77990_calib_table, 208 + .manual_tap_correction = true, 205 209 }; 206 210 207 211 /* ··· 274 268 { .compatible = "renesas,sdhi-r8a77990", .data = &of_r8a77990_compatible, }, 275 269 { .compatible = "renesas,sdhi-r8a77995", .data = &of_rcar_gen3_nohs400_compatible, }, 276 270 { .compatible = "renesas,rcar-gen3-sdhi", .data = &of_rcar_gen3_compatible, }, 271 + { .compatible = "renesas,rcar-gen4-sdhi", .data = &of_rcar_gen3_compatible, }, 277 272 {}, 278 273 }; 279 274 MODULE_DEVICE_TABLE(of, renesas_sdhi_internal_dmac_of_match); ··· 328 321 } 329 322 330 323 /* 331 - * renesas_sdhi_internal_dmac_map() will be called with two difference 324 + * renesas_sdhi_internal_dmac_map() will be called with two different 332 325 * sg pointers in two mmc_data by .pre_req(), but tmio host can have a single 333 326 * sg_ptr only. So, renesas_sdhi_internal_dmac_{un}map() should use a sg 334 327 * pointer in a mmc_data instead of host->sg_ptr. ··· 362 355 363 356 data->host_cookie = cookie; 364 357 365 - /* This DMAC cannot handle if buffer is not 128-bytes alignment */ 358 + /* This DMAC needs buffers to be 128-byte aligned */ 366 359 if (!IS_ALIGNED(sg_dma_address(data->sg), 128)) { 367 360 renesas_sdhi_internal_dmac_unmap(host, data, cookie); 368 361 return false;
+75 -1
drivers/mmc/host/sdhci-brcmstb.c
··· 31 31 struct sdhci_brcmstb_priv { 32 32 void __iomem *cfg_regs; 33 33 unsigned int flags; 34 + struct clk *base_clk; 35 + u32 base_freq_hz; 34 36 }; 35 37 36 38 struct brcmstb_match_priv { ··· 252 250 struct sdhci_pltfm_host *pltfm_host; 253 251 const struct of_device_id *match; 254 252 struct sdhci_brcmstb_priv *priv; 253 + u32 actual_clock_mhz; 255 254 struct sdhci_host *host; 256 255 struct resource *iomem; 257 256 struct clk *clk; 257 + struct clk *base_clk = NULL; 258 258 int res; 259 259 260 260 match = of_match_node(sdhci_brcm_of_match, pdev->dev.of_node); ··· 334 330 if (match_priv->flags & BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT) 335 331 host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; 336 332 333 + /* Change the base clock frequency if the DT property exists */ 334 + if (device_property_read_u32(&pdev->dev, "clock-frequency", 335 + &priv->base_freq_hz) != 0) 336 + goto add_host; 337 + 338 + base_clk = devm_clk_get_optional(&pdev->dev, "sdio_freq"); 339 + if (IS_ERR(base_clk)) { 340 + dev_warn(&pdev->dev, "Clock for \"sdio_freq\" not found\n"); 341 + goto add_host; 342 + } 343 + 344 + res = clk_prepare_enable(base_clk); 345 + if (res) 346 + goto err; 347 + 348 + /* set improved clock rate */ 349 + clk_set_rate(base_clk, priv->base_freq_hz); 350 + actual_clock_mhz = clk_get_rate(base_clk) / 1000000; 351 + 352 + host->caps &= ~SDHCI_CLOCK_V3_BASE_MASK; 353 + host->caps |= (actual_clock_mhz << SDHCI_CLOCK_BASE_SHIFT); 354 + /* Disable presets because they are now incorrect */ 355 + host->quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN; 356 + 357 + dev_dbg(&pdev->dev, "Base Clock Frequency changed to %dMHz\n", 358 + actual_clock_mhz); 359 + priv->base_clk = base_clk; 360 + 361 + add_host: 337 362 res = sdhci_brcmstb_add_host(host, priv); 338 363 if (res) 339 364 goto err; ··· 373 340 err: 374 341 sdhci_pltfm_free(pdev); 375 342 err_clk: 343 + clk_disable_unprepare(base_clk); 376 344 clk_disable_unprepare(clk); 377 345 return res; 378 346 } ··· 385 351 386 352 MODULE_DEVICE_TABLE(of, sdhci_brcm_of_match); 387 353 354 + #ifdef CONFIG_PM_SLEEP 355 + static int sdhci_brcmstb_suspend(struct device *dev) 356 + { 357 + struct sdhci_host *host = dev_get_drvdata(dev); 358 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 359 + struct sdhci_brcmstb_priv *priv = sdhci_pltfm_priv(pltfm_host); 360 + 361 + clk_disable_unprepare(priv->base_clk); 362 + return sdhci_pltfm_suspend(dev); 363 + } 364 + 365 + static int sdhci_brcmstb_resume(struct device *dev) 366 + { 367 + struct sdhci_host *host = dev_get_drvdata(dev); 368 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 369 + struct sdhci_brcmstb_priv *priv = sdhci_pltfm_priv(pltfm_host); 370 + int ret; 371 + 372 + ret = sdhci_pltfm_resume(dev); 373 + if (!ret && priv->base_freq_hz) { 374 + ret = clk_prepare_enable(priv->base_clk); 375 + /* 376 + * Note: using clk_get_rate() below as clk_get_rate() 377 + * honors CLK_GET_RATE_NOCACHE attribute, but clk_set_rate() 378 + * may do implicit get_rate() calls that do not honor 379 + * CLK_GET_RATE_NOCACHE. 380 + */ 381 + if (!ret && 382 + (clk_get_rate(priv->base_clk) != priv->base_freq_hz)) 383 + ret = clk_set_rate(priv->base_clk, priv->base_freq_hz); 384 + } 385 + 386 + return ret; 387 + } 388 + #endif 389 + 390 + static const struct dev_pm_ops sdhci_brcmstb_pmops = { 391 + SET_SYSTEM_SLEEP_PM_OPS(sdhci_brcmstb_suspend, sdhci_brcmstb_resume) 392 + }; 393 + 388 394 static struct platform_driver sdhci_brcmstb_driver = { 389 395 .driver = { 390 396 .name = "sdhci-brcmstb", 391 397 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 392 - .pm = &sdhci_pltfm_pmops, 398 + .pm = &sdhci_brcmstb_pmops, 393 399 .of_match_table = of_match_ptr(sdhci_brcm_of_match), 394 400 }, 395 401 .probe = sdhci_brcmstb_probe,
+4 -25
drivers/mmc/host/sdhci-msm.c
··· 2435 2435 }; 2436 2436 2437 2437 static const struct of_device_id sdhci_msm_dt_match[] = { 2438 - /* Following two entries are deprecated (kept only for backward compatibility) */ 2438 + /* 2439 + * Do not add new variants to the driver which are compatible with 2440 + * generic ones, unless they need customization. 2441 + */ 2439 2442 {.compatible = "qcom,sdhci-msm-v4", .data = &sdhci_msm_mci_var}, 2440 2443 {.compatible = "qcom,sdhci-msm-v5", .data = &sdhci_msm_v5_var}, 2441 - /* Add entries for sdcc versions less than 5.0 here */ 2442 - {.compatible = "qcom,apq8084-sdhci", .data = &sdhci_msm_mci_var}, 2443 - {.compatible = "qcom,msm8226-sdhci", .data = &sdhci_msm_mci_var}, 2444 - {.compatible = "qcom,msm8916-sdhci", .data = &sdhci_msm_mci_var}, 2445 - {.compatible = "qcom,msm8953-sdhci", .data = &sdhci_msm_mci_var}, 2446 - {.compatible = "qcom,msm8974-sdhci", .data = &sdhci_msm_mci_var}, 2447 - {.compatible = "qcom,msm8992-sdhci", .data = &sdhci_msm_mci_var}, 2448 - {.compatible = "qcom,msm8994-sdhci", .data = &sdhci_msm_mci_var}, 2449 - {.compatible = "qcom,msm8996-sdhci", .data = &sdhci_msm_mci_var}, 2450 - /* 2451 - * Add entries for sdcc version 5.0 here. For SDCC version 5.0.0, 2452 - * MCI registers are removed from SDCC interface and some registers 2453 - * are moved to HC. 2454 - */ 2455 - {.compatible = "qcom,qcs404-sdhci", .data = &sdhci_msm_v5_var}, 2456 - {.compatible = "qcom,sdx55-sdhci", .data = &sdhci_msm_v5_var}, 2457 - {.compatible = "qcom,sdx65-sdhci", .data = &sdhci_msm_v5_var}, 2458 - {.compatible = "qcom,sdm630-sdhci", .data = &sdhci_msm_v5_var}, 2459 - {.compatible = "qcom,sm6125-sdhci", .data = &sdhci_msm_v5_var}, 2460 - {.compatible = "qcom,sm6350-sdhci", .data = &sdhci_msm_v5_var}, 2461 - {.compatible = "qcom,sm8150-sdhci", .data = &sdhci_msm_v5_var}, 2462 - {.compatible = "qcom,sm8250-sdhci", .data = &sdhci_msm_v5_var}, 2463 - {.compatible = "qcom,sc7280-sdhci", .data = &sdhci_msm_v5_var}, 2464 - /* Add entries where soc specific handling is required, here */ 2465 2444 {.compatible = "qcom,sdm845-sdhci", .data = &sdm845_sdhci_var}, 2466 2445 {.compatible = "qcom,sc7180-sdhci", .data = &sdm845_sdhci_var}, 2467 2446 {},
+2 -3
drivers/mmc/host/sdhci-of-arasan.c
··· 1733 1733 1734 1734 static int sdhci_arasan_remove(struct platform_device *pdev) 1735 1735 { 1736 - int ret; 1737 1736 struct sdhci_host *host = platform_get_drvdata(pdev); 1738 1737 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 1739 1738 struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host); ··· 1746 1747 1747 1748 sdhci_arasan_unregister_sdclk(&pdev->dev); 1748 1749 1749 - ret = sdhci_pltfm_unregister(pdev); 1750 + sdhci_pltfm_unregister(pdev); 1750 1751 1751 1752 clk_disable_unprepare(clk_ahb); 1752 1753 1753 - return ret; 1754 + return 0; 1754 1755 } 1755 1756 1756 1757 static struct platform_driver sdhci_arasan_driver = {
+7 -2
drivers/mmc/host/sdhci-of-at91.c
··· 100 100 static void sdhci_at91_set_uhs_signaling(struct sdhci_host *host, 101 101 unsigned int timing) 102 102 { 103 - if (timing == MMC_TIMING_MMC_DDR52) 104 - sdhci_writeb(host, SDMMC_MC1R_DDR, SDMMC_MC1R); 103 + u8 mc1r; 104 + 105 + if (timing == MMC_TIMING_MMC_DDR52) { 106 + mc1r = sdhci_readb(host, SDMMC_MC1R); 107 + mc1r |= SDMMC_MC1R_DDR; 108 + sdhci_writeb(host, mc1r, SDMMC_MC1R); 109 + } 105 110 sdhci_set_uhs_signaling(host, timing); 106 111 } 107 112
+151 -42
drivers/mmc/host/sdhci-of-dwcmshc.c
··· 15 15 #include <linux/module.h> 16 16 #include <linux/of.h> 17 17 #include <linux/of_device.h> 18 + #include <linux/reset.h> 18 19 #include <linux/sizes.h> 19 20 20 21 #include "sdhci-pltfm.h" ··· 31 30 /* Offset inside the vendor area 1 */ 32 31 #define DWCMSHC_HOST_CTRL3 0x8 33 32 #define DWCMSHC_EMMC_CONTROL 0x2c 33 + #define DWCMSHC_CARD_IS_EMMC BIT(0) 34 34 #define DWCMSHC_ENHANCED_STROBE BIT(8) 35 35 #define DWCMSHC_EMMC_ATCTRL 0x40 36 36 ··· 40 38 #define DWCMSHC_EMMC_DLL_RXCLK 0x804 41 39 #define DWCMSHC_EMMC_DLL_TXCLK 0x808 42 40 #define DWCMSHC_EMMC_DLL_STRBIN 0x80c 43 - #define DLL_STRBIN_TAPNUM_FROM_SW BIT(24) 41 + #define DECMSHC_EMMC_DLL_CMDOUT 0x810 44 42 #define DWCMSHC_EMMC_DLL_STATUS0 0x840 45 43 #define DWCMSHC_EMMC_DLL_START BIT(0) 46 44 #define DWCMSHC_EMMC_DLL_LOCKED BIT(8) ··· 49 47 #define DWCMSHC_EMMC_DLL_START_POINT 16 50 48 #define DWCMSHC_EMMC_DLL_INC 8 51 49 #define DWCMSHC_EMMC_DLL_DLYENA BIT(27) 52 - #define DLL_TXCLK_TAPNUM_DEFAULT 0x8 53 - #define DLL_STRBIN_TAPNUM_DEFAULT 0x8 50 + #define DLL_TXCLK_TAPNUM_DEFAULT 0x10 51 + #define DLL_TXCLK_TAPNUM_90_DEGREES 0xA 54 52 #define DLL_TXCLK_TAPNUM_FROM_SW BIT(24) 53 + #define DLL_STRBIN_TAPNUM_DEFAULT 0x8 54 + #define DLL_STRBIN_TAPNUM_FROM_SW BIT(24) 55 + #define DLL_STRBIN_DELAY_NUM_SEL BIT(26) 56 + #define DLL_STRBIN_DELAY_NUM_OFFSET 16 57 + #define DLL_STRBIN_DELAY_NUM_DEFAULT 0x16 55 58 #define DLL_RXCLK_NO_INVERTER 1 56 59 #define DLL_RXCLK_INVERTER 0 60 + #define DLL_CMDOUT_TAPNUM_90_DEGREES 0x8 61 + #define DLL_CMDOUT_TAPNUM_FROM_SW BIT(24) 62 + #define DLL_CMDOUT_SRC_CLK_NEG BIT(28) 63 + #define DLL_CMDOUT_EN_SRC_CLK_NEG BIT(29) 64 + 57 65 #define DLL_LOCK_WO_TMOUT(x) \ 58 66 ((((x) & DWCMSHC_EMMC_DLL_LOCKED) == DWCMSHC_EMMC_DLL_LOCKED) && \ 59 67 (((x) & DWCMSHC_EMMC_DLL_TIMEOUT) == 0)) 60 - #define RK3568_MAX_CLKS 3 68 + #define RK35xx_MAX_CLKS 3 61 69 62 70 #define BOUNDARY_OK(addr, len) \ 63 71 ((addr | (SZ_128M - 1)) == ((addr + len - 1) | (SZ_128M - 1))) 64 72 65 - struct rk3568_priv { 73 + enum dwcmshc_rk_type { 74 + DWCMSHC_RK3568, 75 + DWCMSHC_RK3588, 76 + }; 77 + 78 + struct rk35xx_priv { 66 79 /* Rockchip specified optional clocks */ 67 - struct clk_bulk_data rockchip_clks[RK3568_MAX_CLKS]; 80 + struct clk_bulk_data rockchip_clks[RK35xx_MAX_CLKS]; 81 + struct reset_control *reset; 82 + enum dwcmshc_rk_type devtype; 68 83 u8 txclk_tapnum; 69 84 }; 70 85 ··· 150 131 static void dwcmshc_set_uhs_signaling(struct sdhci_host *host, 151 132 unsigned int timing) 152 133 { 153 - u16 ctrl_2; 134 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 135 + struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); 136 + u16 ctrl, ctrl_2; 154 137 155 138 ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL2); 156 139 /* Select Bus Speed Mode for host */ ··· 170 149 else if ((timing == MMC_TIMING_UHS_DDR50) || 171 150 (timing == MMC_TIMING_MMC_DDR52)) 172 151 ctrl_2 |= SDHCI_CTRL_UHS_DDR50; 173 - else if (timing == MMC_TIMING_MMC_HS400) 152 + else if (timing == MMC_TIMING_MMC_HS400) { 153 + /* set CARD_IS_EMMC bit to enable Data Strobe for HS400 */ 154 + ctrl = sdhci_readw(host, priv->vendor_specific_area1 + DWCMSHC_EMMC_CONTROL); 155 + ctrl |= DWCMSHC_CARD_IS_EMMC; 156 + sdhci_writew(host, ctrl, priv->vendor_specific_area1 + DWCMSHC_EMMC_CONTROL); 157 + 174 158 ctrl_2 |= DWCMSHC_CTRL_HS400; 159 + } 160 + 175 161 sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2); 176 162 } 177 163 ··· 204 176 { 205 177 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 206 178 struct dwcmshc_priv *dwc_priv = sdhci_pltfm_priv(pltfm_host); 207 - struct rk3568_priv *priv = dwc_priv->priv; 179 + struct rk35xx_priv *priv = dwc_priv->priv; 208 180 u8 txclk_tapnum = DLL_TXCLK_TAPNUM_DEFAULT; 209 181 u32 extra, reg; 210 182 int err; 211 183 212 184 host->mmc->actual_clock = 0; 213 185 214 - /* 215 - * DO NOT TOUCH THIS SETTING. RX clk inverter unit is enabled 216 - * by default, but it shouldn't be enabled. We should anyway 217 - * disable it before issuing any cmds. 218 - */ 219 - extra = DWCMSHC_EMMC_DLL_DLYENA | 220 - DLL_RXCLK_NO_INVERTER << DWCMSHC_EMMC_DLL_RXCLK_SRCSEL; 221 - sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_RXCLK); 222 - 223 - if (clock == 0) 186 + if (clock == 0) { 187 + /* Disable interface clock at initial state. */ 188 + sdhci_set_clock(host, clock); 224 189 return; 190 + } 225 191 226 192 /* Rockchip platform only support 375KHz for identify mode */ 227 193 if (clock <= 400000) ··· 233 211 extra &= ~BIT(0); 234 212 sdhci_writel(host, extra, reg); 235 213 236 - if (clock <= 400000) { 237 - /* Disable DLL to reset sample clock */ 214 + if (clock <= 52000000) { 215 + /* Disable DLL and reset both of sample and drive clock */ 238 216 sdhci_writel(host, 0, DWCMSHC_EMMC_DLL_CTRL); 217 + sdhci_writel(host, 0, DWCMSHC_EMMC_DLL_RXCLK); 218 + sdhci_writel(host, 0, DWCMSHC_EMMC_DLL_TXCLK); 219 + sdhci_writel(host, 0, DECMSHC_EMMC_DLL_CMDOUT); 220 + /* 221 + * Before switching to hs400es mode, the driver will enable 222 + * enhanced strobe first. PHY needs to configure the parameters 223 + * of enhanced strobe first. 224 + */ 225 + extra = DWCMSHC_EMMC_DLL_DLYENA | 226 + DLL_STRBIN_DELAY_NUM_SEL | 227 + DLL_STRBIN_DELAY_NUM_DEFAULT << DLL_STRBIN_DELAY_NUM_OFFSET; 228 + sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_STRBIN); 239 229 return; 240 230 } 241 231 ··· 255 221 sdhci_writel(host, BIT(1), DWCMSHC_EMMC_DLL_CTRL); 256 222 udelay(1); 257 223 sdhci_writel(host, 0x0, DWCMSHC_EMMC_DLL_CTRL); 224 + 225 + /* 226 + * We shouldn't set DLL_RXCLK_NO_INVERTER for identify mode but 227 + * we must set it in higher speed mode. 228 + */ 229 + extra = DWCMSHC_EMMC_DLL_DLYENA; 230 + if (priv->devtype == DWCMSHC_RK3568) 231 + extra |= DLL_RXCLK_NO_INVERTER << DWCMSHC_EMMC_DLL_RXCLK_SRCSEL; 232 + sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_RXCLK); 258 233 259 234 /* Init DLL settings */ 260 235 extra = 0x5 << DWCMSHC_EMMC_DLL_START_POINT | ··· 287 244 host->mmc->ios.timing == MMC_TIMING_MMC_HS400) 288 245 txclk_tapnum = priv->txclk_tapnum; 289 246 247 + if ((priv->devtype == DWCMSHC_RK3588) && host->mmc->ios.timing == MMC_TIMING_MMC_HS400) { 248 + txclk_tapnum = DLL_TXCLK_TAPNUM_90_DEGREES; 249 + 250 + extra = DLL_CMDOUT_SRC_CLK_NEG | 251 + DLL_CMDOUT_EN_SRC_CLK_NEG | 252 + DWCMSHC_EMMC_DLL_DLYENA | 253 + DLL_CMDOUT_TAPNUM_90_DEGREES | 254 + DLL_CMDOUT_TAPNUM_FROM_SW; 255 + sdhci_writel(host, extra, DECMSHC_EMMC_DLL_CMDOUT); 256 + } 257 + 290 258 extra = DWCMSHC_EMMC_DLL_DLYENA | 291 259 DLL_TXCLK_TAPNUM_FROM_SW | 260 + DLL_RXCLK_NO_INVERTER << DWCMSHC_EMMC_DLL_RXCLK_SRCSEL | 292 261 txclk_tapnum; 293 262 sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_TXCLK); 294 263 ··· 308 253 DLL_STRBIN_TAPNUM_DEFAULT | 309 254 DLL_STRBIN_TAPNUM_FROM_SW; 310 255 sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_STRBIN); 256 + } 257 + 258 + static void rk35xx_sdhci_reset(struct sdhci_host *host, u8 mask) 259 + { 260 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 261 + struct dwcmshc_priv *dwc_priv = sdhci_pltfm_priv(pltfm_host); 262 + struct rk35xx_priv *priv = dwc_priv->priv; 263 + 264 + if (mask & SDHCI_RESET_ALL && priv->reset) { 265 + reset_control_assert(priv->reset); 266 + udelay(1); 267 + reset_control_deassert(priv->reset); 268 + } 269 + 270 + sdhci_reset(host, mask); 311 271 } 312 272 313 273 static const struct sdhci_ops sdhci_dwcmshc_ops = { ··· 334 264 .adma_write_desc = dwcmshc_adma_write_desc, 335 265 }; 336 266 337 - static const struct sdhci_ops sdhci_dwcmshc_rk3568_ops = { 267 + static const struct sdhci_ops sdhci_dwcmshc_rk35xx_ops = { 338 268 .set_clock = dwcmshc_rk3568_set_clock, 339 269 .set_bus_width = sdhci_set_bus_width, 340 270 .set_uhs_signaling = dwcmshc_set_uhs_signaling, 341 271 .get_max_clock = sdhci_pltfm_clk_get_max_clock, 342 - .reset = sdhci_reset, 272 + .reset = rk35xx_sdhci_reset, 343 273 .adma_write_desc = dwcmshc_adma_write_desc, 344 274 }; 345 275 ··· 349 279 .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, 350 280 }; 351 281 352 - static const struct sdhci_pltfm_data sdhci_dwcmshc_rk3568_pdata = { 353 - .ops = &sdhci_dwcmshc_rk3568_ops, 282 + static const struct sdhci_pltfm_data sdhci_dwcmshc_rk35xx_pdata = { 283 + .ops = &sdhci_dwcmshc_rk35xx_ops, 354 284 .quirks = SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN | 355 285 SDHCI_QUIRK_BROKEN_TIMEOUT_VAL, 356 286 .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | 357 287 SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN, 358 288 }; 359 289 360 - static int dwcmshc_rk3568_init(struct sdhci_host *host, struct dwcmshc_priv *dwc_priv) 290 + static int dwcmshc_rk35xx_init(struct sdhci_host *host, struct dwcmshc_priv *dwc_priv) 361 291 { 362 292 int err; 363 - struct rk3568_priv *priv = dwc_priv->priv; 293 + struct rk35xx_priv *priv = dwc_priv->priv; 294 + 295 + priv->reset = devm_reset_control_array_get_optional_exclusive(mmc_dev(host->mmc)); 296 + if (IS_ERR(priv->reset)) { 297 + err = PTR_ERR(priv->reset); 298 + dev_err(mmc_dev(host->mmc), "failed to get reset control %d\n", err); 299 + return err; 300 + } 364 301 365 302 priv->rockchip_clks[0].id = "axi"; 366 303 priv->rockchip_clks[1].id = "block"; 367 304 priv->rockchip_clks[2].id = "timer"; 368 - err = devm_clk_bulk_get_optional(mmc_dev(host->mmc), RK3568_MAX_CLKS, 305 + err = devm_clk_bulk_get_optional(mmc_dev(host->mmc), RK35xx_MAX_CLKS, 369 306 priv->rockchip_clks); 370 307 if (err) { 371 308 dev_err(mmc_dev(host->mmc), "failed to get clocks %d\n", err); 372 309 return err; 373 310 } 374 311 375 - err = clk_bulk_prepare_enable(RK3568_MAX_CLKS, priv->rockchip_clks); 312 + err = clk_bulk_prepare_enable(RK35xx_MAX_CLKS, priv->rockchip_clks); 376 313 if (err) { 377 314 dev_err(mmc_dev(host->mmc), "failed to enable clocks %d\n", err); 378 315 return err; ··· 398 321 return 0; 399 322 } 400 323 324 + static void dwcmshc_rk35xx_postinit(struct sdhci_host *host, struct dwcmshc_priv *dwc_priv) 325 + { 326 + /* 327 + * Don't support highspeed bus mode with low clk speed as we 328 + * cannot use DLL for this condition. 329 + */ 330 + if (host->mmc->f_max <= 52000000) { 331 + dev_info(mmc_dev(host->mmc), "Disabling HS200/HS400, frequency too low (%d)\n", 332 + host->mmc->f_max); 333 + host->mmc->caps2 &= ~(MMC_CAP2_HS200 | MMC_CAP2_HS400); 334 + host->mmc->caps &= ~(MMC_CAP_3_3V_DDR | MMC_CAP_1_8V_DDR); 335 + } 336 + } 337 + 401 338 static const struct of_device_id sdhci_dwcmshc_dt_ids[] = { 402 339 { 340 + .compatible = "rockchip,rk3588-dwcmshc", 341 + .data = &sdhci_dwcmshc_rk35xx_pdata, 342 + }, 343 + { 403 344 .compatible = "rockchip,rk3568-dwcmshc", 404 - .data = &sdhci_dwcmshc_rk3568_pdata, 345 + .data = &sdhci_dwcmshc_rk35xx_pdata, 405 346 }, 406 347 { 407 348 .compatible = "snps,dwcmshc-sdhci", ··· 442 347 struct sdhci_pltfm_host *pltfm_host; 443 348 struct sdhci_host *host; 444 349 struct dwcmshc_priv *priv; 445 - struct rk3568_priv *rk_priv = NULL; 350 + struct rk35xx_priv *rk_priv = NULL; 446 351 const struct sdhci_pltfm_data *pltfm_data; 447 352 int err; 448 353 u32 extra; ··· 497 402 host->mmc_host_ops.request = dwcmshc_request; 498 403 host->mmc_host_ops.hs400_enhanced_strobe = dwcmshc_hs400_enhanced_strobe; 499 404 500 - if (pltfm_data == &sdhci_dwcmshc_rk3568_pdata) { 501 - rk_priv = devm_kzalloc(&pdev->dev, sizeof(struct rk3568_priv), GFP_KERNEL); 405 + if (pltfm_data == &sdhci_dwcmshc_rk35xx_pdata) { 406 + rk_priv = devm_kzalloc(&pdev->dev, sizeof(struct rk35xx_priv), GFP_KERNEL); 502 407 if (!rk_priv) { 503 408 err = -ENOMEM; 504 409 goto err_clk; 505 410 } 506 411 412 + if (of_device_is_compatible(pdev->dev.of_node, "rockchip,rk3588-dwcmshc")) 413 + rk_priv->devtype = DWCMSHC_RK3588; 414 + else 415 + rk_priv->devtype = DWCMSHC_RK3568; 416 + 507 417 priv->priv = rk_priv; 508 418 509 - err = dwcmshc_rk3568_init(host, priv); 419 + err = dwcmshc_rk35xx_init(host, priv); 510 420 if (err) 511 421 goto err_clk; 512 422 } 513 423 514 424 host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY; 515 425 516 - err = sdhci_add_host(host); 426 + err = sdhci_setup_host(host); 517 427 if (err) 518 428 goto err_clk; 519 429 430 + if (rk_priv) 431 + dwcmshc_rk35xx_postinit(host, priv); 432 + 433 + err = __sdhci_add_host(host); 434 + if (err) 435 + goto err_setup_host; 436 + 520 437 return 0; 521 438 439 + err_setup_host: 440 + sdhci_cleanup_host(host); 522 441 err_clk: 523 442 clk_disable_unprepare(pltfm_host->clk); 524 443 clk_disable_unprepare(priv->bus_clk); 525 444 if (rk_priv) 526 - clk_bulk_disable_unprepare(RK3568_MAX_CLKS, 445 + clk_bulk_disable_unprepare(RK35xx_MAX_CLKS, 527 446 rk_priv->rockchip_clks); 528 447 free_pltfm: 529 448 sdhci_pltfm_free(pdev); ··· 549 440 struct sdhci_host *host = platform_get_drvdata(pdev); 550 441 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 551 442 struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); 552 - struct rk3568_priv *rk_priv = priv->priv; 443 + struct rk35xx_priv *rk_priv = priv->priv; 553 444 554 445 sdhci_remove_host(host, 0); 555 446 556 447 clk_disable_unprepare(pltfm_host->clk); 557 448 clk_disable_unprepare(priv->bus_clk); 558 449 if (rk_priv) 559 - clk_bulk_disable_unprepare(RK3568_MAX_CLKS, 450 + clk_bulk_disable_unprepare(RK35xx_MAX_CLKS, 560 451 rk_priv->rockchip_clks); 561 452 sdhci_pltfm_free(pdev); 562 453 ··· 569 460 struct sdhci_host *host = dev_get_drvdata(dev); 570 461 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 571 462 struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); 572 - struct rk3568_priv *rk_priv = priv->priv; 463 + struct rk35xx_priv *rk_priv = priv->priv; 573 464 int ret; 574 465 575 466 ret = sdhci_suspend_host(host); ··· 581 472 clk_disable_unprepare(priv->bus_clk); 582 473 583 474 if (rk_priv) 584 - clk_bulk_disable_unprepare(RK3568_MAX_CLKS, 475 + clk_bulk_disable_unprepare(RK35xx_MAX_CLKS, 585 476 rk_priv->rockchip_clks); 586 477 587 478 return ret; ··· 592 483 struct sdhci_host *host = dev_get_drvdata(dev); 593 484 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 594 485 struct dwcmshc_priv *priv = sdhci_pltfm_priv(pltfm_host); 595 - struct rk3568_priv *rk_priv = priv->priv; 486 + struct rk35xx_priv *rk_priv = priv->priv; 596 487 int ret; 597 488 598 489 ret = clk_prepare_enable(pltfm_host->clk); ··· 606 497 } 607 498 608 499 if (rk_priv) { 609 - ret = clk_bulk_prepare_enable(RK3568_MAX_CLKS, 500 + ret = clk_bulk_prepare_enable(RK35xx_MAX_CLKS, 610 501 rk_priv->rockchip_clks); 611 502 if (ret) 612 503 return ret;
+5 -2
drivers/mmc/host/sdhci-of-esdhc.c
··· 904 904 scfg_node = of_find_matching_node(NULL, scfg_device_ids); 905 905 if (scfg_node) 906 906 scfg_base = of_iomap(scfg_node, 0); 907 + of_node_put(scfg_node); 907 908 if (scfg_base) { 908 909 sdhciovselcr = SDHCIOVSELCR_TGLEN | 909 910 SDHCIOVSELCR_VSELVAL; ··· 1419 1418 static int sdhci_esdhc_probe(struct platform_device *pdev) 1420 1419 { 1421 1420 struct sdhci_host *host; 1422 - struct device_node *np; 1421 + struct device_node *np, *tp; 1423 1422 struct sdhci_pltfm_host *pltfm_host; 1424 1423 struct sdhci_esdhc *esdhc; 1425 1424 int ret; ··· 1464 1463 if (esdhc->vendor_ver > VENDOR_V_22) 1465 1464 host->quirks &= ~SDHCI_QUIRK_NO_BUSY_IRQ; 1466 1465 1467 - if (of_find_compatible_node(NULL, NULL, "fsl,p2020-esdhc")) { 1466 + tp = of_find_compatible_node(NULL, NULL, "fsl,p2020-esdhc"); 1467 + if (tp) { 1468 + of_node_put(tp); 1468 1469 host->quirks |= SDHCI_QUIRK_RESET_AFTER_REQUEST; 1469 1470 host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; 1470 1471 }
+34
drivers/mmc/host/sdhci-pci-gli.c
··· 95 95 #define PCIE_GLI_9763E_SCR 0x8E0 96 96 #define GLI_9763E_SCR_AXI_REQ BIT(9) 97 97 98 + #define PCIE_GLI_9763E_CFG 0x8A0 99 + #define GLI_9763E_CFG_LPSN_DIS BIT(12) 100 + 98 101 #define PCIE_GLI_9763E_CFG2 0x8A4 99 102 #define GLI_9763E_CFG2_L1DLY GENMASK(28, 19) 100 103 #define GLI_9763E_CFG2_L1DLY_MID 0x54 ··· 966 963 } 967 964 968 965 #ifdef CONFIG_PM 966 + static void gl9763e_set_low_power_negotiation(struct sdhci_pci_slot *slot, bool enable) 967 + { 968 + struct pci_dev *pdev = slot->chip->pdev; 969 + u32 value; 970 + 971 + pci_read_config_dword(pdev, PCIE_GLI_9763E_VHS, &value); 972 + value &= ~GLI_9763E_VHS_REV; 973 + value |= FIELD_PREP(GLI_9763E_VHS_REV, GLI_9763E_VHS_REV_W); 974 + pci_write_config_dword(pdev, PCIE_GLI_9763E_VHS, value); 975 + 976 + pci_read_config_dword(pdev, PCIE_GLI_9763E_CFG, &value); 977 + 978 + if (enable) 979 + value &= ~GLI_9763E_CFG_LPSN_DIS; 980 + else 981 + value |= GLI_9763E_CFG_LPSN_DIS; 982 + 983 + pci_write_config_dword(pdev, PCIE_GLI_9763E_CFG, value); 984 + 985 + pci_read_config_dword(pdev, PCIE_GLI_9763E_VHS, &value); 986 + value &= ~GLI_9763E_VHS_REV; 987 + value |= FIELD_PREP(GLI_9763E_VHS_REV, GLI_9763E_VHS_REV_R); 988 + pci_write_config_dword(pdev, PCIE_GLI_9763E_VHS, value); 989 + } 990 + 969 991 static int gl9763e_runtime_suspend(struct sdhci_pci_chip *chip) 970 992 { 971 993 struct sdhci_pci_slot *slot = chip->slots[0]; 972 994 struct sdhci_host *host = slot->host; 973 995 u16 clock; 996 + 997 + /* Enable LPM negotiation to allow entering L1 state */ 998 + gl9763e_set_low_power_negotiation(slot, true); 974 999 975 1000 clock = sdhci_readw(host, SDHCI_CLOCK_CONTROL); 976 1001 clock &= ~(SDHCI_CLOCK_PLL_EN | SDHCI_CLOCK_CARD_EN); ··· 1032 1001 1033 1002 clock |= SDHCI_CLOCK_CARD_EN; 1034 1003 sdhci_writew(host, clock, SDHCI_CLOCK_CONTROL); 1004 + 1005 + /* Disable LPM negotiation to avoid entering L1 state. */ 1006 + gl9763e_set_low_power_negotiation(slot, false); 1035 1007 1036 1008 return 0; 1037 1009 }
+2 -3
drivers/mmc/host/sdhci-st.c
··· 440 440 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 441 441 struct st_mmc_platform_data *pdata = sdhci_pltfm_priv(pltfm_host); 442 442 struct reset_control *rstc = pdata->rstc; 443 - int ret; 444 443 445 - ret = sdhci_pltfm_unregister(pdev); 444 + sdhci_pltfm_unregister(pdev); 446 445 447 446 clk_disable_unprepare(pdata->icnclk); 448 447 449 448 reset_control_assert(rstc); 450 449 451 - return ret; 450 + return 0; 452 451 } 453 452 454 453 #ifdef CONFIG_PM_SLEEP
+44 -15
drivers/mmc/host/sdhci.c
··· 224 224 if (timedout) { 225 225 pr_err("%s: Reset 0x%x never completed.\n", 226 226 mmc_hostname(host->mmc), (int)mask); 227 + sdhci_err_stats_inc(host, CTRL_TIMEOUT); 227 228 sdhci_dumpregs(host); 228 229 return; 229 230 } ··· 1717 1716 if (!timeout--) { 1718 1717 pr_err("%s: Controller never released inhibit bit(s).\n", 1719 1718 mmc_hostname(host->mmc)); 1719 + sdhci_err_stats_inc(host, CTRL_TIMEOUT); 1720 1720 sdhci_dumpregs(host); 1721 1721 cmd->error = -EIO; 1722 1722 return false; ··· 1967 1965 if (timedout) { 1968 1966 pr_err("%s: Internal clock never stabilised.\n", 1969 1967 mmc_hostname(host->mmc)); 1968 + sdhci_err_stats_inc(host, CTRL_TIMEOUT); 1970 1969 sdhci_dumpregs(host); 1971 1970 return; 1972 1971 } ··· 1990 1987 if (timedout) { 1991 1988 pr_err("%s: PLL clock never stabilised.\n", 1992 1989 mmc_hostname(host->mmc)); 1990 + sdhci_err_stats_inc(host, CTRL_TIMEOUT); 1993 1991 sdhci_dumpregs(host); 1994 1992 return; 1995 1993 } ··· 3165 3161 if (host->cmd && !sdhci_data_line_cmd(host->cmd)) { 3166 3162 pr_err("%s: Timeout waiting for hardware cmd interrupt.\n", 3167 3163 mmc_hostname(host->mmc)); 3164 + sdhci_err_stats_inc(host, REQ_TIMEOUT); 3168 3165 sdhci_dumpregs(host); 3169 3166 3170 3167 host->cmd->error = -ETIMEDOUT; ··· 3188 3183 (host->cmd && sdhci_data_line_cmd(host->cmd))) { 3189 3184 pr_err("%s: Timeout waiting for hardware interrupt.\n", 3190 3185 mmc_hostname(host->mmc)); 3186 + sdhci_err_stats_inc(host, REQ_TIMEOUT); 3191 3187 sdhci_dumpregs(host); 3192 3188 3193 3189 if (host->data) { ··· 3240 3234 return; 3241 3235 pr_err("%s: Got command interrupt 0x%08x even though no command operation was in progress.\n", 3242 3236 mmc_hostname(host->mmc), (unsigned)intmask); 3237 + sdhci_err_stats_inc(host, UNEXPECTED_IRQ); 3243 3238 sdhci_dumpregs(host); 3244 3239 return; 3245 3240 } 3246 3241 3247 3242 if (intmask & (SDHCI_INT_TIMEOUT | SDHCI_INT_CRC | 3248 3243 SDHCI_INT_END_BIT | SDHCI_INT_INDEX)) { 3249 - if (intmask & SDHCI_INT_TIMEOUT) 3244 + if (intmask & SDHCI_INT_TIMEOUT) { 3250 3245 host->cmd->error = -ETIMEDOUT; 3251 - else 3246 + sdhci_err_stats_inc(host, CMD_TIMEOUT); 3247 + } else { 3252 3248 host->cmd->error = -EILSEQ; 3253 - 3249 + if (!mmc_op_tuning(host->cmd->opcode)) 3250 + sdhci_err_stats_inc(host, CMD_CRC); 3251 + } 3254 3252 /* Treat data command CRC error the same as data CRC error */ 3255 3253 if (host->cmd->data && 3256 3254 (intmask & (SDHCI_INT_CRC | SDHCI_INT_TIMEOUT)) == ··· 3275 3265 int err = (auto_cmd_status & SDHCI_AUTO_CMD_TIMEOUT) ? 3276 3266 -ETIMEDOUT : 3277 3267 -EILSEQ; 3268 + 3269 + sdhci_err_stats_inc(host, AUTO_CMD); 3278 3270 3279 3271 if (sdhci_auto_cmd23(host, mrq)) { 3280 3272 mrq->sbc->error = err; ··· 3354 3342 if (intmask & SDHCI_INT_DATA_TIMEOUT) { 3355 3343 host->data_cmd = NULL; 3356 3344 data_cmd->error = -ETIMEDOUT; 3345 + sdhci_err_stats_inc(host, CMD_TIMEOUT); 3357 3346 __sdhci_finish_mrq(host, data_cmd->mrq); 3358 3347 return; 3359 3348 } ··· 3383 3370 3384 3371 pr_err("%s: Got data interrupt 0x%08x even though no data operation was in progress.\n", 3385 3372 mmc_hostname(host->mmc), (unsigned)intmask); 3373 + sdhci_err_stats_inc(host, UNEXPECTED_IRQ); 3386 3374 sdhci_dumpregs(host); 3387 3375 3388 3376 return; 3389 3377 } 3390 3378 3391 - if (intmask & SDHCI_INT_DATA_TIMEOUT) 3379 + if (intmask & SDHCI_INT_DATA_TIMEOUT) { 3392 3380 host->data->error = -ETIMEDOUT; 3393 - else if (intmask & SDHCI_INT_DATA_END_BIT) 3381 + sdhci_err_stats_inc(host, DAT_TIMEOUT); 3382 + } else if (intmask & SDHCI_INT_DATA_END_BIT) { 3394 3383 host->data->error = -EILSEQ; 3395 - else if ((intmask & SDHCI_INT_DATA_CRC) && 3384 + if (!mmc_op_tuning(SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND)))) 3385 + sdhci_err_stats_inc(host, DAT_CRC); 3386 + } else if ((intmask & SDHCI_INT_DATA_CRC) && 3396 3387 SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND)) 3397 - != MMC_BUS_TEST_R) 3388 + != MMC_BUS_TEST_R) { 3398 3389 host->data->error = -EILSEQ; 3399 - else if (intmask & SDHCI_INT_ADMA_ERROR) { 3390 + if (!mmc_op_tuning(SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND)))) 3391 + sdhci_err_stats_inc(host, DAT_CRC); 3392 + } else if (intmask & SDHCI_INT_ADMA_ERROR) { 3400 3393 pr_err("%s: ADMA error: 0x%08x\n", mmc_hostname(host->mmc), 3401 3394 intmask); 3402 3395 sdhci_adma_show_error(host); 3396 + sdhci_err_stats_inc(host, ADMA); 3403 3397 host->data->error = -EIO; 3404 3398 if (host->ops->adma_workaround) 3405 3399 host->ops->adma_workaround(host, intmask); ··· 3604 3584 if (unexpected) { 3605 3585 pr_err("%s: Unexpected interrupt 0x%08x.\n", 3606 3586 mmc_hostname(host->mmc), unexpected); 3587 + sdhci_err_stats_inc(host, UNEXPECTED_IRQ); 3607 3588 sdhci_dumpregs(host); 3608 3589 } 3609 3590 ··· 3926 3905 if (!host->cqe_on) 3927 3906 return false; 3928 3907 3929 - if (intmask & (SDHCI_INT_INDEX | SDHCI_INT_END_BIT | SDHCI_INT_CRC)) 3908 + if (intmask & (SDHCI_INT_INDEX | SDHCI_INT_END_BIT | SDHCI_INT_CRC)) { 3930 3909 *cmd_error = -EILSEQ; 3931 - else if (intmask & SDHCI_INT_TIMEOUT) 3910 + if (!mmc_op_tuning(host->cmd->opcode)) 3911 + sdhci_err_stats_inc(host, CMD_CRC); 3912 + } else if (intmask & SDHCI_INT_TIMEOUT) { 3932 3913 *cmd_error = -ETIMEDOUT; 3933 - else 3914 + sdhci_err_stats_inc(host, CMD_TIMEOUT); 3915 + } else 3934 3916 *cmd_error = 0; 3935 3917 3936 - if (intmask & (SDHCI_INT_DATA_END_BIT | SDHCI_INT_DATA_CRC)) 3918 + if (intmask & (SDHCI_INT_DATA_END_BIT | SDHCI_INT_DATA_CRC)) { 3937 3919 *data_error = -EILSEQ; 3938 - else if (intmask & SDHCI_INT_DATA_TIMEOUT) 3920 + if (!mmc_op_tuning(host->cmd->opcode)) 3921 + sdhci_err_stats_inc(host, DAT_CRC); 3922 + } else if (intmask & SDHCI_INT_DATA_TIMEOUT) { 3939 3923 *data_error = -ETIMEDOUT; 3940 - else if (intmask & SDHCI_INT_ADMA_ERROR) 3924 + sdhci_err_stats_inc(host, DAT_TIMEOUT); 3925 + } else if (intmask & SDHCI_INT_ADMA_ERROR) { 3941 3926 *data_error = -EIO; 3942 - else 3927 + sdhci_err_stats_inc(host, ADMA); 3928 + } else 3943 3929 *data_error = 0; 3944 3930 3945 3931 /* Clear selected interrupts. */ ··· 3962 3934 sdhci_writel(host, intmask, SDHCI_INT_STATUS); 3963 3935 pr_err("%s: CQE: Unexpected interrupt 0x%08x.\n", 3964 3936 mmc_hostname(host->mmc), intmask); 3937 + sdhci_err_stats_inc(host, UNEXPECTED_IRQ); 3965 3938 sdhci_dumpregs(host); 3966 3939 } 3967 3940
+3
drivers/mmc/host/sdhci.h
··· 356 356 */ 357 357 #define MMC_CMD_TRANSFER_TIME (10 * NSEC_PER_MSEC) /* max 10 ms */ 358 358 359 + #define sdhci_err_stats_inc(host, err_name) \ 360 + mmc_debugfs_err_stats_inc((host)->mmc, MMC_ERR_##err_name) 361 + 359 362 enum sdhci_cookie { 360 363 COOKIE_UNMAPPED, 361 364 COOKIE_PRE_MAPPED, /* mapped by sdhci_pre_req() */
+1 -1
drivers/mmc/host/tmio_mmc.c
··· 75 75 tmio_mmc_clk_start(host); 76 76 } 77 77 78 - static void tmio_mmc_reset(struct tmio_mmc_host *host) 78 + static void tmio_mmc_reset(struct tmio_mmc_host *host, bool preserve) 79 79 { 80 80 sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0000); 81 81 usleep_range(10000, 11000);
+5 -1
drivers/mmc/host/tmio_mmc.h
··· 42 42 #define CTL_DMA_ENABLE 0xd8 43 43 #define CTL_RESET_SD 0xe0 44 44 #define CTL_VERSION 0xe2 45 + #define CTL_SDIF_MODE 0xe6 /* only known on R-Car 2+ */ 45 46 46 47 /* Definitions for values the CTL_STOP_INTERNAL_ACTION register can take */ 47 48 #define TMIO_STOP_STP BIT(0) ··· 98 97 99 98 /* Definitions for values the CTL_DMA_ENABLE register can take */ 100 99 #define DMA_ENABLE_DMASDRW BIT(1) 100 + 101 + /* Definitions for values the CTL_SDIF_MODE register can take */ 102 + #define SDIF_MODE_HS400 BIT(0) /* only known on R-Car 2+ */ 101 103 102 104 /* Define some IRQ masks */ 103 105 /* This is the mask used at reset by the chip */ ··· 185 181 int (*multi_io_quirk)(struct mmc_card *card, 186 182 unsigned int direction, int blk_size); 187 183 int (*write16_hook)(struct tmio_mmc_host *host, int addr); 188 - void (*reset)(struct tmio_mmc_host *host); 184 + void (*reset)(struct tmio_mmc_host *host, bool preserve); 189 185 bool (*check_retune)(struct tmio_mmc_host *host, struct mmc_request *mrq); 190 186 void (*fixup_request)(struct tmio_mmc_host *host, struct mmc_request *mrq); 191 187 unsigned int (*get_timeout_cycles)(struct tmio_mmc_host *host);
+22 -6
drivers/mmc/host/tmio_mmc_core.c
··· 179 179 sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, reg); 180 180 } 181 181 182 - static void tmio_mmc_reset(struct tmio_mmc_host *host) 182 + static void tmio_mmc_reset(struct tmio_mmc_host *host, bool preserve) 183 183 { 184 + u16 card_opt, clk_ctrl, sdif_mode; 185 + 186 + if (preserve) { 187 + card_opt = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT); 188 + clk_ctrl = sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL); 189 + if (host->pdata->flags & TMIO_MMC_MIN_RCAR2) 190 + sdif_mode = sd_ctrl_read16(host, CTL_SDIF_MODE); 191 + } 192 + 184 193 /* FIXME - should we set stop clock reg here */ 185 194 sd_ctrl_write16(host, CTL_RESET_SD, 0x0000); 186 195 usleep_range(10000, 11000); ··· 199 190 tmio_mmc_abort_dma(host); 200 191 201 192 if (host->reset) 202 - host->reset(host); 193 + host->reset(host, preserve); 203 194 204 195 sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, host->sdcard_irq_mask_all); 205 196 host->sdcard_irq_mask = host->sdcard_irq_mask_all; ··· 213 204 if (host->pdata->flags & TMIO_MMC_SDIO_IRQ) { 214 205 sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask); 215 206 sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001); 207 + } 208 + 209 + if (preserve) { 210 + sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, card_opt); 211 + sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, clk_ctrl); 212 + if (host->pdata->flags & TMIO_MMC_MIN_RCAR2) 213 + sd_ctrl_write16(host, CTL_SDIF_MODE, sdif_mode); 216 214 } 217 215 218 216 if (host->mmc->card) ··· 264 248 265 249 spin_unlock_irqrestore(&host->lock, flags); 266 250 267 - tmio_mmc_reset(host); 251 + tmio_mmc_reset(host, true); 268 252 269 253 /* Ready for new calls */ 270 254 host->mrq = NULL; ··· 977 961 tmio_mmc_power_off(host); 978 962 /* For R-Car Gen2+, we need to reset SDHI specific SCC */ 979 963 if (host->pdata->flags & TMIO_MMC_MIN_RCAR2) 980 - tmio_mmc_reset(host); 964 + tmio_mmc_reset(host, false); 981 965 982 966 host->set_clock(host, 0); 983 967 break; ··· 1205 1189 _host->sdcard_irq_mask_all = TMIO_MASK_ALL; 1206 1190 1207 1191 _host->set_clock(_host, 0); 1208 - tmio_mmc_reset(_host); 1192 + tmio_mmc_reset(_host, false); 1209 1193 1210 1194 spin_lock_init(&_host->lock); 1211 1195 mutex_init(&_host->ios_lock); ··· 1301 1285 struct tmio_mmc_host *host = dev_get_drvdata(dev); 1302 1286 1303 1287 tmio_mmc_clk_enable(host); 1304 - tmio_mmc_reset(host); 1288 + tmio_mmc_reset(host, false); 1305 1289 1306 1290 if (host->clk_cache) 1307 1291 host->set_clock(host, host->clk_cache);
+8 -1
include/linux/mmc/card.h
··· 219 219 wide_bus:1, 220 220 high_power:1, 221 221 high_speed:1, 222 - disable_cd:1; 222 + disable_cd:1, 223 + enable_async_irq:1; 223 224 }; 224 225 225 226 struct sdio_cis { ··· 344 343 return card->ext_csd.data_sector_size == 4096; 345 344 } 346 345 346 + static inline int mmc_card_enable_async_irq(struct mmc_card *card) 347 + { 348 + return card->cccr.enable_async_irq; 349 + } 350 + 347 351 bool mmc_card_is_blockaddr(struct mmc_card *card); 348 352 349 353 #define mmc_card_mmc(c) ((c)->type == MMC_TYPE_MMC) 350 354 #define mmc_card_sd(c) ((c)->type == MMC_TYPE_SD) 351 355 #define mmc_card_sdio(c) ((c)->type == MMC_TYPE_SDIO) 356 + #define mmc_card_sd_combo(c) ((c)->type == MMC_TYPE_SD_COMBO) 352 357 353 358 #endif /* LINUX_MMC_CARD_H */
+26
include/linux/mmc/host.h
··· 93 93 94 94 struct mmc_host; 95 95 96 + enum mmc_err_stat { 97 + MMC_ERR_CMD_TIMEOUT, 98 + MMC_ERR_CMD_CRC, 99 + MMC_ERR_DAT_TIMEOUT, 100 + MMC_ERR_DAT_CRC, 101 + MMC_ERR_AUTO_CMD, 102 + MMC_ERR_ADMA, 103 + MMC_ERR_TUNING, 104 + MMC_ERR_CMDQ_RED, 105 + MMC_ERR_CMDQ_GCE, 106 + MMC_ERR_CMDQ_ICCE, 107 + MMC_ERR_REQ_TIMEOUT, 108 + MMC_ERR_CMDQ_REQ_TIMEOUT, 109 + MMC_ERR_ICE_CFG, 110 + MMC_ERR_CTRL_TIMEOUT, 111 + MMC_ERR_UNEXPECTED_IRQ, 112 + MMC_ERR_MAX, 113 + }; 114 + 96 115 struct mmc_host_ops { 97 116 /* 98 117 * It is optional for the host to implement pre_req and post_req in ··· 520 501 /* Host Software Queue support */ 521 502 bool hsq_enabled; 522 503 504 + u32 err_stats[MMC_ERR_MAX]; 523 505 unsigned long private[] ____cacheline_aligned; 524 506 }; 525 507 ··· 653 633 static inline enum dma_data_direction mmc_get_dma_dir(struct mmc_data *data) 654 634 { 655 635 return data->flags & MMC_DATA_WRITE ? DMA_TO_DEVICE : DMA_FROM_DEVICE; 636 + } 637 + 638 + static inline void mmc_debugfs_err_stats_inc(struct mmc_host *host, 639 + enum mmc_err_stat stat) 640 + { 641 + host->err_stats[stat] += 1; 656 642 } 657 643 658 644 int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
+6
include/linux/mmc/mmc.h
··· 99 99 opcode == MMC_READ_MULTIPLE_BLOCK; 100 100 } 101 101 102 + static inline bool mmc_op_tuning(u32 opcode) 103 + { 104 + return opcode == MMC_SEND_TUNING_BLOCK || 105 + opcode == MMC_SEND_TUNING_BLOCK_HS200; 106 + } 107 + 102 108 /* 103 109 * MMC_SWITCH argument format: 104 110 *
+5
include/linux/mmc/sdio.h
··· 159 159 #define SDIO_DTSx_SET_TYPE_A (1 << SDIO_DRIVE_DTSx_SHIFT) 160 160 #define SDIO_DTSx_SET_TYPE_C (2 << SDIO_DRIVE_DTSx_SHIFT) 161 161 #define SDIO_DTSx_SET_TYPE_D (3 << SDIO_DRIVE_DTSx_SHIFT) 162 + 163 + #define SDIO_CCCR_INTERRUPT_EXT 0x16 164 + #define SDIO_INTERRUPT_EXT_SAI (1 << 0) 165 + #define SDIO_INTERRUPT_EXT_EAI (1 << 1) 166 + 162 167 /* 163 168 * Function Basic Registers (FBR) 164 169 */