[PATCH] imx25: fix UID endianess

Baruch Siach baruch at tkos.co.il
Wed Aug 4 03:55:09 EDT 2010


Apparently, the UID is little-endian. Reverse endianess, and add a note in
comment.

Signed-off-by: Baruch Siach <baruch at tkos.co.il>
---
 arch/arm/mach-imx/imx25.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-imx/imx25.c b/arch/arm/mach-imx/imx25.c
index de70247..70494aa 100644
--- a/arch/arm/mach-imx/imx25.c
+++ b/arch/arm/mach-imx/imx25.c
@@ -35,8 +35,14 @@ u64 imx_uid(void)
 	u64 uid = 0;
 	int i;
 
+	/*
+	 * This code assumes that the UID is stored little-endian. The 
+	 * Freescale AN3682 document is silent about the endianess, but
+	 * experimentation shows that this is the case. All other multi-byte
+	 * values in IIM are big-endian as per AN3682.
+	 */
 	for (i = 0; i < 8; i++)
-		uid = (uid << 8) | readb(IMX_IIM_BASE + IIM_UID + i*4);
+		uid |= (u64)readb(IMX_IIM_BASE + IIM_UID + i*4) << (i*8);
 
 	return uid;
 }
-- 
1.7.1




More information about the barebox mailing list