blob: 7b0044032daa1fe6e1eb2225b343551b17dccb4c [file] [log] [blame]
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +05301/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/gpio_event.h>
Taniya Das2b16d1d2011-12-02 14:44:19 +053015#include <linux/memblock.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070016#include <asm/mach-types.h>
Murali Nalajala41786ab2012-03-06 10:47:32 +053017#include <linux/memblock.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018#include <asm/mach/arch.h>
Taniya Das43bcdd62011-12-02 17:33:27 +053019#include <asm/hardware/gic.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070020#include <mach/board.h>
21#include <mach/msm_iomap.h>
22#include <mach/msm_hsusb.h>
23#include <mach/rpc_hsusb.h>
24#include <mach/rpc_pmapp.h>
25#include <mach/usbdiag.h>
26#include <mach/msm_memtypes.h>
27#include <mach/msm_serial_hs.h>
28#include <linux/usb/android.h>
29#include <linux/platform_device.h>
30#include <linux/io.h>
31#include <linux/gpio.h>
32#include <mach/vreg.h>
33#include <mach/pmic.h>
34#include <mach/socinfo.h>
35#include <linux/mtd/nand.h>
36#include <linux/mtd/partitions.h>
37#include <asm/mach/mmc.h>
38#include <linux/i2c.h>
39#include <linux/i2c/sx150x.h>
40#include <linux/gpio.h>
41#include <linux/android_pmem.h>
42#include <linux/bootmem.h>
43#include <linux/mfd/marimba.h>
44#include <mach/vreg.h>
45#include <linux/power_supply.h>
Justin Paupored98328e2011-08-19 13:48:31 -070046#include <linux/regulator/consumer.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070047#include <mach/rpc_pmapp.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070048#include <mach/msm_battery.h>
49#include <linux/smsc911x.h>
50#include <linux/atmel_maxtouch.h>
Siddartha Mohanadossbc2103f2012-03-20 11:41:48 -070051#include <linux/msm_adc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070052#include "devices.h"
53#include "timer.h"
Justin Pauporeb3a33b72011-08-23 15:30:32 -070054#include "board-msm7x27a-regulator.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070055#include "devices-msm7x2xa.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080056#include "pm.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070057#include <mach/rpc_server_handset.h>
58#include <mach/socinfo.h>
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -060059#include "pm-boot.h"
Chintan Pandyacf467fc2011-12-01 17:11:11 +053060#include "board-msm7627a.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070061
Trilok Sonib9410792012-04-07 15:37:13 +053062#define PMEM_KERNEL_EBI1_SIZE 0x3A000
Sidipotu Ashok554881c2012-04-12 11:42:02 +053063#define MSM_PMEM_AUDIO_SIZE 0x1F4000
Trilok Sonib9410792012-04-07 15:37:13 +053064
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070065#if defined(CONFIG_GPIO_SX150X)
66enum {
67 SX150X_CORE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070068};
69
70static struct sx150x_platform_data sx150x_data[] __initdata = {
71 [SX150X_CORE] = {
72 .gpio_base = GPIO_CORE_EXPANDER_BASE,
73 .oscio_is_gpo = false,
74 .io_pullup_ena = 0,
pankaj kumarc5c01392011-08-12 13:44:05 +053075 .io_pulldn_ena = 0x02,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076 .io_open_drain_ena = 0xfef8,
77 .irq_summary = -1,
78 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070079};
80#endif
81
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070082
Santosh Sajjan6822c682011-07-26 10:49:36 +053083static struct platform_device msm_wlan_ar6000_pm_device = {
84 .name = "wlan_ar6000_pm_dev",
85 .id = -1,
86};
87
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070088#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
89static struct i2c_board_info core_exp_i2c_info[] __initdata = {
90 {
91 I2C_BOARD_INFO("sx1509q", 0x3e),
92 },
93};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070094
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095static void __init register_i2c_devices(void)
96{
Taniya Dase3027e22012-02-27 16:32:27 +053097 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() ||
98 machine_is_msm8625_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070099 sx150x_data[SX150X_CORE].io_open_drain_ena = 0xe0f0;
100
101 core_exp_i2c_info[0].platform_data =
102 &sx150x_data[SX150X_CORE];
103
104 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
105 core_exp_i2c_info,
106 ARRAY_SIZE(core_exp_i2c_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700107}
108#endif
109
110static struct msm_gpio qup_i2c_gpios_io[] = {
111 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
112 "qup_scl" },
113 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
114 "qup_sda" },
115 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
116 "qup_scl" },
117 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
118 "qup_sda" },
119};
120
121static struct msm_gpio qup_i2c_gpios_hw[] = {
122 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
123 "qup_scl" },
124 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
125 "qup_sda" },
126 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
127 "qup_scl" },
128 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
129 "qup_sda" },
130};
131
132static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
133{
134 int rc;
135
136 if (adap_id < 0 || adap_id > 1)
137 return;
138
139 /* Each adapter gets 2 lines from the table */
140 if (config_type)
141 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
142 else
143 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
144 if (rc < 0)
145 pr_err("QUP GPIO request/enable failed: %d\n", rc);
146}
147
148static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
149 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700150 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
151};
152
153static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
154 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700155 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
156};
157
Trilok Sonib9410792012-04-07 15:37:13 +0530158#ifdef CONFIG_ARCH_MSM7X27A
159#define MSM_PMEM_MDP_SIZE 0x2300000
160#define MSM7x25A_MSM_PMEM_MDP_SIZE 0x1500000
161
162#define MSM_PMEM_ADSP_SIZE 0x1100000
163#define MSM7x25A_MSM_PMEM_ADSP_SIZE 0xB91000
164
165#endif
166
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700167static struct android_usb_platform_data android_usb_pdata = {
168 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
169};
170
171static struct platform_device android_usb_device = {
172 .name = "android_usb",
173 .id = -1,
174 .dev = {
175 .platform_data = &android_usb_pdata,
176 },
177};
178
179#ifdef CONFIG_USB_EHCI_MSM_72K
180static void msm_hsusb_vbus_power(unsigned phy_info, int on)
181{
182 int rc = 0;
183 unsigned gpio;
184
185 gpio = GPIO_HOST_VBUS_EN;
186
187 rc = gpio_request(gpio, "i2c_host_vbus_en");
188 if (rc < 0) {
189 pr_err("failed to request %d GPIO\n", gpio);
190 return;
191 }
192 gpio_direction_output(gpio, !!on);
193 gpio_set_value_cansleep(gpio, !!on);
194 gpio_free(gpio);
195}
196
197static struct msm_usb_host_platform_data msm_usb_host_pdata = {
198 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
199};
200
201static void __init msm7x2x_init_host(void)
202{
203 msm_add_host(0, &msm_usb_host_pdata);
204}
205#endif
206
207#ifdef CONFIG_USB_MSM_OTG_72K
208static int hsusb_rpc_connect(int connect)
209{
210 if (connect)
211 return msm_hsusb_rpc_connect();
212 else
213 return msm_hsusb_rpc_close();
214}
215
Justin Paupored98328e2011-08-19 13:48:31 -0700216static struct regulator *reg_hsusb;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700217static int msm_hsusb_ldo_init(int init)
218{
Justin Paupored98328e2011-08-19 13:48:31 -0700219 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700220
Justin Paupored98328e2011-08-19 13:48:31 -0700221 if (init) {
222 reg_hsusb = regulator_get(NULL, "usb");
223 if (IS_ERR(reg_hsusb)) {
224 rc = PTR_ERR(reg_hsusb);
225 pr_err("%s: could not get regulator: %d\n",
226 __func__, rc);
227 goto out;
228 }
229
230 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
231 if (rc) {
232 pr_err("%s: could not set voltage: %d\n",
233 __func__, rc);
234 goto reg_free;
235 }
236
237 return 0;
238 }
239 /* else fall through */
240reg_free:
241 regulator_put(reg_hsusb);
242out:
243 reg_hsusb = NULL;
244 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700245}
246
247static int msm_hsusb_ldo_enable(int enable)
248{
249 static int ldo_status;
250
Justin Paupored98328e2011-08-19 13:48:31 -0700251 if (IS_ERR_OR_NULL(reg_hsusb))
252 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700253
254 if (ldo_status == enable)
255 return 0;
256
257 ldo_status = enable;
258
Justin Paupored98328e2011-08-19 13:48:31 -0700259 return enable ?
260 regulator_enable(reg_hsusb) :
261 regulator_disable(reg_hsusb);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700262}
263
264#ifndef CONFIG_USB_EHCI_MSM_72K
265static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
266{
267 int ret = 0;
268
269 if (init)
270 ret = msm_pm_app_rpc_init(callback);
271 else
272 msm_pm_app_rpc_deinit(callback);
273
274 return ret;
275}
276#endif
277
278static struct msm_otg_platform_data msm_otg_pdata = {
279#ifndef CONFIG_USB_EHCI_MSM_72K
280 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
281#else
282 .vbus_power = msm_hsusb_vbus_power,
283#endif
284 .rpc_connect = hsusb_rpc_connect,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700285 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
286 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
287 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
288 .se1_gating = SE1_GATING_DISABLE,
289 .ldo_init = msm_hsusb_ldo_init,
290 .ldo_enable = msm_hsusb_ldo_enable,
291 .chg_init = hsusb_chg_init,
292 .chg_connected = hsusb_chg_connected,
293 .chg_vbus_draw = hsusb_chg_vbus_draw,
294};
295#endif
296
297static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
298 .is_phy_status_timer_on = 1,
299};
300
301static struct resource smc91x_resources[] = {
302 [0] = {
303 .start = 0x90000300,
304 .end = 0x900003ff,
305 .flags = IORESOURCE_MEM,
306 },
307 [1] = {
308 .start = MSM_GPIO_TO_INT(4),
309 .end = MSM_GPIO_TO_INT(4),
310 .flags = IORESOURCE_IRQ,
311 },
312};
313
314static struct platform_device smc91x_device = {
315 .name = "smc91x",
316 .id = 0,
317 .num_resources = ARRAY_SIZE(smc91x_resources),
318 .resource = smc91x_resources,
319};
320
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700321#ifdef CONFIG_SERIAL_MSM_HS
322static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
323 .inject_rx_on_wakeup = 1,
324 .rx_to_inject = 0xFD,
325};
326#endif
327static struct msm_pm_platform_data msm7x27a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +0530328 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700329 .idle_supported = 1,
330 .suspend_supported = 1,
331 .idle_enabled = 1,
332 .suspend_enabled = 1,
333 .latency = 16000,
334 .residency = 20000,
335 },
Murali Nalajalab10363d2012-01-12 16:29:01 +0530336 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700337 .idle_supported = 1,
338 .suspend_supported = 1,
339 .idle_enabled = 1,
340 .suspend_enabled = 1,
341 .latency = 12000,
342 .residency = 20000,
343 },
Murali Nalajalab10363d2012-01-12 16:29:01 +0530344 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700345 .idle_supported = 1,
346 .suspend_supported = 1,
347 .idle_enabled = 0,
348 .suspend_enabled = 1,
349 .latency = 2000,
350 .residency = 0,
351 },
Murali Nalajalab10363d2012-01-12 16:29:01 +0530352 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700353 .idle_supported = 1,
354 .suspend_supported = 1,
355 .idle_enabled = 1,
356 .suspend_enabled = 1,
357 .latency = 2,
358 .residency = 0,
359 },
360};
361
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600362static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +0530363 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
364 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600365};
366
Murali Nalajalad1f67b02012-02-10 00:23:49 +0530367/* 8625 PM platform data */
368static struct msm_pm_platform_data msm8625_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
369 /* CORE0 entries */
370 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
371 .idle_supported = 1,
372 .suspend_supported = 1,
373 .idle_enabled = 0,
374 .suspend_enabled = 0,
375 .latency = 16000,
376 .residency = 20000,
377 },
378
379 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
380 .idle_supported = 1,
381 .suspend_supported = 1,
382 .idle_enabled = 0,
383 .suspend_enabled = 0,
384 .latency = 12000,
385 .residency = 20000,
386 },
387
388 /* picked latency & redisdency values from 7x30 */
389 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
390 .idle_supported = 1,
391 .suspend_supported = 1,
392 .idle_enabled = 0,
393 .suspend_enabled = 0,
394 .latency = 500,
395 .residency = 6000,
396 },
397
398 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
399 .idle_supported = 1,
400 .suspend_supported = 1,
401 .idle_enabled = 1,
402 .suspend_enabled = 1,
403 .latency = 2,
404 .residency = 10,
405 },
406
407 /* picked latency & redisdency values from 7x30 */
408 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
409 .idle_supported = 1,
410 .suspend_supported = 1,
411 .idle_enabled = 0,
412 .suspend_enabled = 0,
413 .latency = 500,
414 .residency = 6000,
415 },
416
417 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
418 .idle_supported = 1,
419 .suspend_supported = 1,
420 .idle_enabled = 1,
421 .suspend_enabled = 1,
422 .latency = 2,
423 .residency = 10,
424 },
425
426};
427
Murali Nalajala41786ab2012-03-06 10:47:32 +0530428static struct msm_pm_boot_platform_data msm_pm_8625_boot_pdata __initdata = {
429 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
430 .v_addr = MSM_CFG_CTL_BASE,
431};
432
Trilok Sonib9410792012-04-07 15:37:13 +0530433static struct android_pmem_platform_data android_pmem_adsp_pdata = {
434 .name = "pmem_adsp",
435 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
436 .cached = 1,
437 .memory_type = MEMTYPE_EBI1,
Trilok Sonib9410792012-04-07 15:37:13 +0530438};
439
440static struct platform_device android_pmem_adsp_device = {
441 .name = "android_pmem",
442 .id = 1,
443 .dev = { .platform_data = &android_pmem_adsp_pdata },
444};
445
446static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
447static int __init pmem_mdp_size_setup(char *p)
448{
449 pmem_mdp_size = memparse(p, NULL);
450 return 0;
451}
452
453early_param("pmem_mdp_size", pmem_mdp_size_setup);
454
455static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
456static int __init pmem_adsp_size_setup(char *p)
457{
458 pmem_adsp_size = memparse(p, NULL);
459 return 0;
460}
461
462early_param("pmem_adsp_size", pmem_adsp_size_setup);
463
464#define SND(desc, num) { .name = #desc, .id = num }
465static struct snd_endpoint snd_endpoints_list[] = {
466 SND(HANDSET, 0),
467 SND(MONO_HEADSET, 2),
468 SND(HEADSET, 3),
469 SND(SPEAKER, 6),
470 SND(TTY_HEADSET, 8),
471 SND(TTY_VCO, 9),
472 SND(TTY_HCO, 10),
473 SND(BT, 12),
474 SND(IN_S_SADC_OUT_HANDSET, 16),
475 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
476 SND(FM_DIGITAL_STEREO_HEADSET, 26),
477 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
478 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
479 SND(STEREO_HEADSET_AND_SPEAKER, 31),
480 SND(CURRENT, 0x7FFFFFFE),
481 SND(FM_ANALOG_STEREO_HEADSET, 35),
482 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
483};
484#undef SND
485
486static struct msm_snd_endpoints msm_device_snd_endpoints = {
487 .endpoints = snd_endpoints_list,
488 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
489};
490
491static struct platform_device msm_device_snd = {
492 .name = "msm_snd",
493 .id = -1,
494 .dev = {
495 .platform_data = &msm_device_snd_endpoints
496 },
497};
498
499#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
500 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
501 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
502 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
503 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
504 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
505#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
506 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
507 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
508 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
509 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
510 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
511#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
512 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
513 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
514 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
515 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
516 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
517#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
518 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
519 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
520 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
521 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
522 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
523#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
524
525static unsigned int dec_concurrency_table[] = {
526 /* Audio LP */
527 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
528 0, 0, 0,
529
530 /* Concurrency 1 */
531 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
532 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
533 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
534 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
535 (DEC4_FORMAT),
536
537 /* Concurrency 2 */
538 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
539 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
540 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
541 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
542 (DEC4_FORMAT),
543
544 /* Concurrency 3 */
545 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
546 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
547 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
548 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
549 (DEC4_FORMAT),
550
551 /* Concurrency 4 */
552 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
553 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
554 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
555 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
556 (DEC4_FORMAT),
557
558 /* Concurrency 5 */
559 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
560 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
561 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
562 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
563 (DEC4_FORMAT),
564
565 /* Concurrency 6 */
Chaithanya Krishna Bacharaju41f09e22012-04-30 14:56:17 +0530566 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
567 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
Trilok Sonib9410792012-04-07 15:37:13 +0530568 0, 0, 0,
569
570 /* Concurrency 7 */
571 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
572 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
573 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
574 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
575 (DEC4_FORMAT),
576};
577
578#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
579 .module_queueid = queueid, .module_decid = decid, \
580 .nr_codec_support = nr_codec}
581
582static struct msm_adspdec_info dec_info_list[] = {
583 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
584 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
585 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
586 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
587 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
588};
589
590static struct msm_adspdec_database msm_device_adspdec_database = {
591 .num_dec = ARRAY_SIZE(dec_info_list),
592 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
593 ARRAY_SIZE(dec_info_list)),
594 .dec_concurrency_table = dec_concurrency_table,
595 .dec_info_list = dec_info_list,
596};
597
598static struct platform_device msm_device_adspdec = {
599 .name = "msm_adspdec",
600 .id = -1,
601 .dev = {
602 .platform_data = &msm_device_adspdec_database
603 },
604};
605
606static struct android_pmem_platform_data android_pmem_audio_pdata = {
607 .name = "pmem_audio",
608 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
609 .cached = 0,
610 .memory_type = MEMTYPE_EBI1,
611};
612
613static struct platform_device android_pmem_audio_device = {
614 .name = "android_pmem",
615 .id = 2,
616 .dev = { .platform_data = &android_pmem_audio_pdata },
617};
618
619static struct android_pmem_platform_data android_pmem_pdata = {
620 .name = "pmem",
621 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
622 .cached = 1,
623 .memory_type = MEMTYPE_EBI1,
624};
625static struct platform_device android_pmem_device = {
626 .name = "android_pmem",
627 .id = 0,
628 .dev = { .platform_data = &android_pmem_pdata },
629};
630
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700631static u32 msm_calculate_batt_capacity(u32 current_voltage);
632
633static struct msm_psy_batt_pdata msm_psy_batt_data = {
634 .voltage_min_design = 2800,
635 .voltage_max_design = 4300,
636 .avail_chg_sources = AC_CHG | USB_CHG ,
637 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
638 .calculate_capacity = &msm_calculate_batt_capacity,
639};
640
641static u32 msm_calculate_batt_capacity(u32 current_voltage)
642{
643 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
644 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
645
646 return (current_voltage - low_voltage) * 100
647 / (high_voltage - low_voltage);
648}
649
650static struct platform_device msm_batt_device = {
651 .name = "msm-battery",
652 .id = -1,
653 .dev.platform_data = &msm_psy_batt_data,
654};
655
656static struct smsc911x_platform_config smsc911x_config = {
657 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
658 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
659 .flags = SMSC911X_USE_16BIT,
660};
661
662static struct resource smsc911x_resources[] = {
663 [0] = {
664 .start = 0x90000000,
665 .end = 0x90007fff,
666 .flags = IORESOURCE_MEM,
667 },
668 [1] = {
669 .start = MSM_GPIO_TO_INT(48),
670 .end = MSM_GPIO_TO_INT(48),
671 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
672 },
673};
674
675static struct platform_device smsc911x_device = {
676 .name = "smsc911x",
677 .id = 0,
678 .num_resources = ARRAY_SIZE(smsc911x_resources),
679 .resource = smsc911x_resources,
680 .dev = {
681 .platform_data = &smsc911x_config,
682 },
683};
684
685static struct msm_gpio smsc911x_gpios[] = {
686 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
687 "smsc911x_irq" },
688 { GPIO_CFG(49, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
689 "eth_fifo_sel" },
690};
691
Siddartha Mohanadossbc2103f2012-03-20 11:41:48 -0700692static char *msm_adc_surf_device_names[] = {
693 "XO_ADC",
694};
695
696static struct msm_adc_platform_data msm_adc_pdata = {
697 .dev_names = msm_adc_surf_device_names,
698 .num_adc = ARRAY_SIZE(msm_adc_surf_device_names),
699 .target_hw = MSM_8x25,
700};
701
702static struct platform_device msm_adc_device = {
703 .name = "msm_adc",
704 .id = -1,
705 .dev = {
706 .platform_data = &msm_adc_pdata,
707 },
708};
709
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700710#define ETH_FIFO_SEL_GPIO 49
711static void msm7x27a_cfg_smsc911x(void)
712{
713 int res;
714
715 res = msm_gpios_request_enable(smsc911x_gpios,
716 ARRAY_SIZE(smsc911x_gpios));
717 if (res) {
718 pr_err("%s: unable to enable gpios for SMSC911x\n", __func__);
719 return;
720 }
721
722 /* ETH_FIFO_SEL */
723 res = gpio_direction_output(ETH_FIFO_SEL_GPIO, 0);
724 if (res) {
725 pr_err("%s: unable to get direction for gpio %d\n", __func__,
726 ETH_FIFO_SEL_GPIO);
727 msm_gpios_disable_free(smsc911x_gpios,
728 ARRAY_SIZE(smsc911x_gpios));
729 return;
730 }
731 gpio_set_value(ETH_FIFO_SEL_GPIO, 0);
732}
733
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700734#if defined(CONFIG_SERIAL_MSM_HSL_CONSOLE) \
735 && defined(CONFIG_MSM_SHARED_GPIO_FOR_UART2DM)
736static struct msm_gpio uart2dm_gpios[] = {
737 {GPIO_CFG(19, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
738 "uart2dm_rfr_n" },
739 {GPIO_CFG(20, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
740 "uart2dm_cts_n" },
741 {GPIO_CFG(21, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
742 "uart2dm_rx" },
743 {GPIO_CFG(108, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
744 "uart2dm_tx" },
745};
746
747static void msm7x27a_cfg_uart2dm_serial(void)
748{
749 int ret;
750 ret = msm_gpios_request_enable(uart2dm_gpios,
751 ARRAY_SIZE(uart2dm_gpios));
752 if (ret)
753 pr_err("%s: unable to enable gpios for uart2dm\n", __func__);
754}
755#else
756static void msm7x27a_cfg_uart2dm_serial(void) { }
757#endif
758
759static struct platform_device *rumi_sim_devices[] __initdata = {
760 &msm_device_dmov,
761 &msm_device_smd,
762 &smc91x_device,
763 &msm_device_uart1,
764 &msm_device_nand,
765 &msm_device_uart_dm1,
766 &msm_gsbi0_qup_i2c_device,
767 &msm_gsbi1_qup_i2c_device,
768};
769
Taniya Das43bcdd62011-12-02 17:33:27 +0530770static struct platform_device *msm8625_rumi3_devices[] __initdata = {
771 &msm8625_device_dmov,
Angshuman Sarkarfb1cce92012-02-21 15:20:43 +0530772 &msm8625_device_smd,
Taniya Das43bcdd62011-12-02 17:33:27 +0530773 &msm8625_device_uart1,
Taniya Dase3027e22012-02-27 16:32:27 +0530774 &msm8625_gsbi0_qup_i2c_device,
Taniya Das43bcdd62011-12-02 17:33:27 +0530775};
776
Taniya Dase3027e22012-02-27 16:32:27 +0530777static struct platform_device *msm7627a_surf_ffa_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700778 &msm_device_dmov,
779 &msm_device_smd,
780 &msm_device_uart1,
781 &msm_device_uart_dm1,
782 &msm_device_uart_dm2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700783 &msm_gsbi0_qup_i2c_device,
784 &msm_gsbi1_qup_i2c_device,
785 &msm_device_otg,
786 &msm_device_gadget_peripheral,
Taniya Dase3027e22012-02-27 16:32:27 +0530787 &smsc911x_device,
788 &msm_kgsl_3d0,
789};
790
791static struct platform_device *common_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700792 &android_usb_device,
Trilok Sonib9410792012-04-07 15:37:13 +0530793 &android_pmem_device,
794 &android_pmem_adsp_device,
795 &android_pmem_audio_device,
Taniya Dase3027e22012-02-27 16:32:27 +0530796 &msm_device_nand,
Trilok Sonib9410792012-04-07 15:37:13 +0530797 &msm_device_snd,
798 &msm_device_adspdec,
Manish Dewangan3a260992011-06-24 18:01:34 +0530799 &asoc_msm_pcm,
800 &asoc_msm_dai0,
801 &asoc_msm_dai1,
Taniya Dase3027e22012-02-27 16:32:27 +0530802 &msm_batt_device,
Siddartha Mohanadossbc2103f2012-03-20 11:41:48 -0700803 &msm_adc_device,
Taniya Dase3027e22012-02-27 16:32:27 +0530804};
805
806static struct platform_device *msm8625_surf_devices[] __initdata = {
807 &msm8625_device_dmov,
808 &msm8625_device_uart1,
809 &msm8625_device_uart_dm1,
810 &msm8625_device_uart_dm2,
811 &msm8625_gsbi0_qup_i2c_device,
812 &msm8625_gsbi1_qup_i2c_device,
Taniya Dasf2665302012-02-28 16:54:54 +0530813 &msm8625_device_smd,
Taniya Dase3027e22012-02-27 16:32:27 +0530814 &msm8625_device_otg,
815 &msm8625_device_gadget_peripheral,
Ranjhith Kalisamy4ec2e102012-03-06 12:27:50 +0530816 &msm8625_kgsl_3d0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700817};
818
Trilok Sonib9410792012-04-07 15:37:13 +0530819static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
820static int __init pmem_kernel_ebi1_size_setup(char *p)
821{
822 pmem_kernel_ebi1_size = memparse(p, NULL);
823 return 0;
824}
825early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
826
827static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
828static int __init pmem_audio_size_setup(char *p)
829{
830 pmem_audio_size = memparse(p, NULL);
831 return 0;
832}
833early_param("pmem_audio_size", pmem_audio_size_setup);
834
835static struct memtype_reserve msm7x27a_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
Trilok Sonib9410792012-04-07 15:37:13 +0530846static void __init size_pmem_devices(void)
847{
Trilok Sonib9410792012-04-07 15:37:13 +0530848
849 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
850 pmem_mdp_size = MSM7x25A_MSM_PMEM_MDP_SIZE;
851 pmem_adsp_size = MSM7x25A_MSM_PMEM_ADSP_SIZE;
852 } else {
853 pmem_mdp_size = MSM_PMEM_MDP_SIZE;
854 pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
855 }
856
Chintan Pandyaa88ddb92012-04-30 12:38:49 +0530857#ifdef CONFIG_ANDROID_PMEM
Trilok Sonib9410792012-04-07 15:37:13 +0530858 android_pmem_adsp_pdata.size = pmem_adsp_size;
859 android_pmem_pdata.size = pmem_mdp_size;
860 android_pmem_audio_pdata.size = pmem_audio_size;
Trilok Sonib9410792012-04-07 15:37:13 +0530861#endif
Trilok Sonib9410792012-04-07 15:37:13 +0530862}
863
864static void __init reserve_memory_for(struct android_pmem_platform_data *p)
865{
866 msm7x27a_reserve_table[p->memory_type].size += p->size;
867}
868
869static void __init reserve_pmem_memory(void)
870{
871#ifdef CONFIG_ANDROID_PMEM
Chintan Pandyaa88ddb92012-04-30 12:38:49 +0530872 reserve_memory_for(&android_pmem_adsp_pdata);
873 reserve_memory_for(&android_pmem_pdata);
874 reserve_memory_for(&android_pmem_audio_pdata);
Trilok Sonib9410792012-04-07 15:37:13 +0530875 msm7x27a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
876#endif
877}
878
879static void __init msm7x27a_calculate_reserve_sizes(void)
880{
881 size_pmem_devices();
882 reserve_pmem_memory();
883}
884
885static int msm7x27a_paddr_to_memtype(unsigned int paddr)
886{
887 return MEMTYPE_EBI1;
888}
889
890static struct reserve_info msm7x27a_reserve_info __initdata = {
891 .memtype_reserve_table = msm7x27a_reserve_table,
892 .calculate_reserve_sizes = msm7x27a_calculate_reserve_sizes,
893 .paddr_to_memtype = msm7x27a_paddr_to_memtype,
894};
895
896static void __init msm7x27a_reserve(void)
897{
898 reserve_info = &msm7x27a_reserve_info;
899 msm_reserve();
Trilok Sonib9410792012-04-07 15:37:13 +0530900}
901
Taniya Das2b16d1d2011-12-02 14:44:19 +0530902static void __init msm8625_reserve(void)
903{
Trilok Sonib9410792012-04-07 15:37:13 +0530904 msm7x27a_reserve();
Taniya Dasfe04d4f2012-03-14 11:13:21 +0530905 memblock_remove(MSM8625_SECONDARY_PHYS, SZ_8);
Murali Nalajalafeedeae2012-03-28 16:15:32 +0530906 memblock_remove(MSM8625_WARM_BOOT_PHYS, SZ_32);
Taniya Das2b16d1d2011-12-02 14:44:19 +0530907}
908
Taniya Dase3027e22012-02-27 16:32:27 +0530909static void __init msm7x27a_device_i2c_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700910{
911 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
912 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
913}
914
Taniya Dase3027e22012-02-27 16:32:27 +0530915static void __init msm8625_device_i2c_init(void)
916{
917 msm8625_gsbi0_qup_i2c_device.dev.platform_data =
918 &msm_gsbi0_qup_i2c_pdata;
919 msm8625_gsbi1_qup_i2c_device.dev.platform_data =
920 &msm_gsbi1_qup_i2c_pdata;
921}
922
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700923#define MSM_EBI2_PHYS 0xa0d00000
924#define MSM_EBI2_XMEM_CS2_CFG1 0xa0d10030
925
926static void __init msm7x27a_init_ebi2(void)
927{
928 uint32_t ebi2_cfg;
929 void __iomem *ebi2_cfg_ptr;
930
931 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_PHYS, sizeof(uint32_t));
932 if (!ebi2_cfg_ptr)
933 return;
934
935 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530936 if (machine_is_msm7x27a_rumi3() || machine_is_msm7x27a_surf() ||
Taniya Dase3027e22012-02-27 16:32:27 +0530937 machine_is_msm7625a_surf() || machine_is_msm8625_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700938 ebi2_cfg |= (1 << 4); /* CS2 */
939
940 writel(ebi2_cfg, ebi2_cfg_ptr);
941 iounmap(ebi2_cfg_ptr);
942
943 /* Enable A/D MUX[bit 31] from EBI2_XMEM_CS2_CFG1 */
944 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_XMEM_CS2_CFG1,
945 sizeof(uint32_t));
946 if (!ebi2_cfg_ptr)
947 return;
948
949 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530950 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700951 ebi2_cfg |= (1 << 31);
952
953 writel(ebi2_cfg, ebi2_cfg_ptr);
954 iounmap(ebi2_cfg_ptr);
955}
956
Justin Pauporeb3a33b72011-08-23 15:30:32 -0700957static struct platform_device msm_proccomm_regulator_dev = {
958 .name = PROCCOMM_REGULATOR_DEV_NAME,
959 .id = -1,
960 .dev = {
961 .platform_data = &msm7x27a_proccomm_regulator_data
962 }
963};
964
Trilok Sonib9410792012-04-07 15:37:13 +0530965static void msm_adsp_add_pdev(void)
966{
967 int rc = 0;
968 struct rpc_board_dev *rpc_adsp_pdev;
969
970 rpc_adsp_pdev = kzalloc(sizeof(struct rpc_board_dev), GFP_KERNEL);
971 if (rpc_adsp_pdev == NULL) {
972 pr_err("%s: Memory Allocation failure\n", __func__);
973 return;
974 }
975 rpc_adsp_pdev->prog = ADSP_RPC_PROG;
976
977 if (cpu_is_msm8625())
978 rpc_adsp_pdev->pdev = msm8625_device_adsp;
979 else
980 rpc_adsp_pdev->pdev = msm_adsp_device;
981 rc = msm_rpc_add_board_dev(rpc_adsp_pdev, 1);
982 if (rc < 0) {
983 pr_err("%s: return val: %d\n", __func__, rc);
984 kfree(rpc_adsp_pdev);
985 }
986}
987
Trilok Soni16f61af2011-07-26 16:06:58 +0530988static void __init msm7627a_rumi3_init(void)
989{
990 msm7x27a_init_ebi2();
991 platform_add_devices(rumi_sim_devices,
992 ARRAY_SIZE(rumi_sim_devices));
993}
994
Taniya Das43bcdd62011-12-02 17:33:27 +0530995static void __init msm8625_rumi3_init(void)
996{
997 msm7x2x_misc_init();
Taniya Dase3027e22012-02-27 16:32:27 +0530998 msm_adsp_add_pdev();
999 msm8625_device_i2c_init();
Taniya Das43bcdd62011-12-02 17:33:27 +05301000 platform_add_devices(msm8625_rumi3_devices,
1001 ARRAY_SIZE(msm8625_rumi3_devices));
Murali Nalajala41786ab2012-03-06 10:47:32 +05301002
Murali Nalajalad1f67b02012-02-10 00:23:49 +05301003 msm_pm_set_platform_data(msm8625_pm_data,
1004 ARRAY_SIZE(msm8625_pm_data));
Murali Nalajala41786ab2012-03-06 10:47:32 +05301005 BUG_ON(msm_pm_boot_init(&msm_pm_8625_boot_pdata));
1006 msm8x25_spm_device_init();
Taniya Das43bcdd62011-12-02 17:33:27 +05301007}
1008
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001009#define UART1DM_RX_GPIO 45
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301010
1011#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
1012static int __init msm7x27a_init_ar6000pm(void)
1013{
Santosh Sajjan374d6592012-01-19 23:16:46 +05301014 msm_wlan_ar6000_pm_device.dev.platform_data = &ar600x_wlan_power;
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301015 return platform_device_register(&msm_wlan_ar6000_pm_device);
1016}
1017#else
1018static int __init msm7x27a_init_ar6000pm(void) { return 0; }
1019#endif
1020
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001021static void __init msm7x27a_init_regulators(void)
1022{
1023 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1024 if (rc)
1025 pr_err("%s: could not register regulator device: %d\n",
1026 __func__, rc);
1027}
1028
Taniya Dase3027e22012-02-27 16:32:27 +05301029static void __init msm7x27a_add_footswitch_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001030{
Trilok Soni16f61af2011-07-26 16:06:58 +05301031 platform_add_devices(msm_footswitch_devices,
1032 msm_num_footswitch_devices);
Taniya Dase3027e22012-02-27 16:32:27 +05301033}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001034
Taniya Dase3027e22012-02-27 16:32:27 +05301035static void __init msm7x27a_add_platform_devices(void)
1036{
1037 if (machine_is_msm8625_surf()) {
1038 platform_add_devices(msm8625_surf_devices,
1039 ARRAY_SIZE(msm8625_surf_devices));
1040 } else {
1041 platform_add_devices(msm7627a_surf_ffa_devices,
1042 ARRAY_SIZE(msm7627a_surf_ffa_devices));
1043 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001044
Taniya Dase3027e22012-02-27 16:32:27 +05301045 platform_add_devices(common_devices,
1046 ARRAY_SIZE(common_devices));
1047}
1048
1049static void __init msm7x27a_uartdm_config(void)
1050{
1051 msm7x27a_cfg_uart2dm_serial();
1052 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
1053 if (cpu_is_msm8625())
1054 msm8625_device_uart_dm1.dev.platform_data =
1055 &msm_uart_dm1_pdata;
1056 else
1057 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
1058}
1059
1060static void __init msm7x27a_otg_gadget(void)
1061{
Taniya Dase3027e22012-02-27 16:32:27 +05301062 if (cpu_is_msm8625()) {
Murali Nalajala6ff8fb12012-05-02 18:50:50 +05301063 msm_otg_pdata.swfi_latency =
1064 msm8625_pm_data[MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT].latency;
Taniya Dase3027e22012-02-27 16:32:27 +05301065 msm8625_device_otg.dev.platform_data = &msm_otg_pdata;
1066 msm8625_device_gadget_peripheral.dev.platform_data =
1067 &msm_gadget_pdata;
1068 } else {
Murali Nalajala6ff8fb12012-05-02 18:50:50 +05301069 msm_otg_pdata.swfi_latency =
1070 msm7x27a_pm_data[
1071 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
Taniya Dase3027e22012-02-27 16:32:27 +05301072 msm_device_otg.dev.platform_data = &msm_otg_pdata;
1073 msm_device_gadget_peripheral.dev.platform_data =
1074 &msm_gadget_pdata;
1075 }
1076}
1077
Taniya Dase3027e22012-02-27 16:32:27 +05301078static void __init msm7x27a_pm_init(void)
1079{
Murali Nalajala8ee084e2012-03-07 00:09:38 +05301080 if (machine_is_msm8625_surf()) {
1081 msm_pm_set_platform_data(msm8625_pm_data,
1082 ARRAY_SIZE(msm8625_pm_data));
1083 BUG_ON(msm_pm_boot_init(&msm_pm_8625_boot_pdata));
1084 msm8x25_spm_device_init();
1085 } else {
1086 msm_pm_set_platform_data(msm7x27a_pm_data,
1087 ARRAY_SIZE(msm7x27a_pm_data));
1088 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
1089 }
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05301090
1091 msm_pm_register_irqs();
Taniya Dase3027e22012-02-27 16:32:27 +05301092}
1093
1094static void __init msm7x2x_init(void)
1095{
1096 msm7x2x_misc_init();
1097
1098 /* Initialize regulators first so that other devices can use them */
1099 msm7x27a_init_regulators();
1100 msm_adsp_add_pdev();
1101 if (cpu_is_msm8625())
1102 msm8625_device_i2c_init();
1103 else
1104 msm7x27a_device_i2c_init();
1105 msm7x27a_init_ebi2();
1106 msm7x27a_uartdm_config();
1107
1108 msm7x27a_otg_gadget();
1109 msm7x27a_cfg_smsc911x();
1110
1111 msm7x27a_add_footswitch_devices();
1112 msm7x27a_add_platform_devices();
1113 /* Ensure ar6000pm device is registered before MMC/SDC */
1114 msm7x27a_init_ar6000pm();
1115 msm7627a_init_mmc();
1116 msm_fb_add_devices();
1117 msm7x2x_init_host();
1118 msm7x27a_pm_init();
1119 register_i2c_devices();
1120 msm7627a_bt_power_init();
1121 msm7627a_camera_init();
Chintan Pandya0d453192012-03-09 13:20:33 +05301122 msm7627a_add_io_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001123 /*7x25a kgsl initializations*/
1124 msm7x25a_kgsl_3d0_init();
Sudhakara Rao Tentu38ad6e12012-03-30 15:25:18 -07001125 /*8x25 kgsl initializations*/
1126 msm8x25_kgsl_3d0_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001127}
1128
1129static void __init msm7x2x_init_early(void)
1130{
Chintan Pandya250c2e52012-01-19 17:15:49 +05301131 msm_msm7627a_allocate_memory_regions();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001132}
1133
1134MACHINE_START(MSM7X27A_RUMI3, "QCT MSM7x27a RUMI3")
1135 .boot_params = PHYS_OFFSET + 0x100,
1136 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301137 .reserve = msm7x27a_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001138 .init_irq = msm_init_irq,
Trilok Soni16f61af2011-07-26 16:06:58 +05301139 .init_machine = msm7627a_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001140 .timer = &msm_timer,
1141 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301142 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001143MACHINE_END
1144MACHINE_START(MSM7X27A_SURF, "QCT MSM7x27a SURF")
1145 .boot_params = PHYS_OFFSET + 0x100,
1146 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301147 .reserve = msm7x27a_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001148 .init_irq = msm_init_irq,
1149 .init_machine = msm7x2x_init,
1150 .timer = &msm_timer,
1151 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301152 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001153MACHINE_END
1154MACHINE_START(MSM7X27A_FFA, "QCT MSM7x27a FFA")
1155 .boot_params = PHYS_OFFSET + 0x100,
1156 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301157 .reserve = msm7x27a_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001158 .init_irq = msm_init_irq,
1159 .init_machine = msm7x2x_init,
1160 .timer = &msm_timer,
1161 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301162 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001163MACHINE_END
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301164MACHINE_START(MSM7625A_SURF, "QCT MSM7625a SURF")
1165 .boot_params = PHYS_OFFSET + 0x100,
1166 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301167 .reserve = msm7x27a_reserve,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301168 .init_irq = msm_init_irq,
1169 .init_machine = msm7x2x_init,
1170 .timer = &msm_timer,
1171 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301172 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301173MACHINE_END
1174MACHINE_START(MSM7625A_FFA, "QCT MSM7625a FFA")
1175 .boot_params = PHYS_OFFSET + 0x100,
1176 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301177 .reserve = msm7x27a_reserve,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301178 .init_irq = msm_init_irq,
1179 .init_machine = msm7x2x_init,
1180 .timer = &msm_timer,
1181 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301182 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301183MACHINE_END
Taniya Das43bcdd62011-12-02 17:33:27 +05301184MACHINE_START(MSM8625_RUMI3, "QCT MSM8625 RUMI3")
1185 .boot_params = PHYS_OFFSET + 0x100,
1186 .map_io = msm8625_map_io,
Taniya Das2b16d1d2011-12-02 14:44:19 +05301187 .reserve = msm8625_reserve,
Taniya Das43bcdd62011-12-02 17:33:27 +05301188 .init_irq = msm8625_init_irq,
1189 .init_machine = msm8625_rumi3_init,
1190 .timer = &msm_timer,
1191 .handle_irq = gic_handle_irq,
1192MACHINE_END
Taniya Dase3027e22012-02-27 16:32:27 +05301193MACHINE_START(MSM8625_SURF, "QCT MSM8625 SURF")
1194 .boot_params = PHYS_OFFSET + 0x100,
1195 .map_io = msm8625_map_io,
1196 .reserve = msm8625_reserve,
1197 .init_irq = msm8625_init_irq,
1198 .init_machine = msm7x2x_init,
1199 .timer = &msm_timer,
1200 .init_early = msm7x2x_init_early,
1201 .handle_irq = gic_handle_irq,
1202MACHINE_END