blob: d059b8db177ac9d08a3e8232496a1178a90a6ff4 [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>
17#include <asm/mach/arch.h>
Taniya Das43bcdd62011-12-02 17:33:27 +053018#include <asm/hardware/gic.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070019#include <mach/board.h>
20#include <mach/msm_iomap.h>
21#include <mach/msm_hsusb.h>
22#include <mach/rpc_hsusb.h>
23#include <mach/rpc_pmapp.h>
24#include <mach/usbdiag.h>
25#include <mach/msm_memtypes.h>
26#include <mach/msm_serial_hs.h>
27#include <linux/usb/android.h>
28#include <linux/platform_device.h>
29#include <linux/io.h>
30#include <linux/gpio.h>
31#include <mach/vreg.h>
32#include <mach/pmic.h>
33#include <mach/socinfo.h>
34#include <linux/mtd/nand.h>
35#include <linux/mtd/partitions.h>
36#include <asm/mach/mmc.h>
37#include <linux/i2c.h>
38#include <linux/i2c/sx150x.h>
39#include <linux/gpio.h>
40#include <linux/android_pmem.h>
41#include <linux/bootmem.h>
42#include <linux/mfd/marimba.h>
43#include <mach/vreg.h>
44#include <linux/power_supply.h>
Justin Paupored98328e2011-08-19 13:48:31 -070045#include <linux/regulator/consumer.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046#include <mach/rpc_pmapp.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070047#include <mach/msm_battery.h>
48#include <linux/smsc911x.h>
49#include <linux/atmel_maxtouch.h>
Laura Abbott8f3d58b2011-12-18 10:47:03 -080050#include <linux/fmem.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051#include "devices.h"
52#include "timer.h"
Justin Pauporeb3a33b72011-08-23 15:30:32 -070053#include "board-msm7x27a-regulator.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070054#include "devices-msm7x2xa.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080055#include "pm.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056#include <mach/rpc_server_handset.h>
57#include <mach/socinfo.h>
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -060058#include "pm-boot.h"
Chintan Pandyacf467fc2011-12-01 17:11:11 +053059#include "board-msm7627a.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060
61#define PMEM_KERNEL_EBI1_SIZE 0x3A000
62#define MSM_PMEM_AUDIO_SIZE 0x5B000
Laxminath Kasam5faa1ca2012-02-15 12:06:45 +053063#define ADSP_RPC_PROG 0x3000000a
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070064
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070065#if defined(CONFIG_GPIO_SX150X)
66enum {
67 SX150X_CORE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070068};
69
70static struct sx150x_platform_data sx150x_data[] __initdata = {
71 [SX150X_CORE] = {
72 .gpio_base = GPIO_CORE_EXPANDER_BASE,
73 .oscio_is_gpo = false,
74 .io_pullup_ena = 0,
pankaj kumarc5c01392011-08-12 13:44:05 +053075 .io_pulldn_ena = 0x02,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076 .io_open_drain_ena = 0xfef8,
77 .irq_summary = -1,
78 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070079};
80#endif
81
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070082
Santosh Sajjan6822c682011-07-26 10:49:36 +053083static struct platform_device msm_wlan_ar6000_pm_device = {
84 .name = "wlan_ar6000_pm_dev",
85 .id = -1,
86};
87
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070088#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
89static struct i2c_board_info core_exp_i2c_info[] __initdata = {
90 {
91 I2C_BOARD_INFO("sx1509q", 0x3e),
92 },
93};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070094
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095static void __init register_i2c_devices(void)
96{
Trilok Soni3d0f6c52011-07-26 16:06:58 +053097 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070098 sx150x_data[SX150X_CORE].io_open_drain_ena = 0xe0f0;
99
100 core_exp_i2c_info[0].platform_data =
101 &sx150x_data[SX150X_CORE];
102
103 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
104 core_exp_i2c_info,
105 ARRAY_SIZE(core_exp_i2c_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700106}
107#endif
108
109static struct msm_gpio qup_i2c_gpios_io[] = {
110 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
111 "qup_scl" },
112 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
113 "qup_sda" },
114 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
115 "qup_scl" },
116 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
117 "qup_sda" },
118};
119
120static struct msm_gpio qup_i2c_gpios_hw[] = {
121 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
122 "qup_scl" },
123 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
124 "qup_sda" },
125 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
126 "qup_scl" },
127 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
128 "qup_sda" },
129};
130
131static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
132{
133 int rc;
134
135 if (adap_id < 0 || adap_id > 1)
136 return;
137
138 /* Each adapter gets 2 lines from the table */
139 if (config_type)
140 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
141 else
142 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
143 if (rc < 0)
144 pr_err("QUP GPIO request/enable failed: %d\n", rc);
145}
146
147static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
148 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700149 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
150};
151
152static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
153 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700154 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
155};
156
Taniya Das9d187142011-12-02 15:53:25 +0530157static struct msm_i2c_platform_data msm8625_gsbi0_qup_i2c_pdata = {
158 .clk_freq = 100000,
159};
160
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700161#ifdef CONFIG_ARCH_MSM7X27A
Neti Ravi Kumar061726e2011-12-08 15:14:57 +0530162#define MSM_PMEM_MDP_SIZE 0x2300000
163#define MSM7x25A_MSM_PMEM_MDP_SIZE 0x1500000
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530164
Mahesh Lankaa2f6df12012-01-05 16:54:40 +0530165#define MSM_PMEM_ADSP_SIZE 0x1100000
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530166#define MSM7x25A_MSM_PMEM_ADSP_SIZE 0xB91000
167
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700168#endif
169
170static 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
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700370static struct android_pmem_platform_data android_pmem_adsp_pdata = {
371 .name = "pmem_adsp",
372 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
Mahesh Lankac6af7eb2011-08-02 18:00:35 +0530373 .cached = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700374 .memory_type = MEMTYPE_EBI1,
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800375 .request_region = request_fmem_c_region,
376 .release_region = release_fmem_c_region,
377 .reusable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700378};
379
380static struct platform_device android_pmem_adsp_device = {
381 .name = "android_pmem",
382 .id = 1,
383 .dev = { .platform_data = &android_pmem_adsp_pdata },
384};
385
386static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
387static int __init pmem_mdp_size_setup(char *p)
388{
389 pmem_mdp_size = memparse(p, NULL);
390 return 0;
391}
392
393early_param("pmem_mdp_size", pmem_mdp_size_setup);
394
395static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
396static int __init pmem_adsp_size_setup(char *p)
397{
398 pmem_adsp_size = memparse(p, NULL);
399 return 0;
400}
401
402early_param("pmem_adsp_size", pmem_adsp_size_setup);
403
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700404#define SND(desc, num) { .name = #desc, .id = num }
405static struct snd_endpoint snd_endpoints_list[] = {
406 SND(HANDSET, 0),
407 SND(MONO_HEADSET, 2),
408 SND(HEADSET, 3),
409 SND(SPEAKER, 6),
410 SND(TTY_HEADSET, 8),
411 SND(TTY_VCO, 9),
412 SND(TTY_HCO, 10),
413 SND(BT, 12),
414 SND(IN_S_SADC_OUT_HANDSET, 16),
415 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
416 SND(FM_DIGITAL_STEREO_HEADSET, 26),
417 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
418 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
Shashi Kumar64e07602011-10-11 13:18:57 +0530419 SND(STEREO_HEADSET_AND_SPEAKER, 31),
Sidipotu Ashokab34ca42011-07-22 16:34:20 +0530420 SND(CURRENT, 0x7FFFFFFE),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700421 SND(FM_ANALOG_STEREO_HEADSET, 35),
422 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
423};
424#undef SND
425
426static struct msm_snd_endpoints msm_device_snd_endpoints = {
427 .endpoints = snd_endpoints_list,
428 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
429};
430
431static struct platform_device msm_device_snd = {
432 .name = "msm_snd",
433 .id = -1,
434 .dev = {
435 .platform_data = &msm_device_snd_endpoints
436 },
437};
438
439#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
440 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
441 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
442 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
443 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
444 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
445#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
446 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
447 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
448 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
449 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
450 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
451#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
452 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
453 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
454 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
455 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
456 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
457#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
458 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
459 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
460 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
461 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
462 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
463#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
464
465static unsigned int dec_concurrency_table[] = {
466 /* Audio LP */
467 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
468 0, 0, 0,
469
470 /* Concurrency 1 */
471 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
472 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
473 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
474 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
475 (DEC4_FORMAT),
476
477 /* Concurrency 2 */
478 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
479 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
480 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
481 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
482 (DEC4_FORMAT),
483
484 /* Concurrency 3 */
485 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
486 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
487 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
488 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
489 (DEC4_FORMAT),
490
491 /* Concurrency 4 */
492 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
493 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
494 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
495 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
496 (DEC4_FORMAT),
497
498 /* Concurrency 5 */
499 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
500 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
501 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
502 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
503 (DEC4_FORMAT),
504
505 /* Concurrency 6 */
506 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
507 0, 0, 0, 0,
508
509 /* Concurrency 7 */
510 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
511 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
512 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
513 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
514 (DEC4_FORMAT),
515};
516
517#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
518 .module_queueid = queueid, .module_decid = decid, \
519 .nr_codec_support = nr_codec}
520
521static struct msm_adspdec_info dec_info_list[] = {
522 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
523 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
524 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
525 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
526 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
527};
528
529static struct msm_adspdec_database msm_device_adspdec_database = {
530 .num_dec = ARRAY_SIZE(dec_info_list),
531 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
532 ARRAY_SIZE(dec_info_list)),
533 .dec_concurrency_table = dec_concurrency_table,
534 .dec_info_list = dec_info_list,
535};
536
537static struct platform_device msm_device_adspdec = {
538 .name = "msm_adspdec",
539 .id = -1,
540 .dev = {
541 .platform_data = &msm_device_adspdec_database
542 },
543};
544
545static struct android_pmem_platform_data android_pmem_audio_pdata = {
546 .name = "pmem_audio",
547 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
548 .cached = 0,
549 .memory_type = MEMTYPE_EBI1,
550};
551
552static struct platform_device android_pmem_audio_device = {
553 .name = "android_pmem",
554 .id = 2,
555 .dev = { .platform_data = &android_pmem_audio_pdata },
556};
557
558static struct android_pmem_platform_data android_pmem_pdata = {
559 .name = "pmem",
560 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
561 .cached = 1,
562 .memory_type = MEMTYPE_EBI1,
563};
564static struct platform_device android_pmem_device = {
565 .name = "android_pmem",
566 .id = 0,
567 .dev = { .platform_data = &android_pmem_pdata },
568};
569
570static u32 msm_calculate_batt_capacity(u32 current_voltage);
571
572static struct msm_psy_batt_pdata msm_psy_batt_data = {
573 .voltage_min_design = 2800,
574 .voltage_max_design = 4300,
575 .avail_chg_sources = AC_CHG | USB_CHG ,
576 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
577 .calculate_capacity = &msm_calculate_batt_capacity,
578};
579
580static u32 msm_calculate_batt_capacity(u32 current_voltage)
581{
582 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
583 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
584
585 return (current_voltage - low_voltage) * 100
586 / (high_voltage - low_voltage);
587}
588
589static struct platform_device msm_batt_device = {
590 .name = "msm-battery",
591 .id = -1,
592 .dev.platform_data = &msm_psy_batt_data,
593};
594
595static struct smsc911x_platform_config smsc911x_config = {
596 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
597 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
598 .flags = SMSC911X_USE_16BIT,
599};
600
601static struct resource smsc911x_resources[] = {
602 [0] = {
603 .start = 0x90000000,
604 .end = 0x90007fff,
605 .flags = IORESOURCE_MEM,
606 },
607 [1] = {
608 .start = MSM_GPIO_TO_INT(48),
609 .end = MSM_GPIO_TO_INT(48),
610 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
611 },
612};
613
614static struct platform_device smsc911x_device = {
615 .name = "smsc911x",
616 .id = 0,
617 .num_resources = ARRAY_SIZE(smsc911x_resources),
618 .resource = smsc911x_resources,
619 .dev = {
620 .platform_data = &smsc911x_config,
621 },
622};
623
624static struct msm_gpio smsc911x_gpios[] = {
625 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
626 "smsc911x_irq" },
627 { GPIO_CFG(49, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
628 "eth_fifo_sel" },
629};
630
631#define ETH_FIFO_SEL_GPIO 49
632static void msm7x27a_cfg_smsc911x(void)
633{
634 int res;
635
636 res = msm_gpios_request_enable(smsc911x_gpios,
637 ARRAY_SIZE(smsc911x_gpios));
638 if (res) {
639 pr_err("%s: unable to enable gpios for SMSC911x\n", __func__);
640 return;
641 }
642
643 /* ETH_FIFO_SEL */
644 res = gpio_direction_output(ETH_FIFO_SEL_GPIO, 0);
645 if (res) {
646 pr_err("%s: unable to get direction for gpio %d\n", __func__,
647 ETH_FIFO_SEL_GPIO);
648 msm_gpios_disable_free(smsc911x_gpios,
649 ARRAY_SIZE(smsc911x_gpios));
650 return;
651 }
652 gpio_set_value(ETH_FIFO_SEL_GPIO, 0);
653}
654
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700655#if defined(CONFIG_SERIAL_MSM_HSL_CONSOLE) \
656 && defined(CONFIG_MSM_SHARED_GPIO_FOR_UART2DM)
657static struct msm_gpio uart2dm_gpios[] = {
658 {GPIO_CFG(19, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
659 "uart2dm_rfr_n" },
660 {GPIO_CFG(20, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
661 "uart2dm_cts_n" },
662 {GPIO_CFG(21, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
663 "uart2dm_rx" },
664 {GPIO_CFG(108, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
665 "uart2dm_tx" },
666};
667
668static void msm7x27a_cfg_uart2dm_serial(void)
669{
670 int ret;
671 ret = msm_gpios_request_enable(uart2dm_gpios,
672 ARRAY_SIZE(uart2dm_gpios));
673 if (ret)
674 pr_err("%s: unable to enable gpios for uart2dm\n", __func__);
675}
676#else
677static void msm7x27a_cfg_uart2dm_serial(void) { }
678#endif
679
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800680struct fmem_platform_data fmem_pdata;
681
682struct platform_device fmem_device = {
683 .name = "fmem",
684 .id = -1,
685 .dev = { .platform_data = &fmem_pdata },
686};
687
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700688static struct platform_device *rumi_sim_devices[] __initdata = {
689 &msm_device_dmov,
690 &msm_device_smd,
691 &smc91x_device,
692 &msm_device_uart1,
693 &msm_device_nand,
694 &msm_device_uart_dm1,
695 &msm_gsbi0_qup_i2c_device,
696 &msm_gsbi1_qup_i2c_device,
697};
698
Taniya Das43bcdd62011-12-02 17:33:27 +0530699static struct platform_device *msm8625_rumi3_devices[] __initdata = {
700 &msm8625_device_dmov,
701 &msm8625_device_uart1,
Taniya Das9d187142011-12-02 15:53:25 +0530702 &msm8625_device_qup_i2c_gsbi0,
Taniya Das43bcdd62011-12-02 17:33:27 +0530703};
704
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700705static struct platform_device *surf_ffa_devices[] __initdata = {
706 &msm_device_dmov,
707 &msm_device_smd,
708 &msm_device_uart1,
709 &msm_device_uart_dm1,
710 &msm_device_uart_dm2,
711 &msm_device_nand,
712 &msm_gsbi0_qup_i2c_device,
713 &msm_gsbi1_qup_i2c_device,
714 &msm_device_otg,
715 &msm_device_gadget_peripheral,
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800716 &fmem_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700717 &android_usb_device,
718 &android_pmem_device,
719 &android_pmem_adsp_device,
720 &android_pmem_audio_device,
721 &msm_device_snd,
722 &msm_device_adspdec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700723 &msm_batt_device,
724 &smsc911x_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700725 &msm_kgsl_3d0,
726#ifdef CONFIG_BT
727 &msm_bt_power_device,
728#endif
Manish Dewangan3a260992011-06-24 18:01:34 +0530729 &asoc_msm_pcm,
730 &asoc_msm_dai0,
731 &asoc_msm_dai1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700732};
733
734static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
735static int __init pmem_kernel_ebi1_size_setup(char *p)
736{
737 pmem_kernel_ebi1_size = memparse(p, NULL);
738 return 0;
739}
740early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
741
742static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
743static int __init pmem_audio_size_setup(char *p)
744{
745 pmem_audio_size = memparse(p, NULL);
746 return 0;
747}
748early_param("pmem_audio_size", pmem_audio_size_setup);
749
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700750static struct memtype_reserve msm7x27a_reserve_table[] __initdata = {
751 [MEMTYPE_SMI] = {
752 },
753 [MEMTYPE_EBI0] = {
754 .flags = MEMTYPE_FLAGS_1M_ALIGN,
755 },
756 [MEMTYPE_EBI1] = {
757 .flags = MEMTYPE_FLAGS_1M_ALIGN,
758 },
759};
760
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800761#ifdef CONFIG_ANDROID_PMEM
762static struct android_pmem_platform_data *pmem_pdata_array[] __initdata = {
763 &android_pmem_adsp_pdata,
764 &android_pmem_audio_pdata,
765 &android_pmem_pdata,
766};
767#endif
768
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700769static void __init size_pmem_devices(void)
770{
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800771#ifdef CONFIG_ANDROID_PMEM
772 unsigned int i;
773 unsigned int reusable_count = 0;
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530774
775 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
776 pmem_mdp_size = MSM7x25A_MSM_PMEM_MDP_SIZE;
777 pmem_adsp_size = MSM7x25A_MSM_PMEM_ADSP_SIZE;
778 } else {
779 pmem_mdp_size = MSM_PMEM_MDP_SIZE;
780 pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
781 }
782
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700783 android_pmem_adsp_pdata.size = pmem_adsp_size;
784 android_pmem_pdata.size = pmem_mdp_size;
785 android_pmem_audio_pdata.size = pmem_audio_size;
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800786
787 fmem_pdata.size = 0;
788
789 /* Find pmem devices that should use FMEM (reusable) memory.
790 */
791 for (i = 0; i < ARRAY_SIZE(pmem_pdata_array); ++i) {
792 struct android_pmem_platform_data *pdata = pmem_pdata_array[i];
793
794 if (!reusable_count && pdata->reusable)
795 fmem_pdata.size += pdata->size;
796
797 reusable_count += (pdata->reusable) ? 1 : 0;
798
799 if (pdata->reusable && reusable_count > 1) {
800 pr_err("%s: Too many PMEM devices specified as reusable. PMEM device %s was not configured as reusable.\n",
801 __func__, pdata->name);
802 pdata->reusable = 0;
803 }
804 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700805#endif
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800806
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700807}
808
809static void __init reserve_memory_for(struct android_pmem_platform_data *p)
810{
811 msm7x27a_reserve_table[p->memory_type].size += p->size;
812}
813
814static void __init reserve_pmem_memory(void)
815{
816#ifdef CONFIG_ANDROID_PMEM
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800817 unsigned int i;
818 for (i = 0; i < ARRAY_SIZE(pmem_pdata_array); ++i) {
819 if (!pmem_pdata_array[i]->reusable)
820 reserve_memory_for(pmem_pdata_array[i]);
821 }
822
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700823 msm7x27a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
824#endif
825}
826
827static void __init msm7x27a_calculate_reserve_sizes(void)
828{
829 size_pmem_devices();
830 reserve_pmem_memory();
831}
832
833static int msm7x27a_paddr_to_memtype(unsigned int paddr)
834{
835 return MEMTYPE_EBI1;
836}
837
838static struct reserve_info msm7x27a_reserve_info __initdata = {
839 .memtype_reserve_table = msm7x27a_reserve_table,
840 .calculate_reserve_sizes = msm7x27a_calculate_reserve_sizes,
841 .paddr_to_memtype = msm7x27a_paddr_to_memtype,
842};
843
844static void __init msm7x27a_reserve(void)
845{
846 reserve_info = &msm7x27a_reserve_info;
847 msm_reserve();
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800848 fmem_pdata.phys = reserve_memory_for_fmem(fmem_pdata.size);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700849}
850
Taniya Das2b16d1d2011-12-02 14:44:19 +0530851static void __init msm8625_reserve(void)
852{
853 memblock_remove(MSM8625_SECONDARY_PHYS, SZ_8);
854}
855
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700856static void __init msm_device_i2c_init(void)
857{
Taniya Das9d187142011-12-02 15:53:25 +0530858 if (machine_is_msm8625_rumi3()) {
859 msm8625_device_qup_i2c_gsbi0.dev.platform_data =
860 &msm8625_gsbi0_qup_i2c_pdata;
861 return;
862 }
863
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700864 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
865 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
866}
867
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700868#define MSM_EBI2_PHYS 0xa0d00000
869#define MSM_EBI2_XMEM_CS2_CFG1 0xa0d10030
870
871static void __init msm7x27a_init_ebi2(void)
872{
873 uint32_t ebi2_cfg;
874 void __iomem *ebi2_cfg_ptr;
875
876 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_PHYS, sizeof(uint32_t));
877 if (!ebi2_cfg_ptr)
878 return;
879
880 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530881 if (machine_is_msm7x27a_rumi3() || machine_is_msm7x27a_surf() ||
882 machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700883 ebi2_cfg |= (1 << 4); /* CS2 */
884
885 writel(ebi2_cfg, ebi2_cfg_ptr);
886 iounmap(ebi2_cfg_ptr);
887
888 /* Enable A/D MUX[bit 31] from EBI2_XMEM_CS2_CFG1 */
889 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_XMEM_CS2_CFG1,
890 sizeof(uint32_t));
891 if (!ebi2_cfg_ptr)
892 return;
893
894 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530895 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700896 ebi2_cfg |= (1 << 31);
897
898 writel(ebi2_cfg, ebi2_cfg_ptr);
899 iounmap(ebi2_cfg_ptr);
900}
901
902#define ATMEL_TS_I2C_NAME "maXTouch"
Justin Paupored98328e2011-08-19 13:48:31 -0700903
904static struct regulator_bulk_data regs_atmel[] = {
905 { .supply = "ldo2", .min_uV = 2850000, .max_uV = 2850000 },
906 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
907};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700908
909#define ATMEL_TS_GPIO_IRQ 82
910
911static int atmel_ts_power_on(bool on)
912{
Justin Paupored98328e2011-08-19 13:48:31 -0700913 int rc = on ?
914 regulator_bulk_enable(ARRAY_SIZE(regs_atmel), regs_atmel) :
915 regulator_bulk_disable(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700916
Justin Paupored98328e2011-08-19 13:48:31 -0700917 if (rc)
918 pr_err("%s: could not %sable regulators: %d\n",
919 __func__, on ? "en" : "dis", rc);
920 else
921 msleep(50);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700922
Justin Paupored98328e2011-08-19 13:48:31 -0700923 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700924}
925
926static int atmel_ts_platform_init(struct i2c_client *client)
927{
928 int rc;
Justin Paupored98328e2011-08-19 13:48:31 -0700929 struct device *dev = &client->dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700930
Justin Paupored98328e2011-08-19 13:48:31 -0700931 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700932 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700933 dev_err(dev, "%s: could not get regulators: %d\n",
934 __func__, rc);
935 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700936 }
937
Justin Paupored98328e2011-08-19 13:48:31 -0700938 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700939 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700940 dev_err(dev, "%s: could not set voltages: %d\n",
941 __func__, rc);
942 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700943 }
944
945 rc = gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
946 GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
947 GPIO_CFG_8MA), GPIO_CFG_ENABLE);
948 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700949 dev_err(dev, "%s: gpio_tlmm_config for %d failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700950 __func__, ATMEL_TS_GPIO_IRQ);
Justin Paupored98328e2011-08-19 13:48:31 -0700951 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700952 }
953
954 /* configure touchscreen interrupt gpio */
955 rc = gpio_request(ATMEL_TS_GPIO_IRQ, "atmel_maxtouch_gpio");
956 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700957 dev_err(dev, "%s: unable to request gpio %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700958 __func__, ATMEL_TS_GPIO_IRQ);
959 goto ts_gpio_tlmm_unconfig;
960 }
961
962 rc = gpio_direction_input(ATMEL_TS_GPIO_IRQ);
963 if (rc < 0) {
Justin Paupored98328e2011-08-19 13:48:31 -0700964 dev_err(dev, "%s: unable to set the direction of gpio %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700965 __func__, ATMEL_TS_GPIO_IRQ);
966 goto free_ts_gpio;
967 }
968 return 0;
969
970free_ts_gpio:
971 gpio_free(ATMEL_TS_GPIO_IRQ);
972ts_gpio_tlmm_unconfig:
973 gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
974 GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
975 GPIO_CFG_2MA), GPIO_CFG_DISABLE);
Justin Paupored98328e2011-08-19 13:48:31 -0700976reg_free:
977 regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel);
978out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700979 return rc;
980}
981
982static int atmel_ts_platform_exit(struct i2c_client *client)
983{
984 gpio_free(ATMEL_TS_GPIO_IRQ);
985 gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
986 GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
987 GPIO_CFG_2MA), GPIO_CFG_DISABLE);
Justin Paupored98328e2011-08-19 13:48:31 -0700988 regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700989 return 0;
990}
991
992static u8 atmel_ts_read_chg(void)
993{
994 return gpio_get_value(ATMEL_TS_GPIO_IRQ);
995}
996
997static u8 atmel_ts_valid_interrupt(void)
998{
999 return !atmel_ts_read_chg();
1000}
1001
1002#define ATMEL_X_OFFSET 13
1003#define ATMEL_Y_OFFSET 0
1004
Mohan Pallaka4e9a94e2011-11-23 16:34:21 +05301005static struct maxtouch_platform_data atmel_ts_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001006 .numtouch = 4,
1007 .init_platform_hw = atmel_ts_platform_init,
1008 .exit_platform_hw = atmel_ts_platform_exit,
1009 .power_on = atmel_ts_power_on,
1010 .display_res_x = 480,
1011 .display_res_y = 864,
1012 .min_x = ATMEL_X_OFFSET,
1013 .max_x = (505 - ATMEL_X_OFFSET),
1014 .min_y = ATMEL_Y_OFFSET,
1015 .max_y = (863 - ATMEL_Y_OFFSET),
1016 .valid_interrupt = atmel_ts_valid_interrupt,
1017 .read_chg = atmel_ts_read_chg,
1018};
1019
1020static struct i2c_board_info atmel_ts_i2c_info[] __initdata = {
1021 {
1022 I2C_BOARD_INFO(ATMEL_TS_I2C_NAME, 0x4a),
1023 .platform_data = &atmel_ts_pdata,
1024 .irq = MSM_GPIO_TO_INT(ATMEL_TS_GPIO_IRQ),
1025 },
1026};
1027
1028#define KP_INDEX(row, col) ((row)*ARRAY_SIZE(kp_col_gpios) + (col))
1029
1030static unsigned int kp_row_gpios[] = {31, 32, 33, 34, 35};
1031static unsigned int kp_col_gpios[] = {36, 37, 38, 39, 40};
1032
1033static const unsigned short keymap[ARRAY_SIZE(kp_col_gpios) *
1034 ARRAY_SIZE(kp_row_gpios)] = {
1035 [KP_INDEX(0, 0)] = KEY_7,
1036 [KP_INDEX(0, 1)] = KEY_DOWN,
1037 [KP_INDEX(0, 2)] = KEY_UP,
1038 [KP_INDEX(0, 3)] = KEY_RIGHT,
1039 [KP_INDEX(0, 4)] = KEY_ENTER,
1040
1041 [KP_INDEX(1, 0)] = KEY_LEFT,
1042 [KP_INDEX(1, 1)] = KEY_SEND,
1043 [KP_INDEX(1, 2)] = KEY_1,
1044 [KP_INDEX(1, 3)] = KEY_4,
1045 [KP_INDEX(1, 4)] = KEY_CLEAR,
1046
1047 [KP_INDEX(2, 0)] = KEY_6,
1048 [KP_INDEX(2, 1)] = KEY_5,
1049 [KP_INDEX(2, 2)] = KEY_8,
1050 [KP_INDEX(2, 3)] = KEY_3,
1051 [KP_INDEX(2, 4)] = KEY_NUMERIC_STAR,
1052
1053 [KP_INDEX(3, 0)] = KEY_9,
1054 [KP_INDEX(3, 1)] = KEY_NUMERIC_POUND,
1055 [KP_INDEX(3, 2)] = KEY_0,
1056 [KP_INDEX(3, 3)] = KEY_2,
1057 [KP_INDEX(3, 4)] = KEY_SLEEP,
1058
1059 [KP_INDEX(4, 0)] = KEY_BACK,
1060 [KP_INDEX(4, 1)] = KEY_HOME,
1061 [KP_INDEX(4, 2)] = KEY_MENU,
1062 [KP_INDEX(4, 3)] = KEY_VOLUMEUP,
1063 [KP_INDEX(4, 4)] = KEY_VOLUMEDOWN,
1064};
1065
1066/* SURF keypad platform device information */
1067static struct gpio_event_matrix_info kp_matrix_info = {
1068 .info.func = gpio_event_matrix_func,
1069 .keymap = keymap,
1070 .output_gpios = kp_row_gpios,
1071 .input_gpios = kp_col_gpios,
1072 .noutputs = ARRAY_SIZE(kp_row_gpios),
1073 .ninputs = ARRAY_SIZE(kp_col_gpios),
1074 .settle_time.tv_nsec = 40 * NSEC_PER_USEC,
1075 .poll_time.tv_nsec = 20 * NSEC_PER_MSEC,
1076 .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE |
1077 GPIOKPF_PRINT_UNMAPPED_KEYS,
1078};
1079
1080static struct gpio_event_info *kp_info[] = {
1081 &kp_matrix_info.info
1082};
1083
1084static struct gpio_event_platform_data kp_pdata = {
1085 .name = "7x27a_kp",
1086 .info = kp_info,
1087 .info_count = ARRAY_SIZE(kp_info)
1088};
1089
1090static struct platform_device kp_pdev = {
1091 .name = GPIO_EVENT_DEV_NAME,
1092 .id = -1,
1093 .dev = {
1094 .platform_data = &kp_pdata,
1095 },
1096};
1097
1098static struct msm_handset_platform_data hs_platform_data = {
1099 .hs_name = "7k_handset",
1100 .pwr_key_delay_ms = 500, /* 0 will disable end key */
1101};
1102
1103static struct platform_device hs_pdev = {
1104 .name = "msm-handset",
1105 .id = -1,
1106 .dev = {
1107 .platform_data = &hs_platform_data,
1108 },
1109};
1110
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001111static struct platform_device msm_proccomm_regulator_dev = {
1112 .name = PROCCOMM_REGULATOR_DEV_NAME,
1113 .id = -1,
1114 .dev = {
1115 .platform_data = &msm7x27a_proccomm_regulator_data
1116 }
1117};
1118
Laxminath Kasam5faa1ca2012-02-15 12:06:45 +05301119static void msm_adsp_add_pdev(void)
1120{
1121 int rc = 0;
1122 struct rpc_board_dev *rpc_adsp_pdev;
1123
1124 rpc_adsp_pdev = kzalloc(sizeof(struct rpc_board_dev), GFP_KERNEL);
1125 if (rpc_adsp_pdev == NULL) {
1126 pr_err("%s: Memory Allocation failure\n", __func__);
1127 return;
1128 }
1129 rpc_adsp_pdev->prog = ADSP_RPC_PROG;
1130 rpc_adsp_pdev->pdev = msm_adsp_device;
1131 rc = msm_rpc_add_board_dev(rpc_adsp_pdev, 1);
1132 if (rc < 0) {
1133 pr_err("%s: return val: %d\n", __func__, rc);
1134 kfree(rpc_adsp_pdev);
1135 }
1136}
1137
1138static void msm_adsp_8625_add_pdev(void)
1139{
1140 int rc = 0;
1141 struct rpc_board_dev *rpc_adsp_pdev;
1142
1143 rpc_adsp_pdev = kzalloc(sizeof(struct rpc_board_dev), GFP_KERNEL);
1144 if (rpc_adsp_pdev == NULL) {
1145 pr_err("%s: Memory Allocation failure\n", __func__);
1146 return;
1147 }
1148 rpc_adsp_pdev->prog = ADSP_RPC_PROG;
1149 rpc_adsp_pdev->pdev = msm8625_device_adsp;
1150 rc = msm_rpc_add_board_dev(rpc_adsp_pdev, 1);
1151 if (rc < 0) {
1152 pr_err("%s: return val: %d\n", __func__, rc);
1153 kfree(rpc_adsp_pdev);
1154 }
1155}
1156
Trilok Soni16f61af2011-07-26 16:06:58 +05301157static void __init msm7627a_rumi3_init(void)
1158{
1159 msm7x27a_init_ebi2();
1160 platform_add_devices(rumi_sim_devices,
1161 ARRAY_SIZE(rumi_sim_devices));
1162}
1163
Taniya Das43bcdd62011-12-02 17:33:27 +05301164static void __init msm8625_rumi3_init(void)
1165{
1166 msm7x2x_misc_init();
Laxminath Kasam5faa1ca2012-02-15 12:06:45 +05301167 msm_adsp_8625_add_pdev();
Taniya Das9d187142011-12-02 15:53:25 +05301168 msm_device_i2c_init();
Taniya Das43bcdd62011-12-02 17:33:27 +05301169 platform_add_devices(msm8625_rumi3_devices,
1170 ARRAY_SIZE(msm8625_rumi3_devices));
1171}
1172
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001173#define LED_GPIO_PDM 96
1174#define UART1DM_RX_GPIO 45
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301175
1176#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
1177static int __init msm7x27a_init_ar6000pm(void)
1178{
Santosh Sajjan374d6592012-01-19 23:16:46 +05301179 msm_wlan_ar6000_pm_device.dev.platform_data = &ar600x_wlan_power;
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301180 return platform_device_register(&msm_wlan_ar6000_pm_device);
1181}
1182#else
1183static int __init msm7x27a_init_ar6000pm(void) { return 0; }
1184#endif
1185
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001186static void __init msm7x27a_init_regulators(void)
1187{
1188 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1189 if (rc)
1190 pr_err("%s: could not register regulator device: %d\n",
1191 __func__, rc);
1192}
1193
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001194static void __init msm7x2x_init(void)
1195{
Trilok Sonia416c492011-07-22 20:20:23 +05301196 msm7x2x_misc_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001197
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001198 /* Initialize regulators first so that other devices can use them */
1199 msm7x27a_init_regulators();
1200
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001201 /* Common functions for SURF/FFA/RUMI3 */
Laxminath Kasam5faa1ca2012-02-15 12:06:45 +05301202 msm_adsp_add_pdev();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001203 msm_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001204 msm7x27a_init_ebi2();
1205 msm7x27a_cfg_uart2dm_serial();
1206#ifdef CONFIG_SERIAL_MSM_HS
1207 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
1208 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
1209#endif
1210
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001211#ifdef CONFIG_USB_MSM_OTG_72K
Trilok Soni16f61af2011-07-26 16:06:58 +05301212 msm_otg_pdata.swfi_latency =
1213 msm7x27a_pm_data
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001214 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
Trilok Soni16f61af2011-07-26 16:06:58 +05301215 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001216#endif
Trilok Soni16f61af2011-07-26 16:06:58 +05301217 msm_device_gadget_peripheral.dev.platform_data =
1218 &msm_gadget_pdata;
1219 msm7x27a_cfg_smsc911x();
1220 platform_add_devices(msm_footswitch_devices,
1221 msm_num_footswitch_devices);
1222 platform_add_devices(surf_ffa_devices,
1223 ARRAY_SIZE(surf_ffa_devices));
Sujith Reddy Thummaad7c9a82011-09-30 20:54:38 +05301224 /* Ensure ar6000pm device is registered before MMC/SDC */
1225 msm7x27a_init_ar6000pm();
1226#ifdef CONFIG_MMC_MSM
Chintan Pandyacf467fc2011-12-01 17:11:11 +05301227 msm7627a_init_mmc();
Sujith Reddy Thummaad7c9a82011-09-30 20:54:38 +05301228#endif
Trilok Soni16f61af2011-07-26 16:06:58 +05301229 msm_fb_add_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001230#ifdef CONFIG_USB_EHCI_MSM_72K
Trilok Soni16f61af2011-07-26 16:06:58 +05301231 msm7x2x_init_host();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001232#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001233
1234 msm_pm_set_platform_data(msm7x27a_pm_data,
1235 ARRAY_SIZE(msm7x27a_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06001236 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001237
1238#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
1239 register_i2c_devices();
1240#endif
1241#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Chintan Pandya13490c02011-12-20 13:03:36 +05301242 msm7627a_bt_power_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001243#endif
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301244 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001245 atmel_ts_pdata.min_x = 0;
1246 atmel_ts_pdata.max_x = 480;
1247 atmel_ts_pdata.min_y = 0;
1248 atmel_ts_pdata.max_y = 320;
1249 }
1250
1251 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
1252 atmel_ts_i2c_info,
1253 ARRAY_SIZE(atmel_ts_i2c_info));
1254
Pankaj Kumar5be2a3e2011-09-26 11:45:02 +05301255#if defined(CONFIG_MSM_CAMERA)
Chintan Pandya40762702011-12-06 13:47:06 +05301256 msm7627a_camera_init();
Pankaj Kumar5be2a3e2011-09-26 11:45:02 +05301257#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001258 platform_device_register(&kp_pdev);
1259 platform_device_register(&hs_pdev);
1260
1261 /* configure it as a pdm function*/
1262 if (gpio_tlmm_config(GPIO_CFG(LED_GPIO_PDM, 3,
1263 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
1264 GPIO_CFG_8MA), GPIO_CFG_ENABLE))
1265 pr_err("%s: gpio_tlmm_config for %d failed\n",
1266 __func__, LED_GPIO_PDM);
1267 else
1268 platform_device_register(&led_pdev);
1269
1270#ifdef CONFIG_MSM_RPC_VIBRATOR
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301271 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001272 msm_init_pmic_vibrator();
1273#endif
1274 /*7x25a kgsl initializations*/
1275 msm7x25a_kgsl_3d0_init();
1276}
1277
1278static void __init msm7x2x_init_early(void)
1279{
Chintan Pandya250c2e52012-01-19 17:15:49 +05301280 msm_msm7627a_allocate_memory_regions();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001281}
1282
1283MACHINE_START(MSM7X27A_RUMI3, "QCT MSM7x27a RUMI3")
1284 .boot_params = PHYS_OFFSET + 0x100,
1285 .map_io = msm_common_io_init,
1286 .reserve = msm7x27a_reserve,
1287 .init_irq = msm_init_irq,
Trilok Soni16f61af2011-07-26 16:06:58 +05301288 .init_machine = msm7627a_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001289 .timer = &msm_timer,
1290 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301291 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001292MACHINE_END
1293MACHINE_START(MSM7X27A_SURF, "QCT MSM7x27a SURF")
1294 .boot_params = PHYS_OFFSET + 0x100,
1295 .map_io = msm_common_io_init,
1296 .reserve = msm7x27a_reserve,
1297 .init_irq = msm_init_irq,
1298 .init_machine = msm7x2x_init,
1299 .timer = &msm_timer,
1300 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301301 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001302MACHINE_END
1303MACHINE_START(MSM7X27A_FFA, "QCT MSM7x27a FFA")
1304 .boot_params = PHYS_OFFSET + 0x100,
1305 .map_io = msm_common_io_init,
1306 .reserve = msm7x27a_reserve,
1307 .init_irq = msm_init_irq,
1308 .init_machine = msm7x2x_init,
1309 .timer = &msm_timer,
1310 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301311 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001312MACHINE_END
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301313MACHINE_START(MSM7625A_SURF, "QCT MSM7625a SURF")
1314 .boot_params = PHYS_OFFSET + 0x100,
1315 .map_io = msm_common_io_init,
1316 .reserve = msm7x27a_reserve,
1317 .init_irq = msm_init_irq,
1318 .init_machine = msm7x2x_init,
1319 .timer = &msm_timer,
1320 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301321 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301322MACHINE_END
1323MACHINE_START(MSM7625A_FFA, "QCT MSM7625a FFA")
1324 .boot_params = PHYS_OFFSET + 0x100,
1325 .map_io = msm_common_io_init,
1326 .reserve = msm7x27a_reserve,
1327 .init_irq = msm_init_irq,
1328 .init_machine = msm7x2x_init,
1329 .timer = &msm_timer,
1330 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301331 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301332MACHINE_END
Taniya Das43bcdd62011-12-02 17:33:27 +05301333MACHINE_START(MSM8625_RUMI3, "QCT MSM8625 RUMI3")
1334 .boot_params = PHYS_OFFSET + 0x100,
1335 .map_io = msm8625_map_io,
Taniya Das2b16d1d2011-12-02 14:44:19 +05301336 .reserve = msm8625_reserve,
Taniya Das43bcdd62011-12-02 17:33:27 +05301337 .init_irq = msm8625_init_irq,
1338 .init_machine = msm8625_rumi3_init,
1339 .timer = &msm_timer,
1340 .handle_irq = gic_handle_irq,
1341MACHINE_END