mmc: sdhci: fixes and enhancements
v4 cover mmc: sdhci: fixes and enhancements
This patchset does as follows:
[PATCH v4 01/15] mmc: sdhci: fix transfer mode setting bug for cmds w/o data transfer [PATCH v4 02/15] mmc: sdhci: set regulator min/max voltage according to spec [PATCH v4 03/15] mmc: sdhci: refine code for sd clock disable/enable in set ios [PATCH v4 04/15] mmc: sdhci: keep the saved clock var up to date
[PATCH v4 05/15] mmc: sdhci: fix null return check of regulator_get [PATCH v4 06/15] mmc: sdhci-pxav3: controller can't get base clock [PATCH v4 07/15] mmc: host: adjust uhs timing value
[PATCH v4 08/15] mmc: sdhci: enhance preset value function
[PATCH v4 09/15] mmc: sdhci-pxav3: add quirks2
[PATCH v4 10/15] mmc: sdhci: introduce signal_voltage_switch callback function [PATCH v4 11/15] mmc: sdhci-pxav3: add signal_voltage_switch function [PATCH v4 12/15] mmc: core: add new 1.8v flag for mmc
[PATCH v4 13/15] mmc: sdhci: add mmc 1.8v signal voltage switch function [PATCH v4 14/15] mmc: sdhci: fix the bug that DDR50 can't work for emmc [PATCH v4 15/15] mmc: sdhci-pxav3: remove set_uhs_signaling function
changelog v1->v2:
- remove the patch "mmc: sdhci-pxav3: fix build error"
- update the patch 05/15 by avoid warning with return null
- add patches 06/15 ~ 08/15
changelog v2->v3:
- update some comments
- add patches 09/15 ~ 11/15
changelog v3->v4:
- update the patch 01/15 with data null check
- add patches 12/15 ~ 15/15
Kevin Liu (15):
mmc: sdhci: fix transfer mode setting bug for cmds w/o data transfer
mmc: sdhci: set regulator min/max voltage according to spec
mmc: sdhci: refine code for sd clock disable/enable in set ios
mmc: sdhci: keep the saved clock var up to date
mmc: sdhci: fix null return check of regulator_get
mmc: sdhci-pxav3: controller can't get base clock
mmc: host: adjust uhs timing value
mmc: sdhci: enhance preset value function
mmc: sdhci-pxav3: add quirks2
mmc: sdhci: introduce signal_voltage_switch callback function
mmc: sdhci-pxav3: add signal_voltage_switch function
mmc: core: add new 1.8v flag for mmc
mmc: sdhci: add mmc 1.8v signal voltage switch function
mmc: sdhci: fix the bug that DDR50 can't work for emmc
mmc: sdhci-pxav3: remove set_uhs_signaling function
drivers/mmc/core/mmc.c | 3 +- drivers/mmc/core/sd.c | 17 -- drivers/mmc/host/sdhci-pxav3.c | 53 +++---- drivers/mmc/host/sdhci.c | 293 ++++++++++++++++++++++--------- drivers/mmc/host/sdhci.h | 13 ++ include/linux/mmc/host.h | 14 +- include/linux/mmc/sdhci.h | 2 +- include/linux/platform_data/pxa_sdhci.h | 4 + 8 files changed, 254 insertions(+), 145 deletions(-)
PATCH v4 1/15 mmc: sdhci: fix transfer mode setting bug for cmds w/o data transfer
From: Kevin Liu <[email protected]>
Commands without data transfer like cmd5/cmd7 will use previous transfer mode setting, which may lead to error since some bits may have been set unexpectedly.
For example, cmd5 following cmd18/cmd25 will have timeout error since audo cmd23 has been enabled.
--- drivers/mmc/host/sdhci.c | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-)
drivers/mmc/host/sdhci.c +14 -8
@@ -886,8 +886,21 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host,u16 mode;struct mmc_data *data = cmd->data; -if (data ==NULL ) +if (!data) { +if (cmd->opcode ==MMC_SEND_TUNING_BLOCK || + cmd->opcode ==MMC_SEND_TUNING_BLOCK_HS200 ) +/* +* The tuning block is sent by the card to the host +* controller. So we set the TRNS_READ bit in the +* Transfer Mode register. This also takes care of +* setting DMA Enable and Multi Block Select in the +* same register to 0. +*/ +sdhci_writew (host,SDHCI_TRNS_READ ,SDHCI_TRANSFER_MODE ); +else +sdhci_writew (host,0 ,SDHCI_TRANSFER_MODE );return ; + }WARN_ON (!host->data);
@@ -1850,13 +1863,6 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) SDHCI_BLOCK_SIZE); } -/* -* The tuning block is sent by the card to the host controller. -* So we set the TRNS_READ bit in the Transfer Mode register. -* This also takes care of setting DMA Enable and Multi Block -* Select in the same register to 0. -*/ -sdhci_writew (host,SDHCI_TRNS_READ ,SDHCI_TRANSFER_MODE );sdhci_send_command (host, &cmd);
Signature · 1 line
1.7.0.4
Re: [PATCH v4 01/15] mmc: sdhci: fix transfer mode setting bug for cmds w/o data transfer
Reviewed By: Girish K S <[email protected]>
Quoted 63 lines · Kevin Liu
From: Kevin Liu <[email protected]>
Commands without data transfer like cmd5/cmd7 will use previous transfer mode setting, which may lead to error since some bits may have been set unexpectedly.
For example, cmd5 following cmd18/cmd25 will have timeout error since audo cmd23 has been enabled.Signed-off-by Jialing Fu <[email protected]>Signed-off-by Tim Wang <[email protected]>Signed-off-by Kevin Liu <[email protected]>--- drivers/mmc/host/sdhci.c | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-)drivers/mmc/host/sdhci.c +14
-9@@ -886,8 +886,21 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host,u16 mode;struct mmc_data *data = cmd->data; -if (data ==NULL ) +if (!data) { +if (cmd->opcode ==MMC_SEND_TUNING_BLOCK || + cmd->opcode ==MMC_SEND_TUNING_BLOCK_HS200 ) +/* +* The tuning block is sent by the card to the host +* controller. So we set the TRNS_READ bit in the +* Transfer Mode register. This also takes care of +* setting DMA Enable and Multi Block Select in the +* same register to 0. +*/ +sdhci_writew (host,SDHCI_TRNS_READ ,SDHCI_TRANSFER_MODE ); +else +sdhci_writew (host,0 ,SDHCI_TRANSFER_MODE );return ; + }WARN_ON (!host->data);@@ -1850,13 +1863,6 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) SDHCI_BLOCK_SIZE); } -/* -* The tuning block is sent by the card to the host controller. -* So we set the TRNS_READ bit in the Transfer Mode register. -* This also takes care of setting DMA Enable and Multi Block -* Select in the same register to 0. -*/ -sdhci_writew (host,SDHCI_TRNS_READ ,SDHCI_TRANSFER_MODE );sdhci_send_command (host, &cmd); --1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 01/15] mmc: sdhci: fix transfer mode setting bug for cmds w/o data transfer
In reply to Kevin LiuQuoted 8 lines · Kevin Liu
From: Kevin Liu <[email protected]>
Commands without data transfer like cmd5/cmd7 will use previous transfer mode setting, which may lead to error since some bits may have been set unexpectedly.
For example, cmd5 following cmd18/cmd25 will have timeout error since audo cmd23 has been enabled.
Quoted 4 lines
Signed-off-by Jialing Fu <[email protected]>Signed-off-by Tim Wang <[email protected]>Signed-off-by Kevin Liu <[email protected]>---
PATCH v4 2/15 mmc: sdhci: set regulator min/max voltage according to spec
In reply to Kevin LiuFrom: Kevin Liu <[email protected]>
Use voltage range as below rather than a specific value 3.3v: (3.2v, 3.4v)
3.0v: (2.9v, 3.1v)
1.8v: (1.65v, 1.95v)
--- drivers/mmc/host/sdhci.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
drivers/mmc/host/sdhci.c +9 -9
@@ -1628,7 +1628,7 @@ static int sdhci_do_3_3v_signal_voltage_switch(struct sdhci_host *host,sdhci_writew (host, ctrl,SDHCI_HOST_CONTROL2 );if (host->vqmmc) { - ret =regulator_set_voltage (host->vqmmc,3300000 ,3300000 ); + ret =regulator_set_voltage (host->vqmmc,3200000 ,3400000 );if (ret) {pr_warning ("%s: Switching to 3.3V signalling voltage " " failed\n" ,mmc_hostname (host->mmc));
@@ -1672,7 +1672,7 @@ static int sdhci_do_1_8v_signal_voltage_switch(struct sdhci_host *host,*/ if (host->vqmmc) ret =regulator_set_voltage (host->vqmmc, -1800000 ,1800000 ); +1650000 ,1950000 );else ret =0 ;
@@ -2856,7 +2856,7 @@ int sdhci_add_host(struct sdhci_host *host)pr_info ("%s: no vqmmc regulator found\n" ,mmc_hostname (mmc)); host->vqmmc =NULL ; } -else if (regulator_is_supported_voltage (host->vqmmc,1800000 ,1800000 )) +else if (regulator_is_supported_voltage (host->vqmmc,1650000 ,1950000 ))regulator_enable (host->vqmmc);else caps[1] &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 |
@@ -2927,16 +2927,16 @@ int sdhci_add_host(struct sdhci_host *host)#ifdef CONFIG_REGULATOR if (host->vmmc) { - ret =regulator_is_supported_voltage (host->vmmc,3300000 , -3300000 ); + ret =regulator_is_supported_voltage (host->vmmc,3200000 , +3400000 );if ((ret <=0 ) || (!(caps[0 ] &SDHCI_CAN_VDD_330 ))) caps[0 ] &= ~SDHCI_CAN_VDD_330 ; - ret =regulator_is_supported_voltage (host->vmmc,3000000 , -3000000 ); + ret =regulator_is_supported_voltage (host->vmmc,2900000 , +3100000 );if ((ret <=0 ) || (!(caps[0 ] &SDHCI_CAN_VDD_300 ))) caps[0 ] &= ~SDHCI_CAN_VDD_300 ; - ret =regulator_is_supported_voltage (host->vmmc,1800000 , -1800000 ); + ret =regulator_is_supported_voltage (host->vmmc,1650000 , +1950000 );if ((ret <=0 ) || (!(caps[0 ] &SDHCI_CAN_VDD_180 ))) caps[0 ] &= ~SDHCI_CAN_VDD_180 ; }
Signature · 1 line
1.7.0.4
PATCH v4 3/15 mmc: sdhci: refine code for sd clock disable/enable in set ios
In reply to Kevin LiuFrom: Kevin Liu <[email protected]>
With preset value enabled, there are two continuous times of sd clock disable/enable. They can be combined into one to save time and make code cleaner.
--- drivers/mmc/host/sdhci.c | 29 +++++++++-------------------- 1 files changed, 9 insertions(+), 20 deletions(-)
drivers/mmc/host/sdhci.c +9 -20
@@ -1449,33 +1449,22 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) ctrl_2 |=SDHCI_CTRL_DRV_TYPE_C ;sdhci_writew (host, ctrl_2,SDHCI_HOST_CONTROL2 ); - }else { -/* -* According to SDHC Spec v3.00, if the Preset Value -* Enable in the Host Control 2 register is set, we -* need to reset SD Clock Enable before changing High -* Speed Enable to avoid generating clock gliches. -*/ - -/* Reset SD Clock Enable */ - clk =sdhci_readw (host,SDHCI_CLOCK_CONTROL ); - clk &= ~SDHCI_CLOCK_CARD_EN ; -sdhci_writew (host, clk,SDHCI_CLOCK_CONTROL ); - -sdhci_writeb (host, ctrl,SDHCI_HOST_CONTROL ); - -/* Re-enable SD Clock */ - clock = host->clock; - host->clock =0 ; -sdhci_set_clock (host, clock); } -/* Reset SD Clock Enable */ clk =sdhci_readw (host,SDHCI_CLOCK_CONTROL ); clk &= ~SDHCI_CLOCK_CARD_EN ;sdhci_writew (host, clk,SDHCI_CLOCK_CONTROL ); +/* +* According to SDHC Spec v3.00, if the Preset Value +* Enable in the Host Control 2 register is set, we +* need to reset SD Clock Enable before changing High +* Speed Enable to avoid generating clock gliches. +*/ +if (ctrl_2 &SDHCI_CTRL_PRESET_VAL_ENABLE ) +sdhci_writeb (host, ctrl,SDHCI_HOST_CONTROL ); +if (host->ops->set_uhs_signaling) host->ops->set_uhs_signaling (host, ios->timing);else {
Signature · 1 line
1.7.0.4
PATCH v4 4/15 mmc: sdhci: keep the saved clock var up to date
In reply to Kevin LiuFrom: Kevin Liu <[email protected]>
The clock rate set to the sdh controller may not exactly as requested by the mmc core, this patch make the clock rate saved in the mmc_ios and sdhci_host updated with the actual setting as in the controller. Thus "/sys/kernel/debug/mmcx/ios" and card detect prints can show the correct clock rate.
--- drivers/mmc/host/sdhci.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/mmc/host/sdhci.c +5 -1
@@ -1199,7 +1199,10 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)sdhci_writew (host, clk,SDHCI_CLOCK_CONTROL ); out: - host->clock = clock; +if (real_div) + host->clock = host->mmc->actual_clock; +else + host->clock = clock; }static int sdhci_set_power (struct sdhci_host *host,unsigned short power)
@@ -1375,6 +1378,7 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) }sdhci_set_clock (host, ios->clock); + ios->clock = host->clock;if (ios->power_mode ==MMC_POWER_OFF ) vdd_bit =sdhci_set_power (host,-1 );
Signature · 1 line
1.7.0.4
Re: [PATCH v4 04/15] mmc: sdhci: keep the saved clock var up to date
Quoted 7 lines · Kevin Liu
From: Kevin Liu <[email protected]>
The clock rate set to the sdh controller may not exactly as requested by the mmc core, this patch make the clock rate saved in the
mmc_iosandsdhci_hostupdated with the actual setting as in the controller. Thus "/sys/kernel/debug/mmcx/ios" and card detect prints can show the correct clock rate.
The patch may not required if only updating debugfs, since actual_clock already been considered in debugfs.
However, does incorrect ios->clock cause unexpected result, such as powerclass. If so, how about directly correct ios->clock, and remove actual_clock at all?
/Zhangfei
PATCH v4 5/15 mmc: sdhci: fix null return check of regulator_get
In reply to Kevin LiuFrom: Kevin Liu <[email protected]>
regulator_get() returns NULL when CONFIG_REGULATOR not defined, which should not print out the warning.
--- drivers/mmc/host/sdhci.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-)
drivers/mmc/host/sdhci.c +12 -6
@@ -2845,9 +2845,12 @@ int sdhci_add_host(struct sdhci_host *host)/* If vqmmc regulator and no 1.8V signalling, then there's no UHS */ host->vqmmc =regulator_get (mmc_dev (mmc),"vqmmc" ); -if (IS_ERR (host->vqmmc)) { -pr_info ("%s: no vqmmc regulator found\n" ,mmc_hostname (mmc)); - host->vqmmc =NULL ; +if (IS_ERR_OR_NULL (host->vqmmc)) { +if (PTR_ERR (host->vqmmc) <0 ) { +pr_info ("%s: no vqmmc regulator found\n" , +mmc_hostname (mmc)); + host->vqmmc =NULL ; + } }else if (regulator_is_supported_voltage (host->vqmmc,1650000 ,1950000 ))regulator_enable (host->vqmmc);
@@ -2912,9 +2915,12 @@ int sdhci_add_host(struct sdhci_host *host) ocr_avail =0 ; host->vmmc =regulator_get (mmc_dev (mmc),"vmmc" ); -if (IS_ERR (host->vmmc)) { -pr_info ("%s: no vmmc regulator found\n" ,mmc_hostname (mmc)); - host->vmmc =NULL ; +if (IS_ERR_OR_NULL (host->vmmc)) { +if (PTR_ERR (host->vmmc) <0 ) { +pr_info ("%s: no vmmc regulator found\n" , +mmc_hostname (mmc)); + host->vmmc =NULL ; + } }else regulator_enable (host->vmmc);
Signature · 1 line
1.7.0.4
PATCH v4 6/15 mmc: sdhci-pxav3: controller can't get base clock
In reply to Kevin LiuFrom: Kevin Liu <[email protected]>
Enable the quirk SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN since SD_CAPABILITIES_1[15:8](BASE_FREQ) can't get correct base clock value. It return a fixed pre-set value like 200 on some sdhci-pxav3 based platforms like MMP3 while return 0 on the other sdhci-pxav3 based platforms.
So we enable the quirk and get the base clock via function get_max_clock.
--- drivers/mmc/host/sdhci-pxav3.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/mmc/host/sdhci-pxav3.c +2 -1
@@ -249,7 +249,8 @@ static int __devinit sdhci_pxav3_probe(struct platform_device *pdev) host->quirks =SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC - |SDHCI_QUIRK_32BIT_ADMA_SIZE ; + |SDHCI_QUIRK_32BIT_ADMA_SIZE + |SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN ;/* enable 1/8V DDR capable */ host->mmc->caps |=MMC_CAP_1_8V_DDR ;
Signature · 1 line
1.7.0.4
Re: [PATCH v4 06/15] mmc: sdhci-pxav3: controller can't get base clock
Quoted 9 lines · Kevin Liu
From: Kevin Liu <[email protected]>
Enable the quirk
SDHCI_QUIRK_CAP_CLOCK_BASE_BROKENsince SD_CAPABILITIES_1[15:8](BASE_FREQ) can't get correct base clock value. It return a fixed pre-set value like 200 on some sdhci-pxav3 based platforms like MMP3 while return 0 on the other sdhci-pxav3 based platforms.
So we enable the quirk and get the base clock via functionget_max_clock.
Could you provide get_max_clock as well.
Re: [PATCH v4 06/15] mmc: sdhci-pxav3: controller can't get base clock
2012/9/27 zhangfei gao <[email protected]>:
Quoted 11 lines · Kevin Liu
Quoted 9 lines
From: Kevin Liu <[email protected]>
Enable the quirk
SDHCI_QUIRK_CAP_CLOCK_BASE_BROKENsince SD_CAPABILITIES_1[15:8](BASE_FREQ) can't get correct base clock value. It return a fixed pre-set value like 200 on some sdhci-pxav3 based platforms like MMP3 while return 0 on the other sdhci-pxav3 based platforms.
So we enable the quirk and get the base clock via functionget_max_clock.
Quoted 1 line
Could you provide
get_max_clockas well.
Thanks, will add this.
PATCH v4 7/15 mmc: host: adjust uhs timing value
In reply to Kevin LiuFrom: Kevin Liu <[email protected]>
Both of MMC_TIMING_LEGACY and MMC_TIMING_UHS_SDR12 are defined to 0. And ios->timing is set to MMC_TIMING_LEGACY during power up. But set_ios can't distinguish these two timing if host support spec 3.0. Just adjust timing values to be different can resolve this issue without any other impact.
--- include/linux/mmc/host.h | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
include/linux/mmc/host.h +6 -6
@@ -53,12 +53,12 @@ struct mmc_ios {#define MMC_TIMING_LEGACY 0#define MMC_TIMING_MMC_HS 1#define MMC_TIMING_SD_HS 2 -#define MMC_TIMING_UHS_SDR12 MMC_TIMING_LEGACY -#define MMC_TIMING_UHS_SDR25 MMC_TIMING_SD_HS -#define MMC_TIMING_UHS_SDR50 3 -#define MMC_TIMING_UHS_SDR104 4 -#define MMC_TIMING_UHS_DDR50 5 -#define MMC_TIMING_MMC_HS200 6 +#define MMC_TIMING_UHS_SDR12 3 +#define MMC_TIMING_UHS_SDR25 4 +#define MMC_TIMING_UHS_SDR50 5 +#define MMC_TIMING_UHS_SDR104 6 +#define MMC_TIMING_UHS_DDR50 7 +#define MMC_TIMING_MMC_HS200 8#define MMC_SDR_MODE 0#define MMC_1_2V_DDR_MODE 1
Signature · 1 line
1.7.0.4
Re: [PATCH v4 07/15] mmc: host: adjust uhs timing value
Reviewed By: Girish K S <[email protected]>
Quoted 44 lines · Kevin Liu
From: Kevin Liu <[email protected]>
Both of
MMC_TIMING_LEGACYandMMC_TIMING_UHS_SDR12are defined to 0. Andios->timingis set toMMC_TIMING_LEGACYduring power up. Butset_ioscan't distinguish these two timing if host support spec 3.0. Just adjust timing values to be different can resolve this issue without any other impact.Acked-by Ulf Hansson <[email protected]>Signed-off-by Kevin Liu <[email protected]>--- include/linux/mmc/host.h | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)include/linux/mmc/host.h +6
-7@@ -53,12 +53,12 @@ struct mmc_ios {#define MMC_TIMING_LEGACY 0#define MMC_TIMING_MMC_HS 1#define MMC_TIMING_SD_HS 2 -#define MMC_TIMING_UHS_SDR12 MMC_TIMING_LEGACY -#define MMC_TIMING_UHS_SDR25 MMC_TIMING_SD_HS -#define MMC_TIMING_UHS_SDR50 3 -#define MMC_TIMING_UHS_SDR104 4 -#define MMC_TIMING_UHS_DDR50 5 -#define MMC_TIMING_MMC_HS200 6 +#define MMC_TIMING_UHS_SDR12 3 +#define MMC_TIMING_UHS_SDR25 4 +#define MMC_TIMING_UHS_SDR50 5 +#define MMC_TIMING_UHS_SDR104 6 +#define MMC_TIMING_UHS_DDR50 7 +#define MMC_TIMING_MMC_HS200 8#define MMC_SDR_MODE 0#define MMC_1_2V_DDR_MODE 1 --1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 8/15 mmc: sdhci: enhance preset value function
In reply to Kevin LiuFrom: Kevin Liu <[email protected]>
Preset value support was added by 4d55c5a1.
But preset value is enabled after setting clock finished, which means the clock is still set by driver firstly and then switch to preset value at this point. So the driver setting beforehand is useless and unnecessary. What's more, driver is still using the old value which may differ from the preset one. The better way is enable preset value just after switch to UHS mode so the preset value can be used directly. So move preset value enable from mmc_sd_init_card to sdhci_set_ios which will be called during set timing.
And preset value is disabled at the begining of mmc_attach_sd. It's a bit late since low freq should be set in mmc_power_up. So move preset value disable to sdhci_set_ios which will be called during power up.
Also update host->clock and ios->drv_type according to the preset value.
--- drivers/mmc/core/sd.c | 17 ------ drivers/mmc/host/sdhci.c | 128 ++++++++++++++++++++++++++++++-------------- drivers/mmc/host/sdhci.h | 12 ++++ include/linux/mmc/host.h | 1 - include/linux/mmc/sdhci.h | 2 +- 5 files changed, 100 insertions(+), 60 deletions(-)
drivers/mmc/core/sd.c +0 -17
@@ -960,16 +960,6 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,/* Card is an ultra-high-speed card */ mmc_card_set_uhs (card); - -/* -* Since initialization is now complete, enable preset -* value registers for UHS-I cards. -*/ -if (host->ops->enable_preset_value) { -mmc_host_clk_hold (card->host); - host->ops->enable_preset_value (host, true); -mmc_host_clk_release (card->host); - } }else {/* * Attempt to change to high-speed (if supported)
@@ -1148,13 +1138,6 @@ int mmc_attach_sd(struct mmc_host *host)BUG_ON (!host);WARN_ON (!host->claimed); -/* Disable preset value enable if already set since last time */ -if (host->ops->enable_preset_value) { -mmc_host_clk_hold (host); - host->ops->enable_preset_value (host, false); -mmc_host_clk_release (host); - } - err =mmc_send_app_op_cond (host,0 , &ocr);if (err)return err;
drivers/mmc/host/sdhci.c +87 -41
202 lines not on this page · raw message
drivers/mmc/host/sdhci.h +12 -0
@@ -227,6 +227,18 @@/* 60-FB reserved */ +#define SDHCI_PRESET_FOR_SDR12 0x66 +#define SDHCI_PRESET_FOR_SDR25 0x68 +#define SDHCI_PRESET_FOR_SDR50 0x6A +#define SDHCI_PRESET_FOR_SDR104 0x6C +#define SDHCI_PRESET_FOR_DDR50 0x6E +#define SDHCI_PRESET_DRV_MASK 0xC000 +#define SDHCI_PRESET_DRV_SHIFT 14 +#define SDHCI_PRESET_CLKGEN_SEL_MASK 0x400 +#define SDHCI_PRESET_CLKGEN_SEL_SHIFT 10 +#define SDHCI_PRESET_SDCLK_FREQ_MASK 0x3FF +#define SDHCI_PRESET_SDCLK_FREQ_SHIFT 0 +#define SDHCI_SLOT_INT_STATUS 0xFC#define SDHCI_HOST_VERSION 0xFE
include/linux/mmc/host.h +0 -1
@@ -133,7 +133,6 @@ struct mmc_host_ops {/* The tuning command opcode value is different for SD and eMMC cards */ int (*execute_tuning)(struct mmc_host *host,u32 opcode); -void (*enable_preset_value)(struct mmc_host *host,bool enable);int (*select_drive_strength)(unsigned int max_dtr,int host_drv,int card_drv);void (*hw_reset)(struct mmc_host *host); };
include/linux/mmc/sdhci.h +1 -1
@@ -91,7 +91,7 @@ struct sdhci_host {unsigned int quirks2;/* More deviations from spec. */ #define SDHCI_QUIRK2_HOST_OFF_CARD_ON (1<<0) - +#define SDHCI_QUIRK2_PRESET_VALUE_BROKEN (1<<1)int irq;/* Device IRQ */ void __iomem *ioaddr;/* Mapped address */
Signature · 1 line
1.7.0.4
PATCH v4 9/15 mmc: sdhci-pxav3: add quirks2
In reply to Kevin LiuFrom: Kevin Liu <[email protected]>
--- drivers/mmc/host/sdhci-pxav3.c | 2 ++ include/linux/platform_data/pxa_sdhci.h | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-)
drivers/mmc/host/sdhci-pxav3.c +2 -0
@@ -272,6 +272,8 @@ static int __devinit sdhci_pxav3_probe(struct platform_device *pdev)if (pdata->quirks) host->quirks |= pdata->quirks; +if (pdata->quirks2) + host->quirks2 |= pdata->quirks2;if (pdata->host_caps) host->mmc->caps |= pdata->host_caps;if (pdata->host_caps2)
include/linux/platform_data/pxa_sdhci.h +2 -0
@@ -38,6 +38,7 @@* @max_speed: the maximum speed supported * @host_caps: Standard MMC host capabilities bit field. * @quirks: quirks of platfrom +* @quirks2: quirks2 of platfrom * @pm_caps: pm_caps of platfrom */ struct sdhci_pxa_platdata {
@@ -51,6 +52,7 @@ struct sdhci_pxa_platdata {unsigned int host_caps;unsigned int host_caps2;unsigned int quirks; +unsigned int quirks2;unsigned int pm_caps; };
Signature · 1 line
1.7.0.4
Re: [PATCH v4 09/15] mmc: sdhci-pxav3: add quirks2
Quoted 13 lines
include/linux/platform_data/pxa_sdhci.h +1
-0@@ -38,6 +38,7 @@* @max_speed: the maximum speed supported * @host_caps: Standard MMC host capabilities bit field. * @quirks: quirks of platfrom +* @quirks2: quirks2 of platfrom * @pm_caps: pm_caps of platfrom */ struct sdhci_pxa_platdata {
include/linux/platform_data/pxa_sdhci.h struct sdhci_pxa_platdata { · line 58
Quoted 7 lines
include/linux/platform_data/pxa_sdhci.h +1
-0@@ -51,6 +52,7 @@ struct sdhci_pxa_platdata {unsigned int host_caps;unsigned int host_caps2;unsigned int quirks; +unsigned int quirks2;unsigned int pm_caps; };
Not find the patch using quirks2.
Could you merge the patch together?
Re: [PATCH v4 09/15] mmc: sdhci-pxav3: add quirks2
2012/9/27 zhangfei gao <[email protected]>:
Quoted 14 lines
Quoted 14 lines
include/linux/platform_data/pxa_sdhci.h +1
-0@@ -38,6 +38,7 @@* @max_speed: the maximum speed supported * @host_caps: Standard MMC host capabilities bit field. * @quirks: quirks of platfrom +* @quirks2: quirks2 of platfrom * @pm_caps: pm_caps of platfrom */ struct sdhci_pxa_platdata {@@ -51,6 +52,7 @@ struct sdhci_pxa_platdata {unsigned int host_caps;
Quoted 8 lines
include/linux/platform_data/pxa_sdhci.h struct sdhci_pxa_platdata { · line 58
Quoted 6 lines
include/linux/platform_data/pxa_sdhci.h +1
-0unsigned int host_caps2;unsigned int quirks; +unsigned int quirks2;unsigned int pm_caps; };Not find the patch using quirks2.
Could you merge the patch together?
In my another patch "[PATCH v4 08/15] mmc: sdhci: enhance preset value function", I introduced SDHCI_QUIRK2_PRESET_VALUE_BROKEN, which located in quirks2. So I added this. We should not combine this together.
PATCH v4 10/15 mmc: sdhci: introduce signal_voltage_switch callback function
In reply to Kevin LiuFrom: Kevin Liu <[email protected]>
Some soc/platform need specific handling for signal voltage switch. For example, mmp2/mmp3 need to set the AIB IO domain control register accordingly.
--- drivers/mmc/host/sdhci.c | 17 +++++++++++++++++ drivers/mmc/host/sdhci.h | 1 + 2 files changed, 18 insertions(+), 0 deletions(-)
drivers/mmc/host/sdhci.c +17 -0
@@ -1684,6 +1684,15 @@ static int sdhci_do_3_3v_signal_voltage_switch(struct sdhci_host *host,return -EIO ; } } + +/* +* May need to apply soc/platfrom settings for the +* voltage switch +*/ +if (host->ops->signal_voltage_switch) + host->ops->signal_voltage_switch (host, + host->mmc->ios.signal_voltage); +/* Wait for 5ms */ usleep_range (5000 ,5500 );
@@ -1726,6 +1735,14 @@ static int sdhci_do_1_8v_signal_voltage_switch(struct sdhci_host *host, ret =0 ;if (!ret) { +/* +* May need to apply soc/platfrom settings for the +* voltage switch +*/ +if (host->ops->signal_voltage_switch) + host->ops->signal_voltage_switch (host, + host->mmc->ios.signal_voltage); + ctrl |=SDHCI_CTRL_VDD_180 ;sdhci_writew (host, ctrl,SDHCI_HOST_CONTROL2 );
drivers/mmc/host/sdhci.h +1 -0
@@ -290,6 +290,7 @@ struct sdhci_ops {void (*hw_reset)(struct sdhci_host *host);void (*platform_suspend)(struct sdhci_host *host);void (*platform_resume)(struct sdhci_host *host); +void (*signal_voltage_switch)(struct sdhci_host *host,u8 vol); };#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
Signature · 1 line
1.7.0.4
PATCH v4 11/15 mmc: sdhci-pxav3: add signal_voltage_switch function
In reply to Kevin LiuFrom: Kevin Liu <[email protected]>
--- drivers/mmc/host/sdhci-pxav3.c | 25 +++++++++++++++++++++++++ include/linux/platform_data/pxa_sdhci.h | 2 ++ 2 files changed, 27 insertions(+), 0 deletions(-)
drivers/mmc/host/sdhci-pxav3.c +25 -0
@@ -163,10 +163,35 @@ static int pxav3_set_uhs_signaling(struct sdhci_host *host, unsigned int uhs)return 0 ; } +static void pxav3_signal_voltage_switch (struct sdhci_host *host,u8 vol) +{ +struct platform_device *pdev =to_platform_device (mmc_dev (host->mmc)); +struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data; +unsigned int set; + +switch (vol) { +case MMC_SIGNAL_VOLTAGE_330 : + set =3300000 ; +break ; +case MMC_SIGNAL_VOLTAGE_180 : + set =1800000 ; +break ; +case MMC_SIGNAL_VOLTAGE_120 : + set =1200000 ; +break ; +default : + set =3300000 ; +break ; + } +if (pdata && pdata->signal_voltage_switch) + pdata->signal_voltage_switch (set); +} +static struct sdhci_ops pxav3_sdhci_ops = { .platform_reset_exit = pxav3_set_private_registers, .set_uhs_signaling = pxav3_set_uhs_signaling, .platform_send_init_74_clocks = pxav3_gen_init_74_clocks, + .signal_voltage_switch = pxav3_signal_voltage_switch, };#ifdef CONFIG_OF
include/linux/platform_data/pxa_sdhci.h +2 -0
@@ -40,6 +40,7 @@* @quirks: quirks of platfrom * @quirks2: quirks2 of platfrom * @pm_caps: pm_caps of platfrom +* @signal_voltage_switch: soc/platfrom handling needed for voltage switch */ struct sdhci_pxa_platdata {unsigned int flags;
@@ -54,6 +55,7 @@ struct sdhci_pxa_platdata {unsigned int quirks;unsigned int quirks2;unsigned int pm_caps; +void (*signal_voltage_switch)(unsigned int set); };struct sdhci_pxa {
Signature · 1 line
1.7.0.4
Re: [PATCH v4 11/15] mmc: sdhci-pxav3: add signal_voltage_switch function
Quoted 19 lines
drivers/mmc/host/sdhci-pxav3.c +4
-0+if (pdata && pdata->signal_voltage_switch) + pdata->signal_voltage_switch (set); +} +#ifdef CONFIG_OF include/linux/platform_data/pxa_sdhci.h +1
-0@@ -40,6 +40,7 @@* @quirks: quirks of platfrom * @quirks2: quirks2 of platfrom * @pm_caps: pm_caps of platfrom +* @signal_voltage_switch: soc/platfrom handling needed for voltage switch */ struct sdhci_pxa_platdata {unsigned int flags;
include/linux/platform_data/pxa_sdhci.h struct sdhci_pxa_platdata { · line 60
Quoted 6 lines
include/linux/platform_data/pxa_sdhci.h +1
-0@@ -54,6 +55,7 @@ struct sdhci_pxa_platdata {unsigned int quirks;unsigned int quirks2;unsigned int pm_caps; +void (*signal_voltage_switch)(unsigned int set); };
Using callback from pdata is in-acceptable.
DT can not doing such way.
/Zhangfei
PATCH v4 12/15 mmc: core: add new 1.8v flag for mmc
In reply to Kevin LiuFrom: Kevin Liu <[email protected]>
Mmc does NOT have special sequence requirements for 1.8v signal voltage setting compared to sd and sdio. Add a new 1.8v flag for mmc so as to use the same start_signal_voltage_switch interface.
--- drivers/mmc/core/mmc.c | 3 ++- include/linux/mmc/host.h | 1 + 2 files changed, 3 insertions(+), 1 deletions(-)
drivers/mmc/core/mmc.c +2 -1
@@ -758,7 +758,8 @@ static int mmc_select_hs200(struct mmc_card *card)if (err && card->ext_csd.card_type &EXT_CSD_CARD_TYPE_SDR_1_8V && host->caps2 &MMC_CAP2_HS200_1_8V_SDR ) - err =mmc_set_signal_voltage (host,MMC_SIGNAL_VOLTAGE_180 ,0 ); + err =mmc_set_signal_voltage (host, +MMC_SIGNAL_VOLTAGE_MMC_180 ,0 );/* If fails try again during next card power cycle */ if (err)
include/linux/mmc/host.h +1 -0
@@ -71,6 +71,7 @@ struct mmc_ios {#define MMC_SIGNAL_VOLTAGE_330 0#define MMC_SIGNAL_VOLTAGE_180 1#define MMC_SIGNAL_VOLTAGE_120 2 +#define MMC_SIGNAL_VOLTAGE_MMC_180 3unsigned char drv_type;/* driver type (A, B, C, D) */
Signature · 1 line
1.7.0.4
Re: [PATCH v4 12/15] mmc: core: add new 1.8v flag for mmc
Hi Kevin,
Quoted 6 lines · Kevin Liu
From: Kevin Liu <[email protected]>
Mmc does NOT have special sequence requirements for 1.8v signal voltage setting compared to sd and sdio. Add a new 1.8v flag for mmc so as to use the same
start_signal_voltage_switchinterface.
This problem is protocol issue and should not be solved in the host driver. We have more issues for signal_voltage switch as well.
Please have a look at Johan Rudholms patches:
[PATCH v2 1/2] mmc: core: Proper signal voltage switch [PATCH v2 2/2] mmc: core: Power cycle card on voltage switch fail
Quoted 34 lines
Signed-off-by Kevin Liu <[email protected]>--- drivers/mmc/core/mmc.c | 3 ++- include/linux/mmc/host.h | 1 + 2 files changed, 3 insertions(+), 1 deletions(-)drivers/mmc/core/mmc.c +2
-1@@ -758,7 +758,8 @@ static int mmc_select_hs200(struct mmc_card *card)if (err && card->ext_csd.card_type &EXT_CSD_CARD_TYPE_SDR_1_8V && host->caps2 &MMC_CAP2_HS200_1_8V_SDR ) - err =mmc_set_signal_voltage (host,MMC_SIGNAL_VOLTAGE_180 ,0 ); + err =mmc_set_signal_voltage (host, +MMC_SIGNAL_VOLTAGE_MMC_180 ,0 );/* If fails try again during next card power cycle */ if (err)include/linux/mmc/host.h +1
-1@@ -71,6 +71,7 @@ struct mmc_ios {#define MMC_SIGNAL_VOLTAGE_330 0#define MMC_SIGNAL_VOLTAGE_180 1#define MMC_SIGNAL_VOLTAGE_120 2 +#define MMC_SIGNAL_VOLTAGE_MMC_180 3unsigned char drv_type;/* driver type (A, B, C, D) */ --
Quoted 2 lines
1.7.0.4
Kind regards
Ulf Hansson
Re: [PATCH v4 12/15] mmc: core: add new 1.8v flag for mmc
Hi, Ulf
2012/9/27 Ulf Hansson <[email protected]>:
Quoted 10 lines
Hi Kevin,
Quoted 6 lines · Kevin Liu
From: Kevin Liu <[email protected]>
Mmc does NOT have special sequence requirements for 1.8v signal voltage setting compared to sd and sdio. Add a new 1.8v flag for mmc so as to use the same
start_signal_voltage_switchinterface.
Quoted 7 lines
This problem is protocol issue and should not be solved in the host driver. We have more issues for
signal_voltageswitch as well.Please have a look at Johan Rudholms patches:
[PATCH v2 1/2] mmc: core: Proper signal voltage switch [PATCH v2 2/2] mmc: core: Power cycle card on voltage switch fail
I agree that we should do more things in protocal driver. But the real voltage switch work is still done in host driver. If we keep only one voltage switch interface, then we need to add a flag to distinguish sd/sdio or emmc. Or we should define two interfaces to call different host functions to handle this.
Johan's patches can't solve my issue.
Thanks
Kevin
Re: [PATCH v4 12/15] mmc: core: add new 1.8v flag for mmc
Quoted 20 lines · Kevin Liu
Hi, Ulf
2012/9/27 Ulf Hansson <[email protected]>:
Quoted 10 lines
Hi Kevin,
Quoted 6 lines · Kevin Liu
From: Kevin Liu <[email protected]>
Mmc does NOT have special sequence requirements for 1.8v signal voltage setting compared to sd and sdio. Add a new 1.8v flag for mmc so as to use the same
start_signal_voltage_switchinterface.Quoted 7 lines
This problem is protocol issue and should not be solved in the host driver. We have more issues for
signal_voltageswitch as well.Please have a look at Johan Rudholms patches:
[PATCH v2 1/2] mmc: core: Proper signal voltage switch [PATCH v2 2/2] mmc: core: Power cycle card on voltage switch fail
Quoted 6 lines
I agree that we should do more things in protocal driver. But the real voltage switch work is still done in host driver. If we keep only one voltage switch interface, then we need to add a flag to distinguish sd/sdio or emmc. Or we should define two interfaces to call different host functions to handle this.
Johan's patches can't solve my issue.
I understand that your driver today take care of specific things for sd/sdio. The reason for that is because of the protocol layer is not doing the voltage switch properly.
The idea with Johans patches is resolve all these issues. Thus the host driver will just be responsible for the actual voltage switch to happen. So in the end your voltage switch function in the host is supposed to be rather simple.
If you still think you need to handle sd/sdio/eMMC in a specific manner in your driver, there are always mmc_card_sdio|sd|mmc functions you can use.
Quoted 3 lines
Thanks
Kevin
Kind regards
Ulf Hansson
Re: [PATCH v4 12/15] mmc: core: add new 1.8v flag for mmc
2012/9/27 Ulf Hansson <[email protected]>:
Quoted 28 lines · Kevin Liu
Quoted 20 lines
Hi, Ulf
2012/9/27 Ulf Hansson <[email protected]>:
Quoted 10 lines
Hi Kevin,
Quoted 6 lines · Kevin Liu
From: Kevin Liu <[email protected]>
Mmc does NOT have special sequence requirements for 1.8v signal voltage setting compared to sd and sdio. Add a new 1.8v flag for mmc so as to use the same
start_signal_voltage_switchinterface.Quoted 7 lines
This problem is protocol issue and should not be solved in the host driver. We have more issues for
signal_voltageswitch as well.Please have a look at Johan Rudholms patches:
[PATCH v2 1/2] mmc: core: Proper signal voltage switch [PATCH v2 2/2] mmc: core: Power cycle card on voltage switch failQuoted 6 lines
I agree that we should do more things in protocal driver. But the real voltage switch work is still done in host driver. If we keep only one voltage switch interface, then we need to add a flag to distinguish sd/sdio or emmc. Or we should define two interfaces to call different host functions to handle this.
Johan's patches can't solve my issue.
Quoted 8 lines
I understand that your driver today take care of specific things for sd/sdio. The reason for that is because of the protocol layer is not doing the voltage switch properly.
The idea with Johans patches is resolve all these issues. Thus the host driver will just be responsible for the actual voltage switch to happen. So in the end your voltage switch function in the host is supposed to be rather simple.
Ok, Johans new patch is reasonable so I will hold this patch.
Quoted 4 lines
If you still think you need to handle sd/sdio/eMMC in a specific manner in your driver, there are always mmc_card_sdio|sd|mmc functions you can use.
voltage_switch sometimes is called very early even before card type init.
Thanks
Kevin
PATCH v4 13/15 mmc: sdhci: add mmc 1.8v signal voltage switch function
In reply to Kevin LiuFrom: Kevin Liu <[email protected]>
Add the function since MMC 1.8v signal voltage switch don't need the same switch sequence requirements as SD/SDIO.
--- drivers/mmc/host/sdhci.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 45 insertions(+), 1 deletions(-)
drivers/mmc/host/sdhci.c +45 -1
@@ -1794,6 +1794,46 @@ static int sdhci_do_1_8v_signal_voltage_switch(struct sdhci_host *host,return -EAGAIN ; } +static int sdhci_mmc_do_1_8v_signal_voltage_switch (struct sdhci_host *host, +u16 ctrl) +{ +int ret; + +if (host->vqmmc) { + ret =regulator_set_voltage (host->vqmmc,1700000 ,1950000 ); +if (ret) { +pr_warning ("%s: Switching to 1.8V signalling voltage " +" failed\n" ,mmc_hostname (host->mmc)); +return -EIO ; + } + } + +/* +* May need to apply soc/platfrom settings for the +* voltage switch +*/ +if (host->ops->signal_voltage_switch) + host->ops->signal_voltage_switch (host, + host->mmc->ios.signal_voltage); + +/* Enable 1.8V Signal Enable in the Host Control2 register */ + ctrl |=SDHCI_CTRL_VDD_180 ; +sdhci_writew (host, ctrl,SDHCI_HOST_CONTROL2 ); + +/* Wait for 5ms */ +usleep_range (5000 ,5500 ); + +/* 1.8V regulator output should be stable within 5 ms */ + ctrl =sdhci_readw (host,SDHCI_HOST_CONTROL2 ); +if (ctrl &SDHCI_CTRL_VDD_180 ) +return 0 ; + +pr_warning ("%s: 1.8V regulator output did not became stable\n" , +mmc_hostname (host->mmc)); + +return -EIO ; +} +static int sdhci_do_start_signal_voltage_switch (struct sdhci_host *host,struct mmc_ios *ios) {
@@ -1814,8 +1854,12 @@ static int sdhci_do_start_signal_voltage_switch(struct sdhci_host *host,if (ios->signal_voltage ==MMC_SIGNAL_VOLTAGE_330 )return sdhci_do_3_3v_signal_voltage_switch (host, ctrl);else if (!(ctrl &SDHCI_CTRL_VDD_180 ) && - (ios->signal_voltage ==MMC_SIGNAL_VOLTAGE_180 )) + (ios->signal_voltage ==MMC_SIGNAL_VOLTAGE_180 ))return sdhci_do_1_8v_signal_voltage_switch (host, ctrl); +else if (!(ctrl &SDHCI_CTRL_VDD_180 ) && + (ios->signal_voltage ==MMC_SIGNAL_VOLTAGE_MMC_180 )) +return sdhci_mmc_do_1_8v_signal_voltage_switch (host, + ctrl);else /* No signal voltage switch required */ return 0 ;
Signature · 1 line
1.7.0.4
PATCH v4 14/15 mmc: sdhci: fix the bug that DDR50 can't work for emmc
In reply to Kevin LiuFrom: Kevin Liu <[email protected]>
Host controller must enable 1.8v signal for UHS modes. Otherwise UHS modes won't take effect.
But mmc core does NOT switch to 1.8v for DDR50 mode. So enable the 1.8v signal for mmc DDR50 mode in host driver.
--- drivers/mmc/host/sdhci.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
drivers/mmc/host/sdhci.c +8 -1
@@ -1529,8 +1529,15 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) ctrl_2 |=SDHCI_CTRL_UHS_SDR50 ; else if (ios->timing == MMC_TIMING_UHS_SDR104) ctrl_2 |= SDHCI_CTRL_UHS_SDR104; - else if (ios->timing == MMC_TIMING_UHS_DDR50) + else if (ios->timing == MMC_TIMING_UHS_DDR50) { +struct mmc_card *card; + ctrl_2 |=SDHCI_CTRL_UHS_DDR50 ; + card =container_of (&(host->mmc), + struct mmc_card, host); +if (mmc_card_mmc (card)) + ctrl_2 |=SDHCI_CTRL_VDD_180 ; + }sdhci_writew (host, ctrl_2,SDHCI_HOST_CONTROL2 ); } if (!(host->quirks2 & SDHCI_QUIRK2_PRESET_VALUE_BROKEN) &&
Signature · 1 line
1.7.0.4
Re: [PATCH v4 14/15] mmc: sdhci: fix the bug that DDR50 can't work for emmc
Quoted 21 lines · Kevin Liu
From: Kevin Liu <[email protected]>
Host controller must enable 1.8v signal for UHS modes. Otherwise UHS modes won't take effect.
But mmc core does NOT switch to 1.8v for DDR50 mode. So enable the 1.8v signal for mmc DDR50 mode in host driver.Signed-off-by Kevin Liu <[email protected]>--- drivers/mmc/host/sdhci.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)drivers/mmc/host/sdhci.c +0
-0@@ -1529,8 +1529,15 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) ctrl_2 |=SDHCI_CTRL_UHS_SDR50 ; else if (ios->timing == MMC_TIMING_UHS_SDR104) ctrl_2 |= SDHCI_CTRL_UHS_SDR104;
drivers/mmc/host/sdhci.c static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) · line 1540
Quoted 10 lines
drivers/mmc/host/sdhci.c +8
-1-else if (ios->timing ==MMC_TIMING_UHS_DDR50 ) +else if (ios->timing ==MMC_TIMING_UHS_DDR50 ) { +struct mmc_card *card; + ctrl_2 |=SDHCI_CTRL_UHS_DDR50 ; + card =container_of (&(host->mmc), + struct mmc_card, host); +if (mmc_card_mmc (card)) + ctrl_2 |=SDHCI_CTRL_VDD_180 ; + }
If you want to set the voltage to 1.8. It has to be done from the core layer using the api mmc_set_signal_voltage during the mmc card init. as it is done for 1.2 volts switch. In the comment (mmc_card_init function) it is explicitly mentioned
* 1.8V vccq at 3.3V core voltage (vcc) is not required
* in the JEDEC spec for DDR.
can you please check it. Still if you feel its necessary to change the voltage to 1.8 v, you can do it from mmc_init_card function
Quoted 10 lines
drivers/mmc/host/sdhci.c +0
-1sdhci_writew (host, ctrl_2,SDHCI_HOST_CONTROL2 ); } if (!(host->quirks2 & SDHCI_QUIRK2_PRESET_VALUE_BROKEN) && --1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 14/15] mmc: sdhci: fix the bug that DDR50 can't work for emmc
2012/9/26 Girish K S <[email protected]>:
Quoted 32 lines · Kevin Liu
Quoted 21 lines
From: Kevin Liu <[email protected]>
Host controller must enable 1.8v signal for UHS modes. Otherwise UHS modes won't take effect.
But mmc core does NOT switch to 1.8v for DDR50 mode. So enable the 1.8v signal for mmc DDR50 mode in host driver.Signed-off-by Kevin Liu <[email protected]>--- drivers/mmc/host/sdhci.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)drivers/mmc/host/sdhci.c +0
-0@@ -1529,8 +1529,15 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) ctrl_2 |=SDHCI_CTRL_UHS_SDR50 ; else if (ios->timing == MMC_TIMING_UHS_SDR104) ctrl_2 |= SDHCI_CTRL_UHS_SDR104;drivers/mmc/host/sdhci.c static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) · line 1540
Quoted 10 lines
drivers/mmc/host/sdhci.c +8
-1-else if (ios->timing ==MMC_TIMING_UHS_DDR50 ) +else if (ios->timing ==MMC_TIMING_UHS_DDR50 ) { +struct mmc_card *card; + ctrl_2 |=SDHCI_CTRL_UHS_DDR50 ; + card =container_of (&(host->mmc), + struct mmc_card, host); +if (mmc_card_mmc (card)) + ctrl_2 |=SDHCI_CTRL_VDD_180 ; + }
Quoted 8 lines
If you want to set the voltage to 1.8. It has to be done from the core layer using the api
mmc_set_signal_voltageduring the mmc card init. as it is done for 1.2 volts switch. In the comment (mmc_card_initfunction) it is explicitly mentioned
* 1.8V vccq at 3.3V core voltage (vcc) is not required
* in the JEDEC spec for DDR.
can you please check it. Still if you feel its necessary to change the voltage to 1.8 v, you can do it frommmc_init_cardfunction
In JEDEC spec, there are two emmc device types which support DDR50. One type can work under signal 1.2v while the other type work under signal 1.8v or 3v. So current code just keep 3v for the second device type.
But in SD host spec, 1.8v signal must be enabled for all UHS modes taking effect.
So the fact is, if we use SD host to work with emmc chip, we have to select 1.8v in order to enable DDR50. Current code missed this.
Because DDR50 shall can work under both signal 1.8v and 3v according to JEDEC spec, So I don't want to switch to 1.8v in mmc core code. It's the host controller requirement that 1.8v signal must be enabled in order to enable DDR50, which conflict with emmc spec. So I added this in host driver.
Thanks
Kevin
Re: [PATCH v4 14/15] mmc: sdhci: fix the bug that DDR50 can't work for emmc
Quoted 52 lines · Kevin Liu
2012/9/26 Girish K S <[email protected]>:
Quoted 32 lines · Kevin Liu
Quoted 21 lines
From: Kevin Liu <[email protected]>
Host controller must enable 1.8v signal for UHS modes. Otherwise UHS modes won't take effect.
But mmc core does NOT switch to 1.8v for DDR50 mode. So enable the 1.8v signal for mmc DDR50 mode in host driver.Signed-off-by Kevin Liu <[email protected]>--- drivers/mmc/host/sdhci.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)drivers/mmc/host/sdhci.c +0
-0@@ -1529,8 +1529,15 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) ctrl_2 |=SDHCI_CTRL_UHS_SDR50 ; else if (ios->timing == MMC_TIMING_UHS_SDR104) ctrl_2 |= SDHCI_CTRL_UHS_SDR104;drivers/mmc/host/sdhci.c static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) · line 1540
Quoted 10 lines
drivers/mmc/host/sdhci.c +8
-1-else if (ios->timing ==MMC_TIMING_UHS_DDR50 ) +else if (ios->timing ==MMC_TIMING_UHS_DDR50 ) { +struct mmc_card *card; + ctrl_2 |=SDHCI_CTRL_UHS_DDR50 ; + card =container_of (&(host->mmc), + struct mmc_card, host); +if (mmc_card_mmc (card)) + ctrl_2 |=SDHCI_CTRL_VDD_180 ; + }Quoted 8 lines
If you want to set the voltage to 1.8. It has to be done from the core layer using the api
mmc_set_signal_voltageduring the mmc card init. as it is done for 1.2 volts switch. In the comment (mmc_card_initfunction) it is explicitly mentioned
* 1.8V vccq at 3.3V core voltage (vcc) is not required
* in the JEDEC spec for DDR.
can you please check it. Still if you feel its necessary to change the voltage to 1.8 v, you can do it frommmc_init_cardfunctionIn JEDEC spec, there are two emmc device types which support DDR50. One type can work under signal 1.2v while the other type work under signal 1.8v or 3v. So current code just keep 3v for the second device type.
But in SD host spec, 1.8v signal must be enabled for all UHS modes taking effect.
So the fact is, if we use SD host to work with emmc chip, we have to select 1.8v in order to enable DDR50. Current code missed this.
Quoted 5 lines
Because DDR50 shall can work under both signal 1.8v and 3v according to JEDEC spec, So I don't want to switch to 1.8v in mmc core code. It's the host controller requirement that 1.8v signal must be enabled in order to enable DDR50, which conflict with emmc spec. So I added this in host driver.
I understand. Thanks
Quoted 3 lines
Thanks
Kevin
PATCH v4 15/15 mmc: sdhci-pxav3: remove set_uhs_signaling function
In reply to Kevin LiuFrom: Kevin Liu <[email protected]>
Because sdhci can do the same thing so no need to implement this.
--- drivers/mmc/host/sdhci-pxav3.c | 39 --------------------------------------- 1 files changed, 0 insertions(+), 39 deletions(-)
drivers/mmc/host/sdhci-pxav3.c +0 -39
@@ -125,44 +125,6 @@ static void pxav3_gen_init_74_clocks(struct sdhci_host *host, u8 power_mode) pxa->power_mode = power_mode; } -static int pxav3_set_uhs_signaling (struct sdhci_host *host,unsigned int uhs) -{ -u16 ctrl_2; - -/* -* Set V18_EN -- UHS modes do not work without this. -* does not change signaling voltage -*/ - ctrl_2 =sdhci_readw (host,SDHCI_HOST_CONTROL2 ); - -/* Select Bus Speed Mode for host */ - ctrl_2 &= ~SDHCI_CTRL_UHS_MASK ; -switch (uhs) { -case MMC_TIMING_UHS_SDR12 : - ctrl_2 |=SDHCI_CTRL_UHS_SDR12 ; -break ; -case MMC_TIMING_UHS_SDR25 : - ctrl_2 |=SDHCI_CTRL_UHS_SDR25 ; -break ; -case MMC_TIMING_UHS_SDR50 : - ctrl_2 |=SDHCI_CTRL_UHS_SDR50 |SDHCI_CTRL_VDD_180 ; -break ; -case MMC_TIMING_UHS_SDR104 : - ctrl_2 |=SDHCI_CTRL_UHS_SDR104 |SDHCI_CTRL_VDD_180 ; -break ; -case MMC_TIMING_UHS_DDR50 : - ctrl_2 |=SDHCI_CTRL_UHS_DDR50 |SDHCI_CTRL_VDD_180 ; -break ; - } - -sdhci_writew (host, ctrl_2,SDHCI_HOST_CONTROL2 ); -dev_dbg (mmc_dev (host->mmc), -"%s uhs = %d, ctrl_2 = %04X\n" , - __func__, uhs, ctrl_2); - -return 0 ; -} -static void pxav3_signal_voltage_switch (struct sdhci_host *host,u8 vol) {struct platform_device *pdev =to_platform_device (mmc_dev (host->mmc));
@@ -189,7 +151,6 @@ static void pxav3_signal_voltage_switch(struct sdhci_host *host, u8 vol)static struct sdhci_ops pxav3_sdhci_ops = { .platform_reset_exit = pxav3_set_private_registers, - .set_uhs_signaling = pxav3_set_uhs_signaling, .platform_send_init_74_clocks = pxav3_gen_init_74_clocks, .signal_voltage_switch = pxav3_signal_voltage_switch, };
Signature · 1 line
1.7.0.4