Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eda413c2 authored by Lee Jones's avatar Lee Jones Committed by Arnd Bergmann
Browse files

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: default avatarLee Jones <lee.jones@linaro.org>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parent 18403424
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ config MACH_U8500
	bool "U8500 Development platform"
	depends on UX500_SOC_DB8500
	select TPS6105X
	select SOC_BUS
	help
	  Include support for the mop500 development platform.

+22 −8
Original line number Diff line number Diff line
@@ -212,18 +212,32 @@ static int usb_db5500_tx_dma_cfg[] = {
	DB5500_DMA_DEV38_USB_OTG_OEP_8
};

static const char *db5500_read_soc_id(void)
{
	return kasprintf(GFP_KERNEL, "u5500 currently unsupported\n");
}

static struct device * __init db5500_soc_device_init(void)
{
	const char *soc_id = db5500_read_soc_id();

	return ux500_soc_device_init(soc_id);
}

struct device * __init u5500_init_devices(void)
{
	/* FIXME: First parameter to be a real parent. */
	db5500_add_gpios(NULL);
	struct device *parent;

	parent = db5500_soc_device_init();

	db5500_add_gpios(parent);
	db5500_pmu_init();
	db5500_dma_init(NULL);
	db5500_add_rtc(NULL);
	db5500_add_usb(NULL, usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg);
	db5500_dma_init(parent);
	db5500_add_rtc(parent);
	db5500_add_usb(parent, usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg);

	platform_add_devices(db5500_platform_devs,
			     ARRAY_SIZE(db5500_platform_devs));

	/* FIXME: Return value to be a real parent. */
	return NULL;
	return parent;
}
+27 −6
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <mach/setup.h>
#include <mach/devices.h>
#include <mach/usb.h>
#include <mach/db8500-regs.h>

#include "devices-db8500.h"
#include "ste-dma40-db8500.h"
@@ -164,18 +165,38 @@ static int usb_db8500_tx_dma_cfg[] = {
	DB8500_DMA_DEV39_USB_OTG_OEP_8
};

static const char *db8500_read_soc_id(void)
{
	void __iomem *uid = __io_address(U8500_BB_UID_BASE);

	return kasprintf(GFP_KERNEL, "%08x%08x%08x%08x%08x",
			 readl((u32 *)uid+1),
			 readl((u32 *)uid+1), readl((u32 *)uid+2),
			 readl((u32 *)uid+3), readl((u32 *)uid+4));
}

static struct device * __init db8500_soc_device_init(void)
{
	const char *soc_id = db8500_read_soc_id();

	return ux500_soc_device_init(soc_id);
}

/*
 * This function is called from the board init
 */
struct device * __init u8500_init_devices(void)
{
	db8500_add_rtc(NULL);
	db8500_add_gpios(NULL);
	db8500_add_usb(NULL, usb_db8500_rx_dma_cfg, usb_db8500_tx_dma_cfg);
	struct device *parent;

	parent = db8500_soc_device_init();

	db8500_add_rtc(parent);
	db8500_add_gpios(parent);
	db8500_add_usb(parent, usb_db8500_rx_dma_cfg, usb_db8500_tx_dma_cfg);

	platform_device_register_simple("cpufreq-u8500", -1, NULL, 0);
	platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));

	/* FIXME: Return value to be a real parent. */
	return NULL;
	return parent;
}
+75 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
 * 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
 */

@@ -11,6 +12,10 @@
#include <linux/mfd/db8500-prcmu.h>
#include <linux/mfd/db5500-prcmu.h>
#include <linux/clksrc-dbx500-prcmu.h>
#include <linux/sys_soc.h>
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/stat.h>

#include <asm/hardware/gic.h>
#include <asm/mach/map.h>
@@ -50,3 +55,73 @@ void __init ux500_init_irq(void)
		db8500_prcmu_early_init();
	clk_init();
}

static const char * __init ux500_get_machine(void)
{
	return kasprintf(GFP_KERNEL, "DB%4x", dbx500_partnumber());
}

static const char * __init ux500_get_family(void)
{
	return kasprintf(GFP_KERNEL, "ux500");
}

static const char * __init 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 __init soc_info_populate(struct soc_device_attribute *soc_dev_attr,
				     const char *soc_id)
{
	soc_dev_attr->soc_id   = soc_id;
	soc_dev_attr->machine  = ux500_get_machine();
	soc_dev_attr->family   = ux500_get_family();
	soc_dev_attr->revision = ux500_get_revision();
}

struct device_attribute ux500_soc_attr =
	__ATTR(process,  S_IRUGO, ux500_get_process,  NULL);

struct device * __init ux500_soc_device_init(const char *soc_id)
{
	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 ERR_PTR(-ENOMEM);

	soc_info_populate(soc_dev_attr, soc_id);

	soc_dev = soc_device_register(soc_dev_attr);
	if (IS_ERR_OR_NULL(soc_dev)) {
	        kfree(soc_dev_attr);
		return NULL;
	}

	parent = soc_device_to_device(soc_dev);
	if (!IS_ERR_OR_NULL(parent))
		device_create_file(parent, &ux500_soc_attr);

	return parent;
}
+3 −0
Original line number Diff line number Diff line
@@ -161,4 +161,7 @@
#define U8500_MODEM_BASE	0xe000000
#define U8500_APE_BASE		0x6000000

/* SoC identification number information */
#define U8500_BB_UID_BASE      (U8500_BACKUPRAM1_BASE + 0xFC0)

#endif
Loading