Skip to content

Commit bac8068

Browse files
Wenchao Chenstorulf
authored andcommitted
mmc: core: Add host specific tuning support for SD HS mode
To support the need for host specific tuning for SD high-speed mode, let's add two new optional callbacks, ->prepare|execute_sd_hs_tuning() and let's call them when switching into the SD high-speed mode. Note that, during the tuning process it's also needed for host drivers to send commands to the SD card to verify that the tuning process succeeds. Therefore, let's also share the corresponding functions from the core to allow this. Signed-off-by: Wenchao Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] [Ulf: Dropped unnecessary function declarations and updated the commit msg] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 48fe8fa commit bac8068

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

drivers/mmc/core/mmc_ops.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ int mmc_send_adtc_data(struct mmc_card *card, struct mmc_host *host, u32 opcode,
3232
u32 args, void *buf, unsigned len);
3333
int mmc_send_csd(struct mmc_card *card, u32 *csd);
3434
int __mmc_send_status(struct mmc_card *card, u32 *status, unsigned int retries);
35-
int mmc_send_status(struct mmc_card *card, u32 *status);
3635
int mmc_send_cid(struct mmc_host *host, u32 *cid);
3736
int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp);
3837
int mmc_spi_set_crc(struct mmc_host *host, int use_crc);

drivers/mmc/core/sd.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,13 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
15181518
*/
15191519
mmc_set_clock(host, mmc_sd_get_max_clock(card));
15201520

1521+
if (host->ios.timing == MMC_TIMING_SD_HS &&
1522+
host->ops->prepare_sd_hs_tuning) {
1523+
err = host->ops->prepare_sd_hs_tuning(host, card);
1524+
if (err)
1525+
goto free_card;
1526+
}
1527+
15211528
/*
15221529
* Switch to wider bus (if supported).
15231530
*/
@@ -1529,6 +1536,13 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
15291536

15301537
mmc_set_bus_width(host, MMC_BUS_WIDTH_4);
15311538
}
1539+
1540+
if (host->ios.timing == MMC_TIMING_SD_HS &&
1541+
host->ops->execute_sd_hs_tuning) {
1542+
err = host->ops->execute_sd_hs_tuning(host, card);
1543+
if (err)
1544+
goto free_card;
1545+
}
15321546
}
15331547
cont:
15341548
if (!oldcard) {

drivers/mmc/core/sd_ops.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ int mmc_sd_switch(struct mmc_card *card, int mode, int group,
323323
return mmc_send_adtc_data(card, card->host, SD_SWITCH, cmd_args, resp,
324324
64);
325325
}
326+
EXPORT_SYMBOL_GPL(mmc_sd_switch);
326327

327328
int mmc_app_sd_status(struct mmc_card *card, void *ssr)
328329
{

drivers/mmc/core/sd_ops.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ int mmc_send_if_cond(struct mmc_host *host, u32 ocr);
1919
int mmc_send_if_cond_pcie(struct mmc_host *host, u32 ocr);
2020
int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca);
2121
int mmc_app_send_scr(struct mmc_card *card);
22-
int mmc_sd_switch(struct mmc_card *card, int mode, int group,
23-
u8 value, u8 *resp);
2422
int mmc_app_sd_status(struct mmc_card *card, void *ssr);
2523
int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card);
2624

include/linux/mmc/host.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ struct mmc_host_ops {
184184
/* Execute HS400 tuning depending host driver */
185185
int (*execute_hs400_tuning)(struct mmc_host *host, struct mmc_card *card);
186186

187+
/* Optional callback to prepare for SD high-speed tuning */
188+
int (*prepare_sd_hs_tuning)(struct mmc_host *host, struct mmc_card *card);
189+
190+
/* Optional callback to execute SD high-speed tuning */
191+
int (*execute_sd_hs_tuning)(struct mmc_host *host, struct mmc_card *card);
192+
187193
/* Prepare switch to DDR during the HS400 init sequence */
188194
int (*hs400_prepare_ddr)(struct mmc_host *host);
189195

@@ -665,6 +671,8 @@ static inline void mmc_debugfs_err_stats_inc(struct mmc_host *host,
665671
host->err_stats[stat] += 1;
666672
}
667673

674+
int mmc_sd_switch(struct mmc_card *card, int mode, int group, u8 value, u8 *resp);
675+
int mmc_send_status(struct mmc_card *card, u32 *status);
668676
int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
669677
int mmc_send_abort_tuning(struct mmc_host *host, u32 opcode);
670678
int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd);

0 commit comments

Comments
 (0)