blob: ea12570ea6ebf2481ffa6e23c58fbadedd98f1b3 [file] [log] [blame]
Manu Gautam5143b252012-01-05 19:25:23 -08001/* Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
Daniel Walker8d747cd2010-02-25 11:37:43 -08002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
Daniel Walker8d747cd2010-02-25 11:37:43 -080012 */
13
14#include <linux/kernel.h>
15#include <linux/irq.h>
16#include <linux/gpio.h>
17#include <linux/platform_device.h>
18#include <linux/delay.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070019#include <linux/bootmem.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080020#include <linux/io.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070021#ifdef CONFIG_SPI_QSD
22#include <linux/spi/spi.h>
23#endif
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +053024#include <linux/msm_ssbi.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070025#include <linux/mfd/pmic8058.h>
Anirudh Ghayalc2019332011-11-12 06:29:10 +053026#include <linux/leds.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070027#include <linux/mfd/marimba.h>
28#include <linux/i2c.h>
29#include <linux/input.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080030#include <linux/smsc911x.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070031#include <linux/ofn_atlab.h>
32#include <linux/power_supply.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070033#include <linux/i2c/isa1200.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070034#include <linux/i2c/tsc2007.h>
35#include <linux/input/kp_flip_switch.h>
36#include <linux/leds-pmic8058.h>
37#include <linux/input/cy8c_ts.h>
38#include <linux/msm_adc.h>
39#include <linux/dma-mapping.h>
Justin Paupore3f40f342011-08-10 18:52:16 -070040#include <linux/regulator/consumer.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080041
42#include <asm/mach-types.h>
43#include <asm/mach/arch.h>
44#include <asm/setup.h>
45
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046#include <mach/mpp.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080047#include <mach/board.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070048#include <mach/camera.h>
49#include <mach/memory.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080050#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051#include <mach/msm_hsusb.h>
52#include <mach/rpc_hsusb.h>
53#include <mach/msm_spi.h>
54#include <mach/qdsp5v2/msm_lpa.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080055#include <mach/dma.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056#include <linux/android_pmem.h>
57#include <linux/input/msm_ts.h>
58#include <mach/pmic.h>
59#include <mach/rpc_pmapp.h>
60#include <mach/qdsp5v2/aux_pcm.h>
61#include <mach/qdsp5v2/mi2s.h>
62#include <mach/qdsp5v2/audio_dev_ctl.h>
63#include <mach/msm_battery.h>
64#include <mach/rpc_server_handset.h>
65#include <mach/msm_tsif.h>
66#include <mach/socinfo.h>
67#include <mach/msm_memtypes.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070068#include <linux/cyttsp-qc.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080069
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070070#include <asm/mach/mmc.h>
71#include <asm/mach/flash.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080072#include <mach/vreg.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070073#include <linux/platform_data/qcom_crypto_device.h>
74
Daniel Walker8d747cd2010-02-25 11:37:43 -080075#include "devices.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076#include "timer.h"
77#ifdef CONFIG_USB_G_ANDROID
78#include <linux/usb/android.h>
79#include <mach/usbdiag.h>
80#endif
Matt Wagantall7cca4642012-02-01 16:43:24 -080081#include "pm.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -060082#include "pm-boot.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070083#include "spm.h"
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070084#include "acpuclock.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070085#include <mach/dal_axi.h>
86#include <mach/msm_serial_hs.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070087#include <mach/qdsp5v2/mi2s.h>
88#include <mach/qdsp5v2/audio_dev_ctl.h>
89#include <mach/sdio_al.h>
90#include "smd_private.h"
91#include <linux/bma150.h>
Daniel Walker8d747cd2010-02-25 11:37:43 -080092
Justin Paupore637a25d2011-07-14 17:11:04 -070093#include "board-msm7x30-regulator.h"
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +053094#include "pm.h"
Daniel Walker90e37c52010-05-12 14:24:15 -070095
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070096#define MSM_PMEM_SF_SIZE 0x1700000
97#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Mayank Chopraaed3b4b2012-02-29 11:54:18 +053098#define MSM_FB_PRIM_BUF_SIZE (864 * 480 * 4 * 3) /* 4bpp * 3 Pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070099#else
Mayank Chopraaed3b4b2012-02-29 11:54:18 +0530100#define MSM_FB_PRIM_BUF_SIZE (864 * 480 * 4 * 2) /* 4bpp * 2 Pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700101#endif
Alhad Purnapatrec55856c2012-02-28 13:24:57 -0800102/*
103 * Reserve space for double buffered full screen
104 * res V4L2 video overlay - i.e. 1280x720x1.5x2
105 */
106#define MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE 2764800
Mayank Chopraaed3b4b2012-02-29 11:54:18 +0530107
Jeevan Shrirama7d44142012-06-14 15:55:25 +0530108#ifdef CONFIG_FB_MSM_HDMI_ADV7520_PANEL
Mayank Chopraaed3b4b2012-02-29 11:54:18 +0530109#define MSM_FB_EXT_BUF_SIZE (1280 * 720 * 2 * 1) /* 2 bpp x 1 page */
110#else
111#define MSM_FB_EXT_BUF_SIZE 0
112#endif
113
114#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
115/* width x height x 3 bpp x 2 frame buffer */
116#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((864 * 480 * 3 * 2), 4096)
117#else
118#define MSM_FB_OVERLAY0_WRITEBACK_SIZE 0
119#endif
120
121#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE, 4096)
122
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700123#define MSM_PMEM_ADSP_SIZE 0x1E00000
124#define MSM_FLUID_PMEM_ADSP_SIZE 0x2800000
125#define PMEM_KERNEL_EBI0_SIZE 0x600000
126#define MSM_PMEM_AUDIO_SIZE 0x200000
Daniel Walker90e37c52010-05-12 14:24:15 -0700127
Chintan Pandya03b698a2012-06-28 19:03:09 +0530128#ifdef CONFIG_ION_MSM
129static struct platform_device ion_dev;
130#define MSM_ION_AUDIO_SIZE (MSM_PMEM_AUDIO_SIZE + PMEM_KERNEL_EBI0_SIZE)
131#define MSM_ION_SF_SIZE MSM_PMEM_SF_SIZE
132#define MSM_ION_HEAP_NUM 4
133#endif
134
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700135#define PMIC_GPIO_INT 27
136#define PMIC_VREG_WLAN_LEVEL 2900
137#define PMIC_GPIO_SD_DET 36
138#define PMIC_GPIO_SDC4_EN_N 17 /* PMIC GPIO Number 18 */
139#define PMIC_GPIO_HDMI_5V_EN_V3 32 /* PMIC GPIO for V3 H/W */
140#define PMIC_GPIO_HDMI_5V_EN_V2 39 /* PMIC GPIO for V2 H/W */
141
142#define ADV7520_I2C_ADDR 0x39
143
144#define FPGA_SDCC_STATUS 0x8E0001A8
145
146#define FPGA_OPTNAV_GPIO_ADDR 0x8E000026
147#define OPTNAV_I2C_SLAVE_ADDR (0xB0 >> 1)
148#define OPTNAV_IRQ 20
149#define OPTNAV_CHIP_SELECT 19
Asutosh Das853bbcd2012-02-01 10:40:05 +0530150#define PMIC_GPIO_SDC4_PWR_EN_N 24 /* PMIC GPIO Number 25 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700151
152/* Macros assume PMIC GPIOs start at 0 */
153#define PM8058_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio + NR_GPIO_IRQS)
154#define PM8058_GPIO_SYS_TO_PM(sys_gpio) (sys_gpio - NR_GPIO_IRQS)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530155#define PM8058_MPP_BASE PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS)
156#define PM8058_MPP_PM_TO_SYS(pm_gpio) (pm_gpio + PM8058_MPP_BASE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700157
158#define PMIC_GPIO_FLASH_BOOST_ENABLE 15 /* PMIC GPIO Number 16 */
159#define PMIC_GPIO_HAP_ENABLE 16 /* PMIC GPIO Number 17 */
160
161#define PMIC_GPIO_WLAN_EXT_POR 22 /* PMIC GPIO NUMBER 23 */
162
163#define BMA150_GPIO_INT 1
164
165#define HAP_LVL_SHFT_MSM_GPIO 24
166
167#define PMIC_GPIO_QUICKVX_CLK 37 /* PMIC GPIO 38 */
168
169#define PM_FLIP_MPP 5 /* PMIC MPP 06 */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530170
Pankaj Kumarac69ee62012-01-26 00:21:56 +0530171#define DDR1_BANK_BASE 0X20000000
172#define DDR2_BANK_BASE 0X40000000
173
174static unsigned int phys_add = DDR2_BANK_BASE;
175unsigned long ebi1_phys_offset = DDR2_BANK_BASE;
176EXPORT_SYMBOL(ebi1_phys_offset);
177
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530178struct pm8xxx_gpio_init_info {
179 unsigned gpio;
180 struct pm_gpio config;
181};
182
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700183static int pm8058_gpios_init(void)
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100184{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700185 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700186
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530187 struct pm8xxx_gpio_init_info sdc4_en = {
188 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_EN_N),
189 {
190 .direction = PM_GPIO_DIR_OUT,
191 .pull = PM_GPIO_PULL_NO,
192 .vin_sel = PM8058_GPIO_VIN_L5,
193 .function = PM_GPIO_FUNC_NORMAL,
194 .inv_int_pol = 0,
195 .out_strength = PM_GPIO_STRENGTH_LOW,
196 .output_value = 0,
197 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700198 };
199
Asutosh Das853bbcd2012-02-01 10:40:05 +0530200 struct pm8xxx_gpio_init_info sdc4_pwr_en = {
201 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
202 {
203 .direction = PM_GPIO_DIR_OUT,
204 .pull = PM_GPIO_PULL_NO,
205 .vin_sel = PM8058_GPIO_VIN_L5,
206 .function = PM_GPIO_FUNC_NORMAL,
207 .inv_int_pol = 0,
208 .out_strength = PM_GPIO_STRENGTH_LOW,
209 .output_value = 0,
210 },
211 };
212
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530213 struct pm8xxx_gpio_init_info haptics_enable = {
214 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
215 {
216 .direction = PM_GPIO_DIR_OUT,
217 .pull = PM_GPIO_PULL_NO,
218 .out_strength = PM_GPIO_STRENGTH_HIGH,
219 .function = PM_GPIO_FUNC_NORMAL,
220 .inv_int_pol = 0,
221 .vin_sel = 2,
222 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
223 .output_value = 0,
224 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700225 };
226
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530227 struct pm8xxx_gpio_init_info hdmi_5V_en = {
228 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HDMI_5V_EN_V3),
229 {
230 .direction = PM_GPIO_DIR_OUT,
231 .pull = PM_GPIO_PULL_NO,
232 .vin_sel = PM8058_GPIO_VIN_VPH,
233 .function = PM_GPIO_FUNC_NORMAL,
234 .out_strength = PM_GPIO_STRENGTH_LOW,
235 .output_value = 0,
236 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700237 };
238
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530239 struct pm8xxx_gpio_init_info flash_boost_enable = {
240 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE),
241 {
242 .direction = PM_GPIO_DIR_OUT,
243 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
244 .output_value = 0,
245 .pull = PM_GPIO_PULL_NO,
246 .vin_sel = PM8058_GPIO_VIN_S3,
247 .out_strength = PM_GPIO_STRENGTH_HIGH,
248 .function = PM_GPIO_FUNC_2,
249 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700250 };
251
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530252 struct pm8xxx_gpio_init_info gpio23 = {
253 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_WLAN_EXT_POR),
254 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700255 .direction = PM_GPIO_DIR_OUT,
256 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
257 .output_value = 0,
258 .pull = PM_GPIO_PULL_NO,
259 .vin_sel = 2,
260 .out_strength = PM_GPIO_STRENGTH_LOW,
261 .function = PM_GPIO_FUNC_NORMAL,
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100262 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700263 };
264
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530265 struct pm8xxx_gpio_init_info sdcc_det = {
266 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1),
267 {
268 .direction = PM_GPIO_DIR_IN,
269 .pull = PM_GPIO_PULL_UP_1P5,
270 .vin_sel = 2,
271 .function = PM_GPIO_FUNC_NORMAL,
272 .inv_int_pol = 0,
273 },
274 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700275
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530276 if (machine_is_msm7x30_fluid())
277 sdcc_det.config.inv_int_pol = 1;
278
279 rc = pm8xxx_gpio_config(sdcc_det.gpio, &sdcc_det.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700280 if (rc) {
281 pr_err("%s PMIC_GPIO_SD_DET config failed\n", __func__);
282 return rc;
283 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700284
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530285 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
286 machine_is_msm7x30_fluid())
287 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V2;
288 else
289 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V3;
290
291 hdmi_5V_en.gpio = PM8058_GPIO_PM_TO_SYS(hdmi_5V_en.gpio);
292
293 rc = pm8xxx_gpio_config(hdmi_5V_en.gpio, &hdmi_5V_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700294 if (rc) {
295 pr_err("%s PMIC_GPIO_HDMI_5V_EN config failed\n", __func__);
296 return rc;
297 }
298
299 /* Deassert GPIO#23 (source for Ext_POR on WLAN-Volans) */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530300 rc = pm8xxx_gpio_config(gpio23.gpio, &gpio23.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700301 if (rc) {
302 pr_err("%s PMIC_GPIO_WLAN_EXT_POR config failed\n", __func__);
303 return rc;
304 }
305
306 if (machine_is_msm7x30_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530307 /* Haptics gpio */
308 rc = pm8xxx_gpio_config(haptics_enable.gpio,
309 &haptics_enable.config);
310 if (rc) {
311 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
312 haptics_enable.gpio);
313 return rc;
314 }
315 /* Flash boost gpio */
316 rc = pm8xxx_gpio_config(flash_boost_enable.gpio,
317 &flash_boost_enable.config);
318 if (rc) {
319 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
320 flash_boost_enable.gpio);
321 return rc;
322 }
323 /* SCD4 gpio */
324 rc = pm8xxx_gpio_config(sdc4_en.gpio, &sdc4_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700325 if (rc) {
326 pr_err("%s PMIC_GPIO_SDC4_EN_N config failed\n",
327 __func__);
328 return rc;
329 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530330 rc = gpio_request(sdc4_en.gpio, "sdc4_en");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700331 if (rc) {
332 pr_err("%s PMIC_GPIO_SDC4_EN_N gpio_request failed\n",
333 __func__);
334 return rc;
335 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530336 gpio_set_value_cansleep(sdc4_en.gpio, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700337 }
Asutosh Das853bbcd2012-02-01 10:40:05 +0530338 /* FFA -> gpio_25 controls vdd of sdcc4 */
339 else {
340 /* SCD4 gpio_25 */
341 rc = pm8xxx_gpio_config(sdc4_pwr_en.gpio, &sdc4_pwr_en.config);
342 if (rc) {
343 pr_err("%s PMIC_GPIO_SDC4_PWR_EN_N config failed: %d\n",
344 __func__, rc);
345 return rc;
346 }
347
348 rc = gpio_request(sdc4_pwr_en.gpio, "sdc4_pwr_en");
349 if (rc) {
350 pr_err("PMIC_GPIO_SDC4_PWR_EN_N gpio_req failed: %d\n",
351 rc);
352 return rc;
353 }
354 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700355
356 return 0;
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100357}
358
Justin Paupore637a25d2011-07-14 17:11:04 -0700359/* Regulator API support */
360
361#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
362static struct platform_device msm_proccomm_regulator_dev = {
363 .name = PROCCOMM_REGULATOR_DEV_NAME,
364 .id = -1,
365 .dev = {
366 .platform_data = &msm7x30_proccomm_regulator_data
367 }
368};
369#endif
370
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700371/*virtual key support */
372static ssize_t tma300_vkeys_show(struct kobject *kobj,
373 struct kobj_attribute *attr, char *buf)
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100374{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700375 return sprintf(buf,
376 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":50:842:80:100"
377 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":170:842:80:100"
378 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":290:842:80:100"
379 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":410:842:80:100"
380 "\n");
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100381}
382
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700383static struct kobj_attribute tma300_vkeys_attr = {
384 .attr = {
385 .mode = S_IRUGO,
386 },
387 .show = &tma300_vkeys_show,
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530388};
389
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700390static struct attribute *tma300_properties_attrs[] = {
391 &tma300_vkeys_attr.attr,
392 NULL
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530393};
394
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700395static struct attribute_group tma300_properties_attr_group = {
396 .attrs = tma300_properties_attrs,
397};
398
399static struct kobject *properties_kobj;
Justin Paupore3f40f342011-08-10 18:52:16 -0700400static struct regulator_bulk_data cyttsp_regs[] = {
401 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
402 { .supply = "ldo15", .min_uV = 3050000, .max_uV = 3100000 },
403};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700404
405#define CYTTSP_TS_GPIO_IRQ 150
406static int cyttsp_platform_init(struct i2c_client *client)
407{
408 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700409
Justin Paupore3f40f342011-08-10 18:52:16 -0700410 rc = regulator_bulk_get(NULL, ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700411
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700412 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700413 pr_err("%s: could not get regulators: %d\n", __func__, rc);
414 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700415 }
416
Justin Paupore3f40f342011-08-10 18:52:16 -0700417 rc = regulator_bulk_set_voltage(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
418
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700419 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700420 pr_err("%s: could not set regulator voltages: %d\n", __func__,
421 rc);
422 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700423 }
424
Justin Paupore3f40f342011-08-10 18:52:16 -0700425 rc = regulator_bulk_enable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700426
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700427 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700428 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
429 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700430 }
431
432 /* check this device active by reading first byte/register */
433 rc = i2c_smbus_read_byte_data(client, 0x01);
434 if (rc < 0) {
435 pr_err("%s: i2c sanity check failed\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -0700436 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700437 }
438
439 rc = gpio_tlmm_config(GPIO_CFG(CYTTSP_TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
440 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
441 if (rc) {
442 pr_err("%s: Could not configure gpio %d\n",
443 __func__, CYTTSP_TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -0700444 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700445 }
446
447 /* virtual keys */
448 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
449 properties_kobj = kobject_create_and_add("board_properties",
450 NULL);
451 if (properties_kobj)
452 rc = sysfs_create_group(properties_kobj,
453 &tma300_properties_attr_group);
454 if (!properties_kobj || rc)
455 pr_err("%s: failed to create board_properties\n",
456 __func__);
457
458 return CY_OK;
459
Justin Paupore3f40f342011-08-10 18:52:16 -0700460regs_disable:
461 regulator_bulk_disable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
462regs_free:
463 regulator_bulk_free(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
464out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700465 return rc;
466}
467
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530468/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
469static int cyttsp_platform_suspend(struct i2c_client *client)
470{
471 msleep(20);
472
473 return CY_OK;
474}
475
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700476static int cyttsp_platform_resume(struct i2c_client *client)
477{
478 /* add any special code to strobe a wakeup pin or chip reset */
479 mdelay(10);
480
481 return CY_OK;
482}
483
484static struct cyttsp_platform_data cyttsp_data = {
485 .fw_fname = "cyttsp_7630_fluid.hex",
486 .panel_maxx = 479,
487 .panel_maxy = 799,
488 .disp_maxx = 469,
489 .disp_maxy = 799,
490 .disp_minx = 10,
491 .disp_miny = 0,
492 .flags = 0,
493 .gen = CY_GEN3, /* or */
494 .use_st = CY_USE_ST,
495 .use_mt = CY_USE_MT,
496 .use_hndshk = CY_SEND_HNDSHK,
497 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +0530498 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700499 .use_gestures = CY_USE_GESTURES,
500 /* activate up to 4 groups
501 * and set active distance
502 */
503 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
504 CY_GEST_GRP3 | CY_GEST_GRP4 |
505 CY_ACT_DIST,
506 /* change act_intrvl to customize the Active power state
507 * scanning/processing refresh interval for Operating mode
508 */
509 .act_intrvl = CY_ACT_INTRVL_DFLT,
510 /* change tch_tmout to customize the touch timeout for the
511 * Active power state for Operating mode
512 */
513 .tch_tmout = CY_TCH_TMOUT_DFLT,
514 /* change lp_intrvl to customize the Low Power power state
515 * scanning/processing refresh interval for Operating mode
516 */
517 .lp_intrvl = CY_LP_INTRVL_DFLT,
518 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530519 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700520 .init = cyttsp_platform_init,
521 .sleep_gpio = -1,
522 .resout_gpio = -1,
523 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
Mohan Pallaka49c37d62011-08-01 11:52:00 +0530524 .correct_fw_ver = 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700525};
526
527static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
528{
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530529 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700530 .direction = PM_GPIO_DIR_OUT,
531 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
532 .output_value = 0,
533 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530534 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700535 .out_strength = PM_GPIO_STRENGTH_HIGH,
536 .function = PM_GPIO_FUNC_2,
537 };
538 int rc = -EINVAL;
539 int id, mode, max_mA;
540
541 id = mode = max_mA = 0;
542 switch (ch) {
543 case 0:
544 case 1:
545 case 2:
546 if (on) {
547 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530548 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
549 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700550 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530551 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700552 __func__, id, rc);
553 }
554 break;
555
556 case 3:
557 id = PM_PWM_LED_KPD;
558 mode = PM_PWM_CONF_DTEST3;
559 max_mA = 200;
560 break;
561
562 case 4:
563 id = PM_PWM_LED_0;
564 mode = PM_PWM_CONF_PWM1;
565 max_mA = 40;
566 break;
567
568 case 5:
569 id = PM_PWM_LED_2;
570 mode = PM_PWM_CONF_PWM2;
571 max_mA = 40;
572 break;
573
574 case 6:
575 id = PM_PWM_LED_FLASH;
576 mode = PM_PWM_CONF_DTEST3;
577 max_mA = 200;
578 break;
579
580 default:
581 break;
582 }
583
584 if (ch >= 3 && ch <= 6) {
585 if (!on) {
586 mode = PM_PWM_CONF_NONE;
587 max_mA = 0;
588 }
589 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
590 if (rc)
591 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
592 __func__, ch, rc);
593 }
594
595 return rc;
596}
597
598static int pm8058_pwm_enable(struct pwm_device *pwm, int ch, int on)
599{
600 int rc;
601
602 switch (ch) {
603 case 7:
604 rc = pm8058_pwm_set_dtest(pwm, on);
605 if (rc)
606 pr_err("%s: pwm_set_dtest(%d): rc=%d\n",
607 __func__, on, rc);
608 break;
609 default:
610 rc = -EINVAL;
611 break;
612 }
613 return rc;
614}
615
616static const unsigned int fluid_keymap[] = {
617 KEY(0, 0, KEY_7),
618 KEY(0, 1, KEY_ENTER),
619 KEY(0, 2, KEY_UP),
620 /* drop (0,3) as it always shows up in pair with(0,2) */
621 KEY(0, 4, KEY_DOWN),
622
623 KEY(1, 0, KEY_CAMERA_SNAPSHOT),
624 KEY(1, 1, KEY_SELECT),
625 KEY(1, 2, KEY_1),
626 KEY(1, 3, KEY_VOLUMEUP),
627 KEY(1, 4, KEY_VOLUMEDOWN),
628};
629
630static const unsigned int surf_keymap[] = {
631 KEY(0, 0, KEY_7),
632 KEY(0, 1, KEY_DOWN),
633 KEY(0, 2, KEY_UP),
634 KEY(0, 3, KEY_RIGHT),
635 KEY(0, 4, KEY_ENTER),
636 KEY(0, 5, KEY_L),
637 KEY(0, 6, KEY_BACK),
638 KEY(0, 7, KEY_M),
639
640 KEY(1, 0, KEY_LEFT),
641 KEY(1, 1, KEY_SEND),
642 KEY(1, 2, KEY_1),
643 KEY(1, 3, KEY_4),
644 KEY(1, 4, KEY_CLEAR),
645 KEY(1, 5, KEY_MSDOS),
646 KEY(1, 6, KEY_SPACE),
647 KEY(1, 7, KEY_COMMA),
648
649 KEY(2, 0, KEY_6),
650 KEY(2, 1, KEY_5),
651 KEY(2, 2, KEY_8),
652 KEY(2, 3, KEY_3),
653 KEY(2, 4, KEY_NUMERIC_STAR),
654 KEY(2, 5, KEY_UP),
655 KEY(2, 6, KEY_DOWN), /* SYN */
656 KEY(2, 7, KEY_LEFTSHIFT),
657
658 KEY(3, 0, KEY_9),
659 KEY(3, 1, KEY_NUMERIC_POUND),
660 KEY(3, 2, KEY_0),
661 KEY(3, 3, KEY_2),
662 KEY(3, 4, KEY_SLEEP),
663 KEY(3, 5, KEY_F1),
664 KEY(3, 6, KEY_F2),
665 KEY(3, 7, KEY_F3),
666
667 KEY(4, 0, KEY_BACK),
668 KEY(4, 1, KEY_HOME),
669 KEY(4, 2, KEY_MENU),
670 KEY(4, 3, KEY_VOLUMEUP),
671 KEY(4, 4, KEY_VOLUMEDOWN),
672 KEY(4, 5, KEY_F4),
673 KEY(4, 6, KEY_F5),
674 KEY(4, 7, KEY_F6),
675
676 KEY(5, 0, KEY_R),
677 KEY(5, 1, KEY_T),
678 KEY(5, 2, KEY_Y),
679 KEY(5, 3, KEY_LEFTALT),
680 KEY(5, 4, KEY_KPENTER),
681 KEY(5, 5, KEY_Q),
682 KEY(5, 6, KEY_W),
683 KEY(5, 7, KEY_E),
684
685 KEY(6, 0, KEY_F),
686 KEY(6, 1, KEY_G),
687 KEY(6, 2, KEY_H),
688 KEY(6, 3, KEY_CAPSLOCK),
689 KEY(6, 4, KEY_PAGEUP),
690 KEY(6, 5, KEY_A),
691 KEY(6, 6, KEY_S),
692 KEY(6, 7, KEY_D),
693
694 KEY(7, 0, KEY_V),
695 KEY(7, 1, KEY_B),
696 KEY(7, 2, KEY_N),
697 KEY(7, 3, KEY_MENU), /* REVISIT - SYM */
698 KEY(7, 4, KEY_PAGEDOWN),
699 KEY(7, 5, KEY_Z),
700 KEY(7, 6, KEY_X),
701 KEY(7, 7, KEY_C),
702
703 KEY(8, 0, KEY_P),
704 KEY(8, 1, KEY_J),
705 KEY(8, 2, KEY_K),
706 KEY(8, 3, KEY_INSERT),
707 KEY(8, 4, KEY_LINEFEED),
708 KEY(8, 5, KEY_U),
709 KEY(8, 6, KEY_I),
710 KEY(8, 7, KEY_O),
711
712 KEY(9, 0, KEY_4),
713 KEY(9, 1, KEY_5),
714 KEY(9, 2, KEY_6),
715 KEY(9, 3, KEY_7),
716 KEY(9, 4, KEY_8),
717 KEY(9, 5, KEY_1),
718 KEY(9, 6, KEY_2),
719 KEY(9, 7, KEY_3),
720
721 KEY(10, 0, KEY_F7),
722 KEY(10, 1, KEY_F8),
723 KEY(10, 2, KEY_F9),
724 KEY(10, 3, KEY_F10),
725 KEY(10, 4, KEY_FN),
726 KEY(10, 5, KEY_9),
727 KEY(10, 6, KEY_0),
728 KEY(10, 7, KEY_DOT),
729
730 KEY(11, 0, KEY_LEFTCTRL),
731 KEY(11, 1, KEY_F11), /* START */
732 KEY(11, 2, KEY_ENTER),
733 KEY(11, 3, KEY_SEARCH),
734 KEY(11, 4, KEY_DELETE),
735 KEY(11, 5, KEY_RIGHT),
736 KEY(11, 6, KEY_LEFT),
737 KEY(11, 7, KEY_RIGHTSHIFT),
738};
739
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700740static struct matrix_keymap_data surf_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530741 .keymap_size = ARRAY_SIZE(surf_keymap),
742 .keymap = surf_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700743};
744
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530745static struct pm8xxx_keypad_platform_data surf_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700746 .input_name = "surf_keypad",
747 .input_phys_device = "surf_keypad/input0",
748 .num_rows = 12,
749 .num_cols = 8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530750 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
751 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
752 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700753 .scan_delay_ms = 32,
754 .row_hold_ns = 91500,
755 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530756 .keymap_data = &surf_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700757};
758
759static struct matrix_keymap_data fluid_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530760 .keymap_size = ARRAY_SIZE(fluid_keymap),
761 .keymap = fluid_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700762};
763
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530764static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700765 .input_name = "fluid-keypad",
766 .input_phys_device = "fluid-keypad/input0",
767 .num_rows = 5,
768 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530769 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
770 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
771 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700772 .scan_delay_ms = 32,
773 .row_hold_ns = 91500,
774 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530775 .keymap_data = &fluid_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700776};
777
778static struct pm8058_pwm_pdata pm8058_pwm_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530779 .config = pm8058_pwm_config,
780 .enable = pm8058_pwm_enable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700781};
782
783static struct pmic8058_led pmic8058_ffa_leds[] = {
784 [0] = {
785 .name = "keyboard-backlight",
786 .max_brightness = 15,
787 .id = PMIC8058_ID_LED_KB_LIGHT,
Dima Zavinba5499e2011-01-10 11:00:30 -0800788 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700789};
790
791static struct pmic8058_leds_platform_data pm8058_ffa_leds_data = {
792 .num_leds = ARRAY_SIZE(pmic8058_ffa_leds),
793 .leds = pmic8058_ffa_leds,
794};
795
796static struct pmic8058_led pmic8058_surf_leds[] = {
797 [0] = {
798 .name = "keyboard-backlight",
799 .max_brightness = 15,
800 .id = PMIC8058_ID_LED_KB_LIGHT,
Dima Zavinba5499e2011-01-10 11:00:30 -0800801 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700802 [1] = {
803 .name = "voice:red",
804 .max_brightness = 20,
805 .id = PMIC8058_ID_LED_0,
Dima Zavinba5499e2011-01-10 11:00:30 -0800806 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700807 [2] = {
808 .name = "wlan:green",
809 .max_brightness = 20,
810 .id = PMIC8058_ID_LED_2,
811 },
812};
813
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700814static struct pmic8058_leds_platform_data pm8058_surf_leds_data = {
815 .num_leds = ARRAY_SIZE(pmic8058_surf_leds),
816 .leds = pmic8058_surf_leds,
817};
818
819static struct pmic8058_led pmic8058_fluid_leds[] = {
820 [0] = {
821 .name = "keyboard-backlight",
822 .max_brightness = 15,
823 .id = PMIC8058_ID_LED_KB_LIGHT,
824 },
825 [1] = {
826 .name = "flash:led_0",
827 .max_brightness = 15,
828 .id = PMIC8058_ID_FLASH_LED_0,
829 },
830 [2] = {
831 .name = "flash:led_1",
832 .max_brightness = 15,
833 .id = PMIC8058_ID_FLASH_LED_1,
834 },
835};
836
837static struct pmic8058_leds_platform_data pm8058_fluid_leds_data = {
838 .num_leds = ARRAY_SIZE(pmic8058_fluid_leds),
839 .leds = pmic8058_fluid_leds,
840};
841
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530842static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata = {
843 .irq_base = PMIC8058_IRQ_BASE,
844 .devirq = MSM_GPIO_TO_INT(PMIC_GPIO_INT),
845 .irq_trigger_flag = IRQF_TRIGGER_LOW,
846};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700847
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530848static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata = {
849 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
850};
851
852static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata = {
853 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
854};
855
856static struct pm8058_platform_data pm8058_7x30_data = {
857 .irq_pdata = &pm8xxx_irq_pdata,
858 .gpio_pdata = &pm8xxx_gpio_pdata,
859 .mpp_pdata = &pm8xxx_mpp_pdata,
860 .pwm_pdata = &pm8058_pwm_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700861};
862
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530863#ifdef CONFIG_MSM_SSBI
864static struct msm_ssbi_platform_data msm7x30_ssbi_pm8058_pdata = {
Kenneth Heitke48952912012-01-12 14:02:06 -0700865 .rsl_id = "D:PMIC_SSBI",
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530866 .controller_type = MSM_SBI_CTRL_SSBI2,
867 .slave = {
868 .name = "pm8058-core",
869 .platform_data = &pm8058_7x30_data,
870 },
871};
872#endif
873
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700874static struct i2c_board_info cy8info[] __initdata = {
875 {
876 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
877 .platform_data = &cyttsp_data,
878#ifndef CY_USE_TIMER
879 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
880#endif /* CY_USE_TIMER */
881 },
882};
883
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700884#ifdef CONFIG_MSM_CAMERA_V4L2
885static struct msm_camera_device_platform_data msm_camera_csi_device_data[] = {
886 {
887 .csid_core = 0,
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700888 .is_vpe = 1,
889 .ioclk = {
890 .vfe_clk_rate = 153600000,
891 },
892 },
Sreesudhan Ramakrish Ramkumar66deac32012-04-05 10:15:38 -0700893 {
894 .csid_core = 0,
895 .is_vpe = 1,
896 .ioclk = {
897 .vfe_clk_rate = 153600000,
898 },
899 },
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700900};
901
902static struct camera_vreg_t msm_7x30_back_cam_vreg[] = {
903 {"gp2", REG_LDO, 2600000, 2600000, -1},
904 {"lvsw1", REG_VS, 0, 0, 0},
905};
906
907static uint32_t camera_off_gpio_table[] = {
908 /* parallel CAMERA interfaces */
909 /* RST */
910 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
911 /* DAT2 */
912 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
913 /* DAT3 */
914 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
915 /* DAT4 */
916 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
917 /* DAT5 */
918 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
919 /* DAT6 */
920 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
921 /* DAT7 */
922 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
923 /* DAT8 */
924 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
925 /* DAT9 */
926 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
927 /* DAT10 */
928 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
929 /* DAT11 */
930 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
931 /* PCLK */
932 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
933 /* HSYNC_IN */
934 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
935 /* VSYNC_IN */
936 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
937 /* MCLK */
938 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
939};
940
941static uint32_t camera_on_gpio_table[] = {
942 /* parallel CAMERA interfaces */
943 /* RST */
944 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
945 /* DAT2 */
946 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
947 /* DAT3 */
948 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
949 /* DAT4 */
950 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
951 /* DAT5 */
952 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
953 /* DAT6 */
954 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
955 /* DAT7 */
956 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
957 /* DAT8 */
958 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
959 /* DAT9 */
960 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
961 /* DAT10 */
962 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
963 /* DAT11 */
964 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
965 /* PCLK */
966 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
967 /* HSYNC_IN */
968 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
969 /* VSYNC_IN */
970 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
971 /* MCLK */
972 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
973};
974
975static struct gpio msm7x30_back_cam_gpio[] = {
976 {0, GPIOF_DIR_OUT, "CAM_RESET"},
977};
978
979static struct msm_gpio_set_tbl msm7x30_back_cam_gpio_set_tbl[] = {
980 {0, GPIOF_OUT_INIT_LOW, 1000},
981 {0, GPIOF_OUT_INIT_HIGH, 4000},
982};
983
984static struct msm_camera_gpio_conf msm_7x30_back_cam_gpio_conf = {
985 .cam_gpio_req_tbl = msm7x30_back_cam_gpio,
986 .cam_gpio_req_tbl_size = ARRAY_SIZE(msm7x30_back_cam_gpio),
987 .cam_gpio_set_tbl = msm7x30_back_cam_gpio_set_tbl,
988 .cam_gpio_set_tbl_size = ARRAY_SIZE(msm7x30_back_cam_gpio_set_tbl),
989 .camera_off_table = camera_off_gpio_table,
990 .camera_off_table_size = ARRAY_SIZE(camera_off_gpio_table),
991 .camera_on_table = camera_on_gpio_table,
992 .camera_on_table_size = ARRAY_SIZE(camera_on_gpio_table),
993 .gpio_no_mux = 1,
994};
995
996static struct msm_camera_sensor_flash_data flash_vx6953 = {
997 .flash_type = MSM_CAMERA_FLASH_NONE,
998};
999
1000static struct msm_camera_sensor_platform_info sensor_board_info_vx6953 = {
1001 .mount_angle = 0,
1002 .cam_vreg = msm_7x30_back_cam_vreg,
1003 .num_vreg = ARRAY_SIZE(msm_7x30_back_cam_vreg),
1004 .gpio_conf = &msm_7x30_back_cam_gpio_conf,
1005};
1006
1007static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1008 .sensor_name = "vx6953",
1009 .pdata = &msm_camera_csi_device_data[0],
1010 .flash_data = &flash_vx6953,
1011 .sensor_platform_info = &sensor_board_info_vx6953,
1012 .csi_if = 1,
1013 .camera_type = BACK_CAMERA_2D,
1014};
1015
Kevin Chan94b4c832012-03-02 21:27:16 -08001016static struct platform_device msm_camera_server = {
1017 .name = "msm_cam_server",
1018 .id = 0,
1019};
1020
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001021void __init msm7x30_init_cam(void)
1022{
Kevin Chan94b4c832012-03-02 21:27:16 -08001023 platform_device_register(&msm_camera_server);
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001024 platform_device_register(&msm_device_csic0);
1025 platform_device_register(&msm_device_vfe);
1026 platform_device_register(&msm_device_vpe);
1027}
1028
1029#ifdef CONFIG_I2C
1030static struct i2c_board_info msm_camera_boardinfo[] = {
1031 {
1032 I2C_BOARD_INFO("vx6953", 0x20),
1033 .platform_data = &msm_camera_sensor_vx6953_data,
1034 },
1035};
1036#endif
1037#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001038static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
1039#ifdef CONFIG_MT9D112
1040 {
1041 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
Dima Zavinba5499e2011-01-10 11:00:30 -08001042 },
1043#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001044#ifdef CONFIG_WEBCAM_OV9726
1045 {
1046 I2C_BOARD_INFO("ov9726", 0x10),
1047 },
1048#endif
1049#ifdef CONFIG_S5K3E2FX
1050 {
1051 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
1052 },
1053#endif
1054#ifdef CONFIG_MT9P012
1055 {
1056 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
1057 },
1058#endif
1059#ifdef CONFIG_VX6953
1060 {
1061 I2C_BOARD_INFO("vx6953", 0x20),
1062 },
1063#endif
1064#ifdef CONFIG_MT9E013
1065 {
1066 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
1067 },
1068#endif
1069#ifdef CONFIG_SN12M0PZ
1070 {
1071 I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1),
1072 },
1073#endif
1074#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
1075 {
1076 I2C_BOARD_INFO("mt9t013", 0x6C),
1077 },
1078#endif
1079
Dima Zavinba5499e2011-01-10 11:00:30 -08001080};
1081
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001082#ifdef CONFIG_MSM_CAMERA
1083#define CAM_STNDBY 143
1084static uint32_t camera_off_vcm_gpio_table[] = {
1085GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */
1086};
1087
1088static uint32_t camera_off_gpio_table[] = {
1089 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001090 /* RST */
1091 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1092 /* DAT2 */
1093 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1094 /* DAT3 */
1095 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1096 /* DAT4 */
1097 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1098 /* DAT5 */
1099 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1100 /* DAT6 */
1101 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1102 /* DAT7 */
1103 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1104 /* DAT8 */
1105 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1106 /* DAT9 */
1107 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1108 /* DAT10 */
1109 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1110 /* DAT11 */
1111 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1112 /* PCLK */
1113 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1114 /* HSYNC_IN */
1115 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1116 /* VSYNC_IN */
1117 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1118 /* MCLK */
1119 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001120};
1121
1122static uint32_t camera_on_vcm_gpio_table[] = {
1123GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */
1124};
1125
1126static uint32_t camera_on_gpio_table[] = {
1127 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001128 /* RST */
1129 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1130 /* DAT2 */
1131 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1132 /* DAT3 */
1133 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1134 /* DAT4 */
1135 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1136 /* DAT5 */
1137 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1138 /* DAT6 */
1139 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1140 /* DAT7 */
1141 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1142 /* DAT8 */
1143 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1144 /* DAT9 */
1145 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1146 /* DAT10 */
1147 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1148 /* DAT11 */
1149 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1150 /* PCLK */
1151 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1152 /* HSYNC_IN */
1153 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1154 /* VSYNC_IN */
1155 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1156 /* MCLK */
1157 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001158};
1159
1160static uint32_t camera_off_gpio_fluid_table[] = {
1161 /* FLUID: CAM_VGA_RST_N */
1162 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1163 /* FLUID: CAMIF_STANDBY */
1164 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1165};
1166
1167static uint32_t camera_on_gpio_fluid_table[] = {
1168 /* FLUID: CAM_VGA_RST_N */
1169 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1170 /* FLUID: CAMIF_STANDBY */
1171 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1172};
1173
1174static void config_gpio_table(uint32_t *table, int len)
1175{
1176 int n, rc;
1177 for (n = 0; n < len; n++) {
1178 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
1179 if (rc) {
1180 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
1181 __func__, table[n], rc);
1182 break;
1183 }
1184 }
1185}
1186static int config_camera_on_gpios(void)
1187{
1188 config_gpio_table(camera_on_gpio_table,
1189 ARRAY_SIZE(camera_on_gpio_table));
1190
1191 if (adie_get_detected_codec_type() != TIMPANI_ID)
1192 /* GPIO1 is shared also used in Timpani RF card so
1193 only configure it for non-Timpani RF card */
1194 config_gpio_table(camera_on_vcm_gpio_table,
1195 ARRAY_SIZE(camera_on_vcm_gpio_table));
1196
1197 if (machine_is_msm7x30_fluid()) {
1198 config_gpio_table(camera_on_gpio_fluid_table,
1199 ARRAY_SIZE(camera_on_gpio_fluid_table));
1200 /* FLUID: turn on 5V booster */
1201 gpio_set_value(
1202 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 1);
1203 /* FLUID: drive high to put secondary sensor to STANDBY */
1204 gpio_set_value(CAM_STNDBY, 1);
1205 }
1206 return 0;
1207}
1208
1209static void config_camera_off_gpios(void)
1210{
1211 config_gpio_table(camera_off_gpio_table,
1212 ARRAY_SIZE(camera_off_gpio_table));
1213
1214 if (adie_get_detected_codec_type() != TIMPANI_ID)
1215 /* GPIO1 is shared also used in Timpani RF card so
1216 only configure it for non-Timpani RF card */
1217 config_gpio_table(camera_off_vcm_gpio_table,
1218 ARRAY_SIZE(camera_off_vcm_gpio_table));
1219
1220 if (machine_is_msm7x30_fluid()) {
1221 config_gpio_table(camera_off_gpio_fluid_table,
1222 ARRAY_SIZE(camera_off_gpio_fluid_table));
1223 /* FLUID: turn off 5V booster */
1224 gpio_set_value(
1225 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 0);
1226 }
1227}
1228
1229struct resource msm_camera_resources[] = {
1230 {
1231 .start = 0xA6000000,
1232 .end = 0xA6000000 + SZ_1M - 1,
1233 .flags = IORESOURCE_MEM,
1234 },
1235 {
1236 .start = INT_VFE,
1237 .end = INT_VFE,
1238 .flags = IORESOURCE_IRQ,
1239 },
1240 {
1241 .flags = IORESOURCE_DMA,
1242 }
1243};
1244
1245struct msm_camera_device_platform_data msm_camera_device_data = {
1246 .camera_gpio_on = config_camera_on_gpios,
1247 .camera_gpio_off = config_camera_off_gpios,
1248 .ioext.camifpadphy = 0xAB000000,
1249 .ioext.camifpadsz = 0x00000400,
1250 .ioext.csiphy = 0xA6100000,
1251 .ioext.csisz = 0x00000400,
1252 .ioext.csiirq = INT_CSI,
1253 .ioclk.mclk_clk_rate = 24000000,
1254 .ioclk.vfe_clk_rate = 147456000,
1255};
1256
1257static struct msm_camera_sensor_flash_src msm_flash_src_pwm = {
1258 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PWM,
1259 ._fsrc.pwm_src.freq = 1000,
1260 ._fsrc.pwm_src.max_load = 300,
1261 ._fsrc.pwm_src.low_load = 30,
1262 ._fsrc.pwm_src.high_load = 100,
1263 ._fsrc.pwm_src.channel = 7,
1264};
1265
1266#ifdef CONFIG_MT9D112
1267static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1268 .flash_type = MSM_CAMERA_FLASH_LED,
1269 .flash_src = &msm_flash_src_pwm
1270};
1271
1272static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1273 .sensor_name = "mt9d112",
1274 .sensor_reset = 0,
1275 .sensor_pwd = 85,
1276 .vcm_pwd = 1,
1277 .vcm_enable = 0,
1278 .pdata = &msm_camera_device_data,
1279 .resource = msm_camera_resources,
1280 .num_resources = ARRAY_SIZE(msm_camera_resources),
1281 .flash_data = &flash_mt9d112,
1282 .csi_if = 0
1283};
1284
1285static struct platform_device msm_camera_sensor_mt9d112 = {
1286 .name = "msm_camera_mt9d112",
1287 .dev = {
1288 .platform_data = &msm_camera_sensor_mt9d112_data,
1289 },
1290};
1291#endif
1292
1293#ifdef CONFIG_WEBCAM_OV9726
1294
1295static struct msm_camera_sensor_platform_info ov9726_sensor_7630_info = {
1296 .mount_angle = 90
1297};
1298
1299static struct msm_camera_sensor_flash_data flash_ov9726 = {
1300 .flash_type = MSM_CAMERA_FLASH_LED,
1301 .flash_src = &msm_flash_src_pwm
1302};
1303static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
1304 .sensor_name = "ov9726",
1305 .sensor_reset = 0,
1306 .sensor_pwd = 85,
1307 .vcm_pwd = 1,
1308 .vcm_enable = 0,
1309 .pdata = &msm_camera_device_data,
1310 .resource = msm_camera_resources,
1311 .num_resources = ARRAY_SIZE(msm_camera_resources),
1312 .flash_data = &flash_ov9726,
1313 .sensor_platform_info = &ov9726_sensor_7630_info,
1314 .csi_if = 1
1315};
1316struct platform_device msm_camera_sensor_ov9726 = {
1317 .name = "msm_camera_ov9726",
1318 .dev = {
1319 .platform_data = &msm_camera_sensor_ov9726_data,
1320 },
1321};
1322#endif
1323
1324#ifdef CONFIG_S5K3E2FX
1325static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1326 .flash_type = MSM_CAMERA_FLASH_LED,
1327 .flash_src = &msm_flash_src_pwm,
1328};
1329
1330static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1331 .sensor_name = "s5k3e2fx",
1332 .sensor_reset = 0,
1333 .sensor_pwd = 85,
1334 .vcm_pwd = 1,
1335 .vcm_enable = 0,
1336 .pdata = &msm_camera_device_data,
1337 .resource = msm_camera_resources,
1338 .num_resources = ARRAY_SIZE(msm_camera_resources),
1339 .flash_data = &flash_s5k3e2fx,
1340 .csi_if = 0
1341};
1342
1343static struct platform_device msm_camera_sensor_s5k3e2fx = {
1344 .name = "msm_camera_s5k3e2fx",
1345 .dev = {
1346 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1347 },
1348};
1349#endif
1350
1351#ifdef CONFIG_MT9P012
1352static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1353 .flash_type = MSM_CAMERA_FLASH_LED,
1354 .flash_src = &msm_flash_src_pwm
1355};
1356
1357static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1358 .sensor_name = "mt9p012",
1359 .sensor_reset = 0,
1360 .sensor_pwd = 85,
1361 .vcm_pwd = 1,
1362 .vcm_enable = 1,
1363 .pdata = &msm_camera_device_data,
1364 .resource = msm_camera_resources,
1365 .num_resources = ARRAY_SIZE(msm_camera_resources),
1366 .flash_data = &flash_mt9p012,
1367 .csi_if = 0
1368};
1369
1370static struct platform_device msm_camera_sensor_mt9p012 = {
1371 .name = "msm_camera_mt9p012",
1372 .dev = {
1373 .platform_data = &msm_camera_sensor_mt9p012_data,
1374 },
1375};
1376#endif
1377
1378#ifdef CONFIG_MT9E013
1379static struct msm_camera_sensor_platform_info mt9e013_sensor_7630_info = {
1380 .mount_angle = 0
1381};
1382
1383static struct msm_camera_sensor_flash_data flash_mt9e013 = {
1384 .flash_type = MSM_CAMERA_FLASH_LED,
1385 .flash_src = &msm_flash_src_pwm
1386};
1387
1388static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
1389 .sensor_name = "mt9e013",
1390 .sensor_reset = 0,
1391 .sensor_pwd = 85,
1392 .vcm_pwd = 1,
1393 .vcm_enable = 1,
1394 .pdata = &msm_camera_device_data,
1395 .resource = msm_camera_resources,
1396 .num_resources = ARRAY_SIZE(msm_camera_resources),
1397 .flash_data = &flash_mt9e013,
1398 .sensor_platform_info = &mt9e013_sensor_7630_info,
1399 .csi_if = 1
1400};
1401
1402static struct platform_device msm_camera_sensor_mt9e013 = {
1403 .name = "msm_camera_mt9e013",
1404 .dev = {
1405 .platform_data = &msm_camera_sensor_mt9e013_data,
1406 },
1407};
1408#endif
1409
1410#ifdef CONFIG_VX6953
Jilai Wang971f97f2011-07-13 14:25:25 -04001411static struct msm_camera_sensor_platform_info vx6953_sensor_7630_info = {
1412 .mount_angle = 0
1413};
1414
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001415static struct msm_camera_sensor_flash_data flash_vx6953 = {
1416 .flash_type = MSM_CAMERA_FLASH_LED,
1417 .flash_src = &msm_flash_src_pwm
1418};
1419static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1420 .sensor_name = "vx6953",
1421 .sensor_reset = 0,
1422 .sensor_pwd = 85,
1423 .vcm_pwd = 1,
1424 .vcm_enable = 0,
1425 .pdata = &msm_camera_device_data,
1426 .resource = msm_camera_resources,
1427 .num_resources = ARRAY_SIZE(msm_camera_resources),
Jilai Wang971f97f2011-07-13 14:25:25 -04001428 .sensor_platform_info = &vx6953_sensor_7630_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001429 .flash_data = &flash_vx6953,
1430 .csi_if = 1
1431};
1432static struct platform_device msm_camera_sensor_vx6953 = {
1433 .name = "msm_camera_vx6953",
1434 .dev = {
1435 .platform_data = &msm_camera_sensor_vx6953_data,
1436 },
1437};
1438#endif
1439
1440#ifdef CONFIG_SN12M0PZ
1441static struct msm_camera_sensor_flash_src msm_flash_src_current_driver = {
1442 .flash_sr_type = MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER,
1443 ._fsrc.current_driver_src.low_current = 210,
1444 ._fsrc.current_driver_src.high_current = 700,
1445 ._fsrc.current_driver_src.driver_channel = &pm8058_fluid_leds_data,
1446};
1447
1448static struct msm_camera_sensor_flash_data flash_sn12m0pz = {
1449 .flash_type = MSM_CAMERA_FLASH_LED,
1450 .flash_src = &msm_flash_src_current_driver
1451};
1452static struct msm_camera_sensor_info msm_camera_sensor_sn12m0pz_data = {
1453 .sensor_name = "sn12m0pz",
1454 .sensor_reset = 0,
1455 .sensor_pwd = 85,
1456 .vcm_pwd = 1,
1457 .vcm_enable = 1,
1458 .pdata = &msm_camera_device_data,
1459 .flash_data = &flash_sn12m0pz,
1460 .resource = msm_camera_resources,
1461 .num_resources = ARRAY_SIZE(msm_camera_resources),
1462 .csi_if = 0
1463};
1464
1465static struct platform_device msm_camera_sensor_sn12m0pz = {
1466 .name = "msm_camera_sn12m0pz",
1467 .dev = {
1468 .platform_data = &msm_camera_sensor_sn12m0pz_data,
1469 },
1470};
1471#endif
1472
1473#ifdef CONFIG_MT9T013
1474static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1475 .flash_type = MSM_CAMERA_FLASH_LED,
1476 .flash_src = &msm_flash_src_pwm
1477};
1478
1479static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1480 .sensor_name = "mt9t013",
1481 .sensor_reset = 0,
1482 .sensor_pwd = 85,
1483 .vcm_pwd = 1,
1484 .vcm_enable = 0,
1485 .pdata = &msm_camera_device_data,
1486 .resource = msm_camera_resources,
1487 .num_resources = ARRAY_SIZE(msm_camera_resources),
1488 .flash_data = &flash_mt9t013,
1489 .csi_if = 1
1490};
1491
1492static struct platform_device msm_camera_sensor_mt9t013 = {
1493 .name = "msm_camera_mt9t013",
1494 .dev = {
1495 .platform_data = &msm_camera_sensor_mt9t013_data,
1496 },
1497};
1498#endif
1499
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001500#ifdef CONFIG_MSM_VPE
1501static struct resource msm_vpe_resources[] = {
1502 {
1503 .start = 0xAD200000,
1504 .end = 0xAD200000 + SZ_1M - 1,
1505 .flags = IORESOURCE_MEM,
1506 },
1507 {
1508 .start = INT_VPE,
1509 .end = INT_VPE,
1510 .flags = IORESOURCE_IRQ,
1511 },
1512};
1513
1514static struct platform_device msm_vpe_device = {
1515 .name = "msm_vpe",
1516 .id = 0,
1517 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1518 .resource = msm_vpe_resources,
1519};
1520#endif
1521
1522#endif /*CONFIG_MSM_CAMERA*/
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001523#endif
1524
1525#ifdef CONFIG_MSM_GEMINI
1526static struct resource msm_gemini_resources[] = {
1527 {
1528 .start = 0xA3A00000,
1529 .end = 0xA3A00000 + 0x0150 - 1,
1530 .flags = IORESOURCE_MEM,
1531 },
1532 {
1533 .start = INT_JPEG,
1534 .end = INT_JPEG,
1535 .flags = IORESOURCE_IRQ,
1536 },
1537};
1538
1539static struct platform_device msm_gemini_device = {
1540 .name = "msm_gemini",
1541 .resource = msm_gemini_resources,
1542 .num_resources = ARRAY_SIZE(msm_gemini_resources),
1543};
1544#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001545
1546#ifdef CONFIG_MSM7KV2_AUDIO
1547static uint32_t audio_pamp_gpio_config =
1548 GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1549
1550static uint32_t audio_fluid_icodec_tx_config =
1551 GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1552
1553static int __init snddev_poweramp_gpio_init(void)
1554{
1555 int rc;
1556
1557 pr_info("snddev_poweramp_gpio_init \n");
1558 rc = gpio_tlmm_config(audio_pamp_gpio_config, GPIO_CFG_ENABLE);
1559 if (rc) {
1560 printk(KERN_ERR
1561 "%s: gpio_tlmm_config(%#x)=%d\n",
1562 __func__, audio_pamp_gpio_config, rc);
1563 }
1564 return rc;
1565}
1566
1567void msm_snddev_tx_route_config(void)
1568{
1569 int rc;
1570
1571 pr_debug("%s()\n", __func__);
1572
1573 if (machine_is_msm7x30_fluid()) {
1574 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1575 GPIO_CFG_ENABLE);
1576 if (rc) {
1577 printk(KERN_ERR
1578 "%s: gpio_tlmm_config(%#x)=%d\n",
1579 __func__, audio_fluid_icodec_tx_config, rc);
1580 } else
1581 gpio_set_value(85, 0);
1582 }
1583}
1584
1585void msm_snddev_tx_route_deconfig(void)
1586{
1587 int rc;
1588
1589 pr_debug("%s()\n", __func__);
1590
1591 if (machine_is_msm7x30_fluid()) {
1592 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1593 GPIO_CFG_DISABLE);
1594 if (rc) {
1595 printk(KERN_ERR
1596 "%s: gpio_tlmm_config(%#x)=%d\n",
1597 __func__, audio_fluid_icodec_tx_config, rc);
1598 }
1599 }
1600}
1601
1602void msm_snddev_poweramp_on(void)
1603{
1604 gpio_set_value(82, 1); /* enable spkr poweramp */
1605 pr_info("%s: power on amplifier\n", __func__);
1606}
1607
1608void msm_snddev_poweramp_off(void)
1609{
1610 gpio_set_value(82, 0); /* disable spkr poweramp */
1611 pr_info("%s: power off amplifier\n", __func__);
1612}
1613
Justin Paupore3f40f342011-08-10 18:52:16 -07001614static struct regulator_bulk_data snddev_regs[] = {
1615 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
1616 { .supply = "ncp", .min_uV = 1800000, .max_uV = 1800000 },
1617};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001618
Justin Paupore3f40f342011-08-10 18:52:16 -07001619static int __init snddev_hsed_voltage_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001620{
1621 int rc;
1622
Justin Paupore3f40f342011-08-10 18:52:16 -07001623 rc = regulator_bulk_get(NULL, ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001624
Justin Paupore3f40f342011-08-10 18:52:16 -07001625 if (rc) {
1626 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1627 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001628 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001629
1630 rc = regulator_bulk_set_voltage(ARRAY_SIZE(snddev_regs), snddev_regs);
1631
1632 if (rc) {
1633 pr_err("%s: could not set regulator voltages: %d\n",
1634 __func__, rc);
1635 goto regs_free;
1636 }
1637
1638 return 0;
1639
1640regs_free:
1641 regulator_bulk_free(ARRAY_SIZE(snddev_regs), snddev_regs);
1642out:
1643 return rc;
1644}
1645
1646
1647void msm_snddev_hsed_voltage_on(void)
1648{
1649 int rc = regulator_bulk_enable(ARRAY_SIZE(snddev_regs), snddev_regs);
1650
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001651 if (rc)
Justin Paupore3f40f342011-08-10 18:52:16 -07001652 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001653}
1654
1655void msm_snddev_hsed_voltage_off(void)
1656{
Justin Paupore3f40f342011-08-10 18:52:16 -07001657 int rc = regulator_bulk_disable(ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001658
Justin Paupore3f40f342011-08-10 18:52:16 -07001659 if (rc) {
1660 pr_err("%s: could not disable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001661 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001662}
1663
1664static unsigned aux_pcm_gpio_on[] = {
1665 GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
1666 GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
1667 GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
1668 GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
1669};
1670
1671static int __init aux_pcm_gpio_init(void)
1672{
1673 int pin, rc;
1674
1675 pr_info("aux_pcm_gpio_init \n");
1676 for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) {
1677 rc = gpio_tlmm_config(aux_pcm_gpio_on[pin],
1678 GPIO_CFG_ENABLE);
1679 if (rc) {
1680 printk(KERN_ERR
1681 "%s: gpio_tlmm_config(%#x)=%d\n",
1682 __func__, aux_pcm_gpio_on[pin], rc);
1683 }
1684 }
1685 return rc;
1686}
1687
1688static struct msm_gpio mi2s_clk_gpios[] = {
1689 { GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1690 "MI2S_SCLK"},
1691 { GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1692 "MI2S_WS"},
1693 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1694 "MI2S_MCLK_A"},
1695};
1696
1697static struct msm_gpio mi2s_rx_data_lines_gpios[] = {
1698 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1699 "MI2S_DATA_SD0_A"},
1700 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1701 "MI2S_DATA_SD1_A"},
1702 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1703 "MI2S_DATA_SD2_A"},
1704 { GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1705 "MI2S_DATA_SD3"},
1706};
1707
1708static struct msm_gpio mi2s_tx_data_lines_gpios[] = {
1709 { GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1710 "MI2S_DATA_SD3"},
1711};
1712
1713int mi2s_config_clk_gpio(void)
1714{
1715 int rc = 0;
1716
1717 rc = msm_gpios_request_enable(mi2s_clk_gpios,
1718 ARRAY_SIZE(mi2s_clk_gpios));
1719 if (rc) {
1720 pr_err("%s: enable mi2s clk gpios failed\n",
1721 __func__);
1722 return rc;
1723 }
1724 return 0;
1725}
1726
1727int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask)
1728{
1729 int i, rc = 0;
1730 sd_line_mask &= MI2S_SD_LINE_MASK;
1731
1732 switch (direction) {
1733 case DIR_TX:
1734 msm_gpios_disable_free(mi2s_tx_data_lines_gpios, 1);
1735 break;
1736 case DIR_RX:
1737 i = 0;
1738 while (sd_line_mask) {
1739 if (sd_line_mask & 0x1)
1740 msm_gpios_disable_free(
1741 mi2s_rx_data_lines_gpios + i , 1);
1742 sd_line_mask = sd_line_mask >> 1;
1743 i++;
1744 }
1745 break;
1746 default:
1747 pr_err("%s: Invaild direction direction = %u\n",
1748 __func__, direction);
1749 rc = -EINVAL;
1750 break;
1751 }
1752 return rc;
1753}
1754
1755int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask)
1756{
1757 int i , rc = 0;
1758 u8 sd_config_done_mask = 0;
1759
1760 sd_line_mask &= MI2S_SD_LINE_MASK;
1761
1762 switch (direction) {
1763 case DIR_TX:
1764 if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) ||
1765 (sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) {
1766 pr_err("%s: can not use SD0 or SD1 or SD2 for TX"
1767 ".only can use SD3. sd_line_mask = 0x%x\n",
1768 __func__ , sd_line_mask);
1769 rc = -EINVAL;
1770 } else {
1771 rc = msm_gpios_request_enable(mi2s_tx_data_lines_gpios,
1772 1);
1773 if (rc)
1774 pr_err("%s: enable mi2s gpios for TX failed\n",
1775 __func__);
1776 }
1777 break;
1778 case DIR_RX:
1779 i = 0;
1780 while (sd_line_mask && (rc == 0)) {
1781 if (sd_line_mask & 0x1) {
1782 rc = msm_gpios_request_enable(
1783 mi2s_rx_data_lines_gpios + i , 1);
1784 if (rc) {
1785 pr_err("%s: enable mi2s gpios for"
1786 "RX failed. SD line = %s\n",
1787 __func__,
1788 (mi2s_rx_data_lines_gpios + i)->label);
1789 mi2s_unconfig_data_gpio(DIR_RX,
1790 sd_config_done_mask);
1791 } else
1792 sd_config_done_mask |= (1 << i);
1793 }
1794 sd_line_mask = sd_line_mask >> 1;
1795 i++;
1796 }
1797 break;
1798 default:
1799 pr_err("%s: Invaild direction direction = %u\n",
1800 __func__, direction);
1801 rc = -EINVAL;
1802 break;
1803 }
1804 return rc;
1805}
1806
1807int mi2s_unconfig_clk_gpio(void)
1808{
1809 msm_gpios_disable_free(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios));
1810 return 0;
1811}
1812
1813#endif /* CONFIG_MSM7KV2_AUDIO */
1814
1815static int __init buses_init(void)
1816{
1817 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT,
1818 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
1819 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
1820 __func__, PMIC_GPIO_INT);
1821
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301822 if (machine_is_msm8x60_fluid())
1823 pm8058_7x30_data.keypad_pdata = &fluid_keypad_data;
1824 else
1825 pm8058_7x30_data.keypad_pdata = &surf_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001826
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001827 return 0;
1828}
1829
1830#define TIMPANI_RESET_GPIO 1
1831
1832struct bahama_config_register{
1833 u8 reg;
1834 u8 value;
1835 u8 mask;
1836};
1837
1838enum version{
1839 VER_1_0,
1840 VER_2_0,
1841 VER_UNSUPPORTED = 0xFF
1842};
1843
Justin Paupore3f40f342011-08-10 18:52:16 -07001844static struct regulator *vreg_marimba_1;
1845static struct regulator *vreg_marimba_2;
1846static struct regulator *vreg_bahama;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001847
1848static struct msm_gpio timpani_reset_gpio_cfg[] = {
1849{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
1850 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} };
1851
1852static u8 read_bahama_ver(void)
1853{
1854 int rc;
1855 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1856 u8 bahama_version;
1857
1858 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
1859 if (rc < 0) {
1860 printk(KERN_ERR
1861 "%s: version read failed: %d\n",
1862 __func__, rc);
1863 return rc;
1864 } else {
1865 printk(KERN_INFO
1866 "%s: version read got: 0x%x\n",
1867 __func__, bahama_version);
1868 }
1869
1870 switch (bahama_version) {
1871 case 0x08: /* varient of bahama v1 */
1872 case 0x10:
1873 case 0x00:
1874 return VER_1_0;
1875 case 0x09: /* variant of bahama v2 */
1876 return VER_2_0;
1877 default:
1878 return VER_UNSUPPORTED;
1879 }
1880}
1881
1882static int config_timpani_reset(void)
1883{
1884 int rc;
1885
1886 rc = msm_gpios_request_enable(timpani_reset_gpio_cfg,
1887 ARRAY_SIZE(timpani_reset_gpio_cfg));
1888 if (rc < 0) {
1889 printk(KERN_ERR
1890 "%s: msm_gpios_request_enable failed (%d)\n",
1891 __func__, rc);
1892 }
1893 return rc;
1894}
1895
1896static unsigned int msm_timpani_setup_power(void)
1897{
1898 int rc;
1899
1900 rc = config_timpani_reset();
1901 if (rc < 0)
1902 goto out;
1903
Justin Paupore3f40f342011-08-10 18:52:16 -07001904 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001905 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001906 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001907 goto out;
1908 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001909
1910 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001911 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001912 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1913 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001914 }
1915
1916 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1);
1917 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001918 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001919 __func__, rc);
1920 msm_gpios_free(timpani_reset_gpio_cfg,
1921 ARRAY_SIZE(timpani_reset_gpio_cfg));
Justin Paupore3f40f342011-08-10 18:52:16 -07001922 goto disable_marimba_2;
1923 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001924
Justin Paupore3f40f342011-08-10 18:52:16 -07001925 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001926
Justin Paupore3f40f342011-08-10 18:52:16 -07001927disable_marimba_2:
1928 regulator_disable(vreg_marimba_2);
1929disable_marimba_1:
1930 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001931out:
1932 return rc;
1933};
1934
1935static void msm_timpani_shutdown_power(void)
1936{
1937 int rc;
1938
Justin Paupore3f40f342011-08-10 18:52:16 -07001939 rc = regulator_disable(vreg_marimba_2);
1940 if (rc)
1941 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1942
1943 rc = regulator_disable(vreg_marimba_1);
1944 if (rc)
1945 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001946
1947 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0);
Justin Paupore3f40f342011-08-10 18:52:16 -07001948 if (rc < 0)
1949 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001950 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001951
1952 msm_gpios_free(timpani_reset_gpio_cfg,
1953 ARRAY_SIZE(timpani_reset_gpio_cfg));
1954};
1955
1956static unsigned int msm_bahama_core_config(int type)
1957{
1958 int rc = 0;
1959
1960 if (type == BAHAMA_ID) {
1961
1962 int i;
1963 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1964
1965 const struct bahama_config_register v20_init[] = {
1966 /* reg, value, mask */
1967 { 0xF4, 0x84, 0xFF }, /* AREG */
1968 { 0xF0, 0x04, 0xFF } /* DREG */
1969 };
1970
1971 if (read_bahama_ver() == VER_2_0) {
1972 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
1973 u8 value = v20_init[i].value;
1974 rc = marimba_write_bit_mask(&config,
1975 v20_init[i].reg,
1976 &value,
1977 sizeof(v20_init[i].value),
1978 v20_init[i].mask);
1979 if (rc < 0) {
1980 printk(KERN_ERR
1981 "%s: reg %d write failed: %d\n",
1982 __func__, v20_init[i].reg, rc);
1983 return rc;
1984 }
1985 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
1986 " mask 0x%02x\n",
1987 __func__, v20_init[i].reg,
1988 v20_init[i].value, v20_init[i].mask);
1989 }
1990 }
1991 }
1992 printk(KERN_INFO "core type: %d\n", type);
1993
1994 return rc;
1995}
1996
1997static unsigned int msm_bahama_setup_power(void)
1998{
Justin Paupore3f40f342011-08-10 18:52:16 -07001999 int rc = regulator_enable(vreg_bahama);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002000
Justin Paupore3f40f342011-08-10 18:52:16 -07002001 if (rc)
2002 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002003
2004 return rc;
2005};
2006
2007static unsigned int msm_bahama_shutdown_power(int value)
2008{
2009 int rc = 0;
2010
2011 if (value != BAHAMA_ID) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002012 rc = regulator_disable(vreg_bahama);
2013
2014 if (rc)
2015 pr_err("%s: regulator_disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002016 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002017 }
2018
2019 return rc;
2020};
2021
2022static struct msm_gpio marimba_svlte_config_clock[] = {
2023 { GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2024 "MARIMBA_SVLTE_CLOCK_ENABLE" },
2025};
2026
2027static unsigned int msm_marimba_gpio_config_svlte(int gpio_cfg_marimba)
2028{
2029 if (machine_is_msm8x55_svlte_surf() ||
2030 machine_is_msm8x55_svlte_ffa()) {
2031 if (gpio_cfg_marimba)
2032 gpio_set_value(GPIO_PIN
2033 (marimba_svlte_config_clock->gpio_cfg), 1);
2034 else
2035 gpio_set_value(GPIO_PIN
2036 (marimba_svlte_config_clock->gpio_cfg), 0);
2037 }
2038
2039 return 0;
2040};
2041
2042static unsigned int msm_marimba_setup_power(void)
2043{
2044 int rc;
2045
Justin Paupore3f40f342011-08-10 18:52:16 -07002046 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002047 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002048 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002049 goto out;
2050 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002051
2052 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002053 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002054 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2055 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002056 }
2057
2058 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
2059 rc = msm_gpios_request_enable(marimba_svlte_config_clock,
2060 ARRAY_SIZE(marimba_svlte_config_clock));
2061 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002062 pr_err("%s: msm_gpios_request_enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002063 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002064 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002065 }
2066
2067 rc = gpio_direction_output(GPIO_PIN
2068 (marimba_svlte_config_clock->gpio_cfg), 0);
2069 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002070 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002071 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002072 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002073 }
2074 }
2075
Justin Paupore3f40f342011-08-10 18:52:16 -07002076 return 0;
2077
2078disable_marimba_2:
2079 regulator_disable(vreg_marimba_2);
2080disable_marimba_1:
2081 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002082out:
2083 return rc;
2084};
2085
2086static void msm_marimba_shutdown_power(void)
2087{
2088 int rc;
2089
Justin Paupore3f40f342011-08-10 18:52:16 -07002090 rc = regulator_disable(vreg_marimba_2);
2091 if (rc)
2092 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
2093
2094 rc = regulator_disable(vreg_marimba_1);
2095 if (rc)
2096 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002097};
2098
2099static int bahama_present(void)
2100{
2101 int id;
2102 switch (id = adie_get_detected_connectivity_type()) {
2103 case BAHAMA_ID:
2104 return 1;
2105
2106 case MARIMBA_ID:
2107 return 0;
2108
2109 case TIMPANI_ID:
2110 default:
2111 printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n",
2112 __func__, id);
2113 return -ENODEV;
2114 }
2115}
2116
Justin Paupore3f40f342011-08-10 18:52:16 -07002117struct regulator *fm_regulator;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002118static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
2119{
Justin Paupore3f40f342011-08-10 18:52:16 -07002120 int rc, voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002121 uint32_t irqcfg;
2122 const char *id = "FMPW";
2123
2124 int bahama_not_marimba = bahama_present();
2125
Justin Paupore3f40f342011-08-10 18:52:16 -07002126 if (bahama_not_marimba < 0) {
2127 pr_warn("%s: bahama_present: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002128 __func__, bahama_not_marimba);
Justin Paupore3f40f342011-08-10 18:52:16 -07002129 rc = -ENODEV;
2130 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002131 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002132 if (bahama_not_marimba) {
2133 fm_regulator = regulator_get(NULL, "s3");
2134 voltage = 1800000;
2135 } else {
2136 fm_regulator = regulator_get(NULL, "s2");
2137 voltage = 1300000;
2138 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002139
2140 if (IS_ERR(fm_regulator)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002141 rc = PTR_ERR(fm_regulator);
2142 pr_err("%s: regulator_get failed (%d)\n", __func__, rc);
2143 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002144 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002145
Justin Paupore3f40f342011-08-10 18:52:16 -07002146 rc = regulator_set_voltage(fm_regulator, voltage, voltage);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002147
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002148 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002149 pr_err("%s: regulator_set_voltage failed (%d)\n", __func__, rc);
2150 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002151 }
2152
Justin Paupore3f40f342011-08-10 18:52:16 -07002153 rc = regulator_enable(fm_regulator);
2154
2155 if (rc) {
2156 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2157 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002158 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002159
2160 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_ON);
2161
2162 if (rc < 0) {
2163 pr_err("%s: clock vote failed (%d)\n", __func__, rc);
2164 goto regulator_disable;
2165 }
2166
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002167 /*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2168 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002169 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002170 rc = marimba_gpio_config(1);
Justin Paupore3f40f342011-08-10 18:52:16 -07002171 if (rc < 0) {
2172 pr_err("%s: clock enable for svlte : %d\n",
2173 __func__, rc);
2174 goto clock_devote;
2175 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002176 }
2177 irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
2178 GPIO_CFG_2MA);
2179 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2180 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002181 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002182 rc = -EIO;
Justin Paupore3f40f342011-08-10 18:52:16 -07002183 goto gpio_deconfig;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002184
2185 }
2186 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002187
Justin Paupore3f40f342011-08-10 18:52:16 -07002188gpio_deconfig:
2189 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa())
2190 marimba_gpio_config(0);
2191clock_devote:
2192 pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_OFF);
2193regulator_disable:
2194 regulator_disable(fm_regulator);
2195regulator_free:
2196 regulator_put(fm_regulator);
2197 fm_regulator = NULL;
2198out:
2199 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002200};
2201
2202static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
2203{
2204 int rc;
2205 const char *id = "FMPW";
2206 uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
2207 GPIO_CFG_2MA);
2208
2209 int bahama_not_marimba = bahama_present();
2210 if (bahama_not_marimba == -1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002211 pr_warn("%s: bahama_present: %d\n",
2212 __func__, bahama_not_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002213 return;
2214 }
2215
2216 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2217 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002218 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002219 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002220 if (!IS_ERR_OR_NULL(fm_regulator)) {
2221 rc = regulator_disable(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002222
Justin Paupore3f40f342011-08-10 18:52:16 -07002223 if (rc)
2224 pr_err("%s: return val: %d\n", __func__, rc);
2225
2226 regulator_put(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002227 fm_regulator = NULL;
2228 }
2229 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
2230 PMAPP_CLOCK_VOTE_OFF);
2231 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002232 pr_err("%s: clock_vote return val: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002233
2234 /*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2235 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002236 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002237 rc = marimba_gpio_config(0);
2238 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002239 pr_err("%s: clock disable for svlte : %d\n",
2240 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002241 }
2242}
2243
2244static struct marimba_fm_platform_data marimba_fm_pdata = {
2245 .fm_setup = fm_radio_setup,
2246 .fm_shutdown = fm_radio_shutdown,
2247 .irq = MSM_GPIO_TO_INT(147),
2248 .vreg_s2 = NULL,
2249 .vreg_xo_out = NULL,
2250 .is_fm_soc_i2s_master = false,
2251 .config_i2s_gpio = NULL,
2252};
2253
2254
2255/* Slave id address for FM/CDC/QMEMBIST
2256 * Values can be programmed using Marimba slave id 0
2257 * should there be a conflict with other I2C devices
2258 * */
2259#define MARIMBA_SLAVE_ID_FM_ADDR 0x2A
2260#define MARIMBA_SLAVE_ID_CDC_ADDR 0x77
2261#define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66
2262
2263#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
2264#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
2265
2266static const char *tsadc_id = "MADC";
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002267
Justin Paupore3f40f342011-08-10 18:52:16 -07002268static struct regulator_bulk_data regs_tsadc_marimba[] = {
2269 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2270 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002271};
Justin Paupore3f40f342011-08-10 18:52:16 -07002272
2273static struct regulator_bulk_data regs_tsadc_timpani[] = {
2274 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2275 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2276 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2277};
2278
2279static struct regulator_bulk_data *regs_tsadc;
2280static int regs_tsadc_count;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002281
2282static int marimba_tsadc_power(int vreg_on)
2283{
Justin Paupore3f40f342011-08-10 18:52:16 -07002284 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002285 int tsadc_adie_type = adie_get_detected_codec_type();
2286
Justin Paupore3f40f342011-08-10 18:52:16 -07002287 switch (tsadc_adie_type) {
2288 case TIMPANI_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002289 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2290 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2291 if (rc) {
2292 pr_err("%s: unable to %svote for d1 clk\n",
2293 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002294 goto D1_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002295 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002296
2297 /* fall through */
2298 case MARIMBA_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002299 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2300 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2301 if (rc) {
2302 pr_err("%s: unable to %svote for d1 clk\n",
2303 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002304 goto D0_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002305 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002306
Justin Paupore3f40f342011-08-10 18:52:16 -07002307 WARN_ON(regs_tsadc_count == 0);
2308
2309 rc = vreg_on ?
2310 regulator_bulk_enable(regs_tsadc_count, regs_tsadc) :
2311 regulator_bulk_disable(regs_tsadc_count, regs_tsadc);
2312
2313 if (rc) {
2314 pr_err("%s: regulator %sable failed: %d\n",
2315 __func__, vreg_on ? "en" : "dis", rc);
2316 goto regulator_switch_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002317 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002318
2319 break;
2320 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002321 pr_err("%s:Adie %d not supported\n",
2322 __func__, tsadc_adie_type);
2323 return -ENODEV;
2324 }
2325
2326 msleep(5); /* ensure power is stable */
2327
2328 return 0;
2329
Justin Paupore3f40f342011-08-10 18:52:16 -07002330regulator_switch_fail:
2331 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2332 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2333D0_vote_fail:
2334 if (tsadc_adie_type == TIMPANI_ID)
2335 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2336 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2337D1_vote_fail:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002338 return rc;
2339}
2340
2341static int marimba_tsadc_init(void)
2342{
Justin Paupore3f40f342011-08-10 18:52:16 -07002343 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002344 int tsadc_adie_type = adie_get_detected_codec_type();
2345
Justin Paupore3f40f342011-08-10 18:52:16 -07002346 switch (tsadc_adie_type) {
2347 case MARIMBA_ID:
2348 regs_tsadc = regs_tsadc_marimba;
2349 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_marimba);
2350 break;
2351 case TIMPANI_ID:
2352 regs_tsadc = regs_tsadc_timpani;
2353 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_timpani);
2354 break;
2355 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002356 pr_err("%s:Adie %d not supported\n",
2357 __func__, tsadc_adie_type);
Justin Paupore3f40f342011-08-10 18:52:16 -07002358 rc = -ENODEV;
2359 goto out;
2360 }
2361
2362 rc = regulator_bulk_get(NULL, regs_tsadc_count, regs_tsadc);
2363 if (rc) {
2364 pr_err("%s: could not get regulators: %d\n",
2365 __func__, rc);
2366 goto out;
2367 }
2368
2369 rc = regulator_bulk_set_voltage(regs_tsadc_count, regs_tsadc);
2370 if (rc) {
2371 pr_err("%s: could not set regulator voltages: %d\n",
2372 __func__, rc);
2373 goto vreg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002374 }
2375
2376 return 0;
2377
Justin Paupore3f40f342011-08-10 18:52:16 -07002378vreg_free:
2379 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2380out:
2381 regs_tsadc = NULL;
2382 regs_tsadc_count = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002383 return rc;
2384}
2385
2386static int marimba_tsadc_exit(void)
2387{
Justin Paupore3f40f342011-08-10 18:52:16 -07002388 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2389 regs_tsadc_count = 0;
2390 regs_tsadc = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002391
Justin Paupore3f40f342011-08-10 18:52:16 -07002392 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002393}
2394
2395
2396static struct msm_ts_platform_data msm_ts_data = {
Anirudh Ghayal82b74722012-01-19 15:35:34 +05302397 .min_x = 284,
2398 .max_x = 3801,
2399 .min_y = 155,
2400 .max_y = 3929,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002401 .min_press = 0,
2402 .max_press = 255,
2403 .inv_x = 4096,
2404 .inv_y = 4096,
2405 .can_wakeup = false,
2406};
2407
2408static struct marimba_tsadc_platform_data marimba_tsadc_pdata = {
2409 .marimba_tsadc_power = marimba_tsadc_power,
2410 .init = marimba_tsadc_init,
2411 .exit = marimba_tsadc_exit,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002412 .tsadc_prechg_en = true,
2413 .can_wakeup = false,
2414 .setup = {
2415 .pen_irq_en = true,
2416 .tsadc_en = true,
2417 },
2418 .params2 = {
2419 .input_clk_khz = 2400,
2420 .sample_prd = TSADC_CLK_3,
2421 },
2422 .params3 = {
2423 .prechg_time_nsecs = 6400,
2424 .stable_time_nsecs = 6400,
2425 .tsadc_test_mode = 0,
2426 },
2427 .tssc_data = &msm_ts_data,
2428};
2429
Justin Paupore3f40f342011-08-10 18:52:16 -07002430static struct regulator_bulk_data codec_regs[] = {
2431 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
2432};
2433
2434static int __init msm_marimba_codec_init(void)
2435{
2436 int rc = regulator_bulk_get(NULL, ARRAY_SIZE(codec_regs), codec_regs);
2437
2438 if (rc) {
2439 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2440 goto out;
2441 }
2442
2443 rc = regulator_bulk_set_voltage(ARRAY_SIZE(codec_regs), codec_regs);
2444 if (rc) {
2445 pr_err("%s: could not set regulator voltages: %d\n",
2446 __func__, rc);
2447 goto reg_free;
2448 }
2449
2450 return rc;
2451
2452reg_free:
2453 regulator_bulk_free(ARRAY_SIZE(codec_regs), codec_regs);
2454out:
2455 return rc;
2456}
2457
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002458static int msm_marimba_codec_power(int vreg_on)
2459{
Justin Paupore3f40f342011-08-10 18:52:16 -07002460 int rc = vreg_on ?
2461 regulator_bulk_enable(ARRAY_SIZE(codec_regs), codec_regs) :
2462 regulator_bulk_disable(ARRAY_SIZE(codec_regs), codec_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002463
Justin Paupore3f40f342011-08-10 18:52:16 -07002464 if (rc) {
2465 pr_err("%s: could not %sable regulators: %d",
2466 __func__, vreg_on ? "en" : "dis", rc);
2467 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002468 }
2469
Justin Paupore3f40f342011-08-10 18:52:16 -07002470 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002471}
2472
2473static struct marimba_codec_platform_data mariba_codec_pdata = {
2474 .marimba_codec_power = msm_marimba_codec_power,
2475#ifdef CONFIG_MARIMBA_CODEC
2476 .snddev_profile_init = msm_snddev_init,
2477#endif
2478};
2479
2480static struct marimba_platform_data marimba_pdata = {
2481 .slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR,
2482 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2483 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2484 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
2485 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
2486 .marimba_setup = msm_marimba_setup_power,
2487 .marimba_shutdown = msm_marimba_shutdown_power,
2488 .bahama_setup = msm_bahama_setup_power,
2489 .bahama_shutdown = msm_bahama_shutdown_power,
2490 .marimba_gpio_config = msm_marimba_gpio_config_svlte,
2491 .bahama_core_config = msm_bahama_core_config,
2492 .fm = &marimba_fm_pdata,
2493 .codec = &mariba_codec_pdata,
2494 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2495};
2496
2497static void __init msm7x30_init_marimba(void)
2498{
2499 int rc;
2500
Justin Paupore3f40f342011-08-10 18:52:16 -07002501 struct regulator_bulk_data regs[] = {
2502 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2503 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2504 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
2505 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002506
Justin Paupore3f40f342011-08-10 18:52:16 -07002507 rc = msm_marimba_codec_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002508
Justin Paupore3f40f342011-08-10 18:52:16 -07002509 if (rc) {
2510 pr_err("%s: msm_marimba_codec_init failed (%d)\n",
2511 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002512 return;
2513 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002514
2515 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
2516
2517 if (rc) {
2518 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2519 return;
2520 }
2521
2522 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
2523
2524 if (rc) {
2525 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2526 regulator_bulk_free(ARRAY_SIZE(regs), regs);
2527 return;
2528 }
2529
2530 vreg_marimba_1 = regs[0].consumer;
2531 vreg_marimba_2 = regs[1].consumer;
2532 vreg_bahama = regs[2].consumer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002533}
2534
2535static struct marimba_codec_platform_data timpani_codec_pdata = {
2536 .marimba_codec_power = msm_marimba_codec_power,
2537#ifdef CONFIG_TIMPANI_CODEC
2538 .snddev_profile_init = msm_snddev_init_timpani,
2539#endif
2540};
2541
2542static struct marimba_platform_data timpani_pdata = {
2543 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2544 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2545 .marimba_setup = msm_timpani_setup_power,
2546 .marimba_shutdown = msm_timpani_shutdown_power,
2547 .codec = &timpani_codec_pdata,
2548 .tsadc = &marimba_tsadc_pdata,
2549 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2550};
2551
2552#define TIMPANI_I2C_SLAVE_ADDR 0xD
2553
2554static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
2555 {
2556 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
2557 .platform_data = &timpani_pdata,
2558 },
2559};
2560
2561#ifdef CONFIG_MSM7KV2_AUDIO
2562static struct resource msm_aictl_resources[] = {
2563 {
2564 .name = "aictl",
2565 .start = 0xa5000100,
2566 .end = 0xa5000100,
2567 .flags = IORESOURCE_MEM,
2568 }
2569};
2570
2571static struct resource msm_mi2s_resources[] = {
2572 {
2573 .name = "hdmi",
2574 .start = 0xac900000,
2575 .end = 0xac900038,
2576 .flags = IORESOURCE_MEM,
2577 },
2578 {
2579 .name = "codec_rx",
2580 .start = 0xac940040,
2581 .end = 0xac940078,
2582 .flags = IORESOURCE_MEM,
2583 },
2584 {
2585 .name = "codec_tx",
2586 .start = 0xac980080,
2587 .end = 0xac9800B8,
2588 .flags = IORESOURCE_MEM,
2589 }
2590
2591};
2592
2593static struct msm_lpa_platform_data lpa_pdata = {
2594 .obuf_hlb_size = 0x2BFF8,
2595 .dsp_proc_id = 0,
2596 .app_proc_id = 2,
2597 .nosb_config = {
2598 .llb_min_addr = 0,
2599 .llb_max_addr = 0x3ff8,
2600 .sb_min_addr = 0,
2601 .sb_max_addr = 0,
2602 },
2603 .sb_config = {
2604 .llb_min_addr = 0,
2605 .llb_max_addr = 0x37f8,
2606 .sb_min_addr = 0x3800,
2607 .sb_max_addr = 0x3ff8,
2608 }
2609};
2610
2611static struct resource msm_lpa_resources[] = {
2612 {
2613 .name = "lpa",
2614 .start = 0xa5000000,
2615 .end = 0xa50000a0,
2616 .flags = IORESOURCE_MEM,
2617 }
2618};
2619
2620static struct resource msm_aux_pcm_resources[] = {
2621
2622 {
2623 .name = "aux_codec_reg_addr",
2624 .start = 0xac9c00c0,
2625 .end = 0xac9c00c8,
2626 .flags = IORESOURCE_MEM,
2627 },
2628 {
2629 .name = "aux_pcm_dout",
2630 .start = 138,
2631 .end = 138,
2632 .flags = IORESOURCE_IO,
2633 },
2634 {
2635 .name = "aux_pcm_din",
2636 .start = 139,
2637 .end = 139,
2638 .flags = IORESOURCE_IO,
2639 },
2640 {
2641 .name = "aux_pcm_syncout",
2642 .start = 140,
2643 .end = 140,
2644 .flags = IORESOURCE_IO,
2645 },
2646 {
2647 .name = "aux_pcm_clkin_a",
2648 .start = 141,
2649 .end = 141,
2650 .flags = IORESOURCE_IO,
2651 },
2652};
2653
2654static struct platform_device msm_aux_pcm_device = {
2655 .name = "msm_aux_pcm",
2656 .id = 0,
2657 .num_resources = ARRAY_SIZE(msm_aux_pcm_resources),
2658 .resource = msm_aux_pcm_resources,
2659};
2660
2661struct platform_device msm_aictl_device = {
2662 .name = "audio_interct",
2663 .id = 0,
2664 .num_resources = ARRAY_SIZE(msm_aictl_resources),
2665 .resource = msm_aictl_resources,
2666};
2667
2668struct platform_device msm_mi2s_device = {
2669 .name = "mi2s",
2670 .id = 0,
2671 .num_resources = ARRAY_SIZE(msm_mi2s_resources),
2672 .resource = msm_mi2s_resources,
2673};
2674
2675struct platform_device msm_lpa_device = {
2676 .name = "lpa",
2677 .id = 0,
2678 .num_resources = ARRAY_SIZE(msm_lpa_resources),
2679 .resource = msm_lpa_resources,
2680 .dev = {
2681 .platform_data = &lpa_pdata,
2682 },
2683};
2684#endif /* CONFIG_MSM7KV2_AUDIO */
2685
2686#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2687 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2688 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2689 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2690 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2691 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2692#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2693 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2694 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2695 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2696 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2697 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2698 #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2699 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2700 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2701 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2702 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2703 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2704 #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2705 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2706 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2707 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2708 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2709 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2710#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
2711
2712static unsigned int dec_concurrency_table[] = {
2713 /* Audio LP */
2714 0,
2715 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2716 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2717 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2718 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)|
2719 (1<<MSM_ADSP_OP_DM)),
2720
2721 /* Concurrency 1 */
2722 (DEC4_FORMAT),
2723 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2724 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2725 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2726 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2727
2728 /* Concurrency 2 */
2729 (DEC4_FORMAT),
2730 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2731 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2732 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2733 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2734
2735 /* Concurrency 3 */
2736 (DEC4_FORMAT),
2737 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2738 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2739 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2740 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2741
2742 /* Concurrency 4 */
2743 (DEC4_FORMAT),
2744 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2745 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2746 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2747 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2748
2749 /* Concurrency 5 */
2750 (DEC4_FORMAT),
2751 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2752 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2753 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2754 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2755
2756 /* Concurrency 6 */
2757 (DEC4_FORMAT),
2758 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2759 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2760 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2761 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2762};
2763
2764#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
2765 .module_queueid = queueid, .module_decid = decid, \
2766 .nr_codec_support = nr_codec}
2767
2768#define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
2769 .max_instances_same_dec = max_instance_same, \
2770 .max_instances_diff_dec = max_instance_diff}
2771
2772static struct msm_adspdec_info dec_info_list[] = {
2773 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
2774 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
2775 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
2776 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
2777 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
2778};
2779
2780static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
2781 /* Non Turbo Mode */
2782 {
2783 DEC_INSTANCE(4, 3), /* WAV */
2784 DEC_INSTANCE(4, 3), /* ADPCM */
2785 DEC_INSTANCE(4, 2), /* MP3 */
2786 DEC_INSTANCE(0, 0), /* Real Audio */
2787 DEC_INSTANCE(4, 2), /* WMA */
2788 DEC_INSTANCE(3, 2), /* AAC */
2789 DEC_INSTANCE(0, 0), /* Reserved */
2790 DEC_INSTANCE(0, 0), /* MIDI */
2791 DEC_INSTANCE(4, 3), /* YADPCM */
2792 DEC_INSTANCE(4, 3), /* QCELP */
2793 DEC_INSTANCE(4, 3), /* AMRNB */
2794 DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
2795 DEC_INSTANCE(4, 3), /* EVRC */
2796 DEC_INSTANCE(1, 1), /* WMAPRO */
2797 },
2798 /* Turbo Mode */
2799 {
2800 DEC_INSTANCE(4, 3), /* WAV */
2801 DEC_INSTANCE(4, 3), /* ADPCM */
2802 DEC_INSTANCE(4, 3), /* MP3 */
2803 DEC_INSTANCE(0, 0), /* Real Audio */
2804 DEC_INSTANCE(4, 3), /* WMA */
2805 DEC_INSTANCE(4, 3), /* AAC */
2806 DEC_INSTANCE(0, 0), /* Reserved */
2807 DEC_INSTANCE(0, 0), /* MIDI */
2808 DEC_INSTANCE(4, 3), /* YADPCM */
2809 DEC_INSTANCE(4, 3), /* QCELP */
2810 DEC_INSTANCE(4, 3), /* AMRNB */
2811 DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
2812 DEC_INSTANCE(4, 3), /* EVRC */
2813 DEC_INSTANCE(1, 2), /* WMAPRO */
2814 },
2815};
2816
2817static struct msm_adspdec_database msm_device_adspdec_database = {
2818 .num_dec = ARRAY_SIZE(dec_info_list),
2819 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
2820 ARRAY_SIZE(dec_info_list)),
2821 .dec_concurrency_table = dec_concurrency_table,
2822 .dec_info_list = dec_info_list,
2823 .dec_instance_list = &dec_instance_list[0][0],
2824};
2825
2826static struct platform_device msm_device_adspdec = {
2827 .name = "msm_adspdec",
2828 .id = -1,
2829 .dev = {
2830 .platform_data = &msm_device_adspdec_database
2831 },
2832};
2833
2834static struct resource smc91x_resources[] = {
2835 [0] = {
2836 .start = 0x8A000300,
2837 .end = 0x8A0003ff,
2838 .flags = IORESOURCE_MEM,
2839 },
2840 [1] = {
2841 .start = MSM_GPIO_TO_INT(156),
2842 .end = MSM_GPIO_TO_INT(156),
2843 .flags = IORESOURCE_IRQ,
2844 },
2845};
2846
2847static struct platform_device smc91x_device = {
2848 .name = "smc91x",
2849 .id = 0,
2850 .num_resources = ARRAY_SIZE(smc91x_resources),
2851 .resource = smc91x_resources,
2852};
2853
2854static struct smsc911x_platform_config smsc911x_config = {
2855 .phy_interface = PHY_INTERFACE_MODE_MII,
2856 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
2857 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
2858 .flags = SMSC911X_USE_32BIT,
2859};
2860
2861static struct resource smsc911x_resources[] = {
2862 [0] = {
2863 .start = 0x8D000000,
2864 .end = 0x8D000100,
2865 .flags = IORESOURCE_MEM,
2866 },
2867 [1] = {
2868 .start = MSM_GPIO_TO_INT(88),
2869 .end = MSM_GPIO_TO_INT(88),
2870 .flags = IORESOURCE_IRQ,
2871 },
2872};
2873
2874static struct platform_device smsc911x_device = {
2875 .name = "smsc911x",
2876 .id = -1,
2877 .num_resources = ARRAY_SIZE(smsc911x_resources),
2878 .resource = smsc911x_resources,
2879 .dev = {
2880 .platform_data = &smsc911x_config,
2881 },
2882};
2883
2884static struct msm_gpio smsc911x_gpios[] = {
2885 { GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" },
2886 { GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" },
2887 { GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" },
2888 { GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" },
2889 { GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" },
2890 { GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" },
2891 { GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" },
2892 { GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" },
2893};
2894
2895static void msm7x30_cfg_smsc911x(void)
2896{
2897 int rc;
2898
2899 rc = msm_gpios_request_enable(smsc911x_gpios,
2900 ARRAY_SIZE(smsc911x_gpios));
2901 if (rc)
2902 pr_err("%s: unable to enable gpios\n", __func__);
2903}
2904
2905#ifdef CONFIG_USB_G_ANDROID
2906static struct android_usb_platform_data android_usb_pdata = {
2907 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2908};
2909
2910static struct platform_device android_usb_device = {
2911 .name = "android_usb",
2912 .id = -1,
2913 .dev = {
2914 .platform_data = &android_usb_pdata,
2915 },
2916};
2917#endif
2918
2919static struct msm_gpio optnav_config_data[] = {
2920 { GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA),
2921 "optnav_chip_select" },
2922};
2923
Justin Paupore3f40f342011-08-10 18:52:16 -07002924static struct regulator_bulk_data optnav_regulators[] = {
2925 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2926 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
2927 { .supply = "gp9", .min_uV = 1800000, .max_uV = 1800000 },
2928 { .supply = "usb", .min_uV = 3300000, .max_uV = 3300000 },
2929};
2930
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002931static void __iomem *virtual_optnav;
2932
2933static int optnav_gpio_setup(void)
2934{
2935 int rc = -ENODEV;
2936 rc = msm_gpios_request_enable(optnav_config_data,
2937 ARRAY_SIZE(optnav_config_data));
2938
Justin Paupore3f40f342011-08-10 18:52:16 -07002939 if (rc)
2940 return rc;
2941
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002942 /* Configure the FPGA for GPIOs */
2943 virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4);
2944 if (!virtual_optnav) {
2945 pr_err("%s:Could not ioremap region\n", __func__);
2946 return -ENOMEM;
2947 }
2948 /*
2949 * Configure the FPGA to set GPIO 19 as
2950 * normal, active(enabled), output(MSM to SURF)
2951 */
2952 writew(0x311E, virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002953
2954 rc = regulator_bulk_get(NULL, ARRAY_SIZE(optnav_regulators),
2955 optnav_regulators);
2956 if (rc)
2957 return rc;
2958
2959 rc = regulator_bulk_set_voltage(ARRAY_SIZE(optnav_regulators),
2960 optnav_regulators);
2961
2962 if (rc)
2963 goto regulator_put;
2964
2965 return rc;
2966
2967regulator_put:
2968 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002969 return rc;
2970}
2971
2972static void optnav_gpio_release(void)
2973{
2974 msm_gpios_disable_free(optnav_config_data,
2975 ARRAY_SIZE(optnav_config_data));
2976 iounmap(virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002977 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002978}
2979
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002980static int optnav_enable(void)
2981{
2982 int rc;
2983 /*
2984 * Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
2985 * for I2C communication with keyboard.
2986 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002987
Justin Paupore3f40f342011-08-10 18:52:16 -07002988 rc = regulator_bulk_enable(ARRAY_SIZE(optnav_regulators),
2989 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002990
Justin Paupore3f40f342011-08-10 18:52:16 -07002991 if (rc)
2992 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002993
2994 /* Enable the chip select GPIO */
2995 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2996 gpio_set_value(OPTNAV_CHIP_SELECT, 0);
2997
2998 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002999}
3000
3001static void optnav_disable(void)
3002{
Justin Paupore3f40f342011-08-10 18:52:16 -07003003 regulator_bulk_disable(ARRAY_SIZE(optnav_regulators),
3004 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003005
3006 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
3007}
3008
3009static struct ofn_atlab_platform_data optnav_data = {
3010 .gpio_setup = optnav_gpio_setup,
3011 .gpio_release = optnav_gpio_release,
3012 .optnav_on = optnav_enable,
3013 .optnav_off = optnav_disable,
3014 .rotate_xy = 0,
3015 .function1 = {
3016 .no_motion1_en = true,
3017 .touch_sensor_en = true,
3018 .ofn_en = true,
3019 .clock_select_khz = 1500,
3020 .cpi_selection = 1200,
3021 },
3022 .function2 = {
3023 .invert_y = false,
3024 .invert_x = true,
3025 .swap_x_y = false,
3026 .hold_a_b_en = true,
3027 .motion_filter_en = true,
3028 },
3029};
3030
3031static int hdmi_comm_power(int on, int show);
3032static int hdmi_init_irq(void);
3033static int hdmi_enable_5v(int on);
3034static int hdmi_core_power(int on, int show);
3035static int hdmi_cec_power(int on);
3036static bool hdmi_check_hdcp_hw_support(void);
3037
3038static struct msm_hdmi_platform_data adv7520_hdmi_data = {
3039 .irq = MSM_GPIO_TO_INT(18),
3040 .comm_power = hdmi_comm_power,
3041 .init_irq = hdmi_init_irq,
3042 .enable_5v = hdmi_enable_5v,
3043 .core_power = hdmi_core_power,
3044 .cec_power = hdmi_cec_power,
3045 .check_hdcp_hw_support = hdmi_check_hdcp_hw_support,
3046};
3047
3048#ifdef CONFIG_BOSCH_BMA150
Justin Paupore3f40f342011-08-10 18:52:16 -07003049
3050static struct regulator_bulk_data sensors_ldo[] = {
3051 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
3052 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
3053};
3054
3055static int __init sensors_ldo_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003056{
3057 int rc;
3058
Justin Paupore3f40f342011-08-10 18:52:16 -07003059 rc = regulator_bulk_get(NULL, ARRAY_SIZE(sensors_ldo), sensors_ldo);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003060
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003061 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003062 pr_err("%s: could not get regulators: %d\n", __func__, rc);
3063 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003064 }
3065
Justin Paupore3f40f342011-08-10 18:52:16 -07003066 rc = regulator_bulk_set_voltage(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3067
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003068 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003069 pr_err("%s: could not set voltages: %d\n", __func__, rc);
3070 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003071 }
3072
3073 return 0;
3074
Justin Paupore3f40f342011-08-10 18:52:16 -07003075reg_free:
3076 regulator_bulk_free(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3077out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003078 return rc;
3079}
3080
Justin Paupore3f40f342011-08-10 18:52:16 -07003081static int sensors_ldo_set(int on)
3082{
3083 int rc = on ?
3084 regulator_bulk_enable(ARRAY_SIZE(sensors_ldo), sensors_ldo) :
3085 regulator_bulk_disable(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3086
3087 if (rc)
3088 pr_err("%s: could not %sable regulators: %d\n",
3089 __func__, on ? "en" : "dis", rc);
3090
3091 return rc;
3092}
3093
3094static int sensors_ldo_enable(void)
3095{
3096 return sensors_ldo_set(1);
3097}
3098
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003099static void sensors_ldo_disable(void)
3100{
Justin Paupore3f40f342011-08-10 18:52:16 -07003101 sensors_ldo_set(0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003102}
Justin Paupore3f40f342011-08-10 18:52:16 -07003103
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003104static struct bma150_platform_data bma150_data = {
3105 .power_on = sensors_ldo_enable,
3106 .power_off = sensors_ldo_disable,
3107};
3108
3109static struct i2c_board_info bma150_board_info[] __initdata = {
3110 {
3111 I2C_BOARD_INFO("bma150", 0x38),
3112 .flags = I2C_CLIENT_WAKE,
3113 .irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
3114 .platform_data = &bma150_data,
3115 },
3116};
3117#endif
3118
3119static struct i2c_board_info msm_i2c_board_info[] = {
3120 {
3121 I2C_BOARD_INFO("m33c01", OPTNAV_I2C_SLAVE_ADDR),
3122 .irq = MSM_GPIO_TO_INT(OPTNAV_IRQ),
3123 .platform_data = &optnav_data,
3124 },
3125 {
3126 I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR),
3127 .platform_data = &adv7520_hdmi_data,
3128 },
3129};
3130
3131static struct i2c_board_info msm_marimba_board_info[] = {
3132 {
3133 I2C_BOARD_INFO("marimba", 0xc),
3134 .platform_data = &marimba_pdata,
3135 }
3136};
3137
3138
3139static struct msm_handset_platform_data hs_platform_data = {
3140 .hs_name = "7k_handset",
3141 .pwr_key_delay_ms = 500, /* 0 will disable end key */
3142};
3143
3144static struct platform_device hs_device = {
3145 .name = "msm-handset",
3146 .id = -1,
3147 .dev = {
3148 .platform_data = &hs_platform_data,
3149 },
3150};
3151
3152static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +05303153 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003154 .idle_supported = 1,
3155 .suspend_supported = 1,
3156 .idle_enabled = 1,
3157 .suspend_enabled = 1,
3158 .latency = 8594,
3159 .residency = 23740,
3160 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303161 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003162 .idle_supported = 1,
3163 .suspend_supported = 1,
3164 .idle_enabled = 1,
3165 .suspend_enabled = 1,
3166 .latency = 4594,
3167 .residency = 23740,
3168 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303169 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003170#ifdef CONFIG_MSM_STANDALONE_POWER_COLLAPSE
3171 .idle_supported = 1,
3172 .suspend_supported = 1,
3173 .idle_enabled = 1,
3174 .suspend_enabled = 0,
3175#else /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3176 .idle_supported = 0,
3177 .suspend_supported = 0,
3178 .idle_enabled = 0,
3179 .suspend_enabled = 0,
3180#endif /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3181 .latency = 500,
3182 .residency = 6000,
3183 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303184 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003185 .idle_supported = 1,
3186 .suspend_supported = 1,
3187 .idle_enabled = 0,
3188 .suspend_enabled = 1,
3189 .latency = 443,
3190 .residency = 1098,
3191 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303192 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003193 .idle_supported = 1,
3194 .suspend_supported = 1,
3195 .idle_enabled = 1,
3196 .suspend_enabled = 1,
3197 .latency = 2,
3198 .residency = 0,
3199 },
3200};
3201
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003202static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3203 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
3204 .v_addr = (uint32_t *)PAGE_OFFSET,
3205};
3206
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003207static struct resource qsd_spi_resources[] = {
3208 {
3209 .name = "spi_irq_in",
3210 .start = INT_SPI_INPUT,
3211 .end = INT_SPI_INPUT,
3212 .flags = IORESOURCE_IRQ,
3213 },
3214 {
3215 .name = "spi_irq_out",
3216 .start = INT_SPI_OUTPUT,
3217 .end = INT_SPI_OUTPUT,
3218 .flags = IORESOURCE_IRQ,
3219 },
3220 {
3221 .name = "spi_irq_err",
3222 .start = INT_SPI_ERROR,
3223 .end = INT_SPI_ERROR,
3224 .flags = IORESOURCE_IRQ,
3225 },
3226 {
3227 .name = "spi_base",
3228 .start = 0xA8000000,
3229 .end = 0xA8000000 + SZ_4K - 1,
3230 .flags = IORESOURCE_MEM,
3231 },
3232 {
3233 .name = "spidm_channels",
3234 .flags = IORESOURCE_DMA,
3235 },
3236 {
3237 .name = "spidm_crci",
3238 .flags = IORESOURCE_DMA,
3239 },
3240};
3241
3242#define AMDH0_BASE_PHYS 0xAC200000
3243#define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
3244static int msm_qsd_spi_dma_config(void)
3245{
3246 void __iomem *ct_adm_base = 0;
3247 u32 spi_mux = 0;
3248 int ret = 0;
3249
3250 ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
3251 if (!ct_adm_base) {
3252 pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
3253 return -ENOMEM;
3254 }
3255
3256 spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
3257
3258 qsd_spi_resources[4].start = DMOV_USB_CHAN;
3259 qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
3260
3261 switch (spi_mux) {
3262 case (1):
3263 qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
3264 qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
3265 break;
3266 case (2):
3267 qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
3268 qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
3269 break;
3270 case (3):
3271 qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
3272 qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
3273 break;
3274 default:
3275 ret = -ENOENT;
3276 }
3277
3278 iounmap(ct_adm_base);
3279
3280 return ret;
3281}
3282
3283static struct platform_device qsd_device_spi = {
3284 .name = "spi_qsd",
3285 .id = 0,
3286 .num_resources = ARRAY_SIZE(qsd_spi_resources),
3287 .resource = qsd_spi_resources,
3288};
3289
3290#ifdef CONFIG_SPI_QSD
3291static struct spi_board_info lcdc_sharp_spi_board_info[] __initdata = {
3292 {
3293 .modalias = "lcdc_sharp_ls038y7dx01",
3294 .mode = SPI_MODE_1,
3295 .bus_num = 0,
3296 .chip_select = 0,
3297 .max_speed_hz = 26331429,
3298 }
3299};
3300static struct spi_board_info lcdc_toshiba_spi_board_info[] __initdata = {
3301 {
3302 .modalias = "lcdc_toshiba_ltm030dd40",
3303 .mode = SPI_MODE_3|SPI_CS_HIGH,
3304 .bus_num = 0,
3305 .chip_select = 0,
3306 .max_speed_hz = 9963243,
3307 }
3308};
3309#endif
3310
3311static struct msm_gpio qsd_spi_gpio_config_data[] = {
3312 { GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3313 { GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3314 { GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" },
3315 { GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3316};
3317
3318static int msm_qsd_spi_gpio_config(void)
3319{
3320 return msm_gpios_request_enable(qsd_spi_gpio_config_data,
3321 ARRAY_SIZE(qsd_spi_gpio_config_data));
3322}
3323
3324static void msm_qsd_spi_gpio_release(void)
3325{
3326 msm_gpios_disable_free(qsd_spi_gpio_config_data,
3327 ARRAY_SIZE(qsd_spi_gpio_config_data));
3328}
3329
3330static struct msm_spi_platform_data qsd_spi_pdata = {
3331 .max_clock_speed = 26331429,
3332 .gpio_config = msm_qsd_spi_gpio_config,
3333 .gpio_release = msm_qsd_spi_gpio_release,
3334 .dma_config = msm_qsd_spi_dma_config,
3335};
3336
3337static void __init msm_qsd_spi_init(void)
3338{
3339 qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
3340}
3341
3342#ifdef CONFIG_USB_EHCI_MSM_72K
3343static void msm_hsusb_vbus_power(unsigned phy_info, int on)
3344{
3345 int rc;
3346 static int vbus_is_on;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303347 struct pm8xxx_gpio_init_info usb_vbus = {
3348 PM8058_GPIO_PM_TO_SYS(36),
3349 {
3350 .direction = PM_GPIO_DIR_OUT,
3351 .pull = PM_GPIO_PULL_NO,
3352 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3353 .output_value = 1,
3354 .vin_sel = 2,
3355 .out_strength = PM_GPIO_STRENGTH_MED,
3356 .function = PM_GPIO_FUNC_NORMAL,
3357 .inv_int_pol = 0,
3358 },
3359 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003360
3361 /* If VBUS is already on (or off), do nothing. */
3362 if (unlikely(on == vbus_is_on))
3363 return;
3364
3365 if (on) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303366 rc = pm8xxx_gpio_config(usb_vbus.gpio, &usb_vbus.config);
3367 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003368 pr_err("%s PMIC GPIO 36 write failed\n", __func__);
3369 return;
3370 }
3371 } else {
3372 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(36), 0);
3373 }
3374
3375 vbus_is_on = on;
3376}
3377
3378static struct msm_usb_host_platform_data msm_usb_host_pdata = {
3379 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
3380 .vbus_power = msm_hsusb_vbus_power,
3381 .power_budget = 180,
3382};
3383#endif
3384
3385#ifdef CONFIG_USB_MSM_OTG_72K
3386static int hsusb_rpc_connect(int connect)
3387{
3388 if (connect)
3389 return msm_hsusb_rpc_connect();
3390 else
3391 return msm_hsusb_rpc_close();
3392}
3393#endif
3394
3395#ifdef CONFIG_USB_MSM_OTG_72K
Justin Paupore3f40f342011-08-10 18:52:16 -07003396static struct regulator *vreg_3p3;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003397static int msm_hsusb_ldo_init(int init)
3398{
3399 uint32_t version = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07003400 int def_vol = 3400000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003401
3402 version = socinfo_get_version();
3403
3404 if (SOCINFO_VERSION_MAJOR(version) >= 2 &&
3405 SOCINFO_VERSION_MINOR(version) >= 1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003406 def_vol = 3075000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003407 pr_debug("%s: default voltage:%d\n", __func__, def_vol);
3408 }
3409
3410 if (init) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003411 vreg_3p3 = regulator_get(NULL, "usb");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003412 if (IS_ERR(vreg_3p3))
3413 return PTR_ERR(vreg_3p3);
Justin Paupore3f40f342011-08-10 18:52:16 -07003414 regulator_set_voltage(vreg_3p3, def_vol, def_vol);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003415 } else
Justin Paupore3f40f342011-08-10 18:52:16 -07003416 regulator_put(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003417
3418 return 0;
3419}
3420
3421static int msm_hsusb_ldo_enable(int enable)
3422{
3423 static int ldo_status;
3424
3425 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3426 return -ENODEV;
3427
3428 if (ldo_status == enable)
3429 return 0;
3430
3431 ldo_status = enable;
3432
3433 if (enable)
Justin Paupore3f40f342011-08-10 18:52:16 -07003434 return regulator_enable(vreg_3p3);
3435 else
3436 return regulator_disable(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003437}
3438
3439static int msm_hsusb_ldo_set_voltage(int mV)
3440{
Justin Paupore3f40f342011-08-10 18:52:16 -07003441 static int cur_voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003442
3443 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3444 return -ENODEV;
3445
3446 if (cur_voltage == mV)
3447 return 0;
3448
3449 cur_voltage = mV;
3450
3451 pr_debug("%s: (%d)\n", __func__, mV);
3452
Justin Paupore3f40f342011-08-10 18:52:16 -07003453 return regulator_set_voltage(vreg_3p3, mV*1000, mV*1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003454}
3455#endif
3456
3457#ifndef CONFIG_USB_EHCI_MSM_72K
3458static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init);
3459#endif
3460static struct msm_otg_platform_data msm_otg_pdata = {
3461 .rpc_connect = hsusb_rpc_connect,
3462
3463#ifndef CONFIG_USB_EHCI_MSM_72K
3464 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
3465#else
3466 .vbus_power = msm_hsusb_vbus_power,
3467#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003468 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
3469 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
3470 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
3471 .se1_gating = SE1_GATING_DISABLE,
3472 .chg_vbus_draw = hsusb_chg_vbus_draw,
3473 .chg_connected = hsusb_chg_connected,
3474 .chg_init = hsusb_chg_init,
3475 .ldo_enable = msm_hsusb_ldo_enable,
3476 .ldo_init = msm_hsusb_ldo_init,
3477 .ldo_set_voltage = msm_hsusb_ldo_set_voltage,
3478};
3479
3480#ifdef CONFIG_USB_GADGET
3481static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
3482 .is_phy_status_timer_on = 1,
3483};
3484#endif
3485#ifndef CONFIG_USB_EHCI_MSM_72K
3486typedef void (*notify_vbus_state) (int);
3487notify_vbus_state notify_vbus_state_func_ptr;
3488int vbus_on_irq;
3489static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
3490{
3491 pr_info("%s: vbus notification from pmic\n", __func__);
3492
3493 (*notify_vbus_state_func_ptr) (1);
3494
3495 return IRQ_HANDLED;
3496}
3497static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
3498{
3499 int ret;
3500
3501 if (init) {
3502 if (!callback)
3503 return -ENODEV;
3504
3505 notify_vbus_state_func_ptr = callback;
3506 vbus_on_irq = platform_get_irq_byname(&msm_device_otg,
3507 "vbus_on");
3508 if (vbus_on_irq <= 0) {
3509 pr_err("%s: unable to get vbus on irq\n", __func__);
3510 return -ENODEV;
3511 }
3512
3513 ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq,
3514 IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
3515 if (ret < 0) {
3516 pr_info("%s: request_irq for vbus_on"
3517 "interrupt failed\n", __func__);
3518 return ret;
3519 }
3520 msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
3521 return 0;
3522 } else {
3523 free_irq(vbus_on_irq, 0);
3524 notify_vbus_state_func_ptr = NULL;
3525 return 0;
3526 }
3527}
3528#endif
3529
3530static struct android_pmem_platform_data android_pmem_pdata = {
3531 .name = "pmem",
3532 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
3533 .cached = 1,
3534 .memory_type = MEMTYPE_EBI0,
3535};
3536
3537static struct platform_device android_pmem_device = {
3538 .name = "android_pmem",
3539 .id = 0,
3540 .dev = { .platform_data = &android_pmem_pdata },
3541};
3542
3543#ifndef CONFIG_SPI_QSD
3544static int lcdc_gpio_array_num[] = {
3545 45, /* spi_clk */
3546 46, /* spi_cs */
3547 47, /* spi_mosi */
3548 48, /* spi_miso */
3549 };
3550
3551static struct msm_gpio lcdc_gpio_config_data[] = {
3552 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3553 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3554 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
3555 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3556};
3557
3558static void lcdc_config_gpios(int enable)
3559{
3560 if (enable) {
3561 msm_gpios_request_enable(lcdc_gpio_config_data,
3562 ARRAY_SIZE(
3563 lcdc_gpio_config_data));
3564 } else
3565 msm_gpios_disable_free(lcdc_gpio_config_data,
3566 ARRAY_SIZE(
3567 lcdc_gpio_config_data));
3568}
3569#endif
3570
3571static struct msm_panel_common_pdata lcdc_sharp_panel_data = {
3572#ifndef CONFIG_SPI_QSD
3573 .panel_config_gpio = lcdc_config_gpios,
3574 .gpio_num = lcdc_gpio_array_num,
3575#endif
3576 .gpio = 2, /* LPG PMIC_GPIO26 channel number */
3577};
3578
3579static struct platform_device lcdc_sharp_panel_device = {
3580 .name = "lcdc_sharp_wvga",
3581 .id = 0,
3582 .dev = {
3583 .platform_data = &lcdc_sharp_panel_data,
3584 }
3585};
3586
3587static struct msm_gpio dtv_panel_irq_gpios[] = {
3588 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
3589 "hdmi_int" },
3590};
3591
3592static struct msm_gpio dtv_panel_gpios[] = {
3593 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
3594 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
3595 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
3596 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
3597 { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
3598 { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
3599 { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
3600 { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
3601 { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
3602 { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
3603 { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
3604 { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
3605 { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
3606 { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
3607 { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
3608 { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
3609 { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
3610 { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
3611 { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
3612 { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
3613 { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
3614 { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
3615 { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
3616 { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
3617 { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
3618 { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
3619 { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
3620 { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
3621 { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
3622 { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
3623 { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
3624 { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
3625};
3626
3627
3628#ifdef HDMI_RESET
3629static unsigned dtv_reset_gpio =
3630 GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3631#endif
3632
Justin Paupore3f40f342011-08-10 18:52:16 -07003633static struct regulator_bulk_data hdmi_core_regs[] = {
3634 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3635};
3636
3637static struct regulator_bulk_data hdmi_comm_regs[] = {
3638 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3639 { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 },
3640};
3641
3642static struct regulator_bulk_data hdmi_cec_regs[] = {
3643 { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 },
3644};
3645
3646static int __init hdmi_init_regs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003647{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003648 int rc;
3649
Justin Paupore3f40f342011-08-10 18:52:16 -07003650 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs),
3651 hdmi_core_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003652
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003653 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003654 pr_err("%s: could not get %s regulators: %d\n",
3655 __func__, "core", rc);
3656 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003657 }
3658
Justin Paupore3f40f342011-08-10 18:52:16 -07003659 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs),
3660 hdmi_core_regs);
3661
3662 if (rc) {
3663 pr_err("%s: could not set %s voltages: %d\n",
3664 __func__, "core", rc);
3665 goto free_core;
3666 }
3667
3668 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs),
3669 hdmi_comm_regs);
3670
3671 if (rc) {
3672 pr_err("%s: could not get %s regulators: %d\n",
3673 __func__, "comm", rc);
3674 goto free_core;
3675 }
3676
3677 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs),
3678 hdmi_comm_regs);
3679
3680 if (rc) {
3681 pr_err("%s: could not set %s voltages: %d\n",
3682 __func__, "comm", rc);
3683 goto free_comm;
3684 }
3685
3686 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs),
3687 hdmi_cec_regs);
3688
3689 if (rc) {
3690 pr_err("%s: could not get %s regulators: %d\n",
3691 __func__, "cec", rc);
3692 goto free_comm;
3693 }
3694
3695 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs),
3696 hdmi_cec_regs);
3697
3698 if (rc) {
3699 pr_err("%s: could not set %s voltages: %d\n",
3700 __func__, "cec", rc);
3701 goto free_cec;
3702 }
3703
3704 return 0;
3705
3706free_cec:
3707 regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs);
3708free_comm:
3709 regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs);
3710free_core:
3711 regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs);
3712out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003713 return rc;
3714}
3715
Justin Paupore3f40f342011-08-10 18:52:16 -07003716static int hdmi_init_irq(void)
3717{
3718 int rc = msm_gpios_enable(dtv_panel_irq_gpios,
3719 ARRAY_SIZE(dtv_panel_irq_gpios));
3720 if (rc < 0) {
3721 pr_err("%s: gpio enable failed: %d\n", __func__, rc);
3722 return rc;
3723 }
3724 pr_info("%s\n", __func__);
3725
3726 return 0;
3727}
3728
3729static int hdmi_enable_5v(int on)
3730{
3731 int pmic_gpio_hdmi_5v_en ;
3732
3733 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
3734 machine_is_msm7x30_fluid())
3735 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
3736 else
3737 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
3738
3739 pr_info("%s: %d\n", __func__, on);
3740 if (on) {
3741 int rc;
3742 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
3743 "hdmi_5V_en");
3744 if (rc) {
3745 pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
3746 __func__);
3747 return rc;
3748 }
3749 gpio_set_value_cansleep(
3750 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
3751 } else {
3752 gpio_set_value_cansleep(
3753 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
3754 gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
3755 }
3756 return 0;
3757}
3758
3759static int hdmi_comm_power(int on, int show)
3760{
3761 if (show)
3762 pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
3763 return on ?
3764 regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs),
3765 hdmi_comm_regs) :
3766 regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs),
3767 hdmi_comm_regs);
3768}
3769
3770static int hdmi_core_power(int on, int show)
3771{
3772 if (show)
3773 pr_info("%s: %d <LDO8>\n", __func__, on);
3774 return on ?
3775 regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs),
3776 hdmi_core_regs) :
3777 regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs),
3778 hdmi_core_regs);
3779}
3780
3781static int hdmi_cec_power(int on)
3782{
3783 pr_info("%s: %d <LDO17>\n", __func__, on);
3784 return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs),
3785 hdmi_cec_regs) :
3786 regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs),
3787 hdmi_cec_regs);
3788}
3789
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003790#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
3791/* there is an i2c address conflict between adv7520 and bma150 sensor after
3792 * power up on fluid. As a solution, the default address of adv7520's packet
3793 * memory is changed as soon as possible
3794 */
3795static int __init fluid_i2c_address_fixup(void)
3796{
3797 unsigned char wBuff[16];
3798 unsigned char rBuff[16];
3799 struct i2c_msg msgs[3];
3800 int res;
3801 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003802 struct i2c_adapter *adapter;
3803
3804 if (machine_is_msm7x30_fluid()) {
3805 adapter = i2c_get_adapter(0);
3806 if (!adapter) {
3807 pr_err("%s: invalid i2c adapter\n", __func__);
3808 return PTR_ERR(adapter);
3809 }
3810
3811 /* turn on LDO8 */
Justin Paupore3f40f342011-08-10 18:52:16 -07003812 rc = hdmi_core_power(1, 0);
3813 if (rc) {
3814 pr_err("%s: could not enable hdmi core regs: %d",
3815 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003816 goto adapter_put;
3817 }
3818
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003819 /* change packet memory address to 0x74 */
3820 wBuff[0] = 0x45;
3821 wBuff[1] = 0x74;
3822
3823 msgs[0].addr = ADV7520_I2C_ADDR;
3824 msgs[0].flags = 0;
3825 msgs[0].buf = (unsigned char *) wBuff;
3826 msgs[0].len = 2;
3827
3828 res = i2c_transfer(adapter, msgs, 1);
3829 if (res != 1) {
3830 pr_err("%s: error writing adv7520\n", __func__);
3831 goto ldo8_disable;
3832 }
3833
3834 /* powerdown adv7520 using bit 6 */
3835 /* i2c read first */
3836 wBuff[0] = 0x41;
3837
3838 msgs[0].addr = ADV7520_I2C_ADDR;
3839 msgs[0].flags = 0;
3840 msgs[0].buf = (unsigned char *) wBuff;
3841 msgs[0].len = 1;
3842
3843 msgs[1].addr = ADV7520_I2C_ADDR;
3844 msgs[1].flags = I2C_M_RD;
3845 msgs[1].buf = rBuff;
3846 msgs[1].len = 1;
3847 res = i2c_transfer(adapter, msgs, 2);
3848 if (res != 2) {
3849 pr_err("%s: error reading adv7520\n", __func__);
3850 goto ldo8_disable;
3851 }
3852
3853 /* i2c write back */
3854 wBuff[0] = 0x41;
3855 wBuff[1] = rBuff[0] | 0x40;
3856
3857 msgs[0].addr = ADV7520_I2C_ADDR;
3858 msgs[0].flags = 0;
3859 msgs[0].buf = (unsigned char *) wBuff;
3860 msgs[0].len = 2;
3861
3862 res = i2c_transfer(adapter, msgs, 1);
3863 if (res != 1) {
3864 pr_err("%s: error writing adv7520\n", __func__);
3865 goto ldo8_disable;
3866 }
3867
3868 /* for successful fixup, we release the i2c adapter */
3869 /* but leave ldo8 on so that the adv7520 is not repowered */
3870 i2c_put_adapter(adapter);
3871 pr_info("%s: fluid i2c address conflict resolved\n", __func__);
3872 }
3873 return 0;
3874
3875ldo8_disable:
Justin Paupore3f40f342011-08-10 18:52:16 -07003876 hdmi_core_power(0, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003877adapter_put:
3878 i2c_put_adapter(adapter);
3879 return rc;
3880}
3881fs_initcall_sync(fluid_i2c_address_fixup);
3882#endif
3883
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003884static bool hdmi_check_hdcp_hw_support(void)
3885{
3886 if (machine_is_msm7x30_fluid())
3887 return false;
3888 else
3889 return true;
3890}
3891
3892static int dtv_panel_power(int on)
3893{
3894 int flag_on = !!on;
3895 static int dtv_power_save_on;
3896 int rc;
3897
3898 if (dtv_power_save_on == flag_on)
3899 return 0;
3900
3901 dtv_power_save_on = flag_on;
3902 pr_info("%s: %d\n", __func__, on);
3903
3904#ifdef HDMI_RESET
3905 if (on) {
3906 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
3907 rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
3908 if (rc) {
3909 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
3910 __func__, dtv_reset_gpio, rc);
3911 return rc;
3912 }
3913
3914 /* bring reset line low to hold reset*/
3915 gpio_set_value(37, 0);
3916 }
3917#endif
3918
3919 if (on) {
3920 rc = msm_gpios_enable(dtv_panel_gpios,
3921 ARRAY_SIZE(dtv_panel_gpios));
3922 if (rc < 0) {
3923 printk(KERN_ERR "%s: gpio enable failed: %d\n",
3924 __func__, rc);
3925 return rc;
3926 }
3927 } else {
3928 rc = msm_gpios_disable(dtv_panel_gpios,
3929 ARRAY_SIZE(dtv_panel_gpios));
3930 if (rc < 0) {
3931 printk(KERN_ERR "%s: gpio disable failed: %d\n",
3932 __func__, rc);
3933 return rc;
3934 }
3935 }
3936
3937 mdelay(5); /* ensure power is stable */
3938
3939#ifdef HDMI_RESET
3940 if (on) {
3941 gpio_set_value(37, 1); /* bring reset line high */
3942 mdelay(10); /* 10 msec before IO can be accessed */
3943 }
3944#endif
3945
3946 return rc;
3947}
3948
3949static struct lcdc_platform_data dtv_pdata = {
3950 .lcdc_power_save = dtv_panel_power,
3951};
3952
3953static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3954 .inject_rx_on_wakeup = 1,
3955 .rx_to_inject = 0xFD,
3956};
3957
3958static struct resource msm_fb_resources[] = {
3959 {
3960 .flags = IORESOURCE_DMA,
3961 }
3962};
3963
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08003964#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
3965static struct resource msm_v4l2_video_overlay_resources[] = {
3966 {
3967 .flags = IORESOURCE_DMA,
3968 }
3969};
3970#endif
3971
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003972static int msm_fb_detect_panel(const char *name)
3973{
3974 if (machine_is_msm7x30_fluid()) {
3975 if (!strcmp(name, "lcdc_sharp_wvga_pt"))
3976 return 0;
3977 } else {
3978 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
3979 return -EPERM;
3980 else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20))
3981 return 0;
3982 else if (!strcmp(name, "mddi_orise"))
3983 return -EPERM;
3984 else if (!strcmp(name, "mddi_quickvx"))
3985 return -EPERM;
3986 }
3987 return -ENODEV;
3988}
3989
3990static struct msm_fb_platform_data msm_fb_pdata = {
3991 .detect_client = msm_fb_detect_panel,
3992 .mddi_prescan = 1,
3993};
3994
3995static struct platform_device msm_fb_device = {
3996 .name = "msm_fb",
3997 .id = 0,
3998 .num_resources = ARRAY_SIZE(msm_fb_resources),
3999 .resource = msm_fb_resources,
4000 .dev = {
4001 .platform_data = &msm_fb_pdata,
4002 }
4003};
4004
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08004005#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
4006
4007static struct platform_device msm_v4l2_video_overlay_device = {
4008 .name = "msm_v4l2_overlay_pd",
4009 .id = 0,
4010 .num_resources = ARRAY_SIZE(msm_v4l2_video_overlay_resources),
4011 .resource = msm_v4l2_video_overlay_resources,
4012};
4013#endif
4014
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004015static struct platform_device msm_migrate_pages_device = {
4016 .name = "msm_migrate_pages",
4017 .id = -1,
4018};
4019
4020static struct android_pmem_platform_data android_pmem_adsp_pdata = {
4021 .name = "pmem_adsp",
4022 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4023 .cached = 0,
4024 .memory_type = MEMTYPE_EBI0,
4025};
4026
4027static struct android_pmem_platform_data android_pmem_audio_pdata = {
4028 .name = "pmem_audio",
4029 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4030 .cached = 0,
4031 .memory_type = MEMTYPE_EBI0,
4032};
4033
4034static struct platform_device android_pmem_adsp_device = {
4035 .name = "android_pmem",
4036 .id = 2,
4037 .dev = { .platform_data = &android_pmem_adsp_pdata },
4038};
4039
4040static struct platform_device android_pmem_audio_device = {
4041 .name = "android_pmem",
4042 .id = 4,
4043 .dev = { .platform_data = &android_pmem_audio_pdata },
4044};
4045
4046#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4047 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
4048 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4049 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4050
4051#define QCE_SIZE 0x10000
4052#define QCE_0_BASE 0xA8400000
4053
4054#define QCE_HW_KEY_SUPPORT 1
4055#define QCE_SHA_HMAC_SUPPORT 0
4056#define QCE_SHARE_CE_RESOURCE 0
4057#define QCE_CE_SHARED 0
4058
4059static struct resource qcrypto_resources[] = {
4060 [0] = {
4061 .start = QCE_0_BASE,
4062 .end = QCE_0_BASE + QCE_SIZE - 1,
4063 .flags = IORESOURCE_MEM,
4064 },
4065 [1] = {
4066 .name = "crypto_channels",
4067 .start = DMOV_CE_IN_CHAN,
4068 .end = DMOV_CE_OUT_CHAN,
4069 .flags = IORESOURCE_DMA,
4070 },
4071 [2] = {
4072 .name = "crypto_crci_in",
4073 .start = DMOV_CE_IN_CRCI,
4074 .end = DMOV_CE_IN_CRCI,
4075 .flags = IORESOURCE_DMA,
4076 },
4077 [3] = {
4078 .name = "crypto_crci_out",
4079 .start = DMOV_CE_OUT_CRCI,
4080 .end = DMOV_CE_OUT_CRCI,
4081 .flags = IORESOURCE_DMA,
4082 },
4083 [4] = {
4084 .name = "crypto_crci_hash",
4085 .start = DMOV_CE_HASH_CRCI,
4086 .end = DMOV_CE_HASH_CRCI,
4087 .flags = IORESOURCE_DMA,
4088 },
4089};
4090
4091static struct resource qcedev_resources[] = {
4092 [0] = {
4093 .start = QCE_0_BASE,
4094 .end = QCE_0_BASE + QCE_SIZE - 1,
4095 .flags = IORESOURCE_MEM,
4096 },
4097 [1] = {
4098 .name = "crypto_channels",
4099 .start = DMOV_CE_IN_CHAN,
4100 .end = DMOV_CE_OUT_CHAN,
4101 .flags = IORESOURCE_DMA,
4102 },
4103 [2] = {
4104 .name = "crypto_crci_in",
4105 .start = DMOV_CE_IN_CRCI,
4106 .end = DMOV_CE_IN_CRCI,
4107 .flags = IORESOURCE_DMA,
4108 },
4109 [3] = {
4110 .name = "crypto_crci_out",
4111 .start = DMOV_CE_OUT_CRCI,
4112 .end = DMOV_CE_OUT_CRCI,
4113 .flags = IORESOURCE_DMA,
4114 },
4115 [4] = {
4116 .name = "crypto_crci_hash",
4117 .start = DMOV_CE_HASH_CRCI,
4118 .end = DMOV_CE_HASH_CRCI,
4119 .flags = IORESOURCE_DMA,
4120 },
4121};
4122
4123#endif
4124
4125#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4126 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
4127
4128static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
4129 .ce_shared = QCE_CE_SHARED,
4130 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4131 .hw_key_support = QCE_HW_KEY_SUPPORT,
4132 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004133 /* Bus Scaling declaration*/
4134 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004135};
4136
4137static struct platform_device qcrypto_device = {
4138 .name = "qcrypto",
4139 .id = 0,
4140 .num_resources = ARRAY_SIZE(qcrypto_resources),
4141 .resource = qcrypto_resources,
4142 .dev = {
4143 .coherent_dma_mask = DMA_BIT_MASK(32),
4144 .platform_data = &qcrypto_ce_hw_suppport,
4145 },
4146};
4147#endif
4148
4149#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4150 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4151
4152static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
4153 .ce_shared = QCE_CE_SHARED,
4154 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4155 .hw_key_support = QCE_HW_KEY_SUPPORT,
4156 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004157 /* Bus Scaling declaration*/
4158 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004159};
4160static struct platform_device qcedev_device = {
4161 .name = "qce",
4162 .id = 0,
4163 .num_resources = ARRAY_SIZE(qcedev_resources),
4164 .resource = qcedev_resources,
4165 .dev = {
4166 .coherent_dma_mask = DMA_BIT_MASK(32),
4167 .platform_data = &qcedev_ce_hw_suppport,
4168 },
4169};
4170#endif
4171
4172static int mddi_toshiba_pmic_bl(int level)
4173{
4174 int ret = -EPERM;
4175
4176 ret = pmic_set_led_intensity(LED_LCD, level);
4177
4178 if (ret)
4179 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
4180 __func__);
4181 return ret;
4182}
4183
4184static struct msm_panel_common_pdata mddi_toshiba_pdata = {
4185 .pmic_backlight = mddi_toshiba_pmic_bl,
4186};
4187
4188static struct platform_device mddi_toshiba_device = {
4189 .name = "mddi_toshiba",
4190 .id = 0,
4191 .dev = {
4192 .platform_data = &mddi_toshiba_pdata,
4193 }
4194};
4195
4196static unsigned wega_reset_gpio =
4197 GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4198
4199static struct msm_gpio fluid_vee_reset_gpio[] = {
4200 { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
4201};
4202
4203static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1;
4204static unsigned char quickvx_ldo_enabled;
4205
4206static unsigned quickvx_vlp_gpio =
4207 GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4208
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304209static struct pm8xxx_gpio_init_info pmic_quickvx_clk_gpio = {
4210 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_QUICKVX_CLK),
4211 {
4212 .direction = PM_GPIO_DIR_OUT,
4213 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
4214 .output_value = 1,
4215 .pull = PM_GPIO_PULL_NO,
4216 .vin_sel = PM8058_GPIO_VIN_S3,
4217 .out_strength = PM_GPIO_STRENGTH_HIGH,
4218 .function = PM_GPIO_FUNC_2,
4219 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004220};
4221
Justin Paupore3f40f342011-08-10 18:52:16 -07004222static struct regulator *mddi_ldo20;
4223static struct regulator *mddi_ldo12;
4224static struct regulator *mddi_ldo16;
4225static struct regulator *mddi_ldo6;
4226static struct regulator *mddi_lcd;
4227
4228static int display_common_init(void)
4229{
4230 struct regulator_bulk_data regs[5] = {
4231 { .supply = "ldo20", /* voltage set in display_common_power */},
4232 { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 },
4233 { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 },
4234 { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 },
4235 { .supply = NULL, /* mddi_lcd, initialized below */ },
4236 };
4237
4238 int rc = 0;
4239
4240 if (machine_is_msm7x30_fluid()) {
4241 /* lcd: LDO8 @1.8V */
4242 regs[4].supply = "ldo8";
4243 regs[4].min_uV = 1800000;
4244 regs[4].max_uV = 1800000;
4245 } else {
4246 /* lcd: LDO15 @3.1V */
4247 regs[4].supply = "ldo15";
4248 regs[4].min_uV = 3100000;
4249 regs[4].max_uV = 3100000;
4250 }
4251
4252 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4253 if (rc) {
4254 pr_err("%s: regulator_bulk_get failed: %d\n",
4255 __func__, rc);
4256 goto bail;
4257 }
4258
4259 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4260 if (rc) {
4261 pr_err("%s: regulator_bulk_set_voltage failed: %d\n",
4262 __func__, rc);
4263 goto put_regs;
4264 }
4265
4266 mddi_ldo20 = regs[0].consumer;
4267 mddi_ldo12 = regs[1].consumer;
4268 mddi_ldo6 = regs[2].consumer;
4269 mddi_ldo16 = regs[3].consumer;
4270 mddi_lcd = regs[4].consumer;
4271
4272 return rc;
4273
4274put_regs:
4275 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4276bail:
4277 return rc;
4278}
4279
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004280static int display_common_power(int on)
4281{
4282 int rc = 0, flag_on = !!on;
4283 static int display_common_power_save_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004284 static bool display_regs_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004285
4286 if (display_common_power_save_on == flag_on)
4287 return 0;
4288
4289 display_common_power_save_on = flag_on;
4290
Justin Paupore3f40f342011-08-10 18:52:16 -07004291 if (unlikely(!display_regs_initialized)) {
4292 rc = display_common_init();
4293 if (rc) {
4294 pr_err("%s: regulator init failed: %d\n",
4295 __func__, rc);
4296 return rc;
4297 }
4298 display_regs_initialized = true;
4299 }
4300
4301
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004302 if (on) {
4303 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
4304 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
4305 if (rc) {
4306 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4307 __func__, wega_reset_gpio, rc);
4308 return rc;
4309 }
4310
4311 /* bring reset line low to hold reset*/
4312 gpio_set_value(180, 0);
4313
4314 if (quickvx_mddi_client) {
4315 /* QuickVX chip -- VLP pin -- gpio 97 */
4316 rc = gpio_tlmm_config(quickvx_vlp_gpio,
4317 GPIO_CFG_ENABLE);
4318 if (rc) {
4319 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4320 __func__, quickvx_vlp_gpio, rc);
4321 return rc;
4322 }
4323
4324 /* bring QuickVX VLP line low */
4325 gpio_set_value(97, 0);
4326
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304327 rc = pm8xxx_gpio_config(pmic_quickvx_clk_gpio.gpio,
4328 &pmic_quickvx_clk_gpio.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004329 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304330 pr_err("%s: pm8xxx_gpio_config(%#x)=%d\n",
4331 __func__, pmic_quickvx_clk_gpio.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004332 rc);
4333 return rc;
4334 }
4335
4336 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4337 PMIC_GPIO_QUICKVX_CLK), 0);
4338 }
4339 }
4340
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004341 if (quickvx_mddi_client)
Justin Paupore3f40f342011-08-10 18:52:16 -07004342 rc = regulator_set_voltage(mddi_ldo20, 1800000, 1800000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004343 else
Justin Paupore3f40f342011-08-10 18:52:16 -07004344 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000);
4345
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004346 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004347 pr_err("%s: could not set voltage for ldo20: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004348 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07004349 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004350 }
4351
4352 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004353 rc = regulator_enable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004354 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004355 pr_err("%s: LDO20 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004356 __func__, rc);
4357 return rc;
4358 }
4359
Justin Paupore3f40f342011-08-10 18:52:16 -07004360 rc = regulator_enable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004361 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004362 pr_err("%s: LDO12 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004363 __func__, rc);
4364 return rc;
4365 }
4366
4367 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004368 rc = regulator_enable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004369 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004370 pr_err("%s: LDO16 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004371 __func__, rc);
4372 return rc;
4373 }
4374 }
4375
Justin Paupore3f40f342011-08-10 18:52:16 -07004376 if (quickvx_ldo_enabled) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004377 /* Disable LDO6 during display ON */
Justin Paupore3f40f342011-08-10 18:52:16 -07004378 rc = regulator_disable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004379 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004380 pr_err("%s: LDO6 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004381 __func__, rc);
4382 return rc;
4383 }
4384 quickvx_ldo_enabled = 0;
4385 }
4386
Justin Paupore3f40f342011-08-10 18:52:16 -07004387 rc = regulator_enable(mddi_lcd);
4388 if (rc) {
4389 pr_err("%s: LCD regulator enable failed (%d)\n",
4390 __func__, rc);
4391 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004392 }
4393
4394 mdelay(5); /* ensure power is stable */
4395
4396 if (machine_is_msm7x30_fluid()) {
4397 rc = msm_gpios_request_enable(fluid_vee_reset_gpio,
4398 ARRAY_SIZE(fluid_vee_reset_gpio));
4399 if (rc)
4400 pr_err("%s gpio_request_enable failed rc=%d\n",
4401 __func__, rc);
4402 else {
4403 /* assert vee reset_n */
4404 gpio_set_value(20, 1);
4405 gpio_set_value(20, 0);
4406 mdelay(1);
4407 gpio_set_value(20, 1);
4408 }
4409 }
4410
4411 gpio_set_value(180, 1); /* bring reset line high */
4412 mdelay(10); /* 10 msec before IO can be accessed */
4413
4414 if (quickvx_mddi_client) {
4415 gpio_set_value(97, 1);
4416 msleep(2);
4417 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4418 PMIC_GPIO_QUICKVX_CLK), 1);
4419 msleep(2);
4420 }
4421
4422 rc = pmapp_display_clock_config(1);
4423 if (rc) {
4424 pr_err("%s pmapp_display_clock_config rc=%d\n",
4425 __func__, rc);
4426 return rc;
4427 }
4428
4429 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004430 rc = regulator_disable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004431 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004432 pr_err("%s: LDO20 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004433 __func__, rc);
4434 return rc;
4435 }
4436
4437
4438 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004439 rc = regulator_disable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004440 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004441 pr_err("%s: LDO16 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004442 __func__, rc);
4443 return rc;
4444 }
4445 }
4446
4447 if (quickvx_mddi_client && !quickvx_ldo_enabled) {
4448 /* Enable LDO6 during display OFF for
4449 Quicklogic chip to sleep with data retention */
Justin Paupore3f40f342011-08-10 18:52:16 -07004450 rc = regulator_enable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004451 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004452 pr_err("%s: LDO6 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004453 __func__, rc);
4454 return rc;
4455 }
4456 quickvx_ldo_enabled = 1;
4457 }
4458
4459 gpio_set_value(180, 0); /* bring reset line low */
4460
4461 if (quickvx_mddi_client) {
4462 gpio_set_value(97, 0);
4463 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4464 PMIC_GPIO_QUICKVX_CLK), 0);
4465 }
4466
Justin Paupore3f40f342011-08-10 18:52:16 -07004467 rc = regulator_disable(mddi_lcd);
4468 if (rc) {
4469 pr_err("%s: LCD regulator disable failed (%d)\n",
4470 __func__, rc);
4471 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004472 }
4473
4474 mdelay(5); /* ensure power is stable */
4475
Justin Paupore3f40f342011-08-10 18:52:16 -07004476 rc = regulator_disable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004477 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004478 pr_err("%s: LDO12 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004479 __func__, rc);
4480 return rc;
4481 }
4482
4483 if (machine_is_msm7x30_fluid()) {
4484 msm_gpios_disable_free(fluid_vee_reset_gpio,
4485 ARRAY_SIZE(fluid_vee_reset_gpio));
4486 }
4487
4488 rc = pmapp_display_clock_config(0);
4489 if (rc) {
4490 pr_err("%s pmapp_display_clock_config rc=%d\n",
4491 __func__, rc);
4492 return rc;
4493 }
4494 }
4495
4496 return rc;
4497}
4498
4499static int msm_fb_mddi_sel_clk(u32 *clk_rate)
4500{
4501 *clk_rate *= 2;
4502 return 0;
4503}
4504
4505static int msm_fb_mddi_client_power(u32 client_id)
4506{
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304507 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004508 printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
4509 /* Check if it is Quicklogic client */
4510 if (client_id == 0xc5835800) {
4511 printk(KERN_NOTICE "\n Quicklogic MDDI client");
4512 other_mddi_client = 0;
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304513 if (IS_ERR(mddi_ldo16)) {
4514 rc = PTR_ERR(mddi_ldo16);
4515 pr_err("%s: gp10 vreg get failed (%d)\n", __func__, rc);
4516 return rc;
4517 }
4518 rc = regulator_disable(mddi_ldo16);
4519 if (rc) {
4520 pr_err("%s: LDO16 vreg enable failed (%d)\n",
4521 __func__, rc);
4522 return rc;
4523 }
4524
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004525 } else {
4526 printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
4527 quickvx_mddi_client = 0;
4528 gpio_set_value(97, 0);
4529 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4530 PMIC_GPIO_QUICKVX_CLK), 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004531 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004532
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004533 return 0;
4534}
4535
4536static struct mddi_platform_data mddi_pdata = {
4537 .mddi_power_save = display_common_power,
4538 .mddi_sel_clk = msm_fb_mddi_sel_clk,
4539 .mddi_client_power = msm_fb_mddi_client_power,
4540};
4541
4542int mdp_core_clk_rate_table[] = {
4543 122880000,
4544 122880000,
Pradeep Jilagam3cc12f92011-07-26 22:25:18 +05304545 192000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004546 192000000,
4547};
4548
4549static struct msm_panel_common_pdata mdp_pdata = {
4550 .hw_revision_addr = 0xac001270,
4551 .gpio = 30,
4552 .mdp_core_clk_rate = 122880000,
4553 .mdp_core_clk_table = mdp_core_clk_rate_table,
4554 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07004555 .mdp_rev = MDP_REV_40,
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05304556 .mem_hid = MEMTYPE_EBI0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004557};
4558
4559static int lcd_panel_spi_gpio_num[] = {
4560 45, /* spi_clk */
4561 46, /* spi_cs */
4562 47, /* spi_mosi */
4563 48, /* spi_miso */
4564 };
4565
4566static struct msm_gpio lcd_panel_gpios[] = {
4567/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
4568 * input. if there is a hardware revision; we should reassign this GPIO to a
4569 * new open line; and removing it will just ensure that this will be missed in
4570 * the future.
4571 { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
4572 */
4573 { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
4574 { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
4575 { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
4576 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4577 { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
4578 { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
4579 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4580#ifndef CONFIG_SPI_QSD
4581 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
4582 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
4583 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
4584 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
4585#endif
4586 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4587 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4588 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4589 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4590 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4591 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4592 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4593 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4594 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4595 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4596 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4597 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4598 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4599 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4600 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4601 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4602 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4603 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4604 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4605 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4606};
4607
4608static struct msm_gpio lcd_sharp_panel_gpios[] = {
4609 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4610 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4611 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4612 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4613 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4614 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4615 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4616 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4617 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4618 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4619 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4620 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4621 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4622 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4623 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4624 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4625 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4626 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4627 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4628 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4629 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4630 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4631};
4632
4633static int lcdc_toshiba_panel_power(int on)
4634{
4635 int rc, i;
4636 struct msm_gpio *gp;
4637
4638 rc = display_common_power(on);
4639 if (rc < 0) {
4640 printk(KERN_ERR "%s display_common_power failed: %d\n",
4641 __func__, rc);
4642 return rc;
4643 }
4644
4645 if (on) {
4646 rc = msm_gpios_enable(lcd_panel_gpios,
4647 ARRAY_SIZE(lcd_panel_gpios));
4648 if (rc < 0) {
4649 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4650 __func__, rc);
4651 }
4652 } else { /* off */
4653 gp = lcd_panel_gpios;
4654 for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
4655 /* ouput low */
4656 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4657 gp++;
4658 }
4659 }
4660
4661 return rc;
4662}
4663
4664static int lcdc_sharp_panel_power(int on)
4665{
4666 int rc, i;
4667 struct msm_gpio *gp;
4668
4669 rc = display_common_power(on);
4670 if (rc < 0) {
4671 printk(KERN_ERR "%s display_common_power failed: %d\n",
4672 __func__, rc);
4673 return rc;
4674 }
4675
4676 if (on) {
4677 rc = msm_gpios_enable(lcd_sharp_panel_gpios,
4678 ARRAY_SIZE(lcd_sharp_panel_gpios));
4679 if (rc < 0) {
4680 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4681 __func__, rc);
4682 }
4683 } else { /* off */
4684 gp = lcd_sharp_panel_gpios;
4685 for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) {
4686 /* ouput low */
4687 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4688 gp++;
4689 }
4690 }
4691
4692 return rc;
4693}
4694
4695static int lcdc_panel_power(int on)
4696{
4697 int flag_on = !!on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004698 static int lcdc_power_save_on, lcdc_power_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004699
4700 if (lcdc_power_save_on == flag_on)
4701 return 0;
4702
4703 lcdc_power_save_on = flag_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004704
4705 if (unlikely(!lcdc_power_initialized)) {
4706 quickvx_mddi_client = 0;
4707 display_common_init();
4708 lcdc_power_initialized = 1;
4709 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004710
4711 if (machine_is_msm7x30_fluid())
4712 return lcdc_sharp_panel_power(on);
4713 else
4714 return lcdc_toshiba_panel_power(on);
4715}
4716
4717static struct lcdc_platform_data lcdc_pdata = {
4718 .lcdc_power_save = lcdc_panel_power,
4719};
4720
Justin Paupore3f40f342011-08-10 18:52:16 -07004721static struct regulator *atv_s4, *atv_ldo9;
4722
4723static int __init atv_dac_power_init(void)
4724{
4725 int rc;
4726 struct regulator_bulk_data regs[] = {
4727 { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 },
4728 { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 },
4729 };
4730
4731 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4732
4733 if (rc) {
4734 pr_err("%s: could not get regulators: %d\n", __func__, rc);
4735 goto bail;
4736 }
4737
4738 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4739
4740 if (rc) {
4741 pr_err("%s: could not set voltages: %d\n", __func__, rc);
4742 goto reg_free;
4743 }
4744
4745 atv_s4 = regs[0].consumer;
4746 atv_ldo9 = regs[1].consumer;
4747
4748reg_free:
4749 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4750bail:
4751 return rc;
4752}
4753
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004754static int atv_dac_power(int on)
4755{
4756 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004757
4758 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004759 rc = regulator_enable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004760 if (rc) {
4761 pr_err("%s: s4 vreg enable failed (%d)\n",
4762 __func__, rc);
4763 return rc;
4764 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004765 rc = regulator_enable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004766 if (rc) {
4767 pr_err("%s: ldo9 vreg enable failed (%d)\n",
4768 __func__, rc);
4769 return rc;
4770 }
4771 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004772 rc = regulator_disable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004773 if (rc) {
4774 pr_err("%s: ldo9 vreg disable failed (%d)\n",
4775 __func__, rc);
4776 return rc;
4777 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004778 rc = regulator_disable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004779 if (rc) {
4780 pr_err("%s: s4 vreg disable failed (%d)\n",
4781 __func__, rc);
4782 return rc;
4783 }
4784 }
4785 return rc;
4786}
4787
4788static struct tvenc_platform_data atv_pdata = {
4789 .poll = 1,
4790 .pm_vid_en = atv_dac_power,
4791};
4792
4793static void __init msm_fb_add_devices(void)
4794{
4795 msm_fb_register_device("mdp", &mdp_pdata);
4796 msm_fb_register_device("pmdh", &mddi_pdata);
4797 msm_fb_register_device("lcdc", &lcdc_pdata);
4798 msm_fb_register_device("dtv", &dtv_pdata);
4799 msm_fb_register_device("tvenc", &atv_pdata);
4800#ifdef CONFIG_FB_MSM_TVOUT
4801 msm_fb_register_device("tvout_device", NULL);
4802#endif
4803}
4804
4805static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
4806 .gpio_num = lcd_panel_spi_gpio_num,
4807};
4808
4809static struct platform_device lcdc_toshiba_panel_device = {
4810 .name = "lcdc_toshiba_wvga",
4811 .id = 0,
4812 .dev = {
4813 .platform_data = &lcdc_toshiba_panel_data,
4814 }
4815};
4816
4817#if defined(CONFIG_MARIMBA_CORE) && \
4818 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4819static struct platform_device msm_bt_power_device = {
4820 .name = "bt_power",
4821 .id = -1
4822};
4823
4824enum {
4825 BT_RFR,
4826 BT_CTS,
4827 BT_RX,
4828 BT_TX,
4829};
4830
4831static struct msm_gpio bt_config_power_on[] = {
4832 { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4833 "UART1DM_RFR" },
4834 { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4835 "UART1DM_CTS" },
4836 { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4837 "UART1DM_Rx" },
4838 { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4839 "UART1DM_Tx" }
4840};
4841
4842static struct msm_gpio bt_config_power_off[] = {
4843 { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4844 "UART1DM_RFR" },
4845 { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4846 "UART1DM_CTS" },
4847 { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4848 "UART1DM_Rx" },
4849 { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4850 "UART1DM_Tx" }
4851};
4852
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004853static u8 bahama_version;
4854
Justin Paupore3f40f342011-08-10 18:52:16 -07004855static struct regulator_bulk_data regs_bt_marimba[] = {
4856 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4857 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
4858 { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304859 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004860};
4861
4862static struct regulator_bulk_data regs_bt_bahama_v1[] = {
4863 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4864 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
4865 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304866 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004867};
4868
4869static struct regulator_bulk_data regs_bt_bahama_v2[] = {
4870 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4871 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304872 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004873};
4874
4875static struct regulator_bulk_data *regs_bt;
4876static int regs_bt_count;
4877
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004878static int marimba_bt(int on)
4879{
4880 int rc;
4881 int i;
4882 struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
4883
4884 struct marimba_config_register {
4885 u8 reg;
4886 u8 value;
4887 u8 mask;
4888 };
4889
4890 struct marimba_variant_register {
4891 const size_t size;
4892 const struct marimba_config_register *set;
4893 };
4894
4895 const struct marimba_config_register *p;
4896
4897 u8 version;
4898
4899 const struct marimba_config_register v10_bt_on[] = {
4900 { 0xE5, 0x0B, 0x0F },
4901 { 0x05, 0x02, 0x07 },
4902 { 0x06, 0x88, 0xFF },
4903 { 0xE7, 0x21, 0x21 },
4904 { 0xE3, 0x38, 0xFF },
4905 { 0xE4, 0x06, 0xFF },
4906 };
4907
4908 const struct marimba_config_register v10_bt_off[] = {
4909 { 0xE5, 0x0B, 0x0F },
4910 { 0x05, 0x08, 0x0F },
4911 { 0x06, 0x88, 0xFF },
4912 { 0xE7, 0x00, 0x21 },
4913 { 0xE3, 0x00, 0xFF },
4914 { 0xE4, 0x00, 0xFF },
4915 };
4916
4917 const struct marimba_config_register v201_bt_on[] = {
4918 { 0x05, 0x08, 0x07 },
4919 { 0x06, 0x88, 0xFF },
4920 { 0xE7, 0x21, 0x21 },
4921 { 0xE3, 0x38, 0xFF },
4922 { 0xE4, 0x06, 0xFF },
4923 };
4924
4925 const struct marimba_config_register v201_bt_off[] = {
4926 { 0x05, 0x08, 0x07 },
4927 { 0x06, 0x88, 0xFF },
4928 { 0xE7, 0x00, 0x21 },
4929 { 0xE3, 0x00, 0xFF },
4930 { 0xE4, 0x00, 0xFF },
4931 };
4932
4933 const struct marimba_config_register v210_bt_on[] = {
4934 { 0xE9, 0x01, 0x01 },
4935 { 0x06, 0x88, 0xFF },
4936 { 0xE7, 0x21, 0x21 },
4937 { 0xE3, 0x38, 0xFF },
4938 { 0xE4, 0x06, 0xFF },
4939 };
4940
4941 const struct marimba_config_register v210_bt_off[] = {
4942 { 0x06, 0x88, 0xFF },
4943 { 0xE7, 0x00, 0x21 },
4944 { 0xE9, 0x00, 0x01 },
4945 { 0xE3, 0x00, 0xFF },
4946 { 0xE4, 0x00, 0xFF },
4947 };
4948
4949 const struct marimba_variant_register bt_marimba[2][4] = {
4950 {
4951 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4952 { 0, NULL },
4953 { ARRAY_SIZE(v201_bt_off), v201_bt_off },
4954 { ARRAY_SIZE(v210_bt_off), v210_bt_off }
4955 },
4956 {
4957 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4958 { 0, NULL },
4959 { ARRAY_SIZE(v201_bt_on), v201_bt_on },
4960 { ARRAY_SIZE(v210_bt_on), v210_bt_on }
4961 }
4962 };
4963
4964 on = on ? 1 : 0;
4965
4966 rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F);
4967 if (rc < 0) {
4968 printk(KERN_ERR
4969 "%s: version read failed: %d\n",
4970 __func__, rc);
4971 return rc;
4972 }
4973
4974 if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
4975 (bt_marimba[on][version].size == 0)) {
4976 printk(KERN_ERR
4977 "%s: unsupported version\n",
4978 __func__);
4979 return -EIO;
4980 }
4981
4982 p = bt_marimba[on][version].set;
4983
4984 printk(KERN_INFO "%s: found version %d\n", __func__, version);
4985
4986 for (i = 0; i < bt_marimba[on][version].size; i++) {
4987 u8 value = (p+i)->value;
4988 rc = marimba_write_bit_mask(&config,
4989 (p+i)->reg,
4990 &value,
4991 sizeof((p+i)->value),
4992 (p+i)->mask);
4993 if (rc < 0) {
4994 printk(KERN_ERR
4995 "%s: reg %d write failed: %d\n",
4996 __func__, (p+i)->reg, rc);
4997 return rc;
4998 }
4999 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
5000 __func__, (p+i)->reg,
5001 value, (p+i)->mask);
5002 }
5003 return 0;
5004}
5005
5006static int bahama_bt(int on)
5007{
5008 int rc;
5009 int i;
5010 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
5011
5012 struct bahama_variant_register {
5013 const size_t size;
5014 const struct bahama_config_register *set;
5015 };
5016
5017 const struct bahama_config_register *p;
5018
5019
5020 const struct bahama_config_register v10_bt_on[] = {
5021 { 0xE9, 0x00, 0xFF },
5022 { 0xF4, 0x80, 0xFF },
5023 { 0xF0, 0x06, 0xFF },
5024 { 0xE4, 0x00, 0xFF },
5025 { 0xE5, 0x00, 0x0F },
5026#ifdef CONFIG_WLAN
5027 { 0xE6, 0x38, 0x7F },
5028 { 0xE7, 0x06, 0xFF },
5029#endif
5030 { 0x11, 0x13, 0xFF },
5031 { 0xE9, 0x21, 0xFF },
5032 { 0x01, 0x0C, 0x1F },
5033 { 0x01, 0x08, 0x1F },
5034 };
5035
5036 const struct bahama_config_register v20_bt_on_fm_off[] = {
5037 { 0x11, 0x0C, 0xFF },
5038 { 0x13, 0x01, 0xFF },
5039 { 0xF4, 0x80, 0xFF },
5040 { 0xF0, 0x00, 0xFF },
5041 { 0xE9, 0x00, 0xFF },
5042#ifdef CONFIG_WLAN
5043 { 0x81, 0x00, 0xFF },
5044 { 0x82, 0x00, 0xFF },
5045 { 0xE6, 0x38, 0x7F },
5046 { 0xE7, 0x06, 0xFF },
5047#endif
5048 { 0xE9, 0x21, 0xFF }
5049 };
5050
5051 const struct bahama_config_register v20_bt_on_fm_on[] = {
5052 { 0x11, 0x0C, 0xFF },
5053 { 0x13, 0x01, 0xFF },
5054 { 0xF4, 0x86, 0xFF },
5055 { 0xF0, 0x06, 0xFF },
5056 { 0xE9, 0x00, 0xFF },
5057#ifdef CONFIG_WLAN
5058 { 0x81, 0x00, 0xFF },
5059 { 0x82, 0x00, 0xFF },
5060 { 0xE6, 0x38, 0x7F },
5061 { 0xE7, 0x06, 0xFF },
5062#endif
5063 { 0xE9, 0x21, 0xFF }
5064 };
5065
5066 const struct bahama_config_register v10_bt_off[] = {
5067 { 0xE9, 0x00, 0xFF },
5068 };
5069
5070 const struct bahama_config_register v20_bt_off_fm_off[] = {
5071 { 0xF4, 0x84, 0xFF },
5072 { 0xF0, 0x04, 0xFF },
5073 { 0xE9, 0x00, 0xFF }
5074 };
5075
5076 const struct bahama_config_register v20_bt_off_fm_on[] = {
5077 { 0xF4, 0x86, 0xFF },
5078 { 0xF0, 0x06, 0xFF },
5079 { 0xE9, 0x00, 0xFF }
5080 };
5081
5082 const struct bahama_variant_register bt_bahama[2][3] = {
5083 {
5084 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
5085 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
5086 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
5087 },
5088 {
5089 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
5090 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
5091 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
5092 }
5093 };
5094
5095 u8 offset = 0; /* index into bahama configs */
5096
5097 on = on ? 1 : 0;
5098
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005099
5100 if (bahama_version == VER_2_0) {
5101 if (marimba_get_fm_status(&config))
5102 offset = 0x01;
5103 }
5104
5105 p = bt_bahama[on][bahama_version + offset].set;
5106
5107 dev_info(&msm_bt_power_device.dev,
5108 "%s: found version %d\n", __func__, bahama_version);
5109
5110 for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
5111 u8 value = (p+i)->value;
5112 rc = marimba_write_bit_mask(&config,
5113 (p+i)->reg,
5114 &value,
5115 sizeof((p+i)->value),
5116 (p+i)->mask);
5117 if (rc < 0) {
5118 dev_err(&msm_bt_power_device.dev,
5119 "%s: reg %d write failed: %d\n",
5120 __func__, (p+i)->reg, rc);
5121 return rc;
5122 }
5123 dev_info(&msm_bt_power_device.dev,
5124 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
5125 __func__, (p+i)->reg,
5126 value, (p+i)->mask);
5127 }
5128 /* Update BT status */
5129 if (on)
5130 marimba_set_bt_status(&config, true);
5131 else
5132 marimba_set_bt_status(&config, false);
5133
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005134 return 0;
5135}
5136
Justin Paupore3f40f342011-08-10 18:52:16 -07005137static int bluetooth_regs_init(int bahama_not_marimba)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005138{
Justin Paupore3f40f342011-08-10 18:52:16 -07005139 int rc = 0;
5140 struct device *const dev = &msm_bt_power_device.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005141
5142 if (bahama_not_marimba) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005143 bahama_version = read_bahama_ver();
5144
5145 switch (bahama_version) {
5146 case VER_1_0:
5147 regs_bt = regs_bt_bahama_v1;
5148 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1);
5149 break;
5150 case VER_2_0:
5151 regs_bt = regs_bt_bahama_v2;
5152 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2);
5153 break;
5154 case VER_UNSUPPORTED:
5155 default:
5156 dev_err(dev,
5157 "%s: i2c failure or unsupported version: %d\n",
5158 __func__, bahama_version);
5159 rc = -EIO;
5160 goto out;
5161 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005162 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07005163 regs_bt = regs_bt_marimba;
5164 regs_bt_count = ARRAY_SIZE(regs_bt_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005165 }
5166
Justin Paupore3f40f342011-08-10 18:52:16 -07005167 rc = regulator_bulk_get(&msm_bt_power_device.dev,
5168 regs_bt_count, regs_bt);
5169 if (rc) {
5170 dev_err(dev, "%s: could not get regulators: %d\n",
5171 __func__, rc);
5172 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005173 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005174
5175 rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt);
5176 if (rc) {
5177 dev_err(dev, "%s: could not set voltages: %d\n",
5178 __func__, rc);
5179 goto reg_free;
5180 }
5181
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005182 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005183
5184reg_free:
5185 regulator_bulk_free(regs_bt_count, regs_bt);
5186out:
5187 regs_bt_count = 0;
5188 regs_bt = NULL;
5189 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005190}
5191
5192static int bluetooth_power(int on)
5193{
5194 int rc;
5195 const char *id = "BTPW";
5196
5197 int bahama_not_marimba = bahama_present();
5198
5199 if (bahama_not_marimba == -1) {
5200 printk(KERN_WARNING "%s: bahama_present: %d\n",
5201 __func__, bahama_not_marimba);
5202 return -ENODEV;
5203 }
5204
Justin Paupore3f40f342011-08-10 18:52:16 -07005205 if (unlikely(regs_bt_count == 0)) {
5206 rc = bluetooth_regs_init(bahama_not_marimba);
5207 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005208 return rc;
Justin Paupore3f40f342011-08-10 18:52:16 -07005209 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005210
Justin Paupore3f40f342011-08-10 18:52:16 -07005211 if (on) {
5212 rc = regulator_bulk_enable(regs_bt_count, regs_bt);
5213 if (rc)
5214 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005215
5216 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5217 PMAPP_CLOCK_VOTE_ON);
5218 if (rc < 0)
5219 return -EIO;
5220
5221 if (machine_is_msm8x55_svlte_surf() ||
5222 machine_is_msm8x55_svlte_ffa()) {
5223 rc = marimba_gpio_config(1);
5224 if (rc < 0)
5225 return -EIO;
5226 }
5227
5228 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5229 if (rc < 0)
5230 return -EIO;
5231
5232 msleep(10);
5233
5234 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5235 PMAPP_CLOCK_VOTE_PIN_CTRL);
5236 if (rc < 0)
5237 return -EIO;
5238
5239 if (machine_is_msm8x55_svlte_surf() ||
5240 machine_is_msm8x55_svlte_ffa()) {
5241 rc = marimba_gpio_config(0);
5242 if (rc < 0)
5243 return -EIO;
5244 }
5245
5246 rc = msm_gpios_enable(bt_config_power_on,
5247 ARRAY_SIZE(bt_config_power_on));
5248
5249 if (rc < 0)
5250 return rc;
5251
5252 } else {
5253 rc = msm_gpios_enable(bt_config_power_off,
5254 ARRAY_SIZE(bt_config_power_off));
5255 if (rc < 0)
5256 return rc;
5257
5258 /* check for initial RFKILL block (power off) */
5259 if (platform_get_drvdata(&msm_bt_power_device) == NULL)
5260 goto out;
5261
5262 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5263 if (rc < 0)
5264 return -EIO;
5265
5266 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5267 PMAPP_CLOCK_VOTE_OFF);
5268 if (rc < 0)
5269 return -EIO;
5270
Justin Paupore3f40f342011-08-10 18:52:16 -07005271 rc = regulator_bulk_disable(regs_bt_count, regs_bt);
5272 if (rc)
5273 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005274
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005275 }
5276
5277out:
5278 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
5279
5280 return 0;
5281}
5282
5283static void __init bt_power_init(void)
5284{
Justin Paupore3f40f342011-08-10 18:52:16 -07005285 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005286}
5287#else
5288#define bt_power_init(x) do {} while (0)
5289#endif
5290
5291static struct msm_psy_batt_pdata msm_psy_batt_data = {
5292 .voltage_min_design = 2800,
5293 .voltage_max_design = 4300,
5294 .avail_chg_sources = AC_CHG | USB_CHG ,
5295 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
5296};
5297
5298static struct platform_device msm_batt_device = {
5299 .name = "msm-battery",
5300 .id = -1,
5301 .dev.platform_data = &msm_psy_batt_data,
5302};
5303
5304static char *msm_adc_fluid_device_names[] = {
5305 "LTC_ADC1",
5306 "LTC_ADC2",
5307 "LTC_ADC3",
5308};
5309
5310static char *msm_adc_surf_device_names[] = {
5311 "XO_ADC",
5312};
5313
5314static struct msm_adc_platform_data msm_adc_pdata;
5315
5316static struct platform_device msm_adc_device = {
5317 .name = "msm_adc",
5318 .id = -1,
5319 .dev = {
5320 .platform_data = &msm_adc_pdata,
5321 },
5322};
5323
5324#ifdef CONFIG_MSM_SDIO_AL
5325static struct msm_gpio mdm2ap_status = {
5326 GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5327 "mdm2ap_status"
5328};
5329
5330
5331static int configure_mdm2ap_status(int on)
5332{
5333 if (on)
5334 return msm_gpios_request_enable(&mdm2ap_status, 1);
5335 else {
5336 msm_gpios_disable_free(&mdm2ap_status, 1);
5337 return 0;
5338 }
5339}
5340
5341static int get_mdm2ap_status(void)
5342{
5343 return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
5344}
5345
5346static struct sdio_al_platform_data sdio_al_pdata = {
5347 .config_mdm2ap_status = configure_mdm2ap_status,
5348 .get_mdm2ap_status = get_mdm2ap_status,
5349 .allow_sdioc_version_major_2 = 1,
5350 .peer_sdioc_version_minor = 0x0001,
5351 .peer_sdioc_version_major = 0x0003,
5352 .peer_sdioc_boot_version_minor = 0x0001,
5353 .peer_sdioc_boot_version_major = 0x0003,
5354};
5355
5356struct platform_device msm_device_sdio_al = {
5357 .name = "msm_sdio_al",
5358 .id = -1,
5359 .dev = {
5360 .platform_data = &sdio_al_pdata,
5361 },
5362};
5363
5364#endif /* CONFIG_MSM_SDIO_AL */
5365
Daniel Walker8d747cd2010-02-25 11:37:43 -08005366static struct platform_device *devices[] __initdata = {
Daniel Walker90e37c52010-05-12 14:24:15 -07005367#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005368 &msm_device_uart2,
5369#endif
Justin Paupore637a25d2011-07-14 17:11:04 -07005370#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
5371 &msm_proccomm_regulator_dev,
5372#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005373 &asoc_msm_pcm,
5374 &asoc_msm_dai0,
5375 &asoc_msm_dai1,
5376#if defined (CONFIG_SND_MSM_MVS_DAI_SOC)
5377 &asoc_msm_mvs,
5378 &asoc_mvs_dai0,
5379 &asoc_mvs_dai1,
Daniel Walker90e37c52010-05-12 14:24:15 -07005380#endif
Niranjana Vishwanathapuraa8855e92010-10-06 13:52:10 -07005381 &msm_device_smd,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005382 &msm_device_dmov,
5383 &smc91x_device,
5384 &smsc911x_device,
5385 &msm_device_nand,
5386#ifdef CONFIG_USB_MSM_OTG_72K
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05305387 &msm_device_otg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005388#ifdef CONFIG_USB_GADGET
5389 &msm_device_gadget_peripheral,
5390#endif
5391#endif
5392#ifdef CONFIG_USB_G_ANDROID
5393 &android_usb_device,
5394#endif
5395 &qsd_device_spi,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305396
5397#ifdef CONFIG_MSM_SSBI
5398 &msm_device_ssbi_pmic1,
5399#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005400#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005401 &msm_device_ssbi7,
5402#endif
5403 &android_pmem_device,
5404 &msm_fb_device,
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08005405#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
5406 &msm_v4l2_video_overlay_device,
5407#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005408 &msm_migrate_pages_device,
5409 &mddi_toshiba_device,
5410 &lcdc_toshiba_panel_device,
5411#ifdef CONFIG_MSM_ROTATOR
5412 &msm_rotator_device,
5413#endif
5414 &lcdc_sharp_panel_device,
5415 &android_pmem_adsp_device,
5416 &android_pmem_audio_device,
5417 &msm_device_i2c,
5418 &msm_device_i2c_2,
5419 &msm_device_uart_dm1,
5420 &hs_device,
5421#ifdef CONFIG_MSM7KV2_AUDIO
5422 &msm_aictl_device,
5423 &msm_mi2s_device,
5424 &msm_lpa_device,
5425 &msm_aux_pcm_device,
5426#endif
5427 &msm_device_adspdec,
5428 &qup_device_i2c,
5429#if defined(CONFIG_MARIMBA_CORE) && \
5430 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5431 &msm_bt_power_device,
5432#endif
5433 &msm_kgsl_3d0,
5434 &msm_kgsl_2d0,
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005435#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005436#ifdef CONFIG_MT9T013
5437 &msm_camera_sensor_mt9t013,
5438#endif
5439#ifdef CONFIG_MT9D112
5440 &msm_camera_sensor_mt9d112,
5441#endif
5442#ifdef CONFIG_WEBCAM_OV9726
5443 &msm_camera_sensor_ov9726,
5444#endif
5445#ifdef CONFIG_S5K3E2FX
5446 &msm_camera_sensor_s5k3e2fx,
5447#endif
5448#ifdef CONFIG_MT9P012
5449 &msm_camera_sensor_mt9p012,
5450#endif
5451#ifdef CONFIG_MT9E013
5452 &msm_camera_sensor_mt9e013,
5453#endif
5454#ifdef CONFIG_VX6953
5455 &msm_camera_sensor_vx6953,
5456#endif
5457#ifdef CONFIG_SN12M0PZ
5458 &msm_camera_sensor_sn12m0pz,
5459#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005460#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005461 &msm_device_vidc_720p,
5462#ifdef CONFIG_MSM_GEMINI
5463 &msm_gemini_device,
5464#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005465#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005466#ifdef CONFIG_MSM_VPE
5467 &msm_vpe_device,
5468#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005469#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005470#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5471 &msm_device_tsif,
5472#endif
5473#ifdef CONFIG_MSM_SDIO_AL
5474 &msm_device_sdio_al,
5475#endif
5476
5477#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5478 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5479 &qcrypto_device,
5480#endif
5481
5482#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5483 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5484 &qcedev_device,
5485#endif
5486
5487 &msm_batt_device,
5488 &msm_adc_device,
5489 &msm_ebi0_thermal,
Laxminath Kasam1d8255d2012-02-15 13:10:19 +05305490 &msm_ebi1_thermal,
Chintan Pandya03b698a2012-06-28 19:03:09 +05305491 &msm_adsp_device,
5492#ifdef CONFIG_ION_MSM
5493 &ion_dev,
5494#endif
Daniel Walker8d747cd2010-02-25 11:37:43 -08005495};
5496
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005497static struct msm_gpio msm_i2c_gpios_hw[] = {
5498 { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5499 { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5500};
5501
5502static struct msm_gpio msm_i2c_gpios_io[] = {
5503 { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5504 { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5505};
5506
5507static struct msm_gpio qup_i2c_gpios_io[] = {
5508 { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5509 { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5510};
5511static struct msm_gpio qup_i2c_gpios_hw[] = {
5512 { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5513 { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5514};
5515
5516static void
5517msm_i2c_gpio_config(int adap_id, int config_type)
5518{
5519 struct msm_gpio *msm_i2c_table;
5520
5521 /* Each adapter gets 2 lines from the table */
5522 if (adap_id > 0)
5523 return;
5524 if (config_type)
5525 msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
5526 else
5527 msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
5528 msm_gpios_enable(msm_i2c_table, 2);
5529}
5530/*This needs to be enabled only for OEMS*/
5531#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005532static struct regulator *qup_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005533#endif
5534static void
5535qup_i2c_gpio_config(int adap_id, int config_type)
5536{
5537 int rc = 0;
5538 struct msm_gpio *qup_i2c_table;
5539 /* Each adapter gets 2 lines from the table */
5540 if (adap_id != 4)
5541 return;
5542 if (config_type)
5543 qup_i2c_table = qup_i2c_gpios_hw;
5544 else
5545 qup_i2c_table = qup_i2c_gpios_io;
5546 rc = msm_gpios_enable(qup_i2c_table, 2);
5547 if (rc < 0)
5548 printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
5549 /*This needs to be enabled only for OEMS*/
5550#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005551 if (!IS_ERR_OR_NULL(qup_vreg)) {
5552 rc = regulator_enable(qup_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005553 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005554 pr_err("%s: regulator_enable failed: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005555 __func__, rc);
5556 }
5557 }
5558#endif
5559}
5560
5561static struct msm_i2c_platform_data msm_i2c_pdata = {
5562 .clk_freq = 100000,
5563 .pri_clk = 70,
5564 .pri_dat = 71,
5565 .rmutex = 1,
5566 .rsl_id = "D:I2C02000021",
5567 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5568};
5569
5570static void __init msm_device_i2c_init(void)
5571{
5572 if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
5573 pr_err("failed to request I2C gpios\n");
5574
5575 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
5576}
5577
5578static struct msm_i2c_platform_data msm_i2c_2_pdata = {
5579 .clk_freq = 100000,
5580 .rmutex = 1,
5581 .rsl_id = "D:I2C02000022",
5582 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5583};
5584
5585static void __init msm_device_i2c_2_init(void)
5586{
5587 msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
5588}
5589
5590static struct msm_i2c_platform_data qup_i2c_pdata = {
5591 .clk_freq = 384000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005592 .msm_i2c_config_gpio = qup_i2c_gpio_config,
5593};
5594
5595static void __init qup_device_i2c_init(void)
5596{
5597 if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
5598 pr_err("failed to request I2C gpios\n");
5599
5600 qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
5601 /*This needs to be enabled only for OEMS*/
5602#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005603 qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005604 if (IS_ERR(qup_vreg)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005605 dev_err(&qup_device_i2c.dev,
5606 "%s: regulator_get failed: %ld\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005607 __func__, PTR_ERR(qup_vreg));
5608 }
5609#endif
5610}
5611
5612#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005613static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = {
5614 .rsl_id = "D:CODEC_SSBI",
5615 .controller_type = MSM_SBI_CTRL_SSBI,
5616};
5617#endif
5618
Daniel Walker8d747cd2010-02-25 11:37:43 -08005619static void __init msm7x30_init_irq(void)
5620{
5621 msm_init_irq();
5622}
5623
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005624static struct msm_gpio msm_nand_ebi2_cfg_data[] = {
5625 {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
5626 {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
5627};
5628
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005629#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
5630 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
5631 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
5632 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
5633
5634struct sdcc_gpio {
5635 struct msm_gpio *cfg_data;
5636 uint32_t size;
5637 struct msm_gpio *sleep_cfg_data;
5638};
5639#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5640static struct msm_gpio sdc1_lvlshft_cfg_data[] = {
5641 {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
5642};
5643#endif
5644static struct msm_gpio sdc1_cfg_data[] = {
5645 {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
5646 {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
5647 {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
5648 {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
5649 {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
5650 {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
5651};
5652
5653static struct msm_gpio sdc2_cfg_data[] = {
5654 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
5655 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
5656 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
5657 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
5658 {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
5659 {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
5660
5661#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5662 {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
5663 {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
5664 {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
5665 {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
5666#endif
5667};
5668
5669static struct msm_gpio sdc3_cfg_data[] = {
5670 {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
5671 {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
5672 {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
5673 {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
5674 {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
5675 {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
5676};
5677
5678static struct msm_gpio sdc3_sleep_cfg_data[] = {
5679 {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5680 "sdc3_clk"},
5681 {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5682 "sdc3_cmd"},
5683 {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5684 "sdc3_dat_3"},
5685 {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5686 "sdc3_dat_2"},
5687 {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5688 "sdc3_dat_1"},
5689 {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5690 "sdc3_dat_0"},
5691};
5692
5693static struct msm_gpio sdc4_cfg_data[] = {
5694 {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
5695 {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
5696 {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
5697 {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
5698 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
5699 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
5700};
5701
5702static struct sdcc_gpio sdcc_cfg_data[] = {
5703 {
5704 .cfg_data = sdc1_cfg_data,
5705 .size = ARRAY_SIZE(sdc1_cfg_data),
5706 .sleep_cfg_data = NULL,
5707 },
5708 {
5709 .cfg_data = sdc2_cfg_data,
5710 .size = ARRAY_SIZE(sdc2_cfg_data),
5711 .sleep_cfg_data = NULL,
5712 },
5713 {
5714 .cfg_data = sdc3_cfg_data,
5715 .size = ARRAY_SIZE(sdc3_cfg_data),
5716 .sleep_cfg_data = sdc3_sleep_cfg_data,
5717 },
5718 {
5719 .cfg_data = sdc4_cfg_data,
5720 .size = ARRAY_SIZE(sdc4_cfg_data),
5721 .sleep_cfg_data = NULL,
5722 },
5723};
5724
Justin Paupore3f40f342011-08-10 18:52:16 -07005725static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005726
5727static unsigned long vreg_sts, gpio_sts;
5728
5729static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
5730{
5731 int rc = 0;
5732 struct sdcc_gpio *curr;
5733
5734 curr = &sdcc_cfg_data[dev_id - 1];
5735
5736 if (!(test_bit(dev_id, &gpio_sts)^enable))
5737 return rc;
5738
5739 if (enable) {
5740 set_bit(dev_id, &gpio_sts);
5741 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
5742 if (rc)
5743 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
5744 __func__, dev_id);
5745 } else {
5746 clear_bit(dev_id, &gpio_sts);
5747 if (curr->sleep_cfg_data) {
5748 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
5749 msm_gpios_free(curr->sleep_cfg_data, curr->size);
5750 } else {
5751 msm_gpios_disable_free(curr->cfg_data, curr->size);
5752 }
5753 }
5754
5755 return rc;
5756}
5757
5758static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
5759{
5760 int rc = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005761 struct regulator *curr = sdcc_vreg_data[dev_id - 1];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005762 static int enabled_once[] = {0, 0, 0, 0};
5763
Justin Paupore3f40f342011-08-10 18:52:16 -07005764 if (test_bit(dev_id, &vreg_sts) == enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005765 return rc;
5766
Asutosh Das853bbcd2012-02-01 10:40:05 +05305767 if (dev_id == 4) {
5768 if (enable) {
5769 pr_debug("Enable Vdd dev_%d\n", dev_id);
5770 gpio_set_value_cansleep(
5771 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5772 0);
5773 set_bit(dev_id, &vreg_sts);
5774 } else {
5775 pr_debug("Disable Vdd dev_%d\n", dev_id);
5776 gpio_set_value_cansleep(
5777 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5778 1);
5779 clear_bit(dev_id, &vreg_sts);
5780 }
5781 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005782
Asutosh Das853bbcd2012-02-01 10:40:05 +05305783 if (!enable || enabled_once[dev_id - 1])
5784 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005785 if (!curr)
5786 return -ENODEV;
5787
5788 if (IS_ERR(curr))
5789 return PTR_ERR(curr);
5790
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005791 if (enable) {
5792 set_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005793
5794 rc = regulator_enable(curr);
5795 if (rc)
5796 pr_err("%s: could not enable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005797 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005798 enabled_once[dev_id - 1] = 1;
5799 } else {
5800 clear_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005801
5802 rc = regulator_disable(curr);
5803 if (rc)
5804 pr_err("%s: could not disable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005805 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005806 }
5807 return rc;
5808}
5809
5810static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
5811{
5812 int rc = 0;
5813 struct platform_device *pdev;
5814
5815 pdev = container_of(dv, struct platform_device, dev);
5816 rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
5817 if (rc)
5818 goto out;
5819
5820 if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
5821 rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
5822out:
5823 return rc;
5824}
5825
5826#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \
5827 defined(CONFIG_CSDIO_VENDOR_ID) && \
5828 defined(CONFIG_CSDIO_DEVICE_ID) && \
5829 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5830
5831#define MBP_ON 1
5832#define MBP_OFF 0
5833
5834#define MBP_RESET_N \
5835 GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
5836#define MBP_INT0 \
5837 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
5838
5839#define MBP_MODE_CTRL_0 \
5840 GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5841#define MBP_MODE_CTRL_1 \
5842 GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5843#define MBP_MODE_CTRL_2 \
5844 GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5845#define TSIF_EN \
5846 GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5847#define TSIF_DATA \
5848 GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5849#define TSIF_CLK \
5850 GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5851
5852static struct msm_gpio mbp_cfg_data[] = {
5853 {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5854 "mbp_reset"},
5855 {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5856 "mbp_io_voltage"},
5857};
5858
5859static int mbp_config_gpios_pre_init(int enable)
5860{
5861 int rc = 0;
5862
5863 if (enable) {
5864 rc = msm_gpios_request_enable(mbp_cfg_data,
5865 ARRAY_SIZE(mbp_cfg_data));
5866 if (rc) {
5867 printk(KERN_ERR
5868 "%s: Failed to turnon GPIOs for mbp chip(%d)\n",
5869 __func__, rc);
5870 }
5871 } else
5872 msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
5873 return rc;
5874}
5875
Justin Paupore3f40f342011-08-10 18:52:16 -07005876static struct regulator_bulk_data mbp_regs_io[2];
5877static struct regulator_bulk_data mbp_regs_rf[2];
5878static struct regulator_bulk_data mbp_regs_adc[1];
5879static struct regulator_bulk_data mbp_regs_core[1];
5880
5881static int mbp_init_regs(struct device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005882{
Justin Paupore3f40f342011-08-10 18:52:16 -07005883 struct regulator_bulk_data regs[] = {
5884 /* Analog and I/O regs */
5885 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
5886 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
5887 /* RF regs */
5888 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
5889 { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 },
5890 /* ADC regs */
5891 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
5892 /* Core regs */
5893 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
5894 };
5895
5896 struct regulator_bulk_data *regptr = regs;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005897 int rc;
5898
Justin Paupore3f40f342011-08-10 18:52:16 -07005899 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs);
5900
5901 if (rc) {
5902 dev_err(dev, "%s: could not get regulators: %d\n",
5903 __func__, rc);
5904 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005905 }
5906
Justin Paupore3f40f342011-08-10 18:52:16 -07005907 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005908
Justin Paupore3f40f342011-08-10 18:52:16 -07005909 if (rc) {
5910 dev_err(dev, "%s: could not set voltages: %d\n",
5911 __func__, rc);
5912 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005913 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005914
5915 memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io));
5916 regptr += ARRAY_SIZE(mbp_regs_io);
5917
5918 memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf));
5919 regptr += ARRAY_SIZE(mbp_regs_rf);
5920
5921 memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc));
5922 regptr += ARRAY_SIZE(mbp_regs_adc);
5923
5924 memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core));
5925
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005926 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005927
5928reg_free:
5929 regulator_bulk_free(ARRAY_SIZE(regs), regs);
5930out:
5931 return rc;
5932}
5933
5934static int mbp_setup_rf_vregs(int state)
5935{
5936 return state ?
5937 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) :
5938 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005939}
5940
5941static int mbp_setup_vregs(int state)
5942{
Justin Paupore3f40f342011-08-10 18:52:16 -07005943 return state ?
5944 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) :
5945 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005946}
5947
5948static int mbp_set_tcxo_en(int enable)
5949{
5950 int rc;
5951 const char *id = "UBMC";
5952 struct vreg *vreg_analog = NULL;
5953
5954 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
5955 enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
5956 if (rc < 0) {
5957 printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
5958 __func__, enable ? "" : "de-");
5959 return -EIO;
5960 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005961 return rc;
5962}
5963
5964static void mbp_set_freeze_io(int state)
5965{
5966 if (state)
5967 gpio_set_value(85, 0);
5968 else
5969 gpio_set_value(85, 1);
5970}
5971
5972static int mbp_set_core_voltage_en(int enable)
5973{
Justin Paupore3f40f342011-08-10 18:52:16 -07005974 static bool is_enabled;
5975 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005976
Justin Paupore3f40f342011-08-10 18:52:16 -07005977 if (enable && !is_enabled) {
5978 rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core),
5979 mbp_regs_core);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005980 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005981 pr_err("%s: could not enable regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005982 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07005983 } else {
5984 is_enabled = true;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005985 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005986 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005987
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005988 return rc;
5989}
5990
5991static void mbp_set_reset(int state)
5992{
5993 if (state)
5994 gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
5995 else
5996 gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
5997}
5998
5999static int mbp_config_interface_mode(int state)
6000{
6001 if (state) {
6002 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
6003 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
6004 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
6005 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
6006 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
6007 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
6008 } else {
6009 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
6010 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
6011 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
6012 }
6013 return 0;
6014}
6015
6016static int mbp_setup_adc_vregs(int state)
6017{
Justin Paupore3f40f342011-08-10 18:52:16 -07006018 return state ?
6019 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) :
6020 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006021}
6022
6023static int mbp_power_up(void)
6024{
6025 int rc;
6026
6027 rc = mbp_config_gpios_pre_init(MBP_ON);
6028 if (rc)
6029 goto exit;
6030 pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__);
6031
6032 rc = mbp_setup_vregs(MBP_ON);
6033 if (rc)
6034 goto exit;
6035 pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
6036
6037 rc = mbp_set_tcxo_en(MBP_ON);
6038 if (rc)
6039 goto exit;
6040 pr_debug("%s: tcxo clock done\n", __func__);
6041
6042 mbp_set_freeze_io(MBP_OFF);
6043 pr_debug("%s: set gpio 85 to 1 done\n", __func__);
6044
6045 udelay(100);
6046 mbp_set_reset(MBP_ON);
6047
6048 udelay(300);
6049 rc = mbp_config_interface_mode(MBP_ON);
6050 if (rc)
6051 goto exit;
6052 pr_debug("%s: mbp_config_interface_mode() done\n", __func__);
6053
6054 udelay(100 + mbp_set_core_voltage_en(MBP_ON));
6055 pr_debug("%s: power gp16 1.2V done\n", __func__);
6056
6057 mbp_set_freeze_io(MBP_ON);
6058 pr_debug("%s: set gpio 85 to 0 done\n", __func__);
6059
6060 udelay(100);
6061
6062 rc = mbp_setup_rf_vregs(MBP_ON);
6063 if (rc)
6064 goto exit;
6065 pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
6066
6067 rc = mbp_setup_adc_vregs(MBP_ON);
6068 if (rc)
6069 goto exit;
6070 pr_debug("%s: s4 2.2V done\n", __func__);
6071
6072 udelay(200);
6073
6074 mbp_set_reset(MBP_OFF);
6075 pr_debug("%s: close gpio 44 done\n", __func__);
6076
6077 msleep(20);
6078exit:
6079 return rc;
6080}
6081
6082static int mbp_power_down(void)
6083{
6084 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006085
6086 mbp_set_reset(MBP_ON);
6087 pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
6088
6089 udelay(100);
6090
6091 rc = mbp_setup_adc_vregs(MBP_OFF);
6092 if (rc)
6093 goto exit;
6094 pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
6095
6096 udelay(5);
6097
6098 rc = mbp_setup_rf_vregs(MBP_OFF);
6099 if (rc)
6100 goto exit;
6101 pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
6102
6103 udelay(5);
6104
6105 mbp_set_freeze_io(MBP_OFF);
6106 pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
6107
6108 udelay(100);
6109 rc = mbp_set_core_voltage_en(MBP_OFF);
6110 if (rc)
6111 goto exit;
6112 pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
6113
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006114 rc = mbp_set_tcxo_en(MBP_OFF);
6115 if (rc)
6116 goto exit;
6117 pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
6118
Justin Paupore3f40f342011-08-10 18:52:16 -07006119 rc = mbp_setup_vregs(MBP_OFF);
6120 if (rc)
6121 goto exit;
6122 pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__);
6123
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006124 rc = mbp_config_gpios_pre_init(MBP_OFF);
6125 if (rc)
6126 goto exit;
6127exit:
6128 return rc;
6129}
6130
6131static void (*mbp_status_notify_cb)(int card_present, void *dev_id);
6132static void *mbp_status_notify_cb_devid;
6133static int mbp_power_status;
6134static int mbp_power_init_done;
6135
6136static uint32_t mbp_setup_power(struct device *dv,
6137 unsigned int power_status)
6138{
6139 int rc = 0;
6140 struct platform_device *pdev;
6141
6142 pdev = container_of(dv, struct platform_device, dev);
6143
6144 if (power_status == mbp_power_status)
6145 goto exit;
6146 if (power_status) {
6147 pr_debug("turn on power of mbp slot");
6148 rc = mbp_power_up();
6149 mbp_power_status = 1;
6150 } else {
6151 pr_debug("turn off power of mbp slot");
6152 rc = mbp_power_down();
6153 mbp_power_status = 0;
6154 }
6155exit:
6156 return rc;
6157};
6158
6159int mbp_register_status_notify(void (*callback)(int, void *),
6160 void *dev_id)
6161{
6162 mbp_status_notify_cb = callback;
6163 mbp_status_notify_cb_devid = dev_id;
6164 return 0;
6165}
6166
6167static unsigned int mbp_status(struct device *dev)
6168{
6169 return mbp_power_status;
6170}
6171
6172static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd)
6173{
6174 struct platform_device *pdev;
6175 uint32_t rc = 0;
6176
6177 pdev = container_of(dv, struct platform_device, dev);
6178 rc = msm_sdcc_setup_power(dv, vdd);
6179 if (rc) {
6180 pr_err("%s: Failed to setup power (%d)\n",
6181 __func__, rc);
6182 goto out;
6183 }
6184 if (!mbp_power_init_done) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006185 rc = mbp_init_regs(dv);
6186 if (rc) {
6187 dev_err(dv, "%s: regulator init failed: %d\n",
6188 __func__, rc);
6189 goto out;
6190 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006191 mbp_setup_power(dv, 1);
6192 mbp_setup_power(dv, 0);
6193 mbp_power_init_done = 1;
6194 }
6195 if (vdd >= 0x8000) {
6196 rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
6197 if (rc) {
6198 pr_err("%s: Failed to config mbp chip power (%d)\n",
6199 __func__, rc);
6200 goto out;
6201 }
6202 if (mbp_status_notify_cb) {
6203 mbp_status_notify_cb(mbp_power_status,
6204 mbp_status_notify_cb_devid);
6205 }
6206 }
6207out:
6208 /* should return 0 only */
6209 return 0;
6210}
6211
6212#endif
6213
6214#endif
6215
6216#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006217static unsigned int msm7x30_sdcc_slot_status(struct device *dev)
6218{
6219 return (unsigned int)
6220 gpio_get_value_cansleep(
6221 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1));
6222}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006223
6224static int msm_sdcc_get_wpswitch(struct device *dv)
6225{
6226 void __iomem *wp_addr = 0;
6227 uint32_t ret = 0;
6228 struct platform_device *pdev;
6229
6230 if (!(machine_is_msm7x30_surf()))
6231 return -1;
6232 pdev = container_of(dv, struct platform_device, dev);
6233
6234 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
6235 if (!wp_addr) {
6236 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
6237 return -ENOMEM;
6238 }
6239
6240 ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
6241 pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
6242 pdev->id, ret);
6243 iounmap(wp_addr);
6244
6245 return ret;
6246}
6247#endif
6248
6249#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
6250#if defined(CONFIG_CSDIO_VENDOR_ID) && \
6251 defined(CONFIG_CSDIO_DEVICE_ID) && \
6252 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
6253static struct mmc_platform_data msm7x30_sdc1_data = {
6254 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
6255 .translate_vdd = msm_sdcc_setup_power_mbp,
6256 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6257 .status = mbp_status,
6258 .register_status_notify = mbp_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006259 .msmsdcc_fmin = 144000,
6260 .msmsdcc_fmid = 24576000,
6261 .msmsdcc_fmax = 24576000,
6262 .nonremovable = 0,
6263};
6264#else
6265static struct mmc_platform_data msm7x30_sdc1_data = {
6266 .ocr_mask = MMC_VDD_165_195,
6267 .translate_vdd = msm_sdcc_setup_power,
6268 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006269 .msmsdcc_fmin = 144000,
6270 .msmsdcc_fmid = 24576000,
6271 .msmsdcc_fmax = 49152000,
6272 .nonremovable = 0,
6273};
6274#endif
6275#endif
6276
6277#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
6278static struct mmc_platform_data msm7x30_sdc2_data = {
6279 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
6280 .translate_vdd = msm_sdcc_setup_power,
6281#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
6282 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
6283#else
6284 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6285#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006286 .msmsdcc_fmin = 144000,
6287 .msmsdcc_fmid = 24576000,
6288 .msmsdcc_fmax = 49152000,
6289 .nonremovable = 1,
6290};
6291#endif
6292
6293#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
6294static struct mmc_platform_data msm7x30_sdc3_data = {
6295 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6296 .translate_vdd = msm_sdcc_setup_power,
6297 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006298 .sdiowakeup_irq = MSM_GPIO_TO_INT(118),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006299 .msmsdcc_fmin = 144000,
6300 .msmsdcc_fmid = 24576000,
6301 .msmsdcc_fmax = 49152000,
6302 .nonremovable = 0,
6303};
6304#endif
6305
6306#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6307static struct mmc_platform_data msm7x30_sdc4_data = {
6308 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6309 .translate_vdd = msm_sdcc_setup_power,
6310 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006311 .status = msm7x30_sdcc_slot_status,
6312 .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
6313 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006314 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006315 .msmsdcc_fmin = 144000,
6316 .msmsdcc_fmid = 24576000,
6317 .msmsdcc_fmax = 49152000,
6318 .nonremovable = 0,
6319};
6320#endif
6321
6322#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006323static int msm_sdc1_lvlshft_enable(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006324{
Justin Paupore3f40f342011-08-10 18:52:16 -07006325 static struct regulator *ldo5;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006326 int rc;
6327
6328 /* Enable LDO5, an input to the FET that powers slot 1 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006329
Justin Paupore3f40f342011-08-10 18:52:16 -07006330 ldo5 = regulator_get(NULL, "ldo5");
6331
6332 if (IS_ERR(ldo5)) {
6333 rc = PTR_ERR(ldo5);
6334 pr_err("%s: could not get ldo5: %d\n", __func__, rc);
6335 goto out;
6336 }
6337
6338 rc = regulator_set_voltage(ldo5, 2850000, 2850000);
6339 if (rc) {
6340 pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc);
6341 goto ldo5_free;
6342 }
6343
6344 rc = regulator_enable(ldo5);
6345 if (rc) {
6346 pr_err("%s: could not enable ldo5: %d\n", __func__, rc);
6347 goto ldo5_free;
6348 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006349
6350 /* Enable GPIO 35, to turn on the FET that powers slot 1 */
6351 rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
6352 ARRAY_SIZE(sdc1_lvlshft_cfg_data));
6353 if (rc)
6354 printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
6355
6356 rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg),
6357 1);
6358 if (rc)
6359 printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006360
6361 return 0;
6362
6363ldo5_free:
6364 regulator_put(ldo5);
6365out:
6366 ldo5 = NULL;
6367 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006368}
6369#endif
6370
Justin Paupore3f40f342011-08-10 18:52:16 -07006371static int mmc_regulator_init(int sdcc_no, const char *supply, int uV)
6372{
6373 int rc;
6374
6375 BUG_ON(sdcc_no < 1 || sdcc_no > 4);
6376
6377 sdcc_no--;
6378
6379 sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply);
6380
6381 if (IS_ERR(sdcc_vreg_data[sdcc_no])) {
6382 rc = PTR_ERR(sdcc_vreg_data[sdcc_no]);
6383 pr_err("%s: could not get regulator \"%s\": %d\n",
6384 __func__, supply, rc);
6385 goto out;
6386 }
6387
6388 rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV);
6389
6390 if (rc) {
6391 pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n",
6392 __func__, supply, uV, rc);
6393 goto reg_free;
6394 }
6395
6396 return rc;
6397
6398reg_free:
6399 regulator_put(sdcc_vreg_data[sdcc_no]);
6400out:
6401 sdcc_vreg_data[sdcc_no] = NULL;
6402 return rc;
6403}
6404
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006405static void __init msm7x30_init_mmc(void)
6406{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006407#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006408 if (mmc_regulator_init(1, "s3", 1800000))
6409 goto out1;
6410
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006411 if (machine_is_msm7x30_fluid()) {
6412 msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
Justin Paupore3f40f342011-08-10 18:52:16 -07006413 if (msm_sdc1_lvlshft_enable()) {
6414 pr_err("%s: could not enable level shift\n");
6415 goto out1;
6416 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006417 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006418
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006419 msm_add_sdcc(1, &msm7x30_sdc1_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006420out1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006421#endif
6422#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006423 if (mmc_regulator_init(2, "s3", 1800000))
6424 goto out2;
6425
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006426 if (machine_is_msm8x55_svlte_surf())
6427 msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
Sujith Reddy Thumma84a0f512011-08-29 09:57:03 +05306428 if (machine_is_msm8x55_svlte_surf() ||
6429 machine_is_msm8x55_svlte_ffa()) {
6430 msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
6431 msm7x30_sdc2_data.is_sdio_al_client = 1;
6432 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006433
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006434 msm_add_sdcc(2, &msm7x30_sdc2_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006435out2:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006436#endif
6437#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006438 if (mmc_regulator_init(3, "s3", 1800000))
6439 goto out3;
6440
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006441 msm_sdcc_setup_gpio(3, 1);
6442 msm_add_sdcc(3, &msm7x30_sdc3_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006443out3:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006444#endif
6445#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006446 if (mmc_regulator_init(4, "mmc", 2850000))
6447 return;
6448
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006449 msm_add_sdcc(4, &msm7x30_sdc4_data);
6450#endif
6451
6452}
6453
6454static void __init msm7x30_init_nand(void)
6455{
6456 char *build_id;
6457 struct flash_platform_data *plat_data;
6458
6459 build_id = socinfo_get_build_id();
6460 if (build_id == NULL) {
6461 pr_err("%s: Build ID not available from socinfo\n", __func__);
6462 return;
6463 }
6464
6465 if (build_id[8] == 'C' &&
6466 !msm_gpios_request_enable(msm_nand_ebi2_cfg_data,
6467 ARRAY_SIZE(msm_nand_ebi2_cfg_data))) {
6468 plat_data = msm_device_nand.dev.platform_data;
6469 plat_data->interleave = 1;
6470 printk(KERN_INFO "%s: Interleave mode Build ID found\n",
6471 __func__);
6472 }
6473}
6474
6475#ifdef CONFIG_SERIAL_MSM_CONSOLE
6476static struct msm_gpio uart2_config_data[] = {
6477 { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
6478 { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
6479 { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
6480 { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
6481};
6482
6483static void msm7x30_init_uart2(void)
6484{
6485 msm_gpios_request_enable(uart2_config_data,
6486 ARRAY_SIZE(uart2_config_data));
6487
6488}
6489#endif
6490
6491/* TSIF begin */
6492#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6493
6494#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6495#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6496#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6497#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6498
6499static const struct msm_gpio tsif_gpios[] = {
6500 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
6501 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
6502 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
6503 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
6504};
6505
6506static struct msm_tsif_platform_data tsif_platform_data = {
6507 .num_gpios = ARRAY_SIZE(tsif_gpios),
6508 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -07006509 .tsif_pclk = "iface_clk",
6510 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006511};
6512#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
6513/* TSIF end */
6514
6515static void __init pmic8058_leds_init(void)
6516{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306517 if (machine_is_msm7x30_surf())
6518 pm8058_7x30_data.leds_pdata = &pm8058_surf_leds_data;
6519 else if (!machine_is_msm7x30_fluid())
6520 pm8058_7x30_data.leds_pdata = &pm8058_ffa_leds_data;
6521 else if (machine_is_msm7x30_fluid())
6522 pm8058_7x30_data.leds_pdata = &pm8058_fluid_leds_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006523}
6524
6525static struct msm_spm_platform_data msm_spm_data __initdata = {
Taniya Das298de8c2012-02-16 11:45:31 +05306526 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006527
6528 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
6529 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
6530 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
6531 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
6532
6533 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
6534 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
6535 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
6536
6537 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
6538 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
6539 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
6540
6541 .awake_vlevel = 0xF2,
6542 .retention_vlevel = 0xE0,
6543 .collapse_vlevel = 0x72,
6544 .retention_mid_vlevel = 0xE0,
6545 .collapse_mid_vlevel = 0xE0,
6546
6547 .vctl_timeout_us = 50,
6548};
6549
6550#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6551 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6552
6553#define TSC2007_TS_PEN_INT 20
6554
6555static struct msm_gpio tsc2007_config_data[] = {
6556 { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
6557 "tsc2007_irq" },
6558};
6559
Justin Paupore3f40f342011-08-10 18:52:16 -07006560static struct regulator_bulk_data tsc2007_regs[] = {
6561 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
6562 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
6563};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006564
6565static int tsc2007_init(void)
6566{
6567 int rc;
6568
Justin Paupore3f40f342011-08-10 18:52:16 -07006569 rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006570
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006571 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006572 pr_err("%s: could not get regulators: %d\n", __func__, rc);
6573 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006574 }
6575
Justin Paupore3f40f342011-08-10 18:52:16 -07006576 rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6577
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006578 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006579 pr_err("%s: could not set voltages: %d\n", __func__, rc);
6580 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006581 }
6582
Justin Paupore3f40f342011-08-10 18:52:16 -07006583 rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006584
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006585 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006586 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
6587 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006588 }
6589
6590 rc = msm_gpios_request_enable(tsc2007_config_data,
6591 ARRAY_SIZE(tsc2007_config_data));
6592 if (rc) {
6593 pr_err("%s: Unable to request gpios\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006594 goto reg_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006595 }
6596
6597 return 0;
6598
Justin Paupore3f40f342011-08-10 18:52:16 -07006599reg_disable:
6600 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6601reg_free:
6602 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6603out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006604 return rc;
6605}
6606
6607static int tsc2007_get_pendown_state(void)
6608{
6609 int rc;
6610
6611 rc = gpio_get_value(TSC2007_TS_PEN_INT);
6612 if (rc < 0) {
6613 pr_err("%s: MSM GPIO %d read failed\n", __func__,
6614 TSC2007_TS_PEN_INT);
6615 return rc;
6616 }
6617
6618 return (rc == 0 ? 1 : 0);
6619}
6620
6621static void tsc2007_exit(void)
6622{
Justin Paupore3f40f342011-08-10 18:52:16 -07006623
6624 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6625 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006626
6627 msm_gpios_disable_free(tsc2007_config_data,
6628 ARRAY_SIZE(tsc2007_config_data));
6629}
6630
6631static int tsc2007_power_shutdown(bool enable)
6632{
6633 int rc;
6634
Justin Paupore3f40f342011-08-10 18:52:16 -07006635 rc = (enable == false) ?
6636 regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) :
6637 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6638
6639 if (rc) {
6640 pr_err("%s: could not %sable regulators: %d\n",
6641 __func__, enable ? "dis" : "en", rc);
6642 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006643 }
6644
Justin Paupore3f40f342011-08-10 18:52:16 -07006645 if (enable == false)
6646 msleep(20);
6647
6648 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006649}
6650
6651static struct tsc2007_platform_data tsc2007_ts_data = {
6652 .model = 2007,
6653 .x_plate_ohms = 300,
Anirudh Ghayala2cf2e22012-01-25 12:29:42 +05306654 .min_x = 210,
6655 .max_x = 3832,
6656 .min_y = 150,
6657 .max_y = 3936,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006658 .irq_flags = IRQF_TRIGGER_LOW,
6659 .init_platform_hw = tsc2007_init,
6660 .exit_platform_hw = tsc2007_exit,
6661 .power_shutdown = tsc2007_power_shutdown,
6662 .invert_x = true,
6663 .invert_y = true,
6664 /* REVISIT: Temporary fix for reversed pressure */
6665 .invert_z1 = true,
6666 .invert_z2 = true,
6667 .get_pendown_state = tsc2007_get_pendown_state,
6668};
6669
6670static struct i2c_board_info tsc_i2c_board_info[] = {
6671 {
6672 I2C_BOARD_INFO("tsc2007", 0x48),
6673 .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
6674 .platform_data = &tsc2007_ts_data,
6675 },
6676};
6677#endif
6678
Justin Paupore3f40f342011-08-10 18:52:16 -07006679static struct regulator_bulk_data regs_isa1200[] = {
6680 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
6681 { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006682};
6683
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006684static int isa1200_power(int vreg_on)
6685{
Justin Paupore3f40f342011-08-10 18:52:16 -07006686 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006687
Justin Paupore3f40f342011-08-10 18:52:16 -07006688 rc = vreg_on ?
6689 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) :
6690 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006691
Justin Paupore3f40f342011-08-10 18:52:16 -07006692 if (rc) {
6693 pr_err("%s: could not %sable regulators: %d\n",
6694 __func__, vreg_on ? "en" : "dis", rc);
6695 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006696 }
6697
6698 /* vote for DO buffer */
6699 rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO,
6700 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
6701 if (rc) {
6702 pr_err("%s: unable to %svote for d0 clk\n",
6703 __func__, vreg_on ? "" : "de-");
6704 goto vreg_fail;
6705 }
6706
6707 return 0;
6708
6709vreg_fail:
Justin Paupore3f40f342011-08-10 18:52:16 -07006710 if (vreg_on)
6711 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6712 else
6713 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6714out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006715 return rc;
6716}
6717
6718static int isa1200_dev_setup(bool enable)
6719{
Justin Paupore3f40f342011-08-10 18:52:16 -07006720 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006721
6722 if (enable == true) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006723 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200),
6724 regs_isa1200);
6725
6726 if (rc) {
6727 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006728 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006729 goto out;
6730 }
6731
6732 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200),
6733 regs_isa1200);
6734 if (rc) {
6735 pr_err("%s: could not set voltages: %d\n",
6736 __func__, rc);
6737 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006738 }
6739
6740 rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
6741 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
6742 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
6743 if (rc) {
6744 pr_err("%s: Could not configure gpio %d\n",
6745 __func__, HAP_LVL_SHFT_MSM_GPIO);
Justin Paupore3f40f342011-08-10 18:52:16 -07006746 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006747 }
6748
6749 rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
6750 if (rc) {
6751 pr_err("%s: unable to request gpio %d (%d)\n",
6752 __func__, HAP_LVL_SHFT_MSM_GPIO, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006753 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006754 }
6755
6756 gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
6757 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006758 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006759 gpio_free(HAP_LVL_SHFT_MSM_GPIO);
6760 }
6761
6762 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07006763
6764reg_free:
6765 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6766out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006767 return rc;
6768}
6769static struct isa1200_platform_data isa1200_1_pdata = {
6770 .name = "vibrator",
6771 .power_on = isa1200_power,
6772 .dev_setup = isa1200_dev_setup,
6773 .pwm_ch_id = 1, /*channel id*/
6774 /*gpio to enable haptic*/
6775 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka03122322011-09-09 15:15:43 +05306776 .hap_len_gpio = -1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006777 .max_timeout = 15000,
6778 .mode_ctrl = PWM_GEN_MODE,
6779 .pwm_fd = {
6780 .pwm_div = 256,
6781 },
6782 .is_erm = false,
6783 .smart_en = true,
6784 .ext_clk_en = true,
6785 .chip_en = 1,
6786};
6787
6788static struct i2c_board_info msm_isa1200_board_info[] = {
6789 {
6790 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
6791 .platform_data = &isa1200_1_pdata,
6792 },
6793};
6794
6795
6796static int kp_flip_mpp_config(void)
6797{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306798 struct pm8xxx_mpp_config_data kp_flip_mpp = {
6799 .type = PM8XXX_MPP_TYPE_D_INPUT,
6800 .level = PM8018_MPP_DIG_LEVEL_S3,
6801 .control = PM8XXX_MPP_DIN_TO_INT,
6802 };
6803
6804 return pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(PM_FLIP_MPP),
6805 &kp_flip_mpp);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006806}
6807
6808static struct flip_switch_pdata flip_switch_data = {
6809 .name = "kp_flip_switch",
6810 .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP,
6811 .left_key = KEY_OPEN,
6812 .right_key = KEY_CLOSE,
6813 .active_low = 0,
6814 .wakeup = 1,
6815 .flip_mpp_config = kp_flip_mpp_config,
6816};
6817
6818static struct platform_device flip_switch_device = {
6819 .name = "kp_flip_switch",
6820 .id = -1,
6821 .dev = {
6822 .platform_data = &flip_switch_data,
6823 }
6824};
6825
Justin Paupore3f40f342011-08-10 18:52:16 -07006826static struct regulator_bulk_data regs_tma300[] = {
6827 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
6828 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006829};
6830
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006831static int tma300_power(int vreg_on)
6832{
Justin Paupore3f40f342011-08-10 18:52:16 -07006833 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006834
Justin Paupore3f40f342011-08-10 18:52:16 -07006835 rc = vreg_on ?
6836 regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) :
6837 regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006838
Justin Paupore3f40f342011-08-10 18:52:16 -07006839 if (rc)
6840 pr_err("%s: could not %sable regulators: %d\n",
6841 __func__, vreg_on ? "en" : "dis", rc);
6842 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006843}
6844
6845#define TS_GPIO_IRQ 150
6846
6847static int tma300_dev_setup(bool enable)
6848{
Justin Paupore3f40f342011-08-10 18:52:16 -07006849 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006850
6851 if (enable) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006852 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300),
6853 regs_tma300);
6854
6855 if (rc) {
6856 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006857 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006858 goto out;
6859 }
6860
6861 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300),
6862 regs_tma300);
6863
6864 if (rc) {
6865 pr_err("%s: could not set voltages: %d\n",
6866 __func__, rc);
6867 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006868 }
6869
6870 /* enable interrupt gpio */
6871 rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
6872 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
6873 if (rc) {
6874 pr_err("%s: Could not configure gpio %d\n",
6875 __func__, TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -07006876 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006877 }
6878
6879 /* virtual keys */
6880 tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
6881 properties_kobj = kobject_create_and_add("board_properties",
6882 NULL);
6883 if (!properties_kobj) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006884 pr_err("%s: failed to create a kobject "
6885 "for board_properties\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006886 rc = -ENOMEM;
Justin Paupore3f40f342011-08-10 18:52:16 -07006887 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006888 }
6889 rc = sysfs_create_group(properties_kobj,
6890 &tma300_properties_attr_group);
6891 if (rc) {
6892 pr_err("%s: failed to create a sysfs entry %s\n",
6893 __func__, tma300_vkeys_attr.attr.name);
Justin Paupore3f40f342011-08-10 18:52:16 -07006894 goto kobj_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006895 }
6896 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006897 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006898 /* destroy virtual keys */
6899 if (properties_kobj) {
6900 sysfs_remove_group(properties_kobj,
6901 &tma300_properties_attr_group);
6902 kobject_put(properties_kobj);
6903 }
6904 }
6905 return 0;
6906
Justin Paupore3f40f342011-08-10 18:52:16 -07006907kobj_free:
6908 kobject_put(properties_kobj);
6909 properties_kobj = NULL;
6910reg_free:
6911 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
6912out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006913 return rc;
6914}
6915
6916static struct cy8c_ts_platform_data cy8ctma300_pdata = {
6917 .power_on = tma300_power,
6918 .dev_setup = tma300_dev_setup,
6919 .ts_name = "msm_tma300_ts",
6920 .dis_min_x = 0,
6921 .dis_max_x = 479,
6922 .dis_min_y = 0,
6923 .dis_max_y = 799,
6924 .res_x = 479,
6925 .res_y = 1009,
6926 .min_tid = 1,
6927 .max_tid = 255,
6928 .min_touch = 0,
6929 .max_touch = 255,
6930 .min_width = 0,
6931 .max_width = 255,
6932 .invert_y = 1,
6933 .nfingers = 4,
6934 .irq_gpio = TS_GPIO_IRQ,
6935 .resout_gpio = -1,
6936};
6937
6938static struct i2c_board_info cy8ctma300_board_info[] = {
6939 {
6940 I2C_BOARD_INFO("cy8ctma300", 0x2),
6941 .platform_data = &cy8ctma300_pdata,
6942 }
6943};
6944
Daniel Walker8d747cd2010-02-25 11:37:43 -08006945static void __init msm7x30_init(void)
6946{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006947 int rc;
6948 unsigned smem_size;
6949 uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56,
6950 0,
6951 GPIO_CFG_OUTPUT,
6952 GPIO_CFG_NO_PULL,
6953 GPIO_CFG_2MA);
6954 uint32_t soc_version = 0;
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05306955
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006956 soc_version = socinfo_get_version();
6957
Stephen Boydbb600ae2011-08-02 20:11:40 -07006958 msm_clock_init(&msm7x30_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006959#ifdef CONFIG_SERIAL_MSM_CONSOLE
6960 msm7x30_init_uart2();
6961#endif
6962 msm_spm_init(&msm_spm_data, 1);
Matt Wagantallbf430eb2012-03-22 11:45:49 -07006963 platform_device_register(&msm7x30_device_acpuclk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006964 if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid())
6965 msm7x30_cfg_smsc911x();
6966
6967#ifdef CONFIG_USB_MSM_OTG_72K
6968 if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 &&
6969 SOCINFO_VERSION_MINOR(soc_version) >= 1) {
6970 pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
6971 msm_otg_pdata.ldo_set_voltage = 0;
6972 }
6973
6974 msm_device_otg.dev.platform_data = &msm_otg_pdata;
6975#ifdef CONFIG_USB_GADGET
6976 msm_otg_pdata.swfi_latency =
6977 msm_pm_data
6978 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
6979 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
6980#endif
6981#endif
6982 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
6983 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
6984#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6985 msm_device_tsif.dev.platform_data = &tsif_platform_data;
6986#endif
6987 if (machine_is_msm7x30_fluid()) {
6988 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
6989 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
6990 } else {
6991 msm_adc_pdata.dev_names = msm_adc_surf_device_names;
6992 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names);
6993 }
6994
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306995 pmic8058_leds_init();
6996
6997 buses_init();
6998
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306999#ifdef CONFIG_MSM_SSBI
7000 msm_device_ssbi_pmic1.dev.platform_data =
7001 &msm7x30_ssbi_pm8058_pdata;
7002#endif
7003
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007004 platform_add_devices(msm_footswitch_devices,
7005 msm_num_footswitch_devices);
Daniel Walker8d747cd2010-02-25 11:37:43 -08007006 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007007#ifdef CONFIG_USB_EHCI_MSM_72K
7008 msm_add_host(0, &msm_usb_host_pdata);
7009#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07007010#ifdef CONFIG_MSM_CAMERA_V4L2
7011 msm7x30_init_cam();
7012#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007013 msm7x30_init_mmc();
7014 msm7x30_init_nand();
7015 msm_qsd_spi_init();
7016
7017#ifdef CONFIG_SPI_QSD
7018 if (machine_is_msm7x30_fluid())
7019 spi_register_board_info(lcdc_sharp_spi_board_info,
7020 ARRAY_SIZE(lcdc_sharp_spi_board_info));
7021 else
7022 spi_register_board_info(lcdc_toshiba_spi_board_info,
7023 ARRAY_SIZE(lcdc_toshiba_spi_board_info));
7024#endif
7025
Justin Paupore3f40f342011-08-10 18:52:16 -07007026 atv_dac_power_init();
7027 sensors_ldo_init();
7028 hdmi_init_regs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007029 msm_fb_add_devices();
7030 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06007031 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05307032 msm_pm_register_irqs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007033 msm_device_i2c_init();
7034 msm_device_i2c_2_init();
7035 qup_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007036 msm7x30_init_marimba();
7037#ifdef CONFIG_MSM7KV2_AUDIO
7038 snddev_poweramp_gpio_init();
Justin Paupore3f40f342011-08-10 18:52:16 -07007039 snddev_hsed_voltage_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007040 aux_pcm_gpio_init();
7041#endif
7042
7043 i2c_register_board_info(0, msm_i2c_board_info,
7044 ARRAY_SIZE(msm_i2c_board_info));
7045
7046 if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid())
7047 marimba_pdata.tsadc = &marimba_tsadc_pdata;
7048
7049 if (machine_is_msm7x30_fluid())
7050 i2c_register_board_info(0, cy8info,
7051 ARRAY_SIZE(cy8info));
7052#ifdef CONFIG_BOSCH_BMA150
7053 if (machine_is_msm7x30_fluid())
7054 i2c_register_board_info(0, bma150_board_info,
7055 ARRAY_SIZE(bma150_board_info));
7056#endif
7057
7058 i2c_register_board_info(2, msm_marimba_board_info,
7059 ARRAY_SIZE(msm_marimba_board_info));
7060
7061 i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info,
7062 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info));
7063
7064 i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
7065 ARRAY_SIZE(msm_camera_boardinfo));
7066
7067 bt_power_init();
7068#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007069 msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
7070#endif
7071 if (machine_is_msm7x30_fluid())
7072 i2c_register_board_info(0, msm_isa1200_board_info,
7073 ARRAY_SIZE(msm_isa1200_board_info));
7074
7075#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
7076 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
7077 if (machine_is_msm8x55_svlte_ffa())
7078 i2c_register_board_info(2, tsc_i2c_board_info,
7079 ARRAY_SIZE(tsc_i2c_board_info));
7080#endif
7081
7082 if (machine_is_msm7x30_surf())
7083 platform_device_register(&flip_switch_device);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307084
7085 pm8058_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007086
7087 if (machine_is_msm7x30_fluid()) {
7088 /* Initialize platform data for fluid v2 hardware */
7089 if (SOCINFO_VERSION_MAJOR(
7090 socinfo_get_platform_version()) == 2) {
7091 cy8ctma300_pdata.res_y = 920;
7092 cy8ctma300_pdata.invert_y = 0;
7093 }
7094 i2c_register_board_info(0, cy8ctma300_board_info,
7095 ARRAY_SIZE(cy8ctma300_board_info));
7096 }
7097
7098 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
7099 rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE);
7100 if (rc)
7101 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
7102 __func__, usb_hub_gpio_cfg_value, rc);
7103 }
7104
7105 boot_reason = *(unsigned int *)
7106 (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
7107 printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
7108}
7109
7110static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
7111static int __init pmem_sf_size_setup(char *p)
7112{
7113 pmem_sf_size = memparse(p, NULL);
7114 return 0;
7115}
7116early_param("pmem_sf_size", pmem_sf_size_setup);
7117
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307118static unsigned fb_size;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007119static int __init fb_size_setup(char *p)
7120{
7121 fb_size = memparse(p, NULL);
7122 return 0;
7123}
7124early_param("fb_size", fb_size_setup);
7125
7126static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
7127static int __init pmem_adsp_size_setup(char *p)
7128{
7129 pmem_adsp_size = memparse(p, NULL);
7130 return 0;
7131}
7132early_param("pmem_adsp_size", pmem_adsp_size_setup);
7133
7134static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE;
7135static int __init fluid_pmem_adsp_size_setup(char *p)
7136{
7137 fluid_pmem_adsp_size = memparse(p, NULL);
7138 return 0;
7139}
7140early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup);
7141
7142static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
7143static int __init pmem_audio_size_setup(char *p)
7144{
7145 pmem_audio_size = memparse(p, NULL);
7146 return 0;
7147}
7148early_param("pmem_audio_size", pmem_audio_size_setup);
7149
7150static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE;
7151static int __init pmem_kernel_ebi0_size_setup(char *p)
7152{
7153 pmem_kernel_ebi0_size = memparse(p, NULL);
7154 return 0;
7155}
7156early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
7157
Chintan Pandya03b698a2012-06-28 19:03:09 +05307158#ifdef CONFIG_ION_MSM
7159#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
7160static struct ion_co_heap_pdata co_ion_pdata = {
7161 .adjacent_mem_id = INVALID_HEAP_ID,
7162 .align = PAGE_SIZE,
7163};
7164#endif
7165
7166/**
7167 * These heaps are listed in the order they will be allocated.
7168 * Don't swap the order unless you know what you are doing!
7169 */
7170static struct ion_platform_data ion_pdata = {
7171 .nr = MSM_ION_HEAP_NUM,
7172 .heaps = {
7173 {
7174 .id = ION_SYSTEM_HEAP_ID,
7175 .type = ION_HEAP_TYPE_SYSTEM,
7176 .name = ION_VMALLOC_HEAP_NAME,
7177 },
7178#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
7179 /* PMEM_ADSP = CAMERA */
7180 {
7181 .id = ION_CAMERA_HEAP_ID,
7182 .type = ION_HEAP_TYPE_CARVEOUT,
7183 .name = ION_CAMERA_HEAP_NAME,
7184 .memory_type = ION_EBI_TYPE,
7185 .has_outer_cache = 1,
7186 .extra_data = (void *)&co_ion_pdata,
7187 },
7188 /* PMEM_AUDIO */
7189 {
7190 .id = ION_AUDIO_HEAP_ID,
7191 .type = ION_HEAP_TYPE_CARVEOUT,
7192 .name = ION_AUDIO_HEAP_NAME,
7193 .memory_type = ION_EBI_TYPE,
7194 .has_outer_cache = 1,
7195 .extra_data = (void *)&co_ion_pdata,
7196 },
7197 /* PMEM_MDP = SF */
7198 {
7199 .id = ION_SF_HEAP_ID,
7200 .type = ION_HEAP_TYPE_CARVEOUT,
7201 .name = ION_SF_HEAP_NAME,
7202 .memory_type = ION_EBI_TYPE,
7203 .has_outer_cache = 1,
7204 .extra_data = (void *)&co_ion_pdata,
7205 },
7206#endif
7207 }
7208};
7209
7210static struct platform_device ion_dev = {
7211 .name = "ion-msm",
7212 .id = 1,
7213 .dev = { .platform_data = &ion_pdata },
7214};
7215#endif
7216
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007217static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
7218 [MEMTYPE_SMI] = {
7219 },
7220 [MEMTYPE_EBI0] = {
7221 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7222 },
7223 [MEMTYPE_EBI1] = {
7224 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7225 },
7226};
7227
Chintan Pandya03b698a2012-06-28 19:03:09 +05307228unsigned long size;
7229unsigned long msm_ion_camera_size;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007230
Chintan Pandya03b698a2012-06-28 19:03:09 +05307231static void fix_sizes(void)
7232{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007233 if machine_is_msm7x30_fluid()
7234 size = fluid_pmem_adsp_size;
7235 else
7236 size = pmem_adsp_size;
Chintan Pandya03b698a2012-06-28 19:03:09 +05307237
7238#ifdef CONFIG_ION_MSM
7239 msm_ion_camera_size = size;
7240#endif
7241}
7242
7243static void __init size_pmem_devices(void)
7244{
7245#ifdef CONFIG_ANDROID_PMEM
7246#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
7247
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007248 android_pmem_adsp_pdata.size = size;
7249 android_pmem_audio_pdata.size = pmem_audio_size;
7250 android_pmem_pdata.size = pmem_sf_size;
7251#endif
Chintan Pandya03b698a2012-06-28 19:03:09 +05307252#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007253}
7254
Chintan Pandya03b698a2012-06-28 19:03:09 +05307255#ifdef CONFIG_ANDROID_PMEM
7256#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007257static void __init reserve_memory_for(struct android_pmem_platform_data *p)
7258{
7259 msm7x30_reserve_table[p->memory_type].size += p->size;
7260}
Chintan Pandya03b698a2012-06-28 19:03:09 +05307261#endif
7262#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007263
7264static void __init reserve_pmem_memory(void)
7265{
7266#ifdef CONFIG_ANDROID_PMEM
Chintan Pandya03b698a2012-06-28 19:03:09 +05307267#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007268 reserve_memory_for(&android_pmem_adsp_pdata);
7269 reserve_memory_for(&android_pmem_audio_pdata);
7270 reserve_memory_for(&android_pmem_pdata);
7271 msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
7272#endif
Chintan Pandya03b698a2012-06-28 19:03:09 +05307273#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007274}
7275
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307276static void __init reserve_mdp_memory(void)
7277{
7278 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
7279 msm7x30_reserve_table[mdp_pdata.mem_hid].size += mdp_pdata.ov0_wb_size;
7280}
7281
Chintan Pandya03b698a2012-06-28 19:03:09 +05307282static void __init size_ion_devices(void)
7283{
7284#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
7285 ion_pdata.heaps[1].size = msm_ion_camera_size;
7286 ion_pdata.heaps[2].size = MSM_ION_AUDIO_SIZE;
7287 ion_pdata.heaps[3].size = MSM_ION_SF_SIZE;
7288#endif
7289}
7290
7291static void __init reserve_ion_memory(void)
7292{
7293#if defined(CONFIG_ION_MSM) && defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
7294 msm7x30_reserve_table[MEMTYPE_EBI0].size += msm_ion_camera_size;
7295 msm7x30_reserve_table[MEMTYPE_EBI0].size += MSM_ION_AUDIO_SIZE;
7296 msm7x30_reserve_table[MEMTYPE_EBI0].size += MSM_ION_SF_SIZE;
7297#endif
7298}
7299
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007300static void __init msm7x30_calculate_reserve_sizes(void)
7301{
Chintan Pandya03b698a2012-06-28 19:03:09 +05307302 fix_sizes();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007303 size_pmem_devices();
7304 reserve_pmem_memory();
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307305 reserve_mdp_memory();
Chintan Pandya03b698a2012-06-28 19:03:09 +05307306 size_ion_devices();
7307 reserve_ion_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007308}
7309
7310static int msm7x30_paddr_to_memtype(unsigned int paddr)
7311{
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307312 if (paddr < phys_add)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007313 return MEMTYPE_EBI0;
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307314 if (paddr >= phys_add && paddr < 0x80000000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007315 return MEMTYPE_EBI1;
7316 return MEMTYPE_NONE;
7317}
7318
7319static struct reserve_info msm7x30_reserve_info __initdata = {
7320 .memtype_reserve_table = msm7x30_reserve_table,
7321 .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes,
7322 .paddr_to_memtype = msm7x30_paddr_to_memtype,
7323};
7324
7325static void __init msm7x30_reserve(void)
7326{
7327 reserve_info = &msm7x30_reserve_info;
7328 msm_reserve();
7329}
7330
7331static void __init msm7x30_allocate_memory_regions(void)
7332{
7333 void *addr;
7334 unsigned long size;
7335
7336 size = fb_size ? : MSM_FB_SIZE;
7337 addr = alloc_bootmem_align(size, 0x1000);
7338 msm_fb_resources[0].start = __pa(addr);
7339 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
7340 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
7341 size, addr, __pa(addr));
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08007342
7343#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
7344 size = MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE;
7345 addr = alloc_bootmem_align(size, 0x1000);
7346 msm_v4l2_video_overlay_resources[0].start = __pa(addr);
7347 msm_v4l2_video_overlay_resources[0].end =
7348 msm_v4l2_video_overlay_resources[0].start + size - 1;
7349 pr_debug("allocating %lu bytes at %p (%lx physical) for v4l2\n",
7350 size, addr, __pa(addr));
7351#endif
Daniel Walker8d747cd2010-02-25 11:37:43 -08007352}
7353
7354static void __init msm7x30_map_io(void)
7355{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007356 msm_shared_ram_phys = 0x00100000;
Daniel Walker8d747cd2010-02-25 11:37:43 -08007357 msm_map_msm7x30_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007358 if (socinfo_init() < 0)
7359 printk(KERN_ERR "%s: socinfo_init() failed!\n",
7360 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007361}
7362
7363static void __init msm7x30_init_early(void)
7364{
7365 msm7x30_allocate_memory_regions();
Daniel Walker8d747cd2010-02-25 11:37:43 -08007366}
7367
Steve Mucklef132c6c2012-06-06 18:30:57 -07007368static void __init msm7x30_fixup(struct tag *tags, char **cmdline,
7369 struct meminfo *mi)
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307370{
7371 for (; tags->hdr.size; tags = tag_next(tags)) {
7372 if (tags->hdr.tag == ATAG_MEM && tags->u.mem.start ==
7373 DDR1_BANK_BASE) {
7374 ebi1_phys_offset = DDR1_BANK_BASE;
7375 phys_add = DDR1_BANK_BASE;
7376 break;
7377 }
7378 }
Daniel Walker8d747cd2010-02-25 11:37:43 -08007379}
7380
7381MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
Nicolas Pitref631dd42011-07-05 22:38:14 -04007382 .atag_offset = 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007383 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007384 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007385 .init_irq = msm7x30_init_irq,
7386 .init_machine = msm7x30_init,
7387 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007388 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307389 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307390 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007391MACHINE_END
7392
7393MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
Nicolas Pitref631dd42011-07-05 22:38:14 -04007394 .atag_offset = 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007395 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007396 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007397 .init_irq = msm7x30_init_irq,
7398 .init_machine = msm7x30_init,
7399 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007400 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307401 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307402 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007403MACHINE_END
7404
7405MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
Nicolas Pitref631dd42011-07-05 22:38:14 -04007406 .atag_offset = 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007407 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007408 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007409 .init_irq = msm7x30_init_irq,
7410 .init_machine = msm7x30_init,
7411 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007412 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307413 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307414 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007415MACHINE_END
7416
7417MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007418 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007419 .map_io = msm7x30_map_io,
7420 .reserve = msm7x30_reserve,
7421 .init_irq = msm7x30_init_irq,
7422 .init_machine = msm7x30_init,
7423 .timer = &msm_timer,
7424 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307425 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307426 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007427MACHINE_END
7428
7429MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007430 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007431 .map_io = msm7x30_map_io,
7432 .reserve = msm7x30_reserve,
7433 .init_irq = msm7x30_init_irq,
7434 .init_machine = msm7x30_init,
7435 .timer = &msm_timer,
7436 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307437 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307438 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007439MACHINE_END
7440MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007441 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007442 .map_io = msm7x30_map_io,
7443 .reserve = msm7x30_reserve,
7444 .init_irq = msm7x30_init_irq,
7445 .init_machine = msm7x30_init,
7446 .timer = &msm_timer,
7447 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307448 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307449 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007450MACHINE_END
7451MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007452 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007453 .map_io = msm7x30_map_io,
7454 .reserve = msm7x30_reserve,
7455 .init_irq = msm7x30_init_irq,
7456 .init_machine = msm7x30_init,
7457 .timer = &msm_timer,
7458 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307459 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307460 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007461MACHINE_END