Lines Matching refs:md

54 static void mipid_transfer(struct mipid_device *md, int cmd, const u8 *wbuf,  in mipid_transfer()  argument
62 BUG_ON(md->spi == NULL); in mipid_transfer()
103 r = spi_sync(md->spi, &m); in mipid_transfer()
105 dev_dbg(&md->spi->dev, "spi_sync %d\n", r); in mipid_transfer()
111 static inline void mipid_cmd(struct mipid_device *md, int cmd) in mipid_cmd() argument
113 mipid_transfer(md, cmd, NULL, 0, NULL, 0); in mipid_cmd()
116 static inline void mipid_write(struct mipid_device *md, in mipid_write() argument
119 mipid_transfer(md, reg, buf, len, NULL, 0); in mipid_write()
122 static inline void mipid_read(struct mipid_device *md, in mipid_read() argument
125 mipid_transfer(md, reg, NULL, 0, buf, len); in mipid_read()
128 static void set_data_lines(struct mipid_device *md, int data_lines) in set_data_lines() argument
143 mipid_write(md, 0x3a, (u8 *)&par, 2); in set_data_lines()
146 static void send_init_string(struct mipid_device *md) in send_init_string() argument
150 mipid_write(md, 0xc2, (u8 *)initpar, sizeof(initpar)); in send_init_string()
151 set_data_lines(md, md->panel.data_lines); in send_init_string()
154 static void hw_guard_start(struct mipid_device *md, int guard_msec) in hw_guard_start() argument
156 md->hw_guard_wait = msecs_to_jiffies(guard_msec); in hw_guard_start()
157 md->hw_guard_end = jiffies + md->hw_guard_wait; in hw_guard_start()
160 static void hw_guard_wait(struct mipid_device *md) in hw_guard_wait() argument
162 unsigned long wait = md->hw_guard_end - jiffies; in hw_guard_wait()
164 if ((long)wait > 0 && time_before_eq(wait, md->hw_guard_wait)) { in hw_guard_wait()
170 static void set_sleep_mode(struct mipid_device *md, int on) in set_sleep_mode() argument
178 hw_guard_wait(md); in set_sleep_mode()
179 mipid_cmd(md, cmd); in set_sleep_mode()
180 hw_guard_start(md, 120); in set_sleep_mode()
192 static void set_display_state(struct mipid_device *md, int enabled) in set_display_state() argument
196 mipid_cmd(md, cmd); in set_display_state()
201 struct mipid_device *md = to_mipid_device(panel); in mipid_set_bklight_level() local
202 struct mipid_platform_data *pd = md->spi->dev.platform_data; in mipid_set_bklight_level()
208 if (!md->enabled) { in mipid_set_bklight_level()
209 md->saved_bklight_level = level; in mipid_set_bklight_level()
219 struct mipid_device *md = to_mipid_device(panel); in mipid_get_bklight_level() local
220 struct mipid_platform_data *pd = md->spi->dev.platform_data; in mipid_get_bklight_level()
229 struct mipid_device *md = to_mipid_device(panel); in mipid_get_bklight_max() local
230 struct mipid_platform_data *pd = md->spi->dev.platform_data; in mipid_get_bklight_max()
243 static u16 read_first_pixel(struct mipid_device *md) in read_first_pixel() argument
248 mutex_lock(&md->mutex); in read_first_pixel()
249 mipid_read(md, MIPID_CMD_READ_RED, &red, 1); in read_first_pixel()
250 mipid_read(md, MIPID_CMD_READ_GREEN, &green, 1); in read_first_pixel()
251 mipid_read(md, MIPID_CMD_READ_BLUE, &blue, 1); in read_first_pixel()
252 mutex_unlock(&md->mutex); in read_first_pixel()
254 switch (md->panel.data_lines) { in read_first_pixel()
273 struct mipid_device *md = to_mipid_device(panel); in mipid_run_test() local
286 omapfb_write_first_pixel(md->fbdev, test_values[i]); in mipid_run_test()
293 pixel = read_first_pixel(md); in mipid_run_test()
297 dev_err(&md->spi->dev, in mipid_run_test()
310 static void ls041y3_esd_recover(struct mipid_device *md) in ls041y3_esd_recover() argument
312 dev_err(&md->spi->dev, "performing LCD ESD recovery\n"); in ls041y3_esd_recover()
313 set_sleep_mode(md, 1); in ls041y3_esd_recover()
314 set_sleep_mode(md, 0); in ls041y3_esd_recover()
317 static void ls041y3_esd_check_mode1(struct mipid_device *md) in ls041y3_esd_check_mode1() argument
321 mipid_read(md, MIPID_CMD_RDDSDR, &state1, 1); in ls041y3_esd_check_mode1()
322 set_sleep_mode(md, 0); in ls041y3_esd_check_mode1()
323 mipid_read(md, MIPID_CMD_RDDSDR, &state2, 1); in ls041y3_esd_check_mode1()
324 dev_dbg(&md->spi->dev, "ESD mode 1 state1 %02x state2 %02x\n", in ls041y3_esd_check_mode1()
330 ls041y3_esd_recover(md); in ls041y3_esd_check_mode1()
333 static void ls041y3_esd_check_mode2(struct mipid_device *md) in ls041y3_esd_check_mode2() argument
353 mipid_write(md, rd->cmd, (u8 *)rd->wbuf, rd->wlen); in ls041y3_esd_check_mode2()
356 mipid_read(md, rd->cmd, rbuf, 2); in ls041y3_esd_check_mode2()
361 mipid_write(md, rd->cmd, (u8 *)rd->wbuf, rd->wlen); in ls041y3_esd_check_mode2()
364 dev_dbg(&md->spi->dev, "ESD mode 2 state %02x\n", rbuf[1]); in ls041y3_esd_check_mode2()
366 ls041y3_esd_recover(md); in ls041y3_esd_check_mode2()
369 static void ls041y3_esd_check(struct mipid_device *md) in ls041y3_esd_check() argument
371 ls041y3_esd_check_mode1(md); in ls041y3_esd_check()
372 if (md->revision >= 0x88) in ls041y3_esd_check()
373 ls041y3_esd_check_mode2(md); in ls041y3_esd_check()
376 static void mipid_esd_start_check(struct mipid_device *md) in mipid_esd_start_check() argument
378 if (md->esd_check != NULL) in mipid_esd_start_check()
379 schedule_delayed_work(&md->esd_work, in mipid_esd_start_check()
383 static void mipid_esd_stop_check(struct mipid_device *md) in mipid_esd_stop_check() argument
385 if (md->esd_check != NULL) in mipid_esd_stop_check()
386 cancel_delayed_work_sync(&md->esd_work); in mipid_esd_stop_check()
391 struct mipid_device *md = container_of(work, struct mipid_device, in mipid_esd_work() local
394 mutex_lock(&md->mutex); in mipid_esd_work()
395 md->esd_check(md); in mipid_esd_work()
396 mutex_unlock(&md->mutex); in mipid_esd_work()
397 mipid_esd_start_check(md); in mipid_esd_work()
402 struct mipid_device *md = to_mipid_device(panel); in mipid_enable() local
404 mutex_lock(&md->mutex); in mipid_enable()
406 if (md->enabled) { in mipid_enable()
407 mutex_unlock(&md->mutex); in mipid_enable()
410 set_sleep_mode(md, 0); in mipid_enable()
411 md->enabled = 1; in mipid_enable()
412 send_init_string(md); in mipid_enable()
413 set_display_state(md, 1); in mipid_enable()
414 mipid_set_bklight_level(panel, md->saved_bklight_level); in mipid_enable()
415 mipid_esd_start_check(md); in mipid_enable()
417 mutex_unlock(&md->mutex); in mipid_enable()
423 struct mipid_device *md = to_mipid_device(panel); in mipid_disable() local
429 mipid_esd_stop_check(md); in mipid_disable()
430 mutex_lock(&md->mutex); in mipid_disable()
432 if (!md->enabled) { in mipid_disable()
433 mutex_unlock(&md->mutex); in mipid_disable()
436 md->saved_bklight_level = mipid_get_bklight_level(panel); in mipid_disable()
438 set_display_state(md, 0); in mipid_disable()
439 set_sleep_mode(md, 1); in mipid_disable()
440 md->enabled = 0; in mipid_disable()
442 mutex_unlock(&md->mutex); in mipid_disable()
445 static int panel_enabled(struct mipid_device *md) in panel_enabled() argument
450 mipid_read(md, MIPID_CMD_READ_DISP_STATUS, (u8 *)&disp_status, 4); in panel_enabled()
453 dev_dbg(&md->spi->dev, in panel_enabled()
462 struct mipid_device *md = to_mipid_device(panel); in mipid_init() local
464 md->fbdev = fbdev; in mipid_init()
465 INIT_DELAYED_WORK(&md->esd_work, mipid_esd_work); in mipid_init()
466 mutex_init(&md->mutex); in mipid_init()
468 md->enabled = panel_enabled(md); in mipid_init()
470 if (md->enabled) in mipid_init()
471 mipid_esd_start_check(md); in mipid_init()
473 md->saved_bklight_level = mipid_get_bklight_level(panel); in mipid_init()
480 struct mipid_device *md = to_mipid_device(panel); in mipid_cleanup() local
482 if (md->enabled) in mipid_cleanup()
483 mipid_esd_stop_check(md); in mipid_cleanup()
511 static int mipid_detect(struct mipid_device *md) in mipid_detect() argument
516 pdata = md->spi->dev.platform_data; in mipid_detect()
518 dev_err(&md->spi->dev, "missing platform data\n"); in mipid_detect()
522 mipid_read(md, MIPID_CMD_READ_DISP_ID, display_id, 3); in mipid_detect()
523 dev_dbg(&md->spi->dev, "MIPI display ID: %02x%02x%02x\n", in mipid_detect()
528 md->panel.name = "lph8923"; in mipid_detect()
531 md->panel.name = "ls041y3"; in mipid_detect()
532 md->esd_check = ls041y3_esd_check; in mipid_detect()
535 md->panel.name = "unknown"; in mipid_detect()
536 dev_err(&md->spi->dev, "invalid display ID\n"); in mipid_detect()
540 md->revision = display_id[1]; in mipid_detect()
541 md->panel.data_lines = pdata->data_lines; in mipid_detect()
543 md->panel.name, md->revision, md->panel.data_lines); in mipid_detect()
550 struct mipid_device *md; in mipid_spi_probe() local
553 md = kzalloc(sizeof(*md), GFP_KERNEL); in mipid_spi_probe()
554 if (md == NULL) { in mipid_spi_probe()
560 md->spi = spi; in mipid_spi_probe()
561 dev_set_drvdata(&spi->dev, md); in mipid_spi_probe()
562 md->panel = mipid_panel; in mipid_spi_probe()
564 r = mipid_detect(md); in mipid_spi_probe()
568 omapfb_register_panel(&md->panel); in mipid_spi_probe()
575 struct mipid_device *md = dev_get_drvdata(&spi->dev); in mipid_spi_remove() local
577 mipid_disable(&md->panel); in mipid_spi_remove()
578 kfree(md); in mipid_spi_remove()