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