Skip to content

Commit 512ce50

Browse files
committed
drivers: mipi-dbi-spi: Fix initialization of GPIO CS
Access the correct node to get the SPI device GPIO CS. It comes from the parent spi-dev node, not the bus Signed-off-by: Jeremy Dick <[email protected]>
1 parent 3462a48 commit 512ce50

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

include/zephyr/drivers/mipi_dbi.h

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@
4141
extern "C" {
4242
#endif
4343

44+
/** @cond INTERNAL_HIDDEN */
45+
#define MIPI_DBI_SPI_DT(node_id) \
46+
DT_PHANDLE(DT_PARENT(node_id), spi_dev)
47+
48+
#define MIPI_DBI_SPI_CS_GPIOS_DT_SPEC_GET(node_id) \
49+
GPIO_DT_SPEC_GET_BY_IDX_OR(MIPI_DBI_SPI_DT(node_id), \
50+
cs_gpios, DT_REG_ADDR_RAW(node_id), {})
51+
52+
#define MIPI_DBI_SPI_CS_CONTROL_INIT_GPIO(node_id, delay_) \
53+
.gpio = MIPI_DBI_SPI_CS_GPIOS_DT_SPEC_GET(node_id), \
54+
.delay = delay_,
55+
/** @endcond */
56+
4457
/**
4558
* @brief initialize a MIPI DBI SPI configuration struct from devicetree
4659
*
@@ -61,12 +74,12 @@ extern "C" {
6174
COND_CODE_1(DT_PROP(node_id, mipi_cpha), SPI_MODE_CPHA, (0)) | \
6275
COND_CODE_1(DT_PROP(node_id, mipi_hold_cs), SPI_HOLD_ON_CS, (0)), \
6376
.slave = DT_REG_ADDR(node_id), \
64-
.cs = { \
65-
COND_CODE_1(DT_SPI_DEV_HAS_CS_GPIOS(node_id), \
66-
(SPI_CS_CONTROL_INIT_GPIO(node_id, delay_)), \
67-
(SPI_CS_CONTROL_INIT_NATIVE(node_id))) \
68-
.cs_is_gpio = DT_SPI_DEV_HAS_CS_GPIOS(node_id), \
69-
}, \
77+
.cs = { \
78+
COND_CODE_1(DT_SPI_HAS_CS_GPIOS(MIPI_DBI_SPI_DT(node_id)), \
79+
(MIPI_DBI_SPI_CS_CONTROL_INIT_GPIO(node_id, delay_)), \
80+
(SPI_CS_CONTROL_INIT_NATIVE(node_id))) \
81+
.cs_is_gpio = DT_SPI_HAS_CS_GPIOS(MIPI_DBI_SPI_DT(node_id)), \
82+
}, \
7083
}
7184

7285
/**

0 commit comments

Comments
 (0)