blob: ee13e04b0cdfea9052fd9e4b4c9fadc9bcfe9c2d [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>
Steve Mucklef132c6c2012-06-06 18:30:57 -070068#include <linux/cyttsp-qc.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"
Matt Wagantall33d01f52012-02-23 23:27:44 -080085#include "clock.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070086#include <mach/dal_axi.h>
87#include <mach/msm_serial_hs.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070088#include <mach/qdsp5v2/mi2s.h>
89#include <mach/qdsp5v2/audio_dev_ctl.h>
90#include <mach/sdio_al.h>
91#include "smd_private.h"
92#include <linux/bma150.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080093
Justin Paupore637a25d2011-07-14 17:11:04 -070094#include "board-msm7x30-regulator.h"
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +053095#include "pm.h"
Daniel Walker90e37c52010-05-12 14:24:15 -070096
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070097#define MSM_PMEM_SF_SIZE 0x1700000
98#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Mayank Chopraaed3b4b2012-02-29 11:54:18 +053099#define MSM_FB_PRIM_BUF_SIZE (864 * 480 * 4 * 3) /* 4bpp * 3 Pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700100#else
Mayank Chopraaed3b4b2012-02-29 11:54:18 +0530101#define MSM_FB_PRIM_BUF_SIZE (864 * 480 * 4 * 2) /* 4bpp * 2 Pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700102#endif
Alhad Purnapatrec55856c2012-02-28 13:24:57 -0800103/*
104 * Reserve space for double buffered full screen
105 * res V4L2 video overlay - i.e. 1280x720x1.5x2
106 */
107#define MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE 2764800
Mayank Chopraaed3b4b2012-02-29 11:54:18 +0530108
Jeevan Shrirama7d44142012-06-14 15:55:25 +0530109#ifdef CONFIG_FB_MSM_HDMI_ADV7520_PANEL
Mayank Chopraaed3b4b2012-02-29 11:54:18 +0530110#define MSM_FB_EXT_BUF_SIZE (1280 * 720 * 2 * 1) /* 2 bpp x 1 page */
111#else
112#define MSM_FB_EXT_BUF_SIZE 0
113#endif
114
115#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
116/* width x height x 3 bpp x 2 frame buffer */
117#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((864 * 480 * 3 * 2), 4096)
118#else
119#define MSM_FB_OVERLAY0_WRITEBACK_SIZE 0
120#endif
121
122#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE, 4096)
123
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700124#define MSM_PMEM_ADSP_SIZE 0x1E00000
125#define MSM_FLUID_PMEM_ADSP_SIZE 0x2800000
126#define PMEM_KERNEL_EBI0_SIZE 0x600000
127#define MSM_PMEM_AUDIO_SIZE 0x200000
Daniel Walker90e37c52010-05-12 14:24:15 -0700128
Chintan Pandya03b698a2012-06-28 19:03:09 +0530129#ifdef CONFIG_ION_MSM
130static struct platform_device ion_dev;
131#define MSM_ION_AUDIO_SIZE (MSM_PMEM_AUDIO_SIZE + PMEM_KERNEL_EBI0_SIZE)
132#define MSM_ION_SF_SIZE MSM_PMEM_SF_SIZE
133#define MSM_ION_HEAP_NUM 4
134#endif
135
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700136#define PMIC_GPIO_INT 27
137#define PMIC_VREG_WLAN_LEVEL 2900
138#define PMIC_GPIO_SD_DET 36
139#define PMIC_GPIO_SDC4_EN_N 17 /* PMIC GPIO Number 18 */
140#define PMIC_GPIO_HDMI_5V_EN_V3 32 /* PMIC GPIO for V3 H/W */
141#define PMIC_GPIO_HDMI_5V_EN_V2 39 /* PMIC GPIO for V2 H/W */
142
143#define ADV7520_I2C_ADDR 0x39
144
145#define FPGA_SDCC_STATUS 0x8E0001A8
146
147#define FPGA_OPTNAV_GPIO_ADDR 0x8E000026
148#define OPTNAV_I2C_SLAVE_ADDR (0xB0 >> 1)
149#define OPTNAV_IRQ 20
150#define OPTNAV_CHIP_SELECT 19
Asutosh Das853bbcd2012-02-01 10:40:05 +0530151#define PMIC_GPIO_SDC4_PWR_EN_N 24 /* PMIC GPIO Number 25 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700152
153/* Macros assume PMIC GPIOs start at 0 */
154#define PM8058_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio + NR_GPIO_IRQS)
155#define PM8058_GPIO_SYS_TO_PM(sys_gpio) (sys_gpio - NR_GPIO_IRQS)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530156#define PM8058_MPP_BASE PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS)
157#define PM8058_MPP_PM_TO_SYS(pm_gpio) (pm_gpio + PM8058_MPP_BASE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700158
159#define PMIC_GPIO_FLASH_BOOST_ENABLE 15 /* PMIC GPIO Number 16 */
160#define PMIC_GPIO_HAP_ENABLE 16 /* PMIC GPIO Number 17 */
161
162#define PMIC_GPIO_WLAN_EXT_POR 22 /* PMIC GPIO NUMBER 23 */
163
164#define BMA150_GPIO_INT 1
165
166#define HAP_LVL_SHFT_MSM_GPIO 24
167
168#define PMIC_GPIO_QUICKVX_CLK 37 /* PMIC GPIO 38 */
169
170#define PM_FLIP_MPP 5 /* PMIC MPP 06 */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530171
Pankaj Kumarac69ee62012-01-26 00:21:56 +0530172#define DDR1_BANK_BASE 0X20000000
173#define DDR2_BANK_BASE 0X40000000
174
175static unsigned int phys_add = DDR2_BANK_BASE;
176unsigned long ebi1_phys_offset = DDR2_BANK_BASE;
177EXPORT_SYMBOL(ebi1_phys_offset);
178
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530179struct pm8xxx_gpio_init_info {
180 unsigned gpio;
181 struct pm_gpio config;
182};
183
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700184static int pm8058_gpios_init(void)
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100185{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700186 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700187
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530188 struct pm8xxx_gpio_init_info sdc4_en = {
189 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_EN_N),
190 {
191 .direction = PM_GPIO_DIR_OUT,
192 .pull = PM_GPIO_PULL_NO,
193 .vin_sel = PM8058_GPIO_VIN_L5,
194 .function = PM_GPIO_FUNC_NORMAL,
195 .inv_int_pol = 0,
196 .out_strength = PM_GPIO_STRENGTH_LOW,
197 .output_value = 0,
198 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700199 };
200
Asutosh Das853bbcd2012-02-01 10:40:05 +0530201 struct pm8xxx_gpio_init_info sdc4_pwr_en = {
202 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
203 {
204 .direction = PM_GPIO_DIR_OUT,
205 .pull = PM_GPIO_PULL_NO,
206 .vin_sel = PM8058_GPIO_VIN_L5,
207 .function = PM_GPIO_FUNC_NORMAL,
208 .inv_int_pol = 0,
209 .out_strength = PM_GPIO_STRENGTH_LOW,
210 .output_value = 0,
211 },
212 };
213
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530214 struct pm8xxx_gpio_init_info haptics_enable = {
215 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
216 {
217 .direction = PM_GPIO_DIR_OUT,
218 .pull = PM_GPIO_PULL_NO,
219 .out_strength = PM_GPIO_STRENGTH_HIGH,
220 .function = PM_GPIO_FUNC_NORMAL,
221 .inv_int_pol = 0,
222 .vin_sel = 2,
223 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
224 .output_value = 0,
225 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700226 };
227
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530228 struct pm8xxx_gpio_init_info hdmi_5V_en = {
229 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HDMI_5V_EN_V3),
230 {
231 .direction = PM_GPIO_DIR_OUT,
232 .pull = PM_GPIO_PULL_NO,
233 .vin_sel = PM8058_GPIO_VIN_VPH,
234 .function = PM_GPIO_FUNC_NORMAL,
235 .out_strength = PM_GPIO_STRENGTH_LOW,
236 .output_value = 0,
237 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700238 };
239
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530240 struct pm8xxx_gpio_init_info flash_boost_enable = {
241 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE),
242 {
243 .direction = PM_GPIO_DIR_OUT,
244 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
245 .output_value = 0,
246 .pull = PM_GPIO_PULL_NO,
247 .vin_sel = PM8058_GPIO_VIN_S3,
248 .out_strength = PM_GPIO_STRENGTH_HIGH,
249 .function = PM_GPIO_FUNC_2,
250 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700251 };
252
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530253 struct pm8xxx_gpio_init_info gpio23 = {
254 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_WLAN_EXT_POR),
255 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700256 .direction = PM_GPIO_DIR_OUT,
257 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
258 .output_value = 0,
259 .pull = PM_GPIO_PULL_NO,
260 .vin_sel = 2,
261 .out_strength = PM_GPIO_STRENGTH_LOW,
262 .function = PM_GPIO_FUNC_NORMAL,
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100263 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700264 };
265
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530266 struct pm8xxx_gpio_init_info sdcc_det = {
267 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1),
268 {
269 .direction = PM_GPIO_DIR_IN,
270 .pull = PM_GPIO_PULL_UP_1P5,
271 .vin_sel = 2,
272 .function = PM_GPIO_FUNC_NORMAL,
273 .inv_int_pol = 0,
274 },
275 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700276
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530277 if (machine_is_msm7x30_fluid())
278 sdcc_det.config.inv_int_pol = 1;
279
280 rc = pm8xxx_gpio_config(sdcc_det.gpio, &sdcc_det.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700281 if (rc) {
282 pr_err("%s PMIC_GPIO_SD_DET config failed\n", __func__);
283 return rc;
284 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700285
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530286 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
287 machine_is_msm7x30_fluid())
288 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V2;
289 else
290 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V3;
291
292 hdmi_5V_en.gpio = PM8058_GPIO_PM_TO_SYS(hdmi_5V_en.gpio);
293
294 rc = pm8xxx_gpio_config(hdmi_5V_en.gpio, &hdmi_5V_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700295 if (rc) {
296 pr_err("%s PMIC_GPIO_HDMI_5V_EN config failed\n", __func__);
297 return rc;
298 }
299
300 /* Deassert GPIO#23 (source for Ext_POR on WLAN-Volans) */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530301 rc = pm8xxx_gpio_config(gpio23.gpio, &gpio23.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700302 if (rc) {
303 pr_err("%s PMIC_GPIO_WLAN_EXT_POR config failed\n", __func__);
304 return rc;
305 }
306
307 if (machine_is_msm7x30_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530308 /* Haptics gpio */
309 rc = pm8xxx_gpio_config(haptics_enable.gpio,
310 &haptics_enable.config);
311 if (rc) {
312 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
313 haptics_enable.gpio);
314 return rc;
315 }
316 /* Flash boost gpio */
317 rc = pm8xxx_gpio_config(flash_boost_enable.gpio,
318 &flash_boost_enable.config);
319 if (rc) {
320 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
321 flash_boost_enable.gpio);
322 return rc;
323 }
324 /* SCD4 gpio */
325 rc = pm8xxx_gpio_config(sdc4_en.gpio, &sdc4_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700326 if (rc) {
327 pr_err("%s PMIC_GPIO_SDC4_EN_N config failed\n",
328 __func__);
329 return rc;
330 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530331 rc = gpio_request(sdc4_en.gpio, "sdc4_en");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700332 if (rc) {
333 pr_err("%s PMIC_GPIO_SDC4_EN_N gpio_request failed\n",
334 __func__);
335 return rc;
336 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530337 gpio_set_value_cansleep(sdc4_en.gpio, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700338 }
Asutosh Das853bbcd2012-02-01 10:40:05 +0530339 /* FFA -> gpio_25 controls vdd of sdcc4 */
340 else {
341 /* SCD4 gpio_25 */
342 rc = pm8xxx_gpio_config(sdc4_pwr_en.gpio, &sdc4_pwr_en.config);
343 if (rc) {
344 pr_err("%s PMIC_GPIO_SDC4_PWR_EN_N config failed: %d\n",
345 __func__, rc);
346 return rc;
347 }
348
349 rc = gpio_request(sdc4_pwr_en.gpio, "sdc4_pwr_en");
350 if (rc) {
351 pr_err("PMIC_GPIO_SDC4_PWR_EN_N gpio_req failed: %d\n",
352 rc);
353 return rc;
354 }
355 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700356
357 return 0;
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100358}
359
Justin Paupore637a25d2011-07-14 17:11:04 -0700360/* Regulator API support */
361
362#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
363static struct platform_device msm_proccomm_regulator_dev = {
364 .name = PROCCOMM_REGULATOR_DEV_NAME,
365 .id = -1,
366 .dev = {
367 .platform_data = &msm7x30_proccomm_regulator_data
368 }
369};
370#endif
371
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700372/*virtual key support */
373static ssize_t tma300_vkeys_show(struct kobject *kobj,
374 struct kobj_attribute *attr, char *buf)
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100375{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700376 return sprintf(buf,
377 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":50:842:80:100"
378 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":170:842:80:100"
379 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":290:842:80:100"
380 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":410:842:80:100"
381 "\n");
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100382}
383
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700384static struct kobj_attribute tma300_vkeys_attr = {
385 .attr = {
386 .mode = S_IRUGO,
387 },
388 .show = &tma300_vkeys_show,
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530389};
390
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700391static struct attribute *tma300_properties_attrs[] = {
392 &tma300_vkeys_attr.attr,
393 NULL
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530394};
395
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700396static struct attribute_group tma300_properties_attr_group = {
397 .attrs = tma300_properties_attrs,
398};
399
400static struct kobject *properties_kobj;
Justin Paupore3f40f342011-08-10 18:52:16 -0700401static struct regulator_bulk_data cyttsp_regs[] = {
402 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
403 { .supply = "ldo15", .min_uV = 3050000, .max_uV = 3100000 },
404};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700405
406#define CYTTSP_TS_GPIO_IRQ 150
407static int cyttsp_platform_init(struct i2c_client *client)
408{
409 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700410
Justin Paupore3f40f342011-08-10 18:52:16 -0700411 rc = regulator_bulk_get(NULL, ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700412
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700413 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700414 pr_err("%s: could not get regulators: %d\n", __func__, rc);
415 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700416 }
417
Justin Paupore3f40f342011-08-10 18:52:16 -0700418 rc = regulator_bulk_set_voltage(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
419
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700420 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700421 pr_err("%s: could not set regulator voltages: %d\n", __func__,
422 rc);
423 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700424 }
425
Justin Paupore3f40f342011-08-10 18:52:16 -0700426 rc = regulator_bulk_enable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700427
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700428 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700429 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
430 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700431 }
432
433 /* check this device active by reading first byte/register */
434 rc = i2c_smbus_read_byte_data(client, 0x01);
435 if (rc < 0) {
436 pr_err("%s: i2c sanity check failed\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -0700437 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700438 }
439
440 rc = gpio_tlmm_config(GPIO_CFG(CYTTSP_TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
441 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
442 if (rc) {
443 pr_err("%s: Could not configure gpio %d\n",
444 __func__, CYTTSP_TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -0700445 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700446 }
447
448 /* virtual keys */
449 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
450 properties_kobj = kobject_create_and_add("board_properties",
451 NULL);
452 if (properties_kobj)
453 rc = sysfs_create_group(properties_kobj,
454 &tma300_properties_attr_group);
455 if (!properties_kobj || rc)
456 pr_err("%s: failed to create board_properties\n",
457 __func__);
458
459 return CY_OK;
460
Justin Paupore3f40f342011-08-10 18:52:16 -0700461regs_disable:
462 regulator_bulk_disable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
463regs_free:
464 regulator_bulk_free(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
465out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700466 return rc;
467}
468
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530469/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
470static int cyttsp_platform_suspend(struct i2c_client *client)
471{
472 msleep(20);
473
474 return CY_OK;
475}
476
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700477static int cyttsp_platform_resume(struct i2c_client *client)
478{
479 /* add any special code to strobe a wakeup pin or chip reset */
480 mdelay(10);
481
482 return CY_OK;
483}
484
485static struct cyttsp_platform_data cyttsp_data = {
486 .fw_fname = "cyttsp_7630_fluid.hex",
487 .panel_maxx = 479,
488 .panel_maxy = 799,
489 .disp_maxx = 469,
490 .disp_maxy = 799,
491 .disp_minx = 10,
492 .disp_miny = 0,
493 .flags = 0,
494 .gen = CY_GEN3, /* or */
495 .use_st = CY_USE_ST,
496 .use_mt = CY_USE_MT,
497 .use_hndshk = CY_SEND_HNDSHK,
498 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +0530499 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700500 .use_gestures = CY_USE_GESTURES,
501 /* activate up to 4 groups
502 * and set active distance
503 */
504 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
505 CY_GEST_GRP3 | CY_GEST_GRP4 |
506 CY_ACT_DIST,
507 /* change act_intrvl to customize the Active power state
508 * scanning/processing refresh interval for Operating mode
509 */
510 .act_intrvl = CY_ACT_INTRVL_DFLT,
511 /* change tch_tmout to customize the touch timeout for the
512 * Active power state for Operating mode
513 */
514 .tch_tmout = CY_TCH_TMOUT_DFLT,
515 /* change lp_intrvl to customize the Low Power power state
516 * scanning/processing refresh interval for Operating mode
517 */
518 .lp_intrvl = CY_LP_INTRVL_DFLT,
519 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530520 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700521 .init = cyttsp_platform_init,
522 .sleep_gpio = -1,
523 .resout_gpio = -1,
524 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
Mohan Pallaka49c37d62011-08-01 11:52:00 +0530525 .correct_fw_ver = 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700526};
527
528static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
529{
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530530 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700531 .direction = PM_GPIO_DIR_OUT,
532 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
533 .output_value = 0,
534 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530535 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700536 .out_strength = PM_GPIO_STRENGTH_HIGH,
537 .function = PM_GPIO_FUNC_2,
538 };
539 int rc = -EINVAL;
540 int id, mode, max_mA;
541
542 id = mode = max_mA = 0;
543 switch (ch) {
544 case 0:
545 case 1:
546 case 2:
547 if (on) {
548 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530549 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
550 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700551 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530552 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700553 __func__, id, rc);
554 }
555 break;
556
557 case 3:
558 id = PM_PWM_LED_KPD;
559 mode = PM_PWM_CONF_DTEST3;
560 max_mA = 200;
561 break;
562
563 case 4:
564 id = PM_PWM_LED_0;
565 mode = PM_PWM_CONF_PWM1;
566 max_mA = 40;
567 break;
568
569 case 5:
570 id = PM_PWM_LED_2;
571 mode = PM_PWM_CONF_PWM2;
572 max_mA = 40;
573 break;
574
575 case 6:
576 id = PM_PWM_LED_FLASH;
577 mode = PM_PWM_CONF_DTEST3;
578 max_mA = 200;
579 break;
580
581 default:
582 break;
583 }
584
585 if (ch >= 3 && ch <= 6) {
586 if (!on) {
587 mode = PM_PWM_CONF_NONE;
588 max_mA = 0;
589 }
590 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
591 if (rc)
592 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
593 __func__, ch, rc);
594 }
595
596 return rc;
597}
598
599static int pm8058_pwm_enable(struct pwm_device *pwm, int ch, int on)
600{
601 int rc;
602
603 switch (ch) {
604 case 7:
605 rc = pm8058_pwm_set_dtest(pwm, on);
606 if (rc)
607 pr_err("%s: pwm_set_dtest(%d): rc=%d\n",
608 __func__, on, rc);
609 break;
610 default:
611 rc = -EINVAL;
612 break;
613 }
614 return rc;
615}
616
617static const unsigned int fluid_keymap[] = {
618 KEY(0, 0, KEY_7),
619 KEY(0, 1, KEY_ENTER),
620 KEY(0, 2, KEY_UP),
621 /* drop (0,3) as it always shows up in pair with(0,2) */
622 KEY(0, 4, KEY_DOWN),
623
624 KEY(1, 0, KEY_CAMERA_SNAPSHOT),
625 KEY(1, 1, KEY_SELECT),
626 KEY(1, 2, KEY_1),
627 KEY(1, 3, KEY_VOLUMEUP),
628 KEY(1, 4, KEY_VOLUMEDOWN),
629};
630
631static const unsigned int surf_keymap[] = {
632 KEY(0, 0, KEY_7),
633 KEY(0, 1, KEY_DOWN),
634 KEY(0, 2, KEY_UP),
635 KEY(0, 3, KEY_RIGHT),
636 KEY(0, 4, KEY_ENTER),
637 KEY(0, 5, KEY_L),
638 KEY(0, 6, KEY_BACK),
639 KEY(0, 7, KEY_M),
640
641 KEY(1, 0, KEY_LEFT),
642 KEY(1, 1, KEY_SEND),
643 KEY(1, 2, KEY_1),
644 KEY(1, 3, KEY_4),
645 KEY(1, 4, KEY_CLEAR),
646 KEY(1, 5, KEY_MSDOS),
647 KEY(1, 6, KEY_SPACE),
648 KEY(1, 7, KEY_COMMA),
649
650 KEY(2, 0, KEY_6),
651 KEY(2, 1, KEY_5),
652 KEY(2, 2, KEY_8),
653 KEY(2, 3, KEY_3),
654 KEY(2, 4, KEY_NUMERIC_STAR),
655 KEY(2, 5, KEY_UP),
656 KEY(2, 6, KEY_DOWN), /* SYN */
657 KEY(2, 7, KEY_LEFTSHIFT),
658
659 KEY(3, 0, KEY_9),
660 KEY(3, 1, KEY_NUMERIC_POUND),
661 KEY(3, 2, KEY_0),
662 KEY(3, 3, KEY_2),
663 KEY(3, 4, KEY_SLEEP),
664 KEY(3, 5, KEY_F1),
665 KEY(3, 6, KEY_F2),
666 KEY(3, 7, KEY_F3),
667
668 KEY(4, 0, KEY_BACK),
669 KEY(4, 1, KEY_HOME),
670 KEY(4, 2, KEY_MENU),
671 KEY(4, 3, KEY_VOLUMEUP),
672 KEY(4, 4, KEY_VOLUMEDOWN),
673 KEY(4, 5, KEY_F4),
674 KEY(4, 6, KEY_F5),
675 KEY(4, 7, KEY_F6),
676
677 KEY(5, 0, KEY_R),
678 KEY(5, 1, KEY_T),
679 KEY(5, 2, KEY_Y),
680 KEY(5, 3, KEY_LEFTALT),
681 KEY(5, 4, KEY_KPENTER),
682 KEY(5, 5, KEY_Q),
683 KEY(5, 6, KEY_W),
684 KEY(5, 7, KEY_E),
685
686 KEY(6, 0, KEY_F),
687 KEY(6, 1, KEY_G),
688 KEY(6, 2, KEY_H),
689 KEY(6, 3, KEY_CAPSLOCK),
690 KEY(6, 4, KEY_PAGEUP),
691 KEY(6, 5, KEY_A),
692 KEY(6, 6, KEY_S),
693 KEY(6, 7, KEY_D),
694
695 KEY(7, 0, KEY_V),
696 KEY(7, 1, KEY_B),
697 KEY(7, 2, KEY_N),
698 KEY(7, 3, KEY_MENU), /* REVISIT - SYM */
699 KEY(7, 4, KEY_PAGEDOWN),
700 KEY(7, 5, KEY_Z),
701 KEY(7, 6, KEY_X),
702 KEY(7, 7, KEY_C),
703
704 KEY(8, 0, KEY_P),
705 KEY(8, 1, KEY_J),
706 KEY(8, 2, KEY_K),
707 KEY(8, 3, KEY_INSERT),
708 KEY(8, 4, KEY_LINEFEED),
709 KEY(8, 5, KEY_U),
710 KEY(8, 6, KEY_I),
711 KEY(8, 7, KEY_O),
712
713 KEY(9, 0, KEY_4),
714 KEY(9, 1, KEY_5),
715 KEY(9, 2, KEY_6),
716 KEY(9, 3, KEY_7),
717 KEY(9, 4, KEY_8),
718 KEY(9, 5, KEY_1),
719 KEY(9, 6, KEY_2),
720 KEY(9, 7, KEY_3),
721
722 KEY(10, 0, KEY_F7),
723 KEY(10, 1, KEY_F8),
724 KEY(10, 2, KEY_F9),
725 KEY(10, 3, KEY_F10),
726 KEY(10, 4, KEY_FN),
727 KEY(10, 5, KEY_9),
728 KEY(10, 6, KEY_0),
729 KEY(10, 7, KEY_DOT),
730
731 KEY(11, 0, KEY_LEFTCTRL),
732 KEY(11, 1, KEY_F11), /* START */
733 KEY(11, 2, KEY_ENTER),
734 KEY(11, 3, KEY_SEARCH),
735 KEY(11, 4, KEY_DELETE),
736 KEY(11, 5, KEY_RIGHT),
737 KEY(11, 6, KEY_LEFT),
738 KEY(11, 7, KEY_RIGHTSHIFT),
739};
740
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700741static struct matrix_keymap_data surf_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530742 .keymap_size = ARRAY_SIZE(surf_keymap),
743 .keymap = surf_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700744};
745
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530746static struct pm8xxx_keypad_platform_data surf_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700747 .input_name = "surf_keypad",
748 .input_phys_device = "surf_keypad/input0",
749 .num_rows = 12,
750 .num_cols = 8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530751 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
752 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
753 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700754 .scan_delay_ms = 32,
755 .row_hold_ns = 91500,
756 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530757 .keymap_data = &surf_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700758};
759
760static struct matrix_keymap_data fluid_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530761 .keymap_size = ARRAY_SIZE(fluid_keymap),
762 .keymap = fluid_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700763};
764
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530765static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700766 .input_name = "fluid-keypad",
767 .input_phys_device = "fluid-keypad/input0",
768 .num_rows = 5,
769 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530770 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
771 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
772 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700773 .scan_delay_ms = 32,
774 .row_hold_ns = 91500,
775 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530776 .keymap_data = &fluid_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700777};
778
779static struct pm8058_pwm_pdata pm8058_pwm_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530780 .config = pm8058_pwm_config,
781 .enable = pm8058_pwm_enable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700782};
783
784static struct pmic8058_led pmic8058_ffa_leds[] = {
785 [0] = {
786 .name = "keyboard-backlight",
787 .max_brightness = 15,
788 .id = PMIC8058_ID_LED_KB_LIGHT,
Dima Zavinba5499e2011-01-10 11:00:30 -0800789 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700790};
791
792static struct pmic8058_leds_platform_data pm8058_ffa_leds_data = {
793 .num_leds = ARRAY_SIZE(pmic8058_ffa_leds),
794 .leds = pmic8058_ffa_leds,
795};
796
797static struct pmic8058_led pmic8058_surf_leds[] = {
798 [0] = {
799 .name = "keyboard-backlight",
800 .max_brightness = 15,
801 .id = PMIC8058_ID_LED_KB_LIGHT,
Dima Zavinba5499e2011-01-10 11:00:30 -0800802 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700803 [1] = {
804 .name = "voice:red",
805 .max_brightness = 20,
806 .id = PMIC8058_ID_LED_0,
Dima Zavinba5499e2011-01-10 11:00:30 -0800807 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700808 [2] = {
809 .name = "wlan:green",
810 .max_brightness = 20,
811 .id = PMIC8058_ID_LED_2,
812 },
813};
814
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700815static struct pmic8058_leds_platform_data pm8058_surf_leds_data = {
816 .num_leds = ARRAY_SIZE(pmic8058_surf_leds),
817 .leds = pmic8058_surf_leds,
818};
819
820static struct pmic8058_led pmic8058_fluid_leds[] = {
821 [0] = {
822 .name = "keyboard-backlight",
823 .max_brightness = 15,
824 .id = PMIC8058_ID_LED_KB_LIGHT,
825 },
826 [1] = {
827 .name = "flash:led_0",
828 .max_brightness = 15,
829 .id = PMIC8058_ID_FLASH_LED_0,
830 },
831 [2] = {
832 .name = "flash:led_1",
833 .max_brightness = 15,
834 .id = PMIC8058_ID_FLASH_LED_1,
835 },
836};
837
838static struct pmic8058_leds_platform_data pm8058_fluid_leds_data = {
839 .num_leds = ARRAY_SIZE(pmic8058_fluid_leds),
840 .leds = pmic8058_fluid_leds,
841};
842
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530843static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata = {
844 .irq_base = PMIC8058_IRQ_BASE,
845 .devirq = MSM_GPIO_TO_INT(PMIC_GPIO_INT),
846 .irq_trigger_flag = IRQF_TRIGGER_LOW,
847};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700848
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530849static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata = {
850 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
851};
852
853static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata = {
854 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
855};
856
857static struct pm8058_platform_data pm8058_7x30_data = {
858 .irq_pdata = &pm8xxx_irq_pdata,
859 .gpio_pdata = &pm8xxx_gpio_pdata,
860 .mpp_pdata = &pm8xxx_mpp_pdata,
861 .pwm_pdata = &pm8058_pwm_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700862};
863
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530864#ifdef CONFIG_MSM_SSBI
865static struct msm_ssbi_platform_data msm7x30_ssbi_pm8058_pdata = {
Kenneth Heitke48952912012-01-12 14:02:06 -0700866 .rsl_id = "D:PMIC_SSBI",
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530867 .controller_type = MSM_SBI_CTRL_SSBI2,
868 .slave = {
869 .name = "pm8058-core",
870 .platform_data = &pm8058_7x30_data,
871 },
872};
873#endif
874
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700875static struct i2c_board_info cy8info[] __initdata = {
876 {
877 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
878 .platform_data = &cyttsp_data,
879#ifndef CY_USE_TIMER
880 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
881#endif /* CY_USE_TIMER */
882 },
883};
884
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700885#ifdef CONFIG_MSM_CAMERA_V4L2
886static struct msm_camera_device_platform_data msm_camera_csi_device_data[] = {
887 {
Sreesudhan Ramakrish Ramkumar5ad18cd2012-09-07 23:22:34 -0700888 .csiphy_core = 0,
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700889 .csid_core = 0,
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700890 .is_vpe = 1,
891 .ioclk = {
892 .vfe_clk_rate = 153600000,
893 },
894 },
Sreesudhan Ramakrish Ramkumar66deac32012-04-05 10:15:38 -0700895 {
Sreesudhan Ramakrish Ramkumar5ad18cd2012-09-07 23:22:34 -0700896 .csiphy_core = 0,
Sreesudhan Ramakrish Ramkumar66deac32012-04-05 10:15:38 -0700897 .csid_core = 0,
898 .is_vpe = 1,
899 .ioclk = {
900 .vfe_clk_rate = 153600000,
901 },
902 },
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700903};
904
905static struct camera_vreg_t msm_7x30_back_cam_vreg[] = {
906 {"gp2", REG_LDO, 2600000, 2600000, -1},
907 {"lvsw1", REG_VS, 0, 0, 0},
908};
909
910static uint32_t camera_off_gpio_table[] = {
911 /* parallel CAMERA interfaces */
912 /* RST */
913 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
914 /* DAT2 */
915 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
916 /* DAT3 */
917 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
918 /* DAT4 */
919 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
920 /* DAT5 */
921 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
922 /* DAT6 */
923 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
924 /* DAT7 */
925 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
926 /* DAT8 */
927 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
928 /* DAT9 */
929 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
930 /* DAT10 */
931 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
932 /* DAT11 */
933 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
934 /* PCLK */
935 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
936 /* HSYNC_IN */
937 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
938 /* VSYNC_IN */
939 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
940 /* MCLK */
941 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
942};
943
944static uint32_t camera_on_gpio_table[] = {
945 /* parallel CAMERA interfaces */
946 /* RST */
947 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
948 /* DAT2 */
949 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
950 /* DAT3 */
951 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
952 /* DAT4 */
953 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
954 /* DAT5 */
955 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
956 /* DAT6 */
957 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
958 /* DAT7 */
959 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
960 /* DAT8 */
961 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
962 /* DAT9 */
963 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
964 /* DAT10 */
965 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
966 /* DAT11 */
967 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
968 /* PCLK */
969 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
970 /* HSYNC_IN */
971 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
972 /* VSYNC_IN */
973 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
974 /* MCLK */
975 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
976};
977
978static struct gpio msm7x30_back_cam_gpio[] = {
979 {0, GPIOF_DIR_OUT, "CAM_RESET"},
980};
981
982static struct msm_gpio_set_tbl msm7x30_back_cam_gpio_set_tbl[] = {
983 {0, GPIOF_OUT_INIT_LOW, 1000},
984 {0, GPIOF_OUT_INIT_HIGH, 4000},
985};
986
987static struct msm_camera_gpio_conf msm_7x30_back_cam_gpio_conf = {
988 .cam_gpio_req_tbl = msm7x30_back_cam_gpio,
989 .cam_gpio_req_tbl_size = ARRAY_SIZE(msm7x30_back_cam_gpio),
990 .cam_gpio_set_tbl = msm7x30_back_cam_gpio_set_tbl,
991 .cam_gpio_set_tbl_size = ARRAY_SIZE(msm7x30_back_cam_gpio_set_tbl),
992 .camera_off_table = camera_off_gpio_table,
993 .camera_off_table_size = ARRAY_SIZE(camera_off_gpio_table),
994 .camera_on_table = camera_on_gpio_table,
995 .camera_on_table_size = ARRAY_SIZE(camera_on_gpio_table),
996 .gpio_no_mux = 1,
997};
998
999static struct msm_camera_sensor_flash_data flash_vx6953 = {
1000 .flash_type = MSM_CAMERA_FLASH_NONE,
1001};
1002
1003static struct msm_camera_sensor_platform_info sensor_board_info_vx6953 = {
1004 .mount_angle = 0,
1005 .cam_vreg = msm_7x30_back_cam_vreg,
1006 .num_vreg = ARRAY_SIZE(msm_7x30_back_cam_vreg),
1007 .gpio_conf = &msm_7x30_back_cam_gpio_conf,
1008};
1009
1010static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1011 .sensor_name = "vx6953",
1012 .pdata = &msm_camera_csi_device_data[0],
1013 .flash_data = &flash_vx6953,
1014 .sensor_platform_info = &sensor_board_info_vx6953,
1015 .csi_if = 1,
1016 .camera_type = BACK_CAMERA_2D,
1017};
1018
Kevin Chan94b4c832012-03-02 21:27:16 -08001019static struct platform_device msm_camera_server = {
1020 .name = "msm_cam_server",
1021 .id = 0,
1022};
1023
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001024void __init msm7x30_init_cam(void)
1025{
Kevin Chan94b4c832012-03-02 21:27:16 -08001026 platform_device_register(&msm_camera_server);
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001027 platform_device_register(&msm_device_csic0);
1028 platform_device_register(&msm_device_vfe);
1029 platform_device_register(&msm_device_vpe);
1030}
1031
1032#ifdef CONFIG_I2C
1033static struct i2c_board_info msm_camera_boardinfo[] = {
1034 {
1035 I2C_BOARD_INFO("vx6953", 0x20),
1036 .platform_data = &msm_camera_sensor_vx6953_data,
1037 },
1038};
1039#endif
1040#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001041static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
1042#ifdef CONFIG_MT9D112
1043 {
1044 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
Dima Zavinba5499e2011-01-10 11:00:30 -08001045 },
1046#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001047#ifdef CONFIG_WEBCAM_OV9726
1048 {
1049 I2C_BOARD_INFO("ov9726", 0x10),
1050 },
1051#endif
1052#ifdef CONFIG_S5K3E2FX
1053 {
1054 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
1055 },
1056#endif
1057#ifdef CONFIG_MT9P012
1058 {
1059 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
1060 },
1061#endif
1062#ifdef CONFIG_VX6953
1063 {
1064 I2C_BOARD_INFO("vx6953", 0x20),
1065 },
1066#endif
1067#ifdef CONFIG_MT9E013
1068 {
1069 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
1070 },
1071#endif
1072#ifdef CONFIG_SN12M0PZ
1073 {
1074 I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1),
1075 },
1076#endif
1077#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
1078 {
1079 I2C_BOARD_INFO("mt9t013", 0x6C),
1080 },
1081#endif
1082
Dima Zavinba5499e2011-01-10 11:00:30 -08001083};
1084
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001085#ifdef CONFIG_MSM_CAMERA
1086#define CAM_STNDBY 143
1087static uint32_t camera_off_vcm_gpio_table[] = {
1088GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */
1089};
1090
1091static uint32_t camera_off_gpio_table[] = {
1092 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001093 /* RST */
1094 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1095 /* DAT2 */
1096 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1097 /* DAT3 */
1098 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1099 /* DAT4 */
1100 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1101 /* DAT5 */
1102 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1103 /* DAT6 */
1104 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1105 /* DAT7 */
1106 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1107 /* DAT8 */
1108 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1109 /* DAT9 */
1110 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1111 /* DAT10 */
1112 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1113 /* DAT11 */
1114 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1115 /* PCLK */
1116 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1117 /* HSYNC_IN */
1118 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1119 /* VSYNC_IN */
1120 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1121 /* MCLK */
1122 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001123};
1124
1125static uint32_t camera_on_vcm_gpio_table[] = {
1126GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */
1127};
1128
1129static uint32_t camera_on_gpio_table[] = {
1130 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001131 /* RST */
1132 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1133 /* DAT2 */
1134 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1135 /* DAT3 */
1136 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1137 /* DAT4 */
1138 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1139 /* DAT5 */
1140 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1141 /* DAT6 */
1142 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1143 /* DAT7 */
1144 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1145 /* DAT8 */
1146 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1147 /* DAT9 */
1148 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1149 /* DAT10 */
1150 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1151 /* DAT11 */
1152 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1153 /* PCLK */
1154 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1155 /* HSYNC_IN */
1156 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1157 /* VSYNC_IN */
1158 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1159 /* MCLK */
1160 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001161};
1162
1163static uint32_t camera_off_gpio_fluid_table[] = {
1164 /* FLUID: CAM_VGA_RST_N */
1165 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1166 /* FLUID: CAMIF_STANDBY */
1167 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1168};
1169
1170static uint32_t camera_on_gpio_fluid_table[] = {
1171 /* FLUID: CAM_VGA_RST_N */
1172 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1173 /* FLUID: CAMIF_STANDBY */
1174 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1175};
1176
1177static void config_gpio_table(uint32_t *table, int len)
1178{
1179 int n, rc;
1180 for (n = 0; n < len; n++) {
1181 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
1182 if (rc) {
1183 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
1184 __func__, table[n], rc);
1185 break;
1186 }
1187 }
1188}
1189static int config_camera_on_gpios(void)
1190{
1191 config_gpio_table(camera_on_gpio_table,
1192 ARRAY_SIZE(camera_on_gpio_table));
1193
1194 if (adie_get_detected_codec_type() != TIMPANI_ID)
1195 /* GPIO1 is shared also used in Timpani RF card so
1196 only configure it for non-Timpani RF card */
1197 config_gpio_table(camera_on_vcm_gpio_table,
1198 ARRAY_SIZE(camera_on_vcm_gpio_table));
1199
1200 if (machine_is_msm7x30_fluid()) {
1201 config_gpio_table(camera_on_gpio_fluid_table,
1202 ARRAY_SIZE(camera_on_gpio_fluid_table));
1203 /* FLUID: turn on 5V booster */
1204 gpio_set_value(
1205 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 1);
1206 /* FLUID: drive high to put secondary sensor to STANDBY */
1207 gpio_set_value(CAM_STNDBY, 1);
1208 }
1209 return 0;
1210}
1211
1212static void config_camera_off_gpios(void)
1213{
1214 config_gpio_table(camera_off_gpio_table,
1215 ARRAY_SIZE(camera_off_gpio_table));
1216
1217 if (adie_get_detected_codec_type() != TIMPANI_ID)
1218 /* GPIO1 is shared also used in Timpani RF card so
1219 only configure it for non-Timpani RF card */
1220 config_gpio_table(camera_off_vcm_gpio_table,
1221 ARRAY_SIZE(camera_off_vcm_gpio_table));
1222
1223 if (machine_is_msm7x30_fluid()) {
1224 config_gpio_table(camera_off_gpio_fluid_table,
1225 ARRAY_SIZE(camera_off_gpio_fluid_table));
1226 /* FLUID: turn off 5V booster */
1227 gpio_set_value(
1228 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 0);
1229 }
1230}
1231
1232struct resource msm_camera_resources[] = {
1233 {
1234 .start = 0xA6000000,
1235 .end = 0xA6000000 + SZ_1M - 1,
1236 .flags = IORESOURCE_MEM,
1237 },
1238 {
1239 .start = INT_VFE,
1240 .end = INT_VFE,
1241 .flags = IORESOURCE_IRQ,
1242 },
1243 {
1244 .flags = IORESOURCE_DMA,
1245 }
1246};
1247
1248struct msm_camera_device_platform_data msm_camera_device_data = {
1249 .camera_gpio_on = config_camera_on_gpios,
1250 .camera_gpio_off = config_camera_off_gpios,
1251 .ioext.camifpadphy = 0xAB000000,
1252 .ioext.camifpadsz = 0x00000400,
1253 .ioext.csiphy = 0xA6100000,
1254 .ioext.csisz = 0x00000400,
1255 .ioext.csiirq = INT_CSI,
1256 .ioclk.mclk_clk_rate = 24000000,
1257 .ioclk.vfe_clk_rate = 147456000,
1258};
1259
1260static struct msm_camera_sensor_flash_src msm_flash_src_pwm = {
1261 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PWM,
1262 ._fsrc.pwm_src.freq = 1000,
1263 ._fsrc.pwm_src.max_load = 300,
1264 ._fsrc.pwm_src.low_load = 30,
1265 ._fsrc.pwm_src.high_load = 100,
1266 ._fsrc.pwm_src.channel = 7,
1267};
1268
1269#ifdef CONFIG_MT9D112
1270static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1271 .flash_type = MSM_CAMERA_FLASH_LED,
1272 .flash_src = &msm_flash_src_pwm
1273};
1274
1275static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1276 .sensor_name = "mt9d112",
1277 .sensor_reset = 0,
1278 .sensor_pwd = 85,
1279 .vcm_pwd = 1,
1280 .vcm_enable = 0,
1281 .pdata = &msm_camera_device_data,
1282 .resource = msm_camera_resources,
1283 .num_resources = ARRAY_SIZE(msm_camera_resources),
1284 .flash_data = &flash_mt9d112,
1285 .csi_if = 0
1286};
1287
1288static struct platform_device msm_camera_sensor_mt9d112 = {
1289 .name = "msm_camera_mt9d112",
1290 .dev = {
1291 .platform_data = &msm_camera_sensor_mt9d112_data,
1292 },
1293};
1294#endif
1295
1296#ifdef CONFIG_WEBCAM_OV9726
1297
1298static struct msm_camera_sensor_platform_info ov9726_sensor_7630_info = {
1299 .mount_angle = 90
1300};
1301
1302static struct msm_camera_sensor_flash_data flash_ov9726 = {
1303 .flash_type = MSM_CAMERA_FLASH_LED,
1304 .flash_src = &msm_flash_src_pwm
1305};
1306static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
1307 .sensor_name = "ov9726",
1308 .sensor_reset = 0,
1309 .sensor_pwd = 85,
1310 .vcm_pwd = 1,
1311 .vcm_enable = 0,
1312 .pdata = &msm_camera_device_data,
1313 .resource = msm_camera_resources,
1314 .num_resources = ARRAY_SIZE(msm_camera_resources),
1315 .flash_data = &flash_ov9726,
1316 .sensor_platform_info = &ov9726_sensor_7630_info,
1317 .csi_if = 1
1318};
1319struct platform_device msm_camera_sensor_ov9726 = {
1320 .name = "msm_camera_ov9726",
1321 .dev = {
1322 .platform_data = &msm_camera_sensor_ov9726_data,
1323 },
1324};
1325#endif
1326
1327#ifdef CONFIG_S5K3E2FX
1328static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1329 .flash_type = MSM_CAMERA_FLASH_LED,
1330 .flash_src = &msm_flash_src_pwm,
1331};
1332
1333static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1334 .sensor_name = "s5k3e2fx",
1335 .sensor_reset = 0,
1336 .sensor_pwd = 85,
1337 .vcm_pwd = 1,
1338 .vcm_enable = 0,
1339 .pdata = &msm_camera_device_data,
1340 .resource = msm_camera_resources,
1341 .num_resources = ARRAY_SIZE(msm_camera_resources),
1342 .flash_data = &flash_s5k3e2fx,
1343 .csi_if = 0
1344};
1345
1346static struct platform_device msm_camera_sensor_s5k3e2fx = {
1347 .name = "msm_camera_s5k3e2fx",
1348 .dev = {
1349 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1350 },
1351};
1352#endif
1353
1354#ifdef CONFIG_MT9P012
1355static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1356 .flash_type = MSM_CAMERA_FLASH_LED,
1357 .flash_src = &msm_flash_src_pwm
1358};
1359
1360static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1361 .sensor_name = "mt9p012",
1362 .sensor_reset = 0,
1363 .sensor_pwd = 85,
1364 .vcm_pwd = 1,
1365 .vcm_enable = 1,
1366 .pdata = &msm_camera_device_data,
1367 .resource = msm_camera_resources,
1368 .num_resources = ARRAY_SIZE(msm_camera_resources),
1369 .flash_data = &flash_mt9p012,
1370 .csi_if = 0
1371};
1372
1373static struct platform_device msm_camera_sensor_mt9p012 = {
1374 .name = "msm_camera_mt9p012",
1375 .dev = {
1376 .platform_data = &msm_camera_sensor_mt9p012_data,
1377 },
1378};
1379#endif
1380
1381#ifdef CONFIG_MT9E013
1382static struct msm_camera_sensor_platform_info mt9e013_sensor_7630_info = {
1383 .mount_angle = 0
1384};
1385
1386static struct msm_camera_sensor_flash_data flash_mt9e013 = {
1387 .flash_type = MSM_CAMERA_FLASH_LED,
1388 .flash_src = &msm_flash_src_pwm
1389};
1390
1391static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
1392 .sensor_name = "mt9e013",
1393 .sensor_reset = 0,
1394 .sensor_pwd = 85,
1395 .vcm_pwd = 1,
1396 .vcm_enable = 1,
1397 .pdata = &msm_camera_device_data,
1398 .resource = msm_camera_resources,
1399 .num_resources = ARRAY_SIZE(msm_camera_resources),
1400 .flash_data = &flash_mt9e013,
1401 .sensor_platform_info = &mt9e013_sensor_7630_info,
1402 .csi_if = 1
1403};
1404
1405static struct platform_device msm_camera_sensor_mt9e013 = {
1406 .name = "msm_camera_mt9e013",
1407 .dev = {
1408 .platform_data = &msm_camera_sensor_mt9e013_data,
1409 },
1410};
1411#endif
1412
1413#ifdef CONFIG_VX6953
Jilai Wang971f97f2011-07-13 14:25:25 -04001414static struct msm_camera_sensor_platform_info vx6953_sensor_7630_info = {
1415 .mount_angle = 0
1416};
1417
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001418static struct msm_camera_sensor_flash_data flash_vx6953 = {
1419 .flash_type = MSM_CAMERA_FLASH_LED,
1420 .flash_src = &msm_flash_src_pwm
1421};
1422static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1423 .sensor_name = "vx6953",
1424 .sensor_reset = 0,
1425 .sensor_pwd = 85,
1426 .vcm_pwd = 1,
1427 .vcm_enable = 0,
1428 .pdata = &msm_camera_device_data,
1429 .resource = msm_camera_resources,
1430 .num_resources = ARRAY_SIZE(msm_camera_resources),
Jilai Wang971f97f2011-07-13 14:25:25 -04001431 .sensor_platform_info = &vx6953_sensor_7630_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001432 .flash_data = &flash_vx6953,
1433 .csi_if = 1
1434};
1435static struct platform_device msm_camera_sensor_vx6953 = {
1436 .name = "msm_camera_vx6953",
1437 .dev = {
1438 .platform_data = &msm_camera_sensor_vx6953_data,
1439 },
1440};
1441#endif
1442
1443#ifdef CONFIG_SN12M0PZ
1444static struct msm_camera_sensor_flash_src msm_flash_src_current_driver = {
1445 .flash_sr_type = MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER,
1446 ._fsrc.current_driver_src.low_current = 210,
1447 ._fsrc.current_driver_src.high_current = 700,
1448 ._fsrc.current_driver_src.driver_channel = &pm8058_fluid_leds_data,
1449};
1450
1451static struct msm_camera_sensor_flash_data flash_sn12m0pz = {
1452 .flash_type = MSM_CAMERA_FLASH_LED,
1453 .flash_src = &msm_flash_src_current_driver
1454};
1455static struct msm_camera_sensor_info msm_camera_sensor_sn12m0pz_data = {
1456 .sensor_name = "sn12m0pz",
1457 .sensor_reset = 0,
1458 .sensor_pwd = 85,
1459 .vcm_pwd = 1,
1460 .vcm_enable = 1,
1461 .pdata = &msm_camera_device_data,
1462 .flash_data = &flash_sn12m0pz,
1463 .resource = msm_camera_resources,
1464 .num_resources = ARRAY_SIZE(msm_camera_resources),
1465 .csi_if = 0
1466};
1467
1468static struct platform_device msm_camera_sensor_sn12m0pz = {
1469 .name = "msm_camera_sn12m0pz",
1470 .dev = {
1471 .platform_data = &msm_camera_sensor_sn12m0pz_data,
1472 },
1473};
1474#endif
1475
1476#ifdef CONFIG_MT9T013
1477static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1478 .flash_type = MSM_CAMERA_FLASH_LED,
1479 .flash_src = &msm_flash_src_pwm
1480};
1481
1482static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1483 .sensor_name = "mt9t013",
1484 .sensor_reset = 0,
1485 .sensor_pwd = 85,
1486 .vcm_pwd = 1,
1487 .vcm_enable = 0,
1488 .pdata = &msm_camera_device_data,
1489 .resource = msm_camera_resources,
1490 .num_resources = ARRAY_SIZE(msm_camera_resources),
1491 .flash_data = &flash_mt9t013,
1492 .csi_if = 1
1493};
1494
1495static struct platform_device msm_camera_sensor_mt9t013 = {
1496 .name = "msm_camera_mt9t013",
1497 .dev = {
1498 .platform_data = &msm_camera_sensor_mt9t013_data,
1499 },
1500};
1501#endif
1502
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001503#ifdef CONFIG_MSM_VPE
1504static struct resource msm_vpe_resources[] = {
1505 {
1506 .start = 0xAD200000,
1507 .end = 0xAD200000 + SZ_1M - 1,
1508 .flags = IORESOURCE_MEM,
1509 },
1510 {
1511 .start = INT_VPE,
1512 .end = INT_VPE,
1513 .flags = IORESOURCE_IRQ,
1514 },
1515};
1516
1517static struct platform_device msm_vpe_device = {
1518 .name = "msm_vpe",
1519 .id = 0,
1520 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1521 .resource = msm_vpe_resources,
1522};
1523#endif
1524
1525#endif /*CONFIG_MSM_CAMERA*/
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001526#endif
1527
1528#ifdef CONFIG_MSM_GEMINI
1529static struct resource msm_gemini_resources[] = {
1530 {
1531 .start = 0xA3A00000,
1532 .end = 0xA3A00000 + 0x0150 - 1,
1533 .flags = IORESOURCE_MEM,
1534 },
1535 {
1536 .start = INT_JPEG,
1537 .end = INT_JPEG,
1538 .flags = IORESOURCE_IRQ,
1539 },
1540};
1541
1542static struct platform_device msm_gemini_device = {
1543 .name = "msm_gemini",
1544 .resource = msm_gemini_resources,
1545 .num_resources = ARRAY_SIZE(msm_gemini_resources),
1546};
1547#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001548
1549#ifdef CONFIG_MSM7KV2_AUDIO
1550static uint32_t audio_pamp_gpio_config =
1551 GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1552
1553static uint32_t audio_fluid_icodec_tx_config =
1554 GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1555
1556static int __init snddev_poweramp_gpio_init(void)
1557{
1558 int rc;
1559
1560 pr_info("snddev_poweramp_gpio_init \n");
1561 rc = gpio_tlmm_config(audio_pamp_gpio_config, GPIO_CFG_ENABLE);
1562 if (rc) {
1563 printk(KERN_ERR
1564 "%s: gpio_tlmm_config(%#x)=%d\n",
1565 __func__, audio_pamp_gpio_config, rc);
1566 }
1567 return rc;
1568}
1569
1570void msm_snddev_tx_route_config(void)
1571{
1572 int rc;
1573
1574 pr_debug("%s()\n", __func__);
1575
1576 if (machine_is_msm7x30_fluid()) {
1577 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1578 GPIO_CFG_ENABLE);
1579 if (rc) {
1580 printk(KERN_ERR
1581 "%s: gpio_tlmm_config(%#x)=%d\n",
1582 __func__, audio_fluid_icodec_tx_config, rc);
1583 } else
1584 gpio_set_value(85, 0);
1585 }
1586}
1587
1588void msm_snddev_tx_route_deconfig(void)
1589{
1590 int rc;
1591
1592 pr_debug("%s()\n", __func__);
1593
1594 if (machine_is_msm7x30_fluid()) {
1595 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1596 GPIO_CFG_DISABLE);
1597 if (rc) {
1598 printk(KERN_ERR
1599 "%s: gpio_tlmm_config(%#x)=%d\n",
1600 __func__, audio_fluid_icodec_tx_config, rc);
1601 }
1602 }
1603}
1604
1605void msm_snddev_poweramp_on(void)
1606{
1607 gpio_set_value(82, 1); /* enable spkr poweramp */
1608 pr_info("%s: power on amplifier\n", __func__);
1609}
1610
1611void msm_snddev_poweramp_off(void)
1612{
1613 gpio_set_value(82, 0); /* disable spkr poweramp */
1614 pr_info("%s: power off amplifier\n", __func__);
1615}
1616
Justin Paupore3f40f342011-08-10 18:52:16 -07001617static struct regulator_bulk_data snddev_regs[] = {
1618 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
1619 { .supply = "ncp", .min_uV = 1800000, .max_uV = 1800000 },
1620};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001621
Justin Paupore3f40f342011-08-10 18:52:16 -07001622static int __init snddev_hsed_voltage_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001623{
1624 int rc;
1625
Justin Paupore3f40f342011-08-10 18:52:16 -07001626 rc = regulator_bulk_get(NULL, ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001627
Justin Paupore3f40f342011-08-10 18:52:16 -07001628 if (rc) {
1629 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1630 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001631 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001632
1633 rc = regulator_bulk_set_voltage(ARRAY_SIZE(snddev_regs), snddev_regs);
1634
1635 if (rc) {
1636 pr_err("%s: could not set regulator voltages: %d\n",
1637 __func__, rc);
1638 goto regs_free;
1639 }
1640
1641 return 0;
1642
1643regs_free:
1644 regulator_bulk_free(ARRAY_SIZE(snddev_regs), snddev_regs);
1645out:
1646 return rc;
1647}
1648
1649
1650void msm_snddev_hsed_voltage_on(void)
1651{
1652 int rc = regulator_bulk_enable(ARRAY_SIZE(snddev_regs), snddev_regs);
1653
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001654 if (rc)
Justin Paupore3f40f342011-08-10 18:52:16 -07001655 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001656}
1657
1658void msm_snddev_hsed_voltage_off(void)
1659{
Justin Paupore3f40f342011-08-10 18:52:16 -07001660 int rc = regulator_bulk_disable(ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001661
Justin Paupore3f40f342011-08-10 18:52:16 -07001662 if (rc) {
1663 pr_err("%s: could not disable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001664 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001665}
1666
1667static unsigned aux_pcm_gpio_on[] = {
1668 GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
1669 GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
1670 GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
1671 GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
1672};
1673
1674static int __init aux_pcm_gpio_init(void)
1675{
1676 int pin, rc;
1677
1678 pr_info("aux_pcm_gpio_init \n");
1679 for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) {
1680 rc = gpio_tlmm_config(aux_pcm_gpio_on[pin],
1681 GPIO_CFG_ENABLE);
1682 if (rc) {
1683 printk(KERN_ERR
1684 "%s: gpio_tlmm_config(%#x)=%d\n",
1685 __func__, aux_pcm_gpio_on[pin], rc);
1686 }
1687 }
1688 return rc;
1689}
1690
1691static struct msm_gpio mi2s_clk_gpios[] = {
1692 { GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1693 "MI2S_SCLK"},
1694 { GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1695 "MI2S_WS"},
1696 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1697 "MI2S_MCLK_A"},
1698};
1699
1700static struct msm_gpio mi2s_rx_data_lines_gpios[] = {
1701 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1702 "MI2S_DATA_SD0_A"},
1703 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1704 "MI2S_DATA_SD1_A"},
1705 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1706 "MI2S_DATA_SD2_A"},
1707 { GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1708 "MI2S_DATA_SD3"},
1709};
1710
1711static struct msm_gpio mi2s_tx_data_lines_gpios[] = {
1712 { GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1713 "MI2S_DATA_SD3"},
1714};
1715
1716int mi2s_config_clk_gpio(void)
1717{
1718 int rc = 0;
1719
1720 rc = msm_gpios_request_enable(mi2s_clk_gpios,
1721 ARRAY_SIZE(mi2s_clk_gpios));
1722 if (rc) {
1723 pr_err("%s: enable mi2s clk gpios failed\n",
1724 __func__);
1725 return rc;
1726 }
1727 return 0;
1728}
1729
1730int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask)
1731{
1732 int i, rc = 0;
1733 sd_line_mask &= MI2S_SD_LINE_MASK;
1734
1735 switch (direction) {
1736 case DIR_TX:
1737 msm_gpios_disable_free(mi2s_tx_data_lines_gpios, 1);
1738 break;
1739 case DIR_RX:
1740 i = 0;
1741 while (sd_line_mask) {
1742 if (sd_line_mask & 0x1)
1743 msm_gpios_disable_free(
1744 mi2s_rx_data_lines_gpios + i , 1);
1745 sd_line_mask = sd_line_mask >> 1;
1746 i++;
1747 }
1748 break;
1749 default:
1750 pr_err("%s: Invaild direction direction = %u\n",
1751 __func__, direction);
1752 rc = -EINVAL;
1753 break;
1754 }
1755 return rc;
1756}
1757
1758int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask)
1759{
1760 int i , rc = 0;
1761 u8 sd_config_done_mask = 0;
1762
1763 sd_line_mask &= MI2S_SD_LINE_MASK;
1764
1765 switch (direction) {
1766 case DIR_TX:
1767 if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) ||
1768 (sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) {
1769 pr_err("%s: can not use SD0 or SD1 or SD2 for TX"
1770 ".only can use SD3. sd_line_mask = 0x%x\n",
1771 __func__ , sd_line_mask);
1772 rc = -EINVAL;
1773 } else {
1774 rc = msm_gpios_request_enable(mi2s_tx_data_lines_gpios,
1775 1);
1776 if (rc)
1777 pr_err("%s: enable mi2s gpios for TX failed\n",
1778 __func__);
1779 }
1780 break;
1781 case DIR_RX:
1782 i = 0;
1783 while (sd_line_mask && (rc == 0)) {
1784 if (sd_line_mask & 0x1) {
1785 rc = msm_gpios_request_enable(
1786 mi2s_rx_data_lines_gpios + i , 1);
1787 if (rc) {
1788 pr_err("%s: enable mi2s gpios for"
1789 "RX failed. SD line = %s\n",
1790 __func__,
1791 (mi2s_rx_data_lines_gpios + i)->label);
1792 mi2s_unconfig_data_gpio(DIR_RX,
1793 sd_config_done_mask);
1794 } else
1795 sd_config_done_mask |= (1 << i);
1796 }
1797 sd_line_mask = sd_line_mask >> 1;
1798 i++;
1799 }
1800 break;
1801 default:
1802 pr_err("%s: Invaild direction direction = %u\n",
1803 __func__, direction);
1804 rc = -EINVAL;
1805 break;
1806 }
1807 return rc;
1808}
1809
1810int mi2s_unconfig_clk_gpio(void)
1811{
1812 msm_gpios_disable_free(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios));
1813 return 0;
1814}
1815
1816#endif /* CONFIG_MSM7KV2_AUDIO */
1817
1818static int __init buses_init(void)
1819{
1820 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT,
1821 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
1822 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
1823 __func__, PMIC_GPIO_INT);
1824
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301825 if (machine_is_msm8x60_fluid())
1826 pm8058_7x30_data.keypad_pdata = &fluid_keypad_data;
1827 else
1828 pm8058_7x30_data.keypad_pdata = &surf_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001829
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001830 return 0;
1831}
1832
1833#define TIMPANI_RESET_GPIO 1
1834
1835struct bahama_config_register{
1836 u8 reg;
1837 u8 value;
1838 u8 mask;
1839};
1840
1841enum version{
1842 VER_1_0,
1843 VER_2_0,
1844 VER_UNSUPPORTED = 0xFF
1845};
1846
Justin Paupore3f40f342011-08-10 18:52:16 -07001847static struct regulator *vreg_marimba_1;
1848static struct regulator *vreg_marimba_2;
1849static struct regulator *vreg_bahama;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001850
1851static struct msm_gpio timpani_reset_gpio_cfg[] = {
1852{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
1853 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} };
1854
1855static u8 read_bahama_ver(void)
1856{
1857 int rc;
1858 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1859 u8 bahama_version;
1860
1861 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
1862 if (rc < 0) {
1863 printk(KERN_ERR
1864 "%s: version read failed: %d\n",
1865 __func__, rc);
1866 return rc;
1867 } else {
1868 printk(KERN_INFO
1869 "%s: version read got: 0x%x\n",
1870 __func__, bahama_version);
1871 }
1872
1873 switch (bahama_version) {
1874 case 0x08: /* varient of bahama v1 */
1875 case 0x10:
1876 case 0x00:
1877 return VER_1_0;
1878 case 0x09: /* variant of bahama v2 */
1879 return VER_2_0;
1880 default:
1881 return VER_UNSUPPORTED;
1882 }
1883}
1884
1885static int config_timpani_reset(void)
1886{
1887 int rc;
1888
1889 rc = msm_gpios_request_enable(timpani_reset_gpio_cfg,
1890 ARRAY_SIZE(timpani_reset_gpio_cfg));
1891 if (rc < 0) {
1892 printk(KERN_ERR
1893 "%s: msm_gpios_request_enable failed (%d)\n",
1894 __func__, rc);
1895 }
1896 return rc;
1897}
1898
1899static unsigned int msm_timpani_setup_power(void)
1900{
1901 int rc;
1902
1903 rc = config_timpani_reset();
1904 if (rc < 0)
1905 goto out;
1906
Justin Paupore3f40f342011-08-10 18:52:16 -07001907 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001908 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001909 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001910 goto out;
1911 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001912
1913 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001914 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001915 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1916 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001917 }
1918
1919 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1);
1920 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001921 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001922 __func__, rc);
1923 msm_gpios_free(timpani_reset_gpio_cfg,
1924 ARRAY_SIZE(timpani_reset_gpio_cfg));
Justin Paupore3f40f342011-08-10 18:52:16 -07001925 goto disable_marimba_2;
1926 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001927
Justin Paupore3f40f342011-08-10 18:52:16 -07001928 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001929
Justin Paupore3f40f342011-08-10 18:52:16 -07001930disable_marimba_2:
1931 regulator_disable(vreg_marimba_2);
1932disable_marimba_1:
1933 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001934out:
1935 return rc;
1936};
1937
1938static void msm_timpani_shutdown_power(void)
1939{
1940 int rc;
1941
Justin Paupore3f40f342011-08-10 18:52:16 -07001942 rc = regulator_disable(vreg_marimba_2);
1943 if (rc)
1944 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1945
1946 rc = regulator_disable(vreg_marimba_1);
1947 if (rc)
1948 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001949
1950 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0);
Justin Paupore3f40f342011-08-10 18:52:16 -07001951 if (rc < 0)
1952 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001953 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001954
1955 msm_gpios_free(timpani_reset_gpio_cfg,
1956 ARRAY_SIZE(timpani_reset_gpio_cfg));
1957};
1958
1959static unsigned int msm_bahama_core_config(int type)
1960{
1961 int rc = 0;
1962
1963 if (type == BAHAMA_ID) {
1964
1965 int i;
1966 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1967
1968 const struct bahama_config_register v20_init[] = {
1969 /* reg, value, mask */
1970 { 0xF4, 0x84, 0xFF }, /* AREG */
1971 { 0xF0, 0x04, 0xFF } /* DREG */
1972 };
1973
1974 if (read_bahama_ver() == VER_2_0) {
1975 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
1976 u8 value = v20_init[i].value;
1977 rc = marimba_write_bit_mask(&config,
1978 v20_init[i].reg,
1979 &value,
1980 sizeof(v20_init[i].value),
1981 v20_init[i].mask);
1982 if (rc < 0) {
1983 printk(KERN_ERR
1984 "%s: reg %d write failed: %d\n",
1985 __func__, v20_init[i].reg, rc);
1986 return rc;
1987 }
1988 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
1989 " mask 0x%02x\n",
1990 __func__, v20_init[i].reg,
1991 v20_init[i].value, v20_init[i].mask);
1992 }
1993 }
1994 }
1995 printk(KERN_INFO "core type: %d\n", type);
1996
1997 return rc;
1998}
1999
2000static unsigned int msm_bahama_setup_power(void)
2001{
Justin Paupore3f40f342011-08-10 18:52:16 -07002002 int rc = regulator_enable(vreg_bahama);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002003
Justin Paupore3f40f342011-08-10 18:52:16 -07002004 if (rc)
2005 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002006
2007 return rc;
2008};
2009
2010static unsigned int msm_bahama_shutdown_power(int value)
2011{
2012 int rc = 0;
2013
2014 if (value != BAHAMA_ID) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002015 rc = regulator_disable(vreg_bahama);
2016
2017 if (rc)
2018 pr_err("%s: regulator_disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002019 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002020 }
2021
2022 return rc;
2023};
2024
2025static struct msm_gpio marimba_svlte_config_clock[] = {
2026 { GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2027 "MARIMBA_SVLTE_CLOCK_ENABLE" },
2028};
2029
2030static unsigned int msm_marimba_gpio_config_svlte(int gpio_cfg_marimba)
2031{
2032 if (machine_is_msm8x55_svlte_surf() ||
2033 machine_is_msm8x55_svlte_ffa()) {
2034 if (gpio_cfg_marimba)
2035 gpio_set_value(GPIO_PIN
2036 (marimba_svlte_config_clock->gpio_cfg), 1);
2037 else
2038 gpio_set_value(GPIO_PIN
2039 (marimba_svlte_config_clock->gpio_cfg), 0);
2040 }
2041
2042 return 0;
2043};
2044
2045static unsigned int msm_marimba_setup_power(void)
2046{
2047 int rc;
2048
Justin Paupore3f40f342011-08-10 18:52:16 -07002049 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002050 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002051 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002052 goto out;
2053 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002054
2055 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002056 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002057 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2058 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002059 }
2060
2061 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
2062 rc = msm_gpios_request_enable(marimba_svlte_config_clock,
2063 ARRAY_SIZE(marimba_svlte_config_clock));
2064 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002065 pr_err("%s: msm_gpios_request_enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002066 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002067 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002068 }
2069
2070 rc = gpio_direction_output(GPIO_PIN
2071 (marimba_svlte_config_clock->gpio_cfg), 0);
2072 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002073 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002074 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002075 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002076 }
2077 }
2078
Justin Paupore3f40f342011-08-10 18:52:16 -07002079 return 0;
2080
2081disable_marimba_2:
2082 regulator_disable(vreg_marimba_2);
2083disable_marimba_1:
2084 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002085out:
2086 return rc;
2087};
2088
2089static void msm_marimba_shutdown_power(void)
2090{
2091 int rc;
2092
Justin Paupore3f40f342011-08-10 18:52:16 -07002093 rc = regulator_disable(vreg_marimba_2);
2094 if (rc)
2095 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
2096
2097 rc = regulator_disable(vreg_marimba_1);
2098 if (rc)
2099 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002100};
2101
2102static int bahama_present(void)
2103{
2104 int id;
2105 switch (id = adie_get_detected_connectivity_type()) {
2106 case BAHAMA_ID:
2107 return 1;
2108
2109 case MARIMBA_ID:
2110 return 0;
2111
2112 case TIMPANI_ID:
2113 default:
2114 printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n",
2115 __func__, id);
2116 return -ENODEV;
2117 }
2118}
2119
Justin Paupore3f40f342011-08-10 18:52:16 -07002120struct regulator *fm_regulator;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002121static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
2122{
Justin Paupore3f40f342011-08-10 18:52:16 -07002123 int rc, voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002124 uint32_t irqcfg;
2125 const char *id = "FMPW";
2126
2127 int bahama_not_marimba = bahama_present();
2128
Justin Paupore3f40f342011-08-10 18:52:16 -07002129 if (bahama_not_marimba < 0) {
2130 pr_warn("%s: bahama_present: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002131 __func__, bahama_not_marimba);
Justin Paupore3f40f342011-08-10 18:52:16 -07002132 rc = -ENODEV;
2133 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002134 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002135 if (bahama_not_marimba) {
2136 fm_regulator = regulator_get(NULL, "s3");
2137 voltage = 1800000;
2138 } else {
2139 fm_regulator = regulator_get(NULL, "s2");
2140 voltage = 1300000;
2141 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002142
2143 if (IS_ERR(fm_regulator)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002144 rc = PTR_ERR(fm_regulator);
2145 pr_err("%s: regulator_get failed (%d)\n", __func__, rc);
2146 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002147 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002148
Justin Paupore3f40f342011-08-10 18:52:16 -07002149 rc = regulator_set_voltage(fm_regulator, voltage, voltage);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002150
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002151 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002152 pr_err("%s: regulator_set_voltage failed (%d)\n", __func__, rc);
2153 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002154 }
2155
Justin Paupore3f40f342011-08-10 18:52:16 -07002156 rc = regulator_enable(fm_regulator);
2157
2158 if (rc) {
2159 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2160 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002161 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002162
2163 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_ON);
2164
2165 if (rc < 0) {
2166 pr_err("%s: clock vote failed (%d)\n", __func__, rc);
2167 goto regulator_disable;
2168 }
2169
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002170 /*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2171 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002172 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002173 rc = marimba_gpio_config(1);
Justin Paupore3f40f342011-08-10 18:52:16 -07002174 if (rc < 0) {
2175 pr_err("%s: clock enable for svlte : %d\n",
2176 __func__, rc);
2177 goto clock_devote;
2178 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002179 }
2180 irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
2181 GPIO_CFG_2MA);
2182 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2183 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002184 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002185 rc = -EIO;
Justin Paupore3f40f342011-08-10 18:52:16 -07002186 goto gpio_deconfig;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002187
2188 }
2189 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002190
Justin Paupore3f40f342011-08-10 18:52:16 -07002191gpio_deconfig:
2192 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa())
2193 marimba_gpio_config(0);
2194clock_devote:
2195 pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_OFF);
2196regulator_disable:
2197 regulator_disable(fm_regulator);
2198regulator_free:
2199 regulator_put(fm_regulator);
2200 fm_regulator = NULL;
2201out:
2202 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002203};
2204
2205static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
2206{
2207 int rc;
2208 const char *id = "FMPW";
2209 uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
2210 GPIO_CFG_2MA);
2211
2212 int bahama_not_marimba = bahama_present();
2213 if (bahama_not_marimba == -1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002214 pr_warn("%s: bahama_present: %d\n",
2215 __func__, bahama_not_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002216 return;
2217 }
2218
2219 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2220 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002221 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002222 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002223 if (!IS_ERR_OR_NULL(fm_regulator)) {
2224 rc = regulator_disable(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002225
Justin Paupore3f40f342011-08-10 18:52:16 -07002226 if (rc)
2227 pr_err("%s: return val: %d\n", __func__, rc);
2228
2229 regulator_put(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002230 fm_regulator = NULL;
2231 }
2232 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
2233 PMAPP_CLOCK_VOTE_OFF);
2234 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002235 pr_err("%s: clock_vote return val: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002236
2237 /*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2238 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002239 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002240 rc = marimba_gpio_config(0);
2241 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002242 pr_err("%s: clock disable for svlte : %d\n",
2243 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002244 }
2245}
2246
2247static struct marimba_fm_platform_data marimba_fm_pdata = {
2248 .fm_setup = fm_radio_setup,
2249 .fm_shutdown = fm_radio_shutdown,
2250 .irq = MSM_GPIO_TO_INT(147),
2251 .vreg_s2 = NULL,
2252 .vreg_xo_out = NULL,
2253 .is_fm_soc_i2s_master = false,
2254 .config_i2s_gpio = NULL,
2255};
2256
2257
2258/* Slave id address for FM/CDC/QMEMBIST
2259 * Values can be programmed using Marimba slave id 0
2260 * should there be a conflict with other I2C devices
2261 * */
2262#define MARIMBA_SLAVE_ID_FM_ADDR 0x2A
2263#define MARIMBA_SLAVE_ID_CDC_ADDR 0x77
2264#define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66
2265
2266#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
2267#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
2268
2269static const char *tsadc_id = "MADC";
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002270
Justin Paupore3f40f342011-08-10 18:52:16 -07002271static struct regulator_bulk_data regs_tsadc_marimba[] = {
2272 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2273 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002274};
Justin Paupore3f40f342011-08-10 18:52:16 -07002275
2276static struct regulator_bulk_data regs_tsadc_timpani[] = {
2277 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2278 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2279 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2280};
2281
2282static struct regulator_bulk_data *regs_tsadc;
2283static int regs_tsadc_count;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002284
2285static int marimba_tsadc_power(int vreg_on)
2286{
Justin Paupore3f40f342011-08-10 18:52:16 -07002287 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002288 int tsadc_adie_type = adie_get_detected_codec_type();
2289
Justin Paupore3f40f342011-08-10 18:52:16 -07002290 switch (tsadc_adie_type) {
2291 case TIMPANI_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002292 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2293 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2294 if (rc) {
2295 pr_err("%s: unable to %svote for d1 clk\n",
2296 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002297 goto D1_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002298 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002299
2300 /* fall through */
2301 case MARIMBA_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002302 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2303 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2304 if (rc) {
2305 pr_err("%s: unable to %svote for d1 clk\n",
2306 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002307 goto D0_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002308 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002309
Justin Paupore3f40f342011-08-10 18:52:16 -07002310 WARN_ON(regs_tsadc_count == 0);
2311
2312 rc = vreg_on ?
2313 regulator_bulk_enable(regs_tsadc_count, regs_tsadc) :
2314 regulator_bulk_disable(regs_tsadc_count, regs_tsadc);
2315
2316 if (rc) {
2317 pr_err("%s: regulator %sable failed: %d\n",
2318 __func__, vreg_on ? "en" : "dis", rc);
2319 goto regulator_switch_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002320 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002321
2322 break;
2323 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002324 pr_err("%s:Adie %d not supported\n",
2325 __func__, tsadc_adie_type);
2326 return -ENODEV;
2327 }
2328
2329 msleep(5); /* ensure power is stable */
2330
2331 return 0;
2332
Justin Paupore3f40f342011-08-10 18:52:16 -07002333regulator_switch_fail:
2334 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2335 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2336D0_vote_fail:
2337 if (tsadc_adie_type == TIMPANI_ID)
2338 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2339 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2340D1_vote_fail:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002341 return rc;
2342}
2343
2344static int marimba_tsadc_init(void)
2345{
Justin Paupore3f40f342011-08-10 18:52:16 -07002346 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002347 int tsadc_adie_type = adie_get_detected_codec_type();
2348
Justin Paupore3f40f342011-08-10 18:52:16 -07002349 switch (tsadc_adie_type) {
2350 case MARIMBA_ID:
2351 regs_tsadc = regs_tsadc_marimba;
2352 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_marimba);
2353 break;
2354 case TIMPANI_ID:
2355 regs_tsadc = regs_tsadc_timpani;
2356 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_timpani);
2357 break;
2358 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002359 pr_err("%s:Adie %d not supported\n",
2360 __func__, tsadc_adie_type);
Justin Paupore3f40f342011-08-10 18:52:16 -07002361 rc = -ENODEV;
2362 goto out;
2363 }
2364
2365 rc = regulator_bulk_get(NULL, regs_tsadc_count, regs_tsadc);
2366 if (rc) {
2367 pr_err("%s: could not get regulators: %d\n",
2368 __func__, rc);
2369 goto out;
2370 }
2371
2372 rc = regulator_bulk_set_voltage(regs_tsadc_count, regs_tsadc);
2373 if (rc) {
2374 pr_err("%s: could not set regulator voltages: %d\n",
2375 __func__, rc);
2376 goto vreg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002377 }
2378
2379 return 0;
2380
Justin Paupore3f40f342011-08-10 18:52:16 -07002381vreg_free:
2382 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2383out:
2384 regs_tsadc = NULL;
2385 regs_tsadc_count = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002386 return rc;
2387}
2388
2389static int marimba_tsadc_exit(void)
2390{
Justin Paupore3f40f342011-08-10 18:52:16 -07002391 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2392 regs_tsadc_count = 0;
2393 regs_tsadc = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002394
Justin Paupore3f40f342011-08-10 18:52:16 -07002395 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002396}
2397
2398
2399static struct msm_ts_platform_data msm_ts_data = {
Anirudh Ghayal82b74722012-01-19 15:35:34 +05302400 .min_x = 284,
2401 .max_x = 3801,
2402 .min_y = 155,
2403 .max_y = 3929,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002404 .min_press = 0,
2405 .max_press = 255,
2406 .inv_x = 4096,
2407 .inv_y = 4096,
2408 .can_wakeup = false,
2409};
2410
2411static struct marimba_tsadc_platform_data marimba_tsadc_pdata = {
2412 .marimba_tsadc_power = marimba_tsadc_power,
2413 .init = marimba_tsadc_init,
2414 .exit = marimba_tsadc_exit,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002415 .tsadc_prechg_en = true,
2416 .can_wakeup = false,
2417 .setup = {
2418 .pen_irq_en = true,
2419 .tsadc_en = true,
2420 },
2421 .params2 = {
2422 .input_clk_khz = 2400,
2423 .sample_prd = TSADC_CLK_3,
2424 },
2425 .params3 = {
2426 .prechg_time_nsecs = 6400,
2427 .stable_time_nsecs = 6400,
2428 .tsadc_test_mode = 0,
2429 },
2430 .tssc_data = &msm_ts_data,
2431};
2432
Justin Paupore3f40f342011-08-10 18:52:16 -07002433static struct regulator_bulk_data codec_regs[] = {
2434 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
2435};
2436
2437static int __init msm_marimba_codec_init(void)
2438{
2439 int rc = regulator_bulk_get(NULL, ARRAY_SIZE(codec_regs), codec_regs);
2440
2441 if (rc) {
2442 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2443 goto out;
2444 }
2445
2446 rc = regulator_bulk_set_voltage(ARRAY_SIZE(codec_regs), codec_regs);
2447 if (rc) {
2448 pr_err("%s: could not set regulator voltages: %d\n",
2449 __func__, rc);
2450 goto reg_free;
2451 }
2452
2453 return rc;
2454
2455reg_free:
2456 regulator_bulk_free(ARRAY_SIZE(codec_regs), codec_regs);
2457out:
2458 return rc;
2459}
2460
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002461static int msm_marimba_codec_power(int vreg_on)
2462{
Justin Paupore3f40f342011-08-10 18:52:16 -07002463 int rc = vreg_on ?
2464 regulator_bulk_enable(ARRAY_SIZE(codec_regs), codec_regs) :
2465 regulator_bulk_disable(ARRAY_SIZE(codec_regs), codec_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002466
Justin Paupore3f40f342011-08-10 18:52:16 -07002467 if (rc) {
2468 pr_err("%s: could not %sable regulators: %d",
2469 __func__, vreg_on ? "en" : "dis", rc);
2470 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002471 }
2472
Justin Paupore3f40f342011-08-10 18:52:16 -07002473 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002474}
2475
2476static struct marimba_codec_platform_data mariba_codec_pdata = {
2477 .marimba_codec_power = msm_marimba_codec_power,
2478#ifdef CONFIG_MARIMBA_CODEC
2479 .snddev_profile_init = msm_snddev_init,
2480#endif
2481};
2482
2483static struct marimba_platform_data marimba_pdata = {
2484 .slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR,
2485 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2486 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2487 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
2488 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
2489 .marimba_setup = msm_marimba_setup_power,
2490 .marimba_shutdown = msm_marimba_shutdown_power,
2491 .bahama_setup = msm_bahama_setup_power,
2492 .bahama_shutdown = msm_bahama_shutdown_power,
2493 .marimba_gpio_config = msm_marimba_gpio_config_svlte,
2494 .bahama_core_config = msm_bahama_core_config,
2495 .fm = &marimba_fm_pdata,
2496 .codec = &mariba_codec_pdata,
2497 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2498};
2499
2500static void __init msm7x30_init_marimba(void)
2501{
2502 int rc;
2503
Justin Paupore3f40f342011-08-10 18:52:16 -07002504 struct regulator_bulk_data regs[] = {
2505 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2506 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2507 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
2508 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002509
Justin Paupore3f40f342011-08-10 18:52:16 -07002510 rc = msm_marimba_codec_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002511
Justin Paupore3f40f342011-08-10 18:52:16 -07002512 if (rc) {
2513 pr_err("%s: msm_marimba_codec_init failed (%d)\n",
2514 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002515 return;
2516 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002517
2518 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
2519
2520 if (rc) {
2521 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2522 return;
2523 }
2524
2525 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
2526
2527 if (rc) {
2528 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2529 regulator_bulk_free(ARRAY_SIZE(regs), regs);
2530 return;
2531 }
2532
2533 vreg_marimba_1 = regs[0].consumer;
2534 vreg_marimba_2 = regs[1].consumer;
2535 vreg_bahama = regs[2].consumer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002536}
2537
2538static struct marimba_codec_platform_data timpani_codec_pdata = {
2539 .marimba_codec_power = msm_marimba_codec_power,
2540#ifdef CONFIG_TIMPANI_CODEC
2541 .snddev_profile_init = msm_snddev_init_timpani,
2542#endif
2543};
2544
2545static struct marimba_platform_data timpani_pdata = {
2546 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2547 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2548 .marimba_setup = msm_timpani_setup_power,
2549 .marimba_shutdown = msm_timpani_shutdown_power,
2550 .codec = &timpani_codec_pdata,
2551 .tsadc = &marimba_tsadc_pdata,
2552 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2553};
2554
2555#define TIMPANI_I2C_SLAVE_ADDR 0xD
2556
2557static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
2558 {
2559 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
2560 .platform_data = &timpani_pdata,
2561 },
2562};
2563
2564#ifdef CONFIG_MSM7KV2_AUDIO
2565static struct resource msm_aictl_resources[] = {
2566 {
2567 .name = "aictl",
2568 .start = 0xa5000100,
2569 .end = 0xa5000100,
2570 .flags = IORESOURCE_MEM,
2571 }
2572};
2573
2574static struct resource msm_mi2s_resources[] = {
2575 {
2576 .name = "hdmi",
2577 .start = 0xac900000,
2578 .end = 0xac900038,
2579 .flags = IORESOURCE_MEM,
2580 },
2581 {
2582 .name = "codec_rx",
2583 .start = 0xac940040,
2584 .end = 0xac940078,
2585 .flags = IORESOURCE_MEM,
2586 },
2587 {
2588 .name = "codec_tx",
2589 .start = 0xac980080,
2590 .end = 0xac9800B8,
2591 .flags = IORESOURCE_MEM,
2592 }
2593
2594};
2595
2596static struct msm_lpa_platform_data lpa_pdata = {
2597 .obuf_hlb_size = 0x2BFF8,
2598 .dsp_proc_id = 0,
2599 .app_proc_id = 2,
2600 .nosb_config = {
2601 .llb_min_addr = 0,
2602 .llb_max_addr = 0x3ff8,
2603 .sb_min_addr = 0,
2604 .sb_max_addr = 0,
2605 },
2606 .sb_config = {
2607 .llb_min_addr = 0,
2608 .llb_max_addr = 0x37f8,
2609 .sb_min_addr = 0x3800,
2610 .sb_max_addr = 0x3ff8,
2611 }
2612};
2613
2614static struct resource msm_lpa_resources[] = {
2615 {
2616 .name = "lpa",
2617 .start = 0xa5000000,
2618 .end = 0xa50000a0,
2619 .flags = IORESOURCE_MEM,
2620 }
2621};
2622
2623static struct resource msm_aux_pcm_resources[] = {
2624
2625 {
2626 .name = "aux_codec_reg_addr",
2627 .start = 0xac9c00c0,
2628 .end = 0xac9c00c8,
2629 .flags = IORESOURCE_MEM,
2630 },
2631 {
2632 .name = "aux_pcm_dout",
2633 .start = 138,
2634 .end = 138,
2635 .flags = IORESOURCE_IO,
2636 },
2637 {
2638 .name = "aux_pcm_din",
2639 .start = 139,
2640 .end = 139,
2641 .flags = IORESOURCE_IO,
2642 },
2643 {
2644 .name = "aux_pcm_syncout",
2645 .start = 140,
2646 .end = 140,
2647 .flags = IORESOURCE_IO,
2648 },
2649 {
2650 .name = "aux_pcm_clkin_a",
2651 .start = 141,
2652 .end = 141,
2653 .flags = IORESOURCE_IO,
2654 },
2655};
2656
2657static struct platform_device msm_aux_pcm_device = {
2658 .name = "msm_aux_pcm",
2659 .id = 0,
2660 .num_resources = ARRAY_SIZE(msm_aux_pcm_resources),
2661 .resource = msm_aux_pcm_resources,
2662};
2663
2664struct platform_device msm_aictl_device = {
2665 .name = "audio_interct",
2666 .id = 0,
2667 .num_resources = ARRAY_SIZE(msm_aictl_resources),
2668 .resource = msm_aictl_resources,
2669};
2670
2671struct platform_device msm_mi2s_device = {
2672 .name = "mi2s",
2673 .id = 0,
2674 .num_resources = ARRAY_SIZE(msm_mi2s_resources),
2675 .resource = msm_mi2s_resources,
2676};
2677
2678struct platform_device msm_lpa_device = {
2679 .name = "lpa",
2680 .id = 0,
2681 .num_resources = ARRAY_SIZE(msm_lpa_resources),
2682 .resource = msm_lpa_resources,
2683 .dev = {
2684 .platform_data = &lpa_pdata,
2685 },
2686};
2687#endif /* CONFIG_MSM7KV2_AUDIO */
2688
2689#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2690 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2691 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2692 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2693 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2694 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2695#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2696 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2697 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2698 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2699 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2700 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2701 #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2702 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2703 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2704 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2705 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2706 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2707 #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2708 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2709 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2710 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2711 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2712 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2713#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
2714
2715static unsigned int dec_concurrency_table[] = {
2716 /* Audio LP */
2717 0,
2718 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2719 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2720 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2721 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)|
2722 (1<<MSM_ADSP_OP_DM)),
2723
2724 /* Concurrency 1 */
2725 (DEC4_FORMAT),
2726 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2727 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2728 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2729 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2730
2731 /* Concurrency 2 */
2732 (DEC4_FORMAT),
2733 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2734 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2735 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2736 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2737
2738 /* Concurrency 3 */
2739 (DEC4_FORMAT),
2740 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2741 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2742 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2743 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2744
2745 /* Concurrency 4 */
2746 (DEC4_FORMAT),
2747 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2748 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2749 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2750 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2751
2752 /* Concurrency 5 */
2753 (DEC4_FORMAT),
2754 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2755 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2756 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2757 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2758
2759 /* Concurrency 6 */
2760 (DEC4_FORMAT),
2761 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2762 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2763 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2764 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2765};
2766
2767#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
2768 .module_queueid = queueid, .module_decid = decid, \
2769 .nr_codec_support = nr_codec}
2770
2771#define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
2772 .max_instances_same_dec = max_instance_same, \
2773 .max_instances_diff_dec = max_instance_diff}
2774
2775static struct msm_adspdec_info dec_info_list[] = {
2776 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
2777 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
2778 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
2779 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
2780 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
2781};
2782
2783static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
2784 /* Non Turbo Mode */
2785 {
2786 DEC_INSTANCE(4, 3), /* WAV */
2787 DEC_INSTANCE(4, 3), /* ADPCM */
2788 DEC_INSTANCE(4, 2), /* MP3 */
2789 DEC_INSTANCE(0, 0), /* Real Audio */
2790 DEC_INSTANCE(4, 2), /* WMA */
2791 DEC_INSTANCE(3, 2), /* AAC */
2792 DEC_INSTANCE(0, 0), /* Reserved */
2793 DEC_INSTANCE(0, 0), /* MIDI */
2794 DEC_INSTANCE(4, 3), /* YADPCM */
2795 DEC_INSTANCE(4, 3), /* QCELP */
2796 DEC_INSTANCE(4, 3), /* AMRNB */
2797 DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
2798 DEC_INSTANCE(4, 3), /* EVRC */
2799 DEC_INSTANCE(1, 1), /* WMAPRO */
2800 },
2801 /* Turbo Mode */
2802 {
2803 DEC_INSTANCE(4, 3), /* WAV */
2804 DEC_INSTANCE(4, 3), /* ADPCM */
2805 DEC_INSTANCE(4, 3), /* MP3 */
2806 DEC_INSTANCE(0, 0), /* Real Audio */
2807 DEC_INSTANCE(4, 3), /* WMA */
2808 DEC_INSTANCE(4, 3), /* AAC */
2809 DEC_INSTANCE(0, 0), /* Reserved */
2810 DEC_INSTANCE(0, 0), /* MIDI */
2811 DEC_INSTANCE(4, 3), /* YADPCM */
2812 DEC_INSTANCE(4, 3), /* QCELP */
2813 DEC_INSTANCE(4, 3), /* AMRNB */
2814 DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
2815 DEC_INSTANCE(4, 3), /* EVRC */
2816 DEC_INSTANCE(1, 2), /* WMAPRO */
2817 },
2818};
2819
2820static struct msm_adspdec_database msm_device_adspdec_database = {
2821 .num_dec = ARRAY_SIZE(dec_info_list),
2822 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
2823 ARRAY_SIZE(dec_info_list)),
2824 .dec_concurrency_table = dec_concurrency_table,
2825 .dec_info_list = dec_info_list,
2826 .dec_instance_list = &dec_instance_list[0][0],
2827};
2828
2829static struct platform_device msm_device_adspdec = {
2830 .name = "msm_adspdec",
2831 .id = -1,
2832 .dev = {
2833 .platform_data = &msm_device_adspdec_database
2834 },
2835};
2836
2837static struct resource smc91x_resources[] = {
2838 [0] = {
2839 .start = 0x8A000300,
2840 .end = 0x8A0003ff,
2841 .flags = IORESOURCE_MEM,
2842 },
2843 [1] = {
2844 .start = MSM_GPIO_TO_INT(156),
2845 .end = MSM_GPIO_TO_INT(156),
2846 .flags = IORESOURCE_IRQ,
2847 },
2848};
2849
2850static struct platform_device smc91x_device = {
2851 .name = "smc91x",
2852 .id = 0,
2853 .num_resources = ARRAY_SIZE(smc91x_resources),
2854 .resource = smc91x_resources,
2855};
2856
2857static struct smsc911x_platform_config smsc911x_config = {
2858 .phy_interface = PHY_INTERFACE_MODE_MII,
2859 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
2860 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
2861 .flags = SMSC911X_USE_32BIT,
2862};
2863
2864static struct resource smsc911x_resources[] = {
2865 [0] = {
2866 .start = 0x8D000000,
2867 .end = 0x8D000100,
2868 .flags = IORESOURCE_MEM,
2869 },
2870 [1] = {
2871 .start = MSM_GPIO_TO_INT(88),
2872 .end = MSM_GPIO_TO_INT(88),
2873 .flags = IORESOURCE_IRQ,
2874 },
2875};
2876
2877static struct platform_device smsc911x_device = {
2878 .name = "smsc911x",
2879 .id = -1,
2880 .num_resources = ARRAY_SIZE(smsc911x_resources),
2881 .resource = smsc911x_resources,
2882 .dev = {
2883 .platform_data = &smsc911x_config,
2884 },
2885};
2886
2887static struct msm_gpio smsc911x_gpios[] = {
2888 { GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" },
2889 { GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" },
2890 { GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" },
2891 { GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" },
2892 { GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" },
2893 { GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" },
2894 { GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" },
2895 { GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" },
2896};
2897
2898static void msm7x30_cfg_smsc911x(void)
2899{
2900 int rc;
2901
2902 rc = msm_gpios_request_enable(smsc911x_gpios,
2903 ARRAY_SIZE(smsc911x_gpios));
2904 if (rc)
2905 pr_err("%s: unable to enable gpios\n", __func__);
2906}
2907
2908#ifdef CONFIG_USB_G_ANDROID
2909static struct android_usb_platform_data android_usb_pdata = {
2910 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2911};
2912
2913static struct platform_device android_usb_device = {
2914 .name = "android_usb",
2915 .id = -1,
2916 .dev = {
2917 .platform_data = &android_usb_pdata,
2918 },
2919};
2920#endif
2921
2922static struct msm_gpio optnav_config_data[] = {
2923 { GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA),
2924 "optnav_chip_select" },
2925};
2926
Justin Paupore3f40f342011-08-10 18:52:16 -07002927static struct regulator_bulk_data optnav_regulators[] = {
2928 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2929 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
2930 { .supply = "gp9", .min_uV = 1800000, .max_uV = 1800000 },
2931 { .supply = "usb", .min_uV = 3300000, .max_uV = 3300000 },
2932};
2933
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002934static void __iomem *virtual_optnav;
2935
2936static int optnav_gpio_setup(void)
2937{
2938 int rc = -ENODEV;
2939 rc = msm_gpios_request_enable(optnav_config_data,
2940 ARRAY_SIZE(optnav_config_data));
2941
Justin Paupore3f40f342011-08-10 18:52:16 -07002942 if (rc)
2943 return rc;
2944
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002945 /* Configure the FPGA for GPIOs */
2946 virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4);
2947 if (!virtual_optnav) {
2948 pr_err("%s:Could not ioremap region\n", __func__);
2949 return -ENOMEM;
2950 }
2951 /*
2952 * Configure the FPGA to set GPIO 19 as
2953 * normal, active(enabled), output(MSM to SURF)
2954 */
2955 writew(0x311E, virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002956
2957 rc = regulator_bulk_get(NULL, ARRAY_SIZE(optnav_regulators),
2958 optnav_regulators);
2959 if (rc)
2960 return rc;
2961
2962 rc = regulator_bulk_set_voltage(ARRAY_SIZE(optnav_regulators),
2963 optnav_regulators);
2964
2965 if (rc)
2966 goto regulator_put;
2967
2968 return rc;
2969
2970regulator_put:
2971 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002972 return rc;
2973}
2974
2975static void optnav_gpio_release(void)
2976{
2977 msm_gpios_disable_free(optnav_config_data,
2978 ARRAY_SIZE(optnav_config_data));
2979 iounmap(virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002980 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002981}
2982
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002983static int optnav_enable(void)
2984{
2985 int rc;
2986 /*
2987 * Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
2988 * for I2C communication with keyboard.
2989 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002990
Justin Paupore3f40f342011-08-10 18:52:16 -07002991 rc = regulator_bulk_enable(ARRAY_SIZE(optnav_regulators),
2992 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002993
Justin Paupore3f40f342011-08-10 18:52:16 -07002994 if (rc)
2995 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002996
2997 /* Enable the chip select GPIO */
2998 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2999 gpio_set_value(OPTNAV_CHIP_SELECT, 0);
3000
3001 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003002}
3003
3004static void optnav_disable(void)
3005{
Justin Paupore3f40f342011-08-10 18:52:16 -07003006 regulator_bulk_disable(ARRAY_SIZE(optnav_regulators),
3007 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003008
3009 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
3010}
3011
3012static struct ofn_atlab_platform_data optnav_data = {
3013 .gpio_setup = optnav_gpio_setup,
3014 .gpio_release = optnav_gpio_release,
3015 .optnav_on = optnav_enable,
3016 .optnav_off = optnav_disable,
3017 .rotate_xy = 0,
3018 .function1 = {
3019 .no_motion1_en = true,
3020 .touch_sensor_en = true,
3021 .ofn_en = true,
3022 .clock_select_khz = 1500,
3023 .cpi_selection = 1200,
3024 },
3025 .function2 = {
3026 .invert_y = false,
3027 .invert_x = true,
3028 .swap_x_y = false,
3029 .hold_a_b_en = true,
3030 .motion_filter_en = true,
3031 },
3032};
3033
3034static int hdmi_comm_power(int on, int show);
3035static int hdmi_init_irq(void);
3036static int hdmi_enable_5v(int on);
3037static int hdmi_core_power(int on, int show);
3038static int hdmi_cec_power(int on);
3039static bool hdmi_check_hdcp_hw_support(void);
3040
3041static struct msm_hdmi_platform_data adv7520_hdmi_data = {
3042 .irq = MSM_GPIO_TO_INT(18),
3043 .comm_power = hdmi_comm_power,
3044 .init_irq = hdmi_init_irq,
3045 .enable_5v = hdmi_enable_5v,
3046 .core_power = hdmi_core_power,
3047 .cec_power = hdmi_cec_power,
3048 .check_hdcp_hw_support = hdmi_check_hdcp_hw_support,
3049};
3050
3051#ifdef CONFIG_BOSCH_BMA150
Justin Paupore3f40f342011-08-10 18:52:16 -07003052
3053static struct regulator_bulk_data sensors_ldo[] = {
3054 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
3055 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
3056};
3057
3058static int __init sensors_ldo_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003059{
3060 int rc;
3061
Justin Paupore3f40f342011-08-10 18:52:16 -07003062 rc = regulator_bulk_get(NULL, ARRAY_SIZE(sensors_ldo), sensors_ldo);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003063
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003064 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003065 pr_err("%s: could not get regulators: %d\n", __func__, rc);
3066 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003067 }
3068
Justin Paupore3f40f342011-08-10 18:52:16 -07003069 rc = regulator_bulk_set_voltage(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3070
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003071 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003072 pr_err("%s: could not set voltages: %d\n", __func__, rc);
3073 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003074 }
3075
3076 return 0;
3077
Justin Paupore3f40f342011-08-10 18:52:16 -07003078reg_free:
3079 regulator_bulk_free(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3080out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003081 return rc;
3082}
3083
Justin Paupore3f40f342011-08-10 18:52:16 -07003084static int sensors_ldo_set(int on)
3085{
3086 int rc = on ?
3087 regulator_bulk_enable(ARRAY_SIZE(sensors_ldo), sensors_ldo) :
3088 regulator_bulk_disable(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3089
3090 if (rc)
3091 pr_err("%s: could not %sable regulators: %d\n",
3092 __func__, on ? "en" : "dis", rc);
3093
3094 return rc;
3095}
3096
3097static int sensors_ldo_enable(void)
3098{
3099 return sensors_ldo_set(1);
3100}
3101
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003102static void sensors_ldo_disable(void)
3103{
Justin Paupore3f40f342011-08-10 18:52:16 -07003104 sensors_ldo_set(0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003105}
Justin Paupore3f40f342011-08-10 18:52:16 -07003106
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003107static struct bma150_platform_data bma150_data = {
3108 .power_on = sensors_ldo_enable,
3109 .power_off = sensors_ldo_disable,
3110};
3111
3112static struct i2c_board_info bma150_board_info[] __initdata = {
3113 {
3114 I2C_BOARD_INFO("bma150", 0x38),
3115 .flags = I2C_CLIENT_WAKE,
3116 .irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
3117 .platform_data = &bma150_data,
3118 },
3119};
3120#endif
3121
3122static struct i2c_board_info msm_i2c_board_info[] = {
3123 {
3124 I2C_BOARD_INFO("m33c01", OPTNAV_I2C_SLAVE_ADDR),
3125 .irq = MSM_GPIO_TO_INT(OPTNAV_IRQ),
3126 .platform_data = &optnav_data,
3127 },
3128 {
3129 I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR),
3130 .platform_data = &adv7520_hdmi_data,
3131 },
3132};
3133
3134static struct i2c_board_info msm_marimba_board_info[] = {
3135 {
3136 I2C_BOARD_INFO("marimba", 0xc),
3137 .platform_data = &marimba_pdata,
3138 }
3139};
3140
3141
3142static struct msm_handset_platform_data hs_platform_data = {
3143 .hs_name = "7k_handset",
3144 .pwr_key_delay_ms = 500, /* 0 will disable end key */
3145};
3146
3147static struct platform_device hs_device = {
3148 .name = "msm-handset",
3149 .id = -1,
3150 .dev = {
3151 .platform_data = &hs_platform_data,
3152 },
3153};
3154
3155static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +05303156 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003157 .idle_supported = 1,
3158 .suspend_supported = 1,
3159 .idle_enabled = 1,
3160 .suspend_enabled = 1,
3161 .latency = 8594,
3162 .residency = 23740,
3163 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303164 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003165 .idle_supported = 1,
3166 .suspend_supported = 1,
3167 .idle_enabled = 1,
3168 .suspend_enabled = 1,
3169 .latency = 4594,
3170 .residency = 23740,
3171 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303172 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003173#ifdef CONFIG_MSM_STANDALONE_POWER_COLLAPSE
3174 .idle_supported = 1,
3175 .suspend_supported = 1,
3176 .idle_enabled = 1,
3177 .suspend_enabled = 0,
3178#else /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3179 .idle_supported = 0,
3180 .suspend_supported = 0,
3181 .idle_enabled = 0,
3182 .suspend_enabled = 0,
3183#endif /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3184 .latency = 500,
3185 .residency = 6000,
3186 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303187 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003188 .idle_supported = 1,
3189 .suspend_supported = 1,
3190 .idle_enabled = 0,
3191 .suspend_enabled = 1,
3192 .latency = 443,
3193 .residency = 1098,
3194 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303195 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003196 .idle_supported = 1,
3197 .suspend_supported = 1,
3198 .idle_enabled = 1,
3199 .suspend_enabled = 1,
3200 .latency = 2,
3201 .residency = 0,
3202 },
3203};
3204
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003205static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3206 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
3207 .v_addr = (uint32_t *)PAGE_OFFSET,
3208};
3209
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003210static struct resource qsd_spi_resources[] = {
3211 {
3212 .name = "spi_irq_in",
3213 .start = INT_SPI_INPUT,
3214 .end = INT_SPI_INPUT,
3215 .flags = IORESOURCE_IRQ,
3216 },
3217 {
3218 .name = "spi_irq_out",
3219 .start = INT_SPI_OUTPUT,
3220 .end = INT_SPI_OUTPUT,
3221 .flags = IORESOURCE_IRQ,
3222 },
3223 {
3224 .name = "spi_irq_err",
3225 .start = INT_SPI_ERROR,
3226 .end = INT_SPI_ERROR,
3227 .flags = IORESOURCE_IRQ,
3228 },
3229 {
3230 .name = "spi_base",
3231 .start = 0xA8000000,
3232 .end = 0xA8000000 + SZ_4K - 1,
3233 .flags = IORESOURCE_MEM,
3234 },
3235 {
3236 .name = "spidm_channels",
3237 .flags = IORESOURCE_DMA,
3238 },
3239 {
3240 .name = "spidm_crci",
3241 .flags = IORESOURCE_DMA,
3242 },
3243};
3244
3245#define AMDH0_BASE_PHYS 0xAC200000
3246#define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
3247static int msm_qsd_spi_dma_config(void)
3248{
3249 void __iomem *ct_adm_base = 0;
3250 u32 spi_mux = 0;
3251 int ret = 0;
3252
3253 ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
3254 if (!ct_adm_base) {
3255 pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
3256 return -ENOMEM;
3257 }
3258
3259 spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
3260
3261 qsd_spi_resources[4].start = DMOV_USB_CHAN;
3262 qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
3263
3264 switch (spi_mux) {
3265 case (1):
3266 qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
3267 qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
3268 break;
3269 case (2):
3270 qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
3271 qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
3272 break;
3273 case (3):
3274 qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
3275 qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
3276 break;
3277 default:
3278 ret = -ENOENT;
3279 }
3280
3281 iounmap(ct_adm_base);
3282
3283 return ret;
3284}
3285
3286static struct platform_device qsd_device_spi = {
3287 .name = "spi_qsd",
3288 .id = 0,
3289 .num_resources = ARRAY_SIZE(qsd_spi_resources),
3290 .resource = qsd_spi_resources,
3291};
3292
3293#ifdef CONFIG_SPI_QSD
3294static struct spi_board_info lcdc_sharp_spi_board_info[] __initdata = {
3295 {
3296 .modalias = "lcdc_sharp_ls038y7dx01",
3297 .mode = SPI_MODE_1,
3298 .bus_num = 0,
3299 .chip_select = 0,
3300 .max_speed_hz = 26331429,
3301 }
3302};
3303static struct spi_board_info lcdc_toshiba_spi_board_info[] __initdata = {
3304 {
3305 .modalias = "lcdc_toshiba_ltm030dd40",
3306 .mode = SPI_MODE_3|SPI_CS_HIGH,
3307 .bus_num = 0,
3308 .chip_select = 0,
3309 .max_speed_hz = 9963243,
3310 }
3311};
3312#endif
3313
3314static struct msm_gpio qsd_spi_gpio_config_data[] = {
3315 { GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3316 { GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3317 { GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" },
3318 { GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3319};
3320
3321static int msm_qsd_spi_gpio_config(void)
3322{
3323 return msm_gpios_request_enable(qsd_spi_gpio_config_data,
3324 ARRAY_SIZE(qsd_spi_gpio_config_data));
3325}
3326
3327static void msm_qsd_spi_gpio_release(void)
3328{
3329 msm_gpios_disable_free(qsd_spi_gpio_config_data,
3330 ARRAY_SIZE(qsd_spi_gpio_config_data));
3331}
3332
3333static struct msm_spi_platform_data qsd_spi_pdata = {
3334 .max_clock_speed = 26331429,
3335 .gpio_config = msm_qsd_spi_gpio_config,
3336 .gpio_release = msm_qsd_spi_gpio_release,
3337 .dma_config = msm_qsd_spi_dma_config,
3338};
3339
3340static void __init msm_qsd_spi_init(void)
3341{
3342 qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
3343}
3344
3345#ifdef CONFIG_USB_EHCI_MSM_72K
3346static void msm_hsusb_vbus_power(unsigned phy_info, int on)
3347{
3348 int rc;
3349 static int vbus_is_on;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303350 struct pm8xxx_gpio_init_info usb_vbus = {
3351 PM8058_GPIO_PM_TO_SYS(36),
3352 {
3353 .direction = PM_GPIO_DIR_OUT,
3354 .pull = PM_GPIO_PULL_NO,
3355 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3356 .output_value = 1,
3357 .vin_sel = 2,
3358 .out_strength = PM_GPIO_STRENGTH_MED,
3359 .function = PM_GPIO_FUNC_NORMAL,
3360 .inv_int_pol = 0,
3361 },
3362 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003363
3364 /* If VBUS is already on (or off), do nothing. */
3365 if (unlikely(on == vbus_is_on))
3366 return;
3367
3368 if (on) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303369 rc = pm8xxx_gpio_config(usb_vbus.gpio, &usb_vbus.config);
3370 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003371 pr_err("%s PMIC GPIO 36 write failed\n", __func__);
3372 return;
3373 }
3374 } else {
3375 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(36), 0);
3376 }
3377
3378 vbus_is_on = on;
3379}
3380
3381static struct msm_usb_host_platform_data msm_usb_host_pdata = {
3382 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
3383 .vbus_power = msm_hsusb_vbus_power,
3384 .power_budget = 180,
3385};
3386#endif
3387
3388#ifdef CONFIG_USB_MSM_OTG_72K
3389static int hsusb_rpc_connect(int connect)
3390{
3391 if (connect)
3392 return msm_hsusb_rpc_connect();
3393 else
3394 return msm_hsusb_rpc_close();
3395}
3396#endif
3397
3398#ifdef CONFIG_USB_MSM_OTG_72K
Justin Paupore3f40f342011-08-10 18:52:16 -07003399static struct regulator *vreg_3p3;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003400static int msm_hsusb_ldo_init(int init)
3401{
3402 uint32_t version = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07003403 int def_vol = 3400000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003404
3405 version = socinfo_get_version();
3406
3407 if (SOCINFO_VERSION_MAJOR(version) >= 2 &&
3408 SOCINFO_VERSION_MINOR(version) >= 1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003409 def_vol = 3075000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003410 pr_debug("%s: default voltage:%d\n", __func__, def_vol);
3411 }
3412
3413 if (init) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003414 vreg_3p3 = regulator_get(NULL, "usb");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003415 if (IS_ERR(vreg_3p3))
3416 return PTR_ERR(vreg_3p3);
Justin Paupore3f40f342011-08-10 18:52:16 -07003417 regulator_set_voltage(vreg_3p3, def_vol, def_vol);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003418 } else
Justin Paupore3f40f342011-08-10 18:52:16 -07003419 regulator_put(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003420
3421 return 0;
3422}
3423
3424static int msm_hsusb_ldo_enable(int enable)
3425{
3426 static int ldo_status;
3427
3428 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3429 return -ENODEV;
3430
3431 if (ldo_status == enable)
3432 return 0;
3433
3434 ldo_status = enable;
3435
3436 if (enable)
Justin Paupore3f40f342011-08-10 18:52:16 -07003437 return regulator_enable(vreg_3p3);
3438 else
3439 return regulator_disable(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003440}
3441
3442static int msm_hsusb_ldo_set_voltage(int mV)
3443{
Justin Paupore3f40f342011-08-10 18:52:16 -07003444 static int cur_voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003445
3446 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3447 return -ENODEV;
3448
3449 if (cur_voltage == mV)
3450 return 0;
3451
3452 cur_voltage = mV;
3453
3454 pr_debug("%s: (%d)\n", __func__, mV);
3455
Justin Paupore3f40f342011-08-10 18:52:16 -07003456 return regulator_set_voltage(vreg_3p3, mV*1000, mV*1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003457}
3458#endif
3459
3460#ifndef CONFIG_USB_EHCI_MSM_72K
3461static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init);
3462#endif
3463static struct msm_otg_platform_data msm_otg_pdata = {
3464 .rpc_connect = hsusb_rpc_connect,
3465
3466#ifndef CONFIG_USB_EHCI_MSM_72K
3467 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
3468#else
3469 .vbus_power = msm_hsusb_vbus_power,
3470#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003471 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
3472 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
3473 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
3474 .se1_gating = SE1_GATING_DISABLE,
3475 .chg_vbus_draw = hsusb_chg_vbus_draw,
3476 .chg_connected = hsusb_chg_connected,
3477 .chg_init = hsusb_chg_init,
3478 .ldo_enable = msm_hsusb_ldo_enable,
3479 .ldo_init = msm_hsusb_ldo_init,
3480 .ldo_set_voltage = msm_hsusb_ldo_set_voltage,
3481};
3482
3483#ifdef CONFIG_USB_GADGET
3484static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
3485 .is_phy_status_timer_on = 1,
3486};
3487#endif
3488#ifndef CONFIG_USB_EHCI_MSM_72K
3489typedef void (*notify_vbus_state) (int);
3490notify_vbus_state notify_vbus_state_func_ptr;
3491int vbus_on_irq;
3492static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
3493{
3494 pr_info("%s: vbus notification from pmic\n", __func__);
3495
3496 (*notify_vbus_state_func_ptr) (1);
3497
3498 return IRQ_HANDLED;
3499}
3500static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
3501{
3502 int ret;
3503
3504 if (init) {
3505 if (!callback)
3506 return -ENODEV;
3507
3508 notify_vbus_state_func_ptr = callback;
3509 vbus_on_irq = platform_get_irq_byname(&msm_device_otg,
3510 "vbus_on");
3511 if (vbus_on_irq <= 0) {
3512 pr_err("%s: unable to get vbus on irq\n", __func__);
3513 return -ENODEV;
3514 }
3515
3516 ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq,
3517 IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
3518 if (ret < 0) {
3519 pr_info("%s: request_irq for vbus_on"
3520 "interrupt failed\n", __func__);
3521 return ret;
3522 }
3523 msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
3524 return 0;
3525 } else {
3526 free_irq(vbus_on_irq, 0);
3527 notify_vbus_state_func_ptr = NULL;
3528 return 0;
3529 }
3530}
3531#endif
3532
3533static struct android_pmem_platform_data android_pmem_pdata = {
3534 .name = "pmem",
3535 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
3536 .cached = 1,
3537 .memory_type = MEMTYPE_EBI0,
3538};
3539
3540static struct platform_device android_pmem_device = {
3541 .name = "android_pmem",
3542 .id = 0,
3543 .dev = { .platform_data = &android_pmem_pdata },
3544};
3545
3546#ifndef CONFIG_SPI_QSD
3547static int lcdc_gpio_array_num[] = {
3548 45, /* spi_clk */
3549 46, /* spi_cs */
3550 47, /* spi_mosi */
3551 48, /* spi_miso */
3552 };
3553
3554static struct msm_gpio lcdc_gpio_config_data[] = {
3555 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3556 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3557 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
3558 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3559};
3560
3561static void lcdc_config_gpios(int enable)
3562{
3563 if (enable) {
3564 msm_gpios_request_enable(lcdc_gpio_config_data,
3565 ARRAY_SIZE(
3566 lcdc_gpio_config_data));
3567 } else
3568 msm_gpios_disable_free(lcdc_gpio_config_data,
3569 ARRAY_SIZE(
3570 lcdc_gpio_config_data));
3571}
3572#endif
3573
3574static struct msm_panel_common_pdata lcdc_sharp_panel_data = {
3575#ifndef CONFIG_SPI_QSD
3576 .panel_config_gpio = lcdc_config_gpios,
3577 .gpio_num = lcdc_gpio_array_num,
3578#endif
3579 .gpio = 2, /* LPG PMIC_GPIO26 channel number */
3580};
3581
3582static struct platform_device lcdc_sharp_panel_device = {
3583 .name = "lcdc_sharp_wvga",
3584 .id = 0,
3585 .dev = {
3586 .platform_data = &lcdc_sharp_panel_data,
3587 }
3588};
3589
3590static struct msm_gpio dtv_panel_irq_gpios[] = {
3591 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
3592 "hdmi_int" },
3593};
3594
3595static struct msm_gpio dtv_panel_gpios[] = {
3596 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
3597 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
3598 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
3599 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
3600 { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
3601 { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
3602 { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
3603 { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
3604 { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
3605 { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
3606 { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
3607 { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
3608 { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
3609 { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
3610 { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
3611 { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
3612 { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
3613 { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
3614 { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
3615 { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
3616 { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
3617 { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
3618 { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
3619 { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
3620 { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
3621 { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
3622 { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
3623 { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
3624 { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
3625 { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
3626 { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
3627 { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
3628};
3629
3630
3631#ifdef HDMI_RESET
3632static unsigned dtv_reset_gpio =
3633 GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3634#endif
3635
Justin Paupore3f40f342011-08-10 18:52:16 -07003636static struct regulator_bulk_data hdmi_core_regs[] = {
3637 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3638};
3639
3640static struct regulator_bulk_data hdmi_comm_regs[] = {
3641 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3642 { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 },
3643};
3644
3645static struct regulator_bulk_data hdmi_cec_regs[] = {
3646 { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 },
3647};
3648
3649static int __init hdmi_init_regs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003650{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003651 int rc;
3652
Justin Paupore3f40f342011-08-10 18:52:16 -07003653 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs),
3654 hdmi_core_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003655
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003656 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003657 pr_err("%s: could not get %s regulators: %d\n",
3658 __func__, "core", rc);
3659 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003660 }
3661
Justin Paupore3f40f342011-08-10 18:52:16 -07003662 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs),
3663 hdmi_core_regs);
3664
3665 if (rc) {
3666 pr_err("%s: could not set %s voltages: %d\n",
3667 __func__, "core", rc);
3668 goto free_core;
3669 }
3670
3671 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs),
3672 hdmi_comm_regs);
3673
3674 if (rc) {
3675 pr_err("%s: could not get %s regulators: %d\n",
3676 __func__, "comm", rc);
3677 goto free_core;
3678 }
3679
3680 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs),
3681 hdmi_comm_regs);
3682
3683 if (rc) {
3684 pr_err("%s: could not set %s voltages: %d\n",
3685 __func__, "comm", rc);
3686 goto free_comm;
3687 }
3688
3689 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs),
3690 hdmi_cec_regs);
3691
3692 if (rc) {
3693 pr_err("%s: could not get %s regulators: %d\n",
3694 __func__, "cec", rc);
3695 goto free_comm;
3696 }
3697
3698 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs),
3699 hdmi_cec_regs);
3700
3701 if (rc) {
3702 pr_err("%s: could not set %s voltages: %d\n",
3703 __func__, "cec", rc);
3704 goto free_cec;
3705 }
3706
3707 return 0;
3708
3709free_cec:
3710 regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs);
3711free_comm:
3712 regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs);
3713free_core:
3714 regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs);
3715out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003716 return rc;
3717}
3718
Justin Paupore3f40f342011-08-10 18:52:16 -07003719static int hdmi_init_irq(void)
3720{
3721 int rc = msm_gpios_enable(dtv_panel_irq_gpios,
3722 ARRAY_SIZE(dtv_panel_irq_gpios));
3723 if (rc < 0) {
3724 pr_err("%s: gpio enable failed: %d\n", __func__, rc);
3725 return rc;
3726 }
3727 pr_info("%s\n", __func__);
3728
3729 return 0;
3730}
3731
3732static int hdmi_enable_5v(int on)
3733{
3734 int pmic_gpio_hdmi_5v_en ;
3735
3736 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
3737 machine_is_msm7x30_fluid())
3738 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
3739 else
3740 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
3741
3742 pr_info("%s: %d\n", __func__, on);
3743 if (on) {
3744 int rc;
3745 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
3746 "hdmi_5V_en");
3747 if (rc) {
3748 pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
3749 __func__);
3750 return rc;
3751 }
3752 gpio_set_value_cansleep(
3753 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
3754 } else {
3755 gpio_set_value_cansleep(
3756 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
3757 gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
3758 }
3759 return 0;
3760}
3761
3762static int hdmi_comm_power(int on, int show)
3763{
3764 if (show)
3765 pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
3766 return on ?
3767 regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs),
3768 hdmi_comm_regs) :
3769 regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs),
3770 hdmi_comm_regs);
3771}
3772
3773static int hdmi_core_power(int on, int show)
3774{
3775 if (show)
3776 pr_info("%s: %d <LDO8>\n", __func__, on);
3777 return on ?
3778 regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs),
3779 hdmi_core_regs) :
3780 regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs),
3781 hdmi_core_regs);
3782}
3783
3784static int hdmi_cec_power(int on)
3785{
3786 pr_info("%s: %d <LDO17>\n", __func__, on);
3787 return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs),
3788 hdmi_cec_regs) :
3789 regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs),
3790 hdmi_cec_regs);
3791}
3792
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003793#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
3794/* there is an i2c address conflict between adv7520 and bma150 sensor after
3795 * power up on fluid. As a solution, the default address of adv7520's packet
3796 * memory is changed as soon as possible
3797 */
3798static int __init fluid_i2c_address_fixup(void)
3799{
3800 unsigned char wBuff[16];
3801 unsigned char rBuff[16];
3802 struct i2c_msg msgs[3];
3803 int res;
3804 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003805 struct i2c_adapter *adapter;
3806
3807 if (machine_is_msm7x30_fluid()) {
3808 adapter = i2c_get_adapter(0);
3809 if (!adapter) {
3810 pr_err("%s: invalid i2c adapter\n", __func__);
3811 return PTR_ERR(adapter);
3812 }
3813
3814 /* turn on LDO8 */
Justin Paupore3f40f342011-08-10 18:52:16 -07003815 rc = hdmi_core_power(1, 0);
3816 if (rc) {
3817 pr_err("%s: could not enable hdmi core regs: %d",
3818 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003819 goto adapter_put;
3820 }
3821
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003822 /* change packet memory address to 0x74 */
3823 wBuff[0] = 0x45;
3824 wBuff[1] = 0x74;
3825
3826 msgs[0].addr = ADV7520_I2C_ADDR;
3827 msgs[0].flags = 0;
3828 msgs[0].buf = (unsigned char *) wBuff;
3829 msgs[0].len = 2;
3830
3831 res = i2c_transfer(adapter, msgs, 1);
3832 if (res != 1) {
3833 pr_err("%s: error writing adv7520\n", __func__);
3834 goto ldo8_disable;
3835 }
3836
3837 /* powerdown adv7520 using bit 6 */
3838 /* i2c read first */
3839 wBuff[0] = 0x41;
3840
3841 msgs[0].addr = ADV7520_I2C_ADDR;
3842 msgs[0].flags = 0;
3843 msgs[0].buf = (unsigned char *) wBuff;
3844 msgs[0].len = 1;
3845
3846 msgs[1].addr = ADV7520_I2C_ADDR;
3847 msgs[1].flags = I2C_M_RD;
3848 msgs[1].buf = rBuff;
3849 msgs[1].len = 1;
3850 res = i2c_transfer(adapter, msgs, 2);
3851 if (res != 2) {
3852 pr_err("%s: error reading adv7520\n", __func__);
3853 goto ldo8_disable;
3854 }
3855
3856 /* i2c write back */
3857 wBuff[0] = 0x41;
3858 wBuff[1] = rBuff[0] | 0x40;
3859
3860 msgs[0].addr = ADV7520_I2C_ADDR;
3861 msgs[0].flags = 0;
3862 msgs[0].buf = (unsigned char *) wBuff;
3863 msgs[0].len = 2;
3864
3865 res = i2c_transfer(adapter, msgs, 1);
3866 if (res != 1) {
3867 pr_err("%s: error writing adv7520\n", __func__);
3868 goto ldo8_disable;
3869 }
3870
3871 /* for successful fixup, we release the i2c adapter */
3872 /* but leave ldo8 on so that the adv7520 is not repowered */
3873 i2c_put_adapter(adapter);
3874 pr_info("%s: fluid i2c address conflict resolved\n", __func__);
3875 }
3876 return 0;
3877
3878ldo8_disable:
Justin Paupore3f40f342011-08-10 18:52:16 -07003879 hdmi_core_power(0, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003880adapter_put:
3881 i2c_put_adapter(adapter);
3882 return rc;
3883}
3884fs_initcall_sync(fluid_i2c_address_fixup);
3885#endif
3886
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003887static bool hdmi_check_hdcp_hw_support(void)
3888{
3889 if (machine_is_msm7x30_fluid())
3890 return false;
3891 else
3892 return true;
3893}
3894
3895static int dtv_panel_power(int on)
3896{
3897 int flag_on = !!on;
3898 static int dtv_power_save_on;
3899 int rc;
3900
3901 if (dtv_power_save_on == flag_on)
3902 return 0;
3903
3904 dtv_power_save_on = flag_on;
3905 pr_info("%s: %d\n", __func__, on);
3906
3907#ifdef HDMI_RESET
3908 if (on) {
3909 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
3910 rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
3911 if (rc) {
3912 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
3913 __func__, dtv_reset_gpio, rc);
3914 return rc;
3915 }
3916
3917 /* bring reset line low to hold reset*/
3918 gpio_set_value(37, 0);
3919 }
3920#endif
3921
3922 if (on) {
3923 rc = msm_gpios_enable(dtv_panel_gpios,
3924 ARRAY_SIZE(dtv_panel_gpios));
3925 if (rc < 0) {
3926 printk(KERN_ERR "%s: gpio enable failed: %d\n",
3927 __func__, rc);
3928 return rc;
3929 }
3930 } else {
3931 rc = msm_gpios_disable(dtv_panel_gpios,
3932 ARRAY_SIZE(dtv_panel_gpios));
3933 if (rc < 0) {
3934 printk(KERN_ERR "%s: gpio disable failed: %d\n",
3935 __func__, rc);
3936 return rc;
3937 }
3938 }
3939
3940 mdelay(5); /* ensure power is stable */
3941
3942#ifdef HDMI_RESET
3943 if (on) {
3944 gpio_set_value(37, 1); /* bring reset line high */
3945 mdelay(10); /* 10 msec before IO can be accessed */
3946 }
3947#endif
3948
3949 return rc;
3950}
3951
3952static struct lcdc_platform_data dtv_pdata = {
3953 .lcdc_power_save = dtv_panel_power,
3954};
3955
3956static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3957 .inject_rx_on_wakeup = 1,
3958 .rx_to_inject = 0xFD,
3959};
3960
3961static struct resource msm_fb_resources[] = {
3962 {
3963 .flags = IORESOURCE_DMA,
3964 }
3965};
3966
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08003967#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
3968static struct resource msm_v4l2_video_overlay_resources[] = {
3969 {
3970 .flags = IORESOURCE_DMA,
3971 }
3972};
3973#endif
3974
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003975static int msm_fb_detect_panel(const char *name)
3976{
3977 if (machine_is_msm7x30_fluid()) {
3978 if (!strcmp(name, "lcdc_sharp_wvga_pt"))
3979 return 0;
3980 } else {
3981 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
3982 return -EPERM;
3983 else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20))
3984 return 0;
3985 else if (!strcmp(name, "mddi_orise"))
3986 return -EPERM;
3987 else if (!strcmp(name, "mddi_quickvx"))
3988 return -EPERM;
3989 }
3990 return -ENODEV;
3991}
3992
3993static struct msm_fb_platform_data msm_fb_pdata = {
3994 .detect_client = msm_fb_detect_panel,
3995 .mddi_prescan = 1,
3996};
3997
3998static struct platform_device msm_fb_device = {
3999 .name = "msm_fb",
4000 .id = 0,
4001 .num_resources = ARRAY_SIZE(msm_fb_resources),
4002 .resource = msm_fb_resources,
4003 .dev = {
4004 .platform_data = &msm_fb_pdata,
4005 }
4006};
4007
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08004008#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
4009
4010static struct platform_device msm_v4l2_video_overlay_device = {
4011 .name = "msm_v4l2_overlay_pd",
4012 .id = 0,
4013 .num_resources = ARRAY_SIZE(msm_v4l2_video_overlay_resources),
4014 .resource = msm_v4l2_video_overlay_resources,
4015};
4016#endif
4017
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004018static struct platform_device msm_migrate_pages_device = {
4019 .name = "msm_migrate_pages",
4020 .id = -1,
4021};
4022
4023static struct android_pmem_platform_data android_pmem_adsp_pdata = {
4024 .name = "pmem_adsp",
4025 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4026 .cached = 0,
4027 .memory_type = MEMTYPE_EBI0,
4028};
4029
4030static struct android_pmem_platform_data android_pmem_audio_pdata = {
4031 .name = "pmem_audio",
4032 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4033 .cached = 0,
4034 .memory_type = MEMTYPE_EBI0,
4035};
4036
4037static struct platform_device android_pmem_adsp_device = {
4038 .name = "android_pmem",
4039 .id = 2,
4040 .dev = { .platform_data = &android_pmem_adsp_pdata },
4041};
4042
4043static struct platform_device android_pmem_audio_device = {
4044 .name = "android_pmem",
4045 .id = 4,
4046 .dev = { .platform_data = &android_pmem_audio_pdata },
4047};
4048
4049#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4050 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
4051 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4052 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4053
4054#define QCE_SIZE 0x10000
4055#define QCE_0_BASE 0xA8400000
4056
4057#define QCE_HW_KEY_SUPPORT 1
4058#define QCE_SHA_HMAC_SUPPORT 0
4059#define QCE_SHARE_CE_RESOURCE 0
4060#define QCE_CE_SHARED 0
4061
4062static struct resource qcrypto_resources[] = {
4063 [0] = {
4064 .start = QCE_0_BASE,
4065 .end = QCE_0_BASE + QCE_SIZE - 1,
4066 .flags = IORESOURCE_MEM,
4067 },
4068 [1] = {
4069 .name = "crypto_channels",
4070 .start = DMOV_CE_IN_CHAN,
4071 .end = DMOV_CE_OUT_CHAN,
4072 .flags = IORESOURCE_DMA,
4073 },
4074 [2] = {
4075 .name = "crypto_crci_in",
4076 .start = DMOV_CE_IN_CRCI,
4077 .end = DMOV_CE_IN_CRCI,
4078 .flags = IORESOURCE_DMA,
4079 },
4080 [3] = {
4081 .name = "crypto_crci_out",
4082 .start = DMOV_CE_OUT_CRCI,
4083 .end = DMOV_CE_OUT_CRCI,
4084 .flags = IORESOURCE_DMA,
4085 },
4086 [4] = {
4087 .name = "crypto_crci_hash",
4088 .start = DMOV_CE_HASH_CRCI,
4089 .end = DMOV_CE_HASH_CRCI,
4090 .flags = IORESOURCE_DMA,
4091 },
4092};
4093
4094static struct resource qcedev_resources[] = {
4095 [0] = {
4096 .start = QCE_0_BASE,
4097 .end = QCE_0_BASE + QCE_SIZE - 1,
4098 .flags = IORESOURCE_MEM,
4099 },
4100 [1] = {
4101 .name = "crypto_channels",
4102 .start = DMOV_CE_IN_CHAN,
4103 .end = DMOV_CE_OUT_CHAN,
4104 .flags = IORESOURCE_DMA,
4105 },
4106 [2] = {
4107 .name = "crypto_crci_in",
4108 .start = DMOV_CE_IN_CRCI,
4109 .end = DMOV_CE_IN_CRCI,
4110 .flags = IORESOURCE_DMA,
4111 },
4112 [3] = {
4113 .name = "crypto_crci_out",
4114 .start = DMOV_CE_OUT_CRCI,
4115 .end = DMOV_CE_OUT_CRCI,
4116 .flags = IORESOURCE_DMA,
4117 },
4118 [4] = {
4119 .name = "crypto_crci_hash",
4120 .start = DMOV_CE_HASH_CRCI,
4121 .end = DMOV_CE_HASH_CRCI,
4122 .flags = IORESOURCE_DMA,
4123 },
4124};
4125
4126#endif
4127
4128#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4129 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
4130
4131static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
4132 .ce_shared = QCE_CE_SHARED,
4133 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4134 .hw_key_support = QCE_HW_KEY_SUPPORT,
4135 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004136 /* Bus Scaling declaration*/
4137 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004138};
4139
4140static struct platform_device qcrypto_device = {
4141 .name = "qcrypto",
4142 .id = 0,
4143 .num_resources = ARRAY_SIZE(qcrypto_resources),
4144 .resource = qcrypto_resources,
4145 .dev = {
4146 .coherent_dma_mask = DMA_BIT_MASK(32),
4147 .platform_data = &qcrypto_ce_hw_suppport,
4148 },
4149};
4150#endif
4151
4152#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4153 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4154
4155static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
4156 .ce_shared = QCE_CE_SHARED,
4157 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4158 .hw_key_support = QCE_HW_KEY_SUPPORT,
4159 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004160 /* Bus Scaling declaration*/
4161 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004162};
4163static struct platform_device qcedev_device = {
4164 .name = "qce",
4165 .id = 0,
4166 .num_resources = ARRAY_SIZE(qcedev_resources),
4167 .resource = qcedev_resources,
4168 .dev = {
4169 .coherent_dma_mask = DMA_BIT_MASK(32),
4170 .platform_data = &qcedev_ce_hw_suppport,
4171 },
4172};
4173#endif
4174
4175static int mddi_toshiba_pmic_bl(int level)
4176{
4177 int ret = -EPERM;
4178
4179 ret = pmic_set_led_intensity(LED_LCD, level);
4180
4181 if (ret)
4182 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
4183 __func__);
4184 return ret;
4185}
4186
4187static struct msm_panel_common_pdata mddi_toshiba_pdata = {
4188 .pmic_backlight = mddi_toshiba_pmic_bl,
4189};
4190
4191static struct platform_device mddi_toshiba_device = {
4192 .name = "mddi_toshiba",
4193 .id = 0,
4194 .dev = {
4195 .platform_data = &mddi_toshiba_pdata,
4196 }
4197};
4198
4199static unsigned wega_reset_gpio =
4200 GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4201
4202static struct msm_gpio fluid_vee_reset_gpio[] = {
4203 { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
4204};
4205
4206static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1;
4207static unsigned char quickvx_ldo_enabled;
4208
4209static unsigned quickvx_vlp_gpio =
4210 GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4211
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304212static struct pm8xxx_gpio_init_info pmic_quickvx_clk_gpio = {
4213 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_QUICKVX_CLK),
4214 {
4215 .direction = PM_GPIO_DIR_OUT,
4216 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
4217 .output_value = 1,
4218 .pull = PM_GPIO_PULL_NO,
4219 .vin_sel = PM8058_GPIO_VIN_S3,
4220 .out_strength = PM_GPIO_STRENGTH_HIGH,
4221 .function = PM_GPIO_FUNC_2,
4222 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004223};
4224
Justin Paupore3f40f342011-08-10 18:52:16 -07004225static struct regulator *mddi_ldo20;
4226static struct regulator *mddi_ldo12;
4227static struct regulator *mddi_ldo16;
4228static struct regulator *mddi_ldo6;
4229static struct regulator *mddi_lcd;
4230
4231static int display_common_init(void)
4232{
4233 struct regulator_bulk_data regs[5] = {
4234 { .supply = "ldo20", /* voltage set in display_common_power */},
4235 { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 },
4236 { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 },
4237 { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 },
4238 { .supply = NULL, /* mddi_lcd, initialized below */ },
4239 };
4240
4241 int rc = 0;
4242
4243 if (machine_is_msm7x30_fluid()) {
4244 /* lcd: LDO8 @1.8V */
4245 regs[4].supply = "ldo8";
4246 regs[4].min_uV = 1800000;
4247 regs[4].max_uV = 1800000;
4248 } else {
4249 /* lcd: LDO15 @3.1V */
4250 regs[4].supply = "ldo15";
4251 regs[4].min_uV = 3100000;
4252 regs[4].max_uV = 3100000;
4253 }
4254
4255 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4256 if (rc) {
4257 pr_err("%s: regulator_bulk_get failed: %d\n",
4258 __func__, rc);
4259 goto bail;
4260 }
4261
4262 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4263 if (rc) {
4264 pr_err("%s: regulator_bulk_set_voltage failed: %d\n",
4265 __func__, rc);
4266 goto put_regs;
4267 }
4268
4269 mddi_ldo20 = regs[0].consumer;
4270 mddi_ldo12 = regs[1].consumer;
4271 mddi_ldo6 = regs[2].consumer;
4272 mddi_ldo16 = regs[3].consumer;
4273 mddi_lcd = regs[4].consumer;
4274
4275 return rc;
4276
4277put_regs:
4278 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4279bail:
4280 return rc;
4281}
4282
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004283static int display_common_power(int on)
4284{
4285 int rc = 0, flag_on = !!on;
4286 static int display_common_power_save_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004287 static bool display_regs_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004288
4289 if (display_common_power_save_on == flag_on)
4290 return 0;
4291
4292 display_common_power_save_on = flag_on;
4293
Justin Paupore3f40f342011-08-10 18:52:16 -07004294 if (unlikely(!display_regs_initialized)) {
4295 rc = display_common_init();
4296 if (rc) {
4297 pr_err("%s: regulator init failed: %d\n",
4298 __func__, rc);
4299 return rc;
4300 }
4301 display_regs_initialized = true;
4302 }
4303
4304
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004305 if (on) {
4306 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
4307 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
4308 if (rc) {
4309 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4310 __func__, wega_reset_gpio, rc);
4311 return rc;
4312 }
4313
4314 /* bring reset line low to hold reset*/
4315 gpio_set_value(180, 0);
4316
4317 if (quickvx_mddi_client) {
4318 /* QuickVX chip -- VLP pin -- gpio 97 */
4319 rc = gpio_tlmm_config(quickvx_vlp_gpio,
4320 GPIO_CFG_ENABLE);
4321 if (rc) {
4322 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4323 __func__, quickvx_vlp_gpio, rc);
4324 return rc;
4325 }
4326
4327 /* bring QuickVX VLP line low */
4328 gpio_set_value(97, 0);
4329
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304330 rc = pm8xxx_gpio_config(pmic_quickvx_clk_gpio.gpio,
4331 &pmic_quickvx_clk_gpio.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004332 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304333 pr_err("%s: pm8xxx_gpio_config(%#x)=%d\n",
4334 __func__, pmic_quickvx_clk_gpio.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004335 rc);
4336 return rc;
4337 }
4338
4339 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4340 PMIC_GPIO_QUICKVX_CLK), 0);
4341 }
4342 }
4343
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004344 if (quickvx_mddi_client)
Jeevan Shriram9624b742012-08-08 11:19:49 +05304345 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1800000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004346 else
Justin Paupore3f40f342011-08-10 18:52:16 -07004347 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000);
4348
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004349 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004350 pr_err("%s: could not set voltage for ldo20: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004351 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07004352 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004353 }
4354
4355 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004356 rc = regulator_enable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004357 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004358 pr_err("%s: LDO20 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004359 __func__, rc);
4360 return rc;
4361 }
4362
Justin Paupore3f40f342011-08-10 18:52:16 -07004363 rc = regulator_enable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004364 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004365 pr_err("%s: LDO12 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004366 __func__, rc);
4367 return rc;
4368 }
4369
4370 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004371 rc = regulator_enable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004372 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004373 pr_err("%s: LDO16 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004374 __func__, rc);
4375 return rc;
4376 }
4377 }
4378
Justin Paupore3f40f342011-08-10 18:52:16 -07004379 if (quickvx_ldo_enabled) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004380 /* Disable LDO6 during display ON */
Justin Paupore3f40f342011-08-10 18:52:16 -07004381 rc = regulator_disable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004382 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004383 pr_err("%s: LDO6 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004384 __func__, rc);
4385 return rc;
4386 }
4387 quickvx_ldo_enabled = 0;
4388 }
4389
Justin Paupore3f40f342011-08-10 18:52:16 -07004390 rc = regulator_enable(mddi_lcd);
4391 if (rc) {
4392 pr_err("%s: LCD regulator enable failed (%d)\n",
4393 __func__, rc);
4394 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004395 }
4396
4397 mdelay(5); /* ensure power is stable */
4398
4399 if (machine_is_msm7x30_fluid()) {
4400 rc = msm_gpios_request_enable(fluid_vee_reset_gpio,
4401 ARRAY_SIZE(fluid_vee_reset_gpio));
4402 if (rc)
4403 pr_err("%s gpio_request_enable failed rc=%d\n",
4404 __func__, rc);
4405 else {
4406 /* assert vee reset_n */
4407 gpio_set_value(20, 1);
4408 gpio_set_value(20, 0);
4409 mdelay(1);
4410 gpio_set_value(20, 1);
4411 }
4412 }
4413
4414 gpio_set_value(180, 1); /* bring reset line high */
4415 mdelay(10); /* 10 msec before IO can be accessed */
4416
4417 if (quickvx_mddi_client) {
4418 gpio_set_value(97, 1);
4419 msleep(2);
4420 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4421 PMIC_GPIO_QUICKVX_CLK), 1);
4422 msleep(2);
4423 }
4424
4425 rc = pmapp_display_clock_config(1);
4426 if (rc) {
4427 pr_err("%s pmapp_display_clock_config rc=%d\n",
4428 __func__, rc);
4429 return rc;
4430 }
4431
4432 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004433 rc = regulator_disable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004434 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004435 pr_err("%s: LDO20 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004436 __func__, rc);
4437 return rc;
4438 }
4439
4440
4441 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004442 rc = regulator_disable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004443 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004444 pr_err("%s: LDO16 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004445 __func__, rc);
4446 return rc;
4447 }
4448 }
4449
4450 if (quickvx_mddi_client && !quickvx_ldo_enabled) {
4451 /* Enable LDO6 during display OFF for
4452 Quicklogic chip to sleep with data retention */
Justin Paupore3f40f342011-08-10 18:52:16 -07004453 rc = regulator_enable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004454 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004455 pr_err("%s: LDO6 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004456 __func__, rc);
4457 return rc;
4458 }
4459 quickvx_ldo_enabled = 1;
4460 }
4461
4462 gpio_set_value(180, 0); /* bring reset line low */
4463
4464 if (quickvx_mddi_client) {
4465 gpio_set_value(97, 0);
4466 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4467 PMIC_GPIO_QUICKVX_CLK), 0);
4468 }
4469
Justin Paupore3f40f342011-08-10 18:52:16 -07004470 rc = regulator_disable(mddi_lcd);
4471 if (rc) {
4472 pr_err("%s: LCD regulator disable failed (%d)\n",
4473 __func__, rc);
4474 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004475 }
4476
4477 mdelay(5); /* ensure power is stable */
4478
Justin Paupore3f40f342011-08-10 18:52:16 -07004479 rc = regulator_disable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004480 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004481 pr_err("%s: LDO12 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004482 __func__, rc);
4483 return rc;
4484 }
4485
4486 if (machine_is_msm7x30_fluid()) {
4487 msm_gpios_disable_free(fluid_vee_reset_gpio,
4488 ARRAY_SIZE(fluid_vee_reset_gpio));
4489 }
4490
4491 rc = pmapp_display_clock_config(0);
4492 if (rc) {
4493 pr_err("%s pmapp_display_clock_config rc=%d\n",
4494 __func__, rc);
4495 return rc;
4496 }
4497 }
4498
4499 return rc;
4500}
4501
4502static int msm_fb_mddi_sel_clk(u32 *clk_rate)
4503{
4504 *clk_rate *= 2;
4505 return 0;
4506}
4507
4508static int msm_fb_mddi_client_power(u32 client_id)
4509{
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304510 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004511 printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
4512 /* Check if it is Quicklogic client */
4513 if (client_id == 0xc5835800) {
4514 printk(KERN_NOTICE "\n Quicklogic MDDI client");
4515 other_mddi_client = 0;
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304516 if (IS_ERR(mddi_ldo16)) {
4517 rc = PTR_ERR(mddi_ldo16);
4518 pr_err("%s: gp10 vreg get failed (%d)\n", __func__, rc);
4519 return rc;
4520 }
4521 rc = regulator_disable(mddi_ldo16);
4522 if (rc) {
4523 pr_err("%s: LDO16 vreg enable failed (%d)\n",
4524 __func__, rc);
4525 return rc;
4526 }
4527
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004528 } else {
4529 printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
4530 quickvx_mddi_client = 0;
4531 gpio_set_value(97, 0);
4532 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4533 PMIC_GPIO_QUICKVX_CLK), 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004534 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004535
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004536 return 0;
4537}
4538
4539static struct mddi_platform_data mddi_pdata = {
4540 .mddi_power_save = display_common_power,
4541 .mddi_sel_clk = msm_fb_mddi_sel_clk,
4542 .mddi_client_power = msm_fb_mddi_client_power,
4543};
4544
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004545static struct msm_panel_common_pdata mdp_pdata = {
4546 .hw_revision_addr = 0xac001270,
4547 .gpio = 30,
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07004548 .mdp_max_clk = 192000000,
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07004549 .mdp_rev = MDP_REV_40,
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05304550 .mem_hid = MEMTYPE_EBI0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004551};
4552
4553static int lcd_panel_spi_gpio_num[] = {
4554 45, /* spi_clk */
4555 46, /* spi_cs */
4556 47, /* spi_mosi */
4557 48, /* spi_miso */
4558 };
4559
4560static struct msm_gpio lcd_panel_gpios[] = {
4561/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
4562 * input. if there is a hardware revision; we should reassign this GPIO to a
4563 * new open line; and removing it will just ensure that this will be missed in
4564 * the future.
4565 { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
4566 */
4567 { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
4568 { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
4569 { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
4570 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4571 { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
4572 { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
4573 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4574#ifndef CONFIG_SPI_QSD
4575 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
4576 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
4577 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
4578 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
4579#endif
4580 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4581 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4582 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4583 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4584 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4585 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4586 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4587 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4588 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4589 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4590 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4591 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4592 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4593 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4594 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4595 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4596 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4597 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4598 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4599 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4600};
4601
4602static struct msm_gpio lcd_sharp_panel_gpios[] = {
4603 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4604 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4605 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4606 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4607 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4608 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4609 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4610 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4611 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4612 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4613 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4614 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4615 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4616 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4617 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4618 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4619 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4620 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4621 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4622 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4623 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4624 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4625};
4626
4627static int lcdc_toshiba_panel_power(int on)
4628{
4629 int rc, i;
4630 struct msm_gpio *gp;
4631
4632 rc = display_common_power(on);
4633 if (rc < 0) {
4634 printk(KERN_ERR "%s display_common_power failed: %d\n",
4635 __func__, rc);
4636 return rc;
4637 }
4638
4639 if (on) {
4640 rc = msm_gpios_enable(lcd_panel_gpios,
4641 ARRAY_SIZE(lcd_panel_gpios));
4642 if (rc < 0) {
4643 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4644 __func__, rc);
4645 }
4646 } else { /* off */
4647 gp = lcd_panel_gpios;
4648 for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
4649 /* ouput low */
4650 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4651 gp++;
4652 }
4653 }
4654
4655 return rc;
4656}
4657
4658static int lcdc_sharp_panel_power(int on)
4659{
4660 int rc, i;
4661 struct msm_gpio *gp;
4662
4663 rc = display_common_power(on);
4664 if (rc < 0) {
4665 printk(KERN_ERR "%s display_common_power failed: %d\n",
4666 __func__, rc);
4667 return rc;
4668 }
4669
4670 if (on) {
4671 rc = msm_gpios_enable(lcd_sharp_panel_gpios,
4672 ARRAY_SIZE(lcd_sharp_panel_gpios));
4673 if (rc < 0) {
4674 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4675 __func__, rc);
4676 }
4677 } else { /* off */
4678 gp = lcd_sharp_panel_gpios;
4679 for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) {
4680 /* ouput low */
4681 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4682 gp++;
4683 }
4684 }
4685
4686 return rc;
4687}
4688
4689static int lcdc_panel_power(int on)
4690{
4691 int flag_on = !!on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004692 static int lcdc_power_save_on, lcdc_power_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004693
4694 if (lcdc_power_save_on == flag_on)
4695 return 0;
4696
4697 lcdc_power_save_on = flag_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004698
4699 if (unlikely(!lcdc_power_initialized)) {
4700 quickvx_mddi_client = 0;
4701 display_common_init();
4702 lcdc_power_initialized = 1;
4703 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004704
4705 if (machine_is_msm7x30_fluid())
4706 return lcdc_sharp_panel_power(on);
4707 else
4708 return lcdc_toshiba_panel_power(on);
4709}
4710
4711static struct lcdc_platform_data lcdc_pdata = {
4712 .lcdc_power_save = lcdc_panel_power,
4713};
4714
Justin Paupore3f40f342011-08-10 18:52:16 -07004715static struct regulator *atv_s4, *atv_ldo9;
4716
4717static int __init atv_dac_power_init(void)
4718{
4719 int rc;
4720 struct regulator_bulk_data regs[] = {
4721 { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 },
4722 { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 },
4723 };
4724
4725 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4726
4727 if (rc) {
4728 pr_err("%s: could not get regulators: %d\n", __func__, rc);
4729 goto bail;
4730 }
4731
4732 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4733
4734 if (rc) {
4735 pr_err("%s: could not set voltages: %d\n", __func__, rc);
4736 goto reg_free;
4737 }
4738
4739 atv_s4 = regs[0].consumer;
4740 atv_ldo9 = regs[1].consumer;
4741
4742reg_free:
4743 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4744bail:
4745 return rc;
4746}
4747
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004748static int atv_dac_power(int on)
4749{
4750 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004751
4752 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004753 rc = regulator_enable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004754 if (rc) {
4755 pr_err("%s: s4 vreg enable failed (%d)\n",
4756 __func__, rc);
4757 return rc;
4758 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004759 rc = regulator_enable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004760 if (rc) {
4761 pr_err("%s: ldo9 vreg enable failed (%d)\n",
4762 __func__, rc);
4763 return rc;
4764 }
4765 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004766 rc = regulator_disable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004767 if (rc) {
4768 pr_err("%s: ldo9 vreg disable failed (%d)\n",
4769 __func__, rc);
4770 return rc;
4771 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004772 rc = regulator_disable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004773 if (rc) {
4774 pr_err("%s: s4 vreg disable failed (%d)\n",
4775 __func__, rc);
4776 return rc;
4777 }
4778 }
4779 return rc;
4780}
4781
4782static struct tvenc_platform_data atv_pdata = {
4783 .poll = 1,
4784 .pm_vid_en = atv_dac_power,
4785};
4786
4787static void __init msm_fb_add_devices(void)
4788{
4789 msm_fb_register_device("mdp", &mdp_pdata);
4790 msm_fb_register_device("pmdh", &mddi_pdata);
4791 msm_fb_register_device("lcdc", &lcdc_pdata);
4792 msm_fb_register_device("dtv", &dtv_pdata);
4793 msm_fb_register_device("tvenc", &atv_pdata);
4794#ifdef CONFIG_FB_MSM_TVOUT
4795 msm_fb_register_device("tvout_device", NULL);
4796#endif
4797}
4798
4799static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
4800 .gpio_num = lcd_panel_spi_gpio_num,
4801};
4802
4803static struct platform_device lcdc_toshiba_panel_device = {
4804 .name = "lcdc_toshiba_wvga",
4805 .id = 0,
4806 .dev = {
4807 .platform_data = &lcdc_toshiba_panel_data,
4808 }
4809};
4810
4811#if defined(CONFIG_MARIMBA_CORE) && \
4812 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4813static struct platform_device msm_bt_power_device = {
4814 .name = "bt_power",
4815 .id = -1
4816};
4817
4818enum {
4819 BT_RFR,
4820 BT_CTS,
4821 BT_RX,
4822 BT_TX,
4823};
4824
4825static struct msm_gpio bt_config_power_on[] = {
4826 { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4827 "UART1DM_RFR" },
4828 { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4829 "UART1DM_CTS" },
4830 { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4831 "UART1DM_Rx" },
4832 { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4833 "UART1DM_Tx" }
4834};
4835
4836static struct msm_gpio bt_config_power_off[] = {
4837 { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4838 "UART1DM_RFR" },
4839 { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4840 "UART1DM_CTS" },
4841 { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4842 "UART1DM_Rx" },
4843 { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4844 "UART1DM_Tx" }
4845};
4846
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004847static u8 bahama_version;
4848
Justin Paupore3f40f342011-08-10 18:52:16 -07004849static struct regulator_bulk_data regs_bt_marimba[] = {
4850 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4851 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
4852 { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304853 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004854};
4855
4856static struct regulator_bulk_data regs_bt_bahama_v1[] = {
4857 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4858 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
4859 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304860 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004861};
4862
4863static struct regulator_bulk_data regs_bt_bahama_v2[] = {
4864 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4865 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304866 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004867};
4868
4869static struct regulator_bulk_data *regs_bt;
4870static int regs_bt_count;
4871
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004872static int marimba_bt(int on)
4873{
4874 int rc;
4875 int i;
4876 struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
4877
4878 struct marimba_config_register {
4879 u8 reg;
4880 u8 value;
4881 u8 mask;
4882 };
4883
4884 struct marimba_variant_register {
4885 const size_t size;
4886 const struct marimba_config_register *set;
4887 };
4888
4889 const struct marimba_config_register *p;
4890
4891 u8 version;
4892
4893 const struct marimba_config_register v10_bt_on[] = {
4894 { 0xE5, 0x0B, 0x0F },
4895 { 0x05, 0x02, 0x07 },
4896 { 0x06, 0x88, 0xFF },
4897 { 0xE7, 0x21, 0x21 },
4898 { 0xE3, 0x38, 0xFF },
4899 { 0xE4, 0x06, 0xFF },
4900 };
4901
4902 const struct marimba_config_register v10_bt_off[] = {
4903 { 0xE5, 0x0B, 0x0F },
4904 { 0x05, 0x08, 0x0F },
4905 { 0x06, 0x88, 0xFF },
4906 { 0xE7, 0x00, 0x21 },
4907 { 0xE3, 0x00, 0xFF },
4908 { 0xE4, 0x00, 0xFF },
4909 };
4910
4911 const struct marimba_config_register v201_bt_on[] = {
4912 { 0x05, 0x08, 0x07 },
4913 { 0x06, 0x88, 0xFF },
4914 { 0xE7, 0x21, 0x21 },
4915 { 0xE3, 0x38, 0xFF },
4916 { 0xE4, 0x06, 0xFF },
4917 };
4918
4919 const struct marimba_config_register v201_bt_off[] = {
4920 { 0x05, 0x08, 0x07 },
4921 { 0x06, 0x88, 0xFF },
4922 { 0xE7, 0x00, 0x21 },
4923 { 0xE3, 0x00, 0xFF },
4924 { 0xE4, 0x00, 0xFF },
4925 };
4926
4927 const struct marimba_config_register v210_bt_on[] = {
4928 { 0xE9, 0x01, 0x01 },
4929 { 0x06, 0x88, 0xFF },
4930 { 0xE7, 0x21, 0x21 },
4931 { 0xE3, 0x38, 0xFF },
4932 { 0xE4, 0x06, 0xFF },
4933 };
4934
4935 const struct marimba_config_register v210_bt_off[] = {
4936 { 0x06, 0x88, 0xFF },
4937 { 0xE7, 0x00, 0x21 },
4938 { 0xE9, 0x00, 0x01 },
4939 { 0xE3, 0x00, 0xFF },
4940 { 0xE4, 0x00, 0xFF },
4941 };
4942
4943 const struct marimba_variant_register bt_marimba[2][4] = {
4944 {
4945 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4946 { 0, NULL },
4947 { ARRAY_SIZE(v201_bt_off), v201_bt_off },
4948 { ARRAY_SIZE(v210_bt_off), v210_bt_off }
4949 },
4950 {
4951 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4952 { 0, NULL },
4953 { ARRAY_SIZE(v201_bt_on), v201_bt_on },
4954 { ARRAY_SIZE(v210_bt_on), v210_bt_on }
4955 }
4956 };
4957
4958 on = on ? 1 : 0;
4959
4960 rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F);
4961 if (rc < 0) {
4962 printk(KERN_ERR
4963 "%s: version read failed: %d\n",
4964 __func__, rc);
4965 return rc;
4966 }
4967
4968 if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
4969 (bt_marimba[on][version].size == 0)) {
4970 printk(KERN_ERR
4971 "%s: unsupported version\n",
4972 __func__);
4973 return -EIO;
4974 }
4975
4976 p = bt_marimba[on][version].set;
4977
4978 printk(KERN_INFO "%s: found version %d\n", __func__, version);
4979
4980 for (i = 0; i < bt_marimba[on][version].size; i++) {
4981 u8 value = (p+i)->value;
4982 rc = marimba_write_bit_mask(&config,
4983 (p+i)->reg,
4984 &value,
4985 sizeof((p+i)->value),
4986 (p+i)->mask);
4987 if (rc < 0) {
4988 printk(KERN_ERR
4989 "%s: reg %d write failed: %d\n",
4990 __func__, (p+i)->reg, rc);
4991 return rc;
4992 }
4993 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
4994 __func__, (p+i)->reg,
4995 value, (p+i)->mask);
4996 }
4997 return 0;
4998}
4999
5000static int bahama_bt(int on)
5001{
5002 int rc;
5003 int i;
5004 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
5005
5006 struct bahama_variant_register {
5007 const size_t size;
5008 const struct bahama_config_register *set;
5009 };
5010
5011 const struct bahama_config_register *p;
5012
5013
5014 const struct bahama_config_register v10_bt_on[] = {
5015 { 0xE9, 0x00, 0xFF },
5016 { 0xF4, 0x80, 0xFF },
5017 { 0xF0, 0x06, 0xFF },
5018 { 0xE4, 0x00, 0xFF },
5019 { 0xE5, 0x00, 0x0F },
5020#ifdef CONFIG_WLAN
5021 { 0xE6, 0x38, 0x7F },
5022 { 0xE7, 0x06, 0xFF },
5023#endif
5024 { 0x11, 0x13, 0xFF },
5025 { 0xE9, 0x21, 0xFF },
5026 { 0x01, 0x0C, 0x1F },
5027 { 0x01, 0x08, 0x1F },
5028 };
5029
5030 const struct bahama_config_register v20_bt_on_fm_off[] = {
5031 { 0x11, 0x0C, 0xFF },
5032 { 0x13, 0x01, 0xFF },
5033 { 0xF4, 0x80, 0xFF },
5034 { 0xF0, 0x00, 0xFF },
5035 { 0xE9, 0x00, 0xFF },
5036#ifdef CONFIG_WLAN
5037 { 0x81, 0x00, 0xFF },
5038 { 0x82, 0x00, 0xFF },
5039 { 0xE6, 0x38, 0x7F },
5040 { 0xE7, 0x06, 0xFF },
5041#endif
5042 { 0xE9, 0x21, 0xFF }
5043 };
5044
5045 const struct bahama_config_register v20_bt_on_fm_on[] = {
5046 { 0x11, 0x0C, 0xFF },
5047 { 0x13, 0x01, 0xFF },
5048 { 0xF4, 0x86, 0xFF },
5049 { 0xF0, 0x06, 0xFF },
5050 { 0xE9, 0x00, 0xFF },
5051#ifdef CONFIG_WLAN
5052 { 0x81, 0x00, 0xFF },
5053 { 0x82, 0x00, 0xFF },
5054 { 0xE6, 0x38, 0x7F },
5055 { 0xE7, 0x06, 0xFF },
5056#endif
5057 { 0xE9, 0x21, 0xFF }
5058 };
5059
5060 const struct bahama_config_register v10_bt_off[] = {
5061 { 0xE9, 0x00, 0xFF },
5062 };
5063
5064 const struct bahama_config_register v20_bt_off_fm_off[] = {
5065 { 0xF4, 0x84, 0xFF },
5066 { 0xF0, 0x04, 0xFF },
5067 { 0xE9, 0x00, 0xFF }
5068 };
5069
5070 const struct bahama_config_register v20_bt_off_fm_on[] = {
5071 { 0xF4, 0x86, 0xFF },
5072 { 0xF0, 0x06, 0xFF },
5073 { 0xE9, 0x00, 0xFF }
5074 };
5075
5076 const struct bahama_variant_register bt_bahama[2][3] = {
5077 {
5078 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
5079 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
5080 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
5081 },
5082 {
5083 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
5084 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
5085 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
5086 }
5087 };
5088
5089 u8 offset = 0; /* index into bahama configs */
5090
5091 on = on ? 1 : 0;
5092
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005093
5094 if (bahama_version == VER_2_0) {
5095 if (marimba_get_fm_status(&config))
5096 offset = 0x01;
5097 }
5098
5099 p = bt_bahama[on][bahama_version + offset].set;
5100
5101 dev_info(&msm_bt_power_device.dev,
5102 "%s: found version %d\n", __func__, bahama_version);
5103
5104 for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
5105 u8 value = (p+i)->value;
5106 rc = marimba_write_bit_mask(&config,
5107 (p+i)->reg,
5108 &value,
5109 sizeof((p+i)->value),
5110 (p+i)->mask);
5111 if (rc < 0) {
5112 dev_err(&msm_bt_power_device.dev,
5113 "%s: reg %d write failed: %d\n",
5114 __func__, (p+i)->reg, rc);
5115 return rc;
5116 }
5117 dev_info(&msm_bt_power_device.dev,
5118 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
5119 __func__, (p+i)->reg,
5120 value, (p+i)->mask);
5121 }
5122 /* Update BT status */
5123 if (on)
5124 marimba_set_bt_status(&config, true);
5125 else
5126 marimba_set_bt_status(&config, false);
5127
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005128 return 0;
5129}
5130
Justin Paupore3f40f342011-08-10 18:52:16 -07005131static int bluetooth_regs_init(int bahama_not_marimba)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005132{
Justin Paupore3f40f342011-08-10 18:52:16 -07005133 int rc = 0;
5134 struct device *const dev = &msm_bt_power_device.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005135
5136 if (bahama_not_marimba) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005137 bahama_version = read_bahama_ver();
5138
5139 switch (bahama_version) {
5140 case VER_1_0:
5141 regs_bt = regs_bt_bahama_v1;
5142 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1);
5143 break;
5144 case VER_2_0:
5145 regs_bt = regs_bt_bahama_v2;
5146 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2);
5147 break;
5148 case VER_UNSUPPORTED:
5149 default:
5150 dev_err(dev,
5151 "%s: i2c failure or unsupported version: %d\n",
5152 __func__, bahama_version);
5153 rc = -EIO;
5154 goto out;
5155 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005156 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07005157 regs_bt = regs_bt_marimba;
5158 regs_bt_count = ARRAY_SIZE(regs_bt_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005159 }
5160
Justin Paupore3f40f342011-08-10 18:52:16 -07005161 rc = regulator_bulk_get(&msm_bt_power_device.dev,
5162 regs_bt_count, regs_bt);
5163 if (rc) {
5164 dev_err(dev, "%s: could not get regulators: %d\n",
5165 __func__, rc);
5166 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005167 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005168
5169 rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt);
5170 if (rc) {
5171 dev_err(dev, "%s: could not set voltages: %d\n",
5172 __func__, rc);
5173 goto reg_free;
5174 }
5175
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005176 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005177
5178reg_free:
5179 regulator_bulk_free(regs_bt_count, regs_bt);
5180out:
5181 regs_bt_count = 0;
5182 regs_bt = NULL;
5183 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005184}
5185
5186static int bluetooth_power(int on)
5187{
5188 int rc;
5189 const char *id = "BTPW";
5190
5191 int bahama_not_marimba = bahama_present();
5192
Ram Mohan Korukonda1747cde2012-10-04 22:10:59 +05305193 if (bahama_not_marimba < 0) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005194 printk(KERN_WARNING "%s: bahama_present: %d\n",
5195 __func__, bahama_not_marimba);
5196 return -ENODEV;
5197 }
5198
Justin Paupore3f40f342011-08-10 18:52:16 -07005199 if (unlikely(regs_bt_count == 0)) {
5200 rc = bluetooth_regs_init(bahama_not_marimba);
5201 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005202 return rc;
Justin Paupore3f40f342011-08-10 18:52:16 -07005203 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005204
Justin Paupore3f40f342011-08-10 18:52:16 -07005205 if (on) {
5206 rc = regulator_bulk_enable(regs_bt_count, regs_bt);
5207 if (rc)
5208 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005209
5210 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5211 PMAPP_CLOCK_VOTE_ON);
5212 if (rc < 0)
5213 return -EIO;
5214
5215 if (machine_is_msm8x55_svlte_surf() ||
5216 machine_is_msm8x55_svlte_ffa()) {
5217 rc = marimba_gpio_config(1);
5218 if (rc < 0)
5219 return -EIO;
5220 }
5221
5222 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5223 if (rc < 0)
5224 return -EIO;
5225
5226 msleep(10);
5227
5228 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5229 PMAPP_CLOCK_VOTE_PIN_CTRL);
5230 if (rc < 0)
5231 return -EIO;
5232
5233 if (machine_is_msm8x55_svlte_surf() ||
5234 machine_is_msm8x55_svlte_ffa()) {
5235 rc = marimba_gpio_config(0);
5236 if (rc < 0)
5237 return -EIO;
5238 }
5239
5240 rc = msm_gpios_enable(bt_config_power_on,
5241 ARRAY_SIZE(bt_config_power_on));
5242
5243 if (rc < 0)
5244 return rc;
5245
5246 } else {
5247 rc = msm_gpios_enable(bt_config_power_off,
5248 ARRAY_SIZE(bt_config_power_off));
5249 if (rc < 0)
5250 return rc;
5251
5252 /* check for initial RFKILL block (power off) */
5253 if (platform_get_drvdata(&msm_bt_power_device) == NULL)
5254 goto out;
5255
5256 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5257 if (rc < 0)
5258 return -EIO;
5259
5260 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5261 PMAPP_CLOCK_VOTE_OFF);
5262 if (rc < 0)
5263 return -EIO;
5264
Justin Paupore3f40f342011-08-10 18:52:16 -07005265 rc = regulator_bulk_disable(regs_bt_count, regs_bt);
5266 if (rc)
5267 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005268
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005269 }
5270
5271out:
5272 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
5273
5274 return 0;
5275}
5276
5277static void __init bt_power_init(void)
5278{
Justin Paupore3f40f342011-08-10 18:52:16 -07005279 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005280}
5281#else
5282#define bt_power_init(x) do {} while (0)
5283#endif
5284
5285static struct msm_psy_batt_pdata msm_psy_batt_data = {
5286 .voltage_min_design = 2800,
5287 .voltage_max_design = 4300,
5288 .avail_chg_sources = AC_CHG | USB_CHG ,
5289 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
5290};
5291
5292static struct platform_device msm_batt_device = {
5293 .name = "msm-battery",
5294 .id = -1,
5295 .dev.platform_data = &msm_psy_batt_data,
5296};
5297
5298static char *msm_adc_fluid_device_names[] = {
5299 "LTC_ADC1",
5300 "LTC_ADC2",
5301 "LTC_ADC3",
5302};
5303
5304static char *msm_adc_surf_device_names[] = {
5305 "XO_ADC",
5306};
5307
5308static struct msm_adc_platform_data msm_adc_pdata;
5309
5310static struct platform_device msm_adc_device = {
5311 .name = "msm_adc",
5312 .id = -1,
5313 .dev = {
5314 .platform_data = &msm_adc_pdata,
5315 },
5316};
5317
5318#ifdef CONFIG_MSM_SDIO_AL
5319static struct msm_gpio mdm2ap_status = {
5320 GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5321 "mdm2ap_status"
5322};
5323
5324
5325static int configure_mdm2ap_status(int on)
5326{
5327 if (on)
5328 return msm_gpios_request_enable(&mdm2ap_status, 1);
5329 else {
5330 msm_gpios_disable_free(&mdm2ap_status, 1);
5331 return 0;
5332 }
5333}
5334
5335static int get_mdm2ap_status(void)
5336{
5337 return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
5338}
5339
5340static struct sdio_al_platform_data sdio_al_pdata = {
5341 .config_mdm2ap_status = configure_mdm2ap_status,
5342 .get_mdm2ap_status = get_mdm2ap_status,
5343 .allow_sdioc_version_major_2 = 1,
5344 .peer_sdioc_version_minor = 0x0001,
5345 .peer_sdioc_version_major = 0x0003,
5346 .peer_sdioc_boot_version_minor = 0x0001,
5347 .peer_sdioc_boot_version_major = 0x0003,
5348};
5349
5350struct platform_device msm_device_sdio_al = {
5351 .name = "msm_sdio_al",
5352 .id = -1,
5353 .dev = {
5354 .platform_data = &sdio_al_pdata,
5355 },
5356};
5357
5358#endif /* CONFIG_MSM_SDIO_AL */
5359
Daniel Walker8d747cd2010-02-25 11:37:43 -08005360static struct platform_device *devices[] __initdata = {
Daniel Walker90e37c52010-05-12 14:24:15 -07005361#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005362 &msm_device_uart2,
5363#endif
Justin Paupore637a25d2011-07-14 17:11:04 -07005364#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
5365 &msm_proccomm_regulator_dev,
5366#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005367 &asoc_msm_pcm,
5368 &asoc_msm_dai0,
5369 &asoc_msm_dai1,
5370#if defined (CONFIG_SND_MSM_MVS_DAI_SOC)
5371 &asoc_msm_mvs,
5372 &asoc_mvs_dai0,
5373 &asoc_mvs_dai1,
Daniel Walker90e37c52010-05-12 14:24:15 -07005374#endif
Niranjana Vishwanathapuraa8855e92010-10-06 13:52:10 -07005375 &msm_device_smd,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005376 &msm_device_dmov,
5377 &smc91x_device,
5378 &smsc911x_device,
5379 &msm_device_nand,
5380#ifdef CONFIG_USB_MSM_OTG_72K
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05305381 &msm_device_otg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005382#ifdef CONFIG_USB_GADGET
5383 &msm_device_gadget_peripheral,
5384#endif
5385#endif
5386#ifdef CONFIG_USB_G_ANDROID
5387 &android_usb_device,
5388#endif
5389 &qsd_device_spi,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305390
5391#ifdef CONFIG_MSM_SSBI
5392 &msm_device_ssbi_pmic1,
5393#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005394#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005395 &msm_device_ssbi7,
5396#endif
5397 &android_pmem_device,
5398 &msm_fb_device,
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08005399#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
5400 &msm_v4l2_video_overlay_device,
5401#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005402 &msm_migrate_pages_device,
5403 &mddi_toshiba_device,
5404 &lcdc_toshiba_panel_device,
5405#ifdef CONFIG_MSM_ROTATOR
5406 &msm_rotator_device,
5407#endif
5408 &lcdc_sharp_panel_device,
5409 &android_pmem_adsp_device,
5410 &android_pmem_audio_device,
5411 &msm_device_i2c,
5412 &msm_device_i2c_2,
5413 &msm_device_uart_dm1,
5414 &hs_device,
5415#ifdef CONFIG_MSM7KV2_AUDIO
5416 &msm_aictl_device,
5417 &msm_mi2s_device,
5418 &msm_lpa_device,
5419 &msm_aux_pcm_device,
5420#endif
5421 &msm_device_adspdec,
5422 &qup_device_i2c,
5423#if defined(CONFIG_MARIMBA_CORE) && \
5424 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5425 &msm_bt_power_device,
5426#endif
5427 &msm_kgsl_3d0,
5428 &msm_kgsl_2d0,
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005429#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005430#ifdef CONFIG_MT9T013
5431 &msm_camera_sensor_mt9t013,
5432#endif
5433#ifdef CONFIG_MT9D112
5434 &msm_camera_sensor_mt9d112,
5435#endif
5436#ifdef CONFIG_WEBCAM_OV9726
5437 &msm_camera_sensor_ov9726,
5438#endif
5439#ifdef CONFIG_S5K3E2FX
5440 &msm_camera_sensor_s5k3e2fx,
5441#endif
5442#ifdef CONFIG_MT9P012
5443 &msm_camera_sensor_mt9p012,
5444#endif
5445#ifdef CONFIG_MT9E013
5446 &msm_camera_sensor_mt9e013,
5447#endif
5448#ifdef CONFIG_VX6953
5449 &msm_camera_sensor_vx6953,
5450#endif
5451#ifdef CONFIG_SN12M0PZ
5452 &msm_camera_sensor_sn12m0pz,
5453#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005454#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005455 &msm_device_vidc_720p,
5456#ifdef CONFIG_MSM_GEMINI
5457 &msm_gemini_device,
5458#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005459#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005460#ifdef CONFIG_MSM_VPE
5461 &msm_vpe_device,
5462#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005463#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005464#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5465 &msm_device_tsif,
5466#endif
5467#ifdef CONFIG_MSM_SDIO_AL
5468 &msm_device_sdio_al,
5469#endif
5470
5471#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5472 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5473 &qcrypto_device,
5474#endif
5475
5476#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5477 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5478 &qcedev_device,
5479#endif
5480
5481 &msm_batt_device,
5482 &msm_adc_device,
5483 &msm_ebi0_thermal,
Laxminath Kasam1d8255d2012-02-15 13:10:19 +05305484 &msm_ebi1_thermal,
Chintan Pandya03b698a2012-06-28 19:03:09 +05305485 &msm_adsp_device,
5486#ifdef CONFIG_ION_MSM
5487 &ion_dev,
5488#endif
Daniel Walker8d747cd2010-02-25 11:37:43 -08005489};
5490
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005491static struct msm_gpio msm_i2c_gpios_hw[] = {
5492 { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5493 { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5494};
5495
5496static struct msm_gpio msm_i2c_gpios_io[] = {
5497 { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5498 { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5499};
5500
5501static struct msm_gpio qup_i2c_gpios_io[] = {
5502 { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5503 { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5504};
5505static struct msm_gpio qup_i2c_gpios_hw[] = {
5506 { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5507 { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5508};
5509
5510static void
5511msm_i2c_gpio_config(int adap_id, int config_type)
5512{
5513 struct msm_gpio *msm_i2c_table;
5514
5515 /* Each adapter gets 2 lines from the table */
5516 if (adap_id > 0)
5517 return;
5518 if (config_type)
5519 msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
5520 else
5521 msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
5522 msm_gpios_enable(msm_i2c_table, 2);
5523}
5524/*This needs to be enabled only for OEMS*/
5525#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005526static struct regulator *qup_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005527#endif
5528static void
5529qup_i2c_gpio_config(int adap_id, int config_type)
5530{
5531 int rc = 0;
5532 struct msm_gpio *qup_i2c_table;
5533 /* Each adapter gets 2 lines from the table */
5534 if (adap_id != 4)
5535 return;
5536 if (config_type)
5537 qup_i2c_table = qup_i2c_gpios_hw;
5538 else
5539 qup_i2c_table = qup_i2c_gpios_io;
5540 rc = msm_gpios_enable(qup_i2c_table, 2);
5541 if (rc < 0)
5542 printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
5543 /*This needs to be enabled only for OEMS*/
5544#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005545 if (!IS_ERR_OR_NULL(qup_vreg)) {
5546 rc = regulator_enable(qup_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005547 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005548 pr_err("%s: regulator_enable failed: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005549 __func__, rc);
5550 }
5551 }
5552#endif
5553}
5554
5555static struct msm_i2c_platform_data msm_i2c_pdata = {
5556 .clk_freq = 100000,
5557 .pri_clk = 70,
5558 .pri_dat = 71,
5559 .rmutex = 1,
5560 .rsl_id = "D:I2C02000021",
5561 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5562};
5563
5564static void __init msm_device_i2c_init(void)
5565{
5566 if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
5567 pr_err("failed to request I2C gpios\n");
5568
5569 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
5570}
5571
5572static struct msm_i2c_platform_data msm_i2c_2_pdata = {
5573 .clk_freq = 100000,
5574 .rmutex = 1,
5575 .rsl_id = "D:I2C02000022",
5576 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5577};
5578
5579static void __init msm_device_i2c_2_init(void)
5580{
5581 msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
5582}
5583
5584static struct msm_i2c_platform_data qup_i2c_pdata = {
5585 .clk_freq = 384000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005586 .msm_i2c_config_gpio = qup_i2c_gpio_config,
5587};
5588
5589static void __init qup_device_i2c_init(void)
5590{
5591 if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
5592 pr_err("failed to request I2C gpios\n");
5593
5594 qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
5595 /*This needs to be enabled only for OEMS*/
5596#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005597 qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005598 if (IS_ERR(qup_vreg)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005599 dev_err(&qup_device_i2c.dev,
5600 "%s: regulator_get failed: %ld\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005601 __func__, PTR_ERR(qup_vreg));
5602 }
5603#endif
5604}
5605
5606#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005607static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = {
5608 .rsl_id = "D:CODEC_SSBI",
5609 .controller_type = MSM_SBI_CTRL_SSBI,
5610};
5611#endif
5612
Daniel Walker8d747cd2010-02-25 11:37:43 -08005613static void __init msm7x30_init_irq(void)
5614{
5615 msm_init_irq();
5616}
5617
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005618static struct msm_gpio msm_nand_ebi2_cfg_data[] = {
5619 {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
5620 {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
5621};
5622
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005623#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
5624 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
5625 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
5626 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
5627
5628struct sdcc_gpio {
5629 struct msm_gpio *cfg_data;
5630 uint32_t size;
5631 struct msm_gpio *sleep_cfg_data;
5632};
5633#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5634static struct msm_gpio sdc1_lvlshft_cfg_data[] = {
5635 {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
5636};
5637#endif
5638static struct msm_gpio sdc1_cfg_data[] = {
5639 {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
5640 {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
5641 {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
5642 {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
5643 {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
5644 {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
5645};
5646
5647static struct msm_gpio sdc2_cfg_data[] = {
5648 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
5649 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
5650 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
5651 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
5652 {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
5653 {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
5654
5655#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5656 {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
5657 {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
5658 {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
5659 {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
5660#endif
5661};
5662
5663static struct msm_gpio sdc3_cfg_data[] = {
5664 {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
5665 {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
5666 {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
5667 {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
5668 {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
5669 {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
5670};
5671
5672static struct msm_gpio sdc3_sleep_cfg_data[] = {
5673 {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5674 "sdc3_clk"},
5675 {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5676 "sdc3_cmd"},
5677 {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5678 "sdc3_dat_3"},
5679 {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5680 "sdc3_dat_2"},
5681 {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5682 "sdc3_dat_1"},
5683 {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5684 "sdc3_dat_0"},
5685};
5686
5687static struct msm_gpio sdc4_cfg_data[] = {
5688 {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
5689 {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
5690 {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
5691 {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
5692 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
5693 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
5694};
5695
5696static struct sdcc_gpio sdcc_cfg_data[] = {
5697 {
5698 .cfg_data = sdc1_cfg_data,
5699 .size = ARRAY_SIZE(sdc1_cfg_data),
5700 .sleep_cfg_data = NULL,
5701 },
5702 {
5703 .cfg_data = sdc2_cfg_data,
5704 .size = ARRAY_SIZE(sdc2_cfg_data),
5705 .sleep_cfg_data = NULL,
5706 },
5707 {
5708 .cfg_data = sdc3_cfg_data,
5709 .size = ARRAY_SIZE(sdc3_cfg_data),
5710 .sleep_cfg_data = sdc3_sleep_cfg_data,
5711 },
5712 {
5713 .cfg_data = sdc4_cfg_data,
5714 .size = ARRAY_SIZE(sdc4_cfg_data),
5715 .sleep_cfg_data = NULL,
5716 },
5717};
5718
Justin Paupore3f40f342011-08-10 18:52:16 -07005719static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005720
5721static unsigned long vreg_sts, gpio_sts;
5722
5723static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
5724{
5725 int rc = 0;
5726 struct sdcc_gpio *curr;
5727
5728 curr = &sdcc_cfg_data[dev_id - 1];
5729
5730 if (!(test_bit(dev_id, &gpio_sts)^enable))
5731 return rc;
5732
5733 if (enable) {
5734 set_bit(dev_id, &gpio_sts);
5735 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
5736 if (rc)
5737 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
5738 __func__, dev_id);
5739 } else {
5740 clear_bit(dev_id, &gpio_sts);
5741 if (curr->sleep_cfg_data) {
5742 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
5743 msm_gpios_free(curr->sleep_cfg_data, curr->size);
5744 } else {
5745 msm_gpios_disable_free(curr->cfg_data, curr->size);
5746 }
5747 }
5748
5749 return rc;
5750}
5751
5752static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
5753{
5754 int rc = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005755 struct regulator *curr = sdcc_vreg_data[dev_id - 1];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005756 static int enabled_once[] = {0, 0, 0, 0};
5757
Justin Paupore3f40f342011-08-10 18:52:16 -07005758 if (test_bit(dev_id, &vreg_sts) == enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005759 return rc;
5760
Asutosh Das853bbcd2012-02-01 10:40:05 +05305761 if (dev_id == 4) {
5762 if (enable) {
5763 pr_debug("Enable Vdd dev_%d\n", dev_id);
5764 gpio_set_value_cansleep(
5765 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5766 0);
5767 set_bit(dev_id, &vreg_sts);
5768 } else {
5769 pr_debug("Disable Vdd dev_%d\n", dev_id);
5770 gpio_set_value_cansleep(
5771 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5772 1);
5773 clear_bit(dev_id, &vreg_sts);
5774 }
5775 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005776
Asutosh Das853bbcd2012-02-01 10:40:05 +05305777 if (!enable || enabled_once[dev_id - 1])
5778 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005779 if (!curr)
5780 return -ENODEV;
5781
5782 if (IS_ERR(curr))
5783 return PTR_ERR(curr);
5784
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005785 if (enable) {
5786 set_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005787
5788 rc = regulator_enable(curr);
5789 if (rc)
5790 pr_err("%s: could not enable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005791 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005792 enabled_once[dev_id - 1] = 1;
5793 } else {
5794 clear_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005795
5796 rc = regulator_disable(curr);
5797 if (rc)
5798 pr_err("%s: could not disable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005799 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005800 }
5801 return rc;
5802}
5803
5804static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
5805{
5806 int rc = 0;
5807 struct platform_device *pdev;
5808
5809 pdev = container_of(dv, struct platform_device, dev);
5810 rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
5811 if (rc)
5812 goto out;
5813
5814 if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
5815 rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
5816out:
5817 return rc;
5818}
5819
5820#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \
5821 defined(CONFIG_CSDIO_VENDOR_ID) && \
5822 defined(CONFIG_CSDIO_DEVICE_ID) && \
5823 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5824
5825#define MBP_ON 1
5826#define MBP_OFF 0
5827
5828#define MBP_RESET_N \
5829 GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
5830#define MBP_INT0 \
5831 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
5832
5833#define MBP_MODE_CTRL_0 \
5834 GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5835#define MBP_MODE_CTRL_1 \
5836 GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5837#define MBP_MODE_CTRL_2 \
5838 GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5839#define TSIF_EN \
5840 GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5841#define TSIF_DATA \
5842 GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5843#define TSIF_CLK \
5844 GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5845
5846static struct msm_gpio mbp_cfg_data[] = {
5847 {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5848 "mbp_reset"},
5849 {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5850 "mbp_io_voltage"},
5851};
5852
5853static int mbp_config_gpios_pre_init(int enable)
5854{
5855 int rc = 0;
5856
5857 if (enable) {
5858 rc = msm_gpios_request_enable(mbp_cfg_data,
5859 ARRAY_SIZE(mbp_cfg_data));
5860 if (rc) {
5861 printk(KERN_ERR
5862 "%s: Failed to turnon GPIOs for mbp chip(%d)\n",
5863 __func__, rc);
5864 }
5865 } else
5866 msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
5867 return rc;
5868}
5869
Justin Paupore3f40f342011-08-10 18:52:16 -07005870static struct regulator_bulk_data mbp_regs_io[2];
5871static struct regulator_bulk_data mbp_regs_rf[2];
5872static struct regulator_bulk_data mbp_regs_adc[1];
5873static struct regulator_bulk_data mbp_regs_core[1];
5874
5875static int mbp_init_regs(struct device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005876{
Justin Paupore3f40f342011-08-10 18:52:16 -07005877 struct regulator_bulk_data regs[] = {
5878 /* Analog and I/O regs */
5879 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
5880 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
5881 /* RF regs */
5882 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
5883 { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 },
5884 /* ADC regs */
5885 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
5886 /* Core regs */
5887 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
5888 };
5889
5890 struct regulator_bulk_data *regptr = regs;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005891 int rc;
5892
Justin Paupore3f40f342011-08-10 18:52:16 -07005893 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs);
5894
5895 if (rc) {
5896 dev_err(dev, "%s: could not get regulators: %d\n",
5897 __func__, rc);
5898 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005899 }
5900
Justin Paupore3f40f342011-08-10 18:52:16 -07005901 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005902
Justin Paupore3f40f342011-08-10 18:52:16 -07005903 if (rc) {
5904 dev_err(dev, "%s: could not set voltages: %d\n",
5905 __func__, rc);
5906 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005907 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005908
5909 memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io));
5910 regptr += ARRAY_SIZE(mbp_regs_io);
5911
5912 memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf));
5913 regptr += ARRAY_SIZE(mbp_regs_rf);
5914
5915 memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc));
5916 regptr += ARRAY_SIZE(mbp_regs_adc);
5917
5918 memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core));
5919
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005920 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005921
5922reg_free:
5923 regulator_bulk_free(ARRAY_SIZE(regs), regs);
5924out:
5925 return rc;
5926}
5927
5928static int mbp_setup_rf_vregs(int state)
5929{
5930 return state ?
5931 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) :
5932 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005933}
5934
5935static int mbp_setup_vregs(int state)
5936{
Justin Paupore3f40f342011-08-10 18:52:16 -07005937 return state ?
5938 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) :
5939 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005940}
5941
5942static int mbp_set_tcxo_en(int enable)
5943{
5944 int rc;
5945 const char *id = "UBMC";
5946 struct vreg *vreg_analog = NULL;
5947
5948 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
5949 enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
5950 if (rc < 0) {
5951 printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
5952 __func__, enable ? "" : "de-");
5953 return -EIO;
5954 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005955 return rc;
5956}
5957
5958static void mbp_set_freeze_io(int state)
5959{
5960 if (state)
5961 gpio_set_value(85, 0);
5962 else
5963 gpio_set_value(85, 1);
5964}
5965
5966static int mbp_set_core_voltage_en(int enable)
5967{
Justin Paupore3f40f342011-08-10 18:52:16 -07005968 static bool is_enabled;
5969 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005970
Justin Paupore3f40f342011-08-10 18:52:16 -07005971 if (enable && !is_enabled) {
5972 rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core),
5973 mbp_regs_core);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005974 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005975 pr_err("%s: could not enable regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005976 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07005977 } else {
5978 is_enabled = true;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005979 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005980 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005981
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005982 return rc;
5983}
5984
5985static void mbp_set_reset(int state)
5986{
5987 if (state)
5988 gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
5989 else
5990 gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
5991}
5992
5993static int mbp_config_interface_mode(int state)
5994{
5995 if (state) {
5996 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
5997 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
5998 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
5999 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
6000 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
6001 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
6002 } else {
6003 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
6004 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
6005 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
6006 }
6007 return 0;
6008}
6009
6010static int mbp_setup_adc_vregs(int state)
6011{
Justin Paupore3f40f342011-08-10 18:52:16 -07006012 return state ?
6013 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) :
6014 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006015}
6016
6017static int mbp_power_up(void)
6018{
6019 int rc;
6020
6021 rc = mbp_config_gpios_pre_init(MBP_ON);
6022 if (rc)
6023 goto exit;
6024 pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__);
6025
6026 rc = mbp_setup_vregs(MBP_ON);
6027 if (rc)
6028 goto exit;
6029 pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
6030
6031 rc = mbp_set_tcxo_en(MBP_ON);
6032 if (rc)
6033 goto exit;
6034 pr_debug("%s: tcxo clock done\n", __func__);
6035
6036 mbp_set_freeze_io(MBP_OFF);
6037 pr_debug("%s: set gpio 85 to 1 done\n", __func__);
6038
6039 udelay(100);
6040 mbp_set_reset(MBP_ON);
6041
6042 udelay(300);
6043 rc = mbp_config_interface_mode(MBP_ON);
6044 if (rc)
6045 goto exit;
6046 pr_debug("%s: mbp_config_interface_mode() done\n", __func__);
6047
6048 udelay(100 + mbp_set_core_voltage_en(MBP_ON));
6049 pr_debug("%s: power gp16 1.2V done\n", __func__);
6050
6051 mbp_set_freeze_io(MBP_ON);
6052 pr_debug("%s: set gpio 85 to 0 done\n", __func__);
6053
6054 udelay(100);
6055
6056 rc = mbp_setup_rf_vregs(MBP_ON);
6057 if (rc)
6058 goto exit;
6059 pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
6060
6061 rc = mbp_setup_adc_vregs(MBP_ON);
6062 if (rc)
6063 goto exit;
6064 pr_debug("%s: s4 2.2V done\n", __func__);
6065
6066 udelay(200);
6067
6068 mbp_set_reset(MBP_OFF);
6069 pr_debug("%s: close gpio 44 done\n", __func__);
6070
6071 msleep(20);
6072exit:
6073 return rc;
6074}
6075
6076static int mbp_power_down(void)
6077{
6078 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006079
6080 mbp_set_reset(MBP_ON);
6081 pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
6082
6083 udelay(100);
6084
6085 rc = mbp_setup_adc_vregs(MBP_OFF);
6086 if (rc)
6087 goto exit;
6088 pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
6089
6090 udelay(5);
6091
6092 rc = mbp_setup_rf_vregs(MBP_OFF);
6093 if (rc)
6094 goto exit;
6095 pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
6096
6097 udelay(5);
6098
6099 mbp_set_freeze_io(MBP_OFF);
6100 pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
6101
6102 udelay(100);
6103 rc = mbp_set_core_voltage_en(MBP_OFF);
6104 if (rc)
6105 goto exit;
6106 pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
6107
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006108 rc = mbp_set_tcxo_en(MBP_OFF);
6109 if (rc)
6110 goto exit;
6111 pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
6112
Justin Paupore3f40f342011-08-10 18:52:16 -07006113 rc = mbp_setup_vregs(MBP_OFF);
6114 if (rc)
6115 goto exit;
6116 pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__);
6117
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006118 rc = mbp_config_gpios_pre_init(MBP_OFF);
6119 if (rc)
6120 goto exit;
6121exit:
6122 return rc;
6123}
6124
6125static void (*mbp_status_notify_cb)(int card_present, void *dev_id);
6126static void *mbp_status_notify_cb_devid;
6127static int mbp_power_status;
6128static int mbp_power_init_done;
6129
6130static uint32_t mbp_setup_power(struct device *dv,
6131 unsigned int power_status)
6132{
6133 int rc = 0;
6134 struct platform_device *pdev;
6135
6136 pdev = container_of(dv, struct platform_device, dev);
6137
6138 if (power_status == mbp_power_status)
6139 goto exit;
6140 if (power_status) {
6141 pr_debug("turn on power of mbp slot");
6142 rc = mbp_power_up();
6143 mbp_power_status = 1;
6144 } else {
6145 pr_debug("turn off power of mbp slot");
6146 rc = mbp_power_down();
6147 mbp_power_status = 0;
6148 }
6149exit:
6150 return rc;
6151};
6152
6153int mbp_register_status_notify(void (*callback)(int, void *),
6154 void *dev_id)
6155{
6156 mbp_status_notify_cb = callback;
6157 mbp_status_notify_cb_devid = dev_id;
6158 return 0;
6159}
6160
6161static unsigned int mbp_status(struct device *dev)
6162{
6163 return mbp_power_status;
6164}
6165
6166static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd)
6167{
6168 struct platform_device *pdev;
6169 uint32_t rc = 0;
6170
6171 pdev = container_of(dv, struct platform_device, dev);
6172 rc = msm_sdcc_setup_power(dv, vdd);
6173 if (rc) {
6174 pr_err("%s: Failed to setup power (%d)\n",
6175 __func__, rc);
6176 goto out;
6177 }
6178 if (!mbp_power_init_done) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006179 rc = mbp_init_regs(dv);
6180 if (rc) {
6181 dev_err(dv, "%s: regulator init failed: %d\n",
6182 __func__, rc);
6183 goto out;
6184 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006185 mbp_setup_power(dv, 1);
6186 mbp_setup_power(dv, 0);
6187 mbp_power_init_done = 1;
6188 }
6189 if (vdd >= 0x8000) {
6190 rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
6191 if (rc) {
6192 pr_err("%s: Failed to config mbp chip power (%d)\n",
6193 __func__, rc);
6194 goto out;
6195 }
6196 if (mbp_status_notify_cb) {
6197 mbp_status_notify_cb(mbp_power_status,
6198 mbp_status_notify_cb_devid);
6199 }
6200 }
6201out:
6202 /* should return 0 only */
6203 return 0;
6204}
6205
6206#endif
6207
6208#endif
6209
6210#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006211static unsigned int msm7x30_sdcc_slot_status(struct device *dev)
6212{
6213 return (unsigned int)
6214 gpio_get_value_cansleep(
6215 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1));
6216}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006217
6218static int msm_sdcc_get_wpswitch(struct device *dv)
6219{
6220 void __iomem *wp_addr = 0;
6221 uint32_t ret = 0;
6222 struct platform_device *pdev;
6223
6224 if (!(machine_is_msm7x30_surf()))
6225 return -1;
6226 pdev = container_of(dv, struct platform_device, dev);
6227
6228 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
6229 if (!wp_addr) {
6230 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
6231 return -ENOMEM;
6232 }
6233
6234 ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
6235 pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
6236 pdev->id, ret);
6237 iounmap(wp_addr);
6238
6239 return ret;
6240}
6241#endif
6242
6243#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
6244#if defined(CONFIG_CSDIO_VENDOR_ID) && \
6245 defined(CONFIG_CSDIO_DEVICE_ID) && \
6246 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
6247static struct mmc_platform_data msm7x30_sdc1_data = {
6248 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
6249 .translate_vdd = msm_sdcc_setup_power_mbp,
6250 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6251 .status = mbp_status,
6252 .register_status_notify = mbp_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006253 .msmsdcc_fmin = 144000,
6254 .msmsdcc_fmid = 24576000,
6255 .msmsdcc_fmax = 24576000,
6256 .nonremovable = 0,
6257};
6258#else
6259static struct mmc_platform_data msm7x30_sdc1_data = {
6260 .ocr_mask = MMC_VDD_165_195,
6261 .translate_vdd = msm_sdcc_setup_power,
6262 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006263 .msmsdcc_fmin = 144000,
6264 .msmsdcc_fmid = 24576000,
6265 .msmsdcc_fmax = 49152000,
6266 .nonremovable = 0,
6267};
6268#endif
6269#endif
6270
6271#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
6272static struct mmc_platform_data msm7x30_sdc2_data = {
6273 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
6274 .translate_vdd = msm_sdcc_setup_power,
6275#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
6276 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
6277#else
6278 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6279#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006280 .msmsdcc_fmin = 144000,
6281 .msmsdcc_fmid = 24576000,
6282 .msmsdcc_fmax = 49152000,
6283 .nonremovable = 1,
6284};
6285#endif
6286
6287#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
6288static struct mmc_platform_data msm7x30_sdc3_data = {
6289 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6290 .translate_vdd = msm_sdcc_setup_power,
6291 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006292 .sdiowakeup_irq = MSM_GPIO_TO_INT(118),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006293 .msmsdcc_fmin = 144000,
6294 .msmsdcc_fmid = 24576000,
6295 .msmsdcc_fmax = 49152000,
6296 .nonremovable = 0,
6297};
6298#endif
6299
6300#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6301static struct mmc_platform_data msm7x30_sdc4_data = {
6302 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6303 .translate_vdd = msm_sdcc_setup_power,
6304 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006305 .status = msm7x30_sdcc_slot_status,
6306 .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
6307 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006308 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006309 .msmsdcc_fmin = 144000,
6310 .msmsdcc_fmid = 24576000,
6311 .msmsdcc_fmax = 49152000,
6312 .nonremovable = 0,
6313};
6314#endif
6315
6316#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006317static int msm_sdc1_lvlshft_enable(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006318{
Justin Paupore3f40f342011-08-10 18:52:16 -07006319 static struct regulator *ldo5;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006320 int rc;
6321
6322 /* Enable LDO5, an input to the FET that powers slot 1 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006323
Justin Paupore3f40f342011-08-10 18:52:16 -07006324 ldo5 = regulator_get(NULL, "ldo5");
6325
6326 if (IS_ERR(ldo5)) {
6327 rc = PTR_ERR(ldo5);
6328 pr_err("%s: could not get ldo5: %d\n", __func__, rc);
6329 goto out;
6330 }
6331
6332 rc = regulator_set_voltage(ldo5, 2850000, 2850000);
6333 if (rc) {
6334 pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc);
6335 goto ldo5_free;
6336 }
6337
6338 rc = regulator_enable(ldo5);
6339 if (rc) {
6340 pr_err("%s: could not enable ldo5: %d\n", __func__, rc);
6341 goto ldo5_free;
6342 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006343
6344 /* Enable GPIO 35, to turn on the FET that powers slot 1 */
6345 rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
6346 ARRAY_SIZE(sdc1_lvlshft_cfg_data));
6347 if (rc)
6348 printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
6349
6350 rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg),
6351 1);
6352 if (rc)
6353 printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006354
6355 return 0;
6356
6357ldo5_free:
6358 regulator_put(ldo5);
6359out:
6360 ldo5 = NULL;
6361 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006362}
6363#endif
6364
Justin Paupore3f40f342011-08-10 18:52:16 -07006365static int mmc_regulator_init(int sdcc_no, const char *supply, int uV)
6366{
6367 int rc;
6368
6369 BUG_ON(sdcc_no < 1 || sdcc_no > 4);
6370
6371 sdcc_no--;
6372
6373 sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply);
6374
6375 if (IS_ERR(sdcc_vreg_data[sdcc_no])) {
6376 rc = PTR_ERR(sdcc_vreg_data[sdcc_no]);
6377 pr_err("%s: could not get regulator \"%s\": %d\n",
6378 __func__, supply, rc);
6379 goto out;
6380 }
6381
6382 rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV);
6383
6384 if (rc) {
6385 pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n",
6386 __func__, supply, uV, rc);
6387 goto reg_free;
6388 }
6389
6390 return rc;
6391
6392reg_free:
6393 regulator_put(sdcc_vreg_data[sdcc_no]);
6394out:
6395 sdcc_vreg_data[sdcc_no] = NULL;
6396 return rc;
6397}
6398
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006399static void __init msm7x30_init_mmc(void)
6400{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006401#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006402 if (mmc_regulator_init(1, "s3", 1800000))
6403 goto out1;
6404
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006405 if (machine_is_msm7x30_fluid()) {
6406 msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
Justin Paupore3f40f342011-08-10 18:52:16 -07006407 if (msm_sdc1_lvlshft_enable()) {
6408 pr_err("%s: could not enable level shift\n");
6409 goto out1;
6410 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006411 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006412
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006413 msm_add_sdcc(1, &msm7x30_sdc1_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006414out1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006415#endif
6416#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006417 if (mmc_regulator_init(2, "s3", 1800000))
6418 goto out2;
6419
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006420 if (machine_is_msm8x55_svlte_surf())
6421 msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
Sujith Reddy Thumma84a0f512011-08-29 09:57:03 +05306422 if (machine_is_msm8x55_svlte_surf() ||
6423 machine_is_msm8x55_svlte_ffa()) {
6424 msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
6425 msm7x30_sdc2_data.is_sdio_al_client = 1;
6426 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006427
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006428 msm_add_sdcc(2, &msm7x30_sdc2_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006429out2:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006430#endif
6431#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006432 if (mmc_regulator_init(3, "s3", 1800000))
6433 goto out3;
6434
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006435 msm_sdcc_setup_gpio(3, 1);
6436 msm_add_sdcc(3, &msm7x30_sdc3_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006437out3:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006438#endif
6439#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006440 if (mmc_regulator_init(4, "mmc", 2850000))
6441 return;
6442
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006443 msm_add_sdcc(4, &msm7x30_sdc4_data);
6444#endif
6445
6446}
6447
6448static void __init msm7x30_init_nand(void)
6449{
6450 char *build_id;
6451 struct flash_platform_data *plat_data;
6452
6453 build_id = socinfo_get_build_id();
6454 if (build_id == NULL) {
6455 pr_err("%s: Build ID not available from socinfo\n", __func__);
6456 return;
6457 }
6458
6459 if (build_id[8] == 'C' &&
6460 !msm_gpios_request_enable(msm_nand_ebi2_cfg_data,
6461 ARRAY_SIZE(msm_nand_ebi2_cfg_data))) {
6462 plat_data = msm_device_nand.dev.platform_data;
6463 plat_data->interleave = 1;
6464 printk(KERN_INFO "%s: Interleave mode Build ID found\n",
6465 __func__);
6466 }
6467}
6468
6469#ifdef CONFIG_SERIAL_MSM_CONSOLE
6470static struct msm_gpio uart2_config_data[] = {
6471 { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
6472 { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
6473 { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
6474 { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
6475};
6476
6477static void msm7x30_init_uart2(void)
6478{
6479 msm_gpios_request_enable(uart2_config_data,
6480 ARRAY_SIZE(uart2_config_data));
6481
6482}
6483#endif
6484
6485/* TSIF begin */
6486#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6487
6488#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6489#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6490#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6491#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6492
6493static const struct msm_gpio tsif_gpios[] = {
6494 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
6495 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
6496 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
6497 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
6498};
6499
6500static struct msm_tsif_platform_data tsif_platform_data = {
6501 .num_gpios = ARRAY_SIZE(tsif_gpios),
6502 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -07006503 .tsif_pclk = "iface_clk",
6504 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006505};
6506#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
6507/* TSIF end */
6508
6509static void __init pmic8058_leds_init(void)
6510{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306511 if (machine_is_msm7x30_surf())
6512 pm8058_7x30_data.leds_pdata = &pm8058_surf_leds_data;
6513 else if (!machine_is_msm7x30_fluid())
6514 pm8058_7x30_data.leds_pdata = &pm8058_ffa_leds_data;
6515 else if (machine_is_msm7x30_fluid())
6516 pm8058_7x30_data.leds_pdata = &pm8058_fluid_leds_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006517}
6518
6519static struct msm_spm_platform_data msm_spm_data __initdata = {
Taniya Das298de8c2012-02-16 11:45:31 +05306520 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006521
6522 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
6523 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
6524 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
6525 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
6526
6527 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
6528 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
6529 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
6530
6531 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
6532 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
6533 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
6534
6535 .awake_vlevel = 0xF2,
6536 .retention_vlevel = 0xE0,
6537 .collapse_vlevel = 0x72,
6538 .retention_mid_vlevel = 0xE0,
6539 .collapse_mid_vlevel = 0xE0,
6540
6541 .vctl_timeout_us = 50,
6542};
6543
6544#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6545 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6546
6547#define TSC2007_TS_PEN_INT 20
6548
6549static struct msm_gpio tsc2007_config_data[] = {
6550 { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
6551 "tsc2007_irq" },
6552};
6553
Justin Paupore3f40f342011-08-10 18:52:16 -07006554static struct regulator_bulk_data tsc2007_regs[] = {
6555 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
6556 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
6557};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006558
6559static int tsc2007_init(void)
6560{
6561 int rc;
6562
Justin Paupore3f40f342011-08-10 18:52:16 -07006563 rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006564
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006565 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006566 pr_err("%s: could not get regulators: %d\n", __func__, rc);
6567 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006568 }
6569
Justin Paupore3f40f342011-08-10 18:52:16 -07006570 rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6571
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006572 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006573 pr_err("%s: could not set voltages: %d\n", __func__, rc);
6574 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006575 }
6576
Justin Paupore3f40f342011-08-10 18:52:16 -07006577 rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006578
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006579 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006580 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
6581 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006582 }
6583
6584 rc = msm_gpios_request_enable(tsc2007_config_data,
6585 ARRAY_SIZE(tsc2007_config_data));
6586 if (rc) {
6587 pr_err("%s: Unable to request gpios\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006588 goto reg_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006589 }
6590
6591 return 0;
6592
Justin Paupore3f40f342011-08-10 18:52:16 -07006593reg_disable:
6594 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6595reg_free:
6596 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6597out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006598 return rc;
6599}
6600
6601static int tsc2007_get_pendown_state(void)
6602{
6603 int rc;
6604
6605 rc = gpio_get_value(TSC2007_TS_PEN_INT);
6606 if (rc < 0) {
6607 pr_err("%s: MSM GPIO %d read failed\n", __func__,
6608 TSC2007_TS_PEN_INT);
6609 return rc;
6610 }
6611
6612 return (rc == 0 ? 1 : 0);
6613}
6614
6615static void tsc2007_exit(void)
6616{
Justin Paupore3f40f342011-08-10 18:52:16 -07006617
6618 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6619 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006620
6621 msm_gpios_disable_free(tsc2007_config_data,
6622 ARRAY_SIZE(tsc2007_config_data));
6623}
6624
6625static int tsc2007_power_shutdown(bool enable)
6626{
6627 int rc;
6628
Justin Paupore3f40f342011-08-10 18:52:16 -07006629 rc = (enable == false) ?
6630 regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) :
6631 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6632
6633 if (rc) {
6634 pr_err("%s: could not %sable regulators: %d\n",
6635 __func__, enable ? "dis" : "en", rc);
6636 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006637 }
6638
Justin Paupore3f40f342011-08-10 18:52:16 -07006639 if (enable == false)
6640 msleep(20);
6641
6642 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006643}
6644
6645static struct tsc2007_platform_data tsc2007_ts_data = {
6646 .model = 2007,
6647 .x_plate_ohms = 300,
Anirudh Ghayala2cf2e22012-01-25 12:29:42 +05306648 .min_x = 210,
6649 .max_x = 3832,
6650 .min_y = 150,
6651 .max_y = 3936,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006652 .irq_flags = IRQF_TRIGGER_LOW,
6653 .init_platform_hw = tsc2007_init,
6654 .exit_platform_hw = tsc2007_exit,
6655 .power_shutdown = tsc2007_power_shutdown,
6656 .invert_x = true,
6657 .invert_y = true,
6658 /* REVISIT: Temporary fix for reversed pressure */
6659 .invert_z1 = true,
6660 .invert_z2 = true,
6661 .get_pendown_state = tsc2007_get_pendown_state,
6662};
6663
6664static struct i2c_board_info tsc_i2c_board_info[] = {
6665 {
6666 I2C_BOARD_INFO("tsc2007", 0x48),
6667 .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
6668 .platform_data = &tsc2007_ts_data,
6669 },
6670};
6671#endif
6672
Justin Paupore3f40f342011-08-10 18:52:16 -07006673static struct regulator_bulk_data regs_isa1200[] = {
6674 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
6675 { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006676};
6677
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006678static int isa1200_power(int vreg_on)
6679{
Justin Paupore3f40f342011-08-10 18:52:16 -07006680 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006681
Justin Paupore3f40f342011-08-10 18:52:16 -07006682 rc = vreg_on ?
6683 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) :
6684 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006685
Justin Paupore3f40f342011-08-10 18:52:16 -07006686 if (rc) {
6687 pr_err("%s: could not %sable regulators: %d\n",
6688 __func__, vreg_on ? "en" : "dis", rc);
6689 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006690 }
6691
6692 /* vote for DO buffer */
6693 rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO,
6694 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
6695 if (rc) {
6696 pr_err("%s: unable to %svote for d0 clk\n",
6697 __func__, vreg_on ? "" : "de-");
6698 goto vreg_fail;
6699 }
6700
6701 return 0;
6702
6703vreg_fail:
Justin Paupore3f40f342011-08-10 18:52:16 -07006704 if (vreg_on)
6705 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6706 else
6707 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6708out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006709 return rc;
6710}
6711
6712static int isa1200_dev_setup(bool enable)
6713{
Justin Paupore3f40f342011-08-10 18:52:16 -07006714 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006715
6716 if (enable == true) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006717 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200),
6718 regs_isa1200);
6719
6720 if (rc) {
6721 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006722 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006723 goto out;
6724 }
6725
6726 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200),
6727 regs_isa1200);
6728 if (rc) {
6729 pr_err("%s: could not set voltages: %d\n",
6730 __func__, rc);
6731 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006732 }
6733
6734 rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
6735 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
6736 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
6737 if (rc) {
6738 pr_err("%s: Could not configure gpio %d\n",
6739 __func__, HAP_LVL_SHFT_MSM_GPIO);
Justin Paupore3f40f342011-08-10 18:52:16 -07006740 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006741 }
6742
6743 rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
6744 if (rc) {
6745 pr_err("%s: unable to request gpio %d (%d)\n",
6746 __func__, HAP_LVL_SHFT_MSM_GPIO, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006747 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006748 }
6749
6750 gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
6751 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006752 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006753 gpio_free(HAP_LVL_SHFT_MSM_GPIO);
6754 }
6755
6756 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07006757
6758reg_free:
6759 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6760out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006761 return rc;
6762}
6763static struct isa1200_platform_data isa1200_1_pdata = {
6764 .name = "vibrator",
6765 .power_on = isa1200_power,
6766 .dev_setup = isa1200_dev_setup,
6767 .pwm_ch_id = 1, /*channel id*/
6768 /*gpio to enable haptic*/
6769 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka03122322011-09-09 15:15:43 +05306770 .hap_len_gpio = -1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006771 .max_timeout = 15000,
6772 .mode_ctrl = PWM_GEN_MODE,
6773 .pwm_fd = {
6774 .pwm_div = 256,
6775 },
6776 .is_erm = false,
6777 .smart_en = true,
6778 .ext_clk_en = true,
6779 .chip_en = 1,
6780};
6781
6782static struct i2c_board_info msm_isa1200_board_info[] = {
6783 {
6784 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
6785 .platform_data = &isa1200_1_pdata,
6786 },
6787};
6788
6789
6790static int kp_flip_mpp_config(void)
6791{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306792 struct pm8xxx_mpp_config_data kp_flip_mpp = {
6793 .type = PM8XXX_MPP_TYPE_D_INPUT,
6794 .level = PM8018_MPP_DIG_LEVEL_S3,
6795 .control = PM8XXX_MPP_DIN_TO_INT,
6796 };
6797
6798 return pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(PM_FLIP_MPP),
6799 &kp_flip_mpp);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006800}
6801
6802static struct flip_switch_pdata flip_switch_data = {
6803 .name = "kp_flip_switch",
6804 .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP,
6805 .left_key = KEY_OPEN,
6806 .right_key = KEY_CLOSE,
6807 .active_low = 0,
6808 .wakeup = 1,
6809 .flip_mpp_config = kp_flip_mpp_config,
6810};
6811
6812static struct platform_device flip_switch_device = {
6813 .name = "kp_flip_switch",
6814 .id = -1,
6815 .dev = {
6816 .platform_data = &flip_switch_data,
6817 }
6818};
6819
Justin Paupore3f40f342011-08-10 18:52:16 -07006820static struct regulator_bulk_data regs_tma300[] = {
6821 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
6822 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006823};
6824
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006825static int tma300_power(int vreg_on)
6826{
Justin Paupore3f40f342011-08-10 18:52:16 -07006827 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006828
Justin Paupore3f40f342011-08-10 18:52:16 -07006829 rc = vreg_on ?
6830 regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) :
6831 regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006832
Justin Paupore3f40f342011-08-10 18:52:16 -07006833 if (rc)
6834 pr_err("%s: could not %sable regulators: %d\n",
6835 __func__, vreg_on ? "en" : "dis", rc);
6836 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006837}
6838
6839#define TS_GPIO_IRQ 150
6840
6841static int tma300_dev_setup(bool enable)
6842{
Justin Paupore3f40f342011-08-10 18:52:16 -07006843 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006844
6845 if (enable) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006846 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300),
6847 regs_tma300);
6848
6849 if (rc) {
6850 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006851 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006852 goto out;
6853 }
6854
6855 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300),
6856 regs_tma300);
6857
6858 if (rc) {
6859 pr_err("%s: could not set voltages: %d\n",
6860 __func__, rc);
6861 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006862 }
6863
6864 /* enable interrupt gpio */
6865 rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
6866 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
6867 if (rc) {
6868 pr_err("%s: Could not configure gpio %d\n",
6869 __func__, TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -07006870 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006871 }
6872
6873 /* virtual keys */
6874 tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
6875 properties_kobj = kobject_create_and_add("board_properties",
6876 NULL);
6877 if (!properties_kobj) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006878 pr_err("%s: failed to create a kobject "
6879 "for board_properties\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006880 rc = -ENOMEM;
Justin Paupore3f40f342011-08-10 18:52:16 -07006881 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006882 }
6883 rc = sysfs_create_group(properties_kobj,
6884 &tma300_properties_attr_group);
6885 if (rc) {
6886 pr_err("%s: failed to create a sysfs entry %s\n",
6887 __func__, tma300_vkeys_attr.attr.name);
Justin Paupore3f40f342011-08-10 18:52:16 -07006888 goto kobj_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006889 }
6890 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006891 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006892 /* destroy virtual keys */
6893 if (properties_kobj) {
6894 sysfs_remove_group(properties_kobj,
6895 &tma300_properties_attr_group);
6896 kobject_put(properties_kobj);
6897 }
6898 }
6899 return 0;
6900
Justin Paupore3f40f342011-08-10 18:52:16 -07006901kobj_free:
6902 kobject_put(properties_kobj);
6903 properties_kobj = NULL;
6904reg_free:
6905 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
6906out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006907 return rc;
6908}
6909
6910static struct cy8c_ts_platform_data cy8ctma300_pdata = {
6911 .power_on = tma300_power,
6912 .dev_setup = tma300_dev_setup,
6913 .ts_name = "msm_tma300_ts",
6914 .dis_min_x = 0,
6915 .dis_max_x = 479,
6916 .dis_min_y = 0,
6917 .dis_max_y = 799,
6918 .res_x = 479,
6919 .res_y = 1009,
6920 .min_tid = 1,
6921 .max_tid = 255,
6922 .min_touch = 0,
6923 .max_touch = 255,
6924 .min_width = 0,
6925 .max_width = 255,
6926 .invert_y = 1,
6927 .nfingers = 4,
6928 .irq_gpio = TS_GPIO_IRQ,
6929 .resout_gpio = -1,
6930};
6931
6932static struct i2c_board_info cy8ctma300_board_info[] = {
6933 {
6934 I2C_BOARD_INFO("cy8ctma300", 0x2),
6935 .platform_data = &cy8ctma300_pdata,
6936 }
6937};
6938
Daniel Walker8d747cd2010-02-25 11:37:43 -08006939static void __init msm7x30_init(void)
6940{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006941 int rc;
6942 unsigned smem_size;
6943 uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56,
6944 0,
6945 GPIO_CFG_OUTPUT,
6946 GPIO_CFG_NO_PULL,
6947 GPIO_CFG_2MA);
6948 uint32_t soc_version = 0;
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05306949
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006950 soc_version = socinfo_get_version();
6951
Stephen Boydbb600ae2011-08-02 20:11:40 -07006952 msm_clock_init(&msm7x30_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006953#ifdef CONFIG_SERIAL_MSM_CONSOLE
6954 msm7x30_init_uart2();
6955#endif
6956 msm_spm_init(&msm_spm_data, 1);
Matt Wagantallbf430eb2012-03-22 11:45:49 -07006957 platform_device_register(&msm7x30_device_acpuclk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006958 if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid())
6959 msm7x30_cfg_smsc911x();
6960
6961#ifdef CONFIG_USB_MSM_OTG_72K
6962 if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 &&
6963 SOCINFO_VERSION_MINOR(soc_version) >= 1) {
6964 pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
6965 msm_otg_pdata.ldo_set_voltage = 0;
6966 }
6967
6968 msm_device_otg.dev.platform_data = &msm_otg_pdata;
6969#ifdef CONFIG_USB_GADGET
6970 msm_otg_pdata.swfi_latency =
6971 msm_pm_data
6972 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
6973 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
6974#endif
6975#endif
6976 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
6977 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
6978#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6979 msm_device_tsif.dev.platform_data = &tsif_platform_data;
6980#endif
6981 if (machine_is_msm7x30_fluid()) {
6982 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
6983 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
6984 } else {
6985 msm_adc_pdata.dev_names = msm_adc_surf_device_names;
6986 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names);
6987 }
6988
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306989 pmic8058_leds_init();
6990
6991 buses_init();
6992
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306993#ifdef CONFIG_MSM_SSBI
6994 msm_device_ssbi_pmic1.dev.platform_data =
6995 &msm7x30_ssbi_pm8058_pdata;
6996#endif
6997
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006998 platform_add_devices(msm_footswitch_devices,
6999 msm_num_footswitch_devices);
Daniel Walker8d747cd2010-02-25 11:37:43 -08007000 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007001#ifdef CONFIG_USB_EHCI_MSM_72K
7002 msm_add_host(0, &msm_usb_host_pdata);
7003#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07007004#ifdef CONFIG_MSM_CAMERA_V4L2
7005 msm7x30_init_cam();
7006#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007007 msm7x30_init_mmc();
7008 msm7x30_init_nand();
7009 msm_qsd_spi_init();
7010
7011#ifdef CONFIG_SPI_QSD
7012 if (machine_is_msm7x30_fluid())
7013 spi_register_board_info(lcdc_sharp_spi_board_info,
7014 ARRAY_SIZE(lcdc_sharp_spi_board_info));
7015 else
7016 spi_register_board_info(lcdc_toshiba_spi_board_info,
7017 ARRAY_SIZE(lcdc_toshiba_spi_board_info));
7018#endif
7019
Justin Paupore3f40f342011-08-10 18:52:16 -07007020 atv_dac_power_init();
7021 sensors_ldo_init();
7022 hdmi_init_regs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007023 msm_fb_add_devices();
7024 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06007025 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05307026 msm_pm_register_irqs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007027 msm_device_i2c_init();
7028 msm_device_i2c_2_init();
7029 qup_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007030 msm7x30_init_marimba();
7031#ifdef CONFIG_MSM7KV2_AUDIO
7032 snddev_poweramp_gpio_init();
Justin Paupore3f40f342011-08-10 18:52:16 -07007033 snddev_hsed_voltage_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007034 aux_pcm_gpio_init();
7035#endif
7036
7037 i2c_register_board_info(0, msm_i2c_board_info,
7038 ARRAY_SIZE(msm_i2c_board_info));
7039
7040 if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid())
7041 marimba_pdata.tsadc = &marimba_tsadc_pdata;
7042
7043 if (machine_is_msm7x30_fluid())
7044 i2c_register_board_info(0, cy8info,
7045 ARRAY_SIZE(cy8info));
7046#ifdef CONFIG_BOSCH_BMA150
7047 if (machine_is_msm7x30_fluid())
7048 i2c_register_board_info(0, bma150_board_info,
7049 ARRAY_SIZE(bma150_board_info));
7050#endif
7051
7052 i2c_register_board_info(2, msm_marimba_board_info,
7053 ARRAY_SIZE(msm_marimba_board_info));
7054
7055 i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info,
7056 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info));
7057
7058 i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
7059 ARRAY_SIZE(msm_camera_boardinfo));
7060
7061 bt_power_init();
7062#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007063 msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
7064#endif
7065 if (machine_is_msm7x30_fluid())
7066 i2c_register_board_info(0, msm_isa1200_board_info,
7067 ARRAY_SIZE(msm_isa1200_board_info));
7068
7069#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
7070 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
7071 if (machine_is_msm8x55_svlte_ffa())
7072 i2c_register_board_info(2, tsc_i2c_board_info,
7073 ARRAY_SIZE(tsc_i2c_board_info));
7074#endif
7075
7076 if (machine_is_msm7x30_surf())
7077 platform_device_register(&flip_switch_device);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307078
7079 pm8058_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007080
7081 if (machine_is_msm7x30_fluid()) {
7082 /* Initialize platform data for fluid v2 hardware */
7083 if (SOCINFO_VERSION_MAJOR(
7084 socinfo_get_platform_version()) == 2) {
7085 cy8ctma300_pdata.res_y = 920;
7086 cy8ctma300_pdata.invert_y = 0;
7087 }
7088 i2c_register_board_info(0, cy8ctma300_board_info,
7089 ARRAY_SIZE(cy8ctma300_board_info));
7090 }
7091
7092 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
7093 rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE);
7094 if (rc)
7095 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
7096 __func__, usb_hub_gpio_cfg_value, rc);
7097 }
7098
7099 boot_reason = *(unsigned int *)
7100 (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
7101 printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
7102}
7103
7104static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
7105static int __init pmem_sf_size_setup(char *p)
7106{
7107 pmem_sf_size = memparse(p, NULL);
7108 return 0;
7109}
7110early_param("pmem_sf_size", pmem_sf_size_setup);
7111
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307112static unsigned fb_size;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007113static int __init fb_size_setup(char *p)
7114{
7115 fb_size = memparse(p, NULL);
7116 return 0;
7117}
7118early_param("fb_size", fb_size_setup);
7119
7120static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
7121static int __init pmem_adsp_size_setup(char *p)
7122{
7123 pmem_adsp_size = memparse(p, NULL);
7124 return 0;
7125}
7126early_param("pmem_adsp_size", pmem_adsp_size_setup);
7127
7128static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE;
7129static int __init fluid_pmem_adsp_size_setup(char *p)
7130{
7131 fluid_pmem_adsp_size = memparse(p, NULL);
7132 return 0;
7133}
7134early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup);
7135
7136static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
7137static int __init pmem_audio_size_setup(char *p)
7138{
7139 pmem_audio_size = memparse(p, NULL);
7140 return 0;
7141}
7142early_param("pmem_audio_size", pmem_audio_size_setup);
7143
7144static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE;
7145static int __init pmem_kernel_ebi0_size_setup(char *p)
7146{
7147 pmem_kernel_ebi0_size = memparse(p, NULL);
7148 return 0;
7149}
7150early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
7151
Chintan Pandya03b698a2012-06-28 19:03:09 +05307152#ifdef CONFIG_ION_MSM
7153#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
7154static struct ion_co_heap_pdata co_ion_pdata = {
7155 .adjacent_mem_id = INVALID_HEAP_ID,
7156 .align = PAGE_SIZE,
7157};
7158#endif
7159
7160/**
7161 * These heaps are listed in the order they will be allocated.
7162 * Don't swap the order unless you know what you are doing!
7163 */
7164static struct ion_platform_data ion_pdata = {
7165 .nr = MSM_ION_HEAP_NUM,
7166 .heaps = {
7167 {
7168 .id = ION_SYSTEM_HEAP_ID,
7169 .type = ION_HEAP_TYPE_SYSTEM,
7170 .name = ION_VMALLOC_HEAP_NAME,
7171 },
7172#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
7173 /* PMEM_ADSP = CAMERA */
7174 {
7175 .id = ION_CAMERA_HEAP_ID,
7176 .type = ION_HEAP_TYPE_CARVEOUT,
7177 .name = ION_CAMERA_HEAP_NAME,
7178 .memory_type = ION_EBI_TYPE,
Chintan Pandya03b698a2012-06-28 19:03:09 +05307179 .extra_data = (void *)&co_ion_pdata,
7180 },
7181 /* PMEM_AUDIO */
7182 {
7183 .id = ION_AUDIO_HEAP_ID,
7184 .type = ION_HEAP_TYPE_CARVEOUT,
7185 .name = ION_AUDIO_HEAP_NAME,
7186 .memory_type = ION_EBI_TYPE,
Chintan Pandya03b698a2012-06-28 19:03:09 +05307187 .extra_data = (void *)&co_ion_pdata,
7188 },
7189 /* PMEM_MDP = SF */
7190 {
7191 .id = ION_SF_HEAP_ID,
7192 .type = ION_HEAP_TYPE_CARVEOUT,
7193 .name = ION_SF_HEAP_NAME,
7194 .memory_type = ION_EBI_TYPE,
Chintan Pandya03b698a2012-06-28 19:03:09 +05307195 .extra_data = (void *)&co_ion_pdata,
7196 },
7197#endif
7198 }
7199};
7200
7201static struct platform_device ion_dev = {
7202 .name = "ion-msm",
7203 .id = 1,
7204 .dev = { .platform_data = &ion_pdata },
7205};
7206#endif
7207
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007208static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
7209 [MEMTYPE_SMI] = {
7210 },
7211 [MEMTYPE_EBI0] = {
7212 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7213 },
7214 [MEMTYPE_EBI1] = {
7215 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7216 },
7217};
7218
Chintan Pandya03b698a2012-06-28 19:03:09 +05307219unsigned long size;
7220unsigned long msm_ion_camera_size;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007221
Chintan Pandya03b698a2012-06-28 19:03:09 +05307222static void fix_sizes(void)
7223{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007224 if machine_is_msm7x30_fluid()
7225 size = fluid_pmem_adsp_size;
7226 else
7227 size = pmem_adsp_size;
Chintan Pandya03b698a2012-06-28 19:03:09 +05307228
7229#ifdef CONFIG_ION_MSM
7230 msm_ion_camera_size = size;
7231#endif
7232}
7233
7234static void __init size_pmem_devices(void)
7235{
7236#ifdef CONFIG_ANDROID_PMEM
7237#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
7238
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007239 android_pmem_adsp_pdata.size = size;
7240 android_pmem_audio_pdata.size = pmem_audio_size;
7241 android_pmem_pdata.size = pmem_sf_size;
7242#endif
Chintan Pandya03b698a2012-06-28 19:03:09 +05307243#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007244}
7245
Chintan Pandya03b698a2012-06-28 19:03:09 +05307246#ifdef CONFIG_ANDROID_PMEM
7247#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007248static void __init reserve_memory_for(struct android_pmem_platform_data *p)
7249{
7250 msm7x30_reserve_table[p->memory_type].size += p->size;
7251}
Chintan Pandya03b698a2012-06-28 19:03:09 +05307252#endif
7253#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007254
7255static void __init reserve_pmem_memory(void)
7256{
7257#ifdef CONFIG_ANDROID_PMEM
Chintan Pandya03b698a2012-06-28 19:03:09 +05307258#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007259 reserve_memory_for(&android_pmem_adsp_pdata);
7260 reserve_memory_for(&android_pmem_audio_pdata);
7261 reserve_memory_for(&android_pmem_pdata);
7262 msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
7263#endif
Chintan Pandya03b698a2012-06-28 19:03:09 +05307264#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007265}
7266
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307267static void __init reserve_mdp_memory(void)
7268{
7269 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
7270 msm7x30_reserve_table[mdp_pdata.mem_hid].size += mdp_pdata.ov0_wb_size;
7271}
7272
Chintan Pandya03b698a2012-06-28 19:03:09 +05307273static void __init size_ion_devices(void)
7274{
7275#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
7276 ion_pdata.heaps[1].size = msm_ion_camera_size;
7277 ion_pdata.heaps[2].size = MSM_ION_AUDIO_SIZE;
7278 ion_pdata.heaps[3].size = MSM_ION_SF_SIZE;
7279#endif
7280}
7281
7282static void __init reserve_ion_memory(void)
7283{
7284#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
7285 msm7x30_reserve_table[MEMTYPE_EBI0].size += msm_ion_camera_size;
7286 msm7x30_reserve_table[MEMTYPE_EBI0].size += MSM_ION_AUDIO_SIZE;
7287 msm7x30_reserve_table[MEMTYPE_EBI0].size += MSM_ION_SF_SIZE;
7288#endif
7289}
7290
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007291static void __init msm7x30_calculate_reserve_sizes(void)
7292{
Chintan Pandya03b698a2012-06-28 19:03:09 +05307293 fix_sizes();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007294 size_pmem_devices();
7295 reserve_pmem_memory();
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307296 reserve_mdp_memory();
Chintan Pandya03b698a2012-06-28 19:03:09 +05307297 size_ion_devices();
7298 reserve_ion_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007299}
7300
7301static int msm7x30_paddr_to_memtype(unsigned int paddr)
7302{
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307303 if (paddr < phys_add)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007304 return MEMTYPE_EBI0;
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307305 if (paddr >= phys_add && paddr < 0x80000000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007306 return MEMTYPE_EBI1;
7307 return MEMTYPE_NONE;
7308}
7309
7310static struct reserve_info msm7x30_reserve_info __initdata = {
7311 .memtype_reserve_table = msm7x30_reserve_table,
7312 .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes,
7313 .paddr_to_memtype = msm7x30_paddr_to_memtype,
7314};
7315
7316static void __init msm7x30_reserve(void)
7317{
7318 reserve_info = &msm7x30_reserve_info;
7319 msm_reserve();
7320}
7321
7322static void __init msm7x30_allocate_memory_regions(void)
7323{
7324 void *addr;
7325 unsigned long size;
7326
7327 size = fb_size ? : MSM_FB_SIZE;
7328 addr = alloc_bootmem_align(size, 0x1000);
7329 msm_fb_resources[0].start = __pa(addr);
7330 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
7331 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
7332 size, addr, __pa(addr));
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08007333
7334#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
7335 size = MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE;
7336 addr = alloc_bootmem_align(size, 0x1000);
7337 msm_v4l2_video_overlay_resources[0].start = __pa(addr);
7338 msm_v4l2_video_overlay_resources[0].end =
7339 msm_v4l2_video_overlay_resources[0].start + size - 1;
7340 pr_debug("allocating %lu bytes at %p (%lx physical) for v4l2\n",
7341 size, addr, __pa(addr));
7342#endif
Daniel Walker8d747cd2010-02-25 11:37:43 -08007343}
7344
7345static void __init msm7x30_map_io(void)
7346{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007347 msm_shared_ram_phys = 0x00100000;
Daniel Walker8d747cd2010-02-25 11:37:43 -08007348 msm_map_msm7x30_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007349 if (socinfo_init() < 0)
7350 printk(KERN_ERR "%s: socinfo_init() failed!\n",
7351 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007352}
7353
7354static void __init msm7x30_init_early(void)
7355{
7356 msm7x30_allocate_memory_regions();
Daniel Walker8d747cd2010-02-25 11:37:43 -08007357}
7358
Steve Mucklef132c6c2012-06-06 18:30:57 -07007359static void __init msm7x30_fixup(struct tag *tags, char **cmdline,
7360 struct meminfo *mi)
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307361{
7362 for (; tags->hdr.size; tags = tag_next(tags)) {
7363 if (tags->hdr.tag == ATAG_MEM && tags->u.mem.start ==
7364 DDR1_BANK_BASE) {
7365 ebi1_phys_offset = DDR1_BANK_BASE;
7366 phys_add = DDR1_BANK_BASE;
7367 break;
7368 }
7369 }
Daniel Walker8d747cd2010-02-25 11:37:43 -08007370}
7371
7372MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
Nicolas Pitref631dd42011-07-05 22:38:14 -04007373 .atag_offset = 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007374 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007375 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007376 .init_irq = msm7x30_init_irq,
7377 .init_machine = msm7x30_init,
7378 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007379 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307380 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307381 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007382MACHINE_END
7383
7384MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
Nicolas Pitref631dd42011-07-05 22:38:14 -04007385 .atag_offset = 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007386 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007387 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007388 .init_irq = msm7x30_init_irq,
7389 .init_machine = msm7x30_init,
7390 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007391 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307392 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307393 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007394MACHINE_END
7395
7396MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
Nicolas Pitref631dd42011-07-05 22:38:14 -04007397 .atag_offset = 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007398 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007399 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007400 .init_irq = msm7x30_init_irq,
7401 .init_machine = msm7x30_init,
7402 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007403 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307404 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307405 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007406MACHINE_END
7407
7408MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007409 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007410 .map_io = msm7x30_map_io,
7411 .reserve = msm7x30_reserve,
7412 .init_irq = msm7x30_init_irq,
7413 .init_machine = msm7x30_init,
7414 .timer = &msm_timer,
7415 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307416 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307417 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007418MACHINE_END
7419
7420MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007421 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007422 .map_io = msm7x30_map_io,
7423 .reserve = msm7x30_reserve,
7424 .init_irq = msm7x30_init_irq,
7425 .init_machine = msm7x30_init,
7426 .timer = &msm_timer,
7427 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307428 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307429 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007430MACHINE_END
7431MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007432 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007433 .map_io = msm7x30_map_io,
7434 .reserve = msm7x30_reserve,
7435 .init_irq = msm7x30_init_irq,
7436 .init_machine = msm7x30_init,
7437 .timer = &msm_timer,
7438 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307439 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307440 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007441MACHINE_END
7442MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007443 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007444 .map_io = msm7x30_map_io,
7445 .reserve = msm7x30_reserve,
7446 .init_irq = msm7x30_init_irq,
7447 .init_machine = msm7x30_init,
7448 .timer = &msm_timer,
7449 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307450 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307451 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007452MACHINE_END