blob: 4ec9743df42fb3a73502a273c7f48f39cc9823a8 [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>
68#include <linux/cyttsp.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"
Justin Paupore637a25d2011-07-14 17:11:04 -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
108#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
109#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)
177{
178 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,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530255 }
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;
352}
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)
369{
370 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");
376}
377
378static 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,
796 },
797 [1] = {
798 .name = "voice:red",
799 .max_brightness = 20,
800 .id = PMIC8058_ID_LED_0,
801 },
802 [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,
883 .is_csic = 1,
884 .is_vpe = 1,
885 .ioclk = {
886 .vfe_clk_rate = 153600000,
887 },
888 },
Sreesudhan Ramakrish Ramkumar66deac32012-04-05 10:15:38 -0700889 {
890 .csid_core = 0,
891 .is_vpe = 1,
892 .ioclk = {
893 .vfe_clk_rate = 153600000,
894 },
895 },
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700896};
897
898static struct camera_vreg_t msm_7x30_back_cam_vreg[] = {
899 {"gp2", REG_LDO, 2600000, 2600000, -1},
900 {"lvsw1", REG_VS, 0, 0, 0},
901};
902
903static uint32_t camera_off_gpio_table[] = {
904 /* parallel CAMERA interfaces */
905 /* RST */
906 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
907 /* DAT2 */
908 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
909 /* DAT3 */
910 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
911 /* DAT4 */
912 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
913 /* DAT5 */
914 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
915 /* DAT6 */
916 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
917 /* DAT7 */
918 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
919 /* DAT8 */
920 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
921 /* DAT9 */
922 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
923 /* DAT10 */
924 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
925 /* DAT11 */
926 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
927 /* PCLK */
928 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
929 /* HSYNC_IN */
930 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
931 /* VSYNC_IN */
932 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
933 /* MCLK */
934 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
935};
936
937static uint32_t camera_on_gpio_table[] = {
938 /* parallel CAMERA interfaces */
939 /* RST */
940 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
941 /* DAT2 */
942 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
943 /* DAT3 */
944 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
945 /* DAT4 */
946 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
947 /* DAT5 */
948 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
949 /* DAT6 */
950 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
951 /* DAT7 */
952 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
953 /* DAT8 */
954 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
955 /* DAT9 */
956 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
957 /* DAT10 */
958 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
959 /* DAT11 */
960 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
961 /* PCLK */
962 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
963 /* HSYNC_IN */
964 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
965 /* VSYNC_IN */
966 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
967 /* MCLK */
968 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
969};
970
971static struct gpio msm7x30_back_cam_gpio[] = {
972 {0, GPIOF_DIR_OUT, "CAM_RESET"},
973};
974
975static struct msm_gpio_set_tbl msm7x30_back_cam_gpio_set_tbl[] = {
976 {0, GPIOF_OUT_INIT_LOW, 1000},
977 {0, GPIOF_OUT_INIT_HIGH, 4000},
978};
979
980static struct msm_camera_gpio_conf msm_7x30_back_cam_gpio_conf = {
981 .cam_gpio_req_tbl = msm7x30_back_cam_gpio,
982 .cam_gpio_req_tbl_size = ARRAY_SIZE(msm7x30_back_cam_gpio),
983 .cam_gpio_set_tbl = msm7x30_back_cam_gpio_set_tbl,
984 .cam_gpio_set_tbl_size = ARRAY_SIZE(msm7x30_back_cam_gpio_set_tbl),
985 .camera_off_table = camera_off_gpio_table,
986 .camera_off_table_size = ARRAY_SIZE(camera_off_gpio_table),
987 .camera_on_table = camera_on_gpio_table,
988 .camera_on_table_size = ARRAY_SIZE(camera_on_gpio_table),
989 .gpio_no_mux = 1,
990};
991
992static struct msm_camera_sensor_flash_data flash_vx6953 = {
993 .flash_type = MSM_CAMERA_FLASH_NONE,
994};
995
996static struct msm_camera_sensor_platform_info sensor_board_info_vx6953 = {
997 .mount_angle = 0,
998 .cam_vreg = msm_7x30_back_cam_vreg,
999 .num_vreg = ARRAY_SIZE(msm_7x30_back_cam_vreg),
1000 .gpio_conf = &msm_7x30_back_cam_gpio_conf,
1001};
1002
1003static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1004 .sensor_name = "vx6953",
1005 .pdata = &msm_camera_csi_device_data[0],
1006 .flash_data = &flash_vx6953,
1007 .sensor_platform_info = &sensor_board_info_vx6953,
1008 .csi_if = 1,
1009 .camera_type = BACK_CAMERA_2D,
1010};
1011
Kevin Chan94b4c832012-03-02 21:27:16 -08001012static struct platform_device msm_camera_server = {
1013 .name = "msm_cam_server",
1014 .id = 0,
1015};
1016
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001017void __init msm7x30_init_cam(void)
1018{
Kevin Chan94b4c832012-03-02 21:27:16 -08001019 platform_device_register(&msm_camera_server);
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001020 platform_device_register(&msm_device_csic0);
1021 platform_device_register(&msm_device_vfe);
1022 platform_device_register(&msm_device_vpe);
1023}
1024
1025#ifdef CONFIG_I2C
1026static struct i2c_board_info msm_camera_boardinfo[] = {
1027 {
1028 I2C_BOARD_INFO("vx6953", 0x20),
1029 .platform_data = &msm_camera_sensor_vx6953_data,
1030 },
1031};
1032#endif
1033#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001034static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
1035#ifdef CONFIG_MT9D112
1036 {
1037 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
Dima Zavinba5499e2011-01-10 11:00:30 -08001038 },
1039#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001040#ifdef CONFIG_WEBCAM_OV9726
1041 {
1042 I2C_BOARD_INFO("ov9726", 0x10),
1043 },
1044#endif
1045#ifdef CONFIG_S5K3E2FX
1046 {
1047 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
1048 },
1049#endif
1050#ifdef CONFIG_MT9P012
1051 {
1052 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
1053 },
1054#endif
1055#ifdef CONFIG_VX6953
1056 {
1057 I2C_BOARD_INFO("vx6953", 0x20),
1058 },
1059#endif
1060#ifdef CONFIG_MT9E013
1061 {
1062 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
1063 },
1064#endif
1065#ifdef CONFIG_SN12M0PZ
1066 {
1067 I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1),
1068 },
1069#endif
1070#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
1071 {
1072 I2C_BOARD_INFO("mt9t013", 0x6C),
1073 },
1074#endif
1075
Dima Zavinba5499e2011-01-10 11:00:30 -08001076};
1077
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001078#ifdef CONFIG_MSM_CAMERA
1079#define CAM_STNDBY 143
1080static uint32_t camera_off_vcm_gpio_table[] = {
1081GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */
1082};
1083
1084static uint32_t camera_off_gpio_table[] = {
1085 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001086 /* RST */
1087 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1088 /* DAT2 */
1089 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1090 /* DAT3 */
1091 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1092 /* DAT4 */
1093 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1094 /* DAT5 */
1095 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1096 /* DAT6 */
1097 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1098 /* DAT7 */
1099 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1100 /* DAT8 */
1101 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1102 /* DAT9 */
1103 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1104 /* DAT10 */
1105 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1106 /* DAT11 */
1107 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1108 /* PCLK */
1109 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1110 /* HSYNC_IN */
1111 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1112 /* VSYNC_IN */
1113 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1114 /* MCLK */
1115 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001116};
1117
1118static uint32_t camera_on_vcm_gpio_table[] = {
1119GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */
1120};
1121
1122static uint32_t camera_on_gpio_table[] = {
1123 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001124 /* RST */
1125 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1126 /* DAT2 */
1127 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1128 /* DAT3 */
1129 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1130 /* DAT4 */
1131 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1132 /* DAT5 */
1133 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1134 /* DAT6 */
1135 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1136 /* DAT7 */
1137 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1138 /* DAT8 */
1139 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1140 /* DAT9 */
1141 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1142 /* DAT10 */
1143 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1144 /* DAT11 */
1145 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1146 /* PCLK */
1147 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1148 /* HSYNC_IN */
1149 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1150 /* VSYNC_IN */
1151 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1152 /* MCLK */
1153 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001154};
1155
1156static uint32_t camera_off_gpio_fluid_table[] = {
1157 /* FLUID: CAM_VGA_RST_N */
1158 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1159 /* FLUID: CAMIF_STANDBY */
1160 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1161};
1162
1163static uint32_t camera_on_gpio_fluid_table[] = {
1164 /* FLUID: CAM_VGA_RST_N */
1165 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1166 /* FLUID: CAMIF_STANDBY */
1167 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1168};
1169
1170static void config_gpio_table(uint32_t *table, int len)
1171{
1172 int n, rc;
1173 for (n = 0; n < len; n++) {
1174 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
1175 if (rc) {
1176 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
1177 __func__, table[n], rc);
1178 break;
1179 }
1180 }
1181}
1182static int config_camera_on_gpios(void)
1183{
1184 config_gpio_table(camera_on_gpio_table,
1185 ARRAY_SIZE(camera_on_gpio_table));
1186
1187 if (adie_get_detected_codec_type() != TIMPANI_ID)
1188 /* GPIO1 is shared also used in Timpani RF card so
1189 only configure it for non-Timpani RF card */
1190 config_gpio_table(camera_on_vcm_gpio_table,
1191 ARRAY_SIZE(camera_on_vcm_gpio_table));
1192
1193 if (machine_is_msm7x30_fluid()) {
1194 config_gpio_table(camera_on_gpio_fluid_table,
1195 ARRAY_SIZE(camera_on_gpio_fluid_table));
1196 /* FLUID: turn on 5V booster */
1197 gpio_set_value(
1198 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 1);
1199 /* FLUID: drive high to put secondary sensor to STANDBY */
1200 gpio_set_value(CAM_STNDBY, 1);
1201 }
1202 return 0;
1203}
1204
1205static void config_camera_off_gpios(void)
1206{
1207 config_gpio_table(camera_off_gpio_table,
1208 ARRAY_SIZE(camera_off_gpio_table));
1209
1210 if (adie_get_detected_codec_type() != TIMPANI_ID)
1211 /* GPIO1 is shared also used in Timpani RF card so
1212 only configure it for non-Timpani RF card */
1213 config_gpio_table(camera_off_vcm_gpio_table,
1214 ARRAY_SIZE(camera_off_vcm_gpio_table));
1215
1216 if (machine_is_msm7x30_fluid()) {
1217 config_gpio_table(camera_off_gpio_fluid_table,
1218 ARRAY_SIZE(camera_off_gpio_fluid_table));
1219 /* FLUID: turn off 5V booster */
1220 gpio_set_value(
1221 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 0);
1222 }
1223}
1224
1225struct resource msm_camera_resources[] = {
1226 {
1227 .start = 0xA6000000,
1228 .end = 0xA6000000 + SZ_1M - 1,
1229 .flags = IORESOURCE_MEM,
1230 },
1231 {
1232 .start = INT_VFE,
1233 .end = INT_VFE,
1234 .flags = IORESOURCE_IRQ,
1235 },
1236 {
1237 .flags = IORESOURCE_DMA,
1238 }
1239};
1240
1241struct msm_camera_device_platform_data msm_camera_device_data = {
1242 .camera_gpio_on = config_camera_on_gpios,
1243 .camera_gpio_off = config_camera_off_gpios,
1244 .ioext.camifpadphy = 0xAB000000,
1245 .ioext.camifpadsz = 0x00000400,
1246 .ioext.csiphy = 0xA6100000,
1247 .ioext.csisz = 0x00000400,
1248 .ioext.csiirq = INT_CSI,
1249 .ioclk.mclk_clk_rate = 24000000,
1250 .ioclk.vfe_clk_rate = 147456000,
1251};
1252
1253static struct msm_camera_sensor_flash_src msm_flash_src_pwm = {
1254 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PWM,
1255 ._fsrc.pwm_src.freq = 1000,
1256 ._fsrc.pwm_src.max_load = 300,
1257 ._fsrc.pwm_src.low_load = 30,
1258 ._fsrc.pwm_src.high_load = 100,
1259 ._fsrc.pwm_src.channel = 7,
1260};
1261
1262#ifdef CONFIG_MT9D112
1263static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1264 .flash_type = MSM_CAMERA_FLASH_LED,
1265 .flash_src = &msm_flash_src_pwm
1266};
1267
1268static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1269 .sensor_name = "mt9d112",
1270 .sensor_reset = 0,
1271 .sensor_pwd = 85,
1272 .vcm_pwd = 1,
1273 .vcm_enable = 0,
1274 .pdata = &msm_camera_device_data,
1275 .resource = msm_camera_resources,
1276 .num_resources = ARRAY_SIZE(msm_camera_resources),
1277 .flash_data = &flash_mt9d112,
1278 .csi_if = 0
1279};
1280
1281static struct platform_device msm_camera_sensor_mt9d112 = {
1282 .name = "msm_camera_mt9d112",
1283 .dev = {
1284 .platform_data = &msm_camera_sensor_mt9d112_data,
1285 },
1286};
1287#endif
1288
1289#ifdef CONFIG_WEBCAM_OV9726
1290
1291static struct msm_camera_sensor_platform_info ov9726_sensor_7630_info = {
1292 .mount_angle = 90
1293};
1294
1295static struct msm_camera_sensor_flash_data flash_ov9726 = {
1296 .flash_type = MSM_CAMERA_FLASH_LED,
1297 .flash_src = &msm_flash_src_pwm
1298};
1299static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
1300 .sensor_name = "ov9726",
1301 .sensor_reset = 0,
1302 .sensor_pwd = 85,
1303 .vcm_pwd = 1,
1304 .vcm_enable = 0,
1305 .pdata = &msm_camera_device_data,
1306 .resource = msm_camera_resources,
1307 .num_resources = ARRAY_SIZE(msm_camera_resources),
1308 .flash_data = &flash_ov9726,
1309 .sensor_platform_info = &ov9726_sensor_7630_info,
1310 .csi_if = 1
1311};
1312struct platform_device msm_camera_sensor_ov9726 = {
1313 .name = "msm_camera_ov9726",
1314 .dev = {
1315 .platform_data = &msm_camera_sensor_ov9726_data,
1316 },
1317};
1318#endif
1319
1320#ifdef CONFIG_S5K3E2FX
1321static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1322 .flash_type = MSM_CAMERA_FLASH_LED,
1323 .flash_src = &msm_flash_src_pwm,
1324};
1325
1326static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1327 .sensor_name = "s5k3e2fx",
1328 .sensor_reset = 0,
1329 .sensor_pwd = 85,
1330 .vcm_pwd = 1,
1331 .vcm_enable = 0,
1332 .pdata = &msm_camera_device_data,
1333 .resource = msm_camera_resources,
1334 .num_resources = ARRAY_SIZE(msm_camera_resources),
1335 .flash_data = &flash_s5k3e2fx,
1336 .csi_if = 0
1337};
1338
1339static struct platform_device msm_camera_sensor_s5k3e2fx = {
1340 .name = "msm_camera_s5k3e2fx",
1341 .dev = {
1342 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1343 },
1344};
1345#endif
1346
1347#ifdef CONFIG_MT9P012
1348static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1349 .flash_type = MSM_CAMERA_FLASH_LED,
1350 .flash_src = &msm_flash_src_pwm
1351};
1352
1353static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1354 .sensor_name = "mt9p012",
1355 .sensor_reset = 0,
1356 .sensor_pwd = 85,
1357 .vcm_pwd = 1,
1358 .vcm_enable = 1,
1359 .pdata = &msm_camera_device_data,
1360 .resource = msm_camera_resources,
1361 .num_resources = ARRAY_SIZE(msm_camera_resources),
1362 .flash_data = &flash_mt9p012,
1363 .csi_if = 0
1364};
1365
1366static struct platform_device msm_camera_sensor_mt9p012 = {
1367 .name = "msm_camera_mt9p012",
1368 .dev = {
1369 .platform_data = &msm_camera_sensor_mt9p012_data,
1370 },
1371};
1372#endif
1373
1374#ifdef CONFIG_MT9E013
1375static struct msm_camera_sensor_platform_info mt9e013_sensor_7630_info = {
1376 .mount_angle = 0
1377};
1378
1379static struct msm_camera_sensor_flash_data flash_mt9e013 = {
1380 .flash_type = MSM_CAMERA_FLASH_LED,
1381 .flash_src = &msm_flash_src_pwm
1382};
1383
1384static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
1385 .sensor_name = "mt9e013",
1386 .sensor_reset = 0,
1387 .sensor_pwd = 85,
1388 .vcm_pwd = 1,
1389 .vcm_enable = 1,
1390 .pdata = &msm_camera_device_data,
1391 .resource = msm_camera_resources,
1392 .num_resources = ARRAY_SIZE(msm_camera_resources),
1393 .flash_data = &flash_mt9e013,
1394 .sensor_platform_info = &mt9e013_sensor_7630_info,
1395 .csi_if = 1
1396};
1397
1398static struct platform_device msm_camera_sensor_mt9e013 = {
1399 .name = "msm_camera_mt9e013",
1400 .dev = {
1401 .platform_data = &msm_camera_sensor_mt9e013_data,
1402 },
1403};
1404#endif
1405
1406#ifdef CONFIG_VX6953
Jilai Wang971f97f2011-07-13 14:25:25 -04001407static struct msm_camera_sensor_platform_info vx6953_sensor_7630_info = {
1408 .mount_angle = 0
1409};
1410
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001411static struct msm_camera_sensor_flash_data flash_vx6953 = {
1412 .flash_type = MSM_CAMERA_FLASH_LED,
1413 .flash_src = &msm_flash_src_pwm
1414};
1415static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1416 .sensor_name = "vx6953",
1417 .sensor_reset = 0,
1418 .sensor_pwd = 85,
1419 .vcm_pwd = 1,
1420 .vcm_enable = 0,
1421 .pdata = &msm_camera_device_data,
1422 .resource = msm_camera_resources,
1423 .num_resources = ARRAY_SIZE(msm_camera_resources),
Jilai Wang971f97f2011-07-13 14:25:25 -04001424 .sensor_platform_info = &vx6953_sensor_7630_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001425 .flash_data = &flash_vx6953,
1426 .csi_if = 1
1427};
1428static struct platform_device msm_camera_sensor_vx6953 = {
1429 .name = "msm_camera_vx6953",
1430 .dev = {
1431 .platform_data = &msm_camera_sensor_vx6953_data,
1432 },
1433};
1434#endif
1435
1436#ifdef CONFIG_SN12M0PZ
1437static struct msm_camera_sensor_flash_src msm_flash_src_current_driver = {
1438 .flash_sr_type = MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER,
1439 ._fsrc.current_driver_src.low_current = 210,
1440 ._fsrc.current_driver_src.high_current = 700,
1441 ._fsrc.current_driver_src.driver_channel = &pm8058_fluid_leds_data,
1442};
1443
1444static struct msm_camera_sensor_flash_data flash_sn12m0pz = {
1445 .flash_type = MSM_CAMERA_FLASH_LED,
1446 .flash_src = &msm_flash_src_current_driver
1447};
1448static struct msm_camera_sensor_info msm_camera_sensor_sn12m0pz_data = {
1449 .sensor_name = "sn12m0pz",
1450 .sensor_reset = 0,
1451 .sensor_pwd = 85,
1452 .vcm_pwd = 1,
1453 .vcm_enable = 1,
1454 .pdata = &msm_camera_device_data,
1455 .flash_data = &flash_sn12m0pz,
1456 .resource = msm_camera_resources,
1457 .num_resources = ARRAY_SIZE(msm_camera_resources),
1458 .csi_if = 0
1459};
1460
1461static struct platform_device msm_camera_sensor_sn12m0pz = {
1462 .name = "msm_camera_sn12m0pz",
1463 .dev = {
1464 .platform_data = &msm_camera_sensor_sn12m0pz_data,
1465 },
1466};
1467#endif
1468
1469#ifdef CONFIG_MT9T013
1470static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1471 .flash_type = MSM_CAMERA_FLASH_LED,
1472 .flash_src = &msm_flash_src_pwm
1473};
1474
1475static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1476 .sensor_name = "mt9t013",
1477 .sensor_reset = 0,
1478 .sensor_pwd = 85,
1479 .vcm_pwd = 1,
1480 .vcm_enable = 0,
1481 .pdata = &msm_camera_device_data,
1482 .resource = msm_camera_resources,
1483 .num_resources = ARRAY_SIZE(msm_camera_resources),
1484 .flash_data = &flash_mt9t013,
1485 .csi_if = 1
1486};
1487
1488static struct platform_device msm_camera_sensor_mt9t013 = {
1489 .name = "msm_camera_mt9t013",
1490 .dev = {
1491 .platform_data = &msm_camera_sensor_mt9t013_data,
1492 },
1493};
1494#endif
1495
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001496#ifdef CONFIG_MSM_VPE
1497static struct resource msm_vpe_resources[] = {
1498 {
1499 .start = 0xAD200000,
1500 .end = 0xAD200000 + SZ_1M - 1,
1501 .flags = IORESOURCE_MEM,
1502 },
1503 {
1504 .start = INT_VPE,
1505 .end = INT_VPE,
1506 .flags = IORESOURCE_IRQ,
1507 },
1508};
1509
1510static struct platform_device msm_vpe_device = {
1511 .name = "msm_vpe",
1512 .id = 0,
1513 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1514 .resource = msm_vpe_resources,
1515};
1516#endif
1517
1518#endif /*CONFIG_MSM_CAMERA*/
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001519#endif
1520
1521#ifdef CONFIG_MSM_GEMINI
1522static struct resource msm_gemini_resources[] = {
1523 {
1524 .start = 0xA3A00000,
1525 .end = 0xA3A00000 + 0x0150 - 1,
1526 .flags = IORESOURCE_MEM,
1527 },
1528 {
1529 .start = INT_JPEG,
1530 .end = INT_JPEG,
1531 .flags = IORESOURCE_IRQ,
1532 },
1533};
1534
1535static struct platform_device msm_gemini_device = {
1536 .name = "msm_gemini",
1537 .resource = msm_gemini_resources,
1538 .num_resources = ARRAY_SIZE(msm_gemini_resources),
1539};
1540#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001541
1542#ifdef CONFIG_MSM7KV2_AUDIO
1543static uint32_t audio_pamp_gpio_config =
1544 GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1545
1546static uint32_t audio_fluid_icodec_tx_config =
1547 GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1548
1549static int __init snddev_poweramp_gpio_init(void)
1550{
1551 int rc;
1552
1553 pr_info("snddev_poweramp_gpio_init \n");
1554 rc = gpio_tlmm_config(audio_pamp_gpio_config, GPIO_CFG_ENABLE);
1555 if (rc) {
1556 printk(KERN_ERR
1557 "%s: gpio_tlmm_config(%#x)=%d\n",
1558 __func__, audio_pamp_gpio_config, rc);
1559 }
1560 return rc;
1561}
1562
1563void msm_snddev_tx_route_config(void)
1564{
1565 int rc;
1566
1567 pr_debug("%s()\n", __func__);
1568
1569 if (machine_is_msm7x30_fluid()) {
1570 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1571 GPIO_CFG_ENABLE);
1572 if (rc) {
1573 printk(KERN_ERR
1574 "%s: gpio_tlmm_config(%#x)=%d\n",
1575 __func__, audio_fluid_icodec_tx_config, rc);
1576 } else
1577 gpio_set_value(85, 0);
1578 }
1579}
1580
1581void msm_snddev_tx_route_deconfig(void)
1582{
1583 int rc;
1584
1585 pr_debug("%s()\n", __func__);
1586
1587 if (machine_is_msm7x30_fluid()) {
1588 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1589 GPIO_CFG_DISABLE);
1590 if (rc) {
1591 printk(KERN_ERR
1592 "%s: gpio_tlmm_config(%#x)=%d\n",
1593 __func__, audio_fluid_icodec_tx_config, rc);
1594 }
1595 }
1596}
1597
1598void msm_snddev_poweramp_on(void)
1599{
1600 gpio_set_value(82, 1); /* enable spkr poweramp */
1601 pr_info("%s: power on amplifier\n", __func__);
1602}
1603
1604void msm_snddev_poweramp_off(void)
1605{
1606 gpio_set_value(82, 0); /* disable spkr poweramp */
1607 pr_info("%s: power off amplifier\n", __func__);
1608}
1609
Justin Paupore3f40f342011-08-10 18:52:16 -07001610static struct regulator_bulk_data snddev_regs[] = {
1611 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
1612 { .supply = "ncp", .min_uV = 1800000, .max_uV = 1800000 },
1613};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001614
Justin Paupore3f40f342011-08-10 18:52:16 -07001615static int __init snddev_hsed_voltage_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001616{
1617 int rc;
1618
Justin Paupore3f40f342011-08-10 18:52:16 -07001619 rc = regulator_bulk_get(NULL, ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001620
Justin Paupore3f40f342011-08-10 18:52:16 -07001621 if (rc) {
1622 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1623 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001624 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001625
1626 rc = regulator_bulk_set_voltage(ARRAY_SIZE(snddev_regs), snddev_regs);
1627
1628 if (rc) {
1629 pr_err("%s: could not set regulator voltages: %d\n",
1630 __func__, rc);
1631 goto regs_free;
1632 }
1633
1634 return 0;
1635
1636regs_free:
1637 regulator_bulk_free(ARRAY_SIZE(snddev_regs), snddev_regs);
1638out:
1639 return rc;
1640}
1641
1642
1643void msm_snddev_hsed_voltage_on(void)
1644{
1645 int rc = regulator_bulk_enable(ARRAY_SIZE(snddev_regs), snddev_regs);
1646
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001647 if (rc)
Justin Paupore3f40f342011-08-10 18:52:16 -07001648 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001649}
1650
1651void msm_snddev_hsed_voltage_off(void)
1652{
Justin Paupore3f40f342011-08-10 18:52:16 -07001653 int rc = regulator_bulk_disable(ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001654
Justin Paupore3f40f342011-08-10 18:52:16 -07001655 if (rc) {
1656 pr_err("%s: could not disable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001657 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001658}
1659
1660static unsigned aux_pcm_gpio_on[] = {
1661 GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
1662 GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
1663 GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
1664 GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
1665};
1666
1667static int __init aux_pcm_gpio_init(void)
1668{
1669 int pin, rc;
1670
1671 pr_info("aux_pcm_gpio_init \n");
1672 for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) {
1673 rc = gpio_tlmm_config(aux_pcm_gpio_on[pin],
1674 GPIO_CFG_ENABLE);
1675 if (rc) {
1676 printk(KERN_ERR
1677 "%s: gpio_tlmm_config(%#x)=%d\n",
1678 __func__, aux_pcm_gpio_on[pin], rc);
1679 }
1680 }
1681 return rc;
1682}
1683
1684static struct msm_gpio mi2s_clk_gpios[] = {
1685 { GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1686 "MI2S_SCLK"},
1687 { GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1688 "MI2S_WS"},
1689 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1690 "MI2S_MCLK_A"},
1691};
1692
1693static struct msm_gpio mi2s_rx_data_lines_gpios[] = {
1694 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1695 "MI2S_DATA_SD0_A"},
1696 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1697 "MI2S_DATA_SD1_A"},
1698 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1699 "MI2S_DATA_SD2_A"},
1700 { GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1701 "MI2S_DATA_SD3"},
1702};
1703
1704static struct msm_gpio mi2s_tx_data_lines_gpios[] = {
1705 { GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1706 "MI2S_DATA_SD3"},
1707};
1708
1709int mi2s_config_clk_gpio(void)
1710{
1711 int rc = 0;
1712
1713 rc = msm_gpios_request_enable(mi2s_clk_gpios,
1714 ARRAY_SIZE(mi2s_clk_gpios));
1715 if (rc) {
1716 pr_err("%s: enable mi2s clk gpios failed\n",
1717 __func__);
1718 return rc;
1719 }
1720 return 0;
1721}
1722
1723int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask)
1724{
1725 int i, rc = 0;
1726 sd_line_mask &= MI2S_SD_LINE_MASK;
1727
1728 switch (direction) {
1729 case DIR_TX:
1730 msm_gpios_disable_free(mi2s_tx_data_lines_gpios, 1);
1731 break;
1732 case DIR_RX:
1733 i = 0;
1734 while (sd_line_mask) {
1735 if (sd_line_mask & 0x1)
1736 msm_gpios_disable_free(
1737 mi2s_rx_data_lines_gpios + i , 1);
1738 sd_line_mask = sd_line_mask >> 1;
1739 i++;
1740 }
1741 break;
1742 default:
1743 pr_err("%s: Invaild direction direction = %u\n",
1744 __func__, direction);
1745 rc = -EINVAL;
1746 break;
1747 }
1748 return rc;
1749}
1750
1751int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask)
1752{
1753 int i , rc = 0;
1754 u8 sd_config_done_mask = 0;
1755
1756 sd_line_mask &= MI2S_SD_LINE_MASK;
1757
1758 switch (direction) {
1759 case DIR_TX:
1760 if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) ||
1761 (sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) {
1762 pr_err("%s: can not use SD0 or SD1 or SD2 for TX"
1763 ".only can use SD3. sd_line_mask = 0x%x\n",
1764 __func__ , sd_line_mask);
1765 rc = -EINVAL;
1766 } else {
1767 rc = msm_gpios_request_enable(mi2s_tx_data_lines_gpios,
1768 1);
1769 if (rc)
1770 pr_err("%s: enable mi2s gpios for TX failed\n",
1771 __func__);
1772 }
1773 break;
1774 case DIR_RX:
1775 i = 0;
1776 while (sd_line_mask && (rc == 0)) {
1777 if (sd_line_mask & 0x1) {
1778 rc = msm_gpios_request_enable(
1779 mi2s_rx_data_lines_gpios + i , 1);
1780 if (rc) {
1781 pr_err("%s: enable mi2s gpios for"
1782 "RX failed. SD line = %s\n",
1783 __func__,
1784 (mi2s_rx_data_lines_gpios + i)->label);
1785 mi2s_unconfig_data_gpio(DIR_RX,
1786 sd_config_done_mask);
1787 } else
1788 sd_config_done_mask |= (1 << i);
1789 }
1790 sd_line_mask = sd_line_mask >> 1;
1791 i++;
1792 }
1793 break;
1794 default:
1795 pr_err("%s: Invaild direction direction = %u\n",
1796 __func__, direction);
1797 rc = -EINVAL;
1798 break;
1799 }
1800 return rc;
1801}
1802
1803int mi2s_unconfig_clk_gpio(void)
1804{
1805 msm_gpios_disable_free(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios));
1806 return 0;
1807}
1808
1809#endif /* CONFIG_MSM7KV2_AUDIO */
1810
1811static int __init buses_init(void)
1812{
1813 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT,
1814 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
1815 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
1816 __func__, PMIC_GPIO_INT);
1817
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301818 if (machine_is_msm8x60_fluid())
1819 pm8058_7x30_data.keypad_pdata = &fluid_keypad_data;
1820 else
1821 pm8058_7x30_data.keypad_pdata = &surf_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001822
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001823 return 0;
1824}
1825
1826#define TIMPANI_RESET_GPIO 1
1827
1828struct bahama_config_register{
1829 u8 reg;
1830 u8 value;
1831 u8 mask;
1832};
1833
1834enum version{
1835 VER_1_0,
1836 VER_2_0,
1837 VER_UNSUPPORTED = 0xFF
1838};
1839
Justin Paupore3f40f342011-08-10 18:52:16 -07001840static struct regulator *vreg_marimba_1;
1841static struct regulator *vreg_marimba_2;
1842static struct regulator *vreg_bahama;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001843
1844static struct msm_gpio timpani_reset_gpio_cfg[] = {
1845{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
1846 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} };
1847
1848static u8 read_bahama_ver(void)
1849{
1850 int rc;
1851 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1852 u8 bahama_version;
1853
1854 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
1855 if (rc < 0) {
1856 printk(KERN_ERR
1857 "%s: version read failed: %d\n",
1858 __func__, rc);
1859 return rc;
1860 } else {
1861 printk(KERN_INFO
1862 "%s: version read got: 0x%x\n",
1863 __func__, bahama_version);
1864 }
1865
1866 switch (bahama_version) {
1867 case 0x08: /* varient of bahama v1 */
1868 case 0x10:
1869 case 0x00:
1870 return VER_1_0;
1871 case 0x09: /* variant of bahama v2 */
1872 return VER_2_0;
1873 default:
1874 return VER_UNSUPPORTED;
1875 }
1876}
1877
1878static int config_timpani_reset(void)
1879{
1880 int rc;
1881
1882 rc = msm_gpios_request_enable(timpani_reset_gpio_cfg,
1883 ARRAY_SIZE(timpani_reset_gpio_cfg));
1884 if (rc < 0) {
1885 printk(KERN_ERR
1886 "%s: msm_gpios_request_enable failed (%d)\n",
1887 __func__, rc);
1888 }
1889 return rc;
1890}
1891
1892static unsigned int msm_timpani_setup_power(void)
1893{
1894 int rc;
1895
1896 rc = config_timpani_reset();
1897 if (rc < 0)
1898 goto out;
1899
Justin Paupore3f40f342011-08-10 18:52:16 -07001900 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001901 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001902 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001903 goto out;
1904 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001905
1906 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001907 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001908 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1909 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001910 }
1911
1912 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1);
1913 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001914 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001915 __func__, rc);
1916 msm_gpios_free(timpani_reset_gpio_cfg,
1917 ARRAY_SIZE(timpani_reset_gpio_cfg));
Justin Paupore3f40f342011-08-10 18:52:16 -07001918 goto disable_marimba_2;
1919 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001920
Justin Paupore3f40f342011-08-10 18:52:16 -07001921 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001922
Justin Paupore3f40f342011-08-10 18:52:16 -07001923disable_marimba_2:
1924 regulator_disable(vreg_marimba_2);
1925disable_marimba_1:
1926 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001927out:
1928 return rc;
1929};
1930
1931static void msm_timpani_shutdown_power(void)
1932{
1933 int rc;
1934
Justin Paupore3f40f342011-08-10 18:52:16 -07001935 rc = regulator_disable(vreg_marimba_2);
1936 if (rc)
1937 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1938
1939 rc = regulator_disable(vreg_marimba_1);
1940 if (rc)
1941 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001942
1943 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0);
Justin Paupore3f40f342011-08-10 18:52:16 -07001944 if (rc < 0)
1945 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001946 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001947
1948 msm_gpios_free(timpani_reset_gpio_cfg,
1949 ARRAY_SIZE(timpani_reset_gpio_cfg));
1950};
1951
1952static unsigned int msm_bahama_core_config(int type)
1953{
1954 int rc = 0;
1955
1956 if (type == BAHAMA_ID) {
1957
1958 int i;
1959 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1960
1961 const struct bahama_config_register v20_init[] = {
1962 /* reg, value, mask */
1963 { 0xF4, 0x84, 0xFF }, /* AREG */
1964 { 0xF0, 0x04, 0xFF } /* DREG */
1965 };
1966
1967 if (read_bahama_ver() == VER_2_0) {
1968 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
1969 u8 value = v20_init[i].value;
1970 rc = marimba_write_bit_mask(&config,
1971 v20_init[i].reg,
1972 &value,
1973 sizeof(v20_init[i].value),
1974 v20_init[i].mask);
1975 if (rc < 0) {
1976 printk(KERN_ERR
1977 "%s: reg %d write failed: %d\n",
1978 __func__, v20_init[i].reg, rc);
1979 return rc;
1980 }
1981 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
1982 " mask 0x%02x\n",
1983 __func__, v20_init[i].reg,
1984 v20_init[i].value, v20_init[i].mask);
1985 }
1986 }
1987 }
1988 printk(KERN_INFO "core type: %d\n", type);
1989
1990 return rc;
1991}
1992
1993static unsigned int msm_bahama_setup_power(void)
1994{
Justin Paupore3f40f342011-08-10 18:52:16 -07001995 int rc = regulator_enable(vreg_bahama);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001996
Justin Paupore3f40f342011-08-10 18:52:16 -07001997 if (rc)
1998 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001999
2000 return rc;
2001};
2002
2003static unsigned int msm_bahama_shutdown_power(int value)
2004{
2005 int rc = 0;
2006
2007 if (value != BAHAMA_ID) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002008 rc = regulator_disable(vreg_bahama);
2009
2010 if (rc)
2011 pr_err("%s: regulator_disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002012 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002013 }
2014
2015 return rc;
2016};
2017
2018static struct msm_gpio marimba_svlte_config_clock[] = {
2019 { GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2020 "MARIMBA_SVLTE_CLOCK_ENABLE" },
2021};
2022
2023static unsigned int msm_marimba_gpio_config_svlte(int gpio_cfg_marimba)
2024{
2025 if (machine_is_msm8x55_svlte_surf() ||
2026 machine_is_msm8x55_svlte_ffa()) {
2027 if (gpio_cfg_marimba)
2028 gpio_set_value(GPIO_PIN
2029 (marimba_svlte_config_clock->gpio_cfg), 1);
2030 else
2031 gpio_set_value(GPIO_PIN
2032 (marimba_svlte_config_clock->gpio_cfg), 0);
2033 }
2034
2035 return 0;
2036};
2037
2038static unsigned int msm_marimba_setup_power(void)
2039{
2040 int rc;
2041
Justin Paupore3f40f342011-08-10 18:52:16 -07002042 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002043 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002044 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002045 goto out;
2046 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002047
2048 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002049 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002050 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2051 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002052 }
2053
2054 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
2055 rc = msm_gpios_request_enable(marimba_svlte_config_clock,
2056 ARRAY_SIZE(marimba_svlte_config_clock));
2057 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002058 pr_err("%s: msm_gpios_request_enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002059 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002060 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002061 }
2062
2063 rc = gpio_direction_output(GPIO_PIN
2064 (marimba_svlte_config_clock->gpio_cfg), 0);
2065 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002066 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002067 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002068 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002069 }
2070 }
2071
Justin Paupore3f40f342011-08-10 18:52:16 -07002072 return 0;
2073
2074disable_marimba_2:
2075 regulator_disable(vreg_marimba_2);
2076disable_marimba_1:
2077 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002078out:
2079 return rc;
2080};
2081
2082static void msm_marimba_shutdown_power(void)
2083{
2084 int rc;
2085
Justin Paupore3f40f342011-08-10 18:52:16 -07002086 rc = regulator_disable(vreg_marimba_2);
2087 if (rc)
2088 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
2089
2090 rc = regulator_disable(vreg_marimba_1);
2091 if (rc)
2092 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002093};
2094
2095static int bahama_present(void)
2096{
2097 int id;
2098 switch (id = adie_get_detected_connectivity_type()) {
2099 case BAHAMA_ID:
2100 return 1;
2101
2102 case MARIMBA_ID:
2103 return 0;
2104
2105 case TIMPANI_ID:
2106 default:
2107 printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n",
2108 __func__, id);
2109 return -ENODEV;
2110 }
2111}
2112
Justin Paupore3f40f342011-08-10 18:52:16 -07002113struct regulator *fm_regulator;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002114static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
2115{
Justin Paupore3f40f342011-08-10 18:52:16 -07002116 int rc, voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002117 uint32_t irqcfg;
2118 const char *id = "FMPW";
2119
2120 int bahama_not_marimba = bahama_present();
2121
Justin Paupore3f40f342011-08-10 18:52:16 -07002122 if (bahama_not_marimba < 0) {
2123 pr_warn("%s: bahama_present: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002124 __func__, bahama_not_marimba);
Justin Paupore3f40f342011-08-10 18:52:16 -07002125 rc = -ENODEV;
2126 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002127 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002128 if (bahama_not_marimba) {
2129 fm_regulator = regulator_get(NULL, "s3");
2130 voltage = 1800000;
2131 } else {
2132 fm_regulator = regulator_get(NULL, "s2");
2133 voltage = 1300000;
2134 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002135
2136 if (IS_ERR(fm_regulator)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002137 rc = PTR_ERR(fm_regulator);
2138 pr_err("%s: regulator_get failed (%d)\n", __func__, rc);
2139 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002140 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002141
Justin Paupore3f40f342011-08-10 18:52:16 -07002142 rc = regulator_set_voltage(fm_regulator, voltage, voltage);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002143
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002144 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002145 pr_err("%s: regulator_set_voltage failed (%d)\n", __func__, rc);
2146 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002147 }
2148
Justin Paupore3f40f342011-08-10 18:52:16 -07002149 rc = regulator_enable(fm_regulator);
2150
2151 if (rc) {
2152 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2153 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002154 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002155
2156 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_ON);
2157
2158 if (rc < 0) {
2159 pr_err("%s: clock vote failed (%d)\n", __func__, rc);
2160 goto regulator_disable;
2161 }
2162
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002163 /*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2164 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002165 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002166 rc = marimba_gpio_config(1);
Justin Paupore3f40f342011-08-10 18:52:16 -07002167 if (rc < 0) {
2168 pr_err("%s: clock enable for svlte : %d\n",
2169 __func__, rc);
2170 goto clock_devote;
2171 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002172 }
2173 irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
2174 GPIO_CFG_2MA);
2175 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2176 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002177 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002178 rc = -EIO;
Justin Paupore3f40f342011-08-10 18:52:16 -07002179 goto gpio_deconfig;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002180
2181 }
2182 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002183
Justin Paupore3f40f342011-08-10 18:52:16 -07002184gpio_deconfig:
2185 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa())
2186 marimba_gpio_config(0);
2187clock_devote:
2188 pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_OFF);
2189regulator_disable:
2190 regulator_disable(fm_regulator);
2191regulator_free:
2192 regulator_put(fm_regulator);
2193 fm_regulator = NULL;
2194out:
2195 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002196};
2197
2198static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
2199{
2200 int rc;
2201 const char *id = "FMPW";
2202 uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
2203 GPIO_CFG_2MA);
2204
2205 int bahama_not_marimba = bahama_present();
2206 if (bahama_not_marimba == -1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002207 pr_warn("%s: bahama_present: %d\n",
2208 __func__, bahama_not_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002209 return;
2210 }
2211
2212 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2213 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002214 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002215 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002216 if (!IS_ERR_OR_NULL(fm_regulator)) {
2217 rc = regulator_disable(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002218
Justin Paupore3f40f342011-08-10 18:52:16 -07002219 if (rc)
2220 pr_err("%s: return val: %d\n", __func__, rc);
2221
2222 regulator_put(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002223 fm_regulator = NULL;
2224 }
2225 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
2226 PMAPP_CLOCK_VOTE_OFF);
2227 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002228 pr_err("%s: clock_vote return val: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002229
2230 /*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2231 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002232 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002233 rc = marimba_gpio_config(0);
2234 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002235 pr_err("%s: clock disable for svlte : %d\n",
2236 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002237 }
2238}
2239
2240static struct marimba_fm_platform_data marimba_fm_pdata = {
2241 .fm_setup = fm_radio_setup,
2242 .fm_shutdown = fm_radio_shutdown,
2243 .irq = MSM_GPIO_TO_INT(147),
2244 .vreg_s2 = NULL,
2245 .vreg_xo_out = NULL,
2246 .is_fm_soc_i2s_master = false,
2247 .config_i2s_gpio = NULL,
2248};
2249
2250
2251/* Slave id address for FM/CDC/QMEMBIST
2252 * Values can be programmed using Marimba slave id 0
2253 * should there be a conflict with other I2C devices
2254 * */
2255#define MARIMBA_SLAVE_ID_FM_ADDR 0x2A
2256#define MARIMBA_SLAVE_ID_CDC_ADDR 0x77
2257#define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66
2258
2259#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
2260#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
2261
2262static const char *tsadc_id = "MADC";
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002263
Justin Paupore3f40f342011-08-10 18:52:16 -07002264static struct regulator_bulk_data regs_tsadc_marimba[] = {
2265 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2266 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002267};
Justin Paupore3f40f342011-08-10 18:52:16 -07002268
2269static struct regulator_bulk_data regs_tsadc_timpani[] = {
2270 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2271 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2272 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2273};
2274
2275static struct regulator_bulk_data *regs_tsadc;
2276static int regs_tsadc_count;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002277
2278static int marimba_tsadc_power(int vreg_on)
2279{
Justin Paupore3f40f342011-08-10 18:52:16 -07002280 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002281 int tsadc_adie_type = adie_get_detected_codec_type();
2282
Justin Paupore3f40f342011-08-10 18:52:16 -07002283 switch (tsadc_adie_type) {
2284 case TIMPANI_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002285 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2286 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2287 if (rc) {
2288 pr_err("%s: unable to %svote for d1 clk\n",
2289 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002290 goto D1_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002291 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002292
2293 /* fall through */
2294 case MARIMBA_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002295 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2296 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2297 if (rc) {
2298 pr_err("%s: unable to %svote for d1 clk\n",
2299 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002300 goto D0_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002301 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002302
Justin Paupore3f40f342011-08-10 18:52:16 -07002303 WARN_ON(regs_tsadc_count == 0);
2304
2305 rc = vreg_on ?
2306 regulator_bulk_enable(regs_tsadc_count, regs_tsadc) :
2307 regulator_bulk_disable(regs_tsadc_count, regs_tsadc);
2308
2309 if (rc) {
2310 pr_err("%s: regulator %sable failed: %d\n",
2311 __func__, vreg_on ? "en" : "dis", rc);
2312 goto regulator_switch_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002313 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002314
2315 break;
2316 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002317 pr_err("%s:Adie %d not supported\n",
2318 __func__, tsadc_adie_type);
2319 return -ENODEV;
2320 }
2321
2322 msleep(5); /* ensure power is stable */
2323
2324 return 0;
2325
Justin Paupore3f40f342011-08-10 18:52:16 -07002326regulator_switch_fail:
2327 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2328 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2329D0_vote_fail:
2330 if (tsadc_adie_type == TIMPANI_ID)
2331 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2332 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2333D1_vote_fail:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002334 return rc;
2335}
2336
2337static int marimba_tsadc_init(void)
2338{
Justin Paupore3f40f342011-08-10 18:52:16 -07002339 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002340 int tsadc_adie_type = adie_get_detected_codec_type();
2341
Justin Paupore3f40f342011-08-10 18:52:16 -07002342 switch (tsadc_adie_type) {
2343 case MARIMBA_ID:
2344 regs_tsadc = regs_tsadc_marimba;
2345 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_marimba);
2346 break;
2347 case TIMPANI_ID:
2348 regs_tsadc = regs_tsadc_timpani;
2349 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_timpani);
2350 break;
2351 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002352 pr_err("%s:Adie %d not supported\n",
2353 __func__, tsadc_adie_type);
Justin Paupore3f40f342011-08-10 18:52:16 -07002354 rc = -ENODEV;
2355 goto out;
2356 }
2357
2358 rc = regulator_bulk_get(NULL, regs_tsadc_count, regs_tsadc);
2359 if (rc) {
2360 pr_err("%s: could not get regulators: %d\n",
2361 __func__, rc);
2362 goto out;
2363 }
2364
2365 rc = regulator_bulk_set_voltage(regs_tsadc_count, regs_tsadc);
2366 if (rc) {
2367 pr_err("%s: could not set regulator voltages: %d\n",
2368 __func__, rc);
2369 goto vreg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002370 }
2371
2372 return 0;
2373
Justin Paupore3f40f342011-08-10 18:52:16 -07002374vreg_free:
2375 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2376out:
2377 regs_tsadc = NULL;
2378 regs_tsadc_count = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002379 return rc;
2380}
2381
2382static int marimba_tsadc_exit(void)
2383{
Justin Paupore3f40f342011-08-10 18:52:16 -07002384 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2385 regs_tsadc_count = 0;
2386 regs_tsadc = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002387
Justin Paupore3f40f342011-08-10 18:52:16 -07002388 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002389}
2390
2391
2392static struct msm_ts_platform_data msm_ts_data = {
Anirudh Ghayal82b74722012-01-19 15:35:34 +05302393 .min_x = 284,
2394 .max_x = 3801,
2395 .min_y = 155,
2396 .max_y = 3929,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002397 .min_press = 0,
2398 .max_press = 255,
2399 .inv_x = 4096,
2400 .inv_y = 4096,
2401 .can_wakeup = false,
2402};
2403
2404static struct marimba_tsadc_platform_data marimba_tsadc_pdata = {
2405 .marimba_tsadc_power = marimba_tsadc_power,
2406 .init = marimba_tsadc_init,
2407 .exit = marimba_tsadc_exit,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002408 .tsadc_prechg_en = true,
2409 .can_wakeup = false,
2410 .setup = {
2411 .pen_irq_en = true,
2412 .tsadc_en = true,
2413 },
2414 .params2 = {
2415 .input_clk_khz = 2400,
2416 .sample_prd = TSADC_CLK_3,
2417 },
2418 .params3 = {
2419 .prechg_time_nsecs = 6400,
2420 .stable_time_nsecs = 6400,
2421 .tsadc_test_mode = 0,
2422 },
2423 .tssc_data = &msm_ts_data,
2424};
2425
Justin Paupore3f40f342011-08-10 18:52:16 -07002426static struct regulator_bulk_data codec_regs[] = {
2427 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
2428};
2429
2430static int __init msm_marimba_codec_init(void)
2431{
2432 int rc = regulator_bulk_get(NULL, ARRAY_SIZE(codec_regs), codec_regs);
2433
2434 if (rc) {
2435 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2436 goto out;
2437 }
2438
2439 rc = regulator_bulk_set_voltage(ARRAY_SIZE(codec_regs), codec_regs);
2440 if (rc) {
2441 pr_err("%s: could not set regulator voltages: %d\n",
2442 __func__, rc);
2443 goto reg_free;
2444 }
2445
2446 return rc;
2447
2448reg_free:
2449 regulator_bulk_free(ARRAY_SIZE(codec_regs), codec_regs);
2450out:
2451 return rc;
2452}
2453
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002454static int msm_marimba_codec_power(int vreg_on)
2455{
Justin Paupore3f40f342011-08-10 18:52:16 -07002456 int rc = vreg_on ?
2457 regulator_bulk_enable(ARRAY_SIZE(codec_regs), codec_regs) :
2458 regulator_bulk_disable(ARRAY_SIZE(codec_regs), codec_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002459
Justin Paupore3f40f342011-08-10 18:52:16 -07002460 if (rc) {
2461 pr_err("%s: could not %sable regulators: %d",
2462 __func__, vreg_on ? "en" : "dis", rc);
2463 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002464 }
2465
Justin Paupore3f40f342011-08-10 18:52:16 -07002466 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002467}
2468
2469static struct marimba_codec_platform_data mariba_codec_pdata = {
2470 .marimba_codec_power = msm_marimba_codec_power,
2471#ifdef CONFIG_MARIMBA_CODEC
2472 .snddev_profile_init = msm_snddev_init,
2473#endif
2474};
2475
2476static struct marimba_platform_data marimba_pdata = {
2477 .slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR,
2478 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2479 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2480 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
2481 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
2482 .marimba_setup = msm_marimba_setup_power,
2483 .marimba_shutdown = msm_marimba_shutdown_power,
2484 .bahama_setup = msm_bahama_setup_power,
2485 .bahama_shutdown = msm_bahama_shutdown_power,
2486 .marimba_gpio_config = msm_marimba_gpio_config_svlte,
2487 .bahama_core_config = msm_bahama_core_config,
2488 .fm = &marimba_fm_pdata,
2489 .codec = &mariba_codec_pdata,
2490 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2491};
2492
2493static void __init msm7x30_init_marimba(void)
2494{
2495 int rc;
2496
Justin Paupore3f40f342011-08-10 18:52:16 -07002497 struct regulator_bulk_data regs[] = {
2498 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2499 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2500 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
2501 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002502
Justin Paupore3f40f342011-08-10 18:52:16 -07002503 rc = msm_marimba_codec_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002504
Justin Paupore3f40f342011-08-10 18:52:16 -07002505 if (rc) {
2506 pr_err("%s: msm_marimba_codec_init failed (%d)\n",
2507 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002508 return;
2509 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002510
2511 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
2512
2513 if (rc) {
2514 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2515 return;
2516 }
2517
2518 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
2519
2520 if (rc) {
2521 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2522 regulator_bulk_free(ARRAY_SIZE(regs), regs);
2523 return;
2524 }
2525
2526 vreg_marimba_1 = regs[0].consumer;
2527 vreg_marimba_2 = regs[1].consumer;
2528 vreg_bahama = regs[2].consumer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002529}
2530
2531static struct marimba_codec_platform_data timpani_codec_pdata = {
2532 .marimba_codec_power = msm_marimba_codec_power,
2533#ifdef CONFIG_TIMPANI_CODEC
2534 .snddev_profile_init = msm_snddev_init_timpani,
2535#endif
2536};
2537
2538static struct marimba_platform_data timpani_pdata = {
2539 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2540 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2541 .marimba_setup = msm_timpani_setup_power,
2542 .marimba_shutdown = msm_timpani_shutdown_power,
2543 .codec = &timpani_codec_pdata,
2544 .tsadc = &marimba_tsadc_pdata,
2545 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2546};
2547
2548#define TIMPANI_I2C_SLAVE_ADDR 0xD
2549
2550static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
2551 {
2552 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
2553 .platform_data = &timpani_pdata,
2554 },
2555};
2556
2557#ifdef CONFIG_MSM7KV2_AUDIO
2558static struct resource msm_aictl_resources[] = {
2559 {
2560 .name = "aictl",
2561 .start = 0xa5000100,
2562 .end = 0xa5000100,
2563 .flags = IORESOURCE_MEM,
2564 }
2565};
2566
2567static struct resource msm_mi2s_resources[] = {
2568 {
2569 .name = "hdmi",
2570 .start = 0xac900000,
2571 .end = 0xac900038,
2572 .flags = IORESOURCE_MEM,
2573 },
2574 {
2575 .name = "codec_rx",
2576 .start = 0xac940040,
2577 .end = 0xac940078,
2578 .flags = IORESOURCE_MEM,
2579 },
2580 {
2581 .name = "codec_tx",
2582 .start = 0xac980080,
2583 .end = 0xac9800B8,
2584 .flags = IORESOURCE_MEM,
2585 }
2586
2587};
2588
2589static struct msm_lpa_platform_data lpa_pdata = {
2590 .obuf_hlb_size = 0x2BFF8,
2591 .dsp_proc_id = 0,
2592 .app_proc_id = 2,
2593 .nosb_config = {
2594 .llb_min_addr = 0,
2595 .llb_max_addr = 0x3ff8,
2596 .sb_min_addr = 0,
2597 .sb_max_addr = 0,
2598 },
2599 .sb_config = {
2600 .llb_min_addr = 0,
2601 .llb_max_addr = 0x37f8,
2602 .sb_min_addr = 0x3800,
2603 .sb_max_addr = 0x3ff8,
2604 }
2605};
2606
2607static struct resource msm_lpa_resources[] = {
2608 {
2609 .name = "lpa",
2610 .start = 0xa5000000,
2611 .end = 0xa50000a0,
2612 .flags = IORESOURCE_MEM,
2613 }
2614};
2615
2616static struct resource msm_aux_pcm_resources[] = {
2617
2618 {
2619 .name = "aux_codec_reg_addr",
2620 .start = 0xac9c00c0,
2621 .end = 0xac9c00c8,
2622 .flags = IORESOURCE_MEM,
2623 },
2624 {
2625 .name = "aux_pcm_dout",
2626 .start = 138,
2627 .end = 138,
2628 .flags = IORESOURCE_IO,
2629 },
2630 {
2631 .name = "aux_pcm_din",
2632 .start = 139,
2633 .end = 139,
2634 .flags = IORESOURCE_IO,
2635 },
2636 {
2637 .name = "aux_pcm_syncout",
2638 .start = 140,
2639 .end = 140,
2640 .flags = IORESOURCE_IO,
2641 },
2642 {
2643 .name = "aux_pcm_clkin_a",
2644 .start = 141,
2645 .end = 141,
2646 .flags = IORESOURCE_IO,
2647 },
2648};
2649
2650static struct platform_device msm_aux_pcm_device = {
2651 .name = "msm_aux_pcm",
2652 .id = 0,
2653 .num_resources = ARRAY_SIZE(msm_aux_pcm_resources),
2654 .resource = msm_aux_pcm_resources,
2655};
2656
2657struct platform_device msm_aictl_device = {
2658 .name = "audio_interct",
2659 .id = 0,
2660 .num_resources = ARRAY_SIZE(msm_aictl_resources),
2661 .resource = msm_aictl_resources,
2662};
2663
2664struct platform_device msm_mi2s_device = {
2665 .name = "mi2s",
2666 .id = 0,
2667 .num_resources = ARRAY_SIZE(msm_mi2s_resources),
2668 .resource = msm_mi2s_resources,
2669};
2670
2671struct platform_device msm_lpa_device = {
2672 .name = "lpa",
2673 .id = 0,
2674 .num_resources = ARRAY_SIZE(msm_lpa_resources),
2675 .resource = msm_lpa_resources,
2676 .dev = {
2677 .platform_data = &lpa_pdata,
2678 },
2679};
2680#endif /* CONFIG_MSM7KV2_AUDIO */
2681
2682#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2683 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2684 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2685 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2686 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2687 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2688#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2689 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2690 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2691 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2692 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2693 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2694 #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2695 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2696 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2697 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2698 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2699 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2700 #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2701 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2702 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2703 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2704 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2705 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2706#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
2707
2708static unsigned int dec_concurrency_table[] = {
2709 /* Audio LP */
2710 0,
2711 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2712 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2713 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2714 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)|
2715 (1<<MSM_ADSP_OP_DM)),
2716
2717 /* Concurrency 1 */
2718 (DEC4_FORMAT),
2719 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2720 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2721 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2722 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2723
2724 /* Concurrency 2 */
2725 (DEC4_FORMAT),
2726 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2727 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2728 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2729 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2730
2731 /* Concurrency 3 */
2732 (DEC4_FORMAT),
2733 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2734 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2735 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2736 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2737
2738 /* Concurrency 4 */
2739 (DEC4_FORMAT),
2740 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2741 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2742 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2743 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2744
2745 /* Concurrency 5 */
2746 (DEC4_FORMAT),
2747 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2748 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2749 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2750 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2751
2752 /* Concurrency 6 */
2753 (DEC4_FORMAT),
2754 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2755 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2756 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2757 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2758};
2759
2760#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
2761 .module_queueid = queueid, .module_decid = decid, \
2762 .nr_codec_support = nr_codec}
2763
2764#define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
2765 .max_instances_same_dec = max_instance_same, \
2766 .max_instances_diff_dec = max_instance_diff}
2767
2768static struct msm_adspdec_info dec_info_list[] = {
2769 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
2770 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
2771 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
2772 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
2773 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
2774};
2775
2776static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
2777 /* Non Turbo Mode */
2778 {
2779 DEC_INSTANCE(4, 3), /* WAV */
2780 DEC_INSTANCE(4, 3), /* ADPCM */
2781 DEC_INSTANCE(4, 2), /* MP3 */
2782 DEC_INSTANCE(0, 0), /* Real Audio */
2783 DEC_INSTANCE(4, 2), /* WMA */
2784 DEC_INSTANCE(3, 2), /* AAC */
2785 DEC_INSTANCE(0, 0), /* Reserved */
2786 DEC_INSTANCE(0, 0), /* MIDI */
2787 DEC_INSTANCE(4, 3), /* YADPCM */
2788 DEC_INSTANCE(4, 3), /* QCELP */
2789 DEC_INSTANCE(4, 3), /* AMRNB */
2790 DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
2791 DEC_INSTANCE(4, 3), /* EVRC */
2792 DEC_INSTANCE(1, 1), /* WMAPRO */
2793 },
2794 /* Turbo Mode */
2795 {
2796 DEC_INSTANCE(4, 3), /* WAV */
2797 DEC_INSTANCE(4, 3), /* ADPCM */
2798 DEC_INSTANCE(4, 3), /* MP3 */
2799 DEC_INSTANCE(0, 0), /* Real Audio */
2800 DEC_INSTANCE(4, 3), /* WMA */
2801 DEC_INSTANCE(4, 3), /* AAC */
2802 DEC_INSTANCE(0, 0), /* Reserved */
2803 DEC_INSTANCE(0, 0), /* MIDI */
2804 DEC_INSTANCE(4, 3), /* YADPCM */
2805 DEC_INSTANCE(4, 3), /* QCELP */
2806 DEC_INSTANCE(4, 3), /* AMRNB */
2807 DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
2808 DEC_INSTANCE(4, 3), /* EVRC */
2809 DEC_INSTANCE(1, 2), /* WMAPRO */
2810 },
2811};
2812
2813static struct msm_adspdec_database msm_device_adspdec_database = {
2814 .num_dec = ARRAY_SIZE(dec_info_list),
2815 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
2816 ARRAY_SIZE(dec_info_list)),
2817 .dec_concurrency_table = dec_concurrency_table,
2818 .dec_info_list = dec_info_list,
2819 .dec_instance_list = &dec_instance_list[0][0],
2820};
2821
2822static struct platform_device msm_device_adspdec = {
2823 .name = "msm_adspdec",
2824 .id = -1,
2825 .dev = {
2826 .platform_data = &msm_device_adspdec_database
2827 },
2828};
2829
2830static struct resource smc91x_resources[] = {
2831 [0] = {
2832 .start = 0x8A000300,
2833 .end = 0x8A0003ff,
2834 .flags = IORESOURCE_MEM,
2835 },
2836 [1] = {
2837 .start = MSM_GPIO_TO_INT(156),
2838 .end = MSM_GPIO_TO_INT(156),
2839 .flags = IORESOURCE_IRQ,
2840 },
2841};
2842
2843static struct platform_device smc91x_device = {
2844 .name = "smc91x",
2845 .id = 0,
2846 .num_resources = ARRAY_SIZE(smc91x_resources),
2847 .resource = smc91x_resources,
2848};
2849
2850static struct smsc911x_platform_config smsc911x_config = {
2851 .phy_interface = PHY_INTERFACE_MODE_MII,
2852 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
2853 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
2854 .flags = SMSC911X_USE_32BIT,
2855};
2856
2857static struct resource smsc911x_resources[] = {
2858 [0] = {
2859 .start = 0x8D000000,
2860 .end = 0x8D000100,
2861 .flags = IORESOURCE_MEM,
2862 },
2863 [1] = {
2864 .start = MSM_GPIO_TO_INT(88),
2865 .end = MSM_GPIO_TO_INT(88),
2866 .flags = IORESOURCE_IRQ,
2867 },
2868};
2869
2870static struct platform_device smsc911x_device = {
2871 .name = "smsc911x",
2872 .id = -1,
2873 .num_resources = ARRAY_SIZE(smsc911x_resources),
2874 .resource = smsc911x_resources,
2875 .dev = {
2876 .platform_data = &smsc911x_config,
2877 },
2878};
2879
2880static struct msm_gpio smsc911x_gpios[] = {
2881 { GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" },
2882 { GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" },
2883 { GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" },
2884 { GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" },
2885 { GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" },
2886 { GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" },
2887 { GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" },
2888 { GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" },
2889};
2890
2891static void msm7x30_cfg_smsc911x(void)
2892{
2893 int rc;
2894
2895 rc = msm_gpios_request_enable(smsc911x_gpios,
2896 ARRAY_SIZE(smsc911x_gpios));
2897 if (rc)
2898 pr_err("%s: unable to enable gpios\n", __func__);
2899}
2900
2901#ifdef CONFIG_USB_G_ANDROID
2902static struct android_usb_platform_data android_usb_pdata = {
2903 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2904};
2905
2906static struct platform_device android_usb_device = {
2907 .name = "android_usb",
2908 .id = -1,
2909 .dev = {
2910 .platform_data = &android_usb_pdata,
2911 },
2912};
2913#endif
2914
2915static struct msm_gpio optnav_config_data[] = {
2916 { GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA),
2917 "optnav_chip_select" },
2918};
2919
Justin Paupore3f40f342011-08-10 18:52:16 -07002920static struct regulator_bulk_data optnav_regulators[] = {
2921 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2922 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
2923 { .supply = "gp9", .min_uV = 1800000, .max_uV = 1800000 },
2924 { .supply = "usb", .min_uV = 3300000, .max_uV = 3300000 },
2925};
2926
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002927static void __iomem *virtual_optnav;
2928
2929static int optnav_gpio_setup(void)
2930{
2931 int rc = -ENODEV;
2932 rc = msm_gpios_request_enable(optnav_config_data,
2933 ARRAY_SIZE(optnav_config_data));
2934
Justin Paupore3f40f342011-08-10 18:52:16 -07002935 if (rc)
2936 return rc;
2937
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002938 /* Configure the FPGA for GPIOs */
2939 virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4);
2940 if (!virtual_optnav) {
2941 pr_err("%s:Could not ioremap region\n", __func__);
2942 return -ENOMEM;
2943 }
2944 /*
2945 * Configure the FPGA to set GPIO 19 as
2946 * normal, active(enabled), output(MSM to SURF)
2947 */
2948 writew(0x311E, virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002949
2950 rc = regulator_bulk_get(NULL, ARRAY_SIZE(optnav_regulators),
2951 optnav_regulators);
2952 if (rc)
2953 return rc;
2954
2955 rc = regulator_bulk_set_voltage(ARRAY_SIZE(optnav_regulators),
2956 optnav_regulators);
2957
2958 if (rc)
2959 goto regulator_put;
2960
2961 return rc;
2962
2963regulator_put:
2964 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002965 return rc;
2966}
2967
2968static void optnav_gpio_release(void)
2969{
2970 msm_gpios_disable_free(optnav_config_data,
2971 ARRAY_SIZE(optnav_config_data));
2972 iounmap(virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002973 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002974}
2975
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002976static int optnav_enable(void)
2977{
2978 int rc;
2979 /*
2980 * Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
2981 * for I2C communication with keyboard.
2982 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002983
Justin Paupore3f40f342011-08-10 18:52:16 -07002984 rc = regulator_bulk_enable(ARRAY_SIZE(optnav_regulators),
2985 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002986
Justin Paupore3f40f342011-08-10 18:52:16 -07002987 if (rc)
2988 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002989
2990 /* Enable the chip select GPIO */
2991 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2992 gpio_set_value(OPTNAV_CHIP_SELECT, 0);
2993
2994 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002995}
2996
2997static void optnav_disable(void)
2998{
Justin Paupore3f40f342011-08-10 18:52:16 -07002999 regulator_bulk_disable(ARRAY_SIZE(optnav_regulators),
3000 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003001
3002 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
3003}
3004
3005static struct ofn_atlab_platform_data optnav_data = {
3006 .gpio_setup = optnav_gpio_setup,
3007 .gpio_release = optnav_gpio_release,
3008 .optnav_on = optnav_enable,
3009 .optnav_off = optnav_disable,
3010 .rotate_xy = 0,
3011 .function1 = {
3012 .no_motion1_en = true,
3013 .touch_sensor_en = true,
3014 .ofn_en = true,
3015 .clock_select_khz = 1500,
3016 .cpi_selection = 1200,
3017 },
3018 .function2 = {
3019 .invert_y = false,
3020 .invert_x = true,
3021 .swap_x_y = false,
3022 .hold_a_b_en = true,
3023 .motion_filter_en = true,
3024 },
3025};
3026
3027static int hdmi_comm_power(int on, int show);
3028static int hdmi_init_irq(void);
3029static int hdmi_enable_5v(int on);
3030static int hdmi_core_power(int on, int show);
3031static int hdmi_cec_power(int on);
3032static bool hdmi_check_hdcp_hw_support(void);
3033
3034static struct msm_hdmi_platform_data adv7520_hdmi_data = {
3035 .irq = MSM_GPIO_TO_INT(18),
3036 .comm_power = hdmi_comm_power,
3037 .init_irq = hdmi_init_irq,
3038 .enable_5v = hdmi_enable_5v,
3039 .core_power = hdmi_core_power,
3040 .cec_power = hdmi_cec_power,
3041 .check_hdcp_hw_support = hdmi_check_hdcp_hw_support,
3042};
3043
3044#ifdef CONFIG_BOSCH_BMA150
Justin Paupore3f40f342011-08-10 18:52:16 -07003045
3046static struct regulator_bulk_data sensors_ldo[] = {
3047 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
3048 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
3049};
3050
3051static int __init sensors_ldo_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003052{
3053 int rc;
3054
Justin Paupore3f40f342011-08-10 18:52:16 -07003055 rc = regulator_bulk_get(NULL, ARRAY_SIZE(sensors_ldo), sensors_ldo);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003056
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003057 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003058 pr_err("%s: could not get regulators: %d\n", __func__, rc);
3059 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003060 }
3061
Justin Paupore3f40f342011-08-10 18:52:16 -07003062 rc = regulator_bulk_set_voltage(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3063
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003064 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003065 pr_err("%s: could not set voltages: %d\n", __func__, rc);
3066 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003067 }
3068
3069 return 0;
3070
Justin Paupore3f40f342011-08-10 18:52:16 -07003071reg_free:
3072 regulator_bulk_free(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3073out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003074 return rc;
3075}
3076
Justin Paupore3f40f342011-08-10 18:52:16 -07003077static int sensors_ldo_set(int on)
3078{
3079 int rc = on ?
3080 regulator_bulk_enable(ARRAY_SIZE(sensors_ldo), sensors_ldo) :
3081 regulator_bulk_disable(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3082
3083 if (rc)
3084 pr_err("%s: could not %sable regulators: %d\n",
3085 __func__, on ? "en" : "dis", rc);
3086
3087 return rc;
3088}
3089
3090static int sensors_ldo_enable(void)
3091{
3092 return sensors_ldo_set(1);
3093}
3094
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003095static void sensors_ldo_disable(void)
3096{
Justin Paupore3f40f342011-08-10 18:52:16 -07003097 sensors_ldo_set(0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003098}
Justin Paupore3f40f342011-08-10 18:52:16 -07003099
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003100static struct bma150_platform_data bma150_data = {
3101 .power_on = sensors_ldo_enable,
3102 .power_off = sensors_ldo_disable,
3103};
3104
3105static struct i2c_board_info bma150_board_info[] __initdata = {
3106 {
3107 I2C_BOARD_INFO("bma150", 0x38),
3108 .flags = I2C_CLIENT_WAKE,
3109 .irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
3110 .platform_data = &bma150_data,
3111 },
3112};
3113#endif
3114
3115static struct i2c_board_info msm_i2c_board_info[] = {
3116 {
3117 I2C_BOARD_INFO("m33c01", OPTNAV_I2C_SLAVE_ADDR),
3118 .irq = MSM_GPIO_TO_INT(OPTNAV_IRQ),
3119 .platform_data = &optnav_data,
3120 },
3121 {
3122 I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR),
3123 .platform_data = &adv7520_hdmi_data,
3124 },
3125};
3126
3127static struct i2c_board_info msm_marimba_board_info[] = {
3128 {
3129 I2C_BOARD_INFO("marimba", 0xc),
3130 .platform_data = &marimba_pdata,
3131 }
3132};
3133
3134
3135static struct msm_handset_platform_data hs_platform_data = {
3136 .hs_name = "7k_handset",
3137 .pwr_key_delay_ms = 500, /* 0 will disable end key */
3138};
3139
3140static struct platform_device hs_device = {
3141 .name = "msm-handset",
3142 .id = -1,
3143 .dev = {
3144 .platform_data = &hs_platform_data,
3145 },
3146};
3147
3148static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +05303149 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003150 .idle_supported = 1,
3151 .suspend_supported = 1,
3152 .idle_enabled = 1,
3153 .suspend_enabled = 1,
3154 .latency = 8594,
3155 .residency = 23740,
3156 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303157 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003158 .idle_supported = 1,
3159 .suspend_supported = 1,
3160 .idle_enabled = 1,
3161 .suspend_enabled = 1,
3162 .latency = 4594,
3163 .residency = 23740,
3164 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303165 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003166#ifdef CONFIG_MSM_STANDALONE_POWER_COLLAPSE
3167 .idle_supported = 1,
3168 .suspend_supported = 1,
3169 .idle_enabled = 1,
3170 .suspend_enabled = 0,
3171#else /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3172 .idle_supported = 0,
3173 .suspend_supported = 0,
3174 .idle_enabled = 0,
3175 .suspend_enabled = 0,
3176#endif /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3177 .latency = 500,
3178 .residency = 6000,
3179 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303180 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003181 .idle_supported = 1,
3182 .suspend_supported = 1,
3183 .idle_enabled = 0,
3184 .suspend_enabled = 1,
3185 .latency = 443,
3186 .residency = 1098,
3187 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303188 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003189 .idle_supported = 1,
3190 .suspend_supported = 1,
3191 .idle_enabled = 1,
3192 .suspend_enabled = 1,
3193 .latency = 2,
3194 .residency = 0,
3195 },
3196};
3197
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003198static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3199 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
3200 .v_addr = (uint32_t *)PAGE_OFFSET,
3201};
3202
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003203static struct resource qsd_spi_resources[] = {
3204 {
3205 .name = "spi_irq_in",
3206 .start = INT_SPI_INPUT,
3207 .end = INT_SPI_INPUT,
3208 .flags = IORESOURCE_IRQ,
3209 },
3210 {
3211 .name = "spi_irq_out",
3212 .start = INT_SPI_OUTPUT,
3213 .end = INT_SPI_OUTPUT,
3214 .flags = IORESOURCE_IRQ,
3215 },
3216 {
3217 .name = "spi_irq_err",
3218 .start = INT_SPI_ERROR,
3219 .end = INT_SPI_ERROR,
3220 .flags = IORESOURCE_IRQ,
3221 },
3222 {
3223 .name = "spi_base",
3224 .start = 0xA8000000,
3225 .end = 0xA8000000 + SZ_4K - 1,
3226 .flags = IORESOURCE_MEM,
3227 },
3228 {
3229 .name = "spidm_channels",
3230 .flags = IORESOURCE_DMA,
3231 },
3232 {
3233 .name = "spidm_crci",
3234 .flags = IORESOURCE_DMA,
3235 },
3236};
3237
3238#define AMDH0_BASE_PHYS 0xAC200000
3239#define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
3240static int msm_qsd_spi_dma_config(void)
3241{
3242 void __iomem *ct_adm_base = 0;
3243 u32 spi_mux = 0;
3244 int ret = 0;
3245
3246 ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
3247 if (!ct_adm_base) {
3248 pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
3249 return -ENOMEM;
3250 }
3251
3252 spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
3253
3254 qsd_spi_resources[4].start = DMOV_USB_CHAN;
3255 qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
3256
3257 switch (spi_mux) {
3258 case (1):
3259 qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
3260 qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
3261 break;
3262 case (2):
3263 qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
3264 qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
3265 break;
3266 case (3):
3267 qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
3268 qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
3269 break;
3270 default:
3271 ret = -ENOENT;
3272 }
3273
3274 iounmap(ct_adm_base);
3275
3276 return ret;
3277}
3278
3279static struct platform_device qsd_device_spi = {
3280 .name = "spi_qsd",
3281 .id = 0,
3282 .num_resources = ARRAY_SIZE(qsd_spi_resources),
3283 .resource = qsd_spi_resources,
3284};
3285
3286#ifdef CONFIG_SPI_QSD
3287static struct spi_board_info lcdc_sharp_spi_board_info[] __initdata = {
3288 {
3289 .modalias = "lcdc_sharp_ls038y7dx01",
3290 .mode = SPI_MODE_1,
3291 .bus_num = 0,
3292 .chip_select = 0,
3293 .max_speed_hz = 26331429,
3294 }
3295};
3296static struct spi_board_info lcdc_toshiba_spi_board_info[] __initdata = {
3297 {
3298 .modalias = "lcdc_toshiba_ltm030dd40",
3299 .mode = SPI_MODE_3|SPI_CS_HIGH,
3300 .bus_num = 0,
3301 .chip_select = 0,
3302 .max_speed_hz = 9963243,
3303 }
3304};
3305#endif
3306
3307static struct msm_gpio qsd_spi_gpio_config_data[] = {
3308 { GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3309 { GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3310 { GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" },
3311 { GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3312};
3313
3314static int msm_qsd_spi_gpio_config(void)
3315{
3316 return msm_gpios_request_enable(qsd_spi_gpio_config_data,
3317 ARRAY_SIZE(qsd_spi_gpio_config_data));
3318}
3319
3320static void msm_qsd_spi_gpio_release(void)
3321{
3322 msm_gpios_disable_free(qsd_spi_gpio_config_data,
3323 ARRAY_SIZE(qsd_spi_gpio_config_data));
3324}
3325
3326static struct msm_spi_platform_data qsd_spi_pdata = {
3327 .max_clock_speed = 26331429,
3328 .gpio_config = msm_qsd_spi_gpio_config,
3329 .gpio_release = msm_qsd_spi_gpio_release,
3330 .dma_config = msm_qsd_spi_dma_config,
3331};
3332
3333static void __init msm_qsd_spi_init(void)
3334{
3335 qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
3336}
3337
3338#ifdef CONFIG_USB_EHCI_MSM_72K
3339static void msm_hsusb_vbus_power(unsigned phy_info, int on)
3340{
3341 int rc;
3342 static int vbus_is_on;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303343 struct pm8xxx_gpio_init_info usb_vbus = {
3344 PM8058_GPIO_PM_TO_SYS(36),
3345 {
3346 .direction = PM_GPIO_DIR_OUT,
3347 .pull = PM_GPIO_PULL_NO,
3348 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3349 .output_value = 1,
3350 .vin_sel = 2,
3351 .out_strength = PM_GPIO_STRENGTH_MED,
3352 .function = PM_GPIO_FUNC_NORMAL,
3353 .inv_int_pol = 0,
3354 },
3355 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003356
3357 /* If VBUS is already on (or off), do nothing. */
3358 if (unlikely(on == vbus_is_on))
3359 return;
3360
3361 if (on) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303362 rc = pm8xxx_gpio_config(usb_vbus.gpio, &usb_vbus.config);
3363 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003364 pr_err("%s PMIC GPIO 36 write failed\n", __func__);
3365 return;
3366 }
3367 } else {
3368 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(36), 0);
3369 }
3370
3371 vbus_is_on = on;
3372}
3373
3374static struct msm_usb_host_platform_data msm_usb_host_pdata = {
3375 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
3376 .vbus_power = msm_hsusb_vbus_power,
3377 .power_budget = 180,
3378};
3379#endif
3380
3381#ifdef CONFIG_USB_MSM_OTG_72K
3382static int hsusb_rpc_connect(int connect)
3383{
3384 if (connect)
3385 return msm_hsusb_rpc_connect();
3386 else
3387 return msm_hsusb_rpc_close();
3388}
3389#endif
3390
3391#ifdef CONFIG_USB_MSM_OTG_72K
Justin Paupore3f40f342011-08-10 18:52:16 -07003392static struct regulator *vreg_3p3;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003393static int msm_hsusb_ldo_init(int init)
3394{
3395 uint32_t version = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07003396 int def_vol = 3400000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003397
3398 version = socinfo_get_version();
3399
3400 if (SOCINFO_VERSION_MAJOR(version) >= 2 &&
3401 SOCINFO_VERSION_MINOR(version) >= 1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003402 def_vol = 3075000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003403 pr_debug("%s: default voltage:%d\n", __func__, def_vol);
3404 }
3405
3406 if (init) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003407 vreg_3p3 = regulator_get(NULL, "usb");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003408 if (IS_ERR(vreg_3p3))
3409 return PTR_ERR(vreg_3p3);
Justin Paupore3f40f342011-08-10 18:52:16 -07003410 regulator_set_voltage(vreg_3p3, def_vol, def_vol);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003411 } else
Justin Paupore3f40f342011-08-10 18:52:16 -07003412 regulator_put(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003413
3414 return 0;
3415}
3416
3417static int msm_hsusb_ldo_enable(int enable)
3418{
3419 static int ldo_status;
3420
3421 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3422 return -ENODEV;
3423
3424 if (ldo_status == enable)
3425 return 0;
3426
3427 ldo_status = enable;
3428
3429 if (enable)
Justin Paupore3f40f342011-08-10 18:52:16 -07003430 return regulator_enable(vreg_3p3);
3431 else
3432 return regulator_disable(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003433}
3434
3435static int msm_hsusb_ldo_set_voltage(int mV)
3436{
Justin Paupore3f40f342011-08-10 18:52:16 -07003437 static int cur_voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003438
3439 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3440 return -ENODEV;
3441
3442 if (cur_voltage == mV)
3443 return 0;
3444
3445 cur_voltage = mV;
3446
3447 pr_debug("%s: (%d)\n", __func__, mV);
3448
Justin Paupore3f40f342011-08-10 18:52:16 -07003449 return regulator_set_voltage(vreg_3p3, mV*1000, mV*1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003450}
3451#endif
3452
3453#ifndef CONFIG_USB_EHCI_MSM_72K
3454static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init);
3455#endif
3456static struct msm_otg_platform_data msm_otg_pdata = {
3457 .rpc_connect = hsusb_rpc_connect,
3458
3459#ifndef CONFIG_USB_EHCI_MSM_72K
3460 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
3461#else
3462 .vbus_power = msm_hsusb_vbus_power,
3463#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003464 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
3465 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
3466 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
3467 .se1_gating = SE1_GATING_DISABLE,
3468 .chg_vbus_draw = hsusb_chg_vbus_draw,
3469 .chg_connected = hsusb_chg_connected,
3470 .chg_init = hsusb_chg_init,
3471 .ldo_enable = msm_hsusb_ldo_enable,
3472 .ldo_init = msm_hsusb_ldo_init,
3473 .ldo_set_voltage = msm_hsusb_ldo_set_voltage,
3474};
3475
3476#ifdef CONFIG_USB_GADGET
3477static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
3478 .is_phy_status_timer_on = 1,
3479};
3480#endif
3481#ifndef CONFIG_USB_EHCI_MSM_72K
3482typedef void (*notify_vbus_state) (int);
3483notify_vbus_state notify_vbus_state_func_ptr;
3484int vbus_on_irq;
3485static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
3486{
3487 pr_info("%s: vbus notification from pmic\n", __func__);
3488
3489 (*notify_vbus_state_func_ptr) (1);
3490
3491 return IRQ_HANDLED;
3492}
3493static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
3494{
3495 int ret;
3496
3497 if (init) {
3498 if (!callback)
3499 return -ENODEV;
3500
3501 notify_vbus_state_func_ptr = callback;
3502 vbus_on_irq = platform_get_irq_byname(&msm_device_otg,
3503 "vbus_on");
3504 if (vbus_on_irq <= 0) {
3505 pr_err("%s: unable to get vbus on irq\n", __func__);
3506 return -ENODEV;
3507 }
3508
3509 ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq,
3510 IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
3511 if (ret < 0) {
3512 pr_info("%s: request_irq for vbus_on"
3513 "interrupt failed\n", __func__);
3514 return ret;
3515 }
3516 msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
3517 return 0;
3518 } else {
3519 free_irq(vbus_on_irq, 0);
3520 notify_vbus_state_func_ptr = NULL;
3521 return 0;
3522 }
3523}
3524#endif
3525
3526static struct android_pmem_platform_data android_pmem_pdata = {
3527 .name = "pmem",
3528 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
3529 .cached = 1,
3530 .memory_type = MEMTYPE_EBI0,
3531};
3532
3533static struct platform_device android_pmem_device = {
3534 .name = "android_pmem",
3535 .id = 0,
3536 .dev = { .platform_data = &android_pmem_pdata },
3537};
3538
3539#ifndef CONFIG_SPI_QSD
3540static int lcdc_gpio_array_num[] = {
3541 45, /* spi_clk */
3542 46, /* spi_cs */
3543 47, /* spi_mosi */
3544 48, /* spi_miso */
3545 };
3546
3547static struct msm_gpio lcdc_gpio_config_data[] = {
3548 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3549 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3550 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
3551 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3552};
3553
3554static void lcdc_config_gpios(int enable)
3555{
3556 if (enable) {
3557 msm_gpios_request_enable(lcdc_gpio_config_data,
3558 ARRAY_SIZE(
3559 lcdc_gpio_config_data));
3560 } else
3561 msm_gpios_disable_free(lcdc_gpio_config_data,
3562 ARRAY_SIZE(
3563 lcdc_gpio_config_data));
3564}
3565#endif
3566
3567static struct msm_panel_common_pdata lcdc_sharp_panel_data = {
3568#ifndef CONFIG_SPI_QSD
3569 .panel_config_gpio = lcdc_config_gpios,
3570 .gpio_num = lcdc_gpio_array_num,
3571#endif
3572 .gpio = 2, /* LPG PMIC_GPIO26 channel number */
3573};
3574
3575static struct platform_device lcdc_sharp_panel_device = {
3576 .name = "lcdc_sharp_wvga",
3577 .id = 0,
3578 .dev = {
3579 .platform_data = &lcdc_sharp_panel_data,
3580 }
3581};
3582
3583static struct msm_gpio dtv_panel_irq_gpios[] = {
3584 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
3585 "hdmi_int" },
3586};
3587
3588static struct msm_gpio dtv_panel_gpios[] = {
3589 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
3590 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
3591 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
3592 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
3593 { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
3594 { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
3595 { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
3596 { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
3597 { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
3598 { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
3599 { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
3600 { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
3601 { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
3602 { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
3603 { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
3604 { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
3605 { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
3606 { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
3607 { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
3608 { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
3609 { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
3610 { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
3611 { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
3612 { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
3613 { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
3614 { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
3615 { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
3616 { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
3617 { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
3618 { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
3619 { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
3620 { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
3621};
3622
3623
3624#ifdef HDMI_RESET
3625static unsigned dtv_reset_gpio =
3626 GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3627#endif
3628
Justin Paupore3f40f342011-08-10 18:52:16 -07003629static struct regulator_bulk_data hdmi_core_regs[] = {
3630 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3631};
3632
3633static struct regulator_bulk_data hdmi_comm_regs[] = {
3634 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3635 { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 },
3636};
3637
3638static struct regulator_bulk_data hdmi_cec_regs[] = {
3639 { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 },
3640};
3641
3642static int __init hdmi_init_regs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003643{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003644 int rc;
3645
Justin Paupore3f40f342011-08-10 18:52:16 -07003646 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs),
3647 hdmi_core_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003648
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003649 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003650 pr_err("%s: could not get %s regulators: %d\n",
3651 __func__, "core", rc);
3652 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003653 }
3654
Justin Paupore3f40f342011-08-10 18:52:16 -07003655 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs),
3656 hdmi_core_regs);
3657
3658 if (rc) {
3659 pr_err("%s: could not set %s voltages: %d\n",
3660 __func__, "core", rc);
3661 goto free_core;
3662 }
3663
3664 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs),
3665 hdmi_comm_regs);
3666
3667 if (rc) {
3668 pr_err("%s: could not get %s regulators: %d\n",
3669 __func__, "comm", rc);
3670 goto free_core;
3671 }
3672
3673 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs),
3674 hdmi_comm_regs);
3675
3676 if (rc) {
3677 pr_err("%s: could not set %s voltages: %d\n",
3678 __func__, "comm", rc);
3679 goto free_comm;
3680 }
3681
3682 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs),
3683 hdmi_cec_regs);
3684
3685 if (rc) {
3686 pr_err("%s: could not get %s regulators: %d\n",
3687 __func__, "cec", rc);
3688 goto free_comm;
3689 }
3690
3691 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs),
3692 hdmi_cec_regs);
3693
3694 if (rc) {
3695 pr_err("%s: could not set %s voltages: %d\n",
3696 __func__, "cec", rc);
3697 goto free_cec;
3698 }
3699
3700 return 0;
3701
3702free_cec:
3703 regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs);
3704free_comm:
3705 regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs);
3706free_core:
3707 regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs);
3708out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003709 return rc;
3710}
3711
Justin Paupore3f40f342011-08-10 18:52:16 -07003712static int hdmi_init_irq(void)
3713{
3714 int rc = msm_gpios_enable(dtv_panel_irq_gpios,
3715 ARRAY_SIZE(dtv_panel_irq_gpios));
3716 if (rc < 0) {
3717 pr_err("%s: gpio enable failed: %d\n", __func__, rc);
3718 return rc;
3719 }
3720 pr_info("%s\n", __func__);
3721
3722 return 0;
3723}
3724
3725static int hdmi_enable_5v(int on)
3726{
3727 int pmic_gpio_hdmi_5v_en ;
3728
3729 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
3730 machine_is_msm7x30_fluid())
3731 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
3732 else
3733 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
3734
3735 pr_info("%s: %d\n", __func__, on);
3736 if (on) {
3737 int rc;
3738 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
3739 "hdmi_5V_en");
3740 if (rc) {
3741 pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
3742 __func__);
3743 return rc;
3744 }
3745 gpio_set_value_cansleep(
3746 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
3747 } else {
3748 gpio_set_value_cansleep(
3749 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
3750 gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
3751 }
3752 return 0;
3753}
3754
3755static int hdmi_comm_power(int on, int show)
3756{
3757 if (show)
3758 pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
3759 return on ?
3760 regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs),
3761 hdmi_comm_regs) :
3762 regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs),
3763 hdmi_comm_regs);
3764}
3765
3766static int hdmi_core_power(int on, int show)
3767{
3768 if (show)
3769 pr_info("%s: %d <LDO8>\n", __func__, on);
3770 return on ?
3771 regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs),
3772 hdmi_core_regs) :
3773 regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs),
3774 hdmi_core_regs);
3775}
3776
3777static int hdmi_cec_power(int on)
3778{
3779 pr_info("%s: %d <LDO17>\n", __func__, on);
3780 return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs),
3781 hdmi_cec_regs) :
3782 regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs),
3783 hdmi_cec_regs);
3784}
3785
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003786#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
3787/* there is an i2c address conflict between adv7520 and bma150 sensor after
3788 * power up on fluid. As a solution, the default address of adv7520's packet
3789 * memory is changed as soon as possible
3790 */
3791static int __init fluid_i2c_address_fixup(void)
3792{
3793 unsigned char wBuff[16];
3794 unsigned char rBuff[16];
3795 struct i2c_msg msgs[3];
3796 int res;
3797 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003798 struct i2c_adapter *adapter;
3799
3800 if (machine_is_msm7x30_fluid()) {
3801 adapter = i2c_get_adapter(0);
3802 if (!adapter) {
3803 pr_err("%s: invalid i2c adapter\n", __func__);
3804 return PTR_ERR(adapter);
3805 }
3806
3807 /* turn on LDO8 */
Justin Paupore3f40f342011-08-10 18:52:16 -07003808 rc = hdmi_core_power(1, 0);
3809 if (rc) {
3810 pr_err("%s: could not enable hdmi core regs: %d",
3811 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003812 goto adapter_put;
3813 }
3814
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003815 /* change packet memory address to 0x74 */
3816 wBuff[0] = 0x45;
3817 wBuff[1] = 0x74;
3818
3819 msgs[0].addr = ADV7520_I2C_ADDR;
3820 msgs[0].flags = 0;
3821 msgs[0].buf = (unsigned char *) wBuff;
3822 msgs[0].len = 2;
3823
3824 res = i2c_transfer(adapter, msgs, 1);
3825 if (res != 1) {
3826 pr_err("%s: error writing adv7520\n", __func__);
3827 goto ldo8_disable;
3828 }
3829
3830 /* powerdown adv7520 using bit 6 */
3831 /* i2c read first */
3832 wBuff[0] = 0x41;
3833
3834 msgs[0].addr = ADV7520_I2C_ADDR;
3835 msgs[0].flags = 0;
3836 msgs[0].buf = (unsigned char *) wBuff;
3837 msgs[0].len = 1;
3838
3839 msgs[1].addr = ADV7520_I2C_ADDR;
3840 msgs[1].flags = I2C_M_RD;
3841 msgs[1].buf = rBuff;
3842 msgs[1].len = 1;
3843 res = i2c_transfer(adapter, msgs, 2);
3844 if (res != 2) {
3845 pr_err("%s: error reading adv7520\n", __func__);
3846 goto ldo8_disable;
3847 }
3848
3849 /* i2c write back */
3850 wBuff[0] = 0x41;
3851 wBuff[1] = rBuff[0] | 0x40;
3852
3853 msgs[0].addr = ADV7520_I2C_ADDR;
3854 msgs[0].flags = 0;
3855 msgs[0].buf = (unsigned char *) wBuff;
3856 msgs[0].len = 2;
3857
3858 res = i2c_transfer(adapter, msgs, 1);
3859 if (res != 1) {
3860 pr_err("%s: error writing adv7520\n", __func__);
3861 goto ldo8_disable;
3862 }
3863
3864 /* for successful fixup, we release the i2c adapter */
3865 /* but leave ldo8 on so that the adv7520 is not repowered */
3866 i2c_put_adapter(adapter);
3867 pr_info("%s: fluid i2c address conflict resolved\n", __func__);
3868 }
3869 return 0;
3870
3871ldo8_disable:
Justin Paupore3f40f342011-08-10 18:52:16 -07003872 hdmi_core_power(0, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003873adapter_put:
3874 i2c_put_adapter(adapter);
3875 return rc;
3876}
3877fs_initcall_sync(fluid_i2c_address_fixup);
3878#endif
3879
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003880static bool hdmi_check_hdcp_hw_support(void)
3881{
3882 if (machine_is_msm7x30_fluid())
3883 return false;
3884 else
3885 return true;
3886}
3887
3888static int dtv_panel_power(int on)
3889{
3890 int flag_on = !!on;
3891 static int dtv_power_save_on;
3892 int rc;
3893
3894 if (dtv_power_save_on == flag_on)
3895 return 0;
3896
3897 dtv_power_save_on = flag_on;
3898 pr_info("%s: %d\n", __func__, on);
3899
3900#ifdef HDMI_RESET
3901 if (on) {
3902 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
3903 rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
3904 if (rc) {
3905 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
3906 __func__, dtv_reset_gpio, rc);
3907 return rc;
3908 }
3909
3910 /* bring reset line low to hold reset*/
3911 gpio_set_value(37, 0);
3912 }
3913#endif
3914
3915 if (on) {
3916 rc = msm_gpios_enable(dtv_panel_gpios,
3917 ARRAY_SIZE(dtv_panel_gpios));
3918 if (rc < 0) {
3919 printk(KERN_ERR "%s: gpio enable failed: %d\n",
3920 __func__, rc);
3921 return rc;
3922 }
3923 } else {
3924 rc = msm_gpios_disable(dtv_panel_gpios,
3925 ARRAY_SIZE(dtv_panel_gpios));
3926 if (rc < 0) {
3927 printk(KERN_ERR "%s: gpio disable failed: %d\n",
3928 __func__, rc);
3929 return rc;
3930 }
3931 }
3932
3933 mdelay(5); /* ensure power is stable */
3934
3935#ifdef HDMI_RESET
3936 if (on) {
3937 gpio_set_value(37, 1); /* bring reset line high */
3938 mdelay(10); /* 10 msec before IO can be accessed */
3939 }
3940#endif
3941
3942 return rc;
3943}
3944
3945static struct lcdc_platform_data dtv_pdata = {
3946 .lcdc_power_save = dtv_panel_power,
3947};
3948
3949static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3950 .inject_rx_on_wakeup = 1,
3951 .rx_to_inject = 0xFD,
3952};
3953
3954static struct resource msm_fb_resources[] = {
3955 {
3956 .flags = IORESOURCE_DMA,
3957 }
3958};
3959
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08003960#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
3961static struct resource msm_v4l2_video_overlay_resources[] = {
3962 {
3963 .flags = IORESOURCE_DMA,
3964 }
3965};
3966#endif
3967
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003968static int msm_fb_detect_panel(const char *name)
3969{
3970 if (machine_is_msm7x30_fluid()) {
3971 if (!strcmp(name, "lcdc_sharp_wvga_pt"))
3972 return 0;
3973 } else {
3974 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
3975 return -EPERM;
3976 else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20))
3977 return 0;
3978 else if (!strcmp(name, "mddi_orise"))
3979 return -EPERM;
3980 else if (!strcmp(name, "mddi_quickvx"))
3981 return -EPERM;
3982 }
3983 return -ENODEV;
3984}
3985
3986static struct msm_fb_platform_data msm_fb_pdata = {
3987 .detect_client = msm_fb_detect_panel,
3988 .mddi_prescan = 1,
3989};
3990
3991static struct platform_device msm_fb_device = {
3992 .name = "msm_fb",
3993 .id = 0,
3994 .num_resources = ARRAY_SIZE(msm_fb_resources),
3995 .resource = msm_fb_resources,
3996 .dev = {
3997 .platform_data = &msm_fb_pdata,
3998 }
3999};
4000
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08004001#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
4002
4003static struct platform_device msm_v4l2_video_overlay_device = {
4004 .name = "msm_v4l2_overlay_pd",
4005 .id = 0,
4006 .num_resources = ARRAY_SIZE(msm_v4l2_video_overlay_resources),
4007 .resource = msm_v4l2_video_overlay_resources,
4008};
4009#endif
4010
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004011static struct platform_device msm_migrate_pages_device = {
4012 .name = "msm_migrate_pages",
4013 .id = -1,
4014};
4015
4016static struct android_pmem_platform_data android_pmem_adsp_pdata = {
4017 .name = "pmem_adsp",
4018 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4019 .cached = 0,
4020 .memory_type = MEMTYPE_EBI0,
4021};
4022
4023static struct android_pmem_platform_data android_pmem_audio_pdata = {
4024 .name = "pmem_audio",
4025 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4026 .cached = 0,
4027 .memory_type = MEMTYPE_EBI0,
4028};
4029
4030static struct platform_device android_pmem_adsp_device = {
4031 .name = "android_pmem",
4032 .id = 2,
4033 .dev = { .platform_data = &android_pmem_adsp_pdata },
4034};
4035
4036static struct platform_device android_pmem_audio_device = {
4037 .name = "android_pmem",
4038 .id = 4,
4039 .dev = { .platform_data = &android_pmem_audio_pdata },
4040};
4041
4042#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4043 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
4044 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4045 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4046
4047#define QCE_SIZE 0x10000
4048#define QCE_0_BASE 0xA8400000
4049
4050#define QCE_HW_KEY_SUPPORT 1
4051#define QCE_SHA_HMAC_SUPPORT 0
4052#define QCE_SHARE_CE_RESOURCE 0
4053#define QCE_CE_SHARED 0
4054
4055static struct resource qcrypto_resources[] = {
4056 [0] = {
4057 .start = QCE_0_BASE,
4058 .end = QCE_0_BASE + QCE_SIZE - 1,
4059 .flags = IORESOURCE_MEM,
4060 },
4061 [1] = {
4062 .name = "crypto_channels",
4063 .start = DMOV_CE_IN_CHAN,
4064 .end = DMOV_CE_OUT_CHAN,
4065 .flags = IORESOURCE_DMA,
4066 },
4067 [2] = {
4068 .name = "crypto_crci_in",
4069 .start = DMOV_CE_IN_CRCI,
4070 .end = DMOV_CE_IN_CRCI,
4071 .flags = IORESOURCE_DMA,
4072 },
4073 [3] = {
4074 .name = "crypto_crci_out",
4075 .start = DMOV_CE_OUT_CRCI,
4076 .end = DMOV_CE_OUT_CRCI,
4077 .flags = IORESOURCE_DMA,
4078 },
4079 [4] = {
4080 .name = "crypto_crci_hash",
4081 .start = DMOV_CE_HASH_CRCI,
4082 .end = DMOV_CE_HASH_CRCI,
4083 .flags = IORESOURCE_DMA,
4084 },
4085};
4086
4087static struct resource qcedev_resources[] = {
4088 [0] = {
4089 .start = QCE_0_BASE,
4090 .end = QCE_0_BASE + QCE_SIZE - 1,
4091 .flags = IORESOURCE_MEM,
4092 },
4093 [1] = {
4094 .name = "crypto_channels",
4095 .start = DMOV_CE_IN_CHAN,
4096 .end = DMOV_CE_OUT_CHAN,
4097 .flags = IORESOURCE_DMA,
4098 },
4099 [2] = {
4100 .name = "crypto_crci_in",
4101 .start = DMOV_CE_IN_CRCI,
4102 .end = DMOV_CE_IN_CRCI,
4103 .flags = IORESOURCE_DMA,
4104 },
4105 [3] = {
4106 .name = "crypto_crci_out",
4107 .start = DMOV_CE_OUT_CRCI,
4108 .end = DMOV_CE_OUT_CRCI,
4109 .flags = IORESOURCE_DMA,
4110 },
4111 [4] = {
4112 .name = "crypto_crci_hash",
4113 .start = DMOV_CE_HASH_CRCI,
4114 .end = DMOV_CE_HASH_CRCI,
4115 .flags = IORESOURCE_DMA,
4116 },
4117};
4118
4119#endif
4120
4121#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4122 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
4123
4124static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
4125 .ce_shared = QCE_CE_SHARED,
4126 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4127 .hw_key_support = QCE_HW_KEY_SUPPORT,
4128 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004129 /* Bus Scaling declaration*/
4130 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004131};
4132
4133static struct platform_device qcrypto_device = {
4134 .name = "qcrypto",
4135 .id = 0,
4136 .num_resources = ARRAY_SIZE(qcrypto_resources),
4137 .resource = qcrypto_resources,
4138 .dev = {
4139 .coherent_dma_mask = DMA_BIT_MASK(32),
4140 .platform_data = &qcrypto_ce_hw_suppport,
4141 },
4142};
4143#endif
4144
4145#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4146 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4147
4148static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
4149 .ce_shared = QCE_CE_SHARED,
4150 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4151 .hw_key_support = QCE_HW_KEY_SUPPORT,
4152 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004153 /* Bus Scaling declaration*/
4154 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004155};
4156static struct platform_device qcedev_device = {
4157 .name = "qce",
4158 .id = 0,
4159 .num_resources = ARRAY_SIZE(qcedev_resources),
4160 .resource = qcedev_resources,
4161 .dev = {
4162 .coherent_dma_mask = DMA_BIT_MASK(32),
4163 .platform_data = &qcedev_ce_hw_suppport,
4164 },
4165};
4166#endif
4167
4168static int mddi_toshiba_pmic_bl(int level)
4169{
4170 int ret = -EPERM;
4171
4172 ret = pmic_set_led_intensity(LED_LCD, level);
4173
4174 if (ret)
4175 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
4176 __func__);
4177 return ret;
4178}
4179
4180static struct msm_panel_common_pdata mddi_toshiba_pdata = {
4181 .pmic_backlight = mddi_toshiba_pmic_bl,
4182};
4183
4184static struct platform_device mddi_toshiba_device = {
4185 .name = "mddi_toshiba",
4186 .id = 0,
4187 .dev = {
4188 .platform_data = &mddi_toshiba_pdata,
4189 }
4190};
4191
4192static unsigned wega_reset_gpio =
4193 GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4194
4195static struct msm_gpio fluid_vee_reset_gpio[] = {
4196 { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
4197};
4198
4199static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1;
4200static unsigned char quickvx_ldo_enabled;
4201
4202static unsigned quickvx_vlp_gpio =
4203 GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4204
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304205static struct pm8xxx_gpio_init_info pmic_quickvx_clk_gpio = {
4206 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_QUICKVX_CLK),
4207 {
4208 .direction = PM_GPIO_DIR_OUT,
4209 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
4210 .output_value = 1,
4211 .pull = PM_GPIO_PULL_NO,
4212 .vin_sel = PM8058_GPIO_VIN_S3,
4213 .out_strength = PM_GPIO_STRENGTH_HIGH,
4214 .function = PM_GPIO_FUNC_2,
4215 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004216};
4217
Justin Paupore3f40f342011-08-10 18:52:16 -07004218static struct regulator *mddi_ldo20;
4219static struct regulator *mddi_ldo12;
4220static struct regulator *mddi_ldo16;
4221static struct regulator *mddi_ldo6;
4222static struct regulator *mddi_lcd;
4223
4224static int display_common_init(void)
4225{
4226 struct regulator_bulk_data regs[5] = {
4227 { .supply = "ldo20", /* voltage set in display_common_power */},
4228 { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 },
4229 { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 },
4230 { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 },
4231 { .supply = NULL, /* mddi_lcd, initialized below */ },
4232 };
4233
4234 int rc = 0;
4235
4236 if (machine_is_msm7x30_fluid()) {
4237 /* lcd: LDO8 @1.8V */
4238 regs[4].supply = "ldo8";
4239 regs[4].min_uV = 1800000;
4240 regs[4].max_uV = 1800000;
4241 } else {
4242 /* lcd: LDO15 @3.1V */
4243 regs[4].supply = "ldo15";
4244 regs[4].min_uV = 3100000;
4245 regs[4].max_uV = 3100000;
4246 }
4247
4248 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4249 if (rc) {
4250 pr_err("%s: regulator_bulk_get failed: %d\n",
4251 __func__, rc);
4252 goto bail;
4253 }
4254
4255 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4256 if (rc) {
4257 pr_err("%s: regulator_bulk_set_voltage failed: %d\n",
4258 __func__, rc);
4259 goto put_regs;
4260 }
4261
4262 mddi_ldo20 = regs[0].consumer;
4263 mddi_ldo12 = regs[1].consumer;
4264 mddi_ldo6 = regs[2].consumer;
4265 mddi_ldo16 = regs[3].consumer;
4266 mddi_lcd = regs[4].consumer;
4267
4268 return rc;
4269
4270put_regs:
4271 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4272bail:
4273 return rc;
4274}
4275
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004276static int display_common_power(int on)
4277{
4278 int rc = 0, flag_on = !!on;
4279 static int display_common_power_save_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004280 static bool display_regs_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004281
4282 if (display_common_power_save_on == flag_on)
4283 return 0;
4284
4285 display_common_power_save_on = flag_on;
4286
Justin Paupore3f40f342011-08-10 18:52:16 -07004287 if (unlikely(!display_regs_initialized)) {
4288 rc = display_common_init();
4289 if (rc) {
4290 pr_err("%s: regulator init failed: %d\n",
4291 __func__, rc);
4292 return rc;
4293 }
4294 display_regs_initialized = true;
4295 }
4296
4297
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004298 if (on) {
4299 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
4300 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
4301 if (rc) {
4302 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4303 __func__, wega_reset_gpio, rc);
4304 return rc;
4305 }
4306
4307 /* bring reset line low to hold reset*/
4308 gpio_set_value(180, 0);
4309
4310 if (quickvx_mddi_client) {
4311 /* QuickVX chip -- VLP pin -- gpio 97 */
4312 rc = gpio_tlmm_config(quickvx_vlp_gpio,
4313 GPIO_CFG_ENABLE);
4314 if (rc) {
4315 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4316 __func__, quickvx_vlp_gpio, rc);
4317 return rc;
4318 }
4319
4320 /* bring QuickVX VLP line low */
4321 gpio_set_value(97, 0);
4322
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304323 rc = pm8xxx_gpio_config(pmic_quickvx_clk_gpio.gpio,
4324 &pmic_quickvx_clk_gpio.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004325 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304326 pr_err("%s: pm8xxx_gpio_config(%#x)=%d\n",
4327 __func__, pmic_quickvx_clk_gpio.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004328 rc);
4329 return rc;
4330 }
4331
4332 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4333 PMIC_GPIO_QUICKVX_CLK), 0);
4334 }
4335 }
4336
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004337 if (quickvx_mddi_client)
Justin Paupore3f40f342011-08-10 18:52:16 -07004338 rc = regulator_set_voltage(mddi_ldo20, 1800000, 1800000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004339 else
Justin Paupore3f40f342011-08-10 18:52:16 -07004340 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000);
4341
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004342 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004343 pr_err("%s: could not set voltage for ldo20: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004344 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07004345 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004346 }
4347
4348 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004349 rc = regulator_enable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004350 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004351 pr_err("%s: LDO20 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004352 __func__, rc);
4353 return rc;
4354 }
4355
Justin Paupore3f40f342011-08-10 18:52:16 -07004356 rc = regulator_enable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004357 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004358 pr_err("%s: LDO12 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004359 __func__, rc);
4360 return rc;
4361 }
4362
4363 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004364 rc = regulator_enable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004365 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004366 pr_err("%s: LDO16 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004367 __func__, rc);
4368 return rc;
4369 }
4370 }
4371
Justin Paupore3f40f342011-08-10 18:52:16 -07004372 if (quickvx_ldo_enabled) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004373 /* Disable LDO6 during display ON */
Justin Paupore3f40f342011-08-10 18:52:16 -07004374 rc = regulator_disable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004375 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004376 pr_err("%s: LDO6 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004377 __func__, rc);
4378 return rc;
4379 }
4380 quickvx_ldo_enabled = 0;
4381 }
4382
Justin Paupore3f40f342011-08-10 18:52:16 -07004383 rc = regulator_enable(mddi_lcd);
4384 if (rc) {
4385 pr_err("%s: LCD regulator enable failed (%d)\n",
4386 __func__, rc);
4387 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004388 }
4389
4390 mdelay(5); /* ensure power is stable */
4391
4392 if (machine_is_msm7x30_fluid()) {
4393 rc = msm_gpios_request_enable(fluid_vee_reset_gpio,
4394 ARRAY_SIZE(fluid_vee_reset_gpio));
4395 if (rc)
4396 pr_err("%s gpio_request_enable failed rc=%d\n",
4397 __func__, rc);
4398 else {
4399 /* assert vee reset_n */
4400 gpio_set_value(20, 1);
4401 gpio_set_value(20, 0);
4402 mdelay(1);
4403 gpio_set_value(20, 1);
4404 }
4405 }
4406
4407 gpio_set_value(180, 1); /* bring reset line high */
4408 mdelay(10); /* 10 msec before IO can be accessed */
4409
4410 if (quickvx_mddi_client) {
4411 gpio_set_value(97, 1);
4412 msleep(2);
4413 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4414 PMIC_GPIO_QUICKVX_CLK), 1);
4415 msleep(2);
4416 }
4417
4418 rc = pmapp_display_clock_config(1);
4419 if (rc) {
4420 pr_err("%s pmapp_display_clock_config rc=%d\n",
4421 __func__, rc);
4422 return rc;
4423 }
4424
4425 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004426 rc = regulator_disable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004427 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004428 pr_err("%s: LDO20 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004429 __func__, rc);
4430 return rc;
4431 }
4432
4433
4434 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004435 rc = regulator_disable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004436 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004437 pr_err("%s: LDO16 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004438 __func__, rc);
4439 return rc;
4440 }
4441 }
4442
4443 if (quickvx_mddi_client && !quickvx_ldo_enabled) {
4444 /* Enable LDO6 during display OFF for
4445 Quicklogic chip to sleep with data retention */
Justin Paupore3f40f342011-08-10 18:52:16 -07004446 rc = regulator_enable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004447 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004448 pr_err("%s: LDO6 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004449 __func__, rc);
4450 return rc;
4451 }
4452 quickvx_ldo_enabled = 1;
4453 }
4454
4455 gpio_set_value(180, 0); /* bring reset line low */
4456
4457 if (quickvx_mddi_client) {
4458 gpio_set_value(97, 0);
4459 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4460 PMIC_GPIO_QUICKVX_CLK), 0);
4461 }
4462
Justin Paupore3f40f342011-08-10 18:52:16 -07004463 rc = regulator_disable(mddi_lcd);
4464 if (rc) {
4465 pr_err("%s: LCD regulator disable failed (%d)\n",
4466 __func__, rc);
4467 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004468 }
4469
4470 mdelay(5); /* ensure power is stable */
4471
Justin Paupore3f40f342011-08-10 18:52:16 -07004472 rc = regulator_disable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004473 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004474 pr_err("%s: LDO12 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004475 __func__, rc);
4476 return rc;
4477 }
4478
4479 if (machine_is_msm7x30_fluid()) {
4480 msm_gpios_disable_free(fluid_vee_reset_gpio,
4481 ARRAY_SIZE(fluid_vee_reset_gpio));
4482 }
4483
4484 rc = pmapp_display_clock_config(0);
4485 if (rc) {
4486 pr_err("%s pmapp_display_clock_config rc=%d\n",
4487 __func__, rc);
4488 return rc;
4489 }
4490 }
4491
4492 return rc;
4493}
4494
4495static int msm_fb_mddi_sel_clk(u32 *clk_rate)
4496{
4497 *clk_rate *= 2;
4498 return 0;
4499}
4500
4501static int msm_fb_mddi_client_power(u32 client_id)
4502{
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304503 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004504 printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
4505 /* Check if it is Quicklogic client */
4506 if (client_id == 0xc5835800) {
4507 printk(KERN_NOTICE "\n Quicklogic MDDI client");
4508 other_mddi_client = 0;
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304509 if (IS_ERR(mddi_ldo16)) {
4510 rc = PTR_ERR(mddi_ldo16);
4511 pr_err("%s: gp10 vreg get failed (%d)\n", __func__, rc);
4512 return rc;
4513 }
4514 rc = regulator_disable(mddi_ldo16);
4515 if (rc) {
4516 pr_err("%s: LDO16 vreg enable failed (%d)\n",
4517 __func__, rc);
4518 return rc;
4519 }
4520
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004521 } else {
4522 printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
4523 quickvx_mddi_client = 0;
4524 gpio_set_value(97, 0);
4525 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4526 PMIC_GPIO_QUICKVX_CLK), 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004527 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004528
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004529 return 0;
4530}
4531
4532static struct mddi_platform_data mddi_pdata = {
4533 .mddi_power_save = display_common_power,
4534 .mddi_sel_clk = msm_fb_mddi_sel_clk,
4535 .mddi_client_power = msm_fb_mddi_client_power,
4536};
4537
4538int mdp_core_clk_rate_table[] = {
4539 122880000,
4540 122880000,
Pradeep Jilagam3cc12f92011-07-26 22:25:18 +05304541 192000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004542 192000000,
4543};
4544
4545static struct msm_panel_common_pdata mdp_pdata = {
4546 .hw_revision_addr = 0xac001270,
4547 .gpio = 30,
4548 .mdp_core_clk_rate = 122880000,
4549 .mdp_core_clk_table = mdp_core_clk_rate_table,
4550 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07004551 .mdp_rev = MDP_REV_40,
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05304552 .mem_hid = MEMTYPE_EBI0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004553};
4554
4555static int lcd_panel_spi_gpio_num[] = {
4556 45, /* spi_clk */
4557 46, /* spi_cs */
4558 47, /* spi_mosi */
4559 48, /* spi_miso */
4560 };
4561
4562static struct msm_gpio lcd_panel_gpios[] = {
4563/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
4564 * input. if there is a hardware revision; we should reassign this GPIO to a
4565 * new open line; and removing it will just ensure that this will be missed in
4566 * the future.
4567 { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
4568 */
4569 { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
4570 { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
4571 { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
4572 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4573 { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
4574 { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
4575 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4576#ifndef CONFIG_SPI_QSD
4577 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
4578 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
4579 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
4580 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
4581#endif
4582 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4583 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4584 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4585 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4586 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4587 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4588 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4589 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4590 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4591 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4592 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4593 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4594 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4595 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4596 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4597 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4598 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4599 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4600 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4601 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4602};
4603
4604static struct msm_gpio lcd_sharp_panel_gpios[] = {
4605 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4606 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4607 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4608 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4609 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4610 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4611 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4612 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4613 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4614 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4615 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4616 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4617 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4618 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4619 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4620 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4621 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4622 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4623 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4624 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4625 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4626 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4627};
4628
4629static int lcdc_toshiba_panel_power(int on)
4630{
4631 int rc, i;
4632 struct msm_gpio *gp;
4633
4634 rc = display_common_power(on);
4635 if (rc < 0) {
4636 printk(KERN_ERR "%s display_common_power failed: %d\n",
4637 __func__, rc);
4638 return rc;
4639 }
4640
4641 if (on) {
4642 rc = msm_gpios_enable(lcd_panel_gpios,
4643 ARRAY_SIZE(lcd_panel_gpios));
4644 if (rc < 0) {
4645 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4646 __func__, rc);
4647 }
4648 } else { /* off */
4649 gp = lcd_panel_gpios;
4650 for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
4651 /* ouput low */
4652 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4653 gp++;
4654 }
4655 }
4656
4657 return rc;
4658}
4659
4660static int lcdc_sharp_panel_power(int on)
4661{
4662 int rc, i;
4663 struct msm_gpio *gp;
4664
4665 rc = display_common_power(on);
4666 if (rc < 0) {
4667 printk(KERN_ERR "%s display_common_power failed: %d\n",
4668 __func__, rc);
4669 return rc;
4670 }
4671
4672 if (on) {
4673 rc = msm_gpios_enable(lcd_sharp_panel_gpios,
4674 ARRAY_SIZE(lcd_sharp_panel_gpios));
4675 if (rc < 0) {
4676 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4677 __func__, rc);
4678 }
4679 } else { /* off */
4680 gp = lcd_sharp_panel_gpios;
4681 for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) {
4682 /* ouput low */
4683 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4684 gp++;
4685 }
4686 }
4687
4688 return rc;
4689}
4690
4691static int lcdc_panel_power(int on)
4692{
4693 int flag_on = !!on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004694 static int lcdc_power_save_on, lcdc_power_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004695
4696 if (lcdc_power_save_on == flag_on)
4697 return 0;
4698
4699 lcdc_power_save_on = flag_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004700
4701 if (unlikely(!lcdc_power_initialized)) {
4702 quickvx_mddi_client = 0;
4703 display_common_init();
4704 lcdc_power_initialized = 1;
4705 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004706
4707 if (machine_is_msm7x30_fluid())
4708 return lcdc_sharp_panel_power(on);
4709 else
4710 return lcdc_toshiba_panel_power(on);
4711}
4712
4713static struct lcdc_platform_data lcdc_pdata = {
4714 .lcdc_power_save = lcdc_panel_power,
4715};
4716
Justin Paupore3f40f342011-08-10 18:52:16 -07004717static struct regulator *atv_s4, *atv_ldo9;
4718
4719static int __init atv_dac_power_init(void)
4720{
4721 int rc;
4722 struct regulator_bulk_data regs[] = {
4723 { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 },
4724 { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 },
4725 };
4726
4727 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4728
4729 if (rc) {
4730 pr_err("%s: could not get regulators: %d\n", __func__, rc);
4731 goto bail;
4732 }
4733
4734 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4735
4736 if (rc) {
4737 pr_err("%s: could not set voltages: %d\n", __func__, rc);
4738 goto reg_free;
4739 }
4740
4741 atv_s4 = regs[0].consumer;
4742 atv_ldo9 = regs[1].consumer;
4743
4744reg_free:
4745 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4746bail:
4747 return rc;
4748}
4749
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004750static int atv_dac_power(int on)
4751{
4752 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004753
4754 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004755 rc = regulator_enable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004756 if (rc) {
4757 pr_err("%s: s4 vreg enable failed (%d)\n",
4758 __func__, rc);
4759 return rc;
4760 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004761 rc = regulator_enable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004762 if (rc) {
4763 pr_err("%s: ldo9 vreg enable failed (%d)\n",
4764 __func__, rc);
4765 return rc;
4766 }
4767 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004768 rc = regulator_disable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004769 if (rc) {
4770 pr_err("%s: ldo9 vreg disable failed (%d)\n",
4771 __func__, rc);
4772 return rc;
4773 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004774 rc = regulator_disable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004775 if (rc) {
4776 pr_err("%s: s4 vreg disable failed (%d)\n",
4777 __func__, rc);
4778 return rc;
4779 }
4780 }
4781 return rc;
4782}
4783
4784static struct tvenc_platform_data atv_pdata = {
4785 .poll = 1,
4786 .pm_vid_en = atv_dac_power,
4787};
4788
4789static void __init msm_fb_add_devices(void)
4790{
4791 msm_fb_register_device("mdp", &mdp_pdata);
4792 msm_fb_register_device("pmdh", &mddi_pdata);
4793 msm_fb_register_device("lcdc", &lcdc_pdata);
4794 msm_fb_register_device("dtv", &dtv_pdata);
4795 msm_fb_register_device("tvenc", &atv_pdata);
4796#ifdef CONFIG_FB_MSM_TVOUT
4797 msm_fb_register_device("tvout_device", NULL);
4798#endif
4799}
4800
4801static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
4802 .gpio_num = lcd_panel_spi_gpio_num,
4803};
4804
4805static struct platform_device lcdc_toshiba_panel_device = {
4806 .name = "lcdc_toshiba_wvga",
4807 .id = 0,
4808 .dev = {
4809 .platform_data = &lcdc_toshiba_panel_data,
4810 }
4811};
4812
4813#if defined(CONFIG_MARIMBA_CORE) && \
4814 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4815static struct platform_device msm_bt_power_device = {
4816 .name = "bt_power",
4817 .id = -1
4818};
4819
4820enum {
4821 BT_RFR,
4822 BT_CTS,
4823 BT_RX,
4824 BT_TX,
4825};
4826
4827static struct msm_gpio bt_config_power_on[] = {
4828 { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4829 "UART1DM_RFR" },
4830 { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4831 "UART1DM_CTS" },
4832 { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4833 "UART1DM_Rx" },
4834 { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4835 "UART1DM_Tx" }
4836};
4837
4838static struct msm_gpio bt_config_power_off[] = {
4839 { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4840 "UART1DM_RFR" },
4841 { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4842 "UART1DM_CTS" },
4843 { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4844 "UART1DM_Rx" },
4845 { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4846 "UART1DM_Tx" }
4847};
4848
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004849static u8 bahama_version;
4850
Justin Paupore3f40f342011-08-10 18:52:16 -07004851static struct regulator_bulk_data regs_bt_marimba[] = {
4852 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4853 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
4854 { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304855 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004856};
4857
4858static struct regulator_bulk_data regs_bt_bahama_v1[] = {
4859 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4860 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
4861 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304862 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004863};
4864
4865static struct regulator_bulk_data regs_bt_bahama_v2[] = {
4866 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4867 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304868 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004869};
4870
4871static struct regulator_bulk_data *regs_bt;
4872static int regs_bt_count;
4873
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004874static int marimba_bt(int on)
4875{
4876 int rc;
4877 int i;
4878 struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
4879
4880 struct marimba_config_register {
4881 u8 reg;
4882 u8 value;
4883 u8 mask;
4884 };
4885
4886 struct marimba_variant_register {
4887 const size_t size;
4888 const struct marimba_config_register *set;
4889 };
4890
4891 const struct marimba_config_register *p;
4892
4893 u8 version;
4894
4895 const struct marimba_config_register v10_bt_on[] = {
4896 { 0xE5, 0x0B, 0x0F },
4897 { 0x05, 0x02, 0x07 },
4898 { 0x06, 0x88, 0xFF },
4899 { 0xE7, 0x21, 0x21 },
4900 { 0xE3, 0x38, 0xFF },
4901 { 0xE4, 0x06, 0xFF },
4902 };
4903
4904 const struct marimba_config_register v10_bt_off[] = {
4905 { 0xE5, 0x0B, 0x0F },
4906 { 0x05, 0x08, 0x0F },
4907 { 0x06, 0x88, 0xFF },
4908 { 0xE7, 0x00, 0x21 },
4909 { 0xE3, 0x00, 0xFF },
4910 { 0xE4, 0x00, 0xFF },
4911 };
4912
4913 const struct marimba_config_register v201_bt_on[] = {
4914 { 0x05, 0x08, 0x07 },
4915 { 0x06, 0x88, 0xFF },
4916 { 0xE7, 0x21, 0x21 },
4917 { 0xE3, 0x38, 0xFF },
4918 { 0xE4, 0x06, 0xFF },
4919 };
4920
4921 const struct marimba_config_register v201_bt_off[] = {
4922 { 0x05, 0x08, 0x07 },
4923 { 0x06, 0x88, 0xFF },
4924 { 0xE7, 0x00, 0x21 },
4925 { 0xE3, 0x00, 0xFF },
4926 { 0xE4, 0x00, 0xFF },
4927 };
4928
4929 const struct marimba_config_register v210_bt_on[] = {
4930 { 0xE9, 0x01, 0x01 },
4931 { 0x06, 0x88, 0xFF },
4932 { 0xE7, 0x21, 0x21 },
4933 { 0xE3, 0x38, 0xFF },
4934 { 0xE4, 0x06, 0xFF },
4935 };
4936
4937 const struct marimba_config_register v210_bt_off[] = {
4938 { 0x06, 0x88, 0xFF },
4939 { 0xE7, 0x00, 0x21 },
4940 { 0xE9, 0x00, 0x01 },
4941 { 0xE3, 0x00, 0xFF },
4942 { 0xE4, 0x00, 0xFF },
4943 };
4944
4945 const struct marimba_variant_register bt_marimba[2][4] = {
4946 {
4947 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4948 { 0, NULL },
4949 { ARRAY_SIZE(v201_bt_off), v201_bt_off },
4950 { ARRAY_SIZE(v210_bt_off), v210_bt_off }
4951 },
4952 {
4953 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4954 { 0, NULL },
4955 { ARRAY_SIZE(v201_bt_on), v201_bt_on },
4956 { ARRAY_SIZE(v210_bt_on), v210_bt_on }
4957 }
4958 };
4959
4960 on = on ? 1 : 0;
4961
4962 rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F);
4963 if (rc < 0) {
4964 printk(KERN_ERR
4965 "%s: version read failed: %d\n",
4966 __func__, rc);
4967 return rc;
4968 }
4969
4970 if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
4971 (bt_marimba[on][version].size == 0)) {
4972 printk(KERN_ERR
4973 "%s: unsupported version\n",
4974 __func__);
4975 return -EIO;
4976 }
4977
4978 p = bt_marimba[on][version].set;
4979
4980 printk(KERN_INFO "%s: found version %d\n", __func__, version);
4981
4982 for (i = 0; i < bt_marimba[on][version].size; i++) {
4983 u8 value = (p+i)->value;
4984 rc = marimba_write_bit_mask(&config,
4985 (p+i)->reg,
4986 &value,
4987 sizeof((p+i)->value),
4988 (p+i)->mask);
4989 if (rc < 0) {
4990 printk(KERN_ERR
4991 "%s: reg %d write failed: %d\n",
4992 __func__, (p+i)->reg, rc);
4993 return rc;
4994 }
4995 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
4996 __func__, (p+i)->reg,
4997 value, (p+i)->mask);
4998 }
4999 return 0;
5000}
5001
5002static int bahama_bt(int on)
5003{
5004 int rc;
5005 int i;
5006 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
5007
5008 struct bahama_variant_register {
5009 const size_t size;
5010 const struct bahama_config_register *set;
5011 };
5012
5013 const struct bahama_config_register *p;
5014
5015
5016 const struct bahama_config_register v10_bt_on[] = {
5017 { 0xE9, 0x00, 0xFF },
5018 { 0xF4, 0x80, 0xFF },
5019 { 0xF0, 0x06, 0xFF },
5020 { 0xE4, 0x00, 0xFF },
5021 { 0xE5, 0x00, 0x0F },
5022#ifdef CONFIG_WLAN
5023 { 0xE6, 0x38, 0x7F },
5024 { 0xE7, 0x06, 0xFF },
5025#endif
5026 { 0x11, 0x13, 0xFF },
5027 { 0xE9, 0x21, 0xFF },
5028 { 0x01, 0x0C, 0x1F },
5029 { 0x01, 0x08, 0x1F },
5030 };
5031
5032 const struct bahama_config_register v20_bt_on_fm_off[] = {
5033 { 0x11, 0x0C, 0xFF },
5034 { 0x13, 0x01, 0xFF },
5035 { 0xF4, 0x80, 0xFF },
5036 { 0xF0, 0x00, 0xFF },
5037 { 0xE9, 0x00, 0xFF },
5038#ifdef CONFIG_WLAN
5039 { 0x81, 0x00, 0xFF },
5040 { 0x82, 0x00, 0xFF },
5041 { 0xE6, 0x38, 0x7F },
5042 { 0xE7, 0x06, 0xFF },
5043#endif
5044 { 0xE9, 0x21, 0xFF }
5045 };
5046
5047 const struct bahama_config_register v20_bt_on_fm_on[] = {
5048 { 0x11, 0x0C, 0xFF },
5049 { 0x13, 0x01, 0xFF },
5050 { 0xF4, 0x86, 0xFF },
5051 { 0xF0, 0x06, 0xFF },
5052 { 0xE9, 0x00, 0xFF },
5053#ifdef CONFIG_WLAN
5054 { 0x81, 0x00, 0xFF },
5055 { 0x82, 0x00, 0xFF },
5056 { 0xE6, 0x38, 0x7F },
5057 { 0xE7, 0x06, 0xFF },
5058#endif
5059 { 0xE9, 0x21, 0xFF }
5060 };
5061
5062 const struct bahama_config_register v10_bt_off[] = {
5063 { 0xE9, 0x00, 0xFF },
5064 };
5065
5066 const struct bahama_config_register v20_bt_off_fm_off[] = {
5067 { 0xF4, 0x84, 0xFF },
5068 { 0xF0, 0x04, 0xFF },
5069 { 0xE9, 0x00, 0xFF }
5070 };
5071
5072 const struct bahama_config_register v20_bt_off_fm_on[] = {
5073 { 0xF4, 0x86, 0xFF },
5074 { 0xF0, 0x06, 0xFF },
5075 { 0xE9, 0x00, 0xFF }
5076 };
5077
5078 const struct bahama_variant_register bt_bahama[2][3] = {
5079 {
5080 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
5081 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
5082 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
5083 },
5084 {
5085 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
5086 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
5087 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
5088 }
5089 };
5090
5091 u8 offset = 0; /* index into bahama configs */
5092
5093 on = on ? 1 : 0;
5094
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005095
5096 if (bahama_version == VER_2_0) {
5097 if (marimba_get_fm_status(&config))
5098 offset = 0x01;
5099 }
5100
5101 p = bt_bahama[on][bahama_version + offset].set;
5102
5103 dev_info(&msm_bt_power_device.dev,
5104 "%s: found version %d\n", __func__, bahama_version);
5105
5106 for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
5107 u8 value = (p+i)->value;
5108 rc = marimba_write_bit_mask(&config,
5109 (p+i)->reg,
5110 &value,
5111 sizeof((p+i)->value),
5112 (p+i)->mask);
5113 if (rc < 0) {
5114 dev_err(&msm_bt_power_device.dev,
5115 "%s: reg %d write failed: %d\n",
5116 __func__, (p+i)->reg, rc);
5117 return rc;
5118 }
5119 dev_info(&msm_bt_power_device.dev,
5120 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
5121 __func__, (p+i)->reg,
5122 value, (p+i)->mask);
5123 }
5124 /* Update BT status */
5125 if (on)
5126 marimba_set_bt_status(&config, true);
5127 else
5128 marimba_set_bt_status(&config, false);
5129
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005130 return 0;
5131}
5132
Justin Paupore3f40f342011-08-10 18:52:16 -07005133static int bluetooth_regs_init(int bahama_not_marimba)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005134{
Justin Paupore3f40f342011-08-10 18:52:16 -07005135 int rc = 0;
5136 struct device *const dev = &msm_bt_power_device.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005137
5138 if (bahama_not_marimba) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005139 bahama_version = read_bahama_ver();
5140
5141 switch (bahama_version) {
5142 case VER_1_0:
5143 regs_bt = regs_bt_bahama_v1;
5144 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1);
5145 break;
5146 case VER_2_0:
5147 regs_bt = regs_bt_bahama_v2;
5148 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2);
5149 break;
5150 case VER_UNSUPPORTED:
5151 default:
5152 dev_err(dev,
5153 "%s: i2c failure or unsupported version: %d\n",
5154 __func__, bahama_version);
5155 rc = -EIO;
5156 goto out;
5157 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005158 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07005159 regs_bt = regs_bt_marimba;
5160 regs_bt_count = ARRAY_SIZE(regs_bt_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005161 }
5162
Justin Paupore3f40f342011-08-10 18:52:16 -07005163 rc = regulator_bulk_get(&msm_bt_power_device.dev,
5164 regs_bt_count, regs_bt);
5165 if (rc) {
5166 dev_err(dev, "%s: could not get regulators: %d\n",
5167 __func__, rc);
5168 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005169 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005170
5171 rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt);
5172 if (rc) {
5173 dev_err(dev, "%s: could not set voltages: %d\n",
5174 __func__, rc);
5175 goto reg_free;
5176 }
5177
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005178 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005179
5180reg_free:
5181 regulator_bulk_free(regs_bt_count, regs_bt);
5182out:
5183 regs_bt_count = 0;
5184 regs_bt = NULL;
5185 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005186}
5187
5188static int bluetooth_power(int on)
5189{
5190 int rc;
5191 const char *id = "BTPW";
5192
5193 int bahama_not_marimba = bahama_present();
5194
5195 if (bahama_not_marimba == -1) {
5196 printk(KERN_WARNING "%s: bahama_present: %d\n",
5197 __func__, bahama_not_marimba);
5198 return -ENODEV;
5199 }
5200
Justin Paupore3f40f342011-08-10 18:52:16 -07005201 if (unlikely(regs_bt_count == 0)) {
5202 rc = bluetooth_regs_init(bahama_not_marimba);
5203 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005204 return rc;
Justin Paupore3f40f342011-08-10 18:52:16 -07005205 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005206
Justin Paupore3f40f342011-08-10 18:52:16 -07005207 if (on) {
5208 rc = regulator_bulk_enable(regs_bt_count, regs_bt);
5209 if (rc)
5210 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005211
5212 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5213 PMAPP_CLOCK_VOTE_ON);
5214 if (rc < 0)
5215 return -EIO;
5216
5217 if (machine_is_msm8x55_svlte_surf() ||
5218 machine_is_msm8x55_svlte_ffa()) {
5219 rc = marimba_gpio_config(1);
5220 if (rc < 0)
5221 return -EIO;
5222 }
5223
5224 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5225 if (rc < 0)
5226 return -EIO;
5227
5228 msleep(10);
5229
5230 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5231 PMAPP_CLOCK_VOTE_PIN_CTRL);
5232 if (rc < 0)
5233 return -EIO;
5234
5235 if (machine_is_msm8x55_svlte_surf() ||
5236 machine_is_msm8x55_svlte_ffa()) {
5237 rc = marimba_gpio_config(0);
5238 if (rc < 0)
5239 return -EIO;
5240 }
5241
5242 rc = msm_gpios_enable(bt_config_power_on,
5243 ARRAY_SIZE(bt_config_power_on));
5244
5245 if (rc < 0)
5246 return rc;
5247
5248 } else {
5249 rc = msm_gpios_enable(bt_config_power_off,
5250 ARRAY_SIZE(bt_config_power_off));
5251 if (rc < 0)
5252 return rc;
5253
5254 /* check for initial RFKILL block (power off) */
5255 if (platform_get_drvdata(&msm_bt_power_device) == NULL)
5256 goto out;
5257
5258 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5259 if (rc < 0)
5260 return -EIO;
5261
5262 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5263 PMAPP_CLOCK_VOTE_OFF);
5264 if (rc < 0)
5265 return -EIO;
5266
Justin Paupore3f40f342011-08-10 18:52:16 -07005267 rc = regulator_bulk_disable(regs_bt_count, regs_bt);
5268 if (rc)
5269 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005270
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005271 }
5272
5273out:
5274 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
5275
5276 return 0;
5277}
5278
5279static void __init bt_power_init(void)
5280{
Justin Paupore3f40f342011-08-10 18:52:16 -07005281 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005282}
5283#else
5284#define bt_power_init(x) do {} while (0)
5285#endif
5286
5287static struct msm_psy_batt_pdata msm_psy_batt_data = {
5288 .voltage_min_design = 2800,
5289 .voltage_max_design = 4300,
5290 .avail_chg_sources = AC_CHG | USB_CHG ,
5291 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
5292};
5293
5294static struct platform_device msm_batt_device = {
5295 .name = "msm-battery",
5296 .id = -1,
5297 .dev.platform_data = &msm_psy_batt_data,
5298};
5299
5300static char *msm_adc_fluid_device_names[] = {
5301 "LTC_ADC1",
5302 "LTC_ADC2",
5303 "LTC_ADC3",
5304};
5305
5306static char *msm_adc_surf_device_names[] = {
5307 "XO_ADC",
5308};
5309
5310static struct msm_adc_platform_data msm_adc_pdata;
5311
5312static struct platform_device msm_adc_device = {
5313 .name = "msm_adc",
5314 .id = -1,
5315 .dev = {
5316 .platform_data = &msm_adc_pdata,
5317 },
5318};
5319
5320#ifdef CONFIG_MSM_SDIO_AL
5321static struct msm_gpio mdm2ap_status = {
5322 GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5323 "mdm2ap_status"
5324};
5325
5326
5327static int configure_mdm2ap_status(int on)
5328{
5329 if (on)
5330 return msm_gpios_request_enable(&mdm2ap_status, 1);
5331 else {
5332 msm_gpios_disable_free(&mdm2ap_status, 1);
5333 return 0;
5334 }
5335}
5336
5337static int get_mdm2ap_status(void)
5338{
5339 return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
5340}
5341
5342static struct sdio_al_platform_data sdio_al_pdata = {
5343 .config_mdm2ap_status = configure_mdm2ap_status,
5344 .get_mdm2ap_status = get_mdm2ap_status,
5345 .allow_sdioc_version_major_2 = 1,
5346 .peer_sdioc_version_minor = 0x0001,
5347 .peer_sdioc_version_major = 0x0003,
5348 .peer_sdioc_boot_version_minor = 0x0001,
5349 .peer_sdioc_boot_version_major = 0x0003,
5350};
5351
5352struct platform_device msm_device_sdio_al = {
5353 .name = "msm_sdio_al",
5354 .id = -1,
5355 .dev = {
5356 .platform_data = &sdio_al_pdata,
5357 },
5358};
5359
5360#endif /* CONFIG_MSM_SDIO_AL */
5361
Daniel Walker8d747cd2010-02-25 11:37:43 -08005362static struct platform_device *devices[] __initdata = {
Daniel Walker90e37c52010-05-12 14:24:15 -07005363#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005364 &msm_device_uart2,
5365#endif
Justin Paupore637a25d2011-07-14 17:11:04 -07005366#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
5367 &msm_proccomm_regulator_dev,
5368#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005369 &asoc_msm_pcm,
5370 &asoc_msm_dai0,
5371 &asoc_msm_dai1,
5372#if defined (CONFIG_SND_MSM_MVS_DAI_SOC)
5373 &asoc_msm_mvs,
5374 &asoc_mvs_dai0,
5375 &asoc_mvs_dai1,
Daniel Walker90e37c52010-05-12 14:24:15 -07005376#endif
Niranjana Vishwanathapuraa8855e92010-10-06 13:52:10 -07005377 &msm_device_smd,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005378 &msm_device_dmov,
5379 &smc91x_device,
5380 &smsc911x_device,
5381 &msm_device_nand,
5382#ifdef CONFIG_USB_MSM_OTG_72K
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05305383 &msm_device_otg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005384#ifdef CONFIG_USB_GADGET
5385 &msm_device_gadget_peripheral,
5386#endif
5387#endif
5388#ifdef CONFIG_USB_G_ANDROID
5389 &android_usb_device,
5390#endif
5391 &qsd_device_spi,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305392
5393#ifdef CONFIG_MSM_SSBI
5394 &msm_device_ssbi_pmic1,
5395#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005396#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005397 &msm_device_ssbi7,
5398#endif
5399 &android_pmem_device,
5400 &msm_fb_device,
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08005401#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
5402 &msm_v4l2_video_overlay_device,
5403#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005404 &msm_migrate_pages_device,
5405 &mddi_toshiba_device,
5406 &lcdc_toshiba_panel_device,
5407#ifdef CONFIG_MSM_ROTATOR
5408 &msm_rotator_device,
5409#endif
5410 &lcdc_sharp_panel_device,
5411 &android_pmem_adsp_device,
5412 &android_pmem_audio_device,
5413 &msm_device_i2c,
5414 &msm_device_i2c_2,
5415 &msm_device_uart_dm1,
5416 &hs_device,
5417#ifdef CONFIG_MSM7KV2_AUDIO
5418 &msm_aictl_device,
5419 &msm_mi2s_device,
5420 &msm_lpa_device,
5421 &msm_aux_pcm_device,
5422#endif
5423 &msm_device_adspdec,
5424 &qup_device_i2c,
5425#if defined(CONFIG_MARIMBA_CORE) && \
5426 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5427 &msm_bt_power_device,
5428#endif
5429 &msm_kgsl_3d0,
5430 &msm_kgsl_2d0,
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005431#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005432#ifdef CONFIG_MT9T013
5433 &msm_camera_sensor_mt9t013,
5434#endif
5435#ifdef CONFIG_MT9D112
5436 &msm_camera_sensor_mt9d112,
5437#endif
5438#ifdef CONFIG_WEBCAM_OV9726
5439 &msm_camera_sensor_ov9726,
5440#endif
5441#ifdef CONFIG_S5K3E2FX
5442 &msm_camera_sensor_s5k3e2fx,
5443#endif
5444#ifdef CONFIG_MT9P012
5445 &msm_camera_sensor_mt9p012,
5446#endif
5447#ifdef CONFIG_MT9E013
5448 &msm_camera_sensor_mt9e013,
5449#endif
5450#ifdef CONFIG_VX6953
5451 &msm_camera_sensor_vx6953,
5452#endif
5453#ifdef CONFIG_SN12M0PZ
5454 &msm_camera_sensor_sn12m0pz,
5455#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005456#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005457 &msm_device_vidc_720p,
5458#ifdef CONFIG_MSM_GEMINI
5459 &msm_gemini_device,
5460#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005461#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005462#ifdef CONFIG_MSM_VPE
5463 &msm_vpe_device,
5464#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005465#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005466#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5467 &msm_device_tsif,
5468#endif
5469#ifdef CONFIG_MSM_SDIO_AL
5470 &msm_device_sdio_al,
5471#endif
5472
5473#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5474 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5475 &qcrypto_device,
5476#endif
5477
5478#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5479 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5480 &qcedev_device,
5481#endif
5482
5483 &msm_batt_device,
5484 &msm_adc_device,
5485 &msm_ebi0_thermal,
Laxminath Kasam1d8255d2012-02-15 13:10:19 +05305486 &msm_ebi1_thermal,
5487 &msm_adsp_device
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005488};
5489
5490static struct msm_gpio msm_i2c_gpios_hw[] = {
5491 { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5492 { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5493};
5494
5495static struct msm_gpio msm_i2c_gpios_io[] = {
5496 { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5497 { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5498};
5499
5500static struct msm_gpio qup_i2c_gpios_io[] = {
5501 { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5502 { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5503};
5504static struct msm_gpio qup_i2c_gpios_hw[] = {
5505 { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5506 { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5507};
5508
5509static void
5510msm_i2c_gpio_config(int adap_id, int config_type)
5511{
5512 struct msm_gpio *msm_i2c_table;
5513
5514 /* Each adapter gets 2 lines from the table */
5515 if (adap_id > 0)
5516 return;
5517 if (config_type)
5518 msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
5519 else
5520 msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
5521 msm_gpios_enable(msm_i2c_table, 2);
5522}
5523/*This needs to be enabled only for OEMS*/
5524#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005525static struct regulator *qup_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005526#endif
5527static void
5528qup_i2c_gpio_config(int adap_id, int config_type)
5529{
5530 int rc = 0;
5531 struct msm_gpio *qup_i2c_table;
5532 /* Each adapter gets 2 lines from the table */
5533 if (adap_id != 4)
5534 return;
5535 if (config_type)
5536 qup_i2c_table = qup_i2c_gpios_hw;
5537 else
5538 qup_i2c_table = qup_i2c_gpios_io;
5539 rc = msm_gpios_enable(qup_i2c_table, 2);
5540 if (rc < 0)
5541 printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
5542 /*This needs to be enabled only for OEMS*/
5543#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005544 if (!IS_ERR_OR_NULL(qup_vreg)) {
5545 rc = regulator_enable(qup_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005546 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005547 pr_err("%s: regulator_enable failed: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005548 __func__, rc);
5549 }
5550 }
5551#endif
5552}
5553
5554static struct msm_i2c_platform_data msm_i2c_pdata = {
5555 .clk_freq = 100000,
5556 .pri_clk = 70,
5557 .pri_dat = 71,
5558 .rmutex = 1,
5559 .rsl_id = "D:I2C02000021",
5560 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5561};
5562
5563static void __init msm_device_i2c_init(void)
5564{
5565 if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
5566 pr_err("failed to request I2C gpios\n");
5567
5568 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
5569}
5570
5571static struct msm_i2c_platform_data msm_i2c_2_pdata = {
5572 .clk_freq = 100000,
5573 .rmutex = 1,
5574 .rsl_id = "D:I2C02000022",
5575 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5576};
5577
5578static void __init msm_device_i2c_2_init(void)
5579{
5580 msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
5581}
5582
5583static struct msm_i2c_platform_data qup_i2c_pdata = {
5584 .clk_freq = 384000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005585 .msm_i2c_config_gpio = qup_i2c_gpio_config,
5586};
5587
5588static void __init qup_device_i2c_init(void)
5589{
5590 if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
5591 pr_err("failed to request I2C gpios\n");
5592
5593 qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
5594 /*This needs to be enabled only for OEMS*/
5595#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005596 qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005597 if (IS_ERR(qup_vreg)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005598 dev_err(&qup_device_i2c.dev,
5599 "%s: regulator_get failed: %ld\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005600 __func__, PTR_ERR(qup_vreg));
5601 }
5602#endif
5603}
5604
5605#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005606static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = {
5607 .rsl_id = "D:CODEC_SSBI",
5608 .controller_type = MSM_SBI_CTRL_SSBI,
5609};
5610#endif
5611
Daniel Walker8d747cd2010-02-25 11:37:43 -08005612static void __init msm7x30_init_irq(void)
5613{
5614 msm_init_irq();
5615}
5616
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005617static struct msm_gpio msm_nand_ebi2_cfg_data[] = {
5618 {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
5619 {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
5620};
5621
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005622#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
5623 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
5624 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
5625 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
5626
5627struct sdcc_gpio {
5628 struct msm_gpio *cfg_data;
5629 uint32_t size;
5630 struct msm_gpio *sleep_cfg_data;
5631};
5632#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5633static struct msm_gpio sdc1_lvlshft_cfg_data[] = {
5634 {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
5635};
5636#endif
5637static struct msm_gpio sdc1_cfg_data[] = {
5638 {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
5639 {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
5640 {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
5641 {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
5642 {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
5643 {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
5644};
5645
5646static struct msm_gpio sdc2_cfg_data[] = {
5647 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
5648 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
5649 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
5650 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
5651 {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
5652 {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
5653
5654#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5655 {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
5656 {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
5657 {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
5658 {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
5659#endif
5660};
5661
5662static struct msm_gpio sdc3_cfg_data[] = {
5663 {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
5664 {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
5665 {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
5666 {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
5667 {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
5668 {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
5669};
5670
5671static struct msm_gpio sdc3_sleep_cfg_data[] = {
5672 {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5673 "sdc3_clk"},
5674 {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5675 "sdc3_cmd"},
5676 {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5677 "sdc3_dat_3"},
5678 {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5679 "sdc3_dat_2"},
5680 {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5681 "sdc3_dat_1"},
5682 {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5683 "sdc3_dat_0"},
5684};
5685
5686static struct msm_gpio sdc4_cfg_data[] = {
5687 {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
5688 {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
5689 {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
5690 {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
5691 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
5692 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
5693};
5694
5695static struct sdcc_gpio sdcc_cfg_data[] = {
5696 {
5697 .cfg_data = sdc1_cfg_data,
5698 .size = ARRAY_SIZE(sdc1_cfg_data),
5699 .sleep_cfg_data = NULL,
5700 },
5701 {
5702 .cfg_data = sdc2_cfg_data,
5703 .size = ARRAY_SIZE(sdc2_cfg_data),
5704 .sleep_cfg_data = NULL,
5705 },
5706 {
5707 .cfg_data = sdc3_cfg_data,
5708 .size = ARRAY_SIZE(sdc3_cfg_data),
5709 .sleep_cfg_data = sdc3_sleep_cfg_data,
5710 },
5711 {
5712 .cfg_data = sdc4_cfg_data,
5713 .size = ARRAY_SIZE(sdc4_cfg_data),
5714 .sleep_cfg_data = NULL,
5715 },
5716};
5717
Justin Paupore3f40f342011-08-10 18:52:16 -07005718static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005719
5720static unsigned long vreg_sts, gpio_sts;
5721
5722static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
5723{
5724 int rc = 0;
5725 struct sdcc_gpio *curr;
5726
5727 curr = &sdcc_cfg_data[dev_id - 1];
5728
5729 if (!(test_bit(dev_id, &gpio_sts)^enable))
5730 return rc;
5731
5732 if (enable) {
5733 set_bit(dev_id, &gpio_sts);
5734 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
5735 if (rc)
5736 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
5737 __func__, dev_id);
5738 } else {
5739 clear_bit(dev_id, &gpio_sts);
5740 if (curr->sleep_cfg_data) {
5741 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
5742 msm_gpios_free(curr->sleep_cfg_data, curr->size);
5743 } else {
5744 msm_gpios_disable_free(curr->cfg_data, curr->size);
5745 }
5746 }
5747
5748 return rc;
5749}
5750
5751static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
5752{
5753 int rc = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005754 struct regulator *curr = sdcc_vreg_data[dev_id - 1];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005755 static int enabled_once[] = {0, 0, 0, 0};
5756
Justin Paupore3f40f342011-08-10 18:52:16 -07005757 if (test_bit(dev_id, &vreg_sts) == enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005758 return rc;
5759
Asutosh Das853bbcd2012-02-01 10:40:05 +05305760 if (dev_id == 4) {
5761 if (enable) {
5762 pr_debug("Enable Vdd dev_%d\n", dev_id);
5763 gpio_set_value_cansleep(
5764 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5765 0);
5766 set_bit(dev_id, &vreg_sts);
5767 } else {
5768 pr_debug("Disable Vdd dev_%d\n", dev_id);
5769 gpio_set_value_cansleep(
5770 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5771 1);
5772 clear_bit(dev_id, &vreg_sts);
5773 }
5774 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005775
Asutosh Das853bbcd2012-02-01 10:40:05 +05305776 if (!enable || enabled_once[dev_id - 1])
5777 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005778 if (!curr)
5779 return -ENODEV;
5780
5781 if (IS_ERR(curr))
5782 return PTR_ERR(curr);
5783
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005784 if (enable) {
5785 set_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005786
5787 rc = regulator_enable(curr);
5788 if (rc)
5789 pr_err("%s: could not enable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005790 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005791 enabled_once[dev_id - 1] = 1;
5792 } else {
5793 clear_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005794
5795 rc = regulator_disable(curr);
5796 if (rc)
5797 pr_err("%s: could not disable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005798 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005799 }
5800 return rc;
5801}
5802
5803static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
5804{
5805 int rc = 0;
5806 struct platform_device *pdev;
5807
5808 pdev = container_of(dv, struct platform_device, dev);
5809 rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
5810 if (rc)
5811 goto out;
5812
5813 if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
5814 rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
5815out:
5816 return rc;
5817}
5818
5819#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \
5820 defined(CONFIG_CSDIO_VENDOR_ID) && \
5821 defined(CONFIG_CSDIO_DEVICE_ID) && \
5822 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5823
5824#define MBP_ON 1
5825#define MBP_OFF 0
5826
5827#define MBP_RESET_N \
5828 GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
5829#define MBP_INT0 \
5830 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
5831
5832#define MBP_MODE_CTRL_0 \
5833 GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5834#define MBP_MODE_CTRL_1 \
5835 GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5836#define MBP_MODE_CTRL_2 \
5837 GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5838#define TSIF_EN \
5839 GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5840#define TSIF_DATA \
5841 GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5842#define TSIF_CLK \
5843 GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5844
5845static struct msm_gpio mbp_cfg_data[] = {
5846 {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5847 "mbp_reset"},
5848 {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5849 "mbp_io_voltage"},
5850};
5851
5852static int mbp_config_gpios_pre_init(int enable)
5853{
5854 int rc = 0;
5855
5856 if (enable) {
5857 rc = msm_gpios_request_enable(mbp_cfg_data,
5858 ARRAY_SIZE(mbp_cfg_data));
5859 if (rc) {
5860 printk(KERN_ERR
5861 "%s: Failed to turnon GPIOs for mbp chip(%d)\n",
5862 __func__, rc);
5863 }
5864 } else
5865 msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
5866 return rc;
5867}
5868
Justin Paupore3f40f342011-08-10 18:52:16 -07005869static struct regulator_bulk_data mbp_regs_io[2];
5870static struct regulator_bulk_data mbp_regs_rf[2];
5871static struct regulator_bulk_data mbp_regs_adc[1];
5872static struct regulator_bulk_data mbp_regs_core[1];
5873
5874static int mbp_init_regs(struct device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005875{
Justin Paupore3f40f342011-08-10 18:52:16 -07005876 struct regulator_bulk_data regs[] = {
5877 /* Analog and I/O regs */
5878 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
5879 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
5880 /* RF regs */
5881 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
5882 { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 },
5883 /* ADC regs */
5884 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
5885 /* Core regs */
5886 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
5887 };
5888
5889 struct regulator_bulk_data *regptr = regs;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005890 int rc;
5891
Justin Paupore3f40f342011-08-10 18:52:16 -07005892 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs);
5893
5894 if (rc) {
5895 dev_err(dev, "%s: could not get regulators: %d\n",
5896 __func__, rc);
5897 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005898 }
5899
Justin Paupore3f40f342011-08-10 18:52:16 -07005900 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005901
Justin Paupore3f40f342011-08-10 18:52:16 -07005902 if (rc) {
5903 dev_err(dev, "%s: could not set voltages: %d\n",
5904 __func__, rc);
5905 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005906 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005907
5908 memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io));
5909 regptr += ARRAY_SIZE(mbp_regs_io);
5910
5911 memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf));
5912 regptr += ARRAY_SIZE(mbp_regs_rf);
5913
5914 memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc));
5915 regptr += ARRAY_SIZE(mbp_regs_adc);
5916
5917 memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core));
5918
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005919 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005920
5921reg_free:
5922 regulator_bulk_free(ARRAY_SIZE(regs), regs);
5923out:
5924 return rc;
5925}
5926
5927static int mbp_setup_rf_vregs(int state)
5928{
5929 return state ?
5930 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) :
5931 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005932}
5933
5934static int mbp_setup_vregs(int state)
5935{
Justin Paupore3f40f342011-08-10 18:52:16 -07005936 return state ?
5937 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) :
5938 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005939}
5940
5941static int mbp_set_tcxo_en(int enable)
5942{
5943 int rc;
5944 const char *id = "UBMC";
5945 struct vreg *vreg_analog = NULL;
5946
5947 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
5948 enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
5949 if (rc < 0) {
5950 printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
5951 __func__, enable ? "" : "de-");
5952 return -EIO;
5953 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005954 return rc;
5955}
5956
5957static void mbp_set_freeze_io(int state)
5958{
5959 if (state)
5960 gpio_set_value(85, 0);
5961 else
5962 gpio_set_value(85, 1);
5963}
5964
5965static int mbp_set_core_voltage_en(int enable)
5966{
Justin Paupore3f40f342011-08-10 18:52:16 -07005967 static bool is_enabled;
5968 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005969
Justin Paupore3f40f342011-08-10 18:52:16 -07005970 if (enable && !is_enabled) {
5971 rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core),
5972 mbp_regs_core);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005973 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005974 pr_err("%s: could not enable regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005975 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07005976 } else {
5977 is_enabled = true;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005978 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005979 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005980
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005981 return rc;
5982}
5983
5984static void mbp_set_reset(int state)
5985{
5986 if (state)
5987 gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
5988 else
5989 gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
5990}
5991
5992static int mbp_config_interface_mode(int state)
5993{
5994 if (state) {
5995 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
5996 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
5997 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
5998 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
5999 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
6000 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
6001 } else {
6002 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
6003 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
6004 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
6005 }
6006 return 0;
6007}
6008
6009static int mbp_setup_adc_vregs(int state)
6010{
Justin Paupore3f40f342011-08-10 18:52:16 -07006011 return state ?
6012 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) :
6013 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006014}
6015
6016static int mbp_power_up(void)
6017{
6018 int rc;
6019
6020 rc = mbp_config_gpios_pre_init(MBP_ON);
6021 if (rc)
6022 goto exit;
6023 pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__);
6024
6025 rc = mbp_setup_vregs(MBP_ON);
6026 if (rc)
6027 goto exit;
6028 pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
6029
6030 rc = mbp_set_tcxo_en(MBP_ON);
6031 if (rc)
6032 goto exit;
6033 pr_debug("%s: tcxo clock done\n", __func__);
6034
6035 mbp_set_freeze_io(MBP_OFF);
6036 pr_debug("%s: set gpio 85 to 1 done\n", __func__);
6037
6038 udelay(100);
6039 mbp_set_reset(MBP_ON);
6040
6041 udelay(300);
6042 rc = mbp_config_interface_mode(MBP_ON);
6043 if (rc)
6044 goto exit;
6045 pr_debug("%s: mbp_config_interface_mode() done\n", __func__);
6046
6047 udelay(100 + mbp_set_core_voltage_en(MBP_ON));
6048 pr_debug("%s: power gp16 1.2V done\n", __func__);
6049
6050 mbp_set_freeze_io(MBP_ON);
6051 pr_debug("%s: set gpio 85 to 0 done\n", __func__);
6052
6053 udelay(100);
6054
6055 rc = mbp_setup_rf_vregs(MBP_ON);
6056 if (rc)
6057 goto exit;
6058 pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
6059
6060 rc = mbp_setup_adc_vregs(MBP_ON);
6061 if (rc)
6062 goto exit;
6063 pr_debug("%s: s4 2.2V done\n", __func__);
6064
6065 udelay(200);
6066
6067 mbp_set_reset(MBP_OFF);
6068 pr_debug("%s: close gpio 44 done\n", __func__);
6069
6070 msleep(20);
6071exit:
6072 return rc;
6073}
6074
6075static int mbp_power_down(void)
6076{
6077 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006078
6079 mbp_set_reset(MBP_ON);
6080 pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
6081
6082 udelay(100);
6083
6084 rc = mbp_setup_adc_vregs(MBP_OFF);
6085 if (rc)
6086 goto exit;
6087 pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
6088
6089 udelay(5);
6090
6091 rc = mbp_setup_rf_vregs(MBP_OFF);
6092 if (rc)
6093 goto exit;
6094 pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
6095
6096 udelay(5);
6097
6098 mbp_set_freeze_io(MBP_OFF);
6099 pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
6100
6101 udelay(100);
6102 rc = mbp_set_core_voltage_en(MBP_OFF);
6103 if (rc)
6104 goto exit;
6105 pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
6106
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006107 rc = mbp_set_tcxo_en(MBP_OFF);
6108 if (rc)
6109 goto exit;
6110 pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
6111
Justin Paupore3f40f342011-08-10 18:52:16 -07006112 rc = mbp_setup_vregs(MBP_OFF);
6113 if (rc)
6114 goto exit;
6115 pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__);
6116
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006117 rc = mbp_config_gpios_pre_init(MBP_OFF);
6118 if (rc)
6119 goto exit;
6120exit:
6121 return rc;
6122}
6123
6124static void (*mbp_status_notify_cb)(int card_present, void *dev_id);
6125static void *mbp_status_notify_cb_devid;
6126static int mbp_power_status;
6127static int mbp_power_init_done;
6128
6129static uint32_t mbp_setup_power(struct device *dv,
6130 unsigned int power_status)
6131{
6132 int rc = 0;
6133 struct platform_device *pdev;
6134
6135 pdev = container_of(dv, struct platform_device, dev);
6136
6137 if (power_status == mbp_power_status)
6138 goto exit;
6139 if (power_status) {
6140 pr_debug("turn on power of mbp slot");
6141 rc = mbp_power_up();
6142 mbp_power_status = 1;
6143 } else {
6144 pr_debug("turn off power of mbp slot");
6145 rc = mbp_power_down();
6146 mbp_power_status = 0;
6147 }
6148exit:
6149 return rc;
6150};
6151
6152int mbp_register_status_notify(void (*callback)(int, void *),
6153 void *dev_id)
6154{
6155 mbp_status_notify_cb = callback;
6156 mbp_status_notify_cb_devid = dev_id;
6157 return 0;
6158}
6159
6160static unsigned int mbp_status(struct device *dev)
6161{
6162 return mbp_power_status;
6163}
6164
6165static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd)
6166{
6167 struct platform_device *pdev;
6168 uint32_t rc = 0;
6169
6170 pdev = container_of(dv, struct platform_device, dev);
6171 rc = msm_sdcc_setup_power(dv, vdd);
6172 if (rc) {
6173 pr_err("%s: Failed to setup power (%d)\n",
6174 __func__, rc);
6175 goto out;
6176 }
6177 if (!mbp_power_init_done) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006178 rc = mbp_init_regs(dv);
6179 if (rc) {
6180 dev_err(dv, "%s: regulator init failed: %d\n",
6181 __func__, rc);
6182 goto out;
6183 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006184 mbp_setup_power(dv, 1);
6185 mbp_setup_power(dv, 0);
6186 mbp_power_init_done = 1;
6187 }
6188 if (vdd >= 0x8000) {
6189 rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
6190 if (rc) {
6191 pr_err("%s: Failed to config mbp chip power (%d)\n",
6192 __func__, rc);
6193 goto out;
6194 }
6195 if (mbp_status_notify_cb) {
6196 mbp_status_notify_cb(mbp_power_status,
6197 mbp_status_notify_cb_devid);
6198 }
6199 }
6200out:
6201 /* should return 0 only */
6202 return 0;
6203}
6204
6205#endif
6206
6207#endif
6208
6209#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6210#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6211static unsigned int msm7x30_sdcc_slot_status(struct device *dev)
6212{
6213 return (unsigned int)
6214 gpio_get_value_cansleep(
6215 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1));
6216}
6217#endif
6218
6219static int msm_sdcc_get_wpswitch(struct device *dv)
6220{
6221 void __iomem *wp_addr = 0;
6222 uint32_t ret = 0;
6223 struct platform_device *pdev;
6224
6225 if (!(machine_is_msm7x30_surf()))
6226 return -1;
6227 pdev = container_of(dv, struct platform_device, dev);
6228
6229 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
6230 if (!wp_addr) {
6231 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
6232 return -ENOMEM;
6233 }
6234
6235 ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
6236 pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
6237 pdev->id, ret);
6238 iounmap(wp_addr);
6239
6240 return ret;
6241}
6242#endif
6243
6244#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
6245#if defined(CONFIG_CSDIO_VENDOR_ID) && \
6246 defined(CONFIG_CSDIO_DEVICE_ID) && \
6247 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
6248static struct mmc_platform_data msm7x30_sdc1_data = {
6249 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
6250 .translate_vdd = msm_sdcc_setup_power_mbp,
6251 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6252 .status = mbp_status,
6253 .register_status_notify = mbp_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006254 .msmsdcc_fmin = 144000,
6255 .msmsdcc_fmid = 24576000,
6256 .msmsdcc_fmax = 24576000,
6257 .nonremovable = 0,
6258};
6259#else
6260static struct mmc_platform_data msm7x30_sdc1_data = {
6261 .ocr_mask = MMC_VDD_165_195,
6262 .translate_vdd = msm_sdcc_setup_power,
6263 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006264 .msmsdcc_fmin = 144000,
6265 .msmsdcc_fmid = 24576000,
6266 .msmsdcc_fmax = 49152000,
6267 .nonremovable = 0,
6268};
6269#endif
6270#endif
6271
6272#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
6273static struct mmc_platform_data msm7x30_sdc2_data = {
6274 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
6275 .translate_vdd = msm_sdcc_setup_power,
6276#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
6277 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
6278#else
6279 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6280#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006281 .msmsdcc_fmin = 144000,
6282 .msmsdcc_fmid = 24576000,
6283 .msmsdcc_fmax = 49152000,
6284 .nonremovable = 1,
6285};
6286#endif
6287
6288#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
6289static struct mmc_platform_data msm7x30_sdc3_data = {
6290 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6291 .translate_vdd = msm_sdcc_setup_power,
6292 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006293 .sdiowakeup_irq = MSM_GPIO_TO_INT(118),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006294 .msmsdcc_fmin = 144000,
6295 .msmsdcc_fmid = 24576000,
6296 .msmsdcc_fmax = 49152000,
6297 .nonremovable = 0,
6298};
6299#endif
6300
6301#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6302static struct mmc_platform_data msm7x30_sdc4_data = {
6303 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6304 .translate_vdd = msm_sdcc_setup_power,
6305 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6306#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6307 .status = msm7x30_sdcc_slot_status,
6308 .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
6309 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
6310#endif
6311 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006312 .msmsdcc_fmin = 144000,
6313 .msmsdcc_fmid = 24576000,
6314 .msmsdcc_fmax = 49152000,
6315 .nonremovable = 0,
6316};
6317#endif
6318
6319#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006320static int msm_sdc1_lvlshft_enable(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006321{
Justin Paupore3f40f342011-08-10 18:52:16 -07006322 static struct regulator *ldo5;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006323 int rc;
6324
6325 /* Enable LDO5, an input to the FET that powers slot 1 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006326
Justin Paupore3f40f342011-08-10 18:52:16 -07006327 ldo5 = regulator_get(NULL, "ldo5");
6328
6329 if (IS_ERR(ldo5)) {
6330 rc = PTR_ERR(ldo5);
6331 pr_err("%s: could not get ldo5: %d\n", __func__, rc);
6332 goto out;
6333 }
6334
6335 rc = regulator_set_voltage(ldo5, 2850000, 2850000);
6336 if (rc) {
6337 pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc);
6338 goto ldo5_free;
6339 }
6340
6341 rc = regulator_enable(ldo5);
6342 if (rc) {
6343 pr_err("%s: could not enable ldo5: %d\n", __func__, rc);
6344 goto ldo5_free;
6345 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006346
6347 /* Enable GPIO 35, to turn on the FET that powers slot 1 */
6348 rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
6349 ARRAY_SIZE(sdc1_lvlshft_cfg_data));
6350 if (rc)
6351 printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
6352
6353 rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg),
6354 1);
6355 if (rc)
6356 printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006357
6358 return 0;
6359
6360ldo5_free:
6361 regulator_put(ldo5);
6362out:
6363 ldo5 = NULL;
6364 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006365}
6366#endif
6367
Justin Paupore3f40f342011-08-10 18:52:16 -07006368static int mmc_regulator_init(int sdcc_no, const char *supply, int uV)
6369{
6370 int rc;
6371
6372 BUG_ON(sdcc_no < 1 || sdcc_no > 4);
6373
6374 sdcc_no--;
6375
6376 sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply);
6377
6378 if (IS_ERR(sdcc_vreg_data[sdcc_no])) {
6379 rc = PTR_ERR(sdcc_vreg_data[sdcc_no]);
6380 pr_err("%s: could not get regulator \"%s\": %d\n",
6381 __func__, supply, rc);
6382 goto out;
6383 }
6384
6385 rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV);
6386
6387 if (rc) {
6388 pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n",
6389 __func__, supply, uV, rc);
6390 goto reg_free;
6391 }
6392
6393 return rc;
6394
6395reg_free:
6396 regulator_put(sdcc_vreg_data[sdcc_no]);
6397out:
6398 sdcc_vreg_data[sdcc_no] = NULL;
6399 return rc;
6400}
6401
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006402static void __init msm7x30_init_mmc(void)
6403{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006404#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006405 if (mmc_regulator_init(1, "s3", 1800000))
6406 goto out1;
6407
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006408 if (machine_is_msm7x30_fluid()) {
6409 msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
Justin Paupore3f40f342011-08-10 18:52:16 -07006410 if (msm_sdc1_lvlshft_enable()) {
6411 pr_err("%s: could not enable level shift\n");
6412 goto out1;
6413 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006414 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006415
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006416 msm_add_sdcc(1, &msm7x30_sdc1_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006417out1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006418#endif
6419#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006420 if (mmc_regulator_init(2, "s3", 1800000))
6421 goto out2;
6422
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006423 if (machine_is_msm8x55_svlte_surf())
6424 msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
Sujith Reddy Thumma84a0f512011-08-29 09:57:03 +05306425 if (machine_is_msm8x55_svlte_surf() ||
6426 machine_is_msm8x55_svlte_ffa()) {
6427 msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
6428 msm7x30_sdc2_data.is_sdio_al_client = 1;
6429 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006430
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006431 msm_add_sdcc(2, &msm7x30_sdc2_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006432out2:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006433#endif
6434#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006435 if (mmc_regulator_init(3, "s3", 1800000))
6436 goto out3;
6437
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006438 msm_sdcc_setup_gpio(3, 1);
6439 msm_add_sdcc(3, &msm7x30_sdc3_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006440out3:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006441#endif
6442#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006443 if (mmc_regulator_init(4, "mmc", 2850000))
6444 return;
6445
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006446 msm_add_sdcc(4, &msm7x30_sdc4_data);
6447#endif
6448
6449}
6450
6451static void __init msm7x30_init_nand(void)
6452{
6453 char *build_id;
6454 struct flash_platform_data *plat_data;
6455
6456 build_id = socinfo_get_build_id();
6457 if (build_id == NULL) {
6458 pr_err("%s: Build ID not available from socinfo\n", __func__);
6459 return;
6460 }
6461
6462 if (build_id[8] == 'C' &&
6463 !msm_gpios_request_enable(msm_nand_ebi2_cfg_data,
6464 ARRAY_SIZE(msm_nand_ebi2_cfg_data))) {
6465 plat_data = msm_device_nand.dev.platform_data;
6466 plat_data->interleave = 1;
6467 printk(KERN_INFO "%s: Interleave mode Build ID found\n",
6468 __func__);
6469 }
6470}
6471
6472#ifdef CONFIG_SERIAL_MSM_CONSOLE
6473static struct msm_gpio uart2_config_data[] = {
6474 { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
6475 { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
6476 { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
6477 { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
6478};
6479
6480static void msm7x30_init_uart2(void)
6481{
6482 msm_gpios_request_enable(uart2_config_data,
6483 ARRAY_SIZE(uart2_config_data));
6484
6485}
6486#endif
6487
6488/* TSIF begin */
6489#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6490
6491#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6492#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6493#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6494#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6495
6496static const struct msm_gpio tsif_gpios[] = {
6497 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
6498 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
6499 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
6500 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
6501};
6502
6503static struct msm_tsif_platform_data tsif_platform_data = {
6504 .num_gpios = ARRAY_SIZE(tsif_gpios),
6505 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -07006506 .tsif_pclk = "iface_clk",
6507 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006508};
6509#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
6510/* TSIF end */
6511
6512static void __init pmic8058_leds_init(void)
6513{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306514 if (machine_is_msm7x30_surf())
6515 pm8058_7x30_data.leds_pdata = &pm8058_surf_leds_data;
6516 else if (!machine_is_msm7x30_fluid())
6517 pm8058_7x30_data.leds_pdata = &pm8058_ffa_leds_data;
6518 else if (machine_is_msm7x30_fluid())
6519 pm8058_7x30_data.leds_pdata = &pm8058_fluid_leds_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006520}
6521
6522static struct msm_spm_platform_data msm_spm_data __initdata = {
Taniya Das298de8c2012-02-16 11:45:31 +05306523 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006524
6525 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
6526 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
6527 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
6528 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
6529
6530 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
6531 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
6532 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
6533
6534 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
6535 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
6536 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
6537
6538 .awake_vlevel = 0xF2,
6539 .retention_vlevel = 0xE0,
6540 .collapse_vlevel = 0x72,
6541 .retention_mid_vlevel = 0xE0,
6542 .collapse_mid_vlevel = 0xE0,
6543
6544 .vctl_timeout_us = 50,
6545};
6546
6547#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6548 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6549
6550#define TSC2007_TS_PEN_INT 20
6551
6552static struct msm_gpio tsc2007_config_data[] = {
6553 { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
6554 "tsc2007_irq" },
6555};
6556
Justin Paupore3f40f342011-08-10 18:52:16 -07006557static struct regulator_bulk_data tsc2007_regs[] = {
6558 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
6559 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
6560};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006561
6562static int tsc2007_init(void)
6563{
6564 int rc;
6565
Justin Paupore3f40f342011-08-10 18:52:16 -07006566 rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006567
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006568 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006569 pr_err("%s: could not get regulators: %d\n", __func__, rc);
6570 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006571 }
6572
Justin Paupore3f40f342011-08-10 18:52:16 -07006573 rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6574
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006575 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006576 pr_err("%s: could not set voltages: %d\n", __func__, rc);
6577 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006578 }
6579
Justin Paupore3f40f342011-08-10 18:52:16 -07006580 rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006581
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006582 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006583 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
6584 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006585 }
6586
6587 rc = msm_gpios_request_enable(tsc2007_config_data,
6588 ARRAY_SIZE(tsc2007_config_data));
6589 if (rc) {
6590 pr_err("%s: Unable to request gpios\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006591 goto reg_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006592 }
6593
6594 return 0;
6595
Justin Paupore3f40f342011-08-10 18:52:16 -07006596reg_disable:
6597 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6598reg_free:
6599 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6600out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006601 return rc;
6602}
6603
6604static int tsc2007_get_pendown_state(void)
6605{
6606 int rc;
6607
6608 rc = gpio_get_value(TSC2007_TS_PEN_INT);
6609 if (rc < 0) {
6610 pr_err("%s: MSM GPIO %d read failed\n", __func__,
6611 TSC2007_TS_PEN_INT);
6612 return rc;
6613 }
6614
6615 return (rc == 0 ? 1 : 0);
6616}
6617
6618static void tsc2007_exit(void)
6619{
Justin Paupore3f40f342011-08-10 18:52:16 -07006620
6621 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6622 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006623
6624 msm_gpios_disable_free(tsc2007_config_data,
6625 ARRAY_SIZE(tsc2007_config_data));
6626}
6627
6628static int tsc2007_power_shutdown(bool enable)
6629{
6630 int rc;
6631
Justin Paupore3f40f342011-08-10 18:52:16 -07006632 rc = (enable == false) ?
6633 regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) :
6634 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6635
6636 if (rc) {
6637 pr_err("%s: could not %sable regulators: %d\n",
6638 __func__, enable ? "dis" : "en", rc);
6639 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006640 }
6641
Justin Paupore3f40f342011-08-10 18:52:16 -07006642 if (enable == false)
6643 msleep(20);
6644
6645 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006646}
6647
6648static struct tsc2007_platform_data tsc2007_ts_data = {
6649 .model = 2007,
6650 .x_plate_ohms = 300,
Anirudh Ghayala2cf2e22012-01-25 12:29:42 +05306651 .min_x = 210,
6652 .max_x = 3832,
6653 .min_y = 150,
6654 .max_y = 3936,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006655 .irq_flags = IRQF_TRIGGER_LOW,
6656 .init_platform_hw = tsc2007_init,
6657 .exit_platform_hw = tsc2007_exit,
6658 .power_shutdown = tsc2007_power_shutdown,
6659 .invert_x = true,
6660 .invert_y = true,
6661 /* REVISIT: Temporary fix for reversed pressure */
6662 .invert_z1 = true,
6663 .invert_z2 = true,
6664 .get_pendown_state = tsc2007_get_pendown_state,
6665};
6666
6667static struct i2c_board_info tsc_i2c_board_info[] = {
6668 {
6669 I2C_BOARD_INFO("tsc2007", 0x48),
6670 .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
6671 .platform_data = &tsc2007_ts_data,
6672 },
6673};
6674#endif
6675
Justin Paupore3f40f342011-08-10 18:52:16 -07006676static struct regulator_bulk_data regs_isa1200[] = {
6677 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
6678 { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006679};
6680
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006681static int isa1200_power(int vreg_on)
6682{
Justin Paupore3f40f342011-08-10 18:52:16 -07006683 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006684
Justin Paupore3f40f342011-08-10 18:52:16 -07006685 rc = vreg_on ?
6686 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) :
6687 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006688
Justin Paupore3f40f342011-08-10 18:52:16 -07006689 if (rc) {
6690 pr_err("%s: could not %sable regulators: %d\n",
6691 __func__, vreg_on ? "en" : "dis", rc);
6692 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006693 }
6694
6695 /* vote for DO buffer */
6696 rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO,
6697 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
6698 if (rc) {
6699 pr_err("%s: unable to %svote for d0 clk\n",
6700 __func__, vreg_on ? "" : "de-");
6701 goto vreg_fail;
6702 }
6703
6704 return 0;
6705
6706vreg_fail:
Justin Paupore3f40f342011-08-10 18:52:16 -07006707 if (vreg_on)
6708 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6709 else
6710 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6711out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006712 return rc;
6713}
6714
6715static int isa1200_dev_setup(bool enable)
6716{
Justin Paupore3f40f342011-08-10 18:52:16 -07006717 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006718
6719 if (enable == true) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006720 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200),
6721 regs_isa1200);
6722
6723 if (rc) {
6724 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006725 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006726 goto out;
6727 }
6728
6729 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200),
6730 regs_isa1200);
6731 if (rc) {
6732 pr_err("%s: could not set voltages: %d\n",
6733 __func__, rc);
6734 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006735 }
6736
6737 rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
6738 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
6739 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
6740 if (rc) {
6741 pr_err("%s: Could not configure gpio %d\n",
6742 __func__, HAP_LVL_SHFT_MSM_GPIO);
Justin Paupore3f40f342011-08-10 18:52:16 -07006743 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006744 }
6745
6746 rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
6747 if (rc) {
6748 pr_err("%s: unable to request gpio %d (%d)\n",
6749 __func__, HAP_LVL_SHFT_MSM_GPIO, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006750 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006751 }
6752
6753 gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
6754 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006755 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006756 gpio_free(HAP_LVL_SHFT_MSM_GPIO);
6757 }
6758
6759 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07006760
6761reg_free:
6762 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6763out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006764 return rc;
6765}
6766static struct isa1200_platform_data isa1200_1_pdata = {
6767 .name = "vibrator",
6768 .power_on = isa1200_power,
6769 .dev_setup = isa1200_dev_setup,
6770 .pwm_ch_id = 1, /*channel id*/
6771 /*gpio to enable haptic*/
6772 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka03122322011-09-09 15:15:43 +05306773 .hap_len_gpio = -1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006774 .max_timeout = 15000,
6775 .mode_ctrl = PWM_GEN_MODE,
6776 .pwm_fd = {
6777 .pwm_div = 256,
6778 },
6779 .is_erm = false,
6780 .smart_en = true,
6781 .ext_clk_en = true,
6782 .chip_en = 1,
6783};
6784
6785static struct i2c_board_info msm_isa1200_board_info[] = {
6786 {
6787 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
6788 .platform_data = &isa1200_1_pdata,
6789 },
6790};
6791
6792
6793static int kp_flip_mpp_config(void)
6794{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306795 struct pm8xxx_mpp_config_data kp_flip_mpp = {
6796 .type = PM8XXX_MPP_TYPE_D_INPUT,
6797 .level = PM8018_MPP_DIG_LEVEL_S3,
6798 .control = PM8XXX_MPP_DIN_TO_INT,
6799 };
6800
6801 return pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(PM_FLIP_MPP),
6802 &kp_flip_mpp);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006803}
6804
6805static struct flip_switch_pdata flip_switch_data = {
6806 .name = "kp_flip_switch",
6807 .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP,
6808 .left_key = KEY_OPEN,
6809 .right_key = KEY_CLOSE,
6810 .active_low = 0,
6811 .wakeup = 1,
6812 .flip_mpp_config = kp_flip_mpp_config,
6813};
6814
6815static struct platform_device flip_switch_device = {
6816 .name = "kp_flip_switch",
6817 .id = -1,
6818 .dev = {
6819 .platform_data = &flip_switch_data,
6820 }
6821};
6822
Justin Paupore3f40f342011-08-10 18:52:16 -07006823static struct regulator_bulk_data regs_tma300[] = {
6824 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
6825 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006826};
6827
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006828static int tma300_power(int vreg_on)
6829{
Justin Paupore3f40f342011-08-10 18:52:16 -07006830 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006831
Justin Paupore3f40f342011-08-10 18:52:16 -07006832 rc = vreg_on ?
6833 regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) :
6834 regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006835
Justin Paupore3f40f342011-08-10 18:52:16 -07006836 if (rc)
6837 pr_err("%s: could not %sable regulators: %d\n",
6838 __func__, vreg_on ? "en" : "dis", rc);
6839 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006840}
6841
6842#define TS_GPIO_IRQ 150
6843
6844static int tma300_dev_setup(bool enable)
6845{
Justin Paupore3f40f342011-08-10 18:52:16 -07006846 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006847
6848 if (enable) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006849 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300),
6850 regs_tma300);
6851
6852 if (rc) {
6853 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006854 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006855 goto out;
6856 }
6857
6858 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300),
6859 regs_tma300);
6860
6861 if (rc) {
6862 pr_err("%s: could not set voltages: %d\n",
6863 __func__, rc);
6864 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006865 }
6866
6867 /* enable interrupt gpio */
6868 rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
6869 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
6870 if (rc) {
6871 pr_err("%s: Could not configure gpio %d\n",
6872 __func__, TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -07006873 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006874 }
6875
6876 /* virtual keys */
6877 tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
6878 properties_kobj = kobject_create_and_add("board_properties",
6879 NULL);
6880 if (!properties_kobj) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006881 pr_err("%s: failed to create a kobject "
6882 "for board_properties\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006883 rc = -ENOMEM;
Justin Paupore3f40f342011-08-10 18:52:16 -07006884 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006885 }
6886 rc = sysfs_create_group(properties_kobj,
6887 &tma300_properties_attr_group);
6888 if (rc) {
6889 pr_err("%s: failed to create a sysfs entry %s\n",
6890 __func__, tma300_vkeys_attr.attr.name);
Justin Paupore3f40f342011-08-10 18:52:16 -07006891 goto kobj_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006892 }
6893 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006894 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006895 /* destroy virtual keys */
6896 if (properties_kobj) {
6897 sysfs_remove_group(properties_kobj,
6898 &tma300_properties_attr_group);
6899 kobject_put(properties_kobj);
6900 }
6901 }
6902 return 0;
6903
Justin Paupore3f40f342011-08-10 18:52:16 -07006904kobj_free:
6905 kobject_put(properties_kobj);
6906 properties_kobj = NULL;
6907reg_free:
6908 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
6909out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006910 return rc;
6911}
6912
6913static struct cy8c_ts_platform_data cy8ctma300_pdata = {
6914 .power_on = tma300_power,
6915 .dev_setup = tma300_dev_setup,
6916 .ts_name = "msm_tma300_ts",
6917 .dis_min_x = 0,
6918 .dis_max_x = 479,
6919 .dis_min_y = 0,
6920 .dis_max_y = 799,
6921 .res_x = 479,
6922 .res_y = 1009,
6923 .min_tid = 1,
6924 .max_tid = 255,
6925 .min_touch = 0,
6926 .max_touch = 255,
6927 .min_width = 0,
6928 .max_width = 255,
6929 .invert_y = 1,
6930 .nfingers = 4,
6931 .irq_gpio = TS_GPIO_IRQ,
6932 .resout_gpio = -1,
6933};
6934
6935static struct i2c_board_info cy8ctma300_board_info[] = {
6936 {
6937 I2C_BOARD_INFO("cy8ctma300", 0x2),
6938 .platform_data = &cy8ctma300_pdata,
6939 }
6940};
6941
Daniel Walker8d747cd2010-02-25 11:37:43 -08006942static void __init msm7x30_init(void)
6943{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006944 int rc;
6945 unsigned smem_size;
6946 uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56,
6947 0,
6948 GPIO_CFG_OUTPUT,
6949 GPIO_CFG_NO_PULL,
6950 GPIO_CFG_2MA);
6951 uint32_t soc_version = 0;
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05306952
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006953 soc_version = socinfo_get_version();
6954
Stephen Boydbb600ae2011-08-02 20:11:40 -07006955 msm_clock_init(&msm7x30_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006956#ifdef CONFIG_SERIAL_MSM_CONSOLE
6957 msm7x30_init_uart2();
6958#endif
6959 msm_spm_init(&msm_spm_data, 1);
Matt Wagantallec57f062011-08-16 23:54:46 -07006960 acpuclk_init(&acpuclk_7x30_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006961 if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid())
6962 msm7x30_cfg_smsc911x();
6963
6964#ifdef CONFIG_USB_MSM_OTG_72K
6965 if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 &&
6966 SOCINFO_VERSION_MINOR(soc_version) >= 1) {
6967 pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
6968 msm_otg_pdata.ldo_set_voltage = 0;
6969 }
6970
6971 msm_device_otg.dev.platform_data = &msm_otg_pdata;
6972#ifdef CONFIG_USB_GADGET
6973 msm_otg_pdata.swfi_latency =
6974 msm_pm_data
6975 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
6976 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
6977#endif
6978#endif
6979 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
6980 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
6981#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6982 msm_device_tsif.dev.platform_data = &tsif_platform_data;
6983#endif
6984 if (machine_is_msm7x30_fluid()) {
6985 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
6986 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
6987 } else {
6988 msm_adc_pdata.dev_names = msm_adc_surf_device_names;
6989 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names);
6990 }
6991
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306992 pmic8058_leds_init();
6993
6994 buses_init();
6995
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306996#ifdef CONFIG_MSM_SSBI
6997 msm_device_ssbi_pmic1.dev.platform_data =
6998 &msm7x30_ssbi_pm8058_pdata;
6999#endif
7000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007001 platform_add_devices(msm_footswitch_devices,
7002 msm_num_footswitch_devices);
Daniel Walker8d747cd2010-02-25 11:37:43 -08007003 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007004#ifdef CONFIG_USB_EHCI_MSM_72K
7005 msm_add_host(0, &msm_usb_host_pdata);
7006#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07007007#ifdef CONFIG_MSM_CAMERA_V4L2
7008 msm7x30_init_cam();
7009#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007010 msm7x30_init_mmc();
7011 msm7x30_init_nand();
7012 msm_qsd_spi_init();
7013
7014#ifdef CONFIG_SPI_QSD
7015 if (machine_is_msm7x30_fluid())
7016 spi_register_board_info(lcdc_sharp_spi_board_info,
7017 ARRAY_SIZE(lcdc_sharp_spi_board_info));
7018 else
7019 spi_register_board_info(lcdc_toshiba_spi_board_info,
7020 ARRAY_SIZE(lcdc_toshiba_spi_board_info));
7021#endif
7022
Justin Paupore3f40f342011-08-10 18:52:16 -07007023 atv_dac_power_init();
7024 sensors_ldo_init();
7025 hdmi_init_regs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007026 msm_fb_add_devices();
7027 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06007028 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05307029 msm_pm_register_irqs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007030 msm_device_i2c_init();
7031 msm_device_i2c_2_init();
7032 qup_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007033 msm7x30_init_marimba();
7034#ifdef CONFIG_MSM7KV2_AUDIO
7035 snddev_poweramp_gpio_init();
Justin Paupore3f40f342011-08-10 18:52:16 -07007036 snddev_hsed_voltage_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007037 aux_pcm_gpio_init();
7038#endif
7039
7040 i2c_register_board_info(0, msm_i2c_board_info,
7041 ARRAY_SIZE(msm_i2c_board_info));
7042
7043 if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid())
7044 marimba_pdata.tsadc = &marimba_tsadc_pdata;
7045
7046 if (machine_is_msm7x30_fluid())
7047 i2c_register_board_info(0, cy8info,
7048 ARRAY_SIZE(cy8info));
7049#ifdef CONFIG_BOSCH_BMA150
7050 if (machine_is_msm7x30_fluid())
7051 i2c_register_board_info(0, bma150_board_info,
7052 ARRAY_SIZE(bma150_board_info));
7053#endif
7054
7055 i2c_register_board_info(2, msm_marimba_board_info,
7056 ARRAY_SIZE(msm_marimba_board_info));
7057
7058 i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info,
7059 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info));
7060
7061 i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
7062 ARRAY_SIZE(msm_camera_boardinfo));
7063
7064 bt_power_init();
7065#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007066 msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
7067#endif
7068 if (machine_is_msm7x30_fluid())
7069 i2c_register_board_info(0, msm_isa1200_board_info,
7070 ARRAY_SIZE(msm_isa1200_board_info));
7071
7072#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
7073 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
7074 if (machine_is_msm8x55_svlte_ffa())
7075 i2c_register_board_info(2, tsc_i2c_board_info,
7076 ARRAY_SIZE(tsc_i2c_board_info));
7077#endif
7078
7079 if (machine_is_msm7x30_surf())
7080 platform_device_register(&flip_switch_device);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307081
7082 pm8058_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007083
7084 if (machine_is_msm7x30_fluid()) {
7085 /* Initialize platform data for fluid v2 hardware */
7086 if (SOCINFO_VERSION_MAJOR(
7087 socinfo_get_platform_version()) == 2) {
7088 cy8ctma300_pdata.res_y = 920;
7089 cy8ctma300_pdata.invert_y = 0;
7090 }
7091 i2c_register_board_info(0, cy8ctma300_board_info,
7092 ARRAY_SIZE(cy8ctma300_board_info));
7093 }
7094
7095 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
7096 rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE);
7097 if (rc)
7098 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
7099 __func__, usb_hub_gpio_cfg_value, rc);
7100 }
7101
7102 boot_reason = *(unsigned int *)
7103 (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
7104 printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
7105}
7106
7107static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
7108static int __init pmem_sf_size_setup(char *p)
7109{
7110 pmem_sf_size = memparse(p, NULL);
7111 return 0;
7112}
7113early_param("pmem_sf_size", pmem_sf_size_setup);
7114
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307115static unsigned fb_size;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007116static int __init fb_size_setup(char *p)
7117{
7118 fb_size = memparse(p, NULL);
7119 return 0;
7120}
7121early_param("fb_size", fb_size_setup);
7122
7123static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
7124static int __init pmem_adsp_size_setup(char *p)
7125{
7126 pmem_adsp_size = memparse(p, NULL);
7127 return 0;
7128}
7129early_param("pmem_adsp_size", pmem_adsp_size_setup);
7130
7131static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE;
7132static int __init fluid_pmem_adsp_size_setup(char *p)
7133{
7134 fluid_pmem_adsp_size = memparse(p, NULL);
7135 return 0;
7136}
7137early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup);
7138
7139static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
7140static int __init pmem_audio_size_setup(char *p)
7141{
7142 pmem_audio_size = memparse(p, NULL);
7143 return 0;
7144}
7145early_param("pmem_audio_size", pmem_audio_size_setup);
7146
7147static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE;
7148static int __init pmem_kernel_ebi0_size_setup(char *p)
7149{
7150 pmem_kernel_ebi0_size = memparse(p, NULL);
7151 return 0;
7152}
7153early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
7154
7155static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
7156 [MEMTYPE_SMI] = {
7157 },
7158 [MEMTYPE_EBI0] = {
7159 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7160 },
7161 [MEMTYPE_EBI1] = {
7162 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7163 },
7164};
7165
7166static void __init size_pmem_devices(void)
7167{
7168#ifdef CONFIG_ANDROID_PMEM
7169 unsigned long size;
7170
7171 if machine_is_msm7x30_fluid()
7172 size = fluid_pmem_adsp_size;
7173 else
7174 size = pmem_adsp_size;
7175 android_pmem_adsp_pdata.size = size;
7176 android_pmem_audio_pdata.size = pmem_audio_size;
7177 android_pmem_pdata.size = pmem_sf_size;
7178#endif
7179}
7180
7181static void __init reserve_memory_for(struct android_pmem_platform_data *p)
7182{
7183 msm7x30_reserve_table[p->memory_type].size += p->size;
7184}
7185
7186static void __init reserve_pmem_memory(void)
7187{
7188#ifdef CONFIG_ANDROID_PMEM
7189 reserve_memory_for(&android_pmem_adsp_pdata);
7190 reserve_memory_for(&android_pmem_audio_pdata);
7191 reserve_memory_for(&android_pmem_pdata);
7192 msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
7193#endif
7194}
7195
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307196static void __init reserve_mdp_memory(void)
7197{
7198 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
7199 msm7x30_reserve_table[mdp_pdata.mem_hid].size += mdp_pdata.ov0_wb_size;
7200}
7201
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007202static void __init msm7x30_calculate_reserve_sizes(void)
7203{
7204 size_pmem_devices();
7205 reserve_pmem_memory();
Mayank Chopraaed3b4b2012-02-29 11:54:18 +05307206 reserve_mdp_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007207}
7208
7209static int msm7x30_paddr_to_memtype(unsigned int paddr)
7210{
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307211 if (paddr < phys_add)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007212 return MEMTYPE_EBI0;
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307213 if (paddr >= phys_add && paddr < 0x80000000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007214 return MEMTYPE_EBI1;
7215 return MEMTYPE_NONE;
7216}
7217
7218static struct reserve_info msm7x30_reserve_info __initdata = {
7219 .memtype_reserve_table = msm7x30_reserve_table,
7220 .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes,
7221 .paddr_to_memtype = msm7x30_paddr_to_memtype,
7222};
7223
7224static void __init msm7x30_reserve(void)
7225{
7226 reserve_info = &msm7x30_reserve_info;
7227 msm_reserve();
7228}
7229
7230static void __init msm7x30_allocate_memory_regions(void)
7231{
7232 void *addr;
7233 unsigned long size;
7234
7235 size = fb_size ? : MSM_FB_SIZE;
7236 addr = alloc_bootmem_align(size, 0x1000);
7237 msm_fb_resources[0].start = __pa(addr);
7238 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
7239 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
7240 size, addr, __pa(addr));
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08007241
7242#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
7243 size = MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE;
7244 addr = alloc_bootmem_align(size, 0x1000);
7245 msm_v4l2_video_overlay_resources[0].start = __pa(addr);
7246 msm_v4l2_video_overlay_resources[0].end =
7247 msm_v4l2_video_overlay_resources[0].start + size - 1;
7248 pr_debug("allocating %lu bytes at %p (%lx physical) for v4l2\n",
7249 size, addr, __pa(addr));
7250#endif
Daniel Walker8d747cd2010-02-25 11:37:43 -08007251}
7252
7253static void __init msm7x30_map_io(void)
7254{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007255 msm_shared_ram_phys = 0x00100000;
Daniel Walker8d747cd2010-02-25 11:37:43 -08007256 msm_map_msm7x30_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007257 if (socinfo_init() < 0)
7258 printk(KERN_ERR "%s: socinfo_init() failed!\n",
7259 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007260}
7261
7262static void __init msm7x30_init_early(void)
7263{
7264 msm7x30_allocate_memory_regions();
Daniel Walker8d747cd2010-02-25 11:37:43 -08007265}
7266
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307267static void __init msm7x30_fixup(struct machine_desc *desc, struct tag *tags,
7268 char **cmdline, struct meminfo *mi)
7269{
7270 for (; tags->hdr.size; tags = tag_next(tags)) {
7271 if (tags->hdr.tag == ATAG_MEM && tags->u.mem.start ==
7272 DDR1_BANK_BASE) {
7273 ebi1_phys_offset = DDR1_BANK_BASE;
7274 phys_add = DDR1_BANK_BASE;
7275 break;
7276 }
7277 }
7278}
7279
Daniel Walker8d747cd2010-02-25 11:37:43 -08007280MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00007281 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007282 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007283 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007284 .init_irq = msm7x30_init_irq,
7285 .init_machine = msm7x30_init,
7286 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007287 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307288 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307289 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007290MACHINE_END
7291
7292MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00007293 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007294 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007295 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007296 .init_irq = msm7x30_init_irq,
7297 .init_machine = msm7x30_init,
7298 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007299 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307300 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307301 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007302MACHINE_END
7303
7304MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
Russell Kingb75c1782011-01-04 19:03:16 +00007305 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007306 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007307 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007308 .init_irq = msm7x30_init_irq,
7309 .init_machine = msm7x30_init,
7310 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007311 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307312 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307313 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007314MACHINE_END
7315
7316MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
7317 .boot_params = PHYS_OFFSET + 0x100,
7318 .map_io = msm7x30_map_io,
7319 .reserve = msm7x30_reserve,
7320 .init_irq = msm7x30_init_irq,
7321 .init_machine = msm7x30_init,
7322 .timer = &msm_timer,
7323 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307324 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307325 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007326MACHINE_END
7327
7328MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA")
7329 .boot_params = PHYS_OFFSET + 0x100,
7330 .map_io = msm7x30_map_io,
7331 .reserve = msm7x30_reserve,
7332 .init_irq = msm7x30_init_irq,
7333 .init_machine = msm7x30_init,
7334 .timer = &msm_timer,
7335 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307336 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307337 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007338MACHINE_END
7339MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
7340 .boot_params = PHYS_OFFSET + 0x100,
7341 .map_io = msm7x30_map_io,
7342 .reserve = msm7x30_reserve,
7343 .init_irq = msm7x30_init_irq,
7344 .init_machine = msm7x30_init,
7345 .timer = &msm_timer,
7346 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307347 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307348 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007349MACHINE_END
7350MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA")
7351 .boot_params = PHYS_OFFSET + 0x100,
7352 .map_io = msm7x30_map_io,
7353 .reserve = msm7x30_reserve,
7354 .init_irq = msm7x30_init_irq,
7355 .init_machine = msm7x30_init,
7356 .timer = &msm_timer,
7357 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307358 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307359 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007360MACHINE_END