1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * arch/arm/cpu/armv7/rmobile/cpu_info-rcar.c
4  *
5  * Copyright (C) 2013,2014 Renesas Electronics Corporation
6  */
7 #include <common.h>
8 #include <asm/io.h>
9 
10 #define PRR_MASK		0x7fff
11 #define R8A7796_REV_1_0		0x5200
12 #define R8A7796_REV_1_1		0x5210
13 #define R8A7796_REV_1_3		0x5211
14 
rmobile_get_prr(void)15 static u32 rmobile_get_prr(void)
16 {
17 #ifdef CONFIG_RCAR_GEN3
18 	return readl(0xFFF00044);
19 #else
20 	return readl(0xFF000044);
21 #endif
22 }
23 
rmobile_get_cpu_type(void)24 u32 rmobile_get_cpu_type(void)
25 {
26 	return (rmobile_get_prr() & 0x00007F00) >> 8;
27 }
28 
rmobile_get_cpu_rev_integer(void)29 u32 rmobile_get_cpu_rev_integer(void)
30 {
31 	const u32 prr = rmobile_get_prr();
32 	const u32 rev = prr & PRR_MASK;
33 
34 	if (rev == R8A7796_REV_1_1 || rev == R8A7796_REV_1_3)
35 		return 1;
36 	else
37 		return ((prr & 0x000000F0) >> 4) + 1;
38 }
39 
rmobile_get_cpu_rev_fraction(void)40 u32 rmobile_get_cpu_rev_fraction(void)
41 {
42 	const u32 prr = rmobile_get_prr();
43 	const u32 rev = prr & PRR_MASK;
44 
45 	if (rev == R8A7796_REV_1_1)
46 		return 1;
47 	else if (rev == R8A7796_REV_1_3)
48 		return 3;
49 	else
50 		return prr & 0x0000000F;
51 }
52