1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2013-2014 Panasonic Corporation
4  * Copyright (C) 2015-2017 Socionext Inc.
5  *   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
6  */
7 
8 #include <stdio.h>
9 #include <linux/errno.h>
10 #include <linux/io.h>
11 #include <linux/printk.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("SoC:   ");
24 
25 	switch (id) {
26 	case UNIPHIER_LD4_ID:
27 		puts("LD4");
28 		required_rev = 2;
29 		break;
30 	case UNIPHIER_PRO4_ID:
31 		puts("Pro4");
32 		break;
33 	case UNIPHIER_SLD8_ID:
34 		puts("sLD8");
35 		break;
36 	case UNIPHIER_PRO5_ID:
37 		puts("Pro5");
38 		break;
39 	case UNIPHIER_PXS2_ID:
40 		puts("PXs2");
41 		break;
42 	case UNIPHIER_LD6B_ID:
43 		puts("LD6b");
44 		break;
45 	case UNIPHIER_LD11_ID:
46 		puts("LD11");
47 		break;
48 	case UNIPHIER_LD20_ID:
49 		puts("LD20");
50 		break;
51 	case UNIPHIER_PXS3_ID:
52 		puts("PXs3");
53 		break;
54 	default:
55 		printf("Unknown Processor ID (0x%x)\n", id);
56 		return -ENOTSUPP;
57 	}
58 
59 	printf(" (model %d, revision %d)\n", model, rev);
60 
61 	if (model < required_model) {
62 		pr_err("Only model %d or newer is supported.\n",
63 		       required_model);
64 		return -ENOTSUPP;
65 	} else if (rev < required_rev) {
66 		pr_err("Only revision %d or newer is supported.\n",
67 		       required_rev);
68 		return -ENOTSUPP;
69 	}
70 
71 	return 0;
72 }
73