Sathish Ambley | 9b40e7d | 2012-01-03 16:50:44 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 2 | * |
| 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 Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 19 | #include <linux/of_irq.h> |
Sathish Ambley | 9b40e7d | 2012-01-03 16:50:44 -0800 | [diff] [blame] | 20 | #include <asm/hardware/gic.h> |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 21 | #include <asm/arch_timer.h> |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 22 | #include <asm/mach/arch.h> |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 23 | #include <asm/mach/time.h> |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 24 | #include <mach/socinfo.h> |
| 25 | #include <mach/board.h> |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 26 | |
| 27 | static void __init msm_dt_timer_init(void) |
| 28 | { |
| 29 | struct device_node *node; |
| 30 | struct resource res; |
Michael Bohan | c722453 | 2012-01-06 16:02:52 -0800 | [diff] [blame] | 31 | int rc; |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 32 | |
| 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 Bohan | c722453 | 2012-01-06 16:02:52 -0800 | [diff] [blame] | 39 | rc = of_irq_to_resource(node, 0, &res); |
| 40 | if (rc < 0) |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 41 | pr_err("interrupt not specified in timer node\n"); |
Michael Bohan | c722453 | 2012-01-06 16:02:52 -0800 | [diff] [blame] | 42 | else |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 43 | arch_timer_register(&res, 1); |
Michael Bohan | c722453 | 2012-01-06 16:02:52 -0800 | [diff] [blame] | 44 | |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 45 | of_node_put(node); |
| 46 | } |
| 47 | |
| 48 | static struct sys_timer msm_dt_timer = { |
| 49 | .init = msm_dt_timer_init |
| 50 | }; |
| 51 | |
| 52 | int __cpuinit local_timer_setup(struct clock_event_device *evt) |
| 53 | { |
| 54 | return 0; |
| 55 | } |
| 56 | |
Trilok Soni | eecb28c | 2011-07-20 16:24:14 +0100 | [diff] [blame] | 57 | void local_timer_stop(void) |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 58 | { |
Trilok Soni | eecb28c | 2011-07-20 16:24:14 +0100 | [diff] [blame] | 59 | return; |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 60 | } |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 61 | |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 62 | static void __init msm_dt_init_irq(void) |
| 63 | { |
| 64 | if (machine_is_copper()) |
| 65 | msm_copper_init_irq(); |
| 66 | } |
| 67 | |
| 68 | static 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 | |
| 76 | static 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 | |
| 88 | static const char *msm_dt_match[] __initdata = { |
| 89 | "qcom,msmcopper", |
| 90 | NULL |
| 91 | }; |
| 92 | |
Olav Haugan | b800c8c | 2012-01-30 08:50:45 -0800 | [diff] [blame] | 93 | static void __init msm_dt_reserve(void) |
| 94 | { |
| 95 | if (early_machine_is_copper()) |
| 96 | msm_copper_reserve(); |
| 97 | } |
| 98 | |
| 99 | static void __init msm_dt_init_very_early(void) |
| 100 | { |
| 101 | if (early_machine_is_copper()) |
| 102 | msm_copper_very_early(); |
| 103 | } |
| 104 | |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 105 | DT_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 Ambley | 9b40e7d | 2012-01-03 16:50:44 -0800 | [diff] [blame] | 109 | .handle_irq = gic_handle_irq, |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 110 | .timer = &msm_dt_timer, |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 111 | .dt_compat = msm_dt_match, |
Michael Bohan | ce4b20b | 2012-01-06 15:59:39 -0800 | [diff] [blame] | 112 | .nr_irqs = -1, |
Olav Haugan | b800c8c | 2012-01-30 08:50:45 -0800 | [diff] [blame] | 113 | .reserve = msm_dt_reserve, |
| 114 | .init_very_early = msm_dt_init_very_early, |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 115 | MACHINE_END |