ARM: uniphier: refactor board_init()
[oweals/u-boot.git] / 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 }