Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <linux/io.h> |
| 8 | #include <linux/types.h> |
Masahiro Yamada | 107b3fb | 2016-01-09 01:51:13 +0900 | [diff] [blame] | 9 | |
| 10 | #include "sg-regs.h" |
| 11 | #include "soc-info.h" |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 12 | |
| 13 | #if UNIPHIER_MULTI_SOC |
| 14 | enum uniphier_soc_id uniphier_get_soc_type(void) |
| 15 | { |
| 16 | u32 revision = readl(SG_REVISION); |
| 17 | enum uniphier_soc_id ret; |
| 18 | |
| 19 | switch ((revision & SG_REVISION_TYPE_MASK) >> SG_REVISION_TYPE_SHIFT) { |
| 20 | #ifdef CONFIG_ARCH_UNIPHIER_PH1_SLD3 |
| 21 | case 0x25: |
| 22 | ret = SOC_UNIPHIER_PH1_SLD3; |
| 23 | break; |
| 24 | #endif |
| 25 | #ifdef CONFIG_ARCH_UNIPHIER_PH1_LD4 |
| 26 | case 0x26: |
| 27 | ret = SOC_UNIPHIER_PH1_LD4; |
| 28 | break; |
| 29 | #endif |
| 30 | #ifdef CONFIG_ARCH_UNIPHIER_PH1_PRO4 |
| 31 | case 0x28: |
| 32 | ret = SOC_UNIPHIER_PH1_PRO4; |
| 33 | break; |
| 34 | #endif |
| 35 | #ifdef CONFIG_ARCH_UNIPHIER_PH1_SLD8 |
| 36 | case 0x29: |
| 37 | ret = SOC_UNIPHIER_PH1_SLD8; |
| 38 | break; |
| 39 | #endif |
| 40 | #ifdef CONFIG_ARCH_UNIPHIER_PH1_PRO5 |
| 41 | case 0x2A: |
| 42 | ret = SOC_UNIPHIER_PH1_PRO5; |
| 43 | break; |
| 44 | #endif |
| 45 | #ifdef CONFIG_ARCH_UNIPHIER_PROXSTREAM2 |
| 46 | case 0x2E: |
| 47 | ret = SOC_UNIPHIER_PROXSTREAM2; |
| 48 | break; |
| 49 | #endif |
| 50 | #ifdef CONFIG_ARCH_UNIPHIER_PH1_LD6B |
| 51 | case 0x2F: |
| 52 | ret = SOC_UNIPHIER_PH1_LD6B; |
| 53 | break; |
| 54 | #endif |
Masahiro Yamada | 6f45a97 | 2015-12-17 17:47:45 +0900 | [diff] [blame] | 55 | #ifdef CONFIG_ARCH_UNIPHIER_PH1_SLD11 |
| 56 | case 0x31: |
| 57 | ret = SOC_UNIPHIER_PH1_SLD11; |
| 58 | break; |
| 59 | #endif |
| 60 | #ifdef CONFIG_ARCH_UNIPHIER_PH1_LD10 |
| 61 | case 0x32: |
| 62 | ret = SOC_UNIPHIER_PH1_LD10; |
| 63 | break; |
| 64 | #endif |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 65 | default: |
| 66 | ret = SOC_UNIPHIER_UNKNOWN; |
| 67 | break; |
| 68 | } |
| 69 | |
| 70 | return ret; |
| 71 | } |
| 72 | #endif |
Masahiro Yamada | 2071f14 | 2015-12-17 17:47:41 +0900 | [diff] [blame] | 73 | |
| 74 | int uniphier_get_soc_model(void) |
| 75 | { |
| 76 | return (readl(SG_REVISION) & SG_REVISION_MODEL_MASK) >> |
| 77 | SG_REVISION_MODEL_SHIFT; |
| 78 | } |
| 79 | |
| 80 | int uniphier_get_soc_revision(void) |
| 81 | { |
| 82 | return (readl(SG_REVISION) & SG_REVISION_REV_MASK) >> |
| 83 | SG_REVISION_REV_SHIFT; |
| 84 | } |