blob: ce9312f9d8286e434925efdbe48c164f96c42d19 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Nobuhiro Iwamatsuc6ccb472013-11-21 17:06:45 +09002/*
Nobuhiro Iwamatsu091bc062014-03-28 11:07:39 +09003 * arch/arm/cpu/armv7/rmobile/cpu_info-rcar.c
Nobuhiro Iwamatsuc6ccb472013-11-21 17:06:45 +09004 *
Nobuhiro Iwamatsu091bc062014-03-28 11:07:39 +09005 * Copyright (C) 2013,2014 Renesas Electronics Corporation
Nobuhiro Iwamatsuc6ccb472013-11-21 17:06:45 +09006 */
7#include <common.h>
8#include <asm/io.h>
9
Marek Vasut14cdf952017-05-13 15:57:38 +020010#define PRR_MASK 0x7fff
11#define R8A7796_REV_1_0 0x5200
12#define R8A7796_REV_1_1 0x5210
Nobuhiro Iwamatsuc6ccb472013-11-21 17:06:45 +090013
Marek Vasute2985262018-10-18 20:28:19 +020014static u32 rmobile_get_prr(void)
15{
16#ifdef CONFIG_RCAR_GEN3
17 return readl(0xFFF00044);
18#else
19 return readl(0xFF000044);
20#endif
21}
Marek Vasutab7899b2017-11-09 21:49:48 +010022
Nobuhiro Iwamatsuc6ccb472013-11-21 17:06:45 +090023u32 rmobile_get_cpu_type(void)
24{
Marek Vasutab7899b2017-11-09 21:49:48 +010025 return (rmobile_get_prr() & 0x00007F00) >> 8;
Nobuhiro Iwamatsuc6ccb472013-11-21 17:06:45 +090026}
27
28u32 rmobile_get_cpu_rev_integer(void)
29{
Marek Vasutab7899b2017-11-09 21:49:48 +010030 const u32 prr = rmobile_get_prr();
Marek Vasut14cdf952017-05-13 15:57:38 +020031
32 if ((prr & PRR_MASK) == R8A7796_REV_1_1)
33 return 1;
34 else
35 return ((prr & 0x000000F0) >> 4) + 1;
Nobuhiro Iwamatsuc6ccb472013-11-21 17:06:45 +090036}
Nobuhiro Iwamatsu520d06d2014-03-28 11:15:59 +090037
38u32 rmobile_get_cpu_rev_fraction(void)
39{
Marek Vasutab7899b2017-11-09 21:49:48 +010040 const u32 prr = rmobile_get_prr();
Marek Vasut14cdf952017-05-13 15:57:38 +020041
42 if ((prr & PRR_MASK) == R8A7796_REV_1_1)
43 return 1;
44 else
45 return prr & 0x0000000F;
Nobuhiro Iwamatsu520d06d2014-03-28 11:15:59 +090046}