Commit 6eaf349a authored by Kevin Hilman's avatar Kevin Hilman

DaVinci: update CPU detection so compiler can optimize away

Signed-off-by: default avatarKevin Hilman <khilman@deeprootsystems.com>
parent 33592513
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#define JTAG_ID_BASE 0x01c40028 #define JTAG_ID_BASE 0x01c40028
static unsigned int davinci_revision;
struct davinci_id { struct davinci_id {
u8 variant; /* JTAG ID bits 31:28 */ u8 variant; /* JTAG ID bits 31:28 */
u16 part_no; /* JTAG ID bits 27:12 */ u16 part_no; /* JTAG ID bits 27:12 */
...@@ -77,6 +79,11 @@ static u8 __init davinci_get_variant(void) ...@@ -77,6 +79,11 @@ static u8 __init davinci_get_variant(void)
return variant; return variant;
} }
unsigned int davinci_rev(void)
{
return davinci_revision >> 16;
}
void __init davinci_check_revision(void) void __init davinci_check_revision(void)
{ {
int i; int i;
...@@ -89,7 +96,7 @@ void __init davinci_check_revision(void) ...@@ -89,7 +96,7 @@ void __init davinci_check_revision(void)
/* First check only the major version in a safe way */ /* First check only the major version in a safe way */
for (i = 0; i < ARRAY_SIZE(davinci_ids); i++) { for (i = 0; i < ARRAY_SIZE(davinci_ids); i++) {
if (part_no == (davinci_ids[i].part_no)) { if (part_no == (davinci_ids[i].part_no)) {
system_rev = davinci_ids[i].type; davinci_revision = davinci_ids[i].type;
break; break;
} }
} }
...@@ -98,10 +105,11 @@ void __init davinci_check_revision(void) ...@@ -98,10 +105,11 @@ void __init davinci_check_revision(void)
for (i = 0; i < ARRAY_SIZE(davinci_ids); i++) { for (i = 0; i < ARRAY_SIZE(davinci_ids); i++) {
if (part_no == davinci_ids[i].part_no && if (part_no == davinci_ids[i].part_no &&
variant == davinci_ids[i].variant) { variant == davinci_ids[i].variant) {
system_rev = davinci_ids[i].type; davinci_revision = davinci_ids[i].type;
break; break;
} }
} }
printk("DaVinci DM%04x variant 0x%x\n", system_rev >> 16, variant); printk(KERN_INFO "DaVinci DM%04x variant 0x%x\n",
davinci_rev(), variant);
} }
/* /*
* linux/include/asm-arm/arch-davinci/cpu.h * DaVinci CPU type detection
* *
* Davinci cpu type detection * Author: Kevin Hilman, Deep Root Systems, LLC
* *
* Author: Steve Chen <schen@mvista.com> * Defines the cpu_is_*() macros for runtime detection of DaVinci
* device type. In addtion, if support for a given device is not
* compiled in to the kernel, the macros return 0 so that
* resulting code can be optimized out.
* *
* 2007 (c) MontaVista Software, Inc. This file is licensed under * 2007 (c) Deep Root Systems, LLC. This file is licensed under
* the terms of the GNU General Public License version 2. This program * the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express * is licensed "as is" without any warranty of any kind, whether express
* or implied. * or implied.
*/ */
#ifndef _ASM_ARCH_CPU_H #ifndef _ASM_ARCH_CPU_H
#define _ASM_ARCH_CPU_H #define _ASM_ARCH_CPU_H
extern unsigned int system_rev; extern unsigned int davinci_rev(void);
#define GET_DAVINCI_CPU_TYPE ((system_rev >> 16) & 0xffff)
#define IS_DAVINCI_CPU(type, id) \ #define IS_DAVINCI_CPU(type, id) \
static inline int cpu_is_davinci_dm ##type (void) \ static inline int is_davinci_dm ##type(void) \
{ \ { \
return (GET_DAVINCI_CPU_TYPE == (id)) ? 1 : 0; \ return (davinci_rev() == (id)) ? 1 : 0; \
} }
/* following generates the cpu_is_davinci_dmxxx */ IS_DAVINCI_CPU(644x, 0x6446)
IS_DAVINCI_CPU(644x, 0x6446) /* cpu_is_davinci_dm644x() */ IS_DAVINCI_CPU(646x, 0x6467)
IS_DAVINCI_CPU(646x, 0x6467) /* cpu_is_davinci_dm646x() */ IS_DAVINCI_CPU(355, 0x355)
IS_DAVINCI_CPU(355, 0x355) /* cpu_is_davinci_dm355() */
#ifdef CONFIG_ARCH_DAVINCI_DM644x
#define cpu_is_davinci_dm644x() is_davinci_dm644x()
#else
#define cpu_is_davinci_dm644x() 0
#endif
#ifdef CONFIG_ARCH_DAVINCI_DM646x
#define cpu_is_davinci_dm646x() is_davinci_dm646x()
#else
#define cpu_is_davinci_dm646x() 0
#endif
#ifdef CONFIG_ARCH_DAVINCI_DM355
#define cpu_is_davinci_dm355() is_davinci_dm355()
#else
#define cpu_is_davinci_dm355() 0
#endif
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment