blob: 5bde24ae0e70a8d975f822d8bdb48b3750b5af7a [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Nobuhiro Iwamatsu1d0e9272013-11-21 17:06:45 +09002/*
Nobuhiro Iwamatsu9b7fa2f2014-03-28 11:07:39 +09003 * arch/arm/cpu/armv7/rmobile/cpu_info-rcar.c
Nobuhiro Iwamatsu1d0e9272013-11-21 17:06:45 +09004 *
Nobuhiro Iwamatsu9b7fa2f2014-03-28 11:07:39 +09005 * Copyright (C) 2013,2014 Renesas Electronics Corporation
Nobuhiro Iwamatsu1d0e9272013-11-21 17:06:45 +09006 */
7#include <common.h>
8#include <asm/io.h>
9
Marek Vasute965c892017-05-13 15:57:38 +020010#define PRR_MASK 0x7fff
11#define R8A7796_REV_1_0 0x5200
12#define R8A7796_REV_1_1 0x5210
Biju Das7d791362020-09-15 15:15:22 +010013#define R8A7796_REV_1_3 0x5211
Nobuhiro Iwamatsu1d0e9272013-11-21 17:06:45 +090014
Marek Vasutbd6debb2018-10-18 20:28:19 +020015static u32 rmobile_get_prr(void)
16{
17#ifdef CONFIG_RCAR_GEN3
18 return readl(0xFFF00044);
19#else
20 return readl(0xFF000044);
21#endif
22}
Marek Vasutaff151e2017-11-09 21:49:48 +010023
Nobuhiro Iwamatsu1d0e9272013-11-21 17:06:45 +090024u32 rmobile_get_cpu_type(void)
25{
Marek Vasutaff151e2017-11-09 21:49:48 +010026 return (rmobile_get_prr() & 0x00007F00) >> 8;
Nobuhiro Iwamatsu1d0e9272013-11-21 17:06:45 +090027}
28
29u32 rmobile_get_cpu_rev_integer(void)
30{
Marek Vasutaff151e2017-11-09 21:49:48 +010031 const u32 prr = rmobile_get_prr();
Biju Das7d791362020-09-15 15:15:22 +010032 const u32 rev = prr & PRR_MASK;
Marek Vasute965c892017-05-13 15:57:38 +020033
Biju Das7d791362020-09-15 15:15:22 +010034 if (rev == R8A7796_REV_1_1 || rev == R8A7796_REV_1_3)
Marek Vasute965c892017-05-13 15:57:38 +020035 return 1;
36 else
37 return ((prr & 0x000000F0) >> 4) + 1;
Nobuhiro Iwamatsu1d0e9272013-11-21 17:06:45 +090038}
Nobuhiro Iwamatsua028abe2014-03-28 11:15:59 +090039
40u32 rmobile_get_cpu_rev_fraction(void)
41{
Marek Vasutaff151e2017-11-09 21:49:48 +010042 const u32 prr = rmobile_get_prr();
Biju Das7d791362020-09-15 15:15:22 +010043 const u32 rev = prr & PRR_MASK;
Marek Vasute965c892017-05-13 15:57:38 +020044
Biju Das7d791362020-09-15 15:15:22 +010045 if (rev == R8A7796_REV_1_1)
Marek Vasute965c892017-05-13 15:57:38 +020046 return 1;
Biju Das7d791362020-09-15 15:15:22 +010047 else if (rev == R8A7796_REV_1_3)
48 return 3;
Marek Vasute965c892017-05-13 15:57:38 +020049 else
50 return prr & 0x0000000F;
Nobuhiro Iwamatsua028abe2014-03-28 11:15:59 +090051}