blob: 0437134a964d3321200c35076fffa7271ca8424a [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>
Taniya Das43bcdd62011-12-02 17:33:27 +053017#include <asm/hardware/gic.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018#include <mach/board.h>
19#include <mach/msm_iomap.h>
20#include <mach/msm_hsusb.h>
21#include <mach/rpc_hsusb.h>
22#include <mach/rpc_pmapp.h>
23#include <mach/usbdiag.h>
24#include <mach/msm_memtypes.h>
25#include <mach/msm_serial_hs.h>
26#include <linux/usb/android.h>
27#include <linux/platform_device.h>
28#include <linux/io.h>
29#include <linux/gpio.h>
30#include <mach/vreg.h>
31#include <mach/pmic.h>
32#include <mach/socinfo.h>
33#include <linux/mtd/nand.h>
34#include <linux/mtd/partitions.h>
35#include <asm/mach/mmc.h>
36#include <linux/i2c.h>
37#include <linux/i2c/sx150x.h>
38#include <linux/gpio.h>
39#include <linux/android_pmem.h>
40#include <linux/bootmem.h>
41#include <linux/mfd/marimba.h>
42#include <mach/vreg.h>
43#include <linux/power_supply.h>
Justin Paupored98328e2011-08-19 13:48:31 -070044#include <linux/regulator/consumer.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070045#include <mach/rpc_pmapp.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046#include <mach/msm_battery.h>
47#include <linux/smsc911x.h>
48#include <linux/atmel_maxtouch.h>
49#include "devices.h"
50#include "timer.h"
Justin Pauporeb3a33b72011-08-23 15:30:32 -070051#include "board-msm7x27a-regulator.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070052#include "devices-msm7x2xa.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080053#include <mach/pm.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070054#include <mach/rpc_server_handset.h>
55#include <mach/socinfo.h>
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -060056#include "pm-boot.h"
Chintan Pandyacf467fc2011-12-01 17:11:11 +053057#include "board-msm7627a.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070058
59#define PMEM_KERNEL_EBI1_SIZE 0x3A000
60#define MSM_PMEM_AUDIO_SIZE 0x5B000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070061
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070062#if defined(CONFIG_GPIO_SX150X)
63enum {
64 SX150X_CORE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070065};
66
67static struct sx150x_platform_data sx150x_data[] __initdata = {
68 [SX150X_CORE] = {
69 .gpio_base = GPIO_CORE_EXPANDER_BASE,
70 .oscio_is_gpo = false,
71 .io_pullup_ena = 0,
pankaj kumarc5c01392011-08-12 13:44:05 +053072 .io_pulldn_ena = 0x02,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070073 .io_open_drain_ena = 0xfef8,
74 .irq_summary = -1,
75 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076};
77#endif
78
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070079
Santosh Sajjan6822c682011-07-26 10:49:36 +053080static struct platform_device msm_wlan_ar6000_pm_device = {
81 .name = "wlan_ar6000_pm_dev",
82 .id = -1,
83};
84
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070085#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
86static struct i2c_board_info core_exp_i2c_info[] __initdata = {
87 {
88 I2C_BOARD_INFO("sx1509q", 0x3e),
89 },
90};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070091
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070092static void __init register_i2c_devices(void)
93{
Trilok Soni3d0f6c52011-07-26 16:06:58 +053094 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095 sx150x_data[SX150X_CORE].io_open_drain_ena = 0xe0f0;
96
97 core_exp_i2c_info[0].platform_data =
98 &sx150x_data[SX150X_CORE];
99
100 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
101 core_exp_i2c_info,
102 ARRAY_SIZE(core_exp_i2c_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700103}
104#endif
105
106static struct msm_gpio qup_i2c_gpios_io[] = {
107 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
108 "qup_scl" },
109 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
110 "qup_sda" },
111 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
112 "qup_scl" },
113 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
114 "qup_sda" },
115};
116
117static struct msm_gpio qup_i2c_gpios_hw[] = {
118 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
119 "qup_scl" },
120 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
121 "qup_sda" },
122 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
123 "qup_scl" },
124 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
125 "qup_sda" },
126};
127
128static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
129{
130 int rc;
131
132 if (adap_id < 0 || adap_id > 1)
133 return;
134
135 /* Each adapter gets 2 lines from the table */
136 if (config_type)
137 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
138 else
139 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
140 if (rc < 0)
141 pr_err("QUP GPIO request/enable failed: %d\n", rc);
142}
143
144static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
145 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700146 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
147};
148
149static struct msm_i2c_platform_data msm_gsbi1_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
Taniya Das9d187142011-12-02 15:53:25 +0530154static struct msm_i2c_platform_data msm8625_gsbi0_qup_i2c_pdata = {
155 .clk_freq = 100000,
156};
157
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700158#ifdef CONFIG_ARCH_MSM7X27A
Neti Ravi Kumar061726e2011-12-08 15:14:57 +0530159#define MSM_PMEM_MDP_SIZE 0x2300000
160#define MSM7x25A_MSM_PMEM_MDP_SIZE 0x1500000
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530161
Mahesh Lankaa2f6df12012-01-05 16:54:40 +0530162#define MSM_PMEM_ADSP_SIZE 0x1100000
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530163#define MSM7x25A_MSM_PMEM_ADSP_SIZE 0xB91000
164
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700165#endif
166
167static struct android_usb_platform_data android_usb_pdata = {
168 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
169};
170
171static struct platform_device android_usb_device = {
172 .name = "android_usb",
173 .id = -1,
174 .dev = {
175 .platform_data = &android_usb_pdata,
176 },
177};
178
179#ifdef CONFIG_USB_EHCI_MSM_72K
180static void msm_hsusb_vbus_power(unsigned phy_info, int on)
181{
182 int rc = 0;
183 unsigned gpio;
184
185 gpio = GPIO_HOST_VBUS_EN;
186
187 rc = gpio_request(gpio, "i2c_host_vbus_en");
188 if (rc < 0) {
189 pr_err("failed to request %d GPIO\n", gpio);
190 return;
191 }
192 gpio_direction_output(gpio, !!on);
193 gpio_set_value_cansleep(gpio, !!on);
194 gpio_free(gpio);
195}
196
197static struct msm_usb_host_platform_data msm_usb_host_pdata = {
198 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
199};
200
201static void __init msm7x2x_init_host(void)
202{
203 msm_add_host(0, &msm_usb_host_pdata);
204}
205#endif
206
207#ifdef CONFIG_USB_MSM_OTG_72K
208static int hsusb_rpc_connect(int connect)
209{
210 if (connect)
211 return msm_hsusb_rpc_connect();
212 else
213 return msm_hsusb_rpc_close();
214}
215
Justin Paupored98328e2011-08-19 13:48:31 -0700216static struct regulator *reg_hsusb;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700217static int msm_hsusb_ldo_init(int init)
218{
Justin Paupored98328e2011-08-19 13:48:31 -0700219 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700220
Justin Paupored98328e2011-08-19 13:48:31 -0700221 if (init) {
222 reg_hsusb = regulator_get(NULL, "usb");
223 if (IS_ERR(reg_hsusb)) {
224 rc = PTR_ERR(reg_hsusb);
225 pr_err("%s: could not get regulator: %d\n",
226 __func__, rc);
227 goto out;
228 }
229
230 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
231 if (rc) {
232 pr_err("%s: could not set voltage: %d\n",
233 __func__, rc);
234 goto reg_free;
235 }
236
237 return 0;
238 }
239 /* else fall through */
240reg_free:
241 regulator_put(reg_hsusb);
242out:
243 reg_hsusb = NULL;
244 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700245}
246
247static int msm_hsusb_ldo_enable(int enable)
248{
249 static int ldo_status;
250
Justin Paupored98328e2011-08-19 13:48:31 -0700251 if (IS_ERR_OR_NULL(reg_hsusb))
252 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700253
254 if (ldo_status == enable)
255 return 0;
256
257 ldo_status = enable;
258
Justin Paupored98328e2011-08-19 13:48:31 -0700259 return enable ?
260 regulator_enable(reg_hsusb) :
261 regulator_disable(reg_hsusb);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700262}
263
264#ifndef CONFIG_USB_EHCI_MSM_72K
265static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
266{
267 int ret = 0;
268
269 if (init)
270 ret = msm_pm_app_rpc_init(callback);
271 else
272 msm_pm_app_rpc_deinit(callback);
273
274 return ret;
275}
276#endif
277
278static struct msm_otg_platform_data msm_otg_pdata = {
279#ifndef CONFIG_USB_EHCI_MSM_72K
280 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
281#else
282 .vbus_power = msm_hsusb_vbus_power,
283#endif
284 .rpc_connect = hsusb_rpc_connect,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700285 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
286 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
287 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
288 .se1_gating = SE1_GATING_DISABLE,
289 .ldo_init = msm_hsusb_ldo_init,
290 .ldo_enable = msm_hsusb_ldo_enable,
291 .chg_init = hsusb_chg_init,
292 .chg_connected = hsusb_chg_connected,
293 .chg_vbus_draw = hsusb_chg_vbus_draw,
294};
295#endif
296
297static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
298 .is_phy_status_timer_on = 1,
299};
300
301static struct resource smc91x_resources[] = {
302 [0] = {
303 .start = 0x90000300,
304 .end = 0x900003ff,
305 .flags = IORESOURCE_MEM,
306 },
307 [1] = {
308 .start = MSM_GPIO_TO_INT(4),
309 .end = MSM_GPIO_TO_INT(4),
310 .flags = IORESOURCE_IRQ,
311 },
312};
313
314static struct platform_device smc91x_device = {
315 .name = "smc91x",
316 .id = 0,
317 .num_resources = ARRAY_SIZE(smc91x_resources),
318 .resource = smc91x_resources,
319};
320
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700321#ifdef CONFIG_SERIAL_MSM_HS
322static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
323 .inject_rx_on_wakeup = 1,
324 .rx_to_inject = 0xFD,
325};
326#endif
327static struct msm_pm_platform_data msm7x27a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
328 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
329 .idle_supported = 1,
330 .suspend_supported = 1,
331 .idle_enabled = 1,
332 .suspend_enabled = 1,
333 .latency = 16000,
334 .residency = 20000,
335 },
336 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
337 .idle_supported = 1,
338 .suspend_supported = 1,
339 .idle_enabled = 1,
340 .suspend_enabled = 1,
341 .latency = 12000,
342 .residency = 20000,
343 },
344 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
345 .idle_supported = 1,
346 .suspend_supported = 1,
347 .idle_enabled = 0,
348 .suspend_enabled = 1,
349 .latency = 2000,
350 .residency = 0,
351 },
352 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
353 .idle_supported = 1,
354 .suspend_supported = 1,
355 .idle_enabled = 1,
356 .suspend_enabled = 1,
357 .latency = 2,
358 .residency = 0,
359 },
360};
361
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600362static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +0530363 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
364 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600365};
366
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700367static struct android_pmem_platform_data android_pmem_adsp_pdata = {
368 .name = "pmem_adsp",
369 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
Mahesh Lankac6af7eb2011-08-02 18:00:35 +0530370 .cached = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700371 .memory_type = MEMTYPE_EBI1,
372};
373
374static struct platform_device android_pmem_adsp_device = {
375 .name = "android_pmem",
376 .id = 1,
377 .dev = { .platform_data = &android_pmem_adsp_pdata },
378};
379
380static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
381static int __init pmem_mdp_size_setup(char *p)
382{
383 pmem_mdp_size = memparse(p, NULL);
384 return 0;
385}
386
387early_param("pmem_mdp_size", pmem_mdp_size_setup);
388
389static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
390static int __init pmem_adsp_size_setup(char *p)
391{
392 pmem_adsp_size = memparse(p, NULL);
393 return 0;
394}
395
396early_param("pmem_adsp_size", pmem_adsp_size_setup);
397
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700398#define SND(desc, num) { .name = #desc, .id = num }
399static struct snd_endpoint snd_endpoints_list[] = {
400 SND(HANDSET, 0),
401 SND(MONO_HEADSET, 2),
402 SND(HEADSET, 3),
403 SND(SPEAKER, 6),
404 SND(TTY_HEADSET, 8),
405 SND(TTY_VCO, 9),
406 SND(TTY_HCO, 10),
407 SND(BT, 12),
408 SND(IN_S_SADC_OUT_HANDSET, 16),
409 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
410 SND(FM_DIGITAL_STEREO_HEADSET, 26),
411 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
412 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
Shashi Kumar64e07602011-10-11 13:18:57 +0530413 SND(STEREO_HEADSET_AND_SPEAKER, 31),
Sidipotu Ashokab34ca42011-07-22 16:34:20 +0530414 SND(CURRENT, 0x7FFFFFFE),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700415 SND(FM_ANALOG_STEREO_HEADSET, 35),
416 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
417};
418#undef SND
419
420static struct msm_snd_endpoints msm_device_snd_endpoints = {
421 .endpoints = snd_endpoints_list,
422 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
423};
424
425static struct platform_device msm_device_snd = {
426 .name = "msm_snd",
427 .id = -1,
428 .dev = {
429 .platform_data = &msm_device_snd_endpoints
430 },
431};
432
433#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
434 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
435 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
436 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
437 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
438 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
439#define DEC1_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 DEC2_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 DEC3_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 DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
458
459static unsigned int dec_concurrency_table[] = {
460 /* Audio LP */
461 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
462 0, 0, 0,
463
464 /* Concurrency 1 */
465 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
466 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
467 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
468 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
469 (DEC4_FORMAT),
470
471 /* Concurrency 2 */
472 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
473 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
474 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
475 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
476 (DEC4_FORMAT),
477
478 /* Concurrency 3 */
479 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
480 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
481 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
482 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
483 (DEC4_FORMAT),
484
485 /* Concurrency 4 */
486 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
487 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
488 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
489 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
490 (DEC4_FORMAT),
491
492 /* Concurrency 5 */
493 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
494 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
495 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
496 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
497 (DEC4_FORMAT),
498
499 /* Concurrency 6 */
500 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
501 0, 0, 0, 0,
502
503 /* Concurrency 7 */
504 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
505 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
506 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
507 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
508 (DEC4_FORMAT),
509};
510
511#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
512 .module_queueid = queueid, .module_decid = decid, \
513 .nr_codec_support = nr_codec}
514
515static struct msm_adspdec_info dec_info_list[] = {
516 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
517 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
518 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
519 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
520 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
521};
522
523static struct msm_adspdec_database msm_device_adspdec_database = {
524 .num_dec = ARRAY_SIZE(dec_info_list),
525 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
526 ARRAY_SIZE(dec_info_list)),
527 .dec_concurrency_table = dec_concurrency_table,
528 .dec_info_list = dec_info_list,
529};
530
531static struct platform_device msm_device_adspdec = {
532 .name = "msm_adspdec",
533 .id = -1,
534 .dev = {
535 .platform_data = &msm_device_adspdec_database
536 },
537};
538
539static struct android_pmem_platform_data android_pmem_audio_pdata = {
540 .name = "pmem_audio",
541 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
542 .cached = 0,
543 .memory_type = MEMTYPE_EBI1,
544};
545
546static struct platform_device android_pmem_audio_device = {
547 .name = "android_pmem",
548 .id = 2,
549 .dev = { .platform_data = &android_pmem_audio_pdata },
550};
551
552static struct android_pmem_platform_data android_pmem_pdata = {
553 .name = "pmem",
554 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
555 .cached = 1,
556 .memory_type = MEMTYPE_EBI1,
557};
558static struct platform_device android_pmem_device = {
559 .name = "android_pmem",
560 .id = 0,
561 .dev = { .platform_data = &android_pmem_pdata },
562};
563
564static u32 msm_calculate_batt_capacity(u32 current_voltage);
565
566static struct msm_psy_batt_pdata msm_psy_batt_data = {
567 .voltage_min_design = 2800,
568 .voltage_max_design = 4300,
569 .avail_chg_sources = AC_CHG | USB_CHG ,
570 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
571 .calculate_capacity = &msm_calculate_batt_capacity,
572};
573
574static u32 msm_calculate_batt_capacity(u32 current_voltage)
575{
576 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
577 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
578
579 return (current_voltage - low_voltage) * 100
580 / (high_voltage - low_voltage);
581}
582
583static struct platform_device msm_batt_device = {
584 .name = "msm-battery",
585 .id = -1,
586 .dev.platform_data = &msm_psy_batt_data,
587};
588
589static struct smsc911x_platform_config smsc911x_config = {
590 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
591 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
592 .flags = SMSC911X_USE_16BIT,
593};
594
595static struct resource smsc911x_resources[] = {
596 [0] = {
597 .start = 0x90000000,
598 .end = 0x90007fff,
599 .flags = IORESOURCE_MEM,
600 },
601 [1] = {
602 .start = MSM_GPIO_TO_INT(48),
603 .end = MSM_GPIO_TO_INT(48),
604 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
605 },
606};
607
608static struct platform_device smsc911x_device = {
609 .name = "smsc911x",
610 .id = 0,
611 .num_resources = ARRAY_SIZE(smsc911x_resources),
612 .resource = smsc911x_resources,
613 .dev = {
614 .platform_data = &smsc911x_config,
615 },
616};
617
618static struct msm_gpio smsc911x_gpios[] = {
619 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
620 "smsc911x_irq" },
621 { GPIO_CFG(49, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
622 "eth_fifo_sel" },
623};
624
625#define ETH_FIFO_SEL_GPIO 49
626static void msm7x27a_cfg_smsc911x(void)
627{
628 int res;
629
630 res = msm_gpios_request_enable(smsc911x_gpios,
631 ARRAY_SIZE(smsc911x_gpios));
632 if (res) {
633 pr_err("%s: unable to enable gpios for SMSC911x\n", __func__);
634 return;
635 }
636
637 /* ETH_FIFO_SEL */
638 res = gpio_direction_output(ETH_FIFO_SEL_GPIO, 0);
639 if (res) {
640 pr_err("%s: unable to get direction for gpio %d\n", __func__,
641 ETH_FIFO_SEL_GPIO);
642 msm_gpios_disable_free(smsc911x_gpios,
643 ARRAY_SIZE(smsc911x_gpios));
644 return;
645 }
646 gpio_set_value(ETH_FIFO_SEL_GPIO, 0);
647}
648
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700649#if defined(CONFIG_SERIAL_MSM_HSL_CONSOLE) \
650 && defined(CONFIG_MSM_SHARED_GPIO_FOR_UART2DM)
651static struct msm_gpio uart2dm_gpios[] = {
652 {GPIO_CFG(19, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
653 "uart2dm_rfr_n" },
654 {GPIO_CFG(20, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
655 "uart2dm_cts_n" },
656 {GPIO_CFG(21, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
657 "uart2dm_rx" },
658 {GPIO_CFG(108, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
659 "uart2dm_tx" },
660};
661
662static void msm7x27a_cfg_uart2dm_serial(void)
663{
664 int ret;
665 ret = msm_gpios_request_enable(uart2dm_gpios,
666 ARRAY_SIZE(uart2dm_gpios));
667 if (ret)
668 pr_err("%s: unable to enable gpios for uart2dm\n", __func__);
669}
670#else
671static void msm7x27a_cfg_uart2dm_serial(void) { }
672#endif
673
674static struct platform_device *rumi_sim_devices[] __initdata = {
675 &msm_device_dmov,
676 &msm_device_smd,
677 &smc91x_device,
678 &msm_device_uart1,
679 &msm_device_nand,
680 &msm_device_uart_dm1,
681 &msm_gsbi0_qup_i2c_device,
682 &msm_gsbi1_qup_i2c_device,
683};
684
Taniya Das43bcdd62011-12-02 17:33:27 +0530685static struct platform_device *msm8625_rumi3_devices[] __initdata = {
686 &msm8625_device_dmov,
687 &msm8625_device_uart1,
Taniya Das9d187142011-12-02 15:53:25 +0530688 &msm8625_device_qup_i2c_gsbi0,
Taniya Das43bcdd62011-12-02 17:33:27 +0530689};
690
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700691static struct platform_device *surf_ffa_devices[] __initdata = {
692 &msm_device_dmov,
693 &msm_device_smd,
694 &msm_device_uart1,
695 &msm_device_uart_dm1,
696 &msm_device_uart_dm2,
697 &msm_device_nand,
698 &msm_gsbi0_qup_i2c_device,
699 &msm_gsbi1_qup_i2c_device,
700 &msm_device_otg,
701 &msm_device_gadget_peripheral,
702 &android_usb_device,
703 &android_pmem_device,
704 &android_pmem_adsp_device,
705 &android_pmem_audio_device,
706 &msm_device_snd,
707 &msm_device_adspdec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700708 &msm_batt_device,
709 &smsc911x_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700710 &msm_kgsl_3d0,
711#ifdef CONFIG_BT
712 &msm_bt_power_device,
713#endif
Manish Dewangan3a260992011-06-24 18:01:34 +0530714 &asoc_msm_pcm,
715 &asoc_msm_dai0,
716 &asoc_msm_dai1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700717};
718
719static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
720static int __init pmem_kernel_ebi1_size_setup(char *p)
721{
722 pmem_kernel_ebi1_size = memparse(p, NULL);
723 return 0;
724}
725early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
726
727static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
728static int __init pmem_audio_size_setup(char *p)
729{
730 pmem_audio_size = memparse(p, NULL);
731 return 0;
732}
733early_param("pmem_audio_size", pmem_audio_size_setup);
734
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700735static struct memtype_reserve msm7x27a_reserve_table[] __initdata = {
736 [MEMTYPE_SMI] = {
737 },
738 [MEMTYPE_EBI0] = {
739 .flags = MEMTYPE_FLAGS_1M_ALIGN,
740 },
741 [MEMTYPE_EBI1] = {
742 .flags = MEMTYPE_FLAGS_1M_ALIGN,
743 },
744};
745
746static void __init size_pmem_devices(void)
747{
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530748
749 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
750 pmem_mdp_size = MSM7x25A_MSM_PMEM_MDP_SIZE;
751 pmem_adsp_size = MSM7x25A_MSM_PMEM_ADSP_SIZE;
752 } else {
753 pmem_mdp_size = MSM_PMEM_MDP_SIZE;
754 pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
755 }
756
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700757#ifdef CONFIG_ANDROID_PMEM
758 android_pmem_adsp_pdata.size = pmem_adsp_size;
759 android_pmem_pdata.size = pmem_mdp_size;
760 android_pmem_audio_pdata.size = pmem_audio_size;
761#endif
762}
763
764static void __init reserve_memory_for(struct android_pmem_platform_data *p)
765{
766 msm7x27a_reserve_table[p->memory_type].size += p->size;
767}
768
769static void __init reserve_pmem_memory(void)
770{
771#ifdef CONFIG_ANDROID_PMEM
772 reserve_memory_for(&android_pmem_adsp_pdata);
773 reserve_memory_for(&android_pmem_pdata);
774 reserve_memory_for(&android_pmem_audio_pdata);
775 msm7x27a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
776#endif
777}
778
779static void __init msm7x27a_calculate_reserve_sizes(void)
780{
781 size_pmem_devices();
782 reserve_pmem_memory();
783}
784
785static int msm7x27a_paddr_to_memtype(unsigned int paddr)
786{
787 return MEMTYPE_EBI1;
788}
789
790static struct reserve_info msm7x27a_reserve_info __initdata = {
791 .memtype_reserve_table = msm7x27a_reserve_table,
792 .calculate_reserve_sizes = msm7x27a_calculate_reserve_sizes,
793 .paddr_to_memtype = msm7x27a_paddr_to_memtype,
794};
795
796static void __init msm7x27a_reserve(void)
797{
798 reserve_info = &msm7x27a_reserve_info;
799 msm_reserve();
800}
801
802static void __init msm_device_i2c_init(void)
803{
Taniya Das9d187142011-12-02 15:53:25 +0530804 if (machine_is_msm8625_rumi3()) {
805 msm8625_device_qup_i2c_gsbi0.dev.platform_data =
806 &msm8625_gsbi0_qup_i2c_pdata;
807 return;
808 }
809
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700810 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
811 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
812}
813
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700814#define MSM_EBI2_PHYS 0xa0d00000
815#define MSM_EBI2_XMEM_CS2_CFG1 0xa0d10030
816
817static void __init msm7x27a_init_ebi2(void)
818{
819 uint32_t ebi2_cfg;
820 void __iomem *ebi2_cfg_ptr;
821
822 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_PHYS, sizeof(uint32_t));
823 if (!ebi2_cfg_ptr)
824 return;
825
826 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530827 if (machine_is_msm7x27a_rumi3() || machine_is_msm7x27a_surf() ||
828 machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700829 ebi2_cfg |= (1 << 4); /* CS2 */
830
831 writel(ebi2_cfg, ebi2_cfg_ptr);
832 iounmap(ebi2_cfg_ptr);
833
834 /* Enable A/D MUX[bit 31] from EBI2_XMEM_CS2_CFG1 */
835 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_XMEM_CS2_CFG1,
836 sizeof(uint32_t));
837 if (!ebi2_cfg_ptr)
838 return;
839
840 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530841 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700842 ebi2_cfg |= (1 << 31);
843
844 writel(ebi2_cfg, ebi2_cfg_ptr);
845 iounmap(ebi2_cfg_ptr);
846}
847
848#define ATMEL_TS_I2C_NAME "maXTouch"
Justin Paupored98328e2011-08-19 13:48:31 -0700849
850static struct regulator_bulk_data regs_atmel[] = {
851 { .supply = "ldo2", .min_uV = 2850000, .max_uV = 2850000 },
852 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
853};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700854
855#define ATMEL_TS_GPIO_IRQ 82
856
857static int atmel_ts_power_on(bool on)
858{
Justin Paupored98328e2011-08-19 13:48:31 -0700859 int rc = on ?
860 regulator_bulk_enable(ARRAY_SIZE(regs_atmel), regs_atmel) :
861 regulator_bulk_disable(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700862
Justin Paupored98328e2011-08-19 13:48:31 -0700863 if (rc)
864 pr_err("%s: could not %sable regulators: %d\n",
865 __func__, on ? "en" : "dis", rc);
866 else
867 msleep(50);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700868
Justin Paupored98328e2011-08-19 13:48:31 -0700869 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700870}
871
872static int atmel_ts_platform_init(struct i2c_client *client)
873{
874 int rc;
Justin Paupored98328e2011-08-19 13:48:31 -0700875 struct device *dev = &client->dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700876
Justin Paupored98328e2011-08-19 13:48:31 -0700877 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700878 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700879 dev_err(dev, "%s: could not get regulators: %d\n",
880 __func__, rc);
881 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700882 }
883
Justin Paupored98328e2011-08-19 13:48:31 -0700884 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700885 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700886 dev_err(dev, "%s: could not set voltages: %d\n",
887 __func__, rc);
888 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700889 }
890
891 rc = gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
892 GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
893 GPIO_CFG_8MA), GPIO_CFG_ENABLE);
894 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700895 dev_err(dev, "%s: gpio_tlmm_config for %d failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700896 __func__, ATMEL_TS_GPIO_IRQ);
Justin Paupored98328e2011-08-19 13:48:31 -0700897 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700898 }
899
900 /* configure touchscreen interrupt gpio */
901 rc = gpio_request(ATMEL_TS_GPIO_IRQ, "atmel_maxtouch_gpio");
902 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700903 dev_err(dev, "%s: unable to request gpio %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700904 __func__, ATMEL_TS_GPIO_IRQ);
905 goto ts_gpio_tlmm_unconfig;
906 }
907
908 rc = gpio_direction_input(ATMEL_TS_GPIO_IRQ);
909 if (rc < 0) {
Justin Paupored98328e2011-08-19 13:48:31 -0700910 dev_err(dev, "%s: unable to set the direction of gpio %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700911 __func__, ATMEL_TS_GPIO_IRQ);
912 goto free_ts_gpio;
913 }
914 return 0;
915
916free_ts_gpio:
917 gpio_free(ATMEL_TS_GPIO_IRQ);
918ts_gpio_tlmm_unconfig:
919 gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
920 GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
921 GPIO_CFG_2MA), GPIO_CFG_DISABLE);
Justin Paupored98328e2011-08-19 13:48:31 -0700922reg_free:
923 regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel);
924out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700925 return rc;
926}
927
928static int atmel_ts_platform_exit(struct i2c_client *client)
929{
930 gpio_free(ATMEL_TS_GPIO_IRQ);
931 gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
932 GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
933 GPIO_CFG_2MA), GPIO_CFG_DISABLE);
Justin Paupored98328e2011-08-19 13:48:31 -0700934 regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700935 return 0;
936}
937
938static u8 atmel_ts_read_chg(void)
939{
940 return gpio_get_value(ATMEL_TS_GPIO_IRQ);
941}
942
943static u8 atmel_ts_valid_interrupt(void)
944{
945 return !atmel_ts_read_chg();
946}
947
948#define ATMEL_X_OFFSET 13
949#define ATMEL_Y_OFFSET 0
950
Mohan Pallaka4e9a94e2011-11-23 16:34:21 +0530951static struct maxtouch_platform_data atmel_ts_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700952 .numtouch = 4,
953 .init_platform_hw = atmel_ts_platform_init,
954 .exit_platform_hw = atmel_ts_platform_exit,
955 .power_on = atmel_ts_power_on,
956 .display_res_x = 480,
957 .display_res_y = 864,
958 .min_x = ATMEL_X_OFFSET,
959 .max_x = (505 - ATMEL_X_OFFSET),
960 .min_y = ATMEL_Y_OFFSET,
961 .max_y = (863 - ATMEL_Y_OFFSET),
962 .valid_interrupt = atmel_ts_valid_interrupt,
963 .read_chg = atmel_ts_read_chg,
964};
965
966static struct i2c_board_info atmel_ts_i2c_info[] __initdata = {
967 {
968 I2C_BOARD_INFO(ATMEL_TS_I2C_NAME, 0x4a),
969 .platform_data = &atmel_ts_pdata,
970 .irq = MSM_GPIO_TO_INT(ATMEL_TS_GPIO_IRQ),
971 },
972};
973
974#define KP_INDEX(row, col) ((row)*ARRAY_SIZE(kp_col_gpios) + (col))
975
976static unsigned int kp_row_gpios[] = {31, 32, 33, 34, 35};
977static unsigned int kp_col_gpios[] = {36, 37, 38, 39, 40};
978
979static const unsigned short keymap[ARRAY_SIZE(kp_col_gpios) *
980 ARRAY_SIZE(kp_row_gpios)] = {
981 [KP_INDEX(0, 0)] = KEY_7,
982 [KP_INDEX(0, 1)] = KEY_DOWN,
983 [KP_INDEX(0, 2)] = KEY_UP,
984 [KP_INDEX(0, 3)] = KEY_RIGHT,
985 [KP_INDEX(0, 4)] = KEY_ENTER,
986
987 [KP_INDEX(1, 0)] = KEY_LEFT,
988 [KP_INDEX(1, 1)] = KEY_SEND,
989 [KP_INDEX(1, 2)] = KEY_1,
990 [KP_INDEX(1, 3)] = KEY_4,
991 [KP_INDEX(1, 4)] = KEY_CLEAR,
992
993 [KP_INDEX(2, 0)] = KEY_6,
994 [KP_INDEX(2, 1)] = KEY_5,
995 [KP_INDEX(2, 2)] = KEY_8,
996 [KP_INDEX(2, 3)] = KEY_3,
997 [KP_INDEX(2, 4)] = KEY_NUMERIC_STAR,
998
999 [KP_INDEX(3, 0)] = KEY_9,
1000 [KP_INDEX(3, 1)] = KEY_NUMERIC_POUND,
1001 [KP_INDEX(3, 2)] = KEY_0,
1002 [KP_INDEX(3, 3)] = KEY_2,
1003 [KP_INDEX(3, 4)] = KEY_SLEEP,
1004
1005 [KP_INDEX(4, 0)] = KEY_BACK,
1006 [KP_INDEX(4, 1)] = KEY_HOME,
1007 [KP_INDEX(4, 2)] = KEY_MENU,
1008 [KP_INDEX(4, 3)] = KEY_VOLUMEUP,
1009 [KP_INDEX(4, 4)] = KEY_VOLUMEDOWN,
1010};
1011
1012/* SURF keypad platform device information */
1013static struct gpio_event_matrix_info kp_matrix_info = {
1014 .info.func = gpio_event_matrix_func,
1015 .keymap = keymap,
1016 .output_gpios = kp_row_gpios,
1017 .input_gpios = kp_col_gpios,
1018 .noutputs = ARRAY_SIZE(kp_row_gpios),
1019 .ninputs = ARRAY_SIZE(kp_col_gpios),
1020 .settle_time.tv_nsec = 40 * NSEC_PER_USEC,
1021 .poll_time.tv_nsec = 20 * NSEC_PER_MSEC,
1022 .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE |
1023 GPIOKPF_PRINT_UNMAPPED_KEYS,
1024};
1025
1026static struct gpio_event_info *kp_info[] = {
1027 &kp_matrix_info.info
1028};
1029
1030static struct gpio_event_platform_data kp_pdata = {
1031 .name = "7x27a_kp",
1032 .info = kp_info,
1033 .info_count = ARRAY_SIZE(kp_info)
1034};
1035
1036static struct platform_device kp_pdev = {
1037 .name = GPIO_EVENT_DEV_NAME,
1038 .id = -1,
1039 .dev = {
1040 .platform_data = &kp_pdata,
1041 },
1042};
1043
1044static struct msm_handset_platform_data hs_platform_data = {
1045 .hs_name = "7k_handset",
1046 .pwr_key_delay_ms = 500, /* 0 will disable end key */
1047};
1048
1049static struct platform_device hs_pdev = {
1050 .name = "msm-handset",
1051 .id = -1,
1052 .dev = {
1053 .platform_data = &hs_platform_data,
1054 },
1055};
1056
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001057static struct platform_device msm_proccomm_regulator_dev = {
1058 .name = PROCCOMM_REGULATOR_DEV_NAME,
1059 .id = -1,
1060 .dev = {
1061 .platform_data = &msm7x27a_proccomm_regulator_data
1062 }
1063};
1064
Trilok Soni16f61af2011-07-26 16:06:58 +05301065static void __init msm7627a_rumi3_init(void)
1066{
1067 msm7x27a_init_ebi2();
1068 platform_add_devices(rumi_sim_devices,
1069 ARRAY_SIZE(rumi_sim_devices));
1070}
1071
Taniya Das43bcdd62011-12-02 17:33:27 +05301072static void __init msm8625_rumi3_init(void)
1073{
1074 msm7x2x_misc_init();
Taniya Das9d187142011-12-02 15:53:25 +05301075 msm_device_i2c_init();
Taniya Das43bcdd62011-12-02 17:33:27 +05301076 platform_add_devices(msm8625_rumi3_devices,
1077 ARRAY_SIZE(msm8625_rumi3_devices));
1078}
1079
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001080#define LED_GPIO_PDM 96
1081#define UART1DM_RX_GPIO 45
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301082
1083#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
1084static int __init msm7x27a_init_ar6000pm(void)
1085{
Santosh Sajjan374d6592012-01-19 23:16:46 +05301086 msm_wlan_ar6000_pm_device.dev.platform_data = &ar600x_wlan_power;
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301087 return platform_device_register(&msm_wlan_ar6000_pm_device);
1088}
1089#else
1090static int __init msm7x27a_init_ar6000pm(void) { return 0; }
1091#endif
1092
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001093static void __init msm7x27a_init_regulators(void)
1094{
1095 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1096 if (rc)
1097 pr_err("%s: could not register regulator device: %d\n",
1098 __func__, rc);
1099}
1100
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001101static void __init msm7x2x_init(void)
1102{
Trilok Sonia416c492011-07-22 20:20:23 +05301103 msm7x2x_misc_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001104
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001105 /* Initialize regulators first so that other devices can use them */
1106 msm7x27a_init_regulators();
1107
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001108 /* Common functions for SURF/FFA/RUMI3 */
1109 msm_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001110 msm7x27a_init_ebi2();
1111 msm7x27a_cfg_uart2dm_serial();
1112#ifdef CONFIG_SERIAL_MSM_HS
1113 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
1114 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
1115#endif
1116
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001117#ifdef CONFIG_USB_MSM_OTG_72K
Trilok Soni16f61af2011-07-26 16:06:58 +05301118 msm_otg_pdata.swfi_latency =
1119 msm7x27a_pm_data
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001120 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
Trilok Soni16f61af2011-07-26 16:06:58 +05301121 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001122#endif
Trilok Soni16f61af2011-07-26 16:06:58 +05301123 msm_device_gadget_peripheral.dev.platform_data =
1124 &msm_gadget_pdata;
1125 msm7x27a_cfg_smsc911x();
1126 platform_add_devices(msm_footswitch_devices,
1127 msm_num_footswitch_devices);
1128 platform_add_devices(surf_ffa_devices,
1129 ARRAY_SIZE(surf_ffa_devices));
Sujith Reddy Thummaad7c9a82011-09-30 20:54:38 +05301130 /* Ensure ar6000pm device is registered before MMC/SDC */
1131 msm7x27a_init_ar6000pm();
1132#ifdef CONFIG_MMC_MSM
Chintan Pandyacf467fc2011-12-01 17:11:11 +05301133 msm7627a_init_mmc();
Sujith Reddy Thummaad7c9a82011-09-30 20:54:38 +05301134#endif
Trilok Soni16f61af2011-07-26 16:06:58 +05301135 msm_fb_add_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001136#ifdef CONFIG_USB_EHCI_MSM_72K
Trilok Soni16f61af2011-07-26 16:06:58 +05301137 msm7x2x_init_host();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001138#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001139
1140 msm_pm_set_platform_data(msm7x27a_pm_data,
1141 ARRAY_SIZE(msm7x27a_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06001142 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001143
1144#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
1145 register_i2c_devices();
1146#endif
1147#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Chintan Pandya13490c02011-12-20 13:03:36 +05301148 msm7627a_bt_power_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001149#endif
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301150 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001151 atmel_ts_pdata.min_x = 0;
1152 atmel_ts_pdata.max_x = 480;
1153 atmel_ts_pdata.min_y = 0;
1154 atmel_ts_pdata.max_y = 320;
1155 }
1156
1157 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
1158 atmel_ts_i2c_info,
1159 ARRAY_SIZE(atmel_ts_i2c_info));
1160
Pankaj Kumar5be2a3e2011-09-26 11:45:02 +05301161#if defined(CONFIG_MSM_CAMERA)
Chintan Pandya40762702011-12-06 13:47:06 +05301162 msm7627a_camera_init();
Pankaj Kumar5be2a3e2011-09-26 11:45:02 +05301163#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001164 platform_device_register(&kp_pdev);
1165 platform_device_register(&hs_pdev);
1166
1167 /* configure it as a pdm function*/
1168 if (gpio_tlmm_config(GPIO_CFG(LED_GPIO_PDM, 3,
1169 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
1170 GPIO_CFG_8MA), GPIO_CFG_ENABLE))
1171 pr_err("%s: gpio_tlmm_config for %d failed\n",
1172 __func__, LED_GPIO_PDM);
1173 else
1174 platform_device_register(&led_pdev);
1175
1176#ifdef CONFIG_MSM_RPC_VIBRATOR
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301177 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001178 msm_init_pmic_vibrator();
1179#endif
1180 /*7x25a kgsl initializations*/
1181 msm7x25a_kgsl_3d0_init();
1182}
1183
1184static void __init msm7x2x_init_early(void)
1185{
Chintan Pandya250c2e52012-01-19 17:15:49 +05301186 msm_msm7627a_allocate_memory_regions();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001187}
1188
1189MACHINE_START(MSM7X27A_RUMI3, "QCT MSM7x27a RUMI3")
1190 .boot_params = PHYS_OFFSET + 0x100,
1191 .map_io = msm_common_io_init,
1192 .reserve = msm7x27a_reserve,
1193 .init_irq = msm_init_irq,
Trilok Soni16f61af2011-07-26 16:06:58 +05301194 .init_machine = msm7627a_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001195 .timer = &msm_timer,
1196 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301197 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001198MACHINE_END
1199MACHINE_START(MSM7X27A_SURF, "QCT MSM7x27a SURF")
1200 .boot_params = PHYS_OFFSET + 0x100,
1201 .map_io = msm_common_io_init,
1202 .reserve = msm7x27a_reserve,
1203 .init_irq = msm_init_irq,
1204 .init_machine = msm7x2x_init,
1205 .timer = &msm_timer,
1206 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301207 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001208MACHINE_END
1209MACHINE_START(MSM7X27A_FFA, "QCT MSM7x27a FFA")
1210 .boot_params = PHYS_OFFSET + 0x100,
1211 .map_io = msm_common_io_init,
1212 .reserve = msm7x27a_reserve,
1213 .init_irq = msm_init_irq,
1214 .init_machine = msm7x2x_init,
1215 .timer = &msm_timer,
1216 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301217 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001218MACHINE_END
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301219MACHINE_START(MSM7625A_SURF, "QCT MSM7625a SURF")
1220 .boot_params = PHYS_OFFSET + 0x100,
1221 .map_io = msm_common_io_init,
1222 .reserve = msm7x27a_reserve,
1223 .init_irq = msm_init_irq,
1224 .init_machine = msm7x2x_init,
1225 .timer = &msm_timer,
1226 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301227 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301228MACHINE_END
1229MACHINE_START(MSM7625A_FFA, "QCT MSM7625a FFA")
1230 .boot_params = PHYS_OFFSET + 0x100,
1231 .map_io = msm_common_io_init,
1232 .reserve = msm7x27a_reserve,
1233 .init_irq = msm_init_irq,
1234 .init_machine = msm7x2x_init,
1235 .timer = &msm_timer,
1236 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301237 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301238MACHINE_END
Taniya Das43bcdd62011-12-02 17:33:27 +05301239MACHINE_START(MSM8625_RUMI3, "QCT MSM8625 RUMI3")
1240 .boot_params = PHYS_OFFSET + 0x100,
1241 .map_io = msm8625_map_io,
1242 .init_irq = msm8625_init_irq,
1243 .init_machine = msm8625_rumi3_init,
1244 .timer = &msm_timer,
1245 .handle_irq = gic_handle_irq,
1246MACHINE_END