Lines Matching +full:panel +full:- +full:dpi
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * TPO TD043MTEA1 Panel driver
112 dev_warn(&spi->dev, "failed to write to LCD reg (%d)\n", r); in tpo_td043_write()
152 struct panel_drv_data *ddata = dev_get_drvdata(dssdev->dev); in tpo_td043_set_hmirror()
154 ddata->hmirror = enable; in tpo_td043_set_hmirror()
155 return tpo_td043_write_mirror(ddata->spi, ddata->hmirror, in tpo_td043_set_hmirror()
156 ddata->vmirror); in tpo_td043_set_hmirror()
161 struct panel_drv_data *ddata = dev_get_drvdata(dssdev->dev); in tpo_td043_get_hmirror()
163 return ddata->hmirror; in tpo_td043_get_hmirror()
171 return sysfs_emit(buf, "%d\n", ddata->vmirror); in tpo_td043_vmirror_show()
187 ret = tpo_td043_write_mirror(ddata->spi, ddata->hmirror, val); in tpo_td043_vmirror_store()
191 ddata->vmirror = val; in tpo_td043_vmirror_store()
201 return sysfs_emit(buf, "%d\n", ddata->mode); in tpo_td043_mode_show()
213 return -EINVAL; in tpo_td043_mode_store()
215 ddata->mode = val; in tpo_td043_mode_store()
218 tpo_td043_write(ddata->spi, 2, val); in tpo_td043_mode_store()
230 for (i = 0; i < ARRAY_SIZE(ddata->gamma); i++) in tpo_td043_gamma_show()
231 len += sysfs_emit_at(buf, len, "%u ", ddata->gamma[i]); in tpo_td043_gamma_show()
233 buf[len - 1] = '\n'; in tpo_td043_gamma_show()
251 return -EINVAL; in tpo_td043_gamma_store()
254 ddata->gamma[i] = g[i]; in tpo_td043_gamma_store()
256 tpo_td043_write_gamma(ddata->spi, ddata->gamma); in tpo_td043_gamma_store()
283 if (ddata->powered_on) in tpo_td043_power_on()
286 r = regulator_enable(ddata->vcc_reg); in tpo_td043_power_on()
290 /* wait for panel to stabilize */ in tpo_td043_power_on()
293 gpiod_set_value_cansleep(ddata->reset_gpio, 0); in tpo_td043_power_on()
295 tpo_td043_write(ddata->spi, 2, in tpo_td043_power_on()
296 TPO_R02_MODE(ddata->mode) | TPO_R02_NCLK_RISING); in tpo_td043_power_on()
297 tpo_td043_write(ddata->spi, 3, TPO_R03_VAL_NORMAL); in tpo_td043_power_on()
298 tpo_td043_write(ddata->spi, 0x20, 0xf0); in tpo_td043_power_on()
299 tpo_td043_write(ddata->spi, 0x21, 0xf0); in tpo_td043_power_on()
300 tpo_td043_write_mirror(ddata->spi, ddata->hmirror, in tpo_td043_power_on()
301 ddata->vmirror); in tpo_td043_power_on()
302 tpo_td043_write_gamma(ddata->spi, ddata->gamma); in tpo_td043_power_on()
304 ddata->powered_on = 1; in tpo_td043_power_on()
310 if (!ddata->powered_on) in tpo_td043_power_off()
313 tpo_td043_write(ddata->spi, 3, in tpo_td043_power_off()
316 gpiod_set_value_cansleep(ddata->reset_gpio, 1); in tpo_td043_power_off()
321 tpo_td043_write(ddata->spi, 3, TPO_R03_VAL_STANDBY); in tpo_td043_power_off()
323 regulator_disable(ddata->vcc_reg); in tpo_td043_power_off()
325 ddata->powered_on = 0; in tpo_td043_power_off()
331 struct omap_dss_device *in = ddata->in; in tpo_td043_connect()
336 return in->ops.dpi->connect(in, dssdev); in tpo_td043_connect()
342 struct omap_dss_device *in = ddata->in; in tpo_td043_disconnect()
347 in->ops.dpi->disconnect(in, dssdev); in tpo_td043_disconnect()
353 struct omap_dss_device *in = ddata->in; in tpo_td043_enable()
357 return -ENODEV; in tpo_td043_enable()
362 if (ddata->data_lines) in tpo_td043_enable()
363 in->ops.dpi->set_data_lines(in, ddata->data_lines); in tpo_td043_enable()
364 in->ops.dpi->set_timings(in, &ddata->videomode); in tpo_td043_enable()
366 r = in->ops.dpi->enable(in); in tpo_td043_enable()
374 if (!ddata->spi_suspended) { in tpo_td043_enable()
377 in->ops.dpi->disable(in); in tpo_td043_enable()
382 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; in tpo_td043_enable()
390 struct omap_dss_device *in = ddata->in; in tpo_td043_disable()
395 in->ops.dpi->disable(in); in tpo_td043_disable()
397 if (!ddata->spi_suspended) in tpo_td043_disable()
400 dssdev->state = OMAP_DSS_DISPLAY_DISABLED; in tpo_td043_disable()
407 struct omap_dss_device *in = ddata->in; in tpo_td043_set_timings()
409 ddata->videomode = *timings; in tpo_td043_set_timings()
410 dssdev->panel.timings = *timings; in tpo_td043_set_timings()
412 in->ops.dpi->set_timings(in, timings); in tpo_td043_set_timings()
420 *timings = ddata->videomode; in tpo_td043_get_timings()
427 struct omap_dss_device *in = ddata->in; in tpo_td043_check_timings()
429 return in->ops.dpi->check_timings(in, timings); in tpo_td043_check_timings()
455 dev_dbg(&spi->dev, "%s\n", __func__); in tpo_td043_probe()
457 if (!spi->dev.of_node) in tpo_td043_probe()
458 return -ENODEV; in tpo_td043_probe()
460 spi->bits_per_word = 16; in tpo_td043_probe()
461 spi->mode = SPI_MODE_0; in tpo_td043_probe()
465 dev_err(&spi->dev, "spi_setup failed: %d\n", r); in tpo_td043_probe()
469 ddata = devm_kzalloc(&spi->dev, sizeof(*ddata), GFP_KERNEL); in tpo_td043_probe()
471 return -ENOMEM; in tpo_td043_probe()
473 dev_set_drvdata(&spi->dev, ddata); in tpo_td043_probe()
475 ddata->spi = spi; in tpo_td043_probe()
477 ddata->in = omapdss_of_find_source_for_first_ep(spi->dev.of_node); in tpo_td043_probe()
478 r = PTR_ERR_OR_ZERO(ddata->in); in tpo_td043_probe()
480 dev_err(&spi->dev, "failed to find video source: %d\n", r); in tpo_td043_probe()
484 ddata->mode = TPO_R02_MODE_800x480; in tpo_td043_probe()
485 memcpy(ddata->gamma, tpo_td043_def_gamma, sizeof(ddata->gamma)); in tpo_td043_probe()
487 ddata->vcc_reg = devm_regulator_get(&spi->dev, "vcc"); in tpo_td043_probe()
488 if (IS_ERR(ddata->vcc_reg)) { in tpo_td043_probe()
489 r = dev_err_probe(&spi->dev, PTR_ERR(ddata->vcc_reg), in tpo_td043_probe()
494 ddata->reset_gpio = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_HIGH); in tpo_td043_probe()
495 r = PTR_ERR_OR_ZERO(ddata->reset_gpio); in tpo_td043_probe()
497 dev_err(&spi->dev, "couldn't request reset GPIO\n"); in tpo_td043_probe()
501 gpiod_set_consumer_name(ddata->reset_gpio, "lcd reset"); in tpo_td043_probe()
503 r = sysfs_create_group(&spi->dev.kobj, &tpo_td043_attr_group); in tpo_td043_probe()
505 dev_err(&spi->dev, "failed to create sysfs files\n"); in tpo_td043_probe()
509 ddata->videomode = tpo_td043_timings; in tpo_td043_probe()
511 dssdev = &ddata->dssdev; in tpo_td043_probe()
512 dssdev->dev = &spi->dev; in tpo_td043_probe()
513 dssdev->driver = &tpo_td043_ops; in tpo_td043_probe()
514 dssdev->type = OMAP_DISPLAY_TYPE_DPI; in tpo_td043_probe()
515 dssdev->owner = THIS_MODULE; in tpo_td043_probe()
516 dssdev->panel.timings = ddata->videomode; in tpo_td043_probe()
520 dev_err(&spi->dev, "Failed to register panel\n"); in tpo_td043_probe()
527 sysfs_remove_group(&spi->dev.kobj, &tpo_td043_attr_group); in tpo_td043_probe()
531 omap_dss_put_device(ddata->in); in tpo_td043_probe()
537 struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev); in tpo_td043_remove()
538 struct omap_dss_device *dssdev = &ddata->dssdev; in tpo_td043_remove()
539 struct omap_dss_device *in = ddata->in; in tpo_td043_remove()
541 dev_dbg(&ddata->spi->dev, "%s\n", __func__); in tpo_td043_remove()
550 sysfs_remove_group(&spi->dev.kobj, &tpo_td043_attr_group); in tpo_td043_remove()
560 ddata->power_on_resume = ddata->powered_on; in tpo_td043_spi_suspend()
562 ddata->spi_suspended = 1; in tpo_td043_spi_suspend()
574 if (ddata->power_on_resume) { in tpo_td043_spi_resume()
579 ddata->spi_suspended = 0; in tpo_td043_spi_resume()
597 .name = "panel-tpo-td043mtea1",