Lines Matching +full:dsi +full:- +full:based
1 // SPDX-License-Identifier: GPL-2.0
3 * Driver for panels based on Himax HX8394 controller, such as:
5 * - HannStar HSD060BHW4 5.99" MIPI-DSI panel
9 * Based on drivers/gpu/drm/panel/panel-sitronix-st7703.c
15 #include <linux/media-bus-format.h>
27 #define DRV_NAME "panel-himax-hx8394"
29 /* Manufacturer specific commands sent via DSI, listed in HX8394-F datasheet */
91 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in hsd060bhw4_init_sequence() local
94 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_SETEXTC, in hsd060bhw4_init_sequence()
98 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_SETPOWER, in hsd060bhw4_init_sequence()
102 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_SETMIPI, in hsd060bhw4_init_sequence()
106 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_SETDISP, in hsd060bhw4_init_sequence()
110 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_SETCYC, in hsd060bhw4_init_sequence()
116 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_SETGIP0, in hsd060bhw4_init_sequence()
123 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_SETGIP1, in hsd060bhw4_init_sequence()
131 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_SETGIP2, in hsd060bhw4_init_sequence()
139 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_SETGAMMA, in hsd060bhw4_init_sequence()
149 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_SETPANEL, in hsd060bhw4_init_sequence()
152 /* Unknown command, not listed in the HX8394-F datasheet */ in hsd060bhw4_init_sequence()
153 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_UNKNOWN1, in hsd060bhw4_init_sequence()
157 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_SETVCOM, in hsd060bhw4_init_sequence()
160 /* Unknown command, not listed in the HX8394-F datasheet */ in hsd060bhw4_init_sequence()
161 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_UNKNOWN3, in hsd060bhw4_init_sequence()
165 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_SETREGBANK, in hsd060bhw4_init_sequence()
169 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_SETPOWER, in hsd060bhw4_init_sequence()
173 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_SETREGBANK, in hsd060bhw4_init_sequence()
176 /* Unknown command, not listed in the HX8394-F datasheet */ in hsd060bhw4_init_sequence()
177 mipi_dsi_dcs_write_seq(dsi, HX8394_CMD_UNKNOWN3, in hsd060bhw4_init_sequence()
209 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in hx8394_enable() local
212 ret = ctx->desc->init_sequence(ctx); in hx8394_enable()
214 dev_err(ctx->dev, "Panel init sequence failed: %d\n", ret); in hx8394_enable()
218 ret = mipi_dsi_dcs_exit_sleep_mode(dsi); in hx8394_enable()
220 dev_err(ctx->dev, "Failed to exit sleep mode: %d\n", ret); in hx8394_enable()
227 ret = mipi_dsi_dcs_set_display_on(dsi); in hx8394_enable()
229 dev_err(ctx->dev, "Failed to turn on the display: %d\n", ret); in hx8394_enable()
237 if (!mipi_dsi_dcs_enter_sleep_mode(dsi)) in hx8394_enable()
246 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in hx8394_disable() local
249 ret = mipi_dsi_dcs_enter_sleep_mode(dsi); in hx8394_disable()
251 dev_err(ctx->dev, "Failed to enter sleep mode: %d\n", ret); in hx8394_disable()
264 if (!ctx->prepared) in hx8394_unprepare()
267 gpiod_set_value_cansleep(ctx->reset_gpio, 1); in hx8394_unprepare()
269 regulator_disable(ctx->iovcc); in hx8394_unprepare()
270 regulator_disable(ctx->vcc); in hx8394_unprepare()
272 ctx->prepared = false; in hx8394_unprepare()
282 if (ctx->prepared) in hx8394_prepare()
285 gpiod_set_value_cansleep(ctx->reset_gpio, 1); in hx8394_prepare()
287 ret = regulator_enable(ctx->vcc); in hx8394_prepare()
289 dev_err(ctx->dev, "Failed to enable vcc supply: %d\n", ret); in hx8394_prepare()
293 ret = regulator_enable(ctx->iovcc); in hx8394_prepare()
295 dev_err(ctx->dev, "Failed to enable iovcc supply: %d\n", ret); in hx8394_prepare()
299 gpiod_set_value_cansleep(ctx->reset_gpio, 0); in hx8394_prepare()
303 ctx->prepared = true; in hx8394_prepare()
308 gpiod_set_value_cansleep(ctx->reset_gpio, 1); in hx8394_prepare()
309 regulator_disable(ctx->vcc); in hx8394_prepare()
319 mode = drm_mode_duplicate(connector->dev, ctx->desc->mode); in hx8394_get_modes()
321 dev_err(ctx->dev, "Failed to add mode %ux%u@%u\n", in hx8394_get_modes()
322 ctx->desc->mode->hdisplay, ctx->desc->mode->vdisplay, in hx8394_get_modes()
323 drm_mode_vrefresh(ctx->desc->mode)); in hx8394_get_modes()
324 return -ENOMEM; in hx8394_get_modes()
329 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; in hx8394_get_modes()
330 connector->display_info.width_mm = mode->width_mm; in hx8394_get_modes()
331 connector->display_info.height_mm = mode->height_mm; in hx8394_get_modes()
345 static int hx8394_probe(struct mipi_dsi_device *dsi) in hx8394_probe() argument
347 struct device *dev = &dsi->dev; in hx8394_probe()
353 return -ENOMEM; in hx8394_probe()
355 ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in hx8394_probe()
356 if (IS_ERR(ctx->reset_gpio)) in hx8394_probe()
357 return dev_err_probe(dev, PTR_ERR(ctx->reset_gpio), in hx8394_probe()
360 mipi_dsi_set_drvdata(dsi, ctx); in hx8394_probe()
362 ctx->dev = dev; in hx8394_probe()
363 ctx->desc = of_device_get_match_data(dev); in hx8394_probe()
365 dsi->mode_flags = ctx->desc->mode_flags; in hx8394_probe()
366 dsi->format = ctx->desc->format; in hx8394_probe()
367 dsi->lanes = ctx->desc->lanes; in hx8394_probe()
369 ctx->vcc = devm_regulator_get(dev, "vcc"); in hx8394_probe()
370 if (IS_ERR(ctx->vcc)) in hx8394_probe()
371 return dev_err_probe(dev, PTR_ERR(ctx->vcc), in hx8394_probe()
374 ctx->iovcc = devm_regulator_get(dev, "iovcc"); in hx8394_probe()
375 if (IS_ERR(ctx->iovcc)) in hx8394_probe()
376 return dev_err_probe(dev, PTR_ERR(ctx->iovcc), in hx8394_probe()
379 drm_panel_init(&ctx->panel, dev, &hx8394_drm_funcs, in hx8394_probe()
382 ret = drm_panel_of_backlight(&ctx->panel); in hx8394_probe()
386 drm_panel_add(&ctx->panel); in hx8394_probe()
388 ret = mipi_dsi_attach(dsi); in hx8394_probe()
391 drm_panel_remove(&ctx->panel); in hx8394_probe()
395 dev_dbg(dev, "%ux%u@%u %ubpp dsi %udl - ready\n", in hx8394_probe()
396 ctx->desc->mode->hdisplay, ctx->desc->mode->vdisplay, in hx8394_probe()
397 drm_mode_vrefresh(ctx->desc->mode), in hx8394_probe()
398 mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes); in hx8394_probe()
403 static void hx8394_shutdown(struct mipi_dsi_device *dsi) in hx8394_shutdown() argument
405 struct hx8394 *ctx = mipi_dsi_get_drvdata(dsi); in hx8394_shutdown()
408 ret = drm_panel_disable(&ctx->panel); in hx8394_shutdown()
410 dev_err(&dsi->dev, "Failed to disable panel: %d\n", ret); in hx8394_shutdown()
412 ret = drm_panel_unprepare(&ctx->panel); in hx8394_shutdown()
414 dev_err(&dsi->dev, "Failed to unprepare panel: %d\n", ret); in hx8394_shutdown()
417 static void hx8394_remove(struct mipi_dsi_device *dsi) in hx8394_remove() argument
419 struct hx8394 *ctx = mipi_dsi_get_drvdata(dsi); in hx8394_remove()
422 hx8394_shutdown(dsi); in hx8394_remove()
424 ret = mipi_dsi_detach(dsi); in hx8394_remove()
426 dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret); in hx8394_remove()
428 drm_panel_remove(&ctx->panel); in hx8394_remove()
449 MODULE_DESCRIPTION("DRM driver for Himax HX8394 based MIPI DSI panels");