File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments