Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | 7a428cc | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2003 |
| 4 | * Kyle Harris, kharris@nexus-tech.net |
wdenk | 7a428cc | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 655306c | 2020-05-10 11:39:58 -0600 | [diff] [blame] | 8 | #include <blk.h> |
wdenk | 7a428cc | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 9 | #include <command.h> |
Simon Glass | a73bda4 | 2015-11-08 23:47:45 -0700 | [diff] [blame] | 10 | #include <console.h> |
Marek Vasut | dfff8ed | 2020-06-20 14:28:25 +0200 | [diff] [blame] | 11 | #include <memalign.h> |
wdenk | 7a428cc | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 12 | #include <mmc.h> |
Simon Glass | 655306c | 2020-05-10 11:39:58 -0600 | [diff] [blame] | 13 | #include <part.h> |
Jassi Brar | 814a975 | 2018-04-06 12:05:24 +0530 | [diff] [blame] | 14 | #include <sparse_format.h> |
| 15 | #include <image-sparse.h> |
wdenk | 7a428cc | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 16 | |
Mike Frysinger | 0289fe6 | 2009-06-14 21:35:21 -0400 | [diff] [blame] | 17 | static int curr_device = -1; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 18 | |
| 19 | static void print_mmcinfo(struct mmc *mmc) |
| 20 | { |
Diego Santa Cruz | 99ca028 | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 21 | int i; |
| 22 | |
Pantelis Antoniou | 2c85046 | 2014-03-11 19:34:20 +0200 | [diff] [blame] | 23 | printf("Device: %s\n", mmc->cfg->name); |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 24 | printf("Manufacturer ID: %x\n", mmc->cid[0] >> 24); |
| 25 | printf("OEM: %x\n", (mmc->cid[0] >> 8) & 0xffff); |
| 26 | printf("Name: %c%c%c%c%c \n", mmc->cid[0] & 0xff, |
| 27 | (mmc->cid[1] >> 24), (mmc->cid[1] >> 16) & 0xff, |
| 28 | (mmc->cid[1] >> 8) & 0xff, mmc->cid[1] & 0xff); |
| 29 | |
Jean-Jacques Hiblot | f62caf9 | 2017-09-21 16:29:56 +0200 | [diff] [blame] | 30 | printf("Bus Speed: %d\n", mmc->clock); |
Jean-Jacques Hiblot | 93c31d1 | 2017-11-30 17:43:54 +0100 | [diff] [blame] | 31 | #if CONFIG_IS_ENABLED(MMC_VERBOSE) |
Marek Vasut | d1e6346 | 2019-03-18 04:49:21 +0100 | [diff] [blame] | 32 | printf("Mode: %s\n", mmc_mode_name(mmc->selected_mode)); |
Jean-Jacques Hiblot | 93c31d1 | 2017-11-30 17:43:54 +0100 | [diff] [blame] | 33 | mmc_dump_capabilities("card capabilities", mmc->card_caps); |
| 34 | mmc_dump_capabilities("host capabilities", mmc->host_caps); |
| 35 | #endif |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 36 | printf("Rd Block Len: %d\n", mmc->read_bl_len); |
| 37 | |
Pantelis Antoniou | a095bfd | 2015-01-23 12:12:01 +0200 | [diff] [blame] | 38 | printf("%s version %d.%d", IS_SD(mmc) ? "SD" : "MMC", |
| 39 | EXTRACT_SDMMC_MAJOR_VERSION(mmc->version), |
| 40 | EXTRACT_SDMMC_MINOR_VERSION(mmc->version)); |
| 41 | if (EXTRACT_SDMMC_CHANGE_VERSION(mmc->version) != 0) |
| 42 | printf(".%d", EXTRACT_SDMMC_CHANGE_VERSION(mmc->version)); |
| 43 | printf("\n"); |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 44 | |
| 45 | printf("High Capacity: %s\n", mmc->high_capacity ? "Yes" : "No"); |
Minkyu Kang | 316f81a | 2011-01-04 01:04:19 +0000 | [diff] [blame] | 46 | puts("Capacity: "); |
| 47 | print_size(mmc->capacity, "\n"); |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 48 | |
Andrew Gabbasov | 9fc2a41 | 2014-12-01 06:59:09 -0600 | [diff] [blame] | 49 | printf("Bus Width: %d-bit%s\n", mmc->bus_width, |
| 50 | mmc->ddr_mode ? " DDR" : ""); |
Diego Santa Cruz | 99ca028 | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 51 | |
Jean-Jacques Hiblot | 27edffe | 2018-01-04 15:23:34 +0100 | [diff] [blame] | 52 | #if CONFIG_IS_ENABLED(MMC_WRITE) |
Diego Santa Cruz | 173c79e | 2014-12-23 10:50:26 +0100 | [diff] [blame] | 53 | puts("Erase Group Size: "); |
| 54 | print_size(((u64)mmc->erase_grp_size) << 9, "\n"); |
Jean-Jacques Hiblot | 27edffe | 2018-01-04 15:23:34 +0100 | [diff] [blame] | 55 | #endif |
Diego Santa Cruz | 173c79e | 2014-12-23 10:50:26 +0100 | [diff] [blame] | 56 | |
Diego Santa Cruz | 1f69e22 | 2014-12-23 10:50:19 +0100 | [diff] [blame] | 57 | if (!IS_SD(mmc) && mmc->version >= MMC_VERSION_4_41) { |
Diego Santa Cruz | c145f9e | 2014-12-23 10:50:17 +0100 | [diff] [blame] | 58 | bool has_enh = (mmc->part_support & ENHNCD_SUPPORT) != 0; |
Diego Santa Cruz | 2b45f58 | 2014-12-23 10:50:23 +0100 | [diff] [blame] | 59 | bool usr_enh = has_enh && (mmc->part_attr & EXT_CSD_ENH_USR); |
Marek Vasut | dfff8ed | 2020-06-20 14:28:25 +0200 | [diff] [blame] | 60 | ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, MMC_MAX_BLOCK_LEN); |
| 61 | u8 wp; |
Heinrich Schuchardt | 0c8ffff | 2020-03-30 07:24:18 +0200 | [diff] [blame] | 62 | int ret; |
Diego Santa Cruz | 173c79e | 2014-12-23 10:50:26 +0100 | [diff] [blame] | 63 | |
Jean-Jacques Hiblot | ba54ab8 | 2018-01-04 15:23:36 +0100 | [diff] [blame] | 64 | #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING) |
Diego Santa Cruz | 173c79e | 2014-12-23 10:50:26 +0100 | [diff] [blame] | 65 | puts("HC WP Group Size: "); |
| 66 | print_size(((u64)mmc->hc_wp_grp_size) << 9, "\n"); |
Jean-Jacques Hiblot | ba54ab8 | 2018-01-04 15:23:36 +0100 | [diff] [blame] | 67 | #endif |
Diego Santa Cruz | 173c79e | 2014-12-23 10:50:26 +0100 | [diff] [blame] | 68 | |
Diego Santa Cruz | 99ca028 | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 69 | puts("User Capacity: "); |
Diego Santa Cruz | 37a50b9 | 2014-12-23 10:50:33 +0100 | [diff] [blame] | 70 | print_size(mmc->capacity_user, usr_enh ? " ENH" : ""); |
| 71 | if (mmc->wr_rel_set & EXT_CSD_WR_DATA_REL_USR) |
| 72 | puts(" WRREL\n"); |
| 73 | else |
| 74 | putc('\n'); |
Diego Santa Cruz | 2b45f58 | 2014-12-23 10:50:23 +0100 | [diff] [blame] | 75 | if (usr_enh) { |
| 76 | puts("User Enhanced Start: "); |
| 77 | print_size(mmc->enh_user_start, "\n"); |
| 78 | puts("User Enhanced Size: "); |
| 79 | print_size(mmc->enh_user_size, "\n"); |
| 80 | } |
Diego Santa Cruz | 99ca028 | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 81 | puts("Boot Capacity: "); |
Diego Santa Cruz | c145f9e | 2014-12-23 10:50:17 +0100 | [diff] [blame] | 82 | print_size(mmc->capacity_boot, has_enh ? " ENH\n" : "\n"); |
Diego Santa Cruz | 99ca028 | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 83 | puts("RPMB Capacity: "); |
Diego Santa Cruz | c145f9e | 2014-12-23 10:50:17 +0100 | [diff] [blame] | 84 | print_size(mmc->capacity_rpmb, has_enh ? " ENH\n" : "\n"); |
Diego Santa Cruz | 173c79e | 2014-12-23 10:50:26 +0100 | [diff] [blame] | 85 | |
Diego Santa Cruz | 99ca028 | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 86 | for (i = 0; i < ARRAY_SIZE(mmc->capacity_gp); i++) { |
Diego Santa Cruz | c145f9e | 2014-12-23 10:50:17 +0100 | [diff] [blame] | 87 | bool is_enh = has_enh && |
| 88 | (mmc->part_attr & EXT_CSD_ENH_GP(i)); |
Diego Santa Cruz | 99ca028 | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 89 | if (mmc->capacity_gp[i]) { |
Diego Santa Cruz | d835843 | 2014-12-23 10:50:18 +0100 | [diff] [blame] | 90 | printf("GP%i Capacity: ", i+1); |
Diego Santa Cruz | c145f9e | 2014-12-23 10:50:17 +0100 | [diff] [blame] | 91 | print_size(mmc->capacity_gp[i], |
Diego Santa Cruz | 37a50b9 | 2014-12-23 10:50:33 +0100 | [diff] [blame] | 92 | is_enh ? " ENH" : ""); |
| 93 | if (mmc->wr_rel_set & EXT_CSD_WR_DATA_REL_GP(i)) |
| 94 | puts(" WRREL\n"); |
| 95 | else |
| 96 | putc('\n'); |
Diego Santa Cruz | 99ca028 | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 97 | } |
| 98 | } |
Heinrich Schuchardt | 0c8ffff | 2020-03-30 07:24:18 +0200 | [diff] [blame] | 99 | ret = mmc_send_ext_csd(mmc, ext_csd); |
| 100 | if (ret) |
| 101 | return; |
| 102 | wp = ext_csd[EXT_CSD_BOOT_WP_STATUS]; |
| 103 | for (i = 0; i < 2; ++i) { |
| 104 | printf("Boot area %d is ", i); |
| 105 | switch (wp & 3) { |
| 106 | case 0: |
| 107 | printf("not write protected\n"); |
| 108 | break; |
| 109 | case 1: |
| 110 | printf("power on protected\n"); |
| 111 | break; |
| 112 | case 2: |
| 113 | printf("permanently protected\n"); |
| 114 | break; |
| 115 | default: |
| 116 | printf("in reserved protection state\n"); |
| 117 | break; |
| 118 | } |
| 119 | wp >>= 2; |
| 120 | } |
Diego Santa Cruz | 99ca028 | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 121 | } |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 122 | } |
Aswath Govindraju | bb5b9fe | 2021-08-13 23:04:41 +0530 | [diff] [blame] | 123 | |
| 124 | static struct mmc *__init_mmc_device(int dev, bool force_init, |
| 125 | enum bus_mode speed_mode) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 126 | { |
| 127 | struct mmc *mmc; |
| 128 | mmc = find_mmc_device(dev); |
| 129 | if (!mmc) { |
| 130 | printf("no mmc device at slot %x\n", dev); |
| 131 | return NULL; |
| 132 | } |
Eric Nelson | bc18166 | 2016-03-27 12:00:14 -0700 | [diff] [blame] | 133 | |
Marek Vasut | cb5df5d | 2019-01-03 22:09:43 +0100 | [diff] [blame] | 134 | if (!mmc_getcd(mmc)) |
| 135 | force_init = true; |
| 136 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 137 | if (force_init) |
| 138 | mmc->has_init = 0; |
Aswath Govindraju | bb5b9fe | 2021-08-13 23:04:41 +0530 | [diff] [blame] | 139 | |
| 140 | if (IS_ENABLED(CONFIG_MMC_SPEED_MODE_SET)) |
| 141 | mmc->user_speed_mode = speed_mode; |
| 142 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 143 | if (mmc_init(mmc)) |
| 144 | return NULL; |
Marek Vasut | 829540f | 2019-01-03 22:09:44 +0100 | [diff] [blame] | 145 | |
| 146 | #ifdef CONFIG_BLOCK_CACHE |
| 147 | struct blk_desc *bd = mmc_get_blk_desc(mmc); |
| 148 | blkcache_invalidate(bd->if_type, bd->devnum); |
| 149 | #endif |
| 150 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 151 | return mmc; |
| 152 | } |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 153 | |
Aswath Govindraju | bb5b9fe | 2021-08-13 23:04:41 +0530 | [diff] [blame] | 154 | static struct mmc *init_mmc_device(int dev, bool force_init) |
| 155 | { |
| 156 | return __init_mmc_device(dev, force_init, MMC_MODES_END); |
| 157 | } |
| 158 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 159 | static int do_mmcinfo(struct cmd_tbl *cmdtp, int flag, int argc, |
| 160 | char *const argv[]) |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 161 | { |
| 162 | struct mmc *mmc; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 163 | |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 164 | if (curr_device < 0) { |
| 165 | if (get_mmc_num() > 0) |
| 166 | curr_device = 0; |
| 167 | else { |
| 168 | puts("No MMC device available\n"); |
| 169 | return 1; |
| 170 | } |
| 171 | } |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 172 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 173 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 174 | if (!mmc) |
| 175 | return CMD_RET_FAILURE; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 176 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 177 | print_mmcinfo(mmc); |
| 178 | return CMD_RET_SUCCESS; |
| 179 | } |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 180 | |
Alex Kiernan | 60e0f61 | 2018-05-08 04:43:31 +0000 | [diff] [blame] | 181 | #if CONFIG_IS_ENABLED(CMD_MMC_RPMB) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 182 | static int confirm_key_prog(void) |
| 183 | { |
| 184 | puts("Warning: Programming authentication key can be done only once !\n" |
| 185 | " Use this command only if you are sure of what you are doing,\n" |
| 186 | "Really perform the key programming? <y/N> "); |
| 187 | if (confirm_yesno()) |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 188 | return 1; |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 189 | |
| 190 | puts("Authentication key programming aborted\n"); |
| 191 | return 0; |
| 192 | } |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 193 | |
| 194 | static int do_mmcrpmb_key(struct cmd_tbl *cmdtp, int flag, |
| 195 | int argc, char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 196 | { |
| 197 | void *key_addr; |
| 198 | struct mmc *mmc = find_mmc_device(curr_device); |
| 199 | |
| 200 | if (argc != 2) |
| 201 | return CMD_RET_USAGE; |
| 202 | |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 203 | key_addr = (void *)hextoul(argv[1], NULL); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 204 | if (!confirm_key_prog()) |
| 205 | return CMD_RET_FAILURE; |
| 206 | if (mmc_rpmb_set_key(mmc, key_addr)) { |
| 207 | printf("ERROR - Key already programmed ?\n"); |
| 208 | return CMD_RET_FAILURE; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 209 | } |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 210 | return CMD_RET_SUCCESS; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 211 | } |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 212 | |
| 213 | static int do_mmcrpmb_read(struct cmd_tbl *cmdtp, int flag, |
| 214 | int argc, char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 215 | { |
| 216 | u16 blk, cnt; |
| 217 | void *addr; |
| 218 | int n; |
| 219 | void *key_addr = NULL; |
| 220 | struct mmc *mmc = find_mmc_device(curr_device); |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 221 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 222 | if (argc < 4) |
| 223 | return CMD_RET_USAGE; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 224 | |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 225 | addr = (void *)hextoul(argv[1], NULL); |
| 226 | blk = hextoul(argv[2], NULL); |
| 227 | cnt = hextoul(argv[3], NULL); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 228 | |
| 229 | if (argc == 5) |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 230 | key_addr = (void *)hextoul(argv[4], NULL); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 231 | |
| 232 | printf("\nMMC RPMB read: dev # %d, block # %d, count %d ... ", |
| 233 | curr_device, blk, cnt); |
| 234 | n = mmc_rpmb_read(mmc, addr, blk, cnt, key_addr); |
| 235 | |
| 236 | printf("%d RPMB blocks read: %s\n", n, (n == cnt) ? "OK" : "ERROR"); |
| 237 | if (n != cnt) |
| 238 | return CMD_RET_FAILURE; |
| 239 | return CMD_RET_SUCCESS; |
| 240 | } |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 241 | |
| 242 | static int do_mmcrpmb_write(struct cmd_tbl *cmdtp, int flag, |
| 243 | int argc, char *const argv[]) |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 244 | { |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 245 | u16 blk, cnt; |
| 246 | void *addr; |
| 247 | int n; |
| 248 | void *key_addr; |
| 249 | struct mmc *mmc = find_mmc_device(curr_device); |
Lei Wen | 64b2b1e | 2011-06-22 17:03:30 +0000 | [diff] [blame] | 250 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 251 | if (argc != 5) |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 252 | return CMD_RET_USAGE; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 253 | |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 254 | addr = (void *)hextoul(argv[1], NULL); |
| 255 | blk = hextoul(argv[2], NULL); |
| 256 | cnt = hextoul(argv[3], NULL); |
| 257 | key_addr = (void *)hextoul(argv[4], NULL); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 258 | |
| 259 | printf("\nMMC RPMB write: dev # %d, block # %d, count %d ... ", |
| 260 | curr_device, blk, cnt); |
| 261 | n = mmc_rpmb_write(mmc, addr, blk, cnt, key_addr); |
| 262 | |
| 263 | printf("%d RPMB blocks written: %s\n", n, (n == cnt) ? "OK" : "ERROR"); |
| 264 | if (n != cnt) |
| 265 | return CMD_RET_FAILURE; |
| 266 | return CMD_RET_SUCCESS; |
| 267 | } |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 268 | |
| 269 | static int do_mmcrpmb_counter(struct cmd_tbl *cmdtp, int flag, |
| 270 | int argc, char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 271 | { |
| 272 | unsigned long counter; |
| 273 | struct mmc *mmc = find_mmc_device(curr_device); |
| 274 | |
| 275 | if (mmc_rpmb_get_counter(mmc, &counter)) |
| 276 | return CMD_RET_FAILURE; |
| 277 | printf("RPMB Write counter= %lx\n", counter); |
| 278 | return CMD_RET_SUCCESS; |
| 279 | } |
| 280 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 281 | static struct cmd_tbl cmd_rpmb[] = { |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 282 | U_BOOT_CMD_MKENT(key, 2, 0, do_mmcrpmb_key, "", ""), |
| 283 | U_BOOT_CMD_MKENT(read, 5, 1, do_mmcrpmb_read, "", ""), |
| 284 | U_BOOT_CMD_MKENT(write, 5, 0, do_mmcrpmb_write, "", ""), |
| 285 | U_BOOT_CMD_MKENT(counter, 1, 1, do_mmcrpmb_counter, "", ""), |
| 286 | }; |
| 287 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 288 | static int do_mmcrpmb(struct cmd_tbl *cmdtp, int flag, |
| 289 | int argc, char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 290 | { |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 291 | struct cmd_tbl *cp; |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 292 | struct mmc *mmc; |
| 293 | char original_part; |
| 294 | int ret; |
| 295 | |
| 296 | cp = find_cmd_tbl(argv[1], cmd_rpmb, ARRAY_SIZE(cmd_rpmb)); |
| 297 | |
| 298 | /* Drop the rpmb subcommand */ |
| 299 | argc--; |
| 300 | argv++; |
| 301 | |
| 302 | if (cp == NULL || argc > cp->maxargs) |
| 303 | return CMD_RET_USAGE; |
Boris Brezillon | c71dfd1 | 2018-12-03 22:54:20 +0100 | [diff] [blame] | 304 | if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp)) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 305 | return CMD_RET_SUCCESS; |
| 306 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 307 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 308 | if (!mmc) |
| 309 | return CMD_RET_FAILURE; |
| 310 | |
| 311 | if (!(mmc->version & MMC_VERSION_MMC)) { |
Heinrich Schuchardt | eeb191c | 2020-03-29 19:26:57 +0000 | [diff] [blame] | 312 | printf("It is not an eMMC device\n"); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 313 | return CMD_RET_FAILURE; |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 314 | } |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 315 | if (mmc->version < MMC_VERSION_4_41) { |
| 316 | printf("RPMB not supported before version 4.41\n"); |
| 317 | return CMD_RET_FAILURE; |
| 318 | } |
| 319 | /* Switch to the RPMB partition */ |
Kever Yang | cb5f193 | 2017-06-08 09:20:03 +0800 | [diff] [blame] | 320 | #ifndef CONFIG_BLK |
Marek Vasut | a62cf49 | 2016-05-04 16:35:25 +0200 | [diff] [blame] | 321 | original_part = mmc->block_dev.hwpart; |
Kever Yang | cb5f193 | 2017-06-08 09:20:03 +0800 | [diff] [blame] | 322 | #else |
| 323 | original_part = mmc_get_blk_desc(mmc)->hwpart; |
| 324 | #endif |
Simon Glass | 11f2bb6 | 2016-05-01 13:52:29 -0600 | [diff] [blame] | 325 | if (blk_select_hwpart_devnum(IF_TYPE_MMC, curr_device, MMC_PART_RPMB) != |
| 326 | 0) |
Stephen Warren | 1e0f92a | 2015-12-07 11:38:49 -0700 | [diff] [blame] | 327 | return CMD_RET_FAILURE; |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 328 | ret = cp->cmd(cmdtp, flag, argc, argv); |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 329 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 330 | /* Return to original partition */ |
Simon Glass | 11f2bb6 | 2016-05-01 13:52:29 -0600 | [diff] [blame] | 331 | if (blk_select_hwpart_devnum(IF_TYPE_MMC, curr_device, original_part) != |
| 332 | 0) |
Stephen Warren | 1e0f92a | 2015-12-07 11:38:49 -0700 | [diff] [blame] | 333 | return CMD_RET_FAILURE; |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 334 | return ret; |
| 335 | } |
| 336 | #endif |
Rabin Vincent | 3e448aa | 2009-04-05 13:30:53 +0530 | [diff] [blame] | 337 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 338 | static int do_mmc_read(struct cmd_tbl *cmdtp, int flag, |
| 339 | int argc, char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 340 | { |
| 341 | struct mmc *mmc; |
| 342 | u32 blk, cnt, n; |
| 343 | void *addr; |
Stephen Warren | 18faca7 | 2013-04-01 11:50:28 +0000 | [diff] [blame] | 344 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 345 | if (argc != 4) |
| 346 | return CMD_RET_USAGE; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 347 | |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 348 | addr = (void *)hextoul(argv[1], NULL); |
| 349 | blk = hextoul(argv[2], NULL); |
| 350 | cnt = hextoul(argv[3], NULL); |
Lei Wen | 61dba93 | 2010-09-13 22:07:28 +0800 | [diff] [blame] | 351 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 352 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 353 | if (!mmc) |
| 354 | return CMD_RET_FAILURE; |
Lei Wen | 61dba93 | 2010-09-13 22:07:28 +0800 | [diff] [blame] | 355 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 356 | printf("\nMMC read: dev # %d, block # %d, count %d ... ", |
| 357 | curr_device, blk, cnt); |
Stephen Warren | 18faca7 | 2013-04-01 11:50:28 +0000 | [diff] [blame] | 358 | |
Simon Glass | e5db115 | 2016-05-01 13:52:35 -0600 | [diff] [blame] | 359 | n = blk_dread(mmc_get_blk_desc(mmc), blk, cnt, addr); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 360 | printf("%d blocks read: %s\n", n, (n == cnt) ? "OK" : "ERROR"); |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 361 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 362 | return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; |
| 363 | } |
Jean-Jacques Hiblot | 27edffe | 2018-01-04 15:23:34 +0100 | [diff] [blame] | 364 | |
Alex Kiernan | c568bcb | 2018-05-29 15:30:52 +0000 | [diff] [blame] | 365 | #if CONFIG_IS_ENABLED(CMD_MMC_SWRITE) |
Jassi Brar | 814a975 | 2018-04-06 12:05:24 +0530 | [diff] [blame] | 366 | static lbaint_t mmc_sparse_write(struct sparse_storage *info, lbaint_t blk, |
| 367 | lbaint_t blkcnt, const void *buffer) |
| 368 | { |
| 369 | struct blk_desc *dev_desc = info->priv; |
| 370 | |
| 371 | return blk_dwrite(dev_desc, blk, blkcnt, buffer); |
| 372 | } |
| 373 | |
| 374 | static lbaint_t mmc_sparse_reserve(struct sparse_storage *info, |
| 375 | lbaint_t blk, lbaint_t blkcnt) |
| 376 | { |
| 377 | return blkcnt; |
| 378 | } |
| 379 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 380 | static int do_mmc_sparse_write(struct cmd_tbl *cmdtp, int flag, |
| 381 | int argc, char *const argv[]) |
Jassi Brar | 814a975 | 2018-04-06 12:05:24 +0530 | [diff] [blame] | 382 | { |
| 383 | struct sparse_storage sparse; |
| 384 | struct blk_desc *dev_desc; |
| 385 | struct mmc *mmc; |
| 386 | char dest[11]; |
| 387 | void *addr; |
| 388 | u32 blk; |
| 389 | |
| 390 | if (argc != 3) |
| 391 | return CMD_RET_USAGE; |
| 392 | |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 393 | addr = (void *)hextoul(argv[1], NULL); |
| 394 | blk = hextoul(argv[2], NULL); |
Jassi Brar | 814a975 | 2018-04-06 12:05:24 +0530 | [diff] [blame] | 395 | |
| 396 | if (!is_sparse_image(addr)) { |
| 397 | printf("Not a sparse image\n"); |
| 398 | return CMD_RET_FAILURE; |
| 399 | } |
| 400 | |
| 401 | mmc = init_mmc_device(curr_device, false); |
| 402 | if (!mmc) |
| 403 | return CMD_RET_FAILURE; |
| 404 | |
| 405 | printf("\nMMC Sparse write: dev # %d, block # %d ... ", |
| 406 | curr_device, blk); |
| 407 | |
| 408 | if (mmc_getwp(mmc) == 1) { |
| 409 | printf("Error: card is write protected!\n"); |
| 410 | return CMD_RET_FAILURE; |
| 411 | } |
| 412 | |
| 413 | dev_desc = mmc_get_blk_desc(mmc); |
| 414 | sparse.priv = dev_desc; |
| 415 | sparse.blksz = 512; |
| 416 | sparse.start = blk; |
| 417 | sparse.size = dev_desc->lba - blk; |
| 418 | sparse.write = mmc_sparse_write; |
| 419 | sparse.reserve = mmc_sparse_reserve; |
| 420 | sparse.mssg = NULL; |
| 421 | sprintf(dest, "0x" LBAF, sparse.start * sparse.blksz); |
| 422 | |
Alex Kiernan | 27b69de | 2018-05-29 15:30:40 +0000 | [diff] [blame] | 423 | if (write_sparse_image(&sparse, dest, addr, NULL)) |
Jassi Brar | 814a975 | 2018-04-06 12:05:24 +0530 | [diff] [blame] | 424 | return CMD_RET_FAILURE; |
| 425 | else |
| 426 | return CMD_RET_SUCCESS; |
| 427 | } |
| 428 | #endif |
| 429 | |
Alex Kiernan | c568bcb | 2018-05-29 15:30:52 +0000 | [diff] [blame] | 430 | #if CONFIG_IS_ENABLED(MMC_WRITE) |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 431 | static int do_mmc_write(struct cmd_tbl *cmdtp, int flag, |
| 432 | int argc, char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 433 | { |
| 434 | struct mmc *mmc; |
| 435 | u32 blk, cnt, n; |
| 436 | void *addr; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 437 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 438 | if (argc != 4) |
| 439 | return CMD_RET_USAGE; |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 440 | |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 441 | addr = (void *)hextoul(argv[1], NULL); |
| 442 | blk = hextoul(argv[2], NULL); |
| 443 | cnt = hextoul(argv[3], NULL); |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 444 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 445 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 446 | if (!mmc) |
| 447 | return CMD_RET_FAILURE; |
Lei Wen | 31b9980 | 2011-05-02 16:26:26 +0000 | [diff] [blame] | 448 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 449 | printf("\nMMC write: dev # %d, block # %d, count %d ... ", |
| 450 | curr_device, blk, cnt); |
Lei Wen | 31b9980 | 2011-05-02 16:26:26 +0000 | [diff] [blame] | 451 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 452 | if (mmc_getwp(mmc) == 1) { |
| 453 | printf("Error: card is write protected!\n"); |
| 454 | return CMD_RET_FAILURE; |
| 455 | } |
Simon Glass | e5db115 | 2016-05-01 13:52:35 -0600 | [diff] [blame] | 456 | n = blk_dwrite(mmc_get_blk_desc(mmc), blk, cnt, addr); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 457 | printf("%d blocks written: %s\n", n, (n == cnt) ? "OK" : "ERROR"); |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 458 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 459 | return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; |
| 460 | } |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 461 | |
| 462 | static int do_mmc_erase(struct cmd_tbl *cmdtp, int flag, |
| 463 | int argc, char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 464 | { |
| 465 | struct mmc *mmc; |
| 466 | u32 blk, cnt, n; |
Tom Rini | f8c6f79 | 2014-02-05 10:24:21 -0500 | [diff] [blame] | 467 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 468 | if (argc != 3) |
| 469 | return CMD_RET_USAGE; |
Tom Rini | f8c6f79 | 2014-02-05 10:24:21 -0500 | [diff] [blame] | 470 | |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 471 | blk = hextoul(argv[1], NULL); |
| 472 | cnt = hextoul(argv[2], NULL); |
Amar | 3ccad53 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 473 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 474 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 475 | if (!mmc) |
| 476 | return CMD_RET_FAILURE; |
Tom Rini | f8c6f79 | 2014-02-05 10:24:21 -0500 | [diff] [blame] | 477 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 478 | printf("\nMMC erase: dev # %d, block # %d, count %d ... ", |
| 479 | curr_device, blk, cnt); |
Tom Rini | 4cf854c | 2014-02-05 10:24:22 -0500 | [diff] [blame] | 480 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 481 | if (mmc_getwp(mmc) == 1) { |
| 482 | printf("Error: card is write protected!\n"); |
| 483 | return CMD_RET_FAILURE; |
| 484 | } |
Simon Glass | e5db115 | 2016-05-01 13:52:35 -0600 | [diff] [blame] | 485 | n = blk_derase(mmc_get_blk_desc(mmc), blk, cnt); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 486 | printf("%d blocks erased: %s\n", n, (n == cnt) ? "OK" : "ERROR"); |
Tom Rini | 4cf854c | 2014-02-05 10:24:22 -0500 | [diff] [blame] | 487 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 488 | return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; |
| 489 | } |
Jean-Jacques Hiblot | 27edffe | 2018-01-04 15:23:34 +0100 | [diff] [blame] | 490 | #endif |
| 491 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 492 | static int do_mmc_rescan(struct cmd_tbl *cmdtp, int flag, |
| 493 | int argc, char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 494 | { |
| 495 | struct mmc *mmc; |
Aswath Govindraju | bb5b9fe | 2021-08-13 23:04:41 +0530 | [diff] [blame] | 496 | enum bus_mode speed_mode = MMC_MODES_END; |
| 497 | |
| 498 | if (argc == 1) { |
| 499 | mmc = init_mmc_device(curr_device, true); |
| 500 | } else if (argc == 2) { |
| 501 | speed_mode = (int)dectoul(argv[1], NULL); |
| 502 | mmc = __init_mmc_device(curr_device, true, speed_mode); |
| 503 | } else { |
| 504 | return CMD_RET_USAGE; |
| 505 | } |
Tom Rini | 4cf854c | 2014-02-05 10:24:22 -0500 | [diff] [blame] | 506 | |
Stephen Warren | 07ec4e7 | 2014-05-23 13:24:46 -0600 | [diff] [blame] | 507 | if (!mmc) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 508 | return CMD_RET_FAILURE; |
Tom Rini | 4cf854c | 2014-02-05 10:24:22 -0500 | [diff] [blame] | 509 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 510 | return CMD_RET_SUCCESS; |
| 511 | } |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 512 | |
| 513 | static int do_mmc_part(struct cmd_tbl *cmdtp, int flag, |
| 514 | int argc, char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 515 | { |
Simon Glass | e339475 | 2016-02-29 15:25:34 -0700 | [diff] [blame] | 516 | struct blk_desc *mmc_dev; |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 517 | struct mmc *mmc; |
Amar | 3ccad53 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 518 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 519 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 520 | if (!mmc) |
| 521 | return CMD_RET_FAILURE; |
Amar | 3ccad53 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 522 | |
Simon Glass | fa25511 | 2016-05-01 11:36:15 -0600 | [diff] [blame] | 523 | mmc_dev = blk_get_devnum_by_type(IF_TYPE_MMC, curr_device); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 524 | if (mmc_dev != NULL && mmc_dev->type != DEV_TYPE_UNKNOWN) { |
Simon Glass | b89a844 | 2016-02-29 15:25:48 -0700 | [diff] [blame] | 525 | part_print(mmc_dev); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 526 | return CMD_RET_SUCCESS; |
| 527 | } |
Amar | 3ccad53 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 528 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 529 | puts("get mmc type error!\n"); |
| 530 | return CMD_RET_FAILURE; |
| 531 | } |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 532 | |
| 533 | static int do_mmc_dev(struct cmd_tbl *cmdtp, int flag, |
| 534 | int argc, char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 535 | { |
Stephen Warren | 1854980 | 2014-05-23 12:48:10 -0600 | [diff] [blame] | 536 | int dev, part = 0, ret; |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 537 | struct mmc *mmc; |
Aswath Govindraju | bb5b9fe | 2021-08-13 23:04:41 +0530 | [diff] [blame] | 538 | enum bus_mode speed_mode = MMC_MODES_END; |
Tom Rini | 35a3ea1 | 2014-02-07 14:15:20 -0500 | [diff] [blame] | 539 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 540 | if (argc == 1) { |
| 541 | dev = curr_device; |
Aswath Govindraju | bb5b9fe | 2021-08-13 23:04:41 +0530 | [diff] [blame] | 542 | mmc = init_mmc_device(dev, true); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 543 | } else if (argc == 2) { |
Aswath Govindraju | bb5b9fe | 2021-08-13 23:04:41 +0530 | [diff] [blame] | 544 | dev = (int)dectoul(argv[1], NULL); |
| 545 | mmc = init_mmc_device(dev, true); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 546 | } else if (argc == 3) { |
Simon Glass | ff9b903 | 2021-07-24 09:03:30 -0600 | [diff] [blame] | 547 | dev = (int)dectoul(argv[1], NULL); |
| 548 | part = (int)dectoul(argv[2], NULL); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 549 | if (part > PART_ACCESS_MASK) { |
| 550 | printf("#part_num shouldn't be larger than %d\n", |
| 551 | PART_ACCESS_MASK); |
| 552 | return CMD_RET_FAILURE; |
Tom Rini | 35a3ea1 | 2014-02-07 14:15:20 -0500 | [diff] [blame] | 553 | } |
Aswath Govindraju | bb5b9fe | 2021-08-13 23:04:41 +0530 | [diff] [blame] | 554 | mmc = init_mmc_device(dev, true); |
| 555 | } else if (argc == 4) { |
| 556 | dev = (int)dectoul(argv[1], NULL); |
| 557 | part = (int)dectoul(argv[2], NULL); |
| 558 | if (part > PART_ACCESS_MASK) { |
| 559 | printf("#part_num shouldn't be larger than %d\n", |
| 560 | PART_ACCESS_MASK); |
| 561 | return CMD_RET_FAILURE; |
| 562 | } |
| 563 | speed_mode = (int)dectoul(argv[3], NULL); |
| 564 | mmc = __init_mmc_device(dev, true, speed_mode); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 565 | } else { |
| 566 | return CMD_RET_USAGE; |
| 567 | } |
Tom Rini | 35a3ea1 | 2014-02-07 14:15:20 -0500 | [diff] [blame] | 568 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 569 | if (!mmc) |
| 570 | return CMD_RET_FAILURE; |
Tom Rini | 35a3ea1 | 2014-02-07 14:15:20 -0500 | [diff] [blame] | 571 | |
Simon Glass | 11f2bb6 | 2016-05-01 13:52:29 -0600 | [diff] [blame] | 572 | ret = blk_select_hwpart_devnum(IF_TYPE_MMC, dev, part); |
Stephen Warren | 1854980 | 2014-05-23 12:48:10 -0600 | [diff] [blame] | 573 | printf("switch to partitions #%d, %s\n", |
| 574 | part, (!ret) ? "OK" : "ERROR"); |
| 575 | if (ret) |
| 576 | return 1; |
| 577 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 578 | curr_device = dev; |
| 579 | if (mmc->part_config == MMCPART_NOAVAILABLE) |
| 580 | printf("mmc%d is current device\n", curr_device); |
| 581 | else |
| 582 | printf("mmc%d(part %d) is current device\n", |
Simon Glass | e5db115 | 2016-05-01 13:52:35 -0600 | [diff] [blame] | 583 | curr_device, mmc_get_blk_desc(mmc)->hwpart); |
Tom Rini | 35a3ea1 | 2014-02-07 14:15:20 -0500 | [diff] [blame] | 584 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 585 | return CMD_RET_SUCCESS; |
| 586 | } |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 587 | |
| 588 | static int do_mmc_list(struct cmd_tbl *cmdtp, int flag, |
| 589 | int argc, char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 590 | { |
| 591 | print_mmc_devices('\n'); |
| 592 | return CMD_RET_SUCCESS; |
| 593 | } |
Diego Santa Cruz | 420fc16 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 594 | |
Jean-Jacques Hiblot | 1d7769a | 2017-11-30 17:44:02 +0100 | [diff] [blame] | 595 | #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING) |
Marek Vasut | 94e3995 | 2021-09-15 11:43:13 +0200 | [diff] [blame] | 596 | static void parse_hwpart_user_enh_size(struct mmc *mmc, |
| 597 | struct mmc_hwpart_conf *pconf, |
| 598 | char *argv) |
| 599 | { |
Marek Vasut | 30d2966 | 2022-01-17 22:54:29 +0100 | [diff] [blame] | 600 | int i, ret; |
Marek Vasut | 94e3995 | 2021-09-15 11:43:13 +0200 | [diff] [blame] | 601 | |
| 602 | pconf->user.enh_size = 0; |
| 603 | |
| 604 | if (!strcmp(argv, "-")) { /* The rest of eMMC */ |
| 605 | ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, MMC_MAX_BLOCK_LEN); |
| 606 | ret = mmc_send_ext_csd(mmc, ext_csd); |
| 607 | if (ret) |
| 608 | return; |
Marek Vasut | 30d2966 | 2022-01-17 22:54:29 +0100 | [diff] [blame] | 609 | /* The enh_size value is in 512B block units */ |
Marek Vasut | 94e3995 | 2021-09-15 11:43:13 +0200 | [diff] [blame] | 610 | pconf->user.enh_size = |
| 611 | ((ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT + 2] << 16) + |
| 612 | (ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT + 1] << 8) + |
| 613 | ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT]) * 1024 * |
| 614 | ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] * |
| 615 | ext_csd[EXT_CSD_HC_WP_GRP_SIZE]; |
| 616 | pconf->user.enh_size -= pconf->user.enh_start; |
Marek Vasut | 30d2966 | 2022-01-17 22:54:29 +0100 | [diff] [blame] | 617 | for (i = 0; i < ARRAY_SIZE(mmc->capacity_gp); i++) { |
| 618 | /* |
| 619 | * If the eMMC already has GP partitions set, |
| 620 | * subtract their size from the maximum USER |
| 621 | * partition size. |
| 622 | * |
| 623 | * Else, if the command was used to configure new |
| 624 | * GP partitions, subtract their size from maximum |
| 625 | * USER partition size. |
| 626 | */ |
| 627 | if (mmc->capacity_gp[i]) { |
| 628 | /* The capacity_gp is in 1B units */ |
| 629 | pconf->user.enh_size -= mmc->capacity_gp[i] >> 9; |
| 630 | } else if (pconf->gp_part[i].size) { |
| 631 | /* The gp_part[].size is in 512B units */ |
| 632 | pconf->user.enh_size -= pconf->gp_part[i].size; |
| 633 | } |
| 634 | } |
Marek Vasut | 94e3995 | 2021-09-15 11:43:13 +0200 | [diff] [blame] | 635 | } else { |
| 636 | pconf->user.enh_size = dectoul(argv, NULL); |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | static int parse_hwpart_user(struct mmc *mmc, struct mmc_hwpart_conf *pconf, |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 641 | int argc, char *const argv[]) |
Diego Santa Cruz | 58bda79 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 642 | { |
| 643 | int i = 0; |
| 644 | |
| 645 | memset(&pconf->user, 0, sizeof(pconf->user)); |
| 646 | |
| 647 | while (i < argc) { |
| 648 | if (!strcmp(argv[i], "enh")) { |
| 649 | if (i + 2 >= argc) |
| 650 | return -1; |
| 651 | pconf->user.enh_start = |
Simon Glass | ff9b903 | 2021-07-24 09:03:30 -0600 | [diff] [blame] | 652 | dectoul(argv[i + 1], NULL); |
Marek Vasut | 94e3995 | 2021-09-15 11:43:13 +0200 | [diff] [blame] | 653 | parse_hwpart_user_enh_size(mmc, pconf, argv[i + 2]); |
Diego Santa Cruz | 58bda79 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 654 | i += 3; |
| 655 | } else if (!strcmp(argv[i], "wrrel")) { |
| 656 | if (i + 1 >= argc) |
| 657 | return -1; |
| 658 | pconf->user.wr_rel_change = 1; |
| 659 | if (!strcmp(argv[i+1], "on")) |
| 660 | pconf->user.wr_rel_set = 1; |
| 661 | else if (!strcmp(argv[i+1], "off")) |
| 662 | pconf->user.wr_rel_set = 0; |
| 663 | else |
| 664 | return -1; |
| 665 | i += 2; |
| 666 | } else { |
| 667 | break; |
| 668 | } |
| 669 | } |
| 670 | return i; |
| 671 | } |
| 672 | |
| 673 | static int parse_hwpart_gp(struct mmc_hwpart_conf *pconf, int pidx, |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 674 | int argc, char *const argv[]) |
Diego Santa Cruz | 58bda79 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 675 | { |
| 676 | int i; |
| 677 | |
| 678 | memset(&pconf->gp_part[pidx], 0, sizeof(pconf->gp_part[pidx])); |
| 679 | |
| 680 | if (1 >= argc) |
| 681 | return -1; |
Simon Glass | ff9b903 | 2021-07-24 09:03:30 -0600 | [diff] [blame] | 682 | pconf->gp_part[pidx].size = dectoul(argv[0], NULL); |
Diego Santa Cruz | 58bda79 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 683 | |
| 684 | i = 1; |
| 685 | while (i < argc) { |
| 686 | if (!strcmp(argv[i], "enh")) { |
| 687 | pconf->gp_part[pidx].enhanced = 1; |
| 688 | i += 1; |
| 689 | } else if (!strcmp(argv[i], "wrrel")) { |
| 690 | if (i + 1 >= argc) |
| 691 | return -1; |
| 692 | pconf->gp_part[pidx].wr_rel_change = 1; |
| 693 | if (!strcmp(argv[i+1], "on")) |
| 694 | pconf->gp_part[pidx].wr_rel_set = 1; |
| 695 | else if (!strcmp(argv[i+1], "off")) |
| 696 | pconf->gp_part[pidx].wr_rel_set = 0; |
| 697 | else |
| 698 | return -1; |
| 699 | i += 2; |
| 700 | } else { |
| 701 | break; |
| 702 | } |
| 703 | } |
| 704 | return i; |
| 705 | } |
| 706 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 707 | static int do_mmc_hwpartition(struct cmd_tbl *cmdtp, int flag, |
| 708 | int argc, char *const argv[]) |
Diego Santa Cruz | 420fc16 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 709 | { |
| 710 | struct mmc *mmc; |
| 711 | struct mmc_hwpart_conf pconf = { }; |
| 712 | enum mmc_hwpart_conf_mode mode = MMC_HWPART_CONF_CHECK; |
Diego Santa Cruz | 58bda79 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 713 | int i, r, pidx; |
Diego Santa Cruz | 420fc16 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 714 | |
| 715 | mmc = init_mmc_device(curr_device, false); |
| 716 | if (!mmc) |
| 717 | return CMD_RET_FAILURE; |
| 718 | |
Jaehoon Chung | ffbba62 | 2021-09-24 09:23:34 +0900 | [diff] [blame] | 719 | if (IS_SD(mmc)) { |
| 720 | puts("SD doesn't support partitioning\n"); |
| 721 | return CMD_RET_FAILURE; |
| 722 | } |
| 723 | |
Diego Santa Cruz | 420fc16 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 724 | if (argc < 1) |
| 725 | return CMD_RET_USAGE; |
| 726 | i = 1; |
| 727 | while (i < argc) { |
Diego Santa Cruz | 58bda79 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 728 | if (!strcmp(argv[i], "user")) { |
| 729 | i++; |
Marek Vasut | 94e3995 | 2021-09-15 11:43:13 +0200 | [diff] [blame] | 730 | r = parse_hwpart_user(mmc, &pconf, argc - i, &argv[i]); |
Diego Santa Cruz | 58bda79 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 731 | if (r < 0) |
Diego Santa Cruz | 420fc16 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 732 | return CMD_RET_USAGE; |
Diego Santa Cruz | 58bda79 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 733 | i += r; |
Diego Santa Cruz | 420fc16 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 734 | } else if (!strncmp(argv[i], "gp", 2) && |
| 735 | strlen(argv[i]) == 3 && |
| 736 | argv[i][2] >= '1' && argv[i][2] <= '4') { |
Diego Santa Cruz | 420fc16 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 737 | pidx = argv[i][2] - '1'; |
Diego Santa Cruz | 58bda79 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 738 | i++; |
| 739 | r = parse_hwpart_gp(&pconf, pidx, argc-i, &argv[i]); |
| 740 | if (r < 0) |
| 741 | return CMD_RET_USAGE; |
| 742 | i += r; |
Diego Santa Cruz | 420fc16 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 743 | } else if (!strcmp(argv[i], "check")) { |
| 744 | mode = MMC_HWPART_CONF_CHECK; |
| 745 | i++; |
| 746 | } else if (!strcmp(argv[i], "set")) { |
| 747 | mode = MMC_HWPART_CONF_SET; |
| 748 | i++; |
| 749 | } else if (!strcmp(argv[i], "complete")) { |
| 750 | mode = MMC_HWPART_CONF_COMPLETE; |
| 751 | i++; |
| 752 | } else { |
| 753 | return CMD_RET_USAGE; |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | puts("Partition configuration:\n"); |
| 758 | if (pconf.user.enh_size) { |
| 759 | puts("\tUser Enhanced Start: "); |
| 760 | print_size(((u64)pconf.user.enh_start) << 9, "\n"); |
| 761 | puts("\tUser Enhanced Size: "); |
| 762 | print_size(((u64)pconf.user.enh_size) << 9, "\n"); |
| 763 | } else { |
| 764 | puts("\tNo enhanced user data area\n"); |
| 765 | } |
Diego Santa Cruz | 58bda79 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 766 | if (pconf.user.wr_rel_change) |
| 767 | printf("\tUser partition write reliability: %s\n", |
| 768 | pconf.user.wr_rel_set ? "on" : "off"); |
Diego Santa Cruz | 420fc16 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 769 | for (pidx = 0; pidx < 4; pidx++) { |
| 770 | if (pconf.gp_part[pidx].size) { |
| 771 | printf("\tGP%i Capacity: ", pidx+1); |
| 772 | print_size(((u64)pconf.gp_part[pidx].size) << 9, |
| 773 | pconf.gp_part[pidx].enhanced ? |
| 774 | " ENH\n" : "\n"); |
| 775 | } else { |
| 776 | printf("\tNo GP%i partition\n", pidx+1); |
| 777 | } |
Diego Santa Cruz | 58bda79 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 778 | if (pconf.gp_part[pidx].wr_rel_change) |
| 779 | printf("\tGP%i write reliability: %s\n", pidx+1, |
| 780 | pconf.gp_part[pidx].wr_rel_set ? "on" : "off"); |
Diego Santa Cruz | 420fc16 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 781 | } |
| 782 | |
| 783 | if (!mmc_hwpart_config(mmc, &pconf, mode)) { |
| 784 | if (mode == MMC_HWPART_CONF_COMPLETE) |
| 785 | puts("Partitioning successful, " |
| 786 | "power-cycle to make effective\n"); |
| 787 | return CMD_RET_SUCCESS; |
| 788 | } else { |
Diego Santa Cruz | 58bda79 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 789 | puts("Failed!\n"); |
Diego Santa Cruz | 420fc16 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 790 | return CMD_RET_FAILURE; |
| 791 | } |
| 792 | } |
Jean-Jacques Hiblot | 1d7769a | 2017-11-30 17:44:02 +0100 | [diff] [blame] | 793 | #endif |
Diego Santa Cruz | 420fc16 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 794 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 795 | #ifdef CONFIG_SUPPORT_EMMC_BOOT |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 796 | static int do_mmc_bootbus(struct cmd_tbl *cmdtp, int flag, |
| 797 | int argc, char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 798 | { |
| 799 | int dev; |
| 800 | struct mmc *mmc; |
| 801 | u8 width, reset, mode; |
| 802 | |
| 803 | if (argc != 5) |
| 804 | return CMD_RET_USAGE; |
Simon Glass | ff9b903 | 2021-07-24 09:03:30 -0600 | [diff] [blame] | 805 | dev = dectoul(argv[1], NULL); |
| 806 | width = dectoul(argv[2], NULL); |
| 807 | reset = dectoul(argv[3], NULL); |
| 808 | mode = dectoul(argv[4], NULL); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 809 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 810 | mmc = init_mmc_device(dev, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 811 | if (!mmc) |
| 812 | return CMD_RET_FAILURE; |
| 813 | |
| 814 | if (IS_SD(mmc)) { |
| 815 | puts("BOOT_BUS_WIDTH only exists on eMMC\n"); |
| 816 | return CMD_RET_FAILURE; |
Amar | 3ccad53 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 817 | } |
Markus Niebel | 0395141 | 2013-12-16 13:40:46 +0100 | [diff] [blame] | 818 | |
Jaehoon Chung | 7483dd3 | 2021-02-26 18:38:20 +0900 | [diff] [blame] | 819 | /* |
| 820 | * BOOT_BUS_CONDITIONS[177] |
| 821 | * BOOT_MODE[4:3] |
| 822 | * 0x0 : Use SDR + Backward compatible timing in boot operation |
| 823 | * 0x1 : Use SDR + High Speed Timing in boot operation mode |
| 824 | * 0x2 : Use DDR in boot operation |
| 825 | * RESET_BOOT_BUS_CONDITIONS |
| 826 | * 0x0 : Reset bus width to x1, SDR, Backward compatible |
| 827 | * 0x1 : Retain BOOT_BUS_WIDTH and BOOT_MODE |
| 828 | * BOOT_BUS_WIDTH |
| 829 | * 0x0 : x1(sdr) or x4 (ddr) buswidth |
| 830 | * 0x1 : x4(sdr/ddr) buswith |
| 831 | * 0x2 : x8(sdr/ddr) buswith |
| 832 | * |
| 833 | */ |
| 834 | if (width >= 0x3) { |
| 835 | printf("boot_bus_width %d is invalid\n", width); |
| 836 | return CMD_RET_FAILURE; |
| 837 | } |
| 838 | |
| 839 | if (reset >= 0x2) { |
| 840 | printf("reset_boot_bus_width %d is invalid\n", reset); |
| 841 | return CMD_RET_FAILURE; |
| 842 | } |
| 843 | |
| 844 | if (mode >= 0x3) { |
| 845 | printf("reset_boot_bus_width %d is invalid\n", mode); |
| 846 | return CMD_RET_FAILURE; |
| 847 | } |
| 848 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 849 | /* acknowledge to be sent during boot operation */ |
Jaehoon Chung | 7483dd3 | 2021-02-26 18:38:20 +0900 | [diff] [blame] | 850 | if (mmc_set_boot_bus_width(mmc, width, reset, mode)) { |
| 851 | puts("BOOT_BUS_WIDTH is failed to change.\n"); |
| 852 | return CMD_RET_FAILURE; |
| 853 | } |
| 854 | |
| 855 | printf("Set to BOOT_BUS_WIDTH = 0x%x, RESET = 0x%x, BOOT_MODE = 0x%x\n", |
| 856 | width, reset, mode); |
| 857 | return CMD_RET_SUCCESS; |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 858 | } |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 859 | |
| 860 | static int do_mmc_boot_resize(struct cmd_tbl *cmdtp, int flag, |
| 861 | int argc, char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 862 | { |
| 863 | int dev; |
| 864 | struct mmc *mmc; |
| 865 | u32 bootsize, rpmbsize; |
Markus Niebel | 0395141 | 2013-12-16 13:40:46 +0100 | [diff] [blame] | 866 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 867 | if (argc != 4) |
| 868 | return CMD_RET_USAGE; |
Simon Glass | ff9b903 | 2021-07-24 09:03:30 -0600 | [diff] [blame] | 869 | dev = dectoul(argv[1], NULL); |
| 870 | bootsize = dectoul(argv[2], NULL); |
| 871 | rpmbsize = dectoul(argv[3], NULL); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 872 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 873 | mmc = init_mmc_device(dev, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 874 | if (!mmc) |
| 875 | return CMD_RET_FAILURE; |
| 876 | |
| 877 | if (IS_SD(mmc)) { |
Heinrich Schuchardt | eeb191c | 2020-03-29 19:26:57 +0000 | [diff] [blame] | 878 | printf("It is not an eMMC device\n"); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 879 | return CMD_RET_FAILURE; |
Markus Niebel | 0395141 | 2013-12-16 13:40:46 +0100 | [diff] [blame] | 880 | } |
| 881 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 882 | if (mmc_boot_partition_size_change(mmc, bootsize, rpmbsize)) { |
| 883 | printf("EMMC boot partition Size change Failed.\n"); |
| 884 | return CMD_RET_FAILURE; |
| 885 | } |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 886 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 887 | printf("EMMC boot partition Size %d MB\n", bootsize); |
| 888 | printf("EMMC RPMB partition Size %d MB\n", rpmbsize); |
| 889 | return CMD_RET_SUCCESS; |
| 890 | } |
Angelo Dureghello | f54f753 | 2017-08-01 14:27:10 +0200 | [diff] [blame] | 891 | |
Reuben Dowle | 55a81ad | 2021-05-14 10:15:43 +1200 | [diff] [blame] | 892 | static int mmc_partconf_print(struct mmc *mmc, const char *varname) |
Angelo Dureghello | f54f753 | 2017-08-01 14:27:10 +0200 | [diff] [blame] | 893 | { |
| 894 | u8 ack, access, part; |
| 895 | |
| 896 | if (mmc->part_config == MMCPART_NOAVAILABLE) { |
| 897 | printf("No part_config info for ver. 0x%x\n", mmc->version); |
| 898 | return CMD_RET_FAILURE; |
| 899 | } |
| 900 | |
| 901 | access = EXT_CSD_EXTRACT_PARTITION_ACCESS(mmc->part_config); |
| 902 | ack = EXT_CSD_EXTRACT_BOOT_ACK(mmc->part_config); |
| 903 | part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config); |
| 904 | |
Reuben Dowle | 55a81ad | 2021-05-14 10:15:43 +1200 | [diff] [blame] | 905 | if(varname) |
| 906 | env_set_hex(varname, part); |
| 907 | |
Angelo Dureghello | f54f753 | 2017-08-01 14:27:10 +0200 | [diff] [blame] | 908 | printf("EXT_CSD[179], PARTITION_CONFIG:\n" |
| 909 | "BOOT_ACK: 0x%x\n" |
| 910 | "BOOT_PARTITION_ENABLE: 0x%x\n" |
| 911 | "PARTITION_ACCESS: 0x%x\n", ack, part, access); |
| 912 | |
| 913 | return CMD_RET_SUCCESS; |
| 914 | } |
| 915 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 916 | static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag, |
| 917 | int argc, char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 918 | { |
| 919 | int dev; |
| 920 | struct mmc *mmc; |
| 921 | u8 ack, part_num, access; |
Lei Wen | ea52676 | 2011-06-22 17:03:31 +0000 | [diff] [blame] | 922 | |
Reuben Dowle | 55a81ad | 2021-05-14 10:15:43 +1200 | [diff] [blame] | 923 | if (argc != 2 && argc != 3 && argc != 5) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 924 | return CMD_RET_USAGE; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 925 | |
Simon Glass | ff9b903 | 2021-07-24 09:03:30 -0600 | [diff] [blame] | 926 | dev = dectoul(argv[1], NULL); |
Rabin Vincent | 3e448aa | 2009-04-05 13:30:53 +0530 | [diff] [blame] | 927 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 928 | mmc = init_mmc_device(dev, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 929 | if (!mmc) |
| 930 | return CMD_RET_FAILURE; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 931 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 932 | if (IS_SD(mmc)) { |
| 933 | puts("PARTITION_CONFIG only exists on eMMC\n"); |
| 934 | return CMD_RET_FAILURE; |
| 935 | } |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 936 | |
Reuben Dowle | 55a81ad | 2021-05-14 10:15:43 +1200 | [diff] [blame] | 937 | if (argc == 2 || argc == 3) |
| 938 | return mmc_partconf_print(mmc, argc == 3 ? argv[2] : NULL); |
Angelo Dureghello | f54f753 | 2017-08-01 14:27:10 +0200 | [diff] [blame] | 939 | |
Simon Glass | ff9b903 | 2021-07-24 09:03:30 -0600 | [diff] [blame] | 940 | ack = dectoul(argv[2], NULL); |
| 941 | part_num = dectoul(argv[3], NULL); |
| 942 | access = dectoul(argv[4], NULL); |
Angelo Dureghello | f54f753 | 2017-08-01 14:27:10 +0200 | [diff] [blame] | 943 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 944 | /* acknowledge to be sent during boot operation */ |
| 945 | return mmc_set_part_conf(mmc, ack, part_num, access); |
| 946 | } |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 947 | |
| 948 | static int do_mmc_rst_func(struct cmd_tbl *cmdtp, int flag, |
| 949 | int argc, char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 950 | { |
| 951 | int dev; |
| 952 | struct mmc *mmc; |
| 953 | u8 enable; |
Nikita Kiryanov | 020f261 | 2012-12-03 02:19:46 +0000 | [diff] [blame] | 954 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 955 | /* |
| 956 | * Set the RST_n_ENABLE bit of RST_n_FUNCTION |
| 957 | * The only valid values are 0x0, 0x1 and 0x2 and writing |
| 958 | * a value of 0x1 or 0x2 sets the value permanently. |
| 959 | */ |
| 960 | if (argc != 3) |
| 961 | return CMD_RET_USAGE; |
| 962 | |
Simon Glass | ff9b903 | 2021-07-24 09:03:30 -0600 | [diff] [blame] | 963 | dev = dectoul(argv[1], NULL); |
| 964 | enable = dectoul(argv[2], NULL); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 965 | |
Peng Fan | b1e455a | 2015-11-25 17:16:21 +0800 | [diff] [blame] | 966 | if (enable > 2) { |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 967 | puts("Invalid RST_n_ENABLE value\n"); |
| 968 | return CMD_RET_USAGE; |
| 969 | } |
| 970 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 971 | mmc = init_mmc_device(dev, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 972 | if (!mmc) |
| 973 | return CMD_RET_FAILURE; |
| 974 | |
| 975 | if (IS_SD(mmc)) { |
| 976 | puts("RST_n_FUNCTION only exists on eMMC\n"); |
| 977 | return CMD_RET_FAILURE; |
| 978 | } |
| 979 | |
| 980 | return mmc_set_rst_n_function(mmc, enable); |
| 981 | } |
| 982 | #endif |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 983 | static int do_mmc_setdsr(struct cmd_tbl *cmdtp, int flag, |
| 984 | int argc, char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 985 | { |
| 986 | struct mmc *mmc; |
| 987 | u32 val; |
| 988 | int ret; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 989 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 990 | if (argc != 2) |
| 991 | return CMD_RET_USAGE; |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 992 | val = hextoul(argv[1], NULL); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 993 | |
| 994 | mmc = find_mmc_device(curr_device); |
| 995 | if (!mmc) { |
| 996 | printf("no mmc device at slot %x\n", curr_device); |
| 997 | return CMD_RET_FAILURE; |
| 998 | } |
| 999 | ret = mmc_set_dsr(mmc, val); |
| 1000 | printf("set dsr %s\n", (!ret) ? "OK, force rescan" : "ERROR"); |
| 1001 | if (!ret) { |
| 1002 | mmc->has_init = 0; |
| 1003 | if (mmc_init(mmc)) |
| 1004 | return CMD_RET_FAILURE; |
| 1005 | else |
| 1006 | return CMD_RET_SUCCESS; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 1007 | } |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1008 | return ret; |
| 1009 | } |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 1010 | |
Tomas Melin | c17dae5 | 2016-11-25 11:01:03 +0200 | [diff] [blame] | 1011 | #ifdef CONFIG_CMD_BKOPS_ENABLE |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 1012 | static int do_mmc_bkops_enable(struct cmd_tbl *cmdtp, int flag, |
| 1013 | int argc, char *const argv[]) |
Tomas Melin | c17dae5 | 2016-11-25 11:01:03 +0200 | [diff] [blame] | 1014 | { |
| 1015 | int dev; |
| 1016 | struct mmc *mmc; |
| 1017 | |
| 1018 | if (argc != 2) |
| 1019 | return CMD_RET_USAGE; |
| 1020 | |
Simon Glass | ff9b903 | 2021-07-24 09:03:30 -0600 | [diff] [blame] | 1021 | dev = dectoul(argv[1], NULL); |
Tomas Melin | c17dae5 | 2016-11-25 11:01:03 +0200 | [diff] [blame] | 1022 | |
| 1023 | mmc = init_mmc_device(dev, false); |
| 1024 | if (!mmc) |
| 1025 | return CMD_RET_FAILURE; |
| 1026 | |
| 1027 | if (IS_SD(mmc)) { |
| 1028 | puts("BKOPS_EN only exists on eMMC\n"); |
| 1029 | return CMD_RET_FAILURE; |
| 1030 | } |
| 1031 | |
| 1032 | return mmc_set_bkops_enable(mmc); |
| 1033 | } |
| 1034 | #endif |
| 1035 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 1036 | static int do_mmc_boot_wp(struct cmd_tbl *cmdtp, int flag, |
Heinrich Schuchardt | 75e5a64 | 2020-03-30 07:24:19 +0200 | [diff] [blame] | 1037 | int argc, char * const argv[]) |
| 1038 | { |
| 1039 | int err; |
| 1040 | struct mmc *mmc; |
| 1041 | |
| 1042 | mmc = init_mmc_device(curr_device, false); |
| 1043 | if (!mmc) |
| 1044 | return CMD_RET_FAILURE; |
| 1045 | if (IS_SD(mmc)) { |
| 1046 | printf("It is not an eMMC device\n"); |
| 1047 | return CMD_RET_FAILURE; |
| 1048 | } |
| 1049 | err = mmc_boot_wp(mmc); |
| 1050 | if (err) |
| 1051 | return CMD_RET_FAILURE; |
| 1052 | printf("boot areas protected\n"); |
| 1053 | return CMD_RET_SUCCESS; |
| 1054 | } |
| 1055 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 1056 | static struct cmd_tbl cmd_mmc[] = { |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1057 | U_BOOT_CMD_MKENT(info, 1, 0, do_mmcinfo, "", ""), |
| 1058 | U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""), |
Heinrich Schuchardt | 75e5a64 | 2020-03-30 07:24:19 +0200 | [diff] [blame] | 1059 | U_BOOT_CMD_MKENT(wp, 1, 0, do_mmc_boot_wp, "", ""), |
Jean-Jacques Hiblot | 27edffe | 2018-01-04 15:23:34 +0100 | [diff] [blame] | 1060 | #if CONFIG_IS_ENABLED(MMC_WRITE) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1061 | U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""), |
| 1062 | U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""), |
Jean-Jacques Hiblot | 27edffe | 2018-01-04 15:23:34 +0100 | [diff] [blame] | 1063 | #endif |
Alex Kiernan | c568bcb | 2018-05-29 15:30:52 +0000 | [diff] [blame] | 1064 | #if CONFIG_IS_ENABLED(CMD_MMC_SWRITE) |
| 1065 | U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""), |
| 1066 | #endif |
Aswath Govindraju | bb5b9fe | 2021-08-13 23:04:41 +0530 | [diff] [blame] | 1067 | U_BOOT_CMD_MKENT(rescan, 2, 1, do_mmc_rescan, "", ""), |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1068 | U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""), |
Aswath Govindraju | bb5b9fe | 2021-08-13 23:04:41 +0530 | [diff] [blame] | 1069 | U_BOOT_CMD_MKENT(dev, 4, 0, do_mmc_dev, "", ""), |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1070 | U_BOOT_CMD_MKENT(list, 1, 1, do_mmc_list, "", ""), |
Jean-Jacques Hiblot | 1d7769a | 2017-11-30 17:44:02 +0100 | [diff] [blame] | 1071 | #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING) |
Diego Santa Cruz | 58bda79 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 1072 | U_BOOT_CMD_MKENT(hwpartition, 28, 0, do_mmc_hwpartition, "", ""), |
Jean-Jacques Hiblot | 1d7769a | 2017-11-30 17:44:02 +0100 | [diff] [blame] | 1073 | #endif |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1074 | #ifdef CONFIG_SUPPORT_EMMC_BOOT |
| 1075 | U_BOOT_CMD_MKENT(bootbus, 5, 0, do_mmc_bootbus, "", ""), |
Wally Yeh | d49c4aa | 2014-09-25 23:00:16 +0800 | [diff] [blame] | 1076 | U_BOOT_CMD_MKENT(bootpart-resize, 4, 0, do_mmc_boot_resize, "", ""), |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1077 | U_BOOT_CMD_MKENT(partconf, 5, 0, do_mmc_partconf, "", ""), |
| 1078 | U_BOOT_CMD_MKENT(rst-function, 3, 0, do_mmc_rst_func, "", ""), |
| 1079 | #endif |
Alex Kiernan | 60e0f61 | 2018-05-08 04:43:31 +0000 | [diff] [blame] | 1080 | #if CONFIG_IS_ENABLED(CMD_MMC_RPMB) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1081 | U_BOOT_CMD_MKENT(rpmb, CONFIG_SYS_MAXARGS, 1, do_mmcrpmb, "", ""), |
| 1082 | #endif |
| 1083 | U_BOOT_CMD_MKENT(setdsr, 2, 0, do_mmc_setdsr, "", ""), |
Tomas Melin | c17dae5 | 2016-11-25 11:01:03 +0200 | [diff] [blame] | 1084 | #ifdef CONFIG_CMD_BKOPS_ENABLE |
| 1085 | U_BOOT_CMD_MKENT(bkops-enable, 2, 0, do_mmc_bkops_enable, "", ""), |
| 1086 | #endif |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1087 | }; |
| 1088 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 1089 | static int do_mmcops(struct cmd_tbl *cmdtp, int flag, int argc, |
| 1090 | char *const argv[]) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1091 | { |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 1092 | struct cmd_tbl *cp; |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1093 | |
| 1094 | cp = find_cmd_tbl(argv[1], cmd_mmc, ARRAY_SIZE(cmd_mmc)); |
| 1095 | |
| 1096 | /* Drop the mmc command */ |
| 1097 | argc--; |
| 1098 | argv++; |
| 1099 | |
| 1100 | if (cp == NULL || argc > cp->maxargs) |
| 1101 | return CMD_RET_USAGE; |
Boris Brezillon | c71dfd1 | 2018-12-03 22:54:20 +0100 | [diff] [blame] | 1102 | if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp)) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1103 | return CMD_RET_SUCCESS; |
| 1104 | |
| 1105 | if (curr_device < 0) { |
| 1106 | if (get_mmc_num() > 0) { |
| 1107 | curr_device = 0; |
| 1108 | } else { |
| 1109 | puts("No MMC device available\n"); |
| 1110 | return CMD_RET_FAILURE; |
| 1111 | } |
| 1112 | } |
| 1113 | return cp->cmd(cmdtp, flag, argc, argv); |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 1114 | } |
| 1115 | |
| 1116 | U_BOOT_CMD( |
Diego Santa Cruz | 58bda79 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 1117 | mmc, 29, 1, do_mmcops, |
Mike Frysinger | 27e1e62 | 2009-03-23 22:27:34 -0400 | [diff] [blame] | 1118 | "MMC sub system", |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1119 | "info - display info of the current MMC device\n" |
| 1120 | "mmc read addr blk# cnt\n" |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 1121 | "mmc write addr blk# cnt\n" |
Alex Kiernan | c568bcb | 2018-05-29 15:30:52 +0000 | [diff] [blame] | 1122 | #if CONFIG_IS_ENABLED(CMD_MMC_SWRITE) |
Jassi Brar | 814a975 | 2018-04-06 12:05:24 +0530 | [diff] [blame] | 1123 | "mmc swrite addr blk#\n" |
| 1124 | #endif |
Lei Wen | ea52676 | 2011-06-22 17:03:31 +0000 | [diff] [blame] | 1125 | "mmc erase blk# cnt\n" |
Aswath Govindraju | bb5b9fe | 2021-08-13 23:04:41 +0530 | [diff] [blame] | 1126 | "mmc rescan [mode]\n" |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 1127 | "mmc part - lists available partition on current mmc device\n" |
Aswath Govindraju | bb5b9fe | 2021-08-13 23:04:41 +0530 | [diff] [blame] | 1128 | "mmc dev [dev] [part] [mode] - show or set current mmc device [partition] and set mode\n" |
| 1129 | " - the required speed mode is passed as the index from the following list\n" |
| 1130 | " [MMC_LEGACY, MMC_HS, SD_HS, MMC_HS_52, MMC_DDR_52, UHS_SDR12, UHS_SDR25,\n" |
| 1131 | " UHS_SDR50, UHS_DDR50, UHS_SDR104, MMC_HS_200, MMC_HS_400, MMC_HS_400_ES]\n" |
Amar | 3ccad53 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 1132 | "mmc list - lists available devices\n" |
Michal Simek | 21f753c | 2020-06-05 11:45:12 +0200 | [diff] [blame] | 1133 | "mmc wp - power on write protect boot partitions\n" |
Alex Kiernan | 72d8046 | 2018-06-11 16:20:09 +0000 | [diff] [blame] | 1134 | #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING) |
Jaehoon Chung | 94a4757 | 2021-02-26 16:07:18 +0900 | [diff] [blame] | 1135 | "mmc hwpartition <USER> <GP> <MODE> - does hardware partitioning\n" |
Diego Santa Cruz | 420fc16 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 1136 | " arguments (sizes in 512-byte blocks):\n" |
Jaehoon Chung | 94a4757 | 2021-02-26 16:07:18 +0900 | [diff] [blame] | 1137 | " USER - <user> <enh> <start> <cnt> <wrrel> <{on|off}>\n" |
| 1138 | " : sets user data area attributes\n" |
| 1139 | " GP - <{gp1|gp2|gp3|gp4}> <cnt> <enh> <wrrel> <{on|off}>\n" |
| 1140 | " : general purpose partition\n" |
| 1141 | " MODE - <{check|set|complete}>\n" |
| 1142 | " : mode, complete set partitioning completed\n" |
Diego Santa Cruz | 58bda79 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 1143 | " WARNING: Partitioning is a write-once setting once it is set to complete.\n" |
| 1144 | " Power cycling is required to initialize partitions after set to complete.\n" |
Alex Kiernan | 72d8046 | 2018-06-11 16:20:09 +0000 | [diff] [blame] | 1145 | #endif |
Amar | 3ccad53 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 1146 | #ifdef CONFIG_SUPPORT_EMMC_BOOT |
Jaehoon Chung | 8460b91 | 2020-12-16 07:24:50 +0900 | [diff] [blame] | 1147 | "mmc bootbus <dev> <boot_bus_width> <reset_boot_bus_width> <boot_mode>\n" |
Tom Rini | 4cf854c | 2014-02-05 10:24:22 -0500 | [diff] [blame] | 1148 | " - Set the BOOT_BUS_WIDTH field of the specified device\n" |
Tom Rini | 7991946 | 2014-02-05 10:24:20 -0500 | [diff] [blame] | 1149 | "mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>\n" |
| 1150 | " - Change sizes of boot and RPMB partitions of specified device\n" |
Reuben Dowle | 55a81ad | 2021-05-14 10:15:43 +1200 | [diff] [blame] | 1151 | "mmc partconf <dev> [[varname] | [<boot_ack> <boot_partition> <partition_access>]]\n" |
Angelo Dureghello | f54f753 | 2017-08-01 14:27:10 +0200 | [diff] [blame] | 1152 | " - Show or change the bits of the PARTITION_CONFIG field of the specified device\n" |
Reuben Dowle | 55a81ad | 2021-05-14 10:15:43 +1200 | [diff] [blame] | 1153 | " If showing the bits, optionally store the boot_partition field into varname\n" |
Jaehoon Chung | 8460b91 | 2020-12-16 07:24:50 +0900 | [diff] [blame] | 1154 | "mmc rst-function <dev> <value>\n" |
Tom Rini | 35a3ea1 | 2014-02-07 14:15:20 -0500 | [diff] [blame] | 1155 | " - Change the RST_n_FUNCTION field of the specified device\n" |
| 1156 | " WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.\n" |
Dirk Behme | df8852a | 2009-02-18 19:59:39 +0100 | [diff] [blame] | 1157 | #endif |
Alex Kiernan | 60e0f61 | 2018-05-08 04:43:31 +0000 | [diff] [blame] | 1158 | #if CONFIG_IS_ENABLED(CMD_MMC_RPMB) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1159 | "mmc rpmb read addr blk# cnt [address of auth-key] - block size is 256 bytes\n" |
| 1160 | "mmc rpmb write addr blk# cnt <address of auth-key> - block size is 256 bytes\n" |
| 1161 | "mmc rpmb key <address of auth-key> - program the RPMB authentication key.\n" |
| 1162 | "mmc rpmb counter - read the value of the write counter\n" |
| 1163 | #endif |
| 1164 | "mmc setdsr <value> - set DSR register value\n" |
Tomas Melin | c17dae5 | 2016-11-25 11:01:03 +0200 | [diff] [blame] | 1165 | #ifdef CONFIG_CMD_BKOPS_ENABLE |
| 1166 | "mmc bkops-enable <dev> - enable background operations handshake on device\n" |
| 1167 | " WARNING: This is a write-once setting.\n" |
| 1168 | #endif |
Amar | 3ccad53 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 1169 | ); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1170 | |
| 1171 | /* Old command kept for compatibility. Same as 'mmc info' */ |
| 1172 | U_BOOT_CMD( |
| 1173 | mmcinfo, 1, 0, do_mmcinfo, |
| 1174 | "display MMC info", |
| 1175 | "- display info of the current MMC device" |
| 1176 | ); |