summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorJaehoon Chung <jh80.chung@samsung.com>2021-02-26 18:38:20 +0900
committerPeng Fan <peng.fan@nxp.com>2021-04-06 18:08:26 +0800
commite9978b17cd7bc19f0459b2829756f1d891382bf9 (patch)
tree4095b047c697ed5850608ed2f739ffdedb9f5530 /cmd
parent8ae82c4b12e71b9f114aeb18e2211ce1260012ca (diff)
downloadu-boot-e9978b17cd7bc19f0459b2829756f1d891382bf9.tar.gz
u-boot-e9978b17cd7bc19f0459b2829756f1d891382bf9.tar.xz
u-boot-e9978b17cd7bc19f0459b2829756f1d891382bf9.zip
cmd: mmc: check whether bootbus's arguments is valid or not
According to Specification, each bit have valid value. But it doesn't check whether arguments is valid or not. It has potential bug with arguments passed by wrong value. Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/mmc.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/cmd/mmc.c b/cmd/mmc.c
index c1c00d0f32..a10f137204 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -735,8 +735,45 @@ static int do_mmc_bootbus(struct cmd_tbl *cmdtp, int flag,
return CMD_RET_FAILURE;
}
+ /*
+ * BOOT_BUS_CONDITIONS[177]
+ * BOOT_MODE[4:3]
+ * 0x0 : Use SDR + Backward compatible timing in boot operation
+ * 0x1 : Use SDR + High Speed Timing in boot operation mode
+ * 0x2 : Use DDR in boot operation
+ * RESET_BOOT_BUS_CONDITIONS
+ * 0x0 : Reset bus width to x1, SDR, Backward compatible
+ * 0x1 : Retain BOOT_BUS_WIDTH and BOOT_MODE
+ * BOOT_BUS_WIDTH
+ * 0x0 : x1(sdr) or x4 (ddr) buswidth
+ * 0x1 : x4(sdr/ddr) buswith
+ * 0x2 : x8(sdr/ddr) buswith
+ *
+ */
+ if (width >= 0x3) {
+ printf("boot_bus_width %d is invalid\n", width);
+ return CMD_RET_FAILURE;
+ }
+
+ if (reset >= 0x2) {
+ printf("reset_boot_bus_width %d is invalid\n", reset);
+ return CMD_RET_FAILURE;
+ }
+
+ if (mode >= 0x3) {
+ printf("reset_boot_bus_width %d is invalid\n", mode);
+ return CMD_RET_FAILURE;
+ }
+
/* acknowledge to be sent during boot operation */
- return mmc_set_boot_bus_width(mmc, width, reset, mode);
+ if (mmc_set_boot_bus_width(mmc, width, reset, mode)) {
+ puts("BOOT_BUS_WIDTH is failed to change.\n");
+ return CMD_RET_FAILURE;
+ }
+
+ printf("Set to BOOT_BUS_WIDTH = 0x%x, RESET = 0x%x, BOOT_MODE = 0x%x\n",
+ width, reset, mode);
+ return CMD_RET_SUCCESS;
}
static int do_mmc_boot_resize(struct cmd_tbl *cmdtp, int flag,