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