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