Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 332688
b: refs/heads/master
c: 28446ac
h: refs/heads/master
v: v3
  • Loading branch information
Jean-Christophe PLAGNIOL-VILLARD authored and David Woodhouse committed Sep 29, 2012
1 parent 368ace9 commit d5a78c0
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: aa6d01fa435a6f701128829f8d9d04208fd53176
refs/heads/master: 28446acb1f8268cda4b2076f72519534f84d6a36
65 changes: 63 additions & 2 deletions trunk/drivers/mtd/nand/atmel_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev)
if (pdev->dev.of_node) {
res = atmel_of_init_port(host, pdev->dev.of_node);
if (res)
goto err_nand_ioremap;
goto err_ecc_ioremap;
} else {
memcpy(&host->board, pdev->dev.platform_data,
sizeof(struct atmel_nand_data));
Expand All @@ -1414,8 +1414,43 @@ static int __init atmel_nand_probe(struct platform_device *pdev)
nand_chip->IO_ADDR_W = host->io_base;
nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl;

if (gpio_is_valid(host->board.rdy_pin))
if (gpio_is_valid(host->board.rdy_pin)) {
res = gpio_request(host->board.rdy_pin, "nand_rdy");
if (res < 0) {
dev_err(&pdev->dev,
"can't request rdy gpio %d\n",
host->board.rdy_pin);
goto err_ecc_ioremap;
}

res = gpio_direction_input(host->board.rdy_pin);
if (res < 0) {
dev_err(&pdev->dev,
"can't request input direction rdy gpio %d\n",
host->board.rdy_pin);
goto err_ecc_ioremap;
}

nand_chip->dev_ready = atmel_nand_device_ready;
}

if (gpio_is_valid(host->board.enable_pin)) {
res = gpio_request(host->board.enable_pin, "nand_enable");
if (res < 0) {
dev_err(&pdev->dev,
"can't request enable gpio %d\n",
host->board.enable_pin);
goto err_ecc_ioremap;
}

res = gpio_direction_output(host->board.enable_pin, 1);
if (res < 0) {
dev_err(&pdev->dev,
"can't request output direction enable gpio %d\n",
host->board.enable_pin);
goto err_ecc_ioremap;
}
}

nand_chip->ecc.mode = host->board.ecc_mode;
nand_chip->chip_delay = 20; /* 20us command delay time */
Expand All @@ -1430,6 +1465,22 @@ static int __init atmel_nand_probe(struct platform_device *pdev)
atmel_nand_enable(host);

if (gpio_is_valid(host->board.det_pin)) {
res = gpio_request(host->board.det_pin, "nand_det");
if (res < 0) {
dev_err(&pdev->dev,
"can't request det gpio %d\n",
host->board.det_pin);
goto err_no_card;
}

res = gpio_direction_input(host->board.det_pin);
if (res < 0) {
dev_err(&pdev->dev,
"can't request input direction det gpio %d\n",
host->board.det_pin);
goto err_no_card;
}

if (gpio_get_value(host->board.det_pin)) {
printk(KERN_INFO "No SmartMedia card inserted.\n");
res = -ENXIO;
Expand Down Expand Up @@ -1509,6 +1560,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, NULL);
if (host->dma_chan)
dma_release_channel(host->dma_chan);
err_ecc_ioremap:
iounmap(host->io_base);
err_nand_ioremap:
kfree(host);
Expand All @@ -1534,6 +1586,15 @@ static int __exit atmel_nand_remove(struct platform_device *pdev)
pmecc_data_free(host);
}

if (gpio_is_valid(host->board.det_pin))
gpio_free(host->board.det_pin);

if (gpio_is_valid(host->board.enable_pin))
gpio_free(host->board.enable_pin);

if (gpio_is_valid(host->board.rdy_pin))
gpio_free(host->board.rdy_pin);

if (host->ecc)
iounmap(host->ecc);
if (host->pmecc_rom_base)
Expand Down

0 comments on commit d5a78c0

Please sign in to comment.