From: lee.jones@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] mach-ux500: export System-on-Chip information via sysfs
Date: Tue, 12 Jul 2011 14:08:09 +0100 [thread overview]
Message-ID: <1310476090-9807-2-git-send-email-lee.jones@linaro.org> (raw)
In-Reply-To: <1310476090-9807-1-git-send-email-lee.jones@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
arch/arm/mach-ux500/Kconfig | 1 +
arch/arm/mach-ux500/id.c | 115 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 116 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-ux500/Kconfig b/arch/arm/mach-ux500/Kconfig
index 4210cb4..4d2f2c2 100644
--- a/arch/arm/mach-ux500/Kconfig
+++ b/arch/arm/mach-ux500/Kconfig
@@ -26,6 +26,7 @@ config MACH_U8500
bool "U8500 Development platform"
depends on UX500_SOC_DB8500
select TPS6105X
+ select SYS_SOC
help
Include support for the mop500 development platform.
diff --git a/arch/arm/mach-ux500/id.c b/arch/arm/mach-ux500/id.c
index d35122e..5156438 100644
--- a/arch/arm/mach-ux500/id.c
+++ b/arch/arm/mach-ux500/id.c
@@ -2,12 +2,16 @@
* Copyright (C) ST-Ericsson SA 2010
*
* Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
+ * Author: Lee Jones <lee.jones@linaro.org> for ST-Ericsson
* License terms: GNU General Public License (GPL) version 2
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/io.h>
+#include <linux/sys_soc.h>
+#include <linux/slab.h>
+#include <linux/stat.h>
#include <asm/cputype.h>
#include <asm/tlbflush.h>
@@ -105,3 +109,114 @@ void __init ux500_map_io(void)
ux500_print_soc_info(asicid);
}
+
+#ifdef CONFIG_SYS_SOC
+#define U8500_BB_UID_BASE (U8500_BACKUPRAM1_BASE + 0xFC0)
+#define U8500_BB_UID_LENGTH 5
+
+static struct device soc_parent;
+
+static ssize_t ux500_get_family(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ return sprintf(buf, "Ux500\n");
+}
+
+static ssize_t ux500_get_machine(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ return sprintf(buf, "DB%4x\n", dbx500_partnumber());
+}
+
+static ssize_t ux500_get_soc_id(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ void __iomem *uid_base;
+ int i;
+ ssize_t sz = 0;
+
+ if (dbx500_partnumber() == 0x8500) {
+ uid_base = __io_address(U8500_BB_UID_BASE);
+ for (i = 0; i < U8500_BB_UID_LENGTH; i++)
+ sz += sprintf(buf + sz, "%08x",
+ readl(uid_base + i * sizeof(u32)));
+ sz += sprintf(buf + sz, "\n");
+ } else {
+ /* Don't know where it is located for U5500 */
+ sz = sprintf(buf, "N/A\n");
+ }
+
+ return sz;
+}
+
+static ssize_t ux500_get_revision(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ unsigned int rev = dbx500_revision();
+
+ if (rev == 0x01)
+ return sprintf(buf, "%s\n", "ED");
+ else if (rev >= 0xA0)
+ return sprintf(buf, "%d.%d\n" ,
+ (rev >> 4) - 0xA + 1, rev & 0xf);
+
+ return sprintf(buf, "%s", "Unknown\n");
+}
+
+static ssize_t ux500_get_process(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ if (dbx500_id.process == 0x00)
+ return sprintf(buf, "Standard\n");
+
+ return sprintf(buf, "%02xnm\n", dbx500_id.process);
+}
+
+struct soc_callback_functions soc_callbacks = {
+ .get_machine_fn = ux500_get_machine,
+ .get_family_fn = ux500_get_family,
+ .get_soc_id_fn = ux500_get_soc_id,
+ .get_revision_fn = ux500_get_revision,
+};
+
+struct device_attribute ux500_soc_attrs[] = {
+ __ATTR(process, S_IRUGO, ux500_get_process, NULL),
+ __ATTR_NULL,
+};
+
+static int __init ux500_soc_sysfs_init(void)
+{
+ int ret;
+ int i = 0;
+ ret = soc_device_register(&soc_parent,
+ &soc_callbacks);
+ if (ret >= 0) {
+ while (ux500_soc_attrs[i].attr.name != NULL) {
+ ret = device_create_file(&soc_parent,
+ &ux500_soc_attrs[i++]);
+ if (ret)
+ goto out;
+ }
+ }
+ out:
+ return ret;
+}
+module_init(ux500_soc_sysfs_init);
+
+static void __exit ux500_soc_sysfs_exit(void)
+{
+ int i = 0;
+
+ while (ux500_soc_attrs[i].attr.name != NULL)
+ device_remove_file(&soc_parent, &ux500_soc_attrs[i++]);
+
+ soc_device_unregister(&soc_parent);
+}
+module_exit(ux500_soc_sysfs_exit);
+
+#endif
--
1.7.4.1
next prev parent reply other threads:[~2011-07-12 13:08 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-12 13:08 [PATCH 1/3] Framework for exporting System-on-Chip information via sysfs Lee Jones
2011-07-12 13:08 ` Lee Jones [this message]
2011-07-12 16:29 ` [PATCH 2/3] mach-ux500: export " Saravana Kannan
2011-07-13 7:55 ` Lee Jones
2011-07-13 16:40 ` Saravana Kannan
2011-07-13 20:32 ` Greg KH
2011-07-13 20:51 ` Arnd Bergmann
2011-07-14 6:42 ` Lee Jones
2011-07-14 12:58 ` Arnd Bergmann
2011-07-14 13:04 ` Lee Jones
2011-07-14 17:25 ` Saravana Kannan
2011-07-15 6:27 ` Lee Jones
2011-07-12 16:47 ` Arnd Bergmann
2011-07-13 8:10 ` Lee Jones
2011-07-13 13:42 ` Arnd Bergmann
2011-07-13 14:31 ` Lee Jones
2011-07-13 16:20 ` Arnd Bergmann
2011-07-12 13:08 ` [PATCH 3/3] Add documenation for new sysfs devices/soc functionallity Lee Jones
2011-07-12 14:13 ` [PATCH 1/3] Framework for exporting System-on-Chip information via sysfs Baruch Siach
2011-07-12 16:08 ` Greg KH
2011-07-13 7:16 ` Lee Jones
2011-07-13 7:53 ` Greg KH
2011-07-13 8:27 ` Lee Jones
2011-07-15 14:02 ` Arnd Bergmann
-- strict thread matches above, loose matches on Subject: below --
2011-04-14 14:49 [PATCH 0/3] Export valuable System-on-Chip information to user-space " Lee Jones
2011-04-14 14:49 ` [PATCH 2/3] mach-ux500: export System-on-Chip information " Lee Jones
2011-04-17 18:40 ` Arnd Bergmann
2011-04-11 18:01 Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1310476090-9807-2-git-send-email-lee.jones@linaro.org \
--to=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.