Lines Matching +full:mipi +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 */
53 #define dsi_dcs_write_seq(dsi, cmd, seq...) do { \ argument
56 ret = mipi_dsi_dcs_write_buffer(dsi, b, ARRAY_SIZE(b)); \
63 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in kd35t133_init_sequence() local
64 struct device *dev = ctx->dev; in kd35t133_init_sequence()
70 dsi_dcs_write_seq(dsi, KD35T133_CMD_POSITIVEGAMMA, in kd35t133_init_sequence()
73 dsi_dcs_write_seq(dsi, KD35T133_CMD_NEGATIVEGAMMA, in kd35t133_init_sequence()
76 dsi_dcs_write_seq(dsi, KD35T133_CMD_POWERCONTROL1, 0x18, 0x17); in kd35t133_init_sequence()
77 dsi_dcs_write_seq(dsi, KD35T133_CMD_POWERCONTROL2, 0x41); in kd35t133_init_sequence()
78 dsi_dcs_write_seq(dsi, KD35T133_CMD_VCOMCONTROL, 0x00, 0x1a, 0x80); in kd35t133_init_sequence()
79 dsi_dcs_write_seq(dsi, MIPI_DCS_SET_ADDRESS_MODE, 0x48); in kd35t133_init_sequence()
80 dsi_dcs_write_seq(dsi, MIPI_DCS_SET_PIXEL_FORMAT, 0x55); in kd35t133_init_sequence()
81 dsi_dcs_write_seq(dsi, KD35T133_CMD_INTERFACEMODECTRL, 0x00); in kd35t133_init_sequence()
82 dsi_dcs_write_seq(dsi, KD35T133_CMD_FRAMERATECTRL, 0xa0); in kd35t133_init_sequence()
83 dsi_dcs_write_seq(dsi, KD35T133_CMD_DISPLAYINVERSIONCTRL, 0x02); in kd35t133_init_sequence()
84 dsi_dcs_write_seq(dsi, KD35T133_CMD_DISPLAYFUNCTIONCTRL, in kd35t133_init_sequence()
86 dsi_dcs_write_seq(dsi, KD35T133_CMD_SETIMAGEFUNCTION, 0x00); in kd35t133_init_sequence()
87 dsi_dcs_write_seq(dsi, KD35T133_CMD_ADJUSTCONTROL3, in kd35t133_init_sequence()
89 mipi_dsi_dcs_write(dsi, MIPI_DCS_ENTER_INVERT_MODE, NULL, 0); in kd35t133_init_sequence()
98 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in kd35t133_unprepare() local
101 if (!ctx->prepared) in kd35t133_unprepare()
104 ret = mipi_dsi_dcs_set_display_off(dsi); in kd35t133_unprepare()
106 dev_err(ctx->dev, "failed to set display off: %d\n", ret); in kd35t133_unprepare()
108 ret = mipi_dsi_dcs_enter_sleep_mode(dsi); in kd35t133_unprepare()
110 dev_err(ctx->dev, "failed to enter sleep mode: %d\n", ret); in kd35t133_unprepare()
114 regulator_disable(ctx->iovcc); in kd35t133_unprepare()
115 regulator_disable(ctx->vdd); in kd35t133_unprepare()
117 ctx->prepared = false; in kd35t133_unprepare()
125 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in kd35t133_prepare() local
128 if (ctx->prepared) in kd35t133_prepare()
131 dev_dbg(ctx->dev, "Resetting the panel\n"); in kd35t133_prepare()
132 ret = regulator_enable(ctx->vdd); in kd35t133_prepare()
134 dev_err(ctx->dev, "Failed to enable vdd supply: %d\n", ret); in kd35t133_prepare()
138 ret = regulator_enable(ctx->iovcc); in kd35t133_prepare()
140 dev_err(ctx->dev, "Failed to enable iovcc supply: %d\n", ret); in kd35t133_prepare()
146 gpiod_set_value_cansleep(ctx->reset_gpio, 1); in kd35t133_prepare()
148 gpiod_set_value_cansleep(ctx->reset_gpio, 0); in kd35t133_prepare()
152 ret = mipi_dsi_dcs_exit_sleep_mode(dsi); in kd35t133_prepare()
154 dev_err(ctx->dev, "Failed to exit sleep mode: %d\n", ret); in kd35t133_prepare()
162 dev_err(ctx->dev, "Panel init sequence failed: %d\n", ret); in kd35t133_prepare()
166 ret = mipi_dsi_dcs_set_display_on(dsi); in kd35t133_prepare()
168 dev_err(ctx->dev, "Failed to set display on: %d\n", ret); in kd35t133_prepare()
174 ctx->prepared = true; in kd35t133_prepare()
179 regulator_disable(ctx->iovcc); in kd35t133_prepare()
181 regulator_disable(ctx->vdd); in kd35t133_prepare()
205 mode = drm_mode_duplicate(connector->dev, &default_mode); in kd35t133_get_modes()
207 dev_err(ctx->dev, "Failed to add mode %ux%u@%u\n", in kd35t133_get_modes()
210 return -ENOMEM; in kd35t133_get_modes()
215 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; in kd35t133_get_modes()
216 connector->display_info.width_mm = mode->width_mm; in kd35t133_get_modes()
217 connector->display_info.height_mm = mode->height_mm; in kd35t133_get_modes()
229 static int kd35t133_probe(struct mipi_dsi_device *dsi) in kd35t133_probe() argument
231 struct device *dev = &dsi->dev; in kd35t133_probe()
237 return -ENOMEM; in kd35t133_probe()
239 ctx->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in kd35t133_probe()
240 if (IS_ERR(ctx->reset_gpio)) { in kd35t133_probe()
242 return PTR_ERR(ctx->reset_gpio); in kd35t133_probe()
245 ctx->vdd = devm_regulator_get(dev, "vdd"); in kd35t133_probe()
246 if (IS_ERR(ctx->vdd)) { in kd35t133_probe()
247 ret = PTR_ERR(ctx->vdd); in kd35t133_probe()
248 if (ret != -EPROBE_DEFER) in kd35t133_probe()
253 ctx->iovcc = devm_regulator_get(dev, "iovcc"); in kd35t133_probe()
254 if (IS_ERR(ctx->iovcc)) { in kd35t133_probe()
255 ret = PTR_ERR(ctx->iovcc); in kd35t133_probe()
256 if (ret != -EPROBE_DEFER) in kd35t133_probe()
261 mipi_dsi_set_drvdata(dsi, ctx); in kd35t133_probe()
263 ctx->dev = dev; in kd35t133_probe()
265 dsi->lanes = 1; in kd35t133_probe()
266 dsi->format = MIPI_DSI_FMT_RGB888; in kd35t133_probe()
267 dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | in kd35t133_probe()
270 drm_panel_init(&ctx->panel, &dsi->dev, &kd35t133_funcs, in kd35t133_probe()
273 ret = drm_panel_of_backlight(&ctx->panel); in kd35t133_probe()
277 drm_panel_add(&ctx->panel); in kd35t133_probe()
279 ret = mipi_dsi_attach(dsi); in kd35t133_probe()
282 drm_panel_remove(&ctx->panel); in kd35t133_probe()
289 static void kd35t133_shutdown(struct mipi_dsi_device *dsi) in kd35t133_shutdown() argument
291 struct kd35t133 *ctx = mipi_dsi_get_drvdata(dsi); in kd35t133_shutdown()
294 ret = drm_panel_unprepare(&ctx->panel); in kd35t133_shutdown()
296 dev_err(&dsi->dev, "Failed to unprepare panel: %d\n", ret); in kd35t133_shutdown()
298 ret = drm_panel_disable(&ctx->panel); in kd35t133_shutdown()
300 dev_err(&dsi->dev, "Failed to disable panel: %d\n", ret); in kd35t133_shutdown()
303 static int kd35t133_remove(struct mipi_dsi_device *dsi) in kd35t133_remove() argument
305 struct kd35t133 *ctx = mipi_dsi_get_drvdata(dsi); in kd35t133_remove()
308 kd35t133_shutdown(dsi); in kd35t133_remove()
310 ret = mipi_dsi_detach(dsi); in kd35t133_remove()
312 dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret); in kd35t133_remove()
314 drm_panel_remove(&ctx->panel); in kd35t133_remove()
327 .name = "panel-elida-kd35t133",
336 MODULE_AUTHOR("Heiko Stuebner <heiko.stuebner@theobroma-systems.com>");
337 MODULE_DESCRIPTION("DRM driver for Elida kd35t133 MIPI DSI panel");