Lines Matching +full:panel +full:- +full:dsi
1 // SPDX-License-Identifier: GPL-2.0
55 struct drm_panel panel; member
64 struct mipi_dsi_device *dsi[2]; member
71 static inline struct truly_nt35597 *panel_to_ctx(struct drm_panel *panel) in panel_to_ctx() argument
73 return container_of(panel, struct truly_nt35597, panel); in panel_to_ctx()
225 static int truly_dcs_write(struct drm_panel *panel, u32 command) in truly_dcs_write() argument
227 struct truly_nt35597 *ctx = panel_to_ctx(panel); in truly_dcs_write()
230 for (i = 0; i < ARRAY_SIZE(ctx->dsi); i++) { in truly_dcs_write()
231 ret = mipi_dsi_dcs_write(ctx->dsi[i], command, NULL, 0); in truly_dcs_write()
233 dev_err(ctx->dev, "cmd 0x%x failed for dsi = %d\n", command, i); in truly_dcs_write()
240 static int truly_dcs_write_buf(struct drm_panel *panel, in truly_dcs_write_buf() argument
243 struct truly_nt35597 *ctx = panel_to_ctx(panel); in truly_dcs_write_buf()
247 for (i = 0; i < ARRAY_SIZE(ctx->dsi); i++) { in truly_dcs_write_buf()
248 ret = mipi_dsi_dcs_write_buffer(ctx->dsi[i], buf, size); in truly_dcs_write_buf()
250 dev_err(ctx->dev, "failed to tx cmd [%d], err: %d\n", i, ret); in truly_dcs_write_buf()
262 for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) { in truly_35597_power_on()
263 ret = regulator_set_load(ctx->supplies[i].consumer, in truly_35597_power_on()
269 ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); in truly_35597_power_on()
274 * Reset sequence of truly panel requires the panel to be in truly_35597_power_on()
278 gpiod_set_value(ctx->reset_gpio, 0); in truly_35597_power_on()
280 gpiod_set_value(ctx->reset_gpio, 1); in truly_35597_power_on()
282 gpiod_set_value(ctx->reset_gpio, 0); in truly_35597_power_on()
293 gpiod_set_value(ctx->reset_gpio, 1); in truly_nt35597_power_off()
295 for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) { in truly_nt35597_power_off()
296 ret = regulator_set_load(ctx->supplies[i].consumer, in truly_nt35597_power_off()
299 dev_err(ctx->dev, "regulator_set_load failed %d\n", ret); in truly_nt35597_power_off()
304 ret = regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); in truly_nt35597_power_off()
306 dev_err(ctx->dev, "regulator_bulk_disable failed %d\n", ret); in truly_nt35597_power_off()
311 static int truly_nt35597_disable(struct drm_panel *panel) in truly_nt35597_disable() argument
313 struct truly_nt35597 *ctx = panel_to_ctx(panel); in truly_nt35597_disable()
316 if (!ctx->enabled) in truly_nt35597_disable()
319 if (ctx->backlight) { in truly_nt35597_disable()
320 ret = backlight_disable(ctx->backlight); in truly_nt35597_disable()
322 dev_err(ctx->dev, "backlight disable failed %d\n", ret); in truly_nt35597_disable()
325 ctx->enabled = false; in truly_nt35597_disable()
329 static int truly_nt35597_unprepare(struct drm_panel *panel) in truly_nt35597_unprepare() argument
331 struct truly_nt35597 *ctx = panel_to_ctx(panel); in truly_nt35597_unprepare()
334 if (!ctx->prepared) in truly_nt35597_unprepare()
337 ctx->dsi[0]->mode_flags = 0; in truly_nt35597_unprepare()
338 ctx->dsi[1]->mode_flags = 0; in truly_nt35597_unprepare()
340 ret = truly_dcs_write(panel, MIPI_DCS_SET_DISPLAY_OFF); in truly_nt35597_unprepare()
342 dev_err(ctx->dev, "set_display_off cmd failed ret = %d\n", ret); in truly_nt35597_unprepare()
348 ret = truly_dcs_write(panel, MIPI_DCS_ENTER_SLEEP_MODE); in truly_nt35597_unprepare()
350 dev_err(ctx->dev, "enter_sleep cmd failed ret = %d\n", ret); in truly_nt35597_unprepare()
355 dev_err(ctx->dev, "power_off failed ret = %d\n", ret); in truly_nt35597_unprepare()
357 ctx->prepared = false; in truly_nt35597_unprepare()
361 static int truly_nt35597_prepare(struct drm_panel *panel) in truly_nt35597_prepare() argument
363 struct truly_nt35597 *ctx = panel_to_ctx(panel); in truly_nt35597_prepare()
370 if (ctx->prepared) in truly_nt35597_prepare()
377 ctx->dsi[0]->mode_flags |= MIPI_DSI_MODE_LPM; in truly_nt35597_prepare()
378 ctx->dsi[1]->mode_flags |= MIPI_DSI_MODE_LPM; in truly_nt35597_prepare()
380 config = ctx->config; in truly_nt35597_prepare()
381 panel_on_cmds = config->panel_on_cmds; in truly_nt35597_prepare()
382 num_cmds = config->num_on_cmds; in truly_nt35597_prepare()
385 ret = truly_dcs_write_buf(panel, in truly_nt35597_prepare()
389 dev_err(ctx->dev, "cmd set tx failed i = %d ret = %d\n", i, ret); in truly_nt35597_prepare()
394 ret = truly_dcs_write(panel, MIPI_DCS_EXIT_SLEEP_MODE); in truly_nt35597_prepare()
396 dev_err(ctx->dev, "exit_sleep_mode cmd failed ret = %d\n", ret); in truly_nt35597_prepare()
400 /* Per DSI spec wait 120ms after sending exit sleep DCS command */ in truly_nt35597_prepare()
403 ret = truly_dcs_write(panel, MIPI_DCS_SET_DISPLAY_ON); in truly_nt35597_prepare()
405 dev_err(ctx->dev, "set_display_on cmd failed ret = %d\n", ret); in truly_nt35597_prepare()
409 /* Per DSI spec wait 120ms after sending set_display_on DCS command */ in truly_nt35597_prepare()
412 ctx->prepared = true; in truly_nt35597_prepare()
418 dev_err(ctx->dev, "power_off failed\n"); in truly_nt35597_prepare()
422 static int truly_nt35597_enable(struct drm_panel *panel) in truly_nt35597_enable() argument
424 struct truly_nt35597 *ctx = panel_to_ctx(panel); in truly_nt35597_enable()
427 if (ctx->enabled) in truly_nt35597_enable()
430 if (ctx->backlight) { in truly_nt35597_enable()
431 ret = backlight_enable(ctx->backlight); in truly_nt35597_enable()
433 dev_err(ctx->dev, "backlight enable failed %d\n", ret); in truly_nt35597_enable()
436 ctx->enabled = true; in truly_nt35597_enable()
441 static int truly_nt35597_get_modes(struct drm_panel *panel, in truly_nt35597_get_modes() argument
444 struct truly_nt35597 *ctx = panel_to_ctx(panel); in truly_nt35597_get_modes()
448 config = ctx->config; in truly_nt35597_get_modes()
449 mode = drm_mode_create(connector->dev); in truly_nt35597_get_modes()
451 dev_err(ctx->dev, "failed to create a new display mode\n"); in truly_nt35597_get_modes()
455 connector->display_info.width_mm = config->width_mm; in truly_nt35597_get_modes()
456 connector->display_info.height_mm = config->height_mm; in truly_nt35597_get_modes()
457 drm_mode_copy(mode, config->dm); in truly_nt35597_get_modes()
458 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; in truly_nt35597_get_modes()
474 struct device *dev = ctx->dev; in truly_nt35597_panel_add()
477 for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) in truly_nt35597_panel_add()
478 ctx->supplies[i].supply = regulator_names[i]; in truly_nt35597_panel_add()
480 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies), in truly_nt35597_panel_add()
481 ctx->supplies); in truly_nt35597_panel_add()
485 ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in truly_nt35597_panel_add()
486 if (IS_ERR(ctx->reset_gpio)) { in truly_nt35597_panel_add()
487 dev_err(dev, "cannot get reset gpio %ld\n", PTR_ERR(ctx->reset_gpio)); in truly_nt35597_panel_add()
488 return PTR_ERR(ctx->reset_gpio); in truly_nt35597_panel_add()
491 ctx->mode_gpio = devm_gpiod_get(dev, "mode", GPIOD_OUT_LOW); in truly_nt35597_panel_add()
492 if (IS_ERR(ctx->mode_gpio)) { in truly_nt35597_panel_add()
493 dev_err(dev, "cannot get mode gpio %ld\n", PTR_ERR(ctx->mode_gpio)); in truly_nt35597_panel_add()
494 return PTR_ERR(ctx->mode_gpio); in truly_nt35597_panel_add()
498 gpiod_set_value(ctx->mode_gpio, 0); in truly_nt35597_panel_add()
500 drm_panel_init(&ctx->panel, dev, &truly_nt35597_drm_funcs, in truly_nt35597_panel_add()
502 drm_panel_add(&ctx->panel); in truly_nt35597_panel_add()
530 static int truly_nt35597_probe(struct mipi_dsi_device *dsi) in truly_nt35597_probe() argument
532 struct device *dev = &dsi->dev; in truly_nt35597_probe()
550 return -ENOMEM; in truly_nt35597_probe()
554 * fed by the output ports of the two DSI controllers . The DSI0 is in truly_nt35597_probe()
555 * the master controller and has most of the panel related info in its in truly_nt35597_probe()
559 ctx->config = of_device_get_match_data(dev); in truly_nt35597_probe()
561 if (!ctx->config) { in truly_nt35597_probe()
563 return -ENODEV; in truly_nt35597_probe()
566 dsi1 = of_graph_get_remote_node(dsi->dev.of_node, 1, -1); in truly_nt35597_probe()
569 return -ENODEV; in truly_nt35597_probe()
575 dev_err(dev, "failed to find dsi host\n"); in truly_nt35597_probe()
576 return -EPROBE_DEFER; in truly_nt35597_probe()
579 /* register the second DSI device */ in truly_nt35597_probe()
582 dev_err(dev, "failed to create dsi device\n"); in truly_nt35597_probe()
586 mipi_dsi_set_drvdata(dsi, ctx); in truly_nt35597_probe()
588 ctx->dev = dev; in truly_nt35597_probe()
589 ctx->dsi[0] = dsi; in truly_nt35597_probe()
590 ctx->dsi[1] = dsi1_device; in truly_nt35597_probe()
594 dev_err(dev, "failed to add panel\n"); in truly_nt35597_probe()
598 for (i = 0; i < ARRAY_SIZE(ctx->dsi); i++) { in truly_nt35597_probe()
599 dsi_dev = ctx->dsi[i]; in truly_nt35597_probe()
600 dsi_dev->lanes = 4; in truly_nt35597_probe()
601 dsi_dev->format = MIPI_DSI_FMT_RGB888; in truly_nt35597_probe()
602 dsi_dev->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_LPM | in truly_nt35597_probe()
606 dev_err(dev, "dsi attach failed i = %d\n", i); in truly_nt35597_probe()
614 drm_panel_remove(&ctx->panel); in truly_nt35597_probe()
620 static int truly_nt35597_remove(struct mipi_dsi_device *dsi) in truly_nt35597_remove() argument
622 struct truly_nt35597 *ctx = mipi_dsi_get_drvdata(dsi); in truly_nt35597_remove()
624 if (ctx->dsi[0]) in truly_nt35597_remove()
625 mipi_dsi_detach(ctx->dsi[0]); in truly_nt35597_remove()
626 if (ctx->dsi[1]) { in truly_nt35597_remove()
627 mipi_dsi_detach(ctx->dsi[1]); in truly_nt35597_remove()
628 mipi_dsi_device_unregister(ctx->dsi[1]); in truly_nt35597_remove()
631 drm_panel_remove(&ctx->panel); in truly_nt35597_remove()
637 .compatible = "truly,nt35597-2K-display",
646 .name = "panel-truly-nt35597",
654 MODULE_DESCRIPTION("Truly NT35597 DSI Panel Driver");