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

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

Pull MMC updates from Ulf Hansson:
"MMC core:
- Scan the eMMC boot areas for partition table
- Clarify purpose of mmc_can* functions by renaming them to mmc_card_can*
- Clarify helpers for host capabilities by renaming them to mmc_host_can*
- Add support for graceful host removal for SD and eMMC
- Further avoid re-storing power to the eMMC before a shutdown
- Add quirk to disable DDR50 tuning and use it for some Swissbit SD-cards

MMC host:
- mtk-sd: Add support for Dimensity 1200 MT6893
- mtk-sd: Fix condition to enable single burst type
- mtk-sd: Optimize several code-paths by aggregating register-writes
- renesas_sdhi: Add support for the Renesas RZ/V2N variant
- sdhci-msm: Add support for the SM7150 variant
- sdhci-esdhc-imx: Re-factor the system PM logic
- sdhci-esdhc-imx: Lots of improvements around the tuning support
- sdhci-of-arasan: Add support for the Renesas RZ/N1D variant
- sdhci-of-dwcmhsc: Add Sophgo SG2044 support
- sdhci-of-esdhc: Add support for the LS1021a variant
- sdhci-of-k1: Add new driver to support for SpacemiT K1 controller
- sdhci-pic32: Convert microchip,sdhci-pic32 DT doc to json schema
- wmt-sdmmc: Convert DT doc to json schema"

* tag 'mmc-v6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: (59 commits)
dt-bindings: mmc: sdhci-of-dwcmhsc: Allow use of a power-domain
mmc: sdhci-esdhc-imx: fix few build warnings
mmc: bcm2835: Use str_read_write() helper
mmc: host: sdhci-esdhc-imx: refactor the system PM logic
mmc: sdhci: export APIs for sdhci irq wakeup
mmc: sdhci-of-k1: add support for SpacemiT K1 SoC
dt-bindings: mmc: spacemit,sdhci: add support for K1 SoC
mmc: core: Scan the eMMC boot areas for partition table
dt-binding: mmc: microchip,sdhci-pic32: convert text based binding to json schema
mmc: rename mmc_boot_partition_access() to mmc_host_can_access_boot()
mmc: rename mmc_host_uhs() to mmc_host_can_uhs()
mmc: rename mmc_host_done_complete() to mmc_host_can_done_complete()
mmc: rename mmc_host_cmd23() to mmc_host_can_cmd23()
mmc: sdhci-esdhc-imx: fix defined but not used warnings
dt-bindings: mmc: vt8500-sdmmc: Convert to YAML
dt-bindings: mmc: sdhci-msm: Add the SM7150 compatible
dt-bindings: mmc: fsl,esdhc: add compatible string fsl,ls1021a-esdhc
mmc: cavium-thunderx: Use non-hybrid PCI devres API
dt-bindings: mmc: mtk-sd: Add support for Dimensity 1200 MT6893
dt-bindings: mmc: sdhci-of-dwcmhsc: Add Sophgo SG2044 support
...

+1093 -378
+21 -1
Documentation/devicetree/bindings/mmc/arasan,sdhci.yaml
··· 38 38 - items: 39 39 - const: clk_out_sd1 40 40 - const: clk_in_sd1 41 + - if: 42 + properties: 43 + compatible: 44 + contains: 45 + const: renesas,rzn1-sdhci 46 + then: 47 + properties: 48 + interrupts: 49 + minItems: 2 41 50 42 51 properties: 43 52 compatible: ··· 54 45 - const: arasan,sdhci-8.9a # generic Arasan SDHCI 8.9a PHY 55 46 - const: arasan,sdhci-4.9a # generic Arasan SDHCI 4.9a PHY 56 47 - const: arasan,sdhci-5.1 # generic Arasan SDHCI 5.1 PHY 48 + - items: 49 + - const: renesas,r9a06g032-sdhci # Renesas RZ/N1D SoC 50 + - const: renesas,rzn1-sdhci # Renesas RZ/N1 family 51 + - const: arasan,sdhci-8.9a 57 52 - items: 58 53 - const: rockchip,rk3399-sdhci-5.1 # rk3399 eMMC PHY 59 54 - const: arasan,sdhci-5.1 ··· 122 109 - const: gate 123 110 124 111 interrupts: 125 - maxItems: 1 112 + minItems: 1 113 + maxItems: 2 114 + 115 + interrupt-names: 116 + minItems: 1 117 + items: 118 + - const: int 119 + - const: wakeup 126 120 127 121 phys: 128 122 maxItems: 1
+1
Documentation/devicetree/bindings/mmc/fsl,esdhc.yaml
··· 24 24 - fsl,t1040-esdhc 25 25 - fsl,t4240-esdhc 26 26 - fsl,ls1012a-esdhc 27 + - fsl,ls1021a-esdhc 27 28 - fsl,ls1028a-esdhc 28 29 - fsl,ls1088a-esdhc 29 30 - fsl,ls1043a-esdhc
+6 -21
Documentation/devicetree/bindings/mmc/marvell,xenon-sdhci.yaml
··· 52 52 - const: core 53 53 - const: axi 54 54 55 + dma-coherent: true 56 + 55 57 interrupts: 58 + maxItems: 1 59 + 60 + iommus: 56 61 maxItems: 1 57 62 58 63 marvell,pad-type: ··· 147 142 This property provides the re-tuning counter. 148 143 149 144 allOf: 150 - - $ref: mmc-controller.yaml# 145 + - $ref: sdhci-common.yaml# 151 146 - if: 152 147 properties: 153 148 compatible: ··· 168 163 maxItems: 1 169 164 170 165 marvell,pad-type: false 171 - 172 - - if: 173 - properties: 174 - compatible: 175 - contains: 176 - enum: 177 - - marvell,armada-cp110-sdhci 178 - - marvell,armada-ap807-sdhci 179 - - marvell,armada-ap806-sdhci 180 - 181 - then: 182 - properties: 183 - clocks: 184 - minItems: 2 185 - 186 - clock-names: 187 - items: 188 - - const: core 189 - - const: axi 190 - 191 166 192 167 required: 193 168 - compatible
-29
Documentation/devicetree/bindings/mmc/microchip,sdhci-pic32.txt
··· 1 - * Microchip PIC32 SDHCI Controller 2 - 3 - This file documents differences between the core properties in mmc.txt 4 - and the properties used by the sdhci-pic32 driver. 5 - 6 - Required properties: 7 - - compatible: Should be "microchip,pic32mzda-sdhci" 8 - - interrupts: Should contain interrupt 9 - - clock-names: Should be "base_clk", "sys_clk". 10 - See: Documentation/devicetree/bindings/resource-names.txt 11 - - clocks: Phandle to the clock. 12 - See: Documentation/devicetree/bindings/clock/clock-bindings.txt 13 - - pinctrl-names: A pinctrl state names "default" must be defined. 14 - - pinctrl-0: Phandle referencing pin configuration of the SDHCI controller. 15 - See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt 16 - 17 - Example: 18 - 19 - sdhci@1f8ec000 { 20 - compatible = "microchip,pic32mzda-sdhci"; 21 - reg = <0x1f8ec000 0x100>; 22 - interrupts = <191 IRQ_TYPE_LEVEL_HIGH>; 23 - clocks = <&rootclk REF4CLK>, <&rootclk PB5CLK>; 24 - clock-names = "base_clk", "sys_clk"; 25 - bus-width = <4>; 26 - cap-sd-highspeed; 27 - pinctrl-names = "default"; 28 - pinctrl-0 = <&pinctrl_sdhc1>; 29 - };
+66
Documentation/devicetree/bindings/mmc/microchip,sdhci-pic32.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/microchip,sdhci-pic32.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Microchip PIC32 SDHI Controller 8 + 9 + description: 10 + The Microchip PIC32 family of microcontrollers (MCUs) includes models with 11 + Secure Digital Host Controller Interface (SDHCI) controllers, allowing them 12 + to interface with Secure Digital (SD) cards. This interface is used for reading, 13 + writing, and managing data on SD cards, enabling storage and data transfer 14 + capabilities in embedded systems. 15 + 16 + allOf: 17 + - $ref: mmc-controller.yaml 18 + 19 + maintainers: 20 + - Ulf Hansson <ulf.hansson@linaro.org> 21 + 22 + properties: 23 + compatible: 24 + const: microchip,pic32mzda-sdhci 25 + 26 + reg: 27 + maxItems: 1 28 + 29 + interrupts: 30 + maxItems: 1 31 + 32 + clocks: 33 + maxItems: 2 34 + 35 + clock-names: 36 + items: 37 + - const: base_clk 38 + - const: sys_clk 39 + 40 + required: 41 + - compatible 42 + - reg 43 + - interrupts 44 + - clocks 45 + - clock-names 46 + - pinctrl-names 47 + - pinctrl-0 48 + 49 + unevaluatedProperties: false 50 + 51 + examples: 52 + - | 53 + #include <dt-bindings/interrupt-controller/irq.h> 54 + #include <dt-bindings/clock/microchip,pic32-clock.h> 55 + mmc@1f8ec000 { 56 + compatible = "microchip,pic32mzda-sdhci"; 57 + reg = <0x1f8ec000 0x100>; 58 + interrupts = <191 IRQ_TYPE_LEVEL_HIGH>; 59 + clocks = <&rootclk REF4CLK>, <&rootclk PB5CLK>; 60 + clock-names = "base_clk", "sys_clk"; 61 + bus-width = <4>; 62 + cap-sd-highspeed; 63 + pinctrl-names = "default"; 64 + pinctrl-0 = <&pinctrl_sdhc1>; 65 + }; 66 + ...
+2
Documentation/devicetree/bindings/mmc/mtk-sd.yaml
··· 32 32 - const: mediatek,mt2701-mmc 33 33 - items: 34 34 - enum: 35 + - mediatek,mt6893-mmc 35 36 - mediatek,mt8186-mmc 36 37 - mediatek,mt8188-mmc 37 38 - mediatek,mt8192-mmc ··· 300 299 properties: 301 300 compatible: 302 301 enum: 302 + - mediatek,mt6893-mmc 303 303 - mediatek,mt8186-mmc 304 304 - mediatek,mt8188-mmc 305 305 - mediatek,mt8195-mmc
+3 -1
Documentation/devicetree/bindings/mmc/renesas,sdhi.yaml
··· 69 69 - renesas,sdhi-r9a09g011 # RZ/V2M 70 70 - const: renesas,rzg2l-sdhi 71 71 - items: 72 - - const: renesas,sdhi-r9a09g047 # RZ/G3E 72 + - enum: 73 + - renesas,sdhi-r9a09g047 # RZ/G3E 74 + - renesas,sdhi-r9a09g056 # RZ/V2N 73 75 - const: renesas,sdhi-r9a09g057 # RZ/V2H(P) 74 76 75 77 reg:
+1
Documentation/devicetree/bindings/mmc/sdhci-msm.yaml
··· 60 60 - qcom,sm6125-sdhci 61 61 - qcom,sm6350-sdhci 62 62 - qcom,sm6375-sdhci 63 + - qcom,sm7150-sdhci 63 64 - qcom,sm8150-sdhci 64 65 - qcom,sm8250-sdhci 65 66 - qcom,sm8350-sdhci
-13
Documentation/devicetree/bindings/mmc/sdhci.txt
··· 1 - The properties specific for SD host controllers. For properties shared by MMC 2 - host controllers refer to the mmc[1] bindings. 3 - 4 - [1] Documentation/devicetree/bindings/mmc/mmc.txt 5 - 6 - Optional properties: 7 - - sdhci-caps-mask: The sdhci capabilities register is incorrect. This 64bit 8 - property corresponds to the bits in the sdhci capability register. If the bit 9 - is on in the mask then the bit is incorrect in the register and should be 10 - turned off, before applying sdhci-caps. 11 - - sdhci-caps: The sdhci capabilities register is incorrect. This 64bit 12 - property corresponds to the bits in the sdhci capability register. If the 13 - bit is on in the property then the bit should be turned on.
+3 -4
Documentation/devicetree/bindings/mmc/snps,dwcmshc-sdhci.yaml
··· 19 19 - rockchip,rk3562-dwcmshc 20 20 - rockchip,rk3576-dwcmshc 21 21 - const: rockchip,rk3588-dwcmshc 22 + - items: 23 + - const: sophgo,sg2044-dwcmshc 24 + - const: sophgo,sg2042-dwcmshc 22 25 - enum: 23 26 - rockchip,rk3568-dwcmshc 24 27 - rockchip,rk3588-dwcmshc ··· 119 116 then: 120 117 required: 121 118 - power-domains 122 - 123 - else: 124 - properties: 125 - power-domains: false 126 119 127 120 unevaluatedProperties: false 128 121
+53
Documentation/devicetree/bindings/mmc/spacemit,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/spacemit,sdhci.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: SpacemiT SDHCI Controller 8 + 9 + maintainers: 10 + - Yixun Lan <dlan@gentoo.org> 11 + 12 + allOf: 13 + - $ref: mmc-controller.yaml# 14 + 15 + properties: 16 + compatible: 17 + const: spacemit,k1-sdhci 18 + 19 + reg: 20 + maxItems: 1 21 + 22 + interrupts: 23 + maxItems: 1 24 + 25 + clocks: 26 + items: 27 + - description: core clock, used by internal controller 28 + - description: io clock, output for SD, SDIO, eMMC device 29 + 30 + clock-names: 31 + items: 32 + - const: core 33 + - const: io 34 + 35 + required: 36 + - compatible 37 + - reg 38 + - interrupts 39 + - clocks 40 + - clock-names 41 + 42 + unevaluatedProperties: false 43 + 44 + examples: 45 + - | 46 + mmc@d4281000 { 47 + compatible = "spacemit,k1-sdhci"; 48 + reg = <0xd4281000 0x200>; 49 + interrupts = <101>; 50 + interrupt-parent = <&plic>; 51 + clocks = <&clk_apmu 10>, <&clk_apmu 13>; 52 + clock-names = "core", "io"; 53 + };
-23
Documentation/devicetree/bindings/mmc/vt8500-sdmmc.txt
··· 1 - * Wondermedia WM8505/WM8650 SD/MMC Host Controller 2 - 3 - This file documents differences between the core properties described 4 - by mmc.txt and the properties used by the wmt-sdmmc driver. 5 - 6 - Required properties: 7 - - compatible: Should be "wm,wm8505-sdhc". 8 - - interrupts: Two interrupts are required - regular irq and dma irq. 9 - 10 - Optional properties: 11 - - sdon-inverted: SD_ON bit is inverted on the controller 12 - 13 - Examples: 14 - 15 - sdhc@d800a000 { 16 - compatible = "wm,wm8505-sdhc"; 17 - reg = <0xd800a000 0x1000>; 18 - interrupts = <20 21>; 19 - clocks = <&sdhc>; 20 - bus-width = <4>; 21 - sdon-inverted; 22 - }; 23 -
+66
Documentation/devicetree/bindings/mmc/wm,wm8505-sdhc.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/wm,wm8505-sdhc.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: WonderMedia SoC SDHCI Controller 8 + 9 + maintainers: 10 + - Alexey Charkov <alchark@gmail.com> 11 + 12 + allOf: 13 + - $ref: mmc-controller.yaml# 14 + 15 + properties: 16 + compatible: 17 + oneOf: 18 + - const: wm,wm8505-sdhc 19 + - items: 20 + - const: wm,wm8650-sdhc 21 + - const: wm,wm8505-sdhc 22 + - items: 23 + - const: wm,wm8750-sdhc 24 + - const: wm,wm8505-sdhc 25 + - items: 26 + - const: wm,wm8850-sdhc 27 + - const: wm,wm8505-sdhc 28 + 29 + reg: 30 + maxItems: 1 31 + 32 + clocks: 33 + maxItems: 1 34 + 35 + interrupts: 36 + items: 37 + - description: SDMMC controller interrupt 38 + - description: SDMMC controller DMA interrupt 39 + 40 + sdon-inverted: 41 + type: boolean 42 + description: All chips before (not including) WM8505 rev. A2 treated their 43 + "clock stop" bit (register offset 0x08 a.k.a. SDMMC_BUSMODE, bit 0x10) 44 + as "set 1 to disable SD clock", while all the later versions treated it 45 + as "set 0 to disable SD clock". Set this property for later versions of 46 + wm,wm8505-sdhc. On wm,wm8650-sdhc and later this property is implied and 47 + does not need to be set explicitly 48 + 49 + required: 50 + - compatible 51 + - reg 52 + - interrupts 53 + - clocks 54 + 55 + unevaluatedProperties: false 56 + 57 + examples: 58 + - | 59 + mmc@d800a000 { 60 + compatible = "wm,wm8505-sdhc"; 61 + reg = <0xd800a000 0x1000>; 62 + interrupts = <20>, <21>; 63 + clocks = <&sdhc>; 64 + bus-width = <4>; 65 + sdon-inverted; 66 + };
+8 -8
drivers/mmc/core/block.c
··· 1220 1220 int err = 0; 1221 1221 blk_status_t status = BLK_STS_OK; 1222 1222 1223 - if (!mmc_can_erase(card)) { 1223 + if (!mmc_card_can_erase(card)) { 1224 1224 status = BLK_STS_NOTSUPP; 1225 1225 goto fail; 1226 1226 } ··· 1276 1276 int err = 0, type = MMC_BLK_SECDISCARD; 1277 1277 blk_status_t status = BLK_STS_OK; 1278 1278 1279 - if (!(mmc_can_secure_erase_trim(card))) { 1279 + if (!(mmc_card_can_secure_erase_trim(card))) { 1280 1280 status = BLK_STS_NOTSUPP; 1281 1281 goto out; 1282 1282 } ··· 1284 1284 from = blk_rq_pos(req); 1285 1285 nr = blk_rq_sectors(req); 1286 1286 1287 - if (mmc_can_trim(card) && !mmc_erase_group_aligned(card, from, nr)) 1287 + if (mmc_card_can_trim(card) && !mmc_erase_group_aligned(card, from, nr)) 1288 1288 arg = MMC_SECURE_TRIM1_ARG; 1289 1289 else 1290 1290 arg = MMC_SECURE_ERASE_ARG; ··· 2278 2278 static void mmc_blk_mq_complete_prev_req(struct mmc_queue *mq, 2279 2279 struct request **prev_req) 2280 2280 { 2281 - if (mmc_host_done_complete(mq->card->host)) 2281 + if (mmc_host_can_done_complete(mq->card->host)) 2282 2282 return; 2283 2283 2284 2284 mutex_lock(&mq->complete_lock); ··· 2317 2317 struct mmc_host *host = mq->card->host; 2318 2318 unsigned long flags; 2319 2319 2320 - if (!mmc_host_done_complete(host)) { 2320 + if (!mmc_host_can_done_complete(host)) { 2321 2321 bool waiting; 2322 2322 2323 2323 /* ··· 2430 2430 mq->rw_wait = false; 2431 2431 2432 2432 /* Release re-tuning here where there is no synchronization required */ 2433 - if (err || mmc_host_done_complete(host)) 2433 + if (err || mmc_host_can_done_complete(host)) 2434 2434 mmc_retune_release(host); 2435 2435 2436 2436 out_post_req: ··· 2618 2618 */ 2619 2619 md->read_only = mmc_blk_readonly(card); 2620 2620 2621 - if (mmc_host_cmd23(card->host)) { 2621 + if (mmc_host_can_cmd23(card->host)) { 2622 2622 if ((mmc_card_mmc(card) && 2623 2623 card->csd.mmca_vsn >= CSD_SPEC_VER_3) || 2624 2624 (mmc_card_sd(card) && !mmc_card_ult_capacity(card) && ··· 2655 2655 md->disk->private_data = md; 2656 2656 md->parent = parent; 2657 2657 set_disk_ro(md->disk, md->read_only || default_ro); 2658 - if (area_type & (MMC_BLK_DATA_AREA_RPMB | MMC_BLK_DATA_AREA_BOOT)) 2658 + if (area_type & MMC_BLK_DATA_AREA_RPMB) 2659 2659 md->disk->flags |= GENHD_FL_NO_PART; 2660 2660 2661 2661 /*
+6
drivers/mmc/core/card.h
··· 89 89 #define CID_MANFID_MICRON 0x13 90 90 #define CID_MANFID_SAMSUNG 0x15 91 91 #define CID_MANFID_APACER 0x27 92 + #define CID_MANFID_SWISSBIT 0x5D 92 93 #define CID_MANFID_KINGSTON 0x70 93 94 #define CID_MANFID_HYNIX 0x90 94 95 #define CID_MANFID_KINGSTON_SD 0x9F ··· 293 292 static inline int mmc_card_broken_sd_poweroff_notify(const struct mmc_card *c) 294 293 { 295 294 return c->quirks & MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY; 295 + } 296 + 297 + static inline int mmc_card_no_uhs_ddr50_tuning(const struct mmc_card *c) 298 + { 299 + return c->quirks & MMC_QUIRK_NO_UHS_DDR50_TUNING; 296 300 } 297 301 298 302 #endif
+20 -28
drivers/mmc/core/core.c
··· 1837 1837 } 1838 1838 EXPORT_SYMBOL(mmc_erase); 1839 1839 1840 - int mmc_can_erase(struct mmc_card *card) 1840 + bool mmc_card_can_erase(struct mmc_card *card) 1841 1841 { 1842 - if (card->csd.cmdclass & CCC_ERASE && card->erase_size) 1843 - return 1; 1844 - return 0; 1842 + return (card->csd.cmdclass & CCC_ERASE && card->erase_size); 1845 1843 } 1846 - EXPORT_SYMBOL(mmc_can_erase); 1844 + EXPORT_SYMBOL(mmc_card_can_erase); 1847 1845 1848 - int mmc_can_trim(struct mmc_card *card) 1846 + bool mmc_card_can_trim(struct mmc_card *card) 1849 1847 { 1850 - if ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN) && 1851 - (!(card->quirks & MMC_QUIRK_TRIM_BROKEN))) 1852 - return 1; 1853 - return 0; 1848 + return ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN) && 1849 + (!(card->quirks & MMC_QUIRK_TRIM_BROKEN))); 1854 1850 } 1855 - EXPORT_SYMBOL(mmc_can_trim); 1851 + EXPORT_SYMBOL(mmc_card_can_trim); 1856 1852 1857 - int mmc_can_discard(struct mmc_card *card) 1853 + bool mmc_card_can_discard(struct mmc_card *card) 1858 1854 { 1859 1855 /* 1860 1856 * As there's no way to detect the discard support bit at v4.5 1861 1857 * use the s/w feature support filed. 1862 1858 */ 1863 - if (card->ext_csd.feature_support & MMC_DISCARD_FEATURE) 1864 - return 1; 1865 - return 0; 1859 + return (card->ext_csd.feature_support & MMC_DISCARD_FEATURE); 1866 1860 } 1867 - EXPORT_SYMBOL(mmc_can_discard); 1861 + EXPORT_SYMBOL(mmc_card_can_discard); 1868 1862 1869 - int mmc_can_sanitize(struct mmc_card *card) 1863 + bool mmc_card_can_sanitize(struct mmc_card *card) 1870 1864 { 1871 - if (!mmc_can_trim(card) && !mmc_can_erase(card)) 1872 - return 0; 1865 + if (!mmc_card_can_trim(card) && !mmc_card_can_erase(card)) 1866 + return false; 1873 1867 if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE) 1874 - return 1; 1875 - return 0; 1868 + return true; 1869 + return false; 1876 1870 } 1877 1871 1878 - int mmc_can_secure_erase_trim(struct mmc_card *card) 1872 + bool mmc_card_can_secure_erase_trim(struct mmc_card *card) 1879 1873 { 1880 - if ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN) && 1881 - !(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN)) 1882 - return 1; 1883 - return 0; 1874 + return ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN) && 1875 + !(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN)); 1884 1876 } 1885 - EXPORT_SYMBOL(mmc_can_secure_erase_trim); 1877 + EXPORT_SYMBOL(mmc_card_can_secure_erase_trim); 1886 1878 1887 1879 int mmc_erase_group_aligned(struct mmc_card *card, sector_t from, 1888 1880 unsigned int nr) ··· 1979 1987 return card->pref_erase; 1980 1988 1981 1989 max_discard = mmc_do_calc_max_discard(card, MMC_ERASE_ARG); 1982 - if (mmc_can_trim(card)) { 1990 + if (mmc_card_can_trim(card)) { 1983 1991 max_trim = mmc_do_calc_max_discard(card, MMC_TRIM_ARG); 1984 1992 if (max_trim < max_discard || max_discard == 0) 1985 1993 max_discard = max_trim;
+5 -5
drivers/mmc/core/core.h
··· 118 118 int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq); 119 119 120 120 int mmc_erase(struct mmc_card *card, sector_t from, unsigned int nr, unsigned int arg); 121 - int mmc_can_erase(struct mmc_card *card); 122 - int mmc_can_trim(struct mmc_card *card); 123 - int mmc_can_discard(struct mmc_card *card); 124 - int mmc_can_sanitize(struct mmc_card *card); 125 - int mmc_can_secure_erase_trim(struct mmc_card *card); 121 + bool mmc_card_can_erase(struct mmc_card *card); 122 + bool mmc_card_can_trim(struct mmc_card *card); 123 + bool mmc_card_can_discard(struct mmc_card *card); 124 + bool mmc_card_can_sanitize(struct mmc_card *card); 125 + bool mmc_card_can_secure_erase_trim(struct mmc_card *card); 126 126 int mmc_erase_group_aligned(struct mmc_card *card, sector_t from, unsigned int nr); 127 127 unsigned int mmc_calc_max_discard(struct mmc_card *card); 128 128
+4 -4
drivers/mmc/core/host.h
··· 39 39 host->retune_now = 1; 40 40 } 41 41 42 - static inline int mmc_host_cmd23(struct mmc_host *host) 42 + static inline int mmc_host_can_cmd23(struct mmc_host *host) 43 43 { 44 44 return host->caps & MMC_CAP_CMD23; 45 45 } 46 46 47 - static inline bool mmc_host_done_complete(struct mmc_host *host) 47 + static inline bool mmc_host_can_done_complete(struct mmc_host *host) 48 48 { 49 49 return host->caps & MMC_CAP_DONE_COMPLETE; 50 50 } 51 51 52 - static inline int mmc_boot_partition_access(struct mmc_host *host) 52 + static inline int mmc_host_can_access_boot(struct mmc_host *host) 53 53 { 54 54 return !(host->caps2 & MMC_CAP2_BOOTPART_NOACC); 55 55 } 56 56 57 - static inline int mmc_host_uhs(struct mmc_host *host) 57 + static inline int mmc_host_can_uhs(struct mmc_host *host) 58 58 { 59 59 return host->caps & 60 60 (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
+64 -39
drivers/mmc/core/mmc.c
··· 33 33 #define MIN_CACHE_EN_TIMEOUT_MS 1600 34 34 #define CACHE_FLUSH_TIMEOUT_MS 30000 /* 30s */ 35 35 36 + enum mmc_poweroff_type { 37 + MMC_POWEROFF_SUSPEND, 38 + MMC_POWEROFF_SHUTDOWN, 39 + MMC_POWEROFF_UNBIND, 40 + }; 41 + 36 42 static const unsigned int tran_exp[] = { 37 43 10000, 100000, 1000000, 10000000, 38 44 0, 0, 0, 0 ··· 459 453 * There are two boot regions of equal size, defined in 460 454 * multiples of 128K. 461 455 */ 462 - if (ext_csd[EXT_CSD_BOOT_MULT] && mmc_boot_partition_access(card->host)) { 456 + if (ext_csd[EXT_CSD_BOOT_MULT] && mmc_host_can_access_boot(card->host)) { 463 457 for (idx = 0; idx < MMC_NUM_BOOT_PARTITION; idx++) { 464 458 part_size = ext_csd[EXT_CSD_BOOT_MULT] << 17; 465 459 mmc_part_add(card, part_size, ··· 578 572 * RPMB regions are defined in multiples of 128K. 579 573 */ 580 574 card->ext_csd.raw_rpmb_size_mult = ext_csd[EXT_CSD_RPMB_MULT]; 581 - if (ext_csd[EXT_CSD_RPMB_MULT] && mmc_host_cmd23(card->host)) { 575 + if (ext_csd[EXT_CSD_RPMB_MULT] && mmc_host_can_cmd23(card->host)) { 582 576 mmc_part_add(card, ext_csd[EXT_CSD_RPMB_MULT] << 17, 583 577 EXT_CSD_PART_CONFIG_ACC_RPMB, 584 578 "rpmb", 0, false, ··· 680 674 u8 *ext_csd; 681 675 int err; 682 676 683 - if (!mmc_can_ext_csd(card)) 677 + if (!mmc_card_can_ext_csd(card)) 684 678 return 0; 685 679 686 680 err = mmc_get_ext_csd(card, &ext_csd); ··· 959 953 int err, ddr; 960 954 961 955 /* Power class selection is supported for versions >= 4.0 */ 962 - if (!mmc_can_ext_csd(card)) 956 + if (!mmc_card_can_ext_csd(card)) 963 957 return 0; 964 958 965 959 bus_width = host->ios.bus_width; ··· 1022 1016 unsigned idx, bus_width = 0; 1023 1017 int err = 0; 1024 1018 1025 - if (!mmc_can_ext_csd(card) || 1019 + if (!mmc_card_can_ext_csd(card) || 1026 1020 !(host->caps & (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA))) 1027 1021 return 0; 1028 1022 ··· 1543 1537 { 1544 1538 int err = 0; 1545 1539 1546 - if (!mmc_can_ext_csd(card)) 1540 + if (!mmc_card_can_ext_csd(card)) 1547 1541 goto bus_speed; 1548 1542 1549 1543 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400ES) { ··· 1804 1798 } 1805 1799 1806 1800 /* set erase_arg */ 1807 - if (mmc_can_discard(card)) 1801 + if (mmc_card_can_discard(card)) 1808 1802 card->erase_arg = MMC_DISCARD_ARG; 1809 - else if (mmc_can_trim(card)) 1803 + else if (mmc_card_can_trim(card)) 1810 1804 card->erase_arg = MMC_TRIM_ARG; 1811 1805 else 1812 1806 card->erase_arg = MMC_ERASE_ARG; ··· 1955 1949 return err; 1956 1950 } 1957 1951 1958 - static int mmc_can_sleep(struct mmc_card *card) 1952 + static bool mmc_card_can_sleep(struct mmc_card *card) 1959 1953 { 1960 1954 return card->ext_csd.rev >= 3; 1961 1955 } ··· 2013 2007 return err; 2014 2008 } 2015 2009 2016 - static int mmc_can_poweroff_notify(const struct mmc_card *card) 2010 + static bool mmc_card_can_poweroff_notify(const struct mmc_card *card) 2017 2011 { 2018 2012 return card && 2019 2013 mmc_card_mmc(card) && 2020 2014 (card->ext_csd.power_off_notification == EXT_CSD_POWER_ON); 2015 + } 2016 + 2017 + static bool mmc_host_can_poweroff_notify(const struct mmc_host *host, 2018 + enum mmc_poweroff_type pm_type) 2019 + { 2020 + if (host->caps2 & MMC_CAP2_FULL_PWR_CYCLE) 2021 + return true; 2022 + 2023 + if (host->caps2 & MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND && 2024 + pm_type == MMC_POWEROFF_SUSPEND) 2025 + return true; 2026 + 2027 + return pm_type == MMC_POWEROFF_SHUTDOWN; 2021 2028 } 2022 2029 2023 2030 static int mmc_poweroff_notify(struct mmc_card *card, unsigned int notify_type) ··· 2053 2034 card->ext_csd.power_off_notification = EXT_CSD_NO_POWER_NOTIFICATION; 2054 2035 2055 2036 return err; 2056 - } 2057 - 2058 - /* 2059 - * Host is being removed. Free up the current card. 2060 - */ 2061 - static void mmc_remove(struct mmc_host *host) 2062 - { 2063 - mmc_remove_card(host->card); 2064 - host->card = NULL; 2065 2037 } 2066 2038 2067 2039 /* ··· 2080 2070 mmc_put_card(host->card, NULL); 2081 2071 2082 2072 if (err) { 2083 - mmc_remove(host); 2073 + mmc_remove_card(host->card); 2074 + host->card = NULL; 2084 2075 2085 2076 mmc_claim_host(host); 2086 2077 mmc_detach_bus(host); ··· 2119 2108 return err; 2120 2109 } 2121 2110 2122 - static int _mmc_suspend(struct mmc_host *host, bool is_suspend) 2111 + static int _mmc_suspend(struct mmc_host *host, enum mmc_poweroff_type pm_type) 2123 2112 { 2113 + unsigned int notify_type = EXT_CSD_POWER_OFF_SHORT; 2124 2114 int err = 0; 2125 - unsigned int notify_type = is_suspend ? EXT_CSD_POWER_OFF_SHORT : 2126 - EXT_CSD_POWER_OFF_LONG; 2115 + 2116 + if (pm_type == MMC_POWEROFF_SHUTDOWN) 2117 + notify_type = EXT_CSD_POWER_OFF_LONG; 2127 2118 2128 2119 mmc_claim_host(host); 2129 2120 ··· 2136 2123 if (err) 2137 2124 goto out; 2138 2125 2139 - if (mmc_can_poweroff_notify(host->card) && 2140 - ((host->caps2 & MMC_CAP2_FULL_PWR_CYCLE) || !is_suspend || 2141 - (host->caps2 & MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND))) 2126 + if (mmc_card_can_poweroff_notify(host->card) && 2127 + mmc_host_can_poweroff_notify(host, pm_type)) 2142 2128 err = mmc_poweroff_notify(host->card, notify_type); 2143 - else if (mmc_can_sleep(host->card)) 2129 + else if (mmc_card_can_sleep(host->card)) 2144 2130 err = mmc_sleep(host); 2145 2131 else if (!mmc_host_is_spi(host)) 2146 2132 err = mmc_deselect_cards(host); ··· 2154 2142 } 2155 2143 2156 2144 /* 2145 + * Host is being removed. Free up the current card and do a graceful power-off. 2146 + */ 2147 + static void mmc_remove(struct mmc_host *host) 2148 + { 2149 + get_device(&host->card->dev); 2150 + mmc_remove_card(host->card); 2151 + 2152 + _mmc_suspend(host, MMC_POWEROFF_UNBIND); 2153 + 2154 + put_device(&host->card->dev); 2155 + host->card = NULL; 2156 + } 2157 + 2158 + /* 2157 2159 * Suspend callback 2158 2160 */ 2159 2161 static int mmc_suspend(struct mmc_host *host) 2160 2162 { 2161 2163 int err; 2162 2164 2163 - err = _mmc_suspend(host, true); 2165 + err = _mmc_suspend(host, MMC_POWEROFF_SUSPEND); 2164 2166 if (!err) { 2165 2167 pm_runtime_disable(&host->card->dev); 2166 2168 pm_runtime_set_suspended(&host->card->dev); ··· 2213 2187 int err = 0; 2214 2188 2215 2189 /* 2216 - * In a specific case for poweroff notify, we need to resume the card 2217 - * before we can shutdown it properly. 2190 + * If the card remains suspended at this point and it was done by using 2191 + * the sleep-cmd (CMD5), we may need to re-initialize it first, to allow 2192 + * us to send the preferred poweroff-notification cmd at shutdown. 2218 2193 */ 2219 - if (mmc_can_poweroff_notify(host->card) && 2220 - !(host->caps2 & MMC_CAP2_FULL_PWR_CYCLE)) 2194 + if (mmc_card_can_poweroff_notify(host->card) && 2195 + !mmc_host_can_poweroff_notify(host, MMC_POWEROFF_SUSPEND)) 2221 2196 err = _mmc_resume(host); 2222 2197 2223 2198 if (!err) 2224 - err = _mmc_suspend(host, false); 2199 + err = _mmc_suspend(host, MMC_POWEROFF_SHUTDOWN); 2225 2200 2226 2201 return err; 2227 2202 } ··· 2246 2219 if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) 2247 2220 return 0; 2248 2221 2249 - err = _mmc_suspend(host, true); 2222 + err = _mmc_suspend(host, MMC_POWEROFF_SUSPEND); 2250 2223 if (err) 2251 2224 pr_err("%s: error %d doing aggressive suspend\n", 2252 2225 mmc_hostname(host), err); ··· 2269 2242 return 0; 2270 2243 } 2271 2244 2272 - static int mmc_can_reset(struct mmc_card *card) 2245 + static bool mmc_card_can_reset(struct mmc_card *card) 2273 2246 { 2274 2247 u8 rst_n_function; 2275 2248 2276 2249 rst_n_function = card->ext_csd.rst_n_function; 2277 - if ((rst_n_function & EXT_CSD_RST_N_EN_MASK) != EXT_CSD_RST_N_ENABLED) 2278 - return 0; 2279 - return 1; 2250 + return ((rst_n_function & EXT_CSD_RST_N_EN_MASK) == EXT_CSD_RST_N_ENABLED); 2280 2251 } 2281 2252 2282 2253 static int _mmc_hw_reset(struct mmc_host *host) ··· 2288 2263 _mmc_flush_cache(host); 2289 2264 2290 2265 if ((host->caps & MMC_CAP_HW_RESET) && host->ops->card_hw_reset && 2291 - mmc_can_reset(card)) { 2266 + mmc_card_can_reset(card)) { 2292 2267 /* If the card accept RST_n signal, send it. */ 2293 2268 mmc_set_clock(host, host->f_init); 2294 2269 host->ops->card_hw_reset(host);
+3 -3
drivers/mmc/core/mmc_ops.c
··· 383 383 if (!card || !new_ext_csd) 384 384 return -EINVAL; 385 385 386 - if (!mmc_can_ext_csd(card)) 386 + if (!mmc_card_can_ext_csd(card)) 387 387 return -EOPNOTSUPP; 388 388 389 389 /* ··· 944 944 return err; 945 945 } 946 946 947 - int mmc_can_ext_csd(struct mmc_card *card) 947 + bool mmc_card_can_ext_csd(struct mmc_card *card) 948 948 { 949 949 return (card && card->csd.mmca_vsn > CSD_SPEC_VER_3); 950 950 } ··· 1046 1046 struct mmc_host *host = card->host; 1047 1047 int err; 1048 1048 1049 - if (!mmc_can_sanitize(card)) { 1049 + if (!mmc_card_can_sanitize(card)) { 1050 1050 pr_warn("%s: Sanitize not supported\n", mmc_hostname(host)); 1051 1051 return -EOPNOTSUPP; 1052 1052 }
+1 -1
drivers/mmc/core/mmc_ops.h
··· 37 37 int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp); 38 38 int mmc_spi_set_crc(struct mmc_host *host, int use_crc); 39 39 int mmc_bus_test(struct mmc_card *card, u8 bus_width); 40 - int mmc_can_ext_csd(struct mmc_card *card); 40 + bool mmc_card_can_ext_csd(struct mmc_card *card); 41 41 int mmc_switch_status(struct mmc_card *card, bool crc_err_fatal); 42 42 bool mmc_prepare_busy_cmd(struct mmc_host *host, struct mmc_command *cmd, 43 43 unsigned int timeout_ms);
+8 -8
drivers/mmc/core/mmc_test.c
··· 191 191 { 192 192 struct mmc_card *card = test->card; 193 193 194 - if (!mrq->sbc || !mmc_host_cmd23(card->host) || 194 + if (!mrq->sbc || !mmc_host_can_cmd23(card->host) || 195 195 !mmc_test_card_cmd23(card) || !mmc_op_multi(mrq->cmd->opcode) || 196 196 (card->quirks & MMC_QUIRK_BLK_NO_CMD23)) { 197 197 mrq->sbc = NULL; ··· 1510 1510 { 1511 1511 struct mmc_test_area *t = &test->area; 1512 1512 1513 - if (!mmc_can_erase(test->card)) 1513 + if (!mmc_card_can_erase(test->card)) 1514 1514 return 0; 1515 1515 1516 1516 return mmc_erase(test->card, t->dev_addr, t->max_sz >> 9, ··· 1746 1746 struct timespec64 ts1, ts2; 1747 1747 int ret; 1748 1748 1749 - if (!mmc_can_trim(test->card)) 1749 + if (!mmc_card_can_trim(test->card)) 1750 1750 return RESULT_UNSUP_CARD; 1751 1751 1752 - if (!mmc_can_erase(test->card)) 1752 + if (!mmc_card_can_erase(test->card)) 1753 1753 return RESULT_UNSUP_HOST; 1754 1754 1755 1755 for (sz = 512; sz < t->max_sz; sz <<= 1) { ··· 1863 1863 struct timespec64 ts1, ts2; 1864 1864 int ret; 1865 1865 1866 - if (!mmc_can_trim(test->card)) 1866 + if (!mmc_card_can_trim(test->card)) 1867 1867 return RESULT_UNSUP_CARD; 1868 1868 1869 - if (!mmc_can_erase(test->card)) 1869 + if (!mmc_card_can_erase(test->card)) 1870 1870 return RESULT_UNSUP_HOST; 1871 1871 1872 1872 for (sz = 512; sz <= t->max_sz; sz <<= 1) { ··· 2114 2114 return 0; 2115 2115 2116 2116 /* prepare test area */ 2117 - if (mmc_can_erase(test->card) && 2117 + if (mmc_card_can_erase(test->card) && 2118 2118 tdata->prepare & MMC_TEST_PREP_ERASE) { 2119 2119 ret = mmc_erase(test->card, dev_addr, 2120 2120 size / 512, test->card->erase_arg); ··· 2390 2390 512, write); 2391 2391 2392 2392 if (use_sbc && t->blocks > 1 && !mrq->sbc) { 2393 - ret = mmc_host_cmd23(host) ? 2393 + ret = mmc_host_can_cmd23(host) ? 2394 2394 RESULT_UNSUP_CARD : 2395 2395 RESULT_UNSUP_HOST; 2396 2396 goto out_free;
+3 -3
drivers/mmc/core/queue.c
··· 184 184 return; 185 185 186 186 lim->max_hw_discard_sectors = max_discard; 187 - if (mmc_can_secure_erase_trim(card)) 187 + if (mmc_card_can_secure_erase_trim(card)) 188 188 lim->max_secure_erase_sectors = max_discard; 189 - if (mmc_can_trim(card) && card->erased_byte == 0) 189 + if (mmc_card_can_trim(card) && card->erased_byte == 0) 190 190 lim->max_write_zeroes_sectors = max_discard; 191 191 192 192 /* granularity must not be greater than max. discard */ ··· 352 352 }; 353 353 struct gendisk *disk; 354 354 355 - if (mmc_can_erase(card)) 355 + if (mmc_card_can_erase(card)) 356 356 mmc_queue_setup_discard(card, &lim); 357 357 358 358 lim.max_hw_sectors = min(host->max_blk_count, host->max_req_size / 512);
+10
drivers/mmc/core/quirks.h
··· 34 34 MMC_QUIRK_BROKEN_SD_CACHE | MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY, 35 35 EXT_CSD_REV_ANY), 36 36 37 + /* 38 + * Swissbit series S46-u cards throw I/O errors during tuning requests 39 + * after the initial tuning request expectedly times out. This has 40 + * only been observed on cards manufactured on 01/2019 that are using 41 + * Bay Trail host controllers. 42 + */ 43 + _FIXUP_EXT("0016G", CID_MANFID_SWISSBIT, 0x5342, 2019, 1, 44 + 0, -1ull, SDIO_ANY_ID, SDIO_ANY_ID, add_quirk_sd, 45 + MMC_QUIRK_NO_UHS_DDR50_TUNING, EXT_CSD_REV_ANY), 46 + 37 47 END_FIXUP 38 48 }; 39 49
+43 -22
drivers/mmc/core/sd.c
··· 455 455 * If the host doesn't support any of the UHS-I modes, fallback on 456 456 * default speed. 457 457 */ 458 - if (!mmc_host_uhs(card->host)) { 458 + if (!mmc_host_can_uhs(card->host)) { 459 459 card->sd_bus_speed = 0; 460 460 return; 461 461 } ··· 618 618 } 619 619 620 620 /* 621 + * Determine if the card should tune or not. 622 + */ 623 + static bool mmc_sd_use_tuning(struct mmc_card *card) 624 + { 625 + /* 626 + * SPI mode doesn't define CMD19 and tuning is only valid for SDR50 and 627 + * SDR104 mode SD-cards. Note that tuning is mandatory for SDR104. 628 + */ 629 + if (mmc_host_is_spi(card->host)) 630 + return false; 631 + 632 + switch (card->host->ios.timing) { 633 + case MMC_TIMING_UHS_SDR50: 634 + case MMC_TIMING_UHS_SDR104: 635 + return true; 636 + case MMC_TIMING_UHS_DDR50: 637 + return !mmc_card_no_uhs_ddr50_tuning(card); 638 + } 639 + 640 + return false; 641 + } 642 + 643 + /* 621 644 * UHS-I specific initialization procedure 622 645 */ 623 646 static int mmc_sd_init_uhs_card(struct mmc_card *card) ··· 683 660 if (err) 684 661 goto out; 685 662 686 - /* 687 - * SPI mode doesn't define CMD19 and tuning is only valid for SDR50 and 688 - * SDR104 mode SD-cards. Note that tuning is mandatory for SDR104. 689 - */ 690 - if (!mmc_host_is_spi(card->host) && 691 - (card->host->ios.timing == MMC_TIMING_UHS_SDR50 || 692 - card->host->ios.timing == MMC_TIMING_UHS_DDR50 || 693 - card->host->ios.timing == MMC_TIMING_UHS_SDR104)) { 663 + if (mmc_sd_use_tuning(card)) { 694 664 err = mmc_execute_tuning(card); 695 665 696 666 /* ··· 867 851 * to switch to 1.8V signaling level. If the card has failed 868 852 * repeatedly to switch however, skip this. 869 853 */ 870 - if (retries && mmc_host_uhs(host)) 854 + if (retries && mmc_host_can_uhs(host)) 871 855 ocr |= SD_OCR_S18R; 872 856 873 857 /* ··· 1509 1493 * signaling. Detect that situation and try to initialize a UHS-I (1.8V) 1510 1494 * transfer mode. 1511 1495 */ 1512 - if (!v18_fixup_failed && !mmc_host_is_spi(host) && mmc_host_uhs(host) && 1496 + if (!v18_fixup_failed && !mmc_host_is_spi(host) && mmc_host_can_uhs(host) && 1513 1497 mmc_sd_card_using_v18(card) && 1514 1498 host->ios.signal_voltage != MMC_SIGNAL_VOLTAGE_180) { 1515 1499 if (mmc_host_set_uhs_voltage(host) || ··· 1524 1508 } 1525 1509 1526 1510 /* Initialization sequence for UHS-I cards */ 1527 - if (rocr & SD_ROCR_S18A && mmc_host_uhs(host)) { 1511 + if (rocr & SD_ROCR_S18A && mmc_host_can_uhs(host)) { 1528 1512 err = mmc_sd_init_uhs_card(card); 1529 1513 if (err) 1530 1514 goto free_card; ··· 1613 1597 } 1614 1598 1615 1599 /* 1616 - * Host is being removed. Free up the current card. 1617 - */ 1618 - static void mmc_sd_remove(struct mmc_host *host) 1619 - { 1620 - mmc_remove_card(host->card); 1621 - host->card = NULL; 1622 - } 1623 - 1624 - /* 1625 1600 * Card detection - card is alive. 1626 1601 */ 1627 1602 static int mmc_sd_alive(struct mmc_host *host) ··· 1637 1630 mmc_put_card(host->card, NULL); 1638 1631 1639 1632 if (err) { 1640 - mmc_sd_remove(host); 1633 + mmc_remove_card(host->card); 1634 + host->card = NULL; 1641 1635 1642 1636 mmc_claim_host(host); 1643 1637 mmc_detach_bus(host); ··· 1738 1730 return err; 1739 1731 } 1740 1732 1733 + /* 1734 + * Host is being removed. Free up the current card and do a graceful power-off. 1735 + */ 1736 + static void mmc_sd_remove(struct mmc_host *host) 1737 + { 1738 + get_device(&host->card->dev); 1739 + mmc_remove_card(host->card); 1740 + 1741 + _mmc_sd_suspend(host); 1742 + 1743 + put_device(&host->card->dev); 1744 + host->card = NULL; 1745 + } 1741 1746 /* 1742 1747 * Callback for suspend 1743 1748 */
+3 -3
drivers/mmc/core/sdio.c
··· 198 198 if (ret) 199 199 goto out; 200 200 201 - if (mmc_host_uhs(card->host)) { 201 + if (mmc_host_can_uhs(card->host)) { 202 202 if (data & SDIO_UHS_DDR50) 203 203 card->sw_caps.sd3_bus_mode 204 204 |= SD_MODE_UHS_DDR50 | SD_MODE_UHS_SDR50 ··· 527 527 * If the host doesn't support any of the UHS-I modes, fallback on 528 528 * default speed. 529 529 */ 530 - if (!mmc_host_uhs(card->host)) 530 + if (!mmc_host_can_uhs(card->host)) 531 531 return 0; 532 532 533 533 bus_speed = SDIO_SPEED_SDR12; ··· 669 669 WARN_ON(!host->claimed); 670 670 671 671 /* to query card if 1.8V signalling is supported */ 672 - if (mmc_host_uhs(host)) 672 + if (mmc_host_can_uhs(host)) 673 673 ocr |= R4_18V_PRESENT; 674 674 675 675 try_again:
+4 -4
drivers/mmc/core/slot-gpio.c
··· 228 228 } 229 229 EXPORT_SYMBOL(mmc_gpiod_set_cd_config); 230 230 231 - bool mmc_can_gpio_cd(struct mmc_host *host) 231 + bool mmc_host_can_gpio_cd(struct mmc_host *host) 232 232 { 233 233 struct mmc_gpio *ctx = host->slot.handler_priv; 234 234 235 235 return ctx->cd_gpio ? true : false; 236 236 } 237 - EXPORT_SYMBOL(mmc_can_gpio_cd); 237 + EXPORT_SYMBOL(mmc_host_can_gpio_cd); 238 238 239 239 /** 240 240 * mmc_gpiod_request_ro - request a gpio descriptor for write protection ··· 275 275 } 276 276 EXPORT_SYMBOL(mmc_gpiod_request_ro); 277 277 278 - bool mmc_can_gpio_ro(struct mmc_host *host) 278 + bool mmc_host_can_gpio_ro(struct mmc_host *host) 279 279 { 280 280 struct mmc_gpio *ctx = host->slot.handler_priv; 281 281 282 282 return ctx->ro_gpio ? true : false; 283 283 } 284 - EXPORT_SYMBOL(mmc_can_gpio_ro); 284 + EXPORT_SYMBOL(mmc_host_can_gpio_ro);
+14
drivers/mmc/host/Kconfig
··· 250 250 If you have a controller with this interface, say Y or M here. 251 251 If unsure, say N. 252 252 253 + config MMC_SDHCI_OF_K1 254 + tristate "SDHCI OF support for the SpacemiT K1 SoC" 255 + depends on ARCH_SPACEMIT || COMPILE_TEST 256 + depends on MMC_SDHCI_PLTFM 257 + depends on OF 258 + depends on COMMON_CLK 259 + help 260 + This selects the Secure Digital Host Controller Interface (SDHCI) 261 + found in the SpacemiT K1 SoC. 262 + 263 + If you have a controller with this interface, say Y or M here. 264 + 265 + If unsure, say N. 266 + 253 267 config MMC_SDHCI_OF_SPARX5 254 268 tristate "SDHCI OF support for the MCHP Sparx5 SoC" 255 269 depends on MMC_SDHCI_PLTFM
+1
drivers/mmc/host/Makefile
··· 88 88 obj-$(CONFIG_MMC_SDHCI_OF_ESDHC) += sdhci-of-esdhc.o 89 89 obj-$(CONFIG_MMC_SDHCI_OF_HLWD) += sdhci-of-hlwd.o 90 90 obj-$(CONFIG_MMC_SDHCI_OF_DWCMSHC) += sdhci-of-dwcmshc.o 91 + obj-$(CONFIG_MMC_SDHCI_OF_K1) += sdhci-of-k1.o 91 92 obj-$(CONFIG_MMC_SDHCI_OF_SPARX5) += sdhci-of-sparx5.o 92 93 obj-$(CONFIG_MMC_SDHCI_OF_MA35D1) += sdhci-of-ma35d1.o 93 94 obj-$(CONFIG_MMC_SDHCI_BCM_KONA) += sdhci-bcm-kona.o
+2 -1
drivers/mmc/host/alcor.c
··· 20 20 #include <linux/irq.h> 21 21 #include <linux/interrupt.h> 22 22 #include <linux/platform_device.h> 23 + #include <linux/string_choices.h> 23 24 24 25 #include <linux/mmc/host.h> 25 26 #include <linux/mmc/mmc.h> ··· 209 208 len = min(host->sg_miter.length, blksize); 210 209 211 210 dev_dbg(host->dev, "PIO, %s block size: 0x%zx\n", 212 - read ? "read" : "write", blksize); 211 + str_read_write(read), blksize); 213 212 214 213 host->sg_miter.consumed = len; 215 214 host->blocks--;
+4 -4
drivers/mmc/host/bcm2835.c
··· 44 44 #include <linux/scatterlist.h> 45 45 #include <linux/time.h> 46 46 #include <linux/workqueue.h> 47 + #include <linux/string_choices.h> 47 48 48 49 #include <linux/mmc/host.h> 49 50 #include <linux/mmc/mmc.h> ··· 392 391 393 392 if (time_after(jiffies, wait_max)) { 394 393 dev_err(dev, "PIO %s timeout - EDM %08x\n", 395 - is_read ? "read" : "write", 396 - edm); 394 + str_read_write(is_read), edm); 397 395 hsts = SDHSTS_REW_TIME_OUT; 398 396 break; 399 397 } ··· 435 435 SDHSTS_CRC7_ERROR | 436 436 SDHSTS_FIFO_ERROR)) { 437 437 dev_err(dev, "%s transfer error - HSTS %08x\n", 438 - is_read ? "read" : "write", sdhsts); 438 + str_read_write(is_read), sdhsts); 439 439 host->data->error = -EILSEQ; 440 440 } else if ((sdhsts & (SDHSTS_CMD_TIME_OUT | 441 441 SDHSTS_REW_TIME_OUT))) { 442 442 dev_err(dev, "%s timeout error - HSTS %08x\n", 443 - is_read ? "read" : "write", sdhsts); 443 + str_read_write(is_read), sdhsts); 444 444 host->data->error = -ETIMEDOUT; 445 445 } 446 446 }
+1 -3
drivers/mmc/host/cavium-thunderx.c
··· 72 72 if (ret) 73 73 return ret; 74 74 75 - ret = pci_request_regions(pdev, KBUILD_MODNAME); 75 + ret = pcim_request_all_regions(pdev, KBUILD_MODNAME); 76 76 if (ret) 77 77 return ret; 78 78 ··· 164 164 } 165 165 } 166 166 clk_disable_unprepare(host->clk); 167 - pci_release_regions(pdev); 168 167 return ret; 169 168 } 170 169 ··· 182 183 writeq(dma_cfg, host->dma_base + MIO_EMM_DMA_CFG(host)); 183 184 184 185 clk_disable_unprepare(host->clk); 185 - pci_release_regions(pdev); 186 186 } 187 187 188 188 static const struct pci_device_id thunder_mmc_id_table[] = {
+3 -3
drivers/mmc/host/dw_mmc.c
··· 3622 3622 clk_disable_unprepare(host->ciu_clk); 3623 3623 3624 3624 if (host->slot && 3625 - (mmc_can_gpio_cd(host->slot->mmc) || 3625 + (mmc_host_can_gpio_cd(host->slot->mmc) || 3626 3626 !mmc_card_is_removable(host->slot->mmc))) 3627 3627 clk_disable_unprepare(host->biu_clk); 3628 3628 ··· 3636 3636 struct dw_mci *host = dev_get_drvdata(dev); 3637 3637 3638 3638 if (host->slot && 3639 - (mmc_can_gpio_cd(host->slot->mmc) || 3639 + (mmc_host_can_gpio_cd(host->slot->mmc) || 3640 3640 !mmc_card_is_removable(host->slot->mmc))) { 3641 3641 ret = clk_prepare_enable(host->biu_clk); 3642 3642 if (ret) ··· 3690 3690 3691 3691 err: 3692 3692 if (host->slot && 3693 - (mmc_can_gpio_cd(host->slot->mmc) || 3693 + (mmc_host_can_gpio_cd(host->slot->mmc) || 3694 3694 !mmc_card_is_removable(host->slot->mmc))) 3695 3695 clk_disable_unprepare(host->biu_clk); 3696 3696
+141 -76
drivers/mmc/host/mtk-sd.c
··· 5 5 */ 6 6 7 7 #include <linux/module.h> 8 + #include <linux/bitfield.h> 8 9 #include <linux/bitops.h> 9 10 #include <linux/clk.h> 10 11 #include <linux/delay.h> ··· 84 83 #define EMMC51_CFG0 0x204 85 84 #define EMMC50_CFG0 0x208 86 85 #define EMMC50_CFG1 0x20c 86 + #define EMMC50_CFG2 0x21c 87 87 #define EMMC50_CFG3 0x220 88 88 #define SDC_FIFO_CFG 0x228 89 89 #define CQHCI_SETTING 0x7fc ··· 235 233 236 234 /* MSDC_PATCH_BIT mask */ 237 235 #define MSDC_PATCH_BIT_ODDSUPP BIT(1) /* RW */ 236 + #define MSDC_PATCH_BIT_DIS_WRMON BIT(2) /* RW */ 238 237 #define MSDC_PATCH_BIT_RD_DAT_SEL BIT(3) /* RW */ 238 + #define MSDC_PATCH_BIT_DESCUP_SEL BIT(6) /* RW */ 239 239 #define MSDC_INT_DAT_LATCH_CK_SEL GENMASK(9, 7) 240 240 #define MSDC_CKGEN_MSDC_DLY_SEL GENMASK(14, 10) 241 241 #define MSDC_PATCH_BIT_IODSSEL BIT(16) /* RW */ ··· 250 246 #define MSDC_PATCH_BIT_SPCPUSH BIT(29) /* RW */ 251 247 #define MSDC_PATCH_BIT_DECRCTMO BIT(30) /* RW */ 252 248 253 - #define MSDC_PATCH_BIT1_CMDTA GENMASK(5, 3) /* RW */ 249 + /* MSDC_PATCH_BIT1 mask */ 250 + #define MSDC_PB1_WRDAT_CRC_TACNTR GENMASK(2, 0) /* RW */ 251 + #define MSDC_PATCH_BIT1_CMDTA GENMASK(5, 3) /* RW */ 254 252 #define MSDC_PB1_BUSY_CHECK_SEL BIT(7) /* RW */ 255 253 #define MSDC_PATCH_BIT1_STOP_DLY GENMASK(11, 8) /* RW */ 254 + #define MSDC_PB1_DDR_CMD_FIX_SEL BIT(14) /* RW */ 255 + #define MSDC_PB1_SINGLE_BURST BIT(16) /* RW */ 256 + #define MSDC_PB1_RSVD20 GENMASK(18, 17) /* RW */ 257 + #define MSDC_PB1_AUTO_SYNCST_CLR BIT(19) /* RW */ 258 + #define MSDC_PB1_MARK_POP_WATER BIT(20) /* RW */ 259 + #define MSDC_PB1_LP_DCM_EN BIT(21) /* RW */ 260 + #define MSDC_PB1_RSVD3 BIT(22) /* RW */ 261 + #define MSDC_PB1_AHB_GDMA_HCLK BIT(23) /* RW */ 262 + #define MSDC_PB1_MSDC_CLK_ENFEAT GENMASK(31, 24) /* RW */ 256 263 264 + /* MSDC_PATCH_BIT2 mask */ 257 265 #define MSDC_PATCH_BIT2_CFGRESP BIT(15) /* RW */ 258 266 #define MSDC_PATCH_BIT2_CFGCRCSTS BIT(28) /* RW */ 259 267 #define MSDC_PB2_SUPPORT_64G BIT(1) /* RW */ ··· 307 291 /* EMMC50_CFG1 mask */ 308 292 #define EMMC50_CFG1_DS_CFG BIT(28) /* RW */ 309 293 310 - #define EMMC50_CFG3_OUTS_WR GENMASK(4, 0) /* RW */ 294 + /* EMMC50_CFG2 mask */ 295 + #define EMMC50_CFG2_AXI_SET_LEN GENMASK(27, 24) /* RW */ 296 + 297 + #define EMMC50_CFG3_OUTS_WR GENMASK(4, 0) /* RW */ 311 298 312 299 #define SDC_FIFO_CFG_WRVALIDSEL BIT(24) /* RW */ 313 300 #define SDC_FIFO_CFG_RDVALIDSEL BIT(25) /* RW */ ··· 946 927 947 928 static void msdc_new_tx_setting(struct msdc_host *host) 948 929 { 930 + u32 val; 931 + 949 932 if (!host->top_base) 950 933 return; 951 934 952 - sdr_set_bits(host->top_base + LOOP_TEST_CONTROL, 953 - TEST_LOOP_DSCLK_MUX_SEL); 954 - sdr_set_bits(host->top_base + LOOP_TEST_CONTROL, 955 - TEST_LOOP_LATCH_MUX_SEL); 956 - sdr_clr_bits(host->top_base + LOOP_TEST_CONTROL, 957 - TEST_HS400_CMD_LOOP_MUX_SEL); 935 + val = readl(host->top_base + LOOP_TEST_CONTROL); 936 + val |= TEST_LOOP_DSCLK_MUX_SEL; 937 + val |= TEST_LOOP_LATCH_MUX_SEL; 938 + val &= ~TEST_HS400_CMD_LOOP_MUX_SEL; 958 939 959 940 switch (host->timing) { 960 941 case MMC_TIMING_LEGACY: ··· 964 945 case MMC_TIMING_UHS_SDR25: 965 946 case MMC_TIMING_UHS_DDR50: 966 947 case MMC_TIMING_MMC_DDR52: 967 - sdr_clr_bits(host->top_base + LOOP_TEST_CONTROL, 968 - LOOP_EN_SEL_CLK); 948 + val &= ~LOOP_EN_SEL_CLK; 969 949 break; 970 950 case MMC_TIMING_UHS_SDR50: 971 951 case MMC_TIMING_UHS_SDR104: 972 952 case MMC_TIMING_MMC_HS200: 973 953 case MMC_TIMING_MMC_HS400: 974 - sdr_set_bits(host->top_base + LOOP_TEST_CONTROL, 975 - LOOP_EN_SEL_CLK); 954 + val |= LOOP_EN_SEL_CLK; 976 955 break; 977 956 default: 978 957 break; 979 958 } 959 + writel(val, host->top_base + LOOP_TEST_CONTROL); 980 960 } 981 961 982 962 static void msdc_set_mclk(struct msdc_host *host, unsigned char timing, u32 hz) ··· 1834 1816 1835 1817 static void msdc_init_hw(struct msdc_host *host) 1836 1818 { 1837 - u32 val; 1819 + u32 val, pb1_val, pb2_val; 1838 1820 u32 tune_reg = host->dev_comp->pad_tune_reg; 1839 1821 struct mmc_host *mmc = mmc_from_priv(host); 1840 1822 ··· 1887 1869 } 1888 1870 writel(0, host->base + MSDC_IOCON); 1889 1871 sdr_set_field(host->base + MSDC_IOCON, MSDC_IOCON_DDLSEL, 0); 1890 - writel(0x403c0046, host->base + MSDC_PATCH_BIT); 1891 - sdr_set_field(host->base + MSDC_PATCH_BIT, MSDC_CKGEN_MSDC_DLY_SEL, 1); 1892 - writel(0xffff4089, host->base + MSDC_PATCH_BIT1); 1893 - sdr_set_bits(host->base + EMMC50_CFG0, EMMC50_CFG_CFCSTS_SEL); 1872 + 1873 + /* 1874 + * Patch bit 0 and 1 are completely rewritten, but for patch bit 2 1875 + * defaults are retained and, if necessary, only some bits are fixed 1876 + * up: read the PB2 register here for later usage in this function. 1877 + */ 1878 + pb2_val = readl(host->base + MSDC_PATCH_BIT2); 1879 + 1880 + /* Enable odd number support for 8-bit data bus */ 1881 + val = MSDC_PATCH_BIT_ODDSUPP; 1882 + 1883 + /* Disable SD command register write monitor */ 1884 + val |= MSDC_PATCH_BIT_DIS_WRMON; 1885 + 1886 + /* Issue transfer done interrupt after GPD update */ 1887 + val |= MSDC_PATCH_BIT_DESCUP_SEL; 1888 + 1889 + /* Extend R1B busy detection delay (in clock cycles) */ 1890 + val |= FIELD_PREP(MSDC_PATCH_BIT_BUSYDLY, 15); 1891 + 1892 + /* Enable CRC phase timeout during data write operation */ 1893 + val |= MSDC_PATCH_BIT_DECRCTMO; 1894 + 1895 + /* Set CKGEN delay to one stage */ 1896 + val |= FIELD_PREP(MSDC_CKGEN_MSDC_DLY_SEL, 1); 1897 + 1898 + /* First MSDC_PATCH_BIT setup is done: pull the trigger! */ 1899 + writel(val, host->base + MSDC_PATCH_BIT); 1900 + 1901 + /* Set wr data, crc status, cmd response turnaround period for UHS104 */ 1902 + pb1_val = FIELD_PREP(MSDC_PB1_WRDAT_CRC_TACNTR, 1); 1903 + pb1_val |= FIELD_PREP(MSDC_PATCH_BIT1_CMDTA, 1); 1904 + pb1_val |= MSDC_PB1_DDR_CMD_FIX_SEL; 1905 + 1906 + /* Support 'single' burst type only when AXI_LEN is 0 */ 1907 + sdr_get_field(host->base + EMMC50_CFG2, EMMC50_CFG2_AXI_SET_LEN, &val); 1908 + if (!val) 1909 + pb1_val |= MSDC_PB1_SINGLE_BURST; 1910 + 1911 + /* Set auto sync state clear, block gap stop clk */ 1912 + pb1_val |= MSDC_PB1_RSVD20 | MSDC_PB1_AUTO_SYNCST_CLR | MSDC_PB1_MARK_POP_WATER; 1913 + 1914 + /* Set low power DCM, use HCLK for GDMA, use MSDC CLK for everything else */ 1915 + pb1_val |= MSDC_PB1_LP_DCM_EN | MSDC_PB1_RSVD3 | 1916 + MSDC_PB1_AHB_GDMA_HCLK | MSDC_PB1_MSDC_CLK_ENFEAT; 1917 + 1918 + /* If needed, enable R1b command busy check at controller init time */ 1919 + if (!host->dev_comp->busy_check) 1920 + pb1_val |= MSDC_PB1_BUSY_CHECK_SEL; 1894 1921 1895 1922 if (host->dev_comp->stop_clk_fix) { 1896 1923 if (host->dev_comp->stop_dly_sel) 1897 - sdr_set_field(host->base + MSDC_PATCH_BIT1, 1898 - MSDC_PATCH_BIT1_STOP_DLY, 1899 - host->dev_comp->stop_dly_sel); 1924 + pb1_val |= FIELD_PREP(MSDC_PATCH_BIT1_STOP_DLY, 1925 + host->dev_comp->stop_dly_sel); 1900 1926 1901 - if (host->dev_comp->pop_en_cnt) 1902 - sdr_set_field(host->base + MSDC_PATCH_BIT2, 1903 - MSDC_PB2_POP_EN_CNT, 1904 - host->dev_comp->pop_en_cnt); 1927 + if (host->dev_comp->pop_en_cnt) { 1928 + pb2_val &= ~MSDC_PB2_POP_EN_CNT; 1929 + pb2_val |= FIELD_PREP(MSDC_PB2_POP_EN_CNT, 1930 + host->dev_comp->pop_en_cnt); 1931 + } 1905 1932 1906 - sdr_clr_bits(host->base + SDC_FIFO_CFG, 1907 - SDC_FIFO_CFG_WRVALIDSEL); 1908 - sdr_clr_bits(host->base + SDC_FIFO_CFG, 1909 - SDC_FIFO_CFG_RDVALIDSEL); 1933 + sdr_clr_bits(host->base + SDC_FIFO_CFG, SDC_FIFO_CFG_WRVALIDSEL); 1934 + sdr_clr_bits(host->base + SDC_FIFO_CFG, SDC_FIFO_CFG_RDVALIDSEL); 1910 1935 } 1911 1936 1912 - if (host->dev_comp->busy_check) 1913 - sdr_clr_bits(host->base + MSDC_PATCH_BIT1, BIT(7)); 1914 - 1915 1937 if (host->dev_comp->async_fifo) { 1916 - sdr_set_field(host->base + MSDC_PATCH_BIT2, 1917 - MSDC_PB2_RESPWAIT, 3); 1918 - if (host->dev_comp->enhance_rx) { 1919 - if (host->top_base) 1920 - sdr_set_bits(host->top_base + EMMC_TOP_CONTROL, 1921 - SDC_RX_ENH_EN); 1922 - else 1923 - sdr_set_bits(host->base + SDC_ADV_CFG0, 1924 - SDC_RX_ENHANCE_EN); 1938 + /* Set CMD response timeout multiplier to 65 + (16 * 3) cycles */ 1939 + pb2_val &= ~MSDC_PB2_RESPWAIT; 1940 + pb2_val |= FIELD_PREP(MSDC_PB2_RESPWAIT, 3); 1941 + 1942 + /* eMMC4.5: Select async FIFO path for CMD resp and CRC status */ 1943 + pb2_val &= ~MSDC_PATCH_BIT2_CFGRESP; 1944 + pb2_val |= MSDC_PATCH_BIT2_CFGCRCSTS; 1945 + 1946 + if (!host->dev_comp->enhance_rx) { 1947 + /* eMMC4.5: Delay 2T for CMD resp and CRC status EN signals */ 1948 + pb2_val &= ~(MSDC_PB2_RESPSTSENSEL | MSDC_PB2_CRCSTSENSEL); 1949 + pb2_val |= FIELD_PREP(MSDC_PB2_RESPSTSENSEL, 2); 1950 + pb2_val |= FIELD_PREP(MSDC_PB2_CRCSTSENSEL, 2); 1951 + } else if (host->top_base) { 1952 + sdr_set_bits(host->top_base + EMMC_TOP_CONTROL, SDC_RX_ENH_EN); 1925 1953 } else { 1926 - sdr_set_field(host->base + MSDC_PATCH_BIT2, 1927 - MSDC_PB2_RESPSTSENSEL, 2); 1928 - sdr_set_field(host->base + MSDC_PATCH_BIT2, 1929 - MSDC_PB2_CRCSTSENSEL, 2); 1954 + sdr_set_bits(host->base + SDC_ADV_CFG0, SDC_RX_ENHANCE_EN); 1930 1955 } 1931 - /* use async fifo, then no need tune internal delay */ 1932 - sdr_clr_bits(host->base + MSDC_PATCH_BIT2, 1933 - MSDC_PATCH_BIT2_CFGRESP); 1934 - sdr_set_bits(host->base + MSDC_PATCH_BIT2, 1935 - MSDC_PATCH_BIT2_CFGCRCSTS); 1936 1956 } 1937 1957 1938 1958 if (host->dev_comp->support_64g) 1939 - sdr_set_bits(host->base + MSDC_PATCH_BIT2, 1940 - MSDC_PB2_SUPPORT_64G); 1959 + pb2_val |= MSDC_PB2_SUPPORT_64G; 1960 + 1961 + /* Patch Bit 1/2 setup is done: pull the trigger! */ 1962 + writel(pb1_val, host->base + MSDC_PATCH_BIT1); 1963 + writel(pb2_val, host->base + MSDC_PATCH_BIT2); 1964 + sdr_set_bits(host->base + EMMC50_CFG0, EMMC50_CFG_CFCSTS_SEL); 1965 + 1941 1966 if (host->dev_comp->data_tune) { 1942 1967 if (host->top_base) { 1943 - sdr_set_bits(host->top_base + EMMC_TOP_CONTROL, 1944 - PAD_DAT_RD_RXDLY_SEL); 1945 - sdr_clr_bits(host->top_base + EMMC_TOP_CONTROL, 1946 - DATA_K_VALUE_SEL); 1947 - sdr_set_bits(host->top_base + EMMC_TOP_CMD, 1948 - PAD_CMD_RD_RXDLY_SEL); 1968 + u32 top_ctl_val = readl(host->top_base + EMMC_TOP_CONTROL); 1969 + u32 top_cmd_val = readl(host->top_base + EMMC_TOP_CMD); 1970 + 1971 + top_cmd_val |= PAD_CMD_RD_RXDLY_SEL; 1972 + top_ctl_val |= PAD_DAT_RD_RXDLY_SEL; 1973 + top_ctl_val &= ~DATA_K_VALUE_SEL; 1949 1974 if (host->tuning_step > PAD_DELAY_HALF) { 1950 - sdr_set_bits(host->top_base + EMMC_TOP_CONTROL, 1951 - PAD_DAT_RD_RXDLY2_SEL); 1952 - sdr_set_bits(host->top_base + EMMC_TOP_CMD, 1953 - PAD_CMD_RD_RXDLY2_SEL); 1975 + top_cmd_val |= PAD_CMD_RD_RXDLY2_SEL; 1976 + top_ctl_val |= PAD_DAT_RD_RXDLY2_SEL; 1954 1977 } 1978 + 1979 + writel(top_ctl_val, host->top_base + EMMC_TOP_CONTROL); 1980 + writel(top_cmd_val, host->top_base + EMMC_TOP_CMD); 1955 1981 } else { 1956 1982 sdr_set_bits(host->base + tune_reg, 1957 1983 MSDC_PAD_TUNE_RD_SEL | ··· 2205 2143 u32 tune_reg = host->dev_comp->pad_tune_reg; 2206 2144 2207 2145 if (host->top_base) { 2146 + u32 regval = readl(host->top_base + EMMC_TOP_CMD); 2147 + 2148 + regval &= ~(PAD_CMD_RXDLY | PAD_CMD_RXDLY2); 2149 + 2208 2150 if (value < PAD_DELAY_HALF) { 2209 - sdr_set_field(host->top_base + EMMC_TOP_CMD, PAD_CMD_RXDLY, value); 2210 - sdr_set_field(host->top_base + EMMC_TOP_CMD, PAD_CMD_RXDLY2, 0); 2151 + regval |= FIELD_PREP(PAD_CMD_RXDLY, value); 2211 2152 } else { 2212 - sdr_set_field(host->top_base + EMMC_TOP_CMD, PAD_CMD_RXDLY, 2213 - PAD_DELAY_HALF - 1); 2214 - sdr_set_field(host->top_base + EMMC_TOP_CMD, PAD_CMD_RXDLY2, 2215 - value - PAD_DELAY_HALF); 2153 + regval |= FIELD_PREP(PAD_CMD_RXDLY, PAD_DELAY_HALF - 1); 2154 + regval |= FIELD_PREP(PAD_CMD_RXDLY2, value - PAD_DELAY_HALF); 2216 2155 } 2156 + writel(regval, host->top_base + EMMC_TOP_CMD); 2217 2157 } else { 2218 2158 if (value < PAD_DELAY_HALF) { 2219 2159 sdr_set_field(host->base + tune_reg, MSDC_PAD_TUNE_CMDRDLY, value); ··· 2235 2171 u32 tune_reg = host->dev_comp->pad_tune_reg; 2236 2172 2237 2173 if (host->top_base) { 2174 + u32 regval = readl(host->top_base + EMMC_TOP_CONTROL); 2175 + 2176 + regval &= ~(PAD_DAT_RD_RXDLY | PAD_DAT_RD_RXDLY2); 2177 + 2238 2178 if (value < PAD_DELAY_HALF) { 2239 - sdr_set_field(host->top_base + EMMC_TOP_CONTROL, 2240 - PAD_DAT_RD_RXDLY, value); 2241 - sdr_set_field(host->top_base + EMMC_TOP_CONTROL, 2242 - PAD_DAT_RD_RXDLY2, 0); 2179 + regval |= FIELD_PREP(PAD_DAT_RD_RXDLY, value); 2180 + regval |= FIELD_PREP(PAD_DAT_RD_RXDLY2, value); 2243 2181 } else { 2244 - sdr_set_field(host->top_base + EMMC_TOP_CONTROL, 2245 - PAD_DAT_RD_RXDLY, PAD_DELAY_HALF - 1); 2246 - sdr_set_field(host->top_base + EMMC_TOP_CONTROL, 2247 - PAD_DAT_RD_RXDLY2, value - PAD_DELAY_HALF); 2182 + regval |= FIELD_PREP(PAD_DAT_RD_RXDLY, PAD_DELAY_HALF - 1); 2183 + regval |= FIELD_PREP(PAD_DAT_RD_RXDLY2, value - PAD_DELAY_HALF); 2248 2184 } 2185 + writel(regval, host->top_base + EMMC_TOP_CONTROL); 2249 2186 } else { 2250 2187 if (value < PAD_DELAY_HALF) { 2251 2188 sdr_set_field(host->base + tune_reg, MSDC_PAD_TUNE_DATRRDLY, value); ··· 3042 2977 mmc->f_min = DIV_ROUND_UP(host->src_clk_freq, 4 * 4095); 3043 2978 3044 2979 if (!(mmc->caps & MMC_CAP_NONREMOVABLE) && 3045 - !mmc_can_gpio_cd(mmc) && 2980 + !mmc_host_can_gpio_cd(mmc) && 3046 2981 host->dev_comp->use_internal_cd) { 3047 2982 /* 3048 2983 * Is removable but no GPIO declared, so
+5 -15
drivers/mmc/host/renesas_sdhi_core.c
··· 1112 1112 host->mmc->caps2 &= ~(MMC_CAP2_HS400 | MMC_CAP2_HS400_ES); 1113 1113 1114 1114 /* For some SoC, we disable internal WP. GPIO may override this */ 1115 - if (mmc_can_gpio_ro(host->mmc)) 1115 + if (mmc_host_can_gpio_ro(host->mmc)) 1116 1116 mmc_data->capabilities2 &= ~MMC_CAP2_NO_WRITE_PROTECT; 1117 1117 1118 1118 /* SDR speeds are only available on Gen2+ */ ··· 1166 1166 if (ret) 1167 1167 goto efree; 1168 1168 1169 - rcfg.of_node = of_get_child_by_name(dev->of_node, "vqmmc-regulator"); 1170 - if (!of_device_is_available(rcfg.of_node)) { 1171 - of_node_put(rcfg.of_node); 1172 - rcfg.of_node = NULL; 1173 - } 1174 - 1169 + rcfg.of_node = of_get_available_child_by_name(dev->of_node, "vqmmc-regulator"); 1175 1170 if (rcfg.of_node) { 1176 1171 rcfg.driver_data = priv->host; 1177 1172 rdev = devm_regulator_register(dev, &renesas_sdhi_vqmmc_regulator, &rcfg); ··· 1235 1240 1236 1241 sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, host->sdcard_irq_mask_all); 1237 1242 1238 - num_irqs = platform_irq_count(pdev); 1239 - if (num_irqs < 0) { 1240 - ret = num_irqs; 1241 - goto edisclk; 1242 - } 1243 - 1244 1243 /* There must be at least one IRQ source */ 1245 - if (!num_irqs) { 1246 - ret = -ENXIO; 1244 + num_irqs = platform_irq_count(pdev); 1245 + if (num_irqs <= 0) { 1246 + ret = num_irqs ?: -ENOENT; 1247 1247 goto edisclk; 1248 1248 } 1249 1249
+197 -44
drivers/mmc/host/sdhci-esdhc-imx.c
··· 31 31 #include "cqhci.h" 32 32 33 33 #define ESDHC_SYS_CTRL_DTOCV_MASK GENMASK(19, 16) 34 + #define ESDHC_SYS_CTRL_RST_FIFO BIT(22) 34 35 #define ESDHC_SYS_CTRL_IPP_RST_N BIT(23) 36 + #define ESDHC_SYS_CTRL_RESET_TUNING BIT(28) 35 37 #define ESDHC_CTRL_D3CD 0x08 36 38 #define ESDHC_BURST_LEN_EN_INCR (1 << 27) 37 39 /* VENDOR SPEC register */ ··· 83 81 #define ESDHC_TUNE_CTRL_STEP 1 84 82 #define ESDHC_TUNE_CTRL_MIN 0 85 83 #define ESDHC_TUNE_CTRL_MAX ((1 << 7) - 1) 86 - 84 + #define ESDHC_TUNE_CTRL_STATUS_TAP_SEL_MASK GENMASK(30, 16) 85 + #define ESDHC_TUNE_CTRL_STATUS_TAP_SEL_PRE_MASK GENMASK(30, 24) 86 + #define ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_PRE_MASK GENMASK(14, 8) 87 + #define ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_OUT_MASK GENMASK(7, 4) 88 + #define ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_POST_MASK GENMASK(3, 0) 87 89 /* strobe dll register */ 88 90 #define ESDHC_STROBE_DLL_CTRL 0x70 89 91 #define ESDHC_STROBE_DLL_CTRL_ENABLE (1 << 0) ··· 110 104 111 105 #define ESDHC_TUNING_CTRL 0xcc 112 106 #define ESDHC_STD_TUNING_EN (1 << 24) 107 + #define ESDHC_TUNING_WINDOW_MASK GENMASK(22, 20) 113 108 /* NOTE: the minimum valid tuning start tap for mx6sl is 1 */ 114 109 #define ESDHC_TUNING_START_TAP_DEFAULT 0x1 115 110 #define ESDHC_TUNING_START_TAP_MASK 0x7f ··· 212 205 /* The IP does not have GPIO CD wake capabilities */ 213 206 #define ESDHC_FLAG_SKIP_CD_WAKE BIT(18) 214 207 208 + #define ESDHC_AUTO_TUNING_WINDOW 3 209 + 215 210 enum wp_types { 216 211 ESDHC_WP_NONE, /* no WP, neither controller nor gpio */ 217 212 ESDHC_WP_CONTROLLER, /* mmc controller internal WP */ ··· 244 235 unsigned int tuning_step; /* The delay cell steps in tuning procedure */ 245 236 unsigned int tuning_start_tap; /* The start delay cell point in tuning procedure */ 246 237 unsigned int strobe_dll_delay_target; /* The delay cell for strobe pad (read clock) */ 238 + unsigned int saved_tuning_delay_cell; /* save the value of tuning delay cell */ 239 + unsigned int saved_auto_tuning_window; /* save the auto tuning window width */ 247 240 }; 248 241 249 242 struct esdhc_soc_data { ··· 275 264 }; 276 265 277 266 static const struct esdhc_soc_data usdhc_imx6sl_data = { 278 - .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING 267 + .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_MAN_TUNING 279 268 | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_ERR004536 280 269 | ESDHC_FLAG_HS200 281 270 | ESDHC_FLAG_BROKEN_AUTO_CMD23, 282 271 }; 283 272 284 273 static const struct esdhc_soc_data usdhc_imx6sll_data = { 285 - .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING 274 + .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_MAN_TUNING 286 275 | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 287 276 | ESDHC_FLAG_HS400 288 277 | ESDHC_FLAG_STATE_LOST_IN_LPMODE, 289 278 }; 290 279 291 280 static const struct esdhc_soc_data usdhc_imx6sx_data = { 292 - .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING 281 + .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_MAN_TUNING 293 282 | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 294 283 | ESDHC_FLAG_STATE_LOST_IN_LPMODE 295 284 | ESDHC_FLAG_BROKEN_AUTO_CMD23, 296 285 }; 297 286 298 287 static const struct esdhc_soc_data usdhc_imx6ull_data = { 299 - .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING 288 + .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_MAN_TUNING 300 289 | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 301 290 | ESDHC_FLAG_ERR010450 302 291 | ESDHC_FLAG_STATE_LOST_IN_LPMODE, 303 292 }; 304 293 305 294 static const struct esdhc_soc_data usdhc_imx7d_data = { 306 - .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING 295 + .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_MAN_TUNING 307 296 | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 308 297 | ESDHC_FLAG_HS400 309 298 | ESDHC_FLAG_STATE_LOST_IN_LPMODE ··· 319 308 }; 320 309 321 310 static struct esdhc_soc_data usdhc_imx7ulp_data = { 322 - .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING 311 + .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_MAN_TUNING 323 312 | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 324 313 | ESDHC_FLAG_PMQOS | ESDHC_FLAG_HS400 325 314 | ESDHC_FLAG_STATE_LOST_IN_LPMODE, ··· 332 321 }; 333 322 334 323 static struct esdhc_soc_data usdhc_imx8qxp_data = { 335 - .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING 324 + .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_MAN_TUNING 336 325 | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 337 326 | ESDHC_FLAG_HS400 | ESDHC_FLAG_HS400_ES 338 327 | ESDHC_FLAG_STATE_LOST_IN_LPMODE ··· 341 330 }; 342 331 343 332 static struct esdhc_soc_data usdhc_imx8mm_data = { 344 - .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING 333 + .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_MAN_TUNING 345 334 | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 346 335 | ESDHC_FLAG_HS400 | ESDHC_FLAG_HS400_ES 347 336 | ESDHC_FLAG_STATE_LOST_IN_LPMODE, ··· 881 870 882 871 esdhc_clrset_le(host, mask, new_val, reg); 883 872 return; 873 + case SDHCI_TIMEOUT_CONTROL: 874 + esdhc_clrset_le(host, ESDHC_SYS_CTRL_DTOCV_MASK, 875 + FIELD_PREP(ESDHC_SYS_CTRL_DTOCV_MASK, val), 876 + ESDHC_SYSTEM_CONTROL); 877 + return; 884 878 case SDHCI_SOFTWARE_RESET: 885 879 if (val & SDHCI_RESET_DATA) 886 880 new_val = readl(host->ioaddr + SDHCI_HOST_CONTROL); ··· 1073 1057 { 1074 1058 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 1075 1059 struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); 1076 - u32 ctrl; 1060 + u32 ctrl, tuning_ctrl, sys_ctrl; 1077 1061 int ret; 1078 1062 1079 1063 /* Reset the tuning circuit */ ··· 1087 1071 writel(0, host->ioaddr + ESDHC_TUNE_CTRL_STATUS); 1088 1072 } else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) { 1089 1073 writel(ctrl, host->ioaddr + ESDHC_MIX_CTRL); 1074 + /* 1075 + * enable the std tuning just in case it cleared in 1076 + * sdhc_esdhc_tuning_restore. 1077 + */ 1078 + tuning_ctrl = readl(host->ioaddr + ESDHC_TUNING_CTRL); 1079 + if (!(tuning_ctrl & ESDHC_STD_TUNING_EN)) { 1080 + tuning_ctrl |= ESDHC_STD_TUNING_EN; 1081 + writel(tuning_ctrl, host->ioaddr + ESDHC_TUNING_CTRL); 1082 + } 1083 + 1084 + /* set the reset tuning bit */ 1085 + sys_ctrl = readl(host->ioaddr + ESDHC_SYSTEM_CONTROL); 1086 + sys_ctrl |= ESDHC_SYS_CTRL_RESET_TUNING; 1087 + writel(sys_ctrl, host->ioaddr + ESDHC_SYSTEM_CONTROL); 1088 + 1090 1089 ctrl = readl(host->ioaddr + SDHCI_AUTO_CMD_STATUS); 1091 1090 ctrl &= ~ESDHC_MIX_CTRL_SMPCLK_SEL; 1092 1091 ctrl &= ~ESDHC_MIX_CTRL_EXE_TUNE; ··· 1161 1130 1162 1131 static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val) 1163 1132 { 1164 - u32 reg; 1133 + u32 reg, sys_ctrl; 1165 1134 u8 sw_rst; 1166 1135 int ret; 1167 1136 ··· 1180 1149 reg |= ESDHC_MIX_CTRL_EXE_TUNE | ESDHC_MIX_CTRL_SMPCLK_SEL | 1181 1150 ESDHC_MIX_CTRL_FBCLK_SEL; 1182 1151 writel(reg, host->ioaddr + ESDHC_MIX_CTRL); 1183 - writel(val << 8, host->ioaddr + ESDHC_TUNE_CTRL_STATUS); 1152 + writel(FIELD_PREP(ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_PRE_MASK, val), 1153 + host->ioaddr + ESDHC_TUNE_CTRL_STATUS); 1184 1154 dev_dbg(mmc_dev(host->mmc), 1185 1155 "tuning with delay 0x%x ESDHC_TUNE_CTRL_STATUS 0x%x\n", 1186 1156 val, readl(host->ioaddr + ESDHC_TUNE_CTRL_STATUS)); 1157 + 1158 + /* set RST_FIFO to reset the async FIFO, and wat it to self-clear */ 1159 + sys_ctrl = readl(host->ioaddr + ESDHC_SYSTEM_CONTROL); 1160 + sys_ctrl |= ESDHC_SYS_CTRL_RST_FIFO; 1161 + writel(sys_ctrl, host->ioaddr + ESDHC_SYSTEM_CONTROL); 1162 + ret = readl_poll_timeout(host->ioaddr + ESDHC_SYSTEM_CONTROL, sys_ctrl, 1163 + !(sys_ctrl & ESDHC_SYS_CTRL_RST_FIFO), 10, 100); 1164 + if (ret == -ETIMEDOUT) 1165 + dev_warn(mmc_dev(host->mmc), 1166 + "warning! RST_FIFO not clear in 100us\n"); 1187 1167 } 1188 1168 1189 1169 static void esdhc_post_tuning(struct sdhci_host *host) ··· 1214 1172 { 1215 1173 int min, max, avg, ret; 1216 1174 int win_length, target_min, target_max, target_win_length; 1175 + u32 clk_tune_ctrl_status, temp; 1217 1176 1218 - min = ESDHC_TUNE_CTRL_MIN; 1219 - max = ESDHC_TUNE_CTRL_MIN; 1177 + min = target_min = ESDHC_TUNE_CTRL_MIN; 1178 + max = target_max = ESDHC_TUNE_CTRL_MIN; 1220 1179 target_win_length = 0; 1221 1180 while (max < ESDHC_TUNE_CTRL_MAX) { 1222 1181 /* find the mininum delay first which can pass tuning */ ··· 1254 1211 /* use average delay to get the best timing */ 1255 1212 avg = (target_min + target_max) / 2; 1256 1213 esdhc_prepare_tuning(host, avg); 1214 + 1215 + /* 1216 + * adjust the delay according to tuning window, make preparation 1217 + * for the auto-tuning logic. According to hardware suggest, need 1218 + * to config the auto tuning window width to 3, to make the auto 1219 + * tuning logic have enough space to handle the sample point shift 1220 + * caused by temperature change. 1221 + */ 1222 + clk_tune_ctrl_status = FIELD_PREP(ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_PRE_MASK, 1223 + avg - ESDHC_AUTO_TUNING_WINDOW) | 1224 + FIELD_PREP(ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_OUT_MASK, 1225 + ESDHC_AUTO_TUNING_WINDOW) | 1226 + FIELD_PREP(ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_POST_MASK, 1227 + ESDHC_AUTO_TUNING_WINDOW); 1228 + 1229 + writel(clk_tune_ctrl_status, host->ioaddr + ESDHC_TUNE_CTRL_STATUS); 1230 + ret = readl_poll_timeout(host->ioaddr + ESDHC_TUNE_CTRL_STATUS, temp, 1231 + clk_tune_ctrl_status == 1232 + FIELD_GET(ESDHC_TUNE_CTRL_STATUS_TAP_SEL_MASK, temp), 1233 + 1, 10); 1234 + if (ret == -ETIMEDOUT) 1235 + dev_warn(mmc_dev(host->mmc), 1236 + "clock tuning control status not set in 10us\n"); 1237 + 1257 1238 ret = mmc_send_tuning(host->mmc, opcode, NULL); 1258 1239 esdhc_post_tuning(host); 1259 1240 ··· 1452 1385 return esdhc_is_usdhc(imx_data) ? 1 << 29 : 1 << 27; 1453 1386 } 1454 1387 1455 - static void esdhc_set_timeout(struct sdhci_host *host, struct mmc_command *cmd) 1456 - { 1457 - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 1458 - struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); 1459 - 1460 - /* use maximum timeout counter */ 1461 - esdhc_clrset_le(host, ESDHC_SYS_CTRL_DTOCV_MASK, 1462 - esdhc_is_usdhc(imx_data) ? 0xF0000 : 0xE0000, 1463 - ESDHC_SYSTEM_CONTROL); 1464 - } 1465 - 1466 1388 static u32 esdhc_cqhci_irq(struct sdhci_host *host, u32 intmask) 1467 1389 { 1468 1390 int cmd_error = 0; ··· 1488 1432 .get_min_clock = esdhc_pltfm_get_min_clock, 1489 1433 .get_max_timeout_count = esdhc_get_max_timeout_count, 1490 1434 .get_ro = esdhc_pltfm_get_ro, 1491 - .set_timeout = esdhc_set_timeout, 1492 1435 .set_bus_width = esdhc_pltfm_set_bus_width, 1493 1436 .set_uhs_signaling = esdhc_set_uhs_signaling, 1494 1437 .reset = esdhc_reset, ··· 1584 1529 << ESDHC_TUNING_STEP_SHIFT; 1585 1530 } 1586 1531 1532 + /* 1533 + * Config the tuning window to the hardware suggested value 3. 1534 + * This tuning window is used for auto tuning logic. The default 1535 + * tuning window is 2, here change to 3 make the window a bit 1536 + * wider, give auto tuning enough space to handle the sample 1537 + * point shift cause by temperature change. 1538 + */ 1539 + tmp &= ~ESDHC_TUNING_WINDOW_MASK; 1540 + tmp |= FIELD_PREP(ESDHC_TUNING_WINDOW_MASK, ESDHC_AUTO_TUNING_WINDOW); 1541 + 1587 1542 /* Disable the CMD CRC check for tuning, if not, need to 1588 1543 * add some delay after every tuning command, because 1589 1544 * hardware standard tuning logic will directly go to next ··· 1633 1568 } 1634 1569 } 1635 1570 } 1571 + 1572 + #ifdef CONFIG_PM_SLEEP 1573 + static void sdhc_esdhc_tuning_save(struct sdhci_host *host) 1574 + { 1575 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 1576 + struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); 1577 + u32 reg; 1578 + 1579 + /* 1580 + * SD/eMMC do not need this tuning save because it will re-init 1581 + * after system resume back. 1582 + * Here save the tuning delay value for SDIO device since it may 1583 + * keep power during system PM. And for usdhc, only SDR50 and 1584 + * SDR104 mode for SDIO device need to do tuning, and need to 1585 + * save/restore. 1586 + */ 1587 + if (host->timing == MMC_TIMING_UHS_SDR50 || 1588 + host->timing == MMC_TIMING_UHS_SDR104) { 1589 + reg = readl(host->ioaddr + ESDHC_TUNE_CTRL_STATUS); 1590 + reg = FIELD_GET(ESDHC_TUNE_CTRL_STATUS_TAP_SEL_PRE_MASK, reg); 1591 + imx_data->boarddata.saved_tuning_delay_cell = reg; 1592 + } 1593 + } 1594 + 1595 + static void sdhc_esdhc_tuning_restore(struct sdhci_host *host) 1596 + { 1597 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 1598 + struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); 1599 + u32 reg; 1600 + 1601 + if (host->timing == MMC_TIMING_UHS_SDR50 || 1602 + host->timing == MMC_TIMING_UHS_SDR104) { 1603 + /* 1604 + * restore the tuning delay value actually is a 1605 + * manual tuning method, so clear the standard 1606 + * tuning enable bit here. Will set back this 1607 + * ESDHC_STD_TUNING_EN in esdhc_reset_tuning() 1608 + * when trigger re-tuning. 1609 + */ 1610 + reg = readl(host->ioaddr + ESDHC_TUNING_CTRL); 1611 + reg &= ~ESDHC_STD_TUNING_EN; 1612 + writel(reg, host->ioaddr + ESDHC_TUNING_CTRL); 1613 + 1614 + reg = readl(host->ioaddr + ESDHC_MIX_CTRL); 1615 + reg |= ESDHC_MIX_CTRL_SMPCLK_SEL | ESDHC_MIX_CTRL_FBCLK_SEL; 1616 + writel(reg, host->ioaddr + ESDHC_MIX_CTRL); 1617 + 1618 + writel(FIELD_PREP(ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_PRE_MASK, 1619 + imx_data->boarddata.saved_tuning_delay_cell) | 1620 + FIELD_PREP(ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_OUT_MASK, 1621 + ESDHC_AUTO_TUNING_WINDOW) | 1622 + FIELD_PREP(ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_POST_MASK, 1623 + ESDHC_AUTO_TUNING_WINDOW), 1624 + host->ioaddr + ESDHC_TUNE_CTRL_STATUS); 1625 + } 1626 + } 1627 + #endif 1636 1628 1637 1629 static void esdhc_cqe_enable(struct mmc_host *mmc) 1638 1630 { ··· 1899 1777 * to distinguish the card type. 1900 1778 */ 1901 1779 host->mmc_host_ops.init_card = usdhc_init_card; 1780 + 1781 + host->max_timeout_count = 0xF; 1902 1782 } 1903 1783 1904 1784 if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) ··· 2009 1885 struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); 2010 1886 int ret; 2011 1887 2012 - if (host->mmc->caps2 & MMC_CAP2_CQE) { 2013 - ret = cqhci_suspend(host->mmc); 2014 - if (ret) 2015 - return ret; 2016 - } 1888 + /* 1889 + * Switch to runtime resume for two reasons: 1890 + * 1, there is register access (e.g., wakeup control register), so 1891 + * need to make sure gate on ipg clock. 1892 + * 2, make sure the pm_runtime_force_resume() in sdhci_esdhc_resume() really 1893 + * invoke its ->runtime_resume callback (needs_force_resume = 1). 1894 + */ 1895 + pm_runtime_get_sync(dev); 2017 1896 2018 1897 if ((imx_data->socdata->flags & ESDHC_FLAG_STATE_LOST_IN_LPMODE) && 2019 1898 (host->tuning_mode != SDHCI_TUNING_MODE_1)) { ··· 2024 1897 mmc_retune_needed(host->mmc); 2025 1898 } 2026 1899 2027 - if (host->tuning_mode != SDHCI_TUNING_MODE_3) 2028 - mmc_retune_needed(host->mmc); 1900 + /* 1901 + * For the device need to keep power during system PM, need 1902 + * to save the tuning delay value just in case the usdhc 1903 + * lost power during system PM. 1904 + */ 1905 + if (mmc_card_keep_power(host->mmc) && mmc_card_wake_sdio_irq(host->mmc) && 1906 + esdhc_is_usdhc(imx_data)) 1907 + sdhc_esdhc_tuning_save(host); 2029 1908 2030 - ret = sdhci_suspend_host(host); 2031 - if (ret) 2032 - return ret; 1909 + if (device_may_wakeup(dev)) { 1910 + /* The irqs of imx are not shared. It is safe to disable */ 1911 + disable_irq(host->irq); 1912 + ret = sdhci_enable_irq_wakeups(host); 1913 + if (!ret) 1914 + dev_warn(dev, "Failed to enable irq wakeup\n"); 1915 + } 2033 1916 2034 1917 ret = pinctrl_pm_select_sleep_state(dev); 2035 1918 if (ret) ··· 2047 1910 2048 1911 ret = mmc_gpio_set_cd_wake(host->mmc, true); 2049 1912 1913 + /* 1914 + * Make sure invoke runtime_suspend to gate off clock. 1915 + * uSDHC IP supports in-band SDIO wakeup even without clock. 1916 + */ 1917 + pm_runtime_force_suspend(dev); 1918 + 2050 1919 return ret; 2051 1920 } 2052 1921 2053 1922 static int sdhci_esdhc_resume(struct device *dev) 2054 1923 { 2055 1924 struct sdhci_host *host = dev_get_drvdata(dev); 1925 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 1926 + struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); 2056 1927 int ret; 2057 1928 2058 - ret = pinctrl_pm_select_default_state(dev); 1929 + pm_runtime_force_resume(dev); 1930 + 1931 + ret = mmc_gpio_set_cd_wake(host->mmc, false); 2059 1932 if (ret) 2060 1933 return ret; 2061 1934 2062 1935 /* re-initialize hw state in case it's lost in low power mode */ 2063 1936 sdhci_esdhc_imx_hwinit(host); 2064 1937 2065 - ret = sdhci_resume_host(host); 2066 - if (ret) 2067 - return ret; 1938 + if (host->irq_wake_enabled) { 1939 + sdhci_disable_irq_wakeups(host); 1940 + enable_irq(host->irq); 1941 + } 2068 1942 2069 - if (host->mmc->caps2 & MMC_CAP2_CQE) 2070 - ret = cqhci_resume(host->mmc); 1943 + /* 1944 + * restore the saved tuning delay value for the device which keep 1945 + * power during system PM. 1946 + */ 1947 + if (mmc_card_keep_power(host->mmc) && mmc_card_wake_sdio_irq(host->mmc) && 1948 + esdhc_is_usdhc(imx_data)) 1949 + sdhc_esdhc_tuning_restore(host); 2071 1950 2072 - if (!ret) 2073 - ret = mmc_gpio_set_cd_wake(host->mmc, false); 1951 + pm_runtime_mark_last_busy(dev); 1952 + pm_runtime_put_autosuspend(dev); 2074 1953 2075 1954 return ret; 2076 1955 }
+304
drivers/mmc/host/sdhci-of-k1.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (C) 2023-2025 SpacemiT (Hangzhou) Technology Co. Ltd 4 + * Copyright (c) 2025 Yixun Lan <dlan@gentoo.org> 5 + */ 6 + 7 + #include <linux/bitfield.h> 8 + #include <linux/clk.h> 9 + #include <linux/delay.h> 10 + #include <linux/iopoll.h> 11 + #include <linux/init.h> 12 + #include <linux/mmc/card.h> 13 + #include <linux/mmc/host.h> 14 + #include <linux/mmc/mmc.h> 15 + #include <linux/module.h> 16 + #include <linux/of.h> 17 + #include <linux/of_device.h> 18 + #include <linux/platform_device.h> 19 + 20 + #include "sdhci.h" 21 + #include "sdhci-pltfm.h" 22 + 23 + #define SDHC_MMC_CTRL_REG 0x114 24 + #define MISC_INT_EN BIT(1) 25 + #define MISC_INT BIT(2) 26 + #define ENHANCE_STROBE_EN BIT(8) 27 + #define MMC_HS400 BIT(9) 28 + #define MMC_HS200 BIT(10) 29 + #define MMC_CARD_MODE BIT(12) 30 + 31 + #define SDHC_TX_CFG_REG 0x11C 32 + #define TX_INT_CLK_SEL BIT(30) 33 + #define TX_MUX_SEL BIT(31) 34 + 35 + #define SDHC_PHY_CTRL_REG 0x160 36 + #define PHY_FUNC_EN BIT(0) 37 + #define PHY_PLL_LOCK BIT(1) 38 + #define HOST_LEGACY_MODE BIT(31) 39 + 40 + #define SDHC_PHY_FUNC_REG 0x164 41 + #define PHY_TEST_EN BIT(7) 42 + #define HS200_USE_RFIFO BIT(15) 43 + 44 + #define SDHC_PHY_DLLCFG 0x168 45 + #define DLL_PREDLY_NUM GENMASK(3, 2) 46 + #define DLL_FULLDLY_RANGE GENMASK(5, 4) 47 + #define DLL_VREG_CTRL GENMASK(7, 6) 48 + #define DLL_ENABLE BIT(31) 49 + 50 + #define SDHC_PHY_DLLCFG1 0x16C 51 + #define DLL_REG1_CTRL GENMASK(7, 0) 52 + #define DLL_REG2_CTRL GENMASK(15, 8) 53 + #define DLL_REG3_CTRL GENMASK(23, 16) 54 + #define DLL_REG4_CTRL GENMASK(31, 24) 55 + 56 + #define SDHC_PHY_DLLSTS 0x170 57 + #define DLL_LOCK_STATE BIT(0) 58 + 59 + #define SDHC_PHY_PADCFG_REG 0x178 60 + #define PHY_DRIVE_SEL GENMASK(2, 0) 61 + #define RX_BIAS_CTRL BIT(5) 62 + 63 + struct spacemit_sdhci_host { 64 + struct clk *clk_core; 65 + struct clk *clk_io; 66 + }; 67 + 68 + /* All helper functions will update clr/set while preserve rest bits */ 69 + static inline void spacemit_sdhci_setbits(struct sdhci_host *host, u32 val, int reg) 70 + { 71 + sdhci_writel(host, sdhci_readl(host, reg) | val, reg); 72 + } 73 + 74 + static inline void spacemit_sdhci_clrbits(struct sdhci_host *host, u32 val, int reg) 75 + { 76 + sdhci_writel(host, sdhci_readl(host, reg) & ~val, reg); 77 + } 78 + 79 + static inline void spacemit_sdhci_clrsetbits(struct sdhci_host *host, u32 clr, u32 set, int reg) 80 + { 81 + u32 val = sdhci_readl(host, reg); 82 + 83 + val = (val & ~clr) | set; 84 + sdhci_writel(host, val, reg); 85 + } 86 + 87 + static void spacemit_sdhci_reset(struct sdhci_host *host, u8 mask) 88 + { 89 + sdhci_reset(host, mask); 90 + 91 + if (mask != SDHCI_RESET_ALL) 92 + return; 93 + 94 + spacemit_sdhci_setbits(host, PHY_FUNC_EN | PHY_PLL_LOCK, SDHC_PHY_CTRL_REG); 95 + 96 + spacemit_sdhci_clrsetbits(host, PHY_DRIVE_SEL, 97 + RX_BIAS_CTRL | FIELD_PREP(PHY_DRIVE_SEL, 4), 98 + SDHC_PHY_PADCFG_REG); 99 + 100 + if (!(host->mmc->caps2 & MMC_CAP2_NO_MMC)) 101 + spacemit_sdhci_setbits(host, MMC_CARD_MODE, SDHC_MMC_CTRL_REG); 102 + } 103 + 104 + static void spacemit_sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned int timing) 105 + { 106 + if (timing == MMC_TIMING_MMC_HS200) 107 + spacemit_sdhci_setbits(host, MMC_HS200, SDHC_MMC_CTRL_REG); 108 + 109 + if (timing == MMC_TIMING_MMC_HS400) 110 + spacemit_sdhci_setbits(host, MMC_HS400, SDHC_MMC_CTRL_REG); 111 + 112 + sdhci_set_uhs_signaling(host, timing); 113 + 114 + if (!(host->mmc->caps2 & MMC_CAP2_NO_SDIO)) 115 + spacemit_sdhci_setbits(host, SDHCI_CTRL_VDD_180, SDHCI_HOST_CONTROL2); 116 + } 117 + 118 + static void spacemit_sdhci_set_clock(struct sdhci_host *host, unsigned int clock) 119 + { 120 + struct mmc_host *mmc = host->mmc; 121 + 122 + if (mmc->ios.timing <= MMC_TIMING_UHS_SDR50) 123 + spacemit_sdhci_setbits(host, TX_INT_CLK_SEL, SDHC_TX_CFG_REG); 124 + else 125 + spacemit_sdhci_clrbits(host, TX_INT_CLK_SEL, SDHC_TX_CFG_REG); 126 + 127 + sdhci_set_clock(host, clock); 128 + }; 129 + 130 + static void spacemit_sdhci_phy_dll_init(struct sdhci_host *host) 131 + { 132 + u32 state; 133 + int ret; 134 + 135 + spacemit_sdhci_clrsetbits(host, DLL_PREDLY_NUM | DLL_FULLDLY_RANGE | DLL_VREG_CTRL, 136 + FIELD_PREP(DLL_PREDLY_NUM, 1) | 137 + FIELD_PREP(DLL_FULLDLY_RANGE, 1) | 138 + FIELD_PREP(DLL_VREG_CTRL, 1), 139 + SDHC_PHY_DLLCFG); 140 + 141 + spacemit_sdhci_clrsetbits(host, DLL_REG1_CTRL, 142 + FIELD_PREP(DLL_REG1_CTRL, 0x92), 143 + SDHC_PHY_DLLCFG1); 144 + 145 + spacemit_sdhci_setbits(host, DLL_ENABLE, SDHC_PHY_DLLCFG); 146 + 147 + ret = readl_poll_timeout(host->ioaddr + SDHC_PHY_DLLSTS, state, 148 + state & DLL_LOCK_STATE, 2, 100); 149 + if (ret == -ETIMEDOUT) 150 + dev_warn(mmc_dev(host->mmc), "fail to lock phy dll in 100us!\n"); 151 + } 152 + 153 + static void spacemit_sdhci_hs400_enhanced_strobe(struct mmc_host *mmc, struct mmc_ios *ios) 154 + { 155 + struct sdhci_host *host = mmc_priv(mmc); 156 + 157 + if (!ios->enhanced_strobe) { 158 + spacemit_sdhci_clrbits(host, ENHANCE_STROBE_EN, SDHC_MMC_CTRL_REG); 159 + return; 160 + } 161 + 162 + spacemit_sdhci_setbits(host, ENHANCE_STROBE_EN, SDHC_MMC_CTRL_REG); 163 + spacemit_sdhci_phy_dll_init(host); 164 + } 165 + 166 + static unsigned int spacemit_sdhci_clk_get_max_clock(struct sdhci_host *host) 167 + { 168 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 169 + 170 + return clk_get_rate(pltfm_host->clk); 171 + } 172 + 173 + static int spacemit_sdhci_pre_select_hs400(struct mmc_host *mmc) 174 + { 175 + struct sdhci_host *host = mmc_priv(mmc); 176 + 177 + spacemit_sdhci_setbits(host, MMC_HS400, SDHC_MMC_CTRL_REG); 178 + host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY; 179 + 180 + return 0; 181 + } 182 + 183 + static void spacemit_sdhci_post_select_hs400(struct mmc_host *mmc) 184 + { 185 + struct sdhci_host *host = mmc_priv(mmc); 186 + 187 + spacemit_sdhci_phy_dll_init(host); 188 + host->mmc->caps &= ~MMC_CAP_WAIT_WHILE_BUSY; 189 + } 190 + 191 + static void spacemit_sdhci_pre_hs400_to_hs200(struct mmc_host *mmc) 192 + { 193 + struct sdhci_host *host = mmc_priv(mmc); 194 + 195 + spacemit_sdhci_clrbits(host, PHY_FUNC_EN | PHY_PLL_LOCK, SDHC_PHY_CTRL_REG); 196 + spacemit_sdhci_clrbits(host, MMC_HS400 | MMC_HS200 | ENHANCE_STROBE_EN, SDHC_MMC_CTRL_REG); 197 + spacemit_sdhci_clrbits(host, HS200_USE_RFIFO, SDHC_PHY_FUNC_REG); 198 + 199 + udelay(5); 200 + 201 + spacemit_sdhci_setbits(host, PHY_FUNC_EN | PHY_PLL_LOCK, SDHC_PHY_CTRL_REG); 202 + } 203 + 204 + static inline int spacemit_sdhci_get_clocks(struct device *dev, 205 + struct sdhci_pltfm_host *pltfm_host) 206 + { 207 + struct spacemit_sdhci_host *sdhst = sdhci_pltfm_priv(pltfm_host); 208 + 209 + sdhst->clk_core = devm_clk_get_enabled(dev, "core"); 210 + if (IS_ERR(sdhst->clk_core)) 211 + return -EINVAL; 212 + 213 + sdhst->clk_io = devm_clk_get_enabled(dev, "io"); 214 + if (IS_ERR(sdhst->clk_io)) 215 + return -EINVAL; 216 + 217 + pltfm_host->clk = sdhst->clk_io; 218 + 219 + return 0; 220 + } 221 + 222 + static const struct sdhci_ops spacemit_sdhci_ops = { 223 + .get_max_clock = spacemit_sdhci_clk_get_max_clock, 224 + .reset = spacemit_sdhci_reset, 225 + .set_bus_width = sdhci_set_bus_width, 226 + .set_clock = spacemit_sdhci_set_clock, 227 + .set_uhs_signaling = spacemit_sdhci_set_uhs_signaling, 228 + }; 229 + 230 + static const struct sdhci_pltfm_data spacemit_sdhci_k1_pdata = { 231 + .ops = &spacemit_sdhci_ops, 232 + .quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK | 233 + SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC | 234 + SDHCI_QUIRK_32BIT_ADMA_SIZE | 235 + SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN | 236 + SDHCI_QUIRK_BROKEN_CARD_DETECTION | 237 + SDHCI_QUIRK_BROKEN_TIMEOUT_VAL, 238 + .quirks2 = SDHCI_QUIRK2_BROKEN_64_BIT_DMA | 239 + SDHCI_QUIRK2_PRESET_VALUE_BROKEN, 240 + }; 241 + 242 + static const struct of_device_id spacemit_sdhci_of_match[] = { 243 + { .compatible = "spacemit,k1-sdhci" }, 244 + { /* sentinel */ } 245 + }; 246 + MODULE_DEVICE_TABLE(of, spacemit_sdhci_of_match); 247 + 248 + static int spacemit_sdhci_probe(struct platform_device *pdev) 249 + { 250 + struct device *dev = &pdev->dev; 251 + struct spacemit_sdhci_host *sdhst; 252 + struct sdhci_pltfm_host *pltfm_host; 253 + struct sdhci_host *host; 254 + struct mmc_host_ops *mops; 255 + int ret; 256 + 257 + host = sdhci_pltfm_init(pdev, &spacemit_sdhci_k1_pdata, sizeof(*sdhst)); 258 + if (IS_ERR(host)) 259 + return PTR_ERR(host); 260 + 261 + pltfm_host = sdhci_priv(host); 262 + 263 + ret = mmc_of_parse(host->mmc); 264 + if (ret) 265 + goto err_pltfm; 266 + 267 + sdhci_get_of_property(pdev); 268 + 269 + if (!(host->mmc->caps2 & MMC_CAP2_NO_MMC)) { 270 + mops = &host->mmc_host_ops; 271 + mops->hs400_prepare_ddr = spacemit_sdhci_pre_select_hs400; 272 + mops->hs400_complete = spacemit_sdhci_post_select_hs400; 273 + mops->hs400_downgrade = spacemit_sdhci_pre_hs400_to_hs200; 274 + mops->hs400_enhanced_strobe = spacemit_sdhci_hs400_enhanced_strobe; 275 + } 276 + 277 + host->mmc->caps |= MMC_CAP_NEED_RSP_BUSY; 278 + 279 + if (spacemit_sdhci_get_clocks(dev, pltfm_host)) 280 + goto err_pltfm; 281 + 282 + ret = sdhci_add_host(host); 283 + if (ret) 284 + goto err_pltfm; 285 + 286 + return 0; 287 + 288 + err_pltfm: 289 + sdhci_pltfm_free(pdev); 290 + return ret; 291 + } 292 + 293 + static struct platform_driver spacemit_sdhci_driver = { 294 + .driver = { 295 + .name = "sdhci-spacemit", 296 + .of_match_table = spacemit_sdhci_of_match, 297 + }, 298 + .probe = spacemit_sdhci_probe, 299 + .remove = sdhci_pltfm_remove, 300 + }; 301 + module_platform_driver(spacemit_sdhci_driver); 302 + 303 + MODULE_DESCRIPTION("SpacemiT SDHCI platform driver"); 304 + MODULE_LICENSE("GPL");
+1 -1
drivers/mmc/host/sdhci-omap.c
··· 1270 1270 mmc->f_max = 48000000; 1271 1271 } 1272 1272 1273 - if (!mmc_can_gpio_ro(mmc)) 1273 + if (!mmc_host_can_gpio_ro(mmc)) 1274 1274 mmc->caps2 |= MMC_CAP2_NO_WRITE_PROTECT; 1275 1275 1276 1276 pltfm_host->clk = devm_clk_get(dev, "fck");
+7 -5
drivers/mmc/host/sdhci.c
··· 158 158 u32 present; 159 159 160 160 if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) || 161 - !mmc_card_is_removable(host->mmc) || mmc_can_gpio_cd(host->mmc)) 161 + !mmc_card_is_removable(host->mmc) || mmc_host_can_gpio_cd(host->mmc)) 162 162 return; 163 163 164 164 if (enable) { ··· 2571 2571 is_readonly = 0; 2572 2572 } else if (host->ops->get_ro) { 2573 2573 is_readonly = host->ops->get_ro(host); 2574 - } else if (mmc_can_gpio_ro(mmc)) { 2574 + } else if (mmc_host_can_gpio_ro(mmc)) { 2575 2575 is_readonly = mmc_gpio_get_ro(mmc); 2576 2576 /* Do not invert twice */ 2577 2577 allow_invert = !(mmc->caps2 & MMC_CAP2_RO_ACTIVE_HIGH); ··· 3744 3744 { 3745 3745 return mmc_card_is_removable(host->mmc) && 3746 3746 !(host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) && 3747 - !mmc_can_gpio_cd(host->mmc); 3747 + !mmc_host_can_gpio_cd(host->mmc); 3748 3748 } 3749 3749 3750 3750 /* ··· 3755 3755 * sdhci_disable_irq_wakeups() since it will be set by 3756 3756 * sdhci_enable_card_detection() or sdhci_init(). 3757 3757 */ 3758 - static bool sdhci_enable_irq_wakeups(struct sdhci_host *host) 3758 + bool sdhci_enable_irq_wakeups(struct sdhci_host *host) 3759 3759 { 3760 3760 u8 mask = SDHCI_WAKE_ON_INSERT | SDHCI_WAKE_ON_REMOVE | 3761 3761 SDHCI_WAKE_ON_INT; ··· 3787 3787 3788 3788 return host->irq_wake_enabled; 3789 3789 } 3790 + EXPORT_SYMBOL_GPL(sdhci_enable_irq_wakeups); 3790 3791 3791 - static void sdhci_disable_irq_wakeups(struct sdhci_host *host) 3792 + void sdhci_disable_irq_wakeups(struct sdhci_host *host) 3792 3793 { 3793 3794 u8 val; 3794 3795 u8 mask = SDHCI_WAKE_ON_INSERT | SDHCI_WAKE_ON_REMOVE ··· 3803 3802 3804 3803 host->irq_wake_enabled = false; 3805 3804 } 3805 + EXPORT_SYMBOL_GPL(sdhci_disable_irq_wakeups); 3806 3806 3807 3807 int sdhci_suspend_host(struct sdhci_host *host) 3808 3808 {
+2
drivers/mmc/host/sdhci.h
··· 875 875 dma_addr_t addr, int len, unsigned int cmd); 876 876 877 877 #ifdef CONFIG_PM 878 + bool sdhci_enable_irq_wakeups(struct sdhci_host *host); 879 + void sdhci_disable_irq_wakeups(struct sdhci_host *host); 878 880 int sdhci_suspend_host(struct sdhci_host *host); 879 881 int sdhci_resume_host(struct sdhci_host *host); 880 882 int sdhci_runtime_suspend_host(struct sdhci_host *host);
+1 -1
drivers/mmc/host/sunplus-mmc.c
··· 791 791 { 792 792 int ret = 0; 793 793 794 - if (mmc_can_gpio_cd(mmc)) 794 + if (mmc_host_can_gpio_cd(mmc)) 795 795 ret = mmc_gpio_get_cd(mmc); 796 796 797 797 if (ret < 0)
+3 -3
drivers/mmc/host/tmio_mmc_core.c
··· 1176 1176 dma_max_mapping_size(&pdev->dev)); 1177 1177 mmc->max_seg_size = mmc->max_req_size; 1178 1178 1179 - if (mmc_can_gpio_ro(mmc)) 1179 + if (mmc_host_can_gpio_ro(mmc)) 1180 1180 _host->ops.get_ro = mmc_gpio_get_ro; 1181 1181 1182 - if (mmc_can_gpio_cd(mmc)) 1182 + if (mmc_host_can_gpio_cd(mmc)) 1183 1183 _host->ops.get_cd = mmc_gpio_get_cd; 1184 1184 1185 1185 /* must be set before tmio_mmc_reset() */ 1186 - _host->native_hotplug = !(mmc_can_gpio_cd(mmc) || 1186 + _host->native_hotplug = !(mmc_host_can_gpio_cd(mmc) || 1187 1187 mmc->caps & MMC_CAP_NEEDS_POLL || 1188 1188 !mmc_card_is_removable(mmc)); 1189 1189
+1
include/linux/mmc/card.h
··· 329 329 #define MMC_QUIRK_BROKEN_SD_CACHE (1<<15) /* Disable broken SD cache support */ 330 330 #define MMC_QUIRK_BROKEN_CACHE_FLUSH (1<<16) /* Don't flush cache until the write has occurred */ 331 331 #define MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY (1<<17) /* Disable broken SD poweroff notify support */ 332 + #define MMC_QUIRK_NO_UHS_DDR50_TUNING (1<<18) /* Disable DDR50 tuning */ 332 333 333 334 bool written_flag; /* Indicates eMMC has been written since power on */ 334 335 bool reenable_cmdq; /* Re-enable Command Queue */
+2 -2
include/linux/mmc/slot-gpio.h
··· 24 24 int mmc_gpiod_set_cd_config(struct mmc_host *host, unsigned long config); 25 25 int mmc_gpio_set_cd_wake(struct mmc_host *host, bool on); 26 26 void mmc_gpiod_request_cd_irq(struct mmc_host *host); 27 - bool mmc_can_gpio_cd(struct mmc_host *host); 28 - bool mmc_can_gpio_ro(struct mmc_host *host); 27 + bool mmc_host_can_gpio_cd(struct mmc_host *host); 28 + bool mmc_host_can_gpio_ro(struct mmc_host *host); 29 29 30 30 #endif