9
0
Fork 0

mtd: atmel_nand: request and configure pio via gpiolib

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Jean-Christophe PLAGNIOL-VILLARD 2012-12-28 17:46:29 +01:00 committed by Sascha Hauer
parent 4d97a1fc9c
commit 6fefe24a36
1 changed files with 51 additions and 2 deletions

View File

@ -1114,8 +1114,42 @@ static int __init atmel_nand_probe(struct device_d *dev)
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(dev, "can't request rdy gpio %d\n",
host->board->rdy_pin);
goto err_no_card;
}
res = gpio_direction_input(host->board->rdy_pin);
if (res < 0) {
dev_err(dev,
"can't request input direction rdy gpio %d\n",
host->board->rdy_pin);
goto err_no_card;
}
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(dev,
"can't request enable gpio %d\n",
host->board->enable_pin);
goto err_no_card;
}
res = gpio_direction_output(host->board->enable_pin, 1);
if (res < 0) {
dev_err(dev,
"can't request output direction enable gpio %d\n",
host->board->enable_pin);
goto err_no_card;
}
}
nand_chip->ecc.mode = NAND_ECC_SOFT;
@ -1138,9 +1172,24 @@ static int __init atmel_nand_probe(struct device_d *dev)
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(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(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("No SmartMedia card inserted.\n");
res = ENXIO;
res = -ENXIO;
goto err_no_card;
}
}