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

[board] sd/mmc bootloading support for 100ask-d1-h #143

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions board/100ask-d1-h-rs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,42 @@ fn main(p: Peripherals, _c: Clocks) {
// Dump information about the system clocks.
clock_dump(&p.ccu);

// TODO: SD/MMC init.
let _sdmmc_pins = {
let d1 = p.gpio.pf0.into_function::<2>();
let d0 = p.gpio.pf1.into_function::<2>();
let clk = p.gpio.pf2.into_function::<2>();
let cmd = p.gpio.pf3.into_function::<2>();
let d3 = p.gpio.pf4.into_function::<2>();
let d2 = p.gpio.pf5.into_function::<2>();
(clk, cmd, d0, d1, d2, d3)
};
unsafe {
p.ccu
.smhc_bgr
.modify(|val| val.gate_pass::<0>().deassert_reset::<0>());
// p.ccu.smhc_clk[0].modify(|val| val.unmask_clock());
p.smhc0
.global_control
.modify(|val| val.set_dma_reset().set_fifo_reset().set_software_reset());
};
/*
// let sdhci = p.smhc0.smhc(sdmmc_pins)
// sdhci.detect_sdcard() // TODO or: detect_mmc()
p.smhc0.global_control.modify(|val| val.set_dma_reset().set_fifo_reset().set_software_reset());
// TODO sdhci_set_clock(hci, MMC_CLK_400K)
// TODO sdhci_set_width(hci, MMC_BUS_WIDTH_1)
// TODO go_idle_state(hci)
// delay_ms(2)
// let sdcard = sdhci.try_detect_sdcard()?;
// // TODO volumn, directory, file, etc
// let dtb = dir.open_file_in_dir()?;
// // file read loop
// ddr_mem[..size].copy_from_slice(&buf);
// let kernel = ...
// let config = ...
*/

// Start boot command line.
let (command_buffer, history_buffer) = ([0; 128], [0; 128]);
let mut cli = CliBuilder::default()
Expand Down
28 changes: 19 additions & 9 deletions rust/src/soc/sun20iw1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,29 @@ use allwinner_hal::{
ccu::{Clocks, CpuClockSource},
gpio::{Disabled, Function},
};
use allwinner_rt::soc::d1::{CCU, COM, GPIO, PHY, PLIC, SPI0, UART0};
use allwinner_rt::soc::d1::{CCU, COM, GPIO, PHY, PLIC, SMHC0, SMHC1, SMHC2, SPI0, UART0};
use embedded_time::rate::Extensions;

/// SyterKit runtime peripheral ownership and configurations.
pub struct Peripherals<'a> {
/// General Purpose Input/Output peripheral.
pub gpio: Pads<'a>,
/// Clock control unit peripheral.
pub ccu: CCU,
// uart0 is removed; it is occupied by stdin/stdout `Serial` structure.
/// Serial Peripheral Interface peripheral 0.
pub spi0: SPI0,
/// Memory controller physical layer (PHY) of DDR SDRAM.
pub phy: PHY,
/// Common control peripheral of DDR SDRAM.
pub com: COM,
/// Clock control unit peripheral.
pub ccu: CCU,
/// Memory controller physical layer (PHY) of DDR SDRAM.
pub phy: PHY,
/// SD/MMC Host Controller peripheral 0.
pub smhc0: SMHC0,
/// SD/MMC Host Controller peripheral 1.
pub smhc1: SMHC1,
/// SD/MMC Host Controller peripheral 2.
pub smhc2: SMHC2,
/// Serial Peripheral Interface peripheral 0.
pub spi0: SPI0,
/// Platform-local Interrupt Controller.
pub plic: PLIC,
}
Expand All @@ -39,10 +46,13 @@ impl<'a> Peripherals<'a> {
let uart0 = src.uart0;
let p = Self {
gpio: Pads::__init(),
spi0: src.spi0,
phy: src.phy,
com: src.com,
ccu: src.ccu,
com: src.com,
phy: src.phy,
smhc0: src.smhc0,
smhc1: src.smhc1,
smhc2: src.smhc2,
spi0: src.spi0,
plic: src.plic,
};
(p, uart0, pb8, pb9)
Expand Down
Loading