From patchwork Tue Jul 12 13:08:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 968362 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6CDEibP012353 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 12 Jul 2011 13:15:05 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QgcnK-0007AI-G6; Tue, 12 Jul 2011 13:14:34 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QgcnK-0006Rk-4N; Tue, 12 Jul 2011 13:14:34 +0000 Received: from mail-wy0-f177.google.com ([74.125.82.177]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QgcnG-0006RR-MC for linux-arm-kernel@lists.infradead.org; Tue, 12 Jul 2011 13:14:31 +0000 Received: by wyf23 with SMTP id 23so4105660wyf.36 for ; Tue, 12 Jul 2011 06:14:28 -0700 (PDT) Received: by 10.216.24.82 with SMTP id w60mr5059005wew.99.1310476120201; Tue, 12 Jul 2011 06:08:40 -0700 (PDT) Received: from localhost.localdomain (cpc2-aztw13-0-0-cust146.aztw.cable.virginmedia.com [77.99.12.147]) by mx.google.com with ESMTPS id u64sm7553220weq.4.2011.07.12.06.08.38 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Jul 2011 06:08:38 -0700 (PDT) From: 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 Message-Id: <1310476090-9807-2-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1310476090-9807-1-git-send-email-lee.jones@linaro.org> References: <1310476090-9807-1-git-send-email-lee.jones@linaro.org> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110712_091431_017932_307BD197 X-CRM114-Status: GOOD ( 18.37 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.177 listed in list.dnswl.org] Cc: Lee Jones X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 12 Jul 2011 13:15:06 +0000 (UTC) Signed-off-by: Lee Jones --- 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 for ST-Ericsson + * Author: Lee Jones for ST-Ericsson * License terms: GNU General Public License (GPL) version 2 */ #include #include #include +#include +#include +#include #include #include @@ -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