Lines Matching +full:panel +full:- +full:dsi
1 // SPDX-License-Identifier: GPL-2.0
26 #define MCS_PANSET 0xB3A6 /* Panel Type Setting */
28 #define MCS_P_DRV_M 0xC0B4 /* Panel Driving Mode */
36 #define MCS_PANCTRLSET1 0xCB80 /* Panel Control Setting 1 */
37 #define MCS_PANCTRLSET2 0xCB90 /* Panel Control Setting 2 */
38 #define MCS_PANCTRLSET3 0xCBA0 /* Panel Control Setting 3 */
39 #define MCS_PANCTRLSET4 0xCBB0 /* Panel Control Setting 4 */
40 #define MCS_PANCTRLSET5 0xCBC0 /* Panel Control Setting 5 */
41 #define MCS_PANCTRLSET6 0xCBD0 /* Panel Control Setting 6 */
42 #define MCS_PANCTRLSET7 0xCBE0 /* Panel Control Setting 7 */
43 #define MCS_PANCTRLSET8 0xCBF0 /* Panel Control Setting 8 */
44 #define MCS_PANU2D1 0xCC80 /* Panel U2D Setting 1 */
45 #define MCS_PANU2D2 0xCC90 /* Panel U2D Setting 2 */
46 #define MCS_PANU2D3 0xCCA0 /* Panel U2D Setting 3 */
47 #define MCS_PAND2U1 0xCCB0 /* Panel D2U Setting 1 */
48 #define MCS_PAND2U2 0xCCC0 /* Panel D2U Setting 2 */
49 #define MCS_PAND2U3 0xCCD0 /* Panel D2U Setting 3 */
58 #define MCS_GMCT2_2N 0xE200 /* Gamma Correction 2.2- Setting */
65 struct drm_panel panel; member
88 static inline struct otm8009a *panel_to_otm8009a(struct drm_panel *panel) in panel_to_otm8009a() argument
90 return container_of(panel, struct otm8009a, panel); in panel_to_otm8009a()
96 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in otm8009a_dcs_write_buf() local
98 if (mipi_dsi_dcs_write_buffer(dsi, data, len) < 0) in otm8009a_dcs_write_buf()
99 dev_warn(ctx->dev, "mipi dsi dcs write buffer failed\n"); in otm8009a_dcs_write_buf()
105 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in otm8009a_dcs_write_buf_hs() local
107 /* data will be sent in dsi hs mode (ie. no lpm) */ in otm8009a_dcs_write_buf_hs()
108 dsi->mode_flags &= ~MIPI_DSI_MODE_LPM; in otm8009a_dcs_write_buf_hs()
112 /* restore back the dsi lpm mode */ in otm8009a_dcs_write_buf_hs()
113 dsi->mode_flags |= MIPI_DSI_MODE_LPM; in otm8009a_dcs_write_buf_hs()
130 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in otm8009a_init_sequence() local
211 ret = mipi_dsi_dcs_nop(dsi); in otm8009a_init_sequence()
215 ret = mipi_dsi_dcs_exit_sleep_mode(dsi); in otm8009a_init_sequence()
225 ret = mipi_dsi_dcs_set_column_address(dsi, 0, in otm8009a_init_sequence()
226 default_mode.hdisplay - 1); in otm8009a_init_sequence()
230 ret = mipi_dsi_dcs_set_page_address(dsi, 0, default_mode.vdisplay - 1); in otm8009a_init_sequence()
235 ret = mipi_dsi_dcs_set_pixel_format(dsi, MIPI_DCS_PIXEL_FMT_24BIT | in otm8009a_init_sequence()
243 ret = mipi_dsi_dcs_set_display_on(dsi); in otm8009a_init_sequence()
247 ret = mipi_dsi_dcs_nop(dsi); in otm8009a_init_sequence()
254 /* Wait a short while to let the panel be ready before the 1st frame */ in otm8009a_init_sequence()
260 static int otm8009a_disable(struct drm_panel *panel) in otm8009a_disable() argument
262 struct otm8009a *ctx = panel_to_otm8009a(panel); in otm8009a_disable()
263 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in otm8009a_disable() local
266 if (!ctx->enabled) in otm8009a_disable()
269 backlight_disable(ctx->bl_dev); in otm8009a_disable()
271 ret = mipi_dsi_dcs_set_display_off(dsi); in otm8009a_disable()
275 ret = mipi_dsi_dcs_enter_sleep_mode(dsi); in otm8009a_disable()
281 ctx->enabled = false; in otm8009a_disable()
286 static int otm8009a_unprepare(struct drm_panel *panel) in otm8009a_unprepare() argument
288 struct otm8009a *ctx = panel_to_otm8009a(panel); in otm8009a_unprepare()
290 if (!ctx->prepared) in otm8009a_unprepare()
293 if (ctx->reset_gpio) { in otm8009a_unprepare()
294 gpiod_set_value_cansleep(ctx->reset_gpio, 1); in otm8009a_unprepare()
298 regulator_disable(ctx->supply); in otm8009a_unprepare()
300 ctx->prepared = false; in otm8009a_unprepare()
305 static int otm8009a_prepare(struct drm_panel *panel) in otm8009a_prepare() argument
307 struct otm8009a *ctx = panel_to_otm8009a(panel); in otm8009a_prepare()
310 if (ctx->prepared) in otm8009a_prepare()
313 ret = regulator_enable(ctx->supply); in otm8009a_prepare()
315 dev_err(panel->dev, "failed to enable supply: %d\n", ret); in otm8009a_prepare()
319 if (ctx->reset_gpio) { in otm8009a_prepare()
320 gpiod_set_value_cansleep(ctx->reset_gpio, 0); in otm8009a_prepare()
321 gpiod_set_value_cansleep(ctx->reset_gpio, 1); in otm8009a_prepare()
323 gpiod_set_value_cansleep(ctx->reset_gpio, 0); in otm8009a_prepare()
331 ctx->prepared = true; in otm8009a_prepare()
336 static int otm8009a_enable(struct drm_panel *panel) in otm8009a_enable() argument
338 struct otm8009a *ctx = panel_to_otm8009a(panel); in otm8009a_enable()
340 if (ctx->enabled) in otm8009a_enable()
343 backlight_enable(ctx->bl_dev); in otm8009a_enable()
345 ctx->enabled = true; in otm8009a_enable()
350 static int otm8009a_get_modes(struct drm_panel *panel, in otm8009a_get_modes() argument
355 mode = drm_mode_duplicate(connector->dev, &default_mode); in otm8009a_get_modes()
357 dev_err(panel->dev, "failed to add mode %ux%u@%u\n", in otm8009a_get_modes()
360 return -ENOMEM; in otm8009a_get_modes()
365 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; in otm8009a_get_modes()
368 connector->display_info.width_mm = mode->width_mm; in otm8009a_get_modes()
369 connector->display_info.height_mm = mode->height_mm; in otm8009a_get_modes()
383 * DSI-BASED BACKLIGHT
391 if (!ctx->prepared) { in otm8009a_backlight_update_status()
392 dev_dbg(&bd->dev, "lcd not ready yet for setting its backlight!\n"); in otm8009a_backlight_update_status()
393 return -ENXIO; in otm8009a_backlight_update_status()
396 if (bd->props.power <= FB_BLANK_NORMAL) { in otm8009a_backlight_update_status()
399 * as otm8009a driver support only 8-bit brightness (1 param). in otm8009a_backlight_update_status()
402 data[1] = bd->props.brightness; in otm8009a_backlight_update_status()
424 static int otm8009a_probe(struct mipi_dsi_device *dsi) in otm8009a_probe() argument
426 struct device *dev = &dsi->dev; in otm8009a_probe()
432 return -ENOMEM; in otm8009a_probe()
434 ctx->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in otm8009a_probe()
435 if (IS_ERR(ctx->reset_gpio)) { in otm8009a_probe()
436 dev_err(dev, "cannot get reset-gpio\n"); in otm8009a_probe()
437 return PTR_ERR(ctx->reset_gpio); in otm8009a_probe()
440 ctx->supply = devm_regulator_get(dev, "power"); in otm8009a_probe()
441 if (IS_ERR(ctx->supply)) { in otm8009a_probe()
442 ret = PTR_ERR(ctx->supply); in otm8009a_probe()
443 if (ret != -EPROBE_DEFER) in otm8009a_probe()
448 mipi_dsi_set_drvdata(dsi, ctx); in otm8009a_probe()
450 ctx->dev = dev; in otm8009a_probe()
452 dsi->lanes = 2; in otm8009a_probe()
453 dsi->format = MIPI_DSI_FMT_RGB888; in otm8009a_probe()
454 dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | in otm8009a_probe()
457 drm_panel_init(&ctx->panel, dev, &otm8009a_drm_funcs, in otm8009a_probe()
460 ctx->bl_dev = devm_backlight_device_register(dev, dev_name(dev), in otm8009a_probe()
461 dsi->host->dev, ctx, in otm8009a_probe()
464 if (IS_ERR(ctx->bl_dev)) { in otm8009a_probe()
465 ret = PTR_ERR(ctx->bl_dev); in otm8009a_probe()
470 ctx->bl_dev->props.max_brightness = OTM8009A_BACKLIGHT_MAX; in otm8009a_probe()
471 ctx->bl_dev->props.brightness = OTM8009A_BACKLIGHT_DEFAULT; in otm8009a_probe()
472 ctx->bl_dev->props.power = FB_BLANK_POWERDOWN; in otm8009a_probe()
473 ctx->bl_dev->props.type = BACKLIGHT_RAW; in otm8009a_probe()
475 drm_panel_add(&ctx->panel); in otm8009a_probe()
477 ret = mipi_dsi_attach(dsi); in otm8009a_probe()
480 drm_panel_remove(&ctx->panel); in otm8009a_probe()
487 static int otm8009a_remove(struct mipi_dsi_device *dsi) in otm8009a_remove() argument
489 struct otm8009a *ctx = mipi_dsi_get_drvdata(dsi); in otm8009a_remove()
491 mipi_dsi_detach(dsi); in otm8009a_remove()
492 drm_panel_remove(&ctx->panel); in otm8009a_remove()
507 .name = "panel-orisetech-otm8009a",
515 MODULE_DESCRIPTION("DRM driver for Orise Tech OTM8009A MIPI DSI panel");