Skip to content

Commit

Permalink
drivers: display: ili9340: move VCOM parameters to DT
Browse files Browse the repository at this point in the history
Move VCOM control 1/2 register values to DT.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
  • Loading branch information
gmarull authored and MaureenHelm committed Sep 29, 2020
1 parent a1ce0c8 commit 4895620
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 30 deletions.
2 changes: 2 additions & 0 deletions boards/arc/hsdk/hsdk.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
spi-max-frequency = <12000000>;
label = "DISPLAY";
pwctrl1 = [1b 00];
vmctrl1 = [3f 3c];
vmctrl2 = [b7];
pgamctrl = [0f 2a 28 08 0e 08 54 a9 43 0a 0f 00 00 00 00];
ngamctrl = [00 15 17 07 11 06 2b 56 3c 05 10 0f 3f 3f 0f];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
pixel-format = <ILI9340_PIXEL_FORMAT_RGB888>;
rotation = <90>;
pwctrl1 = [23 00];
vmctrl1 = [3e 28];
vmctrl2 = [86];
pgamctrl = [0f 31 2b 0c 0e 08 4e f1 37 07 10 03 0e 09 00];
ngamctrl = [00 0e 14 03 11 07 31 c1 48 08 0f 0c 31 36 0f];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
pixel-format = <ILI9340_PIXEL_FORMAT_RGB565>;
rotation = <0>;
pwctrl1 = [23 00];
vmctrl1 = [3e 28];
vmctrl2 = [86];
pgamctrl = [0f 31 2b 0c 0e 08 4e f1 37 07 10 03 0e 09 00];
ngamctrl = [00 0e 14 03 11 07 31 c1 48 08 0f 0c 31 36 0f];
};
Expand Down
20 changes: 20 additions & 0 deletions drivers/display/display_ili9340.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ struct ili9340_config {
uint8_t gamset[ILI9340_GAMSET_LEN];
uint8_t pwctrl1[ILI9340_PWCTRL1_LEN];
uint8_t pwctrl2[ILI9340_PWCTRL2_LEN];
uint8_t vmctrl1[ILI9340_VMCTRL1_LEN];
uint8_t vmctrl2[ILI9340_VMCTRL2_LEN];
uint8_t pgamctrl[ILI9340_PGAMCTRL_LEN];
uint8_t ngamctrl[ILI9340_NGAMCTRL_LEN];
};
Expand Down Expand Up @@ -390,6 +392,22 @@ static int ili9340_configure(const struct device *dev)
return r;
}

LOG_HEXDUMP_DBG(config->vmctrl1, ILI9340_VMCTRL1_LEN, "VMCTRL1");
memcpy(tx_data, config->vmctrl1, ILI9340_VMCTRL1_LEN);
r = ili9340_transmit(dev, ILI9340_CMD_VCOM_CTRL_1, tx_data,
ILI9340_VMCTRL1_LEN);
if (r < 0) {
return r;
}

LOG_HEXDUMP_DBG(config->vmctrl2, ILI9340_VMCTRL2_LEN, "VMCTRL2");
memcpy(tx_data, config->vmctrl2, ILI9340_VMCTRL2_LEN);
r = ili9340_transmit(dev, ILI9340_CMD_VCOM_CTRL_2, tx_data,
ILI9340_VMCTRL2_LEN);
if (r < 0) {
return r;
}

LOG_HEXDUMP_DBG(config->pgamctrl, ILI9340_PGAMCTRL_LEN, "PGAMCTRL");
memcpy(tx_data, config->pgamctrl, ILI9340_PGAMCTRL_LEN);
r = ili9340_transmit(dev, ILI9340_CMD_POSITIVE_GAMMA_CORRECTION,
Expand Down Expand Up @@ -527,6 +545,8 @@ static const struct display_driver_api ili9340_api = {
.gamset = DT_INST_PROP(index, gamset), \
.pwctrl1 = DT_INST_PROP(index, pwctrl1), \
.pwctrl2 = DT_INST_PROP(index, pwctrl2), \
.vmctrl1 = DT_INST_PROP(index, vmctrl1), \
.vmctrl2 = DT_INST_PROP(index, vmctrl2), \
.pgamctrl = DT_INST_PROP(index, pgamctrl), \
.ngamctrl = DT_INST_PROP(index, ngamctrl), \
}; \
Expand Down
2 changes: 2 additions & 0 deletions drivers/display/display_ili9340.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#define ILI9340_GAMSET_LEN 1U
#define ILI9340_PWCTRL1_LEN 2U
#define ILI9340_PWCTRL2_LEN 1U
#define ILI9340_VMCTRL1_LEN 2U
#define ILI9340_VMCTRL2_LEN 1U
#define ILI9340_PGAMCTRL_LEN 15U
#define ILI9340_NGAMCTRL_LEN 15U

Expand Down
13 changes: 0 additions & 13 deletions drivers/display/display_ili9340_adafruit_1480.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,6 @@ int ili9340_lcd_init(const struct device *dev)
int r;
uint8_t tx_data[15];

tx_data[0] = 0x3e;
tx_data[1] = 0x28;
r = ili9340_transmit(dev, ILI9340_CMD_VCOM_CTRL_1, tx_data, 2);
if (r < 0) {
return r;
}

tx_data[0] = 0x86;
r = ili9340_transmit(dev, ILI9340_CMD_VCOM_CTRL_2, tx_data, 1);
if (r < 0) {
return r;
}

tx_data[0] = 0x00;
tx_data[1] = 0x18;
r = ili9340_transmit(dev, ILI9340_CMD_FRAME_CTRL_NORMAL_MODE, tx_data, 2);
Expand Down
17 changes: 0 additions & 17 deletions drivers/display/display_ili9340_seeed_tftv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,6 @@ int ili9340_lcd_init(const struct device *dev)
return r;
}

/* VCM control */
cmd = ILI9340_CMD_VCOM_CTRL_1;
data[0] = 0x3FU;
data[1] = 0x3CU;
r = ili9340_transmit(dev, cmd, data, 2);
if (r < 0) {
return r;
}

/* VCM control2 */
cmd = ILI9340_CMD_VCOM_CTRL_2;
data[0] = 0xB7U;
r = ili9340_transmit(dev, cmd, data, 1);
if (r < 0) {
return r;
}

/* Frame Rate */
cmd = ILI9340_CMD_FRAME_CTRL_NORMAL_MODE;
data[0] = 0x00U;
Expand Down
12 changes: 12 additions & 0 deletions dts/bindings/display/ilitek,ili9340.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ properties:
description:
Power control 2 (PWCTRL2) register values.

vmctrl1:
type: uint8-array
default: [0x31, 0x3c]
description:
VCOM control 1 (VMCTRL1) register values.

vmctrl2:
type: uint8-array
default: [0xc0]
description:
VCOM control 2 (VMCTRL2) register values.

pgamctrl:
type: uint8-array
default: [
Expand Down

0 comments on commit 4895620

Please sign in to comment.