]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mtd: atmel nand: fix gpio missing request
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Thu, 12 Jul 2012 08:31:08 +0000 (10:31 +0200)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Fri, 24 Aug 2012 08:03:37 +0000 (11:03 +0300)
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>
drivers/mtd/nand/atmel_nand.c

index 647275524e09fb6b48740e313ce133d11479ad1c..6a5a35b1160ef0c927aa1b6319e111454fe913c5 100644 (file)
@@ -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 */
@@ -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;
@@ -1534,6 +1585,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)