Lines Matching +full:panel +full:- +full:mipi +full:- +full:dbi +full:- +full:spi
1 // SPDX-License-Identifier: GPL-2.0
3 * NewVision NV3052C IPS LCD panel driver
12 #include <linux/media-bus-format.h>
17 #include <linux/spi/spi.h>
39 struct drm_panel panel; member
40 struct mipi_dbi dbi; member
257 { 0x23, 0x20 }, // RGB interface control: DE MODE PCLK-N
632 static inline struct nv3052c *to_nv3052c(struct drm_panel *panel) in to_nv3052c() argument
634 return container_of(panel, struct nv3052c, panel); in to_nv3052c()
637 static int nv3052c_prepare(struct drm_panel *panel) in nv3052c_prepare() argument
639 struct nv3052c *priv = to_nv3052c(panel); in nv3052c_prepare()
640 const struct nv3052c_reg *panel_regs = priv->panel_info->panel_regs; in nv3052c_prepare()
641 unsigned int panel_regs_len = priv->panel_info->panel_regs_len; in nv3052c_prepare()
642 struct mipi_dbi *dbi = &priv->dbi; in nv3052c_prepare() local
646 err = regulator_enable(priv->supply); in nv3052c_prepare()
648 dev_err(priv->dev, "Failed to enable power supply: %d\n", err); in nv3052c_prepare()
653 gpiod_set_value_cansleep(priv->reset_gpio, 1); in nv3052c_prepare()
655 gpiod_set_value_cansleep(priv->reset_gpio, 0); in nv3052c_prepare()
659 err = mipi_dbi_command(dbi, panel_regs[i].cmd, in nv3052c_prepare()
663 dev_err(priv->dev, "Unable to set register: %d\n", err); in nv3052c_prepare()
668 err = mipi_dbi_command(dbi, MIPI_DCS_EXIT_SLEEP_MODE); in nv3052c_prepare()
670 dev_err(priv->dev, "Unable to exit sleep mode: %d\n", err); in nv3052c_prepare()
677 regulator_disable(priv->supply); in nv3052c_prepare()
681 static int nv3052c_unprepare(struct drm_panel *panel) in nv3052c_unprepare() argument
683 struct nv3052c *priv = to_nv3052c(panel); in nv3052c_unprepare()
684 struct mipi_dbi *dbi = &priv->dbi; in nv3052c_unprepare() local
687 err = mipi_dbi_command(dbi, MIPI_DCS_ENTER_SLEEP_MODE); in nv3052c_unprepare()
689 dev_err(priv->dev, "Unable to enter sleep mode: %d\n", err); in nv3052c_unprepare()
691 gpiod_set_value_cansleep(priv->reset_gpio, 1); in nv3052c_unprepare()
692 regulator_disable(priv->supply); in nv3052c_unprepare()
697 static int nv3052c_enable(struct drm_panel *panel) in nv3052c_enable() argument
699 struct nv3052c *priv = to_nv3052c(panel); in nv3052c_enable()
700 struct mipi_dbi *dbi = &priv->dbi; in nv3052c_enable() local
703 err = mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_ON); in nv3052c_enable()
705 dev_err(priv->dev, "Unable to enable display: %d\n", err); in nv3052c_enable()
709 if (panel->backlight) { in nv3052c_enable()
717 static int nv3052c_disable(struct drm_panel *panel) in nv3052c_disable() argument
719 struct nv3052c *priv = to_nv3052c(panel); in nv3052c_disable()
720 struct mipi_dbi *dbi = &priv->dbi; in nv3052c_disable() local
723 err = mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_OFF); in nv3052c_disable()
725 dev_err(priv->dev, "Unable to disable display: %d\n", err); in nv3052c_disable()
732 static int nv3052c_get_modes(struct drm_panel *panel, in nv3052c_get_modes() argument
735 struct nv3052c *priv = to_nv3052c(panel); in nv3052c_get_modes()
736 const struct nv3052c_panel_info *panel_info = priv->panel_info; in nv3052c_get_modes()
740 for (i = 0; i < panel_info->num_modes; i++) { in nv3052c_get_modes()
741 mode = drm_mode_duplicate(connector->dev, in nv3052c_get_modes()
742 &panel_info->display_modes[i]); in nv3052c_get_modes()
744 return -ENOMEM; in nv3052c_get_modes()
748 mode->type = DRM_MODE_TYPE_DRIVER; in nv3052c_get_modes()
749 if (panel_info->num_modes == 1) in nv3052c_get_modes()
750 mode->type |= DRM_MODE_TYPE_PREFERRED; in nv3052c_get_modes()
755 connector->display_info.bpc = 8; in nv3052c_get_modes()
756 connector->display_info.width_mm = panel_info->width_mm; in nv3052c_get_modes()
757 connector->display_info.height_mm = panel_info->height_mm; in nv3052c_get_modes()
759 drm_display_info_set_bus_formats(&connector->display_info, in nv3052c_get_modes()
760 &panel_info->bus_format, 1); in nv3052c_get_modes()
761 connector->display_info.bus_flags = panel_info->bus_flags; in nv3052c_get_modes()
763 return panel_info->num_modes; in nv3052c_get_modes()
774 static int nv3052c_probe(struct spi_device *spi) in nv3052c_probe() argument
776 struct device *dev = &spi->dev; in nv3052c_probe()
782 return -ENOMEM; in nv3052c_probe()
784 priv->dev = dev; in nv3052c_probe()
786 priv->panel_info = of_device_get_match_data(dev); in nv3052c_probe()
787 if (!priv->panel_info) in nv3052c_probe()
788 return -EINVAL; in nv3052c_probe()
790 priv->supply = devm_regulator_get(dev, "power"); in nv3052c_probe()
791 if (IS_ERR(priv->supply)) in nv3052c_probe()
792 return dev_err_probe(dev, PTR_ERR(priv->supply), "Failed to get power supply\n"); in nv3052c_probe()
794 priv->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in nv3052c_probe()
795 if (IS_ERR(priv->reset_gpio)) in nv3052c_probe()
796 return dev_err_probe(dev, PTR_ERR(priv->reset_gpio), "Failed to get reset GPIO\n"); in nv3052c_probe()
798 err = mipi_dbi_spi_init(spi, &priv->dbi, NULL); in nv3052c_probe()
800 return dev_err_probe(dev, err, "MIPI DBI init failed\n"); in nv3052c_probe()
802 priv->dbi.read_commands = NULL; in nv3052c_probe()
804 spi_set_drvdata(spi, priv); in nv3052c_probe()
806 drm_panel_init(&priv->panel, dev, &nv3052c_funcs, in nv3052c_probe()
809 err = drm_panel_of_backlight(&priv->panel); in nv3052c_probe()
813 drm_panel_add(&priv->panel); in nv3052c_probe()
818 static void nv3052c_remove(struct spi_device *spi) in nv3052c_remove() argument
820 struct nv3052c *priv = spi_get_drvdata(spi); in nv3052c_remove()
822 drm_panel_remove(&priv->panel); in nv3052c_remove()
823 drm_panel_disable(&priv->panel); in nv3052c_remove()
824 drm_panel_unprepare(&priv->panel); in nv3052c_remove()
920 { "wl-355608-a8", },
923 MODULE_DEVICE_TABLE(spi, nv3052c_ids);
928 { .compatible = "anbernic,rg35xx-plus-panel", .data = &wl_355608_a8_panel_info },
947 MODULE_DESCRIPTION("NewVision NV3052C IPS LCD panel driver");