mtd: rawnand: lpc32xx_mlc: switch to using gpiod API
This switches the driver from legacy gpio API to a newer gpiod API. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20220928230019.2140896-1-dmitry.torokhov@gmail.com
This commit is contained in:
parent
d4353decd4
commit
782e32a990
1 changed files with 19 additions and 17 deletions
|
@ -25,7 +25,7 @@
|
||||||
#include <linux/completion.h>
|
#include <linux/completion.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_gpio.h>
|
#include <linux/gpio/consumer.h>
|
||||||
#include <linux/mtd/lpc32xx_mlc.h>
|
#include <linux/mtd/lpc32xx_mlc.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
|
@ -122,7 +122,6 @@ struct lpc32xx_nand_cfg_mlc {
|
||||||
uint32_t rd_low;
|
uint32_t rd_low;
|
||||||
uint32_t wr_high;
|
uint32_t wr_high;
|
||||||
uint32_t wr_low;
|
uint32_t wr_low;
|
||||||
int wp_gpio;
|
|
||||||
struct mtd_partition *parts;
|
struct mtd_partition *parts;
|
||||||
unsigned num_parts;
|
unsigned num_parts;
|
||||||
};
|
};
|
||||||
|
@ -177,6 +176,7 @@ struct lpc32xx_nand_host {
|
||||||
struct nand_chip nand_chip;
|
struct nand_chip nand_chip;
|
||||||
struct lpc32xx_mlc_platform_data *pdata;
|
struct lpc32xx_mlc_platform_data *pdata;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
|
struct gpio_desc *wp_gpio;
|
||||||
void __iomem *io_base;
|
void __iomem *io_base;
|
||||||
int irq;
|
int irq;
|
||||||
struct lpc32xx_nand_cfg_mlc *ncfg;
|
struct lpc32xx_nand_cfg_mlc *ncfg;
|
||||||
|
@ -370,8 +370,8 @@ static int lpc32xx_waitfunc(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -379,8 +379,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lpc32xx_dma_complete_func(void *completion)
|
static void lpc32xx_dma_complete_func(void *completion)
|
||||||
|
@ -636,8 +636,6 @@ static struct lpc32xx_nand_cfg_mlc *lpc32xx_parse_dt(struct device *dev)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ncfg->wp_gpio = of_get_named_gpio(np, "gpios", 0);
|
|
||||||
|
|
||||||
return ncfg;
|
return ncfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -713,14 +711,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) &&
|
host->wp_gpio = gpiod_get_optional(&pdev->dev, NULL, GPIOD_OUT_LOW);
|
||||||
gpio_request(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);
|
||||||
|
|
||||||
|
@ -817,7 +819,7 @@ put_clk:
|
||||||
clk_put(host->clk);
|
clk_put(host->clk);
|
||||||
free_gpio:
|
free_gpio:
|
||||||
lpc32xx_wp_enable(host);
|
lpc32xx_wp_enable(host);
|
||||||
gpio_free(host->ncfg->wp_gpio);
|
gpiod_put(host->wp_gpio);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -843,7 +845,7 @@ static int lpc32xx_nand_remove(struct platform_device *pdev)
|
||||||
clk_put(host->clk);
|
clk_put(host->clk);
|
||||||
|
|
||||||
lpc32xx_wp_enable(host);
|
lpc32xx_wp_enable(host);
|
||||||
gpio_free(host->ncfg->wp_gpio);
|
gpiod_put(host->wp_gpio);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue