blob: b074809dd33f98ffbf0761cc0a0a8d5cff1cebdb [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 },
231};
232
233static struct smd_subsystem_config smd_config_list[] = {
234 {
235 .irq_config_id = SMD_MODEM,
236 .subsys_name = "modem",
237 .edge = SMD_APPS_MODEM,
238
239 .smd_int.irq_name = "modem_smd_in",
240 .smd_int.flags = IRQF_TRIGGER_RISING,
241 .smd_int.irq_id = -1,
242 .smd_int.device_name = "smd_dev",
243 .smd_int.dev_id = 0,
244 .smd_int.out_bit_pos = 1 << 12,
245 .smd_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
246 .smd_int.out_offset = 0x8,
247
248 .smsm_int.irq_name = "modem_smsm_in",
249 .smsm_int.flags = IRQF_TRIGGER_RISING,
250 .smsm_int.irq_id = -1,
251 .smsm_int.device_name = "smsm_dev",
252 .smsm_int.dev_id = 0,
253 .smsm_int.out_bit_pos = 1 << 13,
254 .smsm_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
255 .smsm_int.out_offset = 0x8,
256 },
257 {
258 .irq_config_id = SMD_Q6,
259 .subsys_name = "q6",
260 .edge = SMD_APPS_QDSP,
261
262 .smd_int.irq_name = "adsp_smd_in",
263 .smd_int.flags = IRQF_TRIGGER_RISING,
264 .smd_int.irq_id = -1,
265 .smd_int.device_name = "smd_dev",
266 .smd_int.dev_id = 0,
267 .smd_int.out_bit_pos = 1 << 8,
268 .smd_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
269 .smd_int.out_offset = 0x8,
270
271 .smsm_int.irq_name = "adsp_smsm_in",
272 .smsm_int.flags = IRQF_TRIGGER_RISING,
273 .smsm_int.irq_id = -1,
274 .smsm_int.device_name = "smsm_dev",
275 .smsm_int.dev_id = 0,
276 .smsm_int.out_bit_pos = 1 << 9,
277 .smsm_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
278 .smsm_int.out_offset = 0x8,
279 },
280 {
281 .irq_config_id = SMD_WCNSS,
282 .subsys_name = "wcnss",
283 .edge = SMD_APPS_WCNSS,
284
285 .smd_int.irq_name = "wcnss_smd_in",
286 .smd_int.flags = IRQF_TRIGGER_RISING,
287 .smd_int.irq_id = -1,
288 .smd_int.device_name = "smd_dev",
289 .smd_int.dev_id = 0,
290 .smd_int.out_bit_pos = 1 << 17,
291 .smd_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
292 .smd_int.out_offset = 0x8,
293
294 .smsm_int.irq_name = "wcnss_smsm_in",
295 .smsm_int.flags = IRQF_TRIGGER_RISING,
296 .smsm_int.irq_id = -1,
297 .smsm_int.device_name = "smsm_dev",
298 .smsm_int.dev_id = 0,
299 .smsm_int.out_bit_pos = 1 << 19,
300 .smsm_int.out_base = (void __iomem *)MSM_APCS_GCC_BASE,
301 .smsm_int.out_offset = 0x8,
302 },
303};
304
305static struct smd_platform smd_platform_data = {
306 .num_ss_configs = ARRAY_SIZE(smd_config_list),
307 .smd_ss_configs = smd_config_list,
308};
309
310struct platform_device msm_device_smd_copper = {
311 .name = "msm_smd",
312 .id = -1,
313 .resource = smd_resource,
314 .num_resources = ARRAY_SIZE(smd_resource),
315 .dev = {
316 .platform_data = &smd_platform_data,
317 }
318};
319
Olav Hauganb800c8c2012-01-30 08:50:45 -0800320static void __init msm_copper_calculate_reserve_sizes(void)
321{
322#ifdef CONFIG_ION_MSM
323 reserve_ion_memory();
324#endif
325}
326
327static struct reserve_info msm_copper_reserve_info __initdata = {
328 .memtype_reserve_table = msm_copper_reserve_table,
329 .calculate_reserve_sizes = msm_copper_calculate_reserve_sizes,
330 .paddr_to_memtype = msm_copper_paddr_to_memtype,
331};
332
333static void __init msm_copper_early_memory(void)
334{
335 reserve_info = &msm_copper_reserve_info;
336}
337
338void __init msm_copper_reserve(void)
339{
340 msm_reserve();
341}
342
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700343static int __init gpiomux_init(void)
344{
345 int rc;
346
347 rc = msm_gpiomux_init(NR_GPIO_IRQS);
348 if (rc) {
349 pr_err("%s: msm_gpiomux_init failed %d\n", __func__, rc);
350 return rc;
351 }
352
353 return 0;
354}
355
Pavankumar Kondeti8c447382012-03-29 09:02:09 +0530356static struct platform_device android_usb_device = {
357 .name = "android_usb",
358 .id = -1,
359};
360
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700361void __init msm_copper_add_devices(void)
362{
Olav Hauganb800c8c2012-01-30 08:50:45 -0800363#ifdef CONFIG_ION_MSM
364 platform_device_register(&ion_dev);
365#endif
Jeff Hugo70946092012-02-10 11:30:43 -0700366 platform_device_register(&msm_device_smd_copper);
Pavankumar Kondeti8c447382012-03-29 09:02:09 +0530367 platform_device_register(&android_usb_device);
Michael Bohan037a0f52012-02-29 19:13:09 -0800368 platform_add_devices(msm_copper_stub_regulator_devices,
369 msm_copper_stub_regulator_devices_len);
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700370}
371
Michael Bohane7c2b472012-03-30 14:27:18 -0700372/*
373 * Used to satisfy dependencies for devices that need to be
374 * run early or in a particular order. Most likely your device doesn't fall
375 * into this category, and thus the driver should not be added here. The
376 * EPROBE_DEFER can satisfy most dependency problems.
377 */
378void __init msm_copper_add_drivers(void)
379{
380 regulator_stub_init();
381}
382
Michael Bohanc7224532012-01-06 16:02:52 -0800383static struct of_device_id irq_match[] __initdata = {
384 { .compatible = "qcom,msm-qgic2", .data = gic_of_init, },
Michael Bohan0425f6f2012-01-17 14:36:39 -0800385 { .compatible = "qcom,msm-gpio", .data = msm_gpio_of_init, },
Michael Bohan115cf652012-01-05 14:32:59 -0800386 { .compatible = "qcom,spmi-pmic-arb", .data = qpnpint_of_init, },
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700387 {}
388};
389
390void __init msm_copper_init_irq(void)
391{
Michael Bohanc7224532012-01-06 16:02:52 -0800392 of_irq_init(irq_match);
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700393}
394
395static struct clk_lookup msm_clocks_dummy[] = {
Sathish Ambley3d50c762011-10-25 15:26:00 -0700396 CLK_DUMMY("core_clk", BLSP2_UART_CLK, "msm_serial_hsl.0", OFF),
397 CLK_DUMMY("iface_clk", BLSP2_UART_CLK, "msm_serial_hsl.0", OFF),
Sujit Reddy Thumma1a4a79e2011-11-04 09:44:32 +0530398 CLK_DUMMY("core_clk", SDC1_CLK, NULL, OFF),
399 CLK_DUMMY("iface_clk", SDC1_P_CLK, NULL, OFF),
400 CLK_DUMMY("core_clk", SDC3_CLK, NULL, OFF),
401 CLK_DUMMY("iface_clk", SDC3_P_CLK, NULL, OFF),
Pavankumar Kondeti0063b842012-01-16 12:19:58 +0530402 CLK_DUMMY("phy_clk", NULL, "msm_otg", OFF),
403 CLK_DUMMY("core_clk", NULL, "msm_otg", OFF),
404 CLK_DUMMY("alt_core_clk", NULL, "msm_otg", OFF),
405 CLK_DUMMY("iface_clk", NULL, "msm_otg", OFF),
Pavankumar Kondeti066bfbf2012-02-20 14:10:20 +0530406 CLK_DUMMY("xo", NULL, "msm_otg", OFF),
Yan He1466daa2011-11-30 17:25:38 -0800407 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
408 CLK_DUMMY("dma_bam_pclk", DMA_BAM_P_CLK, NULL, 0),
409 CLK_DUMMY("mem_clk", NULL, NULL, 0),
Harini Jayaraman5f98dbb2011-12-20 13:38:19 -0700410 CLK_DUMMY("core_clk", SPI_CLK, "spi_qsd.1", OFF),
411 CLK_DUMMY("iface_clk", SPI_P_CLK, "spi_qsd.1", OFF),
Sagar Dharia218edb92012-01-15 18:03:01 -0700412 CLK_DUMMY("core_clk", NULL, "f9966000.i2c", 0),
413 CLK_DUMMY("iface_clk", NULL, "f9966000.i2c", 0),
Sagar Dhariaa316a962012-03-21 16:13:22 -0600414 CLK_DUMMY("core_clk", NULL, "fe12f000.slim", OFF),
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700415};
416
417struct clock_init_data msm_dummy_clock_init_data __initdata = {
418 .table = msm_clocks_dummy,
419 .size = ARRAY_SIZE(msm_clocks_dummy),
420};
421
422static struct of_dev_auxdata msm_copper_auxdata_lookup[] __initdata = {
Sathish Ambleyab783ab2011-11-27 22:21:48 -0800423 OF_DEV_AUXDATA("qcom,msm-lsuart-v14", 0xF991F000, \
Sathish Ambley3d50c762011-10-25 15:26:00 -0700424 "msm_serial_hsl.0", NULL),
Pavankumar Kondeti0063b842012-01-16 12:19:58 +0530425 OF_DEV_AUXDATA("qcom,hsusb-otg", 0xF9A55000, \
426 "msm_otg", NULL),
Harini Jayaraman5f98dbb2011-12-20 13:38:19 -0700427 OF_DEV_AUXDATA("qcom,spi-qup-v2", 0xF9924000, \
428 "spi_qsd.1", NULL),
Kenneth Heitkef3c829c2012-01-13 17:02:43 -0700429 OF_DEV_AUXDATA("qcom,spmi-pmic-arb", 0xFC4C0000, \
430 "spmi-pmic-arb.0", NULL),
Sathish Ambleyc58afc22011-10-09 21:55:39 -0700431 {}
432};
433
434void __init msm_copper_init(struct of_dev_auxdata **adata)
435{
436 if (gpiomux_init())
437 pr_err("%s: gpiomux_init() failed\n", __func__);
438 msm_clock_init(&msm_dummy_clock_init_data);
439
440 *adata = msm_copper_auxdata_lookup;
441}
Olav Hauganb800c8c2012-01-30 08:50:45 -0800442
443void __init msm_copper_very_early(void)
444{
445 msm_copper_early_memory();
446}