mmc: renesas_sdhi: support manual calibration
Subsystems (2)
Wolfram Sang
maintainerv3 cover mmc: renesas_sdhi: support manual calibration
Some R-Car Gen3 SoCs need corrections after they tuned to HS400. This series implements that. Please have a look at the patch descriptions for details. The origins were patches in the BSP from Takeshi Saito.
Changes for RFC v3:
* rebased to the latest BSP patches which now use tables instead of computed values for the correction values
* other refactoring because of the above
* MMC0 instance is hardcoded now because it is located at the same address on all Gen3 SoCs
* except for the TMPPORT accessors, it is basically a new patch
There is a branch for testing here:
git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/topic/sdhi-manual-calib
What is missing here is more testing on more boards. I post it already for review comments. And because it is needed to trigger a stalled SCC condition which is fixed by a patchset I just sent out.
Thanks and happy hacking,
Wolfram
Wolfram Sang (2):
mmc: tmio: add generic hook to fixup after a completed request
mmc: renesas_sdhi: support manual calibration
drivers/mmc/host/renesas_sdhi.h | 5 + drivers/mmc/host/renesas_sdhi_core.c | 152 ++++++++++++++++++++++++++- drivers/mmc/host/tmio_mmc.h | 1 + drivers/mmc/host/tmio_mmc_core.c | 3 + 4 files changed, 159 insertions(+), 2 deletions(-)
Signature · 1 line
2.20.1
Wolfram Sang
maintainerRFC PATCH v3 1/2 mmc: tmio: add generic hook to fixup after a completed request
Sadly, due to HW bugs, we need a callback to work around issues just before completing the request.
--- drivers/mmc/host/tmio_mmc.h | 1 + drivers/mmc/host/tmio_mmc_core.c | 3 +++ 2 files changed, 4 insertions(+)
drivers/mmc/host/tmio_mmc.h +1 -0
@@ -177,6 +177,7 @@ struct tmio_mmc_host {void (*reset)(struct tmio_mmc_host *host);void (*hw_reset)(struct tmio_mmc_host *host);bool (*check_retune)(struct tmio_mmc_host *host); +void (*fixup_request)(struct tmio_mmc_host *host,struct mmc_request *mrq);/* * Mandatory callback for tuning to occur which is optional for SDR50
drivers/mmc/host/tmio_mmc_core.c +3 -0
@@ -827,6 +827,9 @@ static void tmio_mmc_finish_request(struct tmio_mmc_host *host)return ; } +if (host->fixup_request) + host->fixup_request (host, mrq); +mmc_request_done (host->mmc, mrq); }
Signature · 1 line
2.20.1
Wolfram Sang
maintainerRFC PATCH v3 2/2 mmc: renesas_sdhi: support manual calibration
In reply to Wolfram SangSome R-Car Gen3 SoCs need some manual correction of timing parameters after the automatic tuning has finished but before next CMD13 is completed. This patch implements that by this state machine:
- introducing a per-SoC correction table if needed
- iff such a table exists, the 'fixup_request' callback is populated during probe
- iff such a table exists, a runtime flag ('needs_adjust_hs400') is set when HS400 tuning gets prepared
- if tuning HS400 fails, the runtime flag is cleared again
- the callback will check the runtime flag and enable the corrected manual mode if the flag is set and CMD13 is encountered
- at the end of the enablement the runtime flag is cleared
- iff the configuration flag is set, the manual mode will be disabled when HS400 gets downgraded
There also some helper functions added to access the TMPPORT registers. The actual correction table is SoC and instance(!) specific and is added to the quirks struct.
--- drivers/mmc/host/renesas_sdhi.h | 5 + drivers/mmc/host/renesas_sdhi_core.c | 152 ++++++++++++++++++++++++++- 2 files changed, 155 insertions(+), 2 deletions(-)
drivers/mmc/host/renesas_sdhi.h +5 -0
@@ -33,10 +33,13 @@ struct renesas_sdhi_of_data {unsigned short max_segs; }; +#define SDHI_CALIB_TABLE_MAX 32 +struct renesas_sdhi_quirks {bool hs400_disabled;bool hs400_4taps;u32 hs400_bad_taps; +const u8 (*hs400_calib_table)[SDHI_CALIB_TABLE_MAX ]; };struct tmio_mmc_dma {
@@ -58,6 +61,8 @@ struct renesas_sdhi {void __iomem *scc_ctl;u32 scc_tappos;u32 scc_tappos_hs400; +const u8 *adjust_hs400_calib_table; +bool needs_adjust_hs400;bool doing_tune;bool keep_scc_freq;
drivers/mmc/host/renesas_sdhi_core.c +150 -2
226 lines not on this page · raw message
Signature · 1 line
2.20.1
Wolfram Sang
maintainerdrivers/mmc/host/renesas_sdhi_core.c int renesas_sdhi_probe(struct platform_device *pdev, · line 1088
Quoted 9 lines
drivers/mmc/host/renesas_sdhi_core.c +8
-0+if (ver ==SDHI_VER_GEN3_SDMMC && quirks && quirks->hs400_calib_table) { + host->fixup_request = renesas_sdhi_fixup_request; + priv->adjust_hs400_calib_table = *( + res->start ==SDHI_GEN3_MMC0_ADDR ? + quirks->hs400_calib_table : + quirks->hs400_calib_table +1 ); + } +
Testing revealed that this chunk should be moved up before calling tmio_mmc_host_probe(). After that, output from R-Car M3-N and H3 ES2.0 were as expected. Updated debug test patch was pushed out to the branch as well. Tomorrow, I will test R-Car H2 and if all goes well, I will send out the fixed and non-RFC version of this series.