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