mmc: Add support for drive strength for eMMCs
Subsystems (3)
Adrian Hunter
maintainercover mmc: Add support for drive strength for eMMCs
Hi
Here are some patches to enable a host controller to select driver strength for eMMCs using HS200 or HS400. These are based on top of the re-tuning series.
There can be some confusion over the term "driver strength". SD calls it "drive strength" for the card but "driver type" for the host. Whereas JEDEC calls it both "driver strength" and "driver type". The values are the same for both SD and eMMC:
Value Driver Type Relative strength
0 B x1 default and mandatory support
1 A x1.5
2 C x0.75
3 D x0.5Except eMMC also defines value 4:
Value Driver Type Relative strength
4 x1.2
Adrian Hunter (12):
mmc: core: Reset driver type to default
mmc: core: Allow card drive strength to be different to host
mmc: core: Simplify card drive strength mask
mmc: core: Add 'card' to drive strength selection callback
mmc: core: Factor out common code in drive strength selection
mmc: core: Record card drive strength
mmc: mmc: Read card's valid driver strength mask
mmc: mmc: Add driver strength selection
mmc: core: Add function to read driver-strength device property
mmc: sdhci: Add a callback to select drive strength
mmc: sdhci-pci: Add support for drive strength selection for SPT
mmc: sdhci-pci: Enable HS400 for some Intel host controllers
Documentation/devicetree/bindings/mmc/mmc.txt | 4 ++ drivers/mmc/core/core.c | 39 ++++++++++++ drivers/mmc/core/core.h | 2 + drivers/mmc/core/host.c | 21 ++++++ drivers/mmc/core/mmc.c | 46 ++++++++++++-- drivers/mmc/core/sd.c | 69 ++++++-------------- drivers/mmc/core/sdio.c | 77 +++++++--------------- drivers/mmc/host/sdhci-pci-data.c | 3 + drivers/mmc/host/sdhci-pci.c | 92 +++++++++++++++++++++++++++ drivers/mmc/host/sdhci-pci.h | 4 ++ drivers/mmc/host/sdhci.c | 13 ++++ drivers/mmc/host/sdhci.h | 4 ++ include/linux/mmc/card.h | 2 + include/linux/mmc/host.h | 6 +- include/linux/mmc/mmc.h | 4 ++ include/linux/mmc/sdhci-pci-data.h | 2 + 16 files changed, 275 insertions(+), 113 deletions(-)
Regards
Adrian
Adrian Hunter
maintainerPATCH 1/12 mmc: core: Reset driver type to default
IO state variable drv_type could be set during card initialization. Consequently, it must be reset to the default value when setting the initial state.
--- drivers/mmc/core/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/core/core.c +1 -0
@@ -1179,6 +1179,7 @@ void mmc_set_initial_state(struct mmc_host *host) host->ios.bus_mode =MMC_BUSMODE_PUSHPULL ; host->ios.bus_width =MMC_BUS_WIDTH_1 ; host->ios.timing =MMC_TIMING_LEGACY ; + host->ios.drv_type =0 ;mmc_set_ios (host); }
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH 2/12 mmc: core: Allow card drive strength to be different to host
In reply to Adrian HunterInitialization of UHS-I modes for SD and SDIO cards employs a callback to allow the host driver to choose a drive strength value. Currently that assumes the card drive strength and host driver type must be the same value. Change to let the callback make that decision and return both the card drive strength and host driver type.
--- drivers/mmc/core/sd.c | 33 +++++++++++++-------------------- drivers/mmc/core/sdio.c | 43 ++++++++++++++++++------------------------- include/linux/mmc/host.h | 3 ++- 3 files changed, 33 insertions(+), 46 deletions(-)
drivers/mmc/core/sd.c +13 -20
@@ -388,18 +388,9 @@ static int sd_select_driver_type(struct mmc_card *card, u8 *status) {int host_drv_type =SD_DRIVER_TYPE_B ;int card_drv_type =SD_DRIVER_TYPE_B ; -int drive_strength; +int drive_strength, drv_type;int err; -/* -* If the host doesn't support any of the Driver Types A,C or D, -* 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 - |MMC_CAP_DRIVER_TYPE_D ))) -return 0 ; -if (!card->host->ops->select_drive_strength)return 0 ;
@@ -430,20 +421,22 @@ static int sd_select_driver_type(struct mmc_card *card, u8 *status)mmc_host_clk_hold (card->host); drive_strength = card->host->ops->select_drive_strength ( card->sw_caps.uhs_max_dtr, - host_drv_type, card_drv_type); + host_drv_type, card_drv_type, &drv_type);mmc_host_clk_release (card->host); - err =mmc_sd_switch (card,1 ,2 , drive_strength, status); -if (err) -return err; - -if ((status[15 ] &0xF ) != drive_strength) { -pr_warn ("%s: Problem setting drive strength!\n" , -mmc_hostname (card->host)); -return 0 ; +if (drive_strength) { + err =mmc_sd_switch (card,1 ,2 , drive_strength, status); +if (err) +return err; +if ((status[15 ] &0xF ) != drive_strength) { +pr_warn ("%s: Problem setting drive strength!\n" , +mmc_hostname (card->host)); +return 0 ; + } } -mmc_set_driver_type (card->host, drive_strength); +if (drv_type) +mmc_set_driver_type (card->host, drv_type);return 0 ; }
drivers/mmc/core/sdio.c +18 -25
62 lines not on this page · raw message
include/linux/mmc/host.h +2 -1
@@ -138,7 +138,8 @@ struct mmc_host_ops {/* Prepare HS400 target operating frequency depending host driver */ int (*prepare_hs400_tuning)(struct mmc_host *host,struct mmc_ios *ios); -int (*select_drive_strength)(unsigned int max_dtr,int host_drv,int card_drv); +int (*select_drive_strength)(unsigned int max_dtr,int host_drv, +int card_drv,int *drv_type);void (*hw_reset)(struct mmc_host *host);void (*card_event)(struct mmc_host *host);
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH 3/12 mmc: core: Simplify card drive strength mask
In reply to Adrian HunterCard drive strength selection uses a callback to which a mask of supported drive strengths is passed. Currently, the bits are checked against the values in the SD specifications. That is not necessary because the callback will anyway match the mask against a valid value. Simplify by taking the mask as is but still ensuring that the default mandatory value (type B) is always supported.
--- drivers/mmc/core/sd.c | 12 ++---------- drivers/mmc/core/sdio.c | 12 ++---------- 2 files changed, 4 insertions(+), 20 deletions(-)
drivers/mmc/core/sd.c +2 -10
@@ -387,8 +387,7 @@ out:static int sd_select_driver_type (struct mmc_card *card,u8 *status) {int host_drv_type =SD_DRIVER_TYPE_B ; -int card_drv_type =SD_DRIVER_TYPE_B ; -int drive_strength, drv_type; +int card_drv_type, drive_strength, drv_type;int err;if (!card->host->ops->select_drive_strength)
@@ -403,14 +402,7 @@ static int sd_select_driver_type(struct mmc_card *card, u8 *status)if (card->host->caps &MMC_CAP_DRIVER_TYPE_D ) host_drv_type |=SD_DRIVER_TYPE_D ; -if (card->sw_caps.sd3_drv_type &SD_DRIVER_TYPE_A ) - card_drv_type |=SD_DRIVER_TYPE_A ; - -if (card->sw_caps.sd3_drv_type &SD_DRIVER_TYPE_C ) - card_drv_type |=SD_DRIVER_TYPE_C ; - -if (card->sw_caps.sd3_drv_type &SD_DRIVER_TYPE_D ) - card_drv_type |=SD_DRIVER_TYPE_D ; + card_drv_type = card->sw_caps.sd3_drv_type |SD_DRIVER_TYPE_B ;/* * The drive strength that the hardware can support
drivers/mmc/core/sdio.c +2 -10
@@ -400,8 +400,7 @@ static unsigned char host_drive_to_sdio_drive(int host_strength)static void sdio_select_driver_type (struct mmc_card *card) {int host_drv_type =SD_DRIVER_TYPE_B ; -int card_drv_type =SD_DRIVER_TYPE_B ; -int drive_strength, drv_type; +int card_drv_type, drive_strength, drv_type;unsigned char card_strength;int err;
@@ -417,14 +416,7 @@ static void sdio_select_driver_type(struct mmc_card *card)if (card->host->caps &MMC_CAP_DRIVER_TYPE_D ) host_drv_type |=SD_DRIVER_TYPE_D ; -if (card->sw_caps.sd3_drv_type &SD_DRIVER_TYPE_A ) - card_drv_type |=SD_DRIVER_TYPE_A ; - -if (card->sw_caps.sd3_drv_type &SD_DRIVER_TYPE_C ) - card_drv_type |=SD_DRIVER_TYPE_C ; - -if (card->sw_caps.sd3_drv_type &SD_DRIVER_TYPE_D ) - card_drv_type |=SD_DRIVER_TYPE_D ; + card_drv_type = card->sw_caps.sd3_drv_type |SD_DRIVER_TYPE_B ;/* * The drive strength that the hardware can support
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH 4/12 mmc: core: Add 'card' to drive strength selection callback
In reply to Adrian HunterIn preparation for supporting also eMMC drive strength, add the 'card' as a parameter so that the callback can distinguish different types of cards if necessary.
--- drivers/mmc/core/sd.c | 2 +- drivers/mmc/core/sdio.c | 2 +- include/linux/mmc/host.h | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-)
drivers/mmc/core/sd.c +1 -1
@@ -411,7 +411,7 @@ static int sd_select_driver_type(struct mmc_card *card, u8 *status)* return what is possible given the options */ mmc_host_clk_hold (card->host); - drive_strength = card->host->ops->select_drive_strength ( + drive_strength = card->host->ops->select_drive_strength (card, card->sw_caps.uhs_max_dtr, host_drv_type, card_drv_type, &drv_type);mmc_host_clk_release (card->host);
drivers/mmc/core/sdio.c +1 -1
@@ -424,7 +424,7 @@ static void sdio_select_driver_type(struct mmc_card *card)* information and let the hardware specific code * return what is possible given the options */ - drive_strength = card->host->ops->select_drive_strength ( + drive_strength = card->host->ops->select_drive_strength (card, card->sw_caps.uhs_max_dtr, host_drv_type, card_drv_type, &drv_type);
include/linux/mmc/host.h +2 -1
@@ -138,7 +138,8 @@ struct mmc_host_ops {/* Prepare HS400 target operating frequency depending host driver */ int (*prepare_hs400_tuning)(struct mmc_host *host,struct mmc_ios *ios); -int (*select_drive_strength)(unsigned int max_dtr,int host_drv, +int (*select_drive_strength)(struct mmc_card *card, +unsigned int max_dtr,int host_drv,int card_drv,int *drv_type);void (*hw_reset)(struct mmc_host *host);void (*card_event)(struct mmc_host *host);
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH 5/12 mmc: core: Factor out common code in drive strength selection
In reply to Adrian HunterMake a new function out of common code used for drive strength selection.
--- drivers/mmc/core/core.c | 38 ++++++++++++++++++++++++++++++++++++++ drivers/mmc/core/core.h | 2 ++ drivers/mmc/core/sd.c | 27 +++------------------------ drivers/mmc/core/sdio.c | 25 +++---------------------- 4 files changed, 46 insertions(+), 46 deletions(-)
drivers/mmc/core/core.c +38 -0
@@ -1634,6 +1634,44 @@ void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type)mmc_host_clk_release (host); } +int mmc_select_drive_strength (struct mmc_card *card,unsigned int max_dtr, +int card_drv_type,int *drv_type) +{ +struct mmc_host *host = card->host; +int host_drv_type =SD_DRIVER_TYPE_B ; +int drive_strength; + + *drv_type =0 ; + +if (!host->ops->select_drive_strength) +return 0 ; + +/* Use SD definition of driver strength for hosts */ +if (host->caps &MMC_CAP_DRIVER_TYPE_A ) + host_drv_type |=SD_DRIVER_TYPE_A ; + +if (host->caps &MMC_CAP_DRIVER_TYPE_C ) + host_drv_type |=SD_DRIVER_TYPE_C ; + +if (host->caps &MMC_CAP_DRIVER_TYPE_D ) + host_drv_type |=SD_DRIVER_TYPE_D ; + +/* +* 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 +*/ +mmc_host_clk_hold (host); + drive_strength = host->ops->select_drive_strength (card, max_dtr, + host_drv_type, + card_drv_type, + drv_type); +mmc_host_clk_release (host); + +return drive_strength; +} +/* * Apply power to the MMC stack. This is a two-stage process. * First, we enable power to the card without the clock running.
drivers/mmc/core/core.h +2 -0
@@ -50,6 +50,8 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, u32 ocr);int __mmc_set_signal_voltage (struct mmc_host *host,int signal_voltage);void mmc_set_timing (struct mmc_host *host,unsigned int timing);void mmc_set_driver_type (struct mmc_host *host,unsigned int drv_type); +int mmc_select_drive_strength (struct mmc_card *card,unsigned int max_dtr, +int card_drv_type,int *drv_type);void mmc_power_up (struct mmc_host *host,u32 ocr);void mmc_power_off (struct mmc_host *host);void mmc_power_cycle (struct mmc_host *host,u32 ocr);
drivers/mmc/core/sd.c +3 -24
@@ -386,35 +386,14 @@ out:static int sd_select_driver_type (struct mmc_card *card,u8 *status) { -int host_drv_type =SD_DRIVER_TYPE_B ;int card_drv_type, drive_strength, drv_type;int err; -if (!card->host->ops->select_drive_strength) -return 0 ; - -if (card->host->caps &MMC_CAP_DRIVER_TYPE_A ) - host_drv_type |=SD_DRIVER_TYPE_A ; - -if (card->host->caps &MMC_CAP_DRIVER_TYPE_C ) - host_drv_type |=SD_DRIVER_TYPE_C ; - -if (card->host->caps &MMC_CAP_DRIVER_TYPE_D ) - host_drv_type |=SD_DRIVER_TYPE_D ; - card_drv_type = card->sw_caps.sd3_drv_type |SD_DRIVER_TYPE_B ; -/* -* 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 -*/ -mmc_host_clk_hold (card->host); - drive_strength = card->host->ops->select_drive_strength (card, - card->sw_caps.uhs_max_dtr, - host_drv_type, card_drv_type, &drv_type); -mmc_host_clk_release (card->host); + drive_strength =mmc_select_drive_strength (card, + card->sw_caps.uhs_max_dtr, + card_drv_type, &drv_type);if (drive_strength) { err =mmc_sd_switch (card,1 ,2 , drive_strength, status);
drivers/mmc/core/sdio.c +3 -22
@@ -399,34 +399,15 @@ static unsigned char host_drive_to_sdio_drive(int host_strength)static void sdio_select_driver_type (struct mmc_card *card) { -int host_drv_type =SD_DRIVER_TYPE_B ;int card_drv_type, drive_strength, drv_type;unsigned char card_strength;int err; -if (!card->host->ops->select_drive_strength) -return ; - -if (card->host->caps &MMC_CAP_DRIVER_TYPE_A ) - host_drv_type |=SD_DRIVER_TYPE_A ; - -if (card->host->caps &MMC_CAP_DRIVER_TYPE_C ) - host_drv_type |=SD_DRIVER_TYPE_C ; - -if (card->host->caps &MMC_CAP_DRIVER_TYPE_D ) - host_drv_type |=SD_DRIVER_TYPE_D ; - card_drv_type = card->sw_caps.sd3_drv_type |SD_DRIVER_TYPE_B ; -/* -* 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, - card->sw_caps.uhs_max_dtr, - host_drv_type, card_drv_type, &drv_type); + drive_strength =mmc_select_drive_strength (card, + card->sw_caps.uhs_max_dtr, + card_drv_type, &drv_type);if (drive_strength) {/* if error just use default for drive strength B */
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH 6/12 mmc: core: Record card drive strength
In reply to Adrian HunterIn preparation for adding drive strength support for eMMC, add drive_strength to struct mmc_card to record the card drive strength for UHS-I modes and HS200 / HS400. For eMMC this will be needed when switching between HS200 and HS400.
--- drivers/mmc/core/sd.c | 3 +++ drivers/mmc/core/sdio.c | 3 +++ include/linux/mmc/card.h | 1 + 3 files changed, 7 insertions(+)
drivers/mmc/core/sd.c +3 -0
@@ -389,6 +389,8 @@ static int sd_select_driver_type(struct mmc_card *card, u8 *status)int card_drv_type, drive_strength, drv_type;int err; + card->drive_strength =0 ; + card_drv_type = card->sw_caps.sd3_drv_type |SD_DRIVER_TYPE_B ; drive_strength = mmc_select_drive_strength(card,
@@ -404,6 +406,7 @@ static int sd_select_driver_type(struct mmc_card *card, u8 *status) mmc_hostname(card->host));return 0 ; } + card->drive_strength = drive_strength; }if (drv_type)
drivers/mmc/core/sdio.c +3 -0
@@ -403,6 +403,8 @@ static void sdio_select_driver_type(struct mmc_card *card)unsigned char card_strength;int err; + card->drive_strength =0 ; + card_drv_type = card->sw_caps.sd3_drv_type |SD_DRIVER_TYPE_B ; drive_strength = mmc_select_drive_strength(card,
@@ -424,6 +426,7 @@ static void sdio_select_driver_type(struct mmc_card *card) card_strength, NULL);if (err)return ; + card->drive_strength = drive_strength; }if (drv_type)
include/linux/mmc/card.h +1 -0
@@ -305,6 +305,7 @@ struct mmc_card {unsigned int sd_bus_speed;/* Bus Speed Mode set for the card */ unsigned int mmc_avail_type;/* supported device type by both host and card */ +unsigned int drive_strength;/* for UHS-I, HS200 or HS400 */ struct dentry *debugfs_root;struct mmc_part part[MMC_NUM_PHY_PARTITION ];/* physical partitions */
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH 7/12 mmc: mmc: Read card's valid driver strength mask
In reply to Adrian HunterIn preparation for supporing drive strength selection for eMMC, read the card's valid driver strengths.
Note that though the SD spec uses the term "drive strength", the JEDEC eMMC spec uses the term "driver strength".
--- drivers/mmc/core/mmc.c | 1 + include/linux/mmc/card.h | 1 + include/linux/mmc/mmc.h | 1 + 3 files changed, 3 insertions(+)
drivers/mmc/core/mmc.c +1 -0
@@ -426,6 +426,7 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd) card->ext_csd.raw_trim_mult = ext_csd[EXT_CSD_TRIM_MULT ]; card->ext_csd.raw_partition_support = ext_csd[EXT_CSD_PARTITION_SUPPORT ]; + card->ext_csd.raw_driver_strength = ext_csd[EXT_CSD_DRIVER_STRENGTH ];if (card->ext_csd.rev >=4 ) {if (ext_csd[EXT_CSD_PARTITION_SETTING_COMPLETED ] &EXT_CSD_PART_SETTING_COMPLETED )
include/linux/mmc/card.h +1 -0
@@ -97,6 +97,7 @@ struct mmc_ext_csd {u8 raw_erased_mem_count;/* 181 */ u8 raw_ext_csd_structure;/* 194 */ u8 raw_card_type;/* 196 */ +u8 raw_driver_strength;/* 197 */ u8 out_of_int_time;/* 198 */ u8 raw_pwr_cl_52_195;/* 200 */ u8 raw_pwr_cl_26_195;/* 201 */
include/linux/mmc/mmc.h +1 -0
@@ -302,6 +302,7 @@ struct _mmc_csd {#define EXT_CSD_REV 192/* RO */ #define EXT_CSD_STRUCTURE 194/* RO */ #define EXT_CSD_CARD_TYPE 196/* RO */ +#define EXT_CSD_DRIVER_STRENGTH 197/* RO */ #define EXT_CSD_OUT_OF_INTERRUPT_TIME 198/* RO */ #define EXT_CSD_PART_SWITCH_TIME 199/* RO */ #define EXT_CSD_PWR_CL_52_195 200/* RO */
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH 8/12 mmc: mmc: Add driver strength selection
In reply to Adrian HunterAdd the ability to set eMMC driver strength
for HS200 and HS400.
--- drivers/mmc/core/mmc.c | 45 ++++++++++++++++++++++++++++++++++++++------- include/linux/mmc/mmc.h | 3 +++ 2 files changed, 41 insertions(+), 7 deletions(-)
drivers/mmc/core/mmc.c +38 -7
@@ -1033,6 +1033,7 @@ static int mmc_select_hs400(struct mmc_card *card) {struct mmc_host *host = card->host;int err =0 ; +u8 val;/* * HS400 mode requires 8-bit bus width
@@ -1048,8 +1049,10 @@ static int mmc_select_hs400(struct mmc_card *card)mmc_set_timing (card->host,MMC_TIMING_MMC_HS );mmc_set_bus_speed (card); + val =EXT_CSD_TIMING_HS | + card->drive_strength <<EXT_CSD_DRV_STR_SHIFT ; err =__mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , -EXT_CSD_HS_TIMING ,EXT_CSD_TIMING_HS , +EXT_CSD_HS_TIMING , val, card->ext_csd.generic_cmd6_time, true, true, true);if (err) {
@@ -1068,8 +1071,10 @@ static int mmc_select_hs400(struct mmc_card *card)return err; } + val =EXT_CSD_TIMING_HS400 | + card->drive_strength <<EXT_CSD_DRV_STR_SHIFT ; err =__mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , -EXT_CSD_HS_TIMING ,EXT_CSD_TIMING_HS400 , +EXT_CSD_HS_TIMING , val, card->ext_csd.generic_cmd6_time, true, true, true);if (err) {
@@ -1108,6 +1113,7 @@ int mmc_hs400_to_hs200(struct mmc_card *card)bool send_status = true;unsigned int max_dtr;int err; +u8 val;if (host->caps &MMC_CAP_WAIT_WHILE_BUSY ) send_status = false;
@@ -1117,8 +1123,10 @@ int mmc_hs400_to_hs200(struct mmc_card *card)mmc_set_clock (host, max_dtr);/* Switch HS400 to HS DDR */ + val =EXT_CSD_TIMING_HS | + card->drive_strength <<EXT_CSD_DRV_STR_SHIFT ; err =__mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_HS_TIMING , -EXT_CSD_TIMING_HS , card->ext_csd.generic_cmd6_time, + val, card->ext_csd.generic_cmd6_time, true, send_status, true);if (err) goto out_err;
@@ -1147,10 +1155,11 @@ int mmc_hs400_to_hs200(struct mmc_card *card) }/* Switch HS to HS200 */ + val =EXT_CSD_TIMING_HS200 | + card->drive_strength <<EXT_CSD_DRV_STR_SHIFT ; err =__mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_HS_TIMING , -EXT_CSD_TIMING_HS200 , - card->ext_csd.generic_cmd6_time, true, send_status, - true); + val, card->ext_csd.generic_cmd6_time, true, + send_status, true);if (err) goto out_err;
@@ -1172,6 +1181,23 @@ out_err:return err; } +static void mmc_select_driver_type (struct mmc_card *card) +{ +int card_drv_type, drive_strength, drv_type; + + card_drv_type = card->ext_csd.raw_driver_strength | +mmc_driver_type_mask (0 ); + + drive_strength =mmc_select_drive_strength (card, + card->ext_csd.hs200_max_dtr, + card_drv_type, &drv_type); + + card->drive_strength = drive_strength; + +if (drv_type) +mmc_set_driver_type (card->host, drv_type); +} +/* * For device supporting HS200 mode, the following sequence * should be done before executing the tuning process.
@@ -1183,6 +1209,7 @@ static int mmc_select_hs200(struct mmc_card *card) {struct mmc_host *host = card->host;int err = -EINVAL ; +u8 val;if (card->mmc_avail_type &EXT_CSD_CARD_TYPE_HS200_1_2V ) err =__mmc_set_signal_voltage (host,MMC_SIGNAL_VOLTAGE_120 );
@@ -1194,14 +1221,18 @@ static int mmc_select_hs200(struct mmc_card *card)if (err) goto err; +mmc_select_driver_type (card); +/* * Set the bus width(4 or 8) with host's support and * switch to HS200 mode if bus width is set successfully. */ err =mmc_select_bus_width (card);if (!IS_ERR_VALUE (err)) { + val =EXT_CSD_TIMING_HS200 | + card->drive_strength <<EXT_CSD_DRV_STR_SHIFT ; err =__mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , -EXT_CSD_HS_TIMING ,EXT_CSD_TIMING_HS200 , +EXT_CSD_HS_TIMING , val, card->ext_csd.generic_cmd6_time, true, true, true);if (!err)
include/linux/mmc/mmc.h +3 -0
@@ -391,6 +391,7 @@ struct _mmc_csd {#define EXT_CSD_TIMING_HS 1/* High speed */ #define EXT_CSD_TIMING_HS200 2/* HS200 */ #define EXT_CSD_TIMING_HS400 3/* HS400 */ +#define EXT_CSD_DRV_STR_SHIFT 4/* Driver Strength shift */ #define EXT_CSD_SEC_ER_EN BIT(0)#define EXT_CSD_SEC_BD_BLK_EN BIT(2)
@@ -442,4 +443,6 @@ struct _mmc_csd {#define MMC_SWITCH_MODE_CLEAR_BITS 0x02/* Clear bits which are 1 in value */ #define MMC_SWITCH_MODE_WRITE_BYTE 0x03/* Set target to value */ +#define mmc_driver_type_mask (n) (1 << (n)) +#endif /* LINUX_MMC_MMC_H */
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH 9/12 mmc: core: Add function to read driver-strength device property
In reply to Adrian HunterAdd a function to read a new "driver-strength" device property.
Currently there is no documentation for device properties, so add "driver-strength" to mmc devicetree bindings.
--- Documentation/devicetree/bindings/mmc/mmc.txt | 4 ++++ drivers/mmc/core/host.c | 21 +++++++++++++++++++++ include/linux/mmc/host.h | 2 ++ 3 files changed, 27 insertions(+)
Documentation/devicetree/bindings/mmc/mmc.txt +4 -0
@@ -43,6 +43,10 @@ Optional properties: - dsr: Value the card's (optional) Driver Stage Register (DSR) should be programmed with. Valid range: [0 .. 0xffff]. +Device properties (use device_property_ API): +- driver-strength: Optional driver strength value for a card using UHS-I or + HS200/HS400 + *NOTE* on CD and WP polarity. To use common for all SD/MMC host controllers line polarity properties, we have to fix the meaning of the "normal" and "inverted" line levels. We choose to follow the SDHCI standard, which specifies both those
drivers/mmc/core/host.c +21 -0
@@ -22,6 +22,7 @@#include <linux/leds.h> #include <linux/slab.h> #include <linux/suspend.h> +#include <linux/property.h> #include <linux/mmc/host.h> #include <linux/mmc/card.h>
@@ -516,6 +517,26 @@ int mmc_of_parse(struct mmc_host *host)EXPORT_SYMBOL (mmc_of_parse); +int mmc_host_read_drive_strength (struct mmc_host *host) +{ +struct device *dev = host->parent; +u8 drive_strength; +int err; + +if (!device_property_present (dev,"driver-strength" )) +return -ENODATA ; + + err =device_property_read_u8 (dev,"driver-strength" , &drive_strength); +if (err) { +dev_err (dev,"Bad \"driver-strength\" property, error %d\n" , + err); +return -EINVAL ; + } + +return drive_strength; +} +EXPORT_SYMBOL (mmc_host_read_drive_strength); +/** * mmc_alloc_host - initialise the per-host structure. * @extra: sizeof private data structure
include/linux/mmc/host.h +2 -0
@@ -394,6 +394,8 @@ void mmc_remove_host(struct mmc_host *);void mmc_free_host (struct mmc_host *);int mmc_of_parse (struct mmc_host *host); +int mmc_host_read_drive_strength (struct mmc_host *host); +static inline void *mmc_priv (struct mmc_host *host) {return (void *)host->private;
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH 10/12 mmc: sdhci: Add a callback to select drive strength
In reply to Adrian HunterAdd a callbak to let host drivers select drive
strength.
--- drivers/mmc/host/sdhci.c | 13 +++++++++++++ drivers/mmc/host/sdhci.h | 4 ++++ 2 files changed, 17 insertions(+)
drivers/mmc/host/sdhci.c +13 -0
@@ -2054,6 +2054,18 @@ out_unlock:return err; } +static int sdhci_select_drive_strength (struct mmc_card *card, +unsigned int max_dtr,int host_drv, +int card_drv,int *drv_type) +{ +struct sdhci_host *host =mmc_priv (card->host); + +if (!host->ops->select_drive_strength) +return 0 ; + +return host->ops->select_drive_strength (host, card, max_dtr, host_drv, + card_drv, drv_type); +}static void sdhci_enable_preset_value (struct sdhci_host *host,bool enable) {
@@ -2198,6 +2210,7 @@ static const struct mmc_host_ops sdhci_ops = { .start_signal_voltage_switch = sdhci_start_signal_voltage_switch, .prepare_hs400_tuning = sdhci_prepare_hs400_tuning, .execute_tuning = sdhci_execute_tuning, + .select_drive_strength = sdhci_select_drive_strength, .card_event = sdhci_card_event, .card_busy = sdhci_card_busy, };
drivers/mmc/host/sdhci.h +4 -0
@@ -340,6 +340,10 @@ struct sdhci_ops {void (*platform_init)(struct sdhci_host *host);void (*card_event)(struct sdhci_host *host);void (*voltage_switch)(struct sdhci_host *host); +int (*select_drive_strength)(struct sdhci_host *host, +struct mmc_card *card, +unsigned int max_dtr,int host_drv, +int card_drv,int *drv_type); };#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH 11/12 mmc: sdhci-pci: Add support for drive strength selection for SPT
In reply to Adrian HunterImplement the select_drive_strength callback to provide drive strength selection for Intel SPT.
The driver strength will be provided by a device property otherwise an attempt will be made to read it from the card.
--- drivers/mmc/host/sdhci-pci-data.c | 3 ++ drivers/mmc/host/sdhci-pci.c | 91 ++++++++++++++++++++++++++++++++++++++ drivers/mmc/host/sdhci-pci.h | 4 ++ include/linux/mmc/sdhci-pci-data.h | 2 + 4 files changed, 100 insertions(+)
drivers/mmc/host/sdhci-pci-data.c +3 -0
@@ -3,3 +3,6 @@struct sdhci_pci_data *(*sdhci_pci_get_data)(struct pci_dev *pdev,int slotno);EXPORT_SYMBOL_GPL (sdhci_pci_get_data); + +int sdhci_pci_spt_drive_strength; +EXPORT_SYMBOL_GPL (sdhci_pci_spt_drive_strength);
drivers/mmc/host/sdhci-pci.c +91 -0
121 lines not on this page · raw message
drivers/mmc/host/sdhci-pci.h +4 -0
@@ -72,6 +72,10 @@ struct sdhci_pci_slot {bool cd_override_level;void (*hw_reset)(struct sdhci_host *host); +int (*select_drive_strength)(struct sdhci_host *host, +struct mmc_card *card, +unsigned int max_dtr,int host_drv, +int card_drv,int *drv_type); };struct sdhci_pci_chip {
include/linux/mmc/sdhci-pci-data.h +2 -0
@@ -15,4 +15,6 @@ struct sdhci_pci_data {extern struct sdhci_pci_data *(*sdhci_pci_get_data)(struct pci_dev *pdev,int slotno); +extern int sdhci_pci_spt_drive_strength; +#endif
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH 12/12 mmc: sdhci-pci: Enable HS400 for some Intel host controllers
In reply to Adrian HunterEnable detection of HS400 support via capability bit-63 for some Intel host controllers.
--- drivers/mmc/host/sdhci-pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/sdhci-pci.c +1 -0
@@ -378,6 +378,7 @@ static const struct sdhci_pci_fixes sdhci_intel_byt_emmc = { .probe_slot = byt_emmc_probe_slot, .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, .quirks2 =SDHCI_QUIRK2_PRESET_VALUE_BROKEN | +SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400 | SDHCI_QUIRK2_STOP_WITH_TC, };
Signature · 1 line
1.9.1