ARM: rockchip: rk3228: implement function rk3228_restart
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-rockchip / cpu.c
1 #include <linux/kernel.h>
2 #include <linux/cpu.h>
3 #include <linux/rockchip/cpu.h>
4
5 unsigned long rockchip_soc_id;
6 EXPORT_SYMBOL(rockchip_soc_id);
7
8 static ssize_t type_show(struct device *dev, struct device_attribute *attr, char *buf)
9 {
10         const char *type;
11
12         if (cpu_is_rk3288())
13                 type = "rk3288";
14         else if (cpu_is_rk319x())
15                 type = "rk319x";
16         else if (cpu_is_rk3188())
17                 type = "rk3188";
18         else if (cpu_is_rk3066b())
19                 type = "rk3066b";
20         else if (cpu_is_rk3026())
21                 type = "rk3026";
22         else if (cpu_is_rk30xx())
23                 type = "rk30xx";
24         else if (cpu_is_rk2928())
25                 type = "rk2928";
26         else if (cpu_is_rk312x())
27                 type = "rk312x";
28         else
29                 type = "";
30
31         if (rockchip_get_cpu_version())
32                 return sprintf(buf, "%sv%lu\n", type,
33                                rockchip_get_cpu_version());
34
35         return sprintf(buf, "%s\n", type);
36 }
37
38 static struct device_attribute type_attr = __ATTR_RO(type);
39
40 static ssize_t soc_show(struct device *dev, struct device_attribute *attr, char *buf)
41 {
42         const char *soc;
43
44         if (soc_is_rk3288())
45                 soc = "rk3288";
46         else if (soc_is_rk3190())
47                 soc = "rk3190";
48         else if (soc_is_rk3188plus())
49                 soc = "rk3188+";
50         else if (soc_is_rk3188())
51                 soc = "rk3188";
52         else if (soc_is_rk3168())
53                 soc = "rk3168";
54         else if (soc_is_rk3028())
55                 soc = "rk3028";
56         else if (soc_is_rk3066b())
57                 soc = "rk3066b";
58         else if (soc_is_rk3028a())
59                 soc = "rk3028a";
60         else if (soc_is_rk3026())
61                 soc = "rk3026";
62         else if (soc_is_rk2928g())
63                 soc = "rk2928g";
64         else if (soc_is_rk2928l())
65                 soc = "rk2928l";
66         else if (soc_is_rk2926())
67                 soc = "rk2926";
68         else if (soc_is_rk3066())
69                 soc = "rk3066";
70         else if (soc_is_rk3068())
71                 soc = "rk3068";
72         else if (soc_is_rk3000())
73                 soc = "rk3000";
74         else if (soc_is_rk3126() || soc_is_rk3126b())
75                 soc = "rk3126";
76         else if (soc_is_rk3128())
77                 soc = "rk3128";
78         else
79                 soc = "";
80
81         return sprintf(buf, "%s\n", soc);
82 }
83
84 static struct device_attribute soc_attr = __ATTR_RO(soc);
85
86 static int __init rockchip_cpu_lateinit(void)
87 {
88         int err;
89
90         err = device_create_file(cpu_subsys.dev_root, &type_attr);
91         err = device_create_file(cpu_subsys.dev_root, &soc_attr);
92
93         return err;
94 }
95 late_initcall(rockchip_cpu_lateinit);