Commit e27d6c7d328caf75bd7680109bc6610bc681f46e

Authored by Masahiro Yamada
1 parent d9a70368db

ARM: uniphier: simplify SoC ID get function

Currently, uniphier_get_soc_type() converts the SoC ID (this is
read from the revision register) to an enum symbol to use it for SoC
identification.  Come to think of it, there is no need for the
conversion in the first place.  Using the SoC ID from the register
as-is a straightforward way.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Showing 17 changed files with 214 additions and 317 deletions Side-by-side Diff

arch/arm/mach-uniphier/Makefile
... ... @@ -10,7 +10,7 @@
10 10  
11 11 else
12 12  
13   -obj-$(CONFIG_DISPLAY_CPUINFO) += cpu_info.o
  13 +obj-$(CONFIG_DISPLAY_CPUINFO) += cpu-info.o
14 14 obj-y += dram_init.o
15 15 obj-y += board_init.o
16 16 obj-$(CONFIG_BOARD_LATE_INIT) += board_late_init.o
... ... @@ -22,7 +22,7 @@
22 22 endif
23 23  
24 24 obj-y += boards.o
25   -obj-y += soc_info.o
  25 +obj-y += soc-info.o
26 26 obj-y += boot-mode/
27 27 obj-y += clk/
28 28 obj-y += dram/
arch/arm/mach-uniphier/arm32/psci.c
... ... @@ -28,13 +28,13 @@
28 28  
29 29 static int uniphier_get_nr_cpus(void)
30 30 {
31   - switch (uniphier_get_soc_type()) {
32   - case SOC_UNIPHIER_SLD3:
33   - case SOC_UNIPHIER_PRO4:
34   - case SOC_UNIPHIER_PRO5:
  31 + switch (uniphier_get_soc_id()) {
  32 + case UNIPHIER_SLD3_ID:
  33 + case UNIPHIER_PRO4_ID:
  34 + case UNIPHIER_PRO5_ID:
35 35 return 2;
36   - case SOC_UNIPHIER_PXS2:
37   - case SOC_UNIPHIER_LD6B:
  36 + case UNIPHIER_PXS2_ID:
  37 + case UNIPHIER_LD6B_ID:
38 38 return 4;
39 39 default:
40 40 return 1;
arch/arm/mach-uniphier/board_init.c
... ... @@ -80,7 +80,7 @@
80 80 #endif
81 81  
82 82 struct uniphier_initdata {
83   - enum uniphier_soc_id soc_id;
  83 + unsigned int soc_id;
84 84 bool nand_2cs;
85 85 void (*sbc_init)(void);
86 86 void (*pll_init)(void);
... ... @@ -91,7 +91,7 @@
91 91 static const struct uniphier_initdata uniphier_initdata[] = {
92 92 #if defined(CONFIG_ARCH_UNIPHIER_SLD3)
93 93 {
94   - .soc_id = SOC_UNIPHIER_SLD3,
  94 + .soc_id = UNIPHIER_SLD3_ID,
95 95 .nand_2cs = true,
96 96 .sbc_init = uniphier_sbc_init_admulti,
97 97 .pll_init = uniphier_sld3_pll_init,
... ... @@ -100,7 +100,7 @@
100 100 #endif
101 101 #if defined(CONFIG_ARCH_UNIPHIER_LD4)
102 102 {
103   - .soc_id = SOC_UNIPHIER_LD4,
  103 + .soc_id = UNIPHIER_LD4_ID,
104 104 .nand_2cs = true,
105 105 .sbc_init = uniphier_ld4_sbc_init,
106 106 .pll_init = uniphier_ld4_pll_init,
... ... @@ -109,7 +109,7 @@
109 109 #endif
110 110 #if defined(CONFIG_ARCH_UNIPHIER_PRO4)
111 111 {
112   - .soc_id = SOC_UNIPHIER_PRO4,
  112 + .soc_id = UNIPHIER_PRO4_ID,
113 113 .nand_2cs = false,
114 114 .sbc_init = uniphier_sbc_init_savepin,
115 115 .pll_init = uniphier_pro4_pll_init,
... ... @@ -118,7 +118,7 @@
118 118 #endif
119 119 #if defined(CONFIG_ARCH_UNIPHIER_SLD8)
120 120 {
121   - .soc_id = SOC_UNIPHIER_SLD8,
  121 + .soc_id = UNIPHIER_SLD8_ID,
122 122 .nand_2cs = true,
123 123 .sbc_init = uniphier_ld4_sbc_init,
124 124 .pll_init = uniphier_ld4_pll_init,
... ... @@ -127,7 +127,7 @@
127 127 #endif
128 128 #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
129 129 {
130   - .soc_id = SOC_UNIPHIER_PRO5,
  130 + .soc_id = UNIPHIER_PRO5_ID,
131 131 .nand_2cs = true,
132 132 .sbc_init = uniphier_sbc_init_savepin,
133 133 .clk_init = uniphier_pro5_clk_init,
... ... @@ -135,7 +135,7 @@
135 135 #endif
136 136 #if defined(CONFIG_ARCH_UNIPHIER_PXS2)
137 137 {
138   - .soc_id = SOC_UNIPHIER_PXS2,
  138 + .soc_id = UNIPHIER_PXS2_ID,
139 139 .nand_2cs = true,
140 140 .sbc_init = uniphier_pxs2_sbc_init,
141 141 .clk_init = uniphier_pxs2_clk_init,
... ... @@ -143,7 +143,7 @@
143 143 #endif
144 144 #if defined(CONFIG_ARCH_UNIPHIER_LD6B)
145 145 {
146   - .soc_id = SOC_UNIPHIER_LD6B,
  146 + .soc_id = UNIPHIER_LD6B_ID,
147 147 .nand_2cs = true,
148 148 .sbc_init = uniphier_pxs2_sbc_init,
149 149 .clk_init = uniphier_pxs2_clk_init,
... ... @@ -151,7 +151,7 @@
151 151 #endif
152 152 #if defined(CONFIG_ARCH_UNIPHIER_LD11)
153 153 {
154   - .soc_id = SOC_UNIPHIER_LD11,
  154 + .soc_id = UNIPHIER_LD11_ID,
155 155 .nand_2cs = false,
156 156 .sbc_init = uniphier_ld11_sbc_init,
157 157 .pll_init = uniphier_ld11_pll_init,
... ... @@ -161,7 +161,7 @@
161 161 #endif
162 162 #if defined(CONFIG_ARCH_UNIPHIER_LD20)
163 163 {
164   - .soc_id = SOC_UNIPHIER_LD20,
  164 + .soc_id = UNIPHIER_LD20_ID,
165 165 .nand_2cs = false,
166 166 .sbc_init = uniphier_ld11_sbc_init,
167 167 .pll_init = uniphier_ld20_pll_init,
... ... @@ -171,7 +171,7 @@
171 171 };
172 172  
173 173 static const struct uniphier_initdata *uniphier_get_initdata(
174   - enum uniphier_soc_id soc_id)
  174 + unsigned int soc_id)
175 175 {
176 176 int i;
177 177  
178 178  
... ... @@ -186,12 +186,12 @@
186 186 int board_init(void)
187 187 {
188 188 const struct uniphier_initdata *initdata;
189   - enum uniphier_soc_id soc_id;
  189 + unsigned int soc_id;
190 190 int ret;
191 191  
192 192 led_puts("U0");
193 193  
194   - soc_id = uniphier_get_soc_type();
  194 + soc_id = uniphier_get_soc_id();
195 195 initdata = uniphier_get_initdata(soc_id);
196 196 if (!initdata) {
197 197 pr_err("unsupported board\n");
arch/arm/mach-uniphier/boot-mode/boot-mode-ld20.c
1 1 /*
2   - * Copyright (C) 2016 Masahiro Yamada <yamada.masahiro@socionext.com>
  2 + * Copyright (C) 2016-2017 Socionext Inc.
  3 + * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
3 4 *
4 5 * SPDX-License-Identifier: GPL-2.0+
5 6 */
6 7  
7 8  
... ... @@ -57,14 +58,14 @@
57 58 int boot_mode;
58 59 u32 usb_boot_mask;
59 60  
60   - switch (uniphier_get_soc_type()) {
  61 + switch (uniphier_get_soc_id()) {
61 62 #if defined(CONFIG_ARCH_UNIPHIER_LD11)
62   - case SOC_UNIPHIER_LD11:
  63 + case UNIPHIER_LD11_ID:
63 64 usb_boot_mask = 0x00000080;
64 65 break;
65 66 #endif
66 67 #if defined(CONFIG_ARCH_UNIPHIER_LD20)
67   - case SOC_UNIPHIER_LD20:
  68 + case UNIPHIER_LD20_ID:
68 69 usb_boot_mask = 0x00000780;
69 70 break;
70 71 #endif
arch/arm/mach-uniphier/boot-mode/boot-mode.c
... ... @@ -18,30 +18,30 @@
18 18 if (boot_is_swapped())
19 19 return BOOT_DEVICE_NOR;
20 20  
21   - switch (uniphier_get_soc_type()) {
  21 + switch (uniphier_get_soc_id()) {
22 22 #if defined(CONFIG_ARCH_UNIPHIER_SLD3)
23   - case SOC_UNIPHIER_SLD3:
  23 + case UNIPHIER_SLD3_ID:
24 24 return uniphier_sld3_boot_device();
25 25 #endif
26 26 #if defined(CONFIG_ARCH_UNIPHIER_LD4) || defined(CONFIG_ARCH_UNIPHIER_PRO4) || \
27 27 defined(CONFIG_ARCH_UNIPHIER_SLD8)
28   - case SOC_UNIPHIER_LD4:
29   - case SOC_UNIPHIER_PRO4:
30   - case SOC_UNIPHIER_SLD8:
  28 + case UNIPHIER_LD4_ID:
  29 + case UNIPHIER_PRO4_ID:
  30 + case UNIPHIER_SLD8_ID:
31 31 return uniphier_ld4_boot_device();
32 32 #endif
33 33 #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
34   - case SOC_UNIPHIER_PRO5:
  34 + case UNIPHIER_PRO5_ID:
35 35 return uniphier_pro5_boot_device();
36 36 #endif
37 37 #if defined(CONFIG_ARCH_UNIPHIER_PXS2) || defined(CONFIG_ARCH_UNIPHIER_LD6B)
38   - case SOC_UNIPHIER_PXS2:
39   - case SOC_UNIPHIER_LD6B:
  38 + case UNIPHIER_PXS2_ID:
  39 + case UNIPHIER_LD6B_ID:
40 40 return uniphier_pxs2_boot_device();
41 41 #endif
42 42 #if defined(CONFIG_ARCH_UNIPHIER_LD11) || defined(CONFIG_ARCH_UNIPHIER_LD20)
43   - case SOC_UNIPHIER_LD11:
44   - case SOC_UNIPHIER_LD20:
  43 + case UNIPHIER_LD11_ID:
  44 + case UNIPHIER_LD20_ID:
45 45 return uniphier_ld20_boot_device();
46 46 #endif
47 47 default:
48 48  
49 49  
... ... @@ -55,17 +55,17 @@
55 55  
56 56 mode = spl_boot_device_raw();
57 57  
58   - switch (uniphier_get_soc_type()) {
  58 + switch (uniphier_get_soc_id()) {
59 59 #if defined(CONFIG_ARCH_UNIPHIER_PXS2) || defined(CONFIG_ARCH_UNIPHIER_LD6B)
60   - case SOC_UNIPHIER_PXS2:
61   - case SOC_UNIPHIER_LD6B:
  60 + case UNIPHIER_PXS2_ID:
  61 + case UNIPHIER_LD6B_ID:
62 62 if (mode == BOOT_DEVICE_USB)
63 63 mode = BOOT_DEVICE_NOR;
64 64 break;
65 65 #endif
66 66 #if defined(CONFIG_ARCH_UNIPHIER_LD11) || defined(CONFIG_ARCH_UNIPHIER_LD20)
67   - case SOC_UNIPHIER_LD11:
68   - case SOC_UNIPHIER_LD20:
  67 + case UNIPHIER_LD11_ID:
  68 + case UNIPHIER_LD20_ID:
69 69 if (mode == BOOT_DEVICE_MMC1 || mode == BOOT_DEVICE_USB)
70 70 mode = BOOT_DEVICE_BOARD;
71 71 break;
arch/arm/mach-uniphier/boot-mode/cmd_pinmon.c
... ... @@ -14,34 +14,34 @@
14 14 {
15 15 printf("Boot Swap: %s\n\n", boot_is_swapped() ? "ON" : "OFF");
16 16  
17   - switch (uniphier_get_soc_type()) {
  17 + switch (uniphier_get_soc_id()) {
18 18 #if defined(CONFIG_ARCH_UNIPHIER_SLD3)
19   - case SOC_UNIPHIER_SLD3:
  19 + case UNIPHIER_SLD3_ID:
20 20 uniphier_sld3_boot_mode_show();
21 21 break;
22 22 #endif
23 23 #if defined(CONFIG_ARCH_UNIPHIER_LD4) || defined(CONFIG_ARCH_UNIPHIER_PRO4) || \
24 24 defined(CONFIG_ARCH_UNIPHIER_SLD8)
25   - case SOC_UNIPHIER_LD4:
26   - case SOC_UNIPHIER_PRO4:
27   - case SOC_UNIPHIER_SLD8:
  25 + case UNIPHIER_LD4_ID:
  26 + case UNIPHIER_PRO4_ID:
  27 + case UNIPHIER_SLD8_ID:
28 28 uniphier_ld4_boot_mode_show();
29 29 break;
30 30 #endif
31 31 #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
32   - case SOC_UNIPHIER_PRO5:
  32 + case UNIPHIER_PRO5_ID:
33 33 uniphier_pro5_boot_mode_show();
34 34 break;
35 35 #endif
36 36 #if defined(CONFIG_ARCH_UNIPHIER_PXS2) || defined(CONFIG_ARCH_UNIPHIER_LD6B)
37   - case SOC_UNIPHIER_PXS2:
38   - case SOC_UNIPHIER_LD6B:
  37 + case UNIPHIER_PXS2_ID:
  38 + case UNIPHIER_LD6B_ID:
39 39 uniphier_pxs2_boot_mode_show();
40 40 break;
41 41 #endif
42 42 #if defined(CONFIG_ARCH_UNIPHIER_LD11) || defined(CONFIG_ARCH_UNIPHIER_LD20)
43   - case SOC_UNIPHIER_LD11:
44   - case SOC_UNIPHIER_LD20:
  43 + case UNIPHIER_LD11_ID:
  44 + case UNIPHIER_LD20_ID:
45 45 uniphier_ld20_boot_mode_show();
46 46 break;
47 47 #endif
arch/arm/mach-uniphier/boot-mode/spl_board.c
... ... @@ -40,11 +40,11 @@
40 40 {
41 41 const struct uniphier_romfunc_table *table;
42 42  
43   - switch (uniphier_get_soc_type()) {
44   - case SOC_UNIPHIER_LD11:
  43 + switch (uniphier_get_soc_id()) {
  44 + case UNIPHIER_LD11_ID:
45 45 table = &uniphier_ld11_romfunc_table;
46 46 break;
47   - case SOC_UNIPHIER_LD20:
  47 + case UNIPHIER_LD20_ID:
48 48 table = &uniphier_ld20_romfunc_table;
49 49 break;
50 50 default:
arch/arm/mach-uniphier/cpu-info.c
  1 +/*
  2 + * Copyright (C) 2013-2014 Panasonic Corporation
  3 + * Copyright (C) 2015-2017 Socionext Inc.
  4 + * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
  5 + *
  6 + * SPDX-License-Identifier: GPL-2.0+
  7 + */
  8 +
  9 +#include <common.h>
  10 +#include <linux/errno.h>
  11 +#include <linux/io.h>
  12 +
  13 +#include "soc-info.h"
  14 +
  15 +int print_cpuinfo(void)
  16 +{
  17 + unsigned int id, model, rev, required_model = 1, required_rev = 1;
  18 +
  19 + id = uniphier_get_soc_id();
  20 + model = uniphier_get_soc_model();
  21 + rev = uniphier_get_soc_revision();
  22 +
  23 + puts("CPU: ");
  24 +
  25 + switch (id) {
  26 + case UNIPHIER_SLD3_ID:
  27 + puts("sLD3 (MN2WS0220)");
  28 + required_model = 2;
  29 + break;
  30 + case UNIPHIER_LD4_ID:
  31 + puts("LD4 (MN2WS0250)");
  32 + required_rev = 2;
  33 + break;
  34 + case UNIPHIER_PRO4_ID:
  35 + puts("Pro4 (MN2WS0230)");
  36 + break;
  37 + case UNIPHIER_SLD8_ID:
  38 + puts("sLD8 (MN2WS0270)");
  39 + break;
  40 + case UNIPHIER_PRO5_ID:
  41 + puts("Pro5 (MN2WS0300)");
  42 + break;
  43 + case UNIPHIER_PXS2_ID:
  44 + puts("PXs2 (MN2WS0310)");
  45 + break;
  46 + case UNIPHIER_LD6B_ID:
  47 + puts("LD6b (MN2WS0320)");
  48 + break;
  49 + case UNIPHIER_LD11_ID:
  50 + puts("LD11 (SC1405AP1)");
  51 + break;
  52 + case UNIPHIER_LD20_ID:
  53 + puts("LD20 (SC1401AJ1)");
  54 + break;
  55 + default:
  56 + printf("Unknown Processor ID (0x%x)\n", id);
  57 + return -ENOTSUPP;
  58 + }
  59 +
  60 + printf(" model %d (revision %d)\n", model, rev);
  61 +
  62 + if (model < required_model) {
  63 + printf("Only model %d or newer is supported.\n",
  64 + required_model);
  65 + return -ENOTSUPP;
  66 + } else if (rev < required_rev) {
  67 + printf("Only revision %d or newer is supported.\n",
  68 + required_rev);
  69 + return -ENOTSUPP;
  70 + }
  71 +
  72 + return 0;
  73 +}
arch/arm/mach-uniphier/cpu_info.c
1   -/*
2   - * Copyright (C) 2013-2015 Masahiro Yamada <yamada.masahiro@socionext.com>
3   - *
4   - * SPDX-License-Identifier: GPL-2.0+
5   - */
6   -
7   -#include <common.h>
8   -#include <linux/io.h>
9   -
10   -#include "sg-regs.h"
11   -
12   -int print_cpuinfo(void)
13   -{
14   - u32 revision, type, model, rev, required_model = 1, required_rev = 1;
15   -
16   - revision = readl(SG_REVISION);
17   - type = (revision & SG_REVISION_TYPE_MASK) >> SG_REVISION_TYPE_SHIFT;
18   - model = (revision & SG_REVISION_MODEL_MASK) >> SG_REVISION_MODEL_SHIFT;
19   - rev = (revision & SG_REVISION_REV_MASK) >> SG_REVISION_REV_SHIFT;
20   -
21   - puts("CPU: ");
22   -
23   - switch (type) {
24   - case 0x25:
25   - puts("PH1-sLD3 (MN2WS0220)");
26   - required_model = 2;
27   - break;
28   - case 0x26:
29   - puts("PH1-LD4 (MN2WS0250)");
30   - required_rev = 2;
31   - break;
32   - case 0x28:
33   - puts("PH1-Pro4 (MN2WS0230)");
34   - break;
35   - case 0x29:
36   - puts("PH1-sLD8 (MN2WS0270)");
37   - break;
38   - case 0x2A:
39   - puts("PH1-Pro5 (MN2WS0300)");
40   - break;
41   - case 0x2E:
42   - puts("ProXstream2 (MN2WS0310)");
43   - break;
44   - case 0x2F:
45   - puts("PH1-LD6b (MN2WS0320)");
46   - break;
47   - case 0x31:
48   - puts("PH1-LD11 (SC1405AP1)");
49   - break;
50   - case 0x32:
51   - puts("PH1-LD20 (SC1401AJ1)");
52   - break;
53   - default:
54   - printf("Unknown Processor ID (0x%x)\n", revision);
55   - return -1;
56   - }
57   -
58   - printf(" model %d", model);
59   -
60   - printf(" (rev. %d)\n", rev);
61   -
62   - if (model < required_model) {
63   - printf("Sorry, this model is not supported.\n");
64   - printf("Required model is %d.", required_model);
65   - return -1;
66   - } else if (rev < required_rev) {
67   - printf("Sorry, this revision is not supported.\n");
68   - printf("Required revision is %d.", required_rev);
69   - return -1;
70   - }
71   -
72   - return 0;
73   -}
arch/arm/mach-uniphier/debug-uart/debug-uart.c
... ... @@ -32,45 +32,45 @@
32 32 void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE;
33 33 unsigned int divisor;
34 34  
35   - switch (uniphier_get_soc_type()) {
  35 + switch (uniphier_get_soc_id()) {
36 36 #if defined(CONFIG_ARCH_UNIPHIER_SLD3)
37   - case SOC_UNIPHIER_SLD3:
  37 + case UNIPHIER_SLD3_ID:
38 38 divisor = uniphier_sld3_debug_uart_init();
39 39 break;
40 40 #endif
41 41 #if defined(CONFIG_ARCH_UNIPHIER_LD4)
42   - case SOC_UNIPHIER_LD4:
  42 + case UNIPHIER_LD4_ID:
43 43 divisor = uniphier_ld4_debug_uart_init();
44 44 break;
45 45 #endif
46 46 #if defined(CONFIG_ARCH_UNIPHIER_PRO4)
47   - case SOC_UNIPHIER_PRO4:
  47 + case UNIPHIER_PRO4_ID:
48 48 divisor = uniphier_pro4_debug_uart_init();
49 49 break;
50 50 #endif
51 51 #if defined(CONFIG_ARCH_UNIPHIER_SLD8)
52   - case SOC_UNIPHIER_SLD8:
  52 + case UNIPHIER_SLD8_ID:
53 53 divisor = uniphier_sld8_debug_uart_init();
54 54 break;
55 55 #endif
56 56 #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
57   - case SOC_UNIPHIER_PRO5:
  57 + case UNIPHIER_PRO5_ID:
58 58 divisor = uniphier_pro5_debug_uart_init();
59 59 break;
60 60 #endif
61 61 #if defined(CONFIG_ARCH_UNIPHIER_PXS2)
62   - case SOC_UNIPHIER_PXS2:
  62 + case UNIPHIER_PXS2_ID:
63 63 divisor = uniphier_pxs2_debug_uart_init();
64 64 break;
65 65 #endif
66 66 #if defined(CONFIG_ARCH_UNIPHIER_LD6B)
67   - case SOC_UNIPHIER_LD6B:
  67 + case UNIPHIER_LD6B_ID:
68 68 divisor = uniphier_ld6b_debug_uart_init();
69 69 break;
70 70 #endif
71 71 #if defined(CONFIG_ARCH_UNIPHIER_LD11) || defined(CONFIG_ARCH_UNIPHIER_LD20)
72   - case SOC_UNIPHIER_LD11:
73   - case SOC_UNIPHIER_LD20:
  72 + case UNIPHIER_LD11_ID:
  73 + case UNIPHIER_LD20_ID:
74 74 divisor = uniphier_ld20_debug_uart_init();
75 75 break;
76 76 #endif
arch/arm/mach-uniphier/dram/cmd_ddrphy.c
... ... @@ -245,17 +245,17 @@
245 245 char *cmd = argv[1];
246 246 const struct phy_param *phy_param;
247 247  
248   - switch (uniphier_get_soc_type()) {
249   - case SOC_UNIPHIER_LD4:
  248 + switch (uniphier_get_soc_id()) {
  249 + case UNIPHIER_LD4_ID:
250 250 phy_param = uniphier_ld4_phy_param;
251 251 break;
252   - case SOC_UNIPHIER_PRO4:
  252 + case UNIPHIER_PRO4_ID:
253 253 phy_param = uniphier_pro4_phy_param;
254 254 break;
255   - case SOC_UNIPHIER_SLD8:
  255 + case UNIPHIER_SLD8_ID:
256 256 phy_param = uniphier_sld8_phy_param;
257 257 break;
258   - case SOC_UNIPHIER_LD11:
  258 + case UNIPHIER_LD11_ID:
259 259 phy_param = uniphier_ld11_phy_param;
260 260 break;
261 261 default:
arch/arm/mach-uniphier/dram_init.c
... ... @@ -97,7 +97,7 @@
97 97 const unsigned long rsv_size = 64;
98 98 int ch, ret;
99 99  
100   - if (uniphier_get_soc_type() != SOC_UNIPHIER_LD20)
  100 + if (uniphier_get_soc_id() != UNIPHIER_LD20_ID)
101 101 return 0;
102 102  
103 103 param = uniphier_get_board_param();
arch/arm/mach-uniphier/sg-regs.h
1 1 /*
2 2 * UniPhier SG (SoC Glue) block registers
3 3 *
4   - * Copyright (C) 2011-2015 Masahiro Yamada <yamada.masahiro@socionext.com>
  4 + * Copyright (C) 2011-2015 Copyright (C) 2011-2015 Panasonic Corporation
  5 + * Copyright (C) 2016-2017 Socionext Inc.
  6 + * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
5 7 *
6 8 * SPDX-License-Identifier: GPL-2.0+
7 9 */
8 10  
9   -#ifndef ARCH_SG_REGS_H
10   -#define ARCH_SG_REGS_H
  11 +#ifndef UNIPHIER_SG_REGS_H
  12 +#define UNIPHIER_SG_REGS_H
11 13  
12 14 /* Base Address */
13 15 #define SG_CTRL_BASE 0x5f800000
... ... @@ -15,12 +17,6 @@
15 17  
16 18 /* Revision */
17 19 #define SG_REVISION (SG_CTRL_BASE | 0x0000)
18   -#define SG_REVISION_TYPE_SHIFT 16
19   -#define SG_REVISION_TYPE_MASK (0xff << SG_REVISION_TYPE_SHIFT)
20   -#define SG_REVISION_MODEL_SHIFT 8
21   -#define SG_REVISION_MODEL_MASK (0x3 << SG_REVISION_MODEL_SHIFT)
22   -#define SG_REVISION_REV_SHIFT 0
23   -#define SG_REVISION_REV_MASK (0x1f << SG_REVISION_REV_SHIFT)
24 20  
25 21 /* Memory Configuration */
26 22 #define SG_MEMCONF (SG_CTRL_BASE | 0x0400)
... ... @@ -140,5 +136,5 @@
140 136  
141 137 #endif /* __ASSEMBLY__ */
142 138  
143   -#endif /* ARCH_SG_REGS_H */
  139 +#endif /* UNIPHIER_SG_REGS_H */
arch/arm/mach-uniphier/soc-info.c
  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 +{
  29 + return __uniphier_get_revision_field(0x3, 8);
  30 +}
  31 +
  32 +unsigned int uniphier_get_soc_revision(void)
  33 +{
  34 + return __uniphier_get_revision_field(0x1f, 0);
  35 +}
arch/arm/mach-uniphier/soc-info.h
1 1 /*
2   - * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com>
  2 + * Copyright (C) 2017 Socionext Inc.
  3 + * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
3 4 *
4 5 * SPDX-License-Identifier: GPL-2.0+
5 6 */
6 7  
7   -#ifndef __MACH_SOC_INFO_H__
8   -#define __MACH_SOC_INFO_H__
  8 +#ifndef __UNIPHIER_SOC_INFO_H__
  9 +#define __UNIPHIER_SOC_INFO_H__
9 10  
10   -enum uniphier_soc_id {
11   - SOC_UNIPHIER_SLD3,
12   - SOC_UNIPHIER_LD4,
13   - SOC_UNIPHIER_PRO4,
14   - SOC_UNIPHIER_SLD8,
15   - SOC_UNIPHIER_PRO5,
16   - SOC_UNIPHIER_PXS2,
17   - SOC_UNIPHIER_LD6B,
18   - SOC_UNIPHIER_LD11,
19   - SOC_UNIPHIER_LD20,
20   - SOC_UNIPHIER_UNKNOWN,
21   -};
  11 +#define UNIPHIER_SLD3_ID 0x25
  12 +#define UNIPHIER_LD4_ID 0x26
  13 +#define UNIPHIER_PRO4_ID 0x28
  14 +#define UNIPHIER_SLD8_ID 0x29
  15 +#define UNIPHIER_PRO5_ID 0x2a
  16 +#define UNIPHIER_PXS2_ID 0x2e
  17 +#define UNIPHIER_LD6B_ID 0x2f
  18 +#define UNIPHIER_LD11_ID 0x31
  19 +#define UNIPHIER_LD20_ID 0x32
22 20  
23   -#define UNIPHIER_NR_ENABLED_SOCS \
24   - IS_ENABLED(CONFIG_ARCH_UNIPHIER_SLD3) + \
25   - IS_ENABLED(CONFIG_ARCH_UNIPHIER_LD4) + \
26   - IS_ENABLED(CONFIG_ARCH_UNIPHIER_PRO4) + \
27   - IS_ENABLED(CONFIG_ARCH_UNIPHIER_SLD8) + \
28   - IS_ENABLED(CONFIG_ARCH_UNIPHIER_PRO5) + \
29   - IS_ENABLED(CONFIG_ARCH_UNIPHIER_PXS2) + \
30   - IS_ENABLED(CONFIG_ARCH_UNIPHIER_LD6B) + \
31   - IS_ENABLED(CONFIG_ARCH_UNIPHIER_LD11) + \
32   - IS_ENABLED(CONFIG_ARCH_UNIPHIER_LD20)
  21 +unsigned int uniphier_get_soc_id(void);
  22 +unsigned int uniphier_get_soc_model(void);
  23 +unsigned int uniphier_get_soc_revision(void);
33 24  
34   -#define UNIPHIER_MULTI_SOC ((UNIPHIER_NR_ENABLED_SOCS) > 1)
35   -
36   -#if UNIPHIER_MULTI_SOC
37   -enum uniphier_soc_id uniphier_get_soc_type(void);
38   -#else
39   -static inline enum uniphier_soc_id uniphier_get_soc_type(void)
40   -{
41   -#if defined(CONFIG_ARCH_UNIPHIER_SLD3)
42   - return SOC_UNIPHIER_SLD3;
43   -#endif
44   -#if defined(CONFIG_ARCH_UNIPHIER_LD4)
45   - return SOC_UNIPHIER_LD4;
46   -#endif
47   -#if defined(CONFIG_ARCH_UNIPHIER_PRO4)
48   - return SOC_UNIPHIER_PRO4;
49   -#endif
50   -#if defined(CONFIG_ARCH_UNIPHIER_SLD8)
51   - return SOC_UNIPHIER_SLD8;
52   -#endif
53   -#if defined(CONFIG_ARCH_UNIPHIER_PRO5)
54   - return SOC_UNIPHIER_PRO5;
55   -#endif
56   -#if defined(CONFIG_ARCH_UNIPHIER_PXS2)
57   - return SOC_UNIPHIER_PXS2;
58   -#endif
59   -#if defined(CONFIG_ARCH_UNIPHIER_LD6B)
60   - return SOC_UNIPHIER_LD6B;
61   -#endif
62   -#if defined(CONFIG_ARCH_UNIPHIER_LD11)
63   - return SOC_UNIPHIER_LD11;
64   -#endif
65   -#if defined(CONFIG_ARCH_UNIPHIER_LD20)
66   - return SOC_UNIPHIER_LD20;
67   -#endif
68   -
69   - return SOC_UNIPHIER_UNKNOWN;
70   -}
71   -#endif
72   -
73   -int uniphier_get_soc_model(void);
74   -int uniphier_get_soc_revision(void);
75   -
76   -#endif /* __MACH_SOC_INFO_H__ */
  25 +#endif /* __UNIPHIER_SOC_INFO_H__ */
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   -}
arch/arm/mach-uniphier/spl_board_init.c
... ... @@ -14,7 +14,7 @@
14 14 #include "soc-info.h"
15 15  
16 16 struct uniphier_spl_initdata {
17   - enum uniphier_soc_id soc_id;
  17 + unsigned int soc_id;
18 18 void (*bcu_init)(const struct uniphier_board_data *bd);
19 19 void (*early_clk_init)(void);
20 20 int (*dpll_init)(const struct uniphier_board_data *bd);
... ... @@ -26,7 +26,7 @@
26 26 static const struct uniphier_spl_initdata uniphier_spl_initdata[] = {
27 27 #if defined(CONFIG_ARCH_UNIPHIER_SLD3)
28 28 {
29   - .soc_id = SOC_UNIPHIER_SLD3,
  29 + .soc_id = UNIPHIER_SLD3_ID,
30 30 .bcu_init = uniphier_sld3_bcu_init,
31 31 .early_clk_init = uniphier_sld3_early_clk_init,
32 32 .dpll_init = uniphier_sld3_dpll_init,
... ... @@ -37,7 +37,7 @@
37 37 #endif
38 38 #if defined(CONFIG_ARCH_UNIPHIER_LD4)
39 39 {
40   - .soc_id = SOC_UNIPHIER_LD4,
  40 + .soc_id = UNIPHIER_LD4_ID,
41 41 .bcu_init = uniphier_ld4_bcu_init,
42 42 .early_clk_init = uniphier_sld3_early_clk_init,
43 43 .dpll_init = uniphier_ld4_dpll_init,
... ... @@ -48,7 +48,7 @@
48 48 #endif
49 49 #if defined(CONFIG_ARCH_UNIPHIER_PRO4)
50 50 {
51   - .soc_id = SOC_UNIPHIER_PRO4,
  51 + .soc_id = UNIPHIER_PRO4_ID,
52 52 .early_clk_init = uniphier_sld3_early_clk_init,
53 53 .dpll_init = uniphier_pro4_dpll_init,
54 54 .memconf_init = uniphier_memconf_2ch_init,
... ... @@ -58,7 +58,7 @@
58 58 #endif
59 59 #if defined(CONFIG_ARCH_UNIPHIER_SLD8)
60 60 {
61   - .soc_id = SOC_UNIPHIER_SLD8,
  61 + .soc_id = UNIPHIER_SLD8_ID,
62 62 .bcu_init = uniphier_ld4_bcu_init,
63 63 .early_clk_init = uniphier_sld3_early_clk_init,
64 64 .dpll_init = uniphier_sld8_dpll_init,
... ... @@ -69,7 +69,7 @@
69 69 #endif
70 70 #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
71 71 {
72   - .soc_id = SOC_UNIPHIER_PRO5,
  72 + .soc_id = UNIPHIER_PRO5_ID,
73 73 .early_clk_init = uniphier_sld3_early_clk_init,
74 74 .dpll_init = uniphier_pro5_dpll_init,
75 75 .memconf_init = uniphier_memconf_2ch_init,
... ... @@ -79,7 +79,7 @@
79 79 #endif
80 80 #if defined(CONFIG_ARCH_UNIPHIER_PXS2)
81 81 {
82   - .soc_id = SOC_UNIPHIER_PXS2,
  82 + .soc_id = UNIPHIER_PXS2_ID,
83 83 .early_clk_init = uniphier_sld3_early_clk_init,
84 84 .dpll_init = uniphier_pxs2_dpll_init,
85 85 .memconf_init = uniphier_memconf_3ch_init,
... ... @@ -89,7 +89,7 @@
89 89 #endif
90 90 #if defined(CONFIG_ARCH_UNIPHIER_LD6B)
91 91 {
92   - .soc_id = SOC_UNIPHIER_LD6B,
  92 + .soc_id = UNIPHIER_LD6B_ID,
93 93 .early_clk_init = uniphier_sld3_early_clk_init,
94 94 .dpll_init = uniphier_pxs2_dpll_init,
95 95 .memconf_init = uniphier_memconf_3ch_init,
... ... @@ -99,7 +99,7 @@
99 99 #endif
100 100 #if defined(CONFIG_ARCH_UNIPHIER_LD11)
101 101 {
102   - .soc_id = SOC_UNIPHIER_LD11,
  102 + .soc_id = UNIPHIER_LD11_ID,
103 103 .early_clk_init = uniphier_ld11_early_clk_init,
104 104 .dpll_init = uniphier_ld11_dpll_init,
105 105 .memconf_init = uniphier_memconf_2ch_init,
... ... @@ -109,7 +109,7 @@
109 109 #endif
110 110 #if defined(CONFIG_ARCH_UNIPHIER_LD20)
111 111 {
112   - .soc_id = SOC_UNIPHIER_LD20,
  112 + .soc_id = UNIPHIER_LD20_ID,
113 113 .early_clk_init = uniphier_ld11_early_clk_init,
114 114 .dpll_init = uniphier_ld20_dpll_init,
115 115 .memconf_init = uniphier_memconf_3ch_init,
... ... @@ -120,7 +120,7 @@
120 120 };
121 121  
122 122 static const struct uniphier_spl_initdata *uniphier_get_spl_initdata(
123   - enum uniphier_soc_id soc_id)
  123 + unsigned int soc_id)
124 124 {
125 125 int i;
126 126  
... ... @@ -136,7 +136,7 @@
136 136 {
137 137 const struct uniphier_board_data *bd;
138 138 const struct uniphier_spl_initdata *initdata;
139   - enum uniphier_soc_id soc_id;
  139 + unsigned int soc_id;
140 140 int ret;
141 141  
142 142 #ifdef CONFIG_DEBUG_UART
... ... @@ -147,7 +147,7 @@
147 147 if (!bd)
148 148 hang();
149 149  
150   - soc_id = uniphier_get_soc_type();
  150 + soc_id = uniphier_get_soc_id();
151 151 initdata = uniphier_get_spl_initdata(soc_id);
152 152 if (!initdata)
153 153 hang();