blob: 5a64400eeaedd6eb77271c26f8d83eedea5c508e [file] [log] [blame]
Jaehoon Chung277b7cd2021-04-02 09:15:32 +09001.. SPDX-License-Identifier: GPL-2.0+:
2
Heinrich Schuchardt1b0c3162024-01-14 14:53:13 +01003.. index::
4 single: mmc (command)
5
Jaehoon Chung277b7cd2021-04-02 09:15:32 +09006mmc command
Heinrich Schuchardtb72160b2023-10-28 11:59:32 +02007===========
Jaehoon Chung277b7cd2021-04-02 09:15:32 +09008
9Synopsis
10--------
11
12::
13
14 mmc info
15 mmc read addr blk# cnt
16 mmc write addr blk# cnt
17 mmc erase blk# cnt
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +053018 mmc rescan [mode]
Jaehoon Chung277b7cd2021-04-02 09:15:32 +090019 mmc part
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +053020 mmc dev [dev] [part] [mode]
Jaehoon Chung277b7cd2021-04-02 09:15:32 +090021 mmc list
22 mmc wp
23 mmc bootbus <dev> <boot_bus_width> <reset_boot_bus_width> <boot_mode>
24 mmc bootpart-resize <dev> <dev part size MB> <RPMB part size MB>
Reuben Dowle55a81ad2021-05-14 10:15:43 +120025 mmc partconf <dev> [[varname] | [<boot_ack> <boot_partition> <partition_access>]]
Jaehoon Chung277b7cd2021-04-02 09:15:32 +090026 mmc rst-function <dev> <value>
Marek Vasut1f692e32023-10-31 13:20:17 +010027 mmc reg read <reg> <offset> [env]
Jaehoon Chung277b7cd2021-04-02 09:15:32 +090028
29Description
30-----------
31
32The mmc command is used to control MMC(eMMC/SD) device.
33
34The 'mmc info' command displays information (Manufacturer ID, OEM, Name, Bus Speed, Mode, ...) of MMC device.
35
36The 'mmc read' command reads raw data to memory address from MMC device with block offset and count.
37
38The 'mmc write' command writes raw data to MMC device from memory address with block offset and count.
39
40 addr
41 memory address
42 blk#
43 start block offset
44 cnt
45 block count
46
Jaehoon Chungf14d2602021-05-10 16:04:02 +090047The 'mmc erase' command erases *cnt* blocks on the MMC device starting at block *blk#*.
Jaehoon Chung277b7cd2021-04-02 09:15:32 +090048
49 blk#
50 start block offset
51 cnt
52 block count
53
54The 'mmc rescan' command scans the available MMC device.
55
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +053056 mode
57 speed mode to set.
Heinrich Schuchardt44acc5f2021-11-05 16:35:44 +010058 CONFIG_MMC_SPEED_MODE_SET should be enabled. The requested speed mode is
59 passed as a decimal number according to the following table:
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +053060
Heinrich Schuchardt44acc5f2021-11-05 16:35:44 +010061 ========== ==========================
62 Speed mode Description
63 ========== ==========================
64 0 MMC legacy
65 1 MMC High Speed (26MHz)
66 2 SD High Speed (50MHz)
67 3 MMC High Speed (52MHz)
68 4 MMC DDR52 (52MHz)
69 5 UHS SDR12 (25MHz)
70 6 UHS SDR25 (50MHz)
71 7 UHS SDR50 (100MHz)
72 8 UHS DDR50 (50MHz)
73 9 UHS SDR104 (208MHz)
74 10 HS200 (200MHz)
75 11 HS400 (200MHz)
76 12 HS400ES (200MHz)
77 ========== ==========================
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +053078
79 A speed mode can be set only if it has already been enabled in the device tree
80
Jaehoon Chung277b7cd2021-04-02 09:15:32 +090081The 'mmc part' command displays the list available partition on current mmc device.
82
83The 'mmc dev' command shows or set current mmc device.
84
85 dev
86 device number to change
87 part
88 partition number to change
89
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +053090 mode
91 speed mode to set.
Patrick Delaunay2ad5b092022-03-29 16:01:13 +020092 CONFIG_MMC_SPEED_MODE_SET should be enabled. The requested speed mode is
93 passed as a decimal number according to the following table:
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +053094
Patrick Delaunay2ad5b092022-03-29 16:01:13 +020095 ========== ==========================
96 Speed mode Description
97 ========== ==========================
98 0 MMC legacy
99 1 MMC High Speed (26MHz)
100 2 SD High Speed (50MHz)
101 3 MMC High Speed (52MHz)
102 4 MMC DDR52 (52MHz)
103 5 UHS SDR12 (25MHz)
104 6 UHS SDR25 (50MHz)
105 7 UHS SDR50 (100MHz)
106 8 UHS DDR50 (50MHz)
107 9 UHS SDR104 (208MHz)
108 10 HS200 (200MHz)
109 11 HS400 (200MHz)
110 12 HS400ES (200MHz)
111 ========== ==========================
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +0530112
113 A speed mode can be set only if it has already been enabled in the device tree
114
Jaehoon Chung277b7cd2021-04-02 09:15:32 +0900115The 'mmc list' command displays the list available devices.
116
117The 'mmc wp' command enables "power on write protect" function for boot partitions.
118
119The 'mmc bootbus' command sets the BOOT_BUS_WIDTH field. (*Refer to eMMC specification*)
120
121 boot_bus_width
122 0x0
123 x1 (sdr) or x4(ddr) buswidth in boot operation mode (default)
124 0x1
125 x4 (sdr/ddr) buswidth in boot operation mode
126 0x2
127 x8 (sdr/ddr) buswidth in boot operation mode
128 0x3
129 Reserved
130
131 reset_boot_bus_width
132 0x0
133 Reset buswidth to x1, Single data reate and backward compatible timing after boot operation (default)
134 0x1
135 Retain BOOT_BUS_WIDTH and BOOT_MODE value after boot operation. This is relevant to Push-pull mode operation only
136
137 boot_mode
138 0x0
139 Use single data rate + backward compatible timing in boot operation (default)
140 0x1
141 Use single data rate + High Speed timing in boot operation mode
142 0x2
143 Use dual data rate in boot operation
144 0x3
145 Reserved
146
147The 'mmc partconf' command shows or changes PARTITION_CONFIG field.
148
Reuben Dowle55a81ad2021-05-14 10:15:43 +1200149 varname
150 When showing the PARTITION_CONFIG, an optional environment variable to store the current boot_partition value into.
Jaehoon Chung277b7cd2021-04-02 09:15:32 +0900151 boot_ack
152 boot acknowledge value
153 boot_partition
154 boot partition to enable for boot
155 0x0
156 Device not boot enabled(default)
157 0x1
158 Boot partition1 enabled for boot
159 0x2
160 Boot partition2 enabled for boot
161 0x7
162 User area enabled for boot
163 others
164 Reserved
165 partition_access
166 partitions to access
167
168The 'mmc bootpart-resize' command changes sizes of boot and RPMB partitions.
Jaehoon Chungf14d2602021-05-10 16:04:02 +0900169
Jaehoon Chung277b7cd2021-04-02 09:15:32 +0900170 dev
171 device number
172 boot part size MB
173 target size of boot partition
174 RPMB part size MB
175 target size of RPMB partition
176
177The 'mmc rst-function' command changes the RST_n_FUNCTION field.
178**WARNING** : This is a write-once field. (*Refer to eMMC specification*)
179
180 value
181 0x0
182 RST_n signal is temporarily disabled (default)
183 0x1
184 RST_n signal is permanently enabled
185 0x2
186 RST_n signal is permanently disabled
187 0x3
188 Reserved
189
Marek Vasut1f692e32023-10-31 13:20:17 +0100190The 'mmc reg read <reg> <offset> [env]' reads eMMC card register and
191either print it to standard output, or store the value in environment
192variable.
193
194<reg> with
195optional offset <offset> into the register array, and print it to
196standard output or store it into environment variable [env].
197
198 reg
199 cid
200 The Device IDentification (CID) register. Uses offset.
201 csd
202 The Device-Specific Data (CSD) register. Uses offset.
203 dsr
204 The driver stage register (DSR).
205 ocr
206 The operation conditions register (OCR).
207 rca
208 The relative Device address (RCA) register.
209 extcsd
210 The Extended CSD register. Uses offset.
211 offset
212 For 'cid'/'csd' 128 bit registers '[0..3]' in 32-bit increments. For 'extcsd' 512 bit register '[0..512,all]' in 8-bit increments, or 'all' to read the entire register.
213 env
214 Optional environment variable into which 32-bit value read from register should be stored.
Jaehoon Chung277b7cd2021-04-02 09:15:32 +0900215
216Examples
217--------
218
219The 'mmc info' command displays device's capabilities:
220::
221
222 => mmc info
223 Device: EXYNOS DWMMC
224 Manufacturer ID: 45
225 OEM: 100
226 Name: SDW16
227 Bus Speed: 52000000
228 Mode: MMC DDR52 (52MHz)
229 Rd Block Len: 512
230 MMC version 5.0
231 High Capacity: Yes
232 Capacity: 14.7 GiB
233 Bus Width: 8-bit DDR
234 Erase Group Size: 512 KiB
235 HC WP Group Size: 8 MiB
236 User Capacity: 14.7 GiB WRREL
237 Boot Capacity: 4 MiB ENH
238 RPMB Capacity: 4 MiB ENH
239 Boot area 0 is not write protected
240 Boot area 1 is not write protected
241
242The raw data can be read/written via 'mmc read/write' command:
243::
244
Alexander Shirokova705cab2023-04-27 12:12:07 +0200245 => mmc read 40000000 5000 100
Jaehoon Chung277b7cd2021-04-02 09:15:32 +0900246 MMC read: dev # 0, block # 20480, count 256 ... 256 blocks read: OK
247
Alexander Shirokova705cab2023-04-27 12:12:07 +0200248 => mmc write 40000000 5000 100
Jaehoon Chung277b7cd2021-04-02 09:15:32 +0900249 MMC write: dev # 0, block # 20480, count 256 ... 256 blocks written: OK
250
251The partition list can be shown via 'mmc part' command:
252::
253
254 => mmc part
255 Partition Map for MMC device 0 -- Partition Type: DOS
256
257 Part Start Sector Num Sectors UUID Type
258 1 8192 131072 dff8751a-01 0e Boot
259 2 139264 6291456 dff8751a-02 83
260 3 6430720 1048576 dff8751a-03 83
261 4 7479296 23298048 dff8751a-04 05 Extd
262 5 7481344 307200 dff8751a-05 83
263 6 7790592 65536 dff8751a-06 83
264 7 7858176 16384 dff8751a-07 83
265 8 7876608 22900736 dff8751a-08 83
266
267The current device can be shown or set via 'mmc dev' command:
268::
269
270 => mmc dev
271 switch to partitions #0, OK
272 mmc0(part0) is current device
273 => mmc dev 2 0
274 switch to partitions #0, OK
275 mmc2 is current device
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +0530276 => mmc dev 0 1 4
277 switch to partitions #1, OK
278 mmc0(part 1) is current device
Jaehoon Chung277b7cd2021-04-02 09:15:32 +0900279
280The list of available devices can be shown via 'mmc list' command:
281::
282
283 => mmc list
284 mmc list
285 EXYNOS DWMMC: 0 (eMMC)
286 EXYNOS DWMMC: 2 (SD)
287
288Configuration
289-------------
290
291The mmc command is only available if CONFIG_CMD_MMC=y.
292Some commands need to enable more configuration.
293
294write, erase
295 CONFIG_MMC_WRITE
296bootbus, bootpart-resize, partconf, rst-function
297 CONFIG_SUPPORT_EMMC_BOOT=y