@@ -20,8 +20,8 @@ use command::MmcCommand;
20
20
use response:: MmcResponse ;
21
21
use tuning:: { TuningMode , TuningWidth } ;
22
22
23
- /// Common operations for DesignWare MMC controllers on JH7110 SoCs .
24
- pub trait MmcOps {
23
+ /// Common operations for SD/ MMC peripherals .
24
+ pub trait MmcCommon {
25
25
/// Associated error type for the SD/MMC trait.
26
26
type Error ;
27
27
@@ -37,44 +37,33 @@ pub trait MmcOps {
37
37
/// Performs device initialization sequence.
38
38
fn init ( & mut self ) -> Result < ( ) , Self :: Error > ;
39
39
40
- /// Sets the sample phase for the MMC controller.
41
- fn set_sample_phase ( & mut self , sample_phase : u8 ) ;
42
-
43
- /// Waits for the FIFO to indicate readiness for read/write operations.
44
- fn fifo_ready ( & self , fifo_status : FifoStatus ) -> Result < ( ) , Self :: Error > ;
45
-
46
40
/// Waits for the CMD line to reset (usually during power-up).
47
41
fn wait_for_reset ( & mut self , reset : Reset , timeout : u64 ) -> Result < ( ) , Self :: Error > ;
48
42
49
43
/// Waits for the busy signal to clear for maximum `timeout_us` microseconds.
50
44
fn wait_while_busy ( & mut self , timout_us : u64 ) -> Result < ( ) , Self :: Error > ;
51
45
52
- /// Writes a SD/MMC command to the card.
53
- fn write_command < C : MmcCommand > ( & mut self , cmd : & C ) -> Result < ( ) , Self :: Error > ;
54
-
55
- /// Reads a SD/MMC response based on the provided command argument.
56
- ///
57
- /// # Note
58
- ///
59
- /// `cmd` should match the last call to `write_command`.
60
- fn read_response < C : MmcCommand , R : MmcResponse > ( & mut self , cmd : & C ) -> Result < R , Self :: Error > ;
61
-
62
- /// Reads the raw response bytes from the MMC controller.
63
- ///
64
- /// # Note
65
- ///
66
- /// Set `exp_crc` to true if a CRC checksum is expected in the response.
67
- ///
68
- /// The generic `N` parameter is for the expected length (in bytes) of the response.
69
- fn response_bytes < const N : usize > ( & mut self , exp_crc : bool ) -> Result < [ u8 ; N ] , Self :: Error > ;
70
-
71
46
/// Reads data from the MMC data lines.
72
47
fn read_data ( & mut self , data : & mut [ u8 ] ) -> Result < ( ) , Self :: Error > ;
73
48
74
49
/// Writes data to the MMC data lines.
75
50
fn write_data ( & mut self , data : & [ u8 ] ) -> Result < ( ) , Self :: Error > ;
76
51
77
- /// Requests the card to send a tuning block.
52
+ /// Sets the sample phase for the MMC controller.
53
+ fn set_sample_phase ( & mut self , sample_phase : u8 ) ;
54
+
55
+ /// Waits for the FIFO to indicate readiness for read/write operations.
56
+ fn fifo_ready ( & self , fifo_status : FifoStatus ) -> Result < ( ) , Self :: Error > ;
57
+
58
+ /// Handles tuning block requests.
59
+ ///
60
+ /// For hosts:
61
+ ///
62
+ /// - requests the device to send a tuning block
63
+ ///
64
+ /// For devices:
65
+ ///
66
+ /// - sends the host the requested tuning block
78
67
fn send_tuning ( & mut self , mode : TuningMode , width : TuningWidth ) -> Result < ( ) , Self :: Error > ;
79
68
80
69
/// Gets the interrupts status as a 32-bit bitfield.
@@ -95,3 +84,25 @@ pub trait MmcOps {
95
84
/// Clear all interrupts.
96
85
fn clear_all_response_interrupt ( & mut self ) ;
97
86
}
87
+
88
+ /// Common operations for SD/MMC host peripherals.
89
+ pub trait MmcHost : MmcCommon {
90
+ /// Writes a SD/MMC command to the card.
91
+ fn write_command < C : MmcCommand > ( & mut self , cmd : & C ) -> Result < ( ) , Self :: Error > ;
92
+
93
+ /// Reads a SD/MMC response based on the provided command argument.
94
+ ///
95
+ /// # Note
96
+ ///
97
+ /// `cmd` should match the last call to `write_command`.
98
+ fn read_response < C : MmcCommand , R : MmcResponse > ( & mut self , cmd : & C ) -> Result < R , Self :: Error > ;
99
+ }
100
+
101
+ /// Common operations for SD/MMC device peripherals.
102
+ pub trait MmcDevice : MmcCommon {
103
+ /// Reads a SD/MMC command sent from the host.
104
+ fn read_command < C : MmcCommand > ( & mut self ) -> Result < C , Self :: Error > ;
105
+
106
+ /// Writes a SD/MMC response based on the previous command.
107
+ fn write_response < R : MmcResponse > ( & mut self , response : & R ) -> Result < ( ) , Self :: Error > ;
108
+ }
0 commit comments