Skip to content

Commit 2d27453

Browse files
committed
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 ...
2 parents e93bcba + 7aada81 commit 2d27453

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+754
-364
lines changed

Documentation/devicetree/bindings/mmc/fsl,esdhc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ required:
9090

9191
allOf:
9292
- $ref: sdhci-common.yaml#
93+
- $ref: mmc-controller-common.yaml#
9394

9495
unevaluatedProperties: false
9596

Documentation/devicetree/bindings/mmc/mmc-controller-common.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ properties:
9393
minimum: 400000
9494
maximum: 384000000
9595

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+
96104
disable-wp:
97105
$ref: /schemas/types.yaml#/definitions/flag
98106
description:

Documentation/devicetree/bindings/mmc/samsung,exynos-dw-mshc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ properties:
3131
- samsung,exynos5433-dw-mshc-smu
3232
- samsung,exynos7885-dw-mshc-smu
3333
- samsung,exynos850-dw-mshc-smu
34+
- samsung,exynos8890-dw-mshc-smu
3435
- samsung,exynos8895-dw-mshc-smu
3536
- const: samsung,exynos7-dw-mshc-smu
3637

Documentation/devicetree/bindings/mmc/sdhci-msm.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ properties:
4848
- qcom,qcs615-sdhci
4949
- qcom,qcs8300-sdhci
5050
- qcom,qdu1000-sdhci
51+
- qcom,sa8775p-sdhci
5152
- qcom,sar2130p-sdhci
5253
- qcom,sc7180-sdhci
5354
- qcom,sc7280-sdhci

Documentation/devicetree/bindings/mmc/sdhci-pxa.yaml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,29 @@ allOf:
4444
items:
4545
- const: default
4646
- const: state_cmd_gpio
47-
pinctrl-0:
48-
description:
49-
Should contain default pinctrl.
47+
minItems: 1
48+
5049
pinctrl-1:
5150
description:
5251
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.
5370

5471
properties:
5572
compatible:
@@ -82,6 +99,14 @@ properties:
8299
- const: io
83100
- const: core
84101

102+
pinctrl-names: true
103+
104+
pinctrl-0:
105+
description:
106+
Should contain default pinctrl.
107+
108+
pinctrl-1: true
109+
85110
mrvl,clk-delay-cycles:
86111
description: Specify a number of cycles to delay for tuning.
87112
$ref: /schemas/types.yaml#/definitions/uint32

drivers/memstick/core/memstick.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,9 @@ int memstick_set_rw_addr(struct memstick_dev *card)
370370
{
371371
card->next_request = h_memstick_set_rw_addr;
372372
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;
374376

375377
return card->current_mrq.error;
376378
}
@@ -404,7 +406,9 @@ static struct memstick_dev *memstick_alloc_card(struct memstick_host *host)
404406

405407
card->next_request = h_memstick_read_dev_id;
406408
memstick_new_req(host);
407-
wait_for_completion(&card->mrq_complete);
409+
if (!wait_for_completion_timeout(&card->mrq_complete,
410+
msecs_to_jiffies(500)))
411+
card->current_mrq.error = -ETIMEDOUT;
408412

409413
if (card->current_mrq.error)
410414
goto err_out;

drivers/memstick/host/rtsx_usb_ms.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ static int ms_power_off(struct rtsx_usb_ms *host)
216216

217217
rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_CLK_EN, MS_CLK_EN, 0);
218218
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);
220223
err = rtsx_usb_send_cmd(ucr, MODE_C, 100);
221224
if (err < 0)
222225
return err;

drivers/misc/cardreader/rtsx_usb.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,10 @@ static int rtsx_usb_reset_chip(struct rtsx_ucr *ucr)
552552
ret = rtsx_usb_send_cmd(ucr, MODE_C, 100);
553553
if (ret)
554554
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);
555559

556560
/* config non-crystal mode */
557561
rtsx_usb_read_register(ucr, CFG_MODE, &val);
@@ -722,6 +726,9 @@ static int rtsx_usb_suspend(struct usb_interface *intf, pm_message_t message)
722726
if (val & (SD_CD | MS_CD)) {
723727
device_for_each_child(&intf->dev, NULL, rtsx_usb_resume_child);
724728
return -EAGAIN;
729+
} else {
730+
/* if the card does not exists, clear OCP status */
731+
rtsx_usb_write_register(ucr, OCPCTL, MS_OCP_CLEAR, MS_OCP_CLEAR);
725732
}
726733
} else {
727734
/* There is an ongoing operation*/

drivers/mmc/core/block.c

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ struct rpmb_frame {
121121
#define RPMB_READ_DATA 0x4 /* Read data from RPMB partition */
122122
#define RPMB_RESULT_READ 0x5 /* Read result request (Internal) */
123123

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+
124128
static DEFINE_MUTEX(block_mutex);
125129

126130
/*
@@ -1768,8 +1772,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
17681772
* these, while retaining features like reliable writes.
17691773
*/
17701774
if ((md->flags & MMC_BLK_CMD23) && mmc_op_multi(brq->cmd.opcode) &&
1771-
(do_rel_wr || !(card->quirks & MMC_QUIRK_BLK_NO_CMD23) ||
1772-
do_data_tag)) {
1775+
(do_rel_wr || !mmc_card_blk_no_cmd23(card) || do_data_tag)) {
17731776
brq->sbc.opcode = MMC_SET_BLOCK_COUNT;
17741777
brq->sbc.arg = brq->data.blocks |
17751778
(do_rel_wr ? (1 << 31) : 0) |
@@ -2618,13 +2621,8 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
26182621
*/
26192622
md->read_only = mmc_blk_readonly(card);
26202623

2621-
if (mmc_host_can_cmd23(card->host)) {
2622-
if ((mmc_card_mmc(card) &&
2623-
card->csd.mmca_vsn >= CSD_SPEC_VER_3) ||
2624-
(mmc_card_sd(card) && !mmc_card_ult_capacity(card) &&
2625-
card->scr.cmds & SD_SCR_CMD23_SUPPORT))
2626-
md->flags |= MMC_BLK_CMD23;
2627-
}
2624+
if (mmc_host_can_cmd23(card->host) && mmc_card_can_cmd23(card))
2625+
md->flags |= MMC_BLK_CMD23;
26282626

26292627
if (md->flags & MMC_BLK_CMD23 &&
26302628
((card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) ||
@@ -2864,12 +2862,12 @@ static void set_idata(struct mmc_blk_ioc_data *idata, u32 opcode,
28642862
* The size of an RPMB frame must match what's expected by the
28652863
* hardware.
28662864
*/
2867-
BUILD_BUG_ON(sizeof(struct rpmb_frame) != 512);
2865+
static_assert(!CHECK_SIZE_NEQ(512), "RPMB frame size must be 512 bytes");
28682866

28692867
idata->ic.opcode = opcode;
28702868
idata->ic.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
28712869
idata->ic.write_flag = write_flag;
2872-
idata->ic.blksz = sizeof(struct rpmb_frame);
2870+
idata->ic.blksz = RPMB_FRAME_SIZE;
28732871
idata->ic.blocks = buf_bytes / idata->ic.blksz;
28742872
idata->buf = buf;
28752873
idata->buf_bytes = buf_bytes;
@@ -2893,58 +2891,52 @@ static int mmc_route_rpmb_frames(struct device *dev, u8 *req,
28932891
if (IS_ERR(md->queue.card))
28942892
return PTR_ERR(md->queue.card);
28952893

2896-
if (req_len < sizeof(*frm))
2894+
if (req_len < RPMB_FRAME_SIZE)
28972895
return -EINVAL;
28982896

28992897
req_type = be16_to_cpu(frm->req_resp);
29002898
switch (req_type) {
29012899
case RPMB_PROGRAM_KEY:
2902-
if (req_len != sizeof(struct rpmb_frame) ||
2903-
resp_len != sizeof(struct rpmb_frame))
2900+
if (CHECK_SIZE_NEQ(req_len) || CHECK_SIZE_NEQ(resp_len))
29042901
return -EINVAL;
29052902
write = true;
29062903
break;
29072904
case RPMB_GET_WRITE_COUNTER:
2908-
if (req_len != sizeof(struct rpmb_frame) ||
2909-
resp_len != sizeof(struct rpmb_frame))
2905+
if (CHECK_SIZE_NEQ(req_len) || CHECK_SIZE_NEQ(resp_len))
29102906
return -EINVAL;
29112907
write = false;
29122908
break;
29132909
case RPMB_WRITE_DATA:
2914-
if (req_len % sizeof(struct rpmb_frame) ||
2915-
resp_len != sizeof(struct rpmb_frame))
2910+
if (!CHECK_SIZE_ALIGNED(req_len) || CHECK_SIZE_NEQ(resp_len))
29162911
return -EINVAL;
29172912
write = true;
29182913
break;
29192914
case RPMB_READ_DATA:
2920-
if (req_len != sizeof(struct rpmb_frame) ||
2921-
resp_len % sizeof(struct rpmb_frame))
2915+
if (CHECK_SIZE_NEQ(req_len) || !CHECK_SIZE_ALIGNED(resp_len))
29222916
return -EINVAL;
29232917
write = false;
29242918
break;
29252919
default:
29262920
return -EINVAL;
29272921
}
29282922

2929-
if (write)
2930-
cmd_count = 3;
2931-
else
2932-
cmd_count = 2;
2923+
/* Write operations require 3 commands, read operations require 2 */
2924+
cmd_count = write ? 3 : 2;
29332925

29342926
idata = alloc_idata(rpmb, cmd_count);
29352927
if (!idata)
29362928
return -ENOMEM;
29372929

29382930
if (write) {
2939-
struct rpmb_frame *frm = (struct rpmb_frame *)resp;
2931+
struct rpmb_frame *resp_frm = (struct rpmb_frame *)resp;
29402932

29412933
/* Send write request frame(s) */
29422934
set_idata(idata[0], MMC_WRITE_MULTIPLE_BLOCK,
29432935
1 | MMC_CMD23_ARG_REL_WR, req, req_len);
29442936

29452937
/* Send result request frame */
2946-
memset(frm, 0, sizeof(*frm));
2947-
frm->req_resp = cpu_to_be16(RPMB_RESULT_READ);
2938+
memset(resp_frm, 0, RPMB_FRAME_SIZE);
2939+
resp_frm->req_resp = cpu_to_be16(RPMB_RESULT_READ);
29482940
set_idata(idata[1], MMC_WRITE_MULTIPLE_BLOCK, 1, resp,
29492941
resp_len);
29502942

drivers/mmc/core/bus.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <linux/mmc/card.h>
2121
#include <linux/mmc/host.h>
22+
#include <linux/mmc/mmc.h>
2223

2324
#include "core.h"
2425
#include "card.h"
@@ -383,6 +384,14 @@ int mmc_add_card(struct mmc_card *card)
383384

384385
mmc_card_set_present(card);
385386

387+
/*
388+
* Register for undervoltage notification if the card supports
389+
* power-off notification, enabling emergency shutdowns.
390+
*/
391+
if (mmc_card_mmc(card) &&
392+
card->ext_csd.power_off_notification == EXT_CSD_POWER_ON)
393+
mmc_regulator_register_undervoltage_notifier(card->host);
394+
386395
return 0;
387396
}
388397

@@ -394,6 +403,9 @@ void mmc_remove_card(struct mmc_card *card)
394403
{
395404
struct mmc_host *host = card->host;
396405

406+
if (mmc_card_present(card))
407+
mmc_regulator_unregister_undervoltage_notifier(host);
408+
397409
mmc_remove_card_debugfs(card);
398410

399411
if (mmc_card_present(card)) {

0 commit comments

Comments
 (0)