@@ -69,6 +69,18 @@ config BR2_TARGET_TI_K3_R5_LOADER_VERSION
if BR2_TARGET_TI_K3_R5_LOADER_CUSTOM_GIT || \
BR2_TARGET_TI_K3_R5_LOADER_CUSTOM_HG || \
BR2_TARGET_TI_K3_R5_LOADER_CUSTOM_SVN
+
+config BR2_TARGET_TI_K3_R5_LOADER_PATCH
+ string "Custom U-Boot patches"
+ default ""
+ help
+ A space-separated list of patches to apply to U-Boot.
+ Each patch can be described as an URL, a local file path,
+ or a directory. In the case of a directory, all files
+ matching *.patch in the directory will be applied.
+
+ Most users may leave this empty
+
choice
prompt "U-Boot Configuration"
default BR2_TARGET_TI_K3_R5_LOADER_USE_DEFCONFIG
@@ -60,6 +60,25 @@ TI_K3_R5_LOADER_KCONFIG_DEPENDENCIES = \
$(BR2_BISON_HOST_DEPENDENCY) \
$(BR2_FLEX_HOST_DEPENDENCY)
+# Analogous code exists in linux/linux.mk. Basically, the generic
+# package infrastructure handles downloading and applying remote
+# patches. Local patches are handled depending on whether they are
+# directories or files.
+TI_K3_R5_LOADER_PATCHES = $(call qstrip,$(BR2_TARGET_TI_K3_R5_LOADER_PATCH))
+TI_K3_R5_LOADER_PATCH = $(filter ftp://% http://% https://%,$(TI_K3_R5_LOADER_PATCHES))
+
+define TI_K3_R5_LOADER_APPLY_LOCAL_PATCHES
+ for p in $(filter-out ftp://% http://% https://%,$(TI_K3_R5_LOADER_PATCHES)) ; do \
+ if test -d $$p ; then \
+ $(APPLY_PATCHES) $(@D) $$p \*.patch || exit 1 ; \
+ else \
+ $(APPLY_PATCHES) $(@D) `dirname $$p` `basename $$p` || exit 1; \
+ fi \
+ done
+endef
+
+TI_K3_R5_LOADER_POST_PATCH_HOOKS += TI_K3_R5_LOADER_APPLY_LOCAL_PATCHES
+
ifeq ($(BR2_TARGET_TI_K3_R5_LOADER_USE_DEFCONFIG),y)
TI_K3_R5_LOADER_KCONFIG_DEFCONFIG = $(call qstrip,$(BR2_TARGET_TI_K3_R5_LOADER_BOARD_DEFCONFIG))_defconfig
else ifeq ($(BR2_TARGET_TI_K3_R5_LOADER_USE_CUSTOM_CONFIG),y)