aboutsummaryrefslogtreecommitdiffstats
path: root/arch/nios2/platform
diff options
context:
space:
mode:
authorLey Foon Tan <lftan@altera.com>2014-11-06 02:20:03 -0500
committerLey Foon Tan <lftan@altera.com>2014-12-07 23:56:01 -0500
commit95acd4c7b69c9b250d901d154390ec4c8b7b51c1 (patch)
tree2232613144f317f21ccbd3684cd31ee11eb9c2b5 /arch/nios2/platform
parenteea9507a69d637d52705de8703b168bf6bfe5643 (diff)
nios2: Device tree support
Add device tree support to arch/nios2. Signed-off-by: Ley Foon Tan <lftan@altera.com>
Diffstat (limited to 'arch/nios2/platform')
-rw-r--r--arch/nios2/platform/platform.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/arch/nios2/platform/platform.c b/arch/nios2/platform/platform.c
new file mode 100644
index 000000000000..d478773f758a
--- /dev/null
+++ b/arch/nios2/platform/platform.c
@@ -0,0 +1,46 @@
1/*
2 * Copyright (C) 2013 Altera Corporation
3 * Copyright (C) 2011 Thomas Chou
4 * Copyright (C) 2011 Walter Goossens
5 *
6 * This file is subject to the terms and conditions of the GNU General
7 * Public License. See the file COPYING in the main directory of this
8 * archive for more details.
9 */
10
11#include <linux/init.h>
12#include <linux/of_platform.h>
13#include <linux/of_address.h>
14#include <linux/of_fdt.h>
15#include <linux/err.h>
16#include <linux/slab.h>
17#include <linux/sys_soc.h>
18#include <linux/io.h>
19
20static int __init nios2_soc_device_init(void)
21{
22 struct soc_device *soc_dev;
23 struct soc_device_attribute *soc_dev_attr;
24 const char *machine;
25
26 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
27 if (soc_dev_attr) {
28 machine = of_flat_dt_get_machine_name();
29 if (machine)
30 soc_dev_attr->machine = kasprintf(GFP_KERNEL, "%s",
31 machine);
32
33 soc_dev_attr->family = "Nios II";
34
35 soc_dev = soc_device_register(soc_dev_attr);
36 if (IS_ERR(soc_dev)) {
37 kfree(soc_dev_attr->machine);
38 kfree(soc_dev_attr);
39 }
40 }
41
42 return of_platform_populate(NULL, of_default_bus_match_table,
43 NULL, NULL);
44}
45
46device_initcall(nios2_soc_device_init);