blob: d279146c525e0aa64033b3889e326c00fa31edc3 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
Daniel Walker8d747cd2010-02-25 11:37:43 -08002 *
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 *
Daniel Walker8d747cd2010-02-25 11:37:43 -080012 */
13
14#include <linux/kernel.h>
15#include <linux/irq.h>
16#include <linux/gpio.h>
17#include <linux/platform_device.h>
18#include <linux/delay.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070019#include <linux/bootmem.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080020#include <linux/io.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070021#ifdef CONFIG_SPI_QSD
22#include <linux/spi/spi.h>
23#endif
24#include <linux/mfd/pmic8058.h>
25#include <linux/mfd/marimba.h>
26#include <linux/i2c.h>
27#include <linux/input.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080028#include <linux/smsc911x.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070029#include <linux/ofn_atlab.h>
30#include <linux/power_supply.h>
31#include <linux/input/pmic8058-keypad.h>
32#include <linux/i2c/isa1200.h>
33#include <linux/pwm.h>
34#include <linux/pmic8058-pwm.h>
35#include <linux/i2c/tsc2007.h>
36#include <linux/input/kp_flip_switch.h>
37#include <linux/leds-pmic8058.h>
38#include <linux/input/cy8c_ts.h>
39#include <linux/msm_adc.h>
40#include <linux/dma-mapping.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080041
42#include <asm/mach-types.h>
43#include <asm/mach/arch.h>
44#include <asm/setup.h>
45
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046#include <mach/mpp.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080047#include <mach/board.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070048#include <mach/camera.h>
49#include <mach/memory.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080050#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051#include <mach/msm_hsusb.h>
52#include <mach/rpc_hsusb.h>
53#include <mach/msm_spi.h>
54#include <mach/qdsp5v2/msm_lpa.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080055#include <mach/dma.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056#include <linux/android_pmem.h>
57#include <linux/input/msm_ts.h>
58#include <mach/pmic.h>
59#include <mach/rpc_pmapp.h>
60#include <mach/qdsp5v2/aux_pcm.h>
61#include <mach/qdsp5v2/mi2s.h>
62#include <mach/qdsp5v2/audio_dev_ctl.h>
63#include <mach/msm_battery.h>
64#include <mach/rpc_server_handset.h>
65#include <mach/msm_tsif.h>
66#include <mach/socinfo.h>
67#include <mach/msm_memtypes.h>
68#include <linux/cyttsp.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080069
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070070#include <asm/mach/mmc.h>
71#include <asm/mach/flash.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080072#include <mach/vreg.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070073#include <linux/platform_data/qcom_crypto_device.h>
74
Daniel Walker8d747cd2010-02-25 11:37:43 -080075#include "devices.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076#include "timer.h"
77#ifdef CONFIG_USB_G_ANDROID
78#include <linux/usb/android.h>
79#include <mach/usbdiag.h>
80#endif
81#include "pm.h"
82#include "spm.h"
83#include <mach/dal_axi.h>
84#include <mach/msm_serial_hs.h>
85#include <mach/msm_reqs.h>
86#include <mach/qdsp5v2/mi2s.h>
87#include <mach/qdsp5v2/audio_dev_ctl.h>
88#include <mach/sdio_al.h>
89#include "smd_private.h"
90#include <linux/bma150.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080091
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070092#define MSM_PMEM_SF_SIZE 0x1700000
93#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
94#define MSM_FB_SIZE 0x780000
95#else
96#define MSM_FB_SIZE 0x500000
97#endif
98#define MSM_PMEM_ADSP_SIZE 0x1E00000
99#define MSM_FLUID_PMEM_ADSP_SIZE 0x2800000
100#define PMEM_KERNEL_EBI0_SIZE 0x600000
101#define MSM_PMEM_AUDIO_SIZE 0x200000
Daniel Walker90e37c52010-05-12 14:24:15 -0700102
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700103#define PMIC_GPIO_INT 27
104#define PMIC_VREG_WLAN_LEVEL 2900
105#define PMIC_GPIO_SD_DET 36
106#define PMIC_GPIO_SDC4_EN_N 17 /* PMIC GPIO Number 18 */
107#define PMIC_GPIO_HDMI_5V_EN_V3 32 /* PMIC GPIO for V3 H/W */
108#define PMIC_GPIO_HDMI_5V_EN_V2 39 /* PMIC GPIO for V2 H/W */
109
110#define ADV7520_I2C_ADDR 0x39
111
112#define FPGA_SDCC_STATUS 0x8E0001A8
113
114#define FPGA_OPTNAV_GPIO_ADDR 0x8E000026
115#define OPTNAV_I2C_SLAVE_ADDR (0xB0 >> 1)
116#define OPTNAV_IRQ 20
117#define OPTNAV_CHIP_SELECT 19
118
119/* Macros assume PMIC GPIOs start at 0 */
120#define PM8058_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio + NR_GPIO_IRQS)
121#define PM8058_GPIO_SYS_TO_PM(sys_gpio) (sys_gpio - NR_GPIO_IRQS)
122
123#define PMIC_GPIO_FLASH_BOOST_ENABLE 15 /* PMIC GPIO Number 16 */
124#define PMIC_GPIO_HAP_ENABLE 16 /* PMIC GPIO Number 17 */
125
126#define PMIC_GPIO_WLAN_EXT_POR 22 /* PMIC GPIO NUMBER 23 */
127
128#define BMA150_GPIO_INT 1
129
130#define HAP_LVL_SHFT_MSM_GPIO 24
131
132#define PMIC_GPIO_QUICKVX_CLK 37 /* PMIC GPIO 38 */
133
134#define PM_FLIP_MPP 5 /* PMIC MPP 06 */
135static int pm8058_gpios_init(void)
136{
137 int rc;
138 int pmic_gpio_hdmi_5v_en;
139
140#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
141 struct pm8058_gpio sdcc_det = {
142 .direction = PM_GPIO_DIR_IN,
143 .pull = PM_GPIO_PULL_UP_1P5,
144 .vin_sel = 2,
145 .function = PM_GPIO_FUNC_NORMAL,
146 .inv_int_pol = 0,
147 };
148#endif
149 struct pm8058_gpio sdc4_en = {
150 .direction = PM_GPIO_DIR_OUT,
151 .pull = PM_GPIO_PULL_NO,
152 .vin_sel = PM_GPIO_VIN_L5,
153 .function = PM_GPIO_FUNC_NORMAL,
154 .inv_int_pol = 0,
155 .out_strength = PM_GPIO_STRENGTH_LOW,
156 .output_value = 0,
157 };
158
159 struct pm8058_gpio haptics_enable = {
160 .direction = PM_GPIO_DIR_OUT,
161 .pull = PM_GPIO_PULL_NO,
162 .out_strength = PM_GPIO_STRENGTH_HIGH,
163 .function = PM_GPIO_FUNC_NORMAL,
164 .inv_int_pol = 0,
165 .vin_sel = 2,
166 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
167 .output_value = 0,
168 };
169
170 struct pm8058_gpio hdmi_5V_en = {
171 .direction = PM_GPIO_DIR_OUT,
172 .pull = PM_GPIO_PULL_NO,
173 .vin_sel = PM_GPIO_VIN_VPH,
174 .function = PM_GPIO_FUNC_NORMAL,
175 .out_strength = PM_GPIO_STRENGTH_LOW,
176 .output_value = 0,
177 };
178
179 struct pm8058_gpio flash_boost_enable = {
180 .direction = PM_GPIO_DIR_OUT,
181 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
182 .output_value = 0,
183 .pull = PM_GPIO_PULL_NO,
184 .vin_sel = PM_GPIO_VIN_S3,
185 .out_strength = PM_GPIO_STRENGTH_HIGH,
186 .function = PM_GPIO_FUNC_2,
187 };
188
189 struct pm8058_gpio gpio23 = {
190 .direction = PM_GPIO_DIR_OUT,
191 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
192 .output_value = 0,
193 .pull = PM_GPIO_PULL_NO,
194 .vin_sel = 2,
195 .out_strength = PM_GPIO_STRENGTH_LOW,
196 .function = PM_GPIO_FUNC_NORMAL,
197 };
198
199
200 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
201 machine_is_msm7x30_fluid())
202 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
203 else
204 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
205
206 if (machine_is_msm7x30_fluid()) {
207 rc = pm8058_gpio_config(PMIC_GPIO_HAP_ENABLE, &haptics_enable);
208 if (rc) {
209 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
210 (PMIC_GPIO_HAP_ENABLE + 1));
211 return rc;
212 }
213 rc = pm8058_gpio_config(PMIC_GPIO_FLASH_BOOST_ENABLE,
214 &flash_boost_enable);
215 if (rc) {
216 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
217 (PMIC_GPIO_FLASH_BOOST_ENABLE + 1));
218 return rc;
219 }
220 }
221
222#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
223 if (machine_is_msm7x30_fluid())
224 sdcc_det.inv_int_pol = 1;
225
226 rc = pm8058_gpio_config(PMIC_GPIO_SD_DET - 1, &sdcc_det);
227 if (rc) {
228 pr_err("%s PMIC_GPIO_SD_DET config failed\n", __func__);
229 return rc;
230 }
231#endif
232
233 rc = pm8058_gpio_config(pmic_gpio_hdmi_5v_en, &hdmi_5V_en);
234 if (rc) {
235 pr_err("%s PMIC_GPIO_HDMI_5V_EN config failed\n", __func__);
236 return rc;
237 }
238
239 /* Deassert GPIO#23 (source for Ext_POR on WLAN-Volans) */
240 rc = pm8058_gpio_config(PMIC_GPIO_WLAN_EXT_POR, &gpio23);
241 if (rc) {
242 pr_err("%s PMIC_GPIO_WLAN_EXT_POR config failed\n", __func__);
243 return rc;
244 }
245
246 if (machine_is_msm7x30_fluid()) {
247 rc = pm8058_gpio_config(PMIC_GPIO_SDC4_EN_N, &sdc4_en);
248 if (rc) {
249 pr_err("%s PMIC_GPIO_SDC4_EN_N config failed\n",
250 __func__);
251 return rc;
252 }
253 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_EN_N),
254 "sdc4_en");
255 if (rc) {
256 pr_err("%s PMIC_GPIO_SDC4_EN_N gpio_request failed\n",
257 __func__);
258 return rc;
259 }
260 gpio_set_value_cansleep(
261 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_EN_N), 0);
262 }
263
264 return 0;
265}
266
267/*virtual key support */
268static ssize_t tma300_vkeys_show(struct kobject *kobj,
269 struct kobj_attribute *attr, char *buf)
270{
271 return sprintf(buf,
272 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":50:842:80:100"
273 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":170:842:80:100"
274 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":290:842:80:100"
275 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":410:842:80:100"
276 "\n");
277}
278
279static struct kobj_attribute tma300_vkeys_attr = {
280 .attr = {
281 .mode = S_IRUGO,
282 },
283 .show = &tma300_vkeys_show,
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530284};
285
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700286static struct attribute *tma300_properties_attrs[] = {
287 &tma300_vkeys_attr.attr,
288 NULL
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530289};
290
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700291static struct attribute_group tma300_properties_attr_group = {
292 .attrs = tma300_properties_attrs,
293};
294
295static struct kobject *properties_kobj;
296
297#define CYTTSP_TS_GPIO_IRQ 150
298static int cyttsp_platform_init(struct i2c_client *client)
299{
300 int rc = -EINVAL;
301 struct vreg *vreg_ldo8, *vreg_ldo15;
302
303 vreg_ldo8 = vreg_get(NULL, "gp7");
304
305 if (!vreg_ldo8) {
306 pr_err("%s: VREG L8 get failed\n", __func__);
307 return rc;
308 }
309
310 rc = vreg_set_level(vreg_ldo8, 1800);
311 if (rc) {
312 pr_err("%s: VREG L8 set failed\n", __func__);
313 goto l8_put;
314 }
315
316 rc = vreg_enable(vreg_ldo8);
317 if (rc) {
318 pr_err("%s: VREG L8 enable failed\n", __func__);
319 goto l8_put;
320 }
321
322 vreg_ldo15 = vreg_get(NULL, "gp6");
323
324 if (!vreg_ldo15) {
325 pr_err("%s: VREG L15 get failed\n", __func__);
326 goto l8_disable;
327 }
328
329 rc = vreg_set_level(vreg_ldo15, 3050);
330 if (rc) {
331 pr_err("%s: VREG L15 set failed\n", __func__);
332 goto l8_disable;
333 }
334
335 rc = vreg_enable(vreg_ldo15);
336 if (rc) {
337 pr_err("%s: VREG L15 enable failed\n", __func__);
338 goto l8_disable;
339 }
340
341 /* check this device active by reading first byte/register */
342 rc = i2c_smbus_read_byte_data(client, 0x01);
343 if (rc < 0) {
344 pr_err("%s: i2c sanity check failed\n", __func__);
345 goto l8_disable;
346 }
347
348 rc = gpio_tlmm_config(GPIO_CFG(CYTTSP_TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
349 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
350 if (rc) {
351 pr_err("%s: Could not configure gpio %d\n",
352 __func__, CYTTSP_TS_GPIO_IRQ);
353 goto l8_disable;
354 }
355
356 /* virtual keys */
357 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
358 properties_kobj = kobject_create_and_add("board_properties",
359 NULL);
360 if (properties_kobj)
361 rc = sysfs_create_group(properties_kobj,
362 &tma300_properties_attr_group);
363 if (!properties_kobj || rc)
364 pr_err("%s: failed to create board_properties\n",
365 __func__);
366
367 return CY_OK;
368
369l8_disable:
370 vreg_disable(vreg_ldo8);
371l8_put:
372 vreg_put(vreg_ldo8);
373 return rc;
374}
375
376static int cyttsp_platform_resume(struct i2c_client *client)
377{
378 /* add any special code to strobe a wakeup pin or chip reset */
379 mdelay(10);
380
381 return CY_OK;
382}
383
384static struct cyttsp_platform_data cyttsp_data = {
385 .fw_fname = "cyttsp_7630_fluid.hex",
386 .panel_maxx = 479,
387 .panel_maxy = 799,
388 .disp_maxx = 469,
389 .disp_maxy = 799,
390 .disp_minx = 10,
391 .disp_miny = 0,
392 .flags = 0,
393 .gen = CY_GEN3, /* or */
394 .use_st = CY_USE_ST,
395 .use_mt = CY_USE_MT,
396 .use_hndshk = CY_SEND_HNDSHK,
397 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +0530398 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700399 .use_gestures = CY_USE_GESTURES,
400 /* activate up to 4 groups
401 * and set active distance
402 */
403 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
404 CY_GEST_GRP3 | CY_GEST_GRP4 |
405 CY_ACT_DIST,
406 /* change act_intrvl to customize the Active power state
407 * scanning/processing refresh interval for Operating mode
408 */
409 .act_intrvl = CY_ACT_INTRVL_DFLT,
410 /* change tch_tmout to customize the touch timeout for the
411 * Active power state for Operating mode
412 */
413 .tch_tmout = CY_TCH_TMOUT_DFLT,
414 /* change lp_intrvl to customize the Low Power power state
415 * scanning/processing refresh interval for Operating mode
416 */
417 .lp_intrvl = CY_LP_INTRVL_DFLT,
418 .resume = cyttsp_platform_resume,
419 .init = cyttsp_platform_init,
420 .sleep_gpio = -1,
421 .resout_gpio = -1,
422 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
423};
424
425static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
426{
427 struct pm8058_gpio pwm_gpio_config = {
428 .direction = PM_GPIO_DIR_OUT,
429 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
430 .output_value = 0,
431 .pull = PM_GPIO_PULL_NO,
432 .vin_sel = PM_GPIO_VIN_S3,
433 .out_strength = PM_GPIO_STRENGTH_HIGH,
434 .function = PM_GPIO_FUNC_2,
435 };
436 int rc = -EINVAL;
437 int id, mode, max_mA;
438
439 id = mode = max_mA = 0;
440 switch (ch) {
441 case 0:
442 case 1:
443 case 2:
444 if (on) {
445 id = 24 + ch;
446 rc = pm8058_gpio_config(id - 1, &pwm_gpio_config);
447 if (rc)
448 pr_err("%s: pm8058_gpio_config(%d): rc=%d\n",
449 __func__, id, rc);
450 }
451 break;
452
453 case 3:
454 id = PM_PWM_LED_KPD;
455 mode = PM_PWM_CONF_DTEST3;
456 max_mA = 200;
457 break;
458
459 case 4:
460 id = PM_PWM_LED_0;
461 mode = PM_PWM_CONF_PWM1;
462 max_mA = 40;
463 break;
464
465 case 5:
466 id = PM_PWM_LED_2;
467 mode = PM_PWM_CONF_PWM2;
468 max_mA = 40;
469 break;
470
471 case 6:
472 id = PM_PWM_LED_FLASH;
473 mode = PM_PWM_CONF_DTEST3;
474 max_mA = 200;
475 break;
476
477 default:
478 break;
479 }
480
481 if (ch >= 3 && ch <= 6) {
482 if (!on) {
483 mode = PM_PWM_CONF_NONE;
484 max_mA = 0;
485 }
486 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
487 if (rc)
488 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
489 __func__, ch, rc);
490 }
491
492 return rc;
493}
494
495static int pm8058_pwm_enable(struct pwm_device *pwm, int ch, int on)
496{
497 int rc;
498
499 switch (ch) {
500 case 7:
501 rc = pm8058_pwm_set_dtest(pwm, on);
502 if (rc)
503 pr_err("%s: pwm_set_dtest(%d): rc=%d\n",
504 __func__, on, rc);
505 break;
506 default:
507 rc = -EINVAL;
508 break;
509 }
510 return rc;
511}
512
513static const unsigned int fluid_keymap[] = {
514 KEY(0, 0, KEY_7),
515 KEY(0, 1, KEY_ENTER),
516 KEY(0, 2, KEY_UP),
517 /* drop (0,3) as it always shows up in pair with(0,2) */
518 KEY(0, 4, KEY_DOWN),
519
520 KEY(1, 0, KEY_CAMERA_SNAPSHOT),
521 KEY(1, 1, KEY_SELECT),
522 KEY(1, 2, KEY_1),
523 KEY(1, 3, KEY_VOLUMEUP),
524 KEY(1, 4, KEY_VOLUMEDOWN),
525};
526
527static const unsigned int surf_keymap[] = {
528 KEY(0, 0, KEY_7),
529 KEY(0, 1, KEY_DOWN),
530 KEY(0, 2, KEY_UP),
531 KEY(0, 3, KEY_RIGHT),
532 KEY(0, 4, KEY_ENTER),
533 KEY(0, 5, KEY_L),
534 KEY(0, 6, KEY_BACK),
535 KEY(0, 7, KEY_M),
536
537 KEY(1, 0, KEY_LEFT),
538 KEY(1, 1, KEY_SEND),
539 KEY(1, 2, KEY_1),
540 KEY(1, 3, KEY_4),
541 KEY(1, 4, KEY_CLEAR),
542 KEY(1, 5, KEY_MSDOS),
543 KEY(1, 6, KEY_SPACE),
544 KEY(1, 7, KEY_COMMA),
545
546 KEY(2, 0, KEY_6),
547 KEY(2, 1, KEY_5),
548 KEY(2, 2, KEY_8),
549 KEY(2, 3, KEY_3),
550 KEY(2, 4, KEY_NUMERIC_STAR),
551 KEY(2, 5, KEY_UP),
552 KEY(2, 6, KEY_DOWN), /* SYN */
553 KEY(2, 7, KEY_LEFTSHIFT),
554
555 KEY(3, 0, KEY_9),
556 KEY(3, 1, KEY_NUMERIC_POUND),
557 KEY(3, 2, KEY_0),
558 KEY(3, 3, KEY_2),
559 KEY(3, 4, KEY_SLEEP),
560 KEY(3, 5, KEY_F1),
561 KEY(3, 6, KEY_F2),
562 KEY(3, 7, KEY_F3),
563
564 KEY(4, 0, KEY_BACK),
565 KEY(4, 1, KEY_HOME),
566 KEY(4, 2, KEY_MENU),
567 KEY(4, 3, KEY_VOLUMEUP),
568 KEY(4, 4, KEY_VOLUMEDOWN),
569 KEY(4, 5, KEY_F4),
570 KEY(4, 6, KEY_F5),
571 KEY(4, 7, KEY_F6),
572
573 KEY(5, 0, KEY_R),
574 KEY(5, 1, KEY_T),
575 KEY(5, 2, KEY_Y),
576 KEY(5, 3, KEY_LEFTALT),
577 KEY(5, 4, KEY_KPENTER),
578 KEY(5, 5, KEY_Q),
579 KEY(5, 6, KEY_W),
580 KEY(5, 7, KEY_E),
581
582 KEY(6, 0, KEY_F),
583 KEY(6, 1, KEY_G),
584 KEY(6, 2, KEY_H),
585 KEY(6, 3, KEY_CAPSLOCK),
586 KEY(6, 4, KEY_PAGEUP),
587 KEY(6, 5, KEY_A),
588 KEY(6, 6, KEY_S),
589 KEY(6, 7, KEY_D),
590
591 KEY(7, 0, KEY_V),
592 KEY(7, 1, KEY_B),
593 KEY(7, 2, KEY_N),
594 KEY(7, 3, KEY_MENU), /* REVISIT - SYM */
595 KEY(7, 4, KEY_PAGEDOWN),
596 KEY(7, 5, KEY_Z),
597 KEY(7, 6, KEY_X),
598 KEY(7, 7, KEY_C),
599
600 KEY(8, 0, KEY_P),
601 KEY(8, 1, KEY_J),
602 KEY(8, 2, KEY_K),
603 KEY(8, 3, KEY_INSERT),
604 KEY(8, 4, KEY_LINEFEED),
605 KEY(8, 5, KEY_U),
606 KEY(8, 6, KEY_I),
607 KEY(8, 7, KEY_O),
608
609 KEY(9, 0, KEY_4),
610 KEY(9, 1, KEY_5),
611 KEY(9, 2, KEY_6),
612 KEY(9, 3, KEY_7),
613 KEY(9, 4, KEY_8),
614 KEY(9, 5, KEY_1),
615 KEY(9, 6, KEY_2),
616 KEY(9, 7, KEY_3),
617
618 KEY(10, 0, KEY_F7),
619 KEY(10, 1, KEY_F8),
620 KEY(10, 2, KEY_F9),
621 KEY(10, 3, KEY_F10),
622 KEY(10, 4, KEY_FN),
623 KEY(10, 5, KEY_9),
624 KEY(10, 6, KEY_0),
625 KEY(10, 7, KEY_DOT),
626
627 KEY(11, 0, KEY_LEFTCTRL),
628 KEY(11, 1, KEY_F11), /* START */
629 KEY(11, 2, KEY_ENTER),
630 KEY(11, 3, KEY_SEARCH),
631 KEY(11, 4, KEY_DELETE),
632 KEY(11, 5, KEY_RIGHT),
633 KEY(11, 6, KEY_LEFT),
634 KEY(11, 7, KEY_RIGHTSHIFT),
635};
636
637static struct resource resources_keypad[] = {
638 {
639 .start = PM8058_KEYPAD_IRQ(PMIC8058_IRQ_BASE),
640 .end = PM8058_KEYPAD_IRQ(PMIC8058_IRQ_BASE),
641 .flags = IORESOURCE_IRQ,
Dima Zavinba5499e2011-01-10 11:00:30 -0800642 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700643 {
644 .start = PM8058_KEYSTUCK_IRQ(PMIC8058_IRQ_BASE),
645 .end = PM8058_KEYSTUCK_IRQ(PMIC8058_IRQ_BASE),
646 .flags = IORESOURCE_IRQ,
Dima Zavinba5499e2011-01-10 11:00:30 -0800647 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700648};
649
650static struct matrix_keymap_data surf_keymap_data = {
651 .keymap_size = ARRAY_SIZE(surf_keymap),
652 .keymap = surf_keymap,
653};
654
655
656static struct pmic8058_keypad_data surf_keypad_data = {
657 .input_name = "surf_keypad",
658 .input_phys_device = "surf_keypad/input0",
659 .num_rows = 12,
660 .num_cols = 8,
661 .rows_gpio_start = 8,
662 .cols_gpio_start = 0,
663 .debounce_ms = {8, 10},
664 .scan_delay_ms = 32,
665 .row_hold_ns = 91500,
666 .wakeup = 1,
667 .keymap_data = &surf_keymap_data,
668};
669
670static struct matrix_keymap_data fluid_keymap_data = {
671 .keymap_size = ARRAY_SIZE(fluid_keymap),
672 .keymap = fluid_keymap,
673};
674
675
676
677static struct pmic8058_keypad_data fluid_keypad_data = {
678 .input_name = "fluid-keypad",
679 .input_phys_device = "fluid-keypad/input0",
680 .num_rows = 5,
681 .num_cols = 5,
682 .rows_gpio_start = 8,
683 .cols_gpio_start = 0,
684 .debounce_ms = {8, 10},
685 .scan_delay_ms = 32,
686 .row_hold_ns = 91500,
687 .wakeup = 1,
688 .keymap_data = &fluid_keymap_data,
689};
690
691static struct pm8058_pwm_pdata pm8058_pwm_data = {
692 .config = pm8058_pwm_config,
693 .enable = pm8058_pwm_enable,
694};
695
696/* Put sub devices with fixed location first in sub_devices array */
697#define PM8058_SUBDEV_KPD 0
698#define PM8058_SUBDEV_LED 1
699
700static struct pm8058_gpio_platform_data pm8058_gpio_data = {
701 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
702 .irq_base = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, 0),
703 .init = pm8058_gpios_init,
704};
705
706static struct pm8058_gpio_platform_data pm8058_mpp_data = {
707 .gpio_base = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS),
708 .irq_base = PM8058_MPP_IRQ(PMIC8058_IRQ_BASE, 0),
709};
710
711static struct pmic8058_led pmic8058_ffa_leds[] = {
712 [0] = {
713 .name = "keyboard-backlight",
714 .max_brightness = 15,
715 .id = PMIC8058_ID_LED_KB_LIGHT,
Dima Zavinba5499e2011-01-10 11:00:30 -0800716 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700717};
718
719static struct pmic8058_leds_platform_data pm8058_ffa_leds_data = {
720 .num_leds = ARRAY_SIZE(pmic8058_ffa_leds),
721 .leds = pmic8058_ffa_leds,
722};
723
724static struct pmic8058_led pmic8058_surf_leds[] = {
725 [0] = {
726 .name = "keyboard-backlight",
727 .max_brightness = 15,
728 .id = PMIC8058_ID_LED_KB_LIGHT,
729 },
730 [1] = {
731 .name = "voice:red",
732 .max_brightness = 20,
733 .id = PMIC8058_ID_LED_0,
734 },
735 [2] = {
736 .name = "wlan:green",
737 .max_brightness = 20,
738 .id = PMIC8058_ID_LED_2,
739 },
740};
741
742static struct mfd_cell pm8058_subdevs[] = {
743 { .name = "pm8058-keypad",
744 .id = -1,
745 .num_resources = ARRAY_SIZE(resources_keypad),
746 .resources = resources_keypad,
747 },
748 { .name = "pm8058-led",
749 .id = -1,
750 },
751 { .name = "pm8058-gpio",
752 .id = -1,
753 .platform_data = &pm8058_gpio_data,
754 .pdata_size = sizeof(pm8058_gpio_data),
755 },
756 { .name = "pm8058-mpp",
757 .id = -1,
758 .platform_data = &pm8058_mpp_data,
759 .pdata_size = sizeof(pm8058_mpp_data),
760 },
761 { .name = "pm8058-pwm",
762 .id = -1,
763 .platform_data = &pm8058_pwm_data,
764 .pdata_size = sizeof(pm8058_pwm_data),
765 },
766 { .name = "pm8058-nfc",
767 .id = -1,
768 },
769 { .name = "pm8058-upl",
770 .id = -1,
771 },
772};
773
774static struct pmic8058_leds_platform_data pm8058_surf_leds_data = {
775 .num_leds = ARRAY_SIZE(pmic8058_surf_leds),
776 .leds = pmic8058_surf_leds,
777};
778
779static struct pmic8058_led pmic8058_fluid_leds[] = {
780 [0] = {
781 .name = "keyboard-backlight",
782 .max_brightness = 15,
783 .id = PMIC8058_ID_LED_KB_LIGHT,
784 },
785 [1] = {
786 .name = "flash:led_0",
787 .max_brightness = 15,
788 .id = PMIC8058_ID_FLASH_LED_0,
789 },
790 [2] = {
791 .name = "flash:led_1",
792 .max_brightness = 15,
793 .id = PMIC8058_ID_FLASH_LED_1,
794 },
795};
796
797static struct pmic8058_leds_platform_data pm8058_fluid_leds_data = {
798 .num_leds = ARRAY_SIZE(pmic8058_fluid_leds),
799 .leds = pmic8058_fluid_leds,
800};
801
802static struct pm8058_platform_data pm8058_7x30_data = {
803 .irq_base = PMIC8058_IRQ_BASE,
804
805 .num_subdevs = ARRAY_SIZE(pm8058_subdevs),
806 .sub_devices = pm8058_subdevs,
807 .irq_trigger_flags = IRQF_TRIGGER_LOW,
808};
809
810static struct i2c_board_info pm8058_boardinfo[] __initdata = {
811 {
812 I2C_BOARD_INFO("pm8058-core", 0x55),
813 .irq = MSM_GPIO_TO_INT(PMIC_GPIO_INT),
814 .platform_data = &pm8058_7x30_data,
815 },
816};
817
818static struct i2c_board_info cy8info[] __initdata = {
819 {
820 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
821 .platform_data = &cyttsp_data,
822#ifndef CY_USE_TIMER
823 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
824#endif /* CY_USE_TIMER */
825 },
826};
827
828static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
829#ifdef CONFIG_MT9D112
830 {
831 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
Dima Zavinba5499e2011-01-10 11:00:30 -0800832 },
833#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700834#ifdef CONFIG_WEBCAM_OV9726
835 {
836 I2C_BOARD_INFO("ov9726", 0x10),
837 },
838#endif
839#ifdef CONFIG_S5K3E2FX
840 {
841 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
842 },
843#endif
844#ifdef CONFIG_MT9P012
845 {
846 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
847 },
848#endif
849#ifdef CONFIG_VX6953
850 {
851 I2C_BOARD_INFO("vx6953", 0x20),
852 },
853#endif
854#ifdef CONFIG_MT9E013
855 {
856 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
857 },
858#endif
859#ifdef CONFIG_SN12M0PZ
860 {
861 I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1),
862 },
863#endif
864#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
865 {
866 I2C_BOARD_INFO("mt9t013", 0x6C),
867 },
868#endif
869
Dima Zavinba5499e2011-01-10 11:00:30 -0800870};
871
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700872#ifdef CONFIG_MSM_CAMERA
873#define CAM_STNDBY 143
874static uint32_t camera_off_vcm_gpio_table[] = {
875GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */
876};
877
878static uint32_t camera_off_gpio_table[] = {
879 /* parallel CAMERA interfaces */
880 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RST */
881 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
882 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
883 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
884 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
885 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
886 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
887 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
888 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
889 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
890 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
891 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
892 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
893 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
894 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
895};
896
897static uint32_t camera_on_vcm_gpio_table[] = {
898GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */
899};
900
901static uint32_t camera_on_gpio_table[] = {
902 /* parallel CAMERA interfaces */
903 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RST */
904 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
905 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
906 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
907 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
908 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
909 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
910 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
911 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
912 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
913 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
914 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
915 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
916 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
917 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
918};
919
920static uint32_t camera_off_gpio_fluid_table[] = {
921 /* FLUID: CAM_VGA_RST_N */
922 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
923 /* FLUID: CAMIF_STANDBY */
924 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
925};
926
927static uint32_t camera_on_gpio_fluid_table[] = {
928 /* FLUID: CAM_VGA_RST_N */
929 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
930 /* FLUID: CAMIF_STANDBY */
931 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
932};
933
934static void config_gpio_table(uint32_t *table, int len)
935{
936 int n, rc;
937 for (n = 0; n < len; n++) {
938 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
939 if (rc) {
940 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
941 __func__, table[n], rc);
942 break;
943 }
944 }
945}
946static int config_camera_on_gpios(void)
947{
948 config_gpio_table(camera_on_gpio_table,
949 ARRAY_SIZE(camera_on_gpio_table));
950
951 if (adie_get_detected_codec_type() != TIMPANI_ID)
952 /* GPIO1 is shared also used in Timpani RF card so
953 only configure it for non-Timpani RF card */
954 config_gpio_table(camera_on_vcm_gpio_table,
955 ARRAY_SIZE(camera_on_vcm_gpio_table));
956
957 if (machine_is_msm7x30_fluid()) {
958 config_gpio_table(camera_on_gpio_fluid_table,
959 ARRAY_SIZE(camera_on_gpio_fluid_table));
960 /* FLUID: turn on 5V booster */
961 gpio_set_value(
962 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 1);
963 /* FLUID: drive high to put secondary sensor to STANDBY */
964 gpio_set_value(CAM_STNDBY, 1);
965 }
966 return 0;
967}
968
969static void config_camera_off_gpios(void)
970{
971 config_gpio_table(camera_off_gpio_table,
972 ARRAY_SIZE(camera_off_gpio_table));
973
974 if (adie_get_detected_codec_type() != TIMPANI_ID)
975 /* GPIO1 is shared also used in Timpani RF card so
976 only configure it for non-Timpani RF card */
977 config_gpio_table(camera_off_vcm_gpio_table,
978 ARRAY_SIZE(camera_off_vcm_gpio_table));
979
980 if (machine_is_msm7x30_fluid()) {
981 config_gpio_table(camera_off_gpio_fluid_table,
982 ARRAY_SIZE(camera_off_gpio_fluid_table));
983 /* FLUID: turn off 5V booster */
984 gpio_set_value(
985 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 0);
986 }
987}
988
989struct resource msm_camera_resources[] = {
990 {
991 .start = 0xA6000000,
992 .end = 0xA6000000 + SZ_1M - 1,
993 .flags = IORESOURCE_MEM,
994 },
995 {
996 .start = INT_VFE,
997 .end = INT_VFE,
998 .flags = IORESOURCE_IRQ,
999 },
1000 {
1001 .flags = IORESOURCE_DMA,
1002 }
1003};
1004
1005struct msm_camera_device_platform_data msm_camera_device_data = {
1006 .camera_gpio_on = config_camera_on_gpios,
1007 .camera_gpio_off = config_camera_off_gpios,
1008 .ioext.camifpadphy = 0xAB000000,
1009 .ioext.camifpadsz = 0x00000400,
1010 .ioext.csiphy = 0xA6100000,
1011 .ioext.csisz = 0x00000400,
1012 .ioext.csiirq = INT_CSI,
1013 .ioclk.mclk_clk_rate = 24000000,
1014 .ioclk.vfe_clk_rate = 147456000,
1015};
1016
1017static struct msm_camera_sensor_flash_src msm_flash_src_pwm = {
1018 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PWM,
1019 ._fsrc.pwm_src.freq = 1000,
1020 ._fsrc.pwm_src.max_load = 300,
1021 ._fsrc.pwm_src.low_load = 30,
1022 ._fsrc.pwm_src.high_load = 100,
1023 ._fsrc.pwm_src.channel = 7,
1024};
1025
1026#ifdef CONFIG_MT9D112
1027static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1028 .flash_type = MSM_CAMERA_FLASH_LED,
1029 .flash_src = &msm_flash_src_pwm
1030};
1031
1032static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1033 .sensor_name = "mt9d112",
1034 .sensor_reset = 0,
1035 .sensor_pwd = 85,
1036 .vcm_pwd = 1,
1037 .vcm_enable = 0,
1038 .pdata = &msm_camera_device_data,
1039 .resource = msm_camera_resources,
1040 .num_resources = ARRAY_SIZE(msm_camera_resources),
1041 .flash_data = &flash_mt9d112,
1042 .csi_if = 0
1043};
1044
1045static struct platform_device msm_camera_sensor_mt9d112 = {
1046 .name = "msm_camera_mt9d112",
1047 .dev = {
1048 .platform_data = &msm_camera_sensor_mt9d112_data,
1049 },
1050};
1051#endif
1052
1053#ifdef CONFIG_WEBCAM_OV9726
1054
1055static struct msm_camera_sensor_platform_info ov9726_sensor_7630_info = {
1056 .mount_angle = 90
1057};
1058
1059static struct msm_camera_sensor_flash_data flash_ov9726 = {
1060 .flash_type = MSM_CAMERA_FLASH_LED,
1061 .flash_src = &msm_flash_src_pwm
1062};
1063static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
1064 .sensor_name = "ov9726",
1065 .sensor_reset = 0,
1066 .sensor_pwd = 85,
1067 .vcm_pwd = 1,
1068 .vcm_enable = 0,
1069 .pdata = &msm_camera_device_data,
1070 .resource = msm_camera_resources,
1071 .num_resources = ARRAY_SIZE(msm_camera_resources),
1072 .flash_data = &flash_ov9726,
1073 .sensor_platform_info = &ov9726_sensor_7630_info,
1074 .csi_if = 1
1075};
1076struct platform_device msm_camera_sensor_ov9726 = {
1077 .name = "msm_camera_ov9726",
1078 .dev = {
1079 .platform_data = &msm_camera_sensor_ov9726_data,
1080 },
1081};
1082#endif
1083
1084#ifdef CONFIG_S5K3E2FX
1085static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1086 .flash_type = MSM_CAMERA_FLASH_LED,
1087 .flash_src = &msm_flash_src_pwm,
1088};
1089
1090static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1091 .sensor_name = "s5k3e2fx",
1092 .sensor_reset = 0,
1093 .sensor_pwd = 85,
1094 .vcm_pwd = 1,
1095 .vcm_enable = 0,
1096 .pdata = &msm_camera_device_data,
1097 .resource = msm_camera_resources,
1098 .num_resources = ARRAY_SIZE(msm_camera_resources),
1099 .flash_data = &flash_s5k3e2fx,
1100 .csi_if = 0
1101};
1102
1103static struct platform_device msm_camera_sensor_s5k3e2fx = {
1104 .name = "msm_camera_s5k3e2fx",
1105 .dev = {
1106 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1107 },
1108};
1109#endif
1110
1111#ifdef CONFIG_MT9P012
1112static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1113 .flash_type = MSM_CAMERA_FLASH_LED,
1114 .flash_src = &msm_flash_src_pwm
1115};
1116
1117static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1118 .sensor_name = "mt9p012",
1119 .sensor_reset = 0,
1120 .sensor_pwd = 85,
1121 .vcm_pwd = 1,
1122 .vcm_enable = 1,
1123 .pdata = &msm_camera_device_data,
1124 .resource = msm_camera_resources,
1125 .num_resources = ARRAY_SIZE(msm_camera_resources),
1126 .flash_data = &flash_mt9p012,
1127 .csi_if = 0
1128};
1129
1130static struct platform_device msm_camera_sensor_mt9p012 = {
1131 .name = "msm_camera_mt9p012",
1132 .dev = {
1133 .platform_data = &msm_camera_sensor_mt9p012_data,
1134 },
1135};
1136#endif
1137
1138#ifdef CONFIG_MT9E013
1139static struct msm_camera_sensor_platform_info mt9e013_sensor_7630_info = {
1140 .mount_angle = 0
1141};
1142
1143static struct msm_camera_sensor_flash_data flash_mt9e013 = {
1144 .flash_type = MSM_CAMERA_FLASH_LED,
1145 .flash_src = &msm_flash_src_pwm
1146};
1147
1148static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
1149 .sensor_name = "mt9e013",
1150 .sensor_reset = 0,
1151 .sensor_pwd = 85,
1152 .vcm_pwd = 1,
1153 .vcm_enable = 1,
1154 .pdata = &msm_camera_device_data,
1155 .resource = msm_camera_resources,
1156 .num_resources = ARRAY_SIZE(msm_camera_resources),
1157 .flash_data = &flash_mt9e013,
1158 .sensor_platform_info = &mt9e013_sensor_7630_info,
1159 .csi_if = 1
1160};
1161
1162static struct platform_device msm_camera_sensor_mt9e013 = {
1163 .name = "msm_camera_mt9e013",
1164 .dev = {
1165 .platform_data = &msm_camera_sensor_mt9e013_data,
1166 },
1167};
1168#endif
1169
1170#ifdef CONFIG_VX6953
1171static struct msm_camera_sensor_flash_data flash_vx6953 = {
1172 .flash_type = MSM_CAMERA_FLASH_LED,
1173 .flash_src = &msm_flash_src_pwm
1174};
1175static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1176 .sensor_name = "vx6953",
1177 .sensor_reset = 0,
1178 .sensor_pwd = 85,
1179 .vcm_pwd = 1,
1180 .vcm_enable = 0,
1181 .pdata = &msm_camera_device_data,
1182 .resource = msm_camera_resources,
1183 .num_resources = ARRAY_SIZE(msm_camera_resources),
1184 .flash_data = &flash_vx6953,
1185 .csi_if = 1
1186};
1187static struct platform_device msm_camera_sensor_vx6953 = {
1188 .name = "msm_camera_vx6953",
1189 .dev = {
1190 .platform_data = &msm_camera_sensor_vx6953_data,
1191 },
1192};
1193#endif
1194
1195#ifdef CONFIG_SN12M0PZ
1196static struct msm_camera_sensor_flash_src msm_flash_src_current_driver = {
1197 .flash_sr_type = MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER,
1198 ._fsrc.current_driver_src.low_current = 210,
1199 ._fsrc.current_driver_src.high_current = 700,
1200 ._fsrc.current_driver_src.driver_channel = &pm8058_fluid_leds_data,
1201};
1202
1203static struct msm_camera_sensor_flash_data flash_sn12m0pz = {
1204 .flash_type = MSM_CAMERA_FLASH_LED,
1205 .flash_src = &msm_flash_src_current_driver
1206};
1207static struct msm_camera_sensor_info msm_camera_sensor_sn12m0pz_data = {
1208 .sensor_name = "sn12m0pz",
1209 .sensor_reset = 0,
1210 .sensor_pwd = 85,
1211 .vcm_pwd = 1,
1212 .vcm_enable = 1,
1213 .pdata = &msm_camera_device_data,
1214 .flash_data = &flash_sn12m0pz,
1215 .resource = msm_camera_resources,
1216 .num_resources = ARRAY_SIZE(msm_camera_resources),
1217 .csi_if = 0
1218};
1219
1220static struct platform_device msm_camera_sensor_sn12m0pz = {
1221 .name = "msm_camera_sn12m0pz",
1222 .dev = {
1223 .platform_data = &msm_camera_sensor_sn12m0pz_data,
1224 },
1225};
1226#endif
1227
1228#ifdef CONFIG_MT9T013
1229static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1230 .flash_type = MSM_CAMERA_FLASH_LED,
1231 .flash_src = &msm_flash_src_pwm
1232};
1233
1234static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1235 .sensor_name = "mt9t013",
1236 .sensor_reset = 0,
1237 .sensor_pwd = 85,
1238 .vcm_pwd = 1,
1239 .vcm_enable = 0,
1240 .pdata = &msm_camera_device_data,
1241 .resource = msm_camera_resources,
1242 .num_resources = ARRAY_SIZE(msm_camera_resources),
1243 .flash_data = &flash_mt9t013,
1244 .csi_if = 1
1245};
1246
1247static struct platform_device msm_camera_sensor_mt9t013 = {
1248 .name = "msm_camera_mt9t013",
1249 .dev = {
1250 .platform_data = &msm_camera_sensor_mt9t013_data,
1251 },
1252};
1253#endif
1254
1255#ifdef CONFIG_MSM_GEMINI
1256static struct resource msm_gemini_resources[] = {
1257 {
1258 .start = 0xA3A00000,
1259 .end = 0xA3A00000 + 0x0150 - 1,
1260 .flags = IORESOURCE_MEM,
1261 },
1262 {
1263 .start = INT_JPEG,
1264 .end = INT_JPEG,
1265 .flags = IORESOURCE_IRQ,
1266 },
1267};
1268
1269static struct platform_device msm_gemini_device = {
1270 .name = "msm_gemini",
1271 .resource = msm_gemini_resources,
1272 .num_resources = ARRAY_SIZE(msm_gemini_resources),
1273};
1274#endif
1275
1276#ifdef CONFIG_MSM_VPE
1277static struct resource msm_vpe_resources[] = {
1278 {
1279 .start = 0xAD200000,
1280 .end = 0xAD200000 + SZ_1M - 1,
1281 .flags = IORESOURCE_MEM,
1282 },
1283 {
1284 .start = INT_VPE,
1285 .end = INT_VPE,
1286 .flags = IORESOURCE_IRQ,
1287 },
1288};
1289
1290static struct platform_device msm_vpe_device = {
1291 .name = "msm_vpe",
1292 .id = 0,
1293 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1294 .resource = msm_vpe_resources,
1295};
1296#endif
1297
1298#endif /*CONFIG_MSM_CAMERA*/
1299
1300#ifdef CONFIG_MSM7KV2_AUDIO
1301static uint32_t audio_pamp_gpio_config =
1302 GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1303
1304static uint32_t audio_fluid_icodec_tx_config =
1305 GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1306
1307static int __init snddev_poweramp_gpio_init(void)
1308{
1309 int rc;
1310
1311 pr_info("snddev_poweramp_gpio_init \n");
1312 rc = gpio_tlmm_config(audio_pamp_gpio_config, GPIO_CFG_ENABLE);
1313 if (rc) {
1314 printk(KERN_ERR
1315 "%s: gpio_tlmm_config(%#x)=%d\n",
1316 __func__, audio_pamp_gpio_config, rc);
1317 }
1318 return rc;
1319}
1320
1321void msm_snddev_tx_route_config(void)
1322{
1323 int rc;
1324
1325 pr_debug("%s()\n", __func__);
1326
1327 if (machine_is_msm7x30_fluid()) {
1328 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1329 GPIO_CFG_ENABLE);
1330 if (rc) {
1331 printk(KERN_ERR
1332 "%s: gpio_tlmm_config(%#x)=%d\n",
1333 __func__, audio_fluid_icodec_tx_config, rc);
1334 } else
1335 gpio_set_value(85, 0);
1336 }
1337}
1338
1339void msm_snddev_tx_route_deconfig(void)
1340{
1341 int rc;
1342
1343 pr_debug("%s()\n", __func__);
1344
1345 if (machine_is_msm7x30_fluid()) {
1346 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1347 GPIO_CFG_DISABLE);
1348 if (rc) {
1349 printk(KERN_ERR
1350 "%s: gpio_tlmm_config(%#x)=%d\n",
1351 __func__, audio_fluid_icodec_tx_config, rc);
1352 }
1353 }
1354}
1355
1356void msm_snddev_poweramp_on(void)
1357{
1358 gpio_set_value(82, 1); /* enable spkr poweramp */
1359 pr_info("%s: power on amplifier\n", __func__);
1360}
1361
1362void msm_snddev_poweramp_off(void)
1363{
1364 gpio_set_value(82, 0); /* disable spkr poweramp */
1365 pr_info("%s: power off amplifier\n", __func__);
1366}
1367
1368static struct vreg *snddev_vreg_ncp, *snddev_vreg_gp4;
1369
1370void msm_snddev_hsed_voltage_on(void)
1371{
1372 int rc;
1373
1374 snddev_vreg_gp4 = vreg_get(NULL, "gp4");
1375 if (IS_ERR(snddev_vreg_gp4)) {
1376 pr_err("%s: vreg_get(%s) failed (%ld)\n",
1377 __func__, "gp4", PTR_ERR(snddev_vreg_gp4));
1378 return;
1379 }
1380 rc = vreg_enable(snddev_vreg_gp4);
1381 if (rc)
1382 pr_err("%s: vreg_enable(gp4) failed (%d)\n", __func__, rc);
1383
1384 snddev_vreg_ncp = vreg_get(NULL, "ncp");
1385 if (IS_ERR(snddev_vreg_ncp)) {
1386 pr_err("%s: vreg_get(%s) failed (%ld)\n",
1387 __func__, "ncp", PTR_ERR(snddev_vreg_ncp));
1388 return;
1389 }
1390 rc = vreg_enable(snddev_vreg_ncp);
1391 if (rc)
1392 pr_err("%s: vreg_enable(ncp) failed (%d)\n", __func__, rc);
1393}
1394
1395void msm_snddev_hsed_voltage_off(void)
1396{
1397 int rc;
1398
1399 if (IS_ERR(snddev_vreg_ncp)) {
1400 pr_err("%s: vreg_get(%s) failed (%ld)\n",
1401 __func__, "ncp", PTR_ERR(snddev_vreg_ncp));
1402 return;
1403 }
1404 rc = vreg_disable(snddev_vreg_ncp);
1405 if (rc)
1406 pr_err("%s: vreg_disable(ncp) failed (%d)\n", __func__, rc);
1407 vreg_put(snddev_vreg_ncp);
1408
1409 if (IS_ERR(snddev_vreg_gp4)) {
1410 pr_err("%s: vreg_get(%s) failed (%ld)\n",
1411 __func__, "gp4", PTR_ERR(snddev_vreg_gp4));
1412 return;
1413 }
1414 rc = vreg_disable(snddev_vreg_gp4);
1415 if (rc)
1416 pr_err("%s: vreg_disable(gp4) failed (%d)\n", __func__, rc);
1417
1418 vreg_put(snddev_vreg_gp4);
1419
1420}
1421
1422static unsigned aux_pcm_gpio_on[] = {
1423 GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
1424 GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
1425 GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
1426 GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
1427};
1428
1429static int __init aux_pcm_gpio_init(void)
1430{
1431 int pin, rc;
1432
1433 pr_info("aux_pcm_gpio_init \n");
1434 for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) {
1435 rc = gpio_tlmm_config(aux_pcm_gpio_on[pin],
1436 GPIO_CFG_ENABLE);
1437 if (rc) {
1438 printk(KERN_ERR
1439 "%s: gpio_tlmm_config(%#x)=%d\n",
1440 __func__, aux_pcm_gpio_on[pin], rc);
1441 }
1442 }
1443 return rc;
1444}
1445
1446static struct msm_gpio mi2s_clk_gpios[] = {
1447 { GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1448 "MI2S_SCLK"},
1449 { GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1450 "MI2S_WS"},
1451 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1452 "MI2S_MCLK_A"},
1453};
1454
1455static struct msm_gpio mi2s_rx_data_lines_gpios[] = {
1456 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1457 "MI2S_DATA_SD0_A"},
1458 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1459 "MI2S_DATA_SD1_A"},
1460 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1461 "MI2S_DATA_SD2_A"},
1462 { GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1463 "MI2S_DATA_SD3"},
1464};
1465
1466static struct msm_gpio mi2s_tx_data_lines_gpios[] = {
1467 { GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1468 "MI2S_DATA_SD3"},
1469};
1470
1471int mi2s_config_clk_gpio(void)
1472{
1473 int rc = 0;
1474
1475 rc = msm_gpios_request_enable(mi2s_clk_gpios,
1476 ARRAY_SIZE(mi2s_clk_gpios));
1477 if (rc) {
1478 pr_err("%s: enable mi2s clk gpios failed\n",
1479 __func__);
1480 return rc;
1481 }
1482 return 0;
1483}
1484
1485int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask)
1486{
1487 int i, rc = 0;
1488 sd_line_mask &= MI2S_SD_LINE_MASK;
1489
1490 switch (direction) {
1491 case DIR_TX:
1492 msm_gpios_disable_free(mi2s_tx_data_lines_gpios, 1);
1493 break;
1494 case DIR_RX:
1495 i = 0;
1496 while (sd_line_mask) {
1497 if (sd_line_mask & 0x1)
1498 msm_gpios_disable_free(
1499 mi2s_rx_data_lines_gpios + i , 1);
1500 sd_line_mask = sd_line_mask >> 1;
1501 i++;
1502 }
1503 break;
1504 default:
1505 pr_err("%s: Invaild direction direction = %u\n",
1506 __func__, direction);
1507 rc = -EINVAL;
1508 break;
1509 }
1510 return rc;
1511}
1512
1513int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask)
1514{
1515 int i , rc = 0;
1516 u8 sd_config_done_mask = 0;
1517
1518 sd_line_mask &= MI2S_SD_LINE_MASK;
1519
1520 switch (direction) {
1521 case DIR_TX:
1522 if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) ||
1523 (sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) {
1524 pr_err("%s: can not use SD0 or SD1 or SD2 for TX"
1525 ".only can use SD3. sd_line_mask = 0x%x\n",
1526 __func__ , sd_line_mask);
1527 rc = -EINVAL;
1528 } else {
1529 rc = msm_gpios_request_enable(mi2s_tx_data_lines_gpios,
1530 1);
1531 if (rc)
1532 pr_err("%s: enable mi2s gpios for TX failed\n",
1533 __func__);
1534 }
1535 break;
1536 case DIR_RX:
1537 i = 0;
1538 while (sd_line_mask && (rc == 0)) {
1539 if (sd_line_mask & 0x1) {
1540 rc = msm_gpios_request_enable(
1541 mi2s_rx_data_lines_gpios + i , 1);
1542 if (rc) {
1543 pr_err("%s: enable mi2s gpios for"
1544 "RX failed. SD line = %s\n",
1545 __func__,
1546 (mi2s_rx_data_lines_gpios + i)->label);
1547 mi2s_unconfig_data_gpio(DIR_RX,
1548 sd_config_done_mask);
1549 } else
1550 sd_config_done_mask |= (1 << i);
1551 }
1552 sd_line_mask = sd_line_mask >> 1;
1553 i++;
1554 }
1555 break;
1556 default:
1557 pr_err("%s: Invaild direction direction = %u\n",
1558 __func__, direction);
1559 rc = -EINVAL;
1560 break;
1561 }
1562 return rc;
1563}
1564
1565int mi2s_unconfig_clk_gpio(void)
1566{
1567 msm_gpios_disable_free(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios));
1568 return 0;
1569}
1570
1571#endif /* CONFIG_MSM7KV2_AUDIO */
1572
1573static int __init buses_init(void)
1574{
1575 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT,
1576 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
1577 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
1578 __func__, PMIC_GPIO_INT);
1579
1580 if (machine_is_msm7x30_fluid()) {
1581 pm8058_7x30_data.sub_devices[PM8058_SUBDEV_KPD].platform_data
1582 = &fluid_keypad_data;
1583 } else {
1584 pm8058_7x30_data.sub_devices[PM8058_SUBDEV_KPD].platform_data
1585 = &surf_keypad_data;
1586 pm8058_7x30_data.sub_devices[PM8058_SUBDEV_KPD].pdata_size
1587 = sizeof(surf_keypad_data);
1588 }
1589
1590 i2c_register_board_info(6 /* I2C_SSBI ID */, pm8058_boardinfo,
1591 ARRAY_SIZE(pm8058_boardinfo));
1592
1593 return 0;
1594}
1595
1596#define TIMPANI_RESET_GPIO 1
1597
1598struct bahama_config_register{
1599 u8 reg;
1600 u8 value;
1601 u8 mask;
1602};
1603
1604enum version{
1605 VER_1_0,
1606 VER_2_0,
1607 VER_UNSUPPORTED = 0xFF
1608};
1609
1610
1611static struct vreg *vreg_marimba_1;
1612static struct vreg *vreg_marimba_2;
1613static struct vreg *vreg_marimba_3;
1614
1615static struct msm_gpio timpani_reset_gpio_cfg[] = {
1616{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
1617 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} };
1618
1619static u8 read_bahama_ver(void)
1620{
1621 int rc;
1622 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1623 u8 bahama_version;
1624
1625 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
1626 if (rc < 0) {
1627 printk(KERN_ERR
1628 "%s: version read failed: %d\n",
1629 __func__, rc);
1630 return rc;
1631 } else {
1632 printk(KERN_INFO
1633 "%s: version read got: 0x%x\n",
1634 __func__, bahama_version);
1635 }
1636
1637 switch (bahama_version) {
1638 case 0x08: /* varient of bahama v1 */
1639 case 0x10:
1640 case 0x00:
1641 return VER_1_0;
1642 case 0x09: /* variant of bahama v2 */
1643 return VER_2_0;
1644 default:
1645 return VER_UNSUPPORTED;
1646 }
1647}
1648
1649static int config_timpani_reset(void)
1650{
1651 int rc;
1652
1653 rc = msm_gpios_request_enable(timpani_reset_gpio_cfg,
1654 ARRAY_SIZE(timpani_reset_gpio_cfg));
1655 if (rc < 0) {
1656 printk(KERN_ERR
1657 "%s: msm_gpios_request_enable failed (%d)\n",
1658 __func__, rc);
1659 }
1660 return rc;
1661}
1662
1663static unsigned int msm_timpani_setup_power(void)
1664{
1665 int rc;
1666
1667 rc = config_timpani_reset();
1668 if (rc < 0)
1669 goto out;
1670
1671 rc = vreg_enable(vreg_marimba_1);
1672 if (rc) {
1673 printk(KERN_ERR "%s: vreg_enable() = %d\n",
1674 __func__, rc);
1675 goto out;
1676 }
1677 rc = vreg_enable(vreg_marimba_2);
1678 if (rc) {
1679 printk(KERN_ERR "%s: vreg_enable() = %d\n",
1680 __func__, rc);
1681 goto fail_disable_vreg_marimba_1;
1682 }
1683
1684 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1);
1685 if (rc < 0) {
1686 printk(KERN_ERR
1687 "%s: gpio_direction_output failed (%d)\n",
1688 __func__, rc);
1689 msm_gpios_free(timpani_reset_gpio_cfg,
1690 ARRAY_SIZE(timpani_reset_gpio_cfg));
1691 vreg_disable(vreg_marimba_2);
1692 } else
1693 goto out;
1694
1695
1696fail_disable_vreg_marimba_1:
1697 vreg_disable(vreg_marimba_1);
1698
1699out:
1700 return rc;
1701};
1702
1703static void msm_timpani_shutdown_power(void)
1704{
1705 int rc;
1706
1707 rc = vreg_disable(vreg_marimba_1);
1708 if (rc) {
1709 printk(KERN_ERR "%s: return val: %d\n",
1710 __func__, rc);
1711 }
1712 rc = vreg_disable(vreg_marimba_2);
1713 if (rc) {
1714 printk(KERN_ERR "%s: return val: %d\n",
1715 __func__, rc);
1716 }
1717
1718 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0);
1719 if (rc < 0) {
1720 printk(KERN_ERR
1721 "%s: gpio_direction_output failed (%d)\n",
1722 __func__, rc);
1723 }
1724
1725 msm_gpios_free(timpani_reset_gpio_cfg,
1726 ARRAY_SIZE(timpani_reset_gpio_cfg));
1727};
1728
1729static unsigned int msm_bahama_core_config(int type)
1730{
1731 int rc = 0;
1732
1733 if (type == BAHAMA_ID) {
1734
1735 int i;
1736 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1737
1738 const struct bahama_config_register v20_init[] = {
1739 /* reg, value, mask */
1740 { 0xF4, 0x84, 0xFF }, /* AREG */
1741 { 0xF0, 0x04, 0xFF } /* DREG */
1742 };
1743
1744 if (read_bahama_ver() == VER_2_0) {
1745 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
1746 u8 value = v20_init[i].value;
1747 rc = marimba_write_bit_mask(&config,
1748 v20_init[i].reg,
1749 &value,
1750 sizeof(v20_init[i].value),
1751 v20_init[i].mask);
1752 if (rc < 0) {
1753 printk(KERN_ERR
1754 "%s: reg %d write failed: %d\n",
1755 __func__, v20_init[i].reg, rc);
1756 return rc;
1757 }
1758 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
1759 " mask 0x%02x\n",
1760 __func__, v20_init[i].reg,
1761 v20_init[i].value, v20_init[i].mask);
1762 }
1763 }
1764 }
1765 printk(KERN_INFO "core type: %d\n", type);
1766
1767 return rc;
1768}
1769
1770static unsigned int msm_bahama_setup_power(void)
1771{
1772 int rc;
1773
1774 rc = vreg_enable(vreg_marimba_3);
1775 if (rc) {
1776 printk(KERN_ERR "%s: vreg_enable() = %d\n",
1777 __func__, rc);
1778 }
1779
1780 return rc;
1781};
1782
1783static unsigned int msm_bahama_shutdown_power(int value)
1784{
1785 int rc = 0;
1786
1787 if (value != BAHAMA_ID) {
1788 rc = vreg_disable(vreg_marimba_3);
1789 if (rc) {
1790 printk(KERN_ERR "%s: return val: %d\n",
1791 __func__, rc);
1792 }
1793 }
1794
1795 return rc;
1796};
1797
1798static struct msm_gpio marimba_svlte_config_clock[] = {
1799 { GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1800 "MARIMBA_SVLTE_CLOCK_ENABLE" },
1801};
1802
1803static unsigned int msm_marimba_gpio_config_svlte(int gpio_cfg_marimba)
1804{
1805 if (machine_is_msm8x55_svlte_surf() ||
1806 machine_is_msm8x55_svlte_ffa()) {
1807 if (gpio_cfg_marimba)
1808 gpio_set_value(GPIO_PIN
1809 (marimba_svlte_config_clock->gpio_cfg), 1);
1810 else
1811 gpio_set_value(GPIO_PIN
1812 (marimba_svlte_config_clock->gpio_cfg), 0);
1813 }
1814
1815 return 0;
1816};
1817
1818static unsigned int msm_marimba_setup_power(void)
1819{
1820 int rc;
1821
1822 rc = vreg_enable(vreg_marimba_1);
1823 if (rc) {
1824 printk(KERN_ERR "%s: vreg_enable() = %d \n",
1825 __func__, rc);
1826 goto out;
1827 }
1828 rc = vreg_enable(vreg_marimba_2);
1829 if (rc) {
1830 printk(KERN_ERR "%s: vreg_enable() = %d \n",
1831 __func__, rc);
1832 goto out;
1833 }
1834
1835 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
1836 rc = msm_gpios_request_enable(marimba_svlte_config_clock,
1837 ARRAY_SIZE(marimba_svlte_config_clock));
1838 if (rc < 0) {
1839 printk(KERN_ERR
1840 "%s: msm_gpios_request_enable failed (%d)\n",
1841 __func__, rc);
1842 return rc;
1843 }
1844
1845 rc = gpio_direction_output(GPIO_PIN
1846 (marimba_svlte_config_clock->gpio_cfg), 0);
1847 if (rc < 0) {
1848 printk(KERN_ERR
1849 "%s: gpio_direction_output failed (%d)\n",
1850 __func__, rc);
1851 return rc;
1852 }
1853 }
1854
1855out:
1856 return rc;
1857};
1858
1859static void msm_marimba_shutdown_power(void)
1860{
1861 int rc;
1862
1863 rc = vreg_disable(vreg_marimba_1);
1864 if (rc) {
1865 printk(KERN_ERR "%s: return val: %d\n",
1866 __func__, rc);
1867 }
1868 rc = vreg_disable(vreg_marimba_2);
1869 if (rc) {
1870 printk(KERN_ERR "%s: return val: %d \n",
1871 __func__, rc);
1872 }
1873};
1874
1875static int bahama_present(void)
1876{
1877 int id;
1878 switch (id = adie_get_detected_connectivity_type()) {
1879 case BAHAMA_ID:
1880 return 1;
1881
1882 case MARIMBA_ID:
1883 return 0;
1884
1885 case TIMPANI_ID:
1886 default:
1887 printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n",
1888 __func__, id);
1889 return -ENODEV;
1890 }
1891}
1892
1893struct vreg *fm_regulator;
1894static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
1895{
1896 int rc;
1897 uint32_t irqcfg;
1898 const char *id = "FMPW";
1899
1900 int bahama_not_marimba = bahama_present();
1901
1902 if (bahama_not_marimba == -1) {
1903 printk(KERN_WARNING "%s: bahama_present: %d\n",
1904 __func__, bahama_not_marimba);
1905 return -ENODEV;
1906 }
1907 if (bahama_not_marimba)
1908 fm_regulator = vreg_get(NULL, "s3");
1909 else
1910 fm_regulator = vreg_get(NULL, "s2");
1911
1912 if (IS_ERR(fm_regulator)) {
1913 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
1914 __func__, PTR_ERR(fm_regulator));
1915 return -1;
1916 }
1917 if (!bahama_not_marimba) {
1918
1919 rc = pmapp_vreg_level_vote(id, PMAPP_VREG_S2, 1300);
1920
1921 if (rc < 0) {
1922 printk(KERN_ERR "%s: voltage level vote failed (%d)\n",
1923 __func__, rc);
1924 return rc;
1925 }
1926 }
1927 rc = vreg_enable(fm_regulator);
1928 if (rc) {
1929 printk(KERN_ERR "%s: vreg_enable() = %d\n",
1930 __func__, rc);
1931 return rc;
1932 }
1933
1934 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
1935 PMAPP_CLOCK_VOTE_ON);
1936 if (rc < 0) {
1937 printk(KERN_ERR "%s: clock vote failed (%d)\n",
1938 __func__, rc);
1939 goto fm_clock_vote_fail;
1940 }
1941 /*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
1942 of svlte*/
1943 if (machine_is_msm8x55_svlte_surf() ||
1944 machine_is_msm8x55_svlte_ffa()) {
1945 rc = marimba_gpio_config(1);
1946 if (rc < 0)
1947 printk(KERN_ERR "%s: clock enable for svlte : %d\n",
1948 __func__, rc);
1949 }
1950 irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
1951 GPIO_CFG_2MA);
1952 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
1953 if (rc) {
1954 printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
1955 __func__, irqcfg, rc);
1956 rc = -EIO;
1957 goto fm_gpio_config_fail;
1958
1959 }
1960 return 0;
1961fm_gpio_config_fail:
1962 pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
1963 PMAPP_CLOCK_VOTE_OFF);
1964fm_clock_vote_fail:
1965 vreg_disable(fm_regulator);
1966 return rc;
1967
1968};
1969
1970static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
1971{
1972 int rc;
1973 const char *id = "FMPW";
1974 uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
1975 GPIO_CFG_2MA);
1976
1977 int bahama_not_marimba = bahama_present();
1978 if (bahama_not_marimba == -1) {
1979 printk(KERN_WARNING "%s: bahama_present: %d\n",
1980 __func__, bahama_not_marimba);
1981 return;
1982 }
1983
1984 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
1985 if (rc) {
1986 printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
1987 __func__, irqcfg, rc);
1988 }
1989 if (fm_regulator != NULL) {
1990 rc = vreg_disable(fm_regulator);
1991
1992 if (rc) {
1993 printk(KERN_ERR "%s: return val: %d\n",
1994 __func__, rc);
1995 }
1996 fm_regulator = NULL;
1997 }
1998 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
1999 PMAPP_CLOCK_VOTE_OFF);
2000 if (rc < 0)
2001 printk(KERN_ERR "%s: clock_vote return val: %d\n",
2002 __func__, rc);
2003
2004 /*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2005 of svlte*/
2006 if (machine_is_msm8x55_svlte_surf() ||
2007 machine_is_msm8x55_svlte_ffa()) {
2008 rc = marimba_gpio_config(0);
2009 if (rc < 0)
2010 printk(KERN_ERR "%s: clock disable for svlte : %d\n",
2011 __func__, rc);
2012 }
2013
2014
2015 if (!bahama_not_marimba) {
2016 rc = pmapp_vreg_level_vote(id, PMAPP_VREG_S2, 0);
2017
2018 if (rc < 0)
2019 printk(KERN_ERR "%s: vreg level vote return val: %d\n",
2020 __func__, rc);
2021 }
2022}
2023
2024static struct marimba_fm_platform_data marimba_fm_pdata = {
2025 .fm_setup = fm_radio_setup,
2026 .fm_shutdown = fm_radio_shutdown,
2027 .irq = MSM_GPIO_TO_INT(147),
2028 .vreg_s2 = NULL,
2029 .vreg_xo_out = NULL,
2030 .is_fm_soc_i2s_master = false,
2031 .config_i2s_gpio = NULL,
2032};
2033
2034
2035/* Slave id address for FM/CDC/QMEMBIST
2036 * Values can be programmed using Marimba slave id 0
2037 * should there be a conflict with other I2C devices
2038 * */
2039#define MARIMBA_SLAVE_ID_FM_ADDR 0x2A
2040#define MARIMBA_SLAVE_ID_CDC_ADDR 0x77
2041#define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66
2042
2043#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
2044#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
2045
2046static const char *tsadc_id = "MADC";
2047static const char *vregs_tsadc_name[] = {
2048 "gp12",
2049 "s2",
2050};
2051static struct vreg *vregs_tsadc[ARRAY_SIZE(vregs_tsadc_name)];
2052
2053static const char *vregs_timpani_tsadc_name[] = {
2054 "s3",
2055 "gp12",
2056 "gp16"
2057};
2058static struct vreg *vregs_timpani_tsadc[ARRAY_SIZE(vregs_timpani_tsadc_name)];
2059
2060static int marimba_tsadc_power(int vreg_on)
2061{
2062 int i, rc = 0;
2063 int tsadc_adie_type = adie_get_detected_codec_type();
2064
2065 if (tsadc_adie_type == TIMPANI_ID) {
2066 for (i = 0; i < ARRAY_SIZE(vregs_timpani_tsadc_name); i++) {
2067 if (!vregs_timpani_tsadc[i]) {
2068 pr_err("%s: vreg_get %s failed(%d)\n",
2069 __func__, vregs_timpani_tsadc_name[i], rc);
2070 goto vreg_fail;
2071 }
2072
2073 rc = vreg_on ? vreg_enable(vregs_timpani_tsadc[i]) :
2074 vreg_disable(vregs_timpani_tsadc[i]);
2075 if (rc < 0) {
2076 pr_err("%s: vreg %s %s failed(%d)\n",
2077 __func__, vregs_timpani_tsadc_name[i],
2078 vreg_on ? "enable" : "disable", rc);
2079 goto vreg_fail;
2080 }
2081 }
2082 /* Vote for D0 and D1 buffer */
2083 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2084 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2085 if (rc) {
2086 pr_err("%s: unable to %svote for d1 clk\n",
2087 __func__, vreg_on ? "" : "de-");
2088 goto do_vote_fail;
2089 }
2090 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2091 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2092 if (rc) {
2093 pr_err("%s: unable to %svote for d1 clk\n",
2094 __func__, vreg_on ? "" : "de-");
2095 goto do_vote_fail;
2096 }
2097 } else if (tsadc_adie_type == MARIMBA_ID) {
2098 for (i = 0; i < ARRAY_SIZE(vregs_tsadc_name); i++) {
2099 if (!vregs_tsadc[i]) {
2100 pr_err("%s: vreg_get %s failed (%d)\n",
2101 __func__, vregs_tsadc_name[i], rc);
2102 goto vreg_fail;
2103 }
2104
2105 rc = vreg_on ? vreg_enable(vregs_tsadc[i]) :
2106 vreg_disable(vregs_tsadc[i]);
2107 if (rc < 0) {
2108 pr_err("%s: vreg %s %s failed (%d)\n",
2109 __func__, vregs_tsadc_name[i],
2110 vreg_on ? "enable" : "disable", rc);
2111 goto vreg_fail;
2112 }
2113 }
2114 /* If marimba vote for DO buffer */
2115 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2116 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2117 if (rc) {
2118 pr_err("%s: unable to %svote for d0 clk\n",
2119 __func__, vreg_on ? "" : "de-");
2120 goto do_vote_fail;
2121 }
2122 } else {
2123 pr_err("%s:Adie %d not supported\n",
2124 __func__, tsadc_adie_type);
2125 return -ENODEV;
2126 }
2127
2128 msleep(5); /* ensure power is stable */
2129
2130 return 0;
2131
2132do_vote_fail:
2133vreg_fail:
2134 while (i) {
2135 if (vreg_on) {
2136 if (tsadc_adie_type == TIMPANI_ID)
2137 vreg_disable(vregs_timpani_tsadc[--i]);
2138 else if (tsadc_adie_type == MARIMBA_ID)
2139 vreg_disable(vregs_tsadc[--i]);
2140 } else {
2141 if (tsadc_adie_type == TIMPANI_ID)
2142 vreg_enable(vregs_timpani_tsadc[--i]);
2143 else if (tsadc_adie_type == MARIMBA_ID)
2144 vreg_enable(vregs_tsadc[--i]);
2145 }
2146 }
2147
2148 return rc;
2149}
2150
2151static int marimba_tsadc_vote(int vote_on)
2152{
2153 int rc = 0;
2154
2155 if (adie_get_detected_codec_type() == MARIMBA_ID) {
2156 int level = vote_on ? 1300 : 0;
2157 rc = pmapp_vreg_level_vote(tsadc_id, PMAPP_VREG_S2, level);
2158 if (rc < 0)
2159 pr_err("%s: vreg level %s failed (%d)\n",
2160 __func__, vote_on ? "on" : "off", rc);
2161 }
2162
2163 return rc;
2164}
2165
2166static int marimba_tsadc_init(void)
2167{
2168 int i, rc = 0;
2169 int tsadc_adie_type = adie_get_detected_codec_type();
2170
2171 if (tsadc_adie_type == TIMPANI_ID) {
2172 for (i = 0; i < ARRAY_SIZE(vregs_timpani_tsadc_name); i++) {
2173 vregs_timpani_tsadc[i] = vreg_get(NULL,
2174 vregs_timpani_tsadc_name[i]);
2175 if (IS_ERR(vregs_timpani_tsadc[i])) {
2176 pr_err("%s: vreg get %s failed (%ld)\n",
2177 __func__, vregs_timpani_tsadc_name[i],
2178 PTR_ERR(vregs_timpani_tsadc[i]));
2179 rc = PTR_ERR(vregs_timpani_tsadc[i]);
2180 goto vreg_get_fail;
2181 }
2182 }
2183 } else if (tsadc_adie_type == MARIMBA_ID) {
2184 for (i = 0; i < ARRAY_SIZE(vregs_tsadc_name); i++) {
2185 vregs_tsadc[i] = vreg_get(NULL, vregs_tsadc_name[i]);
2186 if (IS_ERR(vregs_tsadc[i])) {
2187 pr_err("%s: vreg get %s failed (%ld)\n",
2188 __func__, vregs_tsadc_name[i],
2189 PTR_ERR(vregs_tsadc[i]));
2190 rc = PTR_ERR(vregs_tsadc[i]);
2191 goto vreg_get_fail;
2192 }
2193 }
2194 } else {
2195 pr_err("%s:Adie %d not supported\n",
2196 __func__, tsadc_adie_type);
2197 return -ENODEV;
2198 }
2199
2200 return 0;
2201
2202vreg_get_fail:
2203 while (i) {
2204 if (tsadc_adie_type == TIMPANI_ID)
2205 vreg_put(vregs_timpani_tsadc[--i]);
2206 else if (tsadc_adie_type == MARIMBA_ID)
2207 vreg_put(vregs_tsadc[--i]);
2208 }
2209 return rc;
2210}
2211
2212static int marimba_tsadc_exit(void)
2213{
2214 int i, rc = 0;
2215 int tsadc_adie_type = adie_get_detected_codec_type();
2216
2217 if (tsadc_adie_type == TIMPANI_ID) {
2218 for (i = 0; i < ARRAY_SIZE(vregs_timpani_tsadc_name); i++) {
2219 if (vregs_tsadc[i])
2220 vreg_put(vregs_timpani_tsadc[i]);
2221 }
2222 } else if (tsadc_adie_type == MARIMBA_ID) {
2223 for (i = 0; i < ARRAY_SIZE(vregs_tsadc_name); i++) {
2224 if (vregs_tsadc[i])
2225 vreg_put(vregs_tsadc[i]);
2226 }
2227 rc = pmapp_vreg_level_vote(tsadc_id, PMAPP_VREG_S2, 0);
2228 if (rc < 0)
2229 pr_err("%s: vreg level off failed (%d)\n",
2230 __func__, rc);
2231 } else {
2232 pr_err("%s:Adie %d not supported\n",
2233 __func__, tsadc_adie_type);
2234 rc = -ENODEV;
2235 }
2236
2237 return rc;
2238}
2239
2240
2241static struct msm_ts_platform_data msm_ts_data = {
2242 .min_x = 0,
2243 .max_x = 4096,
2244 .min_y = 0,
2245 .max_y = 4096,
2246 .min_press = 0,
2247 .max_press = 255,
2248 .inv_x = 4096,
2249 .inv_y = 4096,
2250 .can_wakeup = false,
2251};
2252
2253static struct marimba_tsadc_platform_data marimba_tsadc_pdata = {
2254 .marimba_tsadc_power = marimba_tsadc_power,
2255 .init = marimba_tsadc_init,
2256 .exit = marimba_tsadc_exit,
2257 .level_vote = marimba_tsadc_vote,
2258 .tsadc_prechg_en = true,
2259 .can_wakeup = false,
2260 .setup = {
2261 .pen_irq_en = true,
2262 .tsadc_en = true,
2263 },
2264 .params2 = {
2265 .input_clk_khz = 2400,
2266 .sample_prd = TSADC_CLK_3,
2267 },
2268 .params3 = {
2269 .prechg_time_nsecs = 6400,
2270 .stable_time_nsecs = 6400,
2271 .tsadc_test_mode = 0,
2272 },
2273 .tssc_data = &msm_ts_data,
2274};
2275
2276static struct vreg *vreg_codec_s4;
2277static int msm_marimba_codec_power(int vreg_on)
2278{
2279 int rc = 0;
2280
2281 if (!vreg_codec_s4) {
2282
2283 vreg_codec_s4 = vreg_get(NULL, "s4");
2284
2285 if (IS_ERR(vreg_codec_s4)) {
2286 printk(KERN_ERR "%s: vreg_get() failed (%ld)\n",
2287 __func__, PTR_ERR(vreg_codec_s4));
2288 rc = PTR_ERR(vreg_codec_s4);
2289 goto vreg_codec_s4_fail;
2290 }
2291 }
2292
2293 if (vreg_on) {
2294 rc = vreg_enable(vreg_codec_s4);
2295 if (rc)
2296 printk(KERN_ERR "%s: vreg_enable() = %d \n",
2297 __func__, rc);
2298 goto vreg_codec_s4_fail;
2299 } else {
2300 rc = vreg_disable(vreg_codec_s4);
2301 if (rc)
2302 printk(KERN_ERR "%s: vreg_disable() = %d \n",
2303 __func__, rc);
2304 goto vreg_codec_s4_fail;
2305 }
2306
2307vreg_codec_s4_fail:
2308 return rc;
2309}
2310
2311static struct marimba_codec_platform_data mariba_codec_pdata = {
2312 .marimba_codec_power = msm_marimba_codec_power,
2313#ifdef CONFIG_MARIMBA_CODEC
2314 .snddev_profile_init = msm_snddev_init,
2315#endif
2316};
2317
2318static struct marimba_platform_data marimba_pdata = {
2319 .slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR,
2320 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2321 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2322 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
2323 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
2324 .marimba_setup = msm_marimba_setup_power,
2325 .marimba_shutdown = msm_marimba_shutdown_power,
2326 .bahama_setup = msm_bahama_setup_power,
2327 .bahama_shutdown = msm_bahama_shutdown_power,
2328 .marimba_gpio_config = msm_marimba_gpio_config_svlte,
2329 .bahama_core_config = msm_bahama_core_config,
2330 .fm = &marimba_fm_pdata,
2331 .codec = &mariba_codec_pdata,
2332 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2333};
2334
2335static void __init msm7x30_init_marimba(void)
2336{
2337 int rc;
2338
2339 vreg_marimba_1 = vreg_get(NULL, "s3");
2340 if (IS_ERR(vreg_marimba_1)) {
2341 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
2342 __func__, PTR_ERR(vreg_marimba_1));
2343 return;
2344 }
2345 rc = vreg_set_level(vreg_marimba_1, 1800);
2346
2347 vreg_marimba_2 = vreg_get(NULL, "gp16");
2348 if (IS_ERR(vreg_marimba_1)) {
2349 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
2350 __func__, PTR_ERR(vreg_marimba_1));
2351 return;
2352 }
2353 rc = vreg_set_level(vreg_marimba_2, 1200);
2354
2355 vreg_marimba_3 = vreg_get(NULL, "usb2");
2356 if (IS_ERR(vreg_marimba_3)) {
2357 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
2358 __func__, PTR_ERR(vreg_marimba_3));
2359 return;
2360 }
2361 rc = vreg_set_level(vreg_marimba_3, 1800);
2362}
2363
2364static struct marimba_codec_platform_data timpani_codec_pdata = {
2365 .marimba_codec_power = msm_marimba_codec_power,
2366#ifdef CONFIG_TIMPANI_CODEC
2367 .snddev_profile_init = msm_snddev_init_timpani,
2368#endif
2369};
2370
2371static struct marimba_platform_data timpani_pdata = {
2372 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2373 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2374 .marimba_setup = msm_timpani_setup_power,
2375 .marimba_shutdown = msm_timpani_shutdown_power,
2376 .codec = &timpani_codec_pdata,
2377 .tsadc = &marimba_tsadc_pdata,
2378 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2379};
2380
2381#define TIMPANI_I2C_SLAVE_ADDR 0xD
2382
2383static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
2384 {
2385 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
2386 .platform_data = &timpani_pdata,
2387 },
2388};
2389
2390#ifdef CONFIG_MSM7KV2_AUDIO
2391static struct resource msm_aictl_resources[] = {
2392 {
2393 .name = "aictl",
2394 .start = 0xa5000100,
2395 .end = 0xa5000100,
2396 .flags = IORESOURCE_MEM,
2397 }
2398};
2399
2400static struct resource msm_mi2s_resources[] = {
2401 {
2402 .name = "hdmi",
2403 .start = 0xac900000,
2404 .end = 0xac900038,
2405 .flags = IORESOURCE_MEM,
2406 },
2407 {
2408 .name = "codec_rx",
2409 .start = 0xac940040,
2410 .end = 0xac940078,
2411 .flags = IORESOURCE_MEM,
2412 },
2413 {
2414 .name = "codec_tx",
2415 .start = 0xac980080,
2416 .end = 0xac9800B8,
2417 .flags = IORESOURCE_MEM,
2418 }
2419
2420};
2421
2422static struct msm_lpa_platform_data lpa_pdata = {
2423 .obuf_hlb_size = 0x2BFF8,
2424 .dsp_proc_id = 0,
2425 .app_proc_id = 2,
2426 .nosb_config = {
2427 .llb_min_addr = 0,
2428 .llb_max_addr = 0x3ff8,
2429 .sb_min_addr = 0,
2430 .sb_max_addr = 0,
2431 },
2432 .sb_config = {
2433 .llb_min_addr = 0,
2434 .llb_max_addr = 0x37f8,
2435 .sb_min_addr = 0x3800,
2436 .sb_max_addr = 0x3ff8,
2437 }
2438};
2439
2440static struct resource msm_lpa_resources[] = {
2441 {
2442 .name = "lpa",
2443 .start = 0xa5000000,
2444 .end = 0xa50000a0,
2445 .flags = IORESOURCE_MEM,
2446 }
2447};
2448
2449static struct resource msm_aux_pcm_resources[] = {
2450
2451 {
2452 .name = "aux_codec_reg_addr",
2453 .start = 0xac9c00c0,
2454 .end = 0xac9c00c8,
2455 .flags = IORESOURCE_MEM,
2456 },
2457 {
2458 .name = "aux_pcm_dout",
2459 .start = 138,
2460 .end = 138,
2461 .flags = IORESOURCE_IO,
2462 },
2463 {
2464 .name = "aux_pcm_din",
2465 .start = 139,
2466 .end = 139,
2467 .flags = IORESOURCE_IO,
2468 },
2469 {
2470 .name = "aux_pcm_syncout",
2471 .start = 140,
2472 .end = 140,
2473 .flags = IORESOURCE_IO,
2474 },
2475 {
2476 .name = "aux_pcm_clkin_a",
2477 .start = 141,
2478 .end = 141,
2479 .flags = IORESOURCE_IO,
2480 },
2481};
2482
2483static struct platform_device msm_aux_pcm_device = {
2484 .name = "msm_aux_pcm",
2485 .id = 0,
2486 .num_resources = ARRAY_SIZE(msm_aux_pcm_resources),
2487 .resource = msm_aux_pcm_resources,
2488};
2489
2490struct platform_device msm_aictl_device = {
2491 .name = "audio_interct",
2492 .id = 0,
2493 .num_resources = ARRAY_SIZE(msm_aictl_resources),
2494 .resource = msm_aictl_resources,
2495};
2496
2497struct platform_device msm_mi2s_device = {
2498 .name = "mi2s",
2499 .id = 0,
2500 .num_resources = ARRAY_SIZE(msm_mi2s_resources),
2501 .resource = msm_mi2s_resources,
2502};
2503
2504struct platform_device msm_lpa_device = {
2505 .name = "lpa",
2506 .id = 0,
2507 .num_resources = ARRAY_SIZE(msm_lpa_resources),
2508 .resource = msm_lpa_resources,
2509 .dev = {
2510 .platform_data = &lpa_pdata,
2511 },
2512};
2513#endif /* CONFIG_MSM7KV2_AUDIO */
2514
2515#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2516 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2517 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2518 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2519 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2520 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2521#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2522 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2523 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2524 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2525 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2526 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2527 #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2528 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2529 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2530 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2531 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2532 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2533 #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2534 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2535 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2536 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2537 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2538 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2539#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
2540
2541static unsigned int dec_concurrency_table[] = {
2542 /* Audio LP */
2543 0,
2544 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2545 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2546 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2547 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)|
2548 (1<<MSM_ADSP_OP_DM)),
2549
2550 /* Concurrency 1 */
2551 (DEC4_FORMAT),
2552 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2553 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2554 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2555 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2556
2557 /* Concurrency 2 */
2558 (DEC4_FORMAT),
2559 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2560 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2561 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2562 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2563
2564 /* Concurrency 3 */
2565 (DEC4_FORMAT),
2566 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2567 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2568 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2569 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2570
2571 /* Concurrency 4 */
2572 (DEC4_FORMAT),
2573 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2574 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2575 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2576 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2577
2578 /* Concurrency 5 */
2579 (DEC4_FORMAT),
2580 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2581 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2582 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2583 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2584
2585 /* Concurrency 6 */
2586 (DEC4_FORMAT),
2587 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2588 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2589 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2590 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2591};
2592
2593#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
2594 .module_queueid = queueid, .module_decid = decid, \
2595 .nr_codec_support = nr_codec}
2596
2597#define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
2598 .max_instances_same_dec = max_instance_same, \
2599 .max_instances_diff_dec = max_instance_diff}
2600
2601static struct msm_adspdec_info dec_info_list[] = {
2602 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
2603 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
2604 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
2605 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
2606 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
2607};
2608
2609static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
2610 /* Non Turbo Mode */
2611 {
2612 DEC_INSTANCE(4, 3), /* WAV */
2613 DEC_INSTANCE(4, 3), /* ADPCM */
2614 DEC_INSTANCE(4, 2), /* MP3 */
2615 DEC_INSTANCE(0, 0), /* Real Audio */
2616 DEC_INSTANCE(4, 2), /* WMA */
2617 DEC_INSTANCE(3, 2), /* AAC */
2618 DEC_INSTANCE(0, 0), /* Reserved */
2619 DEC_INSTANCE(0, 0), /* MIDI */
2620 DEC_INSTANCE(4, 3), /* YADPCM */
2621 DEC_INSTANCE(4, 3), /* QCELP */
2622 DEC_INSTANCE(4, 3), /* AMRNB */
2623 DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
2624 DEC_INSTANCE(4, 3), /* EVRC */
2625 DEC_INSTANCE(1, 1), /* WMAPRO */
2626 },
2627 /* Turbo Mode */
2628 {
2629 DEC_INSTANCE(4, 3), /* WAV */
2630 DEC_INSTANCE(4, 3), /* ADPCM */
2631 DEC_INSTANCE(4, 3), /* MP3 */
2632 DEC_INSTANCE(0, 0), /* Real Audio */
2633 DEC_INSTANCE(4, 3), /* WMA */
2634 DEC_INSTANCE(4, 3), /* AAC */
2635 DEC_INSTANCE(0, 0), /* Reserved */
2636 DEC_INSTANCE(0, 0), /* MIDI */
2637 DEC_INSTANCE(4, 3), /* YADPCM */
2638 DEC_INSTANCE(4, 3), /* QCELP */
2639 DEC_INSTANCE(4, 3), /* AMRNB */
2640 DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
2641 DEC_INSTANCE(4, 3), /* EVRC */
2642 DEC_INSTANCE(1, 2), /* WMAPRO */
2643 },
2644};
2645
2646static struct msm_adspdec_database msm_device_adspdec_database = {
2647 .num_dec = ARRAY_SIZE(dec_info_list),
2648 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
2649 ARRAY_SIZE(dec_info_list)),
2650 .dec_concurrency_table = dec_concurrency_table,
2651 .dec_info_list = dec_info_list,
2652 .dec_instance_list = &dec_instance_list[0][0],
2653};
2654
2655static struct platform_device msm_device_adspdec = {
2656 .name = "msm_adspdec",
2657 .id = -1,
2658 .dev = {
2659 .platform_data = &msm_device_adspdec_database
2660 },
2661};
2662
2663static struct resource smc91x_resources[] = {
2664 [0] = {
2665 .start = 0x8A000300,
2666 .end = 0x8A0003ff,
2667 .flags = IORESOURCE_MEM,
2668 },
2669 [1] = {
2670 .start = MSM_GPIO_TO_INT(156),
2671 .end = MSM_GPIO_TO_INT(156),
2672 .flags = IORESOURCE_IRQ,
2673 },
2674};
2675
2676static struct platform_device smc91x_device = {
2677 .name = "smc91x",
2678 .id = 0,
2679 .num_resources = ARRAY_SIZE(smc91x_resources),
2680 .resource = smc91x_resources,
2681};
2682
2683static struct smsc911x_platform_config smsc911x_config = {
2684 .phy_interface = PHY_INTERFACE_MODE_MII,
2685 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
2686 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
2687 .flags = SMSC911X_USE_32BIT,
2688};
2689
2690static struct resource smsc911x_resources[] = {
2691 [0] = {
2692 .start = 0x8D000000,
2693 .end = 0x8D000100,
2694 .flags = IORESOURCE_MEM,
2695 },
2696 [1] = {
2697 .start = MSM_GPIO_TO_INT(88),
2698 .end = MSM_GPIO_TO_INT(88),
2699 .flags = IORESOURCE_IRQ,
2700 },
2701};
2702
2703static struct platform_device smsc911x_device = {
2704 .name = "smsc911x",
2705 .id = -1,
2706 .num_resources = ARRAY_SIZE(smsc911x_resources),
2707 .resource = smsc911x_resources,
2708 .dev = {
2709 .platform_data = &smsc911x_config,
2710 },
2711};
2712
2713static struct msm_gpio smsc911x_gpios[] = {
2714 { GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" },
2715 { GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" },
2716 { GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" },
2717 { GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" },
2718 { GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" },
2719 { GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" },
2720 { GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" },
2721 { GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" },
2722};
2723
2724static void msm7x30_cfg_smsc911x(void)
2725{
2726 int rc;
2727
2728 rc = msm_gpios_request_enable(smsc911x_gpios,
2729 ARRAY_SIZE(smsc911x_gpios));
2730 if (rc)
2731 pr_err("%s: unable to enable gpios\n", __func__);
2732}
2733
2734#ifdef CONFIG_USB_G_ANDROID
2735static struct android_usb_platform_data android_usb_pdata = {
2736 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2737};
2738
2739static struct platform_device android_usb_device = {
2740 .name = "android_usb",
2741 .id = -1,
2742 .dev = {
2743 .platform_data = &android_usb_pdata,
2744 },
2745};
2746#endif
2747
2748static struct msm_gpio optnav_config_data[] = {
2749 { GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA),
2750 "optnav_chip_select" },
2751};
2752
2753static void __iomem *virtual_optnav;
2754
2755static int optnav_gpio_setup(void)
2756{
2757 int rc = -ENODEV;
2758 rc = msm_gpios_request_enable(optnav_config_data,
2759 ARRAY_SIZE(optnav_config_data));
2760
2761 /* Configure the FPGA for GPIOs */
2762 virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4);
2763 if (!virtual_optnav) {
2764 pr_err("%s:Could not ioremap region\n", __func__);
2765 return -ENOMEM;
2766 }
2767 /*
2768 * Configure the FPGA to set GPIO 19 as
2769 * normal, active(enabled), output(MSM to SURF)
2770 */
2771 writew(0x311E, virtual_optnav);
2772 return rc;
2773}
2774
2775static void optnav_gpio_release(void)
2776{
2777 msm_gpios_disable_free(optnav_config_data,
2778 ARRAY_SIZE(optnav_config_data));
2779 iounmap(virtual_optnav);
2780}
2781
2782static struct vreg *vreg_gp7;
2783static struct vreg *vreg_gp4;
2784static struct vreg *vreg_gp9;
2785static struct vreg *vreg_usb3_3;
2786
2787static int optnav_enable(void)
2788{
2789 int rc;
2790 /*
2791 * Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
2792 * for I2C communication with keyboard.
2793 */
2794 vreg_gp7 = vreg_get(NULL, "gp7");
2795 rc = vreg_set_level(vreg_gp7, 1800);
2796 if (rc) {
2797 pr_err("%s: vreg_set_level failed \n", __func__);
2798 goto fail_vreg_gp7;
2799 }
2800
2801 rc = vreg_enable(vreg_gp7);
2802 if (rc) {
2803 pr_err("%s: vreg_enable failed \n", __func__);
2804 goto fail_vreg_gp7;
2805 }
2806
2807 vreg_gp4 = vreg_get(NULL, "gp4");
2808 rc = vreg_set_level(vreg_gp4, 2600);
2809 if (rc) {
2810 pr_err("%s: vreg_set_level failed \n", __func__);
2811 goto fail_vreg_gp4;
2812 }
2813
2814 rc = vreg_enable(vreg_gp4);
2815 if (rc) {
2816 pr_err("%s: vreg_enable failed \n", __func__);
2817 goto fail_vreg_gp4;
2818 }
2819
2820 vreg_gp9 = vreg_get(NULL, "gp9");
2821 rc = vreg_set_level(vreg_gp9, 1800);
2822 if (rc) {
2823 pr_err("%s: vreg_set_level failed \n", __func__);
2824 goto fail_vreg_gp9;
2825 }
2826
2827 rc = vreg_enable(vreg_gp9);
2828 if (rc) {
2829 pr_err("%s: vreg_enable failed \n", __func__);
2830 goto fail_vreg_gp9;
2831 }
2832
2833 vreg_usb3_3 = vreg_get(NULL, "usb");
2834 rc = vreg_set_level(vreg_usb3_3, 3300);
2835 if (rc) {
2836 pr_err("%s: vreg_set_level failed \n", __func__);
2837 goto fail_vreg_3_3;
2838 }
2839
2840 rc = vreg_enable(vreg_usb3_3);
2841 if (rc) {
2842 pr_err("%s: vreg_enable failed \n", __func__);
2843 goto fail_vreg_3_3;
2844 }
2845
2846 /* Enable the chip select GPIO */
2847 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2848 gpio_set_value(OPTNAV_CHIP_SELECT, 0);
2849
2850 return 0;
2851
2852fail_vreg_3_3:
2853 vreg_disable(vreg_gp9);
2854fail_vreg_gp9:
2855 vreg_disable(vreg_gp4);
2856fail_vreg_gp4:
2857 vreg_disable(vreg_gp7);
2858fail_vreg_gp7:
2859 return rc;
2860}
2861
2862static void optnav_disable(void)
2863{
2864 vreg_disable(vreg_usb3_3);
2865 vreg_disable(vreg_gp9);
2866 vreg_disable(vreg_gp4);
2867 vreg_disable(vreg_gp7);
2868
2869 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2870}
2871
2872static struct ofn_atlab_platform_data optnav_data = {
2873 .gpio_setup = optnav_gpio_setup,
2874 .gpio_release = optnav_gpio_release,
2875 .optnav_on = optnav_enable,
2876 .optnav_off = optnav_disable,
2877 .rotate_xy = 0,
2878 .function1 = {
2879 .no_motion1_en = true,
2880 .touch_sensor_en = true,
2881 .ofn_en = true,
2882 .clock_select_khz = 1500,
2883 .cpi_selection = 1200,
2884 },
2885 .function2 = {
2886 .invert_y = false,
2887 .invert_x = true,
2888 .swap_x_y = false,
2889 .hold_a_b_en = true,
2890 .motion_filter_en = true,
2891 },
2892};
2893
2894static int hdmi_comm_power(int on, int show);
2895static int hdmi_init_irq(void);
2896static int hdmi_enable_5v(int on);
2897static int hdmi_core_power(int on, int show);
2898static int hdmi_cec_power(int on);
2899static bool hdmi_check_hdcp_hw_support(void);
2900
2901static struct msm_hdmi_platform_data adv7520_hdmi_data = {
2902 .irq = MSM_GPIO_TO_INT(18),
2903 .comm_power = hdmi_comm_power,
2904 .init_irq = hdmi_init_irq,
2905 .enable_5v = hdmi_enable_5v,
2906 .core_power = hdmi_core_power,
2907 .cec_power = hdmi_cec_power,
2908 .check_hdcp_hw_support = hdmi_check_hdcp_hw_support,
2909};
2910
2911#ifdef CONFIG_BOSCH_BMA150
2912static struct vreg *vreg_gp6;
2913static int sensors_ldo_enable(void)
2914{
2915 int rc;
2916
2917 /*
2918 * Enable the VREGs L8(gp7), L15(gp6)
2919 * for I2C communication with sensors.
2920 */
2921 pr_info("sensors_ldo_enable called!!\n");
2922 vreg_gp7 = vreg_get(NULL, "gp7");
2923 if (IS_ERR(vreg_gp7)) {
2924 pr_err("%s: vreg_get gp7 failed\n", __func__);
2925 rc = PTR_ERR(vreg_gp7);
2926 goto fail_gp7_get;
2927 }
2928
2929 rc = vreg_set_level(vreg_gp7, 1800);
2930 if (rc) {
2931 pr_err("%s: vreg_set_level gp7 failed\n", __func__);
2932 goto fail_gp7_level;
2933 }
2934
2935 rc = vreg_enable(vreg_gp7);
2936 if (rc) {
2937 pr_err("%s: vreg_enable gp7 failed\n", __func__);
2938 goto fail_gp7_level;
2939 }
2940
2941 vreg_gp6 = vreg_get(NULL, "gp6");
2942 if (IS_ERR(vreg_gp6)) {
2943 pr_err("%s: vreg_get gp6 failed\n", __func__);
2944 rc = PTR_ERR(vreg_gp6);
2945 goto fail_gp6_get;
2946 }
2947
2948 rc = vreg_set_level(vreg_gp6, 3050);
2949 if (rc) {
2950 pr_err("%s: vreg_set_level gp6 failed\n", __func__);
2951 goto fail_gp6_level;
2952 }
2953
2954 rc = vreg_enable(vreg_gp6);
2955 if (rc) {
2956 pr_err("%s: vreg_enable gp6 failed\n", __func__);
2957 goto fail_gp6_level;
2958 }
2959
2960 return 0;
2961
2962fail_gp6_level:
2963 vreg_put(vreg_gp6);
2964fail_gp6_get:
2965 vreg_disable(vreg_gp7);
2966fail_gp7_level:
2967 vreg_put(vreg_gp7);
2968fail_gp7_get:
2969 return rc;
2970}
2971
2972static void sensors_ldo_disable(void)
2973{
2974 pr_info("sensors_ldo_disable called!!\n");
2975 vreg_disable(vreg_gp6);
2976 vreg_put(vreg_gp6);
2977 vreg_disable(vreg_gp7);
2978 vreg_put(vreg_gp7);
2979}
2980static struct bma150_platform_data bma150_data = {
2981 .power_on = sensors_ldo_enable,
2982 .power_off = sensors_ldo_disable,
2983};
2984
2985static struct i2c_board_info bma150_board_info[] __initdata = {
2986 {
2987 I2C_BOARD_INFO("bma150", 0x38),
2988 .flags = I2C_CLIENT_WAKE,
2989 .irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
2990 .platform_data = &bma150_data,
2991 },
2992};
2993#endif
2994
2995static struct i2c_board_info msm_i2c_board_info[] = {
2996 {
2997 I2C_BOARD_INFO("m33c01", OPTNAV_I2C_SLAVE_ADDR),
2998 .irq = MSM_GPIO_TO_INT(OPTNAV_IRQ),
2999 .platform_data = &optnav_data,
3000 },
3001 {
3002 I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR),
3003 .platform_data = &adv7520_hdmi_data,
3004 },
3005};
3006
3007static struct i2c_board_info msm_marimba_board_info[] = {
3008 {
3009 I2C_BOARD_INFO("marimba", 0xc),
3010 .platform_data = &marimba_pdata,
3011 }
3012};
3013
3014
3015static struct msm_handset_platform_data hs_platform_data = {
3016 .hs_name = "7k_handset",
3017 .pwr_key_delay_ms = 500, /* 0 will disable end key */
3018};
3019
3020static struct platform_device hs_device = {
3021 .name = "msm-handset",
3022 .id = -1,
3023 .dev = {
3024 .platform_data = &hs_platform_data,
3025 },
3026};
3027
3028static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
3029 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
3030 .idle_supported = 1,
3031 .suspend_supported = 1,
3032 .idle_enabled = 1,
3033 .suspend_enabled = 1,
3034 .latency = 8594,
3035 .residency = 23740,
3036 },
3037 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
3038 .idle_supported = 1,
3039 .suspend_supported = 1,
3040 .idle_enabled = 1,
3041 .suspend_enabled = 1,
3042 .latency = 4594,
3043 .residency = 23740,
3044 },
3045 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE] = {
3046#ifdef CONFIG_MSM_STANDALONE_POWER_COLLAPSE
3047 .idle_supported = 1,
3048 .suspend_supported = 1,
3049 .idle_enabled = 1,
3050 .suspend_enabled = 0,
3051#else /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3052 .idle_supported = 0,
3053 .suspend_supported = 0,
3054 .idle_enabled = 0,
3055 .suspend_enabled = 0,
3056#endif /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3057 .latency = 500,
3058 .residency = 6000,
3059 },
3060 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
3061 .idle_supported = 1,
3062 .suspend_supported = 1,
3063 .idle_enabled = 0,
3064 .suspend_enabled = 1,
3065 .latency = 443,
3066 .residency = 1098,
3067 },
3068 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
3069 .idle_supported = 1,
3070 .suspend_supported = 1,
3071 .idle_enabled = 1,
3072 .suspend_enabled = 1,
3073 .latency = 2,
3074 .residency = 0,
3075 },
3076};
3077
3078static struct resource qsd_spi_resources[] = {
3079 {
3080 .name = "spi_irq_in",
3081 .start = INT_SPI_INPUT,
3082 .end = INT_SPI_INPUT,
3083 .flags = IORESOURCE_IRQ,
3084 },
3085 {
3086 .name = "spi_irq_out",
3087 .start = INT_SPI_OUTPUT,
3088 .end = INT_SPI_OUTPUT,
3089 .flags = IORESOURCE_IRQ,
3090 },
3091 {
3092 .name = "spi_irq_err",
3093 .start = INT_SPI_ERROR,
3094 .end = INT_SPI_ERROR,
3095 .flags = IORESOURCE_IRQ,
3096 },
3097 {
3098 .name = "spi_base",
3099 .start = 0xA8000000,
3100 .end = 0xA8000000 + SZ_4K - 1,
3101 .flags = IORESOURCE_MEM,
3102 },
3103 {
3104 .name = "spidm_channels",
3105 .flags = IORESOURCE_DMA,
3106 },
3107 {
3108 .name = "spidm_crci",
3109 .flags = IORESOURCE_DMA,
3110 },
3111};
3112
3113#define AMDH0_BASE_PHYS 0xAC200000
3114#define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
3115static int msm_qsd_spi_dma_config(void)
3116{
3117 void __iomem *ct_adm_base = 0;
3118 u32 spi_mux = 0;
3119 int ret = 0;
3120
3121 ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
3122 if (!ct_adm_base) {
3123 pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
3124 return -ENOMEM;
3125 }
3126
3127 spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
3128
3129 qsd_spi_resources[4].start = DMOV_USB_CHAN;
3130 qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
3131
3132 switch (spi_mux) {
3133 case (1):
3134 qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
3135 qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
3136 break;
3137 case (2):
3138 qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
3139 qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
3140 break;
3141 case (3):
3142 qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
3143 qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
3144 break;
3145 default:
3146 ret = -ENOENT;
3147 }
3148
3149 iounmap(ct_adm_base);
3150
3151 return ret;
3152}
3153
3154static struct platform_device qsd_device_spi = {
3155 .name = "spi_qsd",
3156 .id = 0,
3157 .num_resources = ARRAY_SIZE(qsd_spi_resources),
3158 .resource = qsd_spi_resources,
3159};
3160
3161#ifdef CONFIG_SPI_QSD
3162static struct spi_board_info lcdc_sharp_spi_board_info[] __initdata = {
3163 {
3164 .modalias = "lcdc_sharp_ls038y7dx01",
3165 .mode = SPI_MODE_1,
3166 .bus_num = 0,
3167 .chip_select = 0,
3168 .max_speed_hz = 26331429,
3169 }
3170};
3171static struct spi_board_info lcdc_toshiba_spi_board_info[] __initdata = {
3172 {
3173 .modalias = "lcdc_toshiba_ltm030dd40",
3174 .mode = SPI_MODE_3|SPI_CS_HIGH,
3175 .bus_num = 0,
3176 .chip_select = 0,
3177 .max_speed_hz = 9963243,
3178 }
3179};
3180#endif
3181
3182static struct msm_gpio qsd_spi_gpio_config_data[] = {
3183 { GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3184 { GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3185 { GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" },
3186 { GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3187};
3188
3189static int msm_qsd_spi_gpio_config(void)
3190{
3191 return msm_gpios_request_enable(qsd_spi_gpio_config_data,
3192 ARRAY_SIZE(qsd_spi_gpio_config_data));
3193}
3194
3195static void msm_qsd_spi_gpio_release(void)
3196{
3197 msm_gpios_disable_free(qsd_spi_gpio_config_data,
3198 ARRAY_SIZE(qsd_spi_gpio_config_data));
3199}
3200
3201static struct msm_spi_platform_data qsd_spi_pdata = {
3202 .max_clock_speed = 26331429,
3203 .gpio_config = msm_qsd_spi_gpio_config,
3204 .gpio_release = msm_qsd_spi_gpio_release,
3205 .dma_config = msm_qsd_spi_dma_config,
3206};
3207
3208static void __init msm_qsd_spi_init(void)
3209{
3210 qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
3211}
3212
3213#ifdef CONFIG_USB_EHCI_MSM_72K
3214static void msm_hsusb_vbus_power(unsigned phy_info, int on)
3215{
3216 int rc;
3217 static int vbus_is_on;
3218 struct pm8058_gpio usb_vbus = {
3219 .direction = PM_GPIO_DIR_OUT,
3220 .pull = PM_GPIO_PULL_NO,
3221 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3222 .output_value = 1,
3223 .vin_sel = 2,
3224 .out_strength = PM_GPIO_STRENGTH_MED,
3225 .function = PM_GPIO_FUNC_NORMAL,
3226 .inv_int_pol = 0,
3227 };
3228
3229 /* If VBUS is already on (or off), do nothing. */
3230 if (unlikely(on == vbus_is_on))
3231 return;
3232
3233 if (on) {
3234 rc = pm8058_gpio_config(36, &usb_vbus);
3235 if (rc) {
3236 pr_err("%s PMIC GPIO 36 write failed\n", __func__);
3237 return;
3238 }
3239 } else {
3240 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(36), 0);
3241 }
3242
3243 vbus_is_on = on;
3244}
3245
3246static struct msm_usb_host_platform_data msm_usb_host_pdata = {
3247 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
3248 .vbus_power = msm_hsusb_vbus_power,
3249 .power_budget = 180,
3250};
3251#endif
3252
3253#ifdef CONFIG_USB_MSM_OTG_72K
3254static int hsusb_rpc_connect(int connect)
3255{
3256 if (connect)
3257 return msm_hsusb_rpc_connect();
3258 else
3259 return msm_hsusb_rpc_close();
3260}
3261#endif
3262
3263#ifdef CONFIG_USB_MSM_OTG_72K
3264static struct vreg *vreg_3p3;
3265static int msm_hsusb_ldo_init(int init)
3266{
3267 uint32_t version = 0;
3268 int def_vol = 3400;
3269
3270 version = socinfo_get_version();
3271
3272 if (SOCINFO_VERSION_MAJOR(version) >= 2 &&
3273 SOCINFO_VERSION_MINOR(version) >= 1) {
3274 def_vol = 3075;
3275 pr_debug("%s: default voltage:%d\n", __func__, def_vol);
3276 }
3277
3278 if (init) {
3279 vreg_3p3 = vreg_get(NULL, "usb");
3280 if (IS_ERR(vreg_3p3))
3281 return PTR_ERR(vreg_3p3);
3282 vreg_set_level(vreg_3p3, def_vol);
3283 } else
3284 vreg_put(vreg_3p3);
3285
3286 return 0;
3287}
3288
3289static int msm_hsusb_ldo_enable(int enable)
3290{
3291 static int ldo_status;
3292
3293 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3294 return -ENODEV;
3295
3296 if (ldo_status == enable)
3297 return 0;
3298
3299 ldo_status = enable;
3300
3301 if (enable)
3302 return vreg_enable(vreg_3p3);
3303
3304 return vreg_disable(vreg_3p3);
3305}
3306
3307static int msm_hsusb_ldo_set_voltage(int mV)
3308{
3309 static int cur_voltage = 3400;
3310
3311 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3312 return -ENODEV;
3313
3314 if (cur_voltage == mV)
3315 return 0;
3316
3317 cur_voltage = mV;
3318
3319 pr_debug("%s: (%d)\n", __func__, mV);
3320
3321 return vreg_set_level(vreg_3p3, mV);
3322}
3323#endif
3324
3325#ifndef CONFIG_USB_EHCI_MSM_72K
3326static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init);
3327#endif
3328static struct msm_otg_platform_data msm_otg_pdata = {
3329 .rpc_connect = hsusb_rpc_connect,
3330
3331#ifndef CONFIG_USB_EHCI_MSM_72K
3332 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
3333#else
3334 .vbus_power = msm_hsusb_vbus_power,
3335#endif
3336 .core_clk = 1,
3337 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
3338 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
3339 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
3340 .se1_gating = SE1_GATING_DISABLE,
3341 .chg_vbus_draw = hsusb_chg_vbus_draw,
3342 .chg_connected = hsusb_chg_connected,
3343 .chg_init = hsusb_chg_init,
3344 .ldo_enable = msm_hsusb_ldo_enable,
3345 .ldo_init = msm_hsusb_ldo_init,
3346 .ldo_set_voltage = msm_hsusb_ldo_set_voltage,
3347};
3348
3349#ifdef CONFIG_USB_GADGET
3350static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
3351 .is_phy_status_timer_on = 1,
3352};
3353#endif
3354#ifndef CONFIG_USB_EHCI_MSM_72K
3355typedef void (*notify_vbus_state) (int);
3356notify_vbus_state notify_vbus_state_func_ptr;
3357int vbus_on_irq;
3358static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
3359{
3360 pr_info("%s: vbus notification from pmic\n", __func__);
3361
3362 (*notify_vbus_state_func_ptr) (1);
3363
3364 return IRQ_HANDLED;
3365}
3366static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
3367{
3368 int ret;
3369
3370 if (init) {
3371 if (!callback)
3372 return -ENODEV;
3373
3374 notify_vbus_state_func_ptr = callback;
3375 vbus_on_irq = platform_get_irq_byname(&msm_device_otg,
3376 "vbus_on");
3377 if (vbus_on_irq <= 0) {
3378 pr_err("%s: unable to get vbus on irq\n", __func__);
3379 return -ENODEV;
3380 }
3381
3382 ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq,
3383 IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
3384 if (ret < 0) {
3385 pr_info("%s: request_irq for vbus_on"
3386 "interrupt failed\n", __func__);
3387 return ret;
3388 }
3389 msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
3390 return 0;
3391 } else {
3392 free_irq(vbus_on_irq, 0);
3393 notify_vbus_state_func_ptr = NULL;
3394 return 0;
3395 }
3396}
3397#endif
3398
3399static struct android_pmem_platform_data android_pmem_pdata = {
3400 .name = "pmem",
3401 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
3402 .cached = 1,
3403 .memory_type = MEMTYPE_EBI0,
3404};
3405
3406static struct platform_device android_pmem_device = {
3407 .name = "android_pmem",
3408 .id = 0,
3409 .dev = { .platform_data = &android_pmem_pdata },
3410};
3411
3412#ifndef CONFIG_SPI_QSD
3413static int lcdc_gpio_array_num[] = {
3414 45, /* spi_clk */
3415 46, /* spi_cs */
3416 47, /* spi_mosi */
3417 48, /* spi_miso */
3418 };
3419
3420static struct msm_gpio lcdc_gpio_config_data[] = {
3421 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3422 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3423 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
3424 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3425};
3426
3427static void lcdc_config_gpios(int enable)
3428{
3429 if (enable) {
3430 msm_gpios_request_enable(lcdc_gpio_config_data,
3431 ARRAY_SIZE(
3432 lcdc_gpio_config_data));
3433 } else
3434 msm_gpios_disable_free(lcdc_gpio_config_data,
3435 ARRAY_SIZE(
3436 lcdc_gpio_config_data));
3437}
3438#endif
3439
3440static struct msm_panel_common_pdata lcdc_sharp_panel_data = {
3441#ifndef CONFIG_SPI_QSD
3442 .panel_config_gpio = lcdc_config_gpios,
3443 .gpio_num = lcdc_gpio_array_num,
3444#endif
3445 .gpio = 2, /* LPG PMIC_GPIO26 channel number */
3446};
3447
3448static struct platform_device lcdc_sharp_panel_device = {
3449 .name = "lcdc_sharp_wvga",
3450 .id = 0,
3451 .dev = {
3452 .platform_data = &lcdc_sharp_panel_data,
3453 }
3454};
3455
3456static struct msm_gpio dtv_panel_irq_gpios[] = {
3457 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
3458 "hdmi_int" },
3459};
3460
3461static struct msm_gpio dtv_panel_gpios[] = {
3462 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
3463 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
3464 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
3465 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
3466 { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
3467 { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
3468 { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
3469 { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
3470 { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
3471 { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
3472 { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
3473 { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
3474 { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
3475 { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
3476 { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
3477 { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
3478 { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
3479 { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
3480 { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
3481 { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
3482 { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
3483 { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
3484 { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
3485 { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
3486 { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
3487 { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
3488 { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
3489 { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
3490 { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
3491 { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
3492 { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
3493 { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
3494};
3495
3496
3497#ifdef HDMI_RESET
3498static unsigned dtv_reset_gpio =
3499 GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3500#endif
3501
3502static int gpio_set(const char *label, const char *name, int level, int on)
3503{
3504 struct vreg *vreg = vreg_get(NULL, label);
3505 int rc;
3506
3507 if (IS_ERR(vreg)) {
3508 rc = PTR_ERR(vreg);
3509 pr_err("%s: vreg %s get failed (%d)\n",
3510 __func__, name, rc);
3511 return rc;
3512 }
3513
3514 rc = vreg_set_level(vreg, level);
3515 if (rc) {
3516 pr_err("%s: vreg %s set level failed (%d)\n",
3517 __func__, name, rc);
3518 return rc;
3519 }
3520
3521 if (on)
3522 rc = vreg_enable(vreg);
3523 else
3524 rc = vreg_disable(vreg);
3525 if (rc)
3526 pr_err("%s: vreg %s enable failed (%d)\n",
3527 __func__, name, rc);
3528 return rc;
3529}
3530
3531#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
3532/* there is an i2c address conflict between adv7520 and bma150 sensor after
3533 * power up on fluid. As a solution, the default address of adv7520's packet
3534 * memory is changed as soon as possible
3535 */
3536static int __init fluid_i2c_address_fixup(void)
3537{
3538 unsigned char wBuff[16];
3539 unsigned char rBuff[16];
3540 struct i2c_msg msgs[3];
3541 int res;
3542 int rc = -EINVAL;
3543 struct vreg *vreg_ldo8;
3544 struct i2c_adapter *adapter;
3545
3546 if (machine_is_msm7x30_fluid()) {
3547 adapter = i2c_get_adapter(0);
3548 if (!adapter) {
3549 pr_err("%s: invalid i2c adapter\n", __func__);
3550 return PTR_ERR(adapter);
3551 }
3552
3553 /* turn on LDO8 */
3554 vreg_ldo8 = vreg_get(NULL, "gp7");
3555 if (!vreg_ldo8) {
3556 pr_err("%s: VREG L8 get failed\n", __func__);
3557 goto adapter_put;
3558 }
3559
3560 rc = vreg_set_level(vreg_ldo8, 1800);
3561 if (rc) {
3562 pr_err("%s: VREG L8 set failed\n", __func__);
3563 goto ldo8_put;
3564 }
3565
3566 rc = vreg_enable(vreg_ldo8);
3567 if (rc) {
3568 pr_err("%s: VREG L8 enable failed\n", __func__);
3569 goto ldo8_put;
3570 }
3571
3572 /* change packet memory address to 0x74 */
3573 wBuff[0] = 0x45;
3574 wBuff[1] = 0x74;
3575
3576 msgs[0].addr = ADV7520_I2C_ADDR;
3577 msgs[0].flags = 0;
3578 msgs[0].buf = (unsigned char *) wBuff;
3579 msgs[0].len = 2;
3580
3581 res = i2c_transfer(adapter, msgs, 1);
3582 if (res != 1) {
3583 pr_err("%s: error writing adv7520\n", __func__);
3584 goto ldo8_disable;
3585 }
3586
3587 /* powerdown adv7520 using bit 6 */
3588 /* i2c read first */
3589 wBuff[0] = 0x41;
3590
3591 msgs[0].addr = ADV7520_I2C_ADDR;
3592 msgs[0].flags = 0;
3593 msgs[0].buf = (unsigned char *) wBuff;
3594 msgs[0].len = 1;
3595
3596 msgs[1].addr = ADV7520_I2C_ADDR;
3597 msgs[1].flags = I2C_M_RD;
3598 msgs[1].buf = rBuff;
3599 msgs[1].len = 1;
3600 res = i2c_transfer(adapter, msgs, 2);
3601 if (res != 2) {
3602 pr_err("%s: error reading adv7520\n", __func__);
3603 goto ldo8_disable;
3604 }
3605
3606 /* i2c write back */
3607 wBuff[0] = 0x41;
3608 wBuff[1] = rBuff[0] | 0x40;
3609
3610 msgs[0].addr = ADV7520_I2C_ADDR;
3611 msgs[0].flags = 0;
3612 msgs[0].buf = (unsigned char *) wBuff;
3613 msgs[0].len = 2;
3614
3615 res = i2c_transfer(adapter, msgs, 1);
3616 if (res != 1) {
3617 pr_err("%s: error writing adv7520\n", __func__);
3618 goto ldo8_disable;
3619 }
3620
3621 /* for successful fixup, we release the i2c adapter */
3622 /* but leave ldo8 on so that the adv7520 is not repowered */
3623 i2c_put_adapter(adapter);
3624 pr_info("%s: fluid i2c address conflict resolved\n", __func__);
3625 }
3626 return 0;
3627
3628ldo8_disable:
3629 vreg_disable(vreg_ldo8);
3630ldo8_put:
3631 vreg_put(vreg_ldo8);
3632adapter_put:
3633 i2c_put_adapter(adapter);
3634 return rc;
3635}
3636fs_initcall_sync(fluid_i2c_address_fixup);
3637#endif
3638
3639static int hdmi_comm_power(int on, int show)
3640{
3641 int rc = gpio_set("gp7", "LDO8", 1800, on);
3642 if (rc) {
3643 pr_warning("hdmi_comm_power: LDO8 gpio failed: rc=%d\n", rc);
3644 return rc;
3645 }
3646 rc = gpio_set("gp4", "LDO10", 2600, on);
3647 if (rc)
3648 pr_warning("hdmi_comm_power: LDO10 gpio failed: rc=%d\n", rc);
3649 if (show)
3650 pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
3651 return rc;
3652}
3653
3654static int hdmi_init_irq(void)
3655{
3656 int rc = msm_gpios_enable(dtv_panel_irq_gpios,
3657 ARRAY_SIZE(dtv_panel_irq_gpios));
3658 if (rc < 0) {
3659 pr_err("%s: gpio enable failed: %d\n", __func__, rc);
3660 return rc;
3661 }
3662 pr_info("%s\n", __func__);
3663
3664 return 0;
3665}
3666
3667static int hdmi_enable_5v(int on)
3668{
3669 int pmic_gpio_hdmi_5v_en ;
3670
3671 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
3672 machine_is_msm7x30_fluid())
3673 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
3674 else
3675 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
3676
3677 pr_info("%s: %d\n", __func__, on);
3678 if (on) {
3679 int rc;
3680 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
3681 "hdmi_5V_en");
3682 if (rc) {
3683 pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
3684 __func__);
3685 return rc;
3686 }
3687 gpio_set_value_cansleep(
3688 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
3689 } else {
3690 gpio_set_value_cansleep(
3691 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
3692 gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
3693 }
3694 return 0;
3695}
3696
3697static int hdmi_core_power(int on, int show)
3698{
3699 if (show)
3700 pr_info("%s: %d <LDO8>\n", __func__, on);
3701 return gpio_set("gp7", "LDO8", 1800, on);
3702}
3703
3704static int hdmi_cec_power(int on)
3705{
3706 pr_info("%s: %d <LDO17>\n", __func__, on);
3707 return gpio_set("gp11", "LDO17", 2600, on);
3708}
3709
3710static bool hdmi_check_hdcp_hw_support(void)
3711{
3712 if (machine_is_msm7x30_fluid())
3713 return false;
3714 else
3715 return true;
3716}
3717
3718static int dtv_panel_power(int on)
3719{
3720 int flag_on = !!on;
3721 static int dtv_power_save_on;
3722 int rc;
3723
3724 if (dtv_power_save_on == flag_on)
3725 return 0;
3726
3727 dtv_power_save_on = flag_on;
3728 pr_info("%s: %d\n", __func__, on);
3729
3730#ifdef HDMI_RESET
3731 if (on) {
3732 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
3733 rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
3734 if (rc) {
3735 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
3736 __func__, dtv_reset_gpio, rc);
3737 return rc;
3738 }
3739
3740 /* bring reset line low to hold reset*/
3741 gpio_set_value(37, 0);
3742 }
3743#endif
3744
3745 if (on) {
3746 rc = msm_gpios_enable(dtv_panel_gpios,
3747 ARRAY_SIZE(dtv_panel_gpios));
3748 if (rc < 0) {
3749 printk(KERN_ERR "%s: gpio enable failed: %d\n",
3750 __func__, rc);
3751 return rc;
3752 }
3753 } else {
3754 rc = msm_gpios_disable(dtv_panel_gpios,
3755 ARRAY_SIZE(dtv_panel_gpios));
3756 if (rc < 0) {
3757 printk(KERN_ERR "%s: gpio disable failed: %d\n",
3758 __func__, rc);
3759 return rc;
3760 }
3761 }
3762
3763 mdelay(5); /* ensure power is stable */
3764
3765#ifdef HDMI_RESET
3766 if (on) {
3767 gpio_set_value(37, 1); /* bring reset line high */
3768 mdelay(10); /* 10 msec before IO can be accessed */
3769 }
3770#endif
3771
3772 return rc;
3773}
3774
3775static struct lcdc_platform_data dtv_pdata = {
3776 .lcdc_power_save = dtv_panel_power,
3777};
3778
3779static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3780 .inject_rx_on_wakeup = 1,
3781 .rx_to_inject = 0xFD,
3782};
3783
3784static struct resource msm_fb_resources[] = {
3785 {
3786 .flags = IORESOURCE_DMA,
3787 }
3788};
3789
3790static int msm_fb_detect_panel(const char *name)
3791{
3792 if (machine_is_msm7x30_fluid()) {
3793 if (!strcmp(name, "lcdc_sharp_wvga_pt"))
3794 return 0;
3795 } else {
3796 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
3797 return -EPERM;
3798 else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20))
3799 return 0;
3800 else if (!strcmp(name, "mddi_orise"))
3801 return -EPERM;
3802 else if (!strcmp(name, "mddi_quickvx"))
3803 return -EPERM;
3804 }
3805 return -ENODEV;
3806}
3807
3808static struct msm_fb_platform_data msm_fb_pdata = {
3809 .detect_client = msm_fb_detect_panel,
3810 .mddi_prescan = 1,
3811};
3812
3813static struct platform_device msm_fb_device = {
3814 .name = "msm_fb",
3815 .id = 0,
3816 .num_resources = ARRAY_SIZE(msm_fb_resources),
3817 .resource = msm_fb_resources,
3818 .dev = {
3819 .platform_data = &msm_fb_pdata,
3820 }
3821};
3822
3823static struct platform_device msm_migrate_pages_device = {
3824 .name = "msm_migrate_pages",
3825 .id = -1,
3826};
3827
3828static struct android_pmem_platform_data android_pmem_adsp_pdata = {
3829 .name = "pmem_adsp",
3830 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
3831 .cached = 0,
3832 .memory_type = MEMTYPE_EBI0,
3833};
3834
3835static struct android_pmem_platform_data android_pmem_audio_pdata = {
3836 .name = "pmem_audio",
3837 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
3838 .cached = 0,
3839 .memory_type = MEMTYPE_EBI0,
3840};
3841
3842static struct platform_device android_pmem_adsp_device = {
3843 .name = "android_pmem",
3844 .id = 2,
3845 .dev = { .platform_data = &android_pmem_adsp_pdata },
3846};
3847
3848static struct platform_device android_pmem_audio_device = {
3849 .name = "android_pmem",
3850 .id = 4,
3851 .dev = { .platform_data = &android_pmem_audio_pdata },
3852};
3853
3854#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3855 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
3856 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3857 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3858
3859#define QCE_SIZE 0x10000
3860#define QCE_0_BASE 0xA8400000
3861
3862#define QCE_HW_KEY_SUPPORT 1
3863#define QCE_SHA_HMAC_SUPPORT 0
3864#define QCE_SHARE_CE_RESOURCE 0
3865#define QCE_CE_SHARED 0
3866
3867static struct resource qcrypto_resources[] = {
3868 [0] = {
3869 .start = QCE_0_BASE,
3870 .end = QCE_0_BASE + QCE_SIZE - 1,
3871 .flags = IORESOURCE_MEM,
3872 },
3873 [1] = {
3874 .name = "crypto_channels",
3875 .start = DMOV_CE_IN_CHAN,
3876 .end = DMOV_CE_OUT_CHAN,
3877 .flags = IORESOURCE_DMA,
3878 },
3879 [2] = {
3880 .name = "crypto_crci_in",
3881 .start = DMOV_CE_IN_CRCI,
3882 .end = DMOV_CE_IN_CRCI,
3883 .flags = IORESOURCE_DMA,
3884 },
3885 [3] = {
3886 .name = "crypto_crci_out",
3887 .start = DMOV_CE_OUT_CRCI,
3888 .end = DMOV_CE_OUT_CRCI,
3889 .flags = IORESOURCE_DMA,
3890 },
3891 [4] = {
3892 .name = "crypto_crci_hash",
3893 .start = DMOV_CE_HASH_CRCI,
3894 .end = DMOV_CE_HASH_CRCI,
3895 .flags = IORESOURCE_DMA,
3896 },
3897};
3898
3899static struct resource qcedev_resources[] = {
3900 [0] = {
3901 .start = QCE_0_BASE,
3902 .end = QCE_0_BASE + QCE_SIZE - 1,
3903 .flags = IORESOURCE_MEM,
3904 },
3905 [1] = {
3906 .name = "crypto_channels",
3907 .start = DMOV_CE_IN_CHAN,
3908 .end = DMOV_CE_OUT_CHAN,
3909 .flags = IORESOURCE_DMA,
3910 },
3911 [2] = {
3912 .name = "crypto_crci_in",
3913 .start = DMOV_CE_IN_CRCI,
3914 .end = DMOV_CE_IN_CRCI,
3915 .flags = IORESOURCE_DMA,
3916 },
3917 [3] = {
3918 .name = "crypto_crci_out",
3919 .start = DMOV_CE_OUT_CRCI,
3920 .end = DMOV_CE_OUT_CRCI,
3921 .flags = IORESOURCE_DMA,
3922 },
3923 [4] = {
3924 .name = "crypto_crci_hash",
3925 .start = DMOV_CE_HASH_CRCI,
3926 .end = DMOV_CE_HASH_CRCI,
3927 .flags = IORESOURCE_DMA,
3928 },
3929};
3930
3931#endif
3932
3933#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3934 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
3935
3936static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
3937 .ce_shared = QCE_CE_SHARED,
3938 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
3939 .hw_key_support = QCE_HW_KEY_SUPPORT,
3940 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
3941};
3942
3943static struct platform_device qcrypto_device = {
3944 .name = "qcrypto",
3945 .id = 0,
3946 .num_resources = ARRAY_SIZE(qcrypto_resources),
3947 .resource = qcrypto_resources,
3948 .dev = {
3949 .coherent_dma_mask = DMA_BIT_MASK(32),
3950 .platform_data = &qcrypto_ce_hw_suppport,
3951 },
3952};
3953#endif
3954
3955#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3956 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3957
3958static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
3959 .ce_shared = QCE_CE_SHARED,
3960 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
3961 .hw_key_support = QCE_HW_KEY_SUPPORT,
3962 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
3963};
3964static struct platform_device qcedev_device = {
3965 .name = "qce",
3966 .id = 0,
3967 .num_resources = ARRAY_SIZE(qcedev_resources),
3968 .resource = qcedev_resources,
3969 .dev = {
3970 .coherent_dma_mask = DMA_BIT_MASK(32),
3971 .platform_data = &qcedev_ce_hw_suppport,
3972 },
3973};
3974#endif
3975
3976static int mddi_toshiba_pmic_bl(int level)
3977{
3978 int ret = -EPERM;
3979
3980 ret = pmic_set_led_intensity(LED_LCD, level);
3981
3982 if (ret)
3983 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
3984 __func__);
3985 return ret;
3986}
3987
3988static struct msm_panel_common_pdata mddi_toshiba_pdata = {
3989 .pmic_backlight = mddi_toshiba_pmic_bl,
3990};
3991
3992static struct platform_device mddi_toshiba_device = {
3993 .name = "mddi_toshiba",
3994 .id = 0,
3995 .dev = {
3996 .platform_data = &mddi_toshiba_pdata,
3997 }
3998};
3999
4000static unsigned wega_reset_gpio =
4001 GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4002
4003static struct msm_gpio fluid_vee_reset_gpio[] = {
4004 { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
4005};
4006
4007static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1;
4008static unsigned char quickvx_ldo_enabled;
4009
4010static unsigned quickvx_vlp_gpio =
4011 GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4012
4013static struct pm8058_gpio pmic_quickvx_clk_gpio = {
4014 .direction = PM_GPIO_DIR_OUT,
4015 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
4016 .output_value = 1,
4017 .pull = PM_GPIO_PULL_NO,
4018 .vin_sel = PM_GPIO_VIN_S3,
4019 .out_strength = PM_GPIO_STRENGTH_HIGH,
4020 .function = PM_GPIO_FUNC_2,
4021};
4022
4023static int display_common_power(int on)
4024{
4025 int rc = 0, flag_on = !!on;
4026 static int display_common_power_save_on;
4027 struct vreg *vreg_ldo12, *vreg_ldo15 = NULL, *vreg_ldo6;
4028 struct vreg *vreg_ldo20, *vreg_ldo16, *vreg_ldo8 = NULL;
4029
4030 if (display_common_power_save_on == flag_on)
4031 return 0;
4032
4033 display_common_power_save_on = flag_on;
4034
4035 if (on) {
4036 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
4037 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
4038 if (rc) {
4039 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4040 __func__, wega_reset_gpio, rc);
4041 return rc;
4042 }
4043
4044 /* bring reset line low to hold reset*/
4045 gpio_set_value(180, 0);
4046
4047 if (quickvx_mddi_client) {
4048 /* QuickVX chip -- VLP pin -- gpio 97 */
4049 rc = gpio_tlmm_config(quickvx_vlp_gpio,
4050 GPIO_CFG_ENABLE);
4051 if (rc) {
4052 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4053 __func__, quickvx_vlp_gpio, rc);
4054 return rc;
4055 }
4056
4057 /* bring QuickVX VLP line low */
4058 gpio_set_value(97, 0);
4059
4060 rc = pm8058_gpio_config(PMIC_GPIO_QUICKVX_CLK,
4061 &pmic_quickvx_clk_gpio);
4062 if (rc) {
4063 pr_err("%s: pm8058_gpio_config(%#x)=%d\n",
4064 __func__, PMIC_GPIO_QUICKVX_CLK + 1,
4065 rc);
4066 return rc;
4067 }
4068
4069 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4070 PMIC_GPIO_QUICKVX_CLK), 0);
4071 }
4072 }
4073
4074 /* Toshiba WeGA power -- has 3 power source */
4075 /* 1.5V -- LDO20*/
4076 vreg_ldo20 = vreg_get(NULL, "gp13");
4077
4078 if (IS_ERR(vreg_ldo20)) {
4079 rc = PTR_ERR(vreg_ldo20);
4080 pr_err("%s: gp13 vreg get failed (%d)\n",
4081 __func__, rc);
4082 return rc;
4083 }
4084
4085 /* 1.8V -- LDO12 */
4086 vreg_ldo12 = vreg_get(NULL, "gp9");
4087
4088 if (IS_ERR(vreg_ldo12)) {
4089 rc = PTR_ERR(vreg_ldo12);
4090 pr_err("%s: gp9 vreg get failed (%d)\n",
4091 __func__, rc);
4092 return rc;
4093 }
4094
4095 /* 2.6V -- LDO16 */
4096 vreg_ldo16 = vreg_get(NULL, "gp10");
4097
4098 if (IS_ERR(vreg_ldo16)) {
4099 rc = PTR_ERR(vreg_ldo16);
4100 pr_err("%s: gp10 vreg get failed (%d)\n",
4101 __func__, rc);
4102 return rc;
4103 }
4104
4105 /* 3.075V -- LDO6 */
4106 vreg_ldo6 = vreg_get(NULL, "usb");
4107
4108 if (IS_ERR(vreg_ldo6)) {
4109 rc = PTR_ERR(vreg_ldo6);
4110 pr_err("%s: usb vreg get failed (%d)\n",
4111 __func__, rc);
4112 return rc;
4113 }
4114
4115 if (machine_is_msm7x30_fluid()) {
4116 /* 1.8V -- LDO8 */
4117 vreg_ldo8 = vreg_get(NULL, "gp7");
4118
4119 if (IS_ERR(vreg_ldo8)) {
4120 rc = PTR_ERR(vreg_ldo8);
4121 pr_err("%s: gp7 vreg get failed (%d)\n",
4122 __func__, rc);
4123 return rc;
4124 }
4125 } else {
4126 /* lcd panel power */
4127 /* 3.1V -- LDO15 */
4128 vreg_ldo15 = vreg_get(NULL, "gp6");
4129
4130 if (IS_ERR(vreg_ldo15)) {
4131 rc = PTR_ERR(vreg_ldo15);
4132 pr_err("%s: gp6 vreg get failed (%d)\n",
4133 __func__, rc);
4134 return rc;
4135 }
4136 }
4137
4138 /* For QuickLogic chip, LDO20 requires 1.8V */
4139 /* Toshiba chip requires 1.5V, but can tolerate 1.8V since max is 3V */
4140 if (quickvx_mddi_client)
4141 rc = vreg_set_level(vreg_ldo20, 1800);
4142 else
4143 rc = vreg_set_level(vreg_ldo20, 1500);
4144 if (rc) {
4145 pr_err("%s: vreg LDO20 set level failed (%d)\n",
4146 __func__, rc);
4147 return rc;
4148 }
4149
4150 rc = vreg_set_level(vreg_ldo12, 1800);
4151 if (rc) {
4152 pr_err("%s: vreg LDO12 set level failed (%d)\n",
4153 __func__, rc);
4154 return rc;
4155 }
4156
4157 if (other_mddi_client) {
4158 rc = vreg_set_level(vreg_ldo16, 2600);
4159 if (rc) {
4160 pr_err("%s: vreg LDO16 set level failed (%d)\n",
4161 __func__, rc);
4162 return rc;
4163 }
4164 }
4165
4166 if (quickvx_mddi_client) {
4167 rc = vreg_set_level(vreg_ldo6, 3075);
4168 if (rc) {
4169 pr_err("%s: vreg LDO6 set level failed (%d)\n",
4170 __func__, rc);
4171 return rc;
4172 }
4173 }
4174
4175 if (machine_is_msm7x30_fluid()) {
4176 rc = vreg_set_level(vreg_ldo8, 1800);
4177 if (rc) {
4178 pr_err("%s: vreg LDO8 set level failed (%d)\n",
4179 __func__, rc);
4180 return rc;
4181 }
4182 } else {
4183 rc = vreg_set_level(vreg_ldo15, 3100);
4184 if (rc) {
4185 pr_err("%s: vreg LDO15 set level failed (%d)\n",
4186 __func__, rc);
4187 return rc;
4188 }
4189 }
4190
4191 if (on) {
4192 rc = vreg_enable(vreg_ldo20);
4193 if (rc) {
4194 pr_err("%s: LDO20 vreg enable failed (%d)\n",
4195 __func__, rc);
4196 return rc;
4197 }
4198
4199 rc = vreg_enable(vreg_ldo12);
4200 if (rc) {
4201 pr_err("%s: LDO12 vreg enable failed (%d)\n",
4202 __func__, rc);
4203 return rc;
4204 }
4205
4206 if (other_mddi_client) {
4207 rc = vreg_enable(vreg_ldo16);
4208 if (rc) {
4209 pr_err("%s: LDO16 vreg enable failed (%d)\n",
4210 __func__, rc);
4211 return rc;
4212 }
4213 }
4214
4215 if (quickvx_mddi_client && quickvx_ldo_enabled) {
4216 /* Disable LDO6 during display ON */
4217 rc = vreg_disable(vreg_ldo6);
4218 if (rc) {
4219 pr_err("%s: LDO6 vreg disable failed (%d)\n",
4220 __func__, rc);
4221 return rc;
4222 }
4223 quickvx_ldo_enabled = 0;
4224 }
4225
4226 if (machine_is_msm7x30_fluid()) {
4227 rc = vreg_enable(vreg_ldo8);
4228 if (rc) {
4229 pr_err("%s: LDO8 vreg enable failed (%d)\n",
4230 __func__, rc);
4231 return rc;
4232 }
4233 } else {
4234 rc = vreg_enable(vreg_ldo15);
4235 if (rc) {
4236 pr_err("%s: LDO15 vreg enable failed (%d)\n",
4237 __func__, rc);
4238 return rc;
4239 }
4240 }
4241
4242 mdelay(5); /* ensure power is stable */
4243
4244 if (machine_is_msm7x30_fluid()) {
4245 rc = msm_gpios_request_enable(fluid_vee_reset_gpio,
4246 ARRAY_SIZE(fluid_vee_reset_gpio));
4247 if (rc)
4248 pr_err("%s gpio_request_enable failed rc=%d\n",
4249 __func__, rc);
4250 else {
4251 /* assert vee reset_n */
4252 gpio_set_value(20, 1);
4253 gpio_set_value(20, 0);
4254 mdelay(1);
4255 gpio_set_value(20, 1);
4256 }
4257 }
4258
4259 gpio_set_value(180, 1); /* bring reset line high */
4260 mdelay(10); /* 10 msec before IO can be accessed */
4261
4262 if (quickvx_mddi_client) {
4263 gpio_set_value(97, 1);
4264 msleep(2);
4265 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4266 PMIC_GPIO_QUICKVX_CLK), 1);
4267 msleep(2);
4268 }
4269
4270 rc = pmapp_display_clock_config(1);
4271 if (rc) {
4272 pr_err("%s pmapp_display_clock_config rc=%d\n",
4273 __func__, rc);
4274 return rc;
4275 }
4276
4277 } else {
4278 rc = vreg_disable(vreg_ldo20);
4279 if (rc) {
4280 pr_err("%s: LDO20 vreg disable failed (%d)\n",
4281 __func__, rc);
4282 return rc;
4283 }
4284
4285
4286 if (other_mddi_client) {
4287 rc = vreg_disable(vreg_ldo16);
4288 if (rc) {
4289 pr_err("%s: LDO16 vreg disable failed (%d)\n",
4290 __func__, rc);
4291 return rc;
4292 }
4293 }
4294
4295 if (quickvx_mddi_client && !quickvx_ldo_enabled) {
4296 /* Enable LDO6 during display OFF for
4297 Quicklogic chip to sleep with data retention */
4298 rc = vreg_enable(vreg_ldo6);
4299 if (rc) {
4300 pr_err("%s: LDO6 vreg enable failed (%d)\n",
4301 __func__, rc);
4302 return rc;
4303 }
4304 quickvx_ldo_enabled = 1;
4305 }
4306
4307 gpio_set_value(180, 0); /* bring reset line low */
4308
4309 if (quickvx_mddi_client) {
4310 gpio_set_value(97, 0);
4311 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4312 PMIC_GPIO_QUICKVX_CLK), 0);
4313 }
4314
4315 if (machine_is_msm7x30_fluid()) {
4316 rc = vreg_disable(vreg_ldo8);
4317 if (rc) {
4318 pr_err("%s: LDO8 vreg disable failed (%d)\n",
4319 __func__, rc);
4320 return rc;
4321 }
4322 } else {
4323 rc = vreg_disable(vreg_ldo15);
4324 if (rc) {
4325 pr_err("%s: LDO15 vreg disable failed (%d)\n",
4326 __func__, rc);
4327 return rc;
4328 }
4329 }
4330
4331 mdelay(5); /* ensure power is stable */
4332
4333 rc = vreg_disable(vreg_ldo12);
4334 if (rc) {
4335 pr_err("%s: LDO12 vreg disable failed (%d)\n",
4336 __func__, rc);
4337 return rc;
4338 }
4339
4340 if (machine_is_msm7x30_fluid()) {
4341 msm_gpios_disable_free(fluid_vee_reset_gpio,
4342 ARRAY_SIZE(fluid_vee_reset_gpio));
4343 }
4344
4345 rc = pmapp_display_clock_config(0);
4346 if (rc) {
4347 pr_err("%s pmapp_display_clock_config rc=%d\n",
4348 __func__, rc);
4349 return rc;
4350 }
4351 }
4352
4353 return rc;
4354}
4355
4356static int msm_fb_mddi_sel_clk(u32 *clk_rate)
4357{
4358 *clk_rate *= 2;
4359 return 0;
4360}
4361
4362static int msm_fb_mddi_client_power(u32 client_id)
4363{
4364 struct vreg *vreg_ldo20, *vreg_ldo16;
4365 int rc;
4366
4367 printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
4368 /* Check if it is Quicklogic client */
4369 if (client_id == 0xc5835800) {
4370 printk(KERN_NOTICE "\n Quicklogic MDDI client");
4371 other_mddi_client = 0;
4372 vreg_ldo16 = vreg_get(NULL, "gp10");
4373
4374 if (IS_ERR(vreg_ldo16)) {
4375 rc = PTR_ERR(vreg_ldo16);
4376 pr_err("%s: gp10 vreg get failed (%d)\n",
4377 __func__, rc);
4378 return rc;
4379 }
4380
4381 rc = vreg_disable(vreg_ldo16);
4382 if (rc) {
4383 pr_err("%s: LDO16 vreg enable failed (%d)\n",
4384 __func__, rc);
4385 return rc;
4386 }
4387 } else {
4388 printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
4389 quickvx_mddi_client = 0;
4390 gpio_set_value(97, 0);
4391 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4392 PMIC_GPIO_QUICKVX_CLK), 0);
4393
4394 vreg_ldo20 = vreg_get(NULL, "gp13");
4395
4396 if (IS_ERR(vreg_ldo20)) {
4397 rc = PTR_ERR(vreg_ldo20);
4398 pr_err("%s: gp13 vreg get failed (%d)\n",
4399 __func__, rc);
4400 return rc;
4401 }
4402 rc = vreg_set_level(vreg_ldo20, 1500);
4403 if (rc) {
4404 pr_err("%s: vreg LDO20 set level failed (%d)\n",
4405 __func__, rc);
4406 return rc;
4407 }
4408 }
4409 return 0;
4410}
4411
4412static struct mddi_platform_data mddi_pdata = {
4413 .mddi_power_save = display_common_power,
4414 .mddi_sel_clk = msm_fb_mddi_sel_clk,
4415 .mddi_client_power = msm_fb_mddi_client_power,
4416};
4417
4418int mdp_core_clk_rate_table[] = {
4419 122880000,
4420 122880000,
4421 122880000,
4422 192000000,
4423};
4424
4425static struct msm_panel_common_pdata mdp_pdata = {
4426 .hw_revision_addr = 0xac001270,
4427 .gpio = 30,
4428 .mdp_core_clk_rate = 122880000,
4429 .mdp_core_clk_table = mdp_core_clk_rate_table,
4430 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
4431};
4432
4433static int lcd_panel_spi_gpio_num[] = {
4434 45, /* spi_clk */
4435 46, /* spi_cs */
4436 47, /* spi_mosi */
4437 48, /* spi_miso */
4438 };
4439
4440static struct msm_gpio lcd_panel_gpios[] = {
4441/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
4442 * input. if there is a hardware revision; we should reassign this GPIO to a
4443 * new open line; and removing it will just ensure that this will be missed in
4444 * the future.
4445 { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
4446 */
4447 { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
4448 { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
4449 { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
4450 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4451 { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
4452 { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
4453 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4454#ifndef CONFIG_SPI_QSD
4455 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
4456 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
4457 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
4458 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
4459#endif
4460 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4461 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4462 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4463 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4464 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4465 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4466 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4467 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4468 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4469 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4470 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4471 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4472 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4473 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4474 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4475 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4476 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4477 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4478 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4479 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4480};
4481
4482static struct msm_gpio lcd_sharp_panel_gpios[] = {
4483 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4484 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4485 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4486 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4487 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4488 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4489 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4490 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4491 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4492 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4493 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4494 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4495 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4496 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4497 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4498 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4499 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4500 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4501 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4502 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4503 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4504 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4505};
4506
4507static int lcdc_toshiba_panel_power(int on)
4508{
4509 int rc, i;
4510 struct msm_gpio *gp;
4511
4512 rc = display_common_power(on);
4513 if (rc < 0) {
4514 printk(KERN_ERR "%s display_common_power failed: %d\n",
4515 __func__, rc);
4516 return rc;
4517 }
4518
4519 if (on) {
4520 rc = msm_gpios_enable(lcd_panel_gpios,
4521 ARRAY_SIZE(lcd_panel_gpios));
4522 if (rc < 0) {
4523 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4524 __func__, rc);
4525 }
4526 } else { /* off */
4527 gp = lcd_panel_gpios;
4528 for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
4529 /* ouput low */
4530 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4531 gp++;
4532 }
4533 }
4534
4535 return rc;
4536}
4537
4538static int lcdc_sharp_panel_power(int on)
4539{
4540 int rc, i;
4541 struct msm_gpio *gp;
4542
4543 rc = display_common_power(on);
4544 if (rc < 0) {
4545 printk(KERN_ERR "%s display_common_power failed: %d\n",
4546 __func__, rc);
4547 return rc;
4548 }
4549
4550 if (on) {
4551 rc = msm_gpios_enable(lcd_sharp_panel_gpios,
4552 ARRAY_SIZE(lcd_sharp_panel_gpios));
4553 if (rc < 0) {
4554 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4555 __func__, rc);
4556 }
4557 } else { /* off */
4558 gp = lcd_sharp_panel_gpios;
4559 for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) {
4560 /* ouput low */
4561 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4562 gp++;
4563 }
4564 }
4565
4566 return rc;
4567}
4568
4569static int lcdc_panel_power(int on)
4570{
4571 int flag_on = !!on;
4572 static int lcdc_power_save_on;
4573
4574 if (lcdc_power_save_on == flag_on)
4575 return 0;
4576
4577 lcdc_power_save_on = flag_on;
4578 quickvx_mddi_client = 0;
4579
4580 if (machine_is_msm7x30_fluid())
4581 return lcdc_sharp_panel_power(on);
4582 else
4583 return lcdc_toshiba_panel_power(on);
4584}
4585
4586static struct lcdc_platform_data lcdc_pdata = {
4587 .lcdc_power_save = lcdc_panel_power,
4588};
4589
4590static int atv_dac_power(int on)
4591{
4592 int rc = 0;
4593 struct vreg *vreg_s4, *vreg_ldo9;
4594
4595 vreg_s4 = vreg_get(NULL, "s4");
4596 if (IS_ERR(vreg_s4)) {
4597 rc = PTR_ERR(vreg_s4);
4598 pr_err("%s: s4 vreg get failed (%d)\n",
4599 __func__, rc);
4600 return -1;
4601 }
4602 vreg_ldo9 = vreg_get(NULL, "gp1");
4603 if (IS_ERR(vreg_ldo9)) {
4604 rc = PTR_ERR(vreg_ldo9);
4605 pr_err("%s: ldo9 vreg get failed (%d)\n",
4606 __func__, rc);
4607 return rc;
4608 }
4609
4610 if (on) {
4611 rc = vreg_enable(vreg_s4);
4612 if (rc) {
4613 pr_err("%s: s4 vreg enable failed (%d)\n",
4614 __func__, rc);
4615 return rc;
4616 }
4617 rc = vreg_enable(vreg_ldo9);
4618 if (rc) {
4619 pr_err("%s: ldo9 vreg enable failed (%d)\n",
4620 __func__, rc);
4621 return rc;
4622 }
4623 } else {
4624 rc = vreg_disable(vreg_ldo9);
4625 if (rc) {
4626 pr_err("%s: ldo9 vreg disable failed (%d)\n",
4627 __func__, rc);
4628 return rc;
4629 }
4630 rc = vreg_disable(vreg_s4);
4631 if (rc) {
4632 pr_err("%s: s4 vreg disable failed (%d)\n",
4633 __func__, rc);
4634 return rc;
4635 }
4636 }
4637 return rc;
4638}
4639
4640static struct tvenc_platform_data atv_pdata = {
4641 .poll = 1,
4642 .pm_vid_en = atv_dac_power,
4643};
4644
4645static void __init msm_fb_add_devices(void)
4646{
4647 msm_fb_register_device("mdp", &mdp_pdata);
4648 msm_fb_register_device("pmdh", &mddi_pdata);
4649 msm_fb_register_device("lcdc", &lcdc_pdata);
4650 msm_fb_register_device("dtv", &dtv_pdata);
4651 msm_fb_register_device("tvenc", &atv_pdata);
4652#ifdef CONFIG_FB_MSM_TVOUT
4653 msm_fb_register_device("tvout_device", NULL);
4654#endif
4655}
4656
4657static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
4658 .gpio_num = lcd_panel_spi_gpio_num,
4659};
4660
4661static struct platform_device lcdc_toshiba_panel_device = {
4662 .name = "lcdc_toshiba_wvga",
4663 .id = 0,
4664 .dev = {
4665 .platform_data = &lcdc_toshiba_panel_data,
4666 }
4667};
4668
4669#if defined(CONFIG_MARIMBA_CORE) && \
4670 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4671static struct platform_device msm_bt_power_device = {
4672 .name = "bt_power",
4673 .id = -1
4674};
4675
4676enum {
4677 BT_RFR,
4678 BT_CTS,
4679 BT_RX,
4680 BT_TX,
4681};
4682
4683static struct msm_gpio bt_config_power_on[] = {
4684 { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4685 "UART1DM_RFR" },
4686 { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4687 "UART1DM_CTS" },
4688 { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4689 "UART1DM_Rx" },
4690 { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4691 "UART1DM_Tx" }
4692};
4693
4694static struct msm_gpio bt_config_power_off[] = {
4695 { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4696 "UART1DM_RFR" },
4697 { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4698 "UART1DM_CTS" },
4699 { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4700 "UART1DM_Rx" },
4701 { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4702 "UART1DM_Tx" }
4703};
4704
4705static const char *vregs_bt_marimba_name[] = {
4706 "s3",
4707 "s2",
4708 "gp16",
4709 "wlan"
4710};
4711static struct vreg *vregs_bt_marimba[ARRAY_SIZE(vregs_bt_marimba_name)];
4712
4713static const char *vregs_bt_bahama_name[] = {
4714 "s3",
4715 "usb2",
4716 "s2",
4717 "wlan"
4718};
4719static struct vreg *vregs_bt_bahama[ARRAY_SIZE(vregs_bt_bahama_name)];
4720
4721static u8 bahama_version;
4722
4723static int marimba_bt(int on)
4724{
4725 int rc;
4726 int i;
4727 struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
4728
4729 struct marimba_config_register {
4730 u8 reg;
4731 u8 value;
4732 u8 mask;
4733 };
4734
4735 struct marimba_variant_register {
4736 const size_t size;
4737 const struct marimba_config_register *set;
4738 };
4739
4740 const struct marimba_config_register *p;
4741
4742 u8 version;
4743
4744 const struct marimba_config_register v10_bt_on[] = {
4745 { 0xE5, 0x0B, 0x0F },
4746 { 0x05, 0x02, 0x07 },
4747 { 0x06, 0x88, 0xFF },
4748 { 0xE7, 0x21, 0x21 },
4749 { 0xE3, 0x38, 0xFF },
4750 { 0xE4, 0x06, 0xFF },
4751 };
4752
4753 const struct marimba_config_register v10_bt_off[] = {
4754 { 0xE5, 0x0B, 0x0F },
4755 { 0x05, 0x08, 0x0F },
4756 { 0x06, 0x88, 0xFF },
4757 { 0xE7, 0x00, 0x21 },
4758 { 0xE3, 0x00, 0xFF },
4759 { 0xE4, 0x00, 0xFF },
4760 };
4761
4762 const struct marimba_config_register v201_bt_on[] = {
4763 { 0x05, 0x08, 0x07 },
4764 { 0x06, 0x88, 0xFF },
4765 { 0xE7, 0x21, 0x21 },
4766 { 0xE3, 0x38, 0xFF },
4767 { 0xE4, 0x06, 0xFF },
4768 };
4769
4770 const struct marimba_config_register v201_bt_off[] = {
4771 { 0x05, 0x08, 0x07 },
4772 { 0x06, 0x88, 0xFF },
4773 { 0xE7, 0x00, 0x21 },
4774 { 0xE3, 0x00, 0xFF },
4775 { 0xE4, 0x00, 0xFF },
4776 };
4777
4778 const struct marimba_config_register v210_bt_on[] = {
4779 { 0xE9, 0x01, 0x01 },
4780 { 0x06, 0x88, 0xFF },
4781 { 0xE7, 0x21, 0x21 },
4782 { 0xE3, 0x38, 0xFF },
4783 { 0xE4, 0x06, 0xFF },
4784 };
4785
4786 const struct marimba_config_register v210_bt_off[] = {
4787 { 0x06, 0x88, 0xFF },
4788 { 0xE7, 0x00, 0x21 },
4789 { 0xE9, 0x00, 0x01 },
4790 { 0xE3, 0x00, 0xFF },
4791 { 0xE4, 0x00, 0xFF },
4792 };
4793
4794 const struct marimba_variant_register bt_marimba[2][4] = {
4795 {
4796 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4797 { 0, NULL },
4798 { ARRAY_SIZE(v201_bt_off), v201_bt_off },
4799 { ARRAY_SIZE(v210_bt_off), v210_bt_off }
4800 },
4801 {
4802 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4803 { 0, NULL },
4804 { ARRAY_SIZE(v201_bt_on), v201_bt_on },
4805 { ARRAY_SIZE(v210_bt_on), v210_bt_on }
4806 }
4807 };
4808
4809 on = on ? 1 : 0;
4810
4811 rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F);
4812 if (rc < 0) {
4813 printk(KERN_ERR
4814 "%s: version read failed: %d\n",
4815 __func__, rc);
4816 return rc;
4817 }
4818
4819 if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
4820 (bt_marimba[on][version].size == 0)) {
4821 printk(KERN_ERR
4822 "%s: unsupported version\n",
4823 __func__);
4824 return -EIO;
4825 }
4826
4827 p = bt_marimba[on][version].set;
4828
4829 printk(KERN_INFO "%s: found version %d\n", __func__, version);
4830
4831 for (i = 0; i < bt_marimba[on][version].size; i++) {
4832 u8 value = (p+i)->value;
4833 rc = marimba_write_bit_mask(&config,
4834 (p+i)->reg,
4835 &value,
4836 sizeof((p+i)->value),
4837 (p+i)->mask);
4838 if (rc < 0) {
4839 printk(KERN_ERR
4840 "%s: reg %d write failed: %d\n",
4841 __func__, (p+i)->reg, rc);
4842 return rc;
4843 }
4844 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
4845 __func__, (p+i)->reg,
4846 value, (p+i)->mask);
4847 }
4848 return 0;
4849}
4850
4851static int bahama_bt(int on)
4852{
4853 int rc;
4854 int i;
4855 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
4856
4857 struct bahama_variant_register {
4858 const size_t size;
4859 const struct bahama_config_register *set;
4860 };
4861
4862 const struct bahama_config_register *p;
4863
4864
4865 const struct bahama_config_register v10_bt_on[] = {
4866 { 0xE9, 0x00, 0xFF },
4867 { 0xF4, 0x80, 0xFF },
4868 { 0xF0, 0x06, 0xFF },
4869 { 0xE4, 0x00, 0xFF },
4870 { 0xE5, 0x00, 0x0F },
4871#ifdef CONFIG_WLAN
4872 { 0xE6, 0x38, 0x7F },
4873 { 0xE7, 0x06, 0xFF },
4874#endif
4875 { 0x11, 0x13, 0xFF },
4876 { 0xE9, 0x21, 0xFF },
4877 { 0x01, 0x0C, 0x1F },
4878 { 0x01, 0x08, 0x1F },
4879 };
4880
4881 const struct bahama_config_register v20_bt_on_fm_off[] = {
4882 { 0x11, 0x0C, 0xFF },
4883 { 0x13, 0x01, 0xFF },
4884 { 0xF4, 0x80, 0xFF },
4885 { 0xF0, 0x00, 0xFF },
4886 { 0xE9, 0x00, 0xFF },
4887#ifdef CONFIG_WLAN
4888 { 0x81, 0x00, 0xFF },
4889 { 0x82, 0x00, 0xFF },
4890 { 0xE6, 0x38, 0x7F },
4891 { 0xE7, 0x06, 0xFF },
4892#endif
4893 { 0xE9, 0x21, 0xFF }
4894 };
4895
4896 const struct bahama_config_register v20_bt_on_fm_on[] = {
4897 { 0x11, 0x0C, 0xFF },
4898 { 0x13, 0x01, 0xFF },
4899 { 0xF4, 0x86, 0xFF },
4900 { 0xF0, 0x06, 0xFF },
4901 { 0xE9, 0x00, 0xFF },
4902#ifdef CONFIG_WLAN
4903 { 0x81, 0x00, 0xFF },
4904 { 0x82, 0x00, 0xFF },
4905 { 0xE6, 0x38, 0x7F },
4906 { 0xE7, 0x06, 0xFF },
4907#endif
4908 { 0xE9, 0x21, 0xFF }
4909 };
4910
4911 const struct bahama_config_register v10_bt_off[] = {
4912 { 0xE9, 0x00, 0xFF },
4913 };
4914
4915 const struct bahama_config_register v20_bt_off_fm_off[] = {
4916 { 0xF4, 0x84, 0xFF },
4917 { 0xF0, 0x04, 0xFF },
4918 { 0xE9, 0x00, 0xFF }
4919 };
4920
4921 const struct bahama_config_register v20_bt_off_fm_on[] = {
4922 { 0xF4, 0x86, 0xFF },
4923 { 0xF0, 0x06, 0xFF },
4924 { 0xE9, 0x00, 0xFF }
4925 };
4926
4927 const struct bahama_variant_register bt_bahama[2][3] = {
4928 {
4929 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4930 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
4931 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
4932 },
4933 {
4934 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4935 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
4936 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
4937 }
4938 };
4939
4940 u8 offset = 0; /* index into bahama configs */
4941
4942 on = on ? 1 : 0;
4943
4944 bahama_version = read_bahama_ver();
4945
4946 if (((int)bahama_version) < 0 ||
4947 bahama_version == VER_UNSUPPORTED) {
4948 dev_err(&msm_bt_power_device.dev,
4949 "%s: i2c failure or unsupported version: %d\n",
4950 __func__, bahama_version);
4951 return -EIO;
4952 }
4953
4954 if (bahama_version == VER_2_0) {
4955 if (marimba_get_fm_status(&config))
4956 offset = 0x01;
4957 }
4958
4959 p = bt_bahama[on][bahama_version + offset].set;
4960
4961 dev_info(&msm_bt_power_device.dev,
4962 "%s: found version %d\n", __func__, bahama_version);
4963
4964 for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
4965 u8 value = (p+i)->value;
4966 rc = marimba_write_bit_mask(&config,
4967 (p+i)->reg,
4968 &value,
4969 sizeof((p+i)->value),
4970 (p+i)->mask);
4971 if (rc < 0) {
4972 dev_err(&msm_bt_power_device.dev,
4973 "%s: reg %d write failed: %d\n",
4974 __func__, (p+i)->reg, rc);
4975 return rc;
4976 }
4977 dev_info(&msm_bt_power_device.dev,
4978 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
4979 __func__, (p+i)->reg,
4980 value, (p+i)->mask);
4981 }
4982 /* Update BT status */
4983 if (on)
4984 marimba_set_bt_status(&config, true);
4985 else
4986 marimba_set_bt_status(&config, false);
4987
4988 if (bahama_version == VER_2_0 && on) { /* variant of bahama v2 */
4989 /* Disable s2 as bahama v2 uses internal LDO regulator */
4990 for (i = 0; i < ARRAY_SIZE(vregs_bt_bahama_name); i++) {
4991 if (!strcmp(vregs_bt_bahama_name[i], "s2")) {
4992 rc = vreg_disable(vregs_bt_bahama[i]);
4993 if (rc < 0) {
4994 printk(KERN_ERR
4995 "%s: vreg %s disable "
4996 "failed (%d)\n",
4997 __func__,
4998 vregs_bt_bahama_name[i], rc);
4999 return -EIO;
5000 }
5001 rc = pmapp_vreg_level_vote("BTPW",
5002 PMAPP_VREG_S2,
5003 0);
5004 if (rc < 0) {
5005 printk(KERN_ERR "%s: vreg "
5006 "level off failed (%d)\n",
5007 __func__, rc);
5008 return -EIO;
5009 }
5010 printk(KERN_INFO "%s: vreg disable & "
5011 "level off successful (%d)\n",
5012 __func__, rc);
5013 }
5014 }
5015 }
5016
5017 return 0;
5018}
5019
5020static int bluetooth_power_regulators(int on, int bahama_not_marimba)
5021{
5022 int i, rc;
5023 const char **vregs_name;
5024 struct vreg **vregs;
5025 int vregs_size;
5026
5027 if (bahama_not_marimba) {
5028 vregs_name = vregs_bt_bahama_name;
5029 vregs = vregs_bt_bahama;
5030 vregs_size = ARRAY_SIZE(vregs_bt_bahama_name);
5031 } else {
5032 vregs_name = vregs_bt_marimba_name;
5033 vregs = vregs_bt_marimba;
5034 vregs_size = ARRAY_SIZE(vregs_bt_marimba_name);
5035 }
5036
5037 for (i = 0; i < vregs_size; i++) {
5038 if (bahama_not_marimba && (bahama_version == VER_2_0) &&
5039 !on && !strcmp(vregs_bt_bahama_name[i], "s2"))
5040 continue;
5041 rc = on ? vreg_enable(vregs[i]) :
5042 vreg_disable(vregs[i]);
5043 if (rc < 0) {
5044 printk(KERN_ERR "%s: vreg %s %s failed (%d)\n",
5045 __func__, vregs_name[i],
5046 on ? "enable" : "disable", rc);
5047 return -EIO;
5048 }
5049 }
5050 return 0;
5051}
5052
5053static int bluetooth_power(int on)
5054{
5055 int rc;
5056 const char *id = "BTPW";
5057
5058 int bahama_not_marimba = bahama_present();
5059
5060 if (bahama_not_marimba == -1) {
5061 printk(KERN_WARNING "%s: bahama_present: %d\n",
5062 __func__, bahama_not_marimba);
5063 return -ENODEV;
5064 }
5065
5066 if (on) {
5067 rc = pmapp_vreg_level_vote(id, PMAPP_VREG_S2, 1300);
5068 if (rc < 0) {
5069 printk(KERN_ERR "%s: vreg level on failed (%d)\n",
5070 __func__, rc);
5071 return rc;
5072 }
5073
5074 rc = bluetooth_power_regulators(on, bahama_not_marimba);
5075 if (rc < 0)
5076 return -EIO;
5077
5078 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5079 PMAPP_CLOCK_VOTE_ON);
5080 if (rc < 0)
5081 return -EIO;
5082
5083 if (machine_is_msm8x55_svlte_surf() ||
5084 machine_is_msm8x55_svlte_ffa()) {
5085 rc = marimba_gpio_config(1);
5086 if (rc < 0)
5087 return -EIO;
5088 }
5089
5090 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5091 if (rc < 0)
5092 return -EIO;
5093
5094 msleep(10);
5095
5096 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5097 PMAPP_CLOCK_VOTE_PIN_CTRL);
5098 if (rc < 0)
5099 return -EIO;
5100
5101 if (machine_is_msm8x55_svlte_surf() ||
5102 machine_is_msm8x55_svlte_ffa()) {
5103 rc = marimba_gpio_config(0);
5104 if (rc < 0)
5105 return -EIO;
5106 }
5107
5108 rc = msm_gpios_enable(bt_config_power_on,
5109 ARRAY_SIZE(bt_config_power_on));
5110
5111 if (rc < 0)
5112 return rc;
5113
5114 } else {
5115 rc = msm_gpios_enable(bt_config_power_off,
5116 ARRAY_SIZE(bt_config_power_off));
5117 if (rc < 0)
5118 return rc;
5119
5120 /* check for initial RFKILL block (power off) */
5121 if (platform_get_drvdata(&msm_bt_power_device) == NULL)
5122 goto out;
5123
5124 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5125 if (rc < 0)
5126 return -EIO;
5127
5128 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5129 PMAPP_CLOCK_VOTE_OFF);
5130 if (rc < 0)
5131 return -EIO;
5132
5133 rc = bluetooth_power_regulators(on, bahama_not_marimba);
5134 if (rc < 0)
5135 return -EIO;
5136
5137 if (bahama_version == VER_1_0) {
5138 rc = pmapp_vreg_level_vote(id, PMAPP_VREG_S2, 0);
5139 if (rc < 0) {
5140 printk(KERN_ERR "%s: vreg level off failed "
5141 "(%d)\n", __func__, rc);
5142 return -EIO;
5143 }
5144 }
5145 }
5146
5147out:
5148 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
5149
5150 return 0;
5151}
5152
5153static void __init bt_power_init(void)
5154{
5155 int i;
5156
5157 for (i = 0; i < ARRAY_SIZE(vregs_bt_marimba_name); i++) {
5158 vregs_bt_marimba[i] = vreg_get(NULL, vregs_bt_marimba_name[i]);
5159 if (IS_ERR(vregs_bt_marimba[i])) {
5160 printk(KERN_ERR "%s: vreg get %s failed (%ld)\n",
5161 __func__, vregs_bt_marimba_name[i],
5162 PTR_ERR(vregs_bt_marimba[i]));
5163 return;
5164 }
5165 }
5166
5167 for (i = 0; i < ARRAY_SIZE(vregs_bt_bahama_name); i++) {
5168 vregs_bt_bahama[i] = vreg_get(NULL, vregs_bt_bahama_name[i]);
5169 if (IS_ERR(vregs_bt_bahama[i])) {
5170 printk(KERN_ERR "%s: vreg get %s failed (%ld)\n",
5171 __func__, vregs_bt_bahama_name[i],
5172 PTR_ERR(vregs_bt_bahama[i]));
5173 return;
5174 }
5175 }
5176
5177 msm_bt_power_device.dev.platform_data = &bluetooth_power;
5178}
5179#else
5180#define bt_power_init(x) do {} while (0)
5181#endif
5182
5183static struct msm_psy_batt_pdata msm_psy_batt_data = {
5184 .voltage_min_design = 2800,
5185 .voltage_max_design = 4300,
5186 .avail_chg_sources = AC_CHG | USB_CHG ,
5187 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
5188};
5189
5190static struct platform_device msm_batt_device = {
5191 .name = "msm-battery",
5192 .id = -1,
5193 .dev.platform_data = &msm_psy_batt_data,
5194};
5195
5196static char *msm_adc_fluid_device_names[] = {
5197 "LTC_ADC1",
5198 "LTC_ADC2",
5199 "LTC_ADC3",
5200};
5201
5202static char *msm_adc_surf_device_names[] = {
5203 "XO_ADC",
5204};
5205
5206static struct msm_adc_platform_data msm_adc_pdata;
5207
5208static struct platform_device msm_adc_device = {
5209 .name = "msm_adc",
5210 .id = -1,
5211 .dev = {
5212 .platform_data = &msm_adc_pdata,
5213 },
5214};
5215
5216#ifdef CONFIG_MSM_SDIO_AL
5217static struct msm_gpio mdm2ap_status = {
5218 GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5219 "mdm2ap_status"
5220};
5221
5222
5223static int configure_mdm2ap_status(int on)
5224{
5225 if (on)
5226 return msm_gpios_request_enable(&mdm2ap_status, 1);
5227 else {
5228 msm_gpios_disable_free(&mdm2ap_status, 1);
5229 return 0;
5230 }
5231}
5232
5233static int get_mdm2ap_status(void)
5234{
5235 return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
5236}
5237
5238static struct sdio_al_platform_data sdio_al_pdata = {
5239 .config_mdm2ap_status = configure_mdm2ap_status,
5240 .get_mdm2ap_status = get_mdm2ap_status,
5241 .allow_sdioc_version_major_2 = 1,
5242 .peer_sdioc_version_minor = 0x0001,
5243 .peer_sdioc_version_major = 0x0003,
5244 .peer_sdioc_boot_version_minor = 0x0001,
5245 .peer_sdioc_boot_version_major = 0x0003,
5246};
5247
5248struct platform_device msm_device_sdio_al = {
5249 .name = "msm_sdio_al",
5250 .id = -1,
5251 .dev = {
5252 .platform_data = &sdio_al_pdata,
5253 },
5254};
5255
5256#endif /* CONFIG_MSM_SDIO_AL */
5257
Daniel Walker8d747cd2010-02-25 11:37:43 -08005258static struct platform_device *devices[] __initdata = {
Daniel Walker90e37c52010-05-12 14:24:15 -07005259#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005260 &msm_device_uart2,
5261#endif
5262 &asoc_msm_pcm,
5263 &asoc_msm_dai0,
5264 &asoc_msm_dai1,
5265#if defined (CONFIG_SND_MSM_MVS_DAI_SOC)
5266 &asoc_msm_mvs,
5267 &asoc_mvs_dai0,
5268 &asoc_mvs_dai1,
Daniel Walker90e37c52010-05-12 14:24:15 -07005269#endif
Niranjana Vishwanathapuraa8855e92010-10-06 13:52:10 -07005270 &msm_device_smd,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005271 &msm_device_dmov,
5272 &smc91x_device,
5273 &smsc911x_device,
5274 &msm_device_nand,
5275#ifdef CONFIG_USB_MSM_OTG_72K
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05305276 &msm_device_otg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005277#ifdef CONFIG_USB_GADGET
5278 &msm_device_gadget_peripheral,
5279#endif
5280#endif
5281#ifdef CONFIG_USB_G_ANDROID
5282 &android_usb_device,
5283#endif
5284 &qsd_device_spi,
5285#ifdef CONFIG_I2C_SSBI
5286 &msm_device_ssbi6,
5287 &msm_device_ssbi7,
5288#endif
5289 &android_pmem_device,
5290 &msm_fb_device,
5291 &msm_migrate_pages_device,
5292 &mddi_toshiba_device,
5293 &lcdc_toshiba_panel_device,
5294#ifdef CONFIG_MSM_ROTATOR
5295 &msm_rotator_device,
5296#endif
5297 &lcdc_sharp_panel_device,
5298 &android_pmem_adsp_device,
5299 &android_pmem_audio_device,
5300 &msm_device_i2c,
5301 &msm_device_i2c_2,
5302 &msm_device_uart_dm1,
5303 &hs_device,
5304#ifdef CONFIG_MSM7KV2_AUDIO
5305 &msm_aictl_device,
5306 &msm_mi2s_device,
5307 &msm_lpa_device,
5308 &msm_aux_pcm_device,
5309#endif
5310 &msm_device_adspdec,
5311 &qup_device_i2c,
5312#if defined(CONFIG_MARIMBA_CORE) && \
5313 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5314 &msm_bt_power_device,
5315#endif
5316 &msm_kgsl_3d0,
5317 &msm_kgsl_2d0,
5318#ifdef CONFIG_MT9T013
5319 &msm_camera_sensor_mt9t013,
5320#endif
5321#ifdef CONFIG_MT9D112
5322 &msm_camera_sensor_mt9d112,
5323#endif
5324#ifdef CONFIG_WEBCAM_OV9726
5325 &msm_camera_sensor_ov9726,
5326#endif
5327#ifdef CONFIG_S5K3E2FX
5328 &msm_camera_sensor_s5k3e2fx,
5329#endif
5330#ifdef CONFIG_MT9P012
5331 &msm_camera_sensor_mt9p012,
5332#endif
5333#ifdef CONFIG_MT9E013
5334 &msm_camera_sensor_mt9e013,
5335#endif
5336#ifdef CONFIG_VX6953
5337 &msm_camera_sensor_vx6953,
5338#endif
5339#ifdef CONFIG_SN12M0PZ
5340 &msm_camera_sensor_sn12m0pz,
5341#endif
5342 &msm_device_vidc_720p,
5343#ifdef CONFIG_MSM_GEMINI
5344 &msm_gemini_device,
5345#endif
5346#ifdef CONFIG_MSM_VPE
5347 &msm_vpe_device,
5348#endif
5349#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5350 &msm_device_tsif,
5351#endif
5352#ifdef CONFIG_MSM_SDIO_AL
5353 &msm_device_sdio_al,
5354#endif
5355
5356#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5357 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5358 &qcrypto_device,
5359#endif
5360
5361#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5362 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5363 &qcedev_device,
5364#endif
5365
5366 &msm_batt_device,
5367 &msm_adc_device,
5368 &msm_ebi0_thermal,
5369 &msm_ebi1_thermal
5370};
5371
5372static struct msm_gpio msm_i2c_gpios_hw[] = {
5373 { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5374 { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5375};
5376
5377static struct msm_gpio msm_i2c_gpios_io[] = {
5378 { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5379 { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5380};
5381
5382static struct msm_gpio qup_i2c_gpios_io[] = {
5383 { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5384 { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5385};
5386static struct msm_gpio qup_i2c_gpios_hw[] = {
5387 { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5388 { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5389};
5390
5391static void
5392msm_i2c_gpio_config(int adap_id, int config_type)
5393{
5394 struct msm_gpio *msm_i2c_table;
5395
5396 /* Each adapter gets 2 lines from the table */
5397 if (adap_id > 0)
5398 return;
5399 if (config_type)
5400 msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
5401 else
5402 msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
5403 msm_gpios_enable(msm_i2c_table, 2);
5404}
5405/*This needs to be enabled only for OEMS*/
5406#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
5407static struct vreg *qup_vreg;
5408#endif
5409static void
5410qup_i2c_gpio_config(int adap_id, int config_type)
5411{
5412 int rc = 0;
5413 struct msm_gpio *qup_i2c_table;
5414 /* Each adapter gets 2 lines from the table */
5415 if (adap_id != 4)
5416 return;
5417 if (config_type)
5418 qup_i2c_table = qup_i2c_gpios_hw;
5419 else
5420 qup_i2c_table = qup_i2c_gpios_io;
5421 rc = msm_gpios_enable(qup_i2c_table, 2);
5422 if (rc < 0)
5423 printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
5424 /*This needs to be enabled only for OEMS*/
5425#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
5426 if (qup_vreg) {
5427 int rc = vreg_set_level(qup_vreg, 1800);
5428 if (rc) {
5429 pr_err("%s: vreg LVS1 set level failed (%d)\n",
5430 __func__, rc);
5431 }
5432 rc = vreg_enable(qup_vreg);
5433 if (rc) {
5434 pr_err("%s: vreg_enable() = %d \n",
5435 __func__, rc);
5436 }
5437 }
5438#endif
5439}
5440
5441static struct msm_i2c_platform_data msm_i2c_pdata = {
5442 .clk_freq = 100000,
5443 .pri_clk = 70,
5444 .pri_dat = 71,
5445 .rmutex = 1,
5446 .rsl_id = "D:I2C02000021",
5447 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5448};
5449
5450static void __init msm_device_i2c_init(void)
5451{
5452 if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
5453 pr_err("failed to request I2C gpios\n");
5454
5455 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
5456}
5457
5458static struct msm_i2c_platform_data msm_i2c_2_pdata = {
5459 .clk_freq = 100000,
5460 .rmutex = 1,
5461 .rsl_id = "D:I2C02000022",
5462 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5463};
5464
5465static void __init msm_device_i2c_2_init(void)
5466{
5467 msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
5468}
5469
5470static struct msm_i2c_platform_data qup_i2c_pdata = {
5471 .clk_freq = 384000,
5472 .pclk = "camif_pad_pclk",
5473 .msm_i2c_config_gpio = qup_i2c_gpio_config,
5474};
5475
5476static void __init qup_device_i2c_init(void)
5477{
5478 if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
5479 pr_err("failed to request I2C gpios\n");
5480
5481 qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
5482 /*This needs to be enabled only for OEMS*/
5483#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
5484 qup_vreg = vreg_get(NULL, "lvsw1");
5485 if (IS_ERR(qup_vreg)) {
5486 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
5487 __func__, PTR_ERR(qup_vreg));
5488 }
5489#endif
5490}
5491
5492#ifdef CONFIG_I2C_SSBI
5493static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi6_pdata = {
5494 .rsl_id = "D:PMIC_SSBI",
5495 .controller_type = MSM_SBI_CTRL_SSBI2,
5496};
5497
5498static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = {
5499 .rsl_id = "D:CODEC_SSBI",
5500 .controller_type = MSM_SBI_CTRL_SSBI,
5501};
5502#endif
5503
5504static struct msm_acpu_clock_platform_data msm7x30_clock_data = {
5505 .acpu_switch_time_us = 50,
5506 .vdd_switch_time_us = 62,
Daniel Walker8d747cd2010-02-25 11:37:43 -08005507};
5508
5509static void __init msm7x30_init_irq(void)
5510{
5511 msm_init_irq();
5512}
5513
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005514static struct msm_gpio msm_nand_ebi2_cfg_data[] = {
5515 {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
5516 {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
5517};
5518
5519struct vreg *vreg_s3;
5520struct vreg *vreg_mmc;
5521
5522#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
5523 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
5524 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
5525 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
5526
5527struct sdcc_gpio {
5528 struct msm_gpio *cfg_data;
5529 uint32_t size;
5530 struct msm_gpio *sleep_cfg_data;
5531};
5532#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5533static struct msm_gpio sdc1_lvlshft_cfg_data[] = {
5534 {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
5535};
5536#endif
5537static struct msm_gpio sdc1_cfg_data[] = {
5538 {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
5539 {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
5540 {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
5541 {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
5542 {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
5543 {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
5544};
5545
5546static struct msm_gpio sdc2_cfg_data[] = {
5547 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
5548 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
5549 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
5550 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
5551 {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
5552 {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
5553
5554#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5555 {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
5556 {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
5557 {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
5558 {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
5559#endif
5560};
5561
5562static struct msm_gpio sdc3_cfg_data[] = {
5563 {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
5564 {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
5565 {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
5566 {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
5567 {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
5568 {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
5569};
5570
5571static struct msm_gpio sdc3_sleep_cfg_data[] = {
5572 {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5573 "sdc3_clk"},
5574 {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5575 "sdc3_cmd"},
5576 {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5577 "sdc3_dat_3"},
5578 {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5579 "sdc3_dat_2"},
5580 {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5581 "sdc3_dat_1"},
5582 {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5583 "sdc3_dat_0"},
5584};
5585
5586static struct msm_gpio sdc4_cfg_data[] = {
5587 {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
5588 {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
5589 {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
5590 {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
5591 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
5592 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
5593};
5594
5595static struct sdcc_gpio sdcc_cfg_data[] = {
5596 {
5597 .cfg_data = sdc1_cfg_data,
5598 .size = ARRAY_SIZE(sdc1_cfg_data),
5599 .sleep_cfg_data = NULL,
5600 },
5601 {
5602 .cfg_data = sdc2_cfg_data,
5603 .size = ARRAY_SIZE(sdc2_cfg_data),
5604 .sleep_cfg_data = NULL,
5605 },
5606 {
5607 .cfg_data = sdc3_cfg_data,
5608 .size = ARRAY_SIZE(sdc3_cfg_data),
5609 .sleep_cfg_data = sdc3_sleep_cfg_data,
5610 },
5611 {
5612 .cfg_data = sdc4_cfg_data,
5613 .size = ARRAY_SIZE(sdc4_cfg_data),
5614 .sleep_cfg_data = NULL,
5615 },
5616};
5617
5618struct sdcc_vreg {
5619 struct vreg *vreg_data;
5620 unsigned level;
5621};
5622
5623static struct sdcc_vreg sdcc_vreg_data[4];
5624
5625static unsigned long vreg_sts, gpio_sts;
5626
5627static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
5628{
5629 int rc = 0;
5630 struct sdcc_gpio *curr;
5631
5632 curr = &sdcc_cfg_data[dev_id - 1];
5633
5634 if (!(test_bit(dev_id, &gpio_sts)^enable))
5635 return rc;
5636
5637 if (enable) {
5638 set_bit(dev_id, &gpio_sts);
5639 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
5640 if (rc)
5641 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
5642 __func__, dev_id);
5643 } else {
5644 clear_bit(dev_id, &gpio_sts);
5645 if (curr->sleep_cfg_data) {
5646 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
5647 msm_gpios_free(curr->sleep_cfg_data, curr->size);
5648 } else {
5649 msm_gpios_disable_free(curr->cfg_data, curr->size);
5650 }
5651 }
5652
5653 return rc;
5654}
5655
5656static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
5657{
5658 int rc = 0;
5659 struct sdcc_vreg *curr;
5660 static int enabled_once[] = {0, 0, 0, 0};
5661
5662 curr = &sdcc_vreg_data[dev_id - 1];
5663
5664 if (!(test_bit(dev_id, &vreg_sts)^enable))
5665 return rc;
5666
5667 if (!enable || enabled_once[dev_id - 1])
5668 return 0;
5669
5670 if (enable) {
5671 set_bit(dev_id, &vreg_sts);
5672 rc = vreg_set_level(curr->vreg_data, curr->level);
5673 if (rc) {
5674 printk(KERN_ERR "%s: vreg_set_level() = %d \n",
5675 __func__, rc);
5676 }
5677 rc = vreg_enable(curr->vreg_data);
5678 if (rc) {
5679 printk(KERN_ERR "%s: vreg_enable() = %d \n",
5680 __func__, rc);
5681 }
5682 enabled_once[dev_id - 1] = 1;
5683 } else {
5684 clear_bit(dev_id, &vreg_sts);
5685 rc = vreg_disable(curr->vreg_data);
5686 if (rc) {
5687 printk(KERN_ERR "%s: vreg_disable() = %d \n",
5688 __func__, rc);
5689 }
5690 }
5691 return rc;
5692}
5693
5694static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
5695{
5696 int rc = 0;
5697 struct platform_device *pdev;
5698
5699 pdev = container_of(dv, struct platform_device, dev);
5700 rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
5701 if (rc)
5702 goto out;
5703
5704 if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
5705 rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
5706out:
5707 return rc;
5708}
5709
5710#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \
5711 defined(CONFIG_CSDIO_VENDOR_ID) && \
5712 defined(CONFIG_CSDIO_DEVICE_ID) && \
5713 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5714
5715#define MBP_ON 1
5716#define MBP_OFF 0
5717
5718#define MBP_RESET_N \
5719 GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
5720#define MBP_INT0 \
5721 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
5722
5723#define MBP_MODE_CTRL_0 \
5724 GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5725#define MBP_MODE_CTRL_1 \
5726 GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5727#define MBP_MODE_CTRL_2 \
5728 GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5729#define TSIF_EN \
5730 GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5731#define TSIF_DATA \
5732 GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5733#define TSIF_CLK \
5734 GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5735
5736static struct msm_gpio mbp_cfg_data[] = {
5737 {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5738 "mbp_reset"},
5739 {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5740 "mbp_io_voltage"},
5741};
5742
5743static int mbp_config_gpios_pre_init(int enable)
5744{
5745 int rc = 0;
5746
5747 if (enable) {
5748 rc = msm_gpios_request_enable(mbp_cfg_data,
5749 ARRAY_SIZE(mbp_cfg_data));
5750 if (rc) {
5751 printk(KERN_ERR
5752 "%s: Failed to turnon GPIOs for mbp chip(%d)\n",
5753 __func__, rc);
5754 }
5755 } else
5756 msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
5757 return rc;
5758}
5759
5760static int mbp_setup_rf_vregs(int state)
5761{
5762 struct vreg *vreg_rf = NULL;
5763 struct vreg *vreg_rf_switch = NULL;
5764 int rc;
5765
5766 vreg_rf = vreg_get(NULL, "s2");
5767 if (IS_ERR(vreg_rf)) {
5768 pr_err("%s: s2 vreg get failed (%ld)",
5769 __func__, PTR_ERR(vreg_rf));
5770 return -EFAULT;
5771 }
5772 vreg_rf_switch = vreg_get(NULL, "rf");
5773 if (IS_ERR(vreg_rf_switch)) {
5774 pr_err("%s: rf vreg get failed (%ld)",
5775 __func__, PTR_ERR(vreg_rf_switch));
5776 return -EFAULT;
5777 }
5778
5779 if (state) {
5780 rc = vreg_set_level(vreg_rf, 1300);
5781 if (rc) {
5782 pr_err("%s: vreg s2 set level failed (%d)\n",
5783 __func__, rc);
5784 return rc;
5785 }
5786
5787 rc = vreg_enable(vreg_rf);
5788 if (rc) {
5789 printk(KERN_ERR "%s: vreg_enable(s2) = %d\n",
5790 __func__, rc);
5791 }
5792
5793 rc = vreg_set_level(vreg_rf_switch, 2600);
5794 if (rc) {
5795 pr_err("%s: vreg rf switch set level failed (%d)\n",
5796 __func__, rc);
5797 return rc;
5798 }
5799 rc = vreg_enable(vreg_rf_switch);
5800 if (rc) {
5801 printk(KERN_ERR "%s: vreg_enable(rf) = %d\n",
5802 __func__, rc);
5803 }
5804 } else {
5805 (void) vreg_disable(vreg_rf);
5806 (void) vreg_disable(vreg_rf_switch);
5807 }
5808 return 0;
5809}
5810
5811static int mbp_setup_vregs(int state)
5812{
5813 struct vreg *vreg_analog = NULL;
5814 struct vreg *vreg_io = NULL;
5815 int rc;
5816
5817 vreg_analog = vreg_get(NULL, "gp4");
5818 if (IS_ERR(vreg_analog)) {
5819 pr_err("%s: gp4 vreg get failed (%ld)",
5820 __func__, PTR_ERR(vreg_analog));
5821 return -EFAULT;
5822 }
5823 vreg_io = vreg_get(NULL, "s3");
5824 if (IS_ERR(vreg_io)) {
5825 pr_err("%s: s3 vreg get failed (%ld)",
5826 __func__, PTR_ERR(vreg_io));
5827 return -EFAULT;
5828 }
5829 if (state) {
5830 rc = vreg_set_level(vreg_analog, 2600);
5831 if (rc) {
5832 pr_err("%s: vreg_set_level failed (%d)",
5833 __func__, rc);
5834 }
5835 rc = vreg_enable(vreg_analog);
5836 if (rc) {
5837 pr_err("%s: analog vreg enable failed (%d)",
5838 __func__, rc);
5839 }
5840 rc = vreg_set_level(vreg_io, 1800);
5841 if (rc) {
5842 pr_err("%s: vreg_set_level failed (%d)",
5843 __func__, rc);
5844 }
5845 rc = vreg_enable(vreg_io);
5846 if (rc) {
5847 pr_err("%s: io vreg enable failed (%d)",
5848 __func__, rc);
5849 }
5850 } else {
5851 rc = vreg_disable(vreg_analog);
5852 if (rc) {
5853 pr_err("%s: analog vreg disable failed (%d)",
5854 __func__, rc);
5855 }
5856 rc = vreg_disable(vreg_io);
5857 if (rc) {
5858 pr_err("%s: io vreg disable failed (%d)",
5859 __func__, rc);
5860 }
5861 }
5862 return rc;
5863}
5864
5865static int mbp_set_tcxo_en(int enable)
5866{
5867 int rc;
5868 const char *id = "UBMC";
5869 struct vreg *vreg_analog = NULL;
5870
5871 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
5872 enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
5873 if (rc < 0) {
5874 printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
5875 __func__, enable ? "" : "de-");
5876 return -EIO;
5877 }
5878 if (!enable) {
5879 vreg_analog = vreg_get(NULL, "gp4");
5880 if (IS_ERR(vreg_analog)) {
5881 pr_err("%s: gp4 vreg get failed (%ld)",
5882 __func__, PTR_ERR(vreg_analog));
5883 return -EFAULT;
5884 }
5885
5886 (void) vreg_disable(vreg_analog);
5887 }
5888 return rc;
5889}
5890
5891static void mbp_set_freeze_io(int state)
5892{
5893 if (state)
5894 gpio_set_value(85, 0);
5895 else
5896 gpio_set_value(85, 1);
5897}
5898
5899static int mbp_set_core_voltage_en(int enable)
5900{
5901 int rc;
5902 struct vreg *vreg_core1p2 = NULL;
5903
5904 vreg_core1p2 = vreg_get(NULL, "gp16");
5905 if (IS_ERR(vreg_core1p2)) {
5906 pr_err("%s: gp16 vreg get failed (%ld)",
5907 __func__, PTR_ERR(vreg_core1p2));
5908 return -EFAULT;
5909 }
5910 if (enable) {
5911 rc = vreg_set_level(vreg_core1p2, 1200);
5912 if (rc) {
5913 pr_err("%s: vreg_set_level failed (%d)",
5914 __func__, rc);
5915 }
5916 (void) vreg_enable(vreg_core1p2);
5917
5918 return 80;
5919 } else {
5920 gpio_set_value(85, 1);
5921 return 0;
5922 }
5923 return rc;
5924}
5925
5926static void mbp_set_reset(int state)
5927{
5928 if (state)
5929 gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
5930 else
5931 gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
5932}
5933
5934static int mbp_config_interface_mode(int state)
5935{
5936 if (state) {
5937 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
5938 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
5939 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
5940 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
5941 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
5942 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
5943 } else {
5944 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
5945 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
5946 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
5947 }
5948 return 0;
5949}
5950
5951static int mbp_setup_adc_vregs(int state)
5952{
5953 struct vreg *vreg_adc = NULL;
5954 int rc;
5955
5956 vreg_adc = vreg_get(NULL, "s4");
5957 if (IS_ERR(vreg_adc)) {
5958 pr_err("%s: s4 vreg get failed (%ld)",
5959 __func__, PTR_ERR(vreg_adc));
5960 return -EFAULT;
5961 }
5962 if (state) {
5963 rc = vreg_set_level(vreg_adc, 2200);
5964 if (rc) {
5965 pr_err("%s: vreg_set_level failed (%d)",
5966 __func__, rc);
5967 }
5968 rc = vreg_enable(vreg_adc);
5969 if (rc) {
5970 pr_err("%s: enable vreg adc failed (%d)",
5971 __func__, rc);
5972 }
5973 } else {
5974 rc = vreg_disable(vreg_adc);
5975 if (rc) {
5976 pr_err("%s: disable vreg adc failed (%d)",
5977 __func__, rc);
5978 }
5979 }
5980 return rc;
5981}
5982
5983static int mbp_power_up(void)
5984{
5985 int rc;
5986
5987 rc = mbp_config_gpios_pre_init(MBP_ON);
5988 if (rc)
5989 goto exit;
5990 pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__);
5991
5992 rc = mbp_setup_vregs(MBP_ON);
5993 if (rc)
5994 goto exit;
5995 pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
5996
5997 rc = mbp_set_tcxo_en(MBP_ON);
5998 if (rc)
5999 goto exit;
6000 pr_debug("%s: tcxo clock done\n", __func__);
6001
6002 mbp_set_freeze_io(MBP_OFF);
6003 pr_debug("%s: set gpio 85 to 1 done\n", __func__);
6004
6005 udelay(100);
6006 mbp_set_reset(MBP_ON);
6007
6008 udelay(300);
6009 rc = mbp_config_interface_mode(MBP_ON);
6010 if (rc)
6011 goto exit;
6012 pr_debug("%s: mbp_config_interface_mode() done\n", __func__);
6013
6014 udelay(100 + mbp_set_core_voltage_en(MBP_ON));
6015 pr_debug("%s: power gp16 1.2V done\n", __func__);
6016
6017 mbp_set_freeze_io(MBP_ON);
6018 pr_debug("%s: set gpio 85 to 0 done\n", __func__);
6019
6020 udelay(100);
6021
6022 rc = mbp_setup_rf_vregs(MBP_ON);
6023 if (rc)
6024 goto exit;
6025 pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
6026
6027 rc = mbp_setup_adc_vregs(MBP_ON);
6028 if (rc)
6029 goto exit;
6030 pr_debug("%s: s4 2.2V done\n", __func__);
6031
6032 udelay(200);
6033
6034 mbp_set_reset(MBP_OFF);
6035 pr_debug("%s: close gpio 44 done\n", __func__);
6036
6037 msleep(20);
6038exit:
6039 return rc;
6040}
6041
6042static int mbp_power_down(void)
6043{
6044 int rc;
6045 struct vreg *vreg_adc = NULL;
6046
6047 vreg_adc = vreg_get(NULL, "s4");
6048 if (IS_ERR(vreg_adc)) {
6049 pr_err("%s: s4 vreg get failed (%ld)",
6050 __func__, PTR_ERR(vreg_adc));
6051 return -EFAULT;
6052 }
6053
6054 mbp_set_reset(MBP_ON);
6055 pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
6056
6057 udelay(100);
6058
6059 rc = mbp_setup_adc_vregs(MBP_OFF);
6060 if (rc)
6061 goto exit;
6062 pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
6063
6064 udelay(5);
6065
6066 rc = mbp_setup_rf_vregs(MBP_OFF);
6067 if (rc)
6068 goto exit;
6069 pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
6070
6071 udelay(5);
6072
6073 mbp_set_freeze_io(MBP_OFF);
6074 pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
6075
6076 udelay(100);
6077 rc = mbp_set_core_voltage_en(MBP_OFF);
6078 if (rc)
6079 goto exit;
6080 pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
6081
6082 gpio_set_value(85, 1);
6083
6084 rc = mbp_set_tcxo_en(MBP_OFF);
6085 if (rc)
6086 goto exit;
6087 pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
6088
6089 rc = mbp_config_gpios_pre_init(MBP_OFF);
6090 if (rc)
6091 goto exit;
6092exit:
6093 return rc;
6094}
6095
6096static void (*mbp_status_notify_cb)(int card_present, void *dev_id);
6097static void *mbp_status_notify_cb_devid;
6098static int mbp_power_status;
6099static int mbp_power_init_done;
6100
6101static uint32_t mbp_setup_power(struct device *dv,
6102 unsigned int power_status)
6103{
6104 int rc = 0;
6105 struct platform_device *pdev;
6106
6107 pdev = container_of(dv, struct platform_device, dev);
6108
6109 if (power_status == mbp_power_status)
6110 goto exit;
6111 if (power_status) {
6112 pr_debug("turn on power of mbp slot");
6113 rc = mbp_power_up();
6114 mbp_power_status = 1;
6115 } else {
6116 pr_debug("turn off power of mbp slot");
6117 rc = mbp_power_down();
6118 mbp_power_status = 0;
6119 }
6120exit:
6121 return rc;
6122};
6123
6124int mbp_register_status_notify(void (*callback)(int, void *),
6125 void *dev_id)
6126{
6127 mbp_status_notify_cb = callback;
6128 mbp_status_notify_cb_devid = dev_id;
6129 return 0;
6130}
6131
6132static unsigned int mbp_status(struct device *dev)
6133{
6134 return mbp_power_status;
6135}
6136
6137static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd)
6138{
6139 struct platform_device *pdev;
6140 uint32_t rc = 0;
6141
6142 pdev = container_of(dv, struct platform_device, dev);
6143 rc = msm_sdcc_setup_power(dv, vdd);
6144 if (rc) {
6145 pr_err("%s: Failed to setup power (%d)\n",
6146 __func__, rc);
6147 goto out;
6148 }
6149 if (!mbp_power_init_done) {
6150 mbp_setup_power(dv, 1);
6151 mbp_setup_power(dv, 0);
6152 mbp_power_init_done = 1;
6153 }
6154 if (vdd >= 0x8000) {
6155 rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
6156 if (rc) {
6157 pr_err("%s: Failed to config mbp chip power (%d)\n",
6158 __func__, rc);
6159 goto out;
6160 }
6161 if (mbp_status_notify_cb) {
6162 mbp_status_notify_cb(mbp_power_status,
6163 mbp_status_notify_cb_devid);
6164 }
6165 }
6166out:
6167 /* should return 0 only */
6168 return 0;
6169}
6170
6171#endif
6172
6173#endif
6174
6175#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6176#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6177static unsigned int msm7x30_sdcc_slot_status(struct device *dev)
6178{
6179 return (unsigned int)
6180 gpio_get_value_cansleep(
6181 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1));
6182}
6183#endif
6184
6185static int msm_sdcc_get_wpswitch(struct device *dv)
6186{
6187 void __iomem *wp_addr = 0;
6188 uint32_t ret = 0;
6189 struct platform_device *pdev;
6190
6191 if (!(machine_is_msm7x30_surf()))
6192 return -1;
6193 pdev = container_of(dv, struct platform_device, dev);
6194
6195 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
6196 if (!wp_addr) {
6197 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
6198 return -ENOMEM;
6199 }
6200
6201 ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
6202 pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
6203 pdev->id, ret);
6204 iounmap(wp_addr);
6205
6206 return ret;
6207}
6208#endif
6209
6210#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
6211#if defined(CONFIG_CSDIO_VENDOR_ID) && \
6212 defined(CONFIG_CSDIO_DEVICE_ID) && \
6213 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
6214static struct mmc_platform_data msm7x30_sdc1_data = {
6215 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
6216 .translate_vdd = msm_sdcc_setup_power_mbp,
6217 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6218 .status = mbp_status,
6219 .register_status_notify = mbp_register_status_notify,
6220#ifdef CONFIG_MMC_MSM_SDC1_DUMMY52_REQUIRED
6221 .dummy52_required = 1,
6222#endif
6223 .msmsdcc_fmin = 144000,
6224 .msmsdcc_fmid = 24576000,
6225 .msmsdcc_fmax = 24576000,
6226 .nonremovable = 0,
6227};
6228#else
6229static struct mmc_platform_data msm7x30_sdc1_data = {
6230 .ocr_mask = MMC_VDD_165_195,
6231 .translate_vdd = msm_sdcc_setup_power,
6232 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6233#ifdef CONFIG_MMC_MSM_SDC1_DUMMY52_REQUIRED
6234 .dummy52_required = 1,
6235#endif
6236 .msmsdcc_fmin = 144000,
6237 .msmsdcc_fmid = 24576000,
6238 .msmsdcc_fmax = 49152000,
6239 .nonremovable = 0,
6240};
6241#endif
6242#endif
6243
6244#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
6245static struct mmc_platform_data msm7x30_sdc2_data = {
6246 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
6247 .translate_vdd = msm_sdcc_setup_power,
6248#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
6249 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
6250#else
6251 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6252#endif
6253#ifdef CONFIG_MMC_MSM_SDC2_DUMMY52_REQUIRED
6254 .dummy52_required = 1,
6255#endif
6256 .msmsdcc_fmin = 144000,
6257 .msmsdcc_fmid = 24576000,
6258 .msmsdcc_fmax = 49152000,
6259 .nonremovable = 1,
6260};
6261#endif
6262
6263#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
6264static struct mmc_platform_data msm7x30_sdc3_data = {
6265 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6266 .translate_vdd = msm_sdcc_setup_power,
6267 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6268#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
6269 .sdiowakeup_irq = MSM_GPIO_TO_INT(118),
6270#endif
6271#ifdef CONFIG_MMC_MSM_SDC3_DUMMY52_REQUIRED
6272 .dummy52_required = 1,
6273#endif
6274 .msmsdcc_fmin = 144000,
6275 .msmsdcc_fmid = 24576000,
6276 .msmsdcc_fmax = 49152000,
6277 .nonremovable = 0,
6278};
6279#endif
6280
6281#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6282static struct mmc_platform_data msm7x30_sdc4_data = {
6283 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6284 .translate_vdd = msm_sdcc_setup_power,
6285 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6286#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6287 .status = msm7x30_sdcc_slot_status,
6288 .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
6289 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
6290#endif
6291 .wpswitch = msm_sdcc_get_wpswitch,
6292#ifdef CONFIG_MMC_MSM_SDC4_DUMMY52_REQUIRED
6293 .dummy52_required = 1,
6294#endif
6295 .msmsdcc_fmin = 144000,
6296 .msmsdcc_fmid = 24576000,
6297 .msmsdcc_fmax = 49152000,
6298 .nonremovable = 0,
6299};
6300#endif
6301
6302#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
6303static void msm_sdc1_lvlshft_enable(void)
6304{
6305 int rc;
6306
6307 /* Enable LDO5, an input to the FET that powers slot 1 */
6308 rc = vreg_set_level(vreg_mmc, 2850);
6309 if (rc)
6310 printk(KERN_ERR "%s: vreg_set_level() = %d \n", __func__, rc);
6311
6312 rc = vreg_enable(vreg_mmc);
6313 if (rc)
6314 printk(KERN_ERR "%s: vreg_enable() = %d \n", __func__, rc);
6315
6316 /* Enable GPIO 35, to turn on the FET that powers slot 1 */
6317 rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
6318 ARRAY_SIZE(sdc1_lvlshft_cfg_data));
6319 if (rc)
6320 printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
6321
6322 rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg),
6323 1);
6324 if (rc)
6325 printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
6326}
6327#endif
6328
6329static void __init msm7x30_init_mmc(void)
6330{
6331 vreg_s3 = vreg_get(NULL, "s3");
6332 if (IS_ERR(vreg_s3)) {
6333 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
6334 __func__, PTR_ERR(vreg_s3));
6335 return;
6336 }
6337
6338 vreg_mmc = vreg_get(NULL, "mmc");
6339 if (IS_ERR(vreg_mmc)) {
6340 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
6341 __func__, PTR_ERR(vreg_mmc));
6342 return;
6343 }
6344
6345#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
6346 if (machine_is_msm7x30_fluid()) {
6347 msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
6348 msm_sdc1_lvlshft_enable();
6349 }
6350 sdcc_vreg_data[0].vreg_data = vreg_s3;
6351 sdcc_vreg_data[0].level = 1800;
6352 msm_add_sdcc(1, &msm7x30_sdc1_data);
6353#endif
6354#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
6355 if (machine_is_msm8x55_svlte_surf())
6356 msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
6357 sdcc_vreg_data[1].vreg_data = vreg_s3;
6358 sdcc_vreg_data[1].level = 1800;
6359 msm_add_sdcc(2, &msm7x30_sdc2_data);
6360#endif
6361#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
6362 sdcc_vreg_data[2].vreg_data = vreg_s3;
6363 sdcc_vreg_data[2].level = 1800;
6364 msm_sdcc_setup_gpio(3, 1);
6365 msm_add_sdcc(3, &msm7x30_sdc3_data);
6366#endif
6367#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6368 sdcc_vreg_data[3].vreg_data = vreg_mmc;
6369 sdcc_vreg_data[3].level = 2850;
6370 msm_add_sdcc(4, &msm7x30_sdc4_data);
6371#endif
6372
6373}
6374
6375static void __init msm7x30_init_nand(void)
6376{
6377 char *build_id;
6378 struct flash_platform_data *plat_data;
6379
6380 build_id = socinfo_get_build_id();
6381 if (build_id == NULL) {
6382 pr_err("%s: Build ID not available from socinfo\n", __func__);
6383 return;
6384 }
6385
6386 if (build_id[8] == 'C' &&
6387 !msm_gpios_request_enable(msm_nand_ebi2_cfg_data,
6388 ARRAY_SIZE(msm_nand_ebi2_cfg_data))) {
6389 plat_data = msm_device_nand.dev.platform_data;
6390 plat_data->interleave = 1;
6391 printk(KERN_INFO "%s: Interleave mode Build ID found\n",
6392 __func__);
6393 }
6394}
6395
6396#ifdef CONFIG_SERIAL_MSM_CONSOLE
6397static struct msm_gpio uart2_config_data[] = {
6398 { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
6399 { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
6400 { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
6401 { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
6402};
6403
6404static void msm7x30_init_uart2(void)
6405{
6406 msm_gpios_request_enable(uart2_config_data,
6407 ARRAY_SIZE(uart2_config_data));
6408
6409}
6410#endif
6411
6412/* TSIF begin */
6413#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6414
6415#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6416#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6417#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6418#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6419
6420static const struct msm_gpio tsif_gpios[] = {
6421 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
6422 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
6423 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
6424 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
6425};
6426
6427static struct msm_tsif_platform_data tsif_platform_data = {
6428 .num_gpios = ARRAY_SIZE(tsif_gpios),
6429 .gpios = tsif_gpios,
6430 .tsif_pclk = "tsif_pclk",
6431 .tsif_ref_clk = "tsif_ref_clk",
6432};
6433#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
6434/* TSIF end */
6435
6436static void __init pmic8058_leds_init(void)
6437{
6438 if (machine_is_msm7x30_surf()) {
6439 pm8058_7x30_data.sub_devices[PM8058_SUBDEV_LED].platform_data
6440 = &pm8058_surf_leds_data;
6441 } else if (!machine_is_msm7x30_fluid()) {
6442 pm8058_7x30_data.sub_devices[PM8058_SUBDEV_LED].platform_data
6443 = &pm8058_ffa_leds_data;
6444 } else if (machine_is_msm7x30_fluid()) {
6445 pm8058_7x30_data.sub_devices[PM8058_SUBDEV_LED].platform_data
6446 = &pm8058_fluid_leds_data;
6447 }
6448}
6449
6450static struct msm_spm_platform_data msm_spm_data __initdata = {
6451 .reg_base_addr = MSM_SAW_BASE,
6452
6453 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
6454 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
6455 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
6456 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
6457
6458 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
6459 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
6460 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
6461
6462 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
6463 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
6464 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
6465
6466 .awake_vlevel = 0xF2,
6467 .retention_vlevel = 0xE0,
6468 .collapse_vlevel = 0x72,
6469 .retention_mid_vlevel = 0xE0,
6470 .collapse_mid_vlevel = 0xE0,
6471
6472 .vctl_timeout_us = 50,
6473};
6474
6475#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6476 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6477
6478#define TSC2007_TS_PEN_INT 20
6479
6480static struct msm_gpio tsc2007_config_data[] = {
6481 { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
6482 "tsc2007_irq" },
6483};
6484
6485static struct vreg *vreg_tsc_s3;
6486static struct vreg *vreg_tsc_s2;
6487
6488static int tsc2007_init(void)
6489{
6490 int rc;
6491
6492 vreg_tsc_s3 = vreg_get(NULL, "s3");
6493 if (IS_ERR(vreg_tsc_s3)) {
6494 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
6495 __func__, PTR_ERR(vreg_tsc_s3));
6496 return -ENODEV;
6497 }
6498
6499 rc = vreg_set_level(vreg_tsc_s3, 1800);
6500 if (rc) {
6501 pr_err("%s: vreg_set_level failed \n", __func__);
6502 goto fail_vreg_set_level;
6503 }
6504
6505 rc = vreg_enable(vreg_tsc_s3);
6506 if (rc) {
6507 pr_err("%s: vreg_enable failed \n", __func__);
6508 goto fail_vreg_set_level;
6509 }
6510
6511 vreg_tsc_s2 = vreg_get(NULL, "s2");
6512 if (IS_ERR(vreg_tsc_s2)) {
6513 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
6514 __func__, PTR_ERR(vreg_tsc_s2));
6515 goto fail_vreg_get;
6516 }
6517
6518 rc = vreg_set_level(vreg_tsc_s2, 1300);
6519 if (rc) {
6520 pr_err("%s: vreg_set_level failed \n", __func__);
6521 goto fail_vreg_s2_level;
6522 }
6523
6524 rc = vreg_enable(vreg_tsc_s2);
6525 if (rc) {
6526 pr_err("%s: vreg_enable failed \n", __func__);
6527 goto fail_vreg_s2_level;
6528 }
6529
6530 rc = msm_gpios_request_enable(tsc2007_config_data,
6531 ARRAY_SIZE(tsc2007_config_data));
6532 if (rc) {
6533 pr_err("%s: Unable to request gpios\n", __func__);
6534 goto fail_gpio_req;
6535 }
6536
6537 return 0;
6538
6539fail_gpio_req:
6540 vreg_disable(vreg_tsc_s2);
6541fail_vreg_s2_level:
6542 vreg_put(vreg_tsc_s2);
6543fail_vreg_get:
6544 vreg_disable(vreg_tsc_s3);
6545fail_vreg_set_level:
6546 vreg_put(vreg_tsc_s3);
6547 return rc;
6548}
6549
6550static int tsc2007_get_pendown_state(void)
6551{
6552 int rc;
6553
6554 rc = gpio_get_value(TSC2007_TS_PEN_INT);
6555 if (rc < 0) {
6556 pr_err("%s: MSM GPIO %d read failed\n", __func__,
6557 TSC2007_TS_PEN_INT);
6558 return rc;
6559 }
6560
6561 return (rc == 0 ? 1 : 0);
6562}
6563
6564static void tsc2007_exit(void)
6565{
6566 vreg_disable(vreg_tsc_s3);
6567 vreg_put(vreg_tsc_s3);
6568 vreg_disable(vreg_tsc_s2);
6569 vreg_put(vreg_tsc_s2);
6570
6571 msm_gpios_disable_free(tsc2007_config_data,
6572 ARRAY_SIZE(tsc2007_config_data));
6573}
6574
6575static int tsc2007_power_shutdown(bool enable)
6576{
6577 int rc;
6578
6579 if (enable == false) {
6580 rc = vreg_enable(vreg_tsc_s2);
6581 if (rc) {
6582 pr_err("%s: vreg_enable failed\n", __func__);
6583 return rc;
6584 }
6585 rc = vreg_enable(vreg_tsc_s3);
6586 if (rc) {
6587 pr_err("%s: vreg_enable failed\n", __func__);
6588 vreg_disable(vreg_tsc_s2);
6589 return rc;
6590 }
6591 /* Voltage settling delay */
6592 msleep(20);
6593 } else {
6594 rc = vreg_disable(vreg_tsc_s2);
6595 if (rc) {
6596 pr_err("%s: vreg_disable failed\n", __func__);
6597 return rc;
6598 }
6599 rc = vreg_disable(vreg_tsc_s3);
6600 if (rc) {
6601 pr_err("%s: vreg_disable failed\n", __func__);
6602 vreg_enable(vreg_tsc_s2);
6603 return rc;
6604 }
6605 }
6606
6607 return rc;
6608}
6609
6610static struct tsc2007_platform_data tsc2007_ts_data = {
6611 .model = 2007,
6612 .x_plate_ohms = 300,
6613 .irq_flags = IRQF_TRIGGER_LOW,
6614 .init_platform_hw = tsc2007_init,
6615 .exit_platform_hw = tsc2007_exit,
6616 .power_shutdown = tsc2007_power_shutdown,
6617 .invert_x = true,
6618 .invert_y = true,
6619 /* REVISIT: Temporary fix for reversed pressure */
6620 .invert_z1 = true,
6621 .invert_z2 = true,
6622 .get_pendown_state = tsc2007_get_pendown_state,
6623};
6624
6625static struct i2c_board_info tsc_i2c_board_info[] = {
6626 {
6627 I2C_BOARD_INFO("tsc2007", 0x48),
6628 .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
6629 .platform_data = &tsc2007_ts_data,
6630 },
6631};
6632#endif
6633
6634static const char *vregs_isa1200_name[] = {
6635 "gp7",
6636 "gp10",
6637};
6638
6639static const int vregs_isa1200_val[] = {
6640 1800,
6641 2600,
6642};
6643static struct vreg *vregs_isa1200[ARRAY_SIZE(vregs_isa1200_name)];
6644
6645static int isa1200_power(int vreg_on)
6646{
6647 int i, rc = 0;
6648
6649 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
6650 if (!vregs_isa1200[i]) {
6651 pr_err("%s: vreg_get %s failed (%d)\n",
6652 __func__, vregs_isa1200_name[i], rc);
6653 goto vreg_fail;
6654 }
6655
6656 rc = vreg_on ? vreg_enable(vregs_isa1200[i]) :
6657 vreg_disable(vregs_isa1200[i]);
6658 if (rc < 0) {
6659 pr_err("%s: vreg %s %s failed (%d)\n",
6660 __func__, vregs_isa1200_name[i],
6661 vreg_on ? "enable" : "disable", rc);
6662 goto vreg_fail;
6663 }
6664 }
6665
6666 /* vote for DO buffer */
6667 rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO,
6668 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
6669 if (rc) {
6670 pr_err("%s: unable to %svote for d0 clk\n",
6671 __func__, vreg_on ? "" : "de-");
6672 goto vreg_fail;
6673 }
6674
6675 return 0;
6676
6677vreg_fail:
6678 while (i)
6679 vreg_disable(vregs_isa1200[--i]);
6680 return rc;
6681}
6682
6683static int isa1200_dev_setup(bool enable)
6684{
6685 int i, rc;
6686
6687 if (enable == true) {
6688 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
6689 vregs_isa1200[i] = vreg_get(NULL,
6690 vregs_isa1200_name[i]);
6691 if (IS_ERR(vregs_isa1200[i])) {
6692 pr_err("%s: vreg get %s failed (%ld)\n",
6693 __func__, vregs_isa1200_name[i],
6694 PTR_ERR(vregs_isa1200[i]));
6695 rc = PTR_ERR(vregs_isa1200[i]);
6696 goto vreg_get_fail;
6697 }
6698 rc = vreg_set_level(vregs_isa1200[i],
6699 vregs_isa1200_val[i]);
6700 if (rc) {
6701 pr_err("%s: vreg_set_level() = %d\n",
6702 __func__, rc);
6703 goto vreg_get_fail;
6704 }
6705 }
6706
6707 rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
6708 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
6709 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
6710 if (rc) {
6711 pr_err("%s: Could not configure gpio %d\n",
6712 __func__, HAP_LVL_SHFT_MSM_GPIO);
6713 goto vreg_get_fail;
6714 }
6715
6716 rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
6717 if (rc) {
6718 pr_err("%s: unable to request gpio %d (%d)\n",
6719 __func__, HAP_LVL_SHFT_MSM_GPIO, rc);
6720 goto vreg_get_fail;
6721 }
6722
6723 gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
6724 } else {
6725 for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++)
6726 vreg_put(vregs_isa1200[i]);
6727
6728 gpio_free(HAP_LVL_SHFT_MSM_GPIO);
6729 }
6730
6731 return 0;
6732vreg_get_fail:
6733 while (i)
6734 vreg_put(vregs_isa1200[--i]);
6735 return rc;
6736}
6737static struct isa1200_platform_data isa1200_1_pdata = {
6738 .name = "vibrator",
6739 .power_on = isa1200_power,
6740 .dev_setup = isa1200_dev_setup,
6741 .pwm_ch_id = 1, /*channel id*/
6742 /*gpio to enable haptic*/
6743 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
6744 .max_timeout = 15000,
6745 .mode_ctrl = PWM_GEN_MODE,
6746 .pwm_fd = {
6747 .pwm_div = 256,
6748 },
6749 .is_erm = false,
6750 .smart_en = true,
6751 .ext_clk_en = true,
6752 .chip_en = 1,
6753};
6754
6755static struct i2c_board_info msm_isa1200_board_info[] = {
6756 {
6757 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
6758 .platform_data = &isa1200_1_pdata,
6759 },
6760};
6761
6762
6763static int kp_flip_mpp_config(void)
6764{
6765 return pm8058_mpp_config_digital_in(PM_FLIP_MPP,
6766 PM8058_MPP_DIG_LEVEL_S3, PM_MPP_DIN_TO_INT);
6767}
6768
6769static struct flip_switch_pdata flip_switch_data = {
6770 .name = "kp_flip_switch",
6771 .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP,
6772 .left_key = KEY_OPEN,
6773 .right_key = KEY_CLOSE,
6774 .active_low = 0,
6775 .wakeup = 1,
6776 .flip_mpp_config = kp_flip_mpp_config,
6777};
6778
6779static struct platform_device flip_switch_device = {
6780 .name = "kp_flip_switch",
6781 .id = -1,
6782 .dev = {
6783 .platform_data = &flip_switch_data,
6784 }
6785};
6786
6787static const char *vregs_tma300_name[] = {
6788 "gp6",
6789 "gp7",
6790};
6791
6792static const int vregs_tma300_val[] = {
6793 3050,
6794 1800,
6795};
6796static struct vreg *vregs_tma300[ARRAY_SIZE(vregs_tma300_name)];
6797
6798static int tma300_power(int vreg_on)
6799{
6800 int i, rc = -EINVAL;
6801
6802 for (i = 0; i < ARRAY_SIZE(vregs_tma300_name); i++) {
6803 /* Never disable gp6 for fluid as lcd has a problem with it */
6804 if (!i && !vreg_on)
6805 continue;
6806 if (!vregs_tma300[i]) {
6807 printk(KERN_ERR "%s: vreg_get %s failed (%d)\n",
6808 __func__, vregs_tma300_name[i], rc);
6809 return rc;
6810 }
6811
6812 rc = vreg_on ? vreg_enable(vregs_tma300[i]) :
6813 vreg_disable(vregs_tma300[i]);
6814 if (rc < 0) {
6815 printk(KERN_ERR "%s: vreg %s %s failed (%d)\n",
6816 __func__, vregs_tma300_name[i],
6817 vreg_on ? "enable" : "disable", rc);
6818 return rc;
6819 }
6820 }
6821
6822 return 0;
6823}
6824
6825#define TS_GPIO_IRQ 150
6826
6827static int tma300_dev_setup(bool enable)
6828{
6829 int i, rc;
6830
6831 if (enable) {
6832 /* get voltage sources */
6833 for (i = 0; i < ARRAY_SIZE(vregs_tma300_name); i++) {
6834 vregs_tma300[i] = vreg_get(NULL, vregs_tma300_name[i]);
6835 if (IS_ERR(vregs_tma300[i])) {
6836 pr_err("%s: vreg get %s failed (%ld)\n",
6837 __func__, vregs_tma300_name[i],
6838 PTR_ERR(vregs_tma300[i]));
6839 rc = PTR_ERR(vregs_tma300[i]);
6840 goto vreg_get_fail;
6841 }
6842 rc = vreg_set_level(vregs_tma300[i],
6843 vregs_tma300_val[i]);
6844 if (rc) {
6845 pr_err("%s: vreg_set_level() = %d\n",
6846 __func__, rc);
6847 i++;
6848 goto vreg_get_fail;
6849 }
6850 }
6851
6852 /* enable interrupt gpio */
6853 rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
6854 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
6855 if (rc) {
6856 pr_err("%s: Could not configure gpio %d\n",
6857 __func__, TS_GPIO_IRQ);
6858 goto vreg_get_fail;
6859 }
6860
6861 /* virtual keys */
6862 tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
6863 properties_kobj = kobject_create_and_add("board_properties",
6864 NULL);
6865 if (!properties_kobj) {
6866 pr_err("%s: failed to create a kobject"
6867 "for board_properites\n", __func__);
6868 rc = -ENOMEM;
6869 goto vreg_get_fail;
6870 }
6871 rc = sysfs_create_group(properties_kobj,
6872 &tma300_properties_attr_group);
6873 if (rc) {
6874 pr_err("%s: failed to create a sysfs entry %s\n",
6875 __func__, tma300_vkeys_attr.attr.name);
6876 kobject_put(properties_kobj);
6877 goto vreg_get_fail;
6878 }
6879 } else {
6880 /* put voltage sources */
6881 for (i = 0; i < ARRAY_SIZE(vregs_tma300_name); i++)
6882 vreg_put(vregs_tma300[i]);
6883 /* destroy virtual keys */
6884 if (properties_kobj) {
6885 sysfs_remove_group(properties_kobj,
6886 &tma300_properties_attr_group);
6887 kobject_put(properties_kobj);
6888 }
6889 }
6890 return 0;
6891
6892vreg_get_fail:
6893 while (i)
6894 vreg_put(vregs_tma300[--i]);
6895 return rc;
6896}
6897
6898static struct cy8c_ts_platform_data cy8ctma300_pdata = {
6899 .power_on = tma300_power,
6900 .dev_setup = tma300_dev_setup,
6901 .ts_name = "msm_tma300_ts",
6902 .dis_min_x = 0,
6903 .dis_max_x = 479,
6904 .dis_min_y = 0,
6905 .dis_max_y = 799,
6906 .res_x = 479,
6907 .res_y = 1009,
6908 .min_tid = 1,
6909 .max_tid = 255,
6910 .min_touch = 0,
6911 .max_touch = 255,
6912 .min_width = 0,
6913 .max_width = 255,
6914 .invert_y = 1,
6915 .nfingers = 4,
6916 .irq_gpio = TS_GPIO_IRQ,
6917 .resout_gpio = -1,
6918};
6919
6920static struct i2c_board_info cy8ctma300_board_info[] = {
6921 {
6922 I2C_BOARD_INFO("cy8ctma300", 0x2),
6923 .platform_data = &cy8ctma300_pdata,
6924 }
6925};
6926
Daniel Walker8d747cd2010-02-25 11:37:43 -08006927static void __init msm7x30_init(void)
6928{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006929 int rc;
6930 unsigned smem_size;
6931 uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56,
6932 0,
6933 GPIO_CFG_OUTPUT,
6934 GPIO_CFG_NO_PULL,
6935 GPIO_CFG_2MA);
6936 uint32_t soc_version = 0;
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05306937
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006938 if (socinfo_init() < 0)
6939 printk(KERN_ERR "%s: socinfo_init() failed!\n",
6940 __func__);
6941
6942 soc_version = socinfo_get_version();
6943
6944 msm7x30_clock_init();
6945#ifdef CONFIG_SERIAL_MSM_CONSOLE
6946 msm7x30_init_uart2();
6947#endif
6948 msm_spm_init(&msm_spm_data, 1);
6949 msm_acpu_clock_init(&msm7x30_clock_data);
6950 if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid())
6951 msm7x30_cfg_smsc911x();
6952
6953#ifdef CONFIG_USB_MSM_OTG_72K
6954 if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 &&
6955 SOCINFO_VERSION_MINOR(soc_version) >= 1) {
6956 pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
6957 msm_otg_pdata.ldo_set_voltage = 0;
6958 }
6959
6960 msm_device_otg.dev.platform_data = &msm_otg_pdata;
6961#ifdef CONFIG_USB_GADGET
6962 msm_otg_pdata.swfi_latency =
6963 msm_pm_data
6964 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
6965 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
6966#endif
6967#endif
6968 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
6969 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
6970#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6971 msm_device_tsif.dev.platform_data = &tsif_platform_data;
6972#endif
6973 if (machine_is_msm7x30_fluid()) {
6974 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
6975 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
6976 } else {
6977 msm_adc_pdata.dev_names = msm_adc_surf_device_names;
6978 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names);
6979 }
6980
6981 platform_add_devices(msm_footswitch_devices,
6982 msm_num_footswitch_devices);
Daniel Walker8d747cd2010-02-25 11:37:43 -08006983 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006984#ifdef CONFIG_USB_EHCI_MSM_72K
6985 msm_add_host(0, &msm_usb_host_pdata);
6986#endif
6987 msm7x30_init_mmc();
6988 msm7x30_init_nand();
6989 msm_qsd_spi_init();
6990
6991#ifdef CONFIG_SPI_QSD
6992 if (machine_is_msm7x30_fluid())
6993 spi_register_board_info(lcdc_sharp_spi_board_info,
6994 ARRAY_SIZE(lcdc_sharp_spi_board_info));
6995 else
6996 spi_register_board_info(lcdc_toshiba_spi_board_info,
6997 ARRAY_SIZE(lcdc_toshiba_spi_board_info));
6998#endif
6999
7000 msm_fb_add_devices();
7001 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
7002 msm_device_i2c_init();
7003 msm_device_i2c_2_init();
7004 qup_device_i2c_init();
7005 buses_init();
7006 msm7x30_init_marimba();
7007#ifdef CONFIG_MSM7KV2_AUDIO
7008 snddev_poweramp_gpio_init();
7009 aux_pcm_gpio_init();
7010#endif
7011
7012 i2c_register_board_info(0, msm_i2c_board_info,
7013 ARRAY_SIZE(msm_i2c_board_info));
7014
7015 if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid())
7016 marimba_pdata.tsadc = &marimba_tsadc_pdata;
7017
7018 if (machine_is_msm7x30_fluid())
7019 i2c_register_board_info(0, cy8info,
7020 ARRAY_SIZE(cy8info));
7021#ifdef CONFIG_BOSCH_BMA150
7022 if (machine_is_msm7x30_fluid())
7023 i2c_register_board_info(0, bma150_board_info,
7024 ARRAY_SIZE(bma150_board_info));
7025#endif
7026
7027 i2c_register_board_info(2, msm_marimba_board_info,
7028 ARRAY_SIZE(msm_marimba_board_info));
7029
7030 i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info,
7031 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info));
7032
7033 i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
7034 ARRAY_SIZE(msm_camera_boardinfo));
7035
7036 bt_power_init();
7037#ifdef CONFIG_I2C_SSBI
7038 msm_device_ssbi6.dev.platform_data = &msm_i2c_ssbi6_pdata;
7039 msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
7040#endif
7041 if (machine_is_msm7x30_fluid())
7042 i2c_register_board_info(0, msm_isa1200_board_info,
7043 ARRAY_SIZE(msm_isa1200_board_info));
7044
7045#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
7046 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
7047 if (machine_is_msm8x55_svlte_ffa())
7048 i2c_register_board_info(2, tsc_i2c_board_info,
7049 ARRAY_SIZE(tsc_i2c_board_info));
7050#endif
7051
7052 if (machine_is_msm7x30_surf())
7053 platform_device_register(&flip_switch_device);
7054 pmic8058_leds_init();
7055
7056 if (machine_is_msm7x30_fluid()) {
7057 /* Initialize platform data for fluid v2 hardware */
7058 if (SOCINFO_VERSION_MAJOR(
7059 socinfo_get_platform_version()) == 2) {
7060 cy8ctma300_pdata.res_y = 920;
7061 cy8ctma300_pdata.invert_y = 0;
7062 }
7063 i2c_register_board_info(0, cy8ctma300_board_info,
7064 ARRAY_SIZE(cy8ctma300_board_info));
7065 }
7066
7067 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
7068 rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE);
7069 if (rc)
7070 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
7071 __func__, usb_hub_gpio_cfg_value, rc);
7072 }
7073
7074 boot_reason = *(unsigned int *)
7075 (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
7076 printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
7077}
7078
7079static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
7080static int __init pmem_sf_size_setup(char *p)
7081{
7082 pmem_sf_size = memparse(p, NULL);
7083 return 0;
7084}
7085early_param("pmem_sf_size", pmem_sf_size_setup);
7086
7087static unsigned fb_size = MSM_FB_SIZE;
7088static int __init fb_size_setup(char *p)
7089{
7090 fb_size = memparse(p, NULL);
7091 return 0;
7092}
7093early_param("fb_size", fb_size_setup);
7094
7095static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
7096static int __init pmem_adsp_size_setup(char *p)
7097{
7098 pmem_adsp_size = memparse(p, NULL);
7099 return 0;
7100}
7101early_param("pmem_adsp_size", pmem_adsp_size_setup);
7102
7103static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE;
7104static int __init fluid_pmem_adsp_size_setup(char *p)
7105{
7106 fluid_pmem_adsp_size = memparse(p, NULL);
7107 return 0;
7108}
7109early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup);
7110
7111static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
7112static int __init pmem_audio_size_setup(char *p)
7113{
7114 pmem_audio_size = memparse(p, NULL);
7115 return 0;
7116}
7117early_param("pmem_audio_size", pmem_audio_size_setup);
7118
7119static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE;
7120static int __init pmem_kernel_ebi0_size_setup(char *p)
7121{
7122 pmem_kernel_ebi0_size = memparse(p, NULL);
7123 return 0;
7124}
7125early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
7126
7127static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
7128 [MEMTYPE_SMI] = {
7129 },
7130 [MEMTYPE_EBI0] = {
7131 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7132 },
7133 [MEMTYPE_EBI1] = {
7134 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7135 },
7136};
7137
7138static void __init size_pmem_devices(void)
7139{
7140#ifdef CONFIG_ANDROID_PMEM
7141 unsigned long size;
7142
7143 if machine_is_msm7x30_fluid()
7144 size = fluid_pmem_adsp_size;
7145 else
7146 size = pmem_adsp_size;
7147 android_pmem_adsp_pdata.size = size;
7148 android_pmem_audio_pdata.size = pmem_audio_size;
7149 android_pmem_pdata.size = pmem_sf_size;
7150#endif
7151}
7152
7153static void __init reserve_memory_for(struct android_pmem_platform_data *p)
7154{
7155 msm7x30_reserve_table[p->memory_type].size += p->size;
7156}
7157
7158static void __init reserve_pmem_memory(void)
7159{
7160#ifdef CONFIG_ANDROID_PMEM
7161 reserve_memory_for(&android_pmem_adsp_pdata);
7162 reserve_memory_for(&android_pmem_audio_pdata);
7163 reserve_memory_for(&android_pmem_pdata);
7164 msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
7165#endif
7166}
7167
7168static void __init msm7x30_calculate_reserve_sizes(void)
7169{
7170 size_pmem_devices();
7171 reserve_pmem_memory();
7172}
7173
7174static int msm7x30_paddr_to_memtype(unsigned int paddr)
7175{
7176 if (paddr < 0x40000000)
7177 return MEMTYPE_EBI0;
7178 if (paddr >= 0x40000000 && paddr < 0x80000000)
7179 return MEMTYPE_EBI1;
7180 return MEMTYPE_NONE;
7181}
7182
7183static struct reserve_info msm7x30_reserve_info __initdata = {
7184 .memtype_reserve_table = msm7x30_reserve_table,
7185 .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes,
7186 .paddr_to_memtype = msm7x30_paddr_to_memtype,
7187};
7188
7189static void __init msm7x30_reserve(void)
7190{
7191 reserve_info = &msm7x30_reserve_info;
7192 msm_reserve();
7193}
7194
7195static void __init msm7x30_allocate_memory_regions(void)
7196{
7197 void *addr;
7198 unsigned long size;
7199
7200 size = fb_size ? : MSM_FB_SIZE;
7201 addr = alloc_bootmem_align(size, 0x1000);
7202 msm_fb_resources[0].start = __pa(addr);
7203 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
7204 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
7205 size, addr, __pa(addr));
Daniel Walker8d747cd2010-02-25 11:37:43 -08007206}
7207
7208static void __init msm7x30_map_io(void)
7209{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007210 msm_shared_ram_phys = 0x00100000;
Daniel Walker8d747cd2010-02-25 11:37:43 -08007211 msm_map_msm7x30_io();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007212}
7213
7214static void __init msm7x30_init_early(void)
7215{
7216 msm7x30_allocate_memory_regions();
Daniel Walker8d747cd2010-02-25 11:37:43 -08007217}
7218
7219MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00007220 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007221 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007222 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007223 .init_irq = msm7x30_init_irq,
7224 .init_machine = msm7x30_init,
7225 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007226 .init_early = msm7x30_init_early,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007227MACHINE_END
7228
7229MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00007230 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007231 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007232 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007233 .init_irq = msm7x30_init_irq,
7234 .init_machine = msm7x30_init,
7235 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007236 .init_early = msm7x30_init_early,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007237MACHINE_END
7238
7239MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
Russell Kingb75c1782011-01-04 19:03:16 +00007240 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007241 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007242 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007243 .init_irq = msm7x30_init_irq,
7244 .init_machine = msm7x30_init,
7245 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007246 .init_early = msm7x30_init_early,
7247MACHINE_END
7248
7249MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
7250 .boot_params = PHYS_OFFSET + 0x100,
7251 .map_io = msm7x30_map_io,
7252 .reserve = msm7x30_reserve,
7253 .init_irq = msm7x30_init_irq,
7254 .init_machine = msm7x30_init,
7255 .timer = &msm_timer,
7256 .init_early = msm7x30_init_early,
7257MACHINE_END
7258
7259MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA")
7260 .boot_params = PHYS_OFFSET + 0x100,
7261 .map_io = msm7x30_map_io,
7262 .reserve = msm7x30_reserve,
7263 .init_irq = msm7x30_init_irq,
7264 .init_machine = msm7x30_init,
7265 .timer = &msm_timer,
7266 .init_early = msm7x30_init_early,
7267MACHINE_END
7268MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
7269 .boot_params = PHYS_OFFSET + 0x100,
7270 .map_io = msm7x30_map_io,
7271 .reserve = msm7x30_reserve,
7272 .init_irq = msm7x30_init_irq,
7273 .init_machine = msm7x30_init,
7274 .timer = &msm_timer,
7275 .init_early = msm7x30_init_early,
7276MACHINE_END
7277MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA")
7278 .boot_params = PHYS_OFFSET + 0x100,
7279 .map_io = msm7x30_map_io,
7280 .reserve = msm7x30_reserve,
7281 .init_irq = msm7x30_init_irq,
7282 .init_machine = msm7x30_init,
7283 .timer = &msm_timer,
7284 .init_early = msm7x30_init_early,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007285MACHINE_END