Closed janoslim closed 3 years ago
To manipulate the cryp clock, you should use the clock driver interface, from #include <stm32_util.h>
:
void stm32_clock_enable(unsigned long id);
void stm32_clock_disable(unsigned long id);
unsigned long stm32_clock_get_rate(unsigned long id);
bool stm32_clock_is_enabled(unsigned long id);
To get the clock, use DT support. Something like:
const void *fdt = get_embedded_dt();
int node = fdt_node_offset_by_compatible(fdt, -1, "st,stm32mp1-cryp");
struct dt_node_info dt_info = { };
unsigned long clock = 0;
if (node < 0) {
// node node or FDT not found
}
_fdt_fill_device_info(fdt, &dt_info, node);
if (dt_info.status == DT_STATUS_DISABLED) {
// ensure cryp has status = "okay"
}
if (dt_info.clock == DT_INFO_INVALID_CLOCK) {
// no clock defined...
} else {
// use can use dt_info.clock as clock reference
clock = (unsigned long)dt_info.clock;
// try it
EMSG("cryp clock: %lu Hz, %s", stm32_clock_get_rate(clock),
stm32_clock_is_enabled(clock) ? "enabled" : "disabled");
}
Note that a clock framework is likely to be merged in OP-TEE soon (https://github.com/OP-TEE/optee_os/pull/4705). Stm32mp1 clock driver will move to that framework when possible. Stay tuned.
Thank you!!
Hello @janoslim, @ToromanoSTM has created a P-R for stm32_cryp support and plug in drvcrypt framework: https://github.com/OP-TEE/optee_os/pull/4939. You may be interested in this.
Hello,
I am currently making driver on optee for CRYP of stm32mp157c-dk2 board which is crypto peripheral on cpu bus. And I refer to linux driver source code already implemented. And I notice that clock enabling is required and It seems that it is related to RCC.
line 2080 of link here.
and in stm32mp15xc.dtsi, it is defined as using clock and reset of RCC,
And what i tried to do is...
io_setbits32(rcc + RCC_MC_AHB5ENSETR, RCC_MC_AHB5ENSETR_CRYP1EN_POS);
And I wonder what I need to do for enable / disable this peripheral in the point of RCC. As I understand, just writing value to specific register(RCC_AHB5RSTCLRR) is needed according to this TRM page 778. However due to I do not have many background on stm system, I wonder It would works.
Thank you for your great help!