-
Notifications
You must be signed in to change notification settings - Fork 19
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
Changes from 17 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
ece1b7a
Create SMHC driver skeleton
jspngh d7f9249
Create sdmmc kernel service, copied from i2c service
jspngh f2488b9
Copy some kernel communication stuff from TWI to SMHC driver
jspngh ef24fa1
Add SDMMC uuid
jspngh b7c1a2f
Replace Transfer/Transaction with Command/Response in sdmmc service
jspngh 95e5daa
sdmmc: rework `Command` and start implementation of `SdCardClient`
jspngh 9d1f933
smhc driver: initial implementation of `run` and `command` functions
jspngh cdd8ce7
Add smhc in `src/lib.rs`
jspngh 63e88b0
Rebase on main
jspngh 36663e7
sdmmc: add *data* field to `Response::Short`
jspngh 183dd96
smhc driver: implement `advance_isr`
jspngh 391d9c9
ccu.rs: fix swapped docs in `BusGatingResetRegister`
jspngh 6a39d6e
sdmmc: implement `initialize` function
jspngh c32ffc0
Add small function to test SdCardClient
jspngh 92438ce
sdmmc: implement more functions
jspngh befaf60
sdmmc: implement reading from SD card for allwinner-d1
jspngh abaf683
Apply some PR feedback
jspngh 3722c51
smhc: reduce module clock rate to 100 MHz
jspngh 5a5c468
ccu: set gating and reset in single line
jspngh 597a9b7
smhc: extract `reset_fifo` function
jspngh 4a45088
smhc: refactor `idmac` descriptors to be inline with `dmac` implement…
jspngh 24cb3cb
smhc: apply more PR feedback
jspngh d53a807
dmac: some spelling fixes
jspngh 4853c46
smhc: fix some check + clippy lints
jspngh 4910303
smhc: fix lints + formatting
jspngh a0a3a9b
kernel/src/services/mod: fix rustfmt
jspngh 8de1561
smhc+sdmmc: improve error handling + doc comments
jspngh 1b01fa5
sdmmc: map [u32;4] to u128 for card identification register
jspngh 18d2757
smhc: add `num` field to `Smhc` struct
jspngh c517354
smhc: use `bool` for single-bit fields in `Cfg` bitfield
jspngh d676e44
smhc: update some doc comments
jspngh a8478c7
allwinner-d1/src/lib: remove sdcard test code
jspngh 0f14a11
sdmmc: update mapping of [u32;4] to u128
jspngh 87c505f
Merge branch 'main' into jspngh/smhc-driver
hawkw 86c6b8d
sdmmc: use `maitake::time` to sleep in `SdCardClient::initialize`
jspngh 29c1dd1
sdmmc: `Response::Long` contains u128
jspngh 15c49d5
sdmmc: move response tracing line to `SdCardClient::cmd`
jspngh 091961b
sdmmc: refactor Error to struct with *kind* and *message*
jspngh 3649fed
sdmmc: small style improvements
jspngh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -18,12 +18,24 @@ pub struct Ccu { | |||||||||||||
ccu: CCU, | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
#[derive(PartialEq)] | ||||||||||||||
pub enum BusGating { | ||||||||||||||
Mask, | ||||||||||||||
Pass, | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
#[derive(PartialEq)] | ||||||||||||||
pub enum BusReset { | ||||||||||||||
Assert, | ||||||||||||||
Deassert, | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
/// 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, gating: BusGating); | ||||||||||||||
/// Enable or disable the clock reset bit | ||||||||||||||
fn reset(ccu: &mut CCU, reset: BusReset); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
// TODO: should this move into the `Clint`? | ||||||||||||||
|
@@ -49,16 +61,16 @@ 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, BusReset::Deassert); | ||||||||||||||
sdelay(20); | ||||||||||||||
MODULE::gating(&mut self.ccu, true); | ||||||||||||||
MODULE::gating(&mut self.ccu, BusGating::Pass); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
/// Disable the clock gating bit and assert the reset bit for the given module | ||||||||||||||
pub fn disable_module<MODULE: BusGatingResetRegister>(&mut self, _mod: &mut MODULE) { | ||||||||||||||
MODULE::gating(&mut self.ccu, false); | ||||||||||||||
MODULE::gating(&mut self.ccu, BusGating::Mask); | ||||||||||||||
// TODO: delay? | ||||||||||||||
MODULE::reset(&mut self.ccu, false); | ||||||||||||||
MODULE::reset(&mut self.ccu, BusReset::Assert); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
/// Allow modules to configure their own clock on a PAC level | ||||||||||||||
|
@@ -248,12 +260,24 @@ macro_rules! impl_bgr { | |||||||||||||
($($MODULE:ident : ($reg:ident, $gating:ident, $reset:ident),)+) => { | ||||||||||||||
$( | ||||||||||||||
impl BusGatingResetRegister for $MODULE { | ||||||||||||||
fn gating(ccu: &mut CCU, pass: bool) { | ||||||||||||||
ccu.$reg.modify(|_, w| w.$gating().bit(pass)); | ||||||||||||||
fn gating(ccu: &mut CCU, gating: BusGating) { | ||||||||||||||
ccu.$reg.modify(|_, w| { | ||||||||||||||
if gating == BusGating::Mask { | ||||||||||||||
w.$gating().clear_bit() | ||||||||||||||
} else { | ||||||||||||||
w.$gating().set_bit() | ||||||||||||||
} | ||||||||||||||
}); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
fn reset(ccu: &mut CCU, deassert: bool) { | ||||||||||||||
ccu.$reg.modify(|_, w| w.$reset().bit(deassert)); | ||||||||||||||
fn reset(ccu: &mut CCU, reset: BusReset) { | ||||||||||||||
ccu.$reg.modify(|_, w| { | ||||||||||||||
if reset == BusReset::Assert { | ||||||||||||||
w.$reset().clear_bit() | ||||||||||||||
} else { | ||||||||||||||
w.$reset().set_bit() | ||||||||||||||
} | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit, take it or leave it: this could still be a one-liner if we wrote
Suggested change
|
||||||||||||||
}); | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
)+ | ||||||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, take it or leave it: this could still be a one-liner if we wrote