Skip to content

Commit 22a922f

Browse files
danieldegrassefabiobaltieri
authored andcommitted
drivers: mipi_dbi: nxp_lcdic: add support for 8080 mode
Enable support for 8 bit 8080 mode in the NXP LCDIC driver. Support for programming the minimum duration of the write active/inactive signal is also added, since this will be required to support high display clocks in 8080 mode. Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent 04726a2 commit 22a922f

File tree

2 files changed

+57
-10
lines changed

2 files changed

+57
-10
lines changed

drivers/mipi_dbi/mipi_dbi_nxp_lcdic.c

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ struct mipi_dbi_lcdic_config {
7272
const struct device *clock_dev;
7373
clock_control_subsys_t clock_subsys;
7474
bool swap_bytes;
75+
uint8_t write_active_min;
76+
uint8_t write_inactive_min;
7577
};
7678

7779
#ifdef CONFIG_MIPI_DBI_NXP_LCDIC_DMA
@@ -249,10 +251,6 @@ static int mipi_dbi_lcdic_configure(const struct device *dev,
249251
LOG_ERR("Invalid clock frequency %d", spi_cfg->frequency);
250252
return ret;
251253
}
252-
if (!(spi_cfg->operation & SPI_HALF_DUPLEX)) {
253-
LOG_ERR("LCDIC only supports half duplex operation");
254-
return -ENOTSUP;
255-
}
256254
if (spi_cfg->slave != 0) {
257255
/* Only one slave select line */
258256
return -ENOTSUP;
@@ -265,13 +263,26 @@ static int mipi_dbi_lcdic_configure(const struct device *dev,
265263
reg = base->CTRL;
266264
/* Disable LCD module during configuration */
267265
reg &= ~LCDIC_CTRL_LCDIC_EN_MASK;
268-
/* Select SPI mode */
269-
reg &= ~LCDIC_CTRL_LCDIC_MD_MASK;
270-
/* Select 3 or 4 wire mode based on config selection */
271-
if (dbi_config->mode == MIPI_DBI_MODE_SPI_4WIRE) {
266+
if (dbi_config->mode == MIPI_DBI_MODE_8080_BUS_8_BIT) {
267+
/* Enable 8080 Mode */
268+
reg |= LCDIC_CTRL_LCDIC_MD_MASK;
269+
} else if (dbi_config->mode == MIPI_DBI_MODE_SPI_4WIRE) {
270+
/* Select SPI 4 wire mode */
272271
reg |= LCDIC_CTRL_SPI_MD_MASK;
272+
reg &= ~LCDIC_CTRL_LCDIC_MD_MASK;
273+
} else if (dbi_config->mode == MIPI_DBI_MODE_SPI_3WIRE) {
274+
/* Select SPI 3 wire mode */
275+
reg &= ~(LCDIC_CTRL_LCDIC_MD_MASK |
276+
LCDIC_CTRL_SPI_MD_MASK);
273277
} else {
274-
reg &= ~LCDIC_CTRL_SPI_MD_MASK;
278+
/* Unsupported mode */
279+
return -ENOTSUP;
280+
}
281+
/* If using SPI mode, validate that half-duplex was requested */
282+
if ((!(reg & LCDIC_CTRL_LCDIC_MD_MASK)) &&
283+
(!(spi_cfg->operation & SPI_HALF_DUPLEX))) {
284+
LOG_ERR("LCDIC only supports half duplex operation");
285+
return -ENOTSUP;
275286
}
276287
/* Enable byte swapping if user requested it */
277288
reg = (reg & ~LCDIC_CTRL_DAT_ENDIAN_MASK) |
@@ -292,6 +303,15 @@ static int mipi_dbi_lcdic_configure(const struct device *dev,
292303
LCDIC_SPI_CTRL_CPOL((spi_cfg->operation & SPI_MODE_CPOL) ? 1 : 0);
293304
base->SPI_CTRL = reg;
294305

306+
/*
307+
* Set 8080 control based on module properties. TRIW and TRAW are
308+
* set to their reset values
309+
*/
310+
base->I8080_CTRL1 = LCDIC_I8080_CTRL1_TRIW(0xf) |
311+
LCDIC_I8080_CTRL1_TRAW(0xf) |
312+
LCDIC_I8080_CTRL1_TWIW(config->write_inactive_min) |
313+
LCDIC_I8080_CTRL1_TWAW(config->write_active_min);
314+
295315
/* Enable the module */
296316
base->CTRL |= LCDIC_CTRL_LCDIC_EN_MASK;
297317
mipi_dbi_lcdic_reset_delay();
@@ -783,6 +803,10 @@ static void mipi_dbi_lcdic_isr(const struct device *dev)
783803
DT_INST_CLOCKS_CELL(n, name), \
784804
.irq_config_func = mipi_dbi_lcdic_config_func_##n, \
785805
.swap_bytes = DT_INST_PROP(n, nxp_swap_bytes), \
806+
.write_active_min = \
807+
DT_INST_PROP(n, nxp_write_active_cycles), \
808+
.write_inactive_min = \
809+
DT_INST_PROP(n, nxp_write_inactive_cycles), \
786810
}; \
787811
static struct mipi_dbi_lcdic_data mipi_dbi_lcdic_data_##n = { \
788812
LCDIC_DMA_CHANNELS(n) \

dts/bindings/mipi-dbi/nxp,lcdic.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
description: |
55
NXP LCDIC Controller. This controller implements 8080 and SPI mode MIPI-DBI
6-
compliant transfers. Only SPI mode is currently supported.
6+
compliant transfers.
77
compatible: "nxp,lcdic"
88

99
include: ["mipi-dbi-controller.yaml", "pinctrl-device.yaml"]
@@ -23,3 +23,26 @@ properties:
2323
description: |
2424
Swap bytes while transferring on LCDIC. When set, the LCDIC will send
2525
the most significant byte first when using multibyte pixel formats.
26+
27+
reset-gpios:
28+
type: phandle-array
29+
description: |
30+
Reset GPIO pin. The controller will set this pin to logic high to reset
31+
the display. If not provided, the LCDIC module's reset pin will be used
32+
to reset attached displays.
33+
34+
nxp,write-inactive-cycles:
35+
type: int
36+
default: 6
37+
description: |
38+
Set minimum count of write inactive cycles, as a multiple of the module
39+
clock frequency. This controls the length of the inactive period of the
40+
WRX signal. Default is IP reset value. Only valid in 8080 mode.
41+
42+
nxp,write-active-cycles:
43+
type: int
44+
default: 6
45+
description: |
46+
Set minimum count of write active cycles, as a multiple of the module
47+
clock frequency. This controls the length of the active period of the
48+
WRX signal. Default is IP reset value. Only valid in 8080 mode.

0 commit comments

Comments
 (0)