1 /*
2  * Copyright (c) 2020 Teslabs Engineering S.L.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #ifndef ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9488_H_
7 #define ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9488_H_
8 
9 #include <zephyr/device.h>
10 
11 /* Commands/registers. */
12 #define ILI9488_FRMCTR1 0xB1
13 #define ILI9488_DISCTRL 0xB6
14 #define ILI9488_PWCTRL1 0xC0
15 #define ILI9488_PWCTRL2 0xC1
16 #define ILI9488_VMCTRL 0xC5
17 #define ILI9488_PGAMCTRL 0xE0
18 #define ILI9488_NGAMCTRL 0xE1
19 
20 /* Commands/registers length. */
21 #define ILI9488_FRMCTR1_LEN 2U
22 #define ILI9488_DISCTRL_LEN 3U
23 #define ILI9488_PWCTRL1_LEN 2U
24 #define ILI9488_PWCTRL2_LEN 1U
25 #define ILI9488_VMCTRL_LEN 4U
26 #define ILI9488_PGAMCTRL_LEN 15U
27 #define ILI9488_NGAMCTRL_LEN 15U
28 
29 /** X resolution (pixels). */
30 #define ILI9488_X_RES 320U
31 /** Y resolution (pixels). */
32 #define ILI9488_Y_RES 480U
33 
34 /** ILI9488 registers to be initialized. */
35 struct ili9488_regs {
36 	uint8_t frmctr1[ILI9488_FRMCTR1_LEN];
37 	uint8_t disctrl[ILI9488_DISCTRL_LEN];
38 	uint8_t pwctrl1[ILI9488_PWCTRL1_LEN];
39 	uint8_t pwctrl2[ILI9488_PWCTRL2_LEN];
40 	uint8_t vmctrl[ILI9488_VMCTRL_LEN];
41 	uint8_t pgamctrl[ILI9488_PGAMCTRL_LEN];
42 	uint8_t ngamctrl[ILI9488_NGAMCTRL_LEN];
43 };
44 
45 /* Initializer macro for ILI9488 registers. */
46 #define ILI9488_REGS_INIT(n)                                                   \
47 	static const struct ili9488_regs ili9xxx_regs_##n = {                  \
48 		.frmctr1 = DT_PROP(DT_INST(n, ilitek_ili9488), frmctr1),       \
49 		.disctrl = DT_PROP(DT_INST(n, ilitek_ili9488), disctrl),       \
50 		.pwctrl1 = DT_PROP(DT_INST(n, ilitek_ili9488), pwctrl1),       \
51 		.pwctrl2 = DT_PROP(DT_INST(n, ilitek_ili9488), pwctrl2),       \
52 		.vmctrl = DT_PROP(DT_INST(n, ilitek_ili9488), vmctrl),         \
53 		.pgamctrl = DT_PROP(DT_INST(n, ilitek_ili9488), pgamctrl),     \
54 		.ngamctrl = DT_PROP(DT_INST(n, ilitek_ili9488), ngamctrl),     \
55 	}
56 
57 /**
58  * @brief Initialize ILI9488 registers with DT values.
59  *
60  * @param dev ILI9488 device instance
61  * @return 0 on success, errno otherwise.
62  */
63 int ili9488_regs_init(const struct device *dev);
64 
65 #endif /* ZEPHYR_DRIVERS_DISPLAY_DISPLAY_ILI9488_H_ */
66