Commit 57e0478a authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Tomi Valkeinen

drm/omap: panel-nec-nl8048hl11: Convert to the GPIO descriptors API

The GPIO descriptor API is favoured over the plain GPIO API for consumer
drivers. Using it simplifies the driver code.

The reset GPIO is mandatory, so drop conditional tests through the
driver. The qvga GPIO is unused, so drop it completely.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarSebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent ac2d1fcb
...@@ -11,11 +11,10 @@ ...@@ -11,11 +11,10 @@
* (at your option) any later version. * (at your option) any later version.
*/ */
#include <linux/module.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/spi/spi.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/of_gpio.h> #include <linux/module.h>
#include <linux/spi/spi.h>
#include "../dss/omapdss.h" #include "../dss/omapdss.h"
...@@ -24,8 +23,7 @@ struct panel_drv_data { ...@@ -24,8 +23,7 @@ struct panel_drv_data {
struct videomode vm; struct videomode vm;
int res_gpio; struct gpio_desc *res_gpio;
int qvga_gpio;
struct spi_device *spi; struct spi_device *spi;
}; };
...@@ -140,8 +138,7 @@ static int nec_8048_enable(struct omap_dss_device *dssdev) ...@@ -140,8 +138,7 @@ static int nec_8048_enable(struct omap_dss_device *dssdev)
if (r) if (r)
return r; return r;
if (gpio_is_valid(ddata->res_gpio)) gpiod_set_value_cansleep(ddata->res_gpio, 1);
gpio_set_value_cansleep(ddata->res_gpio, 1);
dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
...@@ -156,8 +153,7 @@ static void nec_8048_disable(struct omap_dss_device *dssdev) ...@@ -156,8 +153,7 @@ static void nec_8048_disable(struct omap_dss_device *dssdev)
if (!omapdss_device_is_enabled(dssdev)) if (!omapdss_device_is_enabled(dssdev))
return; return;
if (gpio_is_valid(ddata->res_gpio)) gpiod_set_value_cansleep(ddata->res_gpio, 0);
gpio_set_value_cansleep(ddata->res_gpio, 0);
src->ops->disable(src); src->ops->disable(src);
...@@ -203,29 +199,11 @@ static const struct omap_dss_driver nec_8048_ops = { ...@@ -203,29 +199,11 @@ static const struct omap_dss_driver nec_8048_ops = {
.check_timings = nec_8048_check_timings, .check_timings = nec_8048_check_timings,
}; };
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);
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;
return 0;
}
static int nec_8048_probe(struct spi_device *spi) static int nec_8048_probe(struct spi_device *spi)
{ {
struct panel_drv_data *ddata; struct panel_drv_data *ddata;
struct omap_dss_device *dssdev; struct omap_dss_device *dssdev;
struct gpio_desc *gpio;
int r; int r;
dev_dbg(&spi->dev, "%s\n", __func__); dev_dbg(&spi->dev, "%s\n", __func__);
...@@ -249,23 +227,13 @@ static int nec_8048_probe(struct spi_device *spi) ...@@ -249,23 +227,13 @@ static int nec_8048_probe(struct spi_device *spi)
ddata->spi = spi; ddata->spi = spi;
r = nec_8048_probe_of(spi); gpio = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_LOW);
if (r) if (IS_ERR(gpio)) {
return r; dev_err(&spi->dev, "failed to get reset gpio\n");
return PTR_ERR(gpio);
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)
return r;
} }
if (gpio_is_valid(ddata->res_gpio)) { ddata->res_gpio = gpio;
r = devm_gpio_request_one(&spi->dev, ddata->res_gpio,
GPIOF_OUT_INIT_LOW, "lcd RES");
if (r)
return r;
}
ddata->vm = nec_8048_panel_vm; ddata->vm = nec_8048_panel_vm;
......
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