Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 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> |
| 20 | #include <asm/arch_timer.h> |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 21 | #include <asm/mach/arch.h> |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame^] | 22 | #include <asm/mach/time.h> |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 23 | #include <mach/socinfo.h> |
| 24 | #include <mach/board.h> |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame^] | 25 | |
| 26 | static void __init msm_dt_timer_init(void) |
| 27 | { |
| 28 | struct device_node *node; |
| 29 | struct resource res; |
| 30 | struct of_irq oirq; |
| 31 | |
| 32 | node = of_find_compatible_node(NULL, NULL, "qcom,msm-qtimer"); |
| 33 | if (!node) { |
| 34 | pr_err("no matching timer node found\n"); |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | if (of_irq_map_one(node, 0, &oirq)) { |
| 39 | pr_err("interrupt not specified in timer node\n"); |
| 40 | } else { |
| 41 | res.start = res.end = oirq.specifier[0]; |
| 42 | res.flags = IORESOURCE_IRQ; |
| 43 | arch_timer_register(&res, 1); |
| 44 | } |
| 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 | |
| 57 | int local_timer_ack(void) |
| 58 | { |
| 59 | return 1; |
| 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 | |
| 93 | DT_MACHINE_START(MSM_DT, "Qualcomm MSM (Flattened Device Tree)") |
| 94 | .map_io = msm_dt_map_io, |
| 95 | .init_irq = msm_dt_init_irq, |
| 96 | .init_machine = msm_dt_init, |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame^] | 97 | .timer = &msm_dt_timer, |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 98 | .dt_compat = msm_dt_match, |
| 99 | MACHINE_END |