11dbae815STony Lindgren /*
21dbae815STony Lindgren  * Copyright (C) 2005 Nokia Corporation
31dbae815STony Lindgren  * Author: Paul Mundt <paul.mundt@nokia.com>
41dbae815STony Lindgren  *
58d61649dSBenoit Cousson  * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
61dbae815STony Lindgren  *
78d61649dSBenoit Cousson  * Modified from the original mach-omap/omap2/board-generic.c did by Paul
88d61649dSBenoit Cousson  * to support the OMAP2+ device tree boards with an unique board file.
91dbae815STony Lindgren  *
101dbae815STony Lindgren  * This program is free software; you can redistribute it and/or modify
111dbae815STony Lindgren  * it under the terms of the GNU General Public License version 2 as
121dbae815STony Lindgren  * published by the Free Software Foundation.
131dbae815STony Lindgren  */
148d61649dSBenoit Cousson #include <linux/io.h>
15fbf75da7SBenoit Cousson #include <linux/of_irq.h>
168d61649dSBenoit Cousson #include <linux/of_platform.h>
178d61649dSBenoit Cousson #include <linux/irqdomain.h>
181dbae815STony Lindgren 
19b755706cSBenoit Cousson #include <asm/hardware/gic.h>
201dbae815STony Lindgren #include <asm/mach/arch.h>
211dbae815STony Lindgren 
224e65331cSTony Lindgren #include "common.h"
23a7cbb9b1SBenoit Cousson #include "common-board-devices.h"
2463d5fc0cSTomi Valkeinen #include "dss-common.h"
251dbae815STony Lindgren 
2675a57fe9STony Lindgren #if !(defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3))
27c4082d49SR Sricharan #define intc_of_init	NULL
2875a57fe9STony Lindgren #endif
2975a57fe9STony Lindgren #ifndef CONFIG_ARCH_OMAP4
3075a57fe9STony Lindgren #define gic_of_init		NULL
3175a57fe9STony Lindgren #endif
3275a57fe9STony Lindgren 
338d61649dSBenoit Cousson static struct of_device_id omap_dt_match_table[] __initdata = {
348d61649dSBenoit Cousson 	{ .compatible = "simple-bus", },
358d61649dSBenoit Cousson 	{ .compatible = "ti,omap-infra", },
368d61649dSBenoit Cousson 	{ }
37b3c6df3aSPaul Walmsley };
38b3c6df3aSPaul Walmsley 
391dbae815STony Lindgren static void __init omap_generic_init(void)
401dbae815STony Lindgren {
41a4ca9dbeSTony Lindgren 	omap_sdrc_init(NULL, NULL);
428d61649dSBenoit Cousson 
438d61649dSBenoit Cousson 	of_platform_populate(NULL, omap_dt_match_table, NULL, NULL);
4463d5fc0cSTomi Valkeinen 
4563d5fc0cSTomi Valkeinen 	/*
4663d5fc0cSTomi Valkeinen 	 * HACK: call display setup code for selected boards to enable omapdss.
4763d5fc0cSTomi Valkeinen 	 * This will be removed when omapdss supports DT.
4863d5fc0cSTomi Valkeinen 	 */
4963d5fc0cSTomi Valkeinen 	if (of_machine_is_compatible("ti,omap4-panda"))
5063d5fc0cSTomi Valkeinen 		omap4_panda_display_init_of();
5163d5fc0cSTomi Valkeinen 	else if (of_machine_is_compatible("ti,omap4-sdp"))
5263d5fc0cSTomi Valkeinen 		omap_4430sdp_display_init_of();
531dbae815STony Lindgren }
541dbae815STony Lindgren 
550e02a8c1SBenoit Cousson #ifdef CONFIG_SOC_OMAP2420
568d61649dSBenoit Cousson static const char *omap242x_boards_compat[] __initdata = {
578d61649dSBenoit Cousson 	"ti,omap2420",
588d61649dSBenoit Cousson 	NULL,
598d61649dSBenoit Cousson };
601dbae815STony Lindgren 
618d61649dSBenoit Cousson DT_MACHINE_START(OMAP242X_DT, "Generic OMAP2420 (Flattened Device Tree)")
6271ee7dadSRussell King 	.reserve	= omap_reserve,
638d61649dSBenoit Cousson 	.map_io		= omap242x_map_io,
648d61649dSBenoit Cousson 	.init_early	= omap2420_init_early,
65c4082d49SR Sricharan 	.init_irq	= omap_intc_of_init,
66b755706cSBenoit Cousson 	.handle_irq	= omap2_intc_handle_irq,
671dbae815STony Lindgren 	.init_machine	= omap_generic_init,
686bb27d73SStephen Warren 	.init_time	= omap2_sync32k_timer_init,
698d61649dSBenoit Cousson 	.dt_compat	= omap242x_boards_compat,
70187e3e06SPaul Walmsley 	.restart	= omap2xxx_restart,
711dbae815STony Lindgren MACHINE_END
728d61649dSBenoit Cousson #endif
738d61649dSBenoit Cousson 
740e02a8c1SBenoit Cousson #ifdef CONFIG_SOC_OMAP2430
758d61649dSBenoit Cousson static const char *omap243x_boards_compat[] __initdata = {
768d61649dSBenoit Cousson 	"ti,omap2430",
778d61649dSBenoit Cousson 	NULL,
788d61649dSBenoit Cousson };
798d61649dSBenoit Cousson 
808d61649dSBenoit Cousson DT_MACHINE_START(OMAP243X_DT, "Generic OMAP2430 (Flattened Device Tree)")
818d61649dSBenoit Cousson 	.reserve	= omap_reserve,
828d61649dSBenoit Cousson 	.map_io		= omap243x_map_io,
838d61649dSBenoit Cousson 	.init_early	= omap2430_init_early,
84c4082d49SR Sricharan 	.init_irq	= omap_intc_of_init,
856b2f55d7SMarc Zyngier 	.handle_irq	= omap2_intc_handle_irq,
868d61649dSBenoit Cousson 	.init_machine	= omap_generic_init,
876bb27d73SStephen Warren 	.init_time	= omap2_sync32k_timer_init,
888d61649dSBenoit Cousson 	.dt_compat	= omap243x_boards_compat,
89187e3e06SPaul Walmsley 	.restart	= omap2xxx_restart,
908d61649dSBenoit Cousson MACHINE_END
918d61649dSBenoit Cousson #endif
928d61649dSBenoit Cousson 
930e02a8c1SBenoit Cousson #ifdef CONFIG_ARCH_OMAP3
948d61649dSBenoit Cousson static const char *omap3_boards_compat[] __initdata = {
958d61649dSBenoit Cousson 	"ti,omap3",
968d61649dSBenoit Cousson 	NULL,
978d61649dSBenoit Cousson };
988d61649dSBenoit Cousson 
998d61649dSBenoit Cousson DT_MACHINE_START(OMAP3_DT, "Generic OMAP3 (Flattened Device Tree)")
1008d61649dSBenoit Cousson 	.reserve	= omap_reserve,
1018d61649dSBenoit Cousson 	.map_io		= omap3_map_io,
1028d61649dSBenoit Cousson 	.init_early	= omap3430_init_early,
103c4082d49SR Sricharan 	.init_irq	= omap_intc_of_init,
104b755706cSBenoit Cousson 	.handle_irq	= omap3_intc_handle_irq,
10593651b85SBenoit Cousson 	.init_machine	= omap_generic_init,
1066bb27d73SStephen Warren 	.init_time	= omap3_sync32k_timer_init,
1078d61649dSBenoit Cousson 	.dt_compat	= omap3_boards_compat,
108187e3e06SPaul Walmsley 	.restart	= omap3xxx_restart,
1098d61649dSBenoit Cousson MACHINE_END
1107dd9d502SJon Hunter 
1117dd9d502SJon Hunter static const char *omap3_gp_boards_compat[] __initdata = {
1127dd9d502SJon Hunter 	"ti,omap3-beagle",
1137dd9d502SJon Hunter 	NULL,
1147dd9d502SJon Hunter };
1157dd9d502SJon Hunter 
1167dd9d502SJon Hunter DT_MACHINE_START(OMAP3_GP_DT, "Generic OMAP3-GP (Flattened Device Tree)")
1177dd9d502SJon Hunter 	.reserve	= omap_reserve,
1187dd9d502SJon Hunter 	.map_io		= omap3_map_io,
1197dd9d502SJon Hunter 	.init_early	= omap3430_init_early,
1207dd9d502SJon Hunter 	.init_irq	= omap_intc_of_init,
1217dd9d502SJon Hunter 	.handle_irq	= omap3_intc_handle_irq,
1227dd9d502SJon Hunter 	.init_machine	= omap_generic_init,
1236bb27d73SStephen Warren 	.init_time	= omap3_secure_sync32k_timer_init,
1247dd9d502SJon Hunter 	.dt_compat	= omap3_gp_boards_compat,
125d01e4afdSLinus Torvalds 	.restart	= omap3xxx_restart,
1268d61649dSBenoit Cousson MACHINE_END
1278d61649dSBenoit Cousson #endif
1288d61649dSBenoit Cousson 
12908f30989SAfzal Mohammed #ifdef CONFIG_SOC_AM33XX
13008f30989SAfzal Mohammed static const char *am33xx_boards_compat[] __initdata = {
13108f30989SAfzal Mohammed 	"ti,am33xx",
13208f30989SAfzal Mohammed 	NULL,
13308f30989SAfzal Mohammed };
13408f30989SAfzal Mohammed 
13508f30989SAfzal Mohammed DT_MACHINE_START(AM33XX_DT, "Generic AM33XX (Flattened Device Tree)")
13608f30989SAfzal Mohammed 	.reserve	= omap_reserve,
13708f30989SAfzal Mohammed 	.map_io		= am33xx_map_io,
13808f30989SAfzal Mohammed 	.init_early	= am33xx_init_early,
139c4082d49SR Sricharan 	.init_irq	= omap_intc_of_init,
14008f30989SAfzal Mohammed 	.handle_irq	= omap3_intc_handle_irq,
14108f30989SAfzal Mohammed 	.init_machine	= omap_generic_init,
14200ea4d56SJon Hunter 	.init_time	= omap3_gptimer_timer_init,
14308f30989SAfzal Mohammed 	.dt_compat	= am33xx_boards_compat,
14408f30989SAfzal Mohammed MACHINE_END
14508f30989SAfzal Mohammed #endif
14608f30989SAfzal Mohammed 
1470e02a8c1SBenoit Cousson #ifdef CONFIG_ARCH_OMAP4
1488d61649dSBenoit Cousson static const char *omap4_boards_compat[] __initdata = {
1498d61649dSBenoit Cousson 	"ti,omap4",
1508d61649dSBenoit Cousson 	NULL,
1518d61649dSBenoit Cousson };
1528d61649dSBenoit Cousson 
1538d61649dSBenoit Cousson DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)")
1548d61649dSBenoit Cousson 	.reserve	= omap_reserve,
15506915321SMarc Zyngier 	.smp		= smp_ops(omap4_smp_ops),
1568d61649dSBenoit Cousson 	.map_io		= omap4_map_io,
1578d61649dSBenoit Cousson 	.init_early	= omap4430_init_early,
158c4082d49SR Sricharan 	.init_irq	= omap_gic_of_init,
159b755706cSBenoit Cousson 	.handle_irq	= gic_handle_irq,
16093651b85SBenoit Cousson 	.init_machine	= omap_generic_init,
161bbd707acSShawn Guo 	.init_late	= omap4430_init_late,
1626bb27d73SStephen Warren 	.init_time	= omap4_local_timer_init,
1638d61649dSBenoit Cousson 	.dt_compat	= omap4_boards_compat,
164187e3e06SPaul Walmsley 	.restart	= omap44xx_restart,
1658d61649dSBenoit Cousson MACHINE_END
1668d61649dSBenoit Cousson #endif
1670c1b6facSR Sricharan 
1680c1b6facSR Sricharan #ifdef CONFIG_SOC_OMAP5
1690c1b6facSR Sricharan static const char *omap5_boards_compat[] __initdata = {
1700c1b6facSR Sricharan 	"ti,omap5",
1710c1b6facSR Sricharan 	NULL,
1720c1b6facSR Sricharan };
1730c1b6facSR Sricharan 
1740c1b6facSR Sricharan DT_MACHINE_START(OMAP5_DT, "Generic OMAP5 (Flattened Device Tree)")
1750c1b6facSR Sricharan 	.reserve	= omap_reserve,
17606915321SMarc Zyngier 	.smp		= smp_ops(omap4_smp_ops),
1770c1b6facSR Sricharan 	.map_io		= omap5_map_io,
1780c1b6facSR Sricharan 	.init_early	= omap5_init_early,
1790c1b6facSR Sricharan 	.init_irq	= omap_gic_of_init,
1800c1b6facSR Sricharan 	.handle_irq	= gic_handle_irq,
1810c1b6facSR Sricharan 	.init_machine	= omap_generic_init,
1826bb27d73SStephen Warren 	.init_time	= omap5_realtime_timer_init,
1830c1b6facSR Sricharan 	.dt_compat	= omap5_boards_compat,
184187e3e06SPaul Walmsley 	.restart	= omap44xx_restart,
1850c1b6facSR Sricharan MACHINE_END
1860c1b6facSR Sricharan #endif
187