Skip to content

Commit

Permalink
drm/omap: panel-tpo-td043mtea1: Convert to the GPIO descriptors API
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Laurent Pinchart authored and Tomi Valkeinen committed Sep 3, 2018
1 parent 2167f9e commit e7df657
Showing 1 changed file with 14 additions and 38 deletions.
52 changes: 14 additions & 38 deletions drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
* (at your option) any later version.
*/

#include <linux/module.h>
#include <linux/delay.h>
#include <linux/spi/spi.h>
#include <linux/regulator/consumer.h>
#include <linux/gpio/consumer.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/of_gpio.h>
#include <linux/spi/spi.h>

#include "../dss/omapdss.h"

Expand Down Expand Up @@ -59,7 +58,7 @@ struct panel_drv_data {

struct spi_device *spi;
struct regulator *vcc_reg;
int nreset_gpio;
struct gpio_desc *reset_gpio;
u16 gamma[12];
u32 mode;
u32 vmirror:1;
Expand Down Expand Up @@ -282,8 +281,7 @@ static int tpo_td043_power_on(struct panel_drv_data *ddata)
/* wait for panel to stabilize */
msleep(160);

if (gpio_is_valid(ddata->nreset_gpio))
gpio_set_value(ddata->nreset_gpio, 1);
gpiod_set_value(ddata->reset_gpio, 0);

tpo_td043_write(ddata->spi, 2,
TPO_R02_MODE(ddata->mode) | TPO_R02_NCLK_RISING);
Expand All @@ -305,8 +303,7 @@ static void tpo_td043_power_off(struct panel_drv_data *ddata)
tpo_td043_write(ddata->spi, 3,
TPO_R03_VAL_STANDBY | TPO_R03_EN_PWM);

if (gpio_is_valid(ddata->nreset_gpio))
gpio_set_value(ddata->nreset_gpio, 0);
gpiod_set_value(ddata->reset_gpio, 1);

/* wait for at least 2 vsyncs before cutting off power */
msleep(50);
Expand Down Expand Up @@ -419,26 +416,11 @@ static const struct omap_dss_driver tpo_td043_ops = {
.check_timings = tpo_td043_check_timings,
};

static int tpo_td043_probe_of(struct spi_device *spi)
{
struct device_node *node = spi->dev.of_node;
struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
int gpio;

gpio = of_get_named_gpio(node, "reset-gpios", 0);
if (!gpio_is_valid(gpio)) {
dev_err(&spi->dev, "failed to parse enable gpio\n");
return gpio;
}
ddata->nreset_gpio = gpio;

return 0;
}

static int tpo_td043_probe(struct spi_device *spi)
{
struct panel_drv_data *ddata;
struct omap_dss_device *dssdev;
struct gpio_desc *gpio;
int r;

dev_dbg(&spi->dev, "%s\n", __func__);
Expand All @@ -460,10 +442,6 @@ static int tpo_td043_probe(struct spi_device *spi)

ddata->spi = spi;

r = tpo_td043_probe_of(spi);
if (r)
return r;

ddata->mode = TPO_R02_MODE_800x480;
memcpy(ddata->gamma, tpo_td043_def_gamma, sizeof(ddata->gamma));

Expand All @@ -473,16 +451,14 @@ static int tpo_td043_probe(struct spi_device *spi)
return PTR_ERR(ddata->vcc_reg);
}

if (gpio_is_valid(ddata->nreset_gpio)) {
r = devm_gpio_request_one(&spi->dev,
ddata->nreset_gpio, GPIOF_OUT_INIT_LOW,
"lcd reset");
if (r < 0) {
dev_err(&spi->dev, "couldn't request reset GPIO\n");
return r;
}
gpio = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(gpio)) {
dev_err(&spi->dev, "failed to get reset gpio\n");
return PTR_ERR(gpio);
}

ddata->reset_gpio = gpio;

r = sysfs_create_group(&spi->dev.kobj, &tpo_td043_attr_group);
if (r) {
dev_err(&spi->dev, "failed to create sysfs files\n");
Expand Down

0 comments on commit e7df657

Please sign in to comment.