Commit ca8e99b3 authored by Philip Rakity's avatar Philip Rakity Committed by Chris Ball

mmc: core: Set non-default Drive Strength via platform hook

Non default Drive Strength cannot be set automatically.  It is a function
of the board design and only if there is a specific platform handler can
it be set.  The platform handler needs to take into account the board
design.  Pass to the platform code the necessary information.

For example:  The card and host controller may indicate they support HIGH
and LOW drive strength.  There is no way to know what should be chosen
without specific board knowledge.  Setting HIGH may lead to reflections
and setting LOW may not suffice.  There is no mechanism (like ethernet
duplex or speed pulses) to determine what should be done automatically.

If no platform handler is defined -- use the default value.
Signed-off-by: default avatarPhilip Rakity <prakity@marvell.com>
Reviewed-by: default avatarArindam Nath <arindam.nath@amd.com>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent ee8a43a5
...@@ -409,52 +409,62 @@ int mmc_sd_switch_hs(struct mmc_card *card) ...@@ -409,52 +409,62 @@ int mmc_sd_switch_hs(struct mmc_card *card)
static int sd_select_driver_type(struct mmc_card *card, u8 *status) static int sd_select_driver_type(struct mmc_card *card, u8 *status)
{ {
int host_drv_type = 0, card_drv_type = 0; int host_drv_type = SD_DRIVER_TYPE_B;
int card_drv_type = SD_DRIVER_TYPE_B;
int drive_strength;
int err; int err;
/* /*
* If the host doesn't support any of the Driver Types A,C or D, * If the host doesn't support any of the Driver Types A,C or D,
* default Driver Type B is used. * or there is no board specific handler then default Driver
* Type B is used.
*/ */
if (!(card->host->caps & (MMC_CAP_DRIVER_TYPE_A | MMC_CAP_DRIVER_TYPE_C if (!(card->host->caps & (MMC_CAP_DRIVER_TYPE_A | MMC_CAP_DRIVER_TYPE_C
| MMC_CAP_DRIVER_TYPE_D))) | MMC_CAP_DRIVER_TYPE_D)))
return 0; return 0;
if (card->host->caps & MMC_CAP_DRIVER_TYPE_A) { if (!card->host->ops->select_drive_strength)
host_drv_type = MMC_SET_DRIVER_TYPE_A; return 0;
if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_A)
card_drv_type = MMC_SET_DRIVER_TYPE_A; if (card->host->caps & MMC_CAP_DRIVER_TYPE_A)
else if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_B) host_drv_type |= SD_DRIVER_TYPE_A;
card_drv_type = MMC_SET_DRIVER_TYPE_B;
else if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_C) if (card->host->caps & MMC_CAP_DRIVER_TYPE_C)
card_drv_type = MMC_SET_DRIVER_TYPE_C; host_drv_type |= SD_DRIVER_TYPE_C;
} else if (card->host->caps & MMC_CAP_DRIVER_TYPE_C) {
host_drv_type = MMC_SET_DRIVER_TYPE_C; if (card->host->caps & MMC_CAP_DRIVER_TYPE_D)
if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_C) host_drv_type |= SD_DRIVER_TYPE_D;
card_drv_type = MMC_SET_DRIVER_TYPE_C;
} else if (!(card->host->caps & MMC_CAP_DRIVER_TYPE_D)) { if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_A)
/* card_drv_type |= SD_DRIVER_TYPE_A;
* If we are here, that means only the default driver type
* B is supported by the host. if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_C)
*/ card_drv_type |= SD_DRIVER_TYPE_C;
host_drv_type = MMC_SET_DRIVER_TYPE_B;
if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_B) if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_D)
card_drv_type = MMC_SET_DRIVER_TYPE_B; card_drv_type |= SD_DRIVER_TYPE_D;
else if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_C)
card_drv_type = MMC_SET_DRIVER_TYPE_C; /*
} * The drive strength that the hardware can support
* depends on the board design. Pass the appropriate
* information and let the hardware specific code
* return what is possible given the options
*/
drive_strength = card->host->ops->select_drive_strength(
card->sw_caps.uhs_max_dtr,
host_drv_type, card_drv_type);
err = mmc_sd_switch(card, 1, 2, card_drv_type, status); err = mmc_sd_switch(card, 1, 2, drive_strength, status);
if (err) if (err)
return err; return err;
if ((status[15] & 0xF) != card_drv_type) { if ((status[15] & 0xF) != drive_strength) {
printk(KERN_WARNING "%s: Problem setting driver strength!\n", printk(KERN_WARNING "%s: Problem setting drive strength!\n",
mmc_hostname(card->host)); mmc_hostname(card->host));
return 0; return 0;
} }
mmc_set_driver_type(card->host, host_drv_type); mmc_set_driver_type(card->host, drive_strength);
return 0; return 0;
} }
......
...@@ -148,6 +148,7 @@ struct mmc_host_ops { ...@@ -148,6 +148,7 @@ struct mmc_host_ops {
int (*start_signal_voltage_switch)(struct mmc_host *host, struct mmc_ios *ios); int (*start_signal_voltage_switch)(struct mmc_host *host, struct mmc_ios *ios);
int (*execute_tuning)(struct mmc_host *host); int (*execute_tuning)(struct mmc_host *host);
void (*enable_preset_value)(struct mmc_host *host, bool enable); void (*enable_preset_value)(struct mmc_host *host, bool enable);
int (*select_drive_strength)(unsigned int max_dtr, int host_drv, int card_drv);
}; };
struct mmc_card; struct mmc_card;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment