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