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;
42 static inline struct panel_nv3051d *panel_to_panelnv3051d(struct drm_panel *panel)
44 return container_of(panel, struct panel_nv3051d, panel);
49 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
241 dev_dbg(ctx->dev, "Panel init sequence done\n");
246 static int panel_nv3051d_unprepare(struct drm_panel *panel)
248 struct panel_nv3051d *ctx = panel_to_panelnv3051d(panel);
249 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
254 dev_err(ctx->dev, "failed to set display off: %d\n", ret);
260 dev_err(ctx->dev, "failed to enter sleep mode: %d\n", ret);
266 gpiod_set_value_cansleep(ctx->reset_gpio, 1);
268 regulator_disable(ctx->vdd);
273 static int panel_nv3051d_prepare(struct drm_panel *panel)
275 struct panel_nv3051d *ctx = panel_to_panelnv3051d(panel);
276 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
279 dev_dbg(ctx->dev, "Resetting the panel\n");
280 ret = regulator_enable(ctx->vdd);
282 dev_err(ctx->dev, "Failed to enable vdd supply: %d\n", ret);
287 gpiod_set_value_cansleep(ctx->reset_gpio, 1);
289 gpiod_set_value_cansleep(ctx->reset_gpio, 0);
294 dev_err(ctx->dev, "Panel init sequence failed: %d\n", ret);
300 dev_err(ctx->dev, "Failed to exit sleep mode: %d\n", ret);
308 dev_err(ctx->dev, "Failed to set display on: %d\n", ret);
317 regulator_disable(ctx->vdd);
321 static int panel_nv3051d_get_modes(struct drm_panel *panel,
324 struct panel_nv3051d *ctx = panel_to_panelnv3051d(panel);
325 const struct nv3051d_panel_info *panel_info = ctx->panel_info;
329 for (i = 0; i < panel_info->num_modes; i++) {
330 mode = drm_mode_duplicate(connector->dev,
331 &panel_info->display_modes[i]);
333 return -ENOMEM;
337 mode->type = DRM_MODE_TYPE_DRIVER;
338 if (panel_info->num_modes == 1)
339 mode->type |= DRM_MODE_TYPE_PREFERRED;
344 connector->display_info.bpc = 8;
345 connector->display_info.width_mm = panel_info->width_mm;
346 connector->display_info.height_mm = panel_info->height_mm;
347 connector->display_info.bus_flags = panel_info->bus_flags;
349 return panel_info->num_modes;
360 struct device *dev = &dsi->dev;
364 ctx = devm_drm_panel_alloc(dev, struct panel_nv3051d, panel,
370 ctx->dev = dev;
372 ctx->panel_info = of_device_get_match_data(dev);
373 if (!ctx->panel_info)
374 return -EINVAL;
376 ctx->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
377 if (IS_ERR(ctx->reset_gpio)) {
379 return PTR_ERR(ctx->reset_gpio);
382 ctx->vdd = devm_regulator_get(dev, "vdd");
383 if (IS_ERR(ctx->vdd)) {
384 ret = PTR_ERR(ctx->vdd);
385 if (ret != -EPROBE_DEFER)
392 dsi->lanes = 4;
393 dsi->format = MIPI_DSI_FMT_RGB888;
394 dsi->mode_flags = ctx->panel_info->mode_flags;
396 ret = drm_panel_of_backlight(&ctx->panel);
400 drm_panel_add(&ctx->panel);
405 drm_panel_remove(&ctx->panel);
416 drm_panel_unprepare(&ctx->panel);
418 drm_panel_disable(&ctx->panel);
430 dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret);
432 drm_panel_remove(&ctx->panel);
521 { .compatible = "anbernic,rg351v-panel", .data = &nv3051d_rg351v_info },
522 { .compatible = "anbernic,rg353p-panel", .data = &nv3051d_rg353p_info },
523 { .compatible = "powkiddy,rk2023-panel", .data = &nv3051d_rk2023_info },
530 .name = "panel-newvision-nv3051d",