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> |
Stepan Moskovchenko | a000d13 | 2012-08-14 21:05:14 -0700 | [diff] [blame] | 26 | #include <mach/restart.h> |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 27 | |
| 28 | static void __init msm_dt_timer_init(void) |
| 29 | { |
Sathish Ambley | 2f27a17 | 2012-03-16 10:46:28 -0700 | [diff] [blame] | 30 | arch_timer_of_register(); |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | static struct sys_timer msm_dt_timer = { |
| 34 | .init = msm_dt_timer_init |
| 35 | }; |
| 36 | |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 37 | static void __init msm_dt_init_irq(void) |
| 38 | { |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 39 | if (machine_is_msm8974()) |
| 40 | msm_8974_init_irq(); |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | static void __init msm_dt_map_io(void) |
| 44 | { |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 45 | if (early_machine_is_msm8974()) |
| 46 | msm_map_8974_io(); |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 47 | if (socinfo_init() < 0) |
| 48 | pr_err("%s: socinfo_init() failed\n", __func__); |
| 49 | } |
| 50 | |
| 51 | static void __init msm_dt_init(void) |
| 52 | { |
| 53 | struct of_dev_auxdata *adata = NULL; |
| 54 | |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 55 | if (machine_is_msm8974()) |
| 56 | msm_8974_init(&adata); |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 57 | |
| 58 | of_platform_populate(NULL, of_default_bus_match_table, adata, NULL); |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 59 | if (machine_is_msm8974()) { |
| 60 | msm_8974_add_devices(); |
| 61 | msm_8974_add_drivers(); |
Michael Bohan | e7c2b47 | 2012-03-30 14:27:18 -0700 | [diff] [blame] | 62 | } |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 63 | } |
| 64 | |
David Brown | 2545426 | 2012-03-29 15:28:43 -0700 | [diff] [blame] | 65 | static const char *msm_dt_match[] __initconst = { |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 66 | "qcom,msm8974", |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 67 | NULL |
| 68 | }; |
| 69 | |
Olav Haugan | b800c8c | 2012-01-30 08:50:45 -0800 | [diff] [blame] | 70 | static void __init msm_dt_reserve(void) |
| 71 | { |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 72 | if (early_machine_is_msm8974()) |
| 73 | msm_8974_reserve(); |
Olav Haugan | b800c8c | 2012-01-30 08:50:45 -0800 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | static void __init msm_dt_init_very_early(void) |
| 77 | { |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 78 | if (early_machine_is_msm8974()) |
| 79 | msm_8974_very_early(); |
Olav Haugan | b800c8c | 2012-01-30 08:50:45 -0800 | [diff] [blame] | 80 | } |
| 81 | |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 82 | DT_MACHINE_START(MSM_DT, "Qualcomm MSM (Flattened Device Tree)") |
| 83 | .map_io = msm_dt_map_io, |
| 84 | .init_irq = msm_dt_init_irq, |
| 85 | .init_machine = msm_dt_init, |
Sathish Ambley | 9b40e7d | 2012-01-03 16:50:44 -0800 | [diff] [blame] | 86 | .handle_irq = gic_handle_irq, |
Sathish Ambley | 098f9bd | 2011-11-09 16:32:53 -0800 | [diff] [blame] | 87 | .timer = &msm_dt_timer, |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 88 | .dt_compat = msm_dt_match, |
Olav Haugan | b800c8c | 2012-01-30 08:50:45 -0800 | [diff] [blame] | 89 | .reserve = msm_dt_reserve, |
| 90 | .init_very_early = msm_dt_init_very_early, |
Stepan Moskovchenko | a000d13 | 2012-08-14 21:05:14 -0700 | [diff] [blame] | 91 | .restart = msm_restart, |
Sathish Ambley | c58afc2 | 2011-10-09 21:55:39 -0700 | [diff] [blame] | 92 | MACHINE_END |