From patchwork Wed Feb 6 18:59:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruslan Bilovol X-Patchwork-Id: 2106161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 0119BDF2A1 for ; Wed, 6 Feb 2013 19:03:10 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U3AER-0000IJ-4Q; Wed, 06 Feb 2013 19:00:31 +0000 Received: from mail-ea0-f180.google.com ([209.85.215.180]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1U3AEK-0000Gr-BE for linux-arm-kernel@lists.infradead.org; Wed, 06 Feb 2013 19:00:25 +0000 Received: by mail-ea0-f180.google.com with SMTP id c1so708687eaa.11 for ; Wed, 06 Feb 2013 11:00:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:subject:date:message-id:x-mailer :in-reply-to:references; bh=u8a9kIM2IJPIIFTUJSUnYMaUX6h6OWgmffazvjn7o0g=; b=eiRYJMa+HJPs9dSvH5O010lwxGzeRuKJ0ovTTNj6TTd9CSCnQh302L1JJubjLR4iFj o6AqDi3382hogWWuq9n8ELqer6ocMJ34Dc+g5FqdIoYRLq3taCxmGEcSq5RY1vtPSdho JfBzbUS5BDStWAac7KVSKkEzZph1YReuh/DBMGzkfNwCvmxv37616UK9Gz5T7mR7o6+b gIIAkhcvd8tbUJ0NJhZcBDRF11G89pVynFvZ1EUKlGvW53RTAk8k+B3gzurBecBNatSQ jywt6tUIs6IFk7IVa0n1cbOWz3GSt6V/1f4LQvwoio2nCdcErIKxn/oT+mli0pKvNUeX Ojrg== X-Received: by 10.14.220.1 with SMTP id n1mr99737977eep.16.1360177221729; Wed, 06 Feb 2013 11:00:21 -0800 (PST) Received: from localhost ([195.238.93.36]) by mx.google.com with ESMTPS id q5sm38266474eeo.17.2013.02.06.11.00.19 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 06 Feb 2013 11:00:20 -0800 (PST) From: Ruslan Bilovol To: tony@atomide.com, linux@arm.linux.org.uk, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] ARM: OMAP2+: Export SoC information to userspace Date: Wed, 6 Feb 2013 20:59:56 +0200 Message-Id: <1360177196-18196-3-git-send-email-ruslan.bilovol@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1360177196-18196-1-git-send-email-ruslan.bilovol@ti.com> References: <1360177196-18196-1-git-send-email-ruslan.bilovol@ti.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130206_140024_527036_5C887A57 X-CRM114-Status: GOOD ( 15.71 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.215.180 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ruslan.bilovol[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 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 In some situations it is useful for userspace to know some SoC-specific information. For example, this may be used for deciding what kernel module to use or how to better configure some settings etc. This patch exports OMAP SoC information to userspace using existing in Linux kernel SoC infrastructure. This information can be read under /sys/devices/socX directory Signed-off-by: Ruslan Bilovol --- arch/arm/mach-omap2/common.h | 8 ++++++ arch/arm/mach-omap2/id.c | 65 ++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/io.c | 1 + arch/arm/plat-omap/Kconfig | 1 + 4 files changed, 75 insertions(+) diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h index 0c3a991..a024084 100644 --- a/arch/arm/mach-omap2/common.h +++ b/arch/arm/mach-omap2/common.h @@ -111,6 +111,14 @@ void ti81xx_init_late(void); void omap4430_init_late(void); int omap2_common_pm_late_init(void); +#ifdef CONFIG_SOC_BUS +void omap_soc_device_init(void); +#else +static inline void omap_soc_device_init(void) +{ +} +#endif + #if defined(CONFIG_SOC_OMAP2420) || defined(CONFIG_SOC_OMAP2430) void omap2xxx_restart(char mode, const char *cmd); #else diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c index b16a432..6134073 100644 --- a/arch/arm/mach-omap2/id.c +++ b/arch/arm/mach-omap2/id.c @@ -18,6 +18,11 @@ #include #include #include +#include + +#ifdef CONFIG_SOC_BUS +#include +#endif #include @@ -582,3 +587,63 @@ void __init omap2_set_globals_tap(u32 class, void __iomem *tap) else tap_prod_id = 0x0208; } + +#ifdef CONFIG_SOC_BUS + +static const char const *omap_types[] = { + [OMAP2_DEVICE_TYPE_TEST] = "TST", + [OMAP2_DEVICE_TYPE_EMU] = "EMU", + [OMAP2_DEVICE_TYPE_SEC] = "HS", + [OMAP2_DEVICE_TYPE_GP] = "GP", + [OMAP2_DEVICE_TYPE_BAD] = "BAD", +}; + +static const char * __init omap_get_family(void) +{ + if (cpu_is_omap24xx()) + return kasprintf(GFP_KERNEL, "OMAP2"); + else if (cpu_is_omap34xx()) + return kasprintf(GFP_KERNEL, "OMAP3"); + else if (cpu_is_omap44xx()) + return kasprintf(GFP_KERNEL, "OMAP4"); + else if (soc_is_omap54xx()) + return kasprintf(GFP_KERNEL, "OMAP5"); + else + return kasprintf(GFP_KERNEL, "Unknown"); +} + +static ssize_t omap_get_type(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return sprintf(buf, "%s\n", omap_types[omap_type()]); +} + +static struct device_attribute omap_soc_attr = + __ATTR(type, S_IRUGO, omap_get_type, NULL); + +void __init omap_soc_device_init(void) +{ + struct device *parent; + struct soc_device *soc_dev; + struct soc_device_attribute *soc_dev_attr; + + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + return; + + soc_dev_attr->machine = soc_name; + soc_dev_attr->family = omap_get_family(); + soc_dev_attr->revision = soc_rev; + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR_OR_NULL(soc_dev)) { + kfree(soc_dev_attr); + return; + } + + parent = soc_device_to_device(soc_dev); + if (!IS_ERR_OR_NULL(parent)) + device_create_file(parent, &omap_soc_attr); +} +#endif /* CONFIG_SOC_BUS */ diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c index 2c3fdd6..08003c1 100644 --- a/arch/arm/mach-omap2/io.c +++ b/arch/arm/mach-omap2/io.c @@ -602,6 +602,7 @@ void __init omap4430_init_late(void) omap2_common_pm_late_init(); omap4_pm_init(); omap2_clk_enable_autoidle_all(); + omap_soc_device_init(); } #endif diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig index 1fbac36..24b5687 100644 --- a/arch/arm/plat-omap/Kconfig +++ b/arch/arm/plat-omap/Kconfig @@ -30,6 +30,7 @@ config ARCH_OMAP2PLUS select PROC_DEVICETREE if PROC_FS select SPARSE_IRQ select USE_OF + select SOC_BUS help "Systems based on OMAP2, OMAP3, OMAP4 or OMAP5"