Re: [PATCH v3 6/9] drm/panel: Add driver for the Sharp LS037V7DW01 panel
On Tue, Aug 13, 2019 at 04:33:08PM +0300, Laurent Pinchart wrote: > This panel is used on the TI SDP3430 board. > > The code is based on the omapdrm-specific panel-sharp-ls037v7dw01 > driver. > > Signed-off-by: Laurent Pinchart Reviewed-by: Sam Ravnborg > --- > Changes since v1: > > - Mention boards using the panel in Kconfig > - Renamed ls037v7dw01_device to ls037v7dw01_panel > - Renamed vcc to vdd > - Comments updates > - Store width_mm and height_mm in drm_display_mode > - Use drm_panel_disable() in .remove() handler > - Use devm_gpiod_get() where applicable > - Remove NULL-check on vdd > - Order Kconfig entries alphabetically > --- > drivers/gpu/drm/panel/Kconfig | 7 + > drivers/gpu/drm/panel/Makefile| 1 + > .../gpu/drm/panel/panel-sharp-ls037v7dw01.c | 226 ++ > 3 files changed, 234 insertions(+) > create mode 100644 drivers/gpu/drm/panel/panel-sharp-ls037v7dw01.c > > diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig > index d28133c6aa0a..8d9a8cdb704e 100644 > --- a/drivers/gpu/drm/panel/Kconfig > +++ b/drivers/gpu/drm/panel/Kconfig > @@ -282,6 +282,13 @@ config DRM_PANEL_SHARP_LQ101R1SX01 > To compile this driver as a module, choose M here: the module > will be called panel-sharp-lq101r1sx01. > > +config DRM_PANEL_SHARP_LS037V7DW01 > + tristate "Sharp LS037V7DW01 VGA LCD panel" > + depends on GPIOLIB && OF && REGULATOR > + help > + Say Y here if you want to enable support for Sharp LS037V7DW01 VGA > + (480x640) LCD panel (found on the TI SDP3430 board). > + > config DRM_PANEL_SHARP_LS043T1LE01 > tristate "Sharp LS043T1LE01 qHD video mode panel" > depends on OF > diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile > index 8052f9a7ad60..14d1c49ef3ab 100644 > --- a/drivers/gpu/drm/panel/Makefile > +++ b/drivers/gpu/drm/panel/Makefile > @@ -29,6 +29,7 @@ obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0) += > panel-samsung-s6e63m0.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 > +obj-$(CONFIG_DRM_PANEL_SHARP_LS037V7DW01) += panel-sharp-ls037v7dw01.o > obj-$(CONFIG_DRM_PANEL_SHARP_LS043T1LE01) += panel-sharp-ls043t1le01.o > obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7701) += panel-sitronix-st7701.o > obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o > diff --git a/drivers/gpu/drm/panel/panel-sharp-ls037v7dw01.c > b/drivers/gpu/drm/panel/panel-sharp-ls037v7dw01.c > new file mode 100644 > index ..2aaea507cc1f > --- /dev/null > +++ b/drivers/gpu/drm/panel/panel-sharp-ls037v7dw01.c > @@ -0,0 +1,226 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Sharp LS037V7DW01 LCD Panel Driver > + * > + * Copyright (C) 2019 Texas Instruments Incorporated > + * > + * Based on the omapdrm-specific panel-sharp-ls037v7dw01 driver > + * > + * Copyright (C) 2013 Texas Instruments Incorporated > + * Author: Tomi Valkeinen > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > + > +struct ls037v7dw01_panel { > + struct drm_panel panel; > + struct platform_device *pdev; > + > + struct regulator *vdd; > + struct gpio_desc *resb_gpio;/* low = reset active min 20 us */ > + struct gpio_desc *ini_gpio; /* high = power on */ > + struct gpio_desc *mo_gpio; /* low = 480x640, high = 240x320 */ > + struct gpio_desc *lr_gpio; /* high = conventional horizontal > scanning */ > + struct gpio_desc *ud_gpio; /* high = conventional vertical > scanning */ > +}; > + > +#define to_ls037v7dw01_device(p) \ > + container_of(p, struct ls037v7dw01_panel, panel) > + > +static int ls037v7dw01_disable(struct drm_panel *panel) > +{ > + struct ls037v7dw01_panel *lcd = to_ls037v7dw01_device(panel); > + > + gpiod_set_value_cansleep(lcd->ini_gpio, 0); > + gpiod_set_value_cansleep(lcd->resb_gpio, 0); > + > + /* Wait at least 5 vsyncs after disabling the LCD. */ > + msleep(100); > + > + return 0; > +} > + > +static int ls037v7dw01_unprepare(struct drm_panel *panel) > +{ > + struct ls037v7dw01_panel *lcd = to_ls037v7dw01_device(panel); > + > + regulator_disable(lcd->vdd); > + return 0; > +} > + > +static int ls037v7dw01_prepare(struct drm_panel *panel) > +{ > + struct ls037v7dw01_panel *lcd = to_ls037v7dw01_device(panel); > + int ret; > + > + ret = regulator_enable(lcd->vdd); > + if (ret < 0) > + dev_err(&lcd->pdev->dev, "%s: failed to enable regulator\n", > + __func__); > + > + return ret; > +} > + > +static int ls037v7dw01_enable(struct drm_panel *panel) > +{ > + struct ls037v7dw01_panel *lcd = to_ls037v7dw01_device(panel); > + > + /* Wait couple of vsyncs before enabling the LCD. *
[PATCH v3 6/9] drm/panel: Add driver for the Sharp LS037V7DW01 panel
This panel is used on the TI SDP3430 board. The code is based on the omapdrm-specific panel-sharp-ls037v7dw01 driver. Signed-off-by: Laurent Pinchart --- Changes since v1: - Mention boards using the panel in Kconfig - Renamed ls037v7dw01_device to ls037v7dw01_panel - Renamed vcc to vdd - Comments updates - Store width_mm and height_mm in drm_display_mode - Use drm_panel_disable() in .remove() handler - Use devm_gpiod_get() where applicable - Remove NULL-check on vdd - Order Kconfig entries alphabetically --- drivers/gpu/drm/panel/Kconfig | 7 + drivers/gpu/drm/panel/Makefile| 1 + .../gpu/drm/panel/panel-sharp-ls037v7dw01.c | 226 ++ 3 files changed, 234 insertions(+) create mode 100644 drivers/gpu/drm/panel/panel-sharp-ls037v7dw01.c diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig index d28133c6aa0a..8d9a8cdb704e 100644 --- a/drivers/gpu/drm/panel/Kconfig +++ b/drivers/gpu/drm/panel/Kconfig @@ -282,6 +282,13 @@ config DRM_PANEL_SHARP_LQ101R1SX01 To compile this driver as a module, choose M here: the module will be called panel-sharp-lq101r1sx01. +config DRM_PANEL_SHARP_LS037V7DW01 + tristate "Sharp LS037V7DW01 VGA LCD panel" + depends on GPIOLIB && OF && REGULATOR + help + Say Y here if you want to enable support for Sharp LS037V7DW01 VGA + (480x640) LCD panel (found on the TI SDP3430 board). + config DRM_PANEL_SHARP_LS043T1LE01 tristate "Sharp LS043T1LE01 qHD video mode panel" depends on OF diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile index 8052f9a7ad60..14d1c49ef3ab 100644 --- a/drivers/gpu/drm/panel/Makefile +++ b/drivers/gpu/drm/panel/Makefile @@ -29,6 +29,7 @@ obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6E63M0) += panel-samsung-s6e63m0.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 +obj-$(CONFIG_DRM_PANEL_SHARP_LS037V7DW01) += panel-sharp-ls037v7dw01.o obj-$(CONFIG_DRM_PANEL_SHARP_LS043T1LE01) += panel-sharp-ls043t1le01.o obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7701) += panel-sitronix-st7701.o obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o diff --git a/drivers/gpu/drm/panel/panel-sharp-ls037v7dw01.c b/drivers/gpu/drm/panel/panel-sharp-ls037v7dw01.c new file mode 100644 index ..2aaea507cc1f --- /dev/null +++ b/drivers/gpu/drm/panel/panel-sharp-ls037v7dw01.c @@ -0,0 +1,226 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Sharp LS037V7DW01 LCD Panel Driver + * + * Copyright (C) 2019 Texas Instruments Incorporated + * + * Based on the omapdrm-specific panel-sharp-ls037v7dw01 driver + * + * Copyright (C) 2013 Texas Instruments Incorporated + * Author: Tomi Valkeinen + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +struct ls037v7dw01_panel { + struct drm_panel panel; + struct platform_device *pdev; + + struct regulator *vdd; + struct gpio_desc *resb_gpio;/* low = reset active min 20 us */ + struct gpio_desc *ini_gpio; /* high = power on */ + struct gpio_desc *mo_gpio; /* low = 480x640, high = 240x320 */ + struct gpio_desc *lr_gpio; /* high = conventional horizontal scanning */ + struct gpio_desc *ud_gpio; /* high = conventional vertical scanning */ +}; + +#define to_ls037v7dw01_device(p) \ + container_of(p, struct ls037v7dw01_panel, panel) + +static int ls037v7dw01_disable(struct drm_panel *panel) +{ + struct ls037v7dw01_panel *lcd = to_ls037v7dw01_device(panel); + + gpiod_set_value_cansleep(lcd->ini_gpio, 0); + gpiod_set_value_cansleep(lcd->resb_gpio, 0); + + /* Wait at least 5 vsyncs after disabling the LCD. */ + msleep(100); + + return 0; +} + +static int ls037v7dw01_unprepare(struct drm_panel *panel) +{ + struct ls037v7dw01_panel *lcd = to_ls037v7dw01_device(panel); + + regulator_disable(lcd->vdd); + return 0; +} + +static int ls037v7dw01_prepare(struct drm_panel *panel) +{ + struct ls037v7dw01_panel *lcd = to_ls037v7dw01_device(panel); + int ret; + + ret = regulator_enable(lcd->vdd); + if (ret < 0) + dev_err(&lcd->pdev->dev, "%s: failed to enable regulator\n", + __func__); + + return ret; +} + +static int ls037v7dw01_enable(struct drm_panel *panel) +{ + struct ls037v7dw01_panel *lcd = to_ls037v7dw01_device(panel); + + /* Wait couple of vsyncs before enabling the LCD. */ + msleep(50); + + gpiod_set_value_cansleep(lcd->resb_gpio, 1); + gpiod_set_value_cansleep(lcd->ini_gpio, 1); + + return 0; +} + +static const struct drm_display_mode ls037v7dw01_mode = { + .clock = 19200, + .hdisplay = 480, + .hsync_start = 480 + 1, + .hsy