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

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

Pull MMC updates from Ulf Hansson:
"MMC core:
- Improve RPMB frame handling code
- Add support for a new max-sd-hs-hz DT property to limit frequency
- Add support to manage regulator-under-voltage events
- Support regulator-under-voltage for eMMC to mitigate data
corruptions
- Add mmc_read_tuning() to allow a host to validate its tuning
sequence
- Add some helpers to align checks for CMD23 support
- Read the CCCR register for SDIO over SPI rather than the
unsupported CMD7

MMC host:
- Add COMPILE_TEST option for a couple of drivers
- Convert drivers to use the modern PM macros
- dw_mmc-exynos: Enable support for the Exynos8890 variant
- mmc_spi: Don't use crc ack during multiple block read
- renesas_sdhi: Enable 64-bit polling mode for R-Car gen3 and
RZ/G2L SoCs
- rtsx_usb: Add support for over-current-protection
- sdhci-cadence: Add support for multi-block read gap tuning
- sdhci-msm:
- Add support for tuning for SDR50 mode for SD cards
- Enable support for the Lemans variant
- sdhci-pci: Disable SD card clock before update for a few
Intel platforms
- sdhci-pxav3: Add support for UHS pinctrl settings
- tmio: Add 64-bit read/write support in polling mode

MEMSTICK:
- Convert to use timeouts to prevent indefinite waiting
- rtsx_usb: Add support for over-current-protection"

* tag 'mmc-v6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: (77 commits)
dt-bindings: mmc: samsung,exynos-dw-mshc: add specific compatible for exynos8890
mmc: select REGMAP_MMIO with MMC_LOONGSON2
mmc: add COMPILE_TEST to multiple drivers
mmc: core: Improve RPMB frame handling code
mmc: core: Fix variable shadowing in mmc_route_rpmb_frames()
mmc: core: Parse and use the new max-sd-hs-hz DT property
dt-bindings: mmc: controller: Add max-sd-hs-hz property
mmc: sdhci-msm: Enable tuning for SDR50 mode for SD card
dt-bindings: mmc: sdhci-msm: Document the Lemans compatible
mmc: sh_mmcif: Remove dummy PM resume callback
dt-bindings: mmc: sdhci-pxa: Add minItems to pinctrl-names
mmc: sdio: Drop dev_pm_domain_detach() call
mmc: dw_mmc-rockchip: use modern PM macros
mmc: dw_mmc-pci: use modern PM macros
mmc: dw_mmc-k3: use modern PM macros
mmc: dw_mmc: exynos: use modern PM macros
mmc: via-sdmmc: use modern PM macros
mmc: sdhci-msm: use modern PM macros
mmc: mtk-sd: use modern PM macros
mmc: wmt-sdmmc: use modern PM macros
...

+754 -364
+1
Documentation/devicetree/bindings/mmc/fsl,esdhc.yaml
··· 90 90 91 91 allOf: 92 92 - $ref: sdhci-common.yaml# 93 + - $ref: mmc-controller-common.yaml# 93 94 94 95 unevaluatedProperties: false 95 96
+8
Documentation/devicetree/bindings/mmc/mmc-controller-common.yaml
··· 93 93 minimum: 400000 94 94 maximum: 384000000 95 95 96 + max-sd-hs-hz: 97 + description: | 98 + Maximum frequency (in Hz) to be used for SD cards operating in 99 + High-Speed (HS) mode. 100 + minimum: 400000 101 + maximum: 50000000 102 + default: 50000000 103 + 96 104 disable-wp: 97 105 $ref: /schemas/types.yaml#/definitions/flag 98 106 description:
+1
Documentation/devicetree/bindings/mmc/samsung,exynos-dw-mshc.yaml
··· 31 31 - samsung,exynos5433-dw-mshc-smu 32 32 - samsung,exynos7885-dw-mshc-smu 33 33 - samsung,exynos850-dw-mshc-smu 34 + - samsung,exynos8890-dw-mshc-smu 34 35 - samsung,exynos8895-dw-mshc-smu 35 36 - const: samsung,exynos7-dw-mshc-smu 36 37
+1
Documentation/devicetree/bindings/mmc/sdhci-msm.yaml
··· 48 48 - qcom,qcs615-sdhci 49 49 - qcom,qcs8300-sdhci 50 50 - qcom,qdu1000-sdhci 51 + - qcom,sa8775p-sdhci 51 52 - qcom,sar2130p-sdhci 52 53 - qcom,sc7180-sdhci 53 54 - qcom,sc7280-sdhci
+28 -3
Documentation/devicetree/bindings/mmc/sdhci-pxa.yaml
··· 44 44 items: 45 45 - const: default 46 46 - const: state_cmd_gpio 47 - pinctrl-0: 48 - description: 49 - Should contain default pinctrl. 47 + minItems: 1 48 + 50 49 pinctrl-1: 51 50 description: 52 51 Should switch CMD pin to GPIO mode as a high output. 52 + - if: 53 + properties: 54 + compatible: 55 + contains: 56 + const: mrvl,pxav3-mmc 57 + then: 58 + properties: 59 + pinctrl-names: 60 + description: 61 + Optional for increasing stability of the controller at fast bus clocks. 62 + items: 63 + - const: default 64 + - const: state_uhs 65 + minItems: 1 66 + 67 + pinctrl-1: 68 + description: 69 + Should switch the drive strength of the data pins to high. 53 70 54 71 properties: 55 72 compatible: ··· 98 81 items: 99 82 - const: io 100 83 - const: core 84 + 85 + pinctrl-names: true 86 + 87 + pinctrl-0: 88 + description: 89 + Should contain default pinctrl. 90 + 91 + pinctrl-1: true 101 92 102 93 mrvl,clk-delay-cycles: 103 94 description: Specify a number of cycles to delay for tuning.
+6 -2
drivers/memstick/core/memstick.c
··· 370 370 { 371 371 card->next_request = h_memstick_set_rw_addr; 372 372 memstick_new_req(card->host); 373 - wait_for_completion(&card->mrq_complete); 373 + if (!wait_for_completion_timeout(&card->mrq_complete, 374 + msecs_to_jiffies(500))) 375 + card->current_mrq.error = -ETIMEDOUT; 374 376 375 377 return card->current_mrq.error; 376 378 } ··· 406 404 407 405 card->next_request = h_memstick_read_dev_id; 408 406 memstick_new_req(host); 409 - wait_for_completion(&card->mrq_complete); 407 + if (!wait_for_completion_timeout(&card->mrq_complete, 408 + msecs_to_jiffies(500))) 409 + card->current_mrq.error = -ETIMEDOUT; 410 410 411 411 if (card->current_mrq.error) 412 412 goto err_out;
+4 -1
drivers/memstick/host/rtsx_usb_ms.c
··· 216 216 217 217 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_CLK_EN, MS_CLK_EN, 0); 218 218 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_OE, MS_OUTPUT_EN, 0); 219 - 219 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PWR_CTL, 220 + POWER_MASK, POWER_OFF); 221 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PWR_CTL, 222 + POWER_MASK | LDO3318_PWR_MASK, POWER_OFF | LDO_SUSPEND); 220 223 err = rtsx_usb_send_cmd(ucr, MODE_C, 100); 221 224 if (err < 0) 222 225 return err;
+7
drivers/misc/cardreader/rtsx_usb.c
··· 552 552 ret = rtsx_usb_send_cmd(ucr, MODE_C, 100); 553 553 if (ret) 554 554 return ret; 555 + /* config OCP */ 556 + rtsx_usb_write_register(ucr, OCPCTL, MS_OCP_DETECT_EN, MS_OCP_DETECT_EN); 557 + rtsx_usb_write_register(ucr, OCPPARA1, 0xF0, 0x50); 558 + rtsx_usb_write_register(ucr, OCPPARA2, 0x7, 0x3); 555 559 556 560 /* config non-crystal mode */ 557 561 rtsx_usb_read_register(ucr, CFG_MODE, &val); ··· 726 722 if (val & (SD_CD | MS_CD)) { 727 723 device_for_each_child(&intf->dev, NULL, rtsx_usb_resume_child); 728 724 return -EAGAIN; 725 + } else { 726 + /* if the card does not exists, clear OCP status */ 727 + rtsx_usb_write_register(ucr, OCPCTL, MS_OCP_CLEAR, MS_OCP_CLEAR); 729 728 } 730 729 } else { 731 730 /* There is an ongoing operation*/
+19 -27
drivers/mmc/core/block.c
··· 121 121 #define RPMB_READ_DATA 0x4 /* Read data from RPMB partition */ 122 122 #define RPMB_RESULT_READ 0x5 /* Read result request (Internal) */ 123 123 124 + #define RPMB_FRAME_SIZE sizeof(struct rpmb_frame) 125 + #define CHECK_SIZE_NEQ(val) ((val) != sizeof(struct rpmb_frame)) 126 + #define CHECK_SIZE_ALIGNED(val) IS_ALIGNED((val), sizeof(struct rpmb_frame)) 127 + 124 128 static DEFINE_MUTEX(block_mutex); 125 129 126 130 /* ··· 1772 1768 * these, while retaining features like reliable writes. 1773 1769 */ 1774 1770 if ((md->flags & MMC_BLK_CMD23) && mmc_op_multi(brq->cmd.opcode) && 1775 - (do_rel_wr || !(card->quirks & MMC_QUIRK_BLK_NO_CMD23) || 1776 - do_data_tag)) { 1771 + (do_rel_wr || !mmc_card_blk_no_cmd23(card) || do_data_tag)) { 1777 1772 brq->sbc.opcode = MMC_SET_BLOCK_COUNT; 1778 1773 brq->sbc.arg = brq->data.blocks | 1779 1774 (do_rel_wr ? (1 << 31) : 0) | ··· 2621 2618 */ 2622 2619 md->read_only = mmc_blk_readonly(card); 2623 2620 2624 - if (mmc_host_can_cmd23(card->host)) { 2625 - if ((mmc_card_mmc(card) && 2626 - card->csd.mmca_vsn >= CSD_SPEC_VER_3) || 2627 - (mmc_card_sd(card) && !mmc_card_ult_capacity(card) && 2628 - card->scr.cmds & SD_SCR_CMD23_SUPPORT)) 2629 - md->flags |= MMC_BLK_CMD23; 2630 - } 2621 + if (mmc_host_can_cmd23(card->host) && mmc_card_can_cmd23(card)) 2622 + md->flags |= MMC_BLK_CMD23; 2631 2623 2632 2624 if (md->flags & MMC_BLK_CMD23 && 2633 2625 ((card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) || ··· 2862 2864 * The size of an RPMB frame must match what's expected by the 2863 2865 * hardware. 2864 2866 */ 2865 - BUILD_BUG_ON(sizeof(struct rpmb_frame) != 512); 2867 + static_assert(!CHECK_SIZE_NEQ(512), "RPMB frame size must be 512 bytes"); 2866 2868 2867 2869 idata->ic.opcode = opcode; 2868 2870 idata->ic.flags = MMC_RSP_R1 | MMC_CMD_ADTC; 2869 2871 idata->ic.write_flag = write_flag; 2870 - idata->ic.blksz = sizeof(struct rpmb_frame); 2872 + idata->ic.blksz = RPMB_FRAME_SIZE; 2871 2873 idata->ic.blocks = buf_bytes / idata->ic.blksz; 2872 2874 idata->buf = buf; 2873 2875 idata->buf_bytes = buf_bytes; ··· 2891 2893 if (IS_ERR(md->queue.card)) 2892 2894 return PTR_ERR(md->queue.card); 2893 2895 2894 - if (req_len < sizeof(*frm)) 2896 + if (req_len < RPMB_FRAME_SIZE) 2895 2897 return -EINVAL; 2896 2898 2897 2899 req_type = be16_to_cpu(frm->req_resp); 2898 2900 switch (req_type) { 2899 2901 case RPMB_PROGRAM_KEY: 2900 - if (req_len != sizeof(struct rpmb_frame) || 2901 - resp_len != sizeof(struct rpmb_frame)) 2902 + if (CHECK_SIZE_NEQ(req_len) || CHECK_SIZE_NEQ(resp_len)) 2902 2903 return -EINVAL; 2903 2904 write = true; 2904 2905 break; 2905 2906 case RPMB_GET_WRITE_COUNTER: 2906 - if (req_len != sizeof(struct rpmb_frame) || 2907 - resp_len != sizeof(struct rpmb_frame)) 2907 + if (CHECK_SIZE_NEQ(req_len) || CHECK_SIZE_NEQ(resp_len)) 2908 2908 return -EINVAL; 2909 2909 write = false; 2910 2910 break; 2911 2911 case RPMB_WRITE_DATA: 2912 - if (req_len % sizeof(struct rpmb_frame) || 2913 - resp_len != sizeof(struct rpmb_frame)) 2912 + if (!CHECK_SIZE_ALIGNED(req_len) || CHECK_SIZE_NEQ(resp_len)) 2914 2913 return -EINVAL; 2915 2914 write = true; 2916 2915 break; 2917 2916 case RPMB_READ_DATA: 2918 - if (req_len != sizeof(struct rpmb_frame) || 2919 - resp_len % sizeof(struct rpmb_frame)) 2917 + if (CHECK_SIZE_NEQ(req_len) || !CHECK_SIZE_ALIGNED(resp_len)) 2920 2918 return -EINVAL; 2921 2919 write = false; 2922 2920 break; ··· 2920 2926 return -EINVAL; 2921 2927 } 2922 2928 2923 - if (write) 2924 - cmd_count = 3; 2925 - else 2926 - cmd_count = 2; 2929 + /* Write operations require 3 commands, read operations require 2 */ 2930 + cmd_count = write ? 3 : 2; 2927 2931 2928 2932 idata = alloc_idata(rpmb, cmd_count); 2929 2933 if (!idata) 2930 2934 return -ENOMEM; 2931 2935 2932 2936 if (write) { 2933 - struct rpmb_frame *frm = (struct rpmb_frame *)resp; 2937 + struct rpmb_frame *resp_frm = (struct rpmb_frame *)resp; 2934 2938 2935 2939 /* Send write request frame(s) */ 2936 2940 set_idata(idata[0], MMC_WRITE_MULTIPLE_BLOCK, 2937 2941 1 | MMC_CMD23_ARG_REL_WR, req, req_len); 2938 2942 2939 2943 /* Send result request frame */ 2940 - memset(frm, 0, sizeof(*frm)); 2941 - frm->req_resp = cpu_to_be16(RPMB_RESULT_READ); 2944 + memset(resp_frm, 0, RPMB_FRAME_SIZE); 2945 + resp_frm->req_resp = cpu_to_be16(RPMB_RESULT_READ); 2942 2946 set_idata(idata[1], MMC_WRITE_MULTIPLE_BLOCK, 1, resp, 2943 2947 resp_len); 2944 2948
+12
drivers/mmc/core/bus.c
··· 19 19 20 20 #include <linux/mmc/card.h> 21 21 #include <linux/mmc/host.h> 22 + #include <linux/mmc/mmc.h> 22 23 23 24 #include "core.h" 24 25 #include "card.h" ··· 384 383 385 384 mmc_card_set_present(card); 386 385 386 + /* 387 + * Register for undervoltage notification if the card supports 388 + * power-off notification, enabling emergency shutdowns. 389 + */ 390 + if (mmc_card_mmc(card) && 391 + card->ext_csd.power_off_notification == EXT_CSD_POWER_ON) 392 + mmc_regulator_register_undervoltage_notifier(card->host); 393 + 387 394 return 0; 388 395 } 389 396 ··· 402 393 void mmc_remove_card(struct mmc_card *card) 403 394 { 404 395 struct mmc_host *host = card->host; 396 + 397 + if (mmc_card_present(card)) 398 + mmc_regulator_unregister_undervoltage_notifier(host); 405 399 406 400 mmc_remove_card_debugfs(card); 407 401
+7 -2
drivers/mmc/core/card.h
··· 245 245 return c->quirks & MMC_QUIRK_BLKSZ_FOR_BYTE_MODE; 246 246 } 247 247 248 + static inline int mmc_card_nonstd_func_interface(const struct mmc_card *c) 249 + { 250 + return c->quirks & MMC_QUIRK_NONSTD_FUNC_IF; 251 + } 252 + 248 253 static inline int mmc_card_disable_cd(const struct mmc_card *c) 249 254 { 250 255 return c->quirks & MMC_QUIRK_DISABLE_CD; 251 256 } 252 257 253 - static inline int mmc_card_nonstd_func_interface(const struct mmc_card *c) 258 + static inline int mmc_card_blk_no_cmd23(const struct mmc_card *c) 254 259 { 255 - return c->quirks & MMC_QUIRK_NONSTD_FUNC_IF; 260 + return c->quirks & MMC_QUIRK_BLK_NO_CMD23; 256 261 } 257 262 258 263 static inline int mmc_card_broken_byte_mode_512(const struct mmc_card *c)
+32
drivers/mmc/core/core.c
··· 1398 1398 mmc_power_up(host, ocr); 1399 1399 } 1400 1400 1401 + /** 1402 + * mmc_handle_undervoltage - Handle an undervoltage event on the MMC bus 1403 + * @host: The MMC host that detected the undervoltage condition 1404 + * 1405 + * This function is called when an undervoltage event is detected on one of 1406 + * the MMC regulators. 1407 + * 1408 + * Returns: 0 on success or a negative error code on failure. 1409 + */ 1410 + int mmc_handle_undervoltage(struct mmc_host *host) 1411 + { 1412 + /* Stop the host to prevent races with card removal */ 1413 + __mmc_stop_host(host); 1414 + 1415 + if (!host->bus_ops || !host->bus_ops->handle_undervoltage) 1416 + return 0; 1417 + 1418 + dev_warn(mmc_dev(host), "%s: Undervoltage detected, initiating emergency stop\n", 1419 + mmc_hostname(host)); 1420 + 1421 + return host->bus_ops->handle_undervoltage(host); 1422 + } 1423 + 1401 1424 /* 1402 1425 * Assign a mmc bus handler to a host. Only one bus handler may control a 1403 1426 * host at any given time. ··· 1897 1874 !(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN)); 1898 1875 } 1899 1876 EXPORT_SYMBOL(mmc_card_can_secure_erase_trim); 1877 + 1878 + bool mmc_card_can_cmd23(struct mmc_card *card) 1879 + { 1880 + return ((mmc_card_mmc(card) && 1881 + card->csd.mmca_vsn >= CSD_SPEC_VER_3) || 1882 + (mmc_card_sd(card) && !mmc_card_ult_capacity(card) && 1883 + card->scr.cmds & SD_SCR_CMD23_SUPPORT)); 1884 + } 1885 + EXPORT_SYMBOL(mmc_card_can_cmd23); 1900 1886 1901 1887 int mmc_erase_group_aligned(struct mmc_card *card, sector_t from, 1902 1888 unsigned int nr)
+6
drivers/mmc/core/core.h
··· 31 31 int (*sw_reset)(struct mmc_host *); 32 32 bool (*cache_enabled)(struct mmc_host *); 33 33 int (*flush_cache)(struct mmc_host *); 34 + int (*handle_undervoltage)(struct mmc_host *host); 34 35 }; 35 36 36 37 void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops); ··· 60 59 void mmc_power_cycle(struct mmc_host *host, u32 ocr); 61 60 void mmc_set_initial_state(struct mmc_host *host); 62 61 u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max); 62 + int mmc_handle_undervoltage(struct mmc_host *host); 63 + void mmc_regulator_register_undervoltage_notifier(struct mmc_host *host); 64 + void mmc_regulator_unregister_undervoltage_notifier(struct mmc_host *host); 65 + void mmc_undervoltage_workfn(struct work_struct *work); 63 66 64 67 static inline void mmc_delay(unsigned int ms) 65 68 { ··· 128 123 bool mmc_card_can_discard(struct mmc_card *card); 129 124 bool mmc_card_can_sanitize(struct mmc_card *card); 130 125 bool mmc_card_can_secure_erase_trim(struct mmc_card *card); 126 + bool mmc_card_can_cmd23(struct mmc_card *card); 131 127 int mmc_erase_group_aligned(struct mmc_card *card, sector_t from, unsigned int nr); 132 128 unsigned int mmc_calc_max_discard(struct mmc_card *card); 133 129
+4
drivers/mmc/core/host.c
··· 302 302 /* f_max is obtained from the optional "max-frequency" property */ 303 303 device_property_read_u32(dev, "max-frequency", &host->f_max); 304 304 305 + device_property_read_u32(dev, "max-sd-hs-hz", &host->max_sd_hs_hz); 306 + 305 307 /* 306 308 * Configure CD and WP pins. They are both by default active low to 307 309 * match the SDHCI spec. If GPIOs are provided for CD and / or WP, the ··· 565 563 INIT_DELAYED_WORK(&host->detect, mmc_rescan); 566 564 INIT_WORK(&host->sdio_irq_work, sdio_irq_work); 567 565 timer_setup(&host->retune_timer, mmc_retune_timer, 0); 566 + 567 + INIT_WORK(&host->supply.uv_work, mmc_undervoltage_workfn); 568 568 569 569 /* 570 570 * By default, hosts do not support SGIO or large requests.
+67 -3
drivers/mmc/core/mmc.c
··· 36 36 enum mmc_poweroff_type { 37 37 MMC_POWEROFF_SUSPEND, 38 38 MMC_POWEROFF_SHUTDOWN, 39 + MMC_POWEROFF_UNDERVOLTAGE, 39 40 MMC_POWEROFF_UNBIND, 40 41 }; 41 42 ··· 2133 2132 if (mmc_card_suspended(host->card)) 2134 2133 goto out; 2135 2134 2136 - err = _mmc_flush_cache(host); 2137 - if (err) 2138 - goto out; 2135 + /* 2136 + * For the undervoltage case, we care more about device integrity. 2137 + * Avoid cache flush and notify the device to power off quickly. 2138 + */ 2139 + if (pm_type != MMC_POWEROFF_UNDERVOLTAGE) { 2140 + err = _mmc_flush_cache(host); 2141 + if (err) 2142 + goto out; 2143 + } 2139 2144 2140 2145 if (mmc_card_can_poweroff_notify(host->card) && 2141 2146 mmc_host_can_poweroff_notify(host, pm_type)) ··· 2218 2211 static int mmc_shutdown(struct mmc_host *host) 2219 2212 { 2220 2213 int err = 0; 2214 + 2215 + /* 2216 + * In case of undervoltage, the card will be powered off (removed) by 2217 + * _mmc_handle_undervoltage() 2218 + */ 2219 + if (mmc_card_removed(host->card)) 2220 + return 0; 2221 2221 2222 2222 /* 2223 2223 * If the card remains suspended at this point and it was done by using ··· 2316 2302 return mmc_init_card(host, card->ocr, card); 2317 2303 } 2318 2304 2305 + /** 2306 + * _mmc_handle_undervoltage - Handle an undervoltage event for MMC/eMMC devices 2307 + * @host: MMC host structure 2308 + * 2309 + * This function is triggered when an undervoltage condition is detected. 2310 + * It attempts to transition the device into a low-power or safe state to 2311 + * prevent data corruption. 2312 + * 2313 + * Steps performed: 2314 + * - Perform an emergency suspend using EXT_CSD_POWER_OFF_SHORT if possible. 2315 + * - If power-off notify is not supported, fallback mechanisms like sleep or 2316 + * deselecting the card are attempted. 2317 + * - Cache flushing is skipped to reduce execution time. 2318 + * - Mark the card as removed to prevent further interactions after 2319 + * undervoltage. 2320 + * 2321 + * Note: This function does not handle host claiming or releasing. The caller 2322 + * must ensure that the host is properly claimed before calling this 2323 + * function and released afterward. 2324 + * 2325 + * Returns: 0 on success, or a negative error code if any step fails. 2326 + */ 2327 + static int _mmc_handle_undervoltage(struct mmc_host *host) 2328 + { 2329 + struct mmc_card *card = host->card; 2330 + int err; 2331 + 2332 + /* 2333 + * Perform an emergency suspend to power off the eMMC quickly. 2334 + * This ensures the device enters a safe state before power is lost. 2335 + * We first attempt EXT_CSD_POWER_OFF_SHORT, but if power-off notify 2336 + * is not supported, we fall back to sleep mode or deselecting the card. 2337 + * Cache flushing is skipped to minimize delay. 2338 + */ 2339 + err = _mmc_suspend(host, MMC_POWEROFF_UNDERVOLTAGE); 2340 + if (err) 2341 + pr_err("%s: undervoltage suspend failed: %pe\n", 2342 + mmc_hostname(host), ERR_PTR(err)); 2343 + 2344 + /* 2345 + * Mark the card as removed to prevent further operations. 2346 + * This ensures the system does not attempt to access the device 2347 + * after an undervoltage event, avoiding potential corruption. 2348 + */ 2349 + mmc_card_set_removed(card); 2350 + 2351 + return err; 2352 + } 2353 + 2319 2354 static const struct mmc_bus_ops mmc_ops = { 2320 2355 .remove = mmc_remove, 2321 2356 .detect = mmc_detect, ··· 2377 2314 .hw_reset = _mmc_hw_reset, 2378 2315 .cache_enabled = _mmc_cache_enabled, 2379 2316 .flush_cache = _mmc_flush_cache, 2317 + .handle_undervoltage = _mmc_handle_undervoltage, 2380 2318 }; 2381 2319 2382 2320 /*
+72
drivers/mmc/core/mmc_ops.c
··· 1077 1077 return err; 1078 1078 } 1079 1079 EXPORT_SYMBOL_GPL(mmc_sanitize); 1080 + 1081 + /** 1082 + * mmc_read_tuning() - read data blocks from the mmc 1083 + * @host: mmc host doing the read 1084 + * @blksz: data block size 1085 + * @blocks: number of blocks to read 1086 + * 1087 + * Read one or more blocks of data from the beginning of the mmc. This is a 1088 + * low-level helper for tuning operation. It is assumed that CMD23 can be used 1089 + * for multi-block read if the host supports it. 1090 + * 1091 + * Note: Allocate and free a temporary buffer to store the data read. The data 1092 + * is not available outside of the function, only the status of the read 1093 + * operation. 1094 + * 1095 + * Return: 0 in case of success, otherwise -EIO / -ENOMEM / -E2BIG 1096 + */ 1097 + int mmc_read_tuning(struct mmc_host *host, unsigned int blksz, unsigned int blocks) 1098 + { 1099 + struct mmc_request mrq = {}; 1100 + struct mmc_command sbc = {}; 1101 + struct mmc_command cmd = {}; 1102 + struct mmc_command stop = {}; 1103 + struct mmc_data data = {}; 1104 + struct scatterlist sg; 1105 + void *buf; 1106 + unsigned int len; 1107 + 1108 + if (blocks > 1) { 1109 + if (mmc_host_can_cmd23(host)) { 1110 + mrq.sbc = &sbc; 1111 + sbc.opcode = MMC_SET_BLOCK_COUNT; 1112 + sbc.arg = blocks; 1113 + sbc.flags = MMC_RSP_R1 | MMC_CMD_AC; 1114 + } 1115 + cmd.opcode = MMC_READ_MULTIPLE_BLOCK; 1116 + mrq.stop = &stop; 1117 + stop.opcode = MMC_STOP_TRANSMISSION; 1118 + stop.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; 1119 + } else { 1120 + cmd.opcode = MMC_READ_SINGLE_BLOCK; 1121 + } 1122 + 1123 + mrq.cmd = &cmd; 1124 + cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC; 1125 + 1126 + mrq.data = &data; 1127 + data.flags = MMC_DATA_READ; 1128 + data.blksz = blksz; 1129 + data.blocks = blocks; 1130 + data.blk_addr = 0; 1131 + data.sg = &sg; 1132 + data.sg_len = 1; 1133 + data.timeout_ns = 1000000000; 1134 + 1135 + if (check_mul_overflow(blksz, blocks, &len)) 1136 + return -E2BIG; 1137 + buf = kmalloc(len, GFP_KERNEL); 1138 + if (!buf) 1139 + return -ENOMEM; 1140 + 1141 + sg_init_one(&sg, buf, len); 1142 + 1143 + mmc_wait_for_req(host, &mrq); 1144 + kfree(buf); 1145 + 1146 + if (sbc.error || cmd.error || data.error) 1147 + return -EIO; 1148 + 1149 + return 0; 1150 + } 1151 + EXPORT_SYMBOL_GPL(mmc_read_tuning);
+2 -8
drivers/mmc/core/mmc_test.c
··· 180 180 return mmc_set_blocklen(test->card, size); 181 181 } 182 182 183 - static bool mmc_test_card_cmd23(struct mmc_card *card) 184 - { 185 - return mmc_card_mmc(card) || 186 - (mmc_card_sd(card) && card->scr.cmds & SD_SCR_CMD23_SUPPORT); 187 - } 188 - 189 183 static void mmc_test_prepare_sbc(struct mmc_test_card *test, 190 184 struct mmc_request *mrq, unsigned int blocks) 191 185 { 192 186 struct mmc_card *card = test->card; 193 187 194 188 if (!mrq->sbc || !mmc_host_can_cmd23(card->host) || 195 - !mmc_test_card_cmd23(card) || !mmc_op_multi(mrq->cmd->opcode) || 196 - (card->quirks & MMC_QUIRK_BLK_NO_CMD23)) { 189 + !mmc_card_can_cmd23(card) || !mmc_op_multi(mrq->cmd->opcode) || 190 + mmc_card_blk_no_cmd23(card)) { 197 191 mrq->sbc = NULL; 198 192 return; 199 193 }
+77
drivers/mmc/core/regulator.c
··· 7 7 #include <linux/err.h> 8 8 #include <linux/log2.h> 9 9 #include <linux/regulator/consumer.h> 10 + #include <linux/workqueue.h> 10 11 11 12 #include <linux/mmc/host.h> 12 13 ··· 262 261 } 263 262 264 263 #endif /* CONFIG_REGULATOR */ 264 + 265 + /* To be called from a high-priority workqueue */ 266 + void mmc_undervoltage_workfn(struct work_struct *work) 267 + { 268 + struct mmc_supply *supply; 269 + struct mmc_host *host; 270 + 271 + supply = container_of(work, struct mmc_supply, uv_work); 272 + host = container_of(supply, struct mmc_host, supply); 273 + 274 + mmc_handle_undervoltage(host); 275 + } 276 + 277 + static int mmc_handle_regulator_event(struct notifier_block *nb, 278 + unsigned long event, void *data) 279 + { 280 + struct mmc_supply *supply = container_of(nb, struct mmc_supply, 281 + vmmc_nb); 282 + struct mmc_host *host = container_of(supply, struct mmc_host, supply); 283 + unsigned long flags; 284 + 285 + switch (event) { 286 + case REGULATOR_EVENT_UNDER_VOLTAGE: 287 + spin_lock_irqsave(&host->lock, flags); 288 + if (host->undervoltage) { 289 + spin_unlock_irqrestore(&host->lock, flags); 290 + return NOTIFY_OK; 291 + } 292 + 293 + host->undervoltage = true; 294 + spin_unlock_irqrestore(&host->lock, flags); 295 + 296 + queue_work(system_highpri_wq, &host->supply.uv_work); 297 + break; 298 + default: 299 + return NOTIFY_DONE; 300 + } 301 + 302 + return NOTIFY_OK; 303 + } 304 + 305 + /** 306 + * mmc_regulator_register_undervoltage_notifier - Register for undervoltage 307 + * events 308 + * @host: MMC host 309 + * 310 + * To be called by a bus driver when a card supporting graceful shutdown 311 + * is attached. 312 + */ 313 + void mmc_regulator_register_undervoltage_notifier(struct mmc_host *host) 314 + { 315 + int ret; 316 + 317 + if (IS_ERR_OR_NULL(host->supply.vmmc)) 318 + return; 319 + 320 + host->supply.vmmc_nb.notifier_call = mmc_handle_regulator_event; 321 + ret = regulator_register_notifier(host->supply.vmmc, 322 + &host->supply.vmmc_nb); 323 + if (ret) 324 + dev_warn(mmc_dev(host), "Failed to register vmmc notifier: %d\n", ret); 325 + } 326 + 327 + /** 328 + * mmc_regulator_unregister_undervoltage_notifier - Unregister undervoltage 329 + * notifier 330 + * @host: MMC host 331 + */ 332 + void mmc_regulator_unregister_undervoltage_notifier(struct mmc_host *host) 333 + { 334 + if (IS_ERR_OR_NULL(host->supply.vmmc)) 335 + return; 336 + 337 + regulator_unregister_notifier(host->supply.vmmc, &host->supply.vmmc_nb); 338 + cancel_work_sync(&host->supply.uv_work); 339 + } 265 340 266 341 /** 267 342 * mmc_regulator_get_supply - try to get VMMC and VQMMC regulators for a host
+1 -1
drivers/mmc/core/sd.c
··· 359 359 } 360 360 361 361 if (status[13] & SD_MODE_HIGH_SPEED) 362 - card->sw_caps.hs_max_dtr = HIGH_SPEED_MAX_DTR; 362 + card->sw_caps.hs_max_dtr = card->host->max_sd_hs_hz ?: HIGH_SPEED_MAX_DTR; 363 363 364 364 if (card->scr.sda_spec3) { 365 365 card->sw_caps.sd3_bus_mode = status[13];
+5 -1
drivers/mmc/core/sdio.c
··· 945 945 */ 946 946 static int mmc_sdio_alive(struct mmc_host *host) 947 947 { 948 - return mmc_select_card(host->card); 948 + if (!mmc_host_is_spi(host)) 949 + return mmc_select_card(host->card); 950 + else 951 + return mmc_io_rw_direct(host->card, 0, 0, SDIO_CCCR_CCCR, 0, 952 + NULL); 949 953 } 950 954 951 955 /*
-3
drivers/mmc/core/sdio_bus.c
··· 200 200 atomic_dec(&func->card->sdio_funcs_probed); 201 201 if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) 202 202 pm_runtime_put_noidle(dev); 203 - dev_pm_domain_detach(dev, false); 204 203 return ret; 205 204 } 206 205 ··· 230 231 /* Then undo the runtime PM settings in sdio_bus_probe() */ 231 232 if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) 232 233 pm_runtime_put_sync(dev); 233 - 234 - dev_pm_domain_detach(dev, false); 235 234 } 236 235 237 236 static const struct dev_pm_ops sdio_bus_pm_ops = {
+8 -6
drivers/mmc/host/Kconfig
··· 56 56 57 57 config MMC_PXA 58 58 tristate "Intel PXA25x/26x/27x Multimedia Card Interface support" 59 - depends on ARCH_PXA 59 + depends on ARCH_PXA || COMPILE_TEST 60 60 help 61 61 This selects the Intel(R) PXA(R) Multimedia card Interface. 62 62 If you have a PXA(R) platform with a Multimedia Card slot, ··· 359 359 depends on PLAT_SAMSUNG || ARCH_S5PV210 || ARCH_EXYNOS || COMPILE_TEST 360 360 help 361 361 This selects the Secure Digital Host Controller Interface (SDHCI) 362 - often referrered to as the HSMMC block in some of the Samsung 362 + often referred to as the HSMMC block in some of the Samsung 363 363 S3C6410, S5Pv210 and Exynos (Exynso4210, Exynos4412) SoCs. 364 364 365 365 If you have a controller with this interface (thereforeyou build for ··· 401 401 depends on OF 402 402 help 403 403 This selects the Secure Digital Host Controller Interface (SDHCI) 404 - often referrered to as the HSMMC block in some of the ST SPEAR range 404 + often referred to as the HSMMC block in some of the ST SPEAR range 405 405 of SoC 406 406 407 407 If you have a controller with this interface, say Y or M here. ··· 608 608 609 609 config MMC_MXC 610 610 tristate "Freescale i.MX21/27/31 or MPC512x Multimedia Card support" 611 - depends on ARCH_MXC || PPC_MPC512x 611 + depends on ARCH_MXC || PPC_MPC512x || COMPILE_TEST 612 612 help 613 613 This selects the Freescale i.MX21, i.MX27, i.MX31 or MPC512x 614 614 Multimedia Card Interface. If you have an i.MX or MPC512x platform ··· 866 866 867 867 config MMC_DW_ROCKCHIP 868 868 tristate "Rockchip specific extensions for Synopsys DW Memory Card Interface" 869 - depends on MMC_DW && ARCH_ROCKCHIP 869 + depends on MMC_DW 870 + depends on ARCH_ROCKCHIP || COMPILE_TEST 870 871 select MMC_DW_PLTFM 871 872 help 872 873 This selects support for Rockchip SoC specific extensions to the ··· 949 948 950 949 config MMC_WMT 951 950 tristate "Wondermedia SD/MMC Host Controller support" 952 - depends on ARCH_VT8500 951 + depends on ARCH_VT8500 || COMPILE_TEST 953 952 default y 954 953 help 955 954 This selects support for the SD/MMC Host Controller on ··· 1116 1115 tristate "Loongson-2K SD/SDIO/eMMC Host Interface support" 1117 1116 depends on LOONGARCH || COMPILE_TEST 1118 1117 depends on HAS_DMA 1118 + select REGMAP_MMIO 1119 1119 help 1120 1120 This selects support for the SD/SDIO/eMMC Host Controller on 1121 1121 Loongson-2K series CPUs.
+3 -5
drivers/mmc/host/alcor.c
··· 1129 1129 mmc_remove_host(mmc); 1130 1130 } 1131 1131 1132 - #ifdef CONFIG_PM_SLEEP 1133 1132 static int alcor_pci_sdmmc_suspend(struct device *dev) 1134 1133 { 1135 1134 struct alcor_sdmmc_host *host = dev_get_drvdata(dev); ··· 1149 1150 1150 1151 return 0; 1151 1152 } 1152 - #endif /* CONFIG_PM_SLEEP */ 1153 1153 1154 - static SIMPLE_DEV_PM_OPS(alcor_mmc_pm_ops, alcor_pci_sdmmc_suspend, 1155 - alcor_pci_sdmmc_resume); 1154 + static DEFINE_SIMPLE_DEV_PM_OPS(alcor_mmc_pm_ops, alcor_pci_sdmmc_suspend, 1155 + alcor_pci_sdmmc_resume); 1156 1156 1157 1157 static const struct platform_device_id alcor_pci_sdmmc_ids[] = { 1158 1158 { ··· 1169 1171 .driver = { 1170 1172 .name = DRV_NAME_ALCOR_PCI_SDMMC, 1171 1173 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1172 - .pm = &alcor_mmc_pm_ops 1174 + .pm = pm_sleep_ptr(&alcor_mmc_pm_ops), 1173 1175 }, 1174 1176 }; 1175 1177 module_platform_driver(alcor_pci_sdmmc_driver);
+3 -6
drivers/mmc/host/atmel-mci.c
··· 2622 2622 pm_runtime_put_noidle(dev); 2623 2623 } 2624 2624 2625 - #ifdef CONFIG_PM 2626 2625 static int atmci_runtime_suspend(struct device *dev) 2627 2626 { 2628 2627 struct atmel_mci *host = dev_get_drvdata(dev); ··· 2641 2642 2642 2643 return clk_prepare_enable(host->mck); 2643 2644 } 2644 - #endif 2645 2645 2646 2646 static const struct dev_pm_ops atmci_dev_pm_ops = { 2647 - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 2648 - pm_runtime_force_resume) 2649 - SET_RUNTIME_PM_OPS(atmci_runtime_suspend, atmci_runtime_resume, NULL) 2647 + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) 2648 + RUNTIME_PM_OPS(atmci_runtime_suspend, atmci_runtime_resume, NULL) 2650 2649 }; 2651 2650 2652 2651 static struct platform_driver atmci_driver = { ··· 2654 2657 .name = "atmel_mci", 2655 2658 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 2656 2659 .of_match_table = atmci_dt_ids, 2657 - .pm = &atmci_dev_pm_ops, 2660 + .pm = pm_ptr(&atmci_dev_pm_ops), 2658 2661 }, 2659 2662 }; 2660 2663 module_platform_driver(atmci_driver);
+7 -11
drivers/mmc/host/au1xmmc.c
··· 1150 1150 } 1151 1151 } 1152 1152 1153 - #ifdef CONFIG_PM 1154 - static int au1xmmc_suspend(struct platform_device *pdev, pm_message_t state) 1153 + static int au1xmmc_suspend(struct device *dev) 1155 1154 { 1156 - struct au1xmmc_host *host = platform_get_drvdata(pdev); 1155 + struct au1xmmc_host *host = dev_get_drvdata(dev); 1157 1156 1158 1157 __raw_writel(0, HOST_CONFIG2(host)); 1159 1158 __raw_writel(0, HOST_CONFIG(host)); ··· 1163 1164 return 0; 1164 1165 } 1165 1166 1166 - static int au1xmmc_resume(struct platform_device *pdev) 1167 + static int au1xmmc_resume(struct device *dev) 1167 1168 { 1168 - struct au1xmmc_host *host = platform_get_drvdata(pdev); 1169 + struct au1xmmc_host *host = dev_get_drvdata(dev); 1169 1170 1170 1171 au1xmmc_reset_controller(host); 1171 1172 1172 1173 return 0; 1173 1174 } 1174 - #else 1175 - #define au1xmmc_suspend NULL 1176 - #define au1xmmc_resume NULL 1177 - #endif 1175 + 1176 + static DEFINE_SIMPLE_DEV_PM_OPS(au1xmmc_pmops, au1xmmc_suspend, au1xmmc_resume); 1178 1177 1179 1178 static struct platform_driver au1xmmc_driver = { 1180 1179 .probe = au1xmmc_probe, 1181 1180 .remove = au1xmmc_remove, 1182 - .suspend = au1xmmc_suspend, 1183 - .resume = au1xmmc_resume, 1184 1181 .driver = { 1185 1182 .name = DRIVER_NAME, 1186 1183 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1184 + .pm = pm_sleep_ptr(&au1xmmc_pmops), 1187 1185 }, 1188 1186 }; 1189 1187
+9 -10
drivers/mmc/host/cb710-mmc.c
··· 664 664 .get_cd = cb710_mmc_get_cd, 665 665 }; 666 666 667 - #ifdef CONFIG_PM 668 - 669 - static int cb710_mmc_suspend(struct platform_device *pdev, pm_message_t state) 667 + static int cb710_mmc_suspend(struct device *dev) 670 668 { 669 + struct platform_device *pdev = to_platform_device(dev); 671 670 struct cb710_slot *slot = cb710_pdev_to_slot(pdev); 672 671 673 672 cb710_mmc_enable_irq(slot, 0, ~0); 674 673 return 0; 675 674 } 676 675 677 - static int cb710_mmc_resume(struct platform_device *pdev) 676 + static int cb710_mmc_resume(struct device *dev) 678 677 { 678 + struct platform_device *pdev = to_platform_device(dev); 679 679 struct cb710_slot *slot = cb710_pdev_to_slot(pdev); 680 680 681 681 cb710_mmc_enable_irq(slot, 0, ~0); 682 682 return 0; 683 683 } 684 684 685 - #endif /* CONFIG_PM */ 685 + static DEFINE_SIMPLE_DEV_PM_OPS(cb710_mmc_pmops, cb710_mmc_suspend, cb710_mmc_resume); 686 686 687 687 static int cb710_mmc_init(struct platform_device *pdev) 688 688 { ··· 767 767 } 768 768 769 769 static struct platform_driver cb710_mmc_driver = { 770 - .driver.name = "cb710-mmc", 770 + .driver = { 771 + .name = "cb710-mmc", 772 + .pm = pm_sleep_ptr(&cb710_mmc_pmops), 773 + }, 771 774 .probe = cb710_mmc_init, 772 775 .remove = cb710_mmc_exit, 773 - #ifdef CONFIG_PM 774 - .suspend = cb710_mmc_suspend, 775 - .resume = cb710_mmc_resume, 776 - #endif 777 776 }; 778 777 779 778 module_platform_driver(cb710_mmc_driver);
+4 -12
drivers/mmc/host/davinci_mmc.c
··· 588 588 cpu_relax(); 589 589 } 590 590 if (mmcst1 & MMCST1_BUSY) { 591 - dev_err(mmc_dev(host->mmc), "still BUSY? bad ... \n"); 591 + dev_err(mmc_dev(host->mmc), "still BUSY? bad ...\n"); 592 592 req->cmd->error = -ETIMEDOUT; 593 593 mmc_request_done(mmc, req); 594 594 return; ··· 1347 1347 clk_disable_unprepare(host->clk); 1348 1348 } 1349 1349 1350 - #ifdef CONFIG_PM 1351 1350 static int davinci_mmcsd_suspend(struct device *dev) 1352 1351 { 1353 1352 struct mmc_davinci_host *host = dev_get_drvdata(dev); ··· 1372 1373 return 0; 1373 1374 } 1374 1375 1375 - static const struct dev_pm_ops davinci_mmcsd_pm = { 1376 - .suspend = davinci_mmcsd_suspend, 1377 - .resume = davinci_mmcsd_resume, 1378 - }; 1379 - 1380 - #define davinci_mmcsd_pm_ops (&davinci_mmcsd_pm) 1381 - #else 1382 - #define davinci_mmcsd_pm_ops NULL 1383 - #endif 1376 + static DEFINE_SIMPLE_DEV_PM_OPS(davinci_mmcsd_pm_ops, 1377 + davinci_mmcsd_suspend, davinci_mmcsd_resume); 1384 1378 1385 1379 static struct platform_driver davinci_mmcsd_driver = { 1386 1380 .driver = { 1387 1381 .name = "davinci_mmc", 1388 1382 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1389 - .pm = davinci_mmcsd_pm_ops, 1383 + .pm = pm_sleep_ptr(&davinci_mmcsd_pm_ops), 1390 1384 .of_match_table = davinci_mmc_dt_ids, 1391 1385 }, 1392 1386 .probe = davinci_mmcsd_probe,
+3 -10
drivers/mmc/host/dw_mmc-exynos.c
··· 189 189 set_bit(DW_MMC_CARD_NO_USE_HOLD, &host->slot->flags); 190 190 } 191 191 192 - #ifdef CONFIG_PM 193 192 static int dw_mci_exynos_runtime_resume(struct device *dev) 194 193 { 195 194 struct dw_mci *host = dev_get_drvdata(dev); ··· 202 203 203 204 return ret; 204 205 } 205 - #endif /* CONFIG_PM */ 206 206 207 - #ifdef CONFIG_PM_SLEEP 208 207 /** 209 208 * dw_mci_exynos_suspend_noirq - Exynos-specific suspend code 210 209 * @dev: Device to suspend (this device) ··· 262 265 263 266 return 0; 264 267 } 265 - #endif /* CONFIG_PM_SLEEP */ 266 268 267 269 static void dw_mci_exynos_config_hs400(struct dw_mci *host, u32 timing) 268 270 { ··· 708 712 } 709 713 710 714 static const struct dev_pm_ops dw_mci_exynos_pmops = { 711 - SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(dw_mci_exynos_suspend_noirq, 712 - dw_mci_exynos_resume_noirq) 713 - SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend, 714 - dw_mci_exynos_runtime_resume, 715 - NULL) 715 + NOIRQ_SYSTEM_SLEEP_PM_OPS(dw_mci_exynos_suspend_noirq, dw_mci_exynos_resume_noirq) 716 + RUNTIME_PM_OPS(dw_mci_runtime_suspend, dw_mci_exynos_runtime_resume, NULL) 716 717 }; 717 718 718 719 static struct platform_driver dw_mci_exynos_pltfm_driver = { ··· 719 726 .name = "dwmmc_exynos", 720 727 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 721 728 .of_match_table = dw_mci_exynos_match, 722 - .pm = &dw_mci_exynos_pmops, 729 + .pm = pm_ptr(&dw_mci_exynos_pmops), 723 730 }, 724 731 }; 725 732
+3 -6
drivers/mmc/host/dw_mmc-k3.c
··· 461 461 } 462 462 463 463 static const struct dev_pm_ops dw_mci_k3_dev_pm_ops = { 464 - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 465 - pm_runtime_force_resume) 466 - SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend, 467 - dw_mci_runtime_resume, 468 - NULL) 464 + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) 465 + RUNTIME_PM_OPS(dw_mci_runtime_suspend, dw_mci_runtime_resume, NULL) 469 466 }; 470 467 471 468 static struct platform_driver dw_mci_k3_pltfm_driver = { ··· 472 475 .name = "dwmmc_k3", 473 476 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 474 477 .of_match_table = dw_mci_k3_match, 475 - .pm = &dw_mci_k3_dev_pm_ops, 478 + .pm = pm_ptr(&dw_mci_k3_dev_pm_ops), 476 479 }, 477 480 }; 478 481
+3 -6
drivers/mmc/host/dw_mmc-pci.c
··· 75 75 } 76 76 77 77 static const struct dev_pm_ops dw_mci_pci_dev_pm_ops = { 78 - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 79 - pm_runtime_force_resume) 80 - SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend, 81 - dw_mci_runtime_resume, 82 - NULL) 78 + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) 79 + RUNTIME_PM_OPS(dw_mci_runtime_suspend, dw_mci_runtime_resume, NULL) 83 80 }; 84 81 85 82 static const struct pci_device_id dw_mci_pci_id[] = { ··· 91 94 .probe = dw_mci_pci_probe, 92 95 .remove = dw_mci_pci_remove, 93 96 .driver = { 94 - .pm = &dw_mci_pci_dev_pm_ops, 97 + .pm = pm_ptr(&dw_mci_pci_dev_pm_ops), 95 98 }, 96 99 }; 97 100
+3 -6
drivers/mmc/host/dw_mmc-rockchip.c
··· 568 568 } 569 569 570 570 static const struct dev_pm_ops dw_mci_rockchip_dev_pm_ops = { 571 - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 572 - pm_runtime_force_resume) 573 - SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend, 574 - dw_mci_runtime_resume, 575 - NULL) 571 + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) 572 + RUNTIME_PM_OPS(dw_mci_runtime_suspend, dw_mci_runtime_resume, NULL) 576 573 }; 577 574 578 575 static struct platform_driver dw_mci_rockchip_pltfm_driver = { ··· 579 582 .name = "dwmmc_rockchip", 580 583 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 581 584 .of_match_table = dw_mci_rockchip_match, 582 - .pm = &dw_mci_rockchip_dev_pm_ops, 585 + .pm = pm_ptr(&dw_mci_rockchip_dev_pm_ops), 583 586 }, 584 587 }; 585 588
+3
drivers/mmc/host/dw_mmc.h
··· 541 541 #ifdef CONFIG_PM 542 542 extern int dw_mci_runtime_suspend(struct device *device); 543 543 extern int dw_mci_runtime_resume(struct device *device); 544 + #else 545 + static inline int dw_mci_runtime_suspend(struct device *device) { return -EOPNOTSUPP; } 546 + static inline int dw_mci_runtime_resume(struct device *device) { return -EOPNOTSUPP; } 544 547 #endif 545 548 546 549 /**
+1 -3
drivers/mmc/host/meson-mx-sdhc-clkc.c
··· 84 84 return ret; 85 85 86 86 clk_bulk_data[bulk_index].clk = devm_clk_hw_get_clk(dev, hw, name_suffix); 87 - if (IS_ERR(clk_bulk_data[bulk_index].clk)) 88 - return PTR_ERR(clk_bulk_data[bulk_index].clk); 89 87 90 - return 0; 88 + return PTR_ERR_OR_ZERO(clk_bulk_data[bulk_index].clk); 91 89 } 92 90 93 91 int meson_mx_sdhc_register_clkc(struct device *dev, void __iomem *base,
+2 -2
drivers/mmc/host/mmc_spi.c
··· 563 563 * the next token (next data block, or STOP_TRAN). We can try to 564 564 * minimize I/O ops by using a single read to collect end-of-busy. 565 565 */ 566 - if (multiple || write) { 566 + if (write) { 567 567 t = &host->early_status; 568 568 memset(t, 0, sizeof(*t)); 569 - t->len = write ? sizeof(scratch->status) : 1; 569 + t->len = sizeof(scratch->status); 570 570 t->tx_buf = host->ones; 571 571 t->rx_buf = scratch->status; 572 572 t->cs_change = 1;
+3 -6
drivers/mmc/host/mmci.c
··· 2516 2516 } 2517 2517 } 2518 2518 2519 - #ifdef CONFIG_PM 2520 2519 static void mmci_save(struct mmci_host *host) 2521 2520 { 2522 2521 unsigned long flags; ··· 2580 2581 2581 2582 return 0; 2582 2583 } 2583 - #endif 2584 2584 2585 2585 static const struct dev_pm_ops mmci_dev_pm_ops = { 2586 - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 2587 - pm_runtime_force_resume) 2588 - SET_RUNTIME_PM_OPS(mmci_runtime_suspend, mmci_runtime_resume, NULL) 2586 + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) 2587 + RUNTIME_PM_OPS(mmci_runtime_suspend, mmci_runtime_resume, NULL) 2589 2588 }; 2590 2589 2591 2590 static const struct amba_id mmci_ids[] = { ··· 2672 2675 static struct amba_driver mmci_driver = { 2673 2676 .drv = { 2674 2677 .name = DRIVER_NAME, 2675 - .pm = &mmci_dev_pm_ops, 2678 + .pm = pm_ptr(&mmci_dev_pm_ops), 2676 2679 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 2677 2680 }, 2678 2681 .probe = mmci_probe,
+7 -7
drivers/mmc/host/mtk-sd.c
··· 3278 3278 __msdc_enable_sdio_irq(host, 1); 3279 3279 } 3280 3280 3281 - static int __maybe_unused msdc_runtime_suspend(struct device *dev) 3281 + static int msdc_runtime_suspend(struct device *dev) 3282 3282 { 3283 3283 struct mmc_host *mmc = dev_get_drvdata(dev); 3284 3284 struct msdc_host *host = mmc_priv(mmc); ··· 3300 3300 return 0; 3301 3301 } 3302 3302 3303 - static int __maybe_unused msdc_runtime_resume(struct device *dev) 3303 + static int msdc_runtime_resume(struct device *dev) 3304 3304 { 3305 3305 struct mmc_host *mmc = dev_get_drvdata(dev); 3306 3306 struct msdc_host *host = mmc_priv(mmc); ··· 3323 3323 return 0; 3324 3324 } 3325 3325 3326 - static int __maybe_unused msdc_suspend(struct device *dev) 3326 + static int msdc_suspend(struct device *dev) 3327 3327 { 3328 3328 struct mmc_host *mmc = dev_get_drvdata(dev); 3329 3329 struct msdc_host *host = mmc_priv(mmc); ··· 3348 3348 return pm_runtime_force_suspend(dev); 3349 3349 } 3350 3350 3351 - static int __maybe_unused msdc_resume(struct device *dev) 3351 + static int msdc_resume(struct device *dev) 3352 3352 { 3353 3353 struct mmc_host *mmc = dev_get_drvdata(dev); 3354 3354 struct msdc_host *host = mmc_priv(mmc); ··· 3360 3360 } 3361 3361 3362 3362 static const struct dev_pm_ops msdc_dev_pm_ops = { 3363 - SET_SYSTEM_SLEEP_PM_OPS(msdc_suspend, msdc_resume) 3364 - SET_RUNTIME_PM_OPS(msdc_runtime_suspend, msdc_runtime_resume, NULL) 3363 + SYSTEM_SLEEP_PM_OPS(msdc_suspend, msdc_resume) 3364 + RUNTIME_PM_OPS(msdc_runtime_suspend, msdc_runtime_resume, NULL) 3365 3365 }; 3366 3366 3367 3367 static struct platform_driver mt_msdc_driver = { ··· 3371 3371 .name = "mtk-msdc", 3372 3372 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 3373 3373 .of_match_table = msdc_of_ids, 3374 - .pm = &msdc_dev_pm_ops, 3374 + .pm = pm_ptr(&msdc_dev_pm_ops), 3375 3375 }, 3376 3376 }; 3377 3377
+2 -4
drivers/mmc/host/mxs-mmc.c
··· 680 680 clk_disable_unprepare(ssp->clk); 681 681 } 682 682 683 - #ifdef CONFIG_PM_SLEEP 684 683 static int mxs_mmc_suspend(struct device *dev) 685 684 { 686 685 struct mmc_host *mmc = dev_get_drvdata(dev); ··· 698 699 699 700 return clk_prepare_enable(ssp->clk); 700 701 } 701 - #endif 702 702 703 - static SIMPLE_DEV_PM_OPS(mxs_mmc_pm_ops, mxs_mmc_suspend, mxs_mmc_resume); 703 + static DEFINE_SIMPLE_DEV_PM_OPS(mxs_mmc_pm_ops, mxs_mmc_suspend, mxs_mmc_resume); 704 704 705 705 static struct platform_driver mxs_mmc_driver = { 706 706 .probe = mxs_mmc_probe, ··· 707 709 .driver = { 708 710 .name = DRIVER_NAME, 709 711 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 710 - .pm = &mxs_mmc_pm_ops, 712 + .pm = pm_sleep_ptr(&mxs_mmc_pm_ops), 711 713 .of_match_table = mxs_mmc_dt_ids, 712 714 }, 713 715 };
+4 -9
drivers/mmc/host/omap_hsmmc.c
··· 620 620 OMAP_HSMMC_WRITE(host->base, CON, con & ~OD); 621 621 } 622 622 623 - #ifdef CONFIG_PM 624 - 625 623 /* 626 624 * Restore the MMC host context, if it was lost as result of a 627 625 * power state change. ··· 687 689 return 0; 688 690 } 689 691 692 + #ifdef CONFIG_PM 690 693 /* 691 694 * Save the MMC host context (store the number of power state changes so far). 692 695 */ ··· 1989 1990 clk_disable_unprepare(host->dbclk); 1990 1991 } 1991 1992 1992 - #ifdef CONFIG_PM_SLEEP 1993 1993 static int omap_hsmmc_suspend(struct device *dev) 1994 1994 { 1995 1995 struct omap_hsmmc_host *host = dev_get_drvdata(dev); ··· 2030 2032 pm_runtime_put_autosuspend(host->dev); 2031 2033 return 0; 2032 2034 } 2033 - #endif 2034 2035 2035 - #ifdef CONFIG_PM 2036 2036 static int omap_hsmmc_runtime_suspend(struct device *dev) 2037 2037 { 2038 2038 struct omap_hsmmc_host *host; ··· 2098 2102 spin_unlock_irqrestore(&host->irq_lock, flags); 2099 2103 return 0; 2100 2104 } 2101 - #endif 2102 2105 2103 2106 static const struct dev_pm_ops omap_hsmmc_dev_pm_ops = { 2104 - SET_SYSTEM_SLEEP_PM_OPS(omap_hsmmc_suspend, omap_hsmmc_resume) 2105 - SET_RUNTIME_PM_OPS(omap_hsmmc_runtime_suspend, omap_hsmmc_runtime_resume, NULL) 2107 + SYSTEM_SLEEP_PM_OPS(omap_hsmmc_suspend, omap_hsmmc_resume) 2108 + RUNTIME_PM_OPS(omap_hsmmc_runtime_suspend, omap_hsmmc_runtime_resume, NULL) 2106 2109 }; 2107 2110 2108 2111 static struct platform_driver omap_hsmmc_driver = { ··· 2110 2115 .driver = { 2111 2116 .name = DRIVER_NAME, 2112 2117 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 2113 - .pm = &omap_hsmmc_dev_pm_ops, 2118 + .pm = pm_ptr(&omap_hsmmc_dev_pm_ops), 2114 2119 .of_match_table = of_match_ptr(omap_mmc_of_match), 2115 2120 }, 2116 2121 };
+5 -1
drivers/mmc/host/renesas_sdhi_core.c
··· 222 222 clk &= ~0xff; 223 223 } 224 224 225 - sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, clk & CLK_CTL_DIV_MASK); 225 + clock = clk & CLK_CTL_DIV_MASK; 226 + if (clock != CLK_CTL_DIV_MASK) 227 + host->mmc->actual_clock /= (1 << (ffs(clock) + 1)); 228 + 229 + sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, clock); 226 230 if (!(host->pdata->flags & TMIO_MMC_MIN_RCAR2)) 227 231 usleep_range(10000, 11000); 228 232
+2 -1
drivers/mmc/host/renesas_sdhi_internal_dmac.c
··· 107 107 108 108 static const struct renesas_sdhi_of_data of_data_rcar_gen3 = { 109 109 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL | 110 - TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2, 110 + TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2 | 111 + TMIO_MMC_64BIT_DATA_PORT, 111 112 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | 112 113 MMC_CAP_CMD23 | MMC_CAP_WAIT_WHILE_BUSY, 113 114 .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT | MMC_CAP2_MERGE_CAPABLE,
+32 -8
drivers/mmc/host/rtsx_usb_sdmmc.c
··· 48 48 bool ddr_mode; 49 49 50 50 unsigned char power_mode; 51 - 51 + u16 ocp_stat; 52 52 #ifdef RTSX_USB_USE_LEDS_CLASS 53 53 struct led_classdev led; 54 54 char led_name[32]; ··· 789 789 if (err) 790 790 goto no_card; 791 791 792 + /* get OCP status */ 793 + host->ocp_stat = (val >> 4) & 0x03; 794 + 792 795 if (val & SD_CD) { 793 796 host->card_exist = true; 794 797 return 1; 795 798 } 796 799 797 800 no_card: 801 + /* clear OCP status */ 802 + if (host->ocp_stat & (MS_OCP_NOW | MS_OCP_EVER)) { 803 + rtsx_usb_write_register(ucr, OCPCTL, MS_OCP_CLEAR, MS_OCP_CLEAR); 804 + host->ocp_stat = 0; 805 + } 798 806 host->card_exist = false; 799 807 return 0; 800 808 } ··· 826 818 cmd->error = -ENOMEDIUM; 827 819 goto finish_detect_card; 828 820 } 829 - 821 + /* check OCP stat */ 822 + if (host->ocp_stat & (MS_OCP_NOW | MS_OCP_EVER)) { 823 + cmd->error = -ENOMEDIUM; 824 + goto finish_detect_card; 825 + } 830 826 mutex_lock(&ucr->dev_mutex); 831 827 832 828 mutex_lock(&host->host_mutex); ··· 964 952 struct rtsx_ucr *ucr = host->ucr; 965 953 int err; 966 954 955 + if (host->ocp_stat & (MS_OCP_NOW | MS_OCP_EVER)) { 956 + dev_dbg(sdmmc_dev(host), "over current\n"); 957 + return -EIO; 958 + } 967 959 dev_dbg(sdmmc_dev(host), "%s\n", __func__); 968 960 rtsx_usb_init_cmd(ucr); 969 961 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_SELECT, 0x07, SD_MOD_SEL); ··· 994 978 usleep_range(800, 1000); 995 979 996 980 rtsx_usb_init_cmd(ucr); 981 + /* WA OCP issue: after OCP, there were problems with reopen card power */ 982 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PWR_CTL, POWER_MASK, POWER_ON); 983 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, FPDCTL, SSC_POWER_MASK, SSC_POWER_DOWN); 984 + err = rtsx_usb_send_cmd(ucr, MODE_C, 100); 985 + if (err) 986 + return err; 987 + msleep(20); 988 + rtsx_usb_write_register(ucr, FPDCTL, SSC_POWER_MASK, SSC_POWER_ON); 989 + usleep_range(180, 200); 990 + rtsx_usb_init_cmd(ucr); 997 991 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PWR_CTL, 998 - POWER_MASK|LDO3318_PWR_MASK, POWER_ON|LDO_ON); 992 + LDO3318_PWR_MASK, LDO_ON); 999 993 rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_OE, 1000 994 SD_OUTPUT_EN, SD_OUTPUT_EN); 1001 995 ··· 1358 1332 mmc->max_req_size = 524288; 1359 1333 1360 1334 host->power_mode = MMC_POWER_OFF; 1335 + host->ocp_stat = 0; 1361 1336 } 1362 1337 1363 1338 static int rtsx_usb_sdmmc_drv_probe(struct platform_device *pdev) ··· 1455 1428 ": Realtek USB SD/MMC module has been removed\n"); 1456 1429 } 1457 1430 1458 - #ifdef CONFIG_PM 1459 1431 static int rtsx_usb_sdmmc_runtime_suspend(struct device *dev) 1460 1432 { 1461 1433 struct rtsx_usb_sdmmc *host = dev_get_drvdata(dev); ··· 1472 1446 mmc_detect_change(host->mmc, 0); 1473 1447 return 0; 1474 1448 } 1475 - #endif 1476 1449 1477 1450 static const struct dev_pm_ops rtsx_usb_sdmmc_dev_pm_ops = { 1478 - SET_RUNTIME_PM_OPS(rtsx_usb_sdmmc_runtime_suspend, 1479 - rtsx_usb_sdmmc_runtime_resume, NULL) 1451 + RUNTIME_PM_OPS(rtsx_usb_sdmmc_runtime_suspend, rtsx_usb_sdmmc_runtime_resume, NULL) 1480 1452 }; 1481 1453 1482 1454 static const struct platform_device_id rtsx_usb_sdmmc_ids[] = { ··· 1493 1469 .driver = { 1494 1470 .name = "rtsx_usb_sdmmc", 1495 1471 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1496 - .pm = &rtsx_usb_sdmmc_dev_pm_ops, 1472 + .pm = pm_ptr(&rtsx_usb_sdmmc_dev_pm_ops), 1497 1473 }, 1498 1474 }; 1499 1475 module_platform_driver(rtsx_usb_sdmmc_driver);
+4 -14
drivers/mmc/host/sdhci-acpi.c
··· 973 973 c->slot->free_slot(pdev); 974 974 } 975 975 976 - static void __maybe_unused sdhci_acpi_reset_signal_voltage_if_needed( 977 - struct device *dev) 976 + static void sdhci_acpi_reset_signal_voltage_if_needed(struct device *dev) 978 977 { 979 978 struct sdhci_acpi_host *c = dev_get_drvdata(dev); 980 979 struct sdhci_host *host = c->host; ··· 987 988 intel_dsm(intel_host, dev, fn, &result); 988 989 } 989 990 } 990 - 991 - #ifdef CONFIG_PM_SLEEP 992 991 993 992 static int sdhci_acpi_suspend(struct device *dev) 994 993 { ··· 1014 1017 return sdhci_resume_host(c->host); 1015 1018 } 1016 1019 1017 - #endif 1018 - 1019 - #ifdef CONFIG_PM 1020 - 1021 1020 static int sdhci_acpi_runtime_suspend(struct device *dev) 1022 1021 { 1023 1022 struct sdhci_acpi_host *c = dev_get_drvdata(dev); ··· 1038 1045 return 0; 1039 1046 } 1040 1047 1041 - #endif 1042 - 1043 1048 static const struct dev_pm_ops sdhci_acpi_pm_ops = { 1044 - SET_SYSTEM_SLEEP_PM_OPS(sdhci_acpi_suspend, sdhci_acpi_resume) 1045 - SET_RUNTIME_PM_OPS(sdhci_acpi_runtime_suspend, 1046 - sdhci_acpi_runtime_resume, NULL) 1049 + SYSTEM_SLEEP_PM_OPS(sdhci_acpi_suspend, sdhci_acpi_resume) 1050 + RUNTIME_PM_OPS(sdhci_acpi_runtime_suspend, sdhci_acpi_runtime_resume, NULL) 1047 1051 }; 1048 1052 1049 1053 static struct platform_driver sdhci_acpi_driver = { ··· 1048 1058 .name = "sdhci-acpi", 1049 1059 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1050 1060 .acpi_match_table = sdhci_acpi_ids, 1051 - .pm = &sdhci_acpi_pm_ops, 1061 + .pm = pm_ptr(&sdhci_acpi_pm_ops), 1052 1062 }, 1053 1063 .probe = sdhci_acpi_probe, 1054 1064 .remove = sdhci_acpi_remove,
+2 -6
drivers/mmc/host/sdhci-brcmstb.c
··· 496 496 497 497 MODULE_DEVICE_TABLE(of, sdhci_brcm_of_match); 498 498 499 - #ifdef CONFIG_PM_SLEEP 500 499 static int sdhci_brcmstb_suspend(struct device *dev) 501 500 { 502 501 struct sdhci_host *host = dev_get_drvdata(dev); ··· 539 540 540 541 return ret; 541 542 } 542 - #endif 543 543 544 - static const struct dev_pm_ops sdhci_brcmstb_pmops = { 545 - SET_SYSTEM_SLEEP_PM_OPS(sdhci_brcmstb_suspend, sdhci_brcmstb_resume) 546 - }; 544 + static DEFINE_SIMPLE_DEV_PM_OPS(sdhci_brcmstb_pmops, sdhci_brcmstb_suspend, sdhci_brcmstb_resume); 547 545 548 546 static struct platform_driver sdhci_brcmstb_driver = { 549 547 .driver = { 550 548 .name = "sdhci-brcmstb", 551 549 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 552 - .pm = &sdhci_brcmstb_pmops, 550 + .pm = pm_sleep_ptr(&sdhci_brcmstb_pmops), 553 551 .of_match_table = of_match_ptr(sdhci_brcm_of_match), 554 552 }, 555 553 .probe = sdhci_brcmstb_probe,
+63 -7
drivers/mmc/host/sdhci-cadence.c
··· 36 36 #define SDHCI_CDNS_HRS06_MODE_MMC_HS400 0x5 37 37 #define SDHCI_CDNS_HRS06_MODE_MMC_HS400ES 0x6 38 38 39 + /* Read block gap */ 40 + #define SDHCI_CDNS_HRS37 0x94 /* interface mode select */ 41 + #define SDHCI_CDNS_HRS37_MODE_DS 0x0 42 + #define SDHCI_CDNS_HRS37_MODE_HS 0x1 43 + #define SDHCI_CDNS_HRS37_MODE_UDS_SDR12 0x8 44 + #define SDHCI_CDNS_HRS37_MODE_UDS_SDR25 0x9 45 + #define SDHCI_CDNS_HRS37_MODE_UDS_SDR50 0xa 46 + #define SDHCI_CDNS_HRS37_MODE_UDS_SDR104 0xb 47 + #define SDHCI_CDNS_HRS37_MODE_UDS_DDR50 0xc 48 + #define SDHCI_CDNS_HRS37_MODE_MMC_LEGACY 0x20 49 + #define SDHCI_CDNS_HRS37_MODE_MMC_SDR 0x21 50 + #define SDHCI_CDNS_HRS37_MODE_MMC_DDR 0x22 51 + #define SDHCI_CDNS_HRS37_MODE_MMC_HS200 0x23 52 + #define SDHCI_CDNS_HRS37_MODE_MMC_HS400 0x24 53 + #define SDHCI_CDNS_HRS37_MODE_MMC_HS400ES 0x25 54 + #define SDHCI_CDNS_HRS38 0x98 /* Read block gap coefficient */ 55 + #define SDHCI_CDNS_HRS38_BLKGAP_MAX 0xf 56 + 39 57 /* SRS - Slot Register Set (SDHCI-compatible) */ 40 58 #define SDHCI_CDNS_SRS_BASE 0x200 41 59 ··· 269 251 return 0; 270 252 } 271 253 254 + /** 255 + * sdhci_cdns_tune_blkgap() - tune multi-block read gap 256 + * @mmc: MMC host 257 + * 258 + * Tune delay used in multi block read. To do so, 259 + * try sending multi-block read command with incremented gap, unless 260 + * it succeeds. 261 + * 262 + * Return: error code 263 + */ 264 + static int sdhci_cdns_tune_blkgap(struct mmc_host *mmc) 265 + { 266 + struct sdhci_host *host = mmc_priv(mmc); 267 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 268 + struct sdhci_cdns_priv *priv = sdhci_pltfm_priv(pltfm_host); 269 + void __iomem *hrs37_reg = priv->hrs_addr + SDHCI_CDNS_HRS37; 270 + void __iomem *hrs38_reg = priv->hrs_addr + SDHCI_CDNS_HRS38; 271 + int ret; 272 + u32 gap; 273 + 274 + /* Currently only needed in HS200 mode */ 275 + if (host->timing != MMC_TIMING_MMC_HS200) 276 + return 0; 277 + 278 + writel(SDHCI_CDNS_HRS37_MODE_MMC_HS200, hrs37_reg); 279 + 280 + for (gap = 0; gap <= SDHCI_CDNS_HRS38_BLKGAP_MAX; gap++) { 281 + writel(gap, hrs38_reg); 282 + ret = mmc_read_tuning(mmc, 512, 32); 283 + if (!ret) 284 + break; 285 + } 286 + 287 + dev_dbg(mmc_dev(mmc), "read block gap tune %s, gap %d\n", ret ? "failed" : "OK", gap); 288 + return ret; 289 + } 290 + 272 291 /* 273 292 * In SD mode, software must not use the hardware tuning and instead perform 274 293 * an almost identical procedure to eMMC. ··· 316 261 int max_streak = 0; 317 262 int end_of_streak = 0; 318 263 int i; 264 + int ret; 319 265 320 266 /* 321 267 * Do not execute tuning for UHS_SDR50 or UHS_DDR50. ··· 344 288 return -EIO; 345 289 } 346 290 347 - return sdhci_cdns_set_tune_val(host, end_of_streak - max_streak / 2); 291 + ret = sdhci_cdns_set_tune_val(host, end_of_streak - max_streak / 2); 292 + if (ret) 293 + return ret; 294 + 295 + return sdhci_cdns_tune_blkgap(host->mmc); 348 296 } 349 297 350 298 static void sdhci_cdns_set_uhs_signaling(struct sdhci_host *host, ··· 611 551 return sdhci_add_host(host); 612 552 } 613 553 614 - #ifdef CONFIG_PM_SLEEP 615 554 static int sdhci_cdns_resume(struct device *dev) 616 555 { 617 556 struct sdhci_host *host = dev_get_drvdata(dev); ··· 637 578 638 579 return ret; 639 580 } 640 - #endif 641 581 642 - static const struct dev_pm_ops sdhci_cdns_pm_ops = { 643 - SET_SYSTEM_SLEEP_PM_OPS(sdhci_pltfm_suspend, sdhci_cdns_resume) 644 - }; 582 + static DEFINE_SIMPLE_DEV_PM_OPS(sdhci_cdns_pm_ops, sdhci_pltfm_suspend, sdhci_cdns_resume); 645 583 646 584 static const struct of_device_id sdhci_cdns_match[] = { 647 585 { ··· 662 606 .driver = { 663 607 .name = "sdhci-cdns", 664 608 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 665 - .pm = &sdhci_cdns_pm_ops, 609 + .pm = pm_sleep_ptr(&sdhci_cdns_pm_ops), 666 610 .of_match_table = sdhci_cdns_match, 667 611 }, 668 612 .probe = sdhci_cdns_probe,
+3 -10
drivers/mmc/host/sdhci-esdhc-imx.c
··· 1650 1650 } 1651 1651 } 1652 1652 1653 - #ifdef CONFIG_PM_SLEEP 1654 1653 static void sdhc_esdhc_tuning_save(struct sdhci_host *host) 1655 1654 { 1656 1655 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); ··· 1706 1707 host->ioaddr + ESDHC_TUNE_CTRL_STATUS); 1707 1708 } 1708 1709 } 1709 - #endif 1710 1710 1711 1711 static void esdhc_cqe_enable(struct mmc_host *mmc) 1712 1712 { ··· 2014 2016 cpu_latency_qos_remove_request(&imx_data->pm_qos_req); 2015 2017 } 2016 2018 2017 - #ifdef CONFIG_PM_SLEEP 2018 2019 static int sdhci_esdhc_suspend(struct device *dev) 2019 2020 { 2020 2021 struct sdhci_host *host = dev_get_drvdata(dev); ··· 2109 2112 2110 2113 return ret; 2111 2114 } 2112 - #endif 2113 2115 2114 - #ifdef CONFIG_PM 2115 2116 static int sdhci_esdhc_runtime_suspend(struct device *dev) 2116 2117 { 2117 2118 struct sdhci_host *host = dev_get_drvdata(dev); ··· 2183 2188 cpu_latency_qos_remove_request(&imx_data->pm_qos_req); 2184 2189 return err; 2185 2190 } 2186 - #endif 2187 2191 2188 2192 static const struct dev_pm_ops sdhci_esdhc_pmops = { 2189 - SET_SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume) 2190 - SET_RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend, 2191 - sdhci_esdhc_runtime_resume, NULL) 2193 + SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume) 2194 + RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend, sdhci_esdhc_runtime_resume, NULL) 2192 2195 }; 2193 2196 2194 2197 static struct platform_driver sdhci_esdhc_imx_driver = { ··· 2194 2201 .name = "sdhci-esdhc-imx", 2195 2202 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 2196 2203 .of_match_table = imx_esdhc_dt_ids, 2197 - .pm = &sdhci_esdhc_pmops, 2204 + .pm = pm_ptr(&sdhci_esdhc_pmops), 2198 2205 }, 2199 2206 .probe = sdhci_esdhc_imx_probe, 2200 2207 .remove = sdhci_esdhc_imx_remove,
+24 -12
drivers/mmc/host/sdhci-msm.c
··· 81 81 #define CORE_IO_PAD_PWR_SWITCH_EN BIT(15) 82 82 #define CORE_IO_PAD_PWR_SWITCH BIT(16) 83 83 #define CORE_HC_SELECT_IN_EN BIT(18) 84 + #define CORE_HC_SELECT_IN_SDR50 (4 << 19) 84 85 #define CORE_HC_SELECT_IN_HS400 (6 << 19) 85 86 #define CORE_HC_SELECT_IN_MASK (7 << 19) 86 87 ··· 1134 1133 { 1135 1134 struct mmc_ios *ios = &host->mmc->ios; 1136 1135 1136 + if (ios->timing == MMC_TIMING_UHS_SDR50 && 1137 + host->flags & SDHCI_SDR50_NEEDS_TUNING) 1138 + return true; 1139 + 1137 1140 /* 1138 1141 * Tuning is required for SDR104, HS200 and HS400 cards and 1139 1142 * if clock frequency is greater than 100MHz in these modes. ··· 1206 1201 struct mmc_ios ios = host->mmc->ios; 1207 1202 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 1208 1203 struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); 1204 + const struct sdhci_msm_offset *msm_offset = msm_host->offset; 1205 + u32 config; 1209 1206 1210 1207 if (!sdhci_msm_is_tuning_needed(host)) { 1211 1208 msm_host->use_cdr = false; ··· 1223 1216 * HS400 settings. 1224 1217 */ 1225 1218 msm_host->tuning_done = 0; 1219 + 1220 + if (ios.timing == MMC_TIMING_UHS_SDR50 && 1221 + host->flags & SDHCI_SDR50_NEEDS_TUNING) { 1222 + config = readl_relaxed(host->ioaddr + msm_offset->core_vendor_spec); 1223 + config &= ~CORE_HC_SELECT_IN_MASK; 1224 + config |= CORE_HC_SELECT_IN_EN | CORE_HC_SELECT_IN_SDR50; 1225 + writel_relaxed(config, host->ioaddr + msm_offset->core_vendor_spec); 1226 + } 1226 1227 1227 1228 /* 1228 1229 * For HS400 tuning in HS200 timing requires: ··· 1958 1943 qcom_ice_enable(msm_host->ice); 1959 1944 } 1960 1945 1961 - static __maybe_unused int sdhci_msm_ice_resume(struct sdhci_msm_host *msm_host) 1946 + static int sdhci_msm_ice_resume(struct sdhci_msm_host *msm_host) 1962 1947 { 1963 1948 if (msm_host->mmc->caps2 & MMC_CAP2_CRYPTO) 1964 1949 return qcom_ice_resume(msm_host->ice); ··· 1966 1951 return 0; 1967 1952 } 1968 1953 1969 - static __maybe_unused int sdhci_msm_ice_suspend(struct sdhci_msm_host *msm_host) 1954 + static int sdhci_msm_ice_suspend(struct sdhci_msm_host *msm_host) 1970 1955 { 1971 1956 if (msm_host->mmc->caps2 & MMC_CAP2_CRYPTO) 1972 1957 return qcom_ice_suspend(msm_host->ice); ··· 2026 2011 { 2027 2012 } 2028 2013 2029 - static inline __maybe_unused int 2014 + static inline int 2030 2015 sdhci_msm_ice_resume(struct sdhci_msm_host *msm_host) 2031 2016 { 2032 2017 return 0; 2033 2018 } 2034 2019 2035 - static inline __maybe_unused int 2020 + static inline int 2036 2021 sdhci_msm_ice_suspend(struct sdhci_msm_host *msm_host) 2037 2022 { 2038 2023 return 0; ··· 2816 2801 clk_disable_unprepare(msm_host->bus_clk); 2817 2802 } 2818 2803 2819 - static __maybe_unused int sdhci_msm_runtime_suspend(struct device *dev) 2804 + static int sdhci_msm_runtime_suspend(struct device *dev) 2820 2805 { 2821 2806 struct sdhci_host *host = dev_get_drvdata(dev); 2822 2807 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); ··· 2835 2820 return sdhci_msm_ice_suspend(msm_host); 2836 2821 } 2837 2822 2838 - static __maybe_unused int sdhci_msm_runtime_resume(struct device *dev) 2823 + static int sdhci_msm_runtime_resume(struct device *dev) 2839 2824 { 2840 2825 struct sdhci_host *host = dev_get_drvdata(dev); 2841 2826 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); ··· 2871 2856 } 2872 2857 2873 2858 static const struct dev_pm_ops sdhci_msm_pm_ops = { 2874 - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 2875 - pm_runtime_force_resume) 2876 - SET_RUNTIME_PM_OPS(sdhci_msm_runtime_suspend, 2877 - sdhci_msm_runtime_resume, 2878 - NULL) 2859 + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) 2860 + RUNTIME_PM_OPS(sdhci_msm_runtime_suspend, sdhci_msm_runtime_resume, NULL) 2879 2861 }; 2880 2862 2881 2863 static struct platform_driver sdhci_msm_driver = { ··· 2881 2869 .driver = { 2882 2870 .name = "sdhci_msm", 2883 2871 .of_match_table = sdhci_msm_dt_match, 2884 - .pm = &sdhci_msm_pm_ops, 2872 + .pm = pm_ptr(&sdhci_msm_pm_ops), 2885 2873 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 2886 2874 }, 2887 2875 };
+3 -5
drivers/mmc/host/sdhci-of-arasan.c
··· 605 605 SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN, 606 606 }; 607 607 608 - #ifdef CONFIG_PM_SLEEP 609 608 /** 610 609 * sdhci_arasan_suspend - Suspend method for the driver 611 610 * @dev: Address of the device structure ··· 698 699 699 700 return 0; 700 701 } 701 - #endif /* ! CONFIG_PM_SLEEP */ 702 702 703 - static SIMPLE_DEV_PM_OPS(sdhci_arasan_dev_pm_ops, sdhci_arasan_suspend, 704 - sdhci_arasan_resume); 703 + static DEFINE_SIMPLE_DEV_PM_OPS(sdhci_arasan_dev_pm_ops, sdhci_arasan_suspend, 704 + sdhci_arasan_resume); 705 705 706 706 /** 707 707 * sdhci_arasan_sdcardclk_recalc_rate - Return the card clock rate ··· 2078 2080 .name = "sdhci-arasan", 2079 2081 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 2080 2082 .of_match_table = sdhci_arasan_of_match, 2081 - .pm = &sdhci_arasan_dev_pm_ops, 2083 + .pm = pm_sleep_ptr(&sdhci_arasan_dev_pm_ops), 2082 2084 }, 2083 2085 .probe = sdhci_arasan_probe, 2084 2086 .remove = sdhci_arasan_remove,
+3 -9
drivers/mmc/host/sdhci-of-at91.c
··· 229 229 return 0; 230 230 } 231 231 232 - #ifdef CONFIG_PM_SLEEP 233 232 static int sdhci_at91_suspend(struct device *dev) 234 233 { 235 234 struct sdhci_host *host = dev_get_drvdata(dev); ··· 242 243 243 244 return ret; 244 245 } 245 - #endif /* CONFIG_PM_SLEEP */ 246 246 247 - #ifdef CONFIG_PM 248 247 static int sdhci_at91_runtime_suspend(struct device *dev) 249 248 { 250 249 struct sdhci_host *host = dev_get_drvdata(dev); ··· 299 302 sdhci_runtime_resume_host(host, 0); 300 303 return 0; 301 304 } 302 - #endif /* CONFIG_PM */ 303 305 304 306 static const struct dev_pm_ops sdhci_at91_dev_pm_ops = { 305 - SET_SYSTEM_SLEEP_PM_OPS(sdhci_at91_suspend, pm_runtime_force_resume) 306 - SET_RUNTIME_PM_OPS(sdhci_at91_runtime_suspend, 307 - sdhci_at91_runtime_resume, 308 - NULL) 307 + SYSTEM_SLEEP_PM_OPS(sdhci_at91_suspend, pm_runtime_force_resume) 308 + RUNTIME_PM_OPS(sdhci_at91_runtime_suspend, sdhci_at91_runtime_resume, NULL) 309 309 }; 310 310 311 311 static int sdhci_at91_probe(struct platform_device *pdev) ··· 454 460 .name = "sdhci-at91", 455 461 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 456 462 .of_match_table = sdhci_at91_dt_match, 457 - .pm = &sdhci_at91_dev_pm_ops, 463 + .pm = pm_ptr(&sdhci_at91_dev_pm_ops), 458 464 }, 459 465 .probe = sdhci_at91_probe, 460 466 .remove = sdhci_at91_remove,
+3 -10
drivers/mmc/host/sdhci-of-dwcmshc.c
··· 1499 1499 clk_bulk_disable_unprepare(priv->num_other_clks, priv->other_clks); 1500 1500 } 1501 1501 1502 - #ifdef CONFIG_PM_SLEEP 1503 1502 static int dwcmshc_suspend(struct device *dev) 1504 1503 { 1505 1504 struct sdhci_host *host = dev_get_drvdata(dev); ··· 1569 1570 clk_disable_unprepare(pltfm_host->clk); 1570 1571 return ret; 1571 1572 } 1572 - #endif 1573 - 1574 - #ifdef CONFIG_PM 1575 1573 1576 1574 static void dwcmshc_enable_card_clk(struct sdhci_host *host) 1577 1575 { ··· 1599 1603 return 0; 1600 1604 } 1601 1605 1602 - #endif 1603 - 1604 1606 static const struct dev_pm_ops dwcmshc_pmops = { 1605 - SET_SYSTEM_SLEEP_PM_OPS(dwcmshc_suspend, dwcmshc_resume) 1606 - SET_RUNTIME_PM_OPS(dwcmshc_runtime_suspend, 1607 - dwcmshc_runtime_resume, NULL) 1607 + SYSTEM_SLEEP_PM_OPS(dwcmshc_suspend, dwcmshc_resume) 1608 + RUNTIME_PM_OPS(dwcmshc_runtime_suspend, dwcmshc_runtime_resume, NULL) 1608 1609 }; 1609 1610 1610 1611 static struct platform_driver sdhci_dwcmshc_driver = { ··· 1610 1617 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1611 1618 .of_match_table = sdhci_dwcmshc_dt_ids, 1612 1619 .acpi_match_table = ACPI_PTR(sdhci_dwcmshc_acpi_ids), 1613 - .pm = &dwcmshc_pmops, 1620 + .pm = pm_ptr(&dwcmshc_pmops), 1614 1621 }, 1615 1622 .probe = dwcmshc_probe, 1616 1623 .remove = dwcmshc_remove,
+2 -6
drivers/mmc/host/sdhci-of-esdhc.c
··· 1234 1234 return intmask; 1235 1235 } 1236 1236 1237 - #ifdef CONFIG_PM_SLEEP 1238 1237 static u32 esdhc_proctl; 1239 1238 static int esdhc_of_suspend(struct device *dev) 1240 1239 { ··· 1259 1260 } 1260 1261 return ret; 1261 1262 } 1262 - #endif 1263 1263 1264 - static SIMPLE_DEV_PM_OPS(esdhc_of_dev_pm_ops, 1265 - esdhc_of_suspend, 1266 - esdhc_of_resume); 1264 + static DEFINE_SIMPLE_DEV_PM_OPS(esdhc_of_dev_pm_ops, esdhc_of_suspend, esdhc_of_resume); 1267 1265 1268 1266 static const struct sdhci_ops sdhci_esdhc_be_ops = { 1269 1267 .read_l = esdhc_be_readl, ··· 1507 1511 .name = "sdhci-esdhc", 1508 1512 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1509 1513 .of_match_table = sdhci_esdhc_of_match, 1510 - .pm = &esdhc_of_dev_pm_ops, 1514 + .pm = pm_sleep_ptr(&esdhc_of_dev_pm_ops), 1511 1515 }, 1512 1516 .probe = sdhci_esdhc_probe, 1513 1517 .remove = sdhci_pltfm_remove,
+7 -11
drivers/mmc/host/sdhci-omap.c
··· 1400 1400 pm_runtime_force_suspend(dev); 1401 1401 } 1402 1402 1403 - #ifdef CONFIG_PM 1404 - static void __maybe_unused sdhci_omap_context_save(struct sdhci_omap_host *omap_host) 1403 + static void sdhci_omap_context_save(struct sdhci_omap_host *omap_host) 1405 1404 { 1406 1405 omap_host->con = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON); 1407 1406 omap_host->hctl = sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL); ··· 1411 1412 } 1412 1413 1413 1414 /* Order matters here, HCTL must be restored in two phases */ 1414 - static void __maybe_unused sdhci_omap_context_restore(struct sdhci_omap_host *omap_host) 1415 + static void sdhci_omap_context_restore(struct sdhci_omap_host *omap_host) 1415 1416 { 1416 1417 sdhci_omap_writel(omap_host, SDHCI_OMAP_HCTL, omap_host->hctl); 1417 1418 sdhci_omap_writel(omap_host, SDHCI_OMAP_CAPA, omap_host->capa); ··· 1423 1424 sdhci_omap_writel(omap_host, SDHCI_OMAP_ISE, omap_host->ise); 1424 1425 } 1425 1426 1426 - static int __maybe_unused sdhci_omap_runtime_suspend(struct device *dev) 1427 + static int sdhci_omap_runtime_suspend(struct device *dev) 1427 1428 { 1428 1429 struct sdhci_host *host = dev_get_drvdata(dev); 1429 1430 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); ··· 1442 1443 return 0; 1443 1444 } 1444 1445 1445 - static int __maybe_unused sdhci_omap_runtime_resume(struct device *dev) 1446 + static int sdhci_omap_runtime_resume(struct device *dev) 1446 1447 { 1447 1448 struct sdhci_host *host = dev_get_drvdata(dev); 1448 1449 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); ··· 1457 1458 1458 1459 return 0; 1459 1460 } 1460 - #endif 1461 1461 1462 1462 static const struct dev_pm_ops sdhci_omap_dev_pm_ops = { 1463 - SET_RUNTIME_PM_OPS(sdhci_omap_runtime_suspend, 1464 - sdhci_omap_runtime_resume, NULL) 1465 - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 1466 - pm_runtime_force_resume) 1463 + RUNTIME_PM_OPS(sdhci_omap_runtime_suspend, sdhci_omap_runtime_resume, NULL) 1464 + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) 1467 1465 }; 1468 1466 1469 1467 static struct platform_driver sdhci_omap_driver = { ··· 1469 1473 .driver = { 1470 1474 .name = "sdhci-omap", 1471 1475 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1472 - .pm = &sdhci_omap_dev_pm_ops, 1476 + .pm = pm_ptr(&sdhci_omap_dev_pm_ops), 1473 1477 .of_match_table = omap_sdhci_match, 1474 1478 }, 1475 1479 };
+13 -2
drivers/mmc/host/sdhci-pci-core.c
··· 679 679 return 0; 680 680 } 681 681 682 + static void sdhci_intel_set_clock(struct sdhci_host *host, unsigned int clock) 683 + { 684 + u16 clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); 685 + 686 + /* Stop card clock separately to avoid glitches on clock line */ 687 + if (clk & SDHCI_CLOCK_CARD_EN) 688 + sdhci_writew(host, clk & ~SDHCI_CLOCK_CARD_EN, SDHCI_CLOCK_CONTROL); 689 + 690 + sdhci_set_clock(host, clock); 691 + } 692 + 682 693 static const struct sdhci_ops sdhci_intel_byt_ops = { 683 - .set_clock = sdhci_set_clock, 694 + .set_clock = sdhci_intel_set_clock, 684 695 .set_power = sdhci_intel_set_power, 685 696 .enable_dma = sdhci_pci_enable_dma, 686 697 .set_bus_width = sdhci_set_bus_width, ··· 701 690 }; 702 691 703 692 static const struct sdhci_ops sdhci_intel_glk_ops = { 704 - .set_clock = sdhci_set_clock, 693 + .set_clock = sdhci_intel_set_clock, 705 694 .set_power = sdhci_intel_set_power, 706 695 .enable_dma = sdhci_pci_enable_dma, 707 696 .set_bus_width = sdhci_set_bus_width,
+43 -9
drivers/mmc/host/sdhci-pxav3.c
··· 20 20 #include <linux/module.h> 21 21 #include <linux/of.h> 22 22 #include <linux/of_device.h> 23 + #include <linux/pinctrl/consumer.h> 23 24 #include <linux/pm.h> 24 25 #include <linux/pm_runtime.h> 25 26 #include <linux/mbus.h> 27 + #include <linux/units.h> 26 28 27 29 #include "sdhci.h" 28 30 #include "sdhci-pltfm.h" ··· 53 51 struct clk *clk_io; 54 52 u8 power_mode; 55 53 void __iomem *sdio3_conf_reg; 54 + struct pinctrl *pinctrl; 55 + struct pinctrl_state *pins_default; 56 + struct pinctrl_state *pins_uhs; 56 57 }; 57 58 58 59 /* ··· 318 313 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); 319 314 } 320 315 316 + static void pxav3_set_clock(struct sdhci_host *host, unsigned int clock) 317 + { 318 + struct sdhci_pltfm_host *phost = sdhci_priv(host); 319 + struct sdhci_pxa *pxa = sdhci_pltfm_priv(phost); 320 + struct pinctrl_state *pins = clock < 100 * HZ_PER_MHZ ? pxa->pins_default : pxa->pins_uhs; 321 + 322 + if (pins) 323 + pinctrl_select_state(pxa->pinctrl, pins); 324 + 325 + sdhci_set_clock(host, clock); 326 + } 327 + 321 328 static const struct sdhci_ops pxav3_sdhci_ops = { 322 - .set_clock = sdhci_set_clock, 329 + .set_clock = pxav3_set_clock, 323 330 .set_power = pxav3_set_power, 324 331 .platform_send_init_74_clocks = pxav3_gen_init_74_clocks, 325 332 .get_max_clock = sdhci_pltfm_clk_get_max_clock, ··· 382 365 return NULL; 383 366 } 384 367 #endif 368 + 369 + static struct pinctrl_state *pxav3_lookup_pinstate(struct device *dev, struct pinctrl *pinctrl, 370 + const char *name) 371 + { 372 + struct pinctrl_state *pins = pinctrl_lookup_state(pinctrl, name); 373 + 374 + if (IS_ERR(pins)) { 375 + dev_dbg(dev, "could not get pinstate '%s': %ld\n", name, PTR_ERR(pins)); 376 + return NULL; 377 + } 378 + 379 + return pins; 380 + } 385 381 386 382 static int sdhci_pxav3_probe(struct platform_device *pdev) 387 383 { ··· 470 440 host->mmc->pm_caps |= pdata->pm_caps; 471 441 } 472 442 443 + pxa->pinctrl = devm_pinctrl_get(dev); 444 + if (!IS_ERR(pxa->pinctrl)) { 445 + pxa->pins_default = pxav3_lookup_pinstate(dev, pxa->pinctrl, "default"); 446 + if (pxa->pins_default) 447 + pxa->pins_uhs = pxav3_lookup_pinstate(dev, pxa->pinctrl, "state_uhs"); 448 + } else { 449 + dev_dbg(dev, "could not get pinctrl handle: %ld\n", PTR_ERR(pxa->pinctrl)); 450 + } 451 + 473 452 pm_runtime_get_noresume(&pdev->dev); 474 453 pm_runtime_set_active(&pdev->dev); 475 454 pm_runtime_set_autosuspend_delay(&pdev->dev, PXAV3_RPM_DELAY_MS); ··· 523 484 clk_disable_unprepare(pxa->clk_core); 524 485 } 525 486 526 - #ifdef CONFIG_PM_SLEEP 527 487 static int sdhci_pxav3_suspend(struct device *dev) 528 488 { 529 489 int ret; ··· 548 510 549 511 return ret; 550 512 } 551 - #endif 552 513 553 - #ifdef CONFIG_PM 554 514 static int sdhci_pxav3_runtime_suspend(struct device *dev) 555 515 { 556 516 struct sdhci_host *host = dev_get_drvdata(dev); ··· 580 544 sdhci_runtime_resume_host(host, 0); 581 545 return 0; 582 546 } 583 - #endif 584 547 585 548 static const struct dev_pm_ops sdhci_pxav3_pmops = { 586 - SET_SYSTEM_SLEEP_PM_OPS(sdhci_pxav3_suspend, sdhci_pxav3_resume) 587 - SET_RUNTIME_PM_OPS(sdhci_pxav3_runtime_suspend, 588 - sdhci_pxav3_runtime_resume, NULL) 549 + SYSTEM_SLEEP_PM_OPS(sdhci_pxav3_suspend, sdhci_pxav3_resume) 550 + RUNTIME_PM_OPS(sdhci_pxav3_runtime_suspend, sdhci_pxav3_runtime_resume, NULL) 589 551 }; 590 552 591 553 static struct platform_driver sdhci_pxav3_driver = { ··· 591 557 .name = "sdhci-pxav3", 592 558 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 593 559 .of_match_table = of_match_ptr(sdhci_pxav3_of_match), 594 - .pm = &sdhci_pxav3_pmops, 560 + .pm = pm_ptr(&sdhci_pxav3_pmops), 595 561 }, 596 562 .probe = sdhci_pxav3_probe, 597 563 .remove = sdhci_pxav3_remove,
+3 -8
drivers/mmc/host/sdhci-s3c.c
··· 681 681 clk_disable_unprepare(sc->clk_io); 682 682 } 683 683 684 - #ifdef CONFIG_PM_SLEEP 685 684 static int sdhci_s3c_suspend(struct device *dev) 686 685 { 687 686 struct sdhci_host *host = dev_get_drvdata(dev); ··· 697 698 698 699 return sdhci_resume_host(host); 699 700 } 700 - #endif 701 701 702 - #ifdef CONFIG_PM 703 702 static int sdhci_s3c_runtime_suspend(struct device *dev) 704 703 { 705 704 struct sdhci_host *host = dev_get_drvdata(dev); ··· 727 730 sdhci_runtime_resume_host(host, 0); 728 731 return 0; 729 732 } 730 - #endif 731 733 732 734 static const struct dev_pm_ops sdhci_s3c_pmops = { 733 - SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume) 734 - SET_RUNTIME_PM_OPS(sdhci_s3c_runtime_suspend, sdhci_s3c_runtime_resume, 735 - NULL) 735 + SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume) 736 + RUNTIME_PM_OPS(sdhci_s3c_runtime_suspend, sdhci_s3c_runtime_resume, NULL) 736 737 }; 737 738 738 739 static const struct platform_device_id sdhci_s3c_driver_ids[] = { ··· 765 770 .name = "s3c-sdhci", 766 771 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 767 772 .of_match_table = of_match_ptr(sdhci_s3c_dt_match), 768 - .pm = &sdhci_s3c_pmops, 773 + .pm = pm_ptr(&sdhci_s3c_pmops), 769 774 }, 770 775 }; 771 776
+2 -4
drivers/mmc/host/sdhci-spear.c
··· 130 130 clk_disable_unprepare(sdhci->clk); 131 131 } 132 132 133 - #ifdef CONFIG_PM_SLEEP 134 133 static int sdhci_suspend(struct device *dev) 135 134 { 136 135 struct sdhci_host *host = dev_get_drvdata(dev); ··· 160 161 161 162 return sdhci_resume_host(host); 162 163 } 163 - #endif 164 164 165 - static SIMPLE_DEV_PM_OPS(sdhci_pm_ops, sdhci_suspend, sdhci_resume); 165 + static DEFINE_SIMPLE_DEV_PM_OPS(sdhci_pm_ops, sdhci_suspend, sdhci_resume); 166 166 167 167 static const struct of_device_id sdhci_spear_id_table[] = { 168 168 { .compatible = "st,spear300-sdhci" }, ··· 173 175 .driver = { 174 176 .name = "sdhci", 175 177 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 176 - .pm = &sdhci_pm_ops, 178 + .pm = pm_sleep_ptr(&sdhci_pm_ops), 177 179 .of_match_table = sdhci_spear_id_table, 178 180 }, 179 181 .probe = sdhci_probe,
+3 -7
drivers/mmc/host/sdhci-sprd.c
··· 903 903 }; 904 904 MODULE_DEVICE_TABLE(of, sdhci_sprd_of_match); 905 905 906 - #ifdef CONFIG_PM 907 906 static int sdhci_sprd_runtime_suspend(struct device *dev) 908 907 { 909 908 struct sdhci_host *host = dev_get_drvdata(dev); ··· 949 950 950 951 return ret; 951 952 } 952 - #endif 953 953 954 954 static const struct dev_pm_ops sdhci_sprd_pm_ops = { 955 - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 956 - pm_runtime_force_resume) 957 - SET_RUNTIME_PM_OPS(sdhci_sprd_runtime_suspend, 958 - sdhci_sprd_runtime_resume, NULL) 955 + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) 956 + RUNTIME_PM_OPS(sdhci_sprd_runtime_suspend, sdhci_sprd_runtime_resume, NULL) 959 957 }; 960 958 961 959 static struct platform_driver sdhci_sprd_driver = { ··· 962 966 .name = "sdhci_sprd_r11", 963 967 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 964 968 .of_match_table = sdhci_sprd_of_match, 965 - .pm = &sdhci_sprd_pm_ops, 969 + .pm = pm_ptr(&sdhci_sprd_pm_ops), 966 970 }, 967 971 }; 968 972 module_platform_driver(sdhci_sprd_driver);
+2 -4
drivers/mmc/host/sdhci-st.c
··· 445 445 reset_control_assert(rstc); 446 446 } 447 447 448 - #ifdef CONFIG_PM_SLEEP 449 448 static int sdhci_st_suspend(struct device *dev) 450 449 { 451 450 struct sdhci_host *host = dev_get_drvdata(dev); ··· 491 492 492 493 return sdhci_resume_host(host); 493 494 } 494 - #endif 495 495 496 - static SIMPLE_DEV_PM_OPS(sdhci_st_pmops, sdhci_st_suspend, sdhci_st_resume); 496 + static DEFINE_SIMPLE_DEV_PM_OPS(sdhci_st_pmops, sdhci_st_suspend, sdhci_st_resume); 497 497 498 498 static const struct of_device_id st_sdhci_match[] = { 499 499 { .compatible = "st,sdhci" }, ··· 507 509 .driver = { 508 510 .name = "sdhci-st", 509 511 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 510 - .pm = &sdhci_st_pmops, 512 + .pm = pm_sleep_ptr(&sdhci_st_pmops), 511 513 .of_match_table = st_sdhci_match, 512 514 }, 513 515 };
+5 -8
drivers/mmc/host/sdhci-tegra.c
··· 1831 1831 clk_disable_unprepare(tegra_host->tmclk); 1832 1832 } 1833 1833 1834 - static int __maybe_unused sdhci_tegra_runtime_suspend(struct device *dev) 1834 + static int sdhci_tegra_runtime_suspend(struct device *dev) 1835 1835 { 1836 1836 struct sdhci_host *host = dev_get_drvdata(dev); 1837 1837 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); ··· 1841 1841 return 0; 1842 1842 } 1843 1843 1844 - static int __maybe_unused sdhci_tegra_runtime_resume(struct device *dev) 1844 + static int sdhci_tegra_runtime_resume(struct device *dev) 1845 1845 { 1846 1846 struct sdhci_host *host = dev_get_drvdata(dev); 1847 1847 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); ··· 1849 1849 return clk_prepare_enable(pltfm_host->clk); 1850 1850 } 1851 1851 1852 - #ifdef CONFIG_PM_SLEEP 1853 1852 static int sdhci_tegra_suspend(struct device *dev) 1854 1853 { 1855 1854 struct sdhci_host *host = dev_get_drvdata(dev); ··· 1909 1910 pm_runtime_force_suspend(dev); 1910 1911 return ret; 1911 1912 } 1912 - #endif 1913 1913 1914 1914 static const struct dev_pm_ops sdhci_tegra_dev_pm_ops = { 1915 - SET_RUNTIME_PM_OPS(sdhci_tegra_runtime_suspend, sdhci_tegra_runtime_resume, 1916 - NULL) 1917 - SET_SYSTEM_SLEEP_PM_OPS(sdhci_tegra_suspend, sdhci_tegra_resume) 1915 + RUNTIME_PM_OPS(sdhci_tegra_runtime_suspend, sdhci_tegra_runtime_resume, NULL) 1916 + SYSTEM_SLEEP_PM_OPS(sdhci_tegra_suspend, sdhci_tegra_resume) 1918 1917 }; 1919 1918 1920 1919 static struct platform_driver sdhci_tegra_driver = { ··· 1920 1923 .name = "sdhci-tegra", 1921 1924 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1922 1925 .of_match_table = sdhci_tegra_dt_match, 1923 - .pm = &sdhci_tegra_dev_pm_ops, 1926 + .pm = pm_ptr(&sdhci_tegra_dev_pm_ops), 1924 1927 }, 1925 1928 .probe = sdhci_tegra_probe, 1926 1929 .remove = sdhci_tegra_remove,
+3 -10
drivers/mmc/host/sdhci-xenon.c
··· 622 622 clk_disable_unprepare(pltfm_host->clk); 623 623 } 624 624 625 - #ifdef CONFIG_PM_SLEEP 626 625 static int xenon_suspend(struct device *dev) 627 626 { 628 627 struct sdhci_host *host = dev_get_drvdata(dev); ··· 634 635 priv->restore_needed = true; 635 636 return ret; 636 637 } 637 - #endif 638 638 639 - #ifdef CONFIG_PM 640 639 static int xenon_runtime_suspend(struct device *dev) 641 640 { 642 641 struct sdhci_host *host = dev_get_drvdata(dev); ··· 682 685 clk_disable_unprepare(pltfm_host->clk); 683 686 return ret; 684 687 } 685 - #endif /* CONFIG_PM */ 686 688 687 689 static const struct dev_pm_ops sdhci_xenon_dev_pm_ops = { 688 - SET_SYSTEM_SLEEP_PM_OPS(xenon_suspend, 689 - pm_runtime_force_resume) 690 - SET_RUNTIME_PM_OPS(xenon_runtime_suspend, 691 - xenon_runtime_resume, 692 - NULL) 690 + SYSTEM_SLEEP_PM_OPS(xenon_suspend, pm_runtime_force_resume) 691 + RUNTIME_PM_OPS(xenon_runtime_suspend, xenon_runtime_resume, NULL) 693 692 }; 694 693 695 694 static const struct of_device_id sdhci_xenon_dt_ids[] = { ··· 714 721 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 715 722 .of_match_table = sdhci_xenon_dt_ids, 716 723 .acpi_match_table = ACPI_PTR(sdhci_xenon_acpi_ids), 717 - .pm = &sdhci_xenon_dev_pm_ops, 724 + .pm = pm_ptr(&sdhci_xenon_dev_pm_ops), 718 725 }, 719 726 .probe = xenon_probe, 720 727 .remove = xenon_remove,
+7
drivers/mmc/host/sdhci.h
··· 880 880 int sdhci_resume_host(struct sdhci_host *host); 881 881 void sdhci_runtime_suspend_host(struct sdhci_host *host); 882 882 void sdhci_runtime_resume_host(struct sdhci_host *host, int soft_reset); 883 + #else 884 + static inline bool sdhci_enable_irq_wakeups(struct sdhci_host *host) { return false; } 885 + static inline void sdhci_disable_irq_wakeups(struct sdhci_host *host) {} 886 + static inline int sdhci_suspend_host(struct sdhci_host *host) { return -EOPNOTSUPP; } 887 + static inline int sdhci_resume_host(struct sdhci_host *host) { return -EOPNOTSUPP; } 888 + static inline void sdhci_runtime_suspend_host(struct sdhci_host *host) {} 889 + static inline void sdhci_runtime_resume_host(struct sdhci_host *host, int soft_reset) {} 883 890 #endif 884 891 885 892 void sdhci_cqe_enable(struct mmc_host *mmc);
+3 -8
drivers/mmc/host/sdhci_am654.c
··· 95 95 .reg_bits = 32, 96 96 .val_bits = 32, 97 97 .reg_stride = 4, 98 - .fast_io = true, 99 98 }; 100 99 101 100 struct timing_data { ··· 1035 1036 pm_runtime_put_noidle(dev); 1036 1037 } 1037 1038 1038 - #ifdef CONFIG_PM 1039 1039 static int sdhci_am654_restore(struct sdhci_host *host) 1040 1040 { 1041 1041 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); ··· 1122 1124 1123 1125 return 0; 1124 1126 } 1125 - #endif 1126 1127 1127 1128 static const struct dev_pm_ops sdhci_am654_dev_pm_ops = { 1128 - SET_RUNTIME_PM_OPS(sdhci_am654_runtime_suspend, 1129 - sdhci_am654_runtime_resume, NULL) 1130 - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 1131 - pm_runtime_force_resume) 1129 + RUNTIME_PM_OPS(sdhci_am654_runtime_suspend, sdhci_am654_runtime_resume, NULL) 1130 + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) 1132 1131 }; 1133 1132 1134 1133 static struct platform_driver sdhci_am654_driver = { 1135 1134 .driver = { 1136 1135 .name = "sdhci-am654", 1137 1136 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1138 - .pm = &sdhci_am654_dev_pm_ops, 1137 + .pm = pm_ptr(&sdhci_am654_dev_pm_ops), 1139 1138 .of_match_table = sdhci_am654_of_match, 1140 1139 }, 1141 1140 .probe = sdhci_am654_probe,
+2 -11
drivers/mmc/host/sh_mmcif.c
··· 1568 1568 pm_runtime_disable(&pdev->dev); 1569 1569 } 1570 1570 1571 - #ifdef CONFIG_PM_SLEEP 1572 1571 static int sh_mmcif_suspend(struct device *dev) 1573 1572 { 1574 1573 struct sh_mmcif_host *host = dev_get_drvdata(dev); ··· 1579 1580 return 0; 1580 1581 } 1581 1582 1582 - static int sh_mmcif_resume(struct device *dev) 1583 - { 1584 - return 0; 1585 - } 1586 - #endif 1587 - 1588 - static const struct dev_pm_ops sh_mmcif_dev_pm_ops = { 1589 - SET_SYSTEM_SLEEP_PM_OPS(sh_mmcif_suspend, sh_mmcif_resume) 1590 - }; 1583 + static DEFINE_SIMPLE_DEV_PM_OPS(sh_mmcif_dev_pm_ops, sh_mmcif_suspend, NULL); 1591 1584 1592 1585 static struct platform_driver sh_mmcif_driver = { 1593 1586 .probe = sh_mmcif_probe, ··· 1587 1596 .driver = { 1588 1597 .name = DRIVER_NAME, 1589 1598 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1590 - .pm = &sh_mmcif_dev_pm_ops, 1599 + .pm = pm_sleep_ptr(&sh_mmcif_dev_pm_ops), 1591 1600 .of_match_table = sh_mmcif_of_match, 1592 1601 }, 1593 1602 };
+3 -8
drivers/mmc/host/sunxi-mmc.c
··· 1495 1495 dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma); 1496 1496 } 1497 1497 1498 - #ifdef CONFIG_PM 1499 1498 static int sunxi_mmc_runtime_resume(struct device *dev) 1500 1499 { 1501 1500 struct mmc_host *mmc = dev_get_drvdata(dev); ··· 1529 1530 1530 1531 return 0; 1531 1532 } 1532 - #endif 1533 1533 1534 1534 static const struct dev_pm_ops sunxi_mmc_pm_ops = { 1535 - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 1536 - pm_runtime_force_resume) 1537 - SET_RUNTIME_PM_OPS(sunxi_mmc_runtime_suspend, 1538 - sunxi_mmc_runtime_resume, 1539 - NULL) 1535 + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) 1536 + RUNTIME_PM_OPS(sunxi_mmc_runtime_suspend, sunxi_mmc_runtime_resume, NULL) 1540 1537 }; 1541 1538 1542 1539 static struct platform_driver sunxi_mmc_driver = { ··· 1540 1545 .name = "sunxi-mmc", 1541 1546 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 1542 1547 .of_match_table = sunxi_mmc_of_match, 1543 - .pm = &sunxi_mmc_pm_ops, 1548 + .pm = pm_ptr(&sunxi_mmc_pm_ops), 1544 1549 }, 1545 1550 .probe = sunxi_mmc_probe, 1546 1551 .remove = sunxi_mmc_remove,
+15
drivers/mmc/host/tmio_mmc.h
··· 16 16 17 17 #include <linux/dmaengine.h> 18 18 #include <linux/highmem.h> 19 + #include <linux/io.h> 19 20 #include <linux/mutex.h> 20 21 #include <linux/pagemap.h> 21 22 #include <linux/scatterlist.h> ··· 242 241 { 243 242 ioread32_rep(host->ctl + (addr << host->bus_shift), buf, count); 244 243 } 244 + 245 + #ifdef CONFIG_64BIT 246 + static inline void sd_ctrl_read64_rep(struct tmio_mmc_host *host, int addr, 247 + u64 *buf, int count) 248 + { 249 + readsq(host->ctl + (addr << host->bus_shift), buf, count); 250 + } 251 + 252 + static inline void sd_ctrl_write64_rep(struct tmio_mmc_host *host, int addr, 253 + const u64 *buf, int count) 254 + { 255 + writesq(host->ctl + (addr << host->bus_shift), buf, count); 256 + } 257 + #endif 245 258 246 259 static inline void sd_ctrl_write16(struct tmio_mmc_host *host, int addr, 247 260 u16 val)
+33
drivers/mmc/host/tmio_mmc_core.c
··· 349 349 /* 350 350 * Transfer the data 351 351 */ 352 + #ifdef CONFIG_64BIT 353 + if (host->pdata->flags & TMIO_MMC_64BIT_DATA_PORT) { 354 + u64 *buf64 = (u64 *)buf; 355 + u64 data = 0; 356 + 357 + if (count >= 8) { 358 + if (is_read) 359 + sd_ctrl_read64_rep(host, CTL_SD_DATA_PORT, 360 + buf64, count >> 3); 361 + else 362 + sd_ctrl_write64_rep(host, CTL_SD_DATA_PORT, 363 + buf64, count >> 3); 364 + } 365 + 366 + /* if count was multiple of 8 */ 367 + if (!(count & 0x7)) 368 + return; 369 + 370 + buf64 += count >> 3; 371 + count %= 8; 372 + 373 + if (is_read) { 374 + sd_ctrl_read64_rep(host, CTL_SD_DATA_PORT, &data, 1); 375 + memcpy(buf64, &data, count); 376 + } else { 377 + memcpy(&data, buf64, count); 378 + sd_ctrl_write64_rep(host, CTL_SD_DATA_PORT, &data, 1); 379 + } 380 + 381 + return; 382 + } 383 + #endif 384 + 352 385 if (host->pdata->flags & TMIO_MMC_32BIT_DATA_PORT) { 353 386 u32 data = 0; 354 387 u32 *buf32 = (u32 *)buf;
+2 -6
drivers/mmc/host/toshsd.c
··· 567 567 pci_write_config_byte(host->pdev, SD_PCICFG_CLKSTOP, 0); 568 568 } 569 569 570 - #ifdef CONFIG_PM_SLEEP 571 570 static int toshsd_pm_suspend(struct device *dev) 572 571 { 573 572 struct pci_dev *pdev = to_pci_dev(dev); ··· 598 599 599 600 return 0; 600 601 } 601 - #endif /* CONFIG_PM_SLEEP */ 602 602 603 603 static int toshsd_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 604 604 { ··· 686 688 pci_disable_device(pdev); 687 689 } 688 690 689 - static const struct dev_pm_ops toshsd_pm_ops = { 690 - SET_SYSTEM_SLEEP_PM_OPS(toshsd_pm_suspend, toshsd_pm_resume) 691 - }; 691 + static DEFINE_SIMPLE_DEV_PM_OPS(toshsd_pm_ops, toshsd_pm_suspend, toshsd_pm_resume); 692 692 693 693 static struct pci_driver toshsd_driver = { 694 694 .name = DRIVER_NAME, 695 695 .id_table = pci_ids, 696 696 .probe = toshsd_probe, 697 697 .remove = toshsd_remove, 698 - .driver.pm = &toshsd_pm_ops, 698 + .driver.pm = pm_sleep_ptr(&toshsd_pm_ops), 699 699 }; 700 700 701 701 module_pci_driver(toshsd_driver);
+5 -5
drivers/mmc/host/via-sdmmc.c
··· 1218 1218 pci_name(pcidev), (int)pcidev->vendor, (int)pcidev->device); 1219 1219 } 1220 1220 1221 - static void __maybe_unused via_init_sdc_pm(struct via_crdr_mmc_host *host) 1221 + static void via_init_sdc_pm(struct via_crdr_mmc_host *host) 1222 1222 { 1223 1223 struct sdhcreg *pm_sdhcreg; 1224 1224 void __iomem *addrbase; ··· 1252 1252 via_print_sdchc(host); 1253 1253 } 1254 1254 1255 - static int __maybe_unused via_sd_suspend(struct device *dev) 1255 + static int via_sd_suspend(struct device *dev) 1256 1256 { 1257 1257 struct via_crdr_mmc_host *host; 1258 1258 unsigned long flags; ··· 1269 1269 return 0; 1270 1270 } 1271 1271 1272 - static int __maybe_unused via_sd_resume(struct device *dev) 1272 + static int via_sd_resume(struct device *dev) 1273 1273 { 1274 1274 struct via_crdr_mmc_host *sdhost; 1275 1275 u8 gatt; ··· 1295 1295 return 0; 1296 1296 } 1297 1297 1298 - static SIMPLE_DEV_PM_OPS(via_sd_pm_ops, via_sd_suspend, via_sd_resume); 1298 + static DEFINE_SIMPLE_DEV_PM_OPS(via_sd_pm_ops, via_sd_suspend, via_sd_resume); 1299 1299 1300 1300 static struct pci_driver via_sd_driver = { 1301 1301 .name = DRV_NAME, 1302 1302 .id_table = via_ids, 1303 1303 .probe = via_sd_probe, 1304 1304 .remove = via_sd_remove, 1305 - .driver.pm = &via_sd_pm_ops, 1305 + .driver.pm = pm_sleep_ptr(&via_sd_pm_ops), 1306 1306 }; 1307 1307 1308 1308 module_pci_driver(via_sd_driver);
+2 -14
drivers/mmc/host/wmt-sdmmc.c
··· 911 911 dev_info(&pdev->dev, "WMT MCI device removed\n"); 912 912 } 913 913 914 - #ifdef CONFIG_PM 915 914 static int wmt_mci_suspend(struct device *dev) 916 915 { 917 916 u32 reg_tmp; ··· 962 963 return 0; 963 964 } 964 965 965 - static const struct dev_pm_ops wmt_mci_pm = { 966 - .suspend = wmt_mci_suspend, 967 - .resume = wmt_mci_resume, 968 - }; 969 - 970 - #define wmt_mci_pm_ops (&wmt_mci_pm) 971 - 972 - #else /* !CONFIG_PM */ 973 - 974 - #define wmt_mci_pm_ops NULL 975 - 976 - #endif 966 + static DEFINE_SIMPLE_DEV_PM_OPS(wmt_mci_pm_ops, wmt_mci_suspend, wmt_mci_resume); 977 967 978 968 static struct platform_driver wmt_mci_driver = { 979 969 .probe = wmt_mci_probe, ··· 970 982 .driver = { 971 983 .name = DRIVER_NAME, 972 984 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 973 - .pm = wmt_mci_pm_ops, 985 + .pm = pm_sleep_ptr(&wmt_mci_pm_ops), 974 986 .of_match_table = wmt_mci_dt_ids, 975 987 }, 976 988 };
+13
include/linux/mmc/host.h
··· 337 337 338 338 struct regulator; 339 339 struct mmc_pwrseq; 340 + struct notifier_block; 340 341 341 342 struct mmc_supply { 342 343 struct regulator *vmmc; /* Card power supply */ 343 344 struct regulator *vqmmc; /* Optional Vccq supply */ 344 345 struct regulator *vqmmc2; /* Optional supply for phy */ 346 + 347 + struct notifier_block vmmc_nb; /* Notifier for vmmc */ 348 + struct work_struct uv_work; /* Undervoltage work */ 345 349 }; 346 350 347 351 struct mmc_ctx { ··· 498 494 unsigned int can_dma_map_merge:1; /* merging can be used */ 499 495 unsigned int vqmmc_enabled:1; /* vqmmc regulator is enabled */ 500 496 497 + /* 498 + * Indicates if an undervoltage event has already been handled. 499 + * This prevents repeated regulator notifiers from triggering 500 + * multiple REGULATOR_EVENT_UNDER_VOLTAGE events. 501 + */ 502 + unsigned int undervoltage:1; /* Undervoltage state */ 503 + 501 504 int rescan_disable; /* disable card detection */ 502 505 int rescan_entered; /* used with nonremovable devices */ 503 506 ··· 576 565 int hsq_depth; 577 566 578 567 u32 err_stats[MMC_ERR_MAX]; 568 + u32 max_sd_hs_hz; 579 569 unsigned long private[] ____cacheline_aligned; 580 570 }; 581 571 ··· 755 743 int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error); 756 744 int mmc_send_abort_tuning(struct mmc_host *host, u32 opcode); 757 745 int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd); 746 + int mmc_read_tuning(struct mmc_host *host, unsigned int blksz, unsigned int blocks); 758 747 759 748 #endif /* LINUX_MMC_HOST_H */
+3
include/linux/platform_data/tmio.h
··· 47 47 /* Some controllers have a CBSY bit */ 48 48 #define TMIO_MMC_HAVE_CBSY BIT(11) 49 49 50 + /* Some controllers have a 64-bit wide data port register */ 51 + #define TMIO_MMC_64BIT_DATA_PORT BIT(12) 52 + 50 53 struct tmio_mmc_data { 51 54 void *chan_priv_tx; 52 55 void *chan_priv_rx;
+11
include/linux/rtsx_usb.h
··· 99 99 #define CD_MASK (SD_CD | MS_CD | XD_CD) 100 100 #define SD_WP 0x08 101 101 102 + /* OCPCTL */ 103 + #define MS_OCP_DETECT_EN 0x08 104 + #define MS_OCP_INT_EN 0x04 105 + #define MS_OCP_INT_CLR 0x02 106 + #define MS_OCP_CLEAR 0x01 107 + 108 + /* OCPSTAT */ 109 + #define MS_OCP_DETECT 0x80 110 + #define MS_OCP_NOW 0x02 111 + #define MS_OCP_EVER 0x01 112 + 102 113 /* reader command field offset & parameters */ 103 114 #define READ_REG_CMD 0 104 115 #define WRITE_REG_CMD 1