blob: 51ca29d6f33f7ac41166f4210d1cf8f213b857fb [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;
30 struct resource res;
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
Michael Bohanc7224532012-01-06 16:02:52 -080039 rc = of_irq_to_resource(node, 0, &res);
40 if (rc < 0)
Sathish Ambley098f9bd2011-11-09 16:32:53 -080041 pr_err("interrupt not specified in timer node\n");
Michael Bohanc7224532012-01-06 16:02:52 -080042 else
Sathish Ambley098f9bd2011-11-09 16:32:53 -080043 arch_timer_register(&res, 1);
Michael Bohanc7224532012-01-06 16:02:52 -080044
Sathish Ambley098f9bd2011-11-09 16:32:53 -080045 of_node_put(node);
46}
47
48static struct sys_timer msm_dt_timer = {
49 .init = msm_dt_timer_init
50};
51
52int __cpuinit local_timer_setup(struct clock_event_device *evt)
53{
54 return 0;
55}
56
Trilok Sonieecb28c2011-07-20 16:24:14 +010057void local_timer_stop(void)
Sathish Ambley098f9bd2011-11-09 16:32:53 -080058{
Trilok Sonieecb28c2011-07-20 16:24:14 +010059 return;
Sathish Ambley098f9bd2011-11-09 16:32:53 -080060}
Sathish Ambleyc58afc22011-10-09 21:55:39 -070061
Sathish Ambleyc58afc22011-10-09 21:55:39 -070062static void __init msm_dt_init_irq(void)
63{
64 if (machine_is_copper())
65 msm_copper_init_irq();
66}
67
68static void __init msm_dt_map_io(void)
69{
70 if (early_machine_is_copper())
71 msm_map_copper_io();
72 if (socinfo_init() < 0)
73 pr_err("%s: socinfo_init() failed\n", __func__);
74}
75
76static void __init msm_dt_init(void)
77{
78 struct of_dev_auxdata *adata = NULL;
79
80 if (machine_is_copper())
81 msm_copper_init(&adata);
82
83 of_platform_populate(NULL, of_default_bus_match_table, adata, NULL);
84 if (machine_is_copper())
85 msm_copper_add_devices();
86}
87
88static const char *msm_dt_match[] __initdata = {
89 "qcom,msmcopper",
90 NULL
91};
92
Olav Hauganb800c8c2012-01-30 08:50:45 -080093static void __init msm_dt_reserve(void)
94{
95 if (early_machine_is_copper())
96 msm_copper_reserve();
97}
98
99static void __init msm_dt_init_very_early(void)
100{
101 if (early_machine_is_copper())
102 msm_copper_very_early();
103}
104
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700105DT_MACHINE_START(MSM_DT, "Qualcomm MSM (Flattened Device Tree)")
106 .map_io = msm_dt_map_io,
107 .init_irq = msm_dt_init_irq,
108 .init_machine = msm_dt_init,
Sathish Ambley9b40e7d2012-01-03 16:50:44 -0800109 .handle_irq = gic_handle_irq,
Sathish Ambley098f9bd2011-11-09 16:32:53 -0800110 .timer = &msm_dt_timer,
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700111 .dt_compat = msm_dt_match,
Michael Bohance4b20b2012-01-06 15:59:39 -0800112 .nr_irqs = -1,
Olav Hauganb800c8c2012-01-30 08:50:45 -0800113 .reserve = msm_dt_reserve,
114 .init_very_early = msm_dt_init_very_early,
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700115MACHINE_END