Re: [PATCH 3/3] drm/panel: Add panel driver for the Mantix MLAF057WE51-X DSI panel

2020-08-15 Thread Sam Ravnborg
On Sat, Aug 15, 2020 at 12:40:22PM +0200, Guido Günther wrote:
> Hi Sam,
> On Sat, Aug 15, 2020 at 12:02:30PM +0200, Sam Ravnborg wrote:
> > Hi Guido.
> > 
> > > +static int mantix_probe(struct mipi_dsi_device *dsi)
> > > +{
> > > + struct device *dev = >dev;
> > > + struct mantix *ctx;
> > > + int ret;
> > > +
> > > + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
> > > + if (!ctx)
> > > + return -ENOMEM;
> > > +
> > > + ctx->reset_gpio = devm_gpiod_get(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);
> > > + }
> > > +
> > > + mipi_dsi_set_drvdata(dsi, ctx);
> > > + ctx->dev = dev;
> > > +
> > > + dsi->lanes = 4;
> > > + dsi->format = MIPI_DSI_FMT_RGB888;
> > > + dsi->mode_flags = MIPI_DSI_MODE_VIDEO |
> > > + MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE;
> > > +
> > > + ctx->avdd = devm_regulator_get(dev, "avdd");
> > > + if (IS_ERR(ctx->avdd)) {
> > > + ret = PTR_ERR(ctx->avdd);
> > > + if (ret != -EPROBE_DEFER)
> > > + DRM_DEV_ERROR(dev,
> > > +   "Failed to request avdd regulator: %d\n",
> > > +   ret);
> > > + return ret;
> > > + }
> > 
> > Consider to use the recently added dev_err_probe() here and below.
> > Note: Not part of drm-misc-next yet - but hopefully after -rc1
> > when a backmerge is done.
> 
> In fact I did decided against it since i was told that missing dev_* and
> DRM_* logging shouldn't be done. So is that o.k. nowadays?
s/missing/mixing/

I often request that logging is consistent - so I recognize the
argument.

For panel/* I have not made up my mind what I think is the best
approach. The DRM_DEV_* and DRM_* logging do not add much value.
So I have been tempted several times to convert all logging in
panel/ to dev_* and pr_* (when no struct device * is available).
That would also avoid that we mix up logging.

We have drm_* logging - but they require a valid drm_device * which we
do not have in the the panel drivers. So they are ruled out here.

Do you have any opinions/comments on this?

Sam


Re: [PATCH 3/3] drm/panel: Add panel driver for the Mantix MLAF057WE51-X DSI panel

2020-08-15 Thread Sam Ravnborg
Hi Guido.

On Fri, Aug 14, 2020 at 03:36:23PM +0200, Guido Günther wrote:
> The panel uses a Focaltech FT8006p, the touch part is handled by the
> already existing edt-ft5x06.
> 
> Signed-off-by: Guido Günther 

Looks good.
A few notes in the following, nothing major.

Sam

> ---
>  MAINTAINERS   |   7 +
>  drivers/gpu/drm/panel/Kconfig |  11 +
>  drivers/gpu/drm/panel/Makefile|   1 +
>  .../gpu/drm/panel/panel-mantix-mlaf057we51.c  | 362 ++
>  4 files changed, 381 insertions(+)
>  create mode 100644 drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 83ba7b62651f7..7dfe4cc3d4ec8 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5474,6 +5474,13 @@ S: Maintained
>  F:   drivers/gpu/drm/panel/panel-lvds.c
>  F:   Documentation/devicetree/bindings/display/panel/lvds.yaml
>  
> +DRM DRIVER FOR MANTIX MLAF057WE51 PANELS
> +M:   Guido Günther 
> +R:   Purism Kernel Team 
> +S:   Maintained
> +F:   
> Documentation/devicetree/bindings/display/panel/mantix,mlaf057we51-x.yaml
> +F:   drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
> +
>  DRM DRIVER FOR MATROX G200/G400 GRAPHICS CARDS
>  S:   Orphan / Obsolete
>  F:   drivers/gpu/drm/mga/
> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> index de2f2a452be55..8d97d07c58713 100644
> --- a/drivers/gpu/drm/panel/Kconfig
> +++ b/drivers/gpu/drm/panel/Kconfig
> @@ -217,6 +217,17 @@ config DRM_PANEL_NOVATEK_NT39016
> Say Y here if you want to enable support for the panels built
> around the Novatek NT39016 display controller.
>  
> +config DRM_PANEL_MANTIX_MLAF057WE51
> + tristate "Mantix MLAF057WE51-X MIPI-DSI LCD 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 Mantix
> +   MLAF057WE51-X MIPI DSI panel as e.g. used in the Librem 5. It
> +   has a resolution of 720x1440 pixels, a built in backlight and touch
> +   controller.
> +
>  config DRM_PANEL_OLIMEX_LCD_OLINUXINO
>   tristate "Olimex LCD-OLinuXino panel"
>   depends on OF
> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> index e45ceac6286fd..15a4e77529514 100644
> --- a/drivers/gpu/drm/panel/Makefile
> +++ b/drivers/gpu/drm/panel/Makefile
> @@ -20,6 +20,7 @@ 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_MANTIX_MLAF057WE51) += panel-mantix-mlaf057we51.o
>  obj-$(CONFIG_DRM_PANEL_OLIMEX_LCD_OLINUXINO) += panel-olimex-lcd-olinuxino.o
>  obj-$(CONFIG_DRM_PANEL_ORISETECH_OTM8009A) += panel-orisetech-otm8009a.o
>  obj-$(CONFIG_DRM_PANEL_OSD_OSD101T2587_53TS) += panel-osd-osd101t2587-53ts.o
> diff --git a/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c 
> b/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
> new file mode 100644
> index 0..6c07bcdb75937
> --- /dev/null
> +++ b/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
> @@ -0,0 +1,362 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Mantix MLAF057WE51 5.7" MIPI-DSI panel driver
> + *
> + * Copyright (C) Purism SPC 2020
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
Include not needed.

> +#include 
> +#include 
> +
> +#include 
I do not think this include is needed

> +#include 
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define DRV_NAME "panel-mantix-mlaf057we51"
> +
> +/* Manufacturer specific Commands send via DSI */
> +#define MANTIX_CMD_OTP_STOP_RELOAD_MIPI 0x41
> +#define MANTIX_CMD_INT_CANCEL   0x4C
> +
> +struct mantix {
> + struct device *dev;
> + struct drm_panel panel;
> + struct gpio_desc *reset_gpio;
> +
> + struct regulator *avdd;
> + struct regulator *avee;
> + struct regulator *vddi;
> +};
> +
> +static inline struct mantix *panel_to_mantix(struct drm_panel *panel)
> +{
> + return container_of(panel, struct mantix, panel);
> +}
> +
> +#define dsi_generic_write_seq(dsi, seq...) do {  
> \
> + static const u8 d[] = { seq };  \
> + int ret;\
> + ret = mipi_dsi_generic_write(dsi, d, ARRAY_SIZE(d));\
> + if (ret < 0)\
> + return ret; \
> + } while (0)
> +
> +static int mantix_init_sequence(struct mantix *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.
> +  */
> + 

Re: [PATCH 3/3] drm/panel: Add panel driver for the Mantix MLAF057WE51-X DSI panel

2020-08-15 Thread Guido Günther
Hi Sam,
On Sat, Aug 15, 2020 at 12:02:30PM +0200, Sam Ravnborg wrote:
> Hi Guido.
> 
> > +static int mantix_probe(struct mipi_dsi_device *dsi)
> > +{
> > +   struct device *dev = >dev;
> > +   struct mantix *ctx;
> > +   int ret;
> > +
> > +   ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
> > +   if (!ctx)
> > +   return -ENOMEM;
> > +
> > +   ctx->reset_gpio = devm_gpiod_get(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);
> > +   }
> > +
> > +   mipi_dsi_set_drvdata(dsi, ctx);
> > +   ctx->dev = dev;
> > +
> > +   dsi->lanes = 4;
> > +   dsi->format = MIPI_DSI_FMT_RGB888;
> > +   dsi->mode_flags = MIPI_DSI_MODE_VIDEO |
> > +   MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE;
> > +
> > +   ctx->avdd = devm_regulator_get(dev, "avdd");
> > +   if (IS_ERR(ctx->avdd)) {
> > +   ret = PTR_ERR(ctx->avdd);
> > +   if (ret != -EPROBE_DEFER)
> > +   DRM_DEV_ERROR(dev,
> > + "Failed to request avdd regulator: %d\n",
> > + ret);
> > +   return ret;
> > +   }
> 
> Consider to use the recently added dev_err_probe() here and below.
> Note: Not part of drm-misc-next yet - but hopefully after -rc1
> when a backmerge is done.

In fact I did decided against it since i was told that missing dev_* and
DRM_* logging shouldn't be done. So is that o.k. nowadays?
Cheers,
 -- Guido

> 
>   Sam
> 
> > +   ctx->avee = devm_regulator_get(dev, "avee");
> > +   if (IS_ERR(ctx->avee)) {
> > +   ret = PTR_ERR(ctx->avee);
> > +   if (ret != -EPROBE_DEFER)
> > +   DRM_DEV_ERROR(dev,
> > + "Failed to request avee regulator: %d\n",
> > + ret);
> > +   return ret;
> > +   }
> > +   ctx->vddi = devm_regulator_get(dev, "vddi");
> > +   if (IS_ERR(ctx->vddi)) {
> > +   ret = PTR_ERR(ctx->vddi);
> > +   if (ret != -EPROBE_DEFER)
> > +   DRM_DEV_ERROR(dev,
> > + "Failed to request vddi regulator: %d\n",
> > + ret);
> > +   return ret;
> > +   }
> > +
> > +   drm_panel_init(>panel, dev, _drm_funcs,
> > +  DRM_MODE_CONNECTOR_DSI);
> > +
> > +   ret = drm_panel_of_backlight(>panel);
> > +   if (ret)
> > +   return ret;
> > +   drm_panel_add(>panel);
> > +
> > +   ret = mipi_dsi_attach(dsi);
> > +   if (ret < 0) {
> > +   DRM_DEV_ERROR(dev,
> > + "mipi_dsi_attach failed (%d). Is host ready?\n",
> > + ret);
> > +   drm_panel_remove(>panel);
> > +   return ret;
> > +   }
> > +
> > +   DRM_DEV_INFO(dev, "%ux%u@%u %ubpp dsi %udl - ready\n",
> > +default_mode.hdisplay, default_mode.vdisplay,
> > +drm_mode_vrefresh(_mode),
> > +mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes);
> > +
> > +   return 0;
> > +}
> > +
> > +static void mantix_shutdown(struct mipi_dsi_device *dsi)
> > +{
> > +   struct mantix *ctx = mipi_dsi_get_drvdata(dsi);
> > +   int ret;
> > +
> > +   ret = drm_panel_unprepare(>panel);
> > +   if (ret < 0)
> > +   DRM_DEV_ERROR(>dev, "Failed to unprepare panel: %d\n",
> > + ret);
> > +
> > +   ret = drm_panel_disable(>panel);
> > +   if (ret < 0)
> > +   DRM_DEV_ERROR(>dev, "Failed to disable panel: %d\n",
> > + ret);
> > +}
> > +
> > +static int mantix_remove(struct mipi_dsi_device *dsi)
> > +{
> > +   struct mantix *ctx = mipi_dsi_get_drvdata(dsi);
> > +   int ret;
> > +
> > +   mantix_shutdown(dsi);
> > +
> > +   ret = mipi_dsi_detach(dsi);
> > +   if (ret < 0)
> > +   DRM_DEV_ERROR(>dev, "Failed to detach from DSI host: %d\n",
> > + ret);
> > +
> > +   drm_panel_remove(>panel);
> > +
> > +   return 0;
> > +}
> > +
> > +static const struct of_device_id mantix_of_match[] = {
> > +   { .compatible = "mantix,mlaf057we51-x" },
> > +   { /* sentinel */ }
> > +};
> > +MODULE_DEVICE_TABLE(of, mantix_of_match);
> > +
> > +static struct mipi_dsi_driver mantix_driver = {
> > +   .probe  = mantix_probe,
> > +   .remove = mantix_remove,
> > +   .shutdown = mantix_shutdown,
> > +   .driver = {
> > +   .name = DRV_NAME,
> > +   .of_match_table = mantix_of_match,
> > +   },
> > +};
> > +module_mipi_dsi_driver(mantix_driver);
> > +
> > +MODULE_AUTHOR("Guido Günther ");
> > +MODULE_DESCRIPTION("DRM driver for Mantix MLAF057WE51-X MIPI DSI panel");
> > +MODULE_LICENSE("GPL v2");
> > -- 
> > 2.26.2
> > 
> > ___
> > dri-devel mailing list
> > dri-de...@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 


Re: [PATCH 3/3] drm/panel: Add panel driver for the Mantix MLAF057WE51-X DSI panel

2020-08-15 Thread Sam Ravnborg
Hi Guido.

> > In fact I did decided against it since i was told that missing dev_* and
> > DRM_* logging shouldn't be done. So is that o.k. nowadays?
> s/missing/mixing/
> 
> I often request that logging is consistent - so I recognize the
> argument.
> 
> For panel/* I have not made up my mind what I think is the best
> approach. The DRM_DEV_* and DRM_* logging do not add much value.
> So I have been tempted several times to convert all logging in
> panel/ to dev_* and pr_* (when no struct device * is available).
> That would also avoid that we mix up logging.
> 
> We have drm_* logging - but they require a valid drm_device * which we
> do not have in the the panel drivers. So they are ruled out here.
> 
> Do you have any opinions/comments on this?
I went ahead and dropped the DRM_ logging in drm/panel, you are copied
on the patchset. Feedback on the patches would be nice.

Sam


Re: [PATCH 3/3] drm/panel: Add panel driver for the Mantix MLAF057WE51-X DSI panel

2020-08-15 Thread Guido Günther
Hi,
On Sat, Aug 15, 2020 at 12:46:51PM +0200, Sam Ravnborg wrote:
> On Sat, Aug 15, 2020 at 12:40:22PM +0200, Guido Günther wrote:
> > Hi Sam,
> > On Sat, Aug 15, 2020 at 12:02:30PM +0200, Sam Ravnborg wrote:
> > > Hi Guido.
> > > 
> > > > +static int mantix_probe(struct mipi_dsi_device *dsi)
> > > > +{
> > > > +   struct device *dev = >dev;
> > > > +   struct mantix *ctx;
> > > > +   int ret;
> > > > +
> > > > +   ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
> > > > +   if (!ctx)
> > > > +   return -ENOMEM;
> > > > +
> > > > +   ctx->reset_gpio = devm_gpiod_get(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);
> > > > +   }
> > > > +
> > > > +   mipi_dsi_set_drvdata(dsi, ctx);
> > > > +   ctx->dev = dev;
> > > > +
> > > > +   dsi->lanes = 4;
> > > > +   dsi->format = MIPI_DSI_FMT_RGB888;
> > > > +   dsi->mode_flags = MIPI_DSI_MODE_VIDEO |
> > > > +   MIPI_DSI_MODE_VIDEO_BURST | 
> > > > MIPI_DSI_MODE_VIDEO_SYNC_PULSE;
> > > > +
> > > > +   ctx->avdd = devm_regulator_get(dev, "avdd");
> > > > +   if (IS_ERR(ctx->avdd)) {
> > > > +   ret = PTR_ERR(ctx->avdd);
> > > > +   if (ret != -EPROBE_DEFER)
> > > > +   DRM_DEV_ERROR(dev,
> > > > + "Failed to request avdd 
> > > > regulator: %d\n",
> > > > + ret);
> > > > +   return ret;
> > > > +   }
> > > 
> > > Consider to use the recently added dev_err_probe() here and below.
> > > Note: Not part of drm-misc-next yet - but hopefully after -rc1
> > > when a backmerge is done.
> > 
> > In fact I did decided against it since i was told that missing dev_* and
> > DRM_* logging shouldn't be done. So is that o.k. nowadays?
> s/missing/mixing/
> 
> I often request that logging is consistent - so I recognize the
> argument.
> 
> For panel/* I have not made up my mind what I think is the best
> approach. The DRM_DEV_* and DRM_* logging do not add much value.
> So I have been tempted several times to convert all logging in
> panel/ to dev_* and pr_* (when no struct device * is available).
> That would also avoid that we mix up logging.
> 
> We have drm_* logging - but they require a valid drm_device * which we
> do not have in the the panel drivers. So they are ruled out here.
> 
> Do you have any opinions/comments on this?

I think for panel drivers DRM_* does not give any bonus so moving to
{dev,pr}_* sounds good. I just wonder if other drm parts don't need
`dev_drm_err_probe()` (or similar) anyway. But then maybe dyn_debug
is enough nowadays to not need DRM_DEV_DEBUG_* either?
Cheers,
 -- Guido

> 
>   Sam
> 


Re: [PATCH 3/3] drm/panel: Add panel driver for the Mantix MLAF057WE51-X DSI panel

2020-08-15 Thread Sam Ravnborg
Hi Guido.

> +static int mantix_probe(struct mipi_dsi_device *dsi)
> +{
> + struct device *dev = >dev;
> + struct mantix *ctx;
> + int ret;
> +
> + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
> + if (!ctx)
> + return -ENOMEM;
> +
> + ctx->reset_gpio = devm_gpiod_get(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);
> + }
> +
> + mipi_dsi_set_drvdata(dsi, ctx);
> + ctx->dev = dev;
> +
> + dsi->lanes = 4;
> + dsi->format = MIPI_DSI_FMT_RGB888;
> + dsi->mode_flags = MIPI_DSI_MODE_VIDEO |
> + MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE;
> +
> + ctx->avdd = devm_regulator_get(dev, "avdd");
> + if (IS_ERR(ctx->avdd)) {
> + ret = PTR_ERR(ctx->avdd);
> + if (ret != -EPROBE_DEFER)
> + DRM_DEV_ERROR(dev,
> +   "Failed to request avdd regulator: %d\n",
> +   ret);
> + return ret;
> + }

Consider to use the recently added dev_err_probe() here and below.
Note: Not part of drm-misc-next yet - but hopefully after -rc1
when a backmerge is done.

Sam

> + ctx->avee = devm_regulator_get(dev, "avee");
> + if (IS_ERR(ctx->avee)) {
> + ret = PTR_ERR(ctx->avee);
> + if (ret != -EPROBE_DEFER)
> + DRM_DEV_ERROR(dev,
> +   "Failed to request avee regulator: %d\n",
> +   ret);
> + return ret;
> + }
> + ctx->vddi = devm_regulator_get(dev, "vddi");
> + if (IS_ERR(ctx->vddi)) {
> + ret = PTR_ERR(ctx->vddi);
> + if (ret != -EPROBE_DEFER)
> + DRM_DEV_ERROR(dev,
> +   "Failed to request vddi regulator: %d\n",
> +   ret);
> + return ret;
> + }
> +
> + drm_panel_init(>panel, dev, _drm_funcs,
> +DRM_MODE_CONNECTOR_DSI);
> +
> + ret = drm_panel_of_backlight(>panel);
> + if (ret)
> + return ret;
> + drm_panel_add(>panel);
> +
> + ret = mipi_dsi_attach(dsi);
> + if (ret < 0) {
> + DRM_DEV_ERROR(dev,
> +   "mipi_dsi_attach failed (%d). Is host ready?\n",
> +   ret);
> + drm_panel_remove(>panel);
> + return ret;
> + }
> +
> + DRM_DEV_INFO(dev, "%ux%u@%u %ubpp dsi %udl - ready\n",
> +  default_mode.hdisplay, default_mode.vdisplay,
> +  drm_mode_vrefresh(_mode),
> +  mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes);
> +
> + return 0;
> +}
> +
> +static void mantix_shutdown(struct mipi_dsi_device *dsi)
> +{
> + struct mantix *ctx = mipi_dsi_get_drvdata(dsi);
> + int ret;
> +
> + ret = drm_panel_unprepare(>panel);
> + if (ret < 0)
> + DRM_DEV_ERROR(>dev, "Failed to unprepare panel: %d\n",
> +   ret);
> +
> + ret = drm_panel_disable(>panel);
> + if (ret < 0)
> + DRM_DEV_ERROR(>dev, "Failed to disable panel: %d\n",
> +   ret);
> +}
> +
> +static int mantix_remove(struct mipi_dsi_device *dsi)
> +{
> + struct mantix *ctx = mipi_dsi_get_drvdata(dsi);
> + int ret;
> +
> + mantix_shutdown(dsi);
> +
> + ret = mipi_dsi_detach(dsi);
> + if (ret < 0)
> + DRM_DEV_ERROR(>dev, "Failed to detach from DSI host: %d\n",
> +   ret);
> +
> + drm_panel_remove(>panel);
> +
> + return 0;
> +}
> +
> +static const struct of_device_id mantix_of_match[] = {
> + { .compatible = "mantix,mlaf057we51-x" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, mantix_of_match);
> +
> +static struct mipi_dsi_driver mantix_driver = {
> + .probe  = mantix_probe,
> + .remove = mantix_remove,
> + .shutdown = mantix_shutdown,
> + .driver = {
> + .name = DRV_NAME,
> + .of_match_table = mantix_of_match,
> + },
> +};
> +module_mipi_dsi_driver(mantix_driver);
> +
> +MODULE_AUTHOR("Guido Günther ");
> +MODULE_DESCRIPTION("DRM driver for Mantix MLAF057WE51-X MIPI DSI panel");
> +MODULE_LICENSE("GPL v2");
> -- 
> 2.26.2
> 
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 3/3] drm/panel: Add panel driver for the Mantix MLAF057WE51-X DSI panel

2020-08-15 Thread Guido Günther
Hi Sam,
On Sat, Aug 15, 2020 at 11:32:26AM +0200, Sam Ravnborg wrote:
> Hi Guido.
> 
> On Fri, Aug 14, 2020 at 03:36:23PM +0200, Guido Günther wrote:
> > The panel uses a Focaltech FT8006p, the touch part is handled by the
> > already existing edt-ft5x06.
> > 
> > Signed-off-by: Guido Günther 
> 
> Looks good.
> A few notes in the following, nothing major.

Thanks. I've added your suggestions to v2.
 -- Guido
> 
>   Sam
> 
> > ---
> >  MAINTAINERS   |   7 +
> >  drivers/gpu/drm/panel/Kconfig |  11 +
> >  drivers/gpu/drm/panel/Makefile|   1 +
> >  .../gpu/drm/panel/panel-mantix-mlaf057we51.c  | 362 ++
> >  4 files changed, 381 insertions(+)
> >  create mode 100644 drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
> > 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 83ba7b62651f7..7dfe4cc3d4ec8 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -5474,6 +5474,13 @@ S:   Maintained
> >  F: drivers/gpu/drm/panel/panel-lvds.c
> >  F: Documentation/devicetree/bindings/display/panel/lvds.yaml
> >  
> > +DRM DRIVER FOR MANTIX MLAF057WE51 PANELS
> > +M: Guido Günther 
> > +R: Purism Kernel Team 
> > +S: Maintained
> > +F: 
> > Documentation/devicetree/bindings/display/panel/mantix,mlaf057we51-x.yaml
> > +F: drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
> > +
> >  DRM DRIVER FOR MATROX G200/G400 GRAPHICS CARDS
> >  S: Orphan / Obsolete
> >  F: drivers/gpu/drm/mga/
> > diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> > index de2f2a452be55..8d97d07c58713 100644
> > --- a/drivers/gpu/drm/panel/Kconfig
> > +++ b/drivers/gpu/drm/panel/Kconfig
> > @@ -217,6 +217,17 @@ config DRM_PANEL_NOVATEK_NT39016
> >   Say Y here if you want to enable support for the panels built
> >   around the Novatek NT39016 display controller.
> >  
> > +config DRM_PANEL_MANTIX_MLAF057WE51
> > +   tristate "Mantix MLAF057WE51-X MIPI-DSI LCD 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 Mantix
> > + MLAF057WE51-X MIPI DSI panel as e.g. used in the Librem 5. It
> > + has a resolution of 720x1440 pixels, a built in backlight and touch
> > + controller.
> > +
> >  config DRM_PANEL_OLIMEX_LCD_OLINUXINO
> > tristate "Olimex LCD-OLinuXino panel"
> > depends on OF
> > diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> > index e45ceac6286fd..15a4e77529514 100644
> > --- a/drivers/gpu/drm/panel/Makefile
> > +++ b/drivers/gpu/drm/panel/Makefile
> > @@ -20,6 +20,7 @@ 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_MANTIX_MLAF057WE51) += panel-mantix-mlaf057we51.o
> >  obj-$(CONFIG_DRM_PANEL_OLIMEX_LCD_OLINUXINO) += 
> > panel-olimex-lcd-olinuxino.o
> >  obj-$(CONFIG_DRM_PANEL_ORISETECH_OTM8009A) += panel-orisetech-otm8009a.o
> >  obj-$(CONFIG_DRM_PANEL_OSD_OSD101T2587_53TS) += 
> > panel-osd-osd101t2587-53ts.o
> > diff --git a/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c 
> > b/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
> > new file mode 100644
> > index 0..6c07bcdb75937
> > --- /dev/null
> > +++ b/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
> > @@ -0,0 +1,362 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Mantix MLAF057WE51 5.7" MIPI-DSI panel driver
> > + *
> > + * Copyright (C) Purism SPC 2020
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> Include not needed.
> 
> > +#include 
> > +#include 
> > +
> > +#include 
> I do not think this include is needed
> 
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#define DRV_NAME "panel-mantix-mlaf057we51"
> > +
> > +/* Manufacturer specific Commands send via DSI */
> > +#define MANTIX_CMD_OTP_STOP_RELOAD_MIPI 0x41
> > +#define MANTIX_CMD_INT_CANCEL   0x4C
> > +
> > +struct mantix {
> > +   struct device *dev;
> > +   struct drm_panel panel;
> > +   struct gpio_desc *reset_gpio;
> > +
> > +   struct regulator *avdd;
> > +   struct regulator *avee;
> > +   struct regulator *vddi;
> > +};
> > +
> > +static inline struct mantix *panel_to_mantix(struct drm_panel *panel)
> > +{
> > +   return container_of(panel, struct mantix, panel);
> > +}
> > +
> > +#define dsi_generic_write_seq(dsi, seq...) do {
> > \
> > +   static const u8 d[] = { seq };  \
> > +   int ret;\
> > +   ret = mipi_dsi_generic_write(dsi, d, ARRAY_SIZE(d));\
> > +   if (ret < 0)\
> > +   return 

[PATCH 3/3] drm/panel: Add panel driver for the Mantix MLAF057WE51-X DSI panel

2020-08-14 Thread Guido Günther
The panel uses a Focaltech FT8006p, the touch part is handled by the
already existing edt-ft5x06.

Signed-off-by: Guido Günther 
---
 MAINTAINERS   |   7 +
 drivers/gpu/drm/panel/Kconfig |  11 +
 drivers/gpu/drm/panel/Makefile|   1 +
 .../gpu/drm/panel/panel-mantix-mlaf057we51.c  | 362 ++
 4 files changed, 381 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 83ba7b62651f7..7dfe4cc3d4ec8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5474,6 +5474,13 @@ S:   Maintained
 F: drivers/gpu/drm/panel/panel-lvds.c
 F: Documentation/devicetree/bindings/display/panel/lvds.yaml
 
+DRM DRIVER FOR MANTIX MLAF057WE51 PANELS
+M: Guido Günther 
+R: Purism Kernel Team 
+S: Maintained
+F: 
Documentation/devicetree/bindings/display/panel/mantix,mlaf057we51-x.yaml
+F: drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
+
 DRM DRIVER FOR MATROX G200/G400 GRAPHICS CARDS
 S: Orphan / Obsolete
 F: drivers/gpu/drm/mga/
diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index de2f2a452be55..8d97d07c58713 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -217,6 +217,17 @@ config DRM_PANEL_NOVATEK_NT39016
  Say Y here if you want to enable support for the panels built
  around the Novatek NT39016 display controller.
 
+config DRM_PANEL_MANTIX_MLAF057WE51
+   tristate "Mantix MLAF057WE51-X MIPI-DSI LCD 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 Mantix
+ MLAF057WE51-X MIPI DSI panel as e.g. used in the Librem 5. It
+ has a resolution of 720x1440 pixels, a built in backlight and touch
+ controller.
+
 config DRM_PANEL_OLIMEX_LCD_OLINUXINO
tristate "Olimex LCD-OLinuXino panel"
depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index e45ceac6286fd..15a4e77529514 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -20,6 +20,7 @@ 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_MANTIX_MLAF057WE51) += panel-mantix-mlaf057we51.o
 obj-$(CONFIG_DRM_PANEL_OLIMEX_LCD_OLINUXINO) += panel-olimex-lcd-olinuxino.o
 obj-$(CONFIG_DRM_PANEL_ORISETECH_OTM8009A) += panel-orisetech-otm8009a.o
 obj-$(CONFIG_DRM_PANEL_OSD_OSD101T2587_53TS) += panel-osd-osd101t2587-53ts.o
diff --git a/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c 
b/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
new file mode 100644
index 0..6c07bcdb75937
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
@@ -0,0 +1,362 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Mantix MLAF057WE51 5.7" MIPI-DSI panel driver
+ *
+ * Copyright (C) Purism SPC 2020
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#define DRV_NAME "panel-mantix-mlaf057we51"
+
+/* Manufacturer specific Commands send via DSI */
+#define MANTIX_CMD_OTP_STOP_RELOAD_MIPI 0x41
+#define MANTIX_CMD_INT_CANCEL   0x4C
+
+struct mantix {
+   struct device *dev;
+   struct drm_panel panel;
+   struct gpio_desc *reset_gpio;
+
+   struct regulator *avdd;
+   struct regulator *avee;
+   struct regulator *vddi;
+};
+
+static inline struct mantix *panel_to_mantix(struct drm_panel *panel)
+{
+   return container_of(panel, struct mantix, panel);
+}
+
+#define dsi_generic_write_seq(dsi, seq...) do {
\
+   static const u8 d[] = { seq };  \
+   int ret;\
+   ret = mipi_dsi_generic_write(dsi, d, ARRAY_SIZE(d));\
+   if (ret < 0)\
+   return ret; \
+   } while (0)
+
+static int mantix_init_sequence(struct mantix *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.
+*/
+   dsi_generic_write_seq(dsi, MANTIX_CMD_OTP_STOP_RELOAD_MIPI, 0x5A);
+
+   dsi_generic_write_seq(dsi, MANTIX_CMD_INT_CANCEL, 0x03);
+   dsi_generic_write_seq(dsi, MANTIX_CMD_OTP_STOP_RELOAD_MIPI, 0x5A, 0x03);
+   dsi_generic_write_seq(dsi, 0x80, 0xA9, 0x00);
+
+   dsi_generic_write_seq(dsi, MANTIX_CMD_OTP_STOP_RELOAD_MIPI, 0x5A, 0x09);
+   dsi_generic_write_seq(dsi,