blob: 4aa6abe48ca2bc636f205428acb2c05f350c4358 [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>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070021#include <asm/mach-types.h>
22#include <asm/mach/arch.h>
23#include <asm/hardware/gic.h>
Sahitya Tummala3586ed92011-08-03 09:13:23 +053024#include <asm/mach/mmc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070025
26#include <mach/board.h>
27#include <mach/msm_iomap.h>
28#include <linux/usb/msm_hsusb.h>
29#include <linux/usb/android.h>
30#include <mach/socinfo.h>
Harini Jayaramanc4c58692011-07-19 14:50:10 -060031#include <mach/msm_spi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070032#include "timer.h"
33#include "devices.h"
Joel King4ebccc62011-07-22 09:43:22 -070034#include <mach/gpio.h>
35#include <mach/gpiomux.h>
Kevin Chan13be4e22011-10-20 11:30:32 -070036#include <linux/android_pmem.h>
37#include <mach/msm_memtypes.h>
38#include <linux/bootmem.h>
39#include <asm/setup.h>
Joel King4ebccc62011-07-22 09:43:22 -070040
Jay Chokshiea67c622011-07-29 17:12:26 -070041#include "board-apq8064.h"
42
Kevin Chan13be4e22011-10-20 11:30:32 -070043#define MSM_PMEM_KERNEL_EBI1_SIZE 0x600000
44#define MSM_PMEM_ADSP_SIZE 0x3800000
45#define MSM_PMEM_AUDIO_SIZE 0x28B000
46#define MSM_PMEM_SIZE 0x1800000 /* 24 Mbytes */
47
48static struct memtype_reserve apq8064_reserve_table[] __initdata = {
49 [MEMTYPE_SMI] = {
50 },
51 [MEMTYPE_EBI0] = {
52 .flags = MEMTYPE_FLAGS_1M_ALIGN,
53 },
54 [MEMTYPE_EBI1] = {
55 .flags = MEMTYPE_FLAGS_1M_ALIGN,
56 },
57};
58
59static int apq8064_paddr_to_memtype(unsigned int paddr)
60{
61 return MEMTYPE_EBI1;
62}
63
64static unsigned pmem_size = MSM_PMEM_SIZE;
65static int __init pmem_size_setup(char *p)
66{
67 pmem_size = memparse(p, NULL);
68 return 0;
69}
70early_param("pmem_size", pmem_size_setup);
71
72static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
73
74static int __init pmem_adsp_size_setup(char *p)
75{
76 pmem_adsp_size = memparse(p, NULL);
77 return 0;
78}
79early_param("pmem_adsp_size", pmem_adsp_size_setup);
80
81static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
82
83static int __init pmem_audio_size_setup(char *p)
84{
85 pmem_audio_size = memparse(p, NULL);
86 return 0;
87}
88early_param("pmem_audio_size", pmem_audio_size_setup);
89
90static struct android_pmem_platform_data android_pmem_pdata = {
91 .name = "pmem",
92 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
93 .cached = 1,
94 .memory_type = MEMTYPE_EBI1,
95};
96
97static struct platform_device android_pmem_device = {
98 .name = "android_pmem",
99 .id = 0,
100 .dev = {.platform_data = &android_pmem_pdata},
101};
102
103static struct android_pmem_platform_data android_pmem_adsp_pdata = {
104 .name = "pmem_adsp",
105 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
106 .cached = 0,
107 .memory_type = MEMTYPE_EBI1,
108};
109
110static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
111static int __init pmem_kernel_ebi1_size_setup(char *p)
112{
113 pmem_kernel_ebi1_size = memparse(p, NULL);
114 return 0;
115}
116early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
117
118static struct platform_device android_pmem_adsp_device = {
119 .name = "android_pmem",
120 .id = 2,
121 .dev = { .platform_data = &android_pmem_adsp_pdata },
122};
123
124static struct android_pmem_platform_data android_pmem_audio_pdata = {
125 .name = "pmem_audio",
126 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
127 .cached = 0,
128 .memory_type = MEMTYPE_EBI1,
129};
130
131static struct platform_device android_pmem_audio_device = {
132 .name = "android_pmem",
133 .id = 4,
134 .dev = { .platform_data = &android_pmem_audio_pdata },
135};
136
137static void __init size_pmem_devices(void)
138{
139 android_pmem_adsp_pdata.size = pmem_adsp_size;
140 android_pmem_pdata.size = pmem_size;
141 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
142}
143
144static void __init reserve_memory_for(struct android_pmem_platform_data *p)
145{
146 apq8064_reserve_table[p->memory_type].size += p->size;
147}
148
149
150static void __init reserve_pmem_memory(void)
151{
152 reserve_memory_for(&android_pmem_adsp_pdata);
153 reserve_memory_for(&android_pmem_pdata);
154 reserve_memory_for(&android_pmem_audio_pdata);
155 apq8064_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
156}
157
158static void __init apq8064_calculate_reserve_sizes(void)
159{
160 size_pmem_devices();
161 reserve_pmem_memory();
162}
163
164static struct reserve_info apq8064_reserve_info __initdata = {
165 .memtype_reserve_table = apq8064_reserve_table,
166 .calculate_reserve_sizes = apq8064_calculate_reserve_sizes,
167 .paddr_to_memtype = apq8064_paddr_to_memtype,
168};
169
170static int apq8064_memory_bank_size(void)
171{
172 return 1<<29;
173}
174
175static void __init locate_unstable_memory(void)
176{
177 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
178 unsigned long bank_size;
179 unsigned long low, high;
180
181 bank_size = apq8064_memory_bank_size();
182 low = meminfo.bank[0].start;
183 high = mb->start + mb->size;
184 low &= ~(bank_size - 1);
185
186 if (high - low <= bank_size)
187 return;
188 apq8064_reserve_info.low_unstable_address = low + bank_size;
189 apq8064_reserve_info.max_unstable_size = high - low - bank_size;
190 apq8064_reserve_info.bank_size = bank_size;
191 pr_info("low unstable address %lx max size %lx bank size %lx\n",
192 apq8064_reserve_info.low_unstable_address,
193 apq8064_reserve_info.max_unstable_size,
194 apq8064_reserve_info.bank_size);
195}
196
197static void __init apq8064_reserve(void)
198{
199 reserve_info = &apq8064_reserve_info;
200 locate_unstable_memory();
201 msm_reserve();
202}
203
Hemant Kumar4933b072011-10-17 23:43:11 -0700204static struct platform_device android_usb_device = {
205 .name = "android_usb",
206 .id = -1,
207};
208
209static struct msm_otg_platform_data msm_otg_pdata = {
210 .mode = USB_PERIPHERAL,
211 .otg_control = OTG_PHY_CONTROL,
212 .phy_type = SNPS_28NM_INTEGRATED_PHY,
213 .pclk_src_name = "dfab_usb_hs_clk",
214};
215
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -0700216/* APQ8064 has 4 SDCC controllers */
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530217enum sdcc_controllers {
218 SDCC1,
219 SDCC2,
220 SDCC3,
221 SDCC4,
222 MAX_SDCC_CONTROLLER
223};
224
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -0700225/* All SDCC controllers require VDD/VCC voltage */
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530226static struct msm_mmc_reg_data mmc_vdd_reg_data[MAX_SDCC_CONTROLLER] = {
227 /* SDCC1 : eMMC card connected */
228 [SDCC1] = {
229 .name = "sdc_vdd",
230 .set_voltage_sup = 1,
231 .high_vol_level = 2950000,
232 .low_vol_level = 2950000,
233 .always_on = 1,
234 .lpm_sup = 1,
235 .lpm_uA = 9000,
236 .hpm_uA = 200000, /* 200mA */
237 },
238 /* SDCC3 : External card slot connected */
239 [SDCC3] = {
240 .name = "sdc_vdd",
241 .set_voltage_sup = 1,
242 .high_vol_level = 2950000,
243 .low_vol_level = 2950000,
244 .hpm_uA = 600000, /* 600mA */
245 }
246};
247
248/* Only slots having eMMC card will require VCCQ voltage */
249static struct msm_mmc_reg_data mmc_vccq_reg_data[1] = {
250 /* SDCC1 : eMMC card connected */
251 [SDCC1] = {
252 .name = "sdc_vccq",
253 .set_voltage_sup = 1,
254 .always_on = 1,
255 .high_vol_level = 1800000,
256 .low_vol_level = 1800000,
257 .hpm_uA = 200000, /* 200mA */
258 }
259};
260
261/* All SDCC controllers may require voting for VDD PAD voltage */
262static struct msm_mmc_reg_data mmc_vddp_reg_data[MAX_SDCC_CONTROLLER] = {
263 /* SDCC3 : External card slot connected */
264 [SDCC3] = {
265 .name = "sdc_vddp",
266 .set_voltage_sup = 1,
267 .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],
407 .sdcc_v4_sup = true,
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530408};
409static struct mmc_platform_data *apq8064_sdc1_pdata = &sdc1_data;
410#else
411static struct mmc_platform_data *apq8064_sdc1_pdata;
412#endif
413
414#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
415static unsigned int sdc3_sup_clk_rates[] = {
416 400000, 24000000, 48000000, 96000000
417};
418
419static struct mmc_platform_data sdc3_data = {
420 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
421 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
422 .sup_clk_table = sdc3_sup_clk_rates,
423 .sup_clk_cnt = ARRAY_SIZE(sdc3_sup_clk_rates),
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530424 .pin_data = &mmc_slot_pin_data[SDCC3],
425 .vreg_data = &mmc_slot_vreg_data[SDCC3],
426 .sdcc_v4_sup = true,
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530427};
428static struct mmc_platform_data *apq8064_sdc3_pdata = &sdc3_data;
429#else
430static struct mmc_platform_data *apq8064_sdc3_pdata;
431#endif
432
433static void __init apq8064_init_mmc(void)
434{
Amol Jadi7d4ce032011-09-09 17:07:18 -0700435 if ((machine_is_apq8064_rumi3()) || machine_is_apq8064_sim()) {
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530436 if (apq8064_sdc1_pdata) {
Sahitya Tummalad9df3272011-08-19 16:50:46 +0530437 apq8064_sdc1_pdata->disable_bam = true;
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530438 apq8064_sdc1_pdata->disable_runtime_pm = true;
Sahitya Tummala85fa0702011-09-15 09:39:37 +0530439 apq8064_sdc1_pdata->disable_cmd23 = true;
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530440 }
441 if (apq8064_sdc3_pdata) {
Sahitya Tummalad9df3272011-08-19 16:50:46 +0530442 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
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600451#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700452static void __init apq8064_map_io(void)
453{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600454 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700455 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -0700456 if (socinfo_init() < 0)
457 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700458}
459
460static void __init apq8064_init_irq(void)
461{
462 unsigned int i;
463 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
464 (void *)MSM_QGIC_CPU_BASE);
465
466 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
467 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
468
469 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
470 mb();
471
472 /*
473 * FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
474 * as they are configured as level, which does not play nice with
475 * handle_percpu_irq.
476 */
477 for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
478 if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
479 irq_set_handler(i, handle_percpu_irq);
480 }
481}
482
483static struct platform_device *common_devices[] __initdata = {
Kenneth Heitke748593a2011-07-15 15:45:11 -0600484 &apq8064_device_qup_i2c_gsbi4,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600485 &apq8064_device_qup_spi_gsbi5,
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600486 &apq8064_slim_ctrl,
Jay Chokshi9c25f072011-09-23 18:19:15 -0700487 &apq8064_device_ssbi_pmic1,
488 &apq8064_device_ssbi_pmic2,
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600489 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -0700490 &apq8064_device_otg,
491 &apq8064_device_gadget_peripheral,
492 &android_usb_device,
Kevin Chan13be4e22011-10-20 11:30:32 -0700493 &android_pmem_device,
494 &android_pmem_adsp_device,
495 &android_pmem_audio_device,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600496};
497
Joel King4e7ad222011-08-17 15:47:38 -0700498static struct platform_device *sim_devices[] __initdata = {
499 &apq8064_device_dmov,
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700500 &apq8064_device_uart_gsbi3,
Yan He06913ce2011-08-26 16:33:46 -0700501 &msm_device_sps_apq8064,
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700502};
503
504static struct platform_device *rumi3_devices[] __initdata = {
505 &apq8064_device_uart_gsbi1,
Joel King4e7ad222011-08-17 15:47:38 -0700506};
507
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600508static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
509 .max_clock_speed = 26000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700510};
511
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700512#define KS8851_IRQ_GPIO 43
513
514static struct spi_board_info spi_board_info[] __initdata = {
515 {
516 .modalias = "ks8851",
517 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
518 .max_speed_hz = 19200000,
519 .bus_num = 0,
520 .chip_select = 2,
521 .mode = SPI_MODE_0,
522 },
523};
524
525#ifdef CONFIG_KS8851
526static struct gpiomux_setting gpio_eth_config = {
527 .pull = GPIOMUX_PULL_NONE,
528 .drv = GPIOMUX_DRV_8MA,
529 .func = GPIOMUX_FUNC_GPIO,
530};
531
532/* The SPI configurations apply to GSBI 5*/
533static struct gpiomux_setting gpio_spi_config = {
534 .func = GPIOMUX_FUNC_2,
535 .drv = GPIOMUX_DRV_8MA,
536 .pull = GPIOMUX_PULL_NONE,
537};
538
539/* The SPI configurations apply to GSBI 5 chip select 2*/
540static struct gpiomux_setting gpio_spi_cs2_config = {
541 .func = GPIOMUX_FUNC_3,
542 .drv = GPIOMUX_DRV_8MA,
543 .pull = GPIOMUX_PULL_NONE,
544};
545#endif
546
547struct msm_gpiomux_config apq8064_ethernet_configs[NR_GPIO_IRQS] = {
548#ifdef CONFIG_KS8851
549 {
550 .gpio = KS8851_IRQ_GPIO,
551 .settings = {
552 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
553 [GPIOMUX_ACTIVE] = &gpio_eth_config,
554 }
555 },
556#endif
557};
558
559static struct msm_gpiomux_config apq8064_gsbi_configs[] __initdata = {
560#ifdef CONFIG_KS8851
561 {
562 .gpio = 51, /* GSBI5 QUP SPI_DATA_MOSI */
563 .settings = {
564 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
565 },
566 },
567 {
568 .gpio = 52, /* GSBI5 QUP SPI_DATA_MISO */
569 .settings = {
570 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
571 },
572 },
573 {
574 .gpio = 31, /* GSBI5 QUP SPI_CS2_N */
575 .settings = {
576 [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config,
577 },
578 },
579 {
580 .gpio = 54, /* GSBI5 QUP SPI_CLK */
581 .settings = {
582 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
583 },
584 },
585#endif
586};
587
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700588static struct pm8xxx_mpp_platform_data
589apq8064_pm8921_mpp_pdata __devinitdata = {
590 .mpp_base = PM8921_MPP_PM_TO_SYS(1),
591};
592
593static struct pm8xxx_gpio_platform_data
594apq8064_pm8921_gpio_pdata __devinitdata = {
595 .gpio_base = PM8921_GPIO_PM_TO_SYS(1),
596};
597
598static struct pm8xxx_irq_platform_data
599apq8064_pm8921_irq_pdata __devinitdata = {
600 .irq_base = PM8921_IRQ_BASE,
Jay Chokshi44873f72011-08-30 17:24:26 -0700601 .devirq = PM8921_USR_IRQ_N,
602 .irq_trigger_flag = IRQF_TRIGGER_HIGH,
Jay Chokshi9e926e72011-09-23 19:19:58 -0700603 .dev_id = 0,
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700604};
605
606static struct pm8921_platform_data
607apq8064_pm8921_platform_data __devinitdata = {
Jay Chokshiea67c622011-07-29 17:12:26 -0700608 .regulator_pdatas = msm8064_pm8921_regulator_pdata,
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700609 .irq_pdata = &apq8064_pm8921_irq_pdata,
610 .gpio_pdata = &apq8064_pm8921_gpio_pdata,
611 .mpp_pdata = &apq8064_pm8921_mpp_pdata,
Jay Chokshiea67c622011-07-29 17:12:26 -0700612};
613
Jay Chokshi44873f72011-08-30 17:24:26 -0700614static struct pm8xxx_irq_platform_data
615apq8064_pm8821_irq_pdata __devinitdata = {
616 .irq_base = PM8821_IRQ_BASE,
617 .devirq = PM8821_USR_IRQ_N,
618 .irq_trigger_flag = IRQF_TRIGGER_HIGH,
Jay Chokshi9e926e72011-09-23 19:19:58 -0700619 .dev_id = 1,
Jay Chokshi44873f72011-08-30 17:24:26 -0700620};
621
622static struct pm8xxx_mpp_platform_data
623apq8064_pm8821_mpp_pdata __devinitdata = {
624 .mpp_base = PM8821_MPP_PM_TO_SYS(1),
625};
626
627static struct pm8821_platform_data
628apq8064_pm8821_platform_data __devinitdata = {
629 .irq_pdata = &apq8064_pm8821_irq_pdata,
630 .mpp_pdata = &apq8064_pm8821_mpp_pdata,
631};
632
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700633static struct msm_ssbi_platform_data apq8064_ssbi_pm8921_pdata __devinitdata = {
634 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
635 .slave = {
Jay Chokshiea67c622011-07-29 17:12:26 -0700636 .name = "pm8921-core",
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700637 .platform_data = &apq8064_pm8921_platform_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700638 },
639};
640
641static struct msm_ssbi_platform_data apq8064_ssbi_pm8821_pdata __devinitdata = {
642 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
643 .slave = {
Jay Chokshi44873f72011-08-30 17:24:26 -0700644 .name = "pm8821-core",
645 .platform_data = &apq8064_pm8821_platform_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700646 },
647};
648
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600649static struct slim_boardinfo apq8064_slim_devices[] = {
650 /* Add slimbus slaves as needed */
651};
652
Kenneth Heitke748593a2011-07-15 15:45:11 -0600653static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
654 .clk_freq = 100000,
655 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600656};
657
658static void __init apq8064_i2c_init(void)
659{
660 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
661 &apq8064_i2c_qup_gsbi4_pdata;
662}
663
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700664static int __init gpiomux_init(void)
665{
666 int rc;
667
668 rc = msm_gpiomux_init(NR_GPIO_IRQS);
669 if (rc) {
670 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
671 return rc;
672 }
673 msm_gpiomux_install(apq8064_ethernet_configs,
674 ARRAY_SIZE(apq8064_ethernet_configs));
675
676 msm_gpiomux_install(apq8064_gsbi_configs,
677 ARRAY_SIZE(apq8064_gsbi_configs));
678 return 0;
679}
680
681#ifdef CONFIG_KS8851
682static int ethernet_init(void)
683{
684 int ret;
685 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
686 if (ret) {
687 pr_err("ks8851 gpio_request failed: %d\n", ret);
688 goto fail;
689 }
690
691 return 0;
692fail:
693 return ret;
694}
695#else
696static int ethernet_init(void)
697{
698 return 0;
699}
700#endif
701
Tianyi Gou41515e22011-09-01 19:37:43 -0700702static void __init apq8064_clock_init(void)
703{
704 if (machine_is_apq8064_sim())
705 msm_clock_init(&apq8064_clock_init_data);
706 else
707 msm_clock_init(&apq8064_dummy_clock_init_data);
708}
709
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700710static void __init apq8064_common_init(void)
711{
712 if (socinfo_init() < 0)
713 pr_err("socinfo_init() failed!\n");
Tianyi Gou41515e22011-09-01 19:37:43 -0700714 apq8064_clock_init();
Joel King4ebccc62011-07-22 09:43:22 -0700715 gpiomux_init();
Kenneth Heitke748593a2011-07-15 15:45:11 -0600716 apq8064_i2c_init();
Kenneth Heitke36920d32011-07-20 16:44:30 -0600717
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600718 apq8064_device_qup_spi_gsbi5.dev.platform_data =
719 &apq8064_qup_spi_gsbi5_pdata;
Kenneth Heitke36920d32011-07-20 16:44:30 -0600720 apq8064_device_ssbi_pmic1.dev.platform_data =
Jay Chokshiea67c622011-07-29 17:12:26 -0700721 &apq8064_ssbi_pm8921_pdata;
Kenneth Heitke36920d32011-07-20 16:44:30 -0600722 apq8064_device_ssbi_pmic2.dev.platform_data =
723 &apq8064_ssbi_pm8821_pdata;
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -0700724 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
725 apq8064_device_gadget_peripheral.dev.parent = &apq8064_device_otg.dev;
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700726 apq8064_pm8921_platform_data.num_regulators =
Jay Chokshiea67c622011-07-29 17:12:26 -0700727 msm8064_pm8921_regulator_pdata_len;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700728 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530729 apq8064_init_mmc();
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600730 slim_register_board_info(apq8064_slim_devices,
731 ARRAY_SIZE(apq8064_slim_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700732}
733
734static void __init apq8064_sim_init(void)
735{
736 apq8064_common_init();
Joel King4e7ad222011-08-17 15:47:38 -0700737 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
738}
739
740static void __init apq8064_rumi3_init(void)
741{
Jay Chokshi9c25f072011-09-23 18:19:15 -0700742 apq8064_pm8921_irq_pdata.devirq = 0;
743 apq8064_pm8821_irq_pdata.devirq = 0;
Joel King4e7ad222011-08-17 15:47:38 -0700744 apq8064_common_init();
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700745 ethernet_init();
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700746 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700747 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700748}
749
750MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR")
751 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700752 .reserve = apq8064_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700753 .init_irq = apq8064_init_irq,
754 .timer = &msm_timer,
755 .init_machine = apq8064_sim_init,
756MACHINE_END
757
Joel King4e7ad222011-08-17 15:47:38 -0700758MACHINE_START(APQ8064_RUMI3, "QCT APQ8064 RUMI3")
759 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700760 .reserve = apq8064_reserve,
Joel King4e7ad222011-08-17 15:47:38 -0700761 .init_irq = apq8064_init_irq,
762 .timer = &msm_timer,
763 .init_machine = apq8064_rumi3_init,
764MACHINE_END
765