aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-12-02 14:48:26 -0500
committerBrian Norris <computersforpeace@gmail.com>2015-02-02 04:04:36 -0500
commitcd145af998886bf3c596cb7b6ddc55a287b76e76 (patch)
tree3e57b712a24029518b2e276f01d7402d30020326 /drivers/mtd/nand
parente0377cdebaf3913bff693c9eea17ff6eb4d7abc8 (diff)
mtd: nand: jz4740: Convert to GPIO descriptor API
Use the GPIO descriptor API instead of the deprecated legacy GPIO API to manage the busy GPIO. The patch updates both the jz4740 nand driver and the only user of the driver the qi-lb60 board driver. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/jz4740_nand.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/drivers/mtd/nand/jz4740_nand.c b/drivers/mtd/nand/jz4740_nand.c
index 1633ec9c5108..ebf2cce04cba 100644
--- a/drivers/mtd/nand/jz4740_nand.c
+++ b/drivers/mtd/nand/jz4740_nand.c
@@ -69,7 +69,7 @@ struct jz_nand {
69 69
70 int selected_bank; 70 int selected_bank;
71 71
72 struct jz_nand_platform_data *pdata; 72 struct gpio_desc *busy_gpio;
73 bool is_reading; 73 bool is_reading;
74}; 74};
75 75
@@ -131,7 +131,7 @@ static void jz_nand_cmd_ctrl(struct mtd_info *mtd, int dat, unsigned int ctrl)
131static int jz_nand_dev_ready(struct mtd_info *mtd) 131static int jz_nand_dev_ready(struct mtd_info *mtd)
132{ 132{
133 struct jz_nand *nand = mtd_to_jz_nand(mtd); 133 struct jz_nand *nand = mtd_to_jz_nand(mtd);
134 return gpio_get_value_cansleep(nand->pdata->busy_gpio); 134 return gpiod_get_value_cansleep(nand->busy_gpio);
135} 135}
136 136
137static void jz_nand_hwctl(struct mtd_info *mtd, int mode) 137static void jz_nand_hwctl(struct mtd_info *mtd, int mode)
@@ -423,14 +423,12 @@ static int jz_nand_probe(struct platform_device *pdev)
423 if (ret) 423 if (ret)
424 goto err_free; 424 goto err_free;
425 425
426 if (pdata && gpio_is_valid(pdata->busy_gpio)) { 426 nand->busy_gpio = devm_gpiod_get_optional(&pdev->dev, "busy", GPIOD_IN);
427 ret = gpio_request(pdata->busy_gpio, "NAND busy pin"); 427 if (IS_ERR(nand->busy_gpio)) {
428 if (ret) { 428 ret = PTR_ERR(nand->busy_gpio);
429 dev_err(&pdev->dev, 429 dev_err(&pdev->dev, "Failed to request busy gpio %d\n",
430 "Failed to request busy gpio %d: %d\n", 430 ret);
431 pdata->busy_gpio, ret); 431 goto err_iounmap_mmio;
432 goto err_iounmap_mmio;
433 }
434 } 432 }
435 433
436 mtd = &nand->mtd; 434 mtd = &nand->mtd;
@@ -454,10 +452,9 @@ static int jz_nand_probe(struct platform_device *pdev)
454 chip->cmd_ctrl = jz_nand_cmd_ctrl; 452 chip->cmd_ctrl = jz_nand_cmd_ctrl;
455 chip->select_chip = jz_nand_select_chip; 453 chip->select_chip = jz_nand_select_chip;
456 454
457 if (pdata && gpio_is_valid(pdata->busy_gpio)) 455 if (nand->busy_gpio)
458 chip->dev_ready = jz_nand_dev_ready; 456 chip->dev_ready = jz_nand_dev_ready;
459 457
460 nand->pdata = pdata;
461 platform_set_drvdata(pdev, nand); 458 platform_set_drvdata(pdev, nand);
462 459
463 /* We are going to autodetect NAND chips in the banks specified in the 460 /* We are going to autodetect NAND chips in the banks specified in the
@@ -496,7 +493,7 @@ static int jz_nand_probe(struct platform_device *pdev)
496 } 493 }
497 if (chipnr == 0) { 494 if (chipnr == 0) {
498 dev_err(&pdev->dev, "No NAND chips found\n"); 495 dev_err(&pdev->dev, "No NAND chips found\n");
499 goto err_gpio_busy; 496 goto err_iounmap_mmio;
500 } 497 }
501 498
502 if (pdata && pdata->ident_callback) { 499 if (pdata && pdata->ident_callback) {
@@ -533,9 +530,6 @@ err_unclaim_banks:
533 nand->bank_base[bank - 1]); 530 nand->bank_base[bank - 1]);
534 } 531 }
535 writel(0, nand->base + JZ_REG_NAND_CTRL); 532 writel(0, nand->base + JZ_REG_NAND_CTRL);
536err_gpio_busy:
537 if (pdata && gpio_is_valid(pdata->busy_gpio))
538 gpio_free(pdata->busy_gpio);
539err_iounmap_mmio: 533err_iounmap_mmio:
540 jz_nand_iounmap_resource(nand->mem, nand->base); 534 jz_nand_iounmap_resource(nand->mem, nand->base);
541err_free: 535err_free:
@@ -546,7 +540,6 @@ err_free:
546static int jz_nand_remove(struct platform_device *pdev) 540static int jz_nand_remove(struct platform_device *pdev)
547{ 541{
548 struct jz_nand *nand = platform_get_drvdata(pdev); 542 struct jz_nand *nand = platform_get_drvdata(pdev);
549 struct jz_nand_platform_data *pdata = dev_get_platdata(&pdev->dev);
550 size_t i; 543 size_t i;
551 544
552 nand_release(&nand->mtd); 545 nand_release(&nand->mtd);
@@ -562,8 +555,6 @@ static int jz_nand_remove(struct platform_device *pdev)
562 gpio_free(JZ_GPIO_MEM_CS0 + bank - 1); 555 gpio_free(JZ_GPIO_MEM_CS0 + bank - 1);
563 } 556 }
564 } 557 }
565 if (pdata && gpio_is_valid(pdata->busy_gpio))
566 gpio_free(pdata->busy_gpio);
567 558
568 jz_nand_iounmap_resource(nand->mem, nand->base); 559 jz_nand_iounmap_resource(nand->mem, nand->base);
569 560