blob: e46da5bff44793fabcdc195e07d7d452e84bc4f7 [file] [log] [blame]
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
2 *
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>
Taniya Dasc98bfbc2011-08-23 09:58:55 +053029#include <asm/mach/mmc.h>
30#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32#include <mach/board.h>
33#include <mach/msm_iomap.h>
34#include <mach/msm_hsusb.h>
35#include <mach/rpc_hsusb.h>
36#include <mach/rpc_pmapp.h>
37#include <mach/usbdiag.h>
38#include <mach/usb_gadget_fserial.h>
39#include <mach/msm_memtypes.h>
40#include <mach/msm_serial_hs.h>
41#include <mach/vreg.h>
42#include <mach/pmic.h>
43#include <mach/socinfo.h>
44#include <mach/vreg.h>
45#include <mach/rpc_pmapp.h>
46#include <mach/msm_battery.h>
47#include <mach/rpc_server_handset.h>
48#include <mach/socinfo.h>
49
50#include "devices.h"
51#include "devices-msm7x2xa.h"
52#include "pm.h"
53#include "timer.h"
54
55#define PMEM_KERNEL_EBI1_SIZE 0x3A000
56#define MSM_PMEM_AUDIO_SIZE 0x5B000
57#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
58#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
59#define BAHAMA_SLAVE_ID_FM_REG 0x02
60#define FM_GPIO 83
61
62enum {
63 GPIO_HOST_VBUS_EN = 107,
64 GPIO_BT_SYS_REST_EN = 114,
65 GPIO_WAKE_ON_WIRELESS,
66 GPIO_BACKLIGHT_EN,
Taniya Das7a22cdd2011-09-08 14:57:00 +053067 GPIO_NC,
68 GPIO_CAM_3MP_PWDN, /* CAM_VGA */
Taniya Dasc98bfbc2011-08-23 09:58:55 +053069 GPIO_WLAN_EN,
70 GPIO_CAM_5MP_SHDN_EN,
71 GPIO_CAM_5MP_RESET,
Taniya Das7a22cdd2011-09-08 14:57:00 +053072 GPIO_TP,
73 GPIO_CAM_GP_CAMIF_RESET,
Taniya Dasc98bfbc2011-08-23 09:58:55 +053074};
75
76 /* FM Platform power and shutdown routines */
77#define FPGA_MSM_CNTRL_REG2 0x90008010
78
79static void config_pcm_i2s_mode(int mode)
80{
81 void __iomem *cfg_ptr;
82 u8 reg2;
83
84 cfg_ptr = ioremap_nocache(FPGA_MSM_CNTRL_REG2, sizeof(char));
85
86 if (!cfg_ptr)
87 return;
88 if (mode) {
89 /*enable the pcm mode in FPGA*/
90 reg2 = readb_relaxed(cfg_ptr);
91 if (reg2 == 0) {
92 reg2 = 1;
93 writeb_relaxed(reg2, cfg_ptr);
94 }
95 } else {
96 /*enable i2s mode in FPGA*/
97 reg2 = readb_relaxed(cfg_ptr);
98 if (reg2 == 1) {
99 reg2 = 0;
100 writeb_relaxed(reg2, cfg_ptr);
101 }
102 }
103 iounmap(cfg_ptr);
104}
105
106static unsigned fm_i2s_config_power_on[] = {
107 /*FM_I2S_SD*/
108 GPIO_CFG(68, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
109 /*FM_I2S_WS*/
110 GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
111 /*FM_I2S_SCK*/
112 GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
113};
114
115static unsigned fm_i2s_config_power_off[] = {
116 /*FM_I2S_SD*/
117 GPIO_CFG(68, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
118 /*FM_I2S_WS*/
119 GPIO_CFG(70, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
120 /*FM_I2S_SCK*/
121 GPIO_CFG(71, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
122};
123
124static unsigned bt_config_power_on[] = {
125 /*RFR*/
126 GPIO_CFG(43, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
127 /*CTS*/
128 GPIO_CFG(44, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
129 /*RX*/
130 GPIO_CFG(45, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
131 /*TX*/
132 GPIO_CFG(46, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
133};
134static unsigned bt_config_pcm_on[] = {
135 /*PCM_DOUT*/
136 GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
137 /*PCM_DIN*/
138 GPIO_CFG(69, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
139 /*PCM_SYNC*/
140 GPIO_CFG(70, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
141 /*PCM_CLK*/
142 GPIO_CFG(71, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
143};
144static unsigned bt_config_power_off[] = {
145 /*RFR*/
146 GPIO_CFG(43, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
147 /*CTS*/
148 GPIO_CFG(44, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
149 /*RX*/
150 GPIO_CFG(45, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
151 /*TX*/
152 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
153};
154static unsigned bt_config_pcm_off[] = {
155 /*PCM_DOUT*/
156 GPIO_CFG(68, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
157 /*PCM_DIN*/
158 GPIO_CFG(69, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
159 /*PCM_SYNC*/
160 GPIO_CFG(70, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
161 /*PCM_CLK*/
162 GPIO_CFG(71, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
163};
164
165
166static int config_i2s(int mode)
167{
168 int pin, rc = 0;
169
170 if (mode == FM_I2S_ON) {
171 if (machine_is_msm7627a_qrd1())
172 config_pcm_i2s_mode(0);
173 pr_err("%s mode = FM_I2S_ON", __func__);
174 for (pin = 0; pin < ARRAY_SIZE(fm_i2s_config_power_on);
175 pin++) {
176 rc = gpio_tlmm_config(
177 fm_i2s_config_power_on[pin],
178 GPIO_CFG_ENABLE
179 );
180 if (rc < 0)
181 return rc;
182 }
183 } else if (mode == FM_I2S_OFF) {
184 pr_err("%s mode = FM_I2S_OFF", __func__);
185 for (pin = 0; pin < ARRAY_SIZE(fm_i2s_config_power_off);
186 pin++) {
187 rc = gpio_tlmm_config(
188 fm_i2s_config_power_off[pin],
189 GPIO_CFG_ENABLE
190 );
191 if (rc < 0)
192 return rc;
193 }
194 }
195 return rc;
196}
197static int config_pcm(int mode)
198{
199 int pin, rc = 0;
200
201 if (mode == BT_PCM_ON) {
202 if (machine_is_msm7627a_qrd1())
203 config_pcm_i2s_mode(1);
204 pr_err("%s mode =BT_PCM_ON", __func__);
205 for (pin = 0; pin < ARRAY_SIZE(bt_config_pcm_on);
206 pin++) {
207 rc = gpio_tlmm_config(bt_config_pcm_on[pin],
208 GPIO_CFG_ENABLE);
209 if (rc < 0)
210 return rc;
211 }
212 } else if (mode == BT_PCM_OFF) {
213 pr_err("%s mode =BT_PCM_OFF", __func__);
214 for (pin = 0; pin < ARRAY_SIZE(bt_config_pcm_off);
215 pin++) {
216 rc = gpio_tlmm_config(bt_config_pcm_off[pin],
217 GPIO_CFG_ENABLE);
218 if (rc < 0)
219 return rc;
220 }
221
222 }
223
224 return rc;
225}
226
227static int msm_bahama_setup_pcm_i2s(int mode)
228{
229 int fm_state = 0, bt_state = 0;
230 int rc = 0;
231 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
232
233 fm_state = marimba_get_fm_status(&config);
234 bt_state = marimba_get_bt_status(&config);
235
236 switch (mode) {
237 case BT_PCM_ON:
238 case BT_PCM_OFF:
239 if (!fm_state)
240 rc = config_pcm(mode);
241 break;
242 case FM_I2S_ON:
243 rc = config_i2s(mode);
244 break;
245 case FM_I2S_OFF:
246 if (bt_state)
247 rc = config_pcm(BT_PCM_ON);
248 else
249 rc = config_i2s(mode);
250 break;
251 default:
252 rc = -EIO;
253 pr_err("%s:Unsupported mode", __func__);
254 }
255 return rc;
256}
257
258static int bt_set_gpio(int on)
259{
260 int rc = 0;
261 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
262
263 if (on) {
264 rc = gpio_direction_output(GPIO_BT_SYS_REST_EN, 1);
265 msleep(100);
266 } else {
267 if (!marimba_get_fm_status(&config) &&
268 !marimba_get_bt_status(&config)) {
269 gpio_set_value_cansleep(GPIO_BT_SYS_REST_EN, 0);
270 rc = gpio_direction_input(GPIO_BT_SYS_REST_EN);
271 msleep(100);
272 }
273 }
274 if (rc)
275 pr_err("%s: BT sys_reset_en GPIO : Error", __func__);
276
277 return rc;
278}
279static struct vreg *fm_regulator;
280static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
281{
282 int rc = 0;
283 const char *id = "FMPW";
284 uint32_t irqcfg;
285 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
286 u8 value;
287
288 /* Voting for 1.8V Regulator */
289 fm_regulator = vreg_get(NULL , "msme1");
290 if (IS_ERR(fm_regulator)) {
291 pr_err("%s: vreg get failed with : (%ld)\n",
292 __func__, PTR_ERR(fm_regulator));
293 return -EINVAL;
294 }
295
296 /* Set the voltage level to 1.8V */
297 rc = vreg_set_level(fm_regulator, 1800);
298 if (rc < 0) {
299 pr_err("%s: set regulator level failed with :(%d)\n",
300 __func__, rc);
301 goto fm_vreg_fail;
302 }
303
304 /* Enabling the 1.8V regulator */
305 rc = vreg_enable(fm_regulator);
306 if (rc) {
307 pr_err("%s: enable regulator failed with :(%d)\n",
308 __func__, rc);
309 goto fm_vreg_fail;
310 }
311
312 /* Voting for 19.2MHz clock */
313 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
314 PMAPP_CLOCK_VOTE_ON);
315 if (rc < 0) {
316 pr_err("%s: clock vote failed with :(%d)\n",
317 __func__, rc);
318 goto fm_clock_vote_fail;
319 }
320
321 rc = bt_set_gpio(1);
322 if (rc) {
323 pr_err("%s: bt_set_gpio = %d", __func__, rc);
324 goto fm_gpio_config_fail;
325 }
326 /*re-write FM Slave Id, after reset*/
327 value = BAHAMA_SLAVE_ID_FM_ADDR;
328 rc = marimba_write_bit_mask(&config,
329 BAHAMA_SLAVE_ID_FM_REG, &value, 1, 0xFF);
330 if (rc < 0) {
331 pr_err("%s: FM Slave ID rewrite Failed = %d", __func__, rc);
332 goto fm_gpio_config_fail;
333 }
334 /* Configuring the FM GPIO */
335 irqcfg = GPIO_CFG(FM_GPIO, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
336 GPIO_CFG_2MA);
337
338 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
339 if (rc) {
340 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
341 __func__, irqcfg, rc);
342 goto fm_gpio_config_fail;
343 }
344
345 return 0;
346
347fm_gpio_config_fail:
348 pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
349 PMAPP_CLOCK_VOTE_OFF);
350 bt_set_gpio(0);
351fm_clock_vote_fail:
352 vreg_disable(fm_regulator);
353
354fm_vreg_fail:
355 vreg_put(fm_regulator);
356
357 return rc;
358};
359
360static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
361{
362 int rc;
363 const char *id = "FMPW";
364
365 /* Releasing the GPIO line used by FM */
366 uint32_t irqcfg = GPIO_CFG(FM_GPIO, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
367 GPIO_CFG_2MA);
368
369 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
370 if (rc)
371 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
372 __func__, irqcfg, rc);
373
374 /* Releasing the 1.8V Regulator */
375 if (fm_regulator != NULL) {
376 rc = vreg_disable(fm_regulator);
377 if (rc)
378 pr_err("%s: disable regulator failed:(%d)\n",
379 __func__, rc);
380 fm_regulator = NULL;
381 }
382
383 /* Voting off the clock */
384 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
385 PMAPP_CLOCK_VOTE_OFF);
386 if (rc < 0)
387 pr_err("%s: voting off failed with :(%d)\n",
388 __func__, rc);
389 rc = bt_set_gpio(0);
390 if (rc)
391 pr_err("%s: bt_set_gpio = %d", __func__, rc);
392}
393
394static struct marimba_fm_platform_data marimba_fm_pdata = {
395 .fm_setup = fm_radio_setup,
396 .fm_shutdown = fm_radio_shutdown,
397 .irq = MSM_GPIO_TO_INT(FM_GPIO),
398 .vreg_s2 = NULL,
399 .vreg_xo_out = NULL,
400 /* Configuring the FM SoC as I2S Master */
401 .is_fm_soc_i2s_master = true,
402 .config_i2s_gpio = msm_bahama_setup_pcm_i2s,
403};
404
405static struct platform_device msm_wlan_ar6000_pm_device = {
406 .name = "wlan_ar6000_pm_dev",
407 .id = -1,
408};
409
410#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
411
412static struct platform_device msm_bt_power_device = {
413 .name = "bt_power",
414};
415struct bahama_config_register {
416 u8 reg;
417 u8 value;
418 u8 mask;
419};
420struct bt_vreg_info {
421 const char *name;
422 unsigned int pmapp_id;
423 unsigned int level;
424 unsigned int is_pin_controlled;
425 struct vreg *vregs;
426};
427static struct bt_vreg_info bt_vregs[] = {
428 {"msme1", 2, 1800, 0, NULL},
429 {"bt", 21, 2900, 1, NULL}
430};
431
432static int bahama_bt(int on)
433{
434
435 int rc = 0;
436 int i;
437
438 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
439
440 struct bahama_variant_register {
441 const size_t size;
442 const struct bahama_config_register *set;
443 };
444
445 const struct bahama_config_register *p;
446
447 u8 version;
448
449 const struct bahama_config_register v10_bt_on[] = {
450 { 0xE9, 0x00, 0xFF },
451 { 0xF4, 0x80, 0xFF },
452 { 0xE4, 0x00, 0xFF },
453 { 0xE5, 0x00, 0x0F },
454#ifdef CONFIG_WLAN
455 { 0xE6, 0x38, 0x7F },
456 { 0xE7, 0x06, 0xFF },
457#endif
458 { 0xE9, 0x21, 0xFF },
459 { 0x01, 0x0C, 0x1F },
460 { 0x01, 0x08, 0x1F },
461 };
462
463 const struct bahama_config_register v20_bt_on_fm_off[] = {
464 { 0x11, 0x0C, 0xFF },
465 { 0x13, 0x01, 0xFF },
466 { 0xF4, 0x80, 0xFF },
467 { 0xF0, 0x00, 0xFF },
468 { 0xE9, 0x00, 0xFF },
469#ifdef CONFIG_WLAN
470 { 0x81, 0x00, 0x7F },
471 { 0x82, 0x00, 0xFF },
472 { 0xE6, 0x38, 0x7F },
473 { 0xE7, 0x06, 0xFF },
474#endif
475 { 0x8E, 0x15, 0xFF },
476 { 0x8F, 0x15, 0xFF },
477 { 0x90, 0x15, 0xFF },
478
479 { 0xE9, 0x21, 0xFF },
480 };
481
482 const struct bahama_config_register v20_bt_on_fm_on[] = {
483 { 0x11, 0x0C, 0xFF },
484 { 0x13, 0x01, 0xFF },
485 { 0xF4, 0x86, 0xFF },
486 { 0xF0, 0x06, 0xFF },
487 { 0xE9, 0x00, 0xFF },
488#ifdef CONFIG_WLAN
489 { 0x81, 0x00, 0x7F },
490 { 0x82, 0x00, 0xFF },
491 { 0xE6, 0x38, 0x7F },
492 { 0xE7, 0x06, 0xFF },
493#endif
494 { 0xE9, 0x21, 0xFF },
495 };
496
497 const struct bahama_config_register v10_bt_off[] = {
498 { 0xE9, 0x00, 0xFF },
499 };
500
501 const struct bahama_config_register v20_bt_off_fm_off[] = {
502 { 0xF4, 0x84, 0xFF },
503 { 0xF0, 0x04, 0xFF },
504 { 0xE9, 0x00, 0xFF }
505 };
506
507 const struct bahama_config_register v20_bt_off_fm_on[] = {
508 { 0xF4, 0x86, 0xFF },
509 { 0xF0, 0x06, 0xFF },
510 { 0xE9, 0x00, 0xFF }
511 };
512 const struct bahama_variant_register bt_bahama[2][3] = {
513 {
514 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
515 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
516 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
517 },
518 {
519 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
520 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
521 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
522 }
523 };
524
525 u8 offset = 0; /* index into bahama configs */
526 on = on ? 1 : 0;
527 version = marimba_read_bahama_ver(&config);
528 if ((int)version < 0 || version == BAHAMA_VER_UNSUPPORTED) {
529 dev_err(&msm_bt_power_device.dev, "%s: Bahama \
530 version read Error, version = %d \n",
531 __func__, version);
532 return -EIO;
533 }
534
535 if (version == BAHAMA_VER_2_0) {
536 if (marimba_get_fm_status(&config))
537 offset = 0x01;
538 }
539
540 p = bt_bahama[on][version + offset].set;
541
542 dev_info(&msm_bt_power_device.dev,
543 "%s: found version %d\n", __func__, version);
544
545 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
546 u8 value = (p+i)->value;
547 rc = marimba_write_bit_mask(&config,
548 (p+i)->reg,
549 &value,
550 sizeof((p+i)->value),
551 (p+i)->mask);
552 if (rc < 0) {
553 dev_err(&msm_bt_power_device.dev,
554 "%s: reg %x write failed: %d\n",
555 __func__, (p+i)->reg, rc);
556 return rc;
557 }
558 dev_dbg(&msm_bt_power_device.dev,
559 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
560 __func__, (p+i)->reg,
561 value, (p+i)->mask);
562 value = 0;
563 rc = marimba_read_bit_mask(&config,
564 (p+i)->reg, &value,
565 sizeof((p+i)->value), (p+i)->mask);
566 if (rc < 0)
567 dev_err(&msm_bt_power_device.dev, "%s marimba_read_bit_mask- error",
568 __func__);
569 dev_dbg(&msm_bt_power_device.dev,
570 "%s: reg 0x%02x read value 0x%02x mask 0x%02x\n",
571 __func__, (p+i)->reg,
572 value, (p+i)->mask);
573 }
574 /* Update BT Status */
575 if (on)
576 marimba_set_bt_status(&config, true);
577 else
578 marimba_set_bt_status(&config, false);
579 return rc;
580}
581static int bluetooth_switch_regulators(int on)
582{
583 int i, rc = 0;
584 const char *id = "BTPW";
585
586 for (i = 0; i < ARRAY_SIZE(bt_vregs); i++) {
587 if (!bt_vregs[i].vregs) {
588 pr_err("%s: vreg_get %s failed(%d)\n",
589 __func__, bt_vregs[i].name, rc);
590 goto vreg_fail;
591 }
592 rc = on ? vreg_set_level(bt_vregs[i].vregs,
593 bt_vregs[i].level) : 0;
594
595 if (rc < 0) {
596 pr_err("%s: vreg set level failed (%d)\n",
597 __func__, rc);
598 goto vreg_set_level_fail;
599 }
600 if (bt_vregs[i].is_pin_controlled == 1) {
601 rc = pmapp_vreg_pincntrl_vote(id,
602 bt_vregs[i].pmapp_id,
603 PMAPP_CLOCK_ID_D1,
604 on ? PMAPP_CLOCK_VOTE_ON :
605 PMAPP_CLOCK_VOTE_OFF);
606 } else {
607 rc = on ? vreg_enable(bt_vregs[i].vregs) :
608 vreg_disable(bt_vregs[i].vregs);
609 }
610
611 if (rc < 0) {
612 pr_err("%s: vreg %s %s failed(%d)\n",
613 __func__, bt_vregs[i].name,
614 on ? "enable" : "disable", rc);
615 goto vreg_fail;
616 }
617 }
618
619 return rc;
620
621vreg_fail:
622 while (i) {
623 if (on)
624 vreg_disable(bt_vregs[--i].vregs);
625 }
626vreg_set_level_fail:
627 vreg_put(bt_vregs[0].vregs);
628 vreg_put(bt_vregs[1].vregs);
629 return rc;
630}
631
632static unsigned int msm_bahama_setup_power(void)
633{
634 int rc = 0;
635 struct vreg *vreg_s3 = NULL;
636
637 vreg_s3 = vreg_get(NULL, "msme1");
638 if (IS_ERR(vreg_s3)) {
639 pr_err("%s: vreg get failed (%ld)\n",
640 __func__, PTR_ERR(vreg_s3));
641 return PTR_ERR(vreg_s3);
642 }
643 rc = vreg_set_level(vreg_s3, 1800);
644 if (rc < 0) {
645 pr_err("%s: vreg set level failed (%d)\n",
646 __func__, rc);
647 goto vreg_fail;
648 }
649 rc = vreg_enable(vreg_s3);
650 if (rc < 0) {
651 pr_err("%s: vreg enable failed (%d)\n",
652 __func__, rc);
653 goto vreg_fail;
654 }
655
656 /*setup Bahama_sys_reset_n*/
657 rc = gpio_request(GPIO_BT_SYS_REST_EN, "bahama sys_rst_n");
658 if (rc < 0) {
659 pr_err("%s: gpio_request %d = %d\n", __func__,
660 GPIO_BT_SYS_REST_EN, rc);
661 goto vreg_fail;
662 }
663 rc = bt_set_gpio(1);
664 if (rc < 0) {
665 pr_err("%s: bt_set_gpio %d = %d\n", __func__,
666 GPIO_BT_SYS_REST_EN, rc);
667 goto gpio_fail;
668 }
669 return rc;
670
671gpio_fail:
672 gpio_free(GPIO_BT_SYS_REST_EN);
673vreg_fail:
674 vreg_put(vreg_s3);
675 return rc;
676}
677
678static unsigned int msm_bahama_shutdown_power(int value)
679{
680 int rc = 0;
681 struct vreg *vreg_s3 = NULL;
682
683 vreg_s3 = vreg_get(NULL, "msme1");
684 if (IS_ERR(vreg_s3)) {
685 pr_err("%s: vreg get failed (%ld)\n",
686 __func__, PTR_ERR(vreg_s3));
687 return PTR_ERR(vreg_s3);
688 }
689 rc = vreg_disable(vreg_s3);
690 if (rc) {
691 pr_err("%s: vreg disable failed (%d)\n",
692 __func__, rc);
693 vreg_put(vreg_s3);
694 return rc;
695 }
696 if (value == BAHAMA_ID) {
697 rc = bt_set_gpio(0);
698 if (rc) {
699 pr_err("%s: bt_set_gpio = %d\n",
700 __func__, rc);
701 }
702 }
703 return rc;
704}
705
706static unsigned int msm_bahama_core_config(int type)
707{
708 int rc = 0;
709
710 if (type == BAHAMA_ID) {
711 int i;
712 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
713 const struct bahama_config_register v20_init[] = {
714 /* reg, value, mask */
715 { 0xF4, 0x84, 0xFF }, /* AREG */
716 { 0xF0, 0x04, 0xFF } /* DREG */
717 };
718 if (marimba_read_bahama_ver(&config) == BAHAMA_VER_2_0) {
719 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
720 u8 value = v20_init[i].value;
721 rc = marimba_write_bit_mask(&config,
722 v20_init[i].reg,
723 &value,
724 sizeof(v20_init[i].value),
725 v20_init[i].mask);
726 if (rc < 0) {
727 pr_err("%s: reg %d write failed: %d\n",
728 __func__, v20_init[i].reg, rc);
729 return rc;
730 }
731 pr_debug("%s: reg 0x%02x value 0x%02x"
732 " mask 0x%02x\n",
733 __func__, v20_init[i].reg,
734 v20_init[i].value, v20_init[i].mask);
735 }
736 }
737 }
738 rc = bt_set_gpio(0);
739 if (rc) {
740 pr_err("%s: bt_set_gpio = %d\n",
741 __func__, rc);
742 }
743 pr_debug("core type: %d\n", type);
744 return rc;
745}
746
747static int bluetooth_power(int on)
748{
749 int pin, rc = 0;
750 const char *id = "BTPW";
751 int cid = 0;
752
753 cid = adie_get_detected_connectivity_type();
754 if (cid != BAHAMA_ID) {
755 pr_err("%s: unexpected adie connectivity type: %d\n",
756 __func__, cid);
757 return -ENODEV;
758 }
759 if (on) {
760 /*setup power for BT SOC*/
761 rc = bt_set_gpio(on);
762 if (rc) {
763 pr_err("%s: bt_set_gpio = %d\n",
764 __func__, rc);
765 goto exit;
766 }
767 rc = bluetooth_switch_regulators(on);
768 if (rc < 0) {
769 pr_err("%s: bluetooth_switch_regulators rc = %d",
770 __func__, rc);
771 goto exit;
772 }
773 /*setup BT GPIO lines*/
774 for (pin = 0; pin < ARRAY_SIZE(bt_config_power_on);
775 pin++) {
776 rc = gpio_tlmm_config(bt_config_power_on[pin],
777 GPIO_CFG_ENABLE);
778 if (rc < 0) {
779 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
780 __func__,
781 bt_config_power_on[pin],
782 rc);
783 goto fail_power;
784 }
785 }
786 /*Setup BT clocks*/
787 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
788 PMAPP_CLOCK_VOTE_ON);
789 if (rc < 0) {
790 pr_err("Failed to vote for TCXO_D1 ON\n");
791 goto fail_clock;
792 }
793 msleep(20);
794
795 /*I2C config for Bahama*/
796 rc = bahama_bt(1);
797 if (rc < 0) {
798 pr_err("%s: bahama_bt rc = %d", __func__, rc);
799 goto fail_i2c;
800 }
801 msleep(20);
802
803 /*setup BT PCM lines*/
804 rc = msm_bahama_setup_pcm_i2s(BT_PCM_ON);
805 if (rc < 0) {
806 pr_err("%s: msm_bahama_setup_pcm_i2s , rc =%d\n",
807 __func__, rc);
808 goto fail_power;
809 }
810 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
811 PMAPP_CLOCK_VOTE_PIN_CTRL);
812 if (rc < 0)
813 pr_err("%s:Pin Control Failed, rc = %d",
814 __func__, rc);
815
816 } else {
817 rc = bahama_bt(0);
818 if (rc < 0)
819 pr_err("%s: bahama_bt rc = %d", __func__, rc);
820
821 rc = bt_set_gpio(on);
822 if (rc) {
823 pr_err("%s: bt_set_gpio = %d\n",
824 __func__, rc);
825 }
826fail_i2c:
827 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
828 PMAPP_CLOCK_VOTE_OFF);
829 if (rc < 0)
830 pr_err("%s: Failed to vote Off D1\n", __func__);
831fail_clock:
832 for (pin = 0; pin < ARRAY_SIZE(bt_config_power_off);
833 pin++) {
834 rc = gpio_tlmm_config(bt_config_power_off[pin],
835 GPIO_CFG_ENABLE);
836 if (rc < 0) {
837 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
838 __func__, bt_config_power_off[pin], rc);
839 }
840 }
841 rc = msm_bahama_setup_pcm_i2s(BT_PCM_OFF);
842 if (rc < 0) {
843 pr_err("%s: msm_bahama_setup_pcm_i2s, rc =%d\n",
844 __func__, rc);
845 }
846fail_power:
847 rc = bluetooth_switch_regulators(0);
848 if (rc < 0) {
849 pr_err("%s: switch_regulators : rc = %d",\
850 __func__, rc);
851 goto exit;
852 }
853 }
854 return rc;
855exit:
856 pr_err("%s: failed with rc = %d", __func__, rc);
857 return rc;
858}
859
860static int __init bt_power_init(void)
861{
862 int i, rc = 0;
863 for (i = 0; i < ARRAY_SIZE(bt_vregs); i++) {
864 bt_vregs[i].vregs = vreg_get(NULL,
865 bt_vregs[i].name);
866 if (IS_ERR(bt_vregs[i].vregs)) {
867 pr_err("%s: vreg get %s failed (%ld)\n",
868 __func__, bt_vregs[i].name,
869 PTR_ERR(bt_vregs[i].vregs));
870 rc = PTR_ERR(bt_vregs[i].vregs);
871 goto vreg_get_fail;
872 }
873 }
874
875 msm_bt_power_device.dev.platform_data = &bluetooth_power;
876
877 return rc;
878
879vreg_get_fail:
880 while (i)
881 vreg_put(bt_vregs[--i].vregs);
882 return rc;
883}
884
885static struct marimba_platform_data marimba_pdata = {
886 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
887 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
888 .bahama_setup = msm_bahama_setup_power,
889 .bahama_shutdown = msm_bahama_shutdown_power,
890 .bahama_core_config = msm_bahama_core_config,
891 .fm = &marimba_fm_pdata,
892};
893
894#endif
895
896#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
897static struct i2c_board_info bahama_devices[] = {
898{
899 I2C_BOARD_INFO("marimba", 0xc),
900 .platform_data = &marimba_pdata,
901},
902};
903#endif
904
905static struct msm_gpio qup_i2c_gpios_io[] = {
906 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
907 "qup_scl" },
908 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
909 "qup_sda" },
910 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
911 "qup_scl" },
912 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
913 "qup_sda" },
914};
915
916static struct msm_gpio qup_i2c_gpios_hw[] = {
917 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
918 "qup_scl" },
919 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
920 "qup_sda" },
921 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
922 "qup_scl" },
923 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
924 "qup_sda" },
925};
926
927static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
928{
929 int rc;
930
931 if (adap_id < 0 || adap_id > 1)
932 return;
933
934 /* Each adapter gets 2 lines from the table */
935 if (config_type)
936 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
937 else
938 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
939 if (rc < 0)
940 pr_err("QUP GPIO request/enable failed: %d\n", rc);
941}
942
943static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
944 .clk_freq = 100000,
945 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
946};
947
948static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
949 .clk_freq = 100000,
950 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
951};
952
953#ifdef CONFIG_ARCH_MSM7X27A
954#define MSM_PMEM_MDP_SIZE 0x1DD1000
955#define MSM_PMEM_ADSP_SIZE 0x1000000
956
957#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
958#define MSM_FB_SIZE 0x260000
959#else
960#define MSM_FB_SIZE 0x195000
961#endif
962
963#endif
964
Taniya Dasda408822011-09-06 12:54:06 +0530965#if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) || \
966defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C_MODULE)
967
968#ifndef CLEARPAD3000_ATTEN_GPIO
969#define CLEARPAD3000_ATTEN_GPIO (48)
970#endif
971
972#ifndef CLEARPAD3000_RESET_GPIO
973#define CLEARPAD3000_RESET_GPIO (26)
974#endif
975
976static int synaptics_touchpad_setup(void);
977
978static struct msm_gpio clearpad3000_cfg_data[] = {
979 {GPIO_CFG(CLEARPAD3000_ATTEN_GPIO, 0, GPIO_CFG_INPUT,
980 GPIO_CFG_NO_PULL, GPIO_CFG_6MA), "rmi4_attn"},
981 {GPIO_CFG(CLEARPAD3000_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
982 GPIO_CFG_PULL_DOWN, GPIO_CFG_8MA), "rmi4_reset"},
983};
984
985static struct rmi_XY_pair rmi_offset = {.x = 0, .y = 0};
986static struct rmi_range rmi_clipx = {.min = 48, .max = 980};
987static struct rmi_range rmi_clipy = {.min = 7, .max = 1647};
988static struct rmi_f11_functiondata synaptics_f11_data = {
989 .swap_axes = false,
990 .flipX = false,
991 .flipY = false,
992 .offset = &rmi_offset,
993 .button_height = 113,
994 .clipX = &rmi_clipx,
995 .clipY = &rmi_clipy,
996};
997
998#define MAX_LEN 100
999
1000static ssize_t clearpad3000_virtual_keys_register(struct kobject *kobj,
1001 struct kobj_attribute *attr, char *buf)
1002{
1003 char *virtual_keys = __stringify(EV_KEY) ":" __stringify(KEY_MENU) \
1004 ":60:830:120:60" ":" __stringify(EV_KEY) \
1005 ":" __stringify(KEY_HOME) ":180:830:120:60" \
1006 ":" __stringify(EV_KEY) ":" \
1007 __stringify(KEY_SEARCH) ":300:830:120:60" \
1008 ":" __stringify(EV_KEY) ":" \
1009 __stringify(KEY_BACK) ":420:830:120:60" "\n";
1010
1011 return snprintf(buf, strnlen(virtual_keys, MAX_LEN) + 1 , "%s",
1012 virtual_keys);
1013}
1014
1015static struct kobj_attribute clearpad3000_virtual_keys_attr = {
1016 .attr = {
1017 .name = "virtualkeys.sensor00fn11",
1018 .mode = S_IRUGO,
1019 },
1020 .show = &clearpad3000_virtual_keys_register,
1021};
1022
1023static struct attribute *virtual_key_properties_attrs[] = {
1024 &clearpad3000_virtual_keys_attr.attr,
1025 NULL
1026};
1027
1028static struct attribute_group virtual_key_properties_attr_group = {
1029 .attrs = virtual_key_properties_attrs,
1030};
1031
1032struct kobject *virtual_key_properties_kobj;
1033
1034static struct rmi_functiondata synaptics_functiondata[] = {
1035 {
1036 .function_index = RMI_F11_INDEX,
1037 .data = &synaptics_f11_data,
1038 },
1039};
1040
1041static struct rmi_functiondata_list synaptics_perfunctiondata = {
1042 .count = ARRAY_SIZE(synaptics_functiondata),
1043 .functiondata = synaptics_functiondata,
1044};
1045
1046static struct rmi_sensordata synaptics_sensordata = {
1047 .perfunctiondata = &synaptics_perfunctiondata,
1048 .rmi_sensor_setup = synaptics_touchpad_setup,
1049};
1050
1051static struct rmi_i2c_platformdata synaptics_platformdata = {
1052 .i2c_address = 0x2c,
1053 .irq_type = IORESOURCE_IRQ_LOWLEVEL,
1054 .sensordata = &synaptics_sensordata,
1055};
1056
1057static struct i2c_board_info synaptic_i2c_clearpad3k[] = {
1058 {
1059 I2C_BOARD_INFO("rmi4_ts", 0x2c),
1060 .platform_data = &synaptics_platformdata,
1061 },
1062};
1063
1064static int synaptics_touchpad_setup(void)
1065{
1066 int retval = 0;
1067
1068 virtual_key_properties_kobj =
1069 kobject_create_and_add("board_properties", NULL);
1070 if (virtual_key_properties_kobj)
1071 retval = sysfs_create_group(virtual_key_properties_kobj,
1072 &virtual_key_properties_attr_group);
1073 if (!virtual_key_properties_kobj || retval)
1074 pr_err("failed to create ft5202 board_properties\n");
1075
1076 retval = msm_gpios_request_enable(clearpad3000_cfg_data,
1077 sizeof(clearpad3000_cfg_data)/sizeof(struct msm_gpio));
1078 if (retval) {
1079 pr_err("%s:Failed to obtain touchpad GPIO %d. Code: %d.",
1080 __func__, CLEARPAD3000_ATTEN_GPIO, retval);
1081 retval = 0; /* ignore the err */
1082 }
1083 synaptics_platformdata.irq = gpio_to_irq(CLEARPAD3000_ATTEN_GPIO);
1084
1085 gpio_set_value(CLEARPAD3000_RESET_GPIO, 0);
1086 usleep(10000);
1087 gpio_set_value(CLEARPAD3000_RESET_GPIO, 1);
1088 usleep(50000);
1089
1090 return retval;
1091}
1092#endif
1093
1094
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301095static struct android_usb_platform_data android_usb_pdata = {
Pankaj Kumar6f841742011-10-10 15:52:14 +05301096 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301097};
1098
1099static struct platform_device android_usb_device = {
1100 .name = "android_usb",
1101 .id = -1,
1102 .dev = {
1103 .platform_data = &android_usb_pdata,
1104 },
1105};
1106
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301107#ifdef CONFIG_USB_EHCI_MSM_72K
1108static void msm_hsusb_vbus_power(unsigned phy_info, int on)
1109{
1110 int rc = 0;
1111 unsigned gpio;
1112
1113 gpio = GPIO_HOST_VBUS_EN;
1114
1115 rc = gpio_request(gpio, "i2c_host_vbus_en");
1116 if (rc < 0) {
1117 pr_err("failed to request %d GPIO\n", gpio);
1118 return;
1119 }
1120 gpio_direction_output(gpio, !!on);
1121 gpio_set_value_cansleep(gpio, !!on);
1122 gpio_free(gpio);
1123}
1124
1125static struct msm_usb_host_platform_data msm_usb_host_pdata = {
1126 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
1127};
1128
1129static void __init msm7627a_init_host(void)
1130{
1131 msm_add_host(0, &msm_usb_host_pdata);
1132}
1133#endif
1134
1135#ifdef CONFIG_USB_MSM_OTG_72K
1136static int hsusb_rpc_connect(int connect)
1137{
1138 if (connect)
1139 return msm_hsusb_rpc_connect();
1140 else
1141 return msm_hsusb_rpc_close();
1142}
1143
1144static struct vreg *vreg_3p3;
1145static int msm_hsusb_ldo_init(int init)
1146{
1147 if (init) {
1148 vreg_3p3 = vreg_get(NULL, "usb");
1149 if (IS_ERR(vreg_3p3))
1150 return PTR_ERR(vreg_3p3);
1151 } else
1152 vreg_put(vreg_3p3);
1153
1154 return 0;
1155}
1156
1157static int msm_hsusb_ldo_enable(int enable)
1158{
1159 static int ldo_status;
1160
1161 if (!vreg_3p3 || IS_ERR(vreg_3p3))
1162 return -ENODEV;
1163
1164 if (ldo_status == enable)
1165 return 0;
1166
1167 ldo_status = enable;
1168
1169 if (enable)
1170 return vreg_enable(vreg_3p3);
1171
1172 return vreg_disable(vreg_3p3);
1173}
1174
1175#ifndef CONFIG_USB_EHCI_MSM_72K
1176static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
1177{
1178 int ret = 0;
1179
1180 if (init)
1181 ret = msm_pm_app_rpc_init(callback);
1182 else
1183 msm_pm_app_rpc_deinit(callback);
1184
1185 return ret;
1186}
1187#endif
1188
1189static struct msm_otg_platform_data msm_otg_pdata = {
1190#ifndef CONFIG_USB_EHCI_MSM_72K
1191 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
1192#else
1193 .vbus_power = msm_hsusb_vbus_power,
1194#endif
1195 .rpc_connect = hsusb_rpc_connect,
1196 .core_clk = 1,
1197 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
1198 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
1199 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
1200 .se1_gating = SE1_GATING_DISABLE,
1201 .ldo_init = msm_hsusb_ldo_init,
1202 .ldo_enable = msm_hsusb_ldo_enable,
1203 .chg_init = hsusb_chg_init,
1204 .chg_connected = hsusb_chg_connected,
1205 .chg_vbus_draw = hsusb_chg_vbus_draw,
1206};
1207#endif
1208
1209static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
1210 .is_phy_status_timer_on = 1,
1211};
1212
1213#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
1214 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
1215 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
1216 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
1217
1218static unsigned long vreg_sts, gpio_sts;
1219static struct vreg *vreg_mmc;
1220static struct vreg *vreg_emmc;
1221
1222struct sdcc_vreg {
1223 struct vreg *vreg_data;
1224 unsigned level;
1225};
1226
1227static struct sdcc_vreg sdcc_vreg_data[4];
1228
1229struct sdcc_gpio {
1230 struct msm_gpio *cfg_data;
1231 uint32_t size;
1232 struct msm_gpio *sleep_cfg_data;
1233};
1234
1235/**
1236 * Due to insufficient drive strengths for SDC GPIO lines some old versioned
1237 * SD/MMC cards may cause data CRC errors. Hence, set optimal values
1238 * for SDC slots based on timing closure and marginality. SDC1 slot
1239 * require higher value since it should handle bad signal quality due
1240 * to size of T-flash adapters.
1241 */
1242static struct msm_gpio sdc1_cfg_data[] = {
1243 {GPIO_CFG(51, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_14MA),
1244 "sdc1_dat_3"},
1245 {GPIO_CFG(52, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_14MA),
1246 "sdc1_dat_2"},
1247 {GPIO_CFG(53, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_14MA),
1248 "sdc1_dat_1"},
1249 {GPIO_CFG(54, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_14MA),
1250 "sdc1_dat_0"},
1251 {GPIO_CFG(55, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_14MA),
1252 "sdc1_cmd"},
1253 {GPIO_CFG(56, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_14MA),
1254 "sdc1_clk"},
1255};
1256
1257static struct msm_gpio sdc2_cfg_data[] = {
1258 {GPIO_CFG(62, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
1259 "sdc2_clk"},
1260 {GPIO_CFG(63, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1261 "sdc2_cmd"},
1262 {GPIO_CFG(64, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1263 "sdc2_dat_3"},
1264 {GPIO_CFG(65, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1265 "sdc2_dat_2"},
1266 {GPIO_CFG(66, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1267 "sdc2_dat_1"},
1268 {GPIO_CFG(67, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1269 "sdc2_dat_0"},
1270};
1271
1272static struct msm_gpio sdc2_sleep_cfg_data[] = {
1273 {GPIO_CFG(62, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1274 "sdc2_clk"},
1275 {GPIO_CFG(63, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1276 "sdc2_cmd"},
1277 {GPIO_CFG(64, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1278 "sdc2_dat_3"},
1279 {GPIO_CFG(65, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1280 "sdc2_dat_2"},
1281 {GPIO_CFG(66, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1282 "sdc2_dat_1"},
1283 {GPIO_CFG(67, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1284 "sdc2_dat_0"},
1285};
1286static struct msm_gpio sdc3_cfg_data[] = {
1287 {GPIO_CFG(88, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
1288 "sdc3_clk"},
1289 {GPIO_CFG(89, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1290 "sdc3_cmd"},
1291 {GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1292 "sdc3_dat_3"},
1293 {GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1294 "sdc3_dat_2"},
1295 {GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1296 "sdc3_dat_1"},
1297 {GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1298 "sdc3_dat_0"},
1299#ifdef CONFIG_MMC_MSM_SDC3_8_BIT_SUPPORT
1300 {GPIO_CFG(19, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1301 "sdc3_dat_7"},
1302 {GPIO_CFG(20, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1303 "sdc3_dat_6"},
1304 {GPIO_CFG(21, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1305 "sdc3_dat_5"},
1306 {GPIO_CFG(108, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1307 "sdc3_dat_4"},
1308#endif
1309};
1310
1311static struct msm_gpio sdc4_cfg_data[] = {
1312 {GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1313 "sdc4_dat_3"},
1314 {GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1315 "sdc4_dat_2"},
1316 {GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1317 "sdc4_dat_1"},
1318 {GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1319 "sdc4_cmd"},
1320 {GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA),
1321 "sdc4_dat_0"},
1322 {GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
1323 "sdc4_clk"},
1324};
1325
1326static struct sdcc_gpio sdcc_cfg_data[] = {
1327 {
1328 .cfg_data = sdc1_cfg_data,
1329 .size = ARRAY_SIZE(sdc1_cfg_data),
1330 },
1331 {
1332 .cfg_data = sdc2_cfg_data,
1333 .size = ARRAY_SIZE(sdc2_cfg_data),
1334 .sleep_cfg_data = sdc2_sleep_cfg_data,
1335 },
1336 {
1337 .cfg_data = sdc3_cfg_data,
1338 .size = ARRAY_SIZE(sdc3_cfg_data),
1339 },
1340 {
1341 .cfg_data = sdc4_cfg_data,
1342 .size = ARRAY_SIZE(sdc4_cfg_data),
1343 },
1344};
1345
1346static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
1347{
1348 int rc = 0;
1349 struct sdcc_gpio *curr;
1350
1351 curr = &sdcc_cfg_data[dev_id - 1];
1352 if (!(test_bit(dev_id, &gpio_sts)^enable))
1353 return rc;
1354
1355 if (enable) {
1356 set_bit(dev_id, &gpio_sts);
1357 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
1358 if (rc)
1359 pr_err("%s: Failed to turn on GPIOs for slot %d\n",
1360 __func__, dev_id);
1361 } else {
1362 clear_bit(dev_id, &gpio_sts);
1363 if (curr->sleep_cfg_data) {
1364 rc = msm_gpios_enable(curr->sleep_cfg_data, curr->size);
1365 msm_gpios_free(curr->sleep_cfg_data, curr->size);
1366 return rc;
1367 }
1368 msm_gpios_disable_free(curr->cfg_data, curr->size);
1369 }
1370 return rc;
1371}
1372
1373static int msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
1374{
1375 int rc = 0;
1376 struct sdcc_vreg *curr;
1377
1378 curr = &sdcc_vreg_data[dev_id - 1];
1379
1380 if (!(test_bit(dev_id, &vreg_sts)^enable))
1381 return rc;
1382
1383 if (enable) {
1384 set_bit(dev_id, &vreg_sts);
1385 rc = vreg_set_level(curr->vreg_data, curr->level);
1386 if (rc)
1387 pr_err("%s: vreg_set_level() = %d\n", __func__, rc);
1388
1389 rc = vreg_enable(curr->vreg_data);
1390 if (rc)
1391 pr_err("%s: vreg_enable() = %d\n", __func__, rc);
1392 } else {
1393 clear_bit(dev_id, &vreg_sts);
1394 rc = vreg_disable(curr->vreg_data);
1395 if (rc)
1396 pr_err("%s: vreg_disable() = %d\n", __func__, rc);
1397 }
1398 return rc;
1399}
1400
1401static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
1402{
1403 int rc = 0;
1404 struct platform_device *pdev;
1405
1406 pdev = container_of(dv, struct platform_device, dev);
1407
1408 rc = msm_sdcc_setup_gpio(pdev->id, !!vdd);
1409 if (rc)
1410 goto out;
1411
1412 rc = msm_sdcc_setup_vreg(pdev->id, !!vdd);
1413out:
1414 return rc;
1415}
1416
Sujit Reddy Thumma535c9e32011-10-28 09:45:33 +05301417#define GPIO_SDC1_HW_DET 42
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301418
1419#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) \
1420 && defined(CONFIG_MMC_MSM_CARD_HW_DETECTION)
1421static unsigned int msm7627a_sdcc_slot_status(struct device *dev)
1422{
1423 int status;
1424
1425 status = gpio_tlmm_config(GPIO_CFG(GPIO_SDC1_HW_DET, 2, GPIO_CFG_INPUT,
1426 GPIO_CFG_PULL_UP, GPIO_CFG_8MA), GPIO_CFG_ENABLE);
1427 if (status)
1428 pr_err("%s:Failed to configure tlmm for GPIO %d\n", __func__,
1429 GPIO_SDC1_HW_DET);
1430
1431 status = gpio_request(GPIO_SDC1_HW_DET, "SD_HW_Detect");
1432 if (status) {
1433 pr_err("%s:Failed to request GPIO %d\n", __func__,
1434 GPIO_SDC1_HW_DET);
1435 } else {
1436 status = gpio_direction_input(GPIO_SDC1_HW_DET);
1437 if (!status)
Sujit Reddy Thumma535c9e32011-10-28 09:45:33 +05301438 status = !gpio_get_value(GPIO_SDC1_HW_DET);
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301439 gpio_free(GPIO_SDC1_HW_DET);
1440 }
1441 return status;
1442}
1443#endif
1444
1445#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
1446static struct mmc_platform_data sdc1_plat_data = {
1447 .ocr_mask = MMC_VDD_28_29,
1448 .translate_vdd = msm_sdcc_setup_power,
1449 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
1450 .msmsdcc_fmin = 144000,
1451 .msmsdcc_fmid = 24576000,
1452 .msmsdcc_fmax = 49152000,
1453#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
1454 .status = msm7627a_sdcc_slot_status,
1455 .status_irq = MSM_GPIO_TO_INT(GPIO_SDC1_HW_DET),
1456 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
1457#endif
1458};
1459#endif
1460
1461#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
1462static struct mmc_platform_data sdc2_plat_data = {
1463 /*
1464 * SDC2 supports only 1.8V, claim for 2.85V range is just
1465 * for allowing buggy cards who advertise 2.8V even though
1466 * they can operate at 1.8V supply.
1467 */
1468 .ocr_mask = MMC_VDD_28_29 | MMC_VDD_165_195,
1469 .translate_vdd = msm_sdcc_setup_power,
1470 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
1471#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
1472 .sdiowakeup_irq = MSM_GPIO_TO_INT(66),
1473#endif
1474 .msmsdcc_fmin = 144000,
1475 .msmsdcc_fmid = 24576000,
1476 .msmsdcc_fmax = 49152000,
1477#ifdef CONFIG_MMC_MSM_SDC2_DUMMY52_REQUIRED
1478 .dummy52_required = 1,
1479#endif
1480};
1481#endif
1482
1483#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
1484static struct mmc_platform_data sdc3_plat_data = {
1485 .ocr_mask = MMC_VDD_28_29,
1486 .translate_vdd = msm_sdcc_setup_power,
1487#ifdef CONFIG_MMC_MSM_SDC3_8_BIT_SUPPORT
1488 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
1489#else
1490 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
1491#endif
1492 .msmsdcc_fmin = 144000,
1493 .msmsdcc_fmid = 24576000,
1494 .msmsdcc_fmax = 49152000,
1495 .nonremovable = 1,
1496};
1497#endif
1498
1499#if (defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
1500 && !defined(CONFIG_MMC_MSM_SDC3_8_BIT_SUPPORT))
1501static struct mmc_platform_data sdc4_plat_data = {
1502 .ocr_mask = MMC_VDD_28_29,
1503 .translate_vdd = msm_sdcc_setup_power,
1504 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
1505 .msmsdcc_fmin = 144000,
1506 .msmsdcc_fmid = 24576000,
1507 .msmsdcc_fmax = 49152000,
1508};
1509#endif
1510#endif
1511
1512#ifdef CONFIG_SERIAL_MSM_HS
1513static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
1514 .inject_rx_on_wakeup = 1,
1515 .rx_to_inject = 0xFD,
1516};
1517#endif
1518static struct msm_pm_platform_data msm7627a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
1519 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
1520 .idle_supported = 1,
1521 .suspend_supported = 1,
1522 .idle_enabled = 1,
1523 .suspend_enabled = 1,
1524 .latency = 16000,
1525 .residency = 20000,
1526 },
1527 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
1528 .idle_supported = 1,
1529 .suspend_supported = 1,
1530 .idle_enabled = 1,
1531 .suspend_enabled = 1,
1532 .latency = 12000,
1533 .residency = 20000,
1534 },
1535 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
1536 .idle_supported = 1,
1537 .suspend_supported = 1,
1538 .idle_enabled = 0,
1539 .suspend_enabled = 1,
1540 .latency = 2000,
1541 .residency = 0,
1542 },
1543 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
1544 .idle_supported = 1,
1545 .suspend_supported = 1,
1546 .idle_enabled = 1,
1547 .suspend_enabled = 1,
1548 .latency = 2,
1549 .residency = 0,
1550 },
1551};
1552
1553static struct android_pmem_platform_data android_pmem_adsp_pdata = {
1554 .name = "pmem_adsp",
1555 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
1556 .cached = 1,
1557 .memory_type = MEMTYPE_EBI1,
1558};
1559
1560static struct platform_device android_pmem_adsp_device = {
1561 .name = "android_pmem",
1562 .id = 1,
1563 .dev = { .platform_data = &android_pmem_adsp_pdata },
1564};
1565
1566static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
1567static int __init pmem_mdp_size_setup(char *p)
1568{
1569 pmem_mdp_size = memparse(p, NULL);
1570 return 0;
1571}
1572
1573early_param("pmem_mdp_size", pmem_mdp_size_setup);
1574
1575static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
1576static int __init pmem_adsp_size_setup(char *p)
1577{
1578 pmem_adsp_size = memparse(p, NULL);
1579 return 0;
1580}
1581
1582early_param("pmem_adsp_size", pmem_adsp_size_setup);
1583
1584static unsigned fb_size = MSM_FB_SIZE;
1585static int __init fb_size_setup(char *p)
1586{
1587 fb_size = memparse(p, NULL);
1588 return 0;
1589}
1590
1591early_param("fb_size", fb_size_setup);
1592
Taniya Das0a5303a2011-08-23 18:47:48 +05301593static struct resource msm_fb_resources[] = {
1594 {
1595 .flags = IORESOURCE_DMA,
1596 }
1597};
1598
1599static int msm_fb_detect_panel(const char *name)
1600{
1601 int ret;
1602
1603 if (!strncmp(name, "mipi_video_truly_wvga", 21))
1604 ret = 0;
1605 else
1606 ret = -ENODEV;
1607
1608 return ret;
1609}
1610
1611static int mipi_truly_set_bl(int on)
1612{
1613 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, !!on);
1614
1615 return 1;
1616}
1617
1618static struct msm_fb_platform_data msm_fb_pdata = {
1619 .detect_client = msm_fb_detect_panel,
1620};
1621
1622static struct platform_device msm_fb_device = {
1623 .name = "msm_fb",
1624 .id = 0,
1625 .num_resources = ARRAY_SIZE(msm_fb_resources),
1626 .resource = msm_fb_resources,
1627 .dev = {
1628 .platform_data = &msm_fb_pdata,
1629 }
1630};
1631
1632static struct msm_panel_common_pdata mipi_truly_pdata = {
1633 .pmic_backlight = mipi_truly_set_bl,
1634};
1635
1636static struct platform_device mipi_dsi_truly_panel_device = {
1637 .name = "mipi_truly",
1638 .id = 0,
1639 .dev = {
1640 .platform_data = &mipi_truly_pdata,
1641 }
1642};
1643
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301644static void __init msm7627a_init_mmc(void)
1645{
1646 vreg_emmc = vreg_get(NULL, "emmc");
1647 if (IS_ERR(vreg_emmc)) {
1648 pr_err("%s: vreg get failed (%ld)\n",
1649 __func__, PTR_ERR(vreg_emmc));
1650 return;
1651 }
1652
1653 vreg_mmc = vreg_get(NULL, "mmc");
1654 if (IS_ERR(vreg_mmc)) {
1655 pr_err("%s: vreg get failed (%ld)\n",
1656 __func__, PTR_ERR(vreg_mmc));
1657 return;
1658 }
1659
1660 /* eMMC slot */
1661#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
1662 sdcc_vreg_data[2].vreg_data = vreg_emmc;
1663 sdcc_vreg_data[2].level = 3000;
1664 msm_add_sdcc(3, &sdc3_plat_data);
1665#endif
1666 /* Micro-SD slot */
1667#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
1668 sdcc_vreg_data[0].vreg_data = vreg_mmc;
1669 sdcc_vreg_data[0].level = 2850;
1670 msm_add_sdcc(1, &sdc1_plat_data);
1671#endif
1672 /* SDIO WLAN slot */
1673#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
1674 sdcc_vreg_data[1].vreg_data = vreg_mmc;
1675 sdcc_vreg_data[1].level = 2850;
1676 msm_add_sdcc(2, &sdc2_plat_data);
1677#endif
1678 /* Not Used */
1679#if (defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\
1680 && !defined(CONFIG_MMC_MSM_SDC3_8_BIT_SUPPORT))
1681 sdcc_vreg_data[3].vreg_data = vreg_mmc;
1682 sdcc_vreg_data[3].level = 2850;
1683 msm_add_sdcc(4, &sdc4_plat_data);
1684#endif
1685}
1686
1687#define SND(desc, num) { .name = #desc, .id = num }
1688static struct snd_endpoint snd_endpoints_list[] = {
1689 SND(HANDSET, 0),
1690 SND(MONO_HEADSET, 2),
1691 SND(HEADSET, 3),
1692 SND(SPEAKER, 6),
1693 SND(TTY_HEADSET, 8),
1694 SND(TTY_VCO, 9),
1695 SND(TTY_HCO, 10),
1696 SND(BT, 12),
1697 SND(IN_S_SADC_OUT_HANDSET, 16),
1698 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
1699 SND(FM_DIGITAL_STEREO_HEADSET, 26),
1700 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
1701 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
Shashi Kumar64e07602011-10-11 13:18:57 +05301702 SND(STEREO_HEADSET_AND_SPEAKER, 31),
Phani Kumar Alladad6971252011-10-19 10:50:15 +05301703 SND(CURRENT, 0x7FFFFFFE),
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301704 SND(FM_ANALOG_STEREO_HEADSET, 35),
1705 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
1706};
1707#undef SND
1708
1709static struct msm_snd_endpoints msm_device_snd_endpoints = {
1710 .endpoints = snd_endpoints_list,
1711 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
1712};
1713
1714static struct platform_device msm_device_snd = {
1715 .name = "msm_snd",
1716 .id = -1,
1717 .dev = {
1718 .platform_data = &msm_device_snd_endpoints
1719 },
1720};
1721
1722#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
1723 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
1724 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
1725 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
1726 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
1727 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
1728#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
1729 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
1730 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
1731 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
1732 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
1733 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
1734#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
1735 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
1736 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
1737 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
1738 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
1739 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
1740#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
1741 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
1742 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
1743 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
1744 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
1745 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
1746#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
1747
1748static unsigned int dec_concurrency_table[] = {
1749 /* Audio LP */
1750 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
1751 0, 0, 0,
1752
1753 /* Concurrency 1 */
1754 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1755 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1756 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1757 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1758 (DEC4_FORMAT),
1759
1760 /* Concurrency 2 */
1761 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1762 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1763 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1764 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1765 (DEC4_FORMAT),
1766
1767 /* Concurrency 3 */
1768 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1769 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1770 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1771 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1772 (DEC4_FORMAT),
1773
1774 /* Concurrency 4 */
1775 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1776 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1777 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1778 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1779 (DEC4_FORMAT),
1780
1781 /* Concurrency 5 */
1782 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1783 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1784 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1785 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1786 (DEC4_FORMAT),
1787
1788 /* Concurrency 6 */
1789 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1790 0, 0, 0, 0,
1791
1792 /* Concurrency 7 */
1793 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1794 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1795 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1796 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1797 (DEC4_FORMAT),
1798};
1799
1800#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
1801 .module_queueid = queueid, .module_decid = decid, \
1802 .nr_codec_support = nr_codec}
1803
1804static struct msm_adspdec_info dec_info_list[] = {
1805 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
1806 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
1807 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
1808 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
1809 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
1810};
1811
1812static struct msm_adspdec_database msm_device_adspdec_database = {
1813 .num_dec = ARRAY_SIZE(dec_info_list),
1814 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
1815 ARRAY_SIZE(dec_info_list)),
1816 .dec_concurrency_table = dec_concurrency_table,
1817 .dec_info_list = dec_info_list,
1818};
1819
1820static struct platform_device msm_device_adspdec = {
1821 .name = "msm_adspdec",
1822 .id = -1,
1823 .dev = {
1824 .platform_data = &msm_device_adspdec_database
1825 },
1826};
1827
1828static struct android_pmem_platform_data android_pmem_audio_pdata = {
1829 .name = "pmem_audio",
1830 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
1831 .cached = 0,
1832 .memory_type = MEMTYPE_EBI1,
1833};
1834
1835static struct platform_device android_pmem_audio_device = {
1836 .name = "android_pmem",
1837 .id = 2,
1838 .dev = { .platform_data = &android_pmem_audio_pdata },
1839};
1840
1841static struct android_pmem_platform_data android_pmem_pdata = {
1842 .name = "pmem",
1843 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
1844 .cached = 1,
1845 .memory_type = MEMTYPE_EBI1,
1846};
1847static struct platform_device android_pmem_device = {
1848 .name = "android_pmem",
1849 .id = 0,
1850 .dev = { .platform_data = &android_pmem_pdata },
1851};
1852
1853static u32 msm_calculate_batt_capacity(u32 current_voltage);
1854
1855static struct msm_psy_batt_pdata msm_psy_batt_data = {
1856 .voltage_min_design = 2800,
1857 .voltage_max_design = 4300,
1858 .avail_chg_sources = AC_CHG | USB_CHG ,
1859 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
1860 .calculate_capacity = &msm_calculate_batt_capacity,
1861};
1862
1863static u32 msm_calculate_batt_capacity(u32 current_voltage)
1864{
1865 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
1866 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
1867
1868 return (current_voltage - low_voltage) * 100
1869 / (high_voltage - low_voltage);
1870}
1871
1872static struct platform_device msm_batt_device = {
1873 .name = "msm-battery",
1874 .id = -1,
1875 .dev.platform_data = &msm_psy_batt_data,
1876};
1877
Taniya Das7a22cdd2011-09-08 14:57:00 +05301878#ifdef CONFIG_MSM_CAMERA
1879static uint32_t camera_off_gpio_table[] = {
1880 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1881};
1882
1883static uint32_t camera_on_gpio_table[] = {
1884 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1885};
1886
1887static void qrd1_camera_gpio_cfg(void)
1888{
1889
1890 int rc = 0;
1891
1892 rc = gpio_request(GPIO_CAM_5MP_SHDN_EN, "ov5640");
1893 if (rc < 0)
1894 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
1895 __func__);
1896
1897
1898 rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_5MP_SHDN_EN, 0,
1899 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
1900 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1901 if (rc < 0) {
1902 pr_err("%s: unable to enable Power Down gpio for main"
1903 "camera!\n", __func__);
1904 gpio_free(GPIO_CAM_5MP_SHDN_EN);
1905 }
1906
1907
1908 rc = gpio_request(GPIO_CAM_5MP_RESET, "ov5640");
1909 if (rc < 0) {
1910 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
1911 __func__);
1912 gpio_free(GPIO_CAM_5MP_SHDN_EN);
1913 }
1914
1915
1916 rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_5MP_RESET, 0,
1917 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
1918 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1919 if (rc < 0) {
1920 pr_err("%s: unable to enable reset gpio for main camera!\n",
1921 __func__);
1922 gpio_free(GPIO_CAM_5MP_RESET);
1923 }
1924
1925 rc = gpio_request(GPIO_CAM_3MP_PWDN, "ov7692");
1926 if (rc < 0)
1927 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
1928 __func__);
1929
1930 rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_3MP_PWDN, 0,
1931 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
1932 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1933 if (rc < 0) {
1934 pr_err("%s: unable to enable Power Down gpio for front"
1935 "camera!\n", __func__);
1936 gpio_free(GPIO_CAM_3MP_PWDN);
1937 }
1938
1939 gpio_direction_output(GPIO_CAM_5MP_SHDN_EN, 1);
1940 gpio_direction_output(GPIO_CAM_5MP_RESET, 1);
1941 gpio_direction_output(GPIO_CAM_3MP_PWDN, 1);
1942}
1943
1944#endif
1945static struct vreg *vreg_gp1;
1946static struct vreg *vreg_gp2;
1947static struct vreg *vreg_gp3;
1948static void msm_camera_vreg_config(int vreg_en)
1949{
1950 int rc;
1951
1952 if (vreg_gp1 == NULL) {
1953 vreg_gp1 = vreg_get(NULL, "msme1");
1954 if (IS_ERR(vreg_gp1)) {
1955 pr_err("%s: vreg_get(%s) failed (%ld)\n",
1956 __func__, "msme1", PTR_ERR(vreg_gp1));
1957 return;
1958 }
1959
1960 rc = vreg_set_level(vreg_gp1, 1800);
1961 if (rc) {
1962 pr_err("%s: GP1 set_level failed (%d)\n",
1963 __func__, rc);
1964 return;
1965 }
1966 }
1967
1968 if (vreg_gp2 == NULL) {
1969 vreg_gp2 = vreg_get(NULL, "gp2");
1970 if (IS_ERR(vreg_gp2)) {
1971 pr_err("%s: vreg_get(%s) failed (%ld)\n",
1972 __func__, "gp2", PTR_ERR(vreg_gp2));
1973 return;
1974 }
1975
1976 rc = vreg_set_level(vreg_gp2, 2850);
1977 if (rc) {
1978 pr_err("%s: GP2 set_level failed (%d)\n",
1979 __func__, rc);
1980 }
1981 }
1982
1983 if (vreg_gp3 == NULL) {
1984 vreg_gp3 = vreg_get(NULL, "usb2");
1985 if (IS_ERR(vreg_gp3)) {
1986 pr_err("%s: vreg_get(%s) failed (%ld)\n",
1987 __func__, "gp3", PTR_ERR(vreg_gp3));
1988 return;
1989 }
1990
1991 rc = vreg_set_level(vreg_gp3, 1800);
1992 if (rc) {
1993 pr_err("%s: GP3 set level failed (%d)\n",
1994 __func__, rc);
1995 }
1996 }
1997
1998 if (vreg_en) {
1999 rc = vreg_enable(vreg_gp1);
2000 if (rc) {
2001 pr_err("%s: GP1 enable failed (%d)\n",
2002 __func__, rc);
2003 return;
2004 }
2005
2006 rc = vreg_enable(vreg_gp2);
2007 if (rc) {
2008 pr_err("%s: GP2 enable failed (%d)\n",
2009 __func__, rc);
2010 }
2011
2012 rc = vreg_enable(vreg_gp3);
2013 if (rc) {
2014 pr_err("%s: GP3 enable failed (%d)\n",
2015 __func__, rc);
2016 }
2017 } else {
2018 rc = vreg_disable(vreg_gp1);
2019 if (rc)
2020 pr_err("%s: GP1 disable failed (%d)\n",
2021 __func__, rc);
2022
2023 rc = vreg_disable(vreg_gp2);
2024 if (rc) {
2025 pr_err("%s: GP2 disable failed (%d)\n",
2026 __func__, rc);
2027 }
2028
2029 rc = vreg_disable(vreg_gp3);
2030 if (rc) {
2031 pr_err("%s: GP3 disable failed (%d)\n",
2032 __func__, rc);
2033 }
2034 }
2035}
2036
2037static int config_gpio_table(uint32_t *table, int len)
2038{
2039 int rc = 0, i = 0;
2040
2041 for (i = 0; i < len; i++) {
2042 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
2043 if (rc) {
2044 pr_err("%s not able to get gpio\n", __func__);
2045 for (i--; i >= 0; i--)
2046 gpio_tlmm_config(camera_off_gpio_table[i],
2047 GPIO_CFG_ENABLE);
2048 break;
2049 }
2050 }
2051 return rc;
2052}
2053
2054static int config_camera_on_gpios_rear(void)
2055{
2056 int rc = 0;
2057
2058 msm_camera_vreg_config(1);
2059
2060 rc = config_gpio_table(camera_on_gpio_table,
2061 ARRAY_SIZE(camera_on_gpio_table));
2062 if (rc < 0) {
2063 pr_err("%s: CAMSENSOR gpio table request"
2064 "failed\n", __func__);
2065 return rc;
2066 }
2067
2068 return rc;
2069}
2070
2071static void config_camera_off_gpios_rear(void)
2072{
2073 msm_camera_vreg_config(0);
2074 config_gpio_table(camera_off_gpio_table,
2075 ARRAY_SIZE(camera_off_gpio_table));
2076}
2077
2078static int config_camera_on_gpios_front(void)
2079{
2080 int rc = 0;
2081
2082 msm_camera_vreg_config(1);
2083
2084 rc = config_gpio_table(camera_on_gpio_table,
2085 ARRAY_SIZE(camera_on_gpio_table));
2086 if (rc < 0) {
2087 pr_err("%s: CAMSENSOR gpio table request"
2088 "failed\n", __func__);
2089 return rc;
2090 }
2091
2092 return rc;
2093}
2094
2095static void config_camera_off_gpios_front(void)
2096{
2097 msm_camera_vreg_config(0);
2098
2099 config_gpio_table(camera_off_gpio_table,
2100 ARRAY_SIZE(camera_off_gpio_table));
2101}
2102
2103struct msm_camera_device_platform_data msm_camera_data_rear = {
2104 .camera_gpio_on = config_camera_on_gpios_rear,
2105 .camera_gpio_off = config_camera_off_gpios_rear,
2106 .ioext.csiphy = 0xA1000000,
2107 .ioext.csisz = 0x00100000,
2108 .ioext.csiirq = INT_CSI_IRQ_1,
2109 .ioclk.mclk_clk_rate = 24000000,
2110 .ioclk.vfe_clk_rate = 192000000,
2111 .ioext.appphy = MSM_CLK_CTL_PHYS,
2112 .ioext.appsz = MSM_CLK_CTL_SIZE,
2113};
2114
2115struct msm_camera_device_platform_data msm_camera_data_front = {
2116 .camera_gpio_on = config_camera_on_gpios_front,
2117 .camera_gpio_off = config_camera_off_gpios_front,
2118 .ioext.csiphy = 0xA0F00000,
2119 .ioext.csisz = 0x00100000,
2120 .ioext.csiirq = INT_CSI_IRQ_0,
2121 .ioclk.mclk_clk_rate = 24000000,
2122 .ioclk.vfe_clk_rate = 192000000,
2123 .ioext.appphy = MSM_CLK_CTL_PHYS,
2124 .ioext.appsz = MSM_CLK_CTL_SIZE,
2125};
2126
2127#ifdef CONFIG_OV5640
2128static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
2129 .mount_angle = 90
2130};
2131
2132static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
2133 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
2134 ._fsrc.led_src.led_name = "flashlight",
2135 ._fsrc.led_src.led_name_len = 10,
2136};
2137
2138static struct msm_camera_sensor_flash_data flash_ov5640 = {
2139 .flash_type = MSM_CAMERA_FLASH_LED,
2140 .flash_src = &msm_flash_src_ov5640,
2141};
2142
2143static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
2144 .sensor_name = "ov5640",
2145 .sensor_reset_enable = 1,
2146 .sensor_reset = GPIO_CAM_5MP_RESET,
2147 .sensor_pwd = GPIO_CAM_5MP_SHDN_EN,
2148 .vcm_pwd = 0,
2149 .vcm_enable = 0,
2150 .pdata = &msm_camera_data_rear,
2151 .flash_data = &flash_ov5640,
2152 .sensor_platform_info = &ov5640_sensor_info,
2153 .csi_if = 1,
2154};
2155
2156static struct platform_device msm_camera_sensor_ov5640 = {
2157 .name = "msm_camera_ov5640",
2158 .dev = {
2159 .platform_data = &msm_camera_sensor_ov5640_data,
2160 },
2161};
2162#endif
2163
2164#ifdef CONFIG_WEBCAM_OV7692_QRD
2165static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
2166 .mount_angle = 90
2167};
2168
2169static struct msm_camera_sensor_flash_data flash_ov7692 = {
2170 .flash_type = MSM_CAMERA_FLASH_NONE,
2171};
2172
2173static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
2174 .sensor_name = "ov7692",
2175 .sensor_reset_enable = 0,
2176 .sensor_reset = 0,
2177 .sensor_pwd = GPIO_CAM_3MP_PWDN,
2178 .vcm_pwd = 0,
2179 .vcm_enable = 0,
2180 .pdata = &msm_camera_data_front,
2181 .flash_data = &flash_ov7692,
2182 .sensor_platform_info = &ov7692_sensor_7627a_info,
2183 .csi_if = 1,
2184};
2185
2186static struct platform_device msm_camera_sensor_ov7692 = {
2187 .name = "msm_camera_ov7692",
2188 .dev = {
2189 .platform_data = &msm_camera_sensor_ov7692_data,
2190 },
2191};
2192#endif
2193
2194static struct i2c_board_info i2c_camera_devices[] = {
2195 #ifdef CONFIG_OV5640
2196 {
2197 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
2198 },
2199 #endif
2200 #ifdef CONFIG_WEBCAM_OV7692_QRD
2201 {
2202 I2C_BOARD_INFO("ov7692", 0x78),
2203 },
2204 #endif
2205};
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302206static struct platform_device *qrd1_devices[] __initdata = {
2207 &msm_device_dmov,
2208 &msm_device_smd,
2209 &msm_device_uart1,
2210 &msm_device_uart_dm1,
2211 &msm_gsbi0_qup_i2c_device,
2212 &msm_gsbi1_qup_i2c_device,
2213 &msm_device_otg,
2214 &msm_device_gadget_peripheral,
2215 &android_usb_device,
2216 &android_pmem_device,
2217 &android_pmem_adsp_device,
Taniya Das0a5303a2011-08-23 18:47:48 +05302218 &msm_fb_device,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302219 &android_pmem_audio_device,
2220 &msm_device_snd,
2221 &msm_device_adspdec,
2222 &msm_batt_device,
Taniya Das7a22cdd2011-09-08 14:57:00 +05302223#ifdef CONFIG_OV5640
2224 &msm_camera_sensor_ov5640,
2225#endif
2226#ifdef CONFIG_WEBCAM_OV7692_QRD
2227 &msm_camera_sensor_ov7692,
2228#endif
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302229 &msm_kgsl_3d0,
2230#ifdef CONFIG_BT
2231 &msm_bt_power_device,
2232#endif
Taniya Das0a5303a2011-08-23 18:47:48 +05302233 &mipi_dsi_truly_panel_device,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302234 &msm_wlan_ar6000_pm_device,
2235 &asoc_msm_pcm,
2236 &asoc_msm_dai0,
2237 &asoc_msm_dai1,
2238};
2239
2240static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
2241static int __init pmem_kernel_ebi1_size_setup(char *p)
2242{
2243 pmem_kernel_ebi1_size = memparse(p, NULL);
2244 return 0;
2245}
2246early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2247
2248static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
2249static int __init pmem_audio_size_setup(char *p)
2250{
2251 pmem_audio_size = memparse(p, NULL);
2252 return 0;
2253}
2254early_param("pmem_audio_size", pmem_audio_size_setup);
2255
2256static void __init msm_msm7627a_allocate_memory_regions(void)
2257{
Taniya Das0a5303a2011-08-23 18:47:48 +05302258 void *addr;
2259 unsigned long size;
2260
2261 size = fb_size ? : MSM_FB_SIZE;
2262 addr = alloc_bootmem_align(size, 0x1000);
2263 msm_fb_resources[0].start = __pa(addr);
2264 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
2265 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", size,
2266 addr, __pa(addr));
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302267}
2268
2269static struct memtype_reserve msm7627a_reserve_table[] __initdata = {
2270 [MEMTYPE_SMI] = {
2271 },
2272 [MEMTYPE_EBI0] = {
2273 .flags = MEMTYPE_FLAGS_1M_ALIGN,
2274 },
2275 [MEMTYPE_EBI1] = {
2276 .flags = MEMTYPE_FLAGS_1M_ALIGN,
2277 },
2278};
2279
Taniya Das0a5303a2011-08-23 18:47:48 +05302280static struct msm_panel_common_pdata mdp_pdata = {
2281 .gpio = 97,
2282 .mdp_rev = MDP_REV_303,
2283};
2284
2285#define GPIO_LCDC_BRDG_PD 128
2286#define GPIO_LCDC_BRDG_RESET_N 129
2287#define GPIO_LCD_DSI_SEL 125
2288
2289static unsigned mipi_dsi_gpio[] = {
2290 GPIO_CFG(GPIO_LCDC_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT,
2291 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */
2292 GPIO_CFG(GPIO_LCDC_BRDG_PD, 0, GPIO_CFG_OUTPUT,
2293 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_PD */
2294};
2295
2296static unsigned lcd_dsi_sel_gpio[] = {
2297 GPIO_CFG(GPIO_LCD_DSI_SEL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
2298 GPIO_CFG_2MA),
2299};
2300
2301enum {
2302 DSI_SINGLE_LANE = 1,
2303 DSI_TWO_LANES,
2304};
2305
2306static int msm_fb_get_lane_config(void)
2307{
2308 pr_info("DSI_TWO_LANES\n");
2309 return DSI_TWO_LANES;
2310}
2311
2312static int mipi_truly_sel_mode(int video_mode)
2313{
2314 int rc = 0;
2315
2316 rc = gpio_request(GPIO_LCD_DSI_SEL, "lcd_dsi_sel");
2317 if (rc < 0)
2318 goto gpio_error;
2319
2320 rc = gpio_tlmm_config(lcd_dsi_sel_gpio[0], GPIO_CFG_ENABLE);
2321 if (rc)
2322 goto gpio_error;
2323
2324 rc = gpio_direction_output(GPIO_LCD_DSI_SEL, 1);
2325 if (!rc) {
2326 gpio_set_value_cansleep(GPIO_LCD_DSI_SEL, video_mode);
2327 return rc;
2328 } else {
2329 goto gpio_error;
2330 }
2331
2332gpio_error:
2333 pr_err("mipi_truly_sel_mode failed\n");
2334 gpio_free(GPIO_LCD_DSI_SEL);
2335 return rc;
2336}
2337
2338static int msm_fb_dsi_client_qrd1_reset(void)
2339{
2340 int rc = 0;
2341
2342 rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n");
2343 if (rc < 0) {
2344 pr_err("failed to request lcd brdg reset_n\n");
2345 return rc;
2346 }
2347
2348 rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE);
2349 if (rc < 0) {
2350 pr_err("Failed to enable LCDC Bridge reset enable\n");
2351 return rc;
2352 }
2353
2354 rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1);
2355 if (rc < 0) {
2356 pr_err("Failed GPIO bridge pd\n");
2357 gpio_free(GPIO_LCDC_BRDG_RESET_N);
2358 return rc;
2359 }
2360
2361 mipi_truly_sel_mode(1);
2362
2363 return rc;
2364}
2365
2366static int msm_fb_dsi_client_reset(void)
2367{
2368 int rc = 0;
2369
2370 rc = msm_fb_dsi_client_qrd1_reset();
2371 return rc;
2372}
2373
2374static int dsi_gpio_initialized;
2375
2376static int mipi_dsi_panel_qrd1_power(int on)
2377{
2378 int rc = 0;
2379
2380 if (!dsi_gpio_initialized) {
2381 rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en");
2382 if (rc < 0)
2383 return rc;
2384
2385 rc = gpio_direction_output(GPIO_BACKLIGHT_EN, 1);
2386 if (rc < 0) {
2387 pr_err("failed to enable backlight\n");
2388 gpio_free(GPIO_BACKLIGHT_EN);
2389 return rc;
2390 }
2391 dsi_gpio_initialized = 1;
2392 }
2393
2394 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, !!on);
2395
2396 if (!on) {
2397 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
2398 msleep(20);
2399 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0);
2400 msleep(20);
2401 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
2402
2403 }
2404
2405 return rc;
2406}
2407
2408static int mipi_dsi_panel_power(int on)
2409{
2410 int rc = 0;
2411
2412 rc = mipi_dsi_panel_qrd1_power(on);
2413 return rc;
2414}
2415
2416#define MDP_303_VSYNC_GPIO 97
2417
2418#ifdef CONFIG_FB_MSM_MDP303
2419static struct mipi_dsi_platform_data mipi_dsi_pdata = {
2420 .vsync_gpio = MDP_303_VSYNC_GPIO,
2421 .dsi_power_save = mipi_dsi_panel_power,
2422 .dsi_client_reset = msm_fb_dsi_client_reset,
2423 .get_lane_config = msm_fb_get_lane_config,
2424};
2425#endif
2426
2427static void __init msm_fb_add_devices(void)
2428{
2429 msm_fb_register_device("mdp", &mdp_pdata);
2430 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
2431}
2432
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302433static void __init size_pmem_devices(void)
2434{
2435#ifdef CONFIG_ANDROID_PMEM
2436 android_pmem_adsp_pdata.size = pmem_adsp_size;
2437 android_pmem_pdata.size = pmem_mdp_size;
2438 android_pmem_audio_pdata.size = pmem_audio_size;
2439#endif
2440}
2441
2442static void __init reserve_memory_for(struct android_pmem_platform_data *p)
2443{
2444 msm7627a_reserve_table[p->memory_type].size += p->size;
2445}
2446
2447static void __init reserve_pmem_memory(void)
2448{
2449#ifdef CONFIG_ANDROID_PMEM
2450 reserve_memory_for(&android_pmem_adsp_pdata);
2451 reserve_memory_for(&android_pmem_pdata);
2452 reserve_memory_for(&android_pmem_audio_pdata);
2453 msm7627a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
2454#endif
2455}
2456
2457static void __init msm7627a_calculate_reserve_sizes(void)
2458{
2459 size_pmem_devices();
2460 reserve_pmem_memory();
2461}
2462
2463static int msm7627a_paddr_to_memtype(unsigned int paddr)
2464{
2465 return MEMTYPE_EBI1;
2466}
2467
2468static struct reserve_info msm7627a_reserve_info __initdata = {
2469 .memtype_reserve_table = msm7627a_reserve_table,
2470 .calculate_reserve_sizes = msm7627a_calculate_reserve_sizes,
2471 .paddr_to_memtype = msm7627a_paddr_to_memtype,
2472};
2473
2474static void __init msm7627a_reserve(void)
2475{
2476 reserve_info = &msm7627a_reserve_info;
2477 msm_reserve();
2478}
2479
2480static void __init msm_device_i2c_init(void)
2481{
2482 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
2483 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
2484}
2485
2486static struct msm_handset_platform_data hs_platform_data = {
2487 .hs_name = "7k_handset",
2488 .pwr_key_delay_ms = 500, /* 0 will disable end key */
2489};
2490
2491static struct platform_device hs_pdev = {
2492 .name = "msm-handset",
2493 .id = -1,
2494 .dev = {
2495 .platform_data = &hs_platform_data,
2496 },
2497};
2498
2499#define UART1DM_RX_GPIO 45
2500static void __init msm_qrd1_init(void)
2501{
2502 msm7x2x_misc_init();
2503 msm_device_i2c_init();
2504 msm7627a_init_mmc();
2505
Taniya Das7a22cdd2011-09-08 14:57:00 +05302506 qrd1_camera_gpio_cfg();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302507#ifdef CONFIG_SERIAL_MSM_HS
2508 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
2509 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
2510#endif
2511
2512#ifdef CONFIG_USB_MSM_OTG_72K
2513 msm_otg_pdata.swfi_latency = msm7627a_pm_data
2514 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
2515 msm_device_otg.dev.platform_data = &msm_otg_pdata;
2516#endif
2517 msm_device_gadget_peripheral.dev.platform_data =
Taniya Das7a22cdd2011-09-08 14:57:00 +05302518 &msm_gadget_pdata;
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302519 platform_add_devices(qrd1_devices,
Taniya Das7a22cdd2011-09-08 14:57:00 +05302520 ARRAY_SIZE(qrd1_devices));
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302521#ifdef CONFIG_USB_EHCI_MSM_72K
2522 msm7627a_init_host();
2523#endif
2524 msm_pm_set_platform_data(msm7627a_pm_data,
2525 ARRAY_SIZE(msm7627a_pm_data));
Taniya Das0a5303a2011-08-23 18:47:48 +05302526 msm_fb_add_devices();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302527
2528#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
2529 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
Taniya Das7a22cdd2011-09-08 14:57:00 +05302530 bahama_devices,
2531 ARRAY_SIZE(bahama_devices));
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302532 bt_power_init();
2533#endif
Taniya Dasda408822011-09-06 12:54:06 +05302534
Taniya Das7a22cdd2011-09-08 14:57:00 +05302535 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID, i2c_camera_devices,
2536 ARRAY_SIZE(i2c_camera_devices));
2537
Taniya Dasda408822011-09-06 12:54:06 +05302538#if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) || \
2539 defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C_MODULE)
2540 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
2541 synaptic_i2c_clearpad3k,
2542 ARRAY_SIZE(synaptic_i2c_clearpad3k));
2543#endif
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302544 platform_device_register(&hs_pdev);
2545
2546#ifdef CONFIG_MSM_RPC_VIBRATOR
2547 msm_init_pmic_vibrator();
2548#endif
2549}
2550
2551static void __init qrd7627a_init_early(void)
2552{
2553 msm_msm7627a_allocate_memory_regions();
2554}
2555
2556MACHINE_START(MSM7627A_QRD1, "QRD MSM7627a QRD1")
2557 .boot_params = PHYS_OFFSET + 0x100,
2558 .map_io = msm_common_io_init,
2559 .reserve = msm7627a_reserve,
2560 .init_irq = msm_init_irq,
2561 .init_machine = msm_qrd1_init,
2562 .timer = &msm_timer,
2563 .init_early = qrd7627a_init_early,
Pankaj Kumarbf8a2a32011-10-21 11:47:21 +05302564 .handle_irq = vic_handle_irq,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302565MACHINE_END