blob: dad15614d38054bcd447b5d7b069012cfe22103f [file] [log] [blame]
Michael Bohan0425f6f2012-01-17 14:36:39 -08001/* Copyright (c) 2011-2012, Code Aurora Forum. 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
13#include <linux/kernel.h>
14#include <linux/platform_device.h>
15#include <linux/io.h>
16#include <linux/irq.h>
17#include <linux/irqdomain.h>
18#include <linux/of.h>
19#include <linux/of_address.h>
20#include <linux/of_platform.h>
Michael Bohanc7224532012-01-06 16:02:52 -080021#include <linux/of_irq.h>
Olav Hauganb800c8c2012-01-30 08:50:45 -080022#ifdef CONFIG_ION_MSM
23#include <linux/ion.h>
24#endif
25#include <linux/memory.h>
26#ifdef CONFIG_ANDROID_PMEM
27#include <linux/android_pmem.h>
28#endif
Michael Bohan037a0f52012-02-29 19:13:09 -080029#include <linux/regulator/stub-regulator.h>
Sathish Ambleyc58afc22011-10-09 21:55:39 -070030#include <asm/mach/map.h>
31#include <asm/hardware/gic.h>
32#include <mach/board.h>
33#include <mach/gpio.h>
34#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>
Michael Bohan115cf652012-01-05 14:32:59 -080041#include <mach/qpnp-int.h>
Sathish Ambleyc58afc22011-10-09 21:55:39 -070042#include "clock.h"
Michael Bohan037a0f52012-02-29 19:13:09 -080043#include "devices.h"
Sathish Ambleyc58afc22011-10-09 21:55:39 -070044
Olav Hauganb800c8c2012-01-30 08:50:45 -080045#define MSM_KERNEL_EBI1_MEM_SIZE 0x280000
46#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
47#define MSM_ION_SF_SIZE 0x4000000 /* 64 Mbytes */
48#else
49#define MSM_ION_SF_SIZE 0x2800000 /* 40 Mbytes */
50#endif
51#define MSM_ION_MM_FW_SIZE 0x200000 /* (2MB) */
52#define MSM_ION_MM_SIZE 0x7800000 /* (120MB) */
53#define MSM_ION_QSECOM_SIZE 0x100000 /* (1MB) */
54#define MSM_ION_MFC_SIZE SZ_8K
55#define MSM_ION_AUDIO_SIZE 0x2B4000
56#define MSM_ION_HEAP_NUM 8
57
58#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
59static unsigned kernel_ebi1_mem_size = MSM_KERNEL_EBI1_MEM_SIZE;
60static int __init kernel_ebi1_mem_size_setup(char *p)
61{
62 kernel_ebi1_mem_size = memparse(p, NULL);
63 return 0;
64}
65early_param("kernel_ebi1_mem_size", kernel_ebi1_mem_size_setup);
66#endif
67
68static struct memtype_reserve msm_copper_reserve_table[] __initdata = {
69 [MEMTYPE_SMI] = {
70 },
71 [MEMTYPE_EBI0] = {
72 .flags = MEMTYPE_FLAGS_1M_ALIGN,
73 },
74 [MEMTYPE_EBI1] = {
75 .flags = MEMTYPE_FLAGS_1M_ALIGN,
76 },
77};
78
79static int msm_copper_paddr_to_memtype(unsigned int paddr)
80{
81 return MEMTYPE_EBI1;
82}
83
84#ifdef CONFIG_ION_MSM
85static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
86 .permission_type = IPT_TYPE_MM_CARVEOUT,
87 .align = PAGE_SIZE,
88};
89
90static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
91 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
92 .align = PAGE_SIZE,
93};
94
95static struct ion_co_heap_pdata co_ion_pdata = {
96 .adjacent_mem_id = INVALID_HEAP_ID,
97 .align = PAGE_SIZE,
98};
99
100static struct ion_co_heap_pdata fw_co_ion_pdata = {
101 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
102 .align = SZ_128K,
103};
104
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800105/**
106 * These heaps are listed in the order they will be allocated. Due to
107 * video hardware restrictions and content protection the FW heap has to
108 * be allocated adjacent (below) the MM heap and the MFC heap has to be
109 * allocated after the MM heap to ensure MFC heap is not more than 256MB
110 * away from the base address of the FW heap.
111 * However, the order of FW heap and MM heap doesn't matter since these
112 * two heaps are taken care of by separate code to ensure they are adjacent
113 * to each other.
114 * Don't swap the order unless you know what you are doing!
115 */
Olav Hauganb800c8c2012-01-30 08:50:45 -0800116static struct ion_platform_data ion_pdata = {
117 .nr = MSM_ION_HEAP_NUM,
118 .heaps = {
119 {
120 .id = ION_SYSTEM_HEAP_ID,
121 .type = ION_HEAP_TYPE_SYSTEM,
122 .name = ION_VMALLOC_HEAP_NAME,
123 },
124 {
Olav Hauganb800c8c2012-01-30 08:50:45 -0800125 .id = ION_CP_MM_HEAP_ID,
126 .type = ION_HEAP_TYPE_CP,
127 .name = ION_MM_HEAP_NAME,
128 .size = MSM_ION_MM_SIZE,
129 .memory_type = ION_EBI_TYPE,
130 .extra_data = (void *) &cp_mm_ion_pdata,
131 },
132 {
133 .id = ION_MM_FIRMWARE_HEAP_ID,
134 .type = ION_HEAP_TYPE_CARVEOUT,
135 .name = ION_MM_FIRMWARE_HEAP_NAME,
136 .size = MSM_ION_MM_FW_SIZE,
137 .memory_type = ION_EBI_TYPE,
138 .extra_data = (void *) &fw_co_ion_pdata,
139 },
140 {
141 .id = ION_CP_MFC_HEAP_ID,
142 .type = ION_HEAP_TYPE_CP,
143 .name = ION_MFC_HEAP_NAME,
144 .size = MSM_ION_MFC_SIZE,
145 .memory_type = ION_EBI_TYPE,
146 .extra_data = (void *) &cp_mfc_ion_pdata,
147 },
148 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800149 .id = ION_SF_HEAP_ID,
150 .type = ION_HEAP_TYPE_CARVEOUT,
151 .name = ION_SF_HEAP_NAME,
152 .size = MSM_ION_SF_SIZE,
153 .memory_type = ION_EBI_TYPE,
154 .extra_data = (void *) &co_ion_pdata,
155 },
156 {
Olav Hauganb800c8c2012-01-30 08:50:45 -0800157 .id = ION_IOMMU_HEAP_ID,
158 .type = ION_HEAP_TYPE_IOMMU,
159 .name = ION_IOMMU_HEAP_NAME,
160 },
161 {
162 .id = ION_QSECOM_HEAP_ID,
163 .type = ION_HEAP_TYPE_CARVEOUT,
164 .name = ION_QSECOM_HEAP_NAME,
165 .size = MSM_ION_QSECOM_SIZE,
166 .memory_type = ION_EBI_TYPE,
167 .extra_data = (void *) &co_ion_pdata,
168 },
169 {
170 .id = ION_AUDIO_HEAP_ID,
171 .type = ION_HEAP_TYPE_CARVEOUT,
172 .name = ION_AUDIO_HEAP_NAME,
173 .size = MSM_ION_AUDIO_SIZE,
174 .memory_type = ION_EBI_TYPE,
175 .extra_data = (void *) &co_ion_pdata,
176 },
177 }
178};
179
180static struct platform_device ion_dev = {
181 .name = "ion-msm",
182 .id = 1,
183 .dev = { .platform_data = &ion_pdata },
184};
185
186static void reserve_ion_memory(void)
187{
188 msm_copper_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MM_SIZE;
189 msm_copper_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MM_FW_SIZE;
190 msm_copper_reserve_table[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE;
191 msm_copper_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MFC_SIZE;
192 msm_copper_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
193 msm_copper_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
194#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
195 msm_copper_reserve_table[MEMTYPE_EBI1].size += kernel_ebi1_mem_size;
196#endif
197}
198#endif
199
Jeff Hugo70946092012-02-10 11:30:43 -0700200static struct resource smd_resource[] = {
201 {
202 .name = "modem_smd_in",
203 .start = 32 + 17, /* mss_sw_to_kpss_ipc_irq0 */
204 .flags = IORESOURCE_IRQ,
205 },
206 {
207 .name = "modem_smsm_in",
208 .start = 32 + 18, /* mss_sw_to_kpss_ipc_irq1 */
209 .flags = IORESOURCE_IRQ,
210 },
211 {
212 .name = "adsp_smd_in",
213 .start = 32 + 156, /* lpass_to_kpss_ipc_irq0 */
214 .flags = IORESOURCE_IRQ,
215 },
216 {
217 .name = "adsp_smsm_in",
218 .start = 32 + 157, /* lpass_to_kpss_ipc_irq1 */
219 .flags = IORESOURCE_IRQ,
220 },
221 {
222 .name = "wcnss_smd_in",
223 .start = 32 + 142, /* WcnssAppsSmdMedIrq */
224 .flags = IORESOURCE_IRQ,
225 },
226 {
227 .name = "wcnss_smsm_in",
228 .start = 32 + 144, /* RicaAppsWlanSmsmIrq */
229 .flags = IORESOURCE_IRQ,
230 },
Jeff Hugo9a5dc6e2012-03-29 14:39:42 -0600231 {
232 .name = "rpm_smd_in",
233 .start = 32 + 168, /* rpm_to_kpss_ipc_irq4 */
234 .flags = IORESOURCE_IRQ,
235 },
Jeff Hugo70946092012-02-10 11:30:43 -0700236};
237
238static struct smd_subsystem_config smd_config_list[] = {
239 {
240 .irq_config_id = SMD_MODEM,
241 .subsys_name = "modem",
242 .edge = SMD_APPS_MODEM,
243
244 .smd_int.irq_name = "modem_smd_in",
245 .smd_int.flags = IRQF_TRIGGER_RISING,
246 .smd_int.irq_id = -1,
247 .smd_int.device_name = "smd_dev",
248 .smd_int.dev_id = 0,
249 .smd_int.out_bit_pos = 1 << 12,
250 .smd_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
251 .smd_int.out_offset = 0x8,
252
253 .smsm_int.irq_name = "modem_smsm_in",
254 .smsm_int.flags = IRQF_TRIGGER_RISING,
255 .smsm_int.irq_id = -1,
256 .smsm_int.device_name = "smsm_dev",
257 .smsm_int.dev_id = 0,
258 .smsm_int.out_bit_pos = 1 << 13,
259 .smsm_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
260 .smsm_int.out_offset = 0x8,
261 },
262 {
263 .irq_config_id = SMD_Q6,
264 .subsys_name = "q6",
265 .edge = SMD_APPS_QDSP,
266
267 .smd_int.irq_name = "adsp_smd_in",
268 .smd_int.flags = IRQF_TRIGGER_RISING,
269 .smd_int.irq_id = -1,
270 .smd_int.device_name = "smd_dev",
271 .smd_int.dev_id = 0,
272 .smd_int.out_bit_pos = 1 << 8,
273 .smd_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
274 .smd_int.out_offset = 0x8,
275
276 .smsm_int.irq_name = "adsp_smsm_in",
277 .smsm_int.flags = IRQF_TRIGGER_RISING,
278 .smsm_int.irq_id = -1,
279 .smsm_int.device_name = "smsm_dev",
280 .smsm_int.dev_id = 0,
281 .smsm_int.out_bit_pos = 1 << 9,
282 .smsm_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
283 .smsm_int.out_offset = 0x8,
284 },
285 {
286 .irq_config_id = SMD_WCNSS,
287 .subsys_name = "wcnss",
288 .edge = SMD_APPS_WCNSS,
289
290 .smd_int.irq_name = "wcnss_smd_in",
291 .smd_int.flags = IRQF_TRIGGER_RISING,
292 .smd_int.irq_id = -1,
293 .smd_int.device_name = "smd_dev",
294 .smd_int.dev_id = 0,
295 .smd_int.out_bit_pos = 1 << 17,
296 .smd_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
297 .smd_int.out_offset = 0x8,
298
299 .smsm_int.irq_name = "wcnss_smsm_in",
300 .smsm_int.flags = IRQF_TRIGGER_RISING,
301 .smsm_int.irq_id = -1,
302 .smsm_int.device_name = "smsm_dev",
303 .smsm_int.dev_id = 0,
304 .smsm_int.out_bit_pos = 1 << 19,
305 .smsm_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
306 .smsm_int.out_offset = 0x8,
307 },
Jeff Hugo9a5dc6e2012-03-29 14:39:42 -0600308 {
309 .irq_config_id = SMD_RPM,
310 .subsys_name = NULL, /* do not use PIL to load RPM */
311 .edge = SMD_APPS_RPM,
312
313 .smd_int.irq_name = "rpm_smd_in",
314 .smd_int.flags = IRQF_TRIGGER_RISING,
315 .smd_int.irq_id = -1,
316 .smd_int.device_name = "smd_dev",
317 .smd_int.dev_id = 0,
318 .smd_int.out_bit_pos = 1 << 0,
319 .smd_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
320 .smd_int.out_offset = 0x8,
321
322 .smsm_int.irq_name = NULL, /* RPM does not support SMSM */
323 .smsm_int.flags = 0,
324 .smsm_int.irq_id = 0,
325 .smsm_int.device_name = NULL,
326 .smsm_int.dev_id = 0,
327 .smsm_int.out_bit_pos = 0,
328 .smsm_int.out_base = NULL,
329 .smsm_int.out_offset = 0,
330 },
331};
332
333static struct smd_smem_regions aux_smem_areas[] = {
334 {
335 .phys_addr = (void *)(0xfc428000),
336 .size = 0x4000,
337 },
Jeff Hugo70946092012-02-10 11:30:43 -0700338};
339
340static struct smd_platform smd_platform_data = {
341 .num_ss_configs = ARRAY_SIZE(smd_config_list),
342 .smd_ss_configs = smd_config_list,
Jeff Hugo9a5dc6e2012-03-29 14:39:42 -0600343 .num_smem_areas = ARRAY_SIZE(aux_smem_areas),
344 .smd_smem_areas = aux_smem_areas,
Jeff Hugo70946092012-02-10 11:30:43 -0700345};
346
347struct platform_device msm_device_smd_copper = {
348 .name = "msm_smd",
349 .id = -1,
350 .resource = smd_resource,
351 .num_resources = ARRAY_SIZE(smd_resource),
352 .dev = {
353 .platform_data = &smd_platform_data,
354 }
355};
356
Olav Hauganb800c8c2012-01-30 08:50:45 -0800357static void __init msm_copper_calculate_reserve_sizes(void)
358{
359#ifdef CONFIG_ION_MSM
360 reserve_ion_memory();
361#endif
362}
363
364static struct reserve_info msm_copper_reserve_info __initdata = {
365 .memtype_reserve_table = msm_copper_reserve_table,
366 .calculate_reserve_sizes = msm_copper_calculate_reserve_sizes,
367 .paddr_to_memtype = msm_copper_paddr_to_memtype,
368};
369
370static void __init msm_copper_early_memory(void)
371{
372 reserve_info = &msm_copper_reserve_info;
373}
374
375void __init msm_copper_reserve(void)
376{
377 msm_reserve();
378}
379
Pavankumar Kondeti8c447382012-03-29 09:02:09 +0530380static struct platform_device android_usb_device = {
381 .name = "android_usb",
382 .id = -1,
383};
384
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700385void __init msm_copper_add_devices(void)
386{
Olav Hauganb800c8c2012-01-30 08:50:45 -0800387#ifdef CONFIG_ION_MSM
388 platform_device_register(&ion_dev);
389#endif
Jeff Hugo70946092012-02-10 11:30:43 -0700390 platform_device_register(&msm_device_smd_copper);
Pavankumar Kondeti8c447382012-03-29 09:02:09 +0530391 platform_device_register(&android_usb_device);
Michael Bohan037a0f52012-02-29 19:13:09 -0800392 platform_add_devices(msm_copper_stub_regulator_devices,
393 msm_copper_stub_regulator_devices_len);
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700394}
395
Michael Bohane7c2b472012-03-30 14:27:18 -0700396/*
397 * Used to satisfy dependencies for devices that need to be
398 * run early or in a particular order. Most likely your device doesn't fall
399 * into this category, and thus the driver should not be added here. The
400 * EPROBE_DEFER can satisfy most dependency problems.
401 */
402void __init msm_copper_add_drivers(void)
403{
404 regulator_stub_init();
405}
406
Michael Bohanc7224532012-01-06 16:02:52 -0800407static struct of_device_id irq_match[] __initdata = {
408 { .compatible = "qcom,msm-qgic2", .data = gic_of_init, },
Michael Bohan0425f6f2012-01-17 14:36:39 -0800409 { .compatible = "qcom,msm-gpio", .data = msm_gpio_of_init, },
Michael Bohan115cf652012-01-05 14:32:59 -0800410 { .compatible = "qcom,spmi-pmic-arb", .data = qpnpint_of_init, },
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700411 {}
412};
413
414void __init msm_copper_init_irq(void)
415{
Michael Bohanc7224532012-01-06 16:02:52 -0800416 of_irq_init(irq_match);
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700417}
418
419static struct clk_lookup msm_clocks_dummy[] = {
Matt Wagantallb3fe8992011-12-07 19:26:55 -0800420 CLK_DUMMY("xo", XO_CLK, NULL, OFF),
Sathish Ambley3d50c762011-10-25 15:26:00 -0700421 CLK_DUMMY("core_clk", BLSP2_UART_CLK, "msm_serial_hsl.0", OFF),
422 CLK_DUMMY("iface_clk", BLSP2_UART_CLK, "msm_serial_hsl.0", OFF),
Sujit Reddy Thumma1a4a79e2011-11-04 09:44:32 +0530423 CLK_DUMMY("core_clk", SDC1_CLK, NULL, OFF),
424 CLK_DUMMY("iface_clk", SDC1_P_CLK, NULL, OFF),
425 CLK_DUMMY("core_clk", SDC3_CLK, NULL, OFF),
426 CLK_DUMMY("iface_clk", SDC3_P_CLK, NULL, OFF),
Pavankumar Kondeti0063b842012-01-16 12:19:58 +0530427 CLK_DUMMY("phy_clk", NULL, "msm_otg", OFF),
428 CLK_DUMMY("core_clk", NULL, "msm_otg", OFF),
Pavankumar Kondeti0063b842012-01-16 12:19:58 +0530429 CLK_DUMMY("iface_clk", NULL, "msm_otg", OFF),
Pavankumar Kondeti066bfbf2012-02-20 14:10:20 +0530430 CLK_DUMMY("xo", NULL, "msm_otg", OFF),
Yan He1466daa2011-11-30 17:25:38 -0800431 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
432 CLK_DUMMY("dma_bam_pclk", DMA_BAM_P_CLK, NULL, 0),
433 CLK_DUMMY("mem_clk", NULL, NULL, 0),
Harini Jayaraman5f98dbb2011-12-20 13:38:19 -0700434 CLK_DUMMY("core_clk", SPI_CLK, "spi_qsd.1", OFF),
435 CLK_DUMMY("iface_clk", SPI_P_CLK, "spi_qsd.1", OFF),
Sagar Dharia218edb92012-01-15 18:03:01 -0700436 CLK_DUMMY("core_clk", NULL, "f9966000.i2c", 0),
437 CLK_DUMMY("iface_clk", NULL, "f9966000.i2c", 0),
Sagar Dhariaa316a962012-03-21 16:13:22 -0600438 CLK_DUMMY("core_clk", NULL, "fe12f000.slim", OFF),
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700439};
440
441struct clock_init_data msm_dummy_clock_init_data __initdata = {
442 .table = msm_clocks_dummy,
443 .size = ARRAY_SIZE(msm_clocks_dummy),
444};
445
446static struct of_dev_auxdata msm_copper_auxdata_lookup[] __initdata = {
Sathish Ambleyab783ab2011-11-27 22:21:48 -0800447 OF_DEV_AUXDATA("qcom,msm-lsuart-v14", 0xF991F000, \
Sathish Ambley3d50c762011-10-25 15:26:00 -0700448 "msm_serial_hsl.0", NULL),
Pavankumar Kondeti0063b842012-01-16 12:19:58 +0530449 OF_DEV_AUXDATA("qcom,hsusb-otg", 0xF9A55000, \
450 "msm_otg", NULL),
Harini Jayaraman5f98dbb2011-12-20 13:38:19 -0700451 OF_DEV_AUXDATA("qcom,spi-qup-v2", 0xF9924000, \
452 "spi_qsd.1", NULL),
Kenneth Heitkef3c829c2012-01-13 17:02:43 -0700453 OF_DEV_AUXDATA("qcom,spmi-pmic-arb", 0xFC4C0000, \
454 "spmi-pmic-arb.0", NULL),
David Ng665140f2012-04-12 16:03:45 -0700455 OF_DEV_AUXDATA("qcom,msm-sdcc", 0xF980B000, \
456 "msm_sdcc.1", NULL),
457 OF_DEV_AUXDATA("qcom,msm-sdcc", 0xF984B000, \
458 "msm_sdcc.3", NULL),
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700459 {}
460};
461
462void __init msm_copper_init(struct of_dev_auxdata **adata)
463{
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700464 msm_copper_init_gpiomux();
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700465 msm_clock_init(&msm_dummy_clock_init_data);
466
467 *adata = msm_copper_auxdata_lookup;
468}
Olav Hauganb800c8c2012-01-30 08:50:45 -0800469
470void __init msm_copper_very_early(void)
471{
472 msm_copper_early_memory();
473}