arm64: kernel: add MPIDR_EL1 accessors macros
authorLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Mon, 5 Aug 2013 14:24:27 +0000 (15:24 +0100)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Mon, 16 Dec 2013 17:17:29 +0000 (17:17 +0000)
In order to simplify access to different affinity levels within the
MPIDR_EL1 register values, this patch implements some preprocessor
macros that allow to retrieve the MPIDR_EL1 affinity level value according
to the level passed as input parameter.

Reviewed-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
arch/arm64/include/asm/cputype.h

index 5fe138e0b828f130e55bd93b56e9d9e8492f1060..e371936b8ab2ed2a66a73a3f148af16bba50a40b 100644 (file)
 
 #define MPIDR_HWID_BITMASK     0xff00ffffff
 
+#define MPIDR_LEVEL_BITS_SHIFT 3
+#define MPIDR_LEVEL_BITS       (1 << MPIDR_LEVEL_BITS_SHIFT)
+#define MPIDR_LEVEL_MASK       ((1 << MPIDR_LEVEL_BITS) - 1)
+
+#define MPIDR_LEVEL_SHIFT(level) \
+       (((1 << level) >> 1) << MPIDR_LEVEL_BITS_SHIFT)
+
+#define MPIDR_AFFINITY_LEVEL(mpidr, level) \
+       ((mpidr >> MPIDR_LEVEL_SHIFT(level)) & MPIDR_LEVEL_MASK)
+
 #define read_cpuid(reg) ({                                             \
        u64 __val;                                                      \
        asm("mrs        %0, " reg : "=r" (__val));                      \