diff options
Diffstat (limited to 'drivers/mmc/host')
-rw-r--r-- | drivers/mmc/host/au1xmmc.c | 54 | ||||
-rw-r--r-- | drivers/mmc/host/pxamci.c | 2 | ||||
-rw-r--r-- | drivers/mmc/host/s3cmci.c | 50 | ||||
-rw-r--r-- | drivers/mmc/host/sdhci.c | 167 | ||||
-rw-r--r-- | drivers/mmc/host/sdhci.h | 7 |
5 files changed, 152 insertions, 128 deletions
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c index 3f15eb204895..99b20917cc0f 100644 --- a/drivers/mmc/host/au1xmmc.c +++ b/drivers/mmc/host/au1xmmc.c | |||
@@ -1043,7 +1043,7 @@ static int __devinit au1xmmc_probe(struct platform_device *pdev) | |||
1043 | goto out6; | 1043 | goto out6; |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | platform_set_drvdata(pdev, mmc); | 1046 | platform_set_drvdata(pdev, host); |
1047 | 1047 | ||
1048 | printk(KERN_INFO DRIVER_NAME ": MMC Controller %d set up at %8.8X" | 1048 | printk(KERN_INFO DRIVER_NAME ": MMC Controller %d set up at %8.8X" |
1049 | " (mode=%s)\n", pdev->id, host->iobase, | 1049 | " (mode=%s)\n", pdev->id, host->iobase, |
@@ -1087,13 +1087,10 @@ out0: | |||
1087 | 1087 | ||
1088 | static int __devexit au1xmmc_remove(struct platform_device *pdev) | 1088 | static int __devexit au1xmmc_remove(struct platform_device *pdev) |
1089 | { | 1089 | { |
1090 | struct mmc_host *mmc = platform_get_drvdata(pdev); | 1090 | struct au1xmmc_host *host = platform_get_drvdata(pdev); |
1091 | struct au1xmmc_host *host; | ||
1092 | |||
1093 | if (mmc) { | ||
1094 | host = mmc_priv(mmc); | ||
1095 | 1091 | ||
1096 | mmc_remove_host(mmc); | 1092 | if (host) { |
1093 | mmc_remove_host(host->mmc); | ||
1097 | 1094 | ||
1098 | #ifdef CONFIG_LEDS_CLASS | 1095 | #ifdef CONFIG_LEDS_CLASS |
1099 | if (host->platdata && host->platdata->led) | 1096 | if (host->platdata && host->platdata->led) |
@@ -1101,8 +1098,8 @@ static int __devexit au1xmmc_remove(struct platform_device *pdev) | |||
1101 | #endif | 1098 | #endif |
1102 | 1099 | ||
1103 | if (host->platdata && host->platdata->cd_setup && | 1100 | if (host->platdata && host->platdata->cd_setup && |
1104 | !(mmc->caps & MMC_CAP_NEEDS_POLL)) | 1101 | !(host->mmc->caps & MMC_CAP_NEEDS_POLL)) |
1105 | host->platdata->cd_setup(mmc, 0); | 1102 | host->platdata->cd_setup(host->mmc, 0); |
1106 | 1103 | ||
1107 | au_writel(0, HOST_ENABLE(host)); | 1104 | au_writel(0, HOST_ENABLE(host)); |
1108 | au_writel(0, HOST_CONFIG(host)); | 1105 | au_writel(0, HOST_CONFIG(host)); |
@@ -1122,16 +1119,49 @@ static int __devexit au1xmmc_remove(struct platform_device *pdev) | |||
1122 | release_resource(host->ioarea); | 1119 | release_resource(host->ioarea); |
1123 | kfree(host->ioarea); | 1120 | kfree(host->ioarea); |
1124 | 1121 | ||
1125 | mmc_free_host(mmc); | 1122 | mmc_free_host(host->mmc); |
1123 | platform_set_drvdata(pdev, NULL); | ||
1126 | } | 1124 | } |
1127 | return 0; | 1125 | return 0; |
1128 | } | 1126 | } |
1129 | 1127 | ||
1128 | #ifdef CONFIG_PM | ||
1129 | static int au1xmmc_suspend(struct platform_device *pdev, pm_message_t state) | ||
1130 | { | ||
1131 | struct au1xmmc_host *host = platform_get_drvdata(pdev); | ||
1132 | int ret; | ||
1133 | |||
1134 | ret = mmc_suspend_host(host->mmc, state); | ||
1135 | if (ret) | ||
1136 | return ret; | ||
1137 | |||
1138 | au_writel(0, HOST_CONFIG2(host)); | ||
1139 | au_writel(0, HOST_CONFIG(host)); | ||
1140 | au_writel(0xffffffff, HOST_STATUS(host)); | ||
1141 | au_writel(0, HOST_ENABLE(host)); | ||
1142 | au_sync(); | ||
1143 | |||
1144 | return 0; | ||
1145 | } | ||
1146 | |||
1147 | static int au1xmmc_resume(struct platform_device *pdev) | ||
1148 | { | ||
1149 | struct au1xmmc_host *host = platform_get_drvdata(pdev); | ||
1150 | |||
1151 | au1xmmc_reset_controller(host); | ||
1152 | |||
1153 | return mmc_resume_host(host->mmc); | ||
1154 | } | ||
1155 | #else | ||
1156 | #define au1xmmc_suspend NULL | ||
1157 | #define au1xmmc_resume NULL | ||
1158 | #endif | ||
1159 | |||
1130 | static struct platform_driver au1xmmc_driver = { | 1160 | static struct platform_driver au1xmmc_driver = { |
1131 | .probe = au1xmmc_probe, | 1161 | .probe = au1xmmc_probe, |
1132 | .remove = au1xmmc_remove, | 1162 | .remove = au1xmmc_remove, |
1133 | .suspend = NULL, | 1163 | .suspend = au1xmmc_suspend, |
1134 | .resume = NULL, | 1164 | .resume = au1xmmc_resume, |
1135 | .driver = { | 1165 | .driver = { |
1136 | .name = DRIVER_NAME, | 1166 | .name = DRIVER_NAME, |
1137 | .owner = THIS_MODULE, | 1167 | .owner = THIS_MODULE, |
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c index d39f59738866..a8e18fe53077 100644 --- a/drivers/mmc/host/pxamci.c +++ b/drivers/mmc/host/pxamci.c | |||
@@ -177,7 +177,7 @@ static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data) | |||
177 | if (dalgn) | 177 | if (dalgn) |
178 | DALGN |= (1 << host->dma); | 178 | DALGN |= (1 << host->dma); |
179 | else | 179 | else |
180 | DALGN &= (1 << host->dma); | 180 | DALGN &= ~(1 << host->dma); |
181 | DDADR(host->dma) = host->sg_dma; | 181 | DDADR(host->dma) = host->sg_dma; |
182 | DCSR(host->dma) = DCSR_RUN; | 182 | DCSR(host->dma) = DCSR_RUN; |
183 | } | 183 | } |
diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c index 6a1e4994b724..be550c26da68 100644 --- a/drivers/mmc/host/s3cmci.c +++ b/drivers/mmc/host/s3cmci.c | |||
@@ -1331,21 +1331,30 @@ static int __devinit s3cmci_probe(struct platform_device *pdev, int is2440) | |||
1331 | return ret; | 1331 | return ret; |
1332 | } | 1332 | } |
1333 | 1333 | ||
1334 | static void s3cmci_shutdown(struct platform_device *pdev) | ||
1335 | { | ||
1336 | struct mmc_host *mmc = platform_get_drvdata(pdev); | ||
1337 | struct s3cmci_host *host = mmc_priv(mmc); | ||
1338 | |||
1339 | if (host->irq_cd >= 0) | ||
1340 | free_irq(host->irq_cd, host); | ||
1341 | |||
1342 | mmc_remove_host(mmc); | ||
1343 | clk_disable(host->clk); | ||
1344 | } | ||
1345 | |||
1334 | static int __devexit s3cmci_remove(struct platform_device *pdev) | 1346 | static int __devexit s3cmci_remove(struct platform_device *pdev) |
1335 | { | 1347 | { |
1336 | struct mmc_host *mmc = platform_get_drvdata(pdev); | 1348 | struct mmc_host *mmc = platform_get_drvdata(pdev); |
1337 | struct s3cmci_host *host = mmc_priv(mmc); | 1349 | struct s3cmci_host *host = mmc_priv(mmc); |
1338 | 1350 | ||
1339 | mmc_remove_host(mmc); | 1351 | s3cmci_shutdown(pdev); |
1340 | 1352 | ||
1341 | clk_disable(host->clk); | ||
1342 | clk_put(host->clk); | 1353 | clk_put(host->clk); |
1343 | 1354 | ||
1344 | tasklet_disable(&host->pio_tasklet); | 1355 | tasklet_disable(&host->pio_tasklet); |
1345 | s3c2410_dma_free(S3CMCI_DMA, &s3cmci_dma_client); | 1356 | s3c2410_dma_free(S3CMCI_DMA, &s3cmci_dma_client); |
1346 | 1357 | ||
1347 | if (host->irq_cd >= 0) | ||
1348 | free_irq(host->irq_cd, host); | ||
1349 | free_irq(host->irq, host); | 1358 | free_irq(host->irq, host); |
1350 | 1359 | ||
1351 | iounmap(host->base); | 1360 | iounmap(host->base); |
@@ -1355,17 +1364,17 @@ static int __devexit s3cmci_remove(struct platform_device *pdev) | |||
1355 | return 0; | 1364 | return 0; |
1356 | } | 1365 | } |
1357 | 1366 | ||
1358 | static int __devinit s3cmci_probe_2410(struct platform_device *dev) | 1367 | static int __devinit s3cmci_2410_probe(struct platform_device *dev) |
1359 | { | 1368 | { |
1360 | return s3cmci_probe(dev, 0); | 1369 | return s3cmci_probe(dev, 0); |
1361 | } | 1370 | } |
1362 | 1371 | ||
1363 | static int __devinit s3cmci_probe_2412(struct platform_device *dev) | 1372 | static int __devinit s3cmci_2412_probe(struct platform_device *dev) |
1364 | { | 1373 | { |
1365 | return s3cmci_probe(dev, 1); | 1374 | return s3cmci_probe(dev, 1); |
1366 | } | 1375 | } |
1367 | 1376 | ||
1368 | static int __devinit s3cmci_probe_2440(struct platform_device *dev) | 1377 | static int __devinit s3cmci_2440_probe(struct platform_device *dev) |
1369 | { | 1378 | { |
1370 | return s3cmci_probe(dev, 1); | 1379 | return s3cmci_probe(dev, 1); |
1371 | } | 1380 | } |
@@ -1392,29 +1401,32 @@ static int s3cmci_resume(struct platform_device *dev) | |||
1392 | #endif /* CONFIG_PM */ | 1401 | #endif /* CONFIG_PM */ |
1393 | 1402 | ||
1394 | 1403 | ||
1395 | static struct platform_driver s3cmci_driver_2410 = { | 1404 | static struct platform_driver s3cmci_2410_driver = { |
1396 | .driver.name = "s3c2410-sdi", | 1405 | .driver.name = "s3c2410-sdi", |
1397 | .driver.owner = THIS_MODULE, | 1406 | .driver.owner = THIS_MODULE, |
1398 | .probe = s3cmci_probe_2410, | 1407 | .probe = s3cmci_2410_probe, |
1399 | .remove = __devexit_p(s3cmci_remove), | 1408 | .remove = __devexit_p(s3cmci_remove), |
1409 | .shutdown = s3cmci_shutdown, | ||
1400 | .suspend = s3cmci_suspend, | 1410 | .suspend = s3cmci_suspend, |
1401 | .resume = s3cmci_resume, | 1411 | .resume = s3cmci_resume, |
1402 | }; | 1412 | }; |
1403 | 1413 | ||
1404 | static struct platform_driver s3cmci_driver_2412 = { | 1414 | static struct platform_driver s3cmci_2412_driver = { |
1405 | .driver.name = "s3c2412-sdi", | 1415 | .driver.name = "s3c2412-sdi", |
1406 | .driver.owner = THIS_MODULE, | 1416 | .driver.owner = THIS_MODULE, |
1407 | .probe = s3cmci_probe_2412, | 1417 | .probe = s3cmci_2412_probe, |
1408 | .remove = __devexit_p(s3cmci_remove), | 1418 | .remove = __devexit_p(s3cmci_remove), |
1419 | .shutdown = s3cmci_shutdown, | ||
1409 | .suspend = s3cmci_suspend, | 1420 | .suspend = s3cmci_suspend, |
1410 | .resume = s3cmci_resume, | 1421 | .resume = s3cmci_resume, |
1411 | }; | 1422 | }; |
1412 | 1423 | ||
1413 | static struct platform_driver s3cmci_driver_2440 = { | 1424 | static struct platform_driver s3cmci_2440_driver = { |
1414 | .driver.name = "s3c2440-sdi", | 1425 | .driver.name = "s3c2440-sdi", |
1415 | .driver.owner = THIS_MODULE, | 1426 | .driver.owner = THIS_MODULE, |
1416 | .probe = s3cmci_probe_2440, | 1427 | .probe = s3cmci_2440_probe, |
1417 | .remove = __devexit_p(s3cmci_remove), | 1428 | .remove = __devexit_p(s3cmci_remove), |
1429 | .shutdown = s3cmci_shutdown, | ||
1418 | .suspend = s3cmci_suspend, | 1430 | .suspend = s3cmci_suspend, |
1419 | .resume = s3cmci_resume, | 1431 | .resume = s3cmci_resume, |
1420 | }; | 1432 | }; |
@@ -1422,17 +1434,17 @@ static struct platform_driver s3cmci_driver_2440 = { | |||
1422 | 1434 | ||
1423 | static int __init s3cmci_init(void) | 1435 | static int __init s3cmci_init(void) |
1424 | { | 1436 | { |
1425 | platform_driver_register(&s3cmci_driver_2410); | 1437 | platform_driver_register(&s3cmci_2410_driver); |
1426 | platform_driver_register(&s3cmci_driver_2412); | 1438 | platform_driver_register(&s3cmci_2412_driver); |
1427 | platform_driver_register(&s3cmci_driver_2440); | 1439 | platform_driver_register(&s3cmci_2440_driver); |
1428 | return 0; | 1440 | return 0; |
1429 | } | 1441 | } |
1430 | 1442 | ||
1431 | static void __exit s3cmci_exit(void) | 1443 | static void __exit s3cmci_exit(void) |
1432 | { | 1444 | { |
1433 | platform_driver_unregister(&s3cmci_driver_2410); | 1445 | platform_driver_unregister(&s3cmci_2410_driver); |
1434 | platform_driver_unregister(&s3cmci_driver_2412); | 1446 | platform_driver_unregister(&s3cmci_2412_driver); |
1435 | platform_driver_unregister(&s3cmci_driver_2440); | 1447 | platform_driver_unregister(&s3cmci_2440_driver); |
1436 | } | 1448 | } |
1437 | 1449 | ||
1438 | module_init(s3cmci_init); | 1450 | module_init(s3cmci_init); |
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 17701c3da733..c3a5db72ddd7 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -173,119 +173,95 @@ static void sdhci_led_control(struct led_classdev *led, | |||
173 | * * | 173 | * * |
174 | \*****************************************************************************/ | 174 | \*****************************************************************************/ |
175 | 175 | ||
176 | static inline char* sdhci_sg_to_buffer(struct sdhci_host* host) | ||
177 | { | ||
178 | return sg_virt(host->cur_sg); | ||
179 | } | ||
180 | |||
181 | static inline int sdhci_next_sg(struct sdhci_host* host) | ||
182 | { | ||
183 | /* | ||
184 | * Skip to next SG entry. | ||
185 | */ | ||
186 | host->cur_sg++; | ||
187 | host->num_sg--; | ||
188 | |||
189 | /* | ||
190 | * Any entries left? | ||
191 | */ | ||
192 | if (host->num_sg > 0) { | ||
193 | host->offset = 0; | ||
194 | host->remain = host->cur_sg->length; | ||
195 | } | ||
196 | |||
197 | return host->num_sg; | ||
198 | } | ||
199 | |||
200 | static void sdhci_read_block_pio(struct sdhci_host *host) | 176 | static void sdhci_read_block_pio(struct sdhci_host *host) |
201 | { | 177 | { |
202 | int blksize, chunk_remain; | 178 | unsigned long flags; |
203 | u32 data; | 179 | size_t blksize, len, chunk; |
204 | char *buffer; | 180 | u32 scratch; |
205 | int size; | 181 | u8 *buf; |
206 | 182 | ||
207 | DBG("PIO reading\n"); | 183 | DBG("PIO reading\n"); |
208 | 184 | ||
209 | blksize = host->data->blksz; | 185 | blksize = host->data->blksz; |
210 | chunk_remain = 0; | 186 | chunk = 0; |
211 | data = 0; | ||
212 | 187 | ||
213 | buffer = sdhci_sg_to_buffer(host) + host->offset; | 188 | local_irq_save(flags); |
214 | 189 | ||
215 | while (blksize) { | 190 | while (blksize) { |
216 | if (chunk_remain == 0) { | 191 | if (!sg_miter_next(&host->sg_miter)) |
217 | data = readl(host->ioaddr + SDHCI_BUFFER); | 192 | BUG(); |
218 | chunk_remain = min(blksize, 4); | ||
219 | } | ||
220 | 193 | ||
221 | size = min(host->remain, chunk_remain); | 194 | len = min(host->sg_miter.length, blksize); |
222 | 195 | ||
223 | chunk_remain -= size; | 196 | blksize -= len; |
224 | blksize -= size; | 197 | host->sg_miter.consumed = len; |
225 | host->offset += size; | ||
226 | host->remain -= size; | ||
227 | 198 | ||
228 | while (size) { | 199 | buf = host->sg_miter.addr; |
229 | *buffer = data & 0xFF; | ||
230 | buffer++; | ||
231 | data >>= 8; | ||
232 | size--; | ||
233 | } | ||
234 | 200 | ||
235 | if (host->remain == 0) { | 201 | while (len) { |
236 | if (sdhci_next_sg(host) == 0) { | 202 | if (chunk == 0) { |
237 | BUG_ON(blksize != 0); | 203 | scratch = readl(host->ioaddr + SDHCI_BUFFER); |
238 | return; | 204 | chunk = 4; |
239 | } | 205 | } |
240 | buffer = sdhci_sg_to_buffer(host); | 206 | |
207 | *buf = scratch & 0xFF; | ||
208 | |||
209 | buf++; | ||
210 | scratch >>= 8; | ||
211 | chunk--; | ||
212 | len--; | ||
241 | } | 213 | } |
242 | } | 214 | } |
215 | |||
216 | sg_miter_stop(&host->sg_miter); | ||
217 | |||
218 | local_irq_restore(flags); | ||
243 | } | 219 | } |
244 | 220 | ||
245 | static void sdhci_write_block_pio(struct sdhci_host *host) | 221 | static void sdhci_write_block_pio(struct sdhci_host *host) |
246 | { | 222 | { |
247 | int blksize, chunk_remain; | 223 | unsigned long flags; |
248 | u32 data; | 224 | size_t blksize, len, chunk; |
249 | char *buffer; | 225 | u32 scratch; |
250 | int bytes, size; | 226 | u8 *buf; |
251 | 227 | ||
252 | DBG("PIO writing\n"); | 228 | DBG("PIO writing\n"); |
253 | 229 | ||
254 | blksize = host->data->blksz; | 230 | blksize = host->data->blksz; |
255 | chunk_remain = 4; | 231 | chunk = 0; |
256 | data = 0; | 232 | scratch = 0; |
257 | 233 | ||
258 | bytes = 0; | 234 | local_irq_save(flags); |
259 | buffer = sdhci_sg_to_buffer(host) + host->offset; | ||
260 | 235 | ||
261 | while (blksize) { | 236 | while (blksize) { |
262 | size = min(host->remain, chunk_remain); | 237 | if (!sg_miter_next(&host->sg_miter)) |
263 | 238 | BUG(); | |
264 | chunk_remain -= size; | ||
265 | blksize -= size; | ||
266 | host->offset += size; | ||
267 | host->remain -= size; | ||
268 | |||
269 | while (size) { | ||
270 | data >>= 8; | ||
271 | data |= (u32)*buffer << 24; | ||
272 | buffer++; | ||
273 | size--; | ||
274 | } | ||
275 | 239 | ||
276 | if (chunk_remain == 0) { | 240 | len = min(host->sg_miter.length, blksize); |
277 | writel(data, host->ioaddr + SDHCI_BUFFER); | 241 | |
278 | chunk_remain = min(blksize, 4); | 242 | blksize -= len; |
279 | } | 243 | host->sg_miter.consumed = len; |
244 | |||
245 | buf = host->sg_miter.addr; | ||
280 | 246 | ||
281 | if (host->remain == 0) { | 247 | while (len) { |
282 | if (sdhci_next_sg(host) == 0) { | 248 | scratch |= (u32)*buf << (chunk * 8); |
283 | BUG_ON(blksize != 0); | 249 | |
284 | return; | 250 | buf++; |
251 | chunk++; | ||
252 | len--; | ||
253 | |||
254 | if ((chunk == 4) || ((len == 0) && (blksize == 0))) { | ||
255 | writel(scratch, host->ioaddr + SDHCI_BUFFER); | ||
256 | chunk = 0; | ||
257 | scratch = 0; | ||
285 | } | 258 | } |
286 | buffer = sdhci_sg_to_buffer(host); | ||
287 | } | 259 | } |
288 | } | 260 | } |
261 | |||
262 | sg_miter_stop(&host->sg_miter); | ||
263 | |||
264 | local_irq_restore(flags); | ||
289 | } | 265 | } |
290 | 266 | ||
291 | static void sdhci_transfer_pio(struct sdhci_host *host) | 267 | static void sdhci_transfer_pio(struct sdhci_host *host) |
@@ -294,7 +270,7 @@ static void sdhci_transfer_pio(struct sdhci_host *host) | |||
294 | 270 | ||
295 | BUG_ON(!host->data); | 271 | BUG_ON(!host->data); |
296 | 272 | ||
297 | if (host->num_sg == 0) | 273 | if (host->blocks == 0) |
298 | return; | 274 | return; |
299 | 275 | ||
300 | if (host->data->flags & MMC_DATA_READ) | 276 | if (host->data->flags & MMC_DATA_READ) |
@@ -308,7 +284,8 @@ static void sdhci_transfer_pio(struct sdhci_host *host) | |||
308 | else | 284 | else |
309 | sdhci_write_block_pio(host); | 285 | sdhci_write_block_pio(host); |
310 | 286 | ||
311 | if (host->num_sg == 0) | 287 | host->blocks--; |
288 | if (host->blocks == 0) | ||
312 | break; | 289 | break; |
313 | } | 290 | } |
314 | 291 | ||
@@ -389,6 +366,7 @@ static int sdhci_adma_table_pre(struct sdhci_host *host, | |||
389 | if (offset) { | 366 | if (offset) { |
390 | if (data->flags & MMC_DATA_WRITE) { | 367 | if (data->flags & MMC_DATA_WRITE) { |
391 | buffer = sdhci_kmap_atomic(sg, &flags); | 368 | buffer = sdhci_kmap_atomic(sg, &flags); |
369 | WARN_ON(((long)buffer & PAGE_MASK) > (PAGE_SIZE - 3)); | ||
392 | memcpy(align, buffer, offset); | 370 | memcpy(align, buffer, offset); |
393 | sdhci_kunmap_atomic(buffer, &flags); | 371 | sdhci_kunmap_atomic(buffer, &flags); |
394 | } | 372 | } |
@@ -510,6 +488,7 @@ static void sdhci_adma_table_post(struct sdhci_host *host, | |||
510 | size = 4 - (sg_dma_address(sg) & 0x3); | 488 | size = 4 - (sg_dma_address(sg) & 0x3); |
511 | 489 | ||
512 | buffer = sdhci_kmap_atomic(sg, &flags); | 490 | buffer = sdhci_kmap_atomic(sg, &flags); |
491 | WARN_ON(((long)buffer & PAGE_MASK) > (PAGE_SIZE - 3)); | ||
513 | memcpy(buffer, align, size); | 492 | memcpy(buffer, align, size); |
514 | sdhci_kunmap_atomic(buffer, &flags); | 493 | sdhci_kunmap_atomic(buffer, &flags); |
515 | 494 | ||
@@ -687,7 +666,7 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data) | |||
687 | WARN_ON(1); | 666 | WARN_ON(1); |
688 | host->flags &= ~SDHCI_USE_DMA; | 667 | host->flags &= ~SDHCI_USE_DMA; |
689 | } else { | 668 | } else { |
690 | WARN_ON(count != 1); | 669 | WARN_ON(sg_cnt != 1); |
691 | writel(sg_dma_address(data->sg), | 670 | writel(sg_dma_address(data->sg), |
692 | host->ioaddr + SDHCI_DMA_ADDRESS); | 671 | host->ioaddr + SDHCI_DMA_ADDRESS); |
693 | } | 672 | } |
@@ -711,11 +690,9 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data) | |||
711 | } | 690 | } |
712 | 691 | ||
713 | if (!(host->flags & SDHCI_REQ_USE_DMA)) { | 692 | if (!(host->flags & SDHCI_REQ_USE_DMA)) { |
714 | host->cur_sg = data->sg; | 693 | sg_miter_start(&host->sg_miter, |
715 | host->num_sg = data->sg_len; | 694 | data->sg, data->sg_len, SG_MITER_ATOMIC); |
716 | 695 | host->blocks = data->blocks; | |
717 | host->offset = 0; | ||
718 | host->remain = host->cur_sg->length; | ||
719 | } | 696 | } |
720 | 697 | ||
721 | /* We do not handle DMA boundaries, so set it to max (512 KiB) */ | 698 | /* We do not handle DMA boundaries, so set it to max (512 KiB) */ |
@@ -1581,9 +1558,15 @@ int sdhci_add_host(struct sdhci_host *host) | |||
1581 | } | 1558 | } |
1582 | } | 1559 | } |
1583 | 1560 | ||
1584 | /* XXX: Hack to get MMC layer to avoid highmem */ | 1561 | /* |
1585 | if (!(host->flags & SDHCI_USE_DMA)) | 1562 | * If we use DMA, then it's up to the caller to set the DMA |
1586 | mmc_dev(host->mmc)->dma_mask = NULL; | 1563 | * mask, but PIO does not need the hw shim so we set a new |
1564 | * mask here in that case. | ||
1565 | */ | ||
1566 | if (!(host->flags & SDHCI_USE_DMA)) { | ||
1567 | host->dma_mask = DMA_BIT_MASK(64); | ||
1568 | mmc_dev(host->mmc)->dma_mask = &host->dma_mask; | ||
1569 | } | ||
1587 | 1570 | ||
1588 | host->max_clk = | 1571 | host->max_clk = |
1589 | (caps & SDHCI_CLOCK_BASE_MASK) >> SDHCI_CLOCK_BASE_SHIFT; | 1572 | (caps & SDHCI_CLOCK_BASE_MASK) >> SDHCI_CLOCK_BASE_SHIFT; |
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 5bb355281765..a06bf8b89343 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h | |||
@@ -212,6 +212,7 @@ struct sdhci_host { | |||
212 | 212 | ||
213 | /* Internal data */ | 213 | /* Internal data */ |
214 | struct mmc_host *mmc; /* MMC structure */ | 214 | struct mmc_host *mmc; /* MMC structure */ |
215 | u64 dma_mask; /* custom DMA mask */ | ||
215 | 216 | ||
216 | #ifdef CONFIG_LEDS_CLASS | 217 | #ifdef CONFIG_LEDS_CLASS |
217 | struct led_classdev led; /* LED control */ | 218 | struct led_classdev led; /* LED control */ |
@@ -238,10 +239,8 @@ struct sdhci_host { | |||
238 | struct mmc_data *data; /* Current data request */ | 239 | struct mmc_data *data; /* Current data request */ |
239 | unsigned int data_early:1; /* Data finished before cmd */ | 240 | unsigned int data_early:1; /* Data finished before cmd */ |
240 | 241 | ||
241 | struct scatterlist *cur_sg; /* We're working on this */ | 242 | struct sg_mapping_iter sg_miter; /* SG state for PIO */ |
242 | int num_sg; /* Entries left */ | 243 | unsigned int blocks; /* remaining PIO blocks */ |
243 | int offset; /* Offset into current sg */ | ||
244 | int remain; /* Bytes left in current */ | ||
245 | 244 | ||
246 | int sg_count; /* Mapped sg entries */ | 245 | int sg_count; /* Mapped sg entries */ |
247 | 246 | ||