blob: 889ac000ff56be101af22d72c8d8f90a4939f7a2 [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>
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
59#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
60#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
61#define BAHAMA_SLAVE_ID_FM_REG 0x02
62#define FM_GPIO 83
63
64enum {
65 GPIO_HOST_VBUS_EN = 107,
66 GPIO_BT_SYS_REST_EN = 114,
67 GPIO_WAKE_ON_WIRELESS,
68 GPIO_BACKLIGHT_EN,
Taniya Das7a22cdd2011-09-08 14:57:00 +053069 GPIO_NC,
70 GPIO_CAM_3MP_PWDN, /* CAM_VGA */
Taniya Dasc98bfbc2011-08-23 09:58:55 +053071 GPIO_WLAN_EN,
72 GPIO_CAM_5MP_SHDN_EN,
73 GPIO_CAM_5MP_RESET,
Taniya Das7a22cdd2011-09-08 14:57:00 +053074 GPIO_TP,
75 GPIO_CAM_GP_CAMIF_RESET,
Taniya Dasc98bfbc2011-08-23 09:58:55 +053076};
77
78 /* FM Platform power and shutdown routines */
79#define FPGA_MSM_CNTRL_REG2 0x90008010
80
Chintan Pandya3b2aff72011-11-25 16:26:08 +053081#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Taniya Dasc98bfbc2011-08-23 09:58:55 +053082static void config_pcm_i2s_mode(int mode)
83{
84 void __iomem *cfg_ptr;
85 u8 reg2;
86
87 cfg_ptr = ioremap_nocache(FPGA_MSM_CNTRL_REG2, sizeof(char));
88
89 if (!cfg_ptr)
90 return;
91 if (mode) {
92 /*enable the pcm mode in FPGA*/
93 reg2 = readb_relaxed(cfg_ptr);
94 if (reg2 == 0) {
95 reg2 = 1;
96 writeb_relaxed(reg2, cfg_ptr);
97 }
98 } else {
99 /*enable i2s mode in FPGA*/
100 reg2 = readb_relaxed(cfg_ptr);
101 if (reg2 == 1) {
102 reg2 = 0;
103 writeb_relaxed(reg2, cfg_ptr);
104 }
105 }
106 iounmap(cfg_ptr);
107}
108
109static unsigned fm_i2s_config_power_on[] = {
110 /*FM_I2S_SD*/
111 GPIO_CFG(68, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
112 /*FM_I2S_WS*/
113 GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
114 /*FM_I2S_SCK*/
115 GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
116};
117
118static unsigned fm_i2s_config_power_off[] = {
119 /*FM_I2S_SD*/
120 GPIO_CFG(68, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
121 /*FM_I2S_WS*/
122 GPIO_CFG(70, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
123 /*FM_I2S_SCK*/
124 GPIO_CFG(71, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
125};
126
127static unsigned bt_config_power_on[] = {
128 /*RFR*/
129 GPIO_CFG(43, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
130 /*CTS*/
131 GPIO_CFG(44, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
132 /*RX*/
133 GPIO_CFG(45, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
134 /*TX*/
135 GPIO_CFG(46, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
136};
137static unsigned bt_config_pcm_on[] = {
138 /*PCM_DOUT*/
139 GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
140 /*PCM_DIN*/
141 GPIO_CFG(69, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
142 /*PCM_SYNC*/
143 GPIO_CFG(70, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
144 /*PCM_CLK*/
145 GPIO_CFG(71, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
146};
147static unsigned bt_config_power_off[] = {
148 /*RFR*/
149 GPIO_CFG(43, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
150 /*CTS*/
151 GPIO_CFG(44, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
152 /*RX*/
153 GPIO_CFG(45, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
154 /*TX*/
155 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
156};
157static unsigned bt_config_pcm_off[] = {
158 /*PCM_DOUT*/
159 GPIO_CFG(68, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
160 /*PCM_DIN*/
161 GPIO_CFG(69, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
162 /*PCM_SYNC*/
163 GPIO_CFG(70, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
164 /*PCM_CLK*/
165 GPIO_CFG(71, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
166};
167
168
169static int config_i2s(int mode)
170{
171 int pin, rc = 0;
172
173 if (mode == FM_I2S_ON) {
174 if (machine_is_msm7627a_qrd1())
175 config_pcm_i2s_mode(0);
176 pr_err("%s mode = FM_I2S_ON", __func__);
177 for (pin = 0; pin < ARRAY_SIZE(fm_i2s_config_power_on);
178 pin++) {
179 rc = gpio_tlmm_config(
180 fm_i2s_config_power_on[pin],
181 GPIO_CFG_ENABLE
182 );
183 if (rc < 0)
184 return rc;
185 }
186 } else if (mode == FM_I2S_OFF) {
187 pr_err("%s mode = FM_I2S_OFF", __func__);
188 for (pin = 0; pin < ARRAY_SIZE(fm_i2s_config_power_off);
189 pin++) {
190 rc = gpio_tlmm_config(
191 fm_i2s_config_power_off[pin],
192 GPIO_CFG_ENABLE
193 );
194 if (rc < 0)
195 return rc;
196 }
197 }
198 return rc;
199}
200static int config_pcm(int mode)
201{
202 int pin, rc = 0;
203
204 if (mode == BT_PCM_ON) {
205 if (machine_is_msm7627a_qrd1())
206 config_pcm_i2s_mode(1);
207 pr_err("%s mode =BT_PCM_ON", __func__);
208 for (pin = 0; pin < ARRAY_SIZE(bt_config_pcm_on);
209 pin++) {
210 rc = gpio_tlmm_config(bt_config_pcm_on[pin],
211 GPIO_CFG_ENABLE);
212 if (rc < 0)
213 return rc;
214 }
215 } else if (mode == BT_PCM_OFF) {
216 pr_err("%s mode =BT_PCM_OFF", __func__);
217 for (pin = 0; pin < ARRAY_SIZE(bt_config_pcm_off);
218 pin++) {
219 rc = gpio_tlmm_config(bt_config_pcm_off[pin],
220 GPIO_CFG_ENABLE);
221 if (rc < 0)
222 return rc;
223 }
224
225 }
226
227 return rc;
228}
229
230static int msm_bahama_setup_pcm_i2s(int mode)
231{
232 int fm_state = 0, bt_state = 0;
233 int rc = 0;
234 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
235
236 fm_state = marimba_get_fm_status(&config);
237 bt_state = marimba_get_bt_status(&config);
238
239 switch (mode) {
240 case BT_PCM_ON:
241 case BT_PCM_OFF:
242 if (!fm_state)
243 rc = config_pcm(mode);
244 break;
245 case FM_I2S_ON:
246 rc = config_i2s(mode);
247 break;
248 case FM_I2S_OFF:
249 if (bt_state)
250 rc = config_pcm(BT_PCM_ON);
251 else
252 rc = config_i2s(mode);
253 break;
254 default:
255 rc = -EIO;
256 pr_err("%s:Unsupported mode", __func__);
257 }
258 return rc;
259}
260
261static int bt_set_gpio(int on)
262{
263 int rc = 0;
264 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
265
266 if (on) {
267 rc = gpio_direction_output(GPIO_BT_SYS_REST_EN, 1);
268 msleep(100);
269 } else {
270 if (!marimba_get_fm_status(&config) &&
271 !marimba_get_bt_status(&config)) {
272 gpio_set_value_cansleep(GPIO_BT_SYS_REST_EN, 0);
273 rc = gpio_direction_input(GPIO_BT_SYS_REST_EN);
274 msleep(100);
275 }
276 }
277 if (rc)
278 pr_err("%s: BT sys_reset_en GPIO : Error", __func__);
279
280 return rc;
281}
Pankaj Kumar27c02642011-09-22 15:55:55 +0530282static struct regulator *fm_regulator;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530283static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
284{
285 int rc = 0;
286 const char *id = "FMPW";
287 uint32_t irqcfg;
288 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
289 u8 value;
290
291 /* Voting for 1.8V Regulator */
Pankaj Kumar27c02642011-09-22 15:55:55 +0530292 fm_regulator = regulator_get(NULL , "msme1");
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530293 if (IS_ERR(fm_regulator)) {
Pankaj Kumar27c02642011-09-22 15:55:55 +0530294 rc = PTR_ERR(fm_regulator);
295 pr_err("%s: could not get regulator: %d\n", __func__, rc);
296 goto out;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530297 }
298
299 /* Set the voltage level to 1.8V */
Pankaj Kumar27c02642011-09-22 15:55:55 +0530300 rc = regulator_set_voltage(fm_regulator, 1800000, 1800000);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530301 if (rc < 0) {
Pankaj Kumar27c02642011-09-22 15:55:55 +0530302 pr_err("%s: could not set voltage: %d\n", __func__, rc);
303 goto reg_free;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530304 }
305
306 /* Enabling the 1.8V regulator */
Pankaj Kumar27c02642011-09-22 15:55:55 +0530307 rc = regulator_enable(fm_regulator);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530308 if (rc) {
Pankaj Kumar27c02642011-09-22 15:55:55 +0530309 pr_err("%s: could not enable regulator: %d\n", __func__, rc);
310 goto reg_free;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530311 }
312
313 /* Voting for 19.2MHz clock */
314 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
315 PMAPP_CLOCK_VOTE_ON);
316 if (rc < 0) {
317 pr_err("%s: clock vote failed with :(%d)\n",
318 __func__, rc);
Pankaj Kumar27c02642011-09-22 15:55:55 +0530319 goto reg_disable;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530320 }
321
322 rc = bt_set_gpio(1);
323 if (rc) {
324 pr_err("%s: bt_set_gpio = %d", __func__, rc);
Pankaj Kumar27c02642011-09-22 15:55:55 +0530325 goto gpio_deconfig;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530326 }
327 /*re-write FM Slave Id, after reset*/
328 value = BAHAMA_SLAVE_ID_FM_ADDR;
329 rc = marimba_write_bit_mask(&config,
330 BAHAMA_SLAVE_ID_FM_REG, &value, 1, 0xFF);
331 if (rc < 0) {
332 pr_err("%s: FM Slave ID rewrite Failed = %d", __func__, rc);
Pankaj Kumar27c02642011-09-22 15:55:55 +0530333 goto gpio_deconfig;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530334 }
335 /* Configuring the FM GPIO */
336 irqcfg = GPIO_CFG(FM_GPIO, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
337 GPIO_CFG_2MA);
338
339 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
340 if (rc) {
341 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
342 __func__, irqcfg, rc);
Pankaj Kumar27c02642011-09-22 15:55:55 +0530343 goto gpio_deconfig;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530344 }
345
346 return 0;
347
Pankaj Kumar27c02642011-09-22 15:55:55 +0530348gpio_deconfig:
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530349 pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
350 PMAPP_CLOCK_VOTE_OFF);
351 bt_set_gpio(0);
Pankaj Kumar27c02642011-09-22 15:55:55 +0530352reg_disable:
353 regulator_disable(fm_regulator);
354reg_free:
355 regulator_put(fm_regulator);
356 fm_regulator = NULL;
357out:
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530358 return rc;
359};
360
361static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
362{
363 int rc;
364 const char *id = "FMPW";
365
366 /* Releasing the GPIO line used by FM */
367 uint32_t irqcfg = GPIO_CFG(FM_GPIO, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
368 GPIO_CFG_2MA);
369
370 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
371 if (rc)
372 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
373 __func__, irqcfg, rc);
374
375 /* Releasing the 1.8V Regulator */
Pankaj Kumar27c02642011-09-22 15:55:55 +0530376 if (!IS_ERR_OR_NULL(fm_regulator)) {
377 rc = regulator_disable(fm_regulator);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530378 if (rc)
Pankaj Kumar27c02642011-09-22 15:55:55 +0530379 pr_err("%s: could not disable regulator: %d\n",
380 __func__, rc);
381 regulator_put(fm_regulator);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530382 fm_regulator = NULL;
383 }
384
385 /* Voting off the clock */
386 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
387 PMAPP_CLOCK_VOTE_OFF);
388 if (rc < 0)
389 pr_err("%s: voting off failed with :(%d)\n",
390 __func__, rc);
391 rc = bt_set_gpio(0);
392 if (rc)
393 pr_err("%s: bt_set_gpio = %d", __func__, rc);
394}
395
396static struct marimba_fm_platform_data marimba_fm_pdata = {
397 .fm_setup = fm_radio_setup,
398 .fm_shutdown = fm_radio_shutdown,
399 .irq = MSM_GPIO_TO_INT(FM_GPIO),
400 .vreg_s2 = NULL,
401 .vreg_xo_out = NULL,
402 /* Configuring the FM SoC as I2S Master */
403 .is_fm_soc_i2s_master = true,
404 .config_i2s_gpio = msm_bahama_setup_pcm_i2s,
405};
Chintan Pandya3b2aff72011-11-25 16:26:08 +0530406#endif
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530407
408static struct platform_device msm_wlan_ar6000_pm_device = {
409 .name = "wlan_ar6000_pm_dev",
410 .id = -1,
411};
412
413#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
414
415static struct platform_device msm_bt_power_device = {
416 .name = "bt_power",
417};
418struct bahama_config_register {
419 u8 reg;
420 u8 value;
421 u8 mask;
422};
423struct bt_vreg_info {
424 const char *name;
425 unsigned int pmapp_id;
Pankaj Kumar27c02642011-09-22 15:55:55 +0530426 unsigned int min_level;
427 unsigned int max_level;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530428 unsigned int is_pin_controlled;
Pankaj Kumar27c02642011-09-22 15:55:55 +0530429 struct regulator *reg;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530430};
431static struct bt_vreg_info bt_vregs[] = {
Pankaj Kumar27c02642011-09-22 15:55:55 +0530432 {"msme1", 2, 1800000, 1800000, 0, NULL},
433 {"bt", 21, 2900000, 3050000, 1, NULL}
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530434};
435
436static int bahama_bt(int on)
437{
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530438 int rc = 0;
439 int i;
440
441 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
442
443 struct bahama_variant_register {
444 const size_t size;
445 const struct bahama_config_register *set;
446 };
447
448 const struct bahama_config_register *p;
449
450 u8 version;
451
452 const struct bahama_config_register v10_bt_on[] = {
453 { 0xE9, 0x00, 0xFF },
454 { 0xF4, 0x80, 0xFF },
455 { 0xE4, 0x00, 0xFF },
456 { 0xE5, 0x00, 0x0F },
457#ifdef CONFIG_WLAN
458 { 0xE6, 0x38, 0x7F },
459 { 0xE7, 0x06, 0xFF },
460#endif
461 { 0xE9, 0x21, 0xFF },
462 { 0x01, 0x0C, 0x1F },
463 { 0x01, 0x08, 0x1F },
464 };
465
466 const struct bahama_config_register v20_bt_on_fm_off[] = {
467 { 0x11, 0x0C, 0xFF },
468 { 0x13, 0x01, 0xFF },
469 { 0xF4, 0x80, 0xFF },
470 { 0xF0, 0x00, 0xFF },
471 { 0xE9, 0x00, 0xFF },
472#ifdef CONFIG_WLAN
473 { 0x81, 0x00, 0x7F },
474 { 0x82, 0x00, 0xFF },
475 { 0xE6, 0x38, 0x7F },
476 { 0xE7, 0x06, 0xFF },
477#endif
478 { 0x8E, 0x15, 0xFF },
479 { 0x8F, 0x15, 0xFF },
480 { 0x90, 0x15, 0xFF },
481
482 { 0xE9, 0x21, 0xFF },
483 };
484
485 const struct bahama_config_register v20_bt_on_fm_on[] = {
486 { 0x11, 0x0C, 0xFF },
487 { 0x13, 0x01, 0xFF },
488 { 0xF4, 0x86, 0xFF },
489 { 0xF0, 0x06, 0xFF },
490 { 0xE9, 0x00, 0xFF },
491#ifdef CONFIG_WLAN
492 { 0x81, 0x00, 0x7F },
493 { 0x82, 0x00, 0xFF },
494 { 0xE6, 0x38, 0x7F },
495 { 0xE7, 0x06, 0xFF },
496#endif
497 { 0xE9, 0x21, 0xFF },
498 };
499
500 const struct bahama_config_register v10_bt_off[] = {
501 { 0xE9, 0x00, 0xFF },
502 };
503
504 const struct bahama_config_register v20_bt_off_fm_off[] = {
505 { 0xF4, 0x84, 0xFF },
506 { 0xF0, 0x04, 0xFF },
507 { 0xE9, 0x00, 0xFF }
508 };
509
510 const struct bahama_config_register v20_bt_off_fm_on[] = {
511 { 0xF4, 0x86, 0xFF },
512 { 0xF0, 0x06, 0xFF },
513 { 0xE9, 0x00, 0xFF }
514 };
515 const struct bahama_variant_register bt_bahama[2][3] = {
516 {
517 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
518 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
519 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
520 },
521 {
522 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
523 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
524 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
525 }
526 };
527
528 u8 offset = 0; /* index into bahama configs */
529 on = on ? 1 : 0;
530 version = marimba_read_bahama_ver(&config);
531 if ((int)version < 0 || version == BAHAMA_VER_UNSUPPORTED) {
532 dev_err(&msm_bt_power_device.dev, "%s: Bahama \
533 version read Error, version = %d \n",
534 __func__, version);
535 return -EIO;
536 }
537
538 if (version == BAHAMA_VER_2_0) {
539 if (marimba_get_fm_status(&config))
540 offset = 0x01;
541 }
542
543 p = bt_bahama[on][version + offset].set;
544
545 dev_info(&msm_bt_power_device.dev,
546 "%s: found version %d\n", __func__, version);
547
548 for (i = 0; i < bt_bahama[on][version + offset].size; i++) {
549 u8 value = (p+i)->value;
550 rc = marimba_write_bit_mask(&config,
551 (p+i)->reg,
552 &value,
553 sizeof((p+i)->value),
554 (p+i)->mask);
555 if (rc < 0) {
556 dev_err(&msm_bt_power_device.dev,
557 "%s: reg %x write failed: %d\n",
558 __func__, (p+i)->reg, rc);
559 return rc;
560 }
561 dev_dbg(&msm_bt_power_device.dev,
562 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
563 __func__, (p+i)->reg,
564 value, (p+i)->mask);
565 value = 0;
566 rc = marimba_read_bit_mask(&config,
567 (p+i)->reg, &value,
568 sizeof((p+i)->value), (p+i)->mask);
569 if (rc < 0)
570 dev_err(&msm_bt_power_device.dev, "%s marimba_read_bit_mask- error",
571 __func__);
572 dev_dbg(&msm_bt_power_device.dev,
573 "%s: reg 0x%02x read value 0x%02x mask 0x%02x\n",
574 __func__, (p+i)->reg,
575 value, (p+i)->mask);
576 }
577 /* Update BT Status */
578 if (on)
579 marimba_set_bt_status(&config, true);
580 else
581 marimba_set_bt_status(&config, false);
582 return rc;
583}
584static int bluetooth_switch_regulators(int on)
585{
586 int i, rc = 0;
587 const char *id = "BTPW";
588
589 for (i = 0; i < ARRAY_SIZE(bt_vregs); i++) {
Pankaj Kumar27c02642011-09-22 15:55:55 +0530590 if (IS_ERR_OR_NULL(bt_vregs[i].reg)) {
591 rc = bt_vregs[i].reg ?
592 PTR_ERR(bt_vregs[i].reg) :
593 -ENODEV;
594 dev_err(&msm_bt_power_device.dev,
595 "%s: invalid regulator handle for %s: %d\n",
596 __func__, bt_vregs[i].name, rc);
597 goto reg_disable;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530598 }
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530599
Pankaj Kumar27c02642011-09-22 15:55:55 +0530600 rc = on ? regulator_set_voltage(bt_vregs[i].reg,
601 bt_vregs[i].min_level,
602 bt_vregs[i].max_level) : 0;
603 if (rc) {
604 dev_err(&msm_bt_power_device.dev,
605 "%s: could not set voltage for %s: %d\n",
606 __func__, bt_vregs[i].name, rc);
607 goto reg_disable;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530608 }
Pankaj Kumar27c02642011-09-22 15:55:55 +0530609
610 rc = on ? regulator_enable(bt_vregs[i].reg) : 0;
611 if (rc) {
612 dev_err(&msm_bt_power_device.dev,
613 "%s: could not %sable regulator %s: %d\n",
614 __func__, "en", bt_vregs[i].name, rc);
615 goto reg_disable;
616 }
617
618 if (bt_vregs[i].is_pin_controlled) {
619 rc = pmapp_vreg_lpm_pincntrl_vote(id,
620 bt_vregs[i].pmapp_id,
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530621 PMAPP_CLOCK_ID_D1,
622 on ? PMAPP_CLOCK_VOTE_ON :
Pankaj Kumar27c02642011-09-22 15:55:55 +0530623 PMAPP_CLOCK_VOTE_OFF);
624 if (rc) {
625 dev_err(&msm_bt_power_device.dev,
626 "%s: pin control failed for %s: %d\n",
627 __func__, bt_vregs[i].name, rc);
628 goto pin_cnt_fail;
629 }
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530630 }
Pankaj Kumar27c02642011-09-22 15:55:55 +0530631 rc = on ? 0 : regulator_disable(bt_vregs[i].reg);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530632
Pankaj Kumar27c02642011-09-22 15:55:55 +0530633 if (rc) {
634 dev_err(&msm_bt_power_device.dev,
635 "%s: could not %sable regulator %s: %d\n",
636 __func__, "dis", bt_vregs[i].name, rc);
637 goto reg_disable;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530638 }
639 }
640
641 return rc;
Pankaj Kumar27c02642011-09-22 15:55:55 +0530642pin_cnt_fail:
643 if (on)
644 regulator_disable(bt_vregs[i].reg);
645reg_disable:
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530646 while (i) {
Pankaj Kumar27c02642011-09-22 15:55:55 +0530647 if (on) {
648 i--;
649 regulator_disable(bt_vregs[i].reg);
650 regulator_put(bt_vregs[i].reg);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530651 }
Pankaj Kumar27c02642011-09-22 15:55:55 +0530652 }
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530653 return rc;
654}
655
Pankaj Kumar27c02642011-09-22 15:55:55 +0530656static struct regulator *reg_s3;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530657static unsigned int msm_bahama_setup_power(void)
658{
659 int rc = 0;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530660
Pankaj Kumar27c02642011-09-22 15:55:55 +0530661 reg_s3 = regulator_get(NULL, "msme1");
662 if (IS_ERR(reg_s3)) {
663 rc = PTR_ERR(reg_s3);
664 pr_err("%s: could not get regulator: %d\n", __func__, rc);
665 goto out;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530666 }
Pankaj Kumar27c02642011-09-22 15:55:55 +0530667
668 rc = regulator_set_voltage(reg_s3, 1800000, 1800000);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530669 if (rc < 0) {
Pankaj Kumar27c02642011-09-22 15:55:55 +0530670 pr_err("%s: could not set voltage: %d\n", __func__, rc);
671 goto reg_fail;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530672 }
Pankaj Kumar27c02642011-09-22 15:55:55 +0530673
674 rc = regulator_enable(reg_s3);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530675 if (rc < 0) {
Pankaj Kumar27c02642011-09-22 15:55:55 +0530676 pr_err("%s: could not enable regulator: %d\n", __func__, rc);
677 goto reg_fail;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530678 }
679
Rahul Kashyap5e59b892011-12-12 16:54:04 +0530680 gpio_tlmm_config(GPIO_CFG(GPIO_BT_SYS_REST_EN, 0,
681 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
682 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
683
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530684 /*setup Bahama_sys_reset_n*/
685 rc = gpio_request(GPIO_BT_SYS_REST_EN, "bahama sys_rst_n");
686 if (rc < 0) {
687 pr_err("%s: gpio_request %d = %d\n", __func__,
688 GPIO_BT_SYS_REST_EN, rc);
Pankaj Kumar27c02642011-09-22 15:55:55 +0530689 goto reg_disable;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530690 }
Pankaj Kumar27c02642011-09-22 15:55:55 +0530691
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530692 rc = bt_set_gpio(1);
693 if (rc < 0) {
694 pr_err("%s: bt_set_gpio %d = %d\n", __func__,
695 GPIO_BT_SYS_REST_EN, rc);
696 goto gpio_fail;
697 }
Pankaj Kumar27c02642011-09-22 15:55:55 +0530698
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530699 return rc;
700
701gpio_fail:
702 gpio_free(GPIO_BT_SYS_REST_EN);
Pankaj Kumar27c02642011-09-22 15:55:55 +0530703reg_disable:
704 regulator_disable(reg_s3);
705reg_fail:
706 regulator_put(reg_s3);
707out:
708 reg_s3 = NULL;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530709 return rc;
710}
711
712static unsigned int msm_bahama_shutdown_power(int value)
713{
714 int rc = 0;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530715
Pankaj Kumar27c02642011-09-22 15:55:55 +0530716 if (IS_ERR_OR_NULL(reg_s3)) {
717 rc = reg_s3 ? PTR_ERR(reg_s3) : -ENODEV;
718 goto out;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530719 }
Pankaj Kumar27c02642011-09-22 15:55:55 +0530720
721 rc = regulator_disable(reg_s3);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530722 if (rc) {
Pankaj Kumar27c02642011-09-22 15:55:55 +0530723 pr_err("%s: could not disable regulator: %d\n", __func__, rc);
724 goto out;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530725 }
Pankaj Kumar27c02642011-09-22 15:55:55 +0530726
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530727 if (value == BAHAMA_ID) {
728 rc = bt_set_gpio(0);
729 if (rc) {
730 pr_err("%s: bt_set_gpio = %d\n",
731 __func__, rc);
Pankaj Kumar27c02642011-09-22 15:55:55 +0530732 goto reg_enable;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530733 }
Pankaj Kumar27c02642011-09-22 15:55:55 +0530734 gpio_free(GPIO_BT_SYS_REST_EN);
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530735 }
Pankaj Kumar27c02642011-09-22 15:55:55 +0530736
737 regulator_put(reg_s3);
738 reg_s3 = NULL;
739
740 return 0;
741
742reg_enable:
743 regulator_enable(reg_s3);
744out:
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530745 return rc;
746}
747
748static unsigned int msm_bahama_core_config(int type)
749{
750 int rc = 0;
751
752 if (type == BAHAMA_ID) {
753 int i;
754 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA};
755 const struct bahama_config_register v20_init[] = {
756 /* reg, value, mask */
757 { 0xF4, 0x84, 0xFF }, /* AREG */
758 { 0xF0, 0x04, 0xFF } /* DREG */
759 };
760 if (marimba_read_bahama_ver(&config) == BAHAMA_VER_2_0) {
761 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
762 u8 value = v20_init[i].value;
763 rc = marimba_write_bit_mask(&config,
764 v20_init[i].reg,
765 &value,
766 sizeof(v20_init[i].value),
767 v20_init[i].mask);
768 if (rc < 0) {
769 pr_err("%s: reg %d write failed: %d\n",
770 __func__, v20_init[i].reg, rc);
771 return rc;
772 }
773 pr_debug("%s: reg 0x%02x value 0x%02x"
774 " mask 0x%02x\n",
775 __func__, v20_init[i].reg,
776 v20_init[i].value, v20_init[i].mask);
777 }
778 }
779 }
780 rc = bt_set_gpio(0);
781 if (rc) {
782 pr_err("%s: bt_set_gpio = %d\n",
783 __func__, rc);
784 }
785 pr_debug("core type: %d\n", type);
786 return rc;
787}
788
789static int bluetooth_power(int on)
790{
791 int pin, rc = 0;
792 const char *id = "BTPW";
793 int cid = 0;
794
795 cid = adie_get_detected_connectivity_type();
796 if (cid != BAHAMA_ID) {
797 pr_err("%s: unexpected adie connectivity type: %d\n",
798 __func__, cid);
799 return -ENODEV;
800 }
801 if (on) {
802 /*setup power for BT SOC*/
803 rc = bt_set_gpio(on);
804 if (rc) {
805 pr_err("%s: bt_set_gpio = %d\n",
806 __func__, rc);
807 goto exit;
808 }
809 rc = bluetooth_switch_regulators(on);
810 if (rc < 0) {
811 pr_err("%s: bluetooth_switch_regulators rc = %d",
812 __func__, rc);
813 goto exit;
814 }
815 /*setup BT GPIO lines*/
816 for (pin = 0; pin < ARRAY_SIZE(bt_config_power_on);
817 pin++) {
818 rc = gpio_tlmm_config(bt_config_power_on[pin],
819 GPIO_CFG_ENABLE);
820 if (rc < 0) {
821 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
822 __func__,
823 bt_config_power_on[pin],
824 rc);
825 goto fail_power;
826 }
827 }
828 /*Setup BT clocks*/
829 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
830 PMAPP_CLOCK_VOTE_ON);
831 if (rc < 0) {
832 pr_err("Failed to vote for TCXO_D1 ON\n");
833 goto fail_clock;
834 }
835 msleep(20);
836
837 /*I2C config for Bahama*/
838 rc = bahama_bt(1);
839 if (rc < 0) {
840 pr_err("%s: bahama_bt rc = %d", __func__, rc);
841 goto fail_i2c;
842 }
843 msleep(20);
844
845 /*setup BT PCM lines*/
846 rc = msm_bahama_setup_pcm_i2s(BT_PCM_ON);
847 if (rc < 0) {
848 pr_err("%s: msm_bahama_setup_pcm_i2s , rc =%d\n",
849 __func__, rc);
850 goto fail_power;
851 }
852 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
853 PMAPP_CLOCK_VOTE_PIN_CTRL);
854 if (rc < 0)
855 pr_err("%s:Pin Control Failed, rc = %d",
856 __func__, rc);
857
858 } else {
859 rc = bahama_bt(0);
860 if (rc < 0)
861 pr_err("%s: bahama_bt rc = %d", __func__, rc);
862
863 rc = bt_set_gpio(on);
864 if (rc) {
865 pr_err("%s: bt_set_gpio = %d\n",
866 __func__, rc);
867 }
868fail_i2c:
869 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
870 PMAPP_CLOCK_VOTE_OFF);
871 if (rc < 0)
872 pr_err("%s: Failed to vote Off D1\n", __func__);
873fail_clock:
874 for (pin = 0; pin < ARRAY_SIZE(bt_config_power_off);
875 pin++) {
876 rc = gpio_tlmm_config(bt_config_power_off[pin],
877 GPIO_CFG_ENABLE);
878 if (rc < 0) {
879 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
880 __func__, bt_config_power_off[pin], rc);
881 }
882 }
883 rc = msm_bahama_setup_pcm_i2s(BT_PCM_OFF);
884 if (rc < 0) {
885 pr_err("%s: msm_bahama_setup_pcm_i2s, rc =%d\n",
886 __func__, rc);
887 }
888fail_power:
889 rc = bluetooth_switch_regulators(0);
890 if (rc < 0) {
891 pr_err("%s: switch_regulators : rc = %d",\
892 __func__, rc);
893 goto exit;
894 }
895 }
896 return rc;
897exit:
898 pr_err("%s: failed with rc = %d", __func__, rc);
899 return rc;
900}
901
902static int __init bt_power_init(void)
903{
904 int i, rc = 0;
Pankaj Kumar27c02642011-09-22 15:55:55 +0530905 struct device *dev = &msm_bt_power_device.dev;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530906
Pankaj Kumar27c02642011-09-22 15:55:55 +0530907 for (i = 0; i < ARRAY_SIZE(bt_vregs); i++) {
908 bt_vregs[i].reg = regulator_get(dev, bt_vregs[i].name);
909 if (IS_ERR(bt_vregs[i].reg)) {
910 rc = PTR_ERR(bt_vregs[i].reg);
911 dev_err(dev, "%s: could not get regulator %s: %d\n",
912 __func__, bt_vregs[i].name, rc);
913 goto reg_get_fail;
914 }
915 }
916
917 dev->platform_data = &bluetooth_power;
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530918
919 return rc;
920
Pankaj Kumar27c02642011-09-22 15:55:55 +0530921reg_get_fail:
922 while (i--) {
923 regulator_put(bt_vregs[i].reg);
924 bt_vregs[i].reg = NULL;
925 }
Taniya Dasc98bfbc2011-08-23 09:58:55 +0530926 return rc;
927}
928
929static struct marimba_platform_data marimba_pdata = {
930 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
931 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
932 .bahama_setup = msm_bahama_setup_power,
933 .bahama_shutdown = msm_bahama_shutdown_power,
934 .bahama_core_config = msm_bahama_core_config,
935 .fm = &marimba_fm_pdata,
936};
937
938#endif
939
940#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
941static struct i2c_board_info bahama_devices[] = {
942{
943 I2C_BOARD_INFO("marimba", 0xc),
944 .platform_data = &marimba_pdata,
945},
946};
947#endif
948
949static struct msm_gpio qup_i2c_gpios_io[] = {
950 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
951 "qup_scl" },
952 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
953 "qup_sda" },
954 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
955 "qup_scl" },
956 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
957 "qup_sda" },
958};
959
960static struct msm_gpio qup_i2c_gpios_hw[] = {
961 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
962 "qup_scl" },
963 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
964 "qup_sda" },
965 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
966 "qup_scl" },
967 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
968 "qup_sda" },
969};
970
971static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
972{
973 int rc;
974
975 if (adap_id < 0 || adap_id > 1)
976 return;
977
978 /* Each adapter gets 2 lines from the table */
979 if (config_type)
980 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
981 else
982 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
983 if (rc < 0)
984 pr_err("QUP GPIO request/enable failed: %d\n", rc);
985}
986
987static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
988 .clk_freq = 100000,
989 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
990};
991
992static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
993 .clk_freq = 100000,
994 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
995};
996
997#ifdef CONFIG_ARCH_MSM7X27A
998#define MSM_PMEM_MDP_SIZE 0x1DD1000
999#define MSM_PMEM_ADSP_SIZE 0x1000000
1000
1001#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
1002#define MSM_FB_SIZE 0x260000
1003#else
1004#define MSM_FB_SIZE 0x195000
1005#endif
1006
1007#endif
1008
Taniya Dasda408822011-09-06 12:54:06 +05301009#if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) || \
1010defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C_MODULE)
1011
1012#ifndef CLEARPAD3000_ATTEN_GPIO
1013#define CLEARPAD3000_ATTEN_GPIO (48)
1014#endif
1015
1016#ifndef CLEARPAD3000_RESET_GPIO
1017#define CLEARPAD3000_RESET_GPIO (26)
1018#endif
1019
1020static int synaptics_touchpad_setup(void);
1021
1022static struct msm_gpio clearpad3000_cfg_data[] = {
1023 {GPIO_CFG(CLEARPAD3000_ATTEN_GPIO, 0, GPIO_CFG_INPUT,
1024 GPIO_CFG_NO_PULL, GPIO_CFG_6MA), "rmi4_attn"},
1025 {GPIO_CFG(CLEARPAD3000_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
1026 GPIO_CFG_PULL_DOWN, GPIO_CFG_8MA), "rmi4_reset"},
1027};
1028
1029static struct rmi_XY_pair rmi_offset = {.x = 0, .y = 0};
1030static struct rmi_range rmi_clipx = {.min = 48, .max = 980};
1031static struct rmi_range rmi_clipy = {.min = 7, .max = 1647};
1032static struct rmi_f11_functiondata synaptics_f11_data = {
1033 .swap_axes = false,
1034 .flipX = false,
1035 .flipY = false,
1036 .offset = &rmi_offset,
1037 .button_height = 113,
1038 .clipX = &rmi_clipx,
1039 .clipY = &rmi_clipy,
1040};
1041
1042#define MAX_LEN 100
1043
1044static ssize_t clearpad3000_virtual_keys_register(struct kobject *kobj,
1045 struct kobj_attribute *attr, char *buf)
1046{
1047 char *virtual_keys = __stringify(EV_KEY) ":" __stringify(KEY_MENU) \
1048 ":60:830:120:60" ":" __stringify(EV_KEY) \
1049 ":" __stringify(KEY_HOME) ":180:830:120:60" \
1050 ":" __stringify(EV_KEY) ":" \
1051 __stringify(KEY_SEARCH) ":300:830:120:60" \
1052 ":" __stringify(EV_KEY) ":" \
1053 __stringify(KEY_BACK) ":420:830:120:60" "\n";
1054
1055 return snprintf(buf, strnlen(virtual_keys, MAX_LEN) + 1 , "%s",
1056 virtual_keys);
1057}
1058
1059static struct kobj_attribute clearpad3000_virtual_keys_attr = {
1060 .attr = {
1061 .name = "virtualkeys.sensor00fn11",
1062 .mode = S_IRUGO,
1063 },
1064 .show = &clearpad3000_virtual_keys_register,
1065};
1066
1067static struct attribute *virtual_key_properties_attrs[] = {
1068 &clearpad3000_virtual_keys_attr.attr,
1069 NULL
1070};
1071
1072static struct attribute_group virtual_key_properties_attr_group = {
1073 .attrs = virtual_key_properties_attrs,
1074};
1075
1076struct kobject *virtual_key_properties_kobj;
1077
1078static struct rmi_functiondata synaptics_functiondata[] = {
1079 {
1080 .function_index = RMI_F11_INDEX,
1081 .data = &synaptics_f11_data,
1082 },
1083};
1084
1085static struct rmi_functiondata_list synaptics_perfunctiondata = {
1086 .count = ARRAY_SIZE(synaptics_functiondata),
1087 .functiondata = synaptics_functiondata,
1088};
1089
1090static struct rmi_sensordata synaptics_sensordata = {
1091 .perfunctiondata = &synaptics_perfunctiondata,
1092 .rmi_sensor_setup = synaptics_touchpad_setup,
1093};
1094
1095static struct rmi_i2c_platformdata synaptics_platformdata = {
1096 .i2c_address = 0x2c,
1097 .irq_type = IORESOURCE_IRQ_LOWLEVEL,
1098 .sensordata = &synaptics_sensordata,
1099};
1100
1101static struct i2c_board_info synaptic_i2c_clearpad3k[] = {
1102 {
1103 I2C_BOARD_INFO("rmi4_ts", 0x2c),
1104 .platform_data = &synaptics_platformdata,
1105 },
1106};
1107
1108static int synaptics_touchpad_setup(void)
1109{
1110 int retval = 0;
1111
1112 virtual_key_properties_kobj =
1113 kobject_create_and_add("board_properties", NULL);
1114 if (virtual_key_properties_kobj)
1115 retval = sysfs_create_group(virtual_key_properties_kobj,
1116 &virtual_key_properties_attr_group);
1117 if (!virtual_key_properties_kobj || retval)
1118 pr_err("failed to create ft5202 board_properties\n");
1119
1120 retval = msm_gpios_request_enable(clearpad3000_cfg_data,
1121 sizeof(clearpad3000_cfg_data)/sizeof(struct msm_gpio));
1122 if (retval) {
1123 pr_err("%s:Failed to obtain touchpad GPIO %d. Code: %d.",
1124 __func__, CLEARPAD3000_ATTEN_GPIO, retval);
1125 retval = 0; /* ignore the err */
1126 }
1127 synaptics_platformdata.irq = gpio_to_irq(CLEARPAD3000_ATTEN_GPIO);
1128
1129 gpio_set_value(CLEARPAD3000_RESET_GPIO, 0);
1130 usleep(10000);
1131 gpio_set_value(CLEARPAD3000_RESET_GPIO, 1);
1132 usleep(50000);
1133
1134 return retval;
1135}
1136#endif
1137
1138
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301139static struct android_usb_platform_data android_usb_pdata = {
Pankaj Kumar6f841742011-10-10 15:52:14 +05301140 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301141};
1142
1143static struct platform_device android_usb_device = {
1144 .name = "android_usb",
1145 .id = -1,
1146 .dev = {
1147 .platform_data = &android_usb_pdata,
1148 },
1149};
1150
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301151#ifdef CONFIG_USB_EHCI_MSM_72K
1152static void msm_hsusb_vbus_power(unsigned phy_info, int on)
1153{
1154 int rc = 0;
1155 unsigned gpio;
1156
1157 gpio = GPIO_HOST_VBUS_EN;
1158
1159 rc = gpio_request(gpio, "i2c_host_vbus_en");
1160 if (rc < 0) {
1161 pr_err("failed to request %d GPIO\n", gpio);
1162 return;
1163 }
1164 gpio_direction_output(gpio, !!on);
1165 gpio_set_value_cansleep(gpio, !!on);
1166 gpio_free(gpio);
1167}
1168
1169static struct msm_usb_host_platform_data msm_usb_host_pdata = {
1170 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
1171};
1172
1173static void __init msm7627a_init_host(void)
1174{
1175 msm_add_host(0, &msm_usb_host_pdata);
1176}
1177#endif
1178
1179#ifdef CONFIG_USB_MSM_OTG_72K
1180static int hsusb_rpc_connect(int connect)
1181{
1182 if (connect)
1183 return msm_hsusb_rpc_connect();
1184 else
1185 return msm_hsusb_rpc_close();
1186}
1187
Pankaj Kumar27c02642011-09-22 15:55:55 +05301188static struct regulator *reg_hsusb;
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301189static int msm_hsusb_ldo_init(int init)
1190{
Pankaj Kumar27c02642011-09-22 15:55:55 +05301191 int rc = 0;
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301192
Pankaj Kumar27c02642011-09-22 15:55:55 +05301193 if (init) {
1194 reg_hsusb = regulator_get(NULL, "usb");
1195 if (IS_ERR(reg_hsusb)) {
1196 rc = PTR_ERR(reg_hsusb);
1197 pr_err("%s: could not get regulator: %d\n",
1198 __func__, rc);
1199 goto out;
1200 }
1201
1202 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
1203 if (rc) {
1204 pr_err("%s: could not set voltage: %d\n",
1205 __func__, rc);
1206 goto reg_free;
1207 }
1208
1209 return 0;
1210 }
1211 /* else fall through */
1212reg_free:
1213 regulator_put(reg_hsusb);
1214out:
1215 reg_hsusb = NULL;
1216 return rc;
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301217}
1218
1219static int msm_hsusb_ldo_enable(int enable)
1220{
1221 static int ldo_status;
1222
Pankaj Kumar27c02642011-09-22 15:55:55 +05301223 if (IS_ERR_OR_NULL(reg_hsusb))
1224 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301225
1226 if (ldo_status == enable)
1227 return 0;
1228
1229 ldo_status = enable;
1230
Pankaj Kumar27c02642011-09-22 15:55:55 +05301231 return enable ?
1232 regulator_enable(reg_hsusb) :
1233 regulator_disable(reg_hsusb);
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301234}
1235
1236#ifndef CONFIG_USB_EHCI_MSM_72K
1237static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
1238{
1239 int ret = 0;
1240
1241 if (init)
1242 ret = msm_pm_app_rpc_init(callback);
1243 else
1244 msm_pm_app_rpc_deinit(callback);
1245
1246 return ret;
1247}
1248#endif
1249
1250static struct msm_otg_platform_data msm_otg_pdata = {
1251#ifndef CONFIG_USB_EHCI_MSM_72K
1252 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
1253#else
1254 .vbus_power = msm_hsusb_vbus_power,
1255#endif
1256 .rpc_connect = hsusb_rpc_connect,
1257 .core_clk = 1,
1258 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
1259 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
1260 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
1261 .se1_gating = SE1_GATING_DISABLE,
1262 .ldo_init = msm_hsusb_ldo_init,
1263 .ldo_enable = msm_hsusb_ldo_enable,
1264 .chg_init = hsusb_chg_init,
1265 .chg_connected = hsusb_chg_connected,
1266 .chg_vbus_draw = hsusb_chg_vbus_draw,
1267};
1268#endif
1269
1270static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
1271 .is_phy_status_timer_on = 1,
1272};
1273
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301274#ifdef CONFIG_SERIAL_MSM_HS
1275static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
1276 .inject_rx_on_wakeup = 1,
1277 .rx_to_inject = 0xFD,
1278};
1279#endif
1280static struct msm_pm_platform_data msm7627a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
1281 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
1282 .idle_supported = 1,
1283 .suspend_supported = 1,
1284 .idle_enabled = 1,
1285 .suspend_enabled = 1,
1286 .latency = 16000,
1287 .residency = 20000,
1288 },
1289 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
1290 .idle_supported = 1,
1291 .suspend_supported = 1,
1292 .idle_enabled = 1,
1293 .suspend_enabled = 1,
1294 .latency = 12000,
1295 .residency = 20000,
1296 },
1297 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
1298 .idle_supported = 1,
1299 .suspend_supported = 1,
1300 .idle_enabled = 0,
1301 .suspend_enabled = 1,
1302 .latency = 2000,
1303 .residency = 0,
1304 },
1305 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
1306 .idle_supported = 1,
1307 .suspend_supported = 1,
1308 .idle_enabled = 1,
1309 .suspend_enabled = 1,
1310 .latency = 2,
1311 .residency = 0,
1312 },
1313};
1314
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06001315static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
1316 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
1317 .v_addr = (uint32_t *)PAGE_OFFSET,
1318};
1319
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301320static struct android_pmem_platform_data android_pmem_adsp_pdata = {
1321 .name = "pmem_adsp",
1322 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
1323 .cached = 1,
1324 .memory_type = MEMTYPE_EBI1,
1325};
1326
1327static struct platform_device android_pmem_adsp_device = {
1328 .name = "android_pmem",
1329 .id = 1,
1330 .dev = { .platform_data = &android_pmem_adsp_pdata },
1331};
1332
1333static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
1334static int __init pmem_mdp_size_setup(char *p)
1335{
1336 pmem_mdp_size = memparse(p, NULL);
1337 return 0;
1338}
1339
1340early_param("pmem_mdp_size", pmem_mdp_size_setup);
1341
1342static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
1343static int __init pmem_adsp_size_setup(char *p)
1344{
1345 pmem_adsp_size = memparse(p, NULL);
1346 return 0;
1347}
1348
1349early_param("pmem_adsp_size", pmem_adsp_size_setup);
1350
1351static unsigned fb_size = MSM_FB_SIZE;
1352static int __init fb_size_setup(char *p)
1353{
1354 fb_size = memparse(p, NULL);
1355 return 0;
1356}
1357
1358early_param("fb_size", fb_size_setup);
1359
Taniya Das0a5303a2011-08-23 18:47:48 +05301360static struct resource msm_fb_resources[] = {
1361 {
1362 .flags = IORESOURCE_DMA,
1363 }
1364};
1365
1366static int msm_fb_detect_panel(const char *name)
1367{
1368 int ret;
1369
1370 if (!strncmp(name, "mipi_video_truly_wvga", 21))
1371 ret = 0;
1372 else
1373 ret = -ENODEV;
1374
1375 return ret;
1376}
1377
1378static int mipi_truly_set_bl(int on)
1379{
1380 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, !!on);
1381
1382 return 1;
1383}
1384
1385static struct msm_fb_platform_data msm_fb_pdata = {
1386 .detect_client = msm_fb_detect_panel,
1387};
1388
1389static struct platform_device msm_fb_device = {
1390 .name = "msm_fb",
1391 .id = 0,
1392 .num_resources = ARRAY_SIZE(msm_fb_resources),
1393 .resource = msm_fb_resources,
1394 .dev = {
1395 .platform_data = &msm_fb_pdata,
1396 }
1397};
1398
1399static struct msm_panel_common_pdata mipi_truly_pdata = {
1400 .pmic_backlight = mipi_truly_set_bl,
1401};
1402
1403static struct platform_device mipi_dsi_truly_panel_device = {
1404 .name = "mipi_truly",
1405 .id = 0,
1406 .dev = {
1407 .platform_data = &mipi_truly_pdata,
1408 }
1409};
1410
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301411#define SND(desc, num) { .name = #desc, .id = num }
1412static struct snd_endpoint snd_endpoints_list[] = {
1413 SND(HANDSET, 0),
1414 SND(MONO_HEADSET, 2),
1415 SND(HEADSET, 3),
1416 SND(SPEAKER, 6),
1417 SND(TTY_HEADSET, 8),
1418 SND(TTY_VCO, 9),
1419 SND(TTY_HCO, 10),
1420 SND(BT, 12),
1421 SND(IN_S_SADC_OUT_HANDSET, 16),
1422 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
1423 SND(FM_DIGITAL_STEREO_HEADSET, 26),
1424 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
1425 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
Shashi Kumar64e07602011-10-11 13:18:57 +05301426 SND(STEREO_HEADSET_AND_SPEAKER, 31),
Phani Kumar Alladad6971252011-10-19 10:50:15 +05301427 SND(CURRENT, 0x7FFFFFFE),
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301428 SND(FM_ANALOG_STEREO_HEADSET, 35),
1429 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
1430};
1431#undef SND
1432
1433static struct msm_snd_endpoints msm_device_snd_endpoints = {
1434 .endpoints = snd_endpoints_list,
1435 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
1436};
1437
1438static struct platform_device msm_device_snd = {
1439 .name = "msm_snd",
1440 .id = -1,
1441 .dev = {
1442 .platform_data = &msm_device_snd_endpoints
1443 },
1444};
1445
1446#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
1447 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
1448 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
1449 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
1450 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
1451 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
1452#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
1453 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
1454 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
1455 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
1456 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
1457 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
1458#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
1459 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
1460 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
1461 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
1462 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
1463 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
1464#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
1465 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
1466 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
1467 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
1468 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
1469 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
1470#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
1471
1472static unsigned int dec_concurrency_table[] = {
1473 /* Audio LP */
1474 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
1475 0, 0, 0,
1476
1477 /* Concurrency 1 */
1478 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1479 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1480 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1481 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1482 (DEC4_FORMAT),
1483
1484 /* Concurrency 2 */
1485 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1486 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1487 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1488 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1489 (DEC4_FORMAT),
1490
1491 /* Concurrency 3 */
1492 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1493 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1494 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1495 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1496 (DEC4_FORMAT),
1497
1498 /* Concurrency 4 */
1499 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1500 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1501 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1502 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1503 (DEC4_FORMAT),
1504
1505 /* Concurrency 5 */
1506 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
1507 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1508 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1509 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1510 (DEC4_FORMAT),
1511
1512 /* Concurrency 6 */
1513 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1514 0, 0, 0, 0,
1515
1516 /* Concurrency 7 */
1517 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1518 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1519 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1520 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
1521 (DEC4_FORMAT),
1522};
1523
1524#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
1525 .module_queueid = queueid, .module_decid = decid, \
1526 .nr_codec_support = nr_codec}
1527
1528static struct msm_adspdec_info dec_info_list[] = {
1529 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
1530 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
1531 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
1532 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
1533 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
1534};
1535
1536static struct msm_adspdec_database msm_device_adspdec_database = {
1537 .num_dec = ARRAY_SIZE(dec_info_list),
1538 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
1539 ARRAY_SIZE(dec_info_list)),
1540 .dec_concurrency_table = dec_concurrency_table,
1541 .dec_info_list = dec_info_list,
1542};
1543
1544static struct platform_device msm_device_adspdec = {
1545 .name = "msm_adspdec",
1546 .id = -1,
1547 .dev = {
1548 .platform_data = &msm_device_adspdec_database
1549 },
1550};
1551
1552static struct android_pmem_platform_data android_pmem_audio_pdata = {
1553 .name = "pmem_audio",
1554 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
1555 .cached = 0,
1556 .memory_type = MEMTYPE_EBI1,
1557};
1558
1559static struct platform_device android_pmem_audio_device = {
1560 .name = "android_pmem",
1561 .id = 2,
1562 .dev = { .platform_data = &android_pmem_audio_pdata },
1563};
1564
1565static struct android_pmem_platform_data android_pmem_pdata = {
1566 .name = "pmem",
1567 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
1568 .cached = 1,
1569 .memory_type = MEMTYPE_EBI1,
1570};
1571static struct platform_device android_pmem_device = {
1572 .name = "android_pmem",
1573 .id = 0,
1574 .dev = { .platform_data = &android_pmem_pdata },
1575};
1576
1577static u32 msm_calculate_batt_capacity(u32 current_voltage);
1578
1579static struct msm_psy_batt_pdata msm_psy_batt_data = {
1580 .voltage_min_design = 2800,
1581 .voltage_max_design = 4300,
1582 .avail_chg_sources = AC_CHG | USB_CHG ,
1583 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
1584 .calculate_capacity = &msm_calculate_batt_capacity,
1585};
1586
1587static u32 msm_calculate_batt_capacity(u32 current_voltage)
1588{
1589 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
1590 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
1591
1592 return (current_voltage - low_voltage) * 100
1593 / (high_voltage - low_voltage);
1594}
1595
1596static struct platform_device msm_batt_device = {
1597 .name = "msm-battery",
1598 .id = -1,
1599 .dev.platform_data = &msm_psy_batt_data,
1600};
1601
Taniya Das7a22cdd2011-09-08 14:57:00 +05301602#ifdef CONFIG_MSM_CAMERA
1603static uint32_t camera_off_gpio_table[] = {
1604 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1605};
1606
1607static uint32_t camera_on_gpio_table[] = {
1608 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1609};
1610
1611static void qrd1_camera_gpio_cfg(void)
1612{
1613
1614 int rc = 0;
1615
1616 rc = gpio_request(GPIO_CAM_5MP_SHDN_EN, "ov5640");
1617 if (rc < 0)
1618 pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!",
1619 __func__);
1620
1621
1622 rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_5MP_SHDN_EN, 0,
1623 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
1624 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1625 if (rc < 0) {
1626 pr_err("%s: unable to enable Power Down gpio for main"
1627 "camera!\n", __func__);
1628 gpio_free(GPIO_CAM_5MP_SHDN_EN);
1629 }
1630
1631
1632 rc = gpio_request(GPIO_CAM_5MP_RESET, "ov5640");
1633 if (rc < 0) {
1634 pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!",
1635 __func__);
1636 gpio_free(GPIO_CAM_5MP_SHDN_EN);
1637 }
1638
1639
1640 rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_5MP_RESET, 0,
1641 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
1642 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1643 if (rc < 0) {
1644 pr_err("%s: unable to enable reset gpio for main camera!\n",
1645 __func__);
1646 gpio_free(GPIO_CAM_5MP_RESET);
1647 }
1648
1649 rc = gpio_request(GPIO_CAM_3MP_PWDN, "ov7692");
1650 if (rc < 0)
1651 pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!",
1652 __func__);
1653
1654 rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_3MP_PWDN, 0,
1655 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
1656 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
1657 if (rc < 0) {
1658 pr_err("%s: unable to enable Power Down gpio for front"
1659 "camera!\n", __func__);
1660 gpio_free(GPIO_CAM_3MP_PWDN);
1661 }
1662
1663 gpio_direction_output(GPIO_CAM_5MP_SHDN_EN, 1);
1664 gpio_direction_output(GPIO_CAM_5MP_RESET, 1);
1665 gpio_direction_output(GPIO_CAM_3MP_PWDN, 1);
1666}
1667
1668#endif
Pankaj Kumar27c02642011-09-22 15:55:55 +05301669static struct regulator_bulk_data regs_camera[] = {
1670 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
1671 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
1672 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
1673};
1674
1675static void __init msm_camera_vreg_init(void)
Taniya Das7a22cdd2011-09-08 14:57:00 +05301676{
1677 int rc;
1678
Pankaj Kumar27c02642011-09-22 15:55:55 +05301679 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera);
1680 if (rc) {
1681 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1682 return;
Taniya Das7a22cdd2011-09-08 14:57:00 +05301683 }
1684
Pankaj Kumar27c02642011-09-22 15:55:55 +05301685 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera);
1686 if (rc) {
1687 pr_err("%s: could not set voltages: %d\n", __func__, rc);
1688 return;
Taniya Das7a22cdd2011-09-08 14:57:00 +05301689 }
1690}
1691
Pankaj Kumar27c02642011-09-22 15:55:55 +05301692static void msm_camera_vreg_config(int vreg_en)
1693{
1694 int rc = vreg_en ?
1695 regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) :
1696 regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera);
1697
1698 if (rc)
1699 pr_err("%s: could not %sable regulators: %d\n",
1700 __func__, vreg_en ? "en" : "dis", rc);
1701}
Taniya Das7a22cdd2011-09-08 14:57:00 +05301702static int config_gpio_table(uint32_t *table, int len)
1703{
1704 int rc = 0, i = 0;
1705
1706 for (i = 0; i < len; i++) {
1707 rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE);
1708 if (rc) {
1709 pr_err("%s not able to get gpio\n", __func__);
1710 for (i--; i >= 0; i--)
1711 gpio_tlmm_config(camera_off_gpio_table[i],
1712 GPIO_CFG_ENABLE);
1713 break;
1714 }
1715 }
1716 return rc;
1717}
1718
1719static int config_camera_on_gpios_rear(void)
1720{
1721 int rc = 0;
1722
1723 msm_camera_vreg_config(1);
1724
1725 rc = config_gpio_table(camera_on_gpio_table,
1726 ARRAY_SIZE(camera_on_gpio_table));
1727 if (rc < 0) {
1728 pr_err("%s: CAMSENSOR gpio table request"
1729 "failed\n", __func__);
1730 return rc;
1731 }
1732
1733 return rc;
1734}
1735
1736static void config_camera_off_gpios_rear(void)
1737{
1738 msm_camera_vreg_config(0);
1739 config_gpio_table(camera_off_gpio_table,
1740 ARRAY_SIZE(camera_off_gpio_table));
1741}
1742
1743static int config_camera_on_gpios_front(void)
1744{
1745 int rc = 0;
1746
1747 msm_camera_vreg_config(1);
1748
1749 rc = config_gpio_table(camera_on_gpio_table,
1750 ARRAY_SIZE(camera_on_gpio_table));
1751 if (rc < 0) {
1752 pr_err("%s: CAMSENSOR gpio table request"
1753 "failed\n", __func__);
1754 return rc;
1755 }
1756
1757 return rc;
1758}
1759
1760static void config_camera_off_gpios_front(void)
1761{
1762 msm_camera_vreg_config(0);
1763
1764 config_gpio_table(camera_off_gpio_table,
1765 ARRAY_SIZE(camera_off_gpio_table));
1766}
1767
1768struct msm_camera_device_platform_data msm_camera_data_rear = {
1769 .camera_gpio_on = config_camera_on_gpios_rear,
1770 .camera_gpio_off = config_camera_off_gpios_rear,
1771 .ioext.csiphy = 0xA1000000,
1772 .ioext.csisz = 0x00100000,
1773 .ioext.csiirq = INT_CSI_IRQ_1,
1774 .ioclk.mclk_clk_rate = 24000000,
1775 .ioclk.vfe_clk_rate = 192000000,
1776 .ioext.appphy = MSM_CLK_CTL_PHYS,
1777 .ioext.appsz = MSM_CLK_CTL_SIZE,
1778};
1779
1780struct msm_camera_device_platform_data msm_camera_data_front = {
1781 .camera_gpio_on = config_camera_on_gpios_front,
1782 .camera_gpio_off = config_camera_off_gpios_front,
1783 .ioext.csiphy = 0xA0F00000,
1784 .ioext.csisz = 0x00100000,
1785 .ioext.csiirq = INT_CSI_IRQ_0,
1786 .ioclk.mclk_clk_rate = 24000000,
1787 .ioclk.vfe_clk_rate = 192000000,
1788 .ioext.appphy = MSM_CLK_CTL_PHYS,
1789 .ioext.appsz = MSM_CLK_CTL_SIZE,
1790};
1791
1792#ifdef CONFIG_OV5640
1793static struct msm_camera_sensor_platform_info ov5640_sensor_info = {
1794 .mount_angle = 90
1795};
1796
1797static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = {
1798 .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED,
1799 ._fsrc.led_src.led_name = "flashlight",
1800 ._fsrc.led_src.led_name_len = 10,
1801};
1802
1803static struct msm_camera_sensor_flash_data flash_ov5640 = {
1804 .flash_type = MSM_CAMERA_FLASH_LED,
1805 .flash_src = &msm_flash_src_ov5640,
1806};
1807
1808static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
1809 .sensor_name = "ov5640",
1810 .sensor_reset_enable = 1,
1811 .sensor_reset = GPIO_CAM_5MP_RESET,
1812 .sensor_pwd = GPIO_CAM_5MP_SHDN_EN,
1813 .vcm_pwd = 0,
1814 .vcm_enable = 0,
1815 .pdata = &msm_camera_data_rear,
1816 .flash_data = &flash_ov5640,
1817 .sensor_platform_info = &ov5640_sensor_info,
1818 .csi_if = 1,
1819};
1820
1821static struct platform_device msm_camera_sensor_ov5640 = {
1822 .name = "msm_camera_ov5640",
1823 .dev = {
1824 .platform_data = &msm_camera_sensor_ov5640_data,
1825 },
1826};
1827#endif
1828
1829#ifdef CONFIG_WEBCAM_OV7692_QRD
1830static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = {
1831 .mount_angle = 90
1832};
1833
1834static struct msm_camera_sensor_flash_data flash_ov7692 = {
1835 .flash_type = MSM_CAMERA_FLASH_NONE,
1836};
1837
1838static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = {
1839 .sensor_name = "ov7692",
1840 .sensor_reset_enable = 0,
1841 .sensor_reset = 0,
1842 .sensor_pwd = GPIO_CAM_3MP_PWDN,
1843 .vcm_pwd = 0,
1844 .vcm_enable = 0,
1845 .pdata = &msm_camera_data_front,
1846 .flash_data = &flash_ov7692,
1847 .sensor_platform_info = &ov7692_sensor_7627a_info,
1848 .csi_if = 1,
1849};
1850
1851static struct platform_device msm_camera_sensor_ov7692 = {
1852 .name = "msm_camera_ov7692",
1853 .dev = {
1854 .platform_data = &msm_camera_sensor_ov7692_data,
1855 },
1856};
1857#endif
1858
1859static struct i2c_board_info i2c_camera_devices[] = {
1860 #ifdef CONFIG_OV5640
1861 {
1862 I2C_BOARD_INFO("ov5640", 0x78 >> 1),
1863 },
1864 #endif
1865 #ifdef CONFIG_WEBCAM_OV7692_QRD
1866 {
1867 I2C_BOARD_INFO("ov7692", 0x78),
1868 },
1869 #endif
1870};
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301871static struct platform_device *qrd1_devices[] __initdata = {
1872 &msm_device_dmov,
1873 &msm_device_smd,
1874 &msm_device_uart1,
1875 &msm_device_uart_dm1,
1876 &msm_gsbi0_qup_i2c_device,
1877 &msm_gsbi1_qup_i2c_device,
1878 &msm_device_otg,
1879 &msm_device_gadget_peripheral,
1880 &android_usb_device,
1881 &android_pmem_device,
1882 &android_pmem_adsp_device,
Taniya Das0a5303a2011-08-23 18:47:48 +05301883 &msm_fb_device,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301884 &android_pmem_audio_device,
1885 &msm_device_snd,
1886 &msm_device_adspdec,
1887 &msm_batt_device,
Taniya Das7a22cdd2011-09-08 14:57:00 +05301888#ifdef CONFIG_OV5640
1889 &msm_camera_sensor_ov5640,
1890#endif
1891#ifdef CONFIG_WEBCAM_OV7692_QRD
1892 &msm_camera_sensor_ov7692,
1893#endif
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301894 &msm_kgsl_3d0,
1895#ifdef CONFIG_BT
1896 &msm_bt_power_device,
1897#endif
Taniya Das0a5303a2011-08-23 18:47:48 +05301898 &mipi_dsi_truly_panel_device,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301899 &msm_wlan_ar6000_pm_device,
1900 &asoc_msm_pcm,
1901 &asoc_msm_dai0,
1902 &asoc_msm_dai1,
1903};
1904
1905static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
1906static int __init pmem_kernel_ebi1_size_setup(char *p)
1907{
1908 pmem_kernel_ebi1_size = memparse(p, NULL);
1909 return 0;
1910}
1911early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
1912
1913static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
1914static int __init pmem_audio_size_setup(char *p)
1915{
1916 pmem_audio_size = memparse(p, NULL);
1917 return 0;
1918}
1919early_param("pmem_audio_size", pmem_audio_size_setup);
1920
1921static void __init msm_msm7627a_allocate_memory_regions(void)
1922{
Taniya Das0a5303a2011-08-23 18:47:48 +05301923 void *addr;
1924 unsigned long size;
1925
1926 size = fb_size ? : MSM_FB_SIZE;
1927 addr = alloc_bootmem_align(size, 0x1000);
1928 msm_fb_resources[0].start = __pa(addr);
1929 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
1930 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", size,
1931 addr, __pa(addr));
Taniya Dasc98bfbc2011-08-23 09:58:55 +05301932}
1933
1934static struct memtype_reserve msm7627a_reserve_table[] __initdata = {
1935 [MEMTYPE_SMI] = {
1936 },
1937 [MEMTYPE_EBI0] = {
1938 .flags = MEMTYPE_FLAGS_1M_ALIGN,
1939 },
1940 [MEMTYPE_EBI1] = {
1941 .flags = MEMTYPE_FLAGS_1M_ALIGN,
1942 },
1943};
1944
Taniya Das0a5303a2011-08-23 18:47:48 +05301945static struct msm_panel_common_pdata mdp_pdata = {
1946 .gpio = 97,
1947 .mdp_rev = MDP_REV_303,
1948};
1949
1950#define GPIO_LCDC_BRDG_PD 128
1951#define GPIO_LCDC_BRDG_RESET_N 129
1952#define GPIO_LCD_DSI_SEL 125
1953
1954static unsigned mipi_dsi_gpio[] = {
1955 GPIO_CFG(GPIO_LCDC_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT,
1956 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */
1957 GPIO_CFG(GPIO_LCDC_BRDG_PD, 0, GPIO_CFG_OUTPUT,
1958 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_PD */
1959};
1960
1961static unsigned lcd_dsi_sel_gpio[] = {
1962 GPIO_CFG(GPIO_LCD_DSI_SEL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
1963 GPIO_CFG_2MA),
1964};
1965
1966enum {
1967 DSI_SINGLE_LANE = 1,
1968 DSI_TWO_LANES,
1969};
1970
1971static int msm_fb_get_lane_config(void)
1972{
1973 pr_info("DSI_TWO_LANES\n");
1974 return DSI_TWO_LANES;
1975}
1976
1977static int mipi_truly_sel_mode(int video_mode)
1978{
1979 int rc = 0;
1980
1981 rc = gpio_request(GPIO_LCD_DSI_SEL, "lcd_dsi_sel");
1982 if (rc < 0)
1983 goto gpio_error;
1984
1985 rc = gpio_tlmm_config(lcd_dsi_sel_gpio[0], GPIO_CFG_ENABLE);
1986 if (rc)
1987 goto gpio_error;
1988
1989 rc = gpio_direction_output(GPIO_LCD_DSI_SEL, 1);
1990 if (!rc) {
1991 gpio_set_value_cansleep(GPIO_LCD_DSI_SEL, video_mode);
1992 return rc;
1993 } else {
1994 goto gpio_error;
1995 }
1996
1997gpio_error:
1998 pr_err("mipi_truly_sel_mode failed\n");
1999 gpio_free(GPIO_LCD_DSI_SEL);
2000 return rc;
2001}
2002
2003static int msm_fb_dsi_client_qrd1_reset(void)
2004{
2005 int rc = 0;
2006
2007 rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n");
2008 if (rc < 0) {
2009 pr_err("failed to request lcd brdg reset_n\n");
2010 return rc;
2011 }
2012
2013 rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE);
2014 if (rc < 0) {
2015 pr_err("Failed to enable LCDC Bridge reset enable\n");
2016 return rc;
2017 }
2018
2019 rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1);
2020 if (rc < 0) {
2021 pr_err("Failed GPIO bridge pd\n");
2022 gpio_free(GPIO_LCDC_BRDG_RESET_N);
2023 return rc;
2024 }
2025
2026 mipi_truly_sel_mode(1);
2027
2028 return rc;
2029}
2030
2031static int msm_fb_dsi_client_reset(void)
2032{
2033 int rc = 0;
2034
2035 rc = msm_fb_dsi_client_qrd1_reset();
2036 return rc;
2037}
2038
2039static int dsi_gpio_initialized;
2040
2041static int mipi_dsi_panel_qrd1_power(int on)
2042{
2043 int rc = 0;
2044
2045 if (!dsi_gpio_initialized) {
2046 rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en");
2047 if (rc < 0)
2048 return rc;
2049
Jeevan Shriram72e4cc62011-11-10 14:57:22 +05302050 rc = gpio_tlmm_config(GPIO_CFG(GPIO_BACKLIGHT_EN, 0,
2051 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2052 GPIO_CFG_ENABLE);
2053 if (rc < 0) {
2054 pr_err("failed GPIO_BACKLIGHT_EN tlmm config\n");
2055 return rc;
2056 }
2057
Taniya Das0a5303a2011-08-23 18:47:48 +05302058 rc = gpio_direction_output(GPIO_BACKLIGHT_EN, 1);
2059 if (rc < 0) {
2060 pr_err("failed to enable backlight\n");
2061 gpio_free(GPIO_BACKLIGHT_EN);
2062 return rc;
2063 }
2064 dsi_gpio_initialized = 1;
2065 }
2066
2067 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, !!on);
2068
2069 if (!on) {
2070 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
2071 msleep(20);
2072 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0);
2073 msleep(20);
2074 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
2075
2076 }
2077
2078 return rc;
2079}
2080
2081static int mipi_dsi_panel_power(int on)
2082{
2083 int rc = 0;
2084
2085 rc = mipi_dsi_panel_qrd1_power(on);
2086 return rc;
2087}
2088
2089#define MDP_303_VSYNC_GPIO 97
2090
2091#ifdef CONFIG_FB_MSM_MDP303
2092static struct mipi_dsi_platform_data mipi_dsi_pdata = {
2093 .vsync_gpio = MDP_303_VSYNC_GPIO,
2094 .dsi_power_save = mipi_dsi_panel_power,
2095 .dsi_client_reset = msm_fb_dsi_client_reset,
2096 .get_lane_config = msm_fb_get_lane_config,
2097};
2098#endif
2099
2100static void __init msm_fb_add_devices(void)
2101{
2102 msm_fb_register_device("mdp", &mdp_pdata);
2103 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
2104}
2105
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302106static void __init size_pmem_devices(void)
2107{
2108#ifdef CONFIG_ANDROID_PMEM
2109 android_pmem_adsp_pdata.size = pmem_adsp_size;
2110 android_pmem_pdata.size = pmem_mdp_size;
2111 android_pmem_audio_pdata.size = pmem_audio_size;
2112#endif
2113}
2114
2115static void __init reserve_memory_for(struct android_pmem_platform_data *p)
2116{
2117 msm7627a_reserve_table[p->memory_type].size += p->size;
2118}
2119
2120static void __init reserve_pmem_memory(void)
2121{
2122#ifdef CONFIG_ANDROID_PMEM
2123 reserve_memory_for(&android_pmem_adsp_pdata);
2124 reserve_memory_for(&android_pmem_pdata);
2125 reserve_memory_for(&android_pmem_audio_pdata);
2126 msm7627a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
2127#endif
2128}
2129
2130static void __init msm7627a_calculate_reserve_sizes(void)
2131{
2132 size_pmem_devices();
2133 reserve_pmem_memory();
2134}
2135
2136static int msm7627a_paddr_to_memtype(unsigned int paddr)
2137{
2138 return MEMTYPE_EBI1;
2139}
2140
2141static struct reserve_info msm7627a_reserve_info __initdata = {
2142 .memtype_reserve_table = msm7627a_reserve_table,
2143 .calculate_reserve_sizes = msm7627a_calculate_reserve_sizes,
2144 .paddr_to_memtype = msm7627a_paddr_to_memtype,
2145};
2146
2147static void __init msm7627a_reserve(void)
2148{
2149 reserve_info = &msm7627a_reserve_info;
2150 msm_reserve();
2151}
2152
2153static void __init msm_device_i2c_init(void)
2154{
2155 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
2156 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
2157}
2158
2159static struct msm_handset_platform_data hs_platform_data = {
2160 .hs_name = "7k_handset",
2161 .pwr_key_delay_ms = 500, /* 0 will disable end key */
2162};
2163
2164static struct platform_device hs_pdev = {
2165 .name = "msm-handset",
2166 .id = -1,
2167 .dev = {
2168 .platform_data = &hs_platform_data,
2169 },
2170};
2171
Pankaj Kumar3cec0582011-11-18 11:13:29 +05302172static struct platform_device msm_proccomm_regulator_dev = {
2173 .name = PROCCOMM_REGULATOR_DEV_NAME,
2174 .id = -1,
2175 .dev = {
2176 .platform_data = &msm7x27a_proccomm_regulator_data
2177 }
2178};
2179
2180static void __init msm7627a_init_regulators(void)
2181{
2182 int rc = platform_device_register(&msm_proccomm_regulator_dev);
2183 if (rc)
2184 pr_err("%s: could not register regulator device: %d\n",
2185 __func__, rc);
2186}
2187
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302188#define UART1DM_RX_GPIO 45
2189static void __init msm_qrd1_init(void)
2190{
2191 msm7x2x_misc_init();
Pankaj Kumar3cec0582011-11-18 11:13:29 +05302192 msm7627a_init_regulators();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302193 msm_device_i2c_init();
Taniya Das7a22cdd2011-09-08 14:57:00 +05302194 qrd1_camera_gpio_cfg();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302195#ifdef CONFIG_SERIAL_MSM_HS
2196 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
2197 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
2198#endif
2199
2200#ifdef CONFIG_USB_MSM_OTG_72K
2201 msm_otg_pdata.swfi_latency = msm7627a_pm_data
2202 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
2203 msm_device_otg.dev.platform_data = &msm_otg_pdata;
2204#endif
2205 msm_device_gadget_peripheral.dev.platform_data =
Taniya Das7a22cdd2011-09-08 14:57:00 +05302206 &msm_gadget_pdata;
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302207 platform_add_devices(qrd1_devices,
Taniya Das7a22cdd2011-09-08 14:57:00 +05302208 ARRAY_SIZE(qrd1_devices));
Chintan Pandyacf467fc2011-12-01 17:11:11 +05302209 msm7627a_init_mmc();
2210
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302211#ifdef CONFIG_USB_EHCI_MSM_72K
2212 msm7627a_init_host();
2213#endif
2214 msm_pm_set_platform_data(msm7627a_pm_data,
2215 ARRAY_SIZE(msm7627a_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06002216 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Murali Nalajalaa1827842011-11-13 14:12:39 +05302217
Taniya Das0a5303a2011-08-23 18:47:48 +05302218 msm_fb_add_devices();
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302219
2220#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
2221 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
Taniya Das7a22cdd2011-09-08 14:57:00 +05302222 bahama_devices,
2223 ARRAY_SIZE(bahama_devices));
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302224 bt_power_init();
2225#endif
Taniya Dasda408822011-09-06 12:54:06 +05302226
Pankaj Kumar27c02642011-09-22 15:55:55 +05302227 msm_camera_vreg_init();
Taniya Das7a22cdd2011-09-08 14:57:00 +05302228 i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID, i2c_camera_devices,
2229 ARRAY_SIZE(i2c_camera_devices));
2230
Taniya Dasda408822011-09-06 12:54:06 +05302231#if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) || \
2232 defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C_MODULE)
2233 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
2234 synaptic_i2c_clearpad3k,
2235 ARRAY_SIZE(synaptic_i2c_clearpad3k));
2236#endif
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302237 platform_device_register(&hs_pdev);
2238
2239#ifdef CONFIG_MSM_RPC_VIBRATOR
2240 msm_init_pmic_vibrator();
2241#endif
2242}
2243
2244static void __init qrd7627a_init_early(void)
2245{
2246 msm_msm7627a_allocate_memory_regions();
2247}
2248
2249MACHINE_START(MSM7627A_QRD1, "QRD MSM7627a QRD1")
2250 .boot_params = PHYS_OFFSET + 0x100,
2251 .map_io = msm_common_io_init,
2252 .reserve = msm7627a_reserve,
2253 .init_irq = msm_init_irq,
2254 .init_machine = msm_qrd1_init,
2255 .timer = &msm_timer,
2256 .init_early = qrd7627a_init_early,
Pankaj Kumarbf8a2a32011-10-21 11:47:21 +05302257 .handle_irq = vic_handle_irq,
Taniya Dasc98bfbc2011-08-23 09:58:55 +05302258MACHINE_END