blob: 0680c440e9213432d5883d4b17d661d8303ae07a [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>
50#include "devices.h"
51#include "timer.h"
Justin Pauporeb3a33b72011-08-23 15:30:32 -070052#include "board-msm7x27a-regulator.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070053#include "devices-msm7x2xa.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080054#include "pm.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070055#include <mach/rpc_server_handset.h>
56#include <mach/socinfo.h>
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -060057#include "pm-boot.h"
Chintan Pandyacf467fc2011-12-01 17:11:11 +053058#include "board-msm7627a.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070059
60#define PMEM_KERNEL_EBI1_SIZE 0x3A000
61#define MSM_PMEM_AUDIO_SIZE 0x5B000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070062
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070063#if defined(CONFIG_GPIO_SX150X)
64enum {
65 SX150X_CORE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070066};
67
68static struct sx150x_platform_data sx150x_data[] __initdata = {
69 [SX150X_CORE] = {
70 .gpio_base = GPIO_CORE_EXPANDER_BASE,
71 .oscio_is_gpo = false,
72 .io_pullup_ena = 0,
pankaj kumarc5c01392011-08-12 13:44:05 +053073 .io_pulldn_ena = 0x02,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070074 .io_open_drain_ena = 0xfef8,
75 .irq_summary = -1,
76 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070077};
78#endif
79
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070080
Santosh Sajjan6822c682011-07-26 10:49:36 +053081static struct platform_device msm_wlan_ar6000_pm_device = {
82 .name = "wlan_ar6000_pm_dev",
83 .id = -1,
84};
85
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070086#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
87static struct i2c_board_info core_exp_i2c_info[] __initdata = {
88 {
89 I2C_BOARD_INFO("sx1509q", 0x3e),
90 },
91};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070092
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070093static void __init register_i2c_devices(void)
94{
Trilok Soni3d0f6c52011-07-26 16:06:58 +053095 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070096 sx150x_data[SX150X_CORE].io_open_drain_ena = 0xe0f0;
97
98 core_exp_i2c_info[0].platform_data =
99 &sx150x_data[SX150X_CORE];
100
101 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
102 core_exp_i2c_info,
103 ARRAY_SIZE(core_exp_i2c_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700104}
105#endif
106
107static struct msm_gpio qup_i2c_gpios_io[] = {
108 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
109 "qup_scl" },
110 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
111 "qup_sda" },
112 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
113 "qup_scl" },
114 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
115 "qup_sda" },
116};
117
118static struct msm_gpio qup_i2c_gpios_hw[] = {
119 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
120 "qup_scl" },
121 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
122 "qup_sda" },
123 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
124 "qup_scl" },
125 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
126 "qup_sda" },
127};
128
129static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
130{
131 int rc;
132
133 if (adap_id < 0 || adap_id > 1)
134 return;
135
136 /* Each adapter gets 2 lines from the table */
137 if (config_type)
138 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
139 else
140 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
141 if (rc < 0)
142 pr_err("QUP GPIO request/enable failed: %d\n", rc);
143}
144
145static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
146 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700147 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
148};
149
150static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
151 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700152 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
153};
154
Taniya Das9d187142011-12-02 15:53:25 +0530155static struct msm_i2c_platform_data msm8625_gsbi0_qup_i2c_pdata = {
156 .clk_freq = 100000,
157};
158
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700159#ifdef CONFIG_ARCH_MSM7X27A
Neti Ravi Kumar061726e2011-12-08 15:14:57 +0530160#define MSM_PMEM_MDP_SIZE 0x2300000
161#define MSM7x25A_MSM_PMEM_MDP_SIZE 0x1500000
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530162
Mahesh Lankaa2f6df12012-01-05 16:54:40 +0530163#define MSM_PMEM_ADSP_SIZE 0x1100000
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530164#define MSM7x25A_MSM_PMEM_ADSP_SIZE 0xB91000
165
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700166#endif
167
168static struct android_usb_platform_data android_usb_pdata = {
169 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
170};
171
172static struct platform_device android_usb_device = {
173 .name = "android_usb",
174 .id = -1,
175 .dev = {
176 .platform_data = &android_usb_pdata,
177 },
178};
179
180#ifdef CONFIG_USB_EHCI_MSM_72K
181static void msm_hsusb_vbus_power(unsigned phy_info, int on)
182{
183 int rc = 0;
184 unsigned gpio;
185
186 gpio = GPIO_HOST_VBUS_EN;
187
188 rc = gpio_request(gpio, "i2c_host_vbus_en");
189 if (rc < 0) {
190 pr_err("failed to request %d GPIO\n", gpio);
191 return;
192 }
193 gpio_direction_output(gpio, !!on);
194 gpio_set_value_cansleep(gpio, !!on);
195 gpio_free(gpio);
196}
197
198static struct msm_usb_host_platform_data msm_usb_host_pdata = {
199 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
200};
201
202static void __init msm7x2x_init_host(void)
203{
204 msm_add_host(0, &msm_usb_host_pdata);
205}
206#endif
207
208#ifdef CONFIG_USB_MSM_OTG_72K
209static int hsusb_rpc_connect(int connect)
210{
211 if (connect)
212 return msm_hsusb_rpc_connect();
213 else
214 return msm_hsusb_rpc_close();
215}
216
Justin Paupored98328e2011-08-19 13:48:31 -0700217static struct regulator *reg_hsusb;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700218static int msm_hsusb_ldo_init(int init)
219{
Justin Paupored98328e2011-08-19 13:48:31 -0700220 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700221
Justin Paupored98328e2011-08-19 13:48:31 -0700222 if (init) {
223 reg_hsusb = regulator_get(NULL, "usb");
224 if (IS_ERR(reg_hsusb)) {
225 rc = PTR_ERR(reg_hsusb);
226 pr_err("%s: could not get regulator: %d\n",
227 __func__, rc);
228 goto out;
229 }
230
231 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
232 if (rc) {
233 pr_err("%s: could not set voltage: %d\n",
234 __func__, rc);
235 goto reg_free;
236 }
237
238 return 0;
239 }
240 /* else fall through */
241reg_free:
242 regulator_put(reg_hsusb);
243out:
244 reg_hsusb = NULL;
245 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700246}
247
248static int msm_hsusb_ldo_enable(int enable)
249{
250 static int ldo_status;
251
Justin Paupored98328e2011-08-19 13:48:31 -0700252 if (IS_ERR_OR_NULL(reg_hsusb))
253 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700254
255 if (ldo_status == enable)
256 return 0;
257
258 ldo_status = enable;
259
Justin Paupored98328e2011-08-19 13:48:31 -0700260 return enable ?
261 regulator_enable(reg_hsusb) :
262 regulator_disable(reg_hsusb);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700263}
264
265#ifndef CONFIG_USB_EHCI_MSM_72K
266static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
267{
268 int ret = 0;
269
270 if (init)
271 ret = msm_pm_app_rpc_init(callback);
272 else
273 msm_pm_app_rpc_deinit(callback);
274
275 return ret;
276}
277#endif
278
279static struct msm_otg_platform_data msm_otg_pdata = {
280#ifndef CONFIG_USB_EHCI_MSM_72K
281 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
282#else
283 .vbus_power = msm_hsusb_vbus_power,
284#endif
285 .rpc_connect = hsusb_rpc_connect,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700286 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
287 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
288 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
289 .se1_gating = SE1_GATING_DISABLE,
290 .ldo_init = msm_hsusb_ldo_init,
291 .ldo_enable = msm_hsusb_ldo_enable,
292 .chg_init = hsusb_chg_init,
293 .chg_connected = hsusb_chg_connected,
294 .chg_vbus_draw = hsusb_chg_vbus_draw,
295};
296#endif
297
298static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
299 .is_phy_status_timer_on = 1,
300};
301
302static struct resource smc91x_resources[] = {
303 [0] = {
304 .start = 0x90000300,
305 .end = 0x900003ff,
306 .flags = IORESOURCE_MEM,
307 },
308 [1] = {
309 .start = MSM_GPIO_TO_INT(4),
310 .end = MSM_GPIO_TO_INT(4),
311 .flags = IORESOURCE_IRQ,
312 },
313};
314
315static struct platform_device smc91x_device = {
316 .name = "smc91x",
317 .id = 0,
318 .num_resources = ARRAY_SIZE(smc91x_resources),
319 .resource = smc91x_resources,
320};
321
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700322#ifdef CONFIG_SERIAL_MSM_HS
323static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
324 .inject_rx_on_wakeup = 1,
325 .rx_to_inject = 0xFD,
326};
327#endif
328static struct msm_pm_platform_data msm7x27a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
329 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
330 .idle_supported = 1,
331 .suspend_supported = 1,
332 .idle_enabled = 1,
333 .suspend_enabled = 1,
334 .latency = 16000,
335 .residency = 20000,
336 },
337 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
338 .idle_supported = 1,
339 .suspend_supported = 1,
340 .idle_enabled = 1,
341 .suspend_enabled = 1,
342 .latency = 12000,
343 .residency = 20000,
344 },
345 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
346 .idle_supported = 1,
347 .suspend_supported = 1,
348 .idle_enabled = 0,
349 .suspend_enabled = 1,
350 .latency = 2000,
351 .residency = 0,
352 },
353 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
354 .idle_supported = 1,
355 .suspend_supported = 1,
356 .idle_enabled = 1,
357 .suspend_enabled = 1,
358 .latency = 2,
359 .residency = 0,
360 },
361};
362
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600363static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +0530364 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
365 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600366};
367
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700368static struct android_pmem_platform_data android_pmem_adsp_pdata = {
369 .name = "pmem_adsp",
370 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
Mahesh Lankac6af7eb2011-08-02 18:00:35 +0530371 .cached = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700372 .memory_type = MEMTYPE_EBI1,
373};
374
375static struct platform_device android_pmem_adsp_device = {
376 .name = "android_pmem",
377 .id = 1,
378 .dev = { .platform_data = &android_pmem_adsp_pdata },
379};
380
381static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
382static int __init pmem_mdp_size_setup(char *p)
383{
384 pmem_mdp_size = memparse(p, NULL);
385 return 0;
386}
387
388early_param("pmem_mdp_size", pmem_mdp_size_setup);
389
390static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
391static int __init pmem_adsp_size_setup(char *p)
392{
393 pmem_adsp_size = memparse(p, NULL);
394 return 0;
395}
396
397early_param("pmem_adsp_size", pmem_adsp_size_setup);
398
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700399#define SND(desc, num) { .name = #desc, .id = num }
400static struct snd_endpoint snd_endpoints_list[] = {
401 SND(HANDSET, 0),
402 SND(MONO_HEADSET, 2),
403 SND(HEADSET, 3),
404 SND(SPEAKER, 6),
405 SND(TTY_HEADSET, 8),
406 SND(TTY_VCO, 9),
407 SND(TTY_HCO, 10),
408 SND(BT, 12),
409 SND(IN_S_SADC_OUT_HANDSET, 16),
410 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
411 SND(FM_DIGITAL_STEREO_HEADSET, 26),
412 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
413 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
Shashi Kumar64e07602011-10-11 13:18:57 +0530414 SND(STEREO_HEADSET_AND_SPEAKER, 31),
Sidipotu Ashokab34ca42011-07-22 16:34:20 +0530415 SND(CURRENT, 0x7FFFFFFE),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700416 SND(FM_ANALOG_STEREO_HEADSET, 35),
417 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
418};
419#undef SND
420
421static struct msm_snd_endpoints msm_device_snd_endpoints = {
422 .endpoints = snd_endpoints_list,
423 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
424};
425
426static struct platform_device msm_device_snd = {
427 .name = "msm_snd",
428 .id = -1,
429 .dev = {
430 .platform_data = &msm_device_snd_endpoints
431 },
432};
433
434#define DEC0_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 DEC1_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 DEC2_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 DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
453 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
454 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
455 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
456 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
457 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
458#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
459
460static unsigned int dec_concurrency_table[] = {
461 /* Audio LP */
462 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
463 0, 0, 0,
464
465 /* Concurrency 1 */
466 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
467 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
468 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
469 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
470 (DEC4_FORMAT),
471
472 /* Concurrency 2 */
473 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
474 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
475 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
476 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
477 (DEC4_FORMAT),
478
479 /* Concurrency 3 */
480 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
481 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
482 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
483 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
484 (DEC4_FORMAT),
485
486 /* Concurrency 4 */
487 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
488 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
489 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
490 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
491 (DEC4_FORMAT),
492
493 /* Concurrency 5 */
494 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
495 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
496 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
497 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
498 (DEC4_FORMAT),
499
500 /* Concurrency 6 */
501 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
502 0, 0, 0, 0,
503
504 /* Concurrency 7 */
505 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
506 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
507 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
508 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
509 (DEC4_FORMAT),
510};
511
512#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
513 .module_queueid = queueid, .module_decid = decid, \
514 .nr_codec_support = nr_codec}
515
516static struct msm_adspdec_info dec_info_list[] = {
517 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
518 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
519 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
520 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
521 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
522};
523
524static struct msm_adspdec_database msm_device_adspdec_database = {
525 .num_dec = ARRAY_SIZE(dec_info_list),
526 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
527 ARRAY_SIZE(dec_info_list)),
528 .dec_concurrency_table = dec_concurrency_table,
529 .dec_info_list = dec_info_list,
530};
531
532static struct platform_device msm_device_adspdec = {
533 .name = "msm_adspdec",
534 .id = -1,
535 .dev = {
536 .platform_data = &msm_device_adspdec_database
537 },
538};
539
540static struct android_pmem_platform_data android_pmem_audio_pdata = {
541 .name = "pmem_audio",
542 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
543 .cached = 0,
544 .memory_type = MEMTYPE_EBI1,
545};
546
547static struct platform_device android_pmem_audio_device = {
548 .name = "android_pmem",
549 .id = 2,
550 .dev = { .platform_data = &android_pmem_audio_pdata },
551};
552
553static struct android_pmem_platform_data android_pmem_pdata = {
554 .name = "pmem",
555 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
556 .cached = 1,
557 .memory_type = MEMTYPE_EBI1,
558};
559static struct platform_device android_pmem_device = {
560 .name = "android_pmem",
561 .id = 0,
562 .dev = { .platform_data = &android_pmem_pdata },
563};
564
565static u32 msm_calculate_batt_capacity(u32 current_voltage);
566
567static struct msm_psy_batt_pdata msm_psy_batt_data = {
568 .voltage_min_design = 2800,
569 .voltage_max_design = 4300,
570 .avail_chg_sources = AC_CHG | USB_CHG ,
571 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
572 .calculate_capacity = &msm_calculate_batt_capacity,
573};
574
575static u32 msm_calculate_batt_capacity(u32 current_voltage)
576{
577 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
578 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
579
580 return (current_voltage - low_voltage) * 100
581 / (high_voltage - low_voltage);
582}
583
584static struct platform_device msm_batt_device = {
585 .name = "msm-battery",
586 .id = -1,
587 .dev.platform_data = &msm_psy_batt_data,
588};
589
590static struct smsc911x_platform_config smsc911x_config = {
591 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
592 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
593 .flags = SMSC911X_USE_16BIT,
594};
595
596static struct resource smsc911x_resources[] = {
597 [0] = {
598 .start = 0x90000000,
599 .end = 0x90007fff,
600 .flags = IORESOURCE_MEM,
601 },
602 [1] = {
603 .start = MSM_GPIO_TO_INT(48),
604 .end = MSM_GPIO_TO_INT(48),
605 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
606 },
607};
608
609static struct platform_device smsc911x_device = {
610 .name = "smsc911x",
611 .id = 0,
612 .num_resources = ARRAY_SIZE(smsc911x_resources),
613 .resource = smsc911x_resources,
614 .dev = {
615 .platform_data = &smsc911x_config,
616 },
617};
618
619static struct msm_gpio smsc911x_gpios[] = {
620 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
621 "smsc911x_irq" },
622 { GPIO_CFG(49, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
623 "eth_fifo_sel" },
624};
625
626#define ETH_FIFO_SEL_GPIO 49
627static void msm7x27a_cfg_smsc911x(void)
628{
629 int res;
630
631 res = msm_gpios_request_enable(smsc911x_gpios,
632 ARRAY_SIZE(smsc911x_gpios));
633 if (res) {
634 pr_err("%s: unable to enable gpios for SMSC911x\n", __func__);
635 return;
636 }
637
638 /* ETH_FIFO_SEL */
639 res = gpio_direction_output(ETH_FIFO_SEL_GPIO, 0);
640 if (res) {
641 pr_err("%s: unable to get direction for gpio %d\n", __func__,
642 ETH_FIFO_SEL_GPIO);
643 msm_gpios_disable_free(smsc911x_gpios,
644 ARRAY_SIZE(smsc911x_gpios));
645 return;
646 }
647 gpio_set_value(ETH_FIFO_SEL_GPIO, 0);
648}
649
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700650#if defined(CONFIG_SERIAL_MSM_HSL_CONSOLE) \
651 && defined(CONFIG_MSM_SHARED_GPIO_FOR_UART2DM)
652static struct msm_gpio uart2dm_gpios[] = {
653 {GPIO_CFG(19, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
654 "uart2dm_rfr_n" },
655 {GPIO_CFG(20, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
656 "uart2dm_cts_n" },
657 {GPIO_CFG(21, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
658 "uart2dm_rx" },
659 {GPIO_CFG(108, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
660 "uart2dm_tx" },
661};
662
663static void msm7x27a_cfg_uart2dm_serial(void)
664{
665 int ret;
666 ret = msm_gpios_request_enable(uart2dm_gpios,
667 ARRAY_SIZE(uart2dm_gpios));
668 if (ret)
669 pr_err("%s: unable to enable gpios for uart2dm\n", __func__);
670}
671#else
672static void msm7x27a_cfg_uart2dm_serial(void) { }
673#endif
674
675static struct platform_device *rumi_sim_devices[] __initdata = {
676 &msm_device_dmov,
677 &msm_device_smd,
678 &smc91x_device,
679 &msm_device_uart1,
680 &msm_device_nand,
681 &msm_device_uart_dm1,
682 &msm_gsbi0_qup_i2c_device,
683 &msm_gsbi1_qup_i2c_device,
684};
685
Taniya Das43bcdd62011-12-02 17:33:27 +0530686static struct platform_device *msm8625_rumi3_devices[] __initdata = {
687 &msm8625_device_dmov,
688 &msm8625_device_uart1,
Taniya Das9d187142011-12-02 15:53:25 +0530689 &msm8625_device_qup_i2c_gsbi0,
Taniya Das43bcdd62011-12-02 17:33:27 +0530690};
691
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700692static struct platform_device *surf_ffa_devices[] __initdata = {
693 &msm_device_dmov,
694 &msm_device_smd,
695 &msm_device_uart1,
696 &msm_device_uart_dm1,
697 &msm_device_uart_dm2,
698 &msm_device_nand,
699 &msm_gsbi0_qup_i2c_device,
700 &msm_gsbi1_qup_i2c_device,
701 &msm_device_otg,
702 &msm_device_gadget_peripheral,
703 &android_usb_device,
704 &android_pmem_device,
705 &android_pmem_adsp_device,
706 &android_pmem_audio_device,
707 &msm_device_snd,
708 &msm_device_adspdec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700709 &msm_batt_device,
710 &smsc911x_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700711 &msm_kgsl_3d0,
712#ifdef CONFIG_BT
713 &msm_bt_power_device,
714#endif
Manish Dewangan3a260992011-06-24 18:01:34 +0530715 &asoc_msm_pcm,
716 &asoc_msm_dai0,
717 &asoc_msm_dai1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700718};
719
720static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
721static int __init pmem_kernel_ebi1_size_setup(char *p)
722{
723 pmem_kernel_ebi1_size = memparse(p, NULL);
724 return 0;
725}
726early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
727
728static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
729static int __init pmem_audio_size_setup(char *p)
730{
731 pmem_audio_size = memparse(p, NULL);
732 return 0;
733}
734early_param("pmem_audio_size", pmem_audio_size_setup);
735
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700736static struct memtype_reserve msm7x27a_reserve_table[] __initdata = {
737 [MEMTYPE_SMI] = {
738 },
739 [MEMTYPE_EBI0] = {
740 .flags = MEMTYPE_FLAGS_1M_ALIGN,
741 },
742 [MEMTYPE_EBI1] = {
743 .flags = MEMTYPE_FLAGS_1M_ALIGN,
744 },
745};
746
747static void __init size_pmem_devices(void)
748{
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530749
750 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
751 pmem_mdp_size = MSM7x25A_MSM_PMEM_MDP_SIZE;
752 pmem_adsp_size = MSM7x25A_MSM_PMEM_ADSP_SIZE;
753 } else {
754 pmem_mdp_size = MSM_PMEM_MDP_SIZE;
755 pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
756 }
757
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700758#ifdef CONFIG_ANDROID_PMEM
759 android_pmem_adsp_pdata.size = pmem_adsp_size;
760 android_pmem_pdata.size = pmem_mdp_size;
761 android_pmem_audio_pdata.size = pmem_audio_size;
762#endif
763}
764
765static void __init reserve_memory_for(struct android_pmem_platform_data *p)
766{
767 msm7x27a_reserve_table[p->memory_type].size += p->size;
768}
769
770static void __init reserve_pmem_memory(void)
771{
772#ifdef CONFIG_ANDROID_PMEM
773 reserve_memory_for(&android_pmem_adsp_pdata);
774 reserve_memory_for(&android_pmem_pdata);
775 reserve_memory_for(&android_pmem_audio_pdata);
776 msm7x27a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
777#endif
778}
779
780static void __init msm7x27a_calculate_reserve_sizes(void)
781{
782 size_pmem_devices();
783 reserve_pmem_memory();
784}
785
786static int msm7x27a_paddr_to_memtype(unsigned int paddr)
787{
788 return MEMTYPE_EBI1;
789}
790
791static struct reserve_info msm7x27a_reserve_info __initdata = {
792 .memtype_reserve_table = msm7x27a_reserve_table,
793 .calculate_reserve_sizes = msm7x27a_calculate_reserve_sizes,
794 .paddr_to_memtype = msm7x27a_paddr_to_memtype,
795};
796
797static void __init msm7x27a_reserve(void)
798{
799 reserve_info = &msm7x27a_reserve_info;
800 msm_reserve();
801}
802
Taniya Das2b16d1d2011-12-02 14:44:19 +0530803static void __init msm8625_reserve(void)
804{
805 memblock_remove(MSM8625_SECONDARY_PHYS, SZ_8);
806}
807
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700808static void __init msm_device_i2c_init(void)
809{
Taniya Das9d187142011-12-02 15:53:25 +0530810 if (machine_is_msm8625_rumi3()) {
811 msm8625_device_qup_i2c_gsbi0.dev.platform_data =
812 &msm8625_gsbi0_qup_i2c_pdata;
813 return;
814 }
815
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700816 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
817 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
818}
819
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700820#define MSM_EBI2_PHYS 0xa0d00000
821#define MSM_EBI2_XMEM_CS2_CFG1 0xa0d10030
822
823static void __init msm7x27a_init_ebi2(void)
824{
825 uint32_t ebi2_cfg;
826 void __iomem *ebi2_cfg_ptr;
827
828 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_PHYS, sizeof(uint32_t));
829 if (!ebi2_cfg_ptr)
830 return;
831
832 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530833 if (machine_is_msm7x27a_rumi3() || machine_is_msm7x27a_surf() ||
834 machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700835 ebi2_cfg |= (1 << 4); /* CS2 */
836
837 writel(ebi2_cfg, ebi2_cfg_ptr);
838 iounmap(ebi2_cfg_ptr);
839
840 /* Enable A/D MUX[bit 31] from EBI2_XMEM_CS2_CFG1 */
841 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_XMEM_CS2_CFG1,
842 sizeof(uint32_t));
843 if (!ebi2_cfg_ptr)
844 return;
845
846 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530847 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700848 ebi2_cfg |= (1 << 31);
849
850 writel(ebi2_cfg, ebi2_cfg_ptr);
851 iounmap(ebi2_cfg_ptr);
852}
853
854#define ATMEL_TS_I2C_NAME "maXTouch"
Justin Paupored98328e2011-08-19 13:48:31 -0700855
856static struct regulator_bulk_data regs_atmel[] = {
857 { .supply = "ldo2", .min_uV = 2850000, .max_uV = 2850000 },
858 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
859};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700860
861#define ATMEL_TS_GPIO_IRQ 82
862
863static int atmel_ts_power_on(bool on)
864{
Justin Paupored98328e2011-08-19 13:48:31 -0700865 int rc = on ?
866 regulator_bulk_enable(ARRAY_SIZE(regs_atmel), regs_atmel) :
867 regulator_bulk_disable(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700868
Justin Paupored98328e2011-08-19 13:48:31 -0700869 if (rc)
870 pr_err("%s: could not %sable regulators: %d\n",
871 __func__, on ? "en" : "dis", rc);
872 else
873 msleep(50);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700874
Justin Paupored98328e2011-08-19 13:48:31 -0700875 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700876}
877
878static int atmel_ts_platform_init(struct i2c_client *client)
879{
880 int rc;
Justin Paupored98328e2011-08-19 13:48:31 -0700881 struct device *dev = &client->dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700882
Justin Paupored98328e2011-08-19 13:48:31 -0700883 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700884 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700885 dev_err(dev, "%s: could not get regulators: %d\n",
886 __func__, rc);
887 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700888 }
889
Justin Paupored98328e2011-08-19 13:48:31 -0700890 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700891 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700892 dev_err(dev, "%s: could not set voltages: %d\n",
893 __func__, rc);
894 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700895 }
896
897 rc = gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
898 GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
899 GPIO_CFG_8MA), GPIO_CFG_ENABLE);
900 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700901 dev_err(dev, "%s: gpio_tlmm_config for %d failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700902 __func__, ATMEL_TS_GPIO_IRQ);
Justin Paupored98328e2011-08-19 13:48:31 -0700903 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700904 }
905
906 /* configure touchscreen interrupt gpio */
907 rc = gpio_request(ATMEL_TS_GPIO_IRQ, "atmel_maxtouch_gpio");
908 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700909 dev_err(dev, "%s: unable to request gpio %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700910 __func__, ATMEL_TS_GPIO_IRQ);
911 goto ts_gpio_tlmm_unconfig;
912 }
913
914 rc = gpio_direction_input(ATMEL_TS_GPIO_IRQ);
915 if (rc < 0) {
Justin Paupored98328e2011-08-19 13:48:31 -0700916 dev_err(dev, "%s: unable to set the direction of gpio %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700917 __func__, ATMEL_TS_GPIO_IRQ);
918 goto free_ts_gpio;
919 }
920 return 0;
921
922free_ts_gpio:
923 gpio_free(ATMEL_TS_GPIO_IRQ);
924ts_gpio_tlmm_unconfig:
925 gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
926 GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
927 GPIO_CFG_2MA), GPIO_CFG_DISABLE);
Justin Paupored98328e2011-08-19 13:48:31 -0700928reg_free:
929 regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel);
930out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700931 return rc;
932}
933
934static int atmel_ts_platform_exit(struct i2c_client *client)
935{
936 gpio_free(ATMEL_TS_GPIO_IRQ);
937 gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
938 GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
939 GPIO_CFG_2MA), GPIO_CFG_DISABLE);
Justin Paupored98328e2011-08-19 13:48:31 -0700940 regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700941 return 0;
942}
943
944static u8 atmel_ts_read_chg(void)
945{
946 return gpio_get_value(ATMEL_TS_GPIO_IRQ);
947}
948
949static u8 atmel_ts_valid_interrupt(void)
950{
951 return !atmel_ts_read_chg();
952}
953
954#define ATMEL_X_OFFSET 13
955#define ATMEL_Y_OFFSET 0
956
Mohan Pallaka4e9a94e2011-11-23 16:34:21 +0530957static struct maxtouch_platform_data atmel_ts_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700958 .numtouch = 4,
959 .init_platform_hw = atmel_ts_platform_init,
960 .exit_platform_hw = atmel_ts_platform_exit,
961 .power_on = atmel_ts_power_on,
962 .display_res_x = 480,
963 .display_res_y = 864,
964 .min_x = ATMEL_X_OFFSET,
965 .max_x = (505 - ATMEL_X_OFFSET),
966 .min_y = ATMEL_Y_OFFSET,
967 .max_y = (863 - ATMEL_Y_OFFSET),
968 .valid_interrupt = atmel_ts_valid_interrupt,
969 .read_chg = atmel_ts_read_chg,
970};
971
972static struct i2c_board_info atmel_ts_i2c_info[] __initdata = {
973 {
974 I2C_BOARD_INFO(ATMEL_TS_I2C_NAME, 0x4a),
975 .platform_data = &atmel_ts_pdata,
976 .irq = MSM_GPIO_TO_INT(ATMEL_TS_GPIO_IRQ),
977 },
978};
979
980#define KP_INDEX(row, col) ((row)*ARRAY_SIZE(kp_col_gpios) + (col))
981
982static unsigned int kp_row_gpios[] = {31, 32, 33, 34, 35};
983static unsigned int kp_col_gpios[] = {36, 37, 38, 39, 40};
984
985static const unsigned short keymap[ARRAY_SIZE(kp_col_gpios) *
986 ARRAY_SIZE(kp_row_gpios)] = {
987 [KP_INDEX(0, 0)] = KEY_7,
988 [KP_INDEX(0, 1)] = KEY_DOWN,
989 [KP_INDEX(0, 2)] = KEY_UP,
990 [KP_INDEX(0, 3)] = KEY_RIGHT,
991 [KP_INDEX(0, 4)] = KEY_ENTER,
992
993 [KP_INDEX(1, 0)] = KEY_LEFT,
994 [KP_INDEX(1, 1)] = KEY_SEND,
995 [KP_INDEX(1, 2)] = KEY_1,
996 [KP_INDEX(1, 3)] = KEY_4,
997 [KP_INDEX(1, 4)] = KEY_CLEAR,
998
999 [KP_INDEX(2, 0)] = KEY_6,
1000 [KP_INDEX(2, 1)] = KEY_5,
1001 [KP_INDEX(2, 2)] = KEY_8,
1002 [KP_INDEX(2, 3)] = KEY_3,
1003 [KP_INDEX(2, 4)] = KEY_NUMERIC_STAR,
1004
1005 [KP_INDEX(3, 0)] = KEY_9,
1006 [KP_INDEX(3, 1)] = KEY_NUMERIC_POUND,
1007 [KP_INDEX(3, 2)] = KEY_0,
1008 [KP_INDEX(3, 3)] = KEY_2,
1009 [KP_INDEX(3, 4)] = KEY_SLEEP,
1010
1011 [KP_INDEX(4, 0)] = KEY_BACK,
1012 [KP_INDEX(4, 1)] = KEY_HOME,
1013 [KP_INDEX(4, 2)] = KEY_MENU,
1014 [KP_INDEX(4, 3)] = KEY_VOLUMEUP,
1015 [KP_INDEX(4, 4)] = KEY_VOLUMEDOWN,
1016};
1017
1018/* SURF keypad platform device information */
1019static struct gpio_event_matrix_info kp_matrix_info = {
1020 .info.func = gpio_event_matrix_func,
1021 .keymap = keymap,
1022 .output_gpios = kp_row_gpios,
1023 .input_gpios = kp_col_gpios,
1024 .noutputs = ARRAY_SIZE(kp_row_gpios),
1025 .ninputs = ARRAY_SIZE(kp_col_gpios),
1026 .settle_time.tv_nsec = 40 * NSEC_PER_USEC,
1027 .poll_time.tv_nsec = 20 * NSEC_PER_MSEC,
1028 .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE |
1029 GPIOKPF_PRINT_UNMAPPED_KEYS,
1030};
1031
1032static struct gpio_event_info *kp_info[] = {
1033 &kp_matrix_info.info
1034};
1035
1036static struct gpio_event_platform_data kp_pdata = {
1037 .name = "7x27a_kp",
1038 .info = kp_info,
1039 .info_count = ARRAY_SIZE(kp_info)
1040};
1041
1042static struct platform_device kp_pdev = {
1043 .name = GPIO_EVENT_DEV_NAME,
1044 .id = -1,
1045 .dev = {
1046 .platform_data = &kp_pdata,
1047 },
1048};
1049
1050static struct msm_handset_platform_data hs_platform_data = {
1051 .hs_name = "7k_handset",
1052 .pwr_key_delay_ms = 500, /* 0 will disable end key */
1053};
1054
1055static struct platform_device hs_pdev = {
1056 .name = "msm-handset",
1057 .id = -1,
1058 .dev = {
1059 .platform_data = &hs_platform_data,
1060 },
1061};
1062
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001063static struct platform_device msm_proccomm_regulator_dev = {
1064 .name = PROCCOMM_REGULATOR_DEV_NAME,
1065 .id = -1,
1066 .dev = {
1067 .platform_data = &msm7x27a_proccomm_regulator_data
1068 }
1069};
1070
Trilok Soni16f61af2011-07-26 16:06:58 +05301071static void __init msm7627a_rumi3_init(void)
1072{
1073 msm7x27a_init_ebi2();
1074 platform_add_devices(rumi_sim_devices,
1075 ARRAY_SIZE(rumi_sim_devices));
1076}
1077
Taniya Das43bcdd62011-12-02 17:33:27 +05301078static void __init msm8625_rumi3_init(void)
1079{
1080 msm7x2x_misc_init();
Taniya Das9d187142011-12-02 15:53:25 +05301081 msm_device_i2c_init();
Taniya Das43bcdd62011-12-02 17:33:27 +05301082 platform_add_devices(msm8625_rumi3_devices,
1083 ARRAY_SIZE(msm8625_rumi3_devices));
1084}
1085
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001086#define LED_GPIO_PDM 96
1087#define UART1DM_RX_GPIO 45
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301088
1089#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
1090static int __init msm7x27a_init_ar6000pm(void)
1091{
Santosh Sajjan374d6592012-01-19 23:16:46 +05301092 msm_wlan_ar6000_pm_device.dev.platform_data = &ar600x_wlan_power;
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301093 return platform_device_register(&msm_wlan_ar6000_pm_device);
1094}
1095#else
1096static int __init msm7x27a_init_ar6000pm(void) { return 0; }
1097#endif
1098
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001099static void __init msm7x27a_init_regulators(void)
1100{
1101 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1102 if (rc)
1103 pr_err("%s: could not register regulator device: %d\n",
1104 __func__, rc);
1105}
1106
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001107static void __init msm7x2x_init(void)
1108{
Trilok Sonia416c492011-07-22 20:20:23 +05301109 msm7x2x_misc_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001110
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001111 /* Initialize regulators first so that other devices can use them */
1112 msm7x27a_init_regulators();
1113
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001114 /* Common functions for SURF/FFA/RUMI3 */
1115 msm_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001116 msm7x27a_init_ebi2();
1117 msm7x27a_cfg_uart2dm_serial();
1118#ifdef CONFIG_SERIAL_MSM_HS
1119 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
1120 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
1121#endif
1122
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001123#ifdef CONFIG_USB_MSM_OTG_72K
Trilok Soni16f61af2011-07-26 16:06:58 +05301124 msm_otg_pdata.swfi_latency =
1125 msm7x27a_pm_data
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001126 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
Trilok Soni16f61af2011-07-26 16:06:58 +05301127 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001128#endif
Trilok Soni16f61af2011-07-26 16:06:58 +05301129 msm_device_gadget_peripheral.dev.platform_data =
1130 &msm_gadget_pdata;
1131 msm7x27a_cfg_smsc911x();
1132 platform_add_devices(msm_footswitch_devices,
1133 msm_num_footswitch_devices);
1134 platform_add_devices(surf_ffa_devices,
1135 ARRAY_SIZE(surf_ffa_devices));
Sujith Reddy Thummaad7c9a82011-09-30 20:54:38 +05301136 /* Ensure ar6000pm device is registered before MMC/SDC */
1137 msm7x27a_init_ar6000pm();
1138#ifdef CONFIG_MMC_MSM
Chintan Pandyacf467fc2011-12-01 17:11:11 +05301139 msm7627a_init_mmc();
Sujith Reddy Thummaad7c9a82011-09-30 20:54:38 +05301140#endif
Trilok Soni16f61af2011-07-26 16:06:58 +05301141 msm_fb_add_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001142#ifdef CONFIG_USB_EHCI_MSM_72K
Trilok Soni16f61af2011-07-26 16:06:58 +05301143 msm7x2x_init_host();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001144#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001145
1146 msm_pm_set_platform_data(msm7x27a_pm_data,
1147 ARRAY_SIZE(msm7x27a_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06001148 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001149
1150#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
1151 register_i2c_devices();
1152#endif
1153#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Chintan Pandya13490c02011-12-20 13:03:36 +05301154 msm7627a_bt_power_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001155#endif
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301156 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001157 atmel_ts_pdata.min_x = 0;
1158 atmel_ts_pdata.max_x = 480;
1159 atmel_ts_pdata.min_y = 0;
1160 atmel_ts_pdata.max_y = 320;
1161 }
1162
1163 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
1164 atmel_ts_i2c_info,
1165 ARRAY_SIZE(atmel_ts_i2c_info));
1166
Pankaj Kumar5be2a3e2011-09-26 11:45:02 +05301167#if defined(CONFIG_MSM_CAMERA)
Chintan Pandya40762702011-12-06 13:47:06 +05301168 msm7627a_camera_init();
Pankaj Kumar5be2a3e2011-09-26 11:45:02 +05301169#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001170 platform_device_register(&kp_pdev);
1171 platform_device_register(&hs_pdev);
1172
1173 /* configure it as a pdm function*/
1174 if (gpio_tlmm_config(GPIO_CFG(LED_GPIO_PDM, 3,
1175 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
1176 GPIO_CFG_8MA), GPIO_CFG_ENABLE))
1177 pr_err("%s: gpio_tlmm_config for %d failed\n",
1178 __func__, LED_GPIO_PDM);
1179 else
1180 platform_device_register(&led_pdev);
1181
1182#ifdef CONFIG_MSM_RPC_VIBRATOR
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301183 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001184 msm_init_pmic_vibrator();
1185#endif
1186 /*7x25a kgsl initializations*/
1187 msm7x25a_kgsl_3d0_init();
1188}
1189
1190static void __init msm7x2x_init_early(void)
1191{
Chintan Pandya250c2e52012-01-19 17:15:49 +05301192 msm_msm7627a_allocate_memory_regions();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001193}
1194
1195MACHINE_START(MSM7X27A_RUMI3, "QCT MSM7x27a RUMI3")
1196 .boot_params = PHYS_OFFSET + 0x100,
1197 .map_io = msm_common_io_init,
1198 .reserve = msm7x27a_reserve,
1199 .init_irq = msm_init_irq,
Trilok Soni16f61af2011-07-26 16:06:58 +05301200 .init_machine = msm7627a_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001201 .timer = &msm_timer,
1202 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301203 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001204MACHINE_END
1205MACHINE_START(MSM7X27A_SURF, "QCT MSM7x27a SURF")
1206 .boot_params = PHYS_OFFSET + 0x100,
1207 .map_io = msm_common_io_init,
1208 .reserve = msm7x27a_reserve,
1209 .init_irq = msm_init_irq,
1210 .init_machine = msm7x2x_init,
1211 .timer = &msm_timer,
1212 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301213 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001214MACHINE_END
1215MACHINE_START(MSM7X27A_FFA, "QCT MSM7x27a FFA")
1216 .boot_params = PHYS_OFFSET + 0x100,
1217 .map_io = msm_common_io_init,
1218 .reserve = msm7x27a_reserve,
1219 .init_irq = msm_init_irq,
1220 .init_machine = msm7x2x_init,
1221 .timer = &msm_timer,
1222 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301223 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001224MACHINE_END
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301225MACHINE_START(MSM7625A_SURF, "QCT MSM7625a SURF")
1226 .boot_params = PHYS_OFFSET + 0x100,
1227 .map_io = msm_common_io_init,
1228 .reserve = msm7x27a_reserve,
1229 .init_irq = msm_init_irq,
1230 .init_machine = msm7x2x_init,
1231 .timer = &msm_timer,
1232 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301233 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301234MACHINE_END
1235MACHINE_START(MSM7625A_FFA, "QCT MSM7625a FFA")
1236 .boot_params = PHYS_OFFSET + 0x100,
1237 .map_io = msm_common_io_init,
1238 .reserve = msm7x27a_reserve,
1239 .init_irq = msm_init_irq,
1240 .init_machine = msm7x2x_init,
1241 .timer = &msm_timer,
1242 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301243 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301244MACHINE_END
Taniya Das43bcdd62011-12-02 17:33:27 +05301245MACHINE_START(MSM8625_RUMI3, "QCT MSM8625 RUMI3")
1246 .boot_params = PHYS_OFFSET + 0x100,
1247 .map_io = msm8625_map_io,
Taniya Das2b16d1d2011-12-02 14:44:19 +05301248 .reserve = msm8625_reserve,
Taniya Das43bcdd62011-12-02 17:33:27 +05301249 .init_irq = msm8625_init_irq,
1250 .init_machine = msm8625_rumi3_init,
1251 .timer = &msm_timer,
1252 .handle_irq = gic_handle_irq,
1253MACHINE_END