Lines Matching +full:panel +full:- +full:mipi +full:- +full:dbi +full:- +full:spi
1 // SPDX-License-Identifier: GPL-2.0
3 * Magnachip d53e6ea8966 MIPI-DSI panel driver
18 #include <linux/media-bus-format.h>
22 #include <linux/spi/spi.h>
29 /* Panel info, unique to each panel */
35 /** @width_mm: panel width in mm */
37 /** @height_mm: panel height in mm */
39 /** @bus_flags: drm bus flags for panel */
41 /** @panel_init_seq: panel specific init sequence */
43 /** @backlight_register: panel backlight registration or NULL */
50 /** @dbi: the DBI bus abstraction handle */
51 struct mipi_dbi dbi; member
52 /** @panel: the DRM panel instance for this device */
53 struct drm_panel panel; member
58 /** @reg_vdd: VDD supply regulator for panel logic */
60 /** @reg_elvdd: ELVDD supply regulator for panel display */
62 /** @dsi_dev: DSI child device (panel) */
64 /** @bl_dev: pseudo-backlight device for oled panel */
66 /** @panel_info: struct containing panel timing and info */
72 #define MAX_BRIGHTNESS (NUM_GAMMA_LEVELS - 1)
84 static inline struct d53e6ea8966 *to_d53e6ea8966(struct drm_panel *panel) in to_d53e6ea8966() argument
86 return container_of(panel, struct d53e6ea8966, panel); in to_d53e6ea8966()
150 static int ams495qa01_update_gamma(struct mipi_dbi *dbi, int brightness) in ams495qa01_update_gamma() argument
154 mipi_dbi_command_buf(dbi, MCS_SET_GAMMA, ams495qa01_gamma[tmp], in ams495qa01_update_gamma()
156 mipi_dbi_command(dbi, MCS_SET_GAMMA, 0x00); in ams495qa01_update_gamma()
159 mipi_dbi_command(dbi, 0x26, 0x00); in ams495qa01_update_gamma()
161 mipi_dbi_command(dbi, MCS_TEMP_SWIRE, ams495qa01_elvss[tmp]); in ams495qa01_update_gamma()
168 struct mipi_dbi *dbi = &db->dbi; in ams495qa01_panel_init() local
170 mipi_dbi_command(dbi, MCS_PASSWORD_0, 0x5a, 0x5a); in ams495qa01_panel_init()
171 mipi_dbi_command(dbi, MCS_PASSWORD_1, 0x5a, 0x5a); in ams495qa01_panel_init()
174 mipi_dbi_command(dbi, 0xb0, 0x02); in ams495qa01_panel_init()
175 mipi_dbi_command(dbi, 0xf3, 0x3b); in ams495qa01_panel_init()
177 mipi_dbi_command(dbi, MCS_ANALOG_PWR_CTL_0, 0x33, 0x42, 0x00, 0x08); in ams495qa01_panel_init()
178 mipi_dbi_command(dbi, MCS_ANALOG_PWR_CTL_1, 0x00, 0x06, 0x26, 0x35, 0x03); in ams495qa01_panel_init()
181 mipi_dbi_command(dbi, 0xf6, 0x02); in ams495qa01_panel_init()
182 mipi_dbi_command(dbi, 0xc6, 0x0b, 0x00, 0x00, 0x3c, 0x00, 0x22, in ams495qa01_panel_init()
185 mipi_dbi_command(dbi, MCS_GTCON_SET, 0x20); in ams495qa01_panel_init()
186 mipi_dbi_command(dbi, MCS_TEMP_SWIRE, 0x06, 0x06, 0x06, 0x06); in ams495qa01_panel_init()
187 mipi_dbi_command(dbi, MCS_ELVSS_ON, 0x07, 0x00, 0x10); in ams495qa01_panel_init()
188 mipi_dbi_command(dbi, MCS_GATELESS_SIGNAL_SET, 0x7f, 0x7a, in ams495qa01_panel_init()
194 mipi_dbi_command(dbi, 0xb5, 0xff, 0xef, 0x35, 0x42, 0x0d, 0xd7, in ams495qa01_panel_init()
198 mipi_dbi_command(dbi, 0xb4, 0x15); in ams495qa01_panel_init()
199 mipi_dbi_command(dbi, 0xb3, 0x00); in ams495qa01_panel_init()
201 ams495qa01_update_gamma(dbi, MAX_BRIGHTNESS); in ams495qa01_panel_init()
204 static int d53e6ea8966_prepare(struct drm_panel *panel) in d53e6ea8966_prepare() argument
206 struct d53e6ea8966 *db = to_d53e6ea8966(panel); in d53e6ea8966_prepare()
210 ret = regulator_enable(db->reg_vdd); in d53e6ea8966_prepare()
212 dev_err(db->dev, "failed to enable vdd regulator: %d\n", ret); in d53e6ea8966_prepare()
216 if (db->reg_elvdd) { in d53e6ea8966_prepare()
217 ret = regulator_enable(db->reg_elvdd); in d53e6ea8966_prepare()
219 dev_err(db->dev, in d53e6ea8966_prepare()
221 regulator_disable(db->reg_vdd); in d53e6ea8966_prepare()
227 if (db->enable) in d53e6ea8966_prepare()
228 gpiod_set_value_cansleep(db->enable, 1); in d53e6ea8966_prepare()
233 gpiod_set_value_cansleep(db->reset, 1); in d53e6ea8966_prepare()
235 gpiod_set_value_cansleep(db->reset, 0); in d53e6ea8966_prepare()
238 db->panel_info->panel_init_seq(db); in d53e6ea8966_prepare()
243 static int d53e6ea8966_enable(struct drm_panel *panel) in d53e6ea8966_enable() argument
245 struct d53e6ea8966 *db = to_d53e6ea8966(panel); in d53e6ea8966_enable()
246 struct mipi_dbi *dbi = &db->dbi; in d53e6ea8966_enable() local
248 mipi_dbi_command(dbi, MIPI_DCS_EXIT_SLEEP_MODE); in d53e6ea8966_enable()
250 mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_ON); in d53e6ea8966_enable()
256 static int d53e6ea8966_disable(struct drm_panel *panel) in d53e6ea8966_disable() argument
258 struct d53e6ea8966 *db = to_d53e6ea8966(panel); in d53e6ea8966_disable()
259 struct mipi_dbi *dbi = &db->dbi; in d53e6ea8966_disable() local
261 mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_OFF); in d53e6ea8966_disable()
263 mipi_dbi_command(dbi, MIPI_DCS_ENTER_SLEEP_MODE); in d53e6ea8966_disable()
269 static int d53e6ea8966_unprepare(struct drm_panel *panel) in d53e6ea8966_unprepare() argument
271 struct d53e6ea8966 *db = to_d53e6ea8966(panel); in d53e6ea8966_unprepare()
273 if (db->enable) in d53e6ea8966_unprepare()
274 gpiod_set_value_cansleep(db->enable, 0); in d53e6ea8966_unprepare()
276 gpiod_set_value_cansleep(db->reset, 1); in d53e6ea8966_unprepare()
278 if (db->reg_elvdd) in d53e6ea8966_unprepare()
279 regulator_disable(db->reg_elvdd); in d53e6ea8966_unprepare()
281 regulator_disable(db->reg_vdd); in d53e6ea8966_unprepare()
287 static int d53e6ea8966_get_modes(struct drm_panel *panel, in d53e6ea8966_get_modes() argument
290 struct d53e6ea8966 *db = to_d53e6ea8966(panel); in d53e6ea8966_get_modes()
291 const struct d53e6ea8966_panel_info *panel_info = db->panel_info; in d53e6ea8966_get_modes()
296 for (i = 0; i < panel_info->num_modes; i++) { in d53e6ea8966_get_modes()
297 mode = drm_mode_duplicate(connector->dev, in d53e6ea8966_get_modes()
298 &panel_info->display_modes[i]); in d53e6ea8966_get_modes()
300 return -ENOMEM; in d53e6ea8966_get_modes()
306 connector->display_info.bpc = 8; in d53e6ea8966_get_modes()
307 connector->display_info.width_mm = panel_info->width_mm; in d53e6ea8966_get_modes()
308 connector->display_info.height_mm = panel_info->height_mm; in d53e6ea8966_get_modes()
309 connector->display_info.bus_flags = panel_info->bus_flags; in d53e6ea8966_get_modes()
311 drm_display_info_set_bus_formats(&connector->display_info, in d53e6ea8966_get_modes()
328 struct mipi_dbi *dbi = &db->dbi; in ams495qa01_set_brightness() local
331 ams495qa01_update_gamma(dbi, brightness); in ams495qa01_set_brightness()
347 struct device *dev = db->dev; in ams495qa01_backlight_register()
350 db->bl_dev = devm_backlight_device_register(dev, "panel", dev, db, in ams495qa01_backlight_register()
353 if (IS_ERR(db->bl_dev)) { in ams495qa01_backlight_register()
354 ret = PTR_ERR(db->bl_dev); in ams495qa01_backlight_register()
361 static int d53e6ea8966_probe(struct spi_device *spi) in d53e6ea8966_probe() argument
363 struct device *dev = &spi->dev; in d53e6ea8966_probe()
375 return -ENOMEM; in d53e6ea8966_probe()
377 spi_set_drvdata(spi, db); in d53e6ea8966_probe()
379 db->dev = dev; in d53e6ea8966_probe()
381 db->panel_info = of_device_get_match_data(dev); in d53e6ea8966_probe()
382 if (!db->panel_info) in d53e6ea8966_probe()
383 return -EINVAL; in d53e6ea8966_probe()
385 db->reg_vdd = devm_regulator_get(dev, "vdd"); in d53e6ea8966_probe()
386 if (IS_ERR(db->reg_vdd)) in d53e6ea8966_probe()
387 return dev_err_probe(dev, PTR_ERR(db->reg_vdd), in d53e6ea8966_probe()
390 db->reg_elvdd = devm_regulator_get_optional(dev, "elvdd"); in d53e6ea8966_probe()
391 if (IS_ERR(db->reg_elvdd)) in d53e6ea8966_probe()
392 db->reg_elvdd = NULL; in d53e6ea8966_probe()
394 db->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in d53e6ea8966_probe()
395 if (IS_ERR(db->reset)) { in d53e6ea8966_probe()
396 ret = PTR_ERR(db->reset); in d53e6ea8966_probe()
400 db->enable = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); in d53e6ea8966_probe()
401 if (IS_ERR(db->enable)) { in d53e6ea8966_probe()
402 ret = PTR_ERR(db->enable); in d53e6ea8966_probe()
406 ret = mipi_dbi_spi_init(spi, &db->dbi, NULL); in d53e6ea8966_probe()
408 return dev_err_probe(dev, ret, "MIPI DBI init failed\n"); in d53e6ea8966_probe()
416 db->dsi_dev = devm_mipi_dsi_device_register_full(dev, dsi_host, &info); in d53e6ea8966_probe()
417 if (IS_ERR(db->dsi_dev)) { in d53e6ea8966_probe()
419 PTR_ERR(db->dsi_dev)); in d53e6ea8966_probe()
420 return PTR_ERR(db->dsi_dev); in d53e6ea8966_probe()
423 db->dsi_dev->lanes = 2; in d53e6ea8966_probe()
424 db->dsi_dev->format = MIPI_DSI_FMT_RGB888; in d53e6ea8966_probe()
425 db->dsi_dev->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | in d53e6ea8966_probe()
428 drm_panel_init(&db->panel, dev, &d53e6ea8966_panel_funcs, in d53e6ea8966_probe()
431 if (db->panel_info->backlight_register) { in d53e6ea8966_probe()
432 ret = db->panel_info->backlight_register(db); in d53e6ea8966_probe()
435 db->panel.backlight = db->bl_dev; in d53e6ea8966_probe()
438 drm_panel_add(&db->panel); in d53e6ea8966_probe()
440 ret = devm_mipi_dsi_attach(dev, db->dsi_dev); in d53e6ea8966_probe()
443 drm_panel_remove(&db->panel); in d53e6ea8966_probe()
450 static void d53e6ea8966_remove(struct spi_device *spi) in d53e6ea8966_remove() argument
452 struct d53e6ea8966 *db = spi_get_drvdata(spi); in d53e6ea8966_remove()
454 drm_panel_remove(&db->panel); in d53e6ea8966_remove()
506 MODULE_DEVICE_TABLE(spi, d53e6ea8966_ids);
510 .name = "d53e6ea8966-panel",
520 MODULE_DESCRIPTION("Magnachip d53e6ea8966 panel driver");