summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorAlbert ARIBAUD <albert.u.boot@aribaud.net>2014-04-08 09:25:08 +0200
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>2014-04-08 09:25:08 +0200
commit519fdde9e6a6ebce7dc743b4f5621503d25b7a45 (patch)
tree29649f48b92b92342183f71565c34afeca0b1735 /common
parentc71645ad2bd5179ad21e2501c26f574e9688f02a (diff)
parent04d2f0a9f33112bd70ce4d9c451fdca1682e3a59 (diff)
downloadu-boot-imx-519fdde9e6a6ebce7dc743b4f5621503d25b7a45.zip
u-boot-imx-519fdde9e6a6ebce7dc743b4f5621503d25b7a45.tar.gz
u-boot-imx-519fdde9e6a6ebce7dc743b4f5621503d25b7a45.tar.bz2
Merge branch 'u-boot/master' into 'u-boot-arm/master'
Conflicts: arch/arm/cpu/arm926ejs/mxs/Makefile include/configs/trats.h include/configs/trats2.h include/mmc.h
Diffstat (limited to 'common')
-rw-r--r--common/Makefile3
-rw-r--r--common/cmd_eeprom.c9
-rw-r--r--common/cmd_gpt.c61
-rw-r--r--common/cmd_lzmadec.c52
-rw-r--r--common/cmd_mmc.c39
-rw-r--r--common/cmd_mmc_spi.c2
6 files changed, 147 insertions, 19 deletions
diff --git a/common/Makefile b/common/Makefile
index e2ff0cb..cecd81a 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -159,6 +159,9 @@ obj-$(CONFIG_CMD_UBI) += cmd_ubi.o
obj-$(CONFIG_CMD_UBIFS) += cmd_ubifs.o
obj-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o
obj-$(CONFIG_CMD_UNZIP) += cmd_unzip.o
+ifdef CONFIG_LZMA
+obj-$(CONFIG_CMD_LZMADEC) += cmd_lzmadec.o
+endif
ifdef CONFIG_CMD_USB
obj-y += cmd_usb.o
obj-y += usb.o usb_hub.o
diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index 3924805..fad462f 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -389,8 +389,13 @@ void eeprom_init (void)
#if defined(CONFIG_SPI) && !defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
spi_init_f ();
#endif
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C_SOFT)
- i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C_SOFT) || \
+ defined(CONFIG_SYS_I2C)
+#ifdef CONFIG_SYS_I2C
+ i2c_init_all();
+#else
+ i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+#endif
#endif
}
diff --git a/common/cmd_gpt.c b/common/cmd_gpt.c
index 1f12e6d..e38422d 100644
--- a/common/cmd_gpt.c
+++ b/common/cmd_gpt.c
@@ -29,30 +29,53 @@
*
* @return - zero on successful expand and env is set
*/
-static char extract_env(const char *str, char **env)
+static int extract_env(const char *str, char **env)
{
+ int ret = -1;
char *e, *s;
+#ifdef CONFIG_RANDOM_UUID
+ char uuid_str[UUID_STR_LEN + 1];
+#endif
if (!str || strlen(str) < 4)
return -1;
- if ((strncmp(str, "${", 2) == 0) && (str[strlen(str) - 1] == '}')) {
- s = strdup(str);
- if (s == NULL)
- return -1;
- memset(s + strlen(s) - 1, '\0', 1);
- memmove(s, s + 2, strlen(s) - 1);
+ if (!((strncmp(str, "${", 2) == 0) && (str[strlen(str) - 1] == '}')))
+ return -1;
+
+ s = strdup(str);
+ if (s == NULL)
+ return -1;
+
+ memset(s + strlen(s) - 1, '\0', 1);
+ memmove(s, s + 2, strlen(s) - 1);
+
+ e = getenv(s);
+ if (e == NULL) {
+#ifdef CONFIG_RANDOM_UUID
+ debug("%s unset. ", str);
+ gen_rand_uuid_str(uuid_str, UUID_STR_FORMAT_STD);
+ setenv(s, uuid_str);
+
e = getenv(s);
- free(s);
- if (e == NULL) {
- printf("Environmental '%s' not set\n", str);
- return -1; /* env not set */
+ if (e) {
+ debug("Set to random.\n");
+ ret = 0;
+ } else {
+ debug("Can't get random UUID.\n");
}
- *env = e;
- return 0;
+#else
+ debug("%s unset.\n", str);
+#endif
+ } else {
+ debug("%s get from environment.\n", str);
+ ret = 0;
}
- return -1;
+ *env = e;
+ free(s);
+
+ return ret;
}
/**
@@ -299,8 +322,16 @@ static int do_gpt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return CMD_RET_FAILURE;
}
- if (gpt_default(blk_dev_desc, argv[4]))
+ puts("Writing GPT: ");
+
+ ret = gpt_default(blk_dev_desc, argv[4]);
+ if (!ret) {
+ puts("success!\n");
+ return CMD_RET_SUCCESS;
+ } else {
+ puts("error!\n");
return CMD_RET_FAILURE;
+ }
} else {
return CMD_RET_USAGE;
}
diff --git a/common/cmd_lzmadec.c b/common/cmd_lzmadec.c
new file mode 100644
index 0000000..7b0b3fd
--- /dev/null
+++ b/common/cmd_lzmadec.c
@@ -0,0 +1,52 @@
+/*
+ * (C) Copyright 2013 Patrice Bouchand <pbfwdlist_gmail_com>
+ * lzma uncompress command in Uboot
+ *
+ * made from existing cmd_unzip.c file of Uboot
+ *
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <command.h>
+#include <asm/io.h>
+
+#include <lzma/LzmaTools.h>
+
+static int do_lzmadec(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+{
+ unsigned long src, dst;
+ unsigned long src_len = ~0UL, dst_len = ~0UL;
+ int ret;
+
+ switch (argc) {
+ case 4:
+ dst_len = simple_strtoul(argv[3], NULL, 16);
+ /* fall through */
+ case 3:
+ src = simple_strtoul(argv[1], NULL, 16);
+ dst = simple_strtoul(argv[2], NULL, 16);
+ break;
+ default:
+ return CMD_RET_USAGE;
+ }
+
+ ret = lzmaBuffToBuffDecompress(map_sysmem(dst, dst_len), &src_len,
+ map_sysmem(src, 0), dst_len);
+
+ if (ret != SZ_OK)
+ return 1;
+ printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len);
+ setenv_hex("filesize", src_len);
+
+ return 0;
+}
+
+U_BOOT_CMD(
+ lzmadec, 4, 1, do_lzmadec,
+ "lzma uncompress a memory region",
+ "srcaddr dstaddr [dstsize]"
+);
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 2d51927..c1916c9 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -79,7 +79,7 @@ enum mmc_state {
};
static void print_mmcinfo(struct mmc *mmc)
{
- printf("Device: %s\n", mmc->name);
+ printf("Device: %s\n", mmc->cfg->name);
printf("Manufacturer ID: %x\n", mmc->cid[0] >> 24);
printf("OEM: %x\n", (mmc->cid[0] >> 8) & 0xffff);
printf("Name: %c%c%c%c%c \n", mmc->cid[0] & 0xff,
@@ -330,6 +330,40 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
printf("EMMC boot partition Size change Failed.\n");
return 1;
}
+ } else if (strcmp(argv[1], "rst-function") == 0) {
+ /*
+ * Set the RST_n_ENABLE bit of RST_n_FUNCTION
+ * The only valid values are 0x0, 0x1 and 0x2 and writing
+ * a value of 0x1 or 0x2 sets the value permanently.
+ */
+ int dev;
+ struct mmc *mmc;
+ u8 enable;
+
+ if (argc == 4) {
+ dev = simple_strtoul(argv[2], NULL, 10);
+ enable = simple_strtoul(argv[3], NULL, 10);
+ } else {
+ return CMD_RET_USAGE;
+ }
+
+ if (enable > 2 || enable < 0) {
+ puts("Invalid RST_n_ENABLE value\n");
+ return CMD_RET_USAGE;
+ }
+
+ mmc = find_mmc_device(dev);
+ if (!mmc) {
+ printf("no mmc device at slot %x\n", dev);
+ return 1;
+ }
+
+ if (IS_SD(mmc)) {
+ puts("RST_n_FUNCTION only exists on eMMC\n");
+ return 1;
+ }
+
+ return mmc_set_rst_n_function(mmc, enable);
#endif /* CONFIG_SUPPORT_EMMC_BOOT */
}
@@ -436,6 +470,9 @@ U_BOOT_CMD(
" - 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 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"
#endif
"mmc setdsr - set DSR register value\n"
);
diff --git a/common/cmd_mmc_spi.c b/common/cmd_mmc_spi.c
index 98cd788..a2138b8 100644
--- a/common/cmd_mmc_spi.c
+++ b/common/cmd_mmc_spi.c
@@ -72,7 +72,7 @@ static int do_mmc_spi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
printf("Failed to create MMC Device\n");
return 1;
}
- printf("%s: %d at %u:%u hz %u mode %u\n", mmc->name, mmc->block_dev.dev,
+ printf("%s: %d at %u:%u hz %u mode %u\n", mmc->cfg->name, mmc->block_dev.dev,
bus, cs, speed, mode);
mmc_init(mmc);
return 0;