Lines Matching +full:rg353p +full:- +full:panel
1 // SPDX-License-Identifier: GPL-2.0
3 * NV3051D MIPI-DSI panel driver for Anbernic RG353x
8 * Elida kd35t133 3.5" MIPI-DSI panel driver
14 #include <linux/media-bus-format.h>
36 struct drm_panel panel; member
42 static inline struct panel_nv3051d *panel_to_panelnv3051d(struct drm_panel *panel) in panel_to_panelnv3051d() argument
44 return container_of(panel, struct panel_nv3051d, panel); in panel_to_panelnv3051d()
49 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in panel_nv3051d_init_sequence()
241 dev_dbg(ctx->dev, "Panel init sequence done\n"); in panel_nv3051d_init_sequence()
246 static int panel_nv3051d_unprepare(struct drm_panel *panel) in panel_nv3051d_unprepare() argument
248 struct panel_nv3051d *ctx = panel_to_panelnv3051d(panel); in panel_nv3051d_unprepare()
249 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in panel_nv3051d_unprepare()
254 dev_err(ctx->dev, "failed to set display off: %d\n", ret); in panel_nv3051d_unprepare()
260 dev_err(ctx->dev, "failed to enter sleep mode: %d\n", ret); in panel_nv3051d_unprepare()
266 gpiod_set_value_cansleep(ctx->reset_gpio, 1); in panel_nv3051d_unprepare()
268 regulator_disable(ctx->vdd); in panel_nv3051d_unprepare()
273 static int panel_nv3051d_prepare(struct drm_panel *panel) in panel_nv3051d_prepare() argument
275 struct panel_nv3051d *ctx = panel_to_panelnv3051d(panel); in panel_nv3051d_prepare()
276 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in panel_nv3051d_prepare()
279 dev_dbg(ctx->dev, "Resetting the panel\n"); in panel_nv3051d_prepare()
280 ret = regulator_enable(ctx->vdd); in panel_nv3051d_prepare()
282 dev_err(ctx->dev, "Failed to enable vdd supply: %d\n", ret); in panel_nv3051d_prepare()
287 gpiod_set_value_cansleep(ctx->reset_gpio, 1); in panel_nv3051d_prepare()
289 gpiod_set_value_cansleep(ctx->reset_gpio, 0); in panel_nv3051d_prepare()
294 dev_err(ctx->dev, "Panel init sequence failed: %d\n", ret); in panel_nv3051d_prepare()
300 dev_err(ctx->dev, "Failed to exit sleep mode: %d\n", ret); in panel_nv3051d_prepare()
308 dev_err(ctx->dev, "Failed to set display on: %d\n", ret); in panel_nv3051d_prepare()
317 regulator_disable(ctx->vdd); in panel_nv3051d_prepare()
321 static int panel_nv3051d_get_modes(struct drm_panel *panel, in panel_nv3051d_get_modes() argument
324 struct panel_nv3051d *ctx = panel_to_panelnv3051d(panel); in panel_nv3051d_get_modes()
325 const struct nv3051d_panel_info *panel_info = ctx->panel_info; in panel_nv3051d_get_modes()
329 for (i = 0; i < panel_info->num_modes; i++) { in panel_nv3051d_get_modes()
330 mode = drm_mode_duplicate(connector->dev, in panel_nv3051d_get_modes()
331 &panel_info->display_modes[i]); in panel_nv3051d_get_modes()
333 return -ENOMEM; in panel_nv3051d_get_modes()
337 mode->type = DRM_MODE_TYPE_DRIVER; in panel_nv3051d_get_modes()
338 if (panel_info->num_modes == 1) in panel_nv3051d_get_modes()
339 mode->type |= DRM_MODE_TYPE_PREFERRED; in panel_nv3051d_get_modes()
344 connector->display_info.bpc = 8; in panel_nv3051d_get_modes()
345 connector->display_info.width_mm = panel_info->width_mm; in panel_nv3051d_get_modes()
346 connector->display_info.height_mm = panel_info->height_mm; in panel_nv3051d_get_modes()
347 connector->display_info.bus_flags = panel_info->bus_flags; in panel_nv3051d_get_modes()
349 return panel_info->num_modes; in panel_nv3051d_get_modes()
360 struct device *dev = &dsi->dev; in panel_nv3051d_probe()
366 return -ENOMEM; in panel_nv3051d_probe()
368 ctx->dev = dev; in panel_nv3051d_probe()
370 ctx->panel_info = of_device_get_match_data(dev); in panel_nv3051d_probe()
371 if (!ctx->panel_info) in panel_nv3051d_probe()
372 return -EINVAL; in panel_nv3051d_probe()
374 ctx->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); in panel_nv3051d_probe()
375 if (IS_ERR(ctx->reset_gpio)) { in panel_nv3051d_probe()
377 return PTR_ERR(ctx->reset_gpio); in panel_nv3051d_probe()
380 ctx->vdd = devm_regulator_get(dev, "vdd"); in panel_nv3051d_probe()
381 if (IS_ERR(ctx->vdd)) { in panel_nv3051d_probe()
382 ret = PTR_ERR(ctx->vdd); in panel_nv3051d_probe()
383 if (ret != -EPROBE_DEFER) in panel_nv3051d_probe()
390 dsi->lanes = 4; in panel_nv3051d_probe()
391 dsi->format = MIPI_DSI_FMT_RGB888; in panel_nv3051d_probe()
392 dsi->mode_flags = ctx->panel_info->mode_flags; in panel_nv3051d_probe()
394 drm_panel_init(&ctx->panel, &dsi->dev, &panel_nv3051d_funcs, in panel_nv3051d_probe()
397 ret = drm_panel_of_backlight(&ctx->panel); in panel_nv3051d_probe()
401 drm_panel_add(&ctx->panel); in panel_nv3051d_probe()
406 drm_panel_remove(&ctx->panel); in panel_nv3051d_probe()
418 ret = drm_panel_unprepare(&ctx->panel); in panel_nv3051d_shutdown()
420 dev_err(&dsi->dev, "Failed to unprepare panel: %d\n", ret); in panel_nv3051d_shutdown()
422 ret = drm_panel_disable(&ctx->panel); in panel_nv3051d_shutdown()
424 dev_err(&dsi->dev, "Failed to disable panel: %d\n", ret); in panel_nv3051d_shutdown()
436 dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret); in panel_nv3051d_remove()
438 drm_panel_remove(&ctx->panel); in panel_nv3051d_remove()
527 { .compatible = "anbernic,rg351v-panel", .data = &nv3051d_rg351v_info },
528 { .compatible = "anbernic,rg353p-panel", .data = &nv3051d_rg353p_info },
529 { .compatible = "powkiddy,rk2023-panel", .data = &nv3051d_rk2023_info },
536 .name = "panel-newvision-nv3051d",