blob: bd570cf9c73c1ec9ba50de1b143df7641d27b1e5 [file] [log] [blame]
Manu Gautam5143b252012-01-05 19:25:23 -08001/* Copyright (c) 2009-2012, 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
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080081#include <mach/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
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003217 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
3218 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
3219 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
3220 .se1_gating = SE1_GATING_DISABLE,
3221 .chg_vbus_draw = hsusb_chg_vbus_draw,
3222 .chg_connected = hsusb_chg_connected,
3223 .chg_init = hsusb_chg_init,
3224 .ldo_enable = msm_hsusb_ldo_enable,
3225 .ldo_init = msm_hsusb_ldo_init,
3226 .ldo_set_voltage = msm_hsusb_ldo_set_voltage,
3227};
3228
3229#ifdef CONFIG_USB_GADGET
3230static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
3231 .is_phy_status_timer_on = 1,
3232};
3233#endif
3234#ifndef CONFIG_USB_EHCI_MSM_72K
3235typedef void (*notify_vbus_state) (int);
3236notify_vbus_state notify_vbus_state_func_ptr;
3237int vbus_on_irq;
3238static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
3239{
3240 pr_info("%s: vbus notification from pmic\n", __func__);
3241
3242 (*notify_vbus_state_func_ptr) (1);
3243
3244 return IRQ_HANDLED;
3245}
3246static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
3247{
3248 int ret;
3249
3250 if (init) {
3251 if (!callback)
3252 return -ENODEV;
3253
3254 notify_vbus_state_func_ptr = callback;
3255 vbus_on_irq = platform_get_irq_byname(&msm_device_otg,
3256 "vbus_on");
3257 if (vbus_on_irq <= 0) {
3258 pr_err("%s: unable to get vbus on irq\n", __func__);
3259 return -ENODEV;
3260 }
3261
3262 ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq,
3263 IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
3264 if (ret < 0) {
3265 pr_info("%s: request_irq for vbus_on"
3266 "interrupt failed\n", __func__);
3267 return ret;
3268 }
3269 msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
3270 return 0;
3271 } else {
3272 free_irq(vbus_on_irq, 0);
3273 notify_vbus_state_func_ptr = NULL;
3274 return 0;
3275 }
3276}
3277#endif
3278
3279static struct android_pmem_platform_data android_pmem_pdata = {
3280 .name = "pmem",
3281 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
3282 .cached = 1,
3283 .memory_type = MEMTYPE_EBI0,
3284};
3285
3286static struct platform_device android_pmem_device = {
3287 .name = "android_pmem",
3288 .id = 0,
3289 .dev = { .platform_data = &android_pmem_pdata },
3290};
3291
3292#ifndef CONFIG_SPI_QSD
3293static int lcdc_gpio_array_num[] = {
3294 45, /* spi_clk */
3295 46, /* spi_cs */
3296 47, /* spi_mosi */
3297 48, /* spi_miso */
3298 };
3299
3300static struct msm_gpio lcdc_gpio_config_data[] = {
3301 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3302 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3303 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
3304 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3305};
3306
3307static void lcdc_config_gpios(int enable)
3308{
3309 if (enable) {
3310 msm_gpios_request_enable(lcdc_gpio_config_data,
3311 ARRAY_SIZE(
3312 lcdc_gpio_config_data));
3313 } else
3314 msm_gpios_disable_free(lcdc_gpio_config_data,
3315 ARRAY_SIZE(
3316 lcdc_gpio_config_data));
3317}
3318#endif
3319
3320static struct msm_panel_common_pdata lcdc_sharp_panel_data = {
3321#ifndef CONFIG_SPI_QSD
3322 .panel_config_gpio = lcdc_config_gpios,
3323 .gpio_num = lcdc_gpio_array_num,
3324#endif
3325 .gpio = 2, /* LPG PMIC_GPIO26 channel number */
3326};
3327
3328static struct platform_device lcdc_sharp_panel_device = {
3329 .name = "lcdc_sharp_wvga",
3330 .id = 0,
3331 .dev = {
3332 .platform_data = &lcdc_sharp_panel_data,
3333 }
3334};
3335
3336static struct msm_gpio dtv_panel_irq_gpios[] = {
3337 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
3338 "hdmi_int" },
3339};
3340
3341static struct msm_gpio dtv_panel_gpios[] = {
3342 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
3343 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
3344 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
3345 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
3346 { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
3347 { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
3348 { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
3349 { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
3350 { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
3351 { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
3352 { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
3353 { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
3354 { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
3355 { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
3356 { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
3357 { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
3358 { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
3359 { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
3360 { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
3361 { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
3362 { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
3363 { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
3364 { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
3365 { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
3366 { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
3367 { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
3368 { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
3369 { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
3370 { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
3371 { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
3372 { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
3373 { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
3374};
3375
3376
3377#ifdef HDMI_RESET
3378static unsigned dtv_reset_gpio =
3379 GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3380#endif
3381
Justin Paupore3f40f342011-08-10 18:52:16 -07003382static struct regulator_bulk_data hdmi_core_regs[] = {
3383 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3384};
3385
3386static struct regulator_bulk_data hdmi_comm_regs[] = {
3387 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3388 { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 },
3389};
3390
3391static struct regulator_bulk_data hdmi_cec_regs[] = {
3392 { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 },
3393};
3394
3395static int __init hdmi_init_regs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003396{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003397 int rc;
3398
Justin Paupore3f40f342011-08-10 18:52:16 -07003399 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs),
3400 hdmi_core_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003401
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003402 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003403 pr_err("%s: could not get %s regulators: %d\n",
3404 __func__, "core", rc);
3405 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003406 }
3407
Justin Paupore3f40f342011-08-10 18:52:16 -07003408 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs),
3409 hdmi_core_regs);
3410
3411 if (rc) {
3412 pr_err("%s: could not set %s voltages: %d\n",
3413 __func__, "core", rc);
3414 goto free_core;
3415 }
3416
3417 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs),
3418 hdmi_comm_regs);
3419
3420 if (rc) {
3421 pr_err("%s: could not get %s regulators: %d\n",
3422 __func__, "comm", rc);
3423 goto free_core;
3424 }
3425
3426 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs),
3427 hdmi_comm_regs);
3428
3429 if (rc) {
3430 pr_err("%s: could not set %s voltages: %d\n",
3431 __func__, "comm", rc);
3432 goto free_comm;
3433 }
3434
3435 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs),
3436 hdmi_cec_regs);
3437
3438 if (rc) {
3439 pr_err("%s: could not get %s regulators: %d\n",
3440 __func__, "cec", rc);
3441 goto free_comm;
3442 }
3443
3444 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs),
3445 hdmi_cec_regs);
3446
3447 if (rc) {
3448 pr_err("%s: could not set %s voltages: %d\n",
3449 __func__, "cec", rc);
3450 goto free_cec;
3451 }
3452
3453 return 0;
3454
3455free_cec:
3456 regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs);
3457free_comm:
3458 regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs);
3459free_core:
3460 regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs);
3461out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003462 return rc;
3463}
3464
Justin Paupore3f40f342011-08-10 18:52:16 -07003465static int hdmi_init_irq(void)
3466{
3467 int rc = msm_gpios_enable(dtv_panel_irq_gpios,
3468 ARRAY_SIZE(dtv_panel_irq_gpios));
3469 if (rc < 0) {
3470 pr_err("%s: gpio enable failed: %d\n", __func__, rc);
3471 return rc;
3472 }
3473 pr_info("%s\n", __func__);
3474
3475 return 0;
3476}
3477
3478static int hdmi_enable_5v(int on)
3479{
3480 int pmic_gpio_hdmi_5v_en ;
3481
3482 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
3483 machine_is_msm7x30_fluid())
3484 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
3485 else
3486 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
3487
3488 pr_info("%s: %d\n", __func__, on);
3489 if (on) {
3490 int rc;
3491 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
3492 "hdmi_5V_en");
3493 if (rc) {
3494 pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
3495 __func__);
3496 return rc;
3497 }
3498 gpio_set_value_cansleep(
3499 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
3500 } else {
3501 gpio_set_value_cansleep(
3502 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
3503 gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
3504 }
3505 return 0;
3506}
3507
3508static int hdmi_comm_power(int on, int show)
3509{
3510 if (show)
3511 pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
3512 return on ?
3513 regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs),
3514 hdmi_comm_regs) :
3515 regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs),
3516 hdmi_comm_regs);
3517}
3518
3519static int hdmi_core_power(int on, int show)
3520{
3521 if (show)
3522 pr_info("%s: %d <LDO8>\n", __func__, on);
3523 return on ?
3524 regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs),
3525 hdmi_core_regs) :
3526 regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs),
3527 hdmi_core_regs);
3528}
3529
3530static int hdmi_cec_power(int on)
3531{
3532 pr_info("%s: %d <LDO17>\n", __func__, on);
3533 return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs),
3534 hdmi_cec_regs) :
3535 regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs),
3536 hdmi_cec_regs);
3537}
3538
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003539#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
3540/* there is an i2c address conflict between adv7520 and bma150 sensor after
3541 * power up on fluid. As a solution, the default address of adv7520's packet
3542 * memory is changed as soon as possible
3543 */
3544static int __init fluid_i2c_address_fixup(void)
3545{
3546 unsigned char wBuff[16];
3547 unsigned char rBuff[16];
3548 struct i2c_msg msgs[3];
3549 int res;
3550 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003551 struct i2c_adapter *adapter;
3552
3553 if (machine_is_msm7x30_fluid()) {
3554 adapter = i2c_get_adapter(0);
3555 if (!adapter) {
3556 pr_err("%s: invalid i2c adapter\n", __func__);
3557 return PTR_ERR(adapter);
3558 }
3559
3560 /* turn on LDO8 */
Justin Paupore3f40f342011-08-10 18:52:16 -07003561 rc = hdmi_core_power(1, 0);
3562 if (rc) {
3563 pr_err("%s: could not enable hdmi core regs: %d",
3564 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003565 goto adapter_put;
3566 }
3567
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003568 /* change packet memory address to 0x74 */
3569 wBuff[0] = 0x45;
3570 wBuff[1] = 0x74;
3571
3572 msgs[0].addr = ADV7520_I2C_ADDR;
3573 msgs[0].flags = 0;
3574 msgs[0].buf = (unsigned char *) wBuff;
3575 msgs[0].len = 2;
3576
3577 res = i2c_transfer(adapter, msgs, 1);
3578 if (res != 1) {
3579 pr_err("%s: error writing adv7520\n", __func__);
3580 goto ldo8_disable;
3581 }
3582
3583 /* powerdown adv7520 using bit 6 */
3584 /* i2c read first */
3585 wBuff[0] = 0x41;
3586
3587 msgs[0].addr = ADV7520_I2C_ADDR;
3588 msgs[0].flags = 0;
3589 msgs[0].buf = (unsigned char *) wBuff;
3590 msgs[0].len = 1;
3591
3592 msgs[1].addr = ADV7520_I2C_ADDR;
3593 msgs[1].flags = I2C_M_RD;
3594 msgs[1].buf = rBuff;
3595 msgs[1].len = 1;
3596 res = i2c_transfer(adapter, msgs, 2);
3597 if (res != 2) {
3598 pr_err("%s: error reading adv7520\n", __func__);
3599 goto ldo8_disable;
3600 }
3601
3602 /* i2c write back */
3603 wBuff[0] = 0x41;
3604 wBuff[1] = rBuff[0] | 0x40;
3605
3606 msgs[0].addr = ADV7520_I2C_ADDR;
3607 msgs[0].flags = 0;
3608 msgs[0].buf = (unsigned char *) wBuff;
3609 msgs[0].len = 2;
3610
3611 res = i2c_transfer(adapter, msgs, 1);
3612 if (res != 1) {
3613 pr_err("%s: error writing adv7520\n", __func__);
3614 goto ldo8_disable;
3615 }
3616
3617 /* for successful fixup, we release the i2c adapter */
3618 /* but leave ldo8 on so that the adv7520 is not repowered */
3619 i2c_put_adapter(adapter);
3620 pr_info("%s: fluid i2c address conflict resolved\n", __func__);
3621 }
3622 return 0;
3623
3624ldo8_disable:
Justin Paupore3f40f342011-08-10 18:52:16 -07003625 hdmi_core_power(0, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003626adapter_put:
3627 i2c_put_adapter(adapter);
3628 return rc;
3629}
3630fs_initcall_sync(fluid_i2c_address_fixup);
3631#endif
3632
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003633static bool hdmi_check_hdcp_hw_support(void)
3634{
3635 if (machine_is_msm7x30_fluid())
3636 return false;
3637 else
3638 return true;
3639}
3640
3641static int dtv_panel_power(int on)
3642{
3643 int flag_on = !!on;
3644 static int dtv_power_save_on;
3645 int rc;
3646
3647 if (dtv_power_save_on == flag_on)
3648 return 0;
3649
3650 dtv_power_save_on = flag_on;
3651 pr_info("%s: %d\n", __func__, on);
3652
3653#ifdef HDMI_RESET
3654 if (on) {
3655 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
3656 rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
3657 if (rc) {
3658 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
3659 __func__, dtv_reset_gpio, rc);
3660 return rc;
3661 }
3662
3663 /* bring reset line low to hold reset*/
3664 gpio_set_value(37, 0);
3665 }
3666#endif
3667
3668 if (on) {
3669 rc = msm_gpios_enable(dtv_panel_gpios,
3670 ARRAY_SIZE(dtv_panel_gpios));
3671 if (rc < 0) {
3672 printk(KERN_ERR "%s: gpio enable failed: %d\n",
3673 __func__, rc);
3674 return rc;
3675 }
3676 } else {
3677 rc = msm_gpios_disable(dtv_panel_gpios,
3678 ARRAY_SIZE(dtv_panel_gpios));
3679 if (rc < 0) {
3680 printk(KERN_ERR "%s: gpio disable failed: %d\n",
3681 __func__, rc);
3682 return rc;
3683 }
3684 }
3685
3686 mdelay(5); /* ensure power is stable */
3687
3688#ifdef HDMI_RESET
3689 if (on) {
3690 gpio_set_value(37, 1); /* bring reset line high */
3691 mdelay(10); /* 10 msec before IO can be accessed */
3692 }
3693#endif
3694
3695 return rc;
3696}
3697
3698static struct lcdc_platform_data dtv_pdata = {
3699 .lcdc_power_save = dtv_panel_power,
3700};
3701
3702static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3703 .inject_rx_on_wakeup = 1,
3704 .rx_to_inject = 0xFD,
3705};
3706
3707static struct resource msm_fb_resources[] = {
3708 {
3709 .flags = IORESOURCE_DMA,
3710 }
3711};
3712
3713static int msm_fb_detect_panel(const char *name)
3714{
3715 if (machine_is_msm7x30_fluid()) {
3716 if (!strcmp(name, "lcdc_sharp_wvga_pt"))
3717 return 0;
3718 } else {
3719 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
3720 return -EPERM;
3721 else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20))
3722 return 0;
3723 else if (!strcmp(name, "mddi_orise"))
3724 return -EPERM;
3725 else if (!strcmp(name, "mddi_quickvx"))
3726 return -EPERM;
3727 }
3728 return -ENODEV;
3729}
3730
3731static struct msm_fb_platform_data msm_fb_pdata = {
3732 .detect_client = msm_fb_detect_panel,
3733 .mddi_prescan = 1,
3734};
3735
3736static struct platform_device msm_fb_device = {
3737 .name = "msm_fb",
3738 .id = 0,
3739 .num_resources = ARRAY_SIZE(msm_fb_resources),
3740 .resource = msm_fb_resources,
3741 .dev = {
3742 .platform_data = &msm_fb_pdata,
3743 }
3744};
3745
3746static struct platform_device msm_migrate_pages_device = {
3747 .name = "msm_migrate_pages",
3748 .id = -1,
3749};
3750
3751static struct android_pmem_platform_data android_pmem_adsp_pdata = {
3752 .name = "pmem_adsp",
3753 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
3754 .cached = 0,
3755 .memory_type = MEMTYPE_EBI0,
3756};
3757
3758static struct android_pmem_platform_data android_pmem_audio_pdata = {
3759 .name = "pmem_audio",
3760 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
3761 .cached = 0,
3762 .memory_type = MEMTYPE_EBI0,
3763};
3764
3765static struct platform_device android_pmem_adsp_device = {
3766 .name = "android_pmem",
3767 .id = 2,
3768 .dev = { .platform_data = &android_pmem_adsp_pdata },
3769};
3770
3771static struct platform_device android_pmem_audio_device = {
3772 .name = "android_pmem",
3773 .id = 4,
3774 .dev = { .platform_data = &android_pmem_audio_pdata },
3775};
3776
3777#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3778 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
3779 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3780 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3781
3782#define QCE_SIZE 0x10000
3783#define QCE_0_BASE 0xA8400000
3784
3785#define QCE_HW_KEY_SUPPORT 1
3786#define QCE_SHA_HMAC_SUPPORT 0
3787#define QCE_SHARE_CE_RESOURCE 0
3788#define QCE_CE_SHARED 0
3789
3790static struct resource qcrypto_resources[] = {
3791 [0] = {
3792 .start = QCE_0_BASE,
3793 .end = QCE_0_BASE + QCE_SIZE - 1,
3794 .flags = IORESOURCE_MEM,
3795 },
3796 [1] = {
3797 .name = "crypto_channels",
3798 .start = DMOV_CE_IN_CHAN,
3799 .end = DMOV_CE_OUT_CHAN,
3800 .flags = IORESOURCE_DMA,
3801 },
3802 [2] = {
3803 .name = "crypto_crci_in",
3804 .start = DMOV_CE_IN_CRCI,
3805 .end = DMOV_CE_IN_CRCI,
3806 .flags = IORESOURCE_DMA,
3807 },
3808 [3] = {
3809 .name = "crypto_crci_out",
3810 .start = DMOV_CE_OUT_CRCI,
3811 .end = DMOV_CE_OUT_CRCI,
3812 .flags = IORESOURCE_DMA,
3813 },
3814 [4] = {
3815 .name = "crypto_crci_hash",
3816 .start = DMOV_CE_HASH_CRCI,
3817 .end = DMOV_CE_HASH_CRCI,
3818 .flags = IORESOURCE_DMA,
3819 },
3820};
3821
3822static struct resource qcedev_resources[] = {
3823 [0] = {
3824 .start = QCE_0_BASE,
3825 .end = QCE_0_BASE + QCE_SIZE - 1,
3826 .flags = IORESOURCE_MEM,
3827 },
3828 [1] = {
3829 .name = "crypto_channels",
3830 .start = DMOV_CE_IN_CHAN,
3831 .end = DMOV_CE_OUT_CHAN,
3832 .flags = IORESOURCE_DMA,
3833 },
3834 [2] = {
3835 .name = "crypto_crci_in",
3836 .start = DMOV_CE_IN_CRCI,
3837 .end = DMOV_CE_IN_CRCI,
3838 .flags = IORESOURCE_DMA,
3839 },
3840 [3] = {
3841 .name = "crypto_crci_out",
3842 .start = DMOV_CE_OUT_CRCI,
3843 .end = DMOV_CE_OUT_CRCI,
3844 .flags = IORESOURCE_DMA,
3845 },
3846 [4] = {
3847 .name = "crypto_crci_hash",
3848 .start = DMOV_CE_HASH_CRCI,
3849 .end = DMOV_CE_HASH_CRCI,
3850 .flags = IORESOURCE_DMA,
3851 },
3852};
3853
3854#endif
3855
3856#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3857 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
3858
3859static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
3860 .ce_shared = QCE_CE_SHARED,
3861 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
3862 .hw_key_support = QCE_HW_KEY_SUPPORT,
3863 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08003864 /* Bus Scaling declaration*/
3865 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003866};
3867
3868static struct platform_device qcrypto_device = {
3869 .name = "qcrypto",
3870 .id = 0,
3871 .num_resources = ARRAY_SIZE(qcrypto_resources),
3872 .resource = qcrypto_resources,
3873 .dev = {
3874 .coherent_dma_mask = DMA_BIT_MASK(32),
3875 .platform_data = &qcrypto_ce_hw_suppport,
3876 },
3877};
3878#endif
3879
3880#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3881 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3882
3883static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
3884 .ce_shared = QCE_CE_SHARED,
3885 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
3886 .hw_key_support = QCE_HW_KEY_SUPPORT,
3887 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08003888 /* Bus Scaling declaration*/
3889 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003890};
3891static struct platform_device qcedev_device = {
3892 .name = "qce",
3893 .id = 0,
3894 .num_resources = ARRAY_SIZE(qcedev_resources),
3895 .resource = qcedev_resources,
3896 .dev = {
3897 .coherent_dma_mask = DMA_BIT_MASK(32),
3898 .platform_data = &qcedev_ce_hw_suppport,
3899 },
3900};
3901#endif
3902
3903static int mddi_toshiba_pmic_bl(int level)
3904{
3905 int ret = -EPERM;
3906
3907 ret = pmic_set_led_intensity(LED_LCD, level);
3908
3909 if (ret)
3910 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
3911 __func__);
3912 return ret;
3913}
3914
3915static struct msm_panel_common_pdata mddi_toshiba_pdata = {
3916 .pmic_backlight = mddi_toshiba_pmic_bl,
3917};
3918
3919static struct platform_device mddi_toshiba_device = {
3920 .name = "mddi_toshiba",
3921 .id = 0,
3922 .dev = {
3923 .platform_data = &mddi_toshiba_pdata,
3924 }
3925};
3926
3927static unsigned wega_reset_gpio =
3928 GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3929
3930static struct msm_gpio fluid_vee_reset_gpio[] = {
3931 { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
3932};
3933
3934static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1;
3935static unsigned char quickvx_ldo_enabled;
3936
3937static unsigned quickvx_vlp_gpio =
3938 GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3939
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303940static struct pm8xxx_gpio_init_info pmic_quickvx_clk_gpio = {
3941 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_QUICKVX_CLK),
3942 {
3943 .direction = PM_GPIO_DIR_OUT,
3944 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3945 .output_value = 1,
3946 .pull = PM_GPIO_PULL_NO,
3947 .vin_sel = PM8058_GPIO_VIN_S3,
3948 .out_strength = PM_GPIO_STRENGTH_HIGH,
3949 .function = PM_GPIO_FUNC_2,
3950 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003951};
3952
Justin Paupore3f40f342011-08-10 18:52:16 -07003953static struct regulator *mddi_ldo20;
3954static struct regulator *mddi_ldo12;
3955static struct regulator *mddi_ldo16;
3956static struct regulator *mddi_ldo6;
3957static struct regulator *mddi_lcd;
3958
3959static int display_common_init(void)
3960{
3961 struct regulator_bulk_data regs[5] = {
3962 { .supply = "ldo20", /* voltage set in display_common_power */},
3963 { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 },
3964 { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 },
3965 { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 },
3966 { .supply = NULL, /* mddi_lcd, initialized below */ },
3967 };
3968
3969 int rc = 0;
3970
3971 if (machine_is_msm7x30_fluid()) {
3972 /* lcd: LDO8 @1.8V */
3973 regs[4].supply = "ldo8";
3974 regs[4].min_uV = 1800000;
3975 regs[4].max_uV = 1800000;
3976 } else {
3977 /* lcd: LDO15 @3.1V */
3978 regs[4].supply = "ldo15";
3979 regs[4].min_uV = 3100000;
3980 regs[4].max_uV = 3100000;
3981 }
3982
3983 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
3984 if (rc) {
3985 pr_err("%s: regulator_bulk_get failed: %d\n",
3986 __func__, rc);
3987 goto bail;
3988 }
3989
3990 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
3991 if (rc) {
3992 pr_err("%s: regulator_bulk_set_voltage failed: %d\n",
3993 __func__, rc);
3994 goto put_regs;
3995 }
3996
3997 mddi_ldo20 = regs[0].consumer;
3998 mddi_ldo12 = regs[1].consumer;
3999 mddi_ldo6 = regs[2].consumer;
4000 mddi_ldo16 = regs[3].consumer;
4001 mddi_lcd = regs[4].consumer;
4002
4003 return rc;
4004
4005put_regs:
4006 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4007bail:
4008 return rc;
4009}
4010
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004011static int display_common_power(int on)
4012{
4013 int rc = 0, flag_on = !!on;
4014 static int display_common_power_save_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004015 static bool display_regs_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004016
4017 if (display_common_power_save_on == flag_on)
4018 return 0;
4019
4020 display_common_power_save_on = flag_on;
4021
Justin Paupore3f40f342011-08-10 18:52:16 -07004022 if (unlikely(!display_regs_initialized)) {
4023 rc = display_common_init();
4024 if (rc) {
4025 pr_err("%s: regulator init failed: %d\n",
4026 __func__, rc);
4027 return rc;
4028 }
4029 display_regs_initialized = true;
4030 }
4031
4032
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004033 if (on) {
4034 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
4035 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
4036 if (rc) {
4037 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4038 __func__, wega_reset_gpio, rc);
4039 return rc;
4040 }
4041
4042 /* bring reset line low to hold reset*/
4043 gpio_set_value(180, 0);
4044
4045 if (quickvx_mddi_client) {
4046 /* QuickVX chip -- VLP pin -- gpio 97 */
4047 rc = gpio_tlmm_config(quickvx_vlp_gpio,
4048 GPIO_CFG_ENABLE);
4049 if (rc) {
4050 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4051 __func__, quickvx_vlp_gpio, rc);
4052 return rc;
4053 }
4054
4055 /* bring QuickVX VLP line low */
4056 gpio_set_value(97, 0);
4057
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304058 rc = pm8xxx_gpio_config(pmic_quickvx_clk_gpio.gpio,
4059 &pmic_quickvx_clk_gpio.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004060 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304061 pr_err("%s: pm8xxx_gpio_config(%#x)=%d\n",
4062 __func__, pmic_quickvx_clk_gpio.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004063 rc);
4064 return rc;
4065 }
4066
4067 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4068 PMIC_GPIO_QUICKVX_CLK), 0);
4069 }
4070 }
4071
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004072 if (quickvx_mddi_client)
Justin Paupore3f40f342011-08-10 18:52:16 -07004073 rc = regulator_set_voltage(mddi_ldo20, 1800000, 1800000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004074 else
Justin Paupore3f40f342011-08-10 18:52:16 -07004075 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000);
4076
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004077 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004078 pr_err("%s: could not set voltage for ldo20: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004079 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07004080 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004081 }
4082
4083 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004084 rc = regulator_enable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004085 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004086 pr_err("%s: LDO20 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004087 __func__, rc);
4088 return rc;
4089 }
4090
Justin Paupore3f40f342011-08-10 18:52:16 -07004091 rc = regulator_enable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004092 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004093 pr_err("%s: LDO12 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004094 __func__, rc);
4095 return rc;
4096 }
4097
4098 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004099 rc = regulator_enable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004100 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004101 pr_err("%s: LDO16 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004102 __func__, rc);
4103 return rc;
4104 }
4105 }
4106
Justin Paupore3f40f342011-08-10 18:52:16 -07004107 if (quickvx_ldo_enabled) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004108 /* Disable LDO6 during display ON */
Justin Paupore3f40f342011-08-10 18:52:16 -07004109 rc = regulator_disable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004110 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004111 pr_err("%s: LDO6 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004112 __func__, rc);
4113 return rc;
4114 }
4115 quickvx_ldo_enabled = 0;
4116 }
4117
Justin Paupore3f40f342011-08-10 18:52:16 -07004118 rc = regulator_enable(mddi_lcd);
4119 if (rc) {
4120 pr_err("%s: LCD regulator enable failed (%d)\n",
4121 __func__, rc);
4122 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004123 }
4124
4125 mdelay(5); /* ensure power is stable */
4126
4127 if (machine_is_msm7x30_fluid()) {
4128 rc = msm_gpios_request_enable(fluid_vee_reset_gpio,
4129 ARRAY_SIZE(fluid_vee_reset_gpio));
4130 if (rc)
4131 pr_err("%s gpio_request_enable failed rc=%d\n",
4132 __func__, rc);
4133 else {
4134 /* assert vee reset_n */
4135 gpio_set_value(20, 1);
4136 gpio_set_value(20, 0);
4137 mdelay(1);
4138 gpio_set_value(20, 1);
4139 }
4140 }
4141
4142 gpio_set_value(180, 1); /* bring reset line high */
4143 mdelay(10); /* 10 msec before IO can be accessed */
4144
4145 if (quickvx_mddi_client) {
4146 gpio_set_value(97, 1);
4147 msleep(2);
4148 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4149 PMIC_GPIO_QUICKVX_CLK), 1);
4150 msleep(2);
4151 }
4152
4153 rc = pmapp_display_clock_config(1);
4154 if (rc) {
4155 pr_err("%s pmapp_display_clock_config rc=%d\n",
4156 __func__, rc);
4157 return rc;
4158 }
4159
4160 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004161 rc = regulator_disable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004162 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004163 pr_err("%s: LDO20 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004164 __func__, rc);
4165 return rc;
4166 }
4167
4168
4169 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004170 rc = regulator_disable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004171 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004172 pr_err("%s: LDO16 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004173 __func__, rc);
4174 return rc;
4175 }
4176 }
4177
4178 if (quickvx_mddi_client && !quickvx_ldo_enabled) {
4179 /* Enable LDO6 during display OFF for
4180 Quicklogic chip to sleep with data retention */
Justin Paupore3f40f342011-08-10 18:52:16 -07004181 rc = regulator_enable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004182 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004183 pr_err("%s: LDO6 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004184 __func__, rc);
4185 return rc;
4186 }
4187 quickvx_ldo_enabled = 1;
4188 }
4189
4190 gpio_set_value(180, 0); /* bring reset line low */
4191
4192 if (quickvx_mddi_client) {
4193 gpio_set_value(97, 0);
4194 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4195 PMIC_GPIO_QUICKVX_CLK), 0);
4196 }
4197
Justin Paupore3f40f342011-08-10 18:52:16 -07004198 rc = regulator_disable(mddi_lcd);
4199 if (rc) {
4200 pr_err("%s: LCD regulator disable failed (%d)\n",
4201 __func__, rc);
4202 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004203 }
4204
4205 mdelay(5); /* ensure power is stable */
4206
Justin Paupore3f40f342011-08-10 18:52:16 -07004207 rc = regulator_disable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004208 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004209 pr_err("%s: LDO12 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004210 __func__, rc);
4211 return rc;
4212 }
4213
4214 if (machine_is_msm7x30_fluid()) {
4215 msm_gpios_disable_free(fluid_vee_reset_gpio,
4216 ARRAY_SIZE(fluid_vee_reset_gpio));
4217 }
4218
4219 rc = pmapp_display_clock_config(0);
4220 if (rc) {
4221 pr_err("%s pmapp_display_clock_config rc=%d\n",
4222 __func__, rc);
4223 return rc;
4224 }
4225 }
4226
4227 return rc;
4228}
4229
4230static int msm_fb_mddi_sel_clk(u32 *clk_rate)
4231{
4232 *clk_rate *= 2;
4233 return 0;
4234}
4235
4236static int msm_fb_mddi_client_power(u32 client_id)
4237{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004238 printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
4239 /* Check if it is Quicklogic client */
4240 if (client_id == 0xc5835800) {
4241 printk(KERN_NOTICE "\n Quicklogic MDDI client");
4242 other_mddi_client = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004243 } else {
4244 printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
4245 quickvx_mddi_client = 0;
4246 gpio_set_value(97, 0);
4247 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4248 PMIC_GPIO_QUICKVX_CLK), 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004249 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004250
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004251 return 0;
4252}
4253
4254static struct mddi_platform_data mddi_pdata = {
4255 .mddi_power_save = display_common_power,
4256 .mddi_sel_clk = msm_fb_mddi_sel_clk,
4257 .mddi_client_power = msm_fb_mddi_client_power,
4258};
4259
4260int mdp_core_clk_rate_table[] = {
4261 122880000,
4262 122880000,
Pradeep Jilagam3cc12f92011-07-26 22:25:18 +05304263 192000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004264 192000000,
4265};
4266
4267static struct msm_panel_common_pdata mdp_pdata = {
4268 .hw_revision_addr = 0xac001270,
4269 .gpio = 30,
4270 .mdp_core_clk_rate = 122880000,
4271 .mdp_core_clk_table = mdp_core_clk_rate_table,
4272 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07004273 .mdp_rev = MDP_REV_40,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004274};
4275
4276static int lcd_panel_spi_gpio_num[] = {
4277 45, /* spi_clk */
4278 46, /* spi_cs */
4279 47, /* spi_mosi */
4280 48, /* spi_miso */
4281 };
4282
4283static struct msm_gpio lcd_panel_gpios[] = {
4284/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
4285 * input. if there is a hardware revision; we should reassign this GPIO to a
4286 * new open line; and removing it will just ensure that this will be missed in
4287 * the future.
4288 { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
4289 */
4290 { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
4291 { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
4292 { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
4293 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4294 { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
4295 { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
4296 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4297#ifndef CONFIG_SPI_QSD
4298 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
4299 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
4300 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
4301 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
4302#endif
4303 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4304 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4305 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4306 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4307 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4308 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4309 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4310 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4311 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4312 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4313 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4314 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4315 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4316 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4317 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4318 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4319 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4320 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4321 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4322 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4323};
4324
4325static struct msm_gpio lcd_sharp_panel_gpios[] = {
4326 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4327 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4328 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4329 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4330 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4331 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4332 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4333 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4334 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4335 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4336 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4337 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4338 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4339 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4340 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4341 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4342 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4343 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4344 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4345 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4346 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4347 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4348};
4349
4350static int lcdc_toshiba_panel_power(int on)
4351{
4352 int rc, i;
4353 struct msm_gpio *gp;
4354
4355 rc = display_common_power(on);
4356 if (rc < 0) {
4357 printk(KERN_ERR "%s display_common_power failed: %d\n",
4358 __func__, rc);
4359 return rc;
4360 }
4361
4362 if (on) {
4363 rc = msm_gpios_enable(lcd_panel_gpios,
4364 ARRAY_SIZE(lcd_panel_gpios));
4365 if (rc < 0) {
4366 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4367 __func__, rc);
4368 }
4369 } else { /* off */
4370 gp = lcd_panel_gpios;
4371 for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
4372 /* ouput low */
4373 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4374 gp++;
4375 }
4376 }
4377
4378 return rc;
4379}
4380
4381static int lcdc_sharp_panel_power(int on)
4382{
4383 int rc, i;
4384 struct msm_gpio *gp;
4385
4386 rc = display_common_power(on);
4387 if (rc < 0) {
4388 printk(KERN_ERR "%s display_common_power failed: %d\n",
4389 __func__, rc);
4390 return rc;
4391 }
4392
4393 if (on) {
4394 rc = msm_gpios_enable(lcd_sharp_panel_gpios,
4395 ARRAY_SIZE(lcd_sharp_panel_gpios));
4396 if (rc < 0) {
4397 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4398 __func__, rc);
4399 }
4400 } else { /* off */
4401 gp = lcd_sharp_panel_gpios;
4402 for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) {
4403 /* ouput low */
4404 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4405 gp++;
4406 }
4407 }
4408
4409 return rc;
4410}
4411
4412static int lcdc_panel_power(int on)
4413{
4414 int flag_on = !!on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004415 static int lcdc_power_save_on, lcdc_power_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004416
4417 if (lcdc_power_save_on == flag_on)
4418 return 0;
4419
4420 lcdc_power_save_on = flag_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004421
4422 if (unlikely(!lcdc_power_initialized)) {
4423 quickvx_mddi_client = 0;
4424 display_common_init();
4425 lcdc_power_initialized = 1;
4426 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004427
4428 if (machine_is_msm7x30_fluid())
4429 return lcdc_sharp_panel_power(on);
4430 else
4431 return lcdc_toshiba_panel_power(on);
4432}
4433
4434static struct lcdc_platform_data lcdc_pdata = {
4435 .lcdc_power_save = lcdc_panel_power,
4436};
4437
Justin Paupore3f40f342011-08-10 18:52:16 -07004438static struct regulator *atv_s4, *atv_ldo9;
4439
4440static int __init atv_dac_power_init(void)
4441{
4442 int rc;
4443 struct regulator_bulk_data regs[] = {
4444 { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 },
4445 { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 },
4446 };
4447
4448 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4449
4450 if (rc) {
4451 pr_err("%s: could not get regulators: %d\n", __func__, rc);
4452 goto bail;
4453 }
4454
4455 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4456
4457 if (rc) {
4458 pr_err("%s: could not set voltages: %d\n", __func__, rc);
4459 goto reg_free;
4460 }
4461
4462 atv_s4 = regs[0].consumer;
4463 atv_ldo9 = regs[1].consumer;
4464
4465reg_free:
4466 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4467bail:
4468 return rc;
4469}
4470
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004471static int atv_dac_power(int on)
4472{
4473 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004474
4475 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004476 rc = regulator_enable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004477 if (rc) {
4478 pr_err("%s: s4 vreg enable failed (%d)\n",
4479 __func__, rc);
4480 return rc;
4481 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004482 rc = regulator_enable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004483 if (rc) {
4484 pr_err("%s: ldo9 vreg enable failed (%d)\n",
4485 __func__, rc);
4486 return rc;
4487 }
4488 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004489 rc = regulator_disable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004490 if (rc) {
4491 pr_err("%s: ldo9 vreg disable failed (%d)\n",
4492 __func__, rc);
4493 return rc;
4494 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004495 rc = regulator_disable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004496 if (rc) {
4497 pr_err("%s: s4 vreg disable failed (%d)\n",
4498 __func__, rc);
4499 return rc;
4500 }
4501 }
4502 return rc;
4503}
4504
4505static struct tvenc_platform_data atv_pdata = {
4506 .poll = 1,
4507 .pm_vid_en = atv_dac_power,
4508};
4509
4510static void __init msm_fb_add_devices(void)
4511{
4512 msm_fb_register_device("mdp", &mdp_pdata);
4513 msm_fb_register_device("pmdh", &mddi_pdata);
4514 msm_fb_register_device("lcdc", &lcdc_pdata);
4515 msm_fb_register_device("dtv", &dtv_pdata);
4516 msm_fb_register_device("tvenc", &atv_pdata);
4517#ifdef CONFIG_FB_MSM_TVOUT
4518 msm_fb_register_device("tvout_device", NULL);
4519#endif
4520}
4521
4522static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
4523 .gpio_num = lcd_panel_spi_gpio_num,
4524};
4525
4526static struct platform_device lcdc_toshiba_panel_device = {
4527 .name = "lcdc_toshiba_wvga",
4528 .id = 0,
4529 .dev = {
4530 .platform_data = &lcdc_toshiba_panel_data,
4531 }
4532};
4533
4534#if defined(CONFIG_MARIMBA_CORE) && \
4535 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4536static struct platform_device msm_bt_power_device = {
4537 .name = "bt_power",
4538 .id = -1
4539};
4540
4541enum {
4542 BT_RFR,
4543 BT_CTS,
4544 BT_RX,
4545 BT_TX,
4546};
4547
4548static struct msm_gpio bt_config_power_on[] = {
4549 { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4550 "UART1DM_RFR" },
4551 { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4552 "UART1DM_CTS" },
4553 { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4554 "UART1DM_Rx" },
4555 { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4556 "UART1DM_Tx" }
4557};
4558
4559static struct msm_gpio bt_config_power_off[] = {
4560 { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4561 "UART1DM_RFR" },
4562 { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4563 "UART1DM_CTS" },
4564 { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4565 "UART1DM_Rx" },
4566 { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4567 "UART1DM_Tx" }
4568};
4569
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004570static u8 bahama_version;
4571
Justin Paupore3f40f342011-08-10 18:52:16 -07004572static struct regulator_bulk_data regs_bt_marimba[] = {
4573 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4574 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
4575 { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304576 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004577};
4578
4579static struct regulator_bulk_data regs_bt_bahama_v1[] = {
4580 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4581 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
4582 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304583 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004584};
4585
4586static struct regulator_bulk_data regs_bt_bahama_v2[] = {
4587 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4588 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304589 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004590};
4591
4592static struct regulator_bulk_data *regs_bt;
4593static int regs_bt_count;
4594
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004595static int marimba_bt(int on)
4596{
4597 int rc;
4598 int i;
4599 struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
4600
4601 struct marimba_config_register {
4602 u8 reg;
4603 u8 value;
4604 u8 mask;
4605 };
4606
4607 struct marimba_variant_register {
4608 const size_t size;
4609 const struct marimba_config_register *set;
4610 };
4611
4612 const struct marimba_config_register *p;
4613
4614 u8 version;
4615
4616 const struct marimba_config_register v10_bt_on[] = {
4617 { 0xE5, 0x0B, 0x0F },
4618 { 0x05, 0x02, 0x07 },
4619 { 0x06, 0x88, 0xFF },
4620 { 0xE7, 0x21, 0x21 },
4621 { 0xE3, 0x38, 0xFF },
4622 { 0xE4, 0x06, 0xFF },
4623 };
4624
4625 const struct marimba_config_register v10_bt_off[] = {
4626 { 0xE5, 0x0B, 0x0F },
4627 { 0x05, 0x08, 0x0F },
4628 { 0x06, 0x88, 0xFF },
4629 { 0xE7, 0x00, 0x21 },
4630 { 0xE3, 0x00, 0xFF },
4631 { 0xE4, 0x00, 0xFF },
4632 };
4633
4634 const struct marimba_config_register v201_bt_on[] = {
4635 { 0x05, 0x08, 0x07 },
4636 { 0x06, 0x88, 0xFF },
4637 { 0xE7, 0x21, 0x21 },
4638 { 0xE3, 0x38, 0xFF },
4639 { 0xE4, 0x06, 0xFF },
4640 };
4641
4642 const struct marimba_config_register v201_bt_off[] = {
4643 { 0x05, 0x08, 0x07 },
4644 { 0x06, 0x88, 0xFF },
4645 { 0xE7, 0x00, 0x21 },
4646 { 0xE3, 0x00, 0xFF },
4647 { 0xE4, 0x00, 0xFF },
4648 };
4649
4650 const struct marimba_config_register v210_bt_on[] = {
4651 { 0xE9, 0x01, 0x01 },
4652 { 0x06, 0x88, 0xFF },
4653 { 0xE7, 0x21, 0x21 },
4654 { 0xE3, 0x38, 0xFF },
4655 { 0xE4, 0x06, 0xFF },
4656 };
4657
4658 const struct marimba_config_register v210_bt_off[] = {
4659 { 0x06, 0x88, 0xFF },
4660 { 0xE7, 0x00, 0x21 },
4661 { 0xE9, 0x00, 0x01 },
4662 { 0xE3, 0x00, 0xFF },
4663 { 0xE4, 0x00, 0xFF },
4664 };
4665
4666 const struct marimba_variant_register bt_marimba[2][4] = {
4667 {
4668 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4669 { 0, NULL },
4670 { ARRAY_SIZE(v201_bt_off), v201_bt_off },
4671 { ARRAY_SIZE(v210_bt_off), v210_bt_off }
4672 },
4673 {
4674 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4675 { 0, NULL },
4676 { ARRAY_SIZE(v201_bt_on), v201_bt_on },
4677 { ARRAY_SIZE(v210_bt_on), v210_bt_on }
4678 }
4679 };
4680
4681 on = on ? 1 : 0;
4682
4683 rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F);
4684 if (rc < 0) {
4685 printk(KERN_ERR
4686 "%s: version read failed: %d\n",
4687 __func__, rc);
4688 return rc;
4689 }
4690
4691 if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
4692 (bt_marimba[on][version].size == 0)) {
4693 printk(KERN_ERR
4694 "%s: unsupported version\n",
4695 __func__);
4696 return -EIO;
4697 }
4698
4699 p = bt_marimba[on][version].set;
4700
4701 printk(KERN_INFO "%s: found version %d\n", __func__, version);
4702
4703 for (i = 0; i < bt_marimba[on][version].size; i++) {
4704 u8 value = (p+i)->value;
4705 rc = marimba_write_bit_mask(&config,
4706 (p+i)->reg,
4707 &value,
4708 sizeof((p+i)->value),
4709 (p+i)->mask);
4710 if (rc < 0) {
4711 printk(KERN_ERR
4712 "%s: reg %d write failed: %d\n",
4713 __func__, (p+i)->reg, rc);
4714 return rc;
4715 }
4716 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
4717 __func__, (p+i)->reg,
4718 value, (p+i)->mask);
4719 }
4720 return 0;
4721}
4722
4723static int bahama_bt(int on)
4724{
4725 int rc;
4726 int i;
4727 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
4728
4729 struct bahama_variant_register {
4730 const size_t size;
4731 const struct bahama_config_register *set;
4732 };
4733
4734 const struct bahama_config_register *p;
4735
4736
4737 const struct bahama_config_register v10_bt_on[] = {
4738 { 0xE9, 0x00, 0xFF },
4739 { 0xF4, 0x80, 0xFF },
4740 { 0xF0, 0x06, 0xFF },
4741 { 0xE4, 0x00, 0xFF },
4742 { 0xE5, 0x00, 0x0F },
4743#ifdef CONFIG_WLAN
4744 { 0xE6, 0x38, 0x7F },
4745 { 0xE7, 0x06, 0xFF },
4746#endif
4747 { 0x11, 0x13, 0xFF },
4748 { 0xE9, 0x21, 0xFF },
4749 { 0x01, 0x0C, 0x1F },
4750 { 0x01, 0x08, 0x1F },
4751 };
4752
4753 const struct bahama_config_register v20_bt_on_fm_off[] = {
4754 { 0x11, 0x0C, 0xFF },
4755 { 0x13, 0x01, 0xFF },
4756 { 0xF4, 0x80, 0xFF },
4757 { 0xF0, 0x00, 0xFF },
4758 { 0xE9, 0x00, 0xFF },
4759#ifdef CONFIG_WLAN
4760 { 0x81, 0x00, 0xFF },
4761 { 0x82, 0x00, 0xFF },
4762 { 0xE6, 0x38, 0x7F },
4763 { 0xE7, 0x06, 0xFF },
4764#endif
4765 { 0xE9, 0x21, 0xFF }
4766 };
4767
4768 const struct bahama_config_register v20_bt_on_fm_on[] = {
4769 { 0x11, 0x0C, 0xFF },
4770 { 0x13, 0x01, 0xFF },
4771 { 0xF4, 0x86, 0xFF },
4772 { 0xF0, 0x06, 0xFF },
4773 { 0xE9, 0x00, 0xFF },
4774#ifdef CONFIG_WLAN
4775 { 0x81, 0x00, 0xFF },
4776 { 0x82, 0x00, 0xFF },
4777 { 0xE6, 0x38, 0x7F },
4778 { 0xE7, 0x06, 0xFF },
4779#endif
4780 { 0xE9, 0x21, 0xFF }
4781 };
4782
4783 const struct bahama_config_register v10_bt_off[] = {
4784 { 0xE9, 0x00, 0xFF },
4785 };
4786
4787 const struct bahama_config_register v20_bt_off_fm_off[] = {
4788 { 0xF4, 0x84, 0xFF },
4789 { 0xF0, 0x04, 0xFF },
4790 { 0xE9, 0x00, 0xFF }
4791 };
4792
4793 const struct bahama_config_register v20_bt_off_fm_on[] = {
4794 { 0xF4, 0x86, 0xFF },
4795 { 0xF0, 0x06, 0xFF },
4796 { 0xE9, 0x00, 0xFF }
4797 };
4798
4799 const struct bahama_variant_register bt_bahama[2][3] = {
4800 {
4801 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4802 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
4803 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
4804 },
4805 {
4806 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4807 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
4808 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
4809 }
4810 };
4811
4812 u8 offset = 0; /* index into bahama configs */
4813
4814 on = on ? 1 : 0;
4815
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004816
4817 if (bahama_version == VER_2_0) {
4818 if (marimba_get_fm_status(&config))
4819 offset = 0x01;
4820 }
4821
4822 p = bt_bahama[on][bahama_version + offset].set;
4823
4824 dev_info(&msm_bt_power_device.dev,
4825 "%s: found version %d\n", __func__, bahama_version);
4826
4827 for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
4828 u8 value = (p+i)->value;
4829 rc = marimba_write_bit_mask(&config,
4830 (p+i)->reg,
4831 &value,
4832 sizeof((p+i)->value),
4833 (p+i)->mask);
4834 if (rc < 0) {
4835 dev_err(&msm_bt_power_device.dev,
4836 "%s: reg %d write failed: %d\n",
4837 __func__, (p+i)->reg, rc);
4838 return rc;
4839 }
4840 dev_info(&msm_bt_power_device.dev,
4841 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
4842 __func__, (p+i)->reg,
4843 value, (p+i)->mask);
4844 }
4845 /* Update BT status */
4846 if (on)
4847 marimba_set_bt_status(&config, true);
4848 else
4849 marimba_set_bt_status(&config, false);
4850
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004851 return 0;
4852}
4853
Justin Paupore3f40f342011-08-10 18:52:16 -07004854static int bluetooth_regs_init(int bahama_not_marimba)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004855{
Justin Paupore3f40f342011-08-10 18:52:16 -07004856 int rc = 0;
4857 struct device *const dev = &msm_bt_power_device.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004858
4859 if (bahama_not_marimba) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004860 bahama_version = read_bahama_ver();
4861
4862 switch (bahama_version) {
4863 case VER_1_0:
4864 regs_bt = regs_bt_bahama_v1;
4865 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1);
4866 break;
4867 case VER_2_0:
4868 regs_bt = regs_bt_bahama_v2;
4869 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2);
4870 break;
4871 case VER_UNSUPPORTED:
4872 default:
4873 dev_err(dev,
4874 "%s: i2c failure or unsupported version: %d\n",
4875 __func__, bahama_version);
4876 rc = -EIO;
4877 goto out;
4878 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004879 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004880 regs_bt = regs_bt_marimba;
4881 regs_bt_count = ARRAY_SIZE(regs_bt_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004882 }
4883
Justin Paupore3f40f342011-08-10 18:52:16 -07004884 rc = regulator_bulk_get(&msm_bt_power_device.dev,
4885 regs_bt_count, regs_bt);
4886 if (rc) {
4887 dev_err(dev, "%s: could not get regulators: %d\n",
4888 __func__, rc);
4889 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004890 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004891
4892 rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt);
4893 if (rc) {
4894 dev_err(dev, "%s: could not set voltages: %d\n",
4895 __func__, rc);
4896 goto reg_free;
4897 }
4898
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004899 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07004900
4901reg_free:
4902 regulator_bulk_free(regs_bt_count, regs_bt);
4903out:
4904 regs_bt_count = 0;
4905 regs_bt = NULL;
4906 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004907}
4908
4909static int bluetooth_power(int on)
4910{
4911 int rc;
4912 const char *id = "BTPW";
4913
4914 int bahama_not_marimba = bahama_present();
4915
4916 if (bahama_not_marimba == -1) {
4917 printk(KERN_WARNING "%s: bahama_present: %d\n",
4918 __func__, bahama_not_marimba);
4919 return -ENODEV;
4920 }
4921
Justin Paupore3f40f342011-08-10 18:52:16 -07004922 if (unlikely(regs_bt_count == 0)) {
4923 rc = bluetooth_regs_init(bahama_not_marimba);
4924 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004925 return rc;
Justin Paupore3f40f342011-08-10 18:52:16 -07004926 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004927
Justin Paupore3f40f342011-08-10 18:52:16 -07004928 if (on) {
4929 rc = regulator_bulk_enable(regs_bt_count, regs_bt);
4930 if (rc)
4931 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004932
4933 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
4934 PMAPP_CLOCK_VOTE_ON);
4935 if (rc < 0)
4936 return -EIO;
4937
4938 if (machine_is_msm8x55_svlte_surf() ||
4939 machine_is_msm8x55_svlte_ffa()) {
4940 rc = marimba_gpio_config(1);
4941 if (rc < 0)
4942 return -EIO;
4943 }
4944
4945 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
4946 if (rc < 0)
4947 return -EIO;
4948
4949 msleep(10);
4950
4951 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
4952 PMAPP_CLOCK_VOTE_PIN_CTRL);
4953 if (rc < 0)
4954 return -EIO;
4955
4956 if (machine_is_msm8x55_svlte_surf() ||
4957 machine_is_msm8x55_svlte_ffa()) {
4958 rc = marimba_gpio_config(0);
4959 if (rc < 0)
4960 return -EIO;
4961 }
4962
4963 rc = msm_gpios_enable(bt_config_power_on,
4964 ARRAY_SIZE(bt_config_power_on));
4965
4966 if (rc < 0)
4967 return rc;
4968
4969 } else {
4970 rc = msm_gpios_enable(bt_config_power_off,
4971 ARRAY_SIZE(bt_config_power_off));
4972 if (rc < 0)
4973 return rc;
4974
4975 /* check for initial RFKILL block (power off) */
4976 if (platform_get_drvdata(&msm_bt_power_device) == NULL)
4977 goto out;
4978
4979 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
4980 if (rc < 0)
4981 return -EIO;
4982
4983 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
4984 PMAPP_CLOCK_VOTE_OFF);
4985 if (rc < 0)
4986 return -EIO;
4987
Justin Paupore3f40f342011-08-10 18:52:16 -07004988 rc = regulator_bulk_disable(regs_bt_count, regs_bt);
4989 if (rc)
4990 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004991
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004992 }
4993
4994out:
4995 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
4996
4997 return 0;
4998}
4999
5000static void __init bt_power_init(void)
5001{
Justin Paupore3f40f342011-08-10 18:52:16 -07005002 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005003}
5004#else
5005#define bt_power_init(x) do {} while (0)
5006#endif
5007
5008static struct msm_psy_batt_pdata msm_psy_batt_data = {
5009 .voltage_min_design = 2800,
5010 .voltage_max_design = 4300,
5011 .avail_chg_sources = AC_CHG | USB_CHG ,
5012 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
5013};
5014
5015static struct platform_device msm_batt_device = {
5016 .name = "msm-battery",
5017 .id = -1,
5018 .dev.platform_data = &msm_psy_batt_data,
5019};
5020
5021static char *msm_adc_fluid_device_names[] = {
5022 "LTC_ADC1",
5023 "LTC_ADC2",
5024 "LTC_ADC3",
5025};
5026
5027static char *msm_adc_surf_device_names[] = {
5028 "XO_ADC",
5029};
5030
5031static struct msm_adc_platform_data msm_adc_pdata;
5032
5033static struct platform_device msm_adc_device = {
5034 .name = "msm_adc",
5035 .id = -1,
5036 .dev = {
5037 .platform_data = &msm_adc_pdata,
5038 },
5039};
5040
5041#ifdef CONFIG_MSM_SDIO_AL
5042static struct msm_gpio mdm2ap_status = {
5043 GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5044 "mdm2ap_status"
5045};
5046
5047
5048static int configure_mdm2ap_status(int on)
5049{
5050 if (on)
5051 return msm_gpios_request_enable(&mdm2ap_status, 1);
5052 else {
5053 msm_gpios_disable_free(&mdm2ap_status, 1);
5054 return 0;
5055 }
5056}
5057
5058static int get_mdm2ap_status(void)
5059{
5060 return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
5061}
5062
5063static struct sdio_al_platform_data sdio_al_pdata = {
5064 .config_mdm2ap_status = configure_mdm2ap_status,
5065 .get_mdm2ap_status = get_mdm2ap_status,
5066 .allow_sdioc_version_major_2 = 1,
5067 .peer_sdioc_version_minor = 0x0001,
5068 .peer_sdioc_version_major = 0x0003,
5069 .peer_sdioc_boot_version_minor = 0x0001,
5070 .peer_sdioc_boot_version_major = 0x0003,
5071};
5072
5073struct platform_device msm_device_sdio_al = {
5074 .name = "msm_sdio_al",
5075 .id = -1,
5076 .dev = {
5077 .platform_data = &sdio_al_pdata,
5078 },
5079};
5080
5081#endif /* CONFIG_MSM_SDIO_AL */
5082
Daniel Walker8d747cd2010-02-25 11:37:43 -08005083static struct platform_device *devices[] __initdata = {
Daniel Walker90e37c52010-05-12 14:24:15 -07005084#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005085 &msm_device_uart2,
5086#endif
Justin Paupore637a25d2011-07-14 17:11:04 -07005087#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
5088 &msm_proccomm_regulator_dev,
5089#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005090 &asoc_msm_pcm,
5091 &asoc_msm_dai0,
5092 &asoc_msm_dai1,
5093#if defined (CONFIG_SND_MSM_MVS_DAI_SOC)
5094 &asoc_msm_mvs,
5095 &asoc_mvs_dai0,
5096 &asoc_mvs_dai1,
Daniel Walker90e37c52010-05-12 14:24:15 -07005097#endif
Niranjana Vishwanathapuraa8855e92010-10-06 13:52:10 -07005098 &msm_device_smd,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005099 &msm_device_dmov,
5100 &smc91x_device,
5101 &smsc911x_device,
5102 &msm_device_nand,
5103#ifdef CONFIG_USB_MSM_OTG_72K
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05305104 &msm_device_otg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005105#ifdef CONFIG_USB_GADGET
5106 &msm_device_gadget_peripheral,
5107#endif
5108#endif
5109#ifdef CONFIG_USB_G_ANDROID
5110 &android_usb_device,
5111#endif
5112 &qsd_device_spi,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305113
5114#ifdef CONFIG_MSM_SSBI
5115 &msm_device_ssbi_pmic1,
5116#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005117#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005118 &msm_device_ssbi7,
5119#endif
5120 &android_pmem_device,
5121 &msm_fb_device,
5122 &msm_migrate_pages_device,
5123 &mddi_toshiba_device,
5124 &lcdc_toshiba_panel_device,
5125#ifdef CONFIG_MSM_ROTATOR
5126 &msm_rotator_device,
5127#endif
5128 &lcdc_sharp_panel_device,
5129 &android_pmem_adsp_device,
5130 &android_pmem_audio_device,
5131 &msm_device_i2c,
5132 &msm_device_i2c_2,
5133 &msm_device_uart_dm1,
5134 &hs_device,
5135#ifdef CONFIG_MSM7KV2_AUDIO
5136 &msm_aictl_device,
5137 &msm_mi2s_device,
5138 &msm_lpa_device,
5139 &msm_aux_pcm_device,
5140#endif
5141 &msm_device_adspdec,
5142 &qup_device_i2c,
5143#if defined(CONFIG_MARIMBA_CORE) && \
5144 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5145 &msm_bt_power_device,
5146#endif
5147 &msm_kgsl_3d0,
5148 &msm_kgsl_2d0,
5149#ifdef CONFIG_MT9T013
5150 &msm_camera_sensor_mt9t013,
5151#endif
5152#ifdef CONFIG_MT9D112
5153 &msm_camera_sensor_mt9d112,
5154#endif
5155#ifdef CONFIG_WEBCAM_OV9726
5156 &msm_camera_sensor_ov9726,
5157#endif
5158#ifdef CONFIG_S5K3E2FX
5159 &msm_camera_sensor_s5k3e2fx,
5160#endif
5161#ifdef CONFIG_MT9P012
5162 &msm_camera_sensor_mt9p012,
5163#endif
5164#ifdef CONFIG_MT9E013
5165 &msm_camera_sensor_mt9e013,
5166#endif
5167#ifdef CONFIG_VX6953
5168 &msm_camera_sensor_vx6953,
5169#endif
5170#ifdef CONFIG_SN12M0PZ
5171 &msm_camera_sensor_sn12m0pz,
5172#endif
5173 &msm_device_vidc_720p,
5174#ifdef CONFIG_MSM_GEMINI
5175 &msm_gemini_device,
5176#endif
5177#ifdef CONFIG_MSM_VPE
5178 &msm_vpe_device,
5179#endif
5180#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5181 &msm_device_tsif,
5182#endif
5183#ifdef CONFIG_MSM_SDIO_AL
5184 &msm_device_sdio_al,
5185#endif
5186
5187#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5188 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5189 &qcrypto_device,
5190#endif
5191
5192#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5193 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5194 &qcedev_device,
5195#endif
5196
5197 &msm_batt_device,
5198 &msm_adc_device,
5199 &msm_ebi0_thermal,
5200 &msm_ebi1_thermal
5201};
5202
5203static struct msm_gpio msm_i2c_gpios_hw[] = {
5204 { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5205 { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5206};
5207
5208static struct msm_gpio msm_i2c_gpios_io[] = {
5209 { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5210 { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5211};
5212
5213static struct msm_gpio qup_i2c_gpios_io[] = {
5214 { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5215 { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5216};
5217static struct msm_gpio qup_i2c_gpios_hw[] = {
5218 { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5219 { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5220};
5221
5222static void
5223msm_i2c_gpio_config(int adap_id, int config_type)
5224{
5225 struct msm_gpio *msm_i2c_table;
5226
5227 /* Each adapter gets 2 lines from the table */
5228 if (adap_id > 0)
5229 return;
5230 if (config_type)
5231 msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
5232 else
5233 msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
5234 msm_gpios_enable(msm_i2c_table, 2);
5235}
5236/*This needs to be enabled only for OEMS*/
5237#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005238static struct regulator *qup_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005239#endif
5240static void
5241qup_i2c_gpio_config(int adap_id, int config_type)
5242{
5243 int rc = 0;
5244 struct msm_gpio *qup_i2c_table;
5245 /* Each adapter gets 2 lines from the table */
5246 if (adap_id != 4)
5247 return;
5248 if (config_type)
5249 qup_i2c_table = qup_i2c_gpios_hw;
5250 else
5251 qup_i2c_table = qup_i2c_gpios_io;
5252 rc = msm_gpios_enable(qup_i2c_table, 2);
5253 if (rc < 0)
5254 printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
5255 /*This needs to be enabled only for OEMS*/
5256#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005257 if (!IS_ERR_OR_NULL(qup_vreg)) {
5258 rc = regulator_enable(qup_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005259 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005260 pr_err("%s: regulator_enable failed: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005261 __func__, rc);
5262 }
5263 }
5264#endif
5265}
5266
5267static struct msm_i2c_platform_data msm_i2c_pdata = {
5268 .clk_freq = 100000,
5269 .pri_clk = 70,
5270 .pri_dat = 71,
5271 .rmutex = 1,
5272 .rsl_id = "D:I2C02000021",
5273 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5274};
5275
5276static void __init msm_device_i2c_init(void)
5277{
5278 if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
5279 pr_err("failed to request I2C gpios\n");
5280
5281 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
5282}
5283
5284static struct msm_i2c_platform_data msm_i2c_2_pdata = {
5285 .clk_freq = 100000,
5286 .rmutex = 1,
5287 .rsl_id = "D:I2C02000022",
5288 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5289};
5290
5291static void __init msm_device_i2c_2_init(void)
5292{
5293 msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
5294}
5295
5296static struct msm_i2c_platform_data qup_i2c_pdata = {
5297 .clk_freq = 384000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005298 .msm_i2c_config_gpio = qup_i2c_gpio_config,
5299};
5300
5301static void __init qup_device_i2c_init(void)
5302{
5303 if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
5304 pr_err("failed to request I2C gpios\n");
5305
5306 qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
5307 /*This needs to be enabled only for OEMS*/
5308#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005309 qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005310 if (IS_ERR(qup_vreg)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005311 dev_err(&qup_device_i2c.dev,
5312 "%s: regulator_get failed: %ld\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005313 __func__, PTR_ERR(qup_vreg));
5314 }
5315#endif
5316}
5317
5318#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005319static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = {
5320 .rsl_id = "D:CODEC_SSBI",
5321 .controller_type = MSM_SBI_CTRL_SSBI,
5322};
5323#endif
5324
Daniel Walker8d747cd2010-02-25 11:37:43 -08005325static void __init msm7x30_init_irq(void)
5326{
5327 msm_init_irq();
5328}
5329
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005330static struct msm_gpio msm_nand_ebi2_cfg_data[] = {
5331 {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
5332 {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
5333};
5334
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005335#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
5336 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
5337 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
5338 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
5339
5340struct sdcc_gpio {
5341 struct msm_gpio *cfg_data;
5342 uint32_t size;
5343 struct msm_gpio *sleep_cfg_data;
5344};
5345#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5346static struct msm_gpio sdc1_lvlshft_cfg_data[] = {
5347 {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
5348};
5349#endif
5350static struct msm_gpio sdc1_cfg_data[] = {
5351 {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
5352 {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
5353 {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
5354 {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
5355 {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
5356 {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
5357};
5358
5359static struct msm_gpio sdc2_cfg_data[] = {
5360 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
5361 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
5362 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
5363 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
5364 {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
5365 {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
5366
5367#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5368 {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
5369 {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
5370 {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
5371 {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
5372#endif
5373};
5374
5375static struct msm_gpio sdc3_cfg_data[] = {
5376 {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
5377 {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
5378 {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
5379 {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
5380 {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
5381 {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
5382};
5383
5384static struct msm_gpio sdc3_sleep_cfg_data[] = {
5385 {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5386 "sdc3_clk"},
5387 {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5388 "sdc3_cmd"},
5389 {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5390 "sdc3_dat_3"},
5391 {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5392 "sdc3_dat_2"},
5393 {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5394 "sdc3_dat_1"},
5395 {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5396 "sdc3_dat_0"},
5397};
5398
5399static struct msm_gpio sdc4_cfg_data[] = {
5400 {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
5401 {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
5402 {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
5403 {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
5404 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
5405 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
5406};
5407
5408static struct sdcc_gpio sdcc_cfg_data[] = {
5409 {
5410 .cfg_data = sdc1_cfg_data,
5411 .size = ARRAY_SIZE(sdc1_cfg_data),
5412 .sleep_cfg_data = NULL,
5413 },
5414 {
5415 .cfg_data = sdc2_cfg_data,
5416 .size = ARRAY_SIZE(sdc2_cfg_data),
5417 .sleep_cfg_data = NULL,
5418 },
5419 {
5420 .cfg_data = sdc3_cfg_data,
5421 .size = ARRAY_SIZE(sdc3_cfg_data),
5422 .sleep_cfg_data = sdc3_sleep_cfg_data,
5423 },
5424 {
5425 .cfg_data = sdc4_cfg_data,
5426 .size = ARRAY_SIZE(sdc4_cfg_data),
5427 .sleep_cfg_data = NULL,
5428 },
5429};
5430
Justin Paupore3f40f342011-08-10 18:52:16 -07005431static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005432
5433static unsigned long vreg_sts, gpio_sts;
5434
5435static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
5436{
5437 int rc = 0;
5438 struct sdcc_gpio *curr;
5439
5440 curr = &sdcc_cfg_data[dev_id - 1];
5441
5442 if (!(test_bit(dev_id, &gpio_sts)^enable))
5443 return rc;
5444
5445 if (enable) {
5446 set_bit(dev_id, &gpio_sts);
5447 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
5448 if (rc)
5449 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
5450 __func__, dev_id);
5451 } else {
5452 clear_bit(dev_id, &gpio_sts);
5453 if (curr->sleep_cfg_data) {
5454 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
5455 msm_gpios_free(curr->sleep_cfg_data, curr->size);
5456 } else {
5457 msm_gpios_disable_free(curr->cfg_data, curr->size);
5458 }
5459 }
5460
5461 return rc;
5462}
5463
5464static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
5465{
5466 int rc = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005467 struct regulator *curr = sdcc_vreg_data[dev_id - 1];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005468 static int enabled_once[] = {0, 0, 0, 0};
5469
Justin Paupore3f40f342011-08-10 18:52:16 -07005470 if (test_bit(dev_id, &vreg_sts) == enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005471 return rc;
5472
5473 if (!enable || enabled_once[dev_id - 1])
5474 return 0;
5475
Justin Paupore3f40f342011-08-10 18:52:16 -07005476 if (!curr)
5477 return -ENODEV;
5478
5479 if (IS_ERR(curr))
5480 return PTR_ERR(curr);
5481
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005482 if (enable) {
5483 set_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005484
5485 rc = regulator_enable(curr);
5486 if (rc)
5487 pr_err("%s: could not enable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005488 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005489 enabled_once[dev_id - 1] = 1;
5490 } else {
5491 clear_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005492
5493 rc = regulator_disable(curr);
5494 if (rc)
5495 pr_err("%s: could not disable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005496 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005497 }
5498 return rc;
5499}
5500
5501static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
5502{
5503 int rc = 0;
5504 struct platform_device *pdev;
5505
5506 pdev = container_of(dv, struct platform_device, dev);
5507 rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
5508 if (rc)
5509 goto out;
5510
5511 if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
5512 rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
5513out:
5514 return rc;
5515}
5516
5517#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \
5518 defined(CONFIG_CSDIO_VENDOR_ID) && \
5519 defined(CONFIG_CSDIO_DEVICE_ID) && \
5520 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5521
5522#define MBP_ON 1
5523#define MBP_OFF 0
5524
5525#define MBP_RESET_N \
5526 GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
5527#define MBP_INT0 \
5528 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
5529
5530#define MBP_MODE_CTRL_0 \
5531 GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5532#define MBP_MODE_CTRL_1 \
5533 GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5534#define MBP_MODE_CTRL_2 \
5535 GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5536#define TSIF_EN \
5537 GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5538#define TSIF_DATA \
5539 GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5540#define TSIF_CLK \
5541 GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5542
5543static struct msm_gpio mbp_cfg_data[] = {
5544 {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5545 "mbp_reset"},
5546 {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5547 "mbp_io_voltage"},
5548};
5549
5550static int mbp_config_gpios_pre_init(int enable)
5551{
5552 int rc = 0;
5553
5554 if (enable) {
5555 rc = msm_gpios_request_enable(mbp_cfg_data,
5556 ARRAY_SIZE(mbp_cfg_data));
5557 if (rc) {
5558 printk(KERN_ERR
5559 "%s: Failed to turnon GPIOs for mbp chip(%d)\n",
5560 __func__, rc);
5561 }
5562 } else
5563 msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
5564 return rc;
5565}
5566
Justin Paupore3f40f342011-08-10 18:52:16 -07005567static struct regulator_bulk_data mbp_regs_io[2];
5568static struct regulator_bulk_data mbp_regs_rf[2];
5569static struct regulator_bulk_data mbp_regs_adc[1];
5570static struct regulator_bulk_data mbp_regs_core[1];
5571
5572static int mbp_init_regs(struct device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005573{
Justin Paupore3f40f342011-08-10 18:52:16 -07005574 struct regulator_bulk_data regs[] = {
5575 /* Analog and I/O regs */
5576 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
5577 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
5578 /* RF regs */
5579 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
5580 { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 },
5581 /* ADC regs */
5582 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
5583 /* Core regs */
5584 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
5585 };
5586
5587 struct regulator_bulk_data *regptr = regs;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005588 int rc;
5589
Justin Paupore3f40f342011-08-10 18:52:16 -07005590 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs);
5591
5592 if (rc) {
5593 dev_err(dev, "%s: could not get regulators: %d\n",
5594 __func__, rc);
5595 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005596 }
5597
Justin Paupore3f40f342011-08-10 18:52:16 -07005598 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005599
Justin Paupore3f40f342011-08-10 18:52:16 -07005600 if (rc) {
5601 dev_err(dev, "%s: could not set voltages: %d\n",
5602 __func__, rc);
5603 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005604 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005605
5606 memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io));
5607 regptr += ARRAY_SIZE(mbp_regs_io);
5608
5609 memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf));
5610 regptr += ARRAY_SIZE(mbp_regs_rf);
5611
5612 memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc));
5613 regptr += ARRAY_SIZE(mbp_regs_adc);
5614
5615 memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core));
5616
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005617 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005618
5619reg_free:
5620 regulator_bulk_free(ARRAY_SIZE(regs), regs);
5621out:
5622 return rc;
5623}
5624
5625static int mbp_setup_rf_vregs(int state)
5626{
5627 return state ?
5628 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) :
5629 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005630}
5631
5632static int mbp_setup_vregs(int state)
5633{
Justin Paupore3f40f342011-08-10 18:52:16 -07005634 return state ?
5635 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) :
5636 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005637}
5638
5639static int mbp_set_tcxo_en(int enable)
5640{
5641 int rc;
5642 const char *id = "UBMC";
5643 struct vreg *vreg_analog = NULL;
5644
5645 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
5646 enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
5647 if (rc < 0) {
5648 printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
5649 __func__, enable ? "" : "de-");
5650 return -EIO;
5651 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005652 return rc;
5653}
5654
5655static void mbp_set_freeze_io(int state)
5656{
5657 if (state)
5658 gpio_set_value(85, 0);
5659 else
5660 gpio_set_value(85, 1);
5661}
5662
5663static int mbp_set_core_voltage_en(int enable)
5664{
Justin Paupore3f40f342011-08-10 18:52:16 -07005665 static bool is_enabled;
5666 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005667
Justin Paupore3f40f342011-08-10 18:52:16 -07005668 if (enable && !is_enabled) {
5669 rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core),
5670 mbp_regs_core);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005671 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005672 pr_err("%s: could not enable regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005673 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07005674 } else {
5675 is_enabled = true;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005676 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005677 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005678
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005679 return rc;
5680}
5681
5682static void mbp_set_reset(int state)
5683{
5684 if (state)
5685 gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
5686 else
5687 gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
5688}
5689
5690static int mbp_config_interface_mode(int state)
5691{
5692 if (state) {
5693 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
5694 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
5695 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
5696 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
5697 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
5698 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
5699 } else {
5700 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
5701 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
5702 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
5703 }
5704 return 0;
5705}
5706
5707static int mbp_setup_adc_vregs(int state)
5708{
Justin Paupore3f40f342011-08-10 18:52:16 -07005709 return state ?
5710 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) :
5711 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005712}
5713
5714static int mbp_power_up(void)
5715{
5716 int rc;
5717
5718 rc = mbp_config_gpios_pre_init(MBP_ON);
5719 if (rc)
5720 goto exit;
5721 pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__);
5722
5723 rc = mbp_setup_vregs(MBP_ON);
5724 if (rc)
5725 goto exit;
5726 pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
5727
5728 rc = mbp_set_tcxo_en(MBP_ON);
5729 if (rc)
5730 goto exit;
5731 pr_debug("%s: tcxo clock done\n", __func__);
5732
5733 mbp_set_freeze_io(MBP_OFF);
5734 pr_debug("%s: set gpio 85 to 1 done\n", __func__);
5735
5736 udelay(100);
5737 mbp_set_reset(MBP_ON);
5738
5739 udelay(300);
5740 rc = mbp_config_interface_mode(MBP_ON);
5741 if (rc)
5742 goto exit;
5743 pr_debug("%s: mbp_config_interface_mode() done\n", __func__);
5744
5745 udelay(100 + mbp_set_core_voltage_en(MBP_ON));
5746 pr_debug("%s: power gp16 1.2V done\n", __func__);
5747
5748 mbp_set_freeze_io(MBP_ON);
5749 pr_debug("%s: set gpio 85 to 0 done\n", __func__);
5750
5751 udelay(100);
5752
5753 rc = mbp_setup_rf_vregs(MBP_ON);
5754 if (rc)
5755 goto exit;
5756 pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
5757
5758 rc = mbp_setup_adc_vregs(MBP_ON);
5759 if (rc)
5760 goto exit;
5761 pr_debug("%s: s4 2.2V done\n", __func__);
5762
5763 udelay(200);
5764
5765 mbp_set_reset(MBP_OFF);
5766 pr_debug("%s: close gpio 44 done\n", __func__);
5767
5768 msleep(20);
5769exit:
5770 return rc;
5771}
5772
5773static int mbp_power_down(void)
5774{
5775 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005776
5777 mbp_set_reset(MBP_ON);
5778 pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
5779
5780 udelay(100);
5781
5782 rc = mbp_setup_adc_vregs(MBP_OFF);
5783 if (rc)
5784 goto exit;
5785 pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
5786
5787 udelay(5);
5788
5789 rc = mbp_setup_rf_vregs(MBP_OFF);
5790 if (rc)
5791 goto exit;
5792 pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
5793
5794 udelay(5);
5795
5796 mbp_set_freeze_io(MBP_OFF);
5797 pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
5798
5799 udelay(100);
5800 rc = mbp_set_core_voltage_en(MBP_OFF);
5801 if (rc)
5802 goto exit;
5803 pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
5804
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005805 rc = mbp_set_tcxo_en(MBP_OFF);
5806 if (rc)
5807 goto exit;
5808 pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
5809
Justin Paupore3f40f342011-08-10 18:52:16 -07005810 rc = mbp_setup_vregs(MBP_OFF);
5811 if (rc)
5812 goto exit;
5813 pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__);
5814
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005815 rc = mbp_config_gpios_pre_init(MBP_OFF);
5816 if (rc)
5817 goto exit;
5818exit:
5819 return rc;
5820}
5821
5822static void (*mbp_status_notify_cb)(int card_present, void *dev_id);
5823static void *mbp_status_notify_cb_devid;
5824static int mbp_power_status;
5825static int mbp_power_init_done;
5826
5827static uint32_t mbp_setup_power(struct device *dv,
5828 unsigned int power_status)
5829{
5830 int rc = 0;
5831 struct platform_device *pdev;
5832
5833 pdev = container_of(dv, struct platform_device, dev);
5834
5835 if (power_status == mbp_power_status)
5836 goto exit;
5837 if (power_status) {
5838 pr_debug("turn on power of mbp slot");
5839 rc = mbp_power_up();
5840 mbp_power_status = 1;
5841 } else {
5842 pr_debug("turn off power of mbp slot");
5843 rc = mbp_power_down();
5844 mbp_power_status = 0;
5845 }
5846exit:
5847 return rc;
5848};
5849
5850int mbp_register_status_notify(void (*callback)(int, void *),
5851 void *dev_id)
5852{
5853 mbp_status_notify_cb = callback;
5854 mbp_status_notify_cb_devid = dev_id;
5855 return 0;
5856}
5857
5858static unsigned int mbp_status(struct device *dev)
5859{
5860 return mbp_power_status;
5861}
5862
5863static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd)
5864{
5865 struct platform_device *pdev;
5866 uint32_t rc = 0;
5867
5868 pdev = container_of(dv, struct platform_device, dev);
5869 rc = msm_sdcc_setup_power(dv, vdd);
5870 if (rc) {
5871 pr_err("%s: Failed to setup power (%d)\n",
5872 __func__, rc);
5873 goto out;
5874 }
5875 if (!mbp_power_init_done) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005876 rc = mbp_init_regs(dv);
5877 if (rc) {
5878 dev_err(dv, "%s: regulator init failed: %d\n",
5879 __func__, rc);
5880 goto out;
5881 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005882 mbp_setup_power(dv, 1);
5883 mbp_setup_power(dv, 0);
5884 mbp_power_init_done = 1;
5885 }
5886 if (vdd >= 0x8000) {
5887 rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
5888 if (rc) {
5889 pr_err("%s: Failed to config mbp chip power (%d)\n",
5890 __func__, rc);
5891 goto out;
5892 }
5893 if (mbp_status_notify_cb) {
5894 mbp_status_notify_cb(mbp_power_status,
5895 mbp_status_notify_cb_devid);
5896 }
5897 }
5898out:
5899 /* should return 0 only */
5900 return 0;
5901}
5902
5903#endif
5904
5905#endif
5906
5907#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
5908#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5909static unsigned int msm7x30_sdcc_slot_status(struct device *dev)
5910{
5911 return (unsigned int)
5912 gpio_get_value_cansleep(
5913 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1));
5914}
5915#endif
5916
5917static int msm_sdcc_get_wpswitch(struct device *dv)
5918{
5919 void __iomem *wp_addr = 0;
5920 uint32_t ret = 0;
5921 struct platform_device *pdev;
5922
5923 if (!(machine_is_msm7x30_surf()))
5924 return -1;
5925 pdev = container_of(dv, struct platform_device, dev);
5926
5927 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
5928 if (!wp_addr) {
5929 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
5930 return -ENOMEM;
5931 }
5932
5933 ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
5934 pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
5935 pdev->id, ret);
5936 iounmap(wp_addr);
5937
5938 return ret;
5939}
5940#endif
5941
5942#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5943#if defined(CONFIG_CSDIO_VENDOR_ID) && \
5944 defined(CONFIG_CSDIO_DEVICE_ID) && \
5945 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5946static struct mmc_platform_data msm7x30_sdc1_data = {
5947 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
5948 .translate_vdd = msm_sdcc_setup_power_mbp,
5949 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
5950 .status = mbp_status,
5951 .register_status_notify = mbp_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005952 .msmsdcc_fmin = 144000,
5953 .msmsdcc_fmid = 24576000,
5954 .msmsdcc_fmax = 24576000,
5955 .nonremovable = 0,
5956};
5957#else
5958static struct mmc_platform_data msm7x30_sdc1_data = {
5959 .ocr_mask = MMC_VDD_165_195,
5960 .translate_vdd = msm_sdcc_setup_power,
5961 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005962 .msmsdcc_fmin = 144000,
5963 .msmsdcc_fmid = 24576000,
5964 .msmsdcc_fmax = 49152000,
5965 .nonremovable = 0,
5966};
5967#endif
5968#endif
5969
5970#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
5971static struct mmc_platform_data msm7x30_sdc2_data = {
5972 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
5973 .translate_vdd = msm_sdcc_setup_power,
5974#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5975 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
5976#else
5977 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
5978#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005979 .msmsdcc_fmin = 144000,
5980 .msmsdcc_fmid = 24576000,
5981 .msmsdcc_fmax = 49152000,
5982 .nonremovable = 1,
5983};
5984#endif
5985
5986#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
5987static struct mmc_platform_data msm7x30_sdc3_data = {
5988 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
5989 .translate_vdd = msm_sdcc_setup_power,
5990 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
5991#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
5992 .sdiowakeup_irq = MSM_GPIO_TO_INT(118),
5993#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005994 .msmsdcc_fmin = 144000,
5995 .msmsdcc_fmid = 24576000,
5996 .msmsdcc_fmax = 49152000,
5997 .nonremovable = 0,
5998};
5999#endif
6000
6001#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6002static struct mmc_platform_data msm7x30_sdc4_data = {
6003 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6004 .translate_vdd = msm_sdcc_setup_power,
6005 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6006#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6007 .status = msm7x30_sdcc_slot_status,
6008 .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
6009 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
6010#endif
6011 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006012 .msmsdcc_fmin = 144000,
6013 .msmsdcc_fmid = 24576000,
6014 .msmsdcc_fmax = 49152000,
6015 .nonremovable = 0,
6016};
6017#endif
6018
6019#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006020static int msm_sdc1_lvlshft_enable(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006021{
Justin Paupore3f40f342011-08-10 18:52:16 -07006022 static struct regulator *ldo5;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006023 int rc;
6024
6025 /* Enable LDO5, an input to the FET that powers slot 1 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006026
Justin Paupore3f40f342011-08-10 18:52:16 -07006027 ldo5 = regulator_get(NULL, "ldo5");
6028
6029 if (IS_ERR(ldo5)) {
6030 rc = PTR_ERR(ldo5);
6031 pr_err("%s: could not get ldo5: %d\n", __func__, rc);
6032 goto out;
6033 }
6034
6035 rc = regulator_set_voltage(ldo5, 2850000, 2850000);
6036 if (rc) {
6037 pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc);
6038 goto ldo5_free;
6039 }
6040
6041 rc = regulator_enable(ldo5);
6042 if (rc) {
6043 pr_err("%s: could not enable ldo5: %d\n", __func__, rc);
6044 goto ldo5_free;
6045 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006046
6047 /* Enable GPIO 35, to turn on the FET that powers slot 1 */
6048 rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
6049 ARRAY_SIZE(sdc1_lvlshft_cfg_data));
6050 if (rc)
6051 printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
6052
6053 rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg),
6054 1);
6055 if (rc)
6056 printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006057
6058 return 0;
6059
6060ldo5_free:
6061 regulator_put(ldo5);
6062out:
6063 ldo5 = NULL;
6064 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006065}
6066#endif
6067
Justin Paupore3f40f342011-08-10 18:52:16 -07006068static int mmc_regulator_init(int sdcc_no, const char *supply, int uV)
6069{
6070 int rc;
6071
6072 BUG_ON(sdcc_no < 1 || sdcc_no > 4);
6073
6074 sdcc_no--;
6075
6076 sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply);
6077
6078 if (IS_ERR(sdcc_vreg_data[sdcc_no])) {
6079 rc = PTR_ERR(sdcc_vreg_data[sdcc_no]);
6080 pr_err("%s: could not get regulator \"%s\": %d\n",
6081 __func__, supply, rc);
6082 goto out;
6083 }
6084
6085 rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV);
6086
6087 if (rc) {
6088 pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n",
6089 __func__, supply, uV, rc);
6090 goto reg_free;
6091 }
6092
6093 return rc;
6094
6095reg_free:
6096 regulator_put(sdcc_vreg_data[sdcc_no]);
6097out:
6098 sdcc_vreg_data[sdcc_no] = NULL;
6099 return rc;
6100}
6101
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006102static void __init msm7x30_init_mmc(void)
6103{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006104#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006105 if (mmc_regulator_init(1, "s3", 1800000))
6106 goto out1;
6107
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006108 if (machine_is_msm7x30_fluid()) {
6109 msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
Justin Paupore3f40f342011-08-10 18:52:16 -07006110 if (msm_sdc1_lvlshft_enable()) {
6111 pr_err("%s: could not enable level shift\n");
6112 goto out1;
6113 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006114 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006115
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006116 msm_add_sdcc(1, &msm7x30_sdc1_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006117out1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006118#endif
6119#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006120 if (mmc_regulator_init(2, "s3", 1800000))
6121 goto out2;
6122
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006123 if (machine_is_msm8x55_svlte_surf())
6124 msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
Sujith Reddy Thumma84a0f512011-08-29 09:57:03 +05306125 if (machine_is_msm8x55_svlte_surf() ||
6126 machine_is_msm8x55_svlte_ffa()) {
6127 msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
6128 msm7x30_sdc2_data.is_sdio_al_client = 1;
6129 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006130
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006131 msm_add_sdcc(2, &msm7x30_sdc2_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006132out2:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006133#endif
6134#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006135 if (mmc_regulator_init(3, "s3", 1800000))
6136 goto out3;
6137
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006138 msm_sdcc_setup_gpio(3, 1);
6139 msm_add_sdcc(3, &msm7x30_sdc3_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006140out3:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006141#endif
6142#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006143 if (mmc_regulator_init(4, "mmc", 2850000))
6144 return;
6145
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006146 msm_add_sdcc(4, &msm7x30_sdc4_data);
6147#endif
6148
6149}
6150
6151static void __init msm7x30_init_nand(void)
6152{
6153 char *build_id;
6154 struct flash_platform_data *plat_data;
6155
6156 build_id = socinfo_get_build_id();
6157 if (build_id == NULL) {
6158 pr_err("%s: Build ID not available from socinfo\n", __func__);
6159 return;
6160 }
6161
6162 if (build_id[8] == 'C' &&
6163 !msm_gpios_request_enable(msm_nand_ebi2_cfg_data,
6164 ARRAY_SIZE(msm_nand_ebi2_cfg_data))) {
6165 plat_data = msm_device_nand.dev.platform_data;
6166 plat_data->interleave = 1;
6167 printk(KERN_INFO "%s: Interleave mode Build ID found\n",
6168 __func__);
6169 }
6170}
6171
6172#ifdef CONFIG_SERIAL_MSM_CONSOLE
6173static struct msm_gpio uart2_config_data[] = {
6174 { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
6175 { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
6176 { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
6177 { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
6178};
6179
6180static void msm7x30_init_uart2(void)
6181{
6182 msm_gpios_request_enable(uart2_config_data,
6183 ARRAY_SIZE(uart2_config_data));
6184
6185}
6186#endif
6187
6188/* TSIF begin */
6189#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6190
6191#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6192#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6193#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6194#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6195
6196static const struct msm_gpio tsif_gpios[] = {
6197 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
6198 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
6199 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
6200 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
6201};
6202
6203static struct msm_tsif_platform_data tsif_platform_data = {
6204 .num_gpios = ARRAY_SIZE(tsif_gpios),
6205 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -07006206 .tsif_pclk = "iface_clk",
6207 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006208};
6209#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
6210/* TSIF end */
6211
6212static void __init pmic8058_leds_init(void)
6213{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306214 if (machine_is_msm7x30_surf())
6215 pm8058_7x30_data.leds_pdata = &pm8058_surf_leds_data;
6216 else if (!machine_is_msm7x30_fluid())
6217 pm8058_7x30_data.leds_pdata = &pm8058_ffa_leds_data;
6218 else if (machine_is_msm7x30_fluid())
6219 pm8058_7x30_data.leds_pdata = &pm8058_fluid_leds_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006220}
6221
6222static struct msm_spm_platform_data msm_spm_data __initdata = {
6223 .reg_base_addr = MSM_SAW_BASE,
6224
6225 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
6226 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
6227 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
6228 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
6229
6230 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
6231 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
6232 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
6233
6234 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
6235 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
6236 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
6237
6238 .awake_vlevel = 0xF2,
6239 .retention_vlevel = 0xE0,
6240 .collapse_vlevel = 0x72,
6241 .retention_mid_vlevel = 0xE0,
6242 .collapse_mid_vlevel = 0xE0,
6243
6244 .vctl_timeout_us = 50,
6245};
6246
6247#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6248 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6249
6250#define TSC2007_TS_PEN_INT 20
6251
6252static struct msm_gpio tsc2007_config_data[] = {
6253 { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
6254 "tsc2007_irq" },
6255};
6256
Justin Paupore3f40f342011-08-10 18:52:16 -07006257static struct regulator_bulk_data tsc2007_regs[] = {
6258 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
6259 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
6260};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006261
6262static int tsc2007_init(void)
6263{
6264 int rc;
6265
Justin Paupore3f40f342011-08-10 18:52:16 -07006266 rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006267
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006268 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006269 pr_err("%s: could not get regulators: %d\n", __func__, rc);
6270 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006271 }
6272
Justin Paupore3f40f342011-08-10 18:52:16 -07006273 rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6274
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006275 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006276 pr_err("%s: could not set voltages: %d\n", __func__, rc);
6277 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006278 }
6279
Justin Paupore3f40f342011-08-10 18:52:16 -07006280 rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006281
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006282 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006283 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
6284 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006285 }
6286
6287 rc = msm_gpios_request_enable(tsc2007_config_data,
6288 ARRAY_SIZE(tsc2007_config_data));
6289 if (rc) {
6290 pr_err("%s: Unable to request gpios\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006291 goto reg_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006292 }
6293
6294 return 0;
6295
Justin Paupore3f40f342011-08-10 18:52:16 -07006296reg_disable:
6297 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6298reg_free:
6299 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6300out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006301 return rc;
6302}
6303
6304static int tsc2007_get_pendown_state(void)
6305{
6306 int rc;
6307
6308 rc = gpio_get_value(TSC2007_TS_PEN_INT);
6309 if (rc < 0) {
6310 pr_err("%s: MSM GPIO %d read failed\n", __func__,
6311 TSC2007_TS_PEN_INT);
6312 return rc;
6313 }
6314
6315 return (rc == 0 ? 1 : 0);
6316}
6317
6318static void tsc2007_exit(void)
6319{
Justin Paupore3f40f342011-08-10 18:52:16 -07006320
6321 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6322 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006323
6324 msm_gpios_disable_free(tsc2007_config_data,
6325 ARRAY_SIZE(tsc2007_config_data));
6326}
6327
6328static int tsc2007_power_shutdown(bool enable)
6329{
6330 int rc;
6331
Justin Paupore3f40f342011-08-10 18:52:16 -07006332 rc = (enable == false) ?
6333 regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) :
6334 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6335
6336 if (rc) {
6337 pr_err("%s: could not %sable regulators: %d\n",
6338 __func__, enable ? "dis" : "en", rc);
6339 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006340 }
6341
Justin Paupore3f40f342011-08-10 18:52:16 -07006342 if (enable == false)
6343 msleep(20);
6344
6345 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006346}
6347
6348static struct tsc2007_platform_data tsc2007_ts_data = {
6349 .model = 2007,
6350 .x_plate_ohms = 300,
6351 .irq_flags = IRQF_TRIGGER_LOW,
6352 .init_platform_hw = tsc2007_init,
6353 .exit_platform_hw = tsc2007_exit,
6354 .power_shutdown = tsc2007_power_shutdown,
6355 .invert_x = true,
6356 .invert_y = true,
6357 /* REVISIT: Temporary fix for reversed pressure */
6358 .invert_z1 = true,
6359 .invert_z2 = true,
6360 .get_pendown_state = tsc2007_get_pendown_state,
6361};
6362
6363static struct i2c_board_info tsc_i2c_board_info[] = {
6364 {
6365 I2C_BOARD_INFO("tsc2007", 0x48),
6366 .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
6367 .platform_data = &tsc2007_ts_data,
6368 },
6369};
6370#endif
6371
Justin Paupore3f40f342011-08-10 18:52:16 -07006372static struct regulator_bulk_data regs_isa1200[] = {
6373 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
6374 { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006375};
6376
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006377static int isa1200_power(int vreg_on)
6378{
Justin Paupore3f40f342011-08-10 18:52:16 -07006379 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006380
Justin Paupore3f40f342011-08-10 18:52:16 -07006381 rc = vreg_on ?
6382 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) :
6383 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006384
Justin Paupore3f40f342011-08-10 18:52:16 -07006385 if (rc) {
6386 pr_err("%s: could not %sable regulators: %d\n",
6387 __func__, vreg_on ? "en" : "dis", rc);
6388 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006389 }
6390
6391 /* vote for DO buffer */
6392 rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO,
6393 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
6394 if (rc) {
6395 pr_err("%s: unable to %svote for d0 clk\n",
6396 __func__, vreg_on ? "" : "de-");
6397 goto vreg_fail;
6398 }
6399
6400 return 0;
6401
6402vreg_fail:
Justin Paupore3f40f342011-08-10 18:52:16 -07006403 if (vreg_on)
6404 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6405 else
6406 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6407out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006408 return rc;
6409}
6410
6411static int isa1200_dev_setup(bool enable)
6412{
Justin Paupore3f40f342011-08-10 18:52:16 -07006413 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006414
6415 if (enable == true) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006416 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200),
6417 regs_isa1200);
6418
6419 if (rc) {
6420 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006421 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006422 goto out;
6423 }
6424
6425 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200),
6426 regs_isa1200);
6427 if (rc) {
6428 pr_err("%s: could not set voltages: %d\n",
6429 __func__, rc);
6430 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006431 }
6432
6433 rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
6434 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
6435 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
6436 if (rc) {
6437 pr_err("%s: Could not configure gpio %d\n",
6438 __func__, HAP_LVL_SHFT_MSM_GPIO);
Justin Paupore3f40f342011-08-10 18:52:16 -07006439 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006440 }
6441
6442 rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
6443 if (rc) {
6444 pr_err("%s: unable to request gpio %d (%d)\n",
6445 __func__, HAP_LVL_SHFT_MSM_GPIO, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006446 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006447 }
6448
6449 gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
6450 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006451 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006452 gpio_free(HAP_LVL_SHFT_MSM_GPIO);
6453 }
6454
6455 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07006456
6457reg_free:
6458 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6459out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006460 return rc;
6461}
6462static struct isa1200_platform_data isa1200_1_pdata = {
6463 .name = "vibrator",
6464 .power_on = isa1200_power,
6465 .dev_setup = isa1200_dev_setup,
6466 .pwm_ch_id = 1, /*channel id*/
6467 /*gpio to enable haptic*/
6468 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka03122322011-09-09 15:15:43 +05306469 .hap_len_gpio = -1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006470 .max_timeout = 15000,
6471 .mode_ctrl = PWM_GEN_MODE,
6472 .pwm_fd = {
6473 .pwm_div = 256,
6474 },
6475 .is_erm = false,
6476 .smart_en = true,
6477 .ext_clk_en = true,
6478 .chip_en = 1,
6479};
6480
6481static struct i2c_board_info msm_isa1200_board_info[] = {
6482 {
6483 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
6484 .platform_data = &isa1200_1_pdata,
6485 },
6486};
6487
6488
6489static int kp_flip_mpp_config(void)
6490{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306491 struct pm8xxx_mpp_config_data kp_flip_mpp = {
6492 .type = PM8XXX_MPP_TYPE_D_INPUT,
6493 .level = PM8018_MPP_DIG_LEVEL_S3,
6494 .control = PM8XXX_MPP_DIN_TO_INT,
6495 };
6496
6497 return pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(PM_FLIP_MPP),
6498 &kp_flip_mpp);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006499}
6500
6501static struct flip_switch_pdata flip_switch_data = {
6502 .name = "kp_flip_switch",
6503 .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP,
6504 .left_key = KEY_OPEN,
6505 .right_key = KEY_CLOSE,
6506 .active_low = 0,
6507 .wakeup = 1,
6508 .flip_mpp_config = kp_flip_mpp_config,
6509};
6510
6511static struct platform_device flip_switch_device = {
6512 .name = "kp_flip_switch",
6513 .id = -1,
6514 .dev = {
6515 .platform_data = &flip_switch_data,
6516 }
6517};
6518
Justin Paupore3f40f342011-08-10 18:52:16 -07006519static struct regulator_bulk_data regs_tma300[] = {
6520 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
6521 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006522};
6523
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006524static int tma300_power(int vreg_on)
6525{
Justin Paupore3f40f342011-08-10 18:52:16 -07006526 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006527
Justin Paupore3f40f342011-08-10 18:52:16 -07006528 rc = vreg_on ?
6529 regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) :
6530 regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006531
Justin Paupore3f40f342011-08-10 18:52:16 -07006532 if (rc)
6533 pr_err("%s: could not %sable regulators: %d\n",
6534 __func__, vreg_on ? "en" : "dis", rc);
6535 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006536}
6537
6538#define TS_GPIO_IRQ 150
6539
6540static int tma300_dev_setup(bool enable)
6541{
Justin Paupore3f40f342011-08-10 18:52:16 -07006542 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006543
6544 if (enable) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006545 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300),
6546 regs_tma300);
6547
6548 if (rc) {
6549 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006550 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006551 goto out;
6552 }
6553
6554 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300),
6555 regs_tma300);
6556
6557 if (rc) {
6558 pr_err("%s: could not set voltages: %d\n",
6559 __func__, rc);
6560 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006561 }
6562
6563 /* enable interrupt gpio */
6564 rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
6565 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
6566 if (rc) {
6567 pr_err("%s: Could not configure gpio %d\n",
6568 __func__, TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -07006569 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006570 }
6571
6572 /* virtual keys */
6573 tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
6574 properties_kobj = kobject_create_and_add("board_properties",
6575 NULL);
6576 if (!properties_kobj) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006577 pr_err("%s: failed to create a kobject "
6578 "for board_properties\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006579 rc = -ENOMEM;
Justin Paupore3f40f342011-08-10 18:52:16 -07006580 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006581 }
6582 rc = sysfs_create_group(properties_kobj,
6583 &tma300_properties_attr_group);
6584 if (rc) {
6585 pr_err("%s: failed to create a sysfs entry %s\n",
6586 __func__, tma300_vkeys_attr.attr.name);
Justin Paupore3f40f342011-08-10 18:52:16 -07006587 goto kobj_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006588 }
6589 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006590 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006591 /* destroy virtual keys */
6592 if (properties_kobj) {
6593 sysfs_remove_group(properties_kobj,
6594 &tma300_properties_attr_group);
6595 kobject_put(properties_kobj);
6596 }
6597 }
6598 return 0;
6599
Justin Paupore3f40f342011-08-10 18:52:16 -07006600kobj_free:
6601 kobject_put(properties_kobj);
6602 properties_kobj = NULL;
6603reg_free:
6604 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
6605out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006606 return rc;
6607}
6608
6609static struct cy8c_ts_platform_data cy8ctma300_pdata = {
6610 .power_on = tma300_power,
6611 .dev_setup = tma300_dev_setup,
6612 .ts_name = "msm_tma300_ts",
6613 .dis_min_x = 0,
6614 .dis_max_x = 479,
6615 .dis_min_y = 0,
6616 .dis_max_y = 799,
6617 .res_x = 479,
6618 .res_y = 1009,
6619 .min_tid = 1,
6620 .max_tid = 255,
6621 .min_touch = 0,
6622 .max_touch = 255,
6623 .min_width = 0,
6624 .max_width = 255,
6625 .invert_y = 1,
6626 .nfingers = 4,
6627 .irq_gpio = TS_GPIO_IRQ,
6628 .resout_gpio = -1,
6629};
6630
6631static struct i2c_board_info cy8ctma300_board_info[] = {
6632 {
6633 I2C_BOARD_INFO("cy8ctma300", 0x2),
6634 .platform_data = &cy8ctma300_pdata,
6635 }
6636};
6637
Daniel Walker8d747cd2010-02-25 11:37:43 -08006638static void __init msm7x30_init(void)
6639{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006640 int rc;
6641 unsigned smem_size;
6642 uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56,
6643 0,
6644 GPIO_CFG_OUTPUT,
6645 GPIO_CFG_NO_PULL,
6646 GPIO_CFG_2MA);
6647 uint32_t soc_version = 0;
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05306648
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006649 soc_version = socinfo_get_version();
6650
Stephen Boydbb600ae2011-08-02 20:11:40 -07006651 msm_clock_init(&msm7x30_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006652#ifdef CONFIG_SERIAL_MSM_CONSOLE
6653 msm7x30_init_uart2();
6654#endif
6655 msm_spm_init(&msm_spm_data, 1);
Matt Wagantallec57f062011-08-16 23:54:46 -07006656 acpuclk_init(&acpuclk_7x30_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006657 if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid())
6658 msm7x30_cfg_smsc911x();
6659
6660#ifdef CONFIG_USB_MSM_OTG_72K
6661 if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 &&
6662 SOCINFO_VERSION_MINOR(soc_version) >= 1) {
6663 pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
6664 msm_otg_pdata.ldo_set_voltage = 0;
6665 }
6666
6667 msm_device_otg.dev.platform_data = &msm_otg_pdata;
6668#ifdef CONFIG_USB_GADGET
6669 msm_otg_pdata.swfi_latency =
6670 msm_pm_data
6671 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
6672 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
6673#endif
6674#endif
6675 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
6676 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
6677#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6678 msm_device_tsif.dev.platform_data = &tsif_platform_data;
6679#endif
6680 if (machine_is_msm7x30_fluid()) {
6681 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
6682 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
6683 } else {
6684 msm_adc_pdata.dev_names = msm_adc_surf_device_names;
6685 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names);
6686 }
6687
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306688 pmic8058_leds_init();
6689
6690 buses_init();
6691
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306692#ifdef CONFIG_MSM_SSBI
6693 msm_device_ssbi_pmic1.dev.platform_data =
6694 &msm7x30_ssbi_pm8058_pdata;
6695#endif
6696
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006697 platform_add_devices(msm_footswitch_devices,
6698 msm_num_footswitch_devices);
Daniel Walker8d747cd2010-02-25 11:37:43 -08006699 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006700#ifdef CONFIG_USB_EHCI_MSM_72K
6701 msm_add_host(0, &msm_usb_host_pdata);
6702#endif
6703 msm7x30_init_mmc();
6704 msm7x30_init_nand();
6705 msm_qsd_spi_init();
6706
6707#ifdef CONFIG_SPI_QSD
6708 if (machine_is_msm7x30_fluid())
6709 spi_register_board_info(lcdc_sharp_spi_board_info,
6710 ARRAY_SIZE(lcdc_sharp_spi_board_info));
6711 else
6712 spi_register_board_info(lcdc_toshiba_spi_board_info,
6713 ARRAY_SIZE(lcdc_toshiba_spi_board_info));
6714#endif
6715
Justin Paupore3f40f342011-08-10 18:52:16 -07006716 atv_dac_power_init();
6717 sensors_ldo_init();
6718 hdmi_init_regs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006719 msm_fb_add_devices();
6720 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06006721 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006722 msm_device_i2c_init();
6723 msm_device_i2c_2_init();
6724 qup_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006725 msm7x30_init_marimba();
6726#ifdef CONFIG_MSM7KV2_AUDIO
6727 snddev_poweramp_gpio_init();
Justin Paupore3f40f342011-08-10 18:52:16 -07006728 snddev_hsed_voltage_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006729 aux_pcm_gpio_init();
6730#endif
6731
6732 i2c_register_board_info(0, msm_i2c_board_info,
6733 ARRAY_SIZE(msm_i2c_board_info));
6734
6735 if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid())
6736 marimba_pdata.tsadc = &marimba_tsadc_pdata;
6737
6738 if (machine_is_msm7x30_fluid())
6739 i2c_register_board_info(0, cy8info,
6740 ARRAY_SIZE(cy8info));
6741#ifdef CONFIG_BOSCH_BMA150
6742 if (machine_is_msm7x30_fluid())
6743 i2c_register_board_info(0, bma150_board_info,
6744 ARRAY_SIZE(bma150_board_info));
6745#endif
6746
6747 i2c_register_board_info(2, msm_marimba_board_info,
6748 ARRAY_SIZE(msm_marimba_board_info));
6749
6750 i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info,
6751 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info));
6752
6753 i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
6754 ARRAY_SIZE(msm_camera_boardinfo));
6755
6756 bt_power_init();
6757#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006758 msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
6759#endif
6760 if (machine_is_msm7x30_fluid())
6761 i2c_register_board_info(0, msm_isa1200_board_info,
6762 ARRAY_SIZE(msm_isa1200_board_info));
6763
6764#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6765 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6766 if (machine_is_msm8x55_svlte_ffa())
6767 i2c_register_board_info(2, tsc_i2c_board_info,
6768 ARRAY_SIZE(tsc_i2c_board_info));
6769#endif
6770
6771 if (machine_is_msm7x30_surf())
6772 platform_device_register(&flip_switch_device);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306773
6774 pm8058_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006775
6776 if (machine_is_msm7x30_fluid()) {
6777 /* Initialize platform data for fluid v2 hardware */
6778 if (SOCINFO_VERSION_MAJOR(
6779 socinfo_get_platform_version()) == 2) {
6780 cy8ctma300_pdata.res_y = 920;
6781 cy8ctma300_pdata.invert_y = 0;
6782 }
6783 i2c_register_board_info(0, cy8ctma300_board_info,
6784 ARRAY_SIZE(cy8ctma300_board_info));
6785 }
6786
6787 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
6788 rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE);
6789 if (rc)
6790 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
6791 __func__, usb_hub_gpio_cfg_value, rc);
6792 }
6793
6794 boot_reason = *(unsigned int *)
6795 (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
6796 printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
6797}
6798
6799static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
6800static int __init pmem_sf_size_setup(char *p)
6801{
6802 pmem_sf_size = memparse(p, NULL);
6803 return 0;
6804}
6805early_param("pmem_sf_size", pmem_sf_size_setup);
6806
6807static unsigned fb_size = MSM_FB_SIZE;
6808static int __init fb_size_setup(char *p)
6809{
6810 fb_size = memparse(p, NULL);
6811 return 0;
6812}
6813early_param("fb_size", fb_size_setup);
6814
6815static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
6816static int __init pmem_adsp_size_setup(char *p)
6817{
6818 pmem_adsp_size = memparse(p, NULL);
6819 return 0;
6820}
6821early_param("pmem_adsp_size", pmem_adsp_size_setup);
6822
6823static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE;
6824static int __init fluid_pmem_adsp_size_setup(char *p)
6825{
6826 fluid_pmem_adsp_size = memparse(p, NULL);
6827 return 0;
6828}
6829early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup);
6830
6831static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
6832static int __init pmem_audio_size_setup(char *p)
6833{
6834 pmem_audio_size = memparse(p, NULL);
6835 return 0;
6836}
6837early_param("pmem_audio_size", pmem_audio_size_setup);
6838
6839static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE;
6840static int __init pmem_kernel_ebi0_size_setup(char *p)
6841{
6842 pmem_kernel_ebi0_size = memparse(p, NULL);
6843 return 0;
6844}
6845early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
6846
6847static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
6848 [MEMTYPE_SMI] = {
6849 },
6850 [MEMTYPE_EBI0] = {
6851 .flags = MEMTYPE_FLAGS_1M_ALIGN,
6852 },
6853 [MEMTYPE_EBI1] = {
6854 .flags = MEMTYPE_FLAGS_1M_ALIGN,
6855 },
6856};
6857
6858static void __init size_pmem_devices(void)
6859{
6860#ifdef CONFIG_ANDROID_PMEM
6861 unsigned long size;
6862
6863 if machine_is_msm7x30_fluid()
6864 size = fluid_pmem_adsp_size;
6865 else
6866 size = pmem_adsp_size;
6867 android_pmem_adsp_pdata.size = size;
6868 android_pmem_audio_pdata.size = pmem_audio_size;
6869 android_pmem_pdata.size = pmem_sf_size;
6870#endif
6871}
6872
6873static void __init reserve_memory_for(struct android_pmem_platform_data *p)
6874{
6875 msm7x30_reserve_table[p->memory_type].size += p->size;
6876}
6877
6878static void __init reserve_pmem_memory(void)
6879{
6880#ifdef CONFIG_ANDROID_PMEM
6881 reserve_memory_for(&android_pmem_adsp_pdata);
6882 reserve_memory_for(&android_pmem_audio_pdata);
6883 reserve_memory_for(&android_pmem_pdata);
6884 msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
6885#endif
6886}
6887
6888static void __init msm7x30_calculate_reserve_sizes(void)
6889{
6890 size_pmem_devices();
6891 reserve_pmem_memory();
6892}
6893
6894static int msm7x30_paddr_to_memtype(unsigned int paddr)
6895{
6896 if (paddr < 0x40000000)
6897 return MEMTYPE_EBI0;
6898 if (paddr >= 0x40000000 && paddr < 0x80000000)
6899 return MEMTYPE_EBI1;
6900 return MEMTYPE_NONE;
6901}
6902
6903static struct reserve_info msm7x30_reserve_info __initdata = {
6904 .memtype_reserve_table = msm7x30_reserve_table,
6905 .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes,
6906 .paddr_to_memtype = msm7x30_paddr_to_memtype,
6907};
6908
6909static void __init msm7x30_reserve(void)
6910{
6911 reserve_info = &msm7x30_reserve_info;
6912 msm_reserve();
6913}
6914
6915static void __init msm7x30_allocate_memory_regions(void)
6916{
6917 void *addr;
6918 unsigned long size;
6919
6920 size = fb_size ? : MSM_FB_SIZE;
6921 addr = alloc_bootmem_align(size, 0x1000);
6922 msm_fb_resources[0].start = __pa(addr);
6923 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
6924 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
6925 size, addr, __pa(addr));
Daniel Walker8d747cd2010-02-25 11:37:43 -08006926}
6927
6928static void __init msm7x30_map_io(void)
6929{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006930 msm_shared_ram_phys = 0x00100000;
Daniel Walker8d747cd2010-02-25 11:37:43 -08006931 msm_map_msm7x30_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07006932 if (socinfo_init() < 0)
6933 printk(KERN_ERR "%s: socinfo_init() failed!\n",
6934 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006935}
6936
6937static void __init msm7x30_init_early(void)
6938{
6939 msm7x30_allocate_memory_regions();
Daniel Walker8d747cd2010-02-25 11:37:43 -08006940}
6941
6942MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00006943 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006944 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006945 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006946 .init_irq = msm7x30_init_irq,
6947 .init_machine = msm7x30_init,
6948 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006949 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05306950 .handle_irq = vic_handle_irq,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006951MACHINE_END
6952
6953MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00006954 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006955 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006956 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006957 .init_irq = msm7x30_init_irq,
6958 .init_machine = msm7x30_init,
6959 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006960 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05306961 .handle_irq = vic_handle_irq,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006962MACHINE_END
6963
6964MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
Russell Kingb75c1782011-01-04 19:03:16 +00006965 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006966 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006967 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006968 .init_irq = msm7x30_init_irq,
6969 .init_machine = msm7x30_init,
6970 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006971 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05306972 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006973MACHINE_END
6974
6975MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
6976 .boot_params = PHYS_OFFSET + 0x100,
6977 .map_io = msm7x30_map_io,
6978 .reserve = msm7x30_reserve,
6979 .init_irq = msm7x30_init_irq,
6980 .init_machine = msm7x30_init,
6981 .timer = &msm_timer,
6982 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05306983 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006984MACHINE_END
6985
6986MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA")
6987 .boot_params = PHYS_OFFSET + 0x100,
6988 .map_io = msm7x30_map_io,
6989 .reserve = msm7x30_reserve,
6990 .init_irq = msm7x30_init_irq,
6991 .init_machine = msm7x30_init,
6992 .timer = &msm_timer,
6993 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05306994 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006995MACHINE_END
6996MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
6997 .boot_params = PHYS_OFFSET + 0x100,
6998 .map_io = msm7x30_map_io,
6999 .reserve = msm7x30_reserve,
7000 .init_irq = msm7x30_init_irq,
7001 .init_machine = msm7x30_init,
7002 .timer = &msm_timer,
7003 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307004 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007005MACHINE_END
7006MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA")
7007 .boot_params = PHYS_OFFSET + 0x100,
7008 .map_io = msm7x30_map_io,
7009 .reserve = msm7x30_reserve,
7010 .init_irq = msm7x30_init_irq,
7011 .init_machine = msm7x30_init,
7012 .timer = &msm_timer,
7013 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307014 .handle_irq = vic_handle_irq,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007015MACHINE_END