blob: 857c88adb996e359d64f35ae6316fe89d9c82e85 [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>
Justin Paupore3f40f342011-08-10 18:52:16 -070040#include <linux/regulator/consumer.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080041
42#include <asm/mach-types.h>
43#include <asm/mach/arch.h>
44#include <asm/setup.h>
45
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046#include <mach/mpp.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080047#include <mach/board.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070048#include <mach/camera.h>
49#include <mach/memory.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080050#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051#include <mach/msm_hsusb.h>
52#include <mach/rpc_hsusb.h>
53#include <mach/msm_spi.h>
54#include <mach/qdsp5v2/msm_lpa.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080055#include <mach/dma.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056#include <linux/android_pmem.h>
57#include <linux/input/msm_ts.h>
58#include <mach/pmic.h>
59#include <mach/rpc_pmapp.h>
60#include <mach/qdsp5v2/aux_pcm.h>
61#include <mach/qdsp5v2/mi2s.h>
62#include <mach/qdsp5v2/audio_dev_ctl.h>
63#include <mach/msm_battery.h>
64#include <mach/rpc_server_handset.h>
65#include <mach/msm_tsif.h>
66#include <mach/socinfo.h>
67#include <mach/msm_memtypes.h>
68#include <linux/cyttsp.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080069
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070070#include <asm/mach/mmc.h>
71#include <asm/mach/flash.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080072#include <mach/vreg.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070073#include <linux/platform_data/qcom_crypto_device.h>
74
Daniel Walker8d747cd2010-02-25 11:37:43 -080075#include "devices.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076#include "timer.h"
77#ifdef CONFIG_USB_G_ANDROID
78#include <linux/usb/android.h>
79#include <mach/usbdiag.h>
80#endif
81#include "pm.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -060082#include "pm-boot.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070083#include "spm.h"
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070084#include "acpuclock.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070085#include <mach/dal_axi.h>
86#include <mach/msm_serial_hs.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070087#include <mach/qdsp5v2/mi2s.h>
88#include <mach/qdsp5v2/audio_dev_ctl.h>
89#include <mach/sdio_al.h>
90#include "smd_private.h"
91#include <linux/bma150.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080092
Justin Paupore637a25d2011-07-14 17:11:04 -070093#include "board-msm7x30-regulator.h"
94
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095#define MSM_PMEM_SF_SIZE 0x1700000
96#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
97#define MSM_FB_SIZE 0x780000
98#else
99#define MSM_FB_SIZE 0x500000
100#endif
101#define MSM_PMEM_ADSP_SIZE 0x1E00000
102#define MSM_FLUID_PMEM_ADSP_SIZE 0x2800000
103#define PMEM_KERNEL_EBI0_SIZE 0x600000
104#define MSM_PMEM_AUDIO_SIZE 0x200000
Daniel Walker90e37c52010-05-12 14:24:15 -0700105
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700106#define PMIC_GPIO_INT 27
107#define PMIC_VREG_WLAN_LEVEL 2900
108#define PMIC_GPIO_SD_DET 36
109#define PMIC_GPIO_SDC4_EN_N 17 /* PMIC GPIO Number 18 */
110#define PMIC_GPIO_HDMI_5V_EN_V3 32 /* PMIC GPIO for V3 H/W */
111#define PMIC_GPIO_HDMI_5V_EN_V2 39 /* PMIC GPIO for V2 H/W */
112
113#define ADV7520_I2C_ADDR 0x39
114
115#define FPGA_SDCC_STATUS 0x8E0001A8
116
117#define FPGA_OPTNAV_GPIO_ADDR 0x8E000026
118#define OPTNAV_I2C_SLAVE_ADDR (0xB0 >> 1)
119#define OPTNAV_IRQ 20
120#define OPTNAV_CHIP_SELECT 19
121
122/* Macros assume PMIC GPIOs start at 0 */
123#define PM8058_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio + NR_GPIO_IRQS)
124#define PM8058_GPIO_SYS_TO_PM(sys_gpio) (sys_gpio - NR_GPIO_IRQS)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530125#define PM8058_MPP_BASE PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS)
126#define PM8058_MPP_PM_TO_SYS(pm_gpio) (pm_gpio + PM8058_MPP_BASE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700127
128#define PMIC_GPIO_FLASH_BOOST_ENABLE 15 /* PMIC GPIO Number 16 */
129#define PMIC_GPIO_HAP_ENABLE 16 /* PMIC GPIO Number 17 */
130
131#define PMIC_GPIO_WLAN_EXT_POR 22 /* PMIC GPIO NUMBER 23 */
132
133#define BMA150_GPIO_INT 1
134
135#define HAP_LVL_SHFT_MSM_GPIO 24
136
137#define PMIC_GPIO_QUICKVX_CLK 37 /* PMIC GPIO 38 */
138
139#define PM_FLIP_MPP 5 /* PMIC MPP 06 */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530140
141struct pm8xxx_gpio_init_info {
142 unsigned gpio;
143 struct pm_gpio config;
144};
145
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700146static int pm8058_gpios_init(void)
147{
148 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700149
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530150 struct pm8xxx_gpio_init_info sdc4_en = {
151 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_EN_N),
152 {
153 .direction = PM_GPIO_DIR_OUT,
154 .pull = PM_GPIO_PULL_NO,
155 .vin_sel = PM8058_GPIO_VIN_L5,
156 .function = PM_GPIO_FUNC_NORMAL,
157 .inv_int_pol = 0,
158 .out_strength = PM_GPIO_STRENGTH_LOW,
159 .output_value = 0,
160 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700161 };
162
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530163 struct pm8xxx_gpio_init_info haptics_enable = {
164 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
165 {
166 .direction = PM_GPIO_DIR_OUT,
167 .pull = PM_GPIO_PULL_NO,
168 .out_strength = PM_GPIO_STRENGTH_HIGH,
169 .function = PM_GPIO_FUNC_NORMAL,
170 .inv_int_pol = 0,
171 .vin_sel = 2,
172 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
173 .output_value = 0,
174 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700175 };
176
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530177 struct pm8xxx_gpio_init_info hdmi_5V_en = {
178 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HDMI_5V_EN_V3),
179 {
180 .direction = PM_GPIO_DIR_OUT,
181 .pull = PM_GPIO_PULL_NO,
182 .vin_sel = PM8058_GPIO_VIN_VPH,
183 .function = PM_GPIO_FUNC_NORMAL,
184 .out_strength = PM_GPIO_STRENGTH_LOW,
185 .output_value = 0,
186 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700187 };
188
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530189 struct pm8xxx_gpio_init_info flash_boost_enable = {
190 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE),
191 {
192 .direction = PM_GPIO_DIR_OUT,
193 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
194 .output_value = 0,
195 .pull = PM_GPIO_PULL_NO,
196 .vin_sel = PM8058_GPIO_VIN_S3,
197 .out_strength = PM_GPIO_STRENGTH_HIGH,
198 .function = PM_GPIO_FUNC_2,
199 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700200 };
201
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530202 struct pm8xxx_gpio_init_info gpio23 = {
203 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_WLAN_EXT_POR),
204 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700205 .direction = PM_GPIO_DIR_OUT,
206 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
207 .output_value = 0,
208 .pull = PM_GPIO_PULL_NO,
209 .vin_sel = 2,
210 .out_strength = PM_GPIO_STRENGTH_LOW,
211 .function = PM_GPIO_FUNC_NORMAL,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530212 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700213 };
214
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700215#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530216 struct pm8xxx_gpio_init_info sdcc_det = {
217 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1),
218 {
219 .direction = PM_GPIO_DIR_IN,
220 .pull = PM_GPIO_PULL_UP_1P5,
221 .vin_sel = 2,
222 .function = PM_GPIO_FUNC_NORMAL,
223 .inv_int_pol = 0,
224 },
225 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700226
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530227 if (machine_is_msm7x30_fluid())
228 sdcc_det.config.inv_int_pol = 1;
229
230 rc = pm8xxx_gpio_config(sdcc_det.gpio, &sdcc_det.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700231 if (rc) {
232 pr_err("%s PMIC_GPIO_SD_DET config failed\n", __func__);
233 return rc;
234 }
235#endif
236
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530237 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
238 machine_is_msm7x30_fluid())
239 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V2;
240 else
241 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V3;
242
243 hdmi_5V_en.gpio = PM8058_GPIO_PM_TO_SYS(hdmi_5V_en.gpio);
244
245 rc = pm8xxx_gpio_config(hdmi_5V_en.gpio, &hdmi_5V_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700246 if (rc) {
247 pr_err("%s PMIC_GPIO_HDMI_5V_EN config failed\n", __func__);
248 return rc;
249 }
250
251 /* Deassert GPIO#23 (source for Ext_POR on WLAN-Volans) */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530252 rc = pm8xxx_gpio_config(gpio23.gpio, &gpio23.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700253 if (rc) {
254 pr_err("%s PMIC_GPIO_WLAN_EXT_POR config failed\n", __func__);
255 return rc;
256 }
257
258 if (machine_is_msm7x30_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530259 /* Haptics gpio */
260 rc = pm8xxx_gpio_config(haptics_enable.gpio,
261 &haptics_enable.config);
262 if (rc) {
263 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
264 haptics_enable.gpio);
265 return rc;
266 }
267 /* Flash boost gpio */
268 rc = pm8xxx_gpio_config(flash_boost_enable.gpio,
269 &flash_boost_enable.config);
270 if (rc) {
271 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
272 flash_boost_enable.gpio);
273 return rc;
274 }
275 /* SCD4 gpio */
276 rc = pm8xxx_gpio_config(sdc4_en.gpio, &sdc4_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700277 if (rc) {
278 pr_err("%s PMIC_GPIO_SDC4_EN_N config failed\n",
279 __func__);
280 return rc;
281 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530282 rc = gpio_request(sdc4_en.gpio, "sdc4_en");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700283 if (rc) {
284 pr_err("%s PMIC_GPIO_SDC4_EN_N gpio_request failed\n",
285 __func__);
286 return rc;
287 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530288 gpio_set_value_cansleep(sdc4_en.gpio, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700289 }
290
291 return 0;
292}
293
Justin Paupore637a25d2011-07-14 17:11:04 -0700294/* Regulator API support */
295
296#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
297static struct platform_device msm_proccomm_regulator_dev = {
298 .name = PROCCOMM_REGULATOR_DEV_NAME,
299 .id = -1,
300 .dev = {
301 .platform_data = &msm7x30_proccomm_regulator_data
302 }
303};
304#endif
305
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700306/*virtual key support */
307static ssize_t tma300_vkeys_show(struct kobject *kobj,
308 struct kobj_attribute *attr, char *buf)
309{
310 return sprintf(buf,
311 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":50:842:80:100"
312 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":170:842:80:100"
313 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":290:842:80:100"
314 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":410:842:80:100"
315 "\n");
316}
317
318static struct kobj_attribute tma300_vkeys_attr = {
319 .attr = {
320 .mode = S_IRUGO,
321 },
322 .show = &tma300_vkeys_show,
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530323};
324
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700325static struct attribute *tma300_properties_attrs[] = {
326 &tma300_vkeys_attr.attr,
327 NULL
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530328};
329
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700330static struct attribute_group tma300_properties_attr_group = {
331 .attrs = tma300_properties_attrs,
332};
333
334static struct kobject *properties_kobj;
Justin Paupore3f40f342011-08-10 18:52:16 -0700335static struct regulator_bulk_data cyttsp_regs[] = {
336 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
337 { .supply = "ldo15", .min_uV = 3050000, .max_uV = 3100000 },
338};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700339
340#define CYTTSP_TS_GPIO_IRQ 150
341static int cyttsp_platform_init(struct i2c_client *client)
342{
343 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700344
Justin Paupore3f40f342011-08-10 18:52:16 -0700345 rc = regulator_bulk_get(NULL, ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700346
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700347 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700348 pr_err("%s: could not get regulators: %d\n", __func__, rc);
349 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700350 }
351
Justin Paupore3f40f342011-08-10 18:52:16 -0700352 rc = regulator_bulk_set_voltage(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
353
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700354 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700355 pr_err("%s: could not set regulator voltages: %d\n", __func__,
356 rc);
357 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700358 }
359
Justin Paupore3f40f342011-08-10 18:52:16 -0700360 rc = regulator_bulk_enable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700361
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700362 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700363 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
364 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700365 }
366
367 /* check this device active by reading first byte/register */
368 rc = i2c_smbus_read_byte_data(client, 0x01);
369 if (rc < 0) {
370 pr_err("%s: i2c sanity check failed\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -0700371 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700372 }
373
374 rc = gpio_tlmm_config(GPIO_CFG(CYTTSP_TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
375 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
376 if (rc) {
377 pr_err("%s: Could not configure gpio %d\n",
378 __func__, CYTTSP_TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -0700379 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700380 }
381
382 /* virtual keys */
383 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
384 properties_kobj = kobject_create_and_add("board_properties",
385 NULL);
386 if (properties_kobj)
387 rc = sysfs_create_group(properties_kobj,
388 &tma300_properties_attr_group);
389 if (!properties_kobj || rc)
390 pr_err("%s: failed to create board_properties\n",
391 __func__);
392
393 return CY_OK;
394
Justin Paupore3f40f342011-08-10 18:52:16 -0700395regs_disable:
396 regulator_bulk_disable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
397regs_free:
398 regulator_bulk_free(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
399out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700400 return rc;
401}
402
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530403/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
404static int cyttsp_platform_suspend(struct i2c_client *client)
405{
406 msleep(20);
407
408 return CY_OK;
409}
410
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700411static int cyttsp_platform_resume(struct i2c_client *client)
412{
413 /* add any special code to strobe a wakeup pin or chip reset */
414 mdelay(10);
415
416 return CY_OK;
417}
418
419static struct cyttsp_platform_data cyttsp_data = {
420 .fw_fname = "cyttsp_7630_fluid.hex",
421 .panel_maxx = 479,
422 .panel_maxy = 799,
423 .disp_maxx = 469,
424 .disp_maxy = 799,
425 .disp_minx = 10,
426 .disp_miny = 0,
427 .flags = 0,
428 .gen = CY_GEN3, /* or */
429 .use_st = CY_USE_ST,
430 .use_mt = CY_USE_MT,
431 .use_hndshk = CY_SEND_HNDSHK,
432 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +0530433 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700434 .use_gestures = CY_USE_GESTURES,
435 /* activate up to 4 groups
436 * and set active distance
437 */
438 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
439 CY_GEST_GRP3 | CY_GEST_GRP4 |
440 CY_ACT_DIST,
441 /* change act_intrvl to customize the Active power state
442 * scanning/processing refresh interval for Operating mode
443 */
444 .act_intrvl = CY_ACT_INTRVL_DFLT,
445 /* change tch_tmout to customize the touch timeout for the
446 * Active power state for Operating mode
447 */
448 .tch_tmout = CY_TCH_TMOUT_DFLT,
449 /* change lp_intrvl to customize the Low Power power state
450 * scanning/processing refresh interval for Operating mode
451 */
452 .lp_intrvl = CY_LP_INTRVL_DFLT,
453 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530454 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700455 .init = cyttsp_platform_init,
456 .sleep_gpio = -1,
457 .resout_gpio = -1,
458 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
Mohan Pallaka49c37d62011-08-01 11:52:00 +0530459 .correct_fw_ver = 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700460};
461
462static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
463{
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530464 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700465 .direction = PM_GPIO_DIR_OUT,
466 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
467 .output_value = 0,
468 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530469 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700470 .out_strength = PM_GPIO_STRENGTH_HIGH,
471 .function = PM_GPIO_FUNC_2,
472 };
473 int rc = -EINVAL;
474 int id, mode, max_mA;
475
476 id = mode = max_mA = 0;
477 switch (ch) {
478 case 0:
479 case 1:
480 case 2:
481 if (on) {
482 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530483 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
484 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700485 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530486 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700487 __func__, id, rc);
488 }
489 break;
490
491 case 3:
492 id = PM_PWM_LED_KPD;
493 mode = PM_PWM_CONF_DTEST3;
494 max_mA = 200;
495 break;
496
497 case 4:
498 id = PM_PWM_LED_0;
499 mode = PM_PWM_CONF_PWM1;
500 max_mA = 40;
501 break;
502
503 case 5:
504 id = PM_PWM_LED_2;
505 mode = PM_PWM_CONF_PWM2;
506 max_mA = 40;
507 break;
508
509 case 6:
510 id = PM_PWM_LED_FLASH;
511 mode = PM_PWM_CONF_DTEST3;
512 max_mA = 200;
513 break;
514
515 default:
516 break;
517 }
518
519 if (ch >= 3 && ch <= 6) {
520 if (!on) {
521 mode = PM_PWM_CONF_NONE;
522 max_mA = 0;
523 }
524 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
525 if (rc)
526 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
527 __func__, ch, rc);
528 }
529
530 return rc;
531}
532
533static int pm8058_pwm_enable(struct pwm_device *pwm, int ch, int on)
534{
535 int rc;
536
537 switch (ch) {
538 case 7:
539 rc = pm8058_pwm_set_dtest(pwm, on);
540 if (rc)
541 pr_err("%s: pwm_set_dtest(%d): rc=%d\n",
542 __func__, on, rc);
543 break;
544 default:
545 rc = -EINVAL;
546 break;
547 }
548 return rc;
549}
550
551static const unsigned int fluid_keymap[] = {
552 KEY(0, 0, KEY_7),
553 KEY(0, 1, KEY_ENTER),
554 KEY(0, 2, KEY_UP),
555 /* drop (0,3) as it always shows up in pair with(0,2) */
556 KEY(0, 4, KEY_DOWN),
557
558 KEY(1, 0, KEY_CAMERA_SNAPSHOT),
559 KEY(1, 1, KEY_SELECT),
560 KEY(1, 2, KEY_1),
561 KEY(1, 3, KEY_VOLUMEUP),
562 KEY(1, 4, KEY_VOLUMEDOWN),
563};
564
565static const unsigned int surf_keymap[] = {
566 KEY(0, 0, KEY_7),
567 KEY(0, 1, KEY_DOWN),
568 KEY(0, 2, KEY_UP),
569 KEY(0, 3, KEY_RIGHT),
570 KEY(0, 4, KEY_ENTER),
571 KEY(0, 5, KEY_L),
572 KEY(0, 6, KEY_BACK),
573 KEY(0, 7, KEY_M),
574
575 KEY(1, 0, KEY_LEFT),
576 KEY(1, 1, KEY_SEND),
577 KEY(1, 2, KEY_1),
578 KEY(1, 3, KEY_4),
579 KEY(1, 4, KEY_CLEAR),
580 KEY(1, 5, KEY_MSDOS),
581 KEY(1, 6, KEY_SPACE),
582 KEY(1, 7, KEY_COMMA),
583
584 KEY(2, 0, KEY_6),
585 KEY(2, 1, KEY_5),
586 KEY(2, 2, KEY_8),
587 KEY(2, 3, KEY_3),
588 KEY(2, 4, KEY_NUMERIC_STAR),
589 KEY(2, 5, KEY_UP),
590 KEY(2, 6, KEY_DOWN), /* SYN */
591 KEY(2, 7, KEY_LEFTSHIFT),
592
593 KEY(3, 0, KEY_9),
594 KEY(3, 1, KEY_NUMERIC_POUND),
595 KEY(3, 2, KEY_0),
596 KEY(3, 3, KEY_2),
597 KEY(3, 4, KEY_SLEEP),
598 KEY(3, 5, KEY_F1),
599 KEY(3, 6, KEY_F2),
600 KEY(3, 7, KEY_F3),
601
602 KEY(4, 0, KEY_BACK),
603 KEY(4, 1, KEY_HOME),
604 KEY(4, 2, KEY_MENU),
605 KEY(4, 3, KEY_VOLUMEUP),
606 KEY(4, 4, KEY_VOLUMEDOWN),
607 KEY(4, 5, KEY_F4),
608 KEY(4, 6, KEY_F5),
609 KEY(4, 7, KEY_F6),
610
611 KEY(5, 0, KEY_R),
612 KEY(5, 1, KEY_T),
613 KEY(5, 2, KEY_Y),
614 KEY(5, 3, KEY_LEFTALT),
615 KEY(5, 4, KEY_KPENTER),
616 KEY(5, 5, KEY_Q),
617 KEY(5, 6, KEY_W),
618 KEY(5, 7, KEY_E),
619
620 KEY(6, 0, KEY_F),
621 KEY(6, 1, KEY_G),
622 KEY(6, 2, KEY_H),
623 KEY(6, 3, KEY_CAPSLOCK),
624 KEY(6, 4, KEY_PAGEUP),
625 KEY(6, 5, KEY_A),
626 KEY(6, 6, KEY_S),
627 KEY(6, 7, KEY_D),
628
629 KEY(7, 0, KEY_V),
630 KEY(7, 1, KEY_B),
631 KEY(7, 2, KEY_N),
632 KEY(7, 3, KEY_MENU), /* REVISIT - SYM */
633 KEY(7, 4, KEY_PAGEDOWN),
634 KEY(7, 5, KEY_Z),
635 KEY(7, 6, KEY_X),
636 KEY(7, 7, KEY_C),
637
638 KEY(8, 0, KEY_P),
639 KEY(8, 1, KEY_J),
640 KEY(8, 2, KEY_K),
641 KEY(8, 3, KEY_INSERT),
642 KEY(8, 4, KEY_LINEFEED),
643 KEY(8, 5, KEY_U),
644 KEY(8, 6, KEY_I),
645 KEY(8, 7, KEY_O),
646
647 KEY(9, 0, KEY_4),
648 KEY(9, 1, KEY_5),
649 KEY(9, 2, KEY_6),
650 KEY(9, 3, KEY_7),
651 KEY(9, 4, KEY_8),
652 KEY(9, 5, KEY_1),
653 KEY(9, 6, KEY_2),
654 KEY(9, 7, KEY_3),
655
656 KEY(10, 0, KEY_F7),
657 KEY(10, 1, KEY_F8),
658 KEY(10, 2, KEY_F9),
659 KEY(10, 3, KEY_F10),
660 KEY(10, 4, KEY_FN),
661 KEY(10, 5, KEY_9),
662 KEY(10, 6, KEY_0),
663 KEY(10, 7, KEY_DOT),
664
665 KEY(11, 0, KEY_LEFTCTRL),
666 KEY(11, 1, KEY_F11), /* START */
667 KEY(11, 2, KEY_ENTER),
668 KEY(11, 3, KEY_SEARCH),
669 KEY(11, 4, KEY_DELETE),
670 KEY(11, 5, KEY_RIGHT),
671 KEY(11, 6, KEY_LEFT),
672 KEY(11, 7, KEY_RIGHTSHIFT),
673};
674
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700675static struct matrix_keymap_data surf_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530676 .keymap_size = ARRAY_SIZE(surf_keymap),
677 .keymap = surf_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700678};
679
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530680static struct pm8xxx_keypad_platform_data surf_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700681 .input_name = "surf_keypad",
682 .input_phys_device = "surf_keypad/input0",
683 .num_rows = 12,
684 .num_cols = 8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530685 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
686 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
687 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700688 .scan_delay_ms = 32,
689 .row_hold_ns = 91500,
690 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530691 .keymap_data = &surf_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700692};
693
694static struct matrix_keymap_data fluid_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530695 .keymap_size = ARRAY_SIZE(fluid_keymap),
696 .keymap = fluid_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700697};
698
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530699static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700700 .input_name = "fluid-keypad",
701 .input_phys_device = "fluid-keypad/input0",
702 .num_rows = 5,
703 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530704 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
705 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
706 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700707 .scan_delay_ms = 32,
708 .row_hold_ns = 91500,
709 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530710 .keymap_data = &fluid_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700711};
712
713static struct pm8058_pwm_pdata pm8058_pwm_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530714 .config = pm8058_pwm_config,
715 .enable = pm8058_pwm_enable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700716};
717
718static struct pmic8058_led pmic8058_ffa_leds[] = {
719 [0] = {
720 .name = "keyboard-backlight",
721 .max_brightness = 15,
722 .id = PMIC8058_ID_LED_KB_LIGHT,
Dima Zavinba5499e2011-01-10 11:00:30 -0800723 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700724};
725
726static struct pmic8058_leds_platform_data pm8058_ffa_leds_data = {
727 .num_leds = ARRAY_SIZE(pmic8058_ffa_leds),
728 .leds = pmic8058_ffa_leds,
729};
730
731static struct pmic8058_led pmic8058_surf_leds[] = {
732 [0] = {
733 .name = "keyboard-backlight",
734 .max_brightness = 15,
735 .id = PMIC8058_ID_LED_KB_LIGHT,
736 },
737 [1] = {
738 .name = "voice:red",
739 .max_brightness = 20,
740 .id = PMIC8058_ID_LED_0,
741 },
742 [2] = {
743 .name = "wlan:green",
744 .max_brightness = 20,
745 .id = PMIC8058_ID_LED_2,
746 },
747};
748
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700749static struct pmic8058_leds_platform_data pm8058_surf_leds_data = {
750 .num_leds = ARRAY_SIZE(pmic8058_surf_leds),
751 .leds = pmic8058_surf_leds,
752};
753
754static struct pmic8058_led pmic8058_fluid_leds[] = {
755 [0] = {
756 .name = "keyboard-backlight",
757 .max_brightness = 15,
758 .id = PMIC8058_ID_LED_KB_LIGHT,
759 },
760 [1] = {
761 .name = "flash:led_0",
762 .max_brightness = 15,
763 .id = PMIC8058_ID_FLASH_LED_0,
764 },
765 [2] = {
766 .name = "flash:led_1",
767 .max_brightness = 15,
768 .id = PMIC8058_ID_FLASH_LED_1,
769 },
770};
771
772static struct pmic8058_leds_platform_data pm8058_fluid_leds_data = {
773 .num_leds = ARRAY_SIZE(pmic8058_fluid_leds),
774 .leds = pmic8058_fluid_leds,
775};
776
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530777static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata = {
778 .irq_base = PMIC8058_IRQ_BASE,
779 .devirq = MSM_GPIO_TO_INT(PMIC_GPIO_INT),
780 .irq_trigger_flag = IRQF_TRIGGER_LOW,
781};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700782
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530783static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata = {
784 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
785};
786
787static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata = {
788 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
789};
790
791static struct pm8058_platform_data pm8058_7x30_data = {
792 .irq_pdata = &pm8xxx_irq_pdata,
793 .gpio_pdata = &pm8xxx_gpio_pdata,
794 .mpp_pdata = &pm8xxx_mpp_pdata,
795 .pwm_pdata = &pm8058_pwm_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700796};
797
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530798#ifdef CONFIG_MSM_SSBI
799static struct msm_ssbi_platform_data msm7x30_ssbi_pm8058_pdata = {
800 .controller_type = MSM_SBI_CTRL_SSBI2,
801 .slave = {
802 .name = "pm8058-core",
803 .platform_data = &pm8058_7x30_data,
804 },
805};
806#endif
807
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700808static struct i2c_board_info cy8info[] __initdata = {
809 {
810 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
811 .platform_data = &cyttsp_data,
812#ifndef CY_USE_TIMER
813 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
814#endif /* CY_USE_TIMER */
815 },
816};
817
818static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
819#ifdef CONFIG_MT9D112
820 {
821 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
Dima Zavinba5499e2011-01-10 11:00:30 -0800822 },
823#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700824#ifdef CONFIG_WEBCAM_OV9726
825 {
826 I2C_BOARD_INFO("ov9726", 0x10),
827 },
828#endif
829#ifdef CONFIG_S5K3E2FX
830 {
831 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
832 },
833#endif
834#ifdef CONFIG_MT9P012
835 {
836 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
837 },
838#endif
839#ifdef CONFIG_VX6953
840 {
841 I2C_BOARD_INFO("vx6953", 0x20),
842 },
843#endif
844#ifdef CONFIG_MT9E013
845 {
846 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
847 },
848#endif
849#ifdef CONFIG_SN12M0PZ
850 {
851 I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1),
852 },
853#endif
854#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
855 {
856 I2C_BOARD_INFO("mt9t013", 0x6C),
857 },
858#endif
859
Dima Zavinba5499e2011-01-10 11:00:30 -0800860};
861
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700862#ifdef CONFIG_MSM_CAMERA
863#define CAM_STNDBY 143
864static uint32_t camera_off_vcm_gpio_table[] = {
865GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */
866};
867
868static uint32_t camera_off_gpio_table[] = {
869 /* parallel CAMERA interfaces */
870 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RST */
871 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
872 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
873 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
874 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
875 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
876 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
877 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
878 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
879 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
880 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
881 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
882 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
883 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
884 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
885};
886
887static uint32_t camera_on_vcm_gpio_table[] = {
888GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */
889};
890
891static uint32_t camera_on_gpio_table[] = {
892 /* parallel CAMERA interfaces */
893 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RST */
894 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
895 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
896 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
897 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
898 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
899 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
900 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
901 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
902 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
903 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
904 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
905 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
906 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
907 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
908};
909
910static uint32_t camera_off_gpio_fluid_table[] = {
911 /* FLUID: CAM_VGA_RST_N */
912 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
913 /* FLUID: CAMIF_STANDBY */
914 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
915};
916
917static uint32_t camera_on_gpio_fluid_table[] = {
918 /* FLUID: CAM_VGA_RST_N */
919 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
920 /* FLUID: CAMIF_STANDBY */
921 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
922};
923
924static void config_gpio_table(uint32_t *table, int len)
925{
926 int n, rc;
927 for (n = 0; n < len; n++) {
928 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
929 if (rc) {
930 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
931 __func__, table[n], rc);
932 break;
933 }
934 }
935}
936static int config_camera_on_gpios(void)
937{
938 config_gpio_table(camera_on_gpio_table,
939 ARRAY_SIZE(camera_on_gpio_table));
940
941 if (adie_get_detected_codec_type() != TIMPANI_ID)
942 /* GPIO1 is shared also used in Timpani RF card so
943 only configure it for non-Timpani RF card */
944 config_gpio_table(camera_on_vcm_gpio_table,
945 ARRAY_SIZE(camera_on_vcm_gpio_table));
946
947 if (machine_is_msm7x30_fluid()) {
948 config_gpio_table(camera_on_gpio_fluid_table,
949 ARRAY_SIZE(camera_on_gpio_fluid_table));
950 /* FLUID: turn on 5V booster */
951 gpio_set_value(
952 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 1);
953 /* FLUID: drive high to put secondary sensor to STANDBY */
954 gpio_set_value(CAM_STNDBY, 1);
955 }
956 return 0;
957}
958
959static void config_camera_off_gpios(void)
960{
961 config_gpio_table(camera_off_gpio_table,
962 ARRAY_SIZE(camera_off_gpio_table));
963
964 if (adie_get_detected_codec_type() != TIMPANI_ID)
965 /* GPIO1 is shared also used in Timpani RF card so
966 only configure it for non-Timpani RF card */
967 config_gpio_table(camera_off_vcm_gpio_table,
968 ARRAY_SIZE(camera_off_vcm_gpio_table));
969
970 if (machine_is_msm7x30_fluid()) {
971 config_gpio_table(camera_off_gpio_fluid_table,
972 ARRAY_SIZE(camera_off_gpio_fluid_table));
973 /* FLUID: turn off 5V booster */
974 gpio_set_value(
975 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 0);
976 }
977}
978
979struct resource msm_camera_resources[] = {
980 {
981 .start = 0xA6000000,
982 .end = 0xA6000000 + SZ_1M - 1,
983 .flags = IORESOURCE_MEM,
984 },
985 {
986 .start = INT_VFE,
987 .end = INT_VFE,
988 .flags = IORESOURCE_IRQ,
989 },
990 {
991 .flags = IORESOURCE_DMA,
992 }
993};
994
995struct msm_camera_device_platform_data msm_camera_device_data = {
996 .camera_gpio_on = config_camera_on_gpios,
997 .camera_gpio_off = config_camera_off_gpios,
998 .ioext.camifpadphy = 0xAB000000,
999 .ioext.camifpadsz = 0x00000400,
1000 .ioext.csiphy = 0xA6100000,
1001 .ioext.csisz = 0x00000400,
1002 .ioext.csiirq = INT_CSI,
1003 .ioclk.mclk_clk_rate = 24000000,
1004 .ioclk.vfe_clk_rate = 147456000,
1005};
1006
1007static struct msm_camera_sensor_flash_src msm_flash_src_pwm = {
1008 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PWM,
1009 ._fsrc.pwm_src.freq = 1000,
1010 ._fsrc.pwm_src.max_load = 300,
1011 ._fsrc.pwm_src.low_load = 30,
1012 ._fsrc.pwm_src.high_load = 100,
1013 ._fsrc.pwm_src.channel = 7,
1014};
1015
1016#ifdef CONFIG_MT9D112
1017static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1018 .flash_type = MSM_CAMERA_FLASH_LED,
1019 .flash_src = &msm_flash_src_pwm
1020};
1021
1022static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1023 .sensor_name = "mt9d112",
1024 .sensor_reset = 0,
1025 .sensor_pwd = 85,
1026 .vcm_pwd = 1,
1027 .vcm_enable = 0,
1028 .pdata = &msm_camera_device_data,
1029 .resource = msm_camera_resources,
1030 .num_resources = ARRAY_SIZE(msm_camera_resources),
1031 .flash_data = &flash_mt9d112,
1032 .csi_if = 0
1033};
1034
1035static struct platform_device msm_camera_sensor_mt9d112 = {
1036 .name = "msm_camera_mt9d112",
1037 .dev = {
1038 .platform_data = &msm_camera_sensor_mt9d112_data,
1039 },
1040};
1041#endif
1042
1043#ifdef CONFIG_WEBCAM_OV9726
1044
1045static struct msm_camera_sensor_platform_info ov9726_sensor_7630_info = {
1046 .mount_angle = 90
1047};
1048
1049static struct msm_camera_sensor_flash_data flash_ov9726 = {
1050 .flash_type = MSM_CAMERA_FLASH_LED,
1051 .flash_src = &msm_flash_src_pwm
1052};
1053static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
1054 .sensor_name = "ov9726",
1055 .sensor_reset = 0,
1056 .sensor_pwd = 85,
1057 .vcm_pwd = 1,
1058 .vcm_enable = 0,
1059 .pdata = &msm_camera_device_data,
1060 .resource = msm_camera_resources,
1061 .num_resources = ARRAY_SIZE(msm_camera_resources),
1062 .flash_data = &flash_ov9726,
1063 .sensor_platform_info = &ov9726_sensor_7630_info,
1064 .csi_if = 1
1065};
1066struct platform_device msm_camera_sensor_ov9726 = {
1067 .name = "msm_camera_ov9726",
1068 .dev = {
1069 .platform_data = &msm_camera_sensor_ov9726_data,
1070 },
1071};
1072#endif
1073
1074#ifdef CONFIG_S5K3E2FX
1075static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1076 .flash_type = MSM_CAMERA_FLASH_LED,
1077 .flash_src = &msm_flash_src_pwm,
1078};
1079
1080static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1081 .sensor_name = "s5k3e2fx",
1082 .sensor_reset = 0,
1083 .sensor_pwd = 85,
1084 .vcm_pwd = 1,
1085 .vcm_enable = 0,
1086 .pdata = &msm_camera_device_data,
1087 .resource = msm_camera_resources,
1088 .num_resources = ARRAY_SIZE(msm_camera_resources),
1089 .flash_data = &flash_s5k3e2fx,
1090 .csi_if = 0
1091};
1092
1093static struct platform_device msm_camera_sensor_s5k3e2fx = {
1094 .name = "msm_camera_s5k3e2fx",
1095 .dev = {
1096 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1097 },
1098};
1099#endif
1100
1101#ifdef CONFIG_MT9P012
1102static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1103 .flash_type = MSM_CAMERA_FLASH_LED,
1104 .flash_src = &msm_flash_src_pwm
1105};
1106
1107static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1108 .sensor_name = "mt9p012",
1109 .sensor_reset = 0,
1110 .sensor_pwd = 85,
1111 .vcm_pwd = 1,
1112 .vcm_enable = 1,
1113 .pdata = &msm_camera_device_data,
1114 .resource = msm_camera_resources,
1115 .num_resources = ARRAY_SIZE(msm_camera_resources),
1116 .flash_data = &flash_mt9p012,
1117 .csi_if = 0
1118};
1119
1120static struct platform_device msm_camera_sensor_mt9p012 = {
1121 .name = "msm_camera_mt9p012",
1122 .dev = {
1123 .platform_data = &msm_camera_sensor_mt9p012_data,
1124 },
1125};
1126#endif
1127
1128#ifdef CONFIG_MT9E013
1129static struct msm_camera_sensor_platform_info mt9e013_sensor_7630_info = {
1130 .mount_angle = 0
1131};
1132
1133static struct msm_camera_sensor_flash_data flash_mt9e013 = {
1134 .flash_type = MSM_CAMERA_FLASH_LED,
1135 .flash_src = &msm_flash_src_pwm
1136};
1137
1138static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
1139 .sensor_name = "mt9e013",
1140 .sensor_reset = 0,
1141 .sensor_pwd = 85,
1142 .vcm_pwd = 1,
1143 .vcm_enable = 1,
1144 .pdata = &msm_camera_device_data,
1145 .resource = msm_camera_resources,
1146 .num_resources = ARRAY_SIZE(msm_camera_resources),
1147 .flash_data = &flash_mt9e013,
1148 .sensor_platform_info = &mt9e013_sensor_7630_info,
1149 .csi_if = 1
1150};
1151
1152static struct platform_device msm_camera_sensor_mt9e013 = {
1153 .name = "msm_camera_mt9e013",
1154 .dev = {
1155 .platform_data = &msm_camera_sensor_mt9e013_data,
1156 },
1157};
1158#endif
1159
1160#ifdef CONFIG_VX6953
Jilai Wang971f97f2011-07-13 14:25:25 -04001161static struct msm_camera_sensor_platform_info vx6953_sensor_7630_info = {
1162 .mount_angle = 0
1163};
1164
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001165static struct msm_camera_sensor_flash_data flash_vx6953 = {
1166 .flash_type = MSM_CAMERA_FLASH_LED,
1167 .flash_src = &msm_flash_src_pwm
1168};
1169static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1170 .sensor_name = "vx6953",
1171 .sensor_reset = 0,
1172 .sensor_pwd = 85,
1173 .vcm_pwd = 1,
1174 .vcm_enable = 0,
1175 .pdata = &msm_camera_device_data,
1176 .resource = msm_camera_resources,
1177 .num_resources = ARRAY_SIZE(msm_camera_resources),
Jilai Wang971f97f2011-07-13 14:25:25 -04001178 .sensor_platform_info = &vx6953_sensor_7630_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001179 .flash_data = &flash_vx6953,
1180 .csi_if = 1
1181};
1182static struct platform_device msm_camera_sensor_vx6953 = {
1183 .name = "msm_camera_vx6953",
1184 .dev = {
1185 .platform_data = &msm_camera_sensor_vx6953_data,
1186 },
1187};
1188#endif
1189
1190#ifdef CONFIG_SN12M0PZ
1191static struct msm_camera_sensor_flash_src msm_flash_src_current_driver = {
1192 .flash_sr_type = MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER,
1193 ._fsrc.current_driver_src.low_current = 210,
1194 ._fsrc.current_driver_src.high_current = 700,
1195 ._fsrc.current_driver_src.driver_channel = &pm8058_fluid_leds_data,
1196};
1197
1198static struct msm_camera_sensor_flash_data flash_sn12m0pz = {
1199 .flash_type = MSM_CAMERA_FLASH_LED,
1200 .flash_src = &msm_flash_src_current_driver
1201};
1202static struct msm_camera_sensor_info msm_camera_sensor_sn12m0pz_data = {
1203 .sensor_name = "sn12m0pz",
1204 .sensor_reset = 0,
1205 .sensor_pwd = 85,
1206 .vcm_pwd = 1,
1207 .vcm_enable = 1,
1208 .pdata = &msm_camera_device_data,
1209 .flash_data = &flash_sn12m0pz,
1210 .resource = msm_camera_resources,
1211 .num_resources = ARRAY_SIZE(msm_camera_resources),
1212 .csi_if = 0
1213};
1214
1215static struct platform_device msm_camera_sensor_sn12m0pz = {
1216 .name = "msm_camera_sn12m0pz",
1217 .dev = {
1218 .platform_data = &msm_camera_sensor_sn12m0pz_data,
1219 },
1220};
1221#endif
1222
1223#ifdef CONFIG_MT9T013
1224static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1225 .flash_type = MSM_CAMERA_FLASH_LED,
1226 .flash_src = &msm_flash_src_pwm
1227};
1228
1229static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1230 .sensor_name = "mt9t013",
1231 .sensor_reset = 0,
1232 .sensor_pwd = 85,
1233 .vcm_pwd = 1,
1234 .vcm_enable = 0,
1235 .pdata = &msm_camera_device_data,
1236 .resource = msm_camera_resources,
1237 .num_resources = ARRAY_SIZE(msm_camera_resources),
1238 .flash_data = &flash_mt9t013,
1239 .csi_if = 1
1240};
1241
1242static struct platform_device msm_camera_sensor_mt9t013 = {
1243 .name = "msm_camera_mt9t013",
1244 .dev = {
1245 .platform_data = &msm_camera_sensor_mt9t013_data,
1246 },
1247};
1248#endif
1249
1250#ifdef CONFIG_MSM_GEMINI
1251static struct resource msm_gemini_resources[] = {
1252 {
1253 .start = 0xA3A00000,
1254 .end = 0xA3A00000 + 0x0150 - 1,
1255 .flags = IORESOURCE_MEM,
1256 },
1257 {
1258 .start = INT_JPEG,
1259 .end = INT_JPEG,
1260 .flags = IORESOURCE_IRQ,
1261 },
1262};
1263
1264static struct platform_device msm_gemini_device = {
1265 .name = "msm_gemini",
1266 .resource = msm_gemini_resources,
1267 .num_resources = ARRAY_SIZE(msm_gemini_resources),
1268};
1269#endif
1270
1271#ifdef CONFIG_MSM_VPE
1272static struct resource msm_vpe_resources[] = {
1273 {
1274 .start = 0xAD200000,
1275 .end = 0xAD200000 + SZ_1M - 1,
1276 .flags = IORESOURCE_MEM,
1277 },
1278 {
1279 .start = INT_VPE,
1280 .end = INT_VPE,
1281 .flags = IORESOURCE_IRQ,
1282 },
1283};
1284
1285static struct platform_device msm_vpe_device = {
1286 .name = "msm_vpe",
1287 .id = 0,
1288 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1289 .resource = msm_vpe_resources,
1290};
1291#endif
1292
1293#endif /*CONFIG_MSM_CAMERA*/
1294
1295#ifdef CONFIG_MSM7KV2_AUDIO
1296static uint32_t audio_pamp_gpio_config =
1297 GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1298
1299static uint32_t audio_fluid_icodec_tx_config =
1300 GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1301
1302static int __init snddev_poweramp_gpio_init(void)
1303{
1304 int rc;
1305
1306 pr_info("snddev_poweramp_gpio_init \n");
1307 rc = gpio_tlmm_config(audio_pamp_gpio_config, GPIO_CFG_ENABLE);
1308 if (rc) {
1309 printk(KERN_ERR
1310 "%s: gpio_tlmm_config(%#x)=%d\n",
1311 __func__, audio_pamp_gpio_config, rc);
1312 }
1313 return rc;
1314}
1315
1316void msm_snddev_tx_route_config(void)
1317{
1318 int rc;
1319
1320 pr_debug("%s()\n", __func__);
1321
1322 if (machine_is_msm7x30_fluid()) {
1323 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1324 GPIO_CFG_ENABLE);
1325 if (rc) {
1326 printk(KERN_ERR
1327 "%s: gpio_tlmm_config(%#x)=%d\n",
1328 __func__, audio_fluid_icodec_tx_config, rc);
1329 } else
1330 gpio_set_value(85, 0);
1331 }
1332}
1333
1334void msm_snddev_tx_route_deconfig(void)
1335{
1336 int rc;
1337
1338 pr_debug("%s()\n", __func__);
1339
1340 if (machine_is_msm7x30_fluid()) {
1341 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1342 GPIO_CFG_DISABLE);
1343 if (rc) {
1344 printk(KERN_ERR
1345 "%s: gpio_tlmm_config(%#x)=%d\n",
1346 __func__, audio_fluid_icodec_tx_config, rc);
1347 }
1348 }
1349}
1350
1351void msm_snddev_poweramp_on(void)
1352{
1353 gpio_set_value(82, 1); /* enable spkr poweramp */
1354 pr_info("%s: power on amplifier\n", __func__);
1355}
1356
1357void msm_snddev_poweramp_off(void)
1358{
1359 gpio_set_value(82, 0); /* disable spkr poweramp */
1360 pr_info("%s: power off amplifier\n", __func__);
1361}
1362
Justin Paupore3f40f342011-08-10 18:52:16 -07001363static struct regulator_bulk_data snddev_regs[] = {
1364 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
1365 { .supply = "ncp", .min_uV = 1800000, .max_uV = 1800000 },
1366};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001367
Justin Paupore3f40f342011-08-10 18:52:16 -07001368static int __init snddev_hsed_voltage_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001369{
1370 int rc;
1371
Justin Paupore3f40f342011-08-10 18:52:16 -07001372 rc = regulator_bulk_get(NULL, ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001373
Justin Paupore3f40f342011-08-10 18:52:16 -07001374 if (rc) {
1375 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1376 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001377 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001378
1379 rc = regulator_bulk_set_voltage(ARRAY_SIZE(snddev_regs), snddev_regs);
1380
1381 if (rc) {
1382 pr_err("%s: could not set regulator voltages: %d\n",
1383 __func__, rc);
1384 goto regs_free;
1385 }
1386
1387 return 0;
1388
1389regs_free:
1390 regulator_bulk_free(ARRAY_SIZE(snddev_regs), snddev_regs);
1391out:
1392 return rc;
1393}
1394
1395
1396void msm_snddev_hsed_voltage_on(void)
1397{
1398 int rc = regulator_bulk_enable(ARRAY_SIZE(snddev_regs), snddev_regs);
1399
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001400 if (rc)
Justin Paupore3f40f342011-08-10 18:52:16 -07001401 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001402}
1403
1404void msm_snddev_hsed_voltage_off(void)
1405{
Justin Paupore3f40f342011-08-10 18:52:16 -07001406 int rc = regulator_bulk_disable(ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001407
Justin Paupore3f40f342011-08-10 18:52:16 -07001408 if (rc) {
1409 pr_err("%s: could not disable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001410 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001411}
1412
1413static unsigned aux_pcm_gpio_on[] = {
1414 GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
1415 GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
1416 GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
1417 GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
1418};
1419
1420static int __init aux_pcm_gpio_init(void)
1421{
1422 int pin, rc;
1423
1424 pr_info("aux_pcm_gpio_init \n");
1425 for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) {
1426 rc = gpio_tlmm_config(aux_pcm_gpio_on[pin],
1427 GPIO_CFG_ENABLE);
1428 if (rc) {
1429 printk(KERN_ERR
1430 "%s: gpio_tlmm_config(%#x)=%d\n",
1431 __func__, aux_pcm_gpio_on[pin], rc);
1432 }
1433 }
1434 return rc;
1435}
1436
1437static struct msm_gpio mi2s_clk_gpios[] = {
1438 { GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1439 "MI2S_SCLK"},
1440 { GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1441 "MI2S_WS"},
1442 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1443 "MI2S_MCLK_A"},
1444};
1445
1446static struct msm_gpio mi2s_rx_data_lines_gpios[] = {
1447 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1448 "MI2S_DATA_SD0_A"},
1449 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1450 "MI2S_DATA_SD1_A"},
1451 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1452 "MI2S_DATA_SD2_A"},
1453 { GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1454 "MI2S_DATA_SD3"},
1455};
1456
1457static struct msm_gpio mi2s_tx_data_lines_gpios[] = {
1458 { GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1459 "MI2S_DATA_SD3"},
1460};
1461
1462int mi2s_config_clk_gpio(void)
1463{
1464 int rc = 0;
1465
1466 rc = msm_gpios_request_enable(mi2s_clk_gpios,
1467 ARRAY_SIZE(mi2s_clk_gpios));
1468 if (rc) {
1469 pr_err("%s: enable mi2s clk gpios failed\n",
1470 __func__);
1471 return rc;
1472 }
1473 return 0;
1474}
1475
1476int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask)
1477{
1478 int i, rc = 0;
1479 sd_line_mask &= MI2S_SD_LINE_MASK;
1480
1481 switch (direction) {
1482 case DIR_TX:
1483 msm_gpios_disable_free(mi2s_tx_data_lines_gpios, 1);
1484 break;
1485 case DIR_RX:
1486 i = 0;
1487 while (sd_line_mask) {
1488 if (sd_line_mask & 0x1)
1489 msm_gpios_disable_free(
1490 mi2s_rx_data_lines_gpios + i , 1);
1491 sd_line_mask = sd_line_mask >> 1;
1492 i++;
1493 }
1494 break;
1495 default:
1496 pr_err("%s: Invaild direction direction = %u\n",
1497 __func__, direction);
1498 rc = -EINVAL;
1499 break;
1500 }
1501 return rc;
1502}
1503
1504int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask)
1505{
1506 int i , rc = 0;
1507 u8 sd_config_done_mask = 0;
1508
1509 sd_line_mask &= MI2S_SD_LINE_MASK;
1510
1511 switch (direction) {
1512 case DIR_TX:
1513 if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) ||
1514 (sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) {
1515 pr_err("%s: can not use SD0 or SD1 or SD2 for TX"
1516 ".only can use SD3. sd_line_mask = 0x%x\n",
1517 __func__ , sd_line_mask);
1518 rc = -EINVAL;
1519 } else {
1520 rc = msm_gpios_request_enable(mi2s_tx_data_lines_gpios,
1521 1);
1522 if (rc)
1523 pr_err("%s: enable mi2s gpios for TX failed\n",
1524 __func__);
1525 }
1526 break;
1527 case DIR_RX:
1528 i = 0;
1529 while (sd_line_mask && (rc == 0)) {
1530 if (sd_line_mask & 0x1) {
1531 rc = msm_gpios_request_enable(
1532 mi2s_rx_data_lines_gpios + i , 1);
1533 if (rc) {
1534 pr_err("%s: enable mi2s gpios for"
1535 "RX failed. SD line = %s\n",
1536 __func__,
1537 (mi2s_rx_data_lines_gpios + i)->label);
1538 mi2s_unconfig_data_gpio(DIR_RX,
1539 sd_config_done_mask);
1540 } else
1541 sd_config_done_mask |= (1 << i);
1542 }
1543 sd_line_mask = sd_line_mask >> 1;
1544 i++;
1545 }
1546 break;
1547 default:
1548 pr_err("%s: Invaild direction direction = %u\n",
1549 __func__, direction);
1550 rc = -EINVAL;
1551 break;
1552 }
1553 return rc;
1554}
1555
1556int mi2s_unconfig_clk_gpio(void)
1557{
1558 msm_gpios_disable_free(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios));
1559 return 0;
1560}
1561
1562#endif /* CONFIG_MSM7KV2_AUDIO */
1563
1564static int __init buses_init(void)
1565{
1566 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT,
1567 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
1568 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
1569 __func__, PMIC_GPIO_INT);
1570
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301571 if (machine_is_msm8x60_fluid())
1572 pm8058_7x30_data.keypad_pdata = &fluid_keypad_data;
1573 else
1574 pm8058_7x30_data.keypad_pdata = &surf_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001575
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001576 return 0;
1577}
1578
1579#define TIMPANI_RESET_GPIO 1
1580
1581struct bahama_config_register{
1582 u8 reg;
1583 u8 value;
1584 u8 mask;
1585};
1586
1587enum version{
1588 VER_1_0,
1589 VER_2_0,
1590 VER_UNSUPPORTED = 0xFF
1591};
1592
Justin Paupore3f40f342011-08-10 18:52:16 -07001593static struct regulator *vreg_marimba_1;
1594static struct regulator *vreg_marimba_2;
1595static struct regulator *vreg_bahama;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001596
1597static struct msm_gpio timpani_reset_gpio_cfg[] = {
1598{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
1599 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} };
1600
1601static u8 read_bahama_ver(void)
1602{
1603 int rc;
1604 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1605 u8 bahama_version;
1606
1607 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
1608 if (rc < 0) {
1609 printk(KERN_ERR
1610 "%s: version read failed: %d\n",
1611 __func__, rc);
1612 return rc;
1613 } else {
1614 printk(KERN_INFO
1615 "%s: version read got: 0x%x\n",
1616 __func__, bahama_version);
1617 }
1618
1619 switch (bahama_version) {
1620 case 0x08: /* varient of bahama v1 */
1621 case 0x10:
1622 case 0x00:
1623 return VER_1_0;
1624 case 0x09: /* variant of bahama v2 */
1625 return VER_2_0;
1626 default:
1627 return VER_UNSUPPORTED;
1628 }
1629}
1630
1631static int config_timpani_reset(void)
1632{
1633 int rc;
1634
1635 rc = msm_gpios_request_enable(timpani_reset_gpio_cfg,
1636 ARRAY_SIZE(timpani_reset_gpio_cfg));
1637 if (rc < 0) {
1638 printk(KERN_ERR
1639 "%s: msm_gpios_request_enable failed (%d)\n",
1640 __func__, rc);
1641 }
1642 return rc;
1643}
1644
1645static unsigned int msm_timpani_setup_power(void)
1646{
1647 int rc;
1648
1649 rc = config_timpani_reset();
1650 if (rc < 0)
1651 goto out;
1652
Justin Paupore3f40f342011-08-10 18:52:16 -07001653 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001654 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001655 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001656 goto out;
1657 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001658
1659 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001660 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001661 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1662 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001663 }
1664
1665 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1);
1666 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001667 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001668 __func__, rc);
1669 msm_gpios_free(timpani_reset_gpio_cfg,
1670 ARRAY_SIZE(timpani_reset_gpio_cfg));
Justin Paupore3f40f342011-08-10 18:52:16 -07001671 goto disable_marimba_2;
1672 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001673
Justin Paupore3f40f342011-08-10 18:52:16 -07001674 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001675
Justin Paupore3f40f342011-08-10 18:52:16 -07001676disable_marimba_2:
1677 regulator_disable(vreg_marimba_2);
1678disable_marimba_1:
1679 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001680out:
1681 return rc;
1682};
1683
1684static void msm_timpani_shutdown_power(void)
1685{
1686 int rc;
1687
Justin Paupore3f40f342011-08-10 18:52:16 -07001688 rc = regulator_disable(vreg_marimba_2);
1689 if (rc)
1690 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1691
1692 rc = regulator_disable(vreg_marimba_1);
1693 if (rc)
1694 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001695
1696 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0);
Justin Paupore3f40f342011-08-10 18:52:16 -07001697 if (rc < 0)
1698 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001699 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001700
1701 msm_gpios_free(timpani_reset_gpio_cfg,
1702 ARRAY_SIZE(timpani_reset_gpio_cfg));
1703};
1704
1705static unsigned int msm_bahama_core_config(int type)
1706{
1707 int rc = 0;
1708
1709 if (type == BAHAMA_ID) {
1710
1711 int i;
1712 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1713
1714 const struct bahama_config_register v20_init[] = {
1715 /* reg, value, mask */
1716 { 0xF4, 0x84, 0xFF }, /* AREG */
1717 { 0xF0, 0x04, 0xFF } /* DREG */
1718 };
1719
1720 if (read_bahama_ver() == VER_2_0) {
1721 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
1722 u8 value = v20_init[i].value;
1723 rc = marimba_write_bit_mask(&config,
1724 v20_init[i].reg,
1725 &value,
1726 sizeof(v20_init[i].value),
1727 v20_init[i].mask);
1728 if (rc < 0) {
1729 printk(KERN_ERR
1730 "%s: reg %d write failed: %d\n",
1731 __func__, v20_init[i].reg, rc);
1732 return rc;
1733 }
1734 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
1735 " mask 0x%02x\n",
1736 __func__, v20_init[i].reg,
1737 v20_init[i].value, v20_init[i].mask);
1738 }
1739 }
1740 }
1741 printk(KERN_INFO "core type: %d\n", type);
1742
1743 return rc;
1744}
1745
1746static unsigned int msm_bahama_setup_power(void)
1747{
Justin Paupore3f40f342011-08-10 18:52:16 -07001748 int rc = regulator_enable(vreg_bahama);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001749
Justin Paupore3f40f342011-08-10 18:52:16 -07001750 if (rc)
1751 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001752
1753 return rc;
1754};
1755
1756static unsigned int msm_bahama_shutdown_power(int value)
1757{
1758 int rc = 0;
1759
1760 if (value != BAHAMA_ID) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001761 rc = regulator_disable(vreg_bahama);
1762
1763 if (rc)
1764 pr_err("%s: regulator_disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001765 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001766 }
1767
1768 return rc;
1769};
1770
1771static struct msm_gpio marimba_svlte_config_clock[] = {
1772 { GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1773 "MARIMBA_SVLTE_CLOCK_ENABLE" },
1774};
1775
1776static unsigned int msm_marimba_gpio_config_svlte(int gpio_cfg_marimba)
1777{
1778 if (machine_is_msm8x55_svlte_surf() ||
1779 machine_is_msm8x55_svlte_ffa()) {
1780 if (gpio_cfg_marimba)
1781 gpio_set_value(GPIO_PIN
1782 (marimba_svlte_config_clock->gpio_cfg), 1);
1783 else
1784 gpio_set_value(GPIO_PIN
1785 (marimba_svlte_config_clock->gpio_cfg), 0);
1786 }
1787
1788 return 0;
1789};
1790
1791static unsigned int msm_marimba_setup_power(void)
1792{
1793 int rc;
1794
Justin Paupore3f40f342011-08-10 18:52:16 -07001795 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001796 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001797 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001798 goto out;
1799 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001800
1801 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001802 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001803 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1804 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001805 }
1806
1807 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
1808 rc = msm_gpios_request_enable(marimba_svlte_config_clock,
1809 ARRAY_SIZE(marimba_svlte_config_clock));
1810 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001811 pr_err("%s: msm_gpios_request_enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001812 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07001813 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001814 }
1815
1816 rc = gpio_direction_output(GPIO_PIN
1817 (marimba_svlte_config_clock->gpio_cfg), 0);
1818 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001819 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001820 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07001821 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001822 }
1823 }
1824
Justin Paupore3f40f342011-08-10 18:52:16 -07001825 return 0;
1826
1827disable_marimba_2:
1828 regulator_disable(vreg_marimba_2);
1829disable_marimba_1:
1830 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001831out:
1832 return rc;
1833};
1834
1835static void msm_marimba_shutdown_power(void)
1836{
1837 int rc;
1838
Justin Paupore3f40f342011-08-10 18:52:16 -07001839 rc = regulator_disable(vreg_marimba_2);
1840 if (rc)
1841 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1842
1843 rc = regulator_disable(vreg_marimba_1);
1844 if (rc)
1845 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001846};
1847
1848static int bahama_present(void)
1849{
1850 int id;
1851 switch (id = adie_get_detected_connectivity_type()) {
1852 case BAHAMA_ID:
1853 return 1;
1854
1855 case MARIMBA_ID:
1856 return 0;
1857
1858 case TIMPANI_ID:
1859 default:
1860 printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n",
1861 __func__, id);
1862 return -ENODEV;
1863 }
1864}
1865
Justin Paupore3f40f342011-08-10 18:52:16 -07001866struct regulator *fm_regulator;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001867static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
1868{
Justin Paupore3f40f342011-08-10 18:52:16 -07001869 int rc, voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001870 uint32_t irqcfg;
1871 const char *id = "FMPW";
1872
1873 int bahama_not_marimba = bahama_present();
1874
Justin Paupore3f40f342011-08-10 18:52:16 -07001875 if (bahama_not_marimba < 0) {
1876 pr_warn("%s: bahama_present: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001877 __func__, bahama_not_marimba);
Justin Paupore3f40f342011-08-10 18:52:16 -07001878 rc = -ENODEV;
1879 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001880 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001881 if (bahama_not_marimba) {
1882 fm_regulator = regulator_get(NULL, "s3");
1883 voltage = 1800000;
1884 } else {
1885 fm_regulator = regulator_get(NULL, "s2");
1886 voltage = 1300000;
1887 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001888
1889 if (IS_ERR(fm_regulator)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001890 rc = PTR_ERR(fm_regulator);
1891 pr_err("%s: regulator_get failed (%d)\n", __func__, rc);
1892 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001893 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001894
Justin Paupore3f40f342011-08-10 18:52:16 -07001895 rc = regulator_set_voltage(fm_regulator, voltage, voltage);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001896
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001897 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001898 pr_err("%s: regulator_set_voltage failed (%d)\n", __func__, rc);
1899 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001900 }
1901
Justin Paupore3f40f342011-08-10 18:52:16 -07001902 rc = regulator_enable(fm_regulator);
1903
1904 if (rc) {
1905 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1906 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001907 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001908
1909 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_ON);
1910
1911 if (rc < 0) {
1912 pr_err("%s: clock vote failed (%d)\n", __func__, rc);
1913 goto regulator_disable;
1914 }
1915
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001916 /*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
1917 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07001918 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001919 rc = marimba_gpio_config(1);
Justin Paupore3f40f342011-08-10 18:52:16 -07001920 if (rc < 0) {
1921 pr_err("%s: clock enable for svlte : %d\n",
1922 __func__, rc);
1923 goto clock_devote;
1924 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001925 }
1926 irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
1927 GPIO_CFG_2MA);
1928 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
1929 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001930 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001931 rc = -EIO;
Justin Paupore3f40f342011-08-10 18:52:16 -07001932 goto gpio_deconfig;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001933
1934 }
1935 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001936
Justin Paupore3f40f342011-08-10 18:52:16 -07001937gpio_deconfig:
1938 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa())
1939 marimba_gpio_config(0);
1940clock_devote:
1941 pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_OFF);
1942regulator_disable:
1943 regulator_disable(fm_regulator);
1944regulator_free:
1945 regulator_put(fm_regulator);
1946 fm_regulator = NULL;
1947out:
1948 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001949};
1950
1951static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
1952{
1953 int rc;
1954 const char *id = "FMPW";
1955 uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
1956 GPIO_CFG_2MA);
1957
1958 int bahama_not_marimba = bahama_present();
1959 if (bahama_not_marimba == -1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001960 pr_warn("%s: bahama_present: %d\n",
1961 __func__, bahama_not_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001962 return;
1963 }
1964
1965 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
1966 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001967 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001968 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001969 if (!IS_ERR_OR_NULL(fm_regulator)) {
1970 rc = regulator_disable(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001971
Justin Paupore3f40f342011-08-10 18:52:16 -07001972 if (rc)
1973 pr_err("%s: return val: %d\n", __func__, rc);
1974
1975 regulator_put(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001976 fm_regulator = NULL;
1977 }
1978 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
1979 PMAPP_CLOCK_VOTE_OFF);
1980 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07001981 pr_err("%s: clock_vote return val: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001982
1983 /*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
1984 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07001985 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001986 rc = marimba_gpio_config(0);
1987 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07001988 pr_err("%s: clock disable for svlte : %d\n",
1989 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001990 }
1991}
1992
1993static struct marimba_fm_platform_data marimba_fm_pdata = {
1994 .fm_setup = fm_radio_setup,
1995 .fm_shutdown = fm_radio_shutdown,
1996 .irq = MSM_GPIO_TO_INT(147),
1997 .vreg_s2 = NULL,
1998 .vreg_xo_out = NULL,
1999 .is_fm_soc_i2s_master = false,
2000 .config_i2s_gpio = NULL,
2001};
2002
2003
2004/* Slave id address for FM/CDC/QMEMBIST
2005 * Values can be programmed using Marimba slave id 0
2006 * should there be a conflict with other I2C devices
2007 * */
2008#define MARIMBA_SLAVE_ID_FM_ADDR 0x2A
2009#define MARIMBA_SLAVE_ID_CDC_ADDR 0x77
2010#define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66
2011
2012#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
2013#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
2014
2015static const char *tsadc_id = "MADC";
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002016
Justin Paupore3f40f342011-08-10 18:52:16 -07002017static struct regulator_bulk_data regs_tsadc_marimba[] = {
2018 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2019 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002020};
Justin Paupore3f40f342011-08-10 18:52:16 -07002021
2022static struct regulator_bulk_data regs_tsadc_timpani[] = {
2023 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2024 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2025 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2026};
2027
2028static struct regulator_bulk_data *regs_tsadc;
2029static int regs_tsadc_count;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002030
2031static int marimba_tsadc_power(int vreg_on)
2032{
Justin Paupore3f40f342011-08-10 18:52:16 -07002033 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002034 int tsadc_adie_type = adie_get_detected_codec_type();
2035
Justin Paupore3f40f342011-08-10 18:52:16 -07002036 switch (tsadc_adie_type) {
2037 case TIMPANI_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002038 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2039 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2040 if (rc) {
2041 pr_err("%s: unable to %svote for d1 clk\n",
2042 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002043 goto D1_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002044 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002045
2046 /* fall through */
2047 case MARIMBA_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002048 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2049 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2050 if (rc) {
2051 pr_err("%s: unable to %svote for d1 clk\n",
2052 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002053 goto D0_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002054 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002055
Justin Paupore3f40f342011-08-10 18:52:16 -07002056 WARN_ON(regs_tsadc_count == 0);
2057
2058 rc = vreg_on ?
2059 regulator_bulk_enable(regs_tsadc_count, regs_tsadc) :
2060 regulator_bulk_disable(regs_tsadc_count, regs_tsadc);
2061
2062 if (rc) {
2063 pr_err("%s: regulator %sable failed: %d\n",
2064 __func__, vreg_on ? "en" : "dis", rc);
2065 goto regulator_switch_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002066 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002067
2068 break;
2069 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002070 pr_err("%s:Adie %d not supported\n",
2071 __func__, tsadc_adie_type);
2072 return -ENODEV;
2073 }
2074
2075 msleep(5); /* ensure power is stable */
2076
2077 return 0;
2078
Justin Paupore3f40f342011-08-10 18:52:16 -07002079regulator_switch_fail:
2080 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2081 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2082D0_vote_fail:
2083 if (tsadc_adie_type == TIMPANI_ID)
2084 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2085 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2086D1_vote_fail:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002087 return rc;
2088}
2089
2090static int marimba_tsadc_init(void)
2091{
Justin Paupore3f40f342011-08-10 18:52:16 -07002092 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002093 int tsadc_adie_type = adie_get_detected_codec_type();
2094
Justin Paupore3f40f342011-08-10 18:52:16 -07002095 switch (tsadc_adie_type) {
2096 case MARIMBA_ID:
2097 regs_tsadc = regs_tsadc_marimba;
2098 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_marimba);
2099 break;
2100 case TIMPANI_ID:
2101 regs_tsadc = regs_tsadc_timpani;
2102 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_timpani);
2103 break;
2104 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002105 pr_err("%s:Adie %d not supported\n",
2106 __func__, tsadc_adie_type);
Justin Paupore3f40f342011-08-10 18:52:16 -07002107 rc = -ENODEV;
2108 goto out;
2109 }
2110
2111 rc = regulator_bulk_get(NULL, regs_tsadc_count, regs_tsadc);
2112 if (rc) {
2113 pr_err("%s: could not get regulators: %d\n",
2114 __func__, rc);
2115 goto out;
2116 }
2117
2118 rc = regulator_bulk_set_voltage(regs_tsadc_count, regs_tsadc);
2119 if (rc) {
2120 pr_err("%s: could not set regulator voltages: %d\n",
2121 __func__, rc);
2122 goto vreg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002123 }
2124
2125 return 0;
2126
Justin Paupore3f40f342011-08-10 18:52:16 -07002127vreg_free:
2128 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2129out:
2130 regs_tsadc = NULL;
2131 regs_tsadc_count = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002132 return rc;
2133}
2134
2135static int marimba_tsadc_exit(void)
2136{
Justin Paupore3f40f342011-08-10 18:52:16 -07002137 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2138 regs_tsadc_count = 0;
2139 regs_tsadc = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002140
Justin Paupore3f40f342011-08-10 18:52:16 -07002141 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002142}
2143
2144
2145static struct msm_ts_platform_data msm_ts_data = {
2146 .min_x = 0,
2147 .max_x = 4096,
2148 .min_y = 0,
2149 .max_y = 4096,
2150 .min_press = 0,
2151 .max_press = 255,
2152 .inv_x = 4096,
2153 .inv_y = 4096,
2154 .can_wakeup = false,
2155};
2156
2157static struct marimba_tsadc_platform_data marimba_tsadc_pdata = {
2158 .marimba_tsadc_power = marimba_tsadc_power,
2159 .init = marimba_tsadc_init,
2160 .exit = marimba_tsadc_exit,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002161 .tsadc_prechg_en = true,
2162 .can_wakeup = false,
2163 .setup = {
2164 .pen_irq_en = true,
2165 .tsadc_en = true,
2166 },
2167 .params2 = {
2168 .input_clk_khz = 2400,
2169 .sample_prd = TSADC_CLK_3,
2170 },
2171 .params3 = {
2172 .prechg_time_nsecs = 6400,
2173 .stable_time_nsecs = 6400,
2174 .tsadc_test_mode = 0,
2175 },
2176 .tssc_data = &msm_ts_data,
2177};
2178
Justin Paupore3f40f342011-08-10 18:52:16 -07002179static struct regulator_bulk_data codec_regs[] = {
2180 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
2181};
2182
2183static int __init msm_marimba_codec_init(void)
2184{
2185 int rc = regulator_bulk_get(NULL, ARRAY_SIZE(codec_regs), codec_regs);
2186
2187 if (rc) {
2188 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2189 goto out;
2190 }
2191
2192 rc = regulator_bulk_set_voltage(ARRAY_SIZE(codec_regs), codec_regs);
2193 if (rc) {
2194 pr_err("%s: could not set regulator voltages: %d\n",
2195 __func__, rc);
2196 goto reg_free;
2197 }
2198
2199 return rc;
2200
2201reg_free:
2202 regulator_bulk_free(ARRAY_SIZE(codec_regs), codec_regs);
2203out:
2204 return rc;
2205}
2206
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002207static int msm_marimba_codec_power(int vreg_on)
2208{
Justin Paupore3f40f342011-08-10 18:52:16 -07002209 int rc = vreg_on ?
2210 regulator_bulk_enable(ARRAY_SIZE(codec_regs), codec_regs) :
2211 regulator_bulk_disable(ARRAY_SIZE(codec_regs), codec_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002212
Justin Paupore3f40f342011-08-10 18:52:16 -07002213 if (rc) {
2214 pr_err("%s: could not %sable regulators: %d",
2215 __func__, vreg_on ? "en" : "dis", rc);
2216 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002217 }
2218
Justin Paupore3f40f342011-08-10 18:52:16 -07002219 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002220}
2221
2222static struct marimba_codec_platform_data mariba_codec_pdata = {
2223 .marimba_codec_power = msm_marimba_codec_power,
2224#ifdef CONFIG_MARIMBA_CODEC
2225 .snddev_profile_init = msm_snddev_init,
2226#endif
2227};
2228
2229static struct marimba_platform_data marimba_pdata = {
2230 .slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR,
2231 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2232 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2233 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
2234 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
2235 .marimba_setup = msm_marimba_setup_power,
2236 .marimba_shutdown = msm_marimba_shutdown_power,
2237 .bahama_setup = msm_bahama_setup_power,
2238 .bahama_shutdown = msm_bahama_shutdown_power,
2239 .marimba_gpio_config = msm_marimba_gpio_config_svlte,
2240 .bahama_core_config = msm_bahama_core_config,
2241 .fm = &marimba_fm_pdata,
2242 .codec = &mariba_codec_pdata,
2243 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2244};
2245
2246static void __init msm7x30_init_marimba(void)
2247{
2248 int rc;
2249
Justin Paupore3f40f342011-08-10 18:52:16 -07002250 struct regulator_bulk_data regs[] = {
2251 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2252 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2253 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
2254 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002255
Justin Paupore3f40f342011-08-10 18:52:16 -07002256 rc = msm_marimba_codec_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002257
Justin Paupore3f40f342011-08-10 18:52:16 -07002258 if (rc) {
2259 pr_err("%s: msm_marimba_codec_init failed (%d)\n",
2260 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002261 return;
2262 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002263
2264 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
2265
2266 if (rc) {
2267 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2268 return;
2269 }
2270
2271 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
2272
2273 if (rc) {
2274 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2275 regulator_bulk_free(ARRAY_SIZE(regs), regs);
2276 return;
2277 }
2278
2279 vreg_marimba_1 = regs[0].consumer;
2280 vreg_marimba_2 = regs[1].consumer;
2281 vreg_bahama = regs[2].consumer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002282}
2283
2284static struct marimba_codec_platform_data timpani_codec_pdata = {
2285 .marimba_codec_power = msm_marimba_codec_power,
2286#ifdef CONFIG_TIMPANI_CODEC
2287 .snddev_profile_init = msm_snddev_init_timpani,
2288#endif
2289};
2290
2291static struct marimba_platform_data timpani_pdata = {
2292 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2293 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2294 .marimba_setup = msm_timpani_setup_power,
2295 .marimba_shutdown = msm_timpani_shutdown_power,
2296 .codec = &timpani_codec_pdata,
2297 .tsadc = &marimba_tsadc_pdata,
2298 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2299};
2300
2301#define TIMPANI_I2C_SLAVE_ADDR 0xD
2302
2303static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
2304 {
2305 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
2306 .platform_data = &timpani_pdata,
2307 },
2308};
2309
2310#ifdef CONFIG_MSM7KV2_AUDIO
2311static struct resource msm_aictl_resources[] = {
2312 {
2313 .name = "aictl",
2314 .start = 0xa5000100,
2315 .end = 0xa5000100,
2316 .flags = IORESOURCE_MEM,
2317 }
2318};
2319
2320static struct resource msm_mi2s_resources[] = {
2321 {
2322 .name = "hdmi",
2323 .start = 0xac900000,
2324 .end = 0xac900038,
2325 .flags = IORESOURCE_MEM,
2326 },
2327 {
2328 .name = "codec_rx",
2329 .start = 0xac940040,
2330 .end = 0xac940078,
2331 .flags = IORESOURCE_MEM,
2332 },
2333 {
2334 .name = "codec_tx",
2335 .start = 0xac980080,
2336 .end = 0xac9800B8,
2337 .flags = IORESOURCE_MEM,
2338 }
2339
2340};
2341
2342static struct msm_lpa_platform_data lpa_pdata = {
2343 .obuf_hlb_size = 0x2BFF8,
2344 .dsp_proc_id = 0,
2345 .app_proc_id = 2,
2346 .nosb_config = {
2347 .llb_min_addr = 0,
2348 .llb_max_addr = 0x3ff8,
2349 .sb_min_addr = 0,
2350 .sb_max_addr = 0,
2351 },
2352 .sb_config = {
2353 .llb_min_addr = 0,
2354 .llb_max_addr = 0x37f8,
2355 .sb_min_addr = 0x3800,
2356 .sb_max_addr = 0x3ff8,
2357 }
2358};
2359
2360static struct resource msm_lpa_resources[] = {
2361 {
2362 .name = "lpa",
2363 .start = 0xa5000000,
2364 .end = 0xa50000a0,
2365 .flags = IORESOURCE_MEM,
2366 }
2367};
2368
2369static struct resource msm_aux_pcm_resources[] = {
2370
2371 {
2372 .name = "aux_codec_reg_addr",
2373 .start = 0xac9c00c0,
2374 .end = 0xac9c00c8,
2375 .flags = IORESOURCE_MEM,
2376 },
2377 {
2378 .name = "aux_pcm_dout",
2379 .start = 138,
2380 .end = 138,
2381 .flags = IORESOURCE_IO,
2382 },
2383 {
2384 .name = "aux_pcm_din",
2385 .start = 139,
2386 .end = 139,
2387 .flags = IORESOURCE_IO,
2388 },
2389 {
2390 .name = "aux_pcm_syncout",
2391 .start = 140,
2392 .end = 140,
2393 .flags = IORESOURCE_IO,
2394 },
2395 {
2396 .name = "aux_pcm_clkin_a",
2397 .start = 141,
2398 .end = 141,
2399 .flags = IORESOURCE_IO,
2400 },
2401};
2402
2403static struct platform_device msm_aux_pcm_device = {
2404 .name = "msm_aux_pcm",
2405 .id = 0,
2406 .num_resources = ARRAY_SIZE(msm_aux_pcm_resources),
2407 .resource = msm_aux_pcm_resources,
2408};
2409
2410struct platform_device msm_aictl_device = {
2411 .name = "audio_interct",
2412 .id = 0,
2413 .num_resources = ARRAY_SIZE(msm_aictl_resources),
2414 .resource = msm_aictl_resources,
2415};
2416
2417struct platform_device msm_mi2s_device = {
2418 .name = "mi2s",
2419 .id = 0,
2420 .num_resources = ARRAY_SIZE(msm_mi2s_resources),
2421 .resource = msm_mi2s_resources,
2422};
2423
2424struct platform_device msm_lpa_device = {
2425 .name = "lpa",
2426 .id = 0,
2427 .num_resources = ARRAY_SIZE(msm_lpa_resources),
2428 .resource = msm_lpa_resources,
2429 .dev = {
2430 .platform_data = &lpa_pdata,
2431 },
2432};
2433#endif /* CONFIG_MSM7KV2_AUDIO */
2434
2435#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2436 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2437 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2438 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2439 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2440 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2441#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2442 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2443 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2444 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2445 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2446 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2447 #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2448 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2449 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2450 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2451 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2452 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2453 #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2454 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2455 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2456 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2457 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2458 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2459#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
2460
2461static unsigned int dec_concurrency_table[] = {
2462 /* Audio LP */
2463 0,
2464 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2465 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2466 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2467 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)|
2468 (1<<MSM_ADSP_OP_DM)),
2469
2470 /* Concurrency 1 */
2471 (DEC4_FORMAT),
2472 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2473 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2474 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2475 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2476
2477 /* Concurrency 2 */
2478 (DEC4_FORMAT),
2479 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2480 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2481 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2482 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2483
2484 /* Concurrency 3 */
2485 (DEC4_FORMAT),
2486 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2487 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2488 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2489 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2490
2491 /* Concurrency 4 */
2492 (DEC4_FORMAT),
2493 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2494 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2495 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2496 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2497
2498 /* Concurrency 5 */
2499 (DEC4_FORMAT),
2500 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2501 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2502 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2503 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2504
2505 /* Concurrency 6 */
2506 (DEC4_FORMAT),
2507 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2508 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2509 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2510 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2511};
2512
2513#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
2514 .module_queueid = queueid, .module_decid = decid, \
2515 .nr_codec_support = nr_codec}
2516
2517#define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
2518 .max_instances_same_dec = max_instance_same, \
2519 .max_instances_diff_dec = max_instance_diff}
2520
2521static struct msm_adspdec_info dec_info_list[] = {
2522 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
2523 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
2524 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
2525 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
2526 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
2527};
2528
2529static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
2530 /* Non Turbo Mode */
2531 {
2532 DEC_INSTANCE(4, 3), /* WAV */
2533 DEC_INSTANCE(4, 3), /* ADPCM */
2534 DEC_INSTANCE(4, 2), /* MP3 */
2535 DEC_INSTANCE(0, 0), /* Real Audio */
2536 DEC_INSTANCE(4, 2), /* WMA */
2537 DEC_INSTANCE(3, 2), /* AAC */
2538 DEC_INSTANCE(0, 0), /* Reserved */
2539 DEC_INSTANCE(0, 0), /* MIDI */
2540 DEC_INSTANCE(4, 3), /* YADPCM */
2541 DEC_INSTANCE(4, 3), /* QCELP */
2542 DEC_INSTANCE(4, 3), /* AMRNB */
2543 DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
2544 DEC_INSTANCE(4, 3), /* EVRC */
2545 DEC_INSTANCE(1, 1), /* WMAPRO */
2546 },
2547 /* Turbo Mode */
2548 {
2549 DEC_INSTANCE(4, 3), /* WAV */
2550 DEC_INSTANCE(4, 3), /* ADPCM */
2551 DEC_INSTANCE(4, 3), /* MP3 */
2552 DEC_INSTANCE(0, 0), /* Real Audio */
2553 DEC_INSTANCE(4, 3), /* WMA */
2554 DEC_INSTANCE(4, 3), /* AAC */
2555 DEC_INSTANCE(0, 0), /* Reserved */
2556 DEC_INSTANCE(0, 0), /* MIDI */
2557 DEC_INSTANCE(4, 3), /* YADPCM */
2558 DEC_INSTANCE(4, 3), /* QCELP */
2559 DEC_INSTANCE(4, 3), /* AMRNB */
2560 DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
2561 DEC_INSTANCE(4, 3), /* EVRC */
2562 DEC_INSTANCE(1, 2), /* WMAPRO */
2563 },
2564};
2565
2566static struct msm_adspdec_database msm_device_adspdec_database = {
2567 .num_dec = ARRAY_SIZE(dec_info_list),
2568 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
2569 ARRAY_SIZE(dec_info_list)),
2570 .dec_concurrency_table = dec_concurrency_table,
2571 .dec_info_list = dec_info_list,
2572 .dec_instance_list = &dec_instance_list[0][0],
2573};
2574
2575static struct platform_device msm_device_adspdec = {
2576 .name = "msm_adspdec",
2577 .id = -1,
2578 .dev = {
2579 .platform_data = &msm_device_adspdec_database
2580 },
2581};
2582
2583static struct resource smc91x_resources[] = {
2584 [0] = {
2585 .start = 0x8A000300,
2586 .end = 0x8A0003ff,
2587 .flags = IORESOURCE_MEM,
2588 },
2589 [1] = {
2590 .start = MSM_GPIO_TO_INT(156),
2591 .end = MSM_GPIO_TO_INT(156),
2592 .flags = IORESOURCE_IRQ,
2593 },
2594};
2595
2596static struct platform_device smc91x_device = {
2597 .name = "smc91x",
2598 .id = 0,
2599 .num_resources = ARRAY_SIZE(smc91x_resources),
2600 .resource = smc91x_resources,
2601};
2602
2603static struct smsc911x_platform_config smsc911x_config = {
2604 .phy_interface = PHY_INTERFACE_MODE_MII,
2605 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
2606 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
2607 .flags = SMSC911X_USE_32BIT,
2608};
2609
2610static struct resource smsc911x_resources[] = {
2611 [0] = {
2612 .start = 0x8D000000,
2613 .end = 0x8D000100,
2614 .flags = IORESOURCE_MEM,
2615 },
2616 [1] = {
2617 .start = MSM_GPIO_TO_INT(88),
2618 .end = MSM_GPIO_TO_INT(88),
2619 .flags = IORESOURCE_IRQ,
2620 },
2621};
2622
2623static struct platform_device smsc911x_device = {
2624 .name = "smsc911x",
2625 .id = -1,
2626 .num_resources = ARRAY_SIZE(smsc911x_resources),
2627 .resource = smsc911x_resources,
2628 .dev = {
2629 .platform_data = &smsc911x_config,
2630 },
2631};
2632
2633static struct msm_gpio smsc911x_gpios[] = {
2634 { GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" },
2635 { GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" },
2636 { GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" },
2637 { GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" },
2638 { GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" },
2639 { GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" },
2640 { GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" },
2641 { GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" },
2642};
2643
2644static void msm7x30_cfg_smsc911x(void)
2645{
2646 int rc;
2647
2648 rc = msm_gpios_request_enable(smsc911x_gpios,
2649 ARRAY_SIZE(smsc911x_gpios));
2650 if (rc)
2651 pr_err("%s: unable to enable gpios\n", __func__);
2652}
2653
2654#ifdef CONFIG_USB_G_ANDROID
2655static struct android_usb_platform_data android_usb_pdata = {
2656 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2657};
2658
2659static struct platform_device android_usb_device = {
2660 .name = "android_usb",
2661 .id = -1,
2662 .dev = {
2663 .platform_data = &android_usb_pdata,
2664 },
2665};
2666#endif
2667
2668static struct msm_gpio optnav_config_data[] = {
2669 { GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA),
2670 "optnav_chip_select" },
2671};
2672
Justin Paupore3f40f342011-08-10 18:52:16 -07002673static struct regulator_bulk_data optnav_regulators[] = {
2674 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2675 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
2676 { .supply = "gp9", .min_uV = 1800000, .max_uV = 1800000 },
2677 { .supply = "usb", .min_uV = 3300000, .max_uV = 3300000 },
2678};
2679
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002680static void __iomem *virtual_optnav;
2681
2682static int optnav_gpio_setup(void)
2683{
2684 int rc = -ENODEV;
2685 rc = msm_gpios_request_enable(optnav_config_data,
2686 ARRAY_SIZE(optnav_config_data));
2687
Justin Paupore3f40f342011-08-10 18:52:16 -07002688 if (rc)
2689 return rc;
2690
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002691 /* Configure the FPGA for GPIOs */
2692 virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4);
2693 if (!virtual_optnav) {
2694 pr_err("%s:Could not ioremap region\n", __func__);
2695 return -ENOMEM;
2696 }
2697 /*
2698 * Configure the FPGA to set GPIO 19 as
2699 * normal, active(enabled), output(MSM to SURF)
2700 */
2701 writew(0x311E, virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002702
2703 rc = regulator_bulk_get(NULL, ARRAY_SIZE(optnav_regulators),
2704 optnav_regulators);
2705 if (rc)
2706 return rc;
2707
2708 rc = regulator_bulk_set_voltage(ARRAY_SIZE(optnav_regulators),
2709 optnav_regulators);
2710
2711 if (rc)
2712 goto regulator_put;
2713
2714 return rc;
2715
2716regulator_put:
2717 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002718 return rc;
2719}
2720
2721static void optnav_gpio_release(void)
2722{
2723 msm_gpios_disable_free(optnav_config_data,
2724 ARRAY_SIZE(optnav_config_data));
2725 iounmap(virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002726 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002727}
2728
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002729static int optnav_enable(void)
2730{
2731 int rc;
2732 /*
2733 * Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
2734 * for I2C communication with keyboard.
2735 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002736
Justin Paupore3f40f342011-08-10 18:52:16 -07002737 rc = regulator_bulk_enable(ARRAY_SIZE(optnav_regulators),
2738 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002739
Justin Paupore3f40f342011-08-10 18:52:16 -07002740 if (rc)
2741 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002742
2743 /* Enable the chip select GPIO */
2744 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2745 gpio_set_value(OPTNAV_CHIP_SELECT, 0);
2746
2747 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002748}
2749
2750static void optnav_disable(void)
2751{
Justin Paupore3f40f342011-08-10 18:52:16 -07002752 regulator_bulk_disable(ARRAY_SIZE(optnav_regulators),
2753 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002754
2755 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2756}
2757
2758static struct ofn_atlab_platform_data optnav_data = {
2759 .gpio_setup = optnav_gpio_setup,
2760 .gpio_release = optnav_gpio_release,
2761 .optnav_on = optnav_enable,
2762 .optnav_off = optnav_disable,
2763 .rotate_xy = 0,
2764 .function1 = {
2765 .no_motion1_en = true,
2766 .touch_sensor_en = true,
2767 .ofn_en = true,
2768 .clock_select_khz = 1500,
2769 .cpi_selection = 1200,
2770 },
2771 .function2 = {
2772 .invert_y = false,
2773 .invert_x = true,
2774 .swap_x_y = false,
2775 .hold_a_b_en = true,
2776 .motion_filter_en = true,
2777 },
2778};
2779
2780static int hdmi_comm_power(int on, int show);
2781static int hdmi_init_irq(void);
2782static int hdmi_enable_5v(int on);
2783static int hdmi_core_power(int on, int show);
2784static int hdmi_cec_power(int on);
2785static bool hdmi_check_hdcp_hw_support(void);
2786
2787static struct msm_hdmi_platform_data adv7520_hdmi_data = {
2788 .irq = MSM_GPIO_TO_INT(18),
2789 .comm_power = hdmi_comm_power,
2790 .init_irq = hdmi_init_irq,
2791 .enable_5v = hdmi_enable_5v,
2792 .core_power = hdmi_core_power,
2793 .cec_power = hdmi_cec_power,
2794 .check_hdcp_hw_support = hdmi_check_hdcp_hw_support,
2795};
2796
2797#ifdef CONFIG_BOSCH_BMA150
Justin Paupore3f40f342011-08-10 18:52:16 -07002798
2799static struct regulator_bulk_data sensors_ldo[] = {
2800 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2801 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
2802};
2803
2804static int __init sensors_ldo_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002805{
2806 int rc;
2807
Justin Paupore3f40f342011-08-10 18:52:16 -07002808 rc = regulator_bulk_get(NULL, ARRAY_SIZE(sensors_ldo), sensors_ldo);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002809
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002810 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002811 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2812 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002813 }
2814
Justin Paupore3f40f342011-08-10 18:52:16 -07002815 rc = regulator_bulk_set_voltage(ARRAY_SIZE(sensors_ldo), sensors_ldo);
2816
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002817 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002818 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2819 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002820 }
2821
2822 return 0;
2823
Justin Paupore3f40f342011-08-10 18:52:16 -07002824reg_free:
2825 regulator_bulk_free(ARRAY_SIZE(sensors_ldo), sensors_ldo);
2826out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002827 return rc;
2828}
2829
Justin Paupore3f40f342011-08-10 18:52:16 -07002830static int sensors_ldo_set(int on)
2831{
2832 int rc = on ?
2833 regulator_bulk_enable(ARRAY_SIZE(sensors_ldo), sensors_ldo) :
2834 regulator_bulk_disable(ARRAY_SIZE(sensors_ldo), sensors_ldo);
2835
2836 if (rc)
2837 pr_err("%s: could not %sable regulators: %d\n",
2838 __func__, on ? "en" : "dis", rc);
2839
2840 return rc;
2841}
2842
2843static int sensors_ldo_enable(void)
2844{
2845 return sensors_ldo_set(1);
2846}
2847
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002848static void sensors_ldo_disable(void)
2849{
Justin Paupore3f40f342011-08-10 18:52:16 -07002850 sensors_ldo_set(0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002851}
Justin Paupore3f40f342011-08-10 18:52:16 -07002852
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002853static struct bma150_platform_data bma150_data = {
2854 .power_on = sensors_ldo_enable,
2855 .power_off = sensors_ldo_disable,
2856};
2857
2858static struct i2c_board_info bma150_board_info[] __initdata = {
2859 {
2860 I2C_BOARD_INFO("bma150", 0x38),
2861 .flags = I2C_CLIENT_WAKE,
2862 .irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
2863 .platform_data = &bma150_data,
2864 },
2865};
2866#endif
2867
2868static struct i2c_board_info msm_i2c_board_info[] = {
2869 {
2870 I2C_BOARD_INFO("m33c01", OPTNAV_I2C_SLAVE_ADDR),
2871 .irq = MSM_GPIO_TO_INT(OPTNAV_IRQ),
2872 .platform_data = &optnav_data,
2873 },
2874 {
2875 I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR),
2876 .platform_data = &adv7520_hdmi_data,
2877 },
2878};
2879
2880static struct i2c_board_info msm_marimba_board_info[] = {
2881 {
2882 I2C_BOARD_INFO("marimba", 0xc),
2883 .platform_data = &marimba_pdata,
2884 }
2885};
2886
2887
2888static struct msm_handset_platform_data hs_platform_data = {
2889 .hs_name = "7k_handset",
2890 .pwr_key_delay_ms = 500, /* 0 will disable end key */
2891};
2892
2893static struct platform_device hs_device = {
2894 .name = "msm-handset",
2895 .id = -1,
2896 .dev = {
2897 .platform_data = &hs_platform_data,
2898 },
2899};
2900
2901static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
2902 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
2903 .idle_supported = 1,
2904 .suspend_supported = 1,
2905 .idle_enabled = 1,
2906 .suspend_enabled = 1,
2907 .latency = 8594,
2908 .residency = 23740,
2909 },
2910 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
2911 .idle_supported = 1,
2912 .suspend_supported = 1,
2913 .idle_enabled = 1,
2914 .suspend_enabled = 1,
2915 .latency = 4594,
2916 .residency = 23740,
2917 },
2918 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE] = {
2919#ifdef CONFIG_MSM_STANDALONE_POWER_COLLAPSE
2920 .idle_supported = 1,
2921 .suspend_supported = 1,
2922 .idle_enabled = 1,
2923 .suspend_enabled = 0,
2924#else /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
2925 .idle_supported = 0,
2926 .suspend_supported = 0,
2927 .idle_enabled = 0,
2928 .suspend_enabled = 0,
2929#endif /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
2930 .latency = 500,
2931 .residency = 6000,
2932 },
2933 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
2934 .idle_supported = 1,
2935 .suspend_supported = 1,
2936 .idle_enabled = 0,
2937 .suspend_enabled = 1,
2938 .latency = 443,
2939 .residency = 1098,
2940 },
2941 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
2942 .idle_supported = 1,
2943 .suspend_supported = 1,
2944 .idle_enabled = 1,
2945 .suspend_enabled = 1,
2946 .latency = 2,
2947 .residency = 0,
2948 },
2949};
2950
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06002951static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
2952 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
2953 .v_addr = (uint32_t *)PAGE_OFFSET,
2954};
2955
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002956static struct resource qsd_spi_resources[] = {
2957 {
2958 .name = "spi_irq_in",
2959 .start = INT_SPI_INPUT,
2960 .end = INT_SPI_INPUT,
2961 .flags = IORESOURCE_IRQ,
2962 },
2963 {
2964 .name = "spi_irq_out",
2965 .start = INT_SPI_OUTPUT,
2966 .end = INT_SPI_OUTPUT,
2967 .flags = IORESOURCE_IRQ,
2968 },
2969 {
2970 .name = "spi_irq_err",
2971 .start = INT_SPI_ERROR,
2972 .end = INT_SPI_ERROR,
2973 .flags = IORESOURCE_IRQ,
2974 },
2975 {
2976 .name = "spi_base",
2977 .start = 0xA8000000,
2978 .end = 0xA8000000 + SZ_4K - 1,
2979 .flags = IORESOURCE_MEM,
2980 },
2981 {
2982 .name = "spidm_channels",
2983 .flags = IORESOURCE_DMA,
2984 },
2985 {
2986 .name = "spidm_crci",
2987 .flags = IORESOURCE_DMA,
2988 },
2989};
2990
2991#define AMDH0_BASE_PHYS 0xAC200000
2992#define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
2993static int msm_qsd_spi_dma_config(void)
2994{
2995 void __iomem *ct_adm_base = 0;
2996 u32 spi_mux = 0;
2997 int ret = 0;
2998
2999 ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
3000 if (!ct_adm_base) {
3001 pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
3002 return -ENOMEM;
3003 }
3004
3005 spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
3006
3007 qsd_spi_resources[4].start = DMOV_USB_CHAN;
3008 qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
3009
3010 switch (spi_mux) {
3011 case (1):
3012 qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
3013 qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
3014 break;
3015 case (2):
3016 qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
3017 qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
3018 break;
3019 case (3):
3020 qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
3021 qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
3022 break;
3023 default:
3024 ret = -ENOENT;
3025 }
3026
3027 iounmap(ct_adm_base);
3028
3029 return ret;
3030}
3031
3032static struct platform_device qsd_device_spi = {
3033 .name = "spi_qsd",
3034 .id = 0,
3035 .num_resources = ARRAY_SIZE(qsd_spi_resources),
3036 .resource = qsd_spi_resources,
3037};
3038
3039#ifdef CONFIG_SPI_QSD
3040static struct spi_board_info lcdc_sharp_spi_board_info[] __initdata = {
3041 {
3042 .modalias = "lcdc_sharp_ls038y7dx01",
3043 .mode = SPI_MODE_1,
3044 .bus_num = 0,
3045 .chip_select = 0,
3046 .max_speed_hz = 26331429,
3047 }
3048};
3049static struct spi_board_info lcdc_toshiba_spi_board_info[] __initdata = {
3050 {
3051 .modalias = "lcdc_toshiba_ltm030dd40",
3052 .mode = SPI_MODE_3|SPI_CS_HIGH,
3053 .bus_num = 0,
3054 .chip_select = 0,
3055 .max_speed_hz = 9963243,
3056 }
3057};
3058#endif
3059
3060static struct msm_gpio qsd_spi_gpio_config_data[] = {
3061 { GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3062 { GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3063 { GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" },
3064 { GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3065};
3066
3067static int msm_qsd_spi_gpio_config(void)
3068{
3069 return msm_gpios_request_enable(qsd_spi_gpio_config_data,
3070 ARRAY_SIZE(qsd_spi_gpio_config_data));
3071}
3072
3073static void msm_qsd_spi_gpio_release(void)
3074{
3075 msm_gpios_disable_free(qsd_spi_gpio_config_data,
3076 ARRAY_SIZE(qsd_spi_gpio_config_data));
3077}
3078
3079static struct msm_spi_platform_data qsd_spi_pdata = {
3080 .max_clock_speed = 26331429,
3081 .gpio_config = msm_qsd_spi_gpio_config,
3082 .gpio_release = msm_qsd_spi_gpio_release,
3083 .dma_config = msm_qsd_spi_dma_config,
3084};
3085
3086static void __init msm_qsd_spi_init(void)
3087{
3088 qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
3089}
3090
3091#ifdef CONFIG_USB_EHCI_MSM_72K
3092static void msm_hsusb_vbus_power(unsigned phy_info, int on)
3093{
3094 int rc;
3095 static int vbus_is_on;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303096 struct pm8xxx_gpio_init_info usb_vbus = {
3097 PM8058_GPIO_PM_TO_SYS(36),
3098 {
3099 .direction = PM_GPIO_DIR_OUT,
3100 .pull = PM_GPIO_PULL_NO,
3101 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3102 .output_value = 1,
3103 .vin_sel = 2,
3104 .out_strength = PM_GPIO_STRENGTH_MED,
3105 .function = PM_GPIO_FUNC_NORMAL,
3106 .inv_int_pol = 0,
3107 },
3108 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003109
3110 /* If VBUS is already on (or off), do nothing. */
3111 if (unlikely(on == vbus_is_on))
3112 return;
3113
3114 if (on) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303115 rc = pm8xxx_gpio_config(usb_vbus.gpio, &usb_vbus.config);
3116 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003117 pr_err("%s PMIC GPIO 36 write failed\n", __func__);
3118 return;
3119 }
3120 } else {
3121 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(36), 0);
3122 }
3123
3124 vbus_is_on = on;
3125}
3126
3127static struct msm_usb_host_platform_data msm_usb_host_pdata = {
3128 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
3129 .vbus_power = msm_hsusb_vbus_power,
3130 .power_budget = 180,
3131};
3132#endif
3133
3134#ifdef CONFIG_USB_MSM_OTG_72K
3135static int hsusb_rpc_connect(int connect)
3136{
3137 if (connect)
3138 return msm_hsusb_rpc_connect();
3139 else
3140 return msm_hsusb_rpc_close();
3141}
3142#endif
3143
3144#ifdef CONFIG_USB_MSM_OTG_72K
Justin Paupore3f40f342011-08-10 18:52:16 -07003145static struct regulator *vreg_3p3;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003146static int msm_hsusb_ldo_init(int init)
3147{
3148 uint32_t version = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07003149 int def_vol = 3400000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003150
3151 version = socinfo_get_version();
3152
3153 if (SOCINFO_VERSION_MAJOR(version) >= 2 &&
3154 SOCINFO_VERSION_MINOR(version) >= 1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003155 def_vol = 3075000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003156 pr_debug("%s: default voltage:%d\n", __func__, def_vol);
3157 }
3158
3159 if (init) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003160 vreg_3p3 = regulator_get(NULL, "usb");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003161 if (IS_ERR(vreg_3p3))
3162 return PTR_ERR(vreg_3p3);
Justin Paupore3f40f342011-08-10 18:52:16 -07003163 regulator_set_voltage(vreg_3p3, def_vol, def_vol);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003164 } else
Justin Paupore3f40f342011-08-10 18:52:16 -07003165 regulator_put(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003166
3167 return 0;
3168}
3169
3170static int msm_hsusb_ldo_enable(int enable)
3171{
3172 static int ldo_status;
3173
3174 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3175 return -ENODEV;
3176
3177 if (ldo_status == enable)
3178 return 0;
3179
3180 ldo_status = enable;
3181
3182 if (enable)
Justin Paupore3f40f342011-08-10 18:52:16 -07003183 return regulator_enable(vreg_3p3);
3184 else
3185 return regulator_disable(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003186}
3187
3188static int msm_hsusb_ldo_set_voltage(int mV)
3189{
Justin Paupore3f40f342011-08-10 18:52:16 -07003190 static int cur_voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003191
3192 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3193 return -ENODEV;
3194
3195 if (cur_voltage == mV)
3196 return 0;
3197
3198 cur_voltage = mV;
3199
3200 pr_debug("%s: (%d)\n", __func__, mV);
3201
Justin Paupore3f40f342011-08-10 18:52:16 -07003202 return regulator_set_voltage(vreg_3p3, mV*1000, mV*1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003203}
3204#endif
3205
3206#ifndef CONFIG_USB_EHCI_MSM_72K
3207static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init);
3208#endif
3209static struct msm_otg_platform_data msm_otg_pdata = {
3210 .rpc_connect = hsusb_rpc_connect,
3211
3212#ifndef CONFIG_USB_EHCI_MSM_72K
3213 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
3214#else
3215 .vbus_power = msm_hsusb_vbus_power,
3216#endif
3217 .core_clk = 1,
3218 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
3219 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
3220 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
3221 .se1_gating = SE1_GATING_DISABLE,
3222 .chg_vbus_draw = hsusb_chg_vbus_draw,
3223 .chg_connected = hsusb_chg_connected,
3224 .chg_init = hsusb_chg_init,
3225 .ldo_enable = msm_hsusb_ldo_enable,
3226 .ldo_init = msm_hsusb_ldo_init,
3227 .ldo_set_voltage = msm_hsusb_ldo_set_voltage,
3228};
3229
3230#ifdef CONFIG_USB_GADGET
3231static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
3232 .is_phy_status_timer_on = 1,
3233};
3234#endif
3235#ifndef CONFIG_USB_EHCI_MSM_72K
3236typedef void (*notify_vbus_state) (int);
3237notify_vbus_state notify_vbus_state_func_ptr;
3238int vbus_on_irq;
3239static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
3240{
3241 pr_info("%s: vbus notification from pmic\n", __func__);
3242
3243 (*notify_vbus_state_func_ptr) (1);
3244
3245 return IRQ_HANDLED;
3246}
3247static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
3248{
3249 int ret;
3250
3251 if (init) {
3252 if (!callback)
3253 return -ENODEV;
3254
3255 notify_vbus_state_func_ptr = callback;
3256 vbus_on_irq = platform_get_irq_byname(&msm_device_otg,
3257 "vbus_on");
3258 if (vbus_on_irq <= 0) {
3259 pr_err("%s: unable to get vbus on irq\n", __func__);
3260 return -ENODEV;
3261 }
3262
3263 ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq,
3264 IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
3265 if (ret < 0) {
3266 pr_info("%s: request_irq for vbus_on"
3267 "interrupt failed\n", __func__);
3268 return ret;
3269 }
3270 msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
3271 return 0;
3272 } else {
3273 free_irq(vbus_on_irq, 0);
3274 notify_vbus_state_func_ptr = NULL;
3275 return 0;
3276 }
3277}
3278#endif
3279
3280static struct android_pmem_platform_data android_pmem_pdata = {
3281 .name = "pmem",
3282 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
3283 .cached = 1,
3284 .memory_type = MEMTYPE_EBI0,
3285};
3286
3287static struct platform_device android_pmem_device = {
3288 .name = "android_pmem",
3289 .id = 0,
3290 .dev = { .platform_data = &android_pmem_pdata },
3291};
3292
3293#ifndef CONFIG_SPI_QSD
3294static int lcdc_gpio_array_num[] = {
3295 45, /* spi_clk */
3296 46, /* spi_cs */
3297 47, /* spi_mosi */
3298 48, /* spi_miso */
3299 };
3300
3301static struct msm_gpio lcdc_gpio_config_data[] = {
3302 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3303 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3304 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
3305 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3306};
3307
3308static void lcdc_config_gpios(int enable)
3309{
3310 if (enable) {
3311 msm_gpios_request_enable(lcdc_gpio_config_data,
3312 ARRAY_SIZE(
3313 lcdc_gpio_config_data));
3314 } else
3315 msm_gpios_disable_free(lcdc_gpio_config_data,
3316 ARRAY_SIZE(
3317 lcdc_gpio_config_data));
3318}
3319#endif
3320
3321static struct msm_panel_common_pdata lcdc_sharp_panel_data = {
3322#ifndef CONFIG_SPI_QSD
3323 .panel_config_gpio = lcdc_config_gpios,
3324 .gpio_num = lcdc_gpio_array_num,
3325#endif
3326 .gpio = 2, /* LPG PMIC_GPIO26 channel number */
3327};
3328
3329static struct platform_device lcdc_sharp_panel_device = {
3330 .name = "lcdc_sharp_wvga",
3331 .id = 0,
3332 .dev = {
3333 .platform_data = &lcdc_sharp_panel_data,
3334 }
3335};
3336
3337static struct msm_gpio dtv_panel_irq_gpios[] = {
3338 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
3339 "hdmi_int" },
3340};
3341
3342static struct msm_gpio dtv_panel_gpios[] = {
3343 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
3344 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
3345 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
3346 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
3347 { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
3348 { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
3349 { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
3350 { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
3351 { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
3352 { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
3353 { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
3354 { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
3355 { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
3356 { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
3357 { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
3358 { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
3359 { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
3360 { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
3361 { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
3362 { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
3363 { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
3364 { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
3365 { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
3366 { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
3367 { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
3368 { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
3369 { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
3370 { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
3371 { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
3372 { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
3373 { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
3374 { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
3375};
3376
3377
3378#ifdef HDMI_RESET
3379static unsigned dtv_reset_gpio =
3380 GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3381#endif
3382
Justin Paupore3f40f342011-08-10 18:52:16 -07003383static struct regulator_bulk_data hdmi_core_regs[] = {
3384 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3385};
3386
3387static struct regulator_bulk_data hdmi_comm_regs[] = {
3388 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3389 { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 },
3390};
3391
3392static struct regulator_bulk_data hdmi_cec_regs[] = {
3393 { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 },
3394};
3395
3396static int __init hdmi_init_regs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003397{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003398 int rc;
3399
Justin Paupore3f40f342011-08-10 18:52:16 -07003400 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs),
3401 hdmi_core_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003402
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003403 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003404 pr_err("%s: could not get %s regulators: %d\n",
3405 __func__, "core", rc);
3406 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003407 }
3408
Justin Paupore3f40f342011-08-10 18:52:16 -07003409 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs),
3410 hdmi_core_regs);
3411
3412 if (rc) {
3413 pr_err("%s: could not set %s voltages: %d\n",
3414 __func__, "core", rc);
3415 goto free_core;
3416 }
3417
3418 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs),
3419 hdmi_comm_regs);
3420
3421 if (rc) {
3422 pr_err("%s: could not get %s regulators: %d\n",
3423 __func__, "comm", rc);
3424 goto free_core;
3425 }
3426
3427 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs),
3428 hdmi_comm_regs);
3429
3430 if (rc) {
3431 pr_err("%s: could not set %s voltages: %d\n",
3432 __func__, "comm", rc);
3433 goto free_comm;
3434 }
3435
3436 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs),
3437 hdmi_cec_regs);
3438
3439 if (rc) {
3440 pr_err("%s: could not get %s regulators: %d\n",
3441 __func__, "cec", rc);
3442 goto free_comm;
3443 }
3444
3445 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs),
3446 hdmi_cec_regs);
3447
3448 if (rc) {
3449 pr_err("%s: could not set %s voltages: %d\n",
3450 __func__, "cec", rc);
3451 goto free_cec;
3452 }
3453
3454 return 0;
3455
3456free_cec:
3457 regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs);
3458free_comm:
3459 regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs);
3460free_core:
3461 regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs);
3462out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003463 return rc;
3464}
3465
Justin Paupore3f40f342011-08-10 18:52:16 -07003466static int hdmi_init_irq(void)
3467{
3468 int rc = msm_gpios_enable(dtv_panel_irq_gpios,
3469 ARRAY_SIZE(dtv_panel_irq_gpios));
3470 if (rc < 0) {
3471 pr_err("%s: gpio enable failed: %d\n", __func__, rc);
3472 return rc;
3473 }
3474 pr_info("%s\n", __func__);
3475
3476 return 0;
3477}
3478
3479static int hdmi_enable_5v(int on)
3480{
3481 int pmic_gpio_hdmi_5v_en ;
3482
3483 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
3484 machine_is_msm7x30_fluid())
3485 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
3486 else
3487 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
3488
3489 pr_info("%s: %d\n", __func__, on);
3490 if (on) {
3491 int rc;
3492 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
3493 "hdmi_5V_en");
3494 if (rc) {
3495 pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
3496 __func__);
3497 return rc;
3498 }
3499 gpio_set_value_cansleep(
3500 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
3501 } else {
3502 gpio_set_value_cansleep(
3503 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
3504 gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
3505 }
3506 return 0;
3507}
3508
3509static int hdmi_comm_power(int on, int show)
3510{
3511 if (show)
3512 pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
3513 return on ?
3514 regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs),
3515 hdmi_comm_regs) :
3516 regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs),
3517 hdmi_comm_regs);
3518}
3519
3520static int hdmi_core_power(int on, int show)
3521{
3522 if (show)
3523 pr_info("%s: %d <LDO8>\n", __func__, on);
3524 return on ?
3525 regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs),
3526 hdmi_core_regs) :
3527 regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs),
3528 hdmi_core_regs);
3529}
3530
3531static int hdmi_cec_power(int on)
3532{
3533 pr_info("%s: %d <LDO17>\n", __func__, on);
3534 return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs),
3535 hdmi_cec_regs) :
3536 regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs),
3537 hdmi_cec_regs);
3538}
3539
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003540#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
3541/* there is an i2c address conflict between adv7520 and bma150 sensor after
3542 * power up on fluid. As a solution, the default address of adv7520's packet
3543 * memory is changed as soon as possible
3544 */
3545static int __init fluid_i2c_address_fixup(void)
3546{
3547 unsigned char wBuff[16];
3548 unsigned char rBuff[16];
3549 struct i2c_msg msgs[3];
3550 int res;
3551 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003552 struct i2c_adapter *adapter;
3553
3554 if (machine_is_msm7x30_fluid()) {
3555 adapter = i2c_get_adapter(0);
3556 if (!adapter) {
3557 pr_err("%s: invalid i2c adapter\n", __func__);
3558 return PTR_ERR(adapter);
3559 }
3560
3561 /* turn on LDO8 */
Justin Paupore3f40f342011-08-10 18:52:16 -07003562 rc = hdmi_core_power(1, 0);
3563 if (rc) {
3564 pr_err("%s: could not enable hdmi core regs: %d",
3565 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003566 goto adapter_put;
3567 }
3568
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003569 /* change packet memory address to 0x74 */
3570 wBuff[0] = 0x45;
3571 wBuff[1] = 0x74;
3572
3573 msgs[0].addr = ADV7520_I2C_ADDR;
3574 msgs[0].flags = 0;
3575 msgs[0].buf = (unsigned char *) wBuff;
3576 msgs[0].len = 2;
3577
3578 res = i2c_transfer(adapter, msgs, 1);
3579 if (res != 1) {
3580 pr_err("%s: error writing adv7520\n", __func__);
3581 goto ldo8_disable;
3582 }
3583
3584 /* powerdown adv7520 using bit 6 */
3585 /* i2c read first */
3586 wBuff[0] = 0x41;
3587
3588 msgs[0].addr = ADV7520_I2C_ADDR;
3589 msgs[0].flags = 0;
3590 msgs[0].buf = (unsigned char *) wBuff;
3591 msgs[0].len = 1;
3592
3593 msgs[1].addr = ADV7520_I2C_ADDR;
3594 msgs[1].flags = I2C_M_RD;
3595 msgs[1].buf = rBuff;
3596 msgs[1].len = 1;
3597 res = i2c_transfer(adapter, msgs, 2);
3598 if (res != 2) {
3599 pr_err("%s: error reading adv7520\n", __func__);
3600 goto ldo8_disable;
3601 }
3602
3603 /* i2c write back */
3604 wBuff[0] = 0x41;
3605 wBuff[1] = rBuff[0] | 0x40;
3606
3607 msgs[0].addr = ADV7520_I2C_ADDR;
3608 msgs[0].flags = 0;
3609 msgs[0].buf = (unsigned char *) wBuff;
3610 msgs[0].len = 2;
3611
3612 res = i2c_transfer(adapter, msgs, 1);
3613 if (res != 1) {
3614 pr_err("%s: error writing adv7520\n", __func__);
3615 goto ldo8_disable;
3616 }
3617
3618 /* for successful fixup, we release the i2c adapter */
3619 /* but leave ldo8 on so that the adv7520 is not repowered */
3620 i2c_put_adapter(adapter);
3621 pr_info("%s: fluid i2c address conflict resolved\n", __func__);
3622 }
3623 return 0;
3624
3625ldo8_disable:
Justin Paupore3f40f342011-08-10 18:52:16 -07003626 hdmi_core_power(0, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003627adapter_put:
3628 i2c_put_adapter(adapter);
3629 return rc;
3630}
3631fs_initcall_sync(fluid_i2c_address_fixup);
3632#endif
3633
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003634static bool hdmi_check_hdcp_hw_support(void)
3635{
3636 if (machine_is_msm7x30_fluid())
3637 return false;
3638 else
3639 return true;
3640}
3641
3642static int dtv_panel_power(int on)
3643{
3644 int flag_on = !!on;
3645 static int dtv_power_save_on;
3646 int rc;
3647
3648 if (dtv_power_save_on == flag_on)
3649 return 0;
3650
3651 dtv_power_save_on = flag_on;
3652 pr_info("%s: %d\n", __func__, on);
3653
3654#ifdef HDMI_RESET
3655 if (on) {
3656 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
3657 rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
3658 if (rc) {
3659 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
3660 __func__, dtv_reset_gpio, rc);
3661 return rc;
3662 }
3663
3664 /* bring reset line low to hold reset*/
3665 gpio_set_value(37, 0);
3666 }
3667#endif
3668
3669 if (on) {
3670 rc = msm_gpios_enable(dtv_panel_gpios,
3671 ARRAY_SIZE(dtv_panel_gpios));
3672 if (rc < 0) {
3673 printk(KERN_ERR "%s: gpio enable failed: %d\n",
3674 __func__, rc);
3675 return rc;
3676 }
3677 } else {
3678 rc = msm_gpios_disable(dtv_panel_gpios,
3679 ARRAY_SIZE(dtv_panel_gpios));
3680 if (rc < 0) {
3681 printk(KERN_ERR "%s: gpio disable failed: %d\n",
3682 __func__, rc);
3683 return rc;
3684 }
3685 }
3686
3687 mdelay(5); /* ensure power is stable */
3688
3689#ifdef HDMI_RESET
3690 if (on) {
3691 gpio_set_value(37, 1); /* bring reset line high */
3692 mdelay(10); /* 10 msec before IO can be accessed */
3693 }
3694#endif
3695
3696 return rc;
3697}
3698
3699static struct lcdc_platform_data dtv_pdata = {
3700 .lcdc_power_save = dtv_panel_power,
3701};
3702
3703static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3704 .inject_rx_on_wakeup = 1,
3705 .rx_to_inject = 0xFD,
3706};
3707
3708static struct resource msm_fb_resources[] = {
3709 {
3710 .flags = IORESOURCE_DMA,
3711 }
3712};
3713
3714static int msm_fb_detect_panel(const char *name)
3715{
3716 if (machine_is_msm7x30_fluid()) {
3717 if (!strcmp(name, "lcdc_sharp_wvga_pt"))
3718 return 0;
3719 } else {
3720 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
3721 return -EPERM;
3722 else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20))
3723 return 0;
3724 else if (!strcmp(name, "mddi_orise"))
3725 return -EPERM;
3726 else if (!strcmp(name, "mddi_quickvx"))
3727 return -EPERM;
3728 }
3729 return -ENODEV;
3730}
3731
3732static struct msm_fb_platform_data msm_fb_pdata = {
3733 .detect_client = msm_fb_detect_panel,
3734 .mddi_prescan = 1,
3735};
3736
3737static struct platform_device msm_fb_device = {
3738 .name = "msm_fb",
3739 .id = 0,
3740 .num_resources = ARRAY_SIZE(msm_fb_resources),
3741 .resource = msm_fb_resources,
3742 .dev = {
3743 .platform_data = &msm_fb_pdata,
3744 }
3745};
3746
3747static struct platform_device msm_migrate_pages_device = {
3748 .name = "msm_migrate_pages",
3749 .id = -1,
3750};
3751
3752static struct android_pmem_platform_data android_pmem_adsp_pdata = {
3753 .name = "pmem_adsp",
3754 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
3755 .cached = 0,
3756 .memory_type = MEMTYPE_EBI0,
3757};
3758
3759static struct android_pmem_platform_data android_pmem_audio_pdata = {
3760 .name = "pmem_audio",
3761 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
3762 .cached = 0,
3763 .memory_type = MEMTYPE_EBI0,
3764};
3765
3766static struct platform_device android_pmem_adsp_device = {
3767 .name = "android_pmem",
3768 .id = 2,
3769 .dev = { .platform_data = &android_pmem_adsp_pdata },
3770};
3771
3772static struct platform_device android_pmem_audio_device = {
3773 .name = "android_pmem",
3774 .id = 4,
3775 .dev = { .platform_data = &android_pmem_audio_pdata },
3776};
3777
3778#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3779 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
3780 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3781 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3782
3783#define QCE_SIZE 0x10000
3784#define QCE_0_BASE 0xA8400000
3785
3786#define QCE_HW_KEY_SUPPORT 1
3787#define QCE_SHA_HMAC_SUPPORT 0
3788#define QCE_SHARE_CE_RESOURCE 0
3789#define QCE_CE_SHARED 0
3790
3791static struct resource qcrypto_resources[] = {
3792 [0] = {
3793 .start = QCE_0_BASE,
3794 .end = QCE_0_BASE + QCE_SIZE - 1,
3795 .flags = IORESOURCE_MEM,
3796 },
3797 [1] = {
3798 .name = "crypto_channels",
3799 .start = DMOV_CE_IN_CHAN,
3800 .end = DMOV_CE_OUT_CHAN,
3801 .flags = IORESOURCE_DMA,
3802 },
3803 [2] = {
3804 .name = "crypto_crci_in",
3805 .start = DMOV_CE_IN_CRCI,
3806 .end = DMOV_CE_IN_CRCI,
3807 .flags = IORESOURCE_DMA,
3808 },
3809 [3] = {
3810 .name = "crypto_crci_out",
3811 .start = DMOV_CE_OUT_CRCI,
3812 .end = DMOV_CE_OUT_CRCI,
3813 .flags = IORESOURCE_DMA,
3814 },
3815 [4] = {
3816 .name = "crypto_crci_hash",
3817 .start = DMOV_CE_HASH_CRCI,
3818 .end = DMOV_CE_HASH_CRCI,
3819 .flags = IORESOURCE_DMA,
3820 },
3821};
3822
3823static struct resource qcedev_resources[] = {
3824 [0] = {
3825 .start = QCE_0_BASE,
3826 .end = QCE_0_BASE + QCE_SIZE - 1,
3827 .flags = IORESOURCE_MEM,
3828 },
3829 [1] = {
3830 .name = "crypto_channels",
3831 .start = DMOV_CE_IN_CHAN,
3832 .end = DMOV_CE_OUT_CHAN,
3833 .flags = IORESOURCE_DMA,
3834 },
3835 [2] = {
3836 .name = "crypto_crci_in",
3837 .start = DMOV_CE_IN_CRCI,
3838 .end = DMOV_CE_IN_CRCI,
3839 .flags = IORESOURCE_DMA,
3840 },
3841 [3] = {
3842 .name = "crypto_crci_out",
3843 .start = DMOV_CE_OUT_CRCI,
3844 .end = DMOV_CE_OUT_CRCI,
3845 .flags = IORESOURCE_DMA,
3846 },
3847 [4] = {
3848 .name = "crypto_crci_hash",
3849 .start = DMOV_CE_HASH_CRCI,
3850 .end = DMOV_CE_HASH_CRCI,
3851 .flags = IORESOURCE_DMA,
3852 },
3853};
3854
3855#endif
3856
3857#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3858 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
3859
3860static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
3861 .ce_shared = QCE_CE_SHARED,
3862 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
3863 .hw_key_support = QCE_HW_KEY_SUPPORT,
3864 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
3865};
3866
3867static struct platform_device qcrypto_device = {
3868 .name = "qcrypto",
3869 .id = 0,
3870 .num_resources = ARRAY_SIZE(qcrypto_resources),
3871 .resource = qcrypto_resources,
3872 .dev = {
3873 .coherent_dma_mask = DMA_BIT_MASK(32),
3874 .platform_data = &qcrypto_ce_hw_suppport,
3875 },
3876};
3877#endif
3878
3879#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3880 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3881
3882static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
3883 .ce_shared = QCE_CE_SHARED,
3884 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
3885 .hw_key_support = QCE_HW_KEY_SUPPORT,
3886 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
3887};
3888static struct platform_device qcedev_device = {
3889 .name = "qce",
3890 .id = 0,
3891 .num_resources = ARRAY_SIZE(qcedev_resources),
3892 .resource = qcedev_resources,
3893 .dev = {
3894 .coherent_dma_mask = DMA_BIT_MASK(32),
3895 .platform_data = &qcedev_ce_hw_suppport,
3896 },
3897};
3898#endif
3899
3900static int mddi_toshiba_pmic_bl(int level)
3901{
3902 int ret = -EPERM;
3903
3904 ret = pmic_set_led_intensity(LED_LCD, level);
3905
3906 if (ret)
3907 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
3908 __func__);
3909 return ret;
3910}
3911
3912static struct msm_panel_common_pdata mddi_toshiba_pdata = {
3913 .pmic_backlight = mddi_toshiba_pmic_bl,
3914};
3915
3916static struct platform_device mddi_toshiba_device = {
3917 .name = "mddi_toshiba",
3918 .id = 0,
3919 .dev = {
3920 .platform_data = &mddi_toshiba_pdata,
3921 }
3922};
3923
3924static unsigned wega_reset_gpio =
3925 GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3926
3927static struct msm_gpio fluid_vee_reset_gpio[] = {
3928 { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
3929};
3930
3931static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1;
3932static unsigned char quickvx_ldo_enabled;
3933
3934static unsigned quickvx_vlp_gpio =
3935 GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3936
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303937static struct pm8xxx_gpio_init_info pmic_quickvx_clk_gpio = {
3938 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_QUICKVX_CLK),
3939 {
3940 .direction = PM_GPIO_DIR_OUT,
3941 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3942 .output_value = 1,
3943 .pull = PM_GPIO_PULL_NO,
3944 .vin_sel = PM8058_GPIO_VIN_S3,
3945 .out_strength = PM_GPIO_STRENGTH_HIGH,
3946 .function = PM_GPIO_FUNC_2,
3947 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003948};
3949
Justin Paupore3f40f342011-08-10 18:52:16 -07003950static struct regulator *mddi_ldo20;
3951static struct regulator *mddi_ldo12;
3952static struct regulator *mddi_ldo16;
3953static struct regulator *mddi_ldo6;
3954static struct regulator *mddi_lcd;
3955
3956static int display_common_init(void)
3957{
3958 struct regulator_bulk_data regs[5] = {
3959 { .supply = "ldo20", /* voltage set in display_common_power */},
3960 { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 },
3961 { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 },
3962 { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 },
3963 { .supply = NULL, /* mddi_lcd, initialized below */ },
3964 };
3965
3966 int rc = 0;
3967
3968 if (machine_is_msm7x30_fluid()) {
3969 /* lcd: LDO8 @1.8V */
3970 regs[4].supply = "ldo8";
3971 regs[4].min_uV = 1800000;
3972 regs[4].max_uV = 1800000;
3973 } else {
3974 /* lcd: LDO15 @3.1V */
3975 regs[4].supply = "ldo15";
3976 regs[4].min_uV = 3100000;
3977 regs[4].max_uV = 3100000;
3978 }
3979
3980 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
3981 if (rc) {
3982 pr_err("%s: regulator_bulk_get failed: %d\n",
3983 __func__, rc);
3984 goto bail;
3985 }
3986
3987 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
3988 if (rc) {
3989 pr_err("%s: regulator_bulk_set_voltage failed: %d\n",
3990 __func__, rc);
3991 goto put_regs;
3992 }
3993
3994 mddi_ldo20 = regs[0].consumer;
3995 mddi_ldo12 = regs[1].consumer;
3996 mddi_ldo6 = regs[2].consumer;
3997 mddi_ldo16 = regs[3].consumer;
3998 mddi_lcd = regs[4].consumer;
3999
4000 return rc;
4001
4002put_regs:
4003 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4004bail:
4005 return rc;
4006}
4007
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004008static int display_common_power(int on)
4009{
4010 int rc = 0, flag_on = !!on;
4011 static int display_common_power_save_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004012 static bool display_regs_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004013
4014 if (display_common_power_save_on == flag_on)
4015 return 0;
4016
4017 display_common_power_save_on = flag_on;
4018
Justin Paupore3f40f342011-08-10 18:52:16 -07004019 if (unlikely(!display_regs_initialized)) {
4020 rc = display_common_init();
4021 if (rc) {
4022 pr_err("%s: regulator init failed: %d\n",
4023 __func__, rc);
4024 return rc;
4025 }
4026 display_regs_initialized = true;
4027 }
4028
4029
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004030 if (on) {
4031 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
4032 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
4033 if (rc) {
4034 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4035 __func__, wega_reset_gpio, rc);
4036 return rc;
4037 }
4038
4039 /* bring reset line low to hold reset*/
4040 gpio_set_value(180, 0);
4041
4042 if (quickvx_mddi_client) {
4043 /* QuickVX chip -- VLP pin -- gpio 97 */
4044 rc = gpio_tlmm_config(quickvx_vlp_gpio,
4045 GPIO_CFG_ENABLE);
4046 if (rc) {
4047 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4048 __func__, quickvx_vlp_gpio, rc);
4049 return rc;
4050 }
4051
4052 /* bring QuickVX VLP line low */
4053 gpio_set_value(97, 0);
4054
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304055 rc = pm8xxx_gpio_config(pmic_quickvx_clk_gpio.gpio,
4056 &pmic_quickvx_clk_gpio.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004057 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304058 pr_err("%s: pm8xxx_gpio_config(%#x)=%d\n",
4059 __func__, pmic_quickvx_clk_gpio.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004060 rc);
4061 return rc;
4062 }
4063
4064 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4065 PMIC_GPIO_QUICKVX_CLK), 0);
4066 }
4067 }
4068
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004069 if (quickvx_mddi_client)
Justin Paupore3f40f342011-08-10 18:52:16 -07004070 rc = regulator_set_voltage(mddi_ldo20, 1800000, 1800000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004071 else
Justin Paupore3f40f342011-08-10 18:52:16 -07004072 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000);
4073
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004074 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004075 pr_err("%s: could not set voltage for ldo20: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004076 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07004077 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004078 }
4079
4080 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004081 rc = regulator_enable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004082 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004083 pr_err("%s: LDO20 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004084 __func__, rc);
4085 return rc;
4086 }
4087
Justin Paupore3f40f342011-08-10 18:52:16 -07004088 rc = regulator_enable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004089 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004090 pr_err("%s: LDO12 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004091 __func__, rc);
4092 return rc;
4093 }
4094
4095 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004096 rc = regulator_enable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004097 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004098 pr_err("%s: LDO16 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004099 __func__, rc);
4100 return rc;
4101 }
4102 }
4103
Justin Paupore3f40f342011-08-10 18:52:16 -07004104 if (quickvx_ldo_enabled) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004105 /* Disable LDO6 during display ON */
Justin Paupore3f40f342011-08-10 18:52:16 -07004106 rc = regulator_disable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004107 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004108 pr_err("%s: LDO6 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004109 __func__, rc);
4110 return rc;
4111 }
4112 quickvx_ldo_enabled = 0;
4113 }
4114
Justin Paupore3f40f342011-08-10 18:52:16 -07004115 rc = regulator_enable(mddi_lcd);
4116 if (rc) {
4117 pr_err("%s: LCD regulator enable failed (%d)\n",
4118 __func__, rc);
4119 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004120 }
4121
4122 mdelay(5); /* ensure power is stable */
4123
4124 if (machine_is_msm7x30_fluid()) {
4125 rc = msm_gpios_request_enable(fluid_vee_reset_gpio,
4126 ARRAY_SIZE(fluid_vee_reset_gpio));
4127 if (rc)
4128 pr_err("%s gpio_request_enable failed rc=%d\n",
4129 __func__, rc);
4130 else {
4131 /* assert vee reset_n */
4132 gpio_set_value(20, 1);
4133 gpio_set_value(20, 0);
4134 mdelay(1);
4135 gpio_set_value(20, 1);
4136 }
4137 }
4138
4139 gpio_set_value(180, 1); /* bring reset line high */
4140 mdelay(10); /* 10 msec before IO can be accessed */
4141
4142 if (quickvx_mddi_client) {
4143 gpio_set_value(97, 1);
4144 msleep(2);
4145 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4146 PMIC_GPIO_QUICKVX_CLK), 1);
4147 msleep(2);
4148 }
4149
4150 rc = pmapp_display_clock_config(1);
4151 if (rc) {
4152 pr_err("%s pmapp_display_clock_config rc=%d\n",
4153 __func__, rc);
4154 return rc;
4155 }
4156
4157 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004158 rc = regulator_disable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004159 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004160 pr_err("%s: LDO20 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004161 __func__, rc);
4162 return rc;
4163 }
4164
4165
4166 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004167 rc = regulator_disable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004168 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004169 pr_err("%s: LDO16 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004170 __func__, rc);
4171 return rc;
4172 }
4173 }
4174
4175 if (quickvx_mddi_client && !quickvx_ldo_enabled) {
4176 /* Enable LDO6 during display OFF for
4177 Quicklogic chip to sleep with data retention */
Justin Paupore3f40f342011-08-10 18:52:16 -07004178 rc = regulator_enable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004179 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004180 pr_err("%s: LDO6 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004181 __func__, rc);
4182 return rc;
4183 }
4184 quickvx_ldo_enabled = 1;
4185 }
4186
4187 gpio_set_value(180, 0); /* bring reset line low */
4188
4189 if (quickvx_mddi_client) {
4190 gpio_set_value(97, 0);
4191 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4192 PMIC_GPIO_QUICKVX_CLK), 0);
4193 }
4194
Justin Paupore3f40f342011-08-10 18:52:16 -07004195 rc = regulator_disable(mddi_lcd);
4196 if (rc) {
4197 pr_err("%s: LCD regulator disable failed (%d)\n",
4198 __func__, rc);
4199 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004200 }
4201
4202 mdelay(5); /* ensure power is stable */
4203
Justin Paupore3f40f342011-08-10 18:52:16 -07004204 rc = regulator_disable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004205 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004206 pr_err("%s: LDO12 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004207 __func__, rc);
4208 return rc;
4209 }
4210
4211 if (machine_is_msm7x30_fluid()) {
4212 msm_gpios_disable_free(fluid_vee_reset_gpio,
4213 ARRAY_SIZE(fluid_vee_reset_gpio));
4214 }
4215
4216 rc = pmapp_display_clock_config(0);
4217 if (rc) {
4218 pr_err("%s pmapp_display_clock_config rc=%d\n",
4219 __func__, rc);
4220 return rc;
4221 }
4222 }
4223
4224 return rc;
4225}
4226
4227static int msm_fb_mddi_sel_clk(u32 *clk_rate)
4228{
4229 *clk_rate *= 2;
4230 return 0;
4231}
4232
4233static int msm_fb_mddi_client_power(u32 client_id)
4234{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004235 printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
4236 /* Check if it is Quicklogic client */
4237 if (client_id == 0xc5835800) {
4238 printk(KERN_NOTICE "\n Quicklogic MDDI client");
4239 other_mddi_client = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004240 } else {
4241 printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
4242 quickvx_mddi_client = 0;
4243 gpio_set_value(97, 0);
4244 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4245 PMIC_GPIO_QUICKVX_CLK), 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004246 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004247
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004248 return 0;
4249}
4250
4251static struct mddi_platform_data mddi_pdata = {
4252 .mddi_power_save = display_common_power,
4253 .mddi_sel_clk = msm_fb_mddi_sel_clk,
4254 .mddi_client_power = msm_fb_mddi_client_power,
4255};
4256
4257int mdp_core_clk_rate_table[] = {
4258 122880000,
4259 122880000,
Pradeep Jilagam3cc12f92011-07-26 22:25:18 +05304260 192000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004261 192000000,
4262};
4263
4264static struct msm_panel_common_pdata mdp_pdata = {
4265 .hw_revision_addr = 0xac001270,
4266 .gpio = 30,
4267 .mdp_core_clk_rate = 122880000,
4268 .mdp_core_clk_table = mdp_core_clk_rate_table,
4269 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07004270 .mdp_rev = MDP_REV_40,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004271};
4272
4273static int lcd_panel_spi_gpio_num[] = {
4274 45, /* spi_clk */
4275 46, /* spi_cs */
4276 47, /* spi_mosi */
4277 48, /* spi_miso */
4278 };
4279
4280static struct msm_gpio lcd_panel_gpios[] = {
4281/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
4282 * input. if there is a hardware revision; we should reassign this GPIO to a
4283 * new open line; and removing it will just ensure that this will be missed in
4284 * the future.
4285 { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
4286 */
4287 { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
4288 { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
4289 { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
4290 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4291 { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
4292 { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
4293 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4294#ifndef CONFIG_SPI_QSD
4295 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
4296 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
4297 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
4298 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
4299#endif
4300 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4301 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4302 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4303 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4304 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4305 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4306 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4307 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4308 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4309 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4310 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4311 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4312 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4313 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4314 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4315 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4316 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4317 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4318 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4319 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4320};
4321
4322static struct msm_gpio lcd_sharp_panel_gpios[] = {
4323 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4324 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4325 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4326 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4327 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4328 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4329 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4330 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4331 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4332 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4333 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4334 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4335 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4336 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4337 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4338 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4339 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4340 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4341 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4342 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4343 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4344 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4345};
4346
4347static int lcdc_toshiba_panel_power(int on)
4348{
4349 int rc, i;
4350 struct msm_gpio *gp;
4351
4352 rc = display_common_power(on);
4353 if (rc < 0) {
4354 printk(KERN_ERR "%s display_common_power failed: %d\n",
4355 __func__, rc);
4356 return rc;
4357 }
4358
4359 if (on) {
4360 rc = msm_gpios_enable(lcd_panel_gpios,
4361 ARRAY_SIZE(lcd_panel_gpios));
4362 if (rc < 0) {
4363 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4364 __func__, rc);
4365 }
4366 } else { /* off */
4367 gp = lcd_panel_gpios;
4368 for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
4369 /* ouput low */
4370 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4371 gp++;
4372 }
4373 }
4374
4375 return rc;
4376}
4377
4378static int lcdc_sharp_panel_power(int on)
4379{
4380 int rc, i;
4381 struct msm_gpio *gp;
4382
4383 rc = display_common_power(on);
4384 if (rc < 0) {
4385 printk(KERN_ERR "%s display_common_power failed: %d\n",
4386 __func__, rc);
4387 return rc;
4388 }
4389
4390 if (on) {
4391 rc = msm_gpios_enable(lcd_sharp_panel_gpios,
4392 ARRAY_SIZE(lcd_sharp_panel_gpios));
4393 if (rc < 0) {
4394 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4395 __func__, rc);
4396 }
4397 } else { /* off */
4398 gp = lcd_sharp_panel_gpios;
4399 for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) {
4400 /* ouput low */
4401 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4402 gp++;
4403 }
4404 }
4405
4406 return rc;
4407}
4408
4409static int lcdc_panel_power(int on)
4410{
4411 int flag_on = !!on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004412 static int lcdc_power_save_on, lcdc_power_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004413
4414 if (lcdc_power_save_on == flag_on)
4415 return 0;
4416
4417 lcdc_power_save_on = flag_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004418
4419 if (unlikely(!lcdc_power_initialized)) {
4420 quickvx_mddi_client = 0;
4421 display_common_init();
4422 lcdc_power_initialized = 1;
4423 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004424
4425 if (machine_is_msm7x30_fluid())
4426 return lcdc_sharp_panel_power(on);
4427 else
4428 return lcdc_toshiba_panel_power(on);
4429}
4430
4431static struct lcdc_platform_data lcdc_pdata = {
4432 .lcdc_power_save = lcdc_panel_power,
4433};
4434
Justin Paupore3f40f342011-08-10 18:52:16 -07004435static struct regulator *atv_s4, *atv_ldo9;
4436
4437static int __init atv_dac_power_init(void)
4438{
4439 int rc;
4440 struct regulator_bulk_data regs[] = {
4441 { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 },
4442 { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 },
4443 };
4444
4445 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4446
4447 if (rc) {
4448 pr_err("%s: could not get regulators: %d\n", __func__, rc);
4449 goto bail;
4450 }
4451
4452 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4453
4454 if (rc) {
4455 pr_err("%s: could not set voltages: %d\n", __func__, rc);
4456 goto reg_free;
4457 }
4458
4459 atv_s4 = regs[0].consumer;
4460 atv_ldo9 = regs[1].consumer;
4461
4462reg_free:
4463 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4464bail:
4465 return rc;
4466}
4467
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004468static int atv_dac_power(int on)
4469{
4470 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004471
4472 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004473 rc = regulator_enable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004474 if (rc) {
4475 pr_err("%s: s4 vreg enable failed (%d)\n",
4476 __func__, rc);
4477 return rc;
4478 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004479 rc = regulator_enable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004480 if (rc) {
4481 pr_err("%s: ldo9 vreg enable failed (%d)\n",
4482 __func__, rc);
4483 return rc;
4484 }
4485 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004486 rc = regulator_disable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004487 if (rc) {
4488 pr_err("%s: ldo9 vreg disable failed (%d)\n",
4489 __func__, rc);
4490 return rc;
4491 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004492 rc = regulator_disable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004493 if (rc) {
4494 pr_err("%s: s4 vreg disable failed (%d)\n",
4495 __func__, rc);
4496 return rc;
4497 }
4498 }
4499 return rc;
4500}
4501
4502static struct tvenc_platform_data atv_pdata = {
4503 .poll = 1,
4504 .pm_vid_en = atv_dac_power,
4505};
4506
4507static void __init msm_fb_add_devices(void)
4508{
4509 msm_fb_register_device("mdp", &mdp_pdata);
4510 msm_fb_register_device("pmdh", &mddi_pdata);
4511 msm_fb_register_device("lcdc", &lcdc_pdata);
4512 msm_fb_register_device("dtv", &dtv_pdata);
4513 msm_fb_register_device("tvenc", &atv_pdata);
4514#ifdef CONFIG_FB_MSM_TVOUT
4515 msm_fb_register_device("tvout_device", NULL);
4516#endif
4517}
4518
4519static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
4520 .gpio_num = lcd_panel_spi_gpio_num,
4521};
4522
4523static struct platform_device lcdc_toshiba_panel_device = {
4524 .name = "lcdc_toshiba_wvga",
4525 .id = 0,
4526 .dev = {
4527 .platform_data = &lcdc_toshiba_panel_data,
4528 }
4529};
4530
4531#if defined(CONFIG_MARIMBA_CORE) && \
4532 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4533static struct platform_device msm_bt_power_device = {
4534 .name = "bt_power",
4535 .id = -1
4536};
4537
4538enum {
4539 BT_RFR,
4540 BT_CTS,
4541 BT_RX,
4542 BT_TX,
4543};
4544
4545static struct msm_gpio bt_config_power_on[] = {
4546 { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4547 "UART1DM_RFR" },
4548 { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4549 "UART1DM_CTS" },
4550 { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4551 "UART1DM_Rx" },
4552 { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4553 "UART1DM_Tx" }
4554};
4555
4556static struct msm_gpio bt_config_power_off[] = {
4557 { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4558 "UART1DM_RFR" },
4559 { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4560 "UART1DM_CTS" },
4561 { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4562 "UART1DM_Rx" },
4563 { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4564 "UART1DM_Tx" }
4565};
4566
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004567static u8 bahama_version;
4568
Justin Paupore3f40f342011-08-10 18:52:16 -07004569static struct regulator_bulk_data regs_bt_marimba[] = {
4570 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4571 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
4572 { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304573 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004574};
4575
4576static struct regulator_bulk_data regs_bt_bahama_v1[] = {
4577 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4578 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
4579 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304580 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004581};
4582
4583static struct regulator_bulk_data regs_bt_bahama_v2[] = {
4584 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4585 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304586 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004587};
4588
4589static struct regulator_bulk_data *regs_bt;
4590static int regs_bt_count;
4591
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004592static int marimba_bt(int on)
4593{
4594 int rc;
4595 int i;
4596 struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
4597
4598 struct marimba_config_register {
4599 u8 reg;
4600 u8 value;
4601 u8 mask;
4602 };
4603
4604 struct marimba_variant_register {
4605 const size_t size;
4606 const struct marimba_config_register *set;
4607 };
4608
4609 const struct marimba_config_register *p;
4610
4611 u8 version;
4612
4613 const struct marimba_config_register v10_bt_on[] = {
4614 { 0xE5, 0x0B, 0x0F },
4615 { 0x05, 0x02, 0x07 },
4616 { 0x06, 0x88, 0xFF },
4617 { 0xE7, 0x21, 0x21 },
4618 { 0xE3, 0x38, 0xFF },
4619 { 0xE4, 0x06, 0xFF },
4620 };
4621
4622 const struct marimba_config_register v10_bt_off[] = {
4623 { 0xE5, 0x0B, 0x0F },
4624 { 0x05, 0x08, 0x0F },
4625 { 0x06, 0x88, 0xFF },
4626 { 0xE7, 0x00, 0x21 },
4627 { 0xE3, 0x00, 0xFF },
4628 { 0xE4, 0x00, 0xFF },
4629 };
4630
4631 const struct marimba_config_register v201_bt_on[] = {
4632 { 0x05, 0x08, 0x07 },
4633 { 0x06, 0x88, 0xFF },
4634 { 0xE7, 0x21, 0x21 },
4635 { 0xE3, 0x38, 0xFF },
4636 { 0xE4, 0x06, 0xFF },
4637 };
4638
4639 const struct marimba_config_register v201_bt_off[] = {
4640 { 0x05, 0x08, 0x07 },
4641 { 0x06, 0x88, 0xFF },
4642 { 0xE7, 0x00, 0x21 },
4643 { 0xE3, 0x00, 0xFF },
4644 { 0xE4, 0x00, 0xFF },
4645 };
4646
4647 const struct marimba_config_register v210_bt_on[] = {
4648 { 0xE9, 0x01, 0x01 },
4649 { 0x06, 0x88, 0xFF },
4650 { 0xE7, 0x21, 0x21 },
4651 { 0xE3, 0x38, 0xFF },
4652 { 0xE4, 0x06, 0xFF },
4653 };
4654
4655 const struct marimba_config_register v210_bt_off[] = {
4656 { 0x06, 0x88, 0xFF },
4657 { 0xE7, 0x00, 0x21 },
4658 { 0xE9, 0x00, 0x01 },
4659 { 0xE3, 0x00, 0xFF },
4660 { 0xE4, 0x00, 0xFF },
4661 };
4662
4663 const struct marimba_variant_register bt_marimba[2][4] = {
4664 {
4665 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4666 { 0, NULL },
4667 { ARRAY_SIZE(v201_bt_off), v201_bt_off },
4668 { ARRAY_SIZE(v210_bt_off), v210_bt_off }
4669 },
4670 {
4671 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4672 { 0, NULL },
4673 { ARRAY_SIZE(v201_bt_on), v201_bt_on },
4674 { ARRAY_SIZE(v210_bt_on), v210_bt_on }
4675 }
4676 };
4677
4678 on = on ? 1 : 0;
4679
4680 rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F);
4681 if (rc < 0) {
4682 printk(KERN_ERR
4683 "%s: version read failed: %d\n",
4684 __func__, rc);
4685 return rc;
4686 }
4687
4688 if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
4689 (bt_marimba[on][version].size == 0)) {
4690 printk(KERN_ERR
4691 "%s: unsupported version\n",
4692 __func__);
4693 return -EIO;
4694 }
4695
4696 p = bt_marimba[on][version].set;
4697
4698 printk(KERN_INFO "%s: found version %d\n", __func__, version);
4699
4700 for (i = 0; i < bt_marimba[on][version].size; i++) {
4701 u8 value = (p+i)->value;
4702 rc = marimba_write_bit_mask(&config,
4703 (p+i)->reg,
4704 &value,
4705 sizeof((p+i)->value),
4706 (p+i)->mask);
4707 if (rc < 0) {
4708 printk(KERN_ERR
4709 "%s: reg %d write failed: %d\n",
4710 __func__, (p+i)->reg, rc);
4711 return rc;
4712 }
4713 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
4714 __func__, (p+i)->reg,
4715 value, (p+i)->mask);
4716 }
4717 return 0;
4718}
4719
4720static int bahama_bt(int on)
4721{
4722 int rc;
4723 int i;
4724 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
4725
4726 struct bahama_variant_register {
4727 const size_t size;
4728 const struct bahama_config_register *set;
4729 };
4730
4731 const struct bahama_config_register *p;
4732
4733
4734 const struct bahama_config_register v10_bt_on[] = {
4735 { 0xE9, 0x00, 0xFF },
4736 { 0xF4, 0x80, 0xFF },
4737 { 0xF0, 0x06, 0xFF },
4738 { 0xE4, 0x00, 0xFF },
4739 { 0xE5, 0x00, 0x0F },
4740#ifdef CONFIG_WLAN
4741 { 0xE6, 0x38, 0x7F },
4742 { 0xE7, 0x06, 0xFF },
4743#endif
4744 { 0x11, 0x13, 0xFF },
4745 { 0xE9, 0x21, 0xFF },
4746 { 0x01, 0x0C, 0x1F },
4747 { 0x01, 0x08, 0x1F },
4748 };
4749
4750 const struct bahama_config_register v20_bt_on_fm_off[] = {
4751 { 0x11, 0x0C, 0xFF },
4752 { 0x13, 0x01, 0xFF },
4753 { 0xF4, 0x80, 0xFF },
4754 { 0xF0, 0x00, 0xFF },
4755 { 0xE9, 0x00, 0xFF },
4756#ifdef CONFIG_WLAN
4757 { 0x81, 0x00, 0xFF },
4758 { 0x82, 0x00, 0xFF },
4759 { 0xE6, 0x38, 0x7F },
4760 { 0xE7, 0x06, 0xFF },
4761#endif
4762 { 0xE9, 0x21, 0xFF }
4763 };
4764
4765 const struct bahama_config_register v20_bt_on_fm_on[] = {
4766 { 0x11, 0x0C, 0xFF },
4767 { 0x13, 0x01, 0xFF },
4768 { 0xF4, 0x86, 0xFF },
4769 { 0xF0, 0x06, 0xFF },
4770 { 0xE9, 0x00, 0xFF },
4771#ifdef CONFIG_WLAN
4772 { 0x81, 0x00, 0xFF },
4773 { 0x82, 0x00, 0xFF },
4774 { 0xE6, 0x38, 0x7F },
4775 { 0xE7, 0x06, 0xFF },
4776#endif
4777 { 0xE9, 0x21, 0xFF }
4778 };
4779
4780 const struct bahama_config_register v10_bt_off[] = {
4781 { 0xE9, 0x00, 0xFF },
4782 };
4783
4784 const struct bahama_config_register v20_bt_off_fm_off[] = {
4785 { 0xF4, 0x84, 0xFF },
4786 { 0xF0, 0x04, 0xFF },
4787 { 0xE9, 0x00, 0xFF }
4788 };
4789
4790 const struct bahama_config_register v20_bt_off_fm_on[] = {
4791 { 0xF4, 0x86, 0xFF },
4792 { 0xF0, 0x06, 0xFF },
4793 { 0xE9, 0x00, 0xFF }
4794 };
4795
4796 const struct bahama_variant_register bt_bahama[2][3] = {
4797 {
4798 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4799 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
4800 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
4801 },
4802 {
4803 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4804 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
4805 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
4806 }
4807 };
4808
4809 u8 offset = 0; /* index into bahama configs */
4810
4811 on = on ? 1 : 0;
4812
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004813
4814 if (bahama_version == VER_2_0) {
4815 if (marimba_get_fm_status(&config))
4816 offset = 0x01;
4817 }
4818
4819 p = bt_bahama[on][bahama_version + offset].set;
4820
4821 dev_info(&msm_bt_power_device.dev,
4822 "%s: found version %d\n", __func__, bahama_version);
4823
4824 for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
4825 u8 value = (p+i)->value;
4826 rc = marimba_write_bit_mask(&config,
4827 (p+i)->reg,
4828 &value,
4829 sizeof((p+i)->value),
4830 (p+i)->mask);
4831 if (rc < 0) {
4832 dev_err(&msm_bt_power_device.dev,
4833 "%s: reg %d write failed: %d\n",
4834 __func__, (p+i)->reg, rc);
4835 return rc;
4836 }
4837 dev_info(&msm_bt_power_device.dev,
4838 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
4839 __func__, (p+i)->reg,
4840 value, (p+i)->mask);
4841 }
4842 /* Update BT status */
4843 if (on)
4844 marimba_set_bt_status(&config, true);
4845 else
4846 marimba_set_bt_status(&config, false);
4847
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004848 return 0;
4849}
4850
Justin Paupore3f40f342011-08-10 18:52:16 -07004851static int bluetooth_regs_init(int bahama_not_marimba)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004852{
Justin Paupore3f40f342011-08-10 18:52:16 -07004853 int rc = 0;
4854 struct device *const dev = &msm_bt_power_device.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004855
4856 if (bahama_not_marimba) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004857 bahama_version = read_bahama_ver();
4858
4859 switch (bahama_version) {
4860 case VER_1_0:
4861 regs_bt = regs_bt_bahama_v1;
4862 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1);
4863 break;
4864 case VER_2_0:
4865 regs_bt = regs_bt_bahama_v2;
4866 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2);
4867 break;
4868 case VER_UNSUPPORTED:
4869 default:
4870 dev_err(dev,
4871 "%s: i2c failure or unsupported version: %d\n",
4872 __func__, bahama_version);
4873 rc = -EIO;
4874 goto out;
4875 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004876 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004877 regs_bt = regs_bt_marimba;
4878 regs_bt_count = ARRAY_SIZE(regs_bt_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004879 }
4880
Justin Paupore3f40f342011-08-10 18:52:16 -07004881 rc = regulator_bulk_get(&msm_bt_power_device.dev,
4882 regs_bt_count, regs_bt);
4883 if (rc) {
4884 dev_err(dev, "%s: could not get regulators: %d\n",
4885 __func__, rc);
4886 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004887 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004888
4889 rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt);
4890 if (rc) {
4891 dev_err(dev, "%s: could not set voltages: %d\n",
4892 __func__, rc);
4893 goto reg_free;
4894 }
4895
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004896 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07004897
4898reg_free:
4899 regulator_bulk_free(regs_bt_count, regs_bt);
4900out:
4901 regs_bt_count = 0;
4902 regs_bt = NULL;
4903 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004904}
4905
4906static int bluetooth_power(int on)
4907{
4908 int rc;
4909 const char *id = "BTPW";
4910
4911 int bahama_not_marimba = bahama_present();
4912
4913 if (bahama_not_marimba == -1) {
4914 printk(KERN_WARNING "%s: bahama_present: %d\n",
4915 __func__, bahama_not_marimba);
4916 return -ENODEV;
4917 }
4918
Justin Paupore3f40f342011-08-10 18:52:16 -07004919 if (unlikely(regs_bt_count == 0)) {
4920 rc = bluetooth_regs_init(bahama_not_marimba);
4921 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004922 return rc;
Justin Paupore3f40f342011-08-10 18:52:16 -07004923 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004924
Justin Paupore3f40f342011-08-10 18:52:16 -07004925 if (on) {
4926 rc = regulator_bulk_enable(regs_bt_count, regs_bt);
4927 if (rc)
4928 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004929
4930 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
4931 PMAPP_CLOCK_VOTE_ON);
4932 if (rc < 0)
4933 return -EIO;
4934
4935 if (machine_is_msm8x55_svlte_surf() ||
4936 machine_is_msm8x55_svlte_ffa()) {
4937 rc = marimba_gpio_config(1);
4938 if (rc < 0)
4939 return -EIO;
4940 }
4941
4942 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
4943 if (rc < 0)
4944 return -EIO;
4945
4946 msleep(10);
4947
4948 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
4949 PMAPP_CLOCK_VOTE_PIN_CTRL);
4950 if (rc < 0)
4951 return -EIO;
4952
4953 if (machine_is_msm8x55_svlte_surf() ||
4954 machine_is_msm8x55_svlte_ffa()) {
4955 rc = marimba_gpio_config(0);
4956 if (rc < 0)
4957 return -EIO;
4958 }
4959
4960 rc = msm_gpios_enable(bt_config_power_on,
4961 ARRAY_SIZE(bt_config_power_on));
4962
4963 if (rc < 0)
4964 return rc;
4965
4966 } else {
4967 rc = msm_gpios_enable(bt_config_power_off,
4968 ARRAY_SIZE(bt_config_power_off));
4969 if (rc < 0)
4970 return rc;
4971
4972 /* check for initial RFKILL block (power off) */
4973 if (platform_get_drvdata(&msm_bt_power_device) == NULL)
4974 goto out;
4975
4976 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
4977 if (rc < 0)
4978 return -EIO;
4979
4980 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
4981 PMAPP_CLOCK_VOTE_OFF);
4982 if (rc < 0)
4983 return -EIO;
4984
Justin Paupore3f40f342011-08-10 18:52:16 -07004985 rc = regulator_bulk_disable(regs_bt_count, regs_bt);
4986 if (rc)
4987 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004988
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004989 }
4990
4991out:
4992 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
4993
4994 return 0;
4995}
4996
4997static void __init bt_power_init(void)
4998{
Justin Paupore3f40f342011-08-10 18:52:16 -07004999 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005000}
5001#else
5002#define bt_power_init(x) do {} while (0)
5003#endif
5004
5005static struct msm_psy_batt_pdata msm_psy_batt_data = {
5006 .voltage_min_design = 2800,
5007 .voltage_max_design = 4300,
5008 .avail_chg_sources = AC_CHG | USB_CHG ,
5009 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
5010};
5011
5012static struct platform_device msm_batt_device = {
5013 .name = "msm-battery",
5014 .id = -1,
5015 .dev.platform_data = &msm_psy_batt_data,
5016};
5017
5018static char *msm_adc_fluid_device_names[] = {
5019 "LTC_ADC1",
5020 "LTC_ADC2",
5021 "LTC_ADC3",
5022};
5023
5024static char *msm_adc_surf_device_names[] = {
5025 "XO_ADC",
5026};
5027
5028static struct msm_adc_platform_data msm_adc_pdata;
5029
5030static struct platform_device msm_adc_device = {
5031 .name = "msm_adc",
5032 .id = -1,
5033 .dev = {
5034 .platform_data = &msm_adc_pdata,
5035 },
5036};
5037
5038#ifdef CONFIG_MSM_SDIO_AL
5039static struct msm_gpio mdm2ap_status = {
5040 GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5041 "mdm2ap_status"
5042};
5043
5044
5045static int configure_mdm2ap_status(int on)
5046{
5047 if (on)
5048 return msm_gpios_request_enable(&mdm2ap_status, 1);
5049 else {
5050 msm_gpios_disable_free(&mdm2ap_status, 1);
5051 return 0;
5052 }
5053}
5054
5055static int get_mdm2ap_status(void)
5056{
5057 return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
5058}
5059
5060static struct sdio_al_platform_data sdio_al_pdata = {
5061 .config_mdm2ap_status = configure_mdm2ap_status,
5062 .get_mdm2ap_status = get_mdm2ap_status,
5063 .allow_sdioc_version_major_2 = 1,
5064 .peer_sdioc_version_minor = 0x0001,
5065 .peer_sdioc_version_major = 0x0003,
5066 .peer_sdioc_boot_version_minor = 0x0001,
5067 .peer_sdioc_boot_version_major = 0x0003,
5068};
5069
5070struct platform_device msm_device_sdio_al = {
5071 .name = "msm_sdio_al",
5072 .id = -1,
5073 .dev = {
5074 .platform_data = &sdio_al_pdata,
5075 },
5076};
5077
5078#endif /* CONFIG_MSM_SDIO_AL */
5079
Daniel Walker8d747cd2010-02-25 11:37:43 -08005080static struct platform_device *devices[] __initdata = {
Daniel Walker90e37c52010-05-12 14:24:15 -07005081#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005082 &msm_device_uart2,
5083#endif
Justin Paupore637a25d2011-07-14 17:11:04 -07005084#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
5085 &msm_proccomm_regulator_dev,
5086#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005087 &asoc_msm_pcm,
5088 &asoc_msm_dai0,
5089 &asoc_msm_dai1,
5090#if defined (CONFIG_SND_MSM_MVS_DAI_SOC)
5091 &asoc_msm_mvs,
5092 &asoc_mvs_dai0,
5093 &asoc_mvs_dai1,
Daniel Walker90e37c52010-05-12 14:24:15 -07005094#endif
Niranjana Vishwanathapuraa8855e92010-10-06 13:52:10 -07005095 &msm_device_smd,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005096 &msm_device_dmov,
5097 &smc91x_device,
5098 &smsc911x_device,
5099 &msm_device_nand,
5100#ifdef CONFIG_USB_MSM_OTG_72K
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05305101 &msm_device_otg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005102#ifdef CONFIG_USB_GADGET
5103 &msm_device_gadget_peripheral,
5104#endif
5105#endif
5106#ifdef CONFIG_USB_G_ANDROID
5107 &android_usb_device,
5108#endif
5109 &qsd_device_spi,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305110
5111#ifdef CONFIG_MSM_SSBI
5112 &msm_device_ssbi_pmic1,
5113#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005114#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005115 &msm_device_ssbi7,
5116#endif
5117 &android_pmem_device,
5118 &msm_fb_device,
5119 &msm_migrate_pages_device,
5120 &mddi_toshiba_device,
5121 &lcdc_toshiba_panel_device,
5122#ifdef CONFIG_MSM_ROTATOR
5123 &msm_rotator_device,
5124#endif
5125 &lcdc_sharp_panel_device,
5126 &android_pmem_adsp_device,
5127 &android_pmem_audio_device,
5128 &msm_device_i2c,
5129 &msm_device_i2c_2,
5130 &msm_device_uart_dm1,
5131 &hs_device,
5132#ifdef CONFIG_MSM7KV2_AUDIO
5133 &msm_aictl_device,
5134 &msm_mi2s_device,
5135 &msm_lpa_device,
5136 &msm_aux_pcm_device,
5137#endif
5138 &msm_device_adspdec,
5139 &qup_device_i2c,
5140#if defined(CONFIG_MARIMBA_CORE) && \
5141 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5142 &msm_bt_power_device,
5143#endif
5144 &msm_kgsl_3d0,
5145 &msm_kgsl_2d0,
5146#ifdef CONFIG_MT9T013
5147 &msm_camera_sensor_mt9t013,
5148#endif
5149#ifdef CONFIG_MT9D112
5150 &msm_camera_sensor_mt9d112,
5151#endif
5152#ifdef CONFIG_WEBCAM_OV9726
5153 &msm_camera_sensor_ov9726,
5154#endif
5155#ifdef CONFIG_S5K3E2FX
5156 &msm_camera_sensor_s5k3e2fx,
5157#endif
5158#ifdef CONFIG_MT9P012
5159 &msm_camera_sensor_mt9p012,
5160#endif
5161#ifdef CONFIG_MT9E013
5162 &msm_camera_sensor_mt9e013,
5163#endif
5164#ifdef CONFIG_VX6953
5165 &msm_camera_sensor_vx6953,
5166#endif
5167#ifdef CONFIG_SN12M0PZ
5168 &msm_camera_sensor_sn12m0pz,
5169#endif
5170 &msm_device_vidc_720p,
5171#ifdef CONFIG_MSM_GEMINI
5172 &msm_gemini_device,
5173#endif
5174#ifdef CONFIG_MSM_VPE
5175 &msm_vpe_device,
5176#endif
5177#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5178 &msm_device_tsif,
5179#endif
5180#ifdef CONFIG_MSM_SDIO_AL
5181 &msm_device_sdio_al,
5182#endif
5183
5184#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5185 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5186 &qcrypto_device,
5187#endif
5188
5189#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5190 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5191 &qcedev_device,
5192#endif
5193
5194 &msm_batt_device,
5195 &msm_adc_device,
5196 &msm_ebi0_thermal,
5197 &msm_ebi1_thermal
5198};
5199
5200static struct msm_gpio msm_i2c_gpios_hw[] = {
5201 { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5202 { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5203};
5204
5205static struct msm_gpio msm_i2c_gpios_io[] = {
5206 { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5207 { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5208};
5209
5210static struct msm_gpio qup_i2c_gpios_io[] = {
5211 { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5212 { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5213};
5214static struct msm_gpio qup_i2c_gpios_hw[] = {
5215 { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5216 { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5217};
5218
5219static void
5220msm_i2c_gpio_config(int adap_id, int config_type)
5221{
5222 struct msm_gpio *msm_i2c_table;
5223
5224 /* Each adapter gets 2 lines from the table */
5225 if (adap_id > 0)
5226 return;
5227 if (config_type)
5228 msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
5229 else
5230 msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
5231 msm_gpios_enable(msm_i2c_table, 2);
5232}
5233/*This needs to be enabled only for OEMS*/
5234#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005235static struct regulator *qup_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005236#endif
5237static void
5238qup_i2c_gpio_config(int adap_id, int config_type)
5239{
5240 int rc = 0;
5241 struct msm_gpio *qup_i2c_table;
5242 /* Each adapter gets 2 lines from the table */
5243 if (adap_id != 4)
5244 return;
5245 if (config_type)
5246 qup_i2c_table = qup_i2c_gpios_hw;
5247 else
5248 qup_i2c_table = qup_i2c_gpios_io;
5249 rc = msm_gpios_enable(qup_i2c_table, 2);
5250 if (rc < 0)
5251 printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
5252 /*This needs to be enabled only for OEMS*/
5253#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005254 if (!IS_ERR_OR_NULL(qup_vreg)) {
5255 rc = regulator_enable(qup_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005256 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005257 pr_err("%s: regulator_enable failed: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005258 __func__, rc);
5259 }
5260 }
5261#endif
5262}
5263
5264static struct msm_i2c_platform_data msm_i2c_pdata = {
5265 .clk_freq = 100000,
5266 .pri_clk = 70,
5267 .pri_dat = 71,
5268 .rmutex = 1,
5269 .rsl_id = "D:I2C02000021",
5270 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5271};
5272
5273static void __init msm_device_i2c_init(void)
5274{
5275 if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
5276 pr_err("failed to request I2C gpios\n");
5277
5278 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
5279}
5280
5281static struct msm_i2c_platform_data msm_i2c_2_pdata = {
5282 .clk_freq = 100000,
5283 .rmutex = 1,
5284 .rsl_id = "D:I2C02000022",
5285 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5286};
5287
5288static void __init msm_device_i2c_2_init(void)
5289{
5290 msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
5291}
5292
5293static struct msm_i2c_platform_data qup_i2c_pdata = {
5294 .clk_freq = 384000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005295 .msm_i2c_config_gpio = qup_i2c_gpio_config,
5296};
5297
5298static void __init qup_device_i2c_init(void)
5299{
5300 if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
5301 pr_err("failed to request I2C gpios\n");
5302
5303 qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
5304 /*This needs to be enabled only for OEMS*/
5305#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005306 qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005307 if (IS_ERR(qup_vreg)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005308 dev_err(&qup_device_i2c.dev,
5309 "%s: regulator_get failed: %ld\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005310 __func__, PTR_ERR(qup_vreg));
5311 }
5312#endif
5313}
5314
5315#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005316static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = {
5317 .rsl_id = "D:CODEC_SSBI",
5318 .controller_type = MSM_SBI_CTRL_SSBI,
5319};
5320#endif
5321
Daniel Walker8d747cd2010-02-25 11:37:43 -08005322static void __init msm7x30_init_irq(void)
5323{
5324 msm_init_irq();
5325}
5326
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005327static struct msm_gpio msm_nand_ebi2_cfg_data[] = {
5328 {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
5329 {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
5330};
5331
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005332#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
5333 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
5334 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
5335 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
5336
5337struct sdcc_gpio {
5338 struct msm_gpio *cfg_data;
5339 uint32_t size;
5340 struct msm_gpio *sleep_cfg_data;
5341};
5342#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5343static struct msm_gpio sdc1_lvlshft_cfg_data[] = {
5344 {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
5345};
5346#endif
5347static struct msm_gpio sdc1_cfg_data[] = {
5348 {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
5349 {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
5350 {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
5351 {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
5352 {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
5353 {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
5354};
5355
5356static struct msm_gpio sdc2_cfg_data[] = {
5357 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
5358 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
5359 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
5360 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
5361 {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
5362 {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
5363
5364#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5365 {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
5366 {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
5367 {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
5368 {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
5369#endif
5370};
5371
5372static struct msm_gpio sdc3_cfg_data[] = {
5373 {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
5374 {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
5375 {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
5376 {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
5377 {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
5378 {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
5379};
5380
5381static struct msm_gpio sdc3_sleep_cfg_data[] = {
5382 {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5383 "sdc3_clk"},
5384 {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5385 "sdc3_cmd"},
5386 {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5387 "sdc3_dat_3"},
5388 {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5389 "sdc3_dat_2"},
5390 {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5391 "sdc3_dat_1"},
5392 {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5393 "sdc3_dat_0"},
5394};
5395
5396static struct msm_gpio sdc4_cfg_data[] = {
5397 {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
5398 {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
5399 {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
5400 {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
5401 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
5402 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
5403};
5404
5405static struct sdcc_gpio sdcc_cfg_data[] = {
5406 {
5407 .cfg_data = sdc1_cfg_data,
5408 .size = ARRAY_SIZE(sdc1_cfg_data),
5409 .sleep_cfg_data = NULL,
5410 },
5411 {
5412 .cfg_data = sdc2_cfg_data,
5413 .size = ARRAY_SIZE(sdc2_cfg_data),
5414 .sleep_cfg_data = NULL,
5415 },
5416 {
5417 .cfg_data = sdc3_cfg_data,
5418 .size = ARRAY_SIZE(sdc3_cfg_data),
5419 .sleep_cfg_data = sdc3_sleep_cfg_data,
5420 },
5421 {
5422 .cfg_data = sdc4_cfg_data,
5423 .size = ARRAY_SIZE(sdc4_cfg_data),
5424 .sleep_cfg_data = NULL,
5425 },
5426};
5427
Justin Paupore3f40f342011-08-10 18:52:16 -07005428static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005429
5430static unsigned long vreg_sts, gpio_sts;
5431
5432static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
5433{
5434 int rc = 0;
5435 struct sdcc_gpio *curr;
5436
5437 curr = &sdcc_cfg_data[dev_id - 1];
5438
5439 if (!(test_bit(dev_id, &gpio_sts)^enable))
5440 return rc;
5441
5442 if (enable) {
5443 set_bit(dev_id, &gpio_sts);
5444 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
5445 if (rc)
5446 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
5447 __func__, dev_id);
5448 } else {
5449 clear_bit(dev_id, &gpio_sts);
5450 if (curr->sleep_cfg_data) {
5451 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
5452 msm_gpios_free(curr->sleep_cfg_data, curr->size);
5453 } else {
5454 msm_gpios_disable_free(curr->cfg_data, curr->size);
5455 }
5456 }
5457
5458 return rc;
5459}
5460
5461static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
5462{
5463 int rc = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005464 struct regulator *curr = sdcc_vreg_data[dev_id - 1];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005465 static int enabled_once[] = {0, 0, 0, 0};
5466
Justin Paupore3f40f342011-08-10 18:52:16 -07005467 if (test_bit(dev_id, &vreg_sts) == enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005468 return rc;
5469
5470 if (!enable || enabled_once[dev_id - 1])
5471 return 0;
5472
Justin Paupore3f40f342011-08-10 18:52:16 -07005473 if (!curr)
5474 return -ENODEV;
5475
5476 if (IS_ERR(curr))
5477 return PTR_ERR(curr);
5478
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005479 if (enable) {
5480 set_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005481
5482 rc = regulator_enable(curr);
5483 if (rc)
5484 pr_err("%s: could not enable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005485 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005486 enabled_once[dev_id - 1] = 1;
5487 } else {
5488 clear_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005489
5490 rc = regulator_disable(curr);
5491 if (rc)
5492 pr_err("%s: could not disable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005493 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005494 }
5495 return rc;
5496}
5497
5498static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
5499{
5500 int rc = 0;
5501 struct platform_device *pdev;
5502
5503 pdev = container_of(dv, struct platform_device, dev);
5504 rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
5505 if (rc)
5506 goto out;
5507
5508 if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
5509 rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
5510out:
5511 return rc;
5512}
5513
5514#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \
5515 defined(CONFIG_CSDIO_VENDOR_ID) && \
5516 defined(CONFIG_CSDIO_DEVICE_ID) && \
5517 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5518
5519#define MBP_ON 1
5520#define MBP_OFF 0
5521
5522#define MBP_RESET_N \
5523 GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
5524#define MBP_INT0 \
5525 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
5526
5527#define MBP_MODE_CTRL_0 \
5528 GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5529#define MBP_MODE_CTRL_1 \
5530 GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5531#define MBP_MODE_CTRL_2 \
5532 GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5533#define TSIF_EN \
5534 GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5535#define TSIF_DATA \
5536 GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5537#define TSIF_CLK \
5538 GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5539
5540static struct msm_gpio mbp_cfg_data[] = {
5541 {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5542 "mbp_reset"},
5543 {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5544 "mbp_io_voltage"},
5545};
5546
5547static int mbp_config_gpios_pre_init(int enable)
5548{
5549 int rc = 0;
5550
5551 if (enable) {
5552 rc = msm_gpios_request_enable(mbp_cfg_data,
5553 ARRAY_SIZE(mbp_cfg_data));
5554 if (rc) {
5555 printk(KERN_ERR
5556 "%s: Failed to turnon GPIOs for mbp chip(%d)\n",
5557 __func__, rc);
5558 }
5559 } else
5560 msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
5561 return rc;
5562}
5563
Justin Paupore3f40f342011-08-10 18:52:16 -07005564static struct regulator_bulk_data mbp_regs_io[2];
5565static struct regulator_bulk_data mbp_regs_rf[2];
5566static struct regulator_bulk_data mbp_regs_adc[1];
5567static struct regulator_bulk_data mbp_regs_core[1];
5568
5569static int mbp_init_regs(struct device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005570{
Justin Paupore3f40f342011-08-10 18:52:16 -07005571 struct regulator_bulk_data regs[] = {
5572 /* Analog and I/O regs */
5573 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
5574 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
5575 /* RF regs */
5576 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
5577 { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 },
5578 /* ADC regs */
5579 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
5580 /* Core regs */
5581 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
5582 };
5583
5584 struct regulator_bulk_data *regptr = regs;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005585 int rc;
5586
Justin Paupore3f40f342011-08-10 18:52:16 -07005587 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs);
5588
5589 if (rc) {
5590 dev_err(dev, "%s: could not get regulators: %d\n",
5591 __func__, rc);
5592 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005593 }
5594
Justin Paupore3f40f342011-08-10 18:52:16 -07005595 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005596
Justin Paupore3f40f342011-08-10 18:52:16 -07005597 if (rc) {
5598 dev_err(dev, "%s: could not set voltages: %d\n",
5599 __func__, rc);
5600 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005601 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005602
5603 memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io));
5604 regptr += ARRAY_SIZE(mbp_regs_io);
5605
5606 memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf));
5607 regptr += ARRAY_SIZE(mbp_regs_rf);
5608
5609 memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc));
5610 regptr += ARRAY_SIZE(mbp_regs_adc);
5611
5612 memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core));
5613
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005614 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005615
5616reg_free:
5617 regulator_bulk_free(ARRAY_SIZE(regs), regs);
5618out:
5619 return rc;
5620}
5621
5622static int mbp_setup_rf_vregs(int state)
5623{
5624 return state ?
5625 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) :
5626 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005627}
5628
5629static int mbp_setup_vregs(int state)
5630{
Justin Paupore3f40f342011-08-10 18:52:16 -07005631 return state ?
5632 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) :
5633 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005634}
5635
5636static int mbp_set_tcxo_en(int enable)
5637{
5638 int rc;
5639 const char *id = "UBMC";
5640 struct vreg *vreg_analog = NULL;
5641
5642 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
5643 enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
5644 if (rc < 0) {
5645 printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
5646 __func__, enable ? "" : "de-");
5647 return -EIO;
5648 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005649 return rc;
5650}
5651
5652static void mbp_set_freeze_io(int state)
5653{
5654 if (state)
5655 gpio_set_value(85, 0);
5656 else
5657 gpio_set_value(85, 1);
5658}
5659
5660static int mbp_set_core_voltage_en(int enable)
5661{
Justin Paupore3f40f342011-08-10 18:52:16 -07005662 static bool is_enabled;
5663 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005664
Justin Paupore3f40f342011-08-10 18:52:16 -07005665 if (enable && !is_enabled) {
5666 rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core),
5667 mbp_regs_core);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005668 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005669 pr_err("%s: could not enable regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005670 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07005671 } else {
5672 is_enabled = true;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005673 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005674 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005675
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005676 return rc;
5677}
5678
5679static void mbp_set_reset(int state)
5680{
5681 if (state)
5682 gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
5683 else
5684 gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
5685}
5686
5687static int mbp_config_interface_mode(int state)
5688{
5689 if (state) {
5690 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
5691 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
5692 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
5693 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
5694 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
5695 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
5696 } else {
5697 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
5698 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
5699 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
5700 }
5701 return 0;
5702}
5703
5704static int mbp_setup_adc_vregs(int state)
5705{
Justin Paupore3f40f342011-08-10 18:52:16 -07005706 return state ?
5707 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) :
5708 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005709}
5710
5711static int mbp_power_up(void)
5712{
5713 int rc;
5714
5715 rc = mbp_config_gpios_pre_init(MBP_ON);
5716 if (rc)
5717 goto exit;
5718 pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__);
5719
5720 rc = mbp_setup_vregs(MBP_ON);
5721 if (rc)
5722 goto exit;
5723 pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
5724
5725 rc = mbp_set_tcxo_en(MBP_ON);
5726 if (rc)
5727 goto exit;
5728 pr_debug("%s: tcxo clock done\n", __func__);
5729
5730 mbp_set_freeze_io(MBP_OFF);
5731 pr_debug("%s: set gpio 85 to 1 done\n", __func__);
5732
5733 udelay(100);
5734 mbp_set_reset(MBP_ON);
5735
5736 udelay(300);
5737 rc = mbp_config_interface_mode(MBP_ON);
5738 if (rc)
5739 goto exit;
5740 pr_debug("%s: mbp_config_interface_mode() done\n", __func__);
5741
5742 udelay(100 + mbp_set_core_voltage_en(MBP_ON));
5743 pr_debug("%s: power gp16 1.2V done\n", __func__);
5744
5745 mbp_set_freeze_io(MBP_ON);
5746 pr_debug("%s: set gpio 85 to 0 done\n", __func__);
5747
5748 udelay(100);
5749
5750 rc = mbp_setup_rf_vregs(MBP_ON);
5751 if (rc)
5752 goto exit;
5753 pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
5754
5755 rc = mbp_setup_adc_vregs(MBP_ON);
5756 if (rc)
5757 goto exit;
5758 pr_debug("%s: s4 2.2V done\n", __func__);
5759
5760 udelay(200);
5761
5762 mbp_set_reset(MBP_OFF);
5763 pr_debug("%s: close gpio 44 done\n", __func__);
5764
5765 msleep(20);
5766exit:
5767 return rc;
5768}
5769
5770static int mbp_power_down(void)
5771{
5772 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005773
5774 mbp_set_reset(MBP_ON);
5775 pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
5776
5777 udelay(100);
5778
5779 rc = mbp_setup_adc_vregs(MBP_OFF);
5780 if (rc)
5781 goto exit;
5782 pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
5783
5784 udelay(5);
5785
5786 rc = mbp_setup_rf_vregs(MBP_OFF);
5787 if (rc)
5788 goto exit;
5789 pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
5790
5791 udelay(5);
5792
5793 mbp_set_freeze_io(MBP_OFF);
5794 pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
5795
5796 udelay(100);
5797 rc = mbp_set_core_voltage_en(MBP_OFF);
5798 if (rc)
5799 goto exit;
5800 pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
5801
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005802 rc = mbp_set_tcxo_en(MBP_OFF);
5803 if (rc)
5804 goto exit;
5805 pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
5806
Justin Paupore3f40f342011-08-10 18:52:16 -07005807 rc = mbp_setup_vregs(MBP_OFF);
5808 if (rc)
5809 goto exit;
5810 pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__);
5811
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005812 rc = mbp_config_gpios_pre_init(MBP_OFF);
5813 if (rc)
5814 goto exit;
5815exit:
5816 return rc;
5817}
5818
5819static void (*mbp_status_notify_cb)(int card_present, void *dev_id);
5820static void *mbp_status_notify_cb_devid;
5821static int mbp_power_status;
5822static int mbp_power_init_done;
5823
5824static uint32_t mbp_setup_power(struct device *dv,
5825 unsigned int power_status)
5826{
5827 int rc = 0;
5828 struct platform_device *pdev;
5829
5830 pdev = container_of(dv, struct platform_device, dev);
5831
5832 if (power_status == mbp_power_status)
5833 goto exit;
5834 if (power_status) {
5835 pr_debug("turn on power of mbp slot");
5836 rc = mbp_power_up();
5837 mbp_power_status = 1;
5838 } else {
5839 pr_debug("turn off power of mbp slot");
5840 rc = mbp_power_down();
5841 mbp_power_status = 0;
5842 }
5843exit:
5844 return rc;
5845};
5846
5847int mbp_register_status_notify(void (*callback)(int, void *),
5848 void *dev_id)
5849{
5850 mbp_status_notify_cb = callback;
5851 mbp_status_notify_cb_devid = dev_id;
5852 return 0;
5853}
5854
5855static unsigned int mbp_status(struct device *dev)
5856{
5857 return mbp_power_status;
5858}
5859
5860static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd)
5861{
5862 struct platform_device *pdev;
5863 uint32_t rc = 0;
5864
5865 pdev = container_of(dv, struct platform_device, dev);
5866 rc = msm_sdcc_setup_power(dv, vdd);
5867 if (rc) {
5868 pr_err("%s: Failed to setup power (%d)\n",
5869 __func__, rc);
5870 goto out;
5871 }
5872 if (!mbp_power_init_done) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005873 rc = mbp_init_regs(dv);
5874 if (rc) {
5875 dev_err(dv, "%s: regulator init failed: %d\n",
5876 __func__, rc);
5877 goto out;
5878 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005879 mbp_setup_power(dv, 1);
5880 mbp_setup_power(dv, 0);
5881 mbp_power_init_done = 1;
5882 }
5883 if (vdd >= 0x8000) {
5884 rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
5885 if (rc) {
5886 pr_err("%s: Failed to config mbp chip power (%d)\n",
5887 __func__, rc);
5888 goto out;
5889 }
5890 if (mbp_status_notify_cb) {
5891 mbp_status_notify_cb(mbp_power_status,
5892 mbp_status_notify_cb_devid);
5893 }
5894 }
5895out:
5896 /* should return 0 only */
5897 return 0;
5898}
5899
5900#endif
5901
5902#endif
5903
5904#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
5905#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5906static unsigned int msm7x30_sdcc_slot_status(struct device *dev)
5907{
5908 return (unsigned int)
5909 gpio_get_value_cansleep(
5910 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1));
5911}
5912#endif
5913
5914static int msm_sdcc_get_wpswitch(struct device *dv)
5915{
5916 void __iomem *wp_addr = 0;
5917 uint32_t ret = 0;
5918 struct platform_device *pdev;
5919
5920 if (!(machine_is_msm7x30_surf()))
5921 return -1;
5922 pdev = container_of(dv, struct platform_device, dev);
5923
5924 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
5925 if (!wp_addr) {
5926 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
5927 return -ENOMEM;
5928 }
5929
5930 ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
5931 pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
5932 pdev->id, ret);
5933 iounmap(wp_addr);
5934
5935 return ret;
5936}
5937#endif
5938
5939#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5940#if defined(CONFIG_CSDIO_VENDOR_ID) && \
5941 defined(CONFIG_CSDIO_DEVICE_ID) && \
5942 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5943static struct mmc_platform_data msm7x30_sdc1_data = {
5944 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
5945 .translate_vdd = msm_sdcc_setup_power_mbp,
5946 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
5947 .status = mbp_status,
5948 .register_status_notify = mbp_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005949 .msmsdcc_fmin = 144000,
5950 .msmsdcc_fmid = 24576000,
5951 .msmsdcc_fmax = 24576000,
5952 .nonremovable = 0,
5953};
5954#else
5955static struct mmc_platform_data msm7x30_sdc1_data = {
5956 .ocr_mask = MMC_VDD_165_195,
5957 .translate_vdd = msm_sdcc_setup_power,
5958 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005959 .msmsdcc_fmin = 144000,
5960 .msmsdcc_fmid = 24576000,
5961 .msmsdcc_fmax = 49152000,
5962 .nonremovable = 0,
5963};
5964#endif
5965#endif
5966
5967#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
5968static struct mmc_platform_data msm7x30_sdc2_data = {
5969 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
5970 .translate_vdd = msm_sdcc_setup_power,
5971#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5972 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
5973#else
5974 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
5975#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005976 .msmsdcc_fmin = 144000,
5977 .msmsdcc_fmid = 24576000,
5978 .msmsdcc_fmax = 49152000,
5979 .nonremovable = 1,
5980};
5981#endif
5982
5983#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
5984static struct mmc_platform_data msm7x30_sdc3_data = {
5985 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
5986 .translate_vdd = msm_sdcc_setup_power,
5987 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
5988#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
5989 .sdiowakeup_irq = MSM_GPIO_TO_INT(118),
5990#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005991 .msmsdcc_fmin = 144000,
5992 .msmsdcc_fmid = 24576000,
5993 .msmsdcc_fmax = 49152000,
5994 .nonremovable = 0,
5995};
5996#endif
5997
5998#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
5999static struct mmc_platform_data msm7x30_sdc4_data = {
6000 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6001 .translate_vdd = msm_sdcc_setup_power,
6002 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6003#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6004 .status = msm7x30_sdcc_slot_status,
6005 .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
6006 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
6007#endif
6008 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006009 .msmsdcc_fmin = 144000,
6010 .msmsdcc_fmid = 24576000,
6011 .msmsdcc_fmax = 49152000,
6012 .nonremovable = 0,
6013};
6014#endif
6015
6016#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006017static int msm_sdc1_lvlshft_enable(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006018{
Justin Paupore3f40f342011-08-10 18:52:16 -07006019 static struct regulator *ldo5;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006020 int rc;
6021
6022 /* Enable LDO5, an input to the FET that powers slot 1 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006023
Justin Paupore3f40f342011-08-10 18:52:16 -07006024 ldo5 = regulator_get(NULL, "ldo5");
6025
6026 if (IS_ERR(ldo5)) {
6027 rc = PTR_ERR(ldo5);
6028 pr_err("%s: could not get ldo5: %d\n", __func__, rc);
6029 goto out;
6030 }
6031
6032 rc = regulator_set_voltage(ldo5, 2850000, 2850000);
6033 if (rc) {
6034 pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc);
6035 goto ldo5_free;
6036 }
6037
6038 rc = regulator_enable(ldo5);
6039 if (rc) {
6040 pr_err("%s: could not enable ldo5: %d\n", __func__, rc);
6041 goto ldo5_free;
6042 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006043
6044 /* Enable GPIO 35, to turn on the FET that powers slot 1 */
6045 rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
6046 ARRAY_SIZE(sdc1_lvlshft_cfg_data));
6047 if (rc)
6048 printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
6049
6050 rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg),
6051 1);
6052 if (rc)
6053 printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006054
6055 return 0;
6056
6057ldo5_free:
6058 regulator_put(ldo5);
6059out:
6060 ldo5 = NULL;
6061 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006062}
6063#endif
6064
Justin Paupore3f40f342011-08-10 18:52:16 -07006065static int mmc_regulator_init(int sdcc_no, const char *supply, int uV)
6066{
6067 int rc;
6068
6069 BUG_ON(sdcc_no < 1 || sdcc_no > 4);
6070
6071 sdcc_no--;
6072
6073 sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply);
6074
6075 if (IS_ERR(sdcc_vreg_data[sdcc_no])) {
6076 rc = PTR_ERR(sdcc_vreg_data[sdcc_no]);
6077 pr_err("%s: could not get regulator \"%s\": %d\n",
6078 __func__, supply, rc);
6079 goto out;
6080 }
6081
6082 rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV);
6083
6084 if (rc) {
6085 pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n",
6086 __func__, supply, uV, rc);
6087 goto reg_free;
6088 }
6089
6090 return rc;
6091
6092reg_free:
6093 regulator_put(sdcc_vreg_data[sdcc_no]);
6094out:
6095 sdcc_vreg_data[sdcc_no] = NULL;
6096 return rc;
6097}
6098
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006099static void __init msm7x30_init_mmc(void)
6100{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006101#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006102 if (mmc_regulator_init(1, "s3", 1800000))
6103 goto out1;
6104
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006105 if (machine_is_msm7x30_fluid()) {
6106 msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
Justin Paupore3f40f342011-08-10 18:52:16 -07006107 if (msm_sdc1_lvlshft_enable()) {
6108 pr_err("%s: could not enable level shift\n");
6109 goto out1;
6110 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006111 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006112
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006113 msm_add_sdcc(1, &msm7x30_sdc1_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006114out1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006115#endif
6116#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006117 if (mmc_regulator_init(2, "s3", 1800000))
6118 goto out2;
6119
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006120 if (machine_is_msm8x55_svlte_surf())
6121 msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
Sujith Reddy Thumma84a0f512011-08-29 09:57:03 +05306122 if (machine_is_msm8x55_svlte_surf() ||
6123 machine_is_msm8x55_svlte_ffa()) {
6124 msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
6125 msm7x30_sdc2_data.is_sdio_al_client = 1;
6126 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006127
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006128 msm_add_sdcc(2, &msm7x30_sdc2_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006129out2:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006130#endif
6131#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006132 if (mmc_regulator_init(3, "s3", 1800000))
6133 goto out3;
6134
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006135 msm_sdcc_setup_gpio(3, 1);
6136 msm_add_sdcc(3, &msm7x30_sdc3_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006137out3:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006138#endif
6139#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006140 if (mmc_regulator_init(4, "mmc", 2850000))
6141 return;
6142
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006143 msm_add_sdcc(4, &msm7x30_sdc4_data);
6144#endif
6145
6146}
6147
6148static void __init msm7x30_init_nand(void)
6149{
6150 char *build_id;
6151 struct flash_platform_data *plat_data;
6152
6153 build_id = socinfo_get_build_id();
6154 if (build_id == NULL) {
6155 pr_err("%s: Build ID not available from socinfo\n", __func__);
6156 return;
6157 }
6158
6159 if (build_id[8] == 'C' &&
6160 !msm_gpios_request_enable(msm_nand_ebi2_cfg_data,
6161 ARRAY_SIZE(msm_nand_ebi2_cfg_data))) {
6162 plat_data = msm_device_nand.dev.platform_data;
6163 plat_data->interleave = 1;
6164 printk(KERN_INFO "%s: Interleave mode Build ID found\n",
6165 __func__);
6166 }
6167}
6168
6169#ifdef CONFIG_SERIAL_MSM_CONSOLE
6170static struct msm_gpio uart2_config_data[] = {
6171 { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
6172 { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
6173 { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
6174 { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
6175};
6176
6177static void msm7x30_init_uart2(void)
6178{
6179 msm_gpios_request_enable(uart2_config_data,
6180 ARRAY_SIZE(uart2_config_data));
6181
6182}
6183#endif
6184
6185/* TSIF begin */
6186#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6187
6188#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6189#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6190#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6191#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6192
6193static const struct msm_gpio tsif_gpios[] = {
6194 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
6195 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
6196 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
6197 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
6198};
6199
6200static struct msm_tsif_platform_data tsif_platform_data = {
6201 .num_gpios = ARRAY_SIZE(tsif_gpios),
6202 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -07006203 .tsif_pclk = "iface_clk",
6204 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006205};
6206#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
6207/* TSIF end */
6208
6209static void __init pmic8058_leds_init(void)
6210{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306211 if (machine_is_msm7x30_surf())
6212 pm8058_7x30_data.leds_pdata = &pm8058_surf_leds_data;
6213 else if (!machine_is_msm7x30_fluid())
6214 pm8058_7x30_data.leds_pdata = &pm8058_ffa_leds_data;
6215 else if (machine_is_msm7x30_fluid())
6216 pm8058_7x30_data.leds_pdata = &pm8058_fluid_leds_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006217}
6218
6219static struct msm_spm_platform_data msm_spm_data __initdata = {
6220 .reg_base_addr = MSM_SAW_BASE,
6221
6222 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
6223 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
6224 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
6225 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
6226
6227 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
6228 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
6229 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
6230
6231 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
6232 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
6233 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
6234
6235 .awake_vlevel = 0xF2,
6236 .retention_vlevel = 0xE0,
6237 .collapse_vlevel = 0x72,
6238 .retention_mid_vlevel = 0xE0,
6239 .collapse_mid_vlevel = 0xE0,
6240
6241 .vctl_timeout_us = 50,
6242};
6243
6244#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6245 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6246
6247#define TSC2007_TS_PEN_INT 20
6248
6249static struct msm_gpio tsc2007_config_data[] = {
6250 { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
6251 "tsc2007_irq" },
6252};
6253
Justin Paupore3f40f342011-08-10 18:52:16 -07006254static struct regulator_bulk_data tsc2007_regs[] = {
6255 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
6256 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
6257};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006258
6259static int tsc2007_init(void)
6260{
6261 int rc;
6262
Justin Paupore3f40f342011-08-10 18:52:16 -07006263 rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006264
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006265 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006266 pr_err("%s: could not get regulators: %d\n", __func__, rc);
6267 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006268 }
6269
Justin Paupore3f40f342011-08-10 18:52:16 -07006270 rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6271
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006272 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006273 pr_err("%s: could not set voltages: %d\n", __func__, rc);
6274 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006275 }
6276
Justin Paupore3f40f342011-08-10 18:52:16 -07006277 rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006278
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006279 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006280 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
6281 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006282 }
6283
6284 rc = msm_gpios_request_enable(tsc2007_config_data,
6285 ARRAY_SIZE(tsc2007_config_data));
6286 if (rc) {
6287 pr_err("%s: Unable to request gpios\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006288 goto reg_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006289 }
6290
6291 return 0;
6292
Justin Paupore3f40f342011-08-10 18:52:16 -07006293reg_disable:
6294 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6295reg_free:
6296 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6297out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006298 return rc;
6299}
6300
6301static int tsc2007_get_pendown_state(void)
6302{
6303 int rc;
6304
6305 rc = gpio_get_value(TSC2007_TS_PEN_INT);
6306 if (rc < 0) {
6307 pr_err("%s: MSM GPIO %d read failed\n", __func__,
6308 TSC2007_TS_PEN_INT);
6309 return rc;
6310 }
6311
6312 return (rc == 0 ? 1 : 0);
6313}
6314
6315static void tsc2007_exit(void)
6316{
Justin Paupore3f40f342011-08-10 18:52:16 -07006317
6318 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6319 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006320
6321 msm_gpios_disable_free(tsc2007_config_data,
6322 ARRAY_SIZE(tsc2007_config_data));
6323}
6324
6325static int tsc2007_power_shutdown(bool enable)
6326{
6327 int rc;
6328
Justin Paupore3f40f342011-08-10 18:52:16 -07006329 rc = (enable == false) ?
6330 regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) :
6331 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6332
6333 if (rc) {
6334 pr_err("%s: could not %sable regulators: %d\n",
6335 __func__, enable ? "dis" : "en", rc);
6336 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006337 }
6338
Justin Paupore3f40f342011-08-10 18:52:16 -07006339 if (enable == false)
6340 msleep(20);
6341
6342 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006343}
6344
6345static struct tsc2007_platform_data tsc2007_ts_data = {
6346 .model = 2007,
6347 .x_plate_ohms = 300,
6348 .irq_flags = IRQF_TRIGGER_LOW,
6349 .init_platform_hw = tsc2007_init,
6350 .exit_platform_hw = tsc2007_exit,
6351 .power_shutdown = tsc2007_power_shutdown,
6352 .invert_x = true,
6353 .invert_y = true,
6354 /* REVISIT: Temporary fix for reversed pressure */
6355 .invert_z1 = true,
6356 .invert_z2 = true,
6357 .get_pendown_state = tsc2007_get_pendown_state,
6358};
6359
6360static struct i2c_board_info tsc_i2c_board_info[] = {
6361 {
6362 I2C_BOARD_INFO("tsc2007", 0x48),
6363 .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
6364 .platform_data = &tsc2007_ts_data,
6365 },
6366};
6367#endif
6368
Justin Paupore3f40f342011-08-10 18:52:16 -07006369static struct regulator_bulk_data regs_isa1200[] = {
6370 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
6371 { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006372};
6373
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006374static int isa1200_power(int vreg_on)
6375{
Justin Paupore3f40f342011-08-10 18:52:16 -07006376 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006377
Justin Paupore3f40f342011-08-10 18:52:16 -07006378 rc = vreg_on ?
6379 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) :
6380 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006381
Justin Paupore3f40f342011-08-10 18:52:16 -07006382 if (rc) {
6383 pr_err("%s: could not %sable regulators: %d\n",
6384 __func__, vreg_on ? "en" : "dis", rc);
6385 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006386 }
6387
6388 /* vote for DO buffer */
6389 rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO,
6390 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
6391 if (rc) {
6392 pr_err("%s: unable to %svote for d0 clk\n",
6393 __func__, vreg_on ? "" : "de-");
6394 goto vreg_fail;
6395 }
6396
6397 return 0;
6398
6399vreg_fail:
Justin Paupore3f40f342011-08-10 18:52:16 -07006400 if (vreg_on)
6401 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6402 else
6403 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6404out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006405 return rc;
6406}
6407
6408static int isa1200_dev_setup(bool enable)
6409{
Justin Paupore3f40f342011-08-10 18:52:16 -07006410 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006411
6412 if (enable == true) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006413 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200),
6414 regs_isa1200);
6415
6416 if (rc) {
6417 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006418 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006419 goto out;
6420 }
6421
6422 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200),
6423 regs_isa1200);
6424 if (rc) {
6425 pr_err("%s: could not set voltages: %d\n",
6426 __func__, rc);
6427 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006428 }
6429
6430 rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
6431 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
6432 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
6433 if (rc) {
6434 pr_err("%s: Could not configure gpio %d\n",
6435 __func__, HAP_LVL_SHFT_MSM_GPIO);
Justin Paupore3f40f342011-08-10 18:52:16 -07006436 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006437 }
6438
6439 rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
6440 if (rc) {
6441 pr_err("%s: unable to request gpio %d (%d)\n",
6442 __func__, HAP_LVL_SHFT_MSM_GPIO, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006443 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006444 }
6445
6446 gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
6447 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006448 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006449 gpio_free(HAP_LVL_SHFT_MSM_GPIO);
6450 }
6451
6452 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07006453
6454reg_free:
6455 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6456out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006457 return rc;
6458}
6459static struct isa1200_platform_data isa1200_1_pdata = {
6460 .name = "vibrator",
6461 .power_on = isa1200_power,
6462 .dev_setup = isa1200_dev_setup,
6463 .pwm_ch_id = 1, /*channel id*/
6464 /*gpio to enable haptic*/
6465 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka03122322011-09-09 15:15:43 +05306466 .hap_len_gpio = -1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006467 .max_timeout = 15000,
6468 .mode_ctrl = PWM_GEN_MODE,
6469 .pwm_fd = {
6470 .pwm_div = 256,
6471 },
6472 .is_erm = false,
6473 .smart_en = true,
6474 .ext_clk_en = true,
6475 .chip_en = 1,
6476};
6477
6478static struct i2c_board_info msm_isa1200_board_info[] = {
6479 {
6480 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
6481 .platform_data = &isa1200_1_pdata,
6482 },
6483};
6484
6485
6486static int kp_flip_mpp_config(void)
6487{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306488 struct pm8xxx_mpp_config_data kp_flip_mpp = {
6489 .type = PM8XXX_MPP_TYPE_D_INPUT,
6490 .level = PM8018_MPP_DIG_LEVEL_S3,
6491 .control = PM8XXX_MPP_DIN_TO_INT,
6492 };
6493
6494 return pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(PM_FLIP_MPP),
6495 &kp_flip_mpp);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006496}
6497
6498static struct flip_switch_pdata flip_switch_data = {
6499 .name = "kp_flip_switch",
6500 .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP,
6501 .left_key = KEY_OPEN,
6502 .right_key = KEY_CLOSE,
6503 .active_low = 0,
6504 .wakeup = 1,
6505 .flip_mpp_config = kp_flip_mpp_config,
6506};
6507
6508static struct platform_device flip_switch_device = {
6509 .name = "kp_flip_switch",
6510 .id = -1,
6511 .dev = {
6512 .platform_data = &flip_switch_data,
6513 }
6514};
6515
Justin Paupore3f40f342011-08-10 18:52:16 -07006516static struct regulator_bulk_data regs_tma300[] = {
6517 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
6518 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006519};
6520
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006521static int tma300_power(int vreg_on)
6522{
Justin Paupore3f40f342011-08-10 18:52:16 -07006523 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006524
Justin Paupore3f40f342011-08-10 18:52:16 -07006525 rc = vreg_on ?
6526 regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) :
6527 regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006528
Justin Paupore3f40f342011-08-10 18:52:16 -07006529 if (rc)
6530 pr_err("%s: could not %sable regulators: %d\n",
6531 __func__, vreg_on ? "en" : "dis", rc);
6532 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006533}
6534
6535#define TS_GPIO_IRQ 150
6536
6537static int tma300_dev_setup(bool enable)
6538{
Justin Paupore3f40f342011-08-10 18:52:16 -07006539 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006540
6541 if (enable) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006542 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300),
6543 regs_tma300);
6544
6545 if (rc) {
6546 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006547 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006548 goto out;
6549 }
6550
6551 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300),
6552 regs_tma300);
6553
6554 if (rc) {
6555 pr_err("%s: could not set voltages: %d\n",
6556 __func__, rc);
6557 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006558 }
6559
6560 /* enable interrupt gpio */
6561 rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
6562 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
6563 if (rc) {
6564 pr_err("%s: Could not configure gpio %d\n",
6565 __func__, TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -07006566 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006567 }
6568
6569 /* virtual keys */
6570 tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
6571 properties_kobj = kobject_create_and_add("board_properties",
6572 NULL);
6573 if (!properties_kobj) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006574 pr_err("%s: failed to create a kobject "
6575 "for board_properties\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006576 rc = -ENOMEM;
Justin Paupore3f40f342011-08-10 18:52:16 -07006577 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006578 }
6579 rc = sysfs_create_group(properties_kobj,
6580 &tma300_properties_attr_group);
6581 if (rc) {
6582 pr_err("%s: failed to create a sysfs entry %s\n",
6583 __func__, tma300_vkeys_attr.attr.name);
Justin Paupore3f40f342011-08-10 18:52:16 -07006584 goto kobj_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006585 }
6586 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006587 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006588 /* destroy virtual keys */
6589 if (properties_kobj) {
6590 sysfs_remove_group(properties_kobj,
6591 &tma300_properties_attr_group);
6592 kobject_put(properties_kobj);
6593 }
6594 }
6595 return 0;
6596
Justin Paupore3f40f342011-08-10 18:52:16 -07006597kobj_free:
6598 kobject_put(properties_kobj);
6599 properties_kobj = NULL;
6600reg_free:
6601 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
6602out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006603 return rc;
6604}
6605
6606static struct cy8c_ts_platform_data cy8ctma300_pdata = {
6607 .power_on = tma300_power,
6608 .dev_setup = tma300_dev_setup,
6609 .ts_name = "msm_tma300_ts",
6610 .dis_min_x = 0,
6611 .dis_max_x = 479,
6612 .dis_min_y = 0,
6613 .dis_max_y = 799,
6614 .res_x = 479,
6615 .res_y = 1009,
6616 .min_tid = 1,
6617 .max_tid = 255,
6618 .min_touch = 0,
6619 .max_touch = 255,
6620 .min_width = 0,
6621 .max_width = 255,
6622 .invert_y = 1,
6623 .nfingers = 4,
6624 .irq_gpio = TS_GPIO_IRQ,
6625 .resout_gpio = -1,
6626};
6627
6628static struct i2c_board_info cy8ctma300_board_info[] = {
6629 {
6630 I2C_BOARD_INFO("cy8ctma300", 0x2),
6631 .platform_data = &cy8ctma300_pdata,
6632 }
6633};
6634
Daniel Walker8d747cd2010-02-25 11:37:43 -08006635static void __init msm7x30_init(void)
6636{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006637 int rc;
6638 unsigned smem_size;
6639 uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56,
6640 0,
6641 GPIO_CFG_OUTPUT,
6642 GPIO_CFG_NO_PULL,
6643 GPIO_CFG_2MA);
6644 uint32_t soc_version = 0;
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05306645
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006646 soc_version = socinfo_get_version();
6647
Stephen Boydbb600ae2011-08-02 20:11:40 -07006648 msm_clock_init(&msm7x30_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006649#ifdef CONFIG_SERIAL_MSM_CONSOLE
6650 msm7x30_init_uart2();
6651#endif
6652 msm_spm_init(&msm_spm_data, 1);
Matt Wagantallec57f062011-08-16 23:54:46 -07006653 acpuclk_init(&acpuclk_7x30_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006654 if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid())
6655 msm7x30_cfg_smsc911x();
6656
6657#ifdef CONFIG_USB_MSM_OTG_72K
6658 if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 &&
6659 SOCINFO_VERSION_MINOR(soc_version) >= 1) {
6660 pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
6661 msm_otg_pdata.ldo_set_voltage = 0;
6662 }
6663
6664 msm_device_otg.dev.platform_data = &msm_otg_pdata;
6665#ifdef CONFIG_USB_GADGET
6666 msm_otg_pdata.swfi_latency =
6667 msm_pm_data
6668 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
6669 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
6670#endif
6671#endif
6672 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
6673 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
6674#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6675 msm_device_tsif.dev.platform_data = &tsif_platform_data;
6676#endif
6677 if (machine_is_msm7x30_fluid()) {
6678 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
6679 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
6680 } else {
6681 msm_adc_pdata.dev_names = msm_adc_surf_device_names;
6682 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names);
6683 }
6684
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306685 pmic8058_leds_init();
6686
6687 buses_init();
6688
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306689#ifdef CONFIG_MSM_SSBI
6690 msm_device_ssbi_pmic1.dev.platform_data =
6691 &msm7x30_ssbi_pm8058_pdata;
6692#endif
6693
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006694 platform_add_devices(msm_footswitch_devices,
6695 msm_num_footswitch_devices);
Daniel Walker8d747cd2010-02-25 11:37:43 -08006696 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006697#ifdef CONFIG_USB_EHCI_MSM_72K
6698 msm_add_host(0, &msm_usb_host_pdata);
6699#endif
6700 msm7x30_init_mmc();
6701 msm7x30_init_nand();
6702 msm_qsd_spi_init();
6703
6704#ifdef CONFIG_SPI_QSD
6705 if (machine_is_msm7x30_fluid())
6706 spi_register_board_info(lcdc_sharp_spi_board_info,
6707 ARRAY_SIZE(lcdc_sharp_spi_board_info));
6708 else
6709 spi_register_board_info(lcdc_toshiba_spi_board_info,
6710 ARRAY_SIZE(lcdc_toshiba_spi_board_info));
6711#endif
6712
Justin Paupore3f40f342011-08-10 18:52:16 -07006713 atv_dac_power_init();
6714 sensors_ldo_init();
6715 hdmi_init_regs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006716 msm_fb_add_devices();
6717 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06006718 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006719 msm_device_i2c_init();
6720 msm_device_i2c_2_init();
6721 qup_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006722 msm7x30_init_marimba();
6723#ifdef CONFIG_MSM7KV2_AUDIO
6724 snddev_poweramp_gpio_init();
Justin Paupore3f40f342011-08-10 18:52:16 -07006725 snddev_hsed_voltage_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006726 aux_pcm_gpio_init();
6727#endif
6728
6729 i2c_register_board_info(0, msm_i2c_board_info,
6730 ARRAY_SIZE(msm_i2c_board_info));
6731
6732 if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid())
6733 marimba_pdata.tsadc = &marimba_tsadc_pdata;
6734
6735 if (machine_is_msm7x30_fluid())
6736 i2c_register_board_info(0, cy8info,
6737 ARRAY_SIZE(cy8info));
6738#ifdef CONFIG_BOSCH_BMA150
6739 if (machine_is_msm7x30_fluid())
6740 i2c_register_board_info(0, bma150_board_info,
6741 ARRAY_SIZE(bma150_board_info));
6742#endif
6743
6744 i2c_register_board_info(2, msm_marimba_board_info,
6745 ARRAY_SIZE(msm_marimba_board_info));
6746
6747 i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info,
6748 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info));
6749
6750 i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
6751 ARRAY_SIZE(msm_camera_boardinfo));
6752
6753 bt_power_init();
6754#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006755 msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
6756#endif
6757 if (machine_is_msm7x30_fluid())
6758 i2c_register_board_info(0, msm_isa1200_board_info,
6759 ARRAY_SIZE(msm_isa1200_board_info));
6760
6761#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6762 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6763 if (machine_is_msm8x55_svlte_ffa())
6764 i2c_register_board_info(2, tsc_i2c_board_info,
6765 ARRAY_SIZE(tsc_i2c_board_info));
6766#endif
6767
6768 if (machine_is_msm7x30_surf())
6769 platform_device_register(&flip_switch_device);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306770
6771 pm8058_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006772
6773 if (machine_is_msm7x30_fluid()) {
6774 /* Initialize platform data for fluid v2 hardware */
6775 if (SOCINFO_VERSION_MAJOR(
6776 socinfo_get_platform_version()) == 2) {
6777 cy8ctma300_pdata.res_y = 920;
6778 cy8ctma300_pdata.invert_y = 0;
6779 }
6780 i2c_register_board_info(0, cy8ctma300_board_info,
6781 ARRAY_SIZE(cy8ctma300_board_info));
6782 }
6783
6784 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
6785 rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE);
6786 if (rc)
6787 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
6788 __func__, usb_hub_gpio_cfg_value, rc);
6789 }
6790
6791 boot_reason = *(unsigned int *)
6792 (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
6793 printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
6794}
6795
6796static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
6797static int __init pmem_sf_size_setup(char *p)
6798{
6799 pmem_sf_size = memparse(p, NULL);
6800 return 0;
6801}
6802early_param("pmem_sf_size", pmem_sf_size_setup);
6803
6804static unsigned fb_size = MSM_FB_SIZE;
6805static int __init fb_size_setup(char *p)
6806{
6807 fb_size = memparse(p, NULL);
6808 return 0;
6809}
6810early_param("fb_size", fb_size_setup);
6811
6812static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
6813static int __init pmem_adsp_size_setup(char *p)
6814{
6815 pmem_adsp_size = memparse(p, NULL);
6816 return 0;
6817}
6818early_param("pmem_adsp_size", pmem_adsp_size_setup);
6819
6820static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE;
6821static int __init fluid_pmem_adsp_size_setup(char *p)
6822{
6823 fluid_pmem_adsp_size = memparse(p, NULL);
6824 return 0;
6825}
6826early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup);
6827
6828static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
6829static int __init pmem_audio_size_setup(char *p)
6830{
6831 pmem_audio_size = memparse(p, NULL);
6832 return 0;
6833}
6834early_param("pmem_audio_size", pmem_audio_size_setup);
6835
6836static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE;
6837static int __init pmem_kernel_ebi0_size_setup(char *p)
6838{
6839 pmem_kernel_ebi0_size = memparse(p, NULL);
6840 return 0;
6841}
6842early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
6843
6844static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
6845 [MEMTYPE_SMI] = {
6846 },
6847 [MEMTYPE_EBI0] = {
6848 .flags = MEMTYPE_FLAGS_1M_ALIGN,
6849 },
6850 [MEMTYPE_EBI1] = {
6851 .flags = MEMTYPE_FLAGS_1M_ALIGN,
6852 },
6853};
6854
6855static void __init size_pmem_devices(void)
6856{
6857#ifdef CONFIG_ANDROID_PMEM
6858 unsigned long size;
6859
6860 if machine_is_msm7x30_fluid()
6861 size = fluid_pmem_adsp_size;
6862 else
6863 size = pmem_adsp_size;
6864 android_pmem_adsp_pdata.size = size;
6865 android_pmem_audio_pdata.size = pmem_audio_size;
6866 android_pmem_pdata.size = pmem_sf_size;
6867#endif
6868}
6869
6870static void __init reserve_memory_for(struct android_pmem_platform_data *p)
6871{
6872 msm7x30_reserve_table[p->memory_type].size += p->size;
6873}
6874
6875static void __init reserve_pmem_memory(void)
6876{
6877#ifdef CONFIG_ANDROID_PMEM
6878 reserve_memory_for(&android_pmem_adsp_pdata);
6879 reserve_memory_for(&android_pmem_audio_pdata);
6880 reserve_memory_for(&android_pmem_pdata);
6881 msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
6882#endif
6883}
6884
6885static void __init msm7x30_calculate_reserve_sizes(void)
6886{
6887 size_pmem_devices();
6888 reserve_pmem_memory();
6889}
6890
6891static int msm7x30_paddr_to_memtype(unsigned int paddr)
6892{
6893 if (paddr < 0x40000000)
6894 return MEMTYPE_EBI0;
6895 if (paddr >= 0x40000000 && paddr < 0x80000000)
6896 return MEMTYPE_EBI1;
6897 return MEMTYPE_NONE;
6898}
6899
6900static struct reserve_info msm7x30_reserve_info __initdata = {
6901 .memtype_reserve_table = msm7x30_reserve_table,
6902 .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes,
6903 .paddr_to_memtype = msm7x30_paddr_to_memtype,
6904};
6905
6906static void __init msm7x30_reserve(void)
6907{
6908 reserve_info = &msm7x30_reserve_info;
6909 msm_reserve();
6910}
6911
6912static void __init msm7x30_allocate_memory_regions(void)
6913{
6914 void *addr;
6915 unsigned long size;
6916
6917 size = fb_size ? : MSM_FB_SIZE;
6918 addr = alloc_bootmem_align(size, 0x1000);
6919 msm_fb_resources[0].start = __pa(addr);
6920 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
6921 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
6922 size, addr, __pa(addr));
Daniel Walker8d747cd2010-02-25 11:37:43 -08006923}
6924
6925static void __init msm7x30_map_io(void)
6926{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006927 msm_shared_ram_phys = 0x00100000;
Daniel Walker8d747cd2010-02-25 11:37:43 -08006928 msm_map_msm7x30_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07006929 if (socinfo_init() < 0)
6930 printk(KERN_ERR "%s: socinfo_init() failed!\n",
6931 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006932}
6933
6934static void __init msm7x30_init_early(void)
6935{
6936 msm7x30_allocate_memory_regions();
Daniel Walker8d747cd2010-02-25 11:37:43 -08006937}
6938
6939MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00006940 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006941 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006942 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006943 .init_irq = msm7x30_init_irq,
6944 .init_machine = msm7x30_init,
6945 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006946 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05306947 .handle_irq = vic_handle_irq,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006948MACHINE_END
6949
6950MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00006951 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006952 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006953 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006954 .init_irq = msm7x30_init_irq,
6955 .init_machine = msm7x30_init,
6956 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006957 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05306958 .handle_irq = vic_handle_irq,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006959MACHINE_END
6960
6961MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
Russell Kingb75c1782011-01-04 19:03:16 +00006962 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006963 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006964 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006965 .init_irq = msm7x30_init_irq,
6966 .init_machine = msm7x30_init,
6967 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006968 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05306969 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006970MACHINE_END
6971
6972MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
6973 .boot_params = PHYS_OFFSET + 0x100,
6974 .map_io = msm7x30_map_io,
6975 .reserve = msm7x30_reserve,
6976 .init_irq = msm7x30_init_irq,
6977 .init_machine = msm7x30_init,
6978 .timer = &msm_timer,
6979 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05306980 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006981MACHINE_END
6982
6983MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA")
6984 .boot_params = PHYS_OFFSET + 0x100,
6985 .map_io = msm7x30_map_io,
6986 .reserve = msm7x30_reserve,
6987 .init_irq = msm7x30_init_irq,
6988 .init_machine = msm7x30_init,
6989 .timer = &msm_timer,
6990 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05306991 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006992MACHINE_END
6993MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
6994 .boot_params = PHYS_OFFSET + 0x100,
6995 .map_io = msm7x30_map_io,
6996 .reserve = msm7x30_reserve,
6997 .init_irq = msm7x30_init_irq,
6998 .init_machine = msm7x30_init,
6999 .timer = &msm_timer,
7000 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307001 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007002MACHINE_END
7003MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA")
7004 .boot_params = PHYS_OFFSET + 0x100,
7005 .map_io = msm7x30_map_io,
7006 .reserve = msm7x30_reserve,
7007 .init_irq = msm7x30_init_irq,
7008 .init_machine = msm7x30_init,
7009 .timer = &msm_timer,
7010 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307011 .handle_irq = vic_handle_irq,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007012MACHINE_END