Skip to content

Commit

Permalink
mmc: core: more fine-grained hooks for HS400 tuning
Browse files Browse the repository at this point in the history
This adds two new HS400 tuning operations:
* hs400_downgrade
* hs400_complete

These supplement the existing HS400 operation:
* prepare_hs400_tuning

This is motivated by a requirement of Renesas SDHI for the following:
1. Disabling SCC before selecting to HS if selection of HS400 has occurred.
   This can be done in an implementation of prepare_hs400_tuning_downgrade
2. Updating registers after switching to HS400
   This can be done in an implementation of complete_hs400_tuning

If hs400_downgrade or hs400_complete are not implemented then they are not
called. Thus means there should be no affect for existing drivers as none
implemt these ops.

Signed-off-by: Simon Horman <[email protected]>
Signed-off-by: Ulf Hansson <[email protected]>
  • Loading branch information
horms authored and storulf committed Jul 16, 2018
1 parent ecf7c7c commit ba6c7ac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/mmc/core/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,10 @@ static int mmc_select_hs400(struct mmc_card *card)
/* Set host controller to HS timing */
mmc_set_timing(card->host, MMC_TIMING_MMC_HS);

/* Prepare host to downgrade to HS timing */
if (host->ops->hs400_downgrade)
host->ops->hs400_downgrade(host);

/* Reduce frequency to HS frequency */
max_dtr = card->ext_csd.hs_max_dtr;
mmc_set_clock(host, max_dtr);
Expand Down Expand Up @@ -1209,6 +1213,9 @@ static int mmc_select_hs400(struct mmc_card *card)
if (err)
goto out_err;

if (host->ops->hs400_complete)
host->ops->hs400_complete(host);

return 0;

out_err:
Expand Down Expand Up @@ -1256,6 +1263,9 @@ int mmc_hs400_to_hs200(struct mmc_card *card)

mmc_set_timing(host, MMC_TIMING_MMC_HS);

if (host->ops->hs400_downgrade)
host->ops->hs400_downgrade(host);

err = mmc_switch_status(card);
if (err)
goto out_err;
Expand Down
7 changes: 7 additions & 0 deletions include/linux/mmc/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ struct mmc_host_ops {

/* Prepare HS400 target operating frequency depending host driver */
int (*prepare_hs400_tuning)(struct mmc_host *host, struct mmc_ios *ios);

/* Prepare for switching from HS400 to HS200 */
void (*hs400_downgrade)(struct mmc_host *host);

/* Complete selection of HS400 */
void (*hs400_complete)(struct mmc_host *host);

/* Prepare enhanced strobe depending host driver */
void (*hs400_enhanced_strobe)(struct mmc_host *host,
struct mmc_ios *ios);
Expand Down

0 comments on commit ba6c7ac

Please sign in to comment.