Re: [PATCH v1 2/2] drm/tinydrm: add driver for ST7735R panels

From: Noralf TrÃnnes
Date: Fri Dec 08 2017 - 09:11:17 EST



Den 06.12.2017 19.27, skrev Noralf TrÃnnes:

Den 29.11.2017 04.01, skrev David Lechner:
This adds a new driver for Sitronix ST7735R display panels.

This has been tested using an Adafruit 1.8" TFT.

Signed-off-by: David Lechner <david@xxxxxxxxxxxxxx>
---

<snip>

diff --git a/drivers/gpu/drm/tinydrm/st7735r.c b/drivers/gpu/drm/tinydrm/st7735r.c

<snip>

+static struct drm_driver st7735r_driver = {
+ÂÂÂ .driver_featuresÂÂÂ = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ DRIVER_ATOMIC,
+ÂÂÂ .fopsÂÂÂÂÂÂÂÂÂÂÂ = &st7735r_fops,
+ÂÂÂ TINYDRM_GEM_DRIVER_OPS,
+ÂÂÂ .lastcloseÂÂÂÂÂÂÂ = tinydrm_lastclose,

tinydrm_lastclose() is going away, please use:

ÂÂÂ .lastcloseÂÂÂ ÂÂÂ = drm_fb_helper_lastclose,

Noralf.

+ÂÂÂ .nameÂÂÂÂÂÂÂÂÂÂÂ = "st7735r",
+ÂÂÂ .descÂÂÂÂÂÂÂÂÂÂÂ = "Sitronix ST7735R",
+ÂÂÂ .dateÂÂÂÂÂÂÂÂÂÂÂ = "20171128",
+ÂÂÂ .majorÂÂÂÂÂÂÂÂÂÂÂ = 1,
+ÂÂÂ .minorÂÂÂÂÂÂÂÂÂÂÂ = 0,
+};
+
+static const struct of_device_id st7735r_of_match[] = {
+ÂÂÂ { .compatible = "sitronix,st7735r-jd-t18003-t01" },
+ÂÂÂ {},
+};
+MODULE_DEVICE_TABLE(of, st7735r_of_match);
+
+static const struct spi_device_id st7735r_id[] = {
+ÂÂÂ { "st7735r-jd-t18003-t01", 0 },
+ÂÂÂ { },
+};
+MODULE_DEVICE_TABLE(spi, st7735r_id);
+
+static int st7735r_probe(struct spi_device *spi)
+{
+ÂÂÂ struct device *dev = &spi->dev;
+ÂÂÂ struct mipi_dbi *mipi;
+ÂÂÂ struct gpio_desc *dc;
+ÂÂÂ u32 rotation = 0;
+ÂÂÂ int ret;
+
+ÂÂÂ mipi = devm_kzalloc(dev, sizeof(*mipi), GFP_KERNEL);
+ÂÂÂ if (!mipi)
+ÂÂÂÂÂÂÂ return -ENOMEM;
+
+ÂÂÂ mipi->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+ÂÂÂ if (IS_ERR(mipi->reset)) {
+ÂÂÂÂÂÂÂ DRM_DEV_ERROR(dev, "Failed to get gpio 'reset'\n");
+ÂÂÂÂÂÂÂ return PTR_ERR(mipi->reset);
+ÂÂÂ }
+
+ÂÂÂ dc = devm_gpiod_get(dev, "dc", GPIOD_OUT_LOW);
+ÂÂÂ if (IS_ERR(dc)) {
+ÂÂÂÂÂÂÂ DRM_DEV_ERROR(dev, "Failed to get gpio 'dc'\n");
+ÂÂÂÂÂÂÂ return PTR_ERR(dc);
+ÂÂÂ }
+
+ÂÂÂ mipi->backlight = tinydrm_of_find_backlight(dev);
+ÂÂÂ if (IS_ERR(mipi->backlight))
+ÂÂÂÂÂÂÂ return PTR_ERR(mipi->backlight);
+
+ÂÂÂ device_property_read_u32(dev, "rotation", &rotation);
+
+ÂÂÂ ret = mipi_dbi_spi_init(spi, mipi, dc);
+ÂÂÂ if (ret)
+ÂÂÂÂÂÂÂ return ret;
+
+ÂÂÂ ret = mipi_dbi_init(&spi->dev, mipi, &st7735r_pipe_funcs,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ &st7735r_driver, &st7735r_mode, rotation);
+ÂÂÂ if (ret)
+ÂÂÂÂÂÂÂ return ret;
+
+ÂÂÂ spi_set_drvdata(spi, mipi);
+
+ÂÂÂ return devm_tinydrm_register(&mipi->tinydrm);
+}
+
+static void st7735r_shutdown(struct spi_device *spi)
+{
+ÂÂÂ struct mipi_dbi *mipi = spi_get_drvdata(spi);
+
+ÂÂÂ tinydrm_shutdown(&mipi->tinydrm);
+}
+
+static struct spi_driver st7735r_spi_driver = {
+ÂÂÂ .driver = {
+ÂÂÂÂÂÂÂ .name = "st7735r",
+ÂÂÂÂÂÂÂ .owner = THIS_MODULE,
+ÂÂÂÂÂÂÂ .of_match_table = st7735r_of_match,
+ÂÂÂ },
+ÂÂÂ .id_table = st7735r_id,
+ÂÂÂ .probe = st7735r_probe,
+ÂÂÂ .shutdown = st7735r_shutdown,
+};
+module_spi_driver(st7735r_spi_driver);
+
+MODULE_DESCRIPTION("Sitronix ST7735R DRM driver");
+MODULE_AUTHOR("David Lechner <david@xxxxxxxxxxxxxx>");
+MODULE_LICENSE("GPL");

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel