// SPDX-License-Identifier: GPL-2.0
/*
* Xinpeng xpp055c272 5.5" MIPI-DSI panel driver
* Copyright (C) 2019 Theobroma Systems Design und Consulting GmbH
*
* based on
*
* Rockteck jh057n00900 5.5" MIPI-DSI panel driver
* Copyright (C) Purism SPC 2019
*/
#include <drm/drm_mipi_dsi.h>
#include <drm/drm_modes.h>
#include <drm/drm_panel.h>
#include <video/display_timing.h>
#include <video/mipi_display.h>
#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>
/* Manufacturer specific Commands send via DSI */
#define XPP055C272_CMD_ALL_PIXEL_OFF 0 x22
#define XPP055C272_CMD_ALL_PIXEL_ON 0 x23
#define XPP055C272_CMD_SETDISP 0 xb2
#define XPP055C272_CMD_SETRGBIF 0 xb3
#define XPP055C272_CMD_SETCYC 0 xb4
#define XPP055C272_CMD_SETBGP 0 xb5
#define XPP055C272_CMD_SETVCOM 0 xb6
#define XPP055C272_CMD_SETOTP 0 xb7
#define XPP055C272_CMD_SETPOWER_EXT 0 xb8
#define XPP055C272_CMD_SETEXTC 0 xb9
#define XPP055C272_CMD_SETMIPI 0 xbA
#define XPP055C272_CMD_SETVDC 0 xbc
#define XPP055C272_CMD_SETPCR 0 xbf
#define XPP055C272_CMD_SETSCR 0 xc0
#define XPP055C272_CMD_SETPOWER 0 xc1
#define XPP055C272_CMD_SETECO 0 xc6
#define XPP055C272_CMD_SETPANEL 0 xcc
#define XPP055C272_CMD_SETGAMMA 0 xe0
#define XPP055C272_CMD_SETEQ 0 xe3
#define XPP055C272_CMD_SETGIP1 0 xe9
#define XPP055C272_CMD_SETGIP2 0 xea
struct xpp055c272 {
struct device *dev;
struct drm_panel panel;
struct gpio_desc *reset_gpio;
struct regulator *vci;
struct regulator *iovcc;
};
static inline struct xpp055c272 *panel_to_xpp055c272(struct drm_panel *panel)
{
return container_of(panel, struct xpp055c272, panel);
}
static void xpp055c272_init_sequence(struct mipi_dsi_multi_context *dsi_ctx)
{
/*
* Init sequence was supplied by the panel vendor without much
* documentation.
*/
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETEXTC, 0 xf1, 0 x12, 0 x83);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETMIPI,
0 x33, 0 x81, 0 x05, 0 xf9, 0 x0e, 0 x0e, 0 x00, 0 x00,
0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x44, 0 x25,
0 x00, 0 x91, 0 x0a, 0 x00, 0 x00, 0 x02, 0 x4f, 0 x01,
0 x00, 0 x00, 0 x37);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETPOWER_EXT, 0 x25);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETPCR, 0 x02, 0 x11, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETRGBIF,
0 x0c, 0 x10, 0 x0a, 0 x50, 0 x03, 0 xff, 0 x00, 0 x00,
0 x00, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETSCR,
0 x73, 0 x73, 0 x50, 0 x50, 0 x00, 0 x00, 0 x08, 0 x70,
0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETVDC, 0 x46);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETPANEL, 0 x0b);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETCYC, 0 x80);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETDISP, 0 xc8, 0 x12, 0 x30);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETEQ,
0 x07, 0 x07, 0 x0b, 0 x0b, 0 x03, 0 x0b, 0 x00, 0 x00,
0 x00, 0 x00, 0 xff, 0 x00, 0 xC0, 0 x10);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETPOWER,
0 x53, 0 x00, 0 x1e, 0 x1e, 0 x77, 0 xe1, 0 xcc, 0 xdd,
0 x67, 0 x77, 0 x33, 0 x33);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETECO, 0 x00, 0 x00, 0 xff,
0 xff, 0 x01, 0 xff);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETBGP, 0 x09, 0 x09);
mipi_dsi_msleep(dsi_ctx, 20 );
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETVCOM, 0 x87, 0 x95);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETGIP1,
0 xc2, 0 x10, 0 x05, 0 x05, 0 x10, 0 x05, 0 xa0, 0 x12,
0 x31, 0 x23, 0 x3f, 0 x81, 0 x0a, 0 xa0, 0 x37, 0 x18,
0 x00, 0 x80, 0 x01, 0 x00, 0 x00, 0 x00, 0 x00, 0 x80,
0 x01, 0 x00, 0 x00, 0 x00, 0 x48, 0 xf8, 0 x86, 0 x42,
0 x08, 0 x88, 0 x88, 0 x80, 0 x88, 0 x88, 0 x88, 0 x58,
0 xf8, 0 x87, 0 x53, 0 x18, 0 x88, 0 x88, 0 x81, 0 x88,
0 x88, 0 x88, 0 x00, 0 x00, 0 x00, 0 x01, 0 x00, 0 x00,
0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETGIP2,
0 x00, 0 x1a, 0 x00, 0 x00, 0 x00, 0 x00, 0 x02, 0 x00,
0 x00, 0 x00, 0 x00, 0 x00, 0 x1f, 0 x88, 0 x81, 0 x35,
0 x78, 0 x88, 0 x88, 0 x85, 0 x88, 0 x88, 0 x88, 0 x0f,
0 x88, 0 x80, 0 x24, 0 x68, 0 x88, 0 x88, 0 x84, 0 x88,
0 x88, 0 x88, 0 x23, 0 x10, 0 x00, 0 x00, 0 x1c, 0 x00,
0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00,
0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x30, 0 x05,
0 xa0, 0 x00, 0 x00, 0 x00, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, XPP055C272_CMD_SETGAMMA,
0 x00, 0 x06, 0 x08, 0 x2a, 0 x31, 0 x3f, 0 x38, 0 x36,
0 x07, 0 x0c, 0 x0d, 0 x11, 0 x13, 0 x12, 0 x13, 0 x11,
0 x18, 0 x00, 0 x06, 0 x08, 0 x2a, 0 x31, 0 x3f, 0 x38,
0 x36, 0 x07, 0 x0c, 0 x0d, 0 x11, 0 x13, 0 x12, 0 x13,
0 x11, 0 x18);
mipi_dsi_msleep(dsi_ctx, 60 );
}
static int xpp055c272_unprepare(struct drm_panel *panel)
{
struct xpp055c272 *ctx = panel_to_xpp055c272(panel);
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
mipi_dsi_dcs_set_display_off_multi(&dsi_ctx);
mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx);
if (dsi_ctx.accum_err)
return dsi_ctx.accum_err;
regulator_disable(ctx->iovcc);
regulator_disable(ctx->vci);
return 0 ;
}
static int xpp055c272_prepare(struct drm_panel *panel)
{
struct xpp055c272 *ctx = panel_to_xpp055c272(panel);
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
dev_dbg(ctx->dev, "Resetting the panel\n" );
dsi_ctx.accum_err = regulator_enable(ctx->vci);
if (dsi_ctx.accum_err) {
dev_err(ctx->dev, "Failed to enable vci supply: %d\n" ,
dsi_ctx.accum_err);
return dsi_ctx.accum_err;
}
dsi_ctx.accum_err = regulator_enable(ctx->iovcc);
if (dsi_ctx.accum_err) {
dev_err(ctx->dev, "Failed to enable iovcc supply: %d\n" ,
dsi_ctx.accum_err);
goto disable_vci;
}
gpiod_set_value_cansleep(ctx->reset_gpio, 1 );
/* T6: 10us */
usleep_range(10 , 20 );
gpiod_set_value_cansleep(ctx->reset_gpio, 0 );
/* T8: 20ms */
msleep(20 );
xpp055c272_init_sequence(&dsi_ctx);
if (!dsi_ctx.accum_err)
dev_dbg(ctx->dev, "Panel init sequence done\n" );
mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
/* T9: 120ms */
mipi_dsi_msleep(&dsi_ctx, 120 );
mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
if (dsi_ctx.accum_err)
goto disable_iovcc;
msleep(50 );
return 0 ;
disable_iovcc:
regulator_disable(ctx->iovcc);
disable_vci:
regulator_disable(ctx->vci);
return dsi_ctx.accum_err;
}
static const struct drm_display_mode default_mode = {
.hdisplay = 720 ,
.hsync_start = 720 + 40 ,
.hsync_end = 720 + 40 + 10 ,
.htotal = 720 + 40 + 10 + 40 ,
.vdisplay = 1280 ,
.vsync_start = 1280 + 22 ,
.vsync_end = 1280 + 22 + 4 ,
.vtotal = 1280 + 22 + 4 + 11 ,
.clock = 64000 ,
.width_mm = 68 ,
.height_mm = 121 ,
};
static int xpp055c272_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
struct xpp055c272 *ctx = panel_to_xpp055c272(panel);
struct drm_display_mode *mode;
mode = drm_mode_duplicate(connector->dev, &default_mode);
if (!mode) {
dev_err(ctx->dev, "Failed to add mode %ux%u@%u\n" ,
default_mode.hdisplay, default_mode.vdisplay,
drm_mode_vrefresh(&default_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 xpp055c272_funcs = {
.unprepare = xpp055c272_unprepare,
.prepare = xpp055c272_prepare,
.get_modes = xpp055c272_get_modes,
};
static int xpp055c272_probe(struct mipi_dsi_device *dsi)
{
struct device *dev = &dsi->dev;
struct xpp055c272 *ctx;
int ret;
ctx = devm_drm_panel_alloc(dev, struct xpp055c272, panel,
&xpp055c272_funcs, DRM_MODE_CONNECTOR_DSI);
if (IS_ERR(ctx))
return PTR_ERR(ctx);
ctx->reset_gpio = devm_gpiod_get_optional(dev, "reset" , GPIOD_OUT_LOW);
if (IS_ERR(ctx->reset_gpio))
return dev_err_probe(dev, PTR_ERR(ctx->reset_gpio),
"cannot get reset gpio\n" );
ctx->vci = devm_regulator_get(dev, "vci" );
if (IS_ERR(ctx->vci))
return dev_err_probe(dev, PTR_ERR(ctx->vci),
"Failed to request vci regulator\n" );
ctx->iovcc = devm_regulator_get(dev, "iovcc" );
if (IS_ERR(ctx->iovcc))
return dev_err_probe(dev, PTR_ERR(ctx->iovcc),
"Failed to request iovcc regulator\n" );
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_LPM | MIPI_DSI_MODE_NO_EOT_PACKET;
ret = drm_panel_of_backlight(&ctx->panel);
if (ret)
return ret;
drm_panel_add(&ctx->panel);
ret = mipi_dsi_attach(dsi);
if (ret < 0 ) {
dev_err(dev, "mipi_dsi_attach failed: %d\n" , ret);
drm_panel_remove(&ctx->panel);
return ret;
}
return 0 ;
}
static void xpp055c272_remove(struct mipi_dsi_device *dsi)
{
struct xpp055c272 *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);
}
static const struct of_device_id xpp055c272_of_match[] = {
{ .compatible = "xinpeng,xpp055c272" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, xpp055c272_of_match);
static struct mipi_dsi_driver xpp055c272_driver = {
.driver = {
.name = "panel-xinpeng-xpp055c272" ,
.of_match_table = xpp055c272_of_match,
},
.probe = xpp055c272_probe,
.remove = xpp055c272_remove,
};
module_mipi_dsi_driver(xpp055c272_driver);
MODULE_AUTHOR("Heiko Stuebner <heiko.stuebner@theobroma-systems.com>" );
MODULE_DESCRIPTION("DRM driver for Xinpeng xpp055c272 MIPI DSI panel" );
MODULE_LICENSE("GPL v2" );
Messung V0.5 in Prozent C=97 H=97 G=96
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-05)
¤
*© Formatika GbR, Deutschland