Skip to content

Commit 269773f

Browse files
sebhubdanieldegrasse
authored andcommitted
drivers: spi: mchp_mss: Add reset support
Add support to reset the device through a reset controller. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
1 parent 9832973 commit 269773f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

drivers/spi/spi_mchp_mss.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616

1717
LOG_MODULE_REGISTER(mss_spi, CONFIG_SPI_LOG_LEVEL);
1818

19+
/* Is MSS SPI module 'resets' line property defined */
20+
#define MSS_SPI_RESET_ENABLED DT_ANY_INST_HAS_PROP_STATUS_OKAY(resets)
21+
22+
#if MSS_SPI_RESET_ENABLED
23+
#include <zephyr/drivers/reset.h>
24+
#endif
25+
1926
#include "spi_context.h"
2027

2128
/* MSS SPI Register offsets */
@@ -102,6 +109,9 @@ struct mss_spi_config {
102109
mm_reg_t base;
103110
uint8_t clk_gen;
104111
int clock_freq;
112+
#if MSS_SPI_RESET_ENABLED
113+
struct reset_dt_spec reset_spec;
114+
#endif
105115
};
106116

107117
struct mss_spi_transfer {
@@ -426,6 +436,12 @@ static int mss_spi_init(const struct device *dev)
426436
int ret = 0;
427437
uint32_t control = 0;
428438

439+
#if MSS_SPI_RESET_ENABLED
440+
if (cfg->reset_spec.dev != NULL) {
441+
(void)reset_line_deassert_dt(&cfg->reset_spec);
442+
}
443+
#endif
444+
429445
/* Remove SPI from Reset */
430446
control = mss_spi_read(cfg, MSS_SPI_REG_CONTROL);
431447
control &= ~MSS_SPI_CONTROL_RESET;
@@ -470,6 +486,8 @@ static DEVICE_API(spi, mss_spi_driver_api) = {
470486
static const struct mss_spi_config mss_spi_config_##n = { \
471487
.base = DT_INST_REG_ADDR(n), \
472488
.clock_freq = DT_INST_PROP(n, clock_frequency), \
489+
IF_ENABLED(DT_INST_NODE_HAS_PROP(n, resets), \
490+
(.reset_spec = RESET_DT_SPEC_INST_GET(n),)) \
473491
}; \
474492
\
475493
static struct mss_spi_data mss_spi_data_##n = { \

dts/bindings/spi/microchip,mpfs-spi.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Microchip Polarfire SOC SPI controller
55

66
compatible: "microchip,mpfs-spi"
77

8-
include: spi-controller.yaml
8+
include: [spi-controller.yaml, reset-device.yaml]
99

1010
properties:
1111
reg:

0 commit comments

Comments
 (0)