]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/kernel-video.git/blob - arch/arm/mach-omap2/board-generic.c
Merge branch 'pm-linux-3.8.y' of git://git.ti.com/~kristo/ti-linux-kernel/pm-linux...
[android-sdk/kernel-video.git] / arch / arm / mach-omap2 / board-generic.c
1 /*
2  * Copyright (C) 2005 Nokia Corporation
3  * Author: Paul Mundt <paul.mundt@nokia.com>
4  *
5  * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6  *
7  * Modified from the original mach-omap/omap2/board-generic.c did by Paul
8  * to support the OMAP2+ device tree boards with an unique board file.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14 #include <linux/io.h>
15 #include <linux/of_irq.h>
16 #include <linux/of_platform.h>
17 #include <linux/irqdomain.h>
18 #include <linux/clk.h>
19 #include <linux/string.h>
20 #include <linux/slab.h>
22 #include <asm/hardware/gic.h>
23 #include <asm/mach/arch.h>
25 #include <plat/sata.h>
27 #include "common.h"
28 #include "common-board-devices.h"
29 #include "dss-common.h"
31 #if !(defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3))
32 #define intc_of_init    NULL
33 #endif
34 #ifndef CONFIG_ARCH_OMAP4
35 #define gic_of_init             NULL
36 #endif
38 static struct of_device_id omap_dt_match_table[] __initdata = {
39         { .compatible = "simple-bus", },
40         { .compatible = "ti,omap-infra", },
41         { }
42 };
44 static int __init omap_create_clk_alias(struct device_node *np)
45 {
46         int ret = 0;
47         const char *s, *alias;
48         char *clk_id;
49         struct device_node *dev_np;
50         struct platform_device *pdev;
52         of_property_read_string(np, "clock-name", &s);
53         if (!s) {
54                 pr_err("%s: couldn't find clock-name property in node %s\n",
55                                 __func__, np->name);
56                 return -ENODEV;
57         }
59         clk_id = kstrdup(s, GFP_KERNEL);
60         if (!clk_id)
61                 return -ENOMEM;
63         dev_np = of_parse_phandle(np, "device", 0);
64         if (!dev_np) {
65                 pr_err("%s: couldn't find device phandle for \'%s\'\n",
66                                 __func__, clk_id);
67                 ret = -ENODEV;
68                 goto exit;
69         }
71         pdev = of_find_device_by_node(dev_np);
72         if (!pdev) {
73                 pr_err("%s: couldn't find device for clock \'%s\'\n",
74                                 __func__, clk_id);
75                 ret = -ENODEV;
76                 goto exit;
77         }
79         ret = of_property_read_string(np, "clock-alias", &alias);
80         if (ret) {
81                 pr_err("%s: couldn't find alias for clock \'%s\'\n",
82                                 __func__, clk_id);
83                 ret = -ENODEV;
84                 goto exit;
85         }
87         ret = clk_add_alias(alias, dev_name(&pdev->dev), clk_id, NULL);
88         if (ret) {
89                 pr_err("%s: couldn't add alias \'%s\' to clock \'%s\'\n",
90                                 __func__, alias, clk_id);
91                 ret = -ENODEV;
92                 goto exit;
93         }
95 exit:
96         kfree(clk_id);
97         return ret;
98 }
100 static void __init omap_generic_init(void)
102         struct device_node *np;
104         omap_sdrc_init(NULL, NULL);
106         of_platform_populate(NULL, omap_dt_match_table, NULL, NULL);
108         omapdss_init_of();
110         /* create clock aliases based on 'clock_alias' nodes */
111         for_each_node_by_name(np, "clock_alias") {
112                 omap_create_clk_alias(np);
113                 of_node_put(np);
114         }
116         if (of_machine_is_compatible("ti,omap5"))
117                 omap_sata_init();
120 #ifdef CONFIG_SOC_OMAP2420
121 static const char *omap242x_boards_compat[] __initdata = {
122         "ti,omap2420",
123         NULL,
124 };
126 DT_MACHINE_START(OMAP242X_DT, "Generic OMAP2420 (Flattened Device Tree)")
127         .reserve        = omap_reserve,
128         .map_io         = omap242x_map_io,
129         .init_early     = omap2420_init_early,
130         .init_irq       = omap_intc_of_init,
131         .handle_irq     = omap2_intc_handle_irq,
132         .init_machine   = omap_generic_init,
133         .timer          = &omap2_timer,
134         .dt_compat      = omap242x_boards_compat,
135         .restart        = omap2xxx_restart,
136 MACHINE_END
137 #endif
139 #ifdef CONFIG_SOC_OMAP2430
140 static const char *omap243x_boards_compat[] __initdata = {
141         "ti,omap2430",
142         NULL,
143 };
145 DT_MACHINE_START(OMAP243X_DT, "Generic OMAP2430 (Flattened Device Tree)")
146         .reserve        = omap_reserve,
147         .map_io         = omap243x_map_io,
148         .init_early     = omap2430_init_early,
149         .init_irq       = omap_intc_of_init,
150         .handle_irq     = omap2_intc_handle_irq,
151         .init_machine   = omap_generic_init,
152         .timer          = &omap2_timer,
153         .dt_compat      = omap243x_boards_compat,
154         .restart        = omap2xxx_restart,
155 MACHINE_END
156 #endif
158 #ifdef CONFIG_ARCH_OMAP3
159 static const char *omap3_boards_compat[] __initdata = {
160         "ti,omap3",
161         NULL,
162 };
164 DT_MACHINE_START(OMAP3_DT, "Generic OMAP3 (Flattened Device Tree)")
165         .reserve        = omap_reserve,
166         .map_io         = omap3_map_io,
167         .init_early     = omap3430_init_early,
168         .init_irq       = omap_intc_of_init,
169         .handle_irq     = omap3_intc_handle_irq,
170         .init_machine   = omap_generic_init,
171         .init_late      = omap3_init_late,
172         .timer          = &omap3_timer,
173         .dt_compat      = omap3_boards_compat,
174         .restart        = omap3xxx_restart,
175 MACHINE_END
177 static const char *omap3_gp_boards_compat[] __initdata = {
178         "ti,omap3-beagle",
179         NULL,
180 };
182 DT_MACHINE_START(OMAP3_GP_DT, "Generic OMAP3-GP (Flattened Device Tree)")
183         .reserve        = omap_reserve,
184         .map_io         = omap3_map_io,
185         .init_early     = omap3430_init_early,
186         .init_irq       = omap_intc_of_init,
187         .handle_irq     = omap3_intc_handle_irq,
188         .init_machine   = omap_generic_init,
189         .init_late      = omap3_init_late,
190         .timer          = &omap3_secure_timer,
191         .dt_compat      = omap3_gp_boards_compat,
192         .restart        = omap3xxx_restart,
193 MACHINE_END
194 #endif
196 #ifdef CONFIG_SOC_AM33XX
197 static const char *am33xx_boards_compat[] __initdata = {
198         "ti,am33xx",
199         NULL,
200 };
202 DT_MACHINE_START(AM33XX_DT, "Generic AM33XX (Flattened Device Tree)")
203         .reserve        = omap_reserve,
204         .map_io         = am33xx_map_io,
205         .init_early     = am33xx_init_early,
206         .init_late      = am33xx_init_late,
207         .init_irq       = omap_intc_of_init,
208         .handle_irq     = omap3_intc_handle_irq,
209         .init_machine   = omap_generic_init,
210         .timer          = &omap3_am33xx_timer,
211         .dt_compat      = am33xx_boards_compat,
212         .restart        = am33xx_restart,
213 MACHINE_END
214 #endif
216 #ifdef CONFIG_ARCH_OMAP4
217 static const char *omap4_boards_compat[] __initdata = {
218         "ti,omap4",
219         NULL,
220 };
222 DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)")
223         .reserve        = omap_reserve,
224         .smp            = smp_ops(omap4_smp_ops),
225         .map_io         = omap4_map_io,
226         .init_early     = omap4430_init_early,
227         .init_irq       = omap_gic_of_init,
228         .handle_irq     = gic_handle_irq,
229         .init_machine   = omap_generic_init,
230         .init_late      = omap4430_init_late,
231         .timer          = &omap4_timer,
232         .dt_compat      = omap4_boards_compat,
233         .restart        = omap44xx_restart,
234 MACHINE_END
235 #endif
237 #ifdef CONFIG_SOC_OMAP5
238 static const char *omap5_boards_compat[] __initdata = {
239         "ti,omap5",
240         NULL,
241 };
243 DT_MACHINE_START(OMAP5_DT, "Generic OMAP5 (Flattened Device Tree)")
244         .reserve        = omap_reserve,
245         .smp            = smp_ops(omap4_smp_ops),
246         .map_io         = omap5_map_io,
247         .init_early     = omap5_init_early,
248         .init_irq       = omap_gic_of_init,
249         .handle_irq     = gic_handle_irq,
250         .init_machine   = omap_generic_init,
251         .init_late      = omap5_init_late,
252         .timer          = &omap5_timer,
253         .dt_compat      = omap5_boards_compat,
254         .restart        = omap44xx_restart,
255 MACHINE_END
256 #endif