blob: b8d8fe55f74af4992d5e220e537d0e2b572591d7 [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 Wagantalld55b90f2012-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 {
888 .csid_core = 0,
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700889 .is_vpe = 1,
890 .ioclk = {
891 .vfe_clk_rate = 153600000,
892 },
893 },
Sreesudhan Ramakrish Ramkumar66deac32012-04-05 10:15:38 -0700894 {
895 .csid_core = 0,
896 .is_vpe = 1,
897 .ioclk = {
898 .vfe_clk_rate = 153600000,
899 },
900 },
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700901};
902
903static struct camera_vreg_t msm_7x30_back_cam_vreg[] = {
904 {"gp2", REG_LDO, 2600000, 2600000, -1},
905 {"lvsw1", REG_VS, 0, 0, 0},
906};
907
908static uint32_t camera_off_gpio_table[] = {
909 /* parallel CAMERA interfaces */
910 /* RST */
911 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
912 /* DAT2 */
913 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
914 /* DAT3 */
915 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
916 /* DAT4 */
917 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
918 /* DAT5 */
919 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
920 /* DAT6 */
921 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
922 /* DAT7 */
923 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
924 /* DAT8 */
925 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
926 /* DAT9 */
927 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
928 /* DAT10 */
929 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
930 /* DAT11 */
931 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
932 /* PCLK */
933 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
934 /* HSYNC_IN */
935 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
936 /* VSYNC_IN */
937 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
938 /* MCLK */
939 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
940};
941
942static uint32_t camera_on_gpio_table[] = {
943 /* parallel CAMERA interfaces */
944 /* RST */
945 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
946 /* DAT2 */
947 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
948 /* DAT3 */
949 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
950 /* DAT4 */
951 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
952 /* DAT5 */
953 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
954 /* DAT6 */
955 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
956 /* DAT7 */
957 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
958 /* DAT8 */
959 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
960 /* DAT9 */
961 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
962 /* DAT10 */
963 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
964 /* DAT11 */
965 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
966 /* PCLK */
967 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
968 /* HSYNC_IN */
969 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
970 /* VSYNC_IN */
971 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
972 /* MCLK */
973 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
974};
975
976static struct gpio msm7x30_back_cam_gpio[] = {
977 {0, GPIOF_DIR_OUT, "CAM_RESET"},
978};
979
980static struct msm_gpio_set_tbl msm7x30_back_cam_gpio_set_tbl[] = {
981 {0, GPIOF_OUT_INIT_LOW, 1000},
982 {0, GPIOF_OUT_INIT_HIGH, 4000},
983};
984
985static struct msm_camera_gpio_conf msm_7x30_back_cam_gpio_conf = {
986 .cam_gpio_req_tbl = msm7x30_back_cam_gpio,
987 .cam_gpio_req_tbl_size = ARRAY_SIZE(msm7x30_back_cam_gpio),
988 .cam_gpio_set_tbl = msm7x30_back_cam_gpio_set_tbl,
989 .cam_gpio_set_tbl_size = ARRAY_SIZE(msm7x30_back_cam_gpio_set_tbl),
990 .camera_off_table = camera_off_gpio_table,
991 .camera_off_table_size = ARRAY_SIZE(camera_off_gpio_table),
992 .camera_on_table = camera_on_gpio_table,
993 .camera_on_table_size = ARRAY_SIZE(camera_on_gpio_table),
994 .gpio_no_mux = 1,
995};
996
997static struct msm_camera_sensor_flash_data flash_vx6953 = {
998 .flash_type = MSM_CAMERA_FLASH_NONE,
999};
1000
1001static struct msm_camera_sensor_platform_info sensor_board_info_vx6953 = {
1002 .mount_angle = 0,
1003 .cam_vreg = msm_7x30_back_cam_vreg,
1004 .num_vreg = ARRAY_SIZE(msm_7x30_back_cam_vreg),
1005 .gpio_conf = &msm_7x30_back_cam_gpio_conf,
1006};
1007
1008static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1009 .sensor_name = "vx6953",
1010 .pdata = &msm_camera_csi_device_data[0],
1011 .flash_data = &flash_vx6953,
1012 .sensor_platform_info = &sensor_board_info_vx6953,
1013 .csi_if = 1,
1014 .camera_type = BACK_CAMERA_2D,
1015};
1016
Kevin Chan94b4c832012-03-02 21:27:16 -08001017static struct platform_device msm_camera_server = {
1018 .name = "msm_cam_server",
1019 .id = 0,
1020};
1021
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001022void __init msm7x30_init_cam(void)
1023{
Kevin Chan94b4c832012-03-02 21:27:16 -08001024 platform_device_register(&msm_camera_server);
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001025 platform_device_register(&msm_device_csic0);
1026 platform_device_register(&msm_device_vfe);
1027 platform_device_register(&msm_device_vpe);
1028}
1029
1030#ifdef CONFIG_I2C
1031static struct i2c_board_info msm_camera_boardinfo[] = {
1032 {
1033 I2C_BOARD_INFO("vx6953", 0x20),
1034 .platform_data = &msm_camera_sensor_vx6953_data,
1035 },
1036};
1037#endif
1038#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001039static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
1040#ifdef CONFIG_MT9D112
1041 {
1042 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
Dima Zavinba5499e2011-01-10 11:00:30 -08001043 },
1044#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001045#ifdef CONFIG_WEBCAM_OV9726
1046 {
1047 I2C_BOARD_INFO("ov9726", 0x10),
1048 },
1049#endif
1050#ifdef CONFIG_S5K3E2FX
1051 {
1052 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
1053 },
1054#endif
1055#ifdef CONFIG_MT9P012
1056 {
1057 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
1058 },
1059#endif
1060#ifdef CONFIG_VX6953
1061 {
1062 I2C_BOARD_INFO("vx6953", 0x20),
1063 },
1064#endif
1065#ifdef CONFIG_MT9E013
1066 {
1067 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
1068 },
1069#endif
1070#ifdef CONFIG_SN12M0PZ
1071 {
1072 I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1),
1073 },
1074#endif
1075#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
1076 {
1077 I2C_BOARD_INFO("mt9t013", 0x6C),
1078 },
1079#endif
1080
Dima Zavinba5499e2011-01-10 11:00:30 -08001081};
1082
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001083#ifdef CONFIG_MSM_CAMERA
1084#define CAM_STNDBY 143
1085static uint32_t camera_off_vcm_gpio_table[] = {
1086GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */
1087};
1088
1089static uint32_t camera_off_gpio_table[] = {
1090 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001091 /* RST */
1092 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1093 /* DAT2 */
1094 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1095 /* DAT3 */
1096 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1097 /* DAT4 */
1098 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1099 /* DAT5 */
1100 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1101 /* DAT6 */
1102 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1103 /* DAT7 */
1104 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1105 /* DAT8 */
1106 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1107 /* DAT9 */
1108 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1109 /* DAT10 */
1110 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1111 /* DAT11 */
1112 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1113 /* PCLK */
1114 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1115 /* HSYNC_IN */
1116 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1117 /* VSYNC_IN */
1118 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1119 /* MCLK */
1120 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001121};
1122
1123static uint32_t camera_on_vcm_gpio_table[] = {
1124GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */
1125};
1126
1127static uint32_t camera_on_gpio_table[] = {
1128 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001129 /* RST */
1130 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1131 /* DAT2 */
1132 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1133 /* DAT3 */
1134 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1135 /* DAT4 */
1136 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1137 /* DAT5 */
1138 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1139 /* DAT6 */
1140 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1141 /* DAT7 */
1142 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1143 /* DAT8 */
1144 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1145 /* DAT9 */
1146 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1147 /* DAT10 */
1148 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1149 /* DAT11 */
1150 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1151 /* PCLK */
1152 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1153 /* HSYNC_IN */
1154 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1155 /* VSYNC_IN */
1156 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1157 /* MCLK */
1158 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001159};
1160
1161static uint32_t camera_off_gpio_fluid_table[] = {
1162 /* FLUID: CAM_VGA_RST_N */
1163 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1164 /* FLUID: CAMIF_STANDBY */
1165 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1166};
1167
1168static uint32_t camera_on_gpio_fluid_table[] = {
1169 /* FLUID: CAM_VGA_RST_N */
1170 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1171 /* FLUID: CAMIF_STANDBY */
1172 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1173};
1174
1175static void config_gpio_table(uint32_t *table, int len)
1176{
1177 int n, rc;
1178 for (n = 0; n < len; n++) {
1179 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
1180 if (rc) {
1181 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
1182 __func__, table[n], rc);
1183 break;
1184 }
1185 }
1186}
1187static int config_camera_on_gpios(void)
1188{
1189 config_gpio_table(camera_on_gpio_table,
1190 ARRAY_SIZE(camera_on_gpio_table));
1191
1192 if (adie_get_detected_codec_type() != TIMPANI_ID)
1193 /* GPIO1 is shared also used in Timpani RF card so
1194 only configure it for non-Timpani RF card */
1195 config_gpio_table(camera_on_vcm_gpio_table,
1196 ARRAY_SIZE(camera_on_vcm_gpio_table));
1197
1198 if (machine_is_msm7x30_fluid()) {
1199 config_gpio_table(camera_on_gpio_fluid_table,
1200 ARRAY_SIZE(camera_on_gpio_fluid_table));
1201 /* FLUID: turn on 5V booster */
1202 gpio_set_value(
1203 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 1);
1204 /* FLUID: drive high to put secondary sensor to STANDBY */
1205 gpio_set_value(CAM_STNDBY, 1);
1206 }
1207 return 0;
1208}
1209
1210static void config_camera_off_gpios(void)
1211{
1212 config_gpio_table(camera_off_gpio_table,
1213 ARRAY_SIZE(camera_off_gpio_table));
1214
1215 if (adie_get_detected_codec_type() != TIMPANI_ID)
1216 /* GPIO1 is shared also used in Timpani RF card so
1217 only configure it for non-Timpani RF card */
1218 config_gpio_table(camera_off_vcm_gpio_table,
1219 ARRAY_SIZE(camera_off_vcm_gpio_table));
1220
1221 if (machine_is_msm7x30_fluid()) {
1222 config_gpio_table(camera_off_gpio_fluid_table,
1223 ARRAY_SIZE(camera_off_gpio_fluid_table));
1224 /* FLUID: turn off 5V booster */
1225 gpio_set_value(
1226 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 0);
1227 }
1228}
1229
1230struct resource msm_camera_resources[] = {
1231 {
1232 .start = 0xA6000000,
1233 .end = 0xA6000000 + SZ_1M - 1,
1234 .flags = IORESOURCE_MEM,
1235 },
1236 {
1237 .start = INT_VFE,
1238 .end = INT_VFE,
1239 .flags = IORESOURCE_IRQ,
1240 },
1241 {
1242 .flags = IORESOURCE_DMA,
1243 }
1244};
1245
1246struct msm_camera_device_platform_data msm_camera_device_data = {
1247 .camera_gpio_on = config_camera_on_gpios,
1248 .camera_gpio_off = config_camera_off_gpios,
1249 .ioext.camifpadphy = 0xAB000000,
1250 .ioext.camifpadsz = 0x00000400,
1251 .ioext.csiphy = 0xA6100000,
1252 .ioext.csisz = 0x00000400,
1253 .ioext.csiirq = INT_CSI,
1254 .ioclk.mclk_clk_rate = 24000000,
1255 .ioclk.vfe_clk_rate = 147456000,
1256};
1257
1258static struct msm_camera_sensor_flash_src msm_flash_src_pwm = {
1259 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PWM,
1260 ._fsrc.pwm_src.freq = 1000,
1261 ._fsrc.pwm_src.max_load = 300,
1262 ._fsrc.pwm_src.low_load = 30,
1263 ._fsrc.pwm_src.high_load = 100,
1264 ._fsrc.pwm_src.channel = 7,
1265};
1266
1267#ifdef CONFIG_MT9D112
1268static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1269 .flash_type = MSM_CAMERA_FLASH_LED,
1270 .flash_src = &msm_flash_src_pwm
1271};
1272
1273static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1274 .sensor_name = "mt9d112",
1275 .sensor_reset = 0,
1276 .sensor_pwd = 85,
1277 .vcm_pwd = 1,
1278 .vcm_enable = 0,
1279 .pdata = &msm_camera_device_data,
1280 .resource = msm_camera_resources,
1281 .num_resources = ARRAY_SIZE(msm_camera_resources),
1282 .flash_data = &flash_mt9d112,
1283 .csi_if = 0
1284};
1285
1286static struct platform_device msm_camera_sensor_mt9d112 = {
1287 .name = "msm_camera_mt9d112",
1288 .dev = {
1289 .platform_data = &msm_camera_sensor_mt9d112_data,
1290 },
1291};
1292#endif
1293
1294#ifdef CONFIG_WEBCAM_OV9726
1295
1296static struct msm_camera_sensor_platform_info ov9726_sensor_7630_info = {
1297 .mount_angle = 90
1298};
1299
1300static struct msm_camera_sensor_flash_data flash_ov9726 = {
1301 .flash_type = MSM_CAMERA_FLASH_LED,
1302 .flash_src = &msm_flash_src_pwm
1303};
1304static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
1305 .sensor_name = "ov9726",
1306 .sensor_reset = 0,
1307 .sensor_pwd = 85,
1308 .vcm_pwd = 1,
1309 .vcm_enable = 0,
1310 .pdata = &msm_camera_device_data,
1311 .resource = msm_camera_resources,
1312 .num_resources = ARRAY_SIZE(msm_camera_resources),
1313 .flash_data = &flash_ov9726,
1314 .sensor_platform_info = &ov9726_sensor_7630_info,
1315 .csi_if = 1
1316};
1317struct platform_device msm_camera_sensor_ov9726 = {
1318 .name = "msm_camera_ov9726",
1319 .dev = {
1320 .platform_data = &msm_camera_sensor_ov9726_data,
1321 },
1322};
1323#endif
1324
1325#ifdef CONFIG_S5K3E2FX
1326static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1327 .flash_type = MSM_CAMERA_FLASH_LED,
1328 .flash_src = &msm_flash_src_pwm,
1329};
1330
1331static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1332 .sensor_name = "s5k3e2fx",
1333 .sensor_reset = 0,
1334 .sensor_pwd = 85,
1335 .vcm_pwd = 1,
1336 .vcm_enable = 0,
1337 .pdata = &msm_camera_device_data,
1338 .resource = msm_camera_resources,
1339 .num_resources = ARRAY_SIZE(msm_camera_resources),
1340 .flash_data = &flash_s5k3e2fx,
1341 .csi_if = 0
1342};
1343
1344static struct platform_device msm_camera_sensor_s5k3e2fx = {
1345 .name = "msm_camera_s5k3e2fx",
1346 .dev = {
1347 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1348 },
1349};
1350#endif
1351
1352#ifdef CONFIG_MT9P012
1353static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1354 .flash_type = MSM_CAMERA_FLASH_LED,
1355 .flash_src = &msm_flash_src_pwm
1356};
1357
1358static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1359 .sensor_name = "mt9p012",
1360 .sensor_reset = 0,
1361 .sensor_pwd = 85,
1362 .vcm_pwd = 1,
1363 .vcm_enable = 1,
1364 .pdata = &msm_camera_device_data,
1365 .resource = msm_camera_resources,
1366 .num_resources = ARRAY_SIZE(msm_camera_resources),
1367 .flash_data = &flash_mt9p012,
1368 .csi_if = 0
1369};
1370
1371static struct platform_device msm_camera_sensor_mt9p012 = {
1372 .name = "msm_camera_mt9p012",
1373 .dev = {
1374 .platform_data = &msm_camera_sensor_mt9p012_data,
1375 },
1376};
1377#endif
1378
1379#ifdef CONFIG_MT9E013
1380static struct msm_camera_sensor_platform_info mt9e013_sensor_7630_info = {
1381 .mount_angle = 0
1382};
1383
1384static struct msm_camera_sensor_flash_data flash_mt9e013 = {
1385 .flash_type = MSM_CAMERA_FLASH_LED,
1386 .flash_src = &msm_flash_src_pwm
1387};
1388
1389static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
1390 .sensor_name = "mt9e013",
1391 .sensor_reset = 0,
1392 .sensor_pwd = 85,
1393 .vcm_pwd = 1,
1394 .vcm_enable = 1,
1395 .pdata = &msm_camera_device_data,
1396 .resource = msm_camera_resources,
1397 .num_resources = ARRAY_SIZE(msm_camera_resources),
1398 .flash_data = &flash_mt9e013,
1399 .sensor_platform_info = &mt9e013_sensor_7630_info,
1400 .csi_if = 1
1401};
1402
1403static struct platform_device msm_camera_sensor_mt9e013 = {
1404 .name = "msm_camera_mt9e013",
1405 .dev = {
1406 .platform_data = &msm_camera_sensor_mt9e013_data,
1407 },
1408};
1409#endif
1410
1411#ifdef CONFIG_VX6953
Jilai Wang971f97f2011-07-13 14:25:25 -04001412static struct msm_camera_sensor_platform_info vx6953_sensor_7630_info = {
1413 .mount_angle = 0
1414};
1415
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001416static struct msm_camera_sensor_flash_data flash_vx6953 = {
1417 .flash_type = MSM_CAMERA_FLASH_LED,
1418 .flash_src = &msm_flash_src_pwm
1419};
1420static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1421 .sensor_name = "vx6953",
1422 .sensor_reset = 0,
1423 .sensor_pwd = 85,
1424 .vcm_pwd = 1,
1425 .vcm_enable = 0,
1426 .pdata = &msm_camera_device_data,
1427 .resource = msm_camera_resources,
1428 .num_resources = ARRAY_SIZE(msm_camera_resources),
Jilai Wang971f97f2011-07-13 14:25:25 -04001429 .sensor_platform_info = &vx6953_sensor_7630_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001430 .flash_data = &flash_vx6953,
1431 .csi_if = 1
1432};
1433static struct platform_device msm_camera_sensor_vx6953 = {
1434 .name = "msm_camera_vx6953",
1435 .dev = {
1436 .platform_data = &msm_camera_sensor_vx6953_data,
1437 },
1438};
1439#endif
1440
1441#ifdef CONFIG_SN12M0PZ
1442static struct msm_camera_sensor_flash_src msm_flash_src_current_driver = {
1443 .flash_sr_type = MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER,
1444 ._fsrc.current_driver_src.low_current = 210,
1445 ._fsrc.current_driver_src.high_current = 700,
1446 ._fsrc.current_driver_src.driver_channel = &pm8058_fluid_leds_data,
1447};
1448
1449static struct msm_camera_sensor_flash_data flash_sn12m0pz = {
1450 .flash_type = MSM_CAMERA_FLASH_LED,
1451 .flash_src = &msm_flash_src_current_driver
1452};
1453static struct msm_camera_sensor_info msm_camera_sensor_sn12m0pz_data = {
1454 .sensor_name = "sn12m0pz",
1455 .sensor_reset = 0,
1456 .sensor_pwd = 85,
1457 .vcm_pwd = 1,
1458 .vcm_enable = 1,
1459 .pdata = &msm_camera_device_data,
1460 .flash_data = &flash_sn12m0pz,
1461 .resource = msm_camera_resources,
1462 .num_resources = ARRAY_SIZE(msm_camera_resources),
1463 .csi_if = 0
1464};
1465
1466static struct platform_device msm_camera_sensor_sn12m0pz = {
1467 .name = "msm_camera_sn12m0pz",
1468 .dev = {
1469 .platform_data = &msm_camera_sensor_sn12m0pz_data,
1470 },
1471};
1472#endif
1473
1474#ifdef CONFIG_MT9T013
1475static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1476 .flash_type = MSM_CAMERA_FLASH_LED,
1477 .flash_src = &msm_flash_src_pwm
1478};
1479
1480static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1481 .sensor_name = "mt9t013",
1482 .sensor_reset = 0,
1483 .sensor_pwd = 85,
1484 .vcm_pwd = 1,
1485 .vcm_enable = 0,
1486 .pdata = &msm_camera_device_data,
1487 .resource = msm_camera_resources,
1488 .num_resources = ARRAY_SIZE(msm_camera_resources),
1489 .flash_data = &flash_mt9t013,
1490 .csi_if = 1
1491};
1492
1493static struct platform_device msm_camera_sensor_mt9t013 = {
1494 .name = "msm_camera_mt9t013",
1495 .dev = {
1496 .platform_data = &msm_camera_sensor_mt9t013_data,
1497 },
1498};
1499#endif
1500
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001501#ifdef CONFIG_MSM_VPE
1502static struct resource msm_vpe_resources[] = {
1503 {
1504 .start = 0xAD200000,
1505 .end = 0xAD200000 + SZ_1M - 1,
1506 .flags = IORESOURCE_MEM,
1507 },
1508 {
1509 .start = INT_VPE,
1510 .end = INT_VPE,
1511 .flags = IORESOURCE_IRQ,
1512 },
1513};
1514
1515static struct platform_device msm_vpe_device = {
1516 .name = "msm_vpe",
1517 .id = 0,
1518 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1519 .resource = msm_vpe_resources,
1520};
1521#endif
1522
1523#endif /*CONFIG_MSM_CAMERA*/
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001524#endif
1525
1526#ifdef CONFIG_MSM_GEMINI
1527static struct resource msm_gemini_resources[] = {
1528 {
1529 .start = 0xA3A00000,
1530 .end = 0xA3A00000 + 0x0150 - 1,
1531 .flags = IORESOURCE_MEM,
1532 },
1533 {
1534 .start = INT_JPEG,
1535 .end = INT_JPEG,
1536 .flags = IORESOURCE_IRQ,
1537 },
1538};
1539
1540static struct platform_device msm_gemini_device = {
1541 .name = "msm_gemini",
1542 .resource = msm_gemini_resources,
1543 .num_resources = ARRAY_SIZE(msm_gemini_resources),
1544};
1545#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001546
1547#ifdef CONFIG_MSM7KV2_AUDIO
1548static uint32_t audio_pamp_gpio_config =
1549 GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1550
1551static uint32_t audio_fluid_icodec_tx_config =
1552 GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1553
1554static int __init snddev_poweramp_gpio_init(void)
1555{
1556 int rc;
1557
1558 pr_info("snddev_poweramp_gpio_init \n");
1559 rc = gpio_tlmm_config(audio_pamp_gpio_config, GPIO_CFG_ENABLE);
1560 if (rc) {
1561 printk(KERN_ERR
1562 "%s: gpio_tlmm_config(%#x)=%d\n",
1563 __func__, audio_pamp_gpio_config, rc);
1564 }
1565 return rc;
1566}
1567
1568void msm_snddev_tx_route_config(void)
1569{
1570 int rc;
1571
1572 pr_debug("%s()\n", __func__);
1573
1574 if (machine_is_msm7x30_fluid()) {
1575 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1576 GPIO_CFG_ENABLE);
1577 if (rc) {
1578 printk(KERN_ERR
1579 "%s: gpio_tlmm_config(%#x)=%d\n",
1580 __func__, audio_fluid_icodec_tx_config, rc);
1581 } else
1582 gpio_set_value(85, 0);
1583 }
1584}
1585
1586void msm_snddev_tx_route_deconfig(void)
1587{
1588 int rc;
1589
1590 pr_debug("%s()\n", __func__);
1591
1592 if (machine_is_msm7x30_fluid()) {
1593 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1594 GPIO_CFG_DISABLE);
1595 if (rc) {
1596 printk(KERN_ERR
1597 "%s: gpio_tlmm_config(%#x)=%d\n",
1598 __func__, audio_fluid_icodec_tx_config, rc);
1599 }
1600 }
1601}
1602
1603void msm_snddev_poweramp_on(void)
1604{
1605 gpio_set_value(82, 1); /* enable spkr poweramp */
1606 pr_info("%s: power on amplifier\n", __func__);
1607}
1608
1609void msm_snddev_poweramp_off(void)
1610{
1611 gpio_set_value(82, 0); /* disable spkr poweramp */
1612 pr_info("%s: power off amplifier\n", __func__);
1613}
1614
Justin Paupore3f40f342011-08-10 18:52:16 -07001615static struct regulator_bulk_data snddev_regs[] = {
1616 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
1617 { .supply = "ncp", .min_uV = 1800000, .max_uV = 1800000 },
1618};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001619
Justin Paupore3f40f342011-08-10 18:52:16 -07001620static int __init snddev_hsed_voltage_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001621{
1622 int rc;
1623
Justin Paupore3f40f342011-08-10 18:52:16 -07001624 rc = regulator_bulk_get(NULL, ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001625
Justin Paupore3f40f342011-08-10 18:52:16 -07001626 if (rc) {
1627 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1628 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001629 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001630
1631 rc = regulator_bulk_set_voltage(ARRAY_SIZE(snddev_regs), snddev_regs);
1632
1633 if (rc) {
1634 pr_err("%s: could not set regulator voltages: %d\n",
1635 __func__, rc);
1636 goto regs_free;
1637 }
1638
1639 return 0;
1640
1641regs_free:
1642 regulator_bulk_free(ARRAY_SIZE(snddev_regs), snddev_regs);
1643out:
1644 return rc;
1645}
1646
1647
1648void msm_snddev_hsed_voltage_on(void)
1649{
1650 int rc = regulator_bulk_enable(ARRAY_SIZE(snddev_regs), snddev_regs);
1651
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001652 if (rc)
Justin Paupore3f40f342011-08-10 18:52:16 -07001653 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001654}
1655
1656void msm_snddev_hsed_voltage_off(void)
1657{
Justin Paupore3f40f342011-08-10 18:52:16 -07001658 int rc = regulator_bulk_disable(ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001659
Justin Paupore3f40f342011-08-10 18:52:16 -07001660 if (rc) {
1661 pr_err("%s: could not disable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001662 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001663}
1664
1665static unsigned aux_pcm_gpio_on[] = {
1666 GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
1667 GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
1668 GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
1669 GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
1670};
1671
1672static int __init aux_pcm_gpio_init(void)
1673{
1674 int pin, rc;
1675
1676 pr_info("aux_pcm_gpio_init \n");
1677 for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) {
1678 rc = gpio_tlmm_config(aux_pcm_gpio_on[pin],
1679 GPIO_CFG_ENABLE);
1680 if (rc) {
1681 printk(KERN_ERR
1682 "%s: gpio_tlmm_config(%#x)=%d\n",
1683 __func__, aux_pcm_gpio_on[pin], rc);
1684 }
1685 }
1686 return rc;
1687}
1688
1689static struct msm_gpio mi2s_clk_gpios[] = {
1690 { GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1691 "MI2S_SCLK"},
1692 { GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1693 "MI2S_WS"},
1694 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1695 "MI2S_MCLK_A"},
1696};
1697
1698static struct msm_gpio mi2s_rx_data_lines_gpios[] = {
1699 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1700 "MI2S_DATA_SD0_A"},
1701 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1702 "MI2S_DATA_SD1_A"},
1703 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1704 "MI2S_DATA_SD2_A"},
1705 { GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1706 "MI2S_DATA_SD3"},
1707};
1708
1709static struct msm_gpio mi2s_tx_data_lines_gpios[] = {
1710 { GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1711 "MI2S_DATA_SD3"},
1712};
1713
1714int mi2s_config_clk_gpio(void)
1715{
1716 int rc = 0;
1717
1718 rc = msm_gpios_request_enable(mi2s_clk_gpios,
1719 ARRAY_SIZE(mi2s_clk_gpios));
1720 if (rc) {
1721 pr_err("%s: enable mi2s clk gpios failed\n",
1722 __func__);
1723 return rc;
1724 }
1725 return 0;
1726}
1727
1728int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask)
1729{
1730 int i, rc = 0;
1731 sd_line_mask &= MI2S_SD_LINE_MASK;
1732
1733 switch (direction) {
1734 case DIR_TX:
1735 msm_gpios_disable_free(mi2s_tx_data_lines_gpios, 1);
1736 break;
1737 case DIR_RX:
1738 i = 0;
1739 while (sd_line_mask) {
1740 if (sd_line_mask & 0x1)
1741 msm_gpios_disable_free(
1742 mi2s_rx_data_lines_gpios + i , 1);
1743 sd_line_mask = sd_line_mask >> 1;
1744 i++;
1745 }
1746 break;
1747 default:
1748 pr_err("%s: Invaild direction direction = %u\n",
1749 __func__, direction);
1750 rc = -EINVAL;
1751 break;
1752 }
1753 return rc;
1754}
1755
1756int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask)
1757{
1758 int i , rc = 0;
1759 u8 sd_config_done_mask = 0;
1760
1761 sd_line_mask &= MI2S_SD_LINE_MASK;
1762
1763 switch (direction) {
1764 case DIR_TX:
1765 if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) ||
1766 (sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) {
1767 pr_err("%s: can not use SD0 or SD1 or SD2 for TX"
1768 ".only can use SD3. sd_line_mask = 0x%x\n",
1769 __func__ , sd_line_mask);
1770 rc = -EINVAL;
1771 } else {
1772 rc = msm_gpios_request_enable(mi2s_tx_data_lines_gpios,
1773 1);
1774 if (rc)
1775 pr_err("%s: enable mi2s gpios for TX failed\n",
1776 __func__);
1777 }
1778 break;
1779 case DIR_RX:
1780 i = 0;
1781 while (sd_line_mask && (rc == 0)) {
1782 if (sd_line_mask & 0x1) {
1783 rc = msm_gpios_request_enable(
1784 mi2s_rx_data_lines_gpios + i , 1);
1785 if (rc) {
1786 pr_err("%s: enable mi2s gpios for"
1787 "RX failed. SD line = %s\n",
1788 __func__,
1789 (mi2s_rx_data_lines_gpios + i)->label);
1790 mi2s_unconfig_data_gpio(DIR_RX,
1791 sd_config_done_mask);
1792 } else
1793 sd_config_done_mask |= (1 << i);
1794 }
1795 sd_line_mask = sd_line_mask >> 1;
1796 i++;
1797 }
1798 break;
1799 default:
1800 pr_err("%s: Invaild direction direction = %u\n",
1801 __func__, direction);
1802 rc = -EINVAL;
1803 break;
1804 }
1805 return rc;
1806}
1807
1808int mi2s_unconfig_clk_gpio(void)
1809{
1810 msm_gpios_disable_free(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios));
1811 return 0;
1812}
1813
1814#endif /* CONFIG_MSM7KV2_AUDIO */
1815
1816static int __init buses_init(void)
1817{
1818 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT,
1819 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
1820 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
1821 __func__, PMIC_GPIO_INT);
1822
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301823 if (machine_is_msm8x60_fluid())
1824 pm8058_7x30_data.keypad_pdata = &fluid_keypad_data;
1825 else
1826 pm8058_7x30_data.keypad_pdata = &surf_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001827
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001828 return 0;
1829}
1830
1831#define TIMPANI_RESET_GPIO 1
1832
1833struct bahama_config_register{
1834 u8 reg;
1835 u8 value;
1836 u8 mask;
1837};
1838
1839enum version{
1840 VER_1_0,
1841 VER_2_0,
1842 VER_UNSUPPORTED = 0xFF
1843};
1844
Justin Paupore3f40f342011-08-10 18:52:16 -07001845static struct regulator *vreg_marimba_1;
1846static struct regulator *vreg_marimba_2;
1847static struct regulator *vreg_bahama;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001848
1849static struct msm_gpio timpani_reset_gpio_cfg[] = {
1850{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
1851 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} };
1852
1853static u8 read_bahama_ver(void)
1854{
1855 int rc;
1856 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1857 u8 bahama_version;
1858
1859 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
1860 if (rc < 0) {
1861 printk(KERN_ERR
1862 "%s: version read failed: %d\n",
1863 __func__, rc);
1864 return rc;
1865 } else {
1866 printk(KERN_INFO
1867 "%s: version read got: 0x%x\n",
1868 __func__, bahama_version);
1869 }
1870
1871 switch (bahama_version) {
1872 case 0x08: /* varient of bahama v1 */
1873 case 0x10:
1874 case 0x00:
1875 return VER_1_0;
1876 case 0x09: /* variant of bahama v2 */
1877 return VER_2_0;
1878 default:
1879 return VER_UNSUPPORTED;
1880 }
1881}
1882
1883static int config_timpani_reset(void)
1884{
1885 int rc;
1886
1887 rc = msm_gpios_request_enable(timpani_reset_gpio_cfg,
1888 ARRAY_SIZE(timpani_reset_gpio_cfg));
1889 if (rc < 0) {
1890 printk(KERN_ERR
1891 "%s: msm_gpios_request_enable failed (%d)\n",
1892 __func__, rc);
1893 }
1894 return rc;
1895}
1896
1897static unsigned int msm_timpani_setup_power(void)
1898{
1899 int rc;
1900
1901 rc = config_timpani_reset();
1902 if (rc < 0)
1903 goto out;
1904
Justin Paupore3f40f342011-08-10 18:52:16 -07001905 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001906 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001907 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001908 goto out;
1909 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001910
1911 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001912 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001913 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1914 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001915 }
1916
1917 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1);
1918 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001919 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001920 __func__, rc);
1921 msm_gpios_free(timpani_reset_gpio_cfg,
1922 ARRAY_SIZE(timpani_reset_gpio_cfg));
Justin Paupore3f40f342011-08-10 18:52:16 -07001923 goto disable_marimba_2;
1924 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001925
Justin Paupore3f40f342011-08-10 18:52:16 -07001926 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001927
Justin Paupore3f40f342011-08-10 18:52:16 -07001928disable_marimba_2:
1929 regulator_disable(vreg_marimba_2);
1930disable_marimba_1:
1931 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001932out:
1933 return rc;
1934};
1935
1936static void msm_timpani_shutdown_power(void)
1937{
1938 int rc;
1939
Justin Paupore3f40f342011-08-10 18:52:16 -07001940 rc = regulator_disable(vreg_marimba_2);
1941 if (rc)
1942 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1943
1944 rc = regulator_disable(vreg_marimba_1);
1945 if (rc)
1946 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001947
1948 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0);
Justin Paupore3f40f342011-08-10 18:52:16 -07001949 if (rc < 0)
1950 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001951 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001952
1953 msm_gpios_free(timpani_reset_gpio_cfg,
1954 ARRAY_SIZE(timpani_reset_gpio_cfg));
1955};
1956
1957static unsigned int msm_bahama_core_config(int type)
1958{
1959 int rc = 0;
1960
1961 if (type == BAHAMA_ID) {
1962
1963 int i;
1964 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1965
1966 const struct bahama_config_register v20_init[] = {
1967 /* reg, value, mask */
1968 { 0xF4, 0x84, 0xFF }, /* AREG */
1969 { 0xF0, 0x04, 0xFF } /* DREG */
1970 };
1971
1972 if (read_bahama_ver() == VER_2_0) {
1973 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
1974 u8 value = v20_init[i].value;
1975 rc = marimba_write_bit_mask(&config,
1976 v20_init[i].reg,
1977 &value,
1978 sizeof(v20_init[i].value),
1979 v20_init[i].mask);
1980 if (rc < 0) {
1981 printk(KERN_ERR
1982 "%s: reg %d write failed: %d\n",
1983 __func__, v20_init[i].reg, rc);
1984 return rc;
1985 }
1986 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
1987 " mask 0x%02x\n",
1988 __func__, v20_init[i].reg,
1989 v20_init[i].value, v20_init[i].mask);
1990 }
1991 }
1992 }
1993 printk(KERN_INFO "core type: %d\n", type);
1994
1995 return rc;
1996}
1997
1998static unsigned int msm_bahama_setup_power(void)
1999{
Justin Paupore3f40f342011-08-10 18:52:16 -07002000 int rc = regulator_enable(vreg_bahama);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002001
Justin Paupore3f40f342011-08-10 18:52:16 -07002002 if (rc)
2003 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002004
2005 return rc;
2006};
2007
2008static unsigned int msm_bahama_shutdown_power(int value)
2009{
2010 int rc = 0;
2011
2012 if (value != BAHAMA_ID) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002013 rc = regulator_disable(vreg_bahama);
2014
2015 if (rc)
2016 pr_err("%s: regulator_disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002017 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002018 }
2019
2020 return rc;
2021};
2022
2023static struct msm_gpio marimba_svlte_config_clock[] = {
2024 { GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2025 "MARIMBA_SVLTE_CLOCK_ENABLE" },
2026};
2027
2028static unsigned int msm_marimba_gpio_config_svlte(int gpio_cfg_marimba)
2029{
2030 if (machine_is_msm8x55_svlte_surf() ||
2031 machine_is_msm8x55_svlte_ffa()) {
2032 if (gpio_cfg_marimba)
2033 gpio_set_value(GPIO_PIN
2034 (marimba_svlte_config_clock->gpio_cfg), 1);
2035 else
2036 gpio_set_value(GPIO_PIN
2037 (marimba_svlte_config_clock->gpio_cfg), 0);
2038 }
2039
2040 return 0;
2041};
2042
2043static unsigned int msm_marimba_setup_power(void)
2044{
2045 int rc;
2046
Justin Paupore3f40f342011-08-10 18:52:16 -07002047 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002048 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002049 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002050 goto out;
2051 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002052
2053 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002054 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002055 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2056 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002057 }
2058
2059 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
2060 rc = msm_gpios_request_enable(marimba_svlte_config_clock,
2061 ARRAY_SIZE(marimba_svlte_config_clock));
2062 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002063 pr_err("%s: msm_gpios_request_enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002064 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002065 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002066 }
2067
2068 rc = gpio_direction_output(GPIO_PIN
2069 (marimba_svlte_config_clock->gpio_cfg), 0);
2070 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002071 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002072 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002073 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002074 }
2075 }
2076
Justin Paupore3f40f342011-08-10 18:52:16 -07002077 return 0;
2078
2079disable_marimba_2:
2080 regulator_disable(vreg_marimba_2);
2081disable_marimba_1:
2082 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002083out:
2084 return rc;
2085};
2086
2087static void msm_marimba_shutdown_power(void)
2088{
2089 int rc;
2090
Justin Paupore3f40f342011-08-10 18:52:16 -07002091 rc = regulator_disable(vreg_marimba_2);
2092 if (rc)
2093 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
2094
2095 rc = regulator_disable(vreg_marimba_1);
2096 if (rc)
2097 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002098};
2099
2100static int bahama_present(void)
2101{
2102 int id;
2103 switch (id = adie_get_detected_connectivity_type()) {
2104 case BAHAMA_ID:
2105 return 1;
2106
2107 case MARIMBA_ID:
2108 return 0;
2109
2110 case TIMPANI_ID:
2111 default:
2112 printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n",
2113 __func__, id);
2114 return -ENODEV;
2115 }
2116}
2117
Justin Paupore3f40f342011-08-10 18:52:16 -07002118struct regulator *fm_regulator;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002119static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
2120{
Justin Paupore3f40f342011-08-10 18:52:16 -07002121 int rc, voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002122 uint32_t irqcfg;
2123 const char *id = "FMPW";
2124
2125 int bahama_not_marimba = bahama_present();
2126
Justin Paupore3f40f342011-08-10 18:52:16 -07002127 if (bahama_not_marimba < 0) {
2128 pr_warn("%s: bahama_present: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002129 __func__, bahama_not_marimba);
Justin Paupore3f40f342011-08-10 18:52:16 -07002130 rc = -ENODEV;
2131 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002132 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002133 if (bahama_not_marimba) {
2134 fm_regulator = regulator_get(NULL, "s3");
2135 voltage = 1800000;
2136 } else {
2137 fm_regulator = regulator_get(NULL, "s2");
2138 voltage = 1300000;
2139 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002140
2141 if (IS_ERR(fm_regulator)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002142 rc = PTR_ERR(fm_regulator);
2143 pr_err("%s: regulator_get failed (%d)\n", __func__, rc);
2144 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002145 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002146
Justin Paupore3f40f342011-08-10 18:52:16 -07002147 rc = regulator_set_voltage(fm_regulator, voltage, voltage);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002148
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002149 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002150 pr_err("%s: regulator_set_voltage failed (%d)\n", __func__, rc);
2151 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002152 }
2153
Justin Paupore3f40f342011-08-10 18:52:16 -07002154 rc = regulator_enable(fm_regulator);
2155
2156 if (rc) {
2157 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2158 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002159 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002160
2161 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_ON);
2162
2163 if (rc < 0) {
2164 pr_err("%s: clock vote failed (%d)\n", __func__, rc);
2165 goto regulator_disable;
2166 }
2167
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002168 /*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2169 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002170 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002171 rc = marimba_gpio_config(1);
Justin Paupore3f40f342011-08-10 18:52:16 -07002172 if (rc < 0) {
2173 pr_err("%s: clock enable for svlte : %d\n",
2174 __func__, rc);
2175 goto clock_devote;
2176 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002177 }
2178 irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
2179 GPIO_CFG_2MA);
2180 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2181 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002182 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002183 rc = -EIO;
Justin Paupore3f40f342011-08-10 18:52:16 -07002184 goto gpio_deconfig;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002185
2186 }
2187 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002188
Justin Paupore3f40f342011-08-10 18:52:16 -07002189gpio_deconfig:
2190 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa())
2191 marimba_gpio_config(0);
2192clock_devote:
2193 pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_OFF);
2194regulator_disable:
2195 regulator_disable(fm_regulator);
2196regulator_free:
2197 regulator_put(fm_regulator);
2198 fm_regulator = NULL;
2199out:
2200 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002201};
2202
2203static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
2204{
2205 int rc;
2206 const char *id = "FMPW";
2207 uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
2208 GPIO_CFG_2MA);
2209
2210 int bahama_not_marimba = bahama_present();
2211 if (bahama_not_marimba == -1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002212 pr_warn("%s: bahama_present: %d\n",
2213 __func__, bahama_not_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002214 return;
2215 }
2216
2217 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2218 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002219 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002220 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002221 if (!IS_ERR_OR_NULL(fm_regulator)) {
2222 rc = regulator_disable(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002223
Justin Paupore3f40f342011-08-10 18:52:16 -07002224 if (rc)
2225 pr_err("%s: return val: %d\n", __func__, rc);
2226
2227 regulator_put(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002228 fm_regulator = NULL;
2229 }
2230 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
2231 PMAPP_CLOCK_VOTE_OFF);
2232 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002233 pr_err("%s: clock_vote return val: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002234
2235 /*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2236 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002237 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002238 rc = marimba_gpio_config(0);
2239 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002240 pr_err("%s: clock disable for svlte : %d\n",
2241 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002242 }
2243}
2244
2245static struct marimba_fm_platform_data marimba_fm_pdata = {
2246 .fm_setup = fm_radio_setup,
2247 .fm_shutdown = fm_radio_shutdown,
2248 .irq = MSM_GPIO_TO_INT(147),
2249 .vreg_s2 = NULL,
2250 .vreg_xo_out = NULL,
2251 .is_fm_soc_i2s_master = false,
2252 .config_i2s_gpio = NULL,
2253};
2254
2255
2256/* Slave id address for FM/CDC/QMEMBIST
2257 * Values can be programmed using Marimba slave id 0
2258 * should there be a conflict with other I2C devices
2259 * */
2260#define MARIMBA_SLAVE_ID_FM_ADDR 0x2A
2261#define MARIMBA_SLAVE_ID_CDC_ADDR 0x77
2262#define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66
2263
2264#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
2265#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
2266
2267static const char *tsadc_id = "MADC";
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002268
Justin Paupore3f40f342011-08-10 18:52:16 -07002269static struct regulator_bulk_data regs_tsadc_marimba[] = {
2270 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2271 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002272};
Justin Paupore3f40f342011-08-10 18:52:16 -07002273
2274static struct regulator_bulk_data regs_tsadc_timpani[] = {
2275 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2276 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2277 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2278};
2279
2280static struct regulator_bulk_data *regs_tsadc;
2281static int regs_tsadc_count;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002282
2283static int marimba_tsadc_power(int vreg_on)
2284{
Justin Paupore3f40f342011-08-10 18:52:16 -07002285 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002286 int tsadc_adie_type = adie_get_detected_codec_type();
2287
Justin Paupore3f40f342011-08-10 18:52:16 -07002288 switch (tsadc_adie_type) {
2289 case TIMPANI_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002290 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2291 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2292 if (rc) {
2293 pr_err("%s: unable to %svote for d1 clk\n",
2294 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002295 goto D1_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002296 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002297
2298 /* fall through */
2299 case MARIMBA_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002300 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2301 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2302 if (rc) {
2303 pr_err("%s: unable to %svote for d1 clk\n",
2304 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002305 goto D0_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002306 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002307
Justin Paupore3f40f342011-08-10 18:52:16 -07002308 WARN_ON(regs_tsadc_count == 0);
2309
2310 rc = vreg_on ?
2311 regulator_bulk_enable(regs_tsadc_count, regs_tsadc) :
2312 regulator_bulk_disable(regs_tsadc_count, regs_tsadc);
2313
2314 if (rc) {
2315 pr_err("%s: regulator %sable failed: %d\n",
2316 __func__, vreg_on ? "en" : "dis", rc);
2317 goto regulator_switch_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002318 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002319
2320 break;
2321 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002322 pr_err("%s:Adie %d not supported\n",
2323 __func__, tsadc_adie_type);
2324 return -ENODEV;
2325 }
2326
2327 msleep(5); /* ensure power is stable */
2328
2329 return 0;
2330
Justin Paupore3f40f342011-08-10 18:52:16 -07002331regulator_switch_fail:
2332 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2333 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2334D0_vote_fail:
2335 if (tsadc_adie_type == TIMPANI_ID)
2336 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2337 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2338D1_vote_fail:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002339 return rc;
2340}
2341
2342static int marimba_tsadc_init(void)
2343{
Justin Paupore3f40f342011-08-10 18:52:16 -07002344 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002345 int tsadc_adie_type = adie_get_detected_codec_type();
2346
Justin Paupore3f40f342011-08-10 18:52:16 -07002347 switch (tsadc_adie_type) {
2348 case MARIMBA_ID:
2349 regs_tsadc = regs_tsadc_marimba;
2350 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_marimba);
2351 break;
2352 case TIMPANI_ID:
2353 regs_tsadc = regs_tsadc_timpani;
2354 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_timpani);
2355 break;
2356 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002357 pr_err("%s:Adie %d not supported\n",
2358 __func__, tsadc_adie_type);
Justin Paupore3f40f342011-08-10 18:52:16 -07002359 rc = -ENODEV;
2360 goto out;
2361 }
2362
2363 rc = regulator_bulk_get(NULL, regs_tsadc_count, regs_tsadc);
2364 if (rc) {
2365 pr_err("%s: could not get regulators: %d\n",
2366 __func__, rc);
2367 goto out;
2368 }
2369
2370 rc = regulator_bulk_set_voltage(regs_tsadc_count, regs_tsadc);
2371 if (rc) {
2372 pr_err("%s: could not set regulator voltages: %d\n",
2373 __func__, rc);
2374 goto vreg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002375 }
2376
2377 return 0;
2378
Justin Paupore3f40f342011-08-10 18:52:16 -07002379vreg_free:
2380 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2381out:
2382 regs_tsadc = NULL;
2383 regs_tsadc_count = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002384 return rc;
2385}
2386
2387static int marimba_tsadc_exit(void)
2388{
Justin Paupore3f40f342011-08-10 18:52:16 -07002389 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2390 regs_tsadc_count = 0;
2391 regs_tsadc = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002392
Justin Paupore3f40f342011-08-10 18:52:16 -07002393 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002394}
2395
2396
2397static struct msm_ts_platform_data msm_ts_data = {
Anirudh Ghayal82b74722012-01-19 15:35:34 +05302398 .min_x = 284,
2399 .max_x = 3801,
2400 .min_y = 155,
2401 .max_y = 3929,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002402 .min_press = 0,
2403 .max_press = 255,
2404 .inv_x = 4096,
2405 .inv_y = 4096,
2406 .can_wakeup = false,
2407};
2408
2409static struct marimba_tsadc_platform_data marimba_tsadc_pdata = {
2410 .marimba_tsadc_power = marimba_tsadc_power,
2411 .init = marimba_tsadc_init,
2412 .exit = marimba_tsadc_exit,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002413 .tsadc_prechg_en = true,
2414 .can_wakeup = false,
2415 .setup = {
2416 .pen_irq_en = true,
2417 .tsadc_en = true,
2418 },
2419 .params2 = {
2420 .input_clk_khz = 2400,
2421 .sample_prd = TSADC_CLK_3,
2422 },
2423 .params3 = {
2424 .prechg_time_nsecs = 6400,
2425 .stable_time_nsecs = 6400,
2426 .tsadc_test_mode = 0,
2427 },
2428 .tssc_data = &msm_ts_data,
2429};
2430
Justin Paupore3f40f342011-08-10 18:52:16 -07002431static struct regulator_bulk_data codec_regs[] = {
2432 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
2433};
2434
2435static int __init msm_marimba_codec_init(void)
2436{
2437 int rc = regulator_bulk_get(NULL, ARRAY_SIZE(codec_regs), codec_regs);
2438
2439 if (rc) {
2440 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2441 goto out;
2442 }
2443
2444 rc = regulator_bulk_set_voltage(ARRAY_SIZE(codec_regs), codec_regs);
2445 if (rc) {
2446 pr_err("%s: could not set regulator voltages: %d\n",
2447 __func__, rc);
2448 goto reg_free;
2449 }
2450
2451 return rc;
2452
2453reg_free:
2454 regulator_bulk_free(ARRAY_SIZE(codec_regs), codec_regs);
2455out:
2456 return rc;
2457}
2458
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002459static int msm_marimba_codec_power(int vreg_on)
2460{
Justin Paupore3f40f342011-08-10 18:52:16 -07002461 int rc = vreg_on ?
2462 regulator_bulk_enable(ARRAY_SIZE(codec_regs), codec_regs) :
2463 regulator_bulk_disable(ARRAY_SIZE(codec_regs), codec_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002464
Justin Paupore3f40f342011-08-10 18:52:16 -07002465 if (rc) {
2466 pr_err("%s: could not %sable regulators: %d",
2467 __func__, vreg_on ? "en" : "dis", rc);
2468 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002469 }
2470
Justin Paupore3f40f342011-08-10 18:52:16 -07002471 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002472}
2473
2474static struct marimba_codec_platform_data mariba_codec_pdata = {
2475 .marimba_codec_power = msm_marimba_codec_power,
2476#ifdef CONFIG_MARIMBA_CODEC
2477 .snddev_profile_init = msm_snddev_init,
2478#endif
2479};
2480
2481static struct marimba_platform_data marimba_pdata = {
2482 .slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR,
2483 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2484 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2485 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
2486 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
2487 .marimba_setup = msm_marimba_setup_power,
2488 .marimba_shutdown = msm_marimba_shutdown_power,
2489 .bahama_setup = msm_bahama_setup_power,
2490 .bahama_shutdown = msm_bahama_shutdown_power,
2491 .marimba_gpio_config = msm_marimba_gpio_config_svlte,
2492 .bahama_core_config = msm_bahama_core_config,
2493 .fm = &marimba_fm_pdata,
2494 .codec = &mariba_codec_pdata,
2495 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2496};
2497
2498static void __init msm7x30_init_marimba(void)
2499{
2500 int rc;
2501
Justin Paupore3f40f342011-08-10 18:52:16 -07002502 struct regulator_bulk_data regs[] = {
2503 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2504 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2505 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
2506 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002507
Justin Paupore3f40f342011-08-10 18:52:16 -07002508 rc = msm_marimba_codec_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002509
Justin Paupore3f40f342011-08-10 18:52:16 -07002510 if (rc) {
2511 pr_err("%s: msm_marimba_codec_init failed (%d)\n",
2512 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002513 return;
2514 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002515
2516 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
2517
2518 if (rc) {
2519 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2520 return;
2521 }
2522
2523 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
2524
2525 if (rc) {
2526 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2527 regulator_bulk_free(ARRAY_SIZE(regs), regs);
2528 return;
2529 }
2530
2531 vreg_marimba_1 = regs[0].consumer;
2532 vreg_marimba_2 = regs[1].consumer;
2533 vreg_bahama = regs[2].consumer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002534}
2535
2536static struct marimba_codec_platform_data timpani_codec_pdata = {
2537 .marimba_codec_power = msm_marimba_codec_power,
2538#ifdef CONFIG_TIMPANI_CODEC
2539 .snddev_profile_init = msm_snddev_init_timpani,
2540#endif
2541};
2542
2543static struct marimba_platform_data timpani_pdata = {
2544 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2545 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2546 .marimba_setup = msm_timpani_setup_power,
2547 .marimba_shutdown = msm_timpani_shutdown_power,
2548 .codec = &timpani_codec_pdata,
2549 .tsadc = &marimba_tsadc_pdata,
2550 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2551};
2552
2553#define TIMPANI_I2C_SLAVE_ADDR 0xD
2554
2555static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
2556 {
2557 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
2558 .platform_data = &timpani_pdata,
2559 },
2560};
2561
2562#ifdef CONFIG_MSM7KV2_AUDIO
2563static struct resource msm_aictl_resources[] = {
2564 {
2565 .name = "aictl",
2566 .start = 0xa5000100,
2567 .end = 0xa5000100,
2568 .flags = IORESOURCE_MEM,
2569 }
2570};
2571
2572static struct resource msm_mi2s_resources[] = {
2573 {
2574 .name = "hdmi",
2575 .start = 0xac900000,
2576 .end = 0xac900038,
2577 .flags = IORESOURCE_MEM,
2578 },
2579 {
2580 .name = "codec_rx",
2581 .start = 0xac940040,
2582 .end = 0xac940078,
2583 .flags = IORESOURCE_MEM,
2584 },
2585 {
2586 .name = "codec_tx",
2587 .start = 0xac980080,
2588 .end = 0xac9800B8,
2589 .flags = IORESOURCE_MEM,
2590 }
2591
2592};
2593
2594static struct msm_lpa_platform_data lpa_pdata = {
2595 .obuf_hlb_size = 0x2BFF8,
2596 .dsp_proc_id = 0,
2597 .app_proc_id = 2,
2598 .nosb_config = {
2599 .llb_min_addr = 0,
2600 .llb_max_addr = 0x3ff8,
2601 .sb_min_addr = 0,
2602 .sb_max_addr = 0,
2603 },
2604 .sb_config = {
2605 .llb_min_addr = 0,
2606 .llb_max_addr = 0x37f8,
2607 .sb_min_addr = 0x3800,
2608 .sb_max_addr = 0x3ff8,
2609 }
2610};
2611
2612static struct resource msm_lpa_resources[] = {
2613 {
2614 .name = "lpa",
2615 .start = 0xa5000000,
2616 .end = 0xa50000a0,
2617 .flags = IORESOURCE_MEM,
2618 }
2619};
2620
2621static struct resource msm_aux_pcm_resources[] = {
2622
2623 {
2624 .name = "aux_codec_reg_addr",
2625 .start = 0xac9c00c0,
2626 .end = 0xac9c00c8,
2627 .flags = IORESOURCE_MEM,
2628 },
2629 {
2630 .name = "aux_pcm_dout",
2631 .start = 138,
2632 .end = 138,
2633 .flags = IORESOURCE_IO,
2634 },
2635 {
2636 .name = "aux_pcm_din",
2637 .start = 139,
2638 .end = 139,
2639 .flags = IORESOURCE_IO,
2640 },
2641 {
2642 .name = "aux_pcm_syncout",
2643 .start = 140,
2644 .end = 140,
2645 .flags = IORESOURCE_IO,
2646 },
2647 {
2648 .name = "aux_pcm_clkin_a",
2649 .start = 141,
2650 .end = 141,
2651 .flags = IORESOURCE_IO,
2652 },
2653};
2654
2655static struct platform_device msm_aux_pcm_device = {
2656 .name = "msm_aux_pcm",
2657 .id = 0,
2658 .num_resources = ARRAY_SIZE(msm_aux_pcm_resources),
2659 .resource = msm_aux_pcm_resources,
2660};
2661
2662struct platform_device msm_aictl_device = {
2663 .name = "audio_interct",
2664 .id = 0,
2665 .num_resources = ARRAY_SIZE(msm_aictl_resources),
2666 .resource = msm_aictl_resources,
2667};
2668
2669struct platform_device msm_mi2s_device = {
2670 .name = "mi2s",
2671 .id = 0,
2672 .num_resources = ARRAY_SIZE(msm_mi2s_resources),
2673 .resource = msm_mi2s_resources,
2674};
2675
2676struct platform_device msm_lpa_device = {
2677 .name = "lpa",
2678 .id = 0,
2679 .num_resources = ARRAY_SIZE(msm_lpa_resources),
2680 .resource = msm_lpa_resources,
2681 .dev = {
2682 .platform_data = &lpa_pdata,
2683 },
2684};
2685#endif /* CONFIG_MSM7KV2_AUDIO */
2686
2687#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2688 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2689 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2690 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2691 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2692 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2693#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2694 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2695 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2696 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2697 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2698 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2699 #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2700 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2701 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2702 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2703 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2704 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2705 #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2706 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2707 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2708 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2709 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2710 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2711#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
2712
2713static unsigned int dec_concurrency_table[] = {
2714 /* Audio LP */
2715 0,
2716 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2717 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2718 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2719 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)|
2720 (1<<MSM_ADSP_OP_DM)),
2721
2722 /* Concurrency 1 */
2723 (DEC4_FORMAT),
2724 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2725 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2726 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2727 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2728
2729 /* Concurrency 2 */
2730 (DEC4_FORMAT),
2731 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2732 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2733 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2734 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2735
2736 /* Concurrency 3 */
2737 (DEC4_FORMAT),
2738 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2739 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2740 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2741 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2742
2743 /* Concurrency 4 */
2744 (DEC4_FORMAT),
2745 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2746 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2747 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2748 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2749
2750 /* Concurrency 5 */
2751 (DEC4_FORMAT),
2752 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2753 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2754 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2755 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2756
2757 /* Concurrency 6 */
2758 (DEC4_FORMAT),
2759 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2760 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2761 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2762 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2763};
2764
2765#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
2766 .module_queueid = queueid, .module_decid = decid, \
2767 .nr_codec_support = nr_codec}
2768
2769#define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
2770 .max_instances_same_dec = max_instance_same, \
2771 .max_instances_diff_dec = max_instance_diff}
2772
2773static struct msm_adspdec_info dec_info_list[] = {
2774 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
2775 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
2776 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
2777 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
2778 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
2779};
2780
2781static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
2782 /* Non Turbo Mode */
2783 {
2784 DEC_INSTANCE(4, 3), /* WAV */
2785 DEC_INSTANCE(4, 3), /* ADPCM */
2786 DEC_INSTANCE(4, 2), /* MP3 */
2787 DEC_INSTANCE(0, 0), /* Real Audio */
2788 DEC_INSTANCE(4, 2), /* WMA */
2789 DEC_INSTANCE(3, 2), /* AAC */
2790 DEC_INSTANCE(0, 0), /* Reserved */
2791 DEC_INSTANCE(0, 0), /* MIDI */
2792 DEC_INSTANCE(4, 3), /* YADPCM */
2793 DEC_INSTANCE(4, 3), /* QCELP */
2794 DEC_INSTANCE(4, 3), /* AMRNB */
2795 DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
2796 DEC_INSTANCE(4, 3), /* EVRC */
2797 DEC_INSTANCE(1, 1), /* WMAPRO */
2798 },
2799 /* Turbo Mode */
2800 {
2801 DEC_INSTANCE(4, 3), /* WAV */
2802 DEC_INSTANCE(4, 3), /* ADPCM */
2803 DEC_INSTANCE(4, 3), /* MP3 */
2804 DEC_INSTANCE(0, 0), /* Real Audio */
2805 DEC_INSTANCE(4, 3), /* WMA */
2806 DEC_INSTANCE(4, 3), /* AAC */
2807 DEC_INSTANCE(0, 0), /* Reserved */
2808 DEC_INSTANCE(0, 0), /* MIDI */
2809 DEC_INSTANCE(4, 3), /* YADPCM */
2810 DEC_INSTANCE(4, 3), /* QCELP */
2811 DEC_INSTANCE(4, 3), /* AMRNB */
2812 DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
2813 DEC_INSTANCE(4, 3), /* EVRC */
2814 DEC_INSTANCE(1, 2), /* WMAPRO */
2815 },
2816};
2817
2818static struct msm_adspdec_database msm_device_adspdec_database = {
2819 .num_dec = ARRAY_SIZE(dec_info_list),
2820 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
2821 ARRAY_SIZE(dec_info_list)),
2822 .dec_concurrency_table = dec_concurrency_table,
2823 .dec_info_list = dec_info_list,
2824 .dec_instance_list = &dec_instance_list[0][0],
2825};
2826
2827static struct platform_device msm_device_adspdec = {
2828 .name = "msm_adspdec",
2829 .id = -1,
2830 .dev = {
2831 .platform_data = &msm_device_adspdec_database
2832 },
2833};
2834
2835static struct resource smc91x_resources[] = {
2836 [0] = {
2837 .start = 0x8A000300,
2838 .end = 0x8A0003ff,
2839 .flags = IORESOURCE_MEM,
2840 },
2841 [1] = {
2842 .start = MSM_GPIO_TO_INT(156),
2843 .end = MSM_GPIO_TO_INT(156),
2844 .flags = IORESOURCE_IRQ,
2845 },
2846};
2847
2848static struct platform_device smc91x_device = {
2849 .name = "smc91x",
2850 .id = 0,
2851 .num_resources = ARRAY_SIZE(smc91x_resources),
2852 .resource = smc91x_resources,
2853};
2854
2855static struct smsc911x_platform_config smsc911x_config = {
2856 .phy_interface = PHY_INTERFACE_MODE_MII,
2857 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
2858 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
2859 .flags = SMSC911X_USE_32BIT,
2860};
2861
2862static struct resource smsc911x_resources[] = {
2863 [0] = {
2864 .start = 0x8D000000,
2865 .end = 0x8D000100,
2866 .flags = IORESOURCE_MEM,
2867 },
2868 [1] = {
2869 .start = MSM_GPIO_TO_INT(88),
2870 .end = MSM_GPIO_TO_INT(88),
2871 .flags = IORESOURCE_IRQ,
2872 },
2873};
2874
2875static struct platform_device smsc911x_device = {
2876 .name = "smsc911x",
2877 .id = -1,
2878 .num_resources = ARRAY_SIZE(smsc911x_resources),
2879 .resource = smsc911x_resources,
2880 .dev = {
2881 .platform_data = &smsc911x_config,
2882 },
2883};
2884
2885static struct msm_gpio smsc911x_gpios[] = {
2886 { GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" },
2887 { GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" },
2888 { GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" },
2889 { GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" },
2890 { GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" },
2891 { GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" },
2892 { GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" },
2893 { GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" },
2894};
2895
2896static void msm7x30_cfg_smsc911x(void)
2897{
2898 int rc;
2899
2900 rc = msm_gpios_request_enable(smsc911x_gpios,
2901 ARRAY_SIZE(smsc911x_gpios));
2902 if (rc)
2903 pr_err("%s: unable to enable gpios\n", __func__);
2904}
2905
2906#ifdef CONFIG_USB_G_ANDROID
2907static struct android_usb_platform_data android_usb_pdata = {
2908 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2909};
2910
2911static struct platform_device android_usb_device = {
2912 .name = "android_usb",
2913 .id = -1,
2914 .dev = {
2915 .platform_data = &android_usb_pdata,
2916 },
2917};
2918#endif
2919
2920static struct msm_gpio optnav_config_data[] = {
2921 { GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA),
2922 "optnav_chip_select" },
2923};
2924
Justin Paupore3f40f342011-08-10 18:52:16 -07002925static struct regulator_bulk_data optnav_regulators[] = {
2926 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2927 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
2928 { .supply = "gp9", .min_uV = 1800000, .max_uV = 1800000 },
2929 { .supply = "usb", .min_uV = 3300000, .max_uV = 3300000 },
2930};
2931
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002932static void __iomem *virtual_optnav;
2933
2934static int optnav_gpio_setup(void)
2935{
2936 int rc = -ENODEV;
2937 rc = msm_gpios_request_enable(optnav_config_data,
2938 ARRAY_SIZE(optnav_config_data));
2939
Justin Paupore3f40f342011-08-10 18:52:16 -07002940 if (rc)
2941 return rc;
2942
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002943 /* Configure the FPGA for GPIOs */
2944 virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4);
2945 if (!virtual_optnav) {
2946 pr_err("%s:Could not ioremap region\n", __func__);
2947 return -ENOMEM;
2948 }
2949 /*
2950 * Configure the FPGA to set GPIO 19 as
2951 * normal, active(enabled), output(MSM to SURF)
2952 */
2953 writew(0x311E, virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002954
2955 rc = regulator_bulk_get(NULL, ARRAY_SIZE(optnav_regulators),
2956 optnav_regulators);
2957 if (rc)
2958 return rc;
2959
2960 rc = regulator_bulk_set_voltage(ARRAY_SIZE(optnav_regulators),
2961 optnav_regulators);
2962
2963 if (rc)
2964 goto regulator_put;
2965
2966 return rc;
2967
2968regulator_put:
2969 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002970 return rc;
2971}
2972
2973static void optnav_gpio_release(void)
2974{
2975 msm_gpios_disable_free(optnav_config_data,
2976 ARRAY_SIZE(optnav_config_data));
2977 iounmap(virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002978 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002979}
2980
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002981static int optnav_enable(void)
2982{
2983 int rc;
2984 /*
2985 * Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
2986 * for I2C communication with keyboard.
2987 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002988
Justin Paupore3f40f342011-08-10 18:52:16 -07002989 rc = regulator_bulk_enable(ARRAY_SIZE(optnav_regulators),
2990 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002991
Justin Paupore3f40f342011-08-10 18:52:16 -07002992 if (rc)
2993 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002994
2995 /* Enable the chip select GPIO */
2996 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2997 gpio_set_value(OPTNAV_CHIP_SELECT, 0);
2998
2999 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003000}
3001
3002static void optnav_disable(void)
3003{
Justin Paupore3f40f342011-08-10 18:52:16 -07003004 regulator_bulk_disable(ARRAY_SIZE(optnav_regulators),
3005 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003006
3007 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
3008}
3009
3010static struct ofn_atlab_platform_data optnav_data = {
3011 .gpio_setup = optnav_gpio_setup,
3012 .gpio_release = optnav_gpio_release,
3013 .optnav_on = optnav_enable,
3014 .optnav_off = optnav_disable,
3015 .rotate_xy = 0,
3016 .function1 = {
3017 .no_motion1_en = true,
3018 .touch_sensor_en = true,
3019 .ofn_en = true,
3020 .clock_select_khz = 1500,
3021 .cpi_selection = 1200,
3022 },
3023 .function2 = {
3024 .invert_y = false,
3025 .invert_x = true,
3026 .swap_x_y = false,
3027 .hold_a_b_en = true,
3028 .motion_filter_en = true,
3029 },
3030};
3031
3032static int hdmi_comm_power(int on, int show);
3033static int hdmi_init_irq(void);
3034static int hdmi_enable_5v(int on);
3035static int hdmi_core_power(int on, int show);
3036static int hdmi_cec_power(int on);
3037static bool hdmi_check_hdcp_hw_support(void);
3038
3039static struct msm_hdmi_platform_data adv7520_hdmi_data = {
3040 .irq = MSM_GPIO_TO_INT(18),
3041 .comm_power = hdmi_comm_power,
3042 .init_irq = hdmi_init_irq,
3043 .enable_5v = hdmi_enable_5v,
3044 .core_power = hdmi_core_power,
3045 .cec_power = hdmi_cec_power,
3046 .check_hdcp_hw_support = hdmi_check_hdcp_hw_support,
3047};
3048
3049#ifdef CONFIG_BOSCH_BMA150
Justin Paupore3f40f342011-08-10 18:52:16 -07003050
3051static struct regulator_bulk_data sensors_ldo[] = {
3052 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
3053 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
3054};
3055
3056static int __init sensors_ldo_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003057{
3058 int rc;
3059
Justin Paupore3f40f342011-08-10 18:52:16 -07003060 rc = regulator_bulk_get(NULL, ARRAY_SIZE(sensors_ldo), sensors_ldo);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003061
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003062 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003063 pr_err("%s: could not get regulators: %d\n", __func__, rc);
3064 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003065 }
3066
Justin Paupore3f40f342011-08-10 18:52:16 -07003067 rc = regulator_bulk_set_voltage(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3068
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003069 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003070 pr_err("%s: could not set voltages: %d\n", __func__, rc);
3071 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003072 }
3073
3074 return 0;
3075
Justin Paupore3f40f342011-08-10 18:52:16 -07003076reg_free:
3077 regulator_bulk_free(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3078out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003079 return rc;
3080}
3081
Justin Paupore3f40f342011-08-10 18:52:16 -07003082static int sensors_ldo_set(int on)
3083{
3084 int rc = on ?
3085 regulator_bulk_enable(ARRAY_SIZE(sensors_ldo), sensors_ldo) :
3086 regulator_bulk_disable(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3087
3088 if (rc)
3089 pr_err("%s: could not %sable regulators: %d\n",
3090 __func__, on ? "en" : "dis", rc);
3091
3092 return rc;
3093}
3094
3095static int sensors_ldo_enable(void)
3096{
3097 return sensors_ldo_set(1);
3098}
3099
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003100static void sensors_ldo_disable(void)
3101{
Justin Paupore3f40f342011-08-10 18:52:16 -07003102 sensors_ldo_set(0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003103}
Justin Paupore3f40f342011-08-10 18:52:16 -07003104
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003105static struct bma150_platform_data bma150_data = {
3106 .power_on = sensors_ldo_enable,
3107 .power_off = sensors_ldo_disable,
3108};
3109
3110static struct i2c_board_info bma150_board_info[] __initdata = {
3111 {
3112 I2C_BOARD_INFO("bma150", 0x38),
3113 .flags = I2C_CLIENT_WAKE,
3114 .irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
3115 .platform_data = &bma150_data,
3116 },
3117};
3118#endif
3119
3120static struct i2c_board_info msm_i2c_board_info[] = {
3121 {
3122 I2C_BOARD_INFO("m33c01", OPTNAV_I2C_SLAVE_ADDR),
3123 .irq = MSM_GPIO_TO_INT(OPTNAV_IRQ),
3124 .platform_data = &optnav_data,
3125 },
3126 {
3127 I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR),
3128 .platform_data = &adv7520_hdmi_data,
3129 },
3130};
3131
3132static struct i2c_board_info msm_marimba_board_info[] = {
3133 {
3134 I2C_BOARD_INFO("marimba", 0xc),
3135 .platform_data = &marimba_pdata,
3136 }
3137};
3138
3139
3140static struct msm_handset_platform_data hs_platform_data = {
3141 .hs_name = "7k_handset",
3142 .pwr_key_delay_ms = 500, /* 0 will disable end key */
3143};
3144
3145static struct platform_device hs_device = {
3146 .name = "msm-handset",
3147 .id = -1,
3148 .dev = {
3149 .platform_data = &hs_platform_data,
3150 },
3151};
3152
3153static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +05303154 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003155 .idle_supported = 1,
3156 .suspend_supported = 1,
3157 .idle_enabled = 1,
3158 .suspend_enabled = 1,
3159 .latency = 8594,
3160 .residency = 23740,
3161 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303162 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003163 .idle_supported = 1,
3164 .suspend_supported = 1,
3165 .idle_enabled = 1,
3166 .suspend_enabled = 1,
3167 .latency = 4594,
3168 .residency = 23740,
3169 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303170 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003171#ifdef CONFIG_MSM_STANDALONE_POWER_COLLAPSE
3172 .idle_supported = 1,
3173 .suspend_supported = 1,
3174 .idle_enabled = 1,
3175 .suspend_enabled = 0,
3176#else /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3177 .idle_supported = 0,
3178 .suspend_supported = 0,
3179 .idle_enabled = 0,
3180 .suspend_enabled = 0,
3181#endif /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3182 .latency = 500,
3183 .residency = 6000,
3184 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303185 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003186 .idle_supported = 1,
3187 .suspend_supported = 1,
3188 .idle_enabled = 0,
3189 .suspend_enabled = 1,
3190 .latency = 443,
3191 .residency = 1098,
3192 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303193 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003194 .idle_supported = 1,
3195 .suspend_supported = 1,
3196 .idle_enabled = 1,
3197 .suspend_enabled = 1,
3198 .latency = 2,
3199 .residency = 0,
3200 },
3201};
3202
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003203static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3204 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
3205 .v_addr = (uint32_t *)PAGE_OFFSET,
3206};
3207
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003208static struct resource qsd_spi_resources[] = {
3209 {
3210 .name = "spi_irq_in",
3211 .start = INT_SPI_INPUT,
3212 .end = INT_SPI_INPUT,
3213 .flags = IORESOURCE_IRQ,
3214 },
3215 {
3216 .name = "spi_irq_out",
3217 .start = INT_SPI_OUTPUT,
3218 .end = INT_SPI_OUTPUT,
3219 .flags = IORESOURCE_IRQ,
3220 },
3221 {
3222 .name = "spi_irq_err",
3223 .start = INT_SPI_ERROR,
3224 .end = INT_SPI_ERROR,
3225 .flags = IORESOURCE_IRQ,
3226 },
3227 {
3228 .name = "spi_base",
3229 .start = 0xA8000000,
3230 .end = 0xA8000000 + SZ_4K - 1,
3231 .flags = IORESOURCE_MEM,
3232 },
3233 {
3234 .name = "spidm_channels",
3235 .flags = IORESOURCE_DMA,
3236 },
3237 {
3238 .name = "spidm_crci",
3239 .flags = IORESOURCE_DMA,
3240 },
3241};
3242
3243#define AMDH0_BASE_PHYS 0xAC200000
3244#define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
3245static int msm_qsd_spi_dma_config(void)
3246{
3247 void __iomem *ct_adm_base = 0;
3248 u32 spi_mux = 0;
3249 int ret = 0;
3250
3251 ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
3252 if (!ct_adm_base) {
3253 pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
3254 return -ENOMEM;
3255 }
3256
3257 spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
3258
3259 qsd_spi_resources[4].start = DMOV_USB_CHAN;
3260 qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
3261
3262 switch (spi_mux) {
3263 case (1):
3264 qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
3265 qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
3266 break;
3267 case (2):
3268 qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
3269 qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
3270 break;
3271 case (3):
3272 qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
3273 qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
3274 break;
3275 default:
3276 ret = -ENOENT;
3277 }
3278
3279 iounmap(ct_adm_base);
3280
3281 return ret;
3282}
3283
3284static struct platform_device qsd_device_spi = {
3285 .name = "spi_qsd",
3286 .id = 0,
3287 .num_resources = ARRAY_SIZE(qsd_spi_resources),
3288 .resource = qsd_spi_resources,
3289};
3290
3291#ifdef CONFIG_SPI_QSD
3292static struct spi_board_info lcdc_sharp_spi_board_info[] __initdata = {
3293 {
3294 .modalias = "lcdc_sharp_ls038y7dx01",
3295 .mode = SPI_MODE_1,
3296 .bus_num = 0,
3297 .chip_select = 0,
3298 .max_speed_hz = 26331429,
3299 }
3300};
3301static struct spi_board_info lcdc_toshiba_spi_board_info[] __initdata = {
3302 {
3303 .modalias = "lcdc_toshiba_ltm030dd40",
3304 .mode = SPI_MODE_3|SPI_CS_HIGH,
3305 .bus_num = 0,
3306 .chip_select = 0,
3307 .max_speed_hz = 9963243,
3308 }
3309};
3310#endif
3311
3312static struct msm_gpio qsd_spi_gpio_config_data[] = {
3313 { GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3314 { GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3315 { GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" },
3316 { GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3317};
3318
3319static int msm_qsd_spi_gpio_config(void)
3320{
3321 return msm_gpios_request_enable(qsd_spi_gpio_config_data,
3322 ARRAY_SIZE(qsd_spi_gpio_config_data));
3323}
3324
3325static void msm_qsd_spi_gpio_release(void)
3326{
3327 msm_gpios_disable_free(qsd_spi_gpio_config_data,
3328 ARRAY_SIZE(qsd_spi_gpio_config_data));
3329}
3330
3331static struct msm_spi_platform_data qsd_spi_pdata = {
3332 .max_clock_speed = 26331429,
3333 .gpio_config = msm_qsd_spi_gpio_config,
3334 .gpio_release = msm_qsd_spi_gpio_release,
3335 .dma_config = msm_qsd_spi_dma_config,
3336};
3337
3338static void __init msm_qsd_spi_init(void)
3339{
3340 qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
3341}
3342
3343#ifdef CONFIG_USB_EHCI_MSM_72K
3344static void msm_hsusb_vbus_power(unsigned phy_info, int on)
3345{
3346 int rc;
3347 static int vbus_is_on;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303348 struct pm8xxx_gpio_init_info usb_vbus = {
3349 PM8058_GPIO_PM_TO_SYS(36),
3350 {
3351 .direction = PM_GPIO_DIR_OUT,
3352 .pull = PM_GPIO_PULL_NO,
3353 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3354 .output_value = 1,
3355 .vin_sel = 2,
3356 .out_strength = PM_GPIO_STRENGTH_MED,
3357 .function = PM_GPIO_FUNC_NORMAL,
3358 .inv_int_pol = 0,
3359 },
3360 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003361
3362 /* If VBUS is already on (or off), do nothing. */
3363 if (unlikely(on == vbus_is_on))
3364 return;
3365
3366 if (on) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303367 rc = pm8xxx_gpio_config(usb_vbus.gpio, &usb_vbus.config);
3368 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003369 pr_err("%s PMIC GPIO 36 write failed\n", __func__);
3370 return;
3371 }
3372 } else {
3373 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(36), 0);
3374 }
3375
3376 vbus_is_on = on;
3377}
3378
3379static struct msm_usb_host_platform_data msm_usb_host_pdata = {
3380 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
3381 .vbus_power = msm_hsusb_vbus_power,
3382 .power_budget = 180,
3383};
3384#endif
3385
3386#ifdef CONFIG_USB_MSM_OTG_72K
3387static int hsusb_rpc_connect(int connect)
3388{
3389 if (connect)
3390 return msm_hsusb_rpc_connect();
3391 else
3392 return msm_hsusb_rpc_close();
3393}
3394#endif
3395
3396#ifdef CONFIG_USB_MSM_OTG_72K
Justin Paupore3f40f342011-08-10 18:52:16 -07003397static struct regulator *vreg_3p3;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003398static int msm_hsusb_ldo_init(int init)
3399{
3400 uint32_t version = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07003401 int def_vol = 3400000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003402
3403 version = socinfo_get_version();
3404
3405 if (SOCINFO_VERSION_MAJOR(version) >= 2 &&
3406 SOCINFO_VERSION_MINOR(version) >= 1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003407 def_vol = 3075000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003408 pr_debug("%s: default voltage:%d\n", __func__, def_vol);
3409 }
3410
3411 if (init) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003412 vreg_3p3 = regulator_get(NULL, "usb");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003413 if (IS_ERR(vreg_3p3))
3414 return PTR_ERR(vreg_3p3);
Justin Paupore3f40f342011-08-10 18:52:16 -07003415 regulator_set_voltage(vreg_3p3, def_vol, def_vol);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003416 } else
Justin Paupore3f40f342011-08-10 18:52:16 -07003417 regulator_put(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003418
3419 return 0;
3420}
3421
3422static int msm_hsusb_ldo_enable(int enable)
3423{
3424 static int ldo_status;
3425
3426 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3427 return -ENODEV;
3428
3429 if (ldo_status == enable)
3430 return 0;
3431
3432 ldo_status = enable;
3433
3434 if (enable)
Justin Paupore3f40f342011-08-10 18:52:16 -07003435 return regulator_enable(vreg_3p3);
3436 else
3437 return regulator_disable(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003438}
3439
3440static int msm_hsusb_ldo_set_voltage(int mV)
3441{
Justin Paupore3f40f342011-08-10 18:52:16 -07003442 static int cur_voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003443
3444 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3445 return -ENODEV;
3446
3447 if (cur_voltage == mV)
3448 return 0;
3449
3450 cur_voltage = mV;
3451
3452 pr_debug("%s: (%d)\n", __func__, mV);
3453
Justin Paupore3f40f342011-08-10 18:52:16 -07003454 return regulator_set_voltage(vreg_3p3, mV*1000, mV*1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003455}
3456#endif
3457
3458#ifndef CONFIG_USB_EHCI_MSM_72K
3459static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init);
3460#endif
3461static struct msm_otg_platform_data msm_otg_pdata = {
3462 .rpc_connect = hsusb_rpc_connect,
3463
3464#ifndef CONFIG_USB_EHCI_MSM_72K
3465 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
3466#else
3467 .vbus_power = msm_hsusb_vbus_power,
3468#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003469 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
3470 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
3471 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
3472 .se1_gating = SE1_GATING_DISABLE,
3473 .chg_vbus_draw = hsusb_chg_vbus_draw,
3474 .chg_connected = hsusb_chg_connected,
3475 .chg_init = hsusb_chg_init,
3476 .ldo_enable = msm_hsusb_ldo_enable,
3477 .ldo_init = msm_hsusb_ldo_init,
3478 .ldo_set_voltage = msm_hsusb_ldo_set_voltage,
3479};
3480
3481#ifdef CONFIG_USB_GADGET
3482static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
3483 .is_phy_status_timer_on = 1,
3484};
3485#endif
3486#ifndef CONFIG_USB_EHCI_MSM_72K
3487typedef void (*notify_vbus_state) (int);
3488notify_vbus_state notify_vbus_state_func_ptr;
3489int vbus_on_irq;
3490static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
3491{
3492 pr_info("%s: vbus notification from pmic\n", __func__);
3493
3494 (*notify_vbus_state_func_ptr) (1);
3495
3496 return IRQ_HANDLED;
3497}
3498static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
3499{
3500 int ret;
3501
3502 if (init) {
3503 if (!callback)
3504 return -ENODEV;
3505
3506 notify_vbus_state_func_ptr = callback;
3507 vbus_on_irq = platform_get_irq_byname(&msm_device_otg,
3508 "vbus_on");
3509 if (vbus_on_irq <= 0) {
3510 pr_err("%s: unable to get vbus on irq\n", __func__);
3511 return -ENODEV;
3512 }
3513
3514 ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq,
3515 IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
3516 if (ret < 0) {
3517 pr_info("%s: request_irq for vbus_on"
3518 "interrupt failed\n", __func__);
3519 return ret;
3520 }
3521 msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
3522 return 0;
3523 } else {
3524 free_irq(vbus_on_irq, 0);
3525 notify_vbus_state_func_ptr = NULL;
3526 return 0;
3527 }
3528}
3529#endif
3530
3531static struct android_pmem_platform_data android_pmem_pdata = {
3532 .name = "pmem",
3533 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
3534 .cached = 1,
3535 .memory_type = MEMTYPE_EBI0,
3536};
3537
3538static struct platform_device android_pmem_device = {
3539 .name = "android_pmem",
3540 .id = 0,
3541 .dev = { .platform_data = &android_pmem_pdata },
3542};
3543
3544#ifndef CONFIG_SPI_QSD
3545static int lcdc_gpio_array_num[] = {
3546 45, /* spi_clk */
3547 46, /* spi_cs */
3548 47, /* spi_mosi */
3549 48, /* spi_miso */
3550 };
3551
3552static struct msm_gpio lcdc_gpio_config_data[] = {
3553 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3554 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3555 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
3556 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3557};
3558
3559static void lcdc_config_gpios(int enable)
3560{
3561 if (enable) {
3562 msm_gpios_request_enable(lcdc_gpio_config_data,
3563 ARRAY_SIZE(
3564 lcdc_gpio_config_data));
3565 } else
3566 msm_gpios_disable_free(lcdc_gpio_config_data,
3567 ARRAY_SIZE(
3568 lcdc_gpio_config_data));
3569}
3570#endif
3571
3572static struct msm_panel_common_pdata lcdc_sharp_panel_data = {
3573#ifndef CONFIG_SPI_QSD
3574 .panel_config_gpio = lcdc_config_gpios,
3575 .gpio_num = lcdc_gpio_array_num,
3576#endif
3577 .gpio = 2, /* LPG PMIC_GPIO26 channel number */
3578};
3579
3580static struct platform_device lcdc_sharp_panel_device = {
3581 .name = "lcdc_sharp_wvga",
3582 .id = 0,
3583 .dev = {
3584 .platform_data = &lcdc_sharp_panel_data,
3585 }
3586};
3587
3588static struct msm_gpio dtv_panel_irq_gpios[] = {
3589 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
3590 "hdmi_int" },
3591};
3592
3593static struct msm_gpio dtv_panel_gpios[] = {
3594 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
3595 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
3596 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
3597 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
3598 { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
3599 { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
3600 { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
3601 { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
3602 { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
3603 { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
3604 { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
3605 { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
3606 { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
3607 { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
3608 { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
3609 { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
3610 { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
3611 { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
3612 { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
3613 { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
3614 { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
3615 { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
3616 { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
3617 { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
3618 { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
3619 { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
3620 { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
3621 { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
3622 { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
3623 { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
3624 { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
3625 { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
3626};
3627
3628
3629#ifdef HDMI_RESET
3630static unsigned dtv_reset_gpio =
3631 GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3632#endif
3633
Justin Paupore3f40f342011-08-10 18:52:16 -07003634static struct regulator_bulk_data hdmi_core_regs[] = {
3635 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3636};
3637
3638static struct regulator_bulk_data hdmi_comm_regs[] = {
3639 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3640 { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 },
3641};
3642
3643static struct regulator_bulk_data hdmi_cec_regs[] = {
3644 { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 },
3645};
3646
3647static int __init hdmi_init_regs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003648{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003649 int rc;
3650
Justin Paupore3f40f342011-08-10 18:52:16 -07003651 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs),
3652 hdmi_core_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003653
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003654 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003655 pr_err("%s: could not get %s regulators: %d\n",
3656 __func__, "core", rc);
3657 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003658 }
3659
Justin Paupore3f40f342011-08-10 18:52:16 -07003660 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs),
3661 hdmi_core_regs);
3662
3663 if (rc) {
3664 pr_err("%s: could not set %s voltages: %d\n",
3665 __func__, "core", rc);
3666 goto free_core;
3667 }
3668
3669 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs),
3670 hdmi_comm_regs);
3671
3672 if (rc) {
3673 pr_err("%s: could not get %s regulators: %d\n",
3674 __func__, "comm", rc);
3675 goto free_core;
3676 }
3677
3678 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs),
3679 hdmi_comm_regs);
3680
3681 if (rc) {
3682 pr_err("%s: could not set %s voltages: %d\n",
3683 __func__, "comm", rc);
3684 goto free_comm;
3685 }
3686
3687 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs),
3688 hdmi_cec_regs);
3689
3690 if (rc) {
3691 pr_err("%s: could not get %s regulators: %d\n",
3692 __func__, "cec", rc);
3693 goto free_comm;
3694 }
3695
3696 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs),
3697 hdmi_cec_regs);
3698
3699 if (rc) {
3700 pr_err("%s: could not set %s voltages: %d\n",
3701 __func__, "cec", rc);
3702 goto free_cec;
3703 }
3704
3705 return 0;
3706
3707free_cec:
3708 regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs);
3709free_comm:
3710 regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs);
3711free_core:
3712 regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs);
3713out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003714 return rc;
3715}
3716
Justin Paupore3f40f342011-08-10 18:52:16 -07003717static int hdmi_init_irq(void)
3718{
3719 int rc = msm_gpios_enable(dtv_panel_irq_gpios,
3720 ARRAY_SIZE(dtv_panel_irq_gpios));
3721 if (rc < 0) {
3722 pr_err("%s: gpio enable failed: %d\n", __func__, rc);
3723 return rc;
3724 }
3725 pr_info("%s\n", __func__);
3726
3727 return 0;
3728}
3729
3730static int hdmi_enable_5v(int on)
3731{
3732 int pmic_gpio_hdmi_5v_en ;
3733
3734 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
3735 machine_is_msm7x30_fluid())
3736 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
3737 else
3738 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
3739
3740 pr_info("%s: %d\n", __func__, on);
3741 if (on) {
3742 int rc;
3743 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
3744 "hdmi_5V_en");
3745 if (rc) {
3746 pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
3747 __func__);
3748 return rc;
3749 }
3750 gpio_set_value_cansleep(
3751 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
3752 } else {
3753 gpio_set_value_cansleep(
3754 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
3755 gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
3756 }
3757 return 0;
3758}
3759
3760static int hdmi_comm_power(int on, int show)
3761{
3762 if (show)
3763 pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
3764 return on ?
3765 regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs),
3766 hdmi_comm_regs) :
3767 regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs),
3768 hdmi_comm_regs);
3769}
3770
3771static int hdmi_core_power(int on, int show)
3772{
3773 if (show)
3774 pr_info("%s: %d <LDO8>\n", __func__, on);
3775 return on ?
3776 regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs),
3777 hdmi_core_regs) :
3778 regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs),
3779 hdmi_core_regs);
3780}
3781
3782static int hdmi_cec_power(int on)
3783{
3784 pr_info("%s: %d <LDO17>\n", __func__, on);
3785 return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs),
3786 hdmi_cec_regs) :
3787 regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs),
3788 hdmi_cec_regs);
3789}
3790
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003791#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
3792/* there is an i2c address conflict between adv7520 and bma150 sensor after
3793 * power up on fluid. As a solution, the default address of adv7520's packet
3794 * memory is changed as soon as possible
3795 */
3796static int __init fluid_i2c_address_fixup(void)
3797{
3798 unsigned char wBuff[16];
3799 unsigned char rBuff[16];
3800 struct i2c_msg msgs[3];
3801 int res;
3802 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003803 struct i2c_adapter *adapter;
3804
3805 if (machine_is_msm7x30_fluid()) {
3806 adapter = i2c_get_adapter(0);
3807 if (!adapter) {
3808 pr_err("%s: invalid i2c adapter\n", __func__);
3809 return PTR_ERR(adapter);
3810 }
3811
3812 /* turn on LDO8 */
Justin Paupore3f40f342011-08-10 18:52:16 -07003813 rc = hdmi_core_power(1, 0);
3814 if (rc) {
3815 pr_err("%s: could not enable hdmi core regs: %d",
3816 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003817 goto adapter_put;
3818 }
3819
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003820 /* change packet memory address to 0x74 */
3821 wBuff[0] = 0x45;
3822 wBuff[1] = 0x74;
3823
3824 msgs[0].addr = ADV7520_I2C_ADDR;
3825 msgs[0].flags = 0;
3826 msgs[0].buf = (unsigned char *) wBuff;
3827 msgs[0].len = 2;
3828
3829 res = i2c_transfer(adapter, msgs, 1);
3830 if (res != 1) {
3831 pr_err("%s: error writing adv7520\n", __func__);
3832 goto ldo8_disable;
3833 }
3834
3835 /* powerdown adv7520 using bit 6 */
3836 /* i2c read first */
3837 wBuff[0] = 0x41;
3838
3839 msgs[0].addr = ADV7520_I2C_ADDR;
3840 msgs[0].flags = 0;
3841 msgs[0].buf = (unsigned char *) wBuff;
3842 msgs[0].len = 1;
3843
3844 msgs[1].addr = ADV7520_I2C_ADDR;
3845 msgs[1].flags = I2C_M_RD;
3846 msgs[1].buf = rBuff;
3847 msgs[1].len = 1;
3848 res = i2c_transfer(adapter, msgs, 2);
3849 if (res != 2) {
3850 pr_err("%s: error reading adv7520\n", __func__);
3851 goto ldo8_disable;
3852 }
3853
3854 /* i2c write back */
3855 wBuff[0] = 0x41;
3856 wBuff[1] = rBuff[0] | 0x40;
3857
3858 msgs[0].addr = ADV7520_I2C_ADDR;
3859 msgs[0].flags = 0;
3860 msgs[0].buf = (unsigned char *) wBuff;
3861 msgs[0].len = 2;
3862
3863 res = i2c_transfer(adapter, msgs, 1);
3864 if (res != 1) {
3865 pr_err("%s: error writing adv7520\n", __func__);
3866 goto ldo8_disable;
3867 }
3868
3869 /* for successful fixup, we release the i2c adapter */
3870 /* but leave ldo8 on so that the adv7520 is not repowered */
3871 i2c_put_adapter(adapter);
3872 pr_info("%s: fluid i2c address conflict resolved\n", __func__);
3873 }
3874 return 0;
3875
3876ldo8_disable:
Justin Paupore3f40f342011-08-10 18:52:16 -07003877 hdmi_core_power(0, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003878adapter_put:
3879 i2c_put_adapter(adapter);
3880 return rc;
3881}
3882fs_initcall_sync(fluid_i2c_address_fixup);
3883#endif
3884
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003885static bool hdmi_check_hdcp_hw_support(void)
3886{
3887 if (machine_is_msm7x30_fluid())
3888 return false;
3889 else
3890 return true;
3891}
3892
3893static int dtv_panel_power(int on)
3894{
3895 int flag_on = !!on;
3896 static int dtv_power_save_on;
3897 int rc;
3898
3899 if (dtv_power_save_on == flag_on)
3900 return 0;
3901
3902 dtv_power_save_on = flag_on;
3903 pr_info("%s: %d\n", __func__, on);
3904
3905#ifdef HDMI_RESET
3906 if (on) {
3907 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
3908 rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
3909 if (rc) {
3910 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
3911 __func__, dtv_reset_gpio, rc);
3912 return rc;
3913 }
3914
3915 /* bring reset line low to hold reset*/
3916 gpio_set_value(37, 0);
3917 }
3918#endif
3919
3920 if (on) {
3921 rc = msm_gpios_enable(dtv_panel_gpios,
3922 ARRAY_SIZE(dtv_panel_gpios));
3923 if (rc < 0) {
3924 printk(KERN_ERR "%s: gpio enable failed: %d\n",
3925 __func__, rc);
3926 return rc;
3927 }
3928 } else {
3929 rc = msm_gpios_disable(dtv_panel_gpios,
3930 ARRAY_SIZE(dtv_panel_gpios));
3931 if (rc < 0) {
3932 printk(KERN_ERR "%s: gpio disable failed: %d\n",
3933 __func__, rc);
3934 return rc;
3935 }
3936 }
3937
3938 mdelay(5); /* ensure power is stable */
3939
3940#ifdef HDMI_RESET
3941 if (on) {
3942 gpio_set_value(37, 1); /* bring reset line high */
3943 mdelay(10); /* 10 msec before IO can be accessed */
3944 }
3945#endif
3946
3947 return rc;
3948}
3949
3950static struct lcdc_platform_data dtv_pdata = {
3951 .lcdc_power_save = dtv_panel_power,
3952};
3953
3954static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3955 .inject_rx_on_wakeup = 1,
3956 .rx_to_inject = 0xFD,
3957};
3958
3959static struct resource msm_fb_resources[] = {
3960 {
3961 .flags = IORESOURCE_DMA,
3962 }
3963};
3964
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08003965#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
3966static struct resource msm_v4l2_video_overlay_resources[] = {
3967 {
3968 .flags = IORESOURCE_DMA,
3969 }
3970};
3971#endif
3972
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003973static int msm_fb_detect_panel(const char *name)
3974{
3975 if (machine_is_msm7x30_fluid()) {
3976 if (!strcmp(name, "lcdc_sharp_wvga_pt"))
3977 return 0;
3978 } else {
3979 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
3980 return -EPERM;
3981 else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20))
3982 return 0;
3983 else if (!strcmp(name, "mddi_orise"))
3984 return -EPERM;
3985 else if (!strcmp(name, "mddi_quickvx"))
3986 return -EPERM;
3987 }
3988 return -ENODEV;
3989}
3990
3991static struct msm_fb_platform_data msm_fb_pdata = {
3992 .detect_client = msm_fb_detect_panel,
3993 .mddi_prescan = 1,
3994};
3995
3996static struct platform_device msm_fb_device = {
3997 .name = "msm_fb",
3998 .id = 0,
3999 .num_resources = ARRAY_SIZE(msm_fb_resources),
4000 .resource = msm_fb_resources,
4001 .dev = {
4002 .platform_data = &msm_fb_pdata,
4003 }
4004};
4005
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08004006#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
4007
4008static struct platform_device msm_v4l2_video_overlay_device = {
4009 .name = "msm_v4l2_overlay_pd",
4010 .id = 0,
4011 .num_resources = ARRAY_SIZE(msm_v4l2_video_overlay_resources),
4012 .resource = msm_v4l2_video_overlay_resources,
4013};
4014#endif
4015
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004016static struct platform_device msm_migrate_pages_device = {
4017 .name = "msm_migrate_pages",
4018 .id = -1,
4019};
4020
4021static struct android_pmem_platform_data android_pmem_adsp_pdata = {
4022 .name = "pmem_adsp",
4023 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4024 .cached = 0,
4025 .memory_type = MEMTYPE_EBI0,
4026};
4027
4028static struct android_pmem_platform_data android_pmem_audio_pdata = {
4029 .name = "pmem_audio",
4030 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4031 .cached = 0,
4032 .memory_type = MEMTYPE_EBI0,
4033};
4034
4035static struct platform_device android_pmem_adsp_device = {
4036 .name = "android_pmem",
4037 .id = 2,
4038 .dev = { .platform_data = &android_pmem_adsp_pdata },
4039};
4040
4041static struct platform_device android_pmem_audio_device = {
4042 .name = "android_pmem",
4043 .id = 4,
4044 .dev = { .platform_data = &android_pmem_audio_pdata },
4045};
4046
4047#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4048 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
4049 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4050 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4051
4052#define QCE_SIZE 0x10000
4053#define QCE_0_BASE 0xA8400000
4054
4055#define QCE_HW_KEY_SUPPORT 1
4056#define QCE_SHA_HMAC_SUPPORT 0
4057#define QCE_SHARE_CE_RESOURCE 0
4058#define QCE_CE_SHARED 0
4059
4060static struct resource qcrypto_resources[] = {
4061 [0] = {
4062 .start = QCE_0_BASE,
4063 .end = QCE_0_BASE + QCE_SIZE - 1,
4064 .flags = IORESOURCE_MEM,
4065 },
4066 [1] = {
4067 .name = "crypto_channels",
4068 .start = DMOV_CE_IN_CHAN,
4069 .end = DMOV_CE_OUT_CHAN,
4070 .flags = IORESOURCE_DMA,
4071 },
4072 [2] = {
4073 .name = "crypto_crci_in",
4074 .start = DMOV_CE_IN_CRCI,
4075 .end = DMOV_CE_IN_CRCI,
4076 .flags = IORESOURCE_DMA,
4077 },
4078 [3] = {
4079 .name = "crypto_crci_out",
4080 .start = DMOV_CE_OUT_CRCI,
4081 .end = DMOV_CE_OUT_CRCI,
4082 .flags = IORESOURCE_DMA,
4083 },
4084 [4] = {
4085 .name = "crypto_crci_hash",
4086 .start = DMOV_CE_HASH_CRCI,
4087 .end = DMOV_CE_HASH_CRCI,
4088 .flags = IORESOURCE_DMA,
4089 },
4090};
4091
4092static struct resource qcedev_resources[] = {
4093 [0] = {
4094 .start = QCE_0_BASE,
4095 .end = QCE_0_BASE + QCE_SIZE - 1,
4096 .flags = IORESOURCE_MEM,
4097 },
4098 [1] = {
4099 .name = "crypto_channels",
4100 .start = DMOV_CE_IN_CHAN,
4101 .end = DMOV_CE_OUT_CHAN,
4102 .flags = IORESOURCE_DMA,
4103 },
4104 [2] = {
4105 .name = "crypto_crci_in",
4106 .start = DMOV_CE_IN_CRCI,
4107 .end = DMOV_CE_IN_CRCI,
4108 .flags = IORESOURCE_DMA,
4109 },
4110 [3] = {
4111 .name = "crypto_crci_out",
4112 .start = DMOV_CE_OUT_CRCI,
4113 .end = DMOV_CE_OUT_CRCI,
4114 .flags = IORESOURCE_DMA,
4115 },
4116 [4] = {
4117 .name = "crypto_crci_hash",
4118 .start = DMOV_CE_HASH_CRCI,
4119 .end = DMOV_CE_HASH_CRCI,
4120 .flags = IORESOURCE_DMA,
4121 },
4122};
4123
4124#endif
4125
4126#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4127 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
4128
4129static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
4130 .ce_shared = QCE_CE_SHARED,
4131 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4132 .hw_key_support = QCE_HW_KEY_SUPPORT,
4133 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004134 /* Bus Scaling declaration*/
4135 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004136};
4137
4138static struct platform_device qcrypto_device = {
4139 .name = "qcrypto",
4140 .id = 0,
4141 .num_resources = ARRAY_SIZE(qcrypto_resources),
4142 .resource = qcrypto_resources,
4143 .dev = {
4144 .coherent_dma_mask = DMA_BIT_MASK(32),
4145 .platform_data = &qcrypto_ce_hw_suppport,
4146 },
4147};
4148#endif
4149
4150#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4151 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4152
4153static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
4154 .ce_shared = QCE_CE_SHARED,
4155 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4156 .hw_key_support = QCE_HW_KEY_SUPPORT,
4157 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004158 /* Bus Scaling declaration*/
4159 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004160};
4161static struct platform_device qcedev_device = {
4162 .name = "qce",
4163 .id = 0,
4164 .num_resources = ARRAY_SIZE(qcedev_resources),
4165 .resource = qcedev_resources,
4166 .dev = {
4167 .coherent_dma_mask = DMA_BIT_MASK(32),
4168 .platform_data = &qcedev_ce_hw_suppport,
4169 },
4170};
4171#endif
4172
4173static int mddi_toshiba_pmic_bl(int level)
4174{
4175 int ret = -EPERM;
4176
4177 ret = pmic_set_led_intensity(LED_LCD, level);
4178
4179 if (ret)
4180 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
4181 __func__);
4182 return ret;
4183}
4184
4185static struct msm_panel_common_pdata mddi_toshiba_pdata = {
4186 .pmic_backlight = mddi_toshiba_pmic_bl,
4187};
4188
4189static struct platform_device mddi_toshiba_device = {
4190 .name = "mddi_toshiba",
4191 .id = 0,
4192 .dev = {
4193 .platform_data = &mddi_toshiba_pdata,
4194 }
4195};
4196
4197static unsigned wega_reset_gpio =
4198 GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4199
4200static struct msm_gpio fluid_vee_reset_gpio[] = {
4201 { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
4202};
4203
4204static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1;
4205static unsigned char quickvx_ldo_enabled;
4206
4207static unsigned quickvx_vlp_gpio =
4208 GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4209
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304210static struct pm8xxx_gpio_init_info pmic_quickvx_clk_gpio = {
4211 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_QUICKVX_CLK),
4212 {
4213 .direction = PM_GPIO_DIR_OUT,
4214 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
4215 .output_value = 1,
4216 .pull = PM_GPIO_PULL_NO,
4217 .vin_sel = PM8058_GPIO_VIN_S3,
4218 .out_strength = PM_GPIO_STRENGTH_HIGH,
4219 .function = PM_GPIO_FUNC_2,
4220 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004221};
4222
Justin Paupore3f40f342011-08-10 18:52:16 -07004223static struct regulator *mddi_ldo20;
4224static struct regulator *mddi_ldo12;
4225static struct regulator *mddi_ldo16;
4226static struct regulator *mddi_ldo6;
4227static struct regulator *mddi_lcd;
4228
4229static int display_common_init(void)
4230{
4231 struct regulator_bulk_data regs[5] = {
4232 { .supply = "ldo20", /* voltage set in display_common_power */},
4233 { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 },
4234 { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 },
4235 { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 },
4236 { .supply = NULL, /* mddi_lcd, initialized below */ },
4237 };
4238
4239 int rc = 0;
4240
4241 if (machine_is_msm7x30_fluid()) {
4242 /* lcd: LDO8 @1.8V */
4243 regs[4].supply = "ldo8";
4244 regs[4].min_uV = 1800000;
4245 regs[4].max_uV = 1800000;
4246 } else {
4247 /* lcd: LDO15 @3.1V */
4248 regs[4].supply = "ldo15";
4249 regs[4].min_uV = 3100000;
4250 regs[4].max_uV = 3100000;
4251 }
4252
4253 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4254 if (rc) {
4255 pr_err("%s: regulator_bulk_get failed: %d\n",
4256 __func__, rc);
4257 goto bail;
4258 }
4259
4260 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4261 if (rc) {
4262 pr_err("%s: regulator_bulk_set_voltage failed: %d\n",
4263 __func__, rc);
4264 goto put_regs;
4265 }
4266
4267 mddi_ldo20 = regs[0].consumer;
4268 mddi_ldo12 = regs[1].consumer;
4269 mddi_ldo6 = regs[2].consumer;
4270 mddi_ldo16 = regs[3].consumer;
4271 mddi_lcd = regs[4].consumer;
4272
4273 return rc;
4274
4275put_regs:
4276 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4277bail:
4278 return rc;
4279}
4280
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004281static int display_common_power(int on)
4282{
4283 int rc = 0, flag_on = !!on;
4284 static int display_common_power_save_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004285 static bool display_regs_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004286
4287 if (display_common_power_save_on == flag_on)
4288 return 0;
4289
4290 display_common_power_save_on = flag_on;
4291
Justin Paupore3f40f342011-08-10 18:52:16 -07004292 if (unlikely(!display_regs_initialized)) {
4293 rc = display_common_init();
4294 if (rc) {
4295 pr_err("%s: regulator init failed: %d\n",
4296 __func__, rc);
4297 return rc;
4298 }
4299 display_regs_initialized = true;
4300 }
4301
4302
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004303 if (on) {
4304 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
4305 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
4306 if (rc) {
4307 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4308 __func__, wega_reset_gpio, rc);
4309 return rc;
4310 }
4311
4312 /* bring reset line low to hold reset*/
4313 gpio_set_value(180, 0);
4314
4315 if (quickvx_mddi_client) {
4316 /* QuickVX chip -- VLP pin -- gpio 97 */
4317 rc = gpio_tlmm_config(quickvx_vlp_gpio,
4318 GPIO_CFG_ENABLE);
4319 if (rc) {
4320 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4321 __func__, quickvx_vlp_gpio, rc);
4322 return rc;
4323 }
4324
4325 /* bring QuickVX VLP line low */
4326 gpio_set_value(97, 0);
4327
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304328 rc = pm8xxx_gpio_config(pmic_quickvx_clk_gpio.gpio,
4329 &pmic_quickvx_clk_gpio.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004330 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304331 pr_err("%s: pm8xxx_gpio_config(%#x)=%d\n",
4332 __func__, pmic_quickvx_clk_gpio.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004333 rc);
4334 return rc;
4335 }
4336
4337 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4338 PMIC_GPIO_QUICKVX_CLK), 0);
4339 }
4340 }
4341
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004342 if (quickvx_mddi_client)
Jeevan Shriram9624b742012-08-08 11:19:49 +05304343 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1800000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004344 else
Justin Paupore3f40f342011-08-10 18:52:16 -07004345 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000);
4346
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004347 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004348 pr_err("%s: could not set voltage for ldo20: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004349 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07004350 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004351 }
4352
4353 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004354 rc = regulator_enable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004355 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004356 pr_err("%s: LDO20 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004357 __func__, rc);
4358 return rc;
4359 }
4360
Justin Paupore3f40f342011-08-10 18:52:16 -07004361 rc = regulator_enable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004362 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004363 pr_err("%s: LDO12 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004364 __func__, rc);
4365 return rc;
4366 }
4367
4368 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004369 rc = regulator_enable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004370 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004371 pr_err("%s: LDO16 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004372 __func__, rc);
4373 return rc;
4374 }
4375 }
4376
Justin Paupore3f40f342011-08-10 18:52:16 -07004377 if (quickvx_ldo_enabled) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004378 /* Disable LDO6 during display ON */
Justin Paupore3f40f342011-08-10 18:52:16 -07004379 rc = regulator_disable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004380 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004381 pr_err("%s: LDO6 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004382 __func__, rc);
4383 return rc;
4384 }
4385 quickvx_ldo_enabled = 0;
4386 }
4387
Justin Paupore3f40f342011-08-10 18:52:16 -07004388 rc = regulator_enable(mddi_lcd);
4389 if (rc) {
4390 pr_err("%s: LCD regulator enable failed (%d)\n",
4391 __func__, rc);
4392 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004393 }
4394
4395 mdelay(5); /* ensure power is stable */
4396
4397 if (machine_is_msm7x30_fluid()) {
4398 rc = msm_gpios_request_enable(fluid_vee_reset_gpio,
4399 ARRAY_SIZE(fluid_vee_reset_gpio));
4400 if (rc)
4401 pr_err("%s gpio_request_enable failed rc=%d\n",
4402 __func__, rc);
4403 else {
4404 /* assert vee reset_n */
4405 gpio_set_value(20, 1);
4406 gpio_set_value(20, 0);
4407 mdelay(1);
4408 gpio_set_value(20, 1);
4409 }
4410 }
4411
4412 gpio_set_value(180, 1); /* bring reset line high */
4413 mdelay(10); /* 10 msec before IO can be accessed */
4414
4415 if (quickvx_mddi_client) {
4416 gpio_set_value(97, 1);
4417 msleep(2);
4418 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4419 PMIC_GPIO_QUICKVX_CLK), 1);
4420 msleep(2);
4421 }
4422
4423 rc = pmapp_display_clock_config(1);
4424 if (rc) {
4425 pr_err("%s pmapp_display_clock_config rc=%d\n",
4426 __func__, rc);
4427 return rc;
4428 }
4429
4430 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004431 rc = regulator_disable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004432 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004433 pr_err("%s: LDO20 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004434 __func__, rc);
4435 return rc;
4436 }
4437
4438
4439 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004440 rc = regulator_disable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004441 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004442 pr_err("%s: LDO16 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004443 __func__, rc);
4444 return rc;
4445 }
4446 }
4447
4448 if (quickvx_mddi_client && !quickvx_ldo_enabled) {
4449 /* Enable LDO6 during display OFF for
4450 Quicklogic chip to sleep with data retention */
Justin Paupore3f40f342011-08-10 18:52:16 -07004451 rc = regulator_enable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004452 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004453 pr_err("%s: LDO6 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004454 __func__, rc);
4455 return rc;
4456 }
4457 quickvx_ldo_enabled = 1;
4458 }
4459
4460 gpio_set_value(180, 0); /* bring reset line low */
4461
4462 if (quickvx_mddi_client) {
4463 gpio_set_value(97, 0);
4464 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4465 PMIC_GPIO_QUICKVX_CLK), 0);
4466 }
4467
Justin Paupore3f40f342011-08-10 18:52:16 -07004468 rc = regulator_disable(mddi_lcd);
4469 if (rc) {
4470 pr_err("%s: LCD regulator disable failed (%d)\n",
4471 __func__, rc);
4472 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004473 }
4474
4475 mdelay(5); /* ensure power is stable */
4476
Justin Paupore3f40f342011-08-10 18:52:16 -07004477 rc = regulator_disable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004478 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004479 pr_err("%s: LDO12 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004480 __func__, rc);
4481 return rc;
4482 }
4483
4484 if (machine_is_msm7x30_fluid()) {
4485 msm_gpios_disable_free(fluid_vee_reset_gpio,
4486 ARRAY_SIZE(fluid_vee_reset_gpio));
4487 }
4488
4489 rc = pmapp_display_clock_config(0);
4490 if (rc) {
4491 pr_err("%s pmapp_display_clock_config rc=%d\n",
4492 __func__, rc);
4493 return rc;
4494 }
4495 }
4496
4497 return rc;
4498}
4499
4500static int msm_fb_mddi_sel_clk(u32 *clk_rate)
4501{
4502 *clk_rate *= 2;
4503 return 0;
4504}
4505
4506static int msm_fb_mddi_client_power(u32 client_id)
4507{
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304508 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004509 printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
4510 /* Check if it is Quicklogic client */
4511 if (client_id == 0xc5835800) {
4512 printk(KERN_NOTICE "\n Quicklogic MDDI client");
4513 other_mddi_client = 0;
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304514 if (IS_ERR(mddi_ldo16)) {
4515 rc = PTR_ERR(mddi_ldo16);
4516 pr_err("%s: gp10 vreg get failed (%d)\n", __func__, rc);
4517 return rc;
4518 }
4519 rc = regulator_disable(mddi_ldo16);
4520 if (rc) {
4521 pr_err("%s: LDO16 vreg enable failed (%d)\n",
4522 __func__, rc);
4523 return rc;
4524 }
4525
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004526 } else {
4527 printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
4528 quickvx_mddi_client = 0;
4529 gpio_set_value(97, 0);
4530 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4531 PMIC_GPIO_QUICKVX_CLK), 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004532 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004533
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004534 return 0;
4535}
4536
4537static struct mddi_platform_data mddi_pdata = {
4538 .mddi_power_save = display_common_power,
4539 .mddi_sel_clk = msm_fb_mddi_sel_clk,
4540 .mddi_client_power = msm_fb_mddi_client_power,
4541};
4542
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004543static struct msm_panel_common_pdata mdp_pdata = {
4544 .hw_revision_addr = 0xac001270,
4545 .gpio = 30,
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07004546 .mdp_max_clk = 192000000,
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07004547 .mdp_rev = MDP_REV_40,
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05304548 .mem_hid = MEMTYPE_EBI0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004549};
4550
4551static int lcd_panel_spi_gpio_num[] = {
4552 45, /* spi_clk */
4553 46, /* spi_cs */
4554 47, /* spi_mosi */
4555 48, /* spi_miso */
4556 };
4557
4558static struct msm_gpio lcd_panel_gpios[] = {
4559/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
4560 * input. if there is a hardware revision; we should reassign this GPIO to a
4561 * new open line; and removing it will just ensure that this will be missed in
4562 * the future.
4563 { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
4564 */
4565 { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
4566 { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
4567 { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
4568 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4569 { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
4570 { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
4571 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4572#ifndef CONFIG_SPI_QSD
4573 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
4574 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
4575 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
4576 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
4577#endif
4578 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4579 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4580 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4581 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4582 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4583 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4584 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4585 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4586 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4587 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4588 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4589 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4590 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4591 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4592 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4593 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4594 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4595 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4596 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4597 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4598};
4599
4600static struct msm_gpio lcd_sharp_panel_gpios[] = {
4601 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4602 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4603 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4604 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4605 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4606 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4607 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4608 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4609 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4610 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4611 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4612 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4613 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4614 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4615 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4616 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4617 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4618 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4619 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4620 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4621 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4622 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4623};
4624
4625static int lcdc_toshiba_panel_power(int on)
4626{
4627 int rc, i;
4628 struct msm_gpio *gp;
4629
4630 rc = display_common_power(on);
4631 if (rc < 0) {
4632 printk(KERN_ERR "%s display_common_power failed: %d\n",
4633 __func__, rc);
4634 return rc;
4635 }
4636
4637 if (on) {
4638 rc = msm_gpios_enable(lcd_panel_gpios,
4639 ARRAY_SIZE(lcd_panel_gpios));
4640 if (rc < 0) {
4641 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4642 __func__, rc);
4643 }
4644 } else { /* off */
4645 gp = lcd_panel_gpios;
4646 for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
4647 /* ouput low */
4648 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4649 gp++;
4650 }
4651 }
4652
4653 return rc;
4654}
4655
4656static int lcdc_sharp_panel_power(int on)
4657{
4658 int rc, i;
4659 struct msm_gpio *gp;
4660
4661 rc = display_common_power(on);
4662 if (rc < 0) {
4663 printk(KERN_ERR "%s display_common_power failed: %d\n",
4664 __func__, rc);
4665 return rc;
4666 }
4667
4668 if (on) {
4669 rc = msm_gpios_enable(lcd_sharp_panel_gpios,
4670 ARRAY_SIZE(lcd_sharp_panel_gpios));
4671 if (rc < 0) {
4672 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4673 __func__, rc);
4674 }
4675 } else { /* off */
4676 gp = lcd_sharp_panel_gpios;
4677 for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) {
4678 /* ouput low */
4679 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4680 gp++;
4681 }
4682 }
4683
4684 return rc;
4685}
4686
4687static int lcdc_panel_power(int on)
4688{
4689 int flag_on = !!on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004690 static int lcdc_power_save_on, lcdc_power_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004691
4692 if (lcdc_power_save_on == flag_on)
4693 return 0;
4694
4695 lcdc_power_save_on = flag_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004696
4697 if (unlikely(!lcdc_power_initialized)) {
4698 quickvx_mddi_client = 0;
4699 display_common_init();
4700 lcdc_power_initialized = 1;
4701 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004702
4703 if (machine_is_msm7x30_fluid())
4704 return lcdc_sharp_panel_power(on);
4705 else
4706 return lcdc_toshiba_panel_power(on);
4707}
4708
4709static struct lcdc_platform_data lcdc_pdata = {
4710 .lcdc_power_save = lcdc_panel_power,
4711};
4712
Justin Paupore3f40f342011-08-10 18:52:16 -07004713static struct regulator *atv_s4, *atv_ldo9;
4714
4715static int __init atv_dac_power_init(void)
4716{
4717 int rc;
4718 struct regulator_bulk_data regs[] = {
4719 { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 },
4720 { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 },
4721 };
4722
4723 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4724
4725 if (rc) {
4726 pr_err("%s: could not get regulators: %d\n", __func__, rc);
4727 goto bail;
4728 }
4729
4730 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4731
4732 if (rc) {
4733 pr_err("%s: could not set voltages: %d\n", __func__, rc);
4734 goto reg_free;
4735 }
4736
4737 atv_s4 = regs[0].consumer;
4738 atv_ldo9 = regs[1].consumer;
4739
4740reg_free:
4741 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4742bail:
4743 return rc;
4744}
4745
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004746static int atv_dac_power(int on)
4747{
4748 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004749
4750 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004751 rc = regulator_enable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004752 if (rc) {
4753 pr_err("%s: s4 vreg enable failed (%d)\n",
4754 __func__, rc);
4755 return rc;
4756 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004757 rc = regulator_enable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004758 if (rc) {
4759 pr_err("%s: ldo9 vreg enable failed (%d)\n",
4760 __func__, rc);
4761 return rc;
4762 }
4763 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004764 rc = regulator_disable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004765 if (rc) {
4766 pr_err("%s: ldo9 vreg disable failed (%d)\n",
4767 __func__, rc);
4768 return rc;
4769 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004770 rc = regulator_disable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004771 if (rc) {
4772 pr_err("%s: s4 vreg disable failed (%d)\n",
4773 __func__, rc);
4774 return rc;
4775 }
4776 }
4777 return rc;
4778}
4779
4780static struct tvenc_platform_data atv_pdata = {
4781 .poll = 1,
4782 .pm_vid_en = atv_dac_power,
4783};
4784
4785static void __init msm_fb_add_devices(void)
4786{
4787 msm_fb_register_device("mdp", &mdp_pdata);
4788 msm_fb_register_device("pmdh", &mddi_pdata);
4789 msm_fb_register_device("lcdc", &lcdc_pdata);
4790 msm_fb_register_device("dtv", &dtv_pdata);
4791 msm_fb_register_device("tvenc", &atv_pdata);
4792#ifdef CONFIG_FB_MSM_TVOUT
4793 msm_fb_register_device("tvout_device", NULL);
4794#endif
4795}
4796
4797static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
4798 .gpio_num = lcd_panel_spi_gpio_num,
4799};
4800
4801static struct platform_device lcdc_toshiba_panel_device = {
4802 .name = "lcdc_toshiba_wvga",
4803 .id = 0,
4804 .dev = {
4805 .platform_data = &lcdc_toshiba_panel_data,
4806 }
4807};
4808
4809#if defined(CONFIG_MARIMBA_CORE) && \
4810 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4811static struct platform_device msm_bt_power_device = {
4812 .name = "bt_power",
4813 .id = -1
4814};
4815
4816enum {
4817 BT_RFR,
4818 BT_CTS,
4819 BT_RX,
4820 BT_TX,
4821};
4822
4823static struct msm_gpio bt_config_power_on[] = {
4824 { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4825 "UART1DM_RFR" },
4826 { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4827 "UART1DM_CTS" },
4828 { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4829 "UART1DM_Rx" },
4830 { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4831 "UART1DM_Tx" }
4832};
4833
4834static struct msm_gpio bt_config_power_off[] = {
4835 { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4836 "UART1DM_RFR" },
4837 { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4838 "UART1DM_CTS" },
4839 { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4840 "UART1DM_Rx" },
4841 { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4842 "UART1DM_Tx" }
4843};
4844
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004845static u8 bahama_version;
4846
Justin Paupore3f40f342011-08-10 18:52:16 -07004847static struct regulator_bulk_data regs_bt_marimba[] = {
4848 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4849 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
4850 { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304851 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004852};
4853
4854static struct regulator_bulk_data regs_bt_bahama_v1[] = {
4855 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4856 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
4857 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304858 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004859};
4860
4861static struct regulator_bulk_data regs_bt_bahama_v2[] = {
4862 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4863 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304864 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004865};
4866
4867static struct regulator_bulk_data *regs_bt;
4868static int regs_bt_count;
4869
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004870static int marimba_bt(int on)
4871{
4872 int rc;
4873 int i;
4874 struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
4875
4876 struct marimba_config_register {
4877 u8 reg;
4878 u8 value;
4879 u8 mask;
4880 };
4881
4882 struct marimba_variant_register {
4883 const size_t size;
4884 const struct marimba_config_register *set;
4885 };
4886
4887 const struct marimba_config_register *p;
4888
4889 u8 version;
4890
4891 const struct marimba_config_register v10_bt_on[] = {
4892 { 0xE5, 0x0B, 0x0F },
4893 { 0x05, 0x02, 0x07 },
4894 { 0x06, 0x88, 0xFF },
4895 { 0xE7, 0x21, 0x21 },
4896 { 0xE3, 0x38, 0xFF },
4897 { 0xE4, 0x06, 0xFF },
4898 };
4899
4900 const struct marimba_config_register v10_bt_off[] = {
4901 { 0xE5, 0x0B, 0x0F },
4902 { 0x05, 0x08, 0x0F },
4903 { 0x06, 0x88, 0xFF },
4904 { 0xE7, 0x00, 0x21 },
4905 { 0xE3, 0x00, 0xFF },
4906 { 0xE4, 0x00, 0xFF },
4907 };
4908
4909 const struct marimba_config_register v201_bt_on[] = {
4910 { 0x05, 0x08, 0x07 },
4911 { 0x06, 0x88, 0xFF },
4912 { 0xE7, 0x21, 0x21 },
4913 { 0xE3, 0x38, 0xFF },
4914 { 0xE4, 0x06, 0xFF },
4915 };
4916
4917 const struct marimba_config_register v201_bt_off[] = {
4918 { 0x05, 0x08, 0x07 },
4919 { 0x06, 0x88, 0xFF },
4920 { 0xE7, 0x00, 0x21 },
4921 { 0xE3, 0x00, 0xFF },
4922 { 0xE4, 0x00, 0xFF },
4923 };
4924
4925 const struct marimba_config_register v210_bt_on[] = {
4926 { 0xE9, 0x01, 0x01 },
4927 { 0x06, 0x88, 0xFF },
4928 { 0xE7, 0x21, 0x21 },
4929 { 0xE3, 0x38, 0xFF },
4930 { 0xE4, 0x06, 0xFF },
4931 };
4932
4933 const struct marimba_config_register v210_bt_off[] = {
4934 { 0x06, 0x88, 0xFF },
4935 { 0xE7, 0x00, 0x21 },
4936 { 0xE9, 0x00, 0x01 },
4937 { 0xE3, 0x00, 0xFF },
4938 { 0xE4, 0x00, 0xFF },
4939 };
4940
4941 const struct marimba_variant_register bt_marimba[2][4] = {
4942 {
4943 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4944 { 0, NULL },
4945 { ARRAY_SIZE(v201_bt_off), v201_bt_off },
4946 { ARRAY_SIZE(v210_bt_off), v210_bt_off }
4947 },
4948 {
4949 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4950 { 0, NULL },
4951 { ARRAY_SIZE(v201_bt_on), v201_bt_on },
4952 { ARRAY_SIZE(v210_bt_on), v210_bt_on }
4953 }
4954 };
4955
4956 on = on ? 1 : 0;
4957
4958 rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F);
4959 if (rc < 0) {
4960 printk(KERN_ERR
4961 "%s: version read failed: %d\n",
4962 __func__, rc);
4963 return rc;
4964 }
4965
4966 if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
4967 (bt_marimba[on][version].size == 0)) {
4968 printk(KERN_ERR
4969 "%s: unsupported version\n",
4970 __func__);
4971 return -EIO;
4972 }
4973
4974 p = bt_marimba[on][version].set;
4975
4976 printk(KERN_INFO "%s: found version %d\n", __func__, version);
4977
4978 for (i = 0; i < bt_marimba[on][version].size; i++) {
4979 u8 value = (p+i)->value;
4980 rc = marimba_write_bit_mask(&config,
4981 (p+i)->reg,
4982 &value,
4983 sizeof((p+i)->value),
4984 (p+i)->mask);
4985 if (rc < 0) {
4986 printk(KERN_ERR
4987 "%s: reg %d write failed: %d\n",
4988 __func__, (p+i)->reg, rc);
4989 return rc;
4990 }
4991 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
4992 __func__, (p+i)->reg,
4993 value, (p+i)->mask);
4994 }
4995 return 0;
4996}
4997
4998static int bahama_bt(int on)
4999{
5000 int rc;
5001 int i;
5002 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
5003
5004 struct bahama_variant_register {
5005 const size_t size;
5006 const struct bahama_config_register *set;
5007 };
5008
5009 const struct bahama_config_register *p;
5010
5011
5012 const struct bahama_config_register v10_bt_on[] = {
5013 { 0xE9, 0x00, 0xFF },
5014 { 0xF4, 0x80, 0xFF },
5015 { 0xF0, 0x06, 0xFF },
5016 { 0xE4, 0x00, 0xFF },
5017 { 0xE5, 0x00, 0x0F },
5018#ifdef CONFIG_WLAN
5019 { 0xE6, 0x38, 0x7F },
5020 { 0xE7, 0x06, 0xFF },
5021#endif
5022 { 0x11, 0x13, 0xFF },
5023 { 0xE9, 0x21, 0xFF },
5024 { 0x01, 0x0C, 0x1F },
5025 { 0x01, 0x08, 0x1F },
5026 };
5027
5028 const struct bahama_config_register v20_bt_on_fm_off[] = {
5029 { 0x11, 0x0C, 0xFF },
5030 { 0x13, 0x01, 0xFF },
5031 { 0xF4, 0x80, 0xFF },
5032 { 0xF0, 0x00, 0xFF },
5033 { 0xE9, 0x00, 0xFF },
5034#ifdef CONFIG_WLAN
5035 { 0x81, 0x00, 0xFF },
5036 { 0x82, 0x00, 0xFF },
5037 { 0xE6, 0x38, 0x7F },
5038 { 0xE7, 0x06, 0xFF },
5039#endif
5040 { 0xE9, 0x21, 0xFF }
5041 };
5042
5043 const struct bahama_config_register v20_bt_on_fm_on[] = {
5044 { 0x11, 0x0C, 0xFF },
5045 { 0x13, 0x01, 0xFF },
5046 { 0xF4, 0x86, 0xFF },
5047 { 0xF0, 0x06, 0xFF },
5048 { 0xE9, 0x00, 0xFF },
5049#ifdef CONFIG_WLAN
5050 { 0x81, 0x00, 0xFF },
5051 { 0x82, 0x00, 0xFF },
5052 { 0xE6, 0x38, 0x7F },
5053 { 0xE7, 0x06, 0xFF },
5054#endif
5055 { 0xE9, 0x21, 0xFF }
5056 };
5057
5058 const struct bahama_config_register v10_bt_off[] = {
5059 { 0xE9, 0x00, 0xFF },
5060 };
5061
5062 const struct bahama_config_register v20_bt_off_fm_off[] = {
5063 { 0xF4, 0x84, 0xFF },
5064 { 0xF0, 0x04, 0xFF },
5065 { 0xE9, 0x00, 0xFF }
5066 };
5067
5068 const struct bahama_config_register v20_bt_off_fm_on[] = {
5069 { 0xF4, 0x86, 0xFF },
5070 { 0xF0, 0x06, 0xFF },
5071 { 0xE9, 0x00, 0xFF }
5072 };
5073
5074 const struct bahama_variant_register bt_bahama[2][3] = {
5075 {
5076 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
5077 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
5078 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
5079 },
5080 {
5081 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
5082 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
5083 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
5084 }
5085 };
5086
5087 u8 offset = 0; /* index into bahama configs */
5088
5089 on = on ? 1 : 0;
5090
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005091
5092 if (bahama_version == VER_2_0) {
5093 if (marimba_get_fm_status(&config))
5094 offset = 0x01;
5095 }
5096
5097 p = bt_bahama[on][bahama_version + offset].set;
5098
5099 dev_info(&msm_bt_power_device.dev,
5100 "%s: found version %d\n", __func__, bahama_version);
5101
5102 for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
5103 u8 value = (p+i)->value;
5104 rc = marimba_write_bit_mask(&config,
5105 (p+i)->reg,
5106 &value,
5107 sizeof((p+i)->value),
5108 (p+i)->mask);
5109 if (rc < 0) {
5110 dev_err(&msm_bt_power_device.dev,
5111 "%s: reg %d write failed: %d\n",
5112 __func__, (p+i)->reg, rc);
5113 return rc;
5114 }
5115 dev_info(&msm_bt_power_device.dev,
5116 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
5117 __func__, (p+i)->reg,
5118 value, (p+i)->mask);
5119 }
5120 /* Update BT status */
5121 if (on)
5122 marimba_set_bt_status(&config, true);
5123 else
5124 marimba_set_bt_status(&config, false);
5125
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005126 return 0;
5127}
5128
Justin Paupore3f40f342011-08-10 18:52:16 -07005129static int bluetooth_regs_init(int bahama_not_marimba)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005130{
Justin Paupore3f40f342011-08-10 18:52:16 -07005131 int rc = 0;
5132 struct device *const dev = &msm_bt_power_device.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005133
5134 if (bahama_not_marimba) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005135 bahama_version = read_bahama_ver();
5136
5137 switch (bahama_version) {
5138 case VER_1_0:
5139 regs_bt = regs_bt_bahama_v1;
5140 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1);
5141 break;
5142 case VER_2_0:
5143 regs_bt = regs_bt_bahama_v2;
5144 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2);
5145 break;
5146 case VER_UNSUPPORTED:
5147 default:
5148 dev_err(dev,
5149 "%s: i2c failure or unsupported version: %d\n",
5150 __func__, bahama_version);
5151 rc = -EIO;
5152 goto out;
5153 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005154 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07005155 regs_bt = regs_bt_marimba;
5156 regs_bt_count = ARRAY_SIZE(regs_bt_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005157 }
5158
Justin Paupore3f40f342011-08-10 18:52:16 -07005159 rc = regulator_bulk_get(&msm_bt_power_device.dev,
5160 regs_bt_count, regs_bt);
5161 if (rc) {
5162 dev_err(dev, "%s: could not get regulators: %d\n",
5163 __func__, rc);
5164 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005165 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005166
5167 rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt);
5168 if (rc) {
5169 dev_err(dev, "%s: could not set voltages: %d\n",
5170 __func__, rc);
5171 goto reg_free;
5172 }
5173
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005174 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005175
5176reg_free:
5177 regulator_bulk_free(regs_bt_count, regs_bt);
5178out:
5179 regs_bt_count = 0;
5180 regs_bt = NULL;
5181 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005182}
5183
5184static int bluetooth_power(int on)
5185{
5186 int rc;
5187 const char *id = "BTPW";
5188
5189 int bahama_not_marimba = bahama_present();
5190
5191 if (bahama_not_marimba == -1) {
5192 printk(KERN_WARNING "%s: bahama_present: %d\n",
5193 __func__, bahama_not_marimba);
5194 return -ENODEV;
5195 }
5196
Justin Paupore3f40f342011-08-10 18:52:16 -07005197 if (unlikely(regs_bt_count == 0)) {
5198 rc = bluetooth_regs_init(bahama_not_marimba);
5199 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005200 return rc;
Justin Paupore3f40f342011-08-10 18:52:16 -07005201 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005202
Justin Paupore3f40f342011-08-10 18:52:16 -07005203 if (on) {
5204 rc = regulator_bulk_enable(regs_bt_count, regs_bt);
5205 if (rc)
5206 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005207
5208 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5209 PMAPP_CLOCK_VOTE_ON);
5210 if (rc < 0)
5211 return -EIO;
5212
5213 if (machine_is_msm8x55_svlte_surf() ||
5214 machine_is_msm8x55_svlte_ffa()) {
5215 rc = marimba_gpio_config(1);
5216 if (rc < 0)
5217 return -EIO;
5218 }
5219
5220 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5221 if (rc < 0)
5222 return -EIO;
5223
5224 msleep(10);
5225
5226 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5227 PMAPP_CLOCK_VOTE_PIN_CTRL);
5228 if (rc < 0)
5229 return -EIO;
5230
5231 if (machine_is_msm8x55_svlte_surf() ||
5232 machine_is_msm8x55_svlte_ffa()) {
5233 rc = marimba_gpio_config(0);
5234 if (rc < 0)
5235 return -EIO;
5236 }
5237
5238 rc = msm_gpios_enable(bt_config_power_on,
5239 ARRAY_SIZE(bt_config_power_on));
5240
5241 if (rc < 0)
5242 return rc;
5243
5244 } else {
5245 rc = msm_gpios_enable(bt_config_power_off,
5246 ARRAY_SIZE(bt_config_power_off));
5247 if (rc < 0)
5248 return rc;
5249
5250 /* check for initial RFKILL block (power off) */
5251 if (platform_get_drvdata(&msm_bt_power_device) == NULL)
5252 goto out;
5253
5254 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5255 if (rc < 0)
5256 return -EIO;
5257
5258 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5259 PMAPP_CLOCK_VOTE_OFF);
5260 if (rc < 0)
5261 return -EIO;
5262
Justin Paupore3f40f342011-08-10 18:52:16 -07005263 rc = regulator_bulk_disable(regs_bt_count, regs_bt);
5264 if (rc)
5265 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005266
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005267 }
5268
5269out:
5270 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
5271
5272 return 0;
5273}
5274
5275static void __init bt_power_init(void)
5276{
Justin Paupore3f40f342011-08-10 18:52:16 -07005277 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005278}
5279#else
5280#define bt_power_init(x) do {} while (0)
5281#endif
5282
5283static struct msm_psy_batt_pdata msm_psy_batt_data = {
5284 .voltage_min_design = 2800,
5285 .voltage_max_design = 4300,
5286 .avail_chg_sources = AC_CHG | USB_CHG ,
5287 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
5288};
5289
5290static struct platform_device msm_batt_device = {
5291 .name = "msm-battery",
5292 .id = -1,
5293 .dev.platform_data = &msm_psy_batt_data,
5294};
5295
5296static char *msm_adc_fluid_device_names[] = {
5297 "LTC_ADC1",
5298 "LTC_ADC2",
5299 "LTC_ADC3",
5300};
5301
5302static char *msm_adc_surf_device_names[] = {
5303 "XO_ADC",
5304};
5305
5306static struct msm_adc_platform_data msm_adc_pdata;
5307
5308static struct platform_device msm_adc_device = {
5309 .name = "msm_adc",
5310 .id = -1,
5311 .dev = {
5312 .platform_data = &msm_adc_pdata,
5313 },
5314};
5315
5316#ifdef CONFIG_MSM_SDIO_AL
5317static struct msm_gpio mdm2ap_status = {
5318 GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5319 "mdm2ap_status"
5320};
5321
5322
5323static int configure_mdm2ap_status(int on)
5324{
5325 if (on)
5326 return msm_gpios_request_enable(&mdm2ap_status, 1);
5327 else {
5328 msm_gpios_disable_free(&mdm2ap_status, 1);
5329 return 0;
5330 }
5331}
5332
5333static int get_mdm2ap_status(void)
5334{
5335 return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
5336}
5337
5338static struct sdio_al_platform_data sdio_al_pdata = {
5339 .config_mdm2ap_status = configure_mdm2ap_status,
5340 .get_mdm2ap_status = get_mdm2ap_status,
5341 .allow_sdioc_version_major_2 = 1,
5342 .peer_sdioc_version_minor = 0x0001,
5343 .peer_sdioc_version_major = 0x0003,
5344 .peer_sdioc_boot_version_minor = 0x0001,
5345 .peer_sdioc_boot_version_major = 0x0003,
5346};
5347
5348struct platform_device msm_device_sdio_al = {
5349 .name = "msm_sdio_al",
5350 .id = -1,
5351 .dev = {
5352 .platform_data = &sdio_al_pdata,
5353 },
5354};
5355
5356#endif /* CONFIG_MSM_SDIO_AL */
5357
Daniel Walker8d747cd2010-02-25 11:37:43 -08005358static struct platform_device *devices[] __initdata = {
Daniel Walker90e37c52010-05-12 14:24:15 -07005359#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005360 &msm_device_uart2,
5361#endif
Justin Paupore637a25d2011-07-14 17:11:04 -07005362#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
5363 &msm_proccomm_regulator_dev,
5364#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005365 &asoc_msm_pcm,
5366 &asoc_msm_dai0,
5367 &asoc_msm_dai1,
5368#if defined (CONFIG_SND_MSM_MVS_DAI_SOC)
5369 &asoc_msm_mvs,
5370 &asoc_mvs_dai0,
5371 &asoc_mvs_dai1,
Daniel Walker90e37c52010-05-12 14:24:15 -07005372#endif
Niranjana Vishwanathapuraa8855e92010-10-06 13:52:10 -07005373 &msm_device_smd,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005374 &msm_device_dmov,
5375 &smc91x_device,
5376 &smsc911x_device,
5377 &msm_device_nand,
5378#ifdef CONFIG_USB_MSM_OTG_72K
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05305379 &msm_device_otg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005380#ifdef CONFIG_USB_GADGET
5381 &msm_device_gadget_peripheral,
5382#endif
5383#endif
5384#ifdef CONFIG_USB_G_ANDROID
5385 &android_usb_device,
5386#endif
5387 &qsd_device_spi,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305388
5389#ifdef CONFIG_MSM_SSBI
5390 &msm_device_ssbi_pmic1,
5391#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005392#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005393 &msm_device_ssbi7,
5394#endif
5395 &android_pmem_device,
5396 &msm_fb_device,
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08005397#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
5398 &msm_v4l2_video_overlay_device,
5399#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005400 &msm_migrate_pages_device,
5401 &mddi_toshiba_device,
5402 &lcdc_toshiba_panel_device,
5403#ifdef CONFIG_MSM_ROTATOR
5404 &msm_rotator_device,
5405#endif
5406 &lcdc_sharp_panel_device,
5407 &android_pmem_adsp_device,
5408 &android_pmem_audio_device,
5409 &msm_device_i2c,
5410 &msm_device_i2c_2,
5411 &msm_device_uart_dm1,
5412 &hs_device,
5413#ifdef CONFIG_MSM7KV2_AUDIO
5414 &msm_aictl_device,
5415 &msm_mi2s_device,
5416 &msm_lpa_device,
5417 &msm_aux_pcm_device,
5418#endif
5419 &msm_device_adspdec,
5420 &qup_device_i2c,
5421#if defined(CONFIG_MARIMBA_CORE) && \
5422 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5423 &msm_bt_power_device,
5424#endif
5425 &msm_kgsl_3d0,
5426 &msm_kgsl_2d0,
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005427#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005428#ifdef CONFIG_MT9T013
5429 &msm_camera_sensor_mt9t013,
5430#endif
5431#ifdef CONFIG_MT9D112
5432 &msm_camera_sensor_mt9d112,
5433#endif
5434#ifdef CONFIG_WEBCAM_OV9726
5435 &msm_camera_sensor_ov9726,
5436#endif
5437#ifdef CONFIG_S5K3E2FX
5438 &msm_camera_sensor_s5k3e2fx,
5439#endif
5440#ifdef CONFIG_MT9P012
5441 &msm_camera_sensor_mt9p012,
5442#endif
5443#ifdef CONFIG_MT9E013
5444 &msm_camera_sensor_mt9e013,
5445#endif
5446#ifdef CONFIG_VX6953
5447 &msm_camera_sensor_vx6953,
5448#endif
5449#ifdef CONFIG_SN12M0PZ
5450 &msm_camera_sensor_sn12m0pz,
5451#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005452#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005453 &msm_device_vidc_720p,
5454#ifdef CONFIG_MSM_GEMINI
5455 &msm_gemini_device,
5456#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005457#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005458#ifdef CONFIG_MSM_VPE
5459 &msm_vpe_device,
5460#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005461#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005462#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5463 &msm_device_tsif,
5464#endif
5465#ifdef CONFIG_MSM_SDIO_AL
5466 &msm_device_sdio_al,
5467#endif
5468
5469#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5470 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5471 &qcrypto_device,
5472#endif
5473
5474#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5475 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5476 &qcedev_device,
5477#endif
5478
5479 &msm_batt_device,
5480 &msm_adc_device,
5481 &msm_ebi0_thermal,
Laxminath Kasam1d8255d2012-02-15 13:10:19 +05305482 &msm_ebi1_thermal,
Chintan Pandya03b698a2012-06-28 19:03:09 +05305483 &msm_adsp_device,
5484#ifdef CONFIG_ION_MSM
5485 &ion_dev,
5486#endif
Daniel Walker8d747cd2010-02-25 11:37:43 -08005487};
5488
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005489static struct msm_gpio msm_i2c_gpios_hw[] = {
5490 { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5491 { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5492};
5493
5494static struct msm_gpio msm_i2c_gpios_io[] = {
5495 { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5496 { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5497};
5498
5499static struct msm_gpio qup_i2c_gpios_io[] = {
5500 { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5501 { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5502};
5503static struct msm_gpio qup_i2c_gpios_hw[] = {
5504 { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5505 { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5506};
5507
5508static void
5509msm_i2c_gpio_config(int adap_id, int config_type)
5510{
5511 struct msm_gpio *msm_i2c_table;
5512
5513 /* Each adapter gets 2 lines from the table */
5514 if (adap_id > 0)
5515 return;
5516 if (config_type)
5517 msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
5518 else
5519 msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
5520 msm_gpios_enable(msm_i2c_table, 2);
5521}
5522/*This needs to be enabled only for OEMS*/
5523#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005524static struct regulator *qup_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005525#endif
5526static void
5527qup_i2c_gpio_config(int adap_id, int config_type)
5528{
5529 int rc = 0;
5530 struct msm_gpio *qup_i2c_table;
5531 /* Each adapter gets 2 lines from the table */
5532 if (adap_id != 4)
5533 return;
5534 if (config_type)
5535 qup_i2c_table = qup_i2c_gpios_hw;
5536 else
5537 qup_i2c_table = qup_i2c_gpios_io;
5538 rc = msm_gpios_enable(qup_i2c_table, 2);
5539 if (rc < 0)
5540 printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
5541 /*This needs to be enabled only for OEMS*/
5542#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005543 if (!IS_ERR_OR_NULL(qup_vreg)) {
5544 rc = regulator_enable(qup_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005545 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005546 pr_err("%s: regulator_enable failed: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005547 __func__, rc);
5548 }
5549 }
5550#endif
5551}
5552
5553static struct msm_i2c_platform_data msm_i2c_pdata = {
5554 .clk_freq = 100000,
5555 .pri_clk = 70,
5556 .pri_dat = 71,
5557 .rmutex = 1,
5558 .rsl_id = "D:I2C02000021",
5559 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5560};
5561
5562static void __init msm_device_i2c_init(void)
5563{
5564 if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
5565 pr_err("failed to request I2C gpios\n");
5566
5567 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
5568}
5569
5570static struct msm_i2c_platform_data msm_i2c_2_pdata = {
5571 .clk_freq = 100000,
5572 .rmutex = 1,
5573 .rsl_id = "D:I2C02000022",
5574 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5575};
5576
5577static void __init msm_device_i2c_2_init(void)
5578{
5579 msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
5580}
5581
5582static struct msm_i2c_platform_data qup_i2c_pdata = {
5583 .clk_freq = 384000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005584 .msm_i2c_config_gpio = qup_i2c_gpio_config,
5585};
5586
5587static void __init qup_device_i2c_init(void)
5588{
5589 if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
5590 pr_err("failed to request I2C gpios\n");
5591
5592 qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
5593 /*This needs to be enabled only for OEMS*/
5594#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005595 qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005596 if (IS_ERR(qup_vreg)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005597 dev_err(&qup_device_i2c.dev,
5598 "%s: regulator_get failed: %ld\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005599 __func__, PTR_ERR(qup_vreg));
5600 }
5601#endif
5602}
5603
5604#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005605static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = {
5606 .rsl_id = "D:CODEC_SSBI",
5607 .controller_type = MSM_SBI_CTRL_SSBI,
5608};
5609#endif
5610
Daniel Walker8d747cd2010-02-25 11:37:43 -08005611static void __init msm7x30_init_irq(void)
5612{
5613 msm_init_irq();
5614}
5615
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005616static struct msm_gpio msm_nand_ebi2_cfg_data[] = {
5617 {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
5618 {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
5619};
5620
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005621#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
5622 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
5623 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
5624 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
5625
5626struct sdcc_gpio {
5627 struct msm_gpio *cfg_data;
5628 uint32_t size;
5629 struct msm_gpio *sleep_cfg_data;
5630};
5631#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5632static struct msm_gpio sdc1_lvlshft_cfg_data[] = {
5633 {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
5634};
5635#endif
5636static struct msm_gpio sdc1_cfg_data[] = {
5637 {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
5638 {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
5639 {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
5640 {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
5641 {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
5642 {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
5643};
5644
5645static struct msm_gpio sdc2_cfg_data[] = {
5646 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
5647 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
5648 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
5649 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
5650 {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
5651 {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
5652
5653#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5654 {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
5655 {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
5656 {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
5657 {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
5658#endif
5659};
5660
5661static struct msm_gpio sdc3_cfg_data[] = {
5662 {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
5663 {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
5664 {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
5665 {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
5666 {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
5667 {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
5668};
5669
5670static struct msm_gpio sdc3_sleep_cfg_data[] = {
5671 {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5672 "sdc3_clk"},
5673 {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5674 "sdc3_cmd"},
5675 {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5676 "sdc3_dat_3"},
5677 {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5678 "sdc3_dat_2"},
5679 {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5680 "sdc3_dat_1"},
5681 {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5682 "sdc3_dat_0"},
5683};
5684
5685static struct msm_gpio sdc4_cfg_data[] = {
5686 {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
5687 {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
5688 {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
5689 {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
5690 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
5691 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
5692};
5693
5694static struct sdcc_gpio sdcc_cfg_data[] = {
5695 {
5696 .cfg_data = sdc1_cfg_data,
5697 .size = ARRAY_SIZE(sdc1_cfg_data),
5698 .sleep_cfg_data = NULL,
5699 },
5700 {
5701 .cfg_data = sdc2_cfg_data,
5702 .size = ARRAY_SIZE(sdc2_cfg_data),
5703 .sleep_cfg_data = NULL,
5704 },
5705 {
5706 .cfg_data = sdc3_cfg_data,
5707 .size = ARRAY_SIZE(sdc3_cfg_data),
5708 .sleep_cfg_data = sdc3_sleep_cfg_data,
5709 },
5710 {
5711 .cfg_data = sdc4_cfg_data,
5712 .size = ARRAY_SIZE(sdc4_cfg_data),
5713 .sleep_cfg_data = NULL,
5714 },
5715};
5716
Justin Paupore3f40f342011-08-10 18:52:16 -07005717static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005718
5719static unsigned long vreg_sts, gpio_sts;
5720
5721static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
5722{
5723 int rc = 0;
5724 struct sdcc_gpio *curr;
5725
5726 curr = &sdcc_cfg_data[dev_id - 1];
5727
5728 if (!(test_bit(dev_id, &gpio_sts)^enable))
5729 return rc;
5730
5731 if (enable) {
5732 set_bit(dev_id, &gpio_sts);
5733 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
5734 if (rc)
5735 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
5736 __func__, dev_id);
5737 } else {
5738 clear_bit(dev_id, &gpio_sts);
5739 if (curr->sleep_cfg_data) {
5740 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
5741 msm_gpios_free(curr->sleep_cfg_data, curr->size);
5742 } else {
5743 msm_gpios_disable_free(curr->cfg_data, curr->size);
5744 }
5745 }
5746
5747 return rc;
5748}
5749
5750static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
5751{
5752 int rc = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005753 struct regulator *curr = sdcc_vreg_data[dev_id - 1];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005754 static int enabled_once[] = {0, 0, 0, 0};
5755
Justin Paupore3f40f342011-08-10 18:52:16 -07005756 if (test_bit(dev_id, &vreg_sts) == enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005757 return rc;
5758
Asutosh Das853bbcd2012-02-01 10:40:05 +05305759 if (dev_id == 4) {
5760 if (enable) {
5761 pr_debug("Enable Vdd dev_%d\n", dev_id);
5762 gpio_set_value_cansleep(
5763 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5764 0);
5765 set_bit(dev_id, &vreg_sts);
5766 } else {
5767 pr_debug("Disable Vdd dev_%d\n", dev_id);
5768 gpio_set_value_cansleep(
5769 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5770 1);
5771 clear_bit(dev_id, &vreg_sts);
5772 }
5773 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005774
Asutosh Das853bbcd2012-02-01 10:40:05 +05305775 if (!enable || enabled_once[dev_id - 1])
5776 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005777 if (!curr)
5778 return -ENODEV;
5779
5780 if (IS_ERR(curr))
5781 return PTR_ERR(curr);
5782
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005783 if (enable) {
5784 set_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005785
5786 rc = regulator_enable(curr);
5787 if (rc)
5788 pr_err("%s: could not enable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005789 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005790 enabled_once[dev_id - 1] = 1;
5791 } else {
5792 clear_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005793
5794 rc = regulator_disable(curr);
5795 if (rc)
5796 pr_err("%s: could not disable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005797 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005798 }
5799 return rc;
5800}
5801
5802static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
5803{
5804 int rc = 0;
5805 struct platform_device *pdev;
5806
5807 pdev = container_of(dv, struct platform_device, dev);
5808 rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
5809 if (rc)
5810 goto out;
5811
5812 if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
5813 rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
5814out:
5815 return rc;
5816}
5817
5818#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \
5819 defined(CONFIG_CSDIO_VENDOR_ID) && \
5820 defined(CONFIG_CSDIO_DEVICE_ID) && \
5821 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5822
5823#define MBP_ON 1
5824#define MBP_OFF 0
5825
5826#define MBP_RESET_N \
5827 GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
5828#define MBP_INT0 \
5829 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
5830
5831#define MBP_MODE_CTRL_0 \
5832 GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5833#define MBP_MODE_CTRL_1 \
5834 GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5835#define MBP_MODE_CTRL_2 \
5836 GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5837#define TSIF_EN \
5838 GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5839#define TSIF_DATA \
5840 GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5841#define TSIF_CLK \
5842 GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5843
5844static struct msm_gpio mbp_cfg_data[] = {
5845 {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5846 "mbp_reset"},
5847 {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5848 "mbp_io_voltage"},
5849};
5850
5851static int mbp_config_gpios_pre_init(int enable)
5852{
5853 int rc = 0;
5854
5855 if (enable) {
5856 rc = msm_gpios_request_enable(mbp_cfg_data,
5857 ARRAY_SIZE(mbp_cfg_data));
5858 if (rc) {
5859 printk(KERN_ERR
5860 "%s: Failed to turnon GPIOs for mbp chip(%d)\n",
5861 __func__, rc);
5862 }
5863 } else
5864 msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
5865 return rc;
5866}
5867
Justin Paupore3f40f342011-08-10 18:52:16 -07005868static struct regulator_bulk_data mbp_regs_io[2];
5869static struct regulator_bulk_data mbp_regs_rf[2];
5870static struct regulator_bulk_data mbp_regs_adc[1];
5871static struct regulator_bulk_data mbp_regs_core[1];
5872
5873static int mbp_init_regs(struct device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005874{
Justin Paupore3f40f342011-08-10 18:52:16 -07005875 struct regulator_bulk_data regs[] = {
5876 /* Analog and I/O regs */
5877 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
5878 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
5879 /* RF regs */
5880 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
5881 { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 },
5882 /* ADC regs */
5883 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
5884 /* Core regs */
5885 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
5886 };
5887
5888 struct regulator_bulk_data *regptr = regs;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005889 int rc;
5890
Justin Paupore3f40f342011-08-10 18:52:16 -07005891 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs);
5892
5893 if (rc) {
5894 dev_err(dev, "%s: could not get regulators: %d\n",
5895 __func__, rc);
5896 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005897 }
5898
Justin Paupore3f40f342011-08-10 18:52:16 -07005899 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005900
Justin Paupore3f40f342011-08-10 18:52:16 -07005901 if (rc) {
5902 dev_err(dev, "%s: could not set voltages: %d\n",
5903 __func__, rc);
5904 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005905 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005906
5907 memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io));
5908 regptr += ARRAY_SIZE(mbp_regs_io);
5909
5910 memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf));
5911 regptr += ARRAY_SIZE(mbp_regs_rf);
5912
5913 memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc));
5914 regptr += ARRAY_SIZE(mbp_regs_adc);
5915
5916 memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core));
5917
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005918 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005919
5920reg_free:
5921 regulator_bulk_free(ARRAY_SIZE(regs), regs);
5922out:
5923 return rc;
5924}
5925
5926static int mbp_setup_rf_vregs(int state)
5927{
5928 return state ?
5929 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) :
5930 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005931}
5932
5933static int mbp_setup_vregs(int state)
5934{
Justin Paupore3f40f342011-08-10 18:52:16 -07005935 return state ?
5936 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) :
5937 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005938}
5939
5940static int mbp_set_tcxo_en(int enable)
5941{
5942 int rc;
5943 const char *id = "UBMC";
5944 struct vreg *vreg_analog = NULL;
5945
5946 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
5947 enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
5948 if (rc < 0) {
5949 printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
5950 __func__, enable ? "" : "de-");
5951 return -EIO;
5952 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005953 return rc;
5954}
5955
5956static void mbp_set_freeze_io(int state)
5957{
5958 if (state)
5959 gpio_set_value(85, 0);
5960 else
5961 gpio_set_value(85, 1);
5962}
5963
5964static int mbp_set_core_voltage_en(int enable)
5965{
Justin Paupore3f40f342011-08-10 18:52:16 -07005966 static bool is_enabled;
5967 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005968
Justin Paupore3f40f342011-08-10 18:52:16 -07005969 if (enable && !is_enabled) {
5970 rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core),
5971 mbp_regs_core);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005972 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005973 pr_err("%s: could not enable regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005974 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07005975 } else {
5976 is_enabled = true;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005977 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005978 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005979
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005980 return rc;
5981}
5982
5983static void mbp_set_reset(int state)
5984{
5985 if (state)
5986 gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
5987 else
5988 gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
5989}
5990
5991static int mbp_config_interface_mode(int state)
5992{
5993 if (state) {
5994 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
5995 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
5996 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
5997 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
5998 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
5999 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
6000 } else {
6001 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
6002 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
6003 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
6004 }
6005 return 0;
6006}
6007
6008static int mbp_setup_adc_vregs(int state)
6009{
Justin Paupore3f40f342011-08-10 18:52:16 -07006010 return state ?
6011 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) :
6012 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006013}
6014
6015static int mbp_power_up(void)
6016{
6017 int rc;
6018
6019 rc = mbp_config_gpios_pre_init(MBP_ON);
6020 if (rc)
6021 goto exit;
6022 pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__);
6023
6024 rc = mbp_setup_vregs(MBP_ON);
6025 if (rc)
6026 goto exit;
6027 pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
6028
6029 rc = mbp_set_tcxo_en(MBP_ON);
6030 if (rc)
6031 goto exit;
6032 pr_debug("%s: tcxo clock done\n", __func__);
6033
6034 mbp_set_freeze_io(MBP_OFF);
6035 pr_debug("%s: set gpio 85 to 1 done\n", __func__);
6036
6037 udelay(100);
6038 mbp_set_reset(MBP_ON);
6039
6040 udelay(300);
6041 rc = mbp_config_interface_mode(MBP_ON);
6042 if (rc)
6043 goto exit;
6044 pr_debug("%s: mbp_config_interface_mode() done\n", __func__);
6045
6046 udelay(100 + mbp_set_core_voltage_en(MBP_ON));
6047 pr_debug("%s: power gp16 1.2V done\n", __func__);
6048
6049 mbp_set_freeze_io(MBP_ON);
6050 pr_debug("%s: set gpio 85 to 0 done\n", __func__);
6051
6052 udelay(100);
6053
6054 rc = mbp_setup_rf_vregs(MBP_ON);
6055 if (rc)
6056 goto exit;
6057 pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
6058
6059 rc = mbp_setup_adc_vregs(MBP_ON);
6060 if (rc)
6061 goto exit;
6062 pr_debug("%s: s4 2.2V done\n", __func__);
6063
6064 udelay(200);
6065
6066 mbp_set_reset(MBP_OFF);
6067 pr_debug("%s: close gpio 44 done\n", __func__);
6068
6069 msleep(20);
6070exit:
6071 return rc;
6072}
6073
6074static int mbp_power_down(void)
6075{
6076 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006077
6078 mbp_set_reset(MBP_ON);
6079 pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
6080
6081 udelay(100);
6082
6083 rc = mbp_setup_adc_vregs(MBP_OFF);
6084 if (rc)
6085 goto exit;
6086 pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
6087
6088 udelay(5);
6089
6090 rc = mbp_setup_rf_vregs(MBP_OFF);
6091 if (rc)
6092 goto exit;
6093 pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
6094
6095 udelay(5);
6096
6097 mbp_set_freeze_io(MBP_OFF);
6098 pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
6099
6100 udelay(100);
6101 rc = mbp_set_core_voltage_en(MBP_OFF);
6102 if (rc)
6103 goto exit;
6104 pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
6105
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006106 rc = mbp_set_tcxo_en(MBP_OFF);
6107 if (rc)
6108 goto exit;
6109 pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
6110
Justin Paupore3f40f342011-08-10 18:52:16 -07006111 rc = mbp_setup_vregs(MBP_OFF);
6112 if (rc)
6113 goto exit;
6114 pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__);
6115
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006116 rc = mbp_config_gpios_pre_init(MBP_OFF);
6117 if (rc)
6118 goto exit;
6119exit:
6120 return rc;
6121}
6122
6123static void (*mbp_status_notify_cb)(int card_present, void *dev_id);
6124static void *mbp_status_notify_cb_devid;
6125static int mbp_power_status;
6126static int mbp_power_init_done;
6127
6128static uint32_t mbp_setup_power(struct device *dv,
6129 unsigned int power_status)
6130{
6131 int rc = 0;
6132 struct platform_device *pdev;
6133
6134 pdev = container_of(dv, struct platform_device, dev);
6135
6136 if (power_status == mbp_power_status)
6137 goto exit;
6138 if (power_status) {
6139 pr_debug("turn on power of mbp slot");
6140 rc = mbp_power_up();
6141 mbp_power_status = 1;
6142 } else {
6143 pr_debug("turn off power of mbp slot");
6144 rc = mbp_power_down();
6145 mbp_power_status = 0;
6146 }
6147exit:
6148 return rc;
6149};
6150
6151int mbp_register_status_notify(void (*callback)(int, void *),
6152 void *dev_id)
6153{
6154 mbp_status_notify_cb = callback;
6155 mbp_status_notify_cb_devid = dev_id;
6156 return 0;
6157}
6158
6159static unsigned int mbp_status(struct device *dev)
6160{
6161 return mbp_power_status;
6162}
6163
6164static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd)
6165{
6166 struct platform_device *pdev;
6167 uint32_t rc = 0;
6168
6169 pdev = container_of(dv, struct platform_device, dev);
6170 rc = msm_sdcc_setup_power(dv, vdd);
6171 if (rc) {
6172 pr_err("%s: Failed to setup power (%d)\n",
6173 __func__, rc);
6174 goto out;
6175 }
6176 if (!mbp_power_init_done) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006177 rc = mbp_init_regs(dv);
6178 if (rc) {
6179 dev_err(dv, "%s: regulator init failed: %d\n",
6180 __func__, rc);
6181 goto out;
6182 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006183 mbp_setup_power(dv, 1);
6184 mbp_setup_power(dv, 0);
6185 mbp_power_init_done = 1;
6186 }
6187 if (vdd >= 0x8000) {
6188 rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
6189 if (rc) {
6190 pr_err("%s: Failed to config mbp chip power (%d)\n",
6191 __func__, rc);
6192 goto out;
6193 }
6194 if (mbp_status_notify_cb) {
6195 mbp_status_notify_cb(mbp_power_status,
6196 mbp_status_notify_cb_devid);
6197 }
6198 }
6199out:
6200 /* should return 0 only */
6201 return 0;
6202}
6203
6204#endif
6205
6206#endif
6207
6208#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006209static unsigned int msm7x30_sdcc_slot_status(struct device *dev)
6210{
6211 return (unsigned int)
6212 gpio_get_value_cansleep(
6213 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1));
6214}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006215
6216static int msm_sdcc_get_wpswitch(struct device *dv)
6217{
6218 void __iomem *wp_addr = 0;
6219 uint32_t ret = 0;
6220 struct platform_device *pdev;
6221
6222 if (!(machine_is_msm7x30_surf()))
6223 return -1;
6224 pdev = container_of(dv, struct platform_device, dev);
6225
6226 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
6227 if (!wp_addr) {
6228 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
6229 return -ENOMEM;
6230 }
6231
6232 ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
6233 pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
6234 pdev->id, ret);
6235 iounmap(wp_addr);
6236
6237 return ret;
6238}
6239#endif
6240
6241#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
6242#if defined(CONFIG_CSDIO_VENDOR_ID) && \
6243 defined(CONFIG_CSDIO_DEVICE_ID) && \
6244 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
6245static struct mmc_platform_data msm7x30_sdc1_data = {
6246 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
6247 .translate_vdd = msm_sdcc_setup_power_mbp,
6248 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6249 .status = mbp_status,
6250 .register_status_notify = mbp_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006251 .msmsdcc_fmin = 144000,
6252 .msmsdcc_fmid = 24576000,
6253 .msmsdcc_fmax = 24576000,
6254 .nonremovable = 0,
6255};
6256#else
6257static struct mmc_platform_data msm7x30_sdc1_data = {
6258 .ocr_mask = MMC_VDD_165_195,
6259 .translate_vdd = msm_sdcc_setup_power,
6260 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006261 .msmsdcc_fmin = 144000,
6262 .msmsdcc_fmid = 24576000,
6263 .msmsdcc_fmax = 49152000,
6264 .nonremovable = 0,
6265};
6266#endif
6267#endif
6268
6269#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
6270static struct mmc_platform_data msm7x30_sdc2_data = {
6271 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
6272 .translate_vdd = msm_sdcc_setup_power,
6273#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
6274 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
6275#else
6276 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6277#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006278 .msmsdcc_fmin = 144000,
6279 .msmsdcc_fmid = 24576000,
6280 .msmsdcc_fmax = 49152000,
6281 .nonremovable = 1,
6282};
6283#endif
6284
6285#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
6286static struct mmc_platform_data msm7x30_sdc3_data = {
6287 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6288 .translate_vdd = msm_sdcc_setup_power,
6289 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006290 .sdiowakeup_irq = MSM_GPIO_TO_INT(118),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006291 .msmsdcc_fmin = 144000,
6292 .msmsdcc_fmid = 24576000,
6293 .msmsdcc_fmax = 49152000,
6294 .nonremovable = 0,
6295};
6296#endif
6297
6298#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6299static struct mmc_platform_data msm7x30_sdc4_data = {
6300 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6301 .translate_vdd = msm_sdcc_setup_power,
6302 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006303 .status = msm7x30_sdcc_slot_status,
6304 .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
6305 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006306 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006307 .msmsdcc_fmin = 144000,
6308 .msmsdcc_fmid = 24576000,
6309 .msmsdcc_fmax = 49152000,
6310 .nonremovable = 0,
6311};
6312#endif
6313
6314#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006315static int msm_sdc1_lvlshft_enable(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006316{
Justin Paupore3f40f342011-08-10 18:52:16 -07006317 static struct regulator *ldo5;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006318 int rc;
6319
6320 /* Enable LDO5, an input to the FET that powers slot 1 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006321
Justin Paupore3f40f342011-08-10 18:52:16 -07006322 ldo5 = regulator_get(NULL, "ldo5");
6323
6324 if (IS_ERR(ldo5)) {
6325 rc = PTR_ERR(ldo5);
6326 pr_err("%s: could not get ldo5: %d\n", __func__, rc);
6327 goto out;
6328 }
6329
6330 rc = regulator_set_voltage(ldo5, 2850000, 2850000);
6331 if (rc) {
6332 pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc);
6333 goto ldo5_free;
6334 }
6335
6336 rc = regulator_enable(ldo5);
6337 if (rc) {
6338 pr_err("%s: could not enable ldo5: %d\n", __func__, rc);
6339 goto ldo5_free;
6340 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006341
6342 /* Enable GPIO 35, to turn on the FET that powers slot 1 */
6343 rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
6344 ARRAY_SIZE(sdc1_lvlshft_cfg_data));
6345 if (rc)
6346 printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
6347
6348 rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg),
6349 1);
6350 if (rc)
6351 printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006352
6353 return 0;
6354
6355ldo5_free:
6356 regulator_put(ldo5);
6357out:
6358 ldo5 = NULL;
6359 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006360}
6361#endif
6362
Justin Paupore3f40f342011-08-10 18:52:16 -07006363static int mmc_regulator_init(int sdcc_no, const char *supply, int uV)
6364{
6365 int rc;
6366
6367 BUG_ON(sdcc_no < 1 || sdcc_no > 4);
6368
6369 sdcc_no--;
6370
6371 sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply);
6372
6373 if (IS_ERR(sdcc_vreg_data[sdcc_no])) {
6374 rc = PTR_ERR(sdcc_vreg_data[sdcc_no]);
6375 pr_err("%s: could not get regulator \"%s\": %d\n",
6376 __func__, supply, rc);
6377 goto out;
6378 }
6379
6380 rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV);
6381
6382 if (rc) {
6383 pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n",
6384 __func__, supply, uV, rc);
6385 goto reg_free;
6386 }
6387
6388 return rc;
6389
6390reg_free:
6391 regulator_put(sdcc_vreg_data[sdcc_no]);
6392out:
6393 sdcc_vreg_data[sdcc_no] = NULL;
6394 return rc;
6395}
6396
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006397static void __init msm7x30_init_mmc(void)
6398{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006399#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006400 if (mmc_regulator_init(1, "s3", 1800000))
6401 goto out1;
6402
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006403 if (machine_is_msm7x30_fluid()) {
6404 msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
Justin Paupore3f40f342011-08-10 18:52:16 -07006405 if (msm_sdc1_lvlshft_enable()) {
6406 pr_err("%s: could not enable level shift\n");
6407 goto out1;
6408 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006409 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006410
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006411 msm_add_sdcc(1, &msm7x30_sdc1_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006412out1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006413#endif
6414#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006415 if (mmc_regulator_init(2, "s3", 1800000))
6416 goto out2;
6417
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006418 if (machine_is_msm8x55_svlte_surf())
6419 msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
Sujith Reddy Thumma84a0f512011-08-29 09:57:03 +05306420 if (machine_is_msm8x55_svlte_surf() ||
6421 machine_is_msm8x55_svlte_ffa()) {
6422 msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
6423 msm7x30_sdc2_data.is_sdio_al_client = 1;
6424 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006425
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006426 msm_add_sdcc(2, &msm7x30_sdc2_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006427out2:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006428#endif
6429#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006430 if (mmc_regulator_init(3, "s3", 1800000))
6431 goto out3;
6432
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006433 msm_sdcc_setup_gpio(3, 1);
6434 msm_add_sdcc(3, &msm7x30_sdc3_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006435out3:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006436#endif
6437#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006438 if (mmc_regulator_init(4, "mmc", 2850000))
6439 return;
6440
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006441 msm_add_sdcc(4, &msm7x30_sdc4_data);
6442#endif
6443
6444}
6445
6446static void __init msm7x30_init_nand(void)
6447{
6448 char *build_id;
6449 struct flash_platform_data *plat_data;
6450
6451 build_id = socinfo_get_build_id();
6452 if (build_id == NULL) {
6453 pr_err("%s: Build ID not available from socinfo\n", __func__);
6454 return;
6455 }
6456
6457 if (build_id[8] == 'C' &&
6458 !msm_gpios_request_enable(msm_nand_ebi2_cfg_data,
6459 ARRAY_SIZE(msm_nand_ebi2_cfg_data))) {
6460 plat_data = msm_device_nand.dev.platform_data;
6461 plat_data->interleave = 1;
6462 printk(KERN_INFO "%s: Interleave mode Build ID found\n",
6463 __func__);
6464 }
6465}
6466
6467#ifdef CONFIG_SERIAL_MSM_CONSOLE
6468static struct msm_gpio uart2_config_data[] = {
6469 { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
6470 { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
6471 { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
6472 { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
6473};
6474
6475static void msm7x30_init_uart2(void)
6476{
6477 msm_gpios_request_enable(uart2_config_data,
6478 ARRAY_SIZE(uart2_config_data));
6479
6480}
6481#endif
6482
6483/* TSIF begin */
6484#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6485
6486#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6487#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6488#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6489#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6490
6491static const struct msm_gpio tsif_gpios[] = {
6492 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
6493 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
6494 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
6495 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
6496};
6497
6498static struct msm_tsif_platform_data tsif_platform_data = {
6499 .num_gpios = ARRAY_SIZE(tsif_gpios),
6500 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -07006501 .tsif_pclk = "iface_clk",
6502 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006503};
6504#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
6505/* TSIF end */
6506
6507static void __init pmic8058_leds_init(void)
6508{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306509 if (machine_is_msm7x30_surf())
6510 pm8058_7x30_data.leds_pdata = &pm8058_surf_leds_data;
6511 else if (!machine_is_msm7x30_fluid())
6512 pm8058_7x30_data.leds_pdata = &pm8058_ffa_leds_data;
6513 else if (machine_is_msm7x30_fluid())
6514 pm8058_7x30_data.leds_pdata = &pm8058_fluid_leds_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006515}
6516
6517static struct msm_spm_platform_data msm_spm_data __initdata = {
Taniya Das298de8c2012-02-16 11:45:31 +05306518 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006519
6520 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
6521 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
6522 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
6523 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
6524
6525 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
6526 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
6527 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
6528
6529 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
6530 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
6531 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
6532
6533 .awake_vlevel = 0xF2,
6534 .retention_vlevel = 0xE0,
6535 .collapse_vlevel = 0x72,
6536 .retention_mid_vlevel = 0xE0,
6537 .collapse_mid_vlevel = 0xE0,
6538
6539 .vctl_timeout_us = 50,
6540};
6541
6542#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6543 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6544
6545#define TSC2007_TS_PEN_INT 20
6546
6547static struct msm_gpio tsc2007_config_data[] = {
6548 { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
6549 "tsc2007_irq" },
6550};
6551
Justin Paupore3f40f342011-08-10 18:52:16 -07006552static struct regulator_bulk_data tsc2007_regs[] = {
6553 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
6554 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
6555};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006556
6557static int tsc2007_init(void)
6558{
6559 int rc;
6560
Justin Paupore3f40f342011-08-10 18:52:16 -07006561 rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006562
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006563 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006564 pr_err("%s: could not get regulators: %d\n", __func__, rc);
6565 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006566 }
6567
Justin Paupore3f40f342011-08-10 18:52:16 -07006568 rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6569
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006570 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006571 pr_err("%s: could not set voltages: %d\n", __func__, rc);
6572 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006573 }
6574
Justin Paupore3f40f342011-08-10 18:52:16 -07006575 rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006576
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006577 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006578 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
6579 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006580 }
6581
6582 rc = msm_gpios_request_enable(tsc2007_config_data,
6583 ARRAY_SIZE(tsc2007_config_data));
6584 if (rc) {
6585 pr_err("%s: Unable to request gpios\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006586 goto reg_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006587 }
6588
6589 return 0;
6590
Justin Paupore3f40f342011-08-10 18:52:16 -07006591reg_disable:
6592 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6593reg_free:
6594 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6595out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006596 return rc;
6597}
6598
6599static int tsc2007_get_pendown_state(void)
6600{
6601 int rc;
6602
6603 rc = gpio_get_value(TSC2007_TS_PEN_INT);
6604 if (rc < 0) {
6605 pr_err("%s: MSM GPIO %d read failed\n", __func__,
6606 TSC2007_TS_PEN_INT);
6607 return rc;
6608 }
6609
6610 return (rc == 0 ? 1 : 0);
6611}
6612
6613static void tsc2007_exit(void)
6614{
Justin Paupore3f40f342011-08-10 18:52:16 -07006615
6616 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6617 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006618
6619 msm_gpios_disable_free(tsc2007_config_data,
6620 ARRAY_SIZE(tsc2007_config_data));
6621}
6622
6623static int tsc2007_power_shutdown(bool enable)
6624{
6625 int rc;
6626
Justin Paupore3f40f342011-08-10 18:52:16 -07006627 rc = (enable == false) ?
6628 regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) :
6629 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6630
6631 if (rc) {
6632 pr_err("%s: could not %sable regulators: %d\n",
6633 __func__, enable ? "dis" : "en", rc);
6634 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006635 }
6636
Justin Paupore3f40f342011-08-10 18:52:16 -07006637 if (enable == false)
6638 msleep(20);
6639
6640 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006641}
6642
6643static struct tsc2007_platform_data tsc2007_ts_data = {
6644 .model = 2007,
6645 .x_plate_ohms = 300,
Anirudh Ghayala2cf2e22012-01-25 12:29:42 +05306646 .min_x = 210,
6647 .max_x = 3832,
6648 .min_y = 150,
6649 .max_y = 3936,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006650 .irq_flags = IRQF_TRIGGER_LOW,
6651 .init_platform_hw = tsc2007_init,
6652 .exit_platform_hw = tsc2007_exit,
6653 .power_shutdown = tsc2007_power_shutdown,
6654 .invert_x = true,
6655 .invert_y = true,
6656 /* REVISIT: Temporary fix for reversed pressure */
6657 .invert_z1 = true,
6658 .invert_z2 = true,
6659 .get_pendown_state = tsc2007_get_pendown_state,
6660};
6661
6662static struct i2c_board_info tsc_i2c_board_info[] = {
6663 {
6664 I2C_BOARD_INFO("tsc2007", 0x48),
6665 .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
6666 .platform_data = &tsc2007_ts_data,
6667 },
6668};
6669#endif
6670
Justin Paupore3f40f342011-08-10 18:52:16 -07006671static struct regulator_bulk_data regs_isa1200[] = {
6672 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
6673 { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006674};
6675
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006676static int isa1200_power(int vreg_on)
6677{
Justin Paupore3f40f342011-08-10 18:52:16 -07006678 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006679
Justin Paupore3f40f342011-08-10 18:52:16 -07006680 rc = vreg_on ?
6681 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) :
6682 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006683
Justin Paupore3f40f342011-08-10 18:52:16 -07006684 if (rc) {
6685 pr_err("%s: could not %sable regulators: %d\n",
6686 __func__, vreg_on ? "en" : "dis", rc);
6687 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006688 }
6689
6690 /* vote for DO buffer */
6691 rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO,
6692 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
6693 if (rc) {
6694 pr_err("%s: unable to %svote for d0 clk\n",
6695 __func__, vreg_on ? "" : "de-");
6696 goto vreg_fail;
6697 }
6698
6699 return 0;
6700
6701vreg_fail:
Justin Paupore3f40f342011-08-10 18:52:16 -07006702 if (vreg_on)
6703 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6704 else
6705 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6706out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006707 return rc;
6708}
6709
6710static int isa1200_dev_setup(bool enable)
6711{
Justin Paupore3f40f342011-08-10 18:52:16 -07006712 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006713
6714 if (enable == true) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006715 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200),
6716 regs_isa1200);
6717
6718 if (rc) {
6719 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006720 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006721 goto out;
6722 }
6723
6724 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200),
6725 regs_isa1200);
6726 if (rc) {
6727 pr_err("%s: could not set voltages: %d\n",
6728 __func__, rc);
6729 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006730 }
6731
6732 rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
6733 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
6734 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
6735 if (rc) {
6736 pr_err("%s: Could not configure gpio %d\n",
6737 __func__, HAP_LVL_SHFT_MSM_GPIO);
Justin Paupore3f40f342011-08-10 18:52:16 -07006738 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006739 }
6740
6741 rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
6742 if (rc) {
6743 pr_err("%s: unable to request gpio %d (%d)\n",
6744 __func__, HAP_LVL_SHFT_MSM_GPIO, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006745 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006746 }
6747
6748 gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
6749 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006750 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006751 gpio_free(HAP_LVL_SHFT_MSM_GPIO);
6752 }
6753
6754 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07006755
6756reg_free:
6757 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6758out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006759 return rc;
6760}
6761static struct isa1200_platform_data isa1200_1_pdata = {
6762 .name = "vibrator",
6763 .power_on = isa1200_power,
6764 .dev_setup = isa1200_dev_setup,
6765 .pwm_ch_id = 1, /*channel id*/
6766 /*gpio to enable haptic*/
6767 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka03122322011-09-09 15:15:43 +05306768 .hap_len_gpio = -1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006769 .max_timeout = 15000,
6770 .mode_ctrl = PWM_GEN_MODE,
6771 .pwm_fd = {
6772 .pwm_div = 256,
6773 },
6774 .is_erm = false,
6775 .smart_en = true,
6776 .ext_clk_en = true,
6777 .chip_en = 1,
6778};
6779
6780static struct i2c_board_info msm_isa1200_board_info[] = {
6781 {
6782 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
6783 .platform_data = &isa1200_1_pdata,
6784 },
6785};
6786
6787
6788static int kp_flip_mpp_config(void)
6789{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306790 struct pm8xxx_mpp_config_data kp_flip_mpp = {
6791 .type = PM8XXX_MPP_TYPE_D_INPUT,
6792 .level = PM8018_MPP_DIG_LEVEL_S3,
6793 .control = PM8XXX_MPP_DIN_TO_INT,
6794 };
6795
6796 return pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(PM_FLIP_MPP),
6797 &kp_flip_mpp);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006798}
6799
6800static struct flip_switch_pdata flip_switch_data = {
6801 .name = "kp_flip_switch",
6802 .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP,
6803 .left_key = KEY_OPEN,
6804 .right_key = KEY_CLOSE,
6805 .active_low = 0,
6806 .wakeup = 1,
6807 .flip_mpp_config = kp_flip_mpp_config,
6808};
6809
6810static struct platform_device flip_switch_device = {
6811 .name = "kp_flip_switch",
6812 .id = -1,
6813 .dev = {
6814 .platform_data = &flip_switch_data,
6815 }
6816};
6817
Justin Paupore3f40f342011-08-10 18:52:16 -07006818static struct regulator_bulk_data regs_tma300[] = {
6819 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
6820 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006821};
6822
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006823static int tma300_power(int vreg_on)
6824{
Justin Paupore3f40f342011-08-10 18:52:16 -07006825 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006826
Justin Paupore3f40f342011-08-10 18:52:16 -07006827 rc = vreg_on ?
6828 regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) :
6829 regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006830
Justin Paupore3f40f342011-08-10 18:52:16 -07006831 if (rc)
6832 pr_err("%s: could not %sable regulators: %d\n",
6833 __func__, vreg_on ? "en" : "dis", rc);
6834 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006835}
6836
6837#define TS_GPIO_IRQ 150
6838
6839static int tma300_dev_setup(bool enable)
6840{
Justin Paupore3f40f342011-08-10 18:52:16 -07006841 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006842
6843 if (enable) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006844 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300),
6845 regs_tma300);
6846
6847 if (rc) {
6848 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006849 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006850 goto out;
6851 }
6852
6853 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300),
6854 regs_tma300);
6855
6856 if (rc) {
6857 pr_err("%s: could not set voltages: %d\n",
6858 __func__, rc);
6859 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006860 }
6861
6862 /* enable interrupt gpio */
6863 rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
6864 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
6865 if (rc) {
6866 pr_err("%s: Could not configure gpio %d\n",
6867 __func__, TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -07006868 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006869 }
6870
6871 /* virtual keys */
6872 tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
6873 properties_kobj = kobject_create_and_add("board_properties",
6874 NULL);
6875 if (!properties_kobj) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006876 pr_err("%s: failed to create a kobject "
6877 "for board_properties\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006878 rc = -ENOMEM;
Justin Paupore3f40f342011-08-10 18:52:16 -07006879 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006880 }
6881 rc = sysfs_create_group(properties_kobj,
6882 &tma300_properties_attr_group);
6883 if (rc) {
6884 pr_err("%s: failed to create a sysfs entry %s\n",
6885 __func__, tma300_vkeys_attr.attr.name);
Justin Paupore3f40f342011-08-10 18:52:16 -07006886 goto kobj_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006887 }
6888 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006889 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006890 /* destroy virtual keys */
6891 if (properties_kobj) {
6892 sysfs_remove_group(properties_kobj,
6893 &tma300_properties_attr_group);
6894 kobject_put(properties_kobj);
6895 }
6896 }
6897 return 0;
6898
Justin Paupore3f40f342011-08-10 18:52:16 -07006899kobj_free:
6900 kobject_put(properties_kobj);
6901 properties_kobj = NULL;
6902reg_free:
6903 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
6904out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006905 return rc;
6906}
6907
6908static struct cy8c_ts_platform_data cy8ctma300_pdata = {
6909 .power_on = tma300_power,
6910 .dev_setup = tma300_dev_setup,
6911 .ts_name = "msm_tma300_ts",
6912 .dis_min_x = 0,
6913 .dis_max_x = 479,
6914 .dis_min_y = 0,
6915 .dis_max_y = 799,
6916 .res_x = 479,
6917 .res_y = 1009,
6918 .min_tid = 1,
6919 .max_tid = 255,
6920 .min_touch = 0,
6921 .max_touch = 255,
6922 .min_width = 0,
6923 .max_width = 255,
6924 .invert_y = 1,
6925 .nfingers = 4,
6926 .irq_gpio = TS_GPIO_IRQ,
6927 .resout_gpio = -1,
6928};
6929
6930static struct i2c_board_info cy8ctma300_board_info[] = {
6931 {
6932 I2C_BOARD_INFO("cy8ctma300", 0x2),
6933 .platform_data = &cy8ctma300_pdata,
6934 }
6935};
6936
Daniel Walker8d747cd2010-02-25 11:37:43 -08006937static void __init msm7x30_init(void)
6938{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006939 int rc;
6940 unsigned smem_size;
6941 uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56,
6942 0,
6943 GPIO_CFG_OUTPUT,
6944 GPIO_CFG_NO_PULL,
6945 GPIO_CFG_2MA);
6946 uint32_t soc_version = 0;
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05306947
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006948 soc_version = socinfo_get_version();
6949
Stephen Boydbb600ae2011-08-02 20:11:40 -07006950 msm_clock_init(&msm7x30_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006951#ifdef CONFIG_SERIAL_MSM_CONSOLE
6952 msm7x30_init_uart2();
6953#endif
6954 msm_spm_init(&msm_spm_data, 1);
Matt Wagantallbf430eb2012-03-22 11:45:49 -07006955 platform_device_register(&msm7x30_device_acpuclk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006956 if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid())
6957 msm7x30_cfg_smsc911x();
6958
6959#ifdef CONFIG_USB_MSM_OTG_72K
6960 if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 &&
6961 SOCINFO_VERSION_MINOR(soc_version) >= 1) {
6962 pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
6963 msm_otg_pdata.ldo_set_voltage = 0;
6964 }
6965
6966 msm_device_otg.dev.platform_data = &msm_otg_pdata;
6967#ifdef CONFIG_USB_GADGET
6968 msm_otg_pdata.swfi_latency =
6969 msm_pm_data
6970 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
6971 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
6972#endif
6973#endif
6974 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
6975 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
6976#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6977 msm_device_tsif.dev.platform_data = &tsif_platform_data;
6978#endif
6979 if (machine_is_msm7x30_fluid()) {
6980 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
6981 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
6982 } else {
6983 msm_adc_pdata.dev_names = msm_adc_surf_device_names;
6984 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names);
6985 }
6986
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306987 pmic8058_leds_init();
6988
6989 buses_init();
6990
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306991#ifdef CONFIG_MSM_SSBI
6992 msm_device_ssbi_pmic1.dev.platform_data =
6993 &msm7x30_ssbi_pm8058_pdata;
6994#endif
6995
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006996 platform_add_devices(msm_footswitch_devices,
6997 msm_num_footswitch_devices);
Daniel Walker8d747cd2010-02-25 11:37:43 -08006998 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006999#ifdef CONFIG_USB_EHCI_MSM_72K
7000 msm_add_host(0, &msm_usb_host_pdata);
7001#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07007002#ifdef CONFIG_MSM_CAMERA_V4L2
7003 msm7x30_init_cam();
7004#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007005 msm7x30_init_mmc();
7006 msm7x30_init_nand();
7007 msm_qsd_spi_init();
7008
7009#ifdef CONFIG_SPI_QSD
7010 if (machine_is_msm7x30_fluid())
7011 spi_register_board_info(lcdc_sharp_spi_board_info,
7012 ARRAY_SIZE(lcdc_sharp_spi_board_info));
7013 else
7014 spi_register_board_info(lcdc_toshiba_spi_board_info,
7015 ARRAY_SIZE(lcdc_toshiba_spi_board_info));
7016#endif
7017
Justin Paupore3f40f342011-08-10 18:52:16 -07007018 atv_dac_power_init();
7019 sensors_ldo_init();
7020 hdmi_init_regs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007021 msm_fb_add_devices();
7022 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06007023 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05307024 msm_pm_register_irqs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007025 msm_device_i2c_init();
7026 msm_device_i2c_2_init();
7027 qup_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007028 msm7x30_init_marimba();
7029#ifdef CONFIG_MSM7KV2_AUDIO
7030 snddev_poweramp_gpio_init();
Justin Paupore3f40f342011-08-10 18:52:16 -07007031 snddev_hsed_voltage_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007032 aux_pcm_gpio_init();
7033#endif
7034
7035 i2c_register_board_info(0, msm_i2c_board_info,
7036 ARRAY_SIZE(msm_i2c_board_info));
7037
7038 if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid())
7039 marimba_pdata.tsadc = &marimba_tsadc_pdata;
7040
7041 if (machine_is_msm7x30_fluid())
7042 i2c_register_board_info(0, cy8info,
7043 ARRAY_SIZE(cy8info));
7044#ifdef CONFIG_BOSCH_BMA150
7045 if (machine_is_msm7x30_fluid())
7046 i2c_register_board_info(0, bma150_board_info,
7047 ARRAY_SIZE(bma150_board_info));
7048#endif
7049
7050 i2c_register_board_info(2, msm_marimba_board_info,
7051 ARRAY_SIZE(msm_marimba_board_info));
7052
7053 i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info,
7054 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info));
7055
7056 i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
7057 ARRAY_SIZE(msm_camera_boardinfo));
7058
7059 bt_power_init();
7060#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007061 msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
7062#endif
7063 if (machine_is_msm7x30_fluid())
7064 i2c_register_board_info(0, msm_isa1200_board_info,
7065 ARRAY_SIZE(msm_isa1200_board_info));
7066
7067#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
7068 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
7069 if (machine_is_msm8x55_svlte_ffa())
7070 i2c_register_board_info(2, tsc_i2c_board_info,
7071 ARRAY_SIZE(tsc_i2c_board_info));
7072#endif
7073
7074 if (machine_is_msm7x30_surf())
7075 platform_device_register(&flip_switch_device);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307076
7077 pm8058_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007078
7079 if (machine_is_msm7x30_fluid()) {
7080 /* Initialize platform data for fluid v2 hardware */
7081 if (SOCINFO_VERSION_MAJOR(
7082 socinfo_get_platform_version()) == 2) {
7083 cy8ctma300_pdata.res_y = 920;
7084 cy8ctma300_pdata.invert_y = 0;
7085 }
7086 i2c_register_board_info(0, cy8ctma300_board_info,
7087 ARRAY_SIZE(cy8ctma300_board_info));
7088 }
7089
7090 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
7091 rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE);
7092 if (rc)
7093 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
7094 __func__, usb_hub_gpio_cfg_value, rc);
7095 }
7096
7097 boot_reason = *(unsigned int *)
7098 (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
7099 printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
7100}
7101
7102static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
7103static int __init pmem_sf_size_setup(char *p)
7104{
7105 pmem_sf_size = memparse(p, NULL);
7106 return 0;
7107}
7108early_param("pmem_sf_size", pmem_sf_size_setup);
7109
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307110static unsigned fb_size;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007111static int __init fb_size_setup(char *p)
7112{
7113 fb_size = memparse(p, NULL);
7114 return 0;
7115}
7116early_param("fb_size", fb_size_setup);
7117
7118static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
7119static int __init pmem_adsp_size_setup(char *p)
7120{
7121 pmem_adsp_size = memparse(p, NULL);
7122 return 0;
7123}
7124early_param("pmem_adsp_size", pmem_adsp_size_setup);
7125
7126static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE;
7127static int __init fluid_pmem_adsp_size_setup(char *p)
7128{
7129 fluid_pmem_adsp_size = memparse(p, NULL);
7130 return 0;
7131}
7132early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup);
7133
7134static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
7135static int __init pmem_audio_size_setup(char *p)
7136{
7137 pmem_audio_size = memparse(p, NULL);
7138 return 0;
7139}
7140early_param("pmem_audio_size", pmem_audio_size_setup);
7141
7142static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE;
7143static int __init pmem_kernel_ebi0_size_setup(char *p)
7144{
7145 pmem_kernel_ebi0_size = memparse(p, NULL);
7146 return 0;
7147}
7148early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
7149
Chintan Pandya03b698a2012-06-28 19:03:09 +05307150#ifdef CONFIG_ION_MSM
7151#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
7152static struct ion_co_heap_pdata co_ion_pdata = {
7153 .adjacent_mem_id = INVALID_HEAP_ID,
7154 .align = PAGE_SIZE,
7155};
7156#endif
7157
7158/**
7159 * These heaps are listed in the order they will be allocated.
7160 * Don't swap the order unless you know what you are doing!
7161 */
7162static struct ion_platform_data ion_pdata = {
7163 .nr = MSM_ION_HEAP_NUM,
7164 .heaps = {
7165 {
7166 .id = ION_SYSTEM_HEAP_ID,
7167 .type = ION_HEAP_TYPE_SYSTEM,
7168 .name = ION_VMALLOC_HEAP_NAME,
7169 },
7170#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
7171 /* PMEM_ADSP = CAMERA */
7172 {
7173 .id = ION_CAMERA_HEAP_ID,
7174 .type = ION_HEAP_TYPE_CARVEOUT,
7175 .name = ION_CAMERA_HEAP_NAME,
7176 .memory_type = ION_EBI_TYPE,
Chintan Pandya03b698a2012-06-28 19:03:09 +05307177 .extra_data = (void *)&co_ion_pdata,
7178 },
7179 /* PMEM_AUDIO */
7180 {
7181 .id = ION_AUDIO_HEAP_ID,
7182 .type = ION_HEAP_TYPE_CARVEOUT,
7183 .name = ION_AUDIO_HEAP_NAME,
7184 .memory_type = ION_EBI_TYPE,
Chintan Pandya03b698a2012-06-28 19:03:09 +05307185 .extra_data = (void *)&co_ion_pdata,
7186 },
7187 /* PMEM_MDP = SF */
7188 {
7189 .id = ION_SF_HEAP_ID,
7190 .type = ION_HEAP_TYPE_CARVEOUT,
7191 .name = ION_SF_HEAP_NAME,
7192 .memory_type = ION_EBI_TYPE,
Chintan Pandya03b698a2012-06-28 19:03:09 +05307193 .extra_data = (void *)&co_ion_pdata,
7194 },
7195#endif
7196 }
7197};
7198
7199static struct platform_device ion_dev = {
7200 .name = "ion-msm",
7201 .id = 1,
7202 .dev = { .platform_data = &ion_pdata },
7203};
7204#endif
7205
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007206static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
7207 [MEMTYPE_SMI] = {
7208 },
7209 [MEMTYPE_EBI0] = {
7210 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7211 },
7212 [MEMTYPE_EBI1] = {
7213 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7214 },
7215};
7216
Chintan Pandya03b698a2012-06-28 19:03:09 +05307217unsigned long size;
7218unsigned long msm_ion_camera_size;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007219
Chintan Pandya03b698a2012-06-28 19:03:09 +05307220static void fix_sizes(void)
7221{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007222 if machine_is_msm7x30_fluid()
7223 size = fluid_pmem_adsp_size;
7224 else
7225 size = pmem_adsp_size;
Chintan Pandya03b698a2012-06-28 19:03:09 +05307226
7227#ifdef CONFIG_ION_MSM
7228 msm_ion_camera_size = size;
7229#endif
7230}
7231
7232static void __init size_pmem_devices(void)
7233{
7234#ifdef CONFIG_ANDROID_PMEM
7235#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
7236
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007237 android_pmem_adsp_pdata.size = size;
7238 android_pmem_audio_pdata.size = pmem_audio_size;
7239 android_pmem_pdata.size = pmem_sf_size;
7240#endif
Chintan Pandya03b698a2012-06-28 19:03:09 +05307241#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007242}
7243
Chintan Pandya03b698a2012-06-28 19:03:09 +05307244#ifdef CONFIG_ANDROID_PMEM
7245#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007246static void __init reserve_memory_for(struct android_pmem_platform_data *p)
7247{
7248 msm7x30_reserve_table[p->memory_type].size += p->size;
7249}
Chintan Pandya03b698a2012-06-28 19:03:09 +05307250#endif
7251#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007252
7253static void __init reserve_pmem_memory(void)
7254{
7255#ifdef CONFIG_ANDROID_PMEM
Chintan Pandya03b698a2012-06-28 19:03:09 +05307256#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007257 reserve_memory_for(&android_pmem_adsp_pdata);
7258 reserve_memory_for(&android_pmem_audio_pdata);
7259 reserve_memory_for(&android_pmem_pdata);
7260 msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
7261#endif
Chintan Pandya03b698a2012-06-28 19:03:09 +05307262#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007263}
7264
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307265static void __init reserve_mdp_memory(void)
7266{
7267 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
7268 msm7x30_reserve_table[mdp_pdata.mem_hid].size += mdp_pdata.ov0_wb_size;
7269}
7270
Chintan Pandya03b698a2012-06-28 19:03:09 +05307271static void __init size_ion_devices(void)
7272{
7273#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
7274 ion_pdata.heaps[1].size = msm_ion_camera_size;
7275 ion_pdata.heaps[2].size = MSM_ION_AUDIO_SIZE;
7276 ion_pdata.heaps[3].size = MSM_ION_SF_SIZE;
7277#endif
7278}
7279
7280static void __init reserve_ion_memory(void)
7281{
7282#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
7283 msm7x30_reserve_table[MEMTYPE_EBI0].size += msm_ion_camera_size;
7284 msm7x30_reserve_table[MEMTYPE_EBI0].size += MSM_ION_AUDIO_SIZE;
7285 msm7x30_reserve_table[MEMTYPE_EBI0].size += MSM_ION_SF_SIZE;
7286#endif
7287}
7288
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007289static void __init msm7x30_calculate_reserve_sizes(void)
7290{
Chintan Pandya03b698a2012-06-28 19:03:09 +05307291 fix_sizes();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007292 size_pmem_devices();
7293 reserve_pmem_memory();
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307294 reserve_mdp_memory();
Chintan Pandya03b698a2012-06-28 19:03:09 +05307295 size_ion_devices();
7296 reserve_ion_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007297}
7298
7299static int msm7x30_paddr_to_memtype(unsigned int paddr)
7300{
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307301 if (paddr < phys_add)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007302 return MEMTYPE_EBI0;
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307303 if (paddr >= phys_add && paddr < 0x80000000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007304 return MEMTYPE_EBI1;
7305 return MEMTYPE_NONE;
7306}
7307
7308static struct reserve_info msm7x30_reserve_info __initdata = {
7309 .memtype_reserve_table = msm7x30_reserve_table,
7310 .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes,
7311 .paddr_to_memtype = msm7x30_paddr_to_memtype,
7312};
7313
7314static void __init msm7x30_reserve(void)
7315{
7316 reserve_info = &msm7x30_reserve_info;
7317 msm_reserve();
7318}
7319
7320static void __init msm7x30_allocate_memory_regions(void)
7321{
7322 void *addr;
7323 unsigned long size;
7324
7325 size = fb_size ? : MSM_FB_SIZE;
7326 addr = alloc_bootmem_align(size, 0x1000);
7327 msm_fb_resources[0].start = __pa(addr);
7328 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
7329 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
7330 size, addr, __pa(addr));
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08007331
7332#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
7333 size = MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE;
7334 addr = alloc_bootmem_align(size, 0x1000);
7335 msm_v4l2_video_overlay_resources[0].start = __pa(addr);
7336 msm_v4l2_video_overlay_resources[0].end =
7337 msm_v4l2_video_overlay_resources[0].start + size - 1;
7338 pr_debug("allocating %lu bytes at %p (%lx physical) for v4l2\n",
7339 size, addr, __pa(addr));
7340#endif
Daniel Walker8d747cd2010-02-25 11:37:43 -08007341}
7342
7343static void __init msm7x30_map_io(void)
7344{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007345 msm_shared_ram_phys = 0x00100000;
Daniel Walker8d747cd2010-02-25 11:37:43 -08007346 msm_map_msm7x30_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007347 if (socinfo_init() < 0)
7348 printk(KERN_ERR "%s: socinfo_init() failed!\n",
7349 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007350}
7351
7352static void __init msm7x30_init_early(void)
7353{
7354 msm7x30_allocate_memory_regions();
Daniel Walker8d747cd2010-02-25 11:37:43 -08007355}
7356
Steve Mucklef132c6c2012-06-06 18:30:57 -07007357static void __init msm7x30_fixup(struct tag *tags, char **cmdline,
7358 struct meminfo *mi)
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307359{
7360 for (; tags->hdr.size; tags = tag_next(tags)) {
7361 if (tags->hdr.tag == ATAG_MEM && tags->u.mem.start ==
7362 DDR1_BANK_BASE) {
7363 ebi1_phys_offset = DDR1_BANK_BASE;
7364 phys_add = DDR1_BANK_BASE;
7365 break;
7366 }
7367 }
Daniel Walker8d747cd2010-02-25 11:37:43 -08007368}
7369
7370MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
Nicolas Pitref631dd42011-07-05 22:38:14 -04007371 .atag_offset = 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007372 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007373 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007374 .init_irq = msm7x30_init_irq,
7375 .init_machine = msm7x30_init,
7376 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007377 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307378 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307379 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007380MACHINE_END
7381
7382MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
Nicolas Pitref631dd42011-07-05 22:38:14 -04007383 .atag_offset = 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007384 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007385 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007386 .init_irq = msm7x30_init_irq,
7387 .init_machine = msm7x30_init,
7388 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007389 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307390 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307391 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007392MACHINE_END
7393
7394MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
Nicolas Pitref631dd42011-07-05 22:38:14 -04007395 .atag_offset = 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007396 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007397 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007398 .init_irq = msm7x30_init_irq,
7399 .init_machine = msm7x30_init,
7400 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007401 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307402 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307403 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007404MACHINE_END
7405
7406MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007407 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007408 .map_io = msm7x30_map_io,
7409 .reserve = msm7x30_reserve,
7410 .init_irq = msm7x30_init_irq,
7411 .init_machine = msm7x30_init,
7412 .timer = &msm_timer,
7413 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307414 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307415 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007416MACHINE_END
7417
7418MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007419 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007420 .map_io = msm7x30_map_io,
7421 .reserve = msm7x30_reserve,
7422 .init_irq = msm7x30_init_irq,
7423 .init_machine = msm7x30_init,
7424 .timer = &msm_timer,
7425 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307426 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307427 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007428MACHINE_END
7429MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007430 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007431 .map_io = msm7x30_map_io,
7432 .reserve = msm7x30_reserve,
7433 .init_irq = msm7x30_init_irq,
7434 .init_machine = msm7x30_init,
7435 .timer = &msm_timer,
7436 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307437 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307438 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007439MACHINE_END
7440MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007441 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007442 .map_io = msm7x30_map_io,
7443 .reserve = msm7x30_reserve,
7444 .init_irq = msm7x30_init_irq,
7445 .init_machine = msm7x30_init,
7446 .timer = &msm_timer,
7447 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307448 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307449 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007450MACHINE_END