Browse Source

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 <linz@li-pro.net>
pull/83829/head
Stephan Linz 6 months ago committed by Benjamin Cabé
parent
commit
7cd7c82aa1
  1. 8
      drivers/mipi_dbi/mipi_dbi_spi.c
  2. 14
      dts/bindings/mipi-dbi/zephyr,mipi-dbi-spi.yaml
  3. 2
      tests/drivers/build_all/display/app.overlay

8
drivers/mipi_dbi/mipi_dbi_spi.c

@ -1,6 +1,6 @@ @@ -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 { @@ -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) = { @@ -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; \
\

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

@ -28,20 +28,16 @@ properties: @@ -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

2
tests/drivers/build_all/display/app.overlay

@ -168,7 +168,7 @@ @@ -168,7 +168,7 @@
spi-dev = <&test_spi>;
#address-cells = <1>;
#size-cells = <0>;
xfr-min-bits = <MIPI_DBI_SPI_XFR_16BIT>;
xfr-min-bits = "MIPI_DBI_SPI_XFR_16BIT";
write-only;
test_mipi_dbi_xfr_16bit_ili9342c: ili9342c@0 {

Loading…
Cancel
Save