blob: 2a35154ca1531f6c5e85aeb5c3aaefade71796a6 [file] [log] [blame]
Ley Foon Tan95acd4c72014-11-06 15:20:03 +08001/*
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>
Ley Foon Tan95acd4c72014-11-06 15:20:03 +080012#include <linux/of_address.h>
13#include <linux/of_fdt.h>
14#include <linux/err.h>
15#include <linux/slab.h>
16#include <linux/sys_soc.h>
17#include <linux/io.h>
18
19static int __init nios2_soc_device_init(void)
20{
21 struct soc_device *soc_dev;
22 struct soc_device_attribute *soc_dev_attr;
23 const char *machine;
24
25 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
26 if (soc_dev_attr) {
27 machine = of_flat_dt_get_machine_name();
28 if (machine)
29 soc_dev_attr->machine = kasprintf(GFP_KERNEL, "%s",
30 machine);
31
32 soc_dev_attr->family = "Nios II";
33
34 soc_dev = soc_device_register(soc_dev_attr);
35 if (IS_ERR(soc_dev)) {
36 kfree(soc_dev_attr->machine);
37 kfree(soc_dev_attr);
38 }
39 }
40
Kefeng Wang623e9ef2016-06-01 14:53:02 +080041 return 0;
Ley Foon Tan95acd4c72014-11-06 15:20:03 +080042}
43
44device_initcall(nios2_soc_device_init);