blob: 5b9ea36e730996b5d2faa2d5c828910b59bbad7f [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,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530147};
148
149static struct platform_device android_usb_device = {
150 .name = "android_usb",
151 .id = -1,
152 .dev = {
153 .platform_data = &android_usb_pdata,
154 },
155};
156
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530157#ifdef CONFIG_USB_EHCI_MSM_72K
158static void msm_hsusb_vbus_power(unsigned phy_info, int on)
159{
160 int rc = 0;
161 unsigned gpio;
162
Chintan Pandya40762702011-12-06 13:47:06 +0530163 gpio = QRD_GPIO_HOST_VBUS_EN;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530164
165 rc = gpio_request(gpio, "i2c_host_vbus_en");
166 if (rc < 0) {
167 pr_err("failed to request %d GPIO\n", gpio);
168 return;
169 }
170 gpio_direction_output(gpio, !!on);
171 gpio_set_value_cansleep(gpio, !!on);
172 gpio_free(gpio);
173}
174
175static struct msm_usb_host_platform_data msm_usb_host_pdata = {
176 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
177};
178
179static void __init msm7627a_init_host(void)
180{
181 msm_add_host(0, &msm_usb_host_pdata);
182}
183#endif
184
185#ifdef CONFIG_USB_MSM_OTG_72K
186static int hsusb_rpc_connect(int connect)
187{
188 if (connect)
189 return msm_hsusb_rpc_connect();
190 else
191 return msm_hsusb_rpc_close();
192}
193
Pankaj Kumar27c02642011-09-22 15:55:55 +0530194static struct regulator *reg_hsusb;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530195static int msm_hsusb_ldo_init(int init)
196{
Pankaj Kumar27c02642011-09-22 15:55:55 +0530197 int rc = 0;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530198
Pankaj Kumar27c02642011-09-22 15:55:55 +0530199 if (init) {
200 reg_hsusb = regulator_get(NULL, "usb");
201 if (IS_ERR(reg_hsusb)) {
202 rc = PTR_ERR(reg_hsusb);
203 pr_err("%s: could not get regulator: %d\n",
204 __func__, rc);
205 goto out;
206 }
207
208 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
209 if (rc) {
210 pr_err("%s: could not set voltage: %d\n",
211 __func__, rc);
212 goto reg_free;
213 }
214
215 return 0;
216 }
217 /* else fall through */
218reg_free:
219 regulator_put(reg_hsusb);
220out:
221 reg_hsusb = NULL;
222 return rc;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530223}
224
225static int msm_hsusb_ldo_enable(int enable)
226{
227 static int ldo_status;
228
Pankaj Kumar27c02642011-09-22 15:55:55 +0530229 if (IS_ERR_OR_NULL(reg_hsusb))
230 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530231
232 if (ldo_status == enable)
233 return 0;
234
235 ldo_status = enable;
236
Pankaj Kumar27c02642011-09-22 15:55:55 +0530237 return enable ?
238 regulator_enable(reg_hsusb) :
239 regulator_disable(reg_hsusb);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530240}
241
242#ifndef CONFIG_USB_EHCI_MSM_72K
243static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
244{
245 int ret = 0;
246
247 if (init)
248 ret = msm_pm_app_rpc_init(callback);
249 else
250 msm_pm_app_rpc_deinit(callback);
251
252 return ret;
253}
254#endif
255
256static struct msm_otg_platform_data msm_otg_pdata = {
257#ifndef CONFIG_USB_EHCI_MSM_72K
258 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
259#else
260 .vbus_power = msm_hsusb_vbus_power,
261#endif
262 .rpc_connect = hsusb_rpc_connect,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530263 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
264 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
265 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
266 .se1_gating = SE1_GATING_DISABLE,
267 .ldo_init = msm_hsusb_ldo_init,
268 .ldo_enable = msm_hsusb_ldo_enable,
269 .chg_init = hsusb_chg_init,
270 .chg_connected = hsusb_chg_connected,
271 .chg_vbus_draw = hsusb_chg_vbus_draw,
272};
273#endif
274
275static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
276 .is_phy_status_timer_on = 1,
277};
278
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530279#ifdef CONFIG_SERIAL_MSM_HS
280static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
281 .inject_rx_on_wakeup = 1,
282 .rx_to_inject = 0xFD,
283};
284#endif
285static struct msm_pm_platform_data msm7627a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
286 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
287 .idle_supported = 1,
288 .suspend_supported = 1,
289 .idle_enabled = 1,
290 .suspend_enabled = 1,
291 .latency = 16000,
292 .residency = 20000,
293 },
294 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
295 .idle_supported = 1,
296 .suspend_supported = 1,
297 .idle_enabled = 1,
298 .suspend_enabled = 1,
299 .latency = 12000,
300 .residency = 20000,
301 },
302 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
303 .idle_supported = 1,
304 .suspend_supported = 1,
305 .idle_enabled = 0,
306 .suspend_enabled = 1,
307 .latency = 2000,
308 .residency = 0,
309 },
310 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
311 .idle_supported = 1,
312 .suspend_supported = 1,
313 .idle_enabled = 1,
314 .suspend_enabled = 1,
315 .latency = 2,
316 .residency = 0,
317 },
318};
319
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600320static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +0530321 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
322 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600323};
324
Murali Nalajala4c996be2012-03-12 17:05:41 +0530325/* 8625 PM platform data */
326static struct msm_pm_platform_data msm8625_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
327 /* CORE0 entries */
328 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
329 .idle_supported = 1,
330 .suspend_supported = 1,
331 .idle_enabled = 0,
332 .suspend_enabled = 0,
333 .latency = 16000,
334 .residency = 20000,
335 },
336
337 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
338 .idle_supported = 1,
339 .suspend_supported = 1,
340 .idle_enabled = 0,
341 .suspend_enabled = 0,
342 .latency = 12000,
343 .residency = 20000,
344 },
345
346 /* picked latency & redisdency values from 7x30 */
347 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
348 .idle_supported = 1,
349 .suspend_supported = 1,
350 .idle_enabled = 0,
351 .suspend_enabled = 0,
352 .latency = 500,
353 .residency = 6000,
354 },
355
356 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
357 .idle_supported = 1,
358 .suspend_supported = 1,
359 .idle_enabled = 1,
360 .suspend_enabled = 1,
361 .latency = 2,
362 .residency = 10,
363 },
364
365 /* picked latency & redisdency values from 7x30 */
366 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
367 .idle_supported = 1,
368 .suspend_supported = 1,
369 .idle_enabled = 0,
370 .suspend_enabled = 0,
371 .latency = 500,
372 .residency = 6000,
373 },
374
375 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
376 .idle_supported = 1,
377 .suspend_supported = 1,
378 .idle_enabled = 1,
379 .suspend_enabled = 1,
380 .latency = 2,
381 .residency = 10,
382 },
383
384};
385
386static struct msm_pm_boot_platform_data msm_pm_8625_boot_pdata __initdata = {
387 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
388 .v_addr = MSM_CFG_CTL_BASE,
389};
390
Trilok Sonib9410792012-04-07 15:37:13 +0530391static struct android_pmem_platform_data android_pmem_adsp_pdata = {
392 .name = "pmem_adsp",
393 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
394 .cached = 1,
395 .memory_type = MEMTYPE_EBI1,
Taniya Das720c5c32012-05-18 14:08:14 +0530396 .request_region = request_fmem_c_region,
397 .release_region = release_fmem_c_region,
398 .reusable = 1,
Trilok Sonib9410792012-04-07 15:37:13 +0530399};
400
401static struct platform_device android_pmem_adsp_device = {
402 .name = "android_pmem",
403 .id = 1,
404 .dev = { .platform_data = &android_pmem_adsp_pdata },
405};
406
407static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
408static int __init pmem_mdp_size_setup(char *p)
409{
410 pmem_mdp_size = memparse(p, NULL);
411 return 0;
412}
413
414early_param("pmem_mdp_size", pmem_mdp_size_setup);
415
416static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
417static int __init pmem_adsp_size_setup(char *p)
418{
419 pmem_adsp_size = memparse(p, NULL);
420 return 0;
421}
422
423early_param("pmem_adsp_size", pmem_adsp_size_setup);
424
425#define SND(desc, num) { .name = #desc, .id = num }
426static struct snd_endpoint snd_endpoints_list[] = {
427 SND(HANDSET, 0),
428 SND(MONO_HEADSET, 2),
429 SND(HEADSET, 3),
430 SND(SPEAKER, 6),
431 SND(TTY_HEADSET, 8),
432 SND(TTY_VCO, 9),
433 SND(TTY_HCO, 10),
434 SND(BT, 12),
435 SND(IN_S_SADC_OUT_HANDSET, 16),
436 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
437 SND(FM_DIGITAL_STEREO_HEADSET, 26),
438 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
439 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
440 SND(STEREO_HEADSET_AND_SPEAKER, 31),
441 SND(CURRENT, 0x7FFFFFFE),
442 SND(FM_ANALOG_STEREO_HEADSET, 35),
443 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
444};
445#undef SND
446
447static struct msm_snd_endpoints msm_device_snd_endpoints = {
448 .endpoints = snd_endpoints_list,
449 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
450};
451
452static struct platform_device msm_device_snd = {
453 .name = "msm_snd",
454 .id = -1,
455 .dev = {
456 .platform_data = &msm_device_snd_endpoints
457 },
458};
459
460#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
461 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
462 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
463 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
464 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
465 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
466#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
467 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
468 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
469 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
470 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
471 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
472#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
473 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
474 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
475 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
476 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
477 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
478#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
479 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
480 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
481 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
482 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
483 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
484#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
485
486static unsigned int dec_concurrency_table[] = {
487 /* Audio LP */
488 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
489 0, 0, 0,
490
491 /* Concurrency 1 */
492 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
493 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
494 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
495 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
496 (DEC4_FORMAT),
497
498 /* Concurrency 2 */
499 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
500 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
501 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
502 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
503 (DEC4_FORMAT),
504
505 /* Concurrency 3 */
506 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
507 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
508 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
509 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
510 (DEC4_FORMAT),
511
512 /* Concurrency 4 */
513 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
514 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
515 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
516 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
517 (DEC4_FORMAT),
518
519 /* Concurrency 5 */
520 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
521 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
522 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
523 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
524 (DEC4_FORMAT),
525
526 /* Concurrency 6 */
Chaithanya Krishna Bacharaju72ab89b2012-05-11 14:24:04 +0530527 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|
528 (1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
529 0, 0, 0, 0,
Trilok Sonib9410792012-04-07 15:37:13 +0530530
531 /* Concurrency 7 */
532 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
533 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
534 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
535 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
536 (DEC4_FORMAT),
537};
538
539#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
540 .module_queueid = queueid, .module_decid = decid, \
541 .nr_codec_support = nr_codec}
542
543static struct msm_adspdec_info dec_info_list[] = {
544 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
545 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
546 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
547 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
548 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
549};
550
551static struct msm_adspdec_database msm_device_adspdec_database = {
552 .num_dec = ARRAY_SIZE(dec_info_list),
553 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
554 ARRAY_SIZE(dec_info_list)),
555 .dec_concurrency_table = dec_concurrency_table,
556 .dec_info_list = dec_info_list,
557};
558
559static struct platform_device msm_device_adspdec = {
560 .name = "msm_adspdec",
561 .id = -1,
562 .dev = {
563 .platform_data = &msm_device_adspdec_database
564 },
565};
566
567static struct android_pmem_platform_data android_pmem_audio_pdata = {
568 .name = "pmem_audio",
569 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
570 .cached = 0,
571 .memory_type = MEMTYPE_EBI1,
572};
573
574static struct platform_device android_pmem_audio_device = {
575 .name = "android_pmem",
576 .id = 2,
577 .dev = { .platform_data = &android_pmem_audio_pdata },
578};
579
580static struct android_pmem_platform_data android_pmem_pdata = {
581 .name = "pmem",
582 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
583 .cached = 1,
584 .memory_type = MEMTYPE_EBI1,
585};
586static struct platform_device android_pmem_device = {
587 .name = "android_pmem",
588 .id = 0,
589 .dev = { .platform_data = &android_pmem_pdata },
590};
591
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530592static u32 msm_calculate_batt_capacity(u32 current_voltage);
593
594static struct msm_psy_batt_pdata msm_psy_batt_data = {
Krishna Vanka9a265e12012-06-04 23:24:26 +0530595 .voltage_min_design = 3200,
596 .voltage_max_design = 4200,
597 .voltage_fail_safe = 3340,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530598 .avail_chg_sources = AC_CHG | USB_CHG ,
599 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
600 .calculate_capacity = &msm_calculate_batt_capacity,
601};
602
603static u32 msm_calculate_batt_capacity(u32 current_voltage)
604{
605 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
606 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
607
Krishna Vankab3494692012-06-12 15:06:43 +0530608 if (current_voltage <= low_voltage)
609 return 0;
610 else if (current_voltage >= high_voltage)
611 return 100;
612 else
613 return (current_voltage - low_voltage) * 100
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530614 / (high_voltage - low_voltage);
615}
616
617static struct platform_device msm_batt_device = {
618 .name = "msm-battery",
619 .id = -1,
620 .dev.platform_data = &msm_psy_batt_data,
621};
622
Siddartha Mohanadossbc2103f2012-03-20 11:41:48 -0700623static char *msm_adc_surf_device_names[] = {
624 "XO_ADC",
625};
626
627static struct msm_adc_platform_data msm_adc_pdata = {
628 .dev_names = msm_adc_surf_device_names,
629 .num_adc = ARRAY_SIZE(msm_adc_surf_device_names),
630 .target_hw = MSM_8x25,
631};
632
633static struct platform_device msm_adc_device = {
634 .name = "msm_adc",
635 .id = -1,
636 .dev = {
637 .platform_data = &msm_adc_pdata,
638 },
639};
640
Taniya Das720c5c32012-05-18 14:08:14 +0530641static struct fmem_platform_data fmem_pdata;
642
643static struct platform_device fmem_device = {
644 .name = "fmem",
645 .id = 1,
646 .dev = { .platform_data = &fmem_pdata },
647};
648
Trilok Soni0ed9c4a2012-05-22 17:54:32 +0530649#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
650 [GPIO_VREG_ID_##_id] = { \
651 .init_data = { \
652 .constraints = { \
653 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
654 }, \
655 .num_consumer_supplies = \
656 ARRAY_SIZE(vreg_consumers_##_id), \
657 .consumer_supplies = vreg_consumers_##_id, \
658 }, \
659 .regulator_name = _reg_name, \
660 .active_low = _active_low, \
661 .gpio_label = _gpio_label, \
662 .gpio = _gpio, \
663 }
664
665#define GPIO_VREG_ID_EXT_2P85V 0
666#define GPIO_VREG_ID_EXT_1P8V 1
667
668static struct regulator_consumer_supply vreg_consumers_EXT_2P85V[] = {
Raju P.L.S.S.S.N4d01b2c2012-06-13 20:13:27 +0530669 REGULATOR_SUPPLY("cam_ov5647_avdd", "0-006c"),
670 REGULATOR_SUPPLY("cam_ov7692_avdd", "0-0078"),
671 REGULATOR_SUPPLY("cam_ov8825_avdd", "0-000d"),
Trilok Soni0ed9c4a2012-05-22 17:54:32 +0530672 REGULATOR_SUPPLY("lcd_vdd", "mipi_dsi.1"),
673};
674
675static struct regulator_consumer_supply vreg_consumers_EXT_1P8V[] = {
Raju P.L.S.S.S.N4d01b2c2012-06-13 20:13:27 +0530676 REGULATOR_SUPPLY("cam_ov5647_vdd", "0-006c"),
677 REGULATOR_SUPPLY("cam_ov7692_vdd", "0-0078"),
678 REGULATOR_SUPPLY("cam_ov8825_vdd", "0-000d"),
Trilok Soni0ed9c4a2012-05-22 17:54:32 +0530679 REGULATOR_SUPPLY("lcd_vddi", "mipi_dsi.1"),
680};
681
682/* GPIO regulator constraints */
683static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
684 GPIO_VREG_INIT(EXT_2P85V, "ext_2p85v", "ext_2p85v_en", 35, 0),
685 GPIO_VREG_INIT(EXT_1P8V, "ext_1p8v", "ext_1p8v_en", 40, 0),
686};
687
688/* GPIO regulator */
Aparna Mallavarapu336c78d2012-07-02 19:43:18 +0530689static struct platform_device qrd_vreg_gpio_ext_2p85v __devinitdata = {
Trilok Soni0ed9c4a2012-05-22 17:54:32 +0530690 .name = GPIO_REGULATOR_DEV_NAME,
691 .id = 35,
692 .dev = {
693 .platform_data =
694 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_2P85V],
695 },
696};
697
Aparna Mallavarapu336c78d2012-07-02 19:43:18 +0530698static struct platform_device qrd_vreg_gpio_ext_1p8v __devinitdata = {
Trilok Soni0ed9c4a2012-05-22 17:54:32 +0530699 .name = GPIO_REGULATOR_DEV_NAME,
700 .id = 40,
701 .dev = {
702 .platform_data =
703 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_1P8V],
704 },
705};
706
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530707static struct platform_device *common_devices[] __initdata = {
708 &android_usb_device,
Trilok Sonib9410792012-04-07 15:37:13 +0530709 &android_pmem_device,
710 &android_pmem_adsp_device,
711 &android_pmem_audio_device,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530712 &msm_batt_device,
Trilok Sonib9410792012-04-07 15:37:13 +0530713 &msm_device_adspdec,
714 &msm_device_snd,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530715 &asoc_msm_pcm,
716 &asoc_msm_dai0,
717 &asoc_msm_dai1,
Siddartha Mohanadossbc2103f2012-03-20 11:41:48 -0700718 &msm_adc_device,
Taniya Das720c5c32012-05-18 14:08:14 +0530719 &fmem_device,
Chintan Pandya43d0a342012-06-08 19:45:56 +0530720#ifdef CONFIG_ION_MSM
721 &ion_dev,
722#endif
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530723};
724
725static struct platform_device *qrd7627a_devices[] __initdata = {
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530726 &msm_device_dmov,
727 &msm_device_smd,
728 &msm_device_uart1,
729 &msm_device_uart_dm1,
730 &msm_gsbi0_qup_i2c_device,
731 &msm_gsbi1_qup_i2c_device,
732 &msm_device_otg,
733 &msm_device_gadget_peripheral,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530734 &msm_kgsl_3d0,
Aparna Mallavarapu336c78d2012-07-02 19:43:18 +0530735 &qrd_vreg_gpio_ext_2p85v,
736 &qrd_vreg_gpio_ext_1p8v,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530737};
738
Chintan Pandyab1bad0e2012-02-06 19:04:51 +0530739static struct platform_device *qrd3_devices[] __initdata = {
740 &msm_device_nand,
741};
742
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530743static struct platform_device *msm8625_evb_devices[] __initdata = {
744 &msm8625_device_dmov,
745 &msm8625_device_smd,
746 &msm8625_gsbi0_qup_i2c_device,
747 &msm8625_gsbi1_qup_i2c_device,
748 &msm8625_device_uart1,
Ram Mohan Korukonda5ee9fb82012-03-09 12:10:01 +0530749 &msm8625_device_uart_dm1,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530750 &msm8625_device_otg,
751 &msm8625_device_gadget_peripheral,
Aparna Mallavarapud95d8fc2012-03-08 12:07:37 +0530752 &msm8625_kgsl_3d0,
Aparna Mallavarapu336c78d2012-07-02 19:43:18 +0530753 &qrd_vreg_gpio_ext_2p85v,
754 &qrd_vreg_gpio_ext_1p8v,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530755};
756
Trilok Sonib9410792012-04-07 15:37:13 +0530757static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
758static int __init pmem_kernel_ebi1_size_setup(char *p)
759{
760 pmem_kernel_ebi1_size = memparse(p, NULL);
761 return 0;
762}
763early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
764
765static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
766static int __init pmem_audio_size_setup(char *p)
767{
768 pmem_audio_size = memparse(p, NULL);
769 return 0;
770}
771early_param("pmem_audio_size", pmem_audio_size_setup);
772
Chintan Pandya43d0a342012-06-08 19:45:56 +0530773#ifdef CONFIG_ION_MSM
774#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
775static struct ion_co_heap_pdata co_ion_pdata = {
776 .adjacent_mem_id = INVALID_HEAP_ID,
777 .align = PAGE_SIZE,
778};
779#endif
780
781/**
782 * These heaps are listed in the order they will be allocated.
783 * Don't swap the order unless you know what you are doing!
784 */
785static struct ion_platform_data ion_pdata = {
786 .nr = MSM_ION_HEAP_NUM,
787 .heaps = {
788 {
789 .id = ION_SYSTEM_HEAP_ID,
790 .type = ION_HEAP_TYPE_SYSTEM,
791 .name = ION_VMALLOC_HEAP_NAME,
792 },
793#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
794 /* PMEM_ADSP = CAMERA */
795 {
796 .id = ION_CAMERA_HEAP_ID,
797 .type = ION_HEAP_TYPE_CARVEOUT,
798 .name = ION_CAMERA_HEAP_NAME,
799 .size = MSM_ION_CAMERA_SIZE,
800 .memory_type = ION_EBI_TYPE,
801 .has_outer_cache = 1,
802 .extra_data = (void *)&co_ion_pdata,
803 },
804 /* PMEM_AUDIO */
805 {
806 .id = ION_AUDIO_HEAP_ID,
807 .type = ION_HEAP_TYPE_CARVEOUT,
808 .name = ION_AUDIO_HEAP_NAME,
809 .size = MSM_ION_AUDIO_SIZE,
810 .memory_type = ION_EBI_TYPE,
811 .has_outer_cache = 1,
812 .extra_data = (void *)&co_ion_pdata,
813 },
814 /* PMEM_MDP = SF */
815 {
816 .id = ION_SF_HEAP_ID,
817 .type = ION_HEAP_TYPE_CARVEOUT,
818 .name = ION_SF_HEAP_NAME,
819 .size = MSM_ION_SF_SIZE,
820 .memory_type = ION_EBI_TYPE,
821 .has_outer_cache = 1,
822 .extra_data = (void *)&co_ion_pdata,
823 },
824#endif
825 }
826};
827
828static struct platform_device ion_dev = {
829 .name = "ion-msm",
830 .id = 1,
831 .dev = { .platform_data = &ion_pdata },
832};
833#endif
834
Trilok Sonib9410792012-04-07 15:37:13 +0530835static struct memtype_reserve msm7627a_reserve_table[] __initdata = {
836 [MEMTYPE_SMI] = {
837 },
838 [MEMTYPE_EBI0] = {
839 .flags = MEMTYPE_FLAGS_1M_ALIGN,
840 },
841 [MEMTYPE_EBI1] = {
842 .flags = MEMTYPE_FLAGS_1M_ALIGN,
843 },
844};
845
Taniya Das720c5c32012-05-18 14:08:14 +0530846#ifdef CONFIG_ANDROID_PMEM
Chintan Pandya43d0a342012-06-08 19:45:56 +0530847#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Taniya Das720c5c32012-05-18 14:08:14 +0530848static struct android_pmem_platform_data *pmem_pdata_array[] __initdata = {
849 &android_pmem_adsp_pdata,
850 &android_pmem_audio_pdata,
851 &android_pmem_pdata,
852};
853#endif
Chintan Pandya43d0a342012-06-08 19:45:56 +0530854#endif
Taniya Das720c5c32012-05-18 14:08:14 +0530855
Trilok Sonib9410792012-04-07 15:37:13 +0530856static void __init size_pmem_devices(void)
857{
858#ifdef CONFIG_ANDROID_PMEM
Chintan Pandya43d0a342012-06-08 19:45:56 +0530859#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Taniya Das720c5c32012-05-18 14:08:14 +0530860 unsigned int i;
861 unsigned int reusable_count = 0;
862
Trilok Sonib9410792012-04-07 15:37:13 +0530863 android_pmem_adsp_pdata.size = pmem_adsp_size;
864 android_pmem_pdata.size = pmem_mdp_size;
865 android_pmem_audio_pdata.size = pmem_audio_size;
Taniya Das720c5c32012-05-18 14:08:14 +0530866
867 fmem_pdata.size = 0;
868 fmem_pdata.align = PAGE_SIZE;
869
870 /* Find pmem devices that should use FMEM (reusable) memory.
871 */
872 for (i = 0; i < ARRAY_SIZE(pmem_pdata_array); ++i) {
873 struct android_pmem_platform_data *pdata = pmem_pdata_array[i];
874
875 if (!reusable_count && pdata->reusable)
876 fmem_pdata.size += pdata->size;
877
878 reusable_count += (pdata->reusable) ? 1 : 0;
879
880 if (pdata->reusable && reusable_count > 1) {
881 pr_err("%s: Too many PMEM devices specified as reusable. PMEM device %s was not configured as reusable.\n",
882 __func__, pdata->name);
883 pdata->reusable = 0;
884 }
885 }
Chintan Pandya43d0a342012-06-08 19:45:56 +0530886#endif
Trilok Sonib9410792012-04-07 15:37:13 +0530887#endif
888}
889
Chintan Pandya43d0a342012-06-08 19:45:56 +0530890#ifdef CONFIG_ANDROID_PMEM
891#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Trilok Sonib9410792012-04-07 15:37:13 +0530892static void __init reserve_memory_for(struct android_pmem_platform_data *p)
893{
894 msm7627a_reserve_table[p->memory_type].size += p->size;
895}
Chintan Pandya43d0a342012-06-08 19:45:56 +0530896#endif
897#endif
Trilok Sonib9410792012-04-07 15:37:13 +0530898
899static void __init reserve_pmem_memory(void)
900{
901#ifdef CONFIG_ANDROID_PMEM
Chintan Pandya43d0a342012-06-08 19:45:56 +0530902#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Taniya Das720c5c32012-05-18 14:08:14 +0530903 unsigned int i;
904 for (i = 0; i < ARRAY_SIZE(pmem_pdata_array); ++i)
905 reserve_memory_for(pmem_pdata_array[i]);
906
Trilok Sonib9410792012-04-07 15:37:13 +0530907 msm7627a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
908#endif
Chintan Pandya43d0a342012-06-08 19:45:56 +0530909#endif
910}
911
912static void __init reserve_ion_memory(void)
913{
914#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
915 msm7627a_reserve_table[MEMTYPE_EBI1].size += MSM_ION_CAMERA_SIZE;
916 msm7627a_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
917 msm7627a_reserve_table[MEMTYPE_EBI1].size += MSM_ION_SF_SIZE;
918#endif
Trilok Sonib9410792012-04-07 15:37:13 +0530919}
920
921static void __init msm7627a_calculate_reserve_sizes(void)
922{
923 size_pmem_devices();
924 reserve_pmem_memory();
Chintan Pandya43d0a342012-06-08 19:45:56 +0530925 reserve_ion_memory();
Trilok Sonib9410792012-04-07 15:37:13 +0530926}
927
928static int msm7627a_paddr_to_memtype(unsigned int paddr)
929{
930 return MEMTYPE_EBI1;
931}
932
933static struct reserve_info msm7627a_reserve_info __initdata = {
934 .memtype_reserve_table = msm7627a_reserve_table,
935 .calculate_reserve_sizes = msm7627a_calculate_reserve_sizes,
936 .paddr_to_memtype = msm7627a_paddr_to_memtype,
937};
938
939static void __init msm7627a_reserve(void)
940{
941 reserve_info = &msm7627a_reserve_info;
942 msm_reserve();
943 memblock_remove(MSM8625_WARM_BOOT_PHYS, SZ_32);
944}
945
946static void __init msm8625_reserve(void)
947{
948 memblock_remove(MSM8625_SECONDARY_PHYS, SZ_8);
949 msm7627a_reserve();
950}
951
952static void msmqrd_adsp_add_pdev(void)
953{
954 int rc = 0;
955 struct rpc_board_dev *rpc_adsp_pdev;
956
957 rpc_adsp_pdev = kzalloc(sizeof(struct rpc_board_dev), GFP_KERNEL);
958 if (rpc_adsp_pdev == NULL) {
959 pr_err("%s: Memory Allocation failure\n", __func__);
960 return;
961 }
962 rpc_adsp_pdev->prog = ADSP_RPC_PROG;
963
964 if (cpu_is_msm8625())
965 rpc_adsp_pdev->pdev = msm8625_device_adsp;
966 else
967 rpc_adsp_pdev->pdev = msm_adsp_device;
968 rc = msm_rpc_add_board_dev(rpc_adsp_pdev, 1);
969 if (rc < 0) {
970 pr_err("%s: return val: %d\n", __func__, rc);
971 kfree(rpc_adsp_pdev);
972 }
973}
974
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530975static void __init msm7627a_device_i2c_init(void)
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530976{
977 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
978 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
979}
980
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530981static void __init msm8625_device_i2c_init(void)
982{
983 msm8625_gsbi0_qup_i2c_device.dev.platform_data
984 = &msm_gsbi0_qup_i2c_pdata;
985 msm8625_gsbi1_qup_i2c_device.dev.platform_data
986 = &msm_gsbi1_qup_i2c_pdata;
987}
988
Pankaj Kumar3cec0582011-11-18 11:13:29 +0530989static struct platform_device msm_proccomm_regulator_dev = {
990 .name = PROCCOMM_REGULATOR_DEV_NAME,
991 .id = -1,
992 .dev = {
993 .platform_data = &msm7x27a_proccomm_regulator_data
994 }
995};
996
997static void __init msm7627a_init_regulators(void)
998{
999 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1000 if (rc)
1001 pr_err("%s: could not register regulator device: %d\n",
1002 __func__, rc);
1003}
1004
Santosh Sajjan374d6592012-01-19 23:16:46 +05301005static int __init msm_qrd_init_ar6000pm(void)
1006{
1007 msm_wlan_ar6000_pm_device.dev.platform_data = &ar600x_wlan_power;
1008 return platform_device_register(&msm_wlan_ar6000_pm_device);
1009}
1010
Taniya Dase380a2d2012-03-09 13:02:41 +05301011static void __init msm_add_footswitch_devices(void)
1012{
1013 platform_add_devices(msm_footswitch_devices,
1014 msm_num_footswitch_devices);
1015}
1016
Stephen Boyd668d7652012-04-25 11:31:01 -07001017static void __init add_platform_devices(void)
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301018{
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301019 if (machine_is_msm8625_evb() || machine_is_msm8625_qrd7()
1020 || machine_is_msm8625_evt()) {
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301021 platform_add_devices(msm8625_evb_devices,
1022 ARRAY_SIZE(msm8625_evb_devices));
Aparna Mallavarapubeafcbc2012-03-13 16:57:39 +05301023 platform_add_devices(qrd3_devices,
Taniya Dasbd096542012-03-15 17:43:45 +05301024 ARRAY_SIZE(qrd3_devices));
Aparna Mallavarapubeafcbc2012-03-13 16:57:39 +05301025 } else {
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301026 platform_add_devices(qrd7627a_devices,
1027 ARRAY_SIZE(qrd7627a_devices));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301028 }
Taniya Dasbd096542012-03-15 17:43:45 +05301029
Aparna Mallavarapu0b69ca22012-03-26 15:58:35 +05301030 if (machine_is_msm7627a_qrd3() || machine_is_msm7627a_evb())
Taniya Dasbd096542012-03-15 17:43:45 +05301031 platform_add_devices(qrd3_devices,
Aparna Mallavarapu0b69ca22012-03-26 15:58:35 +05301032 ARRAY_SIZE(qrd3_devices));
Taniya Dasbd096542012-03-15 17:43:45 +05301033
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301034 platform_add_devices(common_devices,
1035 ARRAY_SIZE(common_devices));
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301036}
1037
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301038#define UART1DM_RX_GPIO 45
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301039static void __init qrd7627a_uart1dm_config(void)
1040{
1041 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
1042 if (cpu_is_msm8625())
1043 msm8625_device_uart_dm1.dev.platform_data =
1044 &msm_uart_dm1_pdata;
1045 else
1046 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
1047}
1048
1049static void __init qrd7627a_otg_gadget(void)
1050{
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301051 if (cpu_is_msm8625()) {
Murali Nalajala6ff8fb12012-05-02 18:50:50 +05301052 msm_otg_pdata.swfi_latency = msm8625_pm_data
1053 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT].latency;
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301054 msm8625_device_otg.dev.platform_data = &msm_otg_pdata;
1055 msm8625_device_gadget_peripheral.dev.platform_data =
1056 &msm_gadget_pdata;
1057
1058 } else {
Murali Nalajala6ff8fb12012-05-02 18:50:50 +05301059 msm_otg_pdata.swfi_latency = msm7627a_pm_data
1060 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301061 msm_device_otg.dev.platform_data = &msm_otg_pdata;
1062 msm_device_gadget_peripheral.dev.platform_data =
1063 &msm_gadget_pdata;
1064 }
1065}
1066
Taniya Dasbd096542012-03-15 17:43:45 +05301067static void __init msm_pm_init(void)
1068{
Taniya Dasbd096542012-03-15 17:43:45 +05301069
Aparna Mallavarapu6d969eb2012-04-03 15:10:25 +05301070 if (!cpu_is_msm8625()) {
Taniya Dasbd096542012-03-15 17:43:45 +05301071 msm_pm_set_platform_data(msm7627a_pm_data,
1072 ARRAY_SIZE(msm7627a_pm_data));
1073 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
1074 } else {
1075 msm_pm_set_platform_data(msm8625_pm_data,
1076 ARRAY_SIZE(msm8625_pm_data));
1077 BUG_ON(msm_pm_boot_init(&msm_pm_8625_boot_pdata));
1078 msm8x25_spm_device_init();
1079 }
1080}
1081
Taniya Dasc868a2e2012-01-03 10:18:47 +05301082static void __init msm_qrd_init(void)
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301083{
1084 msm7x2x_misc_init();
Pankaj Kumar3cec0582011-11-18 11:13:29 +05301085 msm7627a_init_regulators();
Trilok Sonib9410792012-04-07 15:37:13 +05301086 msmqrd_adsp_add_pdev();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301087
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301088 if (cpu_is_msm8625())
1089 msm8625_device_i2c_init();
1090 else
1091 msm7627a_device_i2c_init();
1092
1093 /* uart1dm*/
1094 qrd7627a_uart1dm_config();
1095 /*OTG gadget*/
1096 qrd7627a_otg_gadget();
Taniya Dasc868a2e2012-01-03 10:18:47 +05301097
Taniya Dase380a2d2012-03-09 13:02:41 +05301098 msm_add_footswitch_devices();
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301099 add_platform_devices();
Taniya Dasc868a2e2012-01-03 10:18:47 +05301100
Santosh Sajjan374d6592012-01-19 23:16:46 +05301101 /* Ensure ar6000pm device is registered before MMC/SDC */
1102 msm_qrd_init_ar6000pm();
Chintan Pandyacf467fc2011-12-01 17:11:11 +05301103 msm7627a_init_mmc();
1104
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301105#ifdef CONFIG_USB_EHCI_MSM_72K
1106 msm7627a_init_host();
1107#endif
Taniya Dasbd096542012-03-15 17:43:45 +05301108 msm_pm_init();
Murali Nalajalaa1827842011-11-13 14:12:39 +05301109
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05301110 msm_pm_register_irqs();
Taniya Das0a5303a2011-08-23 18:47:48 +05301111 msm_fb_add_devices();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301112
1113#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Chintan Pandya13490c02011-12-20 13:03:36 +05301114 msm7627a_bt_power_init();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301115#endif
Taniya Dasda408822011-09-06 12:54:06 +05301116
Chintan Pandya40762702011-12-06 13:47:06 +05301117 msm7627a_camera_init();
Chintan Pandya0d453192012-03-09 13:20:33 +05301118 qrd7627a_add_io_devices();
Aparna Mallavarapud95d8fc2012-03-08 12:07:37 +05301119 msm7x25a_kgsl_3d0_init();
Sudhakara Rao Tentu38ad6e12012-03-30 15:25:18 -07001120 msm8x25_kgsl_3d0_init();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301121}
1122
1123static void __init qrd7627a_init_early(void)
1124{
1125 msm_msm7627a_allocate_memory_regions();
1126}
1127
1128MACHINE_START(MSM7627A_QRD1, "QRD MSM7627a QRD1")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001129 .atag_offset = 0x100,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301130 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301131 .reserve = msm7627a_reserve,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301132 .init_irq = msm_init_irq,
Taniya Dasc868a2e2012-01-03 10:18:47 +05301133 .init_machine = msm_qrd_init,
1134 .timer = &msm_timer,
1135 .init_early = qrd7627a_init_early,
1136 .handle_irq = vic_handle_irq,
1137MACHINE_END
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301138MACHINE_START(MSM7627A_QRD3, "QRD MSM7627a QRD3")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001139 .atag_offset = 0x100,
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301140 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301141 .reserve = msm7627a_reserve,
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301142 .init_irq = msm_init_irq,
1143 .init_machine = msm_qrd_init,
1144 .timer = &msm_timer,
1145 .init_early = qrd7627a_init_early,
1146 .handle_irq = vic_handle_irq,
1147MACHINE_END
Taniya Dasc868a2e2012-01-03 10:18:47 +05301148MACHINE_START(MSM7627A_EVB, "QRD MSM7627a EVB")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001149 .atag_offset = 0x100,
Taniya Dasc868a2e2012-01-03 10:18:47 +05301150 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301151 .reserve = msm7627a_reserve,
Taniya Dasc868a2e2012-01-03 10:18:47 +05301152 .init_irq = msm_init_irq,
1153 .init_machine = msm_qrd_init,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301154 .timer = &msm_timer,
1155 .init_early = qrd7627a_init_early,
Pankaj Kumarbf8a2a32011-10-21 11:47:21 +05301156 .handle_irq = vic_handle_irq,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301157MACHINE_END
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301158MACHINE_START(MSM8625_EVB, "QRD MSM8625 EVB")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001159 .atag_offset = 0x100,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301160 .map_io = msm8625_map_io,
Trilok Sonib9410792012-04-07 15:37:13 +05301161 .reserve = msm8625_reserve,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301162 .init_irq = msm8625_init_irq,
1163 .init_machine = msm_qrd_init,
1164 .timer = &msm_timer,
1165 .init_early = qrd7627a_init_early,
1166 .handle_irq = gic_handle_irq,
1167MACHINE_END
Taniya Dasbd096542012-03-15 17:43:45 +05301168MACHINE_START(MSM8625_QRD7, "QRD MSM8625 QRD7")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001169 .atag_offset = 0x100,
Taniya Dasbd096542012-03-15 17:43:45 +05301170 .map_io = msm8625_map_io,
Trilok Sonib9410792012-04-07 15:37:13 +05301171 .reserve = msm8625_reserve,
Taniya Dasbd096542012-03-15 17:43:45 +05301172 .init_irq = msm8625_init_irq,
1173 .init_machine = msm_qrd_init,
1174 .timer = &msm_timer,
1175 .init_early = qrd7627a_init_early,
1176 .handle_irq = gic_handle_irq,
1177MACHINE_END
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301178MACHINE_START(MSM8625_EVT, "QRD MSM8625 EVT")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001179 .atag_offset = 0x100,
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301180 .map_io = msm8625_map_io,
1181 .reserve = msm8625_reserve,
1182 .init_irq = msm8625_init_irq,
1183 .init_machine = msm_qrd_init,
1184 .timer = &msm_timer,
1185 .init_early = qrd7627a_init_early,
1186 .handle_irq = gic_handle_irq,
1187MACHINE_END