Skip to content

Commit 3559dd9

Browse files
M-Moawadcfriedt
authored andcommitted
drivers: spi: dw: Skip version detection on aux-reg platforms
The version register is not accessible through aux-reg interface, So skip it entirely on platforms with aux-reg device tree property. Signed-off-by: Mohamed Moawad <[email protected]>
1 parent 6930d71 commit 3559dd9

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

drivers/spi/spi_dw.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,11 +566,13 @@ int spi_dw_init(const struct device *dev)
566566
write_imr(dev, DW_SPI_IMR_MASK);
567567
clear_bit_ssienr(dev);
568568

569+
#if !DT_ANY_INST_PROP_STATUS_OKAY(aux_reg)
569570
/* SSI component version */
570571
spi->version = read_ssi_comp_version(dev);
571572
LOG_DBG("Version: %c.%c%c%c", (spi->version >> 24) & 0xff,
572573
(spi->version >> 16) & 0xff, (spi->version >> 8) & 0xff,
573574
spi->version & 0xff);
575+
#endif
574576

575577
LOG_DBG("Designware SPI driver initialized on device: %p", dev);
576578

drivers/spi/spi_dw.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@
2020
extern "C" {
2121
#endif
2222

23+
/* Helper macros for checking property status across instances */
24+
#define DT_INST_NODE_PROP_NOT_OR(inst, prop) !DT_INST_PROP(inst, prop) ||
25+
#define DT_ANY_INST_NOT_PROP_STATUS_OKAY(prop) \
26+
(DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_INST_NODE_PROP_NOT_OR, prop) 0)
27+
28+
#define DT_INST_NODE_PROP_AND_OR(inst, prop) DT_INST_PROP(inst, prop) ||
29+
#define DT_ANY_INST_PROP_STATUS_OKAY(prop) \
30+
(DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_INST_NODE_PROP_AND_OR, prop) 0)
31+
2332
typedef void (*spi_dw_config_t)(void);
2433
typedef uint32_t (*spi_dw_read_t)(uint8_t size, mm_reg_t addr, uint32_t off);
2534
typedef void (*spi_dw_write_t)(uint8_t size, uint32_t data, mm_reg_t addr, uint32_t off);
@@ -48,22 +57,14 @@ struct spi_dw_config {
4857
struct spi_dw_data {
4958
DEVICE_MMIO_RAM;
5059
struct spi_context ctx;
60+
#if !DT_ANY_INST_PROP_STATUS_OKAY(aux_reg)
5161
uint32_t version; /* ssi comp version */
62+
#endif
5263
uint8_t dfs; /* dfs in bytes: 1,2 or 4 */
5364
uint8_t fifo_diff; /* cannot be bigger than FIFO depth */
5465
};
5566

5667
/* Register operation functions */
57-
#define DT_INST_NODE_PROP_NOT_OR(inst, prop) \
58-
!DT_INST_PROP(inst, prop) ||
59-
#define DT_ANY_INST_NOT_PROP_STATUS_OKAY(prop) \
60-
(DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_INST_NODE_PROP_NOT_OR, prop) 0)
61-
62-
#define DT_INST_NODE_PROP_AND_OR(inst, prop) \
63-
DT_INST_PROP(inst, prop) ||
64-
#define DT_ANY_INST_PROP_STATUS_OKAY(prop) \
65-
(DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_INST_NODE_PROP_AND_OR, prop) 0)
66-
6768
#if DT_ANY_INST_PROP_STATUS_OKAY(aux_reg)
6869
static uint32_t aux_reg_read(uint8_t size, mm_reg_t addr, uint32_t off)
6970
{

0 commit comments

Comments
 (0)