Re: [PATCH v4 2/4] drm/panel: Add panel driver for NewVision NV3052C based LCDs

2022-03-21 Thread Christophe Branchereau
Hi Paul

On Mon, Mar 14, 2022 at 8:54 PM Paul Cercueil  wrote:
>
> Hi Christophe,
>
> Le ven., mars 11 2022 at 18:02:38 +0100, Christophe Branchereau
>  a écrit :
> > This driver supports the NewVision NV3052C based LCDs. Right now, it
> > only supports the LeadTek LTK035C5444T 2.4" 640x480 TFT LCD panel,
> > which
> > can be found in the Anbernic RG-350M handheld console.
> >
> > Signed-off-by: Christophe Branchereau 
> > ---
> >  drivers/gpu/drm/panel/Kconfig |   9 +
> >  drivers/gpu/drm/panel/Makefile|   1 +
> >  .../gpu/drm/panel/panel-newvision-nv3052c.c   | 497
> > ++
> >  3 files changed, 507 insertions(+)
> >  create mode 100644 drivers/gpu/drm/panel/panel-newvision-nv3052c.c
> >
> > diff --git a/drivers/gpu/drm/panel/Kconfig
> > b/drivers/gpu/drm/panel/Kconfig
> > index bb2e47229c68..40084f709789 100644
> > --- a/drivers/gpu/drm/panel/Kconfig
> > +++ b/drivers/gpu/drm/panel/Kconfig
> > @@ -283,6 +283,15 @@ 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_NEWVISION_NV3052C
> > + tristate "NewVision NV3052C RGB/SPI panel"
> > + depends on OF && SPI
> > + depends on BACKLIGHT_CLASS_DEVICE
> > + select DRM_MIPI_DBI
> > + help
> > +   Say Y here if you want to enable support for the panels built
> > +   around the NewVision NV3052C display controller.
> > +
> >  config DRM_PANEL_NOVATEK_NT35510
> >   tristate "Novatek NT35510 RGB panel driver"
> >   depends on OF
> > diff --git a/drivers/gpu/drm/panel/Makefile
> > b/drivers/gpu/drm/panel/Makefile
> > index 5740911f637c..42a7ab54234b 100644
> > --- a/drivers/gpu/drm/panel/Makefile
> > +++ b/drivers/gpu/drm/panel/Makefile
> > @@ -26,6 +26,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_NEWVISION_NV3052C) +=
> > panel-newvision-nv3052c.o
> >  obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35510) += panel-novatek-nt35510.o
> >  obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35560) += panel-novatek-nt35560.o
> >  obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35950) += panel-novatek-nt35950.o
> > diff --git a/drivers/gpu/drm/panel/panel-newvision-nv3052c.c
> > b/drivers/gpu/drm/panel/panel-newvision-nv3052c.c
> > new file mode 100644
> > index ..fc31df0dee12
> > --- /dev/null
> > +++ b/drivers/gpu/drm/panel/panel-newvision-nv3052c.c
> > @@ -0,0 +1,497 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * NevVision NV3052C IPS LCD panel driver
>
> NewVision*
>
> > + *
> > + * Copyright (C) 2020, Paul Cercueil 
> > + * Copyright (C) 2022, Christophe Branchereau
> > 
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +struct nv3052c_panel_info {
> > + const struct drm_display_mode *display_modes;
> > + unsigned int num_modes;
> > + u16 width_mm, height_mm;
> > + u32 bus_format, bus_flags;
> > +};
> > +
> > +struct nv3052c {
> > + struct device *dev;
> > + struct drm_panel panel;
> > + struct mipi_dbi dbi;
> > +
> > + const struct nv3052c_panel_info *panel_info;
> > +
> > + struct regulator *supply;
> > + struct gpio_desc *reset_gpio;
> > +};
> > +
> > +struct nv3052c_reg {
> > + u8 cmd;
> > + u8 val;
> > +};
> > +
> > +static const struct nv3052c_reg nv3052c_panel_regs[] = {
> > + { 0xff, 0x30 },
> > + { 0xff, 0x52 },
> > + { 0xff, 0x01 },
> > + { 0xe3, 0x00 },
> > + { 0x40, 0x00 },
> > + { 0x03, 0x40 },
> > + { 0x04, 0x00 },
> > + { 0x05, 0x03 },
> > + { 0x08, 0x00 },
> > + { 0x09, 0x07 },
> > + { 0x0a, 0x01 },
> > + { 0x0b, 0x32 },
> > + { 0x0c, 0x32 },
> > + { 0x0d, 0x0b },
> > + { 0x0e, 0x00 },
> > + { 0x23, 0xa0 },
> > +
> > + { 0x24, 0x0c },
> > + { 0x25, 0x06 },
> > + { 0x26, 0x14 },
> > + { 0x27, 0x14 },
> > +
> > + { 0x38, 0xcc },
> > + { 0x39, 0xd7 },
> > + { 0x3a, 0x4a },
> > +
> > + { 0x28, 0x40 },
> > + { 0x29, 0x01 },
> > + { 0x2a, 0xdf },
> > + { 0x49, 0x3c },
> > + { 0x91, 0x77 },
> > + { 0x92, 0x77 },
> > + { 0xa0, 0x55 },
> > + { 0xa1, 0x50 },
> > + { 0xa4, 0x9c },
> > + { 0xa7, 0x02 },
> > + { 0xa8, 0x01 },
> > + { 0xa9, 0x01 },
> > + { 0xaa, 0xfc },
> > + { 0xab, 0x28 },
> > + { 0xac, 0x06 },
> > + { 0xad, 0x06 },
> > + { 0xae, 0x06 },
> > + { 0xaf, 0x03 },
> > + { 0xb0, 0x08 },
> > + { 0xb1, 0x26 },
> > + { 0xb2, 0x28 },
> > + { 0xb3, 0x28 },
> > + { 0xb4, 0x33 },
> > + { 0xb5, 0x08 },
> > + { 

Re: [PATCH v4 2/4] drm/panel: Add panel driver for NewVision NV3052C based LCDs

2022-03-21 Thread Sam Ravnborg
Hi Christophe,

> > > + { 0x0d, 0x58 },
> > > + { 0x0e, 0x48 },
> > > + { 0x0f, 0x38 },
> > > + { 0x10, 0x2b },
> > > +
> > > + { 0xff, 0x30 },
> > > + { 0xff, 0x52 },
> > > + { 0xff, 0x00 },
> > > + { 0x36, 0x0a },
> > > +};
> > There are some random (?) empty lines.
> > If they have any significance then a short comment would be nice.
> > If not, then drop the empty lines.
> >
> 
> The empty lines are not random no, to access a different page in the
> init, one must write i.e.   { 0xff, 0x30 }, { 0xff, 0x52 }, { 0xff,
> 0x02 }, to access page 2, so they add a little bit of readability.
Then I suggest to just say what page is is like:

/* Page 1 */
{ 0xff, 0x30 },
...

Etc. then it is obvious this is page boundaries.

Sam


Re: [PATCH v4 2/4] drm/panel: Add panel driver for NewVision NV3052C based LCDs

2022-03-21 Thread Christophe Branchereau
Hello Sam

On Tue, Mar 15, 2022 at 9:23 PM Sam Ravnborg  wrote:
>
> Hi Christophe,
> On Fri, Mar 11, 2022 at 06:02:38PM +0100, Christophe Branchereau wrote:
> > This driver supports the NewVision NV3052C based LCDs. Right now, it
> > only supports the LeadTek LTK035C5444T 2.4" 640x480 TFT LCD panel, which
> > can be found in the Anbernic RG-350M handheld console.
>
> I had to get away from my day-time job and you were the lucky winner.
> A couple of comments in the following that you can address now or later.
>
> >
> > Signed-off-by: Christophe Branchereau 
> Reviewed-by: Sam Ravnborg 
> > ---
> >  drivers/gpu/drm/panel/Kconfig |   9 +
> >  drivers/gpu/drm/panel/Makefile|   1 +
> >  .../gpu/drm/panel/panel-newvision-nv3052c.c   | 497 ++
> >  3 files changed, 507 insertions(+)
> >  create mode 100644 drivers/gpu/drm/panel/panel-newvision-nv3052c.c
> >
> > diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> > index bb2e47229c68..40084f709789 100644
> > --- a/drivers/gpu/drm/panel/Kconfig
> > +++ b/drivers/gpu/drm/panel/Kconfig
> > @@ -283,6 +283,15 @@ 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_NEWVISION_NV3052C
> > + tristate "NewVision NV3052C RGB/SPI panel"
> > + depends on OF && SPI
> > + depends on BACKLIGHT_CLASS_DEVICE
> > + select DRM_MIPI_DBI
> > + help
> > +   Say Y here if you want to enable support for the panels built
> > +   around the NewVision NV3052C display controller.
> > +
> >  config DRM_PANEL_NOVATEK_NT35510
> >   tristate "Novatek NT35510 RGB panel driver"
> >   depends on OF
> > diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> > index 5740911f637c..42a7ab54234b 100644
> > --- a/drivers/gpu/drm/panel/Makefile
> > +++ b/drivers/gpu/drm/panel/Makefile
> > @@ -26,6 +26,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_NEWVISION_NV3052C) += panel-newvision-nv3052c.o
> >  obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35510) += panel-novatek-nt35510.o
> >  obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35560) += panel-novatek-nt35560.o
> >  obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35950) += panel-novatek-nt35950.o
> > diff --git a/drivers/gpu/drm/panel/panel-newvision-nv3052c.c 
> > b/drivers/gpu/drm/panel/panel-newvision-nv3052c.c
> > new file mode 100644
> > index ..fc31df0dee12
> > --- /dev/null
> > +++ b/drivers/gpu/drm/panel/panel-newvision-nv3052c.c
> > @@ -0,0 +1,497 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * NevVision NV3052C IPS LCD panel driver
> > + *
> > + * Copyright (C) 2020, Paul Cercueil 
> > + * Copyright (C) 2022, Christophe Branchereau 
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +struct nv3052c_panel_info {
> > + const struct drm_display_mode *display_modes;
> > + unsigned int num_modes;
> > + u16 width_mm, height_mm;
> > + u32 bus_format, bus_flags;
> > +};
> > +
> > +struct nv3052c {
> > + struct device *dev;
> > + struct drm_panel panel;
> > + struct mipi_dbi dbi;
> > +
> > + const struct nv3052c_panel_info *panel_info;
> > +
> > + struct regulator *supply;
> > + struct gpio_desc *reset_gpio;
> > +};
> > +
> > +struct nv3052c_reg {
> > + u8 cmd;
> > + u8 val;
> > +};
> > +
> > +static const struct nv3052c_reg nv3052c_panel_regs[] = {
> > + { 0xff, 0x30 },
> > + { 0xff, 0x52 },
> > + { 0xff, 0x01 },
> > + { 0xe3, 0x00 },
> > + { 0x40, 0x00 },
> > + { 0x03, 0x40 },
> > + { 0x04, 0x00 },
> > + { 0x05, 0x03 },
> > + { 0x08, 0x00 },
> > + { 0x09, 0x07 },
> > + { 0x0a, 0x01 },
> > + { 0x0b, 0x32 },
> > + { 0x0c, 0x32 },
> > + { 0x0d, 0x0b },
> > + { 0x0e, 0x00 },
> > + { 0x23, 0xa0 },
> > +
> > + { 0x24, 0x0c },
> > + { 0x25, 0x06 },
> > + { 0x26, 0x14 },
> > + { 0x27, 0x14 },
> > +
> > + { 0x38, 0xcc },
> > + { 0x39, 0xd7 },
> > + { 0x3a, 0x4a },
> > +
> > + { 0x28, 0x40 },
> > + { 0x29, 0x01 },
> > + { 0x2a, 0xdf },
> > + { 0x49, 0x3c },
> > + { 0x91, 0x77 },
> > + { 0x92, 0x77 },
> > + { 0xa0, 0x55 },
> > + { 0xa1, 0x50 },
> > + { 0xa4, 0x9c },
> > + { 0xa7, 0x02 },
> > + { 0xa8, 0x01 },
> > + { 0xa9, 0x01 },
> > + { 0xaa, 0xfc },
> > + { 0xab, 0x28 },
> > + { 0xac, 0x06 },
> > + { 0xad, 0x06 },
> > + { 0xae, 0x06 },
> > + { 0xaf, 0x03 },
> > + { 0xb0, 0x08 },
> > + { 

Re: [PATCH v4 2/4] drm/panel: Add panel driver for NewVision NV3052C based LCDs

2022-03-15 Thread Sam Ravnborg
Hi Christophe,
On Fri, Mar 11, 2022 at 06:02:38PM +0100, Christophe Branchereau wrote:
> This driver supports the NewVision NV3052C based LCDs. Right now, it
> only supports the LeadTek LTK035C5444T 2.4" 640x480 TFT LCD panel, which
> can be found in the Anbernic RG-350M handheld console.

I had to get away from my day-time job and you were the lucky winner.
A couple of comments in the following that you can address now or later.

> 
> Signed-off-by: Christophe Branchereau 
Reviewed-by: Sam Ravnborg 
> ---
>  drivers/gpu/drm/panel/Kconfig |   9 +
>  drivers/gpu/drm/panel/Makefile|   1 +
>  .../gpu/drm/panel/panel-newvision-nv3052c.c   | 497 ++
>  3 files changed, 507 insertions(+)
>  create mode 100644 drivers/gpu/drm/panel/panel-newvision-nv3052c.c
> 
> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> index bb2e47229c68..40084f709789 100644
> --- a/drivers/gpu/drm/panel/Kconfig
> +++ b/drivers/gpu/drm/panel/Kconfig
> @@ -283,6 +283,15 @@ 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_NEWVISION_NV3052C
> + tristate "NewVision NV3052C RGB/SPI panel"
> + depends on OF && SPI
> + depends on BACKLIGHT_CLASS_DEVICE
> + select DRM_MIPI_DBI
> + help
> +   Say Y here if you want to enable support for the panels built
> +   around the NewVision NV3052C display controller.
> +
>  config DRM_PANEL_NOVATEK_NT35510
>   tristate "Novatek NT35510 RGB panel driver"
>   depends on OF
> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> index 5740911f637c..42a7ab54234b 100644
> --- a/drivers/gpu/drm/panel/Makefile
> +++ b/drivers/gpu/drm/panel/Makefile
> @@ -26,6 +26,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_NEWVISION_NV3052C) += panel-newvision-nv3052c.o
>  obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35510) += panel-novatek-nt35510.o
>  obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35560) += panel-novatek-nt35560.o
>  obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35950) += panel-novatek-nt35950.o
> diff --git a/drivers/gpu/drm/panel/panel-newvision-nv3052c.c 
> b/drivers/gpu/drm/panel/panel-newvision-nv3052c.c
> new file mode 100644
> index ..fc31df0dee12
> --- /dev/null
> +++ b/drivers/gpu/drm/panel/panel-newvision-nv3052c.c
> @@ -0,0 +1,497 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * NevVision NV3052C IPS LCD panel driver
> + *
> + * Copyright (C) 2020, Paul Cercueil 
> + * Copyright (C) 2022, Christophe Branchereau 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +struct nv3052c_panel_info {
> + const struct drm_display_mode *display_modes;
> + unsigned int num_modes;
> + u16 width_mm, height_mm;
> + u32 bus_format, bus_flags;
> +};
> +
> +struct nv3052c {
> + struct device *dev;
> + struct drm_panel panel;
> + struct mipi_dbi dbi;
> +
> + const struct nv3052c_panel_info *panel_info;
> +
> + struct regulator *supply;
> + struct gpio_desc *reset_gpio;
> +};
> +
> +struct nv3052c_reg {
> + u8 cmd;
> + u8 val;
> +};
> +
> +static const struct nv3052c_reg nv3052c_panel_regs[] = {
> + { 0xff, 0x30 },
> + { 0xff, 0x52 },
> + { 0xff, 0x01 },
> + { 0xe3, 0x00 },
> + { 0x40, 0x00 },
> + { 0x03, 0x40 },
> + { 0x04, 0x00 },
> + { 0x05, 0x03 },
> + { 0x08, 0x00 },
> + { 0x09, 0x07 },
> + { 0x0a, 0x01 },
> + { 0x0b, 0x32 },
> + { 0x0c, 0x32 },
> + { 0x0d, 0x0b },
> + { 0x0e, 0x00 },
> + { 0x23, 0xa0 },
> +
> + { 0x24, 0x0c },
> + { 0x25, 0x06 },
> + { 0x26, 0x14 },
> + { 0x27, 0x14 },
> +
> + { 0x38, 0xcc },
> + { 0x39, 0xd7 },
> + { 0x3a, 0x4a },
> +
> + { 0x28, 0x40 },
> + { 0x29, 0x01 },
> + { 0x2a, 0xdf },
> + { 0x49, 0x3c },
> + { 0x91, 0x77 },
> + { 0x92, 0x77 },
> + { 0xa0, 0x55 },
> + { 0xa1, 0x50 },
> + { 0xa4, 0x9c },
> + { 0xa7, 0x02 },
> + { 0xa8, 0x01 },
> + { 0xa9, 0x01 },
> + { 0xaa, 0xfc },
> + { 0xab, 0x28 },
> + { 0xac, 0x06 },
> + { 0xad, 0x06 },
> + { 0xae, 0x06 },
> + { 0xaf, 0x03 },
> + { 0xb0, 0x08 },
> + { 0xb1, 0x26 },
> + { 0xb2, 0x28 },
> + { 0xb3, 0x28 },
> + { 0xb4, 0x33 },
> + { 0xb5, 0x08 },
> + { 0xb6, 0x26 },
> + { 0xb7, 0x08 },
> + { 0xb8, 0x26 },
> + { 0xf0, 0x00 },
> + { 0xf6, 0xc0 },
> +
> + { 0xff, 0x30 },
> + { 0xff, 0x52 },
> + { 0xff, 0x02 },
> + { 0xb0, 0x0b },
> + { 0xb1, 0x16 },
> + { 

Re: [PATCH v4 2/4] drm/panel: Add panel driver for NewVision NV3052C based LCDs

2022-03-14 Thread Paul Cercueil

Hi Christophe,

Le ven., mars 11 2022 at 18:02:38 +0100, Christophe Branchereau 
 a écrit :

This driver supports the NewVision NV3052C based LCDs. Right now, it
only supports the LeadTek LTK035C5444T 2.4" 640x480 TFT LCD panel, 
which

can be found in the Anbernic RG-350M handheld console.

Signed-off-by: Christophe Branchereau 
---
 drivers/gpu/drm/panel/Kconfig |   9 +
 drivers/gpu/drm/panel/Makefile|   1 +
 .../gpu/drm/panel/panel-newvision-nv3052c.c   | 497 
++

 3 files changed, 507 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-newvision-nv3052c.c

diff --git a/drivers/gpu/drm/panel/Kconfig 
b/drivers/gpu/drm/panel/Kconfig

index bb2e47229c68..40084f709789 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -283,6 +283,15 @@ 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_NEWVISION_NV3052C
+   tristate "NewVision NV3052C RGB/SPI panel"
+   depends on OF && SPI
+   depends on BACKLIGHT_CLASS_DEVICE
+   select DRM_MIPI_DBI
+   help
+ Say Y here if you want to enable support for the panels built
+ around the NewVision NV3052C display controller.
+
 config DRM_PANEL_NOVATEK_NT35510
tristate "Novatek NT35510 RGB panel driver"
depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile 
b/drivers/gpu/drm/panel/Makefile

index 5740911f637c..42a7ab54234b 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -26,6 +26,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_NEWVISION_NV3052C) += 
panel-newvision-nv3052c.o

 obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35510) += panel-novatek-nt35510.o
 obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35560) += panel-novatek-nt35560.o
 obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35950) += panel-novatek-nt35950.o
diff --git a/drivers/gpu/drm/panel/panel-newvision-nv3052c.c 
b/drivers/gpu/drm/panel/panel-newvision-nv3052c.c

new file mode 100644
index ..fc31df0dee12
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-newvision-nv3052c.c
@@ -0,0 +1,497 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * NevVision NV3052C IPS LCD panel driver


NewVision*


+ *
+ * Copyright (C) 2020, Paul Cercueil 
+ * Copyright (C) 2022, Christophe Branchereau 


+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+struct nv3052c_panel_info {
+   const struct drm_display_mode *display_modes;
+   unsigned int num_modes;
+   u16 width_mm, height_mm;
+   u32 bus_format, bus_flags;
+};
+
+struct nv3052c {
+   struct device *dev;
+   struct drm_panel panel;
+   struct mipi_dbi dbi;
+
+   const struct nv3052c_panel_info *panel_info;
+
+   struct regulator *supply;
+   struct gpio_desc *reset_gpio;
+};
+
+struct nv3052c_reg {
+   u8 cmd;
+   u8 val;
+};
+
+static const struct nv3052c_reg nv3052c_panel_regs[] = {
+   { 0xff, 0x30 },
+   { 0xff, 0x52 },
+   { 0xff, 0x01 },
+   { 0xe3, 0x00 },
+   { 0x40, 0x00 },
+   { 0x03, 0x40 },
+   { 0x04, 0x00 },
+   { 0x05, 0x03 },
+   { 0x08, 0x00 },
+   { 0x09, 0x07 },
+   { 0x0a, 0x01 },
+   { 0x0b, 0x32 },
+   { 0x0c, 0x32 },
+   { 0x0d, 0x0b },
+   { 0x0e, 0x00 },
+   { 0x23, 0xa0 },
+
+   { 0x24, 0x0c },
+   { 0x25, 0x06 },
+   { 0x26, 0x14 },
+   { 0x27, 0x14 },
+
+   { 0x38, 0xcc },
+   { 0x39, 0xd7 },
+   { 0x3a, 0x4a },
+
+   { 0x28, 0x40 },
+   { 0x29, 0x01 },
+   { 0x2a, 0xdf },
+   { 0x49, 0x3c },
+   { 0x91, 0x77 },
+   { 0x92, 0x77 },
+   { 0xa0, 0x55 },
+   { 0xa1, 0x50 },
+   { 0xa4, 0x9c },
+   { 0xa7, 0x02 },
+   { 0xa8, 0x01 },
+   { 0xa9, 0x01 },
+   { 0xaa, 0xfc },
+   { 0xab, 0x28 },
+   { 0xac, 0x06 },
+   { 0xad, 0x06 },
+   { 0xae, 0x06 },
+   { 0xaf, 0x03 },
+   { 0xb0, 0x08 },
+   { 0xb1, 0x26 },
+   { 0xb2, 0x28 },
+   { 0xb3, 0x28 },
+   { 0xb4, 0x33 },
+   { 0xb5, 0x08 },
+   { 0xb6, 0x26 },
+   { 0xb7, 0x08 },
+   { 0xb8, 0x26 },
+   { 0xf0, 0x00 },
+   { 0xf6, 0xc0 },
+
+   { 0xff, 0x30 },
+   { 0xff, 0x52 },
+   { 0xff, 0x02 },
+   { 0xb0, 0x0b },
+   { 0xb1, 0x16 },
+   { 0xb2, 0x17 },
+   { 0xb3, 0x2c },
+   { 0xb4, 0x32 },
+   { 0xb5, 0x3b },
+   { 0xb6, 0x29 },
+   { 0xb7, 0x40 },
+   { 0xb8, 0x0d },
+   { 0xb9, 0x05 },
+   { 0xba, 0x12 },
+   { 0xbb, 0x10 },
+   { 0xbc, 0x12 },
+   { 0xbd, 0x15 },
+   { 0xbe, 0x19 },

[PATCH v4 2/4] drm/panel: Add panel driver for NewVision NV3052C based LCDs

2022-03-11 Thread Christophe Branchereau
This driver supports the NewVision NV3052C based LCDs. Right now, it
only supports the LeadTek LTK035C5444T 2.4" 640x480 TFT LCD panel, which
can be found in the Anbernic RG-350M handheld console.

Signed-off-by: Christophe Branchereau 
---
 drivers/gpu/drm/panel/Kconfig |   9 +
 drivers/gpu/drm/panel/Makefile|   1 +
 .../gpu/drm/panel/panel-newvision-nv3052c.c   | 497 ++
 3 files changed, 507 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-newvision-nv3052c.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index bb2e47229c68..40084f709789 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -283,6 +283,15 @@ 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_NEWVISION_NV3052C
+   tristate "NewVision NV3052C RGB/SPI panel"
+   depends on OF && SPI
+   depends on BACKLIGHT_CLASS_DEVICE
+   select DRM_MIPI_DBI
+   help
+ Say Y here if you want to enable support for the panels built
+ around the NewVision NV3052C display controller.
+
 config DRM_PANEL_NOVATEK_NT35510
tristate "Novatek NT35510 RGB panel driver"
depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 5740911f637c..42a7ab54234b 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -26,6 +26,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_NEWVISION_NV3052C) += panel-newvision-nv3052c.o
 obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35510) += panel-novatek-nt35510.o
 obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35560) += panel-novatek-nt35560.o
 obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35950) += panel-novatek-nt35950.o
diff --git a/drivers/gpu/drm/panel/panel-newvision-nv3052c.c 
b/drivers/gpu/drm/panel/panel-newvision-nv3052c.c
new file mode 100644
index ..fc31df0dee12
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-newvision-nv3052c.c
@@ -0,0 +1,497 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * NevVision NV3052C IPS LCD panel driver
+ *
+ * Copyright (C) 2020, Paul Cercueil 
+ * Copyright (C) 2022, Christophe Branchereau 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+struct nv3052c_panel_info {
+   const struct drm_display_mode *display_modes;
+   unsigned int num_modes;
+   u16 width_mm, height_mm;
+   u32 bus_format, bus_flags;
+};
+
+struct nv3052c {
+   struct device *dev;
+   struct drm_panel panel;
+   struct mipi_dbi dbi;
+
+   const struct nv3052c_panel_info *panel_info;
+
+   struct regulator *supply;
+   struct gpio_desc *reset_gpio;
+};
+
+struct nv3052c_reg {
+   u8 cmd;
+   u8 val;
+};
+
+static const struct nv3052c_reg nv3052c_panel_regs[] = {
+   { 0xff, 0x30 },
+   { 0xff, 0x52 },
+   { 0xff, 0x01 },
+   { 0xe3, 0x00 },
+   { 0x40, 0x00 },
+   { 0x03, 0x40 },
+   { 0x04, 0x00 },
+   { 0x05, 0x03 },
+   { 0x08, 0x00 },
+   { 0x09, 0x07 },
+   { 0x0a, 0x01 },
+   { 0x0b, 0x32 },
+   { 0x0c, 0x32 },
+   { 0x0d, 0x0b },
+   { 0x0e, 0x00 },
+   { 0x23, 0xa0 },
+
+   { 0x24, 0x0c },
+   { 0x25, 0x06 },
+   { 0x26, 0x14 },
+   { 0x27, 0x14 },
+
+   { 0x38, 0xcc },
+   { 0x39, 0xd7 },
+   { 0x3a, 0x4a },
+
+   { 0x28, 0x40 },
+   { 0x29, 0x01 },
+   { 0x2a, 0xdf },
+   { 0x49, 0x3c },
+   { 0x91, 0x77 },
+   { 0x92, 0x77 },
+   { 0xa0, 0x55 },
+   { 0xa1, 0x50 },
+   { 0xa4, 0x9c },
+   { 0xa7, 0x02 },
+   { 0xa8, 0x01 },
+   { 0xa9, 0x01 },
+   { 0xaa, 0xfc },
+   { 0xab, 0x28 },
+   { 0xac, 0x06 },
+   { 0xad, 0x06 },
+   { 0xae, 0x06 },
+   { 0xaf, 0x03 },
+   { 0xb0, 0x08 },
+   { 0xb1, 0x26 },
+   { 0xb2, 0x28 },
+   { 0xb3, 0x28 },
+   { 0xb4, 0x33 },
+   { 0xb5, 0x08 },
+   { 0xb6, 0x26 },
+   { 0xb7, 0x08 },
+   { 0xb8, 0x26 },
+   { 0xf0, 0x00 },
+   { 0xf6, 0xc0 },
+
+   { 0xff, 0x30 },
+   { 0xff, 0x52 },
+   { 0xff, 0x02 },
+   { 0xb0, 0x0b },
+   { 0xb1, 0x16 },
+   { 0xb2, 0x17 },
+   { 0xb3, 0x2c },
+   { 0xb4, 0x32 },
+   { 0xb5, 0x3b },
+   { 0xb6, 0x29 },
+   { 0xb7, 0x40 },
+   { 0xb8, 0x0d },
+   { 0xb9, 0x05 },
+   { 0xba, 0x12 },
+   { 0xbb, 0x10 },
+   { 0xbc, 0x12 },
+   { 0xbd, 0x15 },
+   { 0xbe, 0x19 },
+   { 0xbf, 0x0e },
+   { 0xc0, 0x16 },
+   { 0xc1, 0x0a },
+   { 0xd0, 0x0c },
+   { 0xd1, 0x17