diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 1dfa59126fcf..9a7e9d80b908 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -202,8 +202,8 @@ config PPC
 	select HAVE_IOREMAP_PROT
 	select HAVE_IRQ_EXIT_ON_IRQ_STACK
 	select HAVE_KERNEL_GZIP
-	select HAVE_KERNEL_LZMA			if DEFAULT_UIMAGE
-	select HAVE_KERNEL_LZO			if DEFAULT_UIMAGE
+	select HAVE_KERNEL_LZMA
+	select HAVE_KERNEL_LZO
 	select HAVE_KERNEL_XZ			if PPC_BOOK3S || 44x
 	select HAVE_KPROBES
 	select HAVE_KPROBES_ON_FTRACE
diff --git a/arch/powerpc/boot/decompress.c b/arch/powerpc/boot/decompress.c
index 8bf39ef7d2df..ad82a6fd04f6 100644
--- a/arch/powerpc/boot/decompress.c
+++ b/arch/powerpc/boot/decompress.c
@@ -33,6 +33,17 @@
 #	include "decompress_inflate.c"
 #endif
 
+#ifdef CONFIG_KERNEL_LZMA
+#define large_malloc malloc
+#define large_free free
+#	include "../../../lib/decompress_unlzma.c"
+#endif
+
+#ifdef CONFIG_KERNEL_LZO
+#	include "lzo_config.h"
+#	include "../../../lib/decompress_unlzo.c"
+#endif
+
 #ifdef CONFIG_KERNEL_XZ
 #	include "xz_config.h"
 #	include "../../../lib/decompress_unxz.c"
diff --git a/arch/powerpc/boot/lzo_config.h b/arch/powerpc/boot/lzo_config.h
new file mode 100644
index 000000000000..fd985e887c80
--- /dev/null
+++ b/arch/powerpc/boot/lzo_config.h
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __LZO_CONFIG_H__
+#define __LZO_CONFIG_H__
+
+#include "types.h"
+#include "swab.h"
+
+#ifdef __LITTLE_ENDIAN__
+static inline u32 be32_to_cpup(const u32 *p)
+{
+	return swab32(*(u32 *)p);
+}
+static inline u16 be16_to_cpup(const u16 *p)
+{
+	return swab16(*(u16 *)p);
+}
+static inline u16 le16_to_cpup(const u16 *p)
+{
+	return *p;
+}
+#else
+static inline u32 be32_to_cpup(const u32 *p)
+{
+	return *p;
+}
+static inline u16 be16_to_cpup(const u16 *p)
+{
+	return *p;
+}
+static inline u16 le16_to_cpup(const u16 *p)
+{
+	return swab16(*(u16 *)p);
+}
+#endif
+
+static inline uint32_t get_unaligned_be32(const void *p)
+{
+	return be32_to_cpup(p);
+}
+
+static inline uint32_t get_unaligned_be16(const void *p)
+{
+	return be16_to_cpup(p);
+}
+
+static inline uint32_t get_unaligned_le16(const void *p)
+{
+	return le16_to_cpup(p);
+}
+
+#define get_unaligned(ptr) (*(ptr))
+#define put_unaligned(val, ptr) do { *(ptr) = val; } while (0)
+
+#define likely(x)	__builtin_expect(!!(x), 1)
+#define unlikely(x)	__builtin_expect(!!(x), 0)
+
+#endif
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index 35ace40d9fc2..3a20d7c6127d 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -525,9 +525,22 @@ coff)
     $objbin/hack-coff "$ofile"
     ;;
 cuboot*)
-    gzip -n -f -9 "$ofile"
-    ${MKIMAGE} -A ppc -O linux -T kernel -C gzip -a "$base" -e "$entry" \
-            $uboot_version -d "$ofile".gz "$ofile"
+    case $compression in
+    .xz)
+        xz --check=crc32 -f -6 "$ofile"
+        ;;
+    .gz)
+        gzip -n -f -9 "$ofile"
+        ;;
+    .lzma)
+        xz --format=lzma -f -6 "$ofile"
+	;;
+    .lzo)
+        lzop -f -9 "$ofile"
+	;;
+    esac
+    ${MKIMAGE} -A ppc -O linux -T kernel -C $uboot_comp -a "$base" -e "$entry" \
+            $uboot_version -d "$ofile$compression" "$ofile"
     ;;
 treeboot*)
     mv "$ofile" "$ofile.elf"
diff --git a/lib/decompress_unlzma.c b/lib/decompress_unlzma.c
index ed7a1fd819f2..225a42b8e1d7 100644
--- a/lib/decompress_unlzma.c
+++ b/lib/decompress_unlzma.c
@@ -35,7 +35,9 @@
 #include <linux/decompress/unlzma.h>
 #endif /* STATIC */
 
+#ifdef __KERNEL__
 #include <linux/decompress/mm.h>
+#endif
 
 #define	MIN(a, b) (((a) < (b)) ? (a) : (b))
 
@@ -60,7 +62,9 @@ static long long INIT read_int(unsigned char *ptr, int size)
  *Copyright (c) 1999-2005  Igor Pavlov
  */
 
+#ifdef __KERNEL__
 #include <linux/compiler.h>
+#endif
 
 #define LZMA_IOBUF_SIZE	0x10000
 
diff --git a/lib/decompress_unlzo.c b/lib/decompress_unlzo.c
index 1f439a622076..a8dbde4b32d4 100644
--- a/lib/decompress_unlzo.c
+++ b/lib/decompress_unlzo.c
@@ -23,9 +23,11 @@
 #include <linux/decompress/unlzo.h>
 #endif
 
-#include <linux/types.h>
 #include <linux/lzo.h>
+#ifdef __KERNEL__
+#include <linux/types.h>
 #include <linux/decompress/mm.h>
+#endif
 
 #include <linux/compiler.h>
 #include <asm/unaligned.h>
