blob: 5ae388f93ebc70f6481b6496634217d7529b9026 [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
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800484static struct platform_device msm8064_device_saw_regulator_core0 = {
485 .name = "saw-regulator",
486 .id = 0,
487 .dev = {
488 .platform_data = &msm8064_saw_regulator_pdata_8921_s5,
489 },
490};
491
492static struct platform_device msm8064_device_saw_regulator_core1 = {
493 .name = "saw-regulator",
494 .id = 1,
495 .dev = {
496 .platform_data = &msm8064_saw_regulator_pdata_8921_s6,
497 },
498};
499
500static struct platform_device msm8064_device_saw_regulator_core2 = {
501 .name = "saw-regulator",
502 .id = 2,
503 .dev = {
504 .platform_data = &msm8064_saw_regulator_pdata_8821_s0,
505 },
506};
507
508static struct platform_device msm8064_device_saw_regulator_core3 = {
509 .name = "saw-regulator",
510 .id = 3,
511 .dev = {
512 .platform_data = &msm8064_saw_regulator_pdata_8821_s1,
513 },
514};
515
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700516static struct platform_device *common_devices[] __initdata = {
Jin Hong01f2dbb2011-11-03 22:13:51 -0700517 &apq8064_device_dmov,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600518 &apq8064_device_qup_i2c_gsbi4,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600519 &apq8064_device_qup_spi_gsbi5,
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600520 &apq8064_slim_ctrl,
Jay Chokshi9c25f072011-09-23 18:19:15 -0700521 &apq8064_device_ssbi_pmic1,
522 &apq8064_device_ssbi_pmic2,
Jeff Hugo0c0f5e92011-09-28 13:55:45 -0600523 &msm_device_smd_apq8064,
Hemant Kumar4933b072011-10-17 23:43:11 -0700524 &apq8064_device_otg,
525 &apq8064_device_gadget_peripheral,
526 &android_usb_device,
Kevin Chan13be4e22011-10-20 11:30:32 -0700527 &android_pmem_device,
528 &android_pmem_adsp_device,
529 &android_pmem_audio_device,
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700530 &msm8064_device_watchdog,
Jay Chokshi7805b5a2011-11-07 15:55:30 -0800531 &msm8064_device_saw_regulator_core0,
532 &msm8064_device_saw_regulator_core1,
533 &msm8064_device_saw_regulator_core2,
534 &msm8064_device_saw_regulator_core3,
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600535};
536
Joel King4e7ad222011-08-17 15:47:38 -0700537static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700538 &apq8064_device_uart_gsbi3,
Yan He06913ce2011-08-26 16:33:46 -0700539 &msm_device_sps_apq8064,
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700540};
541
542static struct platform_device *rumi3_devices[] __initdata = {
543 &apq8064_device_uart_gsbi1,
Joel King4e7ad222011-08-17 15:47:38 -0700544};
545
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600546static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = {
Harini Jayaraman60ee14c2011-11-09 18:53:27 -0700547 .max_clock_speed = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700548};
549
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700550#define KS8851_IRQ_GPIO 43
551
552static struct spi_board_info spi_board_info[] __initdata = {
553 {
554 .modalias = "ks8851",
555 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
556 .max_speed_hz = 19200000,
557 .bus_num = 0,
558 .chip_select = 2,
559 .mode = SPI_MODE_0,
560 },
561};
562
563#ifdef CONFIG_KS8851
564static struct gpiomux_setting gpio_eth_config = {
565 .pull = GPIOMUX_PULL_NONE,
566 .drv = GPIOMUX_DRV_8MA,
567 .func = GPIOMUX_FUNC_GPIO,
568};
569
570/* The SPI configurations apply to GSBI 5*/
571static struct gpiomux_setting gpio_spi_config = {
572 .func = GPIOMUX_FUNC_2,
573 .drv = GPIOMUX_DRV_8MA,
574 .pull = GPIOMUX_PULL_NONE,
575};
576
577/* The SPI configurations apply to GSBI 5 chip select 2*/
578static struct gpiomux_setting gpio_spi_cs2_config = {
579 .func = GPIOMUX_FUNC_3,
580 .drv = GPIOMUX_DRV_8MA,
581 .pull = GPIOMUX_PULL_NONE,
582};
583#endif
584
585struct msm_gpiomux_config apq8064_ethernet_configs[NR_GPIO_IRQS] = {
586#ifdef CONFIG_KS8851
587 {
588 .gpio = KS8851_IRQ_GPIO,
589 .settings = {
590 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
591 [GPIOMUX_ACTIVE] = &gpio_eth_config,
592 }
593 },
594#endif
595};
596
597static struct msm_gpiomux_config apq8064_gsbi_configs[] __initdata = {
598#ifdef CONFIG_KS8851
599 {
600 .gpio = 51, /* GSBI5 QUP SPI_DATA_MOSI */
601 .settings = {
602 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
603 },
604 },
605 {
606 .gpio = 52, /* GSBI5 QUP SPI_DATA_MISO */
607 .settings = {
608 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
609 },
610 },
611 {
612 .gpio = 31, /* GSBI5 QUP SPI_CS2_N */
613 .settings = {
614 [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config,
615 },
616 },
617 {
618 .gpio = 54, /* GSBI5 QUP SPI_CLK */
619 .settings = {
620 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
621 },
622 },
623#endif
624};
625
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700626static struct pm8xxx_mpp_platform_data
627apq8064_pm8921_mpp_pdata __devinitdata = {
628 .mpp_base = PM8921_MPP_PM_TO_SYS(1),
629};
630
631static struct pm8xxx_gpio_platform_data
632apq8064_pm8921_gpio_pdata __devinitdata = {
633 .gpio_base = PM8921_GPIO_PM_TO_SYS(1),
634};
635
636static struct pm8xxx_irq_platform_data
637apq8064_pm8921_irq_pdata __devinitdata = {
638 .irq_base = PM8921_IRQ_BASE,
Jay Chokshi44873f72011-08-30 17:24:26 -0700639 .devirq = PM8921_USR_IRQ_N,
640 .irq_trigger_flag = IRQF_TRIGGER_HIGH,
Jay Chokshi9e926e72011-09-23 19:19:58 -0700641 .dev_id = 0,
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700642};
643
644static struct pm8921_platform_data
645apq8064_pm8921_platform_data __devinitdata = {
Jay Chokshiea67c622011-07-29 17:12:26 -0700646 .regulator_pdatas = msm8064_pm8921_regulator_pdata,
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700647 .irq_pdata = &apq8064_pm8921_irq_pdata,
648 .gpio_pdata = &apq8064_pm8921_gpio_pdata,
649 .mpp_pdata = &apq8064_pm8921_mpp_pdata,
Jay Chokshiea67c622011-07-29 17:12:26 -0700650};
651
Jay Chokshi44873f72011-08-30 17:24:26 -0700652static struct pm8xxx_irq_platform_data
653apq8064_pm8821_irq_pdata __devinitdata = {
654 .irq_base = PM8821_IRQ_BASE,
655 .devirq = PM8821_USR_IRQ_N,
656 .irq_trigger_flag = IRQF_TRIGGER_HIGH,
Jay Chokshi9e926e72011-09-23 19:19:58 -0700657 .dev_id = 1,
Jay Chokshi44873f72011-08-30 17:24:26 -0700658};
659
660static struct pm8xxx_mpp_platform_data
661apq8064_pm8821_mpp_pdata __devinitdata = {
662 .mpp_base = PM8821_MPP_PM_TO_SYS(1),
663};
664
665static struct pm8821_platform_data
666apq8064_pm8821_platform_data __devinitdata = {
667 .irq_pdata = &apq8064_pm8821_irq_pdata,
668 .mpp_pdata = &apq8064_pm8821_mpp_pdata,
669};
670
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700671static struct msm_ssbi_platform_data apq8064_ssbi_pm8921_pdata __devinitdata = {
672 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
673 .slave = {
Jay Chokshiea67c622011-07-29 17:12:26 -0700674 .name = "pm8921-core",
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700675 .platform_data = &apq8064_pm8921_platform_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700676 },
677};
678
679static struct msm_ssbi_platform_data apq8064_ssbi_pm8821_pdata __devinitdata = {
680 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
681 .slave = {
Jay Chokshi44873f72011-08-30 17:24:26 -0700682 .name = "pm8821-core",
683 .platform_data = &apq8064_pm8821_platform_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700684 },
685};
686
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600687static struct slim_boardinfo apq8064_slim_devices[] = {
688 /* Add slimbus slaves as needed */
689};
690
Kenneth Heitke748593a2011-07-15 15:45:11 -0600691static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = {
692 .clk_freq = 100000,
693 .src_clk_rate = 24000000,
Kenneth Heitke748593a2011-07-15 15:45:11 -0600694};
695
696static void __init apq8064_i2c_init(void)
697{
698 apq8064_device_qup_i2c_gsbi4.dev.platform_data =
699 &apq8064_i2c_qup_gsbi4_pdata;
700}
701
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700702static int __init gpiomux_init(void)
703{
704 int rc;
705
706 rc = msm_gpiomux_init(NR_GPIO_IRQS);
707 if (rc) {
708 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
709 return rc;
710 }
711 msm_gpiomux_install(apq8064_ethernet_configs,
712 ARRAY_SIZE(apq8064_ethernet_configs));
713
714 msm_gpiomux_install(apq8064_gsbi_configs,
715 ARRAY_SIZE(apq8064_gsbi_configs));
716 return 0;
717}
718
719#ifdef CONFIG_KS8851
720static int ethernet_init(void)
721{
722 int ret;
723 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
724 if (ret) {
725 pr_err("ks8851 gpio_request failed: %d\n", ret);
726 goto fail;
727 }
728
729 return 0;
730fail:
731 return ret;
732}
733#else
734static int ethernet_init(void)
735{
736 return 0;
737}
738#endif
739
Tianyi Gou41515e22011-09-01 19:37:43 -0700740static void __init apq8064_clock_init(void)
741{
742 if (machine_is_apq8064_sim())
743 msm_clock_init(&apq8064_clock_init_data);
744 else
745 msm_clock_init(&apq8064_dummy_clock_init_data);
746}
747
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700748static void __init apq8064_common_init(void)
749{
750 if (socinfo_init() < 0)
751 pr_err("socinfo_init() failed!\n");
Tianyi Gou41515e22011-09-01 19:37:43 -0700752 apq8064_clock_init();
Joel King4ebccc62011-07-22 09:43:22 -0700753 gpiomux_init();
Kenneth Heitke748593a2011-07-15 15:45:11 -0600754 apq8064_i2c_init();
Kenneth Heitke36920d32011-07-20 16:44:30 -0600755
Harini Jayaramanc4c58692011-07-19 14:50:10 -0600756 apq8064_device_qup_spi_gsbi5.dev.platform_data =
757 &apq8064_qup_spi_gsbi5_pdata;
Kenneth Heitke36920d32011-07-20 16:44:30 -0600758 apq8064_device_ssbi_pmic1.dev.platform_data =
Jay Chokshiea67c622011-07-29 17:12:26 -0700759 &apq8064_ssbi_pm8921_pdata;
Kenneth Heitke36920d32011-07-20 16:44:30 -0600760 apq8064_device_ssbi_pmic2.dev.platform_data =
761 &apq8064_ssbi_pm8821_pdata;
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -0700762 apq8064_device_otg.dev.platform_data = &msm_otg_pdata;
763 apq8064_device_gadget_peripheral.dev.parent = &apq8064_device_otg.dev;
Jay Chokshibc3d98d2011-08-10 17:14:23 -0700764 apq8064_pm8921_platform_data.num_regulators =
Jay Chokshiea67c622011-07-29 17:12:26 -0700765 msm8064_pm8921_regulator_pdata_len;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700766 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Sahitya Tummala3586ed92011-08-03 09:13:23 +0530767 apq8064_init_mmc();
Sagar Dharia8bdcdaf2011-09-16 16:01:15 -0600768 slim_register_board_info(apq8064_slim_devices,
769 ARRAY_SIZE(apq8064_slim_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700770}
771
772static void __init apq8064_sim_init(void)
773{
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700774 struct msm_watchdog_pdata *wdog_pdata = (struct msm_watchdog_pdata *)
775 &msm8064_device_watchdog.dev.platform_data;
776
777 wdog_pdata->bark_time = 15000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700778 apq8064_common_init();
Joel King4e7ad222011-08-17 15:47:38 -0700779 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
780}
781
782static void __init apq8064_rumi3_init(void)
783{
Jay Chokshi9c25f072011-09-23 18:19:15 -0700784 apq8064_pm8921_irq_pdata.devirq = 0;
785 apq8064_pm8821_irq_pdata.devirq = 0;
Joel King4e7ad222011-08-17 15:47:38 -0700786 apq8064_common_init();
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700787 ethernet_init();
Stepan Moskovchenko2701a442011-08-19 13:47:22 -0700788 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Stepan Moskovchenkoeed82a52011-09-02 13:19:23 -0700789 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700790}
791
792MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR")
793 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700794 .reserve = apq8064_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700795 .init_irq = apq8064_init_irq,
796 .timer = &msm_timer,
797 .init_machine = apq8064_sim_init,
798MACHINE_END
799
Joel King4e7ad222011-08-17 15:47:38 -0700800MACHINE_START(APQ8064_RUMI3, "QCT APQ8064 RUMI3")
801 .map_io = apq8064_map_io,
Kevin Chan13be4e22011-10-20 11:30:32 -0700802 .reserve = apq8064_reserve,
Joel King4e7ad222011-08-17 15:47:38 -0700803 .init_irq = apq8064_init_irq,
804 .timer = &msm_timer,
805 .init_machine = apq8064_rumi3_init,
806MACHINE_END
807