1 // SPDX-License-Identifier: GPL-2.0
3 * arch/arm/cpu/armv7/rmobile/cpu_info-rcar.c
5 * Copyright (C) 2013,2014 Renesas Electronics Corporation
10 #define PRR_MASK 0x7fff
11 #define R8A7796_REV_1_0 0x5200
12 #define R8A7796_REV_1_1 0x5210
14 static u32 rmobile_get_prr(void);
16 u32 rmobile_get_cpu_type(void)
18 return (rmobile_get_prr() & 0x00007F00) >> 8;
21 u32 rmobile_get_cpu_rev_integer(void)
23 const u32 prr = rmobile_get_prr();
25 if ((prr & PRR_MASK) == R8A7796_REV_1_1)
28 return ((prr & 0x000000F0) >> 4) + 1;
31 u32 rmobile_get_cpu_rev_fraction(void)
33 const u32 prr = rmobile_get_prr();
35 if ((prr & PRR_MASK) == R8A7796_REV_1_1)
38 return prr & 0x0000000F;
41 #if !CONFIG_IS_ENABLED(DM) || !CONFIG_IS_ENABLED(SYSCON)
42 static u32 rmobile_get_prr(void)
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.
51 return readl(0xFF000044);
59 struct renesas_prr_priv {
67 static u32 rmobile_get_prr(void)
71 map = syscon_get_regmap_by_driver_data(PRR_RCAR);
73 printf("PRR regmap failed!\n");
77 return readl(map->base);
80 static const struct udevice_id renesas_prr_ids[] = {
81 { .compatible = "renesas,prr", .data = PRR_RCAR },
85 U_BOOT_DRIVER(renesas_prr) = {
86 .name = "renesas_prr",
88 .of_match = renesas_prr_ids,
89 .flags = DM_FLAG_PRE_RELOC,