Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Aug 2014 19:10:54 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r269607 - head/sys/arm/freescale/imx
Message-ID:  <53e12c3e.591e.6b85d06d@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Tue Aug  5 19:10:53 2014
New Revision: 269607
URL: http://svnweb.freebsd.org/changeset/base/269607

Log:
  Cache the imx6 SoC type in a static var so that it only has to be figured
  out by sniffing hardware registers once.

Modified:
  head/sys/arm/freescale/imx/imx6_machdep.c

Modified: head/sys/arm/freescale/imx/imx6_machdep.c
==============================================================================
--- head/sys/arm/freescale/imx/imx6_machdep.c	Tue Aug  5 19:06:45 2014	(r269606)
+++ head/sys/arm/freescale/imx/imx6_machdep.c	Tue Aug  5 19:10:53 2014	(r269607)
@@ -146,12 +146,16 @@ u_int imx_soc_type()
 {
 	uint32_t digprog, hwsoc;
 	uint32_t *pcr;
+	static u_int soctype;
 	const vm_offset_t SCU_CONFIG_PHYSADDR = 0x00a00004;
 #define	HWSOC_MX6SL	0x60
 #define	HWSOC_MX6DL	0x61
 #define	HWSOC_MX6SOLO	0x62
 #define	HWSOC_MX6Q	0x63
 
+	if (soctype != 0)
+		return (soctype);
+
 	digprog = imx6_anatop_read_4(IMX6_ANALOG_DIGPROG_SL);
 	hwsoc = (digprog >> IMX6_ANALOG_DIGPROG_SOCTYPE_SHIFT) & 
 	    IMX6_ANALOG_DIGPROG_SOCTYPE_MASK;
@@ -175,20 +179,25 @@ u_int imx_soc_type()
 
 	switch (hwsoc) {
 	case HWSOC_MX6SL:
-		return (IMXSOC_6SL);
+		soctype = IMXSOC_6SL;
+		break;
 	case HWSOC_MX6SOLO:
-		return (IMXSOC_6S);
+		soctype = IMXSOC_6S;
+		break;
 	case HWSOC_MX6DL:
-		return (IMXSOC_6DL);
+		soctype = IMXSOC_6DL;
+		break;
 	case HWSOC_MX6Q :
-		return (IMXSOC_6Q);
+		soctype = IMXSOC_6Q;
+		break;
 	default:
 		printf("imx_soc_type: Don't understand hwsoc 0x%02x, "
 		    "digprog 0x%08x; assuming IMXSOC_6Q\n", hwsoc, digprog);
+		soctype = IMXSOC_6Q;
 		break;
 	}
 
-	return (IMXSOC_6Q);
+	return (soctype);
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53e12c3e.591e.6b85d06d>