Skip to content

Commit 6495dc7

Browse files
drivers: spi: update sam spi driver
Update sam spi driver for sama7g54 Signed-off-by: CHEN Xing <[email protected]>
1 parent 091343a commit 6495dc7

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

drivers/spi/spi_sam.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,20 @@ static int spi_sam_configure(const struct device *dev,
101101
uint16_t spi_csr_idx = spi_cs_is_gpio(config) ? 0 : config->slave;
102102
int div;
103103

104+
#ifdef SOC_ATMEL_SAM_MCK_FREQ_HZ
105+
uint32_t rate = SOC_ATMEL_SAM_MCK_FREQ_HZ;
106+
#else
107+
uint32_t rate;
108+
int ret;
109+
110+
ret = clock_control_get_rate(SAM_DT_PMC_CONTROLLER,
111+
(clock_control_subsys_t)&cfg->clock_cfg,
112+
&rate);
113+
if (ret) {
114+
return ret;
115+
}
116+
#endif
117+
104118
if (spi_context_configured(&data->ctx, config)) {
105119
return 0;
106120
}
@@ -146,7 +160,7 @@ static int spi_sam_configure(const struct device *dev,
146160
}
147161

148162
/* Use the requested or next highest possible frequency */
149-
div = SOC_ATMEL_SAM_MCK_FREQ_HZ / config->frequency;
163+
div = rate / config->frequency;
150164
div = CLAMP(div, 1, UINT8_MAX);
151165
spi_csr |= SPI_CSR_SCBR(div);
152166

0 commit comments

Comments
 (0)