blob: 88ce818ffcfc7de27367e2a95d262a0193283b1f [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
Jeff Ohlstein7e668552011-10-06 16:17:25 -070041#include "msm_watchdog.h"
Jay Chokshiea67c622011-07-29 17:12:26 -070042#include "board-apq8064.h"
43
Kevin Chan13be4e22011-10-20 11:30:32 -070044#define MSM_PMEM_KERNEL_EBI1_SIZE 0x600000
45#define MSM_PMEM_ADSP_SIZE 0x3800000
46#define MSM_PMEM_AUDIO_SIZE 0x28B000
47#define MSM_PMEM_SIZE 0x1800000 /* 24 Mbytes */
48
49static struct memtype_reserve apq8064_reserve_table[] __initdata = {
50 [MEMTYPE_SMI] = {
51 },
52 [MEMTYPE_EBI0] = {
53 .flags = MEMTYPE_FLAGS_1M_ALIGN,
54 },
55 [MEMTYPE_EBI1] = {
56 .flags = MEMTYPE_FLAGS_1M_ALIGN,
57 },
58};
59
60static int apq8064_paddr_to_memtype(unsigned int paddr)
61{
62 return MEMTYPE_EBI1;
63}
64
65static unsigned pmem_size = MSM_PMEM_SIZE;
66static int __init pmem_size_setup(char *p)
67{
68 pmem_size = memparse(p, NULL);
69 return 0;
70}
71early_param("pmem_size", pmem_size_setup);
72
73static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
74
75static int __init pmem_adsp_size_setup(char *p)
76{
77 pmem_adsp_size = memparse(p, NULL);
78 return 0;
79}
80early_param("pmem_adsp_size", pmem_adsp_size_setup);
81
82static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
83
84static int __init pmem_audio_size_setup(char *p)
85{
86 pmem_audio_size = memparse(p, NULL);
87 return 0;
88}
89early_param("pmem_audio_size", pmem_audio_size_setup);
90
91static struct android_pmem_platform_data android_pmem_pdata = {
92 .name = "pmem",
93 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
94 .cached = 1,
95 .memory_type = MEMTYPE_EBI1,
96};
97
98static struct platform_device android_pmem_device = {
99 .name = "android_pmem",
100 .id = 0,
101 .dev = {.platform_data = &android_pmem_pdata},
102};
103
104static struct android_pmem_platform_data android_pmem_adsp_pdata = {
105 .name = "pmem_adsp",
106 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
107 .cached = 0,
108 .memory_type = MEMTYPE_EBI1,
109};
110
111static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
112static int __init pmem_kernel_ebi1_size_setup(char *p)
113{
114 pmem_kernel_ebi1_size = memparse(p, NULL);
115 return 0;
116}
117early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
118
119static struct platform_device android_pmem_adsp_device = {
120 .name = "android_pmem",
121 .id = 2,
122 .dev = { .platform_data = &android_pmem_adsp_pdata },
123};
124
125static struct android_pmem_platform_data android_pmem_audio_pdata = {
126 .name = "pmem_audio",
127 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
128 .cached = 0,
129 .memory_type = MEMTYPE_EBI1,
130};
131
132static struct platform_device android_pmem_audio_device = {
133 .name = "android_pmem",
134 .id = 4,
135 .dev = { .platform_data = &android_pmem_audio_pdata },
136};
137
138static void __init size_pmem_devices(void)
139{
140 android_pmem_adsp_pdata.size = pmem_adsp_size;
141 android_pmem_pdata.size = pmem_size;
142 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
143}
144
145static void __init reserve_memory_for(struct android_pmem_platform_data *p)
146{
147 apq8064_reserve_table[p->memory_type].size += p->size;
148}
149
150
151static void __init reserve_pmem_memory(void)
152{
153 reserve_memory_for(&android_pmem_adsp_pdata);
154 reserve_memory_for(&android_pmem_pdata);
155 reserve_memory_for(&android_pmem_audio_pdata);
156 apq8064_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
157}
158
159static void __init apq8064_calculate_reserve_sizes(void)
160{
161 size_pmem_devices();
162 reserve_pmem_memory();
163}
164
165static struct reserve_info apq8064_reserve_info __initdata = {
166 .memtype_reserve_table = apq8064_reserve_table,
167 .calculate_reserve_sizes = apq8064_calculate_reserve_sizes,
168 .paddr_to_memtype = apq8064_paddr_to_memtype,
169};
170
171static int apq8064_memory_bank_size(void)
172{
173 return 1<<29;
174}
175
176static void __init locate_unstable_memory(void)
177{
178 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
179 unsigned long bank_size;
180 unsigned long low, high;
181
182 bank_size = apq8064_memory_bank_size();
183 low = meminfo.bank[0].start;
184 high = mb->start + mb->size;
185 low &= ~(bank_size - 1);
186
187 if (high - low <= bank_size)
188 return;
189 apq8064_reserve_info.low_unstable_address = low + bank_size;
190 apq8064_reserve_info.max_unstable_size = high - low - bank_size;
191 apq8064_reserve_info.bank_size = bank_size;
192 pr_info("low unstable address %lx max size %lx bank size %lx\n",
193 apq8064_reserve_info.low_unstable_address,
194 apq8064_reserve_info.max_unstable_size,
195 apq8064_reserve_info.bank_size);
196}
197
198static void __init apq8064_reserve(void)
199{
200 reserve_info = &apq8064_reserve_info;
201 locate_unstable_memory();
202 msm_reserve();
203}
204
Hemant Kumar4933b072011-10-17 23:43:11 -0700205static struct platform_device android_usb_device = {
206 .name = "android_usb",
207 .id = -1,
208};
209
210static struct msm_otg_platform_data msm_otg_pdata = {
211 .mode = USB_PERIPHERAL,
212 .otg_control = OTG_PHY_CONTROL,
213 .phy_type = SNPS_28NM_INTEGRATED_PHY,
214 .pclk_src_name = "dfab_usb_hs_clk",
215};
216
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -0700217/* APQ8064 has 4 SDCC controllers */
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530218enum sdcc_controllers {
219 SDCC1,
220 SDCC2,
221 SDCC3,
222 SDCC4,
223 MAX_SDCC_CONTROLLER
224};
225
Stepan Moskovchenko73b943b2011-10-31 22:43:00 -0700226/* All SDCC controllers require VDD/VCC voltage */
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530227static struct msm_mmc_reg_data mmc_vdd_reg_data[MAX_SDCC_CONTROLLER] = {
228 /* SDCC1 : eMMC card connected */
229 [SDCC1] = {
230 .name = "sdc_vdd",
231 .set_voltage_sup = 1,
232 .high_vol_level = 2950000,
233 .low_vol_level = 2950000,
234 .always_on = 1,
235 .lpm_sup = 1,
236 .lpm_uA = 9000,
237 .hpm_uA = 200000, /* 200mA */
238 },
239 /* SDCC3 : External card slot connected */
240 [SDCC3] = {
241 .name = "sdc_vdd",
242 .set_voltage_sup = 1,
243 .high_vol_level = 2950000,
244 .low_vol_level = 2950000,
245 .hpm_uA = 600000, /* 600mA */
246 }
247};
248
249/* Only slots having eMMC card will require VCCQ voltage */
250static struct msm_mmc_reg_data mmc_vccq_reg_data[1] = {
251 /* SDCC1 : eMMC card connected */
252 [SDCC1] = {
253 .name = "sdc_vccq",
254 .set_voltage_sup = 1,
255 .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",
267 .set_voltage_sup = 1,
268 .high_vol_level = 2950000,
269 .low_vol_level = 1850000,
270 .always_on = 1,
271 .lpm_sup = 1,
272 /* Max. Active current required is 16 mA */
273 .hpm_uA = 16000,
274 /*
275 * Sleep current required is ~300 uA. But min. vote can be
276 * in terms of mA (min. 1 mA). So let's vote for 2 mA
277 * during sleep.
278 */
279 .lpm_uA = 2000,
280 }
281};
282
283static struct msm_mmc_slot_reg_data mmc_slot_vreg_data[MAX_SDCC_CONTROLLER] = {
284 /* SDCC1 : eMMC card connected */
285 [SDCC1] = {
286 .vdd_data = &mmc_vdd_reg_data[SDCC1],
287 .vccq_data = &mmc_vccq_reg_data[SDCC1],
288 },
289 /* SDCC3 : External card slot connected */
290 [SDCC3] = {
291 .vdd_data = &mmc_vdd_reg_data[SDCC3],
292 .vddp_data = &mmc_vddp_reg_data[SDCC3],
293 }
294};
295
296/* SDC1 pad data */
297static struct msm_mmc_pad_drv sdc1_pad_drv_on_cfg[] = {
298 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_16MA},
299 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_10MA},
300 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_10MA}
301};
302
303static struct msm_mmc_pad_drv sdc1_pad_drv_off_cfg[] = {
304 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_2MA},
305 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_2MA},
306 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_2MA}
307};
308
309static struct msm_mmc_pad_pull sdc1_pad_pull_on_cfg[] = {
Sahitya Tummalaf5764e82011-10-03 13:46:00 +0530310 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530311 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_UP},
312 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_UP}
313};
314
315static struct msm_mmc_pad_pull sdc1_pad_pull_off_cfg[] = {
Sahitya Tummalaf5764e82011-10-03 13:46:00 +0530316 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530317 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_DOWN},
318 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_DOWN}
319};
320
321/* SDC3 pad data */
322static struct msm_mmc_pad_drv sdc3_pad_drv_on_cfg[] = {
323 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
324 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
325 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
326};
327
328static struct msm_mmc_pad_drv sdc3_pad_drv_off_cfg[] = {
329 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
330 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
331 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
332};
333
334static struct msm_mmc_pad_pull sdc3_pad_pull_on_cfg[] = {
Sahitya Tummalaf5764e82011-10-03 13:46:00 +0530335 {TLMM_PULL_SDC3_CLK, GPIO_CFG_NO_PULL},
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530336 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
337 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
338};
339
340static struct msm_mmc_pad_pull sdc3_pad_pull_off_cfg[] = {
Sahitya Tummalaf5764e82011-10-03 13:46:00 +0530341 {TLMM_PULL_SDC3_CLK, GPIO_CFG_NO_PULL},
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530342 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
343 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
344};
345
346static struct msm_mmc_pad_pull_data mmc_pad_pull_data[MAX_SDCC_CONTROLLER] = {
347 [SDCC1] = {
348 .on = sdc1_pad_pull_on_cfg,
349 .off = sdc1_pad_pull_off_cfg,
350 .size = ARRAY_SIZE(sdc1_pad_pull_on_cfg)
351 },
352 [SDCC3] = {
353 .on = sdc3_pad_pull_on_cfg,
354 .off = sdc3_pad_pull_off_cfg,
355 .size = ARRAY_SIZE(sdc3_pad_pull_on_cfg)
356 },
357};
358
359static struct msm_mmc_pad_drv_data mmc_pad_drv_data[MAX_SDCC_CONTROLLER] = {
360 [SDCC1] = {
361 .on = sdc1_pad_drv_on_cfg,
362 .off = sdc1_pad_drv_off_cfg,
363 .size = ARRAY_SIZE(sdc1_pad_drv_on_cfg)
364 },
365 [SDCC3] = {
366 .on = sdc3_pad_drv_on_cfg,
367 .off = sdc3_pad_drv_off_cfg,
368 .size = ARRAY_SIZE(sdc3_pad_drv_on_cfg)
369 },
370};
371
372static struct msm_mmc_pad_data mmc_pad_data[MAX_SDCC_CONTROLLER] = {
373 [SDCC1] = {
374 .pull = &mmc_pad_pull_data[SDCC1],
375 .drv = &mmc_pad_drv_data[SDCC1]
376 },
377 [SDCC3] = {
378 .pull = &mmc_pad_pull_data[SDCC3],
379 .drv = &mmc_pad_drv_data[SDCC3]
380 },
381};
382
383static struct msm_mmc_pin_data mmc_slot_pin_data[MAX_SDCC_CONTROLLER] = {
384 [SDCC1] = {
385 .pad_data = &mmc_pad_data[SDCC1],
386 },
387 [SDCC3] = {
388 .pad_data = &mmc_pad_data[SDCC3],
389 },
390};
391
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530392#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
393static unsigned int sdc1_sup_clk_rates[] = {
394 400000, 24000000, 48000000, 96000000
395};
396
397static struct mmc_platform_data sdc1_data = {
398 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
Sahitya Tummala01431972011-10-03 13:52:26 +0530399#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
400 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
401#else
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530402 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Sahitya Tummala01431972011-10-03 13:52:26 +0530403#endif
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530404 .sup_clk_table = sdc1_sup_clk_rates,
405 .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates),
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530406 .pin_data = &mmc_slot_pin_data[SDCC1],
407 .vreg_data = &mmc_slot_vreg_data[SDCC1],
408 .sdcc_v4_sup = true,
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530409};
410static struct mmc_platform_data *apq8064_sdc1_pdata = &sdc1_data;
411#else
412static struct mmc_platform_data *apq8064_sdc1_pdata;
413#endif
414
415#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
416static unsigned int sdc3_sup_clk_rates[] = {
417 400000, 24000000, 48000000, 96000000
418};
419
420static struct mmc_platform_data sdc3_data = {
421 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
422 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
423 .sup_clk_table = sdc3_sup_clk_rates,
424 .sup_clk_cnt = ARRAY_SIZE(sdc3_sup_clk_rates),
Sahitya Tummalab4d883f2011-08-23 10:44:51 +0530425 .pin_data = &mmc_slot_pin_data[SDCC3],
426 .vreg_data = &mmc_slot_vreg_data[SDCC3],
427 .sdcc_v4_sup = true,
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530428};
429static struct mmc_platform_data *apq8064_sdc3_pdata = &sdc3_data;
430#else
431static struct mmc_platform_data *apq8064_sdc3_pdata;
432#endif
433
434static void __init apq8064_init_mmc(void)
435{
Amol Jadi7d4ce032011-09-09 17:07:18 -0700436 if ((machine_is_apq8064_rumi3()) || machine_is_apq8064_sim()) {
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530437 if (apq8064_sdc1_pdata) {
Sahitya Tummalad9df3272011-08-19 16:50:46 +0530438 apq8064_sdc1_pdata->disable_bam = true;
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530439 apq8064_sdc1_pdata->disable_runtime_pm = true;
Sahitya Tummala85fa0702011-09-15 09:39:37 +0530440 apq8064_sdc1_pdata->disable_cmd23 = true;
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530441 }
442 if (apq8064_sdc3_pdata) {
Sahitya Tummalad9df3272011-08-19 16:50:46 +0530443 apq8064_sdc3_pdata->disable_bam = true;
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530444 apq8064_sdc3_pdata->disable_runtime_pm = true;
Sahitya Tummala85fa0702011-09-15 09:39:37 +0530445 apq8064_sdc3_pdata->disable_cmd23 = true;
Sahitya Tummalab07e1ae2011-09-02 11:58:42 +0530446 }
Sahitya Tummalad9df3272011-08-19 16:50:46 +0530447 }
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530448 apq8064_add_sdcc(1, apq8064_sdc1_pdata);
449 apq8064_add_sdcc(3, apq8064_sdc3_pdata);
450}
451
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600452#define MSM_SHARED_RAM_PHYS 0x80000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700453static void __init apq8064_map_io(void)
454{
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600455 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700456 msm_map_apq8064_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -0700457 if (socinfo_init() < 0)
458 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700459}
460
461static void __init apq8064_init_irq(void)
462{
463 unsigned int i;
464 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
465 (void *)MSM_QGIC_CPU_BASE);
466
467 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
468 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
469
470 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
471 mb();
472
473 /*
474 * FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
475 * as they are configured as level, which does not play nice with
476 * handle_percpu_irq.
477 */
478 for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
479 if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
480 irq_set_handler(i, handle_percpu_irq);
481 }
482}
483
484static struct platform_device *common_devices[] __initdata = {
Kenneth Heitke748593a2011-07-15 15:45:11 -0600485 &apq8064_device_qup_i2c_gsbi4,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600486 &apq8064_device_qup_spi_gsbi5,
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600487 &apq8064_slim_ctrl,
Jay Chokshi9c25f072011-09-23 18:19:15 -0700488 &apq8064_device_ssbi_pmic1,
489 &apq8064_device_ssbi_pmic2,
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600490 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -0700491 &apq8064_device_otg,
492 &apq8064_device_gadget_peripheral,
493 &android_usb_device,
Kevin Chan13be4e22011-10-20 11:30:32 -0700494 &android_pmem_device,
495 &android_pmem_adsp_device,
496 &android_pmem_audio_device,
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700497 &msm8064_device_watchdog,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600498};
499
Joel King4e7ad222011-08-17 15:47:38 -0700500static struct platform_device *sim_devices[] __initdata = {
501 &apq8064_device_dmov,
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700502 &apq8064_device_uart_gsbi3,
Yan He06913ce2011-08-26 16:33:46 -0700503 &msm_device_sps_apq8064,
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700504};
505
506static struct platform_device *rumi3_devices[] __initdata = {
507 &apq8064_device_uart_gsbi1,
Joel King4e7ad222011-08-17 15:47:38 -0700508};
509
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600510static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
511 .max_clock_speed = 26000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700512};
513
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700514#define KS8851_IRQ_GPIO 43
515
516static struct spi_board_info spi_board_info[] __initdata = {
517 {
518 .modalias = "ks8851",
519 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
520 .max_speed_hz = 19200000,
521 .bus_num = 0,
522 .chip_select = 2,
523 .mode = SPI_MODE_0,
524 },
525};
526
527#ifdef CONFIG_KS8851
528static struct gpiomux_setting gpio_eth_config = {
529 .pull = GPIOMUX_PULL_NONE,
530 .drv = GPIOMUX_DRV_8MA,
531 .func = GPIOMUX_FUNC_GPIO,
532};
533
534/* The SPI configurations apply to GSBI 5*/
535static struct gpiomux_setting gpio_spi_config = {
536 .func = GPIOMUX_FUNC_2,
537 .drv = GPIOMUX_DRV_8MA,
538 .pull = GPIOMUX_PULL_NONE,
539};
540
541/* The SPI configurations apply to GSBI 5 chip select 2*/
542static struct gpiomux_setting gpio_spi_cs2_config = {
543 .func = GPIOMUX_FUNC_3,
544 .drv = GPIOMUX_DRV_8MA,
545 .pull = GPIOMUX_PULL_NONE,
546};
547#endif
548
549struct msm_gpiomux_config apq8064_ethernet_configs[NR_GPIO_IRQS] = {
550#ifdef CONFIG_KS8851
551 {
552 .gpio = KS8851_IRQ_GPIO,
553 .settings = {
554 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
555 [GPIOMUX_ACTIVE] = &gpio_eth_config,
556 }
557 },
558#endif
559};
560
561static struct msm_gpiomux_config apq8064_gsbi_configs[] __initdata = {
562#ifdef CONFIG_KS8851
563 {
564 .gpio = 51, /* GSBI5 QUP SPI_DATA_MOSI */
565 .settings = {
566 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
567 },
568 },
569 {
570 .gpio = 52, /* GSBI5 QUP SPI_DATA_MISO */
571 .settings = {
572 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
573 },
574 },
575 {
576 .gpio = 31, /* GSBI5 QUP SPI_CS2_N */
577 .settings = {
578 [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config,
579 },
580 },
581 {
582 .gpio = 54, /* GSBI5 QUP SPI_CLK */
583 .settings = {
584 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
585 },
586 },
587#endif
588};
589
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700590static struct pm8xxx_mpp_platform_data
591apq8064_pm8921_mpp_pdata __devinitdata = {
592 .mpp_base = PM8921_MPP_PM_TO_SYS(1),
593};
594
595static struct pm8xxx_gpio_platform_data
596apq8064_pm8921_gpio_pdata __devinitdata = {
597 .gpio_base = PM8921_GPIO_PM_TO_SYS(1),
598};
599
600static struct pm8xxx_irq_platform_data
601apq8064_pm8921_irq_pdata __devinitdata = {
602 .irq_base = PM8921_IRQ_BASE,
Jay Chokshi44873f72011-08-30 17:24:26 -0700603 .devirq = PM8921_USR_IRQ_N,
604 .irq_trigger_flag = IRQF_TRIGGER_HIGH,
Jay Chokshi9e926e72011-09-23 19:19:58 -0700605 .dev_id = 0,
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700606};
607
608static struct pm8921_platform_data
609apq8064_pm8921_platform_data __devinitdata = {
Jay Chokshiea67c622011-07-29 17:12:26 -0700610 .regulator_pdatas = msm8064_pm8921_regulator_pdata,
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700611 .irq_pdata = &apq8064_pm8921_irq_pdata,
612 .gpio_pdata = &apq8064_pm8921_gpio_pdata,
613 .mpp_pdata = &apq8064_pm8921_mpp_pdata,
Jay Chokshiea67c622011-07-29 17:12:26 -0700614};
615
Jay Chokshi44873f72011-08-30 17:24:26 -0700616static struct pm8xxx_irq_platform_data
617apq8064_pm8821_irq_pdata __devinitdata = {
618 .irq_base = PM8821_IRQ_BASE,
619 .devirq = PM8821_USR_IRQ_N,
620 .irq_trigger_flag = IRQF_TRIGGER_HIGH,
Jay Chokshi9e926e72011-09-23 19:19:58 -0700621 .dev_id = 1,
Jay Chokshi44873f72011-08-30 17:24:26 -0700622};
623
624static struct pm8xxx_mpp_platform_data
625apq8064_pm8821_mpp_pdata __devinitdata = {
626 .mpp_base = PM8821_MPP_PM_TO_SYS(1),
627};
628
629static struct pm8821_platform_data
630apq8064_pm8821_platform_data __devinitdata = {
631 .irq_pdata = &apq8064_pm8821_irq_pdata,
632 .mpp_pdata = &apq8064_pm8821_mpp_pdata,
633};
634
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700635static struct msm_ssbi_platform_data apq8064_ssbi_pm8921_pdata __devinitdata = {
636 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
637 .slave = {
Jay Chokshiea67c622011-07-29 17:12:26 -0700638 .name = "pm8921-core",
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700639 .platform_data = &apq8064_pm8921_platform_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700640 },
641};
642
643static struct msm_ssbi_platform_data apq8064_ssbi_pm8821_pdata __devinitdata = {
644 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
645 .slave = {
Jay Chokshi44873f72011-08-30 17:24:26 -0700646 .name = "pm8821-core",
647 .platform_data = &apq8064_pm8821_platform_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700648 },
649};
650
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600651static struct slim_boardinfo apq8064_slim_devices[] = {
652 /* Add slimbus slaves as needed */
653};
654
Kenneth Heitke748593a2011-07-15 15:45:11 -0600655static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
656 .clk_freq = 100000,
657 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600658};
659
660static void __init apq8064_i2c_init(void)
661{
662 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
663 &apq8064_i2c_qup_gsbi4_pdata;
664}
665
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700666static int __init gpiomux_init(void)
667{
668 int rc;
669
670 rc = msm_gpiomux_init(NR_GPIO_IRQS);
671 if (rc) {
672 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
673 return rc;
674 }
675 msm_gpiomux_install(apq8064_ethernet_configs,
676 ARRAY_SIZE(apq8064_ethernet_configs));
677
678 msm_gpiomux_install(apq8064_gsbi_configs,
679 ARRAY_SIZE(apq8064_gsbi_configs));
680 return 0;
681}
682
683#ifdef CONFIG_KS8851
684static int ethernet_init(void)
685{
686 int ret;
687 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
688 if (ret) {
689 pr_err("ks8851 gpio_request failed: %d\n", ret);
690 goto fail;
691 }
692
693 return 0;
694fail:
695 return ret;
696}
697#else
698static int ethernet_init(void)
699{
700 return 0;
701}
702#endif
703
Tianyi Gou41515e22011-09-01 19:37:43 -0700704static void __init apq8064_clock_init(void)
705{
706 if (machine_is_apq8064_sim())
707 msm_clock_init(&apq8064_clock_init_data);
708 else
709 msm_clock_init(&apq8064_dummy_clock_init_data);
710}
711
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700712static void __init apq8064_common_init(void)
713{
714 if (socinfo_init() < 0)
715 pr_err("socinfo_init() failed!\n");
Tianyi Gou41515e22011-09-01 19:37:43 -0700716 apq8064_clock_init();
Joel King4ebccc62011-07-22 09:43:22 -0700717 gpiomux_init();
Kenneth Heitke748593a2011-07-15 15:45:11 -0600718 apq8064_i2c_init();
Kenneth Heitke36920d32011-07-20 16:44:30 -0600719
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600720 apq8064_device_qup_spi_gsbi5.dev.platform_data =
721 &apq8064_qup_spi_gsbi5_pdata;
Kenneth Heitke36920d32011-07-20 16:44:30 -0600722 apq8064_device_ssbi_pmic1.dev.platform_data =
Jay Chokshiea67c622011-07-29 17:12:26 -0700723 &apq8064_ssbi_pm8921_pdata;
Kenneth Heitke36920d32011-07-20 16:44:30 -0600724 apq8064_device_ssbi_pmic2.dev.platform_data =
725 &apq8064_ssbi_pm8821_pdata;
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -0700726 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
727 apq8064_device_gadget_peripheral.dev.parent = &apq8064_device_otg.dev;
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700728 apq8064_pm8921_platform_data.num_regulators =
Jay Chokshiea67c622011-07-29 17:12:26 -0700729 msm8064_pm8921_regulator_pdata_len;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700730 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530731 apq8064_init_mmc();
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600732 slim_register_board_info(apq8064_slim_devices,
733 ARRAY_SIZE(apq8064_slim_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700734}
735
736static void __init apq8064_sim_init(void)
737{
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700738 struct msm_watchdog_pdata *wdog_pdata = (struct msm_watchdog_pdata *)
739 &msm8064_device_watchdog.dev.platform_data;
740
741 wdog_pdata->bark_time = 15000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700742 apq8064_common_init();
Joel King4e7ad222011-08-17 15:47:38 -0700743 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
744}
745
746static void __init apq8064_rumi3_init(void)
747{
Jay Chokshi9c25f072011-09-23 18:19:15 -0700748 apq8064_pm8921_irq_pdata.devirq = 0;
749 apq8064_pm8821_irq_pdata.devirq = 0;
Joel King4e7ad222011-08-17 15:47:38 -0700750 apq8064_common_init();
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700751 ethernet_init();
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700752 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700753 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700754}
755
756MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR")
757 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700758 .reserve = apq8064_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700759 .init_irq = apq8064_init_irq,
760 .timer = &msm_timer,
761 .init_machine = apq8064_sim_init,
762MACHINE_END
763
Joel King4e7ad222011-08-17 15:47:38 -0700764MACHINE_START(APQ8064_RUMI3, "QCT APQ8064 RUMI3")
765 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700766 .reserve = apq8064_reserve,
Joel King4e7ad222011-08-17 15:47:38 -0700767 .init_irq = apq8064_init_irq,
768 .timer = &msm_timer,
769 .init_machine = apq8064_rumi3_init,
770MACHINE_END
771