blob: 1521a6c52e581a1027d9266a8f762c0547e77884 [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>
Larry Bassel861985f2012-05-02 15:54:52 -070051#include <linux/fmem.h>
Siddartha Mohanadossbc2103f2012-03-20 11:41:48 -070052#include <linux/msm_adc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070053#include "devices.h"
54#include "timer.h"
Justin Pauporeb3a33b72011-08-23 15:30:32 -070055#include "board-msm7x27a-regulator.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056#include "devices-msm7x2xa.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080057#include "pm.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070058#include <mach/rpc_server_handset.h>
59#include <mach/socinfo.h>
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -060060#include "pm-boot.h"
Chintan Pandyacf467fc2011-12-01 17:11:11 +053061#include "board-msm7627a.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070062
Trilok Sonib9410792012-04-07 15:37:13 +053063#define PMEM_KERNEL_EBI1_SIZE 0x3A000
Sidipotu Ashok554881c2012-04-12 11:42:02 +053064#define MSM_PMEM_AUDIO_SIZE 0x1F4000
Trilok Sonib9410792012-04-07 15:37:13 +053065
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070066#if defined(CONFIG_GPIO_SX150X)
67enum {
68 SX150X_CORE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070069};
70
71static struct sx150x_platform_data sx150x_data[] __initdata = {
72 [SX150X_CORE] = {
73 .gpio_base = GPIO_CORE_EXPANDER_BASE,
74 .oscio_is_gpo = false,
75 .io_pullup_ena = 0,
pankaj kumarc5c01392011-08-12 13:44:05 +053076 .io_pulldn_ena = 0x02,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070077 .io_open_drain_ena = 0xfef8,
78 .irq_summary = -1,
79 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070080};
81#endif
82
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070083
Steve Mucklef132c6c2012-06-06 18:30:57 -070084#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Santosh Sajjan6822c682011-07-26 10:49:36 +053085static struct platform_device msm_wlan_ar6000_pm_device = {
86 .name = "wlan_ar6000_pm_dev",
87 .id = -1,
88};
Steve Mucklef132c6c2012-06-06 18:30:57 -070089#endif
Santosh Sajjan6822c682011-07-26 10:49:36 +053090
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070091#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
92static struct i2c_board_info core_exp_i2c_info[] __initdata = {
93 {
94 I2C_BOARD_INFO("sx1509q", 0x3e),
95 },
96};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070097
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070098static void __init register_i2c_devices(void)
99{
Taniya Dase3027e22012-02-27 16:32:27 +0530100 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() ||
101 machine_is_msm8625_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700102 sx150x_data[SX150X_CORE].io_open_drain_ena = 0xe0f0;
103
104 core_exp_i2c_info[0].platform_data =
105 &sx150x_data[SX150X_CORE];
106
107 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
108 core_exp_i2c_info,
109 ARRAY_SIZE(core_exp_i2c_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700110}
111#endif
112
113static struct msm_gpio qup_i2c_gpios_io[] = {
114 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
115 "qup_scl" },
116 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
117 "qup_sda" },
118 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
119 "qup_scl" },
120 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
121 "qup_sda" },
122};
123
124static struct msm_gpio qup_i2c_gpios_hw[] = {
125 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
126 "qup_scl" },
127 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
128 "qup_sda" },
129 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
130 "qup_scl" },
131 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
132 "qup_sda" },
133};
134
135static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
136{
137 int rc;
138
139 if (adap_id < 0 || adap_id > 1)
140 return;
141
142 /* Each adapter gets 2 lines from the table */
143 if (config_type)
144 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
145 else
146 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
147 if (rc < 0)
148 pr_err("QUP GPIO request/enable failed: %d\n", rc);
149}
150
151static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
152 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700153 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
154};
155
156static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
157 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700158 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
159};
160
Trilok Sonib9410792012-04-07 15:37:13 +0530161#ifdef CONFIG_ARCH_MSM7X27A
162#define MSM_PMEM_MDP_SIZE 0x2300000
163#define MSM7x25A_MSM_PMEM_MDP_SIZE 0x1500000
164
165#define MSM_PMEM_ADSP_SIZE 0x1100000
166#define MSM7x25A_MSM_PMEM_ADSP_SIZE 0xB91000
167
168#endif
169
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700170static struct android_usb_platform_data android_usb_pdata = {
171 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
172};
173
174static struct platform_device android_usb_device = {
175 .name = "android_usb",
176 .id = -1,
177 .dev = {
178 .platform_data = &android_usb_pdata,
179 },
180};
181
182#ifdef CONFIG_USB_EHCI_MSM_72K
183static void msm_hsusb_vbus_power(unsigned phy_info, int on)
184{
185 int rc = 0;
186 unsigned gpio;
187
188 gpio = GPIO_HOST_VBUS_EN;
189
190 rc = gpio_request(gpio, "i2c_host_vbus_en");
191 if (rc < 0) {
192 pr_err("failed to request %d GPIO\n", gpio);
193 return;
194 }
195 gpio_direction_output(gpio, !!on);
196 gpio_set_value_cansleep(gpio, !!on);
197 gpio_free(gpio);
198}
199
200static struct msm_usb_host_platform_data msm_usb_host_pdata = {
201 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
202};
203
204static void __init msm7x2x_init_host(void)
205{
206 msm_add_host(0, &msm_usb_host_pdata);
207}
208#endif
209
210#ifdef CONFIG_USB_MSM_OTG_72K
211static int hsusb_rpc_connect(int connect)
212{
213 if (connect)
214 return msm_hsusb_rpc_connect();
215 else
216 return msm_hsusb_rpc_close();
217}
218
Justin Paupored98328e2011-08-19 13:48:31 -0700219static struct regulator *reg_hsusb;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700220static int msm_hsusb_ldo_init(int init)
221{
Justin Paupored98328e2011-08-19 13:48:31 -0700222 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700223
Justin Paupored98328e2011-08-19 13:48:31 -0700224 if (init) {
225 reg_hsusb = regulator_get(NULL, "usb");
226 if (IS_ERR(reg_hsusb)) {
227 rc = PTR_ERR(reg_hsusb);
228 pr_err("%s: could not get regulator: %d\n",
229 __func__, rc);
230 goto out;
231 }
232
233 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
234 if (rc) {
235 pr_err("%s: could not set voltage: %d\n",
236 __func__, rc);
237 goto reg_free;
238 }
239
240 return 0;
241 }
242 /* else fall through */
243reg_free:
244 regulator_put(reg_hsusb);
245out:
246 reg_hsusb = NULL;
247 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700248}
249
250static int msm_hsusb_ldo_enable(int enable)
251{
252 static int ldo_status;
253
Justin Paupored98328e2011-08-19 13:48:31 -0700254 if (IS_ERR_OR_NULL(reg_hsusb))
255 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700256
257 if (ldo_status == enable)
258 return 0;
259
260 ldo_status = enable;
261
Justin Paupored98328e2011-08-19 13:48:31 -0700262 return enable ?
263 regulator_enable(reg_hsusb) :
264 regulator_disable(reg_hsusb);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700265}
266
267#ifndef CONFIG_USB_EHCI_MSM_72K
268static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
269{
270 int ret = 0;
271
272 if (init)
273 ret = msm_pm_app_rpc_init(callback);
274 else
275 msm_pm_app_rpc_deinit(callback);
276
277 return ret;
278}
279#endif
280
281static struct msm_otg_platform_data msm_otg_pdata = {
282#ifndef CONFIG_USB_EHCI_MSM_72K
283 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
284#else
285 .vbus_power = msm_hsusb_vbus_power,
286#endif
287 .rpc_connect = hsusb_rpc_connect,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700288 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
289 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
290 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
291 .se1_gating = SE1_GATING_DISABLE,
292 .ldo_init = msm_hsusb_ldo_init,
293 .ldo_enable = msm_hsusb_ldo_enable,
294 .chg_init = hsusb_chg_init,
295 .chg_connected = hsusb_chg_connected,
296 .chg_vbus_draw = hsusb_chg_vbus_draw,
297};
298#endif
299
300static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
301 .is_phy_status_timer_on = 1,
302};
303
304static struct resource smc91x_resources[] = {
305 [0] = {
306 .start = 0x90000300,
307 .end = 0x900003ff,
308 .flags = IORESOURCE_MEM,
309 },
310 [1] = {
311 .start = MSM_GPIO_TO_INT(4),
312 .end = MSM_GPIO_TO_INT(4),
313 .flags = IORESOURCE_IRQ,
314 },
315};
316
317static struct platform_device smc91x_device = {
318 .name = "smc91x",
319 .id = 0,
320 .num_resources = ARRAY_SIZE(smc91x_resources),
321 .resource = smc91x_resources,
322};
323
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700324#ifdef CONFIG_SERIAL_MSM_HS
325static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
326 .inject_rx_on_wakeup = 1,
327 .rx_to_inject = 0xFD,
328};
329#endif
330static struct msm_pm_platform_data msm7x27a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +0530331 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700332 .idle_supported = 1,
333 .suspend_supported = 1,
334 .idle_enabled = 1,
335 .suspend_enabled = 1,
336 .latency = 16000,
337 .residency = 20000,
338 },
Murali Nalajalab10363d2012-01-12 16:29:01 +0530339 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700340 .idle_supported = 1,
341 .suspend_supported = 1,
342 .idle_enabled = 1,
343 .suspend_enabled = 1,
344 .latency = 12000,
345 .residency = 20000,
346 },
Murali Nalajalab10363d2012-01-12 16:29:01 +0530347 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700348 .idle_supported = 1,
349 .suspend_supported = 1,
350 .idle_enabled = 0,
351 .suspend_enabled = 1,
352 .latency = 2000,
353 .residency = 0,
354 },
Murali Nalajalab10363d2012-01-12 16:29:01 +0530355 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700356 .idle_supported = 1,
357 .suspend_supported = 1,
358 .idle_enabled = 1,
359 .suspend_enabled = 1,
360 .latency = 2,
361 .residency = 0,
362 },
363};
364
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600365static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +0530366 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
367 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600368};
369
Murali Nalajalad1f67b02012-02-10 00:23:49 +0530370/* 8625 PM platform data */
371static struct msm_pm_platform_data msm8625_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
372 /* CORE0 entries */
373 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
374 .idle_supported = 1,
375 .suspend_supported = 1,
376 .idle_enabled = 0,
377 .suspend_enabled = 0,
378 .latency = 16000,
379 .residency = 20000,
380 },
381
382 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
383 .idle_supported = 1,
384 .suspend_supported = 1,
385 .idle_enabled = 0,
386 .suspend_enabled = 0,
387 .latency = 12000,
388 .residency = 20000,
389 },
390
391 /* picked latency & redisdency values from 7x30 */
392 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
393 .idle_supported = 1,
394 .suspend_supported = 1,
395 .idle_enabled = 0,
396 .suspend_enabled = 0,
397 .latency = 500,
398 .residency = 6000,
399 },
400
401 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
402 .idle_supported = 1,
403 .suspend_supported = 1,
404 .idle_enabled = 1,
405 .suspend_enabled = 1,
406 .latency = 2,
407 .residency = 10,
408 },
409
410 /* picked latency & redisdency values from 7x30 */
411 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
412 .idle_supported = 1,
413 .suspend_supported = 1,
414 .idle_enabled = 0,
415 .suspend_enabled = 0,
416 .latency = 500,
417 .residency = 6000,
418 },
419
420 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
421 .idle_supported = 1,
422 .suspend_supported = 1,
423 .idle_enabled = 1,
424 .suspend_enabled = 1,
425 .latency = 2,
426 .residency = 10,
427 },
428
429};
430
Murali Nalajala41786ab2012-03-06 10:47:32 +0530431static struct msm_pm_boot_platform_data msm_pm_8625_boot_pdata __initdata = {
432 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
433 .v_addr = MSM_CFG_CTL_BASE,
434};
435
Trilok Sonib9410792012-04-07 15:37:13 +0530436static struct android_pmem_platform_data android_pmem_adsp_pdata = {
437 .name = "pmem_adsp",
438 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
439 .cached = 1,
440 .memory_type = MEMTYPE_EBI1,
Larry Bassel861985f2012-05-02 15:54:52 -0700441 .request_region = request_fmem_c_region,
442 .release_region = release_fmem_c_region,
443 .reusable = 1,
Trilok Sonib9410792012-04-07 15:37:13 +0530444};
445
446static struct platform_device android_pmem_adsp_device = {
447 .name = "android_pmem",
448 .id = 1,
449 .dev = { .platform_data = &android_pmem_adsp_pdata },
450};
451
452static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
453static int __init pmem_mdp_size_setup(char *p)
454{
455 pmem_mdp_size = memparse(p, NULL);
456 return 0;
457}
458
459early_param("pmem_mdp_size", pmem_mdp_size_setup);
460
461static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
462static int __init pmem_adsp_size_setup(char *p)
463{
464 pmem_adsp_size = memparse(p, NULL);
465 return 0;
466}
467
468early_param("pmem_adsp_size", pmem_adsp_size_setup);
469
470#define SND(desc, num) { .name = #desc, .id = num }
471static struct snd_endpoint snd_endpoints_list[] = {
472 SND(HANDSET, 0),
473 SND(MONO_HEADSET, 2),
474 SND(HEADSET, 3),
475 SND(SPEAKER, 6),
476 SND(TTY_HEADSET, 8),
477 SND(TTY_VCO, 9),
478 SND(TTY_HCO, 10),
479 SND(BT, 12),
480 SND(IN_S_SADC_OUT_HANDSET, 16),
481 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
482 SND(FM_DIGITAL_STEREO_HEADSET, 26),
483 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
484 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
485 SND(STEREO_HEADSET_AND_SPEAKER, 31),
486 SND(CURRENT, 0x7FFFFFFE),
487 SND(FM_ANALOG_STEREO_HEADSET, 35),
488 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
489};
490#undef SND
491
492static struct msm_snd_endpoints msm_device_snd_endpoints = {
493 .endpoints = snd_endpoints_list,
494 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
495};
496
497static struct platform_device msm_device_snd = {
498 .name = "msm_snd",
499 .id = -1,
500 .dev = {
501 .platform_data = &msm_device_snd_endpoints
502 },
503};
504
505#define DEC0_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 DEC1_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 DEC2_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 DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
524 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
525 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
526 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
527 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
528 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
529#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
530
531static unsigned int dec_concurrency_table[] = {
532 /* Audio LP */
533 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
534 0, 0, 0,
535
536 /* Concurrency 1 */
537 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
538 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
539 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
540 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
541 (DEC4_FORMAT),
542
543 /* Concurrency 2 */
544 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
545 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
546 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
547 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
548 (DEC4_FORMAT),
549
550 /* Concurrency 3 */
551 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
552 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
553 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
554 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
555 (DEC4_FORMAT),
556
557 /* Concurrency 4 */
558 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
559 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
560 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
561 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
562 (DEC4_FORMAT),
563
564 /* Concurrency 5 */
565 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
566 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
567 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
568 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
569 (DEC4_FORMAT),
570
571 /* Concurrency 6 */
Chaithanya Krishna Bacharaju72ab89b2012-05-11 14:24:04 +0530572 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|
573 (1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
574 0, 0, 0, 0,
Trilok Sonib9410792012-04-07 15:37:13 +0530575
576 /* Concurrency 7 */
577 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
578 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
579 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
580 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
581 (DEC4_FORMAT),
582};
583
584#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
585 .module_queueid = queueid, .module_decid = decid, \
586 .nr_codec_support = nr_codec}
587
588static struct msm_adspdec_info dec_info_list[] = {
589 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
590 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
591 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
592 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
593 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
594};
595
596static struct msm_adspdec_database msm_device_adspdec_database = {
597 .num_dec = ARRAY_SIZE(dec_info_list),
598 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
599 ARRAY_SIZE(dec_info_list)),
600 .dec_concurrency_table = dec_concurrency_table,
601 .dec_info_list = dec_info_list,
602};
603
604static struct platform_device msm_device_adspdec = {
605 .name = "msm_adspdec",
606 .id = -1,
607 .dev = {
608 .platform_data = &msm_device_adspdec_database
609 },
610};
611
612static struct android_pmem_platform_data android_pmem_audio_pdata = {
613 .name = "pmem_audio",
614 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
615 .cached = 0,
616 .memory_type = MEMTYPE_EBI1,
617};
618
619static struct platform_device android_pmem_audio_device = {
620 .name = "android_pmem",
621 .id = 2,
622 .dev = { .platform_data = &android_pmem_audio_pdata },
623};
624
625static struct android_pmem_platform_data android_pmem_pdata = {
626 .name = "pmem",
627 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
628 .cached = 1,
629 .memory_type = MEMTYPE_EBI1,
630};
631static struct platform_device android_pmem_device = {
632 .name = "android_pmem",
633 .id = 0,
634 .dev = { .platform_data = &android_pmem_pdata },
635};
636
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700637static u32 msm_calculate_batt_capacity(u32 current_voltage);
638
639static struct msm_psy_batt_pdata msm_psy_batt_data = {
Krishna Vanka9a265e12012-06-04 23:24:26 +0530640 .voltage_min_design = 3200,
641 .voltage_max_design = 4200,
642 .voltage_fail_safe = 3340,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700643 .avail_chg_sources = AC_CHG | USB_CHG ,
644 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
645 .calculate_capacity = &msm_calculate_batt_capacity,
646};
647
648static u32 msm_calculate_batt_capacity(u32 current_voltage)
649{
650 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
651 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
652
Krishna Vankab3494692012-06-12 15:06:43 +0530653 if (current_voltage <= low_voltage)
654 return 0;
655 else if (current_voltage >= high_voltage)
656 return 100;
657 else
658 return (current_voltage - low_voltage) * 100
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700659 / (high_voltage - low_voltage);
660}
661
662static struct platform_device msm_batt_device = {
663 .name = "msm-battery",
664 .id = -1,
665 .dev.platform_data = &msm_psy_batt_data,
666};
667
668static struct smsc911x_platform_config smsc911x_config = {
669 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
670 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
671 .flags = SMSC911X_USE_16BIT,
672};
673
674static struct resource smsc911x_resources[] = {
675 [0] = {
676 .start = 0x90000000,
677 .end = 0x90007fff,
678 .flags = IORESOURCE_MEM,
679 },
680 [1] = {
681 .start = MSM_GPIO_TO_INT(48),
682 .end = MSM_GPIO_TO_INT(48),
683 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
684 },
685};
686
687static struct platform_device smsc911x_device = {
688 .name = "smsc911x",
689 .id = 0,
690 .num_resources = ARRAY_SIZE(smsc911x_resources),
691 .resource = smsc911x_resources,
692 .dev = {
693 .platform_data = &smsc911x_config,
694 },
695};
696
697static struct msm_gpio smsc911x_gpios[] = {
698 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
699 "smsc911x_irq" },
700 { GPIO_CFG(49, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
701 "eth_fifo_sel" },
702};
703
Siddartha Mohanadossbc2103f2012-03-20 11:41:48 -0700704static char *msm_adc_surf_device_names[] = {
705 "XO_ADC",
706};
707
708static struct msm_adc_platform_data msm_adc_pdata = {
709 .dev_names = msm_adc_surf_device_names,
710 .num_adc = ARRAY_SIZE(msm_adc_surf_device_names),
711 .target_hw = MSM_8x25,
712};
713
714static struct platform_device msm_adc_device = {
715 .name = "msm_adc",
716 .id = -1,
717 .dev = {
718 .platform_data = &msm_adc_pdata,
719 },
720};
721
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700722#define ETH_FIFO_SEL_GPIO 49
723static void msm7x27a_cfg_smsc911x(void)
724{
725 int res;
726
727 res = msm_gpios_request_enable(smsc911x_gpios,
728 ARRAY_SIZE(smsc911x_gpios));
729 if (res) {
730 pr_err("%s: unable to enable gpios for SMSC911x\n", __func__);
731 return;
732 }
733
734 /* ETH_FIFO_SEL */
735 res = gpio_direction_output(ETH_FIFO_SEL_GPIO, 0);
736 if (res) {
737 pr_err("%s: unable to get direction for gpio %d\n", __func__,
738 ETH_FIFO_SEL_GPIO);
739 msm_gpios_disable_free(smsc911x_gpios,
740 ARRAY_SIZE(smsc911x_gpios));
741 return;
742 }
743 gpio_set_value(ETH_FIFO_SEL_GPIO, 0);
744}
745
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700746#if defined(CONFIG_SERIAL_MSM_HSL_CONSOLE) \
747 && defined(CONFIG_MSM_SHARED_GPIO_FOR_UART2DM)
748static struct msm_gpio uart2dm_gpios[] = {
749 {GPIO_CFG(19, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
750 "uart2dm_rfr_n" },
751 {GPIO_CFG(20, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
752 "uart2dm_cts_n" },
753 {GPIO_CFG(21, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
754 "uart2dm_rx" },
755 {GPIO_CFG(108, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
756 "uart2dm_tx" },
757};
758
759static void msm7x27a_cfg_uart2dm_serial(void)
760{
761 int ret;
762 ret = msm_gpios_request_enable(uart2dm_gpios,
763 ARRAY_SIZE(uart2dm_gpios));
764 if (ret)
765 pr_err("%s: unable to enable gpios for uart2dm\n", __func__);
766}
767#else
768static void msm7x27a_cfg_uart2dm_serial(void) { }
769#endif
770
Taniya Das720c5c32012-05-18 14:08:14 +0530771static struct fmem_platform_data fmem_pdata;
Larry Bassel861985f2012-05-02 15:54:52 -0700772
Taniya Das720c5c32012-05-18 14:08:14 +0530773static struct platform_device fmem_device = {
Larry Bassel861985f2012-05-02 15:54:52 -0700774 .name = "fmem",
775 .id = 1,
776 .dev = { .platform_data = &fmem_pdata },
777};
778
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700779static struct platform_device *rumi_sim_devices[] __initdata = {
780 &msm_device_dmov,
781 &msm_device_smd,
782 &smc91x_device,
783 &msm_device_uart1,
784 &msm_device_nand,
785 &msm_device_uart_dm1,
786 &msm_gsbi0_qup_i2c_device,
787 &msm_gsbi1_qup_i2c_device,
788};
789
Taniya Das43bcdd62011-12-02 17:33:27 +0530790static struct platform_device *msm8625_rumi3_devices[] __initdata = {
791 &msm8625_device_dmov,
Angshuman Sarkarfb1cce92012-02-21 15:20:43 +0530792 &msm8625_device_smd,
Taniya Das43bcdd62011-12-02 17:33:27 +0530793 &msm8625_device_uart1,
Taniya Dase3027e22012-02-27 16:32:27 +0530794 &msm8625_gsbi0_qup_i2c_device,
Taniya Das43bcdd62011-12-02 17:33:27 +0530795};
796
Taniya Dase3027e22012-02-27 16:32:27 +0530797static struct platform_device *msm7627a_surf_ffa_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700798 &msm_device_dmov,
799 &msm_device_smd,
800 &msm_device_uart1,
801 &msm_device_uart_dm1,
802 &msm_device_uart_dm2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700803 &msm_gsbi0_qup_i2c_device,
804 &msm_gsbi1_qup_i2c_device,
805 &msm_device_otg,
806 &msm_device_gadget_peripheral,
Taniya Dase3027e22012-02-27 16:32:27 +0530807 &smsc911x_device,
808 &msm_kgsl_3d0,
809};
810
811static struct platform_device *common_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700812 &android_usb_device,
Trilok Sonib9410792012-04-07 15:37:13 +0530813 &android_pmem_device,
814 &android_pmem_adsp_device,
815 &android_pmem_audio_device,
Larry Bassel861985f2012-05-02 15:54:52 -0700816 &fmem_device,
Taniya Dase3027e22012-02-27 16:32:27 +0530817 &msm_device_nand,
Trilok Sonib9410792012-04-07 15:37:13 +0530818 &msm_device_snd,
819 &msm_device_adspdec,
Manish Dewangan3a260992011-06-24 18:01:34 +0530820 &asoc_msm_pcm,
821 &asoc_msm_dai0,
822 &asoc_msm_dai1,
Taniya Dase3027e22012-02-27 16:32:27 +0530823 &msm_batt_device,
Siddartha Mohanadossbc2103f2012-03-20 11:41:48 -0700824 &msm_adc_device,
Taniya Dase3027e22012-02-27 16:32:27 +0530825};
826
827static struct platform_device *msm8625_surf_devices[] __initdata = {
828 &msm8625_device_dmov,
829 &msm8625_device_uart1,
830 &msm8625_device_uart_dm1,
831 &msm8625_device_uart_dm2,
832 &msm8625_gsbi0_qup_i2c_device,
833 &msm8625_gsbi1_qup_i2c_device,
Taniya Dasf2665302012-02-28 16:54:54 +0530834 &msm8625_device_smd,
Taniya Dase3027e22012-02-27 16:32:27 +0530835 &msm8625_device_otg,
836 &msm8625_device_gadget_peripheral,
Ranjhith Kalisamy4ec2e102012-03-06 12:27:50 +0530837 &msm8625_kgsl_3d0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700838};
839
Trilok Sonib9410792012-04-07 15:37:13 +0530840static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
841static int __init pmem_kernel_ebi1_size_setup(char *p)
842{
843 pmem_kernel_ebi1_size = memparse(p, NULL);
844 return 0;
845}
846early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
847
848static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
849static int __init pmem_audio_size_setup(char *p)
850{
851 pmem_audio_size = memparse(p, NULL);
852 return 0;
853}
854early_param("pmem_audio_size", pmem_audio_size_setup);
855
856static struct memtype_reserve msm7x27a_reserve_table[] __initdata = {
857 [MEMTYPE_SMI] = {
858 },
859 [MEMTYPE_EBI0] = {
860 .flags = MEMTYPE_FLAGS_1M_ALIGN,
861 },
862 [MEMTYPE_EBI1] = {
863 .flags = MEMTYPE_FLAGS_1M_ALIGN,
864 },
865};
866
Larry Bassel861985f2012-05-02 15:54:52 -0700867#ifdef CONFIG_ANDROID_PMEM
868static struct android_pmem_platform_data *pmem_pdata_array[] __initdata = {
869 &android_pmem_adsp_pdata,
870 &android_pmem_audio_pdata,
871 &android_pmem_pdata,
872};
873#endif
874
Trilok Sonib9410792012-04-07 15:37:13 +0530875static void __init size_pmem_devices(void)
876{
Larry Bassel861985f2012-05-02 15:54:52 -0700877#ifdef CONFIG_ANDROID_PMEM
878 unsigned int i;
879 unsigned int reusable_count = 0;
Trilok Sonib9410792012-04-07 15:37:13 +0530880
881 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
882 pmem_mdp_size = MSM7x25A_MSM_PMEM_MDP_SIZE;
883 pmem_adsp_size = MSM7x25A_MSM_PMEM_ADSP_SIZE;
884 } else {
885 pmem_mdp_size = MSM_PMEM_MDP_SIZE;
886 pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
887 }
888
889 android_pmem_adsp_pdata.size = pmem_adsp_size;
890 android_pmem_pdata.size = pmem_mdp_size;
891 android_pmem_audio_pdata.size = pmem_audio_size;
Larry Bassel861985f2012-05-02 15:54:52 -0700892
893 fmem_pdata.size = 0;
Olav Haugan62436252012-05-16 09:09:43 -0700894 fmem_pdata.align = PAGE_SIZE;
Larry Bassel861985f2012-05-02 15:54:52 -0700895
896 /* Find pmem devices that should use FMEM (reusable) memory.
897 */
898 for (i = 0; i < ARRAY_SIZE(pmem_pdata_array); ++i) {
899 struct android_pmem_platform_data *pdata = pmem_pdata_array[i];
900
901 if (!reusable_count && pdata->reusable)
902 fmem_pdata.size += pdata->size;
903
904 reusable_count += (pdata->reusable) ? 1 : 0;
905
906 if (pdata->reusable && reusable_count > 1) {
907 pr_err("%s: Too many PMEM devices specified as reusable. PMEM device %s was not configured as reusable.\n",
908 __func__, pdata->name);
909 pdata->reusable = 0;
910 }
911 }
Trilok Sonib9410792012-04-07 15:37:13 +0530912#endif
Larry Bassel861985f2012-05-02 15:54:52 -0700913
Trilok Sonib9410792012-04-07 15:37:13 +0530914}
915
916static void __init reserve_memory_for(struct android_pmem_platform_data *p)
917{
918 msm7x27a_reserve_table[p->memory_type].size += p->size;
919}
920
921static void __init reserve_pmem_memory(void)
922{
923#ifdef CONFIG_ANDROID_PMEM
Larry Bassel861985f2012-05-02 15:54:52 -0700924 unsigned int i;
925 for (i = 0; i < ARRAY_SIZE(pmem_pdata_array); ++i)
926 reserve_memory_for(pmem_pdata_array[i]);
927
Trilok Sonib9410792012-04-07 15:37:13 +0530928 msm7x27a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
929#endif
930}
931
932static void __init msm7x27a_calculate_reserve_sizes(void)
933{
934 size_pmem_devices();
935 reserve_pmem_memory();
936}
937
938static int msm7x27a_paddr_to_memtype(unsigned int paddr)
939{
940 return MEMTYPE_EBI1;
941}
942
943static struct reserve_info msm7x27a_reserve_info __initdata = {
944 .memtype_reserve_table = msm7x27a_reserve_table,
945 .calculate_reserve_sizes = msm7x27a_calculate_reserve_sizes,
946 .paddr_to_memtype = msm7x27a_paddr_to_memtype,
947};
948
949static void __init msm7x27a_reserve(void)
950{
951 reserve_info = &msm7x27a_reserve_info;
952 msm_reserve();
Trilok Sonib9410792012-04-07 15:37:13 +0530953}
954
Taniya Das2b16d1d2011-12-02 14:44:19 +0530955static void __init msm8625_reserve(void)
956{
Trilok Sonib9410792012-04-07 15:37:13 +0530957 msm7x27a_reserve();
Taniya Dasfe04d4f2012-03-14 11:13:21 +0530958 memblock_remove(MSM8625_SECONDARY_PHYS, SZ_8);
Murali Nalajalafeedeae2012-03-28 16:15:32 +0530959 memblock_remove(MSM8625_WARM_BOOT_PHYS, SZ_32);
Taniya Das2b16d1d2011-12-02 14:44:19 +0530960}
961
Taniya Dase3027e22012-02-27 16:32:27 +0530962static void __init msm7x27a_device_i2c_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700963{
964 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
965 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
966}
967
Taniya Dase3027e22012-02-27 16:32:27 +0530968static void __init msm8625_device_i2c_init(void)
969{
970 msm8625_gsbi0_qup_i2c_device.dev.platform_data =
971 &msm_gsbi0_qup_i2c_pdata;
972 msm8625_gsbi1_qup_i2c_device.dev.platform_data =
973 &msm_gsbi1_qup_i2c_pdata;
974}
975
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700976#define MSM_EBI2_PHYS 0xa0d00000
977#define MSM_EBI2_XMEM_CS2_CFG1 0xa0d10030
978
979static void __init msm7x27a_init_ebi2(void)
980{
981 uint32_t ebi2_cfg;
982 void __iomem *ebi2_cfg_ptr;
983
984 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_PHYS, sizeof(uint32_t));
985 if (!ebi2_cfg_ptr)
986 return;
987
988 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530989 if (machine_is_msm7x27a_rumi3() || machine_is_msm7x27a_surf() ||
Taniya Dase3027e22012-02-27 16:32:27 +0530990 machine_is_msm7625a_surf() || machine_is_msm8625_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700991 ebi2_cfg |= (1 << 4); /* CS2 */
992
993 writel(ebi2_cfg, ebi2_cfg_ptr);
994 iounmap(ebi2_cfg_ptr);
995
996 /* Enable A/D MUX[bit 31] from EBI2_XMEM_CS2_CFG1 */
997 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_XMEM_CS2_CFG1,
998 sizeof(uint32_t));
999 if (!ebi2_cfg_ptr)
1000 return;
1001
1002 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301003 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001004 ebi2_cfg |= (1 << 31);
1005
1006 writel(ebi2_cfg, ebi2_cfg_ptr);
1007 iounmap(ebi2_cfg_ptr);
1008}
1009
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001010static struct platform_device msm_proccomm_regulator_dev = {
1011 .name = PROCCOMM_REGULATOR_DEV_NAME,
1012 .id = -1,
1013 .dev = {
1014 .platform_data = &msm7x27a_proccomm_regulator_data
1015 }
1016};
1017
Trilok Sonib9410792012-04-07 15:37:13 +05301018static void msm_adsp_add_pdev(void)
1019{
1020 int rc = 0;
1021 struct rpc_board_dev *rpc_adsp_pdev;
1022
1023 rpc_adsp_pdev = kzalloc(sizeof(struct rpc_board_dev), GFP_KERNEL);
1024 if (rpc_adsp_pdev == NULL) {
1025 pr_err("%s: Memory Allocation failure\n", __func__);
1026 return;
1027 }
1028 rpc_adsp_pdev->prog = ADSP_RPC_PROG;
1029
1030 if (cpu_is_msm8625())
1031 rpc_adsp_pdev->pdev = msm8625_device_adsp;
1032 else
1033 rpc_adsp_pdev->pdev = msm_adsp_device;
1034 rc = msm_rpc_add_board_dev(rpc_adsp_pdev, 1);
1035 if (rc < 0) {
1036 pr_err("%s: return val: %d\n", __func__, rc);
1037 kfree(rpc_adsp_pdev);
1038 }
1039}
1040
Trilok Soni16f61af2011-07-26 16:06:58 +05301041static void __init msm7627a_rumi3_init(void)
1042{
1043 msm7x27a_init_ebi2();
1044 platform_add_devices(rumi_sim_devices,
1045 ARRAY_SIZE(rumi_sim_devices));
1046}
1047
Taniya Das43bcdd62011-12-02 17:33:27 +05301048static void __init msm8625_rumi3_init(void)
1049{
1050 msm7x2x_misc_init();
Taniya Dase3027e22012-02-27 16:32:27 +05301051 msm_adsp_add_pdev();
1052 msm8625_device_i2c_init();
Taniya Das43bcdd62011-12-02 17:33:27 +05301053 platform_add_devices(msm8625_rumi3_devices,
1054 ARRAY_SIZE(msm8625_rumi3_devices));
Murali Nalajala41786ab2012-03-06 10:47:32 +05301055
Murali Nalajalad1f67b02012-02-10 00:23:49 +05301056 msm_pm_set_platform_data(msm8625_pm_data,
1057 ARRAY_SIZE(msm8625_pm_data));
Murali Nalajala41786ab2012-03-06 10:47:32 +05301058 BUG_ON(msm_pm_boot_init(&msm_pm_8625_boot_pdata));
1059 msm8x25_spm_device_init();
Taniya Das43bcdd62011-12-02 17:33:27 +05301060}
1061
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001062#define UART1DM_RX_GPIO 45
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301063
1064#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
1065static int __init msm7x27a_init_ar6000pm(void)
1066{
Santosh Sajjan374d6592012-01-19 23:16:46 +05301067 msm_wlan_ar6000_pm_device.dev.platform_data = &ar600x_wlan_power;
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301068 return platform_device_register(&msm_wlan_ar6000_pm_device);
1069}
1070#else
1071static int __init msm7x27a_init_ar6000pm(void) { return 0; }
1072#endif
1073
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001074static void __init msm7x27a_init_regulators(void)
1075{
1076 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1077 if (rc)
1078 pr_err("%s: could not register regulator device: %d\n",
1079 __func__, rc);
1080}
1081
Taniya Dase3027e22012-02-27 16:32:27 +05301082static void __init msm7x27a_add_footswitch_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001083{
Trilok Soni16f61af2011-07-26 16:06:58 +05301084 platform_add_devices(msm_footswitch_devices,
1085 msm_num_footswitch_devices);
Taniya Dase3027e22012-02-27 16:32:27 +05301086}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001087
Taniya Dase3027e22012-02-27 16:32:27 +05301088static void __init msm7x27a_add_platform_devices(void)
1089{
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +05301090 if (machine_is_msm8625_surf() || machine_is_msm8625_ffa()) {
Taniya Dase3027e22012-02-27 16:32:27 +05301091 platform_add_devices(msm8625_surf_devices,
1092 ARRAY_SIZE(msm8625_surf_devices));
1093 } else {
1094 platform_add_devices(msm7627a_surf_ffa_devices,
1095 ARRAY_SIZE(msm7627a_surf_ffa_devices));
1096 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001097
Taniya Dase3027e22012-02-27 16:32:27 +05301098 platform_add_devices(common_devices,
1099 ARRAY_SIZE(common_devices));
1100}
1101
1102static void __init msm7x27a_uartdm_config(void)
1103{
1104 msm7x27a_cfg_uart2dm_serial();
1105 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
1106 if (cpu_is_msm8625())
1107 msm8625_device_uart_dm1.dev.platform_data =
1108 &msm_uart_dm1_pdata;
1109 else
1110 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
1111}
1112
1113static void __init msm7x27a_otg_gadget(void)
1114{
Taniya Dase3027e22012-02-27 16:32:27 +05301115 if (cpu_is_msm8625()) {
Murali Nalajala6ff8fb12012-05-02 18:50:50 +05301116 msm_otg_pdata.swfi_latency =
1117 msm8625_pm_data[MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT].latency;
Taniya Dase3027e22012-02-27 16:32:27 +05301118 msm8625_device_otg.dev.platform_data = &msm_otg_pdata;
1119 msm8625_device_gadget_peripheral.dev.platform_data =
1120 &msm_gadget_pdata;
1121 } else {
Murali Nalajala6ff8fb12012-05-02 18:50:50 +05301122 msm_otg_pdata.swfi_latency =
1123 msm7x27a_pm_data[
1124 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
Taniya Dase3027e22012-02-27 16:32:27 +05301125 msm_device_otg.dev.platform_data = &msm_otg_pdata;
1126 msm_device_gadget_peripheral.dev.platform_data =
1127 &msm_gadget_pdata;
1128 }
1129}
1130
Taniya Dase3027e22012-02-27 16:32:27 +05301131static void __init msm7x27a_pm_init(void)
1132{
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +05301133 if (machine_is_msm8625_surf() || machine_is_msm8625_ffa()) {
Murali Nalajala8ee084e2012-03-07 00:09:38 +05301134 msm_pm_set_platform_data(msm8625_pm_data,
1135 ARRAY_SIZE(msm8625_pm_data));
1136 BUG_ON(msm_pm_boot_init(&msm_pm_8625_boot_pdata));
1137 msm8x25_spm_device_init();
1138 } else {
1139 msm_pm_set_platform_data(msm7x27a_pm_data,
1140 ARRAY_SIZE(msm7x27a_pm_data));
1141 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
1142 }
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05301143
1144 msm_pm_register_irqs();
Taniya Dase3027e22012-02-27 16:32:27 +05301145}
1146
1147static void __init msm7x2x_init(void)
1148{
1149 msm7x2x_misc_init();
1150
1151 /* Initialize regulators first so that other devices can use them */
1152 msm7x27a_init_regulators();
1153 msm_adsp_add_pdev();
1154 if (cpu_is_msm8625())
1155 msm8625_device_i2c_init();
1156 else
1157 msm7x27a_device_i2c_init();
1158 msm7x27a_init_ebi2();
1159 msm7x27a_uartdm_config();
1160
1161 msm7x27a_otg_gadget();
1162 msm7x27a_cfg_smsc911x();
1163
1164 msm7x27a_add_footswitch_devices();
1165 msm7x27a_add_platform_devices();
1166 /* Ensure ar6000pm device is registered before MMC/SDC */
1167 msm7x27a_init_ar6000pm();
1168 msm7627a_init_mmc();
1169 msm_fb_add_devices();
1170 msm7x2x_init_host();
1171 msm7x27a_pm_init();
1172 register_i2c_devices();
Steve Mucklef132c6c2012-06-06 18:30:57 -07001173#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Taniya Dase3027e22012-02-27 16:32:27 +05301174 msm7627a_bt_power_init();
Steve Mucklef132c6c2012-06-06 18:30:57 -07001175#endif
Taniya Dase3027e22012-02-27 16:32:27 +05301176 msm7627a_camera_init();
Chintan Pandya0d453192012-03-09 13:20:33 +05301177 msm7627a_add_io_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001178 /*7x25a kgsl initializations*/
1179 msm7x25a_kgsl_3d0_init();
Sudhakara Rao Tentu38ad6e12012-03-30 15:25:18 -07001180 /*8x25 kgsl initializations*/
1181 msm8x25_kgsl_3d0_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001182}
1183
1184static void __init msm7x2x_init_early(void)
1185{
Chintan Pandya250c2e52012-01-19 17:15:49 +05301186 msm_msm7627a_allocate_memory_regions();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001187}
1188
1189MACHINE_START(MSM7X27A_RUMI3, "QCT MSM7x27a RUMI3")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001190 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001191 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301192 .reserve = msm7x27a_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001193 .init_irq = msm_init_irq,
Trilok Soni16f61af2011-07-26 16:06:58 +05301194 .init_machine = msm7627a_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001195 .timer = &msm_timer,
1196 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301197 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001198MACHINE_END
1199MACHINE_START(MSM7X27A_SURF, "QCT MSM7x27a SURF")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001200 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001201 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301202 .reserve = msm7x27a_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001203 .init_irq = msm_init_irq,
1204 .init_machine = msm7x2x_init,
1205 .timer = &msm_timer,
1206 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301207 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001208MACHINE_END
1209MACHINE_START(MSM7X27A_FFA, "QCT MSM7x27a FFA")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001210 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001211 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301212 .reserve = msm7x27a_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001213 .init_irq = msm_init_irq,
1214 .init_machine = msm7x2x_init,
1215 .timer = &msm_timer,
1216 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301217 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001218MACHINE_END
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301219MACHINE_START(MSM7625A_SURF, "QCT MSM7625a SURF")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001220 .atag_offset = 0x100,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301221 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301222 .reserve = msm7x27a_reserve,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301223 .init_irq = msm_init_irq,
1224 .init_machine = msm7x2x_init,
1225 .timer = &msm_timer,
1226 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301227 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301228MACHINE_END
1229MACHINE_START(MSM7625A_FFA, "QCT MSM7625a FFA")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001230 .atag_offset = 0x100,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301231 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301232 .reserve = msm7x27a_reserve,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301233 .init_irq = msm_init_irq,
1234 .init_machine = msm7x2x_init,
1235 .timer = &msm_timer,
1236 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301237 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301238MACHINE_END
Taniya Das43bcdd62011-12-02 17:33:27 +05301239MACHINE_START(MSM8625_RUMI3, "QCT MSM8625 RUMI3")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001240 .atag_offset = 0x100,
Taniya Das43bcdd62011-12-02 17:33:27 +05301241 .map_io = msm8625_map_io,
Taniya Das2b16d1d2011-12-02 14:44:19 +05301242 .reserve = msm8625_reserve,
Taniya Das43bcdd62011-12-02 17:33:27 +05301243 .init_irq = msm8625_init_irq,
1244 .init_machine = msm8625_rumi3_init,
1245 .timer = &msm_timer,
1246 .handle_irq = gic_handle_irq,
1247MACHINE_END
Taniya Dase3027e22012-02-27 16:32:27 +05301248MACHINE_START(MSM8625_SURF, "QCT MSM8625 SURF")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001249 .atag_offset = 0x100,
Taniya Dase3027e22012-02-27 16:32:27 +05301250 .map_io = msm8625_map_io,
1251 .reserve = msm8625_reserve,
1252 .init_irq = msm8625_init_irq,
1253 .init_machine = msm7x2x_init,
1254 .timer = &msm_timer,
1255 .init_early = msm7x2x_init_early,
1256 .handle_irq = gic_handle_irq,
1257MACHINE_END
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +05301258MACHINE_START(MSM8625_FFA, "QCT MSM8625 FFA")
Steve Mucklef132c6c2012-06-06 18:30:57 -07001259 .atag_offset = 0x100,
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +05301260 .map_io = msm8625_map_io,
1261 .reserve = msm8625_reserve,
1262 .init_irq = msm8625_init_irq,
1263 .init_machine = msm7x2x_init,
1264 .timer = &msm_timer,
1265 .init_early = msm7x2x_init_early,
1266 .handle_irq = gic_handle_irq,
1267MACHINE_END