Lines Matching +full:de +full:- +full:asserts

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * LCD driver for MIPI DBI-C / DCS compatible LCDs
16 #include <linux/platform_data/lcd-mipid.h>
64 BUG_ON(md->spi == NULL); in mipid_transfer()
72 x->tx_buf = &cmd; in mipid_transfer()
73 x->bits_per_word = 9; in mipid_transfer()
74 x->len = 2; in mipid_transfer()
79 x->tx_buf = wbuf; in mipid_transfer()
80 x->len = wlen; in mipid_transfer()
81 x->bits_per_word = 9; in mipid_transfer()
87 x->rx_buf = &w; in mipid_transfer()
88 x->len = 1; in mipid_transfer()
95 x->bits_per_word = 9; in mipid_transfer()
96 x->len = 2; in mipid_transfer()
99 x->rx_buf = &rbuf[1]; in mipid_transfer()
100 x->len = rlen - 1; in mipid_transfer()
105 r = spi_sync(md->spi, &m); in mipid_transfer()
107 dev_dbg(&md->spi->dev, "spi_sync %d\n", r); in mipid_transfer()
153 set_data_lines(md, md->panel.data_lines); in send_init_string()
158 md->hw_guard_wait = msecs_to_jiffies(guard_msec); in hw_guard_start()
159 md->hw_guard_end = jiffies + md->hw_guard_wait; in hw_guard_start()
164 unsigned long wait = md->hw_guard_end - jiffies; in hw_guard_wait()
166 if ((long)wait > 0 && time_before_eq(wait, md->hw_guard_wait)) { in hw_guard_wait()
204 struct mipid_platform_data *pd = md->spi->dev.platform_data; in mipid_set_bklight_level()
206 if (pd->get_bklight_max == NULL || pd->set_bklight_level == NULL) in mipid_set_bklight_level()
207 return -ENODEV; in mipid_set_bklight_level()
208 if (level > pd->get_bklight_max(pd)) in mipid_set_bklight_level()
209 return -EINVAL; in mipid_set_bklight_level()
210 if (!md->enabled) { in mipid_set_bklight_level()
211 md->saved_bklight_level = level; in mipid_set_bklight_level()
214 pd->set_bklight_level(pd, level); in mipid_set_bklight_level()
222 struct mipid_platform_data *pd = md->spi->dev.platform_data; in mipid_get_bklight_level()
224 if (pd->get_bklight_level == NULL) in mipid_get_bklight_level()
225 return -ENODEV; in mipid_get_bklight_level()
226 return pd->get_bklight_level(pd); in mipid_get_bklight_level()
232 struct mipid_platform_data *pd = md->spi->dev.platform_data; in mipid_get_bklight_max()
234 if (pd->get_bklight_max == NULL) in mipid_get_bklight_max()
235 return -ENODEV; in mipid_get_bklight_max()
237 return pd->get_bklight_max(pd); in mipid_get_bklight_max()
250 mutex_lock(&md->mutex); in read_first_pixel()
254 mutex_unlock(&md->mutex); in read_first_pixel()
256 switch (md->panel.data_lines) { in read_first_pixel()
261 /* 24 bit -> 16 bit */ in read_first_pixel()
288 omapfb_write_first_pixel(md->fbdev, test_values[i]); in mipid_run_test()
299 dev_err(&md->spi->dev, in mipid_run_test()
314 dev_err(&md->spi->dev, "performing LCD ESD recovery\n"); in ls041y3_esd_recover()
326 dev_dbg(&md->spi->dev, "ESD mode 1 state1 %02x state2 %02x\n", in ls041y3_esd_check_mode1()
355 mipid_write(md, rd->cmd, (u8 *)rd->wbuf, rd->wlen); in ls041y3_esd_check_mode2()
358 mipid_read(md, rd->cmd, rbuf, 2); in ls041y3_esd_check_mode2()
363 mipid_write(md, rd->cmd, (u8 *)rd->wbuf, rd->wlen); in ls041y3_esd_check_mode2()
366 dev_dbg(&md->spi->dev, "ESD mode 2 state %02x\n", rbuf[1]); in ls041y3_esd_check_mode2()
374 if (md->revision >= 0x88) in ls041y3_esd_check()
380 if (md->esd_check != NULL) in mipid_esd_start_check()
381 schedule_delayed_work(&md->esd_work, in mipid_esd_start_check()
387 if (md->esd_check != NULL) in mipid_esd_stop_check()
388 cancel_delayed_work_sync(&md->esd_work); in mipid_esd_stop_check()
396 mutex_lock(&md->mutex); in mipid_esd_work()
397 md->esd_check(md); in mipid_esd_work()
398 mutex_unlock(&md->mutex); in mipid_esd_work()
406 mutex_lock(&md->mutex); in mipid_enable()
408 if (md->enabled) { in mipid_enable()
409 mutex_unlock(&md->mutex); in mipid_enable()
413 md->enabled = 1; in mipid_enable()
416 mipid_set_bklight_level(panel, md->saved_bklight_level); in mipid_enable()
419 mutex_unlock(&md->mutex); in mipid_enable()
432 mutex_lock(&md->mutex); in mipid_disable()
434 if (!md->enabled) { in mipid_disable()
435 mutex_unlock(&md->mutex); in mipid_disable()
438 md->saved_bklight_level = mipid_get_bklight_level(panel); in mipid_disable()
442 md->enabled = 0; in mipid_disable()
444 mutex_unlock(&md->mutex); in mipid_disable()
455 dev_dbg(&md->spi->dev, in panel_enabled()
466 md->fbdev = fbdev; in mipid_init()
467 INIT_DELAYED_WORK(&md->esd_work, mipid_esd_work); in mipid_init()
468 mutex_init(&md->mutex); in mipid_init()
470 md->enabled = panel_enabled(md); in mipid_init()
472 if (md->enabled) in mipid_init()
475 md->saved_bklight_level = mipid_get_bklight_level(panel); in mipid_init()
484 if (md->enabled) in mipid_cleanup()
518 pdata = md->spi->dev.platform_data; in mipid_detect()
520 dev_err(&md->spi->dev, "missing platform data\n"); in mipid_detect()
521 return -ENOENT; in mipid_detect()
525 dev_dbg(&md->spi->dev, "MIPI display ID: %02x%02x%02x\n", in mipid_detect()
530 md->panel.name = "lph8923"; in mipid_detect()
533 md->panel.name = "ls041y3"; in mipid_detect()
534 md->esd_check = ls041y3_esd_check; in mipid_detect()
537 md->panel.name = "unknown"; in mipid_detect()
538 dev_err(&md->spi->dev, "invalid display ID\n"); in mipid_detect()
539 return -ENODEV; in mipid_detect()
542 md->revision = display_id[1]; in mipid_detect()
543 md->panel.data_lines = pdata->data_lines; in mipid_detect()
545 md->panel.name, md->revision, md->panel.data_lines); in mipid_detect()
557 dev_err(&spi->dev, "out of memory\n"); in mipid_spi_probe()
558 return -ENOMEM; in mipid_spi_probe()
561 /* This will de-assert RESET if active */ in mipid_spi_probe()
562 md->reset = gpiod_get(&spi->dev, "reset", GPIOD_OUT_LOW); in mipid_spi_probe()
563 if (IS_ERR(md->reset)) in mipid_spi_probe()
564 return dev_err_probe(&spi->dev, PTR_ERR(md->reset), in mipid_spi_probe()
567 spi->mode = SPI_MODE_0; in mipid_spi_probe()
568 md->spi = spi; in mipid_spi_probe()
569 dev_set_drvdata(&spi->dev, md); in mipid_spi_probe()
570 md->panel = mipid_panel; in mipid_spi_probe()
576 omapfb_register_panel(&md->panel); in mipid_spi_probe()
587 struct mipid_device *md = dev_get_drvdata(&spi->dev); in mipid_spi_remove()
589 /* Asserts RESET */ in mipid_spi_remove()
590 gpiod_set_value(md->reset, 1); in mipid_spi_remove()
591 mipid_disable(&md->panel); in mipid_spi_remove()