Skip to contentSkip to conversation

drm/panel: Add a driver for the TPO TPG110

PATCH Superseded Linus Walleij 2 participants 2 messages Jan 10, 2019

Subsystems (4)

v7 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v7 1/1 drm/panel: Add a driver for the TPO TPG110

The TPO (Toppoly) TPG110 is a pretty generic display driver similar in vein to the Ilitek 93xx devices. It is not a panel per se but a driver used with several low-cost noname panels.

This is used on the Nomadik NHK15 combined with a OSD OSD057VA01CT display for WVGA 800x480.

The driver is pretty minimalistic right now but can be extended to handle non-default polarities, gamma correction etc.

The driver is based on the baked-in code in drivers/video/fbdev/amba-clcd-nomadik.c which will be decomissioned once this us upstream.

---
ChangeLog v6->v7:
- Drop the video mode helpers.
- Do not include <drm/drmP.h> but instead the granular APIs.
- Switch dev_info() and dev_err() for DRM_DEV_INFO() and DRM_DEV_ERROR().
- Switch mdelay(1) for usleep_range(1000,2000) so we don't spin unecessarily during boot.
- Use DRM_DEV_DEBUG() for information about deasserted reset.
- Make a proper DRM_DEV_ERROR() for illegal resolution settings.
- Simplify the inlined backlight enable/disable code by using the existing inline helpers.
- Add a few missing stray \n's
ChangeLog v5->v6:
- Collected Sam's ACK.
ChangeLog v4->v5:
- Assign proper bus_flags.
- This is now the only remaining patch.
ChangeLog v3->v4:
- Tag on the SPI_3WIRE_HIZ flag to the SPI slave mode. ChangeLog v2->v3:
- Rewrite as an SPI child device.

---
 MAINTAINERS                              |   7 +
 drivers/gpu/drm/panel/Kconfig            |   9 +
 drivers/gpu/drm/panel/Makefile           |   1 +
 drivers/gpu/drm/panel/panel-tpo-tpg110.c | 504 +++++++++++++++++++++++
 4 files changed, 521 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-tpo-tpg110.c
MAINTAINERS +7 -0
index 32d444476a90..e177473d5417 100644
@@ -4909,6 +4909,13 @@ DRM DRIVER FOR TDFX VIDEO CARDS
 S:	Orphan / Obsolete
 F:	drivers/gpu/drm/tdfx/
 
+DRM DRIVER FOR TPO TPG110 PANELS
+M:	Linus Walleij <[email protected]>
+T:	git git://anongit.freedesktop.org/drm/drm-misc
+S:	Maintained
+F:	drivers/gpu/drm/panel/panel-tpo-tpg110.c
+F:	Documentation/devicetree/bindings/display/panel/tpo,tpg110.txt
+
 DRM DRIVER FOR USB DISPLAYLINK VIDEO ADAPTERS
 M:	Dave Airlie <[email protected]>
 R:	Sean Paul <[email protected]>
drivers/gpu/drm/panel/Kconfig +9 -0
index 3f3537719beb..a71f44191273 100644
@@ -204,6 +204,15 @@ config DRM_PANEL_SITRONIX_ST7789V
 	  Say Y here if you want to enable support for the Sitronix
 	  ST7789V controller for 240x320 LCD panels
 
+config DRM_PANEL_TPO_TPG110
+	tristate "TPO TPG 800x400 panel"
+	depends on OF && SPI && GPIOLIB
+	depends on BACKLIGHT_CLASS_DEVICE
+	help
+	  Say Y here if you want to enable support for TPO TPG110
+	  400CH LTPS TFT LCD Single Chip Digital Driver for up to
+	  800x400 LCD panels.
+
 config DRM_PANEL_TRULY_NT35597_WQXGA
 	tristate "Truly WQXGA"
 	depends on OF
drivers/gpu/drm/panel/Makefile +1 -0
index 4396658a7996..cd14ca39c6e0 100644
@@ -21,4 +21,5 @@ obj-$(CONFIG_DRM_PANEL_SEIKO_43WVF1G) += panel-seiko-43wvf1g.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
 obj-$(CONFIG_DRM_PANEL_SHARP_LS043T1LE01) += panel-sharp-ls043t1le01.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
+obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o
 obj-$(CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA) += panel-truly-nt35597.o
drivers/gpu/drm/panel/panel-tpo-tpg110.c new file +504 -0

504 lines not on this page · raw message

Signature · 6 lines
2.19.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

Den 10.01.2019 20.30, skrev Linus Walleij:

Quoted 40 lines

The TPO (Toppoly) TPG110 is a pretty generic display driver similar in vein to the Ilitek 93xx devices. It is not a panel per se but a driver used with several low-cost noname panels.

This is used on the Nomadik NHK15 combined with a OSD OSD057VA01CT display for WVGA 800x480.

The driver is pretty minimalistic right now but can be extended to handle non-default polarities, gamma correction etc.

The driver is based on the baked-in code in drivers/video/fbdev/amba-clcd-nomadik.c which will be decomissioned once this us upstream.

---
ChangeLog v6->v7:
- Drop the video mode helpers.
- Do not include <drm/drmP.h> but instead the granular APIs.
- Switch dev_info() and dev_err() for DRM_DEV_INFO() and DRM_DEV_ERROR().
- Switch mdelay(1) for usleep_range(1000,2000) so we don't spin unecessarily during boot.
- Use DRM_DEV_DEBUG() for information about deasserted reset.
- Make a proper DRM_DEV_ERROR() for illegal resolution settings.
- Simplify the inlined backlight enable/disable code by using the existing inline helpers.
- Add a few missing stray \n's
ChangeLog v5->v6:
- Collected Sam's ACK.
ChangeLog v4->v5:
- Assign proper bus_flags.
- This is now the only remaining patch.
ChangeLog v3->v4:
- Tag on the SPI_3WIRE_HIZ flag to the SPI slave mode. ChangeLog v2->v3:
- Rewrite as an SPI child device.
---

<snip>

Quoted 1 line
drivers/gpu/drm/panel/panel-tpo-tpg110.c +0 -0

<snip>

drivers/gpu/drm/panel/panel-tpo-tpg110.c line 360

Quoted 12 lines
drivers/gpu/drm/panel/panel-tpo-tpg110.c +12 -0
+static int tpg110_disable(struct drm_panel *panel)
+{
+	struct tpg110 *tpg = to_tpg110(panel);
+	u8 val;
+
+	/* Put chip into standby */
+	val = tpg110_read_reg(tpg, TPG110_CTRL2_PM);
+	val &= ~TPG110_CTRL2_PM;
+	tpg110_write_reg(tpg, TPG110_CTRL2_PM, val);
+
+	if (tpg->backlight)
+		backlight_disable(tpg->backlight);

backlight_disable() and backlight_enable() is NULL tolerant, so the conditional is not necessary.

Quoted 19 lines
drivers/gpu/drm/panel/panel-tpo-tpg110.c +19 -0
+
+	return 0;
+}
+
+static int tpg110_enable(struct drm_panel *panel)
+{
+	struct tpg110 *tpg = to_tpg110(panel);
+	u8 val;
+
+	if (tpg->backlight)
+		backlight_enable(tpg->backlight);
+
+	/* Take chip out of standby */
+	val = tpg110_read_reg(tpg, TPG110_CTRL2_PM);
+	val |= TPG110_CTRL2_PM;
+	tpg110_write_reg(tpg, TPG110_CTRL2_PM, val);
+
+	return 0;
+}

<snip>

Quoted 20 lines
drivers/gpu/drm/panel/panel-tpo-tpg110.c +20 -0
+static int tpg110_probe(struct spi_device *spi)
+{
+	struct device *dev = &spi->dev;
+	struct device_node *np = dev->of_node;
+	struct device_node *backlight;
+	struct tpg110 *tpg;
+	int ret;
+
+	tpg = devm_kzalloc(dev, sizeof(*tpg), GFP_KERNEL);
+	if (!tpg)
+		return -ENOMEM;
+	tpg->dev = dev;
+
+	/* We get the physical display dimensions from the DT */
+	ret = of_property_read_u32(np, "width-mm", &tpg->width);
+	if (ret)
+		DRM_DEV_ERROR(dev, "no panel width specified\n");
+	ret = of_property_read_u32(np, "height-mm", &tpg->height);
+	if (ret)
+		DRM_DEV_ERROR(dev, "no panel height specified\n");

drivers/gpu/drm/panel/panel-tpo-tpg110.c line 448

Quoted 10 lines
drivers/gpu/drm/panel/panel-tpo-tpg110.c +10 -0
+
+	/* Look for some optional backlight */
+	backlight = of_parse_phandle(np, "backlight", 0);
+	if (backlight) {
+		tpg->backlight = of_find_backlight_by_node(backlight);
+		of_node_put(backlight);
+
+		if (!tpg->backlight)
+			return -EPROBE_DEFER;
+	}

You have forgotten to put the backlight device on device removal. Here's one way to fix it:

	tpg->backlight = devm_of_find_backlight(dev);
	if (IS_ERR(tpg->backlight))
		return PTR_ERR(tpg->backlight);

tpg->backlight will be NULL if there's no backlight node and -EPROBE_DEFER if the node is there but the device is not yet available.

Noralf.

Quoted 47 lines
drivers/gpu/drm/panel/panel-tpo-tpg110.c +46 -0
+
+	/* This asserts the GRESTB signal, putting the display into reset */
+	tpg->grestb = devm_gpiod_get(dev, "grestb", GPIOD_OUT_HIGH);
+	if (IS_ERR(tpg->grestb)) {
+		DRM_DEV_ERROR(dev, "no GRESTB GPIO\n");
+		return -ENODEV;
+	}
+
+	spi->bits_per_word = 8;
+	spi->mode |= SPI_3WIRE_HIZ;
+	ret = spi_setup(spi);
+	if (ret < 0) {
+		DRM_DEV_ERROR(dev, "spi setup failed.\n");
+		return ret;
+	}
+	tpg->spi = spi;
+
+	ret = tpg110_startup(tpg);
+	if (ret)
+		return ret;
+
+	drm_panel_init(&tpg->panel);
+	tpg->panel.dev = dev;
+	tpg->panel.funcs = &tpg110_drm_funcs;
+	spi_set_drvdata(spi, tpg);
+
+	return drm_panel_add(&tpg->panel);
+}
+
+static int tpg110_remove(struct spi_device *spi)
+{
+	struct tpg110 *tpg = spi_get_drvdata(spi);
+
+	drm_panel_remove(&tpg->panel);
+	return 0;
+}
+
+static const struct of_device_id tpg110_match[] = {
+	{ .compatible = "tpo,tpg110", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, tpg110_match);
+
+static struct spi_driver tpg110_driver = {
+	.probe		= tpg110_probe,
+	.remove		= tpg110_remove,

drivers/gpu/drm/panel/panel-tpo-tpg110.c line 504

Quoted 10 lines
drivers/gpu/drm/panel/panel-tpo-tpg110.c +10 -0
+	.driver		= {
+		.name	= "tpo-tpg110-panel",
+		.of_match_table = tpg110_match,
+	},
+};
+module_spi_driver(tpg110_driver);
+
+MODULE_AUTHOR("Linus Walleij <[email protected]>");
+MODULE_DESCRIPTION("TPO TPG110 panel driver");
+MODULE_LICENSE("GPL v2");

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel