diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2012-07-12 04:31:08 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-09-29 09:53:58 -0400 |
commit | 28446acb1f8268cda4b2076f72519534f84d6a36 (patch) | |
tree | eee159031ce3b1ffdbf190f152ad4014986274c8 | |
parent | aa6d01fa435a6f701128829f8d9d04208fd53176 (diff) |
mtd: atmel nand: fix gpio missing request
without this the gpio will not be muxed as a gpio by the current custom pinmux
or later by the pinctrl
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r-- | drivers/mtd/nand/atmel_nand.c | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index 647275524e09..914455783302 100644 --- a/drivers/mtd/nand/atmel_nand.c +++ b/drivers/mtd/nand/atmel_nand.c | |||
@@ -1399,7 +1399,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev) | |||
1399 | if (pdev->dev.of_node) { | 1399 | if (pdev->dev.of_node) { |
1400 | res = atmel_of_init_port(host, pdev->dev.of_node); | 1400 | res = atmel_of_init_port(host, pdev->dev.of_node); |
1401 | if (res) | 1401 | if (res) |
1402 | goto err_nand_ioremap; | 1402 | goto err_ecc_ioremap; |
1403 | } else { | 1403 | } else { |
1404 | memcpy(&host->board, pdev->dev.platform_data, | 1404 | memcpy(&host->board, pdev->dev.platform_data, |
1405 | sizeof(struct atmel_nand_data)); | 1405 | sizeof(struct atmel_nand_data)); |
@@ -1414,8 +1414,43 @@ static int __init atmel_nand_probe(struct platform_device *pdev) | |||
1414 | nand_chip->IO_ADDR_W = host->io_base; | 1414 | nand_chip->IO_ADDR_W = host->io_base; |
1415 | nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl; | 1415 | nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl; |
1416 | 1416 | ||
1417 | if (gpio_is_valid(host->board.rdy_pin)) | 1417 | if (gpio_is_valid(host->board.rdy_pin)) { |
1418 | res = gpio_request(host->board.rdy_pin, "nand_rdy"); | ||
1419 | if (res < 0) { | ||
1420 | dev_err(&pdev->dev, | ||
1421 | "can't request rdy gpio %d\n", | ||
1422 | host->board.rdy_pin); | ||
1423 | goto err_ecc_ioremap; | ||
1424 | } | ||
1425 | |||
1426 | res = gpio_direction_input(host->board.rdy_pin); | ||
1427 | if (res < 0) { | ||
1428 | dev_err(&pdev->dev, | ||
1429 | "can't request input direction rdy gpio %d\n", | ||
1430 | host->board.rdy_pin); | ||
1431 | goto err_ecc_ioremap; | ||
1432 | } | ||
1433 | |||
1418 | nand_chip->dev_ready = atmel_nand_device_ready; | 1434 | nand_chip->dev_ready = atmel_nand_device_ready; |
1435 | } | ||
1436 | |||
1437 | if (gpio_is_valid(host->board.enable_pin)) { | ||
1438 | res = gpio_request(host->board.enable_pin, "nand_enable"); | ||
1439 | if (res < 0) { | ||
1440 | dev_err(&pdev->dev, | ||
1441 | "can't request enable gpio %d\n", | ||
1442 | host->board.enable_pin); | ||
1443 | goto err_ecc_ioremap; | ||
1444 | } | ||
1445 | |||
1446 | res = gpio_direction_output(host->board.enable_pin, 1); | ||
1447 | if (res < 0) { | ||
1448 | dev_err(&pdev->dev, | ||
1449 | "can't request output direction enable gpio %d\n", | ||
1450 | host->board.enable_pin); | ||
1451 | goto err_ecc_ioremap; | ||
1452 | } | ||
1453 | } | ||
1419 | 1454 | ||
1420 | nand_chip->ecc.mode = host->board.ecc_mode; | 1455 | nand_chip->ecc.mode = host->board.ecc_mode; |
1421 | nand_chip->chip_delay = 20; /* 20us command delay time */ | 1456 | nand_chip->chip_delay = 20; /* 20us command delay time */ |
@@ -1430,6 +1465,22 @@ static int __init atmel_nand_probe(struct platform_device *pdev) | |||
1430 | atmel_nand_enable(host); | 1465 | atmel_nand_enable(host); |
1431 | 1466 | ||
1432 | if (gpio_is_valid(host->board.det_pin)) { | 1467 | if (gpio_is_valid(host->board.det_pin)) { |
1468 | res = gpio_request(host->board.det_pin, "nand_det"); | ||
1469 | if (res < 0) { | ||
1470 | dev_err(&pdev->dev, | ||
1471 | "can't request det gpio %d\n", | ||
1472 | host->board.det_pin); | ||
1473 | goto err_no_card; | ||
1474 | } | ||
1475 | |||
1476 | res = gpio_direction_input(host->board.det_pin); | ||
1477 | if (res < 0) { | ||
1478 | dev_err(&pdev->dev, | ||
1479 | "can't request input direction det gpio %d\n", | ||
1480 | host->board.det_pin); | ||
1481 | goto err_no_card; | ||
1482 | } | ||
1483 | |||
1433 | if (gpio_get_value(host->board.det_pin)) { | 1484 | if (gpio_get_value(host->board.det_pin)) { |
1434 | printk(KERN_INFO "No SmartMedia card inserted.\n"); | 1485 | printk(KERN_INFO "No SmartMedia card inserted.\n"); |
1435 | res = -ENXIO; | 1486 | res = -ENXIO; |
@@ -1509,6 +1560,7 @@ err_no_card: | |||
1509 | platform_set_drvdata(pdev, NULL); | 1560 | platform_set_drvdata(pdev, NULL); |
1510 | if (host->dma_chan) | 1561 | if (host->dma_chan) |
1511 | dma_release_channel(host->dma_chan); | 1562 | dma_release_channel(host->dma_chan); |
1563 | err_ecc_ioremap: | ||
1512 | iounmap(host->io_base); | 1564 | iounmap(host->io_base); |
1513 | err_nand_ioremap: | 1565 | err_nand_ioremap: |
1514 | kfree(host); | 1566 | kfree(host); |
@@ -1534,6 +1586,15 @@ static int __exit atmel_nand_remove(struct platform_device *pdev) | |||
1534 | pmecc_data_free(host); | 1586 | pmecc_data_free(host); |
1535 | } | 1587 | } |
1536 | 1588 | ||
1589 | if (gpio_is_valid(host->board.det_pin)) | ||
1590 | gpio_free(host->board.det_pin); | ||
1591 | |||
1592 | if (gpio_is_valid(host->board.enable_pin)) | ||
1593 | gpio_free(host->board.enable_pin); | ||
1594 | |||
1595 | if (gpio_is_valid(host->board.rdy_pin)) | ||
1596 | gpio_free(host->board.rdy_pin); | ||
1597 | |||
1537 | if (host->ecc) | 1598 | if (host->ecc) |
1538 | iounmap(host->ecc); | 1599 | iounmap(host->ecc); |
1539 | if (host->pmecc_rom_base) | 1600 | if (host->pmecc_rom_base) |