Commit 9231abd3 authored by Sebastian Reichel's avatar Sebastian Reichel Committed by Tomi Valkeinen

drm/omap: panel-dsi-cm: switch to gpiod

Use the new descriptor based GPIO API instead of
the legacy one, which results in cleaner code
with less lines of code.
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent a44e552a
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <video/mipi_display.h> #include <video/mipi_display.h>
...@@ -59,8 +58,8 @@ struct panel_drv_data { ...@@ -59,8 +58,8 @@ struct panel_drv_data {
unsigned long hw_guard_wait; /* max guard time in jiffies */ unsigned long hw_guard_wait; /* max guard time in jiffies */
/* panel HW configuration from DT or platform data */ /* panel HW configuration from DT or platform data */
int reset_gpio; struct gpio_desc *reset_gpio;
int ext_te_gpio; struct gpio_desc *ext_te_gpio;
struct regulator *vpnl; struct regulator *vpnl;
struct regulator *vddi; struct regulator *vddi;
...@@ -288,8 +287,8 @@ static int dsicm_enter_ulps(struct panel_drv_data *ddata) ...@@ -288,8 +287,8 @@ static int dsicm_enter_ulps(struct panel_drv_data *ddata)
if (r) if (r)
goto err; goto err;
if (gpio_is_valid(ddata->ext_te_gpio)) if (ddata->ext_te_gpio)
disable_irq(gpio_to_irq(ddata->ext_te_gpio)); disable_irq(gpiod_to_irq(ddata->ext_te_gpio));
in->ops.dsi->disable(in, false, true); in->ops.dsi->disable(in, false, true);
...@@ -330,8 +329,8 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata) ...@@ -330,8 +329,8 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
goto err2; goto err2;
} }
if (gpio_is_valid(ddata->ext_te_gpio)) if (ddata->ext_te_gpio)
enable_irq(gpio_to_irq(ddata->ext_te_gpio)); enable_irq(gpiod_to_irq(ddata->ext_te_gpio));
dsicm_queue_ulps_work(ddata); dsicm_queue_ulps_work(ddata);
...@@ -344,8 +343,8 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata) ...@@ -344,8 +343,8 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata)
r = dsicm_panel_reset(ddata); r = dsicm_panel_reset(ddata);
if (!r) { if (!r) {
if (gpio_is_valid(ddata->ext_te_gpio)) if (ddata->ext_te_gpio)
enable_irq(gpio_to_irq(ddata->ext_te_gpio)); enable_irq(gpiod_to_irq(ddata->ext_te_gpio));
ddata->ulps_enabled = false; ddata->ulps_enabled = false;
} }
err1: err1:
...@@ -591,16 +590,13 @@ static const struct attribute_group dsicm_attr_group = { ...@@ -591,16 +590,13 @@ static const struct attribute_group dsicm_attr_group = {
static void dsicm_hw_reset(struct panel_drv_data *ddata) static void dsicm_hw_reset(struct panel_drv_data *ddata)
{ {
if (!gpio_is_valid(ddata->reset_gpio)) gpiod_set_value(ddata->reset_gpio, 1);
return;
gpio_set_value(ddata->reset_gpio, 1);
udelay(10); udelay(10);
/* reset the panel */ /* reset the panel */
gpio_set_value(ddata->reset_gpio, 0); gpiod_set_value(ddata->reset_gpio, 0);
/* assert reset */ /* assert reset */
udelay(10); udelay(10);
gpio_set_value(ddata->reset_gpio, 1); gpiod_set_value(ddata->reset_gpio, 1);
/* wait after releasing reset */ /* wait after releasing reset */
usleep_range(5000, 10000); usleep_range(5000, 10000);
} }
...@@ -954,7 +950,7 @@ static int dsicm_update(struct omap_dss_device *dssdev, ...@@ -954,7 +950,7 @@ static int dsicm_update(struct omap_dss_device *dssdev,
if (r) if (r)
goto err; goto err;
if (ddata->te_enabled && gpio_is_valid(ddata->ext_te_gpio)) { if (ddata->te_enabled && ddata->ext_te_gpio) {
schedule_delayed_work(&ddata->te_timeout_work, schedule_delayed_work(&ddata->te_timeout_work,
msecs_to_jiffies(250)); msecs_to_jiffies(250));
atomic_set(&ddata->do_update, 1); atomic_set(&ddata->do_update, 1);
...@@ -1001,7 +997,7 @@ static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable) ...@@ -1001,7 +997,7 @@ static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable)
else else
r = dsicm_dcs_write_0(ddata, MIPI_DCS_SET_TEAR_OFF); r = dsicm_dcs_write_0(ddata, MIPI_DCS_SET_TEAR_OFF);
if (!gpio_is_valid(ddata->ext_te_gpio)) if (!ddata->ext_te_gpio)
in->ops.dsi->enable_te(in, enable); in->ops.dsi->enable_te(in, enable);
/* possible panel bug */ /* possible panel bug */
...@@ -1229,21 +1225,21 @@ static int dsicm_probe_of(struct platform_device *pdev) ...@@ -1229,21 +1225,21 @@ static int dsicm_probe_of(struct platform_device *pdev)
struct panel_drv_data *ddata = platform_get_drvdata(pdev); struct panel_drv_data *ddata = platform_get_drvdata(pdev);
struct omap_dss_device *in; struct omap_dss_device *in;
struct display_timing timing; struct display_timing timing;
int gpio, err; int err;
gpio = of_get_named_gpio(node, "reset-gpios", 0); ddata->reset_gpio = devm_gpiod_get(&pdev->dev, "reset", GPIOD_OUT_LOW);
if (!gpio_is_valid(gpio)) { if (IS_ERR(ddata->reset_gpio)) {
dev_err(&pdev->dev, "failed to parse reset gpio\n"); err = PTR_ERR(ddata->reset_gpio);
return gpio; dev_err(&pdev->dev, "reset gpio request failed: %d", err);
return err;
} }
ddata->reset_gpio = gpio;
gpio = of_get_named_gpio(node, "te-gpios", 0); ddata->ext_te_gpio = devm_gpiod_get_optional(&pdev->dev, "te",
if (gpio_is_valid(gpio) || gpio == -ENOENT) { GPIOD_IN);
ddata->ext_te_gpio = gpio; if (IS_ERR(ddata->ext_te_gpio)) {
} else { err = PTR_ERR(ddata->ext_te_gpio);
dev_err(&pdev->dev, "failed to parse TE gpio\n"); dev_err(&pdev->dev, "TE gpio request failed: %d", err);
return gpio; return err;
} }
err = of_get_display_timing(node, "panel-timing", &timing); err = of_get_display_timing(node, "panel-timing", &timing);
...@@ -1353,24 +1349,8 @@ static int dsicm_probe(struct platform_device *pdev) ...@@ -1353,24 +1349,8 @@ static int dsicm_probe(struct platform_device *pdev)
atomic_set(&ddata->do_update, 0); atomic_set(&ddata->do_update, 0);
if (gpio_is_valid(ddata->reset_gpio)) { if (ddata->ext_te_gpio) {
r = devm_gpio_request_one(dev, ddata->reset_gpio, r = devm_request_irq(dev, gpiod_to_irq(ddata->ext_te_gpio),
GPIOF_OUT_INIT_LOW, "taal rst");
if (r) {
dev_err(dev, "failed to request reset gpio\n");
goto err_reg;
}
}
if (gpio_is_valid(ddata->ext_te_gpio)) {
r = devm_gpio_request_one(dev, ddata->ext_te_gpio,
GPIOF_IN, "taal irq");
if (r) {
dev_err(dev, "GPIO request failed\n");
goto err_reg;
}
r = devm_request_irq(dev, gpio_to_irq(ddata->ext_te_gpio),
dsicm_te_isr, dsicm_te_isr,
IRQF_TRIGGER_RISING, IRQF_TRIGGER_RISING,
"taal vsync", ddata); "taal vsync", ddata);
......
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