ARM: uniphier: rework existing DDR PHY code to reuse for LD11 SoC
[oweals/u-boot.git] / arch / arm / mach-uniphier / soc_info.c
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>
9
10 #include "sg-regs.h"
11 #include "soc-info.h"
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_SLD3
21         case 0x25:
22                 ret = SOC_UNIPHIER_SLD3;
23                 break;
24 #endif
25 #ifdef CONFIG_ARCH_UNIPHIER_LD4
26         case 0x26:
27                 ret = SOC_UNIPHIER_LD4;
28                 break;
29 #endif
30 #ifdef CONFIG_ARCH_UNIPHIER_PRO4
31         case 0x28:
32                 ret = SOC_UNIPHIER_PRO4;
33                 break;
34 #endif
35 #ifdef CONFIG_ARCH_UNIPHIER_SLD8
36         case 0x29:
37                 ret = SOC_UNIPHIER_SLD8;
38                 break;
39 #endif
40 #ifdef CONFIG_ARCH_UNIPHIER_PRO5
41         case 0x2A:
42                 ret = SOC_UNIPHIER_PRO5;
43                 break;
44 #endif
45 #ifdef CONFIG_ARCH_UNIPHIER_PXS2
46         case 0x2E:
47                 ret = SOC_UNIPHIER_PXS2;
48                 break;
49 #endif
50 #ifdef CONFIG_ARCH_UNIPHIER_LD6B
51         case 0x2F:
52                 ret = SOC_UNIPHIER_LD6B;
53                 break;
54 #endif
55 #ifdef CONFIG_ARCH_UNIPHIER_LD11
56         case 0x31:
57                 ret = SOC_UNIPHIER_LD11;
58                 break;
59 #endif
60 #ifdef CONFIG_ARCH_UNIPHIER_LD20
61         case 0x32:
62                 ret = SOC_UNIPHIER_LD20;
63                 break;
64 #endif
65         default:
66                 ret = SOC_UNIPHIER_UNKNOWN;
67                 break;
68         }
69
70         return ret;
71 }
72 #endif
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 }