blob: dc26d725dc3313c61b9cec169950b8c4c5fe976d [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
Sathish Ambleyc58afc22011-10-09 21:55:39 -070029#include <asm/mach/map.h>
30#include <asm/hardware/gic.h>
31#include <mach/board.h>
32#include <mach/gpio.h>
33#include <mach/gpiomux.h>
34#include <mach/msm_iomap.h>
Olav Hauganb800c8c2012-01-30 08:50:45 -080035#ifdef CONFIG_ION_MSM
36#include <mach/ion.h>
37#endif
38#include <mach/msm_memtypes.h>
Jeff Hugo70946092012-02-10 11:30:43 -070039#include <mach/msm_smd.h>
Sathish Ambleyc58afc22011-10-09 21:55:39 -070040#include "clock.h"
41
Olav Hauganb800c8c2012-01-30 08:50:45 -080042#define MSM_KERNEL_EBI1_MEM_SIZE 0x280000
43#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
44#define MSM_ION_SF_SIZE 0x4000000 /* 64 Mbytes */
45#else
46#define MSM_ION_SF_SIZE 0x2800000 /* 40 Mbytes */
47#endif
48#define MSM_ION_MM_FW_SIZE 0x200000 /* (2MB) */
49#define MSM_ION_MM_SIZE 0x7800000 /* (120MB) */
50#define MSM_ION_QSECOM_SIZE 0x100000 /* (1MB) */
51#define MSM_ION_MFC_SIZE SZ_8K
52#define MSM_ION_AUDIO_SIZE 0x2B4000
53#define MSM_ION_HEAP_NUM 8
54
55#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
56static unsigned kernel_ebi1_mem_size = MSM_KERNEL_EBI1_MEM_SIZE;
57static int __init kernel_ebi1_mem_size_setup(char *p)
58{
59 kernel_ebi1_mem_size = memparse(p, NULL);
60 return 0;
61}
62early_param("kernel_ebi1_mem_size", kernel_ebi1_mem_size_setup);
63#endif
64
65static struct memtype_reserve msm_copper_reserve_table[] __initdata = {
66 [MEMTYPE_SMI] = {
67 },
68 [MEMTYPE_EBI0] = {
69 .flags = MEMTYPE_FLAGS_1M_ALIGN,
70 },
71 [MEMTYPE_EBI1] = {
72 .flags = MEMTYPE_FLAGS_1M_ALIGN,
73 },
74};
75
76static int msm_copper_paddr_to_memtype(unsigned int paddr)
77{
78 return MEMTYPE_EBI1;
79}
80
81#ifdef CONFIG_ION_MSM
82static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
83 .permission_type = IPT_TYPE_MM_CARVEOUT,
84 .align = PAGE_SIZE,
85};
86
87static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
88 .permission_type = IPT_TYPE_MFC_SHAREDMEM,
89 .align = PAGE_SIZE,
90};
91
92static struct ion_co_heap_pdata co_ion_pdata = {
93 .adjacent_mem_id = INVALID_HEAP_ID,
94 .align = PAGE_SIZE,
95};
96
97static struct ion_co_heap_pdata fw_co_ion_pdata = {
98 .adjacent_mem_id = ION_CP_MM_HEAP_ID,
99 .align = SZ_128K,
100};
101
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800102/**
103 * These heaps are listed in the order they will be allocated. Due to
104 * video hardware restrictions and content protection the FW heap has to
105 * be allocated adjacent (below) the MM heap and the MFC heap has to be
106 * allocated after the MM heap to ensure MFC heap is not more than 256MB
107 * away from the base address of the FW heap.
108 * However, the order of FW heap and MM heap doesn't matter since these
109 * two heaps are taken care of by separate code to ensure they are adjacent
110 * to each other.
111 * Don't swap the order unless you know what you are doing!
112 */
Olav Hauganb800c8c2012-01-30 08:50:45 -0800113static struct ion_platform_data ion_pdata = {
114 .nr = MSM_ION_HEAP_NUM,
115 .heaps = {
116 {
117 .id = ION_SYSTEM_HEAP_ID,
118 .type = ION_HEAP_TYPE_SYSTEM,
119 .name = ION_VMALLOC_HEAP_NAME,
120 },
121 {
Olav Hauganb800c8c2012-01-30 08:50:45 -0800122 .id = ION_CP_MM_HEAP_ID,
123 .type = ION_HEAP_TYPE_CP,
124 .name = ION_MM_HEAP_NAME,
125 .size = MSM_ION_MM_SIZE,
126 .memory_type = ION_EBI_TYPE,
127 .extra_data = (void *) &cp_mm_ion_pdata,
128 },
129 {
130 .id = ION_MM_FIRMWARE_HEAP_ID,
131 .type = ION_HEAP_TYPE_CARVEOUT,
132 .name = ION_MM_FIRMWARE_HEAP_NAME,
133 .size = MSM_ION_MM_FW_SIZE,
134 .memory_type = ION_EBI_TYPE,
135 .extra_data = (void *) &fw_co_ion_pdata,
136 },
137 {
138 .id = ION_CP_MFC_HEAP_ID,
139 .type = ION_HEAP_TYPE_CP,
140 .name = ION_MFC_HEAP_NAME,
141 .size = MSM_ION_MFC_SIZE,
142 .memory_type = ION_EBI_TYPE,
143 .extra_data = (void *) &cp_mfc_ion_pdata,
144 },
145 {
Olav Haugan9cdfc2f2012-02-15 09:52:57 -0800146 .id = ION_SF_HEAP_ID,
147 .type = ION_HEAP_TYPE_CARVEOUT,
148 .name = ION_SF_HEAP_NAME,
149 .size = MSM_ION_SF_SIZE,
150 .memory_type = ION_EBI_TYPE,
151 .extra_data = (void *) &co_ion_pdata,
152 },
153 {
Olav Hauganb800c8c2012-01-30 08:50:45 -0800154 .id = ION_IOMMU_HEAP_ID,
155 .type = ION_HEAP_TYPE_IOMMU,
156 .name = ION_IOMMU_HEAP_NAME,
157 },
158 {
159 .id = ION_QSECOM_HEAP_ID,
160 .type = ION_HEAP_TYPE_CARVEOUT,
161 .name = ION_QSECOM_HEAP_NAME,
162 .size = MSM_ION_QSECOM_SIZE,
163 .memory_type = ION_EBI_TYPE,
164 .extra_data = (void *) &co_ion_pdata,
165 },
166 {
167 .id = ION_AUDIO_HEAP_ID,
168 .type = ION_HEAP_TYPE_CARVEOUT,
169 .name = ION_AUDIO_HEAP_NAME,
170 .size = MSM_ION_AUDIO_SIZE,
171 .memory_type = ION_EBI_TYPE,
172 .extra_data = (void *) &co_ion_pdata,
173 },
174 }
175};
176
177static struct platform_device ion_dev = {
178 .name = "ion-msm",
179 .id = 1,
180 .dev = { .platform_data = &ion_pdata },
181};
182
183static void reserve_ion_memory(void)
184{
185 msm_copper_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MM_SIZE;
186 msm_copper_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MM_FW_SIZE;
187 msm_copper_reserve_table[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE;
188 msm_copper_reserve_table[MEMTYPE_EBI1].size += MSM_ION_MFC_SIZE;
189 msm_copper_reserve_table[MEMTYPE_EBI1].size += MSM_ION_QSECOM_SIZE;
190 msm_copper_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
191#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
192 msm_copper_reserve_table[MEMTYPE_EBI1].size += kernel_ebi1_mem_size;
193#endif
194}
195#endif
196
Jeff Hugo70946092012-02-10 11:30:43 -0700197static struct resource smd_resource[] = {
198 {
199 .name = "modem_smd_in",
200 .start = 32 + 17, /* mss_sw_to_kpss_ipc_irq0 */
201 .flags = IORESOURCE_IRQ,
202 },
203 {
204 .name = "modem_smsm_in",
205 .start = 32 + 18, /* mss_sw_to_kpss_ipc_irq1 */
206 .flags = IORESOURCE_IRQ,
207 },
208 {
209 .name = "adsp_smd_in",
210 .start = 32 + 156, /* lpass_to_kpss_ipc_irq0 */
211 .flags = IORESOURCE_IRQ,
212 },
213 {
214 .name = "adsp_smsm_in",
215 .start = 32 + 157, /* lpass_to_kpss_ipc_irq1 */
216 .flags = IORESOURCE_IRQ,
217 },
218 {
219 .name = "wcnss_smd_in",
220 .start = 32 + 142, /* WcnssAppsSmdMedIrq */
221 .flags = IORESOURCE_IRQ,
222 },
223 {
224 .name = "wcnss_smsm_in",
225 .start = 32 + 144, /* RicaAppsWlanSmsmIrq */
226 .flags = IORESOURCE_IRQ,
227 },
228};
229
230static struct smd_subsystem_config smd_config_list[] = {
231 {
232 .irq_config_id = SMD_MODEM,
233 .subsys_name = "modem",
234 .edge = SMD_APPS_MODEM,
235
236 .smd_int.irq_name = "modem_smd_in",
237 .smd_int.flags = IRQF_TRIGGER_RISING,
238 .smd_int.irq_id = -1,
239 .smd_int.device_name = "smd_dev",
240 .smd_int.dev_id = 0,
241 .smd_int.out_bit_pos = 1 << 12,
242 .smd_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
243 .smd_int.out_offset = 0x8,
244
245 .smsm_int.irq_name = "modem_smsm_in",
246 .smsm_int.flags = IRQF_TRIGGER_RISING,
247 .smsm_int.irq_id = -1,
248 .smsm_int.device_name = "smsm_dev",
249 .smsm_int.dev_id = 0,
250 .smsm_int.out_bit_pos = 1 << 13,
251 .smsm_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
252 .smsm_int.out_offset = 0x8,
253 },
254 {
255 .irq_config_id = SMD_Q6,
256 .subsys_name = "q6",
257 .edge = SMD_APPS_QDSP,
258
259 .smd_int.irq_name = "adsp_smd_in",
260 .smd_int.flags = IRQF_TRIGGER_RISING,
261 .smd_int.irq_id = -1,
262 .smd_int.device_name = "smd_dev",
263 .smd_int.dev_id = 0,
264 .smd_int.out_bit_pos = 1 << 8,
265 .smd_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
266 .smd_int.out_offset = 0x8,
267
268 .smsm_int.irq_name = "adsp_smsm_in",
269 .smsm_int.flags = IRQF_TRIGGER_RISING,
270 .smsm_int.irq_id = -1,
271 .smsm_int.device_name = "smsm_dev",
272 .smsm_int.dev_id = 0,
273 .smsm_int.out_bit_pos = 1 << 9,
274 .smsm_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
275 .smsm_int.out_offset = 0x8,
276 },
277 {
278 .irq_config_id = SMD_WCNSS,
279 .subsys_name = "wcnss",
280 .edge = SMD_APPS_WCNSS,
281
282 .smd_int.irq_name = "wcnss_smd_in",
283 .smd_int.flags = IRQF_TRIGGER_RISING,
284 .smd_int.irq_id = -1,
285 .smd_int.device_name = "smd_dev",
286 .smd_int.dev_id = 0,
287 .smd_int.out_bit_pos = 1 << 17,
288 .smd_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
289 .smd_int.out_offset = 0x8,
290
291 .smsm_int.irq_name = "wcnss_smsm_in",
292 .smsm_int.flags = IRQF_TRIGGER_RISING,
293 .smsm_int.irq_id = -1,
294 .smsm_int.device_name = "smsm_dev",
295 .smsm_int.dev_id = 0,
296 .smsm_int.out_bit_pos = 1 << 19,
297 .smsm_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
298 .smsm_int.out_offset = 0x8,
299 },
300};
301
302static struct smd_platform smd_platform_data = {
303 .num_ss_configs = ARRAY_SIZE(smd_config_list),
304 .smd_ss_configs = smd_config_list,
305};
306
307struct platform_device msm_device_smd_copper = {
308 .name = "msm_smd",
309 .id = -1,
310 .resource = smd_resource,
311 .num_resources = ARRAY_SIZE(smd_resource),
312 .dev = {
313 .platform_data = &smd_platform_data,
314 }
315};
316
Olav Hauganb800c8c2012-01-30 08:50:45 -0800317static void __init msm_copper_calculate_reserve_sizes(void)
318{
319#ifdef CONFIG_ION_MSM
320 reserve_ion_memory();
321#endif
322}
323
324static struct reserve_info msm_copper_reserve_info __initdata = {
325 .memtype_reserve_table = msm_copper_reserve_table,
326 .calculate_reserve_sizes = msm_copper_calculate_reserve_sizes,
327 .paddr_to_memtype = msm_copper_paddr_to_memtype,
328};
329
330static void __init msm_copper_early_memory(void)
331{
332 reserve_info = &msm_copper_reserve_info;
333}
334
335void __init msm_copper_reserve(void)
336{
337 msm_reserve();
338}
339
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700340static int __init gpiomux_init(void)
341{
342 int rc;
343
344 rc = msm_gpiomux_init(NR_GPIO_IRQS);
345 if (rc) {
346 pr_err("%s: msm_gpiomux_init failed %d\n", __func__, rc);
347 return rc;
348 }
349
350 return 0;
351}
352
353void __init msm_copper_add_devices(void)
354{
Olav Hauganb800c8c2012-01-30 08:50:45 -0800355#ifdef CONFIG_ION_MSM
356 platform_device_register(&ion_dev);
357#endif
Jeff Hugo70946092012-02-10 11:30:43 -0700358 platform_device_register(&msm_device_smd_copper);
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700359}
360
Michael Bohanc7224532012-01-06 16:02:52 -0800361static struct of_device_id irq_match[] __initdata = {
362 { .compatible = "qcom,msm-qgic2", .data = gic_of_init, },
Michael Bohan0425f6f2012-01-17 14:36:39 -0800363 { .compatible = "qcom,msm-gpio", .data = msm_gpio_of_init, },
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700364 {}
365};
366
367void __init msm_copper_init_irq(void)
368{
Michael Bohanc7224532012-01-06 16:02:52 -0800369 of_irq_init(irq_match);
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700370}
371
372static struct clk_lookup msm_clocks_dummy[] = {
Sathish Ambley3d50c762011-10-25 15:26:00 -0700373 CLK_DUMMY("core_clk", BLSP2_UART_CLK, "msm_serial_hsl.0", OFF),
374 CLK_DUMMY("iface_clk", BLSP2_UART_CLK, "msm_serial_hsl.0", OFF),
Sujit Reddy Thumma1a4a79e2011-11-04 09:44:32 +0530375 CLK_DUMMY("core_clk", SDC1_CLK, NULL, OFF),
376 CLK_DUMMY("iface_clk", SDC1_P_CLK, NULL, OFF),
377 CLK_DUMMY("core_clk", SDC3_CLK, NULL, OFF),
378 CLK_DUMMY("iface_clk", SDC3_P_CLK, NULL, OFF),
Pavankumar Kondeti0063b842012-01-16 12:19:58 +0530379 CLK_DUMMY("phy_clk", NULL, "msm_otg", OFF),
380 CLK_DUMMY("core_clk", NULL, "msm_otg", OFF),
381 CLK_DUMMY("alt_core_clk", NULL, "msm_otg", OFF),
382 CLK_DUMMY("iface_clk", NULL, "msm_otg", OFF),
Pavankumar Kondeti066bfbf2012-02-20 14:10:20 +0530383 CLK_DUMMY("xo", NULL, "msm_otg", OFF),
Yan He1466daa2011-11-30 17:25:38 -0800384 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
385 CLK_DUMMY("dma_bam_pclk", DMA_BAM_P_CLK, NULL, 0),
386 CLK_DUMMY("mem_clk", NULL, NULL, 0),
Harini Jayaraman5f98dbb2011-12-20 13:38:19 -0700387 CLK_DUMMY("core_clk", SPI_CLK, "spi_qsd.1", OFF),
388 CLK_DUMMY("iface_clk", SPI_P_CLK, "spi_qsd.1", OFF),
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700389};
390
391struct clock_init_data msm_dummy_clock_init_data __initdata = {
392 .table = msm_clocks_dummy,
393 .size = ARRAY_SIZE(msm_clocks_dummy),
394};
395
396static struct of_dev_auxdata msm_copper_auxdata_lookup[] __initdata = {
Sathish Ambleyab783ab2011-11-27 22:21:48 -0800397 OF_DEV_AUXDATA("qcom,msm-lsuart-v14", 0xF991F000, \
Sathish Ambley3d50c762011-10-25 15:26:00 -0700398 "msm_serial_hsl.0", NULL),
Pavankumar Kondeti0063b842012-01-16 12:19:58 +0530399 OF_DEV_AUXDATA("qcom,hsusb-otg", 0xF9A55000, \
400 "msm_otg", NULL),
Harini Jayaraman5f98dbb2011-12-20 13:38:19 -0700401 OF_DEV_AUXDATA("qcom,spi-qup-v2", 0xF9924000, \
402 "spi_qsd.1", NULL),
Kenneth Heitkef3c829c2012-01-13 17:02:43 -0700403 OF_DEV_AUXDATA("qcom,spmi-pmic-arb", 0xFC4C0000, \
404 "spmi-pmic-arb.0", NULL),
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700405 {}
406};
407
408void __init msm_copper_init(struct of_dev_auxdata **adata)
409{
410 if (gpiomux_init())
411 pr_err("%s: gpiomux_init() failed\n", __func__);
412 msm_clock_init(&msm_dummy_clock_init_data);
413
414 *adata = msm_copper_auxdata_lookup;
415}
Olav Hauganb800c8c2012-01-30 08:50:45 -0800416
417void __init msm_copper_very_early(void)
418{
419 msm_copper_early_memory();
420}