]> git.sur5r.net Git - u-boot/blob - arch/arm/mach-rmobile/cpu_info-rcar.c
SPDX: Convert all of our single license tags to Linux Kernel style
[u-boot] / arch / arm / mach-rmobile / cpu_info-rcar.c
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
14 static u32 rmobile_get_prr(void);
15
16 u32 rmobile_get_cpu_type(void)
17 {
18         return (rmobile_get_prr() & 0x00007F00) >> 8;
19 }
20
21 u32 rmobile_get_cpu_rev_integer(void)
22 {
23         const u32 prr = rmobile_get_prr();
24
25         if ((prr & PRR_MASK) == R8A7796_REV_1_1)
26                 return 1;
27         else
28                 return ((prr & 0x000000F0) >> 4) + 1;
29 }
30
31 u32 rmobile_get_cpu_rev_fraction(void)
32 {
33         const u32 prr = rmobile_get_prr();
34
35         if ((prr & PRR_MASK) == R8A7796_REV_1_1)
36                 return 1;
37         else
38                 return prr & 0x0000000F;
39 }
40
41 #if !CONFIG_IS_ENABLED(DM) || !CONFIG_IS_ENABLED(SYSCON)
42 static u32 rmobile_get_prr(void)
43 {
44         /*
45          * On RCar/RMobile Gen2 and older systems, the PRR is always
46          * located at the address below. On newer systems, the PRR
47          * may be located at different address, but that information
48          * is obtained from DT. This code will be removed when all
49          * of the older systems get converted to DM and OF control.
50          */
51         return readl(0xFF000044);
52 }
53 #else
54
55 #include <dm.h>
56 #include <syscon.h>
57 #include <regmap.h>
58
59 struct renesas_prr_priv {
60         fdt_addr_t      regs;
61 };
62
63 enum {
64         PRR_RCAR,
65 };
66
67 static u32 rmobile_get_prr(void)
68 {
69         struct regmap *map;
70
71         map = syscon_get_regmap_by_driver_data(PRR_RCAR);
72         if (!map) {
73                 printf("PRR regmap failed!\n");
74                 hang();
75         }
76
77         return readl(map->base);
78 }
79
80 static const struct udevice_id renesas_prr_ids[] = {
81         { .compatible = "renesas,prr", .data = PRR_RCAR },
82         { }
83 };
84
85 U_BOOT_DRIVER(renesas_prr) = {
86         .name   = "renesas_prr",
87         .id     = UCLASS_SYSCON,
88         .of_match = renesas_prr_ids,
89         .flags  = DM_FLAG_PRE_RELOC,
90 };
91 #endif