blob: 594a084d377f37ae3f316e6793e5d1b5b7e385d4 [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>
Pankaj Kumar3cec0582011-11-18 11:13:29 +053029#include <linux/regulator/consumer.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053030#include <asm/mach/mmc.h>
31#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33#include <mach/board.h>
34#include <mach/msm_iomap.h>
35#include <mach/msm_hsusb.h>
36#include <mach/rpc_hsusb.h>
37#include <mach/rpc_pmapp.h>
38#include <mach/usbdiag.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053039#include <mach/msm_memtypes.h>
40#include <mach/msm_serial_hs.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053041#include <mach/pmic.h>
42#include <mach/socinfo.h>
43#include <mach/vreg.h>
44#include <mach/rpc_pmapp.h>
45#include <mach/msm_battery.h>
46#include <mach/rpc_server_handset.h>
47#include <mach/socinfo.h>
Pankaj Kumar27c02642011-09-22 15:55:55 +053048#include "board-msm7x27a-regulator.h"
Taniya Dasc98bfbc2011-08-23 09:58:55 +053049#include "devices.h"
50#include "devices-msm7x2xa.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080051#include <mach/pm.h>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053052#include "timer.h"
Murali Nalajalaa1827842011-11-13 14:12:39 +053053#include "pm-boot.h"
Pankaj Kumar3cec0582011-11-18 11:13:29 +053054#include "board-msm7x27a-regulator.h"
Chintan Pandyacf467fc2011-12-01 17:11:11 +053055#include "board-msm7627a.h"
Taniya Dasc98bfbc2011-08-23 09:58:55 +053056
57#define PMEM_KERNEL_EBI1_SIZE 0x3A000
58#define MSM_PMEM_AUDIO_SIZE 0x5B000
Taniya Dasc98bfbc2011-08-23 09:58:55 +053059#define BAHAMA_SLAVE_ID_FM_REG 0x02
60#define FM_GPIO 83
Rahul Kashyap8b4a7862011-12-13 18:40:54 +053061#define BT_PCM_BCLK_MODE 0x88
62#define BT_PCM_DIN_MODE 0x89
63#define BT_PCM_DOUT_MODE 0x8A
64#define BT_PCM_SYNC_MODE 0x8B
65#define FM_I2S_SD_MODE 0x8E
66#define FM_I2S_WS_MODE 0x8F
67#define FM_I2S_SCK_MODE 0x90
68#define I2C_PIN_CTL 0x15
69#define I2C_NORMAL 0x40
Taniya Dasc98bfbc2011-08-23 09:58:55 +053070
Chintan Pandyab4298622012-01-04 00:06:07 +053071enum {
72 GPIO_HOST_VBUS_EN = 107,
73 GPIO_BT_SYS_REST_EN = 114,
74 GPIO_WAKE_ON_WIRELESS,
75 GPIO_BACKLIGHT_EN,
76 GPIO_NC,
77 GPIO_CAM_3MP_PWDN, /* CAM_VGA */
78 GPIO_WLAN_EN,
79 GPIO_CAM_5MP_SHDN_EN,
80 GPIO_CAM_5MP_RESET,
81 GPIO_TP,
82 GPIO_CAM_GP_CAMIF_RESET,
83};
84
Taniya Dasc98bfbc2011-08-23 09:58:55 +053085static struct platform_device msm_wlan_ar6000_pm_device = {
86 .name = "wlan_ar6000_pm_dev",
87 .id = -1,
88};
89
Taniya Dasc98bfbc2011-08-23 09:58:55 +053090static struct msm_gpio qup_i2c_gpios_io[] = {
91 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
92 "qup_scl" },
93 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
94 "qup_sda" },
95 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
96 "qup_scl" },
97 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
98 "qup_sda" },
99};
100
101static struct msm_gpio qup_i2c_gpios_hw[] = {
102 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
103 "qup_scl" },
104 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
105 "qup_sda" },
106 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
107 "qup_scl" },
108 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
109 "qup_sda" },
110};
111
112static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
113{
114 int rc;
115
116 if (adap_id < 0 || adap_id > 1)
117 return;
118
119 /* Each adapter gets 2 lines from the table */
120 if (config_type)
121 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
122 else
123 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
124 if (rc < 0)
125 pr_err("QUP GPIO request/enable failed: %d\n", rc);
126}
127
128static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
129 .clk_freq = 100000,
130 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
131};
132
133static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
134 .clk_freq = 100000,
135 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
136};
137
138#ifdef CONFIG_ARCH_MSM7X27A
139#define MSM_PMEM_MDP_SIZE 0x1DD1000
140#define MSM_PMEM_ADSP_SIZE 0x1000000
141
142#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
143#define MSM_FB_SIZE 0x260000
144#else
145#define MSM_FB_SIZE 0x195000
146#endif
147
148#endif
149
Taniya Dasda408822011-09-06 12:54:06 +0530150#if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) || \
151defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C_MODULE)
152
153#ifndef CLEARPAD3000_ATTEN_GPIO
154#define CLEARPAD3000_ATTEN_GPIO (48)
155#endif
156
157#ifndef CLEARPAD3000_RESET_GPIO
158#define CLEARPAD3000_RESET_GPIO (26)
159#endif
160
161static int synaptics_touchpad_setup(void);
162
163static struct msm_gpio clearpad3000_cfg_data[] = {
164 {GPIO_CFG(CLEARPAD3000_ATTEN_GPIO, 0, GPIO_CFG_INPUT,
165 GPIO_CFG_NO_PULL, GPIO_CFG_6MA), "rmi4_attn"},
166 {GPIO_CFG(CLEARPAD3000_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
167 GPIO_CFG_PULL_DOWN, GPIO_CFG_8MA), "rmi4_reset"},
168};
169
170static struct rmi_XY_pair rmi_offset = {.x = 0, .y = 0};
171static struct rmi_range rmi_clipx = {.min = 48, .max = 980};
172static struct rmi_range rmi_clipy = {.min = 7, .max = 1647};
173static struct rmi_f11_functiondata synaptics_f11_data = {
174 .swap_axes = false,
175 .flipX = false,
176 .flipY = false,
177 .offset = &rmi_offset,
178 .button_height = 113,
179 .clipX = &rmi_clipx,
180 .clipY = &rmi_clipy,
181};
182
183#define MAX_LEN 100
184
185static ssize_t clearpad3000_virtual_keys_register(struct kobject *kobj,
186 struct kobj_attribute *attr, char *buf)
187{
188 char *virtual_keys = __stringify(EV_KEY) ":" __stringify(KEY_MENU) \
189 ":60:830:120:60" ":" __stringify(EV_KEY) \
190 ":" __stringify(KEY_HOME) ":180:830:120:60" \
191 ":" __stringify(EV_KEY) ":" \
192 __stringify(KEY_SEARCH) ":300:830:120:60" \
193 ":" __stringify(EV_KEY) ":" \
194 __stringify(KEY_BACK) ":420:830:120:60" "\n";
195
196 return snprintf(buf, strnlen(virtual_keys, MAX_LEN) + 1 , "%s",
197 virtual_keys);
198}
199
200static struct kobj_attribute clearpad3000_virtual_keys_attr = {
201 .attr = {
202 .name = "virtualkeys.sensor00fn11",
203 .mode = S_IRUGO,
204 },
205 .show = &clearpad3000_virtual_keys_register,
206};
207
208static struct attribute *virtual_key_properties_attrs[] = {
209 &clearpad3000_virtual_keys_attr.attr,
210 NULL
211};
212
213static struct attribute_group virtual_key_properties_attr_group = {
214 .attrs = virtual_key_properties_attrs,
215};
216
217struct kobject *virtual_key_properties_kobj;
218
219static struct rmi_functiondata synaptics_functiondata[] = {
220 {
221 .function_index = RMI_F11_INDEX,
222 .data = &synaptics_f11_data,
223 },
224};
225
226static struct rmi_functiondata_list synaptics_perfunctiondata = {
227 .count = ARRAY_SIZE(synaptics_functiondata),
228 .functiondata = synaptics_functiondata,
229};
230
231static struct rmi_sensordata synaptics_sensordata = {
232 .perfunctiondata = &synaptics_perfunctiondata,
233 .rmi_sensor_setup = synaptics_touchpad_setup,
234};
235
236static struct rmi_i2c_platformdata synaptics_platformdata = {
237 .i2c_address = 0x2c,
238 .irq_type = IORESOURCE_IRQ_LOWLEVEL,
239 .sensordata = &synaptics_sensordata,
240};
241
242static struct i2c_board_info synaptic_i2c_clearpad3k[] = {
243 {
244 I2C_BOARD_INFO("rmi4_ts", 0x2c),
245 .platform_data = &synaptics_platformdata,
246 },
247};
248
249static int synaptics_touchpad_setup(void)
250{
251 int retval = 0;
252
253 virtual_key_properties_kobj =
254 kobject_create_and_add("board_properties", NULL);
255 if (virtual_key_properties_kobj)
256 retval = sysfs_create_group(virtual_key_properties_kobj,
257 &virtual_key_properties_attr_group);
258 if (!virtual_key_properties_kobj || retval)
259 pr_err("failed to create ft5202 board_properties\n");
260
261 retval = msm_gpios_request_enable(clearpad3000_cfg_data,
262 sizeof(clearpad3000_cfg_data)/sizeof(struct msm_gpio));
263 if (retval) {
264 pr_err("%s:Failed to obtain touchpad GPIO %d. Code: %d.",
265 __func__, CLEARPAD3000_ATTEN_GPIO, retval);
266 retval = 0; /* ignore the err */
267 }
268 synaptics_platformdata.irq = gpio_to_irq(CLEARPAD3000_ATTEN_GPIO);
269
270 gpio_set_value(CLEARPAD3000_RESET_GPIO, 0);
271 usleep(10000);
272 gpio_set_value(CLEARPAD3000_RESET_GPIO, 1);
273 usleep(50000);
274
275 return retval;
276}
277#endif
278
279
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530280static struct android_usb_platform_data android_usb_pdata = {
Pankaj Kumar6f841742011-10-10 15:52:14 +0530281 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530282};
283
284static struct platform_device android_usb_device = {
285 .name = "android_usb",
286 .id = -1,
287 .dev = {
288 .platform_data = &android_usb_pdata,
289 },
290};
291
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530292#ifdef CONFIG_USB_EHCI_MSM_72K
293static void msm_hsusb_vbus_power(unsigned phy_info, int on)
294{
295 int rc = 0;
296 unsigned gpio;
297
Chintan Pandyab4298622012-01-04 00:06:07 +0530298 gpio = GPIO_HOST_VBUS_EN;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530299
300 rc = gpio_request(gpio, "i2c_host_vbus_en");
301 if (rc < 0) {
302 pr_err("failed to request %d GPIO\n", gpio);
303 return;
304 }
305 gpio_direction_output(gpio, !!on);
306 gpio_set_value_cansleep(gpio, !!on);
307 gpio_free(gpio);
308}
309
310static struct msm_usb_host_platform_data msm_usb_host_pdata = {
311 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
312};
313
314static void __init msm7627a_init_host(void)
315{
316 msm_add_host(0, &msm_usb_host_pdata);
317}
318#endif
319
320#ifdef CONFIG_USB_MSM_OTG_72K
321static int hsusb_rpc_connect(int connect)
322{
323 if (connect)
324 return msm_hsusb_rpc_connect();
325 else
326 return msm_hsusb_rpc_close();
327}
328
Pankaj Kumar27c02642011-09-22 15:55:55 +0530329static struct regulator *reg_hsusb;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530330static int msm_hsusb_ldo_init(int init)
331{
Pankaj Kumar27c02642011-09-22 15:55:55 +0530332 int rc = 0;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530333
Pankaj Kumar27c02642011-09-22 15:55:55 +0530334 if (init) {
335 reg_hsusb = regulator_get(NULL, "usb");
336 if (IS_ERR(reg_hsusb)) {
337 rc = PTR_ERR(reg_hsusb);
338 pr_err("%s: could not get regulator: %d\n",
339 __func__, rc);
340 goto out;
341 }
342
343 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
344 if (rc) {
345 pr_err("%s: could not set voltage: %d\n",
346 __func__, rc);
347 goto reg_free;
348 }
349
350 return 0;
351 }
352 /* else fall through */
353reg_free:
354 regulator_put(reg_hsusb);
355out:
356 reg_hsusb = NULL;
357 return rc;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530358}
359
360static int msm_hsusb_ldo_enable(int enable)
361{
362 static int ldo_status;
363
Pankaj Kumar27c02642011-09-22 15:55:55 +0530364 if (IS_ERR_OR_NULL(reg_hsusb))
365 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530366
367 if (ldo_status == enable)
368 return 0;
369
370 ldo_status = enable;
371
Pankaj Kumar27c02642011-09-22 15:55:55 +0530372 return enable ?
373 regulator_enable(reg_hsusb) :
374 regulator_disable(reg_hsusb);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530375}
376
377#ifndef CONFIG_USB_EHCI_MSM_72K
378static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
379{
380 int ret = 0;
381
382 if (init)
383 ret = msm_pm_app_rpc_init(callback);
384 else
385 msm_pm_app_rpc_deinit(callback);
386
387 return ret;
388}
389#endif
390
391static struct msm_otg_platform_data msm_otg_pdata = {
392#ifndef CONFIG_USB_EHCI_MSM_72K
393 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
394#else
395 .vbus_power = msm_hsusb_vbus_power,
396#endif
397 .rpc_connect = hsusb_rpc_connect,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530398 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
399 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
400 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
401 .se1_gating = SE1_GATING_DISABLE,
402 .ldo_init = msm_hsusb_ldo_init,
403 .ldo_enable = msm_hsusb_ldo_enable,
404 .chg_init = hsusb_chg_init,
405 .chg_connected = hsusb_chg_connected,
406 .chg_vbus_draw = hsusb_chg_vbus_draw,
407};
408#endif
409
410static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
411 .is_phy_status_timer_on = 1,
412};
413
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530414#ifdef CONFIG_SERIAL_MSM_HS
415static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
416 .inject_rx_on_wakeup = 1,
417 .rx_to_inject = 0xFD,
418};
419#endif
420static struct msm_pm_platform_data msm7627a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
421 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
422 .idle_supported = 1,
423 .suspend_supported = 1,
424 .idle_enabled = 1,
425 .suspend_enabled = 1,
426 .latency = 16000,
427 .residency = 20000,
428 },
429 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
430 .idle_supported = 1,
431 .suspend_supported = 1,
432 .idle_enabled = 1,
433 .suspend_enabled = 1,
434 .latency = 12000,
435 .residency = 20000,
436 },
437 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
438 .idle_supported = 1,
439 .suspend_supported = 1,
440 .idle_enabled = 0,
441 .suspend_enabled = 1,
442 .latency = 2000,
443 .residency = 0,
444 },
445 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
446 .idle_supported = 1,
447 .suspend_supported = 1,
448 .idle_enabled = 1,
449 .suspend_enabled = 1,
450 .latency = 2,
451 .residency = 0,
452 },
453};
454
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600455static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +0530456 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
457 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600458};
459
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530460static struct android_pmem_platform_data android_pmem_adsp_pdata = {
461 .name = "pmem_adsp",
462 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
463 .cached = 1,
464 .memory_type = MEMTYPE_EBI1,
465};
466
467static struct platform_device android_pmem_adsp_device = {
468 .name = "android_pmem",
469 .id = 1,
470 .dev = { .platform_data = &android_pmem_adsp_pdata },
471};
472
473static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
474static int __init pmem_mdp_size_setup(char *p)
475{
476 pmem_mdp_size = memparse(p, NULL);
477 return 0;
478}
479
480early_param("pmem_mdp_size", pmem_mdp_size_setup);
481
482static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
483static int __init pmem_adsp_size_setup(char *p)
484{
485 pmem_adsp_size = memparse(p, NULL);
486 return 0;
487}
488
489early_param("pmem_adsp_size", pmem_adsp_size_setup);
490
491static unsigned fb_size = MSM_FB_SIZE;
492static int __init fb_size_setup(char *p)
493{
494 fb_size = memparse(p, NULL);
495 return 0;
496}
497
498early_param("fb_size", fb_size_setup);
499
Taniya Das0a5303a2011-08-23 18:47:48 +0530500static struct resource msm_fb_resources[] = {
501 {
502 .flags = IORESOURCE_DMA,
503 }
504};
505
506static int msm_fb_detect_panel(const char *name)
507{
508 int ret;
509
510 if (!strncmp(name, "mipi_video_truly_wvga", 21))
511 ret = 0;
512 else
513 ret = -ENODEV;
514
515 return ret;
516}
517
518static int mipi_truly_set_bl(int on)
519{
Chintan Pandyab4298622012-01-04 00:06:07 +0530520 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, !!on);
Taniya Das0a5303a2011-08-23 18:47:48 +0530521
522 return 1;
523}
524
525static struct msm_fb_platform_data msm_fb_pdata = {
526 .detect_client = msm_fb_detect_panel,
527};
528
529static struct platform_device msm_fb_device = {
530 .name = "msm_fb",
531 .id = 0,
532 .num_resources = ARRAY_SIZE(msm_fb_resources),
533 .resource = msm_fb_resources,
534 .dev = {
535 .platform_data = &msm_fb_pdata,
536 }
537};
538
539static struct msm_panel_common_pdata mipi_truly_pdata = {
540 .pmic_backlight = mipi_truly_set_bl,
541};
542
543static struct platform_device mipi_dsi_truly_panel_device = {
544 .name = "mipi_truly",
545 .id = 0,
546 .dev = {
547 .platform_data = &mipi_truly_pdata,
548 }
549};
550
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530551#define SND(desc, num) { .name = #desc, .id = num }
552static struct snd_endpoint snd_endpoints_list[] = {
553 SND(HANDSET, 0),
554 SND(MONO_HEADSET, 2),
555 SND(HEADSET, 3),
556 SND(SPEAKER, 6),
557 SND(TTY_HEADSET, 8),
558 SND(TTY_VCO, 9),
559 SND(TTY_HCO, 10),
560 SND(BT, 12),
561 SND(IN_S_SADC_OUT_HANDSET, 16),
562 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
563 SND(FM_DIGITAL_STEREO_HEADSET, 26),
564 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
565 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
Shashi Kumar64e07602011-10-11 13:18:57 +0530566 SND(STEREO_HEADSET_AND_SPEAKER, 31),
Phani Kumar Alladad6971252011-10-19 10:50:15 +0530567 SND(CURRENT, 0x7FFFFFFE),
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530568 SND(FM_ANALOG_STEREO_HEADSET, 35),
569 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
570};
571#undef SND
572
573static struct msm_snd_endpoints msm_device_snd_endpoints = {
574 .endpoints = snd_endpoints_list,
575 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
576};
577
578static struct platform_device msm_device_snd = {
579 .name = "msm_snd",
580 .id = -1,
581 .dev = {
582 .platform_data = &msm_device_snd_endpoints
583 },
584};
585
586#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
587 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
588 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
589 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
590 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
591 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
592#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
593 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
594 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
595 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
596 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
597 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
598#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
599 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
600 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
601 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
602 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
603 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
604#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
605 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
606 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
607 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
608 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
609 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
610#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
611
612static unsigned int dec_concurrency_table[] = {
613 /* Audio LP */
614 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
615 0, 0, 0,
616
617 /* Concurrency 1 */
618 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
619 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
620 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
621 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
622 (DEC4_FORMAT),
623
624 /* Concurrency 2 */
625 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
626 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
627 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
628 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
629 (DEC4_FORMAT),
630
631 /* Concurrency 3 */
632 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
633 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
634 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
635 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
636 (DEC4_FORMAT),
637
638 /* Concurrency 4 */
639 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
640 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
641 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
642 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
643 (DEC4_FORMAT),
644
645 /* Concurrency 5 */
646 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
647 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
648 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
649 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
650 (DEC4_FORMAT),
651
652 /* Concurrency 6 */
653 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
654 0, 0, 0, 0,
655
656 /* Concurrency 7 */
657 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
658 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
659 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
660 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
661 (DEC4_FORMAT),
662};
663
664#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
665 .module_queueid = queueid, .module_decid = decid, \
666 .nr_codec_support = nr_codec}
667
668static struct msm_adspdec_info dec_info_list[] = {
669 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
670 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
671 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
672 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
673 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
674};
675
676static struct msm_adspdec_database msm_device_adspdec_database = {
677 .num_dec = ARRAY_SIZE(dec_info_list),
678 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
679 ARRAY_SIZE(dec_info_list)),
680 .dec_concurrency_table = dec_concurrency_table,
681 .dec_info_list = dec_info_list,
682};
683
684static struct platform_device msm_device_adspdec = {
685 .name = "msm_adspdec",
686 .id = -1,
687 .dev = {
688 .platform_data = &msm_device_adspdec_database
689 },
690};
691
692static struct android_pmem_platform_data android_pmem_audio_pdata = {
693 .name = "pmem_audio",
694 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
695 .cached = 0,
696 .memory_type = MEMTYPE_EBI1,
697};
698
699static struct platform_device android_pmem_audio_device = {
700 .name = "android_pmem",
701 .id = 2,
702 .dev = { .platform_data = &android_pmem_audio_pdata },
703};
704
705static struct android_pmem_platform_data android_pmem_pdata = {
706 .name = "pmem",
707 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
708 .cached = 1,
709 .memory_type = MEMTYPE_EBI1,
710};
711static struct platform_device android_pmem_device = {
712 .name = "android_pmem",
713 .id = 0,
714 .dev = { .platform_data = &android_pmem_pdata },
715};
716
717static u32 msm_calculate_batt_capacity(u32 current_voltage);
718
719static struct msm_psy_batt_pdata msm_psy_batt_data = {
720 .voltage_min_design = 2800,
721 .voltage_max_design = 4300,
722 .avail_chg_sources = AC_CHG | USB_CHG ,
723 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
724 .calculate_capacity = &msm_calculate_batt_capacity,
725};
726
727static u32 msm_calculate_batt_capacity(u32 current_voltage)
728{
729 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
730 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
731
732 return (current_voltage - low_voltage) * 100
733 / (high_voltage - low_voltage);
734}
735
736static struct platform_device msm_batt_device = {
737 .name = "msm-battery",
738 .id = -1,
739 .dev.platform_data = &msm_psy_batt_data,
740};
741
Chintan Pandyab4298622012-01-04 00:06:07 +0530742#ifdef CONFIG_MSM_CAMERA
743static uint32_t camera_off_gpio_table[] = {
744 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
745};
746
747static uint32_t camera_on_gpio_table[] = {
748 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
749};
750
751static void qrd1_camera_gpio_cfg(void)
752{
753
754 int rc = 0;
755
756 rc = gpio_request(GPIO_CAM_5MP_SHDN_EN, "ov5640");
757 if (rc < 0)
758 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
759 __func__);
760
761
762 rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_5MP_SHDN_EN, 0,
763 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
764 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
765 if (rc < 0) {
766 pr_err("%s: unable to enable Power Down gpio for main"
767 "camera!\n", __func__);
768 gpio_free(GPIO_CAM_5MP_SHDN_EN);
769 }
770
771
772 rc = gpio_request(GPIO_CAM_5MP_RESET, "ov5640");
773 if (rc < 0) {
774 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
775 __func__);
776 gpio_free(GPIO_CAM_5MP_SHDN_EN);
777 }
778
779
780 rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_5MP_RESET, 0,
781 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
782 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
783 if (rc < 0) {
784 pr_err("%s: unable to enable reset gpio for main camera!\n",
785 __func__);
786 gpio_free(GPIO_CAM_5MP_RESET);
787 }
788
789 rc = gpio_request(GPIO_CAM_3MP_PWDN, "ov7692");
790 if (rc < 0)
791 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
792 __func__);
793
794 rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_3MP_PWDN, 0,
795 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
796 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
797 if (rc < 0) {
798 pr_err("%s: unable to enable Power Down gpio for front"
799 "camera!\n", __func__);
800 gpio_free(GPIO_CAM_3MP_PWDN);
801 }
802
803 gpio_direction_output(GPIO_CAM_5MP_SHDN_EN, 1);
804 gpio_direction_output(GPIO_CAM_5MP_RESET, 1);
805 gpio_direction_output(GPIO_CAM_3MP_PWDN, 1);
806}
807
808#endif
809static struct regulator_bulk_data regs_camera[] = {
810 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
811 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
812 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
813};
814
815static void __init msm_camera_vreg_init(void)
816{
817 int rc;
818
819 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
820 if (rc) {
821 pr_err("%s: could not get regulators: %d\n", __func__, rc);
822 return;
823 }
824
825 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
826 if (rc) {
827 pr_err("%s: could not set voltages: %d\n", __func__, rc);
828 return;
829 }
830}
831
832static void msm_camera_vreg_config(int vreg_en)
833{
834 int rc = vreg_en ?
835 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
836 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
837
838 if (rc)
839 pr_err("%s: could not %sable regulators: %d\n",
840 __func__, vreg_en ? "en" : "dis", rc);
841}
842static int config_gpio_table(uint32_t *table, int len)
843{
844 int rc = 0, i = 0;
845
846 for (i = 0; i < len; i++) {
847 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
848 if (rc) {
849 pr_err("%s not able to get gpio\n", __func__);
850 for (i--; i >= 0; i--)
851 gpio_tlmm_config(camera_off_gpio_table[i],
852 GPIO_CFG_ENABLE);
853 break;
854 }
855 }
856 return rc;
857}
858
859static int config_camera_on_gpios_rear(void)
860{
861 int rc = 0;
862
863 msm_camera_vreg_config(1);
864
865 rc = config_gpio_table(camera_on_gpio_table,
866 ARRAY_SIZE(camera_on_gpio_table));
867 if (rc < 0) {
868 pr_err("%s: CAMSENSOR gpio table request"
869 "failed\n", __func__);
870 return rc;
871 }
872
873 return rc;
874}
875
876static void config_camera_off_gpios_rear(void)
877{
878 msm_camera_vreg_config(0);
879 config_gpio_table(camera_off_gpio_table,
880 ARRAY_SIZE(camera_off_gpio_table));
881}
882
883static int config_camera_on_gpios_front(void)
884{
885 int rc = 0;
886
887 msm_camera_vreg_config(1);
888
889 rc = config_gpio_table(camera_on_gpio_table,
890 ARRAY_SIZE(camera_on_gpio_table));
891 if (rc < 0) {
892 pr_err("%s: CAMSENSOR gpio table request"
893 "failed\n", __func__);
894 return rc;
895 }
896
897 return rc;
898}
899
900static void config_camera_off_gpios_front(void)
901{
902 msm_camera_vreg_config(0);
903
904 config_gpio_table(camera_off_gpio_table,
905 ARRAY_SIZE(camera_off_gpio_table));
906}
907
908struct msm_camera_device_platform_data msm_camera_data_rear = {
909 .camera_gpio_on = config_camera_on_gpios_rear,
910 .camera_gpio_off = config_camera_off_gpios_rear,
911 .ioext.csiphy = 0xA1000000,
912 .ioext.csisz = 0x00100000,
913 .ioext.csiirq = INT_CSI_IRQ_1,
914 .ioclk.mclk_clk_rate = 24000000,
915 .ioclk.vfe_clk_rate = 192000000,
916 .ioext.appphy = MSM_CLK_CTL_PHYS,
917 .ioext.appsz = MSM_CLK_CTL_SIZE,
918};
919
920struct msm_camera_device_platform_data msm_camera_data_front = {
921 .camera_gpio_on = config_camera_on_gpios_front,
922 .camera_gpio_off = config_camera_off_gpios_front,
923 .ioext.csiphy = 0xA0F00000,
924 .ioext.csisz = 0x00100000,
925 .ioext.csiirq = INT_CSI_IRQ_0,
926 .ioclk.mclk_clk_rate = 24000000,
927 .ioclk.vfe_clk_rate = 192000000,
928 .ioext.appphy = MSM_CLK_CTL_PHYS,
929 .ioext.appsz = MSM_CLK_CTL_SIZE,
930};
931
932#ifdef CONFIG_OV5640
933static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
934 .mount_angle = 90
935};
936
937static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
938 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
939 ._fsrc.led_src.led_name = "flashlight",
940 ._fsrc.led_src.led_name_len = 10,
941};
942
943static struct msm_camera_sensor_flash_data flash_ov5640 = {
944 .flash_type = MSM_CAMERA_FLASH_LED,
945 .flash_src = &msm_flash_src_ov5640,
946};
947
948static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
949 .sensor_name = "ov5640",
950 .sensor_reset_enable = 1,
951 .sensor_reset = GPIO_CAM_5MP_RESET,
952 .sensor_pwd = GPIO_CAM_5MP_SHDN_EN,
953 .vcm_pwd = 0,
954 .vcm_enable = 0,
955 .pdata = &msm_camera_data_rear,
956 .flash_data = &flash_ov5640,
957 .sensor_platform_info = &ov5640_sensor_info,
958 .csi_if = 1,
959};
960
961static struct platform_device msm_camera_sensor_ov5640 = {
962 .name = "msm_camera_ov5640",
963 .dev = {
964 .platform_data = &msm_camera_sensor_ov5640_data,
965 },
966};
967#endif
968
969#ifdef CONFIG_WEBCAM_OV7692_QRD
970static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
971 .mount_angle = 90
972};
973
974static struct msm_camera_sensor_flash_data flash_ov7692 = {
975 .flash_type = MSM_CAMERA_FLASH_NONE,
976};
977
978static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
979 .sensor_name = "ov7692",
980 .sensor_reset_enable = 0,
981 .sensor_reset = 0,
982 .sensor_pwd = GPIO_CAM_3MP_PWDN,
983 .vcm_pwd = 0,
984 .vcm_enable = 0,
985 .pdata = &msm_camera_data_front,
986 .flash_data = &flash_ov7692,
987 .sensor_platform_info = &ov7692_sensor_7627a_info,
988 .csi_if = 1,
989};
990
991static struct platform_device msm_camera_sensor_ov7692 = {
992 .name = "msm_camera_ov7692",
993 .dev = {
994 .platform_data = &msm_camera_sensor_ov7692_data,
995 },
996};
997#endif
998
999static struct i2c_board_info i2c_camera_devices[] = {
1000 #ifdef CONFIG_OV5640
1001 {
1002 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
1003 },
1004 #endif
1005 #ifdef CONFIG_WEBCAM_OV7692_QRD
1006 {
1007 I2C_BOARD_INFO("ov7692", 0x78),
1008 },
1009 #endif
1010};
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301011static struct platform_device *qrd1_devices[] __initdata = {
1012 &msm_device_dmov,
1013 &msm_device_smd,
1014 &msm_device_uart1,
1015 &msm_device_uart_dm1,
1016 &msm_gsbi0_qup_i2c_device,
1017 &msm_gsbi1_qup_i2c_device,
1018 &msm_device_otg,
1019 &msm_device_gadget_peripheral,
1020 &android_usb_device,
1021 &android_pmem_device,
1022 &android_pmem_adsp_device,
Taniya Das0a5303a2011-08-23 18:47:48 +05301023 &msm_fb_device,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301024 &android_pmem_audio_device,
1025 &msm_device_snd,
1026 &msm_device_adspdec,
1027 &msm_batt_device,
Chintan Pandyab4298622012-01-04 00:06:07 +05301028#ifdef CONFIG_OV5640
1029 &msm_camera_sensor_ov5640,
1030#endif
1031#ifdef CONFIG_WEBCAM_OV7692_QRD
1032 &msm_camera_sensor_ov7692,
1033#endif
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301034 &msm_kgsl_3d0,
1035#ifdef CONFIG_BT
1036 &msm_bt_power_device,
1037#endif
Taniya Das0a5303a2011-08-23 18:47:48 +05301038 &mipi_dsi_truly_panel_device,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301039 &msm_wlan_ar6000_pm_device,
1040 &asoc_msm_pcm,
1041 &asoc_msm_dai0,
1042 &asoc_msm_dai1,
1043};
1044
1045static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
1046static int __init pmem_kernel_ebi1_size_setup(char *p)
1047{
1048 pmem_kernel_ebi1_size = memparse(p, NULL);
1049 return 0;
1050}
1051early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
1052
1053static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
1054static int __init pmem_audio_size_setup(char *p)
1055{
1056 pmem_audio_size = memparse(p, NULL);
1057 return 0;
1058}
1059early_param("pmem_audio_size", pmem_audio_size_setup);
1060
1061static void __init msm_msm7627a_allocate_memory_regions(void)
1062{
Taniya Das0a5303a2011-08-23 18:47:48 +05301063 void *addr;
1064 unsigned long size;
1065
1066 size = fb_size ? : MSM_FB_SIZE;
1067 addr = alloc_bootmem_align(size, 0x1000);
1068 msm_fb_resources[0].start = __pa(addr);
1069 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
1070 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", size,
1071 addr, __pa(addr));
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301072}
1073
1074static struct memtype_reserve msm7627a_reserve_table[] __initdata = {
1075 [MEMTYPE_SMI] = {
1076 },
1077 [MEMTYPE_EBI0] = {
1078 .flags = MEMTYPE_FLAGS_1M_ALIGN,
1079 },
1080 [MEMTYPE_EBI1] = {
1081 .flags = MEMTYPE_FLAGS_1M_ALIGN,
1082 },
1083};
1084
Taniya Das0a5303a2011-08-23 18:47:48 +05301085static struct msm_panel_common_pdata mdp_pdata = {
1086 .gpio = 97,
1087 .mdp_rev = MDP_REV_303,
1088};
1089
1090#define GPIO_LCDC_BRDG_PD 128
1091#define GPIO_LCDC_BRDG_RESET_N 129
1092#define GPIO_LCD_DSI_SEL 125
1093
1094static unsigned mipi_dsi_gpio[] = {
1095 GPIO_CFG(GPIO_LCDC_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT,
1096 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */
1097 GPIO_CFG(GPIO_LCDC_BRDG_PD, 0, GPIO_CFG_OUTPUT,
1098 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_PD */
1099};
1100
1101static unsigned lcd_dsi_sel_gpio[] = {
1102 GPIO_CFG(GPIO_LCD_DSI_SEL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
1103 GPIO_CFG_2MA),
1104};
1105
1106enum {
1107 DSI_SINGLE_LANE = 1,
1108 DSI_TWO_LANES,
1109};
1110
1111static int msm_fb_get_lane_config(void)
1112{
1113 pr_info("DSI_TWO_LANES\n");
1114 return DSI_TWO_LANES;
1115}
1116
1117static int mipi_truly_sel_mode(int video_mode)
1118{
1119 int rc = 0;
1120
1121 rc = gpio_request(GPIO_LCD_DSI_SEL, "lcd_dsi_sel");
1122 if (rc < 0)
1123 goto gpio_error;
1124
1125 rc = gpio_tlmm_config(lcd_dsi_sel_gpio[0], GPIO_CFG_ENABLE);
1126 if (rc)
1127 goto gpio_error;
1128
1129 rc = gpio_direction_output(GPIO_LCD_DSI_SEL, 1);
1130 if (!rc) {
1131 gpio_set_value_cansleep(GPIO_LCD_DSI_SEL, video_mode);
1132 return rc;
1133 } else {
1134 goto gpio_error;
1135 }
1136
1137gpio_error:
1138 pr_err("mipi_truly_sel_mode failed\n");
1139 gpio_free(GPIO_LCD_DSI_SEL);
1140 return rc;
1141}
1142
1143static int msm_fb_dsi_client_qrd1_reset(void)
1144{
1145 int rc = 0;
1146
1147 rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n");
1148 if (rc < 0) {
1149 pr_err("failed to request lcd brdg reset_n\n");
1150 return rc;
1151 }
1152
1153 rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE);
1154 if (rc < 0) {
1155 pr_err("Failed to enable LCDC Bridge reset enable\n");
1156 return rc;
1157 }
1158
1159 rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1);
1160 if (rc < 0) {
1161 pr_err("Failed GPIO bridge pd\n");
1162 gpio_free(GPIO_LCDC_BRDG_RESET_N);
1163 return rc;
1164 }
1165
1166 mipi_truly_sel_mode(1);
1167
1168 return rc;
1169}
1170
1171static int msm_fb_dsi_client_reset(void)
1172{
1173 int rc = 0;
1174
1175 rc = msm_fb_dsi_client_qrd1_reset();
1176 return rc;
1177}
1178
1179static int dsi_gpio_initialized;
1180
1181static int mipi_dsi_panel_qrd1_power(int on)
1182{
1183 int rc = 0;
1184
1185 if (!dsi_gpio_initialized) {
Chintan Pandyab4298622012-01-04 00:06:07 +05301186 rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en");
Taniya Das0a5303a2011-08-23 18:47:48 +05301187 if (rc < 0)
1188 return rc;
1189
Chintan Pandyab4298622012-01-04 00:06:07 +05301190 rc = gpio_tlmm_config(GPIO_CFG(GPIO_BACKLIGHT_EN, 0,
Jeevan Shriram72e4cc62011-11-10 14:57:22 +05301191 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1192 GPIO_CFG_ENABLE);
1193 if (rc < 0) {
1194 pr_err("failed GPIO_BACKLIGHT_EN tlmm config\n");
1195 return rc;
1196 }
1197
Chintan Pandyab4298622012-01-04 00:06:07 +05301198 rc = gpio_direction_output(GPIO_BACKLIGHT_EN, 1);
Taniya Das0a5303a2011-08-23 18:47:48 +05301199 if (rc < 0) {
1200 pr_err("failed to enable backlight\n");
Chintan Pandyab4298622012-01-04 00:06:07 +05301201 gpio_free(GPIO_BACKLIGHT_EN);
Taniya Das0a5303a2011-08-23 18:47:48 +05301202 return rc;
1203 }
1204 dsi_gpio_initialized = 1;
1205 }
1206
Chintan Pandyab4298622012-01-04 00:06:07 +05301207 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, !!on);
Taniya Das0a5303a2011-08-23 18:47:48 +05301208
1209 if (!on) {
1210 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
1211 msleep(20);
1212 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0);
1213 msleep(20);
1214 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
1215
1216 }
1217
1218 return rc;
1219}
1220
1221static int mipi_dsi_panel_power(int on)
1222{
1223 int rc = 0;
1224
1225 rc = mipi_dsi_panel_qrd1_power(on);
1226 return rc;
1227}
1228
1229#define MDP_303_VSYNC_GPIO 97
1230
1231#ifdef CONFIG_FB_MSM_MDP303
1232static struct mipi_dsi_platform_data mipi_dsi_pdata = {
1233 .vsync_gpio = MDP_303_VSYNC_GPIO,
1234 .dsi_power_save = mipi_dsi_panel_power,
1235 .dsi_client_reset = msm_fb_dsi_client_reset,
1236 .get_lane_config = msm_fb_get_lane_config,
1237};
1238#endif
1239
1240static void __init msm_fb_add_devices(void)
1241{
1242 msm_fb_register_device("mdp", &mdp_pdata);
1243 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
1244}
1245
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301246static void __init size_pmem_devices(void)
1247{
1248#ifdef CONFIG_ANDROID_PMEM
1249 android_pmem_adsp_pdata.size = pmem_adsp_size;
1250 android_pmem_pdata.size = pmem_mdp_size;
1251 android_pmem_audio_pdata.size = pmem_audio_size;
1252#endif
1253}
1254
1255static void __init reserve_memory_for(struct android_pmem_platform_data *p)
1256{
1257 msm7627a_reserve_table[p->memory_type].size += p->size;
1258}
1259
1260static void __init reserve_pmem_memory(void)
1261{
1262#ifdef CONFIG_ANDROID_PMEM
1263 reserve_memory_for(&android_pmem_adsp_pdata);
1264 reserve_memory_for(&android_pmem_pdata);
1265 reserve_memory_for(&android_pmem_audio_pdata);
1266 msm7627a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
1267#endif
1268}
1269
1270static void __init msm7627a_calculate_reserve_sizes(void)
1271{
1272 size_pmem_devices();
1273 reserve_pmem_memory();
1274}
1275
1276static int msm7627a_paddr_to_memtype(unsigned int paddr)
1277{
1278 return MEMTYPE_EBI1;
1279}
1280
1281static struct reserve_info msm7627a_reserve_info __initdata = {
1282 .memtype_reserve_table = msm7627a_reserve_table,
1283 .calculate_reserve_sizes = msm7627a_calculate_reserve_sizes,
1284 .paddr_to_memtype = msm7627a_paddr_to_memtype,
1285};
1286
1287static void __init msm7627a_reserve(void)
1288{
1289 reserve_info = &msm7627a_reserve_info;
1290 msm_reserve();
1291}
1292
1293static void __init msm_device_i2c_init(void)
1294{
1295 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
1296 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
1297}
1298
1299static struct msm_handset_platform_data hs_platform_data = {
1300 .hs_name = "7k_handset",
1301 .pwr_key_delay_ms = 500, /* 0 will disable end key */
1302};
1303
1304static struct platform_device hs_pdev = {
1305 .name = "msm-handset",
1306 .id = -1,
1307 .dev = {
1308 .platform_data = &hs_platform_data,
1309 },
1310};
1311
Pankaj Kumar3cec0582011-11-18 11:13:29 +05301312static struct platform_device msm_proccomm_regulator_dev = {
1313 .name = PROCCOMM_REGULATOR_DEV_NAME,
1314 .id = -1,
1315 .dev = {
1316 .platform_data = &msm7x27a_proccomm_regulator_data
1317 }
1318};
1319
1320static void __init msm7627a_init_regulators(void)
1321{
1322 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1323 if (rc)
1324 pr_err("%s: could not register regulator device: %d\n",
1325 __func__, rc);
1326}
1327
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301328#define UART1DM_RX_GPIO 45
1329static void __init msm_qrd1_init(void)
1330{
1331 msm7x2x_misc_init();
Pankaj Kumar3cec0582011-11-18 11:13:29 +05301332 msm7627a_init_regulators();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301333 msm_device_i2c_init();
Taniya Das7a22cdd2011-09-08 14:57:00 +05301334 qrd1_camera_gpio_cfg();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301335#ifdef CONFIG_SERIAL_MSM_HS
1336 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
1337 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
1338#endif
1339
1340#ifdef CONFIG_USB_MSM_OTG_72K
1341 msm_otg_pdata.swfi_latency = msm7627a_pm_data
1342 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
1343 msm_device_otg.dev.platform_data = &msm_otg_pdata;
1344#endif
1345 msm_device_gadget_peripheral.dev.platform_data =
Taniya Das7a22cdd2011-09-08 14:57:00 +05301346 &msm_gadget_pdata;
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301347 platform_add_devices(qrd1_devices,
Taniya Das7a22cdd2011-09-08 14:57:00 +05301348 ARRAY_SIZE(qrd1_devices));
Chintan Pandyacf467fc2011-12-01 17:11:11 +05301349 msm7627a_init_mmc();
1350
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301351#ifdef CONFIG_USB_EHCI_MSM_72K
1352 msm7627a_init_host();
1353#endif
1354 msm_pm_set_platform_data(msm7627a_pm_data,
1355 ARRAY_SIZE(msm7627a_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06001356 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Murali Nalajalaa1827842011-11-13 14:12:39 +05301357
Taniya Das0a5303a2011-08-23 18:47:48 +05301358 msm_fb_add_devices();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301359
1360#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Chintan Pandya13490c02011-12-20 13:03:36 +05301361 msm7627a_bt_power_init();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301362#endif
Taniya Dasda408822011-09-06 12:54:06 +05301363
Pankaj Kumar27c02642011-09-22 15:55:55 +05301364 msm_camera_vreg_init();
Chintan Pandyab4298622012-01-04 00:06:07 +05301365 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID, i2c_camera_devices,
1366 ARRAY_SIZE(i2c_camera_devices));
Taniya Das7a22cdd2011-09-08 14:57:00 +05301367
Taniya Dasda408822011-09-06 12:54:06 +05301368#if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) || \
1369 defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C_MODULE)
1370 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
1371 synaptic_i2c_clearpad3k,
1372 ARRAY_SIZE(synaptic_i2c_clearpad3k));
1373#endif
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301374 platform_device_register(&hs_pdev);
1375
1376#ifdef CONFIG_MSM_RPC_VIBRATOR
1377 msm_init_pmic_vibrator();
1378#endif
1379}
1380
1381static void __init qrd7627a_init_early(void)
1382{
1383 msm_msm7627a_allocate_memory_regions();
1384}
1385
1386MACHINE_START(MSM7627A_QRD1, "QRD MSM7627a QRD1")
1387 .boot_params = PHYS_OFFSET + 0x100,
1388 .map_io = msm_common_io_init,
1389 .reserve = msm7627a_reserve,
1390 .init_irq = msm_init_irq,
1391 .init_machine = msm_qrd1_init,
1392 .timer = &msm_timer,
1393 .init_early = qrd7627a_init_early,
Pankaj Kumarbf8a2a32011-10-21 11:47:21 +05301394 .handle_irq = vic_handle_irq,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301395MACHINE_END