diff --git a/README b/README
index 2808dd1eb9a27cdacadb86f1a2dd9eb26121ec29..7663f7a8c55ca5b712b7333655badf8e528e76df 100644
--- a/README
+++ b/README
@@ -4054,6 +4054,11 @@ Configuration Settings:
 	be asserted. See doc/README.omap-reset-time for details on how
 	the value can be calulated on a given board.
 
+- CONFIG_USE_STDINT
+	If stdint.h is available with your toolchain you can define this
+	option to enable it. You can provide option 'USE_STDINT=1' when
+	building U-Boot to enable this.
+
 The following definitions that deal with the placement and management
 of environment data (variable area); in general, we support the
 following configurations:
diff --git a/arch/sandbox/include/asm/types.h b/arch/sandbox/include/asm/types.h
index 6d3eb1f3de23e5a7fbc26abd34d42e4f958db567..42c09e2fff25c9bd0b68f274548f67a73bf416ee 100644
--- a/arch/sandbox/include/asm/types.h
+++ b/arch/sandbox/include/asm/types.h
@@ -42,8 +42,13 @@ typedef unsigned short u16;
 typedef signed int s32;
 typedef unsigned int u32;
 
+#if !defined(CONFIG_USE_STDINT) || !defined(__INT64_TYPE__)
 typedef signed long long s64;
 typedef unsigned long long u64;
+#else
+typedef __INT64_TYPE__ s64;
+typedef __UINT64_TYPE__ u64;
+#endif
 
 #define BITS_PER_LONG	CONFIG_SANDBOX_BITS_PER_LONG
 
diff --git a/arch/x86/include/asm/types.h b/arch/x86/include/asm/types.h
index e9fde88f7d4a52a414d7a44d655185f61f3c96b8..e272c90eb7f6bd3ef52bfb5c1171aab136110c27 100644
--- a/arch/x86/include/asm/types.h
+++ b/arch/x86/include/asm/types.h
@@ -36,8 +36,13 @@ typedef unsigned short u16;
 typedef signed int s32;
 typedef unsigned int u32;
 
+#if !defined(CONFIG_USE_STDINT) || !defined(__INT64_TYPE__)
 typedef signed long long s64;
 typedef unsigned long long u64;
+#else
+typedef __INT64_TYPE__ s64;
+typedef __UINT64_TYPE__ u64;
+#endif
 
 #define BITS_PER_LONG 32
 
diff --git a/config.mk b/config.mk
index 00805bdc5b3d9689b069c86c3bf5e67916e6d35a..64c2951ac1eb1e6942d5bb5b3100cb871d4ef34a 100644
--- a/config.mk
+++ b/config.mk
@@ -59,6 +59,11 @@ ifdef FTRACE
 PLATFORM_CPPFLAGS += -finstrument-functions -DFTRACE
 endif
 
+# Allow use of stdint.h if available
+ifneq ($(USE_STDINT),)
+PLATFORM_CPPFLAGS += -DCONFIG_USE_STDINT
+endif
+
 #########################################################################
 
 RELFLAGS := $(PLATFORM_RELFLAGS)
diff --git a/include/compiler.h b/include/compiler.h
index 21036022d7a12c68916599c487e68f3ff2ea83d6..47c296e202d1e97388d3207e4f0c2321831a2f87 100644
--- a/include/compiler.h
+++ b/include/compiler.h
@@ -112,6 +112,14 @@ typedef unsigned int uint;
 
 #else /* !USE_HOSTCC */
 
+#ifdef CONFIG_USE_STDINT
+/* Provided by gcc. */
+#include <stdint.h>
+#else
+/* Type for `void *' pointers. */
+typedef unsigned long int uintptr_t;
+#endif
+
 #include <linux/string.h>
 #include <linux/types.h>
 #include <asm/byteorder.h>
@@ -128,9 +136,6 @@ typedef unsigned int uint;
 #define __WORDSIZE	32
 #endif
 
-/* Type for `void *' pointers. */
-typedef unsigned long int uintptr_t;
-
 #endif /* USE_HOSTCC */
 
 #define likely(x)	__builtin_expect(!!(x), 1)
diff --git a/include/linux/types.h b/include/linux/types.h
index 9aebc4e8cf0540d5e71c99b311ea3160d33e0692..c9a8d9a8c2cc8befa9fa37b75f9615999928decb 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -104,7 +104,8 @@ typedef		__u8		uint8_t;
 typedef		__u16		uint16_t;
 typedef		__u32		uint32_t;
 
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
+#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && \
+	(!defined(CONFIG_USE_STDINT) || !defined(__INT64_TYPE__))
 typedef		__u64		uint64_t;
 typedef		__u64		u_int64_t;
 typedef		__s64		int64_t;
@@ -112,6 +113,12 @@ typedef		__s64		int64_t;
 
 #endif /* __KERNEL_STRICT_NAMES */
 
+#if defined(CONFIG_USE_STDINT) && defined(__INT64_TYPE__)
+typedef		__UINT64_TYPE__	uint64_t;
+typedef		__UINT64_TYPE__	u_int64_t;
+typedef		__INT64_TYPE__		int64_t;
+#endif
+
 /*
  * Below are truly Linux-specific types that should never collide with
  * any application/library that wants linux/types.h.