blob: 08ec05ecf2a336d4a5b6cad7bdec36f7e4d2c7d3 [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"
51#include "pm.h"
52#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,
398 .core_clk = 1,
399 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
400 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
401 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
402 .se1_gating = SE1_GATING_DISABLE,
403 .ldo_init = msm_hsusb_ldo_init,
404 .ldo_enable = msm_hsusb_ldo_enable,
405 .chg_init = hsusb_chg_init,
406 .chg_connected = hsusb_chg_connected,
407 .chg_vbus_draw = hsusb_chg_vbus_draw,
408};
409#endif
410
411static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
412 .is_phy_status_timer_on = 1,
413};
414
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530415#ifdef CONFIG_SERIAL_MSM_HS
416static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
417 .inject_rx_on_wakeup = 1,
418 .rx_to_inject = 0xFD,
419};
420#endif
421static struct msm_pm_platform_data msm7627a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
422 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
423 .idle_supported = 1,
424 .suspend_supported = 1,
425 .idle_enabled = 1,
426 .suspend_enabled = 1,
427 .latency = 16000,
428 .residency = 20000,
429 },
430 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
431 .idle_supported = 1,
432 .suspend_supported = 1,
433 .idle_enabled = 1,
434 .suspend_enabled = 1,
435 .latency = 12000,
436 .residency = 20000,
437 },
438 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
439 .idle_supported = 1,
440 .suspend_supported = 1,
441 .idle_enabled = 0,
442 .suspend_enabled = 1,
443 .latency = 2000,
444 .residency = 0,
445 },
446 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
447 .idle_supported = 1,
448 .suspend_supported = 1,
449 .idle_enabled = 1,
450 .suspend_enabled = 1,
451 .latency = 2,
452 .residency = 0,
453 },
454};
455
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600456static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +0530457 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
458 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600459};
460
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530461static struct android_pmem_platform_data android_pmem_adsp_pdata = {
462 .name = "pmem_adsp",
463 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
464 .cached = 1,
465 .memory_type = MEMTYPE_EBI1,
466};
467
468static struct platform_device android_pmem_adsp_device = {
469 .name = "android_pmem",
470 .id = 1,
471 .dev = { .platform_data = &android_pmem_adsp_pdata },
472};
473
474static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
475static int __init pmem_mdp_size_setup(char *p)
476{
477 pmem_mdp_size = memparse(p, NULL);
478 return 0;
479}
480
481early_param("pmem_mdp_size", pmem_mdp_size_setup);
482
483static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
484static int __init pmem_adsp_size_setup(char *p)
485{
486 pmem_adsp_size = memparse(p, NULL);
487 return 0;
488}
489
490early_param("pmem_adsp_size", pmem_adsp_size_setup);
491
492static unsigned fb_size = MSM_FB_SIZE;
493static int __init fb_size_setup(char *p)
494{
495 fb_size = memparse(p, NULL);
496 return 0;
497}
498
499early_param("fb_size", fb_size_setup);
500
Taniya Das0a5303a2011-08-23 18:47:48 +0530501static struct resource msm_fb_resources[] = {
502 {
503 .flags = IORESOURCE_DMA,
504 }
505};
506
507static int msm_fb_detect_panel(const char *name)
508{
509 int ret;
510
511 if (!strncmp(name, "mipi_video_truly_wvga", 21))
512 ret = 0;
513 else
514 ret = -ENODEV;
515
516 return ret;
517}
518
519static int mipi_truly_set_bl(int on)
520{
Chintan Pandyab4298622012-01-04 00:06:07 +0530521 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, !!on);
Taniya Das0a5303a2011-08-23 18:47:48 +0530522
523 return 1;
524}
525
526static struct msm_fb_platform_data msm_fb_pdata = {
527 .detect_client = msm_fb_detect_panel,
528};
529
530static struct platform_device msm_fb_device = {
531 .name = "msm_fb",
532 .id = 0,
533 .num_resources = ARRAY_SIZE(msm_fb_resources),
534 .resource = msm_fb_resources,
535 .dev = {
536 .platform_data = &msm_fb_pdata,
537 }
538};
539
540static struct msm_panel_common_pdata mipi_truly_pdata = {
541 .pmic_backlight = mipi_truly_set_bl,
542};
543
544static struct platform_device mipi_dsi_truly_panel_device = {
545 .name = "mipi_truly",
546 .id = 0,
547 .dev = {
548 .platform_data = &mipi_truly_pdata,
549 }
550};
551
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530552#define SND(desc, num) { .name = #desc, .id = num }
553static struct snd_endpoint snd_endpoints_list[] = {
554 SND(HANDSET, 0),
555 SND(MONO_HEADSET, 2),
556 SND(HEADSET, 3),
557 SND(SPEAKER, 6),
558 SND(TTY_HEADSET, 8),
559 SND(TTY_VCO, 9),
560 SND(TTY_HCO, 10),
561 SND(BT, 12),
562 SND(IN_S_SADC_OUT_HANDSET, 16),
563 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
564 SND(FM_DIGITAL_STEREO_HEADSET, 26),
565 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
566 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
Shashi Kumar64e07602011-10-11 13:18:57 +0530567 SND(STEREO_HEADSET_AND_SPEAKER, 31),
Phani Kumar Alladad6971252011-10-19 10:50:15 +0530568 SND(CURRENT, 0x7FFFFFFE),
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530569 SND(FM_ANALOG_STEREO_HEADSET, 35),
570 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
571};
572#undef SND
573
574static struct msm_snd_endpoints msm_device_snd_endpoints = {
575 .endpoints = snd_endpoints_list,
576 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
577};
578
579static struct platform_device msm_device_snd = {
580 .name = "msm_snd",
581 .id = -1,
582 .dev = {
583 .platform_data = &msm_device_snd_endpoints
584 },
585};
586
587#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
588 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
589 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
590 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
591 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
592 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
593#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
594 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
595 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
596 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
597 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
598 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
599#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
600 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
601 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
602 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
603 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
604 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
605#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
606 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
607 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
608 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
609 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
610 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
611#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
612
613static unsigned int dec_concurrency_table[] = {
614 /* Audio LP */
615 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
616 0, 0, 0,
617
618 /* Concurrency 1 */
619 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
620 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
621 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
622 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
623 (DEC4_FORMAT),
624
625 /* Concurrency 2 */
626 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
627 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
628 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
629 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
630 (DEC4_FORMAT),
631
632 /* Concurrency 3 */
633 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
634 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
635 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
636 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
637 (DEC4_FORMAT),
638
639 /* Concurrency 4 */
640 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
641 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
642 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
643 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
644 (DEC4_FORMAT),
645
646 /* Concurrency 5 */
647 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
648 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
649 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
650 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
651 (DEC4_FORMAT),
652
653 /* Concurrency 6 */
654 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
655 0, 0, 0, 0,
656
657 /* Concurrency 7 */
658 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
659 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
660 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
661 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
662 (DEC4_FORMAT),
663};
664
665#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
666 .module_queueid = queueid, .module_decid = decid, \
667 .nr_codec_support = nr_codec}
668
669static struct msm_adspdec_info dec_info_list[] = {
670 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
671 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
672 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
673 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
674 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
675};
676
677static struct msm_adspdec_database msm_device_adspdec_database = {
678 .num_dec = ARRAY_SIZE(dec_info_list),
679 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
680 ARRAY_SIZE(dec_info_list)),
681 .dec_concurrency_table = dec_concurrency_table,
682 .dec_info_list = dec_info_list,
683};
684
685static struct platform_device msm_device_adspdec = {
686 .name = "msm_adspdec",
687 .id = -1,
688 .dev = {
689 .platform_data = &msm_device_adspdec_database
690 },
691};
692
693static struct android_pmem_platform_data android_pmem_audio_pdata = {
694 .name = "pmem_audio",
695 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
696 .cached = 0,
697 .memory_type = MEMTYPE_EBI1,
698};
699
700static struct platform_device android_pmem_audio_device = {
701 .name = "android_pmem",
702 .id = 2,
703 .dev = { .platform_data = &android_pmem_audio_pdata },
704};
705
706static struct android_pmem_platform_data android_pmem_pdata = {
707 .name = "pmem",
708 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
709 .cached = 1,
710 .memory_type = MEMTYPE_EBI1,
711};
712static struct platform_device android_pmem_device = {
713 .name = "android_pmem",
714 .id = 0,
715 .dev = { .platform_data = &android_pmem_pdata },
716};
717
718static u32 msm_calculate_batt_capacity(u32 current_voltage);
719
720static struct msm_psy_batt_pdata msm_psy_batt_data = {
721 .voltage_min_design = 2800,
722 .voltage_max_design = 4300,
723 .avail_chg_sources = AC_CHG | USB_CHG ,
724 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
725 .calculate_capacity = &msm_calculate_batt_capacity,
726};
727
728static u32 msm_calculate_batt_capacity(u32 current_voltage)
729{
730 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
731 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
732
733 return (current_voltage - low_voltage) * 100
734 / (high_voltage - low_voltage);
735}
736
737static struct platform_device msm_batt_device = {
738 .name = "msm-battery",
739 .id = -1,
740 .dev.platform_data = &msm_psy_batt_data,
741};
742
Chintan Pandyab4298622012-01-04 00:06:07 +0530743#ifdef CONFIG_MSM_CAMERA
744static uint32_t camera_off_gpio_table[] = {
745 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
746};
747
748static uint32_t camera_on_gpio_table[] = {
749 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
750};
751
752static void qrd1_camera_gpio_cfg(void)
753{
754
755 int rc = 0;
756
757 rc = gpio_request(GPIO_CAM_5MP_SHDN_EN, "ov5640");
758 if (rc < 0)
759 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
760 __func__);
761
762
763 rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_5MP_SHDN_EN, 0,
764 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
765 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
766 if (rc < 0) {
767 pr_err("%s: unable to enable Power Down gpio for main"
768 "camera!\n", __func__);
769 gpio_free(GPIO_CAM_5MP_SHDN_EN);
770 }
771
772
773 rc = gpio_request(GPIO_CAM_5MP_RESET, "ov5640");
774 if (rc < 0) {
775 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
776 __func__);
777 gpio_free(GPIO_CAM_5MP_SHDN_EN);
778 }
779
780
781 rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_5MP_RESET, 0,
782 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
783 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
784 if (rc < 0) {
785 pr_err("%s: unable to enable reset gpio for main camera!\n",
786 __func__);
787 gpio_free(GPIO_CAM_5MP_RESET);
788 }
789
790 rc = gpio_request(GPIO_CAM_3MP_PWDN, "ov7692");
791 if (rc < 0)
792 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
793 __func__);
794
795 rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_3MP_PWDN, 0,
796 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
797 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
798 if (rc < 0) {
799 pr_err("%s: unable to enable Power Down gpio for front"
800 "camera!\n", __func__);
801 gpio_free(GPIO_CAM_3MP_PWDN);
802 }
803
804 gpio_direction_output(GPIO_CAM_5MP_SHDN_EN, 1);
805 gpio_direction_output(GPIO_CAM_5MP_RESET, 1);
806 gpio_direction_output(GPIO_CAM_3MP_PWDN, 1);
807}
808
809#endif
810static struct regulator_bulk_data regs_camera[] = {
811 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
812 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
813 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
814};
815
816static void __init msm_camera_vreg_init(void)
817{
818 int rc;
819
820 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
821 if (rc) {
822 pr_err("%s: could not get regulators: %d\n", __func__, rc);
823 return;
824 }
825
826 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
827 if (rc) {
828 pr_err("%s: could not set voltages: %d\n", __func__, rc);
829 return;
830 }
831}
832
833static void msm_camera_vreg_config(int vreg_en)
834{
835 int rc = vreg_en ?
836 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
837 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
838
839 if (rc)
840 pr_err("%s: could not %sable regulators: %d\n",
841 __func__, vreg_en ? "en" : "dis", rc);
842}
843static int config_gpio_table(uint32_t *table, int len)
844{
845 int rc = 0, i = 0;
846
847 for (i = 0; i < len; i++) {
848 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
849 if (rc) {
850 pr_err("%s not able to get gpio\n", __func__);
851 for (i--; i >= 0; i--)
852 gpio_tlmm_config(camera_off_gpio_table[i],
853 GPIO_CFG_ENABLE);
854 break;
855 }
856 }
857 return rc;
858}
859
860static int config_camera_on_gpios_rear(void)
861{
862 int rc = 0;
863
864 msm_camera_vreg_config(1);
865
866 rc = config_gpio_table(camera_on_gpio_table,
867 ARRAY_SIZE(camera_on_gpio_table));
868 if (rc < 0) {
869 pr_err("%s: CAMSENSOR gpio table request"
870 "failed\n", __func__);
871 return rc;
872 }
873
874 return rc;
875}
876
877static void config_camera_off_gpios_rear(void)
878{
879 msm_camera_vreg_config(0);
880 config_gpio_table(camera_off_gpio_table,
881 ARRAY_SIZE(camera_off_gpio_table));
882}
883
884static int config_camera_on_gpios_front(void)
885{
886 int rc = 0;
887
888 msm_camera_vreg_config(1);
889
890 rc = config_gpio_table(camera_on_gpio_table,
891 ARRAY_SIZE(camera_on_gpio_table));
892 if (rc < 0) {
893 pr_err("%s: CAMSENSOR gpio table request"
894 "failed\n", __func__);
895 return rc;
896 }
897
898 return rc;
899}
900
901static void config_camera_off_gpios_front(void)
902{
903 msm_camera_vreg_config(0);
904
905 config_gpio_table(camera_off_gpio_table,
906 ARRAY_SIZE(camera_off_gpio_table));
907}
908
909struct msm_camera_device_platform_data msm_camera_data_rear = {
910 .camera_gpio_on = config_camera_on_gpios_rear,
911 .camera_gpio_off = config_camera_off_gpios_rear,
912 .ioext.csiphy = 0xA1000000,
913 .ioext.csisz = 0x00100000,
914 .ioext.csiirq = INT_CSI_IRQ_1,
915 .ioclk.mclk_clk_rate = 24000000,
916 .ioclk.vfe_clk_rate = 192000000,
917 .ioext.appphy = MSM_CLK_CTL_PHYS,
918 .ioext.appsz = MSM_CLK_CTL_SIZE,
919};
920
921struct msm_camera_device_platform_data msm_camera_data_front = {
922 .camera_gpio_on = config_camera_on_gpios_front,
923 .camera_gpio_off = config_camera_off_gpios_front,
924 .ioext.csiphy = 0xA0F00000,
925 .ioext.csisz = 0x00100000,
926 .ioext.csiirq = INT_CSI_IRQ_0,
927 .ioclk.mclk_clk_rate = 24000000,
928 .ioclk.vfe_clk_rate = 192000000,
929 .ioext.appphy = MSM_CLK_CTL_PHYS,
930 .ioext.appsz = MSM_CLK_CTL_SIZE,
931};
932
933#ifdef CONFIG_OV5640
934static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
935 .mount_angle = 90
936};
937
938static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
939 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
940 ._fsrc.led_src.led_name = "flashlight",
941 ._fsrc.led_src.led_name_len = 10,
942};
943
944static struct msm_camera_sensor_flash_data flash_ov5640 = {
945 .flash_type = MSM_CAMERA_FLASH_LED,
946 .flash_src = &msm_flash_src_ov5640,
947};
948
949static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
950 .sensor_name = "ov5640",
951 .sensor_reset_enable = 1,
952 .sensor_reset = GPIO_CAM_5MP_RESET,
953 .sensor_pwd = GPIO_CAM_5MP_SHDN_EN,
954 .vcm_pwd = 0,
955 .vcm_enable = 0,
956 .pdata = &msm_camera_data_rear,
957 .flash_data = &flash_ov5640,
958 .sensor_platform_info = &ov5640_sensor_info,
959 .csi_if = 1,
960};
961
962static struct platform_device msm_camera_sensor_ov5640 = {
963 .name = "msm_camera_ov5640",
964 .dev = {
965 .platform_data = &msm_camera_sensor_ov5640_data,
966 },
967};
968#endif
969
970#ifdef CONFIG_WEBCAM_OV7692_QRD
971static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
972 .mount_angle = 90
973};
974
975static struct msm_camera_sensor_flash_data flash_ov7692 = {
976 .flash_type = MSM_CAMERA_FLASH_NONE,
977};
978
979static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
980 .sensor_name = "ov7692",
981 .sensor_reset_enable = 0,
982 .sensor_reset = 0,
983 .sensor_pwd = GPIO_CAM_3MP_PWDN,
984 .vcm_pwd = 0,
985 .vcm_enable = 0,
986 .pdata = &msm_camera_data_front,
987 .flash_data = &flash_ov7692,
988 .sensor_platform_info = &ov7692_sensor_7627a_info,
989 .csi_if = 1,
990};
991
992static struct platform_device msm_camera_sensor_ov7692 = {
993 .name = "msm_camera_ov7692",
994 .dev = {
995 .platform_data = &msm_camera_sensor_ov7692_data,
996 },
997};
998#endif
999
1000static struct i2c_board_info i2c_camera_devices[] = {
1001 #ifdef CONFIG_OV5640
1002 {
1003 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
1004 },
1005 #endif
1006 #ifdef CONFIG_WEBCAM_OV7692_QRD
1007 {
1008 I2C_BOARD_INFO("ov7692", 0x78),
1009 },
1010 #endif
1011};
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301012static struct platform_device *qrd1_devices[] __initdata = {
1013 &msm_device_dmov,
1014 &msm_device_smd,
1015 &msm_device_uart1,
1016 &msm_device_uart_dm1,
1017 &msm_gsbi0_qup_i2c_device,
1018 &msm_gsbi1_qup_i2c_device,
1019 &msm_device_otg,
1020 &msm_device_gadget_peripheral,
1021 &android_usb_device,
1022 &android_pmem_device,
1023 &android_pmem_adsp_device,
Taniya Das0a5303a2011-08-23 18:47:48 +05301024 &msm_fb_device,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301025 &android_pmem_audio_device,
1026 &msm_device_snd,
1027 &msm_device_adspdec,
1028 &msm_batt_device,
Chintan Pandyab4298622012-01-04 00:06:07 +05301029#ifdef CONFIG_OV5640
1030 &msm_camera_sensor_ov5640,
1031#endif
1032#ifdef CONFIG_WEBCAM_OV7692_QRD
1033 &msm_camera_sensor_ov7692,
1034#endif
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301035 &msm_kgsl_3d0,
1036#ifdef CONFIG_BT
1037 &msm_bt_power_device,
1038#endif
Taniya Das0a5303a2011-08-23 18:47:48 +05301039 &mipi_dsi_truly_panel_device,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301040 &msm_wlan_ar6000_pm_device,
1041 &asoc_msm_pcm,
1042 &asoc_msm_dai0,
1043 &asoc_msm_dai1,
1044};
1045
1046static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
1047static int __init pmem_kernel_ebi1_size_setup(char *p)
1048{
1049 pmem_kernel_ebi1_size = memparse(p, NULL);
1050 return 0;
1051}
1052early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
1053
1054static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
1055static int __init pmem_audio_size_setup(char *p)
1056{
1057 pmem_audio_size = memparse(p, NULL);
1058 return 0;
1059}
1060early_param("pmem_audio_size", pmem_audio_size_setup);
1061
1062static void __init msm_msm7627a_allocate_memory_regions(void)
1063{
Taniya Das0a5303a2011-08-23 18:47:48 +05301064 void *addr;
1065 unsigned long size;
1066
1067 size = fb_size ? : MSM_FB_SIZE;
1068 addr = alloc_bootmem_align(size, 0x1000);
1069 msm_fb_resources[0].start = __pa(addr);
1070 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
1071 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", size,
1072 addr, __pa(addr));
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301073}
1074
1075static struct memtype_reserve msm7627a_reserve_table[] __initdata = {
1076 [MEMTYPE_SMI] = {
1077 },
1078 [MEMTYPE_EBI0] = {
1079 .flags = MEMTYPE_FLAGS_1M_ALIGN,
1080 },
1081 [MEMTYPE_EBI1] = {
1082 .flags = MEMTYPE_FLAGS_1M_ALIGN,
1083 },
1084};
1085
Taniya Das0a5303a2011-08-23 18:47:48 +05301086static struct msm_panel_common_pdata mdp_pdata = {
1087 .gpio = 97,
1088 .mdp_rev = MDP_REV_303,
1089};
1090
1091#define GPIO_LCDC_BRDG_PD 128
1092#define GPIO_LCDC_BRDG_RESET_N 129
1093#define GPIO_LCD_DSI_SEL 125
1094
1095static unsigned mipi_dsi_gpio[] = {
1096 GPIO_CFG(GPIO_LCDC_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT,
1097 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */
1098 GPIO_CFG(GPIO_LCDC_BRDG_PD, 0, GPIO_CFG_OUTPUT,
1099 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_PD */
1100};
1101
1102static unsigned lcd_dsi_sel_gpio[] = {
1103 GPIO_CFG(GPIO_LCD_DSI_SEL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
1104 GPIO_CFG_2MA),
1105};
1106
1107enum {
1108 DSI_SINGLE_LANE = 1,
1109 DSI_TWO_LANES,
1110};
1111
1112static int msm_fb_get_lane_config(void)
1113{
1114 pr_info("DSI_TWO_LANES\n");
1115 return DSI_TWO_LANES;
1116}
1117
1118static int mipi_truly_sel_mode(int video_mode)
1119{
1120 int rc = 0;
1121
1122 rc = gpio_request(GPIO_LCD_DSI_SEL, "lcd_dsi_sel");
1123 if (rc < 0)
1124 goto gpio_error;
1125
1126 rc = gpio_tlmm_config(lcd_dsi_sel_gpio[0], GPIO_CFG_ENABLE);
1127 if (rc)
1128 goto gpio_error;
1129
1130 rc = gpio_direction_output(GPIO_LCD_DSI_SEL, 1);
1131 if (!rc) {
1132 gpio_set_value_cansleep(GPIO_LCD_DSI_SEL, video_mode);
1133 return rc;
1134 } else {
1135 goto gpio_error;
1136 }
1137
1138gpio_error:
1139 pr_err("mipi_truly_sel_mode failed\n");
1140 gpio_free(GPIO_LCD_DSI_SEL);
1141 return rc;
1142}
1143
1144static int msm_fb_dsi_client_qrd1_reset(void)
1145{
1146 int rc = 0;
1147
1148 rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n");
1149 if (rc < 0) {
1150 pr_err("failed to request lcd brdg reset_n\n");
1151 return rc;
1152 }
1153
1154 rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE);
1155 if (rc < 0) {
1156 pr_err("Failed to enable LCDC Bridge reset enable\n");
1157 return rc;
1158 }
1159
1160 rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1);
1161 if (rc < 0) {
1162 pr_err("Failed GPIO bridge pd\n");
1163 gpio_free(GPIO_LCDC_BRDG_RESET_N);
1164 return rc;
1165 }
1166
1167 mipi_truly_sel_mode(1);
1168
1169 return rc;
1170}
1171
1172static int msm_fb_dsi_client_reset(void)
1173{
1174 int rc = 0;
1175
1176 rc = msm_fb_dsi_client_qrd1_reset();
1177 return rc;
1178}
1179
1180static int dsi_gpio_initialized;
1181
1182static int mipi_dsi_panel_qrd1_power(int on)
1183{
1184 int rc = 0;
1185
1186 if (!dsi_gpio_initialized) {
Chintan Pandyab4298622012-01-04 00:06:07 +05301187 rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en");
Taniya Das0a5303a2011-08-23 18:47:48 +05301188 if (rc < 0)
1189 return rc;
1190
Chintan Pandyab4298622012-01-04 00:06:07 +05301191 rc = gpio_tlmm_config(GPIO_CFG(GPIO_BACKLIGHT_EN, 0,
Jeevan Shriram72e4cc62011-11-10 14:57:22 +05301192 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1193 GPIO_CFG_ENABLE);
1194 if (rc < 0) {
1195 pr_err("failed GPIO_BACKLIGHT_EN tlmm config\n");
1196 return rc;
1197 }
1198
Chintan Pandyab4298622012-01-04 00:06:07 +05301199 rc = gpio_direction_output(GPIO_BACKLIGHT_EN, 1);
Taniya Das0a5303a2011-08-23 18:47:48 +05301200 if (rc < 0) {
1201 pr_err("failed to enable backlight\n");
Chintan Pandyab4298622012-01-04 00:06:07 +05301202 gpio_free(GPIO_BACKLIGHT_EN);
Taniya Das0a5303a2011-08-23 18:47:48 +05301203 return rc;
1204 }
1205 dsi_gpio_initialized = 1;
1206 }
1207
Chintan Pandyab4298622012-01-04 00:06:07 +05301208 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, !!on);
Taniya Das0a5303a2011-08-23 18:47:48 +05301209
1210 if (!on) {
1211 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
1212 msleep(20);
1213 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0);
1214 msleep(20);
1215 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
1216
1217 }
1218
1219 return rc;
1220}
1221
1222static int mipi_dsi_panel_power(int on)
1223{
1224 int rc = 0;
1225
1226 rc = mipi_dsi_panel_qrd1_power(on);
1227 return rc;
1228}
1229
1230#define MDP_303_VSYNC_GPIO 97
1231
1232#ifdef CONFIG_FB_MSM_MDP303
1233static struct mipi_dsi_platform_data mipi_dsi_pdata = {
1234 .vsync_gpio = MDP_303_VSYNC_GPIO,
1235 .dsi_power_save = mipi_dsi_panel_power,
1236 .dsi_client_reset = msm_fb_dsi_client_reset,
1237 .get_lane_config = msm_fb_get_lane_config,
1238};
1239#endif
1240
1241static void __init msm_fb_add_devices(void)
1242{
1243 msm_fb_register_device("mdp", &mdp_pdata);
1244 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
1245}
1246
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301247static void __init size_pmem_devices(void)
1248{
1249#ifdef CONFIG_ANDROID_PMEM
1250 android_pmem_adsp_pdata.size = pmem_adsp_size;
1251 android_pmem_pdata.size = pmem_mdp_size;
1252 android_pmem_audio_pdata.size = pmem_audio_size;
1253#endif
1254}
1255
1256static void __init reserve_memory_for(struct android_pmem_platform_data *p)
1257{
1258 msm7627a_reserve_table[p->memory_type].size += p->size;
1259}
1260
1261static void __init reserve_pmem_memory(void)
1262{
1263#ifdef CONFIG_ANDROID_PMEM
1264 reserve_memory_for(&android_pmem_adsp_pdata);
1265 reserve_memory_for(&android_pmem_pdata);
1266 reserve_memory_for(&android_pmem_audio_pdata);
1267 msm7627a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
1268#endif
1269}
1270
1271static void __init msm7627a_calculate_reserve_sizes(void)
1272{
1273 size_pmem_devices();
1274 reserve_pmem_memory();
1275}
1276
1277static int msm7627a_paddr_to_memtype(unsigned int paddr)
1278{
1279 return MEMTYPE_EBI1;
1280}
1281
1282static struct reserve_info msm7627a_reserve_info __initdata = {
1283 .memtype_reserve_table = msm7627a_reserve_table,
1284 .calculate_reserve_sizes = msm7627a_calculate_reserve_sizes,
1285 .paddr_to_memtype = msm7627a_paddr_to_memtype,
1286};
1287
1288static void __init msm7627a_reserve(void)
1289{
1290 reserve_info = &msm7627a_reserve_info;
1291 msm_reserve();
1292}
1293
1294static void __init msm_device_i2c_init(void)
1295{
1296 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
1297 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
1298}
1299
1300static struct msm_handset_platform_data hs_platform_data = {
1301 .hs_name = "7k_handset",
1302 .pwr_key_delay_ms = 500, /* 0 will disable end key */
1303};
1304
1305static struct platform_device hs_pdev = {
1306 .name = "msm-handset",
1307 .id = -1,
1308 .dev = {
1309 .platform_data = &hs_platform_data,
1310 },
1311};
1312
Pankaj Kumar3cec0582011-11-18 11:13:29 +05301313static struct platform_device msm_proccomm_regulator_dev = {
1314 .name = PROCCOMM_REGULATOR_DEV_NAME,
1315 .id = -1,
1316 .dev = {
1317 .platform_data = &msm7x27a_proccomm_regulator_data
1318 }
1319};
1320
1321static void __init msm7627a_init_regulators(void)
1322{
1323 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1324 if (rc)
1325 pr_err("%s: could not register regulator device: %d\n",
1326 __func__, rc);
1327}
1328
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301329#define UART1DM_RX_GPIO 45
1330static void __init msm_qrd1_init(void)
1331{
1332 msm7x2x_misc_init();
Pankaj Kumar3cec0582011-11-18 11:13:29 +05301333 msm7627a_init_regulators();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301334 msm_device_i2c_init();
Taniya Das7a22cdd2011-09-08 14:57:00 +05301335 qrd1_camera_gpio_cfg();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301336#ifdef CONFIG_SERIAL_MSM_HS
1337 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
1338 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
1339#endif
1340
1341#ifdef CONFIG_USB_MSM_OTG_72K
1342 msm_otg_pdata.swfi_latency = msm7627a_pm_data
1343 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
1344 msm_device_otg.dev.platform_data = &msm_otg_pdata;
1345#endif
1346 msm_device_gadget_peripheral.dev.platform_data =
Taniya Das7a22cdd2011-09-08 14:57:00 +05301347 &msm_gadget_pdata;
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301348 platform_add_devices(qrd1_devices,
Taniya Das7a22cdd2011-09-08 14:57:00 +05301349 ARRAY_SIZE(qrd1_devices));
Chintan Pandyacf467fc2011-12-01 17:11:11 +05301350 msm7627a_init_mmc();
1351
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301352#ifdef CONFIG_USB_EHCI_MSM_72K
1353 msm7627a_init_host();
1354#endif
1355 msm_pm_set_platform_data(msm7627a_pm_data,
1356 ARRAY_SIZE(msm7627a_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06001357 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Murali Nalajalaa1827842011-11-13 14:12:39 +05301358
Taniya Das0a5303a2011-08-23 18:47:48 +05301359 msm_fb_add_devices();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301360
1361#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Chintan Pandya13490c02011-12-20 13:03:36 +05301362 msm7627a_bt_power_init();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301363#endif
Taniya Dasda408822011-09-06 12:54:06 +05301364
Pankaj Kumar27c02642011-09-22 15:55:55 +05301365 msm_camera_vreg_init();
Chintan Pandyab4298622012-01-04 00:06:07 +05301366 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID, i2c_camera_devices,
1367 ARRAY_SIZE(i2c_camera_devices));
Taniya Das7a22cdd2011-09-08 14:57:00 +05301368
Taniya Dasda408822011-09-06 12:54:06 +05301369#if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) || \
1370 defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C_MODULE)
1371 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
1372 synaptic_i2c_clearpad3k,
1373 ARRAY_SIZE(synaptic_i2c_clearpad3k));
1374#endif
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301375 platform_device_register(&hs_pdev);
1376
1377#ifdef CONFIG_MSM_RPC_VIBRATOR
1378 msm_init_pmic_vibrator();
1379#endif
1380}
1381
1382static void __init qrd7627a_init_early(void)
1383{
1384 msm_msm7627a_allocate_memory_regions();
1385}
1386
1387MACHINE_START(MSM7627A_QRD1, "QRD MSM7627a QRD1")
1388 .boot_params = PHYS_OFFSET + 0x100,
1389 .map_io = msm_common_io_init,
1390 .reserve = msm7627a_reserve,
1391 .init_irq = msm_init_irq,
1392 .init_machine = msm_qrd1_init,
1393 .timer = &msm_timer,
1394 .init_early = qrd7627a_init_early,
Pankaj Kumarbf8a2a32011-10-21 11:47:21 +05301395 .handle_irq = vic_handle_irq,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301396MACHINE_END