From patchwork Thu Sep 1 12:27:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 1119022 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p81CSifi009719 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 1 Sep 2011 12:29: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 1Qz6NV-000182-Tx; Thu, 01 Sep 2011 12:28:24 +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 1Qz6NV-0000xb-4j; Thu, 01 Sep 2011 12:28:17 +0000 Received: from mail-ww0-f49.google.com ([74.125.82.49]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qz6Mz-0000oz-9q for linux-arm-kernel@lists.infradead.org; Thu, 01 Sep 2011 12:27:46 +0000 Received: by mail-ww0-f49.google.com with SMTP id 10so1275855wwf.18 for ; Thu, 01 Sep 2011 05:27:45 -0700 (PDT) Received: by 10.216.229.149 with SMTP id h21mr170384weq.47.1314880064028; Thu, 01 Sep 2011 05:27:44 -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 r57sm355985weq.12.2011.09.01.05.27.41 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 01 Sep 2011 05:27:42 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/5] mach-ux500: export System-on-Chip information ux500 via sysfs Date: Thu, 1 Sep 2011 13:27:21 +0100 Message-Id: <1314880043-22517-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1314880043-22517-1-git-send-email-lee.jones@linaro.org> References: <1314880043-22517-1-git-send-email-lee.jones@linaro.org> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110901_082745_509665_64F969E3 X-CRM114-Status: GOOD ( 16.47 ) 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.49 listed in list.dnswl.org] Cc: jamie@jamieiles.com, gregkh@suse.de, Lee Jones , linus.walleij@stericsson.com, arnd@arndb.de 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 (demeter1.kernel.org [140.211.167.41]); Thu, 01 Sep 2011 12:29:05 +0000 (UTC) Here we make use of the new drivers/base/soc 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/[1|2|3|...]/[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 --- arch/arm/mach-ux500/Kconfig | 1 + arch/arm/mach-ux500/id.c | 77 ++++++++++++++++++++++++++++++ arch/arm/mach-ux500/include/mach/setup.h | 1 + 3 files changed, 79 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-ux500/Kconfig b/arch/arm/mach-ux500/Kconfig index 86188b2..fa70f65 100644 --- a/arch/arm/mach-ux500/Kconfig +++ b/arch/arm/mach-ux500/Kconfig @@ -27,6 +27,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..8fd53c7 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,76 @@ void __init ux500_map_io(void) ux500_print_soc_info(asicid); } + +struct soc_device *soc_dev; + +static const char *ux500_get_machine(void) +{ + return kasprintf(GFP_KERNEL, "DB%4x", dbx500_partnumber()); +} + +static const char *ux500_get_family(void) +{ + return kasprintf(GFP_KERNEL, "Ux500"); +} + +static const char *ux500_get_revision(void) +{ + unsigned int rev = dbx500_revision(); + + if (rev == 0x01) { + return kasprintf(GFP_KERNEL, "%s", "ED"); + } + else if (rev >= 0xA0) { + return kasprintf(GFP_KERNEL, "%d.%d" , (rev >> 4) - 0xA + 1, rev & 0xf); + } + + return kasprintf(GFP_KERNEL, "%s", "Unknown"); +} + +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); +} + +static void soc_info_populate(struct soc_device *soc_dev) +{ + soc_dev->machine = ux500_get_machine(); + soc_dev->family = ux500_get_family(); + soc_dev->revision = 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; + + soc_dev = kzalloc(sizeof(*soc_dev), GFP_KERNEL); + if (soc_dev == NULL) + return -ENOMEM; + + soc_info_populate(soc_dev); + + ret = soc_device_register(&soc_dev->dev); + + if (ret >= 0) { + while (ux500_soc_attrs[i].attr.name != NULL) { + ret = device_create_file(&soc_dev->dev, &ux500_soc_attrs[i++]); + if (ret) + goto out; + } + } +out: + return ret; +} +postcore_initcall(ux500_soc_sysfs_init); diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h index a7d363f..7d4c35f 100644 --- a/arch/arm/mach-ux500/include/mach/setup.h +++ b/arch/arm/mach-ux500/include/mach/setup.h @@ -35,6 +35,7 @@ extern void __init amba_add_devices(struct amba_device *devs[], int num); struct sys_timer; extern struct sys_timer ux500_timer; +extern struct soc_device *soc_dev; #define __IO_DEV_DESC(x, sz) { \ .virtual = IO_ADDRESS(x), \