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 <stdio.h>
10 #include <linux/errno.h>
11 #include <linux/io.h>
12 #include <linux/printk.h>
13 
14 #include "soc-info.h"
15 
16 int print_cpuinfo(void)
17 {
18 	unsigned int id, model, rev, required_model = 1, required_rev = 1;
19 
20 	id = uniphier_get_soc_id();
21 	model = uniphier_get_soc_model();
22 	rev = uniphier_get_soc_revision();
23 
24 	puts("SoC:   ");
25 
26 	switch (id) {
27 	case UNIPHIER_LD4_ID:
28 		puts("LD4");
29 		required_rev = 2;
30 		break;
31 	case UNIPHIER_PRO4_ID:
32 		puts("Pro4");
33 		break;
34 	case UNIPHIER_SLD8_ID:
35 		puts("sLD8");
36 		break;
37 	case UNIPHIER_PRO5_ID:
38 		puts("Pro5");
39 		break;
40 	case UNIPHIER_PXS2_ID:
41 		puts("PXs2");
42 		break;
43 	case UNIPHIER_LD6B_ID:
44 		puts("LD6b");
45 		break;
46 	case UNIPHIER_LD11_ID:
47 		puts("LD11");
48 		break;
49 	case UNIPHIER_LD20_ID:
50 		puts("LD20");
51 		break;
52 	case UNIPHIER_PXS3_ID:
53 		puts("PXs3");
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 		pr_err("Only model %d or newer is supported.\n",
64 		       required_model);
65 		return -ENOTSUPP;
66 	} else if (rev < required_rev) {
67 		pr_err("Only revision %d or newer is supported.\n",
68 		       required_rev);
69 		return -ENOTSUPP;
70 	}
71 
72 	return 0;
73 }
74