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

1 // SPDX-License-Identifier: GPL-2.0
3 * Xinpeng xpp055c272 5.5" MIPI-DSI panel driver
8 * Rockteck jh057n00900 5.5" MIPI-DSI panel driver
21 #include <linux/media-bus-format.h>
26 /* Manufacturer specific Commands send via DSI */
51 struct drm_panel panel; member
58 static inline struct xpp055c272 *panel_to_xpp055c272(struct drm_panel *panel) in panel_to_xpp055c272() argument
60 return container_of(panel, struct xpp055c272, panel); in panel_to_xpp055c272()
63 #define dsi_generic_write_seq(dsi, cmd, seq...) do { \ argument
66 ret = mipi_dsi_dcs_write_buffer(dsi, b, ARRAY_SIZE(b)); \
73 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in xpp055c272_init_sequence() local
74 struct device *dev = ctx->dev; in xpp055c272_init_sequence()
77 * Init sequence was supplied by the panel vendor without much in xpp055c272_init_sequence()
80 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETEXTC, 0xf1, 0x12, 0x83); in xpp055c272_init_sequence()
81 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETMIPI, in xpp055c272_init_sequence()
86 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETPOWER_EXT, 0x25); in xpp055c272_init_sequence()
87 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETPCR, 0x02, 0x11, 0x00); in xpp055c272_init_sequence()
88 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETRGBIF, in xpp055c272_init_sequence()
91 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETSCR, in xpp055c272_init_sequence()
94 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETVDC, 0x46); in xpp055c272_init_sequence()
95 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETPANEL, 0x0b); in xpp055c272_init_sequence()
96 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETCYC, 0x80); in xpp055c272_init_sequence()
97 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETDISP, 0xc8, 0x12, 0x30); in xpp055c272_init_sequence()
98 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETEQ, in xpp055c272_init_sequence()
101 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETPOWER, in xpp055c272_init_sequence()
104 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETECO, 0x00, 0x00, 0xff, in xpp055c272_init_sequence()
106 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETBGP, 0x09, 0x09); in xpp055c272_init_sequence()
109 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETVCOM, 0x87, 0x95); in xpp055c272_init_sequence()
110 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETGIP1, in xpp055c272_init_sequence()
119 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETGIP2, in xpp055c272_init_sequence()
128 dsi_generic_write_seq(dsi, XPP055C272_CMD_SETGAMMA, in xpp055c272_init_sequence()
137 dev_dbg(dev, "Panel init sequence done\n"); in xpp055c272_init_sequence()
141 static int xpp055c272_unprepare(struct drm_panel *panel) in xpp055c272_unprepare() argument
143 struct xpp055c272 *ctx = panel_to_xpp055c272(panel); in xpp055c272_unprepare()
144 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in xpp055c272_unprepare() local
147 if (!ctx->prepared) in xpp055c272_unprepare()
150 ret = mipi_dsi_dcs_set_display_off(dsi); in xpp055c272_unprepare()
152 dev_err(ctx->dev, "failed to set display off: %d\n", ret); in xpp055c272_unprepare()
154 mipi_dsi_dcs_enter_sleep_mode(dsi); in xpp055c272_unprepare()
156 dev_err(ctx->dev, "failed to enter sleep mode: %d\n", ret); in xpp055c272_unprepare()
160 regulator_disable(ctx->iovcc); in xpp055c272_unprepare()
161 regulator_disable(ctx->vci); in xpp055c272_unprepare()
163 ctx->prepared = false; in xpp055c272_unprepare()
168 static int xpp055c272_prepare(struct drm_panel *panel) in xpp055c272_prepare() argument
170 struct xpp055c272 *ctx = panel_to_xpp055c272(panel); in xpp055c272_prepare()
171 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in xpp055c272_prepare() local
174 if (ctx->prepared) in xpp055c272_prepare()
177 dev_dbg(ctx->dev, "Resetting the panel\n"); in xpp055c272_prepare()
178 ret = regulator_enable(ctx->vci); in xpp055c272_prepare()
180 dev_err(ctx->dev, "Failed to enable vci supply: %d\n", ret); in xpp055c272_prepare()
183 ret = regulator_enable(ctx->iovcc); in xpp055c272_prepare()
185 dev_err(ctx->dev, "Failed to enable iovcc supply: %d\n", ret); in xpp055c272_prepare()
189 gpiod_set_value_cansleep(ctx->reset_gpio, 1); in xpp055c272_prepare()
192 gpiod_set_value_cansleep(ctx->reset_gpio, 0); in xpp055c272_prepare()
199 dev_err(ctx->dev, "Panel init sequence failed: %d\n", ret); in xpp055c272_prepare()
203 ret = mipi_dsi_dcs_exit_sleep_mode(dsi); in xpp055c272_prepare()
205 dev_err(ctx->dev, "Failed to exit sleep mode: %d\n", ret); in xpp055c272_prepare()
212 ret = mipi_dsi_dcs_set_display_on(dsi); in xpp055c272_prepare()
214 dev_err(ctx->dev, "Failed to set display on: %d\n", ret); in xpp055c272_prepare()
220 ctx->prepared = true; in xpp055c272_prepare()
225 regulator_disable(ctx->iovcc); in xpp055c272_prepare()
227 regulator_disable(ctx->vci); in xpp055c272_prepare()
245 static int xpp055c272_get_modes(struct drm_panel *panel, in xpp055c272_get_modes() argument
248 struct xpp055c272 *ctx = panel_to_xpp055c272(panel); in xpp055c272_get_modes()
251 mode = drm_mode_duplicate(connector->dev, &default_mode); in xpp055c272_get_modes()
253 dev_err(ctx->dev, "Failed to add mode %ux%u@%u\n", in xpp055c272_get_modes()
256 return -ENOMEM; in xpp055c272_get_modes()
261 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; in xpp055c272_get_modes()
262 connector->display_info.width_mm = mode->width_mm; in xpp055c272_get_modes()
263 connector->display_info.height_mm = mode->height_mm; in xpp055c272_get_modes()
275 static int xpp055c272_probe(struct mipi_dsi_device *dsi) in xpp055c272_probe() argument
277 struct device *dev = &dsi->dev; in xpp055c272_probe()
283 return -ENOMEM; in xpp055c272_probe()
285 ctx->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in xpp055c272_probe()
286 if (IS_ERR(ctx->reset_gpio)) { in xpp055c272_probe()
288 return PTR_ERR(ctx->reset_gpio); in xpp055c272_probe()
291 ctx->vci = devm_regulator_get(dev, "vci"); in xpp055c272_probe()
292 if (IS_ERR(ctx->vci)) { in xpp055c272_probe()
293 ret = PTR_ERR(ctx->vci); in xpp055c272_probe()
294 if (ret != -EPROBE_DEFER) in xpp055c272_probe()
299 ctx->iovcc = devm_regulator_get(dev, "iovcc"); in xpp055c272_probe()
300 if (IS_ERR(ctx->iovcc)) { in xpp055c272_probe()
301 ret = PTR_ERR(ctx->iovcc); in xpp055c272_probe()
302 if (ret != -EPROBE_DEFER) in xpp055c272_probe()
307 mipi_dsi_set_drvdata(dsi, ctx); in xpp055c272_probe()
309 ctx->dev = dev; in xpp055c272_probe()
311 dsi->lanes = 4; in xpp055c272_probe()
312 dsi->format = MIPI_DSI_FMT_RGB888; in xpp055c272_probe()
313 dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | in xpp055c272_probe()
316 drm_panel_init(&ctx->panel, &dsi->dev, &xpp055c272_funcs, in xpp055c272_probe()
319 ret = drm_panel_of_backlight(&ctx->panel); in xpp055c272_probe()
323 drm_panel_add(&ctx->panel); in xpp055c272_probe()
325 ret = mipi_dsi_attach(dsi); in xpp055c272_probe()
328 drm_panel_remove(&ctx->panel); in xpp055c272_probe()
335 static void xpp055c272_shutdown(struct mipi_dsi_device *dsi) in xpp055c272_shutdown() argument
337 struct xpp055c272 *ctx = mipi_dsi_get_drvdata(dsi); in xpp055c272_shutdown()
340 ret = drm_panel_unprepare(&ctx->panel); in xpp055c272_shutdown()
342 dev_err(&dsi->dev, "Failed to unprepare panel: %d\n", ret); in xpp055c272_shutdown()
344 ret = drm_panel_disable(&ctx->panel); in xpp055c272_shutdown()
346 dev_err(&dsi->dev, "Failed to disable panel: %d\n", ret); in xpp055c272_shutdown()
349 static int xpp055c272_remove(struct mipi_dsi_device *dsi) in xpp055c272_remove() argument
351 struct xpp055c272 *ctx = mipi_dsi_get_drvdata(dsi); in xpp055c272_remove()
354 xpp055c272_shutdown(dsi); in xpp055c272_remove()
356 ret = mipi_dsi_detach(dsi); in xpp055c272_remove()
358 dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret); in xpp055c272_remove()
360 drm_panel_remove(&ctx->panel); in xpp055c272_remove()
373 .name = "panel-xinpeng-xpp055c272",
382 MODULE_AUTHOR("Heiko Stuebner <heiko.stuebner@theobroma-systems.com>");
383 MODULE_DESCRIPTION("DRM driver for Xinpeng xpp055c272 MIPI DSI panel");