blob: 00886c61554b608390da7325934c65b54d81c997 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
2 *
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>
Kenneth Heitke748593a2011-07-15 15:45:11 -060017#include <linux/i2c.h>
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -060018#include <linux/slimbus/slimbus.h>
Kenneth Heitke36920d32011-07-20 16:44:30 -060019#include <linux/msm_ssbi.h>
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -070020#include <linux/spi/spi.h>
Ramesh Masavarapu28311912011-10-27 11:04:12 -070021#include <linux/dma-mapping.h>
22#include <linux/platform_data/qcom_crypto_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070023#include <asm/mach-types.h>
24#include <asm/mach/arch.h>
25#include <asm/hardware/gic.h>
Sahitya Tummala3586ed92011-08-03 09:13:23 +053026#include <asm/mach/mmc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070027
28#include <mach/board.h>
29#include <mach/msm_iomap.h>
30#include <linux/usb/msm_hsusb.h>
31#include <linux/usb/android.h>
32#include <mach/socinfo.h>
Harini Jayaramanc4c58692011-07-19 14:50:10 -060033#include <mach/msm_spi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070034#include "timer.h"
35#include "devices.h"
Joel King4ebccc62011-07-22 09:43:22 -070036#include <mach/gpio.h>
37#include <mach/gpiomux.h>
Kevin Chan13be4e22011-10-20 11:30:32 -070038#include <linux/android_pmem.h>
39#include <mach/msm_memtypes.h>
40#include <linux/bootmem.h>
41#include <asm/setup.h>
Ramesh Masavarapu28311912011-10-27 11:04:12 -070042#include <mach/dma.h>
Joel King4ebccc62011-07-22 09:43:22 -070043
Jeff Ohlstein7e668552011-10-06 16:17:25 -070044#include "msm_watchdog.h"
Jay Chokshiea67c622011-07-29 17:12:26 -070045#include "board-apq8064.h"
46
Kevin Chan13be4e22011-10-20 11:30:32 -070047#define MSM_PMEM_KERNEL_EBI1_SIZE 0x600000
48#define MSM_PMEM_ADSP_SIZE 0x3800000
49#define MSM_PMEM_AUDIO_SIZE 0x28B000
50#define MSM_PMEM_SIZE 0x1800000 /* 24 Mbytes */
51
52static struct memtype_reserve apq8064_reserve_table[] __initdata = {
53 [MEMTYPE_SMI] = {
54 },
55 [MEMTYPE_EBI0] = {
56 .flags = MEMTYPE_FLAGS_1M_ALIGN,
57 },
58 [MEMTYPE_EBI1] = {
59 .flags = MEMTYPE_FLAGS_1M_ALIGN,
60 },
61};
62
63static int apq8064_paddr_to_memtype(unsigned int paddr)
64{
65 return MEMTYPE_EBI1;
66}
67
68static unsigned pmem_size = MSM_PMEM_SIZE;
69static int __init pmem_size_setup(char *p)
70{
71 pmem_size = memparse(p, NULL);
72 return 0;
73}
74early_param("pmem_size", pmem_size_setup);
75
76static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
77
78static int __init pmem_adsp_size_setup(char *p)
79{
80 pmem_adsp_size = memparse(p, NULL);
81 return 0;
82}
83early_param("pmem_adsp_size", pmem_adsp_size_setup);
84
85static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
86
87static int __init pmem_audio_size_setup(char *p)
88{
89 pmem_audio_size = memparse(p, NULL);
90 return 0;
91}
92early_param("pmem_audio_size", pmem_audio_size_setup);
93
94static struct android_pmem_platform_data android_pmem_pdata = {
95 .name = "pmem",
96 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
97 .cached = 1,
98 .memory_type = MEMTYPE_EBI1,
99};
100
101static struct platform_device android_pmem_device = {
102 .name = "android_pmem",
103 .id = 0,
104 .dev = {.platform_data = &android_pmem_pdata},
105};
106
107static struct android_pmem_platform_data android_pmem_adsp_pdata = {
108 .name = "pmem_adsp",
109 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
110 .cached = 0,
111 .memory_type = MEMTYPE_EBI1,
112};
113
114static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
115static int __init pmem_kernel_ebi1_size_setup(char *p)
116{
117 pmem_kernel_ebi1_size = memparse(p, NULL);
118 return 0;
119}
120early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
121
122static struct platform_device android_pmem_adsp_device = {
123 .name = "android_pmem",
124 .id = 2,
125 .dev = { .platform_data = &android_pmem_adsp_pdata },
126};
127
128static struct android_pmem_platform_data android_pmem_audio_pdata = {
129 .name = "pmem_audio",
130 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
131 .cached = 0,
132 .memory_type = MEMTYPE_EBI1,
133};
134
135static struct platform_device android_pmem_audio_device = {
136 .name = "android_pmem",
137 .id = 4,
138 .dev = { .platform_data = &android_pmem_audio_pdata },
139};
140
141static void __init size_pmem_devices(void)
142{
143 android_pmem_adsp_pdata.size = pmem_adsp_size;
144 android_pmem_pdata.size = pmem_size;
145 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
146}
147
148static void __init reserve_memory_for(struct android_pmem_platform_data *p)
149{
150 apq8064_reserve_table[p->memory_type].size += p->size;
151}
152
153
154static void __init reserve_pmem_memory(void)
155{
156 reserve_memory_for(&android_pmem_adsp_pdata);
157 reserve_memory_for(&android_pmem_pdata);
158 reserve_memory_for(&android_pmem_audio_pdata);
159 apq8064_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
160}
161
162static void __init apq8064_calculate_reserve_sizes(void)
163{
164 size_pmem_devices();
165 reserve_pmem_memory();
166}
167
168static struct reserve_info apq8064_reserve_info __initdata = {
169 .memtype_reserve_table = apq8064_reserve_table,
170 .calculate_reserve_sizes = apq8064_calculate_reserve_sizes,
171 .paddr_to_memtype = apq8064_paddr_to_memtype,
172};
173
174static int apq8064_memory_bank_size(void)
175{
176 return 1<<29;
177}
178
179static void __init locate_unstable_memory(void)
180{
181 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
182 unsigned long bank_size;
183 unsigned long low, high;
184
185 bank_size = apq8064_memory_bank_size();
186 low = meminfo.bank[0].start;
187 high = mb->start + mb->size;
188 low &= ~(bank_size - 1);
189
190 if (high - low <= bank_size)
191 return;
192 apq8064_reserve_info.low_unstable_address = low + bank_size;
193 apq8064_reserve_info.max_unstable_size = high - low - bank_size;
194 apq8064_reserve_info.bank_size = bank_size;
195 pr_info("low unstable address %lx max size %lx bank size %lx\n",
196 apq8064_reserve_info.low_unstable_address,
197 apq8064_reserve_info.max_unstable_size,
198 apq8064_reserve_info.bank_size);
199}
200
201static void __init apq8064_reserve(void)
202{
203 reserve_info = &apq8064_reserve_info;
204 locate_unstable_memory();
205 msm_reserve();
206}
207
Hemant Kumar4933b072011-10-17 23:43:11 -0700208static struct platform_device android_usb_device = {
209 .name = "android_usb",
210 .id = -1,
211};
212
213static struct msm_otg_platform_data msm_otg_pdata = {
214 .mode = USB_PERIPHERAL,
215 .otg_control = OTG_PHY_CONTROL,
216 .phy_type = SNPS_28NM_INTEGRATED_PHY,
217 .pclk_src_name = "dfab_usb_hs_clk",
218};
219
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -0700220/* APQ8064 has 4 SDCC controllers */
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530221enum sdcc_controllers {
222 SDCC1,
223 SDCC2,
224 SDCC3,
225 SDCC4,
226 MAX_SDCC_CONTROLLER
227};
228
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -0700229/* All SDCC controllers require VDD/VCC voltage */
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530230static struct msm_mmc_reg_data mmc_vdd_reg_data[MAX_SDCC_CONTROLLER] = {
231 /* SDCC1 : eMMC card connected */
232 [SDCC1] = {
233 .name = "sdc_vdd",
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530234 .high_vol_level = 2950000,
235 .low_vol_level = 2950000,
236 .always_on = 1,
237 .lpm_sup = 1,
238 .lpm_uA = 9000,
239 .hpm_uA = 200000, /* 200mA */
240 },
241 /* SDCC3 : External card slot connected */
242 [SDCC3] = {
243 .name = "sdc_vdd",
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530244 .high_vol_level = 2950000,
245 .low_vol_level = 2950000,
246 .hpm_uA = 600000, /* 600mA */
247 }
248};
249
250/* Only slots having eMMC card will require VCCQ voltage */
251static struct msm_mmc_reg_data mmc_vccq_reg_data[1] = {
252 /* SDCC1 : eMMC card connected */
253 [SDCC1] = {
254 .name = "sdc_vccq",
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530255 .always_on = 1,
256 .high_vol_level = 1800000,
257 .low_vol_level = 1800000,
258 .hpm_uA = 200000, /* 200mA */
259 }
260};
261
262/* All SDCC controllers may require voting for VDD PAD voltage */
263static struct msm_mmc_reg_data mmc_vddp_reg_data[MAX_SDCC_CONTROLLER] = {
264 /* SDCC3 : External card slot connected */
265 [SDCC3] = {
266 .name = "sdc_vddp",
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530267 .high_vol_level = 2950000,
268 .low_vol_level = 1850000,
269 .always_on = 1,
270 .lpm_sup = 1,
271 /* Max. Active current required is 16 mA */
272 .hpm_uA = 16000,
273 /*
274 * Sleep current required is ~300 uA. But min. vote can be
275 * in terms of mA (min. 1 mA). So let's vote for 2 mA
276 * during sleep.
277 */
278 .lpm_uA = 2000,
279 }
280};
281
282static struct msm_mmc_slot_reg_data mmc_slot_vreg_data[MAX_SDCC_CONTROLLER] = {
283 /* SDCC1 : eMMC card connected */
284 [SDCC1] = {
285 .vdd_data = &mmc_vdd_reg_data[SDCC1],
286 .vccq_data = &mmc_vccq_reg_data[SDCC1],
287 },
288 /* SDCC3 : External card slot connected */
289 [SDCC3] = {
290 .vdd_data = &mmc_vdd_reg_data[SDCC3],
291 .vddp_data = &mmc_vddp_reg_data[SDCC3],
292 }
293};
294
295/* SDC1 pad data */
296static struct msm_mmc_pad_drv sdc1_pad_drv_on_cfg[] = {
297 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_16MA},
298 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_10MA},
299 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_10MA}
300};
301
302static struct msm_mmc_pad_drv sdc1_pad_drv_off_cfg[] = {
303 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_2MA},
304 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_2MA},
305 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_2MA}
306};
307
308static struct msm_mmc_pad_pull sdc1_pad_pull_on_cfg[] = {
Sahitya Tummalaf5764e82011-10-03 13:46:00 +0530309 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530310 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_UP},
311 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_UP}
312};
313
314static struct msm_mmc_pad_pull sdc1_pad_pull_off_cfg[] = {
Sahitya Tummalaf5764e82011-10-03 13:46:00 +0530315 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530316 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_DOWN},
317 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_DOWN}
318};
319
320/* SDC3 pad data */
321static struct msm_mmc_pad_drv sdc3_pad_drv_on_cfg[] = {
322 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
323 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
324 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
325};
326
327static struct msm_mmc_pad_drv sdc3_pad_drv_off_cfg[] = {
328 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
329 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
330 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
331};
332
333static struct msm_mmc_pad_pull sdc3_pad_pull_on_cfg[] = {
Sahitya Tummalaf5764e82011-10-03 13:46:00 +0530334 {TLMM_PULL_SDC3_CLK, GPIO_CFG_NO_PULL},
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530335 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
336 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
337};
338
339static struct msm_mmc_pad_pull sdc3_pad_pull_off_cfg[] = {
Sahitya Tummalaf5764e82011-10-03 13:46:00 +0530340 {TLMM_PULL_SDC3_CLK, GPIO_CFG_NO_PULL},
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530341 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
342 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
343};
344
345static struct msm_mmc_pad_pull_data mmc_pad_pull_data[MAX_SDCC_CONTROLLER] = {
346 [SDCC1] = {
347 .on = sdc1_pad_pull_on_cfg,
348 .off = sdc1_pad_pull_off_cfg,
349 .size = ARRAY_SIZE(sdc1_pad_pull_on_cfg)
350 },
351 [SDCC3] = {
352 .on = sdc3_pad_pull_on_cfg,
353 .off = sdc3_pad_pull_off_cfg,
354 .size = ARRAY_SIZE(sdc3_pad_pull_on_cfg)
355 },
356};
357
358static struct msm_mmc_pad_drv_data mmc_pad_drv_data[MAX_SDCC_CONTROLLER] = {
359 [SDCC1] = {
360 .on = sdc1_pad_drv_on_cfg,
361 .off = sdc1_pad_drv_off_cfg,
362 .size = ARRAY_SIZE(sdc1_pad_drv_on_cfg)
363 },
364 [SDCC3] = {
365 .on = sdc3_pad_drv_on_cfg,
366 .off = sdc3_pad_drv_off_cfg,
367 .size = ARRAY_SIZE(sdc3_pad_drv_on_cfg)
368 },
369};
370
371static struct msm_mmc_pad_data mmc_pad_data[MAX_SDCC_CONTROLLER] = {
372 [SDCC1] = {
373 .pull = &mmc_pad_pull_data[SDCC1],
374 .drv = &mmc_pad_drv_data[SDCC1]
375 },
376 [SDCC3] = {
377 .pull = &mmc_pad_pull_data[SDCC3],
378 .drv = &mmc_pad_drv_data[SDCC3]
379 },
380};
381
382static struct msm_mmc_pin_data mmc_slot_pin_data[MAX_SDCC_CONTROLLER] = {
383 [SDCC1] = {
384 .pad_data = &mmc_pad_data[SDCC1],
385 },
386 [SDCC3] = {
387 .pad_data = &mmc_pad_data[SDCC3],
388 },
389};
390
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530391#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
392static unsigned int sdc1_sup_clk_rates[] = {
393 400000, 24000000, 48000000, 96000000
394};
395
396static struct mmc_platform_data sdc1_data = {
397 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
Sahitya Tummala01431972011-10-03 13:52:26 +0530398#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
399 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
400#else
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530401 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Sahitya Tummala01431972011-10-03 13:52:26 +0530402#endif
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530403 .sup_clk_table = sdc1_sup_clk_rates,
404 .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates),
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530405 .pin_data = &mmc_slot_pin_data[SDCC1],
406 .vreg_data = &mmc_slot_vreg_data[SDCC1],
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530407};
408static struct mmc_platform_data *apq8064_sdc1_pdata = &sdc1_data;
409#else
410static struct mmc_platform_data *apq8064_sdc1_pdata;
411#endif
412
413#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
414static unsigned int sdc3_sup_clk_rates[] = {
415 400000, 24000000, 48000000, 96000000
416};
417
418static struct mmc_platform_data sdc3_data = {
419 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
420 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
421 .sup_clk_table = sdc3_sup_clk_rates,
422 .sup_clk_cnt = ARRAY_SIZE(sdc3_sup_clk_rates),
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530423 .pin_data = &mmc_slot_pin_data[SDCC3],
424 .vreg_data = &mmc_slot_vreg_data[SDCC3],
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530425};
426static struct mmc_platform_data *apq8064_sdc3_pdata = &sdc3_data;
427#else
428static struct mmc_platform_data *apq8064_sdc3_pdata;
429#endif
430
431static void __init apq8064_init_mmc(void)
432{
Amol Jadi7d4ce032011-09-09 17:07:18 -0700433 if ((machine_is_apq8064_rumi3()) || machine_is_apq8064_sim()) {
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530434 if (apq8064_sdc1_pdata) {
Sahitya Tummaladc7c0a22011-11-17 11:36:16 +0530435 if (machine_is_apq8064_sim())
436 apq8064_sdc1_pdata->disable_bam = true;
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530437 apq8064_sdc1_pdata->disable_runtime_pm = true;
Sahitya Tummala85fa0702011-09-15 09:39:37 +0530438 apq8064_sdc1_pdata->disable_cmd23 = true;
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530439 }
440 if (apq8064_sdc3_pdata) {
Sahitya Tummaladc7c0a22011-11-17 11:36:16 +0530441 if (machine_is_apq8064_sim())
442 apq8064_sdc3_pdata->disable_bam = true;
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530443 apq8064_sdc3_pdata->disable_runtime_pm = true;
Sahitya Tummala85fa0702011-09-15 09:39:37 +0530444 apq8064_sdc3_pdata->disable_cmd23 = true;
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530445 }
Sahitya Tummalad9df3272011-08-19 16:50:46 +0530446 }
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530447 apq8064_add_sdcc(1, apq8064_sdc1_pdata);
448 apq8064_add_sdcc(3, apq8064_sdc3_pdata);
449}
450
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700451#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
452 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
453 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
454 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
455
456#define QCE_SIZE 0x10000
457#define QCE_0_BASE 0x11000000
458
459#define QCE_HW_KEY_SUPPORT 0
460#define QCE_SHA_HMAC_SUPPORT 1
461#define QCE_SHARE_CE_RESOURCE 3
462#define QCE_CE_SHARED 0
463
464static struct resource qcrypto_resources[] = {
465 [0] = {
466 .start = QCE_0_BASE,
467 .end = QCE_0_BASE + QCE_SIZE - 1,
468 .flags = IORESOURCE_MEM,
469 },
470 [1] = {
471 .name = "crypto_channels",
472 .start = DMOV8064_CE_IN_CHAN,
473 .end = DMOV8064_CE_OUT_CHAN,
474 .flags = IORESOURCE_DMA,
475 },
476 [2] = {
477 .name = "crypto_crci_in",
478 .start = DMOV8064_CE_IN_CRCI,
479 .end = DMOV8064_CE_IN_CRCI,
480 .flags = IORESOURCE_DMA,
481 },
482 [3] = {
483 .name = "crypto_crci_out",
484 .start = DMOV8064_CE_OUT_CRCI,
485 .end = DMOV8064_CE_OUT_CRCI,
486 .flags = IORESOURCE_DMA,
487 },
488};
489
490static struct resource qcedev_resources[] = {
491 [0] = {
492 .start = QCE_0_BASE,
493 .end = QCE_0_BASE + QCE_SIZE - 1,
494 .flags = IORESOURCE_MEM,
495 },
496 [1] = {
497 .name = "crypto_channels",
498 .start = DMOV8064_CE_IN_CHAN,
499 .end = DMOV8064_CE_OUT_CHAN,
500 .flags = IORESOURCE_DMA,
501 },
502 [2] = {
503 .name = "crypto_crci_in",
504 .start = DMOV8064_CE_IN_CRCI,
505 .end = DMOV8064_CE_IN_CRCI,
506 .flags = IORESOURCE_DMA,
507 },
508 [3] = {
509 .name = "crypto_crci_out",
510 .start = DMOV8064_CE_OUT_CRCI,
511 .end = DMOV8064_CE_OUT_CRCI,
512 .flags = IORESOURCE_DMA,
513 },
514};
515
516#endif
517
518#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
519 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
520
521static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
522 .ce_shared = QCE_CE_SHARED,
523 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
524 .hw_key_support = QCE_HW_KEY_SUPPORT,
525 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
526};
527
528static struct platform_device qcrypto_device = {
529 .name = "qcrypto",
530 .id = 0,
531 .num_resources = ARRAY_SIZE(qcrypto_resources),
532 .resource = qcrypto_resources,
533 .dev = {
534 .coherent_dma_mask = DMA_BIT_MASK(32),
535 .platform_data = &qcrypto_ce_hw_suppport,
536 },
537};
538#endif
539
540#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
541 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
542
543static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
544 .ce_shared = QCE_CE_SHARED,
545 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
546 .hw_key_support = QCE_HW_KEY_SUPPORT,
547 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
548};
549
550static struct platform_device qcedev_device = {
551 .name = "qce",
552 .id = 0,
553 .num_resources = ARRAY_SIZE(qcedev_resources),
554 .resource = qcedev_resources,
555 .dev = {
556 .coherent_dma_mask = DMA_BIT_MASK(32),
557 .platform_data = &qcedev_ce_hw_suppport,
558 },
559};
560#endif
561
562
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600563#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700564static void __init apq8064_map_io(void)
565{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600566 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700567 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -0700568 if (socinfo_init() < 0)
569 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700570}
571
572static void __init apq8064_init_irq(void)
573{
574 unsigned int i;
575 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
576 (void *)MSM_QGIC_CPU_BASE);
577
578 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
579 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
580
581 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
582 mb();
583
584 /*
585 * FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
586 * as they are configured as level, which does not play nice with
587 * handle_percpu_irq.
588 */
589 for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
590 if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
591 irq_set_handler(i, handle_percpu_irq);
592 }
593}
594
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800595static struct platform_device msm8064_device_saw_regulator_core0 = {
596 .name = "saw-regulator",
597 .id = 0,
598 .dev = {
599 .platform_data = &msm8064_saw_regulator_pdata_8921_s5,
600 },
601};
602
603static struct platform_device msm8064_device_saw_regulator_core1 = {
604 .name = "saw-regulator",
605 .id = 1,
606 .dev = {
607 .platform_data = &msm8064_saw_regulator_pdata_8921_s6,
608 },
609};
610
611static struct platform_device msm8064_device_saw_regulator_core2 = {
612 .name = "saw-regulator",
613 .id = 2,
614 .dev = {
615 .platform_data = &msm8064_saw_regulator_pdata_8821_s0,
616 },
617};
618
619static struct platform_device msm8064_device_saw_regulator_core3 = {
620 .name = "saw-regulator",
621 .id = 3,
622 .dev = {
623 .platform_data = &msm8064_saw_regulator_pdata_8821_s1,
624 },
625};
626
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700627static struct platform_device *common_devices[] __initdata = {
Jin Hong01f2dbb2011-11-03 22:13:51 -0700628 &apq8064_device_dmov,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600629 &apq8064_device_qup_i2c_gsbi4,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600630 &apq8064_device_qup_spi_gsbi5,
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600631 &apq8064_slim_ctrl,
Jay Chokshi9c25f072011-09-23 18:19:15 -0700632 &apq8064_device_ssbi_pmic1,
633 &apq8064_device_ssbi_pmic2,
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600634 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -0700635 &apq8064_device_otg,
636 &apq8064_device_gadget_peripheral,
637 &android_usb_device,
Kevin Chan13be4e22011-10-20 11:30:32 -0700638 &android_pmem_device,
639 &android_pmem_adsp_device,
640 &android_pmem_audio_device,
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700641 &msm8064_device_watchdog,
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800642 &msm8064_device_saw_regulator_core0,
643 &msm8064_device_saw_regulator_core1,
644 &msm8064_device_saw_regulator_core2,
645 &msm8064_device_saw_regulator_core3,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700646#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
647 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
648 &qcrypto_device,
649#endif
650
651#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
652 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
653 &qcedev_device,
654#endif
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600655};
656
Joel King4e7ad222011-08-17 15:47:38 -0700657static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700658 &apq8064_device_uart_gsbi3,
Yan He06913ce2011-08-26 16:33:46 -0700659 &msm_device_sps_apq8064,
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700660};
661
662static struct platform_device *rumi3_devices[] __initdata = {
663 &apq8064_device_uart_gsbi1,
Joel King4e7ad222011-08-17 15:47:38 -0700664};
665
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600666static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
Harini Jayaraman60ee14c2011-11-09 18:53:27 -0700667 .max_clock_speed = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700668};
669
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700670#define KS8851_IRQ_GPIO 43
671
672static struct spi_board_info spi_board_info[] __initdata = {
673 {
674 .modalias = "ks8851",
675 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
676 .max_speed_hz = 19200000,
677 .bus_num = 0,
678 .chip_select = 2,
679 .mode = SPI_MODE_0,
680 },
681};
682
683#ifdef CONFIG_KS8851
684static struct gpiomux_setting gpio_eth_config = {
685 .pull = GPIOMUX_PULL_NONE,
686 .drv = GPIOMUX_DRV_8MA,
687 .func = GPIOMUX_FUNC_GPIO,
688};
689
690/* The SPI configurations apply to GSBI 5*/
691static struct gpiomux_setting gpio_spi_config = {
692 .func = GPIOMUX_FUNC_2,
693 .drv = GPIOMUX_DRV_8MA,
694 .pull = GPIOMUX_PULL_NONE,
695};
696
697/* The SPI configurations apply to GSBI 5 chip select 2*/
698static struct gpiomux_setting gpio_spi_cs2_config = {
699 .func = GPIOMUX_FUNC_3,
700 .drv = GPIOMUX_DRV_8MA,
701 .pull = GPIOMUX_PULL_NONE,
702};
703#endif
704
705struct msm_gpiomux_config apq8064_ethernet_configs[NR_GPIO_IRQS] = {
706#ifdef CONFIG_KS8851
707 {
708 .gpio = KS8851_IRQ_GPIO,
709 .settings = {
710 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
711 [GPIOMUX_ACTIVE] = &gpio_eth_config,
712 }
713 },
714#endif
715};
716
717static struct msm_gpiomux_config apq8064_gsbi_configs[] __initdata = {
718#ifdef CONFIG_KS8851
719 {
720 .gpio = 51, /* GSBI5 QUP SPI_DATA_MOSI */
721 .settings = {
722 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
723 },
724 },
725 {
726 .gpio = 52, /* GSBI5 QUP SPI_DATA_MISO */
727 .settings = {
728 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
729 },
730 },
731 {
732 .gpio = 31, /* GSBI5 QUP SPI_CS2_N */
733 .settings = {
734 [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config,
735 },
736 },
737 {
738 .gpio = 54, /* GSBI5 QUP SPI_CLK */
739 .settings = {
740 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
741 },
742 },
743#endif
744};
745
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700746static struct pm8xxx_mpp_platform_data
747apq8064_pm8921_mpp_pdata __devinitdata = {
748 .mpp_base = PM8921_MPP_PM_TO_SYS(1),
749};
750
751static struct pm8xxx_gpio_platform_data
752apq8064_pm8921_gpio_pdata __devinitdata = {
753 .gpio_base = PM8921_GPIO_PM_TO_SYS(1),
754};
755
756static struct pm8xxx_irq_platform_data
757apq8064_pm8921_irq_pdata __devinitdata = {
758 .irq_base = PM8921_IRQ_BASE,
Jay Chokshi44873f72011-08-30 17:24:26 -0700759 .devirq = PM8921_USR_IRQ_N,
760 .irq_trigger_flag = IRQF_TRIGGER_HIGH,
Jay Chokshi9e926e72011-09-23 19:19:58 -0700761 .dev_id = 0,
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700762};
763
764static struct pm8921_platform_data
765apq8064_pm8921_platform_data __devinitdata = {
Jay Chokshiea67c622011-07-29 17:12:26 -0700766 .regulator_pdatas = msm8064_pm8921_regulator_pdata,
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700767 .irq_pdata = &apq8064_pm8921_irq_pdata,
768 .gpio_pdata = &apq8064_pm8921_gpio_pdata,
769 .mpp_pdata = &apq8064_pm8921_mpp_pdata,
Jay Chokshiea67c622011-07-29 17:12:26 -0700770};
771
Jay Chokshi44873f72011-08-30 17:24:26 -0700772static struct pm8xxx_irq_platform_data
773apq8064_pm8821_irq_pdata __devinitdata = {
774 .irq_base = PM8821_IRQ_BASE,
775 .devirq = PM8821_USR_IRQ_N,
776 .irq_trigger_flag = IRQF_TRIGGER_HIGH,
Jay Chokshi9e926e72011-09-23 19:19:58 -0700777 .dev_id = 1,
Jay Chokshi44873f72011-08-30 17:24:26 -0700778};
779
780static struct pm8xxx_mpp_platform_data
781apq8064_pm8821_mpp_pdata __devinitdata = {
782 .mpp_base = PM8821_MPP_PM_TO_SYS(1),
783};
784
785static struct pm8821_platform_data
786apq8064_pm8821_platform_data __devinitdata = {
787 .irq_pdata = &apq8064_pm8821_irq_pdata,
788 .mpp_pdata = &apq8064_pm8821_mpp_pdata,
789};
790
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700791static struct msm_ssbi_platform_data apq8064_ssbi_pm8921_pdata __devinitdata = {
792 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
793 .slave = {
Jay Chokshiea67c622011-07-29 17:12:26 -0700794 .name = "pm8921-core",
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700795 .platform_data = &apq8064_pm8921_platform_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700796 },
797};
798
799static struct msm_ssbi_platform_data apq8064_ssbi_pm8821_pdata __devinitdata = {
800 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
801 .slave = {
Jay Chokshi44873f72011-08-30 17:24:26 -0700802 .name = "pm8821-core",
803 .platform_data = &apq8064_pm8821_platform_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700804 },
805};
806
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600807static struct slim_boardinfo apq8064_slim_devices[] = {
808 /* Add slimbus slaves as needed */
809};
810
Kenneth Heitke748593a2011-07-15 15:45:11 -0600811static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
812 .clk_freq = 100000,
813 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600814};
815
816static void __init apq8064_i2c_init(void)
817{
818 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
819 &apq8064_i2c_qup_gsbi4_pdata;
820}
821
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700822static int __init gpiomux_init(void)
823{
824 int rc;
825
826 rc = msm_gpiomux_init(NR_GPIO_IRQS);
827 if (rc) {
828 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
829 return rc;
830 }
831 msm_gpiomux_install(apq8064_ethernet_configs,
832 ARRAY_SIZE(apq8064_ethernet_configs));
833
834 msm_gpiomux_install(apq8064_gsbi_configs,
835 ARRAY_SIZE(apq8064_gsbi_configs));
836 return 0;
837}
838
839#ifdef CONFIG_KS8851
840static int ethernet_init(void)
841{
842 int ret;
843 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
844 if (ret) {
845 pr_err("ks8851 gpio_request failed: %d\n", ret);
846 goto fail;
847 }
848
849 return 0;
850fail:
851 return ret;
852}
853#else
854static int ethernet_init(void)
855{
856 return 0;
857}
858#endif
859
Tianyi Gou41515e22011-09-01 19:37:43 -0700860static void __init apq8064_clock_init(void)
861{
862 if (machine_is_apq8064_sim())
863 msm_clock_init(&apq8064_clock_init_data);
864 else
865 msm_clock_init(&apq8064_dummy_clock_init_data);
866}
867
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700868static void __init apq8064_common_init(void)
869{
870 if (socinfo_init() < 0)
871 pr_err("socinfo_init() failed!\n");
Tianyi Gou41515e22011-09-01 19:37:43 -0700872 apq8064_clock_init();
Joel King4ebccc62011-07-22 09:43:22 -0700873 gpiomux_init();
Kenneth Heitke748593a2011-07-15 15:45:11 -0600874 apq8064_i2c_init();
Kenneth Heitke36920d32011-07-20 16:44:30 -0600875
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600876 apq8064_device_qup_spi_gsbi5.dev.platform_data =
877 &apq8064_qup_spi_gsbi5_pdata;
Kenneth Heitke36920d32011-07-20 16:44:30 -0600878 apq8064_device_ssbi_pmic1.dev.platform_data =
Jay Chokshiea67c622011-07-29 17:12:26 -0700879 &apq8064_ssbi_pm8921_pdata;
Kenneth Heitke36920d32011-07-20 16:44:30 -0600880 apq8064_device_ssbi_pmic2.dev.platform_data =
881 &apq8064_ssbi_pm8821_pdata;
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -0700882 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700883 apq8064_pm8921_platform_data.num_regulators =
Jay Chokshiea67c622011-07-29 17:12:26 -0700884 msm8064_pm8921_regulator_pdata_len;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700885 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530886 apq8064_init_mmc();
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600887 slim_register_board_info(apq8064_slim_devices,
888 ARRAY_SIZE(apq8064_slim_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700889}
890
891static void __init apq8064_sim_init(void)
892{
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700893 struct msm_watchdog_pdata *wdog_pdata = (struct msm_watchdog_pdata *)
894 &msm8064_device_watchdog.dev.platform_data;
895
896 wdog_pdata->bark_time = 15000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700897 apq8064_common_init();
Joel King4e7ad222011-08-17 15:47:38 -0700898 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
899}
900
901static void __init apq8064_rumi3_init(void)
902{
Jay Chokshi9c25f072011-09-23 18:19:15 -0700903 apq8064_pm8921_irq_pdata.devirq = 0;
904 apq8064_pm8821_irq_pdata.devirq = 0;
Joel King4e7ad222011-08-17 15:47:38 -0700905 apq8064_common_init();
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700906 ethernet_init();
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700907 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700908 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700909}
910
911MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR")
912 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700913 .reserve = apq8064_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700914 .init_irq = apq8064_init_irq,
915 .timer = &msm_timer,
916 .init_machine = apq8064_sim_init,
917MACHINE_END
918
Joel King4e7ad222011-08-17 15:47:38 -0700919MACHINE_START(APQ8064_RUMI3, "QCT APQ8064 RUMI3")
920 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700921 .reserve = apq8064_reserve,
Joel King4e7ad222011-08-17 15:47:38 -0700922 .init_irq = apq8064_init_irq,
923 .timer = &msm_timer,
924 .init_machine = apq8064_rumi3_init,
925MACHINE_END
926