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

mmc: core: Factor out common code in drive strength selection

Make a new function out of common code used for drive
strength selection.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Adrian Hunter and committed by
Ulf Hansson
e23350b3 f168359e

+46 -46
+38
drivers/mmc/core/core.c
··· 1639 1639 mmc_host_clk_release(host); 1640 1640 } 1641 1641 1642 + int mmc_select_drive_strength(struct mmc_card *card, unsigned int max_dtr, 1643 + int card_drv_type, int *drv_type) 1644 + { 1645 + struct mmc_host *host = card->host; 1646 + int host_drv_type = SD_DRIVER_TYPE_B; 1647 + int drive_strength; 1648 + 1649 + *drv_type = 0; 1650 + 1651 + if (!host->ops->select_drive_strength) 1652 + return 0; 1653 + 1654 + /* Use SD definition of driver strength for hosts */ 1655 + if (host->caps & MMC_CAP_DRIVER_TYPE_A) 1656 + host_drv_type |= SD_DRIVER_TYPE_A; 1657 + 1658 + if (host->caps & MMC_CAP_DRIVER_TYPE_C) 1659 + host_drv_type |= SD_DRIVER_TYPE_C; 1660 + 1661 + if (host->caps & MMC_CAP_DRIVER_TYPE_D) 1662 + host_drv_type |= SD_DRIVER_TYPE_D; 1663 + 1664 + /* 1665 + * The drive strength that the hardware can support 1666 + * depends on the board design. Pass the appropriate 1667 + * information and let the hardware specific code 1668 + * return what is possible given the options 1669 + */ 1670 + mmc_host_clk_hold(host); 1671 + drive_strength = host->ops->select_drive_strength(card, max_dtr, 1672 + host_drv_type, 1673 + card_drv_type, 1674 + drv_type); 1675 + mmc_host_clk_release(host); 1676 + 1677 + return drive_strength; 1678 + } 1679 + 1642 1680 /* 1643 1681 * Apply power to the MMC stack. This is a two-stage process. 1644 1682 * First, we enable power to the card without the clock running.
+2
drivers/mmc/core/core.h
··· 50 50 int __mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage); 51 51 void mmc_set_timing(struct mmc_host *host, unsigned int timing); 52 52 void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type); 53 + int mmc_select_drive_strength(struct mmc_card *card, unsigned int max_dtr, 54 + int card_drv_type, int *drv_type); 53 55 void mmc_power_up(struct mmc_host *host, u32 ocr); 54 56 void mmc_power_off(struct mmc_host *host); 55 57 void mmc_power_cycle(struct mmc_host *host, u32 ocr);
+3 -24
drivers/mmc/core/sd.c
··· 386 386 387 387 static int sd_select_driver_type(struct mmc_card *card, u8 *status) 388 388 { 389 - int host_drv_type = SD_DRIVER_TYPE_B; 390 389 int card_drv_type, drive_strength, drv_type; 391 390 int err; 392 391 393 - if (!card->host->ops->select_drive_strength) 394 - return 0; 395 - 396 - if (card->host->caps & MMC_CAP_DRIVER_TYPE_A) 397 - host_drv_type |= SD_DRIVER_TYPE_A; 398 - 399 - if (card->host->caps & MMC_CAP_DRIVER_TYPE_C) 400 - host_drv_type |= SD_DRIVER_TYPE_C; 401 - 402 - if (card->host->caps & MMC_CAP_DRIVER_TYPE_D) 403 - host_drv_type |= SD_DRIVER_TYPE_D; 404 - 405 392 card_drv_type = card->sw_caps.sd3_drv_type | SD_DRIVER_TYPE_B; 406 393 407 - /* 408 - * The drive strength that the hardware can support 409 - * depends on the board design. Pass the appropriate 410 - * information and let the hardware specific code 411 - * return what is possible given the options 412 - */ 413 - mmc_host_clk_hold(card->host); 414 - drive_strength = card->host->ops->select_drive_strength(card, 415 - card->sw_caps.uhs_max_dtr, 416 - host_drv_type, card_drv_type, &drv_type); 417 - mmc_host_clk_release(card->host); 394 + drive_strength = mmc_select_drive_strength(card, 395 + card->sw_caps.uhs_max_dtr, 396 + card_drv_type, &drv_type); 418 397 419 398 if (drive_strength) { 420 399 err = mmc_sd_switch(card, 1, 2, drive_strength, status);
+3 -22
drivers/mmc/core/sdio.c
··· 402 402 403 403 static void sdio_select_driver_type(struct mmc_card *card) 404 404 { 405 - int host_drv_type = SD_DRIVER_TYPE_B; 406 405 int card_drv_type, drive_strength, drv_type; 407 406 unsigned char card_strength; 408 407 int err; 409 408 410 - if (!card->host->ops->select_drive_strength) 411 - return; 412 - 413 - if (card->host->caps & MMC_CAP_DRIVER_TYPE_A) 414 - host_drv_type |= SD_DRIVER_TYPE_A; 415 - 416 - if (card->host->caps & MMC_CAP_DRIVER_TYPE_C) 417 - host_drv_type |= SD_DRIVER_TYPE_C; 418 - 419 - if (card->host->caps & MMC_CAP_DRIVER_TYPE_D) 420 - host_drv_type |= SD_DRIVER_TYPE_D; 421 - 422 409 card_drv_type = card->sw_caps.sd3_drv_type | SD_DRIVER_TYPE_B; 423 410 424 - /* 425 - * The drive strength that the hardware can support 426 - * depends on the board design. Pass the appropriate 427 - * information and let the hardware specific code 428 - * return what is possible given the options 429 - */ 430 - drive_strength = card->host->ops->select_drive_strength(card, 431 - card->sw_caps.uhs_max_dtr, 432 - host_drv_type, card_drv_type, &drv_type); 411 + drive_strength = mmc_select_drive_strength(card, 412 + card->sw_caps.uhs_max_dtr, 413 + card_drv_type, &drv_type); 433 414 434 415 if (drive_strength) { 435 416 /* if error just use default for drive strength B */