aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-05-28 10:18:26 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2018-09-03 09:13:28 -0400
commitac2d1fcbebd6e9ff3a5ef645f88611a6ba9b4ece (patch)
tree9d418bd6188737a222b0b7f9b557bed2f76ac0aa
parentede880e1825bfe267088afcf1c096ec62713f005 (diff)
drm/omap: encoder-tfp410: 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. As the descriptor API handles the active-low flag internally we need to invert the polarity of all GPIO operations in the driver. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r--drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c51
1 files changed, 13 insertions, 38 deletions
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
index 7114ea672e69..29bda16afbdc 100644
--- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
+++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
@@ -13,14 +13,13 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/of_gpio.h>
17 16
18#include "../dss/omapdss.h" 17#include "../dss/omapdss.h"
19 18
20struct panel_drv_data { 19struct panel_drv_data {
21 struct omap_dss_device dssdev; 20 struct omap_dss_device dssdev;
22 21
23 int pd_gpio; 22 struct gpio_desc *pd_gpio;
24 23
25 struct videomode vm; 24 struct videomode vm;
26}; 25};
@@ -57,8 +56,8 @@ static int tfp410_enable(struct omap_dss_device *dssdev)
57 if (r) 56 if (r)
58 return r; 57 return r;
59 58
60 if (gpio_is_valid(ddata->pd_gpio)) 59 if (ddata->pd_gpio)
61 gpio_set_value_cansleep(ddata->pd_gpio, 1); 60 gpiod_set_value_cansleep(ddata->pd_gpio, 0);
62 61
63 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; 62 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
64 63
@@ -73,8 +72,8 @@ static void tfp410_disable(struct omap_dss_device *dssdev)
73 if (!omapdss_device_is_enabled(dssdev)) 72 if (!omapdss_device_is_enabled(dssdev))
74 return; 73 return;
75 74
76 if (gpio_is_valid(ddata->pd_gpio)) 75 if (ddata->pd_gpio)
77 gpio_set_value_cansleep(ddata->pd_gpio, 0); 76 gpiod_set_value_cansleep(ddata->pd_gpio, 0);
78 77
79 src->ops->disable(src); 78 src->ops->disable(src);
80 79
@@ -119,30 +118,11 @@ static const struct omap_dss_device_ops tfp410_ops = {
119 .set_timings = tfp410_set_timings, 118 .set_timings = tfp410_set_timings,
120}; 119};
121 120
122static int tfp410_probe_of(struct platform_device *pdev)
123{
124 struct panel_drv_data *ddata = platform_get_drvdata(pdev);
125 struct device_node *node = pdev->dev.of_node;
126 int gpio;
127
128 gpio = of_get_named_gpio(node, "powerdown-gpios", 0);
129
130 if (gpio_is_valid(gpio) || gpio == -ENOENT) {
131 ddata->pd_gpio = gpio;
132 } else {
133 if (gpio != -EPROBE_DEFER)
134 dev_err(&pdev->dev, "failed to parse PD gpio\n");
135 return gpio;
136 }
137
138 return 0;
139}
140
141static int tfp410_probe(struct platform_device *pdev) 121static int tfp410_probe(struct platform_device *pdev)
142{ 122{
143 struct panel_drv_data *ddata; 123 struct panel_drv_data *ddata;
144 struct omap_dss_device *dssdev; 124 struct omap_dss_device *dssdev;
145 int r; 125 struct gpio_desc *gpio;
146 126
147 ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL); 127 ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
148 if (!ddata) 128 if (!ddata)
@@ -150,20 +130,15 @@ static int tfp410_probe(struct platform_device *pdev)
150 130
151 platform_set_drvdata(pdev, ddata); 131 platform_set_drvdata(pdev, ddata);
152 132
153 r = tfp410_probe_of(pdev); 133 /* Powerdown GPIO */
154 if (r) 134 gpio = devm_gpiod_get_optional(&pdev->dev, "powerdown", GPIOD_OUT_HIGH);
155 return r; 135 if (IS_ERR(gpio)) {
156 136 dev_err(&pdev->dev, "failed to parse powerdown gpio\n");
157 if (gpio_is_valid(ddata->pd_gpio)) { 137 return PTR_ERR(gpio);
158 r = devm_gpio_request_one(&pdev->dev, ddata->pd_gpio,
159 GPIOF_OUT_INIT_LOW, "tfp410 PD");
160 if (r) {
161 dev_err(&pdev->dev, "Failed to request PD GPIO %d\n",
162 ddata->pd_gpio);
163 return r;
164 }
165 } 138 }
166 139
140 ddata->pd_gpio = gpio;
141
167 dssdev = &ddata->dssdev; 142 dssdev = &ddata->dssdev;
168 dssdev->ops = &tfp410_ops; 143 dssdev->ops = &tfp410_ops;
169 dssdev->dev = &pdev->dev; 144 dssdev->dev = &pdev->dev;