1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//! # SD/MMC/eMMC Driver Library
//!
//! This library provides a no_std driver for SD, MMC, and eMMC storage devices
//! on ARM64 platforms, specifically optimized for Rockchip RK3568/RK3588 platforms.
//!
//! ## Features
//!
//! - **no_std compatible**: Works without the standard library
//! - **eMMC 4.x/5.x support**: Full support for eMMC standards including HS200/HS400 modes
//! - **SD/SDIO support**: Support for SD 1.0/2.0 and SDIO devices
//! - **PIO and DMA modes**: Choose between programmed I/O or DMA for data transfers
//! - **Rockchip optimization**: Specifically optimized for Rockchip platforms with DWCMSHC controller
//! - **Type-safe register access**: Safe hardware register operations
//!
//! ## Platform Support
//!
//! Currently optimized for:
//! - Rockchip RK3568
//! - Rockchip RK3588
//! - Other platforms using DWCMSHC SDHCI controller
//!
//! ## Usage Example
//!
//! ```rust,no_run
//! use sdmmc::emmc::EMmcHost;
//!
//! // Create EMMC controller instance at hardware base address
//! let mut emmc = EMmcHost::new(0xfe2e0000);
//!
//! // Initialize the controller and card
//! match emmc.init() {
//! Ok(_) => {
//! println!("EMMC initialized successfully");
//! }
//! Err(e) => {
//! println!("EMMC initialization failed: {:?}", e);
//! }
//! }
//! ```
//!
//! ## Features
//!
//! - `pio` (default): Use PIO (Programmed I/O) for data transfers
//! - `dma`: Use DMA (Direct Memory Access) for data transfers
//!
//! ## Modules
//!
//! - [`emmc`]: Main EMMC controller implementation
//! - [`err`]: Error types and handling
// #![no_main]
use warn;
pub const BLOCK_SIZE: usize = 512;
/// Dump memory region for debugging purposes
///
/// # Safety
///
/// This function is unsafe because it reads arbitrary memory addresses.
/// The caller must ensure that the memory region `addr..addr+size` is valid.
///
/// # Arguments
///
/// * `addr` - Starting address of the memory region
/// * `size` - Size of the memory region in bytes
pub unsafe
/// Kernel trait for platform-specific delay implementation
///
/// Users of this library must implement this trait and register it using the `set_impl!` macro.
/// Internal delay function using the registered Kernel implementation
pub
/// Register a Kernel implementation for delay functions
///
/// # Usage
///
/// ```rust
/// struct MyKernel;
///
/// impl Kernel for MyKernel {
/// fn sleep(us: u64) {
/// // Implementation...
/// }
/// }
///
/// set_impl!(MyKernel);
/// ```