diff options
author | Lee Jones <lee.jones@linaro.org> | 2012-02-06 14:22:24 -0500 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2012-02-13 01:31:38 -0500 |
commit | eda413c228e227d888bc13d210e7c4c6aa62a682 (patch) | |
tree | 998f73c26e85a3557a2c911fd954c7ad0c0c8462 /arch/arm/mach-ux500 | |
parent | 18403424c4fe5bac509bf52343f5d5407d45ee3a (diff) |
ARM: ux500: export System-on-Chip information ux500 via sysfs
Here we make use of the new System-On-Chip bus driver to export
vital SoC information out to userspace via sysfs. This patch
provides a data structure of strings to populate the base
nodes found in:
/sys/devices/soc[0|1|2|...]/[family|machine|revision|soc_id].
It also adds one more node as requested by ST-Ericsson.
'process' depicts the way in which the silicon was manufactured.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/arm/mach-ux500')
-rw-r--r-- | arch/arm/mach-ux500/Kconfig | 1 | ||||
-rw-r--r-- | arch/arm/mach-ux500/cpu-db5500.c | 30 | ||||
-rw-r--r-- | arch/arm/mach-ux500/cpu-db8500.c | 33 | ||||
-rw-r--r-- | arch/arm/mach-ux500/cpu.c | 75 | ||||
-rw-r--r-- | arch/arm/mach-ux500/include/mach/db8500-regs.h | 3 | ||||
-rw-r--r-- | arch/arm/mach-ux500/include/mach/setup.h | 2 |
6 files changed, 130 insertions, 14 deletions
diff --git a/arch/arm/mach-ux500/Kconfig b/arch/arm/mach-ux500/Kconfig index 52af00446a63..5cfa5390e0fd 100644 --- a/arch/arm/mach-ux500/Kconfig +++ b/arch/arm/mach-ux500/Kconfig | |||
@@ -28,6 +28,7 @@ config MACH_U8500 | |||
28 | bool "U8500 Development platform" | 28 | bool "U8500 Development platform" |
29 | depends on UX500_SOC_DB8500 | 29 | depends on UX500_SOC_DB8500 |
30 | select TPS6105X | 30 | select TPS6105X |
31 | select SOC_BUS | ||
31 | help | 32 | help |
32 | Include support for the mop500 development platform. | 33 | Include support for the mop500 development platform. |
33 | 34 | ||
diff --git a/arch/arm/mach-ux500/cpu-db5500.c b/arch/arm/mach-ux500/cpu-db5500.c index c402fd6efe53..8f8acfdd4a1b 100644 --- a/arch/arm/mach-ux500/cpu-db5500.c +++ b/arch/arm/mach-ux500/cpu-db5500.c | |||
@@ -212,18 +212,32 @@ static int usb_db5500_tx_dma_cfg[] = { | |||
212 | DB5500_DMA_DEV38_USB_OTG_OEP_8 | 212 | DB5500_DMA_DEV38_USB_OTG_OEP_8 |
213 | }; | 213 | }; |
214 | 214 | ||
215 | struct device* __init u5500_init_devices(void) | 215 | static const char *db5500_read_soc_id(void) |
216 | { | 216 | { |
217 | /* FIXME: First parameter to be a real parent. */ | 217 | return kasprintf(GFP_KERNEL, "u5500 currently unsupported\n"); |
218 | db5500_add_gpios(NULL); | 218 | } |
219 | |||
220 | static struct device * __init db5500_soc_device_init(void) | ||
221 | { | ||
222 | const char *soc_id = db5500_read_soc_id(); | ||
223 | |||
224 | return ux500_soc_device_init(soc_id); | ||
225 | } | ||
226 | |||
227 | struct device * __init u5500_init_devices(void) | ||
228 | { | ||
229 | struct device *parent; | ||
230 | |||
231 | parent = db5500_soc_device_init(); | ||
232 | |||
233 | db5500_add_gpios(parent); | ||
219 | db5500_pmu_init(); | 234 | db5500_pmu_init(); |
220 | db5500_dma_init(NULL); | 235 | db5500_dma_init(parent); |
221 | db5500_add_rtc(NULL); | 236 | db5500_add_rtc(parent); |
222 | db5500_add_usb(NULL, usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg); | 237 | db5500_add_usb(parent, usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg); |
223 | 238 | ||
224 | platform_add_devices(db5500_platform_devs, | 239 | platform_add_devices(db5500_platform_devs, |
225 | ARRAY_SIZE(db5500_platform_devs)); | 240 | ARRAY_SIZE(db5500_platform_devs)); |
226 | 241 | ||
227 | /* FIXME: Return value to be a real parent. */ | 242 | return parent; |
228 | return NULL; | ||
229 | } | 243 | } |
diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c index 1e8a2cb7e503..afcde3df71d7 100644 --- a/arch/arm/mach-ux500/cpu-db8500.c +++ b/arch/arm/mach-ux500/cpu-db8500.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <mach/setup.h> | 24 | #include <mach/setup.h> |
25 | #include <mach/devices.h> | 25 | #include <mach/devices.h> |
26 | #include <mach/usb.h> | 26 | #include <mach/usb.h> |
27 | #include <mach/db8500-regs.h> | ||
27 | 28 | ||
28 | #include "devices-db8500.h" | 29 | #include "devices-db8500.h" |
29 | #include "ste-dma40-db8500.h" | 30 | #include "ste-dma40-db8500.h" |
@@ -164,18 +165,38 @@ static int usb_db8500_tx_dma_cfg[] = { | |||
164 | DB8500_DMA_DEV39_USB_OTG_OEP_8 | 165 | DB8500_DMA_DEV39_USB_OTG_OEP_8 |
165 | }; | 166 | }; |
166 | 167 | ||
168 | static const char *db8500_read_soc_id(void) | ||
169 | { | ||
170 | void __iomem *uid = __io_address(U8500_BB_UID_BASE); | ||
171 | |||
172 | return kasprintf(GFP_KERNEL, "%08x%08x%08x%08x%08x", | ||
173 | readl((u32 *)uid+1), | ||
174 | readl((u32 *)uid+1), readl((u32 *)uid+2), | ||
175 | readl((u32 *)uid+3), readl((u32 *)uid+4)); | ||
176 | } | ||
177 | |||
178 | static struct device * __init db8500_soc_device_init(void) | ||
179 | { | ||
180 | const char *soc_id = db8500_read_soc_id(); | ||
181 | |||
182 | return ux500_soc_device_init(soc_id); | ||
183 | } | ||
184 | |||
167 | /* | 185 | /* |
168 | * This function is called from the board init | 186 | * This function is called from the board init |
169 | */ | 187 | */ |
170 | struct device* __init u8500_init_devices(void) | 188 | struct device * __init u8500_init_devices(void) |
171 | { | 189 | { |
172 | db8500_add_rtc(NULL); | 190 | struct device *parent; |
173 | db8500_add_gpios(NULL); | 191 | |
174 | db8500_add_usb(NULL, usb_db8500_rx_dma_cfg, usb_db8500_tx_dma_cfg); | 192 | parent = db8500_soc_device_init(); |
193 | |||
194 | db8500_add_rtc(parent); | ||
195 | db8500_add_gpios(parent); | ||
196 | db8500_add_usb(parent, usb_db8500_rx_dma_cfg, usb_db8500_tx_dma_cfg); | ||
175 | 197 | ||
176 | platform_device_register_simple("cpufreq-u8500", -1, NULL, 0); | 198 | platform_device_register_simple("cpufreq-u8500", -1, NULL, 0); |
177 | platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); | 199 | platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); |
178 | 200 | ||
179 | /* FIXME: Return value to be a real parent. */ | 201 | return parent; |
180 | return NULL; | ||
181 | } | 202 | } |
diff --git a/arch/arm/mach-ux500/cpu.c b/arch/arm/mach-ux500/cpu.c index f41857494375..055fb6e16ee2 100644 --- a/arch/arm/mach-ux500/cpu.c +++ b/arch/arm/mach-ux500/cpu.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * Copyright (C) ST-Ericsson SA 2010 | 2 | * Copyright (C) ST-Ericsson SA 2010 |
3 | * | 3 | * |
4 | * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson | 4 | * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson |
5 | * Author: Lee Jones <lee.jones@linaro.org> for ST-Ericsson | ||
5 | * License terms: GNU General Public License (GPL) version 2 | 6 | * License terms: GNU General Public License (GPL) version 2 |
6 | */ | 7 | */ |
7 | 8 | ||
@@ -11,6 +12,10 @@ | |||
11 | #include <linux/mfd/db8500-prcmu.h> | 12 | #include <linux/mfd/db8500-prcmu.h> |
12 | #include <linux/mfd/db5500-prcmu.h> | 13 | #include <linux/mfd/db5500-prcmu.h> |
13 | #include <linux/clksrc-dbx500-prcmu.h> | 14 | #include <linux/clksrc-dbx500-prcmu.h> |
15 | #include <linux/sys_soc.h> | ||
16 | #include <linux/err.h> | ||
17 | #include <linux/slab.h> | ||
18 | #include <linux/stat.h> | ||
14 | 19 | ||
15 | #include <asm/hardware/gic.h> | 20 | #include <asm/hardware/gic.h> |
16 | #include <asm/mach/map.h> | 21 | #include <asm/mach/map.h> |
@@ -50,3 +55,73 @@ void __init ux500_init_irq(void) | |||
50 | db8500_prcmu_early_init(); | 55 | db8500_prcmu_early_init(); |
51 | clk_init(); | 56 | clk_init(); |
52 | } | 57 | } |
58 | |||
59 | static const char * __init ux500_get_machine(void) | ||
60 | { | ||
61 | return kasprintf(GFP_KERNEL, "DB%4x", dbx500_partnumber()); | ||
62 | } | ||
63 | |||
64 | static const char * __init ux500_get_family(void) | ||
65 | { | ||
66 | return kasprintf(GFP_KERNEL, "ux500"); | ||
67 | } | ||
68 | |||
69 | static const char * __init ux500_get_revision(void) | ||
70 | { | ||
71 | unsigned int rev = dbx500_revision(); | ||
72 | |||
73 | if (rev == 0x01) | ||
74 | return kasprintf(GFP_KERNEL, "%s", "ED"); | ||
75 | else if (rev >= 0xA0) | ||
76 | return kasprintf(GFP_KERNEL, "%d.%d", | ||
77 | (rev >> 4) - 0xA + 1, rev & 0xf); | ||
78 | |||
79 | return kasprintf(GFP_KERNEL, "%s", "Unknown"); | ||
80 | } | ||
81 | |||
82 | static ssize_t ux500_get_process(struct device *dev, | ||
83 | struct device_attribute *attr, | ||
84 | char *buf) | ||
85 | { | ||
86 | if (dbx500_id.process == 0x00) | ||
87 | return sprintf(buf, "Standard\n"); | ||
88 | |||
89 | return sprintf(buf, "%02xnm\n", dbx500_id.process); | ||
90 | } | ||
91 | |||
92 | static void __init soc_info_populate(struct soc_device_attribute *soc_dev_attr, | ||
93 | const char *soc_id) | ||
94 | { | ||
95 | soc_dev_attr->soc_id = soc_id; | ||
96 | soc_dev_attr->machine = ux500_get_machine(); | ||
97 | soc_dev_attr->family = ux500_get_family(); | ||
98 | soc_dev_attr->revision = ux500_get_revision(); | ||
99 | } | ||
100 | |||
101 | struct device_attribute ux500_soc_attr = | ||
102 | __ATTR(process, S_IRUGO, ux500_get_process, NULL); | ||
103 | |||
104 | struct device * __init ux500_soc_device_init(const char *soc_id) | ||
105 | { | ||
106 | struct device *parent; | ||
107 | struct soc_device *soc_dev; | ||
108 | struct soc_device_attribute *soc_dev_attr; | ||
109 | |||
110 | soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); | ||
111 | if (!soc_dev_attr) | ||
112 | return ERR_PTR(-ENOMEM); | ||
113 | |||
114 | soc_info_populate(soc_dev_attr, soc_id); | ||
115 | |||
116 | soc_dev = soc_device_register(soc_dev_attr); | ||
117 | if (IS_ERR_OR_NULL(soc_dev)) { | ||
118 | kfree(soc_dev_attr); | ||
119 | return NULL; | ||
120 | } | ||
121 | |||
122 | parent = soc_device_to_device(soc_dev); | ||
123 | if (!IS_ERR_OR_NULL(parent)) | ||
124 | device_create_file(parent, &ux500_soc_attr); | ||
125 | |||
126 | return parent; | ||
127 | } | ||
diff --git a/arch/arm/mach-ux500/include/mach/db8500-regs.h b/arch/arm/mach-ux500/include/mach/db8500-regs.h index 80e10f50282e..9ec20b96d8f2 100644 --- a/arch/arm/mach-ux500/include/mach/db8500-regs.h +++ b/arch/arm/mach-ux500/include/mach/db8500-regs.h | |||
@@ -161,4 +161,7 @@ | |||
161 | #define U8500_MODEM_BASE 0xe000000 | 161 | #define U8500_MODEM_BASE 0xe000000 |
162 | #define U8500_APE_BASE 0x6000000 | 162 | #define U8500_APE_BASE 0x6000000 |
163 | 163 | ||
164 | /* SoC identification number information */ | ||
165 | #define U8500_BB_UID_BASE (U8500_BACKUPRAM1_BASE + 0xFC0) | ||
166 | |||
164 | #endif | 167 | #endif |
diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h index e46b8b12056d..74b43bb74542 100644 --- a/arch/arm/mach-ux500/include/mach/setup.h +++ b/arch/arm/mach-ux500/include/mach/setup.h | |||
@@ -27,6 +27,8 @@ extern void __init u5500_sdi_init(struct device *parent); | |||
27 | 27 | ||
28 | extern void __init db5500_dma_init(struct device *parent); | 28 | extern void __init db5500_dma_init(struct device *parent); |
29 | 29 | ||
30 | extern struct device *ux500_soc_device_init(const char *soc_id); | ||
31 | |||
30 | /* We re-use nomadik_timer for this platform */ | 32 | /* We re-use nomadik_timer for this platform */ |
31 | extern void nmdk_timer_init(void); | 33 | extern void nmdk_timer_init(void); |
32 | 34 | ||