xref: /openbmc/linux/arch/nios2/platform/platform.c (revision f26e4331)
195acd4c7SLey Foon Tan /*
295acd4c7SLey Foon Tan  * Copyright (C) 2013 Altera Corporation
395acd4c7SLey Foon Tan  * Copyright (C) 2011 Thomas Chou
495acd4c7SLey Foon Tan  * Copyright (C) 2011 Walter Goossens
595acd4c7SLey Foon Tan  *
695acd4c7SLey Foon Tan  * This file is subject to the terms and conditions of the GNU General
795acd4c7SLey Foon Tan  * Public License. See the file COPYING in the main directory of this
895acd4c7SLey Foon Tan  * archive for more details.
995acd4c7SLey Foon Tan  */
1095acd4c7SLey Foon Tan 
1195acd4c7SLey Foon Tan #include <linux/init.h>
1295acd4c7SLey Foon Tan #include <linux/of_address.h>
1395acd4c7SLey Foon Tan #include <linux/of_fdt.h>
1495acd4c7SLey Foon Tan #include <linux/err.h>
1595acd4c7SLey Foon Tan #include <linux/slab.h>
1695acd4c7SLey Foon Tan #include <linux/sys_soc.h>
1795acd4c7SLey Foon Tan #include <linux/io.h>
18f26e4331SDragos Bogdan #include <linux/clk-provider.h>
19f26e4331SDragos Bogdan 
20f26e4331SDragos Bogdan static const struct of_device_id clk_match[] __initconst = {
21f26e4331SDragos Bogdan 	{ .compatible = "fixed-clock", .data = of_fixed_clk_setup, },
22f26e4331SDragos Bogdan 	{}
23f26e4331SDragos Bogdan };
2495acd4c7SLey Foon Tan 
nios2_soc_device_init(void)2595acd4c7SLey Foon Tan static int __init nios2_soc_device_init(void)
2695acd4c7SLey Foon Tan {
2795acd4c7SLey Foon Tan 	struct soc_device *soc_dev;
2895acd4c7SLey Foon Tan 	struct soc_device_attribute *soc_dev_attr;
2995acd4c7SLey Foon Tan 	const char *machine;
3095acd4c7SLey Foon Tan 
3195acd4c7SLey Foon Tan 	soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
3295acd4c7SLey Foon Tan 	if (soc_dev_attr) {
3395acd4c7SLey Foon Tan 		machine = of_flat_dt_get_machine_name();
3495acd4c7SLey Foon Tan 		if (machine)
3595acd4c7SLey Foon Tan 			soc_dev_attr->machine = kasprintf(GFP_KERNEL, "%s",
3695acd4c7SLey Foon Tan 						machine);
3795acd4c7SLey Foon Tan 
3895acd4c7SLey Foon Tan 		soc_dev_attr->family = "Nios II";
3995acd4c7SLey Foon Tan 
4095acd4c7SLey Foon Tan 		soc_dev = soc_device_register(soc_dev_attr);
4195acd4c7SLey Foon Tan 		if (IS_ERR(soc_dev)) {
4295acd4c7SLey Foon Tan 			kfree(soc_dev_attr->machine);
4395acd4c7SLey Foon Tan 			kfree(soc_dev_attr);
4495acd4c7SLey Foon Tan 		}
4595acd4c7SLey Foon Tan 	}
4695acd4c7SLey Foon Tan 
47f26e4331SDragos Bogdan 	of_clk_init(clk_match);
48f26e4331SDragos Bogdan 
49623e9ef6SKefeng Wang 	return 0;
5095acd4c7SLey Foon Tan }
5195acd4c7SLey Foon Tan 
5295acd4c7SLey Foon Tan device_initcall(nios2_soc_device_init);
53