blob: 713621271e98cd0cecb3ae1305f9dd16792a9b4f [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>
Steve Muckle75c34ca2012-06-12 14:27:40 -070034#include <linux/regulator/msm-gpio-regulator.h>
Chintan Pandya43d0a342012-06-08 19:45:56 +053035#include <linux/ion.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053036#include <asm/mach/mmc.h>
37#include <asm/mach-types.h>
38#include <asm/mach/arch.h>
Chintan Pandyaf4ad4002012-02-28 19:49:03 +053039#include <asm/hardware/gic.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053040#include <mach/board.h>
41#include <mach/msm_iomap.h>
42#include <mach/msm_hsusb.h>
43#include <mach/rpc_hsusb.h>
44#include <mach/rpc_pmapp.h>
45#include <mach/usbdiag.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053046#include <mach/msm_memtypes.h>
47#include <mach/msm_serial_hs.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053048#include <mach/pmic.h>
49#include <mach/socinfo.h>
50#include <mach/vreg.h>
51#include <mach/rpc_pmapp.h>
52#include <mach/msm_battery.h>
53#include <mach/rpc_server_handset.h>
54#include <mach/socinfo.h>
Pankaj Kumar27c02642011-09-22 15:55:55 +053055#include "board-msm7x27a-regulator.h"
Taniya Dasc98bfbc2011-08-23 09:58:55 +053056#include "devices.h"
57#include "devices-msm7x2xa.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080058#include "pm.h"
Taniya Dasc98bfbc2011-08-23 09:58:55 +053059#include "timer.h"
Murali Nalajalaa1827842011-11-13 14:12:39 +053060#include "pm-boot.h"
Pankaj Kumar3cec0582011-11-18 11:13:29 +053061#include "board-msm7x27a-regulator.h"
Chintan Pandyacf467fc2011-12-01 17:11:11 +053062#include "board-msm7627a.h"
Taniya Dasc98bfbc2011-08-23 09:58:55 +053063
Trilok Sonib9410792012-04-07 15:37:13 +053064#define PMEM_KERNEL_EBI1_SIZE 0x3A000
Sidipotu Ashok4f1ddc92012-04-11 13:51:34 +053065#define MSM_PMEM_AUDIO_SIZE 0x1F4000
Trilok Sonib9410792012-04-07 15:37:13 +053066#define BAHAMA_SLAVE_ID_FM_REG 0x02
67#define FM_GPIO 83
68#define BT_PCM_BCLK_MODE 0x88
69#define BT_PCM_DIN_MODE 0x89
70#define BT_PCM_DOUT_MODE 0x8A
71#define BT_PCM_SYNC_MODE 0x8B
72#define FM_I2S_SD_MODE 0x8E
73#define FM_I2S_WS_MODE 0x8F
74#define FM_I2S_SCK_MODE 0x90
75#define I2C_PIN_CTL 0x15
76#define I2C_NORMAL 0x40
77
Manish Dewanganfbad2822012-08-22 10:33:11 +053078#define SNDDEV_CAP_NONE 0x0
79#define SNDDEV_CAP_RX 0x1 /* RX direction */
80#define SNDDEV_CAP_TX 0x2 /* TX direction */
81#define SNDDEV_CAP_VOICE 0x4 /* Support voice call */
82#define SNDDEV_CAP_FM 0x10 /* Support FM radio */
83#define SNDDEV_CAP_TTY 0x20 /* Support TTY */
84
Taniya Dasc98bfbc2011-08-23 09:58:55 +053085static struct platform_device msm_wlan_ar6000_pm_device = {
86 .name = "wlan_ar6000_pm_dev",
87 .id = -1,
88};
89
Taniya Dasc98bfbc2011-08-23 09:58:55 +053090static struct msm_gpio qup_i2c_gpios_io[] = {
91 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
92 "qup_scl" },
93 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
94 "qup_sda" },
95 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
96 "qup_scl" },
97 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
98 "qup_sda" },
99};
100
101static struct msm_gpio qup_i2c_gpios_hw[] = {
102 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
103 "qup_scl" },
104 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
105 "qup_sda" },
106 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
107 "qup_scl" },
108 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
109 "qup_sda" },
110};
111
112static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
113{
114 int rc;
115
116 if (adap_id < 0 || adap_id > 1)
117 return;
118
119 /* Each adapter gets 2 lines from the table */
120 if (config_type)
121 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
122 else
123 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
124 if (rc < 0)
125 pr_err("QUP GPIO request/enable failed: %d\n", rc);
126}
127
128static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
129 .clk_freq = 100000,
130 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
131};
132
133static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
134 .clk_freq = 100000,
135 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
136};
137
Trilok Sonib9410792012-04-07 15:37:13 +0530138#ifdef CONFIG_ARCH_MSM7X27A
Sravan Kumar D.V.N2655b112012-08-02 19:08:30 +0530139#define MSM_PMEM_MDP_SIZE 0x1B00000
Rajeshwar Kurapaty20d7ad12012-06-22 16:11:06 +0530140#define MSM_PMEM_ADSP_SIZE 0x1200000
Chintan Pandya43d0a342012-06-08 19:45:56 +0530141
Chintan Pandya43d0a342012-06-08 19:45:56 +0530142#ifdef CONFIG_ION_MSM
Chintan Pandya62f6c4a2012-08-17 13:30:45 +0530143#define MSM_ION_HEAP_NUM 4
Chintan Pandya43d0a342012-06-08 19:45:56 +0530144static struct platform_device ion_dev;
Chintan Pandya62f6c4a2012-08-17 13:30:45 +0530145static int msm_ion_camera_size;
146static int msm_ion_audio_size;
147static int msm_ion_sf_size;
Chintan Pandya43d0a342012-06-08 19:45:56 +0530148#endif
Trilok Sonib9410792012-04-07 15:37:13 +0530149#endif
150
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530151static struct android_usb_platform_data android_usb_pdata = {
Pankaj Kumar6f841742011-10-10 15:52:14 +0530152 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
Rajkumar Raghupathyc9cb2052012-04-26 13:14:10 +0530153 .cdrom = 1,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530154};
155
156static struct platform_device android_usb_device = {
157 .name = "android_usb",
158 .id = -1,
159 .dev = {
160 .platform_data = &android_usb_pdata,
161 },
162};
163
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530164#ifdef CONFIG_USB_EHCI_MSM_72K
165static void msm_hsusb_vbus_power(unsigned phy_info, int on)
166{
167 int rc = 0;
168 unsigned gpio;
169
Chintan Pandya40762702011-12-06 13:47:06 +0530170 gpio = QRD_GPIO_HOST_VBUS_EN;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530171
172 rc = gpio_request(gpio, "i2c_host_vbus_en");
173 if (rc < 0) {
174 pr_err("failed to request %d GPIO\n", gpio);
175 return;
176 }
177 gpio_direction_output(gpio, !!on);
178 gpio_set_value_cansleep(gpio, !!on);
179 gpio_free(gpio);
180}
181
182static struct msm_usb_host_platform_data msm_usb_host_pdata = {
183 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
184};
185
186static void __init msm7627a_init_host(void)
187{
188 msm_add_host(0, &msm_usb_host_pdata);
189}
190#endif
191
192#ifdef CONFIG_USB_MSM_OTG_72K
193static int hsusb_rpc_connect(int connect)
194{
195 if (connect)
196 return msm_hsusb_rpc_connect();
197 else
198 return msm_hsusb_rpc_close();
199}
200
Pankaj Kumar27c02642011-09-22 15:55:55 +0530201static struct regulator *reg_hsusb;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530202static int msm_hsusb_ldo_init(int init)
203{
Pankaj Kumar27c02642011-09-22 15:55:55 +0530204 int rc = 0;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530205
Pankaj Kumar27c02642011-09-22 15:55:55 +0530206 if (init) {
207 reg_hsusb = regulator_get(NULL, "usb");
208 if (IS_ERR(reg_hsusb)) {
209 rc = PTR_ERR(reg_hsusb);
210 pr_err("%s: could not get regulator: %d\n",
211 __func__, rc);
212 goto out;
213 }
214
215 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
216 if (rc) {
217 pr_err("%s: could not set voltage: %d\n",
218 __func__, rc);
219 goto reg_free;
220 }
221
222 return 0;
223 }
224 /* else fall through */
225reg_free:
226 regulator_put(reg_hsusb);
227out:
228 reg_hsusb = NULL;
229 return rc;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530230}
231
232static int msm_hsusb_ldo_enable(int enable)
233{
234 static int ldo_status;
235
Pankaj Kumar27c02642011-09-22 15:55:55 +0530236 if (IS_ERR_OR_NULL(reg_hsusb))
237 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530238
239 if (ldo_status == enable)
240 return 0;
241
242 ldo_status = enable;
243
Pankaj Kumar27c02642011-09-22 15:55:55 +0530244 return enable ?
245 regulator_enable(reg_hsusb) :
246 regulator_disable(reg_hsusb);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530247}
248
249#ifndef CONFIG_USB_EHCI_MSM_72K
250static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
251{
252 int ret = 0;
253
254 if (init)
255 ret = msm_pm_app_rpc_init(callback);
256 else
257 msm_pm_app_rpc_deinit(callback);
258
259 return ret;
260}
261#endif
262
263static struct msm_otg_platform_data msm_otg_pdata = {
264#ifndef CONFIG_USB_EHCI_MSM_72K
265 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
266#else
267 .vbus_power = msm_hsusb_vbus_power,
268#endif
269 .rpc_connect = hsusb_rpc_connect,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530270 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
271 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
272 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
273 .se1_gating = SE1_GATING_DISABLE,
274 .ldo_init = msm_hsusb_ldo_init,
275 .ldo_enable = msm_hsusb_ldo_enable,
276 .chg_init = hsusb_chg_init,
277 .chg_connected = hsusb_chg_connected,
278 .chg_vbus_draw = hsusb_chg_vbus_draw,
279};
280#endif
281
282static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
283 .is_phy_status_timer_on = 1,
284};
285
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530286#ifdef CONFIG_SERIAL_MSM_HS
287static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
288 .inject_rx_on_wakeup = 1,
289 .rx_to_inject = 0xFD,
290};
291#endif
292static struct msm_pm_platform_data msm7627a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
293 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
294 .idle_supported = 1,
295 .suspend_supported = 1,
296 .idle_enabled = 1,
297 .suspend_enabled = 1,
298 .latency = 16000,
299 .residency = 20000,
300 },
301 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
302 .idle_supported = 1,
303 .suspend_supported = 1,
304 .idle_enabled = 1,
305 .suspend_enabled = 1,
306 .latency = 12000,
307 .residency = 20000,
308 },
309 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
310 .idle_supported = 1,
311 .suspend_supported = 1,
312 .idle_enabled = 0,
313 .suspend_enabled = 1,
314 .latency = 2000,
315 .residency = 0,
316 },
317 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
318 .idle_supported = 1,
319 .suspend_supported = 1,
320 .idle_enabled = 1,
321 .suspend_enabled = 1,
322 .latency = 2,
323 .residency = 0,
324 },
325};
326
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600327static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +0530328 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
329 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600330};
331
Murali Nalajala4c996be2012-03-12 17:05:41 +0530332/* 8625 PM platform data */
333static struct msm_pm_platform_data msm8625_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
334 /* CORE0 entries */
335 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
336 .idle_supported = 1,
337 .suspend_supported = 1,
338 .idle_enabled = 0,
339 .suspend_enabled = 0,
340 .latency = 16000,
341 .residency = 20000,
342 },
343
344 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
345 .idle_supported = 1,
346 .suspend_supported = 1,
347 .idle_enabled = 0,
348 .suspend_enabled = 0,
349 .latency = 12000,
350 .residency = 20000,
351 },
352
353 /* picked latency & redisdency values from 7x30 */
354 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
355 .idle_supported = 1,
356 .suspend_supported = 1,
357 .idle_enabled = 0,
358 .suspend_enabled = 0,
359 .latency = 500,
360 .residency = 6000,
361 },
362
363 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
364 .idle_supported = 1,
365 .suspend_supported = 1,
366 .idle_enabled = 1,
367 .suspend_enabled = 1,
368 .latency = 2,
369 .residency = 10,
370 },
371
372 /* picked latency & redisdency values from 7x30 */
373 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
374 .idle_supported = 1,
375 .suspend_supported = 1,
376 .idle_enabled = 0,
377 .suspend_enabled = 0,
378 .latency = 500,
379 .residency = 6000,
380 },
381
382 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
383 .idle_supported = 1,
384 .suspend_supported = 1,
385 .idle_enabled = 1,
386 .suspend_enabled = 1,
387 .latency = 2,
388 .residency = 10,
389 },
390
391};
392
393static struct msm_pm_boot_platform_data msm_pm_8625_boot_pdata __initdata = {
394 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
395 .v_addr = MSM_CFG_CTL_BASE,
396};
397
Trilok Sonib9410792012-04-07 15:37:13 +0530398static struct android_pmem_platform_data android_pmem_adsp_pdata = {
399 .name = "pmem_adsp",
400 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
401 .cached = 1,
402 .memory_type = MEMTYPE_EBI1,
403};
404
405static struct platform_device android_pmem_adsp_device = {
406 .name = "android_pmem",
407 .id = 1,
408 .dev = { .platform_data = &android_pmem_adsp_pdata },
409};
410
411static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
412static int __init pmem_mdp_size_setup(char *p)
413{
414 pmem_mdp_size = memparse(p, NULL);
415 return 0;
416}
417
418early_param("pmem_mdp_size", pmem_mdp_size_setup);
419
420static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
421static int __init pmem_adsp_size_setup(char *p)
422{
423 pmem_adsp_size = memparse(p, NULL);
424 return 0;
425}
426
427early_param("pmem_adsp_size", pmem_adsp_size_setup);
428
429#define SND(desc, num) { .name = #desc, .id = num }
430static struct snd_endpoint snd_endpoints_list[] = {
431 SND(HANDSET, 0),
432 SND(MONO_HEADSET, 2),
433 SND(HEADSET, 3),
434 SND(SPEAKER, 6),
435 SND(TTY_HEADSET, 8),
436 SND(TTY_VCO, 9),
437 SND(TTY_HCO, 10),
438 SND(BT, 12),
439 SND(IN_S_SADC_OUT_HANDSET, 16),
440 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
441 SND(FM_DIGITAL_STEREO_HEADSET, 26),
442 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
443 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
444 SND(STEREO_HEADSET_AND_SPEAKER, 31),
445 SND(CURRENT, 0x7FFFFFFE),
446 SND(FM_ANALOG_STEREO_HEADSET, 35),
447 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
448};
449#undef SND
450
451static struct msm_snd_endpoints msm_device_snd_endpoints = {
452 .endpoints = snd_endpoints_list,
453 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
454};
455
456static struct platform_device msm_device_snd = {
457 .name = "msm_snd",
458 .id = -1,
459 .dev = {
460 .platform_data = &msm_device_snd_endpoints
461 },
462};
463
Manish Dewanganfbad2822012-08-22 10:33:11 +0530464#define CAD(desc, num, cap) { .name = #desc, .id = num, .capability = cap, }
465static struct cad_endpoint cad_endpoints_list[] = {
466 CAD(NONE, 0, SNDDEV_CAP_NONE),
467 CAD(HANDSET_SPKR, 1, (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE)),
468 CAD(HANDSET_MIC, 2, (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE)),
469 CAD(HEADSET_MIC, 3, (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE)),
470 CAD(HEADSET_SPKR_MONO, 4, (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE)),
471 CAD(HEADSET_SPKR_STEREO, 5, (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE)),
472 CAD(SPEAKER_PHONE_MIC, 6, (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE)),
473 CAD(SPEAKER_PHONE_MONO, 7, (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE)),
474 CAD(SPEAKER_PHONE_STEREO, 8, (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE)),
475 CAD(BT_SCO_MIC, 9, (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE)),
476 CAD(BT_SCO_SPKR, 10, (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE)),
477 CAD(BT_A2DP_SPKR, 11, (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE)),
478 CAD(TTY_HEADSET_MIC, 12, (SNDDEV_CAP_TX | \
479 SNDDEV_CAP_VOICE | SNDDEV_CAP_TTY)),
480 CAD(TTY_HEADSET_SPKR, 13, (SNDDEV_CAP_RX | \
481 SNDDEV_CAP_VOICE | SNDDEV_CAP_TTY)),
482 CAD(HEADSET_STEREO_PLUS_SPKR_MONO_RX, 19, (SNDDEV_CAP_TX | \
483 SNDDEV_CAP_VOICE)),
484 CAD(LP_FM_HEADSET_SPKR_STEREO_RX, 25, (SNDDEV_CAP_TX | SNDDEV_CAP_FM)),
485 CAD(I2S_RX, 26, (SNDDEV_CAP_RX)),
486 CAD(SPEAKER_PHONE_MIC_ENDFIRE, 45, (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE)),
487 CAD(HANDSET_MIC_ENDFIRE, 46, (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE)),
488 CAD(I2S_TX, 48, (SNDDEV_CAP_TX)),
489 CAD(LP_FM_HEADSET_SPKR_STEREO_PLUS_HEADSET_SPKR_STEREO_RX, 57, \
490 (SNDDEV_CAP_FM | SNDDEV_CAP_RX)),
491 CAD(FM_DIGITAL_HEADSET_SPKR_STEREO, 65, \
492 (SNDDEV_CAP_FM | SNDDEV_CAP_RX)),
493 CAD(FM_DIGITAL_SPEAKER_PHONE_MONO, 67, \
494 (SNDDEV_CAP_FM | SNDDEV_CAP_RX)),
495 CAD(FM_DIGITAL_BT_A2DP_SPKR, 69, \
496 (SNDDEV_CAP_FM | SNDDEV_CAP_RX)),
497 CAD(MAX, 80, SNDDEV_CAP_NONE),
498};
499#undef CAD
500
501static struct msm_cad_endpoints msm_device_cad_endpoints = {
502 .endpoints = cad_endpoints_list,
503 .num = sizeof(cad_endpoints_list) / sizeof(struct cad_endpoint)
504};
505
506static struct platform_device msm_device_cad = {
507 .name = "msm_cad",
508 .id = -1,
509 .dev = {
510 .platform_data = &msm_device_cad_endpoints
511 },
512};
513
Trilok Sonib9410792012-04-07 15:37:13 +0530514#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
515 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
516 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
517 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
518 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
Chaithanya Krishna Bacharaju8e838cc2012-08-16 11:32:46 +0530519 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))| \
520 (1<<MSM_ADSP_CODEC_AC3)
Trilok Sonib9410792012-04-07 15:37:13 +0530521#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
522 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
523 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
524 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
525 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
526 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
527#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
528 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
529 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
530 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
531 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
532 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
533#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
534 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
535 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
536 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
537 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
538 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
539#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
540
541static unsigned int dec_concurrency_table[] = {
542 /* Audio LP */
543 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
544 0, 0, 0,
545
546 /* Concurrency 1 */
547 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
548 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
549 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
550 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
551 (DEC4_FORMAT),
552
553 /* Concurrency 2 */
554 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
555 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
556 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
557 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
558 (DEC4_FORMAT),
559
560 /* Concurrency 3 */
561 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
562 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
563 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
564 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
565 (DEC4_FORMAT),
566
567 /* Concurrency 4 */
568 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
569 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
570 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
571 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
572 (DEC4_FORMAT),
573
574 /* Concurrency 5 */
575 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
576 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
577 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
578 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
579 (DEC4_FORMAT),
580
581 /* Concurrency 6 */
Chaithanya Krishna Bacharaju72ab89b2012-05-11 14:24:04 +0530582 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|
583 (1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
584 0, 0, 0, 0,
Trilok Sonib9410792012-04-07 15:37:13 +0530585
586 /* Concurrency 7 */
587 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
588 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
589 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
590 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
591 (DEC4_FORMAT),
592};
593
594#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
595 .module_queueid = queueid, .module_decid = decid, \
596 .nr_codec_support = nr_codec}
597
598static struct msm_adspdec_info dec_info_list[] = {
599 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
600 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
601 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
602 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
603 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
604};
605
606static struct msm_adspdec_database msm_device_adspdec_database = {
607 .num_dec = ARRAY_SIZE(dec_info_list),
608 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
609 ARRAY_SIZE(dec_info_list)),
610 .dec_concurrency_table = dec_concurrency_table,
611 .dec_info_list = dec_info_list,
612};
613
614static struct platform_device msm_device_adspdec = {
615 .name = "msm_adspdec",
616 .id = -1,
617 .dev = {
618 .platform_data = &msm_device_adspdec_database
619 },
620};
621
622static struct android_pmem_platform_data android_pmem_audio_pdata = {
623 .name = "pmem_audio",
624 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
625 .cached = 0,
626 .memory_type = MEMTYPE_EBI1,
627};
628
629static struct platform_device android_pmem_audio_device = {
630 .name = "android_pmem",
631 .id = 2,
632 .dev = { .platform_data = &android_pmem_audio_pdata },
633};
634
635static struct android_pmem_platform_data android_pmem_pdata = {
636 .name = "pmem",
637 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
638 .cached = 1,
639 .memory_type = MEMTYPE_EBI1,
640};
641static struct platform_device android_pmem_device = {
642 .name = "android_pmem",
643 .id = 0,
644 .dev = { .platform_data = &android_pmem_pdata },
645};
646
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530647static u32 msm_calculate_batt_capacity(u32 current_voltage);
648
649static struct msm_psy_batt_pdata msm_psy_batt_data = {
Krishna Vankab3778112012-07-16 11:36:12 +0530650 .voltage_min_design = 3500,
Krishna Vanka9a265e12012-06-04 23:24:26 +0530651 .voltage_max_design = 4200,
Krishna Vankab3778112012-07-16 11:36:12 +0530652 .voltage_fail_safe = 3598,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530653 .avail_chg_sources = AC_CHG | USB_CHG ,
654 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
655 .calculate_capacity = &msm_calculate_batt_capacity,
656};
657
658static u32 msm_calculate_batt_capacity(u32 current_voltage)
659{
660 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
661 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
662
Krishna Vankab3494692012-06-12 15:06:43 +0530663 if (current_voltage <= low_voltage)
664 return 0;
665 else if (current_voltage >= high_voltage)
666 return 100;
667 else
668 return (current_voltage - low_voltage) * 100
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530669 / (high_voltage - low_voltage);
670}
671
672static struct platform_device msm_batt_device = {
673 .name = "msm-battery",
674 .id = -1,
675 .dev.platform_data = &msm_psy_batt_data,
676};
677
Siddartha Mohanadossbc2103f2012-03-20 11:41:48 -0700678static char *msm_adc_surf_device_names[] = {
679 "XO_ADC",
680};
681
682static struct msm_adc_platform_data msm_adc_pdata = {
683 .dev_names = msm_adc_surf_device_names,
684 .num_adc = ARRAY_SIZE(msm_adc_surf_device_names),
685 .target_hw = MSM_8x25,
686};
687
688static struct platform_device msm_adc_device = {
689 .name = "msm_adc",
690 .id = -1,
691 .dev = {
692 .platform_data = &msm_adc_pdata,
693 },
694};
695
Utsab Bosecd0bb5e2012-08-07 13:07:28 +0530696#ifdef CONFIG_MSM_RTB
697static struct msm_rtb_platform_data msm7627a_rtb_pdata = {
698 .size = SZ_1M,
699};
700
701static int __init msm_rtb_set_buffer_size(char *p)
702{
703 int s;
704
705 s = memparse(p, NULL);
706 msm7627a_rtb_pdata.size = ALIGN(s, SZ_4K);
707 return 0;
708}
709early_param("msm_rtb_size", msm_rtb_set_buffer_size);
710
711struct platform_device msm7627a_rtb_device = {
712 .name = "msm_rtb",
713 .id = -1,
714 .dev = {
715 .platform_data = &msm7627a_rtb_pdata,
716 },
717};
718#endif
719
Trilok Soni0ed9c4a2012-05-22 17:54:32 +0530720#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio, _active_low) \
721 [GPIO_VREG_ID_##_id] = { \
722 .init_data = { \
723 .constraints = { \
724 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
725 }, \
726 .num_consumer_supplies = \
727 ARRAY_SIZE(vreg_consumers_##_id), \
728 .consumer_supplies = vreg_consumers_##_id, \
729 }, \
730 .regulator_name = _reg_name, \
731 .active_low = _active_low, \
732 .gpio_label = _gpio_label, \
733 .gpio = _gpio, \
734 }
735
736#define GPIO_VREG_ID_EXT_2P85V 0
737#define GPIO_VREG_ID_EXT_1P8V 1
738
739static struct regulator_consumer_supply vreg_consumers_EXT_2P85V[] = {
Raju P.L.S.S.S.N4d01b2c2012-06-13 20:13:27 +0530740 REGULATOR_SUPPLY("cam_ov5647_avdd", "0-006c"),
741 REGULATOR_SUPPLY("cam_ov7692_avdd", "0-0078"),
742 REGULATOR_SUPPLY("cam_ov8825_avdd", "0-000d"),
Trilok Soni0ed9c4a2012-05-22 17:54:32 +0530743 REGULATOR_SUPPLY("lcd_vdd", "mipi_dsi.1"),
744};
745
746static struct regulator_consumer_supply vreg_consumers_EXT_1P8V[] = {
Raju P.L.S.S.S.N4d01b2c2012-06-13 20:13:27 +0530747 REGULATOR_SUPPLY("cam_ov5647_vdd", "0-006c"),
748 REGULATOR_SUPPLY("cam_ov7692_vdd", "0-0078"),
749 REGULATOR_SUPPLY("cam_ov8825_vdd", "0-000d"),
Trilok Soni0ed9c4a2012-05-22 17:54:32 +0530750 REGULATOR_SUPPLY("lcd_vddi", "mipi_dsi.1"),
751};
752
753/* GPIO regulator constraints */
754static struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
755 GPIO_VREG_INIT(EXT_2P85V, "ext_2p85v", "ext_2p85v_en", 35, 0),
756 GPIO_VREG_INIT(EXT_1P8V, "ext_1p8v", "ext_1p8v_en", 40, 0),
757};
758
759/* GPIO regulator */
Aparna Mallavarapu336c78d2012-07-02 19:43:18 +0530760static struct platform_device qrd_vreg_gpio_ext_2p85v __devinitdata = {
Trilok Soni0ed9c4a2012-05-22 17:54:32 +0530761 .name = GPIO_REGULATOR_DEV_NAME,
762 .id = 35,
763 .dev = {
764 .platform_data =
765 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_2P85V],
766 },
767};
768
Aparna Mallavarapu336c78d2012-07-02 19:43:18 +0530769static struct platform_device qrd_vreg_gpio_ext_1p8v __devinitdata = {
Trilok Soni0ed9c4a2012-05-22 17:54:32 +0530770 .name = GPIO_REGULATOR_DEV_NAME,
771 .id = 40,
772 .dev = {
773 .platform_data =
774 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_1P8V],
775 },
776};
777
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530778static struct platform_device *common_devices[] __initdata = {
779 &android_usb_device,
Trilok Sonib9410792012-04-07 15:37:13 +0530780 &android_pmem_device,
781 &android_pmem_adsp_device,
782 &android_pmem_audio_device,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530783 &msm_batt_device,
Trilok Sonib9410792012-04-07 15:37:13 +0530784 &msm_device_adspdec,
785 &msm_device_snd,
Manish Dewanganfbad2822012-08-22 10:33:11 +0530786 &msm_device_cad,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530787 &asoc_msm_pcm,
788 &asoc_msm_dai0,
789 &asoc_msm_dai1,
Siddartha Mohanadossbc2103f2012-03-20 11:41:48 -0700790 &msm_adc_device,
Utsab Bosecd0bb5e2012-08-07 13:07:28 +0530791#ifdef CONFIG_MSM_RTB
792 &msm7627a_rtb_device,
793#endif
Chintan Pandya43d0a342012-06-08 19:45:56 +0530794#ifdef CONFIG_ION_MSM
795 &ion_dev,
796#endif
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530797};
798
799static struct platform_device *qrd7627a_devices[] __initdata = {
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530800 &msm_device_dmov,
801 &msm_device_smd,
802 &msm_device_uart1,
803 &msm_device_uart_dm1,
804 &msm_gsbi0_qup_i2c_device,
805 &msm_gsbi1_qup_i2c_device,
806 &msm_device_otg,
807 &msm_device_gadget_peripheral,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530808 &msm_kgsl_3d0,
Aparna Mallavarapu336c78d2012-07-02 19:43:18 +0530809 &qrd_vreg_gpio_ext_2p85v,
810 &qrd_vreg_gpio_ext_1p8v,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530811};
812
Chintan Pandyab1bad0e2012-02-06 19:04:51 +0530813static struct platform_device *qrd3_devices[] __initdata = {
814 &msm_device_nand,
815};
816
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530817static struct platform_device *msm8625_evb_devices[] __initdata = {
818 &msm8625_device_dmov,
819 &msm8625_device_smd,
820 &msm8625_gsbi0_qup_i2c_device,
821 &msm8625_gsbi1_qup_i2c_device,
822 &msm8625_device_uart1,
Ram Mohan Korukonda5ee9fb82012-03-09 12:10:01 +0530823 &msm8625_device_uart_dm1,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530824 &msm8625_device_otg,
825 &msm8625_device_gadget_peripheral,
Aparna Mallavarapud95d8fc2012-03-08 12:07:37 +0530826 &msm8625_kgsl_3d0,
Aparna Mallavarapu336c78d2012-07-02 19:43:18 +0530827 &qrd_vreg_gpio_ext_2p85v,
828 &qrd_vreg_gpio_ext_1p8v,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530829};
830
Trilok Sonib9410792012-04-07 15:37:13 +0530831static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
832static int __init pmem_kernel_ebi1_size_setup(char *p)
833{
834 pmem_kernel_ebi1_size = memparse(p, NULL);
835 return 0;
836}
837early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
838
839static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
840static int __init pmem_audio_size_setup(char *p)
841{
842 pmem_audio_size = memparse(p, NULL);
843 return 0;
844}
845early_param("pmem_audio_size", pmem_audio_size_setup);
846
Chintan Pandya62f6c4a2012-08-17 13:30:45 +0530847static void fix_sizes(void)
848{
849#ifdef CONFIG_ION_MSM
850 msm_ion_camera_size = pmem_adsp_size;
851 msm_ion_audio_size = (MSM_PMEM_AUDIO_SIZE + PMEM_KERNEL_EBI1_SIZE);
852 msm_ion_sf_size = pmem_mdp_size;
853#endif
854}
855
Chintan Pandya43d0a342012-06-08 19:45:56 +0530856#ifdef CONFIG_ION_MSM
857#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
858static struct ion_co_heap_pdata co_ion_pdata = {
859 .adjacent_mem_id = INVALID_HEAP_ID,
860 .align = PAGE_SIZE,
861};
862#endif
863
864/**
865 * These heaps are listed in the order they will be allocated.
866 * Don't swap the order unless you know what you are doing!
867 */
868static struct ion_platform_data ion_pdata = {
869 .nr = MSM_ION_HEAP_NUM,
Chintan Pandya8ce738d2012-07-27 13:21:06 +0530870 .has_outer_cache = 1,
Chintan Pandya43d0a342012-06-08 19:45:56 +0530871 .heaps = {
872 {
873 .id = ION_SYSTEM_HEAP_ID,
874 .type = ION_HEAP_TYPE_SYSTEM,
875 .name = ION_VMALLOC_HEAP_NAME,
876 },
877#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
878 /* PMEM_ADSP = CAMERA */
879 {
880 .id = ION_CAMERA_HEAP_ID,
881 .type = ION_HEAP_TYPE_CARVEOUT,
882 .name = ION_CAMERA_HEAP_NAME,
Chintan Pandya43d0a342012-06-08 19:45:56 +0530883 .memory_type = ION_EBI_TYPE,
Chintan Pandya43d0a342012-06-08 19:45:56 +0530884 .extra_data = (void *)&co_ion_pdata,
885 },
886 /* PMEM_AUDIO */
887 {
888 .id = ION_AUDIO_HEAP_ID,
889 .type = ION_HEAP_TYPE_CARVEOUT,
890 .name = ION_AUDIO_HEAP_NAME,
Chintan Pandya43d0a342012-06-08 19:45:56 +0530891 .memory_type = ION_EBI_TYPE,
Chintan Pandya43d0a342012-06-08 19:45:56 +0530892 .extra_data = (void *)&co_ion_pdata,
893 },
894 /* PMEM_MDP = SF */
895 {
896 .id = ION_SF_HEAP_ID,
897 .type = ION_HEAP_TYPE_CARVEOUT,
898 .name = ION_SF_HEAP_NAME,
Chintan Pandya43d0a342012-06-08 19:45:56 +0530899 .memory_type = ION_EBI_TYPE,
Chintan Pandya43d0a342012-06-08 19:45:56 +0530900 .extra_data = (void *)&co_ion_pdata,
901 },
902#endif
903 }
904};
905
906static struct platform_device ion_dev = {
907 .name = "ion-msm",
908 .id = 1,
909 .dev = { .platform_data = &ion_pdata },
910};
911#endif
912
Trilok Sonib9410792012-04-07 15:37:13 +0530913static struct memtype_reserve msm7627a_reserve_table[] __initdata = {
914 [MEMTYPE_SMI] = {
915 },
916 [MEMTYPE_EBI0] = {
917 .flags = MEMTYPE_FLAGS_1M_ALIGN,
918 },
919 [MEMTYPE_EBI1] = {
920 .flags = MEMTYPE_FLAGS_1M_ALIGN,
921 },
922};
923
Utsab Bosecd0bb5e2012-08-07 13:07:28 +0530924#ifdef CONFIG_MSM_RTB
925static void __init reserve_rtb_memory(void)
926{
927 msm7627a_reserve_table[MEMTYPE_EBI1].size += msm7627a_rtb_pdata.size;
928}
929#else
930static void __init reserve_rtb_memory(void)
931{
932}
933#endif
934
Taniya Das720c5c32012-05-18 14:08:14 +0530935#ifdef CONFIG_ANDROID_PMEM
Chintan Pandya43d0a342012-06-08 19:45:56 +0530936#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Taniya Das720c5c32012-05-18 14:08:14 +0530937static struct android_pmem_platform_data *pmem_pdata_array[] __initdata = {
938 &android_pmem_adsp_pdata,
939 &android_pmem_audio_pdata,
940 &android_pmem_pdata,
941};
942#endif
Chintan Pandya43d0a342012-06-08 19:45:56 +0530943#endif
Taniya Das720c5c32012-05-18 14:08:14 +0530944
Trilok Sonib9410792012-04-07 15:37:13 +0530945static void __init size_pmem_devices(void)
946{
947#ifdef CONFIG_ANDROID_PMEM
Chintan Pandya43d0a342012-06-08 19:45:56 +0530948#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Trilok Sonib9410792012-04-07 15:37:13 +0530949 android_pmem_adsp_pdata.size = pmem_adsp_size;
950 android_pmem_pdata.size = pmem_mdp_size;
951 android_pmem_audio_pdata.size = pmem_audio_size;
Chintan Pandya43d0a342012-06-08 19:45:56 +0530952#endif
Trilok Sonib9410792012-04-07 15:37:13 +0530953#endif
954}
955
Chintan Pandya43d0a342012-06-08 19:45:56 +0530956#ifdef CONFIG_ANDROID_PMEM
957#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Trilok Sonib9410792012-04-07 15:37:13 +0530958static void __init reserve_memory_for(struct android_pmem_platform_data *p)
959{
960 msm7627a_reserve_table[p->memory_type].size += p->size;
961}
Chintan Pandya43d0a342012-06-08 19:45:56 +0530962#endif
963#endif
Trilok Sonib9410792012-04-07 15:37:13 +0530964
965static void __init reserve_pmem_memory(void)
966{
967#ifdef CONFIG_ANDROID_PMEM
Chintan Pandya43d0a342012-06-08 19:45:56 +0530968#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Taniya Das720c5c32012-05-18 14:08:14 +0530969 unsigned int i;
970 for (i = 0; i < ARRAY_SIZE(pmem_pdata_array); ++i)
971 reserve_memory_for(pmem_pdata_array[i]);
972
Trilok Sonib9410792012-04-07 15:37:13 +0530973 msm7627a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
974#endif
Chintan Pandya43d0a342012-06-08 19:45:56 +0530975#endif
976}
977
Chintan Pandya62f6c4a2012-08-17 13:30:45 +0530978static void __init size_ion_devices(void)
979{
980#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
981 ion_pdata.heaps[1].size = msm_ion_camera_size;
982 ion_pdata.heaps[2].size = msm_ion_audio_size;
983 ion_pdata.heaps[3].size = msm_ion_sf_size;
984#endif
985}
986
Chintan Pandya43d0a342012-06-08 19:45:56 +0530987static void __init reserve_ion_memory(void)
988{
989#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
Chintan Pandya62f6c4a2012-08-17 13:30:45 +0530990 msm7627a_reserve_table[MEMTYPE_EBI1].size += msm_ion_camera_size;
991 msm7627a_reserve_table[MEMTYPE_EBI1].size += msm_ion_audio_size;
992 msm7627a_reserve_table[MEMTYPE_EBI1].size += msm_ion_sf_size;
Chintan Pandya43d0a342012-06-08 19:45:56 +0530993#endif
Trilok Sonib9410792012-04-07 15:37:13 +0530994}
995
996static void __init msm7627a_calculate_reserve_sizes(void)
997{
Chintan Pandya62f6c4a2012-08-17 13:30:45 +0530998 fix_sizes();
Trilok Sonib9410792012-04-07 15:37:13 +0530999 size_pmem_devices();
1000 reserve_pmem_memory();
Chintan Pandya62f6c4a2012-08-17 13:30:45 +05301001 size_ion_devices();
Chintan Pandya43d0a342012-06-08 19:45:56 +05301002 reserve_ion_memory();
Utsab Bosecd0bb5e2012-08-07 13:07:28 +05301003 reserve_rtb_memory();
Trilok Sonib9410792012-04-07 15:37:13 +05301004}
1005
1006static int msm7627a_paddr_to_memtype(unsigned int paddr)
1007{
1008 return MEMTYPE_EBI1;
1009}
1010
1011static struct reserve_info msm7627a_reserve_info __initdata = {
1012 .memtype_reserve_table = msm7627a_reserve_table,
1013 .calculate_reserve_sizes = msm7627a_calculate_reserve_sizes,
1014 .paddr_to_memtype = msm7627a_paddr_to_memtype,
1015};
1016
1017static void __init msm7627a_reserve(void)
1018{
1019 reserve_info = &msm7627a_reserve_info;
1020 msm_reserve();
1021 memblock_remove(MSM8625_WARM_BOOT_PHYS, SZ_32);
1022}
1023
1024static void __init msm8625_reserve(void)
1025{
1026 memblock_remove(MSM8625_SECONDARY_PHYS, SZ_8);
1027 msm7627a_reserve();
1028}
1029
1030static void msmqrd_adsp_add_pdev(void)
1031{
1032 int rc = 0;
1033 struct rpc_board_dev *rpc_adsp_pdev;
1034
1035 rpc_adsp_pdev = kzalloc(sizeof(struct rpc_board_dev), GFP_KERNEL);
1036 if (rpc_adsp_pdev == NULL) {
1037 pr_err("%s: Memory Allocation failure\n", __func__);
1038 return;
1039 }
1040 rpc_adsp_pdev->prog = ADSP_RPC_PROG;
1041
1042 if (cpu_is_msm8625())
1043 rpc_adsp_pdev->pdev = msm8625_device_adsp;
1044 else
1045 rpc_adsp_pdev->pdev = msm_adsp_device;
1046 rc = msm_rpc_add_board_dev(rpc_adsp_pdev, 1);
1047 if (rc < 0) {
1048 pr_err("%s: return val: %d\n", __func__, rc);
1049 kfree(rpc_adsp_pdev);
1050 }
1051}
1052
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301053static void __init msm7627a_device_i2c_init(void)
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301054{
1055 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
1056 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
1057}
1058
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301059static void __init msm8625_device_i2c_init(void)
1060{
1061 msm8625_gsbi0_qup_i2c_device.dev.platform_data
1062 = &msm_gsbi0_qup_i2c_pdata;
1063 msm8625_gsbi1_qup_i2c_device.dev.platform_data
1064 = &msm_gsbi1_qup_i2c_pdata;
1065}
1066
Pankaj Kumar3cec0582011-11-18 11:13:29 +05301067static struct platform_device msm_proccomm_regulator_dev = {
1068 .name = PROCCOMM_REGULATOR_DEV_NAME,
1069 .id = -1,
1070 .dev = {
1071 .platform_data = &msm7x27a_proccomm_regulator_data
1072 }
1073};
1074
1075static void __init msm7627a_init_regulators(void)
1076{
1077 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1078 if (rc)
1079 pr_err("%s: could not register regulator device: %d\n",
1080 __func__, rc);
1081}
1082
Santosh Sajjan374d6592012-01-19 23:16:46 +05301083static int __init msm_qrd_init_ar6000pm(void)
1084{
1085 msm_wlan_ar6000_pm_device.dev.platform_data = &ar600x_wlan_power;
1086 return platform_device_register(&msm_wlan_ar6000_pm_device);
1087}
1088
Taniya Dase380a2d2012-03-09 13:02:41 +05301089static void __init msm_add_footswitch_devices(void)
1090{
1091 platform_add_devices(msm_footswitch_devices,
1092 msm_num_footswitch_devices);
1093}
1094
Stephen Boyd668d7652012-04-25 11:31:01 -07001095static void __init add_platform_devices(void)
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301096{
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301097 if (machine_is_msm8625_evb() || machine_is_msm8625_qrd7()
1098 || machine_is_msm8625_evt()) {
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301099 platform_add_devices(msm8625_evb_devices,
1100 ARRAY_SIZE(msm8625_evb_devices));
Aparna Mallavarapubeafcbc2012-03-13 16:57:39 +05301101 platform_add_devices(qrd3_devices,
Taniya Dasbd096542012-03-15 17:43:45 +05301102 ARRAY_SIZE(qrd3_devices));
Aparna Mallavarapubeafcbc2012-03-13 16:57:39 +05301103 } else {
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301104 platform_add_devices(qrd7627a_devices,
1105 ARRAY_SIZE(qrd7627a_devices));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301106 }
Taniya Dasbd096542012-03-15 17:43:45 +05301107
Aparna Mallavarapu0b69ca22012-03-26 15:58:35 +05301108 if (machine_is_msm7627a_qrd3() || machine_is_msm7627a_evb())
Taniya Dasbd096542012-03-15 17:43:45 +05301109 platform_add_devices(qrd3_devices,
Aparna Mallavarapu0b69ca22012-03-26 15:58:35 +05301110 ARRAY_SIZE(qrd3_devices));
Taniya Dasbd096542012-03-15 17:43:45 +05301111
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301112 platform_add_devices(common_devices,
1113 ARRAY_SIZE(common_devices));
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301114}
1115
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301116#define UART1DM_RX_GPIO 45
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301117static void __init qrd7627a_uart1dm_config(void)
1118{
1119 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
1120 if (cpu_is_msm8625())
1121 msm8625_device_uart_dm1.dev.platform_data =
1122 &msm_uart_dm1_pdata;
1123 else
1124 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
1125}
1126
1127static void __init qrd7627a_otg_gadget(void)
1128{
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301129 if (cpu_is_msm8625()) {
Murali Nalajala6ff8fb12012-05-02 18:50:50 +05301130 msm_otg_pdata.swfi_latency = msm8625_pm_data
1131 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT].latency;
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301132 msm8625_device_otg.dev.platform_data = &msm_otg_pdata;
1133 msm8625_device_gadget_peripheral.dev.platform_data =
1134 &msm_gadget_pdata;
1135
1136 } else {
Murali Nalajala6ff8fb12012-05-02 18:50:50 +05301137 msm_otg_pdata.swfi_latency = msm7627a_pm_data
1138 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301139 msm_device_otg.dev.platform_data = &msm_otg_pdata;
1140 msm_device_gadget_peripheral.dev.platform_data =
1141 &msm_gadget_pdata;
1142 }
1143}
1144
Taniya Dasbd096542012-03-15 17:43:45 +05301145static void __init msm_pm_init(void)
1146{
Taniya Dasbd096542012-03-15 17:43:45 +05301147
Aparna Mallavarapu6d969eb2012-04-03 15:10:25 +05301148 if (!cpu_is_msm8625()) {
Taniya Dasbd096542012-03-15 17:43:45 +05301149 msm_pm_set_platform_data(msm7627a_pm_data,
1150 ARRAY_SIZE(msm7627a_pm_data));
1151 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
1152 } else {
1153 msm_pm_set_platform_data(msm8625_pm_data,
1154 ARRAY_SIZE(msm8625_pm_data));
1155 BUG_ON(msm_pm_boot_init(&msm_pm_8625_boot_pdata));
1156 msm8x25_spm_device_init();
1157 }
1158}
1159
Taniya Dasc868a2e2012-01-03 10:18:47 +05301160static void __init msm_qrd_init(void)
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301161{
1162 msm7x2x_misc_init();
Pankaj Kumar3cec0582011-11-18 11:13:29 +05301163 msm7627a_init_regulators();
Trilok Sonib9410792012-04-07 15:37:13 +05301164 msmqrd_adsp_add_pdev();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301165
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301166 if (cpu_is_msm8625())
1167 msm8625_device_i2c_init();
1168 else
1169 msm7627a_device_i2c_init();
1170
1171 /* uart1dm*/
1172 qrd7627a_uart1dm_config();
1173 /*OTG gadget*/
1174 qrd7627a_otg_gadget();
Taniya Dasc868a2e2012-01-03 10:18:47 +05301175
Taniya Dase380a2d2012-03-09 13:02:41 +05301176 msm_add_footswitch_devices();
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301177 add_platform_devices();
Taniya Dasc868a2e2012-01-03 10:18:47 +05301178
Santosh Sajjan374d6592012-01-19 23:16:46 +05301179 /* Ensure ar6000pm device is registered before MMC/SDC */
1180 msm_qrd_init_ar6000pm();
Chintan Pandyacf467fc2011-12-01 17:11:11 +05301181 msm7627a_init_mmc();
1182
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301183#ifdef CONFIG_USB_EHCI_MSM_72K
1184 msm7627a_init_host();
1185#endif
Taniya Dasbd096542012-03-15 17:43:45 +05301186 msm_pm_init();
Murali Nalajalaa1827842011-11-13 14:12:39 +05301187
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05301188 msm_pm_register_irqs();
Taniya Das0a5303a2011-08-23 18:47:48 +05301189 msm_fb_add_devices();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301190
1191#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Chintan Pandya13490c02011-12-20 13:03:36 +05301192 msm7627a_bt_power_init();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301193#endif
Taniya Dasda408822011-09-06 12:54:06 +05301194
Chintan Pandya40762702011-12-06 13:47:06 +05301195 msm7627a_camera_init();
Chintan Pandya0d453192012-03-09 13:20:33 +05301196 qrd7627a_add_io_devices();
Aparna Mallavarapud95d8fc2012-03-08 12:07:37 +05301197 msm7x25a_kgsl_3d0_init();
Sudhakara Rao Tentu38ad6e12012-03-30 15:25:18 -07001198 msm8x25_kgsl_3d0_init();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301199}
1200
1201static void __init qrd7627a_init_early(void)
1202{
1203 msm_msm7627a_allocate_memory_regions();
1204}
1205
1206MACHINE_START(MSM7627A_QRD1, "QRD MSM7627a QRD1")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001207 .atag_offset = 0x100,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301208 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301209 .reserve = msm7627a_reserve,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301210 .init_irq = msm_init_irq,
Taniya Dasc868a2e2012-01-03 10:18:47 +05301211 .init_machine = msm_qrd_init,
1212 .timer = &msm_timer,
1213 .init_early = qrd7627a_init_early,
1214 .handle_irq = vic_handle_irq,
1215MACHINE_END
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301216MACHINE_START(MSM7627A_QRD3, "QRD MSM7627a QRD3")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001217 .atag_offset = 0x100,
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301218 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301219 .reserve = msm7627a_reserve,
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301220 .init_irq = msm_init_irq,
1221 .init_machine = msm_qrd_init,
1222 .timer = &msm_timer,
1223 .init_early = qrd7627a_init_early,
1224 .handle_irq = vic_handle_irq,
1225MACHINE_END
Taniya Dasc868a2e2012-01-03 10:18:47 +05301226MACHINE_START(MSM7627A_EVB, "QRD MSM7627a EVB")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001227 .atag_offset = 0x100,
Taniya Dasc868a2e2012-01-03 10:18:47 +05301228 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301229 .reserve = msm7627a_reserve,
Taniya Dasc868a2e2012-01-03 10:18:47 +05301230 .init_irq = msm_init_irq,
1231 .init_machine = msm_qrd_init,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301232 .timer = &msm_timer,
1233 .init_early = qrd7627a_init_early,
Pankaj Kumarbf8a2a32011-10-21 11:47:21 +05301234 .handle_irq = vic_handle_irq,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301235MACHINE_END
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301236MACHINE_START(MSM8625_EVB, "QRD MSM8625 EVB")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001237 .atag_offset = 0x100,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301238 .map_io = msm8625_map_io,
Trilok Sonib9410792012-04-07 15:37:13 +05301239 .reserve = msm8625_reserve,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301240 .init_irq = msm8625_init_irq,
1241 .init_machine = msm_qrd_init,
1242 .timer = &msm_timer,
1243 .init_early = qrd7627a_init_early,
1244 .handle_irq = gic_handle_irq,
1245MACHINE_END
Taniya Dasbd096542012-03-15 17:43:45 +05301246MACHINE_START(MSM8625_QRD7, "QRD MSM8625 QRD7")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001247 .atag_offset = 0x100,
Taniya Dasbd096542012-03-15 17:43:45 +05301248 .map_io = msm8625_map_io,
Trilok Sonib9410792012-04-07 15:37:13 +05301249 .reserve = msm8625_reserve,
Taniya Dasbd096542012-03-15 17:43:45 +05301250 .init_irq = msm8625_init_irq,
1251 .init_machine = msm_qrd_init,
1252 .timer = &msm_timer,
1253 .init_early = qrd7627a_init_early,
1254 .handle_irq = gic_handle_irq,
1255MACHINE_END
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301256MACHINE_START(MSM8625_EVT, "QRD MSM8625 EVT")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001257 .atag_offset = 0x100,
Aparna Mallavarapu5a326242012-05-09 19:49:02 +05301258 .map_io = msm8625_map_io,
1259 .reserve = msm8625_reserve,
1260 .init_irq = msm8625_init_irq,
1261 .init_machine = msm_qrd_init,
1262 .timer = &msm_timer,
1263 .init_early = qrd7627a_init_early,
1264 .handle_irq = gic_handle_irq,
1265MACHINE_END