[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221103-omapfb-gpiod-v1-7-cba1fae5a77c@gmail.com>
Date: Thu, 3 Nov 2022 20:16:36 -0700
From: Dmitry Torokhov <dmitry.torokhov@...il.com>
To: Helge Deller <deller@....de>, Tony Lindgren <tony@...mide.com>,
Tomi Valkeinen <tomi.valkeinen@...asonboard.com>,
Sebastian Reichel <sre@...nel.org>
Cc: linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org,
linux-omap@...r.kernel.org, linux-fbdev@...r.kernel.org
Subject: [PATCH RESEND 07/13] omapfb: panel-nec-nl8048hl11: switch to using gpiod API
Switch the driver from legacy gpio API that is deprecated to the newer
gpiod API that respects line polarities described in ACPI/DT.
Note that because existing DTSes specify incorrect polarity of reset
lines (active high) and GPU drivers have adopted to this, we follow
the suit and use inverted values when controlling reset lines.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@...il.com>
---
.../omap2/omapfb/displays/panel-nec-nl8048hl11.c | 72 ++++++----------------
1 file changed, 20 insertions(+), 52 deletions(-)
diff --git a/drivers/video/fbdev/omap2/omapfb/displays/panel-nec-nl8048hl11.c b/drivers/video/fbdev/omap2/omapfb/displays/panel-nec-nl8048hl11.c
index b407173e27b1..33563953b2ff 100644
--- a/drivers/video/fbdev/omap2/omapfb/displays/panel-nec-nl8048hl11.c
+++ b/drivers/video/fbdev/omap2/omapfb/displays/panel-nec-nl8048hl11.c
@@ -7,12 +7,12 @@
* Converted to new DSS device model: Tomi Valkeinen <tomi.valkeinen@...com>
*/
-#include <linux/module.h>
#include <linux/delay.h>
-#include <linux/spi/spi.h>
+#include <linux/err.h>
#include <linux/fb.h>
-#include <linux/gpio.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
+#include <linux/module.h>
+#include <linux/spi/spi.h>
#include <video/omapfb_dss.h>
@@ -24,8 +24,7 @@ struct panel_drv_data {
int data_lines;
- int res_gpio;
- int qvga_gpio;
+ struct gpio_desc *res_gpio;
struct spi_device *spi;
};
@@ -155,8 +154,8 @@ static int nec_8048_enable(struct omap_dss_device *dssdev)
if (r)
return r;
- if (gpio_is_valid(ddata->res_gpio))
- gpio_set_value_cansleep(ddata->res_gpio, 1);
+ /* Apparently existing DTSes use incorrect polarity (active high) */
+ gpiod_set_value_cansleep(ddata->res_gpio, 1);
dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
@@ -171,8 +170,8 @@ static void nec_8048_disable(struct omap_dss_device *dssdev)
if (!omapdss_device_is_enabled(dssdev))
return;
- if (gpio_is_valid(ddata->res_gpio))
- gpio_set_value_cansleep(ddata->res_gpio, 0);
+ /* Apparently existing DTSes use incorrect polarity (active high) */
+ gpiod_set_value_cansleep(ddata->res_gpio, 0);
in->ops.dpi->disable(in);
@@ -222,35 +221,6 @@ static struct omap_dss_driver nec_8048_ops = {
.get_resolution = omapdss_default_get_resolution,
};
-
-static int nec_8048_probe_of(struct spi_device *spi)
-{
- struct device_node *node = spi->dev.of_node;
- struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
- struct omap_dss_device *in;
- int gpio;
-
- gpio = of_get_named_gpio(node, "reset-gpios", 0);
- if (!gpio_is_valid(gpio)) {
- dev_err(&spi->dev, "failed to parse enable gpio\n");
- return gpio;
- }
- ddata->res_gpio = gpio;
-
- /* XXX the panel spec doesn't mention any QVGA pin?? */
- ddata->qvga_gpio = -ENOENT;
-
- in = omapdss_of_find_source_for_first_ep(node);
- if (IS_ERR(in)) {
- dev_err(&spi->dev, "failed to find video source\n");
- return PTR_ERR(in);
- }
-
- ddata->in = in;
-
- return 0;
-}
-
static int nec_8048_probe(struct spi_device *spi)
{
struct panel_drv_data *ddata;
@@ -281,24 +251,22 @@ static int nec_8048_probe(struct spi_device *spi)
ddata->spi = spi;
- r = nec_8048_probe_of(spi);
- if (r)
+ ddata->in = omapdss_of_find_source_for_first_ep(spi->dev.of_node);
+ r = PTR_ERR_OR_ZERO(ddata->in);
+ if (r) {
+ dev_err(&spi->dev, "failed to find video source: %d\n", r);
return r;
-
- if (gpio_is_valid(ddata->qvga_gpio)) {
- r = devm_gpio_request_one(&spi->dev, ddata->qvga_gpio,
- GPIOF_OUT_INIT_HIGH, "lcd QVGA");
- if (r)
- goto err_gpio;
}
- if (gpio_is_valid(ddata->res_gpio)) {
- r = devm_gpio_request_one(&spi->dev, ddata->res_gpio,
- GPIOF_OUT_INIT_LOW, "lcd RES");
- if (r)
- goto err_gpio;
+ ddata->res_gpio = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_LOW);
+ r = PTR_ERR_OR_ZERO(ddata->res_gpio);
+ if (r) {
+ dev_err(&spi->dev, "failed to request reset gpio: %d\n", r);
+ goto err_gpio;
}
+ gpiod_set_consumer_name(ddata->res_gpio, "lcd RES");
+
ddata->videomode = nec_8048_panel_timings;
dssdev = &ddata->dssdev;
--
b4 0.11.0-dev-28747
Powered by blists - more mailing lists