Skip to content

Commit 1ff9cab

Browse files
wensstorulf
authored andcommitted
mmc: sunxi: Clarify new timing mode usage and implementation
Newer sunxi mmc controller variants support what they call the "new timing mode". Support for this was implemented in two ways, according to the hardware that was seen at the time. The first type retained the old timing mode, and both the clock and mmc controllers had switches to select which mode was used. Both switches had to be set to the same setting. This variant was denoted with the .has_timings_switch field in the sunxi_mmc_cfg structure. This hardware is only seen on the A83T. The second type did away with the old timing mode. The clock controller no longer had the mode selection or clock delay setting bits. In some cases the mmc controller retained its mode selection bit, but this always needed to be set to the new mode, or instabilities would occur. In a few cases, such as the A64 and H6 eMMC controller, the mode selection bit is gone, but the controller still behaves like the new timing mode, requiring the module clock to be double the card clock in DDR transfer modes. This variant is denoted with the .needs_new_timings field. This patch adds more comments explaining the two fields, as well as the possibly nonexistent mode switch in the mmc controller. The .has_timings_switch is renamed to .ccu_has_timings_switch to clarify its meaning. Signed-off-by: Chen-Yu Tsai <wens@csie.org> Acked-by: Maxime Ripard <maxime.ripard@bootlin.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent fb8bd90 commit 1ff9cab

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

drivers/mmc/host/sunxi-mmc.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,16 @@ struct sunxi_mmc_cfg {
258258
/* Does DATA0 needs to be masked while the clock is updated */
259259
bool mask_data0;
260260

261-
/* hardware only supports new timing mode */
261+
/*
262+
* hardware only supports new timing mode, either due to lack of
263+
* a mode switch in the clock controller, or the mmc controller
264+
* is permanently configured in the new timing mode, without the
265+
* NTSR mode switch.
266+
*/
262267
bool needs_new_timings;
263268

264-
/* hardware can switch between old and new timing modes */
265-
bool has_timings_switch;
269+
/* clock hardware can switch between old and new timing modes */
270+
bool ccu_has_timings_switch;
266271
};
267272

268273
struct sunxi_mmc_host {
@@ -787,7 +792,7 @@ static int sunxi_mmc_clk_set_rate(struct sunxi_mmc_host *host,
787792
clock <<= 1;
788793
}
789794

790-
if (host->use_new_timings && host->cfg->has_timings_switch) {
795+
if (host->use_new_timings && host->cfg->ccu_has_timings_switch) {
791796
ret = sunxi_ccu_set_mmc_timing_mode(host->clk_mmc, true);
792797
if (ret) {
793798
dev_err(mmc_dev(mmc),
@@ -822,6 +827,12 @@ static int sunxi_mmc_clk_set_rate(struct sunxi_mmc_host *host,
822827
/* update card clock rate to account for internal divider */
823828
rate /= div;
824829

830+
/*
831+
* Configure the controller to use the new timing mode if needed.
832+
* On controllers that only support the new timing mode, such as
833+
* the eMMC controller on the A64, this register does not exist,
834+
* and any writes to it are ignored.
835+
*/
825836
if (host->use_new_timings) {
826837
/* Don't touch the delay bits */
827838
rval = mmc_readl(host, REG_SD_NTSR);
@@ -1145,7 +1156,7 @@ static const struct sunxi_mmc_cfg sun8i_a83t_emmc_cfg = {
11451156
.idma_des_size_bits = 16,
11461157
.clk_delays = sunxi_mmc_clk_delays,
11471158
.can_calibrate = false,
1148-
.has_timings_switch = true,
1159+
.ccu_has_timings_switch = true,
11491160
};
11501161

11511162
static const struct sunxi_mmc_cfg sun9i_a80_cfg = {
@@ -1351,7 +1362,7 @@ static int sunxi_mmc_probe(struct platform_device *pdev)
13511362
goto error_free_host;
13521363
}
13531364

1354-
if (host->cfg->has_timings_switch) {
1365+
if (host->cfg->ccu_has_timings_switch) {
13551366
/*
13561367
* Supports both old and new timing modes.
13571368
* Try setting the clk to new timing mode.

0 commit comments

Comments
 (0)