Commit 33ace362fdf80e2e2ea4cdf2829a5179c52de3f4

Authored by Tom Rini
Committed by Pantelis Antoniou
1 parent 74c32ef58d

mmc: Add 'mmc rst-function' sub-command

Some eMMC chips may need the RST_n_FUNCTION bit set to a non-zero value
in order for warm reset of the system to work.  Details on this being
required will be part of the eMMC datasheet.  Also add using this
command to the dra7xx README.

* Whitespace fix by panto

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>

Showing 4 changed files with 53 additions and 0 deletions Side-by-side Diff

board/ti/dra7xx/README
... ... @@ -23,4 +23,5 @@
23 23 U-Boot # mmc write ${loadaddr} 300 400
24 24 U-Boot # mmc bootbus 1 2 0 2
25 25 U-Boot # mmc partconf 1 1 1 0
  26 +U-Boot # mmc rst-function 1 1
... ... @@ -330,6 +330,40 @@
330 330 printf("EMMC boot partition Size change Failed.\n");
331 331 return 1;
332 332 }
  333 + } else if (strcmp(argv[1], "rst-function") == 0) {
  334 + /*
  335 + * Set the RST_n_ENABLE bit of RST_n_FUNCTION
  336 + * The only valid values are 0x0, 0x1 and 0x2 and writing
  337 + * a value of 0x1 or 0x2 sets the value permanently.
  338 + */
  339 + int dev;
  340 + struct mmc *mmc;
  341 + u8 enable;
  342 +
  343 + if (argc == 4) {
  344 + dev = simple_strtoul(argv[2], NULL, 10);
  345 + enable = simple_strtoul(argv[3], NULL, 10);
  346 + } else {
  347 + return CMD_RET_USAGE;
  348 + }
  349 +
  350 + if (enable > 2 || enable < 0) {
  351 + puts("Invalid RST_n_ENABLE value\n");
  352 + return CMD_RET_USAGE;
  353 + }
  354 +
  355 + mmc = find_mmc_device(dev);
  356 + if (!mmc) {
  357 + printf("no mmc device at slot %x\n", dev);
  358 + return 1;
  359 + }
  360 +
  361 + if (IS_SD(mmc)) {
  362 + puts("RST_n_FUNCTION only exists on eMMC\n");
  363 + return 1;
  364 + }
  365 +
  366 + return mmc_set_rst_n_function(mmc, enable);
333 367 #endif /* CONFIG_SUPPORT_EMMC_BOOT */
334 368 }
335 369  
... ... @@ -436,6 +470,9 @@
436 470 " - Change sizes of boot and RPMB partitions of specified device\n"
437 471 "mmc partconf dev boot_ack boot_partition partition_access\n"
438 472 " - Change the bits of the PARTITION_CONFIG field of the specified device\n"
  473 + "mmc rst-function dev value\n"
  474 + " - Change the RST_n_FUNCTION field of the specified device\n"
  475 + " WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.\n"
439 476 #endif
440 477 "mmc setdsr - set DSR register value\n"
441 478 );
... ... @@ -1513,5 +1513,17 @@
1513 1513 return err;
1514 1514 return 0;
1515 1515 }
  1516 +
  1517 +/*
  1518 + * Modify EXT_CSD[162] which is RST_n_FUNCTION based on the given value
  1519 + * for enable. Note that this is a write-once field for non-zero values.
  1520 + *
  1521 + * Returns 0 on success.
  1522 + */
  1523 +int mmc_set_rst_n_function(struct mmc *mmc, u8 enable)
  1524 +{
  1525 + return mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_RST_N_FUNCTION,
  1526 + enable);
  1527 +}
1516 1528 #endif
... ... @@ -150,6 +150,7 @@
150 150 #define EXT_CSD_GP_SIZE_MULT 143 /* R/W */
151 151 #define EXT_CSD_PARTITIONS_ATTRIBUTE 156 /* R/W */
152 152 #define EXT_CSD_PARTITIONING_SUPPORT 160 /* RO */
  153 +#define EXT_CSD_RST_N_FUNCTION 162 /* R/W */
153 154 #define EXT_CSD_RPMB_MULT 168 /* RO */
154 155 #define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */
155 156 #define EXT_CSD_BOOT_BUS_WIDTH 177
... ... @@ -332,6 +333,8 @@
332 333 int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access);
333 334 /* Function to modify the BOOT_BUS_WIDTH field of EXT_CSD */
334 335 int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode);
  336 +/* Function to modify the RST_n_FUNCTION field of EXT_CSD */
  337 +int mmc_set_rst_n_function(struct mmc *mmc, u8 enable);
335 338  
336 339 /**
337 340 * Start device initialization and return immediately; it does not block on