// SPDX-License-Identifier: GPL-2.0
/*
* Driver for panels based on Sitronix ST7703 controller, souch as:
*
* - Rocktech jh057n00900 5.5" MIPI-DSI panel
*
* Copyright (C) Purism SPC 2019
*/
#include <linux/debugfs.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/media-bus-format.h>
#include <linux/mod_devicetable.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>
#define DRV_NAME "panel-sitronix-st7703"
/* Manufacturer specific Commands send via DSI */
#define ST7703_CMD_ALL_PIXEL_OFF 0 x22
#define ST7703_CMD_ALL_PIXEL_ON 0 x23
#define ST7703_CMD_SETAPID 0 xB1
#define ST7703_CMD_SETDISP 0 xB2
#define ST7703_CMD_SETRGBIF 0 xB3
#define ST7703_CMD_SETCYC 0 xB4
#define ST7703_CMD_SETBGP 0 xB5
#define ST7703_CMD_SETVCOM 0 xB6
#define ST7703_CMD_SETOTP 0 xB7
#define ST7703_CMD_SETPOWER_EXT 0 xB8
#define ST7703_CMD_SETEXTC 0 xB9
#define ST7703_CMD_SETMIPI 0 xBA
#define ST7703_CMD_SETVDC 0 xBC
#define ST7703_CMD_UNKNOWN_BF 0 xBF
#define ST7703_CMD_SETSCR 0 xC0
#define ST7703_CMD_SETPOWER 0 xC1
#define ST7703_CMD_SETECO 0 xC6
#define ST7703_CMD_SETIO 0 xC7
#define ST7703_CMD_SETCABC 0 xC8
#define ST7703_CMD_SETPANEL 0 xCC
#define ST7703_CMD_SETGAMMA 0 xE0
#define ST7703_CMD_SETEQ 0 xE3
#define ST7703_CMD_SETGIP1 0 xE9
#define ST7703_CMD_SETGIP2 0 xEA
#define ST7703_CMD_UNKNOWN_EF 0 xEF
struct st7703 {
struct device *dev;
struct drm_panel panel;
struct gpio_desc *reset_gpio;
struct regulator *vcc;
struct regulator *iovcc;
struct dentry *debugfs;
const struct st7703_panel_desc *desc;
enum drm_panel_orientation orientation;
};
struct st7703_panel_desc {
const struct drm_display_mode *mode;
unsigned int lanes;
unsigned long mode_flags;
enum mipi_dsi_pixel_format format;
void (*init_sequence)(struct mipi_dsi_multi_context *dsi_ctx);
};
static inline struct st7703 *panel_to_st7703(struct drm_panel *panel)
{
return container_of(panel, struct st7703, panel);
}
static void jh057n_init_sequence(struct mipi_dsi_multi_context *dsi_ctx)
{
/*
* Init sequence was supplied by the panel vendor. Most of the commands
* resemble the ST7703 but the number of parameters often don't match
* so it's likely a clone.
*/
mipi_dsi_generic_write_seq_multi(dsi_ctx, ST7703_CMD_SETEXTC,
0 xF1, 0 x12, 0 x83);
mipi_dsi_generic_write_seq_multi(dsi_ctx, ST7703_CMD_SETRGBIF,
0 x10, 0 x10, 0 x05, 0 x05, 0 x03, 0 xFF, 0 x00, 0 x00,
0 x00, 0 x00);
mipi_dsi_generic_write_seq_multi(dsi_ctx, ST7703_CMD_SETSCR,
0 x73, 0 x73, 0 x50, 0 x50, 0 x00, 0 x00, 0 x08, 0 x70,
0 x00);
mipi_dsi_generic_write_seq_multi(dsi_ctx, ST7703_CMD_SETVDC, 0 x4E);
mipi_dsi_generic_write_seq_multi(dsi_ctx, ST7703_CMD_SETPANEL, 0 x0B);
mipi_dsi_generic_write_seq_multi(dsi_ctx, ST7703_CMD_SETCYC, 0 x80);
mipi_dsi_generic_write_seq_multi(dsi_ctx, ST7703_CMD_SETDISP, 0 xF0, 0 x12, 0 x30);
mipi_dsi_generic_write_seq_multi(dsi_ctx, ST7703_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_generic_write_seq_multi(dsi_ctx, ST7703_CMD_SETBGP, 0 x08, 0 x08);
mipi_dsi_msleep(dsi_ctx, 20 );
mipi_dsi_generic_write_seq_multi(dsi_ctx, ST7703_CMD_SETVCOM, 0 x3F, 0 x3F);
mipi_dsi_generic_write_seq_multi(dsi_ctx, ST7703_CMD_UNKNOWN_BF, 0 x02, 0 x11, 0 x00);
mipi_dsi_generic_write_seq_multi(dsi_ctx, ST7703_CMD_SETGIP1,
0 x82, 0 x10, 0 x06, 0 x05, 0 x9E, 0 x0A, 0 xA5, 0 x12,
0 x31, 0 x23, 0 x37, 0 x83, 0 x04, 0 xBC, 0 x27, 0 x38,
0 x0C, 0 x00, 0 x03, 0 x00, 0 x00, 0 x00, 0 x0C, 0 x00,
0 x03, 0 x00, 0 x00, 0 x00, 0 x75, 0 x75, 0 x31, 0 x88,
0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 x13, 0 x88, 0 x64,
0 x64, 0 x20, 0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 x88,
0 x02, 0 x88, 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);
mipi_dsi_generic_write_seq_multi(dsi_ctx, ST7703_CMD_SETGIP2,
0 x02, 0 x21, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00,
0 x00, 0 x00, 0 x00, 0 x00, 0 x02, 0 x46, 0 x02, 0 x88,
0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 x64, 0 x88, 0 x13,
0 x57, 0 x13, 0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 x88,
0 x75, 0 x88, 0 x23, 0 x14, 0 x00, 0 x00, 0 x02, 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 x0A,
0 xA5, 0 x00, 0 x00, 0 x00, 0 x00);
mipi_dsi_generic_write_seq_multi(dsi_ctx, ST7703_CMD_SETGAMMA,
0 x00, 0 x09, 0 x0E, 0 x29, 0 x2D, 0 x3C, 0 x41, 0 x37,
0 x07, 0 x0B, 0 x0D, 0 x10, 0 x11, 0 x0F, 0 x10, 0 x11,
0 x18, 0 x00, 0 x09, 0 x0E, 0 x29, 0 x2D, 0 x3C, 0 x41,
0 x37, 0 x07, 0 x0B, 0 x0D, 0 x10, 0 x11, 0 x0F, 0 x10,
0 x11, 0 x18);
mipi_dsi_msleep(dsi_ctx, 20 );
}
static const struct drm_display_mode jh057n00900_mode = {
.hdisplay = 720 ,
.hsync_start = 720 + 90 ,
.hsync_end = 720 + 90 + 20 ,
.htotal = 720 + 90 + 20 + 20 ,
.vdisplay = 1440 ,
.vsync_start = 1440 + 20 ,
.vsync_end = 1440 + 20 + 4 ,
.vtotal = 1440 + 20 + 4 + 12 ,
.clock = 75276 ,
.flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
.width_mm = 65 ,
.height_mm = 130 ,
};
static const struct st7703_panel_desc jh057n00900_panel_desc = {
.mode = &jh057n00900_mode,
.lanes = 4 ,
.mode_flags = MIPI_DSI_MODE_VIDEO |
MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
.format = MIPI_DSI_FMT_RGB888,
.init_sequence = jh057n_init_sequence,
};
static void xbd599_init_sequence(struct mipi_dsi_multi_context *dsi_ctx)
{
/*
* Init sequence was supplied by the panel vendor.
*/
/* Magic sequence to unlock user commands below. */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETEXTC, 0 xF1, 0 x12, 0 x83);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETMIPI,
0 x33, /* VC_main = 0, Lane_Number = 3 (4 lanes) */
0 x81, /* DSI_LDO_SEL = 1.7V, RTERM = 90 Ohm */
0 x05, /* IHSRX = x6 (Low High Speed driving ability) */
0 xF9, /* TX_CLK_SEL = fDSICLK/16 */
0 x0E, /* HFP_OSC (min. HFP number in DSI mode) */
0 x0E, /* HBP_OSC (min. HBP number in DSI mode) */
/* The rest is undocumented in ST7703 datasheet */
0 x20, 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 x11, 0 x00, 0 x00, 0 x37);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETPOWER_EXT,
0 x25, /* PCCS = 2, ECP_DC_DIV = 1/4 HSYNC */
0 x22, /* DT = 15ms XDK_ECP = x2 */
0 x20, /* PFM_DC_DIV = /1 */
0 x03 /* ECP_SYNC_EN = 1, VGX_SYNC_EN = 1 */);
/* RGB I/F porch timing */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETRGBIF,
0 x10, /* VBP_RGB_GEN */
0 x10, /* VFP_RGB_GEN */
0 x05, /* DE_BP_RGB_GEN */
0 x05, /* DE_FP_RGB_GEN */
/* The rest is undocumented in ST7703 datasheet */
0 x03, 0 xFF,
0 x00, 0 x00,
0 x00, 0 x00);
/* Source driving settings. */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETSCR,
0 x73, /* N_POPON */
0 x73, /* N_NOPON */
0 x50, /* I_POPON */
0 x50, /* I_NOPON */
0 x00, /* SCR[31,24] */
0 xC0, /* SCR[23,16] */
0 x08, /* SCR[15,8] */
0 x70, /* SCR[7,0] */
0 x00 /* Undocumented */);
/* NVDDD_SEL = -1.8V, VDDD_SEL = out of range (possibly 1.9V?) */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETVDC, 0 x4E);
/*
* SS_PANEL = 1 (reverse scan), GS_PANEL = 0 (normal scan)
* REV_PANEL = 1 (normally black panel), BGR_PANEL = 1 (BGR)
*/
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETPANEL, 0 x0B);
/* Zig-Zag Type C column inversion. */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETCYC, 0 x80);
/* Set display resolution. */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETDISP,
0 xF0, /* NL = 240 */
0 x12, /* RES_V_LSB = 0, BLK_CON = VSSD,
* RESO_SEL = 720RGB
*/
0 xF0 /* WHITE_GND_EN = 1 (GND),
* WHITE_FRAME_SEL = 7 frames,
* ISC = 0 frames
*/
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETEQ,
0 x00, /* PNOEQ */
0 x00, /* NNOEQ */
0 x0B, /* PEQGND */
0 x0B, /* NEQGND */
0 x10, /* PEQVCI */
0 x10, /* NEQVCI */
0 x00, /* PEQVCI1 */
0 x00, /* NEQVCI1 */
0 x00, /* reserved */
0 x00, /* reserved */
0 xFF, /* reserved */
0 x00, /* reserved */
0 xC0, /* ESD_DET_DATA_WHITE = 1, ESD_WHITE_EN = 1 */
0 x10 /* SLPIN_OPTION = 1 (no need vsync after sleep-in)
* VEDIO_NO_CHECK_EN = 0
* ESD_WHITE_GND_EN = 0
* ESD_DET_TIME_SEL = 0 frames
*/
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETECO, 0 x01, 0 x00, 0 xFF, 0 xFF, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETPOWER,
0 x74, /* VBTHS, VBTLS: VGH = 17V, VBL = -11V */
0 x00, /* FBOFF_VGH = 0, FBOFF_VGL = 0 */
0 x32, /* VRP */
0 x32, /* VRN */
0 x77, /* reserved */
0 xF1, /* APS = 1 (small),
* VGL_DET_EN = 1, VGH_DET_EN = 1,
* VGL_TURBO = 1, VGH_TURBO = 1
*/
0 xFF, /* VGH1_L_DIV, VGL1_L_DIV (1.5MHz) */
0 xFF, /* VGH1_R_DIV, VGL1_R_DIV (1.5MHz) */
0 xCC, /* VGH2_L_DIV, VGL2_L_DIV (2.6MHz) */
0 xCC, /* VGH2_R_DIV, VGL2_R_DIV (2.6MHz) */
0 x77, /* VGH3_L_DIV, VGL3_L_DIV (4.5MHz) */
0 x77 /* VGH3_R_DIV, VGL3_R_DIV (4.5MHz) */);
/* Reference voltage. */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETBGP,
0 x07, /* VREF_SEL = 4.2V */
0 x07 /* NVREF_SEL = 4.2V */);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETVCOM,
0 x2C, /* VCOMDC_F = -0.67V */
0 x2C /* VCOMDC_B = -0.67V */);
/* Undocumented command. */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_UNKNOWN_BF, 0 x02, 0 x11, 0 x00);
/* This command is to set forward GIP timing. */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETGIP1,
0 x82, 0 x10, 0 x06, 0 x05, 0 xA2, 0 x0A, 0 xA5, 0 x12,
0 x31, 0 x23, 0 x37, 0 x83, 0 x04, 0 xBC, 0 x27, 0 x38,
0 x0C, 0 x00, 0 x03, 0 x00, 0 x00, 0 x00, 0 x0C, 0 x00,
0 x03, 0 x00, 0 x00, 0 x00, 0 x75, 0 x75, 0 x31, 0 x88,
0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 x13, 0 x88, 0 x64,
0 x64, 0 x20, 0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 x88,
0 x02, 0 x88, 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);
/* This command is to set backward GIP timing. */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETGIP2,
0 x02, 0 x21, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00,
0 x00, 0 x00, 0 x00, 0 x00, 0 x02, 0 x46, 0 x02, 0 x88,
0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 x64, 0 x88, 0 x13,
0 x57, 0 x13, 0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 x88,
0 x75, 0 x88, 0 x23, 0 x14, 0 x00, 0 x00, 0 x02, 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 x03, 0 x0A,
0 xA5, 0 x00, 0 x00, 0 x00, 0 x00);
/* Adjust the gamma characteristics of the panel. */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETGAMMA,
0 x00, 0 x09, 0 x0D, 0 x23, 0 x27, 0 x3C, 0 x41, 0 x35,
0 x07, 0 x0D, 0 x0E, 0 x12, 0 x13, 0 x10, 0 x12, 0 x12,
0 x18, 0 x00, 0 x09, 0 x0D, 0 x23, 0 x27, 0 x3C, 0 x41,
0 x35, 0 x07, 0 x0D, 0 x0E, 0 x12, 0 x13, 0 x10, 0 x12,
0 x12, 0 x18);
}
static const struct drm_display_mode xbd599_mode = {
.hdisplay = 720 ,
.hsync_start = 720 + 40 ,
.hsync_end = 720 + 40 + 40 ,
.htotal = 720 + 40 + 40 + 40 ,
.vdisplay = 1440 ,
.vsync_start = 1440 + 18 ,
.vsync_end = 1440 + 18 + 10 ,
.vtotal = 1440 + 18 + 10 + 17 ,
.clock = 69000 ,
.flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
.width_mm = 68 ,
.height_mm = 136 ,
};
static const struct st7703_panel_desc xbd599_desc = {
.mode = &xbd599_mode,
.lanes = 4 ,
.mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
.format = MIPI_DSI_FMT_RGB888,
.init_sequence = xbd599_init_sequence,
};
static void rg353v2_init_sequence(struct mipi_dsi_multi_context *dsi_ctx)
{
/*
* Init sequence was supplied by the panel vendor.
*/
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETEXTC, 0 xf1, 0 x12, 0 x83);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETAPID, 0 x00, 0 x00, 0 x00,
0 xda, 0 x80);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETDISP, 0 x00, 0 x13, 0 x70);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETRGBIF, 0 x10, 0 x10, 0 x28,
0 x28, 0 x03, 0 xff, 0 x00, 0 x00, 0 x00, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETCYC, 0 x80);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETBGP, 0 x0a, 0 x0a);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETVCOM, 0 x92, 0 x92);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETPOWER_EXT, 0 x25, 0 x22,
0 xf0, 0 x63);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETMIPI, 0 x33, 0 x81, 0 x05,
0 xf9, 0 x0e, 0 x0e, 0 x20, 0 x00, 0 x00, 0 x00, 0 x00,
0 x00, 0 x00, 0 x00, 0 x44, 0 x25, 0 x00, 0 x90, 0 x0a,
0 x00, 0 x00, 0 x01, 0 x4f, 0 x01, 0 x00, 0 x00, 0 x37);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETVDC, 0 x47);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_UNKNOWN_BF, 0 x02, 0 x11, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETSCR, 0 x73, 0 x73, 0 x50, 0 x50,
0 x00, 0 x00, 0 x12, 0 x50, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETPOWER, 0 x53, 0 xc0, 0 x32,
0 x32, 0 x77, 0 xe1, 0 xdd, 0 xdd, 0 x77, 0 x77, 0 x33,
0 x33);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETECO, 0 x82, 0 x00, 0 xbf, 0 xff,
0 x00, 0 xff);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETIO, 0 xb8, 0 x00, 0 x0a, 0 x00,
0 x00, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETCABC, 0 x10, 0 x40, 0 x1e,
0 x02);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETPANEL, 0 x0b);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETGAMMA, 0 x00, 0 x07, 0 x0d,
0 x37, 0 x35, 0 x3f, 0 x41, 0 x44, 0 x06, 0 x0c, 0 x0d,
0 x0f, 0 x11, 0 x10, 0 x12, 0 x14, 0 x1a, 0 x00, 0 x07,
0 x0d, 0 x37, 0 x35, 0 x3f, 0 x41, 0 x44, 0 x06, 0 x0c,
0 x0d, 0 x0f, 0 x11, 0 x10, 0 x12, 0 x14, 0 x1a);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETEQ, 0 x07, 0 x07, 0 x0b, 0 x0b,
0 x0b, 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, ST7703_CMD_SETGIP1, 0 xc8, 0 x10, 0 x02, 0 x00,
0 x00, 0 xb0, 0 xb1, 0 x11, 0 x31, 0 x23, 0 x28, 0 x80,
0 xb0, 0 xb1, 0 x27, 0 x08, 0 x00, 0 x04, 0 x02, 0 x00,
0 x00, 0 x00, 0 x00, 0 x04, 0 x02, 0 x00, 0 x00, 0 x00,
0 x88, 0 x88, 0 xba, 0 x60, 0 x24, 0 x08, 0 x88, 0 x88,
0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 xba, 0 x71, 0 x35,
0 x18, 0 x88, 0 x88, 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, ST7703_CMD_SETGIP2, 0 x97, 0 x0a, 0 x82, 0 x02,
0 x03, 0 x07, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00,
0 x81, 0 x88, 0 xba, 0 x17, 0 x53, 0 x88, 0 x88, 0 x88,
0 x88, 0 x88, 0 x88, 0 x80, 0 x88, 0 xba, 0 x06, 0 x42,
0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 x23, 0 x00,
0 x00, 0 x02, 0 x80, 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 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00,
0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_UNKNOWN_EF, 0 xff, 0 xff, 0 x01);
}
static const struct drm_display_mode rg353v2_mode = {
.hdisplay = 640 ,
.hsync_start = 640 + 40 ,
.hsync_end = 640 + 40 + 2 ,
.htotal = 640 + 40 + 2 + 80 ,
.vdisplay = 480 ,
.vsync_start = 480 + 18 ,
.vsync_end = 480 + 18 + 2 ,
.vtotal = 480 + 18 + 2 + 28 ,
.clock = 24150 ,
.flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
.width_mm = 70 ,
.height_mm = 57 ,
};
static const struct st7703_panel_desc rg353v2_desc = {
.mode = &rg353v2_mode,
.lanes = 4 ,
.mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
MIPI_DSI_MODE_NO_EOT_PACKET | MIPI_DSI_MODE_LPM,
.format = MIPI_DSI_FMT_RGB888,
.init_sequence = rg353v2_init_sequence,
};
static void rgb30panel_init_sequence(struct mipi_dsi_multi_context *dsi_ctx)
{
/* Init sequence extracted from Powkiddy RGB30 BSP kernel. */
/*
* For some reason this specific panel must be taken out of sleep
* before the full init sequence, or else it will not display.
*/
mipi_dsi_dcs_exit_sleep_mode_multi(dsi_ctx);
mipi_dsi_msleep(dsi_ctx, 250 );
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETEXTC, 0 xf1, 0 x12, 0 x83);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETMIPI, 0 x33, 0 x81, 0 x05, 0 xf9,
0 x0e, 0 x0e, 0 x20, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00,
0 x00, 0 x00, 0 x44, 0 x25, 0 x00, 0 x90, 0 x0a, 0 x00,
0 x00, 0 x01, 0 x4f, 0 x01, 0 x00, 0 x00, 0 x37);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETPOWER_EXT, 0 x25, 0 x22, 0 xf0,
0 x63);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_UNKNOWN_BF, 0 x02, 0 x11, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETRGBIF, 0 x10, 0 x10, 0 x28,
0 x28, 0 x03, 0 xff, 0 x00, 0 x00, 0 x00, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETSCR, 0 x73, 0 x73, 0 x50, 0 x50,
0 x00, 0 x00, 0 x12, 0 x70, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETVDC, 0 x46);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETPANEL, 0 x0b);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETCYC, 0 x80);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETDISP, 0 x3c, 0 x12, 0 x30);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_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, ST7703_CMD_SETPOWER, 0 x36, 0 x00, 0 x32,
0 x32, 0 x77, 0 xf1, 0 xcc, 0 xcc, 0 x77, 0 x77, 0 x33,
0 x33);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETBGP, 0 x0a, 0 x0a);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETVCOM, 0 x88, 0 x88);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETGIP1, 0 xc8, 0 x10, 0 x0a, 0 x10,
0 x0f, 0 xa1, 0 x80, 0 x12, 0 x31, 0 x23, 0 x47, 0 x86,
0 xa1, 0 x80, 0 x47, 0 x08, 0 x00, 0 x00, 0 x0d, 0 x00,
0 x00, 0 x00, 0 x00, 0 x00, 0 x0d, 0 x00, 0 x00, 0 x00,
0 x48, 0 x02, 0 x8b, 0 xaf, 0 x46, 0 x02, 0 x88, 0 x88,
0 x88, 0 x88, 0 x88, 0 x48, 0 x13, 0 x8b, 0 xaf, 0 x57,
0 x13, 0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 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);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETGIP2, 0 x96, 0 x12, 0 x01, 0 x01,
0 x01, 0 x78, 0 x02, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00,
0 x4f, 0 x31, 0 x8b, 0 xa8, 0 x31, 0 x75, 0 x88, 0 x88,
0 x88, 0 x88, 0 x88, 0 x4f, 0 x20, 0 x8b, 0 xa8, 0 x20,
0 x64, 0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 x23, 0 x00,
0 x00, 0 x01, 0 x02, 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 x40, 0 xa1, 0 x80, 0 x00, 0 x00, 0 x00,
0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETGAMMA, 0 x00, 0 x0a, 0 x0f,
0 x29, 0 x3b, 0 x3f, 0 x42, 0 x39, 0 x06, 0 x0d, 0 x10,
0 x13, 0 x15, 0 x14, 0 x15, 0 x10, 0 x17, 0 x00, 0 x0a,
0 x0f, 0 x29, 0 x3b, 0 x3f, 0 x42, 0 x39, 0 x06, 0 x0d,
0 x10, 0 x13, 0 x15, 0 x14, 0 x15, 0 x10, 0 x17);
}
static const struct drm_display_mode rgb30panel_mode = {
.hdisplay = 720 ,
.hsync_start = 720 + 45 ,
.hsync_end = 720 + 45 + 4 ,
.htotal = 720 + 45 + 4 + 45 ,
.vdisplay = 720 ,
.vsync_start = 720 + 15 ,
.vsync_end = 720 + 15 + 3 ,
.vtotal = 720 + 15 + 3 + 11 ,
.clock = 36570 ,
.flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
.width_mm = 76 ,
.height_mm = 76 ,
};
static const struct st7703_panel_desc rgb30panel_desc = {
.mode = &rgb30panel_mode,
.lanes = 4 ,
.mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
MIPI_DSI_MODE_NO_EOT_PACKET | MIPI_DSI_MODE_LPM,
.format = MIPI_DSI_FMT_RGB888,
.init_sequence = rgb30panel_init_sequence,
};
static void rgb10max3_panel_init_sequence(struct mipi_dsi_multi_context *dsi_ctx)
{
/* Init sequence extracted from Powkiddy RGB10MAX3 BSP kernel. */
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETEXTC, 0 xf1, 0 x12, 0 x83);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETAPID, 0 x00, 0 x00, 0 x00, 0 xda,
0 x80);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETDISP, 0 xc8, 0 x02, 0 x30);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETRGBIF, 0 x10, 0 x10, 0 x28,
0 x28, 0 x03, 0 xff, 0 x00, 0 x00, 0 x00, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETCYC, 0 x80);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETBGP, 0 x04, 0 x04);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETVCOM, 0 x78, 0 x78);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETPOWER_EXT, 0 x25, 0 x22, 0 xf0,
0 x63);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETMIPI, 0 x33, 0 x81, 0 x05, 0 xf9,
0 x0e, 0 x0e, 0 x20, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00,
0 x00, 0 x00, 0 x44, 0 x25, 0 x00, 0 x90, 0 x0a, 0 x00,
0 x00, 0 x01, 0 x4f, 0 x01, 0 x00, 0 x00, 0 x37);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETVDC, 0 x47);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_UNKNOWN_BF, 0 x02, 0 x11, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETSCR, 0 x73, 0 x73, 0 x50, 0 x50,
0 x00, 0 x00, 0 x12, 0 x70, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETPOWER, 0 x25, 0 x00, 0 x32,
0 x32, 0 x77, 0 xe1, 0 xff, 0 xff, 0 xcc, 0 xcc, 0 x77,
0 x77);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETECO, 0 x82, 0 x00, 0 xbf, 0 xff,
0 x00, 0 xff);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETIO, 0 xb8, 0 x00, 0 x0a, 0 x00,
0 x00, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETCABC, 0 x10, 0 x40, 0 x1e,
0 x02);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETPANEL, 0 x0b);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETGAMMA, 0 x00, 0 x04, 0 x07,
0 x2a, 0 x39, 0 x3f, 0 x36, 0 x31, 0 x06, 0 x0b, 0 x0e,
0 x12, 0 x14, 0 x12, 0 x13, 0 x0f, 0 x17, 0 x00, 0 x04,
0 x07, 0 x2a, 0 x39, 0 x3f, 0 x36, 0 x31, 0 x06, 0 x0b,
0 x0e, 0 x12, 0 x14, 0 x12, 0 x13, 0 x0f, 0 x17);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETEQ, 0 x03, 0 x03, 0 x03, 0 x03,
0 x00, 0 x03, 0 x00, 0 x00, 0 x00, 0 x00, 0 xff, 0 x80,
0 xc0, 0 x10);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETGIP1, 0 xc8, 0 x10, 0 x08, 0 x00,
0 x00, 0 x41, 0 xf8, 0 x12, 0 x31, 0 x23, 0 x37, 0 x86,
0 x11, 0 xc8, 0 x37, 0 x2a, 0 x00, 0 x00, 0 x0c, 0 x00,
0 x00, 0 x00, 0 x00, 0 x00, 0 x0c, 0 x00, 0 x00, 0 x00,
0 x88, 0 x20, 0 x46, 0 x02, 0 x88, 0 x88, 0 x88, 0 x88,
0 x88, 0 x88, 0 xff, 0 x88, 0 x31, 0 x57, 0 x13, 0 x88,
0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 xff, 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);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETGIP2, 0 x00, 0 x1a, 0 x00, 0 x00,
0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00,
0 x8f, 0 x13, 0 x31, 0 x75, 0 x88, 0 x88, 0 x88, 0 x88,
0 x88, 0 x88, 0 xf8, 0 x8f, 0 x02, 0 x20, 0 x64, 0 x88,
0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 xf8, 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 x00, 0 x00, 0 x00,
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, ST7703_CMD_UNKNOWN_EF, 0 xff, 0 xff, 0 x01);
}
static const struct drm_display_mode rgb10max3_panel_mode = {
.hdisplay = 720 ,
.hsync_start = 720 + 40 ,
.hsync_end = 720 + 40 + 10 ,
.htotal = 720 + 40 + 10 + 40 ,
.vdisplay = 1280 ,
.vsync_start = 1280 + 16 ,
.vsync_end = 1280 + 16 + 4 ,
.vtotal = 1280 + 16 + 4 + 14 ,
.clock = 63800 ,
.flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
.width_mm = 62 ,
.height_mm = 109 ,
};
static const struct st7703_panel_desc rgb10max3_panel_desc = {
.mode = &rgb10max3_panel_mode,
.lanes = 4 ,
.mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
MIPI_DSI_MODE_NO_EOT_PACKET | MIPI_DSI_MODE_LPM,
.format = MIPI_DSI_FMT_RGB888,
.init_sequence = rgb10max3_panel_init_sequence,
};
static void gameforcechi_init_sequence(struct mipi_dsi_multi_context *dsi_ctx)
{
/*
* Init sequence was supplied by the panel vendor. Panel will not
* respond to commands until it is brought out of sleep mode first.
*/
mipi_dsi_dcs_exit_sleep_mode_multi(dsi_ctx);
mipi_dsi_msleep(dsi_ctx, 250 );
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETEXTC, 0 xf1, 0 x12, 0 x83);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETMIPI, 0 x31, 0 x81, 0 x05, 0 xf9,
0 x0e, 0 x0e, 0 x20, 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 xd1, 0 x00, 0 x00, 0 x37);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETPOWER_EXT, 0 x25);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_UNKNOWN_BF, 0 x02, 0 x11, 0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_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, ST7703_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, ST7703_CMD_SETVDC, 0 x46);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETPANEL, 0 x0b);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETCYC, 0 x80);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETDISP, 0 x00, 0 x13, 0 xf0);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_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, ST7703_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, ST7703_CMD_SETBGP, 0 x10, 0 x10);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETVCOM, 0 x6c, 0 x7c);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETGIP1, 0 x08, 0 x00, 0 x0e, 0 x00,
0 x00, 0 xb0, 0 xb1, 0 x11, 0 x31, 0 x23, 0 x28, 0 x10,
0 xb0, 0 xb1, 0 x27, 0 x08, 0 x00, 0 x04, 0 x02, 0 x00,
0 x00, 0 x00, 0 x00, 0 x04, 0 x02, 0 x00, 0 x00, 0 x00,
0 x88, 0 x88, 0 xba, 0 x60, 0 x24, 0 x08, 0 x88, 0 x88,
0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 xba, 0 x71, 0 x35,
0 x18, 0 x88, 0 x88, 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, ST7703_CMD_SETGIP2, 0 x97, 0 x0a, 0 x82, 0 x02,
0 x13, 0 x07, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00,
0 x80, 0 x88, 0 xba, 0 x17, 0 x53, 0 x88, 0 x88, 0 x88,
0 x88, 0 x88, 0 x88, 0 x81, 0 x88, 0 xba, 0 x06, 0 x42,
0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 x88, 0 x23, 0 x10,
0 x00, 0 x02, 0 x80, 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 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00,
0 x00);
mipi_dsi_dcs_write_seq_multi(dsi_ctx, ST7703_CMD_SETGAMMA, 0 x00, 0 x07, 0 x0b,
0 x27, 0 x2d, 0 x3f, 0 x3b, 0 x37, 0 x05, 0 x0a, 0 x0b,
0 x0f, 0 x11, 0 x0f, 0 x12, 0 x12, 0 x18, 0 x00, 0 x07,
0 x0b, 0 x27, 0 x2d, 0 x3f, 0 x3b, 0 x37, 0 x05, 0 xa0,
0 x0b, 0 x0f, 0 x11, 0 x0f, 0 x12, 0 x12, 0 x18);
}
static const struct drm_display_mode gameforcechi_mode = {
.hdisplay = 640 ,
.hsync_start = 640 + 40 ,
.hsync_end = 640 + 40 + 2 ,
.htotal = 640 + 40 + 2 + 80 ,
.vdisplay = 480 ,
.vsync_start = 480 + 17 ,
.vsync_end = 480 + 17 + 5 ,
.vtotal = 480 + 17 + 5 + 13 ,
.clock = 23546 ,
.flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
.width_mm = 71 ,
.height_mm = 53 ,
};
static const struct st7703_panel_desc gameforcechi_desc = {
.mode = &gameforcechi_mode,
.lanes = 2 ,
.mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
MIPI_DSI_MODE_NO_EOT_PACKET | MIPI_DSI_MODE_LPM,
.format = MIPI_DSI_FMT_RGB888,
.init_sequence = gameforcechi_init_sequence,
};
static int st7703_enable(struct drm_panel *panel)
{
struct st7703 *ctx = panel_to_st7703(panel);
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
struct mipi_dsi_multi_context dsi_ctx = {.dsi = dsi};
ctx->desc->init_sequence(&dsi_ctx);
mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
/* It takes the controller 120 msec to wake up after sleep. */
mipi_dsi_msleep(&dsi_ctx, 120 );
mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
if (!dsi_ctx.accum_err)
dev_dbg(ctx->dev, "Panel init sequence done\n" );
return dsi_ctx.accum_err;
}
static int st7703_disable(struct drm_panel *panel)
{
struct st7703 *ctx = panel_to_st7703(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);
/* It takes the controller 120 msec to enter sleep mode. */
mipi_dsi_msleep(&dsi_ctx, 120 );
return dsi_ctx.accum_err;
}
static int st7703_unprepare(struct drm_panel *panel)
{
struct st7703 *ctx = panel_to_st7703(panel);
gpiod_set_value_cansleep(ctx->reset_gpio, 1 );
regulator_disable(ctx->iovcc);
regulator_disable(ctx->vcc);
return 0 ;
}
static int st7703_prepare(struct drm_panel *panel)
{
struct st7703 *ctx = panel_to_st7703(panel);
int ret;
dev_dbg(ctx->dev, "Resetting the panel\n" );
gpiod_set_value_cansleep(ctx->reset_gpio, 1 );
ret = regulator_enable(ctx->iovcc);
if (ret < 0 ) {
dev_err(ctx->dev, "Failed to enable iovcc supply: %d\n" , ret);
return ret;
}
ret = regulator_enable(ctx->vcc);
if (ret < 0 ) {
dev_err(ctx->dev, "Failed to enable vcc supply: %d\n" , ret);
regulator_disable(ctx->iovcc);
return ret;
}
/* Give power supplies time to stabilize before deasserting reset. */
usleep_range(10000 , 20000 );
gpiod_set_value_cansleep(ctx->reset_gpio, 0 );
usleep_range(15000 , 20000 );
return 0 ;
}
static const u32 mantix_bus_formats[] = {
MEDIA_BUS_FMT_RGB888_1X24,
};
static int st7703_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
struct st7703 *ctx = panel_to_st7703(panel);
struct drm_display_mode *mode;
mode = drm_mode_duplicate(connector->dev, ctx->desc->mode);
if (!mode) {
dev_err(ctx->dev, "Failed to add mode %ux%u@%u\n" ,
ctx->desc->mode->hdisplay, ctx->desc->mode->vdisplay,
drm_mode_vrefresh(ctx->desc->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);
drm_display_info_set_bus_formats(&connector->display_info,
mantix_bus_formats,
ARRAY_SIZE(mantix_bus_formats));
return 1 ;
}
static enum drm_panel_orientation st7703_get_orientation(struct drm_panel *panel)
{
struct st7703 *st7703 = panel_to_st7703(panel);
return st7703->orientation;
}
static const struct drm_panel_funcs st7703_drm_funcs = {
.disable = st7703_disable,
.unprepare = st7703_unprepare,
.prepare = st7703_prepare,
.enable = st7703_enable,
.get_modes = st7703_get_modes,
.get_orientation = st7703_get_orientation,
};
static int allpixelson_set(void *data, u64 val)
{
struct st7703 *ctx = data;
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
struct mipi_dsi_multi_context dsi_ctx = {.dsi = dsi};
dev_dbg(ctx->dev, "Setting all pixels on\n" );
mipi_dsi_generic_write_seq_multi(&dsi_ctx, ST7703_CMD_ALL_PIXEL_ON);
mipi_dsi_msleep(&dsi_ctx, val * 1000 );
/*
* Reset the panel to get video back. NOTE: This isn't a
* particularly safe thing to do in general because it assumes
* that the screen was on to begin with, but this is just a
* debugfs file so it's not a huge deal.
*/
drm_panel_disable(&ctx->panel);
drm_panel_unprepare(&ctx->panel);
drm_panel_prepare(&ctx->panel);
drm_panel_enable(&ctx->panel);
return dsi_ctx.accum_err;
}
DEFINE_SIMPLE_ATTRIBUTE(allpixelson_fops, NULL,
allpixelson_set, "%llu\n" );
static void st7703_debugfs_init(struct st7703 *ctx)
{
ctx->debugfs = debugfs_create_dir(DRV_NAME, NULL);
debugfs_create_file("allpixelson" , 0600 , ctx->debugfs, ctx,
&allpixelson_fops);
}
static void st7703_debugfs_remove(struct st7703 *ctx)
{
debugfs_remove_recursive(ctx->debugfs);
ctx->debugfs = NULL;
}
static int st7703_probe(struct mipi_dsi_device *dsi)
{
struct device *dev = &dsi->dev;
struct st7703 *ctx;
int ret;
ctx = devm_drm_panel_alloc(dev, struct st7703, panel,
&st7703_drm_funcs,
DRM_MODE_CONNECTOR_DSI);
if (IS_ERR(ctx))
return PTR_ERR(ctx);
ctx->reset_gpio = devm_gpiod_get(dev, "reset" , GPIOD_OUT_LOW);
if (IS_ERR(ctx->reset_gpio))
return dev_err_probe(dev, PTR_ERR(ctx->reset_gpio), "Failed to get reset gpio\n" );
mipi_dsi_set_drvdata(dsi, ctx);
ctx->dev = dev;
ctx->desc = of_device_get_match_data(dev);
dsi->mode_flags = ctx->desc->mode_flags;
dsi->format = ctx->desc->format;
dsi->lanes = ctx->desc->lanes;
ctx->vcc = devm_regulator_get(dev, "vcc" );
if (IS_ERR(ctx->vcc))
return dev_err_probe(dev, PTR_ERR(ctx->vcc), "Failed to request vcc 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" );
ret = of_drm_get_panel_orientation(dsi->dev.of_node, &ctx->orientation);
if (ret < 0 )
return dev_err_probe(&dsi->dev, ret, "Failed to get orientation\n" );
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). Is host ready?\n" , ret);
drm_panel_remove(&ctx->panel);
return ret;
}
dev_info(dev, "%ux%u@%u %ubpp dsi %udl - ready\n" ,
ctx->desc->mode->hdisplay, ctx->desc->mode->vdisplay,
drm_mode_vrefresh(ctx->desc->mode),
mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes);
st7703_debugfs_init(ctx);
return 0 ;
}
static void st7703_remove(struct mipi_dsi_device *dsi)
{
struct st7703 *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);
st7703_debugfs_remove(ctx);
}
static const struct of_device_id st7703_of_match[] = {
{ .compatible = "anbernic,rg353v-panel-v2" , .data = &rg353v2_desc },
{ .compatible = "gameforce,chi-panel" , .data = &gameforcechi_desc },
{ .compatible = "powkiddy,rgb10max3-panel" , .data = &rgb10max3_panel_desc },
{ .compatible = "powkiddy,rgb30-panel" , .data = &rgb30panel_desc },
{ .compatible = "rocktech,jh057n00900" , .data = &jh057n00900_panel_desc },
{ .compatible = "xingbangda,xbd599" , .data = &xbd599_desc },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, st7703_of_match);
static struct mipi_dsi_driver st7703_driver = {
.probe = st7703_probe,
.remove = st7703_remove,
.driver = {
.name = DRV_NAME,
.of_match_table = st7703_of_match,
},
};
module_mipi_dsi_driver(st7703_driver);
MODULE_AUTHOR("Guido Günther <agx@sigxcpu.org>" );
MODULE_DESCRIPTION("DRM driver for Sitronix ST7703 based MIPI DSI panels" );
MODULE_LICENSE("GPL v2" );
Messung V0.5 in Prozent C=93 H=97 G=94
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-06-07)
¤
*© Formatika GbR, Deutschland