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