aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-01-17 11:28:06 -0500
committerUlf Hansson <ulf.hansson@linaro.org>2018-01-18 03:08:56 -0500
commit1910b87f7a9e6d9f9085d36e45dce1e5547c692d (patch)
tree98961cb5f5855c97190122784ff75d94b79e8518
parent85f9ef8cdfb463e6e8ff9fe8cdcc0aed438b526e (diff)
mmc: tmio: refactor .get_ro hook
This IP provides the write protect signal level in the status register, but it is also possible to use GPIO for WP. They are exclusive, so it is not efficient to call mmc_gpio_get_ro() every time from tmio_mmc_get_ro() if we know gpio_ro is not used. Check the capability of gpio_ro just once in the probe function, then set mmc_gpio_get_ro to .get_ro if it is the case. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/host/tmio_mmc_core.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index 7d8eec24f0ed..6d8719be75a8 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -1076,15 +1076,9 @@ static int tmio_mmc_get_ro(struct mmc_host *mmc)
1076{ 1076{
1077 struct tmio_mmc_host *host = mmc_priv(mmc); 1077 struct tmio_mmc_host *host = mmc_priv(mmc);
1078 struct tmio_mmc_data *pdata = host->pdata; 1078 struct tmio_mmc_data *pdata = host->pdata;
1079 int ret = mmc_gpio_get_ro(mmc);
1080 1079
1081 if (ret >= 0) 1080 return !((pdata->flags & TMIO_MMC_WRPROTECT_DISABLE) ||
1082 return ret; 1081 (sd_ctrl_read16_and_16_as_32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT));
1083
1084 ret = !((pdata->flags & TMIO_MMC_WRPROTECT_DISABLE) ||
1085 (sd_ctrl_read16_and_16_as_32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT));
1086
1087 return ret;
1088} 1082}
1089 1083
1090static int tmio_multi_io_quirk(struct mmc_card *card, 1084static int tmio_multi_io_quirk(struct mmc_card *card,
@@ -1247,6 +1241,9 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
1247 } 1241 }
1248 mmc->max_seg_size = mmc->max_req_size; 1242 mmc->max_seg_size = mmc->max_req_size;
1249 1243
1244 if (mmc_can_gpio_ro(mmc))
1245 _host->ops.get_ro = mmc_gpio_get_ro;
1246
1250 _host->native_hotplug = !(mmc_can_gpio_cd(mmc) || 1247 _host->native_hotplug = !(mmc_can_gpio_cd(mmc) ||
1251 mmc->caps & MMC_CAP_NEEDS_POLL || 1248 mmc->caps & MMC_CAP_NEEDS_POLL ||
1252 !mmc_card_is_removable(mmc)); 1249 !mmc_card_is_removable(mmc));