Skip to content

Commit 6429816

Browse files
committed
spi_nxp_lpspi: Clock device in zephyr driver
Clock the device from the zephyr driver. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
1 parent 7bbbb56 commit 6429816

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi_common.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@ LOG_MODULE_REGISTER(spi_mcux_lpspi_common, CONFIG_SPI_LOG_LEVEL);
99

1010
#include "spi_nxp_lpspi_priv.h"
1111

12+
static LPSPI_Type *const lpspi_bases[] = LPSPI_BASE_PTRS;
13+
static const clock_ip_name_t lpspi_clocks[] = LPSPI_CLOCKS;
14+
15+
static inline clock_ip_name_t lpspi_get_clock(LPSPI_Type *const base)
16+
{
17+
clock_ip_name_t clk = -1; /* invalid initial value */
18+
19+
ARRAY_FOR_EACH(lpspi_bases, idx) {
20+
if (lpspi_bases[idx] == base) {
21+
clk = lpspi_clocks[idx];
22+
break;
23+
}
24+
}
25+
26+
__ASSERT_NO_MSG(clk != -1);
27+
return clk;
28+
}
29+
1230
void lpspi_wait_tx_fifo_empty(const struct device *dev)
1331
{
1432
LPSPI_Type *base = (LPSPI_Type *)DEVICE_MMIO_NAMED_GET(dev, reg_base);
@@ -130,6 +148,7 @@ int spi_mcux_configure(const struct device *dev, const struct spi_config *spi_cf
130148

131149
int spi_nxp_init_common(const struct device *dev)
132150
{
151+
LPSPI_Type *base = (LPSPI_Type *)DEVICE_MMIO_NAMED_GET(dev, reg_base);
133152
const struct spi_mcux_config *config = dev->config;
134153
struct spi_mcux_data *data = dev->data;
135154
int err = 0;
@@ -143,6 +162,8 @@ int spi_nxp_init_common(const struct device *dev)
143162
return -ENODEV;
144163
}
145164

165+
CLOCK_EnableClock(lpspi_get_clock(base));
166+
146167
err = spi_context_cs_configure_all(&data->ctx);
147168
if (err < 0) {
148169
return err;

0 commit comments

Comments
 (0)