Lines Matching +full:panel +full:- +full:mipi +full:- +full:dbi +full:- +full:spi
1 // SPDX-License-Identifier: GPL-2.0-only
5 * This panel can be configured to support:
6 * - 16-bit parallel RGB interface
7 * - 18-bit parallel RGB interface
8 * - 4-line serial spi interface
12 * For dbi+dpi part:
13 * Derived from drivers/drm/gpu/panel/panel-ilitek-ili9322.c
14 * the reuse of DBI abstraction part referred from Linus's patch
15 * "drm/panel: s6e63m0: Switch to DBI abstraction for SPI"
17 * For only-dbi part, copy from David's code (drm/tiny/ili9341.c)
29 #include <linux/spi/spi.h>
117 /* struct ili9341_config - the system specific ILI9341 configuration */
181 struct drm_panel panel; member
184 struct mipi_dbi *dbi; member
190 * The Stm32f429-disco board has a panel ili9341 connected to ltdc controller
220 * 0xa2 Normally white, G1 -> G320, S720 -> S1,
226 /* 0x10 AVDD=vci*2, VGH=vci*7, VGL=-vci*4 */
228 /* 0x45 VCOMH 4.425v, 0x15 VCOML -1.975*/
230 /* 0x90 offset voltage, VMH-48, VML-48 */
249 * Gate outputs in non-display area: Interval scan
250 * Determine source/VCOM output in a non-display area in the partial
257 * Gate Output Scan Direction: G1 -> G320
258 * Source Output Scan Direction: S720 -> S1
275 * (EC-SC+1)*(EP-SP+1), the column and page number will be
280 * 16- bit RGB interface (1 transfer/pixel)
296 static inline struct ili9341 *panel_to_ili9341(struct drm_panel *panel) in panel_to_ili9341() argument
298 return container_of(panel, struct ili9341, panel); in panel_to_ili9341()
303 struct device *dev = (&ili->panel)->dev; in ili9341_dpi_init()
304 struct mipi_dbi *dbi = ili->dbi; in ili9341_dpi_init() local
305 struct ili9341_config *cfg = (struct ili9341_config *)ili->conf; in ili9341_dpi_init()
308 mipi_dbi_command_stackbuf(dbi, 0xca, cfg->ca, ILI9341_CA_LEN); in ili9341_dpi_init()
309 mipi_dbi_command_stackbuf(dbi, ILI9341_POWERB, cfg->power_b, in ili9341_dpi_init()
311 mipi_dbi_command_stackbuf(dbi, ILI9341_POWER_SEQ, cfg->power_seq, in ili9341_dpi_init()
313 mipi_dbi_command_stackbuf(dbi, ILI9341_DTCA, cfg->dtca, in ili9341_dpi_init()
315 mipi_dbi_command_stackbuf(dbi, ILI9341_POWERA, cfg->power_a, in ili9341_dpi_init()
317 mipi_dbi_command(ili->dbi, ILI9341_PRC, cfg->prc); in ili9341_dpi_init()
318 mipi_dbi_command_stackbuf(dbi, ILI9341_DTCB, cfg->dtcb, in ili9341_dpi_init()
320 mipi_dbi_command_stackbuf(dbi, ILI9341_FRC, cfg->frc, ILI9341_FRC_LEN); in ili9341_dpi_init()
321 mipi_dbi_command_stackbuf(dbi, ILI9341_DFC, cfg->dfc_1, in ili9341_dpi_init()
323 mipi_dbi_command(dbi, ILI9341_POWER1, cfg->power_1); in ili9341_dpi_init()
324 mipi_dbi_command(dbi, ILI9341_POWER2, cfg->power_2); in ili9341_dpi_init()
327 mipi_dbi_command_stackbuf(dbi, ILI9341_VCOM1, cfg->vcom_1, in ili9341_dpi_init()
329 mipi_dbi_command(dbi, ILI9341_VCOM2, cfg->vcom_2); in ili9341_dpi_init()
330 mipi_dbi_command(dbi, MIPI_DCS_SET_ADDRESS_MODE, cfg->address_mode); in ili9341_dpi_init()
333 mipi_dbi_command(dbi, ILI9341_3GAMMA_EN, cfg->g3amma_en); in ili9341_dpi_init()
334 mipi_dbi_command(dbi, ILI9341_RGB_INTERFACE, cfg->rgb_interface); in ili9341_dpi_init()
335 mipi_dbi_command_stackbuf(dbi, ILI9341_DFC, cfg->dfc_2, in ili9341_dpi_init()
339 mipi_dbi_command_stackbuf(dbi, MIPI_DCS_SET_COLUMN_ADDRESS, in ili9341_dpi_init()
340 cfg->column_addr, ILI9341_COLUMN_ADDR_LEN); in ili9341_dpi_init()
343 mipi_dbi_command_stackbuf(dbi, MIPI_DCS_SET_PAGE_ADDRESS, in ili9341_dpi_init()
344 cfg->page_addr, ILI9341_PAGE_ADDR_LEN); in ili9341_dpi_init()
345 mipi_dbi_command_stackbuf(dbi, ILI9341_INTERFACE, cfg->interface, in ili9341_dpi_init()
349 mipi_dbi_command(dbi, MIPI_DCS_SET_PIXEL_FORMAT, cfg->pixel_format); in ili9341_dpi_init()
350 mipi_dbi_command(dbi, MIPI_DCS_WRITE_MEMORY_START); in ili9341_dpi_init()
352 mipi_dbi_command(dbi, MIPI_DCS_SET_GAMMA_CURVE, cfg->gamma_curve); in ili9341_dpi_init()
353 mipi_dbi_command_stackbuf(dbi, ILI9341_PGAMMA, cfg->pgamma, in ili9341_dpi_init()
355 mipi_dbi_command_stackbuf(dbi, ILI9341_NGAMMA, cfg->ngamma, in ili9341_dpi_init()
357 mipi_dbi_command(dbi, MIPI_DCS_EXIT_SLEEP_MODE); in ili9341_dpi_init()
359 mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_ON); in ili9341_dpi_init()
360 mipi_dbi_command(dbi, MIPI_DCS_WRITE_MEMORY_START); in ili9341_dpi_init()
367 struct device *dev = (&ili->panel)->dev; in ili9341_dpi_power_on()
371 gpiod_set_value(ili->reset_gpio, 1); in ili9341_dpi_power_on()
374 ret = regulator_bulk_enable(ARRAY_SIZE(ili->supplies), in ili9341_dpi_power_on()
375 ili->supplies); in ili9341_dpi_power_on()
382 /* De-assert RESET */ in ili9341_dpi_power_on()
383 gpiod_set_value(ili->reset_gpio, 0); in ili9341_dpi_power_on()
392 gpiod_set_value(ili->reset_gpio, 1); in ili9341_dpi_power_off()
395 return regulator_bulk_disable(ARRAY_SIZE(ili->supplies), in ili9341_dpi_power_off()
396 ili->supplies); in ili9341_dpi_power_off()
399 static int ili9341_dpi_disable(struct drm_panel *panel) in ili9341_dpi_disable() argument
401 struct ili9341 *ili = panel_to_ili9341(panel); in ili9341_dpi_disable()
403 mipi_dbi_command(ili->dbi, MIPI_DCS_SET_DISPLAY_OFF); in ili9341_dpi_disable()
407 static int ili9341_dpi_unprepare(struct drm_panel *panel) in ili9341_dpi_unprepare() argument
409 struct ili9341 *ili = panel_to_ili9341(panel); in ili9341_dpi_unprepare()
414 static int ili9341_dpi_prepare(struct drm_panel *panel) in ili9341_dpi_prepare() argument
416 struct ili9341 *ili = panel_to_ili9341(panel); in ili9341_dpi_prepare()
428 static int ili9341_dpi_enable(struct drm_panel *panel) in ili9341_dpi_enable() argument
430 struct ili9341 *ili = panel_to_ili9341(panel); in ili9341_dpi_enable()
432 mipi_dbi_command(ili->dbi, MIPI_DCS_SET_DISPLAY_ON); in ili9341_dpi_enable()
436 static int ili9341_dpi_get_modes(struct drm_panel *panel, in ili9341_dpi_get_modes() argument
439 struct ili9341 *ili = panel_to_ili9341(panel); in ili9341_dpi_get_modes()
440 struct drm_device *drm = connector->dev; in ili9341_dpi_get_modes()
444 info = &connector->display_info; in ili9341_dpi_get_modes()
445 info->width_mm = ili->conf->mode.width_mm; in ili9341_dpi_get_modes()
446 info->height_mm = ili->conf->mode.height_mm; in ili9341_dpi_get_modes()
448 if (ili->conf->rgb_interface & ILI9341_RGB_DPL) in ili9341_dpi_get_modes()
449 info->bus_flags |= DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE; in ili9341_dpi_get_modes()
451 info->bus_flags |= DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE; in ili9341_dpi_get_modes()
453 if (ili->conf->rgb_interface & ILI9341_RGB_EPL) in ili9341_dpi_get_modes()
454 info->bus_flags |= DRM_BUS_FLAG_DE_LOW; in ili9341_dpi_get_modes()
456 info->bus_flags |= DRM_BUS_FLAG_DE_HIGH; in ili9341_dpi_get_modes()
458 mode = drm_mode_duplicate(drm, &ili->conf->mode); in ili9341_dpi_get_modes()
461 return -EINVAL; in ili9341_dpi_get_modes()
466 if (ili->conf->rgb_interface & ILI9341_RGB_HSPL) in ili9341_dpi_get_modes()
467 mode->flags |= DRM_MODE_FLAG_PHSYNC; in ili9341_dpi_get_modes()
469 mode->flags |= DRM_MODE_FLAG_NHSYNC; in ili9341_dpi_get_modes()
471 if (ili->conf->rgb_interface & ILI9341_RGB_VSPL) in ili9341_dpi_get_modes()
472 mode->flags |= DRM_MODE_FLAG_PVSYNC; in ili9341_dpi_get_modes()
474 mode->flags |= DRM_MODE_FLAG_NVSYNC; in ili9341_dpi_get_modes()
493 struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev); in ili9341_dbi_enable()
494 struct mipi_dbi *dbi = &dbidev->dbi; in ili9341_dbi_enable() local
498 if (!drm_dev_enter(pipe->crtc.dev, &idx)) in ili9341_dbi_enable()
507 mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_OFF); in ili9341_dbi_enable()
509 mipi_dbi_command(dbi, ILI9341_POWERB, 0x00, 0xc1, 0x30); in ili9341_dbi_enable()
510 mipi_dbi_command(dbi, ILI9341_POWER_SEQ, 0x64, 0x03, 0x12, 0x81); in ili9341_dbi_enable()
511 mipi_dbi_command(dbi, ILI9341_DTCA, 0x85, 0x00, 0x78); in ili9341_dbi_enable()
512 mipi_dbi_command(dbi, ILI9341_POWERA, 0x39, 0x2c, 0x00, 0x34, 0x02); in ili9341_dbi_enable()
513 mipi_dbi_command(dbi, ILI9341_PRC, ILI9341_DBI_PRC_NORMAL); in ili9341_dbi_enable()
514 mipi_dbi_command(dbi, ILI9341_DTCB, 0x00, 0x00); in ili9341_dbi_enable()
517 mipi_dbi_command(dbi, ILI9341_POWER1, ILI9341_DBI_VCOMH_4P6V); in ili9341_dbi_enable()
518 mipi_dbi_command(dbi, ILI9341_POWER2, ILI9341_DBI_PWR_2_DEFAULT); in ili9341_dbi_enable()
520 mipi_dbi_command(dbi, ILI9341_VCOM1, ILI9341_DBI_VCOM_1_VMH_4P25V, in ili9341_dbi_enable()
522 mipi_dbi_command(dbi, ILI9341_VCOM2, ILI9341_DBI_VCOM_2_DEC_58); in ili9341_dbi_enable()
525 mipi_dbi_command(dbi, MIPI_DCS_SET_PIXEL_FORMAT, in ili9341_dbi_enable()
529 mipi_dbi_command(dbi, ILI9341_FRC, ILI9341_DBI_FRC_DIVA & 0x03, in ili9341_dbi_enable()
533 mipi_dbi_command(dbi, ILI9341_3GAMMA_EN, 0x00); in ili9341_dbi_enable()
534 mipi_dbi_command(dbi, MIPI_DCS_SET_GAMMA_CURVE, ILI9341_GAMMA_CURVE_1); in ili9341_dbi_enable()
535 mipi_dbi_command(dbi, ILI9341_PGAMMA, in ili9341_dbi_enable()
538 mipi_dbi_command(dbi, ILI9341_NGAMMA, in ili9341_dbi_enable()
543 mipi_dbi_command(dbi, ILI9341_ETMOD, ILI9341_DBI_EMS_GAS | in ili9341_dbi_enable()
548 mipi_dbi_command(dbi, ILI9341_DFC, 0x08, 0x82, 0x27, 0x00); in ili9341_dbi_enable()
549 mipi_dbi_command(dbi, MIPI_DCS_EXIT_SLEEP_MODE); in ili9341_dbi_enable()
552 mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_ON); in ili9341_dbi_enable()
556 switch (dbidev->rotation) { in ili9341_dbi_enable()
573 mipi_dbi_command(dbi, MIPI_DCS_SET_ADDRESS_MODE, addr_mode); in ili9341_dbi_enable()
575 drm_info(&dbidev->drm, "Initialized display serial interface\n"); in ili9341_dbi_enable()
602 static int ili9341_dbi_probe(struct spi_device *spi, struct gpio_desc *dc, in ili9341_dbi_probe() argument
605 struct device *dev = &spi->dev; in ili9341_dbi_probe()
607 struct mipi_dbi *dbi; in ili9341_dbi_probe() local
624 dbi = &dbidev->dbi; in ili9341_dbi_probe()
625 drm = &dbidev->drm; in ili9341_dbi_probe()
626 dbi->reset = reset; in ili9341_dbi_probe()
627 dbidev->regulator = vcc; in ili9341_dbi_probe()
631 dbidev->backlight = devm_of_find_backlight(dev); in ili9341_dbi_probe()
632 if (IS_ERR(dbidev->backlight)) in ili9341_dbi_probe()
633 return PTR_ERR(dbidev->backlight); in ili9341_dbi_probe()
637 ret = mipi_dbi_spi_init(spi, dbi, dc); in ili9341_dbi_probe()
652 spi_set_drvdata(spi, drm); in ili9341_dbi_probe()
659 static int ili9341_dpi_probe(struct spi_device *spi, struct gpio_desc *dc, in ili9341_dpi_probe() argument
662 struct device *dev = &spi->dev; in ili9341_dpi_probe()
668 return -ENOMEM; in ili9341_dpi_probe()
670 ili->dbi = devm_kzalloc(dev, sizeof(struct mipi_dbi), in ili9341_dpi_probe()
672 if (!ili->dbi) in ili9341_dpi_probe()
673 return -ENOMEM; in ili9341_dpi_probe()
675 ili->supplies[0].supply = "vci"; in ili9341_dpi_probe()
676 ili->supplies[1].supply = "vddi"; in ili9341_dpi_probe()
677 ili->supplies[2].supply = "vddi-led"; in ili9341_dpi_probe()
678 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ili->supplies), in ili9341_dpi_probe()
679 ili->supplies); in ili9341_dpi_probe()
685 ret = mipi_dbi_spi_init(spi, ili->dbi, dc); in ili9341_dpi_probe()
689 spi_set_drvdata(spi, ili); in ili9341_dpi_probe()
690 ili->reset_gpio = reset; in ili9341_dpi_probe()
695 ili->conf = device_get_match_data(dev); in ili9341_dpi_probe()
696 if (!ili->conf) { in ili9341_dpi_probe()
698 return -ENODEV; in ili9341_dpi_probe()
701 ili->max_spi_speed = ili->conf->max_spi_speed; in ili9341_dpi_probe()
702 drm_panel_init(&ili->panel, dev, &ili9341_dpi_funcs, in ili9341_dpi_probe()
704 drm_panel_add(&ili->panel); in ili9341_dpi_probe()
709 static int ili9341_probe(struct spi_device *spi) in ili9341_probe() argument
711 struct device *dev = &spi->dev; in ili9341_probe()
714 const struct spi_device_id *id = spi_get_device_id(spi); in ili9341_probe()
724 if (!strcmp(id->name, "sf-tc240t-9370-t")) in ili9341_probe()
725 return ili9341_dpi_probe(spi, dc, reset); in ili9341_probe()
727 if (!strcmp(id->name, "yx240qv29")) in ili9341_probe()
728 return ili9341_dbi_probe(spi, dc, reset); in ili9341_probe()
730 return -ENODEV; in ili9341_probe()
733 static void ili9341_remove(struct spi_device *spi) in ili9341_remove() argument
735 const struct spi_device_id *id = spi_get_device_id(spi); in ili9341_remove()
736 struct ili9341 *ili = spi_get_drvdata(spi); in ili9341_remove()
737 struct drm_device *drm = spi_get_drvdata(spi); in ili9341_remove()
739 if (!strcmp(id->name, "sf-tc240t-9370-t")) { in ili9341_remove()
741 drm_panel_remove(&ili->panel); in ili9341_remove()
742 } else if (!strcmp(id->name, "yx240qv29")) { in ili9341_remove()
748 static void ili9341_shutdown(struct spi_device *spi) in ili9341_shutdown() argument
750 const struct spi_device_id *id = spi_get_device_id(spi); in ili9341_shutdown()
752 if (!strcmp(id->name, "yx240qv29")) in ili9341_shutdown()
753 drm_atomic_helper_shutdown(spi_get_drvdata(spi)); in ili9341_shutdown()
758 .compatible = "st,sf-tc240t-9370-t",
763 * for original mipi dbi compitable
774 { "sf-tc240t-9370-t", 0 },
777 MODULE_DEVICE_TABLE(spi, ili9341_id);
785 .name = "panel-ilitek-ili9341",
792 MODULE_DESCRIPTION("ILI9341 LCD panel driver");