blob: 8182fc4252259d60b55225f1e42a76040c46d215 [file] [log] [blame]
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +05301/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302 *
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/init.h>
15#include <linux/gpio_event.h>
Pankaj Kumar6f841742011-10-10 15:52:14 +053016#include <linux/usb/android.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053017#include <linux/platform_device.h>
18#include <linux/io.h>
19#include <linux/gpio.h>
20#include <linux/mtd/nand.h>
21#include <linux/mtd/partitions.h>
22#include <linux/i2c.h>
23#include <linux/android_pmem.h>
24#include <linux/bootmem.h>
25#include <linux/mfd/marimba.h>
26#include <linux/power_supply.h>
Trilok Sonib9410792012-04-07 15:37:13 +053027#include <linux/input/rmi_platformdata.h>
28#include <linux/input/rmi_i2c.h>
29#include <linux/i2c/atmel_mxt_ts.h>
Pankaj Kumar3cec0582011-11-18 11:13:29 +053030#include <linux/regulator/consumer.h>
Chintan Pandyaf4ad4002012-02-28 19:49:03 +053031#include <linux/memblock.h>
Mohan Pallaka5afe9852012-01-12 23:12:06 +053032#include <linux/input/ft5x06_ts.h>
Siddartha Mohanadossbc2103f2012-03-20 11:41:48 -070033#include <linux/msm_adc.h>
Taniya Das720c5c32012-05-18 14:08:14 +053034#include <linux/fmem.h>
Steve Muckle75c34ca2012-06-12 14:27:40 -070035#include <linux/regulator/msm-gpio-regulator.h>
Chintan Pandya43d0a342012-06-08 19:45:56 +053036#include <linux/ion.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053037#include <asm/mach/mmc.h>
38#include <asm/mach-types.h>
39#include <asm/mach/arch.h>
Chintan Pandyaf4ad4002012-02-28 19:49:03 +053040#include <asm/hardware/gic.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053041#include <mach/board.h>
42#include <mach/msm_iomap.h>
43#include <mach/msm_hsusb.h>
44#include <mach/rpc_hsusb.h>
45#include <mach/rpc_pmapp.h>
46#include <mach/usbdiag.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053047#include <mach/msm_memtypes.h>
48#include <mach/msm_serial_hs.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053049#include <mach/pmic.h>
50#include <mach/socinfo.h>
51#include <mach/vreg.h>
52#include <mach/rpc_pmapp.h>
53#include <mach/msm_battery.h>
54#include <mach/rpc_server_handset.h>
55#include <mach/socinfo.h>
Pankaj Kumar27c02642011-09-22 15:55:55 +053056#include "board-msm7x27a-regulator.h"
Taniya Dasc98bfbc2011-08-23 09:58:55 +053057#include "devices.h"
58#include "devices-msm7x2xa.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080059#include "pm.h"
Taniya Dasc98bfbc2011-08-23 09:58:55 +053060#include "timer.h"
Murali Nalajalaa1827842011-11-13 14:12:39 +053061#include "pm-boot.h"
Pankaj Kumar3cec0582011-11-18 11:13:29 +053062#include "board-msm7x27a-regulator.h"
Chintan Pandyacf467fc2011-12-01 17:11:11 +053063#include "board-msm7627a.h"
Taniya Dasc98bfbc2011-08-23 09:58:55 +053064
Trilok Sonib9410792012-04-07 15:37:13 +053065#define PMEM_KERNEL_EBI1_SIZE 0x3A000
Sidipotu Ashok4f1ddc92012-04-11 13:51:34 +053066#define MSM_PMEM_AUDIO_SIZE 0x1F4000
Trilok Sonib9410792012-04-07 15:37:13 +053067#define BAHAMA_SLAVE_ID_FM_REG 0x02
68#define FM_GPIO 83
69#define BT_PCM_BCLK_MODE 0x88
70#define BT_PCM_DIN_MODE 0x89
71#define BT_PCM_DOUT_MODE 0x8A
72#define BT_PCM_SYNC_MODE 0x8B
73#define FM_I2S_SD_MODE 0x8E
74#define FM_I2S_WS_MODE 0x8F
75#define FM_I2S_SCK_MODE 0x90
76#define I2C_PIN_CTL 0x15
77#define I2C_NORMAL 0x40
78
Taniya Dasc98bfbc2011-08-23 09:58:55 +053079static struct platform_device msm_wlan_ar6000_pm_device = {
80 .name = "wlan_ar6000_pm_dev",
81 .id = -1,
82};
83
Taniya Dasc98bfbc2011-08-23 09:58:55 +053084static struct msm_gpio qup_i2c_gpios_io[] = {
85 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
86 "qup_scl" },
87 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
88 "qup_sda" },
89 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
90 "qup_scl" },
91 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
92 "qup_sda" },
93};
94
95static struct msm_gpio qup_i2c_gpios_hw[] = {
96 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
97 "qup_scl" },
98 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
99 "qup_sda" },
100 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
101 "qup_scl" },
102 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
103 "qup_sda" },
104};
105
106static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
107{
108 int rc;
109
110 if (adap_id < 0 || adap_id > 1)
111 return;
112
113 /* Each adapter gets 2 lines from the table */
114 if (config_type)
115 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
116 else
117 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
118 if (rc < 0)
119 pr_err("QUP GPIO request/enable failed: %d\n", rc);
120}
121
122static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
123 .clk_freq = 100000,
124 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
125};
126
127static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
128 .clk_freq = 100000,
129 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
130};
131
Trilok Sonib9410792012-04-07 15:37:13 +0530132#ifdef CONFIG_ARCH_MSM7X27A
Sravan Kumar D.V.Nd0b59d62012-04-17 15:08:14 +0530133#define MSM_PMEM_MDP_SIZE 0x2300000
Rajeshwar Kurapaty20d7ad12012-06-22 16:11:06 +0530134#define MSM_PMEM_ADSP_SIZE 0x1200000
Chintan Pandya43d0a342012-06-08 19:45:56 +0530135
136#define MSM_ION_AUDIO_SIZE (MSM_PMEM_AUDIO_SIZE + PMEM_KERNEL_EBI1_SIZE)
137#define MSM_ION_CAMERA_SIZE MSM_PMEM_ADSP_SIZE
138#define MSM_ION_SF_SIZE MSM_PMEM_MDP_SIZE
139#define MSM_ION_HEAP_NUM 4
140#ifdef CONFIG_ION_MSM
141static struct platform_device ion_dev;
142#endif
Trilok Sonib9410792012-04-07 15:37:13 +0530143#endif
144
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530145static struct android_usb_platform_data android_usb_pdata = {
Pankaj Kumar6f841742011-10-10 15:52:14 +0530146 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
Rajkumar Raghupathyc9cb2052012-04-26 13:14:10 +0530147 .cdrom = 1,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530148};
149
150static struct platform_device android_usb_device = {
151 .name = "android_usb",
152 .id = -1,
153 .dev = {
154 .platform_data = &android_usb_pdata,
155 },
156};
157
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530158#ifdef CONFIG_USB_EHCI_MSM_72K
159static void msm_hsusb_vbus_power(unsigned phy_info, int on)
160{
161 int rc = 0;
162 unsigned gpio;
163
Chintan Pandya40762702011-12-06 13:47:06 +0530164 gpio = QRD_GPIO_HOST_VBUS_EN;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530165
166 rc = gpio_request(gpio, "i2c_host_vbus_en");
167 if (rc < 0) {
168 pr_err("failed to request %d GPIO\n", gpio);
169 return;
170 }
171 gpio_direction_output(gpio, !!on);
172 gpio_set_value_cansleep(gpio, !!on);
173 gpio_free(gpio);
174}
175
176static struct msm_usb_host_platform_data msm_usb_host_pdata = {
177 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
178};
179
180static void __init msm7627a_init_host(void)
181{
182 msm_add_host(0, &msm_usb_host_pdata);
183}
184#endif
185
186#ifdef CONFIG_USB_MSM_OTG_72K
187static int hsusb_rpc_connect(int connect)
188{
189 if (connect)
190 return msm_hsusb_rpc_connect();
191 else
192 return msm_hsusb_rpc_close();
193}
194
Pankaj Kumar27c02642011-09-22 15:55:55 +0530195static struct regulator *reg_hsusb;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530196static int msm_hsusb_ldo_init(int init)
197{
Pankaj Kumar27c02642011-09-22 15:55:55 +0530198 int rc = 0;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530199
Pankaj Kumar27c02642011-09-22 15:55:55 +0530200 if (init) {
201 reg_hsusb = regulator_get(NULL, "usb");
202 if (IS_ERR(reg_hsusb)) {
203 rc = PTR_ERR(reg_hsusb);
204 pr_err("%s: could not get regulator: %d\n",
205 __func__, rc);
206 goto out;
207 }
208
209 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
210 if (rc) {
211 pr_err("%s: could not set voltage: %d\n",
212 __func__, rc);
213 goto reg_free;
214 }
215
216 return 0;
217 }
218 /* else fall through */
219reg_free:
220 regulator_put(reg_hsusb);
221out:
222 reg_hsusb = NULL;
223 return rc;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530224}
225
226static int msm_hsusb_ldo_enable(int enable)
227{
228 static int ldo_status;
229
Pankaj Kumar27c02642011-09-22 15:55:55 +0530230 if (IS_ERR_OR_NULL(reg_hsusb))
231 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530232
233 if (ldo_status == enable)
234 return 0;
235
236 ldo_status = enable;
237
Pankaj Kumar27c02642011-09-22 15:55:55 +0530238 return enable ?
239 regulator_enable(reg_hsusb) :
240 regulator_disable(reg_hsusb);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530241}
242
243#ifndef CONFIG_USB_EHCI_MSM_72K
244static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
245{
246 int ret = 0;
247
248 if (init)
249 ret = msm_pm_app_rpc_init(callback);
250 else
251 msm_pm_app_rpc_deinit(callback);
252
253 return ret;
254}
255#endif
256
257static struct msm_otg_platform_data msm_otg_pdata = {
258#ifndef CONFIG_USB_EHCI_MSM_72K
259 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
260#else
261 .vbus_power = msm_hsusb_vbus_power,
262#endif
263 .rpc_connect = hsusb_rpc_connect,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530264 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
265 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
266 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
267 .se1_gating = SE1_GATING_DISABLE,
268 .ldo_init = msm_hsusb_ldo_init,
269 .ldo_enable = msm_hsusb_ldo_enable,
270 .chg_init = hsusb_chg_init,
271 .chg_connected = hsusb_chg_connected,
272 .chg_vbus_draw = hsusb_chg_vbus_draw,
273};
274#endif
275
276static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
277 .is_phy_status_timer_on = 1,
278};
279
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530280#ifdef CONFIG_SERIAL_MSM_HS
281static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
282 .inject_rx_on_wakeup = 1,
283 .rx_to_inject = 0xFD,
284};
285#endif
286static struct msm_pm_platform_data msm7627a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
287 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
288 .idle_supported = 1,
289 .suspend_supported = 1,
290 .idle_enabled = 1,
291 .suspend_enabled = 1,
292 .latency = 16000,
293 .residency = 20000,
294 },
295 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
296 .idle_supported = 1,
297 .suspend_supported = 1,
298 .idle_enabled = 1,
299 .suspend_enabled = 1,
300 .latency = 12000,
301 .residency = 20000,
302 },
303 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
304 .idle_supported = 1,
305 .suspend_supported = 1,
306 .idle_enabled = 0,
307 .suspend_enabled = 1,
308 .latency = 2000,
309 .residency = 0,
310 },
311 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
312 .idle_supported = 1,
313 .suspend_supported = 1,
314 .idle_enabled = 1,
315 .suspend_enabled = 1,
316 .latency = 2,
317 .residency = 0,
318 },
319};
320
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600321static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +0530322 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
323 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600324};
325
Murali Nalajala4c996be2012-03-12 17:05:41 +0530326/* 8625 PM platform data */
327static struct msm_pm_platform_data msm8625_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
328 /* CORE0 entries */
329 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
330 .idle_supported = 1,
331 .suspend_supported = 1,
332 .idle_enabled = 0,
333 .suspend_enabled = 0,
334 .latency = 16000,
335 .residency = 20000,
336 },
337
338 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
339 .idle_supported = 1,
340 .suspend_supported = 1,
341 .idle_enabled = 0,
342 .suspend_enabled = 0,
343 .latency = 12000,
344 .residency = 20000,
345 },
346
347 /* picked latency & redisdency values from 7x30 */
348 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
349 .idle_supported = 1,
350 .suspend_supported = 1,
351 .idle_enabled = 0,
352 .suspend_enabled = 0,
353 .latency = 500,
354 .residency = 6000,
355 },
356
357 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
358 .idle_supported = 1,
359 .suspend_supported = 1,
360 .idle_enabled = 1,
361 .suspend_enabled = 1,
362 .latency = 2,
363 .residency = 10,
364 },
365
366 /* picked latency & redisdency values from 7x30 */
367 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
368 .idle_supported = 1,
369 .suspend_supported = 1,
370 .idle_enabled = 0,
371 .suspend_enabled = 0,
372 .latency = 500,
373 .residency = 6000,
374 },
375
376 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
377 .idle_supported = 1,
378 .suspend_supported = 1,
379 .idle_enabled = 1,
380 .suspend_enabled = 1,
381 .latency = 2,
382 .residency = 10,
383 },
384
385};
386
387static struct msm_pm_boot_platform_data msm_pm_8625_boot_pdata __initdata = {
388 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
389 .v_addr = MSM_CFG_CTL_BASE,
390};
391
Trilok Sonib9410792012-04-07 15:37:13 +0530392static struct android_pmem_platform_data android_pmem_adsp_pdata = {
393 .name = "pmem_adsp",
394 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
395 .cached = 1,
396 .memory_type = MEMTYPE_EBI1,
Taniya Das720c5c32012-05-18 14:08:14 +0530397 .request_region = request_fmem_c_region,
398 .release_region = release_fmem_c_region,
399 .reusable = 1,
Trilok Sonib9410792012-04-07 15:37:13 +0530400};
401
402static struct platform_device android_pmem_adsp_device = {
403 .name = "android_pmem",
404 .id = 1,
405 .dev = { .platform_data = &android_pmem_adsp_pdata },
406};
407
408static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
409static int __init pmem_mdp_size_setup(char *p)
410{
411 pmem_mdp_size = memparse(p, NULL);
412 return 0;
413}
414
415early_param("pmem_mdp_size", pmem_mdp_size_setup);
416
417static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
418static int __init pmem_adsp_size_setup(char *p)
419{
420 pmem_adsp_size = memparse(p, NULL);
421 return 0;
422}
423
424early_param("pmem_adsp_size", pmem_adsp_size_setup);
425
426#define SND(desc, num) { .name = #desc, .id = num }
427static struct snd_endpoint snd_endpoints_list[] = {
428 SND(HANDSET, 0),
429 SND(MONO_HEADSET, 2),
430 SND(HEADSET, 3),
431 SND(SPEAKER, 6),
432 SND(TTY_HEADSET, 8),
433 SND(TTY_VCO, 9),
434 SND(TTY_HCO, 10),
435 SND(BT, 12),
436 SND(IN_S_SADC_OUT_HANDSET, 16),
437 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
438 SND(FM_DIGITAL_STEREO_HEADSET, 26),
439 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
440 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
441 SND(STEREO_HEADSET_AND_SPEAKER, 31),
442 SND(CURRENT, 0x7FFFFFFE),
443 SND(FM_ANALOG_STEREO_HEADSET, 35),
444 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
445};
446#undef SND
447
448static struct msm_snd_endpoints msm_device_snd_endpoints = {
449 .endpoints = snd_endpoints_list,
450 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
451};
452
453static struct platform_device msm_device_snd = {
454 .name = "msm_snd",
455 .id = -1,
456 .dev = {
457 .platform_data = &msm_device_snd_endpoints
458 },
459};
460
461#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
462 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
463 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
464 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
465 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
466 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
467#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
468 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
469 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
470 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
471 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
472 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
473#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
474 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
475 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
476 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
477 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
478 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
479#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
480 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
481 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
482 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
483 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
484 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
485#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
486
487static unsigned int dec_concurrency_table[] = {
488 /* Audio LP */
489 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
490 0, 0, 0,
491
492 /* Concurrency 1 */
493 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
494 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
495 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
496 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
497 (DEC4_FORMAT),
498
499 /* Concurrency 2 */
500 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
501 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
502 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
503 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
504 (DEC4_FORMAT),
505
506 /* Concurrency 3 */
507 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
508 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
509 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
510 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
511 (DEC4_FORMAT),
512
513 /* Concurrency 4 */
514 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
515 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
516 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
517 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
518 (DEC4_FORMAT),
519
520 /* Concurrency 5 */
521 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
522 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
523 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
524 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
525 (DEC4_FORMAT),
526
527 /* Concurrency 6 */
Chaithanya Krishna Bacharaju72ab89b2012-05-11 14:24:04 +0530528 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|
529 (1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
530 0, 0, 0, 0,
Trilok Sonib9410792012-04-07 15:37:13 +0530531
532 /* Concurrency 7 */
533 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
534 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
535 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
536 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
537 (DEC4_FORMAT),
538};
539
540#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
541 .module_queueid = queueid, .module_decid = decid, \
542 .nr_codec_support = nr_codec}
543
544static struct msm_adspdec_info dec_info_list[] = {
545 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
546 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
547 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
548 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
549 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
550};
551
552static struct msm_adspdec_database msm_device_adspdec_database = {
553 .num_dec = ARRAY_SIZE(dec_info_list),
554 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
555 ARRAY_SIZE(dec_info_list)),
556 .dec_concurrency_table = dec_concurrency_table,
557 .dec_info_list = dec_info_list,
558};
559
560static struct platform_device msm_device_adspdec = {
561 .name = "msm_adspdec",
562 .id = -1,
563 .dev = {
564 .platform_data = &msm_device_adspdec_database
565 },
566};
567
568static struct android_pmem_platform_data android_pmem_audio_pdata = {
569 .name = "pmem_audio",
570 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
571 .cached = 0,
572 .memory_type = MEMTYPE_EBI1,
573};
574
575static struct platform_device android_pmem_audio_device = {
576 .name = "android_pmem",
577 .id = 2,
578 .dev = { .platform_data = &android_pmem_audio_pdata },
579};
580
581static struct android_pmem_platform_data android_pmem_pdata = {
582 .name = "pmem",
583 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
584 .cached = 1,
585 .memory_type = MEMTYPE_EBI1,
586};
587static struct platform_device android_pmem_device = {
588 .name = "android_pmem",
589 .id = 0,
590 .dev = { .platform_data = &android_pmem_pdata },
591};
592
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530593static u32 msm_calculate_batt_capacity(u32 current_voltage);
594
595static struct msm_psy_batt_pdata msm_psy_batt_data = {
Krishna Vanka9a265e12012-06-04 23:24:26 +0530596 .voltage_min_design = 3200,
597 .voltage_max_design = 4200,
598 .voltage_fail_safe = 3340,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530599 .avail_chg_sources = AC_CHG | USB_CHG ,
600 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
601 .calculate_capacity = &msm_calculate_batt_capacity,
602};
603
604static u32 msm_calculate_batt_capacity(u32 current_voltage)
605{
606 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
607 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
608
Krishna Vankab3494692012-06-12 15:06:43 +0530609 if (current_voltage <= low_voltage)
610 return 0;
611 else if (current_voltage >= high_voltage)
612 return 100;
613 else
614 return (current_voltage - low_voltage) * 100
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530615 / (high_voltage - low_voltage);
616}
617
618static struct platform_device msm_batt_device = {
619 .name = "msm-battery",
620 .id = -1,
621 .dev.platform_data = &msm_psy_batt_data,
622};
623
Siddartha Mohanadossbc2103f2012-03-20 11:41:48 -0700624static char *msm_adc_surf_device_names[] = {
625 "XO_ADC",
626};
627
628static struct msm_adc_platform_data msm_adc_pdata = {
629 .dev_names = msm_adc_surf_device_names,
630 .num_adc = ARRAY_SIZE(msm_adc_surf_device_names),
631 .target_hw = MSM_8x25,
632};
633
634static struct platform_device msm_adc_device = {
635 .name = "msm_adc",
636 .id = -1,
637 .dev = {
638 .platform_data = &msm_adc_pdata,
639 },
640};
641
Taniya Das720c5c32012-05-18 14:08:14 +0530642static struct fmem_platform_data fmem_pdata;
643
644static struct platform_device fmem_device = {
645 .name = "fmem",
646 .id = 1,
647 .dev = { .platform_data = &fmem_pdata },
648};
649
Trilok Soni0ed9c4a2012-05-22 17:54:32 +0530650#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
651 [GPIO_VREG_ID_##_id] = { \
652 .init_data = { \
653 .constraints = { \
654 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
655 }, \
656 .num_consumer_supplies = \
657 ARRAY_SIZE(vreg_consumers_##_id), \
658 .consumer_supplies = vreg_consumers_##_id, \
659 }, \
660 .regulator_name = _reg_name, \
661 .active_low = _active_low, \
662 .gpio_label = _gpio_label, \
663 .gpio = _gpio, \
664 }
665
666#define GPIO_VREG_ID_EXT_2P85V 0
667#define GPIO_VREG_ID_EXT_1P8V 1
668
669static struct regulator_consumer_supply vreg_consumers_EXT_2P85V[] = {
Raju P.L.S.S.S.N4d01b2c2012-06-13 20:13:27 +0530670 REGULATOR_SUPPLY("cam_ov5647_avdd", "0-006c"),
671 REGULATOR_SUPPLY("cam_ov7692_avdd", "0-0078"),
672 REGULATOR_SUPPLY("cam_ov8825_avdd", "0-000d"),
Trilok Soni0ed9c4a2012-05-22 17:54:32 +0530673 REGULATOR_SUPPLY("lcd_vdd", "mipi_dsi.1"),
674};
675
676static struct regulator_consumer_supply vreg_consumers_EXT_1P8V[] = {
Raju P.L.S.S.S.N4d01b2c2012-06-13 20:13:27 +0530677 REGULATOR_SUPPLY("cam_ov5647_vdd", "0-006c"),
678 REGULATOR_SUPPLY("cam_ov7692_vdd", "0-0078"),
679 REGULATOR_SUPPLY("cam_ov8825_vdd", "0-000d"),
Trilok Soni0ed9c4a2012-05-22 17:54:32 +0530680 REGULATOR_SUPPLY("lcd_vddi", "mipi_dsi.1"),
681};
682
683/* GPIO regulator constraints */
684static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
685 GPIO_VREG_INIT(EXT_2P85V, "ext_2p85v", "ext_2p85v_en", 35, 0),
686 GPIO_VREG_INIT(EXT_1P8V, "ext_1p8v", "ext_1p8v_en", 40, 0),
687};
688
689/* GPIO regulator */
Aparna Mallavarapu336c78d2012-07-02 19:43:18 +0530690static struct platform_device qrd_vreg_gpio_ext_2p85v __devinitdata = {
Trilok Soni0ed9c4a2012-05-22 17:54:32 +0530691 .name = GPIO_REGULATOR_DEV_NAME,
692 .id = 35,
693 .dev = {
694 .platform_data =
695 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_2P85V],
696 },
697};
698
Aparna Mallavarapu336c78d2012-07-02 19:43:18 +0530699static struct platform_device qrd_vreg_gpio_ext_1p8v __devinitdata = {
Trilok Soni0ed9c4a2012-05-22 17:54:32 +0530700 .name = GPIO_REGULATOR_DEV_NAME,
701 .id = 40,
702 .dev = {
703 .platform_data =
704 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_1P8V],
705 },
706};
707
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530708static struct platform_device *common_devices[] __initdata = {
709 &android_usb_device,
Trilok Sonib9410792012-04-07 15:37:13 +0530710 &android_pmem_device,
711 &android_pmem_adsp_device,
712 &android_pmem_audio_device,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530713 &msm_batt_device,
Trilok Sonib9410792012-04-07 15:37:13 +0530714 &msm_device_adspdec,
715 &msm_device_snd,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530716 &asoc_msm_pcm,
717 &asoc_msm_dai0,
718 &asoc_msm_dai1,
Siddartha Mohanadossbc2103f2012-03-20 11:41:48 -0700719 &msm_adc_device,
Taniya Das720c5c32012-05-18 14:08:14 +0530720 &fmem_device,
Chintan Pandya43d0a342012-06-08 19:45:56 +0530721#ifdef CONFIG_ION_MSM
722 &ion_dev,
723#endif
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530724};
725
726static struct platform_device *qrd7627a_devices[] __initdata = {
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530727 &msm_device_dmov,
728 &msm_device_smd,
729 &msm_device_uart1,
730 &msm_device_uart_dm1,
731 &msm_gsbi0_qup_i2c_device,
732 &msm_gsbi1_qup_i2c_device,
733 &msm_device_otg,
734 &msm_device_gadget_peripheral,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530735 &msm_kgsl_3d0,
Aparna Mallavarapu336c78d2012-07-02 19:43:18 +0530736 &qrd_vreg_gpio_ext_2p85v,
737 &qrd_vreg_gpio_ext_1p8v,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530738};
739
Chintan Pandyab1bad0e2012-02-06 19:04:51 +0530740static struct platform_device *qrd3_devices[] __initdata = {
741 &msm_device_nand,
742};
743
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530744static struct platform_device *msm8625_evb_devices[] __initdata = {
745 &msm8625_device_dmov,
746 &msm8625_device_smd,
747 &msm8625_gsbi0_qup_i2c_device,
748 &msm8625_gsbi1_qup_i2c_device,
749 &msm8625_device_uart1,
Ram Mohan Korukonda5ee9fb82012-03-09 12:10:01 +0530750 &msm8625_device_uart_dm1,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530751 &msm8625_device_otg,
752 &msm8625_device_gadget_peripheral,
Aparna Mallavarapud95d8fc2012-03-08 12:07:37 +0530753 &msm8625_kgsl_3d0,
Aparna Mallavarapu336c78d2012-07-02 19:43:18 +0530754 &qrd_vreg_gpio_ext_2p85v,
755 &qrd_vreg_gpio_ext_1p8v,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530756};
757
Trilok Sonib9410792012-04-07 15:37:13 +0530758static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
759static int __init pmem_kernel_ebi1_size_setup(char *p)
760{
761 pmem_kernel_ebi1_size = memparse(p, NULL);
762 return 0;
763}
764early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
765
766static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
767static int __init pmem_audio_size_setup(char *p)
768{
769 pmem_audio_size = memparse(p, NULL);
770 return 0;
771}
772early_param("pmem_audio_size", pmem_audio_size_setup);
773
Chintan Pandya43d0a342012-06-08 19:45:56 +0530774#ifdef CONFIG_ION_MSM
775#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
776static struct ion_co_heap_pdata co_ion_pdata = {
777 .adjacent_mem_id = INVALID_HEAP_ID,
778 .align = PAGE_SIZE,
779};
780#endif
781
782/**
783 * These heaps are listed in the order they will be allocated.
784 * Don't swap the order unless you know what you are doing!
785 */
786static struct ion_platform_data ion_pdata = {
787 .nr = MSM_ION_HEAP_NUM,
788 .heaps = {
789 {
790 .id = ION_SYSTEM_HEAP_ID,
791 .type = ION_HEAP_TYPE_SYSTEM,
792 .name = ION_VMALLOC_HEAP_NAME,
793 },
794#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
795 /* PMEM_ADSP = CAMERA */
796 {
797 .id = ION_CAMERA_HEAP_ID,
798 .type = ION_HEAP_TYPE_CARVEOUT,
799 .name = ION_CAMERA_HEAP_NAME,
800 .size = MSM_ION_CAMERA_SIZE,
801 .memory_type = ION_EBI_TYPE,
802 .has_outer_cache = 1,
803 .extra_data = (void *)&co_ion_pdata,
804 },
805 /* PMEM_AUDIO */
806 {
807 .id = ION_AUDIO_HEAP_ID,
808 .type = ION_HEAP_TYPE_CARVEOUT,
809 .name = ION_AUDIO_HEAP_NAME,
810 .size = MSM_ION_AUDIO_SIZE,
811 .memory_type = ION_EBI_TYPE,
812 .has_outer_cache = 1,
813 .extra_data = (void *)&co_ion_pdata,
814 },
815 /* PMEM_MDP = SF */
816 {
817 .id = ION_SF_HEAP_ID,
818 .type = ION_HEAP_TYPE_CARVEOUT,
819 .name = ION_SF_HEAP_NAME,
820 .size = MSM_ION_SF_SIZE,
821 .memory_type = ION_EBI_TYPE,
822 .has_outer_cache = 1,
823 .extra_data = (void *)&co_ion_pdata,
824 },
825#endif
826 }
827};
828
829static struct platform_device ion_dev = {
830 .name = "ion-msm",
831 .id = 1,
832 .dev = { .platform_data = &ion_pdata },
833};
834#endif
835
Trilok Sonib9410792012-04-07 15:37:13 +0530836static struct memtype_reserve msm7627a_reserve_table[] __initdata = {
837 [MEMTYPE_SMI] = {
838 },
839 [MEMTYPE_EBI0] = {
840 .flags = MEMTYPE_FLAGS_1M_ALIGN,
841 },
842 [MEMTYPE_EBI1] = {
843 .flags = MEMTYPE_FLAGS_1M_ALIGN,
844 },
845};
846
Taniya Das720c5c32012-05-18 14:08:14 +0530847#ifdef CONFIG_ANDROID_PMEM
Chintan Pandya43d0a342012-06-08 19:45:56 +0530848#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Taniya Das720c5c32012-05-18 14:08:14 +0530849static struct android_pmem_platform_data *pmem_pdata_array[] __initdata = {
850 &android_pmem_adsp_pdata,
851 &android_pmem_audio_pdata,
852 &android_pmem_pdata,
853};
854#endif
Chintan Pandya43d0a342012-06-08 19:45:56 +0530855#endif
Taniya Das720c5c32012-05-18 14:08:14 +0530856
Trilok Sonib9410792012-04-07 15:37:13 +0530857static void __init size_pmem_devices(void)
858{
859#ifdef CONFIG_ANDROID_PMEM
Chintan Pandya43d0a342012-06-08 19:45:56 +0530860#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Taniya Das720c5c32012-05-18 14:08:14 +0530861 unsigned int i;
862 unsigned int reusable_count = 0;
863
Trilok Sonib9410792012-04-07 15:37:13 +0530864 android_pmem_adsp_pdata.size = pmem_adsp_size;
865 android_pmem_pdata.size = pmem_mdp_size;
866 android_pmem_audio_pdata.size = pmem_audio_size;
Taniya Das720c5c32012-05-18 14:08:14 +0530867
868 fmem_pdata.size = 0;
869 fmem_pdata.align = PAGE_SIZE;
870
871 /* Find pmem devices that should use FMEM (reusable) memory.
872 */
873 for (i = 0; i < ARRAY_SIZE(pmem_pdata_array); ++i) {
874 struct android_pmem_platform_data *pdata = pmem_pdata_array[i];
875
876 if (!reusable_count && pdata->reusable)
877 fmem_pdata.size += pdata->size;
878
879 reusable_count += (pdata->reusable) ? 1 : 0;
880
881 if (pdata->reusable && reusable_count > 1) {
882 pr_err("%s: Too many PMEM devices specified as reusable. PMEM device %s was not configured as reusable.\n",
883 __func__, pdata->name);
884 pdata->reusable = 0;
885 }
886 }
Chintan Pandya43d0a342012-06-08 19:45:56 +0530887#endif
Trilok Sonib9410792012-04-07 15:37:13 +0530888#endif
889}
890
Chintan Pandya43d0a342012-06-08 19:45:56 +0530891#ifdef CONFIG_ANDROID_PMEM
892#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Trilok Sonib9410792012-04-07 15:37:13 +0530893static void __init reserve_memory_for(struct android_pmem_platform_data *p)
894{
895 msm7627a_reserve_table[p->memory_type].size += p->size;
896}
Chintan Pandya43d0a342012-06-08 19:45:56 +0530897#endif
898#endif
Trilok Sonib9410792012-04-07 15:37:13 +0530899
900static void __init reserve_pmem_memory(void)
901{
902#ifdef CONFIG_ANDROID_PMEM
Chintan Pandya43d0a342012-06-08 19:45:56 +0530903#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Taniya Das720c5c32012-05-18 14:08:14 +0530904 unsigned int i;
905 for (i = 0; i < ARRAY_SIZE(pmem_pdata_array); ++i)
906 reserve_memory_for(pmem_pdata_array[i]);
907
Trilok Sonib9410792012-04-07 15:37:13 +0530908 msm7627a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
909#endif
Chintan Pandya43d0a342012-06-08 19:45:56 +0530910#endif
911}
912
913static void __init reserve_ion_memory(void)
914{
915#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
916 msm7627a_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
917 msm7627a_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
918 msm7627a_reserve_table[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE;
919#endif
Trilok Sonib9410792012-04-07 15:37:13 +0530920}
921
922static void __init msm7627a_calculate_reserve_sizes(void)
923{
924 size_pmem_devices();
925 reserve_pmem_memory();
Chintan Pandya43d0a342012-06-08 19:45:56 +0530926 reserve_ion_memory();
Trilok Sonib9410792012-04-07 15:37:13 +0530927}
928
929static int msm7627a_paddr_to_memtype(unsigned int paddr)
930{
931 return MEMTYPE_EBI1;
932}
933
934static struct reserve_info msm7627a_reserve_info __initdata = {
935 .memtype_reserve_table = msm7627a_reserve_table,
936 .calculate_reserve_sizes = msm7627a_calculate_reserve_sizes,
937 .paddr_to_memtype = msm7627a_paddr_to_memtype,
938};
939
940static void __init msm7627a_reserve(void)
941{
942 reserve_info = &msm7627a_reserve_info;
943 msm_reserve();
944 memblock_remove(MSM8625_WARM_BOOT_PHYS, SZ_32);
945}
946
947static void __init msm8625_reserve(void)
948{
949 memblock_remove(MSM8625_SECONDARY_PHYS, SZ_8);
950 msm7627a_reserve();
951}
952
953static void msmqrd_adsp_add_pdev(void)
954{
955 int rc = 0;
956 struct rpc_board_dev *rpc_adsp_pdev;
957
958 rpc_adsp_pdev = kzalloc(sizeof(struct rpc_board_dev), GFP_KERNEL);
959 if (rpc_adsp_pdev == NULL) {
960 pr_err("%s: Memory Allocation failure\n", __func__);
961 return;
962 }
963 rpc_adsp_pdev->prog = ADSP_RPC_PROG;
964
965 if (cpu_is_msm8625())
966 rpc_adsp_pdev->pdev = msm8625_device_adsp;
967 else
968 rpc_adsp_pdev->pdev = msm_adsp_device;
969 rc = msm_rpc_add_board_dev(rpc_adsp_pdev, 1);
970 if (rc < 0) {
971 pr_err("%s: return val: %d\n", __func__, rc);
972 kfree(rpc_adsp_pdev);
973 }
974}
975
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530976static void __init msm7627a_device_i2c_init(void)
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530977{
978 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
979 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
980}
981
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530982static void __init msm8625_device_i2c_init(void)
983{
984 msm8625_gsbi0_qup_i2c_device.dev.platform_data
985 = &msm_gsbi0_qup_i2c_pdata;
986 msm8625_gsbi1_qup_i2c_device.dev.platform_data
987 = &msm_gsbi1_qup_i2c_pdata;
988}
989
Pankaj Kumar3cec0582011-11-18 11:13:29 +0530990static struct platform_device msm_proccomm_regulator_dev = {
991 .name = PROCCOMM_REGULATOR_DEV_NAME,
992 .id = -1,
993 .dev = {
994 .platform_data = &msm7x27a_proccomm_regulator_data
995 }
996};
997
998static void __init msm7627a_init_regulators(void)
999{
1000 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1001 if (rc)
1002 pr_err("%s: could not register regulator device: %d\n",
1003 __func__, rc);
1004}
1005
Santosh Sajjan374d6592012-01-19 23:16:46 +05301006static int __init msm_qrd_init_ar6000pm(void)
1007{
1008 msm_wlan_ar6000_pm_device.dev.platform_data = &ar600x_wlan_power;
1009 return platform_device_register(&msm_wlan_ar6000_pm_device);
1010}
1011
Taniya Dase380a2d2012-03-09 13:02:41 +05301012static void __init msm_add_footswitch_devices(void)
1013{
1014 platform_add_devices(msm_footswitch_devices,
1015 msm_num_footswitch_devices);
1016}
1017
Stephen Boyd668d7652012-04-25 11:31:01 -07001018static void __init add_platform_devices(void)
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301019{
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301020 if (machine_is_msm8625_evb() || machine_is_msm8625_qrd7()
1021 || machine_is_msm8625_evt()) {
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301022 platform_add_devices(msm8625_evb_devices,
1023 ARRAY_SIZE(msm8625_evb_devices));
Aparna Mallavarapubeafcbc2012-03-13 16:57:39 +05301024 platform_add_devices(qrd3_devices,
Taniya Dasbd096542012-03-15 17:43:45 +05301025 ARRAY_SIZE(qrd3_devices));
Aparna Mallavarapubeafcbc2012-03-13 16:57:39 +05301026 } else {
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301027 platform_add_devices(qrd7627a_devices,
1028 ARRAY_SIZE(qrd7627a_devices));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301029 }
Taniya Dasbd096542012-03-15 17:43:45 +05301030
Aparna Mallavarapu0b69ca22012-03-26 15:58:35 +05301031 if (machine_is_msm7627a_qrd3() || machine_is_msm7627a_evb())
Taniya Dasbd096542012-03-15 17:43:45 +05301032 platform_add_devices(qrd3_devices,
Aparna Mallavarapu0b69ca22012-03-26 15:58:35 +05301033 ARRAY_SIZE(qrd3_devices));
Taniya Dasbd096542012-03-15 17:43:45 +05301034
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301035 platform_add_devices(common_devices,
1036 ARRAY_SIZE(common_devices));
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301037}
1038
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301039#define UART1DM_RX_GPIO 45
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301040static void __init qrd7627a_uart1dm_config(void)
1041{
1042 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
1043 if (cpu_is_msm8625())
1044 msm8625_device_uart_dm1.dev.platform_data =
1045 &msm_uart_dm1_pdata;
1046 else
1047 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
1048}
1049
1050static void __init qrd7627a_otg_gadget(void)
1051{
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301052 if (cpu_is_msm8625()) {
Murali Nalajala6ff8fb12012-05-02 18:50:50 +05301053 msm_otg_pdata.swfi_latency = msm8625_pm_data
1054 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT].latency;
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301055 msm8625_device_otg.dev.platform_data = &msm_otg_pdata;
1056 msm8625_device_gadget_peripheral.dev.platform_data =
1057 &msm_gadget_pdata;
1058
1059 } else {
Murali Nalajala6ff8fb12012-05-02 18:50:50 +05301060 msm_otg_pdata.swfi_latency = msm7627a_pm_data
1061 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301062 msm_device_otg.dev.platform_data = &msm_otg_pdata;
1063 msm_device_gadget_peripheral.dev.platform_data =
1064 &msm_gadget_pdata;
1065 }
1066}
1067
Taniya Dasbd096542012-03-15 17:43:45 +05301068static void __init msm_pm_init(void)
1069{
Taniya Dasbd096542012-03-15 17:43:45 +05301070
Aparna Mallavarapu6d969eb2012-04-03 15:10:25 +05301071 if (!cpu_is_msm8625()) {
Taniya Dasbd096542012-03-15 17:43:45 +05301072 msm_pm_set_platform_data(msm7627a_pm_data,
1073 ARRAY_SIZE(msm7627a_pm_data));
1074 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
1075 } else {
1076 msm_pm_set_platform_data(msm8625_pm_data,
1077 ARRAY_SIZE(msm8625_pm_data));
1078 BUG_ON(msm_pm_boot_init(&msm_pm_8625_boot_pdata));
1079 msm8x25_spm_device_init();
1080 }
1081}
1082
Taniya Dasc868a2e2012-01-03 10:18:47 +05301083static void __init msm_qrd_init(void)
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301084{
1085 msm7x2x_misc_init();
Pankaj Kumar3cec0582011-11-18 11:13:29 +05301086 msm7627a_init_regulators();
Trilok Sonib9410792012-04-07 15:37:13 +05301087 msmqrd_adsp_add_pdev();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301088
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301089 if (cpu_is_msm8625())
1090 msm8625_device_i2c_init();
1091 else
1092 msm7627a_device_i2c_init();
1093
1094 /* uart1dm*/
1095 qrd7627a_uart1dm_config();
1096 /*OTG gadget*/
1097 qrd7627a_otg_gadget();
Taniya Dasc868a2e2012-01-03 10:18:47 +05301098
Taniya Dase380a2d2012-03-09 13:02:41 +05301099 msm_add_footswitch_devices();
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301100 add_platform_devices();
Taniya Dasc868a2e2012-01-03 10:18:47 +05301101
Santosh Sajjan374d6592012-01-19 23:16:46 +05301102 /* Ensure ar6000pm device is registered before MMC/SDC */
1103 msm_qrd_init_ar6000pm();
Chintan Pandyacf467fc2011-12-01 17:11:11 +05301104 msm7627a_init_mmc();
1105
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301106#ifdef CONFIG_USB_EHCI_MSM_72K
1107 msm7627a_init_host();
1108#endif
Taniya Dasbd096542012-03-15 17:43:45 +05301109 msm_pm_init();
Murali Nalajalaa1827842011-11-13 14:12:39 +05301110
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05301111 msm_pm_register_irqs();
Taniya Das0a5303a2011-08-23 18:47:48 +05301112 msm_fb_add_devices();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301113
1114#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Chintan Pandya13490c02011-12-20 13:03:36 +05301115 msm7627a_bt_power_init();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301116#endif
Taniya Dasda408822011-09-06 12:54:06 +05301117
Chintan Pandya40762702011-12-06 13:47:06 +05301118 msm7627a_camera_init();
Chintan Pandya0d453192012-03-09 13:20:33 +05301119 qrd7627a_add_io_devices();
Aparna Mallavarapud95d8fc2012-03-08 12:07:37 +05301120 msm7x25a_kgsl_3d0_init();
Sudhakara Rao Tentu38ad6e12012-03-30 15:25:18 -07001121 msm8x25_kgsl_3d0_init();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301122}
1123
1124static void __init qrd7627a_init_early(void)
1125{
1126 msm_msm7627a_allocate_memory_regions();
1127}
1128
1129MACHINE_START(MSM7627A_QRD1, "QRD MSM7627a QRD1")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001130 .atag_offset = 0x100,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301131 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301132 .reserve = msm7627a_reserve,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301133 .init_irq = msm_init_irq,
Taniya Dasc868a2e2012-01-03 10:18:47 +05301134 .init_machine = msm_qrd_init,
1135 .timer = &msm_timer,
1136 .init_early = qrd7627a_init_early,
1137 .handle_irq = vic_handle_irq,
1138MACHINE_END
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301139MACHINE_START(MSM7627A_QRD3, "QRD MSM7627a QRD3")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001140 .atag_offset = 0x100,
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301141 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301142 .reserve = msm7627a_reserve,
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301143 .init_irq = msm_init_irq,
1144 .init_machine = msm_qrd_init,
1145 .timer = &msm_timer,
1146 .init_early = qrd7627a_init_early,
1147 .handle_irq = vic_handle_irq,
1148MACHINE_END
Taniya Dasc868a2e2012-01-03 10:18:47 +05301149MACHINE_START(MSM7627A_EVB, "QRD MSM7627a EVB")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001150 .atag_offset = 0x100,
Taniya Dasc868a2e2012-01-03 10:18:47 +05301151 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301152 .reserve = msm7627a_reserve,
Taniya Dasc868a2e2012-01-03 10:18:47 +05301153 .init_irq = msm_init_irq,
1154 .init_machine = msm_qrd_init,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301155 .timer = &msm_timer,
1156 .init_early = qrd7627a_init_early,
Pankaj Kumarbf8a2a32011-10-21 11:47:21 +05301157 .handle_irq = vic_handle_irq,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301158MACHINE_END
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301159MACHINE_START(MSM8625_EVB, "QRD MSM8625 EVB")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001160 .atag_offset = 0x100,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301161 .map_io = msm8625_map_io,
Trilok Sonib9410792012-04-07 15:37:13 +05301162 .reserve = msm8625_reserve,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301163 .init_irq = msm8625_init_irq,
1164 .init_machine = msm_qrd_init,
1165 .timer = &msm_timer,
1166 .init_early = qrd7627a_init_early,
1167 .handle_irq = gic_handle_irq,
1168MACHINE_END
Taniya Dasbd096542012-03-15 17:43:45 +05301169MACHINE_START(MSM8625_QRD7, "QRD MSM8625 QRD7")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001170 .atag_offset = 0x100,
Taniya Dasbd096542012-03-15 17:43:45 +05301171 .map_io = msm8625_map_io,
Trilok Sonib9410792012-04-07 15:37:13 +05301172 .reserve = msm8625_reserve,
Taniya Dasbd096542012-03-15 17:43:45 +05301173 .init_irq = msm8625_init_irq,
1174 .init_machine = msm_qrd_init,
1175 .timer = &msm_timer,
1176 .init_early = qrd7627a_init_early,
1177 .handle_irq = gic_handle_irq,
1178MACHINE_END
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301179MACHINE_START(MSM8625_EVT, "QRD MSM8625 EVT")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001180 .atag_offset = 0x100,
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301181 .map_io = msm8625_map_io,
1182 .reserve = msm8625_reserve,
1183 .init_irq = msm8625_init_irq,
1184 .init_machine = msm_qrd_init,
1185 .timer = &msm_timer,
1186 .init_early = qrd7627a_init_early,
1187 .handle_irq = gic_handle_irq,
1188MACHINE_END