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
commite7df6571024ba791c6521efba5b3875724c47af6 (patch)
tree0c4e658f6e494d7e1bea7038389b600d1d2d3901
parent2167f9e28a30a4b129b2464fbc5ee8c15e254ff1 (diff)
drm/omap: panel-tpo-td043mtea1: 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. Rename the nreset_gpio field to reset_gpio to reflect that. The reset GPIO is mandatory, so drop conditional tests through 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/panel-tpo-td043mtea1.c52
1 files changed, 14 insertions, 38 deletions
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
index 34531169c166..1521812ab15b 100644
--- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
+++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
@@ -10,14 +10,13 @@
10 * (at your option) any later version. 10 * (at your option) any later version.
11 */ 11 */
12 12
13#include <linux/module.h>
14#include <linux/delay.h> 13#include <linux/delay.h>
15#include <linux/spi/spi.h>
16#include <linux/regulator/consumer.h>
17#include <linux/gpio/consumer.h>
18#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/gpio/consumer.h>
16#include <linux/module.h>
17#include <linux/regulator/consumer.h>
19#include <linux/slab.h> 18#include <linux/slab.h>
20#include <linux/of_gpio.h> 19#include <linux/spi/spi.h>
21 20
22#include "../dss/omapdss.h" 21#include "../dss/omapdss.h"
23 22
@@ -59,7 +58,7 @@ struct panel_drv_data {
59 58
60 struct spi_device *spi; 59 struct spi_device *spi;
61 struct regulator *vcc_reg; 60 struct regulator *vcc_reg;
62 int nreset_gpio; 61 struct gpio_desc *reset_gpio;
63 u16 gamma[12]; 62 u16 gamma[12];
64 u32 mode; 63 u32 mode;
65 u32 vmirror:1; 64 u32 vmirror:1;
@@ -282,8 +281,7 @@ static int tpo_td043_power_on(struct panel_drv_data *ddata)
282 /* wait for panel to stabilize */ 281 /* wait for panel to stabilize */
283 msleep(160); 282 msleep(160);
284 283
285 if (gpio_is_valid(ddata->nreset_gpio)) 284 gpiod_set_value(ddata->reset_gpio, 0);
286 gpio_set_value(ddata->nreset_gpio, 1);
287 285
288 tpo_td043_write(ddata->spi, 2, 286 tpo_td043_write(ddata->spi, 2,
289 TPO_R02_MODE(ddata->mode) | TPO_R02_NCLK_RISING); 287 TPO_R02_MODE(ddata->mode) | TPO_R02_NCLK_RISING);
@@ -305,8 +303,7 @@ static void tpo_td043_power_off(struct panel_drv_data *ddata)
305 tpo_td043_write(ddata->spi, 3, 303 tpo_td043_write(ddata->spi, 3,
306 TPO_R03_VAL_STANDBY | TPO_R03_EN_PWM); 304 TPO_R03_VAL_STANDBY | TPO_R03_EN_PWM);
307 305
308 if (gpio_is_valid(ddata->nreset_gpio)) 306 gpiod_set_value(ddata->reset_gpio, 1);
309 gpio_set_value(ddata->nreset_gpio, 0);
310 307
311 /* wait for at least 2 vsyncs before cutting off power */ 308 /* wait for at least 2 vsyncs before cutting off power */
312 msleep(50); 309 msleep(50);
@@ -419,26 +416,11 @@ static const struct omap_dss_driver tpo_td043_ops = {
419 .check_timings = tpo_td043_check_timings, 416 .check_timings = tpo_td043_check_timings,
420}; 417};
421 418
422static int tpo_td043_probe_of(struct spi_device *spi)
423{
424 struct device_node *node = spi->dev.of_node;
425 struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
426 int gpio;
427
428 gpio = of_get_named_gpio(node, "reset-gpios", 0);
429 if (!gpio_is_valid(gpio)) {
430 dev_err(&spi->dev, "failed to parse enable gpio\n");
431 return gpio;
432 }
433 ddata->nreset_gpio = gpio;
434
435 return 0;
436}
437
438static int tpo_td043_probe(struct spi_device *spi) 419static int tpo_td043_probe(struct spi_device *spi)
439{ 420{
440 struct panel_drv_data *ddata; 421 struct panel_drv_data *ddata;
441 struct omap_dss_device *dssdev; 422 struct omap_dss_device *dssdev;
423 struct gpio_desc *gpio;
442 int r; 424 int r;
443 425
444 dev_dbg(&spi->dev, "%s\n", __func__); 426 dev_dbg(&spi->dev, "%s\n", __func__);
@@ -460,10 +442,6 @@ static int tpo_td043_probe(struct spi_device *spi)
460 442
461 ddata->spi = spi; 443 ddata->spi = spi;
462 444
463 r = tpo_td043_probe_of(spi);
464 if (r)
465 return r;
466
467 ddata->mode = TPO_R02_MODE_800x480; 445 ddata->mode = TPO_R02_MODE_800x480;
468 memcpy(ddata->gamma, tpo_td043_def_gamma, sizeof(ddata->gamma)); 446 memcpy(ddata->gamma, tpo_td043_def_gamma, sizeof(ddata->gamma));
469 447
@@ -473,16 +451,14 @@ static int tpo_td043_probe(struct spi_device *spi)
473 return PTR_ERR(ddata->vcc_reg); 451 return PTR_ERR(ddata->vcc_reg);
474 } 452 }
475 453
476 if (gpio_is_valid(ddata->nreset_gpio)) { 454 gpio = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_HIGH);
477 r = devm_gpio_request_one(&spi->dev, 455 if (IS_ERR(gpio)) {
478 ddata->nreset_gpio, GPIOF_OUT_INIT_LOW, 456 dev_err(&spi->dev, "failed to get reset gpio\n");
479 "lcd reset"); 457 return PTR_ERR(gpio);
480 if (r < 0) {
481 dev_err(&spi->dev, "couldn't request reset GPIO\n");
482 return r;
483 }
484 } 458 }
485 459
460 ddata->reset_gpio = gpio;
461
486 r = sysfs_create_group(&spi->dev.kobj, &tpo_td043_attr_group); 462 r = sysfs_create_group(&spi->dev.kobj, &tpo_td043_attr_group);
487 if (r) { 463 if (r) {
488 dev_err(&spi->dev, "failed to create sysfs files\n"); 464 dev_err(&spi->dev, "failed to create sysfs files\n");