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