Hello!
How can I get CPU ID, e.g. iMX53/1, from user-space?
I can parse /proc/cpuinfo but this is not very, I think, good way.
Thank you and excuse me my bad english.
First of all, Why do you think "parsing /proc/cpuinfo" is not a good way?
I'm not sure if this is any help but there is a file rootfs/usr/include/vpu_lib.h which might give some clues how to do this.
I've never looked at this to see if or how it works, I just remember I edited it once to fix some compiler warnings. In that file are some macros that use an externally defined variable "system_rev", I don't know where that comes from or what's really in it but looking at the macros it seems to contain CPU info. These macros are used in the mxc_vpu_test sample to identify CPU type. This is what's in the file (with my small casts mod):
extern unsigned int system_rev;
#define CHIP_REV_1_0 0x10
#define CHIP_REV_2_0 0x20
#define CHIP_REV_2_1 0x21
#define mxc_cpu() (system_rev >> 12)
#define mxc_is_cpu(part) ((mxc_cpu() == part) ? 1 : 0)
#define mxc_cpu_rev() (system_rev & 0xFF)
// SRG 9-5-12 added casts to unsigned int to fix signed comparison warning
#define mxc_cpu_is_rev(rev) \
((mxc_cpu_rev() == (unsigned int)rev) ? 1 : ((mxc_cpu_rev() < (unsigned int)rev) ? -1 : 2))
#define MXC_REV(type) \
static inline int type## _rev (int rev) \
{ \
return (type() ? mxc_cpu_is_rev(rev) : 0); \
}
#define cpu_is_mx27() mxc_is_cpu(0x27)
#define cpu_is_mx51() mxc_is_cpu(0x51)
#define cpu_is_mx53() mxc_is_cpu(0x53)
#define cpu_is_mx5x() (mxc_is_cpu(0x51) || mxc_is_cpu(0x53))
#define cpu_is_mx6q() mxc_is_cpu(0x63)
MXC_REV(cpu_is_mx27);