Skip to content

Commit 7cd7c82

Browse files
rexutkartben
authored andcommitted
drivers: mipi-dbi-spi: use string for xfr-min-bits property
Use a string for the xfr-min-bits property over an integer value, as this significantly improves the readability of the MIPI DBI SPI device binding. Signed-off-by: Stephan Linz <[email protected]>
1 parent ee5c520 commit 7cd7c82

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

drivers/mipi_dbi/mipi_dbi_spi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright 2023 NXP
3-
* Copyright 2024 TiaC Systems
3+
* Copyright 2024-2025 TiaC Systems
44
*
55
* SPDX-License-Identifier: Apache-2.0
66
*/
@@ -43,8 +43,8 @@ struct mipi_dbi_spi_data {
4343
uint32_t var = MIPI_DBI_SPI_READ_REQUIRED;
4444

4545
/* Expands to 1 if the node does reflect the enum in `xfr-min-bits` property */
46-
#define _XFR_8BITS(n) (DT_INST_PROP(n, xfr_min_bits) == MIPI_DBI_SPI_XFR_8BIT) |
47-
#define _XFR_16BITS(n) (DT_INST_PROP(n, xfr_min_bits) == MIPI_DBI_SPI_XFR_16BIT) |
46+
#define _XFR_8BITS(n) (DT_INST_STRING_UPPER_TOKEN(n, xfr_min_bits) == MIPI_DBI_SPI_XFR_8BIT) |
47+
#define _XFR_16BITS(n) (DT_INST_STRING_UPPER_TOKEN(n, xfr_min_bits) == MIPI_DBI_SPI_XFR_16BIT) |
4848

4949
/* This macros will evaluate to 1 if any of the nodes with zephyr,mipi-dbi-spi
5050
* have the `xfr-min-bits` property to corresponding enum value. The intention
@@ -560,7 +560,7 @@ static DEVICE_API(mipi_dbi, mipi_dbi_spi_driver_api) = {
560560
DT_INST_PHANDLE(n, spi_dev)), \
561561
.cmd_data = GPIO_DT_SPEC_INST_GET_OR(n, dc_gpios, {}), \
562562
.reset = GPIO_DT_SPEC_INST_GET_OR(n, reset_gpios, {}), \
563-
.xfr_min_bits = DT_INST_PROP(n, xfr_min_bits) \
563+
.xfr_min_bits = DT_INST_STRING_UPPER_TOKEN(n, xfr_min_bits) \
564564
}; \
565565
static struct mipi_dbi_spi_data mipi_dbi_spi_data_##n; \
566566
\

dts/bindings/mipi-dbi/zephyr,mipi-dbi-spi.yaml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,16 @@ properties:
2828
Reset GPIO pin. Set high to reset the display
2929
3030
xfr-min-bits:
31-
type: int
32-
default: 8
31+
type: string
32+
default: "MIPI_DBI_SPI_XFR_8BIT"
3333
description:
3434
On rare types of SPI interfaces, discrete shift registers can be found
3535
whose task is to convert the serial SPI bit stream to the parallel MCU
3636
interface with clock and bit accuracy. Typically, these are 16 bits wide.
37-
38-
Use the macros, not the actual enum value. Here is the concordance list
39-
(see dt-bindings/mipi_dbi/mipi_dbi.h)
40-
8 MIPI_DBI_SPI_XFR_8BIT
41-
16 MIPI_DBI_SPI_XFR_16BIT
37+
These definitions should match those in dt-bindings/mipi_dbi/mipi_dbi.h
4238
enum:
43-
- 8
44-
- 16
39+
- "MIPI_DBI_SPI_XFR_8BIT"
40+
- "MIPI_DBI_SPI_XFR_16BIT"
4541

4642
write-only:
4743
type: boolean

tests/drivers/build_all/display/app.overlay

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
spi-dev = <&test_spi>;
169169
#address-cells = <1>;
170170
#size-cells = <0>;
171-
xfr-min-bits = <MIPI_DBI_SPI_XFR_16BIT>;
171+
xfr-min-bits = "MIPI_DBI_SPI_XFR_16BIT";
172172
write-only;
173173

174174
test_mipi_dbi_xfr_16bit_ili9342c: ili9342c@0 {

0 commit comments

Comments
 (0)