Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+: |
| 2 | |
Heinrich Schuchardt | 1b0c316 | 2024-01-14 14:53:13 +0100 | [diff] [blame] | 3 | .. index:: |
| 4 | single: mmc (command) |
| 5 | |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 6 | mmc command |
Heinrich Schuchardt | b72160b | 2023-10-28 11:59:32 +0200 | [diff] [blame] | 7 | =========== |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 8 | |
| 9 | Synopsis |
| 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 Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 18 | mmc rescan [mode] |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 19 | mmc part |
Aswath Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 20 | mmc dev [dev] [part] [mode] |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 21 | 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 Dowle | 55a81ad | 2021-05-14 10:15:43 +1200 | [diff] [blame] | 25 | mmc partconf <dev> [[varname] | [<boot_ack> <boot_partition> <partition_access>]] |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 26 | mmc rst-function <dev> <value> |
Marek Vasut | 1f692e3 | 2023-10-31 13:20:17 +0100 | [diff] [blame] | 27 | mmc reg read <reg> <offset> [env] |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 28 | |
| 29 | Description |
| 30 | ----------- |
| 31 | |
| 32 | The mmc command is used to control MMC(eMMC/SD) device. |
| 33 | |
| 34 | The 'mmc info' command displays information (Manufacturer ID, OEM, Name, Bus Speed, Mode, ...) of MMC device. |
| 35 | |
| 36 | The 'mmc read' command reads raw data to memory address from MMC device with block offset and count. |
| 37 | |
| 38 | The '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 Chung | f14d260 | 2021-05-10 16:04:02 +0900 | [diff] [blame] | 47 | The 'mmc erase' command erases *cnt* blocks on the MMC device starting at block *blk#*. |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 48 | |
| 49 | blk# |
| 50 | start block offset |
| 51 | cnt |
| 52 | block count |
| 53 | |
| 54 | The 'mmc rescan' command scans the available MMC device. |
| 55 | |
Aswath Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 56 | mode |
| 57 | speed mode to set. |
Heinrich Schuchardt | 44acc5f | 2021-11-05 16:35:44 +0100 | [diff] [blame] | 58 | 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 Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 60 | |
Heinrich Schuchardt | 44acc5f | 2021-11-05 16:35:44 +0100 | [diff] [blame] | 61 | ========== ========================== |
| 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 Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 78 | |
| 79 | A speed mode can be set only if it has already been enabled in the device tree |
| 80 | |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 81 | The 'mmc part' command displays the list available partition on current mmc device. |
| 82 | |
| 83 | The '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 Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 90 | mode |
| 91 | speed mode to set. |
Patrick Delaunay | 2ad5b09 | 2022-03-29 16:01:13 +0200 | [diff] [blame] | 92 | 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 Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 94 | |
Patrick Delaunay | 2ad5b09 | 2022-03-29 16:01:13 +0200 | [diff] [blame] | 95 | ========== ========================== |
| 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 Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 112 | |
| 113 | A speed mode can be set only if it has already been enabled in the device tree |
| 114 | |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 115 | The 'mmc list' command displays the list available devices. |
| 116 | |
| 117 | The 'mmc wp' command enables "power on write protect" function for boot partitions. |
| 118 | |
| 119 | The '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 | |
| 147 | The 'mmc partconf' command shows or changes PARTITION_CONFIG field. |
| 148 | |
Reuben Dowle | 55a81ad | 2021-05-14 10:15:43 +1200 | [diff] [blame] | 149 | varname |
| 150 | When showing the PARTITION_CONFIG, an optional environment variable to store the current boot_partition value into. |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 151 | 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 | |
| 168 | The 'mmc bootpart-resize' command changes sizes of boot and RPMB partitions. |
Jaehoon Chung | f14d260 | 2021-05-10 16:04:02 +0900 | [diff] [blame] | 169 | |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 170 | 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 | |
| 177 | The '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 Vasut | 1f692e3 | 2023-10-31 13:20:17 +0100 | [diff] [blame] | 190 | The 'mmc reg read <reg> <offset> [env]' reads eMMC card register and |
| 191 | either print it to standard output, or store the value in environment |
| 192 | variable. |
| 193 | |
| 194 | <reg> with |
| 195 | optional offset <offset> into the register array, and print it to |
| 196 | standard 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 Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 215 | |
| 216 | Examples |
| 217 | -------- |
| 218 | |
| 219 | The '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 | |
| 242 | The raw data can be read/written via 'mmc read/write' command: |
| 243 | :: |
| 244 | |
Alexander Shirokov | a705cab | 2023-04-27 12:12:07 +0200 | [diff] [blame] | 245 | => mmc read 40000000 5000 100 |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 246 | MMC read: dev # 0, block # 20480, count 256 ... 256 blocks read: OK |
| 247 | |
Alexander Shirokov | a705cab | 2023-04-27 12:12:07 +0200 | [diff] [blame] | 248 | => mmc write 40000000 5000 100 |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 249 | MMC write: dev # 0, block # 20480, count 256 ... 256 blocks written: OK |
| 250 | |
| 251 | The 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 | |
| 267 | The 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 Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 276 | => mmc dev 0 1 4 |
| 277 | switch to partitions #1, OK |
| 278 | mmc0(part 1) is current device |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 279 | |
| 280 | The 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 | |
| 288 | Configuration |
| 289 | ------------- |
| 290 | |
| 291 | The mmc command is only available if CONFIG_CMD_MMC=y. |
| 292 | Some commands need to enable more configuration. |
| 293 | |
| 294 | write, erase |
| 295 | CONFIG_MMC_WRITE |
| 296 | bootbus, bootpart-resize, partconf, rst-function |
| 297 | CONFIG_SUPPORT_EMMC_BOOT=y |