Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

OMAPDSS: tpo-td043 panel: handle gpios in panel driver

The tpo-td043mtea1 panel driver leaves gpio configurations to the
platform_enable and disable calls in the platform's board file. These should
happen in the panel driver itself.

Create a platform data struct for the panel, this contains the reset gpio
number used by the panel driver, this struct will be passed to the panel driver
as platform data. The driver will request and configure the reset gpio rather
than leaving it to platform callbacks in board files.

This will help in removing the need for the panel drivers to have platform
related callbacks.

Signed-off-by: Archit Taneja <archit@ti.com>

authored by

Archit Taneja and committed by
Tomi Valkeinen
7eab07e4 be9a0067

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