mmc: sdhci: add a callback of signal voltage switching
Subsystems (3)
PATCH v2 1/8 mmc: sdhci: add a callback of signal voltage switching
Add a signal voltage switching callback to let host use its own switching process.
---
Changes for v2:
- Modified commit message
- Added SDR50 support patches
--- drivers/mmc/host/sdhci.c | 5 +++++ drivers/mmc/host/sdhci.h | 2 ++ 2 files changed, 7 insertions(+)
drivers/mmc/host/sdhci.c +5 -0
@@ -1757,6 +1757,11 @@ static int sdhci_do_start_signal_voltage_switch(struct sdhci_host *host,if (host->version <SDHCI_SPEC_300 )return 0 ; +if (host->ops->signal_voltage_switch) { + host->ops->signal_voltage_switch (host, ios->signal_voltage); +return 0 ; + } + ctrl =sdhci_readw (host,SDHCI_HOST_CONTROL2 );switch (ios->signal_voltage) {
drivers/mmc/host/sdhci.h +2 -0
@@ -544,6 +544,8 @@ struct sdhci_ops {struct mmc_card *card, unsigned int max_dtr, int host_drv, int card_drv, int *drv_type); +void (*signal_voltage_switch)(struct sdhci_host *host, +unsigned char signal_voltage); };#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
Signature · 1 line
2.1.0.27.g96db324
PATCH v2 2/8 mmc: sdhci: add a callback of tuning block setting
Add a tuning block setting callback to let host set its tuning block before executing tuning procedure.
--- drivers/mmc/host/sdhci.c | 3 +++ drivers/mmc/host/sdhci.h | 1 + 2 files changed, 4 insertions(+)
drivers/mmc/host/sdhci.c +3 -0
@@ -1939,6 +1939,9 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)return err; } +if (host->ops->set_tuning_block) + host->ops->set_tuning_block (host); + ctrl =sdhci_readw (host,SDHCI_HOST_CONTROL2 ); ctrl |=SDHCI_CTRL_EXEC_TUNING ;if (host->quirks2 &SDHCI_QUIRK2_TUNING_WORK_AROUND )
drivers/mmc/host/sdhci.h +1 -0
@@ -546,6 +546,7 @@ struct sdhci_ops { int card_drv, int *drv_type);void (*signal_voltage_switch)(struct sdhci_host *host,unsigned char signal_voltage); +void (*set_tuning_block)(struct sdhci_host *host); };#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
Signature · 1 line
2.1.0.27.g96db324
PATCH v2 3/8 mmc: dt: add DT bindings for Freescale eSDHC
In reply to Yangbo LuDocument Freescale eSDHC 'adapter-type' and 'peripheral-frequency' properties.
--- Documentation/devicetree/bindings/mmc/fsl-esdhc.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+)
Documentation/devicetree/bindings/mmc/fsl-esdhc.txt +12 -0
@@ -22,6 +22,18 @@ Optional properties: - voltage-ranges : two cells are required, first cell specifies minimum slot voltage (mV), second cell specifies maximum slot voltage (mV). Several ranges could be specified. + - adapter-tye: specifies SDHC Adapter card type. The Adapter card types are + as below. + TYPE_1 0x1 /* eMMC Card Rev4.5 */ + TYPE_2 0x2 /* SD/MMC Legacy Card */ + TYPE_3 0x3 /* eMMC Card Rev4.4 */ + TYPE_4 0x4 /* Reserved */ + TYPE_5 0x5 /* MMC Card */ + TYPE_6 0x6 /* SD Card Rev2.0 Rev3.0 */ + NO_ADAPTER 0x7 /* No Card is Present*/ + - peripheral-frequency: specifies peripheral clock frequency value. + + Example:
Signature · 1 line
2.1.0.27.g96db324
PATCH v2 4/8 mmc: sdhci-of-esdhc: add eMMC Adapter Card HS200 mode support
In reply to Yangbo LuFreescale QorIQ QDS boards use different SDHC Adapter card types as below. To support SDHC Adapter card type 1(eMMC card Rev4.5) HS200 mode, select to use peripheral clock and add callbacks for signal voltage switching and tuning block setting for eSDHC.SDHC_ADAPTER_TYPE:
ADAPTER_TYPE_1 0x1 /* eMMC Card Rev4.5 */ ADAPTER_TYPE_2 0x2 /* SD/MMC Legacy Card */ ADAPTER_TYPE_3 0x3 /* eMMC Card Rev4.4 */ ADAPTER_TYPE_4 0x4 /* Reserved */ ADAPTER_TYPE_5 0x5 /* MMC Card */ ADAPTER_TYPE_6 0x6 /* SD Card Rev2.0 Rev3.0 */ NO_ADAPTER 0x7 /* No Card is Present*/
--- drivers/mmc/host/sdhci-esdhc.h | 22 ++++++++ drivers/mmc/host/sdhci-of-esdhc.c | 116 +++++++++++++++++++++++++++++++++++++- 2 files changed, 136 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-esdhc.h +22 -0
@@ -24,14 +24,34 @@ SDHCI_QUIRK_PIO_NEEDS_DELAY | \ SDHCI_QUIRK_NO_HISPD_BIT) +#define ESDHCI_PRESENT_STATE 0x24 +#define ESDHC_CLK_STABLE 0x00000008 + +#define ESDHC_PROCTL 0x28 +#define ESDHC_VOLT_SEL 0x00000400 +#define ESDHC_SYSTEM_CONTROL 0x2c#define ESDHC_CLOCK_MASK 0x0000fff0#define ESDHC_PREDIV_SHIFT 8#define ESDHC_DIVIDER_SHIFT 4 +#define ESDHC_CLOCK_CRDEN 0x00000008#define ESDHC_CLOCK_PEREN 0x00000004#define ESDHC_CLOCK_HCKEN 0x00000002#define ESDHC_CLOCK_IPGEN 0x00000001 +#define ESDHC_CAPABILITIES_1 0x114 +#define ESDHC_MODE_MASK 0x00000007 +#define ESDHC_MODE_DDR50_SEL 0xfffffffc +#define ESDHC_MODE_SDR104 0x00000002 +#define ESDHC_MODE_DDR50 0x00000004 + +#define ESDHC_TBCTL 0x120 +#define ESDHC_TB_EN 0x00000004 + +#define ESDHC_CLOCK_CONTROL 0x144 +#define ESDHC_CLKLPBK_EXTPIN 0x80000000 +#define ESDHC_CMDCLK_SHIFTED 0x00008000 +/* pltfm-specific */ #define ESDHC_HOST_CONTROL_LE 0x20
@@ -45,6 +65,8 @@/* OF-specific */ #define ESDHC_DMA_SYSCTL 0x40c#define ESDHC_DMA_SNOOP 0x00000040 +#define ESDHC_FLUSH_ASYNC_FIFO 0x00040000 +#define ESDHC_USE_PERICLK 0x00080000#define ESDHC_HOST_CONTROL_RES 0x01
drivers/mmc/host/sdhci-of-esdhc.c +114 -2
163 lines not on this page · raw message
Signature · 1 line
2.1.0.27.g96db324
PATCH v2 5/8 mmc: sdhci: add SDHCI_QUIRK2_DELAY_BETWEEN_TUNING_CYCLES quirk
In reply to Yangbo LuAlthough eMMC spec does not require a delay between tuning cycles, some hosts need it to avoid tuning failure.
--- drivers/mmc/host/sdhci.c | 3 ++- drivers/mmc/host/sdhci.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +2 -1
@@ -2038,7 +2038,8 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode) ctrl =sdhci_readw (host,SDHCI_HOST_CONTROL2 );/* eMMC spec does not require a delay between tuning cycles */ -if (opcode ==MMC_SEND_TUNING_BLOCK ) +if ((opcode ==MMC_SEND_TUNING_BLOCK ) || + (host->quirks2 &SDHCI_QUIRK2_DELAY_BETWEEN_TUNING_CYCLES ))mdelay (1 ); }while (ctrl &SDHCI_CTRL_EXEC_TUNING );
drivers/mmc/host/sdhci.h +2 -0
@@ -412,6 +412,8 @@ struct sdhci_host {#define SDHCI_QUIRK2_ACMD23_BROKEN (1<<14)/* Broken Clock divider zero in controller */ #define SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN (1<<15) +/* Need delay between tuning cycles */ +#define SDHCI_QUIRK2_DELAY_BETWEEN_TUNING_CYCLES (1<<16)int irq;/* Device IRQ */ void __iomem *ioaddr;/* Mapped address */
Signature · 1 line
2.1.0.27.g96db324
PATCH v2 6/8 mmc: sdhci-of-esdhc: add tuning cycles delay quirk for t2080/t1040
In reply to Yangbo Lu--- drivers/mmc/host/sdhci-of-esdhc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mmc/host/sdhci-of-esdhc.c +4 -0
@@ -470,6 +470,10 @@ static int sdhci_esdhc_probe(struct platform_device *pdev) of_device_is_compatible(np, "fsl,t1040-esdhc")) host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION; +if (of_device_is_compatible (np,"fsl,t1040-esdhc" ) || +of_device_is_compatible (np,"fsl,t2080-esdhc" )) + host->quirks2 |=SDHCI_QUIRK2_DELAY_BETWEEN_TUNING_CYCLES ; +if (of_device_is_compatible (np,"fsl,p2020-esdhc" )) {/* * Freescale messed up with P2020 as it has a non-standard
Signature · 1 line
2.1.0.27.g96db324
PATCH v2 7/8 mmc: sd: set 4bit bus width after IO signal voltage switching
In reply to Yangbo LuIO signal voltage switching is used for UHS speed mode. After the voltage switching, the card is in UHS mode and it's needed to set 4bit bus width before any data transfer command.
--- drivers/mmc/core/sd.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/mmc/core/sd.c +9 -0
@@ -947,6 +947,15 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, goto free_card; } +/* If the signal voltage was switched to 1.8v for UHS mode, +* it's needed to set 4bit bus width for card and host. +*/ +if (host->ios.signal_voltage ==MMC_SIGNAL_VOLTAGE_180 ) { +if (mmc_app_set_bus_width (card,MMC_BUS_WIDTH_4 )) + goto free_card; +mmc_set_bus_width (card->host,MMC_BUS_WIDTH_4 ); + } + err =mmc_sd_setup_card (host, card, oldcard !=NULL );if (err) goto free_card;
Signature · 1 line
2.1.0.27.g96db324
PATCH v2 8/8 mmc: sdhci-of-esdhc: add SDR50 mode support for SD/MMC Legacy Adapter Card
In reply to Yangbo LuThe eSDHC is not compatible with SD spec well, so we need to use eSDHC-special code to switch to SDR50 mode.
1. IO signal voltage switching, eSDHC uses SDHC_VS to switch io voltage and it's needed to configure a global utilities register SCFG_SDHCIOVSELCR(if it has) and SDHC_VS signal.
2. Before executing tuning procedure, eSDHC should set its own tuning block.
static const struct sdhci_ops sdhci_esdhc_ops = {
...
.set_tuning_block = esdhc_set_tuning_block, .signal_voltage_switch = esdhc_signal_voltage_switch,
};
--- drivers/mmc/host/sdhci-esdhc.h | 2 ++ drivers/mmc/host/sdhci-of-esdhc.c | 62 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-esdhc.h +2 -0
@@ -26,6 +26,8 @@#define ESDHCI_PRESENT_STATE 0x24#define ESDHC_CLK_STABLE 0x00000008 +#define ESDHC_DLSL 0x0f000000 +#define ESDHC_CLSL 0x00800000#define ESDHC_PROCTL 0x28#define ESDHC_VOLT_SEL 0x00000400
drivers/mmc/host/sdhci-of-esdhc.c +61 -1
111 lines not on this page · raw message
Signature · 1 line
2.1.0.27.g96db324
Quoted 4 lines · Yangbo Lu
Add a signal voltage switching callback to let host use its own switching process.
Signed-off-by Yangbo Lu <[email protected]>
Sorry for the delay!
Unless you haven't noticed my recent statement around sdhci's callbacks and quirks, please read these.
https://lkml.org/lkml/2015/10/8/734
https://lkml.org/lkml/2015/10/6/158
That said, I won't pick any of the patches from these patchset.
I would also encourage you and other people to help turning shdci into a bunch of library functions.
Kind regards
Uffe
Quoted 41 lines
---
Changes for v2:
- Modified commit message
- Added SDR50 support patches--- drivers/mmc/host/sdhci.c | 5 +++++ drivers/mmc/host/sdhci.h | 2 ++ 2 files changed, 7 insertions(+)drivers/mmc/host/sdhci.c +5
-0@@ -1757,6 +1757,11 @@ static int sdhci_do_start_signal_voltage_switch(struct sdhci_host *host,if (host->version <SDHCI_SPEC_300 )return 0 ; +if (host->ops->signal_voltage_switch) { + host->ops->signal_voltage_switch (host, ios->signal_voltage); +return 0 ; + } + ctrl =sdhci_readw (host,SDHCI_HOST_CONTROL2 );switch (ios->signal_voltage) {drivers/mmc/host/sdhci.h +2
-1@@ -544,6 +544,8 @@ struct sdhci_ops {struct mmc_card *card, unsigned int max_dtr, int host_drv, int card_drv, int *drv_type); +void (*signal_voltage_switch)(struct sdhci_host *host, +unsigned char signal_voltage); };#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS --2.1.0.27.g96db324