blob: 0654a0d1382ecbf5641cc7e83de792be089b2d08 [file] [log] [blame]
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08001/* Copyright (c) 2009-2013, The Linux Foundation. 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
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -080014#include <linux/err.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080015#include <linux/kernel.h>
16#include <linux/irq.h>
17#include <linux/gpio.h>
18#include <linux/platform_device.h>
19#include <linux/delay.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070020#include <linux/bootmem.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080021#include <linux/io.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070022#ifdef CONFIG_SPI_QSD
23#include <linux/spi/spi.h>
24#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +053025#include <linux/msm_ssbi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070026#include <linux/mfd/pmic8058.h>
Anirudh Ghayalc2019332011-11-12 06:29:10 +053027#include <linux/leds.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070028#include <linux/mfd/marimba.h>
29#include <linux/i2c.h>
30#include <linux/input.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080031#include <linux/smsc911x.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070032#include <linux/ofn_atlab.h>
33#include <linux/power_supply.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070034#include <linux/i2c/isa1200.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070035#include <linux/i2c/tsc2007.h>
36#include <linux/input/kp_flip_switch.h>
37#include <linux/leds-pmic8058.h>
38#include <linux/input/cy8c_ts.h>
39#include <linux/msm_adc.h>
40#include <linux/dma-mapping.h>
Justin Paupore3f40f342011-08-10 18:52:16 -070041#include <linux/regulator/consumer.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080042
43#include <asm/mach-types.h>
44#include <asm/mach/arch.h>
45#include <asm/setup.h>
46
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070047#include <mach/mpp.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080048#include <mach/board.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070049#include <mach/camera.h>
50#include <mach/memory.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080051#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070052#include <mach/msm_hsusb.h>
53#include <mach/rpc_hsusb.h>
54#include <mach/msm_spi.h>
55#include <mach/qdsp5v2/msm_lpa.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080056#include <mach/dma.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070057#include <linux/android_pmem.h>
58#include <linux/input/msm_ts.h>
59#include <mach/pmic.h>
60#include <mach/rpc_pmapp.h>
61#include <mach/qdsp5v2/aux_pcm.h>
62#include <mach/qdsp5v2/mi2s.h>
63#include <mach/qdsp5v2/audio_dev_ctl.h>
64#include <mach/msm_battery.h>
65#include <mach/rpc_server_handset.h>
66#include <mach/msm_tsif.h>
67#include <mach/socinfo.h>
68#include <mach/msm_memtypes.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070069#include <linux/cyttsp-qc.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080070
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070071#include <asm/mach/mmc.h>
72#include <asm/mach/flash.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080073#include <mach/vreg.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070074#include <linux/platform_data/qcom_crypto_device.h>
75
Daniel Walker8d747cd2010-02-25 11:37:43 -080076#include "devices.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070077#include "timer.h"
78#ifdef CONFIG_USB_G_ANDROID
79#include <linux/usb/android.h>
80#include <mach/usbdiag.h>
81#endif
Matt Wagantall7cca4642012-02-01 16:43:24 -080082#include "pm.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -060083#include "pm-boot.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070084#include "spm.h"
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070085#include "acpuclock.h"
Matt Wagantall33d01f52012-02-23 23:27:44 -080086#include "clock.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070087#include <mach/dal_axi.h>
88#include <mach/msm_serial_hs.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070089#include <mach/qdsp5v2/mi2s.h>
90#include <mach/qdsp5v2/audio_dev_ctl.h>
91#include <mach/sdio_al.h>
92#include "smd_private.h"
93#include <linux/bma150.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080094
Justin Paupore637a25d2011-07-14 17:11:04 -070095#include "board-msm7x30-regulator.h"
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +053096#include "pm.h"
Daniel Walker90e37c52010-05-12 14:24:15 -070097
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070098#define MSM_PMEM_SF_SIZE 0x1700000
99#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Mayank Chopraaed3b4b2012-02-29 11:54:18 +0530100#define MSM_FB_PRIM_BUF_SIZE (864 * 480 * 4 * 3) /* 4bpp * 3 Pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700101#else
Mayank Chopraaed3b4b2012-02-29 11:54:18 +0530102#define MSM_FB_PRIM_BUF_SIZE (864 * 480 * 4 * 2) /* 4bpp * 2 Pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700103#endif
Alhad Purnapatrec55856c2012-02-28 13:24:57 -0800104/*
105 * Reserve space for double buffered full screen
106 * res V4L2 video overlay - i.e. 1280x720x1.5x2
107 */
108#define MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE 2764800
Mayank Chopraaed3b4b2012-02-29 11:54:18 +0530109
Jeevan Shrirama7d44142012-06-14 15:55:25 +0530110#ifdef CONFIG_FB_MSM_HDMI_ADV7520_PANEL
Mayank Chopraaed3b4b2012-02-29 11:54:18 +0530111#define MSM_FB_EXT_BUF_SIZE (1280 * 720 * 2 * 1) /* 2 bpp x 1 page */
112#else
113#define MSM_FB_EXT_BUF_SIZE 0
114#endif
115
116#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
117/* width x height x 3 bpp x 2 frame buffer */
118#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((864 * 480 * 3 * 2), 4096)
119#else
120#define MSM_FB_OVERLAY0_WRITEBACK_SIZE 0
121#endif
122
123#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE, 4096)
124
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700125#define MSM_PMEM_ADSP_SIZE 0x1E00000
126#define MSM_FLUID_PMEM_ADSP_SIZE 0x2800000
127#define PMEM_KERNEL_EBI0_SIZE 0x600000
128#define MSM_PMEM_AUDIO_SIZE 0x200000
Daniel Walker90e37c52010-05-12 14:24:15 -0700129
Chintan Pandya03b698a2012-06-28 19:03:09 +0530130#ifdef CONFIG_ION_MSM
131static struct platform_device ion_dev;
132#define MSM_ION_AUDIO_SIZE (MSM_PMEM_AUDIO_SIZE + PMEM_KERNEL_EBI0_SIZE)
133#define MSM_ION_SF_SIZE MSM_PMEM_SF_SIZE
134#define MSM_ION_HEAP_NUM 4
135#endif
136
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700137#define PMIC_GPIO_INT 27
138#define PMIC_VREG_WLAN_LEVEL 2900
139#define PMIC_GPIO_SD_DET 36
140#define PMIC_GPIO_SDC4_EN_N 17 /* PMIC GPIO Number 18 */
141#define PMIC_GPIO_HDMI_5V_EN_V3 32 /* PMIC GPIO for V3 H/W */
142#define PMIC_GPIO_HDMI_5V_EN_V2 39 /* PMIC GPIO for V2 H/W */
143
144#define ADV7520_I2C_ADDR 0x39
145
146#define FPGA_SDCC_STATUS 0x8E0001A8
147
148#define FPGA_OPTNAV_GPIO_ADDR 0x8E000026
149#define OPTNAV_I2C_SLAVE_ADDR (0xB0 >> 1)
150#define OPTNAV_IRQ 20
151#define OPTNAV_CHIP_SELECT 19
Asutosh Das853bbcd2012-02-01 10:40:05 +0530152#define PMIC_GPIO_SDC4_PWR_EN_N 24 /* PMIC GPIO Number 25 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700153
154/* Macros assume PMIC GPIOs start at 0 */
155#define PM8058_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio + NR_GPIO_IRQS)
156#define PM8058_GPIO_SYS_TO_PM(sys_gpio) (sys_gpio - NR_GPIO_IRQS)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530157#define PM8058_MPP_BASE PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS)
158#define PM8058_MPP_PM_TO_SYS(pm_gpio) (pm_gpio + PM8058_MPP_BASE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700159
160#define PMIC_GPIO_FLASH_BOOST_ENABLE 15 /* PMIC GPIO Number 16 */
161#define PMIC_GPIO_HAP_ENABLE 16 /* PMIC GPIO Number 17 */
162
163#define PMIC_GPIO_WLAN_EXT_POR 22 /* PMIC GPIO NUMBER 23 */
164
165#define BMA150_GPIO_INT 1
166
167#define HAP_LVL_SHFT_MSM_GPIO 24
168
169#define PMIC_GPIO_QUICKVX_CLK 37 /* PMIC GPIO 38 */
170
171#define PM_FLIP_MPP 5 /* PMIC MPP 06 */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530172
Pankaj Kumarac69ee62012-01-26 00:21:56 +0530173#define DDR1_BANK_BASE 0X20000000
174#define DDR2_BANK_BASE 0X40000000
175
176static unsigned int phys_add = DDR2_BANK_BASE;
177unsigned long ebi1_phys_offset = DDR2_BANK_BASE;
178EXPORT_SYMBOL(ebi1_phys_offset);
179
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530180struct pm8xxx_gpio_init_info {
181 unsigned gpio;
182 struct pm_gpio config;
183};
184
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700185static int pm8058_gpios_init(void)
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100186{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700187 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700188
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530189 struct pm8xxx_gpio_init_info sdc4_en = {
190 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_EN_N),
191 {
192 .direction = PM_GPIO_DIR_OUT,
193 .pull = PM_GPIO_PULL_NO,
194 .vin_sel = PM8058_GPIO_VIN_L5,
195 .function = PM_GPIO_FUNC_NORMAL,
196 .inv_int_pol = 0,
197 .out_strength = PM_GPIO_STRENGTH_LOW,
198 .output_value = 0,
199 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700200 };
201
Asutosh Das853bbcd2012-02-01 10:40:05 +0530202 struct pm8xxx_gpio_init_info sdc4_pwr_en = {
203 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
204 {
205 .direction = PM_GPIO_DIR_OUT,
206 .pull = PM_GPIO_PULL_NO,
207 .vin_sel = PM8058_GPIO_VIN_L5,
208 .function = PM_GPIO_FUNC_NORMAL,
209 .inv_int_pol = 0,
210 .out_strength = PM_GPIO_STRENGTH_LOW,
211 .output_value = 0,
212 },
213 };
214
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530215 struct pm8xxx_gpio_init_info haptics_enable = {
216 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
217 {
218 .direction = PM_GPIO_DIR_OUT,
219 .pull = PM_GPIO_PULL_NO,
220 .out_strength = PM_GPIO_STRENGTH_HIGH,
221 .function = PM_GPIO_FUNC_NORMAL,
222 .inv_int_pol = 0,
223 .vin_sel = 2,
224 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
225 .output_value = 0,
226 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700227 };
228
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530229 struct pm8xxx_gpio_init_info hdmi_5V_en = {
230 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HDMI_5V_EN_V3),
231 {
232 .direction = PM_GPIO_DIR_OUT,
233 .pull = PM_GPIO_PULL_NO,
234 .vin_sel = PM8058_GPIO_VIN_VPH,
235 .function = PM_GPIO_FUNC_NORMAL,
236 .out_strength = PM_GPIO_STRENGTH_LOW,
237 .output_value = 0,
238 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700239 };
240
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530241 struct pm8xxx_gpio_init_info flash_boost_enable = {
242 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE),
243 {
244 .direction = PM_GPIO_DIR_OUT,
245 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
246 .output_value = 0,
247 .pull = PM_GPIO_PULL_NO,
248 .vin_sel = PM8058_GPIO_VIN_S3,
249 .out_strength = PM_GPIO_STRENGTH_HIGH,
250 .function = PM_GPIO_FUNC_2,
251 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700252 };
253
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530254 struct pm8xxx_gpio_init_info gpio23 = {
255 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_WLAN_EXT_POR),
256 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700257 .direction = PM_GPIO_DIR_OUT,
258 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
259 .output_value = 0,
260 .pull = PM_GPIO_PULL_NO,
261 .vin_sel = 2,
262 .out_strength = PM_GPIO_STRENGTH_LOW,
263 .function = PM_GPIO_FUNC_NORMAL,
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100264 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700265 };
266
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530267 struct pm8xxx_gpio_init_info sdcc_det = {
268 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1),
269 {
270 .direction = PM_GPIO_DIR_IN,
271 .pull = PM_GPIO_PULL_UP_1P5,
272 .vin_sel = 2,
273 .function = PM_GPIO_FUNC_NORMAL,
274 .inv_int_pol = 0,
275 },
276 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700277
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530278 if (machine_is_msm7x30_fluid())
279 sdcc_det.config.inv_int_pol = 1;
280
281 rc = pm8xxx_gpio_config(sdcc_det.gpio, &sdcc_det.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700282 if (rc) {
283 pr_err("%s PMIC_GPIO_SD_DET config failed\n", __func__);
284 return rc;
285 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700286
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530287 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
288 machine_is_msm7x30_fluid())
289 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V2;
290 else
291 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V3;
292
293 hdmi_5V_en.gpio = PM8058_GPIO_PM_TO_SYS(hdmi_5V_en.gpio);
294
295 rc = pm8xxx_gpio_config(hdmi_5V_en.gpio, &hdmi_5V_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700296 if (rc) {
297 pr_err("%s PMIC_GPIO_HDMI_5V_EN config failed\n", __func__);
298 return rc;
299 }
300
301 /* Deassert GPIO#23 (source for Ext_POR on WLAN-Volans) */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530302 rc = pm8xxx_gpio_config(gpio23.gpio, &gpio23.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700303 if (rc) {
304 pr_err("%s PMIC_GPIO_WLAN_EXT_POR config failed\n", __func__);
305 return rc;
306 }
307
308 if (machine_is_msm7x30_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530309 /* Haptics gpio */
310 rc = pm8xxx_gpio_config(haptics_enable.gpio,
311 &haptics_enable.config);
312 if (rc) {
313 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
314 haptics_enable.gpio);
315 return rc;
316 }
317 /* Flash boost gpio */
318 rc = pm8xxx_gpio_config(flash_boost_enable.gpio,
319 &flash_boost_enable.config);
320 if (rc) {
321 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
322 flash_boost_enable.gpio);
323 return rc;
324 }
325 /* SCD4 gpio */
326 rc = pm8xxx_gpio_config(sdc4_en.gpio, &sdc4_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700327 if (rc) {
328 pr_err("%s PMIC_GPIO_SDC4_EN_N config failed\n",
329 __func__);
330 return rc;
331 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530332 rc = gpio_request(sdc4_en.gpio, "sdc4_en");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700333 if (rc) {
334 pr_err("%s PMIC_GPIO_SDC4_EN_N gpio_request failed\n",
335 __func__);
336 return rc;
337 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530338 gpio_set_value_cansleep(sdc4_en.gpio, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700339 }
Asutosh Das853bbcd2012-02-01 10:40:05 +0530340 /* FFA -> gpio_25 controls vdd of sdcc4 */
341 else {
342 /* SCD4 gpio_25 */
343 rc = pm8xxx_gpio_config(sdc4_pwr_en.gpio, &sdc4_pwr_en.config);
344 if (rc) {
345 pr_err("%s PMIC_GPIO_SDC4_PWR_EN_N config failed: %d\n",
346 __func__, rc);
347 return rc;
348 }
349
350 rc = gpio_request(sdc4_pwr_en.gpio, "sdc4_pwr_en");
351 if (rc) {
352 pr_err("PMIC_GPIO_SDC4_PWR_EN_N gpio_req failed: %d\n",
353 rc);
354 return rc;
355 }
356 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700357
358 return 0;
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100359}
360
Justin Paupore637a25d2011-07-14 17:11:04 -0700361/* Regulator API support */
362
363#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
364static struct platform_device msm_proccomm_regulator_dev = {
365 .name = PROCCOMM_REGULATOR_DEV_NAME,
366 .id = -1,
367 .dev = {
368 .platform_data = &msm7x30_proccomm_regulator_data
369 }
370};
371#endif
372
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700373/*virtual key support */
374static ssize_t tma300_vkeys_show(struct kobject *kobj,
375 struct kobj_attribute *attr, char *buf)
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100376{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700377 return sprintf(buf,
378 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":50:842:80:100"
379 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":170:842:80:100"
380 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":290:842:80:100"
381 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":410:842:80:100"
382 "\n");
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100383}
384
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700385static struct kobj_attribute tma300_vkeys_attr = {
386 .attr = {
387 .mode = S_IRUGO,
388 },
389 .show = &tma300_vkeys_show,
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530390};
391
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700392static struct attribute *tma300_properties_attrs[] = {
393 &tma300_vkeys_attr.attr,
394 NULL
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530395};
396
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700397static struct attribute_group tma300_properties_attr_group = {
398 .attrs = tma300_properties_attrs,
399};
400
401static struct kobject *properties_kobj;
Justin Paupore3f40f342011-08-10 18:52:16 -0700402static struct regulator_bulk_data cyttsp_regs[] = {
403 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
404 { .supply = "ldo15", .min_uV = 3050000, .max_uV = 3100000 },
405};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700406
407#define CYTTSP_TS_GPIO_IRQ 150
408static int cyttsp_platform_init(struct i2c_client *client)
409{
410 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700411
Justin Paupore3f40f342011-08-10 18:52:16 -0700412 rc = regulator_bulk_get(NULL, ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700413
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700414 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700415 pr_err("%s: could not get regulators: %d\n", __func__, rc);
416 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700417 }
418
Justin Paupore3f40f342011-08-10 18:52:16 -0700419 rc = regulator_bulk_set_voltage(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
420
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700421 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700422 pr_err("%s: could not set regulator voltages: %d\n", __func__,
423 rc);
424 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700425 }
426
Justin Paupore3f40f342011-08-10 18:52:16 -0700427 rc = regulator_bulk_enable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700428
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700429 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700430 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
431 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700432 }
433
434 /* check this device active by reading first byte/register */
435 rc = i2c_smbus_read_byte_data(client, 0x01);
436 if (rc < 0) {
437 pr_err("%s: i2c sanity check failed\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -0700438 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700439 }
440
441 rc = gpio_tlmm_config(GPIO_CFG(CYTTSP_TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
442 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
443 if (rc) {
444 pr_err("%s: Could not configure gpio %d\n",
445 __func__, CYTTSP_TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -0700446 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700447 }
448
449 /* virtual keys */
450 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
451 properties_kobj = kobject_create_and_add("board_properties",
452 NULL);
453 if (properties_kobj)
454 rc = sysfs_create_group(properties_kobj,
455 &tma300_properties_attr_group);
456 if (!properties_kobj || rc)
457 pr_err("%s: failed to create board_properties\n",
458 __func__);
459
460 return CY_OK;
461
Justin Paupore3f40f342011-08-10 18:52:16 -0700462regs_disable:
463 regulator_bulk_disable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
464regs_free:
465 regulator_bulk_free(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
466out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700467 return rc;
468}
469
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530470/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
471static int cyttsp_platform_suspend(struct i2c_client *client)
472{
473 msleep(20);
474
475 return CY_OK;
476}
477
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700478static int cyttsp_platform_resume(struct i2c_client *client)
479{
480 /* add any special code to strobe a wakeup pin or chip reset */
481 mdelay(10);
482
483 return CY_OK;
484}
485
486static struct cyttsp_platform_data cyttsp_data = {
487 .fw_fname = "cyttsp_7630_fluid.hex",
488 .panel_maxx = 479,
489 .panel_maxy = 799,
490 .disp_maxx = 469,
491 .disp_maxy = 799,
492 .disp_minx = 10,
493 .disp_miny = 0,
494 .flags = 0,
495 .gen = CY_GEN3, /* or */
496 .use_st = CY_USE_ST,
497 .use_mt = CY_USE_MT,
498 .use_hndshk = CY_SEND_HNDSHK,
499 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +0530500 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700501 .use_gestures = CY_USE_GESTURES,
502 /* activate up to 4 groups
503 * and set active distance
504 */
505 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
506 CY_GEST_GRP3 | CY_GEST_GRP4 |
507 CY_ACT_DIST,
508 /* change act_intrvl to customize the Active power state
509 * scanning/processing refresh interval for Operating mode
510 */
511 .act_intrvl = CY_ACT_INTRVL_DFLT,
512 /* change tch_tmout to customize the touch timeout for the
513 * Active power state for Operating mode
514 */
515 .tch_tmout = CY_TCH_TMOUT_DFLT,
516 /* change lp_intrvl to customize the Low Power power state
517 * scanning/processing refresh interval for Operating mode
518 */
519 .lp_intrvl = CY_LP_INTRVL_DFLT,
520 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530521 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700522 .init = cyttsp_platform_init,
523 .sleep_gpio = -1,
524 .resout_gpio = -1,
525 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
Mohan Pallaka49c37d62011-08-01 11:52:00 +0530526 .correct_fw_ver = 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700527};
528
529static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
530{
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530531 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700532 .direction = PM_GPIO_DIR_OUT,
533 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
534 .output_value = 0,
535 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530536 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700537 .out_strength = PM_GPIO_STRENGTH_HIGH,
538 .function = PM_GPIO_FUNC_2,
539 };
540 int rc = -EINVAL;
541 int id, mode, max_mA;
542
543 id = mode = max_mA = 0;
544 switch (ch) {
545 case 0:
546 case 1:
547 case 2:
548 if (on) {
549 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530550 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
551 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700552 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530553 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700554 __func__, id, rc);
555 }
556 break;
557
558 case 3:
559 id = PM_PWM_LED_KPD;
560 mode = PM_PWM_CONF_DTEST3;
561 max_mA = 200;
562 break;
563
564 case 4:
565 id = PM_PWM_LED_0;
566 mode = PM_PWM_CONF_PWM1;
567 max_mA = 40;
568 break;
569
570 case 5:
571 id = PM_PWM_LED_2;
572 mode = PM_PWM_CONF_PWM2;
573 max_mA = 40;
574 break;
575
576 case 6:
577 id = PM_PWM_LED_FLASH;
578 mode = PM_PWM_CONF_DTEST3;
579 max_mA = 200;
580 break;
581
582 default:
583 break;
584 }
585
586 if (ch >= 3 && ch <= 6) {
587 if (!on) {
588 mode = PM_PWM_CONF_NONE;
589 max_mA = 0;
590 }
591 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
592 if (rc)
593 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
594 __func__, ch, rc);
595 }
596
597 return rc;
598}
599
600static int pm8058_pwm_enable(struct pwm_device *pwm, int ch, int on)
601{
602 int rc;
603
604 switch (ch) {
605 case 7:
606 rc = pm8058_pwm_set_dtest(pwm, on);
607 if (rc)
608 pr_err("%s: pwm_set_dtest(%d): rc=%d\n",
609 __func__, on, rc);
610 break;
611 default:
612 rc = -EINVAL;
613 break;
614 }
615 return rc;
616}
617
618static const unsigned int fluid_keymap[] = {
619 KEY(0, 0, KEY_7),
620 KEY(0, 1, KEY_ENTER),
621 KEY(0, 2, KEY_UP),
622 /* drop (0,3) as it always shows up in pair with(0,2) */
623 KEY(0, 4, KEY_DOWN),
624
625 KEY(1, 0, KEY_CAMERA_SNAPSHOT),
626 KEY(1, 1, KEY_SELECT),
627 KEY(1, 2, KEY_1),
628 KEY(1, 3, KEY_VOLUMEUP),
629 KEY(1, 4, KEY_VOLUMEDOWN),
630};
631
632static const unsigned int surf_keymap[] = {
633 KEY(0, 0, KEY_7),
634 KEY(0, 1, KEY_DOWN),
635 KEY(0, 2, KEY_UP),
636 KEY(0, 3, KEY_RIGHT),
637 KEY(0, 4, KEY_ENTER),
638 KEY(0, 5, KEY_L),
639 KEY(0, 6, KEY_BACK),
640 KEY(0, 7, KEY_M),
641
642 KEY(1, 0, KEY_LEFT),
643 KEY(1, 1, KEY_SEND),
644 KEY(1, 2, KEY_1),
645 KEY(1, 3, KEY_4),
646 KEY(1, 4, KEY_CLEAR),
647 KEY(1, 5, KEY_MSDOS),
648 KEY(1, 6, KEY_SPACE),
649 KEY(1, 7, KEY_COMMA),
650
651 KEY(2, 0, KEY_6),
652 KEY(2, 1, KEY_5),
653 KEY(2, 2, KEY_8),
654 KEY(2, 3, KEY_3),
655 KEY(2, 4, KEY_NUMERIC_STAR),
656 KEY(2, 5, KEY_UP),
657 KEY(2, 6, KEY_DOWN), /* SYN */
658 KEY(2, 7, KEY_LEFTSHIFT),
659
660 KEY(3, 0, KEY_9),
661 KEY(3, 1, KEY_NUMERIC_POUND),
662 KEY(3, 2, KEY_0),
663 KEY(3, 3, KEY_2),
664 KEY(3, 4, KEY_SLEEP),
665 KEY(3, 5, KEY_F1),
666 KEY(3, 6, KEY_F2),
667 KEY(3, 7, KEY_F3),
668
669 KEY(4, 0, KEY_BACK),
670 KEY(4, 1, KEY_HOME),
671 KEY(4, 2, KEY_MENU),
672 KEY(4, 3, KEY_VOLUMEUP),
673 KEY(4, 4, KEY_VOLUMEDOWN),
674 KEY(4, 5, KEY_F4),
675 KEY(4, 6, KEY_F5),
676 KEY(4, 7, KEY_F6),
677
678 KEY(5, 0, KEY_R),
679 KEY(5, 1, KEY_T),
680 KEY(5, 2, KEY_Y),
681 KEY(5, 3, KEY_LEFTALT),
682 KEY(5, 4, KEY_KPENTER),
683 KEY(5, 5, KEY_Q),
684 KEY(5, 6, KEY_W),
685 KEY(5, 7, KEY_E),
686
687 KEY(6, 0, KEY_F),
688 KEY(6, 1, KEY_G),
689 KEY(6, 2, KEY_H),
690 KEY(6, 3, KEY_CAPSLOCK),
691 KEY(6, 4, KEY_PAGEUP),
692 KEY(6, 5, KEY_A),
693 KEY(6, 6, KEY_S),
694 KEY(6, 7, KEY_D),
695
696 KEY(7, 0, KEY_V),
697 KEY(7, 1, KEY_B),
698 KEY(7, 2, KEY_N),
699 KEY(7, 3, KEY_MENU), /* REVISIT - SYM */
700 KEY(7, 4, KEY_PAGEDOWN),
701 KEY(7, 5, KEY_Z),
702 KEY(7, 6, KEY_X),
703 KEY(7, 7, KEY_C),
704
705 KEY(8, 0, KEY_P),
706 KEY(8, 1, KEY_J),
707 KEY(8, 2, KEY_K),
708 KEY(8, 3, KEY_INSERT),
709 KEY(8, 4, KEY_LINEFEED),
710 KEY(8, 5, KEY_U),
711 KEY(8, 6, KEY_I),
712 KEY(8, 7, KEY_O),
713
714 KEY(9, 0, KEY_4),
715 KEY(9, 1, KEY_5),
716 KEY(9, 2, KEY_6),
717 KEY(9, 3, KEY_7),
718 KEY(9, 4, KEY_8),
719 KEY(9, 5, KEY_1),
720 KEY(9, 6, KEY_2),
721 KEY(9, 7, KEY_3),
722
723 KEY(10, 0, KEY_F7),
724 KEY(10, 1, KEY_F8),
725 KEY(10, 2, KEY_F9),
726 KEY(10, 3, KEY_F10),
727 KEY(10, 4, KEY_FN),
728 KEY(10, 5, KEY_9),
729 KEY(10, 6, KEY_0),
730 KEY(10, 7, KEY_DOT),
731
732 KEY(11, 0, KEY_LEFTCTRL),
733 KEY(11, 1, KEY_F11), /* START */
734 KEY(11, 2, KEY_ENTER),
735 KEY(11, 3, KEY_SEARCH),
736 KEY(11, 4, KEY_DELETE),
737 KEY(11, 5, KEY_RIGHT),
738 KEY(11, 6, KEY_LEFT),
739 KEY(11, 7, KEY_RIGHTSHIFT),
740};
741
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700742static struct matrix_keymap_data surf_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530743 .keymap_size = ARRAY_SIZE(surf_keymap),
744 .keymap = surf_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700745};
746
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530747static struct pm8xxx_keypad_platform_data surf_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700748 .input_name = "surf_keypad",
749 .input_phys_device = "surf_keypad/input0",
750 .num_rows = 12,
751 .num_cols = 8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530752 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
753 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
754 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700755 .scan_delay_ms = 32,
756 .row_hold_ns = 91500,
757 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530758 .keymap_data = &surf_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700759};
760
761static struct matrix_keymap_data fluid_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530762 .keymap_size = ARRAY_SIZE(fluid_keymap),
763 .keymap = fluid_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700764};
765
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530766static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700767 .input_name = "fluid-keypad",
768 .input_phys_device = "fluid-keypad/input0",
769 .num_rows = 5,
770 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530771 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
772 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
773 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700774 .scan_delay_ms = 32,
775 .row_hold_ns = 91500,
776 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530777 .keymap_data = &fluid_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700778};
779
780static struct pm8058_pwm_pdata pm8058_pwm_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530781 .config = pm8058_pwm_config,
782 .enable = pm8058_pwm_enable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700783};
784
785static struct pmic8058_led pmic8058_ffa_leds[] = {
786 [0] = {
787 .name = "keyboard-backlight",
788 .max_brightness = 15,
789 .id = PMIC8058_ID_LED_KB_LIGHT,
Dima Zavinba5499e2011-01-10 11:00:30 -0800790 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700791};
792
793static struct pmic8058_leds_platform_data pm8058_ffa_leds_data = {
794 .num_leds = ARRAY_SIZE(pmic8058_ffa_leds),
795 .leds = pmic8058_ffa_leds,
796};
797
798static struct pmic8058_led pmic8058_surf_leds[] = {
799 [0] = {
800 .name = "keyboard-backlight",
801 .max_brightness = 15,
802 .id = PMIC8058_ID_LED_KB_LIGHT,
Dima Zavinba5499e2011-01-10 11:00:30 -0800803 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700804 [1] = {
805 .name = "voice:red",
806 .max_brightness = 20,
807 .id = PMIC8058_ID_LED_0,
Dima Zavinba5499e2011-01-10 11:00:30 -0800808 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700809 [2] = {
810 .name = "wlan:green",
811 .max_brightness = 20,
812 .id = PMIC8058_ID_LED_2,
813 },
814};
815
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700816static struct pmic8058_leds_platform_data pm8058_surf_leds_data = {
817 .num_leds = ARRAY_SIZE(pmic8058_surf_leds),
818 .leds = pmic8058_surf_leds,
819};
820
821static struct pmic8058_led pmic8058_fluid_leds[] = {
822 [0] = {
823 .name = "keyboard-backlight",
824 .max_brightness = 15,
825 .id = PMIC8058_ID_LED_KB_LIGHT,
826 },
827 [1] = {
828 .name = "flash:led_0",
829 .max_brightness = 15,
830 .id = PMIC8058_ID_FLASH_LED_0,
831 },
832 [2] = {
833 .name = "flash:led_1",
834 .max_brightness = 15,
835 .id = PMIC8058_ID_FLASH_LED_1,
836 },
837};
838
839static struct pmic8058_leds_platform_data pm8058_fluid_leds_data = {
840 .num_leds = ARRAY_SIZE(pmic8058_fluid_leds),
841 .leds = pmic8058_fluid_leds,
842};
843
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530844static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata = {
845 .irq_base = PMIC8058_IRQ_BASE,
846 .devirq = MSM_GPIO_TO_INT(PMIC_GPIO_INT),
847 .irq_trigger_flag = IRQF_TRIGGER_LOW,
848};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700849
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530850static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata = {
851 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
852};
853
854static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata = {
855 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
856};
857
858static struct pm8058_platform_data pm8058_7x30_data = {
859 .irq_pdata = &pm8xxx_irq_pdata,
860 .gpio_pdata = &pm8xxx_gpio_pdata,
861 .mpp_pdata = &pm8xxx_mpp_pdata,
862 .pwm_pdata = &pm8058_pwm_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700863};
864
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530865#ifdef CONFIG_MSM_SSBI
866static struct msm_ssbi_platform_data msm7x30_ssbi_pm8058_pdata = {
Kenneth Heitke48952912012-01-12 14:02:06 -0700867 .rsl_id = "D:PMIC_SSBI",
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530868 .controller_type = MSM_SBI_CTRL_SSBI2,
869 .slave = {
870 .name = "pm8058-core",
871 .platform_data = &pm8058_7x30_data,
872 },
873};
874#endif
875
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700876static struct i2c_board_info cy8info[] __initdata = {
877 {
878 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
879 .platform_data = &cyttsp_data,
880#ifndef CY_USE_TIMER
881 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
882#endif /* CY_USE_TIMER */
883 },
884};
885
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700886#ifdef CONFIG_MSM_CAMERA_V4L2
887static struct msm_camera_device_platform_data msm_camera_csi_device_data[] = {
888 {
Sreesudhan Ramakrish Ramkumar5ad18cd2012-09-07 23:22:34 -0700889 .csiphy_core = 0,
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700890 .csid_core = 0,
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700891 .is_vpe = 1,
892 .ioclk = {
893 .vfe_clk_rate = 153600000,
894 },
895 },
Sreesudhan Ramakrish Ramkumar66deac32012-04-05 10:15:38 -0700896 {
Sreesudhan Ramakrish Ramkumar5ad18cd2012-09-07 23:22:34 -0700897 .csiphy_core = 0,
Sreesudhan Ramakrish Ramkumar66deac32012-04-05 10:15:38 -0700898 .csid_core = 0,
899 .is_vpe = 1,
900 .ioclk = {
901 .vfe_clk_rate = 153600000,
902 },
903 },
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700904};
905
906static struct camera_vreg_t msm_7x30_back_cam_vreg[] = {
907 {"gp2", REG_LDO, 2600000, 2600000, -1},
908 {"lvsw1", REG_VS, 0, 0, 0},
909};
910
911static uint32_t camera_off_gpio_table[] = {
912 /* parallel CAMERA interfaces */
913 /* RST */
914 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
915 /* DAT2 */
916 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
917 /* DAT3 */
918 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
919 /* DAT4 */
920 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
921 /* DAT5 */
922 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
923 /* DAT6 */
924 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
925 /* DAT7 */
926 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
927 /* DAT8 */
928 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
929 /* DAT9 */
930 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
931 /* DAT10 */
932 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
933 /* DAT11 */
934 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
935 /* PCLK */
936 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
937 /* HSYNC_IN */
938 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
939 /* VSYNC_IN */
940 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
941 /* MCLK */
942 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
943};
944
945static uint32_t camera_on_gpio_table[] = {
946 /* parallel CAMERA interfaces */
947 /* RST */
948 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
949 /* DAT2 */
950 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
951 /* DAT3 */
952 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
953 /* DAT4 */
954 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
955 /* DAT5 */
956 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
957 /* DAT6 */
958 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
959 /* DAT7 */
960 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
961 /* DAT8 */
962 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
963 /* DAT9 */
964 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
965 /* DAT10 */
966 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
967 /* DAT11 */
968 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
969 /* PCLK */
970 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
971 /* HSYNC_IN */
972 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
973 /* VSYNC_IN */
974 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
975 /* MCLK */
976 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
977};
978
979static struct gpio msm7x30_back_cam_gpio[] = {
980 {0, GPIOF_DIR_OUT, "CAM_RESET"},
981};
982
983static struct msm_gpio_set_tbl msm7x30_back_cam_gpio_set_tbl[] = {
984 {0, GPIOF_OUT_INIT_LOW, 1000},
985 {0, GPIOF_OUT_INIT_HIGH, 4000},
986};
987
988static struct msm_camera_gpio_conf msm_7x30_back_cam_gpio_conf = {
989 .cam_gpio_req_tbl = msm7x30_back_cam_gpio,
990 .cam_gpio_req_tbl_size = ARRAY_SIZE(msm7x30_back_cam_gpio),
991 .cam_gpio_set_tbl = msm7x30_back_cam_gpio_set_tbl,
992 .cam_gpio_set_tbl_size = ARRAY_SIZE(msm7x30_back_cam_gpio_set_tbl),
993 .camera_off_table = camera_off_gpio_table,
994 .camera_off_table_size = ARRAY_SIZE(camera_off_gpio_table),
995 .camera_on_table = camera_on_gpio_table,
996 .camera_on_table_size = ARRAY_SIZE(camera_on_gpio_table),
997 .gpio_no_mux = 1,
998};
999
1000static struct msm_camera_sensor_flash_data flash_vx6953 = {
1001 .flash_type = MSM_CAMERA_FLASH_NONE,
1002};
1003
1004static struct msm_camera_sensor_platform_info sensor_board_info_vx6953 = {
1005 .mount_angle = 0,
1006 .cam_vreg = msm_7x30_back_cam_vreg,
1007 .num_vreg = ARRAY_SIZE(msm_7x30_back_cam_vreg),
1008 .gpio_conf = &msm_7x30_back_cam_gpio_conf,
1009};
1010
1011static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1012 .sensor_name = "vx6953",
1013 .pdata = &msm_camera_csi_device_data[0],
1014 .flash_data = &flash_vx6953,
1015 .sensor_platform_info = &sensor_board_info_vx6953,
1016 .csi_if = 1,
1017 .camera_type = BACK_CAMERA_2D,
1018};
1019
Kevin Chan94b4c832012-03-02 21:27:16 -08001020static struct platform_device msm_camera_server = {
1021 .name = "msm_cam_server",
1022 .id = 0,
1023};
1024
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001025void __init msm7x30_init_cam(void)
1026{
Kevin Chan94b4c832012-03-02 21:27:16 -08001027 platform_device_register(&msm_camera_server);
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001028 platform_device_register(&msm_device_csic0);
1029 platform_device_register(&msm_device_vfe);
1030 platform_device_register(&msm_device_vpe);
1031}
1032
1033#ifdef CONFIG_I2C
1034static struct i2c_board_info msm_camera_boardinfo[] = {
1035 {
1036 I2C_BOARD_INFO("vx6953", 0x20),
1037 .platform_data = &msm_camera_sensor_vx6953_data,
1038 },
1039};
1040#endif
1041#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001042static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
1043#ifdef CONFIG_MT9D112
1044 {
1045 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
Dima Zavinba5499e2011-01-10 11:00:30 -08001046 },
1047#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001048#ifdef CONFIG_WEBCAM_OV9726
1049 {
1050 I2C_BOARD_INFO("ov9726", 0x10),
1051 },
1052#endif
1053#ifdef CONFIG_S5K3E2FX
1054 {
1055 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
1056 },
1057#endif
1058#ifdef CONFIG_MT9P012
1059 {
1060 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
1061 },
1062#endif
1063#ifdef CONFIG_VX6953
1064 {
1065 I2C_BOARD_INFO("vx6953", 0x20),
1066 },
1067#endif
1068#ifdef CONFIG_MT9E013
1069 {
1070 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
1071 },
1072#endif
1073#ifdef CONFIG_SN12M0PZ
1074 {
1075 I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1),
1076 },
1077#endif
1078#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
1079 {
1080 I2C_BOARD_INFO("mt9t013", 0x6C),
1081 },
1082#endif
1083
Dima Zavinba5499e2011-01-10 11:00:30 -08001084};
1085
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001086#ifdef CONFIG_MSM_CAMERA
1087#define CAM_STNDBY 143
1088static uint32_t camera_off_vcm_gpio_table[] = {
1089GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */
1090};
1091
1092static uint32_t camera_off_gpio_table[] = {
1093 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001094 /* RST */
1095 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1096 /* DAT2 */
1097 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1098 /* DAT3 */
1099 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1100 /* DAT4 */
1101 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1102 /* DAT5 */
1103 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1104 /* DAT6 */
1105 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1106 /* DAT7 */
1107 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1108 /* DAT8 */
1109 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1110 /* DAT9 */
1111 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1112 /* DAT10 */
1113 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1114 /* DAT11 */
1115 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1116 /* PCLK */
1117 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1118 /* HSYNC_IN */
1119 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1120 /* VSYNC_IN */
1121 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1122 /* MCLK */
1123 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001124};
1125
1126static uint32_t camera_on_vcm_gpio_table[] = {
1127GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */
1128};
1129
1130static uint32_t camera_on_gpio_table[] = {
1131 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001132 /* RST */
1133 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1134 /* DAT2 */
1135 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1136 /* DAT3 */
1137 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1138 /* DAT4 */
1139 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1140 /* DAT5 */
1141 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1142 /* DAT6 */
1143 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1144 /* DAT7 */
1145 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1146 /* DAT8 */
1147 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1148 /* DAT9 */
1149 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1150 /* DAT10 */
1151 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1152 /* DAT11 */
1153 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1154 /* PCLK */
1155 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1156 /* HSYNC_IN */
1157 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1158 /* VSYNC_IN */
1159 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1160 /* MCLK */
1161 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001162};
1163
1164static uint32_t camera_off_gpio_fluid_table[] = {
1165 /* FLUID: CAM_VGA_RST_N */
1166 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1167 /* FLUID: CAMIF_STANDBY */
1168 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1169};
1170
1171static uint32_t camera_on_gpio_fluid_table[] = {
1172 /* FLUID: CAM_VGA_RST_N */
1173 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1174 /* FLUID: CAMIF_STANDBY */
1175 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1176};
1177
1178static void config_gpio_table(uint32_t *table, int len)
1179{
1180 int n, rc;
1181 for (n = 0; n < len; n++) {
1182 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
1183 if (rc) {
1184 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
1185 __func__, table[n], rc);
1186 break;
1187 }
1188 }
1189}
1190static int config_camera_on_gpios(void)
1191{
1192 config_gpio_table(camera_on_gpio_table,
1193 ARRAY_SIZE(camera_on_gpio_table));
1194
1195 if (adie_get_detected_codec_type() != TIMPANI_ID)
1196 /* GPIO1 is shared also used in Timpani RF card so
1197 only configure it for non-Timpani RF card */
1198 config_gpio_table(camera_on_vcm_gpio_table,
1199 ARRAY_SIZE(camera_on_vcm_gpio_table));
1200
1201 if (machine_is_msm7x30_fluid()) {
1202 config_gpio_table(camera_on_gpio_fluid_table,
1203 ARRAY_SIZE(camera_on_gpio_fluid_table));
1204 /* FLUID: turn on 5V booster */
1205 gpio_set_value(
1206 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 1);
1207 /* FLUID: drive high to put secondary sensor to STANDBY */
1208 gpio_set_value(CAM_STNDBY, 1);
1209 }
1210 return 0;
1211}
1212
1213static void config_camera_off_gpios(void)
1214{
1215 config_gpio_table(camera_off_gpio_table,
1216 ARRAY_SIZE(camera_off_gpio_table));
1217
1218 if (adie_get_detected_codec_type() != TIMPANI_ID)
1219 /* GPIO1 is shared also used in Timpani RF card so
1220 only configure it for non-Timpani RF card */
1221 config_gpio_table(camera_off_vcm_gpio_table,
1222 ARRAY_SIZE(camera_off_vcm_gpio_table));
1223
1224 if (machine_is_msm7x30_fluid()) {
1225 config_gpio_table(camera_off_gpio_fluid_table,
1226 ARRAY_SIZE(camera_off_gpio_fluid_table));
1227 /* FLUID: turn off 5V booster */
1228 gpio_set_value(
1229 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 0);
1230 }
1231}
1232
1233struct resource msm_camera_resources[] = {
1234 {
1235 .start = 0xA6000000,
1236 .end = 0xA6000000 + SZ_1M - 1,
1237 .flags = IORESOURCE_MEM,
1238 },
1239 {
1240 .start = INT_VFE,
1241 .end = INT_VFE,
1242 .flags = IORESOURCE_IRQ,
1243 },
1244 {
1245 .flags = IORESOURCE_DMA,
1246 }
1247};
1248
1249struct msm_camera_device_platform_data msm_camera_device_data = {
1250 .camera_gpio_on = config_camera_on_gpios,
1251 .camera_gpio_off = config_camera_off_gpios,
1252 .ioext.camifpadphy = 0xAB000000,
1253 .ioext.camifpadsz = 0x00000400,
1254 .ioext.csiphy = 0xA6100000,
1255 .ioext.csisz = 0x00000400,
1256 .ioext.csiirq = INT_CSI,
1257 .ioclk.mclk_clk_rate = 24000000,
1258 .ioclk.vfe_clk_rate = 147456000,
1259};
1260
1261static struct msm_camera_sensor_flash_src msm_flash_src_pwm = {
1262 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PWM,
1263 ._fsrc.pwm_src.freq = 1000,
1264 ._fsrc.pwm_src.max_load = 300,
1265 ._fsrc.pwm_src.low_load = 30,
1266 ._fsrc.pwm_src.high_load = 100,
1267 ._fsrc.pwm_src.channel = 7,
1268};
1269
1270#ifdef CONFIG_MT9D112
1271static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1272 .flash_type = MSM_CAMERA_FLASH_LED,
1273 .flash_src = &msm_flash_src_pwm
1274};
1275
1276static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1277 .sensor_name = "mt9d112",
1278 .sensor_reset = 0,
1279 .sensor_pwd = 85,
1280 .vcm_pwd = 1,
1281 .vcm_enable = 0,
1282 .pdata = &msm_camera_device_data,
1283 .resource = msm_camera_resources,
1284 .num_resources = ARRAY_SIZE(msm_camera_resources),
1285 .flash_data = &flash_mt9d112,
1286 .csi_if = 0
1287};
1288
1289static struct platform_device msm_camera_sensor_mt9d112 = {
1290 .name = "msm_camera_mt9d112",
1291 .dev = {
1292 .platform_data = &msm_camera_sensor_mt9d112_data,
1293 },
1294};
1295#endif
1296
1297#ifdef CONFIG_WEBCAM_OV9726
1298
1299static struct msm_camera_sensor_platform_info ov9726_sensor_7630_info = {
1300 .mount_angle = 90
1301};
1302
1303static struct msm_camera_sensor_flash_data flash_ov9726 = {
1304 .flash_type = MSM_CAMERA_FLASH_LED,
1305 .flash_src = &msm_flash_src_pwm
1306};
1307static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
1308 .sensor_name = "ov9726",
1309 .sensor_reset = 0,
1310 .sensor_pwd = 85,
1311 .vcm_pwd = 1,
1312 .vcm_enable = 0,
1313 .pdata = &msm_camera_device_data,
1314 .resource = msm_camera_resources,
1315 .num_resources = ARRAY_SIZE(msm_camera_resources),
1316 .flash_data = &flash_ov9726,
1317 .sensor_platform_info = &ov9726_sensor_7630_info,
1318 .csi_if = 1
1319};
1320struct platform_device msm_camera_sensor_ov9726 = {
1321 .name = "msm_camera_ov9726",
1322 .dev = {
1323 .platform_data = &msm_camera_sensor_ov9726_data,
1324 },
1325};
1326#endif
1327
1328#ifdef CONFIG_S5K3E2FX
1329static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1330 .flash_type = MSM_CAMERA_FLASH_LED,
1331 .flash_src = &msm_flash_src_pwm,
1332};
1333
1334static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1335 .sensor_name = "s5k3e2fx",
1336 .sensor_reset = 0,
1337 .sensor_pwd = 85,
1338 .vcm_pwd = 1,
1339 .vcm_enable = 0,
1340 .pdata = &msm_camera_device_data,
1341 .resource = msm_camera_resources,
1342 .num_resources = ARRAY_SIZE(msm_camera_resources),
1343 .flash_data = &flash_s5k3e2fx,
1344 .csi_if = 0
1345};
1346
1347static struct platform_device msm_camera_sensor_s5k3e2fx = {
1348 .name = "msm_camera_s5k3e2fx",
1349 .dev = {
1350 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1351 },
1352};
1353#endif
1354
1355#ifdef CONFIG_MT9P012
1356static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1357 .flash_type = MSM_CAMERA_FLASH_LED,
1358 .flash_src = &msm_flash_src_pwm
1359};
1360
1361static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1362 .sensor_name = "mt9p012",
1363 .sensor_reset = 0,
1364 .sensor_pwd = 85,
1365 .vcm_pwd = 1,
1366 .vcm_enable = 1,
1367 .pdata = &msm_camera_device_data,
1368 .resource = msm_camera_resources,
1369 .num_resources = ARRAY_SIZE(msm_camera_resources),
1370 .flash_data = &flash_mt9p012,
1371 .csi_if = 0
1372};
1373
1374static struct platform_device msm_camera_sensor_mt9p012 = {
1375 .name = "msm_camera_mt9p012",
1376 .dev = {
1377 .platform_data = &msm_camera_sensor_mt9p012_data,
1378 },
1379};
1380#endif
1381
1382#ifdef CONFIG_MT9E013
1383static struct msm_camera_sensor_platform_info mt9e013_sensor_7630_info = {
1384 .mount_angle = 0
1385};
1386
1387static struct msm_camera_sensor_flash_data flash_mt9e013 = {
1388 .flash_type = MSM_CAMERA_FLASH_LED,
1389 .flash_src = &msm_flash_src_pwm
1390};
1391
1392static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
1393 .sensor_name = "mt9e013",
1394 .sensor_reset = 0,
1395 .sensor_pwd = 85,
1396 .vcm_pwd = 1,
1397 .vcm_enable = 1,
1398 .pdata = &msm_camera_device_data,
1399 .resource = msm_camera_resources,
1400 .num_resources = ARRAY_SIZE(msm_camera_resources),
1401 .flash_data = &flash_mt9e013,
1402 .sensor_platform_info = &mt9e013_sensor_7630_info,
1403 .csi_if = 1
1404};
1405
1406static struct platform_device msm_camera_sensor_mt9e013 = {
1407 .name = "msm_camera_mt9e013",
1408 .dev = {
1409 .platform_data = &msm_camera_sensor_mt9e013_data,
1410 },
1411};
1412#endif
1413
1414#ifdef CONFIG_VX6953
Jilai Wang971f97f2011-07-13 14:25:25 -04001415static struct msm_camera_sensor_platform_info vx6953_sensor_7630_info = {
1416 .mount_angle = 0
1417};
1418
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001419static struct msm_camera_sensor_flash_data flash_vx6953 = {
1420 .flash_type = MSM_CAMERA_FLASH_LED,
1421 .flash_src = &msm_flash_src_pwm
1422};
1423static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1424 .sensor_name = "vx6953",
1425 .sensor_reset = 0,
1426 .sensor_pwd = 85,
1427 .vcm_pwd = 1,
1428 .vcm_enable = 0,
1429 .pdata = &msm_camera_device_data,
1430 .resource = msm_camera_resources,
1431 .num_resources = ARRAY_SIZE(msm_camera_resources),
Jilai Wang971f97f2011-07-13 14:25:25 -04001432 .sensor_platform_info = &vx6953_sensor_7630_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001433 .flash_data = &flash_vx6953,
1434 .csi_if = 1
1435};
1436static struct platform_device msm_camera_sensor_vx6953 = {
1437 .name = "msm_camera_vx6953",
1438 .dev = {
1439 .platform_data = &msm_camera_sensor_vx6953_data,
1440 },
1441};
1442#endif
1443
1444#ifdef CONFIG_SN12M0PZ
1445static struct msm_camera_sensor_flash_src msm_flash_src_current_driver = {
1446 .flash_sr_type = MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER,
1447 ._fsrc.current_driver_src.low_current = 210,
1448 ._fsrc.current_driver_src.high_current = 700,
1449 ._fsrc.current_driver_src.driver_channel = &pm8058_fluid_leds_data,
1450};
1451
1452static struct msm_camera_sensor_flash_data flash_sn12m0pz = {
1453 .flash_type = MSM_CAMERA_FLASH_LED,
1454 .flash_src = &msm_flash_src_current_driver
1455};
1456static struct msm_camera_sensor_info msm_camera_sensor_sn12m0pz_data = {
1457 .sensor_name = "sn12m0pz",
1458 .sensor_reset = 0,
1459 .sensor_pwd = 85,
1460 .vcm_pwd = 1,
1461 .vcm_enable = 1,
1462 .pdata = &msm_camera_device_data,
1463 .flash_data = &flash_sn12m0pz,
1464 .resource = msm_camera_resources,
1465 .num_resources = ARRAY_SIZE(msm_camera_resources),
1466 .csi_if = 0
1467};
1468
1469static struct platform_device msm_camera_sensor_sn12m0pz = {
1470 .name = "msm_camera_sn12m0pz",
1471 .dev = {
1472 .platform_data = &msm_camera_sensor_sn12m0pz_data,
1473 },
1474};
1475#endif
1476
1477#ifdef CONFIG_MT9T013
1478static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1479 .flash_type = MSM_CAMERA_FLASH_LED,
1480 .flash_src = &msm_flash_src_pwm
1481};
1482
1483static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1484 .sensor_name = "mt9t013",
1485 .sensor_reset = 0,
1486 .sensor_pwd = 85,
1487 .vcm_pwd = 1,
1488 .vcm_enable = 0,
1489 .pdata = &msm_camera_device_data,
1490 .resource = msm_camera_resources,
1491 .num_resources = ARRAY_SIZE(msm_camera_resources),
1492 .flash_data = &flash_mt9t013,
1493 .csi_if = 1
1494};
1495
1496static struct platform_device msm_camera_sensor_mt9t013 = {
1497 .name = "msm_camera_mt9t013",
1498 .dev = {
1499 .platform_data = &msm_camera_sensor_mt9t013_data,
1500 },
1501};
1502#endif
1503
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001504#ifdef CONFIG_MSM_VPE
1505static struct resource msm_vpe_resources[] = {
1506 {
1507 .start = 0xAD200000,
1508 .end = 0xAD200000 + SZ_1M - 1,
1509 .flags = IORESOURCE_MEM,
1510 },
1511 {
1512 .start = INT_VPE,
1513 .end = INT_VPE,
1514 .flags = IORESOURCE_IRQ,
1515 },
1516};
1517
1518static struct platform_device msm_vpe_device = {
1519 .name = "msm_vpe",
1520 .id = 0,
1521 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1522 .resource = msm_vpe_resources,
1523};
1524#endif
1525
1526#endif /*CONFIG_MSM_CAMERA*/
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001527#endif
1528
1529#ifdef CONFIG_MSM_GEMINI
1530static struct resource msm_gemini_resources[] = {
1531 {
1532 .start = 0xA3A00000,
1533 .end = 0xA3A00000 + 0x0150 - 1,
1534 .flags = IORESOURCE_MEM,
1535 },
1536 {
1537 .start = INT_JPEG,
1538 .end = INT_JPEG,
1539 .flags = IORESOURCE_IRQ,
1540 },
1541};
1542
1543static struct platform_device msm_gemini_device = {
1544 .name = "msm_gemini",
1545 .resource = msm_gemini_resources,
1546 .num_resources = ARRAY_SIZE(msm_gemini_resources),
1547};
1548#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001549
1550#ifdef CONFIG_MSM7KV2_AUDIO
1551static uint32_t audio_pamp_gpio_config =
1552 GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1553
1554static uint32_t audio_fluid_icodec_tx_config =
1555 GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1556
1557static int __init snddev_poweramp_gpio_init(void)
1558{
1559 int rc;
1560
1561 pr_info("snddev_poweramp_gpio_init \n");
1562 rc = gpio_tlmm_config(audio_pamp_gpio_config, GPIO_CFG_ENABLE);
1563 if (rc) {
1564 printk(KERN_ERR
1565 "%s: gpio_tlmm_config(%#x)=%d\n",
1566 __func__, audio_pamp_gpio_config, rc);
1567 }
1568 return rc;
1569}
1570
1571void msm_snddev_tx_route_config(void)
1572{
1573 int rc;
1574
1575 pr_debug("%s()\n", __func__);
1576
1577 if (machine_is_msm7x30_fluid()) {
1578 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1579 GPIO_CFG_ENABLE);
1580 if (rc) {
1581 printk(KERN_ERR
1582 "%s: gpio_tlmm_config(%#x)=%d\n",
1583 __func__, audio_fluid_icodec_tx_config, rc);
1584 } else
1585 gpio_set_value(85, 0);
1586 }
1587}
1588
1589void msm_snddev_tx_route_deconfig(void)
1590{
1591 int rc;
1592
1593 pr_debug("%s()\n", __func__);
1594
1595 if (machine_is_msm7x30_fluid()) {
1596 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1597 GPIO_CFG_DISABLE);
1598 if (rc) {
1599 printk(KERN_ERR
1600 "%s: gpio_tlmm_config(%#x)=%d\n",
1601 __func__, audio_fluid_icodec_tx_config, rc);
1602 }
1603 }
1604}
1605
1606void msm_snddev_poweramp_on(void)
1607{
1608 gpio_set_value(82, 1); /* enable spkr poweramp */
1609 pr_info("%s: power on amplifier\n", __func__);
1610}
1611
1612void msm_snddev_poweramp_off(void)
1613{
1614 gpio_set_value(82, 0); /* disable spkr poweramp */
1615 pr_info("%s: power off amplifier\n", __func__);
1616}
1617
Justin Paupore3f40f342011-08-10 18:52:16 -07001618static struct regulator_bulk_data snddev_regs[] = {
1619 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
1620 { .supply = "ncp", .min_uV = 1800000, .max_uV = 1800000 },
1621};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001622
Justin Paupore3f40f342011-08-10 18:52:16 -07001623static int __init snddev_hsed_voltage_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001624{
1625 int rc;
1626
Justin Paupore3f40f342011-08-10 18:52:16 -07001627 rc = regulator_bulk_get(NULL, ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001628
Justin Paupore3f40f342011-08-10 18:52:16 -07001629 if (rc) {
1630 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1631 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001632 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001633
1634 rc = regulator_bulk_set_voltage(ARRAY_SIZE(snddev_regs), snddev_regs);
1635
1636 if (rc) {
1637 pr_err("%s: could not set regulator voltages: %d\n",
1638 __func__, rc);
1639 goto regs_free;
1640 }
1641
1642 return 0;
1643
1644regs_free:
1645 regulator_bulk_free(ARRAY_SIZE(snddev_regs), snddev_regs);
1646out:
1647 return rc;
1648}
1649
1650
1651void msm_snddev_hsed_voltage_on(void)
1652{
1653 int rc = regulator_bulk_enable(ARRAY_SIZE(snddev_regs), snddev_regs);
1654
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001655 if (rc)
Justin Paupore3f40f342011-08-10 18:52:16 -07001656 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001657}
1658
1659void msm_snddev_hsed_voltage_off(void)
1660{
Justin Paupore3f40f342011-08-10 18:52:16 -07001661 int rc = regulator_bulk_disable(ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001662
Justin Paupore3f40f342011-08-10 18:52:16 -07001663 if (rc) {
1664 pr_err("%s: could not disable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001665 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001666}
1667
1668static unsigned aux_pcm_gpio_on[] = {
1669 GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
1670 GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
1671 GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
1672 GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
1673};
1674
1675static int __init aux_pcm_gpio_init(void)
1676{
1677 int pin, rc;
1678
1679 pr_info("aux_pcm_gpio_init \n");
1680 for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) {
1681 rc = gpio_tlmm_config(aux_pcm_gpio_on[pin],
1682 GPIO_CFG_ENABLE);
1683 if (rc) {
1684 printk(KERN_ERR
1685 "%s: gpio_tlmm_config(%#x)=%d\n",
1686 __func__, aux_pcm_gpio_on[pin], rc);
1687 }
1688 }
1689 return rc;
1690}
1691
1692static struct msm_gpio mi2s_clk_gpios[] = {
1693 { GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1694 "MI2S_SCLK"},
1695 { GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1696 "MI2S_WS"},
1697 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1698 "MI2S_MCLK_A"},
1699};
1700
1701static struct msm_gpio mi2s_rx_data_lines_gpios[] = {
1702 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1703 "MI2S_DATA_SD0_A"},
1704 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1705 "MI2S_DATA_SD1_A"},
1706 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1707 "MI2S_DATA_SD2_A"},
1708 { GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1709 "MI2S_DATA_SD3"},
1710};
1711
1712static struct msm_gpio mi2s_tx_data_lines_gpios[] = {
1713 { GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1714 "MI2S_DATA_SD3"},
1715};
1716
1717int mi2s_config_clk_gpio(void)
1718{
1719 int rc = 0;
1720
1721 rc = msm_gpios_request_enable(mi2s_clk_gpios,
1722 ARRAY_SIZE(mi2s_clk_gpios));
1723 if (rc) {
1724 pr_err("%s: enable mi2s clk gpios failed\n",
1725 __func__);
1726 return rc;
1727 }
1728 return 0;
1729}
1730
1731int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask)
1732{
1733 int i, rc = 0;
1734 sd_line_mask &= MI2S_SD_LINE_MASK;
1735
1736 switch (direction) {
1737 case DIR_TX:
1738 msm_gpios_disable_free(mi2s_tx_data_lines_gpios, 1);
1739 break;
1740 case DIR_RX:
1741 i = 0;
1742 while (sd_line_mask) {
1743 if (sd_line_mask & 0x1)
1744 msm_gpios_disable_free(
1745 mi2s_rx_data_lines_gpios + i , 1);
1746 sd_line_mask = sd_line_mask >> 1;
1747 i++;
1748 }
1749 break;
1750 default:
1751 pr_err("%s: Invaild direction direction = %u\n",
1752 __func__, direction);
1753 rc = -EINVAL;
1754 break;
1755 }
1756 return rc;
1757}
1758
1759int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask)
1760{
1761 int i , rc = 0;
1762 u8 sd_config_done_mask = 0;
1763
1764 sd_line_mask &= MI2S_SD_LINE_MASK;
1765
1766 switch (direction) {
1767 case DIR_TX:
1768 if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) ||
1769 (sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) {
1770 pr_err("%s: can not use SD0 or SD1 or SD2 for TX"
1771 ".only can use SD3. sd_line_mask = 0x%x\n",
1772 __func__ , sd_line_mask);
1773 rc = -EINVAL;
1774 } else {
1775 rc = msm_gpios_request_enable(mi2s_tx_data_lines_gpios,
1776 1);
1777 if (rc)
1778 pr_err("%s: enable mi2s gpios for TX failed\n",
1779 __func__);
1780 }
1781 break;
1782 case DIR_RX:
1783 i = 0;
1784 while (sd_line_mask && (rc == 0)) {
1785 if (sd_line_mask & 0x1) {
1786 rc = msm_gpios_request_enable(
1787 mi2s_rx_data_lines_gpios + i , 1);
1788 if (rc) {
1789 pr_err("%s: enable mi2s gpios for"
1790 "RX failed. SD line = %s\n",
1791 __func__,
1792 (mi2s_rx_data_lines_gpios + i)->label);
1793 mi2s_unconfig_data_gpio(DIR_RX,
1794 sd_config_done_mask);
1795 } else
1796 sd_config_done_mask |= (1 << i);
1797 }
1798 sd_line_mask = sd_line_mask >> 1;
1799 i++;
1800 }
1801 break;
1802 default:
1803 pr_err("%s: Invaild direction direction = %u\n",
1804 __func__, direction);
1805 rc = -EINVAL;
1806 break;
1807 }
1808 return rc;
1809}
1810
1811int mi2s_unconfig_clk_gpio(void)
1812{
1813 msm_gpios_disable_free(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios));
1814 return 0;
1815}
1816
1817#endif /* CONFIG_MSM7KV2_AUDIO */
1818
1819static int __init buses_init(void)
1820{
1821 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT,
1822 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
1823 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
1824 __func__, PMIC_GPIO_INT);
1825
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301826 if (machine_is_msm8x60_fluid())
1827 pm8058_7x30_data.keypad_pdata = &fluid_keypad_data;
1828 else
1829 pm8058_7x30_data.keypad_pdata = &surf_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001830
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001831 return 0;
1832}
1833
1834#define TIMPANI_RESET_GPIO 1
1835
1836struct bahama_config_register{
1837 u8 reg;
1838 u8 value;
1839 u8 mask;
1840};
1841
1842enum version{
1843 VER_1_0,
1844 VER_2_0,
1845 VER_UNSUPPORTED = 0xFF
1846};
1847
Justin Paupore3f40f342011-08-10 18:52:16 -07001848static struct regulator *vreg_marimba_1;
1849static struct regulator *vreg_marimba_2;
1850static struct regulator *vreg_bahama;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001851
1852static struct msm_gpio timpani_reset_gpio_cfg[] = {
1853{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
1854 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} };
1855
1856static u8 read_bahama_ver(void)
1857{
1858 int rc;
1859 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1860 u8 bahama_version;
1861
1862 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
1863 if (rc < 0) {
1864 printk(KERN_ERR
1865 "%s: version read failed: %d\n",
1866 __func__, rc);
1867 return rc;
1868 } else {
1869 printk(KERN_INFO
1870 "%s: version read got: 0x%x\n",
1871 __func__, bahama_version);
1872 }
1873
1874 switch (bahama_version) {
1875 case 0x08: /* varient of bahama v1 */
1876 case 0x10:
1877 case 0x00:
1878 return VER_1_0;
1879 case 0x09: /* variant of bahama v2 */
1880 return VER_2_0;
1881 default:
1882 return VER_UNSUPPORTED;
1883 }
1884}
1885
1886static int config_timpani_reset(void)
1887{
1888 int rc;
1889
1890 rc = msm_gpios_request_enable(timpani_reset_gpio_cfg,
1891 ARRAY_SIZE(timpani_reset_gpio_cfg));
1892 if (rc < 0) {
1893 printk(KERN_ERR
1894 "%s: msm_gpios_request_enable failed (%d)\n",
1895 __func__, rc);
1896 }
1897 return rc;
1898}
1899
1900static unsigned int msm_timpani_setup_power(void)
1901{
1902 int rc;
1903
1904 rc = config_timpani_reset();
1905 if (rc < 0)
1906 goto out;
1907
Justin Paupore3f40f342011-08-10 18:52:16 -07001908 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001909 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001910 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001911 goto out;
1912 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001913
1914 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001915 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001916 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1917 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001918 }
1919
1920 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1);
1921 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001922 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001923 __func__, rc);
1924 msm_gpios_free(timpani_reset_gpio_cfg,
1925 ARRAY_SIZE(timpani_reset_gpio_cfg));
Justin Paupore3f40f342011-08-10 18:52:16 -07001926 goto disable_marimba_2;
1927 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001928
Justin Paupore3f40f342011-08-10 18:52:16 -07001929 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001930
Justin Paupore3f40f342011-08-10 18:52:16 -07001931disable_marimba_2:
1932 regulator_disable(vreg_marimba_2);
1933disable_marimba_1:
1934 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001935out:
1936 return rc;
1937};
1938
1939static void msm_timpani_shutdown_power(void)
1940{
1941 int rc;
1942
Justin Paupore3f40f342011-08-10 18:52:16 -07001943 rc = regulator_disable(vreg_marimba_2);
1944 if (rc)
1945 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1946
1947 rc = regulator_disable(vreg_marimba_1);
1948 if (rc)
1949 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001950
1951 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0);
Justin Paupore3f40f342011-08-10 18:52:16 -07001952 if (rc < 0)
1953 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001954 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001955
1956 msm_gpios_free(timpani_reset_gpio_cfg,
1957 ARRAY_SIZE(timpani_reset_gpio_cfg));
1958};
1959
1960static unsigned int msm_bahama_core_config(int type)
1961{
1962 int rc = 0;
1963
1964 if (type == BAHAMA_ID) {
1965
1966 int i;
1967 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1968
1969 const struct bahama_config_register v20_init[] = {
1970 /* reg, value, mask */
1971 { 0xF4, 0x84, 0xFF }, /* AREG */
1972 { 0xF0, 0x04, 0xFF } /* DREG */
1973 };
1974
1975 if (read_bahama_ver() == VER_2_0) {
1976 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
1977 u8 value = v20_init[i].value;
1978 rc = marimba_write_bit_mask(&config,
1979 v20_init[i].reg,
1980 &value,
1981 sizeof(v20_init[i].value),
1982 v20_init[i].mask);
1983 if (rc < 0) {
1984 printk(KERN_ERR
1985 "%s: reg %d write failed: %d\n",
1986 __func__, v20_init[i].reg, rc);
1987 return rc;
1988 }
1989 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
1990 " mask 0x%02x\n",
1991 __func__, v20_init[i].reg,
1992 v20_init[i].value, v20_init[i].mask);
1993 }
1994 }
1995 }
1996 printk(KERN_INFO "core type: %d\n", type);
1997
1998 return rc;
1999}
2000
2001static unsigned int msm_bahama_setup_power(void)
2002{
Justin Paupore3f40f342011-08-10 18:52:16 -07002003 int rc = regulator_enable(vreg_bahama);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002004
Justin Paupore3f40f342011-08-10 18:52:16 -07002005 if (rc)
2006 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002007
2008 return rc;
2009};
2010
2011static unsigned int msm_bahama_shutdown_power(int value)
2012{
2013 int rc = 0;
2014
2015 if (value != BAHAMA_ID) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002016 rc = regulator_disable(vreg_bahama);
2017
2018 if (rc)
2019 pr_err("%s: regulator_disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002020 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002021 }
2022
2023 return rc;
2024};
2025
2026static struct msm_gpio marimba_svlte_config_clock[] = {
2027 { GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2028 "MARIMBA_SVLTE_CLOCK_ENABLE" },
2029};
2030
2031static unsigned int msm_marimba_gpio_config_svlte(int gpio_cfg_marimba)
2032{
2033 if (machine_is_msm8x55_svlte_surf() ||
2034 machine_is_msm8x55_svlte_ffa()) {
2035 if (gpio_cfg_marimba)
2036 gpio_set_value(GPIO_PIN
2037 (marimba_svlte_config_clock->gpio_cfg), 1);
2038 else
2039 gpio_set_value(GPIO_PIN
2040 (marimba_svlte_config_clock->gpio_cfg), 0);
2041 }
2042
2043 return 0;
2044};
2045
2046static unsigned int msm_marimba_setup_power(void)
2047{
2048 int rc;
2049
Justin Paupore3f40f342011-08-10 18:52:16 -07002050 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002051 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002052 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002053 goto out;
2054 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002055
2056 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002057 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002058 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2059 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002060 }
2061
2062 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
2063 rc = msm_gpios_request_enable(marimba_svlte_config_clock,
2064 ARRAY_SIZE(marimba_svlte_config_clock));
2065 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002066 pr_err("%s: msm_gpios_request_enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002067 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002068 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002069 }
2070
2071 rc = gpio_direction_output(GPIO_PIN
2072 (marimba_svlte_config_clock->gpio_cfg), 0);
2073 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002074 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002075 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002076 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002077 }
2078 }
2079
Justin Paupore3f40f342011-08-10 18:52:16 -07002080 return 0;
2081
2082disable_marimba_2:
2083 regulator_disable(vreg_marimba_2);
2084disable_marimba_1:
2085 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002086out:
2087 return rc;
2088};
2089
2090static void msm_marimba_shutdown_power(void)
2091{
2092 int rc;
2093
Justin Paupore3f40f342011-08-10 18:52:16 -07002094 rc = regulator_disable(vreg_marimba_2);
2095 if (rc)
2096 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
2097
2098 rc = regulator_disable(vreg_marimba_1);
2099 if (rc)
2100 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002101};
2102
2103static int bahama_present(void)
2104{
2105 int id;
2106 switch (id = adie_get_detected_connectivity_type()) {
2107 case BAHAMA_ID:
2108 return 1;
2109
2110 case MARIMBA_ID:
2111 return 0;
2112
2113 case TIMPANI_ID:
2114 default:
2115 printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n",
2116 __func__, id);
2117 return -ENODEV;
2118 }
2119}
2120
Justin Paupore3f40f342011-08-10 18:52:16 -07002121struct regulator *fm_regulator;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002122static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
2123{
Justin Paupore3f40f342011-08-10 18:52:16 -07002124 int rc, voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002125 uint32_t irqcfg;
2126 const char *id = "FMPW";
2127
2128 int bahama_not_marimba = bahama_present();
2129
Justin Paupore3f40f342011-08-10 18:52:16 -07002130 if (bahama_not_marimba < 0) {
2131 pr_warn("%s: bahama_present: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002132 __func__, bahama_not_marimba);
Justin Paupore3f40f342011-08-10 18:52:16 -07002133 rc = -ENODEV;
2134 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002135 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002136 if (bahama_not_marimba) {
2137 fm_regulator = regulator_get(NULL, "s3");
2138 voltage = 1800000;
2139 } else {
2140 fm_regulator = regulator_get(NULL, "s2");
2141 voltage = 1300000;
2142 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002143
2144 if (IS_ERR(fm_regulator)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002145 rc = PTR_ERR(fm_regulator);
2146 pr_err("%s: regulator_get failed (%d)\n", __func__, rc);
2147 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002148 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002149
Justin Paupore3f40f342011-08-10 18:52:16 -07002150 rc = regulator_set_voltage(fm_regulator, voltage, voltage);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002151
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002152 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002153 pr_err("%s: regulator_set_voltage failed (%d)\n", __func__, rc);
2154 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002155 }
2156
Justin Paupore3f40f342011-08-10 18:52:16 -07002157 rc = regulator_enable(fm_regulator);
2158
2159 if (rc) {
2160 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2161 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002162 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002163
2164 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_ON);
2165
2166 if (rc < 0) {
2167 pr_err("%s: clock vote failed (%d)\n", __func__, rc);
2168 goto regulator_disable;
2169 }
2170
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002171 /*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2172 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002173 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002174 rc = marimba_gpio_config(1);
Justin Paupore3f40f342011-08-10 18:52:16 -07002175 if (rc < 0) {
2176 pr_err("%s: clock enable for svlte : %d\n",
2177 __func__, rc);
2178 goto clock_devote;
2179 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002180 }
2181 irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
2182 GPIO_CFG_2MA);
2183 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2184 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002185 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002186 rc = -EIO;
Justin Paupore3f40f342011-08-10 18:52:16 -07002187 goto gpio_deconfig;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002188
2189 }
2190 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002191
Justin Paupore3f40f342011-08-10 18:52:16 -07002192gpio_deconfig:
2193 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa())
2194 marimba_gpio_config(0);
2195clock_devote:
2196 pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_OFF);
2197regulator_disable:
2198 regulator_disable(fm_regulator);
2199regulator_free:
2200 regulator_put(fm_regulator);
2201 fm_regulator = NULL;
2202out:
2203 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002204};
2205
2206static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
2207{
2208 int rc;
2209 const char *id = "FMPW";
2210 uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
2211 GPIO_CFG_2MA);
2212
2213 int bahama_not_marimba = bahama_present();
2214 if (bahama_not_marimba == -1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002215 pr_warn("%s: bahama_present: %d\n",
2216 __func__, bahama_not_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002217 return;
2218 }
2219
2220 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2221 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002222 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002223 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002224 if (!IS_ERR_OR_NULL(fm_regulator)) {
2225 rc = regulator_disable(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002226
Justin Paupore3f40f342011-08-10 18:52:16 -07002227 if (rc)
2228 pr_err("%s: return val: %d\n", __func__, rc);
2229
2230 regulator_put(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002231 fm_regulator = NULL;
2232 }
2233 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
2234 PMAPP_CLOCK_VOTE_OFF);
2235 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002236 pr_err("%s: clock_vote return val: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002237
2238 /*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2239 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002240 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002241 rc = marimba_gpio_config(0);
2242 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002243 pr_err("%s: clock disable for svlte : %d\n",
2244 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002245 }
2246}
2247
2248static struct marimba_fm_platform_data marimba_fm_pdata = {
2249 .fm_setup = fm_radio_setup,
2250 .fm_shutdown = fm_radio_shutdown,
2251 .irq = MSM_GPIO_TO_INT(147),
2252 .vreg_s2 = NULL,
2253 .vreg_xo_out = NULL,
2254 .is_fm_soc_i2s_master = false,
2255 .config_i2s_gpio = NULL,
2256};
2257
2258
2259/* Slave id address for FM/CDC/QMEMBIST
2260 * Values can be programmed using Marimba slave id 0
2261 * should there be a conflict with other I2C devices
2262 * */
2263#define MARIMBA_SLAVE_ID_FM_ADDR 0x2A
2264#define MARIMBA_SLAVE_ID_CDC_ADDR 0x77
2265#define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66
2266
2267#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
2268#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
2269
2270static const char *tsadc_id = "MADC";
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002271
Justin Paupore3f40f342011-08-10 18:52:16 -07002272static struct regulator_bulk_data regs_tsadc_marimba[] = {
2273 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2274 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002275};
Justin Paupore3f40f342011-08-10 18:52:16 -07002276
2277static struct regulator_bulk_data regs_tsadc_timpani[] = {
2278 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2279 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2280 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2281};
2282
2283static struct regulator_bulk_data *regs_tsadc;
2284static int regs_tsadc_count;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002285
2286static int marimba_tsadc_power(int vreg_on)
2287{
Justin Paupore3f40f342011-08-10 18:52:16 -07002288 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002289 int tsadc_adie_type = adie_get_detected_codec_type();
2290
Justin Paupore3f40f342011-08-10 18:52:16 -07002291 switch (tsadc_adie_type) {
2292 case TIMPANI_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002293 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2294 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2295 if (rc) {
2296 pr_err("%s: unable to %svote for d1 clk\n",
2297 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002298 goto D1_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002299 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002300
2301 /* fall through */
2302 case MARIMBA_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002303 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2304 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2305 if (rc) {
2306 pr_err("%s: unable to %svote for d1 clk\n",
2307 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002308 goto D0_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002309 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002310
Justin Paupore3f40f342011-08-10 18:52:16 -07002311 WARN_ON(regs_tsadc_count == 0);
2312
2313 rc = vreg_on ?
2314 regulator_bulk_enable(regs_tsadc_count, regs_tsadc) :
2315 regulator_bulk_disable(regs_tsadc_count, regs_tsadc);
2316
2317 if (rc) {
2318 pr_err("%s: regulator %sable failed: %d\n",
2319 __func__, vreg_on ? "en" : "dis", rc);
2320 goto regulator_switch_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002321 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002322
2323 break;
2324 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002325 pr_err("%s:Adie %d not supported\n",
2326 __func__, tsadc_adie_type);
2327 return -ENODEV;
2328 }
2329
2330 msleep(5); /* ensure power is stable */
2331
2332 return 0;
2333
Justin Paupore3f40f342011-08-10 18:52:16 -07002334regulator_switch_fail:
2335 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2336 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2337D0_vote_fail:
2338 if (tsadc_adie_type == TIMPANI_ID)
2339 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2340 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2341D1_vote_fail:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002342 return rc;
2343}
2344
2345static int marimba_tsadc_init(void)
2346{
Justin Paupore3f40f342011-08-10 18:52:16 -07002347 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002348 int tsadc_adie_type = adie_get_detected_codec_type();
2349
Justin Paupore3f40f342011-08-10 18:52:16 -07002350 switch (tsadc_adie_type) {
2351 case MARIMBA_ID:
2352 regs_tsadc = regs_tsadc_marimba;
2353 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_marimba);
2354 break;
2355 case TIMPANI_ID:
2356 regs_tsadc = regs_tsadc_timpani;
2357 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_timpani);
2358 break;
2359 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002360 pr_err("%s:Adie %d not supported\n",
2361 __func__, tsadc_adie_type);
Justin Paupore3f40f342011-08-10 18:52:16 -07002362 rc = -ENODEV;
2363 goto out;
2364 }
2365
2366 rc = regulator_bulk_get(NULL, regs_tsadc_count, regs_tsadc);
2367 if (rc) {
2368 pr_err("%s: could not get regulators: %d\n",
2369 __func__, rc);
2370 goto out;
2371 }
2372
2373 rc = regulator_bulk_set_voltage(regs_tsadc_count, regs_tsadc);
2374 if (rc) {
2375 pr_err("%s: could not set regulator voltages: %d\n",
2376 __func__, rc);
2377 goto vreg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002378 }
2379
2380 return 0;
2381
Justin Paupore3f40f342011-08-10 18:52:16 -07002382vreg_free:
2383 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2384out:
2385 regs_tsadc = NULL;
2386 regs_tsadc_count = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002387 return rc;
2388}
2389
2390static int marimba_tsadc_exit(void)
2391{
Justin Paupore3f40f342011-08-10 18:52:16 -07002392 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2393 regs_tsadc_count = 0;
2394 regs_tsadc = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002395
Justin Paupore3f40f342011-08-10 18:52:16 -07002396 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002397}
2398
2399
2400static struct msm_ts_platform_data msm_ts_data = {
Anirudh Ghayal82b74722012-01-19 15:35:34 +05302401 .min_x = 284,
2402 .max_x = 3801,
2403 .min_y = 155,
2404 .max_y = 3929,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002405 .min_press = 0,
2406 .max_press = 255,
2407 .inv_x = 4096,
2408 .inv_y = 4096,
2409 .can_wakeup = false,
2410};
2411
2412static struct marimba_tsadc_platform_data marimba_tsadc_pdata = {
2413 .marimba_tsadc_power = marimba_tsadc_power,
2414 .init = marimba_tsadc_init,
2415 .exit = marimba_tsadc_exit,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002416 .tsadc_prechg_en = true,
2417 .can_wakeup = false,
2418 .setup = {
2419 .pen_irq_en = true,
2420 .tsadc_en = true,
2421 },
2422 .params2 = {
2423 .input_clk_khz = 2400,
2424 .sample_prd = TSADC_CLK_3,
2425 },
2426 .params3 = {
2427 .prechg_time_nsecs = 6400,
2428 .stable_time_nsecs = 6400,
2429 .tsadc_test_mode = 0,
2430 },
2431 .tssc_data = &msm_ts_data,
2432};
2433
Justin Paupore3f40f342011-08-10 18:52:16 -07002434static struct regulator_bulk_data codec_regs[] = {
2435 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
2436};
2437
2438static int __init msm_marimba_codec_init(void)
2439{
2440 int rc = regulator_bulk_get(NULL, ARRAY_SIZE(codec_regs), codec_regs);
2441
2442 if (rc) {
2443 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2444 goto out;
2445 }
2446
2447 rc = regulator_bulk_set_voltage(ARRAY_SIZE(codec_regs), codec_regs);
2448 if (rc) {
2449 pr_err("%s: could not set regulator voltages: %d\n",
2450 __func__, rc);
2451 goto reg_free;
2452 }
2453
2454 return rc;
2455
2456reg_free:
2457 regulator_bulk_free(ARRAY_SIZE(codec_regs), codec_regs);
2458out:
2459 return rc;
2460}
2461
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002462static int msm_marimba_codec_power(int vreg_on)
2463{
Justin Paupore3f40f342011-08-10 18:52:16 -07002464 int rc = vreg_on ?
2465 regulator_bulk_enable(ARRAY_SIZE(codec_regs), codec_regs) :
2466 regulator_bulk_disable(ARRAY_SIZE(codec_regs), codec_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002467
Justin Paupore3f40f342011-08-10 18:52:16 -07002468 if (rc) {
2469 pr_err("%s: could not %sable regulators: %d",
2470 __func__, vreg_on ? "en" : "dis", rc);
2471 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002472 }
2473
Justin Paupore3f40f342011-08-10 18:52:16 -07002474 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002475}
2476
2477static struct marimba_codec_platform_data mariba_codec_pdata = {
2478 .marimba_codec_power = msm_marimba_codec_power,
2479#ifdef CONFIG_MARIMBA_CODEC
2480 .snddev_profile_init = msm_snddev_init,
2481#endif
2482};
2483
2484static struct marimba_platform_data marimba_pdata = {
2485 .slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR,
2486 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2487 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2488 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
2489 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
2490 .marimba_setup = msm_marimba_setup_power,
2491 .marimba_shutdown = msm_marimba_shutdown_power,
2492 .bahama_setup = msm_bahama_setup_power,
2493 .bahama_shutdown = msm_bahama_shutdown_power,
2494 .marimba_gpio_config = msm_marimba_gpio_config_svlte,
2495 .bahama_core_config = msm_bahama_core_config,
2496 .fm = &marimba_fm_pdata,
2497 .codec = &mariba_codec_pdata,
2498 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2499};
2500
2501static void __init msm7x30_init_marimba(void)
2502{
2503 int rc;
2504
Justin Paupore3f40f342011-08-10 18:52:16 -07002505 struct regulator_bulk_data regs[] = {
2506 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2507 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2508 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
2509 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002510
Justin Paupore3f40f342011-08-10 18:52:16 -07002511 rc = msm_marimba_codec_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002512
Justin Paupore3f40f342011-08-10 18:52:16 -07002513 if (rc) {
2514 pr_err("%s: msm_marimba_codec_init failed (%d)\n",
2515 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002516 return;
2517 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002518
2519 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
2520
2521 if (rc) {
2522 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2523 return;
2524 }
2525
2526 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
2527
2528 if (rc) {
2529 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2530 regulator_bulk_free(ARRAY_SIZE(regs), regs);
2531 return;
2532 }
2533
2534 vreg_marimba_1 = regs[0].consumer;
2535 vreg_marimba_2 = regs[1].consumer;
2536 vreg_bahama = regs[2].consumer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002537}
2538
2539static struct marimba_codec_platform_data timpani_codec_pdata = {
2540 .marimba_codec_power = msm_marimba_codec_power,
2541#ifdef CONFIG_TIMPANI_CODEC
2542 .snddev_profile_init = msm_snddev_init_timpani,
2543#endif
2544};
2545
2546static struct marimba_platform_data timpani_pdata = {
2547 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2548 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2549 .marimba_setup = msm_timpani_setup_power,
2550 .marimba_shutdown = msm_timpani_shutdown_power,
2551 .codec = &timpani_codec_pdata,
2552 .tsadc = &marimba_tsadc_pdata,
2553 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2554};
2555
2556#define TIMPANI_I2C_SLAVE_ADDR 0xD
2557
2558static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
2559 {
2560 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
2561 .platform_data = &timpani_pdata,
2562 },
2563};
2564
2565#ifdef CONFIG_MSM7KV2_AUDIO
2566static struct resource msm_aictl_resources[] = {
2567 {
2568 .name = "aictl",
2569 .start = 0xa5000100,
2570 .end = 0xa5000100,
2571 .flags = IORESOURCE_MEM,
2572 }
2573};
2574
2575static struct resource msm_mi2s_resources[] = {
2576 {
2577 .name = "hdmi",
2578 .start = 0xac900000,
2579 .end = 0xac900038,
2580 .flags = IORESOURCE_MEM,
2581 },
2582 {
2583 .name = "codec_rx",
2584 .start = 0xac940040,
2585 .end = 0xac940078,
2586 .flags = IORESOURCE_MEM,
2587 },
2588 {
2589 .name = "codec_tx",
2590 .start = 0xac980080,
2591 .end = 0xac9800B8,
2592 .flags = IORESOURCE_MEM,
2593 }
2594
2595};
2596
2597static struct msm_lpa_platform_data lpa_pdata = {
2598 .obuf_hlb_size = 0x2BFF8,
2599 .dsp_proc_id = 0,
2600 .app_proc_id = 2,
2601 .nosb_config = {
2602 .llb_min_addr = 0,
2603 .llb_max_addr = 0x3ff8,
2604 .sb_min_addr = 0,
2605 .sb_max_addr = 0,
2606 },
2607 .sb_config = {
2608 .llb_min_addr = 0,
2609 .llb_max_addr = 0x37f8,
2610 .sb_min_addr = 0x3800,
2611 .sb_max_addr = 0x3ff8,
2612 }
2613};
2614
2615static struct resource msm_lpa_resources[] = {
2616 {
2617 .name = "lpa",
2618 .start = 0xa5000000,
2619 .end = 0xa50000a0,
2620 .flags = IORESOURCE_MEM,
2621 }
2622};
2623
2624static struct resource msm_aux_pcm_resources[] = {
2625
2626 {
2627 .name = "aux_codec_reg_addr",
2628 .start = 0xac9c00c0,
2629 .end = 0xac9c00c8,
2630 .flags = IORESOURCE_MEM,
2631 },
2632 {
2633 .name = "aux_pcm_dout",
2634 .start = 138,
2635 .end = 138,
2636 .flags = IORESOURCE_IO,
2637 },
2638 {
2639 .name = "aux_pcm_din",
2640 .start = 139,
2641 .end = 139,
2642 .flags = IORESOURCE_IO,
2643 },
2644 {
2645 .name = "aux_pcm_syncout",
2646 .start = 140,
2647 .end = 140,
2648 .flags = IORESOURCE_IO,
2649 },
2650 {
2651 .name = "aux_pcm_clkin_a",
2652 .start = 141,
2653 .end = 141,
2654 .flags = IORESOURCE_IO,
2655 },
2656};
2657
2658static struct platform_device msm_aux_pcm_device = {
2659 .name = "msm_aux_pcm",
2660 .id = 0,
2661 .num_resources = ARRAY_SIZE(msm_aux_pcm_resources),
2662 .resource = msm_aux_pcm_resources,
2663};
2664
2665struct platform_device msm_aictl_device = {
2666 .name = "audio_interct",
2667 .id = 0,
2668 .num_resources = ARRAY_SIZE(msm_aictl_resources),
2669 .resource = msm_aictl_resources,
2670};
2671
2672struct platform_device msm_mi2s_device = {
2673 .name = "mi2s",
2674 .id = 0,
2675 .num_resources = ARRAY_SIZE(msm_mi2s_resources),
2676 .resource = msm_mi2s_resources,
2677};
2678
2679struct platform_device msm_lpa_device = {
2680 .name = "lpa",
2681 .id = 0,
2682 .num_resources = ARRAY_SIZE(msm_lpa_resources),
2683 .resource = msm_lpa_resources,
2684 .dev = {
2685 .platform_data = &lpa_pdata,
2686 },
2687};
2688#endif /* CONFIG_MSM7KV2_AUDIO */
2689
2690#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2691 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2692 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2693 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2694 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2695 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2696#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2697 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2698 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2699 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2700 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2701 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2702 #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2703 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2704 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2705 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2706 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2707 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2708 #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2709 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2710 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2711 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2712 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2713 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2714#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
2715
2716static unsigned int dec_concurrency_table[] = {
2717 /* Audio LP */
2718 0,
2719 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2720 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2721 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2722 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)|
2723 (1<<MSM_ADSP_OP_DM)),
2724
2725 /* Concurrency 1 */
2726 (DEC4_FORMAT),
2727 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2728 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2729 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2730 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2731
2732 /* Concurrency 2 */
2733 (DEC4_FORMAT),
2734 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2735 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2736 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2737 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2738
2739 /* Concurrency 3 */
2740 (DEC4_FORMAT),
2741 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2742 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2743 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2744 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2745
2746 /* Concurrency 4 */
2747 (DEC4_FORMAT),
2748 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2749 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2750 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2751 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2752
2753 /* Concurrency 5 */
2754 (DEC4_FORMAT),
2755 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2756 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2757 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2758 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2759
2760 /* Concurrency 6 */
2761 (DEC4_FORMAT),
2762 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2763 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2764 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2765 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2766};
2767
2768#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
2769 .module_queueid = queueid, .module_decid = decid, \
2770 .nr_codec_support = nr_codec}
2771
2772#define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
2773 .max_instances_same_dec = max_instance_same, \
2774 .max_instances_diff_dec = max_instance_diff}
2775
2776static struct msm_adspdec_info dec_info_list[] = {
2777 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
2778 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
2779 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
2780 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
2781 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
2782};
2783
2784static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
2785 /* Non Turbo Mode */
2786 {
2787 DEC_INSTANCE(4, 3), /* WAV */
2788 DEC_INSTANCE(4, 3), /* ADPCM */
2789 DEC_INSTANCE(4, 2), /* MP3 */
2790 DEC_INSTANCE(0, 0), /* Real Audio */
2791 DEC_INSTANCE(4, 2), /* WMA */
2792 DEC_INSTANCE(3, 2), /* AAC */
2793 DEC_INSTANCE(0, 0), /* Reserved */
2794 DEC_INSTANCE(0, 0), /* MIDI */
2795 DEC_INSTANCE(4, 3), /* YADPCM */
2796 DEC_INSTANCE(4, 3), /* QCELP */
2797 DEC_INSTANCE(4, 3), /* AMRNB */
2798 DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
2799 DEC_INSTANCE(4, 3), /* EVRC */
2800 DEC_INSTANCE(1, 1), /* WMAPRO */
2801 },
2802 /* Turbo Mode */
2803 {
2804 DEC_INSTANCE(4, 3), /* WAV */
2805 DEC_INSTANCE(4, 3), /* ADPCM */
2806 DEC_INSTANCE(4, 3), /* MP3 */
2807 DEC_INSTANCE(0, 0), /* Real Audio */
2808 DEC_INSTANCE(4, 3), /* WMA */
2809 DEC_INSTANCE(4, 3), /* AAC */
2810 DEC_INSTANCE(0, 0), /* Reserved */
2811 DEC_INSTANCE(0, 0), /* MIDI */
2812 DEC_INSTANCE(4, 3), /* YADPCM */
2813 DEC_INSTANCE(4, 3), /* QCELP */
2814 DEC_INSTANCE(4, 3), /* AMRNB */
2815 DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
2816 DEC_INSTANCE(4, 3), /* EVRC */
2817 DEC_INSTANCE(1, 2), /* WMAPRO */
2818 },
2819};
2820
2821static struct msm_adspdec_database msm_device_adspdec_database = {
2822 .num_dec = ARRAY_SIZE(dec_info_list),
2823 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
2824 ARRAY_SIZE(dec_info_list)),
2825 .dec_concurrency_table = dec_concurrency_table,
2826 .dec_info_list = dec_info_list,
2827 .dec_instance_list = &dec_instance_list[0][0],
2828};
2829
2830static struct platform_device msm_device_adspdec = {
2831 .name = "msm_adspdec",
2832 .id = -1,
2833 .dev = {
2834 .platform_data = &msm_device_adspdec_database
2835 },
2836};
2837
2838static struct resource smc91x_resources[] = {
2839 [0] = {
2840 .start = 0x8A000300,
2841 .end = 0x8A0003ff,
2842 .flags = IORESOURCE_MEM,
2843 },
2844 [1] = {
2845 .start = MSM_GPIO_TO_INT(156),
2846 .end = MSM_GPIO_TO_INT(156),
2847 .flags = IORESOURCE_IRQ,
2848 },
2849};
2850
2851static struct platform_device smc91x_device = {
2852 .name = "smc91x",
2853 .id = 0,
2854 .num_resources = ARRAY_SIZE(smc91x_resources),
2855 .resource = smc91x_resources,
2856};
2857
2858static struct smsc911x_platform_config smsc911x_config = {
2859 .phy_interface = PHY_INTERFACE_MODE_MII,
2860 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
2861 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
2862 .flags = SMSC911X_USE_32BIT,
2863};
2864
2865static struct resource smsc911x_resources[] = {
2866 [0] = {
2867 .start = 0x8D000000,
2868 .end = 0x8D000100,
2869 .flags = IORESOURCE_MEM,
2870 },
2871 [1] = {
2872 .start = MSM_GPIO_TO_INT(88),
2873 .end = MSM_GPIO_TO_INT(88),
2874 .flags = IORESOURCE_IRQ,
2875 },
2876};
2877
2878static struct platform_device smsc911x_device = {
2879 .name = "smsc911x",
2880 .id = -1,
2881 .num_resources = ARRAY_SIZE(smsc911x_resources),
2882 .resource = smsc911x_resources,
2883 .dev = {
2884 .platform_data = &smsc911x_config,
2885 },
2886};
2887
2888static struct msm_gpio smsc911x_gpios[] = {
2889 { GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" },
2890 { GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" },
2891 { GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" },
2892 { GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" },
2893 { GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" },
2894 { GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" },
2895 { GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" },
2896 { GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" },
2897};
2898
2899static void msm7x30_cfg_smsc911x(void)
2900{
2901 int rc;
2902
2903 rc = msm_gpios_request_enable(smsc911x_gpios,
2904 ARRAY_SIZE(smsc911x_gpios));
2905 if (rc)
2906 pr_err("%s: unable to enable gpios\n", __func__);
2907}
2908
2909#ifdef CONFIG_USB_G_ANDROID
2910static struct android_usb_platform_data android_usb_pdata = {
2911 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2912};
2913
2914static struct platform_device android_usb_device = {
2915 .name = "android_usb",
2916 .id = -1,
2917 .dev = {
2918 .platform_data = &android_usb_pdata,
2919 },
2920};
2921#endif
2922
2923static struct msm_gpio optnav_config_data[] = {
2924 { GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA),
2925 "optnav_chip_select" },
2926};
2927
Justin Paupore3f40f342011-08-10 18:52:16 -07002928static struct regulator_bulk_data optnav_regulators[] = {
2929 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2930 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
2931 { .supply = "gp9", .min_uV = 1800000, .max_uV = 1800000 },
2932 { .supply = "usb", .min_uV = 3300000, .max_uV = 3300000 },
2933};
2934
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002935static void __iomem *virtual_optnav;
2936
2937static int optnav_gpio_setup(void)
2938{
2939 int rc = -ENODEV;
2940 rc = msm_gpios_request_enable(optnav_config_data,
2941 ARRAY_SIZE(optnav_config_data));
2942
Justin Paupore3f40f342011-08-10 18:52:16 -07002943 if (rc)
2944 return rc;
2945
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002946 /* Configure the FPGA for GPIOs */
2947 virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4);
2948 if (!virtual_optnav) {
2949 pr_err("%s:Could not ioremap region\n", __func__);
2950 return -ENOMEM;
2951 }
2952 /*
2953 * Configure the FPGA to set GPIO 19 as
2954 * normal, active(enabled), output(MSM to SURF)
2955 */
2956 writew(0x311E, virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002957
2958 rc = regulator_bulk_get(NULL, ARRAY_SIZE(optnav_regulators),
2959 optnav_regulators);
2960 if (rc)
2961 return rc;
2962
2963 rc = regulator_bulk_set_voltage(ARRAY_SIZE(optnav_regulators),
2964 optnav_regulators);
2965
2966 if (rc)
2967 goto regulator_put;
2968
2969 return rc;
2970
2971regulator_put:
2972 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002973 return rc;
2974}
2975
2976static void optnav_gpio_release(void)
2977{
2978 msm_gpios_disable_free(optnav_config_data,
2979 ARRAY_SIZE(optnav_config_data));
2980 iounmap(virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002981 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002982}
2983
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002984static int optnav_enable(void)
2985{
2986 int rc;
2987 /*
2988 * Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
2989 * for I2C communication with keyboard.
2990 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002991
Justin Paupore3f40f342011-08-10 18:52:16 -07002992 rc = regulator_bulk_enable(ARRAY_SIZE(optnav_regulators),
2993 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002994
Justin Paupore3f40f342011-08-10 18:52:16 -07002995 if (rc)
2996 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002997
2998 /* Enable the chip select GPIO */
2999 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
3000 gpio_set_value(OPTNAV_CHIP_SELECT, 0);
3001
3002 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003003}
3004
3005static void optnav_disable(void)
3006{
Justin Paupore3f40f342011-08-10 18:52:16 -07003007 regulator_bulk_disable(ARRAY_SIZE(optnav_regulators),
3008 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003009
3010 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
3011}
3012
3013static struct ofn_atlab_platform_data optnav_data = {
3014 .gpio_setup = optnav_gpio_setup,
3015 .gpio_release = optnav_gpio_release,
3016 .optnav_on = optnav_enable,
3017 .optnav_off = optnav_disable,
3018 .rotate_xy = 0,
3019 .function1 = {
3020 .no_motion1_en = true,
3021 .touch_sensor_en = true,
3022 .ofn_en = true,
3023 .clock_select_khz = 1500,
3024 .cpi_selection = 1200,
3025 },
3026 .function2 = {
3027 .invert_y = false,
3028 .invert_x = true,
3029 .swap_x_y = false,
3030 .hold_a_b_en = true,
3031 .motion_filter_en = true,
3032 },
3033};
3034
3035static int hdmi_comm_power(int on, int show);
3036static int hdmi_init_irq(void);
3037static int hdmi_enable_5v(int on);
3038static int hdmi_core_power(int on, int show);
3039static int hdmi_cec_power(int on);
3040static bool hdmi_check_hdcp_hw_support(void);
3041
3042static struct msm_hdmi_platform_data adv7520_hdmi_data = {
3043 .irq = MSM_GPIO_TO_INT(18),
3044 .comm_power = hdmi_comm_power,
3045 .init_irq = hdmi_init_irq,
3046 .enable_5v = hdmi_enable_5v,
3047 .core_power = hdmi_core_power,
3048 .cec_power = hdmi_cec_power,
3049 .check_hdcp_hw_support = hdmi_check_hdcp_hw_support,
3050};
3051
3052#ifdef CONFIG_BOSCH_BMA150
Justin Paupore3f40f342011-08-10 18:52:16 -07003053
3054static struct regulator_bulk_data sensors_ldo[] = {
3055 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
3056 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
3057};
3058
3059static int __init sensors_ldo_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003060{
3061 int rc;
3062
Justin Paupore3f40f342011-08-10 18:52:16 -07003063 rc = regulator_bulk_get(NULL, ARRAY_SIZE(sensors_ldo), sensors_ldo);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003064
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003065 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003066 pr_err("%s: could not get regulators: %d\n", __func__, rc);
3067 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003068 }
3069
Justin Paupore3f40f342011-08-10 18:52:16 -07003070 rc = regulator_bulk_set_voltage(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3071
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003072 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003073 pr_err("%s: could not set voltages: %d\n", __func__, rc);
3074 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003075 }
3076
3077 return 0;
3078
Justin Paupore3f40f342011-08-10 18:52:16 -07003079reg_free:
3080 regulator_bulk_free(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3081out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003082 return rc;
3083}
3084
Justin Paupore3f40f342011-08-10 18:52:16 -07003085static int sensors_ldo_set(int on)
3086{
3087 int rc = on ?
3088 regulator_bulk_enable(ARRAY_SIZE(sensors_ldo), sensors_ldo) :
3089 regulator_bulk_disable(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3090
3091 if (rc)
3092 pr_err("%s: could not %sable regulators: %d\n",
3093 __func__, on ? "en" : "dis", rc);
3094
3095 return rc;
3096}
3097
3098static int sensors_ldo_enable(void)
3099{
3100 return sensors_ldo_set(1);
3101}
3102
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003103static void sensors_ldo_disable(void)
3104{
Justin Paupore3f40f342011-08-10 18:52:16 -07003105 sensors_ldo_set(0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003106}
Justin Paupore3f40f342011-08-10 18:52:16 -07003107
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003108static struct bma150_platform_data bma150_data = {
3109 .power_on = sensors_ldo_enable,
3110 .power_off = sensors_ldo_disable,
3111};
3112
3113static struct i2c_board_info bma150_board_info[] __initdata = {
3114 {
3115 I2C_BOARD_INFO("bma150", 0x38),
3116 .flags = I2C_CLIENT_WAKE,
3117 .irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
3118 .platform_data = &bma150_data,
3119 },
3120};
3121#endif
3122
3123static struct i2c_board_info msm_i2c_board_info[] = {
3124 {
3125 I2C_BOARD_INFO("m33c01", OPTNAV_I2C_SLAVE_ADDR),
3126 .irq = MSM_GPIO_TO_INT(OPTNAV_IRQ),
3127 .platform_data = &optnav_data,
3128 },
3129 {
3130 I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR),
3131 .platform_data = &adv7520_hdmi_data,
3132 },
3133};
3134
3135static struct i2c_board_info msm_marimba_board_info[] = {
3136 {
3137 I2C_BOARD_INFO("marimba", 0xc),
3138 .platform_data = &marimba_pdata,
3139 }
3140};
3141
3142
3143static struct msm_handset_platform_data hs_platform_data = {
3144 .hs_name = "7k_handset",
3145 .pwr_key_delay_ms = 500, /* 0 will disable end key */
3146};
3147
3148static struct platform_device hs_device = {
3149 .name = "msm-handset",
3150 .id = -1,
3151 .dev = {
3152 .platform_data = &hs_platform_data,
3153 },
3154};
3155
3156static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +05303157 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003158 .idle_supported = 1,
3159 .suspend_supported = 1,
3160 .idle_enabled = 1,
3161 .suspend_enabled = 1,
3162 .latency = 8594,
3163 .residency = 23740,
3164 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303165 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003166 .idle_supported = 1,
3167 .suspend_supported = 1,
3168 .idle_enabled = 1,
3169 .suspend_enabled = 1,
3170 .latency = 4594,
3171 .residency = 23740,
3172 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303173 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003174#ifdef CONFIG_MSM_STANDALONE_POWER_COLLAPSE
3175 .idle_supported = 1,
3176 .suspend_supported = 1,
3177 .idle_enabled = 1,
3178 .suspend_enabled = 0,
3179#else /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3180 .idle_supported = 0,
3181 .suspend_supported = 0,
3182 .idle_enabled = 0,
3183 .suspend_enabled = 0,
3184#endif /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3185 .latency = 500,
3186 .residency = 6000,
3187 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303188 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003189 .idle_supported = 1,
3190 .suspend_supported = 1,
3191 .idle_enabled = 0,
3192 .suspend_enabled = 1,
3193 .latency = 443,
3194 .residency = 1098,
3195 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303196 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003197 .idle_supported = 1,
3198 .suspend_supported = 1,
3199 .idle_enabled = 1,
3200 .suspend_enabled = 1,
3201 .latency = 2,
3202 .residency = 0,
3203 },
3204};
3205
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003206static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3207 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
3208 .v_addr = (uint32_t *)PAGE_OFFSET,
3209};
3210
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003211static struct resource qsd_spi_resources[] = {
3212 {
3213 .name = "spi_irq_in",
3214 .start = INT_SPI_INPUT,
3215 .end = INT_SPI_INPUT,
3216 .flags = IORESOURCE_IRQ,
3217 },
3218 {
3219 .name = "spi_irq_out",
3220 .start = INT_SPI_OUTPUT,
3221 .end = INT_SPI_OUTPUT,
3222 .flags = IORESOURCE_IRQ,
3223 },
3224 {
3225 .name = "spi_irq_err",
3226 .start = INT_SPI_ERROR,
3227 .end = INT_SPI_ERROR,
3228 .flags = IORESOURCE_IRQ,
3229 },
3230 {
3231 .name = "spi_base",
3232 .start = 0xA8000000,
3233 .end = 0xA8000000 + SZ_4K - 1,
3234 .flags = IORESOURCE_MEM,
3235 },
3236 {
3237 .name = "spidm_channels",
3238 .flags = IORESOURCE_DMA,
3239 },
3240 {
3241 .name = "spidm_crci",
3242 .flags = IORESOURCE_DMA,
3243 },
3244};
3245
3246#define AMDH0_BASE_PHYS 0xAC200000
3247#define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
3248static int msm_qsd_spi_dma_config(void)
3249{
3250 void __iomem *ct_adm_base = 0;
3251 u32 spi_mux = 0;
3252 int ret = 0;
3253
3254 ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
3255 if (!ct_adm_base) {
3256 pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
3257 return -ENOMEM;
3258 }
3259
3260 spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
3261
3262 qsd_spi_resources[4].start = DMOV_USB_CHAN;
3263 qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
3264
3265 switch (spi_mux) {
3266 case (1):
3267 qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
3268 qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
3269 break;
3270 case (2):
3271 qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
3272 qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
3273 break;
3274 case (3):
3275 qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
3276 qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
3277 break;
3278 default:
3279 ret = -ENOENT;
3280 }
3281
3282 iounmap(ct_adm_base);
3283
3284 return ret;
3285}
3286
3287static struct platform_device qsd_device_spi = {
3288 .name = "spi_qsd",
3289 .id = 0,
3290 .num_resources = ARRAY_SIZE(qsd_spi_resources),
3291 .resource = qsd_spi_resources,
3292};
3293
3294#ifdef CONFIG_SPI_QSD
3295static struct spi_board_info lcdc_sharp_spi_board_info[] __initdata = {
3296 {
3297 .modalias = "lcdc_sharp_ls038y7dx01",
3298 .mode = SPI_MODE_1,
3299 .bus_num = 0,
3300 .chip_select = 0,
3301 .max_speed_hz = 26331429,
3302 }
3303};
3304static struct spi_board_info lcdc_toshiba_spi_board_info[] __initdata = {
3305 {
3306 .modalias = "lcdc_toshiba_ltm030dd40",
3307 .mode = SPI_MODE_3|SPI_CS_HIGH,
3308 .bus_num = 0,
3309 .chip_select = 0,
3310 .max_speed_hz = 9963243,
3311 }
3312};
3313#endif
3314
3315static struct msm_gpio qsd_spi_gpio_config_data[] = {
3316 { GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3317 { GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3318 { GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" },
3319 { GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3320};
3321
3322static int msm_qsd_spi_gpio_config(void)
3323{
3324 return msm_gpios_request_enable(qsd_spi_gpio_config_data,
3325 ARRAY_SIZE(qsd_spi_gpio_config_data));
3326}
3327
3328static void msm_qsd_spi_gpio_release(void)
3329{
3330 msm_gpios_disable_free(qsd_spi_gpio_config_data,
3331 ARRAY_SIZE(qsd_spi_gpio_config_data));
3332}
3333
3334static struct msm_spi_platform_data qsd_spi_pdata = {
3335 .max_clock_speed = 26331429,
3336 .gpio_config = msm_qsd_spi_gpio_config,
3337 .gpio_release = msm_qsd_spi_gpio_release,
3338 .dma_config = msm_qsd_spi_dma_config,
3339};
3340
3341static void __init msm_qsd_spi_init(void)
3342{
3343 qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
3344}
3345
3346#ifdef CONFIG_USB_EHCI_MSM_72K
3347static void msm_hsusb_vbus_power(unsigned phy_info, int on)
3348{
3349 int rc;
3350 static int vbus_is_on;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303351 struct pm8xxx_gpio_init_info usb_vbus = {
3352 PM8058_GPIO_PM_TO_SYS(36),
3353 {
3354 .direction = PM_GPIO_DIR_OUT,
3355 .pull = PM_GPIO_PULL_NO,
3356 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3357 .output_value = 1,
3358 .vin_sel = 2,
3359 .out_strength = PM_GPIO_STRENGTH_MED,
3360 .function = PM_GPIO_FUNC_NORMAL,
3361 .inv_int_pol = 0,
3362 },
3363 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003364
3365 /* If VBUS is already on (or off), do nothing. */
3366 if (unlikely(on == vbus_is_on))
3367 return;
3368
3369 if (on) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303370 rc = pm8xxx_gpio_config(usb_vbus.gpio, &usb_vbus.config);
3371 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003372 pr_err("%s PMIC GPIO 36 write failed\n", __func__);
3373 return;
3374 }
3375 } else {
3376 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(36), 0);
3377 }
3378
3379 vbus_is_on = on;
3380}
3381
3382static struct msm_usb_host_platform_data msm_usb_host_pdata = {
3383 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
3384 .vbus_power = msm_hsusb_vbus_power,
3385 .power_budget = 180,
3386};
3387#endif
3388
3389#ifdef CONFIG_USB_MSM_OTG_72K
3390static int hsusb_rpc_connect(int connect)
3391{
3392 if (connect)
3393 return msm_hsusb_rpc_connect();
3394 else
3395 return msm_hsusb_rpc_close();
3396}
3397#endif
3398
3399#ifdef CONFIG_USB_MSM_OTG_72K
Justin Paupore3f40f342011-08-10 18:52:16 -07003400static struct regulator *vreg_3p3;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003401static int msm_hsusb_ldo_init(int init)
3402{
3403 uint32_t version = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07003404 int def_vol = 3400000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003405
3406 version = socinfo_get_version();
3407
3408 if (SOCINFO_VERSION_MAJOR(version) >= 2 &&
3409 SOCINFO_VERSION_MINOR(version) >= 1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003410 def_vol = 3075000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003411 pr_debug("%s: default voltage:%d\n", __func__, def_vol);
3412 }
3413
3414 if (init) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003415 vreg_3p3 = regulator_get(NULL, "usb");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003416 if (IS_ERR(vreg_3p3))
3417 return PTR_ERR(vreg_3p3);
Justin Paupore3f40f342011-08-10 18:52:16 -07003418 regulator_set_voltage(vreg_3p3, def_vol, def_vol);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003419 } else
Justin Paupore3f40f342011-08-10 18:52:16 -07003420 regulator_put(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003421
3422 return 0;
3423}
3424
3425static int msm_hsusb_ldo_enable(int enable)
3426{
3427 static int ldo_status;
3428
3429 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3430 return -ENODEV;
3431
3432 if (ldo_status == enable)
3433 return 0;
3434
3435 ldo_status = enable;
3436
3437 if (enable)
Justin Paupore3f40f342011-08-10 18:52:16 -07003438 return regulator_enable(vreg_3p3);
3439 else
3440 return regulator_disable(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003441}
3442
3443static int msm_hsusb_ldo_set_voltage(int mV)
3444{
Justin Paupore3f40f342011-08-10 18:52:16 -07003445 static int cur_voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003446
3447 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3448 return -ENODEV;
3449
3450 if (cur_voltage == mV)
3451 return 0;
3452
3453 cur_voltage = mV;
3454
3455 pr_debug("%s: (%d)\n", __func__, mV);
3456
Justin Paupore3f40f342011-08-10 18:52:16 -07003457 return regulator_set_voltage(vreg_3p3, mV*1000, mV*1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003458}
3459#endif
3460
3461#ifndef CONFIG_USB_EHCI_MSM_72K
3462static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init);
3463#endif
3464static struct msm_otg_platform_data msm_otg_pdata = {
3465 .rpc_connect = hsusb_rpc_connect,
3466
3467#ifndef CONFIG_USB_EHCI_MSM_72K
3468 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
3469#else
3470 .vbus_power = msm_hsusb_vbus_power,
3471#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003472 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
3473 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
3474 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
3475 .se1_gating = SE1_GATING_DISABLE,
3476 .chg_vbus_draw = hsusb_chg_vbus_draw,
3477 .chg_connected = hsusb_chg_connected,
3478 .chg_init = hsusb_chg_init,
3479 .ldo_enable = msm_hsusb_ldo_enable,
3480 .ldo_init = msm_hsusb_ldo_init,
3481 .ldo_set_voltage = msm_hsusb_ldo_set_voltage,
3482};
3483
3484#ifdef CONFIG_USB_GADGET
3485static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
3486 .is_phy_status_timer_on = 1,
3487};
3488#endif
3489#ifndef CONFIG_USB_EHCI_MSM_72K
3490typedef void (*notify_vbus_state) (int);
3491notify_vbus_state notify_vbus_state_func_ptr;
3492int vbus_on_irq;
3493static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
3494{
3495 pr_info("%s: vbus notification from pmic\n", __func__);
3496
3497 (*notify_vbus_state_func_ptr) (1);
3498
3499 return IRQ_HANDLED;
3500}
3501static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
3502{
3503 int ret;
3504
3505 if (init) {
3506 if (!callback)
3507 return -ENODEV;
3508
3509 notify_vbus_state_func_ptr = callback;
3510 vbus_on_irq = platform_get_irq_byname(&msm_device_otg,
3511 "vbus_on");
3512 if (vbus_on_irq <= 0) {
3513 pr_err("%s: unable to get vbus on irq\n", __func__);
3514 return -ENODEV;
3515 }
3516
3517 ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq,
3518 IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
3519 if (ret < 0) {
3520 pr_info("%s: request_irq for vbus_on"
3521 "interrupt failed\n", __func__);
3522 return ret;
3523 }
3524 msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
3525 return 0;
3526 } else {
3527 free_irq(vbus_on_irq, 0);
3528 notify_vbus_state_func_ptr = NULL;
3529 return 0;
3530 }
3531}
3532#endif
3533
3534static struct android_pmem_platform_data android_pmem_pdata = {
3535 .name = "pmem",
3536 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
3537 .cached = 1,
3538 .memory_type = MEMTYPE_EBI0,
3539};
3540
3541static struct platform_device android_pmem_device = {
3542 .name = "android_pmem",
3543 .id = 0,
3544 .dev = { .platform_data = &android_pmem_pdata },
3545};
3546
3547#ifndef CONFIG_SPI_QSD
3548static int lcdc_gpio_array_num[] = {
3549 45, /* spi_clk */
3550 46, /* spi_cs */
3551 47, /* spi_mosi */
3552 48, /* spi_miso */
3553 };
3554
3555static struct msm_gpio lcdc_gpio_config_data[] = {
3556 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3557 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3558 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
3559 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3560};
3561
3562static void lcdc_config_gpios(int enable)
3563{
3564 if (enable) {
3565 msm_gpios_request_enable(lcdc_gpio_config_data,
3566 ARRAY_SIZE(
3567 lcdc_gpio_config_data));
3568 } else
3569 msm_gpios_disable_free(lcdc_gpio_config_data,
3570 ARRAY_SIZE(
3571 lcdc_gpio_config_data));
3572}
3573#endif
3574
3575static struct msm_panel_common_pdata lcdc_sharp_panel_data = {
3576#ifndef CONFIG_SPI_QSD
3577 .panel_config_gpio = lcdc_config_gpios,
3578 .gpio_num = lcdc_gpio_array_num,
3579#endif
3580 .gpio = 2, /* LPG PMIC_GPIO26 channel number */
3581};
3582
3583static struct platform_device lcdc_sharp_panel_device = {
3584 .name = "lcdc_sharp_wvga",
3585 .id = 0,
3586 .dev = {
3587 .platform_data = &lcdc_sharp_panel_data,
3588 }
3589};
3590
3591static struct msm_gpio dtv_panel_irq_gpios[] = {
3592 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
3593 "hdmi_int" },
3594};
3595
3596static struct msm_gpio dtv_panel_gpios[] = {
3597 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
3598 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
3599 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
3600 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
3601 { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
3602 { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
3603 { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
3604 { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
3605 { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
3606 { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
3607 { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
3608 { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
3609 { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
3610 { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
3611 { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
3612 { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
3613 { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
3614 { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
3615 { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
3616 { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
3617 { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
3618 { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
3619 { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
3620 { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
3621 { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
3622 { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
3623 { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
3624 { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
3625 { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
3626 { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
3627 { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
3628 { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
3629};
3630
3631
3632#ifdef HDMI_RESET
3633static unsigned dtv_reset_gpio =
3634 GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3635#endif
3636
Justin Paupore3f40f342011-08-10 18:52:16 -07003637static struct regulator_bulk_data hdmi_core_regs[] = {
3638 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3639};
3640
3641static struct regulator_bulk_data hdmi_comm_regs[] = {
3642 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3643 { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 },
3644};
3645
3646static struct regulator_bulk_data hdmi_cec_regs[] = {
3647 { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 },
3648};
3649
3650static int __init hdmi_init_regs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003651{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003652 int rc;
3653
Justin Paupore3f40f342011-08-10 18:52:16 -07003654 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs),
3655 hdmi_core_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003656
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003657 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003658 pr_err("%s: could not get %s regulators: %d\n",
3659 __func__, "core", rc);
3660 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003661 }
3662
Justin Paupore3f40f342011-08-10 18:52:16 -07003663 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs),
3664 hdmi_core_regs);
3665
3666 if (rc) {
3667 pr_err("%s: could not set %s voltages: %d\n",
3668 __func__, "core", rc);
3669 goto free_core;
3670 }
3671
3672 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs),
3673 hdmi_comm_regs);
3674
3675 if (rc) {
3676 pr_err("%s: could not get %s regulators: %d\n",
3677 __func__, "comm", rc);
3678 goto free_core;
3679 }
3680
3681 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs),
3682 hdmi_comm_regs);
3683
3684 if (rc) {
3685 pr_err("%s: could not set %s voltages: %d\n",
3686 __func__, "comm", rc);
3687 goto free_comm;
3688 }
3689
3690 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs),
3691 hdmi_cec_regs);
3692
3693 if (rc) {
3694 pr_err("%s: could not get %s regulators: %d\n",
3695 __func__, "cec", rc);
3696 goto free_comm;
3697 }
3698
3699 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs),
3700 hdmi_cec_regs);
3701
3702 if (rc) {
3703 pr_err("%s: could not set %s voltages: %d\n",
3704 __func__, "cec", rc);
3705 goto free_cec;
3706 }
3707
3708 return 0;
3709
3710free_cec:
3711 regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs);
3712free_comm:
3713 regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs);
3714free_core:
3715 regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs);
3716out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003717 return rc;
3718}
3719
Justin Paupore3f40f342011-08-10 18:52:16 -07003720static int hdmi_init_irq(void)
3721{
3722 int rc = msm_gpios_enable(dtv_panel_irq_gpios,
3723 ARRAY_SIZE(dtv_panel_irq_gpios));
3724 if (rc < 0) {
3725 pr_err("%s: gpio enable failed: %d\n", __func__, rc);
3726 return rc;
3727 }
3728 pr_info("%s\n", __func__);
3729
3730 return 0;
3731}
3732
3733static int hdmi_enable_5v(int on)
3734{
3735 int pmic_gpio_hdmi_5v_en ;
3736
3737 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
3738 machine_is_msm7x30_fluid())
3739 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
3740 else
3741 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
3742
3743 pr_info("%s: %d\n", __func__, on);
3744 if (on) {
3745 int rc;
3746 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
3747 "hdmi_5V_en");
3748 if (rc) {
3749 pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
3750 __func__);
3751 return rc;
3752 }
3753 gpio_set_value_cansleep(
3754 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
3755 } else {
3756 gpio_set_value_cansleep(
3757 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
3758 gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
3759 }
3760 return 0;
3761}
3762
3763static int hdmi_comm_power(int on, int show)
3764{
3765 if (show)
3766 pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
3767 return on ?
3768 regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs),
3769 hdmi_comm_regs) :
3770 regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs),
3771 hdmi_comm_regs);
3772}
3773
3774static int hdmi_core_power(int on, int show)
3775{
3776 if (show)
3777 pr_info("%s: %d <LDO8>\n", __func__, on);
3778 return on ?
3779 regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs),
3780 hdmi_core_regs) :
3781 regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs),
3782 hdmi_core_regs);
3783}
3784
3785static int hdmi_cec_power(int on)
3786{
3787 pr_info("%s: %d <LDO17>\n", __func__, on);
3788 return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs),
3789 hdmi_cec_regs) :
3790 regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs),
3791 hdmi_cec_regs);
3792}
3793
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003794#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
3795/* there is an i2c address conflict between adv7520 and bma150 sensor after
3796 * power up on fluid. As a solution, the default address of adv7520's packet
3797 * memory is changed as soon as possible
3798 */
3799static int __init fluid_i2c_address_fixup(void)
3800{
3801 unsigned char wBuff[16];
3802 unsigned char rBuff[16];
3803 struct i2c_msg msgs[3];
3804 int res;
3805 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003806 struct i2c_adapter *adapter;
3807
3808 if (machine_is_msm7x30_fluid()) {
3809 adapter = i2c_get_adapter(0);
3810 if (!adapter) {
3811 pr_err("%s: invalid i2c adapter\n", __func__);
3812 return PTR_ERR(adapter);
3813 }
3814
3815 /* turn on LDO8 */
Justin Paupore3f40f342011-08-10 18:52:16 -07003816 rc = hdmi_core_power(1, 0);
3817 if (rc) {
3818 pr_err("%s: could not enable hdmi core regs: %d",
3819 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003820 goto adapter_put;
3821 }
3822
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003823 /* change packet memory address to 0x74 */
3824 wBuff[0] = 0x45;
3825 wBuff[1] = 0x74;
3826
3827 msgs[0].addr = ADV7520_I2C_ADDR;
3828 msgs[0].flags = 0;
3829 msgs[0].buf = (unsigned char *) wBuff;
3830 msgs[0].len = 2;
3831
3832 res = i2c_transfer(adapter, msgs, 1);
3833 if (res != 1) {
3834 pr_err("%s: error writing adv7520\n", __func__);
3835 goto ldo8_disable;
3836 }
3837
3838 /* powerdown adv7520 using bit 6 */
3839 /* i2c read first */
3840 wBuff[0] = 0x41;
3841
3842 msgs[0].addr = ADV7520_I2C_ADDR;
3843 msgs[0].flags = 0;
3844 msgs[0].buf = (unsigned char *) wBuff;
3845 msgs[0].len = 1;
3846
3847 msgs[1].addr = ADV7520_I2C_ADDR;
3848 msgs[1].flags = I2C_M_RD;
3849 msgs[1].buf = rBuff;
3850 msgs[1].len = 1;
3851 res = i2c_transfer(adapter, msgs, 2);
3852 if (res != 2) {
3853 pr_err("%s: error reading adv7520\n", __func__);
3854 goto ldo8_disable;
3855 }
3856
3857 /* i2c write back */
3858 wBuff[0] = 0x41;
3859 wBuff[1] = rBuff[0] | 0x40;
3860
3861 msgs[0].addr = ADV7520_I2C_ADDR;
3862 msgs[0].flags = 0;
3863 msgs[0].buf = (unsigned char *) wBuff;
3864 msgs[0].len = 2;
3865
3866 res = i2c_transfer(adapter, msgs, 1);
3867 if (res != 1) {
3868 pr_err("%s: error writing adv7520\n", __func__);
3869 goto ldo8_disable;
3870 }
3871
3872 /* for successful fixup, we release the i2c adapter */
3873 /* but leave ldo8 on so that the adv7520 is not repowered */
3874 i2c_put_adapter(adapter);
3875 pr_info("%s: fluid i2c address conflict resolved\n", __func__);
3876 }
3877 return 0;
3878
3879ldo8_disable:
Justin Paupore3f40f342011-08-10 18:52:16 -07003880 hdmi_core_power(0, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003881adapter_put:
3882 i2c_put_adapter(adapter);
3883 return rc;
3884}
3885fs_initcall_sync(fluid_i2c_address_fixup);
3886#endif
3887
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003888static bool hdmi_check_hdcp_hw_support(void)
3889{
3890 if (machine_is_msm7x30_fluid())
3891 return false;
3892 else
3893 return true;
3894}
3895
3896static int dtv_panel_power(int on)
3897{
3898 int flag_on = !!on;
3899 static int dtv_power_save_on;
3900 int rc;
3901
3902 if (dtv_power_save_on == flag_on)
3903 return 0;
3904
3905 dtv_power_save_on = flag_on;
3906 pr_info("%s: %d\n", __func__, on);
3907
3908#ifdef HDMI_RESET
3909 if (on) {
3910 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
3911 rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
3912 if (rc) {
3913 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
3914 __func__, dtv_reset_gpio, rc);
3915 return rc;
3916 }
3917
3918 /* bring reset line low to hold reset*/
3919 gpio_set_value(37, 0);
3920 }
3921#endif
3922
3923 if (on) {
3924 rc = msm_gpios_enable(dtv_panel_gpios,
3925 ARRAY_SIZE(dtv_panel_gpios));
3926 if (rc < 0) {
3927 printk(KERN_ERR "%s: gpio enable failed: %d\n",
3928 __func__, rc);
3929 return rc;
3930 }
3931 } else {
3932 rc = msm_gpios_disable(dtv_panel_gpios,
3933 ARRAY_SIZE(dtv_panel_gpios));
3934 if (rc < 0) {
3935 printk(KERN_ERR "%s: gpio disable failed: %d\n",
3936 __func__, rc);
3937 return rc;
3938 }
3939 }
3940
3941 mdelay(5); /* ensure power is stable */
3942
3943#ifdef HDMI_RESET
3944 if (on) {
3945 gpio_set_value(37, 1); /* bring reset line high */
3946 mdelay(10); /* 10 msec before IO can be accessed */
3947 }
3948#endif
3949
3950 return rc;
3951}
3952
3953static struct lcdc_platform_data dtv_pdata = {
3954 .lcdc_power_save = dtv_panel_power,
3955};
3956
3957static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3958 .inject_rx_on_wakeup = 1,
3959 .rx_to_inject = 0xFD,
3960};
3961
3962static struct resource msm_fb_resources[] = {
3963 {
3964 .flags = IORESOURCE_DMA,
3965 }
3966};
3967
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08003968#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
3969static struct resource msm_v4l2_video_overlay_resources[] = {
3970 {
3971 .flags = IORESOURCE_DMA,
3972 }
3973};
3974#endif
3975
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003976static int msm_fb_detect_panel(const char *name)
3977{
3978 if (machine_is_msm7x30_fluid()) {
3979 if (!strcmp(name, "lcdc_sharp_wvga_pt"))
3980 return 0;
3981 } else {
3982 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
3983 return -EPERM;
3984 else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20))
3985 return 0;
3986 else if (!strcmp(name, "mddi_orise"))
3987 return -EPERM;
3988 else if (!strcmp(name, "mddi_quickvx"))
3989 return -EPERM;
3990 }
3991 return -ENODEV;
3992}
3993
3994static struct msm_fb_platform_data msm_fb_pdata = {
3995 .detect_client = msm_fb_detect_panel,
3996 .mddi_prescan = 1,
3997};
3998
3999static struct platform_device msm_fb_device = {
4000 .name = "msm_fb",
4001 .id = 0,
4002 .num_resources = ARRAY_SIZE(msm_fb_resources),
4003 .resource = msm_fb_resources,
4004 .dev = {
4005 .platform_data = &msm_fb_pdata,
4006 }
4007};
4008
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08004009#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
4010
4011static struct platform_device msm_v4l2_video_overlay_device = {
4012 .name = "msm_v4l2_overlay_pd",
4013 .id = 0,
4014 .num_resources = ARRAY_SIZE(msm_v4l2_video_overlay_resources),
4015 .resource = msm_v4l2_video_overlay_resources,
4016};
4017#endif
4018
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004019static struct platform_device msm_migrate_pages_device = {
4020 .name = "msm_migrate_pages",
4021 .id = -1,
4022};
4023
4024static struct android_pmem_platform_data android_pmem_adsp_pdata = {
4025 .name = "pmem_adsp",
4026 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4027 .cached = 0,
4028 .memory_type = MEMTYPE_EBI0,
4029};
4030
4031static struct android_pmem_platform_data android_pmem_audio_pdata = {
4032 .name = "pmem_audio",
4033 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4034 .cached = 0,
4035 .memory_type = MEMTYPE_EBI0,
4036};
4037
4038static struct platform_device android_pmem_adsp_device = {
4039 .name = "android_pmem",
4040 .id = 2,
4041 .dev = { .platform_data = &android_pmem_adsp_pdata },
4042};
4043
4044static struct platform_device android_pmem_audio_device = {
4045 .name = "android_pmem",
4046 .id = 4,
4047 .dev = { .platform_data = &android_pmem_audio_pdata },
4048};
4049
4050#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4051 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
4052 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4053 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4054
4055#define QCE_SIZE 0x10000
4056#define QCE_0_BASE 0xA8400000
4057
4058#define QCE_HW_KEY_SUPPORT 1
4059#define QCE_SHA_HMAC_SUPPORT 0
4060#define QCE_SHARE_CE_RESOURCE 0
4061#define QCE_CE_SHARED 0
4062
4063static struct resource qcrypto_resources[] = {
4064 [0] = {
4065 .start = QCE_0_BASE,
4066 .end = QCE_0_BASE + QCE_SIZE - 1,
4067 .flags = IORESOURCE_MEM,
4068 },
4069 [1] = {
4070 .name = "crypto_channels",
4071 .start = DMOV_CE_IN_CHAN,
4072 .end = DMOV_CE_OUT_CHAN,
4073 .flags = IORESOURCE_DMA,
4074 },
4075 [2] = {
4076 .name = "crypto_crci_in",
4077 .start = DMOV_CE_IN_CRCI,
4078 .end = DMOV_CE_IN_CRCI,
4079 .flags = IORESOURCE_DMA,
4080 },
4081 [3] = {
4082 .name = "crypto_crci_out",
4083 .start = DMOV_CE_OUT_CRCI,
4084 .end = DMOV_CE_OUT_CRCI,
4085 .flags = IORESOURCE_DMA,
4086 },
4087 [4] = {
4088 .name = "crypto_crci_hash",
4089 .start = DMOV_CE_HASH_CRCI,
4090 .end = DMOV_CE_HASH_CRCI,
4091 .flags = IORESOURCE_DMA,
4092 },
4093};
4094
4095static struct resource qcedev_resources[] = {
4096 [0] = {
4097 .start = QCE_0_BASE,
4098 .end = QCE_0_BASE + QCE_SIZE - 1,
4099 .flags = IORESOURCE_MEM,
4100 },
4101 [1] = {
4102 .name = "crypto_channels",
4103 .start = DMOV_CE_IN_CHAN,
4104 .end = DMOV_CE_OUT_CHAN,
4105 .flags = IORESOURCE_DMA,
4106 },
4107 [2] = {
4108 .name = "crypto_crci_in",
4109 .start = DMOV_CE_IN_CRCI,
4110 .end = DMOV_CE_IN_CRCI,
4111 .flags = IORESOURCE_DMA,
4112 },
4113 [3] = {
4114 .name = "crypto_crci_out",
4115 .start = DMOV_CE_OUT_CRCI,
4116 .end = DMOV_CE_OUT_CRCI,
4117 .flags = IORESOURCE_DMA,
4118 },
4119 [4] = {
4120 .name = "crypto_crci_hash",
4121 .start = DMOV_CE_HASH_CRCI,
4122 .end = DMOV_CE_HASH_CRCI,
4123 .flags = IORESOURCE_DMA,
4124 },
4125};
4126
4127#endif
4128
4129#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4130 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
4131
4132static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
4133 .ce_shared = QCE_CE_SHARED,
4134 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4135 .hw_key_support = QCE_HW_KEY_SUPPORT,
4136 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004137 /* Bus Scaling declaration*/
4138 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004139};
4140
4141static struct platform_device qcrypto_device = {
4142 .name = "qcrypto",
4143 .id = 0,
4144 .num_resources = ARRAY_SIZE(qcrypto_resources),
4145 .resource = qcrypto_resources,
4146 .dev = {
4147 .coherent_dma_mask = DMA_BIT_MASK(32),
4148 .platform_data = &qcrypto_ce_hw_suppport,
4149 },
4150};
4151#endif
4152
4153#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4154 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4155
4156static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
4157 .ce_shared = QCE_CE_SHARED,
4158 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4159 .hw_key_support = QCE_HW_KEY_SUPPORT,
4160 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004161 /* Bus Scaling declaration*/
4162 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004163};
4164static struct platform_device qcedev_device = {
4165 .name = "qce",
4166 .id = 0,
4167 .num_resources = ARRAY_SIZE(qcedev_resources),
4168 .resource = qcedev_resources,
4169 .dev = {
4170 .coherent_dma_mask = DMA_BIT_MASK(32),
4171 .platform_data = &qcedev_ce_hw_suppport,
4172 },
4173};
4174#endif
4175
4176static int mddi_toshiba_pmic_bl(int level)
4177{
4178 int ret = -EPERM;
4179
4180 ret = pmic_set_led_intensity(LED_LCD, level);
4181
4182 if (ret)
4183 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
4184 __func__);
4185 return ret;
4186}
4187
4188static struct msm_panel_common_pdata mddi_toshiba_pdata = {
4189 .pmic_backlight = mddi_toshiba_pmic_bl,
4190};
4191
4192static struct platform_device mddi_toshiba_device = {
4193 .name = "mddi_toshiba",
4194 .id = 0,
4195 .dev = {
4196 .platform_data = &mddi_toshiba_pdata,
4197 }
4198};
4199
4200static unsigned wega_reset_gpio =
4201 GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4202
4203static struct msm_gpio fluid_vee_reset_gpio[] = {
4204 { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
4205};
4206
4207static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1;
4208static unsigned char quickvx_ldo_enabled;
4209
4210static unsigned quickvx_vlp_gpio =
4211 GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4212
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304213static struct pm8xxx_gpio_init_info pmic_quickvx_clk_gpio = {
4214 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_QUICKVX_CLK),
4215 {
4216 .direction = PM_GPIO_DIR_OUT,
4217 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
4218 .output_value = 1,
4219 .pull = PM_GPIO_PULL_NO,
4220 .vin_sel = PM8058_GPIO_VIN_S3,
4221 .out_strength = PM_GPIO_STRENGTH_HIGH,
4222 .function = PM_GPIO_FUNC_2,
4223 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004224};
4225
Justin Paupore3f40f342011-08-10 18:52:16 -07004226static struct regulator *mddi_ldo20;
4227static struct regulator *mddi_ldo12;
4228static struct regulator *mddi_ldo16;
4229static struct regulator *mddi_ldo6;
4230static struct regulator *mddi_lcd;
4231
4232static int display_common_init(void)
4233{
4234 struct regulator_bulk_data regs[5] = {
4235 { .supply = "ldo20", /* voltage set in display_common_power */},
4236 { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 },
4237 { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 },
4238 { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 },
4239 { .supply = NULL, /* mddi_lcd, initialized below */ },
4240 };
4241
4242 int rc = 0;
4243
4244 if (machine_is_msm7x30_fluid()) {
4245 /* lcd: LDO8 @1.8V */
4246 regs[4].supply = "ldo8";
4247 regs[4].min_uV = 1800000;
4248 regs[4].max_uV = 1800000;
4249 } else {
4250 /* lcd: LDO15 @3.1V */
4251 regs[4].supply = "ldo15";
4252 regs[4].min_uV = 3100000;
4253 regs[4].max_uV = 3100000;
4254 }
4255
4256 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4257 if (rc) {
4258 pr_err("%s: regulator_bulk_get failed: %d\n",
4259 __func__, rc);
4260 goto bail;
4261 }
4262
4263 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4264 if (rc) {
4265 pr_err("%s: regulator_bulk_set_voltage failed: %d\n",
4266 __func__, rc);
4267 goto put_regs;
4268 }
4269
4270 mddi_ldo20 = regs[0].consumer;
4271 mddi_ldo12 = regs[1].consumer;
4272 mddi_ldo6 = regs[2].consumer;
4273 mddi_ldo16 = regs[3].consumer;
4274 mddi_lcd = regs[4].consumer;
4275
4276 return rc;
4277
4278put_regs:
4279 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4280bail:
4281 return rc;
4282}
4283
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004284static int display_common_power(int on)
4285{
4286 int rc = 0, flag_on = !!on;
4287 static int display_common_power_save_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004288 static bool display_regs_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004289
4290 if (display_common_power_save_on == flag_on)
4291 return 0;
4292
4293 display_common_power_save_on = flag_on;
4294
Justin Paupore3f40f342011-08-10 18:52:16 -07004295 if (unlikely(!display_regs_initialized)) {
4296 rc = display_common_init();
4297 if (rc) {
4298 pr_err("%s: regulator init failed: %d\n",
4299 __func__, rc);
4300 return rc;
4301 }
4302 display_regs_initialized = true;
4303 }
4304
4305
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004306 if (on) {
4307 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
4308 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
4309 if (rc) {
4310 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4311 __func__, wega_reset_gpio, rc);
4312 return rc;
4313 }
4314
4315 /* bring reset line low to hold reset*/
4316 gpio_set_value(180, 0);
4317
4318 if (quickvx_mddi_client) {
4319 /* QuickVX chip -- VLP pin -- gpio 97 */
4320 rc = gpio_tlmm_config(quickvx_vlp_gpio,
4321 GPIO_CFG_ENABLE);
4322 if (rc) {
4323 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4324 __func__, quickvx_vlp_gpio, rc);
4325 return rc;
4326 }
4327
4328 /* bring QuickVX VLP line low */
4329 gpio_set_value(97, 0);
4330
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304331 rc = pm8xxx_gpio_config(pmic_quickvx_clk_gpio.gpio,
4332 &pmic_quickvx_clk_gpio.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004333 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304334 pr_err("%s: pm8xxx_gpio_config(%#x)=%d\n",
4335 __func__, pmic_quickvx_clk_gpio.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004336 rc);
4337 return rc;
4338 }
4339
4340 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4341 PMIC_GPIO_QUICKVX_CLK), 0);
4342 }
4343 }
4344
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004345 if (quickvx_mddi_client)
Jeevan Shriram9624b742012-08-08 11:19:49 +05304346 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1800000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004347 else
Justin Paupore3f40f342011-08-10 18:52:16 -07004348 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000);
4349
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004350 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004351 pr_err("%s: could not set voltage for ldo20: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004352 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07004353 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004354 }
4355
4356 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004357 rc = regulator_enable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004358 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004359 pr_err("%s: LDO20 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004360 __func__, rc);
4361 return rc;
4362 }
4363
Justin Paupore3f40f342011-08-10 18:52:16 -07004364 rc = regulator_enable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004365 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004366 pr_err("%s: LDO12 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004367 __func__, rc);
4368 return rc;
4369 }
4370
4371 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004372 rc = regulator_enable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004373 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004374 pr_err("%s: LDO16 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004375 __func__, rc);
4376 return rc;
4377 }
4378 }
4379
Justin Paupore3f40f342011-08-10 18:52:16 -07004380 if (quickvx_ldo_enabled) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004381 /* Disable LDO6 during display ON */
Justin Paupore3f40f342011-08-10 18:52:16 -07004382 rc = regulator_disable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004383 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004384 pr_err("%s: LDO6 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004385 __func__, rc);
4386 return rc;
4387 }
4388 quickvx_ldo_enabled = 0;
4389 }
4390
Justin Paupore3f40f342011-08-10 18:52:16 -07004391 rc = regulator_enable(mddi_lcd);
4392 if (rc) {
4393 pr_err("%s: LCD regulator enable failed (%d)\n",
4394 __func__, rc);
4395 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004396 }
4397
4398 mdelay(5); /* ensure power is stable */
4399
4400 if (machine_is_msm7x30_fluid()) {
4401 rc = msm_gpios_request_enable(fluid_vee_reset_gpio,
4402 ARRAY_SIZE(fluid_vee_reset_gpio));
4403 if (rc)
4404 pr_err("%s gpio_request_enable failed rc=%d\n",
4405 __func__, rc);
4406 else {
4407 /* assert vee reset_n */
4408 gpio_set_value(20, 1);
4409 gpio_set_value(20, 0);
4410 mdelay(1);
4411 gpio_set_value(20, 1);
4412 }
4413 }
4414
4415 gpio_set_value(180, 1); /* bring reset line high */
4416 mdelay(10); /* 10 msec before IO can be accessed */
4417
4418 if (quickvx_mddi_client) {
4419 gpio_set_value(97, 1);
4420 msleep(2);
4421 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4422 PMIC_GPIO_QUICKVX_CLK), 1);
4423 msleep(2);
4424 }
4425
4426 rc = pmapp_display_clock_config(1);
4427 if (rc) {
4428 pr_err("%s pmapp_display_clock_config rc=%d\n",
4429 __func__, rc);
4430 return rc;
4431 }
4432
4433 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004434 rc = regulator_disable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004435 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004436 pr_err("%s: LDO20 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004437 __func__, rc);
4438 return rc;
4439 }
4440
4441
4442 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004443 rc = regulator_disable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004444 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004445 pr_err("%s: LDO16 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004446 __func__, rc);
4447 return rc;
4448 }
4449 }
4450
4451 if (quickvx_mddi_client && !quickvx_ldo_enabled) {
4452 /* Enable LDO6 during display OFF for
4453 Quicklogic chip to sleep with data retention */
Justin Paupore3f40f342011-08-10 18:52:16 -07004454 rc = regulator_enable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004455 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004456 pr_err("%s: LDO6 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004457 __func__, rc);
4458 return rc;
4459 }
4460 quickvx_ldo_enabled = 1;
4461 }
4462
4463 gpio_set_value(180, 0); /* bring reset line low */
4464
4465 if (quickvx_mddi_client) {
4466 gpio_set_value(97, 0);
4467 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4468 PMIC_GPIO_QUICKVX_CLK), 0);
4469 }
4470
Justin Paupore3f40f342011-08-10 18:52:16 -07004471 rc = regulator_disable(mddi_lcd);
4472 if (rc) {
4473 pr_err("%s: LCD regulator disable failed (%d)\n",
4474 __func__, rc);
4475 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004476 }
4477
4478 mdelay(5); /* ensure power is stable */
4479
Justin Paupore3f40f342011-08-10 18:52:16 -07004480 rc = regulator_disable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004481 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004482 pr_err("%s: LDO12 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004483 __func__, rc);
4484 return rc;
4485 }
4486
4487 if (machine_is_msm7x30_fluid()) {
4488 msm_gpios_disable_free(fluid_vee_reset_gpio,
4489 ARRAY_SIZE(fluid_vee_reset_gpio));
4490 }
4491
4492 rc = pmapp_display_clock_config(0);
4493 if (rc) {
4494 pr_err("%s pmapp_display_clock_config rc=%d\n",
4495 __func__, rc);
4496 return rc;
4497 }
4498 }
4499
4500 return rc;
4501}
4502
4503static int msm_fb_mddi_sel_clk(u32 *clk_rate)
4504{
4505 *clk_rate *= 2;
4506 return 0;
4507}
4508
4509static int msm_fb_mddi_client_power(u32 client_id)
4510{
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304511 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004512 printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
4513 /* Check if it is Quicklogic client */
4514 if (client_id == 0xc5835800) {
4515 printk(KERN_NOTICE "\n Quicklogic MDDI client");
4516 other_mddi_client = 0;
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304517 if (IS_ERR(mddi_ldo16)) {
4518 rc = PTR_ERR(mddi_ldo16);
4519 pr_err("%s: gp10 vreg get failed (%d)\n", __func__, rc);
4520 return rc;
4521 }
4522 rc = regulator_disable(mddi_ldo16);
4523 if (rc) {
4524 pr_err("%s: LDO16 vreg enable failed (%d)\n",
4525 __func__, rc);
4526 return rc;
4527 }
4528
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004529 } else {
4530 printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
4531 quickvx_mddi_client = 0;
4532 gpio_set_value(97, 0);
4533 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4534 PMIC_GPIO_QUICKVX_CLK), 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004535 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004536
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004537 return 0;
4538}
4539
4540static struct mddi_platform_data mddi_pdata = {
4541 .mddi_power_save = display_common_power,
4542 .mddi_sel_clk = msm_fb_mddi_sel_clk,
4543 .mddi_client_power = msm_fb_mddi_client_power,
4544};
4545
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004546static struct msm_panel_common_pdata mdp_pdata = {
4547 .hw_revision_addr = 0xac001270,
4548 .gpio = 30,
Siddhartha Agrawal496f9282012-08-15 17:41:34 -07004549 .mdp_max_clk = 192000000,
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07004550 .mdp_rev = MDP_REV_40,
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05304551 .mem_hid = MEMTYPE_EBI0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004552};
4553
4554static int lcd_panel_spi_gpio_num[] = {
4555 45, /* spi_clk */
4556 46, /* spi_cs */
4557 47, /* spi_mosi */
4558 48, /* spi_miso */
4559 };
4560
4561static struct msm_gpio lcd_panel_gpios[] = {
4562/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
4563 * input. if there is a hardware revision; we should reassign this GPIO to a
4564 * new open line; and removing it will just ensure that this will be missed in
4565 * the future.
4566 { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
4567 */
4568 { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
4569 { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
4570 { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
4571 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4572 { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
4573 { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
4574 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4575#ifndef CONFIG_SPI_QSD
4576 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
4577 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
4578 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
4579 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
4580#endif
4581 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4582 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4583 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4584 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4585 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4586 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4587 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4588 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4589 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4590 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4591 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4592 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4593 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4594 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4595 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4596 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4597 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4598 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4599 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4600 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4601};
4602
4603static struct msm_gpio lcd_sharp_panel_gpios[] = {
4604 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4605 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4606 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4607 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4608 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4609 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4610 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4611 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4612 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4613 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4614 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4615 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4616 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4617 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4618 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4619 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4620 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4621 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4622 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4623 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4624 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4625 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4626};
4627
4628static int lcdc_toshiba_panel_power(int on)
4629{
4630 int rc, i;
4631 struct msm_gpio *gp;
4632
4633 rc = display_common_power(on);
4634 if (rc < 0) {
4635 printk(KERN_ERR "%s display_common_power failed: %d\n",
4636 __func__, rc);
4637 return rc;
4638 }
4639
4640 if (on) {
4641 rc = msm_gpios_enable(lcd_panel_gpios,
4642 ARRAY_SIZE(lcd_panel_gpios));
4643 if (rc < 0) {
4644 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4645 __func__, rc);
4646 }
4647 } else { /* off */
4648 gp = lcd_panel_gpios;
4649 for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
4650 /* ouput low */
4651 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4652 gp++;
4653 }
4654 }
4655
4656 return rc;
4657}
4658
4659static int lcdc_sharp_panel_power(int on)
4660{
4661 int rc, i;
4662 struct msm_gpio *gp;
4663
4664 rc = display_common_power(on);
4665 if (rc < 0) {
4666 printk(KERN_ERR "%s display_common_power failed: %d\n",
4667 __func__, rc);
4668 return rc;
4669 }
4670
4671 if (on) {
4672 rc = msm_gpios_enable(lcd_sharp_panel_gpios,
4673 ARRAY_SIZE(lcd_sharp_panel_gpios));
4674 if (rc < 0) {
4675 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4676 __func__, rc);
4677 }
4678 } else { /* off */
4679 gp = lcd_sharp_panel_gpios;
4680 for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) {
4681 /* ouput low */
4682 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4683 gp++;
4684 }
4685 }
4686
4687 return rc;
4688}
4689
4690static int lcdc_panel_power(int on)
4691{
4692 int flag_on = !!on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004693 static int lcdc_power_save_on, lcdc_power_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004694
4695 if (lcdc_power_save_on == flag_on)
4696 return 0;
4697
4698 lcdc_power_save_on = flag_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004699
4700 if (unlikely(!lcdc_power_initialized)) {
4701 quickvx_mddi_client = 0;
4702 display_common_init();
4703 lcdc_power_initialized = 1;
4704 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004705
4706 if (machine_is_msm7x30_fluid())
4707 return lcdc_sharp_panel_power(on);
4708 else
4709 return lcdc_toshiba_panel_power(on);
4710}
4711
4712static struct lcdc_platform_data lcdc_pdata = {
4713 .lcdc_power_save = lcdc_panel_power,
4714};
4715
Justin Paupore3f40f342011-08-10 18:52:16 -07004716static struct regulator *atv_s4, *atv_ldo9;
4717
4718static int __init atv_dac_power_init(void)
4719{
4720 int rc;
4721 struct regulator_bulk_data regs[] = {
4722 { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 },
4723 { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 },
4724 };
4725
4726 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4727
4728 if (rc) {
4729 pr_err("%s: could not get regulators: %d\n", __func__, rc);
4730 goto bail;
4731 }
4732
4733 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4734
4735 if (rc) {
4736 pr_err("%s: could not set voltages: %d\n", __func__, rc);
4737 goto reg_free;
4738 }
4739
4740 atv_s4 = regs[0].consumer;
4741 atv_ldo9 = regs[1].consumer;
4742
4743reg_free:
4744 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4745bail:
4746 return rc;
4747}
4748
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004749static int atv_dac_power(int on)
4750{
4751 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004752
4753 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004754 rc = regulator_enable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004755 if (rc) {
4756 pr_err("%s: s4 vreg enable failed (%d)\n",
4757 __func__, rc);
4758 return rc;
4759 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004760 rc = regulator_enable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004761 if (rc) {
4762 pr_err("%s: ldo9 vreg enable failed (%d)\n",
4763 __func__, rc);
4764 return rc;
4765 }
4766 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004767 rc = regulator_disable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004768 if (rc) {
4769 pr_err("%s: ldo9 vreg disable failed (%d)\n",
4770 __func__, rc);
4771 return rc;
4772 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004773 rc = regulator_disable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004774 if (rc) {
4775 pr_err("%s: s4 vreg disable failed (%d)\n",
4776 __func__, rc);
4777 return rc;
4778 }
4779 }
4780 return rc;
4781}
4782
4783static struct tvenc_platform_data atv_pdata = {
4784 .poll = 1,
4785 .pm_vid_en = atv_dac_power,
4786};
4787
4788static void __init msm_fb_add_devices(void)
4789{
4790 msm_fb_register_device("mdp", &mdp_pdata);
4791 msm_fb_register_device("pmdh", &mddi_pdata);
4792 msm_fb_register_device("lcdc", &lcdc_pdata);
4793 msm_fb_register_device("dtv", &dtv_pdata);
4794 msm_fb_register_device("tvenc", &atv_pdata);
4795#ifdef CONFIG_FB_MSM_TVOUT
4796 msm_fb_register_device("tvout_device", NULL);
4797#endif
4798}
4799
4800static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
4801 .gpio_num = lcd_panel_spi_gpio_num,
4802};
4803
4804static struct platform_device lcdc_toshiba_panel_device = {
4805 .name = "lcdc_toshiba_wvga",
4806 .id = 0,
4807 .dev = {
4808 .platform_data = &lcdc_toshiba_panel_data,
4809 }
4810};
4811
4812#if defined(CONFIG_MARIMBA_CORE) && \
4813 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4814static struct platform_device msm_bt_power_device = {
4815 .name = "bt_power",
4816 .id = -1
4817};
4818
4819enum {
4820 BT_RFR,
4821 BT_CTS,
4822 BT_RX,
4823 BT_TX,
4824};
4825
4826static struct msm_gpio bt_config_power_on[] = {
4827 { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4828 "UART1DM_RFR" },
4829 { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4830 "UART1DM_CTS" },
4831 { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4832 "UART1DM_Rx" },
4833 { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4834 "UART1DM_Tx" }
4835};
4836
4837static struct msm_gpio bt_config_power_off[] = {
4838 { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4839 "UART1DM_RFR" },
4840 { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4841 "UART1DM_CTS" },
4842 { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4843 "UART1DM_Rx" },
4844 { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4845 "UART1DM_Tx" }
4846};
4847
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004848static u8 bahama_version;
4849
Justin Paupore3f40f342011-08-10 18:52:16 -07004850static struct regulator_bulk_data regs_bt_marimba[] = {
4851 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4852 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
4853 { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304854 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004855};
4856
4857static struct regulator_bulk_data regs_bt_bahama_v1[] = {
4858 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4859 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
4860 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304861 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004862};
4863
4864static struct regulator_bulk_data regs_bt_bahama_v2[] = {
4865 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4866 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304867 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004868};
4869
4870static struct regulator_bulk_data *regs_bt;
4871static int regs_bt_count;
4872
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004873static int marimba_bt(int on)
4874{
4875 int rc;
4876 int i;
4877 struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
4878
4879 struct marimba_config_register {
4880 u8 reg;
4881 u8 value;
4882 u8 mask;
4883 };
4884
4885 struct marimba_variant_register {
4886 const size_t size;
4887 const struct marimba_config_register *set;
4888 };
4889
4890 const struct marimba_config_register *p;
4891
4892 u8 version;
4893
4894 const struct marimba_config_register v10_bt_on[] = {
4895 { 0xE5, 0x0B, 0x0F },
4896 { 0x05, 0x02, 0x07 },
4897 { 0x06, 0x88, 0xFF },
4898 { 0xE7, 0x21, 0x21 },
4899 { 0xE3, 0x38, 0xFF },
4900 { 0xE4, 0x06, 0xFF },
4901 };
4902
4903 const struct marimba_config_register v10_bt_off[] = {
4904 { 0xE5, 0x0B, 0x0F },
4905 { 0x05, 0x08, 0x0F },
4906 { 0x06, 0x88, 0xFF },
4907 { 0xE7, 0x00, 0x21 },
4908 { 0xE3, 0x00, 0xFF },
4909 { 0xE4, 0x00, 0xFF },
4910 };
4911
4912 const struct marimba_config_register v201_bt_on[] = {
4913 { 0x05, 0x08, 0x07 },
4914 { 0x06, 0x88, 0xFF },
4915 { 0xE7, 0x21, 0x21 },
4916 { 0xE3, 0x38, 0xFF },
4917 { 0xE4, 0x06, 0xFF },
4918 };
4919
4920 const struct marimba_config_register v201_bt_off[] = {
4921 { 0x05, 0x08, 0x07 },
4922 { 0x06, 0x88, 0xFF },
4923 { 0xE7, 0x00, 0x21 },
4924 { 0xE3, 0x00, 0xFF },
4925 { 0xE4, 0x00, 0xFF },
4926 };
4927
4928 const struct marimba_config_register v210_bt_on[] = {
4929 { 0xE9, 0x01, 0x01 },
4930 { 0x06, 0x88, 0xFF },
4931 { 0xE7, 0x21, 0x21 },
4932 { 0xE3, 0x38, 0xFF },
4933 { 0xE4, 0x06, 0xFF },
4934 };
4935
4936 const struct marimba_config_register v210_bt_off[] = {
4937 { 0x06, 0x88, 0xFF },
4938 { 0xE7, 0x00, 0x21 },
4939 { 0xE9, 0x00, 0x01 },
4940 { 0xE3, 0x00, 0xFF },
4941 { 0xE4, 0x00, 0xFF },
4942 };
4943
4944 const struct marimba_variant_register bt_marimba[2][4] = {
4945 {
4946 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4947 { 0, NULL },
4948 { ARRAY_SIZE(v201_bt_off), v201_bt_off },
4949 { ARRAY_SIZE(v210_bt_off), v210_bt_off }
4950 },
4951 {
4952 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4953 { 0, NULL },
4954 { ARRAY_SIZE(v201_bt_on), v201_bt_on },
4955 { ARRAY_SIZE(v210_bt_on), v210_bt_on }
4956 }
4957 };
4958
4959 on = on ? 1 : 0;
4960
4961 rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F);
4962 if (rc < 0) {
4963 printk(KERN_ERR
4964 "%s: version read failed: %d\n",
4965 __func__, rc);
4966 return rc;
4967 }
4968
4969 if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
4970 (bt_marimba[on][version].size == 0)) {
4971 printk(KERN_ERR
4972 "%s: unsupported version\n",
4973 __func__);
4974 return -EIO;
4975 }
4976
4977 p = bt_marimba[on][version].set;
4978
4979 printk(KERN_INFO "%s: found version %d\n", __func__, version);
4980
4981 for (i = 0; i < bt_marimba[on][version].size; i++) {
4982 u8 value = (p+i)->value;
4983 rc = marimba_write_bit_mask(&config,
4984 (p+i)->reg,
4985 &value,
4986 sizeof((p+i)->value),
4987 (p+i)->mask);
4988 if (rc < 0) {
4989 printk(KERN_ERR
4990 "%s: reg %d write failed: %d\n",
4991 __func__, (p+i)->reg, rc);
4992 return rc;
4993 }
4994 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
4995 __func__, (p+i)->reg,
4996 value, (p+i)->mask);
4997 }
4998 return 0;
4999}
5000
5001static int bahama_bt(int on)
5002{
5003 int rc;
5004 int i;
5005 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
5006
5007 struct bahama_variant_register {
5008 const size_t size;
5009 const struct bahama_config_register *set;
5010 };
5011
5012 const struct bahama_config_register *p;
5013
5014
5015 const struct bahama_config_register v10_bt_on[] = {
5016 { 0xE9, 0x00, 0xFF },
5017 { 0xF4, 0x80, 0xFF },
5018 { 0xF0, 0x06, 0xFF },
5019 { 0xE4, 0x00, 0xFF },
5020 { 0xE5, 0x00, 0x0F },
5021#ifdef CONFIG_WLAN
5022 { 0xE6, 0x38, 0x7F },
5023 { 0xE7, 0x06, 0xFF },
5024#endif
5025 { 0x11, 0x13, 0xFF },
5026 { 0xE9, 0x21, 0xFF },
5027 { 0x01, 0x0C, 0x1F },
5028 { 0x01, 0x08, 0x1F },
5029 };
5030
5031 const struct bahama_config_register v20_bt_on_fm_off[] = {
5032 { 0x11, 0x0C, 0xFF },
5033 { 0x13, 0x01, 0xFF },
5034 { 0xF4, 0x80, 0xFF },
5035 { 0xF0, 0x00, 0xFF },
5036 { 0xE9, 0x00, 0xFF },
5037#ifdef CONFIG_WLAN
5038 { 0x81, 0x00, 0xFF },
5039 { 0x82, 0x00, 0xFF },
5040 { 0xE6, 0x38, 0x7F },
5041 { 0xE7, 0x06, 0xFF },
5042#endif
5043 { 0xE9, 0x21, 0xFF }
5044 };
5045
5046 const struct bahama_config_register v20_bt_on_fm_on[] = {
5047 { 0x11, 0x0C, 0xFF },
5048 { 0x13, 0x01, 0xFF },
5049 { 0xF4, 0x86, 0xFF },
5050 { 0xF0, 0x06, 0xFF },
5051 { 0xE9, 0x00, 0xFF },
5052#ifdef CONFIG_WLAN
5053 { 0x81, 0x00, 0xFF },
5054 { 0x82, 0x00, 0xFF },
5055 { 0xE6, 0x38, 0x7F },
5056 { 0xE7, 0x06, 0xFF },
5057#endif
5058 { 0xE9, 0x21, 0xFF }
5059 };
5060
5061 const struct bahama_config_register v10_bt_off[] = {
5062 { 0xE9, 0x00, 0xFF },
5063 };
5064
5065 const struct bahama_config_register v20_bt_off_fm_off[] = {
5066 { 0xF4, 0x84, 0xFF },
5067 { 0xF0, 0x04, 0xFF },
5068 { 0xE9, 0x00, 0xFF }
5069 };
5070
5071 const struct bahama_config_register v20_bt_off_fm_on[] = {
5072 { 0xF4, 0x86, 0xFF },
5073 { 0xF0, 0x06, 0xFF },
5074 { 0xE9, 0x00, 0xFF }
5075 };
5076
5077 const struct bahama_variant_register bt_bahama[2][3] = {
5078 {
5079 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
5080 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
5081 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
5082 },
5083 {
5084 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
5085 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
5086 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
5087 }
5088 };
5089
5090 u8 offset = 0; /* index into bahama configs */
5091
5092 on = on ? 1 : 0;
5093
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005094
5095 if (bahama_version == VER_2_0) {
5096 if (marimba_get_fm_status(&config))
5097 offset = 0x01;
5098 }
5099
5100 p = bt_bahama[on][bahama_version + offset].set;
5101
5102 dev_info(&msm_bt_power_device.dev,
5103 "%s: found version %d\n", __func__, bahama_version);
5104
5105 for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
5106 u8 value = (p+i)->value;
5107 rc = marimba_write_bit_mask(&config,
5108 (p+i)->reg,
5109 &value,
5110 sizeof((p+i)->value),
5111 (p+i)->mask);
5112 if (rc < 0) {
5113 dev_err(&msm_bt_power_device.dev,
5114 "%s: reg %d write failed: %d\n",
5115 __func__, (p+i)->reg, rc);
5116 return rc;
5117 }
5118 dev_info(&msm_bt_power_device.dev,
5119 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
5120 __func__, (p+i)->reg,
5121 value, (p+i)->mask);
5122 }
5123 /* Update BT status */
5124 if (on)
5125 marimba_set_bt_status(&config, true);
5126 else
5127 marimba_set_bt_status(&config, false);
5128
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005129 return 0;
5130}
5131
Justin Paupore3f40f342011-08-10 18:52:16 -07005132static int bluetooth_regs_init(int bahama_not_marimba)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005133{
Justin Paupore3f40f342011-08-10 18:52:16 -07005134 int rc = 0;
5135 struct device *const dev = &msm_bt_power_device.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005136
5137 if (bahama_not_marimba) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005138 bahama_version = read_bahama_ver();
5139
5140 switch (bahama_version) {
5141 case VER_1_0:
5142 regs_bt = regs_bt_bahama_v1;
5143 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1);
5144 break;
5145 case VER_2_0:
5146 regs_bt = regs_bt_bahama_v2;
5147 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2);
5148 break;
5149 case VER_UNSUPPORTED:
5150 default:
5151 dev_err(dev,
5152 "%s: i2c failure or unsupported version: %d\n",
5153 __func__, bahama_version);
5154 rc = -EIO;
5155 goto out;
5156 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005157 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07005158 regs_bt = regs_bt_marimba;
5159 regs_bt_count = ARRAY_SIZE(regs_bt_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005160 }
5161
Justin Paupore3f40f342011-08-10 18:52:16 -07005162 rc = regulator_bulk_get(&msm_bt_power_device.dev,
5163 regs_bt_count, regs_bt);
5164 if (rc) {
5165 dev_err(dev, "%s: could not get regulators: %d\n",
5166 __func__, rc);
5167 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005168 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005169
5170 rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt);
5171 if (rc) {
5172 dev_err(dev, "%s: could not set voltages: %d\n",
5173 __func__, rc);
5174 goto reg_free;
5175 }
5176
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005177 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005178
5179reg_free:
5180 regulator_bulk_free(regs_bt_count, regs_bt);
5181out:
5182 regs_bt_count = 0;
5183 regs_bt = NULL;
5184 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005185}
5186
5187static int bluetooth_power(int on)
5188{
5189 int rc;
5190 const char *id = "BTPW";
5191
5192 int bahama_not_marimba = bahama_present();
5193
Ram Mohan Korukonda1747cde2012-10-04 22:10:59 +05305194 if (bahama_not_marimba < 0) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005195 printk(KERN_WARNING "%s: bahama_present: %d\n",
5196 __func__, bahama_not_marimba);
5197 return -ENODEV;
5198 }
5199
Justin Paupore3f40f342011-08-10 18:52:16 -07005200 if (unlikely(regs_bt_count == 0)) {
5201 rc = bluetooth_regs_init(bahama_not_marimba);
5202 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005203 return rc;
Justin Paupore3f40f342011-08-10 18:52:16 -07005204 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005205
Justin Paupore3f40f342011-08-10 18:52:16 -07005206 if (on) {
5207 rc = regulator_bulk_enable(regs_bt_count, regs_bt);
5208 if (rc)
5209 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005210
5211 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5212 PMAPP_CLOCK_VOTE_ON);
5213 if (rc < 0)
5214 return -EIO;
5215
5216 if (machine_is_msm8x55_svlte_surf() ||
5217 machine_is_msm8x55_svlte_ffa()) {
5218 rc = marimba_gpio_config(1);
5219 if (rc < 0)
5220 return -EIO;
5221 }
5222
5223 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5224 if (rc < 0)
5225 return -EIO;
5226
5227 msleep(10);
5228
5229 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5230 PMAPP_CLOCK_VOTE_PIN_CTRL);
5231 if (rc < 0)
5232 return -EIO;
5233
5234 if (machine_is_msm8x55_svlte_surf() ||
5235 machine_is_msm8x55_svlte_ffa()) {
5236 rc = marimba_gpio_config(0);
5237 if (rc < 0)
5238 return -EIO;
5239 }
5240
5241 rc = msm_gpios_enable(bt_config_power_on,
5242 ARRAY_SIZE(bt_config_power_on));
5243
5244 if (rc < 0)
5245 return rc;
5246
5247 } else {
5248 rc = msm_gpios_enable(bt_config_power_off,
5249 ARRAY_SIZE(bt_config_power_off));
5250 if (rc < 0)
5251 return rc;
5252
5253 /* check for initial RFKILL block (power off) */
5254 if (platform_get_drvdata(&msm_bt_power_device) == NULL)
5255 goto out;
5256
5257 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5258 if (rc < 0)
5259 return -EIO;
5260
5261 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5262 PMAPP_CLOCK_VOTE_OFF);
5263 if (rc < 0)
5264 return -EIO;
5265
Justin Paupore3f40f342011-08-10 18:52:16 -07005266 rc = regulator_bulk_disable(regs_bt_count, regs_bt);
5267 if (rc)
5268 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005269
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005270 }
5271
5272out:
5273 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
5274
5275 return 0;
5276}
5277
5278static void __init bt_power_init(void)
5279{
Justin Paupore3f40f342011-08-10 18:52:16 -07005280 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005281}
5282#else
5283#define bt_power_init(x) do {} while (0)
5284#endif
5285
5286static struct msm_psy_batt_pdata msm_psy_batt_data = {
5287 .voltage_min_design = 2800,
5288 .voltage_max_design = 4300,
5289 .avail_chg_sources = AC_CHG | USB_CHG ,
5290 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
5291};
5292
5293static struct platform_device msm_batt_device = {
5294 .name = "msm-battery",
5295 .id = -1,
5296 .dev.platform_data = &msm_psy_batt_data,
5297};
5298
5299static char *msm_adc_fluid_device_names[] = {
5300 "LTC_ADC1",
5301 "LTC_ADC2",
5302 "LTC_ADC3",
5303};
5304
5305static char *msm_adc_surf_device_names[] = {
5306 "XO_ADC",
5307};
5308
5309static struct msm_adc_platform_data msm_adc_pdata;
5310
5311static struct platform_device msm_adc_device = {
5312 .name = "msm_adc",
5313 .id = -1,
5314 .dev = {
5315 .platform_data = &msm_adc_pdata,
5316 },
5317};
5318
5319#ifdef CONFIG_MSM_SDIO_AL
5320static struct msm_gpio mdm2ap_status = {
5321 GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5322 "mdm2ap_status"
5323};
5324
5325
5326static int configure_mdm2ap_status(int on)
5327{
5328 if (on)
5329 return msm_gpios_request_enable(&mdm2ap_status, 1);
5330 else {
5331 msm_gpios_disable_free(&mdm2ap_status, 1);
5332 return 0;
5333 }
5334}
5335
5336static int get_mdm2ap_status(void)
5337{
5338 return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
5339}
5340
5341static struct sdio_al_platform_data sdio_al_pdata = {
5342 .config_mdm2ap_status = configure_mdm2ap_status,
5343 .get_mdm2ap_status = get_mdm2ap_status,
5344 .allow_sdioc_version_major_2 = 1,
5345 .peer_sdioc_version_minor = 0x0001,
5346 .peer_sdioc_version_major = 0x0003,
5347 .peer_sdioc_boot_version_minor = 0x0001,
5348 .peer_sdioc_boot_version_major = 0x0003,
5349};
5350
5351struct platform_device msm_device_sdio_al = {
5352 .name = "msm_sdio_al",
5353 .id = -1,
5354 .dev = {
5355 .platform_data = &sdio_al_pdata,
5356 },
5357};
5358
5359#endif /* CONFIG_MSM_SDIO_AL */
5360
Daniel Walker8d747cd2010-02-25 11:37:43 -08005361static struct platform_device *devices[] __initdata = {
Daniel Walker90e37c52010-05-12 14:24:15 -07005362#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005363 &msm_device_uart2,
5364#endif
Justin Paupore637a25d2011-07-14 17:11:04 -07005365#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
5366 &msm_proccomm_regulator_dev,
5367#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005368 &asoc_msm_pcm,
5369 &asoc_msm_dai0,
5370 &asoc_msm_dai1,
5371#if defined (CONFIG_SND_MSM_MVS_DAI_SOC)
5372 &asoc_msm_mvs,
5373 &asoc_mvs_dai0,
5374 &asoc_mvs_dai1,
Daniel Walker90e37c52010-05-12 14:24:15 -07005375#endif
Niranjana Vishwanathapuraa8855e92010-10-06 13:52:10 -07005376 &msm_device_smd,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005377 &msm_device_dmov,
5378 &smc91x_device,
5379 &smsc911x_device,
5380 &msm_device_nand,
5381#ifdef CONFIG_USB_MSM_OTG_72K
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05305382 &msm_device_otg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005383#ifdef CONFIG_USB_GADGET
5384 &msm_device_gadget_peripheral,
5385#endif
5386#endif
5387#ifdef CONFIG_USB_G_ANDROID
5388 &android_usb_device,
5389#endif
5390 &qsd_device_spi,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305391
5392#ifdef CONFIG_MSM_SSBI
5393 &msm_device_ssbi_pmic1,
5394#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005395#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005396 &msm_device_ssbi7,
5397#endif
5398 &android_pmem_device,
5399 &msm_fb_device,
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08005400#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
5401 &msm_v4l2_video_overlay_device,
5402#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005403 &msm_migrate_pages_device,
5404 &mddi_toshiba_device,
5405 &lcdc_toshiba_panel_device,
5406#ifdef CONFIG_MSM_ROTATOR
5407 &msm_rotator_device,
5408#endif
5409 &lcdc_sharp_panel_device,
5410 &android_pmem_adsp_device,
5411 &android_pmem_audio_device,
5412 &msm_device_i2c,
5413 &msm_device_i2c_2,
5414 &msm_device_uart_dm1,
5415 &hs_device,
5416#ifdef CONFIG_MSM7KV2_AUDIO
5417 &msm_aictl_device,
5418 &msm_mi2s_device,
5419 &msm_lpa_device,
5420 &msm_aux_pcm_device,
5421#endif
5422 &msm_device_adspdec,
5423 &qup_device_i2c,
5424#if defined(CONFIG_MARIMBA_CORE) && \
5425 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5426 &msm_bt_power_device,
5427#endif
5428 &msm_kgsl_3d0,
5429 &msm_kgsl_2d0,
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005430#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005431#ifdef CONFIG_MT9T013
5432 &msm_camera_sensor_mt9t013,
5433#endif
5434#ifdef CONFIG_MT9D112
5435 &msm_camera_sensor_mt9d112,
5436#endif
5437#ifdef CONFIG_WEBCAM_OV9726
5438 &msm_camera_sensor_ov9726,
5439#endif
5440#ifdef CONFIG_S5K3E2FX
5441 &msm_camera_sensor_s5k3e2fx,
5442#endif
5443#ifdef CONFIG_MT9P012
5444 &msm_camera_sensor_mt9p012,
5445#endif
5446#ifdef CONFIG_MT9E013
5447 &msm_camera_sensor_mt9e013,
5448#endif
5449#ifdef CONFIG_VX6953
5450 &msm_camera_sensor_vx6953,
5451#endif
5452#ifdef CONFIG_SN12M0PZ
5453 &msm_camera_sensor_sn12m0pz,
5454#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005455#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005456 &msm_device_vidc_720p,
5457#ifdef CONFIG_MSM_GEMINI
5458 &msm_gemini_device,
5459#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005460#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005461#ifdef CONFIG_MSM_VPE
5462 &msm_vpe_device,
5463#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005464#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005465#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5466 &msm_device_tsif,
5467#endif
5468#ifdef CONFIG_MSM_SDIO_AL
5469 &msm_device_sdio_al,
5470#endif
5471
5472#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5473 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5474 &qcrypto_device,
5475#endif
5476
5477#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5478 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5479 &qcedev_device,
5480#endif
5481
5482 &msm_batt_device,
5483 &msm_adc_device,
5484 &msm_ebi0_thermal,
Laxminath Kasam1d8255d2012-02-15 13:10:19 +05305485 &msm_ebi1_thermal,
Chintan Pandya03b698a2012-06-28 19:03:09 +05305486 &msm_adsp_device,
5487#ifdef CONFIG_ION_MSM
5488 &ion_dev,
5489#endif
Daniel Walker8d747cd2010-02-25 11:37:43 -08005490};
5491
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005492static struct msm_gpio msm_i2c_gpios_hw[] = {
5493 { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5494 { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5495};
5496
5497static struct msm_gpio msm_i2c_gpios_io[] = {
5498 { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5499 { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5500};
5501
5502static struct msm_gpio qup_i2c_gpios_io[] = {
5503 { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5504 { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5505};
5506static struct msm_gpio qup_i2c_gpios_hw[] = {
5507 { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5508 { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5509};
5510
5511static void
5512msm_i2c_gpio_config(int adap_id, int config_type)
5513{
5514 struct msm_gpio *msm_i2c_table;
5515
5516 /* Each adapter gets 2 lines from the table */
5517 if (adap_id > 0)
5518 return;
5519 if (config_type)
5520 msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
5521 else
5522 msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
5523 msm_gpios_enable(msm_i2c_table, 2);
5524}
5525/*This needs to be enabled only for OEMS*/
5526#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005527static struct regulator *qup_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005528#endif
5529static void
5530qup_i2c_gpio_config(int adap_id, int config_type)
5531{
5532 int rc = 0;
5533 struct msm_gpio *qup_i2c_table;
5534 /* Each adapter gets 2 lines from the table */
5535 if (adap_id != 4)
5536 return;
5537 if (config_type)
5538 qup_i2c_table = qup_i2c_gpios_hw;
5539 else
5540 qup_i2c_table = qup_i2c_gpios_io;
5541 rc = msm_gpios_enable(qup_i2c_table, 2);
5542 if (rc < 0)
5543 printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
5544 /*This needs to be enabled only for OEMS*/
5545#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005546 if (!IS_ERR_OR_NULL(qup_vreg)) {
5547 rc = regulator_enable(qup_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005548 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005549 pr_err("%s: regulator_enable failed: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005550 __func__, rc);
5551 }
5552 }
5553#endif
5554}
5555
5556static struct msm_i2c_platform_data msm_i2c_pdata = {
5557 .clk_freq = 100000,
5558 .pri_clk = 70,
5559 .pri_dat = 71,
5560 .rmutex = 1,
5561 .rsl_id = "D:I2C02000021",
5562 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5563};
5564
5565static void __init msm_device_i2c_init(void)
5566{
5567 if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
5568 pr_err("failed to request I2C gpios\n");
5569
5570 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
5571}
5572
5573static struct msm_i2c_platform_data msm_i2c_2_pdata = {
5574 .clk_freq = 100000,
5575 .rmutex = 1,
5576 .rsl_id = "D:I2C02000022",
5577 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5578};
5579
5580static void __init msm_device_i2c_2_init(void)
5581{
5582 msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
5583}
5584
5585static struct msm_i2c_platform_data qup_i2c_pdata = {
5586 .clk_freq = 384000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005587 .msm_i2c_config_gpio = qup_i2c_gpio_config,
5588};
5589
5590static void __init qup_device_i2c_init(void)
5591{
5592 if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
5593 pr_err("failed to request I2C gpios\n");
5594
5595 qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
5596 /*This needs to be enabled only for OEMS*/
5597#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005598 qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005599 if (IS_ERR(qup_vreg)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005600 dev_err(&qup_device_i2c.dev,
5601 "%s: regulator_get failed: %ld\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005602 __func__, PTR_ERR(qup_vreg));
5603 }
5604#endif
5605}
5606
5607#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005608static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = {
5609 .rsl_id = "D:CODEC_SSBI",
5610 .controller_type = MSM_SBI_CTRL_SSBI,
5611};
5612#endif
5613
Daniel Walker8d747cd2010-02-25 11:37:43 -08005614static void __init msm7x30_init_irq(void)
5615{
5616 msm_init_irq();
5617}
5618
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005619static struct msm_gpio msm_nand_ebi2_cfg_data[] = {
5620 {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
5621 {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
5622};
5623
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005624#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
5625 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
5626 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
5627 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
5628
5629struct sdcc_gpio {
5630 struct msm_gpio *cfg_data;
5631 uint32_t size;
5632 struct msm_gpio *sleep_cfg_data;
5633};
5634#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5635static struct msm_gpio sdc1_lvlshft_cfg_data[] = {
5636 {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
5637};
5638#endif
5639static struct msm_gpio sdc1_cfg_data[] = {
5640 {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
5641 {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
5642 {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
5643 {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
5644 {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
5645 {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
5646};
5647
5648static struct msm_gpio sdc2_cfg_data[] = {
5649 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
5650 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
5651 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
5652 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
5653 {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
5654 {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
5655
5656#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5657 {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
5658 {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
5659 {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
5660 {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
5661#endif
5662};
5663
5664static struct msm_gpio sdc3_cfg_data[] = {
5665 {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
5666 {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
5667 {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
5668 {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
5669 {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
5670 {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
5671};
5672
5673static struct msm_gpio sdc3_sleep_cfg_data[] = {
5674 {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5675 "sdc3_clk"},
5676 {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5677 "sdc3_cmd"},
5678 {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5679 "sdc3_dat_3"},
5680 {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5681 "sdc3_dat_2"},
5682 {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5683 "sdc3_dat_1"},
5684 {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5685 "sdc3_dat_0"},
5686};
5687
5688static struct msm_gpio sdc4_cfg_data[] = {
5689 {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
5690 {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
5691 {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
5692 {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
5693 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
5694 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
5695};
5696
5697static struct sdcc_gpio sdcc_cfg_data[] = {
5698 {
5699 .cfg_data = sdc1_cfg_data,
5700 .size = ARRAY_SIZE(sdc1_cfg_data),
5701 .sleep_cfg_data = NULL,
5702 },
5703 {
5704 .cfg_data = sdc2_cfg_data,
5705 .size = ARRAY_SIZE(sdc2_cfg_data),
5706 .sleep_cfg_data = NULL,
5707 },
5708 {
5709 .cfg_data = sdc3_cfg_data,
5710 .size = ARRAY_SIZE(sdc3_cfg_data),
5711 .sleep_cfg_data = sdc3_sleep_cfg_data,
5712 },
5713 {
5714 .cfg_data = sdc4_cfg_data,
5715 .size = ARRAY_SIZE(sdc4_cfg_data),
5716 .sleep_cfg_data = NULL,
5717 },
5718};
5719
Justin Paupore3f40f342011-08-10 18:52:16 -07005720static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005721
5722static unsigned long vreg_sts, gpio_sts;
5723
5724static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
5725{
5726 int rc = 0;
5727 struct sdcc_gpio *curr;
5728
5729 curr = &sdcc_cfg_data[dev_id - 1];
5730
5731 if (!(test_bit(dev_id, &gpio_sts)^enable))
5732 return rc;
5733
5734 if (enable) {
5735 set_bit(dev_id, &gpio_sts);
5736 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
5737 if (rc)
5738 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
5739 __func__, dev_id);
5740 } else {
5741 clear_bit(dev_id, &gpio_sts);
5742 if (curr->sleep_cfg_data) {
5743 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
5744 msm_gpios_free(curr->sleep_cfg_data, curr->size);
5745 } else {
5746 msm_gpios_disable_free(curr->cfg_data, curr->size);
5747 }
5748 }
5749
5750 return rc;
5751}
5752
5753static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
5754{
5755 int rc = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005756 struct regulator *curr = sdcc_vreg_data[dev_id - 1];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005757 static int enabled_once[] = {0, 0, 0, 0};
5758
Justin Paupore3f40f342011-08-10 18:52:16 -07005759 if (test_bit(dev_id, &vreg_sts) == enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005760 return rc;
5761
Asutosh Das853bbcd2012-02-01 10:40:05 +05305762 if (dev_id == 4) {
5763 if (enable) {
5764 pr_debug("Enable Vdd dev_%d\n", dev_id);
5765 gpio_set_value_cansleep(
5766 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5767 0);
5768 set_bit(dev_id, &vreg_sts);
5769 } else {
5770 pr_debug("Disable Vdd dev_%d\n", dev_id);
5771 gpio_set_value_cansleep(
5772 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5773 1);
5774 clear_bit(dev_id, &vreg_sts);
5775 }
5776 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005777
Asutosh Das853bbcd2012-02-01 10:40:05 +05305778 if (!enable || enabled_once[dev_id - 1])
5779 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005780 if (!curr)
5781 return -ENODEV;
5782
5783 if (IS_ERR(curr))
5784 return PTR_ERR(curr);
5785
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005786 if (enable) {
5787 set_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005788
5789 rc = regulator_enable(curr);
5790 if (rc)
5791 pr_err("%s: could not enable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005792 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005793 enabled_once[dev_id - 1] = 1;
5794 } else {
5795 clear_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005796
5797 rc = regulator_disable(curr);
5798 if (rc)
5799 pr_err("%s: could not disable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005800 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005801 }
5802 return rc;
5803}
5804
5805static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
5806{
5807 int rc = 0;
5808 struct platform_device *pdev;
5809
5810 pdev = container_of(dv, struct platform_device, dev);
5811 rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
5812 if (rc)
5813 goto out;
5814
5815 if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
5816 rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
5817out:
5818 return rc;
5819}
5820
5821#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \
5822 defined(CONFIG_CSDIO_VENDOR_ID) && \
5823 defined(CONFIG_CSDIO_DEVICE_ID) && \
5824 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5825
5826#define MBP_ON 1
5827#define MBP_OFF 0
5828
5829#define MBP_RESET_N \
5830 GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
5831#define MBP_INT0 \
5832 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
5833
5834#define MBP_MODE_CTRL_0 \
5835 GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5836#define MBP_MODE_CTRL_1 \
5837 GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5838#define MBP_MODE_CTRL_2 \
5839 GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5840#define TSIF_EN \
5841 GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5842#define TSIF_DATA \
5843 GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5844#define TSIF_CLK \
5845 GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5846
5847static struct msm_gpio mbp_cfg_data[] = {
5848 {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5849 "mbp_reset"},
5850 {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5851 "mbp_io_voltage"},
5852};
5853
5854static int mbp_config_gpios_pre_init(int enable)
5855{
5856 int rc = 0;
5857
5858 if (enable) {
5859 rc = msm_gpios_request_enable(mbp_cfg_data,
5860 ARRAY_SIZE(mbp_cfg_data));
5861 if (rc) {
5862 printk(KERN_ERR
5863 "%s: Failed to turnon GPIOs for mbp chip(%d)\n",
5864 __func__, rc);
5865 }
5866 } else
5867 msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
5868 return rc;
5869}
5870
Justin Paupore3f40f342011-08-10 18:52:16 -07005871static struct regulator_bulk_data mbp_regs_io[2];
5872static struct regulator_bulk_data mbp_regs_rf[2];
5873static struct regulator_bulk_data mbp_regs_adc[1];
5874static struct regulator_bulk_data mbp_regs_core[1];
5875
5876static int mbp_init_regs(struct device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005877{
Justin Paupore3f40f342011-08-10 18:52:16 -07005878 struct regulator_bulk_data regs[] = {
5879 /* Analog and I/O regs */
5880 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
5881 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
5882 /* RF regs */
5883 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
5884 { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 },
5885 /* ADC regs */
5886 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
5887 /* Core regs */
5888 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
5889 };
5890
5891 struct regulator_bulk_data *regptr = regs;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005892 int rc;
5893
Justin Paupore3f40f342011-08-10 18:52:16 -07005894 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs);
5895
5896 if (rc) {
5897 dev_err(dev, "%s: could not get regulators: %d\n",
5898 __func__, rc);
5899 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005900 }
5901
Justin Paupore3f40f342011-08-10 18:52:16 -07005902 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005903
Justin Paupore3f40f342011-08-10 18:52:16 -07005904 if (rc) {
5905 dev_err(dev, "%s: could not set voltages: %d\n",
5906 __func__, rc);
5907 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005908 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005909
5910 memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io));
5911 regptr += ARRAY_SIZE(mbp_regs_io);
5912
5913 memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf));
5914 regptr += ARRAY_SIZE(mbp_regs_rf);
5915
5916 memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc));
5917 regptr += ARRAY_SIZE(mbp_regs_adc);
5918
5919 memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core));
5920
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005921 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005922
5923reg_free:
5924 regulator_bulk_free(ARRAY_SIZE(regs), regs);
5925out:
5926 return rc;
5927}
5928
5929static int mbp_setup_rf_vregs(int state)
5930{
5931 return state ?
5932 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) :
5933 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005934}
5935
5936static int mbp_setup_vregs(int state)
5937{
Justin Paupore3f40f342011-08-10 18:52:16 -07005938 return state ?
5939 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) :
5940 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005941}
5942
5943static int mbp_set_tcxo_en(int enable)
5944{
5945 int rc;
5946 const char *id = "UBMC";
5947 struct vreg *vreg_analog = NULL;
5948
5949 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
5950 enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
5951 if (rc < 0) {
5952 printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
5953 __func__, enable ? "" : "de-");
5954 return -EIO;
5955 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005956 return rc;
5957}
5958
5959static void mbp_set_freeze_io(int state)
5960{
5961 if (state)
5962 gpio_set_value(85, 0);
5963 else
5964 gpio_set_value(85, 1);
5965}
5966
5967static int mbp_set_core_voltage_en(int enable)
5968{
Justin Paupore3f40f342011-08-10 18:52:16 -07005969 static bool is_enabled;
5970 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005971
Justin Paupore3f40f342011-08-10 18:52:16 -07005972 if (enable && !is_enabled) {
5973 rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core),
5974 mbp_regs_core);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005975 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005976 pr_err("%s: could not enable regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005977 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07005978 } else {
5979 is_enabled = true;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005980 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005981 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005982
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005983 return rc;
5984}
5985
5986static void mbp_set_reset(int state)
5987{
5988 if (state)
5989 gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
5990 else
5991 gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
5992}
5993
5994static int mbp_config_interface_mode(int state)
5995{
5996 if (state) {
5997 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
5998 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
5999 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
6000 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
6001 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
6002 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
6003 } else {
6004 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
6005 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
6006 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
6007 }
6008 return 0;
6009}
6010
6011static int mbp_setup_adc_vregs(int state)
6012{
Justin Paupore3f40f342011-08-10 18:52:16 -07006013 return state ?
6014 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) :
6015 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006016}
6017
6018static int mbp_power_up(void)
6019{
6020 int rc;
6021
6022 rc = mbp_config_gpios_pre_init(MBP_ON);
6023 if (rc)
6024 goto exit;
6025 pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__);
6026
6027 rc = mbp_setup_vregs(MBP_ON);
6028 if (rc)
6029 goto exit;
6030 pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
6031
6032 rc = mbp_set_tcxo_en(MBP_ON);
6033 if (rc)
6034 goto exit;
6035 pr_debug("%s: tcxo clock done\n", __func__);
6036
6037 mbp_set_freeze_io(MBP_OFF);
6038 pr_debug("%s: set gpio 85 to 1 done\n", __func__);
6039
6040 udelay(100);
6041 mbp_set_reset(MBP_ON);
6042
6043 udelay(300);
6044 rc = mbp_config_interface_mode(MBP_ON);
6045 if (rc)
6046 goto exit;
6047 pr_debug("%s: mbp_config_interface_mode() done\n", __func__);
6048
6049 udelay(100 + mbp_set_core_voltage_en(MBP_ON));
6050 pr_debug("%s: power gp16 1.2V done\n", __func__);
6051
6052 mbp_set_freeze_io(MBP_ON);
6053 pr_debug("%s: set gpio 85 to 0 done\n", __func__);
6054
6055 udelay(100);
6056
6057 rc = mbp_setup_rf_vregs(MBP_ON);
6058 if (rc)
6059 goto exit;
6060 pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
6061
6062 rc = mbp_setup_adc_vregs(MBP_ON);
6063 if (rc)
6064 goto exit;
6065 pr_debug("%s: s4 2.2V done\n", __func__);
6066
6067 udelay(200);
6068
6069 mbp_set_reset(MBP_OFF);
6070 pr_debug("%s: close gpio 44 done\n", __func__);
6071
6072 msleep(20);
6073exit:
6074 return rc;
6075}
6076
6077static int mbp_power_down(void)
6078{
6079 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006080
6081 mbp_set_reset(MBP_ON);
6082 pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
6083
6084 udelay(100);
6085
6086 rc = mbp_setup_adc_vregs(MBP_OFF);
6087 if (rc)
6088 goto exit;
6089 pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
6090
6091 udelay(5);
6092
6093 rc = mbp_setup_rf_vregs(MBP_OFF);
6094 if (rc)
6095 goto exit;
6096 pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
6097
6098 udelay(5);
6099
6100 mbp_set_freeze_io(MBP_OFF);
6101 pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
6102
6103 udelay(100);
6104 rc = mbp_set_core_voltage_en(MBP_OFF);
6105 if (rc)
6106 goto exit;
6107 pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
6108
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006109 rc = mbp_set_tcxo_en(MBP_OFF);
6110 if (rc)
6111 goto exit;
6112 pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
6113
Justin Paupore3f40f342011-08-10 18:52:16 -07006114 rc = mbp_setup_vregs(MBP_OFF);
6115 if (rc)
6116 goto exit;
6117 pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__);
6118
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006119 rc = mbp_config_gpios_pre_init(MBP_OFF);
6120 if (rc)
6121 goto exit;
6122exit:
6123 return rc;
6124}
6125
6126static void (*mbp_status_notify_cb)(int card_present, void *dev_id);
6127static void *mbp_status_notify_cb_devid;
6128static int mbp_power_status;
6129static int mbp_power_init_done;
6130
6131static uint32_t mbp_setup_power(struct device *dv,
6132 unsigned int power_status)
6133{
6134 int rc = 0;
6135 struct platform_device *pdev;
6136
6137 pdev = container_of(dv, struct platform_device, dev);
6138
6139 if (power_status == mbp_power_status)
6140 goto exit;
6141 if (power_status) {
6142 pr_debug("turn on power of mbp slot");
6143 rc = mbp_power_up();
6144 mbp_power_status = 1;
6145 } else {
6146 pr_debug("turn off power of mbp slot");
6147 rc = mbp_power_down();
6148 mbp_power_status = 0;
6149 }
6150exit:
6151 return rc;
6152};
6153
6154int mbp_register_status_notify(void (*callback)(int, void *),
6155 void *dev_id)
6156{
6157 mbp_status_notify_cb = callback;
6158 mbp_status_notify_cb_devid = dev_id;
6159 return 0;
6160}
6161
6162static unsigned int mbp_status(struct device *dev)
6163{
6164 return mbp_power_status;
6165}
6166
6167static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd)
6168{
6169 struct platform_device *pdev;
6170 uint32_t rc = 0;
6171
6172 pdev = container_of(dv, struct platform_device, dev);
6173 rc = msm_sdcc_setup_power(dv, vdd);
6174 if (rc) {
6175 pr_err("%s: Failed to setup power (%d)\n",
6176 __func__, rc);
6177 goto out;
6178 }
6179 if (!mbp_power_init_done) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006180 rc = mbp_init_regs(dv);
6181 if (rc) {
6182 dev_err(dv, "%s: regulator init failed: %d\n",
6183 __func__, rc);
6184 goto out;
6185 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006186 mbp_setup_power(dv, 1);
6187 mbp_setup_power(dv, 0);
6188 mbp_power_init_done = 1;
6189 }
6190 if (vdd >= 0x8000) {
6191 rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
6192 if (rc) {
6193 pr_err("%s: Failed to config mbp chip power (%d)\n",
6194 __func__, rc);
6195 goto out;
6196 }
6197 if (mbp_status_notify_cb) {
6198 mbp_status_notify_cb(mbp_power_status,
6199 mbp_status_notify_cb_devid);
6200 }
6201 }
6202out:
6203 /* should return 0 only */
6204 return 0;
6205}
6206
6207#endif
6208
6209#endif
6210
6211#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006212static unsigned int msm7x30_sdcc_slot_status(struct device *dev)
6213{
6214 return (unsigned int)
6215 gpio_get_value_cansleep(
6216 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1));
6217}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006218
6219static int msm_sdcc_get_wpswitch(struct device *dv)
6220{
6221 void __iomem *wp_addr = 0;
6222 uint32_t ret = 0;
6223 struct platform_device *pdev;
6224
6225 if (!(machine_is_msm7x30_surf()))
6226 return -1;
6227 pdev = container_of(dv, struct platform_device, dev);
6228
6229 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
6230 if (!wp_addr) {
6231 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
6232 return -ENOMEM;
6233 }
6234
6235 ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
6236 pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
6237 pdev->id, ret);
6238 iounmap(wp_addr);
6239
6240 return ret;
6241}
6242#endif
6243
6244#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
6245#if defined(CONFIG_CSDIO_VENDOR_ID) && \
6246 defined(CONFIG_CSDIO_DEVICE_ID) && \
6247 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
6248static struct mmc_platform_data msm7x30_sdc1_data = {
6249 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
6250 .translate_vdd = msm_sdcc_setup_power_mbp,
6251 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6252 .status = mbp_status,
6253 .register_status_notify = mbp_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006254 .msmsdcc_fmin = 144000,
6255 .msmsdcc_fmid = 24576000,
6256 .msmsdcc_fmax = 24576000,
6257 .nonremovable = 0,
6258};
6259#else
6260static struct mmc_platform_data msm7x30_sdc1_data = {
6261 .ocr_mask = MMC_VDD_165_195,
6262 .translate_vdd = msm_sdcc_setup_power,
6263 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006264 .msmsdcc_fmin = 144000,
6265 .msmsdcc_fmid = 24576000,
6266 .msmsdcc_fmax = 49152000,
6267 .nonremovable = 0,
6268};
6269#endif
6270#endif
6271
6272#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
6273static struct mmc_platform_data msm7x30_sdc2_data = {
6274 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
6275 .translate_vdd = msm_sdcc_setup_power,
6276#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
6277 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
6278#else
6279 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6280#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006281 .msmsdcc_fmin = 144000,
6282 .msmsdcc_fmid = 24576000,
6283 .msmsdcc_fmax = 49152000,
6284 .nonremovable = 1,
6285};
6286#endif
6287
6288#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
6289static struct mmc_platform_data msm7x30_sdc3_data = {
6290 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6291 .translate_vdd = msm_sdcc_setup_power,
6292 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006293 .sdiowakeup_irq = MSM_GPIO_TO_INT(118),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006294 .msmsdcc_fmin = 144000,
6295 .msmsdcc_fmid = 24576000,
6296 .msmsdcc_fmax = 49152000,
6297 .nonremovable = 0,
6298};
6299#endif
6300
6301#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6302static struct mmc_platform_data msm7x30_sdc4_data = {
6303 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6304 .translate_vdd = msm_sdcc_setup_power,
6305 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006306 .status = msm7x30_sdcc_slot_status,
6307 .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
6308 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006309 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006310 .msmsdcc_fmin = 144000,
6311 .msmsdcc_fmid = 24576000,
6312 .msmsdcc_fmax = 49152000,
6313 .nonremovable = 0,
6314};
6315#endif
6316
6317#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006318static int msm_sdc1_lvlshft_enable(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006319{
Justin Paupore3f40f342011-08-10 18:52:16 -07006320 static struct regulator *ldo5;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006321 int rc;
6322
6323 /* Enable LDO5, an input to the FET that powers slot 1 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006324
Justin Paupore3f40f342011-08-10 18:52:16 -07006325 ldo5 = regulator_get(NULL, "ldo5");
6326
6327 if (IS_ERR(ldo5)) {
6328 rc = PTR_ERR(ldo5);
6329 pr_err("%s: could not get ldo5: %d\n", __func__, rc);
6330 goto out;
6331 }
6332
6333 rc = regulator_set_voltage(ldo5, 2850000, 2850000);
6334 if (rc) {
6335 pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc);
6336 goto ldo5_free;
6337 }
6338
6339 rc = regulator_enable(ldo5);
6340 if (rc) {
6341 pr_err("%s: could not enable ldo5: %d\n", __func__, rc);
6342 goto ldo5_free;
6343 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006344
6345 /* Enable GPIO 35, to turn on the FET that powers slot 1 */
6346 rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
6347 ARRAY_SIZE(sdc1_lvlshft_cfg_data));
6348 if (rc)
6349 printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
6350
6351 rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg),
6352 1);
6353 if (rc)
6354 printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006355
6356 return 0;
6357
6358ldo5_free:
6359 regulator_put(ldo5);
6360out:
6361 ldo5 = NULL;
6362 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006363}
6364#endif
6365
Justin Paupore3f40f342011-08-10 18:52:16 -07006366static int mmc_regulator_init(int sdcc_no, const char *supply, int uV)
6367{
6368 int rc;
6369
6370 BUG_ON(sdcc_no < 1 || sdcc_no > 4);
6371
6372 sdcc_no--;
6373
6374 sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply);
6375
6376 if (IS_ERR(sdcc_vreg_data[sdcc_no])) {
6377 rc = PTR_ERR(sdcc_vreg_data[sdcc_no]);
6378 pr_err("%s: could not get regulator \"%s\": %d\n",
6379 __func__, supply, rc);
6380 goto out;
6381 }
6382
6383 rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV);
6384
6385 if (rc) {
6386 pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n",
6387 __func__, supply, uV, rc);
6388 goto reg_free;
6389 }
6390
6391 return rc;
6392
6393reg_free:
6394 regulator_put(sdcc_vreg_data[sdcc_no]);
6395out:
6396 sdcc_vreg_data[sdcc_no] = NULL;
6397 return rc;
6398}
6399
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006400static void __init msm7x30_init_mmc(void)
6401{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006402#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006403 if (mmc_regulator_init(1, "s3", 1800000))
6404 goto out1;
6405
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006406 if (machine_is_msm7x30_fluid()) {
6407 msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
Justin Paupore3f40f342011-08-10 18:52:16 -07006408 if (msm_sdc1_lvlshft_enable()) {
6409 pr_err("%s: could not enable level shift\n");
6410 goto out1;
6411 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006412 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006413
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006414 msm_add_sdcc(1, &msm7x30_sdc1_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006415out1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006416#endif
6417#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006418 if (mmc_regulator_init(2, "s3", 1800000))
6419 goto out2;
6420
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006421 if (machine_is_msm8x55_svlte_surf())
6422 msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
Sujith Reddy Thumma84a0f512011-08-29 09:57:03 +05306423 if (machine_is_msm8x55_svlte_surf() ||
6424 machine_is_msm8x55_svlte_ffa()) {
6425 msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
6426 msm7x30_sdc2_data.is_sdio_al_client = 1;
6427 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006428
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006429 msm_add_sdcc(2, &msm7x30_sdc2_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006430out2:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006431#endif
6432#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006433 if (mmc_regulator_init(3, "s3", 1800000))
6434 goto out3;
6435
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006436 msm_sdcc_setup_gpio(3, 1);
6437 msm_add_sdcc(3, &msm7x30_sdc3_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006438out3:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006439#endif
6440#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006441 if (mmc_regulator_init(4, "mmc", 2850000))
6442 return;
6443
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006444 msm_add_sdcc(4, &msm7x30_sdc4_data);
6445#endif
6446
6447}
6448
6449static void __init msm7x30_init_nand(void)
6450{
6451 char *build_id;
6452 struct flash_platform_data *plat_data;
6453
6454 build_id = socinfo_get_build_id();
6455 if (build_id == NULL) {
6456 pr_err("%s: Build ID not available from socinfo\n", __func__);
6457 return;
6458 }
6459
6460 if (build_id[8] == 'C' &&
6461 !msm_gpios_request_enable(msm_nand_ebi2_cfg_data,
6462 ARRAY_SIZE(msm_nand_ebi2_cfg_data))) {
6463 plat_data = msm_device_nand.dev.platform_data;
6464 plat_data->interleave = 1;
6465 printk(KERN_INFO "%s: Interleave mode Build ID found\n",
6466 __func__);
6467 }
6468}
6469
6470#ifdef CONFIG_SERIAL_MSM_CONSOLE
6471static struct msm_gpio uart2_config_data[] = {
6472 { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
6473 { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
6474 { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
6475 { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
6476};
6477
6478static void msm7x30_init_uart2(void)
6479{
6480 msm_gpios_request_enable(uart2_config_data,
6481 ARRAY_SIZE(uart2_config_data));
6482
6483}
6484#endif
6485
6486/* TSIF begin */
6487#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6488
6489#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6490#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6491#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6492#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6493
6494static const struct msm_gpio tsif_gpios[] = {
6495 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
6496 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
6497 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
6498 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
6499};
6500
6501static struct msm_tsif_platform_data tsif_platform_data = {
6502 .num_gpios = ARRAY_SIZE(tsif_gpios),
6503 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -07006504 .tsif_pclk = "iface_clk",
6505 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006506};
6507#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
6508/* TSIF end */
6509
6510static void __init pmic8058_leds_init(void)
6511{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306512 if (machine_is_msm7x30_surf())
6513 pm8058_7x30_data.leds_pdata = &pm8058_surf_leds_data;
6514 else if (!machine_is_msm7x30_fluid())
6515 pm8058_7x30_data.leds_pdata = &pm8058_ffa_leds_data;
6516 else if (machine_is_msm7x30_fluid())
6517 pm8058_7x30_data.leds_pdata = &pm8058_fluid_leds_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006518}
6519
6520static struct msm_spm_platform_data msm_spm_data __initdata = {
Taniya Das298de8c2012-02-16 11:45:31 +05306521 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006522
6523 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
6524 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
6525 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
6526 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
6527
6528 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
6529 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
6530 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
6531
6532 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
6533 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
6534 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
6535
6536 .awake_vlevel = 0xF2,
6537 .retention_vlevel = 0xE0,
6538 .collapse_vlevel = 0x72,
6539 .retention_mid_vlevel = 0xE0,
6540 .collapse_mid_vlevel = 0xE0,
6541
6542 .vctl_timeout_us = 50,
6543};
6544
6545#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6546 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6547
6548#define TSC2007_TS_PEN_INT 20
6549
6550static struct msm_gpio tsc2007_config_data[] = {
6551 { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
6552 "tsc2007_irq" },
6553};
6554
Justin Paupore3f40f342011-08-10 18:52:16 -07006555static struct regulator_bulk_data tsc2007_regs[] = {
6556 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
6557 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
6558};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006559
6560static int tsc2007_init(void)
6561{
6562 int rc;
6563
Justin Paupore3f40f342011-08-10 18:52:16 -07006564 rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006565
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006566 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006567 pr_err("%s: could not get regulators: %d\n", __func__, rc);
6568 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006569 }
6570
Justin Paupore3f40f342011-08-10 18:52:16 -07006571 rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6572
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006573 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006574 pr_err("%s: could not set voltages: %d\n", __func__, rc);
6575 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006576 }
6577
Justin Paupore3f40f342011-08-10 18:52:16 -07006578 rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006579
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006580 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006581 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
6582 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006583 }
6584
6585 rc = msm_gpios_request_enable(tsc2007_config_data,
6586 ARRAY_SIZE(tsc2007_config_data));
6587 if (rc) {
6588 pr_err("%s: Unable to request gpios\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006589 goto reg_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006590 }
6591
6592 return 0;
6593
Justin Paupore3f40f342011-08-10 18:52:16 -07006594reg_disable:
6595 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6596reg_free:
6597 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6598out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006599 return rc;
6600}
6601
6602static int tsc2007_get_pendown_state(void)
6603{
6604 int rc;
6605
6606 rc = gpio_get_value(TSC2007_TS_PEN_INT);
6607 if (rc < 0) {
6608 pr_err("%s: MSM GPIO %d read failed\n", __func__,
6609 TSC2007_TS_PEN_INT);
6610 return rc;
6611 }
6612
6613 return (rc == 0 ? 1 : 0);
6614}
6615
6616static void tsc2007_exit(void)
6617{
Justin Paupore3f40f342011-08-10 18:52:16 -07006618
6619 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6620 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006621
6622 msm_gpios_disable_free(tsc2007_config_data,
6623 ARRAY_SIZE(tsc2007_config_data));
6624}
6625
6626static int tsc2007_power_shutdown(bool enable)
6627{
6628 int rc;
6629
Justin Paupore3f40f342011-08-10 18:52:16 -07006630 rc = (enable == false) ?
6631 regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) :
6632 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6633
6634 if (rc) {
6635 pr_err("%s: could not %sable regulators: %d\n",
6636 __func__, enable ? "dis" : "en", rc);
6637 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006638 }
6639
Justin Paupore3f40f342011-08-10 18:52:16 -07006640 if (enable == false)
6641 msleep(20);
6642
6643 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006644}
6645
6646static struct tsc2007_platform_data tsc2007_ts_data = {
6647 .model = 2007,
6648 .x_plate_ohms = 300,
Anirudh Ghayala2cf2e22012-01-25 12:29:42 +05306649 .min_x = 210,
6650 .max_x = 3832,
6651 .min_y = 150,
6652 .max_y = 3936,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006653 .irq_flags = IRQF_TRIGGER_LOW,
6654 .init_platform_hw = tsc2007_init,
6655 .exit_platform_hw = tsc2007_exit,
6656 .power_shutdown = tsc2007_power_shutdown,
6657 .invert_x = true,
6658 .invert_y = true,
6659 /* REVISIT: Temporary fix for reversed pressure */
6660 .invert_z1 = true,
6661 .invert_z2 = true,
6662 .get_pendown_state = tsc2007_get_pendown_state,
6663};
6664
6665static struct i2c_board_info tsc_i2c_board_info[] = {
6666 {
6667 I2C_BOARD_INFO("tsc2007", 0x48),
6668 .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
6669 .platform_data = &tsc2007_ts_data,
6670 },
6671};
6672#endif
6673
Justin Paupore3f40f342011-08-10 18:52:16 -07006674static struct regulator_bulk_data regs_isa1200[] = {
6675 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
6676 { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006677};
6678
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006679static int isa1200_power(int vreg_on)
6680{
Justin Paupore3f40f342011-08-10 18:52:16 -07006681 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006682
Justin Paupore3f40f342011-08-10 18:52:16 -07006683 rc = vreg_on ?
6684 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) :
6685 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006686
Justin Paupore3f40f342011-08-10 18:52:16 -07006687 if (rc) {
6688 pr_err("%s: could not %sable regulators: %d\n",
6689 __func__, vreg_on ? "en" : "dis", rc);
6690 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006691 }
6692
6693 /* vote for DO buffer */
6694 rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO,
6695 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
6696 if (rc) {
6697 pr_err("%s: unable to %svote for d0 clk\n",
6698 __func__, vreg_on ? "" : "de-");
6699 goto vreg_fail;
6700 }
6701
6702 return 0;
6703
6704vreg_fail:
Justin Paupore3f40f342011-08-10 18:52:16 -07006705 if (vreg_on)
6706 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6707 else
6708 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6709out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006710 return rc;
6711}
6712
6713static int isa1200_dev_setup(bool enable)
6714{
Justin Paupore3f40f342011-08-10 18:52:16 -07006715 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006716
6717 if (enable == true) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006718 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200),
6719 regs_isa1200);
6720
6721 if (rc) {
6722 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006723 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006724 goto out;
6725 }
6726
6727 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200),
6728 regs_isa1200);
6729 if (rc) {
6730 pr_err("%s: could not set voltages: %d\n",
6731 __func__, rc);
6732 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006733 }
6734
6735 rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
6736 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
6737 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
6738 if (rc) {
6739 pr_err("%s: Could not configure gpio %d\n",
6740 __func__, HAP_LVL_SHFT_MSM_GPIO);
Justin Paupore3f40f342011-08-10 18:52:16 -07006741 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006742 }
6743
6744 rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
6745 if (rc) {
6746 pr_err("%s: unable to request gpio %d (%d)\n",
6747 __func__, HAP_LVL_SHFT_MSM_GPIO, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006748 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006749 }
6750
6751 gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
6752 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006753 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006754 gpio_free(HAP_LVL_SHFT_MSM_GPIO);
6755 }
6756
6757 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07006758
6759reg_free:
6760 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6761out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006762 return rc;
6763}
6764static struct isa1200_platform_data isa1200_1_pdata = {
6765 .name = "vibrator",
6766 .power_on = isa1200_power,
6767 .dev_setup = isa1200_dev_setup,
6768 .pwm_ch_id = 1, /*channel id*/
6769 /*gpio to enable haptic*/
6770 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka03122322011-09-09 15:15:43 +05306771 .hap_len_gpio = -1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006772 .max_timeout = 15000,
6773 .mode_ctrl = PWM_GEN_MODE,
6774 .pwm_fd = {
6775 .pwm_div = 256,
6776 },
6777 .is_erm = false,
6778 .smart_en = true,
6779 .ext_clk_en = true,
6780 .chip_en = 1,
6781};
6782
6783static struct i2c_board_info msm_isa1200_board_info[] = {
6784 {
6785 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
6786 .platform_data = &isa1200_1_pdata,
6787 },
6788};
6789
6790
6791static int kp_flip_mpp_config(void)
6792{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306793 struct pm8xxx_mpp_config_data kp_flip_mpp = {
6794 .type = PM8XXX_MPP_TYPE_D_INPUT,
6795 .level = PM8018_MPP_DIG_LEVEL_S3,
6796 .control = PM8XXX_MPP_DIN_TO_INT,
6797 };
6798
6799 return pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(PM_FLIP_MPP),
6800 &kp_flip_mpp);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006801}
6802
6803static struct flip_switch_pdata flip_switch_data = {
6804 .name = "kp_flip_switch",
6805 .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP,
6806 .left_key = KEY_OPEN,
6807 .right_key = KEY_CLOSE,
6808 .active_low = 0,
6809 .wakeup = 1,
6810 .flip_mpp_config = kp_flip_mpp_config,
6811};
6812
6813static struct platform_device flip_switch_device = {
6814 .name = "kp_flip_switch",
6815 .id = -1,
6816 .dev = {
6817 .platform_data = &flip_switch_data,
6818 }
6819};
6820
Justin Paupore3f40f342011-08-10 18:52:16 -07006821static struct regulator_bulk_data regs_tma300[] = {
6822 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
6823 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006824};
6825
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006826static int tma300_power(int vreg_on)
6827{
Justin Paupore3f40f342011-08-10 18:52:16 -07006828 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006829
Justin Paupore3f40f342011-08-10 18:52:16 -07006830 rc = vreg_on ?
6831 regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) :
6832 regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006833
Justin Paupore3f40f342011-08-10 18:52:16 -07006834 if (rc)
6835 pr_err("%s: could not %sable regulators: %d\n",
6836 __func__, vreg_on ? "en" : "dis", rc);
6837 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006838}
6839
6840#define TS_GPIO_IRQ 150
6841
6842static int tma300_dev_setup(bool enable)
6843{
Justin Paupore3f40f342011-08-10 18:52:16 -07006844 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006845
6846 if (enable) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006847 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300),
6848 regs_tma300);
6849
6850 if (rc) {
6851 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006852 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006853 goto out;
6854 }
6855
6856 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300),
6857 regs_tma300);
6858
6859 if (rc) {
6860 pr_err("%s: could not set voltages: %d\n",
6861 __func__, rc);
6862 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006863 }
6864
6865 /* enable interrupt gpio */
6866 rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
6867 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
6868 if (rc) {
6869 pr_err("%s: Could not configure gpio %d\n",
6870 __func__, TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -07006871 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006872 }
6873
6874 /* virtual keys */
6875 tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
6876 properties_kobj = kobject_create_and_add("board_properties",
6877 NULL);
6878 if (!properties_kobj) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006879 pr_err("%s: failed to create a kobject "
6880 "for board_properties\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006881 rc = -ENOMEM;
Justin Paupore3f40f342011-08-10 18:52:16 -07006882 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006883 }
6884 rc = sysfs_create_group(properties_kobj,
6885 &tma300_properties_attr_group);
6886 if (rc) {
6887 pr_err("%s: failed to create a sysfs entry %s\n",
6888 __func__, tma300_vkeys_attr.attr.name);
Justin Paupore3f40f342011-08-10 18:52:16 -07006889 goto kobj_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006890 }
6891 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006892 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006893 /* destroy virtual keys */
6894 if (properties_kobj) {
6895 sysfs_remove_group(properties_kobj,
6896 &tma300_properties_attr_group);
6897 kobject_put(properties_kobj);
6898 }
6899 }
6900 return 0;
6901
Justin Paupore3f40f342011-08-10 18:52:16 -07006902kobj_free:
6903 kobject_put(properties_kobj);
6904 properties_kobj = NULL;
6905reg_free:
6906 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
6907out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006908 return rc;
6909}
6910
6911static struct cy8c_ts_platform_data cy8ctma300_pdata = {
6912 .power_on = tma300_power,
6913 .dev_setup = tma300_dev_setup,
6914 .ts_name = "msm_tma300_ts",
6915 .dis_min_x = 0,
6916 .dis_max_x = 479,
6917 .dis_min_y = 0,
6918 .dis_max_y = 799,
6919 .res_x = 479,
6920 .res_y = 1009,
6921 .min_tid = 1,
6922 .max_tid = 255,
6923 .min_touch = 0,
6924 .max_touch = 255,
6925 .min_width = 0,
6926 .max_width = 255,
6927 .invert_y = 1,
6928 .nfingers = 4,
6929 .irq_gpio = TS_GPIO_IRQ,
6930 .resout_gpio = -1,
6931};
6932
6933static struct i2c_board_info cy8ctma300_board_info[] = {
6934 {
6935 I2C_BOARD_INFO("cy8ctma300", 0x2),
6936 .platform_data = &cy8ctma300_pdata,
6937 }
6938};
6939
Daniel Walker8d747cd2010-02-25 11:37:43 -08006940static void __init msm7x30_init(void)
6941{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006942 int rc;
6943 unsigned smem_size;
6944 uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56,
6945 0,
6946 GPIO_CFG_OUTPUT,
6947 GPIO_CFG_NO_PULL,
6948 GPIO_CFG_2MA);
6949 uint32_t soc_version = 0;
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05306950
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006951 soc_version = socinfo_get_version();
6952
Stephen Boydbb600ae2011-08-02 20:11:40 -07006953 msm_clock_init(&msm7x30_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006954#ifdef CONFIG_SERIAL_MSM_CONSOLE
6955 msm7x30_init_uart2();
6956#endif
6957 msm_spm_init(&msm_spm_data, 1);
Matt Wagantallbf430eb2012-03-22 11:45:49 -07006958 platform_device_register(&msm7x30_device_acpuclk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006959 if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid())
6960 msm7x30_cfg_smsc911x();
6961
6962#ifdef CONFIG_USB_MSM_OTG_72K
6963 if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 &&
6964 SOCINFO_VERSION_MINOR(soc_version) >= 1) {
6965 pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
6966 msm_otg_pdata.ldo_set_voltage = 0;
6967 }
6968
6969 msm_device_otg.dev.platform_data = &msm_otg_pdata;
6970#ifdef CONFIG_USB_GADGET
6971 msm_otg_pdata.swfi_latency =
6972 msm_pm_data
6973 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
6974 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
6975#endif
6976#endif
6977 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
6978 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
6979#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6980 msm_device_tsif.dev.platform_data = &tsif_platform_data;
6981#endif
6982 if (machine_is_msm7x30_fluid()) {
6983 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
6984 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
6985 } else {
6986 msm_adc_pdata.dev_names = msm_adc_surf_device_names;
6987 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names);
6988 }
6989
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306990 pmic8058_leds_init();
6991
6992 buses_init();
6993
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306994#ifdef CONFIG_MSM_SSBI
6995 msm_device_ssbi_pmic1.dev.platform_data =
6996 &msm7x30_ssbi_pm8058_pdata;
6997#endif
6998
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006999 platform_add_devices(msm_footswitch_devices,
7000 msm_num_footswitch_devices);
Daniel Walker8d747cd2010-02-25 11:37:43 -08007001 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007002#ifdef CONFIG_USB_EHCI_MSM_72K
7003 msm_add_host(0, &msm_usb_host_pdata);
7004#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07007005#ifdef CONFIG_MSM_CAMERA_V4L2
7006 msm7x30_init_cam();
7007#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007008 msm7x30_init_mmc();
7009 msm7x30_init_nand();
7010 msm_qsd_spi_init();
7011
7012#ifdef CONFIG_SPI_QSD
7013 if (machine_is_msm7x30_fluid())
7014 spi_register_board_info(lcdc_sharp_spi_board_info,
7015 ARRAY_SIZE(lcdc_sharp_spi_board_info));
7016 else
7017 spi_register_board_info(lcdc_toshiba_spi_board_info,
7018 ARRAY_SIZE(lcdc_toshiba_spi_board_info));
7019#endif
7020
Justin Paupore3f40f342011-08-10 18:52:16 -07007021 atv_dac_power_init();
7022 sensors_ldo_init();
7023 hdmi_init_regs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007024 msm_fb_add_devices();
7025 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06007026 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05307027 msm_pm_register_irqs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007028 msm_device_i2c_init();
7029 msm_device_i2c_2_init();
7030 qup_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007031 msm7x30_init_marimba();
7032#ifdef CONFIG_MSM7KV2_AUDIO
7033 snddev_poweramp_gpio_init();
Justin Paupore3f40f342011-08-10 18:52:16 -07007034 snddev_hsed_voltage_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007035 aux_pcm_gpio_init();
7036#endif
7037
7038 i2c_register_board_info(0, msm_i2c_board_info,
7039 ARRAY_SIZE(msm_i2c_board_info));
7040
7041 if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid())
7042 marimba_pdata.tsadc = &marimba_tsadc_pdata;
7043
7044 if (machine_is_msm7x30_fluid())
7045 i2c_register_board_info(0, cy8info,
7046 ARRAY_SIZE(cy8info));
7047#ifdef CONFIG_BOSCH_BMA150
7048 if (machine_is_msm7x30_fluid())
7049 i2c_register_board_info(0, bma150_board_info,
7050 ARRAY_SIZE(bma150_board_info));
7051#endif
7052
7053 i2c_register_board_info(2, msm_marimba_board_info,
7054 ARRAY_SIZE(msm_marimba_board_info));
7055
7056 i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info,
7057 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info));
7058
7059 i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
7060 ARRAY_SIZE(msm_camera_boardinfo));
7061
7062 bt_power_init();
7063#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007064 msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
7065#endif
7066 if (machine_is_msm7x30_fluid())
7067 i2c_register_board_info(0, msm_isa1200_board_info,
7068 ARRAY_SIZE(msm_isa1200_board_info));
7069
7070#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
7071 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
7072 if (machine_is_msm8x55_svlte_ffa())
7073 i2c_register_board_info(2, tsc_i2c_board_info,
7074 ARRAY_SIZE(tsc_i2c_board_info));
7075#endif
7076
7077 if (machine_is_msm7x30_surf())
7078 platform_device_register(&flip_switch_device);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307079
7080 pm8058_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007081
7082 if (machine_is_msm7x30_fluid()) {
7083 /* Initialize platform data for fluid v2 hardware */
7084 if (SOCINFO_VERSION_MAJOR(
7085 socinfo_get_platform_version()) == 2) {
7086 cy8ctma300_pdata.res_y = 920;
7087 cy8ctma300_pdata.invert_y = 0;
7088 }
7089 i2c_register_board_info(0, cy8ctma300_board_info,
7090 ARRAY_SIZE(cy8ctma300_board_info));
7091 }
7092
7093 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
7094 rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE);
7095 if (rc)
7096 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
7097 __func__, usb_hub_gpio_cfg_value, rc);
7098 }
7099
7100 boot_reason = *(unsigned int *)
7101 (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
7102 printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
7103}
7104
7105static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
7106static int __init pmem_sf_size_setup(char *p)
7107{
7108 pmem_sf_size = memparse(p, NULL);
7109 return 0;
7110}
7111early_param("pmem_sf_size", pmem_sf_size_setup);
7112
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307113static unsigned fb_size;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007114static int __init fb_size_setup(char *p)
7115{
7116 fb_size = memparse(p, NULL);
7117 return 0;
7118}
7119early_param("fb_size", fb_size_setup);
7120
7121static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
7122static int __init pmem_adsp_size_setup(char *p)
7123{
7124 pmem_adsp_size = memparse(p, NULL);
7125 return 0;
7126}
7127early_param("pmem_adsp_size", pmem_adsp_size_setup);
7128
7129static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE;
7130static int __init fluid_pmem_adsp_size_setup(char *p)
7131{
7132 fluid_pmem_adsp_size = memparse(p, NULL);
7133 return 0;
7134}
7135early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup);
7136
7137static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
7138static int __init pmem_audio_size_setup(char *p)
7139{
7140 pmem_audio_size = memparse(p, NULL);
7141 return 0;
7142}
7143early_param("pmem_audio_size", pmem_audio_size_setup);
7144
7145static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE;
7146static int __init pmem_kernel_ebi0_size_setup(char *p)
7147{
7148 pmem_kernel_ebi0_size = memparse(p, NULL);
7149 return 0;
7150}
7151early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
7152
Chintan Pandya03b698a2012-06-28 19:03:09 +05307153#ifdef CONFIG_ION_MSM
7154#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
7155static struct ion_co_heap_pdata co_ion_pdata = {
7156 .adjacent_mem_id = INVALID_HEAP_ID,
7157 .align = PAGE_SIZE,
7158};
7159#endif
7160
7161/**
7162 * These heaps are listed in the order they will be allocated.
7163 * Don't swap the order unless you know what you are doing!
7164 */
Benjamin Gaignard63d81032012-06-25 15:27:30 -07007165struct ion_platform_heap msm7x30_heaps[] = {
Chintan Pandya03b698a2012-06-28 19:03:09 +05307166 {
7167 .id = ION_SYSTEM_HEAP_ID,
7168 .type = ION_HEAP_TYPE_SYSTEM,
7169 .name = ION_VMALLOC_HEAP_NAME,
7170 },
7171#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
7172 /* PMEM_ADSP = CAMERA */
7173 {
7174 .id = ION_CAMERA_HEAP_ID,
7175 .type = ION_HEAP_TYPE_CARVEOUT,
7176 .name = ION_CAMERA_HEAP_NAME,
7177 .memory_type = ION_EBI_TYPE,
Chintan Pandya03b698a2012-06-28 19:03:09 +05307178 .extra_data = (void *)&co_ion_pdata,
7179 },
7180 /* PMEM_AUDIO */
7181 {
7182 .id = ION_AUDIO_HEAP_ID,
7183 .type = ION_HEAP_TYPE_CARVEOUT,
7184 .name = ION_AUDIO_HEAP_NAME,
7185 .memory_type = ION_EBI_TYPE,
Chintan Pandya03b698a2012-06-28 19:03:09 +05307186 .extra_data = (void *)&co_ion_pdata,
7187 },
7188 /* PMEM_MDP = SF */
7189 {
7190 .id = ION_SF_HEAP_ID,
7191 .type = ION_HEAP_TYPE_CARVEOUT,
7192 .name = ION_SF_HEAP_NAME,
7193 .memory_type = ION_EBI_TYPE,
Chintan Pandya03b698a2012-06-28 19:03:09 +05307194 .extra_data = (void *)&co_ion_pdata,
7195 },
7196#endif
Benjamin Gaignard63d81032012-06-25 15:27:30 -07007197};
7198
7199static struct ion_platform_data ion_pdata = {
7200 .nr = MSM_ION_HEAP_NUM,
7201 .heaps = msm7x30_heaps,
Chintan Pandya03b698a2012-06-28 19:03:09 +05307202};
7203
7204static struct platform_device ion_dev = {
7205 .name = "ion-msm",
7206 .id = 1,
7207 .dev = { .platform_data = &ion_pdata },
7208};
7209#endif
7210
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007211static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
7212 [MEMTYPE_SMI] = {
7213 },
7214 [MEMTYPE_EBI0] = {
7215 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7216 },
7217 [MEMTYPE_EBI1] = {
7218 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7219 },
7220};
7221
Chintan Pandya03b698a2012-06-28 19:03:09 +05307222unsigned long size;
7223unsigned long msm_ion_camera_size;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007224
Chintan Pandya03b698a2012-06-28 19:03:09 +05307225static void fix_sizes(void)
7226{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007227 if machine_is_msm7x30_fluid()
7228 size = fluid_pmem_adsp_size;
7229 else
7230 size = pmem_adsp_size;
Chintan Pandya03b698a2012-06-28 19:03:09 +05307231
7232#ifdef CONFIG_ION_MSM
7233 msm_ion_camera_size = size;
7234#endif
7235}
7236
7237static void __init size_pmem_devices(void)
7238{
7239#ifdef CONFIG_ANDROID_PMEM
7240#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
7241
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007242 android_pmem_adsp_pdata.size = size;
7243 android_pmem_audio_pdata.size = pmem_audio_size;
7244 android_pmem_pdata.size = pmem_sf_size;
7245#endif
Chintan Pandya03b698a2012-06-28 19:03:09 +05307246#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007247}
7248
Chintan Pandya03b698a2012-06-28 19:03:09 +05307249#ifdef CONFIG_ANDROID_PMEM
7250#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007251static void __init reserve_memory_for(struct android_pmem_platform_data *p)
7252{
7253 msm7x30_reserve_table[p->memory_type].size += p->size;
7254}
Chintan Pandya03b698a2012-06-28 19:03:09 +05307255#endif
7256#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007257
7258static void __init reserve_pmem_memory(void)
7259{
7260#ifdef CONFIG_ANDROID_PMEM
Chintan Pandya03b698a2012-06-28 19:03:09 +05307261#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007262 reserve_memory_for(&android_pmem_adsp_pdata);
7263 reserve_memory_for(&android_pmem_audio_pdata);
7264 reserve_memory_for(&android_pmem_pdata);
7265 msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
7266#endif
Chintan Pandya03b698a2012-06-28 19:03:09 +05307267#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007268}
7269
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307270static void __init reserve_mdp_memory(void)
7271{
7272 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
7273 msm7x30_reserve_table[mdp_pdata.mem_hid].size += mdp_pdata.ov0_wb_size;
7274}
7275
Chintan Pandya03b698a2012-06-28 19:03:09 +05307276static void __init size_ion_devices(void)
7277{
7278#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
7279 ion_pdata.heaps[1].size = msm_ion_camera_size;
7280 ion_pdata.heaps[2].size = MSM_ION_AUDIO_SIZE;
7281 ion_pdata.heaps[3].size = MSM_ION_SF_SIZE;
7282#endif
7283}
7284
7285static void __init reserve_ion_memory(void)
7286{
7287#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
7288 msm7x30_reserve_table[MEMTYPE_EBI0].size += msm_ion_camera_size;
7289 msm7x30_reserve_table[MEMTYPE_EBI0].size += MSM_ION_AUDIO_SIZE;
7290 msm7x30_reserve_table[MEMTYPE_EBI0].size += MSM_ION_SF_SIZE;
7291#endif
7292}
7293
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007294static void __init msm7x30_calculate_reserve_sizes(void)
7295{
Chintan Pandya03b698a2012-06-28 19:03:09 +05307296 fix_sizes();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007297 size_pmem_devices();
7298 reserve_pmem_memory();
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307299 reserve_mdp_memory();
Chintan Pandya03b698a2012-06-28 19:03:09 +05307300 size_ion_devices();
7301 reserve_ion_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007302}
7303
7304static int msm7x30_paddr_to_memtype(unsigned int paddr)
7305{
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307306 if (paddr < phys_add)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007307 return MEMTYPE_EBI0;
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307308 if (paddr >= phys_add && paddr < 0x80000000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007309 return MEMTYPE_EBI1;
7310 return MEMTYPE_NONE;
7311}
7312
7313static struct reserve_info msm7x30_reserve_info __initdata = {
7314 .memtype_reserve_table = msm7x30_reserve_table,
7315 .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes,
7316 .paddr_to_memtype = msm7x30_paddr_to_memtype,
7317};
7318
7319static void __init msm7x30_reserve(void)
7320{
7321 reserve_info = &msm7x30_reserve_info;
7322 msm_reserve();
7323}
7324
7325static void __init msm7x30_allocate_memory_regions(void)
7326{
7327 void *addr;
7328 unsigned long size;
7329
7330 size = fb_size ? : MSM_FB_SIZE;
7331 addr = alloc_bootmem_align(size, 0x1000);
7332 msm_fb_resources[0].start = __pa(addr);
7333 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
7334 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
7335 size, addr, __pa(addr));
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08007336
7337#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
7338 size = MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE;
7339 addr = alloc_bootmem_align(size, 0x1000);
7340 msm_v4l2_video_overlay_resources[0].start = __pa(addr);
7341 msm_v4l2_video_overlay_resources[0].end =
7342 msm_v4l2_video_overlay_resources[0].start + size - 1;
7343 pr_debug("allocating %lu bytes at %p (%lx physical) for v4l2\n",
7344 size, addr, __pa(addr));
7345#endif
Daniel Walker8d747cd2010-02-25 11:37:43 -08007346}
7347
7348static void __init msm7x30_map_io(void)
7349{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007350 msm_shared_ram_phys = 0x00100000;
Daniel Walker8d747cd2010-02-25 11:37:43 -08007351 msm_map_msm7x30_io();
Abhimanyu Kapur91a0a502013-01-11 19:24:59 -08007352 if (socinfo_init() < 0)
Abhimanyu Kapur440cdde2012-12-04 00:05:40 -08007353 pr_err("socinfo_init() failed!\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007354}
7355
7356static void __init msm7x30_init_early(void)
7357{
7358 msm7x30_allocate_memory_regions();
Daniel Walker8d747cd2010-02-25 11:37:43 -08007359}
7360
Steve Mucklef132c6c2012-06-06 18:30:57 -07007361static void __init msm7x30_fixup(struct tag *tags, char **cmdline,
7362 struct meminfo *mi)
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307363{
7364 for (; tags->hdr.size; tags = tag_next(tags)) {
7365 if (tags->hdr.tag == ATAG_MEM && tags->u.mem.start ==
7366 DDR1_BANK_BASE) {
7367 ebi1_phys_offset = DDR1_BANK_BASE;
7368 phys_add = DDR1_BANK_BASE;
7369 break;
7370 }
7371 }
Daniel Walker8d747cd2010-02-25 11:37:43 -08007372}
7373
7374MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
Nicolas Pitref631dd42011-07-05 22:38:14 -04007375 .atag_offset = 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007376 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007377 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007378 .init_irq = msm7x30_init_irq,
7379 .init_machine = msm7x30_init,
7380 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007381 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307382 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307383 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007384MACHINE_END
7385
7386MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
Nicolas Pitref631dd42011-07-05 22:38:14 -04007387 .atag_offset = 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007388 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007389 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007390 .init_irq = msm7x30_init_irq,
7391 .init_machine = msm7x30_init,
7392 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007393 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307394 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307395 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007396MACHINE_END
7397
7398MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
Nicolas Pitref631dd42011-07-05 22:38:14 -04007399 .atag_offset = 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007400 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007401 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007402 .init_irq = msm7x30_init_irq,
7403 .init_machine = msm7x30_init,
7404 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007405 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307406 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307407 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007408MACHINE_END
7409
7410MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007411 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007412 .map_io = msm7x30_map_io,
7413 .reserve = msm7x30_reserve,
7414 .init_irq = msm7x30_init_irq,
7415 .init_machine = msm7x30_init,
7416 .timer = &msm_timer,
7417 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307418 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307419 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007420MACHINE_END
7421
7422MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007423 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007424 .map_io = msm7x30_map_io,
7425 .reserve = msm7x30_reserve,
7426 .init_irq = msm7x30_init_irq,
7427 .init_machine = msm7x30_init,
7428 .timer = &msm_timer,
7429 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307430 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307431 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007432MACHINE_END
7433MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007434 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007435 .map_io = msm7x30_map_io,
7436 .reserve = msm7x30_reserve,
7437 .init_irq = msm7x30_init_irq,
7438 .init_machine = msm7x30_init,
7439 .timer = &msm_timer,
7440 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307441 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307442 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007443MACHINE_END
7444MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007445 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007446 .map_io = msm7x30_map_io,
7447 .reserve = msm7x30_reserve,
7448 .init_irq = msm7x30_init_irq,
7449 .init_machine = msm7x30_init,
7450 .timer = &msm_timer,
7451 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307452 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307453 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007454MACHINE_END