blob: b90d75b6e374d199e9c81b44ef102be8c1adbef6 [file] [log] [blame]
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -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
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -080013#include <linux/err.h>
Sathish Ambleyc58afc22011-10-09 21:55:39 -070014#include <linux/kernel.h>
15#include <linux/platform_device.h>
16#include <linux/io.h>
17#include <linux/irq.h>
18#include <linux/irqdomain.h>
19#include <linux/of.h>
20#include <linux/of_address.h>
21#include <linux/of_platform.h>
Olav Hauganb800c8c2012-01-30 08:50:45 -080022#include <linux/memory.h>
23#ifdef CONFIG_ANDROID_PMEM
24#include <linux/android_pmem.h>
25#endif
Matt Wagantallecaa1172012-05-08 21:38:45 -070026#include <linux/regulator/machine.h>
Michael Bohan2a468322012-08-14 17:06:34 -070027#include <linux/regulator/krait-regulator.h>
Eugene Seahce52ef22012-07-12 12:40:38 -060028#include <linux/msm_thermal.h>
Sathish Ambleyc58afc22011-10-09 21:55:39 -070029#include <asm/mach/map.h>
30#include <asm/hardware/gic.h>
Rohit Vaswani750bee12012-09-20 16:18:10 -070031#include <asm/mach/map.h>
32#include <asm/mach/arch.h>
Sathish Ambleyc58afc22011-10-09 21:55:39 -070033#include <mach/board.h>
Sathish Ambleyc58afc22011-10-09 21:55:39 -070034#include <mach/gpiomux.h>
35#include <mach/msm_iomap.h>
Olav Hauganb800c8c2012-01-30 08:50:45 -080036#ifdef CONFIG_ION_MSM
37#include <mach/ion.h>
38#endif
39#include <mach/msm_memtypes.h>
Jeff Hugo70946092012-02-10 11:30:43 -070040#include <mach/msm_smd.h>
Rohit Vaswani750bee12012-09-20 16:18:10 -070041#include <mach/restart.h>
Mahesh Sivasubramaniana8ff9922012-03-27 17:50:42 -060042#include <mach/rpm-smd.h>
David Collins8f4cebc2012-05-08 16:54:50 -070043#include <mach/rpm-regulator-smd.h>
Vikram Mulukutlaaeadb5f2012-05-04 14:03:07 -070044#include <mach/socinfo.h>
Gagan Macdd9bb792012-04-25 16:56:48 -060045#include <mach/msm_bus_board.h>
Rohit Vaswani750bee12012-09-20 16:18:10 -070046#include "board-dt.h"
Sathish Ambleyc58afc22011-10-09 21:55:39 -070047#include "clock.h"
Michael Bohan037a0f52012-02-29 19:13:09 -080048#include "devices.h"
Praveen Chidambaramda9501d2012-04-26 19:48:29 -060049#include "spm.h"
Jeff Hugoa643ca12012-06-11 16:00:23 -060050#include "modem_notifier.h"
Girish Mahadevan40abbe12012-04-25 14:58:13 -060051#include "lpm_resources.h"
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -080052#include "platsmp.h"
Sathish Ambleyc58afc22011-10-09 21:55:39 -070053
Olav Hauganb800c8c2012-01-30 08:50:45 -080054
Rohit Vaswani750bee12012-09-20 16:18:10 -070055static struct memtype_reserve msm8974_reserve_table[] __initdata = {
Olav Hauganb800c8c2012-01-30 08:50:45 -080056 [MEMTYPE_SMI] = {
57 },
58 [MEMTYPE_EBI0] = {
59 .flags = MEMTYPE_FLAGS_1M_ALIGN,
60 },
61 [MEMTYPE_EBI1] = {
62 .flags = MEMTYPE_FLAGS_1M_ALIGN,
63 },
64};
65
Rohit Vaswani750bee12012-09-20 16:18:10 -070066static int msm8974_paddr_to_memtype(unsigned int paddr)
Olav Hauganb800c8c2012-01-30 08:50:45 -080067{
68 return MEMTYPE_EBI1;
69}
70
Rohit Vaswani750bee12012-09-20 16:18:10 -070071static struct reserve_info msm8974_reserve_info __initdata = {
72 .memtype_reserve_table = msm8974_reserve_table,
Rohit Vaswani750bee12012-09-20 16:18:10 -070073 .paddr_to_memtype = msm8974_paddr_to_memtype,
Olav Hauganb800c8c2012-01-30 08:50:45 -080074};
75
Neeti Desai1b2cb552012-11-01 21:57:36 -070076void __init msm_8974_reserve(void)
Olav Hauganb800c8c2012-01-30 08:50:45 -080077{
Rohit Vaswani750bee12012-09-20 16:18:10 -070078 reserve_info = &msm8974_reserve_info;
79 of_scan_flat_dt(dt_scan_for_memory_reserve, msm8974_reserve_table);
Neeti Desai1b2cb552012-11-01 21:57:36 -070080 msm_reserve();
81}
82
83static void __init msm8974_early_memory(void)
84{
85 reserve_info = &msm8974_reserve_info;
86 of_scan_flat_dt(dt_scan_for_memory_hole, msm8974_reserve_table);
Olav Hauganb800c8c2012-01-30 08:50:45 -080087}
88
Gagan Macdd9bb792012-04-25 16:56:48 -060089#define BIMC_BASE 0xfc380000
90#define BIMC_SIZE 0x0006A000
91#define SYS_NOC_BASE 0xfc460000
92#define PERIPH_NOC_BASE 0xFC468000
93#define OCMEM_NOC_BASE 0xfc470000
94#define MMSS_NOC_BASE 0xfc478000
95#define CONFIG_NOC_BASE 0xfc480000
96#define NOC_SIZE 0x00004000
97
98static struct resource bimc_res[] = {
99 {
100 .start = BIMC_BASE,
101 .end = BIMC_BASE + BIMC_SIZE,
102 .flags = IORESOURCE_MEM,
103 .name = "bimc_mem",
104 },
105};
106
107static struct resource ocmem_noc_res[] = {
108 {
109 .start = OCMEM_NOC_BASE,
110 .end = OCMEM_NOC_BASE + NOC_SIZE,
111 .flags = IORESOURCE_MEM,
112 .name = "ocmem_noc_mem",
113 },
114};
115
116static struct resource mmss_noc_res[] = {
117 {
118 .start = MMSS_NOC_BASE,
119 .end = MMSS_NOC_BASE + NOC_SIZE,
120 .flags = IORESOURCE_MEM,
121 .name = "mmss_noc_mem",
122 },
123};
124
125static struct resource sys_noc_res[] = {
126 {
127 .start = SYS_NOC_BASE,
128 .end = SYS_NOC_BASE + NOC_SIZE,
129 .flags = IORESOURCE_MEM,
130 .name = "sys_noc_mem",
131 },
132};
133
134static struct resource config_noc_res[] = {
135 {
136 .start = CONFIG_NOC_BASE,
137 .end = CONFIG_NOC_BASE + NOC_SIZE,
138 .flags = IORESOURCE_MEM,
139 .name = "config_noc_mem",
140 },
141};
142
143static struct resource periph_noc_res[] = {
144 {
145 .start = PERIPH_NOC_BASE,
146 .end = PERIPH_NOC_BASE + NOC_SIZE,
147 .flags = IORESOURCE_MEM,
148 .name = "periph_noc_mem",
149 },
150};
151
152static struct platform_device msm_bus_sys_noc = {
153 .name = "msm_bus_fabric",
154 .id = MSM_BUS_FAB_SYS_NOC,
155 .num_resources = ARRAY_SIZE(sys_noc_res),
156 .resource = sys_noc_res,
157};
158
159static struct platform_device msm_bus_bimc = {
160 .name = "msm_bus_fabric",
161 .id = MSM_BUS_FAB_BIMC,
162 .num_resources = ARRAY_SIZE(bimc_res),
163 .resource = bimc_res,
164};
165
166static struct platform_device msm_bus_mmss_noc = {
167 .name = "msm_bus_fabric",
168 .id = MSM_BUS_FAB_MMSS_NOC,
169 .num_resources = ARRAY_SIZE(mmss_noc_res),
170 .resource = mmss_noc_res,
171};
172
173static struct platform_device msm_bus_ocmem_noc = {
174 .name = "msm_bus_fabric",
175 .id = MSM_BUS_FAB_OCMEM_NOC,
176 .num_resources = ARRAY_SIZE(ocmem_noc_res),
177 .resource = ocmem_noc_res,
178};
179
180static struct platform_device msm_bus_periph_noc = {
181 .name = "msm_bus_fabric",
182 .id = MSM_BUS_FAB_PERIPH_NOC,
183 .num_resources = ARRAY_SIZE(periph_noc_res),
184 .resource = periph_noc_res,
185};
186
187static struct platform_device msm_bus_config_noc = {
188 .name = "msm_bus_fabric",
189 .id = MSM_BUS_FAB_CONFIG_NOC,
190 .num_resources = ARRAY_SIZE(config_noc_res),
191 .resource = config_noc_res,
192};
193
194static struct platform_device msm_bus_ocmem_vnoc = {
195 .name = "msm_bus_fabric",
196 .id = MSM_BUS_FAB_OCMEM_VNOC,
197};
198
Bhakthavatsala Raghavendrab9766542012-08-17 16:25:48 -0700199static struct platform_device msm_fm_platform_init = {
200 .name = "iris_fm",
201 .id = -1,
202};
203
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700204static struct platform_device *msm_bus_8974_devices[] = {
Gagan Macdd9bb792012-04-25 16:56:48 -0600205 &msm_bus_sys_noc,
206 &msm_bus_bimc,
207 &msm_bus_mmss_noc,
208 &msm_bus_ocmem_noc,
209 &msm_bus_periph_noc,
210 &msm_bus_config_noc,
211 &msm_bus_ocmem_vnoc,
Bhakthavatsala Raghavendrab9766542012-08-17 16:25:48 -0700212 &msm_fm_platform_init,
Gagan Macdd9bb792012-04-25 16:56:48 -0600213};
214
Amy Maloche357e8c72012-07-25 16:41:18 -0700215static ssize_t mxt336s_vkeys_show(struct kobject *kobj,
216 struct kobj_attribute *attr, char *buf)
217{
218 return snprintf(buf, 200,
219 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":62:1345:90:90" \
220 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":240:1345:90:90" \
221 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":470:1345:90:90" \
222 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":658:1345:90:90" \
223 "\n");
224}
225
226static struct kobj_attribute mxt336s_vkeys_attr = {
227 .attr = {
228 .mode = S_IRUGO,
229 },
230 .show = &mxt336s_vkeys_show,
231};
232
233static struct attribute *mxt336s_properties_attrs[] = {
234 &mxt336s_vkeys_attr.attr,
235 NULL
236};
237
238static struct attribute_group mxt336s_properties_attr_group = {
239 .attrs = mxt336s_properties_attrs,
240};
241
242static void mxt_init_vkeys_8974(void)
243{
244 int rc = 0;
245 static struct kobject *mxt336s_properties_kobj;
246
247 mxt336s_vkeys_attr.attr.name = "virtualkeys.atmel_mxt_ts";
248 mxt336s_properties_kobj = kobject_create_and_add("board_properties",
249 NULL);
250 if (mxt336s_properties_kobj)
251 rc = sysfs_create_group(mxt336s_properties_kobj,
252 &mxt336s_properties_attr_group);
253 if (!mxt336s_properties_kobj || rc)
254 pr_err("%s: failed to create board_properties\n",
255 __func__);
256
257 return;
258}
259
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700260static void __init msm8974_init_buses(void)
Gagan Macdd9bb792012-04-25 16:56:48 -0600261{
262#ifdef CONFIG_MSM_BUS_SCALING
263 msm_bus_sys_noc.dev.platform_data =
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700264 &msm_bus_8974_sys_noc_pdata;
265 msm_bus_bimc.dev.platform_data = &msm_bus_8974_bimc_pdata;
266 msm_bus_mmss_noc.dev.platform_data = &msm_bus_8974_mmss_noc_pdata;
267 msm_bus_ocmem_noc.dev.platform_data = &msm_bus_8974_ocmem_noc_pdata;
268 msm_bus_periph_noc.dev.platform_data = &msm_bus_8974_periph_noc_pdata;
269 msm_bus_config_noc.dev.platform_data = &msm_bus_8974_config_noc_pdata;
270 msm_bus_ocmem_vnoc.dev.platform_data = &msm_bus_8974_ocmem_vnoc_pdata;
Gagan Macdd9bb792012-04-25 16:56:48 -0600271#endif
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700272 platform_add_devices(msm_bus_8974_devices,
273 ARRAY_SIZE(msm_bus_8974_devices));
Gagan Macdd9bb792012-04-25 16:56:48 -0600274};
Hariprasad Dhalinarasimhaf42732a2012-05-21 18:00:49 -0700275
Vikram Mulukutlaaa6f36c2012-06-12 18:16:29 -0700276/*
277 * Used to satisfy dependencies for devices that need to be
278 * run early or in a particular order. Most likely your device doesn't fall
279 * into this category, and thus the driver should not be added here. The
280 * EPROBE_DEFER can satisfy most dependency problems.
281 */
Rohit Vaswani750bee12012-09-20 16:18:10 -0700282void __init msm8974_add_drivers(void)
Vikram Mulukutlaaa6f36c2012-06-12 18:16:29 -0700283{
Jeff Hugoa643ca12012-06-11 16:00:23 -0600284 msm_init_modem_notifier_list();
Vikram Mulukutlaaa6f36c2012-06-12 18:16:29 -0700285 msm_smd_init();
286 msm_rpm_driver_init();
Girish Mahadevan40abbe12012-04-25 14:58:13 -0600287 msm_lpmrs_module_init();
Vikram Mulukutlaaa6f36c2012-06-12 18:16:29 -0700288 rpm_regulator_smd_driver_init();
289 msm_spm_device_init();
Michael Bohan2a468322012-08-14 17:06:34 -0700290 krait_power_init();
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700291 if (machine_is_msm8974_rumi())
Vikram Mulukutla19245e02012-07-23 15:58:04 -0700292 msm_clock_init(&msm8974_rumi_clock_init_data);
Vikram Mulukutlaaa6f36c2012-06-12 18:16:29 -0700293 else
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700294 msm_clock_init(&msm8974_clock_init_data);
295 msm8974_init_buses();
Eugene Seahce52ef22012-07-12 12:40:38 -0600296 msm_thermal_device_init();
Amy Maloche357e8c72012-07-25 16:41:18 -0700297 mxt_init_vkeys_8974();
Vikram Mulukutlaaa6f36c2012-06-12 18:16:29 -0700298}
299
Rohit Vaswani750bee12012-09-20 16:18:10 -0700300static struct of_dev_auxdata msm8974_auxdata_lookup[] __initdata = {
Pavankumar Kondeti0063b842012-01-16 12:19:58 +0530301 OF_DEV_AUXDATA("qcom,hsusb-otg", 0xF9A55000, \
302 "msm_otg", NULL),
Manu Gautam51be9712012-06-06 14:54:52 +0530303 OF_DEV_AUXDATA("qcom,dwc-usb3-msm", 0xF9200000, \
304 "msm_dwc3", NULL),
Shimrit Malichi57ae1492012-08-06 14:03:45 +0300305 OF_DEV_AUXDATA("qcom,usb-bam-msm", 0xF9304000, \
306 "usb_bam", NULL),
Harini Jayaraman5f98dbb2011-12-20 13:38:19 -0700307 OF_DEV_AUXDATA("qcom,spi-qup-v2", 0xF9924000, \
308 "spi_qsd.1", NULL),
Sujit Reddy Thumma85fc52c2012-05-02 12:53:45 +0530309 OF_DEV_AUXDATA("qcom,msm-sdcc", 0xF9824000, \
David Ng665140f2012-04-12 16:03:45 -0700310 "msm_sdcc.1", NULL),
Sujit Reddy Thumma85fc52c2012-05-02 12:53:45 +0530311 OF_DEV_AUXDATA("qcom,msm-sdcc", 0xF98A4000, \
312 "msm_sdcc.2", NULL),
313 OF_DEV_AUXDATA("qcom,msm-sdcc", 0xF9864000, \
David Ng665140f2012-04-12 16:03:45 -0700314 "msm_sdcc.3", NULL),
Sujit Reddy Thumma85fc52c2012-05-02 12:53:45 +0530315 OF_DEV_AUXDATA("qcom,msm-sdcc", 0xF98E4000, \
316 "msm_sdcc.4", NULL),
Pratik Patel80515b52012-06-17 17:57:24 -0700317 OF_DEV_AUXDATA("arm,coresight-tmc", 0xFC322000, \
318 "coresight-tmc-etr", NULL),
319 OF_DEV_AUXDATA("arm,coresight-tpiu", 0xFC318000, \
320 "coresight-tpiu", NULL),
321 OF_DEV_AUXDATA("qcom,coresight-replicator", 0xFC31C000, \
322 "coresight-replicator", NULL),
323 OF_DEV_AUXDATA("arm,coresight-tmc", 0xFC307000, \
324 "coresight-tmc-etf", NULL),
325 OF_DEV_AUXDATA("arm,coresight-funnel", 0xFC31B000, \
326 "coresight-funnel-merg", NULL),
327 OF_DEV_AUXDATA("arm,coresight-funnel", 0xFC319000, \
328 "coresight-funnel-in0", NULL),
329 OF_DEV_AUXDATA("arm,coresight-funnel", 0xFC31A000, \
330 "coresight-funnel-in1", NULL),
331 OF_DEV_AUXDATA("arm,coresight-funnel", 0xFC345000, \
332 "coresight-funnel-kpss", NULL),
333 OF_DEV_AUXDATA("arm,coresight-funnel", 0xFC364000, \
334 "coresight-funnel-mmss", NULL),
335 OF_DEV_AUXDATA("arm,coresight-stm", 0xFC321000, \
336 "coresight-stm", NULL),
337 OF_DEV_AUXDATA("arm,coresight-etm", 0xFC33C000, \
338 "coresight-etm0", NULL),
339 OF_DEV_AUXDATA("arm,coresight-etm", 0xFC33D000, \
340 "coresight-etm1", NULL),
341 OF_DEV_AUXDATA("arm,coresight-etm", 0xFC33E000, \
342 "coresight-etm2", NULL),
343 OF_DEV_AUXDATA("arm,coresight-etm", 0xFC33F000, \
344 "coresight-etm3", NULL),
Hariprasad Dhalinarasimhade991f02012-05-31 13:15:51 -0700345 OF_DEV_AUXDATA("qcom,msm-rng", 0xF9BFF000, \
346 "msm_rng", NULL),
Ramesh Masavarapufb1f01e2012-06-14 09:40:40 -0700347 OF_DEV_AUXDATA("qcom,qseecom", 0xFE806000, \
348 "qseecom", NULL),
Adrian Salido-Moreno5ef3ac02012-05-14 18:40:47 -0700349 OF_DEV_AUXDATA("qcom,mdss_mdp", 0xFD900000, "mdp.0", NULL),
Siddartha Mohanadoss0a188882012-07-06 15:51:00 -0700350 OF_DEV_AUXDATA("qcom,msm-tsens", 0xFC4A8000, \
351 "msm-tsens", NULL),
Mona Hossainb43e94b2012-05-07 08:52:06 -0700352 OF_DEV_AUXDATA("qcom,qcedev", 0xFD440000, \
353 "qcedev.0", NULL),
354 OF_DEV_AUXDATA("qcom,qcrypto", 0xFD440000, \
355 "qcrypto.0", NULL),
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700356 {}
357};
358
Rohit Vaswani750bee12012-09-20 16:18:10 -0700359static void __init msm8974_map_io(void)
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700360{
Rohit Vaswani750bee12012-09-20 16:18:10 -0700361 msm_map_8974_io();
Rohit Vaswani750bee12012-09-20 16:18:10 -0700362}
363
364void __init msm8974_init(void)
365{
366 struct of_dev_auxdata *adata = msm8974_auxdata_lookup;
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -0800367 struct device *parent;
368
369 parent = socinfo_init();
370 if (IS_ERR_OR_NULL(parent))
371 pr_err("%s: socinfo_init() failed\n", __func__);
Rohit Vaswani750bee12012-09-20 16:18:10 -0700372
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700373 msm_8974_init_gpiomux();
Matt Wagantallecaa1172012-05-08 21:38:45 -0700374 regulator_has_full_constraints();
Rohit Vaswani750bee12012-09-20 16:18:10 -0700375 of_platform_populate(NULL, of_default_bus_match_table, adata, NULL);
Rohit Vaswani750bee12012-09-20 16:18:10 -0700376 msm8974_add_drivers();
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700377}
Olav Hauganb800c8c2012-01-30 08:50:45 -0800378
Rohit Vaswani750bee12012-09-20 16:18:10 -0700379void __init msm8974_init_very_early(void)
Olav Hauganb800c8c2012-01-30 08:50:45 -0800380{
Rohit Vaswani750bee12012-09-20 16:18:10 -0700381 msm8974_early_memory();
Olav Hauganb800c8c2012-01-30 08:50:45 -0800382}
Rohit Vaswani750bee12012-09-20 16:18:10 -0700383
384static const char *msm8974_dt_match[] __initconst = {
385 "qcom,msm8974",
386 NULL
387};
388
389DT_MACHINE_START(MSM8974_DT, "Qualcomm MSM 8974 (Flattened Device Tree)")
390 .map_io = msm8974_map_io,
391 .init_irq = msm_dt_init_irq,
392 .init_machine = msm8974_init,
393 .handle_irq = gic_handle_irq,
394 .timer = &msm_dt_timer,
395 .dt_compat = msm8974_dt_match,
Neeti Desai1b2cb552012-11-01 21:57:36 -0700396 .reserve = msm_8974_reserve,
Rohit Vaswani750bee12012-09-20 16:18:10 -0700397 .init_very_early = msm8974_init_very_early,
398 .restart = msm_restart,
Syed Rameez Mustafa9de46342012-11-30 11:00:08 -0800399 .smp = &msm8974_smp_ops,
Rohit Vaswani750bee12012-09-20 16:18:10 -0700400MACHINE_END