Skip to content

Commit

Permalink
ccu: add DRAM clock configurator
Browse files Browse the repository at this point in the history
TODO: a more proper abstraction considering the PLL source behind peripheral clock
Signed-off-by: Zhouqi Jiang <[email protected]>
  • Loading branch information
luojia65 committed Oct 9, 2024
1 parent 747e9b5 commit 2abc257
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/ccu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,49 @@ pub trait ClockConfig {
);
}

// TODO: a more proper abstraction considering the PLL source behind peripheral clock

/// Dynamic Random-Access Memory (DRAM) clock gate.
pub struct DRAM;

impl ClockGate for DRAM {
#[inline]

Check warning on line 813 in src/ccu.rs

View workflow job for this annotation

GitHub Actions / Rustfmt all packages

Diff in /home/runner/work/allwinner-hal/allwinner-hal/src/ccu.rs
unsafe fn reset(ccu: &ccu::RegisterBlock) {
let dram_bgr = ccu.dram_bgr.read();
ccu.dram_bgr
.write(dram_bgr.gate_mask().assert_reset());
let dram_bgr = ccu.dram_bgr.read();
ccu.dram_bgr
.write(dram_bgr.gate_pass().deassert_reset());
}
#[inline]
unsafe fn free(ccu: &ccu::RegisterBlock) {
let dram_bgr = ccu.dram_bgr.read();

Check warning on line 824 in src/ccu.rs

View workflow job for this annotation

GitHub Actions / Rustfmt all packages

Diff in /home/runner/work/allwinner-hal/allwinner-hal/src/ccu.rs
ccu.dram_bgr
.write(dram_bgr.gate_mask().assert_reset());
}
}

impl ClockConfig for DRAM {
type Source = DramClockSource;

#[inline]
unsafe fn config(
source: Self::Source,
factor_m: u8,
factor_n: FactorN,
ccu: &ccu::RegisterBlock,
) {
let dram_clk = ccu.dram_clock.read();
ccu.dram_clock.write(
dram_clk

Check warning on line 842 in src/ccu.rs

View workflow job for this annotation

GitHub Actions / Rustfmt all packages

Diff in /home/runner/work/allwinner-hal/allwinner-hal/src/ccu.rs
.set_clock_source(source)
.set_factor_m(factor_m)
.set_factor_n(factor_n)
)
}
}

/// Universal Asynchronous Receiver-Transmitter clock gate.
///
/// UART peripheral should be indexed by type parameter `IDX`.
Expand Down

0 comments on commit 2abc257

Please sign in to comment.