blob: 55391fda24c177b6d478e53bbed48fb7a36df6d7 [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
Tomas Paukrtab00d0e2024-09-02 20:49:17 +020018 mmc erase partname
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +053019 mmc rescan [mode]
Jaehoon Chung277b7cd2021-04-02 09:15:32 +090020 mmc part
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +053021 mmc dev [dev] [part] [mode]
Jaehoon Chung277b7cd2021-04-02 09:15:32 +090022 mmc list
23 mmc wp
24 mmc bootbus <dev> <boot_bus_width> <reset_boot_bus_width> <boot_mode>
25 mmc bootpart-resize <dev> <dev part size MB> <RPMB part size MB>
Reuben Dowle55a81ad2021-05-14 10:15:43 +120026 mmc partconf <dev> [[varname] | [<boot_ack> <boot_partition> <partition_access>]]
Jaehoon Chung277b7cd2021-04-02 09:15:32 +090027 mmc rst-function <dev> <value>
Marek Vasut1f692e32023-10-31 13:20:17 +010028 mmc reg read <reg> <offset> [env]
Jaehoon Chung277b7cd2021-04-02 09:15:32 +090029
30Description
31-----------
32
33The mmc command is used to control MMC(eMMC/SD) device.
34
35The 'mmc info' command displays information (Manufacturer ID, OEM, Name, Bus Speed, Mode, ...) of MMC device.
36
37The 'mmc read' command reads raw data to memory address from MMC device with block offset and count.
38
39The 'mmc write' command writes raw data to MMC device from memory address with block offset and count.
40
41 addr
42 memory address
43 blk#
44 start block offset
45 cnt
46 block count
47
Tomas Paukrtab00d0e2024-09-02 20:49:17 +020048The 'mmc erase' command erases *cnt* blocks on the MMC device starting at block *blk#* or
49the entire partition specified by *partname*.
Jaehoon Chung277b7cd2021-04-02 09:15:32 +090050
51 blk#
52 start block offset
53 cnt
54 block count
Tomas Paukrtab00d0e2024-09-02 20:49:17 +020055 partname
56 partition name
Jaehoon Chung277b7cd2021-04-02 09:15:32 +090057
58The 'mmc rescan' command scans the available MMC device.
59
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +053060 mode
61 speed mode to set.
Heinrich Schuchardt44acc5f2021-11-05 16:35:44 +010062 CONFIG_MMC_SPEED_MODE_SET should be enabled. The requested speed mode is
63 passed as a decimal number according to the following table:
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +053064
Heinrich Schuchardt44acc5f2021-11-05 16:35:44 +010065 ========== ==========================
66 Speed mode Description
67 ========== ==========================
68 0 MMC legacy
69 1 MMC High Speed (26MHz)
70 2 SD High Speed (50MHz)
71 3 MMC High Speed (52MHz)
72 4 MMC DDR52 (52MHz)
73 5 UHS SDR12 (25MHz)
74 6 UHS SDR25 (50MHz)
75 7 UHS SDR50 (100MHz)
76 8 UHS DDR50 (50MHz)
77 9 UHS SDR104 (208MHz)
78 10 HS200 (200MHz)
79 11 HS400 (200MHz)
80 12 HS400ES (200MHz)
81 ========== ==========================
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +053082
83 A speed mode can be set only if it has already been enabled in the device tree
84
Jaehoon Chung277b7cd2021-04-02 09:15:32 +090085The 'mmc part' command displays the list available partition on current mmc device.
86
87The 'mmc dev' command shows or set current mmc device.
88
89 dev
90 device number to change
91 part
92 partition number to change
93
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +053094 mode
95 speed mode to set.
Patrick Delaunay2ad5b092022-03-29 16:01:13 +020096 CONFIG_MMC_SPEED_MODE_SET should be enabled. The requested speed mode is
97 passed as a decimal number according to the following table:
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +053098
Patrick Delaunay2ad5b092022-03-29 16:01:13 +020099 ========== ==========================
100 Speed mode Description
101 ========== ==========================
102 0 MMC legacy
103 1 MMC High Speed (26MHz)
104 2 SD High Speed (50MHz)
105 3 MMC High Speed (52MHz)
106 4 MMC DDR52 (52MHz)
107 5 UHS SDR12 (25MHz)
108 6 UHS SDR25 (50MHz)
109 7 UHS SDR50 (100MHz)
110 8 UHS DDR50 (50MHz)
111 9 UHS SDR104 (208MHz)
112 10 HS200 (200MHz)
113 11 HS400 (200MHz)
114 12 HS400ES (200MHz)
115 ========== ==========================
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +0530116
117 A speed mode can be set only if it has already been enabled in the device tree
118
Jaehoon Chung277b7cd2021-04-02 09:15:32 +0900119The 'mmc list' command displays the list available devices.
120
121The 'mmc wp' command enables "power on write protect" function for boot partitions.
122
123The 'mmc bootbus' command sets the BOOT_BUS_WIDTH field. (*Refer to eMMC specification*)
124
125 boot_bus_width
126 0x0
127 x1 (sdr) or x4(ddr) buswidth in boot operation mode (default)
128 0x1
129 x4 (sdr/ddr) buswidth in boot operation mode
130 0x2
131 x8 (sdr/ddr) buswidth in boot operation mode
132 0x3
133 Reserved
134
135 reset_boot_bus_width
136 0x0
137 Reset buswidth to x1, Single data reate and backward compatible timing after boot operation (default)
138 0x1
139 Retain BOOT_BUS_WIDTH and BOOT_MODE value after boot operation. This is relevant to Push-pull mode operation only
140
141 boot_mode
142 0x0
143 Use single data rate + backward compatible timing in boot operation (default)
144 0x1
145 Use single data rate + High Speed timing in boot operation mode
146 0x2
147 Use dual data rate in boot operation
148 0x3
149 Reserved
150
151The 'mmc partconf' command shows or changes PARTITION_CONFIG field.
152
Reuben Dowle55a81ad2021-05-14 10:15:43 +1200153 varname
154 When showing the PARTITION_CONFIG, an optional environment variable to store the current boot_partition value into.
Jaehoon Chung277b7cd2021-04-02 09:15:32 +0900155 boot_ack
156 boot acknowledge value
157 boot_partition
158 boot partition to enable for boot
159 0x0
160 Device not boot enabled(default)
161 0x1
162 Boot partition1 enabled for boot
163 0x2
164 Boot partition2 enabled for boot
165 0x7
166 User area enabled for boot
167 others
168 Reserved
169 partition_access
170 partitions to access
171
172The 'mmc bootpart-resize' command changes sizes of boot and RPMB partitions.
Jaehoon Chungf14d2602021-05-10 16:04:02 +0900173
Jaehoon Chung277b7cd2021-04-02 09:15:32 +0900174 dev
175 device number
176 boot part size MB
177 target size of boot partition
178 RPMB part size MB
179 target size of RPMB partition
180
181The 'mmc rst-function' command changes the RST_n_FUNCTION field.
182**WARNING** : This is a write-once field. (*Refer to eMMC specification*)
183
184 value
185 0x0
186 RST_n signal is temporarily disabled (default)
187 0x1
188 RST_n signal is permanently enabled
189 0x2
190 RST_n signal is permanently disabled
191 0x3
192 Reserved
193
Marek Vasut1f692e32023-10-31 13:20:17 +0100194The 'mmc reg read <reg> <offset> [env]' reads eMMC card register and
195either print it to standard output, or store the value in environment
196variable.
197
198<reg> with
199optional offset <offset> into the register array, and print it to
200standard output or store it into environment variable [env].
201
202 reg
203 cid
204 The Device IDentification (CID) register. Uses offset.
205 csd
206 The Device-Specific Data (CSD) register. Uses offset.
207 dsr
208 The driver stage register (DSR).
209 ocr
210 The operation conditions register (OCR).
211 rca
212 The relative Device address (RCA) register.
213 extcsd
214 The Extended CSD register. Uses offset.
215 offset
216 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.
217 env
218 Optional environment variable into which 32-bit value read from register should be stored.
Jaehoon Chung277b7cd2021-04-02 09:15:32 +0900219
220Examples
221--------
222
223The 'mmc info' command displays device's capabilities:
224::
225
226 => mmc info
227 Device: EXYNOS DWMMC
228 Manufacturer ID: 45
229 OEM: 100
230 Name: SDW16
231 Bus Speed: 52000000
232 Mode: MMC DDR52 (52MHz)
233 Rd Block Len: 512
234 MMC version 5.0
235 High Capacity: Yes
236 Capacity: 14.7 GiB
237 Bus Width: 8-bit DDR
238 Erase Group Size: 512 KiB
239 HC WP Group Size: 8 MiB
240 User Capacity: 14.7 GiB WRREL
241 Boot Capacity: 4 MiB ENH
242 RPMB Capacity: 4 MiB ENH
243 Boot area 0 is not write protected
244 Boot area 1 is not write protected
245
246The raw data can be read/written via 'mmc read/write' command:
247::
248
Alexander Shirokova705cab2023-04-27 12:12:07 +0200249 => mmc read 40000000 5000 100
Jaehoon Chung277b7cd2021-04-02 09:15:32 +0900250 MMC read: dev # 0, block # 20480, count 256 ... 256 blocks read: OK
251
Alexander Shirokova705cab2023-04-27 12:12:07 +0200252 => mmc write 40000000 5000 100
Jaehoon Chung277b7cd2021-04-02 09:15:32 +0900253 MMC write: dev # 0, block # 20480, count 256 ... 256 blocks written: OK
254
255The partition list can be shown via 'mmc part' command:
256::
257
258 => mmc part
259 Partition Map for MMC device 0 -- Partition Type: DOS
260
261 Part Start Sector Num Sectors UUID Type
262 1 8192 131072 dff8751a-01 0e Boot
263 2 139264 6291456 dff8751a-02 83
264 3 6430720 1048576 dff8751a-03 83
265 4 7479296 23298048 dff8751a-04 05 Extd
266 5 7481344 307200 dff8751a-05 83
267 6 7790592 65536 dff8751a-06 83
268 7 7858176 16384 dff8751a-07 83
269 8 7876608 22900736 dff8751a-08 83
270
271The current device can be shown or set via 'mmc dev' command:
272::
273
274 => mmc dev
275 switch to partitions #0, OK
276 mmc0(part0) is current device
277 => mmc dev 2 0
278 switch to partitions #0, OK
279 mmc2 is current device
Aswath Govindraju6bc3dd62021-08-13 23:04:42 +0530280 => mmc dev 0 1 4
281 switch to partitions #1, OK
282 mmc0(part 1) is current device
Jaehoon Chung277b7cd2021-04-02 09:15:32 +0900283
284The list of available devices can be shown via 'mmc list' command:
285::
286
287 => mmc list
288 mmc list
289 EXYNOS DWMMC: 0 (eMMC)
290 EXYNOS DWMMC: 2 (SD)
291
292Configuration
293-------------
294
295The mmc command is only available if CONFIG_CMD_MMC=y.
296Some commands need to enable more configuration.
297
298write, erase
299 CONFIG_MMC_WRITE
300bootbus, bootpart-resize, partconf, rst-function
301 CONFIG_SUPPORT_EMMC_BOOT=y