diff options
author | Ben Dooks <ben@simtec.co.uk> | 2009-10-01 18:44:15 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-10-01 19:11:14 -0400 |
commit | 916a30775fc843e6f82e09c748a4fc70bfd4298e (patch) | |
tree | ded1785543e13596fea087a6bfb3e7e86889875c /drivers/mmc/host | |
parent | 44d0e19968b3b2703aa4ee1f9a5b684425b40448 (diff) |
s3cmci: change GPIO to gpiolib from S3C24XX specific calls
Move to using gpiolib to access the card detect and write protect GPIO
lines instead of using the platform speicifc s3c2410_gpio calls.
Also ensure that the card lines are claimed the same way to avoid overlap
with any other drivers.
Signed-off-by: Ben Dooks <ben@simtec.co.uk>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/mmc/host')
-rw-r--r-- | drivers/mmc/host/s3cmci.c | 87 |
1 files changed, 69 insertions, 18 deletions
diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c index 20ed46cef13b..63d211bfc464 100644 --- a/drivers/mmc/host/s3cmci.c +++ b/drivers/mmc/host/s3cmci.c | |||
@@ -1047,7 +1047,7 @@ static int s3cmci_card_present(struct mmc_host *mmc) | |||
1047 | if (pdata->gpio_detect == 0) | 1047 | if (pdata->gpio_detect == 0) |
1048 | return -ENOSYS; | 1048 | return -ENOSYS; |
1049 | 1049 | ||
1050 | ret = s3c2410_gpio_getpin(pdata->gpio_detect) ? 0 : 1; | 1050 | ret = gpio_get_value(pdata->gpio_detect) ? 0 : 1; |
1051 | return ret ^ pdata->detect_invert; | 1051 | return ret ^ pdata->detect_invert; |
1052 | } | 1052 | } |
1053 | 1053 | ||
@@ -1102,12 +1102,12 @@ static void s3cmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
1102 | switch (ios->power_mode) { | 1102 | switch (ios->power_mode) { |
1103 | case MMC_POWER_ON: | 1103 | case MMC_POWER_ON: |
1104 | case MMC_POWER_UP: | 1104 | case MMC_POWER_UP: |
1105 | s3c2410_gpio_cfgpin(S3C2410_GPE5, S3C2410_GPE5_SDCLK); | 1105 | s3c2410_gpio_cfgpin(S3C2410_GPE(5), S3C2410_GPE5_SDCLK); |
1106 | s3c2410_gpio_cfgpin(S3C2410_GPE6, S3C2410_GPE6_SDCMD); | 1106 | s3c2410_gpio_cfgpin(S3C2410_GPE(6), S3C2410_GPE6_SDCMD); |
1107 | s3c2410_gpio_cfgpin(S3C2410_GPE7, S3C2410_GPE7_SDDAT0); | 1107 | s3c2410_gpio_cfgpin(S3C2410_GPE(7), S3C2410_GPE7_SDDAT0); |
1108 | s3c2410_gpio_cfgpin(S3C2410_GPE8, S3C2410_GPE8_SDDAT1); | 1108 | s3c2410_gpio_cfgpin(S3C2410_GPE(8), S3C2410_GPE8_SDDAT1); |
1109 | s3c2410_gpio_cfgpin(S3C2410_GPE9, S3C2410_GPE9_SDDAT2); | 1109 | s3c2410_gpio_cfgpin(S3C2410_GPE(9), S3C2410_GPE9_SDDAT2); |
1110 | s3c2410_gpio_cfgpin(S3C2410_GPE10, S3C2410_GPE10_SDDAT3); | 1110 | s3c2410_gpio_cfgpin(S3C2410_GPE(10), S3C2410_GPE10_SDDAT3); |
1111 | 1111 | ||
1112 | if (host->pdata->set_power) | 1112 | if (host->pdata->set_power) |
1113 | host->pdata->set_power(ios->power_mode, ios->vdd); | 1113 | host->pdata->set_power(ios->power_mode, ios->vdd); |
@@ -1119,8 +1119,7 @@ static void s3cmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
1119 | 1119 | ||
1120 | case MMC_POWER_OFF: | 1120 | case MMC_POWER_OFF: |
1121 | default: | 1121 | default: |
1122 | s3c2410_gpio_setpin(S3C2410_GPE5, 0); | 1122 | gpio_direction_output(S3C2410_GPE(5), 0); |
1123 | s3c2410_gpio_cfgpin(S3C2410_GPE5, S3C2410_GPIO_OUTPUT); | ||
1124 | 1123 | ||
1125 | if (host->is2440) | 1124 | if (host->is2440) |
1126 | mci_con |= S3C2440_SDICON_SDRESET; | 1125 | mci_con |= S3C2440_SDICON_SDRESET; |
@@ -1244,12 +1243,14 @@ static inline void s3cmci_cpufreq_deregister(struct s3cmci_host *host) | |||
1244 | } | 1243 | } |
1245 | #endif | 1244 | #endif |
1246 | 1245 | ||
1246 | |||
1247 | static int __devinit s3cmci_probe(struct platform_device *pdev) | 1247 | static int __devinit s3cmci_probe(struct platform_device *pdev) |
1248 | { | 1248 | { |
1249 | struct s3cmci_host *host; | 1249 | struct s3cmci_host *host; |
1250 | struct mmc_host *mmc; | 1250 | struct mmc_host *mmc; |
1251 | int ret; | 1251 | int ret; |
1252 | int is2440; | 1252 | int is2440; |
1253 | int i; | ||
1253 | 1254 | ||
1254 | is2440 = platform_get_device_id(pdev)->driver_data; | 1255 | is2440 = platform_get_device_id(pdev)->driver_data; |
1255 | 1256 | ||
@@ -1259,6 +1260,18 @@ static int __devinit s3cmci_probe(struct platform_device *pdev) | |||
1259 | goto probe_out; | 1260 | goto probe_out; |
1260 | } | 1261 | } |
1261 | 1262 | ||
1263 | for (i = S3C2410_GPE(5); i <= S3C2410_GPE(10); i++) { | ||
1264 | ret = gpio_request(i, dev_name(&pdev->dev)); | ||
1265 | if (ret) { | ||
1266 | dev_err(&pdev->dev, "failed to get gpio %d\n", i); | ||
1267 | |||
1268 | for (i--; i >= S3C2410_GPE(5); i--) | ||
1269 | gpio_free(i); | ||
1270 | |||
1271 | goto probe_free_host; | ||
1272 | } | ||
1273 | } | ||
1274 | |||
1262 | host = mmc_priv(mmc); | 1275 | host = mmc_priv(mmc); |
1263 | host->mmc = mmc; | 1276 | host->mmc = mmc; |
1264 | host->pdev = pdev; | 1277 | host->pdev = pdev; |
@@ -1295,7 +1308,7 @@ static int __devinit s3cmci_probe(struct platform_device *pdev) | |||
1295 | "failed to get io memory region resouce.\n"); | 1308 | "failed to get io memory region resouce.\n"); |
1296 | 1309 | ||
1297 | ret = -ENOENT; | 1310 | ret = -ENOENT; |
1298 | goto probe_free_host; | 1311 | goto probe_free_gpio; |
1299 | } | 1312 | } |
1300 | 1313 | ||
1301 | host->mem = request_mem_region(host->mem->start, | 1314 | host->mem = request_mem_region(host->mem->start, |
@@ -1304,7 +1317,7 @@ static int __devinit s3cmci_probe(struct platform_device *pdev) | |||
1304 | if (!host->mem) { | 1317 | if (!host->mem) { |
1305 | dev_err(&pdev->dev, "failed to request io memory region.\n"); | 1318 | dev_err(&pdev->dev, "failed to request io memory region.\n"); |
1306 | ret = -ENOENT; | 1319 | ret = -ENOENT; |
1307 | goto probe_free_host; | 1320 | goto probe_free_gpio; |
1308 | } | 1321 | } |
1309 | 1322 | ||
1310 | host->base = ioremap(host->mem->start, resource_size(host->mem)); | 1323 | host->base = ioremap(host->mem->start, resource_size(host->mem)); |
@@ -1333,6 +1346,14 @@ static int __devinit s3cmci_probe(struct platform_device *pdev) | |||
1333 | 1346 | ||
1334 | disable_irq(host->irq); | 1347 | disable_irq(host->irq); |
1335 | 1348 | ||
1349 | if (host->pdata->gpio_detect) { | ||
1350 | ret = gpio_request(host->pdata->gpio_detect, "s3cmci detect"); | ||
1351 | if (ret) { | ||
1352 | dev_err(&pdev->dev, "failed to get detect gpio\n"); | ||
1353 | goto probe_free_irq; | ||
1354 | } | ||
1355 | } | ||
1356 | |||
1336 | host->irq_cd = s3c2410_gpio_getirq(host->pdata->gpio_detect); | 1357 | host->irq_cd = s3c2410_gpio_getirq(host->pdata->gpio_detect); |
1337 | 1358 | ||
1338 | if (host->irq_cd >= 0) { | 1359 | if (host->irq_cd >= 0) { |
@@ -1341,22 +1362,27 @@ static int __devinit s3cmci_probe(struct platform_device *pdev) | |||
1341 | DRIVER_NAME, host)) { | 1362 | DRIVER_NAME, host)) { |
1342 | dev_err(&pdev->dev, "can't get card detect irq.\n"); | 1363 | dev_err(&pdev->dev, "can't get card detect irq.\n"); |
1343 | ret = -ENOENT; | 1364 | ret = -ENOENT; |
1344 | goto probe_free_irq; | 1365 | goto probe_free_gpio_cd; |
1345 | } | 1366 | } |
1346 | } else { | 1367 | } else { |
1347 | dev_warn(&pdev->dev, "host detect has no irq available\n"); | 1368 | dev_warn(&pdev->dev, "host detect has no irq available\n"); |
1348 | s3c2410_gpio_cfgpin(host->pdata->gpio_detect, | 1369 | gpio_direction_input(host->pdata->gpio_detect); |
1349 | S3C2410_GPIO_INPUT); | ||
1350 | } | 1370 | } |
1351 | 1371 | ||
1352 | if (host->pdata->gpio_wprotect) | 1372 | if (host->pdata->gpio_wprotect) { |
1353 | s3c2410_gpio_cfgpin(host->pdata->gpio_wprotect, | 1373 | ret = gpio_request(host->pdata->gpio_wprotect, "s3cmci wp"); |
1354 | S3C2410_GPIO_INPUT); | 1374 | if (ret) { |
1375 | dev_err(&pdev->dev, "failed to get writeprotect\n"); | ||
1376 | goto probe_free_irq_cd; | ||
1377 | } | ||
1378 | |||
1379 | gpio_direction_input(host->pdata->gpio_wprotect); | ||
1380 | } | ||
1355 | 1381 | ||
1356 | if (s3c2410_dma_request(S3CMCI_DMA, &s3cmci_dma_client, NULL) < 0) { | 1382 | if (s3c2410_dma_request(S3CMCI_DMA, &s3cmci_dma_client, NULL) < 0) { |
1357 | dev_err(&pdev->dev, "unable to get DMA channel.\n"); | 1383 | dev_err(&pdev->dev, "unable to get DMA channel.\n"); |
1358 | ret = -EBUSY; | 1384 | ret = -EBUSY; |
1359 | goto probe_free_irq_cd; | 1385 | goto probe_free_gpio_wp; |
1360 | } | 1386 | } |
1361 | 1387 | ||
1362 | host->clk = clk_get(&pdev->dev, "sdi"); | 1388 | host->clk = clk_get(&pdev->dev, "sdi"); |
@@ -1423,6 +1449,14 @@ static int __devinit s3cmci_probe(struct platform_device *pdev) | |||
1423 | clk_free: | 1449 | clk_free: |
1424 | clk_put(host->clk); | 1450 | clk_put(host->clk); |
1425 | 1451 | ||
1452 | probe_free_gpio_wp: | ||
1453 | if (host->pdata->gpio_wprotect) | ||
1454 | gpio_free(host->pdata->gpio_wprotect); | ||
1455 | |||
1456 | probe_free_gpio_cd: | ||
1457 | if (host->pdata->gpio_detect) | ||
1458 | gpio_free(host->pdata->gpio_detect); | ||
1459 | |||
1426 | probe_free_irq_cd: | 1460 | probe_free_irq_cd: |
1427 | if (host->irq_cd >= 0) | 1461 | if (host->irq_cd >= 0) |
1428 | free_irq(host->irq_cd, host); | 1462 | free_irq(host->irq_cd, host); |
@@ -1436,8 +1470,13 @@ static int __devinit s3cmci_probe(struct platform_device *pdev) | |||
1436 | probe_free_mem_region: | 1470 | probe_free_mem_region: |
1437 | release_mem_region(host->mem->start, resource_size(host->mem)); | 1471 | release_mem_region(host->mem->start, resource_size(host->mem)); |
1438 | 1472 | ||
1473 | probe_free_gpio: | ||
1474 | for (i = S3C2410_GPE(5); i <= S3C2410_GPE(10); i++) | ||
1475 | gpio_free(i); | ||
1476 | |||
1439 | probe_free_host: | 1477 | probe_free_host: |
1440 | mmc_free_host(mmc); | 1478 | mmc_free_host(mmc); |
1479 | |||
1441 | probe_out: | 1480 | probe_out: |
1442 | return ret; | 1481 | return ret; |
1443 | } | 1482 | } |
@@ -1459,6 +1498,8 @@ static int __devexit s3cmci_remove(struct platform_device *pdev) | |||
1459 | { | 1498 | { |
1460 | struct mmc_host *mmc = platform_get_drvdata(pdev); | 1499 | struct mmc_host *mmc = platform_get_drvdata(pdev); |
1461 | struct s3cmci_host *host = mmc_priv(mmc); | 1500 | struct s3cmci_host *host = mmc_priv(mmc); |
1501 | struct s3c24xx_mci_pdata *pd = host->pdata; | ||
1502 | int i; | ||
1462 | 1503 | ||
1463 | s3cmci_shutdown(pdev); | 1504 | s3cmci_shutdown(pdev); |
1464 | 1505 | ||
@@ -1469,6 +1510,16 @@ static int __devexit s3cmci_remove(struct platform_device *pdev) | |||
1469 | 1510 | ||
1470 | free_irq(host->irq, host); | 1511 | free_irq(host->irq, host); |
1471 | 1512 | ||
1513 | if (pd->gpio_wprotect) | ||
1514 | gpio_free(pd->gpio_wprotect); | ||
1515 | |||
1516 | if (pd->gpio_detect) | ||
1517 | gpio_free(pd->gpio_detect); | ||
1518 | |||
1519 | for (i = S3C2410_GPE(5); i <= S3C2410_GPE(10); i++) | ||
1520 | gpio_free(i); | ||
1521 | |||
1522 | |||
1472 | iounmap(host->base); | 1523 | iounmap(host->base); |
1473 | release_mem_region(host->mem->start, resource_size(host->mem)); | 1524 | release_mem_region(host->mem->start, resource_size(host->mem)); |
1474 | 1525 | ||