]> git.sur5r.net Git - u-boot/blobdiff - cmd/mmc.c
cmd: spl: fix compiling error when CONFIG_CMD_SPL_WRITE_SIZE not defined
[u-boot] / cmd / mmc.c
index eb4a547a9707939c71ad5396fe2fe386d9912084..5def4ea1a29ad0b6c72bd60b3c4132c749a1d6ca 100644 (file)
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
 #include <mmc.h>
 
 static int curr_device = -1;
-#ifndef CONFIG_GENERIC_MMC
-int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-       int dev;
-
-       if (argc < 2)
-               return CMD_RET_USAGE;
-
-       if (strcmp(argv[1], "init") == 0) {
-               if (argc == 2) {
-                       if (curr_device < 0)
-                               dev = 1;
-                       else
-                               dev = curr_device;
-               } else if (argc == 3) {
-                       dev = (int)simple_strtoul(argv[2], NULL, 10);
-               } else {
-                       return CMD_RET_USAGE;
-               }
-
-               if (mmc_legacy_init(dev) != 0) {
-                       puts("No MMC card found\n");
-                       return 1;
-               }
-
-               curr_device = dev;
-               printf("mmc%d is available\n", curr_device);
-       } else if (strcmp(argv[1], "device") == 0) {
-               if (argc == 2) {
-                       if (curr_device < 0) {
-                               puts("No MMC device available\n");
-                               return 1;
-                       }
-               } else if (argc == 3) {
-                       dev = (int)simple_strtoul(argv[2], NULL, 10);
-
-#ifdef CONFIG_SYS_MMC_SET_DEV
-                       if (mmc_set_dev(dev) != 0)
-                               return 1;
-#endif
-                       curr_device = dev;
-               } else {
-                       return CMD_RET_USAGE;
-               }
-
-               printf("mmc%d is current device\n", curr_device);
-       } else {
-               return CMD_RET_USAGE;
-       }
-
-       return 0;
-}
-
-U_BOOT_CMD(
-       mmc, 3, 1, do_mmc,
-       "MMC sub-system",
-       "init [dev] - init MMC sub system\n"
-       "mmc device [dev] - show or set current device"
-);
-#else /* !CONFIG_GENERIC_MMC */
 
 static void print_mmcinfo(struct mmc *mmc)
 {
@@ -313,7 +253,11 @@ static int do_mmcrpmb(cmd_tbl_t *cmdtp, int flag,
                return CMD_RET_FAILURE;
        }
        /* Switch to the RPMB partition */
+#ifndef CONFIG_BLK
        original_part = mmc->block_dev.hwpart;
+#else
+       original_part = mmc_get_blk_desc(mmc)->hwpart;
+#endif
        if (blk_select_hwpart_devnum(IF_TYPE_MMC, curr_device, MMC_PART_RPMB) !=
            0)
                return CMD_RET_FAILURE;
@@ -349,8 +293,6 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int flag,
               curr_device, blk, cnt);
 
        n = blk_dread(mmc_get_blk_desc(mmc), blk, cnt, addr);
-       /* flush cache after read */
-       flush_cache((ulong)addr, cnt * 512); /* FIXME */
        printf("%d blocks read: %s\n", n, (n == cnt) ? "OK" : "ERROR");
 
        return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
@@ -699,6 +641,28 @@ static int do_mmc_boot_resize(cmd_tbl_t *cmdtp, int flag,
        printf("EMMC RPMB partition Size %d MB\n", rpmbsize);
        return CMD_RET_SUCCESS;
 }
+
+static int mmc_partconf_print(struct mmc *mmc)
+{
+       u8 ack, access, part;
+
+       if (mmc->part_config == MMCPART_NOAVAILABLE) {
+               printf("No part_config info for ver. 0x%x\n", mmc->version);
+               return CMD_RET_FAILURE;
+       }
+
+       access = EXT_CSD_EXTRACT_PARTITION_ACCESS(mmc->part_config);
+       ack = EXT_CSD_EXTRACT_BOOT_ACK(mmc->part_config);
+       part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
+
+       printf("EXT_CSD[179], PARTITION_CONFIG:\n"
+               "BOOT_ACK: 0x%x\n"
+               "BOOT_PARTITION_ENABLE: 0x%x\n"
+               "PARTITION_ACCESS: 0x%x\n", ack, part, access);
+
+       return CMD_RET_SUCCESS;
+}
+
 static int do_mmc_partconf(cmd_tbl_t *cmdtp, int flag,
                           int argc, char * const argv[])
 {
@@ -706,13 +670,10 @@ static int do_mmc_partconf(cmd_tbl_t *cmdtp, int flag,
        struct mmc *mmc;
        u8 ack, part_num, access;
 
-       if (argc != 5)
+       if (argc != 2 && argc != 5)
                return CMD_RET_USAGE;
 
        dev = simple_strtoul(argv[1], NULL, 10);
-       ack = simple_strtoul(argv[2], NULL, 10);
-       part_num = simple_strtoul(argv[3], NULL, 10);
-       access = simple_strtoul(argv[4], NULL, 10);
 
        mmc = init_mmc_device(dev, false);
        if (!mmc)
@@ -723,6 +684,13 @@ static int do_mmc_partconf(cmd_tbl_t *cmdtp, int flag,
                return CMD_RET_FAILURE;
        }
 
+       if (argc == 2)
+               return mmc_partconf_print(mmc);
+
+       ack = simple_strtoul(argv[2], NULL, 10);
+       part_num = simple_strtoul(argv[3], NULL, 10);
+       access = simple_strtoul(argv[4], NULL, 10);
+
        /* acknowledge to be sent during boot operation */
        return mmc_set_part_conf(mmc, ack, part_num, access);
 }
@@ -770,7 +738,7 @@ static int do_mmc_setdsr(cmd_tbl_t *cmdtp, int flag,
 
        if (argc != 2)
                return CMD_RET_USAGE;
-       val = simple_strtoul(argv[2], NULL, 16);
+       val = simple_strtoul(argv[1], NULL, 16);
 
        mmc = find_mmc_device(curr_device);
        if (!mmc) {
@@ -789,6 +757,31 @@ static int do_mmc_setdsr(cmd_tbl_t *cmdtp, int flag,
        return ret;
 }
 
+#ifdef CONFIG_CMD_BKOPS_ENABLE
+static int do_mmc_bkops_enable(cmd_tbl_t *cmdtp, int flag,
+                                  int argc, char * const argv[])
+{
+       int dev;
+       struct mmc *mmc;
+
+       if (argc != 2)
+               return CMD_RET_USAGE;
+
+       dev = simple_strtoul(argv[1], NULL, 10);
+
+       mmc = init_mmc_device(dev, false);
+       if (!mmc)
+               return CMD_RET_FAILURE;
+
+       if (IS_SD(mmc)) {
+               puts("BKOPS_EN only exists on eMMC\n");
+               return CMD_RET_FAILURE;
+       }
+
+       return mmc_set_bkops_enable(mmc);
+}
+#endif
+
 static cmd_tbl_t cmd_mmc[] = {
        U_BOOT_CMD_MKENT(info, 1, 0, do_mmcinfo, "", ""),
        U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""),
@@ -809,6 +802,9 @@ static cmd_tbl_t cmd_mmc[] = {
        U_BOOT_CMD_MKENT(rpmb, CONFIG_SYS_MAXARGS, 1, do_mmcrpmb, "", ""),
 #endif
        U_BOOT_CMD_MKENT(setdsr, 2, 0, do_mmc_setdsr, "", ""),
+#ifdef CONFIG_CMD_BKOPS_ENABLE
+       U_BOOT_CMD_MKENT(bkops-enable, 2, 0, do_mmc_bkops_enable, "", ""),
+#endif
 };
 
 static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
@@ -860,8 +856,8 @@ U_BOOT_CMD(
        " - Set the BOOT_BUS_WIDTH field of the specified device\n"
        "mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>\n"
        " - Change sizes of boot and RPMB partitions of specified device\n"
-       "mmc partconf dev boot_ack boot_partition partition_access\n"
-       " - Change the bits of the PARTITION_CONFIG field of the specified device\n"
+       "mmc partconf dev [boot_ack boot_partition partition_access]\n"
+       " - Show or change the bits of the PARTITION_CONFIG field of the specified device\n"
        "mmc rst-function dev value\n"
        " - Change the RST_n_FUNCTION field of the specified device\n"
        "   WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.\n"
@@ -873,6 +869,10 @@ U_BOOT_CMD(
        "mmc rpmb counter - read the value of the write counter\n"
 #endif
        "mmc setdsr <value> - set DSR register value\n"
+#ifdef CONFIG_CMD_BKOPS_ENABLE
+       "mmc bkops-enable <dev> - enable background operations handshake on device\n"
+       "   WARNING: This is a write-once setting.\n"
+#endif
        );
 
 /* Old command kept for compatibility. Same as 'mmc info' */
@@ -881,5 +881,3 @@ U_BOOT_CMD(
        "display MMC info",
        "- display info of the current MMC device"
 );
-
-#endif /* !CONFIG_GENERIC_MMC */