[U-Boot] [PATCH 1/8] ARM: keystone2: Cleanup SoC detection

Vitaly Andrianov vitalya at ti.com
Wed Jul 22 17:54:43 CEST 2015



On 07/22/2015 11:39 AM, Lokesh Vutla wrote:
> Add proper register definition for JTAG ID and
> cleanup cpu_is_* functions.
>
> Signed-off-by: Lokesh Vutla <lokeshvutla at ti.com>
> ---
>   arch/arm/mach-keystone/include/mach/hardware.h | 42 ++++++++++++++++----------
>   1 file changed, 26 insertions(+), 16 deletions(-)
>
> diff --git a/arch/arm/mach-keystone/include/mach/hardware.h b/arch/arm/mach-keystone/include/mach/hardware.h
> index 16cbcee..15c25b1 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 <asm/arch/hardware-k2hk.h>
>   #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;
>   }
>
Reviewed-by: Vitaly Andrianov <vitalya at ti.com>


More information about the U-Boot mailing list