]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mtd: nand: gpio: make nCE GPIO optional
authorChristophe Leroy <christophe.leroy@c-s.fr>
Fri, 10 Feb 2017 14:01:10 +0000 (15:01 +0100)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Thu, 16 Mar 2017 09:34:27 +0000 (10:34 +0100)
On some hardware, the nCE signal is wired to the ChipSelect associated
to bus address of the NAND, so it is automatically driven during the
memory access and it is not managed by a GPIO.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
drivers/mtd/nand/gpio.c

index 0d24857469ab396ac10c165076fd380639aa4463..85294f150f4ff36effe127722003f6e69340bbba 100644 (file)
@@ -78,7 +78,9 @@ static void gpio_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
        gpio_nand_dosync(gpiomtd);
 
        if (ctrl & NAND_CTRL_CHANGE) {
-               gpio_set_value(gpiomtd->plat.gpio_nce, !(ctrl & NAND_NCE));
+               if (gpio_is_valid(gpiomtd->plat.gpio_nce))
+                       gpio_set_value(gpiomtd->plat.gpio_nce,
+                                      !(ctrl & NAND_NCE));
                gpio_set_value(gpiomtd->plat.gpio_cle, !!(ctrl & NAND_CLE));
                gpio_set_value(gpiomtd->plat.gpio_ale, !!(ctrl & NAND_ALE));
                gpio_nand_dosync(gpiomtd);
@@ -201,7 +203,8 @@ static int gpio_nand_remove(struct platform_device *pdev)
 
        if (gpio_is_valid(gpiomtd->plat.gpio_nwp))
                gpio_set_value(gpiomtd->plat.gpio_nwp, 0);
-       gpio_set_value(gpiomtd->plat.gpio_nce, 1);
+       if (gpio_is_valid(gpiomtd->plat.gpio_nce))
+               gpio_set_value(gpiomtd->plat.gpio_nce, 1);
 
        return 0;
 }
@@ -239,10 +242,13 @@ static int gpio_nand_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       ret = devm_gpio_request(&pdev->dev, gpiomtd->plat.gpio_nce, "NAND NCE");
-       if (ret)
-               return ret;
-       gpio_direction_output(gpiomtd->plat.gpio_nce, 1);
+       if (gpio_is_valid(gpiomtd->plat.gpio_nce)) {
+               ret = devm_gpio_request(&pdev->dev, gpiomtd->plat.gpio_nce,
+                                       "NAND NCE");
+               if (ret)
+                       return ret;
+               gpio_direction_output(gpiomtd->plat.gpio_nce, 1);
+       }
 
        if (gpio_is_valid(gpiomtd->plat.gpio_nwp)) {
                ret = devm_gpio_request(&pdev->dev, gpiomtd->plat.gpio_nwp,