blob: 1f77b4c1fe9dce40c341f80a7325f40332ae270e [file] [log] [blame]
Abhimanyu Kapur032b1f42013-01-18 00:10:50 -08001/* Copyright (c) 2011-2013, The Linux Foundation. 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
Rohit Vaswani750bee12012-09-20 16:18:10 -070013#include <linux/gpio.h>
Sathish Ambleyc58afc22011-10-09 21:55:39 -070014#include <linux/kernel.h>
Sathish Ambleyc58afc22011-10-09 21:55:39 -070015#include <linux/of.h>
Sathish Ambley098f9bd2011-11-09 16:32:53 -080016#include <linux/of_irq.h>
Abhimanyu Kapur032b1f42013-01-18 00:10:50 -080017#include <linux/of_fdt.h>
Rohit Vaswani750bee12012-09-20 16:18:10 -070018#include <linux/mfd/wcd9xxx/core.h>
Sathish Ambley098f9bd2011-11-09 16:32:53 -080019#include <asm/arch_timer.h>
Sathish Ambley098f9bd2011-11-09 16:32:53 -080020#include <asm/mach/time.h>
Abhimanyu Kapur032b1f42013-01-18 00:10:50 -080021#include <asm/mach/map.h>
Rohit Vaswani7af3b532012-09-21 10:54:49 -070022#include <asm/hardware/cache-l2x0.h>
Rohit Vaswani750bee12012-09-20 16:18:10 -070023#include <asm/hardware/gic.h>
24#include <mach/mpm.h>
25#include <mach/qpnp-int.h>
Abhimanyu Kapur032b1f42013-01-18 00:10:50 -080026#include <mach/msm_iomap.h>
Rohit Vaswani7af3b532012-09-21 10:54:49 -070027#include <mach/scm.h>
Rohit Vaswani750bee12012-09-20 16:18:10 -070028
29#include "board-dt.h"
Sathish Ambley098f9bd2011-11-09 16:32:53 -080030
Rohit Vaswani7af3b532012-09-21 10:54:49 -070031#define SCM_SVC_L2CC_PL310 16
32#define L2CC_PL310_CTRL_ID 1
33#define L2CC_PL310_ON 1
34
Sathish Ambley098f9bd2011-11-09 16:32:53 -080035static void __init msm_dt_timer_init(void)
36{
Sathish Ambley2f27a172012-03-16 10:46:28 -070037 arch_timer_of_register();
Sathish Ambley098f9bd2011-11-09 16:32:53 -080038}
39
Rohit Vaswani750bee12012-09-20 16:18:10 -070040struct sys_timer msm_dt_timer = {
Sathish Ambley098f9bd2011-11-09 16:32:53 -080041 .init = msm_dt_timer_init
42};
43
Rohit Vaswani750bee12012-09-20 16:18:10 -070044static struct of_device_id irq_match[] __initdata = {
45 { .compatible = "qcom,msm-qgic2", .data = gic_of_init, },
46 { .compatible = "qcom,msm-gpio", .data = msm_gpio_of_init, },
47 { .compatible = "qcom,spmi-pmic-arb", .data = qpnpint_of_init, },
48 { .compatible = "qcom,wcd9xxx-irq", .data = wcd9xxx_irq_of_init, },
49 {}
Sathish Ambleyc58afc22011-10-09 21:55:39 -070050};
51
Rohit Vaswani750bee12012-09-20 16:18:10 -070052static struct of_device_id mpm_match[] __initdata = {
53 {.compatible = "qcom,mpm-v2", },
54 {}
55};
Olav Hauganb800c8c2012-01-30 08:50:45 -080056
Rohit Vaswani750bee12012-09-20 16:18:10 -070057void __init msm_dt_init_irq(void)
Olav Hauganb800c8c2012-01-30 08:50:45 -080058{
Rohit Vaswani750bee12012-09-20 16:18:10 -070059 struct device_node *node;
Olav Hauganb800c8c2012-01-30 08:50:45 -080060
Rohit Vaswani750bee12012-09-20 16:18:10 -070061 of_irq_init(irq_match);
62 node = of_find_matching_node(NULL, mpm_match);
63
64 WARN_ON(!node);
65
66 if (node)
67 of_mpm_init(node);
68}
Rohit Vaswani835707b2012-09-20 16:21:39 -070069
70void __init msm_dt_init_irq_nompm(void)
71{
72 of_irq_init(irq_match);
73}
Rohit Vaswani7af3b532012-09-21 10:54:49 -070074
75void __init msm_dt_init_irq_l2x0(void)
76{
77 scm_call_atomic1(SCM_SVC_L2CC_PL310, L2CC_PL310_CTRL_ID, L2CC_PL310_ON);
78 l2x0_of_init(0, ~0UL);
79 msm_dt_init_irq();
80}
Abhimanyu Kapur032b1f42013-01-18 00:10:50 -080081
82int __init msm_scan_dt_map_imem(unsigned long node, const char *uname,
83 int depth, void *data)
84{
85 unsigned int *imem_prop;
86 unsigned long imem_prop_len;
87 struct map_desc map;
88 int ret;
89 const char *compat = "qcom,msm-imem";
90
91 ret = of_flat_dt_is_compatible(node, compat);
92
93 if (!ret)
94 return 0;
95
96 imem_prop = of_get_flat_dt_prop(node, "reg",
97 &imem_prop_len);
98
99 if (!imem_prop) {
100 WARN(1, "IMEM reg field not found\n");
101 return 0;
102 }
103
104 if (imem_prop_len != (2*sizeof(u32))) {
105 WARN(1, "IMEM range malformed\n");
106 return 0;
107 }
108
109 map.virtual = (unsigned long)MSM_IMEM_BASE;
110 map.pfn = __phys_to_pfn(be32_to_cpu(imem_prop[0]));
111 map.length = be32_to_cpu(imem_prop[1]);
112 map.type = MT_DEVICE;
113 iotable_init(&map, 1);
114 pr_info("IMEM DT static mapping successful\n");
115
116 return 1;
117}
Stepan Moskovchenko7d8cdcaa2013-04-25 17:10:55 -0700118
119void __init board_dt_populate(struct of_dev_auxdata *adata)
120{
121 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
122
123 /* Explicitly parent the /soc devices to the root node to preserve
124 * the kernel ABI (sysfs structure, etc) until userspace is updated
125 */
126 of_platform_populate(of_find_node_by_path("/soc"),
127 of_default_bus_match_table, adata, NULL);
128}