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) { |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 20 | #ifdef CONFIG_ARCH_UNIPHIER_SLD3 |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 21 | case 0x25: |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 22 | ret = SOC_UNIPHIER_SLD3; |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 23 | break; |
| 24 | #endif |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 25 | #ifdef CONFIG_ARCH_UNIPHIER_LD4 |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 26 | case 0x26: |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 27 | ret = SOC_UNIPHIER_LD4; |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 28 | break; |
| 29 | #endif |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 30 | #ifdef CONFIG_ARCH_UNIPHIER_PRO4 |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 31 | case 0x28: |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 32 | ret = SOC_UNIPHIER_PRO4; |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 33 | break; |
| 34 | #endif |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 35 | #ifdef CONFIG_ARCH_UNIPHIER_SLD8 |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 36 | case 0x29: |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 37 | ret = SOC_UNIPHIER_SLD8; |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 38 | break; |
| 39 | #endif |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 40 | #ifdef CONFIG_ARCH_UNIPHIER_PRO5 |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 41 | case 0x2A: |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 42 | ret = SOC_UNIPHIER_PRO5; |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 43 | break; |
| 44 | #endif |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 45 | #ifdef CONFIG_ARCH_UNIPHIER_PXS2 |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 46 | case 0x2E: |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 47 | ret = SOC_UNIPHIER_PXS2; |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 48 | break; |
| 49 | #endif |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 50 | #ifdef CONFIG_ARCH_UNIPHIER_LD6B |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 51 | case 0x2F: |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 52 | ret = SOC_UNIPHIER_LD6B; |
Masahiro Yamada | 323d1f9 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 53 | break; |
| 54 | #endif |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 55 | #ifdef CONFIG_ARCH_UNIPHIER_LD11 |
Masahiro Yamada | 6f45a97 | 2015-12-17 17:47:45 +0900 | [diff] [blame] | 56 | case 0x31: |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 57 | ret = SOC_UNIPHIER_LD11; |
Masahiro Yamada | 6f45a97 | 2015-12-17 17:47:45 +0900 | [diff] [blame] | 58 | break; |
| 59 | #endif |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 60 | #ifdef CONFIG_ARCH_UNIPHIER_LD20 |
Masahiro Yamada | 6f45a97 | 2015-12-17 17:47:45 +0900 | [diff] [blame] | 61 | case 0x32: |
Masahiro Yamada | ea65c98 | 2016-03-18 16:41:43 +0900 | [diff] [blame] | 62 | ret = SOC_UNIPHIER_LD20; |
Masahiro Yamada | 6f45a97 | 2015-12-17 17:47:45 +0900 | [diff] [blame] | 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 | } |