environment: ti: Add DFU environment variables k3_dfu.h

Setup env variables for updating firmwares on eMMC/OSPI/MMC via DFU

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
diff --git a/include/configs/j721e_evm.h b/include/configs/j721e_evm.h
index 8451878..71cea3d 100644
--- a/include/configs/j721e_evm.h
+++ b/include/configs/j721e_evm.h
@@ -14,6 +14,7 @@
 #include <environment/ti/mmc.h>
 #include <environment/ti/k3_rproc.h>
 #include <environment/ti/ufs.h>
+#include <environment/ti/k3_dfu.h>
 
 /* DDR Configuration */
 #define CONFIG_SYS_SDRAM_BASE1		0x880000000
@@ -100,12 +101,21 @@
 		"7 /lib/firmware/j7-c66_1-fw "				\
 		"8 /lib/firmware/j7-c71_0-fw "
 
+/* set default dfu_bufsiz to 128KB (sector size of OSPI) */
+#define EXTRA_ENV_DFUARGS \
+	"dfu_bufsiz=0x20000\0" \
+	DFU_ALT_INFO_MMC \
+	DFU_ALT_INFO_EMMC \
+	DFU_ALT_INFO_RAM \
+	DFU_ALT_INFO_OSPI
+
 /* Incorporate settings into the U-Boot environment */
 #define CONFIG_EXTRA_ENV_SETTINGS					\
 	DEFAULT_MMC_TI_ARGS						\
 	EXTRA_ENV_J721E_BOARD_SETTINGS					\
 	EXTRA_ENV_J721E_BOARD_SETTINGS_MMC				\
 	EXTRA_ENV_RPROC_SETTINGS					\
+	EXTRA_ENV_DFUARGS						\
 	DEFAULT_UFS_TI_ARGS
 
 /* Now for the remaining common defines */
diff --git a/include/environment/ti/k3_dfu.h b/include/environment/ti/k3_dfu.h
new file mode 100644
index 0000000..2f503b8
--- /dev/null
+++ b/include/environment/ti/k3_dfu.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com
+ *
+ * Environment variable definitions for DFU on TI K3 SoCs.
+ *
+ */
+
+#ifndef __TI_DFU_H
+#define __TI_DFU_H
+
+#define DFU_ALT_INFO_MMC \
+	"dfu_alt_info_mmc=" \
+	"boot part 1 1;" \
+	"rootfs part 1 2;" \
+	"tiboot3.bin fat 1 1;" \
+	"tispl.bin fat 1 1;" \
+	"u-boot.img fat 1 1;" \
+	"uEnv.txt fat 1 1;" \
+	"sysfw.itb fat 1 1\0"
+
+#define DFU_ALT_INFO_EMMC \
+	"dfu_alt_info_emmc=" \
+	"rawemmc raw 0 0x800000 mmcpart 1;" \
+	"rootfs part 0 1 mmcpart 0;" \
+	"tiboot3.bin.raw raw 0x0 0x400 mmcpart 1;" \
+	"tispl.bin.raw raw 0x400 0x1000 mmcpart 1;" \
+	"u-boot.img.raw raw 0x1400 0x2000 mmcpart 1;" \
+	"u-env.raw raw 0x3400 0x100 mmcpart 1;" \
+	"sysfw.itb.raw raw 0x3600 0x800 mmcpart 1\0"
+
+#define DFU_ALT_INFO_OSPI \
+	"dfu_alt_info_ospi=" \
+	"tiboot3.bin raw 0x0 0x080000;" \
+	"tispl.bin raw 0x080000 0x200000;" \
+	"u-boot.img raw 0x280000 0x400000;" \
+	"u-boot-env raw 0x680000 0x020000;" \
+	"sysfw.itb raw 0x6c0000 0x100000;" \
+	"rootfs raw 0x800000 0x3800000\0"
+
+#define DFU_ALT_INFO_RAM \
+	"dfu_alt_info_ram=" \
+	"tispl.bin ram 0x80080000 0x100000;" \
+	"u-boot.img ram 0x81000000 0x100000\0" \
+
+#endif /* __TI_DFU_H */