blob: 6662751ac543dfeba69b0732672d53ce009f6cbe [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 Tummalad9df3272011-08-19 16:50:46 +0530435 apq8064_sdc1_pdata->disable_bam = true;
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530436 apq8064_sdc1_pdata->disable_runtime_pm = true;
Sahitya Tummala85fa0702011-09-15 09:39:37 +0530437 apq8064_sdc1_pdata->disable_cmd23 = true;
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530438 }
439 if (apq8064_sdc3_pdata) {
Sahitya Tummalad9df3272011-08-19 16:50:46 +0530440 apq8064_sdc3_pdata->disable_bam = true;
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530441 apq8064_sdc3_pdata->disable_runtime_pm = true;
Sahitya Tummala85fa0702011-09-15 09:39:37 +0530442 apq8064_sdc3_pdata->disable_cmd23 = true;
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530443 }
Sahitya Tummalad9df3272011-08-19 16:50:46 +0530444 }
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530445 apq8064_add_sdcc(1, apq8064_sdc1_pdata);
446 apq8064_add_sdcc(3, apq8064_sdc3_pdata);
447}
448
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700449#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
450 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
451 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
452 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
453
454#define QCE_SIZE 0x10000
455#define QCE_0_BASE 0x11000000
456
457#define QCE_HW_KEY_SUPPORT 0
458#define QCE_SHA_HMAC_SUPPORT 1
459#define QCE_SHARE_CE_RESOURCE 3
460#define QCE_CE_SHARED 0
461
462static struct resource qcrypto_resources[] = {
463 [0] = {
464 .start = QCE_0_BASE,
465 .end = QCE_0_BASE + QCE_SIZE - 1,
466 .flags = IORESOURCE_MEM,
467 },
468 [1] = {
469 .name = "crypto_channels",
470 .start = DMOV8064_CE_IN_CHAN,
471 .end = DMOV8064_CE_OUT_CHAN,
472 .flags = IORESOURCE_DMA,
473 },
474 [2] = {
475 .name = "crypto_crci_in",
476 .start = DMOV8064_CE_IN_CRCI,
477 .end = DMOV8064_CE_IN_CRCI,
478 .flags = IORESOURCE_DMA,
479 },
480 [3] = {
481 .name = "crypto_crci_out",
482 .start = DMOV8064_CE_OUT_CRCI,
483 .end = DMOV8064_CE_OUT_CRCI,
484 .flags = IORESOURCE_DMA,
485 },
486};
487
488static struct resource qcedev_resources[] = {
489 [0] = {
490 .start = QCE_0_BASE,
491 .end = QCE_0_BASE + QCE_SIZE - 1,
492 .flags = IORESOURCE_MEM,
493 },
494 [1] = {
495 .name = "crypto_channels",
496 .start = DMOV8064_CE_IN_CHAN,
497 .end = DMOV8064_CE_OUT_CHAN,
498 .flags = IORESOURCE_DMA,
499 },
500 [2] = {
501 .name = "crypto_crci_in",
502 .start = DMOV8064_CE_IN_CRCI,
503 .end = DMOV8064_CE_IN_CRCI,
504 .flags = IORESOURCE_DMA,
505 },
506 [3] = {
507 .name = "crypto_crci_out",
508 .start = DMOV8064_CE_OUT_CRCI,
509 .end = DMOV8064_CE_OUT_CRCI,
510 .flags = IORESOURCE_DMA,
511 },
512};
513
514#endif
515
516#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
517 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
518
519static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
520 .ce_shared = QCE_CE_SHARED,
521 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
522 .hw_key_support = QCE_HW_KEY_SUPPORT,
523 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
524};
525
526static struct platform_device qcrypto_device = {
527 .name = "qcrypto",
528 .id = 0,
529 .num_resources = ARRAY_SIZE(qcrypto_resources),
530 .resource = qcrypto_resources,
531 .dev = {
532 .coherent_dma_mask = DMA_BIT_MASK(32),
533 .platform_data = &qcrypto_ce_hw_suppport,
534 },
535};
536#endif
537
538#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
539 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
540
541static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
542 .ce_shared = QCE_CE_SHARED,
543 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
544 .hw_key_support = QCE_HW_KEY_SUPPORT,
545 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
546};
547
548static struct platform_device qcedev_device = {
549 .name = "qce",
550 .id = 0,
551 .num_resources = ARRAY_SIZE(qcedev_resources),
552 .resource = qcedev_resources,
553 .dev = {
554 .coherent_dma_mask = DMA_BIT_MASK(32),
555 .platform_data = &qcedev_ce_hw_suppport,
556 },
557};
558#endif
559
560
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600561#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700562static void __init apq8064_map_io(void)
563{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600564 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700565 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -0700566 if (socinfo_init() < 0)
567 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700568}
569
570static void __init apq8064_init_irq(void)
571{
572 unsigned int i;
573 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
574 (void *)MSM_QGIC_CPU_BASE);
575
576 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
577 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
578
579 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
580 mb();
581
582 /*
583 * FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
584 * as they are configured as level, which does not play nice with
585 * handle_percpu_irq.
586 */
587 for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
588 if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
589 irq_set_handler(i, handle_percpu_irq);
590 }
591}
592
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800593static struct platform_device msm8064_device_saw_regulator_core0 = {
594 .name = "saw-regulator",
595 .id = 0,
596 .dev = {
597 .platform_data = &msm8064_saw_regulator_pdata_8921_s5,
598 },
599};
600
601static struct platform_device msm8064_device_saw_regulator_core1 = {
602 .name = "saw-regulator",
603 .id = 1,
604 .dev = {
605 .platform_data = &msm8064_saw_regulator_pdata_8921_s6,
606 },
607};
608
609static struct platform_device msm8064_device_saw_regulator_core2 = {
610 .name = "saw-regulator",
611 .id = 2,
612 .dev = {
613 .platform_data = &msm8064_saw_regulator_pdata_8821_s0,
614 },
615};
616
617static struct platform_device msm8064_device_saw_regulator_core3 = {
618 .name = "saw-regulator",
619 .id = 3,
620 .dev = {
621 .platform_data = &msm8064_saw_regulator_pdata_8821_s1,
622 },
623};
624
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700625static struct platform_device *common_devices[] __initdata = {
Jin Hong01f2dbb2011-11-03 22:13:51 -0700626 &apq8064_device_dmov,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600627 &apq8064_device_qup_i2c_gsbi4,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600628 &apq8064_device_qup_spi_gsbi5,
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600629 &apq8064_slim_ctrl,
Jay Chokshi9c25f072011-09-23 18:19:15 -0700630 &apq8064_device_ssbi_pmic1,
631 &apq8064_device_ssbi_pmic2,
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600632 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -0700633 &apq8064_device_otg,
634 &apq8064_device_gadget_peripheral,
635 &android_usb_device,
Kevin Chan13be4e22011-10-20 11:30:32 -0700636 &android_pmem_device,
637 &android_pmem_adsp_device,
638 &android_pmem_audio_device,
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700639 &msm8064_device_watchdog,
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800640 &msm8064_device_saw_regulator_core0,
641 &msm8064_device_saw_regulator_core1,
642 &msm8064_device_saw_regulator_core2,
643 &msm8064_device_saw_regulator_core3,
Ramesh Masavarapu28311912011-10-27 11:04:12 -0700644#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
645 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
646 &qcrypto_device,
647#endif
648
649#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
650 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
651 &qcedev_device,
652#endif
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600653};
654
Joel King4e7ad222011-08-17 15:47:38 -0700655static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700656 &apq8064_device_uart_gsbi3,
Yan He06913ce2011-08-26 16:33:46 -0700657 &msm_device_sps_apq8064,
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700658};
659
660static struct platform_device *rumi3_devices[] __initdata = {
661 &apq8064_device_uart_gsbi1,
Joel King4e7ad222011-08-17 15:47:38 -0700662};
663
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600664static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
Harini Jayaraman60ee14c2011-11-09 18:53:27 -0700665 .max_clock_speed = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700666};
667
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700668#define KS8851_IRQ_GPIO 43
669
670static struct spi_board_info spi_board_info[] __initdata = {
671 {
672 .modalias = "ks8851",
673 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
674 .max_speed_hz = 19200000,
675 .bus_num = 0,
676 .chip_select = 2,
677 .mode = SPI_MODE_0,
678 },
679};
680
681#ifdef CONFIG_KS8851
682static struct gpiomux_setting gpio_eth_config = {
683 .pull = GPIOMUX_PULL_NONE,
684 .drv = GPIOMUX_DRV_8MA,
685 .func = GPIOMUX_FUNC_GPIO,
686};
687
688/* The SPI configurations apply to GSBI 5*/
689static struct gpiomux_setting gpio_spi_config = {
690 .func = GPIOMUX_FUNC_2,
691 .drv = GPIOMUX_DRV_8MA,
692 .pull = GPIOMUX_PULL_NONE,
693};
694
695/* The SPI configurations apply to GSBI 5 chip select 2*/
696static struct gpiomux_setting gpio_spi_cs2_config = {
697 .func = GPIOMUX_FUNC_3,
698 .drv = GPIOMUX_DRV_8MA,
699 .pull = GPIOMUX_PULL_NONE,
700};
701#endif
702
703struct msm_gpiomux_config apq8064_ethernet_configs[NR_GPIO_IRQS] = {
704#ifdef CONFIG_KS8851
705 {
706 .gpio = KS8851_IRQ_GPIO,
707 .settings = {
708 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
709 [GPIOMUX_ACTIVE] = &gpio_eth_config,
710 }
711 },
712#endif
713};
714
715static struct msm_gpiomux_config apq8064_gsbi_configs[] __initdata = {
716#ifdef CONFIG_KS8851
717 {
718 .gpio = 51, /* GSBI5 QUP SPI_DATA_MOSI */
719 .settings = {
720 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
721 },
722 },
723 {
724 .gpio = 52, /* GSBI5 QUP SPI_DATA_MISO */
725 .settings = {
726 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
727 },
728 },
729 {
730 .gpio = 31, /* GSBI5 QUP SPI_CS2_N */
731 .settings = {
732 [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config,
733 },
734 },
735 {
736 .gpio = 54, /* GSBI5 QUP SPI_CLK */
737 .settings = {
738 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
739 },
740 },
741#endif
742};
743
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700744static struct pm8xxx_mpp_platform_data
745apq8064_pm8921_mpp_pdata __devinitdata = {
746 .mpp_base = PM8921_MPP_PM_TO_SYS(1),
747};
748
749static struct pm8xxx_gpio_platform_data
750apq8064_pm8921_gpio_pdata __devinitdata = {
751 .gpio_base = PM8921_GPIO_PM_TO_SYS(1),
752};
753
754static struct pm8xxx_irq_platform_data
755apq8064_pm8921_irq_pdata __devinitdata = {
756 .irq_base = PM8921_IRQ_BASE,
Jay Chokshi44873f72011-08-30 17:24:26 -0700757 .devirq = PM8921_USR_IRQ_N,
758 .irq_trigger_flag = IRQF_TRIGGER_HIGH,
Jay Chokshi9e926e72011-09-23 19:19:58 -0700759 .dev_id = 0,
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700760};
761
762static struct pm8921_platform_data
763apq8064_pm8921_platform_data __devinitdata = {
Jay Chokshiea67c622011-07-29 17:12:26 -0700764 .regulator_pdatas = msm8064_pm8921_regulator_pdata,
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700765 .irq_pdata = &apq8064_pm8921_irq_pdata,
766 .gpio_pdata = &apq8064_pm8921_gpio_pdata,
767 .mpp_pdata = &apq8064_pm8921_mpp_pdata,
Jay Chokshiea67c622011-07-29 17:12:26 -0700768};
769
Jay Chokshi44873f72011-08-30 17:24:26 -0700770static struct pm8xxx_irq_platform_data
771apq8064_pm8821_irq_pdata __devinitdata = {
772 .irq_base = PM8821_IRQ_BASE,
773 .devirq = PM8821_USR_IRQ_N,
774 .irq_trigger_flag = IRQF_TRIGGER_HIGH,
Jay Chokshi9e926e72011-09-23 19:19:58 -0700775 .dev_id = 1,
Jay Chokshi44873f72011-08-30 17:24:26 -0700776};
777
778static struct pm8xxx_mpp_platform_data
779apq8064_pm8821_mpp_pdata __devinitdata = {
780 .mpp_base = PM8821_MPP_PM_TO_SYS(1),
781};
782
783static struct pm8821_platform_data
784apq8064_pm8821_platform_data __devinitdata = {
785 .irq_pdata = &apq8064_pm8821_irq_pdata,
786 .mpp_pdata = &apq8064_pm8821_mpp_pdata,
787};
788
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700789static struct msm_ssbi_platform_data apq8064_ssbi_pm8921_pdata __devinitdata = {
790 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
791 .slave = {
Jay Chokshiea67c622011-07-29 17:12:26 -0700792 .name = "pm8921-core",
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700793 .platform_data = &apq8064_pm8921_platform_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700794 },
795};
796
797static struct msm_ssbi_platform_data apq8064_ssbi_pm8821_pdata __devinitdata = {
798 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
799 .slave = {
Jay Chokshi44873f72011-08-30 17:24:26 -0700800 .name = "pm8821-core",
801 .platform_data = &apq8064_pm8821_platform_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700802 },
803};
804
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600805static struct slim_boardinfo apq8064_slim_devices[] = {
806 /* Add slimbus slaves as needed */
807};
808
Kenneth Heitke748593a2011-07-15 15:45:11 -0600809static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
810 .clk_freq = 100000,
811 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600812};
813
814static void __init apq8064_i2c_init(void)
815{
816 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
817 &apq8064_i2c_qup_gsbi4_pdata;
818}
819
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700820static int __init gpiomux_init(void)
821{
822 int rc;
823
824 rc = msm_gpiomux_init(NR_GPIO_IRQS);
825 if (rc) {
826 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
827 return rc;
828 }
829 msm_gpiomux_install(apq8064_ethernet_configs,
830 ARRAY_SIZE(apq8064_ethernet_configs));
831
832 msm_gpiomux_install(apq8064_gsbi_configs,
833 ARRAY_SIZE(apq8064_gsbi_configs));
834 return 0;
835}
836
837#ifdef CONFIG_KS8851
838static int ethernet_init(void)
839{
840 int ret;
841 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
842 if (ret) {
843 pr_err("ks8851 gpio_request failed: %d\n", ret);
844 goto fail;
845 }
846
847 return 0;
848fail:
849 return ret;
850}
851#else
852static int ethernet_init(void)
853{
854 return 0;
855}
856#endif
857
Tianyi Gou41515e22011-09-01 19:37:43 -0700858static void __init apq8064_clock_init(void)
859{
860 if (machine_is_apq8064_sim())
861 msm_clock_init(&apq8064_clock_init_data);
862 else
863 msm_clock_init(&apq8064_dummy_clock_init_data);
864}
865
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700866static void __init apq8064_common_init(void)
867{
868 if (socinfo_init() < 0)
869 pr_err("socinfo_init() failed!\n");
Tianyi Gou41515e22011-09-01 19:37:43 -0700870 apq8064_clock_init();
Joel King4ebccc62011-07-22 09:43:22 -0700871 gpiomux_init();
Kenneth Heitke748593a2011-07-15 15:45:11 -0600872 apq8064_i2c_init();
Kenneth Heitke36920d32011-07-20 16:44:30 -0600873
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600874 apq8064_device_qup_spi_gsbi5.dev.platform_data =
875 &apq8064_qup_spi_gsbi5_pdata;
Kenneth Heitke36920d32011-07-20 16:44:30 -0600876 apq8064_device_ssbi_pmic1.dev.platform_data =
Jay Chokshiea67c622011-07-29 17:12:26 -0700877 &apq8064_ssbi_pm8921_pdata;
Kenneth Heitke36920d32011-07-20 16:44:30 -0600878 apq8064_device_ssbi_pmic2.dev.platform_data =
879 &apq8064_ssbi_pm8821_pdata;
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -0700880 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700881 apq8064_pm8921_platform_data.num_regulators =
Jay Chokshiea67c622011-07-29 17:12:26 -0700882 msm8064_pm8921_regulator_pdata_len;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700883 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530884 apq8064_init_mmc();
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600885 slim_register_board_info(apq8064_slim_devices,
886 ARRAY_SIZE(apq8064_slim_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700887}
888
889static void __init apq8064_sim_init(void)
890{
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700891 struct msm_watchdog_pdata *wdog_pdata = (struct msm_watchdog_pdata *)
892 &msm8064_device_watchdog.dev.platform_data;
893
894 wdog_pdata->bark_time = 15000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700895 apq8064_common_init();
Joel King4e7ad222011-08-17 15:47:38 -0700896 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
897}
898
899static void __init apq8064_rumi3_init(void)
900{
Jay Chokshi9c25f072011-09-23 18:19:15 -0700901 apq8064_pm8921_irq_pdata.devirq = 0;
902 apq8064_pm8821_irq_pdata.devirq = 0;
Joel King4e7ad222011-08-17 15:47:38 -0700903 apq8064_common_init();
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700904 ethernet_init();
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700905 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700906 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700907}
908
909MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR")
910 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700911 .reserve = apq8064_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700912 .init_irq = apq8064_init_irq,
913 .timer = &msm_timer,
914 .init_machine = apq8064_sim_init,
915MACHINE_END
916
Joel King4e7ad222011-08-17 15:47:38 -0700917MACHINE_START(APQ8064_RUMI3, "QCT APQ8064 RUMI3")
918 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700919 .reserve = apq8064_reserve,
Joel King4e7ad222011-08-17 15:47:38 -0700920 .init_irq = apq8064_init_irq,
921 .timer = &msm_timer,
922 .init_machine = apq8064_rumi3_init,
923MACHINE_END
924