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