kernel version: 3.0.35
一般linux的通用方法是通过
kernel_imx\include\generated\mach-types.h里的定义
machine_is_mx6q_sabresd 来判断当前是否属于此平台
#ifdef CONFIG_MACH_MX6Q_SABRESD因为有多个平台同时定义,所以machine_arch_type一般都是__machine_arch_type,
# ifdef machine_arch_type
# undef machine_arch_type
# define machine_arch_type __machine_arch_type
# else
# define machine_arch_type MACH_TYPE_MX6Q_SABRESD
# endif
# define machine_is_mx6q_sabresd() (machine_arch_type == MACH_TYPE_MX6Q_SABRESD)
#else
# define machine_is_mx6q_sabresd() (0)
#endif
__machine_arch_type的定义在kernel_imx\arch\arm\kernel\head-common.S
__mmap_switched_data:当时系统开机之后只定义而并没有赋值,imx6q使用了读取硬件寄存器的方法:
......
.long __machine_arch_type @ r5
.long __atags_pointer @ r6
......
kernel_imx\arch\arm\plat-mxc\include\mach\mxc.h
# define cpu_is_mx6q() (mxc_cpu_type == MXC_CPU_MX6Q)kernel_imx\arch\arm\plat-mxc\cpu.c
void mxc_set_cpu_type(unsigned int type)kernel_imx\arch\arm\mach-mx6\mm.c
{
__mxc_cpu_type = type;
}
static void mx6_set_cpu_type(void)That's it!
{
u32 cpu_type = readl(IO_ADDRESS(ANATOP_BASE_ADDR + 0x280));
cpu_type >>= 16;
if (cpu_type == 0x60) {
mxc_set_cpu_type(MXC_CPU_MX6SL);
imx_print_silicon_rev("i.MX6SoloLite", mx6sl_revision());
return;
}
cpu_type = readl(IO_ADDRESS(ANATOP_BASE_ADDR + 0x260));
cpu_type >>= 16;
if (cpu_type == 0x63) {
mxc_set_cpu_type(MXC_CPU_MX6Q);
imx_print_silicon_rev("i.MX6Q", mx6q_revision());
} else if (cpu_type == 0x61) {
mxc_set_cpu_type(MXC_CPU_MX6DL);
imx_print_silicon_rev("i.MX6DL/SOLO", mx6dl_revision());
} else
pr_err("Unknown CPU type: %x\n", cpu_type);
}
Refer to: http://blog.csdn.net/sehrich/article/details/7208752