From 7cd7c82aa1cccb1e13c68ac45f76e886814a943e Mon Sep 17 00:00:00 2001 From: Stephan Linz Date: Sun, 5 Jan 2025 08:38:31 +0100 Subject: [PATCH] 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 --- drivers/mipi_dbi/mipi_dbi_spi.c | 8 ++++---- dts/bindings/mipi-dbi/zephyr,mipi-dbi-spi.yaml | 14 +++++--------- tests/drivers/build_all/display/app.overlay | 2 +- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/mipi_dbi/mipi_dbi_spi.c b/drivers/mipi_dbi/mipi_dbi_spi.c index b6a6857c381b..e57d3b3965fc 100644 --- a/drivers/mipi_dbi/mipi_dbi_spi.c +++ b/drivers/mipi_dbi/mipi_dbi_spi.c @@ -1,6 +1,6 @@ /* * Copyright 2023 NXP - * Copyright 2024 TiaC Systems + * Copyright 2024-2025 TiaC Systems * * SPDX-License-Identifier: Apache-2.0 */ @@ -43,8 +43,8 @@ struct mipi_dbi_spi_data { uint32_t var = MIPI_DBI_SPI_READ_REQUIRED; /* Expands to 1 if the node does reflect the enum in `xfr-min-bits` property */ -#define _XFR_8BITS(n) (DT_INST_PROP(n, xfr_min_bits) == MIPI_DBI_SPI_XFR_8BIT) | -#define _XFR_16BITS(n) (DT_INST_PROP(n, xfr_min_bits) == MIPI_DBI_SPI_XFR_16BIT) | +#define _XFR_8BITS(n) (DT_INST_STRING_UPPER_TOKEN(n, xfr_min_bits) == MIPI_DBI_SPI_XFR_8BIT) | +#define _XFR_16BITS(n) (DT_INST_STRING_UPPER_TOKEN(n, xfr_min_bits) == MIPI_DBI_SPI_XFR_16BIT) | /* This macros will evaluate to 1 if any of the nodes with zephyr,mipi-dbi-spi * 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) = { DT_INST_PHANDLE(n, spi_dev)), \ .cmd_data = GPIO_DT_SPEC_INST_GET_OR(n, dc_gpios, {}), \ .reset = GPIO_DT_SPEC_INST_GET_OR(n, reset_gpios, {}), \ - .xfr_min_bits = DT_INST_PROP(n, xfr_min_bits) \ + .xfr_min_bits = DT_INST_STRING_UPPER_TOKEN(n, xfr_min_bits) \ }; \ static struct mipi_dbi_spi_data mipi_dbi_spi_data_##n; \ \ diff --git a/dts/bindings/mipi-dbi/zephyr,mipi-dbi-spi.yaml b/dts/bindings/mipi-dbi/zephyr,mipi-dbi-spi.yaml index 31b9abccc5f5..e3e292fefa5b 100644 --- a/dts/bindings/mipi-dbi/zephyr,mipi-dbi-spi.yaml +++ b/dts/bindings/mipi-dbi/zephyr,mipi-dbi-spi.yaml @@ -28,20 +28,16 @@ properties: Reset GPIO pin. Set high to reset the display xfr-min-bits: - type: int - default: 8 + type: string + default: "MIPI_DBI_SPI_XFR_8BIT" description: On rare types of SPI interfaces, discrete shift registers can be found whose task is to convert the serial SPI bit stream to the parallel MCU interface with clock and bit accuracy. Typically, these are 16 bits wide. - - Use the macros, not the actual enum value. Here is the concordance list - (see dt-bindings/mipi_dbi/mipi_dbi.h) - 8 MIPI_DBI_SPI_XFR_8BIT - 16 MIPI_DBI_SPI_XFR_16BIT + These definitions should match those in dt-bindings/mipi_dbi/mipi_dbi.h enum: - - 8 - - 16 + - "MIPI_DBI_SPI_XFR_8BIT" + - "MIPI_DBI_SPI_XFR_16BIT" write-only: type: boolean diff --git a/tests/drivers/build_all/display/app.overlay b/tests/drivers/build_all/display/app.overlay index e18a2103236b..61122101ce1c 100644 --- a/tests/drivers/build_all/display/app.overlay +++ b/tests/drivers/build_all/display/app.overlay @@ -168,7 +168,7 @@ spi-dev = <&test_spi>; #address-cells = <1>; #size-cells = <0>; - xfr-min-bits = ; + xfr-min-bits = "MIPI_DBI_SPI_XFR_16BIT"; write-only; test_mipi_dbi_xfr_16bit_ili9342c: ili9342c@0 {