Commit 6b923db2 authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Miquel Raynal

mtd: rawnand: lpc32xx_slc: switch to using gpiod API

This switches the driver from legacy gpio API to a newer gpiod API.
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220928230019.2140896-2-dmitry.torokhov@gmail.com
parent 782e32a9
...@@ -23,9 +23,8 @@ ...@@ -23,9 +23,8 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/dmaengine.h> #include <linux/dmaengine.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/mtd/lpc32xx_slc.h> #include <linux/mtd/lpc32xx_slc.h>
#define LPC32XX_MODNAME "lpc32xx-nand" #define LPC32XX_MODNAME "lpc32xx-nand"
...@@ -208,7 +207,6 @@ struct lpc32xx_nand_cfg_slc { ...@@ -208,7 +207,6 @@ struct lpc32xx_nand_cfg_slc {
uint32_t rwidth; uint32_t rwidth;
uint32_t rhold; uint32_t rhold;
uint32_t rsetup; uint32_t rsetup;
int wp_gpio;
struct mtd_partition *parts; struct mtd_partition *parts;
unsigned num_parts; unsigned num_parts;
}; };
...@@ -217,6 +215,7 @@ struct lpc32xx_nand_host { ...@@ -217,6 +215,7 @@ struct lpc32xx_nand_host {
struct nand_chip nand_chip; struct nand_chip nand_chip;
struct lpc32xx_slc_platform_data *pdata; struct lpc32xx_slc_platform_data *pdata;
struct clk *clk; struct clk *clk;
struct gpio_desc *wp_gpio;
void __iomem *io_base; void __iomem *io_base;
struct lpc32xx_nand_cfg_slc *ncfg; struct lpc32xx_nand_cfg_slc *ncfg;
...@@ -309,8 +308,8 @@ static int lpc32xx_nand_device_ready(struct nand_chip *chip) ...@@ -309,8 +308,8 @@ static int lpc32xx_nand_device_ready(struct nand_chip *chip)
*/ */
static void lpc32xx_wp_enable(struct lpc32xx_nand_host *host) static void lpc32xx_wp_enable(struct lpc32xx_nand_host *host)
{ {
if (gpio_is_valid(host->ncfg->wp_gpio)) if (host->wp_gpio)
gpio_set_value(host->ncfg->wp_gpio, 0); gpiod_set_value_cansleep(host->wp_gpio, 1);
} }
/* /*
...@@ -318,8 +317,8 @@ static void lpc32xx_wp_enable(struct lpc32xx_nand_host *host) ...@@ -318,8 +317,8 @@ static void lpc32xx_wp_enable(struct lpc32xx_nand_host *host)
*/ */
static void lpc32xx_wp_disable(struct lpc32xx_nand_host *host) static void lpc32xx_wp_disable(struct lpc32xx_nand_host *host)
{ {
if (gpio_is_valid(host->ncfg->wp_gpio)) if (host->wp_gpio)
gpio_set_value(host->ncfg->wp_gpio, 1); gpiod_set_value_cansleep(host->wp_gpio, 0);
} }
/* /*
...@@ -764,8 +763,6 @@ static struct lpc32xx_nand_cfg_slc *lpc32xx_parse_dt(struct device *dev) ...@@ -764,8 +763,6 @@ static struct lpc32xx_nand_cfg_slc *lpc32xx_parse_dt(struct device *dev)
return NULL; return NULL;
} }
ncfg->wp_gpio = of_get_named_gpio(np, "gpios", 0);
return ncfg; return ncfg;
} }
...@@ -852,14 +849,18 @@ static int lpc32xx_nand_probe(struct platform_device *pdev) ...@@ -852,14 +849,18 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
"Missing or bad NAND config from device tree\n"); "Missing or bad NAND config from device tree\n");
return -ENOENT; return -ENOENT;
} }
if (host->ncfg->wp_gpio == -EPROBE_DEFER)
return -EPROBE_DEFER; /* Start with WP disabled, if available */
if (gpio_is_valid(host->ncfg->wp_gpio) && devm_gpio_request(&pdev->dev, host->wp_gpio = gpiod_get_optional(&pdev->dev, NULL, GPIOD_OUT_LOW);
host->ncfg->wp_gpio, "NAND WP")) { res = PTR_ERR_OR_ZERO(host->wp_gpio);
dev_err(&pdev->dev, "GPIO not available\n"); if (res) {
return -EBUSY; if (res != -EPROBE_DEFER)
dev_err(&pdev->dev, "WP GPIO is not available: %d\n",
res);
return res;
} }
lpc32xx_wp_disable(host);
gpiod_set_consumer_name(host->wp_gpio, "NAND WP");
host->pdata = dev_get_platdata(&pdev->dev); host->pdata = dev_get_platdata(&pdev->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment