Skip to content

Commit

Permalink
patch: kernel: rk35xx-vendor-6.1: fix ili9881c
Browse files Browse the repository at this point in the history
  • Loading branch information
bmx666 committed Dec 18, 2024
1 parent 02811ed commit 3ac68d5
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 0 deletions.
101 changes: 101 additions & 0 deletions patch/kernel/rk35xx-vendor-6.1/ili9881c-debug.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
index cbb68caa36f2..6043f975f5ab 100644
--- a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
+++ b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
@@ -24,6 +24,7 @@
enum ili9881c_op {
ILI9881C_SWITCH_PAGE,
ILI9881C_COMMAND,
+ ILI9881C_READ_ID,
};

struct ili9881c_instr {
@@ -75,6 +76,17 @@ struct ili9881c {
}, \
}

+#define ILI9881C_READ_ID_INSTR(_cmd, _data) \
+ { \
+ .op = ILI9881C_READ_ID, \
+ .arg = { \
+ .cmd = { \
+ .cmd = (_cmd), \
+ .data = (_data), \
+ }, \
+ }, \
+ }
+
static const struct ili9881c_instr lhr050h41_init[] = {
ILI9881C_SWITCH_PAGE_INSTR(3),
ILI9881C_COMMAND_INSTR(0x01, 0x00),
@@ -264,6 +276,8 @@ static const struct ili9881c_instr lhr050h41_init[] = {
};

static const struct ili9881c_instr k101_im2byl02_init[] = {
+ ILI9881C_SWITCH_PAGE_INSTR(1),
+ ILI9881C_READ_ID_INSTR(0x00, 0x00),
ILI9881C_SWITCH_PAGE_INSTR(3),
ILI9881C_COMMAND_INSTR(0x01, 0x00),
ILI9881C_COMMAND_INSTR(0x02, 0x00),
@@ -684,6 +697,8 @@ static int ili9881c_switch_page(struct ili9881c *ctx, u8 page)
u8 buf[4] = { 0xff, 0x98, 0x81, page };
int ret;

+ dev_warn(&ctx->dsi->dev, "SWITCH PAGE: page = %02x\n", page);
+
ret = mipi_dsi_dcs_write_buffer(ctx->dsi, buf, sizeof(buf));
if (ret < 0)
return ret;
@@ -696,6 +711,8 @@ static int ili9881c_send_cmd_data(struct ili9881c *ctx, u8 cmd, u8 data)
u8 buf[2] = { cmd, data };
int ret;

+ dev_warn(&ctx->dsi->dev, "SEND COMMAND: cmd = %02x, data = %02x\n", cmd, data);
+
ret = mipi_dsi_dcs_write_buffer(ctx->dsi, buf, sizeof(buf));
if (ret < 0)
return ret;
@@ -703,6 +720,34 @@ static int ili9881c_send_cmd_data(struct ili9881c *ctx, u8 cmd, u8 data)
return 0;
}

+static int ili9881c_read_id(struct ili9881c *ctx)
+{
+ u8 id1, id2, id3;
+ int ret;
+
+ dev_warn(&ctx->dsi->dev, "READ ID\n");
+
+ ret = mipi_dsi_dcs_read(ctx->dsi, 0x00, &id1, 1);
+ if (ret < 0) {
+ dev_err(&ctx->dsi->dev, "could not read MTP ID1\n");
+ return ret;
+ }
+ ret = mipi_dsi_dcs_read(ctx->dsi, 0x01, &id2, 1);
+ if (ret < 0) {
+ dev_err(&ctx->dsi->dev, "could not read MTP ID2\n");
+ return ret;
+ }
+ ret = mipi_dsi_dcs_read(ctx->dsi, 0x02, &id3, 1);
+ if (ret < 0) {
+ dev_err(&ctx->dsi->dev, "could not read MTP ID3\n");
+ return ret;
+ }
+
+ dev_warn(&ctx->dsi->dev, "MTP ID4: %02x %02x %02x\n", id1, id2, id3);
+
+ return 0;
+}
+
static int ili9881c_prepare(struct drm_panel *panel)
{
struct ili9881c *ctx = panel_to_ili9881c(panel);
@@ -730,6 +775,8 @@ static int ili9881c_prepare(struct drm_panel *panel)
else if (instr->op == ILI9881C_COMMAND)
ret = ili9881c_send_cmd_data(ctx, instr->arg.cmd.cmd,
instr->arg.cmd.data);
+ else if (instr->op == ILI9881C_READ_ID)
+ ret = ili9881c_read_id(ctx);

if (ret)
return ret;
35 changes: 35 additions & 0 deletions patch/kernel/rk35xx-vendor-6.1/ili9881c-fix-init-sequence.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
index cbb68caa36f2..6043f975f5ab 100644
--- a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
+++ b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
@@ -283,8 +297,8 @@ static const struct ili9881c_instr k101_im2byl02_init[] = {
ILI9881C_COMMAND_INSTR(0x10, 0x00),
ILI9881C_COMMAND_INSTR(0x11, 0x00),
ILI9881C_COMMAND_INSTR(0x12, 0x00),
- ILI9881C_COMMAND_INSTR(0x13, 0x00),
- ILI9881C_COMMAND_INSTR(0x14, 0x00),
+ ILI9881C_COMMAND_INSTR(0x13, 0x1F),
+ ILI9881C_COMMAND_INSTR(0x14, 0x1F),
ILI9881C_COMMAND_INSTR(0x15, 0x00),
ILI9881C_COMMAND_INSTR(0x16, 0x00),
ILI9881C_COMMAND_INSTR(0x17, 0x00),
@@ -393,7 +407,7 @@ static const struct ili9881c_instr k101_im2byl02_init[] = {
ILI9881C_COMMAND_INSTR(0x89, 0x0E),
ILI9881C_COMMAND_INSTR(0x8A, 0x02),
ILI9881C_SWITCH_PAGE_INSTR(4),
- ILI9881C_COMMAND_INSTR(0x3B, 0xC0), /* ILI4003D sel */
+ ILI9881C_COMMAND_INSTR(0x00, 0x00),
ILI9881C_COMMAND_INSTR(0x6C, 0x15), /* Set VCORE voltage = 1.5V */
ILI9881C_COMMAND_INSTR(0x6E, 0x2A), /* di_pwr_reg=0 for power mode 2A, VGH clamp 18V */
ILI9881C_COMMAND_INSTR(0x6F, 0x33), /* pumping ratio VGH=5x VGL=-3x */
@@ -405,9 +419,8 @@ static const struct ili9881c_instr k101_im2byl02_init[] = {
ILI9881C_SWITCH_PAGE_INSTR(1),
ILI9881C_COMMAND_INSTR(0x22, 0x0A), /* BGR, SS */
ILI9881C_COMMAND_INSTR(0x31, 0x00), /* Zigzag type3 inversion */
- ILI9881C_COMMAND_INSTR(0x40, 0x53), /* ILI4003D sel */
ILI9881C_COMMAND_INSTR(0x43, 0x66),
- ILI9881C_COMMAND_INSTR(0x53, 0x4C),
+ ILI9881C_COMMAND_INSTR(0x53, 0x42),
ILI9881C_COMMAND_INSTR(0x50, 0x87),
ILI9881C_COMMAND_INSTR(0x51, 0x82),
ILI9881C_COMMAND_INSTR(0x60, 0x15),
13 changes: 13 additions & 0 deletions patch/kernel/rk35xx-vendor-6.1/ili9881c-fix-pixelclk.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
index cbb68caa36f2..6043f975f5ab 100644
--- a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
+++ b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
@@ -797,7 +844,7 @@ static const struct drm_display_mode lhr050h41_default_mode = {
};

static const struct drm_display_mode k101_im2byl02_default_mode = {
- .clock = 69700,
+ .clock = 58000,

.hdisplay = 800,
.hsync_start = 800 + 52,

0 comments on commit 3ac68d5

Please sign in to comment.