Add UHS mode support for TI's AM65x, J721e, J7200 boards
Subsystems (4)
cover Add UHS mode support for TI's AM65x, J721e, J7200 boards
The following are driver and documentation patches to enable UHS modes for TI's AM65x, J721e, and J7200 boards. Device tree and defconfig patches will be sent in a separate series.
With the complete set, the following maximum modes will be supported:
am654x-evm,idk - SDR104, HS200
j721e-common-proc-board - DDR50, HS200
j7200-common-proc-board - DDR50, HS200
These patches mainly add support for the software tuning algorithm[1] needed for higher speed modes
[1] [1] https://www.ti.com/lit/pdf/spract9
Faiz Abbas (6):
dt-bindings: mmc: sdhci-am654: Convert sdhci-am654 controller
documentation to json schema
dt-bindings: mmc: sdhci-am654: Add documentation for input tap delay
mmc: sdhci_am654: Fix hard coded otap delay array size
mmc: sdhci_am654: Add support for input tap delay
mmc: sdhci_am654: Add support for software tuning
mmc: sdhci_am654: Enable tuning for SDR50
.../devicetree/bindings/mmc/sdhci-am654.txt | 65 ------ .../devicetree/bindings/mmc/sdhci-am654.yaml | 218 ++++++++++++++++++ drivers/mmc/host/sdhci_am654.c | 179 ++++++++++---- 3 files changed, 358 insertions(+), 104 deletions(-) delete mode 100644 Documentation/devicetree/bindings/mmc/sdhci-am654.txt create mode 100644 Documentation/devicetree/bindings/mmc/sdhci-am654.yaml
Signature · 1 line
2.17.1
PATCH 1/6 dt-bindings: mmc: sdhci-am654: Convert sdhci-am654 controller documentation to json schema
Convert sdhci-am654 documentation to yaml format. The new file sdhci-am654.yaml will inherit from mmc-controller.yaml.
--- .../devicetree/bindings/mmc/sdhci-am654.txt | 65 ------- .../devicetree/bindings/mmc/sdhci-am654.yaml | 175 ++++++++++++++++++ 2 files changed, 175 insertions(+), 65 deletions(-) delete mode 100644 Documentation/devicetree/bindings/mmc/sdhci-am654.txt create mode 100644 Documentation/devicetree/bindings/mmc/sdhci-am654.yaml
Documentation/devicetree/bindings/mmc/sdhci-am654.txt deleted +0 -65
@@ -1,65 +0,0 @@ -Device Tree Bindings for the SDHCI Controllers present on TI's AM654 SOCs - -The bindings follow the mmc[1], clock[2] and interrupt[3] bindings. -Only deviations are documented here. - - [1] Documentation/devicetree/bindings/mmc/mmc.txt - [2] Documentation/devicetree/bindings/clock/clock-bindings.txt - [3] Documentation/devicetree/bindings/interrupt-controller/interrupts.txt - -Required Properties: - - compatible: should be one of: - "ti,am654-sdhci-5.1": SDHCI on AM654 device. - "ti,j721e-sdhci-8bit": 8 bit SDHCI on J721E device. - "ti,j721e-sdhci-4bit": 4 bit SDHCI on J721E device. - "ti,j7200-sdhci-8bit": 8 bit SDHCI on J7200 device. - "ti,j7200-sdhci-4bit": 4 bit SDHCI on J7200 device. - - reg: Must be two entries. - - The first should be the sdhci register space - - The second should the subsystem/phy register space - - clocks: Handles to the clock inputs. - - clock-names: Tuple including "clk_xin" and "clk_ahb" - - interrupts: Interrupt specifiers - Output tap delay for each speed mode: - - ti,otap-del-sel-legacy - - ti,otap-del-sel-mmc-hs - - ti,otap-del-sel-sd-hs - - ti,otap-del-sel-sdr12 - - ti,otap-del-sel-sdr25 - - ti,otap-del-sel-sdr50 - - ti,otap-del-sel-sdr104 - - ti,otap-del-sel-ddr50 - - ti,otap-del-sel-ddr52 - - ti,otap-del-sel-hs200 - - ti,otap-del-sel-hs400 - These bindings must be provided otherwise the driver will disable the - corresponding speed mode (i.e. all nodes must provide at least -legacy) - -Optional Properties (Required for ti,am654-sdhci-5.1, - ti,j721e-sdhci-8bit, - ti,j7200-sdhci-8bit): - - ti,trm-icp: DLL trim select - - ti,driver-strength-ohm: driver strength in ohms. - Valid values are 33, 40, 50, 66 and 100 ohms. -Optional Properties: - - ti,strobe-sel: strobe select delay for HS400 speed mode. Default value: 0x0. - - ti,clkbuf-sel: Clock Delay Buffer Select - -Example: - - sdhci0: sdhci@4f80000 { - compatible = "ti,am654-sdhci-5.1"; - reg = <0x0 0x4f80000 0x0 0x260>, <0x0 0x4f90000 0x0 0x134>; - power-domains = <&k3_pds 47>; - clocks = <&k3_clks 47 0>, <&k3_clks 47 1>; - clock-names = "clk_ahb", "clk_xin"; - interrupts = <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>; - sdhci-caps-mask = <0x80000007 0x0>; - mmc-ddr-1_8v; - ti,otap-del-sel-legacy = <0x0>; - ti,otap-del-sel-mmc-hs = <0x0>; - ti,otap-del-sel-ddr52 = <0x5>; - ti,otap-del-sel-hs200 = <0x5>; - ti,otap-del-sel-hs400 = <0x0>; - ti,trm-icp = <0x8>; - };
Documentation/devicetree/bindings/mmc/sdhci-am654.yaml new file +175 -0
175 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 2/6 dt-bindings: mmc: sdhci-am654: Add documentation for input tap delay
In reply to Faiz AbbasAdd documentation for input tap delay bindings.
--- .../devicetree/bindings/mmc/sdhci-am654.yaml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+)
Documentation/devicetree/bindings/mmc/sdhci-am654.yaml +43 -0
@@ -114,6 +114,46 @@ properties: minimum: 0 maximum: 0xf + # PHY input tap delays: + # Used to delay the data valid window and align it to the sampling clock for + # modes that don't support tuning + + ti,itap-del-sel-legacy: + description: Input tap delay for SD/MMC legacy timing + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 0x1f + + ti,itap-del-sel-mmc-hs: + description: Input tap delay for MMC high speed timing + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 0x1f + + ti,itap-del-sel-sd-hs: + description: Input tap delay for SD high speed timing + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 0x1f + + ti,itap-del-sel-sdr12: + description: Input tap delay for SD UHS SDR12 timing + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 0x1f + + ti,itap-del-sel-sdr25: + description: Input tap delay for SD UHS SDR25 timing + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 0x1f + + ti,itap-del-sel-ddr52: + description: Input tap delay for MMC DDR52 timing + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 0x1f + ti,trm-icp: description: DLL trim select $ref: "/schemas/types.yaml#/definitions/uint32"
@@ -170,6 +210,9 @@ examples: ti,otap-del-sel-ddr52 = <0x5>; ti,otap-del-sel-hs200 = <0x5>; ti,otap-del-sel-hs400 = <0x0>; + ti,itap-del-sel-legacy = <0x10>; + ti,itap-del-sel-mmc-hs = <0xa>; + ti,itap-del-sel-ddr52 = <0x3>; ti,trm-icp = <0x8>; }; };
Signature · 1 line
2.17.1
PATCH 3/6 mmc: sdhci_am654: Fix hard coded otap delay array size
In reply to Faiz AbbasChange hard coded array size value to depend on struct timing_data array size.
--- drivers/mmc/host/sdhci_am654.c | 42 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-)
drivers/mmc/host/sdhci_am654.c +21 -21
@@ -85,10 +85,30 @@ static struct regmap_config sdhci_am654_regmap_config = { .fast_io = true, }; +struct timing_data { +const char *binding; +u32 capability; +}; + +static const struct timing_data td[] = { + [MMC_TIMING_LEGACY ] = {"ti,otap-del-sel-legacy" ,0 }, + [MMC_TIMING_MMC_HS ] = {"ti,otap-del-sel-mmc-hs" ,MMC_CAP_MMC_HIGHSPEED }, + [MMC_TIMING_SD_HS ] = {"ti,otap-del-sel-sd-hs" ,MMC_CAP_SD_HIGHSPEED }, + [MMC_TIMING_UHS_SDR12 ] = {"ti,otap-del-sel-sdr12" ,MMC_CAP_UHS_SDR12 }, + [MMC_TIMING_UHS_SDR25 ] = {"ti,otap-del-sel-sdr25" ,MMC_CAP_UHS_SDR25 }, + [MMC_TIMING_UHS_SDR50 ] = {"ti,otap-del-sel-sdr50" ,MMC_CAP_UHS_SDR50 }, + [MMC_TIMING_UHS_SDR104 ] = {"ti,otap-del-sel-sdr104" , +MMC_CAP_UHS_SDR104 }, + [MMC_TIMING_UHS_DDR50 ] = {"ti,otap-del-sel-ddr50" ,MMC_CAP_UHS_DDR50 }, + [MMC_TIMING_MMC_DDR52 ] = {"ti,otap-del-sel-ddr52" ,MMC_CAP_DDR }, + [MMC_TIMING_MMC_HS200 ] = {"ti,otap-del-sel-hs200" ,MMC_CAP2_HS200 }, + [MMC_TIMING_MMC_HS400 ] = {"ti,otap-del-sel-hs400" ,MMC_CAP2_HS400 }, +}; +struct sdhci_am654_data {struct regmap *base;bool legacy_otapdly; -int otap_del_sel[11 ]; +int otap_del_sel[ARRAY_SIZE (td)];int clkbuf_sel;int trm_icp;int drv_strength;
@@ -107,26 +127,6 @@ struct sdhci_am654_driver_data {#define DLL_CALIB (1 << 4) }; -struct timing_data { -const char *binding; -u32 capability; -}; - -static const struct timing_data td[] = { - [MMC_TIMING_LEGACY ] = {"ti,otap-del-sel-legacy" ,0 }, - [MMC_TIMING_MMC_HS ] = {"ti,otap-del-sel-mmc-hs" ,MMC_CAP_MMC_HIGHSPEED }, - [MMC_TIMING_SD_HS ] = {"ti,otap-del-sel-sd-hs" ,MMC_CAP_SD_HIGHSPEED }, - [MMC_TIMING_UHS_SDR12 ] = {"ti,otap-del-sel-sdr12" ,MMC_CAP_UHS_SDR12 }, - [MMC_TIMING_UHS_SDR25 ] = {"ti,otap-del-sel-sdr25" ,MMC_CAP_UHS_SDR25 }, - [MMC_TIMING_UHS_SDR50 ] = {"ti,otap-del-sel-sdr50" ,MMC_CAP_UHS_SDR50 }, - [MMC_TIMING_UHS_SDR104 ] = {"ti,otap-del-sel-sdr104" , -MMC_CAP_UHS_SDR104 }, - [MMC_TIMING_UHS_DDR50 ] = {"ti,otap-del-sel-ddr50" ,MMC_CAP_UHS_DDR50 }, - [MMC_TIMING_MMC_DDR52 ] = {"ti,otap-del-sel-ddr52" ,MMC_CAP_DDR }, - [MMC_TIMING_MMC_HS200 ] = {"ti,otap-del-sel-hs200" ,MMC_CAP2_HS200 }, - [MMC_TIMING_MMC_HS400 ] = {"ti,otap-del-sel-hs400" ,MMC_CAP2_HS400 }, -}; -static void sdhci_am654_setup_dll (struct sdhci_host *host,unsigned int clock) {struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);
Signature · 1 line
2.17.1
PATCH 4/6 mmc: sdhci_am654: Add support for input tap delay
In reply to Faiz AbbasDLL need only be enabled for speed modes and clock frequencies at or above 50 MHz. For speed modes that don't enable the DLL, we need to configure a static input delay value. This involves reading an optional itap-del-sel-* value from the device tree and configuring it for the appropriate speed mode.
With this addition, make sure that DLL is always switched off at the beginning of the set_clock() call to simplify configuration. This also removes the need for the dll_on member in struct sdhci_am654_data.
--- drivers/mmc/host/sdhci_am654.c | 114 ++++++++++++++++++++++++--------- 1 file changed, 84 insertions(+), 30 deletions(-)
drivers/mmc/host/sdhci_am654.c +84 -30
@@ -66,6 +66,14 @@#define RETRIM_MASK BIT(RETRIM_SHIFT)#define SELDLYTXCLK_SHIFT 17#define SELDLYTXCLK_MASK BIT(SELDLYTXCLK_SHIFT) +#define SELDLYRXCLK_SHIFT 16 +#define SELDLYRXCLK_MASK BIT(SELDLYRXCLK_SHIFT) +#define ITAPDLYSEL_SHIFT 0 +#define ITAPDLYSEL_MASK GENMASK(4, 0) +#define ITAPDLYENA_SHIFT 8 +#define ITAPDLYENA_MASK BIT(ITAPDLYENA_SHIFT) +#define ITAPCHGWIN_SHIFT 9 +#define ITAPCHGWIN_MASK BIT(ITAPCHGWIN_SHIFT)#define DRIVER_STRENGTH_50_OHM 0x0#define DRIVER_STRENGTH_33_OHM 0x1
@@ -73,7 +81,7 @@#define DRIVER_STRENGTH_100_OHM 0x3#define DRIVER_STRENGTH_40_OHM 0x4 -#define CLOCK_TOO_SLOW_HZ 400000 +#define CLOCK_TOO_SLOW_HZ 50000000/* Command Queue Host Controller Interface Base address */ #define SDHCI_AM654_CQE_BASE_ADDR 0x200
@@ -86,33 +94,55 @@ static struct regmap_config sdhci_am654_regmap_config = { };struct timing_data { -const char *binding; +const char *otap_binding; +const char *itap_binding;u32 capability; };static const struct timing_data td[] = { - [MMC_TIMING_LEGACY ] = {"ti,otap-del-sel-legacy" ,0 }, - [MMC_TIMING_MMC_HS ] = {"ti,otap-del-sel-mmc-hs" ,MMC_CAP_MMC_HIGHSPEED }, - [MMC_TIMING_SD_HS ] = {"ti,otap-del-sel-sd-hs" ,MMC_CAP_SD_HIGHSPEED }, - [MMC_TIMING_UHS_SDR12 ] = {"ti,otap-del-sel-sdr12" ,MMC_CAP_UHS_SDR12 }, - [MMC_TIMING_UHS_SDR25 ] = {"ti,otap-del-sel-sdr25" ,MMC_CAP_UHS_SDR25 }, - [MMC_TIMING_UHS_SDR50 ] = {"ti,otap-del-sel-sdr50" ,MMC_CAP_UHS_SDR50 }, - [MMC_TIMING_UHS_SDR104 ] = {"ti,otap-del-sel-sdr104" , + [MMC_TIMING_LEGACY ] = {"ti,otap-del-sel-legacy" , +"ti,itap-del-sel-legacy" , +0 }, + [MMC_TIMING_MMC_HS ] = {"ti,otap-del-sel-mmc-hs" , +"ti,itap-del-sel-mmc-hs" , +MMC_CAP_MMC_HIGHSPEED }, + [MMC_TIMING_SD_HS ] = {"ti,otap-del-sel-sd-hs" , +"ti,itap-del-sel-sd-hs" , +MMC_CAP_SD_HIGHSPEED }, + [MMC_TIMING_UHS_SDR12 ] = {"ti,otap-del-sel-sdr12" , +"ti,itap-del-sel-sdr12" , +MMC_CAP_UHS_SDR12 }, + [MMC_TIMING_UHS_SDR25 ] = {"ti,otap-del-sel-sdr25" , +"ti,itap-del-sel-sdr25" , +MMC_CAP_UHS_SDR25 }, + [MMC_TIMING_UHS_SDR50 ] = {"ti,otap-del-sel-sdr50" , +NULL , +MMC_CAP_UHS_SDR50 }, + [MMC_TIMING_UHS_SDR104 ] = {"ti,otap-del-sel-sdr104" , +NULL ,MMC_CAP_UHS_SDR104 }, - [MMC_TIMING_UHS_DDR50 ] = {"ti,otap-del-sel-ddr50" ,MMC_CAP_UHS_DDR50 }, - [MMC_TIMING_MMC_DDR52 ] = {"ti,otap-del-sel-ddr52" ,MMC_CAP_DDR }, - [MMC_TIMING_MMC_HS200 ] = {"ti,otap-del-sel-hs200" ,MMC_CAP2_HS200 }, - [MMC_TIMING_MMC_HS400 ] = {"ti,otap-del-sel-hs400" ,MMC_CAP2_HS400 }, + [MMC_TIMING_UHS_DDR50 ] = {"ti,otap-del-sel-ddr50" , +NULL , +MMC_CAP_UHS_DDR50 }, + [MMC_TIMING_MMC_DDR52 ] = {"ti,otap-del-sel-ddr52" , +"ti,itap-del-sel-ddr52" , +MMC_CAP_DDR }, + [MMC_TIMING_MMC_HS200 ] = {"ti,otap-del-sel-hs200" , +NULL , +MMC_CAP2_HS200 }, + [MMC_TIMING_MMC_HS400 ] = {"ti,otap-del-sel-hs400" , +NULL , +MMC_CAP2_HS400 }, };struct sdhci_am654_data {struct regmap *base;bool legacy_otapdly;int otap_del_sel[ARRAY_SIZE (td)]; +int itap_del_sel[ARRAY_SIZE (td)];int clkbuf_sel;int trm_icp;int drv_strength; -bool dll_on;int strb_sel;u32 flags; };
@@ -135,6 +165,10 @@ static void sdhci_am654_setup_dll(struct sdhci_host *host, unsigned int clock)u32 mask, val;int ret; +/* Disable delay chain mode */ +regmap_update_bits (sdhci_am654->base,PHY_CTRL5 , +SELDLYTXCLK_MASK |SELDLYRXCLK_MASK ,0 ); +if (sdhci_am654->flags &FREQSEL_2_BIT ) {switch (clock) {case 200000000 :
@@ -189,8 +223,32 @@ static void sdhci_am654_setup_dll(struct sdhci_host *host, unsigned int clock)dev_err (mmc_dev (host->mmc),"DLL failed to relock\n" );return ; } +} + +static void sdhci_am654_write_itapdly (struct sdhci_am654_data *sdhci_am654, +u32 itapdly) +{ +/* Set ITAPCHGWIN before writing to ITAPDLY */ +regmap_update_bits (sdhci_am654->base,PHY_CTRL4 ,ITAPCHGWIN_MASK , +1 <<ITAPCHGWIN_SHIFT ); +regmap_update_bits (sdhci_am654->base,PHY_CTRL4 ,ITAPDLYSEL_MASK , + itapdly <<ITAPDLYSEL_SHIFT ); +regmap_update_bits (sdhci_am654->base,PHY_CTRL4 ,ITAPCHGWIN_MASK ,0 ); +} + +static void sdhci_am654_setup_delay_chain (struct sdhci_am654_data *sdhci_am654, +unsigned char timing) +{ +u32 mask, val; - sdhci_am654->dll_on = true; +regmap_update_bits (sdhci_am654->base,PHY_CTRL1 ,ENDLL_MASK ,0 ); + + val =1 <<SELDLYTXCLK_SHIFT |1 <<SELDLYRXCLK_SHIFT ; + mask =SELDLYTXCLK_MASK |SELDLYRXCLK_MASK ; +regmap_update_bits (sdhci_am654->base,PHY_CTRL5 , mask, val); + +sdhci_am654_write_itapdly (sdhci_am654, + sdhci_am654->itap_del_sel[timing]); }static void sdhci_am654_set_clock (struct sdhci_host *host,unsigned int clock)
@@ -202,11 +260,7 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)u32 otap_del_ena;u32 mask, val; -if (sdhci_am654->dll_on) { -regmap_update_bits (sdhci_am654->base,PHY_CTRL1 ,ENDLL_MASK ,0 ); - - sdhci_am654->dll_on = false; - } +regmap_update_bits (sdhci_am654->base,PHY_CTRL1 ,ENDLL_MASK ,0 );sdhci_set_clock (host, clock);
@@ -234,14 +288,10 @@ static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock)regmap_update_bits (sdhci_am654->base,PHY_CTRL4 , mask, val); -if (timing >MMC_TIMING_UHS_SDR25 && clock >CLOCK_TOO_SLOW_HZ ) { -regmap_update_bits (sdhci_am654->base,PHY_CTRL5 , -SELDLYTXCLK_MASK ,0 ); +if (timing >MMC_TIMING_UHS_SDR25 && clock >=CLOCK_TOO_SLOW_HZ )sdhci_am654_setup_dll (host, clock); - }else { -regmap_update_bits (sdhci_am654->base,PHY_CTRL5 , -SELDLYTXCLK_MASK ,1 <<SELDLYTXCLK_SHIFT ); - } +else +sdhci_am654_setup_delay_chain (sdhci_am654, timing);regmap_update_bits (sdhci_am654->base,PHY_CTRL5 ,CLKBUFSEL_MASK , sdhci_am654->clkbuf_sel);
@@ -469,7 +519,7 @@ static int sdhci_am654_get_otap_delay(struct sdhci_host *host,int i;int ret; - ret =device_property_read_u32 (dev, td[MMC_TIMING_LEGACY ].binding, + ret =device_property_read_u32 (dev, td[MMC_TIMING_LEGACY ].otap_binding, &sdhci_am654->otap_del_sel[MMC_TIMING_LEGACY ]);if (ret) {/*
@@ -492,11 +542,11 @@ static int sdhci_am654_get_otap_delay(struct sdhci_host *host,for (i =MMC_TIMING_MMC_HS ; i <=MMC_TIMING_MMC_HS400 ; i++) { - ret =device_property_read_u32 (dev, td[i].binding, + ret =device_property_read_u32 (dev, td[i].otap_binding, &sdhci_am654->otap_del_sel[i]);if (ret) {dev_dbg (dev,"Couldn't find %s\n" , - td[i].binding); + td[i].otap_binding);/* * Remove the corresponding capability * if an otap-del-sel value is not found
@@ -506,6 +556,10 @@ static int sdhci_am654_get_otap_delay(struct sdhci_host *host,else host->mmc->caps2 &= ~td[i].capability; } + +if (td[i].itap_binding) +device_property_read_u32 (dev, td[i].itap_binding, + &sdhci_am654->itap_del_sel[i]); }return 0 ;
Signature · 1 line
2.17.1
PATCH 5/6 mmc: sdhci_am654: Add support for software tuning
In reply to Faiz AbbasWith the new SW tuning App note[1], a custom tuning algorithm is required for eMMC HS200, HS400 and SD card UHS modes. The algorithm involves running through the 32 possible input tap delay values and sending the appropriate tuning command (CMD19/21) for each of them to get a fail or pass result for each of the values. Typically, the range will have a small contiguous failing window. Considering the tuning range as a circular buffer, the algorithm then sets a final tuned value directly opposite to the failing window.
[1] https://www.ti.com/lit/pdf/spract9
--- drivers/mmc/host/sdhci_am654.c | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
drivers/mmc/host/sdhci_am654.c +41 -0
@@ -396,7 +396,46 @@ static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask)return 0 ; } +#define ITAP_MAX 32 +static int sdhci_am654_platform_execute_tuning (struct sdhci_host *host, +u32 opcode) +{ +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); +struct sdhci_am654_data *sdhci_am654 =sdhci_pltfm_priv (pltfm_host); +int cur_val, prev_val =1 , fail_len =0 , pass_window =0 , pass_len; +u32 itap; + +/* Enable ITAPDLY */ +regmap_update_bits (sdhci_am654->base,PHY_CTRL4 ,ITAPDLYENA_MASK , +1 <<ITAPDLYENA_SHIFT ); + +for (itap =0 ; itap <ITAP_MAX ; itap++) { +sdhci_am654_write_itapdly (sdhci_am654, itap); + + cur_val = !mmc_send_tuning (host->mmc, opcode,NULL ); +if (cur_val && !prev_val) + pass_window = itap; + +if (!cur_val) + fail_len++; + + prev_val = cur_val; + } +/* +* Having determined the length of the failing window and start of +* the passing window calculate the length of the passing window and +* set the final value halfway through it considering the range as a +* circular buffer +*/ + pass_len =ITAP_MAX - fail_len; + itap = (pass_window + (pass_len >>1 )) %ITAP_MAX ; +sdhci_am654_write_itapdly (sdhci_am654, itap); + +return 0 ; +} +static struct sdhci_ops sdhci_am654_ops = { + .platform_execute_tuning = sdhci_am654_platform_execute_tuning, .get_max_clock = sdhci_pltfm_clk_get_max_clock, .get_timeout_clock = sdhci_pltfm_clk_get_max_clock, .set_uhs_signaling = sdhci_set_uhs_signaling,
@@ -426,6 +465,7 @@ static const struct sdhci_am654_driver_data sdhci_am654_drvdata = { };static struct sdhci_ops sdhci_j721e_8bit_ops = { + .platform_execute_tuning = sdhci_am654_platform_execute_tuning, .get_max_clock = sdhci_pltfm_clk_get_max_clock, .get_timeout_clock = sdhci_pltfm_clk_get_max_clock, .set_uhs_signaling = sdhci_set_uhs_signaling,
@@ -449,6 +489,7 @@ static const struct sdhci_am654_driver_data sdhci_j721e_8bit_drvdata = { };static struct sdhci_ops sdhci_j721e_4bit_ops = { + .platform_execute_tuning = sdhci_am654_platform_execute_tuning, .get_max_clock = sdhci_pltfm_clk_get_max_clock, .get_timeout_clock = sdhci_pltfm_clk_get_max_clock, .set_uhs_signaling = sdhci_set_uhs_signaling,
Signature · 1 line
2.17.1
Re: [PATCH 5/6] mmc: sdhci_am654: Add support for software tuning
Quoted 9 lines · Faiz Abbas
With the new SW tuning App note[1], a custom tuning algorithm is required for eMMC HS200, HS400 and SD card UHS modes. The algorithm involves running through the 32 possible input tap delay values and sending the appropriate tuning command (CMD19/21) for each of them to get a fail or pass result for each of the values. Typically, the range will have a small contiguous failing window. Considering the tuning range as a circular buffer, the algorithm then sets a final tuned value directly opposite to the failing window.
Quoted 3 lines
[1] https://www.ti.com/lit/pdf/spract9
Signed-off-by Faiz Abbas <[email protected]>
Quoted 72 lines
--- drivers/mmc/host/sdhci_am654.c | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)drivers/mmc/host/sdhci_am654.c +41
-0@@ -396,7 +396,46 @@ static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask)return 0 ; } +#define ITAP_MAX 32 +static int sdhci_am654_platform_execute_tuning (struct sdhci_host *host, +u32 opcode) +{ +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); +struct sdhci_am654_data *sdhci_am654 =sdhci_pltfm_priv (pltfm_host); +int cur_val, prev_val =1 , fail_len =0 , pass_window =0 , pass_len; +u32 itap; + +/* Enable ITAPDLY */ +regmap_update_bits (sdhci_am654->base,PHY_CTRL4 ,ITAPDLYENA_MASK , +1 <<ITAPDLYENA_SHIFT ); + +for (itap =0 ; itap <ITAP_MAX ; itap++) { +sdhci_am654_write_itapdly (sdhci_am654, itap); + + cur_val = !mmc_send_tuning (host->mmc, opcode,NULL ); +if (cur_val && !prev_val) + pass_window = itap; + +if (!cur_val) + fail_len++; + + prev_val = cur_val; + } +/* +* Having determined the length of the failing window and start of +* the passing window calculate the length of the passing window and +* set the final value halfway through it considering the range as a +* circular buffer +*/ + pass_len =ITAP_MAX - fail_len; + itap = (pass_window + (pass_len >>1 )) %ITAP_MAX ; +sdhci_am654_write_itapdly (sdhci_am654, itap); + +return 0 ; +} +static struct sdhci_ops sdhci_am654_ops = { + .platform_execute_tuning = sdhci_am654_platform_execute_tuning, .get_max_clock = sdhci_pltfm_clk_get_max_clock, .get_timeout_clock = sdhci_pltfm_clk_get_max_clock, .set_uhs_signaling = sdhci_set_uhs_signaling,@@ -426,6 +465,7 @@ static const struct sdhci_am654_driver_data sdhci_am654_drvdata = { };static struct sdhci_ops sdhci_j721e_8bit_ops = { + .platform_execute_tuning = sdhci_am654_platform_execute_tuning, .get_max_clock = sdhci_pltfm_clk_get_max_clock, .get_timeout_clock = sdhci_pltfm_clk_get_max_clock, .set_uhs_signaling = sdhci_set_uhs_signaling,@@ -449,6 +489,7 @@ static const struct sdhci_am654_driver_data sdhci_j721e_8bit_drvdata = { };static struct sdhci_ops sdhci_j721e_4bit_ops = { + .platform_execute_tuning = sdhci_am654_platform_execute_tuning, .get_max_clock = sdhci_pltfm_clk_get_max_clock, .get_timeout_clock = sdhci_pltfm_clk_get_max_clock, .set_uhs_signaling = sdhci_set_uhs_signaling,
PATCH 6/6 mmc: sdhci_am654: Enable tuning for SDR50
In reply to Faiz AbbasAccording to the SW tuning App note[1], tuning is required for all UHS speed modes. Tuning for SDR50 is not enabled in Capabilities by default so enable it from the CTL_CFG registers.
[1] https://www.ti.com/lit/pdf/spract9
--- drivers/mmc/host/sdhci_am654.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/mmc/host/sdhci_am654.c +6 -0
@@ -19,9 +19,11 @@/* CTL_CFG Registers */ #define CTL_CFG_2 0x14 +#define CTL_CFG_3 0x18#define SLOTTYPE_MASK GENMASK(31, 30)#define SLOTTYPE_EMBEDDED BIT(30) +#define TUNINGFORSDR50_MASK BIT(13)/* PHY Registers */ #define PHY_CTRL1 0x100
@@ -646,6 +648,10 @@ static int sdhci_am654_init(struct sdhci_host *host)regmap_update_bits (sdhci_am654->base,CTL_CFG_2 ,SLOTTYPE_MASK , ctl_cfg_2); +/* Enable tuning for SDR50 */ +regmap_update_bits (sdhci_am654->base,CTL_CFG_3 ,TUNINGFORSDR50_MASK , +TUNINGFORSDR50_MASK ); + ret =sdhci_setup_host (host);if (ret)return ret;
Signature · 1 line
2.17.1
Quoted 32 lines · Faiz Abbas
The following are driver and documentation patches to enable UHS modes for TI's AM65x, J721e, and J7200 boards. Device tree and defconfig patches will be sent in a separate series.
With the complete set, the following maximum modes will be supported:
am654x-evm,idk - SDR104, HS200
j721e-common-proc-board - DDR50, HS200
j7200-common-proc-board - DDR50, HS200These patches mainly add support for the software tuning algorithm[1] needed for higher speed modes
[1] [1] https://www.ti.com/lit/pdf/spract9
Faiz Abbas (6):
dt-bindings: mmc: sdhci-am654: Convert sdhci-am654 controller
documentation to json schema
dt-bindings: mmc: sdhci-am654: Add documentation for input tap delay
mmc:sdhci_am654: Fix hard coded otap delay array size
mmc:sdhci_am654: Add support for input tap delay
mmc:sdhci_am654: Add support for software tuning
mmc:sdhci_am654: Enable tuning for SDR50.../devicetree/bindings/mmc/sdhci-am654.txt | 65 ------ .../devicetree/bindings/mmc/sdhci-am654.yaml | 218 ++++++++++++++++++ drivers/mmc/host/sdhci_am654.c | 179 ++++++++++---- 3 files changed, 358 insertions(+), 104 deletions(-) delete mode 100644 Documentation/devicetree/bindings/mmc/sdhci-am654.txt create mode 100644 Documentation/devicetree/bindings/mmc/sdhci-am654.yaml
Quoted 3 lines
--
2.17.1
Applied for next, thanks!
Kind regards
Uffe