diff options
-rw-r--r-- | drivers/soc/Kconfig | 1 | ||||
-rw-r--r-- | drivers/soc/Makefile | 1 | ||||
-rw-r--r-- | drivers/soc/versatile/Kconfig | 10 | ||||
-rw-r--r-- | drivers/soc/versatile/Makefile | 1 | ||||
-rw-r--r-- | drivers/soc/versatile/soc-realview.c | 144 |
5 files changed, 157 insertions, 0 deletions
diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index 49e3f0cc71af..76d6bd4da138 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig | |||
@@ -2,5 +2,6 @@ menu "SOC (System On Chip) specific Drivers" | |||
2 | 2 | ||
3 | source "drivers/soc/qcom/Kconfig" | 3 | source "drivers/soc/qcom/Kconfig" |
4 | source "drivers/soc/ti/Kconfig" | 4 | source "drivers/soc/ti/Kconfig" |
5 | source "drivers/soc/versatile/Kconfig" | ||
5 | 6 | ||
6 | endmenu | 7 | endmenu |
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 0d6e35dfea8c..063113d0bd38 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile | |||
@@ -5,3 +5,4 @@ | |||
5 | obj-$(CONFIG_ARCH_QCOM) += qcom/ | 5 | obj-$(CONFIG_ARCH_QCOM) += qcom/ |
6 | obj-$(CONFIG_ARCH_TEGRA) += tegra/ | 6 | obj-$(CONFIG_ARCH_TEGRA) += tegra/ |
7 | obj-$(CONFIG_SOC_TI) += ti/ | 7 | obj-$(CONFIG_SOC_TI) += ti/ |
8 | obj-$(CONFIG_PLAT_VERSATILE) += versatile/ | ||
diff --git a/drivers/soc/versatile/Kconfig b/drivers/soc/versatile/Kconfig new file mode 100644 index 000000000000..bf5ee9c85330 --- /dev/null +++ b/drivers/soc/versatile/Kconfig | |||
@@ -0,0 +1,10 @@ | |||
1 | # | ||
2 | # ARM Versatile SoC drivers | ||
3 | # | ||
4 | config SOC_REALVIEW | ||
5 | bool "SoC bus device for the ARM RealView platforms" | ||
6 | depends on ARCH_REALVIEW | ||
7 | select SOC_BUS | ||
8 | help | ||
9 | Include support for the SoC bus on the ARM RealView platforms | ||
10 | providing some sysfs information about the ASIC variant. | ||
diff --git a/drivers/soc/versatile/Makefile b/drivers/soc/versatile/Makefile new file mode 100644 index 000000000000..ad547435648e --- /dev/null +++ b/drivers/soc/versatile/Makefile | |||
@@ -0,0 +1 @@ | |||
obj-$(CONFIG_SOC_REALVIEW) += soc-realview.o | |||
diff --git a/drivers/soc/versatile/soc-realview.c b/drivers/soc/versatile/soc-realview.c new file mode 100644 index 000000000000..cea8ea3491d2 --- /dev/null +++ b/drivers/soc/versatile/soc-realview.c | |||
@@ -0,0 +1,144 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Linaro Ltd. | ||
3 | * | ||
4 | * Author: Linus Walleij <linus.walleij@linaro.org> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2, as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | */ | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/io.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <linux/sys_soc.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/mfd/syscon.h> | ||
17 | #include <linux/regmap.h> | ||
18 | #include <linux/of.h> | ||
19 | |||
20 | /* System ID in syscon */ | ||
21 | #define REALVIEW_SYS_ID_OFFSET 0x00 | ||
22 | |||
23 | static const struct of_device_id realview_soc_of_match[] = { | ||
24 | { .compatible = "arm,realview-eb-soc", }, | ||
25 | { .compatible = "arm,realview-pb1176-soc", }, | ||
26 | { .compatible = "arm,realview-pb11mp-soc", }, | ||
27 | { .compatible = "arm,realview-pba8-soc", }, | ||
28 | { .compatible = "arm,realview-pbx-soc", }, | ||
29 | }; | ||
30 | |||
31 | static u32 realview_coreid; | ||
32 | |||
33 | static const char *realview_board_str(u32 id) | ||
34 | { | ||
35 | switch ((id >> 16) & 0xfff) { | ||
36 | case 0x0147: | ||
37 | return "HBI-0147"; | ||
38 | default: | ||
39 | return "Unknown"; | ||
40 | } | ||
41 | } | ||
42 | |||
43 | static const char *realview_arch_str(u32 id) | ||
44 | { | ||
45 | switch ((id >> 8) & 0xf) { | ||
46 | case 0x05: | ||
47 | return "Multi-layer AXI"; | ||
48 | default: | ||
49 | return "Unknown"; | ||
50 | } | ||
51 | } | ||
52 | |||
53 | static ssize_t realview_get_manf(struct device *dev, | ||
54 | struct device_attribute *attr, | ||
55 | char *buf) | ||
56 | { | ||
57 | return sprintf(buf, "%02x\n", realview_coreid >> 24); | ||
58 | } | ||
59 | |||
60 | static struct device_attribute realview_manf_attr = | ||
61 | __ATTR(manufacturer, S_IRUGO, realview_get_manf, NULL); | ||
62 | |||
63 | static ssize_t realview_get_board(struct device *dev, | ||
64 | struct device_attribute *attr, | ||
65 | char *buf) | ||
66 | { | ||
67 | return sprintf(buf, "%s\n", realview_board_str(realview_coreid)); | ||
68 | } | ||
69 | |||
70 | static struct device_attribute realview_board_attr = | ||
71 | __ATTR(board, S_IRUGO, realview_get_board, NULL); | ||
72 | |||
73 | static ssize_t realview_get_arch(struct device *dev, | ||
74 | struct device_attribute *attr, | ||
75 | char *buf) | ||
76 | { | ||
77 | return sprintf(buf, "%s\n", realview_arch_str(realview_coreid)); | ||
78 | } | ||
79 | |||
80 | static struct device_attribute realview_arch_attr = | ||
81 | __ATTR(fpga, S_IRUGO, realview_get_arch, NULL); | ||
82 | |||
83 | static ssize_t realview_get_build(struct device *dev, | ||
84 | struct device_attribute *attr, | ||
85 | char *buf) | ||
86 | { | ||
87 | return sprintf(buf, "%02x\n", (realview_coreid & 0xFF)); | ||
88 | } | ||
89 | |||
90 | static struct device_attribute realview_build_attr = | ||
91 | __ATTR(build, S_IRUGO, realview_get_build, NULL); | ||
92 | |||
93 | static int realview_soc_probe(struct platform_device *pdev) | ||
94 | { | ||
95 | static struct regmap *syscon_regmap; | ||
96 | struct soc_device *soc_dev; | ||
97 | struct soc_device_attribute *soc_dev_attr; | ||
98 | struct device_node *np = pdev->dev.of_node; | ||
99 | int ret; | ||
100 | |||
101 | syscon_regmap = syscon_regmap_lookup_by_phandle(np, "regmap"); | ||
102 | if (IS_ERR(syscon_regmap)) | ||
103 | return PTR_ERR(syscon_regmap); | ||
104 | |||
105 | soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); | ||
106 | if (!soc_dev_attr) | ||
107 | return -ENOMEM; | ||
108 | |||
109 | ret = of_property_read_string(np, "compatible", | ||
110 | &soc_dev_attr->soc_id); | ||
111 | if (ret) | ||
112 | return -EINVAL; | ||
113 | |||
114 | soc_dev_attr->machine = "RealView"; | ||
115 | soc_dev_attr->family = "Versatile"; | ||
116 | soc_dev = soc_device_register(soc_dev_attr); | ||
117 | if (IS_ERR(soc_dev)) { | ||
118 | kfree(soc_dev_attr); | ||
119 | return -ENODEV; | ||
120 | } | ||
121 | ret = regmap_read(syscon_regmap, REALVIEW_SYS_ID_OFFSET, | ||
122 | &realview_coreid); | ||
123 | if (ret) | ||
124 | return -ENODEV; | ||
125 | |||
126 | device_create_file(soc_device_to_device(soc_dev), &realview_manf_attr); | ||
127 | device_create_file(soc_device_to_device(soc_dev), &realview_board_attr); | ||
128 | device_create_file(soc_device_to_device(soc_dev), &realview_arch_attr); | ||
129 | device_create_file(soc_device_to_device(soc_dev), &realview_build_attr); | ||
130 | |||
131 | dev_info(&pdev->dev, "RealView Syscon Core ID: 0x%08x\n", | ||
132 | realview_coreid); | ||
133 | /* FIXME: add attributes for SoC to sysfs */ | ||
134 | return 0; | ||
135 | } | ||
136 | |||
137 | static struct platform_driver realview_soc_driver = { | ||
138 | .probe = realview_soc_probe, | ||
139 | .driver = { | ||
140 | .name = "realview-soc", | ||
141 | .of_match_table = realview_soc_of_match, | ||
142 | }, | ||
143 | }; | ||
144 | module_platform_driver(realview_soc_driver); | ||