From 269773fff4f192e9d07a5b0eaf06721382cfd718 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 18 Jun 2025 04:04:50 +0200 Subject: [PATCH] drivers: spi: mchp_mss: Add reset support Add support to reset the device through a reset controller. Signed-off-by: Sebastian Huber --- drivers/spi/spi_mchp_mss.c | 18 ++++++++++++++++++ dts/bindings/spi/microchip,mpfs-spi.yaml | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi_mchp_mss.c b/drivers/spi/spi_mchp_mss.c index e1138cfb86f..fcf58687f62 100644 --- a/drivers/spi/spi_mchp_mss.c +++ b/drivers/spi/spi_mchp_mss.c @@ -16,6 +16,13 @@ LOG_MODULE_REGISTER(mss_spi, CONFIG_SPI_LOG_LEVEL); +/* Is MSS SPI module 'resets' line property defined */ +#define MSS_SPI_RESET_ENABLED DT_ANY_INST_HAS_PROP_STATUS_OKAY(resets) + +#if MSS_SPI_RESET_ENABLED +#include +#endif + #include "spi_context.h" /* MSS SPI Register offsets */ @@ -102,6 +109,9 @@ struct mss_spi_config { mm_reg_t base; uint8_t clk_gen; int clock_freq; +#if MSS_SPI_RESET_ENABLED + struct reset_dt_spec reset_spec; +#endif }; struct mss_spi_transfer { @@ -426,6 +436,12 @@ static int mss_spi_init(const struct device *dev) int ret = 0; uint32_t control = 0; +#if MSS_SPI_RESET_ENABLED + if (cfg->reset_spec.dev != NULL) { + (void)reset_line_deassert_dt(&cfg->reset_spec); + } +#endif + /* Remove SPI from Reset */ control = mss_spi_read(cfg, MSS_SPI_REG_CONTROL); control &= ~MSS_SPI_CONTROL_RESET; @@ -470,6 +486,8 @@ static DEVICE_API(spi, mss_spi_driver_api) = { static const struct mss_spi_config mss_spi_config_##n = { \ .base = DT_INST_REG_ADDR(n), \ .clock_freq = DT_INST_PROP(n, clock_frequency), \ + IF_ENABLED(DT_INST_NODE_HAS_PROP(n, resets), \ + (.reset_spec = RESET_DT_SPEC_INST_GET(n),)) \ }; \ \ static struct mss_spi_data mss_spi_data_##n = { \ diff --git a/dts/bindings/spi/microchip,mpfs-spi.yaml b/dts/bindings/spi/microchip,mpfs-spi.yaml index b76a643e471..1ac3bcc55fc 100644 --- a/dts/bindings/spi/microchip,mpfs-spi.yaml +++ b/dts/bindings/spi/microchip,mpfs-spi.yaml @@ -5,7 +5,7 @@ description: Microchip Polarfire SOC SPI controller compatible: "microchip,mpfs-spi" -include: spi-controller.yaml +include: [spi-controller.yaml, reset-device.yaml] properties: reg: