blob: df4ca83810c688d4bbd9788ac3b842cef6797012 [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
Santosh Sajjan6822c682011-07-26 10:49:36 +053084static struct platform_device msm_wlan_ar6000_pm_device = {
85 .name = "wlan_ar6000_pm_dev",
86 .id = -1,
87};
88
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070089#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
90static struct i2c_board_info core_exp_i2c_info[] __initdata = {
91 {
92 I2C_BOARD_INFO("sx1509q", 0x3e),
93 },
94};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070096static void __init register_i2c_devices(void)
97{
Taniya Dase3027e22012-02-27 16:32:27 +053098 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() ||
99 machine_is_msm8625_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700100 sx150x_data[SX150X_CORE].io_open_drain_ena = 0xe0f0;
101
102 core_exp_i2c_info[0].platform_data =
103 &sx150x_data[SX150X_CORE];
104
105 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
106 core_exp_i2c_info,
107 ARRAY_SIZE(core_exp_i2c_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700108}
109#endif
110
111static struct msm_gpio qup_i2c_gpios_io[] = {
112 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
113 "qup_scl" },
114 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
115 "qup_sda" },
116 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
117 "qup_scl" },
118 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
119 "qup_sda" },
120};
121
122static struct msm_gpio qup_i2c_gpios_hw[] = {
123 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
124 "qup_scl" },
125 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
126 "qup_sda" },
127 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
128 "qup_scl" },
129 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
130 "qup_sda" },
131};
132
133static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
134{
135 int rc;
136
137 if (adap_id < 0 || adap_id > 1)
138 return;
139
140 /* Each adapter gets 2 lines from the table */
141 if (config_type)
142 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
143 else
144 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
145 if (rc < 0)
146 pr_err("QUP GPIO request/enable failed: %d\n", rc);
147}
148
149static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
150 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700151 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
152};
153
154static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
155 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700156 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
157};
158
Trilok Sonib9410792012-04-07 15:37:13 +0530159#ifdef CONFIG_ARCH_MSM7X27A
160#define MSM_PMEM_MDP_SIZE 0x2300000
161#define MSM7x25A_MSM_PMEM_MDP_SIZE 0x1500000
162
163#define MSM_PMEM_ADSP_SIZE 0x1100000
164#define MSM7x25A_MSM_PMEM_ADSP_SIZE 0xB91000
165
166#endif
167
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700168static struct android_usb_platform_data android_usb_pdata = {
169 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
170};
171
172static struct platform_device android_usb_device = {
173 .name = "android_usb",
174 .id = -1,
175 .dev = {
176 .platform_data = &android_usb_pdata,
177 },
178};
179
180#ifdef CONFIG_USB_EHCI_MSM_72K
181static void msm_hsusb_vbus_power(unsigned phy_info, int on)
182{
183 int rc = 0;
184 unsigned gpio;
185
186 gpio = GPIO_HOST_VBUS_EN;
187
188 rc = gpio_request(gpio, "i2c_host_vbus_en");
189 if (rc < 0) {
190 pr_err("failed to request %d GPIO\n", gpio);
191 return;
192 }
193 gpio_direction_output(gpio, !!on);
194 gpio_set_value_cansleep(gpio, !!on);
195 gpio_free(gpio);
196}
197
198static struct msm_usb_host_platform_data msm_usb_host_pdata = {
199 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
200};
201
202static void __init msm7x2x_init_host(void)
203{
204 msm_add_host(0, &msm_usb_host_pdata);
205}
206#endif
207
208#ifdef CONFIG_USB_MSM_OTG_72K
209static int hsusb_rpc_connect(int connect)
210{
211 if (connect)
212 return msm_hsusb_rpc_connect();
213 else
214 return msm_hsusb_rpc_close();
215}
216
Justin Paupored98328e2011-08-19 13:48:31 -0700217static struct regulator *reg_hsusb;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700218static int msm_hsusb_ldo_init(int init)
219{
Justin Paupored98328e2011-08-19 13:48:31 -0700220 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700221
Justin Paupored98328e2011-08-19 13:48:31 -0700222 if (init) {
223 reg_hsusb = regulator_get(NULL, "usb");
224 if (IS_ERR(reg_hsusb)) {
225 rc = PTR_ERR(reg_hsusb);
226 pr_err("%s: could not get regulator: %d\n",
227 __func__, rc);
228 goto out;
229 }
230
231 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
232 if (rc) {
233 pr_err("%s: could not set voltage: %d\n",
234 __func__, rc);
235 goto reg_free;
236 }
237
238 return 0;
239 }
240 /* else fall through */
241reg_free:
242 regulator_put(reg_hsusb);
243out:
244 reg_hsusb = NULL;
245 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700246}
247
248static int msm_hsusb_ldo_enable(int enable)
249{
250 static int ldo_status;
251
Justin Paupored98328e2011-08-19 13:48:31 -0700252 if (IS_ERR_OR_NULL(reg_hsusb))
253 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700254
255 if (ldo_status == enable)
256 return 0;
257
258 ldo_status = enable;
259
Justin Paupored98328e2011-08-19 13:48:31 -0700260 return enable ?
261 regulator_enable(reg_hsusb) :
262 regulator_disable(reg_hsusb);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700263}
264
265#ifndef CONFIG_USB_EHCI_MSM_72K
266static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
267{
268 int ret = 0;
269
270 if (init)
271 ret = msm_pm_app_rpc_init(callback);
272 else
273 msm_pm_app_rpc_deinit(callback);
274
275 return ret;
276}
277#endif
278
279static struct msm_otg_platform_data msm_otg_pdata = {
280#ifndef CONFIG_USB_EHCI_MSM_72K
281 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
282#else
283 .vbus_power = msm_hsusb_vbus_power,
284#endif
285 .rpc_connect = hsusb_rpc_connect,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700286 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
287 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
288 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
289 .se1_gating = SE1_GATING_DISABLE,
290 .ldo_init = msm_hsusb_ldo_init,
291 .ldo_enable = msm_hsusb_ldo_enable,
292 .chg_init = hsusb_chg_init,
293 .chg_connected = hsusb_chg_connected,
294 .chg_vbus_draw = hsusb_chg_vbus_draw,
295};
296#endif
297
298static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
299 .is_phy_status_timer_on = 1,
300};
301
302static struct resource smc91x_resources[] = {
303 [0] = {
304 .start = 0x90000300,
305 .end = 0x900003ff,
306 .flags = IORESOURCE_MEM,
307 },
308 [1] = {
309 .start = MSM_GPIO_TO_INT(4),
310 .end = MSM_GPIO_TO_INT(4),
311 .flags = IORESOURCE_IRQ,
312 },
313};
314
315static struct platform_device smc91x_device = {
316 .name = "smc91x",
317 .id = 0,
318 .num_resources = ARRAY_SIZE(smc91x_resources),
319 .resource = smc91x_resources,
320};
321
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700322#ifdef CONFIG_SERIAL_MSM_HS
323static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
324 .inject_rx_on_wakeup = 1,
325 .rx_to_inject = 0xFD,
326};
327#endif
328static struct msm_pm_platform_data msm7x27a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +0530329 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700330 .idle_supported = 1,
331 .suspend_supported = 1,
332 .idle_enabled = 1,
333 .suspend_enabled = 1,
334 .latency = 16000,
335 .residency = 20000,
336 },
Murali Nalajalab10363d2012-01-12 16:29:01 +0530337 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700338 .idle_supported = 1,
339 .suspend_supported = 1,
340 .idle_enabled = 1,
341 .suspend_enabled = 1,
342 .latency = 12000,
343 .residency = 20000,
344 },
Murali Nalajalab10363d2012-01-12 16:29:01 +0530345 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700346 .idle_supported = 1,
347 .suspend_supported = 1,
348 .idle_enabled = 0,
349 .suspend_enabled = 1,
350 .latency = 2000,
351 .residency = 0,
352 },
Murali Nalajalab10363d2012-01-12 16:29:01 +0530353 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700354 .idle_supported = 1,
355 .suspend_supported = 1,
356 .idle_enabled = 1,
357 .suspend_enabled = 1,
358 .latency = 2,
359 .residency = 0,
360 },
361};
362
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600363static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +0530364 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
365 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600366};
367
Murali Nalajalad1f67b02012-02-10 00:23:49 +0530368/* 8625 PM platform data */
369static struct msm_pm_platform_data msm8625_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
370 /* CORE0 entries */
371 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
372 .idle_supported = 1,
373 .suspend_supported = 1,
374 .idle_enabled = 0,
375 .suspend_enabled = 0,
376 .latency = 16000,
377 .residency = 20000,
378 },
379
380 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
381 .idle_supported = 1,
382 .suspend_supported = 1,
383 .idle_enabled = 0,
384 .suspend_enabled = 0,
385 .latency = 12000,
386 .residency = 20000,
387 },
388
389 /* picked latency & redisdency values from 7x30 */
390 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
391 .idle_supported = 1,
392 .suspend_supported = 1,
393 .idle_enabled = 0,
394 .suspend_enabled = 0,
395 .latency = 500,
396 .residency = 6000,
397 },
398
399 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
400 .idle_supported = 1,
401 .suspend_supported = 1,
402 .idle_enabled = 1,
403 .suspend_enabled = 1,
404 .latency = 2,
405 .residency = 10,
406 },
407
408 /* picked latency & redisdency values from 7x30 */
409 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
410 .idle_supported = 1,
411 .suspend_supported = 1,
412 .idle_enabled = 0,
413 .suspend_enabled = 0,
414 .latency = 500,
415 .residency = 6000,
416 },
417
418 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
419 .idle_supported = 1,
420 .suspend_supported = 1,
421 .idle_enabled = 1,
422 .suspend_enabled = 1,
423 .latency = 2,
424 .residency = 10,
425 },
426
427};
428
Murali Nalajala41786ab2012-03-06 10:47:32 +0530429static struct msm_pm_boot_platform_data msm_pm_8625_boot_pdata __initdata = {
430 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
431 .v_addr = MSM_CFG_CTL_BASE,
432};
433
Trilok Sonib9410792012-04-07 15:37:13 +0530434static struct android_pmem_platform_data android_pmem_adsp_pdata = {
435 .name = "pmem_adsp",
436 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
437 .cached = 1,
438 .memory_type = MEMTYPE_EBI1,
Larry Bassel861985f2012-05-02 15:54:52 -0700439 .request_region = request_fmem_c_region,
440 .release_region = release_fmem_c_region,
441 .reusable = 1,
Trilok Sonib9410792012-04-07 15:37:13 +0530442};
443
444static struct platform_device android_pmem_adsp_device = {
445 .name = "android_pmem",
446 .id = 1,
447 .dev = { .platform_data = &android_pmem_adsp_pdata },
448};
449
450static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
451static int __init pmem_mdp_size_setup(char *p)
452{
453 pmem_mdp_size = memparse(p, NULL);
454 return 0;
455}
456
457early_param("pmem_mdp_size", pmem_mdp_size_setup);
458
459static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
460static int __init pmem_adsp_size_setup(char *p)
461{
462 pmem_adsp_size = memparse(p, NULL);
463 return 0;
464}
465
466early_param("pmem_adsp_size", pmem_adsp_size_setup);
467
468#define SND(desc, num) { .name = #desc, .id = num }
469static struct snd_endpoint snd_endpoints_list[] = {
470 SND(HANDSET, 0),
471 SND(MONO_HEADSET, 2),
472 SND(HEADSET, 3),
473 SND(SPEAKER, 6),
474 SND(TTY_HEADSET, 8),
475 SND(TTY_VCO, 9),
476 SND(TTY_HCO, 10),
477 SND(BT, 12),
478 SND(IN_S_SADC_OUT_HANDSET, 16),
479 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
480 SND(FM_DIGITAL_STEREO_HEADSET, 26),
481 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
482 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
483 SND(STEREO_HEADSET_AND_SPEAKER, 31),
484 SND(CURRENT, 0x7FFFFFFE),
485 SND(FM_ANALOG_STEREO_HEADSET, 35),
486 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
487};
488#undef SND
489
490static struct msm_snd_endpoints msm_device_snd_endpoints = {
491 .endpoints = snd_endpoints_list,
492 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
493};
494
495static struct platform_device msm_device_snd = {
496 .name = "msm_snd",
497 .id = -1,
498 .dev = {
499 .platform_data = &msm_device_snd_endpoints
500 },
501};
502
503#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
504 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
505 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
506 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
507 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
508 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
509#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
510 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
511 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
512 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
513 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
514 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
515#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
516 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
517 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
518 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
519 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
520 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
521#define DEC3_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 DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
528
529static unsigned int dec_concurrency_table[] = {
530 /* Audio LP */
531 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
532 0, 0, 0,
533
534 /* Concurrency 1 */
535 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
536 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
537 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
538 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
539 (DEC4_FORMAT),
540
541 /* Concurrency 2 */
542 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
543 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
544 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
545 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
546 (DEC4_FORMAT),
547
548 /* Concurrency 3 */
549 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
550 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
551 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
552 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
553 (DEC4_FORMAT),
554
555 /* Concurrency 4 */
556 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
557 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
558 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
559 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
560 (DEC4_FORMAT),
561
562 /* Concurrency 5 */
563 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
564 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
565 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
566 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
567 (DEC4_FORMAT),
568
569 /* Concurrency 6 */
Chaithanya Krishna Bacharaju72ab89b2012-05-11 14:24:04 +0530570 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|
571 (1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
572 0, 0, 0, 0,
Trilok Sonib9410792012-04-07 15:37:13 +0530573
574 /* Concurrency 7 */
575 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(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
582#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
583 .module_queueid = queueid, .module_decid = decid, \
584 .nr_codec_support = nr_codec}
585
586static struct msm_adspdec_info dec_info_list[] = {
587 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
588 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
589 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
590 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
591 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
592};
593
594static struct msm_adspdec_database msm_device_adspdec_database = {
595 .num_dec = ARRAY_SIZE(dec_info_list),
596 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
597 ARRAY_SIZE(dec_info_list)),
598 .dec_concurrency_table = dec_concurrency_table,
599 .dec_info_list = dec_info_list,
600};
601
602static struct platform_device msm_device_adspdec = {
603 .name = "msm_adspdec",
604 .id = -1,
605 .dev = {
606 .platform_data = &msm_device_adspdec_database
607 },
608};
609
610static struct android_pmem_platform_data android_pmem_audio_pdata = {
611 .name = "pmem_audio",
612 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
613 .cached = 0,
614 .memory_type = MEMTYPE_EBI1,
615};
616
617static struct platform_device android_pmem_audio_device = {
618 .name = "android_pmem",
619 .id = 2,
620 .dev = { .platform_data = &android_pmem_audio_pdata },
621};
622
623static struct android_pmem_platform_data android_pmem_pdata = {
624 .name = "pmem",
625 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
626 .cached = 1,
627 .memory_type = MEMTYPE_EBI1,
628};
629static struct platform_device android_pmem_device = {
630 .name = "android_pmem",
631 .id = 0,
632 .dev = { .platform_data = &android_pmem_pdata },
633};
634
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700635static u32 msm_calculate_batt_capacity(u32 current_voltage);
636
637static struct msm_psy_batt_pdata msm_psy_batt_data = {
638 .voltage_min_design = 2800,
639 .voltage_max_design = 4300,
640 .avail_chg_sources = AC_CHG | USB_CHG ,
641 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
642 .calculate_capacity = &msm_calculate_batt_capacity,
643};
644
645static u32 msm_calculate_batt_capacity(u32 current_voltage)
646{
647 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
648 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
649
650 return (current_voltage - low_voltage) * 100
651 / (high_voltage - low_voltage);
652}
653
654static struct platform_device msm_batt_device = {
655 .name = "msm-battery",
656 .id = -1,
657 .dev.platform_data = &msm_psy_batt_data,
658};
659
660static struct smsc911x_platform_config smsc911x_config = {
661 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
662 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
663 .flags = SMSC911X_USE_16BIT,
664};
665
666static struct resource smsc911x_resources[] = {
667 [0] = {
668 .start = 0x90000000,
669 .end = 0x90007fff,
670 .flags = IORESOURCE_MEM,
671 },
672 [1] = {
673 .start = MSM_GPIO_TO_INT(48),
674 .end = MSM_GPIO_TO_INT(48),
675 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
676 },
677};
678
679static struct platform_device smsc911x_device = {
680 .name = "smsc911x",
681 .id = 0,
682 .num_resources = ARRAY_SIZE(smsc911x_resources),
683 .resource = smsc911x_resources,
684 .dev = {
685 .platform_data = &smsc911x_config,
686 },
687};
688
689static struct msm_gpio smsc911x_gpios[] = {
690 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
691 "smsc911x_irq" },
692 { GPIO_CFG(49, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
693 "eth_fifo_sel" },
694};
695
Siddartha Mohanadossbc2103f2012-03-20 11:41:48 -0700696static char *msm_adc_surf_device_names[] = {
697 "XO_ADC",
698};
699
700static struct msm_adc_platform_data msm_adc_pdata = {
701 .dev_names = msm_adc_surf_device_names,
702 .num_adc = ARRAY_SIZE(msm_adc_surf_device_names),
703 .target_hw = MSM_8x25,
704};
705
706static struct platform_device msm_adc_device = {
707 .name = "msm_adc",
708 .id = -1,
709 .dev = {
710 .platform_data = &msm_adc_pdata,
711 },
712};
713
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700714#define ETH_FIFO_SEL_GPIO 49
715static void msm7x27a_cfg_smsc911x(void)
716{
717 int res;
718
719 res = msm_gpios_request_enable(smsc911x_gpios,
720 ARRAY_SIZE(smsc911x_gpios));
721 if (res) {
722 pr_err("%s: unable to enable gpios for SMSC911x\n", __func__);
723 return;
724 }
725
726 /* ETH_FIFO_SEL */
727 res = gpio_direction_output(ETH_FIFO_SEL_GPIO, 0);
728 if (res) {
729 pr_err("%s: unable to get direction for gpio %d\n", __func__,
730 ETH_FIFO_SEL_GPIO);
731 msm_gpios_disable_free(smsc911x_gpios,
732 ARRAY_SIZE(smsc911x_gpios));
733 return;
734 }
735 gpio_set_value(ETH_FIFO_SEL_GPIO, 0);
736}
737
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700738#if defined(CONFIG_SERIAL_MSM_HSL_CONSOLE) \
739 && defined(CONFIG_MSM_SHARED_GPIO_FOR_UART2DM)
740static struct msm_gpio uart2dm_gpios[] = {
741 {GPIO_CFG(19, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
742 "uart2dm_rfr_n" },
743 {GPIO_CFG(20, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
744 "uart2dm_cts_n" },
745 {GPIO_CFG(21, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
746 "uart2dm_rx" },
747 {GPIO_CFG(108, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
748 "uart2dm_tx" },
749};
750
751static void msm7x27a_cfg_uart2dm_serial(void)
752{
753 int ret;
754 ret = msm_gpios_request_enable(uart2dm_gpios,
755 ARRAY_SIZE(uart2dm_gpios));
756 if (ret)
757 pr_err("%s: unable to enable gpios for uart2dm\n", __func__);
758}
759#else
760static void msm7x27a_cfg_uart2dm_serial(void) { }
761#endif
762
Larry Bassel861985f2012-05-02 15:54:52 -0700763struct fmem_platform_data fmem_pdata;
764
765struct platform_device fmem_device = {
766 .name = "fmem",
767 .id = 1,
768 .dev = { .platform_data = &fmem_pdata },
769};
770
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700771static struct platform_device *rumi_sim_devices[] __initdata = {
772 &msm_device_dmov,
773 &msm_device_smd,
774 &smc91x_device,
775 &msm_device_uart1,
776 &msm_device_nand,
777 &msm_device_uart_dm1,
778 &msm_gsbi0_qup_i2c_device,
779 &msm_gsbi1_qup_i2c_device,
780};
781
Taniya Das43bcdd62011-12-02 17:33:27 +0530782static struct platform_device *msm8625_rumi3_devices[] __initdata = {
783 &msm8625_device_dmov,
Angshuman Sarkarfb1cce92012-02-21 15:20:43 +0530784 &msm8625_device_smd,
Taniya Das43bcdd62011-12-02 17:33:27 +0530785 &msm8625_device_uart1,
Taniya Dase3027e22012-02-27 16:32:27 +0530786 &msm8625_gsbi0_qup_i2c_device,
Taniya Das43bcdd62011-12-02 17:33:27 +0530787};
788
Taniya Dase3027e22012-02-27 16:32:27 +0530789static struct platform_device *msm7627a_surf_ffa_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700790 &msm_device_dmov,
791 &msm_device_smd,
792 &msm_device_uart1,
793 &msm_device_uart_dm1,
794 &msm_device_uart_dm2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700795 &msm_gsbi0_qup_i2c_device,
796 &msm_gsbi1_qup_i2c_device,
797 &msm_device_otg,
798 &msm_device_gadget_peripheral,
Taniya Dase3027e22012-02-27 16:32:27 +0530799 &smsc911x_device,
800 &msm_kgsl_3d0,
801};
802
803static struct platform_device *common_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700804 &android_usb_device,
Trilok Sonib9410792012-04-07 15:37:13 +0530805 &android_pmem_device,
806 &android_pmem_adsp_device,
807 &android_pmem_audio_device,
Larry Bassel861985f2012-05-02 15:54:52 -0700808 &fmem_device,
Taniya Dase3027e22012-02-27 16:32:27 +0530809 &msm_device_nand,
Trilok Sonib9410792012-04-07 15:37:13 +0530810 &msm_device_snd,
811 &msm_device_adspdec,
Manish Dewangan3a260992011-06-24 18:01:34 +0530812 &asoc_msm_pcm,
813 &asoc_msm_dai0,
814 &asoc_msm_dai1,
Taniya Dase3027e22012-02-27 16:32:27 +0530815 &msm_batt_device,
Siddartha Mohanadossbc2103f2012-03-20 11:41:48 -0700816 &msm_adc_device,
Taniya Dase3027e22012-02-27 16:32:27 +0530817};
818
819static struct platform_device *msm8625_surf_devices[] __initdata = {
820 &msm8625_device_dmov,
821 &msm8625_device_uart1,
822 &msm8625_device_uart_dm1,
823 &msm8625_device_uart_dm2,
824 &msm8625_gsbi0_qup_i2c_device,
825 &msm8625_gsbi1_qup_i2c_device,
Taniya Dasf2665302012-02-28 16:54:54 +0530826 &msm8625_device_smd,
Taniya Dase3027e22012-02-27 16:32:27 +0530827 &msm8625_device_otg,
828 &msm8625_device_gadget_peripheral,
Ranjhith Kalisamy4ec2e102012-03-06 12:27:50 +0530829 &msm8625_kgsl_3d0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700830};
831
Trilok Sonib9410792012-04-07 15:37:13 +0530832static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
833static int __init pmem_kernel_ebi1_size_setup(char *p)
834{
835 pmem_kernel_ebi1_size = memparse(p, NULL);
836 return 0;
837}
838early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
839
840static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
841static int __init pmem_audio_size_setup(char *p)
842{
843 pmem_audio_size = memparse(p, NULL);
844 return 0;
845}
846early_param("pmem_audio_size", pmem_audio_size_setup);
847
848static struct memtype_reserve msm7x27a_reserve_table[] __initdata = {
849 [MEMTYPE_SMI] = {
850 },
851 [MEMTYPE_EBI0] = {
852 .flags = MEMTYPE_FLAGS_1M_ALIGN,
853 },
854 [MEMTYPE_EBI1] = {
855 .flags = MEMTYPE_FLAGS_1M_ALIGN,
856 },
857};
858
Larry Bassel861985f2012-05-02 15:54:52 -0700859#ifdef CONFIG_ANDROID_PMEM
860static struct android_pmem_platform_data *pmem_pdata_array[] __initdata = {
861 &android_pmem_adsp_pdata,
862 &android_pmem_audio_pdata,
863 &android_pmem_pdata,
864};
865#endif
866
Trilok Sonib9410792012-04-07 15:37:13 +0530867static void __init size_pmem_devices(void)
868{
Larry Bassel861985f2012-05-02 15:54:52 -0700869#ifdef CONFIG_ANDROID_PMEM
870 unsigned int i;
871 unsigned int reusable_count = 0;
Trilok Sonib9410792012-04-07 15:37:13 +0530872
873 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
874 pmem_mdp_size = MSM7x25A_MSM_PMEM_MDP_SIZE;
875 pmem_adsp_size = MSM7x25A_MSM_PMEM_ADSP_SIZE;
876 } else {
877 pmem_mdp_size = MSM_PMEM_MDP_SIZE;
878 pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
879 }
880
881 android_pmem_adsp_pdata.size = pmem_adsp_size;
882 android_pmem_pdata.size = pmem_mdp_size;
883 android_pmem_audio_pdata.size = pmem_audio_size;
Larry Bassel861985f2012-05-02 15:54:52 -0700884
885 fmem_pdata.size = 0;
886
887 /* Find pmem devices that should use FMEM (reusable) memory.
888 */
889 for (i = 0; i < ARRAY_SIZE(pmem_pdata_array); ++i) {
890 struct android_pmem_platform_data *pdata = pmem_pdata_array[i];
891
892 if (!reusable_count && pdata->reusable)
893 fmem_pdata.size += pdata->size;
894
895 reusable_count += (pdata->reusable) ? 1 : 0;
896
897 if (pdata->reusable && reusable_count > 1) {
898 pr_err("%s: Too many PMEM devices specified as reusable. PMEM device %s was not configured as reusable.\n",
899 __func__, pdata->name);
900 pdata->reusable = 0;
901 }
902 }
Trilok Sonib9410792012-04-07 15:37:13 +0530903#endif
Larry Bassel861985f2012-05-02 15:54:52 -0700904
Trilok Sonib9410792012-04-07 15:37:13 +0530905}
906
907static void __init reserve_memory_for(struct android_pmem_platform_data *p)
908{
909 msm7x27a_reserve_table[p->memory_type].size += p->size;
910}
911
912static void __init reserve_pmem_memory(void)
913{
914#ifdef CONFIG_ANDROID_PMEM
Larry Bassel861985f2012-05-02 15:54:52 -0700915 unsigned int i;
916 for (i = 0; i < ARRAY_SIZE(pmem_pdata_array); ++i)
917 reserve_memory_for(pmem_pdata_array[i]);
918
Trilok Sonib9410792012-04-07 15:37:13 +0530919 msm7x27a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
920#endif
921}
922
923static void __init msm7x27a_calculate_reserve_sizes(void)
924{
925 size_pmem_devices();
926 reserve_pmem_memory();
927}
928
929static int msm7x27a_paddr_to_memtype(unsigned int paddr)
930{
931 return MEMTYPE_EBI1;
932}
933
934static struct reserve_info msm7x27a_reserve_info __initdata = {
935 .memtype_reserve_table = msm7x27a_reserve_table,
936 .calculate_reserve_sizes = msm7x27a_calculate_reserve_sizes,
937 .paddr_to_memtype = msm7x27a_paddr_to_memtype,
938};
939
940static void __init msm7x27a_reserve(void)
941{
942 reserve_info = &msm7x27a_reserve_info;
943 msm_reserve();
Trilok Sonib9410792012-04-07 15:37:13 +0530944}
945
Taniya Das2b16d1d2011-12-02 14:44:19 +0530946static void __init msm8625_reserve(void)
947{
Trilok Sonib9410792012-04-07 15:37:13 +0530948 msm7x27a_reserve();
Taniya Dasfe04d4f2012-03-14 11:13:21 +0530949 memblock_remove(MSM8625_SECONDARY_PHYS, SZ_8);
Murali Nalajalafeedeae2012-03-28 16:15:32 +0530950 memblock_remove(MSM8625_WARM_BOOT_PHYS, SZ_32);
Taniya Das2b16d1d2011-12-02 14:44:19 +0530951}
952
Taniya Dase3027e22012-02-27 16:32:27 +0530953static void __init msm7x27a_device_i2c_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700954{
955 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
956 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
957}
958
Taniya Dase3027e22012-02-27 16:32:27 +0530959static void __init msm8625_device_i2c_init(void)
960{
961 msm8625_gsbi0_qup_i2c_device.dev.platform_data =
962 &msm_gsbi0_qup_i2c_pdata;
963 msm8625_gsbi1_qup_i2c_device.dev.platform_data =
964 &msm_gsbi1_qup_i2c_pdata;
965}
966
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700967#define MSM_EBI2_PHYS 0xa0d00000
968#define MSM_EBI2_XMEM_CS2_CFG1 0xa0d10030
969
970static void __init msm7x27a_init_ebi2(void)
971{
972 uint32_t ebi2_cfg;
973 void __iomem *ebi2_cfg_ptr;
974
975 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_PHYS, sizeof(uint32_t));
976 if (!ebi2_cfg_ptr)
977 return;
978
979 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530980 if (machine_is_msm7x27a_rumi3() || machine_is_msm7x27a_surf() ||
Taniya Dase3027e22012-02-27 16:32:27 +0530981 machine_is_msm7625a_surf() || machine_is_msm8625_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700982 ebi2_cfg |= (1 << 4); /* CS2 */
983
984 writel(ebi2_cfg, ebi2_cfg_ptr);
985 iounmap(ebi2_cfg_ptr);
986
987 /* Enable A/D MUX[bit 31] from EBI2_XMEM_CS2_CFG1 */
988 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_XMEM_CS2_CFG1,
989 sizeof(uint32_t));
990 if (!ebi2_cfg_ptr)
991 return;
992
993 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530994 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700995 ebi2_cfg |= (1 << 31);
996
997 writel(ebi2_cfg, ebi2_cfg_ptr);
998 iounmap(ebi2_cfg_ptr);
999}
1000
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001001static struct platform_device msm_proccomm_regulator_dev = {
1002 .name = PROCCOMM_REGULATOR_DEV_NAME,
1003 .id = -1,
1004 .dev = {
1005 .platform_data = &msm7x27a_proccomm_regulator_data
1006 }
1007};
1008
Trilok Sonib9410792012-04-07 15:37:13 +05301009static void msm_adsp_add_pdev(void)
1010{
1011 int rc = 0;
1012 struct rpc_board_dev *rpc_adsp_pdev;
1013
1014 rpc_adsp_pdev = kzalloc(sizeof(struct rpc_board_dev), GFP_KERNEL);
1015 if (rpc_adsp_pdev == NULL) {
1016 pr_err("%s: Memory Allocation failure\n", __func__);
1017 return;
1018 }
1019 rpc_adsp_pdev->prog = ADSP_RPC_PROG;
1020
1021 if (cpu_is_msm8625())
1022 rpc_adsp_pdev->pdev = msm8625_device_adsp;
1023 else
1024 rpc_adsp_pdev->pdev = msm_adsp_device;
1025 rc = msm_rpc_add_board_dev(rpc_adsp_pdev, 1);
1026 if (rc < 0) {
1027 pr_err("%s: return val: %d\n", __func__, rc);
1028 kfree(rpc_adsp_pdev);
1029 }
1030}
1031
Trilok Soni16f61af2011-07-26 16:06:58 +05301032static void __init msm7627a_rumi3_init(void)
1033{
1034 msm7x27a_init_ebi2();
1035 platform_add_devices(rumi_sim_devices,
1036 ARRAY_SIZE(rumi_sim_devices));
1037}
1038
Taniya Das43bcdd62011-12-02 17:33:27 +05301039static void __init msm8625_rumi3_init(void)
1040{
1041 msm7x2x_misc_init();
Taniya Dase3027e22012-02-27 16:32:27 +05301042 msm_adsp_add_pdev();
1043 msm8625_device_i2c_init();
Taniya Das43bcdd62011-12-02 17:33:27 +05301044 platform_add_devices(msm8625_rumi3_devices,
1045 ARRAY_SIZE(msm8625_rumi3_devices));
Murali Nalajala41786ab2012-03-06 10:47:32 +05301046
Murali Nalajalad1f67b02012-02-10 00:23:49 +05301047 msm_pm_set_platform_data(msm8625_pm_data,
1048 ARRAY_SIZE(msm8625_pm_data));
Murali Nalajala41786ab2012-03-06 10:47:32 +05301049 BUG_ON(msm_pm_boot_init(&msm_pm_8625_boot_pdata));
1050 msm8x25_spm_device_init();
Taniya Das43bcdd62011-12-02 17:33:27 +05301051}
1052
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001053#define UART1DM_RX_GPIO 45
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301054
1055#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
1056static int __init msm7x27a_init_ar6000pm(void)
1057{
Santosh Sajjan374d6592012-01-19 23:16:46 +05301058 msm_wlan_ar6000_pm_device.dev.platform_data = &ar600x_wlan_power;
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301059 return platform_device_register(&msm_wlan_ar6000_pm_device);
1060}
1061#else
1062static int __init msm7x27a_init_ar6000pm(void) { return 0; }
1063#endif
1064
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001065static void __init msm7x27a_init_regulators(void)
1066{
1067 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1068 if (rc)
1069 pr_err("%s: could not register regulator device: %d\n",
1070 __func__, rc);
1071}
1072
Taniya Dase3027e22012-02-27 16:32:27 +05301073static void __init msm7x27a_add_footswitch_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001074{
Trilok Soni16f61af2011-07-26 16:06:58 +05301075 platform_add_devices(msm_footswitch_devices,
1076 msm_num_footswitch_devices);
Taniya Dase3027e22012-02-27 16:32:27 +05301077}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001078
Taniya Dase3027e22012-02-27 16:32:27 +05301079static void __init msm7x27a_add_platform_devices(void)
1080{
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +05301081 if (machine_is_msm8625_surf() || machine_is_msm8625_ffa()) {
Taniya Dase3027e22012-02-27 16:32:27 +05301082 platform_add_devices(msm8625_surf_devices,
1083 ARRAY_SIZE(msm8625_surf_devices));
1084 } else {
1085 platform_add_devices(msm7627a_surf_ffa_devices,
1086 ARRAY_SIZE(msm7627a_surf_ffa_devices));
1087 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001088
Taniya Dase3027e22012-02-27 16:32:27 +05301089 platform_add_devices(common_devices,
1090 ARRAY_SIZE(common_devices));
1091}
1092
1093static void __init msm7x27a_uartdm_config(void)
1094{
1095 msm7x27a_cfg_uart2dm_serial();
1096 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
1097 if (cpu_is_msm8625())
1098 msm8625_device_uart_dm1.dev.platform_data =
1099 &msm_uart_dm1_pdata;
1100 else
1101 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
1102}
1103
1104static void __init msm7x27a_otg_gadget(void)
1105{
Taniya Dase3027e22012-02-27 16:32:27 +05301106 if (cpu_is_msm8625()) {
Murali Nalajala6ff8fb12012-05-02 18:50:50 +05301107 msm_otg_pdata.swfi_latency =
1108 msm8625_pm_data[MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT].latency;
Taniya Dase3027e22012-02-27 16:32:27 +05301109 msm8625_device_otg.dev.platform_data = &msm_otg_pdata;
1110 msm8625_device_gadget_peripheral.dev.platform_data =
1111 &msm_gadget_pdata;
1112 } else {
Murali Nalajala6ff8fb12012-05-02 18:50:50 +05301113 msm_otg_pdata.swfi_latency =
1114 msm7x27a_pm_data[
1115 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
Taniya Dase3027e22012-02-27 16:32:27 +05301116 msm_device_otg.dev.platform_data = &msm_otg_pdata;
1117 msm_device_gadget_peripheral.dev.platform_data =
1118 &msm_gadget_pdata;
1119 }
1120}
1121
Taniya Dase3027e22012-02-27 16:32:27 +05301122static void __init msm7x27a_pm_init(void)
1123{
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +05301124 if (machine_is_msm8625_surf() || machine_is_msm8625_ffa()) {
Murali Nalajala8ee084e2012-03-07 00:09:38 +05301125 msm_pm_set_platform_data(msm8625_pm_data,
1126 ARRAY_SIZE(msm8625_pm_data));
1127 BUG_ON(msm_pm_boot_init(&msm_pm_8625_boot_pdata));
1128 msm8x25_spm_device_init();
1129 } else {
1130 msm_pm_set_platform_data(msm7x27a_pm_data,
1131 ARRAY_SIZE(msm7x27a_pm_data));
1132 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
1133 }
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05301134
1135 msm_pm_register_irqs();
Taniya Dase3027e22012-02-27 16:32:27 +05301136}
1137
1138static void __init msm7x2x_init(void)
1139{
1140 msm7x2x_misc_init();
1141
1142 /* Initialize regulators first so that other devices can use them */
1143 msm7x27a_init_regulators();
1144 msm_adsp_add_pdev();
1145 if (cpu_is_msm8625())
1146 msm8625_device_i2c_init();
1147 else
1148 msm7x27a_device_i2c_init();
1149 msm7x27a_init_ebi2();
1150 msm7x27a_uartdm_config();
1151
1152 msm7x27a_otg_gadget();
1153 msm7x27a_cfg_smsc911x();
1154
1155 msm7x27a_add_footswitch_devices();
1156 msm7x27a_add_platform_devices();
1157 /* Ensure ar6000pm device is registered before MMC/SDC */
1158 msm7x27a_init_ar6000pm();
1159 msm7627a_init_mmc();
1160 msm_fb_add_devices();
1161 msm7x2x_init_host();
1162 msm7x27a_pm_init();
1163 register_i2c_devices();
1164 msm7627a_bt_power_init();
1165 msm7627a_camera_init();
Chintan Pandya0d453192012-03-09 13:20:33 +05301166 msm7627a_add_io_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001167 /*7x25a kgsl initializations*/
1168 msm7x25a_kgsl_3d0_init();
Sudhakara Rao Tentu38ad6e12012-03-30 15:25:18 -07001169 /*8x25 kgsl initializations*/
1170 msm8x25_kgsl_3d0_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001171}
1172
1173static void __init msm7x2x_init_early(void)
1174{
Chintan Pandya250c2e52012-01-19 17:15:49 +05301175 msm_msm7627a_allocate_memory_regions();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001176}
1177
1178MACHINE_START(MSM7X27A_RUMI3, "QCT MSM7x27a RUMI3")
1179 .boot_params = PHYS_OFFSET + 0x100,
1180 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301181 .reserve = msm7x27a_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001182 .init_irq = msm_init_irq,
Trilok Soni16f61af2011-07-26 16:06:58 +05301183 .init_machine = msm7627a_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001184 .timer = &msm_timer,
1185 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301186 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001187MACHINE_END
1188MACHINE_START(MSM7X27A_SURF, "QCT MSM7x27a SURF")
1189 .boot_params = PHYS_OFFSET + 0x100,
1190 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301191 .reserve = msm7x27a_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001192 .init_irq = msm_init_irq,
1193 .init_machine = msm7x2x_init,
1194 .timer = &msm_timer,
1195 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301196 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001197MACHINE_END
1198MACHINE_START(MSM7X27A_FFA, "QCT MSM7x27a FFA")
1199 .boot_params = PHYS_OFFSET + 0x100,
1200 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301201 .reserve = msm7x27a_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001202 .init_irq = msm_init_irq,
1203 .init_machine = msm7x2x_init,
1204 .timer = &msm_timer,
1205 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301206 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001207MACHINE_END
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301208MACHINE_START(MSM7625A_SURF, "QCT MSM7625a SURF")
1209 .boot_params = PHYS_OFFSET + 0x100,
1210 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301211 .reserve = msm7x27a_reserve,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301212 .init_irq = msm_init_irq,
1213 .init_machine = msm7x2x_init,
1214 .timer = &msm_timer,
1215 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301216 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301217MACHINE_END
1218MACHINE_START(MSM7625A_FFA, "QCT MSM7625a FFA")
1219 .boot_params = PHYS_OFFSET + 0x100,
1220 .map_io = msm_common_io_init,
Trilok Sonib9410792012-04-07 15:37:13 +05301221 .reserve = msm7x27a_reserve,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301222 .init_irq = msm_init_irq,
1223 .init_machine = msm7x2x_init,
1224 .timer = &msm_timer,
1225 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301226 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301227MACHINE_END
Taniya Das43bcdd62011-12-02 17:33:27 +05301228MACHINE_START(MSM8625_RUMI3, "QCT MSM8625 RUMI3")
1229 .boot_params = PHYS_OFFSET + 0x100,
1230 .map_io = msm8625_map_io,
Taniya Das2b16d1d2011-12-02 14:44:19 +05301231 .reserve = msm8625_reserve,
Taniya Das43bcdd62011-12-02 17:33:27 +05301232 .init_irq = msm8625_init_irq,
1233 .init_machine = msm8625_rumi3_init,
1234 .timer = &msm_timer,
1235 .handle_irq = gic_handle_irq,
1236MACHINE_END
Taniya Dase3027e22012-02-27 16:32:27 +05301237MACHINE_START(MSM8625_SURF, "QCT MSM8625 SURF")
1238 .boot_params = PHYS_OFFSET + 0x100,
1239 .map_io = msm8625_map_io,
1240 .reserve = msm8625_reserve,
1241 .init_irq = msm8625_init_irq,
1242 .init_machine = msm7x2x_init,
1243 .timer = &msm_timer,
1244 .init_early = msm7x2x_init_early,
1245 .handle_irq = gic_handle_irq,
1246MACHINE_END
Aparna Mallavarapu9f000a72012-04-20 15:37:57 +05301247MACHINE_START(MSM8625_FFA, "QCT MSM8625 FFA")
1248 .boot_params = PHYS_OFFSET + 0x100,
1249 .map_io = msm8625_map_io,
1250 .reserve = msm8625_reserve,
1251 .init_irq = msm8625_init_irq,
1252 .init_machine = msm7x2x_init,
1253 .timer = &msm_timer,
1254 .init_early = msm7x2x_init_early,
1255 .handle_irq = gic_handle_irq,
1256MACHINE_END