Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 2 | /* |
Nobuhiro Iwamatsu | 091bc06 | 2014-03-28 11:07:39 +0900 | [diff] [blame] | 3 | * arch/arm/cpu/armv7/rmobile/cpu_info-rcar.c |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 4 | * |
Nobuhiro Iwamatsu | 091bc06 | 2014-03-28 11:07:39 +0900 | [diff] [blame] | 5 | * Copyright (C) 2013,2014 Renesas Electronics Corporation |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 6 | */ |
Paul Barker | 442ce1c | 2023-11-01 20:05:53 +0000 | [diff] [blame] | 7 | |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 8 | #include <asm/io.h> |
9 | |||||
Marek Vasut | 14cdf95 | 2017-05-13 15:57:38 +0200 | [diff] [blame] | 10 | #define PRR_MASK 0x7fff |
11 | #define R8A7796_REV_1_0 0x5200 | ||||
12 | #define R8A7796_REV_1_1 0x5210 | ||||
Biju Das | 4e93dc9 | 2020-09-15 15:15:22 +0100 | [diff] [blame] | 13 | #define R8A7796_REV_1_3 0x5211 |
Hai Pham | 289754e | 2021-05-04 17:43:23 +0700 | [diff] [blame] | 14 | #define R8A77995_REV_1_1 0x5810 |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 15 | |
Marek Vasut | e298526 | 2018-10-18 20:28:19 +0200 | [diff] [blame] | 16 | static u32 rmobile_get_prr(void) |
17 | { | ||||
Hai Pham | 9046b5f | 2023-02-28 22:22:03 +0100 | [diff] [blame] | 18 | if (IS_ENABLED(CONFIG_RCAR_64)) |
Marek Vasut | 43f5dc0 | 2023-02-28 07:27:51 +0100 | [diff] [blame] | 19 | return readl(0xFFF00044); |
20 | |||||
Marek Vasut | e298526 | 2018-10-18 20:28:19 +0200 | [diff] [blame] | 21 | return readl(0xFF000044); |
Marek Vasut | e298526 | 2018-10-18 20:28:19 +0200 | [diff] [blame] | 22 | } |
Marek Vasut | ab7899b | 2017-11-09 21:49:48 +0100 | [diff] [blame] | 23 | |
Marek Vasut | 30fe98e | 2024-02-27 17:05:45 +0100 | [diff] [blame^] | 24 | u32 renesas_get_cpu_type(void) |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 25 | { |
Marek Vasut | ab7899b | 2017-11-09 21:49:48 +0100 | [diff] [blame] | 26 | return (rmobile_get_prr() & 0x00007F00) >> 8; |
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 27 | } |
28 | |||||
29 | u32 rmobile_get_cpu_rev_integer(void) | ||||
30 | { | ||||
Marek Vasut | ab7899b | 2017-11-09 21:49:48 +0100 | [diff] [blame] | 31 | const u32 prr = rmobile_get_prr(); |
Biju Das | 4e93dc9 | 2020-09-15 15:15:22 +0100 | [diff] [blame] | 32 | const u32 rev = prr & PRR_MASK; |
Marek Vasut | 14cdf95 | 2017-05-13 15:57:38 +0200 | [diff] [blame] | 33 | |
Hai Pham | 289754e | 2021-05-04 17:43:23 +0700 | [diff] [blame] | 34 | if (rev == R8A7796_REV_1_1 || rev == R8A7796_REV_1_3 || |
35 | rev == R8A77995_REV_1_1) | ||||
Marek Vasut | 14cdf95 | 2017-05-13 15:57:38 +0200 | [diff] [blame] | 36 | return 1; |
37 | else | ||||
38 | return ((prr & 0x000000F0) >> 4) + 1; | ||||
Nobuhiro Iwamatsu | c6ccb47 | 2013-11-21 17:06:45 +0900 | [diff] [blame] | 39 | } |
Nobuhiro Iwamatsu | 520d06d | 2014-03-28 11:15:59 +0900 | [diff] [blame] | 40 | |
41 | u32 rmobile_get_cpu_rev_fraction(void) | ||||
42 | { | ||||
Marek Vasut | ab7899b | 2017-11-09 21:49:48 +0100 | [diff] [blame] | 43 | const u32 prr = rmobile_get_prr(); |
Biju Das | 4e93dc9 | 2020-09-15 15:15:22 +0100 | [diff] [blame] | 44 | const u32 rev = prr & PRR_MASK; |
Marek Vasut | 14cdf95 | 2017-05-13 15:57:38 +0200 | [diff] [blame] | 45 | |
Hai Pham | 289754e | 2021-05-04 17:43:23 +0700 | [diff] [blame] | 46 | if (rev == R8A7796_REV_1_1 || rev == R8A77995_REV_1_1) |
Marek Vasut | 14cdf95 | 2017-05-13 15:57:38 +0200 | [diff] [blame] | 47 | return 1; |
Biju Das | 4e93dc9 | 2020-09-15 15:15:22 +0100 | [diff] [blame] | 48 | else if (rev == R8A7796_REV_1_3) |
49 | return 3; | ||||
Marek Vasut | 14cdf95 | 2017-05-13 15:57:38 +0200 | [diff] [blame] | 50 | else |
51 | return prr & 0x0000000F; | ||||
Nobuhiro Iwamatsu | 520d06d | 2014-03-28 11:15:59 +0900 | [diff] [blame] | 52 | } |