blob: 2834f2457af53917f0e35072b2c2642fa1c46a7d [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
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700128#define PMIC_GPIO_INT 27
129#define PMIC_VREG_WLAN_LEVEL 2900
130#define PMIC_GPIO_SD_DET 36
131#define PMIC_GPIO_SDC4_EN_N 17 /* PMIC GPIO Number 18 */
132#define PMIC_GPIO_HDMI_5V_EN_V3 32 /* PMIC GPIO for V3 H/W */
133#define PMIC_GPIO_HDMI_5V_EN_V2 39 /* PMIC GPIO for V2 H/W */
134
135#define ADV7520_I2C_ADDR 0x39
136
137#define FPGA_SDCC_STATUS 0x8E0001A8
138
139#define FPGA_OPTNAV_GPIO_ADDR 0x8E000026
140#define OPTNAV_I2C_SLAVE_ADDR (0xB0 >> 1)
141#define OPTNAV_IRQ 20
142#define OPTNAV_CHIP_SELECT 19
Asutosh Das853bbcd2012-02-01 10:40:05 +0530143#define PMIC_GPIO_SDC4_PWR_EN_N 24 /* PMIC GPIO Number 25 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700144
145/* Macros assume PMIC GPIOs start at 0 */
146#define PM8058_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio + NR_GPIO_IRQS)
147#define PM8058_GPIO_SYS_TO_PM(sys_gpio) (sys_gpio - NR_GPIO_IRQS)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530148#define PM8058_MPP_BASE PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS)
149#define PM8058_MPP_PM_TO_SYS(pm_gpio) (pm_gpio + PM8058_MPP_BASE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700150
151#define PMIC_GPIO_FLASH_BOOST_ENABLE 15 /* PMIC GPIO Number 16 */
152#define PMIC_GPIO_HAP_ENABLE 16 /* PMIC GPIO Number 17 */
153
154#define PMIC_GPIO_WLAN_EXT_POR 22 /* PMIC GPIO NUMBER 23 */
155
156#define BMA150_GPIO_INT 1
157
158#define HAP_LVL_SHFT_MSM_GPIO 24
159
160#define PMIC_GPIO_QUICKVX_CLK 37 /* PMIC GPIO 38 */
161
162#define PM_FLIP_MPP 5 /* PMIC MPP 06 */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530163
Pankaj Kumarac69ee62012-01-26 00:21:56 +0530164#define DDR1_BANK_BASE 0X20000000
165#define DDR2_BANK_BASE 0X40000000
166
167static unsigned int phys_add = DDR2_BANK_BASE;
168unsigned long ebi1_phys_offset = DDR2_BANK_BASE;
169EXPORT_SYMBOL(ebi1_phys_offset);
170
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530171struct pm8xxx_gpio_init_info {
172 unsigned gpio;
173 struct pm_gpio config;
174};
175
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700176static int pm8058_gpios_init(void)
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100177{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700178 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700179
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530180 struct pm8xxx_gpio_init_info sdc4_en = {
181 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_EN_N),
182 {
183 .direction = PM_GPIO_DIR_OUT,
184 .pull = PM_GPIO_PULL_NO,
185 .vin_sel = PM8058_GPIO_VIN_L5,
186 .function = PM_GPIO_FUNC_NORMAL,
187 .inv_int_pol = 0,
188 .out_strength = PM_GPIO_STRENGTH_LOW,
189 .output_value = 0,
190 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700191 };
192
Asutosh Das853bbcd2012-02-01 10:40:05 +0530193 struct pm8xxx_gpio_init_info sdc4_pwr_en = {
194 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
195 {
196 .direction = PM_GPIO_DIR_OUT,
197 .pull = PM_GPIO_PULL_NO,
198 .vin_sel = PM8058_GPIO_VIN_L5,
199 .function = PM_GPIO_FUNC_NORMAL,
200 .inv_int_pol = 0,
201 .out_strength = PM_GPIO_STRENGTH_LOW,
202 .output_value = 0,
203 },
204 };
205
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530206 struct pm8xxx_gpio_init_info haptics_enable = {
207 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
208 {
209 .direction = PM_GPIO_DIR_OUT,
210 .pull = PM_GPIO_PULL_NO,
211 .out_strength = PM_GPIO_STRENGTH_HIGH,
212 .function = PM_GPIO_FUNC_NORMAL,
213 .inv_int_pol = 0,
214 .vin_sel = 2,
215 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
216 .output_value = 0,
217 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700218 };
219
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530220 struct pm8xxx_gpio_init_info hdmi_5V_en = {
221 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HDMI_5V_EN_V3),
222 {
223 .direction = PM_GPIO_DIR_OUT,
224 .pull = PM_GPIO_PULL_NO,
225 .vin_sel = PM8058_GPIO_VIN_VPH,
226 .function = PM_GPIO_FUNC_NORMAL,
227 .out_strength = PM_GPIO_STRENGTH_LOW,
228 .output_value = 0,
229 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700230 };
231
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530232 struct pm8xxx_gpio_init_info flash_boost_enable = {
233 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE),
234 {
235 .direction = PM_GPIO_DIR_OUT,
236 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
237 .output_value = 0,
238 .pull = PM_GPIO_PULL_NO,
239 .vin_sel = PM8058_GPIO_VIN_S3,
240 .out_strength = PM_GPIO_STRENGTH_HIGH,
241 .function = PM_GPIO_FUNC_2,
242 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700243 };
244
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530245 struct pm8xxx_gpio_init_info gpio23 = {
246 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_WLAN_EXT_POR),
247 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700248 .direction = PM_GPIO_DIR_OUT,
249 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
250 .output_value = 0,
251 .pull = PM_GPIO_PULL_NO,
252 .vin_sel = 2,
253 .out_strength = PM_GPIO_STRENGTH_LOW,
254 .function = PM_GPIO_FUNC_NORMAL,
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100255 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700256 };
257
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700258#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530259 struct pm8xxx_gpio_init_info sdcc_det = {
260 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1),
261 {
262 .direction = PM_GPIO_DIR_IN,
263 .pull = PM_GPIO_PULL_UP_1P5,
264 .vin_sel = 2,
265 .function = PM_GPIO_FUNC_NORMAL,
266 .inv_int_pol = 0,
267 },
268 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700269
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530270 if (machine_is_msm7x30_fluid())
271 sdcc_det.config.inv_int_pol = 1;
272
273 rc = pm8xxx_gpio_config(sdcc_det.gpio, &sdcc_det.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700274 if (rc) {
275 pr_err("%s PMIC_GPIO_SD_DET config failed\n", __func__);
276 return rc;
277 }
278#endif
279
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530280 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
281 machine_is_msm7x30_fluid())
282 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V2;
283 else
284 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V3;
285
286 hdmi_5V_en.gpio = PM8058_GPIO_PM_TO_SYS(hdmi_5V_en.gpio);
287
288 rc = pm8xxx_gpio_config(hdmi_5V_en.gpio, &hdmi_5V_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700289 if (rc) {
290 pr_err("%s PMIC_GPIO_HDMI_5V_EN config failed\n", __func__);
291 return rc;
292 }
293
294 /* Deassert GPIO#23 (source for Ext_POR on WLAN-Volans) */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530295 rc = pm8xxx_gpio_config(gpio23.gpio, &gpio23.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700296 if (rc) {
297 pr_err("%s PMIC_GPIO_WLAN_EXT_POR config failed\n", __func__);
298 return rc;
299 }
300
301 if (machine_is_msm7x30_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530302 /* Haptics gpio */
303 rc = pm8xxx_gpio_config(haptics_enable.gpio,
304 &haptics_enable.config);
305 if (rc) {
306 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
307 haptics_enable.gpio);
308 return rc;
309 }
310 /* Flash boost gpio */
311 rc = pm8xxx_gpio_config(flash_boost_enable.gpio,
312 &flash_boost_enable.config);
313 if (rc) {
314 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
315 flash_boost_enable.gpio);
316 return rc;
317 }
318 /* SCD4 gpio */
319 rc = pm8xxx_gpio_config(sdc4_en.gpio, &sdc4_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700320 if (rc) {
321 pr_err("%s PMIC_GPIO_SDC4_EN_N config failed\n",
322 __func__);
323 return rc;
324 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530325 rc = gpio_request(sdc4_en.gpio, "sdc4_en");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700326 if (rc) {
327 pr_err("%s PMIC_GPIO_SDC4_EN_N gpio_request failed\n",
328 __func__);
329 return rc;
330 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530331 gpio_set_value_cansleep(sdc4_en.gpio, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700332 }
Asutosh Das853bbcd2012-02-01 10:40:05 +0530333 /* FFA -> gpio_25 controls vdd of sdcc4 */
334 else {
335 /* SCD4 gpio_25 */
336 rc = pm8xxx_gpio_config(sdc4_pwr_en.gpio, &sdc4_pwr_en.config);
337 if (rc) {
338 pr_err("%s PMIC_GPIO_SDC4_PWR_EN_N config failed: %d\n",
339 __func__, rc);
340 return rc;
341 }
342
343 rc = gpio_request(sdc4_pwr_en.gpio, "sdc4_pwr_en");
344 if (rc) {
345 pr_err("PMIC_GPIO_SDC4_PWR_EN_N gpio_req failed: %d\n",
346 rc);
347 return rc;
348 }
349 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700350
351 return 0;
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100352}
353
Justin Paupore637a25d2011-07-14 17:11:04 -0700354/* Regulator API support */
355
356#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
357static struct platform_device msm_proccomm_regulator_dev = {
358 .name = PROCCOMM_REGULATOR_DEV_NAME,
359 .id = -1,
360 .dev = {
361 .platform_data = &msm7x30_proccomm_regulator_data
362 }
363};
364#endif
365
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700366/*virtual key support */
367static ssize_t tma300_vkeys_show(struct kobject *kobj,
368 struct kobj_attribute *attr, char *buf)
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100369{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700370 return sprintf(buf,
371 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":50:842:80:100"
372 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":170:842:80:100"
373 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":290:842:80:100"
374 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":410:842:80:100"
375 "\n");
Stephen Boyd9e775ad2011-08-12 00:14:28 +0100376}
377
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700378static struct kobj_attribute tma300_vkeys_attr = {
379 .attr = {
380 .mode = S_IRUGO,
381 },
382 .show = &tma300_vkeys_show,
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530383};
384
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700385static struct attribute *tma300_properties_attrs[] = {
386 &tma300_vkeys_attr.attr,
387 NULL
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530388};
389
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700390static struct attribute_group tma300_properties_attr_group = {
391 .attrs = tma300_properties_attrs,
392};
393
394static struct kobject *properties_kobj;
Justin Paupore3f40f342011-08-10 18:52:16 -0700395static struct regulator_bulk_data cyttsp_regs[] = {
396 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
397 { .supply = "ldo15", .min_uV = 3050000, .max_uV = 3100000 },
398};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700399
400#define CYTTSP_TS_GPIO_IRQ 150
401static int cyttsp_platform_init(struct i2c_client *client)
402{
403 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700404
Justin Paupore3f40f342011-08-10 18:52:16 -0700405 rc = regulator_bulk_get(NULL, ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700406
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700407 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700408 pr_err("%s: could not get regulators: %d\n", __func__, rc);
409 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700410 }
411
Justin Paupore3f40f342011-08-10 18:52:16 -0700412 rc = regulator_bulk_set_voltage(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
413
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700414 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700415 pr_err("%s: could not set regulator voltages: %d\n", __func__,
416 rc);
417 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700418 }
419
Justin Paupore3f40f342011-08-10 18:52:16 -0700420 rc = regulator_bulk_enable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700421
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700422 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700423 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
424 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700425 }
426
427 /* check this device active by reading first byte/register */
428 rc = i2c_smbus_read_byte_data(client, 0x01);
429 if (rc < 0) {
430 pr_err("%s: i2c sanity check failed\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -0700431 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700432 }
433
434 rc = gpio_tlmm_config(GPIO_CFG(CYTTSP_TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
435 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
436 if (rc) {
437 pr_err("%s: Could not configure gpio %d\n",
438 __func__, CYTTSP_TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -0700439 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700440 }
441
442 /* virtual keys */
443 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
444 properties_kobj = kobject_create_and_add("board_properties",
445 NULL);
446 if (properties_kobj)
447 rc = sysfs_create_group(properties_kobj,
448 &tma300_properties_attr_group);
449 if (!properties_kobj || rc)
450 pr_err("%s: failed to create board_properties\n",
451 __func__);
452
453 return CY_OK;
454
Justin Paupore3f40f342011-08-10 18:52:16 -0700455regs_disable:
456 regulator_bulk_disable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
457regs_free:
458 regulator_bulk_free(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
459out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700460 return rc;
461}
462
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530463/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
464static int cyttsp_platform_suspend(struct i2c_client *client)
465{
466 msleep(20);
467
468 return CY_OK;
469}
470
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700471static int cyttsp_platform_resume(struct i2c_client *client)
472{
473 /* add any special code to strobe a wakeup pin or chip reset */
474 mdelay(10);
475
476 return CY_OK;
477}
478
479static struct cyttsp_platform_data cyttsp_data = {
480 .fw_fname = "cyttsp_7630_fluid.hex",
481 .panel_maxx = 479,
482 .panel_maxy = 799,
483 .disp_maxx = 469,
484 .disp_maxy = 799,
485 .disp_minx = 10,
486 .disp_miny = 0,
487 .flags = 0,
488 .gen = CY_GEN3, /* or */
489 .use_st = CY_USE_ST,
490 .use_mt = CY_USE_MT,
491 .use_hndshk = CY_SEND_HNDSHK,
492 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +0530493 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700494 .use_gestures = CY_USE_GESTURES,
495 /* activate up to 4 groups
496 * and set active distance
497 */
498 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
499 CY_GEST_GRP3 | CY_GEST_GRP4 |
500 CY_ACT_DIST,
501 /* change act_intrvl to customize the Active power state
502 * scanning/processing refresh interval for Operating mode
503 */
504 .act_intrvl = CY_ACT_INTRVL_DFLT,
505 /* change tch_tmout to customize the touch timeout for the
506 * Active power state for Operating mode
507 */
508 .tch_tmout = CY_TCH_TMOUT_DFLT,
509 /* change lp_intrvl to customize the Low Power power state
510 * scanning/processing refresh interval for Operating mode
511 */
512 .lp_intrvl = CY_LP_INTRVL_DFLT,
513 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530514 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700515 .init = cyttsp_platform_init,
516 .sleep_gpio = -1,
517 .resout_gpio = -1,
518 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
Mohan Pallaka49c37d62011-08-01 11:52:00 +0530519 .correct_fw_ver = 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700520};
521
522static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
523{
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530524 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700525 .direction = PM_GPIO_DIR_OUT,
526 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
527 .output_value = 0,
528 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530529 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700530 .out_strength = PM_GPIO_STRENGTH_HIGH,
531 .function = PM_GPIO_FUNC_2,
532 };
533 int rc = -EINVAL;
534 int id, mode, max_mA;
535
536 id = mode = max_mA = 0;
537 switch (ch) {
538 case 0:
539 case 1:
540 case 2:
541 if (on) {
542 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530543 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
544 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700545 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530546 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700547 __func__, id, rc);
548 }
549 break;
550
551 case 3:
552 id = PM_PWM_LED_KPD;
553 mode = PM_PWM_CONF_DTEST3;
554 max_mA = 200;
555 break;
556
557 case 4:
558 id = PM_PWM_LED_0;
559 mode = PM_PWM_CONF_PWM1;
560 max_mA = 40;
561 break;
562
563 case 5:
564 id = PM_PWM_LED_2;
565 mode = PM_PWM_CONF_PWM2;
566 max_mA = 40;
567 break;
568
569 case 6:
570 id = PM_PWM_LED_FLASH;
571 mode = PM_PWM_CONF_DTEST3;
572 max_mA = 200;
573 break;
574
575 default:
576 break;
577 }
578
579 if (ch >= 3 && ch <= 6) {
580 if (!on) {
581 mode = PM_PWM_CONF_NONE;
582 max_mA = 0;
583 }
584 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
585 if (rc)
586 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
587 __func__, ch, rc);
588 }
589
590 return rc;
591}
592
593static int pm8058_pwm_enable(struct pwm_device *pwm, int ch, int on)
594{
595 int rc;
596
597 switch (ch) {
598 case 7:
599 rc = pm8058_pwm_set_dtest(pwm, on);
600 if (rc)
601 pr_err("%s: pwm_set_dtest(%d): rc=%d\n",
602 __func__, on, rc);
603 break;
604 default:
605 rc = -EINVAL;
606 break;
607 }
608 return rc;
609}
610
611static const unsigned int fluid_keymap[] = {
612 KEY(0, 0, KEY_7),
613 KEY(0, 1, KEY_ENTER),
614 KEY(0, 2, KEY_UP),
615 /* drop (0,3) as it always shows up in pair with(0,2) */
616 KEY(0, 4, KEY_DOWN),
617
618 KEY(1, 0, KEY_CAMERA_SNAPSHOT),
619 KEY(1, 1, KEY_SELECT),
620 KEY(1, 2, KEY_1),
621 KEY(1, 3, KEY_VOLUMEUP),
622 KEY(1, 4, KEY_VOLUMEDOWN),
623};
624
625static const unsigned int surf_keymap[] = {
626 KEY(0, 0, KEY_7),
627 KEY(0, 1, KEY_DOWN),
628 KEY(0, 2, KEY_UP),
629 KEY(0, 3, KEY_RIGHT),
630 KEY(0, 4, KEY_ENTER),
631 KEY(0, 5, KEY_L),
632 KEY(0, 6, KEY_BACK),
633 KEY(0, 7, KEY_M),
634
635 KEY(1, 0, KEY_LEFT),
636 KEY(1, 1, KEY_SEND),
637 KEY(1, 2, KEY_1),
638 KEY(1, 3, KEY_4),
639 KEY(1, 4, KEY_CLEAR),
640 KEY(1, 5, KEY_MSDOS),
641 KEY(1, 6, KEY_SPACE),
642 KEY(1, 7, KEY_COMMA),
643
644 KEY(2, 0, KEY_6),
645 KEY(2, 1, KEY_5),
646 KEY(2, 2, KEY_8),
647 KEY(2, 3, KEY_3),
648 KEY(2, 4, KEY_NUMERIC_STAR),
649 KEY(2, 5, KEY_UP),
650 KEY(2, 6, KEY_DOWN), /* SYN */
651 KEY(2, 7, KEY_LEFTSHIFT),
652
653 KEY(3, 0, KEY_9),
654 KEY(3, 1, KEY_NUMERIC_POUND),
655 KEY(3, 2, KEY_0),
656 KEY(3, 3, KEY_2),
657 KEY(3, 4, KEY_SLEEP),
658 KEY(3, 5, KEY_F1),
659 KEY(3, 6, KEY_F2),
660 KEY(3, 7, KEY_F3),
661
662 KEY(4, 0, KEY_BACK),
663 KEY(4, 1, KEY_HOME),
664 KEY(4, 2, KEY_MENU),
665 KEY(4, 3, KEY_VOLUMEUP),
666 KEY(4, 4, KEY_VOLUMEDOWN),
667 KEY(4, 5, KEY_F4),
668 KEY(4, 6, KEY_F5),
669 KEY(4, 7, KEY_F6),
670
671 KEY(5, 0, KEY_R),
672 KEY(5, 1, KEY_T),
673 KEY(5, 2, KEY_Y),
674 KEY(5, 3, KEY_LEFTALT),
675 KEY(5, 4, KEY_KPENTER),
676 KEY(5, 5, KEY_Q),
677 KEY(5, 6, KEY_W),
678 KEY(5, 7, KEY_E),
679
680 KEY(6, 0, KEY_F),
681 KEY(6, 1, KEY_G),
682 KEY(6, 2, KEY_H),
683 KEY(6, 3, KEY_CAPSLOCK),
684 KEY(6, 4, KEY_PAGEUP),
685 KEY(6, 5, KEY_A),
686 KEY(6, 6, KEY_S),
687 KEY(6, 7, KEY_D),
688
689 KEY(7, 0, KEY_V),
690 KEY(7, 1, KEY_B),
691 KEY(7, 2, KEY_N),
692 KEY(7, 3, KEY_MENU), /* REVISIT - SYM */
693 KEY(7, 4, KEY_PAGEDOWN),
694 KEY(7, 5, KEY_Z),
695 KEY(7, 6, KEY_X),
696 KEY(7, 7, KEY_C),
697
698 KEY(8, 0, KEY_P),
699 KEY(8, 1, KEY_J),
700 KEY(8, 2, KEY_K),
701 KEY(8, 3, KEY_INSERT),
702 KEY(8, 4, KEY_LINEFEED),
703 KEY(8, 5, KEY_U),
704 KEY(8, 6, KEY_I),
705 KEY(8, 7, KEY_O),
706
707 KEY(9, 0, KEY_4),
708 KEY(9, 1, KEY_5),
709 KEY(9, 2, KEY_6),
710 KEY(9, 3, KEY_7),
711 KEY(9, 4, KEY_8),
712 KEY(9, 5, KEY_1),
713 KEY(9, 6, KEY_2),
714 KEY(9, 7, KEY_3),
715
716 KEY(10, 0, KEY_F7),
717 KEY(10, 1, KEY_F8),
718 KEY(10, 2, KEY_F9),
719 KEY(10, 3, KEY_F10),
720 KEY(10, 4, KEY_FN),
721 KEY(10, 5, KEY_9),
722 KEY(10, 6, KEY_0),
723 KEY(10, 7, KEY_DOT),
724
725 KEY(11, 0, KEY_LEFTCTRL),
726 KEY(11, 1, KEY_F11), /* START */
727 KEY(11, 2, KEY_ENTER),
728 KEY(11, 3, KEY_SEARCH),
729 KEY(11, 4, KEY_DELETE),
730 KEY(11, 5, KEY_RIGHT),
731 KEY(11, 6, KEY_LEFT),
732 KEY(11, 7, KEY_RIGHTSHIFT),
733};
734
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700735static struct matrix_keymap_data surf_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530736 .keymap_size = ARRAY_SIZE(surf_keymap),
737 .keymap = surf_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700738};
739
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530740static struct pm8xxx_keypad_platform_data surf_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700741 .input_name = "surf_keypad",
742 .input_phys_device = "surf_keypad/input0",
743 .num_rows = 12,
744 .num_cols = 8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530745 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
746 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
747 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700748 .scan_delay_ms = 32,
749 .row_hold_ns = 91500,
750 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530751 .keymap_data = &surf_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700752};
753
754static struct matrix_keymap_data fluid_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530755 .keymap_size = ARRAY_SIZE(fluid_keymap),
756 .keymap = fluid_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700757};
758
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530759static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700760 .input_name = "fluid-keypad",
761 .input_phys_device = "fluid-keypad/input0",
762 .num_rows = 5,
763 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530764 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
765 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
766 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700767 .scan_delay_ms = 32,
768 .row_hold_ns = 91500,
769 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530770 .keymap_data = &fluid_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700771};
772
773static struct pm8058_pwm_pdata pm8058_pwm_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530774 .config = pm8058_pwm_config,
775 .enable = pm8058_pwm_enable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700776};
777
778static struct pmic8058_led pmic8058_ffa_leds[] = {
779 [0] = {
780 .name = "keyboard-backlight",
781 .max_brightness = 15,
782 .id = PMIC8058_ID_LED_KB_LIGHT,
Dima Zavinba5499e2011-01-10 11:00:30 -0800783 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700784};
785
786static struct pmic8058_leds_platform_data pm8058_ffa_leds_data = {
787 .num_leds = ARRAY_SIZE(pmic8058_ffa_leds),
788 .leds = pmic8058_ffa_leds,
789};
790
791static struct pmic8058_led pmic8058_surf_leds[] = {
792 [0] = {
793 .name = "keyboard-backlight",
794 .max_brightness = 15,
795 .id = PMIC8058_ID_LED_KB_LIGHT,
Dima Zavinba5499e2011-01-10 11:00:30 -0800796 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700797 [1] = {
798 .name = "voice:red",
799 .max_brightness = 20,
800 .id = PMIC8058_ID_LED_0,
Dima Zavinba5499e2011-01-10 11:00:30 -0800801 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700802 [2] = {
803 .name = "wlan:green",
804 .max_brightness = 20,
805 .id = PMIC8058_ID_LED_2,
806 },
807};
808
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700809static struct pmic8058_leds_platform_data pm8058_surf_leds_data = {
810 .num_leds = ARRAY_SIZE(pmic8058_surf_leds),
811 .leds = pmic8058_surf_leds,
812};
813
814static struct pmic8058_led pmic8058_fluid_leds[] = {
815 [0] = {
816 .name = "keyboard-backlight",
817 .max_brightness = 15,
818 .id = PMIC8058_ID_LED_KB_LIGHT,
819 },
820 [1] = {
821 .name = "flash:led_0",
822 .max_brightness = 15,
823 .id = PMIC8058_ID_FLASH_LED_0,
824 },
825 [2] = {
826 .name = "flash:led_1",
827 .max_brightness = 15,
828 .id = PMIC8058_ID_FLASH_LED_1,
829 },
830};
831
832static struct pmic8058_leds_platform_data pm8058_fluid_leds_data = {
833 .num_leds = ARRAY_SIZE(pmic8058_fluid_leds),
834 .leds = pmic8058_fluid_leds,
835};
836
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530837static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata = {
838 .irq_base = PMIC8058_IRQ_BASE,
839 .devirq = MSM_GPIO_TO_INT(PMIC_GPIO_INT),
840 .irq_trigger_flag = IRQF_TRIGGER_LOW,
841};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700842
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530843static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata = {
844 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
845};
846
847static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata = {
848 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
849};
850
851static struct pm8058_platform_data pm8058_7x30_data = {
852 .irq_pdata = &pm8xxx_irq_pdata,
853 .gpio_pdata = &pm8xxx_gpio_pdata,
854 .mpp_pdata = &pm8xxx_mpp_pdata,
855 .pwm_pdata = &pm8058_pwm_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700856};
857
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530858#ifdef CONFIG_MSM_SSBI
859static struct msm_ssbi_platform_data msm7x30_ssbi_pm8058_pdata = {
Kenneth Heitke48952912012-01-12 14:02:06 -0700860 .rsl_id = "D:PMIC_SSBI",
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530861 .controller_type = MSM_SBI_CTRL_SSBI2,
862 .slave = {
863 .name = "pm8058-core",
864 .platform_data = &pm8058_7x30_data,
865 },
866};
867#endif
868
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700869static struct i2c_board_info cy8info[] __initdata = {
870 {
871 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
872 .platform_data = &cyttsp_data,
873#ifndef CY_USE_TIMER
874 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
875#endif /* CY_USE_TIMER */
876 },
877};
878
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700879#ifdef CONFIG_MSM_CAMERA_V4L2
880static struct msm_camera_device_platform_data msm_camera_csi_device_data[] = {
881 {
882 .csid_core = 0,
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700883 .is_vpe = 1,
884 .ioclk = {
885 .vfe_clk_rate = 153600000,
886 },
887 },
Sreesudhan Ramakrish Ramkumar66deac32012-04-05 10:15:38 -0700888 {
889 .csid_core = 0,
890 .is_vpe = 1,
891 .ioclk = {
892 .vfe_clk_rate = 153600000,
893 },
894 },
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700895};
896
897static struct camera_vreg_t msm_7x30_back_cam_vreg[] = {
898 {"gp2", REG_LDO, 2600000, 2600000, -1},
899 {"lvsw1", REG_VS, 0, 0, 0},
900};
901
902static uint32_t camera_off_gpio_table[] = {
903 /* parallel CAMERA interfaces */
904 /* RST */
905 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
906 /* DAT2 */
907 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
908 /* DAT3 */
909 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
910 /* DAT4 */
911 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
912 /* DAT5 */
913 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
914 /* DAT6 */
915 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
916 /* DAT7 */
917 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
918 /* DAT8 */
919 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
920 /* DAT9 */
921 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
922 /* DAT10 */
923 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
924 /* DAT11 */
925 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
926 /* PCLK */
927 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
928 /* HSYNC_IN */
929 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
930 /* VSYNC_IN */
931 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
932 /* MCLK */
933 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
934};
935
936static uint32_t camera_on_gpio_table[] = {
937 /* parallel CAMERA interfaces */
938 /* RST */
939 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
940 /* DAT2 */
941 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
942 /* DAT3 */
943 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
944 /* DAT4 */
945 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
946 /* DAT5 */
947 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
948 /* DAT6 */
949 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
950 /* DAT7 */
951 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
952 /* DAT8 */
953 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
954 /* DAT9 */
955 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
956 /* DAT10 */
957 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
958 /* DAT11 */
959 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
960 /* PCLK */
961 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
962 /* HSYNC_IN */
963 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
964 /* VSYNC_IN */
965 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
966 /* MCLK */
967 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
968};
969
970static struct gpio msm7x30_back_cam_gpio[] = {
971 {0, GPIOF_DIR_OUT, "CAM_RESET"},
972};
973
974static struct msm_gpio_set_tbl msm7x30_back_cam_gpio_set_tbl[] = {
975 {0, GPIOF_OUT_INIT_LOW, 1000},
976 {0, GPIOF_OUT_INIT_HIGH, 4000},
977};
978
979static struct msm_camera_gpio_conf msm_7x30_back_cam_gpio_conf = {
980 .cam_gpio_req_tbl = msm7x30_back_cam_gpio,
981 .cam_gpio_req_tbl_size = ARRAY_SIZE(msm7x30_back_cam_gpio),
982 .cam_gpio_set_tbl = msm7x30_back_cam_gpio_set_tbl,
983 .cam_gpio_set_tbl_size = ARRAY_SIZE(msm7x30_back_cam_gpio_set_tbl),
984 .camera_off_table = camera_off_gpio_table,
985 .camera_off_table_size = ARRAY_SIZE(camera_off_gpio_table),
986 .camera_on_table = camera_on_gpio_table,
987 .camera_on_table_size = ARRAY_SIZE(camera_on_gpio_table),
988 .gpio_no_mux = 1,
989};
990
991static struct msm_camera_sensor_flash_data flash_vx6953 = {
992 .flash_type = MSM_CAMERA_FLASH_NONE,
993};
994
995static struct msm_camera_sensor_platform_info sensor_board_info_vx6953 = {
996 .mount_angle = 0,
997 .cam_vreg = msm_7x30_back_cam_vreg,
998 .num_vreg = ARRAY_SIZE(msm_7x30_back_cam_vreg),
999 .gpio_conf = &msm_7x30_back_cam_gpio_conf,
1000};
1001
1002static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1003 .sensor_name = "vx6953",
1004 .pdata = &msm_camera_csi_device_data[0],
1005 .flash_data = &flash_vx6953,
1006 .sensor_platform_info = &sensor_board_info_vx6953,
1007 .csi_if = 1,
1008 .camera_type = BACK_CAMERA_2D,
1009};
1010
Kevin Chan94b4c832012-03-02 21:27:16 -08001011static struct platform_device msm_camera_server = {
1012 .name = "msm_cam_server",
1013 .id = 0,
1014};
1015
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001016void __init msm7x30_init_cam(void)
1017{
Kevin Chan94b4c832012-03-02 21:27:16 -08001018 platform_device_register(&msm_camera_server);
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001019 platform_device_register(&msm_device_csic0);
1020 platform_device_register(&msm_device_vfe);
1021 platform_device_register(&msm_device_vpe);
1022}
1023
1024#ifdef CONFIG_I2C
1025static struct i2c_board_info msm_camera_boardinfo[] = {
1026 {
1027 I2C_BOARD_INFO("vx6953", 0x20),
1028 .platform_data = &msm_camera_sensor_vx6953_data,
1029 },
1030};
1031#endif
1032#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001033static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
1034#ifdef CONFIG_MT9D112
1035 {
1036 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
Dima Zavinba5499e2011-01-10 11:00:30 -08001037 },
1038#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001039#ifdef CONFIG_WEBCAM_OV9726
1040 {
1041 I2C_BOARD_INFO("ov9726", 0x10),
1042 },
1043#endif
1044#ifdef CONFIG_S5K3E2FX
1045 {
1046 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
1047 },
1048#endif
1049#ifdef CONFIG_MT9P012
1050 {
1051 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
1052 },
1053#endif
1054#ifdef CONFIG_VX6953
1055 {
1056 I2C_BOARD_INFO("vx6953", 0x20),
1057 },
1058#endif
1059#ifdef CONFIG_MT9E013
1060 {
1061 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
1062 },
1063#endif
1064#ifdef CONFIG_SN12M0PZ
1065 {
1066 I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1),
1067 },
1068#endif
1069#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
1070 {
1071 I2C_BOARD_INFO("mt9t013", 0x6C),
1072 },
1073#endif
1074
Dima Zavinba5499e2011-01-10 11:00:30 -08001075};
1076
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001077#ifdef CONFIG_MSM_CAMERA
1078#define CAM_STNDBY 143
1079static uint32_t camera_off_vcm_gpio_table[] = {
1080GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */
1081};
1082
1083static uint32_t camera_off_gpio_table[] = {
1084 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001085 /* RST */
1086 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1087 /* DAT2 */
1088 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1089 /* DAT3 */
1090 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1091 /* DAT4 */
1092 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1093 /* DAT5 */
1094 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1095 /* DAT6 */
1096 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1097 /* DAT7 */
1098 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1099 /* DAT8 */
1100 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1101 /* DAT9 */
1102 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1103 /* DAT10 */
1104 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1105 /* DAT11 */
1106 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1107 /* PCLK */
1108 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1109 /* HSYNC_IN */
1110 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1111 /* VSYNC_IN */
1112 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1113 /* MCLK */
1114 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001115};
1116
1117static uint32_t camera_on_vcm_gpio_table[] = {
1118GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */
1119};
1120
1121static uint32_t camera_on_gpio_table[] = {
1122 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001123 /* RST */
1124 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1125 /* DAT2 */
1126 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1127 /* DAT3 */
1128 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1129 /* DAT4 */
1130 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1131 /* DAT5 */
1132 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1133 /* DAT6 */
1134 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1135 /* DAT7 */
1136 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1137 /* DAT8 */
1138 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1139 /* DAT9 */
1140 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1141 /* DAT10 */
1142 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1143 /* DAT11 */
1144 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1145 /* PCLK */
1146 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1147 /* HSYNC_IN */
1148 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1149 /* VSYNC_IN */
1150 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1151 /* MCLK */
1152 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001153};
1154
1155static uint32_t camera_off_gpio_fluid_table[] = {
1156 /* FLUID: CAM_VGA_RST_N */
1157 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1158 /* FLUID: CAMIF_STANDBY */
1159 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1160};
1161
1162static uint32_t camera_on_gpio_fluid_table[] = {
1163 /* FLUID: CAM_VGA_RST_N */
1164 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1165 /* FLUID: CAMIF_STANDBY */
1166 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1167};
1168
1169static void config_gpio_table(uint32_t *table, int len)
1170{
1171 int n, rc;
1172 for (n = 0; n < len; n++) {
1173 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
1174 if (rc) {
1175 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
1176 __func__, table[n], rc);
1177 break;
1178 }
1179 }
1180}
1181static int config_camera_on_gpios(void)
1182{
1183 config_gpio_table(camera_on_gpio_table,
1184 ARRAY_SIZE(camera_on_gpio_table));
1185
1186 if (adie_get_detected_codec_type() != TIMPANI_ID)
1187 /* GPIO1 is shared also used in Timpani RF card so
1188 only configure it for non-Timpani RF card */
1189 config_gpio_table(camera_on_vcm_gpio_table,
1190 ARRAY_SIZE(camera_on_vcm_gpio_table));
1191
1192 if (machine_is_msm7x30_fluid()) {
1193 config_gpio_table(camera_on_gpio_fluid_table,
1194 ARRAY_SIZE(camera_on_gpio_fluid_table));
1195 /* FLUID: turn on 5V booster */
1196 gpio_set_value(
1197 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 1);
1198 /* FLUID: drive high to put secondary sensor to STANDBY */
1199 gpio_set_value(CAM_STNDBY, 1);
1200 }
1201 return 0;
1202}
1203
1204static void config_camera_off_gpios(void)
1205{
1206 config_gpio_table(camera_off_gpio_table,
1207 ARRAY_SIZE(camera_off_gpio_table));
1208
1209 if (adie_get_detected_codec_type() != TIMPANI_ID)
1210 /* GPIO1 is shared also used in Timpani RF card so
1211 only configure it for non-Timpani RF card */
1212 config_gpio_table(camera_off_vcm_gpio_table,
1213 ARRAY_SIZE(camera_off_vcm_gpio_table));
1214
1215 if (machine_is_msm7x30_fluid()) {
1216 config_gpio_table(camera_off_gpio_fluid_table,
1217 ARRAY_SIZE(camera_off_gpio_fluid_table));
1218 /* FLUID: turn off 5V booster */
1219 gpio_set_value(
1220 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 0);
1221 }
1222}
1223
1224struct resource msm_camera_resources[] = {
1225 {
1226 .start = 0xA6000000,
1227 .end = 0xA6000000 + SZ_1M - 1,
1228 .flags = IORESOURCE_MEM,
1229 },
1230 {
1231 .start = INT_VFE,
1232 .end = INT_VFE,
1233 .flags = IORESOURCE_IRQ,
1234 },
1235 {
1236 .flags = IORESOURCE_DMA,
1237 }
1238};
1239
1240struct msm_camera_device_platform_data msm_camera_device_data = {
1241 .camera_gpio_on = config_camera_on_gpios,
1242 .camera_gpio_off = config_camera_off_gpios,
1243 .ioext.camifpadphy = 0xAB000000,
1244 .ioext.camifpadsz = 0x00000400,
1245 .ioext.csiphy = 0xA6100000,
1246 .ioext.csisz = 0x00000400,
1247 .ioext.csiirq = INT_CSI,
1248 .ioclk.mclk_clk_rate = 24000000,
1249 .ioclk.vfe_clk_rate = 147456000,
1250};
1251
1252static struct msm_camera_sensor_flash_src msm_flash_src_pwm = {
1253 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PWM,
1254 ._fsrc.pwm_src.freq = 1000,
1255 ._fsrc.pwm_src.max_load = 300,
1256 ._fsrc.pwm_src.low_load = 30,
1257 ._fsrc.pwm_src.high_load = 100,
1258 ._fsrc.pwm_src.channel = 7,
1259};
1260
1261#ifdef CONFIG_MT9D112
1262static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1263 .flash_type = MSM_CAMERA_FLASH_LED,
1264 .flash_src = &msm_flash_src_pwm
1265};
1266
1267static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1268 .sensor_name = "mt9d112",
1269 .sensor_reset = 0,
1270 .sensor_pwd = 85,
1271 .vcm_pwd = 1,
1272 .vcm_enable = 0,
1273 .pdata = &msm_camera_device_data,
1274 .resource = msm_camera_resources,
1275 .num_resources = ARRAY_SIZE(msm_camera_resources),
1276 .flash_data = &flash_mt9d112,
1277 .csi_if = 0
1278};
1279
1280static struct platform_device msm_camera_sensor_mt9d112 = {
1281 .name = "msm_camera_mt9d112",
1282 .dev = {
1283 .platform_data = &msm_camera_sensor_mt9d112_data,
1284 },
1285};
1286#endif
1287
1288#ifdef CONFIG_WEBCAM_OV9726
1289
1290static struct msm_camera_sensor_platform_info ov9726_sensor_7630_info = {
1291 .mount_angle = 90
1292};
1293
1294static struct msm_camera_sensor_flash_data flash_ov9726 = {
1295 .flash_type = MSM_CAMERA_FLASH_LED,
1296 .flash_src = &msm_flash_src_pwm
1297};
1298static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
1299 .sensor_name = "ov9726",
1300 .sensor_reset = 0,
1301 .sensor_pwd = 85,
1302 .vcm_pwd = 1,
1303 .vcm_enable = 0,
1304 .pdata = &msm_camera_device_data,
1305 .resource = msm_camera_resources,
1306 .num_resources = ARRAY_SIZE(msm_camera_resources),
1307 .flash_data = &flash_ov9726,
1308 .sensor_platform_info = &ov9726_sensor_7630_info,
1309 .csi_if = 1
1310};
1311struct platform_device msm_camera_sensor_ov9726 = {
1312 .name = "msm_camera_ov9726",
1313 .dev = {
1314 .platform_data = &msm_camera_sensor_ov9726_data,
1315 },
1316};
1317#endif
1318
1319#ifdef CONFIG_S5K3E2FX
1320static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1321 .flash_type = MSM_CAMERA_FLASH_LED,
1322 .flash_src = &msm_flash_src_pwm,
1323};
1324
1325static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1326 .sensor_name = "s5k3e2fx",
1327 .sensor_reset = 0,
1328 .sensor_pwd = 85,
1329 .vcm_pwd = 1,
1330 .vcm_enable = 0,
1331 .pdata = &msm_camera_device_data,
1332 .resource = msm_camera_resources,
1333 .num_resources = ARRAY_SIZE(msm_camera_resources),
1334 .flash_data = &flash_s5k3e2fx,
1335 .csi_if = 0
1336};
1337
1338static struct platform_device msm_camera_sensor_s5k3e2fx = {
1339 .name = "msm_camera_s5k3e2fx",
1340 .dev = {
1341 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1342 },
1343};
1344#endif
1345
1346#ifdef CONFIG_MT9P012
1347static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1348 .flash_type = MSM_CAMERA_FLASH_LED,
1349 .flash_src = &msm_flash_src_pwm
1350};
1351
1352static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1353 .sensor_name = "mt9p012",
1354 .sensor_reset = 0,
1355 .sensor_pwd = 85,
1356 .vcm_pwd = 1,
1357 .vcm_enable = 1,
1358 .pdata = &msm_camera_device_data,
1359 .resource = msm_camera_resources,
1360 .num_resources = ARRAY_SIZE(msm_camera_resources),
1361 .flash_data = &flash_mt9p012,
1362 .csi_if = 0
1363};
1364
1365static struct platform_device msm_camera_sensor_mt9p012 = {
1366 .name = "msm_camera_mt9p012",
1367 .dev = {
1368 .platform_data = &msm_camera_sensor_mt9p012_data,
1369 },
1370};
1371#endif
1372
1373#ifdef CONFIG_MT9E013
1374static struct msm_camera_sensor_platform_info mt9e013_sensor_7630_info = {
1375 .mount_angle = 0
1376};
1377
1378static struct msm_camera_sensor_flash_data flash_mt9e013 = {
1379 .flash_type = MSM_CAMERA_FLASH_LED,
1380 .flash_src = &msm_flash_src_pwm
1381};
1382
1383static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
1384 .sensor_name = "mt9e013",
1385 .sensor_reset = 0,
1386 .sensor_pwd = 85,
1387 .vcm_pwd = 1,
1388 .vcm_enable = 1,
1389 .pdata = &msm_camera_device_data,
1390 .resource = msm_camera_resources,
1391 .num_resources = ARRAY_SIZE(msm_camera_resources),
1392 .flash_data = &flash_mt9e013,
1393 .sensor_platform_info = &mt9e013_sensor_7630_info,
1394 .csi_if = 1
1395};
1396
1397static struct platform_device msm_camera_sensor_mt9e013 = {
1398 .name = "msm_camera_mt9e013",
1399 .dev = {
1400 .platform_data = &msm_camera_sensor_mt9e013_data,
1401 },
1402};
1403#endif
1404
1405#ifdef CONFIG_VX6953
Jilai Wang971f97f2011-07-13 14:25:25 -04001406static struct msm_camera_sensor_platform_info vx6953_sensor_7630_info = {
1407 .mount_angle = 0
1408};
1409
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001410static struct msm_camera_sensor_flash_data flash_vx6953 = {
1411 .flash_type = MSM_CAMERA_FLASH_LED,
1412 .flash_src = &msm_flash_src_pwm
1413};
1414static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1415 .sensor_name = "vx6953",
1416 .sensor_reset = 0,
1417 .sensor_pwd = 85,
1418 .vcm_pwd = 1,
1419 .vcm_enable = 0,
1420 .pdata = &msm_camera_device_data,
1421 .resource = msm_camera_resources,
1422 .num_resources = ARRAY_SIZE(msm_camera_resources),
Jilai Wang971f97f2011-07-13 14:25:25 -04001423 .sensor_platform_info = &vx6953_sensor_7630_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001424 .flash_data = &flash_vx6953,
1425 .csi_if = 1
1426};
1427static struct platform_device msm_camera_sensor_vx6953 = {
1428 .name = "msm_camera_vx6953",
1429 .dev = {
1430 .platform_data = &msm_camera_sensor_vx6953_data,
1431 },
1432};
1433#endif
1434
1435#ifdef CONFIG_SN12M0PZ
1436static struct msm_camera_sensor_flash_src msm_flash_src_current_driver = {
1437 .flash_sr_type = MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER,
1438 ._fsrc.current_driver_src.low_current = 210,
1439 ._fsrc.current_driver_src.high_current = 700,
1440 ._fsrc.current_driver_src.driver_channel = &pm8058_fluid_leds_data,
1441};
1442
1443static struct msm_camera_sensor_flash_data flash_sn12m0pz = {
1444 .flash_type = MSM_CAMERA_FLASH_LED,
1445 .flash_src = &msm_flash_src_current_driver
1446};
1447static struct msm_camera_sensor_info msm_camera_sensor_sn12m0pz_data = {
1448 .sensor_name = "sn12m0pz",
1449 .sensor_reset = 0,
1450 .sensor_pwd = 85,
1451 .vcm_pwd = 1,
1452 .vcm_enable = 1,
1453 .pdata = &msm_camera_device_data,
1454 .flash_data = &flash_sn12m0pz,
1455 .resource = msm_camera_resources,
1456 .num_resources = ARRAY_SIZE(msm_camera_resources),
1457 .csi_if = 0
1458};
1459
1460static struct platform_device msm_camera_sensor_sn12m0pz = {
1461 .name = "msm_camera_sn12m0pz",
1462 .dev = {
1463 .platform_data = &msm_camera_sensor_sn12m0pz_data,
1464 },
1465};
1466#endif
1467
1468#ifdef CONFIG_MT9T013
1469static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1470 .flash_type = MSM_CAMERA_FLASH_LED,
1471 .flash_src = &msm_flash_src_pwm
1472};
1473
1474static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1475 .sensor_name = "mt9t013",
1476 .sensor_reset = 0,
1477 .sensor_pwd = 85,
1478 .vcm_pwd = 1,
1479 .vcm_enable = 0,
1480 .pdata = &msm_camera_device_data,
1481 .resource = msm_camera_resources,
1482 .num_resources = ARRAY_SIZE(msm_camera_resources),
1483 .flash_data = &flash_mt9t013,
1484 .csi_if = 1
1485};
1486
1487static struct platform_device msm_camera_sensor_mt9t013 = {
1488 .name = "msm_camera_mt9t013",
1489 .dev = {
1490 .platform_data = &msm_camera_sensor_mt9t013_data,
1491 },
1492};
1493#endif
1494
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001495#ifdef CONFIG_MSM_VPE
1496static struct resource msm_vpe_resources[] = {
1497 {
1498 .start = 0xAD200000,
1499 .end = 0xAD200000 + SZ_1M - 1,
1500 .flags = IORESOURCE_MEM,
1501 },
1502 {
1503 .start = INT_VPE,
1504 .end = INT_VPE,
1505 .flags = IORESOURCE_IRQ,
1506 },
1507};
1508
1509static struct platform_device msm_vpe_device = {
1510 .name = "msm_vpe",
1511 .id = 0,
1512 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1513 .resource = msm_vpe_resources,
1514};
1515#endif
1516
1517#endif /*CONFIG_MSM_CAMERA*/
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001518#endif
1519
1520#ifdef CONFIG_MSM_GEMINI
1521static struct resource msm_gemini_resources[] = {
1522 {
1523 .start = 0xA3A00000,
1524 .end = 0xA3A00000 + 0x0150 - 1,
1525 .flags = IORESOURCE_MEM,
1526 },
1527 {
1528 .start = INT_JPEG,
1529 .end = INT_JPEG,
1530 .flags = IORESOURCE_IRQ,
1531 },
1532};
1533
1534static struct platform_device msm_gemini_device = {
1535 .name = "msm_gemini",
1536 .resource = msm_gemini_resources,
1537 .num_resources = ARRAY_SIZE(msm_gemini_resources),
1538};
1539#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001540
1541#ifdef CONFIG_MSM7KV2_AUDIO
1542static uint32_t audio_pamp_gpio_config =
1543 GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1544
1545static uint32_t audio_fluid_icodec_tx_config =
1546 GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1547
1548static int __init snddev_poweramp_gpio_init(void)
1549{
1550 int rc;
1551
1552 pr_info("snddev_poweramp_gpio_init \n");
1553 rc = gpio_tlmm_config(audio_pamp_gpio_config, GPIO_CFG_ENABLE);
1554 if (rc) {
1555 printk(KERN_ERR
1556 "%s: gpio_tlmm_config(%#x)=%d\n",
1557 __func__, audio_pamp_gpio_config, rc);
1558 }
1559 return rc;
1560}
1561
1562void msm_snddev_tx_route_config(void)
1563{
1564 int rc;
1565
1566 pr_debug("%s()\n", __func__);
1567
1568 if (machine_is_msm7x30_fluid()) {
1569 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1570 GPIO_CFG_ENABLE);
1571 if (rc) {
1572 printk(KERN_ERR
1573 "%s: gpio_tlmm_config(%#x)=%d\n",
1574 __func__, audio_fluid_icodec_tx_config, rc);
1575 } else
1576 gpio_set_value(85, 0);
1577 }
1578}
1579
1580void msm_snddev_tx_route_deconfig(void)
1581{
1582 int rc;
1583
1584 pr_debug("%s()\n", __func__);
1585
1586 if (machine_is_msm7x30_fluid()) {
1587 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1588 GPIO_CFG_DISABLE);
1589 if (rc) {
1590 printk(KERN_ERR
1591 "%s: gpio_tlmm_config(%#x)=%d\n",
1592 __func__, audio_fluid_icodec_tx_config, rc);
1593 }
1594 }
1595}
1596
1597void msm_snddev_poweramp_on(void)
1598{
1599 gpio_set_value(82, 1); /* enable spkr poweramp */
1600 pr_info("%s: power on amplifier\n", __func__);
1601}
1602
1603void msm_snddev_poweramp_off(void)
1604{
1605 gpio_set_value(82, 0); /* disable spkr poweramp */
1606 pr_info("%s: power off amplifier\n", __func__);
1607}
1608
Justin Paupore3f40f342011-08-10 18:52:16 -07001609static struct regulator_bulk_data snddev_regs[] = {
1610 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
1611 { .supply = "ncp", .min_uV = 1800000, .max_uV = 1800000 },
1612};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001613
Justin Paupore3f40f342011-08-10 18:52:16 -07001614static int __init snddev_hsed_voltage_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001615{
1616 int rc;
1617
Justin Paupore3f40f342011-08-10 18:52:16 -07001618 rc = regulator_bulk_get(NULL, ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001619
Justin Paupore3f40f342011-08-10 18:52:16 -07001620 if (rc) {
1621 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1622 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001623 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001624
1625 rc = regulator_bulk_set_voltage(ARRAY_SIZE(snddev_regs), snddev_regs);
1626
1627 if (rc) {
1628 pr_err("%s: could not set regulator voltages: %d\n",
1629 __func__, rc);
1630 goto regs_free;
1631 }
1632
1633 return 0;
1634
1635regs_free:
1636 regulator_bulk_free(ARRAY_SIZE(snddev_regs), snddev_regs);
1637out:
1638 return rc;
1639}
1640
1641
1642void msm_snddev_hsed_voltage_on(void)
1643{
1644 int rc = regulator_bulk_enable(ARRAY_SIZE(snddev_regs), snddev_regs);
1645
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001646 if (rc)
Justin Paupore3f40f342011-08-10 18:52:16 -07001647 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001648}
1649
1650void msm_snddev_hsed_voltage_off(void)
1651{
Justin Paupore3f40f342011-08-10 18:52:16 -07001652 int rc = regulator_bulk_disable(ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001653
Justin Paupore3f40f342011-08-10 18:52:16 -07001654 if (rc) {
1655 pr_err("%s: could not disable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001656 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001657}
1658
1659static unsigned aux_pcm_gpio_on[] = {
1660 GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
1661 GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
1662 GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
1663 GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
1664};
1665
1666static int __init aux_pcm_gpio_init(void)
1667{
1668 int pin, rc;
1669
1670 pr_info("aux_pcm_gpio_init \n");
1671 for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) {
1672 rc = gpio_tlmm_config(aux_pcm_gpio_on[pin],
1673 GPIO_CFG_ENABLE);
1674 if (rc) {
1675 printk(KERN_ERR
1676 "%s: gpio_tlmm_config(%#x)=%d\n",
1677 __func__, aux_pcm_gpio_on[pin], rc);
1678 }
1679 }
1680 return rc;
1681}
1682
1683static struct msm_gpio mi2s_clk_gpios[] = {
1684 { GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1685 "MI2S_SCLK"},
1686 { GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1687 "MI2S_WS"},
1688 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1689 "MI2S_MCLK_A"},
1690};
1691
1692static struct msm_gpio mi2s_rx_data_lines_gpios[] = {
1693 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1694 "MI2S_DATA_SD0_A"},
1695 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1696 "MI2S_DATA_SD1_A"},
1697 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1698 "MI2S_DATA_SD2_A"},
1699 { GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1700 "MI2S_DATA_SD3"},
1701};
1702
1703static struct msm_gpio mi2s_tx_data_lines_gpios[] = {
1704 { GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1705 "MI2S_DATA_SD3"},
1706};
1707
1708int mi2s_config_clk_gpio(void)
1709{
1710 int rc = 0;
1711
1712 rc = msm_gpios_request_enable(mi2s_clk_gpios,
1713 ARRAY_SIZE(mi2s_clk_gpios));
1714 if (rc) {
1715 pr_err("%s: enable mi2s clk gpios failed\n",
1716 __func__);
1717 return rc;
1718 }
1719 return 0;
1720}
1721
1722int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask)
1723{
1724 int i, rc = 0;
1725 sd_line_mask &= MI2S_SD_LINE_MASK;
1726
1727 switch (direction) {
1728 case DIR_TX:
1729 msm_gpios_disable_free(mi2s_tx_data_lines_gpios, 1);
1730 break;
1731 case DIR_RX:
1732 i = 0;
1733 while (sd_line_mask) {
1734 if (sd_line_mask & 0x1)
1735 msm_gpios_disable_free(
1736 mi2s_rx_data_lines_gpios + i , 1);
1737 sd_line_mask = sd_line_mask >> 1;
1738 i++;
1739 }
1740 break;
1741 default:
1742 pr_err("%s: Invaild direction direction = %u\n",
1743 __func__, direction);
1744 rc = -EINVAL;
1745 break;
1746 }
1747 return rc;
1748}
1749
1750int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask)
1751{
1752 int i , rc = 0;
1753 u8 sd_config_done_mask = 0;
1754
1755 sd_line_mask &= MI2S_SD_LINE_MASK;
1756
1757 switch (direction) {
1758 case DIR_TX:
1759 if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) ||
1760 (sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) {
1761 pr_err("%s: can not use SD0 or SD1 or SD2 for TX"
1762 ".only can use SD3. sd_line_mask = 0x%x\n",
1763 __func__ , sd_line_mask);
1764 rc = -EINVAL;
1765 } else {
1766 rc = msm_gpios_request_enable(mi2s_tx_data_lines_gpios,
1767 1);
1768 if (rc)
1769 pr_err("%s: enable mi2s gpios for TX failed\n",
1770 __func__);
1771 }
1772 break;
1773 case DIR_RX:
1774 i = 0;
1775 while (sd_line_mask && (rc == 0)) {
1776 if (sd_line_mask & 0x1) {
1777 rc = msm_gpios_request_enable(
1778 mi2s_rx_data_lines_gpios + i , 1);
1779 if (rc) {
1780 pr_err("%s: enable mi2s gpios for"
1781 "RX failed. SD line = %s\n",
1782 __func__,
1783 (mi2s_rx_data_lines_gpios + i)->label);
1784 mi2s_unconfig_data_gpio(DIR_RX,
1785 sd_config_done_mask);
1786 } else
1787 sd_config_done_mask |= (1 << i);
1788 }
1789 sd_line_mask = sd_line_mask >> 1;
1790 i++;
1791 }
1792 break;
1793 default:
1794 pr_err("%s: Invaild direction direction = %u\n",
1795 __func__, direction);
1796 rc = -EINVAL;
1797 break;
1798 }
1799 return rc;
1800}
1801
1802int mi2s_unconfig_clk_gpio(void)
1803{
1804 msm_gpios_disable_free(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios));
1805 return 0;
1806}
1807
1808#endif /* CONFIG_MSM7KV2_AUDIO */
1809
1810static int __init buses_init(void)
1811{
1812 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT,
1813 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
1814 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
1815 __func__, PMIC_GPIO_INT);
1816
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301817 if (machine_is_msm8x60_fluid())
1818 pm8058_7x30_data.keypad_pdata = &fluid_keypad_data;
1819 else
1820 pm8058_7x30_data.keypad_pdata = &surf_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001821
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001822 return 0;
1823}
1824
1825#define TIMPANI_RESET_GPIO 1
1826
1827struct bahama_config_register{
1828 u8 reg;
1829 u8 value;
1830 u8 mask;
1831};
1832
1833enum version{
1834 VER_1_0,
1835 VER_2_0,
1836 VER_UNSUPPORTED = 0xFF
1837};
1838
Justin Paupore3f40f342011-08-10 18:52:16 -07001839static struct regulator *vreg_marimba_1;
1840static struct regulator *vreg_marimba_2;
1841static struct regulator *vreg_bahama;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001842
1843static struct msm_gpio timpani_reset_gpio_cfg[] = {
1844{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
1845 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} };
1846
1847static u8 read_bahama_ver(void)
1848{
1849 int rc;
1850 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1851 u8 bahama_version;
1852
1853 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
1854 if (rc < 0) {
1855 printk(KERN_ERR
1856 "%s: version read failed: %d\n",
1857 __func__, rc);
1858 return rc;
1859 } else {
1860 printk(KERN_INFO
1861 "%s: version read got: 0x%x\n",
1862 __func__, bahama_version);
1863 }
1864
1865 switch (bahama_version) {
1866 case 0x08: /* varient of bahama v1 */
1867 case 0x10:
1868 case 0x00:
1869 return VER_1_0;
1870 case 0x09: /* variant of bahama v2 */
1871 return VER_2_0;
1872 default:
1873 return VER_UNSUPPORTED;
1874 }
1875}
1876
1877static int config_timpani_reset(void)
1878{
1879 int rc;
1880
1881 rc = msm_gpios_request_enable(timpani_reset_gpio_cfg,
1882 ARRAY_SIZE(timpani_reset_gpio_cfg));
1883 if (rc < 0) {
1884 printk(KERN_ERR
1885 "%s: msm_gpios_request_enable failed (%d)\n",
1886 __func__, rc);
1887 }
1888 return rc;
1889}
1890
1891static unsigned int msm_timpani_setup_power(void)
1892{
1893 int rc;
1894
1895 rc = config_timpani_reset();
1896 if (rc < 0)
1897 goto out;
1898
Justin Paupore3f40f342011-08-10 18:52:16 -07001899 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001900 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001901 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001902 goto out;
1903 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001904
1905 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001906 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001907 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1908 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001909 }
1910
1911 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1);
1912 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001913 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001914 __func__, rc);
1915 msm_gpios_free(timpani_reset_gpio_cfg,
1916 ARRAY_SIZE(timpani_reset_gpio_cfg));
Justin Paupore3f40f342011-08-10 18:52:16 -07001917 goto disable_marimba_2;
1918 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001919
Justin Paupore3f40f342011-08-10 18:52:16 -07001920 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001921
Justin Paupore3f40f342011-08-10 18:52:16 -07001922disable_marimba_2:
1923 regulator_disable(vreg_marimba_2);
1924disable_marimba_1:
1925 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001926out:
1927 return rc;
1928};
1929
1930static void msm_timpani_shutdown_power(void)
1931{
1932 int rc;
1933
Justin Paupore3f40f342011-08-10 18:52:16 -07001934 rc = regulator_disable(vreg_marimba_2);
1935 if (rc)
1936 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1937
1938 rc = regulator_disable(vreg_marimba_1);
1939 if (rc)
1940 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001941
1942 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0);
Justin Paupore3f40f342011-08-10 18:52:16 -07001943 if (rc < 0)
1944 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001945 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001946
1947 msm_gpios_free(timpani_reset_gpio_cfg,
1948 ARRAY_SIZE(timpani_reset_gpio_cfg));
1949};
1950
1951static unsigned int msm_bahama_core_config(int type)
1952{
1953 int rc = 0;
1954
1955 if (type == BAHAMA_ID) {
1956
1957 int i;
1958 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1959
1960 const struct bahama_config_register v20_init[] = {
1961 /* reg, value, mask */
1962 { 0xF4, 0x84, 0xFF }, /* AREG */
1963 { 0xF0, 0x04, 0xFF } /* DREG */
1964 };
1965
1966 if (read_bahama_ver() == VER_2_0) {
1967 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
1968 u8 value = v20_init[i].value;
1969 rc = marimba_write_bit_mask(&config,
1970 v20_init[i].reg,
1971 &value,
1972 sizeof(v20_init[i].value),
1973 v20_init[i].mask);
1974 if (rc < 0) {
1975 printk(KERN_ERR
1976 "%s: reg %d write failed: %d\n",
1977 __func__, v20_init[i].reg, rc);
1978 return rc;
1979 }
1980 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
1981 " mask 0x%02x\n",
1982 __func__, v20_init[i].reg,
1983 v20_init[i].value, v20_init[i].mask);
1984 }
1985 }
1986 }
1987 printk(KERN_INFO "core type: %d\n", type);
1988
1989 return rc;
1990}
1991
1992static unsigned int msm_bahama_setup_power(void)
1993{
Justin Paupore3f40f342011-08-10 18:52:16 -07001994 int rc = regulator_enable(vreg_bahama);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001995
Justin Paupore3f40f342011-08-10 18:52:16 -07001996 if (rc)
1997 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001998
1999 return rc;
2000};
2001
2002static unsigned int msm_bahama_shutdown_power(int value)
2003{
2004 int rc = 0;
2005
2006 if (value != BAHAMA_ID) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002007 rc = regulator_disable(vreg_bahama);
2008
2009 if (rc)
2010 pr_err("%s: regulator_disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002011 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002012 }
2013
2014 return rc;
2015};
2016
2017static struct msm_gpio marimba_svlte_config_clock[] = {
2018 { GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2019 "MARIMBA_SVLTE_CLOCK_ENABLE" },
2020};
2021
2022static unsigned int msm_marimba_gpio_config_svlte(int gpio_cfg_marimba)
2023{
2024 if (machine_is_msm8x55_svlte_surf() ||
2025 machine_is_msm8x55_svlte_ffa()) {
2026 if (gpio_cfg_marimba)
2027 gpio_set_value(GPIO_PIN
2028 (marimba_svlte_config_clock->gpio_cfg), 1);
2029 else
2030 gpio_set_value(GPIO_PIN
2031 (marimba_svlte_config_clock->gpio_cfg), 0);
2032 }
2033
2034 return 0;
2035};
2036
2037static unsigned int msm_marimba_setup_power(void)
2038{
2039 int rc;
2040
Justin Paupore3f40f342011-08-10 18:52:16 -07002041 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002042 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002043 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002044 goto out;
2045 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002046
2047 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002048 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002049 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2050 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002051 }
2052
2053 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
2054 rc = msm_gpios_request_enable(marimba_svlte_config_clock,
2055 ARRAY_SIZE(marimba_svlte_config_clock));
2056 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002057 pr_err("%s: msm_gpios_request_enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002058 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002059 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002060 }
2061
2062 rc = gpio_direction_output(GPIO_PIN
2063 (marimba_svlte_config_clock->gpio_cfg), 0);
2064 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002065 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002066 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002067 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002068 }
2069 }
2070
Justin Paupore3f40f342011-08-10 18:52:16 -07002071 return 0;
2072
2073disable_marimba_2:
2074 regulator_disable(vreg_marimba_2);
2075disable_marimba_1:
2076 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002077out:
2078 return rc;
2079};
2080
2081static void msm_marimba_shutdown_power(void)
2082{
2083 int rc;
2084
Justin Paupore3f40f342011-08-10 18:52:16 -07002085 rc = regulator_disable(vreg_marimba_2);
2086 if (rc)
2087 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
2088
2089 rc = regulator_disable(vreg_marimba_1);
2090 if (rc)
2091 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002092};
2093
2094static int bahama_present(void)
2095{
2096 int id;
2097 switch (id = adie_get_detected_connectivity_type()) {
2098 case BAHAMA_ID:
2099 return 1;
2100
2101 case MARIMBA_ID:
2102 return 0;
2103
2104 case TIMPANI_ID:
2105 default:
2106 printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n",
2107 __func__, id);
2108 return -ENODEV;
2109 }
2110}
2111
Justin Paupore3f40f342011-08-10 18:52:16 -07002112struct regulator *fm_regulator;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002113static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
2114{
Justin Paupore3f40f342011-08-10 18:52:16 -07002115 int rc, voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002116 uint32_t irqcfg;
2117 const char *id = "FMPW";
2118
2119 int bahama_not_marimba = bahama_present();
2120
Justin Paupore3f40f342011-08-10 18:52:16 -07002121 if (bahama_not_marimba < 0) {
2122 pr_warn("%s: bahama_present: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002123 __func__, bahama_not_marimba);
Justin Paupore3f40f342011-08-10 18:52:16 -07002124 rc = -ENODEV;
2125 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002126 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002127 if (bahama_not_marimba) {
2128 fm_regulator = regulator_get(NULL, "s3");
2129 voltage = 1800000;
2130 } else {
2131 fm_regulator = regulator_get(NULL, "s2");
2132 voltage = 1300000;
2133 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002134
2135 if (IS_ERR(fm_regulator)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002136 rc = PTR_ERR(fm_regulator);
2137 pr_err("%s: regulator_get failed (%d)\n", __func__, rc);
2138 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002139 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002140
Justin Paupore3f40f342011-08-10 18:52:16 -07002141 rc = regulator_set_voltage(fm_regulator, voltage, voltage);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002142
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002143 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002144 pr_err("%s: regulator_set_voltage failed (%d)\n", __func__, rc);
2145 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002146 }
2147
Justin Paupore3f40f342011-08-10 18:52:16 -07002148 rc = regulator_enable(fm_regulator);
2149
2150 if (rc) {
2151 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2152 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002153 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002154
2155 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_ON);
2156
2157 if (rc < 0) {
2158 pr_err("%s: clock vote failed (%d)\n", __func__, rc);
2159 goto regulator_disable;
2160 }
2161
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002162 /*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2163 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002164 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002165 rc = marimba_gpio_config(1);
Justin Paupore3f40f342011-08-10 18:52:16 -07002166 if (rc < 0) {
2167 pr_err("%s: clock enable for svlte : %d\n",
2168 __func__, rc);
2169 goto clock_devote;
2170 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002171 }
2172 irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
2173 GPIO_CFG_2MA);
2174 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2175 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002176 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002177 rc = -EIO;
Justin Paupore3f40f342011-08-10 18:52:16 -07002178 goto gpio_deconfig;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002179
2180 }
2181 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002182
Justin Paupore3f40f342011-08-10 18:52:16 -07002183gpio_deconfig:
2184 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa())
2185 marimba_gpio_config(0);
2186clock_devote:
2187 pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_OFF);
2188regulator_disable:
2189 regulator_disable(fm_regulator);
2190regulator_free:
2191 regulator_put(fm_regulator);
2192 fm_regulator = NULL;
2193out:
2194 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002195};
2196
2197static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
2198{
2199 int rc;
2200 const char *id = "FMPW";
2201 uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
2202 GPIO_CFG_2MA);
2203
2204 int bahama_not_marimba = bahama_present();
2205 if (bahama_not_marimba == -1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002206 pr_warn("%s: bahama_present: %d\n",
2207 __func__, bahama_not_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002208 return;
2209 }
2210
2211 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2212 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002213 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002214 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002215 if (!IS_ERR_OR_NULL(fm_regulator)) {
2216 rc = regulator_disable(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002217
Justin Paupore3f40f342011-08-10 18:52:16 -07002218 if (rc)
2219 pr_err("%s: return val: %d\n", __func__, rc);
2220
2221 regulator_put(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002222 fm_regulator = NULL;
2223 }
2224 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
2225 PMAPP_CLOCK_VOTE_OFF);
2226 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002227 pr_err("%s: clock_vote return val: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002228
2229 /*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2230 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002231 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002232 rc = marimba_gpio_config(0);
2233 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002234 pr_err("%s: clock disable for svlte : %d\n",
2235 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002236 }
2237}
2238
2239static struct marimba_fm_platform_data marimba_fm_pdata = {
2240 .fm_setup = fm_radio_setup,
2241 .fm_shutdown = fm_radio_shutdown,
2242 .irq = MSM_GPIO_TO_INT(147),
2243 .vreg_s2 = NULL,
2244 .vreg_xo_out = NULL,
2245 .is_fm_soc_i2s_master = false,
2246 .config_i2s_gpio = NULL,
2247};
2248
2249
2250/* Slave id address for FM/CDC/QMEMBIST
2251 * Values can be programmed using Marimba slave id 0
2252 * should there be a conflict with other I2C devices
2253 * */
2254#define MARIMBA_SLAVE_ID_FM_ADDR 0x2A
2255#define MARIMBA_SLAVE_ID_CDC_ADDR 0x77
2256#define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66
2257
2258#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
2259#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
2260
2261static const char *tsadc_id = "MADC";
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002262
Justin Paupore3f40f342011-08-10 18:52:16 -07002263static struct regulator_bulk_data regs_tsadc_marimba[] = {
2264 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2265 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002266};
Justin Paupore3f40f342011-08-10 18:52:16 -07002267
2268static struct regulator_bulk_data regs_tsadc_timpani[] = {
2269 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2270 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2271 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2272};
2273
2274static struct regulator_bulk_data *regs_tsadc;
2275static int regs_tsadc_count;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002276
2277static int marimba_tsadc_power(int vreg_on)
2278{
Justin Paupore3f40f342011-08-10 18:52:16 -07002279 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002280 int tsadc_adie_type = adie_get_detected_codec_type();
2281
Justin Paupore3f40f342011-08-10 18:52:16 -07002282 switch (tsadc_adie_type) {
2283 case TIMPANI_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002284 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2285 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2286 if (rc) {
2287 pr_err("%s: unable to %svote for d1 clk\n",
2288 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002289 goto D1_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002290 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002291
2292 /* fall through */
2293 case MARIMBA_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002294 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2295 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2296 if (rc) {
2297 pr_err("%s: unable to %svote for d1 clk\n",
2298 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002299 goto D0_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002300 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002301
Justin Paupore3f40f342011-08-10 18:52:16 -07002302 WARN_ON(regs_tsadc_count == 0);
2303
2304 rc = vreg_on ?
2305 regulator_bulk_enable(regs_tsadc_count, regs_tsadc) :
2306 regulator_bulk_disable(regs_tsadc_count, regs_tsadc);
2307
2308 if (rc) {
2309 pr_err("%s: regulator %sable failed: %d\n",
2310 __func__, vreg_on ? "en" : "dis", rc);
2311 goto regulator_switch_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002312 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002313
2314 break;
2315 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002316 pr_err("%s:Adie %d not supported\n",
2317 __func__, tsadc_adie_type);
2318 return -ENODEV;
2319 }
2320
2321 msleep(5); /* ensure power is stable */
2322
2323 return 0;
2324
Justin Paupore3f40f342011-08-10 18:52:16 -07002325regulator_switch_fail:
2326 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2327 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2328D0_vote_fail:
2329 if (tsadc_adie_type == TIMPANI_ID)
2330 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2331 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2332D1_vote_fail:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002333 return rc;
2334}
2335
2336static int marimba_tsadc_init(void)
2337{
Justin Paupore3f40f342011-08-10 18:52:16 -07002338 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002339 int tsadc_adie_type = adie_get_detected_codec_type();
2340
Justin Paupore3f40f342011-08-10 18:52:16 -07002341 switch (tsadc_adie_type) {
2342 case MARIMBA_ID:
2343 regs_tsadc = regs_tsadc_marimba;
2344 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_marimba);
2345 break;
2346 case TIMPANI_ID:
2347 regs_tsadc = regs_tsadc_timpani;
2348 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_timpani);
2349 break;
2350 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002351 pr_err("%s:Adie %d not supported\n",
2352 __func__, tsadc_adie_type);
Justin Paupore3f40f342011-08-10 18:52:16 -07002353 rc = -ENODEV;
2354 goto out;
2355 }
2356
2357 rc = regulator_bulk_get(NULL, regs_tsadc_count, regs_tsadc);
2358 if (rc) {
2359 pr_err("%s: could not get regulators: %d\n",
2360 __func__, rc);
2361 goto out;
2362 }
2363
2364 rc = regulator_bulk_set_voltage(regs_tsadc_count, regs_tsadc);
2365 if (rc) {
2366 pr_err("%s: could not set regulator voltages: %d\n",
2367 __func__, rc);
2368 goto vreg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002369 }
2370
2371 return 0;
2372
Justin Paupore3f40f342011-08-10 18:52:16 -07002373vreg_free:
2374 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2375out:
2376 regs_tsadc = NULL;
2377 regs_tsadc_count = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002378 return rc;
2379}
2380
2381static int marimba_tsadc_exit(void)
2382{
Justin Paupore3f40f342011-08-10 18:52:16 -07002383 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2384 regs_tsadc_count = 0;
2385 regs_tsadc = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002386
Justin Paupore3f40f342011-08-10 18:52:16 -07002387 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002388}
2389
2390
2391static struct msm_ts_platform_data msm_ts_data = {
Anirudh Ghayal82b74722012-01-19 15:35:34 +05302392 .min_x = 284,
2393 .max_x = 3801,
2394 .min_y = 155,
2395 .max_y = 3929,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002396 .min_press = 0,
2397 .max_press = 255,
2398 .inv_x = 4096,
2399 .inv_y = 4096,
2400 .can_wakeup = false,
2401};
2402
2403static struct marimba_tsadc_platform_data marimba_tsadc_pdata = {
2404 .marimba_tsadc_power = marimba_tsadc_power,
2405 .init = marimba_tsadc_init,
2406 .exit = marimba_tsadc_exit,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002407 .tsadc_prechg_en = true,
2408 .can_wakeup = false,
2409 .setup = {
2410 .pen_irq_en = true,
2411 .tsadc_en = true,
2412 },
2413 .params2 = {
2414 .input_clk_khz = 2400,
2415 .sample_prd = TSADC_CLK_3,
2416 },
2417 .params3 = {
2418 .prechg_time_nsecs = 6400,
2419 .stable_time_nsecs = 6400,
2420 .tsadc_test_mode = 0,
2421 },
2422 .tssc_data = &msm_ts_data,
2423};
2424
Justin Paupore3f40f342011-08-10 18:52:16 -07002425static struct regulator_bulk_data codec_regs[] = {
2426 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
2427};
2428
2429static int __init msm_marimba_codec_init(void)
2430{
2431 int rc = regulator_bulk_get(NULL, ARRAY_SIZE(codec_regs), codec_regs);
2432
2433 if (rc) {
2434 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2435 goto out;
2436 }
2437
2438 rc = regulator_bulk_set_voltage(ARRAY_SIZE(codec_regs), codec_regs);
2439 if (rc) {
2440 pr_err("%s: could not set regulator voltages: %d\n",
2441 __func__, rc);
2442 goto reg_free;
2443 }
2444
2445 return rc;
2446
2447reg_free:
2448 regulator_bulk_free(ARRAY_SIZE(codec_regs), codec_regs);
2449out:
2450 return rc;
2451}
2452
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002453static int msm_marimba_codec_power(int vreg_on)
2454{
Justin Paupore3f40f342011-08-10 18:52:16 -07002455 int rc = vreg_on ?
2456 regulator_bulk_enable(ARRAY_SIZE(codec_regs), codec_regs) :
2457 regulator_bulk_disable(ARRAY_SIZE(codec_regs), codec_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002458
Justin Paupore3f40f342011-08-10 18:52:16 -07002459 if (rc) {
2460 pr_err("%s: could not %sable regulators: %d",
2461 __func__, vreg_on ? "en" : "dis", rc);
2462 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002463 }
2464
Justin Paupore3f40f342011-08-10 18:52:16 -07002465 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002466}
2467
2468static struct marimba_codec_platform_data mariba_codec_pdata = {
2469 .marimba_codec_power = msm_marimba_codec_power,
2470#ifdef CONFIG_MARIMBA_CODEC
2471 .snddev_profile_init = msm_snddev_init,
2472#endif
2473};
2474
2475static struct marimba_platform_data marimba_pdata = {
2476 .slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR,
2477 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2478 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2479 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
2480 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
2481 .marimba_setup = msm_marimba_setup_power,
2482 .marimba_shutdown = msm_marimba_shutdown_power,
2483 .bahama_setup = msm_bahama_setup_power,
2484 .bahama_shutdown = msm_bahama_shutdown_power,
2485 .marimba_gpio_config = msm_marimba_gpio_config_svlte,
2486 .bahama_core_config = msm_bahama_core_config,
2487 .fm = &marimba_fm_pdata,
2488 .codec = &mariba_codec_pdata,
2489 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2490};
2491
2492static void __init msm7x30_init_marimba(void)
2493{
2494 int rc;
2495
Justin Paupore3f40f342011-08-10 18:52:16 -07002496 struct regulator_bulk_data regs[] = {
2497 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2498 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2499 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
2500 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002501
Justin Paupore3f40f342011-08-10 18:52:16 -07002502 rc = msm_marimba_codec_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002503
Justin Paupore3f40f342011-08-10 18:52:16 -07002504 if (rc) {
2505 pr_err("%s: msm_marimba_codec_init failed (%d)\n",
2506 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002507 return;
2508 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002509
2510 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
2511
2512 if (rc) {
2513 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2514 return;
2515 }
2516
2517 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
2518
2519 if (rc) {
2520 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2521 regulator_bulk_free(ARRAY_SIZE(regs), regs);
2522 return;
2523 }
2524
2525 vreg_marimba_1 = regs[0].consumer;
2526 vreg_marimba_2 = regs[1].consumer;
2527 vreg_bahama = regs[2].consumer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002528}
2529
2530static struct marimba_codec_platform_data timpani_codec_pdata = {
2531 .marimba_codec_power = msm_marimba_codec_power,
2532#ifdef CONFIG_TIMPANI_CODEC
2533 .snddev_profile_init = msm_snddev_init_timpani,
2534#endif
2535};
2536
2537static struct marimba_platform_data timpani_pdata = {
2538 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2539 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2540 .marimba_setup = msm_timpani_setup_power,
2541 .marimba_shutdown = msm_timpani_shutdown_power,
2542 .codec = &timpani_codec_pdata,
2543 .tsadc = &marimba_tsadc_pdata,
2544 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2545};
2546
2547#define TIMPANI_I2C_SLAVE_ADDR 0xD
2548
2549static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
2550 {
2551 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
2552 .platform_data = &timpani_pdata,
2553 },
2554};
2555
2556#ifdef CONFIG_MSM7KV2_AUDIO
2557static struct resource msm_aictl_resources[] = {
2558 {
2559 .name = "aictl",
2560 .start = 0xa5000100,
2561 .end = 0xa5000100,
2562 .flags = IORESOURCE_MEM,
2563 }
2564};
2565
2566static struct resource msm_mi2s_resources[] = {
2567 {
2568 .name = "hdmi",
2569 .start = 0xac900000,
2570 .end = 0xac900038,
2571 .flags = IORESOURCE_MEM,
2572 },
2573 {
2574 .name = "codec_rx",
2575 .start = 0xac940040,
2576 .end = 0xac940078,
2577 .flags = IORESOURCE_MEM,
2578 },
2579 {
2580 .name = "codec_tx",
2581 .start = 0xac980080,
2582 .end = 0xac9800B8,
2583 .flags = IORESOURCE_MEM,
2584 }
2585
2586};
2587
2588static struct msm_lpa_platform_data lpa_pdata = {
2589 .obuf_hlb_size = 0x2BFF8,
2590 .dsp_proc_id = 0,
2591 .app_proc_id = 2,
2592 .nosb_config = {
2593 .llb_min_addr = 0,
2594 .llb_max_addr = 0x3ff8,
2595 .sb_min_addr = 0,
2596 .sb_max_addr = 0,
2597 },
2598 .sb_config = {
2599 .llb_min_addr = 0,
2600 .llb_max_addr = 0x37f8,
2601 .sb_min_addr = 0x3800,
2602 .sb_max_addr = 0x3ff8,
2603 }
2604};
2605
2606static struct resource msm_lpa_resources[] = {
2607 {
2608 .name = "lpa",
2609 .start = 0xa5000000,
2610 .end = 0xa50000a0,
2611 .flags = IORESOURCE_MEM,
2612 }
2613};
2614
2615static struct resource msm_aux_pcm_resources[] = {
2616
2617 {
2618 .name = "aux_codec_reg_addr",
2619 .start = 0xac9c00c0,
2620 .end = 0xac9c00c8,
2621 .flags = IORESOURCE_MEM,
2622 },
2623 {
2624 .name = "aux_pcm_dout",
2625 .start = 138,
2626 .end = 138,
2627 .flags = IORESOURCE_IO,
2628 },
2629 {
2630 .name = "aux_pcm_din",
2631 .start = 139,
2632 .end = 139,
2633 .flags = IORESOURCE_IO,
2634 },
2635 {
2636 .name = "aux_pcm_syncout",
2637 .start = 140,
2638 .end = 140,
2639 .flags = IORESOURCE_IO,
2640 },
2641 {
2642 .name = "aux_pcm_clkin_a",
2643 .start = 141,
2644 .end = 141,
2645 .flags = IORESOURCE_IO,
2646 },
2647};
2648
2649static struct platform_device msm_aux_pcm_device = {
2650 .name = "msm_aux_pcm",
2651 .id = 0,
2652 .num_resources = ARRAY_SIZE(msm_aux_pcm_resources),
2653 .resource = msm_aux_pcm_resources,
2654};
2655
2656struct platform_device msm_aictl_device = {
2657 .name = "audio_interct",
2658 .id = 0,
2659 .num_resources = ARRAY_SIZE(msm_aictl_resources),
2660 .resource = msm_aictl_resources,
2661};
2662
2663struct platform_device msm_mi2s_device = {
2664 .name = "mi2s",
2665 .id = 0,
2666 .num_resources = ARRAY_SIZE(msm_mi2s_resources),
2667 .resource = msm_mi2s_resources,
2668};
2669
2670struct platform_device msm_lpa_device = {
2671 .name = "lpa",
2672 .id = 0,
2673 .num_resources = ARRAY_SIZE(msm_lpa_resources),
2674 .resource = msm_lpa_resources,
2675 .dev = {
2676 .platform_data = &lpa_pdata,
2677 },
2678};
2679#endif /* CONFIG_MSM7KV2_AUDIO */
2680
2681#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2682 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2683 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2684 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2685 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2686 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2687#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2688 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2689 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2690 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2691 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2692 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2693 #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2694 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2695 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2696 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2697 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2698 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2699 #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2700 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2701 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2702 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2703 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2704 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2705#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
2706
2707static unsigned int dec_concurrency_table[] = {
2708 /* Audio LP */
2709 0,
2710 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2711 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2712 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2713 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)|
2714 (1<<MSM_ADSP_OP_DM)),
2715
2716 /* Concurrency 1 */
2717 (DEC4_FORMAT),
2718 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2719 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2720 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2721 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2722
2723 /* Concurrency 2 */
2724 (DEC4_FORMAT),
2725 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2726 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2727 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2728 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2729
2730 /* Concurrency 3 */
2731 (DEC4_FORMAT),
2732 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2733 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2734 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2735 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2736
2737 /* Concurrency 4 */
2738 (DEC4_FORMAT),
2739 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2740 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2741 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2742 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2743
2744 /* Concurrency 5 */
2745 (DEC4_FORMAT),
2746 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2747 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2748 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2749 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2750
2751 /* Concurrency 6 */
2752 (DEC4_FORMAT),
2753 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2754 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2755 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2756 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2757};
2758
2759#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
2760 .module_queueid = queueid, .module_decid = decid, \
2761 .nr_codec_support = nr_codec}
2762
2763#define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
2764 .max_instances_same_dec = max_instance_same, \
2765 .max_instances_diff_dec = max_instance_diff}
2766
2767static struct msm_adspdec_info dec_info_list[] = {
2768 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
2769 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
2770 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
2771 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
2772 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
2773};
2774
2775static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
2776 /* Non Turbo Mode */
2777 {
2778 DEC_INSTANCE(4, 3), /* WAV */
2779 DEC_INSTANCE(4, 3), /* ADPCM */
2780 DEC_INSTANCE(4, 2), /* MP3 */
2781 DEC_INSTANCE(0, 0), /* Real Audio */
2782 DEC_INSTANCE(4, 2), /* WMA */
2783 DEC_INSTANCE(3, 2), /* AAC */
2784 DEC_INSTANCE(0, 0), /* Reserved */
2785 DEC_INSTANCE(0, 0), /* MIDI */
2786 DEC_INSTANCE(4, 3), /* YADPCM */
2787 DEC_INSTANCE(4, 3), /* QCELP */
2788 DEC_INSTANCE(4, 3), /* AMRNB */
2789 DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
2790 DEC_INSTANCE(4, 3), /* EVRC */
2791 DEC_INSTANCE(1, 1), /* WMAPRO */
2792 },
2793 /* Turbo Mode */
2794 {
2795 DEC_INSTANCE(4, 3), /* WAV */
2796 DEC_INSTANCE(4, 3), /* ADPCM */
2797 DEC_INSTANCE(4, 3), /* MP3 */
2798 DEC_INSTANCE(0, 0), /* Real Audio */
2799 DEC_INSTANCE(4, 3), /* WMA */
2800 DEC_INSTANCE(4, 3), /* AAC */
2801 DEC_INSTANCE(0, 0), /* Reserved */
2802 DEC_INSTANCE(0, 0), /* MIDI */
2803 DEC_INSTANCE(4, 3), /* YADPCM */
2804 DEC_INSTANCE(4, 3), /* QCELP */
2805 DEC_INSTANCE(4, 3), /* AMRNB */
2806 DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
2807 DEC_INSTANCE(4, 3), /* EVRC */
2808 DEC_INSTANCE(1, 2), /* WMAPRO */
2809 },
2810};
2811
2812static struct msm_adspdec_database msm_device_adspdec_database = {
2813 .num_dec = ARRAY_SIZE(dec_info_list),
2814 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
2815 ARRAY_SIZE(dec_info_list)),
2816 .dec_concurrency_table = dec_concurrency_table,
2817 .dec_info_list = dec_info_list,
2818 .dec_instance_list = &dec_instance_list[0][0],
2819};
2820
2821static struct platform_device msm_device_adspdec = {
2822 .name = "msm_adspdec",
2823 .id = -1,
2824 .dev = {
2825 .platform_data = &msm_device_adspdec_database
2826 },
2827};
2828
2829static struct resource smc91x_resources[] = {
2830 [0] = {
2831 .start = 0x8A000300,
2832 .end = 0x8A0003ff,
2833 .flags = IORESOURCE_MEM,
2834 },
2835 [1] = {
2836 .start = MSM_GPIO_TO_INT(156),
2837 .end = MSM_GPIO_TO_INT(156),
2838 .flags = IORESOURCE_IRQ,
2839 },
2840};
2841
2842static struct platform_device smc91x_device = {
2843 .name = "smc91x",
2844 .id = 0,
2845 .num_resources = ARRAY_SIZE(smc91x_resources),
2846 .resource = smc91x_resources,
2847};
2848
2849static struct smsc911x_platform_config smsc911x_config = {
2850 .phy_interface = PHY_INTERFACE_MODE_MII,
2851 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
2852 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
2853 .flags = SMSC911X_USE_32BIT,
2854};
2855
2856static struct resource smsc911x_resources[] = {
2857 [0] = {
2858 .start = 0x8D000000,
2859 .end = 0x8D000100,
2860 .flags = IORESOURCE_MEM,
2861 },
2862 [1] = {
2863 .start = MSM_GPIO_TO_INT(88),
2864 .end = MSM_GPIO_TO_INT(88),
2865 .flags = IORESOURCE_IRQ,
2866 },
2867};
2868
2869static struct platform_device smsc911x_device = {
2870 .name = "smsc911x",
2871 .id = -1,
2872 .num_resources = ARRAY_SIZE(smsc911x_resources),
2873 .resource = smsc911x_resources,
2874 .dev = {
2875 .platform_data = &smsc911x_config,
2876 },
2877};
2878
2879static struct msm_gpio smsc911x_gpios[] = {
2880 { GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" },
2881 { GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" },
2882 { GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" },
2883 { GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" },
2884 { GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" },
2885 { GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" },
2886 { GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" },
2887 { GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" },
2888};
2889
2890static void msm7x30_cfg_smsc911x(void)
2891{
2892 int rc;
2893
2894 rc = msm_gpios_request_enable(smsc911x_gpios,
2895 ARRAY_SIZE(smsc911x_gpios));
2896 if (rc)
2897 pr_err("%s: unable to enable gpios\n", __func__);
2898}
2899
2900#ifdef CONFIG_USB_G_ANDROID
2901static struct android_usb_platform_data android_usb_pdata = {
2902 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2903};
2904
2905static struct platform_device android_usb_device = {
2906 .name = "android_usb",
2907 .id = -1,
2908 .dev = {
2909 .platform_data = &android_usb_pdata,
2910 },
2911};
2912#endif
2913
2914static struct msm_gpio optnav_config_data[] = {
2915 { GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA),
2916 "optnav_chip_select" },
2917};
2918
Justin Paupore3f40f342011-08-10 18:52:16 -07002919static struct regulator_bulk_data optnav_regulators[] = {
2920 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2921 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
2922 { .supply = "gp9", .min_uV = 1800000, .max_uV = 1800000 },
2923 { .supply = "usb", .min_uV = 3300000, .max_uV = 3300000 },
2924};
2925
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002926static void __iomem *virtual_optnav;
2927
2928static int optnav_gpio_setup(void)
2929{
2930 int rc = -ENODEV;
2931 rc = msm_gpios_request_enable(optnav_config_data,
2932 ARRAY_SIZE(optnav_config_data));
2933
Justin Paupore3f40f342011-08-10 18:52:16 -07002934 if (rc)
2935 return rc;
2936
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002937 /* Configure the FPGA for GPIOs */
2938 virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4);
2939 if (!virtual_optnav) {
2940 pr_err("%s:Could not ioremap region\n", __func__);
2941 return -ENOMEM;
2942 }
2943 /*
2944 * Configure the FPGA to set GPIO 19 as
2945 * normal, active(enabled), output(MSM to SURF)
2946 */
2947 writew(0x311E, virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002948
2949 rc = regulator_bulk_get(NULL, ARRAY_SIZE(optnav_regulators),
2950 optnav_regulators);
2951 if (rc)
2952 return rc;
2953
2954 rc = regulator_bulk_set_voltage(ARRAY_SIZE(optnav_regulators),
2955 optnav_regulators);
2956
2957 if (rc)
2958 goto regulator_put;
2959
2960 return rc;
2961
2962regulator_put:
2963 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002964 return rc;
2965}
2966
2967static void optnav_gpio_release(void)
2968{
2969 msm_gpios_disable_free(optnav_config_data,
2970 ARRAY_SIZE(optnav_config_data));
2971 iounmap(virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002972 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002973}
2974
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002975static int optnav_enable(void)
2976{
2977 int rc;
2978 /*
2979 * Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
2980 * for I2C communication with keyboard.
2981 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002982
Justin Paupore3f40f342011-08-10 18:52:16 -07002983 rc = regulator_bulk_enable(ARRAY_SIZE(optnav_regulators),
2984 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002985
Justin Paupore3f40f342011-08-10 18:52:16 -07002986 if (rc)
2987 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002988
2989 /* Enable the chip select GPIO */
2990 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2991 gpio_set_value(OPTNAV_CHIP_SELECT, 0);
2992
2993 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002994}
2995
2996static void optnav_disable(void)
2997{
Justin Paupore3f40f342011-08-10 18:52:16 -07002998 regulator_bulk_disable(ARRAY_SIZE(optnav_regulators),
2999 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003000
3001 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
3002}
3003
3004static struct ofn_atlab_platform_data optnav_data = {
3005 .gpio_setup = optnav_gpio_setup,
3006 .gpio_release = optnav_gpio_release,
3007 .optnav_on = optnav_enable,
3008 .optnav_off = optnav_disable,
3009 .rotate_xy = 0,
3010 .function1 = {
3011 .no_motion1_en = true,
3012 .touch_sensor_en = true,
3013 .ofn_en = true,
3014 .clock_select_khz = 1500,
3015 .cpi_selection = 1200,
3016 },
3017 .function2 = {
3018 .invert_y = false,
3019 .invert_x = true,
3020 .swap_x_y = false,
3021 .hold_a_b_en = true,
3022 .motion_filter_en = true,
3023 },
3024};
3025
3026static int hdmi_comm_power(int on, int show);
3027static int hdmi_init_irq(void);
3028static int hdmi_enable_5v(int on);
3029static int hdmi_core_power(int on, int show);
3030static int hdmi_cec_power(int on);
3031static bool hdmi_check_hdcp_hw_support(void);
3032
3033static struct msm_hdmi_platform_data adv7520_hdmi_data = {
3034 .irq = MSM_GPIO_TO_INT(18),
3035 .comm_power = hdmi_comm_power,
3036 .init_irq = hdmi_init_irq,
3037 .enable_5v = hdmi_enable_5v,
3038 .core_power = hdmi_core_power,
3039 .cec_power = hdmi_cec_power,
3040 .check_hdcp_hw_support = hdmi_check_hdcp_hw_support,
3041};
3042
3043#ifdef CONFIG_BOSCH_BMA150
Justin Paupore3f40f342011-08-10 18:52:16 -07003044
3045static struct regulator_bulk_data sensors_ldo[] = {
3046 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
3047 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
3048};
3049
3050static int __init sensors_ldo_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003051{
3052 int rc;
3053
Justin Paupore3f40f342011-08-10 18:52:16 -07003054 rc = regulator_bulk_get(NULL, ARRAY_SIZE(sensors_ldo), sensors_ldo);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003055
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003056 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003057 pr_err("%s: could not get regulators: %d\n", __func__, rc);
3058 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003059 }
3060
Justin Paupore3f40f342011-08-10 18:52:16 -07003061 rc = regulator_bulk_set_voltage(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3062
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003063 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003064 pr_err("%s: could not set voltages: %d\n", __func__, rc);
3065 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003066 }
3067
3068 return 0;
3069
Justin Paupore3f40f342011-08-10 18:52:16 -07003070reg_free:
3071 regulator_bulk_free(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3072out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003073 return rc;
3074}
3075
Justin Paupore3f40f342011-08-10 18:52:16 -07003076static int sensors_ldo_set(int on)
3077{
3078 int rc = on ?
3079 regulator_bulk_enable(ARRAY_SIZE(sensors_ldo), sensors_ldo) :
3080 regulator_bulk_disable(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3081
3082 if (rc)
3083 pr_err("%s: could not %sable regulators: %d\n",
3084 __func__, on ? "en" : "dis", rc);
3085
3086 return rc;
3087}
3088
3089static int sensors_ldo_enable(void)
3090{
3091 return sensors_ldo_set(1);
3092}
3093
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003094static void sensors_ldo_disable(void)
3095{
Justin Paupore3f40f342011-08-10 18:52:16 -07003096 sensors_ldo_set(0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003097}
Justin Paupore3f40f342011-08-10 18:52:16 -07003098
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003099static struct bma150_platform_data bma150_data = {
3100 .power_on = sensors_ldo_enable,
3101 .power_off = sensors_ldo_disable,
3102};
3103
3104static struct i2c_board_info bma150_board_info[] __initdata = {
3105 {
3106 I2C_BOARD_INFO("bma150", 0x38),
3107 .flags = I2C_CLIENT_WAKE,
3108 .irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
3109 .platform_data = &bma150_data,
3110 },
3111};
3112#endif
3113
3114static struct i2c_board_info msm_i2c_board_info[] = {
3115 {
3116 I2C_BOARD_INFO("m33c01", OPTNAV_I2C_SLAVE_ADDR),
3117 .irq = MSM_GPIO_TO_INT(OPTNAV_IRQ),
3118 .platform_data = &optnav_data,
3119 },
3120 {
3121 I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR),
3122 .platform_data = &adv7520_hdmi_data,
3123 },
3124};
3125
3126static struct i2c_board_info msm_marimba_board_info[] = {
3127 {
3128 I2C_BOARD_INFO("marimba", 0xc),
3129 .platform_data = &marimba_pdata,
3130 }
3131};
3132
3133
3134static struct msm_handset_platform_data hs_platform_data = {
3135 .hs_name = "7k_handset",
3136 .pwr_key_delay_ms = 500, /* 0 will disable end key */
3137};
3138
3139static struct platform_device hs_device = {
3140 .name = "msm-handset",
3141 .id = -1,
3142 .dev = {
3143 .platform_data = &hs_platform_data,
3144 },
3145};
3146
3147static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +05303148 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003149 .idle_supported = 1,
3150 .suspend_supported = 1,
3151 .idle_enabled = 1,
3152 .suspend_enabled = 1,
3153 .latency = 8594,
3154 .residency = 23740,
3155 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303156 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003157 .idle_supported = 1,
3158 .suspend_supported = 1,
3159 .idle_enabled = 1,
3160 .suspend_enabled = 1,
3161 .latency = 4594,
3162 .residency = 23740,
3163 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303164 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003165#ifdef CONFIG_MSM_STANDALONE_POWER_COLLAPSE
3166 .idle_supported = 1,
3167 .suspend_supported = 1,
3168 .idle_enabled = 1,
3169 .suspend_enabled = 0,
3170#else /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3171 .idle_supported = 0,
3172 .suspend_supported = 0,
3173 .idle_enabled = 0,
3174 .suspend_enabled = 0,
3175#endif /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3176 .latency = 500,
3177 .residency = 6000,
3178 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303179 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003180 .idle_supported = 1,
3181 .suspend_supported = 1,
3182 .idle_enabled = 0,
3183 .suspend_enabled = 1,
3184 .latency = 443,
3185 .residency = 1098,
3186 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303187 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003188 .idle_supported = 1,
3189 .suspend_supported = 1,
3190 .idle_enabled = 1,
3191 .suspend_enabled = 1,
3192 .latency = 2,
3193 .residency = 0,
3194 },
3195};
3196
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003197static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3198 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
3199 .v_addr = (uint32_t *)PAGE_OFFSET,
3200};
3201
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003202static struct resource qsd_spi_resources[] = {
3203 {
3204 .name = "spi_irq_in",
3205 .start = INT_SPI_INPUT,
3206 .end = INT_SPI_INPUT,
3207 .flags = IORESOURCE_IRQ,
3208 },
3209 {
3210 .name = "spi_irq_out",
3211 .start = INT_SPI_OUTPUT,
3212 .end = INT_SPI_OUTPUT,
3213 .flags = IORESOURCE_IRQ,
3214 },
3215 {
3216 .name = "spi_irq_err",
3217 .start = INT_SPI_ERROR,
3218 .end = INT_SPI_ERROR,
3219 .flags = IORESOURCE_IRQ,
3220 },
3221 {
3222 .name = "spi_base",
3223 .start = 0xA8000000,
3224 .end = 0xA8000000 + SZ_4K - 1,
3225 .flags = IORESOURCE_MEM,
3226 },
3227 {
3228 .name = "spidm_channels",
3229 .flags = IORESOURCE_DMA,
3230 },
3231 {
3232 .name = "spidm_crci",
3233 .flags = IORESOURCE_DMA,
3234 },
3235};
3236
3237#define AMDH0_BASE_PHYS 0xAC200000
3238#define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
3239static int msm_qsd_spi_dma_config(void)
3240{
3241 void __iomem *ct_adm_base = 0;
3242 u32 spi_mux = 0;
3243 int ret = 0;
3244
3245 ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
3246 if (!ct_adm_base) {
3247 pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
3248 return -ENOMEM;
3249 }
3250
3251 spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
3252
3253 qsd_spi_resources[4].start = DMOV_USB_CHAN;
3254 qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
3255
3256 switch (spi_mux) {
3257 case (1):
3258 qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
3259 qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
3260 break;
3261 case (2):
3262 qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
3263 qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
3264 break;
3265 case (3):
3266 qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
3267 qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
3268 break;
3269 default:
3270 ret = -ENOENT;
3271 }
3272
3273 iounmap(ct_adm_base);
3274
3275 return ret;
3276}
3277
3278static struct platform_device qsd_device_spi = {
3279 .name = "spi_qsd",
3280 .id = 0,
3281 .num_resources = ARRAY_SIZE(qsd_spi_resources),
3282 .resource = qsd_spi_resources,
3283};
3284
3285#ifdef CONFIG_SPI_QSD
3286static struct spi_board_info lcdc_sharp_spi_board_info[] __initdata = {
3287 {
3288 .modalias = "lcdc_sharp_ls038y7dx01",
3289 .mode = SPI_MODE_1,
3290 .bus_num = 0,
3291 .chip_select = 0,
3292 .max_speed_hz = 26331429,
3293 }
3294};
3295static struct spi_board_info lcdc_toshiba_spi_board_info[] __initdata = {
3296 {
3297 .modalias = "lcdc_toshiba_ltm030dd40",
3298 .mode = SPI_MODE_3|SPI_CS_HIGH,
3299 .bus_num = 0,
3300 .chip_select = 0,
3301 .max_speed_hz = 9963243,
3302 }
3303};
3304#endif
3305
3306static struct msm_gpio qsd_spi_gpio_config_data[] = {
3307 { GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3308 { GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3309 { GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" },
3310 { GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3311};
3312
3313static int msm_qsd_spi_gpio_config(void)
3314{
3315 return msm_gpios_request_enable(qsd_spi_gpio_config_data,
3316 ARRAY_SIZE(qsd_spi_gpio_config_data));
3317}
3318
3319static void msm_qsd_spi_gpio_release(void)
3320{
3321 msm_gpios_disable_free(qsd_spi_gpio_config_data,
3322 ARRAY_SIZE(qsd_spi_gpio_config_data));
3323}
3324
3325static struct msm_spi_platform_data qsd_spi_pdata = {
3326 .max_clock_speed = 26331429,
3327 .gpio_config = msm_qsd_spi_gpio_config,
3328 .gpio_release = msm_qsd_spi_gpio_release,
3329 .dma_config = msm_qsd_spi_dma_config,
3330};
3331
3332static void __init msm_qsd_spi_init(void)
3333{
3334 qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
3335}
3336
3337#ifdef CONFIG_USB_EHCI_MSM_72K
3338static void msm_hsusb_vbus_power(unsigned phy_info, int on)
3339{
3340 int rc;
3341 static int vbus_is_on;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303342 struct pm8xxx_gpio_init_info usb_vbus = {
3343 PM8058_GPIO_PM_TO_SYS(36),
3344 {
3345 .direction = PM_GPIO_DIR_OUT,
3346 .pull = PM_GPIO_PULL_NO,
3347 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3348 .output_value = 1,
3349 .vin_sel = 2,
3350 .out_strength = PM_GPIO_STRENGTH_MED,
3351 .function = PM_GPIO_FUNC_NORMAL,
3352 .inv_int_pol = 0,
3353 },
3354 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003355
3356 /* If VBUS is already on (or off), do nothing. */
3357 if (unlikely(on == vbus_is_on))
3358 return;
3359
3360 if (on) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303361 rc = pm8xxx_gpio_config(usb_vbus.gpio, &usb_vbus.config);
3362 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003363 pr_err("%s PMIC GPIO 36 write failed\n", __func__);
3364 return;
3365 }
3366 } else {
3367 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(36), 0);
3368 }
3369
3370 vbus_is_on = on;
3371}
3372
3373static struct msm_usb_host_platform_data msm_usb_host_pdata = {
3374 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
3375 .vbus_power = msm_hsusb_vbus_power,
3376 .power_budget = 180,
3377};
3378#endif
3379
3380#ifdef CONFIG_USB_MSM_OTG_72K
3381static int hsusb_rpc_connect(int connect)
3382{
3383 if (connect)
3384 return msm_hsusb_rpc_connect();
3385 else
3386 return msm_hsusb_rpc_close();
3387}
3388#endif
3389
3390#ifdef CONFIG_USB_MSM_OTG_72K
Justin Paupore3f40f342011-08-10 18:52:16 -07003391static struct regulator *vreg_3p3;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003392static int msm_hsusb_ldo_init(int init)
3393{
3394 uint32_t version = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07003395 int def_vol = 3400000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003396
3397 version = socinfo_get_version();
3398
3399 if (SOCINFO_VERSION_MAJOR(version) >= 2 &&
3400 SOCINFO_VERSION_MINOR(version) >= 1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003401 def_vol = 3075000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003402 pr_debug("%s: default voltage:%d\n", __func__, def_vol);
3403 }
3404
3405 if (init) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003406 vreg_3p3 = regulator_get(NULL, "usb");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003407 if (IS_ERR(vreg_3p3))
3408 return PTR_ERR(vreg_3p3);
Justin Paupore3f40f342011-08-10 18:52:16 -07003409 regulator_set_voltage(vreg_3p3, def_vol, def_vol);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003410 } else
Justin Paupore3f40f342011-08-10 18:52:16 -07003411 regulator_put(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003412
3413 return 0;
3414}
3415
3416static int msm_hsusb_ldo_enable(int enable)
3417{
3418 static int ldo_status;
3419
3420 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3421 return -ENODEV;
3422
3423 if (ldo_status == enable)
3424 return 0;
3425
3426 ldo_status = enable;
3427
3428 if (enable)
Justin Paupore3f40f342011-08-10 18:52:16 -07003429 return regulator_enable(vreg_3p3);
3430 else
3431 return regulator_disable(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003432}
3433
3434static int msm_hsusb_ldo_set_voltage(int mV)
3435{
Justin Paupore3f40f342011-08-10 18:52:16 -07003436 static int cur_voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003437
3438 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3439 return -ENODEV;
3440
3441 if (cur_voltage == mV)
3442 return 0;
3443
3444 cur_voltage = mV;
3445
3446 pr_debug("%s: (%d)\n", __func__, mV);
3447
Justin Paupore3f40f342011-08-10 18:52:16 -07003448 return regulator_set_voltage(vreg_3p3, mV*1000, mV*1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003449}
3450#endif
3451
3452#ifndef CONFIG_USB_EHCI_MSM_72K
3453static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init);
3454#endif
3455static struct msm_otg_platform_data msm_otg_pdata = {
3456 .rpc_connect = hsusb_rpc_connect,
3457
3458#ifndef CONFIG_USB_EHCI_MSM_72K
3459 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
3460#else
3461 .vbus_power = msm_hsusb_vbus_power,
3462#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003463 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
3464 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
3465 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
3466 .se1_gating = SE1_GATING_DISABLE,
3467 .chg_vbus_draw = hsusb_chg_vbus_draw,
3468 .chg_connected = hsusb_chg_connected,
3469 .chg_init = hsusb_chg_init,
3470 .ldo_enable = msm_hsusb_ldo_enable,
3471 .ldo_init = msm_hsusb_ldo_init,
3472 .ldo_set_voltage = msm_hsusb_ldo_set_voltage,
3473};
3474
3475#ifdef CONFIG_USB_GADGET
3476static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
3477 .is_phy_status_timer_on = 1,
3478};
3479#endif
3480#ifndef CONFIG_USB_EHCI_MSM_72K
3481typedef void (*notify_vbus_state) (int);
3482notify_vbus_state notify_vbus_state_func_ptr;
3483int vbus_on_irq;
3484static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
3485{
3486 pr_info("%s: vbus notification from pmic\n", __func__);
3487
3488 (*notify_vbus_state_func_ptr) (1);
3489
3490 return IRQ_HANDLED;
3491}
3492static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
3493{
3494 int ret;
3495
3496 if (init) {
3497 if (!callback)
3498 return -ENODEV;
3499
3500 notify_vbus_state_func_ptr = callback;
3501 vbus_on_irq = platform_get_irq_byname(&msm_device_otg,
3502 "vbus_on");
3503 if (vbus_on_irq <= 0) {
3504 pr_err("%s: unable to get vbus on irq\n", __func__);
3505 return -ENODEV;
3506 }
3507
3508 ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq,
3509 IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
3510 if (ret < 0) {
3511 pr_info("%s: request_irq for vbus_on"
3512 "interrupt failed\n", __func__);
3513 return ret;
3514 }
3515 msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
3516 return 0;
3517 } else {
3518 free_irq(vbus_on_irq, 0);
3519 notify_vbus_state_func_ptr = NULL;
3520 return 0;
3521 }
3522}
3523#endif
3524
3525static struct android_pmem_platform_data android_pmem_pdata = {
3526 .name = "pmem",
3527 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
3528 .cached = 1,
3529 .memory_type = MEMTYPE_EBI0,
3530};
3531
3532static struct platform_device android_pmem_device = {
3533 .name = "android_pmem",
3534 .id = 0,
3535 .dev = { .platform_data = &android_pmem_pdata },
3536};
3537
3538#ifndef CONFIG_SPI_QSD
3539static int lcdc_gpio_array_num[] = {
3540 45, /* spi_clk */
3541 46, /* spi_cs */
3542 47, /* spi_mosi */
3543 48, /* spi_miso */
3544 };
3545
3546static struct msm_gpio lcdc_gpio_config_data[] = {
3547 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3548 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3549 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
3550 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3551};
3552
3553static void lcdc_config_gpios(int enable)
3554{
3555 if (enable) {
3556 msm_gpios_request_enable(lcdc_gpio_config_data,
3557 ARRAY_SIZE(
3558 lcdc_gpio_config_data));
3559 } else
3560 msm_gpios_disable_free(lcdc_gpio_config_data,
3561 ARRAY_SIZE(
3562 lcdc_gpio_config_data));
3563}
3564#endif
3565
3566static struct msm_panel_common_pdata lcdc_sharp_panel_data = {
3567#ifndef CONFIG_SPI_QSD
3568 .panel_config_gpio = lcdc_config_gpios,
3569 .gpio_num = lcdc_gpio_array_num,
3570#endif
3571 .gpio = 2, /* LPG PMIC_GPIO26 channel number */
3572};
3573
3574static struct platform_device lcdc_sharp_panel_device = {
3575 .name = "lcdc_sharp_wvga",
3576 .id = 0,
3577 .dev = {
3578 .platform_data = &lcdc_sharp_panel_data,
3579 }
3580};
3581
3582static struct msm_gpio dtv_panel_irq_gpios[] = {
3583 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
3584 "hdmi_int" },
3585};
3586
3587static struct msm_gpio dtv_panel_gpios[] = {
3588 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
3589 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
3590 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
3591 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
3592 { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
3593 { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
3594 { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
3595 { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
3596 { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
3597 { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
3598 { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
3599 { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
3600 { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
3601 { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
3602 { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
3603 { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
3604 { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
3605 { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
3606 { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
3607 { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
3608 { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
3609 { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
3610 { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
3611 { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
3612 { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
3613 { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
3614 { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
3615 { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
3616 { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
3617 { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
3618 { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
3619 { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
3620};
3621
3622
3623#ifdef HDMI_RESET
3624static unsigned dtv_reset_gpio =
3625 GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3626#endif
3627
Justin Paupore3f40f342011-08-10 18:52:16 -07003628static struct regulator_bulk_data hdmi_core_regs[] = {
3629 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3630};
3631
3632static struct regulator_bulk_data hdmi_comm_regs[] = {
3633 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3634 { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 },
3635};
3636
3637static struct regulator_bulk_data hdmi_cec_regs[] = {
3638 { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 },
3639};
3640
3641static int __init hdmi_init_regs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003642{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003643 int rc;
3644
Justin Paupore3f40f342011-08-10 18:52:16 -07003645 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs),
3646 hdmi_core_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003647
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003648 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003649 pr_err("%s: could not get %s regulators: %d\n",
3650 __func__, "core", rc);
3651 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003652 }
3653
Justin Paupore3f40f342011-08-10 18:52:16 -07003654 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs),
3655 hdmi_core_regs);
3656
3657 if (rc) {
3658 pr_err("%s: could not set %s voltages: %d\n",
3659 __func__, "core", rc);
3660 goto free_core;
3661 }
3662
3663 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs),
3664 hdmi_comm_regs);
3665
3666 if (rc) {
3667 pr_err("%s: could not get %s regulators: %d\n",
3668 __func__, "comm", rc);
3669 goto free_core;
3670 }
3671
3672 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs),
3673 hdmi_comm_regs);
3674
3675 if (rc) {
3676 pr_err("%s: could not set %s voltages: %d\n",
3677 __func__, "comm", rc);
3678 goto free_comm;
3679 }
3680
3681 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs),
3682 hdmi_cec_regs);
3683
3684 if (rc) {
3685 pr_err("%s: could not get %s regulators: %d\n",
3686 __func__, "cec", rc);
3687 goto free_comm;
3688 }
3689
3690 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs),
3691 hdmi_cec_regs);
3692
3693 if (rc) {
3694 pr_err("%s: could not set %s voltages: %d\n",
3695 __func__, "cec", rc);
3696 goto free_cec;
3697 }
3698
3699 return 0;
3700
3701free_cec:
3702 regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs);
3703free_comm:
3704 regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs);
3705free_core:
3706 regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs);
3707out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003708 return rc;
3709}
3710
Justin Paupore3f40f342011-08-10 18:52:16 -07003711static int hdmi_init_irq(void)
3712{
3713 int rc = msm_gpios_enable(dtv_panel_irq_gpios,
3714 ARRAY_SIZE(dtv_panel_irq_gpios));
3715 if (rc < 0) {
3716 pr_err("%s: gpio enable failed: %d\n", __func__, rc);
3717 return rc;
3718 }
3719 pr_info("%s\n", __func__);
3720
3721 return 0;
3722}
3723
3724static int hdmi_enable_5v(int on)
3725{
3726 int pmic_gpio_hdmi_5v_en ;
3727
3728 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
3729 machine_is_msm7x30_fluid())
3730 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
3731 else
3732 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
3733
3734 pr_info("%s: %d\n", __func__, on);
3735 if (on) {
3736 int rc;
3737 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
3738 "hdmi_5V_en");
3739 if (rc) {
3740 pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
3741 __func__);
3742 return rc;
3743 }
3744 gpio_set_value_cansleep(
3745 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
3746 } else {
3747 gpio_set_value_cansleep(
3748 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
3749 gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
3750 }
3751 return 0;
3752}
3753
3754static int hdmi_comm_power(int on, int show)
3755{
3756 if (show)
3757 pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
3758 return on ?
3759 regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs),
3760 hdmi_comm_regs) :
3761 regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs),
3762 hdmi_comm_regs);
3763}
3764
3765static int hdmi_core_power(int on, int show)
3766{
3767 if (show)
3768 pr_info("%s: %d <LDO8>\n", __func__, on);
3769 return on ?
3770 regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs),
3771 hdmi_core_regs) :
3772 regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs),
3773 hdmi_core_regs);
3774}
3775
3776static int hdmi_cec_power(int on)
3777{
3778 pr_info("%s: %d <LDO17>\n", __func__, on);
3779 return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs),
3780 hdmi_cec_regs) :
3781 regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs),
3782 hdmi_cec_regs);
3783}
3784
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003785#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
3786/* there is an i2c address conflict between adv7520 and bma150 sensor after
3787 * power up on fluid. As a solution, the default address of adv7520's packet
3788 * memory is changed as soon as possible
3789 */
3790static int __init fluid_i2c_address_fixup(void)
3791{
3792 unsigned char wBuff[16];
3793 unsigned char rBuff[16];
3794 struct i2c_msg msgs[3];
3795 int res;
3796 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003797 struct i2c_adapter *adapter;
3798
3799 if (machine_is_msm7x30_fluid()) {
3800 adapter = i2c_get_adapter(0);
3801 if (!adapter) {
3802 pr_err("%s: invalid i2c adapter\n", __func__);
3803 return PTR_ERR(adapter);
3804 }
3805
3806 /* turn on LDO8 */
Justin Paupore3f40f342011-08-10 18:52:16 -07003807 rc = hdmi_core_power(1, 0);
3808 if (rc) {
3809 pr_err("%s: could not enable hdmi core regs: %d",
3810 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003811 goto adapter_put;
3812 }
3813
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003814 /* change packet memory address to 0x74 */
3815 wBuff[0] = 0x45;
3816 wBuff[1] = 0x74;
3817
3818 msgs[0].addr = ADV7520_I2C_ADDR;
3819 msgs[0].flags = 0;
3820 msgs[0].buf = (unsigned char *) wBuff;
3821 msgs[0].len = 2;
3822
3823 res = i2c_transfer(adapter, msgs, 1);
3824 if (res != 1) {
3825 pr_err("%s: error writing adv7520\n", __func__);
3826 goto ldo8_disable;
3827 }
3828
3829 /* powerdown adv7520 using bit 6 */
3830 /* i2c read first */
3831 wBuff[0] = 0x41;
3832
3833 msgs[0].addr = ADV7520_I2C_ADDR;
3834 msgs[0].flags = 0;
3835 msgs[0].buf = (unsigned char *) wBuff;
3836 msgs[0].len = 1;
3837
3838 msgs[1].addr = ADV7520_I2C_ADDR;
3839 msgs[1].flags = I2C_M_RD;
3840 msgs[1].buf = rBuff;
3841 msgs[1].len = 1;
3842 res = i2c_transfer(adapter, msgs, 2);
3843 if (res != 2) {
3844 pr_err("%s: error reading adv7520\n", __func__);
3845 goto ldo8_disable;
3846 }
3847
3848 /* i2c write back */
3849 wBuff[0] = 0x41;
3850 wBuff[1] = rBuff[0] | 0x40;
3851
3852 msgs[0].addr = ADV7520_I2C_ADDR;
3853 msgs[0].flags = 0;
3854 msgs[0].buf = (unsigned char *) wBuff;
3855 msgs[0].len = 2;
3856
3857 res = i2c_transfer(adapter, msgs, 1);
3858 if (res != 1) {
3859 pr_err("%s: error writing adv7520\n", __func__);
3860 goto ldo8_disable;
3861 }
3862
3863 /* for successful fixup, we release the i2c adapter */
3864 /* but leave ldo8 on so that the adv7520 is not repowered */
3865 i2c_put_adapter(adapter);
3866 pr_info("%s: fluid i2c address conflict resolved\n", __func__);
3867 }
3868 return 0;
3869
3870ldo8_disable:
Justin Paupore3f40f342011-08-10 18:52:16 -07003871 hdmi_core_power(0, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003872adapter_put:
3873 i2c_put_adapter(adapter);
3874 return rc;
3875}
3876fs_initcall_sync(fluid_i2c_address_fixup);
3877#endif
3878
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003879static bool hdmi_check_hdcp_hw_support(void)
3880{
3881 if (machine_is_msm7x30_fluid())
3882 return false;
3883 else
3884 return true;
3885}
3886
3887static int dtv_panel_power(int on)
3888{
3889 int flag_on = !!on;
3890 static int dtv_power_save_on;
3891 int rc;
3892
3893 if (dtv_power_save_on == flag_on)
3894 return 0;
3895
3896 dtv_power_save_on = flag_on;
3897 pr_info("%s: %d\n", __func__, on);
3898
3899#ifdef HDMI_RESET
3900 if (on) {
3901 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
3902 rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
3903 if (rc) {
3904 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
3905 __func__, dtv_reset_gpio, rc);
3906 return rc;
3907 }
3908
3909 /* bring reset line low to hold reset*/
3910 gpio_set_value(37, 0);
3911 }
3912#endif
3913
3914 if (on) {
3915 rc = msm_gpios_enable(dtv_panel_gpios,
3916 ARRAY_SIZE(dtv_panel_gpios));
3917 if (rc < 0) {
3918 printk(KERN_ERR "%s: gpio enable failed: %d\n",
3919 __func__, rc);
3920 return rc;
3921 }
3922 } else {
3923 rc = msm_gpios_disable(dtv_panel_gpios,
3924 ARRAY_SIZE(dtv_panel_gpios));
3925 if (rc < 0) {
3926 printk(KERN_ERR "%s: gpio disable failed: %d\n",
3927 __func__, rc);
3928 return rc;
3929 }
3930 }
3931
3932 mdelay(5); /* ensure power is stable */
3933
3934#ifdef HDMI_RESET
3935 if (on) {
3936 gpio_set_value(37, 1); /* bring reset line high */
3937 mdelay(10); /* 10 msec before IO can be accessed */
3938 }
3939#endif
3940
3941 return rc;
3942}
3943
3944static struct lcdc_platform_data dtv_pdata = {
3945 .lcdc_power_save = dtv_panel_power,
3946};
3947
3948static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3949 .inject_rx_on_wakeup = 1,
3950 .rx_to_inject = 0xFD,
3951};
3952
3953static struct resource msm_fb_resources[] = {
3954 {
3955 .flags = IORESOURCE_DMA,
3956 }
3957};
3958
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08003959#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
3960static struct resource msm_v4l2_video_overlay_resources[] = {
3961 {
3962 .flags = IORESOURCE_DMA,
3963 }
3964};
3965#endif
3966
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003967static int msm_fb_detect_panel(const char *name)
3968{
3969 if (machine_is_msm7x30_fluid()) {
3970 if (!strcmp(name, "lcdc_sharp_wvga_pt"))
3971 return 0;
3972 } else {
3973 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
3974 return -EPERM;
3975 else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20))
3976 return 0;
3977 else if (!strcmp(name, "mddi_orise"))
3978 return -EPERM;
3979 else if (!strcmp(name, "mddi_quickvx"))
3980 return -EPERM;
3981 }
3982 return -ENODEV;
3983}
3984
3985static struct msm_fb_platform_data msm_fb_pdata = {
3986 .detect_client = msm_fb_detect_panel,
3987 .mddi_prescan = 1,
3988};
3989
3990static struct platform_device msm_fb_device = {
3991 .name = "msm_fb",
3992 .id = 0,
3993 .num_resources = ARRAY_SIZE(msm_fb_resources),
3994 .resource = msm_fb_resources,
3995 .dev = {
3996 .platform_data = &msm_fb_pdata,
3997 }
3998};
3999
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08004000#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
4001
4002static struct platform_device msm_v4l2_video_overlay_device = {
4003 .name = "msm_v4l2_overlay_pd",
4004 .id = 0,
4005 .num_resources = ARRAY_SIZE(msm_v4l2_video_overlay_resources),
4006 .resource = msm_v4l2_video_overlay_resources,
4007};
4008#endif
4009
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004010static struct platform_device msm_migrate_pages_device = {
4011 .name = "msm_migrate_pages",
4012 .id = -1,
4013};
4014
4015static struct android_pmem_platform_data android_pmem_adsp_pdata = {
4016 .name = "pmem_adsp",
4017 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4018 .cached = 0,
4019 .memory_type = MEMTYPE_EBI0,
4020};
4021
4022static struct android_pmem_platform_data android_pmem_audio_pdata = {
4023 .name = "pmem_audio",
4024 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4025 .cached = 0,
4026 .memory_type = MEMTYPE_EBI0,
4027};
4028
4029static struct platform_device android_pmem_adsp_device = {
4030 .name = "android_pmem",
4031 .id = 2,
4032 .dev = { .platform_data = &android_pmem_adsp_pdata },
4033};
4034
4035static struct platform_device android_pmem_audio_device = {
4036 .name = "android_pmem",
4037 .id = 4,
4038 .dev = { .platform_data = &android_pmem_audio_pdata },
4039};
4040
4041#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4042 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
4043 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4044 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4045
4046#define QCE_SIZE 0x10000
4047#define QCE_0_BASE 0xA8400000
4048
4049#define QCE_HW_KEY_SUPPORT 1
4050#define QCE_SHA_HMAC_SUPPORT 0
4051#define QCE_SHARE_CE_RESOURCE 0
4052#define QCE_CE_SHARED 0
4053
4054static struct resource qcrypto_resources[] = {
4055 [0] = {
4056 .start = QCE_0_BASE,
4057 .end = QCE_0_BASE + QCE_SIZE - 1,
4058 .flags = IORESOURCE_MEM,
4059 },
4060 [1] = {
4061 .name = "crypto_channels",
4062 .start = DMOV_CE_IN_CHAN,
4063 .end = DMOV_CE_OUT_CHAN,
4064 .flags = IORESOURCE_DMA,
4065 },
4066 [2] = {
4067 .name = "crypto_crci_in",
4068 .start = DMOV_CE_IN_CRCI,
4069 .end = DMOV_CE_IN_CRCI,
4070 .flags = IORESOURCE_DMA,
4071 },
4072 [3] = {
4073 .name = "crypto_crci_out",
4074 .start = DMOV_CE_OUT_CRCI,
4075 .end = DMOV_CE_OUT_CRCI,
4076 .flags = IORESOURCE_DMA,
4077 },
4078 [4] = {
4079 .name = "crypto_crci_hash",
4080 .start = DMOV_CE_HASH_CRCI,
4081 .end = DMOV_CE_HASH_CRCI,
4082 .flags = IORESOURCE_DMA,
4083 },
4084};
4085
4086static struct resource qcedev_resources[] = {
4087 [0] = {
4088 .start = QCE_0_BASE,
4089 .end = QCE_0_BASE + QCE_SIZE - 1,
4090 .flags = IORESOURCE_MEM,
4091 },
4092 [1] = {
4093 .name = "crypto_channels",
4094 .start = DMOV_CE_IN_CHAN,
4095 .end = DMOV_CE_OUT_CHAN,
4096 .flags = IORESOURCE_DMA,
4097 },
4098 [2] = {
4099 .name = "crypto_crci_in",
4100 .start = DMOV_CE_IN_CRCI,
4101 .end = DMOV_CE_IN_CRCI,
4102 .flags = IORESOURCE_DMA,
4103 },
4104 [3] = {
4105 .name = "crypto_crci_out",
4106 .start = DMOV_CE_OUT_CRCI,
4107 .end = DMOV_CE_OUT_CRCI,
4108 .flags = IORESOURCE_DMA,
4109 },
4110 [4] = {
4111 .name = "crypto_crci_hash",
4112 .start = DMOV_CE_HASH_CRCI,
4113 .end = DMOV_CE_HASH_CRCI,
4114 .flags = IORESOURCE_DMA,
4115 },
4116};
4117
4118#endif
4119
4120#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4121 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
4122
4123static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
4124 .ce_shared = QCE_CE_SHARED,
4125 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4126 .hw_key_support = QCE_HW_KEY_SUPPORT,
4127 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004128 /* Bus Scaling declaration*/
4129 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004130};
4131
4132static struct platform_device qcrypto_device = {
4133 .name = "qcrypto",
4134 .id = 0,
4135 .num_resources = ARRAY_SIZE(qcrypto_resources),
4136 .resource = qcrypto_resources,
4137 .dev = {
4138 .coherent_dma_mask = DMA_BIT_MASK(32),
4139 .platform_data = &qcrypto_ce_hw_suppport,
4140 },
4141};
4142#endif
4143
4144#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4145 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4146
4147static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
4148 .ce_shared = QCE_CE_SHARED,
4149 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4150 .hw_key_support = QCE_HW_KEY_SUPPORT,
4151 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004152 /* Bus Scaling declaration*/
4153 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004154};
4155static struct platform_device qcedev_device = {
4156 .name = "qce",
4157 .id = 0,
4158 .num_resources = ARRAY_SIZE(qcedev_resources),
4159 .resource = qcedev_resources,
4160 .dev = {
4161 .coherent_dma_mask = DMA_BIT_MASK(32),
4162 .platform_data = &qcedev_ce_hw_suppport,
4163 },
4164};
4165#endif
4166
4167static int mddi_toshiba_pmic_bl(int level)
4168{
4169 int ret = -EPERM;
4170
4171 ret = pmic_set_led_intensity(LED_LCD, level);
4172
4173 if (ret)
4174 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
4175 __func__);
4176 return ret;
4177}
4178
4179static struct msm_panel_common_pdata mddi_toshiba_pdata = {
4180 .pmic_backlight = mddi_toshiba_pmic_bl,
4181};
4182
4183static struct platform_device mddi_toshiba_device = {
4184 .name = "mddi_toshiba",
4185 .id = 0,
4186 .dev = {
4187 .platform_data = &mddi_toshiba_pdata,
4188 }
4189};
4190
4191static unsigned wega_reset_gpio =
4192 GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4193
4194static struct msm_gpio fluid_vee_reset_gpio[] = {
4195 { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
4196};
4197
4198static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1;
4199static unsigned char quickvx_ldo_enabled;
4200
4201static unsigned quickvx_vlp_gpio =
4202 GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4203
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304204static struct pm8xxx_gpio_init_info pmic_quickvx_clk_gpio = {
4205 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_QUICKVX_CLK),
4206 {
4207 .direction = PM_GPIO_DIR_OUT,
4208 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
4209 .output_value = 1,
4210 .pull = PM_GPIO_PULL_NO,
4211 .vin_sel = PM8058_GPIO_VIN_S3,
4212 .out_strength = PM_GPIO_STRENGTH_HIGH,
4213 .function = PM_GPIO_FUNC_2,
4214 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004215};
4216
Justin Paupore3f40f342011-08-10 18:52:16 -07004217static struct regulator *mddi_ldo20;
4218static struct regulator *mddi_ldo12;
4219static struct regulator *mddi_ldo16;
4220static struct regulator *mddi_ldo6;
4221static struct regulator *mddi_lcd;
4222
4223static int display_common_init(void)
4224{
4225 struct regulator_bulk_data regs[5] = {
4226 { .supply = "ldo20", /* voltage set in display_common_power */},
4227 { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 },
4228 { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 },
4229 { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 },
4230 { .supply = NULL, /* mddi_lcd, initialized below */ },
4231 };
4232
4233 int rc = 0;
4234
4235 if (machine_is_msm7x30_fluid()) {
4236 /* lcd: LDO8 @1.8V */
4237 regs[4].supply = "ldo8";
4238 regs[4].min_uV = 1800000;
4239 regs[4].max_uV = 1800000;
4240 } else {
4241 /* lcd: LDO15 @3.1V */
4242 regs[4].supply = "ldo15";
4243 regs[4].min_uV = 3100000;
4244 regs[4].max_uV = 3100000;
4245 }
4246
4247 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4248 if (rc) {
4249 pr_err("%s: regulator_bulk_get failed: %d\n",
4250 __func__, rc);
4251 goto bail;
4252 }
4253
4254 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4255 if (rc) {
4256 pr_err("%s: regulator_bulk_set_voltage failed: %d\n",
4257 __func__, rc);
4258 goto put_regs;
4259 }
4260
4261 mddi_ldo20 = regs[0].consumer;
4262 mddi_ldo12 = regs[1].consumer;
4263 mddi_ldo6 = regs[2].consumer;
4264 mddi_ldo16 = regs[3].consumer;
4265 mddi_lcd = regs[4].consumer;
4266
4267 return rc;
4268
4269put_regs:
4270 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4271bail:
4272 return rc;
4273}
4274
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004275static int display_common_power(int on)
4276{
4277 int rc = 0, flag_on = !!on;
4278 static int display_common_power_save_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004279 static bool display_regs_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004280
4281 if (display_common_power_save_on == flag_on)
4282 return 0;
4283
4284 display_common_power_save_on = flag_on;
4285
Justin Paupore3f40f342011-08-10 18:52:16 -07004286 if (unlikely(!display_regs_initialized)) {
4287 rc = display_common_init();
4288 if (rc) {
4289 pr_err("%s: regulator init failed: %d\n",
4290 __func__, rc);
4291 return rc;
4292 }
4293 display_regs_initialized = true;
4294 }
4295
4296
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004297 if (on) {
4298 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
4299 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
4300 if (rc) {
4301 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4302 __func__, wega_reset_gpio, rc);
4303 return rc;
4304 }
4305
4306 /* bring reset line low to hold reset*/
4307 gpio_set_value(180, 0);
4308
4309 if (quickvx_mddi_client) {
4310 /* QuickVX chip -- VLP pin -- gpio 97 */
4311 rc = gpio_tlmm_config(quickvx_vlp_gpio,
4312 GPIO_CFG_ENABLE);
4313 if (rc) {
4314 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4315 __func__, quickvx_vlp_gpio, rc);
4316 return rc;
4317 }
4318
4319 /* bring QuickVX VLP line low */
4320 gpio_set_value(97, 0);
4321
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304322 rc = pm8xxx_gpio_config(pmic_quickvx_clk_gpio.gpio,
4323 &pmic_quickvx_clk_gpio.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004324 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304325 pr_err("%s: pm8xxx_gpio_config(%#x)=%d\n",
4326 __func__, pmic_quickvx_clk_gpio.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004327 rc);
4328 return rc;
4329 }
4330
4331 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4332 PMIC_GPIO_QUICKVX_CLK), 0);
4333 }
4334 }
4335
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004336 if (quickvx_mddi_client)
Justin Paupore3f40f342011-08-10 18:52:16 -07004337 rc = regulator_set_voltage(mddi_ldo20, 1800000, 1800000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004338 else
Justin Paupore3f40f342011-08-10 18:52:16 -07004339 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000);
4340
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004341 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004342 pr_err("%s: could not set voltage for ldo20: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004343 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07004344 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004345 }
4346
4347 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004348 rc = regulator_enable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004349 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004350 pr_err("%s: LDO20 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004351 __func__, rc);
4352 return rc;
4353 }
4354
Justin Paupore3f40f342011-08-10 18:52:16 -07004355 rc = regulator_enable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004356 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004357 pr_err("%s: LDO12 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004358 __func__, rc);
4359 return rc;
4360 }
4361
4362 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004363 rc = regulator_enable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004364 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004365 pr_err("%s: LDO16 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004366 __func__, rc);
4367 return rc;
4368 }
4369 }
4370
Justin Paupore3f40f342011-08-10 18:52:16 -07004371 if (quickvx_ldo_enabled) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004372 /* Disable LDO6 during display ON */
Justin Paupore3f40f342011-08-10 18:52:16 -07004373 rc = regulator_disable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004374 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004375 pr_err("%s: LDO6 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004376 __func__, rc);
4377 return rc;
4378 }
4379 quickvx_ldo_enabled = 0;
4380 }
4381
Justin Paupore3f40f342011-08-10 18:52:16 -07004382 rc = regulator_enable(mddi_lcd);
4383 if (rc) {
4384 pr_err("%s: LCD regulator enable failed (%d)\n",
4385 __func__, rc);
4386 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004387 }
4388
4389 mdelay(5); /* ensure power is stable */
4390
4391 if (machine_is_msm7x30_fluid()) {
4392 rc = msm_gpios_request_enable(fluid_vee_reset_gpio,
4393 ARRAY_SIZE(fluid_vee_reset_gpio));
4394 if (rc)
4395 pr_err("%s gpio_request_enable failed rc=%d\n",
4396 __func__, rc);
4397 else {
4398 /* assert vee reset_n */
4399 gpio_set_value(20, 1);
4400 gpio_set_value(20, 0);
4401 mdelay(1);
4402 gpio_set_value(20, 1);
4403 }
4404 }
4405
4406 gpio_set_value(180, 1); /* bring reset line high */
4407 mdelay(10); /* 10 msec before IO can be accessed */
4408
4409 if (quickvx_mddi_client) {
4410 gpio_set_value(97, 1);
4411 msleep(2);
4412 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4413 PMIC_GPIO_QUICKVX_CLK), 1);
4414 msleep(2);
4415 }
4416
4417 rc = pmapp_display_clock_config(1);
4418 if (rc) {
4419 pr_err("%s pmapp_display_clock_config rc=%d\n",
4420 __func__, rc);
4421 return rc;
4422 }
4423
4424 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004425 rc = regulator_disable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004426 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004427 pr_err("%s: LDO20 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004428 __func__, rc);
4429 return rc;
4430 }
4431
4432
4433 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004434 rc = regulator_disable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004435 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004436 pr_err("%s: LDO16 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004437 __func__, rc);
4438 return rc;
4439 }
4440 }
4441
4442 if (quickvx_mddi_client && !quickvx_ldo_enabled) {
4443 /* Enable LDO6 during display OFF for
4444 Quicklogic chip to sleep with data retention */
Justin Paupore3f40f342011-08-10 18:52:16 -07004445 rc = regulator_enable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004446 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004447 pr_err("%s: LDO6 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004448 __func__, rc);
4449 return rc;
4450 }
4451 quickvx_ldo_enabled = 1;
4452 }
4453
4454 gpio_set_value(180, 0); /* bring reset line low */
4455
4456 if (quickvx_mddi_client) {
4457 gpio_set_value(97, 0);
4458 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4459 PMIC_GPIO_QUICKVX_CLK), 0);
4460 }
4461
Justin Paupore3f40f342011-08-10 18:52:16 -07004462 rc = regulator_disable(mddi_lcd);
4463 if (rc) {
4464 pr_err("%s: LCD regulator disable failed (%d)\n",
4465 __func__, rc);
4466 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004467 }
4468
4469 mdelay(5); /* ensure power is stable */
4470
Justin Paupore3f40f342011-08-10 18:52:16 -07004471 rc = regulator_disable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004472 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004473 pr_err("%s: LDO12 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004474 __func__, rc);
4475 return rc;
4476 }
4477
4478 if (machine_is_msm7x30_fluid()) {
4479 msm_gpios_disable_free(fluid_vee_reset_gpio,
4480 ARRAY_SIZE(fluid_vee_reset_gpio));
4481 }
4482
4483 rc = pmapp_display_clock_config(0);
4484 if (rc) {
4485 pr_err("%s pmapp_display_clock_config rc=%d\n",
4486 __func__, rc);
4487 return rc;
4488 }
4489 }
4490
4491 return rc;
4492}
4493
4494static int msm_fb_mddi_sel_clk(u32 *clk_rate)
4495{
4496 *clk_rate *= 2;
4497 return 0;
4498}
4499
4500static int msm_fb_mddi_client_power(u32 client_id)
4501{
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304502 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004503 printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
4504 /* Check if it is Quicklogic client */
4505 if (client_id == 0xc5835800) {
4506 printk(KERN_NOTICE "\n Quicklogic MDDI client");
4507 other_mddi_client = 0;
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304508 if (IS_ERR(mddi_ldo16)) {
4509 rc = PTR_ERR(mddi_ldo16);
4510 pr_err("%s: gp10 vreg get failed (%d)\n", __func__, rc);
4511 return rc;
4512 }
4513 rc = regulator_disable(mddi_ldo16);
4514 if (rc) {
4515 pr_err("%s: LDO16 vreg enable failed (%d)\n",
4516 __func__, rc);
4517 return rc;
4518 }
4519
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004520 } else {
4521 printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
4522 quickvx_mddi_client = 0;
4523 gpio_set_value(97, 0);
4524 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4525 PMIC_GPIO_QUICKVX_CLK), 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004526 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004527
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004528 return 0;
4529}
4530
4531static struct mddi_platform_data mddi_pdata = {
4532 .mddi_power_save = display_common_power,
4533 .mddi_sel_clk = msm_fb_mddi_sel_clk,
4534 .mddi_client_power = msm_fb_mddi_client_power,
4535};
4536
4537int mdp_core_clk_rate_table[] = {
4538 122880000,
4539 122880000,
Pradeep Jilagam3cc12f92011-07-26 22:25:18 +05304540 192000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004541 192000000,
4542};
4543
4544static struct msm_panel_common_pdata mdp_pdata = {
4545 .hw_revision_addr = 0xac001270,
4546 .gpio = 30,
4547 .mdp_core_clk_rate = 122880000,
4548 .mdp_core_clk_table = mdp_core_clk_rate_table,
4549 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07004550 .mdp_rev = MDP_REV_40,
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05304551 .mem_hid = MEMTYPE_EBI0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004552};
4553
4554static int lcd_panel_spi_gpio_num[] = {
4555 45, /* spi_clk */
4556 46, /* spi_cs */
4557 47, /* spi_mosi */
4558 48, /* spi_miso */
4559 };
4560
4561static struct msm_gpio lcd_panel_gpios[] = {
4562/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
4563 * input. if there is a hardware revision; we should reassign this GPIO to a
4564 * new open line; and removing it will just ensure that this will be missed in
4565 * the future.
4566 { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
4567 */
4568 { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
4569 { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
4570 { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
4571 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4572 { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
4573 { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
4574 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4575#ifndef CONFIG_SPI_QSD
4576 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
4577 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
4578 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
4579 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
4580#endif
4581 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4582 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4583 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4584 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4585 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4586 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4587 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4588 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4589 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4590 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4591 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4592 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4593 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4594 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4595 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4596 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4597 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4598 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4599 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4600 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4601};
4602
4603static struct msm_gpio lcd_sharp_panel_gpios[] = {
4604 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4605 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4606 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4607 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4608 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4609 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4610 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4611 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4612 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4613 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4614 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4615 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4616 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4617 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4618 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4619 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4620 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4621 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4622 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4623 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4624 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4625 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4626};
4627
4628static int lcdc_toshiba_panel_power(int on)
4629{
4630 int rc, i;
4631 struct msm_gpio *gp;
4632
4633 rc = display_common_power(on);
4634 if (rc < 0) {
4635 printk(KERN_ERR "%s display_common_power failed: %d\n",
4636 __func__, rc);
4637 return rc;
4638 }
4639
4640 if (on) {
4641 rc = msm_gpios_enable(lcd_panel_gpios,
4642 ARRAY_SIZE(lcd_panel_gpios));
4643 if (rc < 0) {
4644 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4645 __func__, rc);
4646 }
4647 } else { /* off */
4648 gp = lcd_panel_gpios;
4649 for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
4650 /* ouput low */
4651 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4652 gp++;
4653 }
4654 }
4655
4656 return rc;
4657}
4658
4659static int lcdc_sharp_panel_power(int on)
4660{
4661 int rc, i;
4662 struct msm_gpio *gp;
4663
4664 rc = display_common_power(on);
4665 if (rc < 0) {
4666 printk(KERN_ERR "%s display_common_power failed: %d\n",
4667 __func__, rc);
4668 return rc;
4669 }
4670
4671 if (on) {
4672 rc = msm_gpios_enable(lcd_sharp_panel_gpios,
4673 ARRAY_SIZE(lcd_sharp_panel_gpios));
4674 if (rc < 0) {
4675 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4676 __func__, rc);
4677 }
4678 } else { /* off */
4679 gp = lcd_sharp_panel_gpios;
4680 for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) {
4681 /* ouput low */
4682 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4683 gp++;
4684 }
4685 }
4686
4687 return rc;
4688}
4689
4690static int lcdc_panel_power(int on)
4691{
4692 int flag_on = !!on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004693 static int lcdc_power_save_on, lcdc_power_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004694
4695 if (lcdc_power_save_on == flag_on)
4696 return 0;
4697
4698 lcdc_power_save_on = flag_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004699
4700 if (unlikely(!lcdc_power_initialized)) {
4701 quickvx_mddi_client = 0;
4702 display_common_init();
4703 lcdc_power_initialized = 1;
4704 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004705
4706 if (machine_is_msm7x30_fluid())
4707 return lcdc_sharp_panel_power(on);
4708 else
4709 return lcdc_toshiba_panel_power(on);
4710}
4711
4712static struct lcdc_platform_data lcdc_pdata = {
4713 .lcdc_power_save = lcdc_panel_power,
4714};
4715
Justin Paupore3f40f342011-08-10 18:52:16 -07004716static struct regulator *atv_s4, *atv_ldo9;
4717
4718static int __init atv_dac_power_init(void)
4719{
4720 int rc;
4721 struct regulator_bulk_data regs[] = {
4722 { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 },
4723 { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 },
4724 };
4725
4726 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4727
4728 if (rc) {
4729 pr_err("%s: could not get regulators: %d\n", __func__, rc);
4730 goto bail;
4731 }
4732
4733 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4734
4735 if (rc) {
4736 pr_err("%s: could not set voltages: %d\n", __func__, rc);
4737 goto reg_free;
4738 }
4739
4740 atv_s4 = regs[0].consumer;
4741 atv_ldo9 = regs[1].consumer;
4742
4743reg_free:
4744 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4745bail:
4746 return rc;
4747}
4748
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004749static int atv_dac_power(int on)
4750{
4751 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004752
4753 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004754 rc = regulator_enable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004755 if (rc) {
4756 pr_err("%s: s4 vreg enable failed (%d)\n",
4757 __func__, rc);
4758 return rc;
4759 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004760 rc = regulator_enable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004761 if (rc) {
4762 pr_err("%s: ldo9 vreg enable failed (%d)\n",
4763 __func__, rc);
4764 return rc;
4765 }
4766 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004767 rc = regulator_disable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004768 if (rc) {
4769 pr_err("%s: ldo9 vreg disable failed (%d)\n",
4770 __func__, rc);
4771 return rc;
4772 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004773 rc = regulator_disable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004774 if (rc) {
4775 pr_err("%s: s4 vreg disable failed (%d)\n",
4776 __func__, rc);
4777 return rc;
4778 }
4779 }
4780 return rc;
4781}
4782
4783static struct tvenc_platform_data atv_pdata = {
4784 .poll = 1,
4785 .pm_vid_en = atv_dac_power,
4786};
4787
4788static void __init msm_fb_add_devices(void)
4789{
4790 msm_fb_register_device("mdp", &mdp_pdata);
4791 msm_fb_register_device("pmdh", &mddi_pdata);
4792 msm_fb_register_device("lcdc", &lcdc_pdata);
4793 msm_fb_register_device("dtv", &dtv_pdata);
4794 msm_fb_register_device("tvenc", &atv_pdata);
4795#ifdef CONFIG_FB_MSM_TVOUT
4796 msm_fb_register_device("tvout_device", NULL);
4797#endif
4798}
4799
4800static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
4801 .gpio_num = lcd_panel_spi_gpio_num,
4802};
4803
4804static struct platform_device lcdc_toshiba_panel_device = {
4805 .name = "lcdc_toshiba_wvga",
4806 .id = 0,
4807 .dev = {
4808 .platform_data = &lcdc_toshiba_panel_data,
4809 }
4810};
4811
4812#if defined(CONFIG_MARIMBA_CORE) && \
4813 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4814static struct platform_device msm_bt_power_device = {
4815 .name = "bt_power",
4816 .id = -1
4817};
4818
4819enum {
4820 BT_RFR,
4821 BT_CTS,
4822 BT_RX,
4823 BT_TX,
4824};
4825
4826static struct msm_gpio bt_config_power_on[] = {
4827 { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4828 "UART1DM_RFR" },
4829 { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4830 "UART1DM_CTS" },
4831 { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4832 "UART1DM_Rx" },
4833 { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4834 "UART1DM_Tx" }
4835};
4836
4837static struct msm_gpio bt_config_power_off[] = {
4838 { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4839 "UART1DM_RFR" },
4840 { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4841 "UART1DM_CTS" },
4842 { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4843 "UART1DM_Rx" },
4844 { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4845 "UART1DM_Tx" }
4846};
4847
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004848static u8 bahama_version;
4849
Justin Paupore3f40f342011-08-10 18:52:16 -07004850static struct regulator_bulk_data regs_bt_marimba[] = {
4851 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4852 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
4853 { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304854 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004855};
4856
4857static struct regulator_bulk_data regs_bt_bahama_v1[] = {
4858 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4859 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
4860 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304861 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004862};
4863
4864static struct regulator_bulk_data regs_bt_bahama_v2[] = {
4865 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4866 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304867 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004868};
4869
4870static struct regulator_bulk_data *regs_bt;
4871static int regs_bt_count;
4872
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004873static int marimba_bt(int on)
4874{
4875 int rc;
4876 int i;
4877 struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
4878
4879 struct marimba_config_register {
4880 u8 reg;
4881 u8 value;
4882 u8 mask;
4883 };
4884
4885 struct marimba_variant_register {
4886 const size_t size;
4887 const struct marimba_config_register *set;
4888 };
4889
4890 const struct marimba_config_register *p;
4891
4892 u8 version;
4893
4894 const struct marimba_config_register v10_bt_on[] = {
4895 { 0xE5, 0x0B, 0x0F },
4896 { 0x05, 0x02, 0x07 },
4897 { 0x06, 0x88, 0xFF },
4898 { 0xE7, 0x21, 0x21 },
4899 { 0xE3, 0x38, 0xFF },
4900 { 0xE4, 0x06, 0xFF },
4901 };
4902
4903 const struct marimba_config_register v10_bt_off[] = {
4904 { 0xE5, 0x0B, 0x0F },
4905 { 0x05, 0x08, 0x0F },
4906 { 0x06, 0x88, 0xFF },
4907 { 0xE7, 0x00, 0x21 },
4908 { 0xE3, 0x00, 0xFF },
4909 { 0xE4, 0x00, 0xFF },
4910 };
4911
4912 const struct marimba_config_register v201_bt_on[] = {
4913 { 0x05, 0x08, 0x07 },
4914 { 0x06, 0x88, 0xFF },
4915 { 0xE7, 0x21, 0x21 },
4916 { 0xE3, 0x38, 0xFF },
4917 { 0xE4, 0x06, 0xFF },
4918 };
4919
4920 const struct marimba_config_register v201_bt_off[] = {
4921 { 0x05, 0x08, 0x07 },
4922 { 0x06, 0x88, 0xFF },
4923 { 0xE7, 0x00, 0x21 },
4924 { 0xE3, 0x00, 0xFF },
4925 { 0xE4, 0x00, 0xFF },
4926 };
4927
4928 const struct marimba_config_register v210_bt_on[] = {
4929 { 0xE9, 0x01, 0x01 },
4930 { 0x06, 0x88, 0xFF },
4931 { 0xE7, 0x21, 0x21 },
4932 { 0xE3, 0x38, 0xFF },
4933 { 0xE4, 0x06, 0xFF },
4934 };
4935
4936 const struct marimba_config_register v210_bt_off[] = {
4937 { 0x06, 0x88, 0xFF },
4938 { 0xE7, 0x00, 0x21 },
4939 { 0xE9, 0x00, 0x01 },
4940 { 0xE3, 0x00, 0xFF },
4941 { 0xE4, 0x00, 0xFF },
4942 };
4943
4944 const struct marimba_variant_register bt_marimba[2][4] = {
4945 {
4946 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4947 { 0, NULL },
4948 { ARRAY_SIZE(v201_bt_off), v201_bt_off },
4949 { ARRAY_SIZE(v210_bt_off), v210_bt_off }
4950 },
4951 {
4952 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4953 { 0, NULL },
4954 { ARRAY_SIZE(v201_bt_on), v201_bt_on },
4955 { ARRAY_SIZE(v210_bt_on), v210_bt_on }
4956 }
4957 };
4958
4959 on = on ? 1 : 0;
4960
4961 rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F);
4962 if (rc < 0) {
4963 printk(KERN_ERR
4964 "%s: version read failed: %d\n",
4965 __func__, rc);
4966 return rc;
4967 }
4968
4969 if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
4970 (bt_marimba[on][version].size == 0)) {
4971 printk(KERN_ERR
4972 "%s: unsupported version\n",
4973 __func__);
4974 return -EIO;
4975 }
4976
4977 p = bt_marimba[on][version].set;
4978
4979 printk(KERN_INFO "%s: found version %d\n", __func__, version);
4980
4981 for (i = 0; i < bt_marimba[on][version].size; i++) {
4982 u8 value = (p+i)->value;
4983 rc = marimba_write_bit_mask(&config,
4984 (p+i)->reg,
4985 &value,
4986 sizeof((p+i)->value),
4987 (p+i)->mask);
4988 if (rc < 0) {
4989 printk(KERN_ERR
4990 "%s: reg %d write failed: %d\n",
4991 __func__, (p+i)->reg, rc);
4992 return rc;
4993 }
4994 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
4995 __func__, (p+i)->reg,
4996 value, (p+i)->mask);
4997 }
4998 return 0;
4999}
5000
5001static int bahama_bt(int on)
5002{
5003 int rc;
5004 int i;
5005 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
5006
5007 struct bahama_variant_register {
5008 const size_t size;
5009 const struct bahama_config_register *set;
5010 };
5011
5012 const struct bahama_config_register *p;
5013
5014
5015 const struct bahama_config_register v10_bt_on[] = {
5016 { 0xE9, 0x00, 0xFF },
5017 { 0xF4, 0x80, 0xFF },
5018 { 0xF0, 0x06, 0xFF },
5019 { 0xE4, 0x00, 0xFF },
5020 { 0xE5, 0x00, 0x0F },
5021#ifdef CONFIG_WLAN
5022 { 0xE6, 0x38, 0x7F },
5023 { 0xE7, 0x06, 0xFF },
5024#endif
5025 { 0x11, 0x13, 0xFF },
5026 { 0xE9, 0x21, 0xFF },
5027 { 0x01, 0x0C, 0x1F },
5028 { 0x01, 0x08, 0x1F },
5029 };
5030
5031 const struct bahama_config_register v20_bt_on_fm_off[] = {
5032 { 0x11, 0x0C, 0xFF },
5033 { 0x13, 0x01, 0xFF },
5034 { 0xF4, 0x80, 0xFF },
5035 { 0xF0, 0x00, 0xFF },
5036 { 0xE9, 0x00, 0xFF },
5037#ifdef CONFIG_WLAN
5038 { 0x81, 0x00, 0xFF },
5039 { 0x82, 0x00, 0xFF },
5040 { 0xE6, 0x38, 0x7F },
5041 { 0xE7, 0x06, 0xFF },
5042#endif
5043 { 0xE9, 0x21, 0xFF }
5044 };
5045
5046 const struct bahama_config_register v20_bt_on_fm_on[] = {
5047 { 0x11, 0x0C, 0xFF },
5048 { 0x13, 0x01, 0xFF },
5049 { 0xF4, 0x86, 0xFF },
5050 { 0xF0, 0x06, 0xFF },
5051 { 0xE9, 0x00, 0xFF },
5052#ifdef CONFIG_WLAN
5053 { 0x81, 0x00, 0xFF },
5054 { 0x82, 0x00, 0xFF },
5055 { 0xE6, 0x38, 0x7F },
5056 { 0xE7, 0x06, 0xFF },
5057#endif
5058 { 0xE9, 0x21, 0xFF }
5059 };
5060
5061 const struct bahama_config_register v10_bt_off[] = {
5062 { 0xE9, 0x00, 0xFF },
5063 };
5064
5065 const struct bahama_config_register v20_bt_off_fm_off[] = {
5066 { 0xF4, 0x84, 0xFF },
5067 { 0xF0, 0x04, 0xFF },
5068 { 0xE9, 0x00, 0xFF }
5069 };
5070
5071 const struct bahama_config_register v20_bt_off_fm_on[] = {
5072 { 0xF4, 0x86, 0xFF },
5073 { 0xF0, 0x06, 0xFF },
5074 { 0xE9, 0x00, 0xFF }
5075 };
5076
5077 const struct bahama_variant_register bt_bahama[2][3] = {
5078 {
5079 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
5080 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
5081 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
5082 },
5083 {
5084 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
5085 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
5086 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
5087 }
5088 };
5089
5090 u8 offset = 0; /* index into bahama configs */
5091
5092 on = on ? 1 : 0;
5093
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005094
5095 if (bahama_version == VER_2_0) {
5096 if (marimba_get_fm_status(&config))
5097 offset = 0x01;
5098 }
5099
5100 p = bt_bahama[on][bahama_version + offset].set;
5101
5102 dev_info(&msm_bt_power_device.dev,
5103 "%s: found version %d\n", __func__, bahama_version);
5104
5105 for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
5106 u8 value = (p+i)->value;
5107 rc = marimba_write_bit_mask(&config,
5108 (p+i)->reg,
5109 &value,
5110 sizeof((p+i)->value),
5111 (p+i)->mask);
5112 if (rc < 0) {
5113 dev_err(&msm_bt_power_device.dev,
5114 "%s: reg %d write failed: %d\n",
5115 __func__, (p+i)->reg, rc);
5116 return rc;
5117 }
5118 dev_info(&msm_bt_power_device.dev,
5119 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
5120 __func__, (p+i)->reg,
5121 value, (p+i)->mask);
5122 }
5123 /* Update BT status */
5124 if (on)
5125 marimba_set_bt_status(&config, true);
5126 else
5127 marimba_set_bt_status(&config, false);
5128
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005129 return 0;
5130}
5131
Justin Paupore3f40f342011-08-10 18:52:16 -07005132static int bluetooth_regs_init(int bahama_not_marimba)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005133{
Justin Paupore3f40f342011-08-10 18:52:16 -07005134 int rc = 0;
5135 struct device *const dev = &msm_bt_power_device.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005136
5137 if (bahama_not_marimba) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005138 bahama_version = read_bahama_ver();
5139
5140 switch (bahama_version) {
5141 case VER_1_0:
5142 regs_bt = regs_bt_bahama_v1;
5143 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1);
5144 break;
5145 case VER_2_0:
5146 regs_bt = regs_bt_bahama_v2;
5147 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2);
5148 break;
5149 case VER_UNSUPPORTED:
5150 default:
5151 dev_err(dev,
5152 "%s: i2c failure or unsupported version: %d\n",
5153 __func__, bahama_version);
5154 rc = -EIO;
5155 goto out;
5156 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005157 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07005158 regs_bt = regs_bt_marimba;
5159 regs_bt_count = ARRAY_SIZE(regs_bt_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005160 }
5161
Justin Paupore3f40f342011-08-10 18:52:16 -07005162 rc = regulator_bulk_get(&msm_bt_power_device.dev,
5163 regs_bt_count, regs_bt);
5164 if (rc) {
5165 dev_err(dev, "%s: could not get regulators: %d\n",
5166 __func__, rc);
5167 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005168 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005169
5170 rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt);
5171 if (rc) {
5172 dev_err(dev, "%s: could not set voltages: %d\n",
5173 __func__, rc);
5174 goto reg_free;
5175 }
5176
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005177 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005178
5179reg_free:
5180 regulator_bulk_free(regs_bt_count, regs_bt);
5181out:
5182 regs_bt_count = 0;
5183 regs_bt = NULL;
5184 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005185}
5186
5187static int bluetooth_power(int on)
5188{
5189 int rc;
5190 const char *id = "BTPW";
5191
5192 int bahama_not_marimba = bahama_present();
5193
5194 if (bahama_not_marimba == -1) {
5195 printk(KERN_WARNING "%s: bahama_present: %d\n",
5196 __func__, bahama_not_marimba);
5197 return -ENODEV;
5198 }
5199
Justin Paupore3f40f342011-08-10 18:52:16 -07005200 if (unlikely(regs_bt_count == 0)) {
5201 rc = bluetooth_regs_init(bahama_not_marimba);
5202 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005203 return rc;
Justin Paupore3f40f342011-08-10 18:52:16 -07005204 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005205
Justin Paupore3f40f342011-08-10 18:52:16 -07005206 if (on) {
5207 rc = regulator_bulk_enable(regs_bt_count, regs_bt);
5208 if (rc)
5209 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005210
5211 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5212 PMAPP_CLOCK_VOTE_ON);
5213 if (rc < 0)
5214 return -EIO;
5215
5216 if (machine_is_msm8x55_svlte_surf() ||
5217 machine_is_msm8x55_svlte_ffa()) {
5218 rc = marimba_gpio_config(1);
5219 if (rc < 0)
5220 return -EIO;
5221 }
5222
5223 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5224 if (rc < 0)
5225 return -EIO;
5226
5227 msleep(10);
5228
5229 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5230 PMAPP_CLOCK_VOTE_PIN_CTRL);
5231 if (rc < 0)
5232 return -EIO;
5233
5234 if (machine_is_msm8x55_svlte_surf() ||
5235 machine_is_msm8x55_svlte_ffa()) {
5236 rc = marimba_gpio_config(0);
5237 if (rc < 0)
5238 return -EIO;
5239 }
5240
5241 rc = msm_gpios_enable(bt_config_power_on,
5242 ARRAY_SIZE(bt_config_power_on));
5243
5244 if (rc < 0)
5245 return rc;
5246
5247 } else {
5248 rc = msm_gpios_enable(bt_config_power_off,
5249 ARRAY_SIZE(bt_config_power_off));
5250 if (rc < 0)
5251 return rc;
5252
5253 /* check for initial RFKILL block (power off) */
5254 if (platform_get_drvdata(&msm_bt_power_device) == NULL)
5255 goto out;
5256
5257 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5258 if (rc < 0)
5259 return -EIO;
5260
5261 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5262 PMAPP_CLOCK_VOTE_OFF);
5263 if (rc < 0)
5264 return -EIO;
5265
Justin Paupore3f40f342011-08-10 18:52:16 -07005266 rc = regulator_bulk_disable(regs_bt_count, regs_bt);
5267 if (rc)
5268 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005269
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005270 }
5271
5272out:
5273 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
5274
5275 return 0;
5276}
5277
5278static void __init bt_power_init(void)
5279{
Justin Paupore3f40f342011-08-10 18:52:16 -07005280 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005281}
5282#else
5283#define bt_power_init(x) do {} while (0)
5284#endif
5285
5286static struct msm_psy_batt_pdata msm_psy_batt_data = {
5287 .voltage_min_design = 2800,
5288 .voltage_max_design = 4300,
5289 .avail_chg_sources = AC_CHG | USB_CHG ,
5290 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
5291};
5292
5293static struct platform_device msm_batt_device = {
5294 .name = "msm-battery",
5295 .id = -1,
5296 .dev.platform_data = &msm_psy_batt_data,
5297};
5298
5299static char *msm_adc_fluid_device_names[] = {
5300 "LTC_ADC1",
5301 "LTC_ADC2",
5302 "LTC_ADC3",
5303};
5304
5305static char *msm_adc_surf_device_names[] = {
5306 "XO_ADC",
5307};
5308
5309static struct msm_adc_platform_data msm_adc_pdata;
5310
5311static struct platform_device msm_adc_device = {
5312 .name = "msm_adc",
5313 .id = -1,
5314 .dev = {
5315 .platform_data = &msm_adc_pdata,
5316 },
5317};
5318
5319#ifdef CONFIG_MSM_SDIO_AL
5320static struct msm_gpio mdm2ap_status = {
5321 GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5322 "mdm2ap_status"
5323};
5324
5325
5326static int configure_mdm2ap_status(int on)
5327{
5328 if (on)
5329 return msm_gpios_request_enable(&mdm2ap_status, 1);
5330 else {
5331 msm_gpios_disable_free(&mdm2ap_status, 1);
5332 return 0;
5333 }
5334}
5335
5336static int get_mdm2ap_status(void)
5337{
5338 return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
5339}
5340
5341static struct sdio_al_platform_data sdio_al_pdata = {
5342 .config_mdm2ap_status = configure_mdm2ap_status,
5343 .get_mdm2ap_status = get_mdm2ap_status,
5344 .allow_sdioc_version_major_2 = 1,
5345 .peer_sdioc_version_minor = 0x0001,
5346 .peer_sdioc_version_major = 0x0003,
5347 .peer_sdioc_boot_version_minor = 0x0001,
5348 .peer_sdioc_boot_version_major = 0x0003,
5349};
5350
5351struct platform_device msm_device_sdio_al = {
5352 .name = "msm_sdio_al",
5353 .id = -1,
5354 .dev = {
5355 .platform_data = &sdio_al_pdata,
5356 },
5357};
5358
5359#endif /* CONFIG_MSM_SDIO_AL */
5360
Daniel Walker8d747cd2010-02-25 11:37:43 -08005361static struct platform_device *devices[] __initdata = {
Daniel Walker90e37c52010-05-12 14:24:15 -07005362#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005363 &msm_device_uart2,
5364#endif
Justin Paupore637a25d2011-07-14 17:11:04 -07005365#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
5366 &msm_proccomm_regulator_dev,
5367#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005368 &asoc_msm_pcm,
5369 &asoc_msm_dai0,
5370 &asoc_msm_dai1,
5371#if defined (CONFIG_SND_MSM_MVS_DAI_SOC)
5372 &asoc_msm_mvs,
5373 &asoc_mvs_dai0,
5374 &asoc_mvs_dai1,
Daniel Walker90e37c52010-05-12 14:24:15 -07005375#endif
Niranjana Vishwanathapuraa8855e92010-10-06 13:52:10 -07005376 &msm_device_smd,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005377 &msm_device_dmov,
5378 &smc91x_device,
5379 &smsc911x_device,
5380 &msm_device_nand,
5381#ifdef CONFIG_USB_MSM_OTG_72K
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05305382 &msm_device_otg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005383#ifdef CONFIG_USB_GADGET
5384 &msm_device_gadget_peripheral,
5385#endif
5386#endif
5387#ifdef CONFIG_USB_G_ANDROID
5388 &android_usb_device,
5389#endif
5390 &qsd_device_spi,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305391
5392#ifdef CONFIG_MSM_SSBI
5393 &msm_device_ssbi_pmic1,
5394#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005395#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005396 &msm_device_ssbi7,
5397#endif
5398 &android_pmem_device,
5399 &msm_fb_device,
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08005400#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
5401 &msm_v4l2_video_overlay_device,
5402#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005403 &msm_migrate_pages_device,
5404 &mddi_toshiba_device,
5405 &lcdc_toshiba_panel_device,
5406#ifdef CONFIG_MSM_ROTATOR
5407 &msm_rotator_device,
5408#endif
5409 &lcdc_sharp_panel_device,
5410 &android_pmem_adsp_device,
5411 &android_pmem_audio_device,
5412 &msm_device_i2c,
5413 &msm_device_i2c_2,
5414 &msm_device_uart_dm1,
5415 &hs_device,
5416#ifdef CONFIG_MSM7KV2_AUDIO
5417 &msm_aictl_device,
5418 &msm_mi2s_device,
5419 &msm_lpa_device,
5420 &msm_aux_pcm_device,
5421#endif
5422 &msm_device_adspdec,
5423 &qup_device_i2c,
5424#if defined(CONFIG_MARIMBA_CORE) && \
5425 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5426 &msm_bt_power_device,
5427#endif
5428 &msm_kgsl_3d0,
5429 &msm_kgsl_2d0,
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005430#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005431#ifdef CONFIG_MT9T013
5432 &msm_camera_sensor_mt9t013,
5433#endif
5434#ifdef CONFIG_MT9D112
5435 &msm_camera_sensor_mt9d112,
5436#endif
5437#ifdef CONFIG_WEBCAM_OV9726
5438 &msm_camera_sensor_ov9726,
5439#endif
5440#ifdef CONFIG_S5K3E2FX
5441 &msm_camera_sensor_s5k3e2fx,
5442#endif
5443#ifdef CONFIG_MT9P012
5444 &msm_camera_sensor_mt9p012,
5445#endif
5446#ifdef CONFIG_MT9E013
5447 &msm_camera_sensor_mt9e013,
5448#endif
5449#ifdef CONFIG_VX6953
5450 &msm_camera_sensor_vx6953,
5451#endif
5452#ifdef CONFIG_SN12M0PZ
5453 &msm_camera_sensor_sn12m0pz,
5454#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005455#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005456 &msm_device_vidc_720p,
5457#ifdef CONFIG_MSM_GEMINI
5458 &msm_gemini_device,
5459#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005460#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005461#ifdef CONFIG_MSM_VPE
5462 &msm_vpe_device,
5463#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005464#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005465#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5466 &msm_device_tsif,
5467#endif
5468#ifdef CONFIG_MSM_SDIO_AL
5469 &msm_device_sdio_al,
5470#endif
5471
5472#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5473 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5474 &qcrypto_device,
5475#endif
5476
5477#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5478 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5479 &qcedev_device,
5480#endif
5481
5482 &msm_batt_device,
5483 &msm_adc_device,
5484 &msm_ebi0_thermal,
Laxminath Kasam1d8255d2012-02-15 13:10:19 +05305485 &msm_ebi1_thermal,
5486 &msm_adsp_device
Daniel Walker8d747cd2010-02-25 11:37:43 -08005487};
5488
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005489static struct msm_gpio msm_i2c_gpios_hw[] = {
5490 { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5491 { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5492};
5493
5494static struct msm_gpio msm_i2c_gpios_io[] = {
5495 { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5496 { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5497};
5498
5499static struct msm_gpio qup_i2c_gpios_io[] = {
5500 { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5501 { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5502};
5503static struct msm_gpio qup_i2c_gpios_hw[] = {
5504 { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5505 { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5506};
5507
5508static void
5509msm_i2c_gpio_config(int adap_id, int config_type)
5510{
5511 struct msm_gpio *msm_i2c_table;
5512
5513 /* Each adapter gets 2 lines from the table */
5514 if (adap_id > 0)
5515 return;
5516 if (config_type)
5517 msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
5518 else
5519 msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
5520 msm_gpios_enable(msm_i2c_table, 2);
5521}
5522/*This needs to be enabled only for OEMS*/
5523#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005524static struct regulator *qup_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005525#endif
5526static void
5527qup_i2c_gpio_config(int adap_id, int config_type)
5528{
5529 int rc = 0;
5530 struct msm_gpio *qup_i2c_table;
5531 /* Each adapter gets 2 lines from the table */
5532 if (adap_id != 4)
5533 return;
5534 if (config_type)
5535 qup_i2c_table = qup_i2c_gpios_hw;
5536 else
5537 qup_i2c_table = qup_i2c_gpios_io;
5538 rc = msm_gpios_enable(qup_i2c_table, 2);
5539 if (rc < 0)
5540 printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
5541 /*This needs to be enabled only for OEMS*/
5542#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005543 if (!IS_ERR_OR_NULL(qup_vreg)) {
5544 rc = regulator_enable(qup_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005545 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005546 pr_err("%s: regulator_enable failed: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005547 __func__, rc);
5548 }
5549 }
5550#endif
5551}
5552
5553static struct msm_i2c_platform_data msm_i2c_pdata = {
5554 .clk_freq = 100000,
5555 .pri_clk = 70,
5556 .pri_dat = 71,
5557 .rmutex = 1,
5558 .rsl_id = "D:I2C02000021",
5559 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5560};
5561
5562static void __init msm_device_i2c_init(void)
5563{
5564 if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
5565 pr_err("failed to request I2C gpios\n");
5566
5567 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
5568}
5569
5570static struct msm_i2c_platform_data msm_i2c_2_pdata = {
5571 .clk_freq = 100000,
5572 .rmutex = 1,
5573 .rsl_id = "D:I2C02000022",
5574 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5575};
5576
5577static void __init msm_device_i2c_2_init(void)
5578{
5579 msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
5580}
5581
5582static struct msm_i2c_platform_data qup_i2c_pdata = {
5583 .clk_freq = 384000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005584 .msm_i2c_config_gpio = qup_i2c_gpio_config,
5585};
5586
5587static void __init qup_device_i2c_init(void)
5588{
5589 if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
5590 pr_err("failed to request I2C gpios\n");
5591
5592 qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
5593 /*This needs to be enabled only for OEMS*/
5594#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005595 qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005596 if (IS_ERR(qup_vreg)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005597 dev_err(&qup_device_i2c.dev,
5598 "%s: regulator_get failed: %ld\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005599 __func__, PTR_ERR(qup_vreg));
5600 }
5601#endif
5602}
5603
5604#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005605static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = {
5606 .rsl_id = "D:CODEC_SSBI",
5607 .controller_type = MSM_SBI_CTRL_SSBI,
5608};
5609#endif
5610
Daniel Walker8d747cd2010-02-25 11:37:43 -08005611static void __init msm7x30_init_irq(void)
5612{
5613 msm_init_irq();
5614}
5615
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005616static struct msm_gpio msm_nand_ebi2_cfg_data[] = {
5617 {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
5618 {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
5619};
5620
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005621#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
5622 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
5623 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
5624 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
5625
5626struct sdcc_gpio {
5627 struct msm_gpio *cfg_data;
5628 uint32_t size;
5629 struct msm_gpio *sleep_cfg_data;
5630};
5631#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5632static struct msm_gpio sdc1_lvlshft_cfg_data[] = {
5633 {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
5634};
5635#endif
5636static struct msm_gpio sdc1_cfg_data[] = {
5637 {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
5638 {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
5639 {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
5640 {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
5641 {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
5642 {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
5643};
5644
5645static struct msm_gpio sdc2_cfg_data[] = {
5646 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
5647 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
5648 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
5649 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
5650 {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
5651 {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
5652
5653#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5654 {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
5655 {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
5656 {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
5657 {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
5658#endif
5659};
5660
5661static struct msm_gpio sdc3_cfg_data[] = {
5662 {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
5663 {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
5664 {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
5665 {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
5666 {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
5667 {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
5668};
5669
5670static struct msm_gpio sdc3_sleep_cfg_data[] = {
5671 {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5672 "sdc3_clk"},
5673 {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5674 "sdc3_cmd"},
5675 {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5676 "sdc3_dat_3"},
5677 {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5678 "sdc3_dat_2"},
5679 {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5680 "sdc3_dat_1"},
5681 {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5682 "sdc3_dat_0"},
5683};
5684
5685static struct msm_gpio sdc4_cfg_data[] = {
5686 {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
5687 {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
5688 {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
5689 {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
5690 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
5691 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
5692};
5693
5694static struct sdcc_gpio sdcc_cfg_data[] = {
5695 {
5696 .cfg_data = sdc1_cfg_data,
5697 .size = ARRAY_SIZE(sdc1_cfg_data),
5698 .sleep_cfg_data = NULL,
5699 },
5700 {
5701 .cfg_data = sdc2_cfg_data,
5702 .size = ARRAY_SIZE(sdc2_cfg_data),
5703 .sleep_cfg_data = NULL,
5704 },
5705 {
5706 .cfg_data = sdc3_cfg_data,
5707 .size = ARRAY_SIZE(sdc3_cfg_data),
5708 .sleep_cfg_data = sdc3_sleep_cfg_data,
5709 },
5710 {
5711 .cfg_data = sdc4_cfg_data,
5712 .size = ARRAY_SIZE(sdc4_cfg_data),
5713 .sleep_cfg_data = NULL,
5714 },
5715};
5716
Justin Paupore3f40f342011-08-10 18:52:16 -07005717static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005718
5719static unsigned long vreg_sts, gpio_sts;
5720
5721static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
5722{
5723 int rc = 0;
5724 struct sdcc_gpio *curr;
5725
5726 curr = &sdcc_cfg_data[dev_id - 1];
5727
5728 if (!(test_bit(dev_id, &gpio_sts)^enable))
5729 return rc;
5730
5731 if (enable) {
5732 set_bit(dev_id, &gpio_sts);
5733 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
5734 if (rc)
5735 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
5736 __func__, dev_id);
5737 } else {
5738 clear_bit(dev_id, &gpio_sts);
5739 if (curr->sleep_cfg_data) {
5740 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
5741 msm_gpios_free(curr->sleep_cfg_data, curr->size);
5742 } else {
5743 msm_gpios_disable_free(curr->cfg_data, curr->size);
5744 }
5745 }
5746
5747 return rc;
5748}
5749
5750static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
5751{
5752 int rc = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005753 struct regulator *curr = sdcc_vreg_data[dev_id - 1];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005754 static int enabled_once[] = {0, 0, 0, 0};
5755
Justin Paupore3f40f342011-08-10 18:52:16 -07005756 if (test_bit(dev_id, &vreg_sts) == enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005757 return rc;
5758
Asutosh Das853bbcd2012-02-01 10:40:05 +05305759 if (dev_id == 4) {
5760 if (enable) {
5761 pr_debug("Enable Vdd dev_%d\n", dev_id);
5762 gpio_set_value_cansleep(
5763 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5764 0);
5765 set_bit(dev_id, &vreg_sts);
5766 } else {
5767 pr_debug("Disable Vdd dev_%d\n", dev_id);
5768 gpio_set_value_cansleep(
5769 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5770 1);
5771 clear_bit(dev_id, &vreg_sts);
5772 }
5773 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005774
Asutosh Das853bbcd2012-02-01 10:40:05 +05305775 if (!enable || enabled_once[dev_id - 1])
5776 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005777 if (!curr)
5778 return -ENODEV;
5779
5780 if (IS_ERR(curr))
5781 return PTR_ERR(curr);
5782
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005783 if (enable) {
5784 set_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005785
5786 rc = regulator_enable(curr);
5787 if (rc)
5788 pr_err("%s: could not enable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005789 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005790 enabled_once[dev_id - 1] = 1;
5791 } else {
5792 clear_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005793
5794 rc = regulator_disable(curr);
5795 if (rc)
5796 pr_err("%s: could not disable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005797 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005798 }
5799 return rc;
5800}
5801
5802static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
5803{
5804 int rc = 0;
5805 struct platform_device *pdev;
5806
5807 pdev = container_of(dv, struct platform_device, dev);
5808 rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
5809 if (rc)
5810 goto out;
5811
5812 if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
5813 rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
5814out:
5815 return rc;
5816}
5817
5818#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \
5819 defined(CONFIG_CSDIO_VENDOR_ID) && \
5820 defined(CONFIG_CSDIO_DEVICE_ID) && \
5821 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5822
5823#define MBP_ON 1
5824#define MBP_OFF 0
5825
5826#define MBP_RESET_N \
5827 GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
5828#define MBP_INT0 \
5829 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
5830
5831#define MBP_MODE_CTRL_0 \
5832 GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5833#define MBP_MODE_CTRL_1 \
5834 GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5835#define MBP_MODE_CTRL_2 \
5836 GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5837#define TSIF_EN \
5838 GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5839#define TSIF_DATA \
5840 GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5841#define TSIF_CLK \
5842 GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5843
5844static struct msm_gpio mbp_cfg_data[] = {
5845 {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5846 "mbp_reset"},
5847 {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5848 "mbp_io_voltage"},
5849};
5850
5851static int mbp_config_gpios_pre_init(int enable)
5852{
5853 int rc = 0;
5854
5855 if (enable) {
5856 rc = msm_gpios_request_enable(mbp_cfg_data,
5857 ARRAY_SIZE(mbp_cfg_data));
5858 if (rc) {
5859 printk(KERN_ERR
5860 "%s: Failed to turnon GPIOs for mbp chip(%d)\n",
5861 __func__, rc);
5862 }
5863 } else
5864 msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
5865 return rc;
5866}
5867
Justin Paupore3f40f342011-08-10 18:52:16 -07005868static struct regulator_bulk_data mbp_regs_io[2];
5869static struct regulator_bulk_data mbp_regs_rf[2];
5870static struct regulator_bulk_data mbp_regs_adc[1];
5871static struct regulator_bulk_data mbp_regs_core[1];
5872
5873static int mbp_init_regs(struct device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005874{
Justin Paupore3f40f342011-08-10 18:52:16 -07005875 struct regulator_bulk_data regs[] = {
5876 /* Analog and I/O regs */
5877 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
5878 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
5879 /* RF regs */
5880 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
5881 { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 },
5882 /* ADC regs */
5883 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
5884 /* Core regs */
5885 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
5886 };
5887
5888 struct regulator_bulk_data *regptr = regs;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005889 int rc;
5890
Justin Paupore3f40f342011-08-10 18:52:16 -07005891 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs);
5892
5893 if (rc) {
5894 dev_err(dev, "%s: could not get regulators: %d\n",
5895 __func__, rc);
5896 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005897 }
5898
Justin Paupore3f40f342011-08-10 18:52:16 -07005899 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005900
Justin Paupore3f40f342011-08-10 18:52:16 -07005901 if (rc) {
5902 dev_err(dev, "%s: could not set voltages: %d\n",
5903 __func__, rc);
5904 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005905 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005906
5907 memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io));
5908 regptr += ARRAY_SIZE(mbp_regs_io);
5909
5910 memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf));
5911 regptr += ARRAY_SIZE(mbp_regs_rf);
5912
5913 memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc));
5914 regptr += ARRAY_SIZE(mbp_regs_adc);
5915
5916 memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core));
5917
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005918 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005919
5920reg_free:
5921 regulator_bulk_free(ARRAY_SIZE(regs), regs);
5922out:
5923 return rc;
5924}
5925
5926static int mbp_setup_rf_vregs(int state)
5927{
5928 return state ?
5929 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) :
5930 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005931}
5932
5933static int mbp_setup_vregs(int state)
5934{
Justin Paupore3f40f342011-08-10 18:52:16 -07005935 return state ?
5936 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) :
5937 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005938}
5939
5940static int mbp_set_tcxo_en(int enable)
5941{
5942 int rc;
5943 const char *id = "UBMC";
5944 struct vreg *vreg_analog = NULL;
5945
5946 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
5947 enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
5948 if (rc < 0) {
5949 printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
5950 __func__, enable ? "" : "de-");
5951 return -EIO;
5952 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005953 return rc;
5954}
5955
5956static void mbp_set_freeze_io(int state)
5957{
5958 if (state)
5959 gpio_set_value(85, 0);
5960 else
5961 gpio_set_value(85, 1);
5962}
5963
5964static int mbp_set_core_voltage_en(int enable)
5965{
Justin Paupore3f40f342011-08-10 18:52:16 -07005966 static bool is_enabled;
5967 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005968
Justin Paupore3f40f342011-08-10 18:52:16 -07005969 if (enable && !is_enabled) {
5970 rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core),
5971 mbp_regs_core);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005972 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005973 pr_err("%s: could not enable regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005974 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07005975 } else {
5976 is_enabled = true;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005977 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005978 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005979
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005980 return rc;
5981}
5982
5983static void mbp_set_reset(int state)
5984{
5985 if (state)
5986 gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
5987 else
5988 gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
5989}
5990
5991static int mbp_config_interface_mode(int state)
5992{
5993 if (state) {
5994 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
5995 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
5996 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
5997 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
5998 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
5999 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
6000 } else {
6001 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
6002 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
6003 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
6004 }
6005 return 0;
6006}
6007
6008static int mbp_setup_adc_vregs(int state)
6009{
Justin Paupore3f40f342011-08-10 18:52:16 -07006010 return state ?
6011 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) :
6012 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006013}
6014
6015static int mbp_power_up(void)
6016{
6017 int rc;
6018
6019 rc = mbp_config_gpios_pre_init(MBP_ON);
6020 if (rc)
6021 goto exit;
6022 pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__);
6023
6024 rc = mbp_setup_vregs(MBP_ON);
6025 if (rc)
6026 goto exit;
6027 pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
6028
6029 rc = mbp_set_tcxo_en(MBP_ON);
6030 if (rc)
6031 goto exit;
6032 pr_debug("%s: tcxo clock done\n", __func__);
6033
6034 mbp_set_freeze_io(MBP_OFF);
6035 pr_debug("%s: set gpio 85 to 1 done\n", __func__);
6036
6037 udelay(100);
6038 mbp_set_reset(MBP_ON);
6039
6040 udelay(300);
6041 rc = mbp_config_interface_mode(MBP_ON);
6042 if (rc)
6043 goto exit;
6044 pr_debug("%s: mbp_config_interface_mode() done\n", __func__);
6045
6046 udelay(100 + mbp_set_core_voltage_en(MBP_ON));
6047 pr_debug("%s: power gp16 1.2V done\n", __func__);
6048
6049 mbp_set_freeze_io(MBP_ON);
6050 pr_debug("%s: set gpio 85 to 0 done\n", __func__);
6051
6052 udelay(100);
6053
6054 rc = mbp_setup_rf_vregs(MBP_ON);
6055 if (rc)
6056 goto exit;
6057 pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
6058
6059 rc = mbp_setup_adc_vregs(MBP_ON);
6060 if (rc)
6061 goto exit;
6062 pr_debug("%s: s4 2.2V done\n", __func__);
6063
6064 udelay(200);
6065
6066 mbp_set_reset(MBP_OFF);
6067 pr_debug("%s: close gpio 44 done\n", __func__);
6068
6069 msleep(20);
6070exit:
6071 return rc;
6072}
6073
6074static int mbp_power_down(void)
6075{
6076 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006077
6078 mbp_set_reset(MBP_ON);
6079 pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
6080
6081 udelay(100);
6082
6083 rc = mbp_setup_adc_vregs(MBP_OFF);
6084 if (rc)
6085 goto exit;
6086 pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
6087
6088 udelay(5);
6089
6090 rc = mbp_setup_rf_vregs(MBP_OFF);
6091 if (rc)
6092 goto exit;
6093 pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
6094
6095 udelay(5);
6096
6097 mbp_set_freeze_io(MBP_OFF);
6098 pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
6099
6100 udelay(100);
6101 rc = mbp_set_core_voltage_en(MBP_OFF);
6102 if (rc)
6103 goto exit;
6104 pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
6105
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006106 rc = mbp_set_tcxo_en(MBP_OFF);
6107 if (rc)
6108 goto exit;
6109 pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
6110
Justin Paupore3f40f342011-08-10 18:52:16 -07006111 rc = mbp_setup_vregs(MBP_OFF);
6112 if (rc)
6113 goto exit;
6114 pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__);
6115
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006116 rc = mbp_config_gpios_pre_init(MBP_OFF);
6117 if (rc)
6118 goto exit;
6119exit:
6120 return rc;
6121}
6122
6123static void (*mbp_status_notify_cb)(int card_present, void *dev_id);
6124static void *mbp_status_notify_cb_devid;
6125static int mbp_power_status;
6126static int mbp_power_init_done;
6127
6128static uint32_t mbp_setup_power(struct device *dv,
6129 unsigned int power_status)
6130{
6131 int rc = 0;
6132 struct platform_device *pdev;
6133
6134 pdev = container_of(dv, struct platform_device, dev);
6135
6136 if (power_status == mbp_power_status)
6137 goto exit;
6138 if (power_status) {
6139 pr_debug("turn on power of mbp slot");
6140 rc = mbp_power_up();
6141 mbp_power_status = 1;
6142 } else {
6143 pr_debug("turn off power of mbp slot");
6144 rc = mbp_power_down();
6145 mbp_power_status = 0;
6146 }
6147exit:
6148 return rc;
6149};
6150
6151int mbp_register_status_notify(void (*callback)(int, void *),
6152 void *dev_id)
6153{
6154 mbp_status_notify_cb = callback;
6155 mbp_status_notify_cb_devid = dev_id;
6156 return 0;
6157}
6158
6159static unsigned int mbp_status(struct device *dev)
6160{
6161 return mbp_power_status;
6162}
6163
6164static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd)
6165{
6166 struct platform_device *pdev;
6167 uint32_t rc = 0;
6168
6169 pdev = container_of(dv, struct platform_device, dev);
6170 rc = msm_sdcc_setup_power(dv, vdd);
6171 if (rc) {
6172 pr_err("%s: Failed to setup power (%d)\n",
6173 __func__, rc);
6174 goto out;
6175 }
6176 if (!mbp_power_init_done) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006177 rc = mbp_init_regs(dv);
6178 if (rc) {
6179 dev_err(dv, "%s: regulator init failed: %d\n",
6180 __func__, rc);
6181 goto out;
6182 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006183 mbp_setup_power(dv, 1);
6184 mbp_setup_power(dv, 0);
6185 mbp_power_init_done = 1;
6186 }
6187 if (vdd >= 0x8000) {
6188 rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
6189 if (rc) {
6190 pr_err("%s: Failed to config mbp chip power (%d)\n",
6191 __func__, rc);
6192 goto out;
6193 }
6194 if (mbp_status_notify_cb) {
6195 mbp_status_notify_cb(mbp_power_status,
6196 mbp_status_notify_cb_devid);
6197 }
6198 }
6199out:
6200 /* should return 0 only */
6201 return 0;
6202}
6203
6204#endif
6205
6206#endif
6207
6208#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6209#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6210static unsigned int msm7x30_sdcc_slot_status(struct device *dev)
6211{
6212 return (unsigned int)
6213 gpio_get_value_cansleep(
6214 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1));
6215}
6216#endif
6217
6218static int msm_sdcc_get_wpswitch(struct device *dv)
6219{
6220 void __iomem *wp_addr = 0;
6221 uint32_t ret = 0;
6222 struct platform_device *pdev;
6223
6224 if (!(machine_is_msm7x30_surf()))
6225 return -1;
6226 pdev = container_of(dv, struct platform_device, dev);
6227
6228 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
6229 if (!wp_addr) {
6230 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
6231 return -ENOMEM;
6232 }
6233
6234 ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
6235 pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
6236 pdev->id, ret);
6237 iounmap(wp_addr);
6238
6239 return ret;
6240}
6241#endif
6242
6243#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
6244#if defined(CONFIG_CSDIO_VENDOR_ID) && \
6245 defined(CONFIG_CSDIO_DEVICE_ID) && \
6246 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
6247static struct mmc_platform_data msm7x30_sdc1_data = {
6248 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
6249 .translate_vdd = msm_sdcc_setup_power_mbp,
6250 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6251 .status = mbp_status,
6252 .register_status_notify = mbp_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006253 .msmsdcc_fmin = 144000,
6254 .msmsdcc_fmid = 24576000,
6255 .msmsdcc_fmax = 24576000,
6256 .nonremovable = 0,
6257};
6258#else
6259static struct mmc_platform_data msm7x30_sdc1_data = {
6260 .ocr_mask = MMC_VDD_165_195,
6261 .translate_vdd = msm_sdcc_setup_power,
6262 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006263 .msmsdcc_fmin = 144000,
6264 .msmsdcc_fmid = 24576000,
6265 .msmsdcc_fmax = 49152000,
6266 .nonremovable = 0,
6267};
6268#endif
6269#endif
6270
6271#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
6272static struct mmc_platform_data msm7x30_sdc2_data = {
6273 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
6274 .translate_vdd = msm_sdcc_setup_power,
6275#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
6276 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
6277#else
6278 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6279#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006280 .msmsdcc_fmin = 144000,
6281 .msmsdcc_fmid = 24576000,
6282 .msmsdcc_fmax = 49152000,
6283 .nonremovable = 1,
6284};
6285#endif
6286
6287#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
6288static struct mmc_platform_data msm7x30_sdc3_data = {
6289 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6290 .translate_vdd = msm_sdcc_setup_power,
6291 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006292 .sdiowakeup_irq = MSM_GPIO_TO_INT(118),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006293 .msmsdcc_fmin = 144000,
6294 .msmsdcc_fmid = 24576000,
6295 .msmsdcc_fmax = 49152000,
6296 .nonremovable = 0,
6297};
6298#endif
6299
6300#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6301static struct mmc_platform_data msm7x30_sdc4_data = {
6302 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6303 .translate_vdd = msm_sdcc_setup_power,
6304 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6305#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6306 .status = msm7x30_sdcc_slot_status,
6307 .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
6308 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
6309#endif
6310 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006311 .msmsdcc_fmin = 144000,
6312 .msmsdcc_fmid = 24576000,
6313 .msmsdcc_fmax = 49152000,
6314 .nonremovable = 0,
6315};
6316#endif
6317
6318#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006319static int msm_sdc1_lvlshft_enable(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006320{
Justin Paupore3f40f342011-08-10 18:52:16 -07006321 static struct regulator *ldo5;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006322 int rc;
6323
6324 /* Enable LDO5, an input to the FET that powers slot 1 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006325
Justin Paupore3f40f342011-08-10 18:52:16 -07006326 ldo5 = regulator_get(NULL, "ldo5");
6327
6328 if (IS_ERR(ldo5)) {
6329 rc = PTR_ERR(ldo5);
6330 pr_err("%s: could not get ldo5: %d\n", __func__, rc);
6331 goto out;
6332 }
6333
6334 rc = regulator_set_voltage(ldo5, 2850000, 2850000);
6335 if (rc) {
6336 pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc);
6337 goto ldo5_free;
6338 }
6339
6340 rc = regulator_enable(ldo5);
6341 if (rc) {
6342 pr_err("%s: could not enable ldo5: %d\n", __func__, rc);
6343 goto ldo5_free;
6344 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006345
6346 /* Enable GPIO 35, to turn on the FET that powers slot 1 */
6347 rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
6348 ARRAY_SIZE(sdc1_lvlshft_cfg_data));
6349 if (rc)
6350 printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
6351
6352 rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg),
6353 1);
6354 if (rc)
6355 printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006356
6357 return 0;
6358
6359ldo5_free:
6360 regulator_put(ldo5);
6361out:
6362 ldo5 = NULL;
6363 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006364}
6365#endif
6366
Justin Paupore3f40f342011-08-10 18:52:16 -07006367static int mmc_regulator_init(int sdcc_no, const char *supply, int uV)
6368{
6369 int rc;
6370
6371 BUG_ON(sdcc_no < 1 || sdcc_no > 4);
6372
6373 sdcc_no--;
6374
6375 sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply);
6376
6377 if (IS_ERR(sdcc_vreg_data[sdcc_no])) {
6378 rc = PTR_ERR(sdcc_vreg_data[sdcc_no]);
6379 pr_err("%s: could not get regulator \"%s\": %d\n",
6380 __func__, supply, rc);
6381 goto out;
6382 }
6383
6384 rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV);
6385
6386 if (rc) {
6387 pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n",
6388 __func__, supply, uV, rc);
6389 goto reg_free;
6390 }
6391
6392 return rc;
6393
6394reg_free:
6395 regulator_put(sdcc_vreg_data[sdcc_no]);
6396out:
6397 sdcc_vreg_data[sdcc_no] = NULL;
6398 return rc;
6399}
6400
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006401static void __init msm7x30_init_mmc(void)
6402{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006403#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006404 if (mmc_regulator_init(1, "s3", 1800000))
6405 goto out1;
6406
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006407 if (machine_is_msm7x30_fluid()) {
6408 msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
Justin Paupore3f40f342011-08-10 18:52:16 -07006409 if (msm_sdc1_lvlshft_enable()) {
6410 pr_err("%s: could not enable level shift\n");
6411 goto out1;
6412 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006413 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006414
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006415 msm_add_sdcc(1, &msm7x30_sdc1_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006416out1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006417#endif
6418#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006419 if (mmc_regulator_init(2, "s3", 1800000))
6420 goto out2;
6421
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006422 if (machine_is_msm8x55_svlte_surf())
6423 msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
Sujith Reddy Thumma84a0f512011-08-29 09:57:03 +05306424 if (machine_is_msm8x55_svlte_surf() ||
6425 machine_is_msm8x55_svlte_ffa()) {
6426 msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
6427 msm7x30_sdc2_data.is_sdio_al_client = 1;
6428 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006429
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006430 msm_add_sdcc(2, &msm7x30_sdc2_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006431out2:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006432#endif
6433#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006434 if (mmc_regulator_init(3, "s3", 1800000))
6435 goto out3;
6436
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006437 msm_sdcc_setup_gpio(3, 1);
6438 msm_add_sdcc(3, &msm7x30_sdc3_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006439out3:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006440#endif
6441#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006442 if (mmc_regulator_init(4, "mmc", 2850000))
6443 return;
6444
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006445 msm_add_sdcc(4, &msm7x30_sdc4_data);
6446#endif
6447
6448}
6449
6450static void __init msm7x30_init_nand(void)
6451{
6452 char *build_id;
6453 struct flash_platform_data *plat_data;
6454
6455 build_id = socinfo_get_build_id();
6456 if (build_id == NULL) {
6457 pr_err("%s: Build ID not available from socinfo\n", __func__);
6458 return;
6459 }
6460
6461 if (build_id[8] == 'C' &&
6462 !msm_gpios_request_enable(msm_nand_ebi2_cfg_data,
6463 ARRAY_SIZE(msm_nand_ebi2_cfg_data))) {
6464 plat_data = msm_device_nand.dev.platform_data;
6465 plat_data->interleave = 1;
6466 printk(KERN_INFO "%s: Interleave mode Build ID found\n",
6467 __func__);
6468 }
6469}
6470
6471#ifdef CONFIG_SERIAL_MSM_CONSOLE
6472static struct msm_gpio uart2_config_data[] = {
6473 { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
6474 { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
6475 { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
6476 { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
6477};
6478
6479static void msm7x30_init_uart2(void)
6480{
6481 msm_gpios_request_enable(uart2_config_data,
6482 ARRAY_SIZE(uart2_config_data));
6483
6484}
6485#endif
6486
6487/* TSIF begin */
6488#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6489
6490#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6491#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6492#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6493#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6494
6495static const struct msm_gpio tsif_gpios[] = {
6496 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
6497 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
6498 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
6499 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
6500};
6501
6502static struct msm_tsif_platform_data tsif_platform_data = {
6503 .num_gpios = ARRAY_SIZE(tsif_gpios),
6504 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -07006505 .tsif_pclk = "iface_clk",
6506 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006507};
6508#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
6509/* TSIF end */
6510
6511static void __init pmic8058_leds_init(void)
6512{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306513 if (machine_is_msm7x30_surf())
6514 pm8058_7x30_data.leds_pdata = &pm8058_surf_leds_data;
6515 else if (!machine_is_msm7x30_fluid())
6516 pm8058_7x30_data.leds_pdata = &pm8058_ffa_leds_data;
6517 else if (machine_is_msm7x30_fluid())
6518 pm8058_7x30_data.leds_pdata = &pm8058_fluid_leds_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006519}
6520
6521static struct msm_spm_platform_data msm_spm_data __initdata = {
Taniya Das298de8c2012-02-16 11:45:31 +05306522 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006523
6524 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
6525 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
6526 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
6527 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
6528
6529 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
6530 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
6531 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
6532
6533 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
6534 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
6535 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
6536
6537 .awake_vlevel = 0xF2,
6538 .retention_vlevel = 0xE0,
6539 .collapse_vlevel = 0x72,
6540 .retention_mid_vlevel = 0xE0,
6541 .collapse_mid_vlevel = 0xE0,
6542
6543 .vctl_timeout_us = 50,
6544};
6545
6546#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6547 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6548
6549#define TSC2007_TS_PEN_INT 20
6550
6551static struct msm_gpio tsc2007_config_data[] = {
6552 { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
6553 "tsc2007_irq" },
6554};
6555
Justin Paupore3f40f342011-08-10 18:52:16 -07006556static struct regulator_bulk_data tsc2007_regs[] = {
6557 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
6558 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
6559};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006560
6561static int tsc2007_init(void)
6562{
6563 int rc;
6564
Justin Paupore3f40f342011-08-10 18:52:16 -07006565 rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006566
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006567 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006568 pr_err("%s: could not get regulators: %d\n", __func__, rc);
6569 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006570 }
6571
Justin Paupore3f40f342011-08-10 18:52:16 -07006572 rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6573
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006574 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006575 pr_err("%s: could not set voltages: %d\n", __func__, rc);
6576 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006577 }
6578
Justin Paupore3f40f342011-08-10 18:52:16 -07006579 rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006580
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006581 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006582 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
6583 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006584 }
6585
6586 rc = msm_gpios_request_enable(tsc2007_config_data,
6587 ARRAY_SIZE(tsc2007_config_data));
6588 if (rc) {
6589 pr_err("%s: Unable to request gpios\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006590 goto reg_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006591 }
6592
6593 return 0;
6594
Justin Paupore3f40f342011-08-10 18:52:16 -07006595reg_disable:
6596 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6597reg_free:
6598 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6599out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006600 return rc;
6601}
6602
6603static int tsc2007_get_pendown_state(void)
6604{
6605 int rc;
6606
6607 rc = gpio_get_value(TSC2007_TS_PEN_INT);
6608 if (rc < 0) {
6609 pr_err("%s: MSM GPIO %d read failed\n", __func__,
6610 TSC2007_TS_PEN_INT);
6611 return rc;
6612 }
6613
6614 return (rc == 0 ? 1 : 0);
6615}
6616
6617static void tsc2007_exit(void)
6618{
Justin Paupore3f40f342011-08-10 18:52:16 -07006619
6620 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6621 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006622
6623 msm_gpios_disable_free(tsc2007_config_data,
6624 ARRAY_SIZE(tsc2007_config_data));
6625}
6626
6627static int tsc2007_power_shutdown(bool enable)
6628{
6629 int rc;
6630
Justin Paupore3f40f342011-08-10 18:52:16 -07006631 rc = (enable == false) ?
6632 regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) :
6633 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6634
6635 if (rc) {
6636 pr_err("%s: could not %sable regulators: %d\n",
6637 __func__, enable ? "dis" : "en", rc);
6638 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006639 }
6640
Justin Paupore3f40f342011-08-10 18:52:16 -07006641 if (enable == false)
6642 msleep(20);
6643
6644 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006645}
6646
6647static struct tsc2007_platform_data tsc2007_ts_data = {
6648 .model = 2007,
6649 .x_plate_ohms = 300,
Anirudh Ghayala2cf2e22012-01-25 12:29:42 +05306650 .min_x = 210,
6651 .max_x = 3832,
6652 .min_y = 150,
6653 .max_y = 3936,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006654 .irq_flags = IRQF_TRIGGER_LOW,
6655 .init_platform_hw = tsc2007_init,
6656 .exit_platform_hw = tsc2007_exit,
6657 .power_shutdown = tsc2007_power_shutdown,
6658 .invert_x = true,
6659 .invert_y = true,
6660 /* REVISIT: Temporary fix for reversed pressure */
6661 .invert_z1 = true,
6662 .invert_z2 = true,
6663 .get_pendown_state = tsc2007_get_pendown_state,
6664};
6665
6666static struct i2c_board_info tsc_i2c_board_info[] = {
6667 {
6668 I2C_BOARD_INFO("tsc2007", 0x48),
6669 .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
6670 .platform_data = &tsc2007_ts_data,
6671 },
6672};
6673#endif
6674
Justin Paupore3f40f342011-08-10 18:52:16 -07006675static struct regulator_bulk_data regs_isa1200[] = {
6676 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
6677 { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006678};
6679
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006680static int isa1200_power(int vreg_on)
6681{
Justin Paupore3f40f342011-08-10 18:52:16 -07006682 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006683
Justin Paupore3f40f342011-08-10 18:52:16 -07006684 rc = vreg_on ?
6685 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) :
6686 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006687
Justin Paupore3f40f342011-08-10 18:52:16 -07006688 if (rc) {
6689 pr_err("%s: could not %sable regulators: %d\n",
6690 __func__, vreg_on ? "en" : "dis", rc);
6691 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006692 }
6693
6694 /* vote for DO buffer */
6695 rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO,
6696 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
6697 if (rc) {
6698 pr_err("%s: unable to %svote for d0 clk\n",
6699 __func__, vreg_on ? "" : "de-");
6700 goto vreg_fail;
6701 }
6702
6703 return 0;
6704
6705vreg_fail:
Justin Paupore3f40f342011-08-10 18:52:16 -07006706 if (vreg_on)
6707 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6708 else
6709 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6710out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006711 return rc;
6712}
6713
6714static int isa1200_dev_setup(bool enable)
6715{
Justin Paupore3f40f342011-08-10 18:52:16 -07006716 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006717
6718 if (enable == true) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006719 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200),
6720 regs_isa1200);
6721
6722 if (rc) {
6723 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006724 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006725 goto out;
6726 }
6727
6728 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200),
6729 regs_isa1200);
6730 if (rc) {
6731 pr_err("%s: could not set voltages: %d\n",
6732 __func__, rc);
6733 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006734 }
6735
6736 rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
6737 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
6738 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
6739 if (rc) {
6740 pr_err("%s: Could not configure gpio %d\n",
6741 __func__, HAP_LVL_SHFT_MSM_GPIO);
Justin Paupore3f40f342011-08-10 18:52:16 -07006742 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006743 }
6744
6745 rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
6746 if (rc) {
6747 pr_err("%s: unable to request gpio %d (%d)\n",
6748 __func__, HAP_LVL_SHFT_MSM_GPIO, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006749 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006750 }
6751
6752 gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
6753 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006754 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006755 gpio_free(HAP_LVL_SHFT_MSM_GPIO);
6756 }
6757
6758 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07006759
6760reg_free:
6761 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6762out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006763 return rc;
6764}
6765static struct isa1200_platform_data isa1200_1_pdata = {
6766 .name = "vibrator",
6767 .power_on = isa1200_power,
6768 .dev_setup = isa1200_dev_setup,
6769 .pwm_ch_id = 1, /*channel id*/
6770 /*gpio to enable haptic*/
6771 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka03122322011-09-09 15:15:43 +05306772 .hap_len_gpio = -1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006773 .max_timeout = 15000,
6774 .mode_ctrl = PWM_GEN_MODE,
6775 .pwm_fd = {
6776 .pwm_div = 256,
6777 },
6778 .is_erm = false,
6779 .smart_en = true,
6780 .ext_clk_en = true,
6781 .chip_en = 1,
6782};
6783
6784static struct i2c_board_info msm_isa1200_board_info[] = {
6785 {
6786 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
6787 .platform_data = &isa1200_1_pdata,
6788 },
6789};
6790
6791
6792static int kp_flip_mpp_config(void)
6793{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306794 struct pm8xxx_mpp_config_data kp_flip_mpp = {
6795 .type = PM8XXX_MPP_TYPE_D_INPUT,
6796 .level = PM8018_MPP_DIG_LEVEL_S3,
6797 .control = PM8XXX_MPP_DIN_TO_INT,
6798 };
6799
6800 return pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(PM_FLIP_MPP),
6801 &kp_flip_mpp);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006802}
6803
6804static struct flip_switch_pdata flip_switch_data = {
6805 .name = "kp_flip_switch",
6806 .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP,
6807 .left_key = KEY_OPEN,
6808 .right_key = KEY_CLOSE,
6809 .active_low = 0,
6810 .wakeup = 1,
6811 .flip_mpp_config = kp_flip_mpp_config,
6812};
6813
6814static struct platform_device flip_switch_device = {
6815 .name = "kp_flip_switch",
6816 .id = -1,
6817 .dev = {
6818 .platform_data = &flip_switch_data,
6819 }
6820};
6821
Justin Paupore3f40f342011-08-10 18:52:16 -07006822static struct regulator_bulk_data regs_tma300[] = {
6823 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
6824 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006825};
6826
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006827static int tma300_power(int vreg_on)
6828{
Justin Paupore3f40f342011-08-10 18:52:16 -07006829 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006830
Justin Paupore3f40f342011-08-10 18:52:16 -07006831 rc = vreg_on ?
6832 regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) :
6833 regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006834
Justin Paupore3f40f342011-08-10 18:52:16 -07006835 if (rc)
6836 pr_err("%s: could not %sable regulators: %d\n",
6837 __func__, vreg_on ? "en" : "dis", rc);
6838 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006839}
6840
6841#define TS_GPIO_IRQ 150
6842
6843static int tma300_dev_setup(bool enable)
6844{
Justin Paupore3f40f342011-08-10 18:52:16 -07006845 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006846
6847 if (enable) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006848 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300),
6849 regs_tma300);
6850
6851 if (rc) {
6852 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006853 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006854 goto out;
6855 }
6856
6857 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300),
6858 regs_tma300);
6859
6860 if (rc) {
6861 pr_err("%s: could not set voltages: %d\n",
6862 __func__, rc);
6863 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006864 }
6865
6866 /* enable interrupt gpio */
6867 rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
6868 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
6869 if (rc) {
6870 pr_err("%s: Could not configure gpio %d\n",
6871 __func__, TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -07006872 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006873 }
6874
6875 /* virtual keys */
6876 tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
6877 properties_kobj = kobject_create_and_add("board_properties",
6878 NULL);
6879 if (!properties_kobj) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006880 pr_err("%s: failed to create a kobject "
6881 "for board_properties\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006882 rc = -ENOMEM;
Justin Paupore3f40f342011-08-10 18:52:16 -07006883 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006884 }
6885 rc = sysfs_create_group(properties_kobj,
6886 &tma300_properties_attr_group);
6887 if (rc) {
6888 pr_err("%s: failed to create a sysfs entry %s\n",
6889 __func__, tma300_vkeys_attr.attr.name);
Justin Paupore3f40f342011-08-10 18:52:16 -07006890 goto kobj_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006891 }
6892 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006893 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006894 /* destroy virtual keys */
6895 if (properties_kobj) {
6896 sysfs_remove_group(properties_kobj,
6897 &tma300_properties_attr_group);
6898 kobject_put(properties_kobj);
6899 }
6900 }
6901 return 0;
6902
Justin Paupore3f40f342011-08-10 18:52:16 -07006903kobj_free:
6904 kobject_put(properties_kobj);
6905 properties_kobj = NULL;
6906reg_free:
6907 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
6908out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006909 return rc;
6910}
6911
6912static struct cy8c_ts_platform_data cy8ctma300_pdata = {
6913 .power_on = tma300_power,
6914 .dev_setup = tma300_dev_setup,
6915 .ts_name = "msm_tma300_ts",
6916 .dis_min_x = 0,
6917 .dis_max_x = 479,
6918 .dis_min_y = 0,
6919 .dis_max_y = 799,
6920 .res_x = 479,
6921 .res_y = 1009,
6922 .min_tid = 1,
6923 .max_tid = 255,
6924 .min_touch = 0,
6925 .max_touch = 255,
6926 .min_width = 0,
6927 .max_width = 255,
6928 .invert_y = 1,
6929 .nfingers = 4,
6930 .irq_gpio = TS_GPIO_IRQ,
6931 .resout_gpio = -1,
6932};
6933
6934static struct i2c_board_info cy8ctma300_board_info[] = {
6935 {
6936 I2C_BOARD_INFO("cy8ctma300", 0x2),
6937 .platform_data = &cy8ctma300_pdata,
6938 }
6939};
6940
Daniel Walker8d747cd2010-02-25 11:37:43 -08006941static void __init msm7x30_init(void)
6942{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006943 int rc;
6944 unsigned smem_size;
6945 uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56,
6946 0,
6947 GPIO_CFG_OUTPUT,
6948 GPIO_CFG_NO_PULL,
6949 GPIO_CFG_2MA);
6950 uint32_t soc_version = 0;
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05306951
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006952 soc_version = socinfo_get_version();
6953
Stephen Boydbb600ae2011-08-02 20:11:40 -07006954 msm_clock_init(&msm7x30_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006955#ifdef CONFIG_SERIAL_MSM_CONSOLE
6956 msm7x30_init_uart2();
6957#endif
6958 msm_spm_init(&msm_spm_data, 1);
Matt Wagantallbf430eb2012-03-22 11:45:49 -07006959 platform_device_register(&msm7x30_device_acpuclk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006960 if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid())
6961 msm7x30_cfg_smsc911x();
6962
6963#ifdef CONFIG_USB_MSM_OTG_72K
6964 if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 &&
6965 SOCINFO_VERSION_MINOR(soc_version) >= 1) {
6966 pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
6967 msm_otg_pdata.ldo_set_voltage = 0;
6968 }
6969
6970 msm_device_otg.dev.platform_data = &msm_otg_pdata;
6971#ifdef CONFIG_USB_GADGET
6972 msm_otg_pdata.swfi_latency =
6973 msm_pm_data
6974 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
6975 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
6976#endif
6977#endif
6978 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
6979 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
6980#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6981 msm_device_tsif.dev.platform_data = &tsif_platform_data;
6982#endif
6983 if (machine_is_msm7x30_fluid()) {
6984 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
6985 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
6986 } else {
6987 msm_adc_pdata.dev_names = msm_adc_surf_device_names;
6988 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names);
6989 }
6990
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306991 pmic8058_leds_init();
6992
6993 buses_init();
6994
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306995#ifdef CONFIG_MSM_SSBI
6996 msm_device_ssbi_pmic1.dev.platform_data =
6997 &msm7x30_ssbi_pm8058_pdata;
6998#endif
6999
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007000 platform_add_devices(msm_footswitch_devices,
7001 msm_num_footswitch_devices);
Daniel Walker8d747cd2010-02-25 11:37:43 -08007002 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007003#ifdef CONFIG_USB_EHCI_MSM_72K
7004 msm_add_host(0, &msm_usb_host_pdata);
7005#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07007006#ifdef CONFIG_MSM_CAMERA_V4L2
7007 msm7x30_init_cam();
7008#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007009 msm7x30_init_mmc();
7010 msm7x30_init_nand();
7011 msm_qsd_spi_init();
7012
7013#ifdef CONFIG_SPI_QSD
7014 if (machine_is_msm7x30_fluid())
7015 spi_register_board_info(lcdc_sharp_spi_board_info,
7016 ARRAY_SIZE(lcdc_sharp_spi_board_info));
7017 else
7018 spi_register_board_info(lcdc_toshiba_spi_board_info,
7019 ARRAY_SIZE(lcdc_toshiba_spi_board_info));
7020#endif
7021
Justin Paupore3f40f342011-08-10 18:52:16 -07007022 atv_dac_power_init();
7023 sensors_ldo_init();
7024 hdmi_init_regs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007025 msm_fb_add_devices();
7026 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06007027 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05307028 msm_pm_register_irqs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007029 msm_device_i2c_init();
7030 msm_device_i2c_2_init();
7031 qup_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007032 msm7x30_init_marimba();
7033#ifdef CONFIG_MSM7KV2_AUDIO
7034 snddev_poweramp_gpio_init();
Justin Paupore3f40f342011-08-10 18:52:16 -07007035 snddev_hsed_voltage_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007036 aux_pcm_gpio_init();
7037#endif
7038
7039 i2c_register_board_info(0, msm_i2c_board_info,
7040 ARRAY_SIZE(msm_i2c_board_info));
7041
7042 if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid())
7043 marimba_pdata.tsadc = &marimba_tsadc_pdata;
7044
7045 if (machine_is_msm7x30_fluid())
7046 i2c_register_board_info(0, cy8info,
7047 ARRAY_SIZE(cy8info));
7048#ifdef CONFIG_BOSCH_BMA150
7049 if (machine_is_msm7x30_fluid())
7050 i2c_register_board_info(0, bma150_board_info,
7051 ARRAY_SIZE(bma150_board_info));
7052#endif
7053
7054 i2c_register_board_info(2, msm_marimba_board_info,
7055 ARRAY_SIZE(msm_marimba_board_info));
7056
7057 i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info,
7058 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info));
7059
7060 i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
7061 ARRAY_SIZE(msm_camera_boardinfo));
7062
7063 bt_power_init();
7064#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007065 msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
7066#endif
7067 if (machine_is_msm7x30_fluid())
7068 i2c_register_board_info(0, msm_isa1200_board_info,
7069 ARRAY_SIZE(msm_isa1200_board_info));
7070
7071#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
7072 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
7073 if (machine_is_msm8x55_svlte_ffa())
7074 i2c_register_board_info(2, tsc_i2c_board_info,
7075 ARRAY_SIZE(tsc_i2c_board_info));
7076#endif
7077
7078 if (machine_is_msm7x30_surf())
7079 platform_device_register(&flip_switch_device);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307080
7081 pm8058_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007082
7083 if (machine_is_msm7x30_fluid()) {
7084 /* Initialize platform data for fluid v2 hardware */
7085 if (SOCINFO_VERSION_MAJOR(
7086 socinfo_get_platform_version()) == 2) {
7087 cy8ctma300_pdata.res_y = 920;
7088 cy8ctma300_pdata.invert_y = 0;
7089 }
7090 i2c_register_board_info(0, cy8ctma300_board_info,
7091 ARRAY_SIZE(cy8ctma300_board_info));
7092 }
7093
7094 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
7095 rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE);
7096 if (rc)
7097 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
7098 __func__, usb_hub_gpio_cfg_value, rc);
7099 }
7100
7101 boot_reason = *(unsigned int *)
7102 (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
7103 printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
7104}
7105
7106static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
7107static int __init pmem_sf_size_setup(char *p)
7108{
7109 pmem_sf_size = memparse(p, NULL);
7110 return 0;
7111}
7112early_param("pmem_sf_size", pmem_sf_size_setup);
7113
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307114static unsigned fb_size;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007115static int __init fb_size_setup(char *p)
7116{
7117 fb_size = memparse(p, NULL);
7118 return 0;
7119}
7120early_param("fb_size", fb_size_setup);
7121
7122static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
7123static int __init pmem_adsp_size_setup(char *p)
7124{
7125 pmem_adsp_size = memparse(p, NULL);
7126 return 0;
7127}
7128early_param("pmem_adsp_size", pmem_adsp_size_setup);
7129
7130static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE;
7131static int __init fluid_pmem_adsp_size_setup(char *p)
7132{
7133 fluid_pmem_adsp_size = memparse(p, NULL);
7134 return 0;
7135}
7136early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup);
7137
7138static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
7139static int __init pmem_audio_size_setup(char *p)
7140{
7141 pmem_audio_size = memparse(p, NULL);
7142 return 0;
7143}
7144early_param("pmem_audio_size", pmem_audio_size_setup);
7145
7146static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE;
7147static int __init pmem_kernel_ebi0_size_setup(char *p)
7148{
7149 pmem_kernel_ebi0_size = memparse(p, NULL);
7150 return 0;
7151}
7152early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
7153
7154static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
7155 [MEMTYPE_SMI] = {
7156 },
7157 [MEMTYPE_EBI0] = {
7158 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7159 },
7160 [MEMTYPE_EBI1] = {
7161 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7162 },
7163};
7164
7165static void __init size_pmem_devices(void)
7166{
7167#ifdef CONFIG_ANDROID_PMEM
7168 unsigned long size;
7169
7170 if machine_is_msm7x30_fluid()
7171 size = fluid_pmem_adsp_size;
7172 else
7173 size = pmem_adsp_size;
7174 android_pmem_adsp_pdata.size = size;
7175 android_pmem_audio_pdata.size = pmem_audio_size;
7176 android_pmem_pdata.size = pmem_sf_size;
7177#endif
7178}
7179
7180static void __init reserve_memory_for(struct android_pmem_platform_data *p)
7181{
7182 msm7x30_reserve_table[p->memory_type].size += p->size;
7183}
7184
7185static void __init reserve_pmem_memory(void)
7186{
7187#ifdef CONFIG_ANDROID_PMEM
7188 reserve_memory_for(&android_pmem_adsp_pdata);
7189 reserve_memory_for(&android_pmem_audio_pdata);
7190 reserve_memory_for(&android_pmem_pdata);
7191 msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
7192#endif
7193}
7194
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307195static void __init reserve_mdp_memory(void)
7196{
7197 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
7198 msm7x30_reserve_table[mdp_pdata.mem_hid].size += mdp_pdata.ov0_wb_size;
7199}
7200
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007201static void __init msm7x30_calculate_reserve_sizes(void)
7202{
7203 size_pmem_devices();
7204 reserve_pmem_memory();
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307205 reserve_mdp_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007206}
7207
7208static int msm7x30_paddr_to_memtype(unsigned int paddr)
7209{
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307210 if (paddr < phys_add)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007211 return MEMTYPE_EBI0;
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307212 if (paddr >= phys_add && paddr < 0x80000000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007213 return MEMTYPE_EBI1;
7214 return MEMTYPE_NONE;
7215}
7216
7217static struct reserve_info msm7x30_reserve_info __initdata = {
7218 .memtype_reserve_table = msm7x30_reserve_table,
7219 .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes,
7220 .paddr_to_memtype = msm7x30_paddr_to_memtype,
7221};
7222
7223static void __init msm7x30_reserve(void)
7224{
7225 reserve_info = &msm7x30_reserve_info;
7226 msm_reserve();
7227}
7228
7229static void __init msm7x30_allocate_memory_regions(void)
7230{
7231 void *addr;
7232 unsigned long size;
7233
7234 size = fb_size ? : MSM_FB_SIZE;
7235 addr = alloc_bootmem_align(size, 0x1000);
7236 msm_fb_resources[0].start = __pa(addr);
7237 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
7238 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
7239 size, addr, __pa(addr));
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08007240
7241#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
7242 size = MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE;
7243 addr = alloc_bootmem_align(size, 0x1000);
7244 msm_v4l2_video_overlay_resources[0].start = __pa(addr);
7245 msm_v4l2_video_overlay_resources[0].end =
7246 msm_v4l2_video_overlay_resources[0].start + size - 1;
7247 pr_debug("allocating %lu bytes at %p (%lx physical) for v4l2\n",
7248 size, addr, __pa(addr));
7249#endif
Daniel Walker8d747cd2010-02-25 11:37:43 -08007250}
7251
7252static void __init msm7x30_map_io(void)
7253{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007254 msm_shared_ram_phys = 0x00100000;
Daniel Walker8d747cd2010-02-25 11:37:43 -08007255 msm_map_msm7x30_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007256 if (socinfo_init() < 0)
7257 printk(KERN_ERR "%s: socinfo_init() failed!\n",
7258 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007259}
7260
7261static void __init msm7x30_init_early(void)
7262{
7263 msm7x30_allocate_memory_regions();
Daniel Walker8d747cd2010-02-25 11:37:43 -08007264}
7265
Steve Mucklef132c6c2012-06-06 18:30:57 -07007266static void __init msm7x30_fixup(struct tag *tags, char **cmdline,
7267 struct meminfo *mi)
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307268{
7269 for (; tags->hdr.size; tags = tag_next(tags)) {
7270 if (tags->hdr.tag == ATAG_MEM && tags->u.mem.start ==
7271 DDR1_BANK_BASE) {
7272 ebi1_phys_offset = DDR1_BANK_BASE;
7273 phys_add = DDR1_BANK_BASE;
7274 break;
7275 }
7276 }
Daniel Walker8d747cd2010-02-25 11:37:43 -08007277}
7278
7279MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
Nicolas Pitref631dd42011-07-05 22:38:14 -04007280 .atag_offset = 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007281 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007282 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007283 .init_irq = msm7x30_init_irq,
7284 .init_machine = msm7x30_init,
7285 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007286 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307287 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307288 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007289MACHINE_END
7290
7291MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
Nicolas Pitref631dd42011-07-05 22:38:14 -04007292 .atag_offset = 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007293 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007294 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007295 .init_irq = msm7x30_init_irq,
7296 .init_machine = msm7x30_init,
7297 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007298 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307299 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307300 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007301MACHINE_END
7302
7303MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
Nicolas Pitref631dd42011-07-05 22:38:14 -04007304 .atag_offset = 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007305 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007306 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007307 .init_irq = msm7x30_init_irq,
7308 .init_machine = msm7x30_init,
7309 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007310 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307311 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307312 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007313MACHINE_END
7314
7315MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007316 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007317 .map_io = msm7x30_map_io,
7318 .reserve = msm7x30_reserve,
7319 .init_irq = msm7x30_init_irq,
7320 .init_machine = msm7x30_init,
7321 .timer = &msm_timer,
7322 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307323 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307324 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007325MACHINE_END
7326
7327MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007328 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007329 .map_io = msm7x30_map_io,
7330 .reserve = msm7x30_reserve,
7331 .init_irq = msm7x30_init_irq,
7332 .init_machine = msm7x30_init,
7333 .timer = &msm_timer,
7334 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307335 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307336 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007337MACHINE_END
7338MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007339 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007340 .map_io = msm7x30_map_io,
7341 .reserve = msm7x30_reserve,
7342 .init_irq = msm7x30_init_irq,
7343 .init_machine = msm7x30_init,
7344 .timer = &msm_timer,
7345 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307346 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307347 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007348MACHINE_END
7349MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA")
Steve Mucklef132c6c2012-06-06 18:30:57 -07007350 .atag_offset = 0x100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007351 .map_io = msm7x30_map_io,
7352 .reserve = msm7x30_reserve,
7353 .init_irq = msm7x30_init_irq,
7354 .init_machine = msm7x30_init,
7355 .timer = &msm_timer,
7356 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307357 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307358 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007359MACHINE_END