diff options
Diffstat (limited to 'drivers/mmc/mmc.c')
-rw-r--r-- | drivers/mmc/mmc.c | 59 |
1 files changed, 52 insertions, 7 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 6201f3086a0..5b9caa7978d 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c | |||
@@ -9,7 +9,6 @@ | |||
9 | * it under the terms of the GNU General Public License version 2 as | 9 | * it under the terms of the GNU General Public License version 2 as |
10 | * published by the Free Software Foundation. | 10 | * published by the Free Software Foundation. |
11 | */ | 11 | */ |
12 | #include <linux/config.h> | ||
13 | #include <linux/module.h> | 12 | #include <linux/module.h> |
14 | #include <linux/init.h> | 13 | #include <linux/init.h> |
15 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
@@ -129,7 +128,7 @@ static void mmc_wait_done(struct mmc_request *mrq) | |||
129 | 128 | ||
130 | int mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq) | 129 | int mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq) |
131 | { | 130 | { |
132 | DECLARE_COMPLETION(complete); | 131 | DECLARE_COMPLETION_ONSTACK(complete); |
133 | 132 | ||
134 | mrq->done_data = &complete; | 133 | mrq->done_data = &complete; |
135 | mrq->done = mmc_wait_done; | 134 | mrq->done = mmc_wait_done; |
@@ -248,6 +247,55 @@ int mmc_wait_for_app_cmd(struct mmc_host *host, unsigned int rca, | |||
248 | 247 | ||
249 | EXPORT_SYMBOL(mmc_wait_for_app_cmd); | 248 | EXPORT_SYMBOL(mmc_wait_for_app_cmd); |
250 | 249 | ||
250 | /** | ||
251 | * mmc_set_data_timeout - set the timeout for a data command | ||
252 | * @data: data phase for command | ||
253 | * @card: the MMC card associated with the data transfer | ||
254 | * @write: flag to differentiate reads from writes | ||
255 | */ | ||
256 | void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card, | ||
257 | int write) | ||
258 | { | ||
259 | unsigned int mult; | ||
260 | |||
261 | /* | ||
262 | * SD cards use a 100 multiplier rather than 10 | ||
263 | */ | ||
264 | mult = mmc_card_sd(card) ? 100 : 10; | ||
265 | |||
266 | /* | ||
267 | * Scale up the multiplier (and therefore the timeout) by | ||
268 | * the r2w factor for writes. | ||
269 | */ | ||
270 | if (write) | ||
271 | mult <<= card->csd.r2w_factor; | ||
272 | |||
273 | data->timeout_ns = card->csd.tacc_ns * mult; | ||
274 | data->timeout_clks = card->csd.tacc_clks * mult; | ||
275 | |||
276 | /* | ||
277 | * SD cards also have an upper limit on the timeout. | ||
278 | */ | ||
279 | if (mmc_card_sd(card)) { | ||
280 | unsigned int timeout_us, limit_us; | ||
281 | |||
282 | timeout_us = data->timeout_ns / 1000; | ||
283 | timeout_us += data->timeout_clks * 1000 / | ||
284 | (card->host->ios.clock / 1000); | ||
285 | |||
286 | if (write) | ||
287 | limit_us = 250000; | ||
288 | else | ||
289 | limit_us = 100000; | ||
290 | |||
291 | if (timeout_us > limit_us) { | ||
292 | data->timeout_ns = limit_us * 1000; | ||
293 | data->timeout_clks = 0; | ||
294 | } | ||
295 | } | ||
296 | } | ||
297 | EXPORT_SYMBOL(mmc_set_data_timeout); | ||
298 | |||
251 | static int mmc_select_card(struct mmc_host *host, struct mmc_card *card); | 299 | static int mmc_select_card(struct mmc_host *host, struct mmc_card *card); |
252 | 300 | ||
253 | /** | 301 | /** |
@@ -909,11 +957,9 @@ static void mmc_read_scrs(struct mmc_host *host) | |||
909 | { | 957 | { |
910 | int err; | 958 | int err; |
911 | struct mmc_card *card; | 959 | struct mmc_card *card; |
912 | |||
913 | struct mmc_request mrq; | 960 | struct mmc_request mrq; |
914 | struct mmc_command cmd; | 961 | struct mmc_command cmd; |
915 | struct mmc_data data; | 962 | struct mmc_data data; |
916 | |||
917 | struct scatterlist sg; | 963 | struct scatterlist sg; |
918 | 964 | ||
919 | list_for_each_entry(card, &host->cards, node) { | 965 | list_for_each_entry(card, &host->cards, node) { |
@@ -948,9 +994,8 @@ static void mmc_read_scrs(struct mmc_host *host) | |||
948 | 994 | ||
949 | memset(&data, 0, sizeof(struct mmc_data)); | 995 | memset(&data, 0, sizeof(struct mmc_data)); |
950 | 996 | ||
951 | data.timeout_ns = card->csd.tacc_ns * 10; | 997 | mmc_set_data_timeout(&data, card, 0); |
952 | data.timeout_clks = card->csd.tacc_clks * 10; | 998 | |
953 | data.blksz_bits = 3; | ||
954 | data.blksz = 1 << 3; | 999 | data.blksz = 1 << 3; |
955 | data.blocks = 1; | 1000 | data.blocks = 1; |
956 | data.flags = MMC_DATA_READ; | 1001 | data.flags = MMC_DATA_READ; |