Commit 844c245f authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Helge Deller

fbdev: omapfb: panel-sony-acx565akm: 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: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: default avatarHelge Deller <deller@gmx.de>
parent 5845b32e
...@@ -18,9 +18,8 @@ ...@@ -18,9 +18,8 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/backlight.h> #include <linux/backlight.h>
#include <linux/fb.h> #include <linux/fb.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h>
#include <video/omapfb_dss.h> #include <video/omapfb_dss.h>
...@@ -56,7 +55,8 @@ struct panel_drv_data { ...@@ -56,7 +55,8 @@ struct panel_drv_data {
struct omap_dss_device dssdev; struct omap_dss_device dssdev;
struct omap_dss_device *in; struct omap_dss_device *in;
int reset_gpio; struct gpio_desc *reset_gpio;
int datapairs; int datapairs;
struct omap_video_timings videomode; struct omap_video_timings videomode;
...@@ -545,8 +545,13 @@ static int acx565akm_panel_power_on(struct omap_dss_device *dssdev) ...@@ -545,8 +545,13 @@ static int acx565akm_panel_power_on(struct omap_dss_device *dssdev)
/*FIXME tweak me */ /*FIXME tweak me */
msleep(50); msleep(50);
if (gpio_is_valid(ddata->reset_gpio)) /*
gpio_set_value(ddata->reset_gpio, 1); * Note that we appear to activate the reset line here. However
* existing DTSes specified incorrect polarity for it (active high),
* so in fact this deasserts the reset line.
*/
if (ddata->reset_gpio)
gpiod_set_value_cansleep(ddata->reset_gpio, 1);
if (ddata->enabled) { if (ddata->enabled) {
dev_dbg(&ddata->spi->dev, "panel already enabled\n"); dev_dbg(&ddata->spi->dev, "panel already enabled\n");
...@@ -595,8 +600,9 @@ static void acx565akm_panel_power_off(struct omap_dss_device *dssdev) ...@@ -595,8 +600,9 @@ static void acx565akm_panel_power_off(struct omap_dss_device *dssdev)
*/ */
msleep(50); msleep(50);
if (gpio_is_valid(ddata->reset_gpio)) /* see comment in acx565akm_panel_power_on() */
gpio_set_value(ddata->reset_gpio, 0); if (ddata->reset_gpio)
gpiod_set_value_cansleep(ddata->reset_gpio, 0);
/* FIXME need to tweak this delay */ /* FIXME need to tweak this delay */
msleep(100); msleep(100);
...@@ -687,22 +693,6 @@ static struct omap_dss_driver acx565akm_ops = { ...@@ -687,22 +693,6 @@ static struct omap_dss_driver acx565akm_ops = {
.get_resolution = omapdss_default_get_resolution, .get_resolution = omapdss_default_get_resolution,
}; };
static int acx565akm_probe_of(struct spi_device *spi)
{
struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
struct device_node *np = spi->dev.of_node;
ddata->reset_gpio = of_get_named_gpio(np, "reset-gpios", 0);
ddata->in = omapdss_of_find_source_for_first_ep(np);
if (IS_ERR(ddata->in)) {
dev_err(&spi->dev, "failed to find video source\n");
return PTR_ERR(ddata->in);
}
return 0;
}
static int acx565akm_probe(struct spi_device *spi) static int acx565akm_probe(struct spi_device *spi)
{ {
struct panel_drv_data *ddata; struct panel_drv_data *ddata;
...@@ -729,19 +719,25 @@ static int acx565akm_probe(struct spi_device *spi) ...@@ -729,19 +719,25 @@ static int acx565akm_probe(struct spi_device *spi)
mutex_init(&ddata->mutex); mutex_init(&ddata->mutex);
r = acx565akm_probe_of(spi); ddata->in = omapdss_of_find_source_for_first_ep(spi->dev.of_node);
if (r) r = PTR_ERR_OR_ZERO(ddata->in);
if (r) {
dev_err(&spi->dev, "failed to find video source\n");
return r; return r;
if (gpio_is_valid(ddata->reset_gpio)) {
r = devm_gpio_request_one(&spi->dev, ddata->reset_gpio,
GPIOF_OUT_INIT_LOW, "lcd reset");
if (r)
goto err_gpio;
} }
if (gpio_is_valid(ddata->reset_gpio)) ddata->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset",
gpio_set_value(ddata->reset_gpio, 1); GPIOD_OUT_LOW);
r = PTR_ERR_OR_ZERO(ddata->reset_gpio);
if (r)
goto err_gpio;
if (ddata->reset_gpio) {
gpiod_set_consumer_name(ddata->reset_gpio, "lcd reset");
/* release the reset line */
gpiod_set_value_cansleep(ddata->reset_gpio, 1);
}
/* /*
* After reset we have to wait 5 msec before the first * After reset we have to wait 5 msec before the first
...@@ -753,8 +749,8 @@ static int acx565akm_probe(struct spi_device *spi) ...@@ -753,8 +749,8 @@ static int acx565akm_probe(struct spi_device *spi)
r = panel_detect(ddata); r = panel_detect(ddata);
if (!ddata->enabled && gpio_is_valid(ddata->reset_gpio)) if (!ddata->enabled && ddata->reset_gpio)
gpio_set_value(ddata->reset_gpio, 0); gpiod_set_value_cansleep(ddata->reset_gpio, 0);
if (r) { if (r) {
dev_err(&spi->dev, "%s panel detect error\n", __func__); dev_err(&spi->dev, "%s panel detect error\n", __func__);
......
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