diff options
Diffstat (limited to 'drivers/gpu/drm/panel')
| -rw-r--r-- | drivers/gpu/drm/panel/Kconfig | 44 | ||||
| -rw-r--r-- | drivers/gpu/drm/panel/Makefile | 5 | ||||
| -rw-r--r-- | drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c | 854 | ||||
| -rw-r--r-- | drivers/gpu/drm/panel/panel-elida-kd35t133.c | 352 | ||||
| -rw-r--r-- | drivers/gpu/drm/panel/panel-feixin-k101-im2ba02.c | 526 | ||||
| -rw-r--r-- | drivers/gpu/drm/panel/panel-ilitek-ili9322.c | 14 | ||||
| -rw-r--r-- | drivers/gpu/drm/panel/panel-lg-lg4573.c | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/panel/panel-novatek-nt35510.c | 1098 | ||||
| -rw-r--r-- | drivers/gpu/drm/panel/panel-samsung-ld9040.c | 6 | ||||
| -rw-r--r-- | drivers/gpu/drm/panel/panel-samsung-s6e88a0-ams452ef01.c | 293 | ||||
| -rw-r--r-- | drivers/gpu/drm/panel/panel-simple.c | 332 | ||||
| -rw-r--r-- | drivers/gpu/drm/panel/panel-sony-acx424akp.c | 4 | ||||
| -rw-r--r-- | drivers/gpu/drm/panel/panel-tpo-td028ttec1.c | 17 | 
13 files changed, 3494 insertions, 53 deletions
| diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig index ae44ac2ec106..a1723c1b5fbf 100644 --- a/drivers/gpu/drm/panel/Kconfig +++ b/drivers/gpu/drm/panel/Kconfig @@ -29,6 +29,15 @@ config DRM_PANEL_BOE_HIMAX8279D  	  24 bit RGB per pixel. It provides a MIPI DSI interface to  	  the host and has a built-in LED backlight. +config DRM_PANEL_BOE_TV101WUM_NL6 +	tristate "BOE TV101WUM and AUO KD101N80 45NA 1200x1920 panel" +	depends on OF +	depends on DRM_MIPI_DSI +	depends on BACKLIGHT_CLASS_DEVICE +	help +	  Say Y here if you want to support for BOE TV101WUM and AUO KD101N80 +	  45NA WUXGA PANEL DSI Video Mode panel +  config DRM_PANEL_LVDS  	tristate "Generic LVDS panel driver"  	depends on OF @@ -50,6 +59,25 @@ config DRM_PANEL_SIMPLE  	  that it can be automatically turned off when the panel goes into a  	  low power state. +config DRM_PANEL_ELIDA_KD35T133 +	tristate "Elida KD35T133 panel driver" +	depends on OF +	depends on DRM_MIPI_DSI +	depends on BACKLIGHT_CLASS_DEVICE +	help +	  Say Y here if you want to enable support for the Elida +	  KD35T133 controller for 320x480 LCD panels with MIPI-DSI +	  system interfaces. + +config DRM_PANEL_FEIXIN_K101_IM2BA02 +	tristate "Feixin K101 IM2BA02 panel" +	depends on OF +	depends on DRM_MIPI_DSI +	depends on BACKLIGHT_CLASS_DEVICE +	help +	  Say Y here if you want to enable support for the Feixin K101 IM2BA02 +	  4-lane 800x1280 MIPI DSI panel. +  config DRM_PANEL_FEIYANG_FY07024DI26A30D  	tristate "Feiyang FY07024DI26A30-D MIPI-DSI LCD panel"  	depends on OF @@ -149,6 +177,16 @@ config DRM_PANEL_NEC_NL8048HL11  	  panel (found on the Zoom2/3/3630 SDP boards). To compile this driver  	  as a module, choose M here. +config DRM_PANEL_NOVATEK_NT35510 +	tristate "Novatek NT35510 RGB panel driver" +	depends on OF +	depends on DRM_MIPI_DSI +	depends on BACKLIGHT_CLASS_DEVICE +	help +	  Say Y here if you want to enable support for the panels built +	  around the Novatek NT35510 display controller, such as some +	  Hydis panels. +  config DRM_PANEL_NOVATEK_NT39016  	tristate "Novatek NT39016 RGB/SPI panel"  	depends on OF && SPI @@ -275,6 +313,12 @@ config DRM_PANEL_SAMSUNG_S6E63M0  	  Say Y here if you want to enable support for Samsung S6E63M0  	  AMOLED LCD panel. +config DRM_PANEL_SAMSUNG_S6E88A0_AMS452EF01 +	tristate "Samsung AMS452EF01 panel with S6E88A0 DSI video mode controller" +	depends on OF +	select DRM_MIPI_DSI +	select VIDEOMODE_HELPERS +  config DRM_PANEL_SAMSUNG_S6E8AA0  	tristate "Samsung S6E8AA0 DSI video mode panel"  	depends on OF diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile index 7c4d3c581fd4..96a883cd6630 100644 --- a/drivers/gpu/drm/panel/Makefile +++ b/drivers/gpu/drm/panel/Makefile @@ -1,8 +1,11 @@  # SPDX-License-Identifier: GPL-2.0  obj-$(CONFIG_DRM_PANEL_ARM_VERSATILE) += panel-arm-versatile.o  obj-$(CONFIG_DRM_PANEL_BOE_HIMAX8279D) += panel-boe-himax8279d.o +obj-$(CONFIG_DRM_PANEL_BOE_TV101WUM_NL6) += panel-boe-tv101wum-nl6.o  obj-$(CONFIG_DRM_PANEL_LVDS) += panel-lvds.o  obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o +obj-$(CONFIG_DRM_PANEL_ELIDA_KD35T133) += panel-elida-kd35t133.o +obj-$(CONFIG_DRM_PANEL_FEIXIN_K101_IM2BA02) += panel-feixin-k101-im2ba02.o  obj-$(CONFIG_DRM_PANEL_FEIYANG_FY07024DI26A30D) += panel-feiyang-fy07024di26a30d.o  obj-$(CONFIG_DRM_PANEL_ILITEK_IL9322) += panel-ilitek-ili9322.o  obj-$(CONFIG_DRM_PANEL_ILITEK_ILI9881C) += panel-ilitek-ili9881c.o @@ -13,6 +16,7 @@ obj-$(CONFIG_DRM_PANEL_LEADTEK_LTK500HD1829) += panel-leadtek-ltk500hd1829.o  obj-$(CONFIG_DRM_PANEL_LG_LB035Q02) += panel-lg-lb035q02.o  obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o  obj-$(CONFIG_DRM_PANEL_NEC_NL8048HL11) += panel-nec-nl8048hl11.o +obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35510) += panel-novatek-nt35510.o  obj-$(CONFIG_DRM_PANEL_NOVATEK_NT39016) += panel-novatek-nt39016.o  obj-$(CONFIG_DRM_PANEL_OLIMEX_LCD_OLINUXINO) += panel-olimex-lcd-olinuxino.o  obj-$(CONFIG_DRM_PANEL_ORISETECH_OTM8009A) += panel-orisetech-otm8009a.o @@ -28,6 +32,7 @@ obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6D16D0) += panel-samsung-s6d16d0.o  obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2) += panel-samsung-s6e3ha2.o  obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03) += panel-samsung-s6e63j0x03.o  obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0) += panel-samsung-s6e63m0.o +obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E88A0_AMS452EF01) += panel-samsung-s6e88a0-ams452ef01.o  obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0) += panel-samsung-s6e8aa0.o  obj-$(CONFIG_DRM_PANEL_SEIKO_43WVF1G) += panel-seiko-43wvf1g.o  obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o diff --git a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c new file mode 100644 index 000000000000..48a164257d18 --- /dev/null +++ b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c @@ -0,0 +1,854 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2018 MediaTek Inc. + * Author: Jitao Shi <[email protected]> + */ + +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/regulator/consumer.h> + +#include <drm/drm_crtc.h> +#include <drm/drm_mipi_dsi.h> +#include <drm/drm_panel.h> + +#include <video/mipi_display.h> + +struct panel_desc { +	const struct drm_display_mode *modes; +	unsigned int bpc; + +	/** +	 * @width_mm: width of the panel's active display area +	 * @height_mm: height of the panel's active display area +	 */ +	struct { +		unsigned int width_mm; +		unsigned int height_mm; +	} size; + +	unsigned long mode_flags; +	enum mipi_dsi_pixel_format format; +	const struct panel_init_cmd *init_cmds; +	unsigned int lanes; +	bool discharge_on_disable; +}; + +struct boe_panel { +	struct drm_panel base; +	struct mipi_dsi_device *dsi; + +	const struct panel_desc *desc; + +	struct regulator *pp1800; +	struct regulator *avee; +	struct regulator *avdd; +	struct gpio_desc *enable_gpio; + +	bool prepared; +}; + +enum dsi_cmd_type { +	INIT_DCS_CMD, +	DELAY_CMD, +}; + +struct panel_init_cmd { +	enum dsi_cmd_type type; +	size_t len; +	const char *data; +}; + +#define _INIT_DCS_CMD(...) { \ +	.type = INIT_DCS_CMD, \ +	.len = sizeof((char[]){__VA_ARGS__}), \ +	.data = (char[]){__VA_ARGS__} } + +#define _INIT_DELAY_CMD(...) { \ +	.type = DELAY_CMD,\ +	.len = sizeof((char[]){__VA_ARGS__}), \ +	.data = (char[]){__VA_ARGS__} } + +static const struct panel_init_cmd boe_init_cmd[] = { +	_INIT_DELAY_CMD(24), +	_INIT_DCS_CMD(0xB0, 0x05), +	_INIT_DCS_CMD(0xB1, 0xE5), +	_INIT_DCS_CMD(0xB3, 0x52), +	_INIT_DCS_CMD(0xB0, 0x00), +	_INIT_DCS_CMD(0xB3, 0x88), +	_INIT_DCS_CMD(0xB0, 0x04), +	_INIT_DCS_CMD(0xB8, 0x00), +	_INIT_DCS_CMD(0xB0, 0x00), +	_INIT_DCS_CMD(0xB6, 0x03), +	_INIT_DCS_CMD(0xBA, 0x8B), +	_INIT_DCS_CMD(0xBF, 0x1A), +	_INIT_DCS_CMD(0xC0, 0x0F), +	_INIT_DCS_CMD(0xC2, 0x0C), +	_INIT_DCS_CMD(0xC3, 0x02), +	_INIT_DCS_CMD(0xC4, 0x0C), +	_INIT_DCS_CMD(0xC5, 0x02), +	_INIT_DCS_CMD(0xB0, 0x01), +	_INIT_DCS_CMD(0xE0, 0x26), +	_INIT_DCS_CMD(0xE1, 0x26), +	_INIT_DCS_CMD(0xDC, 0x00), +	_INIT_DCS_CMD(0xDD, 0x00), +	_INIT_DCS_CMD(0xCC, 0x26), +	_INIT_DCS_CMD(0xCD, 0x26), +	_INIT_DCS_CMD(0xC8, 0x00), +	_INIT_DCS_CMD(0xC9, 0x00), +	_INIT_DCS_CMD(0xD2, 0x03), +	_INIT_DCS_CMD(0xD3, 0x03), +	_INIT_DCS_CMD(0xE6, 0x04), +	_INIT_DCS_CMD(0xE7, 0x04), +	_INIT_DCS_CMD(0xC4, 0x09), +	_INIT_DCS_CMD(0xC5, 0x09), +	_INIT_DCS_CMD(0xD8, 0x0A), +	_INIT_DCS_CMD(0xD9, 0x0A), +	_INIT_DCS_CMD(0xC2, 0x0B), +	_INIT_DCS_CMD(0xC3, 0x0B), +	_INIT_DCS_CMD(0xD6, 0x0C), +	_INIT_DCS_CMD(0xD7, 0x0C), +	_INIT_DCS_CMD(0xC0, 0x05), +	_INIT_DCS_CMD(0xC1, 0x05), +	_INIT_DCS_CMD(0xD4, 0x06), +	_INIT_DCS_CMD(0xD5, 0x06), +	_INIT_DCS_CMD(0xCA, 0x07), +	_INIT_DCS_CMD(0xCB, 0x07), +	_INIT_DCS_CMD(0xDE, 0x08), +	_INIT_DCS_CMD(0xDF, 0x08), +	_INIT_DCS_CMD(0xB0, 0x02), +	_INIT_DCS_CMD(0xC0, 0x00), +	_INIT_DCS_CMD(0xC1, 0x0D), +	_INIT_DCS_CMD(0xC2, 0x17), +	_INIT_DCS_CMD(0xC3, 0x26), +	_INIT_DCS_CMD(0xC4, 0x31), +	_INIT_DCS_CMD(0xC5, 0x1C), +	_INIT_DCS_CMD(0xC6, 0x2C), +	_INIT_DCS_CMD(0xC7, 0x33), +	_INIT_DCS_CMD(0xC8, 0x31), +	_INIT_DCS_CMD(0xC9, 0x37), +	_INIT_DCS_CMD(0xCA, 0x37), +	_INIT_DCS_CMD(0xCB, 0x37), +	_INIT_DCS_CMD(0xCC, 0x39), +	_INIT_DCS_CMD(0xCD, 0x2E), +	_INIT_DCS_CMD(0xCE, 0x2F), +	_INIT_DCS_CMD(0xCF, 0x2F), +	_INIT_DCS_CMD(0xD0, 0x07), +	_INIT_DCS_CMD(0xD2, 0x00), +	_INIT_DCS_CMD(0xD3, 0x0D), +	_INIT_DCS_CMD(0xD4, 0x17), +	_INIT_DCS_CMD(0xD5, 0x26), +	_INIT_DCS_CMD(0xD6, 0x31), +	_INIT_DCS_CMD(0xD7, 0x3F), +	_INIT_DCS_CMD(0xD8, 0x3F), +	_INIT_DCS_CMD(0xD9, 0x3F), +	_INIT_DCS_CMD(0xDA, 0x3F), +	_INIT_DCS_CMD(0xDB, 0x37), +	_INIT_DCS_CMD(0xDC, 0x37), +	_INIT_DCS_CMD(0xDD, 0x37), +	_INIT_DCS_CMD(0xDE, 0x39), +	_INIT_DCS_CMD(0xDF, 0x2E), +	_INIT_DCS_CMD(0xE0, 0x2F), +	_INIT_DCS_CMD(0xE1, 0x2F), +	_INIT_DCS_CMD(0xE2, 0x07), +	_INIT_DCS_CMD(0xB0, 0x03), +	_INIT_DCS_CMD(0xC8, 0x0B), +	_INIT_DCS_CMD(0xC9, 0x07), +	_INIT_DCS_CMD(0xC3, 0x00), +	_INIT_DCS_CMD(0xE7, 0x00), +	_INIT_DCS_CMD(0xC5, 0x2A), +	_INIT_DCS_CMD(0xDE, 0x2A), +	_INIT_DCS_CMD(0xCA, 0x43), +	_INIT_DCS_CMD(0xC9, 0x07), +	_INIT_DCS_CMD(0xE4, 0xC0), +	_INIT_DCS_CMD(0xE5, 0x0D), +	_INIT_DCS_CMD(0xCB, 0x00), +	_INIT_DCS_CMD(0xB0, 0x06), +	_INIT_DCS_CMD(0xB8, 0xA5), +	_INIT_DCS_CMD(0xC0, 0xA5), +	_INIT_DCS_CMD(0xC7, 0x0F), +	_INIT_DCS_CMD(0xD5, 0x32), +	_INIT_DCS_CMD(0xB8, 0x00), +	_INIT_DCS_CMD(0xC0, 0x00), +	_INIT_DCS_CMD(0xBC, 0x00), +	_INIT_DCS_CMD(0xB0, 0x07), +	_INIT_DCS_CMD(0xB1, 0x00), +	_INIT_DCS_CMD(0xB2, 0x02), +	_INIT_DCS_CMD(0xB3, 0x0F), +	_INIT_DCS_CMD(0xB4, 0x25), +	_INIT_DCS_CMD(0xB5, 0x39), +	_INIT_DCS_CMD(0xB6, 0x4E), +	_INIT_DCS_CMD(0xB7, 0x72), +	_INIT_DCS_CMD(0xB8, 0x97), +	_INIT_DCS_CMD(0xB9, 0xDC), +	_INIT_DCS_CMD(0xBA, 0x22), +	_INIT_DCS_CMD(0xBB, 0xA4), +	_INIT_DCS_CMD(0xBC, 0x2B), +	_INIT_DCS_CMD(0xBD, 0x2F), +	_INIT_DCS_CMD(0xBE, 0xA9), +	_INIT_DCS_CMD(0xBF, 0x25), +	_INIT_DCS_CMD(0xC0, 0x61), +	_INIT_DCS_CMD(0xC1, 0x97), +	_INIT_DCS_CMD(0xC2, 0xB2), +	_INIT_DCS_CMD(0xC3, 0xCD), +	_INIT_DCS_CMD(0xC4, 0xD9), +	_INIT_DCS_CMD(0xC5, 0xE7), +	_INIT_DCS_CMD(0xC6, 0xF4), +	_INIT_DCS_CMD(0xC7, 0xFA), +	_INIT_DCS_CMD(0xC8, 0xFC), +	_INIT_DCS_CMD(0xC9, 0x00), +	_INIT_DCS_CMD(0xCA, 0x00), +	_INIT_DCS_CMD(0xCB, 0x16), +	_INIT_DCS_CMD(0xCC, 0xAF), +	_INIT_DCS_CMD(0xCD, 0xFF), +	_INIT_DCS_CMD(0xCE, 0xFF), +	_INIT_DCS_CMD(0xB0, 0x08), +	_INIT_DCS_CMD(0xB1, 0x04), +	_INIT_DCS_CMD(0xB2, 0x05), +	_INIT_DCS_CMD(0xB3, 0x11), +	_INIT_DCS_CMD(0xB4, 0x24), +	_INIT_DCS_CMD(0xB5, 0x39), +	_INIT_DCS_CMD(0xB6, 0x4F), +	_INIT_DCS_CMD(0xB7, 0x72), +	_INIT_DCS_CMD(0xB8, 0x98), +	_INIT_DCS_CMD(0xB9, 0xDC), +	_INIT_DCS_CMD(0xBA, 0x23), +	_INIT_DCS_CMD(0xBB, 0xA6), +	_INIT_DCS_CMD(0xBC, 0x2C), +	_INIT_DCS_CMD(0xBD, 0x30), +	_INIT_DCS_CMD(0xBE, 0xAA), +	_INIT_DCS_CMD(0xBF, 0x26), +	_INIT_DCS_CMD(0xC0, 0x62), +	_INIT_DCS_CMD(0xC1, 0x9B), +	_INIT_DCS_CMD(0xC2, 0xB5), +	_INIT_DCS_CMD(0xC3, 0xCF), +	_INIT_DCS_CMD(0xC4, 0xDB), +	_INIT_DCS_CMD(0xC5, 0xE8), +	_INIT_DCS_CMD(0xC6, 0xF5), +	_INIT_DCS_CMD(0xC7, 0xFA), +	_INIT_DCS_CMD(0xC8, 0xFC), +	_INIT_DCS_CMD(0xC9, 0x00), +	_INIT_DCS_CMD(0xCA, 0x00), +	_INIT_DCS_CMD(0xCB, 0x16), +	_INIT_DCS_CMD(0xCC, 0xAF), +	_INIT_DCS_CMD(0xCD, 0xFF), +	_INIT_DCS_CMD(0xCE, 0xFF), +	_INIT_DCS_CMD(0xB0, 0x09), +	_INIT_DCS_CMD(0xB1, 0x04), +	_INIT_DCS_CMD(0xB2, 0x02), +	_INIT_DCS_CMD(0xB3, 0x16), +	_INIT_DCS_CMD(0xB4, 0x24), +	_INIT_DCS_CMD(0xB5, 0x3B), +	_INIT_DCS_CMD(0xB6, 0x4F), +	_INIT_DCS_CMD(0xB7, 0x73), +	_INIT_DCS_CMD(0xB8, 0x99), +	_INIT_DCS_CMD(0xB9, 0xE0), +	_INIT_DCS_CMD(0xBA, 0x26), +	_INIT_DCS_CMD(0xBB, 0xAD), +	_INIT_DCS_CMD(0xBC, 0x36), +	_INIT_DCS_CMD(0xBD, 0x3A), +	_INIT_DCS_CMD(0xBE, 0xAE), +	_INIT_DCS_CMD(0xBF, 0x2A), +	_INIT_DCS_CMD(0xC0, 0x66), +	_INIT_DCS_CMD(0xC1, 0x9E), +	_INIT_DCS_CMD(0xC2, 0xB8), +	_INIT_DCS_CMD(0xC3, 0xD1), +	_INIT_DCS_CMD(0xC4, 0xDD), +	_INIT_DCS_CMD(0xC5, 0xE9), +	_INIT_DCS_CMD(0xC6, 0xF6), +	_INIT_DCS_CMD(0xC7, 0xFA), +	_INIT_DCS_CMD(0xC8, 0xFC), +	_INIT_DCS_CMD(0xC9, 0x00), +	_INIT_DCS_CMD(0xCA, 0x00), +	_INIT_DCS_CMD(0xCB, 0x16), +	_INIT_DCS_CMD(0xCC, 0xAF), +	_INIT_DCS_CMD(0xCD, 0xFF), +	_INIT_DCS_CMD(0xCE, 0xFF), +	_INIT_DCS_CMD(0xB0, 0x0A), +	_INIT_DCS_CMD(0xB1, 0x00), +	_INIT_DCS_CMD(0xB2, 0x02), +	_INIT_DCS_CMD(0xB3, 0x0F), +	_INIT_DCS_CMD(0xB4, 0x25), +	_INIT_DCS_CMD(0xB5, 0x39), +	_INIT_DCS_CMD(0xB6, 0x4E), +	_INIT_DCS_CMD(0xB7, 0x72), +	_INIT_DCS_CMD(0xB8, 0x97), +	_INIT_DCS_CMD(0xB9, 0xDC), +	_INIT_DCS_CMD(0xBA, 0x22), +	_INIT_DCS_CMD(0xBB, 0xA4), +	_INIT_DCS_CMD(0xBC, 0x2B), +	_INIT_DCS_CMD(0xBD, 0x2F), +	_INIT_DCS_CMD(0xBE, 0xA9), +	_INIT_DCS_CMD(0xBF, 0x25), +	_INIT_DCS_CMD(0xC0, 0x61), +	_INIT_DCS_CMD(0xC1, 0x97), +	_INIT_DCS_CMD(0xC2, 0xB2), +	_INIT_DCS_CMD(0xC3, 0xCD), +	_INIT_DCS_CMD(0xC4, 0xD9), +	_INIT_DCS_CMD(0xC5, 0xE7), +	_INIT_DCS_CMD(0xC6, 0xF4), +	_INIT_DCS_CMD(0xC7, 0xFA), +	_INIT_DCS_CMD(0xC8, 0xFC), +	_INIT_DCS_CMD(0xC9, 0x00), +	_INIT_DCS_CMD(0xCA, 0x00), +	_INIT_DCS_CMD(0xCB, 0x16), +	_INIT_DCS_CMD(0xCC, 0xAF), +	_INIT_DCS_CMD(0xCD, 0xFF), +	_INIT_DCS_CMD(0xCE, 0xFF), +	_INIT_DCS_CMD(0xB0, 0x0B), +	_INIT_DCS_CMD(0xB1, 0x04), +	_INIT_DCS_CMD(0xB2, 0x05), +	_INIT_DCS_CMD(0xB3, 0x11), +	_INIT_DCS_CMD(0xB4, 0x24), +	_INIT_DCS_CMD(0xB5, 0x39), +	_INIT_DCS_CMD(0xB6, 0x4F), +	_INIT_DCS_CMD(0xB7, 0x72), +	_INIT_DCS_CMD(0xB8, 0x98), +	_INIT_DCS_CMD(0xB9, 0xDC), +	_INIT_DCS_CMD(0xBA, 0x23), +	_INIT_DCS_CMD(0xBB, 0xA6), +	_INIT_DCS_CMD(0xBC, 0x2C), +	_INIT_DCS_CMD(0xBD, 0x30), +	_INIT_DCS_CMD(0xBE, 0xAA), +	_INIT_DCS_CMD(0xBF, 0x26), +	_INIT_DCS_CMD(0xC0, 0x62), +	_INIT_DCS_CMD(0xC1, 0x9B), +	_INIT_DCS_CMD(0xC2, 0xB5), +	_INIT_DCS_CMD(0xC3, 0xCF), +	_INIT_DCS_CMD(0xC4, 0xDB), +	_INIT_DCS_CMD(0xC5, 0xE8), +	_INIT_DCS_CMD(0xC6, 0xF5), +	_INIT_DCS_CMD(0xC7, 0xFA), +	_INIT_DCS_CMD(0xC8, 0xFC), +	_INIT_DCS_CMD(0xC9, 0x00), +	_INIT_DCS_CMD(0xCA, 0x00), +	_INIT_DCS_CMD(0xCB, 0x16), +	_INIT_DCS_CMD(0xCC, 0xAF), +	_INIT_DCS_CMD(0xCD, 0xFF), +	_INIT_DCS_CMD(0xCE, 0xFF), +	_INIT_DCS_CMD(0xB0, 0x0C), +	_INIT_DCS_CMD(0xB1, 0x04), +	_INIT_DCS_CMD(0xB2, 0x02), +	_INIT_DCS_CMD(0xB3, 0x16), +	_INIT_DCS_CMD(0xB4, 0x24), +	_INIT_DCS_CMD(0xB5, 0x3B), +	_INIT_DCS_CMD(0xB6, 0x4F), +	_INIT_DCS_CMD(0xB7, 0x73), +	_INIT_DCS_CMD(0xB8, 0x99), +	_INIT_DCS_CMD(0xB9, 0xE0), +	_INIT_DCS_CMD(0xBA, 0x26), +	_INIT_DCS_CMD(0xBB, 0xAD), +	_INIT_DCS_CMD(0xBC, 0x36), +	_INIT_DCS_CMD(0xBD, 0x3A), +	_INIT_DCS_CMD(0xBE, 0xAE), +	_INIT_DCS_CMD(0xBF, 0x2A), +	_INIT_DCS_CMD(0xC0, 0x66), +	_INIT_DCS_CMD(0xC1, 0x9E), +	_INIT_DCS_CMD(0xC2, 0xB8), +	_INIT_DCS_CMD(0xC3, 0xD1), +	_INIT_DCS_CMD(0xC4, 0xDD), +	_INIT_DCS_CMD(0xC5, 0xE9), +	_INIT_DCS_CMD(0xC6, 0xF6), +	_INIT_DCS_CMD(0xC7, 0xFA), +	_INIT_DCS_CMD(0xC8, 0xFC), +	_INIT_DCS_CMD(0xC9, 0x00), +	_INIT_DCS_CMD(0xCA, 0x00), +	_INIT_DCS_CMD(0xCB, 0x16), +	_INIT_DCS_CMD(0xCC, 0xAF), +	_INIT_DCS_CMD(0xCD, 0xFF), +	_INIT_DCS_CMD(0xCE, 0xFF), +	_INIT_DCS_CMD(0xB0, 0x00), +	_INIT_DCS_CMD(0xB3, 0x08), +	_INIT_DCS_CMD(0xB0, 0x04), +	_INIT_DCS_CMD(0xB8, 0x68), +	_INIT_DELAY_CMD(150), +	{}, +}; + +static const struct panel_init_cmd auo_kd101n80_45na_init_cmd[] = { +	_INIT_DELAY_CMD(24), +	_INIT_DCS_CMD(0x11), +	_INIT_DELAY_CMD(120), +	_INIT_DCS_CMD(0x29), +	_INIT_DELAY_CMD(120), +	{}, +}; + +static const struct panel_init_cmd auo_b101uan08_3_init_cmd[] = { +	_INIT_DELAY_CMD(24), +	_INIT_DCS_CMD(0xB0, 0x01), +	_INIT_DCS_CMD(0xC0, 0x48), +	_INIT_DCS_CMD(0xC1, 0x48), +	_INIT_DCS_CMD(0xC2, 0x47), +	_INIT_DCS_CMD(0xC3, 0x47), +	_INIT_DCS_CMD(0xC4, 0x46), +	_INIT_DCS_CMD(0xC5, 0x46), +	_INIT_DCS_CMD(0xC6, 0x45), +	_INIT_DCS_CMD(0xC7, 0x45), +	_INIT_DCS_CMD(0xC8, 0x64), +	_INIT_DCS_CMD(0xC9, 0x64), +	_INIT_DCS_CMD(0xCA, 0x4F), +	_INIT_DCS_CMD(0xCB, 0x4F), +	_INIT_DCS_CMD(0xCC, 0x40), +	_INIT_DCS_CMD(0xCD, 0x40), +	_INIT_DCS_CMD(0xCE, 0x66), +	_INIT_DCS_CMD(0xCF, 0x66), +	_INIT_DCS_CMD(0xD0, 0x4F), +	_INIT_DCS_CMD(0xD1, 0x4F), +	_INIT_DCS_CMD(0xD2, 0x41), +	_INIT_DCS_CMD(0xD3, 0x41), +	_INIT_DCS_CMD(0xD4, 0x48), +	_INIT_DCS_CMD(0xD5, 0x48), +	_INIT_DCS_CMD(0xD6, 0x47), +	_INIT_DCS_CMD(0xD7, 0x47), +	_INIT_DCS_CMD(0xD8, 0x46), +	_INIT_DCS_CMD(0xD9, 0x46), +	_INIT_DCS_CMD(0xDA, 0x45), +	_INIT_DCS_CMD(0xDB, 0x45), +	_INIT_DCS_CMD(0xDC, 0x64), +	_INIT_DCS_CMD(0xDD, 0x64), +	_INIT_DCS_CMD(0xDE, 0x4F), +	_INIT_DCS_CMD(0xDF, 0x4F), +	_INIT_DCS_CMD(0xE0, 0x40), +	_INIT_DCS_CMD(0xE1, 0x40), +	_INIT_DCS_CMD(0xE2, 0x66), +	_INIT_DCS_CMD(0xE3, 0x66), +	_INIT_DCS_CMD(0xE4, 0x4F), +	_INIT_DCS_CMD(0xE5, 0x4F), +	_INIT_DCS_CMD(0xE6, 0x41), +	_INIT_DCS_CMD(0xE7, 0x41), +	_INIT_DELAY_CMD(150), +	{}, +}; + +static inline struct boe_panel *to_boe_panel(struct drm_panel *panel) +{ +	return container_of(panel, struct boe_panel, base); +} + +static int boe_panel_init_dcs_cmd(struct boe_panel *boe) +{ +	struct mipi_dsi_device *dsi = boe->dsi; +	struct drm_panel *panel = &boe->base; +	int i, err = 0; + +	if (boe->desc->init_cmds) { +		const struct panel_init_cmd *init_cmds = boe->desc->init_cmds; + +		for (i = 0; init_cmds[i].len != 0; i++) { +			const struct panel_init_cmd *cmd = &init_cmds[i]; + +			switch (cmd->type) { +			case DELAY_CMD: +				msleep(cmd->data[0]); +				err = 0; +				break; + +			case INIT_DCS_CMD: +				err = mipi_dsi_dcs_write(dsi, cmd->data[0], +							 cmd->len <= 1 ? NULL : +							 &cmd->data[1], +							 cmd->len - 1); +				break; + +			default: +				err = -EINVAL; +			} + +			if (err < 0) { +				dev_err(panel->dev, +					"failed to write command %u\n", i); +				return err; +			} +		} +	} +	return 0; +} + +static int boe_panel_enter_sleep_mode(struct boe_panel *boe) +{ +	struct mipi_dsi_device *dsi = boe->dsi; +	int ret; + +	dsi->mode_flags &= ~MIPI_DSI_MODE_LPM; + +	ret = mipi_dsi_dcs_set_display_off(dsi); +	if (ret < 0) +		return ret; + +	ret = mipi_dsi_dcs_enter_sleep_mode(dsi); +	if (ret < 0) +		return ret; + +	return 0; +} + +static int boe_panel_unprepare(struct drm_panel *panel) +{ +	struct boe_panel *boe = to_boe_panel(panel); +	int ret; + +	if (!boe->prepared) +		return 0; + +	ret = boe_panel_enter_sleep_mode(boe); +	if (ret < 0) { +		dev_err(panel->dev, "failed to set panel off: %d\n", ret); +		return ret; +	} + +	msleep(150); + +	if (boe->desc->discharge_on_disable) { +		regulator_disable(boe->avee); +		regulator_disable(boe->avdd); +		usleep_range(5000, 7000); +		gpiod_set_value(boe->enable_gpio, 0); +		usleep_range(5000, 7000); +		regulator_disable(boe->pp1800); +	} else { +		gpiod_set_value(boe->enable_gpio, 0); +		usleep_range(500, 1000); +		regulator_disable(boe->avee); +		regulator_disable(boe->avdd); +		usleep_range(5000, 7000); +		regulator_disable(boe->pp1800); +	} + +	boe->prepared = false; + +	return 0; +} + +static int boe_panel_prepare(struct drm_panel *panel) +{ +	struct boe_panel *boe = to_boe_panel(panel); +	int ret; + +	if (boe->prepared) +		return 0; + +	gpiod_set_value(boe->enable_gpio, 0); +	usleep_range(1000, 1500); + +	ret = regulator_enable(boe->pp1800); +	if (ret < 0) +		return ret; + +	usleep_range(3000, 5000); + +	ret = regulator_enable(boe->avdd); +	if (ret < 0) +		goto poweroff1v8; +	ret = regulator_enable(boe->avee); +	if (ret < 0) +		goto poweroffavdd; + +	usleep_range(5000, 10000); + +	gpiod_set_value(boe->enable_gpio, 1); +	usleep_range(1000, 2000); +	gpiod_set_value(boe->enable_gpio, 0); +	usleep_range(1000, 2000); +	gpiod_set_value(boe->enable_gpio, 1); +	usleep_range(6000, 10000); + +	ret = boe_panel_init_dcs_cmd(boe); +	if (ret < 0) { +		dev_err(panel->dev, "failed to init panel: %d\n", ret); +		goto poweroff; +	} + +	boe->prepared = true; + +	return 0; + +poweroff: +	regulator_disable(boe->avee); +poweroffavdd: +	regulator_disable(boe->avdd); +poweroff1v8: +	usleep_range(5000, 7000); +	regulator_disable(boe->pp1800); +	gpiod_set_value(boe->enable_gpio, 0); + +	return ret; +} + +static int boe_panel_enable(struct drm_panel *panel) +{ +	msleep(130); +	return 0; +} + +static const struct drm_display_mode boe_tv101wum_nl6_default_mode = { +	.clock = 159425, +	.hdisplay = 1200, +	.hsync_start = 1200 + 100, +	.hsync_end = 1200 + 100 + 40, +	.htotal = 1200 + 100 + 40 + 24, +	.vdisplay = 1920, +	.vsync_start = 1920 + 10, +	.vsync_end = 1920 + 10 + 14, +	.vtotal = 1920 + 10 + 14 + 4, +	.vrefresh = 60, +}; + +static const struct panel_desc boe_tv101wum_nl6_desc = { +	.modes = &boe_tv101wum_nl6_default_mode, +	.bpc = 8, +	.size = { +		.width_mm = 135, +		.height_mm = 216, +	}, +	.lanes = 4, +	.format = MIPI_DSI_FMT_RGB888, +	.mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | +		      MIPI_DSI_MODE_LPM, +	.init_cmds = boe_init_cmd, +	.discharge_on_disable = false, +}; + +static const struct drm_display_mode auo_kd101n80_45na_default_mode = { +	.clock = 157000, +	.hdisplay = 1200, +	.hsync_start = 1200 + 80, +	.hsync_end = 1200 + 80 + 24, +	.htotal = 1200 + 80 + 24 + 36, +	.vdisplay = 1920, +	.vsync_start = 1920 + 16, +	.vsync_end = 1920 + 16 + 4, +	.vtotal = 1920 + 16 + 4 + 16, +	.vrefresh = 60, +}; + +static const struct panel_desc auo_kd101n80_45na_desc = { +	.modes = &auo_kd101n80_45na_default_mode, +	.bpc = 8, +	.size = { +		.width_mm = 135, +		.height_mm = 216, +	}, +	.lanes = 4, +	.format = MIPI_DSI_FMT_RGB888, +	.mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | +		      MIPI_DSI_MODE_LPM, +	.init_cmds = auo_kd101n80_45na_init_cmd, +	.discharge_on_disable = true, +}; + +static const struct drm_display_mode boe_tv101wum_n53_default_mode = { +	.clock = 159916, +	.hdisplay = 1200, +	.hsync_start = 1200 + 80, +	.hsync_end = 1200 + 80 + 24, +	.htotal = 1200 + 80 + 24 + 60, +	.vdisplay = 1920, +	.vsync_start = 1920 + 20, +	.vsync_end = 1920 + 20 + 4, +	.vtotal = 1920 + 20 + 4 + 10, +	.vrefresh = 60, +	.type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED, +}; + +static const struct panel_desc boe_tv101wum_n53_desc = { +	.modes = &boe_tv101wum_n53_default_mode, +	.bpc = 8, +	.size = { +		.width_mm = 135, +		.height_mm = 216, +	}, +	.lanes = 4, +	.format = MIPI_DSI_FMT_RGB888, +	.mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | +		      MIPI_DSI_MODE_LPM, +	.init_cmds = boe_init_cmd, +}; + +static const struct drm_display_mode auo_b101uan08_3_default_mode = { +	.clock = 159667, +	.hdisplay = 1200, +	.hsync_start = 1200 + 60, +	.hsync_end = 1200 + 60 + 4, +	.htotal = 1200 + 60 + 4 + 80, +	.vdisplay = 1920, +	.vsync_start = 1920 + 34, +	.vsync_end = 1920 + 34 + 2, +	.vtotal = 1920 + 34 + 2 + 24, +	.vrefresh = 60, +	.type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED, +}; + +static const struct panel_desc auo_b101uan08_3_desc = { +	.modes = &auo_b101uan08_3_default_mode, +	.bpc = 8, +	.size = { +		.width_mm = 135, +		.height_mm = 216, +	}, +	.lanes = 4, +	.format = MIPI_DSI_FMT_RGB888, +	.mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | +		      MIPI_DSI_MODE_LPM, +	.init_cmds = auo_b101uan08_3_init_cmd, +}; + +static int boe_panel_get_modes(struct drm_panel *panel, +			       struct drm_connector *connector) +{ +	struct boe_panel *boe = to_boe_panel(panel); +	const struct drm_display_mode *m = boe->desc->modes; +	struct drm_display_mode *mode; + +	mode = drm_mode_duplicate(connector->dev, m); +	if (!mode) { +		dev_err(panel->dev, "failed to add mode %ux%u@%u\n", +			m->hdisplay, m->vdisplay, m->vrefresh); +		return -ENOMEM; +	} + +	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; +	drm_mode_set_name(mode); +	drm_mode_probed_add(connector, mode); + +	connector->display_info.width_mm = boe->desc->size.width_mm; +	connector->display_info.height_mm = boe->desc->size.height_mm; +	connector->display_info.bpc = boe->desc->bpc; + +	return 1; +} + +static const struct drm_panel_funcs boe_panel_funcs = { +	.unprepare = boe_panel_unprepare, +	.prepare = boe_panel_prepare, +	.enable = boe_panel_enable, +	.get_modes = boe_panel_get_modes, +}; + +static int boe_panel_add(struct boe_panel *boe) +{ +	struct device *dev = &boe->dsi->dev; +	int err; + +	boe->avdd = devm_regulator_get(dev, "avdd"); +	if (IS_ERR(boe->avdd)) +		return PTR_ERR(boe->avdd); + +	boe->avee = devm_regulator_get(dev, "avee"); +	if (IS_ERR(boe->avee)) +		return PTR_ERR(boe->avee); + +	boe->pp1800 = devm_regulator_get(dev, "pp1800"); +	if (IS_ERR(boe->pp1800)) +		return PTR_ERR(boe->pp1800); + +	boe->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW); +	if (IS_ERR(boe->enable_gpio)) { +		dev_err(dev, "cannot get reset-gpios %ld\n", +			PTR_ERR(boe->enable_gpio)); +		return PTR_ERR(boe->enable_gpio); +	} + +	gpiod_set_value(boe->enable_gpio, 0); + +	drm_panel_init(&boe->base, dev, &boe_panel_funcs, +		       DRM_MODE_CONNECTOR_DSI); + +	err = drm_panel_of_backlight(&boe->base); +	if (err) +		return err; + +	boe->base.funcs = &boe_panel_funcs; +	boe->base.dev = &boe->dsi->dev; + +	return drm_panel_add(&boe->base); +} + +static int boe_panel_probe(struct mipi_dsi_device *dsi) +{ +	struct boe_panel *boe; +	int ret; +	const struct panel_desc *desc; + +	boe = devm_kzalloc(&dsi->dev, sizeof(*boe), GFP_KERNEL); +	if (!boe) +		return -ENOMEM; + +	desc = of_device_get_match_data(&dsi->dev); +	dsi->lanes = desc->lanes; +	dsi->format = desc->format; +	dsi->mode_flags = desc->mode_flags; +	boe->desc = desc; +	boe->dsi = dsi; +	ret = boe_panel_add(boe); +	if (ret < 0) +		return ret; + +	mipi_dsi_set_drvdata(dsi, boe); + +	ret = mipi_dsi_attach(dsi); +	if (ret) +		drm_panel_remove(&boe->base); + +	return ret; +} + +static void boe_panel_shutdown(struct mipi_dsi_device *dsi) +{ +	struct boe_panel *boe = mipi_dsi_get_drvdata(dsi); + +	drm_panel_disable(&boe->base); +	drm_panel_unprepare(&boe->base); +} + +static int boe_panel_remove(struct mipi_dsi_device *dsi) +{ +	struct boe_panel *boe = mipi_dsi_get_drvdata(dsi); +	int ret; + +	boe_panel_shutdown(dsi); + +	ret = mipi_dsi_detach(dsi); +	if (ret < 0) +		dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", ret); + +	if (boe->base.dev) +		drm_panel_remove(&boe->base); + +	return 0; +} + +static const struct of_device_id boe_of_match[] = { +	{ .compatible = "boe,tv101wum-nl6", +	  .data = &boe_tv101wum_nl6_desc +	}, +	{ .compatible = "auo,kd101n80-45na", +	  .data = &auo_kd101n80_45na_desc +	}, +	{ .compatible = "boe,tv101wum-n53", +	  .data = &boe_tv101wum_n53_desc +	}, +	{ .compatible = "auo,b101uan08.3", +	  .data = &auo_b101uan08_3_desc +	}, +	{ /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, boe_of_match); + +static struct mipi_dsi_driver boe_panel_driver = { +	.driver = { +		.name = "panel-boe-tv101wum-nl6", +		.of_match_table = boe_of_match, +	}, +	.probe = boe_panel_probe, +	.remove = boe_panel_remove, +	.shutdown = boe_panel_shutdown, +}; +module_mipi_dsi_driver(boe_panel_driver); + +MODULE_AUTHOR("Jitao Shi <[email protected]>"); +MODULE_DESCRIPTION("BOE tv101wum-nl6 1200x1920 video mode panel driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/gpu/drm/panel/panel-elida-kd35t133.c b/drivers/gpu/drm/panel/panel-elida-kd35t133.c new file mode 100644 index 000000000000..711ded453c44 --- /dev/null +++ b/drivers/gpu/drm/panel/panel-elida-kd35t133.c @@ -0,0 +1,352 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Elida kd35t133 5.5" MIPI-DSI panel driver + * Copyright (C) 2020 Theobroma Systems Design und Consulting GmbH + * + * based on + * + * Rockteck jh057n00900 5.5" MIPI-DSI panel driver + * Copyright (C) Purism SPC 2019 + */ + +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/media-bus-format.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/regulator/consumer.h> + +#include <video/display_timing.h> +#include <video/mipi_display.h> + +#include <drm/drm_mipi_dsi.h> +#include <drm/drm_modes.h> +#include <drm/drm_panel.h> +#include <drm/drm_print.h> + +/* Manufacturer specific Commands send via DSI */ +#define KD35T133_CMD_INTERFACEMODECTRL		0xb0 +#define KD35T133_CMD_FRAMERATECTRL		0xb1 +#define KD35T133_CMD_DISPLAYINVERSIONCTRL	0xb4 +#define KD35T133_CMD_DISPLAYFUNCTIONCTRL	0xb6 +#define KD35T133_CMD_POWERCONTROL1		0xc0 +#define KD35T133_CMD_POWERCONTROL2		0xc1 +#define KD35T133_CMD_VCOMCONTROL		0xc5 +#define KD35T133_CMD_POSITIVEGAMMA		0xe0 +#define KD35T133_CMD_NEGATIVEGAMMA		0xe1 +#define KD35T133_CMD_SETIMAGEFUNCTION		0xe9 +#define KD35T133_CMD_ADJUSTCONTROL3		0xf7 + +struct kd35t133 { +	struct device *dev; +	struct drm_panel panel; +	struct gpio_desc *reset_gpio; +	struct regulator *vdd; +	struct regulator *iovcc; +	bool prepared; +}; + +static inline struct kd35t133 *panel_to_kd35t133(struct drm_panel *panel) +{ +	return container_of(panel, struct kd35t133, panel); +} + +#define dsi_dcs_write_seq(dsi, cmd, seq...) do {			\ +		static const u8 d[] = { seq };				\ +		int ret;						\ +		ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d));	\ +		if (ret < 0)						\ +			return ret;					\ +	} while (0) + +static int kd35t133_init_sequence(struct kd35t133 *ctx) +{ +	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); +	struct device *dev = ctx->dev; + +	/* +	 * Init sequence was supplied by the panel vendor with minimal +	 * documentation. +	 */ +	dsi_dcs_write_seq(dsi, KD35T133_CMD_POSITIVEGAMMA, +			  0x00, 0x13, 0x18, 0x04, 0x0f, 0x06, 0x3a, 0x56, +			  0x4d, 0x03, 0x0a, 0x06, 0x30, 0x3e, 0x0f); +	dsi_dcs_write_seq(dsi, KD35T133_CMD_NEGATIVEGAMMA, +			  0x00, 0x13, 0x18, 0x01, 0x11, 0x06, 0x38, 0x34, +			  0x4d, 0x06, 0x0d, 0x0b, 0x31, 0x37, 0x0f); +	dsi_dcs_write_seq(dsi, KD35T133_CMD_POWERCONTROL1, 0x18, 0x17); +	dsi_dcs_write_seq(dsi, KD35T133_CMD_POWERCONTROL2, 0x41); +	dsi_dcs_write_seq(dsi, KD35T133_CMD_VCOMCONTROL, 0x00, 0x1a, 0x80); +	dsi_dcs_write_seq(dsi, MIPI_DCS_SET_ADDRESS_MODE, 0x48); +	dsi_dcs_write_seq(dsi, MIPI_DCS_SET_PIXEL_FORMAT, 0x55); +	dsi_dcs_write_seq(dsi, KD35T133_CMD_INTERFACEMODECTRL, 0x00); +	dsi_dcs_write_seq(dsi, KD35T133_CMD_FRAMERATECTRL, 0xa0); +	dsi_dcs_write_seq(dsi, KD35T133_CMD_DISPLAYINVERSIONCTRL, 0x02); +	dsi_dcs_write_seq(dsi, KD35T133_CMD_DISPLAYFUNCTIONCTRL, +			  0x20, 0x02); +	dsi_dcs_write_seq(dsi, KD35T133_CMD_SETIMAGEFUNCTION, 0x00); +	dsi_dcs_write_seq(dsi, KD35T133_CMD_ADJUSTCONTROL3, +			  0xa9, 0x51, 0x2c, 0x82); +	mipi_dsi_dcs_write(dsi, MIPI_DCS_ENTER_INVERT_MODE, NULL, 0); + +	DRM_DEV_DEBUG_DRIVER(dev, "Panel init sequence done\n"); +	return 0; +} + +static int kd35t133_unprepare(struct drm_panel *panel) +{ +	struct kd35t133 *ctx = panel_to_kd35t133(panel); +	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); +	int ret; + +	if (!ctx->prepared) +		return 0; + +	ret = mipi_dsi_dcs_set_display_off(dsi); +	if (ret < 0) +		DRM_DEV_ERROR(ctx->dev, "failed to set display off: %d\n", +			      ret); + +	ret = mipi_dsi_dcs_enter_sleep_mode(dsi); +	if (ret < 0) { +		DRM_DEV_ERROR(ctx->dev, "failed to enter sleep mode: %d\n", +			      ret); +		return ret; +	} + +	regulator_disable(ctx->iovcc); +	regulator_disable(ctx->vdd); + +	ctx->prepared = false; + +	return 0; +} + +static int kd35t133_prepare(struct drm_panel *panel) +{ +	struct kd35t133 *ctx = panel_to_kd35t133(panel); +	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); +	int ret; + +	if (ctx->prepared) +		return 0; + +	DRM_DEV_DEBUG_DRIVER(ctx->dev, "Resetting the panel\n"); +	ret = regulator_enable(ctx->vdd); +	if (ret < 0) { +		DRM_DEV_ERROR(ctx->dev, +			      "Failed to enable vdd supply: %d\n", ret); +		return ret; +	} + +	ret = regulator_enable(ctx->iovcc); +	if (ret < 0) { +		DRM_DEV_ERROR(ctx->dev, +			      "Failed to enable iovcc supply: %d\n", ret); +		goto disable_vdd; +	} + +	msleep(20); + +	gpiod_set_value_cansleep(ctx->reset_gpio, 1); +	usleep_range(10, 20); +	gpiod_set_value_cansleep(ctx->reset_gpio, 0); + +	msleep(20); + +	ret = mipi_dsi_dcs_exit_sleep_mode(dsi); +	if (ret < 0) { +		DRM_DEV_ERROR(ctx->dev, "Failed to exit sleep mode: %d\n", ret); +		goto disable_iovcc; +	} + +	msleep(250); + +	ret = kd35t133_init_sequence(ctx); +	if (ret < 0) { +		DRM_DEV_ERROR(ctx->dev, "Panel init sequence failed: %d\n", +			      ret); +		goto disable_iovcc; +	} + +	ret = mipi_dsi_dcs_set_display_on(dsi); +	if (ret < 0) { +		DRM_DEV_ERROR(ctx->dev, "Failed to set display on: %d\n", ret); +		goto disable_iovcc; +	} + +	msleep(50); + +	ctx->prepared = true; + +	return 0; + +disable_iovcc: +	regulator_disable(ctx->iovcc); +disable_vdd: +	regulator_disable(ctx->vdd); +	return ret; +} + +static const struct drm_display_mode default_mode = { +	.hdisplay	= 320, +	.hsync_start	= 320 + 130, +	.hsync_end	= 320 + 130 + 4, +	.htotal		= 320 + 130 + 4 + 130, +	.vdisplay	= 480, +	.vsync_start	= 480 + 2, +	.vsync_end	= 480 + 2 + 1, +	.vtotal		= 480 + 2 + 1 + 2, +	.vrefresh	= 60, +	.clock		= 17000, +	.width_mm	= 42, +	.height_mm	= 82, +}; + +static int kd35t133_get_modes(struct drm_panel *panel, +				struct drm_connector *connector) +{ +	struct kd35t133 *ctx = panel_to_kd35t133(panel); +	struct drm_display_mode *mode; + +	mode = drm_mode_duplicate(connector->dev, &default_mode); +	if (!mode) { +		DRM_DEV_ERROR(ctx->dev, "Failed to add mode %ux%u@%u\n", +			      default_mode.hdisplay, default_mode.vdisplay, +			      default_mode.vrefresh); +		return -ENOMEM; +	} + +	drm_mode_set_name(mode); + +	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; +	connector->display_info.width_mm = mode->width_mm; +	connector->display_info.height_mm = mode->height_mm; +	drm_mode_probed_add(connector, mode); + +	return 1; +} + +static const struct drm_panel_funcs kd35t133_funcs = { +	.unprepare	= kd35t133_unprepare, +	.prepare	= kd35t133_prepare, +	.get_modes	= kd35t133_get_modes, +}; + +static int kd35t133_probe(struct mipi_dsi_device *dsi) +{ +	struct device *dev = &dsi->dev; +	struct kd35t133 *ctx; +	int ret; + +	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); +	if (!ctx) +		return -ENOMEM; + +	ctx->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); +	if (IS_ERR(ctx->reset_gpio)) { +		DRM_DEV_ERROR(dev, "cannot get reset gpio\n"); +		return PTR_ERR(ctx->reset_gpio); +	} + +	ctx->vdd = devm_regulator_get(dev, "vdd"); +	if (IS_ERR(ctx->vdd)) { +		ret = PTR_ERR(ctx->vdd); +		if (ret != -EPROBE_DEFER) +			DRM_DEV_ERROR(dev, +				      "Failed to request vdd regulator: %d\n", +				      ret); +		return ret; +	} + +	ctx->iovcc = devm_regulator_get(dev, "iovcc"); +	if (IS_ERR(ctx->iovcc)) { +		ret = PTR_ERR(ctx->iovcc); +		if (ret != -EPROBE_DEFER) +			DRM_DEV_ERROR(dev, +				      "Failed to request iovcc regulator: %d\n", +				      ret); +		return ret; +	} + +	mipi_dsi_set_drvdata(dsi, ctx); + +	ctx->dev = dev; + +	dsi->lanes = 1; +	dsi->format = MIPI_DSI_FMT_RGB888; +	dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST | +			  MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_EOT_PACKET; + +	drm_panel_init(&ctx->panel, &dsi->dev, &kd35t133_funcs, +		       DRM_MODE_CONNECTOR_DSI); + +	ret = drm_panel_of_backlight(&ctx->panel); +	if (ret) +		return ret; + +	drm_panel_add(&ctx->panel); + +	ret = mipi_dsi_attach(dsi); +	if (ret < 0) { +		DRM_DEV_ERROR(dev, "mipi_dsi_attach failed: %d\n", ret); +		drm_panel_remove(&ctx->panel); +		return ret; +	} + +	return 0; +} + +static void kd35t133_shutdown(struct mipi_dsi_device *dsi) +{ +	struct kd35t133 *ctx = mipi_dsi_get_drvdata(dsi); +	int ret; + +	ret = drm_panel_unprepare(&ctx->panel); +	if (ret < 0) +		DRM_DEV_ERROR(&dsi->dev, "Failed to unprepare panel: %d\n", +			      ret); + +	ret = drm_panel_disable(&ctx->panel); +	if (ret < 0) +		DRM_DEV_ERROR(&dsi->dev, "Failed to disable panel: %d\n", +			      ret); +} + +static int kd35t133_remove(struct mipi_dsi_device *dsi) +{ +	struct kd35t133 *ctx = mipi_dsi_get_drvdata(dsi); +	int ret; + +	kd35t133_shutdown(dsi); + +	ret = mipi_dsi_detach(dsi); +	if (ret < 0) +		DRM_DEV_ERROR(&dsi->dev, "Failed to detach from DSI host: %d\n", +			      ret); + +	drm_panel_remove(&ctx->panel); + +	return 0; +} + +static const struct of_device_id kd35t133_of_match[] = { +	{ .compatible = "elida,kd35t133" }, +	{ /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, kd35t133_of_match); + +static struct mipi_dsi_driver kd35t133_driver = { +	.driver = { +		.name = "panel-elida-kd35t133", +		.of_match_table = kd35t133_of_match, +	}, +	.probe	= kd35t133_probe, +	.remove = kd35t133_remove, +	.shutdown = kd35t133_shutdown, +}; +module_mipi_dsi_driver(kd35t133_driver); + +MODULE_AUTHOR("Heiko Stuebner <[email protected]>"); +MODULE_DESCRIPTION("DRM driver for Elida kd35t133 MIPI DSI panel"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/gpu/drm/panel/panel-feixin-k101-im2ba02.c b/drivers/gpu/drm/panel/panel-feixin-k101-im2ba02.c new file mode 100644 index 000000000000..fddbfddf6566 --- /dev/null +++ b/drivers/gpu/drm/panel/panel-feixin-k101-im2ba02.c @@ -0,0 +1,526 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2019-2020 Icenowy Zheng <[email protected]> + */ + +#include <linux/gpio/consumer.h> +#include <linux/delay.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/regulator/consumer.h> + +#include <drm/drm_mipi_dsi.h> +#include <drm/drm_modes.h> +#include <drm/drm_panel.h> +#include <drm/drm_print.h> + +#define K101_IM2BA02_INIT_CMD_LEN	2 + +static const char * const regulator_names[] = { +	"dvdd", +	"avdd", +	"cvdd" +}; + +struct k101_im2ba02 { +	struct drm_panel	panel; +	struct mipi_dsi_device	*dsi; + +	struct regulator_bulk_data supplies[ARRAY_SIZE(regulator_names)]; +	struct gpio_desc	*reset; +}; + +static inline struct k101_im2ba02 *panel_to_k101_im2ba02(struct drm_panel *panel) +{ +	return container_of(panel, struct k101_im2ba02, panel); +} + +struct k101_im2ba02_init_cmd { +	u8 data[K101_IM2BA02_INIT_CMD_LEN]; +}; + +static const struct k101_im2ba02_init_cmd k101_im2ba02_init_cmds[] = { +	/* Switch to page 0 */ +	{ .data = { 0xE0, 0x00 } }, + +	/* Seems to be some password */ +	{ .data = { 0xE1, 0x93} }, +	{ .data = { 0xE2, 0x65 } }, +	{ .data = { 0xE3, 0xF8 } }, + +	/* Lane number, 0x02 - 3 lanes, 0x03 - 4 lanes */ +	{ .data = { 0x80, 0x03 } }, + +	/* Sequence control */ +	{ .data = { 0x70, 0x02 } }, +	{ .data = { 0x71, 0x23 } }, +	{ .data = { 0x72, 0x06 } }, + +	/* Switch to page 1 */ +	{ .data = { 0xE0, 0x01 } }, + +	/* Set VCOM */ +	{ .data = { 0x00, 0x00 } }, +	{ .data = { 0x01, 0x66 } }, +	/* Set VCOM_Reverse */ +	{ .data = { 0x03, 0x00 } }, +	{ .data = { 0x04, 0x25 } }, + +	/* Set Gamma Power, VG[MS][PN] */ +	{ .data = { 0x17, 0x00 } }, +	{ .data = { 0x18, 0x6D } }, +	{ .data = { 0x19, 0x00 } }, +	{ .data = { 0x1A, 0x00 } }, +	{ .data = { 0x1B, 0xBF } }, /* VGMN = -4.5V */ +	{ .data = { 0x1C, 0x00 } }, + +	/* Set Gate Power */ +	{ .data = { 0x1F, 0x3E } }, /* VGH_R = 15V */ +	{ .data = { 0x20, 0x28 } }, /* VGL_R = -11V */ +	{ .data = { 0x21, 0x28 } }, /* VGL_R2 = -11V */ +	{ .data = { 0x22, 0x0E } }, /* PA[6:4] = 0, PA[0] = 0 */ + +	/* Set Panel */ +	{ .data = { 0x37, 0x09 } }, /* SS = 1, BGR = 1 */ + +	/* Set RGBCYC */ +	{ .data = { 0x38, 0x04 } }, /* JDT = 100 column inversion */ +	{ .data = { 0x39, 0x08 } }, /* RGB_N_EQ1 */ +	{ .data = { 0x3A, 0x12 } }, /* RGB_N_EQ2 */ +	{ .data = { 0x3C, 0x78 } }, /* set EQ3 for TE_H */ +	{ .data = { 0x3D, 0xFF } }, /* set CHGEN_ON */ +	{ .data = { 0x3E, 0xFF } }, /* set CHGEN_OFF */ +	{ .data = { 0x3F, 0x7F } }, /* set CHGEN_OFF2 */ + +	/* Set TCON parameter */ +	{ .data = { 0x40, 0x06 } }, /* RSO = 800 points */ +	{ .data = { 0x41, 0xA0 } }, /* LN = 1280 lines */ + +	/* Set power voltage */ +	{ .data = { 0x55, 0x0F } }, /* DCDCM */ +	{ .data = { 0x56, 0x01 } }, +	{ .data = { 0x57, 0x69 } }, +	{ .data = { 0x58, 0x0A } }, +	{ .data = { 0x59, 0x0A } }, +	{ .data = { 0x5A, 0x45 } }, +	{ .data = { 0x5B, 0x15 } }, + +	/* Set gamma */ +	{ .data = { 0x5D, 0x7C } }, +	{ .data = { 0x5E, 0x65 } }, +	{ .data = { 0x5F, 0x55 } }, +	{ .data = { 0x60, 0x49 } }, +	{ .data = { 0x61, 0x44 } }, +	{ .data = { 0x62, 0x35 } }, +	{ .data = { 0x63, 0x3A } }, +	{ .data = { 0x64, 0x23 } }, +	{ .data = { 0x65, 0x3D } }, +	{ .data = { 0x66, 0x3C } }, +	{ .data = { 0x67, 0x3D } }, +	{ .data = { 0x68, 0x5D } }, +	{ .data = { 0x69, 0x4D } }, +	{ .data = { 0x6A, 0x56 } }, +	{ .data = { 0x6B, 0x48 } }, +	{ .data = { 0x6C, 0x45 } }, +	{ .data = { 0x6D, 0x38 } }, +	{ .data = { 0x6E, 0x25 } }, +	{ .data = { 0x6F, 0x00 } }, +	{ .data = { 0x70, 0x7C } }, +	{ .data = { 0x71, 0x65 } }, +	{ .data = { 0x72, 0x55 } }, +	{ .data = { 0x73, 0x49 } }, +	{ .data = { 0x74, 0x44 } }, +	{ .data = { 0x75, 0x35 } }, +	{ .data = { 0x76, 0x3A } }, +	{ .data = { 0x77, 0x23 } }, +	{ .data = { 0x78, 0x3D } }, +	{ .data = { 0x79, 0x3C } }, +	{ .data = { 0x7A, 0x3D } }, +	{ .data = { 0x7B, 0x5D } }, +	{ .data = { 0x7C, 0x4D } }, +	{ .data = { 0x7D, 0x56 } }, +	{ .data = { 0x7E, 0x48 } }, +	{ .data = { 0x7F, 0x45 } }, +	{ .data = { 0x80, 0x38 } }, +	{ .data = { 0x81, 0x25 } }, +	{ .data = { 0x82, 0x00 } }, + +	/* Switch to page 2, for GIP */ +	{ .data = { 0xE0, 0x02 } }, + +	{ .data = { 0x00, 0x1E } }, +	{ .data = { 0x01, 0x1E } }, +	{ .data = { 0x02, 0x41 } }, +	{ .data = { 0x03, 0x41 } }, +	{ .data = { 0x04, 0x43 } }, +	{ .data = { 0x05, 0x43 } }, +	{ .data = { 0x06, 0x1F } }, +	{ .data = { 0x07, 0x1F } }, +	{ .data = { 0x08, 0x1F } }, +	{ .data = { 0x09, 0x1F } }, +	{ .data = { 0x0A, 0x1E } }, +	{ .data = { 0x0B, 0x1E } }, +	{ .data = { 0x0C, 0x1F } }, +	{ .data = { 0x0D, 0x47 } }, +	{ .data = { 0x0E, 0x47 } }, +	{ .data = { 0x0F, 0x45 } }, +	{ .data = { 0x10, 0x45 } }, +	{ .data = { 0x11, 0x4B } }, +	{ .data = { 0x12, 0x4B } }, +	{ .data = { 0x13, 0x49 } }, +	{ .data = { 0x14, 0x49 } }, +	{ .data = { 0x15, 0x1F } }, + +	{ .data = { 0x16, 0x1E } }, +	{ .data = { 0x17, 0x1E } }, +	{ .data = { 0x18, 0x40 } }, +	{ .data = { 0x19, 0x40 } }, +	{ .data = { 0x1A, 0x42 } }, +	{ .data = { 0x1B, 0x42 } }, +	{ .data = { 0x1C, 0x1F } }, +	{ .data = { 0x1D, 0x1F } }, +	{ .data = { 0x1E, 0x1F } }, +	{ .data = { 0x1F, 0x1f } }, +	{ .data = { 0x20, 0x1E } }, +	{ .data = { 0x21, 0x1E } }, +	{ .data = { 0x22, 0x1f } }, +	{ .data = { 0x23, 0x46 } }, +	{ .data = { 0x24, 0x46 } }, +	{ .data = { 0x25, 0x44 } }, +	{ .data = { 0x26, 0x44 } }, +	{ .data = { 0x27, 0x4A } }, +	{ .data = { 0x28, 0x4A } }, +	{ .data = { 0x29, 0x48 } }, +	{ .data = { 0x2A, 0x48 } }, +	{ .data = { 0x2B, 0x1f } }, + +	{ .data = { 0x2C, 0x1F } }, +	{ .data = { 0x2D, 0x1F } }, +	{ .data = { 0x2E, 0x42 } }, +	{ .data = { 0x2F, 0x42 } }, +	{ .data = { 0x30, 0x40 } }, +	{ .data = { 0x31, 0x40 } }, +	{ .data = { 0x32, 0x1E } }, +	{ .data = { 0x33, 0x1E } }, +	{ .data = { 0x34, 0x1F } }, +	{ .data = { 0x35, 0x1F } }, +	{ .data = { 0x36, 0x1E } }, +	{ .data = { 0x37, 0x1E } }, +	{ .data = { 0x38, 0x1F } }, +	{ .data = { 0x39, 0x48 } }, +	{ .data = { 0x3A, 0x48 } }, +	{ .data = { 0x3B, 0x4A } }, +	{ .data = { 0x3C, 0x4A } }, +	{ .data = { 0x3D, 0x44 } }, +	{ .data = { 0x3E, 0x44 } }, +	{ .data = { 0x3F, 0x46 } }, +	{ .data = { 0x40, 0x46 } }, +	{ .data = { 0x41, 0x1F } }, + +	{ .data = { 0x42, 0x1F } }, +	{ .data = { 0x43, 0x1F } }, +	{ .data = { 0x44, 0x43 } }, +	{ .data = { 0x45, 0x43 } }, +	{ .data = { 0x46, 0x41 } }, +	{ .data = { 0x47, 0x41 } }, +	{ .data = { 0x48, 0x1E } }, +	{ .data = { 0x49, 0x1E } }, +	{ .data = { 0x4A, 0x1E } }, +	{ .data = { 0x4B, 0x1F } }, +	{ .data = { 0x4C, 0x1E } }, +	{ .data = { 0x4D, 0x1E } }, +	{ .data = { 0x4E, 0x1F } }, +	{ .data = { 0x4F, 0x49 } }, +	{ .data = { 0x50, 0x49 } }, +	{ .data = { 0x51, 0x4B } }, +	{ .data = { 0x52, 0x4B } }, +	{ .data = { 0x53, 0x45 } }, +	{ .data = { 0x54, 0x45 } }, +	{ .data = { 0x55, 0x47 } }, +	{ .data = { 0x56, 0x47 } }, +	{ .data = { 0x57, 0x1F } }, + +	{ .data = { 0x58, 0x10 } }, +	{ .data = { 0x59, 0x00 } }, +	{ .data = { 0x5A, 0x00 } }, +	{ .data = { 0x5B, 0x30 } }, +	{ .data = { 0x5C, 0x02 } }, +	{ .data = { 0x5D, 0x40 } }, +	{ .data = { 0x5E, 0x01 } }, +	{ .data = { 0x5F, 0x02 } }, +	{ .data = { 0x60, 0x30 } }, +	{ .data = { 0x61, 0x01 } }, +	{ .data = { 0x62, 0x02 } }, +	{ .data = { 0x63, 0x6A } }, +	{ .data = { 0x64, 0x6A } }, +	{ .data = { 0x65, 0x05 } }, +	{ .data = { 0x66, 0x12 } }, +	{ .data = { 0x67, 0x74 } }, +	{ .data = { 0x68, 0x04 } }, +	{ .data = { 0x69, 0x6A } }, +	{ .data = { 0x6A, 0x6A } }, +	{ .data = { 0x6B, 0x08 } }, + +	{ .data = { 0x6C, 0x00 } }, +	{ .data = { 0x6D, 0x04 } }, +	{ .data = { 0x6E, 0x04 } }, +	{ .data = { 0x6F, 0x88 } }, +	{ .data = { 0x70, 0x00 } }, +	{ .data = { 0x71, 0x00 } }, +	{ .data = { 0x72, 0x06 } }, +	{ .data = { 0x73, 0x7B } }, +	{ .data = { 0x74, 0x00 } }, +	{ .data = { 0x75, 0x07 } }, +	{ .data = { 0x76, 0x00 } }, +	{ .data = { 0x77, 0x5D } }, +	{ .data = { 0x78, 0x17 } }, +	{ .data = { 0x79, 0x1F } }, +	{ .data = { 0x7A, 0x00 } }, +	{ .data = { 0x7B, 0x00 } }, +	{ .data = { 0x7C, 0x00 } }, +	{ .data = { 0x7D, 0x03 } }, +	{ .data = { 0x7E, 0x7B } }, + +	{ .data = { 0xE0, 0x04 } }, +	{ .data = { 0x2B, 0x2B } }, +	{ .data = { 0x2E, 0x44 } }, + +	{ .data = { 0xE0, 0x01 } }, +	{ .data = { 0x0E, 0x01 } }, + +	{ .data = { 0xE0, 0x03 } }, +	{ .data = { 0x98, 0x2F } }, + +	{ .data = { 0xE0, 0x00 } }, +	{ .data = { 0xE6, 0x02 } }, +	{ .data = { 0xE7, 0x02 } }, + +	{ .data = { 0x11, 0x00 } }, +}; + +static const struct k101_im2ba02_init_cmd timed_cmds[] = { +	{ .data = { 0x29, 0x00 } }, +	{ .data = { 0x35, 0x00 } }, +}; + +static int k101_im2ba02_prepare(struct drm_panel *panel) +{ +	struct k101_im2ba02 *ctx = panel_to_k101_im2ba02(panel); +	struct mipi_dsi_device *dsi = ctx->dsi; +	unsigned int i; +	int ret; + +	ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); +	if (ret) +		return ret; + +	msleep(30); + +	gpiod_set_value(ctx->reset, 1); +	msleep(50); + +	gpiod_set_value(ctx->reset, 0); +	msleep(50); + +	gpiod_set_value(ctx->reset, 1); +	msleep(200); + +	for (i = 0; i < ARRAY_SIZE(k101_im2ba02_init_cmds); i++) { +		const struct k101_im2ba02_init_cmd *cmd = &k101_im2ba02_init_cmds[i]; + +		ret = mipi_dsi_dcs_write_buffer(dsi, cmd->data, K101_IM2BA02_INIT_CMD_LEN); +		if (ret < 0) +			goto powerdown; +	} + +	return 0; + +powerdown: +	gpiod_set_value(ctx->reset, 0); +	msleep(50); + +	return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); +} + +static int k101_im2ba02_enable(struct drm_panel *panel) +{ +	struct k101_im2ba02 *ctx = panel_to_k101_im2ba02(panel); +	const struct k101_im2ba02_init_cmd *cmd = &timed_cmds[1]; +	int ret; + +	msleep(150); + +	ret = mipi_dsi_dcs_set_display_on(ctx->dsi); +	if (ret < 0) +		return ret; + +	msleep(50); + +	return mipi_dsi_dcs_write_buffer(ctx->dsi, cmd->data, K101_IM2BA02_INIT_CMD_LEN); +} + +static int k101_im2ba02_disable(struct drm_panel *panel) +{ +	struct k101_im2ba02 *ctx = panel_to_k101_im2ba02(panel); + +	return mipi_dsi_dcs_set_display_off(ctx->dsi); +} + +static int k101_im2ba02_unprepare(struct drm_panel *panel) +{ +	struct k101_im2ba02 *ctx = panel_to_k101_im2ba02(panel); +	int ret; + +	ret = mipi_dsi_dcs_set_display_off(ctx->dsi); +	if (ret < 0) +		DRM_DEV_ERROR(panel->dev, "failed to set display off: %d\n", +			      ret); + +	ret = mipi_dsi_dcs_enter_sleep_mode(ctx->dsi); +	if (ret < 0) +		DRM_DEV_ERROR(panel->dev, "failed to enter sleep mode: %d\n", +			      ret); + +	msleep(200); + +	gpiod_set_value(ctx->reset, 0); +	msleep(20); + +	return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); +} + +static const struct drm_display_mode k101_im2ba02_default_mode = { +	.clock = 70000, +	.vrefresh = 60, + +	.hdisplay = 800, +	.hsync_start = 800 + 20, +	.hsync_end = 800 + 20 + 20, +	.htotal = 800 + 20 + 20 + 20, + +	.vdisplay = 1280, +	.vsync_start = 1280 + 16, +	.vsync_end = 1280 + 16 + 4, +	.vtotal = 1280 + 16 + 4 + 4, + +	.type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED, +	.width_mm	= 136, +	.height_mm	= 217, +}; + +static int k101_im2ba02_get_modes(struct drm_panel *panel, +				  struct drm_connector *connector) +{ +	struct k101_im2ba02 *ctx = panel_to_k101_im2ba02(panel); +	struct drm_display_mode *mode; + +	mode = drm_mode_duplicate(connector->dev, &k101_im2ba02_default_mode); +	if (!mode) { +		DRM_DEV_ERROR(&ctx->dsi->dev, "failed to add mode %ux%ux@%u\n", +			      k101_im2ba02_default_mode.hdisplay, +			      k101_im2ba02_default_mode.vdisplay, +			      k101_im2ba02_default_mode.vrefresh); +		return -ENOMEM; +	} + +	drm_mode_set_name(mode); + +	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; +	connector->display_info.width_mm = mode->width_mm; +	connector->display_info.height_mm = mode->height_mm; +	drm_mode_probed_add(connector, mode); + +	return 1; +} + +static const struct drm_panel_funcs k101_im2ba02_funcs = { +	.disable = k101_im2ba02_disable, +	.unprepare = k101_im2ba02_unprepare, +	.prepare = k101_im2ba02_prepare, +	.enable = k101_im2ba02_enable, +	.get_modes = k101_im2ba02_get_modes, +}; + +static int k101_im2ba02_dsi_probe(struct mipi_dsi_device *dsi) +{ +	struct k101_im2ba02 *ctx; +	unsigned int i; +	int ret; + +	ctx = devm_kzalloc(&dsi->dev, sizeof(*ctx), GFP_KERNEL); +	if (!ctx) +		return -ENOMEM; + +	mipi_dsi_set_drvdata(dsi, ctx); +	ctx->dsi = dsi; + +	for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) +		ctx->supplies[i].supply = regulator_names[i]; + +	ret = devm_regulator_bulk_get(&dsi->dev, ARRAY_SIZE(ctx->supplies), +				      ctx->supplies); +	if (ret < 0) { +		DRM_DEV_ERROR(&dsi->dev, "Couldn't get regulators\n"); +		return ret; +	} + +	ctx->reset = devm_gpiod_get(&dsi->dev, "reset", GPIOD_OUT_LOW); +	if (IS_ERR(ctx->reset)) { +		DRM_DEV_ERROR(&dsi->dev, "Couldn't get our reset GPIO\n"); +		return PTR_ERR(ctx->reset); +	} + +	drm_panel_init(&ctx->panel, &dsi->dev, &k101_im2ba02_funcs, +		       DRM_MODE_CONNECTOR_DSI); + +	ret = drm_panel_of_backlight(&ctx->panel); +	if (ret) +		return ret; + +	ret = drm_panel_add(&ctx->panel); +	if (ret < 0) +		return ret; + +	dsi->mode_flags = MIPI_DSI_MODE_VIDEO; +	dsi->format = MIPI_DSI_FMT_RGB888; +	dsi->lanes = 4; + +	ret = mipi_dsi_attach(dsi); +	if (ret < 0) { +		drm_panel_remove(&ctx->panel); +		return ret; +	} + +	return 0; +} + +static int k101_im2ba02_dsi_remove(struct mipi_dsi_device *dsi) +{ +	struct k101_im2ba02 *ctx = mipi_dsi_get_drvdata(dsi); + +	mipi_dsi_detach(dsi); +	drm_panel_remove(&ctx->panel); + +	return 0; +} + +static const struct of_device_id k101_im2ba02_of_match[] = { +	{ .compatible = "feixin,k101-im2ba02", }, +	{ /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, k101_im2ba02_of_match); + +static struct mipi_dsi_driver k101_im2ba02_driver = { +	.probe = k101_im2ba02_dsi_probe, +	.remove = k101_im2ba02_dsi_remove, +	.driver = { +		.name = "feixin-k101-im2ba02", +		.of_match_table = k101_im2ba02_of_match, +	}, +}; +module_mipi_dsi_driver(k101_im2ba02_driver); + +MODULE_AUTHOR("Icenowy Zheng <[email protected]>"); +MODULE_DESCRIPTION("Feixin K101 IM2BA02 MIPI-DSI LCD panel"); +MODULE_LICENSE("GPL"); diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9322.c b/drivers/gpu/drm/panel/panel-ilitek-ili9322.c index f394d53a7da4..09935520e606 100644 --- a/drivers/gpu/drm/panel/panel-ilitek-ili9322.c +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9322.c @@ -540,7 +540,7 @@ static int ili9322_enable(struct drm_panel *panel)  /* Serial RGB modes */  static const struct drm_display_mode srgb_320x240_mode = { -	.clock = 2453500, +	.clock = 24535,  	.hdisplay = 320,  	.hsync_start = 320 + 359,  	.hsync_end = 320 + 359 + 1, @@ -554,7 +554,7 @@ static const struct drm_display_mode srgb_320x240_mode = {  };  static const struct drm_display_mode srgb_360x240_mode = { -	.clock = 2700000, +	.clock = 27000,  	.hdisplay = 360,  	.hsync_start = 360 + 35,  	.hsync_end = 360 + 35 + 1, @@ -569,7 +569,7 @@ static const struct drm_display_mode srgb_360x240_mode = {  /* This is the only mode listed for parallel RGB in the datasheet */  static const struct drm_display_mode prgb_320x240_mode = { -	.clock = 6400000, +	.clock = 64000,  	.hdisplay = 320,  	.hsync_start = 320 + 38,  	.hsync_end = 320 + 38 + 1, @@ -584,7 +584,7 @@ static const struct drm_display_mode prgb_320x240_mode = {  /* YUV modes */  static const struct drm_display_mode yuv_640x320_mode = { -	.clock = 2454000, +	.clock = 24540,  	.hdisplay = 640,  	.hsync_start = 640 + 252,  	.hsync_end = 640 + 252 + 1, @@ -598,7 +598,7 @@ static const struct drm_display_mode yuv_640x320_mode = {  };  static const struct drm_display_mode yuv_720x360_mode = { -	.clock = 2700000, +	.clock = 27000,  	.hdisplay = 720,  	.hsync_start = 720 + 252,  	.hsync_end = 720 + 252 + 1, @@ -613,7 +613,7 @@ static const struct drm_display_mode yuv_720x360_mode = {  /* BT.656 VGA mode, 640x480 */  static const struct drm_display_mode itu_r_bt_656_640_mode = { -	.clock = 2454000, +	.clock = 24540,  	.hdisplay = 640,  	.hsync_start = 640 + 3,  	.hsync_end = 640 + 3 + 1, @@ -628,7 +628,7 @@ static const struct drm_display_mode itu_r_bt_656_640_mode = {  /* BT.656 D1 mode 720x480 */  static const struct drm_display_mode itu_r_bt_656_720_mode = { -	.clock = 2700000, +	.clock = 27000,  	.hdisplay = 720,  	.hsync_start = 720 + 3,  	.hsync_end = 720 + 3 + 1, diff --git a/drivers/gpu/drm/panel/panel-lg-lg4573.c b/drivers/gpu/drm/panel/panel-lg-lg4573.c index b262b53dbd85..5907f2503755 100644 --- a/drivers/gpu/drm/panel/panel-lg-lg4573.c +++ b/drivers/gpu/drm/panel/panel-lg-lg4573.c @@ -197,7 +197,7 @@ static int lg4573_enable(struct drm_panel *panel)  }  static const struct drm_display_mode default_mode = { -	.clock = 27000, +	.clock = 28341,  	.hdisplay = 480,  	.hsync_start = 480 + 10,  	.hsync_end = 480 + 10 + 59, diff --git a/drivers/gpu/drm/panel/panel-novatek-nt35510.c b/drivers/gpu/drm/panel/panel-novatek-nt35510.c new file mode 100644 index 000000000000..4a8fa908a2cf --- /dev/null +++ b/drivers/gpu/drm/panel/panel-novatek-nt35510.c @@ -0,0 +1,1098 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Novatek NT35510 panel driver + * Copyright (C) 2020 Linus Walleij <[email protected]> + * Based on code by Robert Teather (C) 2012 Samsung + * + * This display driver (and I refer to the physical component NT35510, + * not this Linux kernel software driver) can handle: + * 480x864, 480x854, 480x800, 480x720 and 480x640 pixel displays. + * It has 480x840x24bit SRAM embedded for storing a frame. + * When powered on the display is by default in 480x800 mode. + * + * The actual panels using this component have different names, but + * the code needed to set up and configure the panel will be similar, + * so they should all use the NT35510 driver with appropriate configuration + * per-panel, e.g. for physical size. + * + * This driver is for the DSI interface to panels using the NT35510. + * + * The NT35510 can also use an RGB (DPI) interface combined with an + * I2C or SPI interface for setting up the NT35510. If this is needed + * this panel driver should be refactored to also support that use + * case. + */ +#include <linux/backlight.h> +#include <linux/bitops.h> +#include <linux/gpio/consumer.h> +#include <linux/module.h> +#include <linux/of_device.h> +#include <linux/regmap.h> +#include <linux/regulator/consumer.h> + +#include <video/mipi_display.h> + +#include <drm/drm_mipi_dsi.h> +#include <drm/drm_modes.h> +#include <drm/drm_panel.h> +#include <drm/drm_print.h> + +#define MCS_CMD_MAUCCTR		0xF0 /* Manufacturer command enable */ +#define MCS_CMD_READ_ID1	0xDA +#define MCS_CMD_READ_ID2	0xDB +#define MCS_CMD_READ_ID3	0xDC +#define MCS_CMD_MTP_READ_SETTING 0xF8 /* Uncertain about name */ +#define MCS_CMD_MTP_READ_PARAM 0xFF /* Uncertain about name */ + +/* + * These manufacturer commands are available after we enable manufacturer + * command set (MCS) for page 0. + */ +#define NT35510_P0_DOPCTR 0xB1 +#define NT35510_P0_SDHDTCTR 0xB6 +#define NT35510_P0_GSEQCTR 0xB7 +#define NT35510_P0_SDEQCTR 0xB8 +#define NT35510_P0_SDVPCTR 0xBA +#define NT35510_P0_DPFRCTR1 0xBD +#define NT35510_P0_DPFRCTR2 0xBE +#define NT35510_P0_DPFRCTR3 0xBF +#define NT35510_P0_DPMCTR12 0xCC + +#define NT35510_P0_DOPCTR_LEN 2 +#define NT35510_P0_GSEQCTR_LEN 2 +#define NT35510_P0_SDEQCTR_LEN 4 +#define NT35510_P0_SDVPCTR_LEN 1 +#define NT35510_P0_DPFRCTR1_LEN 5 +#define NT35510_P0_DPFRCTR2_LEN 5 +#define NT35510_P0_DPFRCTR3_LEN 5 +#define NT35510_P0_DPMCTR12_LEN 3 + +#define NT35510_DOPCTR_0_RAMKP BIT(7) /* Contents kept in sleep */ +#define NT35510_DOPCTR_0_DSITE BIT(6) /* Enable TE signal */ +#define NT35510_DOPCTR_0_DSIG BIT(5) /* Enable generic read/write */ +#define NT35510_DOPCTR_0_DSIM BIT(4) /* Enable video mode on DSI */ +#define NT35510_DOPCTR_0_EOTP BIT(3) /* Support EoTP */ +#define NT35510_DOPCTR_0_N565 BIT(2) /* RGB or BGR pixel format */ +#define NT35510_DOPCTR_1_TW_PWR_SEL BIT(4) /* TE power selector */ +#define NT35510_DOPCTR_1_CRGB BIT(3) /* RGB or BGR byte order */ +#define NT35510_DOPCTR_1_CTB BIT(2) /* Vertical scanning direction */ +#define NT35510_DOPCTR_1_CRL BIT(1) /* Source driver data shift */ +#define NT35510_P0_SDVPCTR_PRG BIT(2) /* 0 = normal operation, 1 = VGLO */ +#define NT35510_P0_SDVPCTR_AVDD 0 /* source driver output = AVDD */ +#define NT35510_P0_SDVPCTR_OFFCOL 1 /* source driver output = off color */ +#define NT35510_P0_SDVPCTR_AVSS 2 /* source driver output = AVSS */ +#define NT35510_P0_SDVPCTR_HI_Z 3 /* source driver output = High impedance */ + +/* + * These manufacturer commands are available after we enable manufacturer + * command set (MCS) for page 1. + */ +#define NT35510_P1_SETAVDD 0xB0 +#define NT35510_P1_SETAVEE 0xB1 +#define NT35510_P1_SETVCL 0xB2 +#define NT35510_P1_SETVGH 0xB3 +#define NT35510_P1_SETVRGH 0xB4 +#define NT35510_P1_SETVGL 0xB5 +#define NT35510_P1_BT1CTR 0xB6 +#define NT35510_P1_BT2CTR 0xB7 +#define NT35510_P1_BT3CTR 0xB8 +#define NT35510_P1_BT4CTR 0xB9 /* VGH boosting times/freq */ +#define NT35510_P1_BT5CTR 0xBA +#define NT35510_P1_PFMCTR 0xBB +#define NT35510_P1_SETVGP 0xBC +#define NT35510_P1_SETVGN 0xBD +#define NT35510_P1_SETVCMOFF 0xBE +#define NT35510_P1_VGHCTR 0xBF /* VGH output ctrl */ +#define NT35510_P1_SET_GAMMA_RED_POS 0xD1 +#define NT35510_P1_SET_GAMMA_GREEN_POS 0xD2 +#define NT35510_P1_SET_GAMMA_BLUE_POS 0xD3 +#define NT35510_P1_SET_GAMMA_RED_NEG 0xD4 +#define NT35510_P1_SET_GAMMA_GREEN_NEG 0xD5 +#define NT35510_P1_SET_GAMMA_BLUE_NEG 0xD6 + +/* AVDD and AVEE setting 3 bytes */ +#define NT35510_P1_AVDD_LEN 3 +#define NT35510_P1_AVEE_LEN 3 +#define NT35510_P1_VGH_LEN 3 +#define NT35510_P1_VGL_LEN 3 +#define NT35510_P1_VGP_LEN 3 +#define NT35510_P1_VGN_LEN 3 +/* BT1CTR thru BT5CTR setting 3 bytes */ +#define NT35510_P1_BT1CTR_LEN 3 +#define NT35510_P1_BT2CTR_LEN 3 +#define NT35510_P1_BT4CTR_LEN 3 +#define NT35510_P1_BT5CTR_LEN 3 +/* 52 gamma parameters times two per color: positive and negative */ +#define NT35510_P1_GAMMA_LEN 52 + +/** + * struct nt35510_config - the display-specific NT35510 configuration + * + * Some of the settings provide an array of bytes, A, B C which mean: + * A = normal / idle off mode + * B = idle on mode + * C = partial / idle off mode + * + * Gamma correction arrays are 10bit numbers, two consecutive bytes + * makes out one point on the gamma correction curve. The points are + * not linearly placed along the X axis, we get points 0, 1, 3, 5 + * 7, 11, 15, 23, 31, 47, 63, 95, 127, 128, 160, 192, 208, 224, 232, + * 240, 244, 248, 250, 252, 254, 255. The voltages tuples form + * V0, V1, V3 ... V255, with 0x0000 being the lowest voltage and + * 0x03FF being the highest voltage. + * + * Each value must be strictly higher than the previous value forming + * a rising curve like this: + * + * ^ + * |                                        V255 + * |                                 V254 + * |                         .... + * |                    V5 + * |           V3 + * |     V1 + * | V0 + * +-------------------------------------------> + * + * The details about all settings can be found in the NT35510 Application + * Note. + */ +struct nt35510_config { +	/** +	 * @width_mm: physical panel width [mm] +	 */ +	u32 width_mm; +	/** +	 * @height_mm: physical panel height [mm] +	 */ +	u32 height_mm; +	/** +	 * @mode: the display mode. This is only relevant outside the panel +	 * in video mode: in command mode this is configuring the internal +	 * timing in the display controller. +	 */ +	const struct drm_display_mode mode; +	/** +	 * @avdd: setting for AVDD ranging from 0x00 = 6.5V to 0x14 = 4.5V +	 * in 0.1V steps the default is 0x05 which means 6.0V +	 */ +	u8 avdd[NT35510_P1_AVDD_LEN]; +	/** +	 * @bt1ctr: setting for boost power control for the AVDD step-up +	 * circuit (1) +	 * bits 0..2 in the lower nibble controls PCK, the booster clock +	 * frequency for the step-up circuit: +	 * 0 = Hsync/32 +	 * 1 = Hsync/16 +	 * 2 = Hsync/8 +	 * 3 = Hsync/4 +	 * 4 = Hsync/2 +	 * 5 = Hsync +	 * 6 = Hsync x 2 +	 * 7 = Hsync x 4 +	 * bits 4..6 in the upper nibble controls BTP, the boosting +	 * amplification for the the step-up circuit: +	 * 0 = Disable +	 * 1 = 1.5 x VDDB +	 * 2 = 1.66 x VDDB +	 * 3 = 2 x VDDB +	 * 4 = 2.5 x VDDB +	 * 5 = 3 x VDDB +	 * The defaults are 4 and 4 yielding 0x44 +	 */ +	u8 bt1ctr[NT35510_P1_BT1CTR_LEN]; +	/** +	 * @avee: setting for AVEE ranging from 0x00 = -6.5V to 0x14 = -4.5V +	 * in 0.1V steps the default is 0x05 which means -6.0V +	 */ +	u8 avee[NT35510_P1_AVEE_LEN]; +	/** +	 * @bt2ctr: setting for boost power control for the AVEE step-up +	 * circuit (2) +	 * bits 0..2 in the lower nibble controls NCK, the booster clock +	 * frequency, the values are the same as for PCK in @bt1ctr. +	 * bits 4..5 in the upper nibble controls BTN, the boosting +	 * amplification for the the step-up circuit. +	 * 0 = Disable +	 * 1 = -1.5 x VDDB +	 * 2 = -2 x VDDB +	 * 3 = -2.5 x VDDB +	 * 4 = -3 x VDDB +	 * The defaults are 4 and 3 yielding 0x34 +	 */ +	u8 bt2ctr[NT35510_P1_BT2CTR_LEN]; +	/** +	 * @vgh: setting for VGH ranging from 0x00 = 7.0V to 0x0B = 18.0V +	 * in 1V steps, the default is 0x08 which means 15V +	 */ +	u8 vgh[NT35510_P1_VGH_LEN]; +	/** +	 * @bt4ctr: setting for boost power control for the VGH step-up +	 * circuit (4) +	 * bits 0..2 in the lower nibble controls HCK, the booster clock +	 * frequency, the values are the same as for PCK in @bt1ctr. +	 * bits 4..5 in the upper nibble controls BTH, the boosting +	 * amplification for the the step-up circuit. +	 * 0 = AVDD + VDDB +	 * 1 = AVDD - AVEE +	 * 2 = AVDD - AVEE + VDDB +	 * 3 = AVDD x 2 - AVEE +	 * The defaults are 4 and 3 yielding 0x34 +	 */ +	u8 bt4ctr[NT35510_P1_BT4CTR_LEN]; +	/** +	 * @vgl: setting for VGL ranging from 0x00 = -2V to 0x0f = -15V in +	 * 1V steps, the default is 0x08 which means -10V +	 */ +	u8 vgl[NT35510_P1_VGL_LEN]; +	/** +	 * @bt5ctr: setting for boost power control for the VGL step-up +	 * circuit (5) +	 * bits 0..2 in the lower nibble controls LCK, the booster clock +	 * frequency, the values are the same as for PCK in @bt1ctr. +	 * bits 4..5 in the upper nibble controls BTL, the boosting +	 * amplification for the the step-up circuit. +	 * 0 = AVEE + VCL +	 * 1 = AVEE - AVDD +	 * 2 = AVEE + VCL - AVDD +	 * 3 = AVEE x 2 - AVDD +	 * The defaults are 3 and 2 yielding 0x32 +	 */ +	u8 bt5ctr[NT35510_P1_BT5CTR_LEN]; +	/** +	 * @vgp: setting for VGP, the positive gamma divider voltages +	 * VGMP the high voltage and VGSP the low voltage. +	 * The first byte contains bit 8 of VGMP and VGSP in bits 4 and 0 +	 * The second byte contains bit 0..7 of VGMP +	 * The third byte contains bit 0..7 of VGSP +	 * VGMP 0x00 = 3.0V .. 0x108 = 6.3V in steps of 12.5mV +	 * VGSP 0x00 = 0V .. 0x111 = 3.7V in steps of 12.5mV +	 */ +	u8 vgp[NT35510_P1_VGP_LEN]; +	/** +	 * @vgn: setting for VGN, the negative gamma divider voltages, +	 * same layout of bytes as @vgp. +	 */ +	u8 vgn[NT35510_P1_VGN_LEN]; +	/** +	 * @sdeqctr: Source driver control settings, first byte is +	 * 0 for mode 1 and 1 for mode 2. Mode 1 uses two steps and +	 * mode 2 uses three steps meaning EQS3 is not used in mode +	 * 1. Mode 2 is default. The last three parameters are EQS1, EQS2 +	 * and EQS3, setting the rise time for each equalizer step: +	 * 0x00 = 0.0 us to 0x0f = 7.5 us in steps of 0.5us. The default +	 * is 0x07 = 3.5 us. +	 */ +	u8 sdeqctr[NT35510_P0_SDEQCTR_LEN]; +	/** +	 * @sdvpctr: power/voltage behaviour during vertical porch time +	 */ +	u8 sdvpctr; +	/** +	 * @t1: the number of pixel clocks on one scanline, range +	 * 0x100 (258 ticks) .. 0x3FF (1024 ticks) so the value + 1 +	 * clock ticks. +	 */ +	u16 t1; +	/** +	 * @vbp: vertical back porch toward the PANEL note: not toward +	 * the DSI host; these are separate interfaces, in from DSI host +	 * and out to the panel. +	 */ +	u8 vbp; +	/** +	 * @vfp: vertical front porch toward the PANEL. +	 */ +	u8 vfp; +	/** +	 * @psel: pixel clock divisor: 0 = 1, 1 = 2, 2 = 4, 3 = 8. +	 */ +	u8 psel; +	/** +	 * @dpmctr12: Display timing control 12 +	 * Byte 1 bit 4 selects LVGL voltage level: 0 = VGLX, 1 = VGL_REG +	 * Byte 1 bit 1 selects gate signal mode: 0 = non-overlap, 1 = overlap +	 * Byte 1 bit 0 selects output signal control R/L swap, 0 = normal +	 * 1 = swap all O->E, L->R +	 * Byte 2 is CLW delay clock for CK O/E and CKB O/E signals: +	 * 0x00 = 0us .. 0xFF = 12.75us in 0.05us steps +	 * Byte 3 is FTI_H0 delay time for STP O/E signals: +	 * 0x00 = 0us .. 0xFF = 12.75us in 0.05us steps +	 */ +	u8 dpmctr12[NT35510_P0_DPMCTR12_LEN]; +	/** +	 * @gamma_corr_pos_r: Red gamma correction parameters, positive +	 */ +	u8 gamma_corr_pos_r[NT35510_P1_GAMMA_LEN]; +	/** +	 * @gamma_corr_pos_g: Green gamma correction parameters, positive +	 */ +	u8 gamma_corr_pos_g[NT35510_P1_GAMMA_LEN]; +	/** +	 * @gamma_corr_pos_b: Blue gamma correction parameters, positive +	 */ +	u8 gamma_corr_pos_b[NT35510_P1_GAMMA_LEN]; +	/** +	 * @gamma_corr_neg_r: Red gamma correction parameters, negative +	 */ +	u8 gamma_corr_neg_r[NT35510_P1_GAMMA_LEN]; +	/** +	 * @gamma_corr_neg_g: Green gamma correction parameters, negative +	 */ +	u8 gamma_corr_neg_g[NT35510_P1_GAMMA_LEN]; +	/** +	 * @gamma_corr_neg_b: Blue gamma correction parameters, negative +	 */ +	u8 gamma_corr_neg_b[NT35510_P1_GAMMA_LEN]; +}; + +/** + * struct nt35510 - state container for the NT35510 panel + */ +struct nt35510 { +	/** +	 * @dev: the container device +	 */ +	struct device *dev; +	/** +	 * @conf: the specific panel configuration, as the NT35510 +	 * can be combined with many physical panels, they can have +	 * different physical dimensions and gamma correction etc, +	 * so this is stored in the config. +	 */ +	const struct nt35510_config *conf; +	/** +	 * @panel: the DRM panel object for the instance +	 */ +	struct drm_panel panel; +	/** +	 * @supplies: regulators supplying the panel +	 */ +	struct regulator_bulk_data supplies[2]; +	/** +	 * @reset_gpio: the reset line +	 */ +	struct gpio_desc *reset_gpio; +}; + +/* Manufacturer command has strictly this byte sequence */ +static const u8 nt35510_mauc_select_page_0[] = { 0x55, 0xAA, 0x52, 0x08, 0x00 }; +static const u8 nt35510_mauc_select_page_1[] = { 0x55, 0xAA, 0x52, 0x08, 0x01 }; +static const u8 nt35510_vgh_on[] = { 0x01 }; + +static inline struct nt35510 *panel_to_nt35510(struct drm_panel *panel) +{ +	return container_of(panel, struct nt35510, panel); +} + +#define NT35510_ROTATE_0_SETTING	0x02 +#define NT35510_ROTATE_180_SETTING	0x00 + +static int nt35510_send_long(struct nt35510 *nt, struct mipi_dsi_device *dsi, +			     u8 cmd, u8 cmdlen, const u8 *seq) +{ +	const u8 *seqp = seq; +	int cmdwritten = 0; +	int chunk = cmdlen; +	int ret; + +	if (chunk > 15) +		chunk = 15; +	ret = mipi_dsi_dcs_write(dsi, cmd, seqp, chunk); +	if (ret < 0) { +		DRM_DEV_ERROR(nt->dev, +			      "error sending DCS command seq cmd %02x\n", +			      cmd); +		return ret; +	} +	cmdwritten += chunk; +	seqp += chunk; + +	while (cmdwritten < cmdlen) { +		chunk = cmdlen - cmdwritten; +		if (chunk > 15) +			chunk = 15; +		ret = mipi_dsi_generic_write(dsi, seqp, chunk); +		if (ret < 0) { +			DRM_DEV_ERROR(nt->dev, +				      "error sending generic write seq %02x\n", +				      cmd); +			return ret; +		} +		cmdwritten += chunk; +		seqp += chunk; +	} +	DRM_DEV_DEBUG(nt->dev, "sent command %02x %02x bytes\n", +		      cmd, cmdlen); +	return 0; +} + +static int nt35510_read_id(struct nt35510 *nt) +{ +	struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev); +	u8 id1, id2, id3; +	int ret; + +	ret = mipi_dsi_dcs_read(dsi, MCS_CMD_READ_ID1, &id1, 1); +	if (ret < 0) { +		DRM_DEV_ERROR(nt->dev, "could not read MTP ID1\n"); +		return ret; +	} +	ret = mipi_dsi_dcs_read(dsi, MCS_CMD_READ_ID2, &id2, 1); +	if (ret < 0) { +		DRM_DEV_ERROR(nt->dev, "could not read MTP ID2\n"); +		return ret; +	} +	ret = mipi_dsi_dcs_read(dsi, MCS_CMD_READ_ID3, &id3, 1); +	if (ret < 0) { +		DRM_DEV_ERROR(nt->dev, "could not read MTP ID3\n"); +		return ret; +	} + +	/* +	 * Multi-Time Programmable (?) memory contains manufacturer +	 * ID (e.g. Hydis 0x55), driver ID (e.g. NT35510 0xc0) and +	 * version. +	 */ +	DRM_DEV_INFO(nt->dev, +		     "MTP ID manufacturer: %02x version: %02x driver: %02x\n", +		     id1, id2, id3); + +	return 0; +} + +/** + * nt35510_setup_power() - set up power config in page 1 + * @nt: the display instance to set up + */ +static int nt35510_setup_power(struct nt35510 *nt) +{ +	struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev); +	int ret; + +	ret = nt35510_send_long(nt, dsi, NT35510_P1_SETAVDD, +				NT35510_P1_AVDD_LEN, +				nt->conf->avdd); +	if (ret) +		return ret; +	ret = nt35510_send_long(nt, dsi, NT35510_P1_BT1CTR, +				NT35510_P1_BT1CTR_LEN, +				nt->conf->bt1ctr); +	if (ret) +		return ret; +	ret = nt35510_send_long(nt, dsi, NT35510_P1_SETAVEE, +				NT35510_P1_AVEE_LEN, +				nt->conf->avee); +	if (ret) +		return ret; +	ret = nt35510_send_long(nt, dsi, NT35510_P1_BT2CTR, +				NT35510_P1_BT2CTR_LEN, +				nt->conf->bt2ctr); +	if (ret) +		return ret; +	ret = nt35510_send_long(nt, dsi, NT35510_P1_SETVGH, +				NT35510_P1_VGH_LEN, +				nt->conf->vgh); +	if (ret) +		return ret; +	ret = nt35510_send_long(nt, dsi, NT35510_P1_BT4CTR, +				NT35510_P1_BT4CTR_LEN, +				nt->conf->bt4ctr); +	if (ret) +		return ret; +	ret = nt35510_send_long(nt, dsi, NT35510_P1_VGHCTR, +				ARRAY_SIZE(nt35510_vgh_on), +				nt35510_vgh_on); +	if (ret) +		return ret; +	ret = nt35510_send_long(nt, dsi, NT35510_P1_SETVGL, +				NT35510_P1_VGL_LEN, +				nt->conf->vgl); +	if (ret) +		return ret; +	ret = nt35510_send_long(nt, dsi, NT35510_P1_BT5CTR, +				NT35510_P1_BT5CTR_LEN, +				nt->conf->bt5ctr); +	if (ret) +		return ret; +	ret = nt35510_send_long(nt, dsi, NT35510_P1_SETVGP, +				NT35510_P1_VGP_LEN, +				nt->conf->vgp); +	if (ret) +		return ret; +	ret = nt35510_send_long(nt, dsi, NT35510_P1_SETVGN, +				NT35510_P1_VGN_LEN, +				nt->conf->vgn); +	if (ret) +		return ret; + +	/* Typically 10 ms */ +	usleep_range(10000, 20000); + +	return 0; +} + +/** + * nt35510_setup_display() - set up display config in page 0 + * @nt: the display instance to set up + */ +static int nt35510_setup_display(struct nt35510 *nt) +{ +	struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev); +	const struct nt35510_config *conf = nt->conf; +	u8 dopctr[NT35510_P0_DOPCTR_LEN]; +	u8 gseqctr[NT35510_P0_GSEQCTR_LEN]; +	u8 dpfrctr[NT35510_P0_DPFRCTR1_LEN]; +	/* FIXME: set up any rotation (assume none for now) */ +	u8 addr_mode = NT35510_ROTATE_0_SETTING; +	u8 val; +	int ret; + +	/* Enable TE, EoTP and RGB pixel format */ +	dopctr[0] = NT35510_DOPCTR_0_DSITE | NT35510_DOPCTR_0_EOTP | +		NT35510_DOPCTR_0_N565; +	dopctr[1] = NT35510_DOPCTR_1_CTB; +	ret = nt35510_send_long(nt, dsi, NT35510_P0_DOPCTR, +				NT35510_P0_DOPCTR_LEN, +				dopctr); +	if (ret) +		return ret; + +	ret = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_ADDRESS_MODE, &addr_mode, +				 sizeof(addr_mode)); +	if (ret < 0) +		return ret; + +	/* +	 * Source data hold time, default 0x05 = 2.5us +	 * 0x00..0x3F = 0 .. 31.5us in steps of 0.5us +	 * 0x0A = 5us +	 */ +	val = 0x0A; +	ret = mipi_dsi_dcs_write(dsi, NT35510_P0_SDHDTCTR, &val, +				 sizeof(val)); +	if (ret < 0) +		return ret; + +	/* EQ control for gate signals, 0x00 = 0 us */ +	gseqctr[0] = 0x00; +	gseqctr[1] = 0x00; +	ret = nt35510_send_long(nt, dsi, NT35510_P0_GSEQCTR, +				NT35510_P0_GSEQCTR_LEN, +				gseqctr); +	if (ret) +		return ret; + +	ret = nt35510_send_long(nt, dsi, NT35510_P0_SDEQCTR, +				NT35510_P0_SDEQCTR_LEN, +				conf->sdeqctr); +	if (ret) +		return ret; + +	ret = mipi_dsi_dcs_write(dsi, NT35510_P0_SDVPCTR, +				 &conf->sdvpctr, 1); +	if (ret < 0) +		return ret; + +	/* +	 * Display timing control for active and idle off mode: +	 * the first byte contains +	 * the two high bits of T1A and second byte the low 8 bits, and +	 * the valid range is 0x100 (257) to 0x3ff (1023) representing +	 * 258..1024 (+1) pixel clock ticks for one scanline. At 20MHz pixel +	 * clock this covers the range of 12.90us .. 51.20us in steps of +	 * 0.05us, the default is 0x184 (388) representing 389 ticks. +	 * The third byte is VBPDA, vertical back porch display active +	 * and the fourth VFPDA, vertical front porch display active, +	 * both given in number of scanlines in the range 0x02..0xff +	 * for 2..255 scanlines. The fifth byte is 2 bits selecting +	 * PSEL for active and idle off mode, how much the 20MHz clock +	 * is divided by 0..3.  This needs to be adjusted to get the right +	 * frame rate. +	 */ +	dpfrctr[0] = (conf->t1 >> 8) & 0xFF; +	dpfrctr[1] = conf->t1 & 0xFF; +	/* Vertical back porch */ +	dpfrctr[2] = conf->vbp; +	/* Vertical front porch */ +	dpfrctr[3] = conf->vfp; +	dpfrctr[4] = conf->psel; +	ret = nt35510_send_long(nt, dsi, NT35510_P0_DPFRCTR1, +				NT35510_P0_DPFRCTR1_LEN, +				dpfrctr); +	if (ret) +		return ret; +	/* For idle and partial idle off mode we decrease front porch by one */ +	dpfrctr[3]--; +	ret = nt35510_send_long(nt, dsi, NT35510_P0_DPFRCTR2, +				NT35510_P0_DPFRCTR2_LEN, +				dpfrctr); +	if (ret) +		return ret; +	ret = nt35510_send_long(nt, dsi, NT35510_P0_DPFRCTR3, +				NT35510_P0_DPFRCTR3_LEN, +				dpfrctr); +	if (ret) +		return ret; + +	/* Enable TE on vblank */ +	ret = mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK); +	if (ret) +		return ret; + +	/* Turn on the pads? */ +	ret = nt35510_send_long(nt, dsi, NT35510_P0_DPMCTR12, +				NT35510_P0_DPMCTR12_LEN, +				conf->dpmctr12); +	if (ret) +		return ret; + +	return 0; +} + +static int nt35510_set_brightness(struct backlight_device *bl) +{ +	struct nt35510 *nt = bl_get_data(bl); +	struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev); +	u8 brightness = bl->props.brightness; +	int ret; + +	DRM_DEV_DEBUG(nt->dev, "set brightness %d\n", brightness); +	ret = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, +				 &brightness, +				 sizeof(brightness)); +	if (ret < 0) +		return ret; + +	return 0; +} + +static const struct backlight_ops nt35510_bl_ops = { +	.update_status = nt35510_set_brightness, +}; + +/* + * This power-on sequence + */ +static int nt35510_power_on(struct nt35510 *nt) +{ +	struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev); +	int ret; + +	ret = regulator_bulk_enable(ARRAY_SIZE(nt->supplies), nt->supplies); +	if (ret < 0) { +		dev_err(nt->dev, "unable to enable regulators\n"); +		return ret; +	} + +	/* Toggle RESET in accordance with datasheet page 370 */ +	if (nt->reset_gpio) { +		gpiod_set_value(nt->reset_gpio, 1); +		/* Active min 10 us according to datasheet, let's say 20 */ +		usleep_range(20, 1000); +		gpiod_set_value(nt->reset_gpio, 0); +		/* +		 * 5 ms during sleep mode, 120 ms during sleep out mode +		 * according to datasheet, let's use 120-140 ms. +		 */ +		usleep_range(120000, 140000); +	} + +	ret = nt35510_read_id(nt); +	if (ret) +		return ret; + +	/* Set up stuff in  manufacturer control, page 1 */ +	ret = nt35510_send_long(nt, dsi, MCS_CMD_MAUCCTR, +				ARRAY_SIZE(nt35510_mauc_select_page_1), +				nt35510_mauc_select_page_1); +	if (ret) +		return ret; + +	ret = nt35510_setup_power(nt); +	if (ret) +		return ret; + +	ret = nt35510_send_long(nt, dsi, NT35510_P1_SET_GAMMA_RED_POS, +				NT35510_P1_GAMMA_LEN, +				nt->conf->gamma_corr_pos_r); +	if (ret) +		return ret; +	ret = nt35510_send_long(nt, dsi, NT35510_P1_SET_GAMMA_GREEN_POS, +				NT35510_P1_GAMMA_LEN, +				nt->conf->gamma_corr_pos_g); +	if (ret) +		return ret; +	ret = nt35510_send_long(nt, dsi, NT35510_P1_SET_GAMMA_BLUE_POS, +				NT35510_P1_GAMMA_LEN, +				nt->conf->gamma_corr_pos_b); +	if (ret) +		return ret; +	ret = nt35510_send_long(nt, dsi, NT35510_P1_SET_GAMMA_RED_NEG, +				NT35510_P1_GAMMA_LEN, +				nt->conf->gamma_corr_neg_r); +	if (ret) +		return ret; +	ret = nt35510_send_long(nt, dsi, NT35510_P1_SET_GAMMA_GREEN_NEG, +				NT35510_P1_GAMMA_LEN, +				nt->conf->gamma_corr_neg_g); +	if (ret) +		return ret; +	ret = nt35510_send_long(nt, dsi, NT35510_P1_SET_GAMMA_BLUE_NEG, +				NT35510_P1_GAMMA_LEN, +				nt->conf->gamma_corr_neg_b); +	if (ret) +		return ret; + +	/* Set up stuff in  manufacturer control, page 0 */ +	ret = nt35510_send_long(nt, dsi, MCS_CMD_MAUCCTR, +				ARRAY_SIZE(nt35510_mauc_select_page_0), +				nt35510_mauc_select_page_0); +	if (ret) +		return ret; + +	ret = nt35510_setup_display(nt); +	if (ret) +		return ret; + +	return 0; +} + +static int nt35510_power_off(struct nt35510 *nt) +{ +	int ret; + +	ret = regulator_bulk_disable(ARRAY_SIZE(nt->supplies), nt->supplies); +	if (ret) +		return ret; + +	if (nt->reset_gpio) +		gpiod_set_value(nt->reset_gpio, 1); + +	return 0; +} + +static int nt35510_unprepare(struct drm_panel *panel) +{ +	struct nt35510 *nt = panel_to_nt35510(panel); +	struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev); +	int ret; + +	ret = mipi_dsi_dcs_set_display_off(dsi); +	if (ret) { +		DRM_DEV_ERROR(nt->dev, "failed to turn display off (%d)\n", +			      ret); +		return ret; +	} +	usleep_range(10000, 20000); + +	/* Enter sleep mode */ +	ret = mipi_dsi_dcs_enter_sleep_mode(dsi); +	if (ret) { +		DRM_DEV_ERROR(nt->dev, "failed to enter sleep mode (%d)\n", +			      ret); +		return ret; +	} + +	/* Wait 4 frames, how much is that 5ms in the vendor driver */ +	usleep_range(5000, 10000); + +	ret = nt35510_power_off(nt); +	if (ret) +		return ret; + +	return 0; +} + +static int nt35510_prepare(struct drm_panel *panel) +{ +	struct nt35510 *nt = panel_to_nt35510(panel); +	struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev); +	int ret; + +	ret = nt35510_power_on(nt); +	if (ret) +		return ret; + +	/* Exit sleep mode */ +	ret = mipi_dsi_dcs_exit_sleep_mode(dsi); +	if (ret) { +		DRM_DEV_ERROR(nt->dev, "failed to exit sleep mode (%d)\n", +			      ret); +		return ret; +	} +	/* Up to 120 ms */ +	usleep_range(120000, 150000); + +	ret = mipi_dsi_dcs_set_display_on(dsi); +	if (ret) { +		DRM_DEV_ERROR(nt->dev, "failed to turn display on (%d)\n", +			      ret); +		return ret; +	} +	/* Some 10 ms */ +	usleep_range(10000, 20000); + +	return 0; +} + +static int nt35510_get_modes(struct drm_panel *panel, +			     struct drm_connector *connector) +{ +	struct nt35510 *nt = panel_to_nt35510(panel); +	struct drm_display_mode *mode; +	struct drm_display_info *info; + +	info = &connector->display_info; +	info->width_mm = nt->conf->width_mm; +	info->height_mm = nt->conf->height_mm; +	mode = drm_mode_duplicate(connector->dev, &nt->conf->mode); +	if (!mode) { +		DRM_ERROR("bad mode or failed to add mode\n"); +		return -EINVAL; +	} +	drm_mode_set_name(mode); +	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; + +	mode->width_mm = nt->conf->width_mm; +	mode->height_mm = nt->conf->height_mm; +	drm_mode_probed_add(connector, mode); + +	return 1; /* Number of modes */ +} + +static const struct drm_panel_funcs nt35510_drm_funcs = { +	.unprepare = nt35510_unprepare, +	.prepare = nt35510_prepare, +	.get_modes = nt35510_get_modes, +}; + +static int nt35510_probe(struct mipi_dsi_device *dsi) +{ +	struct device *dev = &dsi->dev; +	struct nt35510 *nt; +	int ret; + +	nt = devm_kzalloc(dev, sizeof(struct nt35510), GFP_KERNEL); +	if (!nt) +		return -ENOMEM; +	mipi_dsi_set_drvdata(dsi, nt); +	nt->dev = dev; + +	dsi->lanes = 2; +	dsi->format = MIPI_DSI_FMT_RGB888; +	/* +	 * Datasheet suggests max HS rate for NT35510 is 250 MHz +	 * (period time 4ns, see figure 7.6.4 page 365) and max LP rate is +	 * 20 MHz (period time 50ns, see figure 7.6.6. page 366). +	 * However these frequencies appear in source code for the Hydis +	 * HVA40WV1 panel and setting up the LP frequency makes the panel +	 * not work. +	 * +	 * TODO: if other panels prove to be closer to the datasheet, +	 * maybe make this a per-panel config in struct nt35510_config? +	 */ +	dsi->hs_rate = 349440000; +	dsi->lp_rate = 9600000; +	dsi->mode_flags = MIPI_DSI_CLOCK_NON_CONTINUOUS | +		MIPI_DSI_MODE_EOT_PACKET; + +	/* +	 * Every new incarnation of this display must have a unique +	 * data entry for the system in this driver. +	 */ +	nt->conf = of_device_get_match_data(dev); +	if (!nt->conf) { +		dev_err(dev, "missing device configuration\n"); +		return -ENODEV; +	} + +	nt->supplies[0].supply = "vdd"; /* 2.3-4.8 V */ +	nt->supplies[1].supply = "vddi"; /* 1.65-3.3V */ +	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(nt->supplies), +				      nt->supplies); +	if (ret < 0) +		return ret; +	ret = regulator_set_voltage(nt->supplies[0].consumer, +				    2300000, 4800000); +	if (ret) +		return ret; +	ret = regulator_set_voltage(nt->supplies[1].consumer, +				    1650000, 3300000); +	if (ret) +		return ret; + +	nt->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_ASIS); +	if (IS_ERR(nt->reset_gpio)) { +		dev_err(dev, "error getting RESET GPIO\n"); +		return PTR_ERR(nt->reset_gpio); +	} + +	drm_panel_init(&nt->panel, dev, &nt35510_drm_funcs, +		       DRM_MODE_CONNECTOR_DSI); + +	/* +	 * First, try to locate an external backlight (such as on GPIO) +	 * if this fails, assume we will want to use the internal backlight +	 * control. +	 */ +	ret = drm_panel_of_backlight(&nt->panel); +	if (ret) { +		dev_err(dev, "error getting external backlight %d\n", ret); +		return ret; +	} +	if (!nt->panel.backlight) { +		struct backlight_device *bl; + +		bl = devm_backlight_device_register(dev, "nt35510", dev, nt, +						    &nt35510_bl_ops, NULL); +		if (IS_ERR(bl)) { +			DRM_DEV_ERROR(dev, "failed to register backlight device\n"); +			return PTR_ERR(bl); +		} +		bl->props.max_brightness = 255; +		bl->props.brightness = 255; +		bl->props.power = FB_BLANK_POWERDOWN; +		nt->panel.backlight = bl; +	} + +	ret = drm_panel_add(&nt->panel); +	if (ret < 0) +		return ret; + +	ret = mipi_dsi_attach(dsi); +	if (ret < 0) +		drm_panel_remove(&nt->panel); + +	return 0; +} + +static int nt35510_remove(struct mipi_dsi_device *dsi) +{ +	struct nt35510 *nt = mipi_dsi_get_drvdata(dsi); +	int ret; + +	mipi_dsi_detach(dsi); +	/* Power off */ +	ret = nt35510_power_off(nt); +	drm_panel_remove(&nt->panel); + +	return ret; +} + +/* + * These gamma correction values are 10bit tuples, so only bits 0 and 1 is + * ever used in the first byte. They form a positive and negative gamma + * correction curve for each color, values must be strictly higher for each + * step on the curve. As can be seen these default curves goes from 0x0001 + * to 0x03FE. + */ +#define NT35510_GAMMA_POS_DEFAULT 0x00, 0x01, 0x00, 0x43, 0x00, \ +		0x6B, 0x00, 0x87, 0x00, 0xA3, 0x00, 0xCE, 0x00, 0xF1, 0x01, \ +		0x27, 0x01, 0x53, 0x01, 0x98, 0x01, 0xCE, 0x02, 0x22, 0x02, \ +		0x83, 0x02, 0x78, 0x02, 0x9E, 0x02, 0xDD, 0x03, 0x00, 0x03, \ +		0x2E, 0x03, 0x54, 0x03, 0x7F, 0x03, 0x95, 0x03, 0xB3, 0x03, \ +		0xC2, 0x03, 0xE1, 0x03, 0xF1, 0x03, 0xFE + +#define NT35510_GAMMA_NEG_DEFAULT 0x00, 0x01, 0x00, 0x43, 0x00, \ +		0x6B, 0x00, 0x87, 0x00, 0xA3, 0x00, 0xCE, 0x00, 0xF1, 0x01, \ +		0x27, 0x01, 0x53, 0x01, 0x98, 0x01, 0xCE, 0x02, 0x22, 0x02, \ +		0x43, 0x02, 0x50, 0x02, 0x9E, 0x02, 0xDD, 0x03, 0x00, 0x03, \ +		0x2E, 0x03, 0x54, 0x03, 0x7F, 0x03, 0x95, 0x03, 0xB3, 0x03, \ +		0xC2, 0x03, 0xE1, 0x03, 0xF1, 0x03, 0xFE + +/* + * The Hydis HVA40WV1 panel + */ +static const struct nt35510_config nt35510_hydis_hva40wv1 = { +	.width_mm = 52, +	.height_mm = 86, +	/** +	 * As the Hydis panel is used in command mode, the porches etc +	 * are settings programmed internally into the NT35510 controller +	 * and generated toward the physical display. As the panel is not +	 * used in video mode, these are not really exposed to the DSI +	 * host. +	 * +	 * Display frame rate control: +	 * Frame rate = (20 MHz / 1) / (389 * (7 + 50 + 800)) ~= 60 Hz +	 */ +	.mode = { +		/* The internal pixel clock of the NT35510 is 20 MHz */ +		.clock = 20000, +		.hdisplay = 480, +		.hsync_start = 480 + 2, /* HFP = 2 */ +		.hsync_end = 480 + 2 + 0, /* HSync = 0 */ +		.htotal = 480 + 2 + 0 + 5, /* HFP = 5 */ +		.vdisplay = 800, +		.vsync_start = 800 + 2, /* VFP = 2 */ +		.vsync_end = 800 + 2 + 0, /* VSync = 0 */ +		.vtotal = 800 + 2 + 0 + 5, /* VBP = 5 */ +		.vrefresh = 60, /* Calculated */ +		.flags = 0, +	}, +	/* 0x09: AVDD = 5.6V */ +	.avdd = { 0x09, 0x09, 0x09 }, +	/* 0x34: PCK = Hsync/2, BTP = 2 x VDDB */ +	.bt1ctr = { 0x34, 0x34, 0x34 }, +	/* 0x09: AVEE = -5.6V */ +	.avee = { 0x09, 0x09, 0x09 }, +	/* 0x24: NCK = Hsync/2, BTN =  -2 x VDDB */ +	.bt2ctr = { 0x24, 0x24, 0x24 }, +	/* 0x05 = 12V */ +	.vgh = { 0x05, 0x05, 0x05 }, +	/* 0x24: NCKA = Hsync/2, VGH = 2 x AVDD - AVEE */ +	.bt4ctr = { 0x24, 0x24, 0x24 }, +	/* 0x0B = -13V */ +	.vgl = { 0x0B, 0x0B, 0x0B }, +	/* 0x24: LCKA = Hsync, VGL = AVDD + VCL - AVDD */ +	.bt5ctr = { 0x24, 0x24, 0x24 }, +	/* VGMP: 0x0A3 = 5.0375V, VGSP = 0V */ +	.vgp = { 0x00, 0xA3, 0x00 }, +	/* VGMP: 0x0A3 = 5.0375V, VGSP = 0V */ +	.vgn = { 0x00, 0xA3, 0x00 }, +	/* SDEQCTR: source driver EQ mode 2, 2.5 us rise time on each step */ +	.sdeqctr = { 0x01, 0x05, 0x05, 0x05 }, +	/* SDVPCTR: Normal operation off color during v porch */ +	.sdvpctr = 0x01, +	/* T1: number of pixel clocks on one scanline: 0x184 = 389 clocks */ +	.t1 = 0x0184, +	/* VBP: vertical back porch toward the panel */ +	.vbp = 7, +	/* VFP: vertical front porch toward the panel */ +	.vfp = 50, +	/* PSEL: divide pixel clock 20MHz with 1 (no clock downscaling) */ +	.psel = 0, +	/* DPTMCTR12: 0x03: LVGL = VGLX, overlap mode, swap R->L O->E */ +	.dpmctr12 = { 0x03, 0x00, 0x00, }, +	/* Default gamma correction values */ +	.gamma_corr_pos_r = { NT35510_GAMMA_POS_DEFAULT }, +	.gamma_corr_pos_g = { NT35510_GAMMA_POS_DEFAULT }, +	.gamma_corr_pos_b = { NT35510_GAMMA_POS_DEFAULT }, +	.gamma_corr_neg_r = { NT35510_GAMMA_NEG_DEFAULT }, +	.gamma_corr_neg_g = { NT35510_GAMMA_NEG_DEFAULT }, +	.gamma_corr_neg_b = { NT35510_GAMMA_NEG_DEFAULT }, +}; + +static const struct of_device_id nt35510_of_match[] = { +	{ +		.compatible = "hydis,hva40wv1", +		.data = &nt35510_hydis_hva40wv1, +	}, +	{ } +}; +MODULE_DEVICE_TABLE(of, nt35510_of_match); + +static struct mipi_dsi_driver nt35510_driver = { +	.probe = nt35510_probe, +	.remove = nt35510_remove, +	.driver = { +		.name = "panel-novatek-nt35510", +		.of_match_table = nt35510_of_match, +	}, +}; +module_mipi_dsi_driver(nt35510_driver); + +MODULE_AUTHOR("Linus Walleij <[email protected]>"); +MODULE_DESCRIPTION("NT35510-based panel driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/gpu/drm/panel/panel-samsung-ld9040.c b/drivers/gpu/drm/panel/panel-samsung-ld9040.c index 3c52f15f7a1c..9bb2e8c7934a 100644 --- a/drivers/gpu/drm/panel/panel-samsung-ld9040.c +++ b/drivers/gpu/drm/panel/panel-samsung-ld9040.c @@ -373,6 +373,12 @@ static const struct of_device_id ld9040_of_match[] = {  };  MODULE_DEVICE_TABLE(of, ld9040_of_match); +static const struct spi_device_id ld9040_ids[] = { +	{ "ld9040", }, +	{ /* sentinel */ } +}; +MODULE_DEVICE_TABLE(spi, ld9040_ids); +  static struct spi_driver ld9040_driver = {  	.probe = ld9040_probe,  	.remove = ld9040_remove, diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e88a0-ams452ef01.c b/drivers/gpu/drm/panel/panel-samsung-s6e88a0-ams452ef01.c new file mode 100644 index 000000000000..9d843fcc3a22 --- /dev/null +++ b/drivers/gpu/drm/panel/panel-samsung-s6e88a0-ams452ef01.c @@ -0,0 +1,293 @@ +// SPDX-License-Identifier: GPL-2.0-only +// Copyright (C) 2019, Michael Srba + +#include <linux/delay.h> +#include <linux/gpio/consumer.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/regulator/consumer.h> + +#include <video/mipi_display.h> + +#include <drm/drm_mipi_dsi.h> +#include <drm/drm_modes.h> +#include <drm/drm_panel.h> + +struct s6e88a0_ams452ef01 { +	struct drm_panel panel; +	struct mipi_dsi_device *dsi; +	struct regulator_bulk_data supplies[2]; +	struct gpio_desc *reset_gpio; + +	bool prepared; +}; + +static inline struct +s6e88a0_ams452ef01 *to_s6e88a0_ams452ef01(struct drm_panel *panel) +{ +	return container_of(panel, struct s6e88a0_ams452ef01, panel); +} + +#define dsi_dcs_write_seq(dsi, seq...) do {				\ +		static const u8 d[] = { seq };				\ +		int ret;						\ +		ret = mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d));	\ +		if (ret < 0)						\ +			return ret;					\ +	} while (0) + +static void s6e88a0_ams452ef01_reset(struct s6e88a0_ams452ef01 *ctx) +{ +	gpiod_set_value_cansleep(ctx->reset_gpio, 1); +	usleep_range(5000, 6000); +	gpiod_set_value_cansleep(ctx->reset_gpio, 0); +	usleep_range(1000, 2000); +	gpiod_set_value_cansleep(ctx->reset_gpio, 1); +	usleep_range(10000, 11000); +} + +static int s6e88a0_ams452ef01_on(struct s6e88a0_ams452ef01 *ctx) +{ +	struct mipi_dsi_device *dsi = ctx->dsi; +	struct device *dev = &dsi->dev; +	int ret; + +	dsi->mode_flags |= MIPI_DSI_MODE_LPM; + +	dsi_dcs_write_seq(dsi, 0xf0, 0x5a, 0x5a); // enable LEVEL2 commands +	dsi_dcs_write_seq(dsi, 0xcc, 0x4c); // set Pixel Clock Divider polarity + +	ret = mipi_dsi_dcs_exit_sleep_mode(dsi); +	if (ret < 0) { +		dev_err(dev, "Failed to exit sleep mode: %d\n", ret); +		return ret; +	} +	msleep(120); + +	// set default brightness/gama +	dsi_dcs_write_seq(dsi, 0xca, +			  0x01, 0x00, 0x01, 0x00, 0x01, 0x00,	// V255 RR,GG,BB +			  0x80, 0x80, 0x80,			// V203 R,G,B +			  0x80, 0x80, 0x80,			// V151 R,G,B +			  0x80, 0x80, 0x80,			// V87  R,G,B +			  0x80, 0x80, 0x80,			// V51  R,G,B +			  0x80, 0x80, 0x80,			// V35  R,G,B +			  0x80, 0x80, 0x80,			// V23  R,G,B +			  0x80, 0x80, 0x80,			// V11  R,G,B +			  0x6b, 0x68, 0x71,			// V3   R,G,B +			  0x00, 0x00, 0x00);			// V1   R,G,B +	// set default Amoled Off Ratio +	dsi_dcs_write_seq(dsi, 0xb2, 0x40, 0x0a, 0x17, 0x00, 0x0a); +	dsi_dcs_write_seq(dsi, 0xb6, 0x2c, 0x0b); // set default elvss voltage +	dsi_dcs_write_seq(dsi, MIPI_DCS_WRITE_POWER_SAVE, 0x00); +	dsi_dcs_write_seq(dsi, 0xf7, 0x03); // gamma/aor update +	dsi_dcs_write_seq(dsi, 0xf0, 0xa5, 0xa5); // disable LEVEL2 commands + +	ret = mipi_dsi_dcs_set_display_on(dsi); +	if (ret < 0) { +		dev_err(dev, "Failed to set display on: %d\n", ret); +		return ret; +	} + +	return 0; +} + +static int s6e88a0_ams452ef01_off(struct s6e88a0_ams452ef01 *ctx) +{ +	struct mipi_dsi_device *dsi = ctx->dsi; +	struct device *dev = &dsi->dev; +	int ret; + +	dsi->mode_flags &= ~MIPI_DSI_MODE_LPM; + +	ret = mipi_dsi_dcs_set_display_off(dsi); +	if (ret < 0) { +		dev_err(dev, "Failed to set display off: %d\n", ret); +		return ret; +	} +	msleep(35); + +	ret = mipi_dsi_dcs_enter_sleep_mode(dsi); +	if (ret < 0) { +		dev_err(dev, "Failed to enter sleep mode: %d\n", ret); +		return ret; +	} +	msleep(120); + +	return 0; +} + +static int s6e88a0_ams452ef01_prepare(struct drm_panel *panel) +{ +	struct s6e88a0_ams452ef01 *ctx = to_s6e88a0_ams452ef01(panel); +	struct device *dev = &ctx->dsi->dev; +	int ret; + +	if (ctx->prepared) +		return 0; + +	ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); +	if (ret < 0) { +		dev_err(dev, "Failed to enable regulators: %d\n", ret); +		return ret; +	} + +	s6e88a0_ams452ef01_reset(ctx); + +	ret = s6e88a0_ams452ef01_on(ctx); +	if (ret < 0) { +		dev_err(dev, "Failed to initialize panel: %d\n", ret); +		gpiod_set_value_cansleep(ctx->reset_gpio, 0); +		regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), +				       ctx->supplies); +		return ret; +	} + +	ctx->prepared = true; +	return 0; +} + +static int s6e88a0_ams452ef01_unprepare(struct drm_panel *panel) +{ +	struct s6e88a0_ams452ef01 *ctx = to_s6e88a0_ams452ef01(panel); +	struct device *dev = &ctx->dsi->dev; +	int ret; + +	if (!ctx->prepared) +		return 0; + +	ret = s6e88a0_ams452ef01_off(ctx); +	if (ret < 0) +		dev_err(dev, "Failed to un-initialize panel: %d\n", ret); + +	gpiod_set_value_cansleep(ctx->reset_gpio, 0); +	regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); + +	ctx->prepared = false; +	return 0; +} + +static const struct drm_display_mode s6e88a0_ams452ef01_mode = { +	.clock = (540 + 88 + 4 + 20) * (960 + 14 + 2 + 8) * 60 / 1000, +	.hdisplay = 540, +	.hsync_start = 540 + 88, +	.hsync_end = 540 + 88 + 4, +	.htotal = 540 + 88 + 4 + 20, +	.vdisplay = 960, +	.vsync_start = 960 + 14, +	.vsync_end = 960 + 14 + 2, +	.vtotal = 960 + 14 + 2 + 8, +	.vrefresh = 60, +	.width_mm = 56, +	.height_mm = 100, +}; + +static int s6e88a0_ams452ef01_get_modes(struct drm_panel *panel, +					struct drm_connector *connector) +{ +	struct drm_display_mode *mode; + +	mode = drm_mode_duplicate(connector->dev, &s6e88a0_ams452ef01_mode); +	if (!mode) +		return -ENOMEM; + +	drm_mode_set_name(mode); + +	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; +	connector->display_info.width_mm = mode->width_mm; +	connector->display_info.height_mm = mode->height_mm; +	drm_mode_probed_add(connector, mode); + +	return 1; +} + +static const struct drm_panel_funcs s6e88a0_ams452ef01_panel_funcs = { +	.unprepare = s6e88a0_ams452ef01_unprepare, +	.prepare = s6e88a0_ams452ef01_prepare, +	.get_modes = s6e88a0_ams452ef01_get_modes, +}; + +static int s6e88a0_ams452ef01_probe(struct mipi_dsi_device *dsi) +{ +	struct device *dev = &dsi->dev; +	struct s6e88a0_ams452ef01 *ctx; +	int ret; + +	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); +	if (!ctx) +		return -ENOMEM; + +	ctx->supplies[0].supply = "vdd3"; +	ctx->supplies[1].supply = "vci"; +	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies), +				      ctx->supplies); +	if (ret < 0) { +		dev_err(dev, "Failed to get regulators: %d\n", ret); +		return ret; +	} + +	ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); +	if (IS_ERR(ctx->reset_gpio)) { +		ret = PTR_ERR(ctx->reset_gpio); +		dev_err(dev, "Failed to get reset-gpios: %d\n", ret); +		return ret; +	} + +	ctx->dsi = dsi; +	mipi_dsi_set_drvdata(dsi, ctx); + +	dsi->lanes = 2; +	dsi->format = MIPI_DSI_FMT_RGB888; +	dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST; + +	drm_panel_init(&ctx->panel, dev, &s6e88a0_ams452ef01_panel_funcs, +		       DRM_MODE_CONNECTOR_DSI); + +	ret = drm_panel_add(&ctx->panel); +	if (ret < 0) { +		dev_err(dev, "Failed to add panel: %d\n", ret); +		return ret; +	} + +	ret = mipi_dsi_attach(dsi); +	if (ret < 0) { +		dev_err(dev, "Failed to attach to DSI host: %d\n", ret); +		return ret; +	} + +	return 0; +} + +static int s6e88a0_ams452ef01_remove(struct mipi_dsi_device *dsi) +{ +	struct s6e88a0_ams452ef01 *ctx = mipi_dsi_get_drvdata(dsi); +	int ret; + +	ret = mipi_dsi_detach(dsi); +	if (ret < 0) +		dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n", ret); + +	drm_panel_remove(&ctx->panel); + +	return 0; +} + +static const struct of_device_id s6e88a0_ams452ef01_of_match[] = { +	{ .compatible = "samsung,s6e88a0-ams452ef01" }, +	{ /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, s6e88a0_ams452ef01_of_match); + +static struct mipi_dsi_driver s6e88a0_ams452ef01_driver = { +	.probe = s6e88a0_ams452ef01_probe, +	.remove = s6e88a0_ams452ef01_remove, +	.driver = { +		.name = "panel-s6e88a0-ams452ef01", +		.of_match_table = s6e88a0_ams452ef01_of_match, +	}, +}; +module_mipi_dsi_driver(s6e88a0_ams452ef01_driver); + +MODULE_AUTHOR("Michael Srba <[email protected]>"); +MODULE_DESCRIPTION("MIPI-DSI based Panel Driver for AMS452EF01 AMOLED LCD with a S6E88A0 controller"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index e14c14ac62b5..0ce81b1f36af 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -351,6 +351,65 @@ static const struct drm_panel_funcs panel_simple_funcs = {  	.get_timings = panel_simple_get_timings,  }; +static struct panel_desc panel_dpi; + +static int panel_dpi_probe(struct device *dev, +			   struct panel_simple *panel) +{ +	struct display_timing *timing; +	const struct device_node *np; +	struct panel_desc *desc; +	unsigned int bus_flags; +	struct videomode vm; +	const char *mapping; +	int ret; + +	np = dev->of_node; +	desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL); +	if (!desc) +		return -ENOMEM; + +	timing = devm_kzalloc(dev, sizeof(*timing), GFP_KERNEL); +	if (!timing) +		return -ENOMEM; + +	ret = of_get_display_timing(np, "panel-timing", timing); +	if (ret < 0) { +		dev_err(dev, "%pOF: no panel-timing node found for \"panel-dpi\" binding\n", +			np); +		return ret; +	} + +	desc->timings = timing; +	desc->num_timings = 1; + +	of_property_read_u32(np, "width-mm", &desc->size.width); +	of_property_read_u32(np, "height-mm", &desc->size.height); + +	of_property_read_string(np, "data-mapping", &mapping); +	if (!strcmp(mapping, "rgb24")) +		desc->bus_format = MEDIA_BUS_FMT_RGB888_1X24; +	else if (!strcmp(mapping, "rgb565")) +		desc->bus_format = MEDIA_BUS_FMT_RGB565_1X16; +	else if (!strcmp(mapping, "bgr666")) +		desc->bus_format = MEDIA_BUS_FMT_RGB666_1X18; +	else if (!strcmp(mapping, "lvds666")) +		desc->bus_format = MEDIA_BUS_FMT_RGB666_1X24_CPADHI; + +	/* Extract bus_flags from display_timing */ +	bus_flags = 0; +	vm.flags = timing->flags; +	drm_bus_flags_from_videomode(&vm, &bus_flags); +	desc->bus_flags = bus_flags; + +	/* We do not know the connector for the DT node, so guess it */ +	desc->connector_type = DRM_MODE_CONNECTOR_DPI; + +	panel->desc = desc; + +	return 0; +} +  #define PANEL_SIMPLE_BOUNDS_CHECK(to_check, bounds, field) \  	(to_check->field.typ >= bounds->field.min && \  	 to_check->field.typ <= bounds->field.max) @@ -437,8 +496,15 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)  			return -EPROBE_DEFER;  	} -	if (!of_get_display_timing(dev->of_node, "panel-timing", &dt)) -		panel_simple_parse_panel_timing_node(dev, panel, &dt); +	if (desc == &panel_dpi) { +		/* Handle the generic panel-dpi binding */ +		err = panel_dpi_probe(dev, panel); +		if (err) +			goto free_ddc; +	} else { +		if (!of_get_display_timing(dev->of_node, "panel-timing", &dt)) +			panel_simple_parse_panel_timing_node(dev, panel, &dt); +	}  	drm_panel_init(&panel->base, dev, &panel_simple_funcs,  		       desc->connector_type); @@ -1301,6 +1367,37 @@ static const struct panel_desc edt_et035012dm6 = {  	.bus_flags = DRM_BUS_FLAG_DE_LOW | DRM_BUS_FLAG_PIXDATA_NEGEDGE,  }; +static const struct drm_display_mode edt_etm043080dh6gp_mode = { +	.clock = 10870, +	.hdisplay = 480, +	.hsync_start = 480 + 8, +	.hsync_end = 480 + 8 + 4, +	.htotal = 480 + 8 + 4 + 41, + +	/* +	 * IWG22M: Y resolution changed for "dc_linuxfb" module crashing while +	 * fb_align +	 */ + +	.vdisplay = 288, +	.vsync_start = 288 + 2, +	.vsync_end = 288 + 2 + 4, +	.vtotal = 288 + 2 + 4 + 10, +	.vrefresh = 60, +}; + +static const struct panel_desc edt_etm043080dh6gp = { +	.modes = &edt_etm043080dh6gp_mode, +	.num_modes = 1, +	.bpc = 8, +	.size = { +		.width = 100, +		.height = 65, +	}, +	.bus_format = MEDIA_BUS_FMT_RGB666_1X18, +	.connector_type = DRM_MODE_CONNECTOR_DPI, +}; +  static const struct drm_display_mode edt_etm0430g0dh6_mode = {  	.clock = 9000,  	.hdisplay = 480, @@ -1440,6 +1537,33 @@ static const struct panel_desc foxlink_fl500wvr00_a0t = {  	.bus_format = MEDIA_BUS_FMT_RGB888_1X24,  }; +static const struct drm_display_mode frida_frd350h54004_mode = { +	.clock = 6000, +	.hdisplay = 320, +	.hsync_start = 320 + 44, +	.hsync_end = 320 + 44 + 16, +	.htotal = 320 + 44 + 16 + 20, +	.vdisplay = 240, +	.vsync_start = 240 + 2, +	.vsync_end = 240 + 2 + 6, +	.vtotal = 240 + 2 + 6 + 2, +	.vrefresh = 60, +	.flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC, +}; + +static const struct panel_desc frida_frd350h54004 = { +	.modes = &frida_frd350h54004_mode, +	.num_modes = 1, +	.bpc = 8, +	.size = { +		.width = 77, +		.height = 64, +	}, +	.bus_format = MEDIA_BUS_FMT_RGB888_1X24, +	.bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_POSEDGE, +	.connector_type = DRM_MODE_CONNECTOR_DPI, +}; +  static const struct drm_display_mode friendlyarm_hd702e_mode = {  	.clock		= 67185,  	.hdisplay	= 800, @@ -2080,6 +2204,64 @@ static const struct panel_desc lg_lp129qe = {  	},  }; +static const struct display_timing logictechno_lt161010_2nh_timing = { +	.pixelclock = { 26400000, 33300000, 46800000 }, +	.hactive = { 800, 800, 800 }, +	.hfront_porch = { 16, 210, 354 }, +	.hback_porch = { 46, 46, 46 }, +	.hsync_len = { 1, 20, 40 }, +	.vactive = { 480, 480, 480 }, +	.vfront_porch = { 7, 22, 147 }, +	.vback_porch = { 23, 23, 23 }, +	.vsync_len = { 1, 10, 20 }, +	.flags = DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW | +		 DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_POSEDGE | +		 DISPLAY_FLAGS_SYNC_POSEDGE, +}; + +static const struct panel_desc logictechno_lt161010_2nh = { +	.timings = &logictechno_lt161010_2nh_timing, +	.num_timings = 1, +	.size = { +		.width = 154, +		.height = 86, +	}, +	.bus_format = MEDIA_BUS_FMT_RGB666_1X18, +	.bus_flags = DRM_BUS_FLAG_DE_HIGH | +		     DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE | +		     DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE, +	.connector_type = DRM_MODE_CONNECTOR_DPI, +}; + +static const struct display_timing logictechno_lt170410_2whc_timing = { +	.pixelclock = { 68900000, 71100000, 73400000 }, +	.hactive = { 1280, 1280, 1280 }, +	.hfront_porch = { 23, 60, 71 }, +	.hback_porch = { 23, 60, 71 }, +	.hsync_len = { 15, 40, 47 }, +	.vactive = { 800, 800, 800 }, +	.vfront_porch = { 5, 7, 10 }, +	.vback_porch = { 5, 7, 10 }, +	.vsync_len = { 6, 9, 12 }, +	.flags = DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW | +		 DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_POSEDGE | +		 DISPLAY_FLAGS_SYNC_POSEDGE, +}; + +static const struct panel_desc logictechno_lt170410_2whc = { +	.timings = &logictechno_lt170410_2whc_timing, +	.num_timings = 1, +	.size = { +		.width = 217, +		.height = 136, +	}, +	.bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG, +	.bus_flags = DRM_BUS_FLAG_DE_HIGH | +		     DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE | +		     DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE, +	.connector_type = DRM_MODE_CONNECTOR_LVDS, +}; +  static const struct drm_display_mode mitsubishi_aa070mc01_mode = {  	.clock = 30400,  	.hdisplay = 800, @@ -2095,7 +2277,7 @@ static const struct drm_display_mode mitsubishi_aa070mc01_mode = {  };  static const struct drm_display_mode logicpd_type_28_mode = { -	.clock = 9000, +	.clock = 9107,  	.hdisplay = 480,  	.hsync_start = 480 + 3,  	.hsync_end = 480 + 3 + 42, @@ -2224,6 +2406,51 @@ static const struct panel_desc netron_dy_e231732 = {  	.bus_format = MEDIA_BUS_FMT_RGB666_1X18,  }; +static const struct drm_display_mode neweast_wjfh116008a_modes[] = { +	{ +		.clock = 138500, +		.hdisplay = 1920, +		.hsync_start = 1920 + 48, +		.hsync_end = 1920 + 48 + 32, +		.htotal = 1920 + 48 + 32 + 80, +		.vdisplay = 1080, +		.vsync_start = 1080 + 3, +		.vsync_end = 1080 + 3 + 5, +		.vtotal = 1080 + 3 + 5 + 23, +		.vrefresh = 60, +		.flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC, +	}, { +		.clock = 110920, +		.hdisplay = 1920, +		.hsync_start = 1920 + 48, +		.hsync_end = 1920 + 48 + 32, +		.htotal = 1920 + 48 + 32 + 80, +		.vdisplay = 1080, +		.vsync_start = 1080 + 3, +		.vsync_end = 1080 + 3 + 5, +		.vtotal = 1080 + 3 + 5 + 23, +		.vrefresh = 48, +		.flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC, +	} +}; + +static const struct panel_desc neweast_wjfh116008a = { +	.modes = neweast_wjfh116008a_modes, +	.num_modes = 2, +	.bpc = 6, +	.size = { +		.width = 260, +		.height = 150, +	}, +	.delay = { +		.prepare = 110, +		.enable = 20, +		.unprepare = 500, +	}, +	.bus_format = MEDIA_BUS_FMT_RGB666_1X18, +	.connector_type = DRM_MODE_CONNECTOR_eDP, +}; +  static const struct drm_display_mode newhaven_nhd_43_480272ef_atxl_mode = {  	.clock = 9000,  	.hdisplay = 480, @@ -2390,15 +2617,15 @@ static const struct panel_desc ontat_yx700wv03 = {  };  static const struct drm_display_mode ortustech_com37h3m_mode  = { -	.clock = 22153, +	.clock = 22230,  	.hdisplay = 480, -	.hsync_start = 480 + 8, -	.hsync_end = 480 + 8 + 10, -	.htotal = 480 + 8 + 10 + 10, +	.hsync_start = 480 + 40, +	.hsync_end = 480 + 40 + 10, +	.htotal = 480 + 40 + 10 + 40,  	.vdisplay = 640,  	.vsync_start = 640 + 4, -	.vsync_end = 640 + 4 + 3, -	.vtotal = 640 + 4 + 3 + 4, +	.vsync_end = 640 + 4 + 2, +	.vtotal = 640 + 4 + 2 + 4,  	.vrefresh = 60,  	.flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,  }; @@ -2439,6 +2666,7 @@ static const struct panel_desc ortustech_com43h4m85ulc = {  	},  	.bus_format = MEDIA_BUS_FMT_RGB888_1X24,  	.bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE, +	.connector_type = DRM_MODE_CONNECTOR_DPI,  };  static const struct drm_display_mode osddisplays_osd070t1718_19ts_mode  = { @@ -2464,7 +2692,8 @@ static const struct panel_desc osddisplays_osd070t1718_19ts = {  		.height = 91,  	},  	.bus_format = MEDIA_BUS_FMT_RGB888_1X24, -	.bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE, +	.bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE | +		DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE,  	.connector_type = DRM_MODE_CONNECTOR_DPI,  }; @@ -2546,6 +2775,35 @@ static const struct panel_desc rocktech_rk070er9427 = {  	.bus_format = MEDIA_BUS_FMT_RGB666_1X18,  }; +static const struct drm_display_mode rocktech_rk101ii01d_ct_mode = { +	.clock = 71100, +	.hdisplay = 1280, +	.hsync_start = 1280 + 48, +	.hsync_end = 1280 + 48 + 32, +	.htotal = 1280 + 48 + 32 + 80, +	.vdisplay = 800, +	.vsync_start = 800 + 2, +	.vsync_end = 800 + 2 + 5, +	.vtotal = 800 + 2 + 5 + 16, +	.vrefresh = 60, +}; + +static const struct panel_desc rocktech_rk101ii01d_ct = { +	.modes = &rocktech_rk101ii01d_ct_mode, +	.num_modes = 1, +	.size = { +		.width = 217, +		.height = 136, +	}, +	.delay = { +		.prepare = 50, +		.disable = 50, +	}, +	.bus_flags = DRM_BUS_FLAG_DE_HIGH, +	.bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG, +	.connector_type = DRM_MODE_CONNECTOR_LVDS, +}; +  static const struct drm_display_mode samsung_lsn122dl01_c01_mode = {  	.clock = 271560,  	.hdisplay = 2560, @@ -2768,30 +3026,6 @@ static const struct panel_desc sharp_lq123p1jx31 = {  	},  }; -static const struct drm_display_mode sharp_lq150x1lg11_mode = { -	.clock = 71100, -	.hdisplay = 1024, -	.hsync_start = 1024 + 168, -	.hsync_end = 1024 + 168 + 64, -	.htotal = 1024 + 168 + 64 + 88, -	.vdisplay = 768, -	.vsync_start = 768 + 37, -	.vsync_end = 768 + 37 + 2, -	.vtotal = 768 + 37 + 2 + 8, -	.vrefresh = 60, -}; - -static const struct panel_desc sharp_lq150x1lg11 = { -	.modes = &sharp_lq150x1lg11_mode, -	.num_modes = 1, -	.bpc = 6, -	.size = { -		.width = 304, -		.height = 228, -	}, -	.bus_format = MEDIA_BUS_FMT_RGB565_1X16, -}; -  static const struct display_timing sharp_ls020b1dd01d_timing = {  	.pixelclock = { 2000000, 4200000, 5000000 },  	.hactive = { 240, 240, 240 }, @@ -3023,7 +3257,7 @@ static const struct panel_desc toshiba_lt089ac29000 = {  		.width = 194,  		.height = 116,  	}, -	.bus_format = MEDIA_BUS_FMT_RGB888_1X24, +	.bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA,  	.bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE,  	.connector_type = DRM_MODE_CONNECTOR_LVDS,  }; @@ -3286,6 +3520,9 @@ static const struct of_device_id platform_of_match[] = {  		.compatible = "edt,et035012dm6",  		.data = &edt_et035012dm6,  	}, { +		.compatible = "edt,etm043080dh6gp", +		.data = &edt_etm043080dh6gp, +	}, {  		.compatible = "edt,etm0430g0dh6",  		.data = &edt_etm0430g0dh6,  	}, { @@ -3310,6 +3547,9 @@ static const struct of_device_id platform_of_match[] = {  		.compatible = "foxlink,fl500wvr00-a0t",  		.data = &foxlink_fl500wvr00_a0t,  	}, { +		.compatible = "frida,frd350h54004", +		.data = &frida_frd350h54004, +	}, {  		.compatible = "friendlyarm,hd702e",  		.data = &friendlyarm_hd702e,  	}, { @@ -3388,6 +3628,15 @@ static const struct of_device_id platform_of_match[] = {  		.compatible = "logicpd,type28",  		.data = &logicpd_type_28,  	}, { +		.compatible = "logictechno,lt161010-2nhc", +		.data = &logictechno_lt161010_2nh, +	}, { +		.compatible = "logictechno,lt161010-2nhr", +		.data = &logictechno_lt161010_2nh, +	}, { +		.compatible = "logictechno,lt170410-2whc", +		.data = &logictechno_lt170410_2whc, +	}, {  		.compatible = "mitsubishi,aa070mc01-ca1",  		.data = &mitsubishi_aa070mc01,  	}, { @@ -3400,6 +3649,9 @@ static const struct of_device_id platform_of_match[] = {  		.compatible = "netron-dy,e231732",  		.data = &netron_dy_e231732,  	}, { +		.compatible = "neweast,wjfh116008a", +		.data = &neweast_wjfh116008a, +	}, {  		.compatible = "newhaven,nhd-4.3-480272ef-atxl",  		.data = &newhaven_nhd_43_480272ef_atxl,  	}, { @@ -3439,6 +3691,9 @@ static const struct of_device_id platform_of_match[] = {  		.compatible = "rocktech,rk070er9427",  		.data = &rocktech_rk070er9427,  	}, { +		.compatible = "rocktech,rk101ii01d-ct", +		.data = &rocktech_rk101ii01d_ct, +	}, {  		.compatible = "samsung,lsn122dl01-c01",  		.data = &samsung_lsn122dl01_c01,  	}, { @@ -3466,9 +3721,6 @@ static const struct of_device_id platform_of_match[] = {  		.compatible = "sharp,lq123p1jx31",  		.data = &sharp_lq123p1jx31,  	}, { -		.compatible = "sharp,lq150x1lg11", -		.data = &sharp_lq150x1lg11, -	}, {  		.compatible = "sharp,ls020b1dd01d",  		.data = &sharp_ls020b1dd01d,  	}, { @@ -3526,6 +3778,10 @@ static const struct of_device_id platform_of_match[] = {  		.compatible = "winstar,wf35ltiacd",  		.data = &winstar_wf35ltiacd,  	}, { +		/* Must be the last entry */ +		.compatible = "panel-dpi", +		.data = &panel_dpi, +	}, {  		/* sentinel */  	}  }; diff --git a/drivers/gpu/drm/panel/panel-sony-acx424akp.c b/drivers/gpu/drm/panel/panel-sony-acx424akp.c index de0abf76ae6f..c91e55b2d7a3 100644 --- a/drivers/gpu/drm/panel/panel-sony-acx424akp.c +++ b/drivers/gpu/drm/panel/panel-sony-acx424akp.c @@ -48,7 +48,7 @@ struct acx424akp {  };  static const struct drm_display_mode sony_acx424akp_vid_mode = { -	.clock = 330000, +	.clock = 27234,  	.hdisplay = 480,  	.hsync_start = 480 + 15,  	.hsync_end = 480 + 15 + 0, @@ -68,7 +68,7 @@ static const struct drm_display_mode sony_acx424akp_vid_mode = {   * command mode using the maximum HS frequency.   */  static const struct drm_display_mode sony_acx424akp_cmd_mode = { -	.clock = 420160, +	.clock = 35478,  	.hdisplay = 480,  	.hsync_start = 480 + 154,  	.hsync_end = 480 + 154 + 16, diff --git a/drivers/gpu/drm/panel/panel-tpo-td028ttec1.c b/drivers/gpu/drm/panel/panel-tpo-td028ttec1.c index cf29405a2dbe..aeca15dfeb3c 100644 --- a/drivers/gpu/drm/panel/panel-tpo-td028ttec1.c +++ b/drivers/gpu/drm/panel/panel-tpo-td028ttec1.c @@ -86,7 +86,12 @@ struct td028ttec1_panel {  #define to_td028ttec1_device(p) container_of(p, struct td028ttec1_panel, panel) -static int jbt_ret_write_0(struct td028ttec1_panel *lcd, u8 reg, int *err) +/* + * noinline_for_stack so we don't get multiple copies of tx_buf + * on the stack in case of gcc-plugin-structleak + */ +static int noinline_for_stack +jbt_ret_write_0(struct td028ttec1_panel *lcd, u8 reg, int *err)  {  	struct spi_device *spi = lcd->spi;  	u16 tx_buf = JBT_COMMAND | reg; @@ -105,8 +110,9 @@ static int jbt_ret_write_0(struct td028ttec1_panel *lcd, u8 reg, int *err)  	return ret;  } -static int jbt_reg_write_1(struct td028ttec1_panel *lcd, -			   u8 reg, u8 data, int *err) +static int noinline_for_stack +jbt_reg_write_1(struct td028ttec1_panel *lcd, +		u8 reg, u8 data, int *err)  {  	struct spi_device *spi = lcd->spi;  	u16 tx_buf[2]; @@ -128,8 +134,9 @@ static int jbt_reg_write_1(struct td028ttec1_panel *lcd,  	return ret;  } -static int jbt_reg_write_2(struct td028ttec1_panel *lcd, -			   u8 reg, u16 data, int *err) +static int noinline_for_stack +jbt_reg_write_2(struct td028ttec1_panel *lcd, +		u8 reg, u16 data, int *err)  {  	struct spi_device *spi = lcd->spi;  	u16 tx_buf[3]; |