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>
16 #include <linux/spi/spi.h>
31 struct drm_panel panel; member
32 struct mipi_dbi dbi; member
235 static inline struct nv3052c *to_nv3052c(struct drm_panel *panel) in to_nv3052c() argument
237 return container_of(panel, struct nv3052c, panel); in to_nv3052c()
240 static int nv3052c_prepare(struct drm_panel *panel) in nv3052c_prepare() argument
242 struct nv3052c *priv = to_nv3052c(panel); in nv3052c_prepare()
243 struct mipi_dbi *dbi = &priv->dbi; in nv3052c_prepare() local
247 err = regulator_enable(priv->supply); in nv3052c_prepare()
249 dev_err(priv->dev, "Failed to enable power supply: %d\n", err); in nv3052c_prepare()
254 gpiod_set_value_cansleep(priv->reset_gpio, 1); in nv3052c_prepare()
256 gpiod_set_value_cansleep(priv->reset_gpio, 0); in nv3052c_prepare()
260 err = mipi_dbi_command(dbi, nv3052c_panel_regs[i].cmd, in nv3052c_prepare()
264 dev_err(priv->dev, "Unable to set register: %d\n", err); in nv3052c_prepare()
269 err = mipi_dbi_command(dbi, MIPI_DCS_EXIT_SLEEP_MODE); in nv3052c_prepare()
271 dev_err(priv->dev, "Unable to exit sleep mode: %d\n", err); in nv3052c_prepare()
278 regulator_disable(priv->supply); in nv3052c_prepare()
282 static int nv3052c_unprepare(struct drm_panel *panel) in nv3052c_unprepare() argument
284 struct nv3052c *priv = to_nv3052c(panel); in nv3052c_unprepare()
285 struct mipi_dbi *dbi = &priv->dbi; in nv3052c_unprepare() local
288 err = mipi_dbi_command(dbi, MIPI_DCS_ENTER_SLEEP_MODE); in nv3052c_unprepare()
290 dev_err(priv->dev, "Unable to enter sleep mode: %d\n", err); in nv3052c_unprepare()
292 gpiod_set_value_cansleep(priv->reset_gpio, 1); in nv3052c_unprepare()
293 regulator_disable(priv->supply); in nv3052c_unprepare()
298 static int nv3052c_enable(struct drm_panel *panel) in nv3052c_enable() argument
300 struct nv3052c *priv = to_nv3052c(panel); in nv3052c_enable()
301 struct mipi_dbi *dbi = &priv->dbi; in nv3052c_enable() local
304 err = mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_ON); in nv3052c_enable()
306 dev_err(priv->dev, "Unable to enable display: %d\n", err); in nv3052c_enable()
310 if (panel->backlight) { in nv3052c_enable()
318 static int nv3052c_disable(struct drm_panel *panel) in nv3052c_disable() argument
320 struct nv3052c *priv = to_nv3052c(panel); in nv3052c_disable()
321 struct mipi_dbi *dbi = &priv->dbi; in nv3052c_disable() local
324 err = mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_OFF); in nv3052c_disable()
326 dev_err(priv->dev, "Unable to disable display: %d\n", err); in nv3052c_disable()
333 static int nv3052c_get_modes(struct drm_panel *panel, in nv3052c_get_modes() argument
336 struct nv3052c *priv = to_nv3052c(panel); in nv3052c_get_modes()
337 const struct nv3052c_panel_info *panel_info = priv->panel_info; in nv3052c_get_modes()
341 for (i = 0; i < panel_info->num_modes; i++) { in nv3052c_get_modes()
342 mode = drm_mode_duplicate(connector->dev, in nv3052c_get_modes()
343 &panel_info->display_modes[i]); in nv3052c_get_modes()
345 return -ENOMEM; in nv3052c_get_modes()
349 mode->type = DRM_MODE_TYPE_DRIVER; in nv3052c_get_modes()
350 if (panel_info->num_modes == 1) in nv3052c_get_modes()
351 mode->type |= DRM_MODE_TYPE_PREFERRED; in nv3052c_get_modes()
356 connector->display_info.bpc = 8; in nv3052c_get_modes()
357 connector->display_info.width_mm = panel_info->width_mm; in nv3052c_get_modes()
358 connector->display_info.height_mm = panel_info->height_mm; in nv3052c_get_modes()
360 drm_display_info_set_bus_formats(&connector->display_info, in nv3052c_get_modes()
361 &panel_info->bus_format, 1); in nv3052c_get_modes()
362 connector->display_info.bus_flags = panel_info->bus_flags; in nv3052c_get_modes()
364 return panel_info->num_modes; in nv3052c_get_modes()
375 static int nv3052c_probe(struct spi_device *spi) in nv3052c_probe() argument
377 struct device *dev = &spi->dev; in nv3052c_probe()
383 return -ENOMEM; in nv3052c_probe()
385 priv->dev = dev; in nv3052c_probe()
387 priv->panel_info = of_device_get_match_data(dev); in nv3052c_probe()
388 if (!priv->panel_info) in nv3052c_probe()
389 return -EINVAL; in nv3052c_probe()
391 priv->supply = devm_regulator_get(dev, "power"); in nv3052c_probe()
392 if (IS_ERR(priv->supply)) in nv3052c_probe()
393 return dev_err_probe(dev, PTR_ERR(priv->supply), "Failed to get power supply\n"); in nv3052c_probe()
395 priv->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in nv3052c_probe()
396 if (IS_ERR(priv->reset_gpio)) in nv3052c_probe()
397 return dev_err_probe(dev, PTR_ERR(priv->reset_gpio), "Failed to get reset GPIO\n"); in nv3052c_probe()
399 err = mipi_dbi_spi_init(spi, &priv->dbi, NULL); in nv3052c_probe()
401 return dev_err_probe(dev, err, "MIPI DBI init failed\n"); in nv3052c_probe()
403 priv->dbi.read_commands = NULL; in nv3052c_probe()
405 spi_set_drvdata(spi, priv); in nv3052c_probe()
407 drm_panel_init(&priv->panel, dev, &nv3052c_funcs, in nv3052c_probe()
410 err = drm_panel_of_backlight(&priv->panel); in nv3052c_probe()
414 drm_panel_add(&priv->panel); in nv3052c_probe()
419 static void nv3052c_remove(struct spi_device *spi) in nv3052c_remove() argument
421 struct nv3052c *priv = spi_get_drvdata(spi); in nv3052c_remove()
423 drm_panel_remove(&priv->panel); in nv3052c_remove()
424 drm_panel_disable(&priv->panel); in nv3052c_remove()
425 drm_panel_unprepare(&priv->panel); in nv3052c_remove()