blob: a6b29dc811635adf0bb5c98293cb06836e06068d [file] [log] [blame]
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +05301/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/gpio_event.h>
Taniya Das2b16d1d2011-12-02 14:44:19 +053015#include <linux/memblock.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070016#include <asm/mach-types.h>
17#include <asm/mach/arch.h>
Taniya Das43bcdd62011-12-02 17:33:27 +053018#include <asm/hardware/gic.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070019#include <mach/board.h>
20#include <mach/msm_iomap.h>
21#include <mach/msm_hsusb.h>
22#include <mach/rpc_hsusb.h>
23#include <mach/rpc_pmapp.h>
24#include <mach/usbdiag.h>
25#include <mach/msm_memtypes.h>
26#include <mach/msm_serial_hs.h>
27#include <linux/usb/android.h>
28#include <linux/platform_device.h>
29#include <linux/io.h>
30#include <linux/gpio.h>
31#include <mach/vreg.h>
32#include <mach/pmic.h>
33#include <mach/socinfo.h>
34#include <linux/mtd/nand.h>
35#include <linux/mtd/partitions.h>
36#include <asm/mach/mmc.h>
37#include <linux/i2c.h>
38#include <linux/i2c/sx150x.h>
39#include <linux/gpio.h>
40#include <linux/android_pmem.h>
41#include <linux/bootmem.h>
42#include <linux/mfd/marimba.h>
43#include <mach/vreg.h>
44#include <linux/power_supply.h>
Justin Paupored98328e2011-08-19 13:48:31 -070045#include <linux/regulator/consumer.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046#include <mach/rpc_pmapp.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070047#include <mach/msm_battery.h>
48#include <linux/smsc911x.h>
49#include <linux/atmel_maxtouch.h>
Laura Abbott8f3d58b2011-12-18 10:47:03 -080050#include <linux/fmem.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051#include "devices.h"
52#include "timer.h"
Justin Pauporeb3a33b72011-08-23 15:30:32 -070053#include "board-msm7x27a-regulator.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070054#include "devices-msm7x2xa.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080055#include "pm.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056#include <mach/rpc_server_handset.h>
57#include <mach/socinfo.h>
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -060058#include "pm-boot.h"
Chintan Pandyacf467fc2011-12-01 17:11:11 +053059#include "board-msm7627a.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060
61#define PMEM_KERNEL_EBI1_SIZE 0x3A000
62#define MSM_PMEM_AUDIO_SIZE 0x5B000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070063
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070064#if defined(CONFIG_GPIO_SX150X)
65enum {
66 SX150X_CORE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070067};
68
69static struct sx150x_platform_data sx150x_data[] __initdata = {
70 [SX150X_CORE] = {
71 .gpio_base = GPIO_CORE_EXPANDER_BASE,
72 .oscio_is_gpo = false,
73 .io_pullup_ena = 0,
pankaj kumarc5c01392011-08-12 13:44:05 +053074 .io_pulldn_ena = 0x02,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070075 .io_open_drain_ena = 0xfef8,
76 .irq_summary = -1,
77 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070078};
79#endif
80
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070081
Santosh Sajjan6822c682011-07-26 10:49:36 +053082static struct platform_device msm_wlan_ar6000_pm_device = {
83 .name = "wlan_ar6000_pm_dev",
84 .id = -1,
85};
86
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070087#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
88static struct i2c_board_info core_exp_i2c_info[] __initdata = {
89 {
90 I2C_BOARD_INFO("sx1509q", 0x3e),
91 },
92};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070093
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070094static void __init register_i2c_devices(void)
95{
Trilok Soni3d0f6c52011-07-26 16:06:58 +053096 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070097 sx150x_data[SX150X_CORE].io_open_drain_ena = 0xe0f0;
98
99 core_exp_i2c_info[0].platform_data =
100 &sx150x_data[SX150X_CORE];
101
102 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
103 core_exp_i2c_info,
104 ARRAY_SIZE(core_exp_i2c_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700105}
106#endif
107
108static struct msm_gpio qup_i2c_gpios_io[] = {
109 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
110 "qup_scl" },
111 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
112 "qup_sda" },
113 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
114 "qup_scl" },
115 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
116 "qup_sda" },
117};
118
119static struct msm_gpio qup_i2c_gpios_hw[] = {
120 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
121 "qup_scl" },
122 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
123 "qup_sda" },
124 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
125 "qup_scl" },
126 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
127 "qup_sda" },
128};
129
130static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
131{
132 int rc;
133
134 if (adap_id < 0 || adap_id > 1)
135 return;
136
137 /* Each adapter gets 2 lines from the table */
138 if (config_type)
139 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
140 else
141 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
142 if (rc < 0)
143 pr_err("QUP GPIO request/enable failed: %d\n", rc);
144}
145
146static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
147 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700148 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
149};
150
151static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
152 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700153 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
154};
155
Taniya Das9d187142011-12-02 15:53:25 +0530156static struct msm_i2c_platform_data msm8625_gsbi0_qup_i2c_pdata = {
157 .clk_freq = 100000,
158};
159
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700160#ifdef CONFIG_ARCH_MSM7X27A
Neti Ravi Kumar061726e2011-12-08 15:14:57 +0530161#define MSM_PMEM_MDP_SIZE 0x2300000
162#define MSM7x25A_MSM_PMEM_MDP_SIZE 0x1500000
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530163
Mahesh Lankaa2f6df12012-01-05 16:54:40 +0530164#define MSM_PMEM_ADSP_SIZE 0x1100000
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530165#define MSM7x25A_MSM_PMEM_ADSP_SIZE 0xB91000
166
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700167#endif
168
169static struct android_usb_platform_data android_usb_pdata = {
170 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
171};
172
173static struct platform_device android_usb_device = {
174 .name = "android_usb",
175 .id = -1,
176 .dev = {
177 .platform_data = &android_usb_pdata,
178 },
179};
180
181#ifdef CONFIG_USB_EHCI_MSM_72K
182static void msm_hsusb_vbus_power(unsigned phy_info, int on)
183{
184 int rc = 0;
185 unsigned gpio;
186
187 gpio = GPIO_HOST_VBUS_EN;
188
189 rc = gpio_request(gpio, "i2c_host_vbus_en");
190 if (rc < 0) {
191 pr_err("failed to request %d GPIO\n", gpio);
192 return;
193 }
194 gpio_direction_output(gpio, !!on);
195 gpio_set_value_cansleep(gpio, !!on);
196 gpio_free(gpio);
197}
198
199static struct msm_usb_host_platform_data msm_usb_host_pdata = {
200 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
201};
202
203static void __init msm7x2x_init_host(void)
204{
205 msm_add_host(0, &msm_usb_host_pdata);
206}
207#endif
208
209#ifdef CONFIG_USB_MSM_OTG_72K
210static int hsusb_rpc_connect(int connect)
211{
212 if (connect)
213 return msm_hsusb_rpc_connect();
214 else
215 return msm_hsusb_rpc_close();
216}
217
Justin Paupored98328e2011-08-19 13:48:31 -0700218static struct regulator *reg_hsusb;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700219static int msm_hsusb_ldo_init(int init)
220{
Justin Paupored98328e2011-08-19 13:48:31 -0700221 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700222
Justin Paupored98328e2011-08-19 13:48:31 -0700223 if (init) {
224 reg_hsusb = regulator_get(NULL, "usb");
225 if (IS_ERR(reg_hsusb)) {
226 rc = PTR_ERR(reg_hsusb);
227 pr_err("%s: could not get regulator: %d\n",
228 __func__, rc);
229 goto out;
230 }
231
232 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
233 if (rc) {
234 pr_err("%s: could not set voltage: %d\n",
235 __func__, rc);
236 goto reg_free;
237 }
238
239 return 0;
240 }
241 /* else fall through */
242reg_free:
243 regulator_put(reg_hsusb);
244out:
245 reg_hsusb = NULL;
246 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700247}
248
249static int msm_hsusb_ldo_enable(int enable)
250{
251 static int ldo_status;
252
Justin Paupored98328e2011-08-19 13:48:31 -0700253 if (IS_ERR_OR_NULL(reg_hsusb))
254 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700255
256 if (ldo_status == enable)
257 return 0;
258
259 ldo_status = enable;
260
Justin Paupored98328e2011-08-19 13:48:31 -0700261 return enable ?
262 regulator_enable(reg_hsusb) :
263 regulator_disable(reg_hsusb);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700264}
265
266#ifndef CONFIG_USB_EHCI_MSM_72K
267static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
268{
269 int ret = 0;
270
271 if (init)
272 ret = msm_pm_app_rpc_init(callback);
273 else
274 msm_pm_app_rpc_deinit(callback);
275
276 return ret;
277}
278#endif
279
280static struct msm_otg_platform_data msm_otg_pdata = {
281#ifndef CONFIG_USB_EHCI_MSM_72K
282 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
283#else
284 .vbus_power = msm_hsusb_vbus_power,
285#endif
286 .rpc_connect = hsusb_rpc_connect,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700287 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
288 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
289 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
290 .se1_gating = SE1_GATING_DISABLE,
291 .ldo_init = msm_hsusb_ldo_init,
292 .ldo_enable = msm_hsusb_ldo_enable,
293 .chg_init = hsusb_chg_init,
294 .chg_connected = hsusb_chg_connected,
295 .chg_vbus_draw = hsusb_chg_vbus_draw,
296};
297#endif
298
299static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
300 .is_phy_status_timer_on = 1,
301};
302
303static struct resource smc91x_resources[] = {
304 [0] = {
305 .start = 0x90000300,
306 .end = 0x900003ff,
307 .flags = IORESOURCE_MEM,
308 },
309 [1] = {
310 .start = MSM_GPIO_TO_INT(4),
311 .end = MSM_GPIO_TO_INT(4),
312 .flags = IORESOURCE_IRQ,
313 },
314};
315
316static struct platform_device smc91x_device = {
317 .name = "smc91x",
318 .id = 0,
319 .num_resources = ARRAY_SIZE(smc91x_resources),
320 .resource = smc91x_resources,
321};
322
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700323#ifdef CONFIG_SERIAL_MSM_HS
324static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
325 .inject_rx_on_wakeup = 1,
326 .rx_to_inject = 0xFD,
327};
328#endif
329static struct msm_pm_platform_data msm7x27a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +0530330 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700331 .idle_supported = 1,
332 .suspend_supported = 1,
333 .idle_enabled = 1,
334 .suspend_enabled = 1,
335 .latency = 16000,
336 .residency = 20000,
337 },
Murali Nalajalab10363d2012-01-12 16:29:01 +0530338 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700339 .idle_supported = 1,
340 .suspend_supported = 1,
341 .idle_enabled = 1,
342 .suspend_enabled = 1,
343 .latency = 12000,
344 .residency = 20000,
345 },
Murali Nalajalab10363d2012-01-12 16:29:01 +0530346 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700347 .idle_supported = 1,
348 .suspend_supported = 1,
349 .idle_enabled = 0,
350 .suspend_enabled = 1,
351 .latency = 2000,
352 .residency = 0,
353 },
Murali Nalajalab10363d2012-01-12 16:29:01 +0530354 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700355 .idle_supported = 1,
356 .suspend_supported = 1,
357 .idle_enabled = 1,
358 .suspend_enabled = 1,
359 .latency = 2,
360 .residency = 0,
361 },
362};
363
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600364static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +0530365 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
366 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600367};
368
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700369static struct android_pmem_platform_data android_pmem_adsp_pdata = {
370 .name = "pmem_adsp",
371 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
Mahesh Lankac6af7eb2011-08-02 18:00:35 +0530372 .cached = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700373 .memory_type = MEMTYPE_EBI1,
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800374 .request_region = request_fmem_c_region,
375 .release_region = release_fmem_c_region,
376 .reusable = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700377};
378
379static struct platform_device android_pmem_adsp_device = {
380 .name = "android_pmem",
381 .id = 1,
382 .dev = { .platform_data = &android_pmem_adsp_pdata },
383};
384
385static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
386static int __init pmem_mdp_size_setup(char *p)
387{
388 pmem_mdp_size = memparse(p, NULL);
389 return 0;
390}
391
392early_param("pmem_mdp_size", pmem_mdp_size_setup);
393
394static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
395static int __init pmem_adsp_size_setup(char *p)
396{
397 pmem_adsp_size = memparse(p, NULL);
398 return 0;
399}
400
401early_param("pmem_adsp_size", pmem_adsp_size_setup);
402
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700403#define SND(desc, num) { .name = #desc, .id = num }
404static struct snd_endpoint snd_endpoints_list[] = {
405 SND(HANDSET, 0),
406 SND(MONO_HEADSET, 2),
407 SND(HEADSET, 3),
408 SND(SPEAKER, 6),
409 SND(TTY_HEADSET, 8),
410 SND(TTY_VCO, 9),
411 SND(TTY_HCO, 10),
412 SND(BT, 12),
413 SND(IN_S_SADC_OUT_HANDSET, 16),
414 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
415 SND(FM_DIGITAL_STEREO_HEADSET, 26),
416 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
417 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
Shashi Kumar64e07602011-10-11 13:18:57 +0530418 SND(STEREO_HEADSET_AND_SPEAKER, 31),
Sidipotu Ashokab34ca42011-07-22 16:34:20 +0530419 SND(CURRENT, 0x7FFFFFFE),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700420 SND(FM_ANALOG_STEREO_HEADSET, 35),
421 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
422};
423#undef SND
424
425static struct msm_snd_endpoints msm_device_snd_endpoints = {
426 .endpoints = snd_endpoints_list,
427 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
428};
429
430static struct platform_device msm_device_snd = {
431 .name = "msm_snd",
432 .id = -1,
433 .dev = {
434 .platform_data = &msm_device_snd_endpoints
435 },
436};
437
438#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
439 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
440 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
441 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
442 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
443 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
444#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
445 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
446 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
447 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
448 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
449 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
450#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
451 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
452 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
453 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
454 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
455 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
456#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
457 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
458 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
459 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
460 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
461 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
462#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
463
464static unsigned int dec_concurrency_table[] = {
465 /* Audio LP */
466 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
467 0, 0, 0,
468
469 /* Concurrency 1 */
470 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
471 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
472 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
473 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
474 (DEC4_FORMAT),
475
476 /* Concurrency 2 */
477 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
478 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
479 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
480 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
481 (DEC4_FORMAT),
482
483 /* Concurrency 3 */
484 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
485 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
486 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
487 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
488 (DEC4_FORMAT),
489
490 /* Concurrency 4 */
491 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
492 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
493 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
494 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
495 (DEC4_FORMAT),
496
497 /* Concurrency 5 */
498 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
499 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
500 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
501 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
502 (DEC4_FORMAT),
503
504 /* Concurrency 6 */
505 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
506 0, 0, 0, 0,
507
508 /* Concurrency 7 */
509 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
510 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
511 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
512 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
513 (DEC4_FORMAT),
514};
515
516#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
517 .module_queueid = queueid, .module_decid = decid, \
518 .nr_codec_support = nr_codec}
519
520static struct msm_adspdec_info dec_info_list[] = {
521 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
522 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
523 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
524 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
525 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
526};
527
528static struct msm_adspdec_database msm_device_adspdec_database = {
529 .num_dec = ARRAY_SIZE(dec_info_list),
530 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
531 ARRAY_SIZE(dec_info_list)),
532 .dec_concurrency_table = dec_concurrency_table,
533 .dec_info_list = dec_info_list,
534};
535
536static struct platform_device msm_device_adspdec = {
537 .name = "msm_adspdec",
538 .id = -1,
539 .dev = {
540 .platform_data = &msm_device_adspdec_database
541 },
542};
543
544static struct android_pmem_platform_data android_pmem_audio_pdata = {
545 .name = "pmem_audio",
546 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
547 .cached = 0,
548 .memory_type = MEMTYPE_EBI1,
549};
550
551static struct platform_device android_pmem_audio_device = {
552 .name = "android_pmem",
553 .id = 2,
554 .dev = { .platform_data = &android_pmem_audio_pdata },
555};
556
557static struct android_pmem_platform_data android_pmem_pdata = {
558 .name = "pmem",
559 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
560 .cached = 1,
561 .memory_type = MEMTYPE_EBI1,
562};
563static struct platform_device android_pmem_device = {
564 .name = "android_pmem",
565 .id = 0,
566 .dev = { .platform_data = &android_pmem_pdata },
567};
568
569static u32 msm_calculate_batt_capacity(u32 current_voltage);
570
571static struct msm_psy_batt_pdata msm_psy_batt_data = {
572 .voltage_min_design = 2800,
573 .voltage_max_design = 4300,
574 .avail_chg_sources = AC_CHG | USB_CHG ,
575 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
576 .calculate_capacity = &msm_calculate_batt_capacity,
577};
578
579static u32 msm_calculate_batt_capacity(u32 current_voltage)
580{
581 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
582 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
583
584 return (current_voltage - low_voltage) * 100
585 / (high_voltage - low_voltage);
586}
587
588static struct platform_device msm_batt_device = {
589 .name = "msm-battery",
590 .id = -1,
591 .dev.platform_data = &msm_psy_batt_data,
592};
593
594static struct smsc911x_platform_config smsc911x_config = {
595 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
596 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
597 .flags = SMSC911X_USE_16BIT,
598};
599
600static struct resource smsc911x_resources[] = {
601 [0] = {
602 .start = 0x90000000,
603 .end = 0x90007fff,
604 .flags = IORESOURCE_MEM,
605 },
606 [1] = {
607 .start = MSM_GPIO_TO_INT(48),
608 .end = MSM_GPIO_TO_INT(48),
609 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
610 },
611};
612
613static struct platform_device smsc911x_device = {
614 .name = "smsc911x",
615 .id = 0,
616 .num_resources = ARRAY_SIZE(smsc911x_resources),
617 .resource = smsc911x_resources,
618 .dev = {
619 .platform_data = &smsc911x_config,
620 },
621};
622
623static struct msm_gpio smsc911x_gpios[] = {
624 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
625 "smsc911x_irq" },
626 { GPIO_CFG(49, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
627 "eth_fifo_sel" },
628};
629
630#define ETH_FIFO_SEL_GPIO 49
631static void msm7x27a_cfg_smsc911x(void)
632{
633 int res;
634
635 res = msm_gpios_request_enable(smsc911x_gpios,
636 ARRAY_SIZE(smsc911x_gpios));
637 if (res) {
638 pr_err("%s: unable to enable gpios for SMSC911x\n", __func__);
639 return;
640 }
641
642 /* ETH_FIFO_SEL */
643 res = gpio_direction_output(ETH_FIFO_SEL_GPIO, 0);
644 if (res) {
645 pr_err("%s: unable to get direction for gpio %d\n", __func__,
646 ETH_FIFO_SEL_GPIO);
647 msm_gpios_disable_free(smsc911x_gpios,
648 ARRAY_SIZE(smsc911x_gpios));
649 return;
650 }
651 gpio_set_value(ETH_FIFO_SEL_GPIO, 0);
652}
653
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700654#if defined(CONFIG_SERIAL_MSM_HSL_CONSOLE) \
655 && defined(CONFIG_MSM_SHARED_GPIO_FOR_UART2DM)
656static struct msm_gpio uart2dm_gpios[] = {
657 {GPIO_CFG(19, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
658 "uart2dm_rfr_n" },
659 {GPIO_CFG(20, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
660 "uart2dm_cts_n" },
661 {GPIO_CFG(21, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
662 "uart2dm_rx" },
663 {GPIO_CFG(108, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
664 "uart2dm_tx" },
665};
666
667static void msm7x27a_cfg_uart2dm_serial(void)
668{
669 int ret;
670 ret = msm_gpios_request_enable(uart2dm_gpios,
671 ARRAY_SIZE(uart2dm_gpios));
672 if (ret)
673 pr_err("%s: unable to enable gpios for uart2dm\n", __func__);
674}
675#else
676static void msm7x27a_cfg_uart2dm_serial(void) { }
677#endif
678
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800679struct fmem_platform_data fmem_pdata;
680
681struct platform_device fmem_device = {
682 .name = "fmem",
683 .id = -1,
684 .dev = { .platform_data = &fmem_pdata },
685};
686
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700687static struct platform_device *rumi_sim_devices[] __initdata = {
688 &msm_device_dmov,
689 &msm_device_smd,
690 &smc91x_device,
691 &msm_device_uart1,
692 &msm_device_nand,
693 &msm_device_uart_dm1,
694 &msm_gsbi0_qup_i2c_device,
695 &msm_gsbi1_qup_i2c_device,
696};
697
Taniya Das43bcdd62011-12-02 17:33:27 +0530698static struct platform_device *msm8625_rumi3_devices[] __initdata = {
699 &msm8625_device_dmov,
700 &msm8625_device_uart1,
Taniya Das9d187142011-12-02 15:53:25 +0530701 &msm8625_device_qup_i2c_gsbi0,
Taniya Das43bcdd62011-12-02 17:33:27 +0530702};
703
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700704static struct platform_device *surf_ffa_devices[] __initdata = {
705 &msm_device_dmov,
706 &msm_device_smd,
707 &msm_device_uart1,
708 &msm_device_uart_dm1,
709 &msm_device_uart_dm2,
710 &msm_device_nand,
711 &msm_gsbi0_qup_i2c_device,
712 &msm_gsbi1_qup_i2c_device,
713 &msm_device_otg,
714 &msm_device_gadget_peripheral,
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800715 &fmem_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700716 &android_usb_device,
717 &android_pmem_device,
718 &android_pmem_adsp_device,
719 &android_pmem_audio_device,
720 &msm_device_snd,
721 &msm_device_adspdec,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700722 &msm_batt_device,
723 &smsc911x_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700724 &msm_kgsl_3d0,
725#ifdef CONFIG_BT
726 &msm_bt_power_device,
727#endif
Manish Dewangan3a260992011-06-24 18:01:34 +0530728 &asoc_msm_pcm,
729 &asoc_msm_dai0,
730 &asoc_msm_dai1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700731};
732
733static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
734static int __init pmem_kernel_ebi1_size_setup(char *p)
735{
736 pmem_kernel_ebi1_size = memparse(p, NULL);
737 return 0;
738}
739early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
740
741static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
742static int __init pmem_audio_size_setup(char *p)
743{
744 pmem_audio_size = memparse(p, NULL);
745 return 0;
746}
747early_param("pmem_audio_size", pmem_audio_size_setup);
748
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700749static struct memtype_reserve msm7x27a_reserve_table[] __initdata = {
750 [MEMTYPE_SMI] = {
751 },
752 [MEMTYPE_EBI0] = {
753 .flags = MEMTYPE_FLAGS_1M_ALIGN,
754 },
755 [MEMTYPE_EBI1] = {
756 .flags = MEMTYPE_FLAGS_1M_ALIGN,
757 },
758};
759
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800760#ifdef CONFIG_ANDROID_PMEM
761static struct android_pmem_platform_data *pmem_pdata_array[] __initdata = {
762 &android_pmem_adsp_pdata,
763 &android_pmem_audio_pdata,
764 &android_pmem_pdata,
765};
766#endif
767
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700768static void __init size_pmem_devices(void)
769{
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800770#ifdef CONFIG_ANDROID_PMEM
771 unsigned int i;
772 unsigned int reusable_count = 0;
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530773
774 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
775 pmem_mdp_size = MSM7x25A_MSM_PMEM_MDP_SIZE;
776 pmem_adsp_size = MSM7x25A_MSM_PMEM_ADSP_SIZE;
777 } else {
778 pmem_mdp_size = MSM_PMEM_MDP_SIZE;
779 pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
780 }
781
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700782 android_pmem_adsp_pdata.size = pmem_adsp_size;
783 android_pmem_pdata.size = pmem_mdp_size;
784 android_pmem_audio_pdata.size = pmem_audio_size;
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800785
786 fmem_pdata.size = 0;
787
788 /* Find pmem devices that should use FMEM (reusable) memory.
789 */
790 for (i = 0; i < ARRAY_SIZE(pmem_pdata_array); ++i) {
791 struct android_pmem_platform_data *pdata = pmem_pdata_array[i];
792
793 if (!reusable_count && pdata->reusable)
794 fmem_pdata.size += pdata->size;
795
796 reusable_count += (pdata->reusable) ? 1 : 0;
797
798 if (pdata->reusable && reusable_count > 1) {
799 pr_err("%s: Too many PMEM devices specified as reusable. PMEM device %s was not configured as reusable.\n",
800 __func__, pdata->name);
801 pdata->reusable = 0;
802 }
803 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700804#endif
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800805
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700806}
807
808static void __init reserve_memory_for(struct android_pmem_platform_data *p)
809{
810 msm7x27a_reserve_table[p->memory_type].size += p->size;
811}
812
813static void __init reserve_pmem_memory(void)
814{
815#ifdef CONFIG_ANDROID_PMEM
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800816 unsigned int i;
817 for (i = 0; i < ARRAY_SIZE(pmem_pdata_array); ++i) {
818 if (!pmem_pdata_array[i]->reusable)
819 reserve_memory_for(pmem_pdata_array[i]);
820 }
821
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700822 msm7x27a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
823#endif
824}
825
826static void __init msm7x27a_calculate_reserve_sizes(void)
827{
828 size_pmem_devices();
829 reserve_pmem_memory();
830}
831
832static int msm7x27a_paddr_to_memtype(unsigned int paddr)
833{
834 return MEMTYPE_EBI1;
835}
836
837static struct reserve_info msm7x27a_reserve_info __initdata = {
838 .memtype_reserve_table = msm7x27a_reserve_table,
839 .calculate_reserve_sizes = msm7x27a_calculate_reserve_sizes,
840 .paddr_to_memtype = msm7x27a_paddr_to_memtype,
841};
842
843static void __init msm7x27a_reserve(void)
844{
845 reserve_info = &msm7x27a_reserve_info;
846 msm_reserve();
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800847 fmem_pdata.phys = reserve_memory_for_fmem(fmem_pdata.size);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700848}
849
Taniya Das2b16d1d2011-12-02 14:44:19 +0530850static void __init msm8625_reserve(void)
851{
852 memblock_remove(MSM8625_SECONDARY_PHYS, SZ_8);
853}
854
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700855static void __init msm_device_i2c_init(void)
856{
Taniya Das9d187142011-12-02 15:53:25 +0530857 if (machine_is_msm8625_rumi3()) {
858 msm8625_device_qup_i2c_gsbi0.dev.platform_data =
859 &msm8625_gsbi0_qup_i2c_pdata;
860 return;
861 }
862
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700863 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
864 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
865}
866
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700867#define MSM_EBI2_PHYS 0xa0d00000
868#define MSM_EBI2_XMEM_CS2_CFG1 0xa0d10030
869
870static void __init msm7x27a_init_ebi2(void)
871{
872 uint32_t ebi2_cfg;
873 void __iomem *ebi2_cfg_ptr;
874
875 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_PHYS, sizeof(uint32_t));
876 if (!ebi2_cfg_ptr)
877 return;
878
879 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530880 if (machine_is_msm7x27a_rumi3() || machine_is_msm7x27a_surf() ||
881 machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700882 ebi2_cfg |= (1 << 4); /* CS2 */
883
884 writel(ebi2_cfg, ebi2_cfg_ptr);
885 iounmap(ebi2_cfg_ptr);
886
887 /* Enable A/D MUX[bit 31] from EBI2_XMEM_CS2_CFG1 */
888 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_XMEM_CS2_CFG1,
889 sizeof(uint32_t));
890 if (!ebi2_cfg_ptr)
891 return;
892
893 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530894 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700895 ebi2_cfg |= (1 << 31);
896
897 writel(ebi2_cfg, ebi2_cfg_ptr);
898 iounmap(ebi2_cfg_ptr);
899}
900
901#define ATMEL_TS_I2C_NAME "maXTouch"
Justin Paupored98328e2011-08-19 13:48:31 -0700902
903static struct regulator_bulk_data regs_atmel[] = {
904 { .supply = "ldo2", .min_uV = 2850000, .max_uV = 2850000 },
905 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
906};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700907
908#define ATMEL_TS_GPIO_IRQ 82
909
910static int atmel_ts_power_on(bool on)
911{
Justin Paupored98328e2011-08-19 13:48:31 -0700912 int rc = on ?
913 regulator_bulk_enable(ARRAY_SIZE(regs_atmel), regs_atmel) :
914 regulator_bulk_disable(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700915
Justin Paupored98328e2011-08-19 13:48:31 -0700916 if (rc)
917 pr_err("%s: could not %sable regulators: %d\n",
918 __func__, on ? "en" : "dis", rc);
919 else
920 msleep(50);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700921
Justin Paupored98328e2011-08-19 13:48:31 -0700922 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700923}
924
925static int atmel_ts_platform_init(struct i2c_client *client)
926{
927 int rc;
Justin Paupored98328e2011-08-19 13:48:31 -0700928 struct device *dev = &client->dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700929
Justin Paupored98328e2011-08-19 13:48:31 -0700930 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700931 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700932 dev_err(dev, "%s: could not get regulators: %d\n",
933 __func__, rc);
934 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700935 }
936
Justin Paupored98328e2011-08-19 13:48:31 -0700937 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700938 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700939 dev_err(dev, "%s: could not set voltages: %d\n",
940 __func__, rc);
941 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700942 }
943
944 rc = gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
945 GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
946 GPIO_CFG_8MA), GPIO_CFG_ENABLE);
947 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700948 dev_err(dev, "%s: gpio_tlmm_config for %d failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700949 __func__, ATMEL_TS_GPIO_IRQ);
Justin Paupored98328e2011-08-19 13:48:31 -0700950 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700951 }
952
953 /* configure touchscreen interrupt gpio */
954 rc = gpio_request(ATMEL_TS_GPIO_IRQ, "atmel_maxtouch_gpio");
955 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -0700956 dev_err(dev, "%s: unable to request gpio %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700957 __func__, ATMEL_TS_GPIO_IRQ);
958 goto ts_gpio_tlmm_unconfig;
959 }
960
961 rc = gpio_direction_input(ATMEL_TS_GPIO_IRQ);
962 if (rc < 0) {
Justin Paupored98328e2011-08-19 13:48:31 -0700963 dev_err(dev, "%s: unable to set the direction of gpio %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700964 __func__, ATMEL_TS_GPIO_IRQ);
965 goto free_ts_gpio;
966 }
967 return 0;
968
969free_ts_gpio:
970 gpio_free(ATMEL_TS_GPIO_IRQ);
971ts_gpio_tlmm_unconfig:
972 gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
973 GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
974 GPIO_CFG_2MA), GPIO_CFG_DISABLE);
Justin Paupored98328e2011-08-19 13:48:31 -0700975reg_free:
976 regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel);
977out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700978 return rc;
979}
980
981static int atmel_ts_platform_exit(struct i2c_client *client)
982{
983 gpio_free(ATMEL_TS_GPIO_IRQ);
984 gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
985 GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
986 GPIO_CFG_2MA), GPIO_CFG_DISABLE);
Justin Paupored98328e2011-08-19 13:48:31 -0700987 regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700988 return 0;
989}
990
991static u8 atmel_ts_read_chg(void)
992{
993 return gpio_get_value(ATMEL_TS_GPIO_IRQ);
994}
995
996static u8 atmel_ts_valid_interrupt(void)
997{
998 return !atmel_ts_read_chg();
999}
1000
1001#define ATMEL_X_OFFSET 13
1002#define ATMEL_Y_OFFSET 0
1003
Mohan Pallaka4e9a94e2011-11-23 16:34:21 +05301004static struct maxtouch_platform_data atmel_ts_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001005 .numtouch = 4,
1006 .init_platform_hw = atmel_ts_platform_init,
1007 .exit_platform_hw = atmel_ts_platform_exit,
1008 .power_on = atmel_ts_power_on,
1009 .display_res_x = 480,
1010 .display_res_y = 864,
1011 .min_x = ATMEL_X_OFFSET,
1012 .max_x = (505 - ATMEL_X_OFFSET),
1013 .min_y = ATMEL_Y_OFFSET,
1014 .max_y = (863 - ATMEL_Y_OFFSET),
1015 .valid_interrupt = atmel_ts_valid_interrupt,
1016 .read_chg = atmel_ts_read_chg,
1017};
1018
1019static struct i2c_board_info atmel_ts_i2c_info[] __initdata = {
1020 {
1021 I2C_BOARD_INFO(ATMEL_TS_I2C_NAME, 0x4a),
1022 .platform_data = &atmel_ts_pdata,
1023 .irq = MSM_GPIO_TO_INT(ATMEL_TS_GPIO_IRQ),
1024 },
1025};
1026
1027#define KP_INDEX(row, col) ((row)*ARRAY_SIZE(kp_col_gpios) + (col))
1028
1029static unsigned int kp_row_gpios[] = {31, 32, 33, 34, 35};
1030static unsigned int kp_col_gpios[] = {36, 37, 38, 39, 40};
1031
1032static const unsigned short keymap[ARRAY_SIZE(kp_col_gpios) *
1033 ARRAY_SIZE(kp_row_gpios)] = {
1034 [KP_INDEX(0, 0)] = KEY_7,
1035 [KP_INDEX(0, 1)] = KEY_DOWN,
1036 [KP_INDEX(0, 2)] = KEY_UP,
1037 [KP_INDEX(0, 3)] = KEY_RIGHT,
1038 [KP_INDEX(0, 4)] = KEY_ENTER,
1039
1040 [KP_INDEX(1, 0)] = KEY_LEFT,
1041 [KP_INDEX(1, 1)] = KEY_SEND,
1042 [KP_INDEX(1, 2)] = KEY_1,
1043 [KP_INDEX(1, 3)] = KEY_4,
1044 [KP_INDEX(1, 4)] = KEY_CLEAR,
1045
1046 [KP_INDEX(2, 0)] = KEY_6,
1047 [KP_INDEX(2, 1)] = KEY_5,
1048 [KP_INDEX(2, 2)] = KEY_8,
1049 [KP_INDEX(2, 3)] = KEY_3,
1050 [KP_INDEX(2, 4)] = KEY_NUMERIC_STAR,
1051
1052 [KP_INDEX(3, 0)] = KEY_9,
1053 [KP_INDEX(3, 1)] = KEY_NUMERIC_POUND,
1054 [KP_INDEX(3, 2)] = KEY_0,
1055 [KP_INDEX(3, 3)] = KEY_2,
1056 [KP_INDEX(3, 4)] = KEY_SLEEP,
1057
1058 [KP_INDEX(4, 0)] = KEY_BACK,
1059 [KP_INDEX(4, 1)] = KEY_HOME,
1060 [KP_INDEX(4, 2)] = KEY_MENU,
1061 [KP_INDEX(4, 3)] = KEY_VOLUMEUP,
1062 [KP_INDEX(4, 4)] = KEY_VOLUMEDOWN,
1063};
1064
1065/* SURF keypad platform device information */
1066static struct gpio_event_matrix_info kp_matrix_info = {
1067 .info.func = gpio_event_matrix_func,
1068 .keymap = keymap,
1069 .output_gpios = kp_row_gpios,
1070 .input_gpios = kp_col_gpios,
1071 .noutputs = ARRAY_SIZE(kp_row_gpios),
1072 .ninputs = ARRAY_SIZE(kp_col_gpios),
1073 .settle_time.tv_nsec = 40 * NSEC_PER_USEC,
1074 .poll_time.tv_nsec = 20 * NSEC_PER_MSEC,
1075 .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE |
1076 GPIOKPF_PRINT_UNMAPPED_KEYS,
1077};
1078
1079static struct gpio_event_info *kp_info[] = {
1080 &kp_matrix_info.info
1081};
1082
1083static struct gpio_event_platform_data kp_pdata = {
1084 .name = "7x27a_kp",
1085 .info = kp_info,
1086 .info_count = ARRAY_SIZE(kp_info)
1087};
1088
1089static struct platform_device kp_pdev = {
1090 .name = GPIO_EVENT_DEV_NAME,
1091 .id = -1,
1092 .dev = {
1093 .platform_data = &kp_pdata,
1094 },
1095};
1096
1097static struct msm_handset_platform_data hs_platform_data = {
1098 .hs_name = "7k_handset",
1099 .pwr_key_delay_ms = 500, /* 0 will disable end key */
1100};
1101
1102static struct platform_device hs_pdev = {
1103 .name = "msm-handset",
1104 .id = -1,
1105 .dev = {
1106 .platform_data = &hs_platform_data,
1107 },
1108};
1109
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001110static struct platform_device msm_proccomm_regulator_dev = {
1111 .name = PROCCOMM_REGULATOR_DEV_NAME,
1112 .id = -1,
1113 .dev = {
1114 .platform_data = &msm7x27a_proccomm_regulator_data
1115 }
1116};
1117
Trilok Soni16f61af2011-07-26 16:06:58 +05301118static void __init msm7627a_rumi3_init(void)
1119{
1120 msm7x27a_init_ebi2();
1121 platform_add_devices(rumi_sim_devices,
1122 ARRAY_SIZE(rumi_sim_devices));
1123}
1124
Taniya Das43bcdd62011-12-02 17:33:27 +05301125static void __init msm8625_rumi3_init(void)
1126{
1127 msm7x2x_misc_init();
Taniya Das9d187142011-12-02 15:53:25 +05301128 msm_device_i2c_init();
Taniya Das43bcdd62011-12-02 17:33:27 +05301129 platform_add_devices(msm8625_rumi3_devices,
1130 ARRAY_SIZE(msm8625_rumi3_devices));
1131}
1132
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001133#define LED_GPIO_PDM 96
1134#define UART1DM_RX_GPIO 45
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301135
1136#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
1137static int __init msm7x27a_init_ar6000pm(void)
1138{
Santosh Sajjan374d6592012-01-19 23:16:46 +05301139 msm_wlan_ar6000_pm_device.dev.platform_data = &ar600x_wlan_power;
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301140 return platform_device_register(&msm_wlan_ar6000_pm_device);
1141}
1142#else
1143static int __init msm7x27a_init_ar6000pm(void) { return 0; }
1144#endif
1145
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001146static void __init msm7x27a_init_regulators(void)
1147{
1148 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1149 if (rc)
1150 pr_err("%s: could not register regulator device: %d\n",
1151 __func__, rc);
1152}
1153
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001154static void __init msm7x2x_init(void)
1155{
Trilok Sonia416c492011-07-22 20:20:23 +05301156 msm7x2x_misc_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001157
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001158 /* Initialize regulators first so that other devices can use them */
1159 msm7x27a_init_regulators();
1160
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001161 /* Common functions for SURF/FFA/RUMI3 */
1162 msm_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001163 msm7x27a_init_ebi2();
1164 msm7x27a_cfg_uart2dm_serial();
1165#ifdef CONFIG_SERIAL_MSM_HS
1166 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
1167 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
1168#endif
1169
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001170#ifdef CONFIG_USB_MSM_OTG_72K
Trilok Soni16f61af2011-07-26 16:06:58 +05301171 msm_otg_pdata.swfi_latency =
1172 msm7x27a_pm_data
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001173 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
Trilok Soni16f61af2011-07-26 16:06:58 +05301174 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001175#endif
Trilok Soni16f61af2011-07-26 16:06:58 +05301176 msm_device_gadget_peripheral.dev.platform_data =
1177 &msm_gadget_pdata;
1178 msm7x27a_cfg_smsc911x();
1179 platform_add_devices(msm_footswitch_devices,
1180 msm_num_footswitch_devices);
1181 platform_add_devices(surf_ffa_devices,
1182 ARRAY_SIZE(surf_ffa_devices));
Sujith Reddy Thummaad7c9a82011-09-30 20:54:38 +05301183 /* Ensure ar6000pm device is registered before MMC/SDC */
1184 msm7x27a_init_ar6000pm();
1185#ifdef CONFIG_MMC_MSM
Chintan Pandyacf467fc2011-12-01 17:11:11 +05301186 msm7627a_init_mmc();
Sujith Reddy Thummaad7c9a82011-09-30 20:54:38 +05301187#endif
Trilok Soni16f61af2011-07-26 16:06:58 +05301188 msm_fb_add_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001189#ifdef CONFIG_USB_EHCI_MSM_72K
Trilok Soni16f61af2011-07-26 16:06:58 +05301190 msm7x2x_init_host();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001191#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001192
1193 msm_pm_set_platform_data(msm7x27a_pm_data,
1194 ARRAY_SIZE(msm7x27a_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06001195 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001196
1197#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
1198 register_i2c_devices();
1199#endif
1200#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Chintan Pandya13490c02011-12-20 13:03:36 +05301201 msm7627a_bt_power_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001202#endif
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301203 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001204 atmel_ts_pdata.min_x = 0;
1205 atmel_ts_pdata.max_x = 480;
1206 atmel_ts_pdata.min_y = 0;
1207 atmel_ts_pdata.max_y = 320;
1208 }
1209
1210 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
1211 atmel_ts_i2c_info,
1212 ARRAY_SIZE(atmel_ts_i2c_info));
1213
Pankaj Kumar5be2a3e2011-09-26 11:45:02 +05301214#if defined(CONFIG_MSM_CAMERA)
Chintan Pandya40762702011-12-06 13:47:06 +05301215 msm7627a_camera_init();
Pankaj Kumar5be2a3e2011-09-26 11:45:02 +05301216#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001217 platform_device_register(&kp_pdev);
1218 platform_device_register(&hs_pdev);
1219
1220 /* configure it as a pdm function*/
1221 if (gpio_tlmm_config(GPIO_CFG(LED_GPIO_PDM, 3,
1222 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
1223 GPIO_CFG_8MA), GPIO_CFG_ENABLE))
1224 pr_err("%s: gpio_tlmm_config for %d failed\n",
1225 __func__, LED_GPIO_PDM);
1226 else
1227 platform_device_register(&led_pdev);
1228
1229#ifdef CONFIG_MSM_RPC_VIBRATOR
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301230 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001231 msm_init_pmic_vibrator();
1232#endif
1233 /*7x25a kgsl initializations*/
1234 msm7x25a_kgsl_3d0_init();
1235}
1236
1237static void __init msm7x2x_init_early(void)
1238{
Chintan Pandya250c2e52012-01-19 17:15:49 +05301239 msm_msm7627a_allocate_memory_regions();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001240}
1241
1242MACHINE_START(MSM7X27A_RUMI3, "QCT MSM7x27a RUMI3")
1243 .boot_params = PHYS_OFFSET + 0x100,
1244 .map_io = msm_common_io_init,
1245 .reserve = msm7x27a_reserve,
1246 .init_irq = msm_init_irq,
Trilok Soni16f61af2011-07-26 16:06:58 +05301247 .init_machine = msm7627a_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001248 .timer = &msm_timer,
1249 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301250 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001251MACHINE_END
1252MACHINE_START(MSM7X27A_SURF, "QCT MSM7x27a SURF")
1253 .boot_params = PHYS_OFFSET + 0x100,
1254 .map_io = msm_common_io_init,
1255 .reserve = msm7x27a_reserve,
1256 .init_irq = msm_init_irq,
1257 .init_machine = msm7x2x_init,
1258 .timer = &msm_timer,
1259 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301260 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001261MACHINE_END
1262MACHINE_START(MSM7X27A_FFA, "QCT MSM7x27a FFA")
1263 .boot_params = PHYS_OFFSET + 0x100,
1264 .map_io = msm_common_io_init,
1265 .reserve = msm7x27a_reserve,
1266 .init_irq = msm_init_irq,
1267 .init_machine = msm7x2x_init,
1268 .timer = &msm_timer,
1269 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301270 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001271MACHINE_END
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301272MACHINE_START(MSM7625A_SURF, "QCT MSM7625a SURF")
1273 .boot_params = PHYS_OFFSET + 0x100,
1274 .map_io = msm_common_io_init,
1275 .reserve = msm7x27a_reserve,
1276 .init_irq = msm_init_irq,
1277 .init_machine = msm7x2x_init,
1278 .timer = &msm_timer,
1279 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301280 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301281MACHINE_END
1282MACHINE_START(MSM7625A_FFA, "QCT MSM7625a FFA")
1283 .boot_params = PHYS_OFFSET + 0x100,
1284 .map_io = msm_common_io_init,
1285 .reserve = msm7x27a_reserve,
1286 .init_irq = msm_init_irq,
1287 .init_machine = msm7x2x_init,
1288 .timer = &msm_timer,
1289 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301290 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301291MACHINE_END
Taniya Das43bcdd62011-12-02 17:33:27 +05301292MACHINE_START(MSM8625_RUMI3, "QCT MSM8625 RUMI3")
1293 .boot_params = PHYS_OFFSET + 0x100,
1294 .map_io = msm8625_map_io,
Taniya Das2b16d1d2011-12-02 14:44:19 +05301295 .reserve = msm8625_reserve,
Taniya Das43bcdd62011-12-02 17:33:27 +05301296 .init_irq = msm8625_init_irq,
1297 .init_machine = msm8625_rumi3_init,
1298 .timer = &msm_timer,
1299 .handle_irq = gic_handle_irq,
1300MACHINE_END