1.. SPDX-License-Identifier: GPL-2.0+:
2
3mmc command
4============
5
6Synopsis
7--------
8
9::
10
11    mmc info
12    mmc read addr blk# cnt
13    mmc write addr blk# cnt
14    mmc erase blk# cnt
15    mmc rescan [mode]
16    mmc part
17    mmc dev [dev] [part] [mode]
18    mmc list
19    mmc wp
20    mmc bootbus <dev> <boot_bus_width> <reset_boot_bus_width> <boot_mode>
21    mmc bootpart-resize <dev> <dev part size MB> <RPMB part size MB>
22    mmc partconf <dev> [[varname] | [<boot_ack> <boot_partition> <partition_access>]]
23    mmc rst-function <dev> <value>
24
25Description
26-----------
27
28The mmc command is used to control MMC(eMMC/SD) device.
29
30The 'mmc info' command displays information (Manufacturer ID, OEM, Name, Bus Speed, Mode, ...) of MMC device.
31
32The 'mmc read' command reads raw data to memory address from MMC device with block offset and count.
33
34The 'mmc write' command writes raw data to MMC device from memory address with block offset and count.
35
36    addr
37        memory address
38    blk#
39        start block offset
40    cnt
41        block count
42
43The 'mmc erase' command erases *cnt* blocks on the MMC device starting at block *blk#*.
44
45    blk#
46        start block offset
47    cnt
48        block count
49
50The 'mmc rescan' command scans the available MMC device.
51
52   mode
53       speed mode to set.
54       CONFIG_MMC_SPEED_MODE_SET should be enabled. The required speed mode is
55       passed as the index from the following list.
56
57       0   - MMC_LEGACY
58       1   - MMC_HS
59       2   - SD_HS
60       3   - MMC_HS_52
61       4   - MMC_DDR_52
62       5   - UHS_SDR12
63       6   - UHS_SDR25
64       7   - UHS_SDR50
65       8   - UHS_DDR50
66       9   - UHS_SDR104
67       10  - MMC_HS_200
68       11  - MMC_HS_400
69       12  - MMC_HS_400_ES
70
71       A speed mode can be set only if it has already been enabled in the device tree
72
73The 'mmc part' command displays the list available partition on current mmc device.
74
75The 'mmc dev' command shows or set current mmc device.
76
77    dev
78        device number to change
79    part
80        partition number to change
81
82   mode
83       speed mode to set.
84       CONFIG_MMC_SPEED_MODE_SET should be enabled. The required speed mode is
85       passed as the index from the following list.
86
87       0   - MMC_LEGACY
88       1   - MMC_HS
89       2   - SD_HS
90       3   - MMC_HS_52
91       4   - MMC_DDR_52
92       5   - UHS_SDR12
93       6   - UHS_SDR25
94       7   - UHS_SDR50
95       8   - UHS_DDR50
96       9   - UHS_SDR104
97       10  - MMC_HS_200
98       11  - MMC_HS_400
99       12  - MMC_HS_400_ES
100
101       A speed mode can be set only if it has already been enabled in the device tree
102
103The 'mmc list' command displays the list available devices.
104
105The 'mmc wp' command enables "power on write protect" function for boot partitions.
106
107The 'mmc bootbus' command sets the BOOT_BUS_WIDTH field. (*Refer to eMMC specification*)
108
109    boot_bus_width
110        0x0
111            x1 (sdr) or x4(ddr) buswidth in boot operation mode (default)
112        0x1
113            x4 (sdr/ddr) buswidth in boot operation mode
114        0x2
115            x8 (sdr/ddr) buswidth in boot operation mode
116        0x3
117            Reserved
118
119    reset_boot_bus_width
120        0x0
121            Reset buswidth to x1, Single data reate and backward compatible timing after boot operation (default)
122        0x1
123            Retain BOOT_BUS_WIDTH and BOOT_MODE value after boot operation. This is relevant to Push-pull mode operation only
124
125    boot_mode
126        0x0
127            Use single data rate + backward compatible timing in boot operation (default)
128        0x1
129            Use single data rate + High Speed timing in boot operation mode
130        0x2
131            Use dual data rate in boot operation
132        0x3
133            Reserved
134
135The 'mmc partconf' command shows or changes PARTITION_CONFIG field.
136
137    varname
138        When showing the PARTITION_CONFIG, an optional environment variable to store the current boot_partition value into.
139    boot_ack
140        boot acknowledge value
141    boot_partition
142        boot partition to enable for boot
143            0x0
144                Device not boot enabled(default)
145            0x1
146                Boot partition1 enabled for boot
147            0x2
148                Boot partition2 enabled for boot
149            0x7
150                User area enabled for boot
151            others
152                Reserved
153    partition_access
154        partitions to access
155
156The 'mmc bootpart-resize' command changes sizes of boot and RPMB partitions.
157
158    dev
159        device number
160    boot part size MB
161        target size of boot partition
162    RPMB part size MB
163        target size of RPMB partition
164
165The 'mmc rst-function' command changes the RST_n_FUNCTION field.
166**WARNING** : This is a write-once field. (*Refer to eMMC specification*)
167
168    value
169        0x0
170            RST_n signal is temporarily disabled (default)
171        0x1
172            RST_n signal is permanently enabled
173        0x2
174            RST_n signal is permanently disabled
175        0x3
176            Reserved
177
178
179Examples
180--------
181
182The 'mmc info' command displays device's capabilities:
183::
184
185    => mmc info
186    Device: EXYNOS DWMMC
187    Manufacturer ID: 45
188    OEM: 100
189    Name: SDW16
190    Bus Speed: 52000000
191    Mode: MMC DDR52 (52MHz)
192    Rd Block Len: 512
193    MMC version 5.0
194    High Capacity: Yes
195    Capacity: 14.7 GiB
196    Bus Width: 8-bit DDR
197    Erase Group Size: 512 KiB
198    HC WP Group Size: 8 MiB
199    User Capacity: 14.7 GiB WRREL
200    Boot Capacity: 4 MiB ENH
201    RPMB Capacity: 4 MiB ENH
202    Boot area 0 is not write protected
203    Boot area 1 is not write protected
204
205The raw data can be read/written via 'mmc read/write' command:
206::
207
208    => mmc read 0x40000000 0x5000 0x100
209    MMC read: dev # 0, block # 20480, count 256 ... 256 blocks read: OK
210
211    => mmc write 0x40000000 0x5000 0x10
212    MMC write: dev # 0, block # 20480, count 256 ... 256 blocks written: OK
213
214The partition list can be shown via 'mmc part' command:
215::
216
217    => mmc part
218    Partition Map for MMC device 0  --   Partition Type: DOS
219
220    Part    Start Sector    Num Sectors     UUID            Type
221      1     8192            131072          dff8751a-01     0e Boot
222      2     139264          6291456         dff8751a-02     83
223      3     6430720         1048576         dff8751a-03     83
224      4     7479296         23298048        dff8751a-04     05 Extd
225      5     7481344         307200          dff8751a-05     83
226      6     7790592         65536           dff8751a-06     83
227      7     7858176         16384           dff8751a-07     83
228      8     7876608         22900736        dff8751a-08     83
229
230The current device can be shown or set via 'mmc dev' command:
231::
232
233    => mmc dev
234    switch to partitions #0, OK
235    mmc0(part0) is current device
236    => mmc dev 2 0
237    switch to partitions #0, OK
238    mmc2 is current device
239    => mmc dev 0 1 4
240    switch to partitions #1, OK
241    mmc0(part 1) is current device
242
243The list of available devices can be shown via 'mmc list' command:
244::
245
246    => mmc list
247    mmc list
248    EXYNOS DWMMC: 0 (eMMC)
249    EXYNOS DWMMC: 2 (SD)
250
251Configuration
252-------------
253
254The mmc command is only available if CONFIG_CMD_MMC=y.
255Some commands need to enable more configuration.
256
257write, erase
258    CONFIG_MMC_WRITE
259bootbus, bootpart-resize, partconf, rst-function
260    CONFIG_SUPPORT_EMMC_BOOT=y
261