aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeungwon Jeon <tgih.jun@samsung.com>2014-04-23 04:07:58 -0400
committerChris Ball <chris@printf.net>2014-05-12 18:05:57 -0400
commit2415c0ef618b3cd95581c7f633cbab78b29b7ab0 (patch)
treebc16740bde6075d555aaed88d2bad42a5bedefb7
parentcdc991790c51c693d0c347a5286af017826a5d01 (diff)
mmc: identify available device type to select
Device types which are supported by both host and device can be identified when EXT_CSD is read. There is no need to check host's capability anymore. Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com> Tested-by: Jaehoon Chung <jh80.chung@samsung.com> Acked-by: Jaehoon Chung <jh80.chung@samsung.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Chris Ball <chris@printf.net>
-rw-r--r--drivers/mmc/core/mmc.c72
-rw-r--r--include/linux/mmc/card.h2
-rw-r--r--include/linux/mmc/host.h6
-rw-r--r--include/linux/mmc/mmc.h12
4 files changed, 48 insertions, 44 deletions
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 31220529e171..b5691fee9629 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -243,28 +243,46 @@ static void mmc_select_card_type(struct mmc_card *card)
243 u8 card_type = card->ext_csd.raw_card_type & EXT_CSD_CARD_TYPE_MASK; 243 u8 card_type = card->ext_csd.raw_card_type & EXT_CSD_CARD_TYPE_MASK;
244 u32 caps = host->caps, caps2 = host->caps2; 244 u32 caps = host->caps, caps2 = host->caps2;
245 unsigned int hs_max_dtr = 0; 245 unsigned int hs_max_dtr = 0;
246 unsigned int avail_type = 0;
246 247
247 if (card_type & EXT_CSD_CARD_TYPE_26) 248 if (caps & MMC_CAP_MMC_HIGHSPEED &&
249 card_type & EXT_CSD_CARD_TYPE_HS_26) {
248 hs_max_dtr = MMC_HIGH_26_MAX_DTR; 250 hs_max_dtr = MMC_HIGH_26_MAX_DTR;
251 avail_type |= EXT_CSD_CARD_TYPE_HS_26;
252 }
249 253
250 if (caps & MMC_CAP_MMC_HIGHSPEED && 254 if (caps & MMC_CAP_MMC_HIGHSPEED &&
251 card_type & EXT_CSD_CARD_TYPE_52) 255 card_type & EXT_CSD_CARD_TYPE_HS_52) {
252 hs_max_dtr = MMC_HIGH_52_MAX_DTR; 256 hs_max_dtr = MMC_HIGH_52_MAX_DTR;
257 avail_type |= EXT_CSD_CARD_TYPE_HS_52;
258 }
253 259
254 if ((caps & MMC_CAP_1_8V_DDR && 260 if (caps & MMC_CAP_1_8V_DDR &&
255 card_type & EXT_CSD_CARD_TYPE_DDR_1_8V) || 261 card_type & EXT_CSD_CARD_TYPE_DDR_1_8V) {
256 (caps & MMC_CAP_1_2V_DDR &&
257 card_type & EXT_CSD_CARD_TYPE_DDR_1_2V))
258 hs_max_dtr = MMC_HIGH_DDR_MAX_DTR; 262 hs_max_dtr = MMC_HIGH_DDR_MAX_DTR;
263 avail_type |= EXT_CSD_CARD_TYPE_DDR_1_8V;
264 }
265
266 if (caps & MMC_CAP_1_2V_DDR &&
267 card_type & EXT_CSD_CARD_TYPE_DDR_1_2V) {
268 hs_max_dtr = MMC_HIGH_DDR_MAX_DTR;
269 avail_type |= EXT_CSD_CARD_TYPE_DDR_1_2V;
270 }
259 271
260 if ((caps2 & MMC_CAP2_HS200_1_8V_SDR && 272 if (caps2 & MMC_CAP2_HS200_1_8V_SDR &&
261 card_type & EXT_CSD_CARD_TYPE_SDR_1_8V) || 273 card_type & EXT_CSD_CARD_TYPE_HS200_1_8V) {
262 (caps2 & MMC_CAP2_HS200_1_2V_SDR &&
263 card_type & EXT_CSD_CARD_TYPE_SDR_1_2V))
264 hs_max_dtr = MMC_HS200_MAX_DTR; 274 hs_max_dtr = MMC_HS200_MAX_DTR;
275 avail_type |= EXT_CSD_CARD_TYPE_HS200_1_8V;
276 }
277
278 if (caps2 & MMC_CAP2_HS200_1_2V_SDR &&
279 card_type & EXT_CSD_CARD_TYPE_HS200_1_2V) {
280 hs_max_dtr = MMC_HS200_MAX_DTR;
281 avail_type |= EXT_CSD_CARD_TYPE_HS200_1_2V;
282 }
265 283
266 card->ext_csd.hs_max_dtr = hs_max_dtr; 284 card->ext_csd.hs_max_dtr = hs_max_dtr;
267 card->ext_csd.card_type = card_type; 285 card->mmc_avail_type = avail_type;
268} 286}
269 287
270/* 288/*
@@ -800,12 +818,10 @@ static int mmc_select_hs200(struct mmc_card *card)
800 818
801 host = card->host; 819 host = card->host;
802 820
803 if (card->ext_csd.card_type & EXT_CSD_CARD_TYPE_SDR_1_2V && 821 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200_1_2V)
804 host->caps2 & MMC_CAP2_HS200_1_2V_SDR)
805 err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120); 822 err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120);
806 823
807 if (err && card->ext_csd.card_type & EXT_CSD_CARD_TYPE_SDR_1_8V && 824 if (err && card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200_1_8V)
808 host->caps2 & MMC_CAP2_HS200_1_8V_SDR)
809 err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180); 825 err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180);
810 826
811 /* If fails try again during next card power cycle */ 827 /* If fails try again during next card power cycle */
@@ -1064,10 +1080,9 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1064 */ 1080 */
1065 if (card->ext_csd.hs_max_dtr != 0) { 1081 if (card->ext_csd.hs_max_dtr != 0) {
1066 err = 0; 1082 err = 0;
1067 if (card->ext_csd.hs_max_dtr > 52000000 && 1083 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200)
1068 host->caps2 & MMC_CAP2_HS200)
1069 err = mmc_select_hs200(card); 1084 err = mmc_select_hs200(card);
1070 else if (host->caps & MMC_CAP_MMC_HIGHSPEED) 1085 else if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS)
1071 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 1086 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1072 EXT_CSD_HS_TIMING, 1, 1087 EXT_CSD_HS_TIMING, 1,
1073 card->ext_csd.generic_cmd6_time, 1088 card->ext_csd.generic_cmd6_time,
@@ -1081,13 +1096,11 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1081 mmc_hostname(card->host)); 1096 mmc_hostname(card->host));
1082 err = 0; 1097 err = 0;
1083 } else { 1098 } else {
1084 if (card->ext_csd.hs_max_dtr > 52000000 && 1099 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200)
1085 host->caps2 & MMC_CAP2_HS200) {
1086 mmc_set_timing(card->host, 1100 mmc_set_timing(card->host,
1087 MMC_TIMING_MMC_HS200); 1101 MMC_TIMING_MMC_HS200);
1088 } else { 1102 else
1089 mmc_set_timing(card->host, MMC_TIMING_MMC_HS); 1103 mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
1090 }
1091 } 1104 }
1092 } 1105 }
1093 1106
@@ -1110,14 +1123,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1110 /* 1123 /*
1111 * Indicate DDR mode (if supported). 1124 * Indicate DDR mode (if supported).
1112 */ 1125 */
1113 if (mmc_card_hs(card)) { 1126 if (mmc_card_hs(card))
1114 if ((card->ext_csd.card_type & EXT_CSD_CARD_TYPE_DDR_1_8V) 1127 ddr = card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_52;
1115 && (host->caps & MMC_CAP_1_8V_DDR))
1116 ddr = MMC_1_8V_DDR_MODE;
1117 else if ((card->ext_csd.card_type & EXT_CSD_CARD_TYPE_DDR_1_2V)
1118 && (host->caps & MMC_CAP_1_2V_DDR))
1119 ddr = MMC_1_2V_DDR_MODE;
1120 }
1121 1128
1122 /* 1129 /*
1123 * Indicate HS200 SDR mode (if supported). 1130 * Indicate HS200 SDR mode (if supported).
@@ -1137,8 +1144,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1137 * 3. set the clock to > 52Mhz <=200MHz and 1144 * 3. set the clock to > 52Mhz <=200MHz and
1138 * 4. execute tuning for HS200 1145 * 4. execute tuning for HS200
1139 */ 1146 */
1140 if ((host->caps2 & MMC_CAP2_HS200) && 1147 if (card->host->ops->execute_tuning) {
1141 card->host->ops->execute_tuning) {
1142 mmc_host_clk_hold(card->host); 1148 mmc_host_clk_hold(card->host);
1143 err = card->host->ops->execute_tuning(card->host, 1149 err = card->host->ops->execute_tuning(card->host,
1144 MMC_SEND_TUNING_BLOCK_HS200); 1150 MMC_SEND_TUNING_BLOCK_HS200);
@@ -1247,7 +1253,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1247 * 1253 *
1248 * WARNING: eMMC rules are NOT the same as SD DDR 1254 * WARNING: eMMC rules are NOT the same as SD DDR
1249 */ 1255 */
1250 if (ddr == MMC_1_2V_DDR_MODE) { 1256 if (ddr & EXT_CSD_CARD_TYPE_DDR_1_2V) {
1251 err = __mmc_set_signal_voltage(host, 1257 err = __mmc_set_signal_voltage(host,
1252 MMC_SIGNAL_VOLTAGE_120); 1258 MMC_SIGNAL_VOLTAGE_120);
1253 if (err) 1259 if (err)
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index aadeaf155d0e..fe31f8d89a03 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -68,7 +68,6 @@ struct mmc_ext_csd {
68#define MMC_HIGH_DDR_MAX_DTR 52000000 68#define MMC_HIGH_DDR_MAX_DTR 52000000
69#define MMC_HS200_MAX_DTR 200000000 69#define MMC_HS200_MAX_DTR 200000000
70 unsigned int sectors; 70 unsigned int sectors;
71 unsigned int card_type;
72 unsigned int hc_erase_size; /* In sectors */ 71 unsigned int hc_erase_size; /* In sectors */
73 unsigned int hc_erase_timeout; /* In milliseconds */ 72 unsigned int hc_erase_timeout; /* In milliseconds */
74 unsigned int sec_trim_mult; /* Secure trim multiplier */ 73 unsigned int sec_trim_mult; /* Secure trim multiplier */
@@ -298,6 +297,7 @@ struct mmc_card {
298 struct sdio_func_tuple *tuples; /* unknown common tuples */ 297 struct sdio_func_tuple *tuples; /* unknown common tuples */
299 298
300 unsigned int sd_bus_speed; /* Bus Speed Mode set for the card */ 299 unsigned int sd_bus_speed; /* Bus Speed Mode set for the card */
300 unsigned int mmc_avail_type; /* supported device type by both host and card */
301 301
302 struct dentry *debugfs_root; 302 struct dentry *debugfs_root;
303 struct mmc_part part[MMC_NUM_PHY_PARTITION]; /* physical partitions */ 303 struct mmc_part part[MMC_NUM_PHY_PARTITION]; /* physical partitions */
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index a43853779799..6b1e9ee6ca10 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -62,12 +62,6 @@ struct mmc_ios {
62#define MMC_TIMING_MMC_DDR52 8 62#define MMC_TIMING_MMC_DDR52 8
63#define MMC_TIMING_MMC_HS200 9 63#define MMC_TIMING_MMC_HS200 9
64 64
65#define MMC_SDR_MODE 0
66#define MMC_1_2V_DDR_MODE 1
67#define MMC_1_8V_DDR_MODE 2
68#define MMC_1_2V_SDR_MODE 3
69#define MMC_1_8V_SDR_MODE 4
70
71 unsigned char signal_voltage; /* signalling voltage (1.8V or 3.3V) */ 65 unsigned char signal_voltage; /* signalling voltage (1.8V or 3.3V) */
72 66
73#define MMC_SIGNAL_VOLTAGE_330 0 67#define MMC_SIGNAL_VOLTAGE_330 0
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index 50bcde3677ca..f734c0c64575 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -354,18 +354,22 @@ struct _mmc_csd {
354#define EXT_CSD_CMD_SET_SECURE (1<<1) 354#define EXT_CSD_CMD_SET_SECURE (1<<1)
355#define EXT_CSD_CMD_SET_CPSECURE (1<<2) 355#define EXT_CSD_CMD_SET_CPSECURE (1<<2)
356 356
357#define EXT_CSD_CARD_TYPE_26 (1<<0) /* Card can run at 26MHz */
358#define EXT_CSD_CARD_TYPE_52 (1<<1) /* Card can run at 52MHz */
359#define EXT_CSD_CARD_TYPE_MASK 0x3F /* Mask out reserved bits */ 357#define EXT_CSD_CARD_TYPE_MASK 0x3F /* Mask out reserved bits */
358#define EXT_CSD_CARD_TYPE_HS_26 (1<<0) /* Card can run at 26MHz */
359#define EXT_CSD_CARD_TYPE_HS_52 (1<<1) /* Card can run at 52MHz */
360#define EXT_CSD_CARD_TYPE_HS (EXT_CSD_CARD_TYPE_HS_26 | \
361 EXT_CSD_CARD_TYPE_HS_52)
360#define EXT_CSD_CARD_TYPE_DDR_1_8V (1<<2) /* Card can run at 52MHz */ 362#define EXT_CSD_CARD_TYPE_DDR_1_8V (1<<2) /* Card can run at 52MHz */
361 /* DDR mode @1.8V or 3V I/O */ 363 /* DDR mode @1.8V or 3V I/O */
362#define EXT_CSD_CARD_TYPE_DDR_1_2V (1<<3) /* Card can run at 52MHz */ 364#define EXT_CSD_CARD_TYPE_DDR_1_2V (1<<3) /* Card can run at 52MHz */
363 /* DDR mode @1.2V I/O */ 365 /* DDR mode @1.2V I/O */
364#define EXT_CSD_CARD_TYPE_DDR_52 (EXT_CSD_CARD_TYPE_DDR_1_8V \ 366#define EXT_CSD_CARD_TYPE_DDR_52 (EXT_CSD_CARD_TYPE_DDR_1_8V \
365 | EXT_CSD_CARD_TYPE_DDR_1_2V) 367 | EXT_CSD_CARD_TYPE_DDR_1_2V)
366#define EXT_CSD_CARD_TYPE_SDR_1_8V (1<<4) /* Card can run at 200MHz */ 368#define EXT_CSD_CARD_TYPE_HS200_1_8V (1<<4) /* Card can run at 200MHz */
367#define EXT_CSD_CARD_TYPE_SDR_1_2V (1<<5) /* Card can run at 200MHz */ 369#define EXT_CSD_CARD_TYPE_HS200_1_2V (1<<5) /* Card can run at 200MHz */
368 /* SDR mode @1.2V I/O */ 370 /* SDR mode @1.2V I/O */
371#define EXT_CSD_CARD_TYPE_HS200 (EXT_CSD_CARD_TYPE_HS200_1_8V | \
372 EXT_CSD_CARD_TYPE_HS200_1_2V)
369 373
370#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */ 374#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */
371#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */ 375#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */