Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(d1): add smhc driver #299

Merged
merged 39 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ece1b7a
Create SMHC driver skeleton
jspngh Jul 30, 2023
d7f9249
Create sdmmc kernel service, copied from i2c service
jspngh Jul 30, 2023
f2488b9
Copy some kernel communication stuff from TWI to SMHC driver
jspngh Jul 30, 2023
ef24fa1
Add SDMMC uuid
jspngh Jul 30, 2023
b7c1a2f
Replace Transfer/Transaction with Command/Response in sdmmc service
jspngh Aug 5, 2023
95e5daa
sdmmc: rework `Command` and start implementation of `SdCardClient`
jspngh Sep 3, 2023
9d1f933
smhc driver: initial implementation of `run` and `command` functions
jspngh Sep 3, 2023
cdd8ce7
Add smhc in `src/lib.rs`
jspngh Sep 3, 2023
63e88b0
Rebase on main
jspngh Sep 20, 2023
36663e7
sdmmc: add *data* field to `Response::Short`
jspngh Sep 20, 2023
183dd96
smhc driver: implement `advance_isr`
jspngh Sep 20, 2023
391d9c9
ccu.rs: fix swapped docs in `BusGatingResetRegister`
jspngh Sep 20, 2023
6a39d6e
sdmmc: implement `initialize` function
jspngh Sep 24, 2023
c32ffc0
Add small function to test SdCardClient
jspngh Sep 24, 2023
92438ce
sdmmc: implement more functions
jspngh Sep 25, 2023
befaf60
sdmmc: implement reading from SD card for allwinner-d1
jspngh Oct 26, 2023
abaf683
Apply some PR feedback
jspngh Nov 2, 2023
3722c51
smhc: reduce module clock rate to 100 MHz
jspngh Nov 2, 2023
5a5c468
ccu: set gating and reset in single line
jspngh Nov 19, 2023
597a9b7
smhc: extract `reset_fifo` function
jspngh Nov 19, 2023
4a45088
smhc: refactor `idmac` descriptors to be inline with `dmac` implement…
jspngh Nov 19, 2023
24cb3cb
smhc: apply more PR feedback
jspngh Nov 19, 2023
d53a807
dmac: some spelling fixes
jspngh Nov 19, 2023
4853c46
smhc: fix some check + clippy lints
jspngh Nov 19, 2023
4910303
smhc: fix lints + formatting
jspngh Nov 20, 2023
a0a3a9b
kernel/src/services/mod: fix rustfmt
jspngh Nov 20, 2023
8de1561
smhc+sdmmc: improve error handling + doc comments
jspngh Nov 20, 2023
1b01fa5
sdmmc: map [u32;4] to u128 for card identification register
jspngh Nov 20, 2023
18d2757
smhc: add `num` field to `Smhc` struct
jspngh Nov 21, 2023
c517354
smhc: use `bool` for single-bit fields in `Cfg` bitfield
jspngh Nov 21, 2023
d676e44
smhc: update some doc comments
jspngh Nov 21, 2023
a8478c7
allwinner-d1/src/lib: remove sdcard test code
jspngh Nov 26, 2023
0f14a11
sdmmc: update mapping of [u32;4] to u128
jspngh Nov 27, 2023
87c505f
Merge branch 'main' into jspngh/smhc-driver
hawkw Nov 28, 2023
86c6b8d
sdmmc: use `maitake::time` to sleep in `SdCardClient::initialize`
jspngh Dec 5, 2023
29c1dd1
sdmmc: `Response::Long` contains u128
jspngh Dec 5, 2023
15c49d5
sdmmc: move response tracing line to `SdCardClient::cmd`
jspngh Dec 5, 2023
091961b
sdmmc: refactor Error to struct with *kind* and *message*
jspngh Dec 8, 2023
3649fed
sdmmc: small style improvements
jspngh Dec 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions platforms/allwinner-d1/d1-core/src/ccu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ pub struct Ccu {

/// Trait to be implemented for module clocks that can be gated and reset
pub trait BusGatingResetRegister {
/// Enable or disable the clock reset bit
fn gating(ccu: &mut CCU, pass: bool);
/// Enable or disable the clock gating bit
fn reset(ccu: &mut CCU, deassert: bool);
fn gating(ccu: &mut CCU, pass: bool);
/// Enable or disable the clock reset bit
fn reset(ccu: &mut CCU, assert: bool);
hawkw marked this conversation as resolved.
Show resolved Hide resolved
}

// TODO: should this move into the `Clint`?
Expand All @@ -49,7 +49,7 @@ impl Ccu {

/// De-assert the reset bit and enable the clock gating bit for the given module
pub fn enable_module<MODULE: BusGatingResetRegister>(&mut self, _mod: &mut MODULE) {
MODULE::reset(&mut self.ccu, true);
MODULE::reset(&mut self.ccu, false);
sdelay(20);
MODULE::gating(&mut self.ccu, true);
}
Expand All @@ -58,7 +58,7 @@ impl Ccu {
pub fn disable_module<MODULE: BusGatingResetRegister>(&mut self, _mod: &mut MODULE) {
MODULE::gating(&mut self.ccu, false);
// TODO: delay?
MODULE::reset(&mut self.ccu, false);
MODULE::reset(&mut self.ccu, true);
}

/// Allow modules to configure their own clock on a PAC level
Expand Down Expand Up @@ -252,8 +252,8 @@ macro_rules! impl_bgr {
ccu.$reg.modify(|_, w| w.$gating().bit(pass));
}

fn reset(ccu: &mut CCU, deassert: bool) {
ccu.$reg.modify(|_, w| w.$reset().bit(deassert));
fn reset(ccu: &mut CCU, assert: bool) {
ccu.$reg.modify(|_, w| w.$reset().bit(!assert));
}
}
)+
Expand Down
1 change: 1 addition & 0 deletions platforms/allwinner-d1/d1-core/src/drivers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#[cfg(feature = "sharp-display")]
pub mod sharp_display;
pub mod smhc;
pub mod spim;
pub mod twi;
pub mod uart;
Loading