From: Lokesh Vutla Date: Tue, 28 Jul 2015 08:46:41 +0000 (+0530) Subject: ARM: keystone2: Cleanup SoC detection X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=cfe5f0cda0f39fe833233fdffbac127fd7b3db4e;p=project%2Fbcm63xx%2Fu-boot.git ARM: keystone2: Cleanup SoC detection Add proper register definition for JTAG ID and cleanup cpu_is_* functions. Reviewed-by: Tom Rini Reviewed-by: Vitaly Andrianov Signed-off-by: Lokesh Vutla --- diff --git a/arch/arm/mach-keystone/include/mach/hardware.h b/arch/arm/mach-keystone/include/mach/hardware.h index 16cbcee12b..6082b87a16 100644 --- a/arch/arm/mach-keystone/include/mach/hardware.h +++ b/arch/arm/mach-keystone/include/mach/hardware.h @@ -237,6 +237,17 @@ typedef volatile unsigned int *dv_reg_p; /* SGMII SerDes */ #define KS2_SGMII_SERDES_BASE 0x0232a000 +/* JTAG ID register */ +#define JTAGID_VARIANT_SHIFT 28 +#define JTAGID_VARIANT_MASK (0xf << 28) +#define JTAGID_PART_NUM_SHIFT 12 +#define JTAGID_PART_NUM_MASK (0xffff << 12) + +/* PART NUMBER definitions */ +#define CPU_66AK2Hx 0xb981 +#define CPU_66AK2Ex 0xb9a6 +#define CPU_66AK2Lx 0xb9a7 + #ifdef CONFIG_SOC_K2HK #include #endif @@ -250,34 +261,33 @@ typedef volatile unsigned int *dv_reg_p; #endif #ifndef __ASSEMBLY__ -static inline int cpu_is_k2hk(void) + +static inline u16 get_part_number(void) { - unsigned int jtag_id = __raw_readl(KS2_JTAG_ID_REG); - unsigned int part_no = (jtag_id >> 12) & 0xffff; + u32 jtag_id = __raw_readl(KS2_JTAG_ID_REG); - return (part_no == 0xb981) ? 1 : 0; + return (jtag_id & JTAGID_PART_NUM_MASK) >> JTAGID_PART_NUM_SHIFT; } -static inline int cpu_is_k2e(void) +static inline u8 cpu_is_k2hk(void) { - unsigned int jtag_id = __raw_readl(KS2_JTAG_ID_REG); - unsigned int part_no = (jtag_id >> 12) & 0xffff; - - return (part_no == 0xb9a6) ? 1 : 0; + return get_part_number() == CPU_66AK2Hx; } -static inline int cpu_is_k2l(void) +static inline u8 cpu_is_k2e(void) { - unsigned int jtag_id = __raw_readl(KS2_JTAG_ID_REG); - unsigned int part_no = (jtag_id >> 12) & 0xffff; + return get_part_number() == CPU_66AK2Ex; +} - return (part_no == 0xb9a7) ? 1 : 0; +static inline u8 cpu_is_k2l(void) +{ + return get_part_number() == CPU_66AK2Lx; } -static inline int cpu_revision(void) +static inline u8 cpu_revision(void) { - unsigned int jtag_id = __raw_readl(KS2_JTAG_ID_REG); - unsigned int rev = (jtag_id >> 28) & 0xf; + u32 jtag_id = __raw_readl(KS2_JTAG_ID_REG); + u8 rev = (jtag_id & JTAGID_VARIANT_MASK) >> JTAGID_VARIANT_SHIFT; return rev; }