Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: tmio: factor out TAP usage

TAPs are Renesas SDHI specific. Now that we moved all handling to the
SDHI core, we can also move the definitions from the TMIO struct to the
SDHI one.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Link: https://lore.kernel.org/r/20200129203709.30493-6-wsa+renesas@sang-engineering.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Wolfram Sang and committed by
Ulf Hansson
b2dd9a13 a86bf70b

+24 -24
+5
drivers/mmc/host/renesas_sdhi.h
··· 58 58 u32 scc_tappos; 59 59 u32 scc_tappos_hs400; 60 60 bool doing_tune; 61 + 62 + /* Tuning values: 1 for success, 0 for failure */ 63 + DECLARE_BITMAP(taps, BITS_PER_BYTE * sizeof(long)); 64 + unsigned int tap_num; 65 + unsigned long tap_set; 61 66 }; 62 67 63 68 #define host_to_priv(host) \
+19 -19
drivers/mmc/host/renesas_sdhi_core.c
··· 354 354 355 355 if (priv->quirks && priv->quirks->hs400_4taps) 356 356 sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_TAPSET, 357 - host->tap_set / 2); 357 + priv->tap_set / 2); 358 358 359 359 sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_CKSEL, 360 360 SH_MOBILE_SDHI_SCC_CKSEL_DTSEL | ··· 438 438 * result requiring the tap to be good in both runs before 439 439 * considering it for tuning selection. 440 440 */ 441 - for (i = 0; i < host->tap_num * 2; i++) { 442 - int offset = host->tap_num * (i < host->tap_num ? 1 : -1); 441 + for (i = 0; i < priv->tap_num * 2; i++) { 442 + int offset = priv->tap_num * (i < priv->tap_num ? 1 : -1); 443 443 444 - if (!test_bit(i, host->taps)) 445 - clear_bit(i + offset, host->taps); 444 + if (!test_bit(i, priv->taps)) 445 + clear_bit(i + offset, priv->taps); 446 446 } 447 447 448 448 /* ··· 454 454 ntap = 0; 455 455 tap_start = 0; 456 456 tap_end = 0; 457 - for (i = 0; i < host->tap_num * 2; i++) { 458 - if (test_bit(i, host->taps)) { 457 + for (i = 0; i < priv->tap_num * 2; i++) { 458 + if (test_bit(i, priv->taps)) { 459 459 ntap++; 460 460 } else { 461 461 if (ntap > tap_cnt) { ··· 474 474 } 475 475 476 476 if (tap_cnt >= SH_MOBILE_SDHI_MAX_TAP) 477 - host->tap_set = (tap_start + tap_end) / 2 % host->tap_num; 477 + priv->tap_set = (tap_start + tap_end) / 2 % priv->tap_num; 478 478 else 479 479 return -EIO; 480 480 481 481 /* Set SCC */ 482 - sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_TAPSET, host->tap_set); 482 + sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_TAPSET, priv->tap_set); 483 483 484 484 /* Enable auto re-tuning */ 485 485 sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL, ··· 494 494 struct renesas_sdhi *priv = host_to_priv(host); 495 495 int i, ret; 496 496 497 - host->tap_num = renesas_sdhi_init_tuning(host); 498 - if (!host->tap_num) 497 + priv->tap_num = renesas_sdhi_init_tuning(host); 498 + if (!priv->tap_num) 499 499 return 0; /* Tuning is not supported */ 500 500 501 - if (host->tap_num * 2 >= sizeof(host->taps) * BITS_PER_BYTE) { 501 + if (priv->tap_num * 2 >= sizeof(priv->taps) * BITS_PER_BYTE) { 502 502 dev_err(&host->pdev->dev, 503 503 "Too many taps, please update 'taps' in tmio_mmc_host!\n"); 504 504 return -EINVAL; 505 505 } 506 506 507 507 priv->doing_tune = true; 508 - bitmap_zero(host->taps, host->tap_num * 2); 508 + bitmap_zero(priv->taps, priv->tap_num * 2); 509 509 510 510 /* Issue CMD19 twice for each tap */ 511 - for (i = 0; i < 2 * host->tap_num; i++) { 511 + for (i = 0; i < 2 * priv->tap_num; i++) { 512 512 /* Set sampling clock position */ 513 - sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_TAPSET, i % host->tap_num); 513 + sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_TAPSET, i % priv->tap_num); 514 514 515 515 ret = mmc_send_tuning(host->mmc, opcode, NULL); 516 516 if (ret == 0) 517 - set_bit(i, host->taps); 517 + set_bit(i, priv->taps); 518 518 } 519 519 520 520 return renesas_sdhi_select_tuning(host); ··· 523 523 static bool renesas_sdhi_manual_correction(struct tmio_mmc_host *host, bool use_4tap) 524 524 { 525 525 struct renesas_sdhi *priv = host_to_priv(host); 526 - unsigned long new_tap = host->tap_set; 526 + unsigned long new_tap = priv->tap_set; 527 527 u32 val; 528 528 529 529 val = sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSREQ); ··· 560 560 return false; 561 561 } 562 562 563 - host->tap_set = (new_tap % host->tap_num); 563 + priv->tap_set = (new_tap % priv->tap_num); 564 564 sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_TAPSET, 565 - host->tap_set / (use_4tap ? 2 : 1)); 565 + priv->tap_set / (use_4tap ? 2 : 1)); 566 566 567 567 return false; 568 568 }
-5
drivers/mmc/host/tmio_mmc.h
··· 184 184 */ 185 185 int (*execute_tuning)(struct tmio_mmc_host *host, u32 opcode); 186 186 187 - /* Tuning values: 1 for success, 0 for failure */ 188 - DECLARE_BITMAP(taps, BITS_PER_BYTE * sizeof(long)); 189 - unsigned int tap_num; 190 - unsigned long tap_set; 191 - 192 187 void (*prepare_hs400_tuning)(struct tmio_mmc_host *host); 193 188 void (*hs400_downgrade)(struct tmio_mmc_host *host); 194 189 void (*hs400_complete)(struct tmio_mmc_host *host);