blob: e0b3c49f6c3193d340f7c03fab4471e6e1647bb8 [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
Matt Wagantall7cca4642012-02-01 16:43:24 -080081#include "pm.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -060082#include "pm-boot.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070083#include "spm.h"
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070084#include "acpuclock.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070085#include <mach/dal_axi.h>
86#include <mach/msm_serial_hs.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070087#include <mach/qdsp5v2/mi2s.h>
88#include <mach/qdsp5v2/audio_dev_ctl.h>
89#include <mach/sdio_al.h>
90#include "smd_private.h"
91#include <linux/bma150.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080092
Justin Paupore637a25d2011-07-14 17:11:04 -070093#include "board-msm7x30-regulator.h"
94
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070095#define MSM_PMEM_SF_SIZE 0x1700000
96#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
97#define MSM_FB_SIZE 0x780000
98#else
99#define MSM_FB_SIZE 0x500000
100#endif
101#define MSM_PMEM_ADSP_SIZE 0x1E00000
102#define MSM_FLUID_PMEM_ADSP_SIZE 0x2800000
103#define PMEM_KERNEL_EBI0_SIZE 0x600000
104#define MSM_PMEM_AUDIO_SIZE 0x200000
Daniel Walker90e37c52010-05-12 14:24:15 -0700105
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700106#define PMIC_GPIO_INT 27
107#define PMIC_VREG_WLAN_LEVEL 2900
108#define PMIC_GPIO_SD_DET 36
109#define PMIC_GPIO_SDC4_EN_N 17 /* PMIC GPIO Number 18 */
110#define PMIC_GPIO_HDMI_5V_EN_V3 32 /* PMIC GPIO for V3 H/W */
111#define PMIC_GPIO_HDMI_5V_EN_V2 39 /* PMIC GPIO for V2 H/W */
112
113#define ADV7520_I2C_ADDR 0x39
114
115#define FPGA_SDCC_STATUS 0x8E0001A8
116
117#define FPGA_OPTNAV_GPIO_ADDR 0x8E000026
118#define OPTNAV_I2C_SLAVE_ADDR (0xB0 >> 1)
119#define OPTNAV_IRQ 20
120#define OPTNAV_CHIP_SELECT 19
121
122/* Macros assume PMIC GPIOs start at 0 */
123#define PM8058_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio + NR_GPIO_IRQS)
124#define PM8058_GPIO_SYS_TO_PM(sys_gpio) (sys_gpio - NR_GPIO_IRQS)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530125#define PM8058_MPP_BASE PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS)
126#define PM8058_MPP_PM_TO_SYS(pm_gpio) (pm_gpio + PM8058_MPP_BASE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700127
128#define PMIC_GPIO_FLASH_BOOST_ENABLE 15 /* PMIC GPIO Number 16 */
129#define PMIC_GPIO_HAP_ENABLE 16 /* PMIC GPIO Number 17 */
130
131#define PMIC_GPIO_WLAN_EXT_POR 22 /* PMIC GPIO NUMBER 23 */
132
133#define BMA150_GPIO_INT 1
134
135#define HAP_LVL_SHFT_MSM_GPIO 24
136
137#define PMIC_GPIO_QUICKVX_CLK 37 /* PMIC GPIO 38 */
138
139#define PM_FLIP_MPP 5 /* PMIC MPP 06 */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530140
Pankaj Kumarac69ee62012-01-26 00:21:56 +0530141#define DDR1_BANK_BASE 0X20000000
142#define DDR2_BANK_BASE 0X40000000
143
144static unsigned int phys_add = DDR2_BANK_BASE;
145unsigned long ebi1_phys_offset = DDR2_BANK_BASE;
146EXPORT_SYMBOL(ebi1_phys_offset);
147
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530148struct pm8xxx_gpio_init_info {
149 unsigned gpio;
150 struct pm_gpio config;
151};
152
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700153static int pm8058_gpios_init(void)
154{
155 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700156
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530157 struct pm8xxx_gpio_init_info sdc4_en = {
158 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_EN_N),
159 {
160 .direction = PM_GPIO_DIR_OUT,
161 .pull = PM_GPIO_PULL_NO,
162 .vin_sel = PM8058_GPIO_VIN_L5,
163 .function = PM_GPIO_FUNC_NORMAL,
164 .inv_int_pol = 0,
165 .out_strength = PM_GPIO_STRENGTH_LOW,
166 .output_value = 0,
167 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700168 };
169
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530170 struct pm8xxx_gpio_init_info haptics_enable = {
171 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
172 {
173 .direction = PM_GPIO_DIR_OUT,
174 .pull = PM_GPIO_PULL_NO,
175 .out_strength = PM_GPIO_STRENGTH_HIGH,
176 .function = PM_GPIO_FUNC_NORMAL,
177 .inv_int_pol = 0,
178 .vin_sel = 2,
179 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
180 .output_value = 0,
181 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700182 };
183
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530184 struct pm8xxx_gpio_init_info hdmi_5V_en = {
185 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HDMI_5V_EN_V3),
186 {
187 .direction = PM_GPIO_DIR_OUT,
188 .pull = PM_GPIO_PULL_NO,
189 .vin_sel = PM8058_GPIO_VIN_VPH,
190 .function = PM_GPIO_FUNC_NORMAL,
191 .out_strength = PM_GPIO_STRENGTH_LOW,
192 .output_value = 0,
193 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700194 };
195
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530196 struct pm8xxx_gpio_init_info flash_boost_enable = {
197 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE),
198 {
199 .direction = PM_GPIO_DIR_OUT,
200 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
201 .output_value = 0,
202 .pull = PM_GPIO_PULL_NO,
203 .vin_sel = PM8058_GPIO_VIN_S3,
204 .out_strength = PM_GPIO_STRENGTH_HIGH,
205 .function = PM_GPIO_FUNC_2,
206 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700207 };
208
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530209 struct pm8xxx_gpio_init_info gpio23 = {
210 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_WLAN_EXT_POR),
211 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700212 .direction = PM_GPIO_DIR_OUT,
213 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
214 .output_value = 0,
215 .pull = PM_GPIO_PULL_NO,
216 .vin_sel = 2,
217 .out_strength = PM_GPIO_STRENGTH_LOW,
218 .function = PM_GPIO_FUNC_NORMAL,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530219 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700220 };
221
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700222#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530223 struct pm8xxx_gpio_init_info sdcc_det = {
224 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1),
225 {
226 .direction = PM_GPIO_DIR_IN,
227 .pull = PM_GPIO_PULL_UP_1P5,
228 .vin_sel = 2,
229 .function = PM_GPIO_FUNC_NORMAL,
230 .inv_int_pol = 0,
231 },
232 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700233
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530234 if (machine_is_msm7x30_fluid())
235 sdcc_det.config.inv_int_pol = 1;
236
237 rc = pm8xxx_gpio_config(sdcc_det.gpio, &sdcc_det.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700238 if (rc) {
239 pr_err("%s PMIC_GPIO_SD_DET config failed\n", __func__);
240 return rc;
241 }
242#endif
243
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530244 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
245 machine_is_msm7x30_fluid())
246 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V2;
247 else
248 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V3;
249
250 hdmi_5V_en.gpio = PM8058_GPIO_PM_TO_SYS(hdmi_5V_en.gpio);
251
252 rc = pm8xxx_gpio_config(hdmi_5V_en.gpio, &hdmi_5V_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700253 if (rc) {
254 pr_err("%s PMIC_GPIO_HDMI_5V_EN config failed\n", __func__);
255 return rc;
256 }
257
258 /* Deassert GPIO#23 (source for Ext_POR on WLAN-Volans) */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530259 rc = pm8xxx_gpio_config(gpio23.gpio, &gpio23.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700260 if (rc) {
261 pr_err("%s PMIC_GPIO_WLAN_EXT_POR config failed\n", __func__);
262 return rc;
263 }
264
265 if (machine_is_msm7x30_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530266 /* Haptics gpio */
267 rc = pm8xxx_gpio_config(haptics_enable.gpio,
268 &haptics_enable.config);
269 if (rc) {
270 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
271 haptics_enable.gpio);
272 return rc;
273 }
274 /* Flash boost gpio */
275 rc = pm8xxx_gpio_config(flash_boost_enable.gpio,
276 &flash_boost_enable.config);
277 if (rc) {
278 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
279 flash_boost_enable.gpio);
280 return rc;
281 }
282 /* SCD4 gpio */
283 rc = pm8xxx_gpio_config(sdc4_en.gpio, &sdc4_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700284 if (rc) {
285 pr_err("%s PMIC_GPIO_SDC4_EN_N config failed\n",
286 __func__);
287 return rc;
288 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530289 rc = gpio_request(sdc4_en.gpio, "sdc4_en");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700290 if (rc) {
291 pr_err("%s PMIC_GPIO_SDC4_EN_N gpio_request failed\n",
292 __func__);
293 return rc;
294 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530295 gpio_set_value_cansleep(sdc4_en.gpio, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700296 }
297
298 return 0;
299}
300
Justin Paupore637a25d2011-07-14 17:11:04 -0700301/* Regulator API support */
302
303#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
304static struct platform_device msm_proccomm_regulator_dev = {
305 .name = PROCCOMM_REGULATOR_DEV_NAME,
306 .id = -1,
307 .dev = {
308 .platform_data = &msm7x30_proccomm_regulator_data
309 }
310};
311#endif
312
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700313/*virtual key support */
314static ssize_t tma300_vkeys_show(struct kobject *kobj,
315 struct kobj_attribute *attr, char *buf)
316{
317 return sprintf(buf,
318 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":50:842:80:100"
319 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":170:842:80:100"
320 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":290:842:80:100"
321 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":410:842:80:100"
322 "\n");
323}
324
325static struct kobj_attribute tma300_vkeys_attr = {
326 .attr = {
327 .mode = S_IRUGO,
328 },
329 .show = &tma300_vkeys_show,
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530330};
331
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700332static struct attribute *tma300_properties_attrs[] = {
333 &tma300_vkeys_attr.attr,
334 NULL
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530335};
336
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700337static struct attribute_group tma300_properties_attr_group = {
338 .attrs = tma300_properties_attrs,
339};
340
341static struct kobject *properties_kobj;
Justin Paupore3f40f342011-08-10 18:52:16 -0700342static struct regulator_bulk_data cyttsp_regs[] = {
343 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
344 { .supply = "ldo15", .min_uV = 3050000, .max_uV = 3100000 },
345};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700346
347#define CYTTSP_TS_GPIO_IRQ 150
348static int cyttsp_platform_init(struct i2c_client *client)
349{
350 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700351
Justin Paupore3f40f342011-08-10 18:52:16 -0700352 rc = regulator_bulk_get(NULL, ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700353
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700354 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700355 pr_err("%s: could not get regulators: %d\n", __func__, rc);
356 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700357 }
358
Justin Paupore3f40f342011-08-10 18:52:16 -0700359 rc = regulator_bulk_set_voltage(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
360
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700361 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700362 pr_err("%s: could not set regulator voltages: %d\n", __func__,
363 rc);
364 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700365 }
366
Justin Paupore3f40f342011-08-10 18:52:16 -0700367 rc = regulator_bulk_enable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700368
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700369 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700370 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
371 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700372 }
373
374 /* check this device active by reading first byte/register */
375 rc = i2c_smbus_read_byte_data(client, 0x01);
376 if (rc < 0) {
377 pr_err("%s: i2c sanity check failed\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -0700378 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700379 }
380
381 rc = gpio_tlmm_config(GPIO_CFG(CYTTSP_TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
382 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
383 if (rc) {
384 pr_err("%s: Could not configure gpio %d\n",
385 __func__, CYTTSP_TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -0700386 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700387 }
388
389 /* virtual keys */
390 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
391 properties_kobj = kobject_create_and_add("board_properties",
392 NULL);
393 if (properties_kobj)
394 rc = sysfs_create_group(properties_kobj,
395 &tma300_properties_attr_group);
396 if (!properties_kobj || rc)
397 pr_err("%s: failed to create board_properties\n",
398 __func__);
399
400 return CY_OK;
401
Justin Paupore3f40f342011-08-10 18:52:16 -0700402regs_disable:
403 regulator_bulk_disable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
404regs_free:
405 regulator_bulk_free(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
406out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700407 return rc;
408}
409
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530410/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
411static int cyttsp_platform_suspend(struct i2c_client *client)
412{
413 msleep(20);
414
415 return CY_OK;
416}
417
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700418static int cyttsp_platform_resume(struct i2c_client *client)
419{
420 /* add any special code to strobe a wakeup pin or chip reset */
421 mdelay(10);
422
423 return CY_OK;
424}
425
426static struct cyttsp_platform_data cyttsp_data = {
427 .fw_fname = "cyttsp_7630_fluid.hex",
428 .panel_maxx = 479,
429 .panel_maxy = 799,
430 .disp_maxx = 469,
431 .disp_maxy = 799,
432 .disp_minx = 10,
433 .disp_miny = 0,
434 .flags = 0,
435 .gen = CY_GEN3, /* or */
436 .use_st = CY_USE_ST,
437 .use_mt = CY_USE_MT,
438 .use_hndshk = CY_SEND_HNDSHK,
439 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +0530440 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700441 .use_gestures = CY_USE_GESTURES,
442 /* activate up to 4 groups
443 * and set active distance
444 */
445 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
446 CY_GEST_GRP3 | CY_GEST_GRP4 |
447 CY_ACT_DIST,
448 /* change act_intrvl to customize the Active power state
449 * scanning/processing refresh interval for Operating mode
450 */
451 .act_intrvl = CY_ACT_INTRVL_DFLT,
452 /* change tch_tmout to customize the touch timeout for the
453 * Active power state for Operating mode
454 */
455 .tch_tmout = CY_TCH_TMOUT_DFLT,
456 /* change lp_intrvl to customize the Low Power power state
457 * scanning/processing refresh interval for Operating mode
458 */
459 .lp_intrvl = CY_LP_INTRVL_DFLT,
460 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530461 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700462 .init = cyttsp_platform_init,
463 .sleep_gpio = -1,
464 .resout_gpio = -1,
465 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
Mohan Pallaka49c37d62011-08-01 11:52:00 +0530466 .correct_fw_ver = 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700467};
468
469static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
470{
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530471 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700472 .direction = PM_GPIO_DIR_OUT,
473 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
474 .output_value = 0,
475 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530476 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700477 .out_strength = PM_GPIO_STRENGTH_HIGH,
478 .function = PM_GPIO_FUNC_2,
479 };
480 int rc = -EINVAL;
481 int id, mode, max_mA;
482
483 id = mode = max_mA = 0;
484 switch (ch) {
485 case 0:
486 case 1:
487 case 2:
488 if (on) {
489 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530490 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
491 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700492 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530493 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700494 __func__, id, rc);
495 }
496 break;
497
498 case 3:
499 id = PM_PWM_LED_KPD;
500 mode = PM_PWM_CONF_DTEST3;
501 max_mA = 200;
502 break;
503
504 case 4:
505 id = PM_PWM_LED_0;
506 mode = PM_PWM_CONF_PWM1;
507 max_mA = 40;
508 break;
509
510 case 5:
511 id = PM_PWM_LED_2;
512 mode = PM_PWM_CONF_PWM2;
513 max_mA = 40;
514 break;
515
516 case 6:
517 id = PM_PWM_LED_FLASH;
518 mode = PM_PWM_CONF_DTEST3;
519 max_mA = 200;
520 break;
521
522 default:
523 break;
524 }
525
526 if (ch >= 3 && ch <= 6) {
527 if (!on) {
528 mode = PM_PWM_CONF_NONE;
529 max_mA = 0;
530 }
531 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
532 if (rc)
533 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
534 __func__, ch, rc);
535 }
536
537 return rc;
538}
539
540static int pm8058_pwm_enable(struct pwm_device *pwm, int ch, int on)
541{
542 int rc;
543
544 switch (ch) {
545 case 7:
546 rc = pm8058_pwm_set_dtest(pwm, on);
547 if (rc)
548 pr_err("%s: pwm_set_dtest(%d): rc=%d\n",
549 __func__, on, rc);
550 break;
551 default:
552 rc = -EINVAL;
553 break;
554 }
555 return rc;
556}
557
558static const unsigned int fluid_keymap[] = {
559 KEY(0, 0, KEY_7),
560 KEY(0, 1, KEY_ENTER),
561 KEY(0, 2, KEY_UP),
562 /* drop (0,3) as it always shows up in pair with(0,2) */
563 KEY(0, 4, KEY_DOWN),
564
565 KEY(1, 0, KEY_CAMERA_SNAPSHOT),
566 KEY(1, 1, KEY_SELECT),
567 KEY(1, 2, KEY_1),
568 KEY(1, 3, KEY_VOLUMEUP),
569 KEY(1, 4, KEY_VOLUMEDOWN),
570};
571
572static const unsigned int surf_keymap[] = {
573 KEY(0, 0, KEY_7),
574 KEY(0, 1, KEY_DOWN),
575 KEY(0, 2, KEY_UP),
576 KEY(0, 3, KEY_RIGHT),
577 KEY(0, 4, KEY_ENTER),
578 KEY(0, 5, KEY_L),
579 KEY(0, 6, KEY_BACK),
580 KEY(0, 7, KEY_M),
581
582 KEY(1, 0, KEY_LEFT),
583 KEY(1, 1, KEY_SEND),
584 KEY(1, 2, KEY_1),
585 KEY(1, 3, KEY_4),
586 KEY(1, 4, KEY_CLEAR),
587 KEY(1, 5, KEY_MSDOS),
588 KEY(1, 6, KEY_SPACE),
589 KEY(1, 7, KEY_COMMA),
590
591 KEY(2, 0, KEY_6),
592 KEY(2, 1, KEY_5),
593 KEY(2, 2, KEY_8),
594 KEY(2, 3, KEY_3),
595 KEY(2, 4, KEY_NUMERIC_STAR),
596 KEY(2, 5, KEY_UP),
597 KEY(2, 6, KEY_DOWN), /* SYN */
598 KEY(2, 7, KEY_LEFTSHIFT),
599
600 KEY(3, 0, KEY_9),
601 KEY(3, 1, KEY_NUMERIC_POUND),
602 KEY(3, 2, KEY_0),
603 KEY(3, 3, KEY_2),
604 KEY(3, 4, KEY_SLEEP),
605 KEY(3, 5, KEY_F1),
606 KEY(3, 6, KEY_F2),
607 KEY(3, 7, KEY_F3),
608
609 KEY(4, 0, KEY_BACK),
610 KEY(4, 1, KEY_HOME),
611 KEY(4, 2, KEY_MENU),
612 KEY(4, 3, KEY_VOLUMEUP),
613 KEY(4, 4, KEY_VOLUMEDOWN),
614 KEY(4, 5, KEY_F4),
615 KEY(4, 6, KEY_F5),
616 KEY(4, 7, KEY_F6),
617
618 KEY(5, 0, KEY_R),
619 KEY(5, 1, KEY_T),
620 KEY(5, 2, KEY_Y),
621 KEY(5, 3, KEY_LEFTALT),
622 KEY(5, 4, KEY_KPENTER),
623 KEY(5, 5, KEY_Q),
624 KEY(5, 6, KEY_W),
625 KEY(5, 7, KEY_E),
626
627 KEY(6, 0, KEY_F),
628 KEY(6, 1, KEY_G),
629 KEY(6, 2, KEY_H),
630 KEY(6, 3, KEY_CAPSLOCK),
631 KEY(6, 4, KEY_PAGEUP),
632 KEY(6, 5, KEY_A),
633 KEY(6, 6, KEY_S),
634 KEY(6, 7, KEY_D),
635
636 KEY(7, 0, KEY_V),
637 KEY(7, 1, KEY_B),
638 KEY(7, 2, KEY_N),
639 KEY(7, 3, KEY_MENU), /* REVISIT - SYM */
640 KEY(7, 4, KEY_PAGEDOWN),
641 KEY(7, 5, KEY_Z),
642 KEY(7, 6, KEY_X),
643 KEY(7, 7, KEY_C),
644
645 KEY(8, 0, KEY_P),
646 KEY(8, 1, KEY_J),
647 KEY(8, 2, KEY_K),
648 KEY(8, 3, KEY_INSERT),
649 KEY(8, 4, KEY_LINEFEED),
650 KEY(8, 5, KEY_U),
651 KEY(8, 6, KEY_I),
652 KEY(8, 7, KEY_O),
653
654 KEY(9, 0, KEY_4),
655 KEY(9, 1, KEY_5),
656 KEY(9, 2, KEY_6),
657 KEY(9, 3, KEY_7),
658 KEY(9, 4, KEY_8),
659 KEY(9, 5, KEY_1),
660 KEY(9, 6, KEY_2),
661 KEY(9, 7, KEY_3),
662
663 KEY(10, 0, KEY_F7),
664 KEY(10, 1, KEY_F8),
665 KEY(10, 2, KEY_F9),
666 KEY(10, 3, KEY_F10),
667 KEY(10, 4, KEY_FN),
668 KEY(10, 5, KEY_9),
669 KEY(10, 6, KEY_0),
670 KEY(10, 7, KEY_DOT),
671
672 KEY(11, 0, KEY_LEFTCTRL),
673 KEY(11, 1, KEY_F11), /* START */
674 KEY(11, 2, KEY_ENTER),
675 KEY(11, 3, KEY_SEARCH),
676 KEY(11, 4, KEY_DELETE),
677 KEY(11, 5, KEY_RIGHT),
678 KEY(11, 6, KEY_LEFT),
679 KEY(11, 7, KEY_RIGHTSHIFT),
680};
681
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700682static struct matrix_keymap_data surf_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530683 .keymap_size = ARRAY_SIZE(surf_keymap),
684 .keymap = surf_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700685};
686
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530687static struct pm8xxx_keypad_platform_data surf_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700688 .input_name = "surf_keypad",
689 .input_phys_device = "surf_keypad/input0",
690 .num_rows = 12,
691 .num_cols = 8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530692 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
693 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
694 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700695 .scan_delay_ms = 32,
696 .row_hold_ns = 91500,
697 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530698 .keymap_data = &surf_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700699};
700
701static struct matrix_keymap_data fluid_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530702 .keymap_size = ARRAY_SIZE(fluid_keymap),
703 .keymap = fluid_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700704};
705
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530706static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700707 .input_name = "fluid-keypad",
708 .input_phys_device = "fluid-keypad/input0",
709 .num_rows = 5,
710 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530711 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
712 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
713 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700714 .scan_delay_ms = 32,
715 .row_hold_ns = 91500,
716 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530717 .keymap_data = &fluid_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700718};
719
720static struct pm8058_pwm_pdata pm8058_pwm_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530721 .config = pm8058_pwm_config,
722 .enable = pm8058_pwm_enable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700723};
724
725static struct pmic8058_led pmic8058_ffa_leds[] = {
726 [0] = {
727 .name = "keyboard-backlight",
728 .max_brightness = 15,
729 .id = PMIC8058_ID_LED_KB_LIGHT,
Dima Zavinba5499e2011-01-10 11:00:30 -0800730 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700731};
732
733static struct pmic8058_leds_platform_data pm8058_ffa_leds_data = {
734 .num_leds = ARRAY_SIZE(pmic8058_ffa_leds),
735 .leds = pmic8058_ffa_leds,
736};
737
738static struct pmic8058_led pmic8058_surf_leds[] = {
739 [0] = {
740 .name = "keyboard-backlight",
741 .max_brightness = 15,
742 .id = PMIC8058_ID_LED_KB_LIGHT,
743 },
744 [1] = {
745 .name = "voice:red",
746 .max_brightness = 20,
747 .id = PMIC8058_ID_LED_0,
748 },
749 [2] = {
750 .name = "wlan:green",
751 .max_brightness = 20,
752 .id = PMIC8058_ID_LED_2,
753 },
754};
755
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700756static struct pmic8058_leds_platform_data pm8058_surf_leds_data = {
757 .num_leds = ARRAY_SIZE(pmic8058_surf_leds),
758 .leds = pmic8058_surf_leds,
759};
760
761static struct pmic8058_led pmic8058_fluid_leds[] = {
762 [0] = {
763 .name = "keyboard-backlight",
764 .max_brightness = 15,
765 .id = PMIC8058_ID_LED_KB_LIGHT,
766 },
767 [1] = {
768 .name = "flash:led_0",
769 .max_brightness = 15,
770 .id = PMIC8058_ID_FLASH_LED_0,
771 },
772 [2] = {
773 .name = "flash:led_1",
774 .max_brightness = 15,
775 .id = PMIC8058_ID_FLASH_LED_1,
776 },
777};
778
779static struct pmic8058_leds_platform_data pm8058_fluid_leds_data = {
780 .num_leds = ARRAY_SIZE(pmic8058_fluid_leds),
781 .leds = pmic8058_fluid_leds,
782};
783
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530784static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata = {
785 .irq_base = PMIC8058_IRQ_BASE,
786 .devirq = MSM_GPIO_TO_INT(PMIC_GPIO_INT),
787 .irq_trigger_flag = IRQF_TRIGGER_LOW,
788};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700789
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530790static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata = {
791 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
792};
793
794static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata = {
795 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
796};
797
798static struct pm8058_platform_data pm8058_7x30_data = {
799 .irq_pdata = &pm8xxx_irq_pdata,
800 .gpio_pdata = &pm8xxx_gpio_pdata,
801 .mpp_pdata = &pm8xxx_mpp_pdata,
802 .pwm_pdata = &pm8058_pwm_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700803};
804
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530805#ifdef CONFIG_MSM_SSBI
806static struct msm_ssbi_platform_data msm7x30_ssbi_pm8058_pdata = {
Kenneth Heitke48952912012-01-12 14:02:06 -0700807 .rsl_id = "D:PMIC_SSBI",
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530808 .controller_type = MSM_SBI_CTRL_SSBI2,
809 .slave = {
810 .name = "pm8058-core",
811 .platform_data = &pm8058_7x30_data,
812 },
813};
814#endif
815
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700816static struct i2c_board_info cy8info[] __initdata = {
817 {
818 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
819 .platform_data = &cyttsp_data,
820#ifndef CY_USE_TIMER
821 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
822#endif /* CY_USE_TIMER */
823 },
824};
825
826static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
827#ifdef CONFIG_MT9D112
828 {
829 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
Dima Zavinba5499e2011-01-10 11:00:30 -0800830 },
831#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700832#ifdef CONFIG_WEBCAM_OV9726
833 {
834 I2C_BOARD_INFO("ov9726", 0x10),
835 },
836#endif
837#ifdef CONFIG_S5K3E2FX
838 {
839 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
840 },
841#endif
842#ifdef CONFIG_MT9P012
843 {
844 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
845 },
846#endif
847#ifdef CONFIG_VX6953
848 {
849 I2C_BOARD_INFO("vx6953", 0x20),
850 },
851#endif
852#ifdef CONFIG_MT9E013
853 {
854 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
855 },
856#endif
857#ifdef CONFIG_SN12M0PZ
858 {
859 I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1),
860 },
861#endif
862#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
863 {
864 I2C_BOARD_INFO("mt9t013", 0x6C),
865 },
866#endif
867
Dima Zavinba5499e2011-01-10 11:00:30 -0800868};
869
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700870#ifdef CONFIG_MSM_CAMERA
871#define CAM_STNDBY 143
872static uint32_t camera_off_vcm_gpio_table[] = {
873GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */
874};
875
876static uint32_t camera_off_gpio_table[] = {
877 /* parallel CAMERA interfaces */
878 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RST */
879 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
880 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
881 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
882 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
883 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
884 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
885 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
886 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
887 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
888 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
889 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
890 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
891 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
892 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
893};
894
895static uint32_t camera_on_vcm_gpio_table[] = {
896GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */
897};
898
899static uint32_t camera_on_gpio_table[] = {
900 /* parallel CAMERA interfaces */
901 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RST */
902 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
903 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
904 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
905 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
906 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
907 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
908 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
909 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
910 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
911 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
912 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
913 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
914 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
915 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
916};
917
918static uint32_t camera_off_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 uint32_t camera_on_gpio_fluid_table[] = {
926 /* FLUID: CAM_VGA_RST_N */
927 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
928 /* FLUID: CAMIF_STANDBY */
929 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
930};
931
932static void config_gpio_table(uint32_t *table, int len)
933{
934 int n, rc;
935 for (n = 0; n < len; n++) {
936 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
937 if (rc) {
938 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
939 __func__, table[n], rc);
940 break;
941 }
942 }
943}
944static int config_camera_on_gpios(void)
945{
946 config_gpio_table(camera_on_gpio_table,
947 ARRAY_SIZE(camera_on_gpio_table));
948
949 if (adie_get_detected_codec_type() != TIMPANI_ID)
950 /* GPIO1 is shared also used in Timpani RF card so
951 only configure it for non-Timpani RF card */
952 config_gpio_table(camera_on_vcm_gpio_table,
953 ARRAY_SIZE(camera_on_vcm_gpio_table));
954
955 if (machine_is_msm7x30_fluid()) {
956 config_gpio_table(camera_on_gpio_fluid_table,
957 ARRAY_SIZE(camera_on_gpio_fluid_table));
958 /* FLUID: turn on 5V booster */
959 gpio_set_value(
960 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 1);
961 /* FLUID: drive high to put secondary sensor to STANDBY */
962 gpio_set_value(CAM_STNDBY, 1);
963 }
964 return 0;
965}
966
967static void config_camera_off_gpios(void)
968{
969 config_gpio_table(camera_off_gpio_table,
970 ARRAY_SIZE(camera_off_gpio_table));
971
972 if (adie_get_detected_codec_type() != TIMPANI_ID)
973 /* GPIO1 is shared also used in Timpani RF card so
974 only configure it for non-Timpani RF card */
975 config_gpio_table(camera_off_vcm_gpio_table,
976 ARRAY_SIZE(camera_off_vcm_gpio_table));
977
978 if (machine_is_msm7x30_fluid()) {
979 config_gpio_table(camera_off_gpio_fluid_table,
980 ARRAY_SIZE(camera_off_gpio_fluid_table));
981 /* FLUID: turn off 5V booster */
982 gpio_set_value(
983 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 0);
984 }
985}
986
987struct resource msm_camera_resources[] = {
988 {
989 .start = 0xA6000000,
990 .end = 0xA6000000 + SZ_1M - 1,
991 .flags = IORESOURCE_MEM,
992 },
993 {
994 .start = INT_VFE,
995 .end = INT_VFE,
996 .flags = IORESOURCE_IRQ,
997 },
998 {
999 .flags = IORESOURCE_DMA,
1000 }
1001};
1002
1003struct msm_camera_device_platform_data msm_camera_device_data = {
1004 .camera_gpio_on = config_camera_on_gpios,
1005 .camera_gpio_off = config_camera_off_gpios,
1006 .ioext.camifpadphy = 0xAB000000,
1007 .ioext.camifpadsz = 0x00000400,
1008 .ioext.csiphy = 0xA6100000,
1009 .ioext.csisz = 0x00000400,
1010 .ioext.csiirq = INT_CSI,
1011 .ioclk.mclk_clk_rate = 24000000,
1012 .ioclk.vfe_clk_rate = 147456000,
1013};
1014
1015static struct msm_camera_sensor_flash_src msm_flash_src_pwm = {
1016 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PWM,
1017 ._fsrc.pwm_src.freq = 1000,
1018 ._fsrc.pwm_src.max_load = 300,
1019 ._fsrc.pwm_src.low_load = 30,
1020 ._fsrc.pwm_src.high_load = 100,
1021 ._fsrc.pwm_src.channel = 7,
1022};
1023
1024#ifdef CONFIG_MT9D112
1025static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1026 .flash_type = MSM_CAMERA_FLASH_LED,
1027 .flash_src = &msm_flash_src_pwm
1028};
1029
1030static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1031 .sensor_name = "mt9d112",
1032 .sensor_reset = 0,
1033 .sensor_pwd = 85,
1034 .vcm_pwd = 1,
1035 .vcm_enable = 0,
1036 .pdata = &msm_camera_device_data,
1037 .resource = msm_camera_resources,
1038 .num_resources = ARRAY_SIZE(msm_camera_resources),
1039 .flash_data = &flash_mt9d112,
1040 .csi_if = 0
1041};
1042
1043static struct platform_device msm_camera_sensor_mt9d112 = {
1044 .name = "msm_camera_mt9d112",
1045 .dev = {
1046 .platform_data = &msm_camera_sensor_mt9d112_data,
1047 },
1048};
1049#endif
1050
1051#ifdef CONFIG_WEBCAM_OV9726
1052
1053static struct msm_camera_sensor_platform_info ov9726_sensor_7630_info = {
1054 .mount_angle = 90
1055};
1056
1057static struct msm_camera_sensor_flash_data flash_ov9726 = {
1058 .flash_type = MSM_CAMERA_FLASH_LED,
1059 .flash_src = &msm_flash_src_pwm
1060};
1061static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
1062 .sensor_name = "ov9726",
1063 .sensor_reset = 0,
1064 .sensor_pwd = 85,
1065 .vcm_pwd = 1,
1066 .vcm_enable = 0,
1067 .pdata = &msm_camera_device_data,
1068 .resource = msm_camera_resources,
1069 .num_resources = ARRAY_SIZE(msm_camera_resources),
1070 .flash_data = &flash_ov9726,
1071 .sensor_platform_info = &ov9726_sensor_7630_info,
1072 .csi_if = 1
1073};
1074struct platform_device msm_camera_sensor_ov9726 = {
1075 .name = "msm_camera_ov9726",
1076 .dev = {
1077 .platform_data = &msm_camera_sensor_ov9726_data,
1078 },
1079};
1080#endif
1081
1082#ifdef CONFIG_S5K3E2FX
1083static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1084 .flash_type = MSM_CAMERA_FLASH_LED,
1085 .flash_src = &msm_flash_src_pwm,
1086};
1087
1088static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1089 .sensor_name = "s5k3e2fx",
1090 .sensor_reset = 0,
1091 .sensor_pwd = 85,
1092 .vcm_pwd = 1,
1093 .vcm_enable = 0,
1094 .pdata = &msm_camera_device_data,
1095 .resource = msm_camera_resources,
1096 .num_resources = ARRAY_SIZE(msm_camera_resources),
1097 .flash_data = &flash_s5k3e2fx,
1098 .csi_if = 0
1099};
1100
1101static struct platform_device msm_camera_sensor_s5k3e2fx = {
1102 .name = "msm_camera_s5k3e2fx",
1103 .dev = {
1104 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1105 },
1106};
1107#endif
1108
1109#ifdef CONFIG_MT9P012
1110static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1111 .flash_type = MSM_CAMERA_FLASH_LED,
1112 .flash_src = &msm_flash_src_pwm
1113};
1114
1115static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1116 .sensor_name = "mt9p012",
1117 .sensor_reset = 0,
1118 .sensor_pwd = 85,
1119 .vcm_pwd = 1,
1120 .vcm_enable = 1,
1121 .pdata = &msm_camera_device_data,
1122 .resource = msm_camera_resources,
1123 .num_resources = ARRAY_SIZE(msm_camera_resources),
1124 .flash_data = &flash_mt9p012,
1125 .csi_if = 0
1126};
1127
1128static struct platform_device msm_camera_sensor_mt9p012 = {
1129 .name = "msm_camera_mt9p012",
1130 .dev = {
1131 .platform_data = &msm_camera_sensor_mt9p012_data,
1132 },
1133};
1134#endif
1135
1136#ifdef CONFIG_MT9E013
1137static struct msm_camera_sensor_platform_info mt9e013_sensor_7630_info = {
1138 .mount_angle = 0
1139};
1140
1141static struct msm_camera_sensor_flash_data flash_mt9e013 = {
1142 .flash_type = MSM_CAMERA_FLASH_LED,
1143 .flash_src = &msm_flash_src_pwm
1144};
1145
1146static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
1147 .sensor_name = "mt9e013",
1148 .sensor_reset = 0,
1149 .sensor_pwd = 85,
1150 .vcm_pwd = 1,
1151 .vcm_enable = 1,
1152 .pdata = &msm_camera_device_data,
1153 .resource = msm_camera_resources,
1154 .num_resources = ARRAY_SIZE(msm_camera_resources),
1155 .flash_data = &flash_mt9e013,
1156 .sensor_platform_info = &mt9e013_sensor_7630_info,
1157 .csi_if = 1
1158};
1159
1160static struct platform_device msm_camera_sensor_mt9e013 = {
1161 .name = "msm_camera_mt9e013",
1162 .dev = {
1163 .platform_data = &msm_camera_sensor_mt9e013_data,
1164 },
1165};
1166#endif
1167
1168#ifdef CONFIG_VX6953
Jilai Wang971f97f2011-07-13 14:25:25 -04001169static struct msm_camera_sensor_platform_info vx6953_sensor_7630_info = {
1170 .mount_angle = 0
1171};
1172
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001173static struct msm_camera_sensor_flash_data flash_vx6953 = {
1174 .flash_type = MSM_CAMERA_FLASH_LED,
1175 .flash_src = &msm_flash_src_pwm
1176};
1177static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1178 .sensor_name = "vx6953",
1179 .sensor_reset = 0,
1180 .sensor_pwd = 85,
1181 .vcm_pwd = 1,
1182 .vcm_enable = 0,
1183 .pdata = &msm_camera_device_data,
1184 .resource = msm_camera_resources,
1185 .num_resources = ARRAY_SIZE(msm_camera_resources),
Jilai Wang971f97f2011-07-13 14:25:25 -04001186 .sensor_platform_info = &vx6953_sensor_7630_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001187 .flash_data = &flash_vx6953,
1188 .csi_if = 1
1189};
1190static struct platform_device msm_camera_sensor_vx6953 = {
1191 .name = "msm_camera_vx6953",
1192 .dev = {
1193 .platform_data = &msm_camera_sensor_vx6953_data,
1194 },
1195};
1196#endif
1197
1198#ifdef CONFIG_SN12M0PZ
1199static struct msm_camera_sensor_flash_src msm_flash_src_current_driver = {
1200 .flash_sr_type = MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER,
1201 ._fsrc.current_driver_src.low_current = 210,
1202 ._fsrc.current_driver_src.high_current = 700,
1203 ._fsrc.current_driver_src.driver_channel = &pm8058_fluid_leds_data,
1204};
1205
1206static struct msm_camera_sensor_flash_data flash_sn12m0pz = {
1207 .flash_type = MSM_CAMERA_FLASH_LED,
1208 .flash_src = &msm_flash_src_current_driver
1209};
1210static struct msm_camera_sensor_info msm_camera_sensor_sn12m0pz_data = {
1211 .sensor_name = "sn12m0pz",
1212 .sensor_reset = 0,
1213 .sensor_pwd = 85,
1214 .vcm_pwd = 1,
1215 .vcm_enable = 1,
1216 .pdata = &msm_camera_device_data,
1217 .flash_data = &flash_sn12m0pz,
1218 .resource = msm_camera_resources,
1219 .num_resources = ARRAY_SIZE(msm_camera_resources),
1220 .csi_if = 0
1221};
1222
1223static struct platform_device msm_camera_sensor_sn12m0pz = {
1224 .name = "msm_camera_sn12m0pz",
1225 .dev = {
1226 .platform_data = &msm_camera_sensor_sn12m0pz_data,
1227 },
1228};
1229#endif
1230
1231#ifdef CONFIG_MT9T013
1232static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1233 .flash_type = MSM_CAMERA_FLASH_LED,
1234 .flash_src = &msm_flash_src_pwm
1235};
1236
1237static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1238 .sensor_name = "mt9t013",
1239 .sensor_reset = 0,
1240 .sensor_pwd = 85,
1241 .vcm_pwd = 1,
1242 .vcm_enable = 0,
1243 .pdata = &msm_camera_device_data,
1244 .resource = msm_camera_resources,
1245 .num_resources = ARRAY_SIZE(msm_camera_resources),
1246 .flash_data = &flash_mt9t013,
1247 .csi_if = 1
1248};
1249
1250static struct platform_device msm_camera_sensor_mt9t013 = {
1251 .name = "msm_camera_mt9t013",
1252 .dev = {
1253 .platform_data = &msm_camera_sensor_mt9t013_data,
1254 },
1255};
1256#endif
1257
1258#ifdef CONFIG_MSM_GEMINI
1259static struct resource msm_gemini_resources[] = {
1260 {
1261 .start = 0xA3A00000,
1262 .end = 0xA3A00000 + 0x0150 - 1,
1263 .flags = IORESOURCE_MEM,
1264 },
1265 {
1266 .start = INT_JPEG,
1267 .end = INT_JPEG,
1268 .flags = IORESOURCE_IRQ,
1269 },
1270};
1271
1272static struct platform_device msm_gemini_device = {
1273 .name = "msm_gemini",
1274 .resource = msm_gemini_resources,
1275 .num_resources = ARRAY_SIZE(msm_gemini_resources),
1276};
1277#endif
1278
1279#ifdef CONFIG_MSM_VPE
1280static struct resource msm_vpe_resources[] = {
1281 {
1282 .start = 0xAD200000,
1283 .end = 0xAD200000 + SZ_1M - 1,
1284 .flags = IORESOURCE_MEM,
1285 },
1286 {
1287 .start = INT_VPE,
1288 .end = INT_VPE,
1289 .flags = IORESOURCE_IRQ,
1290 },
1291};
1292
1293static struct platform_device msm_vpe_device = {
1294 .name = "msm_vpe",
1295 .id = 0,
1296 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1297 .resource = msm_vpe_resources,
1298};
1299#endif
1300
1301#endif /*CONFIG_MSM_CAMERA*/
1302
1303#ifdef CONFIG_MSM7KV2_AUDIO
1304static uint32_t audio_pamp_gpio_config =
1305 GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1306
1307static uint32_t audio_fluid_icodec_tx_config =
1308 GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1309
1310static int __init snddev_poweramp_gpio_init(void)
1311{
1312 int rc;
1313
1314 pr_info("snddev_poweramp_gpio_init \n");
1315 rc = gpio_tlmm_config(audio_pamp_gpio_config, GPIO_CFG_ENABLE);
1316 if (rc) {
1317 printk(KERN_ERR
1318 "%s: gpio_tlmm_config(%#x)=%d\n",
1319 __func__, audio_pamp_gpio_config, rc);
1320 }
1321 return rc;
1322}
1323
1324void msm_snddev_tx_route_config(void)
1325{
1326 int rc;
1327
1328 pr_debug("%s()\n", __func__);
1329
1330 if (machine_is_msm7x30_fluid()) {
1331 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1332 GPIO_CFG_ENABLE);
1333 if (rc) {
1334 printk(KERN_ERR
1335 "%s: gpio_tlmm_config(%#x)=%d\n",
1336 __func__, audio_fluid_icodec_tx_config, rc);
1337 } else
1338 gpio_set_value(85, 0);
1339 }
1340}
1341
1342void msm_snddev_tx_route_deconfig(void)
1343{
1344 int rc;
1345
1346 pr_debug("%s()\n", __func__);
1347
1348 if (machine_is_msm7x30_fluid()) {
1349 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1350 GPIO_CFG_DISABLE);
1351 if (rc) {
1352 printk(KERN_ERR
1353 "%s: gpio_tlmm_config(%#x)=%d\n",
1354 __func__, audio_fluid_icodec_tx_config, rc);
1355 }
1356 }
1357}
1358
1359void msm_snddev_poweramp_on(void)
1360{
1361 gpio_set_value(82, 1); /* enable spkr poweramp */
1362 pr_info("%s: power on amplifier\n", __func__);
1363}
1364
1365void msm_snddev_poweramp_off(void)
1366{
1367 gpio_set_value(82, 0); /* disable spkr poweramp */
1368 pr_info("%s: power off amplifier\n", __func__);
1369}
1370
Justin Paupore3f40f342011-08-10 18:52:16 -07001371static struct regulator_bulk_data snddev_regs[] = {
1372 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
1373 { .supply = "ncp", .min_uV = 1800000, .max_uV = 1800000 },
1374};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001375
Justin Paupore3f40f342011-08-10 18:52:16 -07001376static int __init snddev_hsed_voltage_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001377{
1378 int rc;
1379
Justin Paupore3f40f342011-08-10 18:52:16 -07001380 rc = regulator_bulk_get(NULL, ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001381
Justin Paupore3f40f342011-08-10 18:52:16 -07001382 if (rc) {
1383 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1384 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001385 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001386
1387 rc = regulator_bulk_set_voltage(ARRAY_SIZE(snddev_regs), snddev_regs);
1388
1389 if (rc) {
1390 pr_err("%s: could not set regulator voltages: %d\n",
1391 __func__, rc);
1392 goto regs_free;
1393 }
1394
1395 return 0;
1396
1397regs_free:
1398 regulator_bulk_free(ARRAY_SIZE(snddev_regs), snddev_regs);
1399out:
1400 return rc;
1401}
1402
1403
1404void msm_snddev_hsed_voltage_on(void)
1405{
1406 int rc = regulator_bulk_enable(ARRAY_SIZE(snddev_regs), snddev_regs);
1407
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001408 if (rc)
Justin Paupore3f40f342011-08-10 18:52:16 -07001409 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001410}
1411
1412void msm_snddev_hsed_voltage_off(void)
1413{
Justin Paupore3f40f342011-08-10 18:52:16 -07001414 int rc = regulator_bulk_disable(ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001415
Justin Paupore3f40f342011-08-10 18:52:16 -07001416 if (rc) {
1417 pr_err("%s: could not disable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001418 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001419}
1420
1421static unsigned aux_pcm_gpio_on[] = {
1422 GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
1423 GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
1424 GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
1425 GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
1426};
1427
1428static int __init aux_pcm_gpio_init(void)
1429{
1430 int pin, rc;
1431
1432 pr_info("aux_pcm_gpio_init \n");
1433 for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) {
1434 rc = gpio_tlmm_config(aux_pcm_gpio_on[pin],
1435 GPIO_CFG_ENABLE);
1436 if (rc) {
1437 printk(KERN_ERR
1438 "%s: gpio_tlmm_config(%#x)=%d\n",
1439 __func__, aux_pcm_gpio_on[pin], rc);
1440 }
1441 }
1442 return rc;
1443}
1444
1445static struct msm_gpio mi2s_clk_gpios[] = {
1446 { GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1447 "MI2S_SCLK"},
1448 { GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1449 "MI2S_WS"},
1450 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1451 "MI2S_MCLK_A"},
1452};
1453
1454static struct msm_gpio mi2s_rx_data_lines_gpios[] = {
1455 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1456 "MI2S_DATA_SD0_A"},
1457 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1458 "MI2S_DATA_SD1_A"},
1459 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1460 "MI2S_DATA_SD2_A"},
1461 { GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1462 "MI2S_DATA_SD3"},
1463};
1464
1465static struct msm_gpio mi2s_tx_data_lines_gpios[] = {
1466 { GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1467 "MI2S_DATA_SD3"},
1468};
1469
1470int mi2s_config_clk_gpio(void)
1471{
1472 int rc = 0;
1473
1474 rc = msm_gpios_request_enable(mi2s_clk_gpios,
1475 ARRAY_SIZE(mi2s_clk_gpios));
1476 if (rc) {
1477 pr_err("%s: enable mi2s clk gpios failed\n",
1478 __func__);
1479 return rc;
1480 }
1481 return 0;
1482}
1483
1484int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask)
1485{
1486 int i, rc = 0;
1487 sd_line_mask &= MI2S_SD_LINE_MASK;
1488
1489 switch (direction) {
1490 case DIR_TX:
1491 msm_gpios_disable_free(mi2s_tx_data_lines_gpios, 1);
1492 break;
1493 case DIR_RX:
1494 i = 0;
1495 while (sd_line_mask) {
1496 if (sd_line_mask & 0x1)
1497 msm_gpios_disable_free(
1498 mi2s_rx_data_lines_gpios + i , 1);
1499 sd_line_mask = sd_line_mask >> 1;
1500 i++;
1501 }
1502 break;
1503 default:
1504 pr_err("%s: Invaild direction direction = %u\n",
1505 __func__, direction);
1506 rc = -EINVAL;
1507 break;
1508 }
1509 return rc;
1510}
1511
1512int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask)
1513{
1514 int i , rc = 0;
1515 u8 sd_config_done_mask = 0;
1516
1517 sd_line_mask &= MI2S_SD_LINE_MASK;
1518
1519 switch (direction) {
1520 case DIR_TX:
1521 if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) ||
1522 (sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) {
1523 pr_err("%s: can not use SD0 or SD1 or SD2 for TX"
1524 ".only can use SD3. sd_line_mask = 0x%x\n",
1525 __func__ , sd_line_mask);
1526 rc = -EINVAL;
1527 } else {
1528 rc = msm_gpios_request_enable(mi2s_tx_data_lines_gpios,
1529 1);
1530 if (rc)
1531 pr_err("%s: enable mi2s gpios for TX failed\n",
1532 __func__);
1533 }
1534 break;
1535 case DIR_RX:
1536 i = 0;
1537 while (sd_line_mask && (rc == 0)) {
1538 if (sd_line_mask & 0x1) {
1539 rc = msm_gpios_request_enable(
1540 mi2s_rx_data_lines_gpios + i , 1);
1541 if (rc) {
1542 pr_err("%s: enable mi2s gpios for"
1543 "RX failed. SD line = %s\n",
1544 __func__,
1545 (mi2s_rx_data_lines_gpios + i)->label);
1546 mi2s_unconfig_data_gpio(DIR_RX,
1547 sd_config_done_mask);
1548 } else
1549 sd_config_done_mask |= (1 << i);
1550 }
1551 sd_line_mask = sd_line_mask >> 1;
1552 i++;
1553 }
1554 break;
1555 default:
1556 pr_err("%s: Invaild direction direction = %u\n",
1557 __func__, direction);
1558 rc = -EINVAL;
1559 break;
1560 }
1561 return rc;
1562}
1563
1564int mi2s_unconfig_clk_gpio(void)
1565{
1566 msm_gpios_disable_free(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios));
1567 return 0;
1568}
1569
1570#endif /* CONFIG_MSM7KV2_AUDIO */
1571
1572static int __init buses_init(void)
1573{
1574 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT,
1575 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
1576 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
1577 __func__, PMIC_GPIO_INT);
1578
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301579 if (machine_is_msm8x60_fluid())
1580 pm8058_7x30_data.keypad_pdata = &fluid_keypad_data;
1581 else
1582 pm8058_7x30_data.keypad_pdata = &surf_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001583
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001584 return 0;
1585}
1586
1587#define TIMPANI_RESET_GPIO 1
1588
1589struct bahama_config_register{
1590 u8 reg;
1591 u8 value;
1592 u8 mask;
1593};
1594
1595enum version{
1596 VER_1_0,
1597 VER_2_0,
1598 VER_UNSUPPORTED = 0xFF
1599};
1600
Justin Paupore3f40f342011-08-10 18:52:16 -07001601static struct regulator *vreg_marimba_1;
1602static struct regulator *vreg_marimba_2;
1603static struct regulator *vreg_bahama;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001604
1605static struct msm_gpio timpani_reset_gpio_cfg[] = {
1606{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
1607 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} };
1608
1609static u8 read_bahama_ver(void)
1610{
1611 int rc;
1612 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1613 u8 bahama_version;
1614
1615 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
1616 if (rc < 0) {
1617 printk(KERN_ERR
1618 "%s: version read failed: %d\n",
1619 __func__, rc);
1620 return rc;
1621 } else {
1622 printk(KERN_INFO
1623 "%s: version read got: 0x%x\n",
1624 __func__, bahama_version);
1625 }
1626
1627 switch (bahama_version) {
1628 case 0x08: /* varient of bahama v1 */
1629 case 0x10:
1630 case 0x00:
1631 return VER_1_0;
1632 case 0x09: /* variant of bahama v2 */
1633 return VER_2_0;
1634 default:
1635 return VER_UNSUPPORTED;
1636 }
1637}
1638
1639static int config_timpani_reset(void)
1640{
1641 int rc;
1642
1643 rc = msm_gpios_request_enable(timpani_reset_gpio_cfg,
1644 ARRAY_SIZE(timpani_reset_gpio_cfg));
1645 if (rc < 0) {
1646 printk(KERN_ERR
1647 "%s: msm_gpios_request_enable failed (%d)\n",
1648 __func__, rc);
1649 }
1650 return rc;
1651}
1652
1653static unsigned int msm_timpani_setup_power(void)
1654{
1655 int rc;
1656
1657 rc = config_timpani_reset();
1658 if (rc < 0)
1659 goto out;
1660
Justin Paupore3f40f342011-08-10 18:52:16 -07001661 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001662 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001663 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001664 goto out;
1665 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001666
1667 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001668 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001669 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1670 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001671 }
1672
1673 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1);
1674 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001675 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001676 __func__, rc);
1677 msm_gpios_free(timpani_reset_gpio_cfg,
1678 ARRAY_SIZE(timpani_reset_gpio_cfg));
Justin Paupore3f40f342011-08-10 18:52:16 -07001679 goto disable_marimba_2;
1680 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001681
Justin Paupore3f40f342011-08-10 18:52:16 -07001682 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001683
Justin Paupore3f40f342011-08-10 18:52:16 -07001684disable_marimba_2:
1685 regulator_disable(vreg_marimba_2);
1686disable_marimba_1:
1687 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001688out:
1689 return rc;
1690};
1691
1692static void msm_timpani_shutdown_power(void)
1693{
1694 int rc;
1695
Justin Paupore3f40f342011-08-10 18:52:16 -07001696 rc = regulator_disable(vreg_marimba_2);
1697 if (rc)
1698 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1699
1700 rc = regulator_disable(vreg_marimba_1);
1701 if (rc)
1702 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001703
1704 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0);
Justin Paupore3f40f342011-08-10 18:52:16 -07001705 if (rc < 0)
1706 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001707 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001708
1709 msm_gpios_free(timpani_reset_gpio_cfg,
1710 ARRAY_SIZE(timpani_reset_gpio_cfg));
1711};
1712
1713static unsigned int msm_bahama_core_config(int type)
1714{
1715 int rc = 0;
1716
1717 if (type == BAHAMA_ID) {
1718
1719 int i;
1720 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1721
1722 const struct bahama_config_register v20_init[] = {
1723 /* reg, value, mask */
1724 { 0xF4, 0x84, 0xFF }, /* AREG */
1725 { 0xF0, 0x04, 0xFF } /* DREG */
1726 };
1727
1728 if (read_bahama_ver() == VER_2_0) {
1729 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
1730 u8 value = v20_init[i].value;
1731 rc = marimba_write_bit_mask(&config,
1732 v20_init[i].reg,
1733 &value,
1734 sizeof(v20_init[i].value),
1735 v20_init[i].mask);
1736 if (rc < 0) {
1737 printk(KERN_ERR
1738 "%s: reg %d write failed: %d\n",
1739 __func__, v20_init[i].reg, rc);
1740 return rc;
1741 }
1742 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
1743 " mask 0x%02x\n",
1744 __func__, v20_init[i].reg,
1745 v20_init[i].value, v20_init[i].mask);
1746 }
1747 }
1748 }
1749 printk(KERN_INFO "core type: %d\n", type);
1750
1751 return rc;
1752}
1753
1754static unsigned int msm_bahama_setup_power(void)
1755{
Justin Paupore3f40f342011-08-10 18:52:16 -07001756 int rc = regulator_enable(vreg_bahama);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001757
Justin Paupore3f40f342011-08-10 18:52:16 -07001758 if (rc)
1759 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001760
1761 return rc;
1762};
1763
1764static unsigned int msm_bahama_shutdown_power(int value)
1765{
1766 int rc = 0;
1767
1768 if (value != BAHAMA_ID) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001769 rc = regulator_disable(vreg_bahama);
1770
1771 if (rc)
1772 pr_err("%s: regulator_disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001773 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001774 }
1775
1776 return rc;
1777};
1778
1779static struct msm_gpio marimba_svlte_config_clock[] = {
1780 { GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1781 "MARIMBA_SVLTE_CLOCK_ENABLE" },
1782};
1783
1784static unsigned int msm_marimba_gpio_config_svlte(int gpio_cfg_marimba)
1785{
1786 if (machine_is_msm8x55_svlte_surf() ||
1787 machine_is_msm8x55_svlte_ffa()) {
1788 if (gpio_cfg_marimba)
1789 gpio_set_value(GPIO_PIN
1790 (marimba_svlte_config_clock->gpio_cfg), 1);
1791 else
1792 gpio_set_value(GPIO_PIN
1793 (marimba_svlte_config_clock->gpio_cfg), 0);
1794 }
1795
1796 return 0;
1797};
1798
1799static unsigned int msm_marimba_setup_power(void)
1800{
1801 int rc;
1802
Justin Paupore3f40f342011-08-10 18:52:16 -07001803 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001804 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001805 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001806 goto out;
1807 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001808
1809 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001810 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001811 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1812 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001813 }
1814
1815 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
1816 rc = msm_gpios_request_enable(marimba_svlte_config_clock,
1817 ARRAY_SIZE(marimba_svlte_config_clock));
1818 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001819 pr_err("%s: msm_gpios_request_enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001820 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07001821 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001822 }
1823
1824 rc = gpio_direction_output(GPIO_PIN
1825 (marimba_svlte_config_clock->gpio_cfg), 0);
1826 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001827 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001828 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07001829 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001830 }
1831 }
1832
Justin Paupore3f40f342011-08-10 18:52:16 -07001833 return 0;
1834
1835disable_marimba_2:
1836 regulator_disable(vreg_marimba_2);
1837disable_marimba_1:
1838 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001839out:
1840 return rc;
1841};
1842
1843static void msm_marimba_shutdown_power(void)
1844{
1845 int rc;
1846
Justin Paupore3f40f342011-08-10 18:52:16 -07001847 rc = regulator_disable(vreg_marimba_2);
1848 if (rc)
1849 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1850
1851 rc = regulator_disable(vreg_marimba_1);
1852 if (rc)
1853 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001854};
1855
1856static int bahama_present(void)
1857{
1858 int id;
1859 switch (id = adie_get_detected_connectivity_type()) {
1860 case BAHAMA_ID:
1861 return 1;
1862
1863 case MARIMBA_ID:
1864 return 0;
1865
1866 case TIMPANI_ID:
1867 default:
1868 printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n",
1869 __func__, id);
1870 return -ENODEV;
1871 }
1872}
1873
Justin Paupore3f40f342011-08-10 18:52:16 -07001874struct regulator *fm_regulator;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001875static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
1876{
Justin Paupore3f40f342011-08-10 18:52:16 -07001877 int rc, voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001878 uint32_t irqcfg;
1879 const char *id = "FMPW";
1880
1881 int bahama_not_marimba = bahama_present();
1882
Justin Paupore3f40f342011-08-10 18:52:16 -07001883 if (bahama_not_marimba < 0) {
1884 pr_warn("%s: bahama_present: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001885 __func__, bahama_not_marimba);
Justin Paupore3f40f342011-08-10 18:52:16 -07001886 rc = -ENODEV;
1887 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001888 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001889 if (bahama_not_marimba) {
1890 fm_regulator = regulator_get(NULL, "s3");
1891 voltage = 1800000;
1892 } else {
1893 fm_regulator = regulator_get(NULL, "s2");
1894 voltage = 1300000;
1895 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001896
1897 if (IS_ERR(fm_regulator)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001898 rc = PTR_ERR(fm_regulator);
1899 pr_err("%s: regulator_get failed (%d)\n", __func__, rc);
1900 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001901 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001902
Justin Paupore3f40f342011-08-10 18:52:16 -07001903 rc = regulator_set_voltage(fm_regulator, voltage, voltage);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001904
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001905 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001906 pr_err("%s: regulator_set_voltage failed (%d)\n", __func__, rc);
1907 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001908 }
1909
Justin Paupore3f40f342011-08-10 18:52:16 -07001910 rc = regulator_enable(fm_regulator);
1911
1912 if (rc) {
1913 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1914 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001915 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001916
1917 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_ON);
1918
1919 if (rc < 0) {
1920 pr_err("%s: clock vote failed (%d)\n", __func__, rc);
1921 goto regulator_disable;
1922 }
1923
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001924 /*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
1925 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07001926 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001927 rc = marimba_gpio_config(1);
Justin Paupore3f40f342011-08-10 18:52:16 -07001928 if (rc < 0) {
1929 pr_err("%s: clock enable for svlte : %d\n",
1930 __func__, rc);
1931 goto clock_devote;
1932 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001933 }
1934 irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
1935 GPIO_CFG_2MA);
1936 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
1937 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001938 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001939 rc = -EIO;
Justin Paupore3f40f342011-08-10 18:52:16 -07001940 goto gpio_deconfig;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001941
1942 }
1943 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001944
Justin Paupore3f40f342011-08-10 18:52:16 -07001945gpio_deconfig:
1946 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa())
1947 marimba_gpio_config(0);
1948clock_devote:
1949 pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_OFF);
1950regulator_disable:
1951 regulator_disable(fm_regulator);
1952regulator_free:
1953 regulator_put(fm_regulator);
1954 fm_regulator = NULL;
1955out:
1956 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001957};
1958
1959static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
1960{
1961 int rc;
1962 const char *id = "FMPW";
1963 uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
1964 GPIO_CFG_2MA);
1965
1966 int bahama_not_marimba = bahama_present();
1967 if (bahama_not_marimba == -1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001968 pr_warn("%s: bahama_present: %d\n",
1969 __func__, bahama_not_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001970 return;
1971 }
1972
1973 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
1974 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001975 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001976 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001977 if (!IS_ERR_OR_NULL(fm_regulator)) {
1978 rc = regulator_disable(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001979
Justin Paupore3f40f342011-08-10 18:52:16 -07001980 if (rc)
1981 pr_err("%s: return val: %d\n", __func__, rc);
1982
1983 regulator_put(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001984 fm_regulator = NULL;
1985 }
1986 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
1987 PMAPP_CLOCK_VOTE_OFF);
1988 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07001989 pr_err("%s: clock_vote return val: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001990
1991 /*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
1992 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07001993 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001994 rc = marimba_gpio_config(0);
1995 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07001996 pr_err("%s: clock disable for svlte : %d\n",
1997 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001998 }
1999}
2000
2001static struct marimba_fm_platform_data marimba_fm_pdata = {
2002 .fm_setup = fm_radio_setup,
2003 .fm_shutdown = fm_radio_shutdown,
2004 .irq = MSM_GPIO_TO_INT(147),
2005 .vreg_s2 = NULL,
2006 .vreg_xo_out = NULL,
2007 .is_fm_soc_i2s_master = false,
2008 .config_i2s_gpio = NULL,
2009};
2010
2011
2012/* Slave id address for FM/CDC/QMEMBIST
2013 * Values can be programmed using Marimba slave id 0
2014 * should there be a conflict with other I2C devices
2015 * */
2016#define MARIMBA_SLAVE_ID_FM_ADDR 0x2A
2017#define MARIMBA_SLAVE_ID_CDC_ADDR 0x77
2018#define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66
2019
2020#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
2021#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
2022
2023static const char *tsadc_id = "MADC";
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002024
Justin Paupore3f40f342011-08-10 18:52:16 -07002025static struct regulator_bulk_data regs_tsadc_marimba[] = {
2026 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2027 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002028};
Justin Paupore3f40f342011-08-10 18:52:16 -07002029
2030static struct regulator_bulk_data regs_tsadc_timpani[] = {
2031 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2032 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2033 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2034};
2035
2036static struct regulator_bulk_data *regs_tsadc;
2037static int regs_tsadc_count;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002038
2039static int marimba_tsadc_power(int vreg_on)
2040{
Justin Paupore3f40f342011-08-10 18:52:16 -07002041 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002042 int tsadc_adie_type = adie_get_detected_codec_type();
2043
Justin Paupore3f40f342011-08-10 18:52:16 -07002044 switch (tsadc_adie_type) {
2045 case TIMPANI_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002046 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2047 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2048 if (rc) {
2049 pr_err("%s: unable to %svote for d1 clk\n",
2050 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002051 goto D1_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002052 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002053
2054 /* fall through */
2055 case MARIMBA_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002056 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2057 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2058 if (rc) {
2059 pr_err("%s: unable to %svote for d1 clk\n",
2060 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002061 goto D0_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002062 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002063
Justin Paupore3f40f342011-08-10 18:52:16 -07002064 WARN_ON(regs_tsadc_count == 0);
2065
2066 rc = vreg_on ?
2067 regulator_bulk_enable(regs_tsadc_count, regs_tsadc) :
2068 regulator_bulk_disable(regs_tsadc_count, regs_tsadc);
2069
2070 if (rc) {
2071 pr_err("%s: regulator %sable failed: %d\n",
2072 __func__, vreg_on ? "en" : "dis", rc);
2073 goto regulator_switch_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002074 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002075
2076 break;
2077 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002078 pr_err("%s:Adie %d not supported\n",
2079 __func__, tsadc_adie_type);
2080 return -ENODEV;
2081 }
2082
2083 msleep(5); /* ensure power is stable */
2084
2085 return 0;
2086
Justin Paupore3f40f342011-08-10 18:52:16 -07002087regulator_switch_fail:
2088 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2089 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2090D0_vote_fail:
2091 if (tsadc_adie_type == TIMPANI_ID)
2092 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2093 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2094D1_vote_fail:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002095 return rc;
2096}
2097
2098static int marimba_tsadc_init(void)
2099{
Justin Paupore3f40f342011-08-10 18:52:16 -07002100 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002101 int tsadc_adie_type = adie_get_detected_codec_type();
2102
Justin Paupore3f40f342011-08-10 18:52:16 -07002103 switch (tsadc_adie_type) {
2104 case MARIMBA_ID:
2105 regs_tsadc = regs_tsadc_marimba;
2106 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_marimba);
2107 break;
2108 case TIMPANI_ID:
2109 regs_tsadc = regs_tsadc_timpani;
2110 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_timpani);
2111 break;
2112 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002113 pr_err("%s:Adie %d not supported\n",
2114 __func__, tsadc_adie_type);
Justin Paupore3f40f342011-08-10 18:52:16 -07002115 rc = -ENODEV;
2116 goto out;
2117 }
2118
2119 rc = regulator_bulk_get(NULL, regs_tsadc_count, regs_tsadc);
2120 if (rc) {
2121 pr_err("%s: could not get regulators: %d\n",
2122 __func__, rc);
2123 goto out;
2124 }
2125
2126 rc = regulator_bulk_set_voltage(regs_tsadc_count, regs_tsadc);
2127 if (rc) {
2128 pr_err("%s: could not set regulator voltages: %d\n",
2129 __func__, rc);
2130 goto vreg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002131 }
2132
2133 return 0;
2134
Justin Paupore3f40f342011-08-10 18:52:16 -07002135vreg_free:
2136 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2137out:
2138 regs_tsadc = NULL;
2139 regs_tsadc_count = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002140 return rc;
2141}
2142
2143static int marimba_tsadc_exit(void)
2144{
Justin Paupore3f40f342011-08-10 18:52:16 -07002145 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2146 regs_tsadc_count = 0;
2147 regs_tsadc = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002148
Justin Paupore3f40f342011-08-10 18:52:16 -07002149 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002150}
2151
2152
2153static struct msm_ts_platform_data msm_ts_data = {
Anirudh Ghayal82b74722012-01-19 15:35:34 +05302154 .min_x = 284,
2155 .max_x = 3801,
2156 .min_y = 155,
2157 .max_y = 3929,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002158 .min_press = 0,
2159 .max_press = 255,
2160 .inv_x = 4096,
2161 .inv_y = 4096,
2162 .can_wakeup = false,
2163};
2164
2165static struct marimba_tsadc_platform_data marimba_tsadc_pdata = {
2166 .marimba_tsadc_power = marimba_tsadc_power,
2167 .init = marimba_tsadc_init,
2168 .exit = marimba_tsadc_exit,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002169 .tsadc_prechg_en = true,
2170 .can_wakeup = false,
2171 .setup = {
2172 .pen_irq_en = true,
2173 .tsadc_en = true,
2174 },
2175 .params2 = {
2176 .input_clk_khz = 2400,
2177 .sample_prd = TSADC_CLK_3,
2178 },
2179 .params3 = {
2180 .prechg_time_nsecs = 6400,
2181 .stable_time_nsecs = 6400,
2182 .tsadc_test_mode = 0,
2183 },
2184 .tssc_data = &msm_ts_data,
2185};
2186
Justin Paupore3f40f342011-08-10 18:52:16 -07002187static struct regulator_bulk_data codec_regs[] = {
2188 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
2189};
2190
2191static int __init msm_marimba_codec_init(void)
2192{
2193 int rc = regulator_bulk_get(NULL, ARRAY_SIZE(codec_regs), codec_regs);
2194
2195 if (rc) {
2196 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2197 goto out;
2198 }
2199
2200 rc = regulator_bulk_set_voltage(ARRAY_SIZE(codec_regs), codec_regs);
2201 if (rc) {
2202 pr_err("%s: could not set regulator voltages: %d\n",
2203 __func__, rc);
2204 goto reg_free;
2205 }
2206
2207 return rc;
2208
2209reg_free:
2210 regulator_bulk_free(ARRAY_SIZE(codec_regs), codec_regs);
2211out:
2212 return rc;
2213}
2214
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002215static int msm_marimba_codec_power(int vreg_on)
2216{
Justin Paupore3f40f342011-08-10 18:52:16 -07002217 int rc = vreg_on ?
2218 regulator_bulk_enable(ARRAY_SIZE(codec_regs), codec_regs) :
2219 regulator_bulk_disable(ARRAY_SIZE(codec_regs), codec_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002220
Justin Paupore3f40f342011-08-10 18:52:16 -07002221 if (rc) {
2222 pr_err("%s: could not %sable regulators: %d",
2223 __func__, vreg_on ? "en" : "dis", rc);
2224 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002225 }
2226
Justin Paupore3f40f342011-08-10 18:52:16 -07002227 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002228}
2229
2230static struct marimba_codec_platform_data mariba_codec_pdata = {
2231 .marimba_codec_power = msm_marimba_codec_power,
2232#ifdef CONFIG_MARIMBA_CODEC
2233 .snddev_profile_init = msm_snddev_init,
2234#endif
2235};
2236
2237static struct marimba_platform_data marimba_pdata = {
2238 .slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR,
2239 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2240 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2241 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
2242 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
2243 .marimba_setup = msm_marimba_setup_power,
2244 .marimba_shutdown = msm_marimba_shutdown_power,
2245 .bahama_setup = msm_bahama_setup_power,
2246 .bahama_shutdown = msm_bahama_shutdown_power,
2247 .marimba_gpio_config = msm_marimba_gpio_config_svlte,
2248 .bahama_core_config = msm_bahama_core_config,
2249 .fm = &marimba_fm_pdata,
2250 .codec = &mariba_codec_pdata,
2251 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2252};
2253
2254static void __init msm7x30_init_marimba(void)
2255{
2256 int rc;
2257
Justin Paupore3f40f342011-08-10 18:52:16 -07002258 struct regulator_bulk_data regs[] = {
2259 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2260 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2261 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
2262 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002263
Justin Paupore3f40f342011-08-10 18:52:16 -07002264 rc = msm_marimba_codec_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002265
Justin Paupore3f40f342011-08-10 18:52:16 -07002266 if (rc) {
2267 pr_err("%s: msm_marimba_codec_init failed (%d)\n",
2268 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002269 return;
2270 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002271
2272 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
2273
2274 if (rc) {
2275 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2276 return;
2277 }
2278
2279 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
2280
2281 if (rc) {
2282 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2283 regulator_bulk_free(ARRAY_SIZE(regs), regs);
2284 return;
2285 }
2286
2287 vreg_marimba_1 = regs[0].consumer;
2288 vreg_marimba_2 = regs[1].consumer;
2289 vreg_bahama = regs[2].consumer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002290}
2291
2292static struct marimba_codec_platform_data timpani_codec_pdata = {
2293 .marimba_codec_power = msm_marimba_codec_power,
2294#ifdef CONFIG_TIMPANI_CODEC
2295 .snddev_profile_init = msm_snddev_init_timpani,
2296#endif
2297};
2298
2299static struct marimba_platform_data timpani_pdata = {
2300 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2301 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2302 .marimba_setup = msm_timpani_setup_power,
2303 .marimba_shutdown = msm_timpani_shutdown_power,
2304 .codec = &timpani_codec_pdata,
2305 .tsadc = &marimba_tsadc_pdata,
2306 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2307};
2308
2309#define TIMPANI_I2C_SLAVE_ADDR 0xD
2310
2311static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
2312 {
2313 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
2314 .platform_data = &timpani_pdata,
2315 },
2316};
2317
2318#ifdef CONFIG_MSM7KV2_AUDIO
2319static struct resource msm_aictl_resources[] = {
2320 {
2321 .name = "aictl",
2322 .start = 0xa5000100,
2323 .end = 0xa5000100,
2324 .flags = IORESOURCE_MEM,
2325 }
2326};
2327
2328static struct resource msm_mi2s_resources[] = {
2329 {
2330 .name = "hdmi",
2331 .start = 0xac900000,
2332 .end = 0xac900038,
2333 .flags = IORESOURCE_MEM,
2334 },
2335 {
2336 .name = "codec_rx",
2337 .start = 0xac940040,
2338 .end = 0xac940078,
2339 .flags = IORESOURCE_MEM,
2340 },
2341 {
2342 .name = "codec_tx",
2343 .start = 0xac980080,
2344 .end = 0xac9800B8,
2345 .flags = IORESOURCE_MEM,
2346 }
2347
2348};
2349
2350static struct msm_lpa_platform_data lpa_pdata = {
2351 .obuf_hlb_size = 0x2BFF8,
2352 .dsp_proc_id = 0,
2353 .app_proc_id = 2,
2354 .nosb_config = {
2355 .llb_min_addr = 0,
2356 .llb_max_addr = 0x3ff8,
2357 .sb_min_addr = 0,
2358 .sb_max_addr = 0,
2359 },
2360 .sb_config = {
2361 .llb_min_addr = 0,
2362 .llb_max_addr = 0x37f8,
2363 .sb_min_addr = 0x3800,
2364 .sb_max_addr = 0x3ff8,
2365 }
2366};
2367
2368static struct resource msm_lpa_resources[] = {
2369 {
2370 .name = "lpa",
2371 .start = 0xa5000000,
2372 .end = 0xa50000a0,
2373 .flags = IORESOURCE_MEM,
2374 }
2375};
2376
2377static struct resource msm_aux_pcm_resources[] = {
2378
2379 {
2380 .name = "aux_codec_reg_addr",
2381 .start = 0xac9c00c0,
2382 .end = 0xac9c00c8,
2383 .flags = IORESOURCE_MEM,
2384 },
2385 {
2386 .name = "aux_pcm_dout",
2387 .start = 138,
2388 .end = 138,
2389 .flags = IORESOURCE_IO,
2390 },
2391 {
2392 .name = "aux_pcm_din",
2393 .start = 139,
2394 .end = 139,
2395 .flags = IORESOURCE_IO,
2396 },
2397 {
2398 .name = "aux_pcm_syncout",
2399 .start = 140,
2400 .end = 140,
2401 .flags = IORESOURCE_IO,
2402 },
2403 {
2404 .name = "aux_pcm_clkin_a",
2405 .start = 141,
2406 .end = 141,
2407 .flags = IORESOURCE_IO,
2408 },
2409};
2410
2411static struct platform_device msm_aux_pcm_device = {
2412 .name = "msm_aux_pcm",
2413 .id = 0,
2414 .num_resources = ARRAY_SIZE(msm_aux_pcm_resources),
2415 .resource = msm_aux_pcm_resources,
2416};
2417
2418struct platform_device msm_aictl_device = {
2419 .name = "audio_interct",
2420 .id = 0,
2421 .num_resources = ARRAY_SIZE(msm_aictl_resources),
2422 .resource = msm_aictl_resources,
2423};
2424
2425struct platform_device msm_mi2s_device = {
2426 .name = "mi2s",
2427 .id = 0,
2428 .num_resources = ARRAY_SIZE(msm_mi2s_resources),
2429 .resource = msm_mi2s_resources,
2430};
2431
2432struct platform_device msm_lpa_device = {
2433 .name = "lpa",
2434 .id = 0,
2435 .num_resources = ARRAY_SIZE(msm_lpa_resources),
2436 .resource = msm_lpa_resources,
2437 .dev = {
2438 .platform_data = &lpa_pdata,
2439 },
2440};
2441#endif /* CONFIG_MSM7KV2_AUDIO */
2442
2443#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2444 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2445 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2446 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2447 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2448 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2449#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2450 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2451 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2452 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2453 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2454 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2455 #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2456 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2457 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2458 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2459 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2460 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2461 #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2462 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2463 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2464 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2465 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2466 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2467#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
2468
2469static unsigned int dec_concurrency_table[] = {
2470 /* Audio LP */
2471 0,
2472 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2473 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2474 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2475 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)|
2476 (1<<MSM_ADSP_OP_DM)),
2477
2478 /* Concurrency 1 */
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 2 */
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_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2491
2492 /* Concurrency 3 */
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_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2497 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2498
2499 /* Concurrency 4 */
2500 (DEC4_FORMAT),
2501 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2502 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(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 5 */
2507 (DEC4_FORMAT),
2508 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(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 /* Concurrency 6 */
2514 (DEC4_FORMAT),
2515 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2516 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2517 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2518 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2519};
2520
2521#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
2522 .module_queueid = queueid, .module_decid = decid, \
2523 .nr_codec_support = nr_codec}
2524
2525#define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
2526 .max_instances_same_dec = max_instance_same, \
2527 .max_instances_diff_dec = max_instance_diff}
2528
2529static struct msm_adspdec_info dec_info_list[] = {
2530 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
2531 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
2532 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
2533 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
2534 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
2535};
2536
2537static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
2538 /* Non Turbo Mode */
2539 {
2540 DEC_INSTANCE(4, 3), /* WAV */
2541 DEC_INSTANCE(4, 3), /* ADPCM */
2542 DEC_INSTANCE(4, 2), /* MP3 */
2543 DEC_INSTANCE(0, 0), /* Real Audio */
2544 DEC_INSTANCE(4, 2), /* WMA */
2545 DEC_INSTANCE(3, 2), /* AAC */
2546 DEC_INSTANCE(0, 0), /* Reserved */
2547 DEC_INSTANCE(0, 0), /* MIDI */
2548 DEC_INSTANCE(4, 3), /* YADPCM */
2549 DEC_INSTANCE(4, 3), /* QCELP */
2550 DEC_INSTANCE(4, 3), /* AMRNB */
2551 DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
2552 DEC_INSTANCE(4, 3), /* EVRC */
2553 DEC_INSTANCE(1, 1), /* WMAPRO */
2554 },
2555 /* Turbo Mode */
2556 {
2557 DEC_INSTANCE(4, 3), /* WAV */
2558 DEC_INSTANCE(4, 3), /* ADPCM */
2559 DEC_INSTANCE(4, 3), /* MP3 */
2560 DEC_INSTANCE(0, 0), /* Real Audio */
2561 DEC_INSTANCE(4, 3), /* WMA */
2562 DEC_INSTANCE(4, 3), /* AAC */
2563 DEC_INSTANCE(0, 0), /* Reserved */
2564 DEC_INSTANCE(0, 0), /* MIDI */
2565 DEC_INSTANCE(4, 3), /* YADPCM */
2566 DEC_INSTANCE(4, 3), /* QCELP */
2567 DEC_INSTANCE(4, 3), /* AMRNB */
2568 DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
2569 DEC_INSTANCE(4, 3), /* EVRC */
2570 DEC_INSTANCE(1, 2), /* WMAPRO */
2571 },
2572};
2573
2574static struct msm_adspdec_database msm_device_adspdec_database = {
2575 .num_dec = ARRAY_SIZE(dec_info_list),
2576 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
2577 ARRAY_SIZE(dec_info_list)),
2578 .dec_concurrency_table = dec_concurrency_table,
2579 .dec_info_list = dec_info_list,
2580 .dec_instance_list = &dec_instance_list[0][0],
2581};
2582
2583static struct platform_device msm_device_adspdec = {
2584 .name = "msm_adspdec",
2585 .id = -1,
2586 .dev = {
2587 .platform_data = &msm_device_adspdec_database
2588 },
2589};
2590
2591static struct resource smc91x_resources[] = {
2592 [0] = {
2593 .start = 0x8A000300,
2594 .end = 0x8A0003ff,
2595 .flags = IORESOURCE_MEM,
2596 },
2597 [1] = {
2598 .start = MSM_GPIO_TO_INT(156),
2599 .end = MSM_GPIO_TO_INT(156),
2600 .flags = IORESOURCE_IRQ,
2601 },
2602};
2603
2604static struct platform_device smc91x_device = {
2605 .name = "smc91x",
2606 .id = 0,
2607 .num_resources = ARRAY_SIZE(smc91x_resources),
2608 .resource = smc91x_resources,
2609};
2610
2611static struct smsc911x_platform_config smsc911x_config = {
2612 .phy_interface = PHY_INTERFACE_MODE_MII,
2613 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
2614 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
2615 .flags = SMSC911X_USE_32BIT,
2616};
2617
2618static struct resource smsc911x_resources[] = {
2619 [0] = {
2620 .start = 0x8D000000,
2621 .end = 0x8D000100,
2622 .flags = IORESOURCE_MEM,
2623 },
2624 [1] = {
2625 .start = MSM_GPIO_TO_INT(88),
2626 .end = MSM_GPIO_TO_INT(88),
2627 .flags = IORESOURCE_IRQ,
2628 },
2629};
2630
2631static struct platform_device smsc911x_device = {
2632 .name = "smsc911x",
2633 .id = -1,
2634 .num_resources = ARRAY_SIZE(smsc911x_resources),
2635 .resource = smsc911x_resources,
2636 .dev = {
2637 .platform_data = &smsc911x_config,
2638 },
2639};
2640
2641static struct msm_gpio smsc911x_gpios[] = {
2642 { GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" },
2643 { GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" },
2644 { GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" },
2645 { GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" },
2646 { GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" },
2647 { GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" },
2648 { GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" },
2649 { GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" },
2650};
2651
2652static void msm7x30_cfg_smsc911x(void)
2653{
2654 int rc;
2655
2656 rc = msm_gpios_request_enable(smsc911x_gpios,
2657 ARRAY_SIZE(smsc911x_gpios));
2658 if (rc)
2659 pr_err("%s: unable to enable gpios\n", __func__);
2660}
2661
2662#ifdef CONFIG_USB_G_ANDROID
2663static struct android_usb_platform_data android_usb_pdata = {
2664 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2665};
2666
2667static struct platform_device android_usb_device = {
2668 .name = "android_usb",
2669 .id = -1,
2670 .dev = {
2671 .platform_data = &android_usb_pdata,
2672 },
2673};
2674#endif
2675
2676static struct msm_gpio optnav_config_data[] = {
2677 { GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA),
2678 "optnav_chip_select" },
2679};
2680
Justin Paupore3f40f342011-08-10 18:52:16 -07002681static struct regulator_bulk_data optnav_regulators[] = {
2682 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2683 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
2684 { .supply = "gp9", .min_uV = 1800000, .max_uV = 1800000 },
2685 { .supply = "usb", .min_uV = 3300000, .max_uV = 3300000 },
2686};
2687
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002688static void __iomem *virtual_optnav;
2689
2690static int optnav_gpio_setup(void)
2691{
2692 int rc = -ENODEV;
2693 rc = msm_gpios_request_enable(optnav_config_data,
2694 ARRAY_SIZE(optnav_config_data));
2695
Justin Paupore3f40f342011-08-10 18:52:16 -07002696 if (rc)
2697 return rc;
2698
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002699 /* Configure the FPGA for GPIOs */
2700 virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4);
2701 if (!virtual_optnav) {
2702 pr_err("%s:Could not ioremap region\n", __func__);
2703 return -ENOMEM;
2704 }
2705 /*
2706 * Configure the FPGA to set GPIO 19 as
2707 * normal, active(enabled), output(MSM to SURF)
2708 */
2709 writew(0x311E, virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002710
2711 rc = regulator_bulk_get(NULL, ARRAY_SIZE(optnav_regulators),
2712 optnav_regulators);
2713 if (rc)
2714 return rc;
2715
2716 rc = regulator_bulk_set_voltage(ARRAY_SIZE(optnav_regulators),
2717 optnav_regulators);
2718
2719 if (rc)
2720 goto regulator_put;
2721
2722 return rc;
2723
2724regulator_put:
2725 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002726 return rc;
2727}
2728
2729static void optnav_gpio_release(void)
2730{
2731 msm_gpios_disable_free(optnav_config_data,
2732 ARRAY_SIZE(optnav_config_data));
2733 iounmap(virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002734 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002735}
2736
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002737static int optnav_enable(void)
2738{
2739 int rc;
2740 /*
2741 * Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
2742 * for I2C communication with keyboard.
2743 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002744
Justin Paupore3f40f342011-08-10 18:52:16 -07002745 rc = regulator_bulk_enable(ARRAY_SIZE(optnav_regulators),
2746 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002747
Justin Paupore3f40f342011-08-10 18:52:16 -07002748 if (rc)
2749 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002750
2751 /* Enable the chip select GPIO */
2752 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2753 gpio_set_value(OPTNAV_CHIP_SELECT, 0);
2754
2755 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002756}
2757
2758static void optnav_disable(void)
2759{
Justin Paupore3f40f342011-08-10 18:52:16 -07002760 regulator_bulk_disable(ARRAY_SIZE(optnav_regulators),
2761 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002762
2763 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2764}
2765
2766static struct ofn_atlab_platform_data optnav_data = {
2767 .gpio_setup = optnav_gpio_setup,
2768 .gpio_release = optnav_gpio_release,
2769 .optnav_on = optnav_enable,
2770 .optnav_off = optnav_disable,
2771 .rotate_xy = 0,
2772 .function1 = {
2773 .no_motion1_en = true,
2774 .touch_sensor_en = true,
2775 .ofn_en = true,
2776 .clock_select_khz = 1500,
2777 .cpi_selection = 1200,
2778 },
2779 .function2 = {
2780 .invert_y = false,
2781 .invert_x = true,
2782 .swap_x_y = false,
2783 .hold_a_b_en = true,
2784 .motion_filter_en = true,
2785 },
2786};
2787
2788static int hdmi_comm_power(int on, int show);
2789static int hdmi_init_irq(void);
2790static int hdmi_enable_5v(int on);
2791static int hdmi_core_power(int on, int show);
2792static int hdmi_cec_power(int on);
2793static bool hdmi_check_hdcp_hw_support(void);
2794
2795static struct msm_hdmi_platform_data adv7520_hdmi_data = {
2796 .irq = MSM_GPIO_TO_INT(18),
2797 .comm_power = hdmi_comm_power,
2798 .init_irq = hdmi_init_irq,
2799 .enable_5v = hdmi_enable_5v,
2800 .core_power = hdmi_core_power,
2801 .cec_power = hdmi_cec_power,
2802 .check_hdcp_hw_support = hdmi_check_hdcp_hw_support,
2803};
2804
2805#ifdef CONFIG_BOSCH_BMA150
Justin Paupore3f40f342011-08-10 18:52:16 -07002806
2807static struct regulator_bulk_data sensors_ldo[] = {
2808 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2809 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
2810};
2811
2812static int __init sensors_ldo_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002813{
2814 int rc;
2815
Justin Paupore3f40f342011-08-10 18:52:16 -07002816 rc = regulator_bulk_get(NULL, ARRAY_SIZE(sensors_ldo), sensors_ldo);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002817
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002818 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002819 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2820 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002821 }
2822
Justin Paupore3f40f342011-08-10 18:52:16 -07002823 rc = regulator_bulk_set_voltage(ARRAY_SIZE(sensors_ldo), sensors_ldo);
2824
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002825 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002826 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2827 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002828 }
2829
2830 return 0;
2831
Justin Paupore3f40f342011-08-10 18:52:16 -07002832reg_free:
2833 regulator_bulk_free(ARRAY_SIZE(sensors_ldo), sensors_ldo);
2834out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002835 return rc;
2836}
2837
Justin Paupore3f40f342011-08-10 18:52:16 -07002838static int sensors_ldo_set(int on)
2839{
2840 int rc = on ?
2841 regulator_bulk_enable(ARRAY_SIZE(sensors_ldo), sensors_ldo) :
2842 regulator_bulk_disable(ARRAY_SIZE(sensors_ldo), sensors_ldo);
2843
2844 if (rc)
2845 pr_err("%s: could not %sable regulators: %d\n",
2846 __func__, on ? "en" : "dis", rc);
2847
2848 return rc;
2849}
2850
2851static int sensors_ldo_enable(void)
2852{
2853 return sensors_ldo_set(1);
2854}
2855
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002856static void sensors_ldo_disable(void)
2857{
Justin Paupore3f40f342011-08-10 18:52:16 -07002858 sensors_ldo_set(0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002859}
Justin Paupore3f40f342011-08-10 18:52:16 -07002860
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002861static struct bma150_platform_data bma150_data = {
2862 .power_on = sensors_ldo_enable,
2863 .power_off = sensors_ldo_disable,
2864};
2865
2866static struct i2c_board_info bma150_board_info[] __initdata = {
2867 {
2868 I2C_BOARD_INFO("bma150", 0x38),
2869 .flags = I2C_CLIENT_WAKE,
2870 .irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
2871 .platform_data = &bma150_data,
2872 },
2873};
2874#endif
2875
2876static struct i2c_board_info msm_i2c_board_info[] = {
2877 {
2878 I2C_BOARD_INFO("m33c01", OPTNAV_I2C_SLAVE_ADDR),
2879 .irq = MSM_GPIO_TO_INT(OPTNAV_IRQ),
2880 .platform_data = &optnav_data,
2881 },
2882 {
2883 I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR),
2884 .platform_data = &adv7520_hdmi_data,
2885 },
2886};
2887
2888static struct i2c_board_info msm_marimba_board_info[] = {
2889 {
2890 I2C_BOARD_INFO("marimba", 0xc),
2891 .platform_data = &marimba_pdata,
2892 }
2893};
2894
2895
2896static struct msm_handset_platform_data hs_platform_data = {
2897 .hs_name = "7k_handset",
2898 .pwr_key_delay_ms = 500, /* 0 will disable end key */
2899};
2900
2901static struct platform_device hs_device = {
2902 .name = "msm-handset",
2903 .id = -1,
2904 .dev = {
2905 .platform_data = &hs_platform_data,
2906 },
2907};
2908
2909static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
2910 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
2911 .idle_supported = 1,
2912 .suspend_supported = 1,
2913 .idle_enabled = 1,
2914 .suspend_enabled = 1,
2915 .latency = 8594,
2916 .residency = 23740,
2917 },
2918 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
2919 .idle_supported = 1,
2920 .suspend_supported = 1,
2921 .idle_enabled = 1,
2922 .suspend_enabled = 1,
2923 .latency = 4594,
2924 .residency = 23740,
2925 },
2926 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE] = {
2927#ifdef CONFIG_MSM_STANDALONE_POWER_COLLAPSE
2928 .idle_supported = 1,
2929 .suspend_supported = 1,
2930 .idle_enabled = 1,
2931 .suspend_enabled = 0,
2932#else /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
2933 .idle_supported = 0,
2934 .suspend_supported = 0,
2935 .idle_enabled = 0,
2936 .suspend_enabled = 0,
2937#endif /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
2938 .latency = 500,
2939 .residency = 6000,
2940 },
2941 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
2942 .idle_supported = 1,
2943 .suspend_supported = 1,
2944 .idle_enabled = 0,
2945 .suspend_enabled = 1,
2946 .latency = 443,
2947 .residency = 1098,
2948 },
2949 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
2950 .idle_supported = 1,
2951 .suspend_supported = 1,
2952 .idle_enabled = 1,
2953 .suspend_enabled = 1,
2954 .latency = 2,
2955 .residency = 0,
2956 },
2957};
2958
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06002959static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
2960 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
2961 .v_addr = (uint32_t *)PAGE_OFFSET,
2962};
2963
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002964static struct resource qsd_spi_resources[] = {
2965 {
2966 .name = "spi_irq_in",
2967 .start = INT_SPI_INPUT,
2968 .end = INT_SPI_INPUT,
2969 .flags = IORESOURCE_IRQ,
2970 },
2971 {
2972 .name = "spi_irq_out",
2973 .start = INT_SPI_OUTPUT,
2974 .end = INT_SPI_OUTPUT,
2975 .flags = IORESOURCE_IRQ,
2976 },
2977 {
2978 .name = "spi_irq_err",
2979 .start = INT_SPI_ERROR,
2980 .end = INT_SPI_ERROR,
2981 .flags = IORESOURCE_IRQ,
2982 },
2983 {
2984 .name = "spi_base",
2985 .start = 0xA8000000,
2986 .end = 0xA8000000 + SZ_4K - 1,
2987 .flags = IORESOURCE_MEM,
2988 },
2989 {
2990 .name = "spidm_channels",
2991 .flags = IORESOURCE_DMA,
2992 },
2993 {
2994 .name = "spidm_crci",
2995 .flags = IORESOURCE_DMA,
2996 },
2997};
2998
2999#define AMDH0_BASE_PHYS 0xAC200000
3000#define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
3001static int msm_qsd_spi_dma_config(void)
3002{
3003 void __iomem *ct_adm_base = 0;
3004 u32 spi_mux = 0;
3005 int ret = 0;
3006
3007 ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
3008 if (!ct_adm_base) {
3009 pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
3010 return -ENOMEM;
3011 }
3012
3013 spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
3014
3015 qsd_spi_resources[4].start = DMOV_USB_CHAN;
3016 qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
3017
3018 switch (spi_mux) {
3019 case (1):
3020 qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
3021 qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
3022 break;
3023 case (2):
3024 qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
3025 qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
3026 break;
3027 case (3):
3028 qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
3029 qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
3030 break;
3031 default:
3032 ret = -ENOENT;
3033 }
3034
3035 iounmap(ct_adm_base);
3036
3037 return ret;
3038}
3039
3040static struct platform_device qsd_device_spi = {
3041 .name = "spi_qsd",
3042 .id = 0,
3043 .num_resources = ARRAY_SIZE(qsd_spi_resources),
3044 .resource = qsd_spi_resources,
3045};
3046
3047#ifdef CONFIG_SPI_QSD
3048static struct spi_board_info lcdc_sharp_spi_board_info[] __initdata = {
3049 {
3050 .modalias = "lcdc_sharp_ls038y7dx01",
3051 .mode = SPI_MODE_1,
3052 .bus_num = 0,
3053 .chip_select = 0,
3054 .max_speed_hz = 26331429,
3055 }
3056};
3057static struct spi_board_info lcdc_toshiba_spi_board_info[] __initdata = {
3058 {
3059 .modalias = "lcdc_toshiba_ltm030dd40",
3060 .mode = SPI_MODE_3|SPI_CS_HIGH,
3061 .bus_num = 0,
3062 .chip_select = 0,
3063 .max_speed_hz = 9963243,
3064 }
3065};
3066#endif
3067
3068static struct msm_gpio qsd_spi_gpio_config_data[] = {
3069 { GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3070 { GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3071 { GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" },
3072 { GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3073};
3074
3075static int msm_qsd_spi_gpio_config(void)
3076{
3077 return msm_gpios_request_enable(qsd_spi_gpio_config_data,
3078 ARRAY_SIZE(qsd_spi_gpio_config_data));
3079}
3080
3081static void msm_qsd_spi_gpio_release(void)
3082{
3083 msm_gpios_disable_free(qsd_spi_gpio_config_data,
3084 ARRAY_SIZE(qsd_spi_gpio_config_data));
3085}
3086
3087static struct msm_spi_platform_data qsd_spi_pdata = {
3088 .max_clock_speed = 26331429,
3089 .gpio_config = msm_qsd_spi_gpio_config,
3090 .gpio_release = msm_qsd_spi_gpio_release,
3091 .dma_config = msm_qsd_spi_dma_config,
3092};
3093
3094static void __init msm_qsd_spi_init(void)
3095{
3096 qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
3097}
3098
3099#ifdef CONFIG_USB_EHCI_MSM_72K
3100static void msm_hsusb_vbus_power(unsigned phy_info, int on)
3101{
3102 int rc;
3103 static int vbus_is_on;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303104 struct pm8xxx_gpio_init_info usb_vbus = {
3105 PM8058_GPIO_PM_TO_SYS(36),
3106 {
3107 .direction = PM_GPIO_DIR_OUT,
3108 .pull = PM_GPIO_PULL_NO,
3109 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3110 .output_value = 1,
3111 .vin_sel = 2,
3112 .out_strength = PM_GPIO_STRENGTH_MED,
3113 .function = PM_GPIO_FUNC_NORMAL,
3114 .inv_int_pol = 0,
3115 },
3116 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003117
3118 /* If VBUS is already on (or off), do nothing. */
3119 if (unlikely(on == vbus_is_on))
3120 return;
3121
3122 if (on) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303123 rc = pm8xxx_gpio_config(usb_vbus.gpio, &usb_vbus.config);
3124 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003125 pr_err("%s PMIC GPIO 36 write failed\n", __func__);
3126 return;
3127 }
3128 } else {
3129 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(36), 0);
3130 }
3131
3132 vbus_is_on = on;
3133}
3134
3135static struct msm_usb_host_platform_data msm_usb_host_pdata = {
3136 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
3137 .vbus_power = msm_hsusb_vbus_power,
3138 .power_budget = 180,
3139};
3140#endif
3141
3142#ifdef CONFIG_USB_MSM_OTG_72K
3143static int hsusb_rpc_connect(int connect)
3144{
3145 if (connect)
3146 return msm_hsusb_rpc_connect();
3147 else
3148 return msm_hsusb_rpc_close();
3149}
3150#endif
3151
3152#ifdef CONFIG_USB_MSM_OTG_72K
Justin Paupore3f40f342011-08-10 18:52:16 -07003153static struct regulator *vreg_3p3;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003154static int msm_hsusb_ldo_init(int init)
3155{
3156 uint32_t version = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07003157 int def_vol = 3400000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003158
3159 version = socinfo_get_version();
3160
3161 if (SOCINFO_VERSION_MAJOR(version) >= 2 &&
3162 SOCINFO_VERSION_MINOR(version) >= 1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003163 def_vol = 3075000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003164 pr_debug("%s: default voltage:%d\n", __func__, def_vol);
3165 }
3166
3167 if (init) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003168 vreg_3p3 = regulator_get(NULL, "usb");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003169 if (IS_ERR(vreg_3p3))
3170 return PTR_ERR(vreg_3p3);
Justin Paupore3f40f342011-08-10 18:52:16 -07003171 regulator_set_voltage(vreg_3p3, def_vol, def_vol);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003172 } else
Justin Paupore3f40f342011-08-10 18:52:16 -07003173 regulator_put(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003174
3175 return 0;
3176}
3177
3178static int msm_hsusb_ldo_enable(int enable)
3179{
3180 static int ldo_status;
3181
3182 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3183 return -ENODEV;
3184
3185 if (ldo_status == enable)
3186 return 0;
3187
3188 ldo_status = enable;
3189
3190 if (enable)
Justin Paupore3f40f342011-08-10 18:52:16 -07003191 return regulator_enable(vreg_3p3);
3192 else
3193 return regulator_disable(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003194}
3195
3196static int msm_hsusb_ldo_set_voltage(int mV)
3197{
Justin Paupore3f40f342011-08-10 18:52:16 -07003198 static int cur_voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003199
3200 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3201 return -ENODEV;
3202
3203 if (cur_voltage == mV)
3204 return 0;
3205
3206 cur_voltage = mV;
3207
3208 pr_debug("%s: (%d)\n", __func__, mV);
3209
Justin Paupore3f40f342011-08-10 18:52:16 -07003210 return regulator_set_voltage(vreg_3p3, mV*1000, mV*1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003211}
3212#endif
3213
3214#ifndef CONFIG_USB_EHCI_MSM_72K
3215static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init);
3216#endif
3217static struct msm_otg_platform_data msm_otg_pdata = {
3218 .rpc_connect = hsusb_rpc_connect,
3219
3220#ifndef CONFIG_USB_EHCI_MSM_72K
3221 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
3222#else
3223 .vbus_power = msm_hsusb_vbus_power,
3224#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003225 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
3226 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
3227 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
3228 .se1_gating = SE1_GATING_DISABLE,
3229 .chg_vbus_draw = hsusb_chg_vbus_draw,
3230 .chg_connected = hsusb_chg_connected,
3231 .chg_init = hsusb_chg_init,
3232 .ldo_enable = msm_hsusb_ldo_enable,
3233 .ldo_init = msm_hsusb_ldo_init,
3234 .ldo_set_voltage = msm_hsusb_ldo_set_voltage,
3235};
3236
3237#ifdef CONFIG_USB_GADGET
3238static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
3239 .is_phy_status_timer_on = 1,
3240};
3241#endif
3242#ifndef CONFIG_USB_EHCI_MSM_72K
3243typedef void (*notify_vbus_state) (int);
3244notify_vbus_state notify_vbus_state_func_ptr;
3245int vbus_on_irq;
3246static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
3247{
3248 pr_info("%s: vbus notification from pmic\n", __func__);
3249
3250 (*notify_vbus_state_func_ptr) (1);
3251
3252 return IRQ_HANDLED;
3253}
3254static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
3255{
3256 int ret;
3257
3258 if (init) {
3259 if (!callback)
3260 return -ENODEV;
3261
3262 notify_vbus_state_func_ptr = callback;
3263 vbus_on_irq = platform_get_irq_byname(&msm_device_otg,
3264 "vbus_on");
3265 if (vbus_on_irq <= 0) {
3266 pr_err("%s: unable to get vbus on irq\n", __func__);
3267 return -ENODEV;
3268 }
3269
3270 ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq,
3271 IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
3272 if (ret < 0) {
3273 pr_info("%s: request_irq for vbus_on"
3274 "interrupt failed\n", __func__);
3275 return ret;
3276 }
3277 msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
3278 return 0;
3279 } else {
3280 free_irq(vbus_on_irq, 0);
3281 notify_vbus_state_func_ptr = NULL;
3282 return 0;
3283 }
3284}
3285#endif
3286
3287static struct android_pmem_platform_data android_pmem_pdata = {
3288 .name = "pmem",
3289 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
3290 .cached = 1,
3291 .memory_type = MEMTYPE_EBI0,
3292};
3293
3294static struct platform_device android_pmem_device = {
3295 .name = "android_pmem",
3296 .id = 0,
3297 .dev = { .platform_data = &android_pmem_pdata },
3298};
3299
3300#ifndef CONFIG_SPI_QSD
3301static int lcdc_gpio_array_num[] = {
3302 45, /* spi_clk */
3303 46, /* spi_cs */
3304 47, /* spi_mosi */
3305 48, /* spi_miso */
3306 };
3307
3308static struct msm_gpio lcdc_gpio_config_data[] = {
3309 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3310 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3311 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
3312 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3313};
3314
3315static void lcdc_config_gpios(int enable)
3316{
3317 if (enable) {
3318 msm_gpios_request_enable(lcdc_gpio_config_data,
3319 ARRAY_SIZE(
3320 lcdc_gpio_config_data));
3321 } else
3322 msm_gpios_disable_free(lcdc_gpio_config_data,
3323 ARRAY_SIZE(
3324 lcdc_gpio_config_data));
3325}
3326#endif
3327
3328static struct msm_panel_common_pdata lcdc_sharp_panel_data = {
3329#ifndef CONFIG_SPI_QSD
3330 .panel_config_gpio = lcdc_config_gpios,
3331 .gpio_num = lcdc_gpio_array_num,
3332#endif
3333 .gpio = 2, /* LPG PMIC_GPIO26 channel number */
3334};
3335
3336static struct platform_device lcdc_sharp_panel_device = {
3337 .name = "lcdc_sharp_wvga",
3338 .id = 0,
3339 .dev = {
3340 .platform_data = &lcdc_sharp_panel_data,
3341 }
3342};
3343
3344static struct msm_gpio dtv_panel_irq_gpios[] = {
3345 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
3346 "hdmi_int" },
3347};
3348
3349static struct msm_gpio dtv_panel_gpios[] = {
3350 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
3351 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
3352 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
3353 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
3354 { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
3355 { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
3356 { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
3357 { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
3358 { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
3359 { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
3360 { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
3361 { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
3362 { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
3363 { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
3364 { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
3365 { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
3366 { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
3367 { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
3368 { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
3369 { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
3370 { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
3371 { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
3372 { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
3373 { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
3374 { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
3375 { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
3376 { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
3377 { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
3378 { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
3379 { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
3380 { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
3381 { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
3382};
3383
3384
3385#ifdef HDMI_RESET
3386static unsigned dtv_reset_gpio =
3387 GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3388#endif
3389
Justin Paupore3f40f342011-08-10 18:52:16 -07003390static struct regulator_bulk_data hdmi_core_regs[] = {
3391 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3392};
3393
3394static struct regulator_bulk_data hdmi_comm_regs[] = {
3395 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3396 { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 },
3397};
3398
3399static struct regulator_bulk_data hdmi_cec_regs[] = {
3400 { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 },
3401};
3402
3403static int __init hdmi_init_regs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003404{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003405 int rc;
3406
Justin Paupore3f40f342011-08-10 18:52:16 -07003407 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs),
3408 hdmi_core_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003409
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003410 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003411 pr_err("%s: could not get %s regulators: %d\n",
3412 __func__, "core", rc);
3413 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003414 }
3415
Justin Paupore3f40f342011-08-10 18:52:16 -07003416 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs),
3417 hdmi_core_regs);
3418
3419 if (rc) {
3420 pr_err("%s: could not set %s voltages: %d\n",
3421 __func__, "core", rc);
3422 goto free_core;
3423 }
3424
3425 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs),
3426 hdmi_comm_regs);
3427
3428 if (rc) {
3429 pr_err("%s: could not get %s regulators: %d\n",
3430 __func__, "comm", rc);
3431 goto free_core;
3432 }
3433
3434 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs),
3435 hdmi_comm_regs);
3436
3437 if (rc) {
3438 pr_err("%s: could not set %s voltages: %d\n",
3439 __func__, "comm", rc);
3440 goto free_comm;
3441 }
3442
3443 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs),
3444 hdmi_cec_regs);
3445
3446 if (rc) {
3447 pr_err("%s: could not get %s regulators: %d\n",
3448 __func__, "cec", rc);
3449 goto free_comm;
3450 }
3451
3452 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs),
3453 hdmi_cec_regs);
3454
3455 if (rc) {
3456 pr_err("%s: could not set %s voltages: %d\n",
3457 __func__, "cec", rc);
3458 goto free_cec;
3459 }
3460
3461 return 0;
3462
3463free_cec:
3464 regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs);
3465free_comm:
3466 regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs);
3467free_core:
3468 regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs);
3469out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003470 return rc;
3471}
3472
Justin Paupore3f40f342011-08-10 18:52:16 -07003473static int hdmi_init_irq(void)
3474{
3475 int rc = msm_gpios_enable(dtv_panel_irq_gpios,
3476 ARRAY_SIZE(dtv_panel_irq_gpios));
3477 if (rc < 0) {
3478 pr_err("%s: gpio enable failed: %d\n", __func__, rc);
3479 return rc;
3480 }
3481 pr_info("%s\n", __func__);
3482
3483 return 0;
3484}
3485
3486static int hdmi_enable_5v(int on)
3487{
3488 int pmic_gpio_hdmi_5v_en ;
3489
3490 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
3491 machine_is_msm7x30_fluid())
3492 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
3493 else
3494 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
3495
3496 pr_info("%s: %d\n", __func__, on);
3497 if (on) {
3498 int rc;
3499 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
3500 "hdmi_5V_en");
3501 if (rc) {
3502 pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
3503 __func__);
3504 return rc;
3505 }
3506 gpio_set_value_cansleep(
3507 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
3508 } else {
3509 gpio_set_value_cansleep(
3510 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
3511 gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
3512 }
3513 return 0;
3514}
3515
3516static int hdmi_comm_power(int on, int show)
3517{
3518 if (show)
3519 pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
3520 return on ?
3521 regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs),
3522 hdmi_comm_regs) :
3523 regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs),
3524 hdmi_comm_regs);
3525}
3526
3527static int hdmi_core_power(int on, int show)
3528{
3529 if (show)
3530 pr_info("%s: %d <LDO8>\n", __func__, on);
3531 return on ?
3532 regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs),
3533 hdmi_core_regs) :
3534 regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs),
3535 hdmi_core_regs);
3536}
3537
3538static int hdmi_cec_power(int on)
3539{
3540 pr_info("%s: %d <LDO17>\n", __func__, on);
3541 return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs),
3542 hdmi_cec_regs) :
3543 regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs),
3544 hdmi_cec_regs);
3545}
3546
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003547#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
3548/* there is an i2c address conflict between adv7520 and bma150 sensor after
3549 * power up on fluid. As a solution, the default address of adv7520's packet
3550 * memory is changed as soon as possible
3551 */
3552static int __init fluid_i2c_address_fixup(void)
3553{
3554 unsigned char wBuff[16];
3555 unsigned char rBuff[16];
3556 struct i2c_msg msgs[3];
3557 int res;
3558 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003559 struct i2c_adapter *adapter;
3560
3561 if (machine_is_msm7x30_fluid()) {
3562 adapter = i2c_get_adapter(0);
3563 if (!adapter) {
3564 pr_err("%s: invalid i2c adapter\n", __func__);
3565 return PTR_ERR(adapter);
3566 }
3567
3568 /* turn on LDO8 */
Justin Paupore3f40f342011-08-10 18:52:16 -07003569 rc = hdmi_core_power(1, 0);
3570 if (rc) {
3571 pr_err("%s: could not enable hdmi core regs: %d",
3572 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003573 goto adapter_put;
3574 }
3575
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003576 /* change packet memory address to 0x74 */
3577 wBuff[0] = 0x45;
3578 wBuff[1] = 0x74;
3579
3580 msgs[0].addr = ADV7520_I2C_ADDR;
3581 msgs[0].flags = 0;
3582 msgs[0].buf = (unsigned char *) wBuff;
3583 msgs[0].len = 2;
3584
3585 res = i2c_transfer(adapter, msgs, 1);
3586 if (res != 1) {
3587 pr_err("%s: error writing adv7520\n", __func__);
3588 goto ldo8_disable;
3589 }
3590
3591 /* powerdown adv7520 using bit 6 */
3592 /* i2c read first */
3593 wBuff[0] = 0x41;
3594
3595 msgs[0].addr = ADV7520_I2C_ADDR;
3596 msgs[0].flags = 0;
3597 msgs[0].buf = (unsigned char *) wBuff;
3598 msgs[0].len = 1;
3599
3600 msgs[1].addr = ADV7520_I2C_ADDR;
3601 msgs[1].flags = I2C_M_RD;
3602 msgs[1].buf = rBuff;
3603 msgs[1].len = 1;
3604 res = i2c_transfer(adapter, msgs, 2);
3605 if (res != 2) {
3606 pr_err("%s: error reading adv7520\n", __func__);
3607 goto ldo8_disable;
3608 }
3609
3610 /* i2c write back */
3611 wBuff[0] = 0x41;
3612 wBuff[1] = rBuff[0] | 0x40;
3613
3614 msgs[0].addr = ADV7520_I2C_ADDR;
3615 msgs[0].flags = 0;
3616 msgs[0].buf = (unsigned char *) wBuff;
3617 msgs[0].len = 2;
3618
3619 res = i2c_transfer(adapter, msgs, 1);
3620 if (res != 1) {
3621 pr_err("%s: error writing adv7520\n", __func__);
3622 goto ldo8_disable;
3623 }
3624
3625 /* for successful fixup, we release the i2c adapter */
3626 /* but leave ldo8 on so that the adv7520 is not repowered */
3627 i2c_put_adapter(adapter);
3628 pr_info("%s: fluid i2c address conflict resolved\n", __func__);
3629 }
3630 return 0;
3631
3632ldo8_disable:
Justin Paupore3f40f342011-08-10 18:52:16 -07003633 hdmi_core_power(0, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003634adapter_put:
3635 i2c_put_adapter(adapter);
3636 return rc;
3637}
3638fs_initcall_sync(fluid_i2c_address_fixup);
3639#endif
3640
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003641static bool hdmi_check_hdcp_hw_support(void)
3642{
3643 if (machine_is_msm7x30_fluid())
3644 return false;
3645 else
3646 return true;
3647}
3648
3649static int dtv_panel_power(int on)
3650{
3651 int flag_on = !!on;
3652 static int dtv_power_save_on;
3653 int rc;
3654
3655 if (dtv_power_save_on == flag_on)
3656 return 0;
3657
3658 dtv_power_save_on = flag_on;
3659 pr_info("%s: %d\n", __func__, on);
3660
3661#ifdef HDMI_RESET
3662 if (on) {
3663 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
3664 rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
3665 if (rc) {
3666 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
3667 __func__, dtv_reset_gpio, rc);
3668 return rc;
3669 }
3670
3671 /* bring reset line low to hold reset*/
3672 gpio_set_value(37, 0);
3673 }
3674#endif
3675
3676 if (on) {
3677 rc = msm_gpios_enable(dtv_panel_gpios,
3678 ARRAY_SIZE(dtv_panel_gpios));
3679 if (rc < 0) {
3680 printk(KERN_ERR "%s: gpio enable failed: %d\n",
3681 __func__, rc);
3682 return rc;
3683 }
3684 } else {
3685 rc = msm_gpios_disable(dtv_panel_gpios,
3686 ARRAY_SIZE(dtv_panel_gpios));
3687 if (rc < 0) {
3688 printk(KERN_ERR "%s: gpio disable failed: %d\n",
3689 __func__, rc);
3690 return rc;
3691 }
3692 }
3693
3694 mdelay(5); /* ensure power is stable */
3695
3696#ifdef HDMI_RESET
3697 if (on) {
3698 gpio_set_value(37, 1); /* bring reset line high */
3699 mdelay(10); /* 10 msec before IO can be accessed */
3700 }
3701#endif
3702
3703 return rc;
3704}
3705
3706static struct lcdc_platform_data dtv_pdata = {
3707 .lcdc_power_save = dtv_panel_power,
3708};
3709
3710static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3711 .inject_rx_on_wakeup = 1,
3712 .rx_to_inject = 0xFD,
3713};
3714
3715static struct resource msm_fb_resources[] = {
3716 {
3717 .flags = IORESOURCE_DMA,
3718 }
3719};
3720
3721static int msm_fb_detect_panel(const char *name)
3722{
3723 if (machine_is_msm7x30_fluid()) {
3724 if (!strcmp(name, "lcdc_sharp_wvga_pt"))
3725 return 0;
3726 } else {
3727 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
3728 return -EPERM;
3729 else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20))
3730 return 0;
3731 else if (!strcmp(name, "mddi_orise"))
3732 return -EPERM;
3733 else if (!strcmp(name, "mddi_quickvx"))
3734 return -EPERM;
3735 }
3736 return -ENODEV;
3737}
3738
3739static struct msm_fb_platform_data msm_fb_pdata = {
3740 .detect_client = msm_fb_detect_panel,
3741 .mddi_prescan = 1,
3742};
3743
3744static struct platform_device msm_fb_device = {
3745 .name = "msm_fb",
3746 .id = 0,
3747 .num_resources = ARRAY_SIZE(msm_fb_resources),
3748 .resource = msm_fb_resources,
3749 .dev = {
3750 .platform_data = &msm_fb_pdata,
3751 }
3752};
3753
3754static struct platform_device msm_migrate_pages_device = {
3755 .name = "msm_migrate_pages",
3756 .id = -1,
3757};
3758
3759static struct android_pmem_platform_data android_pmem_adsp_pdata = {
3760 .name = "pmem_adsp",
3761 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
3762 .cached = 0,
3763 .memory_type = MEMTYPE_EBI0,
3764};
3765
3766static struct android_pmem_platform_data android_pmem_audio_pdata = {
3767 .name = "pmem_audio",
3768 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
3769 .cached = 0,
3770 .memory_type = MEMTYPE_EBI0,
3771};
3772
3773static struct platform_device android_pmem_adsp_device = {
3774 .name = "android_pmem",
3775 .id = 2,
3776 .dev = { .platform_data = &android_pmem_adsp_pdata },
3777};
3778
3779static struct platform_device android_pmem_audio_device = {
3780 .name = "android_pmem",
3781 .id = 4,
3782 .dev = { .platform_data = &android_pmem_audio_pdata },
3783};
3784
3785#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3786 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
3787 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3788 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3789
3790#define QCE_SIZE 0x10000
3791#define QCE_0_BASE 0xA8400000
3792
3793#define QCE_HW_KEY_SUPPORT 1
3794#define QCE_SHA_HMAC_SUPPORT 0
3795#define QCE_SHARE_CE_RESOURCE 0
3796#define QCE_CE_SHARED 0
3797
3798static struct resource qcrypto_resources[] = {
3799 [0] = {
3800 .start = QCE_0_BASE,
3801 .end = QCE_0_BASE + QCE_SIZE - 1,
3802 .flags = IORESOURCE_MEM,
3803 },
3804 [1] = {
3805 .name = "crypto_channels",
3806 .start = DMOV_CE_IN_CHAN,
3807 .end = DMOV_CE_OUT_CHAN,
3808 .flags = IORESOURCE_DMA,
3809 },
3810 [2] = {
3811 .name = "crypto_crci_in",
3812 .start = DMOV_CE_IN_CRCI,
3813 .end = DMOV_CE_IN_CRCI,
3814 .flags = IORESOURCE_DMA,
3815 },
3816 [3] = {
3817 .name = "crypto_crci_out",
3818 .start = DMOV_CE_OUT_CRCI,
3819 .end = DMOV_CE_OUT_CRCI,
3820 .flags = IORESOURCE_DMA,
3821 },
3822 [4] = {
3823 .name = "crypto_crci_hash",
3824 .start = DMOV_CE_HASH_CRCI,
3825 .end = DMOV_CE_HASH_CRCI,
3826 .flags = IORESOURCE_DMA,
3827 },
3828};
3829
3830static struct resource qcedev_resources[] = {
3831 [0] = {
3832 .start = QCE_0_BASE,
3833 .end = QCE_0_BASE + QCE_SIZE - 1,
3834 .flags = IORESOURCE_MEM,
3835 },
3836 [1] = {
3837 .name = "crypto_channels",
3838 .start = DMOV_CE_IN_CHAN,
3839 .end = DMOV_CE_OUT_CHAN,
3840 .flags = IORESOURCE_DMA,
3841 },
3842 [2] = {
3843 .name = "crypto_crci_in",
3844 .start = DMOV_CE_IN_CRCI,
3845 .end = DMOV_CE_IN_CRCI,
3846 .flags = IORESOURCE_DMA,
3847 },
3848 [3] = {
3849 .name = "crypto_crci_out",
3850 .start = DMOV_CE_OUT_CRCI,
3851 .end = DMOV_CE_OUT_CRCI,
3852 .flags = IORESOURCE_DMA,
3853 },
3854 [4] = {
3855 .name = "crypto_crci_hash",
3856 .start = DMOV_CE_HASH_CRCI,
3857 .end = DMOV_CE_HASH_CRCI,
3858 .flags = IORESOURCE_DMA,
3859 },
3860};
3861
3862#endif
3863
3864#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3865 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
3866
3867static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
3868 .ce_shared = QCE_CE_SHARED,
3869 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
3870 .hw_key_support = QCE_HW_KEY_SUPPORT,
3871 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08003872 /* Bus Scaling declaration*/
3873 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003874};
3875
3876static struct platform_device qcrypto_device = {
3877 .name = "qcrypto",
3878 .id = 0,
3879 .num_resources = ARRAY_SIZE(qcrypto_resources),
3880 .resource = qcrypto_resources,
3881 .dev = {
3882 .coherent_dma_mask = DMA_BIT_MASK(32),
3883 .platform_data = &qcrypto_ce_hw_suppport,
3884 },
3885};
3886#endif
3887
3888#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3889 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3890
3891static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
3892 .ce_shared = QCE_CE_SHARED,
3893 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
3894 .hw_key_support = QCE_HW_KEY_SUPPORT,
3895 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08003896 /* Bus Scaling declaration*/
3897 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003898};
3899static struct platform_device qcedev_device = {
3900 .name = "qce",
3901 .id = 0,
3902 .num_resources = ARRAY_SIZE(qcedev_resources),
3903 .resource = qcedev_resources,
3904 .dev = {
3905 .coherent_dma_mask = DMA_BIT_MASK(32),
3906 .platform_data = &qcedev_ce_hw_suppport,
3907 },
3908};
3909#endif
3910
3911static int mddi_toshiba_pmic_bl(int level)
3912{
3913 int ret = -EPERM;
3914
3915 ret = pmic_set_led_intensity(LED_LCD, level);
3916
3917 if (ret)
3918 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
3919 __func__);
3920 return ret;
3921}
3922
3923static struct msm_panel_common_pdata mddi_toshiba_pdata = {
3924 .pmic_backlight = mddi_toshiba_pmic_bl,
3925};
3926
3927static struct platform_device mddi_toshiba_device = {
3928 .name = "mddi_toshiba",
3929 .id = 0,
3930 .dev = {
3931 .platform_data = &mddi_toshiba_pdata,
3932 }
3933};
3934
3935static unsigned wega_reset_gpio =
3936 GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3937
3938static struct msm_gpio fluid_vee_reset_gpio[] = {
3939 { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
3940};
3941
3942static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1;
3943static unsigned char quickvx_ldo_enabled;
3944
3945static unsigned quickvx_vlp_gpio =
3946 GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3947
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303948static struct pm8xxx_gpio_init_info pmic_quickvx_clk_gpio = {
3949 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_QUICKVX_CLK),
3950 {
3951 .direction = PM_GPIO_DIR_OUT,
3952 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3953 .output_value = 1,
3954 .pull = PM_GPIO_PULL_NO,
3955 .vin_sel = PM8058_GPIO_VIN_S3,
3956 .out_strength = PM_GPIO_STRENGTH_HIGH,
3957 .function = PM_GPIO_FUNC_2,
3958 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003959};
3960
Justin Paupore3f40f342011-08-10 18:52:16 -07003961static struct regulator *mddi_ldo20;
3962static struct regulator *mddi_ldo12;
3963static struct regulator *mddi_ldo16;
3964static struct regulator *mddi_ldo6;
3965static struct regulator *mddi_lcd;
3966
3967static int display_common_init(void)
3968{
3969 struct regulator_bulk_data regs[5] = {
3970 { .supply = "ldo20", /* voltage set in display_common_power */},
3971 { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 },
3972 { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 },
3973 { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 },
3974 { .supply = NULL, /* mddi_lcd, initialized below */ },
3975 };
3976
3977 int rc = 0;
3978
3979 if (machine_is_msm7x30_fluid()) {
3980 /* lcd: LDO8 @1.8V */
3981 regs[4].supply = "ldo8";
3982 regs[4].min_uV = 1800000;
3983 regs[4].max_uV = 1800000;
3984 } else {
3985 /* lcd: LDO15 @3.1V */
3986 regs[4].supply = "ldo15";
3987 regs[4].min_uV = 3100000;
3988 regs[4].max_uV = 3100000;
3989 }
3990
3991 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
3992 if (rc) {
3993 pr_err("%s: regulator_bulk_get failed: %d\n",
3994 __func__, rc);
3995 goto bail;
3996 }
3997
3998 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
3999 if (rc) {
4000 pr_err("%s: regulator_bulk_set_voltage failed: %d\n",
4001 __func__, rc);
4002 goto put_regs;
4003 }
4004
4005 mddi_ldo20 = regs[0].consumer;
4006 mddi_ldo12 = regs[1].consumer;
4007 mddi_ldo6 = regs[2].consumer;
4008 mddi_ldo16 = regs[3].consumer;
4009 mddi_lcd = regs[4].consumer;
4010
4011 return rc;
4012
4013put_regs:
4014 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4015bail:
4016 return rc;
4017}
4018
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004019static int display_common_power(int on)
4020{
4021 int rc = 0, flag_on = !!on;
4022 static int display_common_power_save_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004023 static bool display_regs_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004024
4025 if (display_common_power_save_on == flag_on)
4026 return 0;
4027
4028 display_common_power_save_on = flag_on;
4029
Justin Paupore3f40f342011-08-10 18:52:16 -07004030 if (unlikely(!display_regs_initialized)) {
4031 rc = display_common_init();
4032 if (rc) {
4033 pr_err("%s: regulator init failed: %d\n",
4034 __func__, rc);
4035 return rc;
4036 }
4037 display_regs_initialized = true;
4038 }
4039
4040
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004041 if (on) {
4042 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
4043 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
4044 if (rc) {
4045 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4046 __func__, wega_reset_gpio, rc);
4047 return rc;
4048 }
4049
4050 /* bring reset line low to hold reset*/
4051 gpio_set_value(180, 0);
4052
4053 if (quickvx_mddi_client) {
4054 /* QuickVX chip -- VLP pin -- gpio 97 */
4055 rc = gpio_tlmm_config(quickvx_vlp_gpio,
4056 GPIO_CFG_ENABLE);
4057 if (rc) {
4058 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4059 __func__, quickvx_vlp_gpio, rc);
4060 return rc;
4061 }
4062
4063 /* bring QuickVX VLP line low */
4064 gpio_set_value(97, 0);
4065
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304066 rc = pm8xxx_gpio_config(pmic_quickvx_clk_gpio.gpio,
4067 &pmic_quickvx_clk_gpio.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004068 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304069 pr_err("%s: pm8xxx_gpio_config(%#x)=%d\n",
4070 __func__, pmic_quickvx_clk_gpio.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004071 rc);
4072 return rc;
4073 }
4074
4075 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4076 PMIC_GPIO_QUICKVX_CLK), 0);
4077 }
4078 }
4079
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004080 if (quickvx_mddi_client)
Justin Paupore3f40f342011-08-10 18:52:16 -07004081 rc = regulator_set_voltage(mddi_ldo20, 1800000, 1800000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004082 else
Justin Paupore3f40f342011-08-10 18:52:16 -07004083 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000);
4084
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004085 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004086 pr_err("%s: could not set voltage for ldo20: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004087 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07004088 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004089 }
4090
4091 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004092 rc = regulator_enable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004093 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004094 pr_err("%s: LDO20 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004095 __func__, rc);
4096 return rc;
4097 }
4098
Justin Paupore3f40f342011-08-10 18:52:16 -07004099 rc = regulator_enable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004100 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004101 pr_err("%s: LDO12 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004102 __func__, rc);
4103 return rc;
4104 }
4105
4106 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004107 rc = regulator_enable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004108 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004109 pr_err("%s: LDO16 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004110 __func__, rc);
4111 return rc;
4112 }
4113 }
4114
Justin Paupore3f40f342011-08-10 18:52:16 -07004115 if (quickvx_ldo_enabled) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004116 /* Disable LDO6 during display ON */
Justin Paupore3f40f342011-08-10 18:52:16 -07004117 rc = regulator_disable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004118 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004119 pr_err("%s: LDO6 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004120 __func__, rc);
4121 return rc;
4122 }
4123 quickvx_ldo_enabled = 0;
4124 }
4125
Justin Paupore3f40f342011-08-10 18:52:16 -07004126 rc = regulator_enable(mddi_lcd);
4127 if (rc) {
4128 pr_err("%s: LCD regulator enable failed (%d)\n",
4129 __func__, rc);
4130 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004131 }
4132
4133 mdelay(5); /* ensure power is stable */
4134
4135 if (machine_is_msm7x30_fluid()) {
4136 rc = msm_gpios_request_enable(fluid_vee_reset_gpio,
4137 ARRAY_SIZE(fluid_vee_reset_gpio));
4138 if (rc)
4139 pr_err("%s gpio_request_enable failed rc=%d\n",
4140 __func__, rc);
4141 else {
4142 /* assert vee reset_n */
4143 gpio_set_value(20, 1);
4144 gpio_set_value(20, 0);
4145 mdelay(1);
4146 gpio_set_value(20, 1);
4147 }
4148 }
4149
4150 gpio_set_value(180, 1); /* bring reset line high */
4151 mdelay(10); /* 10 msec before IO can be accessed */
4152
4153 if (quickvx_mddi_client) {
4154 gpio_set_value(97, 1);
4155 msleep(2);
4156 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4157 PMIC_GPIO_QUICKVX_CLK), 1);
4158 msleep(2);
4159 }
4160
4161 rc = pmapp_display_clock_config(1);
4162 if (rc) {
4163 pr_err("%s pmapp_display_clock_config rc=%d\n",
4164 __func__, rc);
4165 return rc;
4166 }
4167
4168 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004169 rc = regulator_disable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004170 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004171 pr_err("%s: LDO20 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004172 __func__, rc);
4173 return rc;
4174 }
4175
4176
4177 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004178 rc = regulator_disable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004179 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004180 pr_err("%s: LDO16 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004181 __func__, rc);
4182 return rc;
4183 }
4184 }
4185
4186 if (quickvx_mddi_client && !quickvx_ldo_enabled) {
4187 /* Enable LDO6 during display OFF for
4188 Quicklogic chip to sleep with data retention */
Justin Paupore3f40f342011-08-10 18:52:16 -07004189 rc = regulator_enable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004190 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004191 pr_err("%s: LDO6 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004192 __func__, rc);
4193 return rc;
4194 }
4195 quickvx_ldo_enabled = 1;
4196 }
4197
4198 gpio_set_value(180, 0); /* bring reset line low */
4199
4200 if (quickvx_mddi_client) {
4201 gpio_set_value(97, 0);
4202 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4203 PMIC_GPIO_QUICKVX_CLK), 0);
4204 }
4205
Justin Paupore3f40f342011-08-10 18:52:16 -07004206 rc = regulator_disable(mddi_lcd);
4207 if (rc) {
4208 pr_err("%s: LCD regulator disable failed (%d)\n",
4209 __func__, rc);
4210 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004211 }
4212
4213 mdelay(5); /* ensure power is stable */
4214
Justin Paupore3f40f342011-08-10 18:52:16 -07004215 rc = regulator_disable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004216 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004217 pr_err("%s: LDO12 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004218 __func__, rc);
4219 return rc;
4220 }
4221
4222 if (machine_is_msm7x30_fluid()) {
4223 msm_gpios_disable_free(fluid_vee_reset_gpio,
4224 ARRAY_SIZE(fluid_vee_reset_gpio));
4225 }
4226
4227 rc = pmapp_display_clock_config(0);
4228 if (rc) {
4229 pr_err("%s pmapp_display_clock_config rc=%d\n",
4230 __func__, rc);
4231 return rc;
4232 }
4233 }
4234
4235 return rc;
4236}
4237
4238static int msm_fb_mddi_sel_clk(u32 *clk_rate)
4239{
4240 *clk_rate *= 2;
4241 return 0;
4242}
4243
4244static int msm_fb_mddi_client_power(u32 client_id)
4245{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004246 printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
4247 /* Check if it is Quicklogic client */
4248 if (client_id == 0xc5835800) {
4249 printk(KERN_NOTICE "\n Quicklogic MDDI client");
4250 other_mddi_client = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004251 } else {
4252 printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
4253 quickvx_mddi_client = 0;
4254 gpio_set_value(97, 0);
4255 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4256 PMIC_GPIO_QUICKVX_CLK), 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004257 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004258
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004259 return 0;
4260}
4261
4262static struct mddi_platform_data mddi_pdata = {
4263 .mddi_power_save = display_common_power,
4264 .mddi_sel_clk = msm_fb_mddi_sel_clk,
4265 .mddi_client_power = msm_fb_mddi_client_power,
4266};
4267
4268int mdp_core_clk_rate_table[] = {
4269 122880000,
4270 122880000,
Pradeep Jilagam3cc12f92011-07-26 22:25:18 +05304271 192000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004272 192000000,
4273};
4274
4275static struct msm_panel_common_pdata mdp_pdata = {
4276 .hw_revision_addr = 0xac001270,
4277 .gpio = 30,
4278 .mdp_core_clk_rate = 122880000,
4279 .mdp_core_clk_table = mdp_core_clk_rate_table,
4280 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07004281 .mdp_rev = MDP_REV_40,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004282};
4283
4284static int lcd_panel_spi_gpio_num[] = {
4285 45, /* spi_clk */
4286 46, /* spi_cs */
4287 47, /* spi_mosi */
4288 48, /* spi_miso */
4289 };
4290
4291static struct msm_gpio lcd_panel_gpios[] = {
4292/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
4293 * input. if there is a hardware revision; we should reassign this GPIO to a
4294 * new open line; and removing it will just ensure that this will be missed in
4295 * the future.
4296 { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
4297 */
4298 { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
4299 { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
4300 { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
4301 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4302 { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
4303 { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
4304 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4305#ifndef CONFIG_SPI_QSD
4306 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
4307 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
4308 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
4309 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
4310#endif
4311 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4312 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4313 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4314 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4315 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4316 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4317 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4318 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4319 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4320 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4321 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4322 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4323 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4324 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4325 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4326 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4327 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4328 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4329 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4330 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4331};
4332
4333static struct msm_gpio lcd_sharp_panel_gpios[] = {
4334 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4335 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4336 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4337 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4338 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4339 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4340 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4341 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4342 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4343 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4344 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4345 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4346 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4347 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4348 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4349 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4350 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4351 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4352 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4353 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4354 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4355 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4356};
4357
4358static int lcdc_toshiba_panel_power(int on)
4359{
4360 int rc, i;
4361 struct msm_gpio *gp;
4362
4363 rc = display_common_power(on);
4364 if (rc < 0) {
4365 printk(KERN_ERR "%s display_common_power failed: %d\n",
4366 __func__, rc);
4367 return rc;
4368 }
4369
4370 if (on) {
4371 rc = msm_gpios_enable(lcd_panel_gpios,
4372 ARRAY_SIZE(lcd_panel_gpios));
4373 if (rc < 0) {
4374 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4375 __func__, rc);
4376 }
4377 } else { /* off */
4378 gp = lcd_panel_gpios;
4379 for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
4380 /* ouput low */
4381 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4382 gp++;
4383 }
4384 }
4385
4386 return rc;
4387}
4388
4389static int lcdc_sharp_panel_power(int on)
4390{
4391 int rc, i;
4392 struct msm_gpio *gp;
4393
4394 rc = display_common_power(on);
4395 if (rc < 0) {
4396 printk(KERN_ERR "%s display_common_power failed: %d\n",
4397 __func__, rc);
4398 return rc;
4399 }
4400
4401 if (on) {
4402 rc = msm_gpios_enable(lcd_sharp_panel_gpios,
4403 ARRAY_SIZE(lcd_sharp_panel_gpios));
4404 if (rc < 0) {
4405 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4406 __func__, rc);
4407 }
4408 } else { /* off */
4409 gp = lcd_sharp_panel_gpios;
4410 for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) {
4411 /* ouput low */
4412 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4413 gp++;
4414 }
4415 }
4416
4417 return rc;
4418}
4419
4420static int lcdc_panel_power(int on)
4421{
4422 int flag_on = !!on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004423 static int lcdc_power_save_on, lcdc_power_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004424
4425 if (lcdc_power_save_on == flag_on)
4426 return 0;
4427
4428 lcdc_power_save_on = flag_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004429
4430 if (unlikely(!lcdc_power_initialized)) {
4431 quickvx_mddi_client = 0;
4432 display_common_init();
4433 lcdc_power_initialized = 1;
4434 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004435
4436 if (machine_is_msm7x30_fluid())
4437 return lcdc_sharp_panel_power(on);
4438 else
4439 return lcdc_toshiba_panel_power(on);
4440}
4441
4442static struct lcdc_platform_data lcdc_pdata = {
4443 .lcdc_power_save = lcdc_panel_power,
4444};
4445
Justin Paupore3f40f342011-08-10 18:52:16 -07004446static struct regulator *atv_s4, *atv_ldo9;
4447
4448static int __init atv_dac_power_init(void)
4449{
4450 int rc;
4451 struct regulator_bulk_data regs[] = {
4452 { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 },
4453 { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 },
4454 };
4455
4456 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4457
4458 if (rc) {
4459 pr_err("%s: could not get regulators: %d\n", __func__, rc);
4460 goto bail;
4461 }
4462
4463 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4464
4465 if (rc) {
4466 pr_err("%s: could not set voltages: %d\n", __func__, rc);
4467 goto reg_free;
4468 }
4469
4470 atv_s4 = regs[0].consumer;
4471 atv_ldo9 = regs[1].consumer;
4472
4473reg_free:
4474 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4475bail:
4476 return rc;
4477}
4478
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004479static int atv_dac_power(int on)
4480{
4481 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004482
4483 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004484 rc = regulator_enable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004485 if (rc) {
4486 pr_err("%s: s4 vreg enable failed (%d)\n",
4487 __func__, rc);
4488 return rc;
4489 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004490 rc = regulator_enable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004491 if (rc) {
4492 pr_err("%s: ldo9 vreg enable failed (%d)\n",
4493 __func__, rc);
4494 return rc;
4495 }
4496 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004497 rc = regulator_disable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004498 if (rc) {
4499 pr_err("%s: ldo9 vreg disable failed (%d)\n",
4500 __func__, rc);
4501 return rc;
4502 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004503 rc = regulator_disable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004504 if (rc) {
4505 pr_err("%s: s4 vreg disable failed (%d)\n",
4506 __func__, rc);
4507 return rc;
4508 }
4509 }
4510 return rc;
4511}
4512
4513static struct tvenc_platform_data atv_pdata = {
4514 .poll = 1,
4515 .pm_vid_en = atv_dac_power,
4516};
4517
4518static void __init msm_fb_add_devices(void)
4519{
4520 msm_fb_register_device("mdp", &mdp_pdata);
4521 msm_fb_register_device("pmdh", &mddi_pdata);
4522 msm_fb_register_device("lcdc", &lcdc_pdata);
4523 msm_fb_register_device("dtv", &dtv_pdata);
4524 msm_fb_register_device("tvenc", &atv_pdata);
4525#ifdef CONFIG_FB_MSM_TVOUT
4526 msm_fb_register_device("tvout_device", NULL);
4527#endif
4528}
4529
4530static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
4531 .gpio_num = lcd_panel_spi_gpio_num,
4532};
4533
4534static struct platform_device lcdc_toshiba_panel_device = {
4535 .name = "lcdc_toshiba_wvga",
4536 .id = 0,
4537 .dev = {
4538 .platform_data = &lcdc_toshiba_panel_data,
4539 }
4540};
4541
4542#if defined(CONFIG_MARIMBA_CORE) && \
4543 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4544static struct platform_device msm_bt_power_device = {
4545 .name = "bt_power",
4546 .id = -1
4547};
4548
4549enum {
4550 BT_RFR,
4551 BT_CTS,
4552 BT_RX,
4553 BT_TX,
4554};
4555
4556static struct msm_gpio bt_config_power_on[] = {
4557 { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4558 "UART1DM_RFR" },
4559 { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4560 "UART1DM_CTS" },
4561 { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4562 "UART1DM_Rx" },
4563 { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4564 "UART1DM_Tx" }
4565};
4566
4567static struct msm_gpio bt_config_power_off[] = {
4568 { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4569 "UART1DM_RFR" },
4570 { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4571 "UART1DM_CTS" },
4572 { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4573 "UART1DM_Rx" },
4574 { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4575 "UART1DM_Tx" }
4576};
4577
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004578static u8 bahama_version;
4579
Justin Paupore3f40f342011-08-10 18:52:16 -07004580static struct regulator_bulk_data regs_bt_marimba[] = {
4581 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4582 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
4583 { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 },
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_v1[] = {
4588 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4589 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
4590 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304591 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004592};
4593
4594static struct regulator_bulk_data regs_bt_bahama_v2[] = {
4595 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4596 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304597 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004598};
4599
4600static struct regulator_bulk_data *regs_bt;
4601static int regs_bt_count;
4602
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004603static int marimba_bt(int on)
4604{
4605 int rc;
4606 int i;
4607 struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
4608
4609 struct marimba_config_register {
4610 u8 reg;
4611 u8 value;
4612 u8 mask;
4613 };
4614
4615 struct marimba_variant_register {
4616 const size_t size;
4617 const struct marimba_config_register *set;
4618 };
4619
4620 const struct marimba_config_register *p;
4621
4622 u8 version;
4623
4624 const struct marimba_config_register v10_bt_on[] = {
4625 { 0xE5, 0x0B, 0x0F },
4626 { 0x05, 0x02, 0x07 },
4627 { 0x06, 0x88, 0xFF },
4628 { 0xE7, 0x21, 0x21 },
4629 { 0xE3, 0x38, 0xFF },
4630 { 0xE4, 0x06, 0xFF },
4631 };
4632
4633 const struct marimba_config_register v10_bt_off[] = {
4634 { 0xE5, 0x0B, 0x0F },
4635 { 0x05, 0x08, 0x0F },
4636 { 0x06, 0x88, 0xFF },
4637 { 0xE7, 0x00, 0x21 },
4638 { 0xE3, 0x00, 0xFF },
4639 { 0xE4, 0x00, 0xFF },
4640 };
4641
4642 const struct marimba_config_register v201_bt_on[] = {
4643 { 0x05, 0x08, 0x07 },
4644 { 0x06, 0x88, 0xFF },
4645 { 0xE7, 0x21, 0x21 },
4646 { 0xE3, 0x38, 0xFF },
4647 { 0xE4, 0x06, 0xFF },
4648 };
4649
4650 const struct marimba_config_register v201_bt_off[] = {
4651 { 0x05, 0x08, 0x07 },
4652 { 0x06, 0x88, 0xFF },
4653 { 0xE7, 0x00, 0x21 },
4654 { 0xE3, 0x00, 0xFF },
4655 { 0xE4, 0x00, 0xFF },
4656 };
4657
4658 const struct marimba_config_register v210_bt_on[] = {
4659 { 0xE9, 0x01, 0x01 },
4660 { 0x06, 0x88, 0xFF },
4661 { 0xE7, 0x21, 0x21 },
4662 { 0xE3, 0x38, 0xFF },
4663 { 0xE4, 0x06, 0xFF },
4664 };
4665
4666 const struct marimba_config_register v210_bt_off[] = {
4667 { 0x06, 0x88, 0xFF },
4668 { 0xE7, 0x00, 0x21 },
4669 { 0xE9, 0x00, 0x01 },
4670 { 0xE3, 0x00, 0xFF },
4671 { 0xE4, 0x00, 0xFF },
4672 };
4673
4674 const struct marimba_variant_register bt_marimba[2][4] = {
4675 {
4676 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4677 { 0, NULL },
4678 { ARRAY_SIZE(v201_bt_off), v201_bt_off },
4679 { ARRAY_SIZE(v210_bt_off), v210_bt_off }
4680 },
4681 {
4682 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4683 { 0, NULL },
4684 { ARRAY_SIZE(v201_bt_on), v201_bt_on },
4685 { ARRAY_SIZE(v210_bt_on), v210_bt_on }
4686 }
4687 };
4688
4689 on = on ? 1 : 0;
4690
4691 rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F);
4692 if (rc < 0) {
4693 printk(KERN_ERR
4694 "%s: version read failed: %d\n",
4695 __func__, rc);
4696 return rc;
4697 }
4698
4699 if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
4700 (bt_marimba[on][version].size == 0)) {
4701 printk(KERN_ERR
4702 "%s: unsupported version\n",
4703 __func__);
4704 return -EIO;
4705 }
4706
4707 p = bt_marimba[on][version].set;
4708
4709 printk(KERN_INFO "%s: found version %d\n", __func__, version);
4710
4711 for (i = 0; i < bt_marimba[on][version].size; i++) {
4712 u8 value = (p+i)->value;
4713 rc = marimba_write_bit_mask(&config,
4714 (p+i)->reg,
4715 &value,
4716 sizeof((p+i)->value),
4717 (p+i)->mask);
4718 if (rc < 0) {
4719 printk(KERN_ERR
4720 "%s: reg %d write failed: %d\n",
4721 __func__, (p+i)->reg, rc);
4722 return rc;
4723 }
4724 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
4725 __func__, (p+i)->reg,
4726 value, (p+i)->mask);
4727 }
4728 return 0;
4729}
4730
4731static int bahama_bt(int on)
4732{
4733 int rc;
4734 int i;
4735 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
4736
4737 struct bahama_variant_register {
4738 const size_t size;
4739 const struct bahama_config_register *set;
4740 };
4741
4742 const struct bahama_config_register *p;
4743
4744
4745 const struct bahama_config_register v10_bt_on[] = {
4746 { 0xE9, 0x00, 0xFF },
4747 { 0xF4, 0x80, 0xFF },
4748 { 0xF0, 0x06, 0xFF },
4749 { 0xE4, 0x00, 0xFF },
4750 { 0xE5, 0x00, 0x0F },
4751#ifdef CONFIG_WLAN
4752 { 0xE6, 0x38, 0x7F },
4753 { 0xE7, 0x06, 0xFF },
4754#endif
4755 { 0x11, 0x13, 0xFF },
4756 { 0xE9, 0x21, 0xFF },
4757 { 0x01, 0x0C, 0x1F },
4758 { 0x01, 0x08, 0x1F },
4759 };
4760
4761 const struct bahama_config_register v20_bt_on_fm_off[] = {
4762 { 0x11, 0x0C, 0xFF },
4763 { 0x13, 0x01, 0xFF },
4764 { 0xF4, 0x80, 0xFF },
4765 { 0xF0, 0x00, 0xFF },
4766 { 0xE9, 0x00, 0xFF },
4767#ifdef CONFIG_WLAN
4768 { 0x81, 0x00, 0xFF },
4769 { 0x82, 0x00, 0xFF },
4770 { 0xE6, 0x38, 0x7F },
4771 { 0xE7, 0x06, 0xFF },
4772#endif
4773 { 0xE9, 0x21, 0xFF }
4774 };
4775
4776 const struct bahama_config_register v20_bt_on_fm_on[] = {
4777 { 0x11, 0x0C, 0xFF },
4778 { 0x13, 0x01, 0xFF },
4779 { 0xF4, 0x86, 0xFF },
4780 { 0xF0, 0x06, 0xFF },
4781 { 0xE9, 0x00, 0xFF },
4782#ifdef CONFIG_WLAN
4783 { 0x81, 0x00, 0xFF },
4784 { 0x82, 0x00, 0xFF },
4785 { 0xE6, 0x38, 0x7F },
4786 { 0xE7, 0x06, 0xFF },
4787#endif
4788 { 0xE9, 0x21, 0xFF }
4789 };
4790
4791 const struct bahama_config_register v10_bt_off[] = {
4792 { 0xE9, 0x00, 0xFF },
4793 };
4794
4795 const struct bahama_config_register v20_bt_off_fm_off[] = {
4796 { 0xF4, 0x84, 0xFF },
4797 { 0xF0, 0x04, 0xFF },
4798 { 0xE9, 0x00, 0xFF }
4799 };
4800
4801 const struct bahama_config_register v20_bt_off_fm_on[] = {
4802 { 0xF4, 0x86, 0xFF },
4803 { 0xF0, 0x06, 0xFF },
4804 { 0xE9, 0x00, 0xFF }
4805 };
4806
4807 const struct bahama_variant_register bt_bahama[2][3] = {
4808 {
4809 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4810 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
4811 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
4812 },
4813 {
4814 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4815 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
4816 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
4817 }
4818 };
4819
4820 u8 offset = 0; /* index into bahama configs */
4821
4822 on = on ? 1 : 0;
4823
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004824
4825 if (bahama_version == VER_2_0) {
4826 if (marimba_get_fm_status(&config))
4827 offset = 0x01;
4828 }
4829
4830 p = bt_bahama[on][bahama_version + offset].set;
4831
4832 dev_info(&msm_bt_power_device.dev,
4833 "%s: found version %d\n", __func__, bahama_version);
4834
4835 for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
4836 u8 value = (p+i)->value;
4837 rc = marimba_write_bit_mask(&config,
4838 (p+i)->reg,
4839 &value,
4840 sizeof((p+i)->value),
4841 (p+i)->mask);
4842 if (rc < 0) {
4843 dev_err(&msm_bt_power_device.dev,
4844 "%s: reg %d write failed: %d\n",
4845 __func__, (p+i)->reg, rc);
4846 return rc;
4847 }
4848 dev_info(&msm_bt_power_device.dev,
4849 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
4850 __func__, (p+i)->reg,
4851 value, (p+i)->mask);
4852 }
4853 /* Update BT status */
4854 if (on)
4855 marimba_set_bt_status(&config, true);
4856 else
4857 marimba_set_bt_status(&config, false);
4858
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004859 return 0;
4860}
4861
Justin Paupore3f40f342011-08-10 18:52:16 -07004862static int bluetooth_regs_init(int bahama_not_marimba)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004863{
Justin Paupore3f40f342011-08-10 18:52:16 -07004864 int rc = 0;
4865 struct device *const dev = &msm_bt_power_device.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004866
4867 if (bahama_not_marimba) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004868 bahama_version = read_bahama_ver();
4869
4870 switch (bahama_version) {
4871 case VER_1_0:
4872 regs_bt = regs_bt_bahama_v1;
4873 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1);
4874 break;
4875 case VER_2_0:
4876 regs_bt = regs_bt_bahama_v2;
4877 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2);
4878 break;
4879 case VER_UNSUPPORTED:
4880 default:
4881 dev_err(dev,
4882 "%s: i2c failure or unsupported version: %d\n",
4883 __func__, bahama_version);
4884 rc = -EIO;
4885 goto out;
4886 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004887 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004888 regs_bt = regs_bt_marimba;
4889 regs_bt_count = ARRAY_SIZE(regs_bt_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004890 }
4891
Justin Paupore3f40f342011-08-10 18:52:16 -07004892 rc = regulator_bulk_get(&msm_bt_power_device.dev,
4893 regs_bt_count, regs_bt);
4894 if (rc) {
4895 dev_err(dev, "%s: could not get regulators: %d\n",
4896 __func__, rc);
4897 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004898 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004899
4900 rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt);
4901 if (rc) {
4902 dev_err(dev, "%s: could not set voltages: %d\n",
4903 __func__, rc);
4904 goto reg_free;
4905 }
4906
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004907 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07004908
4909reg_free:
4910 regulator_bulk_free(regs_bt_count, regs_bt);
4911out:
4912 regs_bt_count = 0;
4913 regs_bt = NULL;
4914 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004915}
4916
4917static int bluetooth_power(int on)
4918{
4919 int rc;
4920 const char *id = "BTPW";
4921
4922 int bahama_not_marimba = bahama_present();
4923
4924 if (bahama_not_marimba == -1) {
4925 printk(KERN_WARNING "%s: bahama_present: %d\n",
4926 __func__, bahama_not_marimba);
4927 return -ENODEV;
4928 }
4929
Justin Paupore3f40f342011-08-10 18:52:16 -07004930 if (unlikely(regs_bt_count == 0)) {
4931 rc = bluetooth_regs_init(bahama_not_marimba);
4932 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004933 return rc;
Justin Paupore3f40f342011-08-10 18:52:16 -07004934 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004935
Justin Paupore3f40f342011-08-10 18:52:16 -07004936 if (on) {
4937 rc = regulator_bulk_enable(regs_bt_count, regs_bt);
4938 if (rc)
4939 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004940
4941 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
4942 PMAPP_CLOCK_VOTE_ON);
4943 if (rc < 0)
4944 return -EIO;
4945
4946 if (machine_is_msm8x55_svlte_surf() ||
4947 machine_is_msm8x55_svlte_ffa()) {
4948 rc = marimba_gpio_config(1);
4949 if (rc < 0)
4950 return -EIO;
4951 }
4952
4953 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
4954 if (rc < 0)
4955 return -EIO;
4956
4957 msleep(10);
4958
4959 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
4960 PMAPP_CLOCK_VOTE_PIN_CTRL);
4961 if (rc < 0)
4962 return -EIO;
4963
4964 if (machine_is_msm8x55_svlte_surf() ||
4965 machine_is_msm8x55_svlte_ffa()) {
4966 rc = marimba_gpio_config(0);
4967 if (rc < 0)
4968 return -EIO;
4969 }
4970
4971 rc = msm_gpios_enable(bt_config_power_on,
4972 ARRAY_SIZE(bt_config_power_on));
4973
4974 if (rc < 0)
4975 return rc;
4976
4977 } else {
4978 rc = msm_gpios_enable(bt_config_power_off,
4979 ARRAY_SIZE(bt_config_power_off));
4980 if (rc < 0)
4981 return rc;
4982
4983 /* check for initial RFKILL block (power off) */
4984 if (platform_get_drvdata(&msm_bt_power_device) == NULL)
4985 goto out;
4986
4987 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
4988 if (rc < 0)
4989 return -EIO;
4990
4991 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
4992 PMAPP_CLOCK_VOTE_OFF);
4993 if (rc < 0)
4994 return -EIO;
4995
Justin Paupore3f40f342011-08-10 18:52:16 -07004996 rc = regulator_bulk_disable(regs_bt_count, regs_bt);
4997 if (rc)
4998 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004999
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005000 }
5001
5002out:
5003 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
5004
5005 return 0;
5006}
5007
5008static void __init bt_power_init(void)
5009{
Justin Paupore3f40f342011-08-10 18:52:16 -07005010 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005011}
5012#else
5013#define bt_power_init(x) do {} while (0)
5014#endif
5015
5016static struct msm_psy_batt_pdata msm_psy_batt_data = {
5017 .voltage_min_design = 2800,
5018 .voltage_max_design = 4300,
5019 .avail_chg_sources = AC_CHG | USB_CHG ,
5020 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
5021};
5022
5023static struct platform_device msm_batt_device = {
5024 .name = "msm-battery",
5025 .id = -1,
5026 .dev.platform_data = &msm_psy_batt_data,
5027};
5028
5029static char *msm_adc_fluid_device_names[] = {
5030 "LTC_ADC1",
5031 "LTC_ADC2",
5032 "LTC_ADC3",
5033};
5034
5035static char *msm_adc_surf_device_names[] = {
5036 "XO_ADC",
5037};
5038
5039static struct msm_adc_platform_data msm_adc_pdata;
5040
5041static struct platform_device msm_adc_device = {
5042 .name = "msm_adc",
5043 .id = -1,
5044 .dev = {
5045 .platform_data = &msm_adc_pdata,
5046 },
5047};
5048
5049#ifdef CONFIG_MSM_SDIO_AL
5050static struct msm_gpio mdm2ap_status = {
5051 GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5052 "mdm2ap_status"
5053};
5054
5055
5056static int configure_mdm2ap_status(int on)
5057{
5058 if (on)
5059 return msm_gpios_request_enable(&mdm2ap_status, 1);
5060 else {
5061 msm_gpios_disable_free(&mdm2ap_status, 1);
5062 return 0;
5063 }
5064}
5065
5066static int get_mdm2ap_status(void)
5067{
5068 return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
5069}
5070
5071static struct sdio_al_platform_data sdio_al_pdata = {
5072 .config_mdm2ap_status = configure_mdm2ap_status,
5073 .get_mdm2ap_status = get_mdm2ap_status,
5074 .allow_sdioc_version_major_2 = 1,
5075 .peer_sdioc_version_minor = 0x0001,
5076 .peer_sdioc_version_major = 0x0003,
5077 .peer_sdioc_boot_version_minor = 0x0001,
5078 .peer_sdioc_boot_version_major = 0x0003,
5079};
5080
5081struct platform_device msm_device_sdio_al = {
5082 .name = "msm_sdio_al",
5083 .id = -1,
5084 .dev = {
5085 .platform_data = &sdio_al_pdata,
5086 },
5087};
5088
5089#endif /* CONFIG_MSM_SDIO_AL */
5090
Daniel Walker8d747cd2010-02-25 11:37:43 -08005091static struct platform_device *devices[] __initdata = {
Daniel Walker90e37c52010-05-12 14:24:15 -07005092#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005093 &msm_device_uart2,
5094#endif
Justin Paupore637a25d2011-07-14 17:11:04 -07005095#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
5096 &msm_proccomm_regulator_dev,
5097#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005098 &asoc_msm_pcm,
5099 &asoc_msm_dai0,
5100 &asoc_msm_dai1,
5101#if defined (CONFIG_SND_MSM_MVS_DAI_SOC)
5102 &asoc_msm_mvs,
5103 &asoc_mvs_dai0,
5104 &asoc_mvs_dai1,
Daniel Walker90e37c52010-05-12 14:24:15 -07005105#endif
Niranjana Vishwanathapuraa8855e92010-10-06 13:52:10 -07005106 &msm_device_smd,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005107 &msm_device_dmov,
5108 &smc91x_device,
5109 &smsc911x_device,
5110 &msm_device_nand,
5111#ifdef CONFIG_USB_MSM_OTG_72K
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05305112 &msm_device_otg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005113#ifdef CONFIG_USB_GADGET
5114 &msm_device_gadget_peripheral,
5115#endif
5116#endif
5117#ifdef CONFIG_USB_G_ANDROID
5118 &android_usb_device,
5119#endif
5120 &qsd_device_spi,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305121
5122#ifdef CONFIG_MSM_SSBI
5123 &msm_device_ssbi_pmic1,
5124#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005125#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005126 &msm_device_ssbi7,
5127#endif
5128 &android_pmem_device,
5129 &msm_fb_device,
5130 &msm_migrate_pages_device,
5131 &mddi_toshiba_device,
5132 &lcdc_toshiba_panel_device,
5133#ifdef CONFIG_MSM_ROTATOR
5134 &msm_rotator_device,
5135#endif
5136 &lcdc_sharp_panel_device,
5137 &android_pmem_adsp_device,
5138 &android_pmem_audio_device,
5139 &msm_device_i2c,
5140 &msm_device_i2c_2,
5141 &msm_device_uart_dm1,
5142 &hs_device,
5143#ifdef CONFIG_MSM7KV2_AUDIO
5144 &msm_aictl_device,
5145 &msm_mi2s_device,
5146 &msm_lpa_device,
5147 &msm_aux_pcm_device,
5148#endif
5149 &msm_device_adspdec,
5150 &qup_device_i2c,
5151#if defined(CONFIG_MARIMBA_CORE) && \
5152 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5153 &msm_bt_power_device,
5154#endif
5155 &msm_kgsl_3d0,
5156 &msm_kgsl_2d0,
5157#ifdef CONFIG_MT9T013
5158 &msm_camera_sensor_mt9t013,
5159#endif
5160#ifdef CONFIG_MT9D112
5161 &msm_camera_sensor_mt9d112,
5162#endif
5163#ifdef CONFIG_WEBCAM_OV9726
5164 &msm_camera_sensor_ov9726,
5165#endif
5166#ifdef CONFIG_S5K3E2FX
5167 &msm_camera_sensor_s5k3e2fx,
5168#endif
5169#ifdef CONFIG_MT9P012
5170 &msm_camera_sensor_mt9p012,
5171#endif
5172#ifdef CONFIG_MT9E013
5173 &msm_camera_sensor_mt9e013,
5174#endif
5175#ifdef CONFIG_VX6953
5176 &msm_camera_sensor_vx6953,
5177#endif
5178#ifdef CONFIG_SN12M0PZ
5179 &msm_camera_sensor_sn12m0pz,
5180#endif
5181 &msm_device_vidc_720p,
5182#ifdef CONFIG_MSM_GEMINI
5183 &msm_gemini_device,
5184#endif
5185#ifdef CONFIG_MSM_VPE
5186 &msm_vpe_device,
5187#endif
5188#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5189 &msm_device_tsif,
5190#endif
5191#ifdef CONFIG_MSM_SDIO_AL
5192 &msm_device_sdio_al,
5193#endif
5194
5195#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5196 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5197 &qcrypto_device,
5198#endif
5199
5200#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5201 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5202 &qcedev_device,
5203#endif
5204
5205 &msm_batt_device,
5206 &msm_adc_device,
5207 &msm_ebi0_thermal,
5208 &msm_ebi1_thermal
5209};
5210
5211static struct msm_gpio msm_i2c_gpios_hw[] = {
5212 { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5213 { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5214};
5215
5216static struct msm_gpio msm_i2c_gpios_io[] = {
5217 { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5218 { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5219};
5220
5221static struct msm_gpio qup_i2c_gpios_io[] = {
5222 { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5223 { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5224};
5225static struct msm_gpio qup_i2c_gpios_hw[] = {
5226 { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5227 { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5228};
5229
5230static void
5231msm_i2c_gpio_config(int adap_id, int config_type)
5232{
5233 struct msm_gpio *msm_i2c_table;
5234
5235 /* Each adapter gets 2 lines from the table */
5236 if (adap_id > 0)
5237 return;
5238 if (config_type)
5239 msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
5240 else
5241 msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
5242 msm_gpios_enable(msm_i2c_table, 2);
5243}
5244/*This needs to be enabled only for OEMS*/
5245#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005246static struct regulator *qup_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005247#endif
5248static void
5249qup_i2c_gpio_config(int adap_id, int config_type)
5250{
5251 int rc = 0;
5252 struct msm_gpio *qup_i2c_table;
5253 /* Each adapter gets 2 lines from the table */
5254 if (adap_id != 4)
5255 return;
5256 if (config_type)
5257 qup_i2c_table = qup_i2c_gpios_hw;
5258 else
5259 qup_i2c_table = qup_i2c_gpios_io;
5260 rc = msm_gpios_enable(qup_i2c_table, 2);
5261 if (rc < 0)
5262 printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
5263 /*This needs to be enabled only for OEMS*/
5264#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005265 if (!IS_ERR_OR_NULL(qup_vreg)) {
5266 rc = regulator_enable(qup_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005267 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005268 pr_err("%s: regulator_enable failed: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005269 __func__, rc);
5270 }
5271 }
5272#endif
5273}
5274
5275static struct msm_i2c_platform_data msm_i2c_pdata = {
5276 .clk_freq = 100000,
5277 .pri_clk = 70,
5278 .pri_dat = 71,
5279 .rmutex = 1,
5280 .rsl_id = "D:I2C02000021",
5281 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5282};
5283
5284static void __init msm_device_i2c_init(void)
5285{
5286 if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
5287 pr_err("failed to request I2C gpios\n");
5288
5289 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
5290}
5291
5292static struct msm_i2c_platform_data msm_i2c_2_pdata = {
5293 .clk_freq = 100000,
5294 .rmutex = 1,
5295 .rsl_id = "D:I2C02000022",
5296 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5297};
5298
5299static void __init msm_device_i2c_2_init(void)
5300{
5301 msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
5302}
5303
5304static struct msm_i2c_platform_data qup_i2c_pdata = {
5305 .clk_freq = 384000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005306 .msm_i2c_config_gpio = qup_i2c_gpio_config,
5307};
5308
5309static void __init qup_device_i2c_init(void)
5310{
5311 if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
5312 pr_err("failed to request I2C gpios\n");
5313
5314 qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
5315 /*This needs to be enabled only for OEMS*/
5316#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005317 qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005318 if (IS_ERR(qup_vreg)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005319 dev_err(&qup_device_i2c.dev,
5320 "%s: regulator_get failed: %ld\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005321 __func__, PTR_ERR(qup_vreg));
5322 }
5323#endif
5324}
5325
5326#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005327static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = {
5328 .rsl_id = "D:CODEC_SSBI",
5329 .controller_type = MSM_SBI_CTRL_SSBI,
5330};
5331#endif
5332
Daniel Walker8d747cd2010-02-25 11:37:43 -08005333static void __init msm7x30_init_irq(void)
5334{
5335 msm_init_irq();
5336}
5337
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005338static struct msm_gpio msm_nand_ebi2_cfg_data[] = {
5339 {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
5340 {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
5341};
5342
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005343#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
5344 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
5345 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
5346 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
5347
5348struct sdcc_gpio {
5349 struct msm_gpio *cfg_data;
5350 uint32_t size;
5351 struct msm_gpio *sleep_cfg_data;
5352};
5353#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5354static struct msm_gpio sdc1_lvlshft_cfg_data[] = {
5355 {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
5356};
5357#endif
5358static struct msm_gpio sdc1_cfg_data[] = {
5359 {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
5360 {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
5361 {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
5362 {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
5363 {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
5364 {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
5365};
5366
5367static struct msm_gpio sdc2_cfg_data[] = {
5368 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
5369 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
5370 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
5371 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
5372 {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
5373 {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
5374
5375#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5376 {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
5377 {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
5378 {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
5379 {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
5380#endif
5381};
5382
5383static struct msm_gpio sdc3_cfg_data[] = {
5384 {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
5385 {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
5386 {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
5387 {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
5388 {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
5389 {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
5390};
5391
5392static struct msm_gpio sdc3_sleep_cfg_data[] = {
5393 {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5394 "sdc3_clk"},
5395 {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5396 "sdc3_cmd"},
5397 {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5398 "sdc3_dat_3"},
5399 {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5400 "sdc3_dat_2"},
5401 {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5402 "sdc3_dat_1"},
5403 {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5404 "sdc3_dat_0"},
5405};
5406
5407static struct msm_gpio sdc4_cfg_data[] = {
5408 {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
5409 {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
5410 {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
5411 {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
5412 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
5413 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
5414};
5415
5416static struct sdcc_gpio sdcc_cfg_data[] = {
5417 {
5418 .cfg_data = sdc1_cfg_data,
5419 .size = ARRAY_SIZE(sdc1_cfg_data),
5420 .sleep_cfg_data = NULL,
5421 },
5422 {
5423 .cfg_data = sdc2_cfg_data,
5424 .size = ARRAY_SIZE(sdc2_cfg_data),
5425 .sleep_cfg_data = NULL,
5426 },
5427 {
5428 .cfg_data = sdc3_cfg_data,
5429 .size = ARRAY_SIZE(sdc3_cfg_data),
5430 .sleep_cfg_data = sdc3_sleep_cfg_data,
5431 },
5432 {
5433 .cfg_data = sdc4_cfg_data,
5434 .size = ARRAY_SIZE(sdc4_cfg_data),
5435 .sleep_cfg_data = NULL,
5436 },
5437};
5438
Justin Paupore3f40f342011-08-10 18:52:16 -07005439static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005440
5441static unsigned long vreg_sts, gpio_sts;
5442
5443static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
5444{
5445 int rc = 0;
5446 struct sdcc_gpio *curr;
5447
5448 curr = &sdcc_cfg_data[dev_id - 1];
5449
5450 if (!(test_bit(dev_id, &gpio_sts)^enable))
5451 return rc;
5452
5453 if (enable) {
5454 set_bit(dev_id, &gpio_sts);
5455 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
5456 if (rc)
5457 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
5458 __func__, dev_id);
5459 } else {
5460 clear_bit(dev_id, &gpio_sts);
5461 if (curr->sleep_cfg_data) {
5462 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
5463 msm_gpios_free(curr->sleep_cfg_data, curr->size);
5464 } else {
5465 msm_gpios_disable_free(curr->cfg_data, curr->size);
5466 }
5467 }
5468
5469 return rc;
5470}
5471
5472static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
5473{
5474 int rc = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005475 struct regulator *curr = sdcc_vreg_data[dev_id - 1];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005476 static int enabled_once[] = {0, 0, 0, 0};
5477
Justin Paupore3f40f342011-08-10 18:52:16 -07005478 if (test_bit(dev_id, &vreg_sts) == enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005479 return rc;
5480
5481 if (!enable || enabled_once[dev_id - 1])
5482 return 0;
5483
Justin Paupore3f40f342011-08-10 18:52:16 -07005484 if (!curr)
5485 return -ENODEV;
5486
5487 if (IS_ERR(curr))
5488 return PTR_ERR(curr);
5489
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005490 if (enable) {
5491 set_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005492
5493 rc = regulator_enable(curr);
5494 if (rc)
5495 pr_err("%s: could not enable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005496 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005497 enabled_once[dev_id - 1] = 1;
5498 } else {
5499 clear_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005500
5501 rc = regulator_disable(curr);
5502 if (rc)
5503 pr_err("%s: could not disable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005504 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005505 }
5506 return rc;
5507}
5508
5509static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
5510{
5511 int rc = 0;
5512 struct platform_device *pdev;
5513
5514 pdev = container_of(dv, struct platform_device, dev);
5515 rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
5516 if (rc)
5517 goto out;
5518
5519 if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
5520 rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
5521out:
5522 return rc;
5523}
5524
5525#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \
5526 defined(CONFIG_CSDIO_VENDOR_ID) && \
5527 defined(CONFIG_CSDIO_DEVICE_ID) && \
5528 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5529
5530#define MBP_ON 1
5531#define MBP_OFF 0
5532
5533#define MBP_RESET_N \
5534 GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
5535#define MBP_INT0 \
5536 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
5537
5538#define MBP_MODE_CTRL_0 \
5539 GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5540#define MBP_MODE_CTRL_1 \
5541 GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5542#define MBP_MODE_CTRL_2 \
5543 GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5544#define TSIF_EN \
5545 GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5546#define TSIF_DATA \
5547 GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5548#define TSIF_CLK \
5549 GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5550
5551static struct msm_gpio mbp_cfg_data[] = {
5552 {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5553 "mbp_reset"},
5554 {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5555 "mbp_io_voltage"},
5556};
5557
5558static int mbp_config_gpios_pre_init(int enable)
5559{
5560 int rc = 0;
5561
5562 if (enable) {
5563 rc = msm_gpios_request_enable(mbp_cfg_data,
5564 ARRAY_SIZE(mbp_cfg_data));
5565 if (rc) {
5566 printk(KERN_ERR
5567 "%s: Failed to turnon GPIOs for mbp chip(%d)\n",
5568 __func__, rc);
5569 }
5570 } else
5571 msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
5572 return rc;
5573}
5574
Justin Paupore3f40f342011-08-10 18:52:16 -07005575static struct regulator_bulk_data mbp_regs_io[2];
5576static struct regulator_bulk_data mbp_regs_rf[2];
5577static struct regulator_bulk_data mbp_regs_adc[1];
5578static struct regulator_bulk_data mbp_regs_core[1];
5579
5580static int mbp_init_regs(struct device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005581{
Justin Paupore3f40f342011-08-10 18:52:16 -07005582 struct regulator_bulk_data regs[] = {
5583 /* Analog and I/O regs */
5584 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
5585 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
5586 /* RF regs */
5587 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
5588 { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 },
5589 /* ADC regs */
5590 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
5591 /* Core regs */
5592 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
5593 };
5594
5595 struct regulator_bulk_data *regptr = regs;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005596 int rc;
5597
Justin Paupore3f40f342011-08-10 18:52:16 -07005598 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs);
5599
5600 if (rc) {
5601 dev_err(dev, "%s: could not get regulators: %d\n",
5602 __func__, rc);
5603 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005604 }
5605
Justin Paupore3f40f342011-08-10 18:52:16 -07005606 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005607
Justin Paupore3f40f342011-08-10 18:52:16 -07005608 if (rc) {
5609 dev_err(dev, "%s: could not set voltages: %d\n",
5610 __func__, rc);
5611 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005612 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005613
5614 memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io));
5615 regptr += ARRAY_SIZE(mbp_regs_io);
5616
5617 memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf));
5618 regptr += ARRAY_SIZE(mbp_regs_rf);
5619
5620 memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc));
5621 regptr += ARRAY_SIZE(mbp_regs_adc);
5622
5623 memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core));
5624
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005625 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005626
5627reg_free:
5628 regulator_bulk_free(ARRAY_SIZE(regs), regs);
5629out:
5630 return rc;
5631}
5632
5633static int mbp_setup_rf_vregs(int state)
5634{
5635 return state ?
5636 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) :
5637 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005638}
5639
5640static int mbp_setup_vregs(int state)
5641{
Justin Paupore3f40f342011-08-10 18:52:16 -07005642 return state ?
5643 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) :
5644 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005645}
5646
5647static int mbp_set_tcxo_en(int enable)
5648{
5649 int rc;
5650 const char *id = "UBMC";
5651 struct vreg *vreg_analog = NULL;
5652
5653 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
5654 enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
5655 if (rc < 0) {
5656 printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
5657 __func__, enable ? "" : "de-");
5658 return -EIO;
5659 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005660 return rc;
5661}
5662
5663static void mbp_set_freeze_io(int state)
5664{
5665 if (state)
5666 gpio_set_value(85, 0);
5667 else
5668 gpio_set_value(85, 1);
5669}
5670
5671static int mbp_set_core_voltage_en(int enable)
5672{
Justin Paupore3f40f342011-08-10 18:52:16 -07005673 static bool is_enabled;
5674 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005675
Justin Paupore3f40f342011-08-10 18:52:16 -07005676 if (enable && !is_enabled) {
5677 rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core),
5678 mbp_regs_core);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005679 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005680 pr_err("%s: could not enable regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005681 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07005682 } else {
5683 is_enabled = true;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005684 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005685 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005686
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005687 return rc;
5688}
5689
5690static void mbp_set_reset(int state)
5691{
5692 if (state)
5693 gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
5694 else
5695 gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
5696}
5697
5698static int mbp_config_interface_mode(int state)
5699{
5700 if (state) {
5701 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
5702 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
5703 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
5704 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
5705 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
5706 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
5707 } else {
5708 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
5709 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
5710 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
5711 }
5712 return 0;
5713}
5714
5715static int mbp_setup_adc_vregs(int state)
5716{
Justin Paupore3f40f342011-08-10 18:52:16 -07005717 return state ?
5718 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) :
5719 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005720}
5721
5722static int mbp_power_up(void)
5723{
5724 int rc;
5725
5726 rc = mbp_config_gpios_pre_init(MBP_ON);
5727 if (rc)
5728 goto exit;
5729 pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__);
5730
5731 rc = mbp_setup_vregs(MBP_ON);
5732 if (rc)
5733 goto exit;
5734 pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
5735
5736 rc = mbp_set_tcxo_en(MBP_ON);
5737 if (rc)
5738 goto exit;
5739 pr_debug("%s: tcxo clock done\n", __func__);
5740
5741 mbp_set_freeze_io(MBP_OFF);
5742 pr_debug("%s: set gpio 85 to 1 done\n", __func__);
5743
5744 udelay(100);
5745 mbp_set_reset(MBP_ON);
5746
5747 udelay(300);
5748 rc = mbp_config_interface_mode(MBP_ON);
5749 if (rc)
5750 goto exit;
5751 pr_debug("%s: mbp_config_interface_mode() done\n", __func__);
5752
5753 udelay(100 + mbp_set_core_voltage_en(MBP_ON));
5754 pr_debug("%s: power gp16 1.2V done\n", __func__);
5755
5756 mbp_set_freeze_io(MBP_ON);
5757 pr_debug("%s: set gpio 85 to 0 done\n", __func__);
5758
5759 udelay(100);
5760
5761 rc = mbp_setup_rf_vregs(MBP_ON);
5762 if (rc)
5763 goto exit;
5764 pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
5765
5766 rc = mbp_setup_adc_vregs(MBP_ON);
5767 if (rc)
5768 goto exit;
5769 pr_debug("%s: s4 2.2V done\n", __func__);
5770
5771 udelay(200);
5772
5773 mbp_set_reset(MBP_OFF);
5774 pr_debug("%s: close gpio 44 done\n", __func__);
5775
5776 msleep(20);
5777exit:
5778 return rc;
5779}
5780
5781static int mbp_power_down(void)
5782{
5783 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005784
5785 mbp_set_reset(MBP_ON);
5786 pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
5787
5788 udelay(100);
5789
5790 rc = mbp_setup_adc_vregs(MBP_OFF);
5791 if (rc)
5792 goto exit;
5793 pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
5794
5795 udelay(5);
5796
5797 rc = mbp_setup_rf_vregs(MBP_OFF);
5798 if (rc)
5799 goto exit;
5800 pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
5801
5802 udelay(5);
5803
5804 mbp_set_freeze_io(MBP_OFF);
5805 pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
5806
5807 udelay(100);
5808 rc = mbp_set_core_voltage_en(MBP_OFF);
5809 if (rc)
5810 goto exit;
5811 pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
5812
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005813 rc = mbp_set_tcxo_en(MBP_OFF);
5814 if (rc)
5815 goto exit;
5816 pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
5817
Justin Paupore3f40f342011-08-10 18:52:16 -07005818 rc = mbp_setup_vregs(MBP_OFF);
5819 if (rc)
5820 goto exit;
5821 pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__);
5822
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005823 rc = mbp_config_gpios_pre_init(MBP_OFF);
5824 if (rc)
5825 goto exit;
5826exit:
5827 return rc;
5828}
5829
5830static void (*mbp_status_notify_cb)(int card_present, void *dev_id);
5831static void *mbp_status_notify_cb_devid;
5832static int mbp_power_status;
5833static int mbp_power_init_done;
5834
5835static uint32_t mbp_setup_power(struct device *dv,
5836 unsigned int power_status)
5837{
5838 int rc = 0;
5839 struct platform_device *pdev;
5840
5841 pdev = container_of(dv, struct platform_device, dev);
5842
5843 if (power_status == mbp_power_status)
5844 goto exit;
5845 if (power_status) {
5846 pr_debug("turn on power of mbp slot");
5847 rc = mbp_power_up();
5848 mbp_power_status = 1;
5849 } else {
5850 pr_debug("turn off power of mbp slot");
5851 rc = mbp_power_down();
5852 mbp_power_status = 0;
5853 }
5854exit:
5855 return rc;
5856};
5857
5858int mbp_register_status_notify(void (*callback)(int, void *),
5859 void *dev_id)
5860{
5861 mbp_status_notify_cb = callback;
5862 mbp_status_notify_cb_devid = dev_id;
5863 return 0;
5864}
5865
5866static unsigned int mbp_status(struct device *dev)
5867{
5868 return mbp_power_status;
5869}
5870
5871static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd)
5872{
5873 struct platform_device *pdev;
5874 uint32_t rc = 0;
5875
5876 pdev = container_of(dv, struct platform_device, dev);
5877 rc = msm_sdcc_setup_power(dv, vdd);
5878 if (rc) {
5879 pr_err("%s: Failed to setup power (%d)\n",
5880 __func__, rc);
5881 goto out;
5882 }
5883 if (!mbp_power_init_done) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005884 rc = mbp_init_regs(dv);
5885 if (rc) {
5886 dev_err(dv, "%s: regulator init failed: %d\n",
5887 __func__, rc);
5888 goto out;
5889 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005890 mbp_setup_power(dv, 1);
5891 mbp_setup_power(dv, 0);
5892 mbp_power_init_done = 1;
5893 }
5894 if (vdd >= 0x8000) {
5895 rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
5896 if (rc) {
5897 pr_err("%s: Failed to config mbp chip power (%d)\n",
5898 __func__, rc);
5899 goto out;
5900 }
5901 if (mbp_status_notify_cb) {
5902 mbp_status_notify_cb(mbp_power_status,
5903 mbp_status_notify_cb_devid);
5904 }
5905 }
5906out:
5907 /* should return 0 only */
5908 return 0;
5909}
5910
5911#endif
5912
5913#endif
5914
5915#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
5916#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5917static unsigned int msm7x30_sdcc_slot_status(struct device *dev)
5918{
5919 return (unsigned int)
5920 gpio_get_value_cansleep(
5921 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1));
5922}
5923#endif
5924
5925static int msm_sdcc_get_wpswitch(struct device *dv)
5926{
5927 void __iomem *wp_addr = 0;
5928 uint32_t ret = 0;
5929 struct platform_device *pdev;
5930
5931 if (!(machine_is_msm7x30_surf()))
5932 return -1;
5933 pdev = container_of(dv, struct platform_device, dev);
5934
5935 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
5936 if (!wp_addr) {
5937 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
5938 return -ENOMEM;
5939 }
5940
5941 ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
5942 pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
5943 pdev->id, ret);
5944 iounmap(wp_addr);
5945
5946 return ret;
5947}
5948#endif
5949
5950#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5951#if defined(CONFIG_CSDIO_VENDOR_ID) && \
5952 defined(CONFIG_CSDIO_DEVICE_ID) && \
5953 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5954static struct mmc_platform_data msm7x30_sdc1_data = {
5955 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
5956 .translate_vdd = msm_sdcc_setup_power_mbp,
5957 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
5958 .status = mbp_status,
5959 .register_status_notify = mbp_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005960 .msmsdcc_fmin = 144000,
5961 .msmsdcc_fmid = 24576000,
5962 .msmsdcc_fmax = 24576000,
5963 .nonremovable = 0,
5964};
5965#else
5966static struct mmc_platform_data msm7x30_sdc1_data = {
5967 .ocr_mask = MMC_VDD_165_195,
5968 .translate_vdd = msm_sdcc_setup_power,
5969 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005970 .msmsdcc_fmin = 144000,
5971 .msmsdcc_fmid = 24576000,
5972 .msmsdcc_fmax = 49152000,
5973 .nonremovable = 0,
5974};
5975#endif
5976#endif
5977
5978#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
5979static struct mmc_platform_data msm7x30_sdc2_data = {
5980 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
5981 .translate_vdd = msm_sdcc_setup_power,
5982#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5983 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
5984#else
5985 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
5986#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005987 .msmsdcc_fmin = 144000,
5988 .msmsdcc_fmid = 24576000,
5989 .msmsdcc_fmax = 49152000,
5990 .nonremovable = 1,
5991};
5992#endif
5993
5994#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
5995static struct mmc_platform_data msm7x30_sdc3_data = {
5996 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
5997 .translate_vdd = msm_sdcc_setup_power,
5998 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
5999#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
6000 .sdiowakeup_irq = MSM_GPIO_TO_INT(118),
6001#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006002 .msmsdcc_fmin = 144000,
6003 .msmsdcc_fmid = 24576000,
6004 .msmsdcc_fmax = 49152000,
6005 .nonremovable = 0,
6006};
6007#endif
6008
6009#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6010static struct mmc_platform_data msm7x30_sdc4_data = {
6011 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6012 .translate_vdd = msm_sdcc_setup_power,
6013 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6014#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6015 .status = msm7x30_sdcc_slot_status,
6016 .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
6017 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
6018#endif
6019 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006020 .msmsdcc_fmin = 144000,
6021 .msmsdcc_fmid = 24576000,
6022 .msmsdcc_fmax = 49152000,
6023 .nonremovable = 0,
6024};
6025#endif
6026
6027#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006028static int msm_sdc1_lvlshft_enable(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006029{
Justin Paupore3f40f342011-08-10 18:52:16 -07006030 static struct regulator *ldo5;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006031 int rc;
6032
6033 /* Enable LDO5, an input to the FET that powers slot 1 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006034
Justin Paupore3f40f342011-08-10 18:52:16 -07006035 ldo5 = regulator_get(NULL, "ldo5");
6036
6037 if (IS_ERR(ldo5)) {
6038 rc = PTR_ERR(ldo5);
6039 pr_err("%s: could not get ldo5: %d\n", __func__, rc);
6040 goto out;
6041 }
6042
6043 rc = regulator_set_voltage(ldo5, 2850000, 2850000);
6044 if (rc) {
6045 pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc);
6046 goto ldo5_free;
6047 }
6048
6049 rc = regulator_enable(ldo5);
6050 if (rc) {
6051 pr_err("%s: could not enable ldo5: %d\n", __func__, rc);
6052 goto ldo5_free;
6053 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006054
6055 /* Enable GPIO 35, to turn on the FET that powers slot 1 */
6056 rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
6057 ARRAY_SIZE(sdc1_lvlshft_cfg_data));
6058 if (rc)
6059 printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
6060
6061 rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg),
6062 1);
6063 if (rc)
6064 printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006065
6066 return 0;
6067
6068ldo5_free:
6069 regulator_put(ldo5);
6070out:
6071 ldo5 = NULL;
6072 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006073}
6074#endif
6075
Justin Paupore3f40f342011-08-10 18:52:16 -07006076static int mmc_regulator_init(int sdcc_no, const char *supply, int uV)
6077{
6078 int rc;
6079
6080 BUG_ON(sdcc_no < 1 || sdcc_no > 4);
6081
6082 sdcc_no--;
6083
6084 sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply);
6085
6086 if (IS_ERR(sdcc_vreg_data[sdcc_no])) {
6087 rc = PTR_ERR(sdcc_vreg_data[sdcc_no]);
6088 pr_err("%s: could not get regulator \"%s\": %d\n",
6089 __func__, supply, rc);
6090 goto out;
6091 }
6092
6093 rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV);
6094
6095 if (rc) {
6096 pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n",
6097 __func__, supply, uV, rc);
6098 goto reg_free;
6099 }
6100
6101 return rc;
6102
6103reg_free:
6104 regulator_put(sdcc_vreg_data[sdcc_no]);
6105out:
6106 sdcc_vreg_data[sdcc_no] = NULL;
6107 return rc;
6108}
6109
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006110static void __init msm7x30_init_mmc(void)
6111{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006112#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006113 if (mmc_regulator_init(1, "s3", 1800000))
6114 goto out1;
6115
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006116 if (machine_is_msm7x30_fluid()) {
6117 msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
Justin Paupore3f40f342011-08-10 18:52:16 -07006118 if (msm_sdc1_lvlshft_enable()) {
6119 pr_err("%s: could not enable level shift\n");
6120 goto out1;
6121 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006122 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006123
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006124 msm_add_sdcc(1, &msm7x30_sdc1_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006125out1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006126#endif
6127#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006128 if (mmc_regulator_init(2, "s3", 1800000))
6129 goto out2;
6130
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006131 if (machine_is_msm8x55_svlte_surf())
6132 msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
Sujith Reddy Thumma84a0f512011-08-29 09:57:03 +05306133 if (machine_is_msm8x55_svlte_surf() ||
6134 machine_is_msm8x55_svlte_ffa()) {
6135 msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
6136 msm7x30_sdc2_data.is_sdio_al_client = 1;
6137 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006138
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006139 msm_add_sdcc(2, &msm7x30_sdc2_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006140out2:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006141#endif
6142#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006143 if (mmc_regulator_init(3, "s3", 1800000))
6144 goto out3;
6145
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006146 msm_sdcc_setup_gpio(3, 1);
6147 msm_add_sdcc(3, &msm7x30_sdc3_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006148out3:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006149#endif
6150#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006151 if (mmc_regulator_init(4, "mmc", 2850000))
6152 return;
6153
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006154 msm_add_sdcc(4, &msm7x30_sdc4_data);
6155#endif
6156
6157}
6158
6159static void __init msm7x30_init_nand(void)
6160{
6161 char *build_id;
6162 struct flash_platform_data *plat_data;
6163
6164 build_id = socinfo_get_build_id();
6165 if (build_id == NULL) {
6166 pr_err("%s: Build ID not available from socinfo\n", __func__);
6167 return;
6168 }
6169
6170 if (build_id[8] == 'C' &&
6171 !msm_gpios_request_enable(msm_nand_ebi2_cfg_data,
6172 ARRAY_SIZE(msm_nand_ebi2_cfg_data))) {
6173 plat_data = msm_device_nand.dev.platform_data;
6174 plat_data->interleave = 1;
6175 printk(KERN_INFO "%s: Interleave mode Build ID found\n",
6176 __func__);
6177 }
6178}
6179
6180#ifdef CONFIG_SERIAL_MSM_CONSOLE
6181static struct msm_gpio uart2_config_data[] = {
6182 { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
6183 { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
6184 { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
6185 { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
6186};
6187
6188static void msm7x30_init_uart2(void)
6189{
6190 msm_gpios_request_enable(uart2_config_data,
6191 ARRAY_SIZE(uart2_config_data));
6192
6193}
6194#endif
6195
6196/* TSIF begin */
6197#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6198
6199#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6200#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6201#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6202#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6203
6204static const struct msm_gpio tsif_gpios[] = {
6205 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
6206 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
6207 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
6208 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
6209};
6210
6211static struct msm_tsif_platform_data tsif_platform_data = {
6212 .num_gpios = ARRAY_SIZE(tsif_gpios),
6213 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -07006214 .tsif_pclk = "iface_clk",
6215 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006216};
6217#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
6218/* TSIF end */
6219
6220static void __init pmic8058_leds_init(void)
6221{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306222 if (machine_is_msm7x30_surf())
6223 pm8058_7x30_data.leds_pdata = &pm8058_surf_leds_data;
6224 else if (!machine_is_msm7x30_fluid())
6225 pm8058_7x30_data.leds_pdata = &pm8058_ffa_leds_data;
6226 else if (machine_is_msm7x30_fluid())
6227 pm8058_7x30_data.leds_pdata = &pm8058_fluid_leds_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006228}
6229
6230static struct msm_spm_platform_data msm_spm_data __initdata = {
6231 .reg_base_addr = MSM_SAW_BASE,
6232
6233 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
6234 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
6235 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
6236 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
6237
6238 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
6239 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
6240 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
6241
6242 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
6243 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
6244 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
6245
6246 .awake_vlevel = 0xF2,
6247 .retention_vlevel = 0xE0,
6248 .collapse_vlevel = 0x72,
6249 .retention_mid_vlevel = 0xE0,
6250 .collapse_mid_vlevel = 0xE0,
6251
6252 .vctl_timeout_us = 50,
6253};
6254
6255#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6256 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6257
6258#define TSC2007_TS_PEN_INT 20
6259
6260static struct msm_gpio tsc2007_config_data[] = {
6261 { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
6262 "tsc2007_irq" },
6263};
6264
Justin Paupore3f40f342011-08-10 18:52:16 -07006265static struct regulator_bulk_data tsc2007_regs[] = {
6266 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
6267 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
6268};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006269
6270static int tsc2007_init(void)
6271{
6272 int rc;
6273
Justin Paupore3f40f342011-08-10 18:52:16 -07006274 rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006275
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006276 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006277 pr_err("%s: could not get regulators: %d\n", __func__, rc);
6278 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006279 }
6280
Justin Paupore3f40f342011-08-10 18:52:16 -07006281 rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6282
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006283 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006284 pr_err("%s: could not set voltages: %d\n", __func__, rc);
6285 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006286 }
6287
Justin Paupore3f40f342011-08-10 18:52:16 -07006288 rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006289
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006290 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006291 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
6292 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006293 }
6294
6295 rc = msm_gpios_request_enable(tsc2007_config_data,
6296 ARRAY_SIZE(tsc2007_config_data));
6297 if (rc) {
6298 pr_err("%s: Unable to request gpios\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006299 goto reg_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006300 }
6301
6302 return 0;
6303
Justin Paupore3f40f342011-08-10 18:52:16 -07006304reg_disable:
6305 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6306reg_free:
6307 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6308out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006309 return rc;
6310}
6311
6312static int tsc2007_get_pendown_state(void)
6313{
6314 int rc;
6315
6316 rc = gpio_get_value(TSC2007_TS_PEN_INT);
6317 if (rc < 0) {
6318 pr_err("%s: MSM GPIO %d read failed\n", __func__,
6319 TSC2007_TS_PEN_INT);
6320 return rc;
6321 }
6322
6323 return (rc == 0 ? 1 : 0);
6324}
6325
6326static void tsc2007_exit(void)
6327{
Justin Paupore3f40f342011-08-10 18:52:16 -07006328
6329 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6330 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006331
6332 msm_gpios_disable_free(tsc2007_config_data,
6333 ARRAY_SIZE(tsc2007_config_data));
6334}
6335
6336static int tsc2007_power_shutdown(bool enable)
6337{
6338 int rc;
6339
Justin Paupore3f40f342011-08-10 18:52:16 -07006340 rc = (enable == false) ?
6341 regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) :
6342 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6343
6344 if (rc) {
6345 pr_err("%s: could not %sable regulators: %d\n",
6346 __func__, enable ? "dis" : "en", rc);
6347 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006348 }
6349
Justin Paupore3f40f342011-08-10 18:52:16 -07006350 if (enable == false)
6351 msleep(20);
6352
6353 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006354}
6355
6356static struct tsc2007_platform_data tsc2007_ts_data = {
6357 .model = 2007,
6358 .x_plate_ohms = 300,
Anirudh Ghayala2cf2e22012-01-25 12:29:42 +05306359 .min_x = 210,
6360 .max_x = 3832,
6361 .min_y = 150,
6362 .max_y = 3936,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006363 .irq_flags = IRQF_TRIGGER_LOW,
6364 .init_platform_hw = tsc2007_init,
6365 .exit_platform_hw = tsc2007_exit,
6366 .power_shutdown = tsc2007_power_shutdown,
6367 .invert_x = true,
6368 .invert_y = true,
6369 /* REVISIT: Temporary fix for reversed pressure */
6370 .invert_z1 = true,
6371 .invert_z2 = true,
6372 .get_pendown_state = tsc2007_get_pendown_state,
6373};
6374
6375static struct i2c_board_info tsc_i2c_board_info[] = {
6376 {
6377 I2C_BOARD_INFO("tsc2007", 0x48),
6378 .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
6379 .platform_data = &tsc2007_ts_data,
6380 },
6381};
6382#endif
6383
Justin Paupore3f40f342011-08-10 18:52:16 -07006384static struct regulator_bulk_data regs_isa1200[] = {
6385 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
6386 { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006387};
6388
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006389static int isa1200_power(int vreg_on)
6390{
Justin Paupore3f40f342011-08-10 18:52:16 -07006391 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006392
Justin Paupore3f40f342011-08-10 18:52:16 -07006393 rc = vreg_on ?
6394 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) :
6395 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006396
Justin Paupore3f40f342011-08-10 18:52:16 -07006397 if (rc) {
6398 pr_err("%s: could not %sable regulators: %d\n",
6399 __func__, vreg_on ? "en" : "dis", rc);
6400 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006401 }
6402
6403 /* vote for DO buffer */
6404 rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO,
6405 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
6406 if (rc) {
6407 pr_err("%s: unable to %svote for d0 clk\n",
6408 __func__, vreg_on ? "" : "de-");
6409 goto vreg_fail;
6410 }
6411
6412 return 0;
6413
6414vreg_fail:
Justin Paupore3f40f342011-08-10 18:52:16 -07006415 if (vreg_on)
6416 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6417 else
6418 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6419out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006420 return rc;
6421}
6422
6423static int isa1200_dev_setup(bool enable)
6424{
Justin Paupore3f40f342011-08-10 18:52:16 -07006425 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006426
6427 if (enable == true) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006428 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200),
6429 regs_isa1200);
6430
6431 if (rc) {
6432 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006433 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006434 goto out;
6435 }
6436
6437 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200),
6438 regs_isa1200);
6439 if (rc) {
6440 pr_err("%s: could not set voltages: %d\n",
6441 __func__, rc);
6442 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006443 }
6444
6445 rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
6446 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
6447 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
6448 if (rc) {
6449 pr_err("%s: Could not configure gpio %d\n",
6450 __func__, HAP_LVL_SHFT_MSM_GPIO);
Justin Paupore3f40f342011-08-10 18:52:16 -07006451 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006452 }
6453
6454 rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
6455 if (rc) {
6456 pr_err("%s: unable to request gpio %d (%d)\n",
6457 __func__, HAP_LVL_SHFT_MSM_GPIO, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006458 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006459 }
6460
6461 gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
6462 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006463 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006464 gpio_free(HAP_LVL_SHFT_MSM_GPIO);
6465 }
6466
6467 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07006468
6469reg_free:
6470 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6471out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006472 return rc;
6473}
6474static struct isa1200_platform_data isa1200_1_pdata = {
6475 .name = "vibrator",
6476 .power_on = isa1200_power,
6477 .dev_setup = isa1200_dev_setup,
6478 .pwm_ch_id = 1, /*channel id*/
6479 /*gpio to enable haptic*/
6480 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka03122322011-09-09 15:15:43 +05306481 .hap_len_gpio = -1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006482 .max_timeout = 15000,
6483 .mode_ctrl = PWM_GEN_MODE,
6484 .pwm_fd = {
6485 .pwm_div = 256,
6486 },
6487 .is_erm = false,
6488 .smart_en = true,
6489 .ext_clk_en = true,
6490 .chip_en = 1,
6491};
6492
6493static struct i2c_board_info msm_isa1200_board_info[] = {
6494 {
6495 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
6496 .platform_data = &isa1200_1_pdata,
6497 },
6498};
6499
6500
6501static int kp_flip_mpp_config(void)
6502{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306503 struct pm8xxx_mpp_config_data kp_flip_mpp = {
6504 .type = PM8XXX_MPP_TYPE_D_INPUT,
6505 .level = PM8018_MPP_DIG_LEVEL_S3,
6506 .control = PM8XXX_MPP_DIN_TO_INT,
6507 };
6508
6509 return pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(PM_FLIP_MPP),
6510 &kp_flip_mpp);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006511}
6512
6513static struct flip_switch_pdata flip_switch_data = {
6514 .name = "kp_flip_switch",
6515 .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP,
6516 .left_key = KEY_OPEN,
6517 .right_key = KEY_CLOSE,
6518 .active_low = 0,
6519 .wakeup = 1,
6520 .flip_mpp_config = kp_flip_mpp_config,
6521};
6522
6523static struct platform_device flip_switch_device = {
6524 .name = "kp_flip_switch",
6525 .id = -1,
6526 .dev = {
6527 .platform_data = &flip_switch_data,
6528 }
6529};
6530
Justin Paupore3f40f342011-08-10 18:52:16 -07006531static struct regulator_bulk_data regs_tma300[] = {
6532 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
6533 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006534};
6535
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006536static int tma300_power(int vreg_on)
6537{
Justin Paupore3f40f342011-08-10 18:52:16 -07006538 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006539
Justin Paupore3f40f342011-08-10 18:52:16 -07006540 rc = vreg_on ?
6541 regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) :
6542 regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006543
Justin Paupore3f40f342011-08-10 18:52:16 -07006544 if (rc)
6545 pr_err("%s: could not %sable regulators: %d\n",
6546 __func__, vreg_on ? "en" : "dis", rc);
6547 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006548}
6549
6550#define TS_GPIO_IRQ 150
6551
6552static int tma300_dev_setup(bool enable)
6553{
Justin Paupore3f40f342011-08-10 18:52:16 -07006554 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006555
6556 if (enable) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006557 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300),
6558 regs_tma300);
6559
6560 if (rc) {
6561 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006562 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006563 goto out;
6564 }
6565
6566 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300),
6567 regs_tma300);
6568
6569 if (rc) {
6570 pr_err("%s: could not set voltages: %d\n",
6571 __func__, rc);
6572 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006573 }
6574
6575 /* enable interrupt gpio */
6576 rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
6577 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
6578 if (rc) {
6579 pr_err("%s: Could not configure gpio %d\n",
6580 __func__, TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -07006581 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006582 }
6583
6584 /* virtual keys */
6585 tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
6586 properties_kobj = kobject_create_and_add("board_properties",
6587 NULL);
6588 if (!properties_kobj) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006589 pr_err("%s: failed to create a kobject "
6590 "for board_properties\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006591 rc = -ENOMEM;
Justin Paupore3f40f342011-08-10 18:52:16 -07006592 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006593 }
6594 rc = sysfs_create_group(properties_kobj,
6595 &tma300_properties_attr_group);
6596 if (rc) {
6597 pr_err("%s: failed to create a sysfs entry %s\n",
6598 __func__, tma300_vkeys_attr.attr.name);
Justin Paupore3f40f342011-08-10 18:52:16 -07006599 goto kobj_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006600 }
6601 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006602 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006603 /* destroy virtual keys */
6604 if (properties_kobj) {
6605 sysfs_remove_group(properties_kobj,
6606 &tma300_properties_attr_group);
6607 kobject_put(properties_kobj);
6608 }
6609 }
6610 return 0;
6611
Justin Paupore3f40f342011-08-10 18:52:16 -07006612kobj_free:
6613 kobject_put(properties_kobj);
6614 properties_kobj = NULL;
6615reg_free:
6616 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
6617out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006618 return rc;
6619}
6620
6621static struct cy8c_ts_platform_data cy8ctma300_pdata = {
6622 .power_on = tma300_power,
6623 .dev_setup = tma300_dev_setup,
6624 .ts_name = "msm_tma300_ts",
6625 .dis_min_x = 0,
6626 .dis_max_x = 479,
6627 .dis_min_y = 0,
6628 .dis_max_y = 799,
6629 .res_x = 479,
6630 .res_y = 1009,
6631 .min_tid = 1,
6632 .max_tid = 255,
6633 .min_touch = 0,
6634 .max_touch = 255,
6635 .min_width = 0,
6636 .max_width = 255,
6637 .invert_y = 1,
6638 .nfingers = 4,
6639 .irq_gpio = TS_GPIO_IRQ,
6640 .resout_gpio = -1,
6641};
6642
6643static struct i2c_board_info cy8ctma300_board_info[] = {
6644 {
6645 I2C_BOARD_INFO("cy8ctma300", 0x2),
6646 .platform_data = &cy8ctma300_pdata,
6647 }
6648};
6649
Daniel Walker8d747cd2010-02-25 11:37:43 -08006650static void __init msm7x30_init(void)
6651{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006652 int rc;
6653 unsigned smem_size;
6654 uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56,
6655 0,
6656 GPIO_CFG_OUTPUT,
6657 GPIO_CFG_NO_PULL,
6658 GPIO_CFG_2MA);
6659 uint32_t soc_version = 0;
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05306660
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006661 soc_version = socinfo_get_version();
6662
Stephen Boydbb600ae2011-08-02 20:11:40 -07006663 msm_clock_init(&msm7x30_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006664#ifdef CONFIG_SERIAL_MSM_CONSOLE
6665 msm7x30_init_uart2();
6666#endif
6667 msm_spm_init(&msm_spm_data, 1);
Matt Wagantallec57f062011-08-16 23:54:46 -07006668 acpuclk_init(&acpuclk_7x30_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006669 if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid())
6670 msm7x30_cfg_smsc911x();
6671
6672#ifdef CONFIG_USB_MSM_OTG_72K
6673 if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 &&
6674 SOCINFO_VERSION_MINOR(soc_version) >= 1) {
6675 pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
6676 msm_otg_pdata.ldo_set_voltage = 0;
6677 }
6678
6679 msm_device_otg.dev.platform_data = &msm_otg_pdata;
6680#ifdef CONFIG_USB_GADGET
6681 msm_otg_pdata.swfi_latency =
6682 msm_pm_data
6683 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
6684 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
6685#endif
6686#endif
6687 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
6688 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
6689#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6690 msm_device_tsif.dev.platform_data = &tsif_platform_data;
6691#endif
6692 if (machine_is_msm7x30_fluid()) {
6693 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
6694 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
6695 } else {
6696 msm_adc_pdata.dev_names = msm_adc_surf_device_names;
6697 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names);
6698 }
6699
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306700 pmic8058_leds_init();
6701
6702 buses_init();
6703
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306704#ifdef CONFIG_MSM_SSBI
6705 msm_device_ssbi_pmic1.dev.platform_data =
6706 &msm7x30_ssbi_pm8058_pdata;
6707#endif
6708
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006709 platform_add_devices(msm_footswitch_devices,
6710 msm_num_footswitch_devices);
Daniel Walker8d747cd2010-02-25 11:37:43 -08006711 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006712#ifdef CONFIG_USB_EHCI_MSM_72K
6713 msm_add_host(0, &msm_usb_host_pdata);
6714#endif
6715 msm7x30_init_mmc();
6716 msm7x30_init_nand();
6717 msm_qsd_spi_init();
6718
6719#ifdef CONFIG_SPI_QSD
6720 if (machine_is_msm7x30_fluid())
6721 spi_register_board_info(lcdc_sharp_spi_board_info,
6722 ARRAY_SIZE(lcdc_sharp_spi_board_info));
6723 else
6724 spi_register_board_info(lcdc_toshiba_spi_board_info,
6725 ARRAY_SIZE(lcdc_toshiba_spi_board_info));
6726#endif
6727
Justin Paupore3f40f342011-08-10 18:52:16 -07006728 atv_dac_power_init();
6729 sensors_ldo_init();
6730 hdmi_init_regs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006731 msm_fb_add_devices();
6732 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06006733 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006734 msm_device_i2c_init();
6735 msm_device_i2c_2_init();
6736 qup_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006737 msm7x30_init_marimba();
6738#ifdef CONFIG_MSM7KV2_AUDIO
6739 snddev_poweramp_gpio_init();
Justin Paupore3f40f342011-08-10 18:52:16 -07006740 snddev_hsed_voltage_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006741 aux_pcm_gpio_init();
6742#endif
6743
6744 i2c_register_board_info(0, msm_i2c_board_info,
6745 ARRAY_SIZE(msm_i2c_board_info));
6746
6747 if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid())
6748 marimba_pdata.tsadc = &marimba_tsadc_pdata;
6749
6750 if (machine_is_msm7x30_fluid())
6751 i2c_register_board_info(0, cy8info,
6752 ARRAY_SIZE(cy8info));
6753#ifdef CONFIG_BOSCH_BMA150
6754 if (machine_is_msm7x30_fluid())
6755 i2c_register_board_info(0, bma150_board_info,
6756 ARRAY_SIZE(bma150_board_info));
6757#endif
6758
6759 i2c_register_board_info(2, msm_marimba_board_info,
6760 ARRAY_SIZE(msm_marimba_board_info));
6761
6762 i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info,
6763 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info));
6764
6765 i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
6766 ARRAY_SIZE(msm_camera_boardinfo));
6767
6768 bt_power_init();
6769#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006770 msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
6771#endif
6772 if (machine_is_msm7x30_fluid())
6773 i2c_register_board_info(0, msm_isa1200_board_info,
6774 ARRAY_SIZE(msm_isa1200_board_info));
6775
6776#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6777 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6778 if (machine_is_msm8x55_svlte_ffa())
6779 i2c_register_board_info(2, tsc_i2c_board_info,
6780 ARRAY_SIZE(tsc_i2c_board_info));
6781#endif
6782
6783 if (machine_is_msm7x30_surf())
6784 platform_device_register(&flip_switch_device);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306785
6786 pm8058_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006787
6788 if (machine_is_msm7x30_fluid()) {
6789 /* Initialize platform data for fluid v2 hardware */
6790 if (SOCINFO_VERSION_MAJOR(
6791 socinfo_get_platform_version()) == 2) {
6792 cy8ctma300_pdata.res_y = 920;
6793 cy8ctma300_pdata.invert_y = 0;
6794 }
6795 i2c_register_board_info(0, cy8ctma300_board_info,
6796 ARRAY_SIZE(cy8ctma300_board_info));
6797 }
6798
6799 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
6800 rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE);
6801 if (rc)
6802 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
6803 __func__, usb_hub_gpio_cfg_value, rc);
6804 }
6805
6806 boot_reason = *(unsigned int *)
6807 (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
6808 printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
6809}
6810
6811static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
6812static int __init pmem_sf_size_setup(char *p)
6813{
6814 pmem_sf_size = memparse(p, NULL);
6815 return 0;
6816}
6817early_param("pmem_sf_size", pmem_sf_size_setup);
6818
6819static unsigned fb_size = MSM_FB_SIZE;
6820static int __init fb_size_setup(char *p)
6821{
6822 fb_size = memparse(p, NULL);
6823 return 0;
6824}
6825early_param("fb_size", fb_size_setup);
6826
6827static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
6828static int __init pmem_adsp_size_setup(char *p)
6829{
6830 pmem_adsp_size = memparse(p, NULL);
6831 return 0;
6832}
6833early_param("pmem_adsp_size", pmem_adsp_size_setup);
6834
6835static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE;
6836static int __init fluid_pmem_adsp_size_setup(char *p)
6837{
6838 fluid_pmem_adsp_size = memparse(p, NULL);
6839 return 0;
6840}
6841early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup);
6842
6843static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
6844static int __init pmem_audio_size_setup(char *p)
6845{
6846 pmem_audio_size = memparse(p, NULL);
6847 return 0;
6848}
6849early_param("pmem_audio_size", pmem_audio_size_setup);
6850
6851static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE;
6852static int __init pmem_kernel_ebi0_size_setup(char *p)
6853{
6854 pmem_kernel_ebi0_size = memparse(p, NULL);
6855 return 0;
6856}
6857early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
6858
6859static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
6860 [MEMTYPE_SMI] = {
6861 },
6862 [MEMTYPE_EBI0] = {
6863 .flags = MEMTYPE_FLAGS_1M_ALIGN,
6864 },
6865 [MEMTYPE_EBI1] = {
6866 .flags = MEMTYPE_FLAGS_1M_ALIGN,
6867 },
6868};
6869
6870static void __init size_pmem_devices(void)
6871{
6872#ifdef CONFIG_ANDROID_PMEM
6873 unsigned long size;
6874
6875 if machine_is_msm7x30_fluid()
6876 size = fluid_pmem_adsp_size;
6877 else
6878 size = pmem_adsp_size;
6879 android_pmem_adsp_pdata.size = size;
6880 android_pmem_audio_pdata.size = pmem_audio_size;
6881 android_pmem_pdata.size = pmem_sf_size;
6882#endif
6883}
6884
6885static void __init reserve_memory_for(struct android_pmem_platform_data *p)
6886{
6887 msm7x30_reserve_table[p->memory_type].size += p->size;
6888}
6889
6890static void __init reserve_pmem_memory(void)
6891{
6892#ifdef CONFIG_ANDROID_PMEM
6893 reserve_memory_for(&android_pmem_adsp_pdata);
6894 reserve_memory_for(&android_pmem_audio_pdata);
6895 reserve_memory_for(&android_pmem_pdata);
6896 msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
6897#endif
6898}
6899
6900static void __init msm7x30_calculate_reserve_sizes(void)
6901{
6902 size_pmem_devices();
6903 reserve_pmem_memory();
6904}
6905
6906static int msm7x30_paddr_to_memtype(unsigned int paddr)
6907{
Pankaj Kumarac69ee62012-01-26 00:21:56 +05306908 if (paddr < phys_add)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006909 return MEMTYPE_EBI0;
Pankaj Kumarac69ee62012-01-26 00:21:56 +05306910 if (paddr >= phys_add && paddr < 0x80000000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006911 return MEMTYPE_EBI1;
6912 return MEMTYPE_NONE;
6913}
6914
6915static struct reserve_info msm7x30_reserve_info __initdata = {
6916 .memtype_reserve_table = msm7x30_reserve_table,
6917 .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes,
6918 .paddr_to_memtype = msm7x30_paddr_to_memtype,
6919};
6920
6921static void __init msm7x30_reserve(void)
6922{
6923 reserve_info = &msm7x30_reserve_info;
6924 msm_reserve();
6925}
6926
6927static void __init msm7x30_allocate_memory_regions(void)
6928{
6929 void *addr;
6930 unsigned long size;
6931
6932 size = fb_size ? : MSM_FB_SIZE;
6933 addr = alloc_bootmem_align(size, 0x1000);
6934 msm_fb_resources[0].start = __pa(addr);
6935 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
6936 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
6937 size, addr, __pa(addr));
Daniel Walker8d747cd2010-02-25 11:37:43 -08006938}
6939
6940static void __init msm7x30_map_io(void)
6941{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006942 msm_shared_ram_phys = 0x00100000;
Daniel Walker8d747cd2010-02-25 11:37:43 -08006943 msm_map_msm7x30_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07006944 if (socinfo_init() < 0)
6945 printk(KERN_ERR "%s: socinfo_init() failed!\n",
6946 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006947}
6948
6949static void __init msm7x30_init_early(void)
6950{
6951 msm7x30_allocate_memory_regions();
Daniel Walker8d747cd2010-02-25 11:37:43 -08006952}
6953
Pankaj Kumarac69ee62012-01-26 00:21:56 +05306954static void __init msm7x30_fixup(struct machine_desc *desc, struct tag *tags,
6955 char **cmdline, struct meminfo *mi)
6956{
6957 for (; tags->hdr.size; tags = tag_next(tags)) {
6958 if (tags->hdr.tag == ATAG_MEM && tags->u.mem.start ==
6959 DDR1_BANK_BASE) {
6960 ebi1_phys_offset = DDR1_BANK_BASE;
6961 phys_add = DDR1_BANK_BASE;
6962 break;
6963 }
6964 }
6965}
6966
Daniel Walker8d747cd2010-02-25 11:37:43 -08006967MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00006968 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006969 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006970 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006971 .init_irq = msm7x30_init_irq,
6972 .init_machine = msm7x30_init,
6973 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006974 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05306975 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05306976 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006977MACHINE_END
6978
6979MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00006980 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006981 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006982 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006983 .init_irq = msm7x30_init_irq,
6984 .init_machine = msm7x30_init,
6985 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006986 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05306987 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05306988 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006989MACHINE_END
6990
6991MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
Russell Kingb75c1782011-01-04 19:03:16 +00006992 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006993 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006994 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08006995 .init_irq = msm7x30_init_irq,
6996 .init_machine = msm7x30_init,
6997 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006998 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05306999 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307000 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007001MACHINE_END
7002
7003MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
7004 .boot_params = PHYS_OFFSET + 0x100,
7005 .map_io = msm7x30_map_io,
7006 .reserve = msm7x30_reserve,
7007 .init_irq = msm7x30_init_irq,
7008 .init_machine = msm7x30_init,
7009 .timer = &msm_timer,
7010 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307011 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307012 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007013MACHINE_END
7014
7015MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA")
7016 .boot_params = PHYS_OFFSET + 0x100,
7017 .map_io = msm7x30_map_io,
7018 .reserve = msm7x30_reserve,
7019 .init_irq = msm7x30_init_irq,
7020 .init_machine = msm7x30_init,
7021 .timer = &msm_timer,
7022 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307023 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307024 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007025MACHINE_END
7026MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
7027 .boot_params = PHYS_OFFSET + 0x100,
7028 .map_io = msm7x30_map_io,
7029 .reserve = msm7x30_reserve,
7030 .init_irq = msm7x30_init_irq,
7031 .init_machine = msm7x30_init,
7032 .timer = &msm_timer,
7033 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307034 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307035 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007036MACHINE_END
7037MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA")
7038 .boot_params = PHYS_OFFSET + 0x100,
7039 .map_io = msm7x30_map_io,
7040 .reserve = msm7x30_reserve,
7041 .init_irq = msm7x30_init_irq,
7042 .init_machine = msm7x30_init,
7043 .timer = &msm_timer,
7044 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307045 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307046 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007047MACHINE_END