blob: 77db7962da7ee12906835271eb12cc22151505f7 [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>
15#include <asm/mach-types.h>
16#include <asm/mach/arch.h>
17#include <mach/board.h>
18#include <mach/msm_iomap.h>
19#include <mach/msm_hsusb.h>
20#include <mach/rpc_hsusb.h>
21#include <mach/rpc_pmapp.h>
22#include <mach/usbdiag.h>
23#include <mach/msm_memtypes.h>
24#include <mach/msm_serial_hs.h>
25#include <linux/usb/android.h>
26#include <linux/platform_device.h>
27#include <linux/io.h>
28#include <linux/gpio.h>
29#include <mach/vreg.h>
30#include <mach/pmic.h>
31#include <mach/socinfo.h>
32#include <linux/mtd/nand.h>
33#include <linux/mtd/partitions.h>
34#include <asm/mach/mmc.h>
35#include <linux/i2c.h>
36#include <linux/i2c/sx150x.h>
37#include <linux/gpio.h>
38#include <linux/android_pmem.h>
39#include <linux/bootmem.h>
40#include <linux/mfd/marimba.h>
41#include <mach/vreg.h>
42#include <linux/power_supply.h>
Justin Paupored98328e2011-08-19 13:48:31 -070043#include <linux/regulator/consumer.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070044#include <mach/rpc_pmapp.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070045#include <mach/msm_battery.h>
46#include <linux/smsc911x.h>
47#include <linux/atmel_maxtouch.h>
48#include "devices.h"
49#include "timer.h"
Justin Pauporeb3a33b72011-08-23 15:30:32 -070050#include "board-msm7x27a-regulator.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051#include "devices-msm7x2xa.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080052#include <mach/pm.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070053#include <mach/rpc_server_handset.h>
54#include <mach/socinfo.h>
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -060055#include "pm-boot.h"
Chintan Pandyacf467fc2011-12-01 17:11:11 +053056#include "board-msm7627a.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070057
58#define PMEM_KERNEL_EBI1_SIZE 0x3A000
59#define MSM_PMEM_AUDIO_SIZE 0x5B000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070061#if defined(CONFIG_GPIO_SX150X)
62enum {
63 SX150X_CORE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070064};
65
66static struct sx150x_platform_data sx150x_data[] __initdata = {
67 [SX150X_CORE] = {
68 .gpio_base = GPIO_CORE_EXPANDER_BASE,
69 .oscio_is_gpo = false,
70 .io_pullup_ena = 0,
pankaj kumarc5c01392011-08-12 13:44:05 +053071 .io_pulldn_ena = 0x02,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070072 .io_open_drain_ena = 0xfef8,
73 .irq_summary = -1,
74 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070075};
76#endif
77
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070078
Santosh Sajjan6822c682011-07-26 10:49:36 +053079static struct platform_device msm_wlan_ar6000_pm_device = {
80 .name = "wlan_ar6000_pm_dev",
81 .id = -1,
82};
83
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070084#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
85static struct i2c_board_info core_exp_i2c_info[] __initdata = {
86 {
87 I2C_BOARD_INFO("sx1509q", 0x3e),
88 },
89};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070090
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070091static void __init register_i2c_devices(void)
92{
Trilok Soni3d0f6c52011-07-26 16:06:58 +053093 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070094 sx150x_data[SX150X_CORE].io_open_drain_ena = 0xe0f0;
95
96 core_exp_i2c_info[0].platform_data =
97 &sx150x_data[SX150X_CORE];
98
99 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
100 core_exp_i2c_info,
101 ARRAY_SIZE(core_exp_i2c_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700102}
103#endif
104
105static struct msm_gpio qup_i2c_gpios_io[] = {
106 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
107 "qup_scl" },
108 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
109 "qup_sda" },
110 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
111 "qup_scl" },
112 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
113 "qup_sda" },
114};
115
116static struct msm_gpio qup_i2c_gpios_hw[] = {
117 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
118 "qup_scl" },
119 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
120 "qup_sda" },
121 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
122 "qup_scl" },
123 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
124 "qup_sda" },
125};
126
127static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
128{
129 int rc;
130
131 if (adap_id < 0 || adap_id > 1)
132 return;
133
134 /* Each adapter gets 2 lines from the table */
135 if (config_type)
136 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
137 else
138 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
139 if (rc < 0)
140 pr_err("QUP GPIO request/enable failed: %d\n", rc);
141}
142
143static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
144 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700145 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
146};
147
148static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
149 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700150 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
151};
152
153#ifdef CONFIG_ARCH_MSM7X27A
Neti Ravi Kumar061726e2011-12-08 15:14:57 +0530154#define MSM_PMEM_MDP_SIZE 0x2300000
155#define MSM7x25A_MSM_PMEM_MDP_SIZE 0x1500000
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530156
Mahesh Lankaa2f6df12012-01-05 16:54:40 +0530157#define MSM_PMEM_ADSP_SIZE 0x1100000
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530158#define MSM7x25A_MSM_PMEM_ADSP_SIZE 0xB91000
159
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700160#endif
161
162static struct android_usb_platform_data android_usb_pdata = {
163 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
164};
165
166static struct platform_device android_usb_device = {
167 .name = "android_usb",
168 .id = -1,
169 .dev = {
170 .platform_data = &android_usb_pdata,
171 },
172};
173
174#ifdef CONFIG_USB_EHCI_MSM_72K
175static void msm_hsusb_vbus_power(unsigned phy_info, int on)
176{
177 int rc = 0;
178 unsigned gpio;
179
180 gpio = GPIO_HOST_VBUS_EN;
181
182 rc = gpio_request(gpio, "i2c_host_vbus_en");
183 if (rc < 0) {
184 pr_err("failed to request %d GPIO\n", gpio);
185 return;
186 }
187 gpio_direction_output(gpio, !!on);
188 gpio_set_value_cansleep(gpio, !!on);
189 gpio_free(gpio);
190}
191
192static struct msm_usb_host_platform_data msm_usb_host_pdata = {
193 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
194};
195
196static void __init msm7x2x_init_host(void)
197{
198 msm_add_host(0, &msm_usb_host_pdata);
199}
200#endif
201
202#ifdef CONFIG_USB_MSM_OTG_72K
203static int hsusb_rpc_connect(int connect)
204{
205 if (connect)
206 return msm_hsusb_rpc_connect();
207 else
208 return msm_hsusb_rpc_close();
209}
210
Justin Paupored98328e2011-08-19 13:48:31 -0700211static struct regulator *reg_hsusb;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700212static int msm_hsusb_ldo_init(int init)
213{
Justin Paupored98328e2011-08-19 13:48:31 -0700214 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700215
Justin Paupored98328e2011-08-19 13:48:31 -0700216 if (init) {
217 reg_hsusb = regulator_get(NULL, "usb");
218 if (IS_ERR(reg_hsusb)) {
219 rc = PTR_ERR(reg_hsusb);
220 pr_err("%s: could not get regulator: %d\n",
221 __func__, rc);
222 goto out;
223 }
224
225 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
226 if (rc) {
227 pr_err("%s: could not set voltage: %d\n",
228 __func__, rc);
229 goto reg_free;
230 }
231
232 return 0;
233 }
234 /* else fall through */
235reg_free:
236 regulator_put(reg_hsusb);
237out:
238 reg_hsusb = NULL;
239 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700240}
241
242static int msm_hsusb_ldo_enable(int enable)
243{
244 static int ldo_status;
245
Justin Paupored98328e2011-08-19 13:48:31 -0700246 if (IS_ERR_OR_NULL(reg_hsusb))
247 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700248
249 if (ldo_status == enable)
250 return 0;
251
252 ldo_status = enable;
253
Justin Paupored98328e2011-08-19 13:48:31 -0700254 return enable ?
255 regulator_enable(reg_hsusb) :
256 regulator_disable(reg_hsusb);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700257}
258
259#ifndef CONFIG_USB_EHCI_MSM_72K
260static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
261{
262 int ret = 0;
263
264 if (init)
265 ret = msm_pm_app_rpc_init(callback);
266 else
267 msm_pm_app_rpc_deinit(callback);
268
269 return ret;
270}
271#endif
272
273static struct msm_otg_platform_data msm_otg_pdata = {
274#ifndef CONFIG_USB_EHCI_MSM_72K
275 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
276#else
277 .vbus_power = msm_hsusb_vbus_power,
278#endif
279 .rpc_connect = hsusb_rpc_connect,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700280 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
281 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
282 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
283 .se1_gating = SE1_GATING_DISABLE,
284 .ldo_init = msm_hsusb_ldo_init,
285 .ldo_enable = msm_hsusb_ldo_enable,
286 .chg_init = hsusb_chg_init,
287 .chg_connected = hsusb_chg_connected,
288 .chg_vbus_draw = hsusb_chg_vbus_draw,
289};
290#endif
291
292static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
293 .is_phy_status_timer_on = 1,
294};
295
296static struct resource smc91x_resources[] = {
297 [0] = {
298 .start = 0x90000300,
299 .end = 0x900003ff,
300 .flags = IORESOURCE_MEM,
301 },
302 [1] = {
303 .start = MSM_GPIO_TO_INT(4),
304 .end = MSM_GPIO_TO_INT(4),
305 .flags = IORESOURCE_IRQ,
306 },
307};
308
309static struct platform_device smc91x_device = {
310 .name = "smc91x",
311 .id = 0,
312 .num_resources = ARRAY_SIZE(smc91x_resources),
313 .resource = smc91x_resources,
314};
315
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700316#ifdef CONFIG_SERIAL_MSM_HS
317static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
318 .inject_rx_on_wakeup = 1,
319 .rx_to_inject = 0xFD,
320};
321#endif
322static struct msm_pm_platform_data msm7x27a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
323 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
324 .idle_supported = 1,
325 .suspend_supported = 1,
326 .idle_enabled = 1,
327 .suspend_enabled = 1,
328 .latency = 16000,
329 .residency = 20000,
330 },
331 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
332 .idle_supported = 1,
333 .suspend_supported = 1,
334 .idle_enabled = 1,
335 .suspend_enabled = 1,
336 .latency = 12000,
337 .residency = 20000,
338 },
339 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
340 .idle_supported = 1,
341 .suspend_supported = 1,
342 .idle_enabled = 0,
343 .suspend_enabled = 1,
344 .latency = 2000,
345 .residency = 0,
346 },
347 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
348 .idle_supported = 1,
349 .suspend_supported = 1,
350 .idle_enabled = 1,
351 .suspend_enabled = 1,
352 .latency = 2,
353 .residency = 0,
354 },
355};
356
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600357static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +0530358 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
359 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600360};
361
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700362static struct android_pmem_platform_data android_pmem_adsp_pdata = {
363 .name = "pmem_adsp",
364 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
Mahesh Lankac6af7eb2011-08-02 18:00:35 +0530365 .cached = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700366 .memory_type = MEMTYPE_EBI1,
367};
368
369static struct platform_device android_pmem_adsp_device = {
370 .name = "android_pmem",
371 .id = 1,
372 .dev = { .platform_data = &android_pmem_adsp_pdata },
373};
374
375static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
376static int __init pmem_mdp_size_setup(char *p)
377{
378 pmem_mdp_size = memparse(p, NULL);
379 return 0;
380}
381
382early_param("pmem_mdp_size", pmem_mdp_size_setup);
383
384static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
385static int __init pmem_adsp_size_setup(char *p)
386{
387 pmem_adsp_size = memparse(p, NULL);
388 return 0;
389}
390
391early_param("pmem_adsp_size", pmem_adsp_size_setup);
392
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700393#define SND(desc, num) { .name = #desc, .id = num }
394static struct snd_endpoint snd_endpoints_list[] = {
395 SND(HANDSET, 0),
396 SND(MONO_HEADSET, 2),
397 SND(HEADSET, 3),
398 SND(SPEAKER, 6),
399 SND(TTY_HEADSET, 8),
400 SND(TTY_VCO, 9),
401 SND(TTY_HCO, 10),
402 SND(BT, 12),
403 SND(IN_S_SADC_OUT_HANDSET, 16),
404 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
405 SND(FM_DIGITAL_STEREO_HEADSET, 26),
406 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
407 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
Shashi Kumar64e07602011-10-11 13:18:57 +0530408 SND(STEREO_HEADSET_AND_SPEAKER, 31),
Sidipotu Ashokab34ca42011-07-22 16:34:20 +0530409 SND(CURRENT, 0x7FFFFFFE),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700410 SND(FM_ANALOG_STEREO_HEADSET, 35),
411 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
412};
413#undef SND
414
415static struct msm_snd_endpoints msm_device_snd_endpoints = {
416 .endpoints = snd_endpoints_list,
417 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
418};
419
420static struct platform_device msm_device_snd = {
421 .name = "msm_snd",
422 .id = -1,
423 .dev = {
424 .platform_data = &msm_device_snd_endpoints
425 },
426};
427
428#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
429 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
430 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
431 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
432 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
433 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
434#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
435 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
436 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
437 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
438 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
439 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
440#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
441 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
442 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
443 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
444 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
445 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
446#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
447 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
448 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
449 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
450 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
451 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
452#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
453
454static unsigned int dec_concurrency_table[] = {
455 /* Audio LP */
456 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
457 0, 0, 0,
458
459 /* Concurrency 1 */
460 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
461 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
462 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
463 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
464 (DEC4_FORMAT),
465
466 /* Concurrency 2 */
467 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
468 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
469 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
470 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
471 (DEC4_FORMAT),
472
473 /* Concurrency 3 */
474 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
475 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
476 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
477 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
478 (DEC4_FORMAT),
479
480 /* Concurrency 4 */
481 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
482 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
483 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
484 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
485 (DEC4_FORMAT),
486
487 /* Concurrency 5 */
488 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
489 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
490 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
491 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
492 (DEC4_FORMAT),
493
494 /* Concurrency 6 */
495 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
496 0, 0, 0, 0,
497
498 /* Concurrency 7 */
499 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(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
506#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
507 .module_queueid = queueid, .module_decid = decid, \
508 .nr_codec_support = nr_codec}
509
510static struct msm_adspdec_info dec_info_list[] = {
511 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
512 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
513 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
514 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
515 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
516};
517
518static struct msm_adspdec_database msm_device_adspdec_database = {
519 .num_dec = ARRAY_SIZE(dec_info_list),
520 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
521 ARRAY_SIZE(dec_info_list)),
522 .dec_concurrency_table = dec_concurrency_table,
523 .dec_info_list = dec_info_list,
524};
525
526static struct platform_device msm_device_adspdec = {
527 .name = "msm_adspdec",
528 .id = -1,
529 .dev = {
530 .platform_data = &msm_device_adspdec_database
531 },
532};
533
534static struct android_pmem_platform_data android_pmem_audio_pdata = {
535 .name = "pmem_audio",
536 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
537 .cached = 0,
538 .memory_type = MEMTYPE_EBI1,
539};
540
541static struct platform_device android_pmem_audio_device = {
542 .name = "android_pmem",
543 .id = 2,
544 .dev = { .platform_data = &android_pmem_audio_pdata },
545};
546
547static struct android_pmem_platform_data android_pmem_pdata = {
548 .name = "pmem",
549 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
550 .cached = 1,
551 .memory_type = MEMTYPE_EBI1,
552};
553static struct platform_device android_pmem_device = {
554 .name = "android_pmem",
555 .id = 0,
556 .dev = { .platform_data = &android_pmem_pdata },
557};
558
559static u32 msm_calculate_batt_capacity(u32 current_voltage);
560
561static struct msm_psy_batt_pdata msm_psy_batt_data = {
562 .voltage_min_design = 2800,
563 .voltage_max_design = 4300,
564 .avail_chg_sources = AC_CHG | USB_CHG ,
565 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
566 .calculate_capacity = &msm_calculate_batt_capacity,
567};
568
569static u32 msm_calculate_batt_capacity(u32 current_voltage)
570{
571 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
572 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
573
574 return (current_voltage - low_voltage) * 100
575 / (high_voltage - low_voltage);
576}
577
578static struct platform_device msm_batt_device = {
579 .name = "msm-battery",
580 .id = -1,
581 .dev.platform_data = &msm_psy_batt_data,
582};
583
584static struct smsc911x_platform_config smsc911x_config = {
585 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
586 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
587 .flags = SMSC911X_USE_16BIT,
588};
589
590static struct resource smsc911x_resources[] = {
591 [0] = {
592 .start = 0x90000000,
593 .end = 0x90007fff,
594 .flags = IORESOURCE_MEM,
595 },
596 [1] = {
597 .start = MSM_GPIO_TO_INT(48),
598 .end = MSM_GPIO_TO_INT(48),
599 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
600 },
601};
602
603static struct platform_device smsc911x_device = {
604 .name = "smsc911x",
605 .id = 0,
606 .num_resources = ARRAY_SIZE(smsc911x_resources),
607 .resource = smsc911x_resources,
608 .dev = {
609 .platform_data = &smsc911x_config,
610 },
611};
612
613static struct msm_gpio smsc911x_gpios[] = {
614 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
615 "smsc911x_irq" },
616 { GPIO_CFG(49, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
617 "eth_fifo_sel" },
618};
619
620#define ETH_FIFO_SEL_GPIO 49
621static void msm7x27a_cfg_smsc911x(void)
622{
623 int res;
624
625 res = msm_gpios_request_enable(smsc911x_gpios,
626 ARRAY_SIZE(smsc911x_gpios));
627 if (res) {
628 pr_err("%s: unable to enable gpios for SMSC911x\n", __func__);
629 return;
630 }
631
632 /* ETH_FIFO_SEL */
633 res = gpio_direction_output(ETH_FIFO_SEL_GPIO, 0);
634 if (res) {
635 pr_err("%s: unable to get direction for gpio %d\n", __func__,
636 ETH_FIFO_SEL_GPIO);
637 msm_gpios_disable_free(smsc911x_gpios,
638 ARRAY_SIZE(smsc911x_gpios));
639 return;
640 }
641 gpio_set_value(ETH_FIFO_SEL_GPIO, 0);
642}
643
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700644#if defined(CONFIG_SERIAL_MSM_HSL_CONSOLE) \
645 && defined(CONFIG_MSM_SHARED_GPIO_FOR_UART2DM)
646static struct msm_gpio uart2dm_gpios[] = {
647 {GPIO_CFG(19, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
648 "uart2dm_rfr_n" },
649 {GPIO_CFG(20, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
650 "uart2dm_cts_n" },
651 {GPIO_CFG(21, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
652 "uart2dm_rx" },
653 {GPIO_CFG(108, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
654 "uart2dm_tx" },
655};
656
657static void msm7x27a_cfg_uart2dm_serial(void)
658{
659 int ret;
660 ret = msm_gpios_request_enable(uart2dm_gpios,
661 ARRAY_SIZE(uart2dm_gpios));
662 if (ret)
663 pr_err("%s: unable to enable gpios for uart2dm\n", __func__);
664}
665#else
666static void msm7x27a_cfg_uart2dm_serial(void) { }
667#endif
668
669static struct platform_device *rumi_sim_devices[] __initdata = {
670 &msm_device_dmov,
671 &msm_device_smd,
672 &smc91x_device,
673 &msm_device_uart1,
674 &msm_device_nand,
675 &msm_device_uart_dm1,
676 &msm_gsbi0_qup_i2c_device,
677 &msm_gsbi1_qup_i2c_device,
678};
679
680static struct platform_device *surf_ffa_devices[] __initdata = {
681 &msm_device_dmov,
682 &msm_device_smd,
683 &msm_device_uart1,
684 &msm_device_uart_dm1,
685 &msm_device_uart_dm2,
686 &msm_device_nand,
687 &msm_gsbi0_qup_i2c_device,
688 &msm_gsbi1_qup_i2c_device,
689 &msm_device_otg,
690 &msm_device_gadget_peripheral,
691 &android_usb_device,
692 &android_pmem_device,
693 &android_pmem_adsp_device,
694 &android_pmem_audio_device,
695 &msm_device_snd,
696 &msm_device_adspdec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700697 &msm_batt_device,
698 &smsc911x_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700699 &msm_kgsl_3d0,
700#ifdef CONFIG_BT
701 &msm_bt_power_device,
702#endif
Manish Dewangan3a260992011-06-24 18:01:34 +0530703 &asoc_msm_pcm,
704 &asoc_msm_dai0,
705 &asoc_msm_dai1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700706};
707
708static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
709static int __init pmem_kernel_ebi1_size_setup(char *p)
710{
711 pmem_kernel_ebi1_size = memparse(p, NULL);
712 return 0;
713}
714early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
715
716static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
717static int __init pmem_audio_size_setup(char *p)
718{
719 pmem_audio_size = memparse(p, NULL);
720 return 0;
721}
722early_param("pmem_audio_size", pmem_audio_size_setup);
723
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700724static struct memtype_reserve msm7x27a_reserve_table[] __initdata = {
725 [MEMTYPE_SMI] = {
726 },
727 [MEMTYPE_EBI0] = {
728 .flags = MEMTYPE_FLAGS_1M_ALIGN,
729 },
730 [MEMTYPE_EBI1] = {
731 .flags = MEMTYPE_FLAGS_1M_ALIGN,
732 },
733};
734
735static void __init size_pmem_devices(void)
736{
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530737
738 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
739 pmem_mdp_size = MSM7x25A_MSM_PMEM_MDP_SIZE;
740 pmem_adsp_size = MSM7x25A_MSM_PMEM_ADSP_SIZE;
741 } else {
742 pmem_mdp_size = MSM_PMEM_MDP_SIZE;
743 pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
744 }
745
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700746#ifdef CONFIG_ANDROID_PMEM
747 android_pmem_adsp_pdata.size = pmem_adsp_size;
748 android_pmem_pdata.size = pmem_mdp_size;
749 android_pmem_audio_pdata.size = pmem_audio_size;
750#endif
751}
752
753static void __init reserve_memory_for(struct android_pmem_platform_data *p)
754{
755 msm7x27a_reserve_table[p->memory_type].size += p->size;
756}
757
758static void __init reserve_pmem_memory(void)
759{
760#ifdef CONFIG_ANDROID_PMEM
761 reserve_memory_for(&android_pmem_adsp_pdata);
762 reserve_memory_for(&android_pmem_pdata);
763 reserve_memory_for(&android_pmem_audio_pdata);
764 msm7x27a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
765#endif
766}
767
768static void __init msm7x27a_calculate_reserve_sizes(void)
769{
770 size_pmem_devices();
771 reserve_pmem_memory();
772}
773
774static int msm7x27a_paddr_to_memtype(unsigned int paddr)
775{
776 return MEMTYPE_EBI1;
777}
778
779static struct reserve_info msm7x27a_reserve_info __initdata = {
780 .memtype_reserve_table = msm7x27a_reserve_table,
781 .calculate_reserve_sizes = msm7x27a_calculate_reserve_sizes,
782 .paddr_to_memtype = msm7x27a_paddr_to_memtype,
783};
784
785static void __init msm7x27a_reserve(void)
786{
787 reserve_info = &msm7x27a_reserve_info;
788 msm_reserve();
789}
790
791static void __init msm_device_i2c_init(void)
792{
793 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
794 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
795}
796
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700797#define MSM_EBI2_PHYS 0xa0d00000
798#define MSM_EBI2_XMEM_CS2_CFG1 0xa0d10030
799
800static void __init msm7x27a_init_ebi2(void)
801{
802 uint32_t ebi2_cfg;
803 void __iomem *ebi2_cfg_ptr;
804
805 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_PHYS, sizeof(uint32_t));
806 if (!ebi2_cfg_ptr)
807 return;
808
809 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530810 if (machine_is_msm7x27a_rumi3() || machine_is_msm7x27a_surf() ||
811 machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700812 ebi2_cfg |= (1 << 4); /* CS2 */
813
814 writel(ebi2_cfg, ebi2_cfg_ptr);
815 iounmap(ebi2_cfg_ptr);
816
817 /* Enable A/D MUX[bit 31] from EBI2_XMEM_CS2_CFG1 */
818 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_XMEM_CS2_CFG1,
819 sizeof(uint32_t));
820 if (!ebi2_cfg_ptr)
821 return;
822
823 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530824 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700825 ebi2_cfg |= (1 << 31);
826
827 writel(ebi2_cfg, ebi2_cfg_ptr);
828 iounmap(ebi2_cfg_ptr);
829}
830
831#define ATMEL_TS_I2C_NAME "maXTouch"
Justin Paupored98328e2011-08-19 13:48:31 -0700832
833static struct regulator_bulk_data regs_atmel[] = {
834 { .supply = "ldo2", .min_uV = 2850000, .max_uV = 2850000 },
835 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
836};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700837
838#define ATMEL_TS_GPIO_IRQ 82
839
840static int atmel_ts_power_on(bool on)
841{
Justin Paupored98328e2011-08-19 13:48:31 -0700842 int rc = on ?
843 regulator_bulk_enable(ARRAY_SIZE(regs_atmel), regs_atmel) :
844 regulator_bulk_disable(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700845
Justin Paupored98328e2011-08-19 13:48:31 -0700846 if (rc)
847 pr_err("%s: could not %sable regulators: %d\n",
848 __func__, on ? "en" : "dis", rc);
849 else
850 msleep(50);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700851
Justin Paupored98328e2011-08-19 13:48:31 -0700852 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700853}
854
855static int atmel_ts_platform_init(struct i2c_client *client)
856{
857 int rc;
Justin Paupored98328e2011-08-19 13:48:31 -0700858 struct device *dev = &client->dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700859
Justin Paupored98328e2011-08-19 13:48:31 -0700860 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700861 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700862 dev_err(dev, "%s: could not get regulators: %d\n",
863 __func__, rc);
864 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700865 }
866
Justin Paupored98328e2011-08-19 13:48:31 -0700867 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700868 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700869 dev_err(dev, "%s: could not set voltages: %d\n",
870 __func__, rc);
871 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700872 }
873
874 rc = gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
875 GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
876 GPIO_CFG_8MA), GPIO_CFG_ENABLE);
877 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700878 dev_err(dev, "%s: gpio_tlmm_config for %d failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700879 __func__, ATMEL_TS_GPIO_IRQ);
Justin Paupored98328e2011-08-19 13:48:31 -0700880 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700881 }
882
883 /* configure touchscreen interrupt gpio */
884 rc = gpio_request(ATMEL_TS_GPIO_IRQ, "atmel_maxtouch_gpio");
885 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700886 dev_err(dev, "%s: unable to request gpio %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700887 __func__, ATMEL_TS_GPIO_IRQ);
888 goto ts_gpio_tlmm_unconfig;
889 }
890
891 rc = gpio_direction_input(ATMEL_TS_GPIO_IRQ);
892 if (rc < 0) {
Justin Paupored98328e2011-08-19 13:48:31 -0700893 dev_err(dev, "%s: unable to set the direction of gpio %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700894 __func__, ATMEL_TS_GPIO_IRQ);
895 goto free_ts_gpio;
896 }
897 return 0;
898
899free_ts_gpio:
900 gpio_free(ATMEL_TS_GPIO_IRQ);
901ts_gpio_tlmm_unconfig:
902 gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
903 GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
904 GPIO_CFG_2MA), GPIO_CFG_DISABLE);
Justin Paupored98328e2011-08-19 13:48:31 -0700905reg_free:
906 regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel);
907out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700908 return rc;
909}
910
911static int atmel_ts_platform_exit(struct i2c_client *client)
912{
913 gpio_free(ATMEL_TS_GPIO_IRQ);
914 gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
915 GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
916 GPIO_CFG_2MA), GPIO_CFG_DISABLE);
Justin Paupored98328e2011-08-19 13:48:31 -0700917 regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700918 return 0;
919}
920
921static u8 atmel_ts_read_chg(void)
922{
923 return gpio_get_value(ATMEL_TS_GPIO_IRQ);
924}
925
926static u8 atmel_ts_valid_interrupt(void)
927{
928 return !atmel_ts_read_chg();
929}
930
931#define ATMEL_X_OFFSET 13
932#define ATMEL_Y_OFFSET 0
933
Mohan Pallaka4e9a94e2011-11-23 16:34:21 +0530934static struct maxtouch_platform_data atmel_ts_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700935 .numtouch = 4,
936 .init_platform_hw = atmel_ts_platform_init,
937 .exit_platform_hw = atmel_ts_platform_exit,
938 .power_on = atmel_ts_power_on,
939 .display_res_x = 480,
940 .display_res_y = 864,
941 .min_x = ATMEL_X_OFFSET,
942 .max_x = (505 - ATMEL_X_OFFSET),
943 .min_y = ATMEL_Y_OFFSET,
944 .max_y = (863 - ATMEL_Y_OFFSET),
945 .valid_interrupt = atmel_ts_valid_interrupt,
946 .read_chg = atmel_ts_read_chg,
947};
948
949static struct i2c_board_info atmel_ts_i2c_info[] __initdata = {
950 {
951 I2C_BOARD_INFO(ATMEL_TS_I2C_NAME, 0x4a),
952 .platform_data = &atmel_ts_pdata,
953 .irq = MSM_GPIO_TO_INT(ATMEL_TS_GPIO_IRQ),
954 },
955};
956
957#define KP_INDEX(row, col) ((row)*ARRAY_SIZE(kp_col_gpios) + (col))
958
959static unsigned int kp_row_gpios[] = {31, 32, 33, 34, 35};
960static unsigned int kp_col_gpios[] = {36, 37, 38, 39, 40};
961
962static const unsigned short keymap[ARRAY_SIZE(kp_col_gpios) *
963 ARRAY_SIZE(kp_row_gpios)] = {
964 [KP_INDEX(0, 0)] = KEY_7,
965 [KP_INDEX(0, 1)] = KEY_DOWN,
966 [KP_INDEX(0, 2)] = KEY_UP,
967 [KP_INDEX(0, 3)] = KEY_RIGHT,
968 [KP_INDEX(0, 4)] = KEY_ENTER,
969
970 [KP_INDEX(1, 0)] = KEY_LEFT,
971 [KP_INDEX(1, 1)] = KEY_SEND,
972 [KP_INDEX(1, 2)] = KEY_1,
973 [KP_INDEX(1, 3)] = KEY_4,
974 [KP_INDEX(1, 4)] = KEY_CLEAR,
975
976 [KP_INDEX(2, 0)] = KEY_6,
977 [KP_INDEX(2, 1)] = KEY_5,
978 [KP_INDEX(2, 2)] = KEY_8,
979 [KP_INDEX(2, 3)] = KEY_3,
980 [KP_INDEX(2, 4)] = KEY_NUMERIC_STAR,
981
982 [KP_INDEX(3, 0)] = KEY_9,
983 [KP_INDEX(3, 1)] = KEY_NUMERIC_POUND,
984 [KP_INDEX(3, 2)] = KEY_0,
985 [KP_INDEX(3, 3)] = KEY_2,
986 [KP_INDEX(3, 4)] = KEY_SLEEP,
987
988 [KP_INDEX(4, 0)] = KEY_BACK,
989 [KP_INDEX(4, 1)] = KEY_HOME,
990 [KP_INDEX(4, 2)] = KEY_MENU,
991 [KP_INDEX(4, 3)] = KEY_VOLUMEUP,
992 [KP_INDEX(4, 4)] = KEY_VOLUMEDOWN,
993};
994
995/* SURF keypad platform device information */
996static struct gpio_event_matrix_info kp_matrix_info = {
997 .info.func = gpio_event_matrix_func,
998 .keymap = keymap,
999 .output_gpios = kp_row_gpios,
1000 .input_gpios = kp_col_gpios,
1001 .noutputs = ARRAY_SIZE(kp_row_gpios),
1002 .ninputs = ARRAY_SIZE(kp_col_gpios),
1003 .settle_time.tv_nsec = 40 * NSEC_PER_USEC,
1004 .poll_time.tv_nsec = 20 * NSEC_PER_MSEC,
1005 .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE |
1006 GPIOKPF_PRINT_UNMAPPED_KEYS,
1007};
1008
1009static struct gpio_event_info *kp_info[] = {
1010 &kp_matrix_info.info
1011};
1012
1013static struct gpio_event_platform_data kp_pdata = {
1014 .name = "7x27a_kp",
1015 .info = kp_info,
1016 .info_count = ARRAY_SIZE(kp_info)
1017};
1018
1019static struct platform_device kp_pdev = {
1020 .name = GPIO_EVENT_DEV_NAME,
1021 .id = -1,
1022 .dev = {
1023 .platform_data = &kp_pdata,
1024 },
1025};
1026
1027static struct msm_handset_platform_data hs_platform_data = {
1028 .hs_name = "7k_handset",
1029 .pwr_key_delay_ms = 500, /* 0 will disable end key */
1030};
1031
1032static struct platform_device hs_pdev = {
1033 .name = "msm-handset",
1034 .id = -1,
1035 .dev = {
1036 .platform_data = &hs_platform_data,
1037 },
1038};
1039
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001040static struct platform_device msm_proccomm_regulator_dev = {
1041 .name = PROCCOMM_REGULATOR_DEV_NAME,
1042 .id = -1,
1043 .dev = {
1044 .platform_data = &msm7x27a_proccomm_regulator_data
1045 }
1046};
1047
Trilok Soni16f61af2011-07-26 16:06:58 +05301048static void __init msm7627a_rumi3_init(void)
1049{
1050 msm7x27a_init_ebi2();
1051 platform_add_devices(rumi_sim_devices,
1052 ARRAY_SIZE(rumi_sim_devices));
1053}
1054
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001055#define LED_GPIO_PDM 96
1056#define UART1DM_RX_GPIO 45
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301057
1058#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
1059static int __init msm7x27a_init_ar6000pm(void)
1060{
1061 return platform_device_register(&msm_wlan_ar6000_pm_device);
1062}
1063#else
1064static int __init msm7x27a_init_ar6000pm(void) { return 0; }
1065#endif
1066
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001067static void __init msm7x27a_init_regulators(void)
1068{
1069 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1070 if (rc)
1071 pr_err("%s: could not register regulator device: %d\n",
1072 __func__, rc);
1073}
1074
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001075static void __init msm7x2x_init(void)
1076{
Trilok Sonia416c492011-07-22 20:20:23 +05301077 msm7x2x_misc_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001078
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001079 /* Initialize regulators first so that other devices can use them */
1080 msm7x27a_init_regulators();
1081
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001082 /* Common functions for SURF/FFA/RUMI3 */
1083 msm_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001084 msm7x27a_init_ebi2();
1085 msm7x27a_cfg_uart2dm_serial();
1086#ifdef CONFIG_SERIAL_MSM_HS
1087 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
1088 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
1089#endif
1090
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001091#ifdef CONFIG_USB_MSM_OTG_72K
Trilok Soni16f61af2011-07-26 16:06:58 +05301092 msm_otg_pdata.swfi_latency =
1093 msm7x27a_pm_data
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001094 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
Trilok Soni16f61af2011-07-26 16:06:58 +05301095 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001096#endif
Trilok Soni16f61af2011-07-26 16:06:58 +05301097 msm_device_gadget_peripheral.dev.platform_data =
1098 &msm_gadget_pdata;
1099 msm7x27a_cfg_smsc911x();
1100 platform_add_devices(msm_footswitch_devices,
1101 msm_num_footswitch_devices);
1102 platform_add_devices(surf_ffa_devices,
1103 ARRAY_SIZE(surf_ffa_devices));
Sujith Reddy Thummaad7c9a82011-09-30 20:54:38 +05301104 /* Ensure ar6000pm device is registered before MMC/SDC */
1105 msm7x27a_init_ar6000pm();
1106#ifdef CONFIG_MMC_MSM
Chintan Pandyacf467fc2011-12-01 17:11:11 +05301107 msm7627a_init_mmc();
Sujith Reddy Thummaad7c9a82011-09-30 20:54:38 +05301108#endif
Trilok Soni16f61af2011-07-26 16:06:58 +05301109 msm_fb_add_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001110#ifdef CONFIG_USB_EHCI_MSM_72K
Trilok Soni16f61af2011-07-26 16:06:58 +05301111 msm7x2x_init_host();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001112#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001113
1114 msm_pm_set_platform_data(msm7x27a_pm_data,
1115 ARRAY_SIZE(msm7x27a_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06001116 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001117
1118#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
1119 register_i2c_devices();
1120#endif
1121#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Chintan Pandya13490c02011-12-20 13:03:36 +05301122 msm7627a_bt_power_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001123#endif
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301124 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001125 atmel_ts_pdata.min_x = 0;
1126 atmel_ts_pdata.max_x = 480;
1127 atmel_ts_pdata.min_y = 0;
1128 atmel_ts_pdata.max_y = 320;
1129 }
1130
1131 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
1132 atmel_ts_i2c_info,
1133 ARRAY_SIZE(atmel_ts_i2c_info));
1134
Pankaj Kumar5be2a3e2011-09-26 11:45:02 +05301135#if defined(CONFIG_MSM_CAMERA)
Chintan Pandya40762702011-12-06 13:47:06 +05301136 msm7627a_camera_init();
Pankaj Kumar5be2a3e2011-09-26 11:45:02 +05301137#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001138 platform_device_register(&kp_pdev);
1139 platform_device_register(&hs_pdev);
1140
1141 /* configure it as a pdm function*/
1142 if (gpio_tlmm_config(GPIO_CFG(LED_GPIO_PDM, 3,
1143 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
1144 GPIO_CFG_8MA), GPIO_CFG_ENABLE))
1145 pr_err("%s: gpio_tlmm_config for %d failed\n",
1146 __func__, LED_GPIO_PDM);
1147 else
1148 platform_device_register(&led_pdev);
1149
1150#ifdef CONFIG_MSM_RPC_VIBRATOR
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301151 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001152 msm_init_pmic_vibrator();
1153#endif
1154 /*7x25a kgsl initializations*/
1155 msm7x25a_kgsl_3d0_init();
1156}
1157
1158static void __init msm7x2x_init_early(void)
1159{
Chintan Pandya250c2e52012-01-19 17:15:49 +05301160 msm_msm7627a_allocate_memory_regions();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001161}
1162
1163MACHINE_START(MSM7X27A_RUMI3, "QCT MSM7x27a RUMI3")
1164 .boot_params = PHYS_OFFSET + 0x100,
1165 .map_io = msm_common_io_init,
1166 .reserve = msm7x27a_reserve,
1167 .init_irq = msm_init_irq,
Trilok Soni16f61af2011-07-26 16:06:58 +05301168 .init_machine = msm7627a_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001169 .timer = &msm_timer,
1170 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301171 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001172MACHINE_END
1173MACHINE_START(MSM7X27A_SURF, "QCT MSM7x27a SURF")
1174 .boot_params = PHYS_OFFSET + 0x100,
1175 .map_io = msm_common_io_init,
1176 .reserve = msm7x27a_reserve,
1177 .init_irq = msm_init_irq,
1178 .init_machine = msm7x2x_init,
1179 .timer = &msm_timer,
1180 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301181 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001182MACHINE_END
1183MACHINE_START(MSM7X27A_FFA, "QCT MSM7x27a FFA")
1184 .boot_params = PHYS_OFFSET + 0x100,
1185 .map_io = msm_common_io_init,
1186 .reserve = msm7x27a_reserve,
1187 .init_irq = msm_init_irq,
1188 .init_machine = msm7x2x_init,
1189 .timer = &msm_timer,
1190 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301191 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001192MACHINE_END
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301193MACHINE_START(MSM7625A_SURF, "QCT MSM7625a SURF")
1194 .boot_params = PHYS_OFFSET + 0x100,
1195 .map_io = msm_common_io_init,
1196 .reserve = msm7x27a_reserve,
1197 .init_irq = msm_init_irq,
1198 .init_machine = msm7x2x_init,
1199 .timer = &msm_timer,
1200 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301201 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301202MACHINE_END
1203MACHINE_START(MSM7625A_FFA, "QCT MSM7625a FFA")
1204 .boot_params = PHYS_OFFSET + 0x100,
1205 .map_io = msm_common_io_init,
1206 .reserve = msm7x27a_reserve,
1207 .init_irq = msm_init_irq,
1208 .init_machine = msm7x2x_init,
1209 .timer = &msm_timer,
1210 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301211 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301212MACHINE_END