Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Nov 2016 23:48:21 +0000 (UTC)
From:      Olivier Houchard <cognet@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r308818 - head/sys/arm/ti
Message-ID:  <201611182348.uAINmLnH048298@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cognet
Date: Fri Nov 18 23:48:20 2016
New Revision: 308818
URL: https://svnweb.freebsd.org/changeset/base/308818

Log:
  Guess the TI chip based on the PLATFORM infos, instead of relying on the
  kernel config file.

Modified:
  head/sys/arm/ti/ti_cpuid.h
  head/sys/arm/ti/ti_machdep.c

Modified: head/sys/arm/ti/ti_cpuid.h
==============================================================================
--- head/sys/arm/ti/ti_cpuid.h	Fri Nov 18 22:59:33 2016	(r308817)
+++ head/sys/arm/ti/ti_cpuid.h	Fri Nov 18 23:48:20 2016	(r308818)
@@ -70,15 +70,12 @@
 #define	CHIP_OMAP_4	0
 #define	CHIP_AM335X	1
 
+extern int _ti_chip;
+
 static __inline int ti_chip(void)
 {
-#if defined(SOC_OMAP4)
-	return CHIP_OMAP_4;
-#elif defined(SOC_TI_AM335X)
-	return CHIP_AM335X;
-#else
-#  error Chip type not defined, ensure SOC_xxxx is defined
-#endif
+	KASSERT(_ti_chip != -1, ("Can't determine TI Chip"));
+	return _ti_chip;
 }
 
 uint32_t ti_revision(void);

Modified: head/sys/arm/ti/ti_machdep.c
==============================================================================
--- head/sys/arm/ti/ti_machdep.c	Fri Nov 18 22:59:33 2016	(r308817)
+++ head/sys/arm/ti/ti_machdep.c	Fri Nov 18 23:48:20 2016	(r308818)
@@ -54,11 +54,32 @@ __FBSDID("$FreeBSD$");
 
 #include <arm/ti/omap4/omap4_reg.h>
 #include <arm/ti/omap4/omap4_mp.h>
+#include <arm/ti/ti_cpuid.h>
 
 #include "platform_if.h"
 
 void (*ti_cpu_reset)(void) = NULL;
 
+int _ti_chip = -1;
+
+#if defined(SOC_OMAP4)
+static int
+omap4_attach(platform_t plat)
+{
+	_ti_chip = CHIP_OMAP_4;
+	return (0);
+}
+#endif
+
+#if defined(SOC_TI_AM335X)
+static int
+ti_am335x_attach(platform_t plat)
+{
+	_ti_chip = CHIP_AM335X;
+	return (0);
+}
+#endif
+
 static vm_offset_t
 ti_lastaddr(platform_t plat)
 {
@@ -107,6 +128,7 @@ ti_plat_cpu_reset(platform_t plat)
 
 #if defined(SOC_OMAP4)
 static platform_method_t omap4_methods[] = {
+	PLATFORMMETHOD(platform_attach, 	omap4_attach),
 	PLATFORMMETHOD(platform_devmap_init,	ti_omap4_devmap_init),
 	PLATFORMMETHOD(platform_lastaddr,	ti_lastaddr),
 	PLATFORMMETHOD(platform_cpu_reset,	ti_plat_cpu_reset),
@@ -122,6 +144,7 @@ FDT_PLATFORM_DEF(omap4, "omap4", 0, "ti,
 
 #if defined(SOC_TI_AM335X)
 static platform_method_t am335x_methods[] = {
+	PLATFORMMETHOD(platform_attach, 	ti_am335x_attach),
 	PLATFORMMETHOD(platform_devmap_init,	ti_am335x_devmap_init),
 	PLATFORMMETHOD(platform_lastaddr,	ti_lastaddr),
 	PLATFORMMETHOD(platform_cpu_reset,	ti_plat_cpu_reset),



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201611182348.uAINmLnH048298>