@@ -34,6 +34,7 @@ struct lpspi_config {
34
34
const struct device * clock_dev ;
35
35
clock_control_subsys_t clock_subsys ;
36
36
void (* irq_config_func )(const struct device * dev );
37
+ void (* irq_deinit_func )(const struct device * dev );
37
38
uint32_t pcs_sck_delay ;
38
39
uint32_t sck_pcs_delay ;
39
40
uint32_t transfer_delay ;
@@ -65,6 +66,13 @@ int spi_mcux_configure(const struct device *dev, const struct spi_config *spi_cf
65
66
*/
66
67
int spi_nxp_init_common (const struct device * dev );
67
68
69
+ /* Does these things:
70
+ * Reset module
71
+ * Disable clock if present
72
+ * Clear or simply disable IRQ
73
+ */
74
+ int spi_nxp_deinit_common (const struct device * dev );
75
+
68
76
/* common api function for now */
69
77
int spi_lpspi_release (const struct device * dev , const struct spi_config * spi_cfg );
70
78
@@ -87,12 +95,27 @@ void lpspi_wait_tx_fifo_empty(const struct device *dev);
87
95
#define LPSPI_IRQN (n ) COND_CODE_1(DT_NODE_HAS_COMPAT(DT_INST_PARENT(n), nxp_lp_flexcomm), \
88
96
(DT_IRQN(DT_INST_PARENT(n))), (DT_INST_IRQN(n)))
89
97
98
+ #define SPI_LPSPI_IRQ_DEINIT_FUNC_LP_FLEXCOMM (n ) \
99
+ nxp_lp_flexcomm_clearirqhandler(DEVICE_DT_GET(DT_INST_PARENT(n)), \
100
+ LP_FLEXCOMM_PERIPH_LPSPI);
101
+
102
+ #define SPI_LPSPI_IRQ_DEINIT_FUNC_DISTINCT (n ) \
103
+ irq_disable(DT_INST_IRQN(n));
104
+
105
+ #define SPI_LPSPI_IRQ_DEINIT_FUNC (n ) \
106
+ COND_CODE_1( \
107
+ DT_NODE_HAS_COMPAT(DT_INST_PARENT(n), nxp_lp_flexcomm), \
108
+ (SPI_LPSPI_IRQ_DEINIT_FUNC_LP_FLEXCOMM(n)), \
109
+ (SPI_LPSPI_IRQ_DEINIT_FUNC_DISTINCT(n)) \
110
+ )
111
+
90
112
#define SPI_LPSPI_CONFIG_INIT (n ) \
91
113
static const struct lpspi_config lpspi_config_##n = { \
92
114
DEVICE_MMIO_NAMED_ROM_INIT(reg_base, DT_DRV_INST(n)), \
93
115
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
94
116
.clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name), \
95
117
.irq_config_func = lpspi_config_func_##n, \
118
+ .irq_deinit_func = lpspi_deinit_func_##n, \
96
119
.pcs_sck_delay = UTIL_AND(DT_INST_NODE_HAS_PROP(n, pcs_sck_delay), \
97
120
DT_INST_PROP(n, pcs_sck_delay)), \
98
121
.sck_pcs_delay = UTIL_AND(DT_INST_NODE_HAS_PROP(n, sck_pcs_delay), \
@@ -112,7 +135,12 @@ void lpspi_wait_tx_fifo_empty(const struct device *dev);
112
135
\
113
136
static void lpspi_config_func_##n(const struct device *dev) \
114
137
{ \
115
- SPI_LPSPI_IRQ_FUNC(n) \
138
+ SPI_LPSPI_IRQ_FUNC(n) \
139
+ } \
140
+ \
141
+ static void lpspi_deinit_func_##n(const struct device *dev) \
142
+ { \
143
+ SPI_LPSPI_IRQ_DEINIT_FUNC(n) \
116
144
}
117
145
118
146
#define SPI_NXP_LPSPI_COMMON_DATA_INIT (n ) \
0 commit comments