aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/video/omap2/displays/panel-tpo-td043mtea1.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/drivers/video/omap2/displays/panel-tpo-td043mtea1.c b/drivers/video/omap2/displays/panel-tpo-td043mtea1.c
index 048c98381ef6..e3252bf4781a 100644
--- a/drivers/video/omap2/displays/panel-tpo-td043mtea1.c
+++ b/drivers/video/omap2/displays/panel-tpo-td043mtea1.c
@@ -18,6 +18,7 @@
18#include <linux/slab.h> 18#include <linux/slab.h>
19 19
20#include <video/omapdss.h> 20#include <video/omapdss.h>
21#include <video/omap-panel-data.h>
21 22
22#define TPO_R02_MODE(x) ((x) & 7) 23#define TPO_R02_MODE(x) ((x) & 7)
23#define TPO_R02_MODE_800x480 7 24#define TPO_R02_MODE_800x480 7
@@ -278,9 +279,14 @@ static const struct omap_video_timings tpo_td043_timings = {
278 .sync_pclk_edge = OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES, 279 .sync_pclk_edge = OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES,
279}; 280};
280 281
282static inline struct panel_tpo_td043_data
283*get_panel_data(const struct omap_dss_device *dssdev)
284{
285 return (struct panel_tpo_td043_data *) dssdev->data;
286}
287
281static int tpo_td043_power_on(struct tpo_td043_device *tpo_td043) 288static int tpo_td043_power_on(struct tpo_td043_device *tpo_td043)
282{ 289{
283 int nreset_gpio = tpo_td043->nreset_gpio;
284 int r; 290 int r;
285 291
286 if (tpo_td043->powered_on) 292 if (tpo_td043->powered_on)
@@ -293,8 +299,8 @@ static int tpo_td043_power_on(struct tpo_td043_device *tpo_td043)
293 /* wait for panel to stabilize */ 299 /* wait for panel to stabilize */
294 msleep(160); 300 msleep(160);
295 301
296 if (gpio_is_valid(nreset_gpio)) 302 if (gpio_is_valid(tpo_td043->nreset_gpio))
297 gpio_set_value(nreset_gpio, 1); 303 gpio_set_value(tpo_td043->nreset_gpio, 1);
298 304
299 tpo_td043_write(tpo_td043->spi, 2, 305 tpo_td043_write(tpo_td043->spi, 2,
300 TPO_R02_MODE(tpo_td043->mode) | TPO_R02_NCLK_RISING); 306 TPO_R02_MODE(tpo_td043->mode) | TPO_R02_NCLK_RISING);
@@ -311,16 +317,14 @@ static int tpo_td043_power_on(struct tpo_td043_device *tpo_td043)
311 317
312static void tpo_td043_power_off(struct tpo_td043_device *tpo_td043) 318static void tpo_td043_power_off(struct tpo_td043_device *tpo_td043)
313{ 319{
314 int nreset_gpio = tpo_td043->nreset_gpio;
315
316 if (!tpo_td043->powered_on) 320 if (!tpo_td043->powered_on)
317 return; 321 return;
318 322
319 tpo_td043_write(tpo_td043->spi, 3, 323 tpo_td043_write(tpo_td043->spi, 3,
320 TPO_R03_VAL_STANDBY | TPO_R03_EN_PWM); 324 TPO_R03_VAL_STANDBY | TPO_R03_EN_PWM);
321 325
322 if (gpio_is_valid(nreset_gpio)) 326 if (gpio_is_valid(tpo_td043->nreset_gpio))
323 gpio_set_value(nreset_gpio, 0); 327 gpio_set_value(tpo_td043->nreset_gpio, 0);
324 328
325 /* wait for at least 2 vsyncs before cutting off power */ 329 /* wait for at least 2 vsyncs before cutting off power */
326 msleep(50); 330 msleep(50);
@@ -407,7 +411,7 @@ static void tpo_td043_disable(struct omap_dss_device *dssdev)
407static int tpo_td043_probe(struct omap_dss_device *dssdev) 411static int tpo_td043_probe(struct omap_dss_device *dssdev)
408{ 412{
409 struct tpo_td043_device *tpo_td043 = g_tpo_td043; 413 struct tpo_td043_device *tpo_td043 = g_tpo_td043;
410 int nreset_gpio = dssdev->reset_gpio; 414 struct panel_tpo_td043_data *pdata = get_panel_data(dssdev);
411 int ret = 0; 415 int ret = 0;
412 416
413 dev_dbg(&dssdev->dev, "probe\n"); 417 dev_dbg(&dssdev->dev, "probe\n");
@@ -417,6 +421,11 @@ static int tpo_td043_probe(struct omap_dss_device *dssdev)
417 return -ENODEV; 421 return -ENODEV;
418 } 422 }
419 423
424 if (!pdata)
425 return -EINVAL;
426
427 tpo_td043->nreset_gpio = pdata->nreset_gpio;
428
420 dssdev->panel.timings = tpo_td043_timings; 429 dssdev->panel.timings = tpo_td043_timings;
421 dssdev->ctrl.pixel_size = 24; 430 dssdev->ctrl.pixel_size = 24;
422 431
@@ -430,9 +439,10 @@ static int tpo_td043_probe(struct omap_dss_device *dssdev)
430 goto fail_regulator; 439 goto fail_regulator;
431 } 440 }
432 441
433 if (gpio_is_valid(nreset_gpio)) { 442 if (gpio_is_valid(tpo_td043->nreset_gpio)) {
434 ret = gpio_request_one(nreset_gpio, GPIOF_OUT_INIT_LOW, 443 ret = devm_gpio_request_one(&dssdev->dev,
435 "lcd reset"); 444 tpo_td043->nreset_gpio, GPIOF_OUT_INIT_LOW,
445 "lcd reset");
436 if (ret < 0) { 446 if (ret < 0) {
437 dev_err(&dssdev->dev, "couldn't request reset GPIO\n"); 447 dev_err(&dssdev->dev, "couldn't request reset GPIO\n");
438 goto fail_gpio_req; 448 goto fail_gpio_req;
@@ -457,14 +467,11 @@ fail_regulator:
457static void tpo_td043_remove(struct omap_dss_device *dssdev) 467static void tpo_td043_remove(struct omap_dss_device *dssdev)
458{ 468{
459 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(&dssdev->dev); 469 struct tpo_td043_device *tpo_td043 = dev_get_drvdata(&dssdev->dev);
460 int nreset_gpio = dssdev->reset_gpio;
461 470
462 dev_dbg(&dssdev->dev, "remove\n"); 471 dev_dbg(&dssdev->dev, "remove\n");
463 472
464 sysfs_remove_group(&dssdev->dev.kobj, &tpo_td043_attr_group); 473 sysfs_remove_group(&dssdev->dev.kobj, &tpo_td043_attr_group);
465 regulator_put(tpo_td043->vcc_reg); 474 regulator_put(tpo_td043->vcc_reg);
466 if (gpio_is_valid(nreset_gpio))
467 gpio_free(nreset_gpio);
468} 475}
469 476
470static void tpo_td043_set_timings(struct omap_dss_device *dssdev, 477static void tpo_td043_set_timings(struct omap_dss_device *dssdev,
@@ -527,7 +534,6 @@ static int tpo_td043_spi_probe(struct spi_device *spi)
527 return -ENOMEM; 534 return -ENOMEM;
528 535
529 tpo_td043->spi = spi; 536 tpo_td043->spi = spi;
530 tpo_td043->nreset_gpio = dssdev->reset_gpio;
531 dev_set_drvdata(&spi->dev, tpo_td043); 537 dev_set_drvdata(&spi->dev, tpo_td043);
532 g_tpo_td043 = tpo_td043; 538 g_tpo_td043 = tpo_td043;
533 539