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

1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2018-2019, Bridge Systems BV
4 * Copyright (C) 2018-2019, Bootlin
7 * This file based on panel-ilitek-ili9881c.c
16 #include <linux/media-bus-format.h>
28 struct drm_panel panel; member
29 struct mipi_dsi_device *dsi; member
40 static inline struct rb070d30_panel *panel_to_rb070d30_panel(struct drm_panel *panel) in panel_to_rb070d30_panel() argument
42 return container_of(panel, struct rb070d30_panel, panel); in panel_to_rb070d30_panel()
45 static int rb070d30_panel_prepare(struct drm_panel *panel) in rb070d30_panel_prepare() argument
47 struct rb070d30_panel *ctx = panel_to_rb070d30_panel(panel); in rb070d30_panel_prepare()
50 ret = regulator_enable(ctx->supply); in rb070d30_panel_prepare()
52 dev_err(&ctx->dsi->dev, "Failed to enable supply: %d\n", ret); in rb070d30_panel_prepare()
57 gpiod_set_value(ctx->gpios.power, 1); in rb070d30_panel_prepare()
59 gpiod_set_value(ctx->gpios.reset, 1); in rb070d30_panel_prepare()
64 static int rb070d30_panel_unprepare(struct drm_panel *panel) in rb070d30_panel_unprepare() argument
66 struct rb070d30_panel *ctx = panel_to_rb070d30_panel(panel); in rb070d30_panel_unprepare()
68 gpiod_set_value(ctx->gpios.reset, 0); in rb070d30_panel_unprepare()
69 gpiod_set_value(ctx->gpios.power, 0); in rb070d30_panel_unprepare()
70 regulator_disable(ctx->supply); in rb070d30_panel_unprepare()
75 static int rb070d30_panel_enable(struct drm_panel *panel) in rb070d30_panel_enable() argument
77 struct rb070d30_panel *ctx = panel_to_rb070d30_panel(panel); in rb070d30_panel_enable()
80 ret = mipi_dsi_dcs_exit_sleep_mode(ctx->dsi); in rb070d30_panel_enable()
87 static int rb070d30_panel_disable(struct drm_panel *panel) in rb070d30_panel_disable() argument
89 struct rb070d30_panel *ctx = panel_to_rb070d30_panel(panel); in rb070d30_panel_disable()
91 return mipi_dsi_dcs_enter_sleep_mode(ctx->dsi); in rb070d30_panel_disable()
110 static int rb070d30_panel_get_modes(struct drm_panel *panel, in rb070d30_panel_get_modes() argument
113 struct rb070d30_panel *ctx = panel_to_rb070d30_panel(panel); in rb070d30_panel_get_modes()
117 mode = drm_mode_duplicate(connector->dev, &default_mode); in rb070d30_panel_get_modes()
119 dev_err(&ctx->dsi->dev, "Failed to add mode " DRM_MODE_FMT "\n", in rb070d30_panel_get_modes()
121 return -EINVAL; in rb070d30_panel_get_modes()
126 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; in rb070d30_panel_get_modes()
129 connector->display_info.bpc = 8; in rb070d30_panel_get_modes()
130 connector->display_info.width_mm = mode->width_mm; in rb070d30_panel_get_modes()
131 connector->display_info.height_mm = mode->height_mm; in rb070d30_panel_get_modes()
132 drm_display_info_set_bus_formats(&connector->display_info, in rb070d30_panel_get_modes()
146 static int rb070d30_panel_dsi_probe(struct mipi_dsi_device *dsi) in rb070d30_panel_dsi_probe() argument
151 ctx = devm_kzalloc(&dsi->dev, sizeof(*ctx), GFP_KERNEL); in rb070d30_panel_dsi_probe()
153 return -ENOMEM; in rb070d30_panel_dsi_probe()
155 ctx->supply = devm_regulator_get(&dsi->dev, "vcc-lcd"); in rb070d30_panel_dsi_probe()
156 if (IS_ERR(ctx->supply)) in rb070d30_panel_dsi_probe()
157 return PTR_ERR(ctx->supply); in rb070d30_panel_dsi_probe()
159 mipi_dsi_set_drvdata(dsi, ctx); in rb070d30_panel_dsi_probe()
160 ctx->dsi = dsi; in rb070d30_panel_dsi_probe()
162 drm_panel_init(&ctx->panel, &dsi->dev, &rb070d30_panel_funcs, in rb070d30_panel_dsi_probe()
165 ctx->gpios.reset = devm_gpiod_get(&dsi->dev, "reset", GPIOD_OUT_LOW); in rb070d30_panel_dsi_probe()
166 if (IS_ERR(ctx->gpios.reset)) { in rb070d30_panel_dsi_probe()
167 dev_err(&dsi->dev, "Couldn't get our reset GPIO\n"); in rb070d30_panel_dsi_probe()
168 return PTR_ERR(ctx->gpios.reset); in rb070d30_panel_dsi_probe()
171 ctx->gpios.power = devm_gpiod_get(&dsi->dev, "power", GPIOD_OUT_LOW); in rb070d30_panel_dsi_probe()
172 if (IS_ERR(ctx->gpios.power)) { in rb070d30_panel_dsi_probe()
173 dev_err(&dsi->dev, "Couldn't get our power GPIO\n"); in rb070d30_panel_dsi_probe()
174 return PTR_ERR(ctx->gpios.power); in rb070d30_panel_dsi_probe()
181 ctx->gpios.updn = devm_gpiod_get(&dsi->dev, "updn", GPIOD_OUT_LOW); in rb070d30_panel_dsi_probe()
182 if (IS_ERR(ctx->gpios.updn)) { in rb070d30_panel_dsi_probe()
183 dev_err(&dsi->dev, "Couldn't get our updn GPIO\n"); in rb070d30_panel_dsi_probe()
184 return PTR_ERR(ctx->gpios.updn); in rb070d30_panel_dsi_probe()
191 ctx->gpios.shlr = devm_gpiod_get(&dsi->dev, "shlr", GPIOD_OUT_LOW); in rb070d30_panel_dsi_probe()
192 if (IS_ERR(ctx->gpios.shlr)) { in rb070d30_panel_dsi_probe()
193 dev_err(&dsi->dev, "Couldn't get our shlr GPIO\n"); in rb070d30_panel_dsi_probe()
194 return PTR_ERR(ctx->gpios.shlr); in rb070d30_panel_dsi_probe()
197 ret = drm_panel_of_backlight(&ctx->panel); in rb070d30_panel_dsi_probe()
201 drm_panel_add(&ctx->panel); in rb070d30_panel_dsi_probe()
203 dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_LPM; in rb070d30_panel_dsi_probe()
204 dsi->format = MIPI_DSI_FMT_RGB888; in rb070d30_panel_dsi_probe()
205 dsi->lanes = 4; in rb070d30_panel_dsi_probe()
207 return mipi_dsi_attach(dsi); in rb070d30_panel_dsi_probe()
210 static int rb070d30_panel_dsi_remove(struct mipi_dsi_device *dsi) in rb070d30_panel_dsi_remove() argument
212 struct rb070d30_panel *ctx = mipi_dsi_get_drvdata(dsi); in rb070d30_panel_dsi_remove()
214 mipi_dsi_detach(dsi); in rb070d30_panel_dsi_remove()
215 drm_panel_remove(&ctx->panel); in rb070d30_panel_dsi_remove()
230 .name = "panel-ronbo-rb070d30",
238 MODULE_DESCRIPTION("Ronbo RB070D30 Panel Driver");