Commit 6378085b authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Helge Deller

fbdev: omapfb: encoder-tfp410: 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.
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: default avatarHelge Deller <deller@gmx.de>
parent 844c245f
...@@ -6,11 +6,12 @@ ...@@ -6,11 +6,12 @@
* Author: Tomi Valkeinen <tomi.valkeinen@ti.com> * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
*/ */
#include <linux/gpio.h> #include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/of_gpio.h>
#include <video/omapfb_dss.h> #include <video/omapfb_dss.h>
...@@ -18,7 +19,8 @@ struct panel_drv_data { ...@@ -18,7 +19,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 pd_gpio; struct gpio_desc *pd_gpio;
int data_lines; int data_lines;
struct omap_video_timings timings; struct omap_video_timings timings;
...@@ -86,8 +88,8 @@ static int tfp410_enable(struct omap_dss_device *dssdev) ...@@ -86,8 +88,8 @@ static int tfp410_enable(struct omap_dss_device *dssdev)
if (r) if (r)
return r; return r;
if (gpio_is_valid(ddata->pd_gpio)) if (ddata->pd_gpio)
gpio_set_value_cansleep(ddata->pd_gpio, 1); gpiod_set_value_cansleep(ddata->pd_gpio, 0);
dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
...@@ -102,8 +104,8 @@ static void tfp410_disable(struct omap_dss_device *dssdev) ...@@ -102,8 +104,8 @@ static void tfp410_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->pd_gpio)) if (ddata->pd_gpio)
gpio_set_value_cansleep(ddata->pd_gpio, 0); gpiod_set_value_cansleep(ddata->pd_gpio, 1);
in->ops.dpi->disable(in); in->ops.dpi->disable(in);
...@@ -162,33 +164,6 @@ static const struct omapdss_dvi_ops tfp410_dvi_ops = { ...@@ -162,33 +164,6 @@ static const struct omapdss_dvi_ops tfp410_dvi_ops = {
.get_timings = tfp410_get_timings, .get_timings = tfp410_get_timings,
}; };
static int tfp410_probe_of(struct platform_device *pdev)
{
struct panel_drv_data *ddata = platform_get_drvdata(pdev);
struct device_node *node = pdev->dev.of_node;
struct omap_dss_device *in;
int gpio;
gpio = of_get_named_gpio(node, "powerdown-gpios", 0);
if (gpio_is_valid(gpio) || gpio == -ENOENT) {
ddata->pd_gpio = gpio;
} else {
dev_err(&pdev->dev, "failed to parse PD gpio\n");
return gpio;
}
in = omapdss_of_find_source_for_first_ep(node);
if (IS_ERR(in)) {
dev_err(&pdev->dev, "failed to find video source\n");
return PTR_ERR(in);
}
ddata->in = in;
return 0;
}
static int tfp410_probe(struct platform_device *pdev) static int tfp410_probe(struct platform_device *pdev)
{ {
struct panel_drv_data *ddata; struct panel_drv_data *ddata;
...@@ -204,18 +179,21 @@ static int tfp410_probe(struct platform_device *pdev) ...@@ -204,18 +179,21 @@ static int tfp410_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, ddata); platform_set_drvdata(pdev, ddata);
r = tfp410_probe_of(pdev); ddata->pd_gpio = devm_gpiod_get_optional(&pdev->dev, "powerdown",
if (r) GPIOD_OUT_HIGH);
r = PTR_ERR_OR_ZERO(ddata->pd_gpio);
if (r) {
dev_err(&pdev->dev, "Failed to request PD GPIO: %d\n", r);
return r; return r;
}
gpiod_set_consumer_name(ddata->pd_gpio, "tfp410 PD");
if (gpio_is_valid(ddata->pd_gpio)) { ddata->in = omapdss_of_find_source_for_first_ep(pdev->dev.of_node);
r = devm_gpio_request_one(&pdev->dev, ddata->pd_gpio, r = PTR_ERR_OR_ZERO(ddata->in);
GPIOF_OUT_INIT_LOW, "tfp410 PD"); if (r) {
if (r) { dev_err(&pdev->dev, "failed to find video source: %d\n", r);
dev_err(&pdev->dev, "Failed to request PD GPIO %d\n", return r;
ddata->pd_gpio);
goto err_gpio;
}
} }
dssdev = &ddata->dssdev; dssdev = &ddata->dssdev;
...@@ -235,7 +213,6 @@ static int tfp410_probe(struct platform_device *pdev) ...@@ -235,7 +213,6 @@ static int tfp410_probe(struct platform_device *pdev)
return 0; return 0;
err_reg: err_reg:
err_gpio:
omap_dss_put_device(ddata->in); omap_dss_put_device(ddata->in);
return r; return r;
} }
......
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