Skip to content

Commit 44dd182

Browse files
chleroyBoris Brezillon
authored andcommitted
mtd: nand: gpio: make nCE GPIO optional
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 <[email protected]> Reviewed-by: Marek Vasut <[email protected]> Signed-off-by: Boris Brezillon <[email protected]>
1 parent 01eb9ae commit 44dd182

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

drivers/mtd/nand/gpio.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ static void gpio_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
7878
gpio_nand_dosync(gpiomtd);
7979

8080
if (ctrl & NAND_CTRL_CHANGE) {
81-
gpio_set_value(gpiomtd->plat.gpio_nce, !(ctrl & NAND_NCE));
81+
if (gpio_is_valid(gpiomtd->plat.gpio_nce))
82+
gpio_set_value(gpiomtd->plat.gpio_nce,
83+
!(ctrl & NAND_NCE));
8284
gpio_set_value(gpiomtd->plat.gpio_cle, !!(ctrl & NAND_CLE));
8385
gpio_set_value(gpiomtd->plat.gpio_ale, !!(ctrl & NAND_ALE));
8486
gpio_nand_dosync(gpiomtd);
@@ -201,7 +203,8 @@ static int gpio_nand_remove(struct platform_device *pdev)
201203

202204
if (gpio_is_valid(gpiomtd->plat.gpio_nwp))
203205
gpio_set_value(gpiomtd->plat.gpio_nwp, 0);
204-
gpio_set_value(gpiomtd->plat.gpio_nce, 1);
206+
if (gpio_is_valid(gpiomtd->plat.gpio_nce))
207+
gpio_set_value(gpiomtd->plat.gpio_nce, 1);
205208

206209
return 0;
207210
}
@@ -239,10 +242,13 @@ static int gpio_nand_probe(struct platform_device *pdev)
239242
if (ret)
240243
return ret;
241244

242-
ret = devm_gpio_request(&pdev->dev, gpiomtd->plat.gpio_nce, "NAND NCE");
243-
if (ret)
244-
return ret;
245-
gpio_direction_output(gpiomtd->plat.gpio_nce, 1);
245+
if (gpio_is_valid(gpiomtd->plat.gpio_nce)) {
246+
ret = devm_gpio_request(&pdev->dev, gpiomtd->plat.gpio_nce,
247+
"NAND NCE");
248+
if (ret)
249+
return ret;
250+
gpio_direction_output(gpiomtd->plat.gpio_nce, 1);
251+
}
246252

247253
if (gpio_is_valid(gpiomtd->plat.gpio_nwp)) {
248254
ret = devm_gpio_request(&pdev->dev, gpiomtd->plat.gpio_nwp,

0 commit comments

Comments
 (0)