Lines Matching +full:panel +full:- +full:dsi

1 // SPDX-License-Identifier: GPL-2.0
3 * Elida kd35t133 5.5" MIPI-DSI panel driver
8 * Rockteck jh057n00900 5.5" MIPI-DSI panel driver
14 #include <linux/media-bus-format.h>
26 /* Manufacturer specific Commands send via DSI */
41 struct drm_panel panel; member
49 static inline struct kd35t133 *panel_to_kd35t133(struct drm_panel *panel) in panel_to_kd35t133() argument
51 return container_of(panel, struct kd35t133, panel); in panel_to_kd35t133()
56 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in kd35t133_init_sequence() local
57 struct device *dev = ctx->dev; in kd35t133_init_sequence()
60 * Init sequence was supplied by the panel vendor with minimal in kd35t133_init_sequence()
63 mipi_dsi_dcs_write_seq(dsi, KD35T133_CMD_POSITIVEGAMMA, in kd35t133_init_sequence()
66 mipi_dsi_dcs_write_seq(dsi, KD35T133_CMD_NEGATIVEGAMMA, in kd35t133_init_sequence()
69 mipi_dsi_dcs_write_seq(dsi, KD35T133_CMD_POWERCONTROL1, 0x18, 0x17); in kd35t133_init_sequence()
70 mipi_dsi_dcs_write_seq(dsi, KD35T133_CMD_POWERCONTROL2, 0x41); in kd35t133_init_sequence()
71 mipi_dsi_dcs_write_seq(dsi, KD35T133_CMD_VCOMCONTROL, 0x00, 0x1a, 0x80); in kd35t133_init_sequence()
72 mipi_dsi_dcs_write_seq(dsi, MIPI_DCS_SET_ADDRESS_MODE, 0x48); in kd35t133_init_sequence()
73 mipi_dsi_dcs_write_seq(dsi, MIPI_DCS_SET_PIXEL_FORMAT, 0x55); in kd35t133_init_sequence()
74 mipi_dsi_dcs_write_seq(dsi, KD35T133_CMD_INTERFACEMODECTRL, 0x00); in kd35t133_init_sequence()
75 mipi_dsi_dcs_write_seq(dsi, KD35T133_CMD_FRAMERATECTRL, 0xa0); in kd35t133_init_sequence()
76 mipi_dsi_dcs_write_seq(dsi, KD35T133_CMD_DISPLAYINVERSIONCTRL, 0x02); in kd35t133_init_sequence()
77 mipi_dsi_dcs_write_seq(dsi, KD35T133_CMD_DISPLAYFUNCTIONCTRL, in kd35t133_init_sequence()
79 mipi_dsi_dcs_write_seq(dsi, KD35T133_CMD_SETIMAGEFUNCTION, 0x00); in kd35t133_init_sequence()
80 mipi_dsi_dcs_write_seq(dsi, KD35T133_CMD_ADJUSTCONTROL3, in kd35t133_init_sequence()
82 mipi_dsi_dcs_write(dsi, MIPI_DCS_ENTER_INVERT_MODE, NULL, 0); in kd35t133_init_sequence()
84 dev_dbg(dev, "Panel init sequence done\n"); in kd35t133_init_sequence()
88 static int kd35t133_unprepare(struct drm_panel *panel) in kd35t133_unprepare() argument
90 struct kd35t133 *ctx = panel_to_kd35t133(panel); in kd35t133_unprepare()
91 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in kd35t133_unprepare() local
94 if (!ctx->prepared) in kd35t133_unprepare()
97 ret = mipi_dsi_dcs_set_display_off(dsi); in kd35t133_unprepare()
99 dev_err(ctx->dev, "failed to set display off: %d\n", ret); in kd35t133_unprepare()
101 ret = mipi_dsi_dcs_enter_sleep_mode(dsi); in kd35t133_unprepare()
103 dev_err(ctx->dev, "failed to enter sleep mode: %d\n", ret); in kd35t133_unprepare()
107 gpiod_set_value_cansleep(ctx->reset_gpio, 1); in kd35t133_unprepare()
109 regulator_disable(ctx->iovcc); in kd35t133_unprepare()
110 regulator_disable(ctx->vdd); in kd35t133_unprepare()
112 ctx->prepared = false; in kd35t133_unprepare()
117 static int kd35t133_prepare(struct drm_panel *panel) in kd35t133_prepare() argument
119 struct kd35t133 *ctx = panel_to_kd35t133(panel); in kd35t133_prepare()
120 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in kd35t133_prepare() local
123 if (ctx->prepared) in kd35t133_prepare()
126 dev_dbg(ctx->dev, "Resetting the panel\n"); in kd35t133_prepare()
127 ret = regulator_enable(ctx->vdd); in kd35t133_prepare()
129 dev_err(ctx->dev, "Failed to enable vdd supply: %d\n", ret); in kd35t133_prepare()
133 ret = regulator_enable(ctx->iovcc); in kd35t133_prepare()
135 dev_err(ctx->dev, "Failed to enable iovcc supply: %d\n", ret); in kd35t133_prepare()
141 gpiod_set_value_cansleep(ctx->reset_gpio, 1); in kd35t133_prepare()
143 gpiod_set_value_cansleep(ctx->reset_gpio, 0); in kd35t133_prepare()
147 ret = mipi_dsi_dcs_exit_sleep_mode(dsi); in kd35t133_prepare()
149 dev_err(ctx->dev, "Failed to exit sleep mode: %d\n", ret); in kd35t133_prepare()
157 dev_err(ctx->dev, "Panel init sequence failed: %d\n", ret); in kd35t133_prepare()
161 ret = mipi_dsi_dcs_set_display_on(dsi); in kd35t133_prepare()
163 dev_err(ctx->dev, "Failed to set display on: %d\n", ret); in kd35t133_prepare()
169 ctx->prepared = true; in kd35t133_prepare()
174 regulator_disable(ctx->iovcc); in kd35t133_prepare()
176 regulator_disable(ctx->vdd); in kd35t133_prepare()
194 static int kd35t133_get_modes(struct drm_panel *panel, in kd35t133_get_modes() argument
197 struct kd35t133 *ctx = panel_to_kd35t133(panel); in kd35t133_get_modes()
200 mode = drm_mode_duplicate(connector->dev, &default_mode); in kd35t133_get_modes()
202 dev_err(ctx->dev, "Failed to add mode %ux%u@%u\n", in kd35t133_get_modes()
205 return -ENOMEM; in kd35t133_get_modes()
210 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; in kd35t133_get_modes()
211 connector->display_info.width_mm = mode->width_mm; in kd35t133_get_modes()
212 connector->display_info.height_mm = mode->height_mm; in kd35t133_get_modes()
218 drm_connector_set_panel_orientation(connector, ctx->orientation); in kd35t133_get_modes()
223 static enum drm_panel_orientation kd35t133_get_orientation(struct drm_panel *panel) in kd35t133_get_orientation() argument
225 struct kd35t133 *ctx = panel_to_kd35t133(panel); in kd35t133_get_orientation()
227 return ctx->orientation; in kd35t133_get_orientation()
237 static int kd35t133_probe(struct mipi_dsi_device *dsi) in kd35t133_probe() argument
239 struct device *dev = &dsi->dev; in kd35t133_probe()
245 return -ENOMEM; in kd35t133_probe()
247 ctx->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in kd35t133_probe()
248 if (IS_ERR(ctx->reset_gpio)) { in kd35t133_probe()
250 return PTR_ERR(ctx->reset_gpio); in kd35t133_probe()
253 ctx->vdd = devm_regulator_get(dev, "vdd"); in kd35t133_probe()
254 if (IS_ERR(ctx->vdd)) { in kd35t133_probe()
255 ret = PTR_ERR(ctx->vdd); in kd35t133_probe()
256 if (ret != -EPROBE_DEFER) in kd35t133_probe()
261 ctx->iovcc = devm_regulator_get(dev, "iovcc"); in kd35t133_probe()
262 if (IS_ERR(ctx->iovcc)) { in kd35t133_probe()
263 ret = PTR_ERR(ctx->iovcc); in kd35t133_probe()
264 if (ret != -EPROBE_DEFER) in kd35t133_probe()
269 ret = of_drm_get_panel_orientation(dev->of_node, &ctx->orientation); in kd35t133_probe()
271 dev_err(dev, "%pOF: failed to get orientation %d\n", dev->of_node, ret); in kd35t133_probe()
275 mipi_dsi_set_drvdata(dsi, ctx); in kd35t133_probe()
277 ctx->dev = dev; in kd35t133_probe()
279 dsi->lanes = 1; in kd35t133_probe()
280 dsi->format = MIPI_DSI_FMT_RGB888; in kd35t133_probe()
281 dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | in kd35t133_probe()
285 drm_panel_init(&ctx->panel, &dsi->dev, &kd35t133_funcs, in kd35t133_probe()
288 ret = drm_panel_of_backlight(&ctx->panel); in kd35t133_probe()
292 drm_panel_add(&ctx->panel); in kd35t133_probe()
294 ret = mipi_dsi_attach(dsi); in kd35t133_probe()
297 drm_panel_remove(&ctx->panel); in kd35t133_probe()
304 static void kd35t133_shutdown(struct mipi_dsi_device *dsi) in kd35t133_shutdown() argument
306 struct kd35t133 *ctx = mipi_dsi_get_drvdata(dsi); in kd35t133_shutdown()
309 ret = drm_panel_unprepare(&ctx->panel); in kd35t133_shutdown()
311 dev_err(&dsi->dev, "Failed to unprepare panel: %d\n", ret); in kd35t133_shutdown()
313 ret = drm_panel_disable(&ctx->panel); in kd35t133_shutdown()
315 dev_err(&dsi->dev, "Failed to disable panel: %d\n", ret); in kd35t133_shutdown()
318 static void kd35t133_remove(struct mipi_dsi_device *dsi) in kd35t133_remove() argument
320 struct kd35t133 *ctx = mipi_dsi_get_drvdata(dsi); in kd35t133_remove()
323 kd35t133_shutdown(dsi); in kd35t133_remove()
325 ret = mipi_dsi_detach(dsi); in kd35t133_remove()
327 dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret); in kd35t133_remove()
329 drm_panel_remove(&ctx->panel); in kd35t133_remove()
340 .name = "panel-elida-kd35t133",
349 MODULE_AUTHOR("Heiko Stuebner <heiko.stuebner@theobroma-systems.com>");
350 MODULE_DESCRIPTION("DRM driver for Elida kd35t133 MIPI DSI panel");