Lines Matching +full:panel +full:- +full:dpi
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * TPO TD043MTEA1 Panel driver
113 dev_warn(&spi->dev, "failed to write to LCD reg (%d)\n", r); in tpo_td043_write()
153 struct panel_drv_data *ddata = dev_get_drvdata(dssdev->dev); in tpo_td043_set_hmirror()
155 ddata->hmirror = enable; in tpo_td043_set_hmirror()
156 return tpo_td043_write_mirror(ddata->spi, ddata->hmirror, in tpo_td043_set_hmirror()
157 ddata->vmirror); in tpo_td043_set_hmirror()
162 struct panel_drv_data *ddata = dev_get_drvdata(dssdev->dev); in tpo_td043_get_hmirror()
164 return ddata->hmirror; in tpo_td043_get_hmirror()
172 return snprintf(buf, PAGE_SIZE, "%d\n", ddata->vmirror); in tpo_td043_vmirror_show()
188 ret = tpo_td043_write_mirror(ddata->spi, ddata->hmirror, val); in tpo_td043_vmirror_store()
192 ddata->vmirror = val; in tpo_td043_vmirror_store()
202 return snprintf(buf, PAGE_SIZE, "%d\n", ddata->mode); in tpo_td043_mode_show()
214 return -EINVAL; in tpo_td043_mode_store()
216 ddata->mode = val; in tpo_td043_mode_store()
219 tpo_td043_write(ddata->spi, 2, val); in tpo_td043_mode_store()
232 for (i = 0; i < ARRAY_SIZE(ddata->gamma); i++) { in tpo_td043_gamma_show()
233 ret = snprintf(buf + len, PAGE_SIZE - len, "%u ", in tpo_td043_gamma_show()
234 ddata->gamma[i]); in tpo_td043_gamma_show()
239 buf[len - 1] = '\n'; in tpo_td043_gamma_show()
257 return -EINVAL; in tpo_td043_gamma_store()
260 ddata->gamma[i] = g[i]; in tpo_td043_gamma_store()
262 tpo_td043_write_gamma(ddata->spi, ddata->gamma); in tpo_td043_gamma_store()
289 if (ddata->powered_on) in tpo_td043_power_on()
292 r = regulator_enable(ddata->vcc_reg); in tpo_td043_power_on()
296 /* wait for panel to stabilize */ in tpo_td043_power_on()
299 if (gpio_is_valid(ddata->nreset_gpio)) in tpo_td043_power_on()
300 gpio_set_value(ddata->nreset_gpio, 1); in tpo_td043_power_on()
302 tpo_td043_write(ddata->spi, 2, in tpo_td043_power_on()
303 TPO_R02_MODE(ddata->mode) | TPO_R02_NCLK_RISING); in tpo_td043_power_on()
304 tpo_td043_write(ddata->spi, 3, TPO_R03_VAL_NORMAL); in tpo_td043_power_on()
305 tpo_td043_write(ddata->spi, 0x20, 0xf0); in tpo_td043_power_on()
306 tpo_td043_write(ddata->spi, 0x21, 0xf0); in tpo_td043_power_on()
307 tpo_td043_write_mirror(ddata->spi, ddata->hmirror, in tpo_td043_power_on()
308 ddata->vmirror); in tpo_td043_power_on()
309 tpo_td043_write_gamma(ddata->spi, ddata->gamma); in tpo_td043_power_on()
311 ddata->powered_on = 1; in tpo_td043_power_on()
317 if (!ddata->powered_on) in tpo_td043_power_off()
320 tpo_td043_write(ddata->spi, 3, in tpo_td043_power_off()
323 if (gpio_is_valid(ddata->nreset_gpio)) in tpo_td043_power_off()
324 gpio_set_value(ddata->nreset_gpio, 0); in tpo_td043_power_off()
329 tpo_td043_write(ddata->spi, 3, TPO_R03_VAL_STANDBY); in tpo_td043_power_off()
331 regulator_disable(ddata->vcc_reg); in tpo_td043_power_off()
333 ddata->powered_on = 0; in tpo_td043_power_off()
339 struct omap_dss_device *in = ddata->in; in tpo_td043_connect()
345 r = in->ops.dpi->connect(in, dssdev); in tpo_td043_connect()
355 struct omap_dss_device *in = ddata->in; in tpo_td043_disconnect()
360 in->ops.dpi->disconnect(in, dssdev); in tpo_td043_disconnect()
366 struct omap_dss_device *in = ddata->in; in tpo_td043_enable()
370 return -ENODEV; in tpo_td043_enable()
375 if (ddata->data_lines) in tpo_td043_enable()
376 in->ops.dpi->set_data_lines(in, ddata->data_lines); in tpo_td043_enable()
377 in->ops.dpi->set_timings(in, &ddata->videomode); in tpo_td043_enable()
379 r = in->ops.dpi->enable(in); in tpo_td043_enable()
387 if (!ddata->spi_suspended) { in tpo_td043_enable()
390 in->ops.dpi->disable(in); in tpo_td043_enable()
395 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; in tpo_td043_enable()
403 struct omap_dss_device *in = ddata->in; in tpo_td043_disable()
408 in->ops.dpi->disable(in); in tpo_td043_disable()
410 if (!ddata->spi_suspended) in tpo_td043_disable()
413 dssdev->state = OMAP_DSS_DISPLAY_DISABLED; in tpo_td043_disable()
420 struct omap_dss_device *in = ddata->in; in tpo_td043_set_timings()
422 ddata->videomode = *timings; in tpo_td043_set_timings()
423 dssdev->panel.timings = *timings; in tpo_td043_set_timings()
425 in->ops.dpi->set_timings(in, timings); in tpo_td043_set_timings()
433 *timings = ddata->videomode; in tpo_td043_get_timings()
440 struct omap_dss_device *in = ddata->in; in tpo_td043_check_timings()
442 return in->ops.dpi->check_timings(in, timings); in tpo_td043_check_timings()
465 struct device_node *node = spi->dev.of_node; in tpo_td043_probe_of()
466 struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev); in tpo_td043_probe_of()
470 gpio = of_get_named_gpio(node, "reset-gpios", 0); in tpo_td043_probe_of()
472 dev_err(&spi->dev, "failed to parse enable gpio\n"); in tpo_td043_probe_of()
475 ddata->nreset_gpio = gpio; in tpo_td043_probe_of()
479 dev_err(&spi->dev, "failed to find video source\n"); in tpo_td043_probe_of()
483 ddata->in = in; in tpo_td043_probe_of()
494 dev_dbg(&spi->dev, "%s\n", __func__); in tpo_td043_probe()
496 if (!spi->dev.of_node) in tpo_td043_probe()
497 return -ENODEV; in tpo_td043_probe()
499 spi->bits_per_word = 16; in tpo_td043_probe()
500 spi->mode = SPI_MODE_0; in tpo_td043_probe()
504 dev_err(&spi->dev, "spi_setup failed: %d\n", r); in tpo_td043_probe()
508 ddata = devm_kzalloc(&spi->dev, sizeof(*ddata), GFP_KERNEL); in tpo_td043_probe()
510 return -ENOMEM; in tpo_td043_probe()
512 dev_set_drvdata(&spi->dev, ddata); in tpo_td043_probe()
514 ddata->spi = spi; in tpo_td043_probe()
520 ddata->mode = TPO_R02_MODE_800x480; in tpo_td043_probe()
521 memcpy(ddata->gamma, tpo_td043_def_gamma, sizeof(ddata->gamma)); in tpo_td043_probe()
523 ddata->vcc_reg = devm_regulator_get(&spi->dev, "vcc"); in tpo_td043_probe()
524 if (IS_ERR(ddata->vcc_reg)) { in tpo_td043_probe()
525 dev_err(&spi->dev, "failed to get LCD VCC regulator\n"); in tpo_td043_probe()
526 r = PTR_ERR(ddata->vcc_reg); in tpo_td043_probe()
530 if (gpio_is_valid(ddata->nreset_gpio)) { in tpo_td043_probe()
531 r = devm_gpio_request_one(&spi->dev, in tpo_td043_probe()
532 ddata->nreset_gpio, GPIOF_OUT_INIT_LOW, in tpo_td043_probe()
535 dev_err(&spi->dev, "couldn't request reset GPIO\n"); in tpo_td043_probe()
540 r = sysfs_create_group(&spi->dev.kobj, &tpo_td043_attr_group); in tpo_td043_probe()
542 dev_err(&spi->dev, "failed to create sysfs files\n"); in tpo_td043_probe()
546 ddata->videomode = tpo_td043_timings; in tpo_td043_probe()
548 dssdev = &ddata->dssdev; in tpo_td043_probe()
549 dssdev->dev = &spi->dev; in tpo_td043_probe()
550 dssdev->driver = &tpo_td043_ops; in tpo_td043_probe()
551 dssdev->type = OMAP_DISPLAY_TYPE_DPI; in tpo_td043_probe()
552 dssdev->owner = THIS_MODULE; in tpo_td043_probe()
553 dssdev->panel.timings = ddata->videomode; in tpo_td043_probe()
557 dev_err(&spi->dev, "Failed to register panel\n"); in tpo_td043_probe()
564 sysfs_remove_group(&spi->dev.kobj, &tpo_td043_attr_group); in tpo_td043_probe()
568 omap_dss_put_device(ddata->in); in tpo_td043_probe()
574 struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev); in tpo_td043_remove()
575 struct omap_dss_device *dssdev = &ddata->dssdev; in tpo_td043_remove()
576 struct omap_dss_device *in = ddata->in; in tpo_td043_remove()
578 dev_dbg(&ddata->spi->dev, "%s\n", __func__); in tpo_td043_remove()
587 sysfs_remove_group(&spi->dev.kobj, &tpo_td043_attr_group); in tpo_td043_remove()
599 ddata->power_on_resume = ddata->powered_on; in tpo_td043_spi_suspend()
601 ddata->spi_suspended = 1; in tpo_td043_spi_suspend()
613 if (ddata->power_on_resume) { in tpo_td043_spi_resume()
618 ddata->spi_suspended = 0; in tpo_td043_spi_resume()
636 .name = "panel-tpo-td043mtea1",