* [PATCH v3 1/3] video: fbdev: omapfb: lcd_ams_delta: use GPIO lookup table
2018-09-09 22:56 ` [PATCH v3 0/3] ARM: OMAP1: ams-delta: Complete driver gpiod migration Janusz Krzysztofik
@ 2018-09-09 22:56 ` Janusz Krzysztofik
2018-09-10 7:15 ` Linus Walleij
2018-09-09 22:56 ` [PATCH v3 2/3] mtd: rawnand: ams-delta: " Janusz Krzysztofik
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Janusz Krzysztofik @ 2018-09-09 22:56 UTC (permalink / raw)
To: Tony Lindgren
Cc: linux-fbdev, linux-omap, Aaro Koskinen, Richard Weinberger,
Linus Walleij, Bartlomiej Zolnierkiewicz, Janusz Krzysztofik,
linux-kernel, dri-devel, Boris Brezillon, linux-mtd, linux-gpio,
Miquel Raynal, Brian Norris, David Woodhouse, Marek Vasut,
linux-arm-kernel
Now as Amstrad Delta board - the only user of this driver - provides
GPIO lookup tables, switch from GPIO numbers to GPIO descriptors and
use the table to locate required GPIO pins.
Declare static variables for storing GPIO descriptors and replace
gpio_ function calls with their gpiod_ equivalents. Move GPIO lookup
to the driver probe function so device initialization can be deferred
instead of aborted if a GPIO pin is not yet available.
Pin naming used by the driver should be followed while respective GPIO
lookup table is initialized by a board init code.
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
drivers/video/fbdev/omap/lcd_ams_delta.c | 55 +++++++++++++-------------------
1 file changed, 22 insertions(+), 33 deletions(-)
diff --git a/drivers/video/fbdev/omap/lcd_ams_delta.c b/drivers/video/fbdev/omap/lcd_ams_delta.c
index e8c748a0dfe2..cddbd00cbf9f 100644
--- a/drivers/video/fbdev/omap/lcd_ams_delta.c
+++ b/drivers/video/fbdev/omap/lcd_ams_delta.c
@@ -24,11 +24,10 @@
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
#include <linux/lcd.h>
-#include <linux/gpio.h>
#include <mach/hardware.h>
-#include <mach/board-ams-delta.h>
#include "omapfb.h"
@@ -41,6 +40,8 @@
/* LCD class device section */
static int ams_delta_lcd;
+static struct gpio_desc *gpiod_vblen;
+static struct gpio_desc *gpiod_ndisp;
static int ams_delta_lcd_set_power(struct lcd_device *dev, int power)
{
@@ -99,41 +100,17 @@ static struct lcd_ops ams_delta_lcd_ops = {
/* omapfb panel section */
-static const struct gpio _gpios[] = {
- {
- .gpio = AMS_DELTA_GPIO_PIN_LCD_VBLEN,
- .flags = GPIOF_OUT_INIT_LOW,
- .label = "lcd_vblen",
- },
- {
- .gpio = AMS_DELTA_GPIO_PIN_LCD_NDISP,
- .flags = GPIOF_OUT_INIT_LOW,
- .label = "lcd_ndisp",
- },
-};
-
-static int ams_delta_panel_init(struct lcd_panel *panel,
- struct omapfb_device *fbdev)
-{
- return gpio_request_array(_gpios, ARRAY_SIZE(_gpios));
-}
-
-static void ams_delta_panel_cleanup(struct lcd_panel *panel)
-{
- gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
-}
-
static int ams_delta_panel_enable(struct lcd_panel *panel)
{
- gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 1);
- gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 1);
+ gpiod_set_value(gpiod_ndisp, 1);
+ gpiod_set_value(gpiod_vblen, 1);
return 0;
}
static void ams_delta_panel_disable(struct lcd_panel *panel)
{
- gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 0);
- gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 0);
+ gpiod_set_value(gpiod_vblen, 0);
+ gpiod_set_value(gpiod_ndisp, 0);
}
static struct lcd_panel ams_delta_panel = {
@@ -154,8 +131,6 @@ static struct lcd_panel ams_delta_panel = {
.pcd = 0,
.acb = 37,
- .init = ams_delta_panel_init,
- .cleanup = ams_delta_panel_cleanup,
.enable = ams_delta_panel_enable,
.disable = ams_delta_panel_disable,
};
@@ -166,9 +141,23 @@ static struct lcd_panel ams_delta_panel = {
static int ams_delta_panel_probe(struct platform_device *pdev)
{
struct lcd_device *lcd_device = NULL;
-#ifdef CONFIG_LCD_CLASS_DEVICE
int ret;
+ gpiod_vblen = devm_gpiod_get(&pdev->dev, "vblen", GPIOD_OUT_LOW);
+ if (IS_ERR(gpiod_vblen)) {
+ ret = PTR_ERR(gpiod_vblen);
+ dev_err(&pdev->dev, "VBLEN GPIO request failed (%d)\n", ret);
+ return ret;
+ }
+
+ gpiod_ndisp = devm_gpiod_get(&pdev->dev, "ndisp", GPIOD_OUT_LOW);
+ if (IS_ERR(gpiod_ndisp)) {
+ ret = PTR_ERR(gpiod_ndisp);
+ dev_err(&pdev->dev, "NDISP GPIO request failed (%d)\n", ret);
+ return ret;
+ }
+
+#ifdef CONFIG_LCD_CLASS_DEVICE
lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL,
&ams_delta_lcd_ops);
--
2.16.4
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v3 1/3] video: fbdev: omapfb: lcd_ams_delta: use GPIO lookup table
2018-09-09 22:56 ` [PATCH v3 1/3] video: fbdev: omapfb: lcd_ams_delta: use GPIO lookup table Janusz Krzysztofik
@ 2018-09-10 7:15 ` Linus Walleij
0 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2018-09-10 7:15 UTC (permalink / raw)
To: Janusz Krzysztofik
Cc: ext Tony Lindgren, Aaro Koskinen, Boris Brezillon,
Miquèl Raynal, Richard Weinberger, David Woodhouse,
Brian Norris, Mark Vasut, Bartlomiej Zolnierkiewicz, Linux-OMAP,
Linux ARM, linux-mtd, linux-fbdev, open list:DRM PANEL DRIVERS,
open list:GPIO SUBSYSTEM, linux-kernel@vger.kernel.org
On Mon, Sep 10, 2018 at 12:55 AM Janusz Krzysztofik <jmkrzyszt@gmail.com> wrote:
> Now as Amstrad Delta board - the only user of this driver - provides
> GPIO lookup tables, switch from GPIO numbers to GPIO descriptors and
> use the table to locate required GPIO pins.
>
> Declare static variables for storing GPIO descriptors and replace
> gpio_ function calls with their gpiod_ equivalents. Move GPIO lookup
> to the driver probe function so device initialization can be deferred
> instead of aborted if a GPIO pin is not yet available.
>
> Pin naming used by the driver should be followed while respective GPIO
> lookup table is initialized by a board init code.
>
> Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Good work as usual:
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
FWIW I think the entire drivers/video/fbdev/omap/*
could be pretty easy to migrate to DRM if you compare
the simple drivers/gpu/drm/pl111 or drivers/gpu/drm/tve200
drivers. Just inspiration! :)
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 2/3] mtd: rawnand: ams-delta: use GPIO lookup table
2018-09-09 22:56 ` [PATCH v3 0/3] ARM: OMAP1: ams-delta: Complete driver gpiod migration Janusz Krzysztofik
2018-09-09 22:56 ` [PATCH v3 1/3] video: fbdev: omapfb: lcd_ams_delta: use GPIO lookup table Janusz Krzysztofik
@ 2018-09-09 22:56 ` Janusz Krzysztofik
2018-09-19 22:17 ` [PATCH v5] " Janusz Krzysztofik
2018-09-09 22:56 ` [PATCH v3 3/3] ARM: OMAP1: ams-delta: make board header file local to mach-omap1 Janusz Krzysztofik
2018-09-19 18:10 ` [PATCH v3 0/3] ARM: OMAP1: ams-delta: Complete driver gpiod migration Janusz Krzysztofik
3 siblings, 1 reply; 10+ messages in thread
From: Janusz Krzysztofik @ 2018-09-09 22:56 UTC (permalink / raw)
To: Tony Lindgren
Cc: linux-fbdev, linux-omap, Aaro Koskinen, Richard Weinberger,
Linus Walleij, Bartlomiej Zolnierkiewicz, Janusz Krzysztofik,
linux-kernel, dri-devel, Boris Brezillon, linux-mtd, linux-gpio,
Miquel Raynal, Brian Norris, David Woodhouse, Marek Vasut,
linux-arm-kernel
Now as Amstrad Delta board - the only user of this driver - provides
GPIO lookup tables, switch from GPIO numbers to GPIO descriptors and
use the table to locate required GPIO pins.
Declare static variables for storing GPIO descriptors and replace
gpio_ function calls with their gpiod_ equivalents.
Pin naming used by the driver should be followed while respective GPIO
lookup table is initialized by a board init code.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Acked-by: Boris Brezillon <boris.brezillon@bootlin.com>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/mtd/nand/raw/ams-delta.c | 126 +++++++++++++++++++++------------------
1 file changed, 67 insertions(+), 59 deletions(-)
diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c
index 37a3cc21c7bc..2a8872ebd14a 100644
--- a/drivers/mtd/nand/raw/ams-delta.c
+++ b/drivers/mtd/nand/raw/ams-delta.c
@@ -20,23 +20,28 @@
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h>
#include <linux/mtd/partitions.h>
-#include <linux/gpio.h>
#include <linux/platform_data/gpio-omap.h>
#include <asm/io.h>
#include <asm/sizes.h>
-#include <mach/board-ams-delta.h>
-
#include <mach/hardware.h>
/*
* MTD structure for E3 (Delta)
*/
static struct mtd_info *ams_delta_mtd = NULL;
+static struct gpio_desc *gpiod_rdy;
+static struct gpio_desc *gpiod_nce;
+static struct gpio_desc *gpiod_nre;
+static struct gpio_desc *gpiod_nwp;
+static struct gpio_desc *gpiod_nwe;
+static struct gpio_desc *gpiod_ale;
+static struct gpio_desc *gpiod_cle;
/*
* Define partitions for flash devices
@@ -70,9 +75,9 @@ static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte)
writew(0, io_base + OMAP_MPUIO_IO_CNTL);
writew(byte, this->IO_ADDR_W);
- gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NWE, 0);
+ gpiod_set_value(gpiod_nwe, 0);
ndelay(40);
- gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NWE, 1);
+ gpiod_set_value(gpiod_nwe, 1);
}
static u_char ams_delta_read_byte(struct mtd_info *mtd)
@@ -81,11 +86,11 @@ static u_char ams_delta_read_byte(struct mtd_info *mtd)
struct nand_chip *this = mtd_to_nand(mtd);
void __iomem *io_base = (void __iomem *)nand_get_controller_data(this);
- gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NRE, 0);
+ gpiod_set_value(gpiod_nre, 0);
ndelay(40);
writew(~0, io_base + OMAP_MPUIO_IO_CNTL);
res = readw(this->IO_ADDR_R);
- gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NRE, 1);
+ gpiod_set_value(gpiod_nre, 1);
return res;
}
@@ -120,12 +125,9 @@ static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd,
{
if (ctrl & NAND_CTRL_CHANGE) {
- gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NCE,
- (ctrl & NAND_NCE) == 0);
- gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_CLE,
- (ctrl & NAND_CLE) != 0);
- gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_ALE,
- (ctrl & NAND_ALE) != 0);
+ gpiod_set_value(gpiod_nce, !(ctrl & NAND_NCE));
+ gpiod_set_value(gpiod_cle, !!(ctrl & NAND_CLE));
+ gpiod_set_value(gpiod_ale, !!(ctrl & NAND_ALE));
}
if (cmd != NAND_CMD_NONE)
@@ -134,41 +136,9 @@ static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd,
static int ams_delta_nand_ready(struct mtd_info *mtd)
{
- return gpio_get_value(AMS_DELTA_GPIO_PIN_NAND_RB);
+ return gpiod_get_value(gpiod_rdy);
}
-static const struct gpio _mandatory_gpio[] = {
- {
- .gpio = AMS_DELTA_GPIO_PIN_NAND_NCE,
- .flags = GPIOF_OUT_INIT_HIGH,
- .label = "nand_nce",
- },
- {
- .gpio = AMS_DELTA_GPIO_PIN_NAND_NRE,
- .flags = GPIOF_OUT_INIT_HIGH,
- .label = "nand_nre",
- },
- {
- .gpio = AMS_DELTA_GPIO_PIN_NAND_NWP,
- .flags = GPIOF_OUT_INIT_HIGH,
- .label = "nand_nwp",
- },
- {
- .gpio = AMS_DELTA_GPIO_PIN_NAND_NWE,
- .flags = GPIOF_OUT_INIT_HIGH,
- .label = "nand_nwe",
- },
- {
- .gpio = AMS_DELTA_GPIO_PIN_NAND_ALE,
- .flags = GPIOF_OUT_INIT_LOW,
- .label = "nand_ale",
- },
- {
- .gpio = AMS_DELTA_GPIO_PIN_NAND_CLE,
- .flags = GPIOF_OUT_INIT_LOW,
- .label = "nand_cle",
- },
-};
/*
* Main initialization routine
@@ -216,12 +186,17 @@ static int ams_delta_init(struct platform_device *pdev)
this->write_buf = ams_delta_write_buf;
this->read_buf = ams_delta_read_buf;
this->cmd_ctrl = ams_delta_hwcontrol;
- if (gpio_request(AMS_DELTA_GPIO_PIN_NAND_RB, "nand_rdy") == 0) {
- this->dev_ready = ams_delta_nand_ready;
- } else {
- this->dev_ready = NULL;
- pr_notice("Couldn't request gpio for Delta NAND ready.\n");
+
+ gpiod_rdy = devm_gpiod_get_optional(&pdev->dev, "rdy", GPIOD_IN);
+ if (IS_ERR(gpiod_rdy)) {
+ err = PTR_ERR(gpiod_rdy);
+ dev_warn(&pdev->dev, "RDY GPIO request failed (%d)\n", err);
+ goto out_mtd;
}
+
+ if (gpiod_rdy)
+ this->dev_ready = ams_delta_nand_ready;
+
/* 25 us command delay time */
this->chip_delay = 30;
this->ecc.mode = NAND_ECC_SOFT;
@@ -230,9 +205,47 @@ static int ams_delta_init(struct platform_device *pdev)
platform_set_drvdata(pdev, io_base);
/* Set chip enabled, but */
- err = gpio_request_array(_mandatory_gpio, ARRAY_SIZE(_mandatory_gpio));
- if (err)
- goto out_gpio;
+ gpiod_nwp = devm_gpiod_get(&pdev->dev, "nwp", GPIOD_OUT_HIGH);
+ if (IS_ERR(gpiod_nwp)) {
+ err = PTR_ERR(gpiod_nwp);
+ dev_err(&pdev->dev, "NWP GPIO request failed (%d)\n", err);
+ goto out_mtd;
+ }
+
+ gpiod_nce = devm_gpiod_get(&pdev->dev, "nce", GPIOD_OUT_HIGH);
+ if (IS_ERR(gpiod_nce)) {
+ err = PTR_ERR(gpiod_nce);
+ dev_err(&pdev->dev, "NCE GPIO request failed (%d)\n", err);
+ goto out_mtd;
+ }
+
+ gpiod_nre = devm_gpiod_get(&pdev->dev, "nre", GPIOD_OUT_HIGH);
+ if (IS_ERR(gpiod_nre)) {
+ err = PTR_ERR(gpiod_nre);
+ dev_err(&pdev->dev, "NRE GPIO request failed (%d)\n", err);
+ goto out_mtd;
+ }
+
+ gpiod_nwe = devm_gpiod_get(&pdev->dev, "nwe", GPIOD_OUT_HIGH);
+ if (IS_ERR(gpiod_nwe)) {
+ err = PTR_ERR(gpiod_nwe);
+ dev_err(&pdev->dev, "NWE GPIO request failed (%d)\n", err);
+ goto out_mtd;
+ }
+
+ gpiod_ale = devm_gpiod_get(&pdev->dev, "ale", GPIOD_OUT_LOW);
+ if (IS_ERR(gpiod_ale)) {
+ err = PTR_ERR(gpiod_ale);
+ dev_err(&pdev->dev, "ALE GPIO request failed (%d)\n", err);
+ goto out_mtd;
+ }
+
+ gpiod_cle = devm_gpiod_get(&pdev->dev, "cle", GPIOD_OUT_LOW);
+ if (IS_ERR(gpiod_cle)) {
+ err = PTR_ERR(gpiod_cle);
+ dev_err(&pdev->dev, "CLE GPIO request failed (%d)\n", err);
+ goto out_mtd;
+ }
/* Scan to find existence of the device */
err = nand_scan(ams_delta_mtd, 1);
@@ -246,9 +259,6 @@ static int ams_delta_init(struct platform_device *pdev)
goto out;
out_mtd:
- gpio_free_array(_mandatory_gpio, ARRAY_SIZE(_mandatory_gpio));
-out_gpio:
- gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB);
iounmap(io_base);
out_free:
kfree(this);
@@ -266,8 +276,6 @@ static int ams_delta_cleanup(struct platform_device *pdev)
/* Release resources, unregister device */
nand_release(ams_delta_mtd);
- gpio_free_array(_mandatory_gpio, ARRAY_SIZE(_mandatory_gpio));
- gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB);
iounmap(io_base);
/* Free the MTD device structure */
--
2.16.4
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v5] mtd: rawnand: ams-delta: use GPIO lookup table
2018-09-09 22:56 ` [PATCH v3 2/3] mtd: rawnand: ams-delta: " Janusz Krzysztofik
@ 2018-09-19 22:17 ` Janusz Krzysztofik
2018-09-20 15:33 ` Linus Walleij
2018-09-23 11:35 ` Miquel Raynal
0 siblings, 2 replies; 10+ messages in thread
From: Janusz Krzysztofik @ 2018-09-19 22:17 UTC (permalink / raw)
To: Miquel Raynal
Cc: Linus Walleij, Tony Lindgren, Aaro Koskinen, Boris Brezillon,
Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut,
Janusz Krzysztofik, linux-omap, linux-mtd, linux-gpio,
linux-kernel
Now as Amstrad Delta board - the only user of this driver - provides
GPIO lookup tables, switch from GPIO numbers to GPIO descriptors and
use the table to locate required GPIO pins.
Declare static variables for storing GPIO descriptors and replace
gpio_ function calls with their gpiod_ equivalents.
Pin naming used by the driver should be followed while respective GPIO
lookup table is initialized by a board init code.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Acked-by: Boris Brezillon <boris.brezillon@bootlin.com>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
Changelog:
v5:
- rebased on nand/next
- resubmitted to linux-mtd as a stand-alone patch
v3 2/3:
- series rebased on top of v4.19-rc1
- added Acked-by: received from Miquel
v2 2/3 v4:
- fix style issue - thanks to Boris Brezillon
- resubmitted to linux-omap in a series
v3:
- remove problematic error code conversion no longer needed if used on
top of commit d08605a64e67 ("ARM: OMAP1: ams-delta: move late devices
back to init_machine") and commit 8853daf3b4ac ("gpiolib: Defer on
non-DT find_chip_by_name() failure") already in linux-next - thanks
to Boris Brezillon
v2:
- fix handling of devm_gpiod_get_optional() return values - thanks to
Andy Shevchenko
- resubmitted to linux-mtd as a stand-alone patch
Originally submitted to linux-omap as "[PATCH 5/6] mtd: rawnand:
ams-delta: use GPIO lookup table"
drivers/mtd/nand/raw/ams-delta.c | 126 +++++++++++++++++++++------------------
1 file changed, 67 insertions(+), 59 deletions(-)
diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c
index 3d3786dcc5d1..a2d2dfc55984 100644
--- a/drivers/mtd/nand/raw/ams-delta.c
+++ b/drivers/mtd/nand/raw/ams-delta.c
@@ -20,23 +20,28 @@
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h>
#include <linux/mtd/partitions.h>
-#include <linux/gpio.h>
#include <linux/platform_data/gpio-omap.h>
#include <asm/io.h>
#include <asm/sizes.h>
-#include <mach/board-ams-delta.h>
-
#include <mach/hardware.h>
/*
* MTD structure for E3 (Delta)
*/
static struct mtd_info *ams_delta_mtd = NULL;
+static struct gpio_desc *gpiod_rdy;
+static struct gpio_desc *gpiod_nce;
+static struct gpio_desc *gpiod_nre;
+static struct gpio_desc *gpiod_nwp;
+static struct gpio_desc *gpiod_nwe;
+static struct gpio_desc *gpiod_ale;
+static struct gpio_desc *gpiod_cle;
/*
* Define partitions for flash devices
@@ -69,9 +74,9 @@ static void ams_delta_write_byte(struct nand_chip *this, u_char byte)
writew(0, io_base + OMAP_MPUIO_IO_CNTL);
writew(byte, this->legacy.IO_ADDR_W);
- gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NWE, 0);
+ gpiod_set_value(gpiod_nwe, 0);
ndelay(40);
- gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NWE, 1);
+ gpiod_set_value(gpiod_nwe, 1);
}
static u_char ams_delta_read_byte(struct nand_chip *this)
@@ -79,11 +84,11 @@ static u_char ams_delta_read_byte(struct nand_chip *this)
u_char res;
void __iomem *io_base = (void __iomem *)nand_get_controller_data(this);
- gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NRE, 0);
+ gpiod_set_value(gpiod_nre, 0);
ndelay(40);
writew(~0, io_base + OMAP_MPUIO_IO_CNTL);
res = readw(this->legacy.IO_ADDR_R);
- gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NRE, 1);
+ gpiod_set_value(gpiod_nre, 1);
return res;
}
@@ -118,12 +123,9 @@ static void ams_delta_hwcontrol(struct nand_chip *this, int cmd,
{
if (ctrl & NAND_CTRL_CHANGE) {
- gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NCE,
- (ctrl & NAND_NCE) == 0);
- gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_CLE,
- (ctrl & NAND_CLE) != 0);
- gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_ALE,
- (ctrl & NAND_ALE) != 0);
+ gpiod_set_value(gpiod_nce, !(ctrl & NAND_NCE));
+ gpiod_set_value(gpiod_cle, !!(ctrl & NAND_CLE));
+ gpiod_set_value(gpiod_ale, !!(ctrl & NAND_ALE));
}
if (cmd != NAND_CMD_NONE)
@@ -132,41 +134,9 @@ static void ams_delta_hwcontrol(struct nand_chip *this, int cmd,
static int ams_delta_nand_ready(struct nand_chip *this)
{
- return gpio_get_value(AMS_DELTA_GPIO_PIN_NAND_RB);
+ return gpiod_get_value(gpiod_rdy);
}
-static const struct gpio _mandatory_gpio[] = {
- {
- .gpio = AMS_DELTA_GPIO_PIN_NAND_NCE,
- .flags = GPIOF_OUT_INIT_HIGH,
- .label = "nand_nce",
- },
- {
- .gpio = AMS_DELTA_GPIO_PIN_NAND_NRE,
- .flags = GPIOF_OUT_INIT_HIGH,
- .label = "nand_nre",
- },
- {
- .gpio = AMS_DELTA_GPIO_PIN_NAND_NWP,
- .flags = GPIOF_OUT_INIT_HIGH,
- .label = "nand_nwp",
- },
- {
- .gpio = AMS_DELTA_GPIO_PIN_NAND_NWE,
- .flags = GPIOF_OUT_INIT_HIGH,
- .label = "nand_nwe",
- },
- {
- .gpio = AMS_DELTA_GPIO_PIN_NAND_ALE,
- .flags = GPIOF_OUT_INIT_LOW,
- .label = "nand_ale",
- },
- {
- .gpio = AMS_DELTA_GPIO_PIN_NAND_CLE,
- .flags = GPIOF_OUT_INIT_LOW,
- .label = "nand_cle",
- },
-};
/*
* Main initialization routine
@@ -214,12 +184,17 @@ static int ams_delta_init(struct platform_device *pdev)
this->legacy.write_buf = ams_delta_write_buf;
this->legacy.read_buf = ams_delta_read_buf;
this->legacy.cmd_ctrl = ams_delta_hwcontrol;
- if (gpio_request(AMS_DELTA_GPIO_PIN_NAND_RB, "nand_rdy") == 0) {
- this->legacy.dev_ready = ams_delta_nand_ready;
- } else {
- this->legacy.dev_ready = NULL;
- pr_notice("Couldn't request gpio for Delta NAND ready.\n");
+
+ gpiod_rdy = devm_gpiod_get_optional(&pdev->dev, "rdy", GPIOD_IN);
+ if (IS_ERR(gpiod_rdy)) {
+ err = PTR_ERR(gpiod_rdy);
+ dev_warn(&pdev->dev, "RDY GPIO request failed (%d)\n", err);
+ goto out_mtd;
}
+
+ if (gpiod_rdy)
+ this->legacy.dev_ready = ams_delta_nand_ready;
+
/* 25 us command delay time */
this->legacy.chip_delay = 30;
this->ecc.mode = NAND_ECC_SOFT;
@@ -228,9 +203,47 @@ static int ams_delta_init(struct platform_device *pdev)
platform_set_drvdata(pdev, io_base);
/* Set chip enabled, but */
- err = gpio_request_array(_mandatory_gpio, ARRAY_SIZE(_mandatory_gpio));
- if (err)
- goto out_gpio;
+ gpiod_nwp = devm_gpiod_get(&pdev->dev, "nwp", GPIOD_OUT_HIGH);
+ if (IS_ERR(gpiod_nwp)) {
+ err = PTR_ERR(gpiod_nwp);
+ dev_err(&pdev->dev, "NWP GPIO request failed (%d)\n", err);
+ goto out_mtd;
+ }
+
+ gpiod_nce = devm_gpiod_get(&pdev->dev, "nce", GPIOD_OUT_HIGH);
+ if (IS_ERR(gpiod_nce)) {
+ err = PTR_ERR(gpiod_nce);
+ dev_err(&pdev->dev, "NCE GPIO request failed (%d)\n", err);
+ goto out_mtd;
+ }
+
+ gpiod_nre = devm_gpiod_get(&pdev->dev, "nre", GPIOD_OUT_HIGH);
+ if (IS_ERR(gpiod_nre)) {
+ err = PTR_ERR(gpiod_nre);
+ dev_err(&pdev->dev, "NRE GPIO request failed (%d)\n", err);
+ goto out_mtd;
+ }
+
+ gpiod_nwe = devm_gpiod_get(&pdev->dev, "nwe", GPIOD_OUT_HIGH);
+ if (IS_ERR(gpiod_nwe)) {
+ err = PTR_ERR(gpiod_nwe);
+ dev_err(&pdev->dev, "NWE GPIO request failed (%d)\n", err);
+ goto out_mtd;
+ }
+
+ gpiod_ale = devm_gpiod_get(&pdev->dev, "ale", GPIOD_OUT_LOW);
+ if (IS_ERR(gpiod_ale)) {
+ err = PTR_ERR(gpiod_ale);
+ dev_err(&pdev->dev, "ALE GPIO request failed (%d)\n", err);
+ goto out_mtd;
+ }
+
+ gpiod_cle = devm_gpiod_get(&pdev->dev, "cle", GPIOD_OUT_LOW);
+ if (IS_ERR(gpiod_cle)) {
+ err = PTR_ERR(gpiod_cle);
+ dev_err(&pdev->dev, "CLE GPIO request failed (%d)\n", err);
+ goto out_mtd;
+ }
/* Scan to find existence of the device */
err = nand_scan(this, 1);
@@ -244,9 +257,6 @@ static int ams_delta_init(struct platform_device *pdev)
goto out;
out_mtd:
- gpio_free_array(_mandatory_gpio, ARRAY_SIZE(_mandatory_gpio));
-out_gpio:
- gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB);
iounmap(io_base);
out_free:
kfree(this);
@@ -264,8 +274,6 @@ static int ams_delta_cleanup(struct platform_device *pdev)
/* Release resources, unregister device */
nand_release(mtd_to_nand(ams_delta_mtd));
- gpio_free_array(_mandatory_gpio, ARRAY_SIZE(_mandatory_gpio));
- gpio_free(AMS_DELTA_GPIO_PIN_NAND_RB);
iounmap(io_base);
/* Free the MTD device structure */
--
2.16.4
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v5] mtd: rawnand: ams-delta: use GPIO lookup table
2018-09-19 22:17 ` [PATCH v5] " Janusz Krzysztofik
@ 2018-09-20 15:33 ` Linus Walleij
2018-09-23 11:35 ` Miquel Raynal
1 sibling, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2018-09-20 15:33 UTC (permalink / raw)
To: Janusz Krzysztofik
Cc: Miquèl Raynal, ext Tony Lindgren, Aaro Koskinen,
Boris Brezillon, Richard Weinberger, David Woodhouse,
Brian Norris, Mark Vasut, Linux-OMAP, linux-mtd,
open list:GPIO SUBSYSTEM, linux-kernel@vger.kernel.org
On Wed, Sep 19, 2018 at 3:17 PM Janusz Krzysztofik <jmkrzyszt@gmail.com> wrote:
> Now as Amstrad Delta board - the only user of this driver - provides
> GPIO lookup tables, switch from GPIO numbers to GPIO descriptors and
> use the table to locate required GPIO pins.
>
> Declare static variables for storing GPIO descriptors and replace
> gpio_ function calls with their gpiod_ equivalents.
>
> Pin naming used by the driver should be followed while respective GPIO
> lookup table is initialized by a board init code.
>
> Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
> Acked-by: Boris Brezillon <boris.brezillon@bootlin.com>
> Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
> Changelog:
> v5:
> - rebased on nand/next
> - resubmitted to linux-mtd as a stand-alone patch
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5] mtd: rawnand: ams-delta: use GPIO lookup table
2018-09-19 22:17 ` [PATCH v5] " Janusz Krzysztofik
2018-09-20 15:33 ` Linus Walleij
@ 2018-09-23 11:35 ` Miquel Raynal
1 sibling, 0 replies; 10+ messages in thread
From: Miquel Raynal @ 2018-09-23 11:35 UTC (permalink / raw)
To: Janusz Krzysztofik
Cc: Linus Walleij, Tony Lindgren, Aaro Koskinen, Boris Brezillon,
Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut,
linux-omap, linux-mtd, linux-gpio, linux-kernel
Hi Janusz,
Janusz Krzysztofik <jmkrzyszt@gmail.com> wrote on Thu, 20 Sep 2018
00:17:29 +0200:
> Now as Amstrad Delta board - the only user of this driver - provides
> GPIO lookup tables, switch from GPIO numbers to GPIO descriptors and
> use the table to locate required GPIO pins.
>
> Declare static variables for storing GPIO descriptors and replace
> gpio_ function calls with their gpiod_ equivalents.
>
> Pin naming used by the driver should be followed while respective GPIO
> lookup table is initialized by a board init code.
>
> Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
> Acked-by: Boris Brezillon <boris.brezillon@bootlin.com>
> Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
Applied on nand/next.
Thanks,
Miquèl
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 3/3] ARM: OMAP1: ams-delta: make board header file local to mach-omap1
2018-09-09 22:56 ` [PATCH v3 0/3] ARM: OMAP1: ams-delta: Complete driver gpiod migration Janusz Krzysztofik
2018-09-09 22:56 ` [PATCH v3 1/3] video: fbdev: omapfb: lcd_ams_delta: use GPIO lookup table Janusz Krzysztofik
2018-09-09 22:56 ` [PATCH v3 2/3] mtd: rawnand: ams-delta: " Janusz Krzysztofik
@ 2018-09-09 22:56 ` Janusz Krzysztofik
2018-09-19 18:10 ` [PATCH v3 0/3] ARM: OMAP1: ams-delta: Complete driver gpiod migration Janusz Krzysztofik
3 siblings, 0 replies; 10+ messages in thread
From: Janusz Krzysztofik @ 2018-09-09 22:56 UTC (permalink / raw)
To: Tony Lindgren
Cc: linux-fbdev, linux-omap, Aaro Koskinen, Richard Weinberger,
Linus Walleij, Bartlomiej Zolnierkiewicz, Janusz Krzysztofik,
linux-kernel, dri-devel, Boris Brezillon, linux-mtd, linux-gpio,
Miquel Raynal, Brian Norris, David Woodhouse, Marek Vasut,
linux-arm-kernel
Now as board header file is no longer included by drivers, move it to
the root directory of mach-omap1.
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
---
arch/arm/mach-omap1/ams-delta-fiq-handler.S | 2 +-
arch/arm/mach-omap1/ams-delta-fiq.c | 3 +--
arch/arm/mach-omap1/board-ams-delta.c | 2 +-
arch/arm/mach-omap1/{include/mach => }/board-ams-delta.h | 2 +-
4 files changed, 4 insertions(+), 5 deletions(-)
rename arch/arm/mach-omap1/{include/mach => }/board-ams-delta.h (98%)
diff --git a/arch/arm/mach-omap1/ams-delta-fiq-handler.S b/arch/arm/mach-omap1/ams-delta-fiq-handler.S
index ddc27638ba2a..2e2a17364dc9 100644
--- a/arch/arm/mach-omap1/ams-delta-fiq-handler.S
+++ b/arch/arm/mach-omap1/ams-delta-fiq-handler.S
@@ -17,9 +17,9 @@
#include <linux/platform_data/ams-delta-fiq.h>
#include <asm/assembler.h>
-#include <mach/board-ams-delta.h>
#include "ams-delta-fiq.h"
+#include "board-ams-delta.h"
#include "iomap.h"
#include "soc.h"
diff --git a/arch/arm/mach-omap1/ams-delta-fiq.c b/arch/arm/mach-omap1/ams-delta-fiq.c
index b0dc7ddf5877..14c3d3f5255e 100644
--- a/arch/arm/mach-omap1/ams-delta-fiq.c
+++ b/arch/arm/mach-omap1/ams-delta-fiq.c
@@ -22,11 +22,10 @@
#include <linux/platform_data/ams-delta-fiq.h>
#include <linux/platform_device.h>
-#include <mach/board-ams-delta.h>
-
#include <asm/fiq.h>
#include "ams-delta-fiq.h"
+#include "board-ams-delta.h"
static struct fiq_handler fh = {
.name = "ams-delta-fiq"
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index dd28d2614d7f..34cb63ff45b3 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -36,7 +36,6 @@
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
-#include <mach/board-ams-delta.h>
#include <linux/platform_data/keypad-omap.h>
#include <mach/mux.h>
@@ -45,6 +44,7 @@
#include <mach/usb.h>
#include "ams-delta-fiq.h"
+#include "board-ams-delta.h"
#include "iomap.h"
#include "common.h"
diff --git a/arch/arm/mach-omap1/include/mach/board-ams-delta.h b/arch/arm/mach-omap1/board-ams-delta.h
similarity index 98%
rename from arch/arm/mach-omap1/include/mach/board-ams-delta.h
rename to arch/arm/mach-omap1/board-ams-delta.h
index ad6f865d1f16..1fbada29431a 100644
--- a/arch/arm/mach-omap1/include/mach/board-ams-delta.h
+++ b/arch/arm/mach-omap1/board-ams-delta.h
@@ -1,5 +1,5 @@
/*
- * arch/arm/plat-omap/include/mach/board-ams-delta.h
+ * arch/arm/mach-omap1/board-ams-delta.h
*
* Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
*
--
2.16.4
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v3 0/3] ARM: OMAP1: ams-delta: Complete driver gpiod migration
2018-09-09 22:56 ` [PATCH v3 0/3] ARM: OMAP1: ams-delta: Complete driver gpiod migration Janusz Krzysztofik
` (2 preceding siblings ...)
2018-09-09 22:56 ` [PATCH v3 3/3] ARM: OMAP1: ams-delta: make board header file local to mach-omap1 Janusz Krzysztofik
@ 2018-09-19 18:10 ` Janusz Krzysztofik
2018-09-20 20:58 ` Tony Lindgren
3 siblings, 1 reply; 10+ messages in thread
From: Janusz Krzysztofik @ 2018-09-19 18:10 UTC (permalink / raw)
To: Tony Lindgren
Cc: Linus Walleij, Aaro Koskinen, Boris Brezillon, Miquel Raynal,
Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut,
Bartlomiej Zolnierkiewicz, linux-omap, linux-arm-kernel,
linux-mtd, linux-fbdev, dri-devel, linux-gpio, linux-kernel,
Janusz Krzysztofik
On Monday, September 10, 2018 12:56:02 AM CEST Janusz Krzysztofik wrote:
>
> This is a follow up of initial submission of a series consisted of
> 6 changes, 3 of which have been already applied or reworkeed.
>
>
> Janusz Krzysztofik (3):
> video: fbdev: omapfb: lcd_ams_delta: use GPIO lookup table
> mtd: rawnand: ams-delta: use GPIO lookup table
Hi Tony,
Please ignore this patch. It may no longer be possible to merged it cleanly
with nand/next tree. I'll exclude it from the series, rebase on top of nand/
next and submit via linux-mtd.
That shouldn't affect the two remaining patches of the series which should
still apply and merge cleanly, but I can resend them renumbered if you wish.
Thanks,
Janusz
> ARM: OMAP1: ams-delta: make board header file local to mach-omap1
>
>
> I'm submitting the three patches in series because the last one depends
> on the other two.
>
> Tony, please set up an immutable tag for this series to be used by MTD
> as there are more changes on Amstrad Delta NAND driver coming in.
>
> Thanks,
> Janusz
>
>
> Changelog:
> v3:
> - rebased on top of v4.19-rc1
> - added Acked-by: received from Miquel
>
> v2:
> [PATCH 1/6] ARM: OMAP1: ams-delta: add GPIO lookup tables
> - already in mainline, commit 68e62a15a914
> [PATCH 2/6] Input: ams_delta_serio: use GPIO lookup table
> - reworked and submitted as a series, already in linux-omap,
> commit 68e62a15a914 ("ARM: OMAP1: ams-delta: drop GPIO lookup
> table for serio device") followed by 9 more
> [PATCH 3/6] ASoC: ams_delta: use GPIO lookup table
> - already in mainline, commit d65777d1a2cd
> [PATCH 4/6] fbdev: omapfb: lcd_ams_delta: use GPIO lookup table
> - resubmitting as [PATCH v2 1/3 v2]
> v2: Remove problematic error code conversion no longer
> needed if used on top of commit d08605a64e67 ("ARM: OMAP1:
> ams-delta: move late devices back to init_machine")
> and commit 8853daf3b4ac ("gpiolib: Defer on non-DT
> find_chip_by_name() failure") already in linux-next
> [PATCH 5/6] mtd: rawnand: ams-delta: use GPIO lookup table
> - resubmitting as [PATCH v2 2/3 v4]
> v2: Fix handling of devm_gpiod_get_optional() return values -
> thanks to Andy Shevchenko.
> v3: Remove problematic error code conversion no longer needed
> if used on top of commit d08605a64e67 ("ARM: OMAP1:
> ams-delta: move late devices back to init_machine") and
> commit 8853daf3b4ac ("gpiolib: Defer on non-DT
> find_chip_by_name() failure") already in linux-next - thanks
> to Boris Brezillon
> v4: fix style issue - thanks to Boris Brezillon
> [PATCH 6/6] ARM: OMAP1: ams-delta: make board header file local to
> mach-omap1
> - resending as [PATCH v2 3/3]
>
> All dependencies mentioned in v2 changelog are satisfied in v4.19-rc1.
>
>
> diffstat:
> arch/arm/mach-omap1/ams-delta-fiq-handler.S | 2
> arch/arm/mach-omap1/ams-delta-fiq.c | 3
> arch/arm/mach-omap1/board-ams-delta.c | 2
> arch/arm/mach-omap1/board-ams-delta.h | 2
> drivers/mtd/nand/raw/ams-delta.c | 126 +++++++++++++
+--------------
> drivers/video/fbdev/omap/lcd_ams_delta.c | 55 ++++--------
> 6 files changed, 93 insertions(+), 97 deletions(-)
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v3 0/3] ARM: OMAP1: ams-delta: Complete driver gpiod migration
2018-09-19 18:10 ` [PATCH v3 0/3] ARM: OMAP1: ams-delta: Complete driver gpiod migration Janusz Krzysztofik
@ 2018-09-20 20:58 ` Tony Lindgren
0 siblings, 0 replies; 10+ messages in thread
From: Tony Lindgren @ 2018-09-20 20:58 UTC (permalink / raw)
To: Janusz Krzysztofik
Cc: Linus Walleij, Aaro Koskinen, Boris Brezillon, Miquel Raynal,
Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut,
Bartlomiej Zolnierkiewicz, linux-omap, linux-arm-kernel,
linux-mtd, linux-fbdev, dri-devel, linux-gpio, linux-kernel
* Janusz Krzysztofik <jmkrzyszt@gmail.com> [180919 18:13]:
> On Monday, September 10, 2018 12:56:02 AM CEST Janusz Krzysztofik wrote:
> >
> > This is a follow up of initial submission of a series consisted of
> > 6 changes, 3 of which have been already applied or reworkeed.
> >
> >
> > Janusz Krzysztofik (3):
> > video: fbdev: omapfb: lcd_ams_delta: use GPIO lookup table
> > mtd: rawnand: ams-delta: use GPIO lookup table
>
> Hi Tony,
>
> Please ignore this patch. It may no longer be possible to merged it cleanly
> with nand/next tree. I'll exclude it from the series, rebase on top of nand/
> next and submit via linux-mtd.
OK sounds good to me.
> That shouldn't affect the two remaining patches of the series which should
> still apply and merge cleanly, but I can resend them renumbered if you wish.
Up to the mtd and fb folks as far as I'm concerned :)
Regards,
Tony
^ permalink raw reply [flat|nested] 10+ messages in thread