Skip to content

Commit 2724a1e

Browse files
sebhubdanieldegrasse
authored andcommitted
drivers: spi: mchp_mss_qspi: 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 269773f commit 2724a1e

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

drivers/spi/spi_mchp_mss_qspi.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
#include <zephyr/irq.h>
1616

1717
LOG_MODULE_REGISTER(mss_qspi, CONFIG_SPI_LOG_LEVEL);
18+
19+
/* Is MSS QSPI module 'resets' line property defined */
20+
#define MSS_QSPI_RESET_ENABLED DT_ANY_INST_HAS_PROP_STATUS_OKAY(resets)
21+
22+
#if MSS_QSPI_RESET_ENABLED
23+
#include <zephyr/drivers/reset.h>
24+
#endif
25+
1826
#include "spi_context.h"
1927

2028
/*MSS QSPI Register offsets */
@@ -101,6 +109,9 @@ struct mss_qspi_config {
101109
void (*irq_config_func)(const struct device *dev);
102110
int irq;
103111
uint32_t clock_freq;
112+
#if MSS_QSPI_RESET_ENABLED
113+
struct reset_dt_spec reset_spec;
114+
#endif
104115
};
105116

106117
/* Device run time data */
@@ -555,6 +566,12 @@ static int mss_qspi_init(const struct device *dev)
555566
unsigned int ret = 0;
556567
uint32_t control = 0;
557568

569+
#if MSS_QSPI_RESET_ENABLED
570+
if (cfg->reset_spec.dev != NULL) {
571+
(void)reset_line_deassert_dt(&cfg->reset_spec);
572+
}
573+
#endif
574+
558575
cfg->irq_config_func(dev);
559576

560577
control &= ~(MSS_QSPI_CONTROL_SAMPLE_MSK);
@@ -587,6 +604,8 @@ static DEVICE_API(spi, mss_qspi_driver_api) = {
587604
.base = DT_INST_REG_ADDR(n), \
588605
.irq_config_func = mss_qspi_config_func_##n, \
589606
.clock_freq = DT_INST_PROP(n, clock_frequency), \
607+
IF_ENABLED(DT_INST_NODE_HAS_PROP(n, resets), \
608+
(.reset_spec = RESET_DT_SPEC_INST_GET(n),)) \
590609
}; \
591610
\
592611
static struct mss_qspi_data mss_qspi_data_##n = { \

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

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

66
compatible: "microchip,mpfs-qspi"
77

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

1010
properties:
1111
reg:

0 commit comments

Comments
 (0)