rust/sysctl: clock_get_freq add I2Cx clocks

This commit is contained in:
Wladimir J. van der Laan 2019-05-13 11:40:59 +00:00
parent 8dff340565
commit 3ba2204102

View File

@ -460,6 +460,9 @@ pub fn clock_get_clock_select(which: clock_select) -> u8 {
}
pub fn clock_get_freq(clock: clock) -> u32 {
// TODO: all of these are source / threshold, where source can depend on clock_select: generalize this
// to some kind of clock tree
// TODO: clock_source_get_freq(ACLK) calls back into here, don't do this
match clock {
clock::PLL0 => clock_source_get_freq(clock_source::PLL0),
clock::PLL1 => clock_source_get_freq(clock_source::PLL1),
@ -476,6 +479,18 @@ pub fn clock_get_freq(clock: clock) -> u32 {
let source = clock_source_get_freq(clock_source::PLL0);
source / ((clock_get_threshold(threshold::SPI0) + 1) * 2)
}
clock::I2C0 => {
let source = clock_source_get_freq(clock_source::PLL0);
source / ((clock_get_threshold(threshold::I2C0) + 1) * 2)
}
clock::I2C1 => {
let source = clock_source_get_freq(clock_source::PLL0);
source / ((clock_get_threshold(threshold::I2C1) + 1) * 2)
}
clock::I2C2 => {
let source = clock_source_get_freq(clock_source::PLL0);
source / ((clock_get_threshold(threshold::I2C2) + 1) * 2)
}
_ => panic!("not implemented"),
}
}