blob: 218374d178bdd923c8df7e69ee95d1110a14e74b [file] [log] [blame]
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +05301/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302 *
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
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/gpio_event.h>
Pankaj Kumar6f841742011-10-10 15:52:14 +053016#include <linux/usb/android.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053017#include <linux/platform_device.h>
18#include <linux/io.h>
19#include <linux/gpio.h>
20#include <linux/mtd/nand.h>
21#include <linux/mtd/partitions.h>
22#include <linux/i2c.h>
23#include <linux/android_pmem.h>
24#include <linux/bootmem.h>
25#include <linux/mfd/marimba.h>
26#include <linux/power_supply.h>
Taniya Dasda408822011-09-06 12:54:06 +053027#include <linux/input/rmi_platformdata.h>
28#include <linux/input/rmi_i2c.h>
Mohan Pallaka4c5bb922011-11-23 15:54:51 +053029#include <linux/i2c/atmel_mxt_ts.h>
Pankaj Kumar3cec0582011-11-18 11:13:29 +053030#include <linux/regulator/consumer.h>
Chintan Pandyaf4ad4002012-02-28 19:49:03 +053031#include <linux/memblock.h>
Mohan Pallaka5afe9852012-01-12 23:12:06 +053032#include <linux/input/ft5x06_ts.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053033#include <asm/mach/mmc.h>
34#include <asm/mach-types.h>
35#include <asm/mach/arch.h>
Chintan Pandyaf4ad4002012-02-28 19:49:03 +053036#include <asm/hardware/gic.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053037#include <mach/board.h>
38#include <mach/msm_iomap.h>
39#include <mach/msm_hsusb.h>
40#include <mach/rpc_hsusb.h>
41#include <mach/rpc_pmapp.h>
42#include <mach/usbdiag.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053043#include <mach/msm_memtypes.h>
44#include <mach/msm_serial_hs.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053045#include <mach/pmic.h>
46#include <mach/socinfo.h>
47#include <mach/vreg.h>
48#include <mach/rpc_pmapp.h>
49#include <mach/msm_battery.h>
50#include <mach/rpc_server_handset.h>
51#include <mach/socinfo.h>
Pankaj Kumar27c02642011-09-22 15:55:55 +053052#include "board-msm7x27a-regulator.h"
Taniya Dasc98bfbc2011-08-23 09:58:55 +053053#include "devices.h"
54#include "devices-msm7x2xa.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080055#include "pm.h"
Taniya Dasc98bfbc2011-08-23 09:58:55 +053056#include "timer.h"
Murali Nalajalaa1827842011-11-13 14:12:39 +053057#include "pm-boot.h"
Pankaj Kumar3cec0582011-11-18 11:13:29 +053058#include "board-msm7x27a-regulator.h"
Chintan Pandyacf467fc2011-12-01 17:11:11 +053059#include "board-msm7627a.h"
Taniya Dasc98bfbc2011-08-23 09:58:55 +053060
61#define PMEM_KERNEL_EBI1_SIZE 0x3A000
62#define MSM_PMEM_AUDIO_SIZE 0x5B000
Taniya Dasc98bfbc2011-08-23 09:58:55 +053063#define BAHAMA_SLAVE_ID_FM_REG 0x02
64#define FM_GPIO 83
Rahul Kashyap8b4a7862011-12-13 18:40:54 +053065#define BT_PCM_BCLK_MODE 0x88
66#define BT_PCM_DIN_MODE 0x89
67#define BT_PCM_DOUT_MODE 0x8A
68#define BT_PCM_SYNC_MODE 0x8B
69#define FM_I2S_SD_MODE 0x8E
70#define FM_I2S_WS_MODE 0x8F
71#define FM_I2S_SCK_MODE 0x90
72#define I2C_PIN_CTL 0x15
73#define I2C_NORMAL 0x40
Taniya Dasc98bfbc2011-08-23 09:58:55 +053074
Taniya Dasc98bfbc2011-08-23 09:58:55 +053075static struct platform_device msm_wlan_ar6000_pm_device = {
76 .name = "wlan_ar6000_pm_dev",
77 .id = -1,
78};
79
Taniya Dasc98bfbc2011-08-23 09:58:55 +053080static struct msm_gpio qup_i2c_gpios_io[] = {
81 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
82 "qup_scl" },
83 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
84 "qup_sda" },
85 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
86 "qup_scl" },
87 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
88 "qup_sda" },
89};
90
91static struct msm_gpio qup_i2c_gpios_hw[] = {
92 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
93 "qup_scl" },
94 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
95 "qup_sda" },
96 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
97 "qup_scl" },
98 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
99 "qup_sda" },
100};
101
102static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
103{
104 int rc;
105
106 if (adap_id < 0 || adap_id > 1)
107 return;
108
109 /* Each adapter gets 2 lines from the table */
110 if (config_type)
111 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
112 else
113 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
114 if (rc < 0)
115 pr_err("QUP GPIO request/enable failed: %d\n", rc);
116}
117
118static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
119 .clk_freq = 100000,
120 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
121};
122
123static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
124 .clk_freq = 100000,
125 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
126};
127
128#ifdef CONFIG_ARCH_MSM7X27A
129#define MSM_PMEM_MDP_SIZE 0x1DD1000
Mahesh Lankac054d352012-02-29 16:11:51 +0530130#define MSM_PMEM_ADSP_SIZE 0x1100000
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530131#endif
132
Taniya Dasda408822011-09-06 12:54:06 +0530133#if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) || \
134defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C_MODULE)
135
136#ifndef CLEARPAD3000_ATTEN_GPIO
137#define CLEARPAD3000_ATTEN_GPIO (48)
138#endif
139
140#ifndef CLEARPAD3000_RESET_GPIO
141#define CLEARPAD3000_RESET_GPIO (26)
142#endif
143
144static int synaptics_touchpad_setup(void);
145
146static struct msm_gpio clearpad3000_cfg_data[] = {
147 {GPIO_CFG(CLEARPAD3000_ATTEN_GPIO, 0, GPIO_CFG_INPUT,
148 GPIO_CFG_NO_PULL, GPIO_CFG_6MA), "rmi4_attn"},
149 {GPIO_CFG(CLEARPAD3000_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
150 GPIO_CFG_PULL_DOWN, GPIO_CFG_8MA), "rmi4_reset"},
151};
152
153static struct rmi_XY_pair rmi_offset = {.x = 0, .y = 0};
154static struct rmi_range rmi_clipx = {.min = 48, .max = 980};
155static struct rmi_range rmi_clipy = {.min = 7, .max = 1647};
156static struct rmi_f11_functiondata synaptics_f11_data = {
157 .swap_axes = false,
158 .flipX = false,
159 .flipY = false,
160 .offset = &rmi_offset,
161 .button_height = 113,
162 .clipX = &rmi_clipx,
163 .clipY = &rmi_clipy,
164};
165
166#define MAX_LEN 100
167
168static ssize_t clearpad3000_virtual_keys_register(struct kobject *kobj,
169 struct kobj_attribute *attr, char *buf)
170{
171 char *virtual_keys = __stringify(EV_KEY) ":" __stringify(KEY_MENU) \
172 ":60:830:120:60" ":" __stringify(EV_KEY) \
173 ":" __stringify(KEY_HOME) ":180:830:120:60" \
174 ":" __stringify(EV_KEY) ":" \
175 __stringify(KEY_SEARCH) ":300:830:120:60" \
176 ":" __stringify(EV_KEY) ":" \
177 __stringify(KEY_BACK) ":420:830:120:60" "\n";
178
179 return snprintf(buf, strnlen(virtual_keys, MAX_LEN) + 1 , "%s",
180 virtual_keys);
181}
182
183static struct kobj_attribute clearpad3000_virtual_keys_attr = {
184 .attr = {
185 .name = "virtualkeys.sensor00fn11",
186 .mode = S_IRUGO,
187 },
188 .show = &clearpad3000_virtual_keys_register,
189};
190
191static struct attribute *virtual_key_properties_attrs[] = {
192 &clearpad3000_virtual_keys_attr.attr,
193 NULL
194};
195
196static struct attribute_group virtual_key_properties_attr_group = {
197 .attrs = virtual_key_properties_attrs,
198};
199
200struct kobject *virtual_key_properties_kobj;
201
202static struct rmi_functiondata synaptics_functiondata[] = {
203 {
204 .function_index = RMI_F11_INDEX,
205 .data = &synaptics_f11_data,
206 },
207};
208
209static struct rmi_functiondata_list synaptics_perfunctiondata = {
210 .count = ARRAY_SIZE(synaptics_functiondata),
211 .functiondata = synaptics_functiondata,
212};
213
214static struct rmi_sensordata synaptics_sensordata = {
215 .perfunctiondata = &synaptics_perfunctiondata,
216 .rmi_sensor_setup = synaptics_touchpad_setup,
217};
218
219static struct rmi_i2c_platformdata synaptics_platformdata = {
220 .i2c_address = 0x2c,
221 .irq_type = IORESOURCE_IRQ_LOWLEVEL,
222 .sensordata = &synaptics_sensordata,
223};
224
225static struct i2c_board_info synaptic_i2c_clearpad3k[] = {
226 {
227 I2C_BOARD_INFO("rmi4_ts", 0x2c),
228 .platform_data = &synaptics_platformdata,
229 },
230};
231
232static int synaptics_touchpad_setup(void)
233{
234 int retval = 0;
235
236 virtual_key_properties_kobj =
237 kobject_create_and_add("board_properties", NULL);
238 if (virtual_key_properties_kobj)
239 retval = sysfs_create_group(virtual_key_properties_kobj,
240 &virtual_key_properties_attr_group);
241 if (!virtual_key_properties_kobj || retval)
242 pr_err("failed to create ft5202 board_properties\n");
243
244 retval = msm_gpios_request_enable(clearpad3000_cfg_data,
245 sizeof(clearpad3000_cfg_data)/sizeof(struct msm_gpio));
246 if (retval) {
247 pr_err("%s:Failed to obtain touchpad GPIO %d. Code: %d.",
248 __func__, CLEARPAD3000_ATTEN_GPIO, retval);
249 retval = 0; /* ignore the err */
250 }
251 synaptics_platformdata.irq = gpio_to_irq(CLEARPAD3000_ATTEN_GPIO);
252
253 gpio_set_value(CLEARPAD3000_RESET_GPIO, 0);
254 usleep(10000);
255 gpio_set_value(CLEARPAD3000_RESET_GPIO, 1);
256 usleep(50000);
257
258 return retval;
259}
260#endif
261
Mohan Pallaka5afe9852012-01-12 23:12:06 +0530262#define FT5X06_IRQ_GPIO 48
263#define FT5X06_RESET_GPIO 26
264
265static ssize_t
266ft5x06_virtual_keys_register(struct kobject *kobj,
267 struct kobj_attribute *attr,
268 char *buf)
269{
270 return snprintf(buf, 200,
271 __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":40:510:80:60"
272 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":120:510:80:60"
273 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":200:510:80:60"
274 ":" __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":280:510:80:60"
275 "\n");
276}
277
278static struct kobj_attribute ft5x06_virtual_keys_attr = {
279 .attr = {
280 .name = "virtualkeys.ft5x06_ts",
281 .mode = S_IRUGO,
282 },
283 .show = &ft5x06_virtual_keys_register,
284};
285
286static struct attribute *ft5x06_virtual_key_properties_attrs[] = {
287 &ft5x06_virtual_keys_attr.attr,
288 NULL,
289};
290
291static struct attribute_group ft5x06_virtual_key_properties_attr_group = {
292 .attrs = ft5x06_virtual_key_properties_attrs,
293};
294
295struct kobject *ft5x06_virtual_key_properties_kobj;
296
297static struct ft5x06_ts_platform_data ft5x06_platformdata = {
298 .x_max = 320,
299 .y_max = 480,
300 .reset_gpio = FT5X06_RESET_GPIO,
301 .irq_gpio = FT5X06_IRQ_GPIO,
302 .irqflags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
303};
304
305static struct i2c_board_info ft5x06_device_info[] __initdata = {
306 {
307 I2C_BOARD_INFO("ft5x06_ts", 0x38),
308 .platform_data = &ft5x06_platformdata,
309 .irq = MSM_GPIO_TO_INT(FT5X06_IRQ_GPIO),
310 },
311};
312
313static void ft5x06_touchpad_setup(void)
314{
315 int rc;
316
317 rc = gpio_tlmm_config(GPIO_CFG(FT5X06_IRQ_GPIO, 0,
318 GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
319 GPIO_CFG_8MA), GPIO_CFG_ENABLE);
320 if (rc)
321 pr_err("%s: gpio_tlmm_config for %d failed\n",
322 __func__, FT5X06_IRQ_GPIO);
323
324 rc = gpio_tlmm_config(GPIO_CFG(FT5X06_RESET_GPIO, 0,
325 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
326 GPIO_CFG_8MA), GPIO_CFG_ENABLE);
327 if (rc)
328 pr_err("%s: gpio_tlmm_config for %d failed\n",
329 __func__, FT5X06_RESET_GPIO);
330
331 ft5x06_virtual_key_properties_kobj =
332 kobject_create_and_add("board_properties", NULL);
333
334 if (ft5x06_virtual_key_properties_kobj)
335 rc = sysfs_create_group(ft5x06_virtual_key_properties_kobj,
336 &ft5x06_virtual_key_properties_attr_group);
337
338 if (!ft5x06_virtual_key_properties_kobj || rc)
339 pr_err("%s: failed to create board_properties\n", __func__);
340
341 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
342 ft5x06_device_info,
343 ARRAY_SIZE(ft5x06_device_info));
344}
Taniya Dasda408822011-09-06 12:54:06 +0530345
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530346static struct android_usb_platform_data android_usb_pdata = {
Pankaj Kumar6f841742011-10-10 15:52:14 +0530347 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530348};
349
350static struct platform_device android_usb_device = {
351 .name = "android_usb",
352 .id = -1,
353 .dev = {
354 .platform_data = &android_usb_pdata,
355 },
356};
357
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530358#ifdef CONFIG_USB_EHCI_MSM_72K
359static void msm_hsusb_vbus_power(unsigned phy_info, int on)
360{
361 int rc = 0;
362 unsigned gpio;
363
Chintan Pandya40762702011-12-06 13:47:06 +0530364 gpio = QRD_GPIO_HOST_VBUS_EN;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530365
366 rc = gpio_request(gpio, "i2c_host_vbus_en");
367 if (rc < 0) {
368 pr_err("failed to request %d GPIO\n", gpio);
369 return;
370 }
371 gpio_direction_output(gpio, !!on);
372 gpio_set_value_cansleep(gpio, !!on);
373 gpio_free(gpio);
374}
375
376static struct msm_usb_host_platform_data msm_usb_host_pdata = {
377 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
378};
379
380static void __init msm7627a_init_host(void)
381{
382 msm_add_host(0, &msm_usb_host_pdata);
383}
384#endif
385
386#ifdef CONFIG_USB_MSM_OTG_72K
387static int hsusb_rpc_connect(int connect)
388{
389 if (connect)
390 return msm_hsusb_rpc_connect();
391 else
392 return msm_hsusb_rpc_close();
393}
394
Pankaj Kumar27c02642011-09-22 15:55:55 +0530395static struct regulator *reg_hsusb;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530396static int msm_hsusb_ldo_init(int init)
397{
Pankaj Kumar27c02642011-09-22 15:55:55 +0530398 int rc = 0;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530399
Pankaj Kumar27c02642011-09-22 15:55:55 +0530400 if (init) {
401 reg_hsusb = regulator_get(NULL, "usb");
402 if (IS_ERR(reg_hsusb)) {
403 rc = PTR_ERR(reg_hsusb);
404 pr_err("%s: could not get regulator: %d\n",
405 __func__, rc);
406 goto out;
407 }
408
409 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
410 if (rc) {
411 pr_err("%s: could not set voltage: %d\n",
412 __func__, rc);
413 goto reg_free;
414 }
415
416 return 0;
417 }
418 /* else fall through */
419reg_free:
420 regulator_put(reg_hsusb);
421out:
422 reg_hsusb = NULL;
423 return rc;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530424}
425
426static int msm_hsusb_ldo_enable(int enable)
427{
428 static int ldo_status;
429
Pankaj Kumar27c02642011-09-22 15:55:55 +0530430 if (IS_ERR_OR_NULL(reg_hsusb))
431 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530432
433 if (ldo_status == enable)
434 return 0;
435
436 ldo_status = enable;
437
Pankaj Kumar27c02642011-09-22 15:55:55 +0530438 return enable ?
439 regulator_enable(reg_hsusb) :
440 regulator_disable(reg_hsusb);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530441}
442
443#ifndef CONFIG_USB_EHCI_MSM_72K
444static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
445{
446 int ret = 0;
447
448 if (init)
449 ret = msm_pm_app_rpc_init(callback);
450 else
451 msm_pm_app_rpc_deinit(callback);
452
453 return ret;
454}
455#endif
456
457static struct msm_otg_platform_data msm_otg_pdata = {
458#ifndef CONFIG_USB_EHCI_MSM_72K
459 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
460#else
461 .vbus_power = msm_hsusb_vbus_power,
462#endif
463 .rpc_connect = hsusb_rpc_connect,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530464 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
465 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
466 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
467 .se1_gating = SE1_GATING_DISABLE,
468 .ldo_init = msm_hsusb_ldo_init,
469 .ldo_enable = msm_hsusb_ldo_enable,
470 .chg_init = hsusb_chg_init,
471 .chg_connected = hsusb_chg_connected,
472 .chg_vbus_draw = hsusb_chg_vbus_draw,
473};
474#endif
475
476static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
477 .is_phy_status_timer_on = 1,
478};
479
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530480#ifdef CONFIG_SERIAL_MSM_HS
481static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
482 .inject_rx_on_wakeup = 1,
483 .rx_to_inject = 0xFD,
484};
485#endif
486static struct msm_pm_platform_data msm7627a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
487 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
488 .idle_supported = 1,
489 .suspend_supported = 1,
490 .idle_enabled = 1,
491 .suspend_enabled = 1,
492 .latency = 16000,
493 .residency = 20000,
494 },
495 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
496 .idle_supported = 1,
497 .suspend_supported = 1,
498 .idle_enabled = 1,
499 .suspend_enabled = 1,
500 .latency = 12000,
501 .residency = 20000,
502 },
503 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
504 .idle_supported = 1,
505 .suspend_supported = 1,
506 .idle_enabled = 0,
507 .suspend_enabled = 1,
508 .latency = 2000,
509 .residency = 0,
510 },
511 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
512 .idle_supported = 1,
513 .suspend_supported = 1,
514 .idle_enabled = 1,
515 .suspend_enabled = 1,
516 .latency = 2,
517 .residency = 0,
518 },
519};
520
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600521static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +0530522 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
523 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600524};
525
Murali Nalajala4c996be2012-03-12 17:05:41 +0530526/* 8625 PM platform data */
527static struct msm_pm_platform_data msm8625_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
528 /* CORE0 entries */
529 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
530 .idle_supported = 1,
531 .suspend_supported = 1,
532 .idle_enabled = 0,
533 .suspend_enabled = 0,
534 .latency = 16000,
535 .residency = 20000,
536 },
537
538 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
539 .idle_supported = 1,
540 .suspend_supported = 1,
541 .idle_enabled = 0,
542 .suspend_enabled = 0,
543 .latency = 12000,
544 .residency = 20000,
545 },
546
547 /* picked latency & redisdency values from 7x30 */
548 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
549 .idle_supported = 1,
550 .suspend_supported = 1,
551 .idle_enabled = 0,
552 .suspend_enabled = 0,
553 .latency = 500,
554 .residency = 6000,
555 },
556
557 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
558 .idle_supported = 1,
559 .suspend_supported = 1,
560 .idle_enabled = 1,
561 .suspend_enabled = 1,
562 .latency = 2,
563 .residency = 10,
564 },
565
566 /* picked latency & redisdency values from 7x30 */
567 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
568 .idle_supported = 1,
569 .suspend_supported = 1,
570 .idle_enabled = 0,
571 .suspend_enabled = 0,
572 .latency = 500,
573 .residency = 6000,
574 },
575
576 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
577 .idle_supported = 1,
578 .suspend_supported = 1,
579 .idle_enabled = 1,
580 .suspend_enabled = 1,
581 .latency = 2,
582 .residency = 10,
583 },
584
585};
586
587static struct msm_pm_boot_platform_data msm_pm_8625_boot_pdata __initdata = {
588 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
589 .v_addr = MSM_CFG_CTL_BASE,
590};
591
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530592static struct android_pmem_platform_data android_pmem_adsp_pdata = {
593 .name = "pmem_adsp",
594 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
595 .cached = 1,
596 .memory_type = MEMTYPE_EBI1,
597};
598
599static struct platform_device android_pmem_adsp_device = {
600 .name = "android_pmem",
601 .id = 1,
602 .dev = { .platform_data = &android_pmem_adsp_pdata },
603};
604
605static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
606static int __init pmem_mdp_size_setup(char *p)
607{
608 pmem_mdp_size = memparse(p, NULL);
609 return 0;
610}
611
612early_param("pmem_mdp_size", pmem_mdp_size_setup);
613
614static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
615static int __init pmem_adsp_size_setup(char *p)
616{
617 pmem_adsp_size = memparse(p, NULL);
618 return 0;
619}
620
621early_param("pmem_adsp_size", pmem_adsp_size_setup);
622
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530623#define SND(desc, num) { .name = #desc, .id = num }
624static struct snd_endpoint snd_endpoints_list[] = {
625 SND(HANDSET, 0),
626 SND(MONO_HEADSET, 2),
627 SND(HEADSET, 3),
628 SND(SPEAKER, 6),
629 SND(TTY_HEADSET, 8),
630 SND(TTY_VCO, 9),
631 SND(TTY_HCO, 10),
632 SND(BT, 12),
633 SND(IN_S_SADC_OUT_HANDSET, 16),
634 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
635 SND(FM_DIGITAL_STEREO_HEADSET, 26),
636 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
637 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
Shashi Kumar64e07602011-10-11 13:18:57 +0530638 SND(STEREO_HEADSET_AND_SPEAKER, 31),
Phani Kumar Alladad6971252011-10-19 10:50:15 +0530639 SND(CURRENT, 0x7FFFFFFE),
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530640 SND(FM_ANALOG_STEREO_HEADSET, 35),
641 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
642};
643#undef SND
644
645static struct msm_snd_endpoints msm_device_snd_endpoints = {
646 .endpoints = snd_endpoints_list,
647 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
648};
649
650static struct platform_device msm_device_snd = {
651 .name = "msm_snd",
652 .id = -1,
653 .dev = {
654 .platform_data = &msm_device_snd_endpoints
655 },
656};
657
658#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
659 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
660 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
661 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
662 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
663 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
664#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
665 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
666 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
667 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
668 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
669 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
670#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
671 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
672 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
673 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
674 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
675 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
676#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
677 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
678 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
679 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
680 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
681 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
682#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
683
684static unsigned int dec_concurrency_table[] = {
685 /* Audio LP */
686 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
687 0, 0, 0,
688
689 /* Concurrency 1 */
690 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
691 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
692 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
693 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
694 (DEC4_FORMAT),
695
696 /* Concurrency 2 */
697 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
698 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
699 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
700 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
701 (DEC4_FORMAT),
702
703 /* Concurrency 3 */
704 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
705 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
706 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
707 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
708 (DEC4_FORMAT),
709
710 /* Concurrency 4 */
711 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
712 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
713 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
714 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
715 (DEC4_FORMAT),
716
717 /* Concurrency 5 */
718 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
719 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
720 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
721 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
722 (DEC4_FORMAT),
723
724 /* Concurrency 6 */
725 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
726 0, 0, 0, 0,
727
728 /* Concurrency 7 */
729 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
730 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
731 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
732 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
733 (DEC4_FORMAT),
734};
735
736#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
737 .module_queueid = queueid, .module_decid = decid, \
738 .nr_codec_support = nr_codec}
739
740static struct msm_adspdec_info dec_info_list[] = {
741 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
742 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
743 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
744 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
745 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
746};
747
748static struct msm_adspdec_database msm_device_adspdec_database = {
749 .num_dec = ARRAY_SIZE(dec_info_list),
750 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
751 ARRAY_SIZE(dec_info_list)),
752 .dec_concurrency_table = dec_concurrency_table,
753 .dec_info_list = dec_info_list,
754};
755
756static struct platform_device msm_device_adspdec = {
757 .name = "msm_adspdec",
758 .id = -1,
759 .dev = {
760 .platform_data = &msm_device_adspdec_database
761 },
762};
763
764static struct android_pmem_platform_data android_pmem_audio_pdata = {
765 .name = "pmem_audio",
766 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
767 .cached = 0,
768 .memory_type = MEMTYPE_EBI1,
769};
770
771static struct platform_device android_pmem_audio_device = {
772 .name = "android_pmem",
773 .id = 2,
774 .dev = { .platform_data = &android_pmem_audio_pdata },
775};
776
777static struct android_pmem_platform_data android_pmem_pdata = {
778 .name = "pmem",
779 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
780 .cached = 1,
781 .memory_type = MEMTYPE_EBI1,
782};
783static struct platform_device android_pmem_device = {
784 .name = "android_pmem",
785 .id = 0,
786 .dev = { .platform_data = &android_pmem_pdata },
787};
788
789static u32 msm_calculate_batt_capacity(u32 current_voltage);
790
791static struct msm_psy_batt_pdata msm_psy_batt_data = {
792 .voltage_min_design = 2800,
793 .voltage_max_design = 4300,
794 .avail_chg_sources = AC_CHG | USB_CHG ,
795 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
796 .calculate_capacity = &msm_calculate_batt_capacity,
797};
798
799static u32 msm_calculate_batt_capacity(u32 current_voltage)
800{
801 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
802 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
803
804 return (current_voltage - low_voltage) * 100
805 / (high_voltage - low_voltage);
806}
807
808static struct platform_device msm_batt_device = {
809 .name = "msm-battery",
810 .id = -1,
811 .dev.platform_data = &msm_psy_batt_data,
812};
813
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530814static struct platform_device *common_devices[] __initdata = {
815 &android_usb_device,
816 &android_pmem_device,
817 &android_pmem_adsp_device,
818 &android_pmem_audio_device,
819 &msm_batt_device,
820 &msm_device_adspdec,
821 &msm_device_snd,
822 &asoc_msm_pcm,
823 &asoc_msm_dai0,
824 &asoc_msm_dai1,
825};
826
827static struct platform_device *qrd7627a_devices[] __initdata = {
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530828 &msm_device_dmov,
829 &msm_device_smd,
830 &msm_device_uart1,
831 &msm_device_uart_dm1,
832 &msm_gsbi0_qup_i2c_device,
833 &msm_gsbi1_qup_i2c_device,
834 &msm_device_otg,
835 &msm_device_gadget_peripheral,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530836 &msm_kgsl_3d0,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530837};
838
Chintan Pandyab1bad0e2012-02-06 19:04:51 +0530839static struct platform_device *qrd3_devices[] __initdata = {
840 &msm_device_nand,
841};
842
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530843static struct platform_device *msm8625_evb_devices[] __initdata = {
844 &msm8625_device_dmov,
845 &msm8625_device_smd,
846 &msm8625_gsbi0_qup_i2c_device,
847 &msm8625_gsbi1_qup_i2c_device,
848 &msm8625_device_uart1,
Ram Mohan Korukonda5ee9fb82012-03-09 12:10:01 +0530849 &msm8625_device_uart_dm1,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530850 &msm8625_device_otg,
851 &msm8625_device_gadget_peripheral,
Aparna Mallavarapud95d8fc2012-03-08 12:07:37 +0530852 &msm8625_kgsl_3d0,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530853};
854
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530855static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
856static int __init pmem_kernel_ebi1_size_setup(char *p)
857{
858 pmem_kernel_ebi1_size = memparse(p, NULL);
859 return 0;
860}
861early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
862
863static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
864static int __init pmem_audio_size_setup(char *p)
865{
866 pmem_audio_size = memparse(p, NULL);
867 return 0;
868}
869early_param("pmem_audio_size", pmem_audio_size_setup);
870
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530871static struct memtype_reserve msm7627a_reserve_table[] __initdata = {
872 [MEMTYPE_SMI] = {
873 },
874 [MEMTYPE_EBI0] = {
875 .flags = MEMTYPE_FLAGS_1M_ALIGN,
876 },
877 [MEMTYPE_EBI1] = {
878 .flags = MEMTYPE_FLAGS_1M_ALIGN,
879 },
880};
881
882static void __init size_pmem_devices(void)
883{
884#ifdef CONFIG_ANDROID_PMEM
885 android_pmem_adsp_pdata.size = pmem_adsp_size;
886 android_pmem_pdata.size = pmem_mdp_size;
887 android_pmem_audio_pdata.size = pmem_audio_size;
888#endif
889}
890
891static void __init reserve_memory_for(struct android_pmem_platform_data *p)
892{
893 msm7627a_reserve_table[p->memory_type].size += p->size;
894}
895
896static void __init reserve_pmem_memory(void)
897{
898#ifdef CONFIG_ANDROID_PMEM
899 reserve_memory_for(&android_pmem_adsp_pdata);
900 reserve_memory_for(&android_pmem_pdata);
901 reserve_memory_for(&android_pmem_audio_pdata);
902 msm7627a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
903#endif
904}
905
906static void __init msm7627a_calculate_reserve_sizes(void)
907{
908 size_pmem_devices();
909 reserve_pmem_memory();
910}
911
912static int msm7627a_paddr_to_memtype(unsigned int paddr)
913{
914 return MEMTYPE_EBI1;
915}
916
917static struct reserve_info msm7627a_reserve_info __initdata = {
918 .memtype_reserve_table = msm7627a_reserve_table,
919 .calculate_reserve_sizes = msm7627a_calculate_reserve_sizes,
920 .paddr_to_memtype = msm7627a_paddr_to_memtype,
921};
922
923static void __init msm7627a_reserve(void)
924{
925 reserve_info = &msm7627a_reserve_info;
926 msm_reserve();
Murali Nalajala4c996be2012-03-12 17:05:41 +0530927 msm_pm_8625_boot_pdata.p_addr = memblock_alloc(SZ_8, SZ_64K);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530928}
929
Taniya Dasfe04d4f2012-03-14 11:13:21 +0530930static void __init msm8625_reserve(void)
931{
932 memblock_remove(MSM8625_SECONDARY_PHYS, SZ_8);
933 msm7627a_reserve();
934}
935
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530936static void msmqrd_adsp_add_pdev(void)
937{
938 int rc = 0;
939 struct rpc_board_dev *rpc_adsp_pdev;
940
941 rpc_adsp_pdev = kzalloc(sizeof(struct rpc_board_dev), GFP_KERNEL);
942 if (rpc_adsp_pdev == NULL) {
943 pr_err("%s: Memory Allocation failure\n", __func__);
944 return;
945 }
946 rpc_adsp_pdev->prog = ADSP_RPC_PROG;
947
948 if (cpu_is_msm8625())
949 rpc_adsp_pdev->pdev = msm8625_device_adsp;
950 else
951 rpc_adsp_pdev->pdev = msm_adsp_device;
952 rc = msm_rpc_add_board_dev(rpc_adsp_pdev, 1);
953 if (rc < 0) {
954 pr_err("%s: return val: %d\n", __func__, rc);
955 kfree(rpc_adsp_pdev);
956 }
957}
958
959static void __init msm7627a_device_i2c_init(void)
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530960{
961 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
962 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
963}
964
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530965static void __init msm8625_device_i2c_init(void)
966{
967 msm8625_gsbi0_qup_i2c_device.dev.platform_data
968 = &msm_gsbi0_qup_i2c_pdata;
969 msm8625_gsbi1_qup_i2c_device.dev.platform_data
970 = &msm_gsbi1_qup_i2c_pdata;
971}
972
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530973static struct msm_handset_platform_data hs_platform_data = {
974 .hs_name = "7k_handset",
975 .pwr_key_delay_ms = 500, /* 0 will disable end key */
976};
977
978static struct platform_device hs_pdev = {
979 .name = "msm-handset",
980 .id = -1,
981 .dev = {
982 .platform_data = &hs_platform_data,
983 },
984};
985
Pankaj Kumar3cec0582011-11-18 11:13:29 +0530986static struct platform_device msm_proccomm_regulator_dev = {
987 .name = PROCCOMM_REGULATOR_DEV_NAME,
988 .id = -1,
989 .dev = {
990 .platform_data = &msm7x27a_proccomm_regulator_data
991 }
992};
993
994static void __init msm7627a_init_regulators(void)
995{
996 int rc = platform_device_register(&msm_proccomm_regulator_dev);
997 if (rc)
998 pr_err("%s: could not register regulator device: %d\n",
999 __func__, rc);
1000}
1001
Mohan Pallakab6c44b32011-11-23 15:19:57 +05301002/* 8625 keypad device information */
1003static unsigned int kp_row_gpios_8625[] = {31};
1004static unsigned int kp_col_gpios_8625[] = {36, 37};
1005
1006static const unsigned short keymap_8625[] = {
1007 KEY_VOLUMEUP,
1008 KEY_VOLUMEDOWN,
1009};
1010
1011static struct gpio_event_matrix_info kp_matrix_info_8625 = {
1012 .info.func = gpio_event_matrix_func,
1013 .keymap = keymap_8625,
1014 .output_gpios = kp_row_gpios_8625,
1015 .input_gpios = kp_col_gpios_8625,
1016 .noutputs = ARRAY_SIZE(kp_row_gpios_8625),
1017 .ninputs = ARRAY_SIZE(kp_col_gpios_8625),
1018 .settle_time.tv_nsec = 40 * NSEC_PER_USEC,
1019 .poll_time.tv_nsec = 20 * NSEC_PER_MSEC,
1020 .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE |
1021 GPIOKPF_PRINT_UNMAPPED_KEYS,
1022};
1023
1024static struct gpio_event_info *kp_info_8625[] = {
1025 &kp_matrix_info_8625.info,
1026};
1027static struct gpio_event_platform_data kp_pdata_8625 = {
1028 .name = "8625_kp",
1029 .info = kp_info_8625,
1030 .info_count = ARRAY_SIZE(kp_info_8625)
1031};
1032
1033static struct platform_device kp_pdev_8625 = {
1034 .name = GPIO_EVENT_DEV_NAME,
1035 .id = -1,
1036 .dev = {
1037 .platform_data = &kp_pdata_8625,
1038 },
1039};
1040
Mohan Pallakaad78af82011-11-23 15:30:07 +05301041#define LED_RED_GPIO_8625 49
1042#define LED_GREEN_GPIO_8625 34
1043
1044static struct gpio_led gpio_leds_config_8625[] = {
1045 {
1046 .name = "green",
1047 .gpio = LED_GREEN_GPIO_8625,
1048 },
1049 {
1050 .name = "red",
1051 .gpio = LED_RED_GPIO_8625,
1052 },
1053};
1054
1055static struct gpio_led_platform_data gpio_leds_pdata_8625 = {
1056 .num_leds = ARRAY_SIZE(gpio_leds_config_8625),
1057 .leds = gpio_leds_config_8625,
1058};
1059
1060static struct platform_device gpio_leds_8625 = {
1061 .name = "leds-gpio",
1062 .id = -1,
1063 .dev = {
1064 .platform_data = &gpio_leds_pdata_8625,
1065 },
1066};
1067
Mohan Pallaka4c5bb922011-11-23 15:54:51 +05301068#define MXT_TS_IRQ_GPIO 48
1069#define MXT_TS_RESET_GPIO 26
1070
1071static const u8 mxt_config_data[] = {
1072 /* T6 Object */
1073 0, 0, 0, 0, 0, 0,
1074 /* T38 Object */
1075 16, 0, 0, 0, 0, 0, 0, 0,
1076 /* T7 Object */
Mohan Pallaka2c74a132012-03-05 15:50:40 +05301077 32, 16, 50,
Mohan Pallaka4c5bb922011-11-23 15:54:51 +05301078 /* T8 Object */
1079 30, 0, 20, 20, 0, 0, 20, 0, 50, 0,
1080 /* T9 Object */
1081 3, 0, 0, 18, 11, 0, 32, 75, 3, 3,
1082 0, 1, 1, 0, 10, 10, 10, 10, 31, 3,
1083 223, 1, 11, 11, 15, 15, 151, 43, 145, 80,
1084 100, 15, 0, 0, 0,
1085 /* T15 Object */
1086 131, 0, 11, 11, 1, 1, 0, 45, 3, 0,
1087 0,
1088 /* T18 Object */
1089 0, 0,
1090 /* T19 Object */
1091 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1092 0, 0, 0, 0, 0, 0,
1093 /* T23 Object */
1094 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1095 0, 0, 0, 0, 0,
1096 /* T25 Object */
1097 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1098 0, 0, 0, 0,
1099 /* T40 Object */
1100 0, 0, 0, 0, 0,
1101 /* T42 Object */
1102 0, 0, 0, 0, 0, 0, 0, 0,
1103 /* T46 Object */
1104 0, 2, 32, 48, 0, 0, 0, 0, 0,
1105 /* T47 Object */
1106 1, 20, 60, 5, 2, 50, 40, 0, 0, 40,
1107 /* T48 Object */
1108 1, 12, 80, 0, 0, 0, 0, 0, 0, 0,
1109 0, 0, 0, 6, 6, 0, 0, 100, 4, 64,
1110 10, 0, 20, 5, 0, 38, 0, 20, 0, 0,
1111 0, 0, 0, 0, 16, 65, 3, 1, 1, 0,
1112 10, 10, 10, 0, 0, 15, 15, 154, 58, 145,
1113 80, 100, 15, 3,
1114};
1115
1116static struct mxt_config_info mxt_config_array[] = {
1117 {
1118 .config = mxt_config_data,
1119 .config_length = ARRAY_SIZE(mxt_config_data),
1120 .family_id = 0x81,
1121 .variant_id = 0x01,
1122 .version = 0x10,
1123 .build = 0xAA,
1124 },
1125};
1126
1127static int mxt_key_codes[MXT_KEYARRAY_MAX_KEYS] = {
1128 [0] = KEY_HOME,
1129 [1] = KEY_MENU,
1130 [9] = KEY_BACK,
1131 [10] = KEY_SEARCH,
1132};
1133
1134static struct mxt_platform_data mxt_platform_data = {
1135 .config_array = mxt_config_array,
1136 .config_array_size = ARRAY_SIZE(mxt_config_array),
Mohan Pallaka56a1a5d2012-02-23 12:05:13 -08001137 .panel_minx = 0,
1138 .panel_maxx = 479,
1139 .panel_miny = 0,
1140 .panel_maxy = 799,
1141 .disp_minx = 0,
1142 .disp_maxx = 479,
1143 .disp_miny = 0,
1144 .disp_maxy = 799,
Mohan Pallaka4c5bb922011-11-23 15:54:51 +05301145 .irqflags = IRQF_TRIGGER_FALLING,
1146 .i2c_pull_up = true,
1147 .reset_gpio = MXT_TS_RESET_GPIO,
1148 .irq_gpio = MXT_TS_IRQ_GPIO,
1149 .key_codes = mxt_key_codes,
1150};
1151
1152static struct i2c_board_info mxt_device_info[] __initdata = {
1153 {
1154 I2C_BOARD_INFO("atmel_mxt_ts", 0x4a),
1155 .platform_data = &mxt_platform_data,
1156 .irq = MSM_GPIO_TO_INT(MXT_TS_IRQ_GPIO),
1157 },
1158};
1159
Taniya Dasc868a2e2012-01-03 10:18:47 +05301160static void msm7627a_add_io_devices(void)
1161{
Mohan Pallakaad78af82011-11-23 15:30:07 +05301162 int rc;
1163
Mohan Pallaka4c5bb922011-11-23 15:54:51 +05301164 /* touchscreen */
1165 if (machine_is_msm7627a_qrd1()) {
1166 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
1167 synaptic_i2c_clearpad3k,
1168 ARRAY_SIZE(synaptic_i2c_clearpad3k));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301169 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Mohan Pallaka4c5bb922011-11-23 15:54:51 +05301170 rc = gpio_tlmm_config(GPIO_CFG(MXT_TS_IRQ_GPIO, 0,
1171 GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
1172 GPIO_CFG_8MA), GPIO_CFG_ENABLE);
1173 if (rc) {
1174 pr_err("%s: gpio_tlmm_config for %d failed\n",
1175 __func__, MXT_TS_IRQ_GPIO);
1176 }
1177
1178 rc = gpio_tlmm_config(GPIO_CFG(MXT_TS_RESET_GPIO, 0,
1179 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
1180 GPIO_CFG_8MA), GPIO_CFG_ENABLE);
1181 if (rc) {
1182 pr_err("%s: gpio_tlmm_config for %d failed\n",
1183 __func__, MXT_TS_RESET_GPIO);
1184 }
1185
1186 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
1187 mxt_device_info,
1188 ARRAY_SIZE(mxt_device_info));
Mohan Pallaka5afe9852012-01-12 23:12:06 +05301189 } else if (machine_is_msm7627a_qrd3()) {
1190 ft5x06_touchpad_setup();
Mohan Pallaka4c5bb922011-11-23 15:54:51 +05301191 }
1192
1193 /* headset */
Taniya Dasc868a2e2012-01-03 10:18:47 +05301194 platform_device_register(&hs_pdev);
1195
Mohan Pallaka4c5bb922011-11-23 15:54:51 +05301196 /* vibrator */
Taniya Dasc868a2e2012-01-03 10:18:47 +05301197#ifdef CONFIG_MSM_RPC_VIBRATOR
1198 msm_init_pmic_vibrator();
1199#endif
1200
Mohan Pallakab6c44b32011-11-23 15:19:57 +05301201 /* keypad */
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301202 if (machine_is_msm7627a_evb() || machine_is_msm8625_evb())
Mohan Pallakab6c44b32011-11-23 15:19:57 +05301203 platform_device_register(&kp_pdev_8625);
Mohan Pallakaad78af82011-11-23 15:30:07 +05301204
1205 /* leds */
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301206 if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Mohan Pallakaad78af82011-11-23 15:30:07 +05301207 rc = gpio_tlmm_config(GPIO_CFG(LED_RED_GPIO_8625, 0,
1208 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
1209 GPIO_CFG_16MA), GPIO_CFG_ENABLE);
1210 if (rc) {
1211 pr_err("%s: gpio_tlmm_config for %d failed\n",
1212 __func__, LED_RED_GPIO_8625);
1213 }
1214
1215 rc = gpio_tlmm_config(GPIO_CFG(LED_GREEN_GPIO_8625, 0,
1216 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
1217 GPIO_CFG_16MA), GPIO_CFG_ENABLE);
1218 if (rc) {
1219 pr_err("%s: gpio_tlmm_config for %d failed\n",
1220 __func__, LED_GREEN_GPIO_8625);
1221 }
1222
1223 platform_device_register(&gpio_leds_8625);
1224 }
Taniya Dasc868a2e2012-01-03 10:18:47 +05301225}
1226
Santosh Sajjan374d6592012-01-19 23:16:46 +05301227static int __init msm_qrd_init_ar6000pm(void)
1228{
1229 msm_wlan_ar6000_pm_device.dev.platform_data = &ar600x_wlan_power;
1230 return platform_device_register(&msm_wlan_ar6000_pm_device);
1231}
1232
Taniya Dase380a2d2012-03-09 13:02:41 +05301233static void __init msm_add_footswitch_devices(void)
1234{
1235 platform_add_devices(msm_footswitch_devices,
1236 msm_num_footswitch_devices);
1237}
1238
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301239static void add_platform_devices(void)
1240{
Taniya Dasbd096542012-03-15 17:43:45 +05301241 if (machine_is_msm8625_evb() || machine_is_msm8625_qrd7()) {
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301242 platform_add_devices(msm8625_evb_devices,
1243 ARRAY_SIZE(msm8625_evb_devices));
Aparna Mallavarapubeafcbc2012-03-13 16:57:39 +05301244 platform_add_devices(qrd3_devices,
Taniya Dasbd096542012-03-15 17:43:45 +05301245 ARRAY_SIZE(qrd3_devices));
Aparna Mallavarapubeafcbc2012-03-13 16:57:39 +05301246 } else {
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301247 platform_add_devices(qrd7627a_devices,
1248 ARRAY_SIZE(qrd7627a_devices));
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301249 }
Taniya Dasbd096542012-03-15 17:43:45 +05301250
1251 if (machine_is_msm7627a_qrd3())
1252 platform_add_devices(qrd3_devices,
1253 ARRAY_SIZE(qrd3_devices));
1254
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301255 platform_add_devices(common_devices,
1256 ARRAY_SIZE(common_devices));
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301257}
1258
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301259#define UART1DM_RX_GPIO 45
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301260static void __init qrd7627a_uart1dm_config(void)
1261{
1262 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
1263 if (cpu_is_msm8625())
1264 msm8625_device_uart_dm1.dev.platform_data =
1265 &msm_uart_dm1_pdata;
1266 else
1267 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
1268}
1269
1270static void __init qrd7627a_otg_gadget(void)
1271{
1272 msm_otg_pdata.swfi_latency = msm7627a_pm_data
1273 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
1274
1275 if (cpu_is_msm8625()) {
1276 msm8625_device_otg.dev.platform_data = &msm_otg_pdata;
1277 msm8625_device_gadget_peripheral.dev.platform_data =
1278 &msm_gadget_pdata;
1279
1280 } else {
1281 msm_device_otg.dev.platform_data = &msm_otg_pdata;
1282 msm_device_gadget_peripheral.dev.platform_data =
1283 &msm_gadget_pdata;
1284 }
1285}
1286
Taniya Dasbd096542012-03-15 17:43:45 +05301287static void __init msm_pm_init(void)
1288{
1289 if (machine_is_msm8625_qrd7())
1290 return;
1291
1292 if (!machine_is_msm8625_evb()) {
1293 msm_pm_set_platform_data(msm7627a_pm_data,
1294 ARRAY_SIZE(msm7627a_pm_data));
1295 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
1296 } else {
1297 msm_pm_set_platform_data(msm8625_pm_data,
1298 ARRAY_SIZE(msm8625_pm_data));
1299 BUG_ON(msm_pm_boot_init(&msm_pm_8625_boot_pdata));
1300 msm8x25_spm_device_init();
1301 }
1302}
1303
Taniya Dasc868a2e2012-01-03 10:18:47 +05301304static void __init msm_qrd_init(void)
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301305{
1306 msm7x2x_misc_init();
Pankaj Kumar3cec0582011-11-18 11:13:29 +05301307 msm7627a_init_regulators();
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301308 msmqrd_adsp_add_pdev();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301309
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301310 if (cpu_is_msm8625())
1311 msm8625_device_i2c_init();
1312 else
1313 msm7627a_device_i2c_init();
1314
1315 /* uart1dm*/
1316 qrd7627a_uart1dm_config();
1317 /*OTG gadget*/
1318 qrd7627a_otg_gadget();
Taniya Dasc868a2e2012-01-03 10:18:47 +05301319
Taniya Dase380a2d2012-03-09 13:02:41 +05301320 msm_add_footswitch_devices();
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301321 add_platform_devices();
Taniya Dasc868a2e2012-01-03 10:18:47 +05301322
Santosh Sajjan374d6592012-01-19 23:16:46 +05301323 /* Ensure ar6000pm device is registered before MMC/SDC */
1324 msm_qrd_init_ar6000pm();
Chintan Pandyacf467fc2011-12-01 17:11:11 +05301325 msm7627a_init_mmc();
1326
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301327#ifdef CONFIG_USB_EHCI_MSM_72K
1328 msm7627a_init_host();
1329#endif
Taniya Dasbd096542012-03-15 17:43:45 +05301330 msm_pm_init();
Murali Nalajalaa1827842011-11-13 14:12:39 +05301331
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05301332 msm_pm_register_irqs();
Taniya Das0a5303a2011-08-23 18:47:48 +05301333 msm_fb_add_devices();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301334
1335#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Chintan Pandya13490c02011-12-20 13:03:36 +05301336 msm7627a_bt_power_init();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301337#endif
Taniya Dasda408822011-09-06 12:54:06 +05301338
Chintan Pandya40762702011-12-06 13:47:06 +05301339 msm7627a_camera_init();
Taniya Dasc868a2e2012-01-03 10:18:47 +05301340 msm7627a_add_io_devices();
Aparna Mallavarapud95d8fc2012-03-08 12:07:37 +05301341 msm7x25a_kgsl_3d0_init();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301342}
1343
1344static void __init qrd7627a_init_early(void)
1345{
1346 msm_msm7627a_allocate_memory_regions();
1347}
1348
1349MACHINE_START(MSM7627A_QRD1, "QRD MSM7627a QRD1")
1350 .boot_params = PHYS_OFFSET + 0x100,
1351 .map_io = msm_common_io_init,
1352 .reserve = msm7627a_reserve,
1353 .init_irq = msm_init_irq,
Taniya Dasc868a2e2012-01-03 10:18:47 +05301354 .init_machine = msm_qrd_init,
1355 .timer = &msm_timer,
1356 .init_early = qrd7627a_init_early,
1357 .handle_irq = vic_handle_irq,
1358MACHINE_END
Chintan Pandyab1bad0e2012-02-06 19:04:51 +05301359MACHINE_START(MSM7627A_QRD3, "QRD MSM7627a QRD3")
1360 .boot_params = PHYS_OFFSET + 0x100,
1361 .map_io = msm_common_io_init,
1362 .reserve = msm7627a_reserve,
1363 .init_irq = msm_init_irq,
1364 .init_machine = msm_qrd_init,
1365 .timer = &msm_timer,
1366 .init_early = qrd7627a_init_early,
1367 .handle_irq = vic_handle_irq,
1368MACHINE_END
Taniya Dasc868a2e2012-01-03 10:18:47 +05301369MACHINE_START(MSM7627A_EVB, "QRD MSM7627a EVB")
1370 .boot_params = PHYS_OFFSET + 0x100,
1371 .map_io = msm_common_io_init,
1372 .reserve = msm7627a_reserve,
1373 .init_irq = msm_init_irq,
1374 .init_machine = msm_qrd_init,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301375 .timer = &msm_timer,
1376 .init_early = qrd7627a_init_early,
Pankaj Kumarbf8a2a32011-10-21 11:47:21 +05301377 .handle_irq = vic_handle_irq,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301378MACHINE_END
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301379MACHINE_START(MSM8625_EVB, "QRD MSM8625 EVB")
1380 .boot_params = PHYS_OFFSET + 0x100,
1381 .map_io = msm8625_map_io,
Taniya Dasfe04d4f2012-03-14 11:13:21 +05301382 .reserve = msm8625_reserve,
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301383 .init_irq = msm8625_init_irq,
1384 .init_machine = msm_qrd_init,
1385 .timer = &msm_timer,
1386 .init_early = qrd7627a_init_early,
1387 .handle_irq = gic_handle_irq,
1388MACHINE_END
Taniya Dasbd096542012-03-15 17:43:45 +05301389MACHINE_START(MSM8625_QRD7, "QRD MSM8625 QRD7")
1390 .boot_params = PHYS_OFFSET + 0x100,
1391 .map_io = msm8625_map_io,
1392 .reserve = msm7627a_reserve,
1393 .init_irq = msm8625_init_irq,
1394 .init_machine = msm_qrd_init,
1395 .timer = &msm_timer,
1396 .init_early = qrd7627a_init_early,
1397 .handle_irq = gic_handle_irq,
1398MACHINE_END