blob: 260c88079bc1beee5da4ff2fa36afdf453cc8caf [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
Asutosh Das853bbcd2012-02-01 10:40:05 +0530121#define PMIC_GPIO_SDC4_PWR_EN_N 24 /* PMIC GPIO Number 25 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700122
123/* Macros assume PMIC GPIOs start at 0 */
124#define PM8058_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio + NR_GPIO_IRQS)
125#define PM8058_GPIO_SYS_TO_PM(sys_gpio) (sys_gpio - NR_GPIO_IRQS)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530126#define PM8058_MPP_BASE PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS)
127#define PM8058_MPP_PM_TO_SYS(pm_gpio) (pm_gpio + PM8058_MPP_BASE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700128
129#define PMIC_GPIO_FLASH_BOOST_ENABLE 15 /* PMIC GPIO Number 16 */
130#define PMIC_GPIO_HAP_ENABLE 16 /* PMIC GPIO Number 17 */
131
132#define PMIC_GPIO_WLAN_EXT_POR 22 /* PMIC GPIO NUMBER 23 */
133
134#define BMA150_GPIO_INT 1
135
136#define HAP_LVL_SHFT_MSM_GPIO 24
137
138#define PMIC_GPIO_QUICKVX_CLK 37 /* PMIC GPIO 38 */
139
140#define PM_FLIP_MPP 5 /* PMIC MPP 06 */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530141
Pankaj Kumarac69ee62012-01-26 00:21:56 +0530142#define DDR1_BANK_BASE 0X20000000
143#define DDR2_BANK_BASE 0X40000000
144
145static unsigned int phys_add = DDR2_BANK_BASE;
146unsigned long ebi1_phys_offset = DDR2_BANK_BASE;
147EXPORT_SYMBOL(ebi1_phys_offset);
148
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530149struct pm8xxx_gpio_init_info {
150 unsigned gpio;
151 struct pm_gpio config;
152};
153
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700154static int pm8058_gpios_init(void)
155{
156 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700157
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530158 struct pm8xxx_gpio_init_info sdc4_en = {
159 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_EN_N),
160 {
161 .direction = PM_GPIO_DIR_OUT,
162 .pull = PM_GPIO_PULL_NO,
163 .vin_sel = PM8058_GPIO_VIN_L5,
164 .function = PM_GPIO_FUNC_NORMAL,
165 .inv_int_pol = 0,
166 .out_strength = PM_GPIO_STRENGTH_LOW,
167 .output_value = 0,
168 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700169 };
170
Asutosh Das853bbcd2012-02-01 10:40:05 +0530171 struct pm8xxx_gpio_init_info sdc4_pwr_en = {
172 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
173 {
174 .direction = PM_GPIO_DIR_OUT,
175 .pull = PM_GPIO_PULL_NO,
176 .vin_sel = PM8058_GPIO_VIN_L5,
177 .function = PM_GPIO_FUNC_NORMAL,
178 .inv_int_pol = 0,
179 .out_strength = PM_GPIO_STRENGTH_LOW,
180 .output_value = 0,
181 },
182 };
183
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530184 struct pm8xxx_gpio_init_info haptics_enable = {
185 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
186 {
187 .direction = PM_GPIO_DIR_OUT,
188 .pull = PM_GPIO_PULL_NO,
189 .out_strength = PM_GPIO_STRENGTH_HIGH,
190 .function = PM_GPIO_FUNC_NORMAL,
191 .inv_int_pol = 0,
192 .vin_sel = 2,
193 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
194 .output_value = 0,
195 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700196 };
197
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530198 struct pm8xxx_gpio_init_info hdmi_5V_en = {
199 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HDMI_5V_EN_V3),
200 {
201 .direction = PM_GPIO_DIR_OUT,
202 .pull = PM_GPIO_PULL_NO,
203 .vin_sel = PM8058_GPIO_VIN_VPH,
204 .function = PM_GPIO_FUNC_NORMAL,
205 .out_strength = PM_GPIO_STRENGTH_LOW,
206 .output_value = 0,
207 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700208 };
209
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530210 struct pm8xxx_gpio_init_info flash_boost_enable = {
211 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE),
212 {
213 .direction = PM_GPIO_DIR_OUT,
214 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
215 .output_value = 0,
216 .pull = PM_GPIO_PULL_NO,
217 .vin_sel = PM8058_GPIO_VIN_S3,
218 .out_strength = PM_GPIO_STRENGTH_HIGH,
219 .function = PM_GPIO_FUNC_2,
220 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700221 };
222
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530223 struct pm8xxx_gpio_init_info gpio23 = {
224 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_WLAN_EXT_POR),
225 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700226 .direction = PM_GPIO_DIR_OUT,
227 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
228 .output_value = 0,
229 .pull = PM_GPIO_PULL_NO,
230 .vin_sel = 2,
231 .out_strength = PM_GPIO_STRENGTH_LOW,
232 .function = PM_GPIO_FUNC_NORMAL,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530233 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700234 };
235
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700236#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530237 struct pm8xxx_gpio_init_info sdcc_det = {
238 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1),
239 {
240 .direction = PM_GPIO_DIR_IN,
241 .pull = PM_GPIO_PULL_UP_1P5,
242 .vin_sel = 2,
243 .function = PM_GPIO_FUNC_NORMAL,
244 .inv_int_pol = 0,
245 },
246 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700247
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530248 if (machine_is_msm7x30_fluid())
249 sdcc_det.config.inv_int_pol = 1;
250
251 rc = pm8xxx_gpio_config(sdcc_det.gpio, &sdcc_det.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700252 if (rc) {
253 pr_err("%s PMIC_GPIO_SD_DET config failed\n", __func__);
254 return rc;
255 }
256#endif
257
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530258 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
259 machine_is_msm7x30_fluid())
260 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V2;
261 else
262 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V3;
263
264 hdmi_5V_en.gpio = PM8058_GPIO_PM_TO_SYS(hdmi_5V_en.gpio);
265
266 rc = pm8xxx_gpio_config(hdmi_5V_en.gpio, &hdmi_5V_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700267 if (rc) {
268 pr_err("%s PMIC_GPIO_HDMI_5V_EN config failed\n", __func__);
269 return rc;
270 }
271
272 /* Deassert GPIO#23 (source for Ext_POR on WLAN-Volans) */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530273 rc = pm8xxx_gpio_config(gpio23.gpio, &gpio23.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700274 if (rc) {
275 pr_err("%s PMIC_GPIO_WLAN_EXT_POR config failed\n", __func__);
276 return rc;
277 }
278
279 if (machine_is_msm7x30_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530280 /* Haptics gpio */
281 rc = pm8xxx_gpio_config(haptics_enable.gpio,
282 &haptics_enable.config);
283 if (rc) {
284 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
285 haptics_enable.gpio);
286 return rc;
287 }
288 /* Flash boost gpio */
289 rc = pm8xxx_gpio_config(flash_boost_enable.gpio,
290 &flash_boost_enable.config);
291 if (rc) {
292 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
293 flash_boost_enable.gpio);
294 return rc;
295 }
296 /* SCD4 gpio */
297 rc = pm8xxx_gpio_config(sdc4_en.gpio, &sdc4_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700298 if (rc) {
299 pr_err("%s PMIC_GPIO_SDC4_EN_N config failed\n",
300 __func__);
301 return rc;
302 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530303 rc = gpio_request(sdc4_en.gpio, "sdc4_en");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700304 if (rc) {
305 pr_err("%s PMIC_GPIO_SDC4_EN_N gpio_request failed\n",
306 __func__);
307 return rc;
308 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530309 gpio_set_value_cansleep(sdc4_en.gpio, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700310 }
Asutosh Das853bbcd2012-02-01 10:40:05 +0530311 /* FFA -> gpio_25 controls vdd of sdcc4 */
312 else {
313 /* SCD4 gpio_25 */
314 rc = pm8xxx_gpio_config(sdc4_pwr_en.gpio, &sdc4_pwr_en.config);
315 if (rc) {
316 pr_err("%s PMIC_GPIO_SDC4_PWR_EN_N config failed: %d\n",
317 __func__, rc);
318 return rc;
319 }
320
321 rc = gpio_request(sdc4_pwr_en.gpio, "sdc4_pwr_en");
322 if (rc) {
323 pr_err("PMIC_GPIO_SDC4_PWR_EN_N gpio_req failed: %d\n",
324 rc);
325 return rc;
326 }
327 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700328
329 return 0;
330}
331
Justin Paupore637a25d2011-07-14 17:11:04 -0700332/* Regulator API support */
333
334#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
335static struct platform_device msm_proccomm_regulator_dev = {
336 .name = PROCCOMM_REGULATOR_DEV_NAME,
337 .id = -1,
338 .dev = {
339 .platform_data = &msm7x30_proccomm_regulator_data
340 }
341};
342#endif
343
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700344/*virtual key support */
345static ssize_t tma300_vkeys_show(struct kobject *kobj,
346 struct kobj_attribute *attr, char *buf)
347{
348 return sprintf(buf,
349 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":50:842:80:100"
350 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":170:842:80:100"
351 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":290:842:80:100"
352 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":410:842:80:100"
353 "\n");
354}
355
356static struct kobj_attribute tma300_vkeys_attr = {
357 .attr = {
358 .mode = S_IRUGO,
359 },
360 .show = &tma300_vkeys_show,
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530361};
362
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700363static struct attribute *tma300_properties_attrs[] = {
364 &tma300_vkeys_attr.attr,
365 NULL
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530366};
367
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700368static struct attribute_group tma300_properties_attr_group = {
369 .attrs = tma300_properties_attrs,
370};
371
372static struct kobject *properties_kobj;
Justin Paupore3f40f342011-08-10 18:52:16 -0700373static struct regulator_bulk_data cyttsp_regs[] = {
374 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
375 { .supply = "ldo15", .min_uV = 3050000, .max_uV = 3100000 },
376};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700377
378#define CYTTSP_TS_GPIO_IRQ 150
379static int cyttsp_platform_init(struct i2c_client *client)
380{
381 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700382
Justin Paupore3f40f342011-08-10 18:52:16 -0700383 rc = regulator_bulk_get(NULL, ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700384
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700385 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700386 pr_err("%s: could not get regulators: %d\n", __func__, rc);
387 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700388 }
389
Justin Paupore3f40f342011-08-10 18:52:16 -0700390 rc = regulator_bulk_set_voltage(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
391
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700392 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700393 pr_err("%s: could not set regulator voltages: %d\n", __func__,
394 rc);
395 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700396 }
397
Justin Paupore3f40f342011-08-10 18:52:16 -0700398 rc = regulator_bulk_enable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700399
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700400 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700401 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
402 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700403 }
404
405 /* check this device active by reading first byte/register */
406 rc = i2c_smbus_read_byte_data(client, 0x01);
407 if (rc < 0) {
408 pr_err("%s: i2c sanity check failed\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -0700409 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700410 }
411
412 rc = gpio_tlmm_config(GPIO_CFG(CYTTSP_TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
413 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
414 if (rc) {
415 pr_err("%s: Could not configure gpio %d\n",
416 __func__, CYTTSP_TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -0700417 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700418 }
419
420 /* virtual keys */
421 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
422 properties_kobj = kobject_create_and_add("board_properties",
423 NULL);
424 if (properties_kobj)
425 rc = sysfs_create_group(properties_kobj,
426 &tma300_properties_attr_group);
427 if (!properties_kobj || rc)
428 pr_err("%s: failed to create board_properties\n",
429 __func__);
430
431 return CY_OK;
432
Justin Paupore3f40f342011-08-10 18:52:16 -0700433regs_disable:
434 regulator_bulk_disable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
435regs_free:
436 regulator_bulk_free(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
437out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700438 return rc;
439}
440
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530441/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
442static int cyttsp_platform_suspend(struct i2c_client *client)
443{
444 msleep(20);
445
446 return CY_OK;
447}
448
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700449static int cyttsp_platform_resume(struct i2c_client *client)
450{
451 /* add any special code to strobe a wakeup pin or chip reset */
452 mdelay(10);
453
454 return CY_OK;
455}
456
457static struct cyttsp_platform_data cyttsp_data = {
458 .fw_fname = "cyttsp_7630_fluid.hex",
459 .panel_maxx = 479,
460 .panel_maxy = 799,
461 .disp_maxx = 469,
462 .disp_maxy = 799,
463 .disp_minx = 10,
464 .disp_miny = 0,
465 .flags = 0,
466 .gen = CY_GEN3, /* or */
467 .use_st = CY_USE_ST,
468 .use_mt = CY_USE_MT,
469 .use_hndshk = CY_SEND_HNDSHK,
470 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +0530471 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700472 .use_gestures = CY_USE_GESTURES,
473 /* activate up to 4 groups
474 * and set active distance
475 */
476 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
477 CY_GEST_GRP3 | CY_GEST_GRP4 |
478 CY_ACT_DIST,
479 /* change act_intrvl to customize the Active power state
480 * scanning/processing refresh interval for Operating mode
481 */
482 .act_intrvl = CY_ACT_INTRVL_DFLT,
483 /* change tch_tmout to customize the touch timeout for the
484 * Active power state for Operating mode
485 */
486 .tch_tmout = CY_TCH_TMOUT_DFLT,
487 /* change lp_intrvl to customize the Low Power power state
488 * scanning/processing refresh interval for Operating mode
489 */
490 .lp_intrvl = CY_LP_INTRVL_DFLT,
491 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530492 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700493 .init = cyttsp_platform_init,
494 .sleep_gpio = -1,
495 .resout_gpio = -1,
496 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
Mohan Pallaka49c37d62011-08-01 11:52:00 +0530497 .correct_fw_ver = 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700498};
499
500static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
501{
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530502 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700503 .direction = PM_GPIO_DIR_OUT,
504 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
505 .output_value = 0,
506 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530507 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700508 .out_strength = PM_GPIO_STRENGTH_HIGH,
509 .function = PM_GPIO_FUNC_2,
510 };
511 int rc = -EINVAL;
512 int id, mode, max_mA;
513
514 id = mode = max_mA = 0;
515 switch (ch) {
516 case 0:
517 case 1:
518 case 2:
519 if (on) {
520 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530521 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
522 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700523 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530524 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700525 __func__, id, rc);
526 }
527 break;
528
529 case 3:
530 id = PM_PWM_LED_KPD;
531 mode = PM_PWM_CONF_DTEST3;
532 max_mA = 200;
533 break;
534
535 case 4:
536 id = PM_PWM_LED_0;
537 mode = PM_PWM_CONF_PWM1;
538 max_mA = 40;
539 break;
540
541 case 5:
542 id = PM_PWM_LED_2;
543 mode = PM_PWM_CONF_PWM2;
544 max_mA = 40;
545 break;
546
547 case 6:
548 id = PM_PWM_LED_FLASH;
549 mode = PM_PWM_CONF_DTEST3;
550 max_mA = 200;
551 break;
552
553 default:
554 break;
555 }
556
557 if (ch >= 3 && ch <= 6) {
558 if (!on) {
559 mode = PM_PWM_CONF_NONE;
560 max_mA = 0;
561 }
562 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
563 if (rc)
564 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
565 __func__, ch, rc);
566 }
567
568 return rc;
569}
570
571static int pm8058_pwm_enable(struct pwm_device *pwm, int ch, int on)
572{
573 int rc;
574
575 switch (ch) {
576 case 7:
577 rc = pm8058_pwm_set_dtest(pwm, on);
578 if (rc)
579 pr_err("%s: pwm_set_dtest(%d): rc=%d\n",
580 __func__, on, rc);
581 break;
582 default:
583 rc = -EINVAL;
584 break;
585 }
586 return rc;
587}
588
589static const unsigned int fluid_keymap[] = {
590 KEY(0, 0, KEY_7),
591 KEY(0, 1, KEY_ENTER),
592 KEY(0, 2, KEY_UP),
593 /* drop (0,3) as it always shows up in pair with(0,2) */
594 KEY(0, 4, KEY_DOWN),
595
596 KEY(1, 0, KEY_CAMERA_SNAPSHOT),
597 KEY(1, 1, KEY_SELECT),
598 KEY(1, 2, KEY_1),
599 KEY(1, 3, KEY_VOLUMEUP),
600 KEY(1, 4, KEY_VOLUMEDOWN),
601};
602
603static const unsigned int surf_keymap[] = {
604 KEY(0, 0, KEY_7),
605 KEY(0, 1, KEY_DOWN),
606 KEY(0, 2, KEY_UP),
607 KEY(0, 3, KEY_RIGHT),
608 KEY(0, 4, KEY_ENTER),
609 KEY(0, 5, KEY_L),
610 KEY(0, 6, KEY_BACK),
611 KEY(0, 7, KEY_M),
612
613 KEY(1, 0, KEY_LEFT),
614 KEY(1, 1, KEY_SEND),
615 KEY(1, 2, KEY_1),
616 KEY(1, 3, KEY_4),
617 KEY(1, 4, KEY_CLEAR),
618 KEY(1, 5, KEY_MSDOS),
619 KEY(1, 6, KEY_SPACE),
620 KEY(1, 7, KEY_COMMA),
621
622 KEY(2, 0, KEY_6),
623 KEY(2, 1, KEY_5),
624 KEY(2, 2, KEY_8),
625 KEY(2, 3, KEY_3),
626 KEY(2, 4, KEY_NUMERIC_STAR),
627 KEY(2, 5, KEY_UP),
628 KEY(2, 6, KEY_DOWN), /* SYN */
629 KEY(2, 7, KEY_LEFTSHIFT),
630
631 KEY(3, 0, KEY_9),
632 KEY(3, 1, KEY_NUMERIC_POUND),
633 KEY(3, 2, KEY_0),
634 KEY(3, 3, KEY_2),
635 KEY(3, 4, KEY_SLEEP),
636 KEY(3, 5, KEY_F1),
637 KEY(3, 6, KEY_F2),
638 KEY(3, 7, KEY_F3),
639
640 KEY(4, 0, KEY_BACK),
641 KEY(4, 1, KEY_HOME),
642 KEY(4, 2, KEY_MENU),
643 KEY(4, 3, KEY_VOLUMEUP),
644 KEY(4, 4, KEY_VOLUMEDOWN),
645 KEY(4, 5, KEY_F4),
646 KEY(4, 6, KEY_F5),
647 KEY(4, 7, KEY_F6),
648
649 KEY(5, 0, KEY_R),
650 KEY(5, 1, KEY_T),
651 KEY(5, 2, KEY_Y),
652 KEY(5, 3, KEY_LEFTALT),
653 KEY(5, 4, KEY_KPENTER),
654 KEY(5, 5, KEY_Q),
655 KEY(5, 6, KEY_W),
656 KEY(5, 7, KEY_E),
657
658 KEY(6, 0, KEY_F),
659 KEY(6, 1, KEY_G),
660 KEY(6, 2, KEY_H),
661 KEY(6, 3, KEY_CAPSLOCK),
662 KEY(6, 4, KEY_PAGEUP),
663 KEY(6, 5, KEY_A),
664 KEY(6, 6, KEY_S),
665 KEY(6, 7, KEY_D),
666
667 KEY(7, 0, KEY_V),
668 KEY(7, 1, KEY_B),
669 KEY(7, 2, KEY_N),
670 KEY(7, 3, KEY_MENU), /* REVISIT - SYM */
671 KEY(7, 4, KEY_PAGEDOWN),
672 KEY(7, 5, KEY_Z),
673 KEY(7, 6, KEY_X),
674 KEY(7, 7, KEY_C),
675
676 KEY(8, 0, KEY_P),
677 KEY(8, 1, KEY_J),
678 KEY(8, 2, KEY_K),
679 KEY(8, 3, KEY_INSERT),
680 KEY(8, 4, KEY_LINEFEED),
681 KEY(8, 5, KEY_U),
682 KEY(8, 6, KEY_I),
683 KEY(8, 7, KEY_O),
684
685 KEY(9, 0, KEY_4),
686 KEY(9, 1, KEY_5),
687 KEY(9, 2, KEY_6),
688 KEY(9, 3, KEY_7),
689 KEY(9, 4, KEY_8),
690 KEY(9, 5, KEY_1),
691 KEY(9, 6, KEY_2),
692 KEY(9, 7, KEY_3),
693
694 KEY(10, 0, KEY_F7),
695 KEY(10, 1, KEY_F8),
696 KEY(10, 2, KEY_F9),
697 KEY(10, 3, KEY_F10),
698 KEY(10, 4, KEY_FN),
699 KEY(10, 5, KEY_9),
700 KEY(10, 6, KEY_0),
701 KEY(10, 7, KEY_DOT),
702
703 KEY(11, 0, KEY_LEFTCTRL),
704 KEY(11, 1, KEY_F11), /* START */
705 KEY(11, 2, KEY_ENTER),
706 KEY(11, 3, KEY_SEARCH),
707 KEY(11, 4, KEY_DELETE),
708 KEY(11, 5, KEY_RIGHT),
709 KEY(11, 6, KEY_LEFT),
710 KEY(11, 7, KEY_RIGHTSHIFT),
711};
712
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700713static struct matrix_keymap_data surf_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530714 .keymap_size = ARRAY_SIZE(surf_keymap),
715 .keymap = surf_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700716};
717
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530718static struct pm8xxx_keypad_platform_data surf_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700719 .input_name = "surf_keypad",
720 .input_phys_device = "surf_keypad/input0",
721 .num_rows = 12,
722 .num_cols = 8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530723 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
724 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
725 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700726 .scan_delay_ms = 32,
727 .row_hold_ns = 91500,
728 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530729 .keymap_data = &surf_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700730};
731
732static struct matrix_keymap_data fluid_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530733 .keymap_size = ARRAY_SIZE(fluid_keymap),
734 .keymap = fluid_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700735};
736
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530737static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700738 .input_name = "fluid-keypad",
739 .input_phys_device = "fluid-keypad/input0",
740 .num_rows = 5,
741 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530742 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
743 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
744 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700745 .scan_delay_ms = 32,
746 .row_hold_ns = 91500,
747 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530748 .keymap_data = &fluid_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700749};
750
751static struct pm8058_pwm_pdata pm8058_pwm_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530752 .config = pm8058_pwm_config,
753 .enable = pm8058_pwm_enable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700754};
755
756static struct pmic8058_led pmic8058_ffa_leds[] = {
757 [0] = {
758 .name = "keyboard-backlight",
759 .max_brightness = 15,
760 .id = PMIC8058_ID_LED_KB_LIGHT,
Dima Zavinba5499e2011-01-10 11:00:30 -0800761 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700762};
763
764static struct pmic8058_leds_platform_data pm8058_ffa_leds_data = {
765 .num_leds = ARRAY_SIZE(pmic8058_ffa_leds),
766 .leds = pmic8058_ffa_leds,
767};
768
769static struct pmic8058_led pmic8058_surf_leds[] = {
770 [0] = {
771 .name = "keyboard-backlight",
772 .max_brightness = 15,
773 .id = PMIC8058_ID_LED_KB_LIGHT,
774 },
775 [1] = {
776 .name = "voice:red",
777 .max_brightness = 20,
778 .id = PMIC8058_ID_LED_0,
779 },
780 [2] = {
781 .name = "wlan:green",
782 .max_brightness = 20,
783 .id = PMIC8058_ID_LED_2,
784 },
785};
786
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700787static struct pmic8058_leds_platform_data pm8058_surf_leds_data = {
788 .num_leds = ARRAY_SIZE(pmic8058_surf_leds),
789 .leds = pmic8058_surf_leds,
790};
791
792static struct pmic8058_led pmic8058_fluid_leds[] = {
793 [0] = {
794 .name = "keyboard-backlight",
795 .max_brightness = 15,
796 .id = PMIC8058_ID_LED_KB_LIGHT,
797 },
798 [1] = {
799 .name = "flash:led_0",
800 .max_brightness = 15,
801 .id = PMIC8058_ID_FLASH_LED_0,
802 },
803 [2] = {
804 .name = "flash:led_1",
805 .max_brightness = 15,
806 .id = PMIC8058_ID_FLASH_LED_1,
807 },
808};
809
810static struct pmic8058_leds_platform_data pm8058_fluid_leds_data = {
811 .num_leds = ARRAY_SIZE(pmic8058_fluid_leds),
812 .leds = pmic8058_fluid_leds,
813};
814
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530815static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata = {
816 .irq_base = PMIC8058_IRQ_BASE,
817 .devirq = MSM_GPIO_TO_INT(PMIC_GPIO_INT),
818 .irq_trigger_flag = IRQF_TRIGGER_LOW,
819};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700820
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530821static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata = {
822 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
823};
824
825static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata = {
826 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
827};
828
829static struct pm8058_platform_data pm8058_7x30_data = {
830 .irq_pdata = &pm8xxx_irq_pdata,
831 .gpio_pdata = &pm8xxx_gpio_pdata,
832 .mpp_pdata = &pm8xxx_mpp_pdata,
833 .pwm_pdata = &pm8058_pwm_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700834};
835
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530836#ifdef CONFIG_MSM_SSBI
837static struct msm_ssbi_platform_data msm7x30_ssbi_pm8058_pdata = {
Kenneth Heitke48952912012-01-12 14:02:06 -0700838 .rsl_id = "D:PMIC_SSBI",
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530839 .controller_type = MSM_SBI_CTRL_SSBI2,
840 .slave = {
841 .name = "pm8058-core",
842 .platform_data = &pm8058_7x30_data,
843 },
844};
845#endif
846
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700847static struct i2c_board_info cy8info[] __initdata = {
848 {
849 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
850 .platform_data = &cyttsp_data,
851#ifndef CY_USE_TIMER
852 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
853#endif /* CY_USE_TIMER */
854 },
855};
856
857static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
858#ifdef CONFIG_MT9D112
859 {
860 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
Dima Zavinba5499e2011-01-10 11:00:30 -0800861 },
862#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700863#ifdef CONFIG_WEBCAM_OV9726
864 {
865 I2C_BOARD_INFO("ov9726", 0x10),
866 },
867#endif
868#ifdef CONFIG_S5K3E2FX
869 {
870 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
871 },
872#endif
873#ifdef CONFIG_MT9P012
874 {
875 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
876 },
877#endif
878#ifdef CONFIG_VX6953
879 {
880 I2C_BOARD_INFO("vx6953", 0x20),
881 },
882#endif
883#ifdef CONFIG_MT9E013
884 {
885 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
886 },
887#endif
888#ifdef CONFIG_SN12M0PZ
889 {
890 I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1),
891 },
892#endif
893#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
894 {
895 I2C_BOARD_INFO("mt9t013", 0x6C),
896 },
897#endif
898
Dima Zavinba5499e2011-01-10 11:00:30 -0800899};
900
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700901#ifdef CONFIG_MSM_CAMERA
902#define CAM_STNDBY 143
903static uint32_t camera_off_vcm_gpio_table[] = {
904GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */
905};
906
907static uint32_t camera_off_gpio_table[] = {
908 /* parallel CAMERA interfaces */
909 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RST */
910 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
911 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
912 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
913 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
914 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
915 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
916 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
917 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
918 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
919 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
920 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
921 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
922 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
923 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
924};
925
926static uint32_t camera_on_vcm_gpio_table[] = {
927GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */
928};
929
930static uint32_t camera_on_gpio_table[] = {
931 /* parallel CAMERA interfaces */
932 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RST */
933 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
934 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
935 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
936 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
937 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
938 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
939 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
940 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
941 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
942 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
943 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
944 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
945 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
946 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
947};
948
949static uint32_t camera_off_gpio_fluid_table[] = {
950 /* FLUID: CAM_VGA_RST_N */
951 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
952 /* FLUID: CAMIF_STANDBY */
953 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
954};
955
956static uint32_t camera_on_gpio_fluid_table[] = {
957 /* FLUID: CAM_VGA_RST_N */
958 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
959 /* FLUID: CAMIF_STANDBY */
960 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
961};
962
963static void config_gpio_table(uint32_t *table, int len)
964{
965 int n, rc;
966 for (n = 0; n < len; n++) {
967 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
968 if (rc) {
969 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
970 __func__, table[n], rc);
971 break;
972 }
973 }
974}
975static int config_camera_on_gpios(void)
976{
977 config_gpio_table(camera_on_gpio_table,
978 ARRAY_SIZE(camera_on_gpio_table));
979
980 if (adie_get_detected_codec_type() != TIMPANI_ID)
981 /* GPIO1 is shared also used in Timpani RF card so
982 only configure it for non-Timpani RF card */
983 config_gpio_table(camera_on_vcm_gpio_table,
984 ARRAY_SIZE(camera_on_vcm_gpio_table));
985
986 if (machine_is_msm7x30_fluid()) {
987 config_gpio_table(camera_on_gpio_fluid_table,
988 ARRAY_SIZE(camera_on_gpio_fluid_table));
989 /* FLUID: turn on 5V booster */
990 gpio_set_value(
991 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 1);
992 /* FLUID: drive high to put secondary sensor to STANDBY */
993 gpio_set_value(CAM_STNDBY, 1);
994 }
995 return 0;
996}
997
998static void config_camera_off_gpios(void)
999{
1000 config_gpio_table(camera_off_gpio_table,
1001 ARRAY_SIZE(camera_off_gpio_table));
1002
1003 if (adie_get_detected_codec_type() != TIMPANI_ID)
1004 /* GPIO1 is shared also used in Timpani RF card so
1005 only configure it for non-Timpani RF card */
1006 config_gpio_table(camera_off_vcm_gpio_table,
1007 ARRAY_SIZE(camera_off_vcm_gpio_table));
1008
1009 if (machine_is_msm7x30_fluid()) {
1010 config_gpio_table(camera_off_gpio_fluid_table,
1011 ARRAY_SIZE(camera_off_gpio_fluid_table));
1012 /* FLUID: turn off 5V booster */
1013 gpio_set_value(
1014 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 0);
1015 }
1016}
1017
1018struct resource msm_camera_resources[] = {
1019 {
1020 .start = 0xA6000000,
1021 .end = 0xA6000000 + SZ_1M - 1,
1022 .flags = IORESOURCE_MEM,
1023 },
1024 {
1025 .start = INT_VFE,
1026 .end = INT_VFE,
1027 .flags = IORESOURCE_IRQ,
1028 },
1029 {
1030 .flags = IORESOURCE_DMA,
1031 }
1032};
1033
1034struct msm_camera_device_platform_data msm_camera_device_data = {
1035 .camera_gpio_on = config_camera_on_gpios,
1036 .camera_gpio_off = config_camera_off_gpios,
1037 .ioext.camifpadphy = 0xAB000000,
1038 .ioext.camifpadsz = 0x00000400,
1039 .ioext.csiphy = 0xA6100000,
1040 .ioext.csisz = 0x00000400,
1041 .ioext.csiirq = INT_CSI,
1042 .ioclk.mclk_clk_rate = 24000000,
1043 .ioclk.vfe_clk_rate = 147456000,
1044};
1045
1046static struct msm_camera_sensor_flash_src msm_flash_src_pwm = {
1047 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PWM,
1048 ._fsrc.pwm_src.freq = 1000,
1049 ._fsrc.pwm_src.max_load = 300,
1050 ._fsrc.pwm_src.low_load = 30,
1051 ._fsrc.pwm_src.high_load = 100,
1052 ._fsrc.pwm_src.channel = 7,
1053};
1054
1055#ifdef CONFIG_MT9D112
1056static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1057 .flash_type = MSM_CAMERA_FLASH_LED,
1058 .flash_src = &msm_flash_src_pwm
1059};
1060
1061static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1062 .sensor_name = "mt9d112",
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_mt9d112,
1071 .csi_if = 0
1072};
1073
1074static struct platform_device msm_camera_sensor_mt9d112 = {
1075 .name = "msm_camera_mt9d112",
1076 .dev = {
1077 .platform_data = &msm_camera_sensor_mt9d112_data,
1078 },
1079};
1080#endif
1081
1082#ifdef CONFIG_WEBCAM_OV9726
1083
1084static struct msm_camera_sensor_platform_info ov9726_sensor_7630_info = {
1085 .mount_angle = 90
1086};
1087
1088static struct msm_camera_sensor_flash_data flash_ov9726 = {
1089 .flash_type = MSM_CAMERA_FLASH_LED,
1090 .flash_src = &msm_flash_src_pwm
1091};
1092static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
1093 .sensor_name = "ov9726",
1094 .sensor_reset = 0,
1095 .sensor_pwd = 85,
1096 .vcm_pwd = 1,
1097 .vcm_enable = 0,
1098 .pdata = &msm_camera_device_data,
1099 .resource = msm_camera_resources,
1100 .num_resources = ARRAY_SIZE(msm_camera_resources),
1101 .flash_data = &flash_ov9726,
1102 .sensor_platform_info = &ov9726_sensor_7630_info,
1103 .csi_if = 1
1104};
1105struct platform_device msm_camera_sensor_ov9726 = {
1106 .name = "msm_camera_ov9726",
1107 .dev = {
1108 .platform_data = &msm_camera_sensor_ov9726_data,
1109 },
1110};
1111#endif
1112
1113#ifdef CONFIG_S5K3E2FX
1114static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1115 .flash_type = MSM_CAMERA_FLASH_LED,
1116 .flash_src = &msm_flash_src_pwm,
1117};
1118
1119static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1120 .sensor_name = "s5k3e2fx",
1121 .sensor_reset = 0,
1122 .sensor_pwd = 85,
1123 .vcm_pwd = 1,
1124 .vcm_enable = 0,
1125 .pdata = &msm_camera_device_data,
1126 .resource = msm_camera_resources,
1127 .num_resources = ARRAY_SIZE(msm_camera_resources),
1128 .flash_data = &flash_s5k3e2fx,
1129 .csi_if = 0
1130};
1131
1132static struct platform_device msm_camera_sensor_s5k3e2fx = {
1133 .name = "msm_camera_s5k3e2fx",
1134 .dev = {
1135 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1136 },
1137};
1138#endif
1139
1140#ifdef CONFIG_MT9P012
1141static struct msm_camera_sensor_flash_data flash_mt9p012 = {
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_mt9p012_data = {
1147 .sensor_name = "mt9p012",
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_mt9p012,
1156 .csi_if = 0
1157};
1158
1159static struct platform_device msm_camera_sensor_mt9p012 = {
1160 .name = "msm_camera_mt9p012",
1161 .dev = {
1162 .platform_data = &msm_camera_sensor_mt9p012_data,
1163 },
1164};
1165#endif
1166
1167#ifdef CONFIG_MT9E013
1168static struct msm_camera_sensor_platform_info mt9e013_sensor_7630_info = {
1169 .mount_angle = 0
1170};
1171
1172static struct msm_camera_sensor_flash_data flash_mt9e013 = {
1173 .flash_type = MSM_CAMERA_FLASH_LED,
1174 .flash_src = &msm_flash_src_pwm
1175};
1176
1177static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
1178 .sensor_name = "mt9e013",
1179 .sensor_reset = 0,
1180 .sensor_pwd = 85,
1181 .vcm_pwd = 1,
1182 .vcm_enable = 1,
1183 .pdata = &msm_camera_device_data,
1184 .resource = msm_camera_resources,
1185 .num_resources = ARRAY_SIZE(msm_camera_resources),
1186 .flash_data = &flash_mt9e013,
1187 .sensor_platform_info = &mt9e013_sensor_7630_info,
1188 .csi_if = 1
1189};
1190
1191static struct platform_device msm_camera_sensor_mt9e013 = {
1192 .name = "msm_camera_mt9e013",
1193 .dev = {
1194 .platform_data = &msm_camera_sensor_mt9e013_data,
1195 },
1196};
1197#endif
1198
1199#ifdef CONFIG_VX6953
Jilai Wang971f97f2011-07-13 14:25:25 -04001200static struct msm_camera_sensor_platform_info vx6953_sensor_7630_info = {
1201 .mount_angle = 0
1202};
1203
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001204static struct msm_camera_sensor_flash_data flash_vx6953 = {
1205 .flash_type = MSM_CAMERA_FLASH_LED,
1206 .flash_src = &msm_flash_src_pwm
1207};
1208static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1209 .sensor_name = "vx6953",
1210 .sensor_reset = 0,
1211 .sensor_pwd = 85,
1212 .vcm_pwd = 1,
1213 .vcm_enable = 0,
1214 .pdata = &msm_camera_device_data,
1215 .resource = msm_camera_resources,
1216 .num_resources = ARRAY_SIZE(msm_camera_resources),
Jilai Wang971f97f2011-07-13 14:25:25 -04001217 .sensor_platform_info = &vx6953_sensor_7630_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001218 .flash_data = &flash_vx6953,
1219 .csi_if = 1
1220};
1221static struct platform_device msm_camera_sensor_vx6953 = {
1222 .name = "msm_camera_vx6953",
1223 .dev = {
1224 .platform_data = &msm_camera_sensor_vx6953_data,
1225 },
1226};
1227#endif
1228
1229#ifdef CONFIG_SN12M0PZ
1230static struct msm_camera_sensor_flash_src msm_flash_src_current_driver = {
1231 .flash_sr_type = MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER,
1232 ._fsrc.current_driver_src.low_current = 210,
1233 ._fsrc.current_driver_src.high_current = 700,
1234 ._fsrc.current_driver_src.driver_channel = &pm8058_fluid_leds_data,
1235};
1236
1237static struct msm_camera_sensor_flash_data flash_sn12m0pz = {
1238 .flash_type = MSM_CAMERA_FLASH_LED,
1239 .flash_src = &msm_flash_src_current_driver
1240};
1241static struct msm_camera_sensor_info msm_camera_sensor_sn12m0pz_data = {
1242 .sensor_name = "sn12m0pz",
1243 .sensor_reset = 0,
1244 .sensor_pwd = 85,
1245 .vcm_pwd = 1,
1246 .vcm_enable = 1,
1247 .pdata = &msm_camera_device_data,
1248 .flash_data = &flash_sn12m0pz,
1249 .resource = msm_camera_resources,
1250 .num_resources = ARRAY_SIZE(msm_camera_resources),
1251 .csi_if = 0
1252};
1253
1254static struct platform_device msm_camera_sensor_sn12m0pz = {
1255 .name = "msm_camera_sn12m0pz",
1256 .dev = {
1257 .platform_data = &msm_camera_sensor_sn12m0pz_data,
1258 },
1259};
1260#endif
1261
1262#ifdef CONFIG_MT9T013
1263static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1264 .flash_type = MSM_CAMERA_FLASH_LED,
1265 .flash_src = &msm_flash_src_pwm
1266};
1267
1268static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1269 .sensor_name = "mt9t013",
1270 .sensor_reset = 0,
1271 .sensor_pwd = 85,
1272 .vcm_pwd = 1,
1273 .vcm_enable = 0,
1274 .pdata = &msm_camera_device_data,
1275 .resource = msm_camera_resources,
1276 .num_resources = ARRAY_SIZE(msm_camera_resources),
1277 .flash_data = &flash_mt9t013,
1278 .csi_if = 1
1279};
1280
1281static struct platform_device msm_camera_sensor_mt9t013 = {
1282 .name = "msm_camera_mt9t013",
1283 .dev = {
1284 .platform_data = &msm_camera_sensor_mt9t013_data,
1285 },
1286};
1287#endif
1288
1289#ifdef CONFIG_MSM_GEMINI
1290static struct resource msm_gemini_resources[] = {
1291 {
1292 .start = 0xA3A00000,
1293 .end = 0xA3A00000 + 0x0150 - 1,
1294 .flags = IORESOURCE_MEM,
1295 },
1296 {
1297 .start = INT_JPEG,
1298 .end = INT_JPEG,
1299 .flags = IORESOURCE_IRQ,
1300 },
1301};
1302
1303static struct platform_device msm_gemini_device = {
1304 .name = "msm_gemini",
1305 .resource = msm_gemini_resources,
1306 .num_resources = ARRAY_SIZE(msm_gemini_resources),
1307};
1308#endif
1309
1310#ifdef CONFIG_MSM_VPE
1311static struct resource msm_vpe_resources[] = {
1312 {
1313 .start = 0xAD200000,
1314 .end = 0xAD200000 + SZ_1M - 1,
1315 .flags = IORESOURCE_MEM,
1316 },
1317 {
1318 .start = INT_VPE,
1319 .end = INT_VPE,
1320 .flags = IORESOURCE_IRQ,
1321 },
1322};
1323
1324static struct platform_device msm_vpe_device = {
1325 .name = "msm_vpe",
1326 .id = 0,
1327 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1328 .resource = msm_vpe_resources,
1329};
1330#endif
1331
1332#endif /*CONFIG_MSM_CAMERA*/
1333
1334#ifdef CONFIG_MSM7KV2_AUDIO
1335static uint32_t audio_pamp_gpio_config =
1336 GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1337
1338static uint32_t audio_fluid_icodec_tx_config =
1339 GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1340
1341static int __init snddev_poweramp_gpio_init(void)
1342{
1343 int rc;
1344
1345 pr_info("snddev_poweramp_gpio_init \n");
1346 rc = gpio_tlmm_config(audio_pamp_gpio_config, GPIO_CFG_ENABLE);
1347 if (rc) {
1348 printk(KERN_ERR
1349 "%s: gpio_tlmm_config(%#x)=%d\n",
1350 __func__, audio_pamp_gpio_config, rc);
1351 }
1352 return rc;
1353}
1354
1355void msm_snddev_tx_route_config(void)
1356{
1357 int rc;
1358
1359 pr_debug("%s()\n", __func__);
1360
1361 if (machine_is_msm7x30_fluid()) {
1362 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1363 GPIO_CFG_ENABLE);
1364 if (rc) {
1365 printk(KERN_ERR
1366 "%s: gpio_tlmm_config(%#x)=%d\n",
1367 __func__, audio_fluid_icodec_tx_config, rc);
1368 } else
1369 gpio_set_value(85, 0);
1370 }
1371}
1372
1373void msm_snddev_tx_route_deconfig(void)
1374{
1375 int rc;
1376
1377 pr_debug("%s()\n", __func__);
1378
1379 if (machine_is_msm7x30_fluid()) {
1380 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1381 GPIO_CFG_DISABLE);
1382 if (rc) {
1383 printk(KERN_ERR
1384 "%s: gpio_tlmm_config(%#x)=%d\n",
1385 __func__, audio_fluid_icodec_tx_config, rc);
1386 }
1387 }
1388}
1389
1390void msm_snddev_poweramp_on(void)
1391{
1392 gpio_set_value(82, 1); /* enable spkr poweramp */
1393 pr_info("%s: power on amplifier\n", __func__);
1394}
1395
1396void msm_snddev_poweramp_off(void)
1397{
1398 gpio_set_value(82, 0); /* disable spkr poweramp */
1399 pr_info("%s: power off amplifier\n", __func__);
1400}
1401
Justin Paupore3f40f342011-08-10 18:52:16 -07001402static struct regulator_bulk_data snddev_regs[] = {
1403 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
1404 { .supply = "ncp", .min_uV = 1800000, .max_uV = 1800000 },
1405};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001406
Justin Paupore3f40f342011-08-10 18:52:16 -07001407static int __init snddev_hsed_voltage_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001408{
1409 int rc;
1410
Justin Paupore3f40f342011-08-10 18:52:16 -07001411 rc = regulator_bulk_get(NULL, ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001412
Justin Paupore3f40f342011-08-10 18:52:16 -07001413 if (rc) {
1414 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1415 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001416 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001417
1418 rc = regulator_bulk_set_voltage(ARRAY_SIZE(snddev_regs), snddev_regs);
1419
1420 if (rc) {
1421 pr_err("%s: could not set regulator voltages: %d\n",
1422 __func__, rc);
1423 goto regs_free;
1424 }
1425
1426 return 0;
1427
1428regs_free:
1429 regulator_bulk_free(ARRAY_SIZE(snddev_regs), snddev_regs);
1430out:
1431 return rc;
1432}
1433
1434
1435void msm_snddev_hsed_voltage_on(void)
1436{
1437 int rc = regulator_bulk_enable(ARRAY_SIZE(snddev_regs), snddev_regs);
1438
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001439 if (rc)
Justin Paupore3f40f342011-08-10 18:52:16 -07001440 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001441}
1442
1443void msm_snddev_hsed_voltage_off(void)
1444{
Justin Paupore3f40f342011-08-10 18:52:16 -07001445 int rc = regulator_bulk_disable(ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001446
Justin Paupore3f40f342011-08-10 18:52:16 -07001447 if (rc) {
1448 pr_err("%s: could not disable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001449 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001450}
1451
1452static unsigned aux_pcm_gpio_on[] = {
1453 GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
1454 GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
1455 GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
1456 GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
1457};
1458
1459static int __init aux_pcm_gpio_init(void)
1460{
1461 int pin, rc;
1462
1463 pr_info("aux_pcm_gpio_init \n");
1464 for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) {
1465 rc = gpio_tlmm_config(aux_pcm_gpio_on[pin],
1466 GPIO_CFG_ENABLE);
1467 if (rc) {
1468 printk(KERN_ERR
1469 "%s: gpio_tlmm_config(%#x)=%d\n",
1470 __func__, aux_pcm_gpio_on[pin], rc);
1471 }
1472 }
1473 return rc;
1474}
1475
1476static struct msm_gpio mi2s_clk_gpios[] = {
1477 { GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1478 "MI2S_SCLK"},
1479 { GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1480 "MI2S_WS"},
1481 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1482 "MI2S_MCLK_A"},
1483};
1484
1485static struct msm_gpio mi2s_rx_data_lines_gpios[] = {
1486 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1487 "MI2S_DATA_SD0_A"},
1488 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1489 "MI2S_DATA_SD1_A"},
1490 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1491 "MI2S_DATA_SD2_A"},
1492 { GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1493 "MI2S_DATA_SD3"},
1494};
1495
1496static struct msm_gpio mi2s_tx_data_lines_gpios[] = {
1497 { GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1498 "MI2S_DATA_SD3"},
1499};
1500
1501int mi2s_config_clk_gpio(void)
1502{
1503 int rc = 0;
1504
1505 rc = msm_gpios_request_enable(mi2s_clk_gpios,
1506 ARRAY_SIZE(mi2s_clk_gpios));
1507 if (rc) {
1508 pr_err("%s: enable mi2s clk gpios failed\n",
1509 __func__);
1510 return rc;
1511 }
1512 return 0;
1513}
1514
1515int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask)
1516{
1517 int i, rc = 0;
1518 sd_line_mask &= MI2S_SD_LINE_MASK;
1519
1520 switch (direction) {
1521 case DIR_TX:
1522 msm_gpios_disable_free(mi2s_tx_data_lines_gpios, 1);
1523 break;
1524 case DIR_RX:
1525 i = 0;
1526 while (sd_line_mask) {
1527 if (sd_line_mask & 0x1)
1528 msm_gpios_disable_free(
1529 mi2s_rx_data_lines_gpios + i , 1);
1530 sd_line_mask = sd_line_mask >> 1;
1531 i++;
1532 }
1533 break;
1534 default:
1535 pr_err("%s: Invaild direction direction = %u\n",
1536 __func__, direction);
1537 rc = -EINVAL;
1538 break;
1539 }
1540 return rc;
1541}
1542
1543int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask)
1544{
1545 int i , rc = 0;
1546 u8 sd_config_done_mask = 0;
1547
1548 sd_line_mask &= MI2S_SD_LINE_MASK;
1549
1550 switch (direction) {
1551 case DIR_TX:
1552 if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) ||
1553 (sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) {
1554 pr_err("%s: can not use SD0 or SD1 or SD2 for TX"
1555 ".only can use SD3. sd_line_mask = 0x%x\n",
1556 __func__ , sd_line_mask);
1557 rc = -EINVAL;
1558 } else {
1559 rc = msm_gpios_request_enable(mi2s_tx_data_lines_gpios,
1560 1);
1561 if (rc)
1562 pr_err("%s: enable mi2s gpios for TX failed\n",
1563 __func__);
1564 }
1565 break;
1566 case DIR_RX:
1567 i = 0;
1568 while (sd_line_mask && (rc == 0)) {
1569 if (sd_line_mask & 0x1) {
1570 rc = msm_gpios_request_enable(
1571 mi2s_rx_data_lines_gpios + i , 1);
1572 if (rc) {
1573 pr_err("%s: enable mi2s gpios for"
1574 "RX failed. SD line = %s\n",
1575 __func__,
1576 (mi2s_rx_data_lines_gpios + i)->label);
1577 mi2s_unconfig_data_gpio(DIR_RX,
1578 sd_config_done_mask);
1579 } else
1580 sd_config_done_mask |= (1 << i);
1581 }
1582 sd_line_mask = sd_line_mask >> 1;
1583 i++;
1584 }
1585 break;
1586 default:
1587 pr_err("%s: Invaild direction direction = %u\n",
1588 __func__, direction);
1589 rc = -EINVAL;
1590 break;
1591 }
1592 return rc;
1593}
1594
1595int mi2s_unconfig_clk_gpio(void)
1596{
1597 msm_gpios_disable_free(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios));
1598 return 0;
1599}
1600
1601#endif /* CONFIG_MSM7KV2_AUDIO */
1602
1603static int __init buses_init(void)
1604{
1605 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT,
1606 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
1607 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
1608 __func__, PMIC_GPIO_INT);
1609
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301610 if (machine_is_msm8x60_fluid())
1611 pm8058_7x30_data.keypad_pdata = &fluid_keypad_data;
1612 else
1613 pm8058_7x30_data.keypad_pdata = &surf_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001614
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001615 return 0;
1616}
1617
1618#define TIMPANI_RESET_GPIO 1
1619
1620struct bahama_config_register{
1621 u8 reg;
1622 u8 value;
1623 u8 mask;
1624};
1625
1626enum version{
1627 VER_1_0,
1628 VER_2_0,
1629 VER_UNSUPPORTED = 0xFF
1630};
1631
Justin Paupore3f40f342011-08-10 18:52:16 -07001632static struct regulator *vreg_marimba_1;
1633static struct regulator *vreg_marimba_2;
1634static struct regulator *vreg_bahama;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001635
1636static struct msm_gpio timpani_reset_gpio_cfg[] = {
1637{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
1638 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} };
1639
1640static u8 read_bahama_ver(void)
1641{
1642 int rc;
1643 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1644 u8 bahama_version;
1645
1646 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
1647 if (rc < 0) {
1648 printk(KERN_ERR
1649 "%s: version read failed: %d\n",
1650 __func__, rc);
1651 return rc;
1652 } else {
1653 printk(KERN_INFO
1654 "%s: version read got: 0x%x\n",
1655 __func__, bahama_version);
1656 }
1657
1658 switch (bahama_version) {
1659 case 0x08: /* varient of bahama v1 */
1660 case 0x10:
1661 case 0x00:
1662 return VER_1_0;
1663 case 0x09: /* variant of bahama v2 */
1664 return VER_2_0;
1665 default:
1666 return VER_UNSUPPORTED;
1667 }
1668}
1669
1670static int config_timpani_reset(void)
1671{
1672 int rc;
1673
1674 rc = msm_gpios_request_enable(timpani_reset_gpio_cfg,
1675 ARRAY_SIZE(timpani_reset_gpio_cfg));
1676 if (rc < 0) {
1677 printk(KERN_ERR
1678 "%s: msm_gpios_request_enable failed (%d)\n",
1679 __func__, rc);
1680 }
1681 return rc;
1682}
1683
1684static unsigned int msm_timpani_setup_power(void)
1685{
1686 int rc;
1687
1688 rc = config_timpani_reset();
1689 if (rc < 0)
1690 goto out;
1691
Justin Paupore3f40f342011-08-10 18:52:16 -07001692 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001693 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001694 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001695 goto out;
1696 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001697
1698 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001699 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001700 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1701 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001702 }
1703
1704 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1);
1705 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001706 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001707 __func__, rc);
1708 msm_gpios_free(timpani_reset_gpio_cfg,
1709 ARRAY_SIZE(timpani_reset_gpio_cfg));
Justin Paupore3f40f342011-08-10 18:52:16 -07001710 goto disable_marimba_2;
1711 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001712
Justin Paupore3f40f342011-08-10 18:52:16 -07001713 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001714
Justin Paupore3f40f342011-08-10 18:52:16 -07001715disable_marimba_2:
1716 regulator_disable(vreg_marimba_2);
1717disable_marimba_1:
1718 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001719out:
1720 return rc;
1721};
1722
1723static void msm_timpani_shutdown_power(void)
1724{
1725 int rc;
1726
Justin Paupore3f40f342011-08-10 18:52:16 -07001727 rc = regulator_disable(vreg_marimba_2);
1728 if (rc)
1729 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1730
1731 rc = regulator_disable(vreg_marimba_1);
1732 if (rc)
1733 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001734
1735 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0);
Justin Paupore3f40f342011-08-10 18:52:16 -07001736 if (rc < 0)
1737 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001738 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001739
1740 msm_gpios_free(timpani_reset_gpio_cfg,
1741 ARRAY_SIZE(timpani_reset_gpio_cfg));
1742};
1743
1744static unsigned int msm_bahama_core_config(int type)
1745{
1746 int rc = 0;
1747
1748 if (type == BAHAMA_ID) {
1749
1750 int i;
1751 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1752
1753 const struct bahama_config_register v20_init[] = {
1754 /* reg, value, mask */
1755 { 0xF4, 0x84, 0xFF }, /* AREG */
1756 { 0xF0, 0x04, 0xFF } /* DREG */
1757 };
1758
1759 if (read_bahama_ver() == VER_2_0) {
1760 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
1761 u8 value = v20_init[i].value;
1762 rc = marimba_write_bit_mask(&config,
1763 v20_init[i].reg,
1764 &value,
1765 sizeof(v20_init[i].value),
1766 v20_init[i].mask);
1767 if (rc < 0) {
1768 printk(KERN_ERR
1769 "%s: reg %d write failed: %d\n",
1770 __func__, v20_init[i].reg, rc);
1771 return rc;
1772 }
1773 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
1774 " mask 0x%02x\n",
1775 __func__, v20_init[i].reg,
1776 v20_init[i].value, v20_init[i].mask);
1777 }
1778 }
1779 }
1780 printk(KERN_INFO "core type: %d\n", type);
1781
1782 return rc;
1783}
1784
1785static unsigned int msm_bahama_setup_power(void)
1786{
Justin Paupore3f40f342011-08-10 18:52:16 -07001787 int rc = regulator_enable(vreg_bahama);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001788
Justin Paupore3f40f342011-08-10 18:52:16 -07001789 if (rc)
1790 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001791
1792 return rc;
1793};
1794
1795static unsigned int msm_bahama_shutdown_power(int value)
1796{
1797 int rc = 0;
1798
1799 if (value != BAHAMA_ID) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001800 rc = regulator_disable(vreg_bahama);
1801
1802 if (rc)
1803 pr_err("%s: regulator_disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001804 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001805 }
1806
1807 return rc;
1808};
1809
1810static struct msm_gpio marimba_svlte_config_clock[] = {
1811 { GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1812 "MARIMBA_SVLTE_CLOCK_ENABLE" },
1813};
1814
1815static unsigned int msm_marimba_gpio_config_svlte(int gpio_cfg_marimba)
1816{
1817 if (machine_is_msm8x55_svlte_surf() ||
1818 machine_is_msm8x55_svlte_ffa()) {
1819 if (gpio_cfg_marimba)
1820 gpio_set_value(GPIO_PIN
1821 (marimba_svlte_config_clock->gpio_cfg), 1);
1822 else
1823 gpio_set_value(GPIO_PIN
1824 (marimba_svlte_config_clock->gpio_cfg), 0);
1825 }
1826
1827 return 0;
1828};
1829
1830static unsigned int msm_marimba_setup_power(void)
1831{
1832 int rc;
1833
Justin Paupore3f40f342011-08-10 18:52:16 -07001834 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001835 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001836 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001837 goto out;
1838 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001839
1840 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001841 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001842 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1843 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001844 }
1845
1846 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
1847 rc = msm_gpios_request_enable(marimba_svlte_config_clock,
1848 ARRAY_SIZE(marimba_svlte_config_clock));
1849 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001850 pr_err("%s: msm_gpios_request_enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001851 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07001852 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001853 }
1854
1855 rc = gpio_direction_output(GPIO_PIN
1856 (marimba_svlte_config_clock->gpio_cfg), 0);
1857 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001858 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001859 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07001860 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001861 }
1862 }
1863
Justin Paupore3f40f342011-08-10 18:52:16 -07001864 return 0;
1865
1866disable_marimba_2:
1867 regulator_disable(vreg_marimba_2);
1868disable_marimba_1:
1869 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001870out:
1871 return rc;
1872};
1873
1874static void msm_marimba_shutdown_power(void)
1875{
1876 int rc;
1877
Justin Paupore3f40f342011-08-10 18:52:16 -07001878 rc = regulator_disable(vreg_marimba_2);
1879 if (rc)
1880 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1881
1882 rc = regulator_disable(vreg_marimba_1);
1883 if (rc)
1884 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001885};
1886
1887static int bahama_present(void)
1888{
1889 int id;
1890 switch (id = adie_get_detected_connectivity_type()) {
1891 case BAHAMA_ID:
1892 return 1;
1893
1894 case MARIMBA_ID:
1895 return 0;
1896
1897 case TIMPANI_ID:
1898 default:
1899 printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n",
1900 __func__, id);
1901 return -ENODEV;
1902 }
1903}
1904
Justin Paupore3f40f342011-08-10 18:52:16 -07001905struct regulator *fm_regulator;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001906static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
1907{
Justin Paupore3f40f342011-08-10 18:52:16 -07001908 int rc, voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001909 uint32_t irqcfg;
1910 const char *id = "FMPW";
1911
1912 int bahama_not_marimba = bahama_present();
1913
Justin Paupore3f40f342011-08-10 18:52:16 -07001914 if (bahama_not_marimba < 0) {
1915 pr_warn("%s: bahama_present: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001916 __func__, bahama_not_marimba);
Justin Paupore3f40f342011-08-10 18:52:16 -07001917 rc = -ENODEV;
1918 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001919 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001920 if (bahama_not_marimba) {
1921 fm_regulator = regulator_get(NULL, "s3");
1922 voltage = 1800000;
1923 } else {
1924 fm_regulator = regulator_get(NULL, "s2");
1925 voltage = 1300000;
1926 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001927
1928 if (IS_ERR(fm_regulator)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001929 rc = PTR_ERR(fm_regulator);
1930 pr_err("%s: regulator_get failed (%d)\n", __func__, rc);
1931 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001932 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001933
Justin Paupore3f40f342011-08-10 18:52:16 -07001934 rc = regulator_set_voltage(fm_regulator, voltage, voltage);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001935
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001936 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001937 pr_err("%s: regulator_set_voltage failed (%d)\n", __func__, rc);
1938 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001939 }
1940
Justin Paupore3f40f342011-08-10 18:52:16 -07001941 rc = regulator_enable(fm_regulator);
1942
1943 if (rc) {
1944 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1945 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001946 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001947
1948 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_ON);
1949
1950 if (rc < 0) {
1951 pr_err("%s: clock vote failed (%d)\n", __func__, rc);
1952 goto regulator_disable;
1953 }
1954
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001955 /*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
1956 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07001957 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001958 rc = marimba_gpio_config(1);
Justin Paupore3f40f342011-08-10 18:52:16 -07001959 if (rc < 0) {
1960 pr_err("%s: clock enable for svlte : %d\n",
1961 __func__, rc);
1962 goto clock_devote;
1963 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001964 }
1965 irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
1966 GPIO_CFG_2MA);
1967 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
1968 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001969 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001970 rc = -EIO;
Justin Paupore3f40f342011-08-10 18:52:16 -07001971 goto gpio_deconfig;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001972
1973 }
1974 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001975
Justin Paupore3f40f342011-08-10 18:52:16 -07001976gpio_deconfig:
1977 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa())
1978 marimba_gpio_config(0);
1979clock_devote:
1980 pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_OFF);
1981regulator_disable:
1982 regulator_disable(fm_regulator);
1983regulator_free:
1984 regulator_put(fm_regulator);
1985 fm_regulator = NULL;
1986out:
1987 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001988};
1989
1990static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
1991{
1992 int rc;
1993 const char *id = "FMPW";
1994 uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
1995 GPIO_CFG_2MA);
1996
1997 int bahama_not_marimba = bahama_present();
1998 if (bahama_not_marimba == -1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001999 pr_warn("%s: bahama_present: %d\n",
2000 __func__, bahama_not_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002001 return;
2002 }
2003
2004 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2005 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002006 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002007 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002008 if (!IS_ERR_OR_NULL(fm_regulator)) {
2009 rc = regulator_disable(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002010
Justin Paupore3f40f342011-08-10 18:52:16 -07002011 if (rc)
2012 pr_err("%s: return val: %d\n", __func__, rc);
2013
2014 regulator_put(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002015 fm_regulator = NULL;
2016 }
2017 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
2018 PMAPP_CLOCK_VOTE_OFF);
2019 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002020 pr_err("%s: clock_vote return val: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002021
2022 /*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2023 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002024 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002025 rc = marimba_gpio_config(0);
2026 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002027 pr_err("%s: clock disable for svlte : %d\n",
2028 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002029 }
2030}
2031
2032static struct marimba_fm_platform_data marimba_fm_pdata = {
2033 .fm_setup = fm_radio_setup,
2034 .fm_shutdown = fm_radio_shutdown,
2035 .irq = MSM_GPIO_TO_INT(147),
2036 .vreg_s2 = NULL,
2037 .vreg_xo_out = NULL,
2038 .is_fm_soc_i2s_master = false,
2039 .config_i2s_gpio = NULL,
2040};
2041
2042
2043/* Slave id address for FM/CDC/QMEMBIST
2044 * Values can be programmed using Marimba slave id 0
2045 * should there be a conflict with other I2C devices
2046 * */
2047#define MARIMBA_SLAVE_ID_FM_ADDR 0x2A
2048#define MARIMBA_SLAVE_ID_CDC_ADDR 0x77
2049#define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66
2050
2051#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
2052#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
2053
2054static const char *tsadc_id = "MADC";
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002055
Justin Paupore3f40f342011-08-10 18:52:16 -07002056static struct regulator_bulk_data regs_tsadc_marimba[] = {
2057 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2058 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002059};
Justin Paupore3f40f342011-08-10 18:52:16 -07002060
2061static struct regulator_bulk_data regs_tsadc_timpani[] = {
2062 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2063 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2064 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2065};
2066
2067static struct regulator_bulk_data *regs_tsadc;
2068static int regs_tsadc_count;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002069
2070static int marimba_tsadc_power(int vreg_on)
2071{
Justin Paupore3f40f342011-08-10 18:52:16 -07002072 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002073 int tsadc_adie_type = adie_get_detected_codec_type();
2074
Justin Paupore3f40f342011-08-10 18:52:16 -07002075 switch (tsadc_adie_type) {
2076 case TIMPANI_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002077 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2078 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2079 if (rc) {
2080 pr_err("%s: unable to %svote for d1 clk\n",
2081 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002082 goto D1_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002083 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002084
2085 /* fall through */
2086 case MARIMBA_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002087 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2088 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2089 if (rc) {
2090 pr_err("%s: unable to %svote for d1 clk\n",
2091 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002092 goto D0_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002093 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002094
Justin Paupore3f40f342011-08-10 18:52:16 -07002095 WARN_ON(regs_tsadc_count == 0);
2096
2097 rc = vreg_on ?
2098 regulator_bulk_enable(regs_tsadc_count, regs_tsadc) :
2099 regulator_bulk_disable(regs_tsadc_count, regs_tsadc);
2100
2101 if (rc) {
2102 pr_err("%s: regulator %sable failed: %d\n",
2103 __func__, vreg_on ? "en" : "dis", rc);
2104 goto regulator_switch_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002105 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002106
2107 break;
2108 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002109 pr_err("%s:Adie %d not supported\n",
2110 __func__, tsadc_adie_type);
2111 return -ENODEV;
2112 }
2113
2114 msleep(5); /* ensure power is stable */
2115
2116 return 0;
2117
Justin Paupore3f40f342011-08-10 18:52:16 -07002118regulator_switch_fail:
2119 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2120 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2121D0_vote_fail:
2122 if (tsadc_adie_type == TIMPANI_ID)
2123 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2124 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2125D1_vote_fail:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002126 return rc;
2127}
2128
2129static int marimba_tsadc_init(void)
2130{
Justin Paupore3f40f342011-08-10 18:52:16 -07002131 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002132 int tsadc_adie_type = adie_get_detected_codec_type();
2133
Justin Paupore3f40f342011-08-10 18:52:16 -07002134 switch (tsadc_adie_type) {
2135 case MARIMBA_ID:
2136 regs_tsadc = regs_tsadc_marimba;
2137 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_marimba);
2138 break;
2139 case TIMPANI_ID:
2140 regs_tsadc = regs_tsadc_timpani;
2141 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_timpani);
2142 break;
2143 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002144 pr_err("%s:Adie %d not supported\n",
2145 __func__, tsadc_adie_type);
Justin Paupore3f40f342011-08-10 18:52:16 -07002146 rc = -ENODEV;
2147 goto out;
2148 }
2149
2150 rc = regulator_bulk_get(NULL, regs_tsadc_count, regs_tsadc);
2151 if (rc) {
2152 pr_err("%s: could not get regulators: %d\n",
2153 __func__, rc);
2154 goto out;
2155 }
2156
2157 rc = regulator_bulk_set_voltage(regs_tsadc_count, regs_tsadc);
2158 if (rc) {
2159 pr_err("%s: could not set regulator voltages: %d\n",
2160 __func__, rc);
2161 goto vreg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002162 }
2163
2164 return 0;
2165
Justin Paupore3f40f342011-08-10 18:52:16 -07002166vreg_free:
2167 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2168out:
2169 regs_tsadc = NULL;
2170 regs_tsadc_count = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002171 return rc;
2172}
2173
2174static int marimba_tsadc_exit(void)
2175{
Justin Paupore3f40f342011-08-10 18:52:16 -07002176 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2177 regs_tsadc_count = 0;
2178 regs_tsadc = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002179
Justin Paupore3f40f342011-08-10 18:52:16 -07002180 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002181}
2182
2183
2184static struct msm_ts_platform_data msm_ts_data = {
Anirudh Ghayal82b74722012-01-19 15:35:34 +05302185 .min_x = 284,
2186 .max_x = 3801,
2187 .min_y = 155,
2188 .max_y = 3929,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002189 .min_press = 0,
2190 .max_press = 255,
2191 .inv_x = 4096,
2192 .inv_y = 4096,
2193 .can_wakeup = false,
2194};
2195
2196static struct marimba_tsadc_platform_data marimba_tsadc_pdata = {
2197 .marimba_tsadc_power = marimba_tsadc_power,
2198 .init = marimba_tsadc_init,
2199 .exit = marimba_tsadc_exit,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002200 .tsadc_prechg_en = true,
2201 .can_wakeup = false,
2202 .setup = {
2203 .pen_irq_en = true,
2204 .tsadc_en = true,
2205 },
2206 .params2 = {
2207 .input_clk_khz = 2400,
2208 .sample_prd = TSADC_CLK_3,
2209 },
2210 .params3 = {
2211 .prechg_time_nsecs = 6400,
2212 .stable_time_nsecs = 6400,
2213 .tsadc_test_mode = 0,
2214 },
2215 .tssc_data = &msm_ts_data,
2216};
2217
Justin Paupore3f40f342011-08-10 18:52:16 -07002218static struct regulator_bulk_data codec_regs[] = {
2219 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
2220};
2221
2222static int __init msm_marimba_codec_init(void)
2223{
2224 int rc = regulator_bulk_get(NULL, ARRAY_SIZE(codec_regs), codec_regs);
2225
2226 if (rc) {
2227 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2228 goto out;
2229 }
2230
2231 rc = regulator_bulk_set_voltage(ARRAY_SIZE(codec_regs), codec_regs);
2232 if (rc) {
2233 pr_err("%s: could not set regulator voltages: %d\n",
2234 __func__, rc);
2235 goto reg_free;
2236 }
2237
2238 return rc;
2239
2240reg_free:
2241 regulator_bulk_free(ARRAY_SIZE(codec_regs), codec_regs);
2242out:
2243 return rc;
2244}
2245
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002246static int msm_marimba_codec_power(int vreg_on)
2247{
Justin Paupore3f40f342011-08-10 18:52:16 -07002248 int rc = vreg_on ?
2249 regulator_bulk_enable(ARRAY_SIZE(codec_regs), codec_regs) :
2250 regulator_bulk_disable(ARRAY_SIZE(codec_regs), codec_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002251
Justin Paupore3f40f342011-08-10 18:52:16 -07002252 if (rc) {
2253 pr_err("%s: could not %sable regulators: %d",
2254 __func__, vreg_on ? "en" : "dis", rc);
2255 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002256 }
2257
Justin Paupore3f40f342011-08-10 18:52:16 -07002258 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002259}
2260
2261static struct marimba_codec_platform_data mariba_codec_pdata = {
2262 .marimba_codec_power = msm_marimba_codec_power,
2263#ifdef CONFIG_MARIMBA_CODEC
2264 .snddev_profile_init = msm_snddev_init,
2265#endif
2266};
2267
2268static struct marimba_platform_data marimba_pdata = {
2269 .slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR,
2270 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2271 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2272 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
2273 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
2274 .marimba_setup = msm_marimba_setup_power,
2275 .marimba_shutdown = msm_marimba_shutdown_power,
2276 .bahama_setup = msm_bahama_setup_power,
2277 .bahama_shutdown = msm_bahama_shutdown_power,
2278 .marimba_gpio_config = msm_marimba_gpio_config_svlte,
2279 .bahama_core_config = msm_bahama_core_config,
2280 .fm = &marimba_fm_pdata,
2281 .codec = &mariba_codec_pdata,
2282 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2283};
2284
2285static void __init msm7x30_init_marimba(void)
2286{
2287 int rc;
2288
Justin Paupore3f40f342011-08-10 18:52:16 -07002289 struct regulator_bulk_data regs[] = {
2290 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2291 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2292 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
2293 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002294
Justin Paupore3f40f342011-08-10 18:52:16 -07002295 rc = msm_marimba_codec_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002296
Justin Paupore3f40f342011-08-10 18:52:16 -07002297 if (rc) {
2298 pr_err("%s: msm_marimba_codec_init failed (%d)\n",
2299 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002300 return;
2301 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002302
2303 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
2304
2305 if (rc) {
2306 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2307 return;
2308 }
2309
2310 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
2311
2312 if (rc) {
2313 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2314 regulator_bulk_free(ARRAY_SIZE(regs), regs);
2315 return;
2316 }
2317
2318 vreg_marimba_1 = regs[0].consumer;
2319 vreg_marimba_2 = regs[1].consumer;
2320 vreg_bahama = regs[2].consumer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002321}
2322
2323static struct marimba_codec_platform_data timpani_codec_pdata = {
2324 .marimba_codec_power = msm_marimba_codec_power,
2325#ifdef CONFIG_TIMPANI_CODEC
2326 .snddev_profile_init = msm_snddev_init_timpani,
2327#endif
2328};
2329
2330static struct marimba_platform_data timpani_pdata = {
2331 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2332 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2333 .marimba_setup = msm_timpani_setup_power,
2334 .marimba_shutdown = msm_timpani_shutdown_power,
2335 .codec = &timpani_codec_pdata,
2336 .tsadc = &marimba_tsadc_pdata,
2337 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2338};
2339
2340#define TIMPANI_I2C_SLAVE_ADDR 0xD
2341
2342static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
2343 {
2344 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
2345 .platform_data = &timpani_pdata,
2346 },
2347};
2348
2349#ifdef CONFIG_MSM7KV2_AUDIO
2350static struct resource msm_aictl_resources[] = {
2351 {
2352 .name = "aictl",
2353 .start = 0xa5000100,
2354 .end = 0xa5000100,
2355 .flags = IORESOURCE_MEM,
2356 }
2357};
2358
2359static struct resource msm_mi2s_resources[] = {
2360 {
2361 .name = "hdmi",
2362 .start = 0xac900000,
2363 .end = 0xac900038,
2364 .flags = IORESOURCE_MEM,
2365 },
2366 {
2367 .name = "codec_rx",
2368 .start = 0xac940040,
2369 .end = 0xac940078,
2370 .flags = IORESOURCE_MEM,
2371 },
2372 {
2373 .name = "codec_tx",
2374 .start = 0xac980080,
2375 .end = 0xac9800B8,
2376 .flags = IORESOURCE_MEM,
2377 }
2378
2379};
2380
2381static struct msm_lpa_platform_data lpa_pdata = {
2382 .obuf_hlb_size = 0x2BFF8,
2383 .dsp_proc_id = 0,
2384 .app_proc_id = 2,
2385 .nosb_config = {
2386 .llb_min_addr = 0,
2387 .llb_max_addr = 0x3ff8,
2388 .sb_min_addr = 0,
2389 .sb_max_addr = 0,
2390 },
2391 .sb_config = {
2392 .llb_min_addr = 0,
2393 .llb_max_addr = 0x37f8,
2394 .sb_min_addr = 0x3800,
2395 .sb_max_addr = 0x3ff8,
2396 }
2397};
2398
2399static struct resource msm_lpa_resources[] = {
2400 {
2401 .name = "lpa",
2402 .start = 0xa5000000,
2403 .end = 0xa50000a0,
2404 .flags = IORESOURCE_MEM,
2405 }
2406};
2407
2408static struct resource msm_aux_pcm_resources[] = {
2409
2410 {
2411 .name = "aux_codec_reg_addr",
2412 .start = 0xac9c00c0,
2413 .end = 0xac9c00c8,
2414 .flags = IORESOURCE_MEM,
2415 },
2416 {
2417 .name = "aux_pcm_dout",
2418 .start = 138,
2419 .end = 138,
2420 .flags = IORESOURCE_IO,
2421 },
2422 {
2423 .name = "aux_pcm_din",
2424 .start = 139,
2425 .end = 139,
2426 .flags = IORESOURCE_IO,
2427 },
2428 {
2429 .name = "aux_pcm_syncout",
2430 .start = 140,
2431 .end = 140,
2432 .flags = IORESOURCE_IO,
2433 },
2434 {
2435 .name = "aux_pcm_clkin_a",
2436 .start = 141,
2437 .end = 141,
2438 .flags = IORESOURCE_IO,
2439 },
2440};
2441
2442static struct platform_device msm_aux_pcm_device = {
2443 .name = "msm_aux_pcm",
2444 .id = 0,
2445 .num_resources = ARRAY_SIZE(msm_aux_pcm_resources),
2446 .resource = msm_aux_pcm_resources,
2447};
2448
2449struct platform_device msm_aictl_device = {
2450 .name = "audio_interct",
2451 .id = 0,
2452 .num_resources = ARRAY_SIZE(msm_aictl_resources),
2453 .resource = msm_aictl_resources,
2454};
2455
2456struct platform_device msm_mi2s_device = {
2457 .name = "mi2s",
2458 .id = 0,
2459 .num_resources = ARRAY_SIZE(msm_mi2s_resources),
2460 .resource = msm_mi2s_resources,
2461};
2462
2463struct platform_device msm_lpa_device = {
2464 .name = "lpa",
2465 .id = 0,
2466 .num_resources = ARRAY_SIZE(msm_lpa_resources),
2467 .resource = msm_lpa_resources,
2468 .dev = {
2469 .platform_data = &lpa_pdata,
2470 },
2471};
2472#endif /* CONFIG_MSM7KV2_AUDIO */
2473
2474#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2475 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2476 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2477 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2478 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2479 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2480#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2481 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2482 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2483 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2484 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2485 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2486 #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2487 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2488 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2489 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2490 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2491 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2492 #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2493 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2494 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2495 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2496 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2497 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2498#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
2499
2500static unsigned int dec_concurrency_table[] = {
2501 /* Audio LP */
2502 0,
2503 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2504 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2505 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2506 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)|
2507 (1<<MSM_ADSP_OP_DM)),
2508
2509 /* Concurrency 1 */
2510 (DEC4_FORMAT),
2511 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2512 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2513 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2514 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2515
2516 /* Concurrency 2 */
2517 (DEC4_FORMAT),
2518 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2519 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2520 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2521 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2522
2523 /* Concurrency 3 */
2524 (DEC4_FORMAT),
2525 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2526 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2527 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2528 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2529
2530 /* Concurrency 4 */
2531 (DEC4_FORMAT),
2532 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2533 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2534 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2535 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2536
2537 /* Concurrency 5 */
2538 (DEC4_FORMAT),
2539 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2540 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2541 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2542 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2543
2544 /* Concurrency 6 */
2545 (DEC4_FORMAT),
2546 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2547 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2548 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2549 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2550};
2551
2552#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
2553 .module_queueid = queueid, .module_decid = decid, \
2554 .nr_codec_support = nr_codec}
2555
2556#define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
2557 .max_instances_same_dec = max_instance_same, \
2558 .max_instances_diff_dec = max_instance_diff}
2559
2560static struct msm_adspdec_info dec_info_list[] = {
2561 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
2562 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
2563 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
2564 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
2565 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
2566};
2567
2568static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
2569 /* Non Turbo Mode */
2570 {
2571 DEC_INSTANCE(4, 3), /* WAV */
2572 DEC_INSTANCE(4, 3), /* ADPCM */
2573 DEC_INSTANCE(4, 2), /* MP3 */
2574 DEC_INSTANCE(0, 0), /* Real Audio */
2575 DEC_INSTANCE(4, 2), /* WMA */
2576 DEC_INSTANCE(3, 2), /* AAC */
2577 DEC_INSTANCE(0, 0), /* Reserved */
2578 DEC_INSTANCE(0, 0), /* MIDI */
2579 DEC_INSTANCE(4, 3), /* YADPCM */
2580 DEC_INSTANCE(4, 3), /* QCELP */
2581 DEC_INSTANCE(4, 3), /* AMRNB */
2582 DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
2583 DEC_INSTANCE(4, 3), /* EVRC */
2584 DEC_INSTANCE(1, 1), /* WMAPRO */
2585 },
2586 /* Turbo Mode */
2587 {
2588 DEC_INSTANCE(4, 3), /* WAV */
2589 DEC_INSTANCE(4, 3), /* ADPCM */
2590 DEC_INSTANCE(4, 3), /* MP3 */
2591 DEC_INSTANCE(0, 0), /* Real Audio */
2592 DEC_INSTANCE(4, 3), /* WMA */
2593 DEC_INSTANCE(4, 3), /* AAC */
2594 DEC_INSTANCE(0, 0), /* Reserved */
2595 DEC_INSTANCE(0, 0), /* MIDI */
2596 DEC_INSTANCE(4, 3), /* YADPCM */
2597 DEC_INSTANCE(4, 3), /* QCELP */
2598 DEC_INSTANCE(4, 3), /* AMRNB */
2599 DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
2600 DEC_INSTANCE(4, 3), /* EVRC */
2601 DEC_INSTANCE(1, 2), /* WMAPRO */
2602 },
2603};
2604
2605static struct msm_adspdec_database msm_device_adspdec_database = {
2606 .num_dec = ARRAY_SIZE(dec_info_list),
2607 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
2608 ARRAY_SIZE(dec_info_list)),
2609 .dec_concurrency_table = dec_concurrency_table,
2610 .dec_info_list = dec_info_list,
2611 .dec_instance_list = &dec_instance_list[0][0],
2612};
2613
2614static struct platform_device msm_device_adspdec = {
2615 .name = "msm_adspdec",
2616 .id = -1,
2617 .dev = {
2618 .platform_data = &msm_device_adspdec_database
2619 },
2620};
2621
2622static struct resource smc91x_resources[] = {
2623 [0] = {
2624 .start = 0x8A000300,
2625 .end = 0x8A0003ff,
2626 .flags = IORESOURCE_MEM,
2627 },
2628 [1] = {
2629 .start = MSM_GPIO_TO_INT(156),
2630 .end = MSM_GPIO_TO_INT(156),
2631 .flags = IORESOURCE_IRQ,
2632 },
2633};
2634
2635static struct platform_device smc91x_device = {
2636 .name = "smc91x",
2637 .id = 0,
2638 .num_resources = ARRAY_SIZE(smc91x_resources),
2639 .resource = smc91x_resources,
2640};
2641
2642static struct smsc911x_platform_config smsc911x_config = {
2643 .phy_interface = PHY_INTERFACE_MODE_MII,
2644 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
2645 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
2646 .flags = SMSC911X_USE_32BIT,
2647};
2648
2649static struct resource smsc911x_resources[] = {
2650 [0] = {
2651 .start = 0x8D000000,
2652 .end = 0x8D000100,
2653 .flags = IORESOURCE_MEM,
2654 },
2655 [1] = {
2656 .start = MSM_GPIO_TO_INT(88),
2657 .end = MSM_GPIO_TO_INT(88),
2658 .flags = IORESOURCE_IRQ,
2659 },
2660};
2661
2662static struct platform_device smsc911x_device = {
2663 .name = "smsc911x",
2664 .id = -1,
2665 .num_resources = ARRAY_SIZE(smsc911x_resources),
2666 .resource = smsc911x_resources,
2667 .dev = {
2668 .platform_data = &smsc911x_config,
2669 },
2670};
2671
2672static struct msm_gpio smsc911x_gpios[] = {
2673 { GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" },
2674 { GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" },
2675 { GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" },
2676 { GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" },
2677 { GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" },
2678 { GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" },
2679 { GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" },
2680 { GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" },
2681};
2682
2683static void msm7x30_cfg_smsc911x(void)
2684{
2685 int rc;
2686
2687 rc = msm_gpios_request_enable(smsc911x_gpios,
2688 ARRAY_SIZE(smsc911x_gpios));
2689 if (rc)
2690 pr_err("%s: unable to enable gpios\n", __func__);
2691}
2692
2693#ifdef CONFIG_USB_G_ANDROID
2694static struct android_usb_platform_data android_usb_pdata = {
2695 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2696};
2697
2698static struct platform_device android_usb_device = {
2699 .name = "android_usb",
2700 .id = -1,
2701 .dev = {
2702 .platform_data = &android_usb_pdata,
2703 },
2704};
2705#endif
2706
2707static struct msm_gpio optnav_config_data[] = {
2708 { GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA),
2709 "optnav_chip_select" },
2710};
2711
Justin Paupore3f40f342011-08-10 18:52:16 -07002712static struct regulator_bulk_data optnav_regulators[] = {
2713 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2714 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
2715 { .supply = "gp9", .min_uV = 1800000, .max_uV = 1800000 },
2716 { .supply = "usb", .min_uV = 3300000, .max_uV = 3300000 },
2717};
2718
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002719static void __iomem *virtual_optnav;
2720
2721static int optnav_gpio_setup(void)
2722{
2723 int rc = -ENODEV;
2724 rc = msm_gpios_request_enable(optnav_config_data,
2725 ARRAY_SIZE(optnav_config_data));
2726
Justin Paupore3f40f342011-08-10 18:52:16 -07002727 if (rc)
2728 return rc;
2729
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002730 /* Configure the FPGA for GPIOs */
2731 virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4);
2732 if (!virtual_optnav) {
2733 pr_err("%s:Could not ioremap region\n", __func__);
2734 return -ENOMEM;
2735 }
2736 /*
2737 * Configure the FPGA to set GPIO 19 as
2738 * normal, active(enabled), output(MSM to SURF)
2739 */
2740 writew(0x311E, virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002741
2742 rc = regulator_bulk_get(NULL, ARRAY_SIZE(optnav_regulators),
2743 optnav_regulators);
2744 if (rc)
2745 return rc;
2746
2747 rc = regulator_bulk_set_voltage(ARRAY_SIZE(optnav_regulators),
2748 optnav_regulators);
2749
2750 if (rc)
2751 goto regulator_put;
2752
2753 return rc;
2754
2755regulator_put:
2756 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002757 return rc;
2758}
2759
2760static void optnav_gpio_release(void)
2761{
2762 msm_gpios_disable_free(optnav_config_data,
2763 ARRAY_SIZE(optnav_config_data));
2764 iounmap(virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002765 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002766}
2767
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002768static int optnav_enable(void)
2769{
2770 int rc;
2771 /*
2772 * Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
2773 * for I2C communication with keyboard.
2774 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002775
Justin Paupore3f40f342011-08-10 18:52:16 -07002776 rc = regulator_bulk_enable(ARRAY_SIZE(optnav_regulators),
2777 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002778
Justin Paupore3f40f342011-08-10 18:52:16 -07002779 if (rc)
2780 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002781
2782 /* Enable the chip select GPIO */
2783 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2784 gpio_set_value(OPTNAV_CHIP_SELECT, 0);
2785
2786 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002787}
2788
2789static void optnav_disable(void)
2790{
Justin Paupore3f40f342011-08-10 18:52:16 -07002791 regulator_bulk_disable(ARRAY_SIZE(optnav_regulators),
2792 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002793
2794 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2795}
2796
2797static struct ofn_atlab_platform_data optnav_data = {
2798 .gpio_setup = optnav_gpio_setup,
2799 .gpio_release = optnav_gpio_release,
2800 .optnav_on = optnav_enable,
2801 .optnav_off = optnav_disable,
2802 .rotate_xy = 0,
2803 .function1 = {
2804 .no_motion1_en = true,
2805 .touch_sensor_en = true,
2806 .ofn_en = true,
2807 .clock_select_khz = 1500,
2808 .cpi_selection = 1200,
2809 },
2810 .function2 = {
2811 .invert_y = false,
2812 .invert_x = true,
2813 .swap_x_y = false,
2814 .hold_a_b_en = true,
2815 .motion_filter_en = true,
2816 },
2817};
2818
2819static int hdmi_comm_power(int on, int show);
2820static int hdmi_init_irq(void);
2821static int hdmi_enable_5v(int on);
2822static int hdmi_core_power(int on, int show);
2823static int hdmi_cec_power(int on);
2824static bool hdmi_check_hdcp_hw_support(void);
2825
2826static struct msm_hdmi_platform_data adv7520_hdmi_data = {
2827 .irq = MSM_GPIO_TO_INT(18),
2828 .comm_power = hdmi_comm_power,
2829 .init_irq = hdmi_init_irq,
2830 .enable_5v = hdmi_enable_5v,
2831 .core_power = hdmi_core_power,
2832 .cec_power = hdmi_cec_power,
2833 .check_hdcp_hw_support = hdmi_check_hdcp_hw_support,
2834};
2835
2836#ifdef CONFIG_BOSCH_BMA150
Justin Paupore3f40f342011-08-10 18:52:16 -07002837
2838static struct regulator_bulk_data sensors_ldo[] = {
2839 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2840 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
2841};
2842
2843static int __init sensors_ldo_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002844{
2845 int rc;
2846
Justin Paupore3f40f342011-08-10 18:52:16 -07002847 rc = regulator_bulk_get(NULL, ARRAY_SIZE(sensors_ldo), sensors_ldo);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002848
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002849 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002850 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2851 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002852 }
2853
Justin Paupore3f40f342011-08-10 18:52:16 -07002854 rc = regulator_bulk_set_voltage(ARRAY_SIZE(sensors_ldo), sensors_ldo);
2855
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002856 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002857 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2858 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002859 }
2860
2861 return 0;
2862
Justin Paupore3f40f342011-08-10 18:52:16 -07002863reg_free:
2864 regulator_bulk_free(ARRAY_SIZE(sensors_ldo), sensors_ldo);
2865out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002866 return rc;
2867}
2868
Justin Paupore3f40f342011-08-10 18:52:16 -07002869static int sensors_ldo_set(int on)
2870{
2871 int rc = on ?
2872 regulator_bulk_enable(ARRAY_SIZE(sensors_ldo), sensors_ldo) :
2873 regulator_bulk_disable(ARRAY_SIZE(sensors_ldo), sensors_ldo);
2874
2875 if (rc)
2876 pr_err("%s: could not %sable regulators: %d\n",
2877 __func__, on ? "en" : "dis", rc);
2878
2879 return rc;
2880}
2881
2882static int sensors_ldo_enable(void)
2883{
2884 return sensors_ldo_set(1);
2885}
2886
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002887static void sensors_ldo_disable(void)
2888{
Justin Paupore3f40f342011-08-10 18:52:16 -07002889 sensors_ldo_set(0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002890}
Justin Paupore3f40f342011-08-10 18:52:16 -07002891
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002892static struct bma150_platform_data bma150_data = {
2893 .power_on = sensors_ldo_enable,
2894 .power_off = sensors_ldo_disable,
2895};
2896
2897static struct i2c_board_info bma150_board_info[] __initdata = {
2898 {
2899 I2C_BOARD_INFO("bma150", 0x38),
2900 .flags = I2C_CLIENT_WAKE,
2901 .irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
2902 .platform_data = &bma150_data,
2903 },
2904};
2905#endif
2906
2907static struct i2c_board_info msm_i2c_board_info[] = {
2908 {
2909 I2C_BOARD_INFO("m33c01", OPTNAV_I2C_SLAVE_ADDR),
2910 .irq = MSM_GPIO_TO_INT(OPTNAV_IRQ),
2911 .platform_data = &optnav_data,
2912 },
2913 {
2914 I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR),
2915 .platform_data = &adv7520_hdmi_data,
2916 },
2917};
2918
2919static struct i2c_board_info msm_marimba_board_info[] = {
2920 {
2921 I2C_BOARD_INFO("marimba", 0xc),
2922 .platform_data = &marimba_pdata,
2923 }
2924};
2925
2926
2927static struct msm_handset_platform_data hs_platform_data = {
2928 .hs_name = "7k_handset",
2929 .pwr_key_delay_ms = 500, /* 0 will disable end key */
2930};
2931
2932static struct platform_device hs_device = {
2933 .name = "msm-handset",
2934 .id = -1,
2935 .dev = {
2936 .platform_data = &hs_platform_data,
2937 },
2938};
2939
2940static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +05302941 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002942 .idle_supported = 1,
2943 .suspend_supported = 1,
2944 .idle_enabled = 1,
2945 .suspend_enabled = 1,
2946 .latency = 8594,
2947 .residency = 23740,
2948 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05302949 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002950 .idle_supported = 1,
2951 .suspend_supported = 1,
2952 .idle_enabled = 1,
2953 .suspend_enabled = 1,
2954 .latency = 4594,
2955 .residency = 23740,
2956 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05302957 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002958#ifdef CONFIG_MSM_STANDALONE_POWER_COLLAPSE
2959 .idle_supported = 1,
2960 .suspend_supported = 1,
2961 .idle_enabled = 1,
2962 .suspend_enabled = 0,
2963#else /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
2964 .idle_supported = 0,
2965 .suspend_supported = 0,
2966 .idle_enabled = 0,
2967 .suspend_enabled = 0,
2968#endif /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
2969 .latency = 500,
2970 .residency = 6000,
2971 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05302972 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002973 .idle_supported = 1,
2974 .suspend_supported = 1,
2975 .idle_enabled = 0,
2976 .suspend_enabled = 1,
2977 .latency = 443,
2978 .residency = 1098,
2979 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05302980 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002981 .idle_supported = 1,
2982 .suspend_supported = 1,
2983 .idle_enabled = 1,
2984 .suspend_enabled = 1,
2985 .latency = 2,
2986 .residency = 0,
2987 },
2988};
2989
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06002990static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
2991 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
2992 .v_addr = (uint32_t *)PAGE_OFFSET,
2993};
2994
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002995static struct resource qsd_spi_resources[] = {
2996 {
2997 .name = "spi_irq_in",
2998 .start = INT_SPI_INPUT,
2999 .end = INT_SPI_INPUT,
3000 .flags = IORESOURCE_IRQ,
3001 },
3002 {
3003 .name = "spi_irq_out",
3004 .start = INT_SPI_OUTPUT,
3005 .end = INT_SPI_OUTPUT,
3006 .flags = IORESOURCE_IRQ,
3007 },
3008 {
3009 .name = "spi_irq_err",
3010 .start = INT_SPI_ERROR,
3011 .end = INT_SPI_ERROR,
3012 .flags = IORESOURCE_IRQ,
3013 },
3014 {
3015 .name = "spi_base",
3016 .start = 0xA8000000,
3017 .end = 0xA8000000 + SZ_4K - 1,
3018 .flags = IORESOURCE_MEM,
3019 },
3020 {
3021 .name = "spidm_channels",
3022 .flags = IORESOURCE_DMA,
3023 },
3024 {
3025 .name = "spidm_crci",
3026 .flags = IORESOURCE_DMA,
3027 },
3028};
3029
3030#define AMDH0_BASE_PHYS 0xAC200000
3031#define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
3032static int msm_qsd_spi_dma_config(void)
3033{
3034 void __iomem *ct_adm_base = 0;
3035 u32 spi_mux = 0;
3036 int ret = 0;
3037
3038 ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
3039 if (!ct_adm_base) {
3040 pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
3041 return -ENOMEM;
3042 }
3043
3044 spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
3045
3046 qsd_spi_resources[4].start = DMOV_USB_CHAN;
3047 qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
3048
3049 switch (spi_mux) {
3050 case (1):
3051 qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
3052 qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
3053 break;
3054 case (2):
3055 qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
3056 qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
3057 break;
3058 case (3):
3059 qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
3060 qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
3061 break;
3062 default:
3063 ret = -ENOENT;
3064 }
3065
3066 iounmap(ct_adm_base);
3067
3068 return ret;
3069}
3070
3071static struct platform_device qsd_device_spi = {
3072 .name = "spi_qsd",
3073 .id = 0,
3074 .num_resources = ARRAY_SIZE(qsd_spi_resources),
3075 .resource = qsd_spi_resources,
3076};
3077
3078#ifdef CONFIG_SPI_QSD
3079static struct spi_board_info lcdc_sharp_spi_board_info[] __initdata = {
3080 {
3081 .modalias = "lcdc_sharp_ls038y7dx01",
3082 .mode = SPI_MODE_1,
3083 .bus_num = 0,
3084 .chip_select = 0,
3085 .max_speed_hz = 26331429,
3086 }
3087};
3088static struct spi_board_info lcdc_toshiba_spi_board_info[] __initdata = {
3089 {
3090 .modalias = "lcdc_toshiba_ltm030dd40",
3091 .mode = SPI_MODE_3|SPI_CS_HIGH,
3092 .bus_num = 0,
3093 .chip_select = 0,
3094 .max_speed_hz = 9963243,
3095 }
3096};
3097#endif
3098
3099static struct msm_gpio qsd_spi_gpio_config_data[] = {
3100 { GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3101 { GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3102 { GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" },
3103 { GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3104};
3105
3106static int msm_qsd_spi_gpio_config(void)
3107{
3108 return msm_gpios_request_enable(qsd_spi_gpio_config_data,
3109 ARRAY_SIZE(qsd_spi_gpio_config_data));
3110}
3111
3112static void msm_qsd_spi_gpio_release(void)
3113{
3114 msm_gpios_disable_free(qsd_spi_gpio_config_data,
3115 ARRAY_SIZE(qsd_spi_gpio_config_data));
3116}
3117
3118static struct msm_spi_platform_data qsd_spi_pdata = {
3119 .max_clock_speed = 26331429,
3120 .gpio_config = msm_qsd_spi_gpio_config,
3121 .gpio_release = msm_qsd_spi_gpio_release,
3122 .dma_config = msm_qsd_spi_dma_config,
3123};
3124
3125static void __init msm_qsd_spi_init(void)
3126{
3127 qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
3128}
3129
3130#ifdef CONFIG_USB_EHCI_MSM_72K
3131static void msm_hsusb_vbus_power(unsigned phy_info, int on)
3132{
3133 int rc;
3134 static int vbus_is_on;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303135 struct pm8xxx_gpio_init_info usb_vbus = {
3136 PM8058_GPIO_PM_TO_SYS(36),
3137 {
3138 .direction = PM_GPIO_DIR_OUT,
3139 .pull = PM_GPIO_PULL_NO,
3140 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3141 .output_value = 1,
3142 .vin_sel = 2,
3143 .out_strength = PM_GPIO_STRENGTH_MED,
3144 .function = PM_GPIO_FUNC_NORMAL,
3145 .inv_int_pol = 0,
3146 },
3147 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003148
3149 /* If VBUS is already on (or off), do nothing. */
3150 if (unlikely(on == vbus_is_on))
3151 return;
3152
3153 if (on) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303154 rc = pm8xxx_gpio_config(usb_vbus.gpio, &usb_vbus.config);
3155 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003156 pr_err("%s PMIC GPIO 36 write failed\n", __func__);
3157 return;
3158 }
3159 } else {
3160 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(36), 0);
3161 }
3162
3163 vbus_is_on = on;
3164}
3165
3166static struct msm_usb_host_platform_data msm_usb_host_pdata = {
3167 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
3168 .vbus_power = msm_hsusb_vbus_power,
3169 .power_budget = 180,
3170};
3171#endif
3172
3173#ifdef CONFIG_USB_MSM_OTG_72K
3174static int hsusb_rpc_connect(int connect)
3175{
3176 if (connect)
3177 return msm_hsusb_rpc_connect();
3178 else
3179 return msm_hsusb_rpc_close();
3180}
3181#endif
3182
3183#ifdef CONFIG_USB_MSM_OTG_72K
Justin Paupore3f40f342011-08-10 18:52:16 -07003184static struct regulator *vreg_3p3;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003185static int msm_hsusb_ldo_init(int init)
3186{
3187 uint32_t version = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07003188 int def_vol = 3400000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003189
3190 version = socinfo_get_version();
3191
3192 if (SOCINFO_VERSION_MAJOR(version) >= 2 &&
3193 SOCINFO_VERSION_MINOR(version) >= 1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003194 def_vol = 3075000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003195 pr_debug("%s: default voltage:%d\n", __func__, def_vol);
3196 }
3197
3198 if (init) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003199 vreg_3p3 = regulator_get(NULL, "usb");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003200 if (IS_ERR(vreg_3p3))
3201 return PTR_ERR(vreg_3p3);
Justin Paupore3f40f342011-08-10 18:52:16 -07003202 regulator_set_voltage(vreg_3p3, def_vol, def_vol);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003203 } else
Justin Paupore3f40f342011-08-10 18:52:16 -07003204 regulator_put(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003205
3206 return 0;
3207}
3208
3209static int msm_hsusb_ldo_enable(int enable)
3210{
3211 static int ldo_status;
3212
3213 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3214 return -ENODEV;
3215
3216 if (ldo_status == enable)
3217 return 0;
3218
3219 ldo_status = enable;
3220
3221 if (enable)
Justin Paupore3f40f342011-08-10 18:52:16 -07003222 return regulator_enable(vreg_3p3);
3223 else
3224 return regulator_disable(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003225}
3226
3227static int msm_hsusb_ldo_set_voltage(int mV)
3228{
Justin Paupore3f40f342011-08-10 18:52:16 -07003229 static int cur_voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003230
3231 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3232 return -ENODEV;
3233
3234 if (cur_voltage == mV)
3235 return 0;
3236
3237 cur_voltage = mV;
3238
3239 pr_debug("%s: (%d)\n", __func__, mV);
3240
Justin Paupore3f40f342011-08-10 18:52:16 -07003241 return regulator_set_voltage(vreg_3p3, mV*1000, mV*1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003242}
3243#endif
3244
3245#ifndef CONFIG_USB_EHCI_MSM_72K
3246static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init);
3247#endif
3248static struct msm_otg_platform_data msm_otg_pdata = {
3249 .rpc_connect = hsusb_rpc_connect,
3250
3251#ifndef CONFIG_USB_EHCI_MSM_72K
3252 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
3253#else
3254 .vbus_power = msm_hsusb_vbus_power,
3255#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003256 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
3257 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
3258 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
3259 .se1_gating = SE1_GATING_DISABLE,
3260 .chg_vbus_draw = hsusb_chg_vbus_draw,
3261 .chg_connected = hsusb_chg_connected,
3262 .chg_init = hsusb_chg_init,
3263 .ldo_enable = msm_hsusb_ldo_enable,
3264 .ldo_init = msm_hsusb_ldo_init,
3265 .ldo_set_voltage = msm_hsusb_ldo_set_voltage,
3266};
3267
3268#ifdef CONFIG_USB_GADGET
3269static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
3270 .is_phy_status_timer_on = 1,
3271};
3272#endif
3273#ifndef CONFIG_USB_EHCI_MSM_72K
3274typedef void (*notify_vbus_state) (int);
3275notify_vbus_state notify_vbus_state_func_ptr;
3276int vbus_on_irq;
3277static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
3278{
3279 pr_info("%s: vbus notification from pmic\n", __func__);
3280
3281 (*notify_vbus_state_func_ptr) (1);
3282
3283 return IRQ_HANDLED;
3284}
3285static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
3286{
3287 int ret;
3288
3289 if (init) {
3290 if (!callback)
3291 return -ENODEV;
3292
3293 notify_vbus_state_func_ptr = callback;
3294 vbus_on_irq = platform_get_irq_byname(&msm_device_otg,
3295 "vbus_on");
3296 if (vbus_on_irq <= 0) {
3297 pr_err("%s: unable to get vbus on irq\n", __func__);
3298 return -ENODEV;
3299 }
3300
3301 ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq,
3302 IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
3303 if (ret < 0) {
3304 pr_info("%s: request_irq for vbus_on"
3305 "interrupt failed\n", __func__);
3306 return ret;
3307 }
3308 msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
3309 return 0;
3310 } else {
3311 free_irq(vbus_on_irq, 0);
3312 notify_vbus_state_func_ptr = NULL;
3313 return 0;
3314 }
3315}
3316#endif
3317
3318static struct android_pmem_platform_data android_pmem_pdata = {
3319 .name = "pmem",
3320 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
3321 .cached = 1,
3322 .memory_type = MEMTYPE_EBI0,
3323};
3324
3325static struct platform_device android_pmem_device = {
3326 .name = "android_pmem",
3327 .id = 0,
3328 .dev = { .platform_data = &android_pmem_pdata },
3329};
3330
3331#ifndef CONFIG_SPI_QSD
3332static int lcdc_gpio_array_num[] = {
3333 45, /* spi_clk */
3334 46, /* spi_cs */
3335 47, /* spi_mosi */
3336 48, /* spi_miso */
3337 };
3338
3339static struct msm_gpio lcdc_gpio_config_data[] = {
3340 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3341 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3342 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
3343 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3344};
3345
3346static void lcdc_config_gpios(int enable)
3347{
3348 if (enable) {
3349 msm_gpios_request_enable(lcdc_gpio_config_data,
3350 ARRAY_SIZE(
3351 lcdc_gpio_config_data));
3352 } else
3353 msm_gpios_disable_free(lcdc_gpio_config_data,
3354 ARRAY_SIZE(
3355 lcdc_gpio_config_data));
3356}
3357#endif
3358
3359static struct msm_panel_common_pdata lcdc_sharp_panel_data = {
3360#ifndef CONFIG_SPI_QSD
3361 .panel_config_gpio = lcdc_config_gpios,
3362 .gpio_num = lcdc_gpio_array_num,
3363#endif
3364 .gpio = 2, /* LPG PMIC_GPIO26 channel number */
3365};
3366
3367static struct platform_device lcdc_sharp_panel_device = {
3368 .name = "lcdc_sharp_wvga",
3369 .id = 0,
3370 .dev = {
3371 .platform_data = &lcdc_sharp_panel_data,
3372 }
3373};
3374
3375static struct msm_gpio dtv_panel_irq_gpios[] = {
3376 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
3377 "hdmi_int" },
3378};
3379
3380static struct msm_gpio dtv_panel_gpios[] = {
3381 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
3382 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
3383 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
3384 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
3385 { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
3386 { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
3387 { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
3388 { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
3389 { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
3390 { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
3391 { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
3392 { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
3393 { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
3394 { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
3395 { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
3396 { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
3397 { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
3398 { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
3399 { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
3400 { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
3401 { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
3402 { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
3403 { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
3404 { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
3405 { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
3406 { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
3407 { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
3408 { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
3409 { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
3410 { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
3411 { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
3412 { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
3413};
3414
3415
3416#ifdef HDMI_RESET
3417static unsigned dtv_reset_gpio =
3418 GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3419#endif
3420
Justin Paupore3f40f342011-08-10 18:52:16 -07003421static struct regulator_bulk_data hdmi_core_regs[] = {
3422 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3423};
3424
3425static struct regulator_bulk_data hdmi_comm_regs[] = {
3426 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3427 { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 },
3428};
3429
3430static struct regulator_bulk_data hdmi_cec_regs[] = {
3431 { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 },
3432};
3433
3434static int __init hdmi_init_regs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003435{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003436 int rc;
3437
Justin Paupore3f40f342011-08-10 18:52:16 -07003438 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs),
3439 hdmi_core_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003440
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003441 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003442 pr_err("%s: could not get %s regulators: %d\n",
3443 __func__, "core", rc);
3444 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003445 }
3446
Justin Paupore3f40f342011-08-10 18:52:16 -07003447 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs),
3448 hdmi_core_regs);
3449
3450 if (rc) {
3451 pr_err("%s: could not set %s voltages: %d\n",
3452 __func__, "core", rc);
3453 goto free_core;
3454 }
3455
3456 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs),
3457 hdmi_comm_regs);
3458
3459 if (rc) {
3460 pr_err("%s: could not get %s regulators: %d\n",
3461 __func__, "comm", rc);
3462 goto free_core;
3463 }
3464
3465 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs),
3466 hdmi_comm_regs);
3467
3468 if (rc) {
3469 pr_err("%s: could not set %s voltages: %d\n",
3470 __func__, "comm", rc);
3471 goto free_comm;
3472 }
3473
3474 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs),
3475 hdmi_cec_regs);
3476
3477 if (rc) {
3478 pr_err("%s: could not get %s regulators: %d\n",
3479 __func__, "cec", rc);
3480 goto free_comm;
3481 }
3482
3483 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs),
3484 hdmi_cec_regs);
3485
3486 if (rc) {
3487 pr_err("%s: could not set %s voltages: %d\n",
3488 __func__, "cec", rc);
3489 goto free_cec;
3490 }
3491
3492 return 0;
3493
3494free_cec:
3495 regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs);
3496free_comm:
3497 regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs);
3498free_core:
3499 regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs);
3500out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003501 return rc;
3502}
3503
Justin Paupore3f40f342011-08-10 18:52:16 -07003504static int hdmi_init_irq(void)
3505{
3506 int rc = msm_gpios_enable(dtv_panel_irq_gpios,
3507 ARRAY_SIZE(dtv_panel_irq_gpios));
3508 if (rc < 0) {
3509 pr_err("%s: gpio enable failed: %d\n", __func__, rc);
3510 return rc;
3511 }
3512 pr_info("%s\n", __func__);
3513
3514 return 0;
3515}
3516
3517static int hdmi_enable_5v(int on)
3518{
3519 int pmic_gpio_hdmi_5v_en ;
3520
3521 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
3522 machine_is_msm7x30_fluid())
3523 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
3524 else
3525 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
3526
3527 pr_info("%s: %d\n", __func__, on);
3528 if (on) {
3529 int rc;
3530 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
3531 "hdmi_5V_en");
3532 if (rc) {
3533 pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
3534 __func__);
3535 return rc;
3536 }
3537 gpio_set_value_cansleep(
3538 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
3539 } else {
3540 gpio_set_value_cansleep(
3541 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
3542 gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
3543 }
3544 return 0;
3545}
3546
3547static int hdmi_comm_power(int on, int show)
3548{
3549 if (show)
3550 pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
3551 return on ?
3552 regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs),
3553 hdmi_comm_regs) :
3554 regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs),
3555 hdmi_comm_regs);
3556}
3557
3558static int hdmi_core_power(int on, int show)
3559{
3560 if (show)
3561 pr_info("%s: %d <LDO8>\n", __func__, on);
3562 return on ?
3563 regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs),
3564 hdmi_core_regs) :
3565 regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs),
3566 hdmi_core_regs);
3567}
3568
3569static int hdmi_cec_power(int on)
3570{
3571 pr_info("%s: %d <LDO17>\n", __func__, on);
3572 return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs),
3573 hdmi_cec_regs) :
3574 regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs),
3575 hdmi_cec_regs);
3576}
3577
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003578#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
3579/* there is an i2c address conflict between adv7520 and bma150 sensor after
3580 * power up on fluid. As a solution, the default address of adv7520's packet
3581 * memory is changed as soon as possible
3582 */
3583static int __init fluid_i2c_address_fixup(void)
3584{
3585 unsigned char wBuff[16];
3586 unsigned char rBuff[16];
3587 struct i2c_msg msgs[3];
3588 int res;
3589 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003590 struct i2c_adapter *adapter;
3591
3592 if (machine_is_msm7x30_fluid()) {
3593 adapter = i2c_get_adapter(0);
3594 if (!adapter) {
3595 pr_err("%s: invalid i2c adapter\n", __func__);
3596 return PTR_ERR(adapter);
3597 }
3598
3599 /* turn on LDO8 */
Justin Paupore3f40f342011-08-10 18:52:16 -07003600 rc = hdmi_core_power(1, 0);
3601 if (rc) {
3602 pr_err("%s: could not enable hdmi core regs: %d",
3603 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003604 goto adapter_put;
3605 }
3606
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003607 /* change packet memory address to 0x74 */
3608 wBuff[0] = 0x45;
3609 wBuff[1] = 0x74;
3610
3611 msgs[0].addr = ADV7520_I2C_ADDR;
3612 msgs[0].flags = 0;
3613 msgs[0].buf = (unsigned char *) wBuff;
3614 msgs[0].len = 2;
3615
3616 res = i2c_transfer(adapter, msgs, 1);
3617 if (res != 1) {
3618 pr_err("%s: error writing adv7520\n", __func__);
3619 goto ldo8_disable;
3620 }
3621
3622 /* powerdown adv7520 using bit 6 */
3623 /* i2c read first */
3624 wBuff[0] = 0x41;
3625
3626 msgs[0].addr = ADV7520_I2C_ADDR;
3627 msgs[0].flags = 0;
3628 msgs[0].buf = (unsigned char *) wBuff;
3629 msgs[0].len = 1;
3630
3631 msgs[1].addr = ADV7520_I2C_ADDR;
3632 msgs[1].flags = I2C_M_RD;
3633 msgs[1].buf = rBuff;
3634 msgs[1].len = 1;
3635 res = i2c_transfer(adapter, msgs, 2);
3636 if (res != 2) {
3637 pr_err("%s: error reading adv7520\n", __func__);
3638 goto ldo8_disable;
3639 }
3640
3641 /* i2c write back */
3642 wBuff[0] = 0x41;
3643 wBuff[1] = rBuff[0] | 0x40;
3644
3645 msgs[0].addr = ADV7520_I2C_ADDR;
3646 msgs[0].flags = 0;
3647 msgs[0].buf = (unsigned char *) wBuff;
3648 msgs[0].len = 2;
3649
3650 res = i2c_transfer(adapter, msgs, 1);
3651 if (res != 1) {
3652 pr_err("%s: error writing adv7520\n", __func__);
3653 goto ldo8_disable;
3654 }
3655
3656 /* for successful fixup, we release the i2c adapter */
3657 /* but leave ldo8 on so that the adv7520 is not repowered */
3658 i2c_put_adapter(adapter);
3659 pr_info("%s: fluid i2c address conflict resolved\n", __func__);
3660 }
3661 return 0;
3662
3663ldo8_disable:
Justin Paupore3f40f342011-08-10 18:52:16 -07003664 hdmi_core_power(0, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003665adapter_put:
3666 i2c_put_adapter(adapter);
3667 return rc;
3668}
3669fs_initcall_sync(fluid_i2c_address_fixup);
3670#endif
3671
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003672static bool hdmi_check_hdcp_hw_support(void)
3673{
3674 if (machine_is_msm7x30_fluid())
3675 return false;
3676 else
3677 return true;
3678}
3679
3680static int dtv_panel_power(int on)
3681{
3682 int flag_on = !!on;
3683 static int dtv_power_save_on;
3684 int rc;
3685
3686 if (dtv_power_save_on == flag_on)
3687 return 0;
3688
3689 dtv_power_save_on = flag_on;
3690 pr_info("%s: %d\n", __func__, on);
3691
3692#ifdef HDMI_RESET
3693 if (on) {
3694 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
3695 rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
3696 if (rc) {
3697 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
3698 __func__, dtv_reset_gpio, rc);
3699 return rc;
3700 }
3701
3702 /* bring reset line low to hold reset*/
3703 gpio_set_value(37, 0);
3704 }
3705#endif
3706
3707 if (on) {
3708 rc = msm_gpios_enable(dtv_panel_gpios,
3709 ARRAY_SIZE(dtv_panel_gpios));
3710 if (rc < 0) {
3711 printk(KERN_ERR "%s: gpio enable failed: %d\n",
3712 __func__, rc);
3713 return rc;
3714 }
3715 } else {
3716 rc = msm_gpios_disable(dtv_panel_gpios,
3717 ARRAY_SIZE(dtv_panel_gpios));
3718 if (rc < 0) {
3719 printk(KERN_ERR "%s: gpio disable failed: %d\n",
3720 __func__, rc);
3721 return rc;
3722 }
3723 }
3724
3725 mdelay(5); /* ensure power is stable */
3726
3727#ifdef HDMI_RESET
3728 if (on) {
3729 gpio_set_value(37, 1); /* bring reset line high */
3730 mdelay(10); /* 10 msec before IO can be accessed */
3731 }
3732#endif
3733
3734 return rc;
3735}
3736
3737static struct lcdc_platform_data dtv_pdata = {
3738 .lcdc_power_save = dtv_panel_power,
3739};
3740
3741static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3742 .inject_rx_on_wakeup = 1,
3743 .rx_to_inject = 0xFD,
3744};
3745
3746static struct resource msm_fb_resources[] = {
3747 {
3748 .flags = IORESOURCE_DMA,
3749 }
3750};
3751
3752static int msm_fb_detect_panel(const char *name)
3753{
3754 if (machine_is_msm7x30_fluid()) {
3755 if (!strcmp(name, "lcdc_sharp_wvga_pt"))
3756 return 0;
3757 } else {
3758 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
3759 return -EPERM;
3760 else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20))
3761 return 0;
3762 else if (!strcmp(name, "mddi_orise"))
3763 return -EPERM;
3764 else if (!strcmp(name, "mddi_quickvx"))
3765 return -EPERM;
3766 }
3767 return -ENODEV;
3768}
3769
3770static struct msm_fb_platform_data msm_fb_pdata = {
3771 .detect_client = msm_fb_detect_panel,
3772 .mddi_prescan = 1,
3773};
3774
3775static struct platform_device msm_fb_device = {
3776 .name = "msm_fb",
3777 .id = 0,
3778 .num_resources = ARRAY_SIZE(msm_fb_resources),
3779 .resource = msm_fb_resources,
3780 .dev = {
3781 .platform_data = &msm_fb_pdata,
3782 }
3783};
3784
3785static struct platform_device msm_migrate_pages_device = {
3786 .name = "msm_migrate_pages",
3787 .id = -1,
3788};
3789
3790static struct android_pmem_platform_data android_pmem_adsp_pdata = {
3791 .name = "pmem_adsp",
3792 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
3793 .cached = 0,
3794 .memory_type = MEMTYPE_EBI0,
3795};
3796
3797static struct android_pmem_platform_data android_pmem_audio_pdata = {
3798 .name = "pmem_audio",
3799 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
3800 .cached = 0,
3801 .memory_type = MEMTYPE_EBI0,
3802};
3803
3804static struct platform_device android_pmem_adsp_device = {
3805 .name = "android_pmem",
3806 .id = 2,
3807 .dev = { .platform_data = &android_pmem_adsp_pdata },
3808};
3809
3810static struct platform_device android_pmem_audio_device = {
3811 .name = "android_pmem",
3812 .id = 4,
3813 .dev = { .platform_data = &android_pmem_audio_pdata },
3814};
3815
3816#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3817 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
3818 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3819 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3820
3821#define QCE_SIZE 0x10000
3822#define QCE_0_BASE 0xA8400000
3823
3824#define QCE_HW_KEY_SUPPORT 1
3825#define QCE_SHA_HMAC_SUPPORT 0
3826#define QCE_SHARE_CE_RESOURCE 0
3827#define QCE_CE_SHARED 0
3828
3829static struct resource qcrypto_resources[] = {
3830 [0] = {
3831 .start = QCE_0_BASE,
3832 .end = QCE_0_BASE + QCE_SIZE - 1,
3833 .flags = IORESOURCE_MEM,
3834 },
3835 [1] = {
3836 .name = "crypto_channels",
3837 .start = DMOV_CE_IN_CHAN,
3838 .end = DMOV_CE_OUT_CHAN,
3839 .flags = IORESOURCE_DMA,
3840 },
3841 [2] = {
3842 .name = "crypto_crci_in",
3843 .start = DMOV_CE_IN_CRCI,
3844 .end = DMOV_CE_IN_CRCI,
3845 .flags = IORESOURCE_DMA,
3846 },
3847 [3] = {
3848 .name = "crypto_crci_out",
3849 .start = DMOV_CE_OUT_CRCI,
3850 .end = DMOV_CE_OUT_CRCI,
3851 .flags = IORESOURCE_DMA,
3852 },
3853 [4] = {
3854 .name = "crypto_crci_hash",
3855 .start = DMOV_CE_HASH_CRCI,
3856 .end = DMOV_CE_HASH_CRCI,
3857 .flags = IORESOURCE_DMA,
3858 },
3859};
3860
3861static struct resource qcedev_resources[] = {
3862 [0] = {
3863 .start = QCE_0_BASE,
3864 .end = QCE_0_BASE + QCE_SIZE - 1,
3865 .flags = IORESOURCE_MEM,
3866 },
3867 [1] = {
3868 .name = "crypto_channels",
3869 .start = DMOV_CE_IN_CHAN,
3870 .end = DMOV_CE_OUT_CHAN,
3871 .flags = IORESOURCE_DMA,
3872 },
3873 [2] = {
3874 .name = "crypto_crci_in",
3875 .start = DMOV_CE_IN_CRCI,
3876 .end = DMOV_CE_IN_CRCI,
3877 .flags = IORESOURCE_DMA,
3878 },
3879 [3] = {
3880 .name = "crypto_crci_out",
3881 .start = DMOV_CE_OUT_CRCI,
3882 .end = DMOV_CE_OUT_CRCI,
3883 .flags = IORESOURCE_DMA,
3884 },
3885 [4] = {
3886 .name = "crypto_crci_hash",
3887 .start = DMOV_CE_HASH_CRCI,
3888 .end = DMOV_CE_HASH_CRCI,
3889 .flags = IORESOURCE_DMA,
3890 },
3891};
3892
3893#endif
3894
3895#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3896 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
3897
3898static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
3899 .ce_shared = QCE_CE_SHARED,
3900 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
3901 .hw_key_support = QCE_HW_KEY_SUPPORT,
3902 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08003903 /* Bus Scaling declaration*/
3904 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003905};
3906
3907static struct platform_device qcrypto_device = {
3908 .name = "qcrypto",
3909 .id = 0,
3910 .num_resources = ARRAY_SIZE(qcrypto_resources),
3911 .resource = qcrypto_resources,
3912 .dev = {
3913 .coherent_dma_mask = DMA_BIT_MASK(32),
3914 .platform_data = &qcrypto_ce_hw_suppport,
3915 },
3916};
3917#endif
3918
3919#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3920 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3921
3922static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
3923 .ce_shared = QCE_CE_SHARED,
3924 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
3925 .hw_key_support = QCE_HW_KEY_SUPPORT,
3926 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08003927 /* Bus Scaling declaration*/
3928 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003929};
3930static struct platform_device qcedev_device = {
3931 .name = "qce",
3932 .id = 0,
3933 .num_resources = ARRAY_SIZE(qcedev_resources),
3934 .resource = qcedev_resources,
3935 .dev = {
3936 .coherent_dma_mask = DMA_BIT_MASK(32),
3937 .platform_data = &qcedev_ce_hw_suppport,
3938 },
3939};
3940#endif
3941
3942static int mddi_toshiba_pmic_bl(int level)
3943{
3944 int ret = -EPERM;
3945
3946 ret = pmic_set_led_intensity(LED_LCD, level);
3947
3948 if (ret)
3949 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
3950 __func__);
3951 return ret;
3952}
3953
3954static struct msm_panel_common_pdata mddi_toshiba_pdata = {
3955 .pmic_backlight = mddi_toshiba_pmic_bl,
3956};
3957
3958static struct platform_device mddi_toshiba_device = {
3959 .name = "mddi_toshiba",
3960 .id = 0,
3961 .dev = {
3962 .platform_data = &mddi_toshiba_pdata,
3963 }
3964};
3965
3966static unsigned wega_reset_gpio =
3967 GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3968
3969static struct msm_gpio fluid_vee_reset_gpio[] = {
3970 { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
3971};
3972
3973static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1;
3974static unsigned char quickvx_ldo_enabled;
3975
3976static unsigned quickvx_vlp_gpio =
3977 GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3978
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303979static struct pm8xxx_gpio_init_info pmic_quickvx_clk_gpio = {
3980 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_QUICKVX_CLK),
3981 {
3982 .direction = PM_GPIO_DIR_OUT,
3983 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3984 .output_value = 1,
3985 .pull = PM_GPIO_PULL_NO,
3986 .vin_sel = PM8058_GPIO_VIN_S3,
3987 .out_strength = PM_GPIO_STRENGTH_HIGH,
3988 .function = PM_GPIO_FUNC_2,
3989 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003990};
3991
Justin Paupore3f40f342011-08-10 18:52:16 -07003992static struct regulator *mddi_ldo20;
3993static struct regulator *mddi_ldo12;
3994static struct regulator *mddi_ldo16;
3995static struct regulator *mddi_ldo6;
3996static struct regulator *mddi_lcd;
3997
3998static int display_common_init(void)
3999{
4000 struct regulator_bulk_data regs[5] = {
4001 { .supply = "ldo20", /* voltage set in display_common_power */},
4002 { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 },
4003 { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 },
4004 { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 },
4005 { .supply = NULL, /* mddi_lcd, initialized below */ },
4006 };
4007
4008 int rc = 0;
4009
4010 if (machine_is_msm7x30_fluid()) {
4011 /* lcd: LDO8 @1.8V */
4012 regs[4].supply = "ldo8";
4013 regs[4].min_uV = 1800000;
4014 regs[4].max_uV = 1800000;
4015 } else {
4016 /* lcd: LDO15 @3.1V */
4017 regs[4].supply = "ldo15";
4018 regs[4].min_uV = 3100000;
4019 regs[4].max_uV = 3100000;
4020 }
4021
4022 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4023 if (rc) {
4024 pr_err("%s: regulator_bulk_get failed: %d\n",
4025 __func__, rc);
4026 goto bail;
4027 }
4028
4029 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4030 if (rc) {
4031 pr_err("%s: regulator_bulk_set_voltage failed: %d\n",
4032 __func__, rc);
4033 goto put_regs;
4034 }
4035
4036 mddi_ldo20 = regs[0].consumer;
4037 mddi_ldo12 = regs[1].consumer;
4038 mddi_ldo6 = regs[2].consumer;
4039 mddi_ldo16 = regs[3].consumer;
4040 mddi_lcd = regs[4].consumer;
4041
4042 return rc;
4043
4044put_regs:
4045 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4046bail:
4047 return rc;
4048}
4049
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004050static int display_common_power(int on)
4051{
4052 int rc = 0, flag_on = !!on;
4053 static int display_common_power_save_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004054 static bool display_regs_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004055
4056 if (display_common_power_save_on == flag_on)
4057 return 0;
4058
4059 display_common_power_save_on = flag_on;
4060
Justin Paupore3f40f342011-08-10 18:52:16 -07004061 if (unlikely(!display_regs_initialized)) {
4062 rc = display_common_init();
4063 if (rc) {
4064 pr_err("%s: regulator init failed: %d\n",
4065 __func__, rc);
4066 return rc;
4067 }
4068 display_regs_initialized = true;
4069 }
4070
4071
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004072 if (on) {
4073 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
4074 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
4075 if (rc) {
4076 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4077 __func__, wega_reset_gpio, rc);
4078 return rc;
4079 }
4080
4081 /* bring reset line low to hold reset*/
4082 gpio_set_value(180, 0);
4083
4084 if (quickvx_mddi_client) {
4085 /* QuickVX chip -- VLP pin -- gpio 97 */
4086 rc = gpio_tlmm_config(quickvx_vlp_gpio,
4087 GPIO_CFG_ENABLE);
4088 if (rc) {
4089 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4090 __func__, quickvx_vlp_gpio, rc);
4091 return rc;
4092 }
4093
4094 /* bring QuickVX VLP line low */
4095 gpio_set_value(97, 0);
4096
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304097 rc = pm8xxx_gpio_config(pmic_quickvx_clk_gpio.gpio,
4098 &pmic_quickvx_clk_gpio.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004099 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304100 pr_err("%s: pm8xxx_gpio_config(%#x)=%d\n",
4101 __func__, pmic_quickvx_clk_gpio.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004102 rc);
4103 return rc;
4104 }
4105
4106 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4107 PMIC_GPIO_QUICKVX_CLK), 0);
4108 }
4109 }
4110
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004111 if (quickvx_mddi_client)
Justin Paupore3f40f342011-08-10 18:52:16 -07004112 rc = regulator_set_voltage(mddi_ldo20, 1800000, 1800000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004113 else
Justin Paupore3f40f342011-08-10 18:52:16 -07004114 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000);
4115
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004116 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004117 pr_err("%s: could not set voltage for ldo20: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004118 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07004119 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004120 }
4121
4122 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004123 rc = regulator_enable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004124 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004125 pr_err("%s: LDO20 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004126 __func__, rc);
4127 return rc;
4128 }
4129
Justin Paupore3f40f342011-08-10 18:52:16 -07004130 rc = regulator_enable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004131 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004132 pr_err("%s: LDO12 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004133 __func__, rc);
4134 return rc;
4135 }
4136
4137 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004138 rc = regulator_enable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004139 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004140 pr_err("%s: LDO16 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004141 __func__, rc);
4142 return rc;
4143 }
4144 }
4145
Justin Paupore3f40f342011-08-10 18:52:16 -07004146 if (quickvx_ldo_enabled) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004147 /* Disable LDO6 during display ON */
Justin Paupore3f40f342011-08-10 18:52:16 -07004148 rc = regulator_disable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004149 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004150 pr_err("%s: LDO6 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004151 __func__, rc);
4152 return rc;
4153 }
4154 quickvx_ldo_enabled = 0;
4155 }
4156
Justin Paupore3f40f342011-08-10 18:52:16 -07004157 rc = regulator_enable(mddi_lcd);
4158 if (rc) {
4159 pr_err("%s: LCD regulator enable failed (%d)\n",
4160 __func__, rc);
4161 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004162 }
4163
4164 mdelay(5); /* ensure power is stable */
4165
4166 if (machine_is_msm7x30_fluid()) {
4167 rc = msm_gpios_request_enable(fluid_vee_reset_gpio,
4168 ARRAY_SIZE(fluid_vee_reset_gpio));
4169 if (rc)
4170 pr_err("%s gpio_request_enable failed rc=%d\n",
4171 __func__, rc);
4172 else {
4173 /* assert vee reset_n */
4174 gpio_set_value(20, 1);
4175 gpio_set_value(20, 0);
4176 mdelay(1);
4177 gpio_set_value(20, 1);
4178 }
4179 }
4180
4181 gpio_set_value(180, 1); /* bring reset line high */
4182 mdelay(10); /* 10 msec before IO can be accessed */
4183
4184 if (quickvx_mddi_client) {
4185 gpio_set_value(97, 1);
4186 msleep(2);
4187 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4188 PMIC_GPIO_QUICKVX_CLK), 1);
4189 msleep(2);
4190 }
4191
4192 rc = pmapp_display_clock_config(1);
4193 if (rc) {
4194 pr_err("%s pmapp_display_clock_config rc=%d\n",
4195 __func__, rc);
4196 return rc;
4197 }
4198
4199 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004200 rc = regulator_disable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004201 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004202 pr_err("%s: LDO20 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004203 __func__, rc);
4204 return rc;
4205 }
4206
4207
4208 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004209 rc = regulator_disable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004210 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004211 pr_err("%s: LDO16 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004212 __func__, rc);
4213 return rc;
4214 }
4215 }
4216
4217 if (quickvx_mddi_client && !quickvx_ldo_enabled) {
4218 /* Enable LDO6 during display OFF for
4219 Quicklogic chip to sleep with data retention */
Justin Paupore3f40f342011-08-10 18:52:16 -07004220 rc = regulator_enable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004221 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004222 pr_err("%s: LDO6 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004223 __func__, rc);
4224 return rc;
4225 }
4226 quickvx_ldo_enabled = 1;
4227 }
4228
4229 gpio_set_value(180, 0); /* bring reset line low */
4230
4231 if (quickvx_mddi_client) {
4232 gpio_set_value(97, 0);
4233 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4234 PMIC_GPIO_QUICKVX_CLK), 0);
4235 }
4236
Justin Paupore3f40f342011-08-10 18:52:16 -07004237 rc = regulator_disable(mddi_lcd);
4238 if (rc) {
4239 pr_err("%s: LCD regulator disable failed (%d)\n",
4240 __func__, rc);
4241 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004242 }
4243
4244 mdelay(5); /* ensure power is stable */
4245
Justin Paupore3f40f342011-08-10 18:52:16 -07004246 rc = regulator_disable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004247 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004248 pr_err("%s: LDO12 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004249 __func__, rc);
4250 return rc;
4251 }
4252
4253 if (machine_is_msm7x30_fluid()) {
4254 msm_gpios_disable_free(fluid_vee_reset_gpio,
4255 ARRAY_SIZE(fluid_vee_reset_gpio));
4256 }
4257
4258 rc = pmapp_display_clock_config(0);
4259 if (rc) {
4260 pr_err("%s pmapp_display_clock_config rc=%d\n",
4261 __func__, rc);
4262 return rc;
4263 }
4264 }
4265
4266 return rc;
4267}
4268
4269static int msm_fb_mddi_sel_clk(u32 *clk_rate)
4270{
4271 *clk_rate *= 2;
4272 return 0;
4273}
4274
4275static int msm_fb_mddi_client_power(u32 client_id)
4276{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004277 printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
4278 /* Check if it is Quicklogic client */
4279 if (client_id == 0xc5835800) {
4280 printk(KERN_NOTICE "\n Quicklogic MDDI client");
4281 other_mddi_client = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004282 } else {
4283 printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
4284 quickvx_mddi_client = 0;
4285 gpio_set_value(97, 0);
4286 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4287 PMIC_GPIO_QUICKVX_CLK), 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004288 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004289
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004290 return 0;
4291}
4292
4293static struct mddi_platform_data mddi_pdata = {
4294 .mddi_power_save = display_common_power,
4295 .mddi_sel_clk = msm_fb_mddi_sel_clk,
4296 .mddi_client_power = msm_fb_mddi_client_power,
4297};
4298
4299int mdp_core_clk_rate_table[] = {
4300 122880000,
4301 122880000,
Pradeep Jilagam3cc12f92011-07-26 22:25:18 +05304302 192000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004303 192000000,
4304};
4305
4306static struct msm_panel_common_pdata mdp_pdata = {
4307 .hw_revision_addr = 0xac001270,
4308 .gpio = 30,
4309 .mdp_core_clk_rate = 122880000,
4310 .mdp_core_clk_table = mdp_core_clk_rate_table,
4311 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07004312 .mdp_rev = MDP_REV_40,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004313};
4314
4315static int lcd_panel_spi_gpio_num[] = {
4316 45, /* spi_clk */
4317 46, /* spi_cs */
4318 47, /* spi_mosi */
4319 48, /* spi_miso */
4320 };
4321
4322static struct msm_gpio lcd_panel_gpios[] = {
4323/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
4324 * input. if there is a hardware revision; we should reassign this GPIO to a
4325 * new open line; and removing it will just ensure that this will be missed in
4326 * the future.
4327 { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
4328 */
4329 { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
4330 { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
4331 { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
4332 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4333 { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
4334 { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
4335 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4336#ifndef CONFIG_SPI_QSD
4337 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
4338 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
4339 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
4340 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
4341#endif
4342 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4343 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4344 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4345 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4346 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4347 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4348 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4349 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4350 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4351 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4352 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4353 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4354 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4355 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4356 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4357 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4358 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4359 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4360 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4361 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4362};
4363
4364static struct msm_gpio lcd_sharp_panel_gpios[] = {
4365 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4366 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4367 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4368 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4369 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4370 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4371 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4372 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4373 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4374 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4375 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4376 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4377 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4378 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4379 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4380 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4381 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4382 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4383 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4384 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4385 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4386 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4387};
4388
4389static int lcdc_toshiba_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_panel_gpios,
4403 ARRAY_SIZE(lcd_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_panel_gpios;
4410 for (i = 0; i < ARRAY_SIZE(lcd_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_sharp_panel_power(int on)
4421{
4422 int rc, i;
4423 struct msm_gpio *gp;
4424
4425 rc = display_common_power(on);
4426 if (rc < 0) {
4427 printk(KERN_ERR "%s display_common_power failed: %d\n",
4428 __func__, rc);
4429 return rc;
4430 }
4431
4432 if (on) {
4433 rc = msm_gpios_enable(lcd_sharp_panel_gpios,
4434 ARRAY_SIZE(lcd_sharp_panel_gpios));
4435 if (rc < 0) {
4436 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4437 __func__, rc);
4438 }
4439 } else { /* off */
4440 gp = lcd_sharp_panel_gpios;
4441 for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) {
4442 /* ouput low */
4443 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4444 gp++;
4445 }
4446 }
4447
4448 return rc;
4449}
4450
4451static int lcdc_panel_power(int on)
4452{
4453 int flag_on = !!on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004454 static int lcdc_power_save_on, lcdc_power_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004455
4456 if (lcdc_power_save_on == flag_on)
4457 return 0;
4458
4459 lcdc_power_save_on = flag_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004460
4461 if (unlikely(!lcdc_power_initialized)) {
4462 quickvx_mddi_client = 0;
4463 display_common_init();
4464 lcdc_power_initialized = 1;
4465 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004466
4467 if (machine_is_msm7x30_fluid())
4468 return lcdc_sharp_panel_power(on);
4469 else
4470 return lcdc_toshiba_panel_power(on);
4471}
4472
4473static struct lcdc_platform_data lcdc_pdata = {
4474 .lcdc_power_save = lcdc_panel_power,
4475};
4476
Justin Paupore3f40f342011-08-10 18:52:16 -07004477static struct regulator *atv_s4, *atv_ldo9;
4478
4479static int __init atv_dac_power_init(void)
4480{
4481 int rc;
4482 struct regulator_bulk_data regs[] = {
4483 { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 },
4484 { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 },
4485 };
4486
4487 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4488
4489 if (rc) {
4490 pr_err("%s: could not get regulators: %d\n", __func__, rc);
4491 goto bail;
4492 }
4493
4494 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4495
4496 if (rc) {
4497 pr_err("%s: could not set voltages: %d\n", __func__, rc);
4498 goto reg_free;
4499 }
4500
4501 atv_s4 = regs[0].consumer;
4502 atv_ldo9 = regs[1].consumer;
4503
4504reg_free:
4505 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4506bail:
4507 return rc;
4508}
4509
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004510static int atv_dac_power(int on)
4511{
4512 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004513
4514 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004515 rc = regulator_enable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004516 if (rc) {
4517 pr_err("%s: s4 vreg enable failed (%d)\n",
4518 __func__, rc);
4519 return rc;
4520 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004521 rc = regulator_enable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004522 if (rc) {
4523 pr_err("%s: ldo9 vreg enable failed (%d)\n",
4524 __func__, rc);
4525 return rc;
4526 }
4527 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004528 rc = regulator_disable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004529 if (rc) {
4530 pr_err("%s: ldo9 vreg disable failed (%d)\n",
4531 __func__, rc);
4532 return rc;
4533 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004534 rc = regulator_disable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004535 if (rc) {
4536 pr_err("%s: s4 vreg disable failed (%d)\n",
4537 __func__, rc);
4538 return rc;
4539 }
4540 }
4541 return rc;
4542}
4543
4544static struct tvenc_platform_data atv_pdata = {
4545 .poll = 1,
4546 .pm_vid_en = atv_dac_power,
4547};
4548
4549static void __init msm_fb_add_devices(void)
4550{
4551 msm_fb_register_device("mdp", &mdp_pdata);
4552 msm_fb_register_device("pmdh", &mddi_pdata);
4553 msm_fb_register_device("lcdc", &lcdc_pdata);
4554 msm_fb_register_device("dtv", &dtv_pdata);
4555 msm_fb_register_device("tvenc", &atv_pdata);
4556#ifdef CONFIG_FB_MSM_TVOUT
4557 msm_fb_register_device("tvout_device", NULL);
4558#endif
4559}
4560
4561static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
4562 .gpio_num = lcd_panel_spi_gpio_num,
4563};
4564
4565static struct platform_device lcdc_toshiba_panel_device = {
4566 .name = "lcdc_toshiba_wvga",
4567 .id = 0,
4568 .dev = {
4569 .platform_data = &lcdc_toshiba_panel_data,
4570 }
4571};
4572
4573#if defined(CONFIG_MARIMBA_CORE) && \
4574 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4575static struct platform_device msm_bt_power_device = {
4576 .name = "bt_power",
4577 .id = -1
4578};
4579
4580enum {
4581 BT_RFR,
4582 BT_CTS,
4583 BT_RX,
4584 BT_TX,
4585};
4586
4587static struct msm_gpio bt_config_power_on[] = {
4588 { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4589 "UART1DM_RFR" },
4590 { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4591 "UART1DM_CTS" },
4592 { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4593 "UART1DM_Rx" },
4594 { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4595 "UART1DM_Tx" }
4596};
4597
4598static struct msm_gpio bt_config_power_off[] = {
4599 { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4600 "UART1DM_RFR" },
4601 { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4602 "UART1DM_CTS" },
4603 { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4604 "UART1DM_Rx" },
4605 { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4606 "UART1DM_Tx" }
4607};
4608
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004609static u8 bahama_version;
4610
Justin Paupore3f40f342011-08-10 18:52:16 -07004611static struct regulator_bulk_data regs_bt_marimba[] = {
4612 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4613 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
4614 { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304615 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004616};
4617
4618static struct regulator_bulk_data regs_bt_bahama_v1[] = {
4619 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4620 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
4621 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304622 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004623};
4624
4625static struct regulator_bulk_data regs_bt_bahama_v2[] = {
4626 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4627 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304628 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004629};
4630
4631static struct regulator_bulk_data *regs_bt;
4632static int regs_bt_count;
4633
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004634static int marimba_bt(int on)
4635{
4636 int rc;
4637 int i;
4638 struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
4639
4640 struct marimba_config_register {
4641 u8 reg;
4642 u8 value;
4643 u8 mask;
4644 };
4645
4646 struct marimba_variant_register {
4647 const size_t size;
4648 const struct marimba_config_register *set;
4649 };
4650
4651 const struct marimba_config_register *p;
4652
4653 u8 version;
4654
4655 const struct marimba_config_register v10_bt_on[] = {
4656 { 0xE5, 0x0B, 0x0F },
4657 { 0x05, 0x02, 0x07 },
4658 { 0x06, 0x88, 0xFF },
4659 { 0xE7, 0x21, 0x21 },
4660 { 0xE3, 0x38, 0xFF },
4661 { 0xE4, 0x06, 0xFF },
4662 };
4663
4664 const struct marimba_config_register v10_bt_off[] = {
4665 { 0xE5, 0x0B, 0x0F },
4666 { 0x05, 0x08, 0x0F },
4667 { 0x06, 0x88, 0xFF },
4668 { 0xE7, 0x00, 0x21 },
4669 { 0xE3, 0x00, 0xFF },
4670 { 0xE4, 0x00, 0xFF },
4671 };
4672
4673 const struct marimba_config_register v201_bt_on[] = {
4674 { 0x05, 0x08, 0x07 },
4675 { 0x06, 0x88, 0xFF },
4676 { 0xE7, 0x21, 0x21 },
4677 { 0xE3, 0x38, 0xFF },
4678 { 0xE4, 0x06, 0xFF },
4679 };
4680
4681 const struct marimba_config_register v201_bt_off[] = {
4682 { 0x05, 0x08, 0x07 },
4683 { 0x06, 0x88, 0xFF },
4684 { 0xE7, 0x00, 0x21 },
4685 { 0xE3, 0x00, 0xFF },
4686 { 0xE4, 0x00, 0xFF },
4687 };
4688
4689 const struct marimba_config_register v210_bt_on[] = {
4690 { 0xE9, 0x01, 0x01 },
4691 { 0x06, 0x88, 0xFF },
4692 { 0xE7, 0x21, 0x21 },
4693 { 0xE3, 0x38, 0xFF },
4694 { 0xE4, 0x06, 0xFF },
4695 };
4696
4697 const struct marimba_config_register v210_bt_off[] = {
4698 { 0x06, 0x88, 0xFF },
4699 { 0xE7, 0x00, 0x21 },
4700 { 0xE9, 0x00, 0x01 },
4701 { 0xE3, 0x00, 0xFF },
4702 { 0xE4, 0x00, 0xFF },
4703 };
4704
4705 const struct marimba_variant_register bt_marimba[2][4] = {
4706 {
4707 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4708 { 0, NULL },
4709 { ARRAY_SIZE(v201_bt_off), v201_bt_off },
4710 { ARRAY_SIZE(v210_bt_off), v210_bt_off }
4711 },
4712 {
4713 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4714 { 0, NULL },
4715 { ARRAY_SIZE(v201_bt_on), v201_bt_on },
4716 { ARRAY_SIZE(v210_bt_on), v210_bt_on }
4717 }
4718 };
4719
4720 on = on ? 1 : 0;
4721
4722 rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F);
4723 if (rc < 0) {
4724 printk(KERN_ERR
4725 "%s: version read failed: %d\n",
4726 __func__, rc);
4727 return rc;
4728 }
4729
4730 if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
4731 (bt_marimba[on][version].size == 0)) {
4732 printk(KERN_ERR
4733 "%s: unsupported version\n",
4734 __func__);
4735 return -EIO;
4736 }
4737
4738 p = bt_marimba[on][version].set;
4739
4740 printk(KERN_INFO "%s: found version %d\n", __func__, version);
4741
4742 for (i = 0; i < bt_marimba[on][version].size; i++) {
4743 u8 value = (p+i)->value;
4744 rc = marimba_write_bit_mask(&config,
4745 (p+i)->reg,
4746 &value,
4747 sizeof((p+i)->value),
4748 (p+i)->mask);
4749 if (rc < 0) {
4750 printk(KERN_ERR
4751 "%s: reg %d write failed: %d\n",
4752 __func__, (p+i)->reg, rc);
4753 return rc;
4754 }
4755 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
4756 __func__, (p+i)->reg,
4757 value, (p+i)->mask);
4758 }
4759 return 0;
4760}
4761
4762static int bahama_bt(int on)
4763{
4764 int rc;
4765 int i;
4766 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
4767
4768 struct bahama_variant_register {
4769 const size_t size;
4770 const struct bahama_config_register *set;
4771 };
4772
4773 const struct bahama_config_register *p;
4774
4775
4776 const struct bahama_config_register v10_bt_on[] = {
4777 { 0xE9, 0x00, 0xFF },
4778 { 0xF4, 0x80, 0xFF },
4779 { 0xF0, 0x06, 0xFF },
4780 { 0xE4, 0x00, 0xFF },
4781 { 0xE5, 0x00, 0x0F },
4782#ifdef CONFIG_WLAN
4783 { 0xE6, 0x38, 0x7F },
4784 { 0xE7, 0x06, 0xFF },
4785#endif
4786 { 0x11, 0x13, 0xFF },
4787 { 0xE9, 0x21, 0xFF },
4788 { 0x01, 0x0C, 0x1F },
4789 { 0x01, 0x08, 0x1F },
4790 };
4791
4792 const struct bahama_config_register v20_bt_on_fm_off[] = {
4793 { 0x11, 0x0C, 0xFF },
4794 { 0x13, 0x01, 0xFF },
4795 { 0xF4, 0x80, 0xFF },
4796 { 0xF0, 0x00, 0xFF },
4797 { 0xE9, 0x00, 0xFF },
4798#ifdef CONFIG_WLAN
4799 { 0x81, 0x00, 0xFF },
4800 { 0x82, 0x00, 0xFF },
4801 { 0xE6, 0x38, 0x7F },
4802 { 0xE7, 0x06, 0xFF },
4803#endif
4804 { 0xE9, 0x21, 0xFF }
4805 };
4806
4807 const struct bahama_config_register v20_bt_on_fm_on[] = {
4808 { 0x11, 0x0C, 0xFF },
4809 { 0x13, 0x01, 0xFF },
4810 { 0xF4, 0x86, 0xFF },
4811 { 0xF0, 0x06, 0xFF },
4812 { 0xE9, 0x00, 0xFF },
4813#ifdef CONFIG_WLAN
4814 { 0x81, 0x00, 0xFF },
4815 { 0x82, 0x00, 0xFF },
4816 { 0xE6, 0x38, 0x7F },
4817 { 0xE7, 0x06, 0xFF },
4818#endif
4819 { 0xE9, 0x21, 0xFF }
4820 };
4821
4822 const struct bahama_config_register v10_bt_off[] = {
4823 { 0xE9, 0x00, 0xFF },
4824 };
4825
4826 const struct bahama_config_register v20_bt_off_fm_off[] = {
4827 { 0xF4, 0x84, 0xFF },
4828 { 0xF0, 0x04, 0xFF },
4829 { 0xE9, 0x00, 0xFF }
4830 };
4831
4832 const struct bahama_config_register v20_bt_off_fm_on[] = {
4833 { 0xF4, 0x86, 0xFF },
4834 { 0xF0, 0x06, 0xFF },
4835 { 0xE9, 0x00, 0xFF }
4836 };
4837
4838 const struct bahama_variant_register bt_bahama[2][3] = {
4839 {
4840 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4841 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
4842 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
4843 },
4844 {
4845 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4846 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
4847 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
4848 }
4849 };
4850
4851 u8 offset = 0; /* index into bahama configs */
4852
4853 on = on ? 1 : 0;
4854
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004855
4856 if (bahama_version == VER_2_0) {
4857 if (marimba_get_fm_status(&config))
4858 offset = 0x01;
4859 }
4860
4861 p = bt_bahama[on][bahama_version + offset].set;
4862
4863 dev_info(&msm_bt_power_device.dev,
4864 "%s: found version %d\n", __func__, bahama_version);
4865
4866 for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
4867 u8 value = (p+i)->value;
4868 rc = marimba_write_bit_mask(&config,
4869 (p+i)->reg,
4870 &value,
4871 sizeof((p+i)->value),
4872 (p+i)->mask);
4873 if (rc < 0) {
4874 dev_err(&msm_bt_power_device.dev,
4875 "%s: reg %d write failed: %d\n",
4876 __func__, (p+i)->reg, rc);
4877 return rc;
4878 }
4879 dev_info(&msm_bt_power_device.dev,
4880 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
4881 __func__, (p+i)->reg,
4882 value, (p+i)->mask);
4883 }
4884 /* Update BT status */
4885 if (on)
4886 marimba_set_bt_status(&config, true);
4887 else
4888 marimba_set_bt_status(&config, false);
4889
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004890 return 0;
4891}
4892
Justin Paupore3f40f342011-08-10 18:52:16 -07004893static int bluetooth_regs_init(int bahama_not_marimba)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004894{
Justin Paupore3f40f342011-08-10 18:52:16 -07004895 int rc = 0;
4896 struct device *const dev = &msm_bt_power_device.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004897
4898 if (bahama_not_marimba) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004899 bahama_version = read_bahama_ver();
4900
4901 switch (bahama_version) {
4902 case VER_1_0:
4903 regs_bt = regs_bt_bahama_v1;
4904 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1);
4905 break;
4906 case VER_2_0:
4907 regs_bt = regs_bt_bahama_v2;
4908 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2);
4909 break;
4910 case VER_UNSUPPORTED:
4911 default:
4912 dev_err(dev,
4913 "%s: i2c failure or unsupported version: %d\n",
4914 __func__, bahama_version);
4915 rc = -EIO;
4916 goto out;
4917 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004918 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004919 regs_bt = regs_bt_marimba;
4920 regs_bt_count = ARRAY_SIZE(regs_bt_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004921 }
4922
Justin Paupore3f40f342011-08-10 18:52:16 -07004923 rc = regulator_bulk_get(&msm_bt_power_device.dev,
4924 regs_bt_count, regs_bt);
4925 if (rc) {
4926 dev_err(dev, "%s: could not get regulators: %d\n",
4927 __func__, rc);
4928 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004929 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004930
4931 rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt);
4932 if (rc) {
4933 dev_err(dev, "%s: could not set voltages: %d\n",
4934 __func__, rc);
4935 goto reg_free;
4936 }
4937
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004938 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07004939
4940reg_free:
4941 regulator_bulk_free(regs_bt_count, regs_bt);
4942out:
4943 regs_bt_count = 0;
4944 regs_bt = NULL;
4945 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004946}
4947
4948static int bluetooth_power(int on)
4949{
4950 int rc;
4951 const char *id = "BTPW";
4952
4953 int bahama_not_marimba = bahama_present();
4954
4955 if (bahama_not_marimba == -1) {
4956 printk(KERN_WARNING "%s: bahama_present: %d\n",
4957 __func__, bahama_not_marimba);
4958 return -ENODEV;
4959 }
4960
Justin Paupore3f40f342011-08-10 18:52:16 -07004961 if (unlikely(regs_bt_count == 0)) {
4962 rc = bluetooth_regs_init(bahama_not_marimba);
4963 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004964 return rc;
Justin Paupore3f40f342011-08-10 18:52:16 -07004965 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004966
Justin Paupore3f40f342011-08-10 18:52:16 -07004967 if (on) {
4968 rc = regulator_bulk_enable(regs_bt_count, regs_bt);
4969 if (rc)
4970 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004971
4972 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
4973 PMAPP_CLOCK_VOTE_ON);
4974 if (rc < 0)
4975 return -EIO;
4976
4977 if (machine_is_msm8x55_svlte_surf() ||
4978 machine_is_msm8x55_svlte_ffa()) {
4979 rc = marimba_gpio_config(1);
4980 if (rc < 0)
4981 return -EIO;
4982 }
4983
4984 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
4985 if (rc < 0)
4986 return -EIO;
4987
4988 msleep(10);
4989
4990 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
4991 PMAPP_CLOCK_VOTE_PIN_CTRL);
4992 if (rc < 0)
4993 return -EIO;
4994
4995 if (machine_is_msm8x55_svlte_surf() ||
4996 machine_is_msm8x55_svlte_ffa()) {
4997 rc = marimba_gpio_config(0);
4998 if (rc < 0)
4999 return -EIO;
5000 }
5001
5002 rc = msm_gpios_enable(bt_config_power_on,
5003 ARRAY_SIZE(bt_config_power_on));
5004
5005 if (rc < 0)
5006 return rc;
5007
5008 } else {
5009 rc = msm_gpios_enable(bt_config_power_off,
5010 ARRAY_SIZE(bt_config_power_off));
5011 if (rc < 0)
5012 return rc;
5013
5014 /* check for initial RFKILL block (power off) */
5015 if (platform_get_drvdata(&msm_bt_power_device) == NULL)
5016 goto out;
5017
5018 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5019 if (rc < 0)
5020 return -EIO;
5021
5022 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5023 PMAPP_CLOCK_VOTE_OFF);
5024 if (rc < 0)
5025 return -EIO;
5026
Justin Paupore3f40f342011-08-10 18:52:16 -07005027 rc = regulator_bulk_disable(regs_bt_count, regs_bt);
5028 if (rc)
5029 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005030
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005031 }
5032
5033out:
5034 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
5035
5036 return 0;
5037}
5038
5039static void __init bt_power_init(void)
5040{
Justin Paupore3f40f342011-08-10 18:52:16 -07005041 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005042}
5043#else
5044#define bt_power_init(x) do {} while (0)
5045#endif
5046
5047static struct msm_psy_batt_pdata msm_psy_batt_data = {
5048 .voltage_min_design = 2800,
5049 .voltage_max_design = 4300,
5050 .avail_chg_sources = AC_CHG | USB_CHG ,
5051 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
5052};
5053
5054static struct platform_device msm_batt_device = {
5055 .name = "msm-battery",
5056 .id = -1,
5057 .dev.platform_data = &msm_psy_batt_data,
5058};
5059
5060static char *msm_adc_fluid_device_names[] = {
5061 "LTC_ADC1",
5062 "LTC_ADC2",
5063 "LTC_ADC3",
5064};
5065
5066static char *msm_adc_surf_device_names[] = {
5067 "XO_ADC",
5068};
5069
5070static struct msm_adc_platform_data msm_adc_pdata;
5071
5072static struct platform_device msm_adc_device = {
5073 .name = "msm_adc",
5074 .id = -1,
5075 .dev = {
5076 .platform_data = &msm_adc_pdata,
5077 },
5078};
5079
5080#ifdef CONFIG_MSM_SDIO_AL
5081static struct msm_gpio mdm2ap_status = {
5082 GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5083 "mdm2ap_status"
5084};
5085
5086
5087static int configure_mdm2ap_status(int on)
5088{
5089 if (on)
5090 return msm_gpios_request_enable(&mdm2ap_status, 1);
5091 else {
5092 msm_gpios_disable_free(&mdm2ap_status, 1);
5093 return 0;
5094 }
5095}
5096
5097static int get_mdm2ap_status(void)
5098{
5099 return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
5100}
5101
5102static struct sdio_al_platform_data sdio_al_pdata = {
5103 .config_mdm2ap_status = configure_mdm2ap_status,
5104 .get_mdm2ap_status = get_mdm2ap_status,
5105 .allow_sdioc_version_major_2 = 1,
5106 .peer_sdioc_version_minor = 0x0001,
5107 .peer_sdioc_version_major = 0x0003,
5108 .peer_sdioc_boot_version_minor = 0x0001,
5109 .peer_sdioc_boot_version_major = 0x0003,
5110};
5111
5112struct platform_device msm_device_sdio_al = {
5113 .name = "msm_sdio_al",
5114 .id = -1,
5115 .dev = {
5116 .platform_data = &sdio_al_pdata,
5117 },
5118};
5119
5120#endif /* CONFIG_MSM_SDIO_AL */
5121
Daniel Walker8d747cd2010-02-25 11:37:43 -08005122static struct platform_device *devices[] __initdata = {
Daniel Walker90e37c52010-05-12 14:24:15 -07005123#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005124 &msm_device_uart2,
5125#endif
Justin Paupore637a25d2011-07-14 17:11:04 -07005126#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
5127 &msm_proccomm_regulator_dev,
5128#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005129 &asoc_msm_pcm,
5130 &asoc_msm_dai0,
5131 &asoc_msm_dai1,
5132#if defined (CONFIG_SND_MSM_MVS_DAI_SOC)
5133 &asoc_msm_mvs,
5134 &asoc_mvs_dai0,
5135 &asoc_mvs_dai1,
Daniel Walker90e37c52010-05-12 14:24:15 -07005136#endif
Niranjana Vishwanathapuraa8855e92010-10-06 13:52:10 -07005137 &msm_device_smd,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005138 &msm_device_dmov,
5139 &smc91x_device,
5140 &smsc911x_device,
5141 &msm_device_nand,
5142#ifdef CONFIG_USB_MSM_OTG_72K
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05305143 &msm_device_otg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005144#ifdef CONFIG_USB_GADGET
5145 &msm_device_gadget_peripheral,
5146#endif
5147#endif
5148#ifdef CONFIG_USB_G_ANDROID
5149 &android_usb_device,
5150#endif
5151 &qsd_device_spi,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305152
5153#ifdef CONFIG_MSM_SSBI
5154 &msm_device_ssbi_pmic1,
5155#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005156#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005157 &msm_device_ssbi7,
5158#endif
5159 &android_pmem_device,
5160 &msm_fb_device,
5161 &msm_migrate_pages_device,
5162 &mddi_toshiba_device,
5163 &lcdc_toshiba_panel_device,
5164#ifdef CONFIG_MSM_ROTATOR
5165 &msm_rotator_device,
5166#endif
5167 &lcdc_sharp_panel_device,
5168 &android_pmem_adsp_device,
5169 &android_pmem_audio_device,
5170 &msm_device_i2c,
5171 &msm_device_i2c_2,
5172 &msm_device_uart_dm1,
5173 &hs_device,
5174#ifdef CONFIG_MSM7KV2_AUDIO
5175 &msm_aictl_device,
5176 &msm_mi2s_device,
5177 &msm_lpa_device,
5178 &msm_aux_pcm_device,
5179#endif
5180 &msm_device_adspdec,
5181 &qup_device_i2c,
5182#if defined(CONFIG_MARIMBA_CORE) && \
5183 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5184 &msm_bt_power_device,
5185#endif
5186 &msm_kgsl_3d0,
5187 &msm_kgsl_2d0,
5188#ifdef CONFIG_MT9T013
5189 &msm_camera_sensor_mt9t013,
5190#endif
5191#ifdef CONFIG_MT9D112
5192 &msm_camera_sensor_mt9d112,
5193#endif
5194#ifdef CONFIG_WEBCAM_OV9726
5195 &msm_camera_sensor_ov9726,
5196#endif
5197#ifdef CONFIG_S5K3E2FX
5198 &msm_camera_sensor_s5k3e2fx,
5199#endif
5200#ifdef CONFIG_MT9P012
5201 &msm_camera_sensor_mt9p012,
5202#endif
5203#ifdef CONFIG_MT9E013
5204 &msm_camera_sensor_mt9e013,
5205#endif
5206#ifdef CONFIG_VX6953
5207 &msm_camera_sensor_vx6953,
5208#endif
5209#ifdef CONFIG_SN12M0PZ
5210 &msm_camera_sensor_sn12m0pz,
5211#endif
5212 &msm_device_vidc_720p,
5213#ifdef CONFIG_MSM_GEMINI
5214 &msm_gemini_device,
5215#endif
5216#ifdef CONFIG_MSM_VPE
5217 &msm_vpe_device,
5218#endif
5219#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5220 &msm_device_tsif,
5221#endif
5222#ifdef CONFIG_MSM_SDIO_AL
5223 &msm_device_sdio_al,
5224#endif
5225
5226#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5227 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5228 &qcrypto_device,
5229#endif
5230
5231#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5232 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5233 &qcedev_device,
5234#endif
5235
5236 &msm_batt_device,
5237 &msm_adc_device,
5238 &msm_ebi0_thermal,
5239 &msm_ebi1_thermal
5240};
5241
5242static struct msm_gpio msm_i2c_gpios_hw[] = {
5243 { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5244 { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5245};
5246
5247static struct msm_gpio msm_i2c_gpios_io[] = {
5248 { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5249 { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5250};
5251
5252static struct msm_gpio qup_i2c_gpios_io[] = {
5253 { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5254 { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5255};
5256static struct msm_gpio qup_i2c_gpios_hw[] = {
5257 { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5258 { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5259};
5260
5261static void
5262msm_i2c_gpio_config(int adap_id, int config_type)
5263{
5264 struct msm_gpio *msm_i2c_table;
5265
5266 /* Each adapter gets 2 lines from the table */
5267 if (adap_id > 0)
5268 return;
5269 if (config_type)
5270 msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
5271 else
5272 msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
5273 msm_gpios_enable(msm_i2c_table, 2);
5274}
5275/*This needs to be enabled only for OEMS*/
5276#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005277static struct regulator *qup_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005278#endif
5279static void
5280qup_i2c_gpio_config(int adap_id, int config_type)
5281{
5282 int rc = 0;
5283 struct msm_gpio *qup_i2c_table;
5284 /* Each adapter gets 2 lines from the table */
5285 if (adap_id != 4)
5286 return;
5287 if (config_type)
5288 qup_i2c_table = qup_i2c_gpios_hw;
5289 else
5290 qup_i2c_table = qup_i2c_gpios_io;
5291 rc = msm_gpios_enable(qup_i2c_table, 2);
5292 if (rc < 0)
5293 printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
5294 /*This needs to be enabled only for OEMS*/
5295#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005296 if (!IS_ERR_OR_NULL(qup_vreg)) {
5297 rc = regulator_enable(qup_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005298 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005299 pr_err("%s: regulator_enable failed: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005300 __func__, rc);
5301 }
5302 }
5303#endif
5304}
5305
5306static struct msm_i2c_platform_data msm_i2c_pdata = {
5307 .clk_freq = 100000,
5308 .pri_clk = 70,
5309 .pri_dat = 71,
5310 .rmutex = 1,
5311 .rsl_id = "D:I2C02000021",
5312 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5313};
5314
5315static void __init msm_device_i2c_init(void)
5316{
5317 if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
5318 pr_err("failed to request I2C gpios\n");
5319
5320 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
5321}
5322
5323static struct msm_i2c_platform_data msm_i2c_2_pdata = {
5324 .clk_freq = 100000,
5325 .rmutex = 1,
5326 .rsl_id = "D:I2C02000022",
5327 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5328};
5329
5330static void __init msm_device_i2c_2_init(void)
5331{
5332 msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
5333}
5334
5335static struct msm_i2c_platform_data qup_i2c_pdata = {
5336 .clk_freq = 384000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005337 .msm_i2c_config_gpio = qup_i2c_gpio_config,
5338};
5339
5340static void __init qup_device_i2c_init(void)
5341{
5342 if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
5343 pr_err("failed to request I2C gpios\n");
5344
5345 qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
5346 /*This needs to be enabled only for OEMS*/
5347#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005348 qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005349 if (IS_ERR(qup_vreg)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005350 dev_err(&qup_device_i2c.dev,
5351 "%s: regulator_get failed: %ld\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005352 __func__, PTR_ERR(qup_vreg));
5353 }
5354#endif
5355}
5356
5357#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005358static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = {
5359 .rsl_id = "D:CODEC_SSBI",
5360 .controller_type = MSM_SBI_CTRL_SSBI,
5361};
5362#endif
5363
Daniel Walker8d747cd2010-02-25 11:37:43 -08005364static void __init msm7x30_init_irq(void)
5365{
5366 msm_init_irq();
5367}
5368
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005369static struct msm_gpio msm_nand_ebi2_cfg_data[] = {
5370 {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
5371 {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
5372};
5373
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005374#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
5375 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
5376 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
5377 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
5378
5379struct sdcc_gpio {
5380 struct msm_gpio *cfg_data;
5381 uint32_t size;
5382 struct msm_gpio *sleep_cfg_data;
5383};
5384#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5385static struct msm_gpio sdc1_lvlshft_cfg_data[] = {
5386 {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
5387};
5388#endif
5389static struct msm_gpio sdc1_cfg_data[] = {
5390 {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
5391 {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
5392 {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
5393 {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
5394 {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
5395 {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
5396};
5397
5398static struct msm_gpio sdc2_cfg_data[] = {
5399 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
5400 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
5401 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
5402 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
5403 {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
5404 {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
5405
5406#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5407 {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
5408 {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
5409 {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
5410 {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
5411#endif
5412};
5413
5414static struct msm_gpio sdc3_cfg_data[] = {
5415 {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
5416 {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
5417 {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
5418 {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
5419 {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
5420 {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
5421};
5422
5423static struct msm_gpio sdc3_sleep_cfg_data[] = {
5424 {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5425 "sdc3_clk"},
5426 {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5427 "sdc3_cmd"},
5428 {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5429 "sdc3_dat_3"},
5430 {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5431 "sdc3_dat_2"},
5432 {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5433 "sdc3_dat_1"},
5434 {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5435 "sdc3_dat_0"},
5436};
5437
5438static struct msm_gpio sdc4_cfg_data[] = {
5439 {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
5440 {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
5441 {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
5442 {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
5443 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
5444 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
5445};
5446
5447static struct sdcc_gpio sdcc_cfg_data[] = {
5448 {
5449 .cfg_data = sdc1_cfg_data,
5450 .size = ARRAY_SIZE(sdc1_cfg_data),
5451 .sleep_cfg_data = NULL,
5452 },
5453 {
5454 .cfg_data = sdc2_cfg_data,
5455 .size = ARRAY_SIZE(sdc2_cfg_data),
5456 .sleep_cfg_data = NULL,
5457 },
5458 {
5459 .cfg_data = sdc3_cfg_data,
5460 .size = ARRAY_SIZE(sdc3_cfg_data),
5461 .sleep_cfg_data = sdc3_sleep_cfg_data,
5462 },
5463 {
5464 .cfg_data = sdc4_cfg_data,
5465 .size = ARRAY_SIZE(sdc4_cfg_data),
5466 .sleep_cfg_data = NULL,
5467 },
5468};
5469
Justin Paupore3f40f342011-08-10 18:52:16 -07005470static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005471
5472static unsigned long vreg_sts, gpio_sts;
5473
5474static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
5475{
5476 int rc = 0;
5477 struct sdcc_gpio *curr;
5478
5479 curr = &sdcc_cfg_data[dev_id - 1];
5480
5481 if (!(test_bit(dev_id, &gpio_sts)^enable))
5482 return rc;
5483
5484 if (enable) {
5485 set_bit(dev_id, &gpio_sts);
5486 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
5487 if (rc)
5488 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
5489 __func__, dev_id);
5490 } else {
5491 clear_bit(dev_id, &gpio_sts);
5492 if (curr->sleep_cfg_data) {
5493 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
5494 msm_gpios_free(curr->sleep_cfg_data, curr->size);
5495 } else {
5496 msm_gpios_disable_free(curr->cfg_data, curr->size);
5497 }
5498 }
5499
5500 return rc;
5501}
5502
5503static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
5504{
5505 int rc = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005506 struct regulator *curr = sdcc_vreg_data[dev_id - 1];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005507 static int enabled_once[] = {0, 0, 0, 0};
5508
Justin Paupore3f40f342011-08-10 18:52:16 -07005509 if (test_bit(dev_id, &vreg_sts) == enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005510 return rc;
5511
Asutosh Das853bbcd2012-02-01 10:40:05 +05305512 if (dev_id == 4) {
5513 if (enable) {
5514 pr_debug("Enable Vdd dev_%d\n", dev_id);
5515 gpio_set_value_cansleep(
5516 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5517 0);
5518 set_bit(dev_id, &vreg_sts);
5519 } else {
5520 pr_debug("Disable Vdd dev_%d\n", dev_id);
5521 gpio_set_value_cansleep(
5522 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5523 1);
5524 clear_bit(dev_id, &vreg_sts);
5525 }
5526 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005527
Asutosh Das853bbcd2012-02-01 10:40:05 +05305528 if (!enable || enabled_once[dev_id - 1])
5529 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005530 if (!curr)
5531 return -ENODEV;
5532
5533 if (IS_ERR(curr))
5534 return PTR_ERR(curr);
5535
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005536 if (enable) {
5537 set_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005538
5539 rc = regulator_enable(curr);
5540 if (rc)
5541 pr_err("%s: could not enable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005542 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005543 enabled_once[dev_id - 1] = 1;
5544 } else {
5545 clear_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005546
5547 rc = regulator_disable(curr);
5548 if (rc)
5549 pr_err("%s: could not disable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005550 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005551 }
5552 return rc;
5553}
5554
5555static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
5556{
5557 int rc = 0;
5558 struct platform_device *pdev;
5559
5560 pdev = container_of(dv, struct platform_device, dev);
5561 rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
5562 if (rc)
5563 goto out;
5564
5565 if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
5566 rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
5567out:
5568 return rc;
5569}
5570
5571#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \
5572 defined(CONFIG_CSDIO_VENDOR_ID) && \
5573 defined(CONFIG_CSDIO_DEVICE_ID) && \
5574 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5575
5576#define MBP_ON 1
5577#define MBP_OFF 0
5578
5579#define MBP_RESET_N \
5580 GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
5581#define MBP_INT0 \
5582 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
5583
5584#define MBP_MODE_CTRL_0 \
5585 GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5586#define MBP_MODE_CTRL_1 \
5587 GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5588#define MBP_MODE_CTRL_2 \
5589 GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5590#define TSIF_EN \
5591 GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5592#define TSIF_DATA \
5593 GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5594#define TSIF_CLK \
5595 GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5596
5597static struct msm_gpio mbp_cfg_data[] = {
5598 {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5599 "mbp_reset"},
5600 {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5601 "mbp_io_voltage"},
5602};
5603
5604static int mbp_config_gpios_pre_init(int enable)
5605{
5606 int rc = 0;
5607
5608 if (enable) {
5609 rc = msm_gpios_request_enable(mbp_cfg_data,
5610 ARRAY_SIZE(mbp_cfg_data));
5611 if (rc) {
5612 printk(KERN_ERR
5613 "%s: Failed to turnon GPIOs for mbp chip(%d)\n",
5614 __func__, rc);
5615 }
5616 } else
5617 msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
5618 return rc;
5619}
5620
Justin Paupore3f40f342011-08-10 18:52:16 -07005621static struct regulator_bulk_data mbp_regs_io[2];
5622static struct regulator_bulk_data mbp_regs_rf[2];
5623static struct regulator_bulk_data mbp_regs_adc[1];
5624static struct regulator_bulk_data mbp_regs_core[1];
5625
5626static int mbp_init_regs(struct device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005627{
Justin Paupore3f40f342011-08-10 18:52:16 -07005628 struct regulator_bulk_data regs[] = {
5629 /* Analog and I/O regs */
5630 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
5631 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
5632 /* RF regs */
5633 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
5634 { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 },
5635 /* ADC regs */
5636 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
5637 /* Core regs */
5638 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
5639 };
5640
5641 struct regulator_bulk_data *regptr = regs;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005642 int rc;
5643
Justin Paupore3f40f342011-08-10 18:52:16 -07005644 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs);
5645
5646 if (rc) {
5647 dev_err(dev, "%s: could not get regulators: %d\n",
5648 __func__, rc);
5649 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005650 }
5651
Justin Paupore3f40f342011-08-10 18:52:16 -07005652 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005653
Justin Paupore3f40f342011-08-10 18:52:16 -07005654 if (rc) {
5655 dev_err(dev, "%s: could not set voltages: %d\n",
5656 __func__, rc);
5657 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005658 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005659
5660 memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io));
5661 regptr += ARRAY_SIZE(mbp_regs_io);
5662
5663 memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf));
5664 regptr += ARRAY_SIZE(mbp_regs_rf);
5665
5666 memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc));
5667 regptr += ARRAY_SIZE(mbp_regs_adc);
5668
5669 memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core));
5670
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005671 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005672
5673reg_free:
5674 regulator_bulk_free(ARRAY_SIZE(regs), regs);
5675out:
5676 return rc;
5677}
5678
5679static int mbp_setup_rf_vregs(int state)
5680{
5681 return state ?
5682 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) :
5683 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005684}
5685
5686static int mbp_setup_vregs(int state)
5687{
Justin Paupore3f40f342011-08-10 18:52:16 -07005688 return state ?
5689 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) :
5690 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005691}
5692
5693static int mbp_set_tcxo_en(int enable)
5694{
5695 int rc;
5696 const char *id = "UBMC";
5697 struct vreg *vreg_analog = NULL;
5698
5699 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
5700 enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
5701 if (rc < 0) {
5702 printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
5703 __func__, enable ? "" : "de-");
5704 return -EIO;
5705 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005706 return rc;
5707}
5708
5709static void mbp_set_freeze_io(int state)
5710{
5711 if (state)
5712 gpio_set_value(85, 0);
5713 else
5714 gpio_set_value(85, 1);
5715}
5716
5717static int mbp_set_core_voltage_en(int enable)
5718{
Justin Paupore3f40f342011-08-10 18:52:16 -07005719 static bool is_enabled;
5720 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005721
Justin Paupore3f40f342011-08-10 18:52:16 -07005722 if (enable && !is_enabled) {
5723 rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core),
5724 mbp_regs_core);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005725 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005726 pr_err("%s: could not enable regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005727 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07005728 } else {
5729 is_enabled = true;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005730 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005731 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005732
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005733 return rc;
5734}
5735
5736static void mbp_set_reset(int state)
5737{
5738 if (state)
5739 gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
5740 else
5741 gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
5742}
5743
5744static int mbp_config_interface_mode(int state)
5745{
5746 if (state) {
5747 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
5748 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
5749 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
5750 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
5751 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
5752 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
5753 } else {
5754 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
5755 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
5756 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
5757 }
5758 return 0;
5759}
5760
5761static int mbp_setup_adc_vregs(int state)
5762{
Justin Paupore3f40f342011-08-10 18:52:16 -07005763 return state ?
5764 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) :
5765 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005766}
5767
5768static int mbp_power_up(void)
5769{
5770 int rc;
5771
5772 rc = mbp_config_gpios_pre_init(MBP_ON);
5773 if (rc)
5774 goto exit;
5775 pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__);
5776
5777 rc = mbp_setup_vregs(MBP_ON);
5778 if (rc)
5779 goto exit;
5780 pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
5781
5782 rc = mbp_set_tcxo_en(MBP_ON);
5783 if (rc)
5784 goto exit;
5785 pr_debug("%s: tcxo clock done\n", __func__);
5786
5787 mbp_set_freeze_io(MBP_OFF);
5788 pr_debug("%s: set gpio 85 to 1 done\n", __func__);
5789
5790 udelay(100);
5791 mbp_set_reset(MBP_ON);
5792
5793 udelay(300);
5794 rc = mbp_config_interface_mode(MBP_ON);
5795 if (rc)
5796 goto exit;
5797 pr_debug("%s: mbp_config_interface_mode() done\n", __func__);
5798
5799 udelay(100 + mbp_set_core_voltage_en(MBP_ON));
5800 pr_debug("%s: power gp16 1.2V done\n", __func__);
5801
5802 mbp_set_freeze_io(MBP_ON);
5803 pr_debug("%s: set gpio 85 to 0 done\n", __func__);
5804
5805 udelay(100);
5806
5807 rc = mbp_setup_rf_vregs(MBP_ON);
5808 if (rc)
5809 goto exit;
5810 pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
5811
5812 rc = mbp_setup_adc_vregs(MBP_ON);
5813 if (rc)
5814 goto exit;
5815 pr_debug("%s: s4 2.2V done\n", __func__);
5816
5817 udelay(200);
5818
5819 mbp_set_reset(MBP_OFF);
5820 pr_debug("%s: close gpio 44 done\n", __func__);
5821
5822 msleep(20);
5823exit:
5824 return rc;
5825}
5826
5827static int mbp_power_down(void)
5828{
5829 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005830
5831 mbp_set_reset(MBP_ON);
5832 pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
5833
5834 udelay(100);
5835
5836 rc = mbp_setup_adc_vregs(MBP_OFF);
5837 if (rc)
5838 goto exit;
5839 pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
5840
5841 udelay(5);
5842
5843 rc = mbp_setup_rf_vregs(MBP_OFF);
5844 if (rc)
5845 goto exit;
5846 pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
5847
5848 udelay(5);
5849
5850 mbp_set_freeze_io(MBP_OFF);
5851 pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
5852
5853 udelay(100);
5854 rc = mbp_set_core_voltage_en(MBP_OFF);
5855 if (rc)
5856 goto exit;
5857 pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
5858
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005859 rc = mbp_set_tcxo_en(MBP_OFF);
5860 if (rc)
5861 goto exit;
5862 pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
5863
Justin Paupore3f40f342011-08-10 18:52:16 -07005864 rc = mbp_setup_vregs(MBP_OFF);
5865 if (rc)
5866 goto exit;
5867 pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__);
5868
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005869 rc = mbp_config_gpios_pre_init(MBP_OFF);
5870 if (rc)
5871 goto exit;
5872exit:
5873 return rc;
5874}
5875
5876static void (*mbp_status_notify_cb)(int card_present, void *dev_id);
5877static void *mbp_status_notify_cb_devid;
5878static int mbp_power_status;
5879static int mbp_power_init_done;
5880
5881static uint32_t mbp_setup_power(struct device *dv,
5882 unsigned int power_status)
5883{
5884 int rc = 0;
5885 struct platform_device *pdev;
5886
5887 pdev = container_of(dv, struct platform_device, dev);
5888
5889 if (power_status == mbp_power_status)
5890 goto exit;
5891 if (power_status) {
5892 pr_debug("turn on power of mbp slot");
5893 rc = mbp_power_up();
5894 mbp_power_status = 1;
5895 } else {
5896 pr_debug("turn off power of mbp slot");
5897 rc = mbp_power_down();
5898 mbp_power_status = 0;
5899 }
5900exit:
5901 return rc;
5902};
5903
5904int mbp_register_status_notify(void (*callback)(int, void *),
5905 void *dev_id)
5906{
5907 mbp_status_notify_cb = callback;
5908 mbp_status_notify_cb_devid = dev_id;
5909 return 0;
5910}
5911
5912static unsigned int mbp_status(struct device *dev)
5913{
5914 return mbp_power_status;
5915}
5916
5917static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd)
5918{
5919 struct platform_device *pdev;
5920 uint32_t rc = 0;
5921
5922 pdev = container_of(dv, struct platform_device, dev);
5923 rc = msm_sdcc_setup_power(dv, vdd);
5924 if (rc) {
5925 pr_err("%s: Failed to setup power (%d)\n",
5926 __func__, rc);
5927 goto out;
5928 }
5929 if (!mbp_power_init_done) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005930 rc = mbp_init_regs(dv);
5931 if (rc) {
5932 dev_err(dv, "%s: regulator init failed: %d\n",
5933 __func__, rc);
5934 goto out;
5935 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005936 mbp_setup_power(dv, 1);
5937 mbp_setup_power(dv, 0);
5938 mbp_power_init_done = 1;
5939 }
5940 if (vdd >= 0x8000) {
5941 rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
5942 if (rc) {
5943 pr_err("%s: Failed to config mbp chip power (%d)\n",
5944 __func__, rc);
5945 goto out;
5946 }
5947 if (mbp_status_notify_cb) {
5948 mbp_status_notify_cb(mbp_power_status,
5949 mbp_status_notify_cb_devid);
5950 }
5951 }
5952out:
5953 /* should return 0 only */
5954 return 0;
5955}
5956
5957#endif
5958
5959#endif
5960
5961#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
5962#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5963static unsigned int msm7x30_sdcc_slot_status(struct device *dev)
5964{
5965 return (unsigned int)
5966 gpio_get_value_cansleep(
5967 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1));
5968}
5969#endif
5970
5971static int msm_sdcc_get_wpswitch(struct device *dv)
5972{
5973 void __iomem *wp_addr = 0;
5974 uint32_t ret = 0;
5975 struct platform_device *pdev;
5976
5977 if (!(machine_is_msm7x30_surf()))
5978 return -1;
5979 pdev = container_of(dv, struct platform_device, dev);
5980
5981 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
5982 if (!wp_addr) {
5983 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
5984 return -ENOMEM;
5985 }
5986
5987 ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
5988 pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
5989 pdev->id, ret);
5990 iounmap(wp_addr);
5991
5992 return ret;
5993}
5994#endif
5995
5996#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5997#if defined(CONFIG_CSDIO_VENDOR_ID) && \
5998 defined(CONFIG_CSDIO_DEVICE_ID) && \
5999 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
6000static struct mmc_platform_data msm7x30_sdc1_data = {
6001 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
6002 .translate_vdd = msm_sdcc_setup_power_mbp,
6003 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6004 .status = mbp_status,
6005 .register_status_notify = mbp_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006006 .msmsdcc_fmin = 144000,
6007 .msmsdcc_fmid = 24576000,
6008 .msmsdcc_fmax = 24576000,
6009 .nonremovable = 0,
6010};
6011#else
6012static struct mmc_platform_data msm7x30_sdc1_data = {
6013 .ocr_mask = MMC_VDD_165_195,
6014 .translate_vdd = msm_sdcc_setup_power,
6015 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006016 .msmsdcc_fmin = 144000,
6017 .msmsdcc_fmid = 24576000,
6018 .msmsdcc_fmax = 49152000,
6019 .nonremovable = 0,
6020};
6021#endif
6022#endif
6023
6024#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
6025static struct mmc_platform_data msm7x30_sdc2_data = {
6026 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
6027 .translate_vdd = msm_sdcc_setup_power,
6028#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
6029 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
6030#else
6031 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6032#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006033 .msmsdcc_fmin = 144000,
6034 .msmsdcc_fmid = 24576000,
6035 .msmsdcc_fmax = 49152000,
6036 .nonremovable = 1,
6037};
6038#endif
6039
6040#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
6041static struct mmc_platform_data msm7x30_sdc3_data = {
6042 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6043 .translate_vdd = msm_sdcc_setup_power,
6044 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6045#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
6046 .sdiowakeup_irq = MSM_GPIO_TO_INT(118),
6047#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006048 .msmsdcc_fmin = 144000,
6049 .msmsdcc_fmid = 24576000,
6050 .msmsdcc_fmax = 49152000,
6051 .nonremovable = 0,
6052};
6053#endif
6054
6055#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6056static struct mmc_platform_data msm7x30_sdc4_data = {
6057 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6058 .translate_vdd = msm_sdcc_setup_power,
6059 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6060#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6061 .status = msm7x30_sdcc_slot_status,
6062 .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
6063 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
6064#endif
6065 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006066 .msmsdcc_fmin = 144000,
6067 .msmsdcc_fmid = 24576000,
6068 .msmsdcc_fmax = 49152000,
6069 .nonremovable = 0,
6070};
6071#endif
6072
6073#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006074static int msm_sdc1_lvlshft_enable(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006075{
Justin Paupore3f40f342011-08-10 18:52:16 -07006076 static struct regulator *ldo5;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006077 int rc;
6078
6079 /* Enable LDO5, an input to the FET that powers slot 1 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006080
Justin Paupore3f40f342011-08-10 18:52:16 -07006081 ldo5 = regulator_get(NULL, "ldo5");
6082
6083 if (IS_ERR(ldo5)) {
6084 rc = PTR_ERR(ldo5);
6085 pr_err("%s: could not get ldo5: %d\n", __func__, rc);
6086 goto out;
6087 }
6088
6089 rc = regulator_set_voltage(ldo5, 2850000, 2850000);
6090 if (rc) {
6091 pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc);
6092 goto ldo5_free;
6093 }
6094
6095 rc = regulator_enable(ldo5);
6096 if (rc) {
6097 pr_err("%s: could not enable ldo5: %d\n", __func__, rc);
6098 goto ldo5_free;
6099 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006100
6101 /* Enable GPIO 35, to turn on the FET that powers slot 1 */
6102 rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
6103 ARRAY_SIZE(sdc1_lvlshft_cfg_data));
6104 if (rc)
6105 printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
6106
6107 rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg),
6108 1);
6109 if (rc)
6110 printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006111
6112 return 0;
6113
6114ldo5_free:
6115 regulator_put(ldo5);
6116out:
6117 ldo5 = NULL;
6118 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006119}
6120#endif
6121
Justin Paupore3f40f342011-08-10 18:52:16 -07006122static int mmc_regulator_init(int sdcc_no, const char *supply, int uV)
6123{
6124 int rc;
6125
6126 BUG_ON(sdcc_no < 1 || sdcc_no > 4);
6127
6128 sdcc_no--;
6129
6130 sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply);
6131
6132 if (IS_ERR(sdcc_vreg_data[sdcc_no])) {
6133 rc = PTR_ERR(sdcc_vreg_data[sdcc_no]);
6134 pr_err("%s: could not get regulator \"%s\": %d\n",
6135 __func__, supply, rc);
6136 goto out;
6137 }
6138
6139 rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV);
6140
6141 if (rc) {
6142 pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n",
6143 __func__, supply, uV, rc);
6144 goto reg_free;
6145 }
6146
6147 return rc;
6148
6149reg_free:
6150 regulator_put(sdcc_vreg_data[sdcc_no]);
6151out:
6152 sdcc_vreg_data[sdcc_no] = NULL;
6153 return rc;
6154}
6155
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006156static void __init msm7x30_init_mmc(void)
6157{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006158#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006159 if (mmc_regulator_init(1, "s3", 1800000))
6160 goto out1;
6161
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006162 if (machine_is_msm7x30_fluid()) {
6163 msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
Justin Paupore3f40f342011-08-10 18:52:16 -07006164 if (msm_sdc1_lvlshft_enable()) {
6165 pr_err("%s: could not enable level shift\n");
6166 goto out1;
6167 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006168 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006169
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006170 msm_add_sdcc(1, &msm7x30_sdc1_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006171out1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006172#endif
6173#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006174 if (mmc_regulator_init(2, "s3", 1800000))
6175 goto out2;
6176
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006177 if (machine_is_msm8x55_svlte_surf())
6178 msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
Sujith Reddy Thumma84a0f512011-08-29 09:57:03 +05306179 if (machine_is_msm8x55_svlte_surf() ||
6180 machine_is_msm8x55_svlte_ffa()) {
6181 msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
6182 msm7x30_sdc2_data.is_sdio_al_client = 1;
6183 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006184
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006185 msm_add_sdcc(2, &msm7x30_sdc2_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006186out2:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006187#endif
6188#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006189 if (mmc_regulator_init(3, "s3", 1800000))
6190 goto out3;
6191
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006192 msm_sdcc_setup_gpio(3, 1);
6193 msm_add_sdcc(3, &msm7x30_sdc3_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006194out3:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006195#endif
6196#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006197 if (mmc_regulator_init(4, "mmc", 2850000))
6198 return;
6199
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006200 msm_add_sdcc(4, &msm7x30_sdc4_data);
6201#endif
6202
6203}
6204
6205static void __init msm7x30_init_nand(void)
6206{
6207 char *build_id;
6208 struct flash_platform_data *plat_data;
6209
6210 build_id = socinfo_get_build_id();
6211 if (build_id == NULL) {
6212 pr_err("%s: Build ID not available from socinfo\n", __func__);
6213 return;
6214 }
6215
6216 if (build_id[8] == 'C' &&
6217 !msm_gpios_request_enable(msm_nand_ebi2_cfg_data,
6218 ARRAY_SIZE(msm_nand_ebi2_cfg_data))) {
6219 plat_data = msm_device_nand.dev.platform_data;
6220 plat_data->interleave = 1;
6221 printk(KERN_INFO "%s: Interleave mode Build ID found\n",
6222 __func__);
6223 }
6224}
6225
6226#ifdef CONFIG_SERIAL_MSM_CONSOLE
6227static struct msm_gpio uart2_config_data[] = {
6228 { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
6229 { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
6230 { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
6231 { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
6232};
6233
6234static void msm7x30_init_uart2(void)
6235{
6236 msm_gpios_request_enable(uart2_config_data,
6237 ARRAY_SIZE(uart2_config_data));
6238
6239}
6240#endif
6241
6242/* TSIF begin */
6243#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6244
6245#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6246#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6247#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6248#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6249
6250static const struct msm_gpio tsif_gpios[] = {
6251 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
6252 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
6253 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
6254 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
6255};
6256
6257static struct msm_tsif_platform_data tsif_platform_data = {
6258 .num_gpios = ARRAY_SIZE(tsif_gpios),
6259 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -07006260 .tsif_pclk = "iface_clk",
6261 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006262};
6263#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
6264/* TSIF end */
6265
6266static void __init pmic8058_leds_init(void)
6267{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306268 if (machine_is_msm7x30_surf())
6269 pm8058_7x30_data.leds_pdata = &pm8058_surf_leds_data;
6270 else if (!machine_is_msm7x30_fluid())
6271 pm8058_7x30_data.leds_pdata = &pm8058_ffa_leds_data;
6272 else if (machine_is_msm7x30_fluid())
6273 pm8058_7x30_data.leds_pdata = &pm8058_fluid_leds_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006274}
6275
6276static struct msm_spm_platform_data msm_spm_data __initdata = {
6277 .reg_base_addr = MSM_SAW_BASE,
6278
6279 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
6280 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
6281 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
6282 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
6283
6284 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
6285 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
6286 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
6287
6288 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
6289 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
6290 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
6291
6292 .awake_vlevel = 0xF2,
6293 .retention_vlevel = 0xE0,
6294 .collapse_vlevel = 0x72,
6295 .retention_mid_vlevel = 0xE0,
6296 .collapse_mid_vlevel = 0xE0,
6297
6298 .vctl_timeout_us = 50,
6299};
6300
6301#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6302 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6303
6304#define TSC2007_TS_PEN_INT 20
6305
6306static struct msm_gpio tsc2007_config_data[] = {
6307 { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
6308 "tsc2007_irq" },
6309};
6310
Justin Paupore3f40f342011-08-10 18:52:16 -07006311static struct regulator_bulk_data tsc2007_regs[] = {
6312 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
6313 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
6314};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006315
6316static int tsc2007_init(void)
6317{
6318 int rc;
6319
Justin Paupore3f40f342011-08-10 18:52:16 -07006320 rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006321
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006322 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006323 pr_err("%s: could not get regulators: %d\n", __func__, rc);
6324 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006325 }
6326
Justin Paupore3f40f342011-08-10 18:52:16 -07006327 rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6328
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006329 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006330 pr_err("%s: could not set voltages: %d\n", __func__, rc);
6331 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006332 }
6333
Justin Paupore3f40f342011-08-10 18:52:16 -07006334 rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006335
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006336 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006337 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
6338 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006339 }
6340
6341 rc = msm_gpios_request_enable(tsc2007_config_data,
6342 ARRAY_SIZE(tsc2007_config_data));
6343 if (rc) {
6344 pr_err("%s: Unable to request gpios\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006345 goto reg_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006346 }
6347
6348 return 0;
6349
Justin Paupore3f40f342011-08-10 18:52:16 -07006350reg_disable:
6351 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6352reg_free:
6353 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6354out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006355 return rc;
6356}
6357
6358static int tsc2007_get_pendown_state(void)
6359{
6360 int rc;
6361
6362 rc = gpio_get_value(TSC2007_TS_PEN_INT);
6363 if (rc < 0) {
6364 pr_err("%s: MSM GPIO %d read failed\n", __func__,
6365 TSC2007_TS_PEN_INT);
6366 return rc;
6367 }
6368
6369 return (rc == 0 ? 1 : 0);
6370}
6371
6372static void tsc2007_exit(void)
6373{
Justin Paupore3f40f342011-08-10 18:52:16 -07006374
6375 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6376 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006377
6378 msm_gpios_disable_free(tsc2007_config_data,
6379 ARRAY_SIZE(tsc2007_config_data));
6380}
6381
6382static int tsc2007_power_shutdown(bool enable)
6383{
6384 int rc;
6385
Justin Paupore3f40f342011-08-10 18:52:16 -07006386 rc = (enable == false) ?
6387 regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) :
6388 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6389
6390 if (rc) {
6391 pr_err("%s: could not %sable regulators: %d\n",
6392 __func__, enable ? "dis" : "en", rc);
6393 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006394 }
6395
Justin Paupore3f40f342011-08-10 18:52:16 -07006396 if (enable == false)
6397 msleep(20);
6398
6399 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006400}
6401
6402static struct tsc2007_platform_data tsc2007_ts_data = {
6403 .model = 2007,
6404 .x_plate_ohms = 300,
Anirudh Ghayala2cf2e22012-01-25 12:29:42 +05306405 .min_x = 210,
6406 .max_x = 3832,
6407 .min_y = 150,
6408 .max_y = 3936,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006409 .irq_flags = IRQF_TRIGGER_LOW,
6410 .init_platform_hw = tsc2007_init,
6411 .exit_platform_hw = tsc2007_exit,
6412 .power_shutdown = tsc2007_power_shutdown,
6413 .invert_x = true,
6414 .invert_y = true,
6415 /* REVISIT: Temporary fix for reversed pressure */
6416 .invert_z1 = true,
6417 .invert_z2 = true,
6418 .get_pendown_state = tsc2007_get_pendown_state,
6419};
6420
6421static struct i2c_board_info tsc_i2c_board_info[] = {
6422 {
6423 I2C_BOARD_INFO("tsc2007", 0x48),
6424 .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
6425 .platform_data = &tsc2007_ts_data,
6426 },
6427};
6428#endif
6429
Justin Paupore3f40f342011-08-10 18:52:16 -07006430static struct regulator_bulk_data regs_isa1200[] = {
6431 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
6432 { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006433};
6434
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006435static int isa1200_power(int vreg_on)
6436{
Justin Paupore3f40f342011-08-10 18:52:16 -07006437 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006438
Justin Paupore3f40f342011-08-10 18:52:16 -07006439 rc = vreg_on ?
6440 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) :
6441 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006442
Justin Paupore3f40f342011-08-10 18:52:16 -07006443 if (rc) {
6444 pr_err("%s: could not %sable regulators: %d\n",
6445 __func__, vreg_on ? "en" : "dis", rc);
6446 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006447 }
6448
6449 /* vote for DO buffer */
6450 rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO,
6451 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
6452 if (rc) {
6453 pr_err("%s: unable to %svote for d0 clk\n",
6454 __func__, vreg_on ? "" : "de-");
6455 goto vreg_fail;
6456 }
6457
6458 return 0;
6459
6460vreg_fail:
Justin Paupore3f40f342011-08-10 18:52:16 -07006461 if (vreg_on)
6462 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6463 else
6464 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6465out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006466 return rc;
6467}
6468
6469static int isa1200_dev_setup(bool enable)
6470{
Justin Paupore3f40f342011-08-10 18:52:16 -07006471 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006472
6473 if (enable == true) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006474 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200),
6475 regs_isa1200);
6476
6477 if (rc) {
6478 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006479 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006480 goto out;
6481 }
6482
6483 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200),
6484 regs_isa1200);
6485 if (rc) {
6486 pr_err("%s: could not set voltages: %d\n",
6487 __func__, rc);
6488 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006489 }
6490
6491 rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
6492 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
6493 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
6494 if (rc) {
6495 pr_err("%s: Could not configure gpio %d\n",
6496 __func__, HAP_LVL_SHFT_MSM_GPIO);
Justin Paupore3f40f342011-08-10 18:52:16 -07006497 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006498 }
6499
6500 rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
6501 if (rc) {
6502 pr_err("%s: unable to request gpio %d (%d)\n",
6503 __func__, HAP_LVL_SHFT_MSM_GPIO, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006504 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006505 }
6506
6507 gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
6508 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006509 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006510 gpio_free(HAP_LVL_SHFT_MSM_GPIO);
6511 }
6512
6513 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07006514
6515reg_free:
6516 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6517out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006518 return rc;
6519}
6520static struct isa1200_platform_data isa1200_1_pdata = {
6521 .name = "vibrator",
6522 .power_on = isa1200_power,
6523 .dev_setup = isa1200_dev_setup,
6524 .pwm_ch_id = 1, /*channel id*/
6525 /*gpio to enable haptic*/
6526 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka03122322011-09-09 15:15:43 +05306527 .hap_len_gpio = -1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006528 .max_timeout = 15000,
6529 .mode_ctrl = PWM_GEN_MODE,
6530 .pwm_fd = {
6531 .pwm_div = 256,
6532 },
6533 .is_erm = false,
6534 .smart_en = true,
6535 .ext_clk_en = true,
6536 .chip_en = 1,
6537};
6538
6539static struct i2c_board_info msm_isa1200_board_info[] = {
6540 {
6541 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
6542 .platform_data = &isa1200_1_pdata,
6543 },
6544};
6545
6546
6547static int kp_flip_mpp_config(void)
6548{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306549 struct pm8xxx_mpp_config_data kp_flip_mpp = {
6550 .type = PM8XXX_MPP_TYPE_D_INPUT,
6551 .level = PM8018_MPP_DIG_LEVEL_S3,
6552 .control = PM8XXX_MPP_DIN_TO_INT,
6553 };
6554
6555 return pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(PM_FLIP_MPP),
6556 &kp_flip_mpp);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006557}
6558
6559static struct flip_switch_pdata flip_switch_data = {
6560 .name = "kp_flip_switch",
6561 .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP,
6562 .left_key = KEY_OPEN,
6563 .right_key = KEY_CLOSE,
6564 .active_low = 0,
6565 .wakeup = 1,
6566 .flip_mpp_config = kp_flip_mpp_config,
6567};
6568
6569static struct platform_device flip_switch_device = {
6570 .name = "kp_flip_switch",
6571 .id = -1,
6572 .dev = {
6573 .platform_data = &flip_switch_data,
6574 }
6575};
6576
Justin Paupore3f40f342011-08-10 18:52:16 -07006577static struct regulator_bulk_data regs_tma300[] = {
6578 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
6579 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006580};
6581
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006582static int tma300_power(int vreg_on)
6583{
Justin Paupore3f40f342011-08-10 18:52:16 -07006584 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006585
Justin Paupore3f40f342011-08-10 18:52:16 -07006586 rc = vreg_on ?
6587 regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) :
6588 regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006589
Justin Paupore3f40f342011-08-10 18:52:16 -07006590 if (rc)
6591 pr_err("%s: could not %sable regulators: %d\n",
6592 __func__, vreg_on ? "en" : "dis", rc);
6593 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006594}
6595
6596#define TS_GPIO_IRQ 150
6597
6598static int tma300_dev_setup(bool enable)
6599{
Justin Paupore3f40f342011-08-10 18:52:16 -07006600 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006601
6602 if (enable) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006603 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300),
6604 regs_tma300);
6605
6606 if (rc) {
6607 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006608 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006609 goto out;
6610 }
6611
6612 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300),
6613 regs_tma300);
6614
6615 if (rc) {
6616 pr_err("%s: could not set voltages: %d\n",
6617 __func__, rc);
6618 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006619 }
6620
6621 /* enable interrupt gpio */
6622 rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
6623 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
6624 if (rc) {
6625 pr_err("%s: Could not configure gpio %d\n",
6626 __func__, TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -07006627 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006628 }
6629
6630 /* virtual keys */
6631 tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
6632 properties_kobj = kobject_create_and_add("board_properties",
6633 NULL);
6634 if (!properties_kobj) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006635 pr_err("%s: failed to create a kobject "
6636 "for board_properties\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006637 rc = -ENOMEM;
Justin Paupore3f40f342011-08-10 18:52:16 -07006638 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006639 }
6640 rc = sysfs_create_group(properties_kobj,
6641 &tma300_properties_attr_group);
6642 if (rc) {
6643 pr_err("%s: failed to create a sysfs entry %s\n",
6644 __func__, tma300_vkeys_attr.attr.name);
Justin Paupore3f40f342011-08-10 18:52:16 -07006645 goto kobj_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006646 }
6647 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006648 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006649 /* destroy virtual keys */
6650 if (properties_kobj) {
6651 sysfs_remove_group(properties_kobj,
6652 &tma300_properties_attr_group);
6653 kobject_put(properties_kobj);
6654 }
6655 }
6656 return 0;
6657
Justin Paupore3f40f342011-08-10 18:52:16 -07006658kobj_free:
6659 kobject_put(properties_kobj);
6660 properties_kobj = NULL;
6661reg_free:
6662 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
6663out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006664 return rc;
6665}
6666
6667static struct cy8c_ts_platform_data cy8ctma300_pdata = {
6668 .power_on = tma300_power,
6669 .dev_setup = tma300_dev_setup,
6670 .ts_name = "msm_tma300_ts",
6671 .dis_min_x = 0,
6672 .dis_max_x = 479,
6673 .dis_min_y = 0,
6674 .dis_max_y = 799,
6675 .res_x = 479,
6676 .res_y = 1009,
6677 .min_tid = 1,
6678 .max_tid = 255,
6679 .min_touch = 0,
6680 .max_touch = 255,
6681 .min_width = 0,
6682 .max_width = 255,
6683 .invert_y = 1,
6684 .nfingers = 4,
6685 .irq_gpio = TS_GPIO_IRQ,
6686 .resout_gpio = -1,
6687};
6688
6689static struct i2c_board_info cy8ctma300_board_info[] = {
6690 {
6691 I2C_BOARD_INFO("cy8ctma300", 0x2),
6692 .platform_data = &cy8ctma300_pdata,
6693 }
6694};
6695
Daniel Walker8d747cd2010-02-25 11:37:43 -08006696static void __init msm7x30_init(void)
6697{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006698 int rc;
6699 unsigned smem_size;
6700 uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56,
6701 0,
6702 GPIO_CFG_OUTPUT,
6703 GPIO_CFG_NO_PULL,
6704 GPIO_CFG_2MA);
6705 uint32_t soc_version = 0;
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05306706
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006707 soc_version = socinfo_get_version();
6708
Stephen Boydbb600ae2011-08-02 20:11:40 -07006709 msm_clock_init(&msm7x30_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006710#ifdef CONFIG_SERIAL_MSM_CONSOLE
6711 msm7x30_init_uart2();
6712#endif
6713 msm_spm_init(&msm_spm_data, 1);
Matt Wagantallec57f062011-08-16 23:54:46 -07006714 acpuclk_init(&acpuclk_7x30_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006715 if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid())
6716 msm7x30_cfg_smsc911x();
6717
6718#ifdef CONFIG_USB_MSM_OTG_72K
6719 if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 &&
6720 SOCINFO_VERSION_MINOR(soc_version) >= 1) {
6721 pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
6722 msm_otg_pdata.ldo_set_voltage = 0;
6723 }
6724
6725 msm_device_otg.dev.platform_data = &msm_otg_pdata;
6726#ifdef CONFIG_USB_GADGET
6727 msm_otg_pdata.swfi_latency =
6728 msm_pm_data
6729 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
6730 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
6731#endif
6732#endif
6733 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
6734 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
6735#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6736 msm_device_tsif.dev.platform_data = &tsif_platform_data;
6737#endif
6738 if (machine_is_msm7x30_fluid()) {
6739 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
6740 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
6741 } else {
6742 msm_adc_pdata.dev_names = msm_adc_surf_device_names;
6743 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names);
6744 }
6745
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306746 pmic8058_leds_init();
6747
6748 buses_init();
6749
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306750#ifdef CONFIG_MSM_SSBI
6751 msm_device_ssbi_pmic1.dev.platform_data =
6752 &msm7x30_ssbi_pm8058_pdata;
6753#endif
6754
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006755 platform_add_devices(msm_footswitch_devices,
6756 msm_num_footswitch_devices);
Daniel Walker8d747cd2010-02-25 11:37:43 -08006757 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006758#ifdef CONFIG_USB_EHCI_MSM_72K
6759 msm_add_host(0, &msm_usb_host_pdata);
6760#endif
6761 msm7x30_init_mmc();
6762 msm7x30_init_nand();
6763 msm_qsd_spi_init();
6764
6765#ifdef CONFIG_SPI_QSD
6766 if (machine_is_msm7x30_fluid())
6767 spi_register_board_info(lcdc_sharp_spi_board_info,
6768 ARRAY_SIZE(lcdc_sharp_spi_board_info));
6769 else
6770 spi_register_board_info(lcdc_toshiba_spi_board_info,
6771 ARRAY_SIZE(lcdc_toshiba_spi_board_info));
6772#endif
6773
Justin Paupore3f40f342011-08-10 18:52:16 -07006774 atv_dac_power_init();
6775 sensors_ldo_init();
6776 hdmi_init_regs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006777 msm_fb_add_devices();
6778 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06006779 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006780 msm_device_i2c_init();
6781 msm_device_i2c_2_init();
6782 qup_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006783 msm7x30_init_marimba();
6784#ifdef CONFIG_MSM7KV2_AUDIO
6785 snddev_poweramp_gpio_init();
Justin Paupore3f40f342011-08-10 18:52:16 -07006786 snddev_hsed_voltage_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006787 aux_pcm_gpio_init();
6788#endif
6789
6790 i2c_register_board_info(0, msm_i2c_board_info,
6791 ARRAY_SIZE(msm_i2c_board_info));
6792
6793 if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid())
6794 marimba_pdata.tsadc = &marimba_tsadc_pdata;
6795
6796 if (machine_is_msm7x30_fluid())
6797 i2c_register_board_info(0, cy8info,
6798 ARRAY_SIZE(cy8info));
6799#ifdef CONFIG_BOSCH_BMA150
6800 if (machine_is_msm7x30_fluid())
6801 i2c_register_board_info(0, bma150_board_info,
6802 ARRAY_SIZE(bma150_board_info));
6803#endif
6804
6805 i2c_register_board_info(2, msm_marimba_board_info,
6806 ARRAY_SIZE(msm_marimba_board_info));
6807
6808 i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info,
6809 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info));
6810
6811 i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
6812 ARRAY_SIZE(msm_camera_boardinfo));
6813
6814 bt_power_init();
6815#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006816 msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
6817#endif
6818 if (machine_is_msm7x30_fluid())
6819 i2c_register_board_info(0, msm_isa1200_board_info,
6820 ARRAY_SIZE(msm_isa1200_board_info));
6821
6822#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6823 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6824 if (machine_is_msm8x55_svlte_ffa())
6825 i2c_register_board_info(2, tsc_i2c_board_info,
6826 ARRAY_SIZE(tsc_i2c_board_info));
6827#endif
6828
6829 if (machine_is_msm7x30_surf())
6830 platform_device_register(&flip_switch_device);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306831
6832 pm8058_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006833
6834 if (machine_is_msm7x30_fluid()) {
6835 /* Initialize platform data for fluid v2 hardware */
6836 if (SOCINFO_VERSION_MAJOR(
6837 socinfo_get_platform_version()) == 2) {
6838 cy8ctma300_pdata.res_y = 920;
6839 cy8ctma300_pdata.invert_y = 0;
6840 }
6841 i2c_register_board_info(0, cy8ctma300_board_info,
6842 ARRAY_SIZE(cy8ctma300_board_info));
6843 }
6844
6845 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
6846 rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE);
6847 if (rc)
6848 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
6849 __func__, usb_hub_gpio_cfg_value, rc);
6850 }
6851
6852 boot_reason = *(unsigned int *)
6853 (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
6854 printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
6855}
6856
6857static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
6858static int __init pmem_sf_size_setup(char *p)
6859{
6860 pmem_sf_size = memparse(p, NULL);
6861 return 0;
6862}
6863early_param("pmem_sf_size", pmem_sf_size_setup);
6864
6865static unsigned fb_size = MSM_FB_SIZE;
6866static int __init fb_size_setup(char *p)
6867{
6868 fb_size = memparse(p, NULL);
6869 return 0;
6870}
6871early_param("fb_size", fb_size_setup);
6872
6873static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
6874static int __init pmem_adsp_size_setup(char *p)
6875{
6876 pmem_adsp_size = memparse(p, NULL);
6877 return 0;
6878}
6879early_param("pmem_adsp_size", pmem_adsp_size_setup);
6880
6881static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE;
6882static int __init fluid_pmem_adsp_size_setup(char *p)
6883{
6884 fluid_pmem_adsp_size = memparse(p, NULL);
6885 return 0;
6886}
6887early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup);
6888
6889static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
6890static int __init pmem_audio_size_setup(char *p)
6891{
6892 pmem_audio_size = memparse(p, NULL);
6893 return 0;
6894}
6895early_param("pmem_audio_size", pmem_audio_size_setup);
6896
6897static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE;
6898static int __init pmem_kernel_ebi0_size_setup(char *p)
6899{
6900 pmem_kernel_ebi0_size = memparse(p, NULL);
6901 return 0;
6902}
6903early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
6904
6905static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
6906 [MEMTYPE_SMI] = {
6907 },
6908 [MEMTYPE_EBI0] = {
6909 .flags = MEMTYPE_FLAGS_1M_ALIGN,
6910 },
6911 [MEMTYPE_EBI1] = {
6912 .flags = MEMTYPE_FLAGS_1M_ALIGN,
6913 },
6914};
6915
6916static void __init size_pmem_devices(void)
6917{
6918#ifdef CONFIG_ANDROID_PMEM
6919 unsigned long size;
6920
6921 if machine_is_msm7x30_fluid()
6922 size = fluid_pmem_adsp_size;
6923 else
6924 size = pmem_adsp_size;
6925 android_pmem_adsp_pdata.size = size;
6926 android_pmem_audio_pdata.size = pmem_audio_size;
6927 android_pmem_pdata.size = pmem_sf_size;
6928#endif
6929}
6930
6931static void __init reserve_memory_for(struct android_pmem_platform_data *p)
6932{
6933 msm7x30_reserve_table[p->memory_type].size += p->size;
6934}
6935
6936static void __init reserve_pmem_memory(void)
6937{
6938#ifdef CONFIG_ANDROID_PMEM
6939 reserve_memory_for(&android_pmem_adsp_pdata);
6940 reserve_memory_for(&android_pmem_audio_pdata);
6941 reserve_memory_for(&android_pmem_pdata);
6942 msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
6943#endif
6944}
6945
6946static void __init msm7x30_calculate_reserve_sizes(void)
6947{
6948 size_pmem_devices();
6949 reserve_pmem_memory();
6950}
6951
6952static int msm7x30_paddr_to_memtype(unsigned int paddr)
6953{
Pankaj Kumarac69ee62012-01-26 00:21:56 +05306954 if (paddr < phys_add)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006955 return MEMTYPE_EBI0;
Pankaj Kumarac69ee62012-01-26 00:21:56 +05306956 if (paddr >= phys_add && paddr < 0x80000000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006957 return MEMTYPE_EBI1;
6958 return MEMTYPE_NONE;
6959}
6960
6961static struct reserve_info msm7x30_reserve_info __initdata = {
6962 .memtype_reserve_table = msm7x30_reserve_table,
6963 .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes,
6964 .paddr_to_memtype = msm7x30_paddr_to_memtype,
6965};
6966
6967static void __init msm7x30_reserve(void)
6968{
6969 reserve_info = &msm7x30_reserve_info;
6970 msm_reserve();
6971}
6972
6973static void __init msm7x30_allocate_memory_regions(void)
6974{
6975 void *addr;
6976 unsigned long size;
6977
6978 size = fb_size ? : MSM_FB_SIZE;
6979 addr = alloc_bootmem_align(size, 0x1000);
6980 msm_fb_resources[0].start = __pa(addr);
6981 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
6982 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
6983 size, addr, __pa(addr));
Daniel Walker8d747cd2010-02-25 11:37:43 -08006984}
6985
6986static void __init msm7x30_map_io(void)
6987{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006988 msm_shared_ram_phys = 0x00100000;
Daniel Walker8d747cd2010-02-25 11:37:43 -08006989 msm_map_msm7x30_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07006990 if (socinfo_init() < 0)
6991 printk(KERN_ERR "%s: socinfo_init() failed!\n",
6992 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006993}
6994
6995static void __init msm7x30_init_early(void)
6996{
6997 msm7x30_allocate_memory_regions();
Daniel Walker8d747cd2010-02-25 11:37:43 -08006998}
6999
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307000static void __init msm7x30_fixup(struct machine_desc *desc, struct tag *tags,
7001 char **cmdline, struct meminfo *mi)
7002{
7003 for (; tags->hdr.size; tags = tag_next(tags)) {
7004 if (tags->hdr.tag == ATAG_MEM && tags->u.mem.start ==
7005 DDR1_BANK_BASE) {
7006 ebi1_phys_offset = DDR1_BANK_BASE;
7007 phys_add = DDR1_BANK_BASE;
7008 break;
7009 }
7010 }
7011}
7012
Daniel Walker8d747cd2010-02-25 11:37:43 -08007013MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00007014 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007015 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007016 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007017 .init_irq = msm7x30_init_irq,
7018 .init_machine = msm7x30_init,
7019 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007020 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307021 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307022 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007023MACHINE_END
7024
7025MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00007026 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007027 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007028 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007029 .init_irq = msm7x30_init_irq,
7030 .init_machine = msm7x30_init,
7031 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007032 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307033 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307034 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007035MACHINE_END
7036
7037MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
Russell Kingb75c1782011-01-04 19:03:16 +00007038 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007039 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007040 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007041 .init_irq = msm7x30_init_irq,
7042 .init_machine = msm7x30_init,
7043 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007044 .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,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007047MACHINE_END
7048
7049MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
7050 .boot_params = PHYS_OFFSET + 0x100,
7051 .map_io = msm7x30_map_io,
7052 .reserve = msm7x30_reserve,
7053 .init_irq = msm7x30_init_irq,
7054 .init_machine = msm7x30_init,
7055 .timer = &msm_timer,
7056 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307057 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307058 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007059MACHINE_END
7060
7061MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA")
7062 .boot_params = PHYS_OFFSET + 0x100,
7063 .map_io = msm7x30_map_io,
7064 .reserve = msm7x30_reserve,
7065 .init_irq = msm7x30_init_irq,
7066 .init_machine = msm7x30_init,
7067 .timer = &msm_timer,
7068 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307069 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307070 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007071MACHINE_END
7072MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
7073 .boot_params = PHYS_OFFSET + 0x100,
7074 .map_io = msm7x30_map_io,
7075 .reserve = msm7x30_reserve,
7076 .init_irq = msm7x30_init_irq,
7077 .init_machine = msm7x30_init,
7078 .timer = &msm_timer,
7079 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307080 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307081 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007082MACHINE_END
7083MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA")
7084 .boot_params = PHYS_OFFSET + 0x100,
7085 .map_io = msm7x30_map_io,
7086 .reserve = msm7x30_reserve,
7087 .init_irq = msm7x30_init_irq,
7088 .init_machine = msm7x30_init,
7089 .timer = &msm_timer,
7090 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307091 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307092 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007093MACHINE_END