blob: 74140fd38abd21d5e8d763f9bec45da7292cf389 [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/*
Marek Vasutf252dfb2024-02-27 17:05:57 +01003 * arch/arm/mach-renesas/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 */
Paul Barker93565cc2023-11-01 20:05:53 +00007
Nobuhiro Iwamatsu1d0e9272013-11-21 17:06:45 +09008#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
Hai Pham13c8a072021-05-04 17:43:23 +070014#define R8A77995_REV_1_1 0x5810
Nobuhiro Iwamatsu1d0e9272013-11-21 17:06:45 +090015
Marek Vasut82026c42024-02-27 17:05:51 +010016static u32 renesas_get_prr(void)
Marek Vasutbd6debb2018-10-18 20:28:19 +020017{
Hai Pham5a3b0742023-02-28 22:22:03 +010018 if (IS_ENABLED(CONFIG_RCAR_64))
Marek Vasut7fe9d7d2023-02-28 07:27:51 +010019 return readl(0xFFF00044);
20
Marek Vasutbd6debb2018-10-18 20:28:19 +020021 return readl(0xFF000044);
Marek Vasutbd6debb2018-10-18 20:28:19 +020022}
Marek Vasutaff151e2017-11-09 21:49:48 +010023
Marek Vasut6bd3a952024-02-27 17:05:45 +010024u32 renesas_get_cpu_type(void)
Nobuhiro Iwamatsu1d0e9272013-11-21 17:06:45 +090025{
Marek Vasut82026c42024-02-27 17:05:51 +010026 return (renesas_get_prr() & 0x00007F00) >> 8;
Nobuhiro Iwamatsu1d0e9272013-11-21 17:06:45 +090027}
28
Marek Vasutca40ed62024-02-27 17:05:46 +010029u32 renesas_get_cpu_rev_integer(void)
Nobuhiro Iwamatsu1d0e9272013-11-21 17:06:45 +090030{
Marek Vasut82026c42024-02-27 17:05:51 +010031 const u32 prr = renesas_get_prr();
Biju Das7d791362020-09-15 15:15:22 +010032 const u32 rev = prr & PRR_MASK;
Marek Vasute965c892017-05-13 15:57:38 +020033
Hai Pham13c8a072021-05-04 17:43:23 +070034 if (rev == R8A7796_REV_1_1 || rev == R8A7796_REV_1_3 ||
35 rev == R8A77995_REV_1_1)
Marek Vasute965c892017-05-13 15:57:38 +020036 return 1;
37 else
38 return ((prr & 0x000000F0) >> 4) + 1;
Nobuhiro Iwamatsu1d0e9272013-11-21 17:06:45 +090039}
Nobuhiro Iwamatsua028abe2014-03-28 11:15:59 +090040
Marek Vasutca40ed62024-02-27 17:05:46 +010041u32 renesas_get_cpu_rev_fraction(void)
Nobuhiro Iwamatsua028abe2014-03-28 11:15:59 +090042{
Marek Vasut82026c42024-02-27 17:05:51 +010043 const u32 prr = renesas_get_prr();
Biju Das7d791362020-09-15 15:15:22 +010044 const u32 rev = prr & PRR_MASK;
Marek Vasute965c892017-05-13 15:57:38 +020045
Hai Pham13c8a072021-05-04 17:43:23 +070046 if (rev == R8A7796_REV_1_1 || rev == R8A77995_REV_1_1)
Marek Vasute965c892017-05-13 15:57:38 +020047 return 1;
Biju Das7d791362020-09-15 15:15:22 +010048 else if (rev == R8A7796_REV_1_3)
49 return 3;
Marek Vasute965c892017-05-13 15:57:38 +020050 else
51 return prr & 0x0000000F;
Nobuhiro Iwamatsua028abe2014-03-28 11:15:59 +090052}