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

1 // SPDX-License-Identifier: GPL-2.0
3 * Mantix MLAF057WE51 5.7" MIPI-DSI panel driver
11 #include <linux/media-bus-format.h>
22 #define DRV_NAME "panel-mantix-mlaf057we51"
24 /* Manufacturer specific Commands send via DSI */
31 struct drm_panel panel; member
43 static inline struct mantix *panel_to_mantix(struct drm_panel *panel) in panel_to_mantix() argument
45 return container_of(panel, struct mantix, panel); in panel_to_mantix()
51 * Init sequence was supplied by the panel vendor. in mantix_init_sequence()
68 static int mantix_enable(struct drm_panel *panel) in mantix_enable() argument
70 struct mantix *ctx = panel_to_mantix(panel); in mantix_enable()
71 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in mantix_enable() local
72 struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi }; in mantix_enable()
76 dev_dbg(ctx->dev, "Panel init sequence done\n"); in mantix_enable()
89 static int mantix_disable(struct drm_panel *panel) in mantix_disable() argument
91 struct mantix *ctx = panel_to_mantix(panel); in mantix_disable()
92 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in mantix_disable() local
93 struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi }; in mantix_disable()
101 static int mantix_unprepare(struct drm_panel *panel) in mantix_unprepare() argument
103 struct mantix *ctx = panel_to_mantix(panel); in mantix_unprepare()
105 gpiod_set_value_cansleep(ctx->tp_rstn_gpio, 1); in mantix_unprepare()
107 gpiod_set_value_cansleep(ctx->reset_gpio, 1); in mantix_unprepare()
109 regulator_disable(ctx->avee); in mantix_unprepare()
110 regulator_disable(ctx->avdd); in mantix_unprepare()
113 regulator_disable(ctx->vddi); in mantix_unprepare()
120 static int mantix_prepare(struct drm_panel *panel) in mantix_prepare() argument
122 struct mantix *ctx = panel_to_mantix(panel); in mantix_prepare()
126 dev_dbg(ctx->dev, "Resetting the panel\n"); in mantix_prepare()
127 ret = regulator_enable(ctx->vddi); in mantix_prepare()
129 dev_err(ctx->dev, "Failed to enable vddi supply: %d\n", ret); in mantix_prepare()
136 ret = regulator_enable(ctx->avdd); in mantix_prepare()
138 dev_err(ctx->dev, "Failed to enable avdd supply: %d\n", ret); in mantix_prepare()
144 ret = regulator_enable(ctx->avee); in mantix_prepare()
146 dev_err(ctx->dev, "Failed to enable avee supply: %d\n", ret); in mantix_prepare()
152 gpiod_set_value_cansleep(ctx->reset_gpio, 0); in mantix_prepare()
153 gpiod_set_value_cansleep(ctx->tp_rstn_gpio, 0); in mantix_prepare()
195 static int mantix_get_modes(struct drm_panel *panel, in mantix_get_modes() argument
198 struct mantix *ctx = panel_to_mantix(panel); in mantix_get_modes()
201 mode = drm_mode_duplicate(connector->dev, ctx->default_mode); in mantix_get_modes()
203 dev_err(ctx->dev, "Failed to add mode %ux%u@%u\n", in mantix_get_modes()
204 ctx->default_mode->hdisplay, ctx->default_mode->vdisplay, in mantix_get_modes()
205 drm_mode_vrefresh(ctx->default_mode)); in mantix_get_modes()
206 return -ENOMEM; in mantix_get_modes()
211 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; in mantix_get_modes()
212 connector->display_info.width_mm = mode->width_mm; in mantix_get_modes()
213 connector->display_info.height_mm = mode->height_mm; in mantix_get_modes()
216 drm_display_info_set_bus_formats(&connector->display_info, in mantix_get_modes()
231 static int mantix_probe(struct mipi_dsi_device *dsi) in mantix_probe() argument
233 struct device *dev = &dsi->dev; in mantix_probe()
239 return -ENOMEM; in mantix_probe()
240 ctx->default_mode = of_device_get_match_data(dev); in mantix_probe()
242 ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in mantix_probe()
243 if (IS_ERR(ctx->reset_gpio)) { in mantix_probe()
245 return PTR_ERR(ctx->reset_gpio); in mantix_probe()
248 ctx->tp_rstn_gpio = devm_gpiod_get(dev, "mantix,tp-rstn", GPIOD_OUT_HIGH); in mantix_probe()
249 if (IS_ERR(ctx->tp_rstn_gpio)) { in mantix_probe()
250 dev_err(dev, "cannot get tp-rstn gpio\n"); in mantix_probe()
251 return PTR_ERR(ctx->tp_rstn_gpio); in mantix_probe()
254 mipi_dsi_set_drvdata(dsi, ctx); in mantix_probe()
255 ctx->dev = dev; in mantix_probe()
257 dsi->lanes = 4; in mantix_probe()
258 dsi->format = MIPI_DSI_FMT_RGB888; in mantix_probe()
259 dsi->mode_flags = MIPI_DSI_MODE_VIDEO | in mantix_probe()
262 ctx->avdd = devm_regulator_get(dev, "avdd"); in mantix_probe()
263 if (IS_ERR(ctx->avdd)) in mantix_probe()
264 return dev_err_probe(dev, PTR_ERR(ctx->avdd), "Failed to request avdd regulator\n"); in mantix_probe()
266 ctx->avee = devm_regulator_get(dev, "avee"); in mantix_probe()
267 if (IS_ERR(ctx->avee)) in mantix_probe()
268 return dev_err_probe(dev, PTR_ERR(ctx->avee), "Failed to request avee regulator\n"); in mantix_probe()
270 ctx->vddi = devm_regulator_get(dev, "vddi"); in mantix_probe()
271 if (IS_ERR(ctx->vddi)) in mantix_probe()
272 return dev_err_probe(dev, PTR_ERR(ctx->vddi), "Failed to request vddi regulator\n"); in mantix_probe()
274 drm_panel_init(&ctx->panel, dev, &mantix_drm_funcs, in mantix_probe()
277 ret = drm_panel_of_backlight(&ctx->panel); in mantix_probe()
281 drm_panel_add(&ctx->panel); in mantix_probe()
283 ret = mipi_dsi_attach(dsi); in mantix_probe()
286 drm_panel_remove(&ctx->panel); in mantix_probe()
290 dev_info(dev, "%ux%u@%u %ubpp dsi %udl - ready\n", in mantix_probe()
291 ctx->default_mode->hdisplay, ctx->default_mode->vdisplay, in mantix_probe()
292 drm_mode_vrefresh(ctx->default_mode), in mantix_probe()
293 mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes); in mantix_probe()
298 static void mantix_shutdown(struct mipi_dsi_device *dsi) in mantix_shutdown() argument
300 struct mantix *ctx = mipi_dsi_get_drvdata(dsi); in mantix_shutdown()
302 drm_panel_unprepare(&ctx->panel); in mantix_shutdown()
303 drm_panel_disable(&ctx->panel); in mantix_shutdown()
306 static void mantix_remove(struct mipi_dsi_device *dsi) in mantix_remove() argument
308 struct mantix *ctx = mipi_dsi_get_drvdata(dsi); in mantix_remove()
310 mantix_shutdown(dsi); in mantix_remove()
312 mipi_dsi_detach(dsi); in mantix_remove()
313 drm_panel_remove(&ctx->panel); in mantix_remove()
317 { .compatible = "mantix,mlaf057we51-x", .data = &default_mode_mantix },
335 MODULE_DESCRIPTION("DRM driver for Mantix MLAF057WE51-X MIPI DSI panel");