Lines Matching +full:vcc +full:- +full:dsi +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0
5 * - Rocktech jh057n00900 5.5" MIPI-DSI panel
13 #include <linux/media-bus-format.h>
26 #define DRV_NAME "panel-sitronix-st7703"
28 /* Manufacturer specific Commands send via DSI */
55 struct regulator *vcc; member
76 #define dsi_generic_write_seq(dsi, seq...) do { \ argument
79 ret = mipi_dsi_generic_write(dsi, d, ARRAY_SIZE(d)); \
86 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in jh057n_init_sequence() local
93 dsi_generic_write_seq(dsi, ST7703_CMD_SETEXTC, in jh057n_init_sequence()
95 dsi_generic_write_seq(dsi, ST7703_CMD_SETRGBIF, in jh057n_init_sequence()
98 dsi_generic_write_seq(dsi, ST7703_CMD_SETSCR, in jh057n_init_sequence()
101 dsi_generic_write_seq(dsi, ST7703_CMD_SETVDC, 0x4E); in jh057n_init_sequence()
102 dsi_generic_write_seq(dsi, ST7703_CMD_SETPANEL, 0x0B); in jh057n_init_sequence()
103 dsi_generic_write_seq(dsi, ST7703_CMD_SETCYC, 0x80); in jh057n_init_sequence()
104 dsi_generic_write_seq(dsi, ST7703_CMD_SETDISP, 0xF0, 0x12, 0x30); in jh057n_init_sequence()
105 dsi_generic_write_seq(dsi, ST7703_CMD_SETEQ, in jh057n_init_sequence()
108 dsi_generic_write_seq(dsi, ST7703_CMD_SETBGP, 0x08, 0x08); in jh057n_init_sequence()
111 dsi_generic_write_seq(dsi, ST7703_CMD_SETVCOM, 0x3F, 0x3F); in jh057n_init_sequence()
112 dsi_generic_write_seq(dsi, ST7703_CMD_UNKNOWN_BF, 0x02, 0x11, 0x00); in jh057n_init_sequence()
113 dsi_generic_write_seq(dsi, ST7703_CMD_SETGIP1, in jh057n_init_sequence()
122 dsi_generic_write_seq(dsi, ST7703_CMD_SETGIP2, in jh057n_init_sequence()
131 dsi_generic_write_seq(dsi, ST7703_CMD_SETGAMMA, in jh057n_init_sequence()
165 #define dsi_dcs_write_seq(dsi, cmd, seq...) do { \ argument
168 ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d)); \
176 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in xbd599_init_sequence() local
183 dsi_dcs_write_seq(dsi, ST7703_CMD_SETEXTC, 0xF1, 0x12, 0x83); in xbd599_init_sequence()
185 dsi_dcs_write_seq(dsi, ST7703_CMD_SETMIPI, in xbd599_init_sequence()
190 0x0E, /* HFP_OSC (min. HFP number in DSI mode) */ in xbd599_init_sequence()
191 0x0E, /* HBP_OSC (min. HBP number in DSI mode) */ in xbd599_init_sequence()
197 dsi_dcs_write_seq(dsi, ST7703_CMD_SETPOWER_EXT, in xbd599_init_sequence()
204 dsi_dcs_write_seq(dsi, ST7703_CMD_SETRGBIF, in xbd599_init_sequence()
215 dsi_dcs_write_seq(dsi, ST7703_CMD_SETSCR, in xbd599_init_sequence()
226 /* NVDDD_SEL = -1.8V, VDDD_SEL = out of range (possibly 1.9V?) */ in xbd599_init_sequence()
227 dsi_dcs_write_seq(dsi, ST7703_CMD_SETVDC, 0x4E); in xbd599_init_sequence()
233 dsi_dcs_write_seq(dsi, ST7703_CMD_SETPANEL, 0x0B); in xbd599_init_sequence()
235 /* Zig-Zag Type C column inversion. */ in xbd599_init_sequence()
236 dsi_dcs_write_seq(dsi, ST7703_CMD_SETCYC, 0x80); in xbd599_init_sequence()
239 dsi_dcs_write_seq(dsi, ST7703_CMD_SETDISP, in xbd599_init_sequence()
249 dsi_dcs_write_seq(dsi, ST7703_CMD_SETEQ, in xbd599_init_sequence()
263 0x10 /* SLPIN_OPTION = 1 (no need vsync after sleep-in) in xbd599_init_sequence()
270 dsi_dcs_write_seq(dsi, ST7703_CMD_UNKNOWN_C6, 0x01, 0x00, 0xFF, 0xFF, 0x00); in xbd599_init_sequence()
272 dsi_dcs_write_seq(dsi, ST7703_CMD_SETPOWER, in xbd599_init_sequence()
273 0x74, /* VBTHS, VBTLS: VGH = 17V, VBL = -11V */ in xbd599_init_sequence()
290 dsi_dcs_write_seq(dsi, ST7703_CMD_SETBGP, in xbd599_init_sequence()
295 dsi_dcs_write_seq(dsi, ST7703_CMD_SETVCOM, in xbd599_init_sequence()
296 0x2C, /* VCOMDC_F = -0.67V */ in xbd599_init_sequence()
297 0x2C /* VCOMDC_B = -0.67V */); in xbd599_init_sequence()
300 dsi_dcs_write_seq(dsi, ST7703_CMD_UNKNOWN_BF, 0x02, 0x11, 0x00); in xbd599_init_sequence()
303 dsi_dcs_write_seq(dsi, ST7703_CMD_SETGIP1, in xbd599_init_sequence()
314 dsi_dcs_write_seq(dsi, ST7703_CMD_SETGIP2, in xbd599_init_sequence()
325 dsi_dcs_write_seq(dsi, ST7703_CMD_SETGAMMA, in xbd599_init_sequence()
361 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in st7703_enable() local
364 ret = ctx->desc->init_sequence(ctx); in st7703_enable()
366 dev_err(ctx->dev, "Panel init sequence failed: %d\n", ret); in st7703_enable()
372 ret = mipi_dsi_dcs_exit_sleep_mode(dsi); in st7703_enable()
374 dev_err(ctx->dev, "Failed to exit sleep mode: %d\n", ret); in st7703_enable()
381 ret = mipi_dsi_dcs_set_display_on(dsi); in st7703_enable()
385 dev_dbg(ctx->dev, "Panel init sequence done\n"); in st7703_enable()
393 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in st7703_disable() local
396 ret = mipi_dsi_dcs_set_display_off(dsi); in st7703_disable()
398 dev_err(ctx->dev, "Failed to turn off the display: %d\n", ret); in st7703_disable()
400 ret = mipi_dsi_dcs_enter_sleep_mode(dsi); in st7703_disable()
402 dev_err(ctx->dev, "Failed to enter sleep mode: %d\n", ret); in st7703_disable()
411 if (!ctx->prepared) in st7703_unprepare()
414 gpiod_set_value_cansleep(ctx->reset_gpio, 1); in st7703_unprepare()
415 regulator_disable(ctx->iovcc); in st7703_unprepare()
416 regulator_disable(ctx->vcc); in st7703_unprepare()
417 ctx->prepared = false; in st7703_unprepare()
427 if (ctx->prepared) in st7703_prepare()
430 dev_dbg(ctx->dev, "Resetting the panel\n"); in st7703_prepare()
431 ret = regulator_enable(ctx->vcc); in st7703_prepare()
433 dev_err(ctx->dev, "Failed to enable vcc supply: %d\n", ret); in st7703_prepare()
436 ret = regulator_enable(ctx->iovcc); in st7703_prepare()
438 dev_err(ctx->dev, "Failed to enable iovcc supply: %d\n", ret); in st7703_prepare()
442 gpiod_set_value_cansleep(ctx->reset_gpio, 1); in st7703_prepare()
444 gpiod_set_value_cansleep(ctx->reset_gpio, 0); in st7703_prepare()
447 ctx->prepared = true; in st7703_prepare()
452 regulator_disable(ctx->vcc); in st7703_prepare()
466 mode = drm_mode_duplicate(connector->dev, ctx->desc->mode); in st7703_get_modes()
468 dev_err(ctx->dev, "Failed to add mode %ux%u@%u\n", in st7703_get_modes()
469 ctx->desc->mode->hdisplay, ctx->desc->mode->vdisplay, in st7703_get_modes()
470 drm_mode_vrefresh(ctx->desc->mode)); in st7703_get_modes()
471 return -ENOMEM; in st7703_get_modes()
476 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; in st7703_get_modes()
477 connector->display_info.width_mm = mode->width_mm; in st7703_get_modes()
478 connector->display_info.height_mm = mode->height_mm; in st7703_get_modes()
481 drm_display_info_set_bus_formats(&connector->display_info, in st7703_get_modes()
499 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in allpixelson_set() local
501 dev_dbg(ctx->dev, "Setting all pixels on\n"); in allpixelson_set()
502 dsi_generic_write_seq(dsi, ST7703_CMD_ALL_PIXEL_ON); in allpixelson_set()
505 drm_panel_disable(&ctx->panel); in allpixelson_set()
506 drm_panel_unprepare(&ctx->panel); in allpixelson_set()
507 drm_panel_prepare(&ctx->panel); in allpixelson_set()
508 drm_panel_enable(&ctx->panel); in allpixelson_set()
518 ctx->debugfs = debugfs_create_dir(DRV_NAME, NULL); in st7703_debugfs_init()
520 debugfs_create_file("allpixelson", 0600, ctx->debugfs, ctx, in st7703_debugfs_init()
526 debugfs_remove_recursive(ctx->debugfs); in st7703_debugfs_remove()
527 ctx->debugfs = NULL; in st7703_debugfs_remove()
530 static int st7703_probe(struct mipi_dsi_device *dsi) in st7703_probe() argument
532 struct device *dev = &dsi->dev; in st7703_probe()
538 return -ENOMEM; in st7703_probe()
540 ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in st7703_probe()
541 if (IS_ERR(ctx->reset_gpio)) in st7703_probe()
542 return dev_err_probe(dev, PTR_ERR(ctx->reset_gpio), "Failed to get reset gpio\n"); in st7703_probe()
544 mipi_dsi_set_drvdata(dsi, ctx); in st7703_probe()
546 ctx->dev = dev; in st7703_probe()
547 ctx->desc = of_device_get_match_data(dev); in st7703_probe()
549 dsi->mode_flags = ctx->desc->mode_flags; in st7703_probe()
550 dsi->format = ctx->desc->format; in st7703_probe()
551 dsi->lanes = ctx->desc->lanes; in st7703_probe()
553 ctx->vcc = devm_regulator_get(dev, "vcc"); in st7703_probe()
554 if (IS_ERR(ctx->vcc)) in st7703_probe()
555 return dev_err_probe(dev, PTR_ERR(ctx->vcc), "Failed to request vcc regulator\n"); in st7703_probe()
557 ctx->iovcc = devm_regulator_get(dev, "iovcc"); in st7703_probe()
558 if (IS_ERR(ctx->iovcc)) in st7703_probe()
559 return dev_err_probe(dev, PTR_ERR(ctx->iovcc), in st7703_probe()
562 drm_panel_init(&ctx->panel, dev, &st7703_drm_funcs, in st7703_probe()
565 ret = drm_panel_of_backlight(&ctx->panel); in st7703_probe()
569 drm_panel_add(&ctx->panel); in st7703_probe()
571 ret = mipi_dsi_attach(dsi); in st7703_probe()
574 drm_panel_remove(&ctx->panel); in st7703_probe()
578 dev_info(dev, "%ux%u@%u %ubpp dsi %udl - ready\n", in st7703_probe()
579 ctx->desc->mode->hdisplay, ctx->desc->mode->vdisplay, in st7703_probe()
580 drm_mode_vrefresh(ctx->desc->mode), in st7703_probe()
581 mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes); in st7703_probe()
587 static void st7703_shutdown(struct mipi_dsi_device *dsi) in st7703_shutdown() argument
589 struct st7703 *ctx = mipi_dsi_get_drvdata(dsi); in st7703_shutdown()
592 ret = drm_panel_unprepare(&ctx->panel); in st7703_shutdown()
594 dev_err(&dsi->dev, "Failed to unprepare panel: %d\n", ret); in st7703_shutdown()
596 ret = drm_panel_disable(&ctx->panel); in st7703_shutdown()
598 dev_err(&dsi->dev, "Failed to disable panel: %d\n", ret); in st7703_shutdown()
601 static void st7703_remove(struct mipi_dsi_device *dsi) in st7703_remove() argument
603 struct st7703 *ctx = mipi_dsi_get_drvdata(dsi); in st7703_remove()
606 st7703_shutdown(dsi); in st7703_remove()
608 ret = mipi_dsi_detach(dsi); in st7703_remove()
610 dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret); in st7703_remove()
612 drm_panel_remove(&ctx->panel); in st7703_remove()
636 MODULE_DESCRIPTION("DRM driver for Sitronix ST7703 based MIPI DSI panels");