blob: 3fb6042a87d715f73d9d9bb9a3dc32632ea7a3e7 [file] [log] [blame]
Sathish Ambley9b40e7d2012-01-03 16:50:44 -08001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Sathish Ambleyc58afc22011-10-09 21:55:39 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/kernel.h>
14#include <linux/errno.h>
15#include <linux/of.h>
16#include <linux/of_address.h>
17#include <linux/of_platform.h>
18#include <linux/of_fdt.h>
Sathish Ambley098f9bd2011-11-09 16:32:53 -080019#include <linux/of_irq.h>
Sathish Ambley9b40e7d2012-01-03 16:50:44 -080020#include <asm/hardware/gic.h>
Sathish Ambley098f9bd2011-11-09 16:32:53 -080021#include <asm/arch_timer.h>
Sathish Ambleyc58afc22011-10-09 21:55:39 -070022#include <asm/mach/arch.h>
Sathish Ambley098f9bd2011-11-09 16:32:53 -080023#include <asm/mach/time.h>
Sathish Ambleyc58afc22011-10-09 21:55:39 -070024#include <mach/socinfo.h>
25#include <mach/board.h>
Sathish Ambley098f9bd2011-11-09 16:32:53 -080026
27static void __init msm_dt_timer_init(void)
28{
29 struct device_node *node;
Marc Zyngierdf590cc2012-01-11 17:25:17 +000030 struct arch_timer tmr;
Michael Bohanc7224532012-01-06 16:02:52 -080031 int rc;
Sathish Ambley098f9bd2011-11-09 16:32:53 -080032
33 node = of_find_compatible_node(NULL, NULL, "qcom,msm-qtimer");
34 if (!node) {
35 pr_err("no matching timer node found\n");
36 return;
37 }
38
Marc Zyngierdf590cc2012-01-11 17:25:17 +000039 tmr.res[0].start = 0;
40 tmr.res[1].start = 0;
41 rc = of_irq_to_resource(node, 0, tmr.res);
Michael Bohanc7224532012-01-06 16:02:52 -080042 if (rc < 0)
Sathish Ambley098f9bd2011-11-09 16:32:53 -080043 pr_err("interrupt not specified in timer node\n");
Michael Bohanc7224532012-01-06 16:02:52 -080044 else
Marc Zyngierdf590cc2012-01-11 17:25:17 +000045 arch_timer_register(&tmr);
Michael Bohanc7224532012-01-06 16:02:52 -080046
Sathish Ambley098f9bd2011-11-09 16:32:53 -080047 of_node_put(node);
48}
49
50static struct sys_timer msm_dt_timer = {
51 .init = msm_dt_timer_init
52};
53
Sathish Ambleyc58afc22011-10-09 21:55:39 -070054static void __init msm_dt_init_irq(void)
55{
56 if (machine_is_copper())
57 msm_copper_init_irq();
58}
59
60static void __init msm_dt_map_io(void)
61{
62 if (early_machine_is_copper())
63 msm_map_copper_io();
64 if (socinfo_init() < 0)
65 pr_err("%s: socinfo_init() failed\n", __func__);
66}
67
68static void __init msm_dt_init(void)
69{
70 struct of_dev_auxdata *adata = NULL;
71
72 if (machine_is_copper())
73 msm_copper_init(&adata);
74
75 of_platform_populate(NULL, of_default_bus_match_table, adata, NULL);
76 if (machine_is_copper())
77 msm_copper_add_devices();
78}
79
80static const char *msm_dt_match[] __initdata = {
81 "qcom,msmcopper",
82 NULL
83};
84
Olav Hauganb800c8c2012-01-30 08:50:45 -080085static void __init msm_dt_reserve(void)
86{
87 if (early_machine_is_copper())
88 msm_copper_reserve();
89}
90
91static void __init msm_dt_init_very_early(void)
92{
93 if (early_machine_is_copper())
94 msm_copper_very_early();
95}
96
Sathish Ambleyc58afc22011-10-09 21:55:39 -070097DT_MACHINE_START(MSM_DT, "Qualcomm MSM (Flattened Device Tree)")
98 .map_io = msm_dt_map_io,
99 .init_irq = msm_dt_init_irq,
100 .init_machine = msm_dt_init,
Sathish Ambley9b40e7d2012-01-03 16:50:44 -0800101 .handle_irq = gic_handle_irq,
Sathish Ambley098f9bd2011-11-09 16:32:53 -0800102 .timer = &msm_dt_timer,
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700103 .dt_compat = msm_dt_match,
Michael Bohance4b20b2012-01-06 15:59:39 -0800104 .nr_irqs = -1,
Olav Hauganb800c8c2012-01-30 08:50:45 -0800105 .reserve = msm_dt_reserve,
106 .init_very_early = msm_dt_init_very_early,
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700107MACHINE_END