]> git.ipfire.org Git - people/ms/u-boot.git/blame - arch/arm/mach-rmobile/cpu_info-rcar.c
Merge git://git.denx.de/u-boot-spi
[people/ms/u-boot.git] / arch / arm / mach-rmobile / cpu_info-rcar.c
CommitLineData
1d0e9278 1/*
9b7fa2fe 2 * arch/arm/cpu/armv7/rmobile/cpu_info-rcar.c
1d0e9278 3 *
9b7fa2fe 4 * Copyright (C) 2013,2014 Renesas Electronics Corporation
1d0e9278
NI
5 *
6 * SPDX-License-Identifier: GPL-2.0
7 */
8#include <common.h>
9#include <asm/io.h>
10
e965c890
MV
11#define PRR_MASK 0x7fff
12#define R8A7796_REV_1_0 0x5200
13#define R8A7796_REV_1_1 0x5210
1d0e9278 14
aff151e5
MV
15static u32 rmobile_get_prr(void);
16
1d0e9278
NI
17u32 rmobile_get_cpu_type(void)
18{
aff151e5 19 return (rmobile_get_prr() & 0x00007F00) >> 8;
1d0e9278
NI
20}
21
22u32 rmobile_get_cpu_rev_integer(void)
23{
aff151e5 24 const u32 prr = rmobile_get_prr();
e965c890
MV
25
26 if ((prr & PRR_MASK) == R8A7796_REV_1_1)
27 return 1;
28 else
29 return ((prr & 0x000000F0) >> 4) + 1;
1d0e9278 30}
a028abea
NI
31
32u32 rmobile_get_cpu_rev_fraction(void)
33{
aff151e5 34 const u32 prr = rmobile_get_prr();
e965c890
MV
35
36 if ((prr & PRR_MASK) == R8A7796_REV_1_1)
37 return 1;
38 else
39 return prr & 0x0000000F;
a028abea 40}
aff151e5
MV
41
42#if !CONFIG_IS_ENABLED(DM) || !CONFIG_IS_ENABLED(SYSCON)
43static 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
60struct renesas_prr_priv {
61 fdt_addr_t regs;
62};
63
64enum {
65 PRR_RCAR,
66};
67
68static 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
81static const struct udevice_id renesas_prr_ids[] = {
82 { .compatible = "renesas,prr", .data = PRR_RCAR },
83 { }
84};
85
86U_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