Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2017 Socionext Inc. |
| 4 | * Author: Masahiro Yamada <yamada.masahiro@socionext.com> |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <linux/io.h> |
| 8 | #include <linux/types.h> |
| 9 | |
| 10 | #include "sg-regs.h" |
| 11 | #include "soc-info.h" |
| 12 | |
| 13 | static unsigned int __uniphier_get_revision_field(unsigned int mask, |
| 14 | unsigned int shift) |
| 15 | { |
Masahiro Yamada | d41b358 | 2019-07-10 20:07:40 +0900 | [diff] [blame] | 16 | u32 revision = readl(sg_base + SG_REVISION); |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 17 | |
| 18 | return (revision >> shift) & mask; |
| 19 | } |
| 20 | |
| 21 | unsigned int uniphier_get_soc_id(void) |
| 22 | { |
| 23 | return __uniphier_get_revision_field(0xff, 16); |
| 24 | } |
| 25 | |
| 26 | unsigned int uniphier_get_soc_model(void) |
| 27 | { |
Masahiro Yamada | c5bd411 | 2017-05-09 17:14:55 +0900 | [diff] [blame] | 28 | return __uniphier_get_revision_field(0x7, 8); |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | unsigned int uniphier_get_soc_revision(void) |
| 32 | { |
| 33 | return __uniphier_get_revision_field(0x1f, 0); |
| 34 | } |