blob: 972cb22a7fef7e51f8f2956abd16b6262f3829b6 [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
98#define MSM_FB_SIZE 0x780000
99#else
100#define MSM_FB_SIZE 0x500000
101#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
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700107#define MSM_PMEM_ADSP_SIZE 0x1E00000
108#define MSM_FLUID_PMEM_ADSP_SIZE 0x2800000
109#define PMEM_KERNEL_EBI0_SIZE 0x600000
110#define MSM_PMEM_AUDIO_SIZE 0x200000
Daniel Walker90e37c52010-05-12 14:24:15 -0700111
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700112#define PMIC_GPIO_INT 27
113#define PMIC_VREG_WLAN_LEVEL 2900
114#define PMIC_GPIO_SD_DET 36
115#define PMIC_GPIO_SDC4_EN_N 17 /* PMIC GPIO Number 18 */
116#define PMIC_GPIO_HDMI_5V_EN_V3 32 /* PMIC GPIO for V3 H/W */
117#define PMIC_GPIO_HDMI_5V_EN_V2 39 /* PMIC GPIO for V2 H/W */
118
119#define ADV7520_I2C_ADDR 0x39
120
121#define FPGA_SDCC_STATUS 0x8E0001A8
122
123#define FPGA_OPTNAV_GPIO_ADDR 0x8E000026
124#define OPTNAV_I2C_SLAVE_ADDR (0xB0 >> 1)
125#define OPTNAV_IRQ 20
126#define OPTNAV_CHIP_SELECT 19
Asutosh Das853bbcd2012-02-01 10:40:05 +0530127#define PMIC_GPIO_SDC4_PWR_EN_N 24 /* PMIC GPIO Number 25 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700128
129/* Macros assume PMIC GPIOs start at 0 */
130#define PM8058_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio + NR_GPIO_IRQS)
131#define PM8058_GPIO_SYS_TO_PM(sys_gpio) (sys_gpio - NR_GPIO_IRQS)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530132#define PM8058_MPP_BASE PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS)
133#define PM8058_MPP_PM_TO_SYS(pm_gpio) (pm_gpio + PM8058_MPP_BASE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700134
135#define PMIC_GPIO_FLASH_BOOST_ENABLE 15 /* PMIC GPIO Number 16 */
136#define PMIC_GPIO_HAP_ENABLE 16 /* PMIC GPIO Number 17 */
137
138#define PMIC_GPIO_WLAN_EXT_POR 22 /* PMIC GPIO NUMBER 23 */
139
140#define BMA150_GPIO_INT 1
141
142#define HAP_LVL_SHFT_MSM_GPIO 24
143
144#define PMIC_GPIO_QUICKVX_CLK 37 /* PMIC GPIO 38 */
145
146#define PM_FLIP_MPP 5 /* PMIC MPP 06 */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530147
Pankaj Kumarac69ee62012-01-26 00:21:56 +0530148#define DDR1_BANK_BASE 0X20000000
149#define DDR2_BANK_BASE 0X40000000
150
151static unsigned int phys_add = DDR2_BANK_BASE;
152unsigned long ebi1_phys_offset = DDR2_BANK_BASE;
153EXPORT_SYMBOL(ebi1_phys_offset);
154
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530155struct pm8xxx_gpio_init_info {
156 unsigned gpio;
157 struct pm_gpio config;
158};
159
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700160static int pm8058_gpios_init(void)
161{
162 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700163
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530164 struct pm8xxx_gpio_init_info sdc4_en = {
165 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_EN_N),
166 {
167 .direction = PM_GPIO_DIR_OUT,
168 .pull = PM_GPIO_PULL_NO,
169 .vin_sel = PM8058_GPIO_VIN_L5,
170 .function = PM_GPIO_FUNC_NORMAL,
171 .inv_int_pol = 0,
172 .out_strength = PM_GPIO_STRENGTH_LOW,
173 .output_value = 0,
174 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700175 };
176
Asutosh Das853bbcd2012-02-01 10:40:05 +0530177 struct pm8xxx_gpio_init_info sdc4_pwr_en = {
178 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
179 {
180 .direction = PM_GPIO_DIR_OUT,
181 .pull = PM_GPIO_PULL_NO,
182 .vin_sel = PM8058_GPIO_VIN_L5,
183 .function = PM_GPIO_FUNC_NORMAL,
184 .inv_int_pol = 0,
185 .out_strength = PM_GPIO_STRENGTH_LOW,
186 .output_value = 0,
187 },
188 };
189
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530190 struct pm8xxx_gpio_init_info haptics_enable = {
191 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
192 {
193 .direction = PM_GPIO_DIR_OUT,
194 .pull = PM_GPIO_PULL_NO,
195 .out_strength = PM_GPIO_STRENGTH_HIGH,
196 .function = PM_GPIO_FUNC_NORMAL,
197 .inv_int_pol = 0,
198 .vin_sel = 2,
199 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
200 .output_value = 0,
201 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700202 };
203
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530204 struct pm8xxx_gpio_init_info hdmi_5V_en = {
205 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HDMI_5V_EN_V3),
206 {
207 .direction = PM_GPIO_DIR_OUT,
208 .pull = PM_GPIO_PULL_NO,
209 .vin_sel = PM8058_GPIO_VIN_VPH,
210 .function = PM_GPIO_FUNC_NORMAL,
211 .out_strength = PM_GPIO_STRENGTH_LOW,
212 .output_value = 0,
213 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700214 };
215
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530216 struct pm8xxx_gpio_init_info flash_boost_enable = {
217 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE),
218 {
219 .direction = PM_GPIO_DIR_OUT,
220 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
221 .output_value = 0,
222 .pull = PM_GPIO_PULL_NO,
223 .vin_sel = PM8058_GPIO_VIN_S3,
224 .out_strength = PM_GPIO_STRENGTH_HIGH,
225 .function = PM_GPIO_FUNC_2,
226 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700227 };
228
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530229 struct pm8xxx_gpio_init_info gpio23 = {
230 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_WLAN_EXT_POR),
231 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700232 .direction = PM_GPIO_DIR_OUT,
233 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
234 .output_value = 0,
235 .pull = PM_GPIO_PULL_NO,
236 .vin_sel = 2,
237 .out_strength = PM_GPIO_STRENGTH_LOW,
238 .function = PM_GPIO_FUNC_NORMAL,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530239 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700240 };
241
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700242#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530243 struct pm8xxx_gpio_init_info sdcc_det = {
244 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1),
245 {
246 .direction = PM_GPIO_DIR_IN,
247 .pull = PM_GPIO_PULL_UP_1P5,
248 .vin_sel = 2,
249 .function = PM_GPIO_FUNC_NORMAL,
250 .inv_int_pol = 0,
251 },
252 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700253
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530254 if (machine_is_msm7x30_fluid())
255 sdcc_det.config.inv_int_pol = 1;
256
257 rc = pm8xxx_gpio_config(sdcc_det.gpio, &sdcc_det.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700258 if (rc) {
259 pr_err("%s PMIC_GPIO_SD_DET config failed\n", __func__);
260 return rc;
261 }
262#endif
263
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530264 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
265 machine_is_msm7x30_fluid())
266 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V2;
267 else
268 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V3;
269
270 hdmi_5V_en.gpio = PM8058_GPIO_PM_TO_SYS(hdmi_5V_en.gpio);
271
272 rc = pm8xxx_gpio_config(hdmi_5V_en.gpio, &hdmi_5V_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700273 if (rc) {
274 pr_err("%s PMIC_GPIO_HDMI_5V_EN config failed\n", __func__);
275 return rc;
276 }
277
278 /* Deassert GPIO#23 (source for Ext_POR on WLAN-Volans) */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530279 rc = pm8xxx_gpio_config(gpio23.gpio, &gpio23.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700280 if (rc) {
281 pr_err("%s PMIC_GPIO_WLAN_EXT_POR config failed\n", __func__);
282 return rc;
283 }
284
285 if (machine_is_msm7x30_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530286 /* Haptics gpio */
287 rc = pm8xxx_gpio_config(haptics_enable.gpio,
288 &haptics_enable.config);
289 if (rc) {
290 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
291 haptics_enable.gpio);
292 return rc;
293 }
294 /* Flash boost gpio */
295 rc = pm8xxx_gpio_config(flash_boost_enable.gpio,
296 &flash_boost_enable.config);
297 if (rc) {
298 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
299 flash_boost_enable.gpio);
300 return rc;
301 }
302 /* SCD4 gpio */
303 rc = pm8xxx_gpio_config(sdc4_en.gpio, &sdc4_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700304 if (rc) {
305 pr_err("%s PMIC_GPIO_SDC4_EN_N config failed\n",
306 __func__);
307 return rc;
308 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530309 rc = gpio_request(sdc4_en.gpio, "sdc4_en");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700310 if (rc) {
311 pr_err("%s PMIC_GPIO_SDC4_EN_N gpio_request failed\n",
312 __func__);
313 return rc;
314 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530315 gpio_set_value_cansleep(sdc4_en.gpio, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700316 }
Asutosh Das853bbcd2012-02-01 10:40:05 +0530317 /* FFA -> gpio_25 controls vdd of sdcc4 */
318 else {
319 /* SCD4 gpio_25 */
320 rc = pm8xxx_gpio_config(sdc4_pwr_en.gpio, &sdc4_pwr_en.config);
321 if (rc) {
322 pr_err("%s PMIC_GPIO_SDC4_PWR_EN_N config failed: %d\n",
323 __func__, rc);
324 return rc;
325 }
326
327 rc = gpio_request(sdc4_pwr_en.gpio, "sdc4_pwr_en");
328 if (rc) {
329 pr_err("PMIC_GPIO_SDC4_PWR_EN_N gpio_req failed: %d\n",
330 rc);
331 return rc;
332 }
333 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700334
335 return 0;
336}
337
Justin Paupore637a25d2011-07-14 17:11:04 -0700338/* Regulator API support */
339
340#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
341static struct platform_device msm_proccomm_regulator_dev = {
342 .name = PROCCOMM_REGULATOR_DEV_NAME,
343 .id = -1,
344 .dev = {
345 .platform_data = &msm7x30_proccomm_regulator_data
346 }
347};
348#endif
349
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700350/*virtual key support */
351static ssize_t tma300_vkeys_show(struct kobject *kobj,
352 struct kobj_attribute *attr, char *buf)
353{
354 return sprintf(buf,
355 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":50:842:80:100"
356 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":170:842:80:100"
357 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":290:842:80:100"
358 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":410:842:80:100"
359 "\n");
360}
361
362static struct kobj_attribute tma300_vkeys_attr = {
363 .attr = {
364 .mode = S_IRUGO,
365 },
366 .show = &tma300_vkeys_show,
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530367};
368
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700369static struct attribute *tma300_properties_attrs[] = {
370 &tma300_vkeys_attr.attr,
371 NULL
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530372};
373
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700374static struct attribute_group tma300_properties_attr_group = {
375 .attrs = tma300_properties_attrs,
376};
377
378static struct kobject *properties_kobj;
Justin Paupore3f40f342011-08-10 18:52:16 -0700379static struct regulator_bulk_data cyttsp_regs[] = {
380 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
381 { .supply = "ldo15", .min_uV = 3050000, .max_uV = 3100000 },
382};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700383
384#define CYTTSP_TS_GPIO_IRQ 150
385static int cyttsp_platform_init(struct i2c_client *client)
386{
387 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700388
Justin Paupore3f40f342011-08-10 18:52:16 -0700389 rc = regulator_bulk_get(NULL, ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700390
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700391 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700392 pr_err("%s: could not get regulators: %d\n", __func__, rc);
393 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700394 }
395
Justin Paupore3f40f342011-08-10 18:52:16 -0700396 rc = regulator_bulk_set_voltage(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
397
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700398 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700399 pr_err("%s: could not set regulator voltages: %d\n", __func__,
400 rc);
401 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700402 }
403
Justin Paupore3f40f342011-08-10 18:52:16 -0700404 rc = regulator_bulk_enable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700405
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700406 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700407 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
408 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700409 }
410
411 /* check this device active by reading first byte/register */
412 rc = i2c_smbus_read_byte_data(client, 0x01);
413 if (rc < 0) {
414 pr_err("%s: i2c sanity check failed\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -0700415 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700416 }
417
418 rc = gpio_tlmm_config(GPIO_CFG(CYTTSP_TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
419 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
420 if (rc) {
421 pr_err("%s: Could not configure gpio %d\n",
422 __func__, CYTTSP_TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -0700423 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700424 }
425
426 /* virtual keys */
427 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
428 properties_kobj = kobject_create_and_add("board_properties",
429 NULL);
430 if (properties_kobj)
431 rc = sysfs_create_group(properties_kobj,
432 &tma300_properties_attr_group);
433 if (!properties_kobj || rc)
434 pr_err("%s: failed to create board_properties\n",
435 __func__);
436
437 return CY_OK;
438
Justin Paupore3f40f342011-08-10 18:52:16 -0700439regs_disable:
440 regulator_bulk_disable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
441regs_free:
442 regulator_bulk_free(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
443out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700444 return rc;
445}
446
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530447/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
448static int cyttsp_platform_suspend(struct i2c_client *client)
449{
450 msleep(20);
451
452 return CY_OK;
453}
454
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700455static int cyttsp_platform_resume(struct i2c_client *client)
456{
457 /* add any special code to strobe a wakeup pin or chip reset */
458 mdelay(10);
459
460 return CY_OK;
461}
462
463static struct cyttsp_platform_data cyttsp_data = {
464 .fw_fname = "cyttsp_7630_fluid.hex",
465 .panel_maxx = 479,
466 .panel_maxy = 799,
467 .disp_maxx = 469,
468 .disp_maxy = 799,
469 .disp_minx = 10,
470 .disp_miny = 0,
471 .flags = 0,
472 .gen = CY_GEN3, /* or */
473 .use_st = CY_USE_ST,
474 .use_mt = CY_USE_MT,
475 .use_hndshk = CY_SEND_HNDSHK,
476 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +0530477 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700478 .use_gestures = CY_USE_GESTURES,
479 /* activate up to 4 groups
480 * and set active distance
481 */
482 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
483 CY_GEST_GRP3 | CY_GEST_GRP4 |
484 CY_ACT_DIST,
485 /* change act_intrvl to customize the Active power state
486 * scanning/processing refresh interval for Operating mode
487 */
488 .act_intrvl = CY_ACT_INTRVL_DFLT,
489 /* change tch_tmout to customize the touch timeout for the
490 * Active power state for Operating mode
491 */
492 .tch_tmout = CY_TCH_TMOUT_DFLT,
493 /* change lp_intrvl to customize the Low Power power state
494 * scanning/processing refresh interval for Operating mode
495 */
496 .lp_intrvl = CY_LP_INTRVL_DFLT,
497 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530498 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700499 .init = cyttsp_platform_init,
500 .sleep_gpio = -1,
501 .resout_gpio = -1,
502 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
Mohan Pallaka49c37d62011-08-01 11:52:00 +0530503 .correct_fw_ver = 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700504};
505
506static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
507{
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530508 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700509 .direction = PM_GPIO_DIR_OUT,
510 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
511 .output_value = 0,
512 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530513 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700514 .out_strength = PM_GPIO_STRENGTH_HIGH,
515 .function = PM_GPIO_FUNC_2,
516 };
517 int rc = -EINVAL;
518 int id, mode, max_mA;
519
520 id = mode = max_mA = 0;
521 switch (ch) {
522 case 0:
523 case 1:
524 case 2:
525 if (on) {
526 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530527 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
528 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700529 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530530 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700531 __func__, id, rc);
532 }
533 break;
534
535 case 3:
536 id = PM_PWM_LED_KPD;
537 mode = PM_PWM_CONF_DTEST3;
538 max_mA = 200;
539 break;
540
541 case 4:
542 id = PM_PWM_LED_0;
543 mode = PM_PWM_CONF_PWM1;
544 max_mA = 40;
545 break;
546
547 case 5:
548 id = PM_PWM_LED_2;
549 mode = PM_PWM_CONF_PWM2;
550 max_mA = 40;
551 break;
552
553 case 6:
554 id = PM_PWM_LED_FLASH;
555 mode = PM_PWM_CONF_DTEST3;
556 max_mA = 200;
557 break;
558
559 default:
560 break;
561 }
562
563 if (ch >= 3 && ch <= 6) {
564 if (!on) {
565 mode = PM_PWM_CONF_NONE;
566 max_mA = 0;
567 }
568 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
569 if (rc)
570 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
571 __func__, ch, rc);
572 }
573
574 return rc;
575}
576
577static int pm8058_pwm_enable(struct pwm_device *pwm, int ch, int on)
578{
579 int rc;
580
581 switch (ch) {
582 case 7:
583 rc = pm8058_pwm_set_dtest(pwm, on);
584 if (rc)
585 pr_err("%s: pwm_set_dtest(%d): rc=%d\n",
586 __func__, on, rc);
587 break;
588 default:
589 rc = -EINVAL;
590 break;
591 }
592 return rc;
593}
594
595static const unsigned int fluid_keymap[] = {
596 KEY(0, 0, KEY_7),
597 KEY(0, 1, KEY_ENTER),
598 KEY(0, 2, KEY_UP),
599 /* drop (0,3) as it always shows up in pair with(0,2) */
600 KEY(0, 4, KEY_DOWN),
601
602 KEY(1, 0, KEY_CAMERA_SNAPSHOT),
603 KEY(1, 1, KEY_SELECT),
604 KEY(1, 2, KEY_1),
605 KEY(1, 3, KEY_VOLUMEUP),
606 KEY(1, 4, KEY_VOLUMEDOWN),
607};
608
609static const unsigned int surf_keymap[] = {
610 KEY(0, 0, KEY_7),
611 KEY(0, 1, KEY_DOWN),
612 KEY(0, 2, KEY_UP),
613 KEY(0, 3, KEY_RIGHT),
614 KEY(0, 4, KEY_ENTER),
615 KEY(0, 5, KEY_L),
616 KEY(0, 6, KEY_BACK),
617 KEY(0, 7, KEY_M),
618
619 KEY(1, 0, KEY_LEFT),
620 KEY(1, 1, KEY_SEND),
621 KEY(1, 2, KEY_1),
622 KEY(1, 3, KEY_4),
623 KEY(1, 4, KEY_CLEAR),
624 KEY(1, 5, KEY_MSDOS),
625 KEY(1, 6, KEY_SPACE),
626 KEY(1, 7, KEY_COMMA),
627
628 KEY(2, 0, KEY_6),
629 KEY(2, 1, KEY_5),
630 KEY(2, 2, KEY_8),
631 KEY(2, 3, KEY_3),
632 KEY(2, 4, KEY_NUMERIC_STAR),
633 KEY(2, 5, KEY_UP),
634 KEY(2, 6, KEY_DOWN), /* SYN */
635 KEY(2, 7, KEY_LEFTSHIFT),
636
637 KEY(3, 0, KEY_9),
638 KEY(3, 1, KEY_NUMERIC_POUND),
639 KEY(3, 2, KEY_0),
640 KEY(3, 3, KEY_2),
641 KEY(3, 4, KEY_SLEEP),
642 KEY(3, 5, KEY_F1),
643 KEY(3, 6, KEY_F2),
644 KEY(3, 7, KEY_F3),
645
646 KEY(4, 0, KEY_BACK),
647 KEY(4, 1, KEY_HOME),
648 KEY(4, 2, KEY_MENU),
649 KEY(4, 3, KEY_VOLUMEUP),
650 KEY(4, 4, KEY_VOLUMEDOWN),
651 KEY(4, 5, KEY_F4),
652 KEY(4, 6, KEY_F5),
653 KEY(4, 7, KEY_F6),
654
655 KEY(5, 0, KEY_R),
656 KEY(5, 1, KEY_T),
657 KEY(5, 2, KEY_Y),
658 KEY(5, 3, KEY_LEFTALT),
659 KEY(5, 4, KEY_KPENTER),
660 KEY(5, 5, KEY_Q),
661 KEY(5, 6, KEY_W),
662 KEY(5, 7, KEY_E),
663
664 KEY(6, 0, KEY_F),
665 KEY(6, 1, KEY_G),
666 KEY(6, 2, KEY_H),
667 KEY(6, 3, KEY_CAPSLOCK),
668 KEY(6, 4, KEY_PAGEUP),
669 KEY(6, 5, KEY_A),
670 KEY(6, 6, KEY_S),
671 KEY(6, 7, KEY_D),
672
673 KEY(7, 0, KEY_V),
674 KEY(7, 1, KEY_B),
675 KEY(7, 2, KEY_N),
676 KEY(7, 3, KEY_MENU), /* REVISIT - SYM */
677 KEY(7, 4, KEY_PAGEDOWN),
678 KEY(7, 5, KEY_Z),
679 KEY(7, 6, KEY_X),
680 KEY(7, 7, KEY_C),
681
682 KEY(8, 0, KEY_P),
683 KEY(8, 1, KEY_J),
684 KEY(8, 2, KEY_K),
685 KEY(8, 3, KEY_INSERT),
686 KEY(8, 4, KEY_LINEFEED),
687 KEY(8, 5, KEY_U),
688 KEY(8, 6, KEY_I),
689 KEY(8, 7, KEY_O),
690
691 KEY(9, 0, KEY_4),
692 KEY(9, 1, KEY_5),
693 KEY(9, 2, KEY_6),
694 KEY(9, 3, KEY_7),
695 KEY(9, 4, KEY_8),
696 KEY(9, 5, KEY_1),
697 KEY(9, 6, KEY_2),
698 KEY(9, 7, KEY_3),
699
700 KEY(10, 0, KEY_F7),
701 KEY(10, 1, KEY_F8),
702 KEY(10, 2, KEY_F9),
703 KEY(10, 3, KEY_F10),
704 KEY(10, 4, KEY_FN),
705 KEY(10, 5, KEY_9),
706 KEY(10, 6, KEY_0),
707 KEY(10, 7, KEY_DOT),
708
709 KEY(11, 0, KEY_LEFTCTRL),
710 KEY(11, 1, KEY_F11), /* START */
711 KEY(11, 2, KEY_ENTER),
712 KEY(11, 3, KEY_SEARCH),
713 KEY(11, 4, KEY_DELETE),
714 KEY(11, 5, KEY_RIGHT),
715 KEY(11, 6, KEY_LEFT),
716 KEY(11, 7, KEY_RIGHTSHIFT),
717};
718
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700719static struct matrix_keymap_data surf_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530720 .keymap_size = ARRAY_SIZE(surf_keymap),
721 .keymap = surf_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700722};
723
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530724static struct pm8xxx_keypad_platform_data surf_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700725 .input_name = "surf_keypad",
726 .input_phys_device = "surf_keypad/input0",
727 .num_rows = 12,
728 .num_cols = 8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530729 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
730 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
731 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700732 .scan_delay_ms = 32,
733 .row_hold_ns = 91500,
734 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530735 .keymap_data = &surf_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700736};
737
738static struct matrix_keymap_data fluid_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530739 .keymap_size = ARRAY_SIZE(fluid_keymap),
740 .keymap = fluid_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700741};
742
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530743static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700744 .input_name = "fluid-keypad",
745 .input_phys_device = "fluid-keypad/input0",
746 .num_rows = 5,
747 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530748 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
749 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
750 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700751 .scan_delay_ms = 32,
752 .row_hold_ns = 91500,
753 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530754 .keymap_data = &fluid_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700755};
756
757static struct pm8058_pwm_pdata pm8058_pwm_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530758 .config = pm8058_pwm_config,
759 .enable = pm8058_pwm_enable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700760};
761
762static struct pmic8058_led pmic8058_ffa_leds[] = {
763 [0] = {
764 .name = "keyboard-backlight",
765 .max_brightness = 15,
766 .id = PMIC8058_ID_LED_KB_LIGHT,
Dima Zavinba5499e2011-01-10 11:00:30 -0800767 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700768};
769
770static struct pmic8058_leds_platform_data pm8058_ffa_leds_data = {
771 .num_leds = ARRAY_SIZE(pmic8058_ffa_leds),
772 .leds = pmic8058_ffa_leds,
773};
774
775static struct pmic8058_led pmic8058_surf_leds[] = {
776 [0] = {
777 .name = "keyboard-backlight",
778 .max_brightness = 15,
779 .id = PMIC8058_ID_LED_KB_LIGHT,
780 },
781 [1] = {
782 .name = "voice:red",
783 .max_brightness = 20,
784 .id = PMIC8058_ID_LED_0,
785 },
786 [2] = {
787 .name = "wlan:green",
788 .max_brightness = 20,
789 .id = PMIC8058_ID_LED_2,
790 },
791};
792
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700793static struct pmic8058_leds_platform_data pm8058_surf_leds_data = {
794 .num_leds = ARRAY_SIZE(pmic8058_surf_leds),
795 .leds = pmic8058_surf_leds,
796};
797
798static struct pmic8058_led pmic8058_fluid_leds[] = {
799 [0] = {
800 .name = "keyboard-backlight",
801 .max_brightness = 15,
802 .id = PMIC8058_ID_LED_KB_LIGHT,
803 },
804 [1] = {
805 .name = "flash:led_0",
806 .max_brightness = 15,
807 .id = PMIC8058_ID_FLASH_LED_0,
808 },
809 [2] = {
810 .name = "flash:led_1",
811 .max_brightness = 15,
812 .id = PMIC8058_ID_FLASH_LED_1,
813 },
814};
815
816static struct pmic8058_leds_platform_data pm8058_fluid_leds_data = {
817 .num_leds = ARRAY_SIZE(pmic8058_fluid_leds),
818 .leds = pmic8058_fluid_leds,
819};
820
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530821static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata = {
822 .irq_base = PMIC8058_IRQ_BASE,
823 .devirq = MSM_GPIO_TO_INT(PMIC_GPIO_INT),
824 .irq_trigger_flag = IRQF_TRIGGER_LOW,
825};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700826
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530827static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata = {
828 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
829};
830
831static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata = {
832 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
833};
834
835static struct pm8058_platform_data pm8058_7x30_data = {
836 .irq_pdata = &pm8xxx_irq_pdata,
837 .gpio_pdata = &pm8xxx_gpio_pdata,
838 .mpp_pdata = &pm8xxx_mpp_pdata,
839 .pwm_pdata = &pm8058_pwm_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700840};
841
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530842#ifdef CONFIG_MSM_SSBI
843static struct msm_ssbi_platform_data msm7x30_ssbi_pm8058_pdata = {
Kenneth Heitke48952912012-01-12 14:02:06 -0700844 .rsl_id = "D:PMIC_SSBI",
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530845 .controller_type = MSM_SBI_CTRL_SSBI2,
846 .slave = {
847 .name = "pm8058-core",
848 .platform_data = &pm8058_7x30_data,
849 },
850};
851#endif
852
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700853static struct i2c_board_info cy8info[] __initdata = {
854 {
855 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
856 .platform_data = &cyttsp_data,
857#ifndef CY_USE_TIMER
858 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
859#endif /* CY_USE_TIMER */
860 },
861};
862
863static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
864#ifdef CONFIG_MT9D112
865 {
866 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
Dima Zavinba5499e2011-01-10 11:00:30 -0800867 },
868#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700869#ifdef CONFIG_WEBCAM_OV9726
870 {
871 I2C_BOARD_INFO("ov9726", 0x10),
872 },
873#endif
874#ifdef CONFIG_S5K3E2FX
875 {
876 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
877 },
878#endif
879#ifdef CONFIG_MT9P012
880 {
881 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
882 },
883#endif
884#ifdef CONFIG_VX6953
885 {
886 I2C_BOARD_INFO("vx6953", 0x20),
887 },
888#endif
889#ifdef CONFIG_MT9E013
890 {
891 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
892 },
893#endif
894#ifdef CONFIG_SN12M0PZ
895 {
896 I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1),
897 },
898#endif
899#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
900 {
901 I2C_BOARD_INFO("mt9t013", 0x6C),
902 },
903#endif
904
Dima Zavinba5499e2011-01-10 11:00:30 -0800905};
906
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700907#ifdef CONFIG_MSM_CAMERA
908#define CAM_STNDBY 143
909static uint32_t camera_off_vcm_gpio_table[] = {
910GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */
911};
912
913static uint32_t camera_off_gpio_table[] = {
914 /* parallel CAMERA interfaces */
915 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RST */
916 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
917 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
918 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
919 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
920 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
921 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
922 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
923 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
924 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
925 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
926 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
927 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
928 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
929 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
930};
931
932static uint32_t camera_on_vcm_gpio_table[] = {
933GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */
934};
935
936static uint32_t camera_on_gpio_table[] = {
937 /* parallel CAMERA interfaces */
938 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RST */
939 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
940 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
941 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
942 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
943 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
944 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
945 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
946 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
947 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
948 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
949 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
950 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
951 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
952 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
953};
954
955static uint32_t camera_off_gpio_fluid_table[] = {
956 /* FLUID: CAM_VGA_RST_N */
957 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
958 /* FLUID: CAMIF_STANDBY */
959 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
960};
961
962static uint32_t camera_on_gpio_fluid_table[] = {
963 /* FLUID: CAM_VGA_RST_N */
964 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
965 /* FLUID: CAMIF_STANDBY */
966 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
967};
968
969static void config_gpio_table(uint32_t *table, int len)
970{
971 int n, rc;
972 for (n = 0; n < len; n++) {
973 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
974 if (rc) {
975 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
976 __func__, table[n], rc);
977 break;
978 }
979 }
980}
981static int config_camera_on_gpios(void)
982{
983 config_gpio_table(camera_on_gpio_table,
984 ARRAY_SIZE(camera_on_gpio_table));
985
986 if (adie_get_detected_codec_type() != TIMPANI_ID)
987 /* GPIO1 is shared also used in Timpani RF card so
988 only configure it for non-Timpani RF card */
989 config_gpio_table(camera_on_vcm_gpio_table,
990 ARRAY_SIZE(camera_on_vcm_gpio_table));
991
992 if (machine_is_msm7x30_fluid()) {
993 config_gpio_table(camera_on_gpio_fluid_table,
994 ARRAY_SIZE(camera_on_gpio_fluid_table));
995 /* FLUID: turn on 5V booster */
996 gpio_set_value(
997 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 1);
998 /* FLUID: drive high to put secondary sensor to STANDBY */
999 gpio_set_value(CAM_STNDBY, 1);
1000 }
1001 return 0;
1002}
1003
1004static void config_camera_off_gpios(void)
1005{
1006 config_gpio_table(camera_off_gpio_table,
1007 ARRAY_SIZE(camera_off_gpio_table));
1008
1009 if (adie_get_detected_codec_type() != TIMPANI_ID)
1010 /* GPIO1 is shared also used in Timpani RF card so
1011 only configure it for non-Timpani RF card */
1012 config_gpio_table(camera_off_vcm_gpio_table,
1013 ARRAY_SIZE(camera_off_vcm_gpio_table));
1014
1015 if (machine_is_msm7x30_fluid()) {
1016 config_gpio_table(camera_off_gpio_fluid_table,
1017 ARRAY_SIZE(camera_off_gpio_fluid_table));
1018 /* FLUID: turn off 5V booster */
1019 gpio_set_value(
1020 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 0);
1021 }
1022}
1023
1024struct resource msm_camera_resources[] = {
1025 {
1026 .start = 0xA6000000,
1027 .end = 0xA6000000 + SZ_1M - 1,
1028 .flags = IORESOURCE_MEM,
1029 },
1030 {
1031 .start = INT_VFE,
1032 .end = INT_VFE,
1033 .flags = IORESOURCE_IRQ,
1034 },
1035 {
1036 .flags = IORESOURCE_DMA,
1037 }
1038};
1039
1040struct msm_camera_device_platform_data msm_camera_device_data = {
1041 .camera_gpio_on = config_camera_on_gpios,
1042 .camera_gpio_off = config_camera_off_gpios,
1043 .ioext.camifpadphy = 0xAB000000,
1044 .ioext.camifpadsz = 0x00000400,
1045 .ioext.csiphy = 0xA6100000,
1046 .ioext.csisz = 0x00000400,
1047 .ioext.csiirq = INT_CSI,
1048 .ioclk.mclk_clk_rate = 24000000,
1049 .ioclk.vfe_clk_rate = 147456000,
1050};
1051
1052static struct msm_camera_sensor_flash_src msm_flash_src_pwm = {
1053 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PWM,
1054 ._fsrc.pwm_src.freq = 1000,
1055 ._fsrc.pwm_src.max_load = 300,
1056 ._fsrc.pwm_src.low_load = 30,
1057 ._fsrc.pwm_src.high_load = 100,
1058 ._fsrc.pwm_src.channel = 7,
1059};
1060
1061#ifdef CONFIG_MT9D112
1062static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1063 .flash_type = MSM_CAMERA_FLASH_LED,
1064 .flash_src = &msm_flash_src_pwm
1065};
1066
1067static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1068 .sensor_name = "mt9d112",
1069 .sensor_reset = 0,
1070 .sensor_pwd = 85,
1071 .vcm_pwd = 1,
1072 .vcm_enable = 0,
1073 .pdata = &msm_camera_device_data,
1074 .resource = msm_camera_resources,
1075 .num_resources = ARRAY_SIZE(msm_camera_resources),
1076 .flash_data = &flash_mt9d112,
1077 .csi_if = 0
1078};
1079
1080static struct platform_device msm_camera_sensor_mt9d112 = {
1081 .name = "msm_camera_mt9d112",
1082 .dev = {
1083 .platform_data = &msm_camera_sensor_mt9d112_data,
1084 },
1085};
1086#endif
1087
1088#ifdef CONFIG_WEBCAM_OV9726
1089
1090static struct msm_camera_sensor_platform_info ov9726_sensor_7630_info = {
1091 .mount_angle = 90
1092};
1093
1094static struct msm_camera_sensor_flash_data flash_ov9726 = {
1095 .flash_type = MSM_CAMERA_FLASH_LED,
1096 .flash_src = &msm_flash_src_pwm
1097};
1098static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
1099 .sensor_name = "ov9726",
1100 .sensor_reset = 0,
1101 .sensor_pwd = 85,
1102 .vcm_pwd = 1,
1103 .vcm_enable = 0,
1104 .pdata = &msm_camera_device_data,
1105 .resource = msm_camera_resources,
1106 .num_resources = ARRAY_SIZE(msm_camera_resources),
1107 .flash_data = &flash_ov9726,
1108 .sensor_platform_info = &ov9726_sensor_7630_info,
1109 .csi_if = 1
1110};
1111struct platform_device msm_camera_sensor_ov9726 = {
1112 .name = "msm_camera_ov9726",
1113 .dev = {
1114 .platform_data = &msm_camera_sensor_ov9726_data,
1115 },
1116};
1117#endif
1118
1119#ifdef CONFIG_S5K3E2FX
1120static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1121 .flash_type = MSM_CAMERA_FLASH_LED,
1122 .flash_src = &msm_flash_src_pwm,
1123};
1124
1125static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1126 .sensor_name = "s5k3e2fx",
1127 .sensor_reset = 0,
1128 .sensor_pwd = 85,
1129 .vcm_pwd = 1,
1130 .vcm_enable = 0,
1131 .pdata = &msm_camera_device_data,
1132 .resource = msm_camera_resources,
1133 .num_resources = ARRAY_SIZE(msm_camera_resources),
1134 .flash_data = &flash_s5k3e2fx,
1135 .csi_if = 0
1136};
1137
1138static struct platform_device msm_camera_sensor_s5k3e2fx = {
1139 .name = "msm_camera_s5k3e2fx",
1140 .dev = {
1141 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1142 },
1143};
1144#endif
1145
1146#ifdef CONFIG_MT9P012
1147static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1148 .flash_type = MSM_CAMERA_FLASH_LED,
1149 .flash_src = &msm_flash_src_pwm
1150};
1151
1152static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1153 .sensor_name = "mt9p012",
1154 .sensor_reset = 0,
1155 .sensor_pwd = 85,
1156 .vcm_pwd = 1,
1157 .vcm_enable = 1,
1158 .pdata = &msm_camera_device_data,
1159 .resource = msm_camera_resources,
1160 .num_resources = ARRAY_SIZE(msm_camera_resources),
1161 .flash_data = &flash_mt9p012,
1162 .csi_if = 0
1163};
1164
1165static struct platform_device msm_camera_sensor_mt9p012 = {
1166 .name = "msm_camera_mt9p012",
1167 .dev = {
1168 .platform_data = &msm_camera_sensor_mt9p012_data,
1169 },
1170};
1171#endif
1172
1173#ifdef CONFIG_MT9E013
1174static struct msm_camera_sensor_platform_info mt9e013_sensor_7630_info = {
1175 .mount_angle = 0
1176};
1177
1178static struct msm_camera_sensor_flash_data flash_mt9e013 = {
1179 .flash_type = MSM_CAMERA_FLASH_LED,
1180 .flash_src = &msm_flash_src_pwm
1181};
1182
1183static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
1184 .sensor_name = "mt9e013",
1185 .sensor_reset = 0,
1186 .sensor_pwd = 85,
1187 .vcm_pwd = 1,
1188 .vcm_enable = 1,
1189 .pdata = &msm_camera_device_data,
1190 .resource = msm_camera_resources,
1191 .num_resources = ARRAY_SIZE(msm_camera_resources),
1192 .flash_data = &flash_mt9e013,
1193 .sensor_platform_info = &mt9e013_sensor_7630_info,
1194 .csi_if = 1
1195};
1196
1197static struct platform_device msm_camera_sensor_mt9e013 = {
1198 .name = "msm_camera_mt9e013",
1199 .dev = {
1200 .platform_data = &msm_camera_sensor_mt9e013_data,
1201 },
1202};
1203#endif
1204
1205#ifdef CONFIG_VX6953
Jilai Wang971f97f2011-07-13 14:25:25 -04001206static struct msm_camera_sensor_platform_info vx6953_sensor_7630_info = {
1207 .mount_angle = 0
1208};
1209
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001210static struct msm_camera_sensor_flash_data flash_vx6953 = {
1211 .flash_type = MSM_CAMERA_FLASH_LED,
1212 .flash_src = &msm_flash_src_pwm
1213};
1214static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1215 .sensor_name = "vx6953",
1216 .sensor_reset = 0,
1217 .sensor_pwd = 85,
1218 .vcm_pwd = 1,
1219 .vcm_enable = 0,
1220 .pdata = &msm_camera_device_data,
1221 .resource = msm_camera_resources,
1222 .num_resources = ARRAY_SIZE(msm_camera_resources),
Jilai Wang971f97f2011-07-13 14:25:25 -04001223 .sensor_platform_info = &vx6953_sensor_7630_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001224 .flash_data = &flash_vx6953,
1225 .csi_if = 1
1226};
1227static struct platform_device msm_camera_sensor_vx6953 = {
1228 .name = "msm_camera_vx6953",
1229 .dev = {
1230 .platform_data = &msm_camera_sensor_vx6953_data,
1231 },
1232};
1233#endif
1234
1235#ifdef CONFIG_SN12M0PZ
1236static struct msm_camera_sensor_flash_src msm_flash_src_current_driver = {
1237 .flash_sr_type = MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER,
1238 ._fsrc.current_driver_src.low_current = 210,
1239 ._fsrc.current_driver_src.high_current = 700,
1240 ._fsrc.current_driver_src.driver_channel = &pm8058_fluid_leds_data,
1241};
1242
1243static struct msm_camera_sensor_flash_data flash_sn12m0pz = {
1244 .flash_type = MSM_CAMERA_FLASH_LED,
1245 .flash_src = &msm_flash_src_current_driver
1246};
1247static struct msm_camera_sensor_info msm_camera_sensor_sn12m0pz_data = {
1248 .sensor_name = "sn12m0pz",
1249 .sensor_reset = 0,
1250 .sensor_pwd = 85,
1251 .vcm_pwd = 1,
1252 .vcm_enable = 1,
1253 .pdata = &msm_camera_device_data,
1254 .flash_data = &flash_sn12m0pz,
1255 .resource = msm_camera_resources,
1256 .num_resources = ARRAY_SIZE(msm_camera_resources),
1257 .csi_if = 0
1258};
1259
1260static struct platform_device msm_camera_sensor_sn12m0pz = {
1261 .name = "msm_camera_sn12m0pz",
1262 .dev = {
1263 .platform_data = &msm_camera_sensor_sn12m0pz_data,
1264 },
1265};
1266#endif
1267
1268#ifdef CONFIG_MT9T013
1269static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1270 .flash_type = MSM_CAMERA_FLASH_LED,
1271 .flash_src = &msm_flash_src_pwm
1272};
1273
1274static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1275 .sensor_name = "mt9t013",
1276 .sensor_reset = 0,
1277 .sensor_pwd = 85,
1278 .vcm_pwd = 1,
1279 .vcm_enable = 0,
1280 .pdata = &msm_camera_device_data,
1281 .resource = msm_camera_resources,
1282 .num_resources = ARRAY_SIZE(msm_camera_resources),
1283 .flash_data = &flash_mt9t013,
1284 .csi_if = 1
1285};
1286
1287static struct platform_device msm_camera_sensor_mt9t013 = {
1288 .name = "msm_camera_mt9t013",
1289 .dev = {
1290 .platform_data = &msm_camera_sensor_mt9t013_data,
1291 },
1292};
1293#endif
1294
1295#ifdef CONFIG_MSM_GEMINI
1296static struct resource msm_gemini_resources[] = {
1297 {
1298 .start = 0xA3A00000,
1299 .end = 0xA3A00000 + 0x0150 - 1,
1300 .flags = IORESOURCE_MEM,
1301 },
1302 {
1303 .start = INT_JPEG,
1304 .end = INT_JPEG,
1305 .flags = IORESOURCE_IRQ,
1306 },
1307};
1308
1309static struct platform_device msm_gemini_device = {
1310 .name = "msm_gemini",
1311 .resource = msm_gemini_resources,
1312 .num_resources = ARRAY_SIZE(msm_gemini_resources),
1313};
1314#endif
1315
1316#ifdef CONFIG_MSM_VPE
1317static struct resource msm_vpe_resources[] = {
1318 {
1319 .start = 0xAD200000,
1320 .end = 0xAD200000 + SZ_1M - 1,
1321 .flags = IORESOURCE_MEM,
1322 },
1323 {
1324 .start = INT_VPE,
1325 .end = INT_VPE,
1326 .flags = IORESOURCE_IRQ,
1327 },
1328};
1329
1330static struct platform_device msm_vpe_device = {
1331 .name = "msm_vpe",
1332 .id = 0,
1333 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1334 .resource = msm_vpe_resources,
1335};
1336#endif
1337
1338#endif /*CONFIG_MSM_CAMERA*/
1339
1340#ifdef CONFIG_MSM7KV2_AUDIO
1341static uint32_t audio_pamp_gpio_config =
1342 GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1343
1344static uint32_t audio_fluid_icodec_tx_config =
1345 GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1346
1347static int __init snddev_poweramp_gpio_init(void)
1348{
1349 int rc;
1350
1351 pr_info("snddev_poweramp_gpio_init \n");
1352 rc = gpio_tlmm_config(audio_pamp_gpio_config, GPIO_CFG_ENABLE);
1353 if (rc) {
1354 printk(KERN_ERR
1355 "%s: gpio_tlmm_config(%#x)=%d\n",
1356 __func__, audio_pamp_gpio_config, rc);
1357 }
1358 return rc;
1359}
1360
1361void msm_snddev_tx_route_config(void)
1362{
1363 int rc;
1364
1365 pr_debug("%s()\n", __func__);
1366
1367 if (machine_is_msm7x30_fluid()) {
1368 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1369 GPIO_CFG_ENABLE);
1370 if (rc) {
1371 printk(KERN_ERR
1372 "%s: gpio_tlmm_config(%#x)=%d\n",
1373 __func__, audio_fluid_icodec_tx_config, rc);
1374 } else
1375 gpio_set_value(85, 0);
1376 }
1377}
1378
1379void msm_snddev_tx_route_deconfig(void)
1380{
1381 int rc;
1382
1383 pr_debug("%s()\n", __func__);
1384
1385 if (machine_is_msm7x30_fluid()) {
1386 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1387 GPIO_CFG_DISABLE);
1388 if (rc) {
1389 printk(KERN_ERR
1390 "%s: gpio_tlmm_config(%#x)=%d\n",
1391 __func__, audio_fluid_icodec_tx_config, rc);
1392 }
1393 }
1394}
1395
1396void msm_snddev_poweramp_on(void)
1397{
1398 gpio_set_value(82, 1); /* enable spkr poweramp */
1399 pr_info("%s: power on amplifier\n", __func__);
1400}
1401
1402void msm_snddev_poweramp_off(void)
1403{
1404 gpio_set_value(82, 0); /* disable spkr poweramp */
1405 pr_info("%s: power off amplifier\n", __func__);
1406}
1407
Justin Paupore3f40f342011-08-10 18:52:16 -07001408static struct regulator_bulk_data snddev_regs[] = {
1409 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
1410 { .supply = "ncp", .min_uV = 1800000, .max_uV = 1800000 },
1411};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001412
Justin Paupore3f40f342011-08-10 18:52:16 -07001413static int __init snddev_hsed_voltage_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001414{
1415 int rc;
1416
Justin Paupore3f40f342011-08-10 18:52:16 -07001417 rc = regulator_bulk_get(NULL, ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001418
Justin Paupore3f40f342011-08-10 18:52:16 -07001419 if (rc) {
1420 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1421 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001422 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001423
1424 rc = regulator_bulk_set_voltage(ARRAY_SIZE(snddev_regs), snddev_regs);
1425
1426 if (rc) {
1427 pr_err("%s: could not set regulator voltages: %d\n",
1428 __func__, rc);
1429 goto regs_free;
1430 }
1431
1432 return 0;
1433
1434regs_free:
1435 regulator_bulk_free(ARRAY_SIZE(snddev_regs), snddev_regs);
1436out:
1437 return rc;
1438}
1439
1440
1441void msm_snddev_hsed_voltage_on(void)
1442{
1443 int rc = regulator_bulk_enable(ARRAY_SIZE(snddev_regs), snddev_regs);
1444
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001445 if (rc)
Justin Paupore3f40f342011-08-10 18:52:16 -07001446 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001447}
1448
1449void msm_snddev_hsed_voltage_off(void)
1450{
Justin Paupore3f40f342011-08-10 18:52:16 -07001451 int rc = regulator_bulk_disable(ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001452
Justin Paupore3f40f342011-08-10 18:52:16 -07001453 if (rc) {
1454 pr_err("%s: could not disable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001455 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001456}
1457
1458static unsigned aux_pcm_gpio_on[] = {
1459 GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
1460 GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
1461 GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
1462 GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
1463};
1464
1465static int __init aux_pcm_gpio_init(void)
1466{
1467 int pin, rc;
1468
1469 pr_info("aux_pcm_gpio_init \n");
1470 for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) {
1471 rc = gpio_tlmm_config(aux_pcm_gpio_on[pin],
1472 GPIO_CFG_ENABLE);
1473 if (rc) {
1474 printk(KERN_ERR
1475 "%s: gpio_tlmm_config(%#x)=%d\n",
1476 __func__, aux_pcm_gpio_on[pin], rc);
1477 }
1478 }
1479 return rc;
1480}
1481
1482static struct msm_gpio mi2s_clk_gpios[] = {
1483 { GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1484 "MI2S_SCLK"},
1485 { GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1486 "MI2S_WS"},
1487 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1488 "MI2S_MCLK_A"},
1489};
1490
1491static struct msm_gpio mi2s_rx_data_lines_gpios[] = {
1492 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1493 "MI2S_DATA_SD0_A"},
1494 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1495 "MI2S_DATA_SD1_A"},
1496 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1497 "MI2S_DATA_SD2_A"},
1498 { GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1499 "MI2S_DATA_SD3"},
1500};
1501
1502static struct msm_gpio mi2s_tx_data_lines_gpios[] = {
1503 { GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1504 "MI2S_DATA_SD3"},
1505};
1506
1507int mi2s_config_clk_gpio(void)
1508{
1509 int rc = 0;
1510
1511 rc = msm_gpios_request_enable(mi2s_clk_gpios,
1512 ARRAY_SIZE(mi2s_clk_gpios));
1513 if (rc) {
1514 pr_err("%s: enable mi2s clk gpios failed\n",
1515 __func__);
1516 return rc;
1517 }
1518 return 0;
1519}
1520
1521int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask)
1522{
1523 int i, rc = 0;
1524 sd_line_mask &= MI2S_SD_LINE_MASK;
1525
1526 switch (direction) {
1527 case DIR_TX:
1528 msm_gpios_disable_free(mi2s_tx_data_lines_gpios, 1);
1529 break;
1530 case DIR_RX:
1531 i = 0;
1532 while (sd_line_mask) {
1533 if (sd_line_mask & 0x1)
1534 msm_gpios_disable_free(
1535 mi2s_rx_data_lines_gpios + i , 1);
1536 sd_line_mask = sd_line_mask >> 1;
1537 i++;
1538 }
1539 break;
1540 default:
1541 pr_err("%s: Invaild direction direction = %u\n",
1542 __func__, direction);
1543 rc = -EINVAL;
1544 break;
1545 }
1546 return rc;
1547}
1548
1549int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask)
1550{
1551 int i , rc = 0;
1552 u8 sd_config_done_mask = 0;
1553
1554 sd_line_mask &= MI2S_SD_LINE_MASK;
1555
1556 switch (direction) {
1557 case DIR_TX:
1558 if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) ||
1559 (sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) {
1560 pr_err("%s: can not use SD0 or SD1 or SD2 for TX"
1561 ".only can use SD3. sd_line_mask = 0x%x\n",
1562 __func__ , sd_line_mask);
1563 rc = -EINVAL;
1564 } else {
1565 rc = msm_gpios_request_enable(mi2s_tx_data_lines_gpios,
1566 1);
1567 if (rc)
1568 pr_err("%s: enable mi2s gpios for TX failed\n",
1569 __func__);
1570 }
1571 break;
1572 case DIR_RX:
1573 i = 0;
1574 while (sd_line_mask && (rc == 0)) {
1575 if (sd_line_mask & 0x1) {
1576 rc = msm_gpios_request_enable(
1577 mi2s_rx_data_lines_gpios + i , 1);
1578 if (rc) {
1579 pr_err("%s: enable mi2s gpios for"
1580 "RX failed. SD line = %s\n",
1581 __func__,
1582 (mi2s_rx_data_lines_gpios + i)->label);
1583 mi2s_unconfig_data_gpio(DIR_RX,
1584 sd_config_done_mask);
1585 } else
1586 sd_config_done_mask |= (1 << i);
1587 }
1588 sd_line_mask = sd_line_mask >> 1;
1589 i++;
1590 }
1591 break;
1592 default:
1593 pr_err("%s: Invaild direction direction = %u\n",
1594 __func__, direction);
1595 rc = -EINVAL;
1596 break;
1597 }
1598 return rc;
1599}
1600
1601int mi2s_unconfig_clk_gpio(void)
1602{
1603 msm_gpios_disable_free(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios));
1604 return 0;
1605}
1606
1607#endif /* CONFIG_MSM7KV2_AUDIO */
1608
1609static int __init buses_init(void)
1610{
1611 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT,
1612 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
1613 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
1614 __func__, PMIC_GPIO_INT);
1615
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301616 if (machine_is_msm8x60_fluid())
1617 pm8058_7x30_data.keypad_pdata = &fluid_keypad_data;
1618 else
1619 pm8058_7x30_data.keypad_pdata = &surf_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001620
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001621 return 0;
1622}
1623
1624#define TIMPANI_RESET_GPIO 1
1625
1626struct bahama_config_register{
1627 u8 reg;
1628 u8 value;
1629 u8 mask;
1630};
1631
1632enum version{
1633 VER_1_0,
1634 VER_2_0,
1635 VER_UNSUPPORTED = 0xFF
1636};
1637
Justin Paupore3f40f342011-08-10 18:52:16 -07001638static struct regulator *vreg_marimba_1;
1639static struct regulator *vreg_marimba_2;
1640static struct regulator *vreg_bahama;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001641
1642static struct msm_gpio timpani_reset_gpio_cfg[] = {
1643{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
1644 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} };
1645
1646static u8 read_bahama_ver(void)
1647{
1648 int rc;
1649 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1650 u8 bahama_version;
1651
1652 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
1653 if (rc < 0) {
1654 printk(KERN_ERR
1655 "%s: version read failed: %d\n",
1656 __func__, rc);
1657 return rc;
1658 } else {
1659 printk(KERN_INFO
1660 "%s: version read got: 0x%x\n",
1661 __func__, bahama_version);
1662 }
1663
1664 switch (bahama_version) {
1665 case 0x08: /* varient of bahama v1 */
1666 case 0x10:
1667 case 0x00:
1668 return VER_1_0;
1669 case 0x09: /* variant of bahama v2 */
1670 return VER_2_0;
1671 default:
1672 return VER_UNSUPPORTED;
1673 }
1674}
1675
1676static int config_timpani_reset(void)
1677{
1678 int rc;
1679
1680 rc = msm_gpios_request_enable(timpani_reset_gpio_cfg,
1681 ARRAY_SIZE(timpani_reset_gpio_cfg));
1682 if (rc < 0) {
1683 printk(KERN_ERR
1684 "%s: msm_gpios_request_enable failed (%d)\n",
1685 __func__, rc);
1686 }
1687 return rc;
1688}
1689
1690static unsigned int msm_timpani_setup_power(void)
1691{
1692 int rc;
1693
1694 rc = config_timpani_reset();
1695 if (rc < 0)
1696 goto out;
1697
Justin Paupore3f40f342011-08-10 18:52:16 -07001698 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001699 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001700 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001701 goto out;
1702 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001703
1704 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001705 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001706 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1707 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001708 }
1709
1710 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1);
1711 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001712 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001713 __func__, rc);
1714 msm_gpios_free(timpani_reset_gpio_cfg,
1715 ARRAY_SIZE(timpani_reset_gpio_cfg));
Justin Paupore3f40f342011-08-10 18:52:16 -07001716 goto disable_marimba_2;
1717 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001718
Justin Paupore3f40f342011-08-10 18:52:16 -07001719 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001720
Justin Paupore3f40f342011-08-10 18:52:16 -07001721disable_marimba_2:
1722 regulator_disable(vreg_marimba_2);
1723disable_marimba_1:
1724 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001725out:
1726 return rc;
1727};
1728
1729static void msm_timpani_shutdown_power(void)
1730{
1731 int rc;
1732
Justin Paupore3f40f342011-08-10 18:52:16 -07001733 rc = regulator_disable(vreg_marimba_2);
1734 if (rc)
1735 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1736
1737 rc = regulator_disable(vreg_marimba_1);
1738 if (rc)
1739 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001740
1741 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0);
Justin Paupore3f40f342011-08-10 18:52:16 -07001742 if (rc < 0)
1743 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001744 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001745
1746 msm_gpios_free(timpani_reset_gpio_cfg,
1747 ARRAY_SIZE(timpani_reset_gpio_cfg));
1748};
1749
1750static unsigned int msm_bahama_core_config(int type)
1751{
1752 int rc = 0;
1753
1754 if (type == BAHAMA_ID) {
1755
1756 int i;
1757 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1758
1759 const struct bahama_config_register v20_init[] = {
1760 /* reg, value, mask */
1761 { 0xF4, 0x84, 0xFF }, /* AREG */
1762 { 0xF0, 0x04, 0xFF } /* DREG */
1763 };
1764
1765 if (read_bahama_ver() == VER_2_0) {
1766 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
1767 u8 value = v20_init[i].value;
1768 rc = marimba_write_bit_mask(&config,
1769 v20_init[i].reg,
1770 &value,
1771 sizeof(v20_init[i].value),
1772 v20_init[i].mask);
1773 if (rc < 0) {
1774 printk(KERN_ERR
1775 "%s: reg %d write failed: %d\n",
1776 __func__, v20_init[i].reg, rc);
1777 return rc;
1778 }
1779 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
1780 " mask 0x%02x\n",
1781 __func__, v20_init[i].reg,
1782 v20_init[i].value, v20_init[i].mask);
1783 }
1784 }
1785 }
1786 printk(KERN_INFO "core type: %d\n", type);
1787
1788 return rc;
1789}
1790
1791static unsigned int msm_bahama_setup_power(void)
1792{
Justin Paupore3f40f342011-08-10 18:52:16 -07001793 int rc = regulator_enable(vreg_bahama);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001794
Justin Paupore3f40f342011-08-10 18:52:16 -07001795 if (rc)
1796 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001797
1798 return rc;
1799};
1800
1801static unsigned int msm_bahama_shutdown_power(int value)
1802{
1803 int rc = 0;
1804
1805 if (value != BAHAMA_ID) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001806 rc = regulator_disable(vreg_bahama);
1807
1808 if (rc)
1809 pr_err("%s: regulator_disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001810 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001811 }
1812
1813 return rc;
1814};
1815
1816static struct msm_gpio marimba_svlte_config_clock[] = {
1817 { GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1818 "MARIMBA_SVLTE_CLOCK_ENABLE" },
1819};
1820
1821static unsigned int msm_marimba_gpio_config_svlte(int gpio_cfg_marimba)
1822{
1823 if (machine_is_msm8x55_svlte_surf() ||
1824 machine_is_msm8x55_svlte_ffa()) {
1825 if (gpio_cfg_marimba)
1826 gpio_set_value(GPIO_PIN
1827 (marimba_svlte_config_clock->gpio_cfg), 1);
1828 else
1829 gpio_set_value(GPIO_PIN
1830 (marimba_svlte_config_clock->gpio_cfg), 0);
1831 }
1832
1833 return 0;
1834};
1835
1836static unsigned int msm_marimba_setup_power(void)
1837{
1838 int rc;
1839
Justin Paupore3f40f342011-08-10 18:52:16 -07001840 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001841 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001842 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001843 goto out;
1844 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001845
1846 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001847 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001848 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1849 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001850 }
1851
1852 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
1853 rc = msm_gpios_request_enable(marimba_svlte_config_clock,
1854 ARRAY_SIZE(marimba_svlte_config_clock));
1855 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001856 pr_err("%s: msm_gpios_request_enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001857 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07001858 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001859 }
1860
1861 rc = gpio_direction_output(GPIO_PIN
1862 (marimba_svlte_config_clock->gpio_cfg), 0);
1863 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001864 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001865 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07001866 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001867 }
1868 }
1869
Justin Paupore3f40f342011-08-10 18:52:16 -07001870 return 0;
1871
1872disable_marimba_2:
1873 regulator_disable(vreg_marimba_2);
1874disable_marimba_1:
1875 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001876out:
1877 return rc;
1878};
1879
1880static void msm_marimba_shutdown_power(void)
1881{
1882 int rc;
1883
Justin Paupore3f40f342011-08-10 18:52:16 -07001884 rc = regulator_disable(vreg_marimba_2);
1885 if (rc)
1886 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1887
1888 rc = regulator_disable(vreg_marimba_1);
1889 if (rc)
1890 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001891};
1892
1893static int bahama_present(void)
1894{
1895 int id;
1896 switch (id = adie_get_detected_connectivity_type()) {
1897 case BAHAMA_ID:
1898 return 1;
1899
1900 case MARIMBA_ID:
1901 return 0;
1902
1903 case TIMPANI_ID:
1904 default:
1905 printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n",
1906 __func__, id);
1907 return -ENODEV;
1908 }
1909}
1910
Justin Paupore3f40f342011-08-10 18:52:16 -07001911struct regulator *fm_regulator;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001912static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
1913{
Justin Paupore3f40f342011-08-10 18:52:16 -07001914 int rc, voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001915 uint32_t irqcfg;
1916 const char *id = "FMPW";
1917
1918 int bahama_not_marimba = bahama_present();
1919
Justin Paupore3f40f342011-08-10 18:52:16 -07001920 if (bahama_not_marimba < 0) {
1921 pr_warn("%s: bahama_present: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001922 __func__, bahama_not_marimba);
Justin Paupore3f40f342011-08-10 18:52:16 -07001923 rc = -ENODEV;
1924 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001925 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001926 if (bahama_not_marimba) {
1927 fm_regulator = regulator_get(NULL, "s3");
1928 voltage = 1800000;
1929 } else {
1930 fm_regulator = regulator_get(NULL, "s2");
1931 voltage = 1300000;
1932 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001933
1934 if (IS_ERR(fm_regulator)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001935 rc = PTR_ERR(fm_regulator);
1936 pr_err("%s: regulator_get failed (%d)\n", __func__, rc);
1937 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001938 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001939
Justin Paupore3f40f342011-08-10 18:52:16 -07001940 rc = regulator_set_voltage(fm_regulator, voltage, voltage);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001941
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001942 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001943 pr_err("%s: regulator_set_voltage failed (%d)\n", __func__, rc);
1944 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001945 }
1946
Justin Paupore3f40f342011-08-10 18:52:16 -07001947 rc = regulator_enable(fm_regulator);
1948
1949 if (rc) {
1950 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1951 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001952 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001953
1954 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_ON);
1955
1956 if (rc < 0) {
1957 pr_err("%s: clock vote failed (%d)\n", __func__, rc);
1958 goto regulator_disable;
1959 }
1960
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001961 /*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
1962 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07001963 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001964 rc = marimba_gpio_config(1);
Justin Paupore3f40f342011-08-10 18:52:16 -07001965 if (rc < 0) {
1966 pr_err("%s: clock enable for svlte : %d\n",
1967 __func__, rc);
1968 goto clock_devote;
1969 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001970 }
1971 irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
1972 GPIO_CFG_2MA);
1973 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
1974 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001975 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001976 rc = -EIO;
Justin Paupore3f40f342011-08-10 18:52:16 -07001977 goto gpio_deconfig;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001978
1979 }
1980 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001981
Justin Paupore3f40f342011-08-10 18:52:16 -07001982gpio_deconfig:
1983 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa())
1984 marimba_gpio_config(0);
1985clock_devote:
1986 pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_OFF);
1987regulator_disable:
1988 regulator_disable(fm_regulator);
1989regulator_free:
1990 regulator_put(fm_regulator);
1991 fm_regulator = NULL;
1992out:
1993 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001994};
1995
1996static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
1997{
1998 int rc;
1999 const char *id = "FMPW";
2000 uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
2001 GPIO_CFG_2MA);
2002
2003 int bahama_not_marimba = bahama_present();
2004 if (bahama_not_marimba == -1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002005 pr_warn("%s: bahama_present: %d\n",
2006 __func__, bahama_not_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002007 return;
2008 }
2009
2010 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2011 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002012 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002013 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002014 if (!IS_ERR_OR_NULL(fm_regulator)) {
2015 rc = regulator_disable(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002016
Justin Paupore3f40f342011-08-10 18:52:16 -07002017 if (rc)
2018 pr_err("%s: return val: %d\n", __func__, rc);
2019
2020 regulator_put(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002021 fm_regulator = NULL;
2022 }
2023 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
2024 PMAPP_CLOCK_VOTE_OFF);
2025 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002026 pr_err("%s: clock_vote return val: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002027
2028 /*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2029 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002030 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002031 rc = marimba_gpio_config(0);
2032 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002033 pr_err("%s: clock disable for svlte : %d\n",
2034 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002035 }
2036}
2037
2038static struct marimba_fm_platform_data marimba_fm_pdata = {
2039 .fm_setup = fm_radio_setup,
2040 .fm_shutdown = fm_radio_shutdown,
2041 .irq = MSM_GPIO_TO_INT(147),
2042 .vreg_s2 = NULL,
2043 .vreg_xo_out = NULL,
2044 .is_fm_soc_i2s_master = false,
2045 .config_i2s_gpio = NULL,
2046};
2047
2048
2049/* Slave id address for FM/CDC/QMEMBIST
2050 * Values can be programmed using Marimba slave id 0
2051 * should there be a conflict with other I2C devices
2052 * */
2053#define MARIMBA_SLAVE_ID_FM_ADDR 0x2A
2054#define MARIMBA_SLAVE_ID_CDC_ADDR 0x77
2055#define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66
2056
2057#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
2058#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
2059
2060static const char *tsadc_id = "MADC";
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002061
Justin Paupore3f40f342011-08-10 18:52:16 -07002062static struct regulator_bulk_data regs_tsadc_marimba[] = {
2063 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2064 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002065};
Justin Paupore3f40f342011-08-10 18:52:16 -07002066
2067static struct regulator_bulk_data regs_tsadc_timpani[] = {
2068 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2069 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2070 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2071};
2072
2073static struct regulator_bulk_data *regs_tsadc;
2074static int regs_tsadc_count;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002075
2076static int marimba_tsadc_power(int vreg_on)
2077{
Justin Paupore3f40f342011-08-10 18:52:16 -07002078 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002079 int tsadc_adie_type = adie_get_detected_codec_type();
2080
Justin Paupore3f40f342011-08-10 18:52:16 -07002081 switch (tsadc_adie_type) {
2082 case TIMPANI_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002083 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2084 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2085 if (rc) {
2086 pr_err("%s: unable to %svote for d1 clk\n",
2087 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002088 goto D1_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002089 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002090
2091 /* fall through */
2092 case MARIMBA_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002093 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2094 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2095 if (rc) {
2096 pr_err("%s: unable to %svote for d1 clk\n",
2097 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002098 goto D0_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002099 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002100
Justin Paupore3f40f342011-08-10 18:52:16 -07002101 WARN_ON(regs_tsadc_count == 0);
2102
2103 rc = vreg_on ?
2104 regulator_bulk_enable(regs_tsadc_count, regs_tsadc) :
2105 regulator_bulk_disable(regs_tsadc_count, regs_tsadc);
2106
2107 if (rc) {
2108 pr_err("%s: regulator %sable failed: %d\n",
2109 __func__, vreg_on ? "en" : "dis", rc);
2110 goto regulator_switch_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002111 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002112
2113 break;
2114 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002115 pr_err("%s:Adie %d not supported\n",
2116 __func__, tsadc_adie_type);
2117 return -ENODEV;
2118 }
2119
2120 msleep(5); /* ensure power is stable */
2121
2122 return 0;
2123
Justin Paupore3f40f342011-08-10 18:52:16 -07002124regulator_switch_fail:
2125 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2126 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2127D0_vote_fail:
2128 if (tsadc_adie_type == TIMPANI_ID)
2129 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2130 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2131D1_vote_fail:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002132 return rc;
2133}
2134
2135static int marimba_tsadc_init(void)
2136{
Justin Paupore3f40f342011-08-10 18:52:16 -07002137 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002138 int tsadc_adie_type = adie_get_detected_codec_type();
2139
Justin Paupore3f40f342011-08-10 18:52:16 -07002140 switch (tsadc_adie_type) {
2141 case MARIMBA_ID:
2142 regs_tsadc = regs_tsadc_marimba;
2143 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_marimba);
2144 break;
2145 case TIMPANI_ID:
2146 regs_tsadc = regs_tsadc_timpani;
2147 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_timpani);
2148 break;
2149 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002150 pr_err("%s:Adie %d not supported\n",
2151 __func__, tsadc_adie_type);
Justin Paupore3f40f342011-08-10 18:52:16 -07002152 rc = -ENODEV;
2153 goto out;
2154 }
2155
2156 rc = regulator_bulk_get(NULL, regs_tsadc_count, regs_tsadc);
2157 if (rc) {
2158 pr_err("%s: could not get regulators: %d\n",
2159 __func__, rc);
2160 goto out;
2161 }
2162
2163 rc = regulator_bulk_set_voltage(regs_tsadc_count, regs_tsadc);
2164 if (rc) {
2165 pr_err("%s: could not set regulator voltages: %d\n",
2166 __func__, rc);
2167 goto vreg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002168 }
2169
2170 return 0;
2171
Justin Paupore3f40f342011-08-10 18:52:16 -07002172vreg_free:
2173 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2174out:
2175 regs_tsadc = NULL;
2176 regs_tsadc_count = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002177 return rc;
2178}
2179
2180static int marimba_tsadc_exit(void)
2181{
Justin Paupore3f40f342011-08-10 18:52:16 -07002182 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2183 regs_tsadc_count = 0;
2184 regs_tsadc = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002185
Justin Paupore3f40f342011-08-10 18:52:16 -07002186 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002187}
2188
2189
2190static struct msm_ts_platform_data msm_ts_data = {
Anirudh Ghayal82b74722012-01-19 15:35:34 +05302191 .min_x = 284,
2192 .max_x = 3801,
2193 .min_y = 155,
2194 .max_y = 3929,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002195 .min_press = 0,
2196 .max_press = 255,
2197 .inv_x = 4096,
2198 .inv_y = 4096,
2199 .can_wakeup = false,
2200};
2201
2202static struct marimba_tsadc_platform_data marimba_tsadc_pdata = {
2203 .marimba_tsadc_power = marimba_tsadc_power,
2204 .init = marimba_tsadc_init,
2205 .exit = marimba_tsadc_exit,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002206 .tsadc_prechg_en = true,
2207 .can_wakeup = false,
2208 .setup = {
2209 .pen_irq_en = true,
2210 .tsadc_en = true,
2211 },
2212 .params2 = {
2213 .input_clk_khz = 2400,
2214 .sample_prd = TSADC_CLK_3,
2215 },
2216 .params3 = {
2217 .prechg_time_nsecs = 6400,
2218 .stable_time_nsecs = 6400,
2219 .tsadc_test_mode = 0,
2220 },
2221 .tssc_data = &msm_ts_data,
2222};
2223
Justin Paupore3f40f342011-08-10 18:52:16 -07002224static struct regulator_bulk_data codec_regs[] = {
2225 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
2226};
2227
2228static int __init msm_marimba_codec_init(void)
2229{
2230 int rc = regulator_bulk_get(NULL, ARRAY_SIZE(codec_regs), codec_regs);
2231
2232 if (rc) {
2233 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2234 goto out;
2235 }
2236
2237 rc = regulator_bulk_set_voltage(ARRAY_SIZE(codec_regs), codec_regs);
2238 if (rc) {
2239 pr_err("%s: could not set regulator voltages: %d\n",
2240 __func__, rc);
2241 goto reg_free;
2242 }
2243
2244 return rc;
2245
2246reg_free:
2247 regulator_bulk_free(ARRAY_SIZE(codec_regs), codec_regs);
2248out:
2249 return rc;
2250}
2251
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002252static int msm_marimba_codec_power(int vreg_on)
2253{
Justin Paupore3f40f342011-08-10 18:52:16 -07002254 int rc = vreg_on ?
2255 regulator_bulk_enable(ARRAY_SIZE(codec_regs), codec_regs) :
2256 regulator_bulk_disable(ARRAY_SIZE(codec_regs), codec_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002257
Justin Paupore3f40f342011-08-10 18:52:16 -07002258 if (rc) {
2259 pr_err("%s: could not %sable regulators: %d",
2260 __func__, vreg_on ? "en" : "dis", rc);
2261 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002262 }
2263
Justin Paupore3f40f342011-08-10 18:52:16 -07002264 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002265}
2266
2267static struct marimba_codec_platform_data mariba_codec_pdata = {
2268 .marimba_codec_power = msm_marimba_codec_power,
2269#ifdef CONFIG_MARIMBA_CODEC
2270 .snddev_profile_init = msm_snddev_init,
2271#endif
2272};
2273
2274static struct marimba_platform_data marimba_pdata = {
2275 .slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR,
2276 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2277 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2278 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
2279 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
2280 .marimba_setup = msm_marimba_setup_power,
2281 .marimba_shutdown = msm_marimba_shutdown_power,
2282 .bahama_setup = msm_bahama_setup_power,
2283 .bahama_shutdown = msm_bahama_shutdown_power,
2284 .marimba_gpio_config = msm_marimba_gpio_config_svlte,
2285 .bahama_core_config = msm_bahama_core_config,
2286 .fm = &marimba_fm_pdata,
2287 .codec = &mariba_codec_pdata,
2288 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2289};
2290
2291static void __init msm7x30_init_marimba(void)
2292{
2293 int rc;
2294
Justin Paupore3f40f342011-08-10 18:52:16 -07002295 struct regulator_bulk_data regs[] = {
2296 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2297 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2298 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
2299 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002300
Justin Paupore3f40f342011-08-10 18:52:16 -07002301 rc = msm_marimba_codec_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002302
Justin Paupore3f40f342011-08-10 18:52:16 -07002303 if (rc) {
2304 pr_err("%s: msm_marimba_codec_init failed (%d)\n",
2305 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002306 return;
2307 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002308
2309 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
2310
2311 if (rc) {
2312 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2313 return;
2314 }
2315
2316 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
2317
2318 if (rc) {
2319 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2320 regulator_bulk_free(ARRAY_SIZE(regs), regs);
2321 return;
2322 }
2323
2324 vreg_marimba_1 = regs[0].consumer;
2325 vreg_marimba_2 = regs[1].consumer;
2326 vreg_bahama = regs[2].consumer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002327}
2328
2329static struct marimba_codec_platform_data timpani_codec_pdata = {
2330 .marimba_codec_power = msm_marimba_codec_power,
2331#ifdef CONFIG_TIMPANI_CODEC
2332 .snddev_profile_init = msm_snddev_init_timpani,
2333#endif
2334};
2335
2336static struct marimba_platform_data timpani_pdata = {
2337 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2338 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2339 .marimba_setup = msm_timpani_setup_power,
2340 .marimba_shutdown = msm_timpani_shutdown_power,
2341 .codec = &timpani_codec_pdata,
2342 .tsadc = &marimba_tsadc_pdata,
2343 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2344};
2345
2346#define TIMPANI_I2C_SLAVE_ADDR 0xD
2347
2348static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
2349 {
2350 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
2351 .platform_data = &timpani_pdata,
2352 },
2353};
2354
2355#ifdef CONFIG_MSM7KV2_AUDIO
2356static struct resource msm_aictl_resources[] = {
2357 {
2358 .name = "aictl",
2359 .start = 0xa5000100,
2360 .end = 0xa5000100,
2361 .flags = IORESOURCE_MEM,
2362 }
2363};
2364
2365static struct resource msm_mi2s_resources[] = {
2366 {
2367 .name = "hdmi",
2368 .start = 0xac900000,
2369 .end = 0xac900038,
2370 .flags = IORESOURCE_MEM,
2371 },
2372 {
2373 .name = "codec_rx",
2374 .start = 0xac940040,
2375 .end = 0xac940078,
2376 .flags = IORESOURCE_MEM,
2377 },
2378 {
2379 .name = "codec_tx",
2380 .start = 0xac980080,
2381 .end = 0xac9800B8,
2382 .flags = IORESOURCE_MEM,
2383 }
2384
2385};
2386
2387static struct msm_lpa_platform_data lpa_pdata = {
2388 .obuf_hlb_size = 0x2BFF8,
2389 .dsp_proc_id = 0,
2390 .app_proc_id = 2,
2391 .nosb_config = {
2392 .llb_min_addr = 0,
2393 .llb_max_addr = 0x3ff8,
2394 .sb_min_addr = 0,
2395 .sb_max_addr = 0,
2396 },
2397 .sb_config = {
2398 .llb_min_addr = 0,
2399 .llb_max_addr = 0x37f8,
2400 .sb_min_addr = 0x3800,
2401 .sb_max_addr = 0x3ff8,
2402 }
2403};
2404
2405static struct resource msm_lpa_resources[] = {
2406 {
2407 .name = "lpa",
2408 .start = 0xa5000000,
2409 .end = 0xa50000a0,
2410 .flags = IORESOURCE_MEM,
2411 }
2412};
2413
2414static struct resource msm_aux_pcm_resources[] = {
2415
2416 {
2417 .name = "aux_codec_reg_addr",
2418 .start = 0xac9c00c0,
2419 .end = 0xac9c00c8,
2420 .flags = IORESOURCE_MEM,
2421 },
2422 {
2423 .name = "aux_pcm_dout",
2424 .start = 138,
2425 .end = 138,
2426 .flags = IORESOURCE_IO,
2427 },
2428 {
2429 .name = "aux_pcm_din",
2430 .start = 139,
2431 .end = 139,
2432 .flags = IORESOURCE_IO,
2433 },
2434 {
2435 .name = "aux_pcm_syncout",
2436 .start = 140,
2437 .end = 140,
2438 .flags = IORESOURCE_IO,
2439 },
2440 {
2441 .name = "aux_pcm_clkin_a",
2442 .start = 141,
2443 .end = 141,
2444 .flags = IORESOURCE_IO,
2445 },
2446};
2447
2448static struct platform_device msm_aux_pcm_device = {
2449 .name = "msm_aux_pcm",
2450 .id = 0,
2451 .num_resources = ARRAY_SIZE(msm_aux_pcm_resources),
2452 .resource = msm_aux_pcm_resources,
2453};
2454
2455struct platform_device msm_aictl_device = {
2456 .name = "audio_interct",
2457 .id = 0,
2458 .num_resources = ARRAY_SIZE(msm_aictl_resources),
2459 .resource = msm_aictl_resources,
2460};
2461
2462struct platform_device msm_mi2s_device = {
2463 .name = "mi2s",
2464 .id = 0,
2465 .num_resources = ARRAY_SIZE(msm_mi2s_resources),
2466 .resource = msm_mi2s_resources,
2467};
2468
2469struct platform_device msm_lpa_device = {
2470 .name = "lpa",
2471 .id = 0,
2472 .num_resources = ARRAY_SIZE(msm_lpa_resources),
2473 .resource = msm_lpa_resources,
2474 .dev = {
2475 .platform_data = &lpa_pdata,
2476 },
2477};
2478#endif /* CONFIG_MSM7KV2_AUDIO */
2479
2480#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2481 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2482 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2483 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2484 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2485 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2486#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2487 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2488 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2489 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2490 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2491 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2492 #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2493 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2494 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2495 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2496 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2497 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2498 #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2499 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2500 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2501 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2502 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2503 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2504#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
2505
2506static unsigned int dec_concurrency_table[] = {
2507 /* Audio LP */
2508 0,
2509 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2510 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2511 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2512 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)|
2513 (1<<MSM_ADSP_OP_DM)),
2514
2515 /* Concurrency 1 */
2516 (DEC4_FORMAT),
2517 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2518 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2519 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2520 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2521
2522 /* Concurrency 2 */
2523 (DEC4_FORMAT),
2524 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2525 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2526 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2527 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2528
2529 /* Concurrency 3 */
2530 (DEC4_FORMAT),
2531 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2532 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2533 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2534 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2535
2536 /* Concurrency 4 */
2537 (DEC4_FORMAT),
2538 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2539 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2540 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2541 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2542
2543 /* Concurrency 5 */
2544 (DEC4_FORMAT),
2545 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2546 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2547 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2548 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2549
2550 /* Concurrency 6 */
2551 (DEC4_FORMAT),
2552 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2553 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2554 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2555 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2556};
2557
2558#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
2559 .module_queueid = queueid, .module_decid = decid, \
2560 .nr_codec_support = nr_codec}
2561
2562#define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
2563 .max_instances_same_dec = max_instance_same, \
2564 .max_instances_diff_dec = max_instance_diff}
2565
2566static struct msm_adspdec_info dec_info_list[] = {
2567 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
2568 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
2569 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
2570 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
2571 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
2572};
2573
2574static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
2575 /* Non Turbo Mode */
2576 {
2577 DEC_INSTANCE(4, 3), /* WAV */
2578 DEC_INSTANCE(4, 3), /* ADPCM */
2579 DEC_INSTANCE(4, 2), /* MP3 */
2580 DEC_INSTANCE(0, 0), /* Real Audio */
2581 DEC_INSTANCE(4, 2), /* WMA */
2582 DEC_INSTANCE(3, 2), /* AAC */
2583 DEC_INSTANCE(0, 0), /* Reserved */
2584 DEC_INSTANCE(0, 0), /* MIDI */
2585 DEC_INSTANCE(4, 3), /* YADPCM */
2586 DEC_INSTANCE(4, 3), /* QCELP */
2587 DEC_INSTANCE(4, 3), /* AMRNB */
2588 DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
2589 DEC_INSTANCE(4, 3), /* EVRC */
2590 DEC_INSTANCE(1, 1), /* WMAPRO */
2591 },
2592 /* Turbo Mode */
2593 {
2594 DEC_INSTANCE(4, 3), /* WAV */
2595 DEC_INSTANCE(4, 3), /* ADPCM */
2596 DEC_INSTANCE(4, 3), /* MP3 */
2597 DEC_INSTANCE(0, 0), /* Real Audio */
2598 DEC_INSTANCE(4, 3), /* WMA */
2599 DEC_INSTANCE(4, 3), /* AAC */
2600 DEC_INSTANCE(0, 0), /* Reserved */
2601 DEC_INSTANCE(0, 0), /* MIDI */
2602 DEC_INSTANCE(4, 3), /* YADPCM */
2603 DEC_INSTANCE(4, 3), /* QCELP */
2604 DEC_INSTANCE(4, 3), /* AMRNB */
2605 DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
2606 DEC_INSTANCE(4, 3), /* EVRC */
2607 DEC_INSTANCE(1, 2), /* WMAPRO */
2608 },
2609};
2610
2611static struct msm_adspdec_database msm_device_adspdec_database = {
2612 .num_dec = ARRAY_SIZE(dec_info_list),
2613 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
2614 ARRAY_SIZE(dec_info_list)),
2615 .dec_concurrency_table = dec_concurrency_table,
2616 .dec_info_list = dec_info_list,
2617 .dec_instance_list = &dec_instance_list[0][0],
2618};
2619
2620static struct platform_device msm_device_adspdec = {
2621 .name = "msm_adspdec",
2622 .id = -1,
2623 .dev = {
2624 .platform_data = &msm_device_adspdec_database
2625 },
2626};
2627
2628static struct resource smc91x_resources[] = {
2629 [0] = {
2630 .start = 0x8A000300,
2631 .end = 0x8A0003ff,
2632 .flags = IORESOURCE_MEM,
2633 },
2634 [1] = {
2635 .start = MSM_GPIO_TO_INT(156),
2636 .end = MSM_GPIO_TO_INT(156),
2637 .flags = IORESOURCE_IRQ,
2638 },
2639};
2640
2641static struct platform_device smc91x_device = {
2642 .name = "smc91x",
2643 .id = 0,
2644 .num_resources = ARRAY_SIZE(smc91x_resources),
2645 .resource = smc91x_resources,
2646};
2647
2648static struct smsc911x_platform_config smsc911x_config = {
2649 .phy_interface = PHY_INTERFACE_MODE_MII,
2650 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
2651 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
2652 .flags = SMSC911X_USE_32BIT,
2653};
2654
2655static struct resource smsc911x_resources[] = {
2656 [0] = {
2657 .start = 0x8D000000,
2658 .end = 0x8D000100,
2659 .flags = IORESOURCE_MEM,
2660 },
2661 [1] = {
2662 .start = MSM_GPIO_TO_INT(88),
2663 .end = MSM_GPIO_TO_INT(88),
2664 .flags = IORESOURCE_IRQ,
2665 },
2666};
2667
2668static struct platform_device smsc911x_device = {
2669 .name = "smsc911x",
2670 .id = -1,
2671 .num_resources = ARRAY_SIZE(smsc911x_resources),
2672 .resource = smsc911x_resources,
2673 .dev = {
2674 .platform_data = &smsc911x_config,
2675 },
2676};
2677
2678static struct msm_gpio smsc911x_gpios[] = {
2679 { GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" },
2680 { GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" },
2681 { GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" },
2682 { GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" },
2683 { GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" },
2684 { GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" },
2685 { GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" },
2686 { GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" },
2687};
2688
2689static void msm7x30_cfg_smsc911x(void)
2690{
2691 int rc;
2692
2693 rc = msm_gpios_request_enable(smsc911x_gpios,
2694 ARRAY_SIZE(smsc911x_gpios));
2695 if (rc)
2696 pr_err("%s: unable to enable gpios\n", __func__);
2697}
2698
2699#ifdef CONFIG_USB_G_ANDROID
2700static struct android_usb_platform_data android_usb_pdata = {
2701 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2702};
2703
2704static struct platform_device android_usb_device = {
2705 .name = "android_usb",
2706 .id = -1,
2707 .dev = {
2708 .platform_data = &android_usb_pdata,
2709 },
2710};
2711#endif
2712
2713static struct msm_gpio optnav_config_data[] = {
2714 { GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA),
2715 "optnav_chip_select" },
2716};
2717
Justin Paupore3f40f342011-08-10 18:52:16 -07002718static struct regulator_bulk_data optnav_regulators[] = {
2719 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2720 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
2721 { .supply = "gp9", .min_uV = 1800000, .max_uV = 1800000 },
2722 { .supply = "usb", .min_uV = 3300000, .max_uV = 3300000 },
2723};
2724
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002725static void __iomem *virtual_optnav;
2726
2727static int optnav_gpio_setup(void)
2728{
2729 int rc = -ENODEV;
2730 rc = msm_gpios_request_enable(optnav_config_data,
2731 ARRAY_SIZE(optnav_config_data));
2732
Justin Paupore3f40f342011-08-10 18:52:16 -07002733 if (rc)
2734 return rc;
2735
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002736 /* Configure the FPGA for GPIOs */
2737 virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4);
2738 if (!virtual_optnav) {
2739 pr_err("%s:Could not ioremap region\n", __func__);
2740 return -ENOMEM;
2741 }
2742 /*
2743 * Configure the FPGA to set GPIO 19 as
2744 * normal, active(enabled), output(MSM to SURF)
2745 */
2746 writew(0x311E, virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002747
2748 rc = regulator_bulk_get(NULL, ARRAY_SIZE(optnav_regulators),
2749 optnav_regulators);
2750 if (rc)
2751 return rc;
2752
2753 rc = regulator_bulk_set_voltage(ARRAY_SIZE(optnav_regulators),
2754 optnav_regulators);
2755
2756 if (rc)
2757 goto regulator_put;
2758
2759 return rc;
2760
2761regulator_put:
2762 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002763 return rc;
2764}
2765
2766static void optnav_gpio_release(void)
2767{
2768 msm_gpios_disable_free(optnav_config_data,
2769 ARRAY_SIZE(optnav_config_data));
2770 iounmap(virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002771 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002772}
2773
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002774static int optnav_enable(void)
2775{
2776 int rc;
2777 /*
2778 * Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
2779 * for I2C communication with keyboard.
2780 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002781
Justin Paupore3f40f342011-08-10 18:52:16 -07002782 rc = regulator_bulk_enable(ARRAY_SIZE(optnav_regulators),
2783 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002784
Justin Paupore3f40f342011-08-10 18:52:16 -07002785 if (rc)
2786 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002787
2788 /* Enable the chip select GPIO */
2789 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2790 gpio_set_value(OPTNAV_CHIP_SELECT, 0);
2791
2792 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002793}
2794
2795static void optnav_disable(void)
2796{
Justin Paupore3f40f342011-08-10 18:52:16 -07002797 regulator_bulk_disable(ARRAY_SIZE(optnav_regulators),
2798 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002799
2800 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2801}
2802
2803static struct ofn_atlab_platform_data optnav_data = {
2804 .gpio_setup = optnav_gpio_setup,
2805 .gpio_release = optnav_gpio_release,
2806 .optnav_on = optnav_enable,
2807 .optnav_off = optnav_disable,
2808 .rotate_xy = 0,
2809 .function1 = {
2810 .no_motion1_en = true,
2811 .touch_sensor_en = true,
2812 .ofn_en = true,
2813 .clock_select_khz = 1500,
2814 .cpi_selection = 1200,
2815 },
2816 .function2 = {
2817 .invert_y = false,
2818 .invert_x = true,
2819 .swap_x_y = false,
2820 .hold_a_b_en = true,
2821 .motion_filter_en = true,
2822 },
2823};
2824
2825static int hdmi_comm_power(int on, int show);
2826static int hdmi_init_irq(void);
2827static int hdmi_enable_5v(int on);
2828static int hdmi_core_power(int on, int show);
2829static int hdmi_cec_power(int on);
2830static bool hdmi_check_hdcp_hw_support(void);
2831
2832static struct msm_hdmi_platform_data adv7520_hdmi_data = {
2833 .irq = MSM_GPIO_TO_INT(18),
2834 .comm_power = hdmi_comm_power,
2835 .init_irq = hdmi_init_irq,
2836 .enable_5v = hdmi_enable_5v,
2837 .core_power = hdmi_core_power,
2838 .cec_power = hdmi_cec_power,
2839 .check_hdcp_hw_support = hdmi_check_hdcp_hw_support,
2840};
2841
2842#ifdef CONFIG_BOSCH_BMA150
Justin Paupore3f40f342011-08-10 18:52:16 -07002843
2844static struct regulator_bulk_data sensors_ldo[] = {
2845 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2846 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
2847};
2848
2849static int __init sensors_ldo_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002850{
2851 int rc;
2852
Justin Paupore3f40f342011-08-10 18:52:16 -07002853 rc = regulator_bulk_get(NULL, ARRAY_SIZE(sensors_ldo), sensors_ldo);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002854
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002855 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002856 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2857 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002858 }
2859
Justin Paupore3f40f342011-08-10 18:52:16 -07002860 rc = regulator_bulk_set_voltage(ARRAY_SIZE(sensors_ldo), sensors_ldo);
2861
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002862 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002863 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2864 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002865 }
2866
2867 return 0;
2868
Justin Paupore3f40f342011-08-10 18:52:16 -07002869reg_free:
2870 regulator_bulk_free(ARRAY_SIZE(sensors_ldo), sensors_ldo);
2871out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002872 return rc;
2873}
2874
Justin Paupore3f40f342011-08-10 18:52:16 -07002875static int sensors_ldo_set(int on)
2876{
2877 int rc = on ?
2878 regulator_bulk_enable(ARRAY_SIZE(sensors_ldo), sensors_ldo) :
2879 regulator_bulk_disable(ARRAY_SIZE(sensors_ldo), sensors_ldo);
2880
2881 if (rc)
2882 pr_err("%s: could not %sable regulators: %d\n",
2883 __func__, on ? "en" : "dis", rc);
2884
2885 return rc;
2886}
2887
2888static int sensors_ldo_enable(void)
2889{
2890 return sensors_ldo_set(1);
2891}
2892
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002893static void sensors_ldo_disable(void)
2894{
Justin Paupore3f40f342011-08-10 18:52:16 -07002895 sensors_ldo_set(0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002896}
Justin Paupore3f40f342011-08-10 18:52:16 -07002897
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002898static struct bma150_platform_data bma150_data = {
2899 .power_on = sensors_ldo_enable,
2900 .power_off = sensors_ldo_disable,
2901};
2902
2903static struct i2c_board_info bma150_board_info[] __initdata = {
2904 {
2905 I2C_BOARD_INFO("bma150", 0x38),
2906 .flags = I2C_CLIENT_WAKE,
2907 .irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
2908 .platform_data = &bma150_data,
2909 },
2910};
2911#endif
2912
2913static struct i2c_board_info msm_i2c_board_info[] = {
2914 {
2915 I2C_BOARD_INFO("m33c01", OPTNAV_I2C_SLAVE_ADDR),
2916 .irq = MSM_GPIO_TO_INT(OPTNAV_IRQ),
2917 .platform_data = &optnav_data,
2918 },
2919 {
2920 I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR),
2921 .platform_data = &adv7520_hdmi_data,
2922 },
2923};
2924
2925static struct i2c_board_info msm_marimba_board_info[] = {
2926 {
2927 I2C_BOARD_INFO("marimba", 0xc),
2928 .platform_data = &marimba_pdata,
2929 }
2930};
2931
2932
2933static struct msm_handset_platform_data hs_platform_data = {
2934 .hs_name = "7k_handset",
2935 .pwr_key_delay_ms = 500, /* 0 will disable end key */
2936};
2937
2938static struct platform_device hs_device = {
2939 .name = "msm-handset",
2940 .id = -1,
2941 .dev = {
2942 .platform_data = &hs_platform_data,
2943 },
2944};
2945
2946static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +05302947 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002948 .idle_supported = 1,
2949 .suspend_supported = 1,
2950 .idle_enabled = 1,
2951 .suspend_enabled = 1,
2952 .latency = 8594,
2953 .residency = 23740,
2954 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05302955 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002956 .idle_supported = 1,
2957 .suspend_supported = 1,
2958 .idle_enabled = 1,
2959 .suspend_enabled = 1,
2960 .latency = 4594,
2961 .residency = 23740,
2962 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05302963 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002964#ifdef CONFIG_MSM_STANDALONE_POWER_COLLAPSE
2965 .idle_supported = 1,
2966 .suspend_supported = 1,
2967 .idle_enabled = 1,
2968 .suspend_enabled = 0,
2969#else /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
2970 .idle_supported = 0,
2971 .suspend_supported = 0,
2972 .idle_enabled = 0,
2973 .suspend_enabled = 0,
2974#endif /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
2975 .latency = 500,
2976 .residency = 6000,
2977 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05302978 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002979 .idle_supported = 1,
2980 .suspend_supported = 1,
2981 .idle_enabled = 0,
2982 .suspend_enabled = 1,
2983 .latency = 443,
2984 .residency = 1098,
2985 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05302986 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002987 .idle_supported = 1,
2988 .suspend_supported = 1,
2989 .idle_enabled = 1,
2990 .suspend_enabled = 1,
2991 .latency = 2,
2992 .residency = 0,
2993 },
2994};
2995
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05302996u32 msm7x30_power_collapse_latency(enum msm_pm_sleep_mode mode)
2997{
2998 switch (mode) {
2999 case MSM_PM_SLEEP_MODE_POWER_COLLAPSE:
3000 return msm_pm_data
3001 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].latency;
3002 case MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN:
3003 return msm_pm_data
3004 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN].latency;
3005 case MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT:
3006 return msm_pm_data
3007 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
3008 case MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT:
3009 return msm_pm_data
3010 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT].latency;
3011 default:
3012 return 0;
3013 }
3014}
3015
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003016static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3017 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
3018 .v_addr = (uint32_t *)PAGE_OFFSET,
3019};
3020
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003021static struct resource qsd_spi_resources[] = {
3022 {
3023 .name = "spi_irq_in",
3024 .start = INT_SPI_INPUT,
3025 .end = INT_SPI_INPUT,
3026 .flags = IORESOURCE_IRQ,
3027 },
3028 {
3029 .name = "spi_irq_out",
3030 .start = INT_SPI_OUTPUT,
3031 .end = INT_SPI_OUTPUT,
3032 .flags = IORESOURCE_IRQ,
3033 },
3034 {
3035 .name = "spi_irq_err",
3036 .start = INT_SPI_ERROR,
3037 .end = INT_SPI_ERROR,
3038 .flags = IORESOURCE_IRQ,
3039 },
3040 {
3041 .name = "spi_base",
3042 .start = 0xA8000000,
3043 .end = 0xA8000000 + SZ_4K - 1,
3044 .flags = IORESOURCE_MEM,
3045 },
3046 {
3047 .name = "spidm_channels",
3048 .flags = IORESOURCE_DMA,
3049 },
3050 {
3051 .name = "spidm_crci",
3052 .flags = IORESOURCE_DMA,
3053 },
3054};
3055
3056#define AMDH0_BASE_PHYS 0xAC200000
3057#define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
3058static int msm_qsd_spi_dma_config(void)
3059{
3060 void __iomem *ct_adm_base = 0;
3061 u32 spi_mux = 0;
3062 int ret = 0;
3063
3064 ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
3065 if (!ct_adm_base) {
3066 pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
3067 return -ENOMEM;
3068 }
3069
3070 spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
3071
3072 qsd_spi_resources[4].start = DMOV_USB_CHAN;
3073 qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
3074
3075 switch (spi_mux) {
3076 case (1):
3077 qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
3078 qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
3079 break;
3080 case (2):
3081 qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
3082 qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
3083 break;
3084 case (3):
3085 qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
3086 qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
3087 break;
3088 default:
3089 ret = -ENOENT;
3090 }
3091
3092 iounmap(ct_adm_base);
3093
3094 return ret;
3095}
3096
3097static struct platform_device qsd_device_spi = {
3098 .name = "spi_qsd",
3099 .id = 0,
3100 .num_resources = ARRAY_SIZE(qsd_spi_resources),
3101 .resource = qsd_spi_resources,
3102};
3103
3104#ifdef CONFIG_SPI_QSD
3105static struct spi_board_info lcdc_sharp_spi_board_info[] __initdata = {
3106 {
3107 .modalias = "lcdc_sharp_ls038y7dx01",
3108 .mode = SPI_MODE_1,
3109 .bus_num = 0,
3110 .chip_select = 0,
3111 .max_speed_hz = 26331429,
3112 }
3113};
3114static struct spi_board_info lcdc_toshiba_spi_board_info[] __initdata = {
3115 {
3116 .modalias = "lcdc_toshiba_ltm030dd40",
3117 .mode = SPI_MODE_3|SPI_CS_HIGH,
3118 .bus_num = 0,
3119 .chip_select = 0,
3120 .max_speed_hz = 9963243,
3121 }
3122};
3123#endif
3124
3125static struct msm_gpio qsd_spi_gpio_config_data[] = {
3126 { GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3127 { GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3128 { GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" },
3129 { GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3130};
3131
3132static int msm_qsd_spi_gpio_config(void)
3133{
3134 return msm_gpios_request_enable(qsd_spi_gpio_config_data,
3135 ARRAY_SIZE(qsd_spi_gpio_config_data));
3136}
3137
3138static void msm_qsd_spi_gpio_release(void)
3139{
3140 msm_gpios_disable_free(qsd_spi_gpio_config_data,
3141 ARRAY_SIZE(qsd_spi_gpio_config_data));
3142}
3143
3144static struct msm_spi_platform_data qsd_spi_pdata = {
3145 .max_clock_speed = 26331429,
3146 .gpio_config = msm_qsd_spi_gpio_config,
3147 .gpio_release = msm_qsd_spi_gpio_release,
3148 .dma_config = msm_qsd_spi_dma_config,
3149};
3150
3151static void __init msm_qsd_spi_init(void)
3152{
3153 qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
3154}
3155
3156#ifdef CONFIG_USB_EHCI_MSM_72K
3157static void msm_hsusb_vbus_power(unsigned phy_info, int on)
3158{
3159 int rc;
3160 static int vbus_is_on;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303161 struct pm8xxx_gpio_init_info usb_vbus = {
3162 PM8058_GPIO_PM_TO_SYS(36),
3163 {
3164 .direction = PM_GPIO_DIR_OUT,
3165 .pull = PM_GPIO_PULL_NO,
3166 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3167 .output_value = 1,
3168 .vin_sel = 2,
3169 .out_strength = PM_GPIO_STRENGTH_MED,
3170 .function = PM_GPIO_FUNC_NORMAL,
3171 .inv_int_pol = 0,
3172 },
3173 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003174
3175 /* If VBUS is already on (or off), do nothing. */
3176 if (unlikely(on == vbus_is_on))
3177 return;
3178
3179 if (on) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303180 rc = pm8xxx_gpio_config(usb_vbus.gpio, &usb_vbus.config);
3181 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003182 pr_err("%s PMIC GPIO 36 write failed\n", __func__);
3183 return;
3184 }
3185 } else {
3186 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(36), 0);
3187 }
3188
3189 vbus_is_on = on;
3190}
3191
3192static struct msm_usb_host_platform_data msm_usb_host_pdata = {
3193 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
3194 .vbus_power = msm_hsusb_vbus_power,
3195 .power_budget = 180,
3196};
3197#endif
3198
3199#ifdef CONFIG_USB_MSM_OTG_72K
3200static int hsusb_rpc_connect(int connect)
3201{
3202 if (connect)
3203 return msm_hsusb_rpc_connect();
3204 else
3205 return msm_hsusb_rpc_close();
3206}
3207#endif
3208
3209#ifdef CONFIG_USB_MSM_OTG_72K
Justin Paupore3f40f342011-08-10 18:52:16 -07003210static struct regulator *vreg_3p3;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003211static int msm_hsusb_ldo_init(int init)
3212{
3213 uint32_t version = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07003214 int def_vol = 3400000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003215
3216 version = socinfo_get_version();
3217
3218 if (SOCINFO_VERSION_MAJOR(version) >= 2 &&
3219 SOCINFO_VERSION_MINOR(version) >= 1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003220 def_vol = 3075000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003221 pr_debug("%s: default voltage:%d\n", __func__, def_vol);
3222 }
3223
3224 if (init) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003225 vreg_3p3 = regulator_get(NULL, "usb");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003226 if (IS_ERR(vreg_3p3))
3227 return PTR_ERR(vreg_3p3);
Justin Paupore3f40f342011-08-10 18:52:16 -07003228 regulator_set_voltage(vreg_3p3, def_vol, def_vol);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003229 } else
Justin Paupore3f40f342011-08-10 18:52:16 -07003230 regulator_put(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003231
3232 return 0;
3233}
3234
3235static int msm_hsusb_ldo_enable(int enable)
3236{
3237 static int ldo_status;
3238
3239 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3240 return -ENODEV;
3241
3242 if (ldo_status == enable)
3243 return 0;
3244
3245 ldo_status = enable;
3246
3247 if (enable)
Justin Paupore3f40f342011-08-10 18:52:16 -07003248 return regulator_enable(vreg_3p3);
3249 else
3250 return regulator_disable(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003251}
3252
3253static int msm_hsusb_ldo_set_voltage(int mV)
3254{
Justin Paupore3f40f342011-08-10 18:52:16 -07003255 static int cur_voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003256
3257 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3258 return -ENODEV;
3259
3260 if (cur_voltage == mV)
3261 return 0;
3262
3263 cur_voltage = mV;
3264
3265 pr_debug("%s: (%d)\n", __func__, mV);
3266
Justin Paupore3f40f342011-08-10 18:52:16 -07003267 return regulator_set_voltage(vreg_3p3, mV*1000, mV*1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003268}
3269#endif
3270
3271#ifndef CONFIG_USB_EHCI_MSM_72K
3272static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init);
3273#endif
3274static struct msm_otg_platform_data msm_otg_pdata = {
3275 .rpc_connect = hsusb_rpc_connect,
3276
3277#ifndef CONFIG_USB_EHCI_MSM_72K
3278 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
3279#else
3280 .vbus_power = msm_hsusb_vbus_power,
3281#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003282 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
3283 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
3284 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
3285 .se1_gating = SE1_GATING_DISABLE,
3286 .chg_vbus_draw = hsusb_chg_vbus_draw,
3287 .chg_connected = hsusb_chg_connected,
3288 .chg_init = hsusb_chg_init,
3289 .ldo_enable = msm_hsusb_ldo_enable,
3290 .ldo_init = msm_hsusb_ldo_init,
3291 .ldo_set_voltage = msm_hsusb_ldo_set_voltage,
3292};
3293
3294#ifdef CONFIG_USB_GADGET
3295static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
3296 .is_phy_status_timer_on = 1,
3297};
3298#endif
3299#ifndef CONFIG_USB_EHCI_MSM_72K
3300typedef void (*notify_vbus_state) (int);
3301notify_vbus_state notify_vbus_state_func_ptr;
3302int vbus_on_irq;
3303static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
3304{
3305 pr_info("%s: vbus notification from pmic\n", __func__);
3306
3307 (*notify_vbus_state_func_ptr) (1);
3308
3309 return IRQ_HANDLED;
3310}
3311static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
3312{
3313 int ret;
3314
3315 if (init) {
3316 if (!callback)
3317 return -ENODEV;
3318
3319 notify_vbus_state_func_ptr = callback;
3320 vbus_on_irq = platform_get_irq_byname(&msm_device_otg,
3321 "vbus_on");
3322 if (vbus_on_irq <= 0) {
3323 pr_err("%s: unable to get vbus on irq\n", __func__);
3324 return -ENODEV;
3325 }
3326
3327 ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq,
3328 IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
3329 if (ret < 0) {
3330 pr_info("%s: request_irq for vbus_on"
3331 "interrupt failed\n", __func__);
3332 return ret;
3333 }
3334 msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
3335 return 0;
3336 } else {
3337 free_irq(vbus_on_irq, 0);
3338 notify_vbus_state_func_ptr = NULL;
3339 return 0;
3340 }
3341}
3342#endif
3343
3344static struct android_pmem_platform_data android_pmem_pdata = {
3345 .name = "pmem",
3346 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
3347 .cached = 1,
3348 .memory_type = MEMTYPE_EBI0,
3349};
3350
3351static struct platform_device android_pmem_device = {
3352 .name = "android_pmem",
3353 .id = 0,
3354 .dev = { .platform_data = &android_pmem_pdata },
3355};
3356
3357#ifndef CONFIG_SPI_QSD
3358static int lcdc_gpio_array_num[] = {
3359 45, /* spi_clk */
3360 46, /* spi_cs */
3361 47, /* spi_mosi */
3362 48, /* spi_miso */
3363 };
3364
3365static struct msm_gpio lcdc_gpio_config_data[] = {
3366 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3367 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3368 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
3369 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3370};
3371
3372static void lcdc_config_gpios(int enable)
3373{
3374 if (enable) {
3375 msm_gpios_request_enable(lcdc_gpio_config_data,
3376 ARRAY_SIZE(
3377 lcdc_gpio_config_data));
3378 } else
3379 msm_gpios_disable_free(lcdc_gpio_config_data,
3380 ARRAY_SIZE(
3381 lcdc_gpio_config_data));
3382}
3383#endif
3384
3385static struct msm_panel_common_pdata lcdc_sharp_panel_data = {
3386#ifndef CONFIG_SPI_QSD
3387 .panel_config_gpio = lcdc_config_gpios,
3388 .gpio_num = lcdc_gpio_array_num,
3389#endif
3390 .gpio = 2, /* LPG PMIC_GPIO26 channel number */
3391};
3392
3393static struct platform_device lcdc_sharp_panel_device = {
3394 .name = "lcdc_sharp_wvga",
3395 .id = 0,
3396 .dev = {
3397 .platform_data = &lcdc_sharp_panel_data,
3398 }
3399};
3400
3401static struct msm_gpio dtv_panel_irq_gpios[] = {
3402 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
3403 "hdmi_int" },
3404};
3405
3406static struct msm_gpio dtv_panel_gpios[] = {
3407 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
3408 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
3409 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
3410 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
3411 { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
3412 { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
3413 { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
3414 { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
3415 { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
3416 { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
3417 { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
3418 { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
3419 { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
3420 { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
3421 { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
3422 { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
3423 { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
3424 { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
3425 { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
3426 { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
3427 { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
3428 { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
3429 { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
3430 { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
3431 { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
3432 { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
3433 { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
3434 { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
3435 { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
3436 { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
3437 { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
3438 { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
3439};
3440
3441
3442#ifdef HDMI_RESET
3443static unsigned dtv_reset_gpio =
3444 GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3445#endif
3446
Justin Paupore3f40f342011-08-10 18:52:16 -07003447static struct regulator_bulk_data hdmi_core_regs[] = {
3448 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3449};
3450
3451static struct regulator_bulk_data hdmi_comm_regs[] = {
3452 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3453 { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 },
3454};
3455
3456static struct regulator_bulk_data hdmi_cec_regs[] = {
3457 { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 },
3458};
3459
3460static int __init hdmi_init_regs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003461{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003462 int rc;
3463
Justin Paupore3f40f342011-08-10 18:52:16 -07003464 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs),
3465 hdmi_core_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003466
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003467 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003468 pr_err("%s: could not get %s regulators: %d\n",
3469 __func__, "core", rc);
3470 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003471 }
3472
Justin Paupore3f40f342011-08-10 18:52:16 -07003473 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs),
3474 hdmi_core_regs);
3475
3476 if (rc) {
3477 pr_err("%s: could not set %s voltages: %d\n",
3478 __func__, "core", rc);
3479 goto free_core;
3480 }
3481
3482 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs),
3483 hdmi_comm_regs);
3484
3485 if (rc) {
3486 pr_err("%s: could not get %s regulators: %d\n",
3487 __func__, "comm", rc);
3488 goto free_core;
3489 }
3490
3491 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs),
3492 hdmi_comm_regs);
3493
3494 if (rc) {
3495 pr_err("%s: could not set %s voltages: %d\n",
3496 __func__, "comm", rc);
3497 goto free_comm;
3498 }
3499
3500 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs),
3501 hdmi_cec_regs);
3502
3503 if (rc) {
3504 pr_err("%s: could not get %s regulators: %d\n",
3505 __func__, "cec", rc);
3506 goto free_comm;
3507 }
3508
3509 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs),
3510 hdmi_cec_regs);
3511
3512 if (rc) {
3513 pr_err("%s: could not set %s voltages: %d\n",
3514 __func__, "cec", rc);
3515 goto free_cec;
3516 }
3517
3518 return 0;
3519
3520free_cec:
3521 regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs);
3522free_comm:
3523 regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs);
3524free_core:
3525 regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs);
3526out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003527 return rc;
3528}
3529
Justin Paupore3f40f342011-08-10 18:52:16 -07003530static int hdmi_init_irq(void)
3531{
3532 int rc = msm_gpios_enable(dtv_panel_irq_gpios,
3533 ARRAY_SIZE(dtv_panel_irq_gpios));
3534 if (rc < 0) {
3535 pr_err("%s: gpio enable failed: %d\n", __func__, rc);
3536 return rc;
3537 }
3538 pr_info("%s\n", __func__);
3539
3540 return 0;
3541}
3542
3543static int hdmi_enable_5v(int on)
3544{
3545 int pmic_gpio_hdmi_5v_en ;
3546
3547 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
3548 machine_is_msm7x30_fluid())
3549 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
3550 else
3551 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
3552
3553 pr_info("%s: %d\n", __func__, on);
3554 if (on) {
3555 int rc;
3556 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
3557 "hdmi_5V_en");
3558 if (rc) {
3559 pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
3560 __func__);
3561 return rc;
3562 }
3563 gpio_set_value_cansleep(
3564 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
3565 } else {
3566 gpio_set_value_cansleep(
3567 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
3568 gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
3569 }
3570 return 0;
3571}
3572
3573static int hdmi_comm_power(int on, int show)
3574{
3575 if (show)
3576 pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
3577 return on ?
3578 regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs),
3579 hdmi_comm_regs) :
3580 regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs),
3581 hdmi_comm_regs);
3582}
3583
3584static int hdmi_core_power(int on, int show)
3585{
3586 if (show)
3587 pr_info("%s: %d <LDO8>\n", __func__, on);
3588 return on ?
3589 regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs),
3590 hdmi_core_regs) :
3591 regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs),
3592 hdmi_core_regs);
3593}
3594
3595static int hdmi_cec_power(int on)
3596{
3597 pr_info("%s: %d <LDO17>\n", __func__, on);
3598 return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs),
3599 hdmi_cec_regs) :
3600 regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs),
3601 hdmi_cec_regs);
3602}
3603
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003604#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
3605/* there is an i2c address conflict between adv7520 and bma150 sensor after
3606 * power up on fluid. As a solution, the default address of adv7520's packet
3607 * memory is changed as soon as possible
3608 */
3609static int __init fluid_i2c_address_fixup(void)
3610{
3611 unsigned char wBuff[16];
3612 unsigned char rBuff[16];
3613 struct i2c_msg msgs[3];
3614 int res;
3615 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003616 struct i2c_adapter *adapter;
3617
3618 if (machine_is_msm7x30_fluid()) {
3619 adapter = i2c_get_adapter(0);
3620 if (!adapter) {
3621 pr_err("%s: invalid i2c adapter\n", __func__);
3622 return PTR_ERR(adapter);
3623 }
3624
3625 /* turn on LDO8 */
Justin Paupore3f40f342011-08-10 18:52:16 -07003626 rc = hdmi_core_power(1, 0);
3627 if (rc) {
3628 pr_err("%s: could not enable hdmi core regs: %d",
3629 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003630 goto adapter_put;
3631 }
3632
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003633 /* change packet memory address to 0x74 */
3634 wBuff[0] = 0x45;
3635 wBuff[1] = 0x74;
3636
3637 msgs[0].addr = ADV7520_I2C_ADDR;
3638 msgs[0].flags = 0;
3639 msgs[0].buf = (unsigned char *) wBuff;
3640 msgs[0].len = 2;
3641
3642 res = i2c_transfer(adapter, msgs, 1);
3643 if (res != 1) {
3644 pr_err("%s: error writing adv7520\n", __func__);
3645 goto ldo8_disable;
3646 }
3647
3648 /* powerdown adv7520 using bit 6 */
3649 /* i2c read first */
3650 wBuff[0] = 0x41;
3651
3652 msgs[0].addr = ADV7520_I2C_ADDR;
3653 msgs[0].flags = 0;
3654 msgs[0].buf = (unsigned char *) wBuff;
3655 msgs[0].len = 1;
3656
3657 msgs[1].addr = ADV7520_I2C_ADDR;
3658 msgs[1].flags = I2C_M_RD;
3659 msgs[1].buf = rBuff;
3660 msgs[1].len = 1;
3661 res = i2c_transfer(adapter, msgs, 2);
3662 if (res != 2) {
3663 pr_err("%s: error reading adv7520\n", __func__);
3664 goto ldo8_disable;
3665 }
3666
3667 /* i2c write back */
3668 wBuff[0] = 0x41;
3669 wBuff[1] = rBuff[0] | 0x40;
3670
3671 msgs[0].addr = ADV7520_I2C_ADDR;
3672 msgs[0].flags = 0;
3673 msgs[0].buf = (unsigned char *) wBuff;
3674 msgs[0].len = 2;
3675
3676 res = i2c_transfer(adapter, msgs, 1);
3677 if (res != 1) {
3678 pr_err("%s: error writing adv7520\n", __func__);
3679 goto ldo8_disable;
3680 }
3681
3682 /* for successful fixup, we release the i2c adapter */
3683 /* but leave ldo8 on so that the adv7520 is not repowered */
3684 i2c_put_adapter(adapter);
3685 pr_info("%s: fluid i2c address conflict resolved\n", __func__);
3686 }
3687 return 0;
3688
3689ldo8_disable:
Justin Paupore3f40f342011-08-10 18:52:16 -07003690 hdmi_core_power(0, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003691adapter_put:
3692 i2c_put_adapter(adapter);
3693 return rc;
3694}
3695fs_initcall_sync(fluid_i2c_address_fixup);
3696#endif
3697
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003698static bool hdmi_check_hdcp_hw_support(void)
3699{
3700 if (machine_is_msm7x30_fluid())
3701 return false;
3702 else
3703 return true;
3704}
3705
3706static int dtv_panel_power(int on)
3707{
3708 int flag_on = !!on;
3709 static int dtv_power_save_on;
3710 int rc;
3711
3712 if (dtv_power_save_on == flag_on)
3713 return 0;
3714
3715 dtv_power_save_on = flag_on;
3716 pr_info("%s: %d\n", __func__, on);
3717
3718#ifdef HDMI_RESET
3719 if (on) {
3720 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
3721 rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
3722 if (rc) {
3723 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
3724 __func__, dtv_reset_gpio, rc);
3725 return rc;
3726 }
3727
3728 /* bring reset line low to hold reset*/
3729 gpio_set_value(37, 0);
3730 }
3731#endif
3732
3733 if (on) {
3734 rc = msm_gpios_enable(dtv_panel_gpios,
3735 ARRAY_SIZE(dtv_panel_gpios));
3736 if (rc < 0) {
3737 printk(KERN_ERR "%s: gpio enable failed: %d\n",
3738 __func__, rc);
3739 return rc;
3740 }
3741 } else {
3742 rc = msm_gpios_disable(dtv_panel_gpios,
3743 ARRAY_SIZE(dtv_panel_gpios));
3744 if (rc < 0) {
3745 printk(KERN_ERR "%s: gpio disable failed: %d\n",
3746 __func__, rc);
3747 return rc;
3748 }
3749 }
3750
3751 mdelay(5); /* ensure power is stable */
3752
3753#ifdef HDMI_RESET
3754 if (on) {
3755 gpio_set_value(37, 1); /* bring reset line high */
3756 mdelay(10); /* 10 msec before IO can be accessed */
3757 }
3758#endif
3759
3760 return rc;
3761}
3762
3763static struct lcdc_platform_data dtv_pdata = {
3764 .lcdc_power_save = dtv_panel_power,
3765};
3766
3767static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3768 .inject_rx_on_wakeup = 1,
3769 .rx_to_inject = 0xFD,
3770};
3771
3772static struct resource msm_fb_resources[] = {
3773 {
3774 .flags = IORESOURCE_DMA,
3775 }
3776};
3777
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08003778#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
3779static struct resource msm_v4l2_video_overlay_resources[] = {
3780 {
3781 .flags = IORESOURCE_DMA,
3782 }
3783};
3784#endif
3785
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003786static int msm_fb_detect_panel(const char *name)
3787{
3788 if (machine_is_msm7x30_fluid()) {
3789 if (!strcmp(name, "lcdc_sharp_wvga_pt"))
3790 return 0;
3791 } else {
3792 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
3793 return -EPERM;
3794 else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20))
3795 return 0;
3796 else if (!strcmp(name, "mddi_orise"))
3797 return -EPERM;
3798 else if (!strcmp(name, "mddi_quickvx"))
3799 return -EPERM;
3800 }
3801 return -ENODEV;
3802}
3803
3804static struct msm_fb_platform_data msm_fb_pdata = {
3805 .detect_client = msm_fb_detect_panel,
3806 .mddi_prescan = 1,
3807};
3808
3809static struct platform_device msm_fb_device = {
3810 .name = "msm_fb",
3811 .id = 0,
3812 .num_resources = ARRAY_SIZE(msm_fb_resources),
3813 .resource = msm_fb_resources,
3814 .dev = {
3815 .platform_data = &msm_fb_pdata,
3816 }
3817};
3818
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08003819#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
3820
3821static struct platform_device msm_v4l2_video_overlay_device = {
3822 .name = "msm_v4l2_overlay_pd",
3823 .id = 0,
3824 .num_resources = ARRAY_SIZE(msm_v4l2_video_overlay_resources),
3825 .resource = msm_v4l2_video_overlay_resources,
3826};
3827#endif
3828
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003829static struct platform_device msm_migrate_pages_device = {
3830 .name = "msm_migrate_pages",
3831 .id = -1,
3832};
3833
3834static struct android_pmem_platform_data android_pmem_adsp_pdata = {
3835 .name = "pmem_adsp",
3836 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
3837 .cached = 0,
3838 .memory_type = MEMTYPE_EBI0,
3839};
3840
3841static struct android_pmem_platform_data android_pmem_audio_pdata = {
3842 .name = "pmem_audio",
3843 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
3844 .cached = 0,
3845 .memory_type = MEMTYPE_EBI0,
3846};
3847
3848static struct platform_device android_pmem_adsp_device = {
3849 .name = "android_pmem",
3850 .id = 2,
3851 .dev = { .platform_data = &android_pmem_adsp_pdata },
3852};
3853
3854static struct platform_device android_pmem_audio_device = {
3855 .name = "android_pmem",
3856 .id = 4,
3857 .dev = { .platform_data = &android_pmem_audio_pdata },
3858};
3859
3860#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3861 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
3862 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3863 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3864
3865#define QCE_SIZE 0x10000
3866#define QCE_0_BASE 0xA8400000
3867
3868#define QCE_HW_KEY_SUPPORT 1
3869#define QCE_SHA_HMAC_SUPPORT 0
3870#define QCE_SHARE_CE_RESOURCE 0
3871#define QCE_CE_SHARED 0
3872
3873static struct resource qcrypto_resources[] = {
3874 [0] = {
3875 .start = QCE_0_BASE,
3876 .end = QCE_0_BASE + QCE_SIZE - 1,
3877 .flags = IORESOURCE_MEM,
3878 },
3879 [1] = {
3880 .name = "crypto_channels",
3881 .start = DMOV_CE_IN_CHAN,
3882 .end = DMOV_CE_OUT_CHAN,
3883 .flags = IORESOURCE_DMA,
3884 },
3885 [2] = {
3886 .name = "crypto_crci_in",
3887 .start = DMOV_CE_IN_CRCI,
3888 .end = DMOV_CE_IN_CRCI,
3889 .flags = IORESOURCE_DMA,
3890 },
3891 [3] = {
3892 .name = "crypto_crci_out",
3893 .start = DMOV_CE_OUT_CRCI,
3894 .end = DMOV_CE_OUT_CRCI,
3895 .flags = IORESOURCE_DMA,
3896 },
3897 [4] = {
3898 .name = "crypto_crci_hash",
3899 .start = DMOV_CE_HASH_CRCI,
3900 .end = DMOV_CE_HASH_CRCI,
3901 .flags = IORESOURCE_DMA,
3902 },
3903};
3904
3905static struct resource qcedev_resources[] = {
3906 [0] = {
3907 .start = QCE_0_BASE,
3908 .end = QCE_0_BASE + QCE_SIZE - 1,
3909 .flags = IORESOURCE_MEM,
3910 },
3911 [1] = {
3912 .name = "crypto_channels",
3913 .start = DMOV_CE_IN_CHAN,
3914 .end = DMOV_CE_OUT_CHAN,
3915 .flags = IORESOURCE_DMA,
3916 },
3917 [2] = {
3918 .name = "crypto_crci_in",
3919 .start = DMOV_CE_IN_CRCI,
3920 .end = DMOV_CE_IN_CRCI,
3921 .flags = IORESOURCE_DMA,
3922 },
3923 [3] = {
3924 .name = "crypto_crci_out",
3925 .start = DMOV_CE_OUT_CRCI,
3926 .end = DMOV_CE_OUT_CRCI,
3927 .flags = IORESOURCE_DMA,
3928 },
3929 [4] = {
3930 .name = "crypto_crci_hash",
3931 .start = DMOV_CE_HASH_CRCI,
3932 .end = DMOV_CE_HASH_CRCI,
3933 .flags = IORESOURCE_DMA,
3934 },
3935};
3936
3937#endif
3938
3939#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3940 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
3941
3942static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
3943 .ce_shared = QCE_CE_SHARED,
3944 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
3945 .hw_key_support = QCE_HW_KEY_SUPPORT,
3946 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08003947 /* Bus Scaling declaration*/
3948 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003949};
3950
3951static struct platform_device qcrypto_device = {
3952 .name = "qcrypto",
3953 .id = 0,
3954 .num_resources = ARRAY_SIZE(qcrypto_resources),
3955 .resource = qcrypto_resources,
3956 .dev = {
3957 .coherent_dma_mask = DMA_BIT_MASK(32),
3958 .platform_data = &qcrypto_ce_hw_suppport,
3959 },
3960};
3961#endif
3962
3963#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3964 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3965
3966static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
3967 .ce_shared = QCE_CE_SHARED,
3968 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
3969 .hw_key_support = QCE_HW_KEY_SUPPORT,
3970 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08003971 /* Bus Scaling declaration*/
3972 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003973};
3974static struct platform_device qcedev_device = {
3975 .name = "qce",
3976 .id = 0,
3977 .num_resources = ARRAY_SIZE(qcedev_resources),
3978 .resource = qcedev_resources,
3979 .dev = {
3980 .coherent_dma_mask = DMA_BIT_MASK(32),
3981 .platform_data = &qcedev_ce_hw_suppport,
3982 },
3983};
3984#endif
3985
3986static int mddi_toshiba_pmic_bl(int level)
3987{
3988 int ret = -EPERM;
3989
3990 ret = pmic_set_led_intensity(LED_LCD, level);
3991
3992 if (ret)
3993 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
3994 __func__);
3995 return ret;
3996}
3997
3998static struct msm_panel_common_pdata mddi_toshiba_pdata = {
3999 .pmic_backlight = mddi_toshiba_pmic_bl,
4000};
4001
4002static struct platform_device mddi_toshiba_device = {
4003 .name = "mddi_toshiba",
4004 .id = 0,
4005 .dev = {
4006 .platform_data = &mddi_toshiba_pdata,
4007 }
4008};
4009
4010static unsigned wega_reset_gpio =
4011 GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4012
4013static struct msm_gpio fluid_vee_reset_gpio[] = {
4014 { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
4015};
4016
4017static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1;
4018static unsigned char quickvx_ldo_enabled;
4019
4020static unsigned quickvx_vlp_gpio =
4021 GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4022
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304023static struct pm8xxx_gpio_init_info pmic_quickvx_clk_gpio = {
4024 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_QUICKVX_CLK),
4025 {
4026 .direction = PM_GPIO_DIR_OUT,
4027 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
4028 .output_value = 1,
4029 .pull = PM_GPIO_PULL_NO,
4030 .vin_sel = PM8058_GPIO_VIN_S3,
4031 .out_strength = PM_GPIO_STRENGTH_HIGH,
4032 .function = PM_GPIO_FUNC_2,
4033 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004034};
4035
Justin Paupore3f40f342011-08-10 18:52:16 -07004036static struct regulator *mddi_ldo20;
4037static struct regulator *mddi_ldo12;
4038static struct regulator *mddi_ldo16;
4039static struct regulator *mddi_ldo6;
4040static struct regulator *mddi_lcd;
4041
4042static int display_common_init(void)
4043{
4044 struct regulator_bulk_data regs[5] = {
4045 { .supply = "ldo20", /* voltage set in display_common_power */},
4046 { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 },
4047 { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 },
4048 { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 },
4049 { .supply = NULL, /* mddi_lcd, initialized below */ },
4050 };
4051
4052 int rc = 0;
4053
4054 if (machine_is_msm7x30_fluid()) {
4055 /* lcd: LDO8 @1.8V */
4056 regs[4].supply = "ldo8";
4057 regs[4].min_uV = 1800000;
4058 regs[4].max_uV = 1800000;
4059 } else {
4060 /* lcd: LDO15 @3.1V */
4061 regs[4].supply = "ldo15";
4062 regs[4].min_uV = 3100000;
4063 regs[4].max_uV = 3100000;
4064 }
4065
4066 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4067 if (rc) {
4068 pr_err("%s: regulator_bulk_get failed: %d\n",
4069 __func__, rc);
4070 goto bail;
4071 }
4072
4073 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4074 if (rc) {
4075 pr_err("%s: regulator_bulk_set_voltage failed: %d\n",
4076 __func__, rc);
4077 goto put_regs;
4078 }
4079
4080 mddi_ldo20 = regs[0].consumer;
4081 mddi_ldo12 = regs[1].consumer;
4082 mddi_ldo6 = regs[2].consumer;
4083 mddi_ldo16 = regs[3].consumer;
4084 mddi_lcd = regs[4].consumer;
4085
4086 return rc;
4087
4088put_regs:
4089 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4090bail:
4091 return rc;
4092}
4093
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004094static int display_common_power(int on)
4095{
4096 int rc = 0, flag_on = !!on;
4097 static int display_common_power_save_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004098 static bool display_regs_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004099
4100 if (display_common_power_save_on == flag_on)
4101 return 0;
4102
4103 display_common_power_save_on = flag_on;
4104
Justin Paupore3f40f342011-08-10 18:52:16 -07004105 if (unlikely(!display_regs_initialized)) {
4106 rc = display_common_init();
4107 if (rc) {
4108 pr_err("%s: regulator init failed: %d\n",
4109 __func__, rc);
4110 return rc;
4111 }
4112 display_regs_initialized = true;
4113 }
4114
4115
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004116 if (on) {
4117 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
4118 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
4119 if (rc) {
4120 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4121 __func__, wega_reset_gpio, rc);
4122 return rc;
4123 }
4124
4125 /* bring reset line low to hold reset*/
4126 gpio_set_value(180, 0);
4127
4128 if (quickvx_mddi_client) {
4129 /* QuickVX chip -- VLP pin -- gpio 97 */
4130 rc = gpio_tlmm_config(quickvx_vlp_gpio,
4131 GPIO_CFG_ENABLE);
4132 if (rc) {
4133 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4134 __func__, quickvx_vlp_gpio, rc);
4135 return rc;
4136 }
4137
4138 /* bring QuickVX VLP line low */
4139 gpio_set_value(97, 0);
4140
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304141 rc = pm8xxx_gpio_config(pmic_quickvx_clk_gpio.gpio,
4142 &pmic_quickvx_clk_gpio.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004143 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304144 pr_err("%s: pm8xxx_gpio_config(%#x)=%d\n",
4145 __func__, pmic_quickvx_clk_gpio.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004146 rc);
4147 return rc;
4148 }
4149
4150 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4151 PMIC_GPIO_QUICKVX_CLK), 0);
4152 }
4153 }
4154
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004155 if (quickvx_mddi_client)
Justin Paupore3f40f342011-08-10 18:52:16 -07004156 rc = regulator_set_voltage(mddi_ldo20, 1800000, 1800000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004157 else
Justin Paupore3f40f342011-08-10 18:52:16 -07004158 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000);
4159
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004160 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004161 pr_err("%s: could not set voltage for ldo20: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004162 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07004163 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004164 }
4165
4166 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004167 rc = regulator_enable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004168 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004169 pr_err("%s: LDO20 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004170 __func__, rc);
4171 return rc;
4172 }
4173
Justin Paupore3f40f342011-08-10 18:52:16 -07004174 rc = regulator_enable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004175 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004176 pr_err("%s: LDO12 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004177 __func__, rc);
4178 return rc;
4179 }
4180
4181 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004182 rc = regulator_enable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004183 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004184 pr_err("%s: LDO16 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004185 __func__, rc);
4186 return rc;
4187 }
4188 }
4189
Justin Paupore3f40f342011-08-10 18:52:16 -07004190 if (quickvx_ldo_enabled) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004191 /* Disable LDO6 during display ON */
Justin Paupore3f40f342011-08-10 18:52:16 -07004192 rc = regulator_disable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004193 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004194 pr_err("%s: LDO6 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004195 __func__, rc);
4196 return rc;
4197 }
4198 quickvx_ldo_enabled = 0;
4199 }
4200
Justin Paupore3f40f342011-08-10 18:52:16 -07004201 rc = regulator_enable(mddi_lcd);
4202 if (rc) {
4203 pr_err("%s: LCD regulator enable failed (%d)\n",
4204 __func__, rc);
4205 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004206 }
4207
4208 mdelay(5); /* ensure power is stable */
4209
4210 if (machine_is_msm7x30_fluid()) {
4211 rc = msm_gpios_request_enable(fluid_vee_reset_gpio,
4212 ARRAY_SIZE(fluid_vee_reset_gpio));
4213 if (rc)
4214 pr_err("%s gpio_request_enable failed rc=%d\n",
4215 __func__, rc);
4216 else {
4217 /* assert vee reset_n */
4218 gpio_set_value(20, 1);
4219 gpio_set_value(20, 0);
4220 mdelay(1);
4221 gpio_set_value(20, 1);
4222 }
4223 }
4224
4225 gpio_set_value(180, 1); /* bring reset line high */
4226 mdelay(10); /* 10 msec before IO can be accessed */
4227
4228 if (quickvx_mddi_client) {
4229 gpio_set_value(97, 1);
4230 msleep(2);
4231 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4232 PMIC_GPIO_QUICKVX_CLK), 1);
4233 msleep(2);
4234 }
4235
4236 rc = pmapp_display_clock_config(1);
4237 if (rc) {
4238 pr_err("%s pmapp_display_clock_config rc=%d\n",
4239 __func__, rc);
4240 return rc;
4241 }
4242
4243 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004244 rc = regulator_disable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004245 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004246 pr_err("%s: LDO20 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004247 __func__, rc);
4248 return rc;
4249 }
4250
4251
4252 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004253 rc = regulator_disable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004254 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004255 pr_err("%s: LDO16 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004256 __func__, rc);
4257 return rc;
4258 }
4259 }
4260
4261 if (quickvx_mddi_client && !quickvx_ldo_enabled) {
4262 /* Enable LDO6 during display OFF for
4263 Quicklogic chip to sleep with data retention */
Justin Paupore3f40f342011-08-10 18:52:16 -07004264 rc = regulator_enable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004265 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004266 pr_err("%s: LDO6 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004267 __func__, rc);
4268 return rc;
4269 }
4270 quickvx_ldo_enabled = 1;
4271 }
4272
4273 gpio_set_value(180, 0); /* bring reset line low */
4274
4275 if (quickvx_mddi_client) {
4276 gpio_set_value(97, 0);
4277 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4278 PMIC_GPIO_QUICKVX_CLK), 0);
4279 }
4280
Justin Paupore3f40f342011-08-10 18:52:16 -07004281 rc = regulator_disable(mddi_lcd);
4282 if (rc) {
4283 pr_err("%s: LCD regulator disable failed (%d)\n",
4284 __func__, rc);
4285 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004286 }
4287
4288 mdelay(5); /* ensure power is stable */
4289
Justin Paupore3f40f342011-08-10 18:52:16 -07004290 rc = regulator_disable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004291 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004292 pr_err("%s: LDO12 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004293 __func__, rc);
4294 return rc;
4295 }
4296
4297 if (machine_is_msm7x30_fluid()) {
4298 msm_gpios_disable_free(fluid_vee_reset_gpio,
4299 ARRAY_SIZE(fluid_vee_reset_gpio));
4300 }
4301
4302 rc = pmapp_display_clock_config(0);
4303 if (rc) {
4304 pr_err("%s pmapp_display_clock_config rc=%d\n",
4305 __func__, rc);
4306 return rc;
4307 }
4308 }
4309
4310 return rc;
4311}
4312
4313static int msm_fb_mddi_sel_clk(u32 *clk_rate)
4314{
4315 *clk_rate *= 2;
4316 return 0;
4317}
4318
4319static int msm_fb_mddi_client_power(u32 client_id)
4320{
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304321 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004322 printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
4323 /* Check if it is Quicklogic client */
4324 if (client_id == 0xc5835800) {
4325 printk(KERN_NOTICE "\n Quicklogic MDDI client");
4326 other_mddi_client = 0;
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304327 if (IS_ERR(mddi_ldo16)) {
4328 rc = PTR_ERR(mddi_ldo16);
4329 pr_err("%s: gp10 vreg get failed (%d)\n", __func__, rc);
4330 return rc;
4331 }
4332 rc = regulator_disable(mddi_ldo16);
4333 if (rc) {
4334 pr_err("%s: LDO16 vreg enable failed (%d)\n",
4335 __func__, rc);
4336 return rc;
4337 }
4338
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004339 } else {
4340 printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
4341 quickvx_mddi_client = 0;
4342 gpio_set_value(97, 0);
4343 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4344 PMIC_GPIO_QUICKVX_CLK), 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004345 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004346
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004347 return 0;
4348}
4349
4350static struct mddi_platform_data mddi_pdata = {
4351 .mddi_power_save = display_common_power,
4352 .mddi_sel_clk = msm_fb_mddi_sel_clk,
4353 .mddi_client_power = msm_fb_mddi_client_power,
4354};
4355
4356int mdp_core_clk_rate_table[] = {
4357 122880000,
4358 122880000,
Pradeep Jilagam3cc12f92011-07-26 22:25:18 +05304359 192000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004360 192000000,
4361};
4362
4363static struct msm_panel_common_pdata mdp_pdata = {
4364 .hw_revision_addr = 0xac001270,
4365 .gpio = 30,
4366 .mdp_core_clk_rate = 122880000,
4367 .mdp_core_clk_table = mdp_core_clk_rate_table,
4368 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07004369 .mdp_rev = MDP_REV_40,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004370};
4371
4372static int lcd_panel_spi_gpio_num[] = {
4373 45, /* spi_clk */
4374 46, /* spi_cs */
4375 47, /* spi_mosi */
4376 48, /* spi_miso */
4377 };
4378
4379static struct msm_gpio lcd_panel_gpios[] = {
4380/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
4381 * input. if there is a hardware revision; we should reassign this GPIO to a
4382 * new open line; and removing it will just ensure that this will be missed in
4383 * the future.
4384 { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
4385 */
4386 { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
4387 { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
4388 { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
4389 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4390 { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
4391 { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
4392 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4393#ifndef CONFIG_SPI_QSD
4394 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
4395 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
4396 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
4397 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
4398#endif
4399 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4400 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4401 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4402 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4403 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4404 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4405 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4406 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4407 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4408 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4409 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4410 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4411 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4412 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4413 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4414 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4415 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4416 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4417 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4418 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4419};
4420
4421static struct msm_gpio lcd_sharp_panel_gpios[] = {
4422 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4423 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4424 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4425 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4426 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4427 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4428 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4429 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4430 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4431 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4432 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4433 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4434 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4435 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4436 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4437 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4438 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4439 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4440 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4441 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4442 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4443 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4444};
4445
4446static int lcdc_toshiba_panel_power(int on)
4447{
4448 int rc, i;
4449 struct msm_gpio *gp;
4450
4451 rc = display_common_power(on);
4452 if (rc < 0) {
4453 printk(KERN_ERR "%s display_common_power failed: %d\n",
4454 __func__, rc);
4455 return rc;
4456 }
4457
4458 if (on) {
4459 rc = msm_gpios_enable(lcd_panel_gpios,
4460 ARRAY_SIZE(lcd_panel_gpios));
4461 if (rc < 0) {
4462 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4463 __func__, rc);
4464 }
4465 } else { /* off */
4466 gp = lcd_panel_gpios;
4467 for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
4468 /* ouput low */
4469 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4470 gp++;
4471 }
4472 }
4473
4474 return rc;
4475}
4476
4477static int lcdc_sharp_panel_power(int on)
4478{
4479 int rc, i;
4480 struct msm_gpio *gp;
4481
4482 rc = display_common_power(on);
4483 if (rc < 0) {
4484 printk(KERN_ERR "%s display_common_power failed: %d\n",
4485 __func__, rc);
4486 return rc;
4487 }
4488
4489 if (on) {
4490 rc = msm_gpios_enable(lcd_sharp_panel_gpios,
4491 ARRAY_SIZE(lcd_sharp_panel_gpios));
4492 if (rc < 0) {
4493 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4494 __func__, rc);
4495 }
4496 } else { /* off */
4497 gp = lcd_sharp_panel_gpios;
4498 for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) {
4499 /* ouput low */
4500 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4501 gp++;
4502 }
4503 }
4504
4505 return rc;
4506}
4507
4508static int lcdc_panel_power(int on)
4509{
4510 int flag_on = !!on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004511 static int lcdc_power_save_on, lcdc_power_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004512
4513 if (lcdc_power_save_on == flag_on)
4514 return 0;
4515
4516 lcdc_power_save_on = flag_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004517
4518 if (unlikely(!lcdc_power_initialized)) {
4519 quickvx_mddi_client = 0;
4520 display_common_init();
4521 lcdc_power_initialized = 1;
4522 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004523
4524 if (machine_is_msm7x30_fluid())
4525 return lcdc_sharp_panel_power(on);
4526 else
4527 return lcdc_toshiba_panel_power(on);
4528}
4529
4530static struct lcdc_platform_data lcdc_pdata = {
4531 .lcdc_power_save = lcdc_panel_power,
4532};
4533
Justin Paupore3f40f342011-08-10 18:52:16 -07004534static struct regulator *atv_s4, *atv_ldo9;
4535
4536static int __init atv_dac_power_init(void)
4537{
4538 int rc;
4539 struct regulator_bulk_data regs[] = {
4540 { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 },
4541 { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 },
4542 };
4543
4544 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4545
4546 if (rc) {
4547 pr_err("%s: could not get regulators: %d\n", __func__, rc);
4548 goto bail;
4549 }
4550
4551 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4552
4553 if (rc) {
4554 pr_err("%s: could not set voltages: %d\n", __func__, rc);
4555 goto reg_free;
4556 }
4557
4558 atv_s4 = regs[0].consumer;
4559 atv_ldo9 = regs[1].consumer;
4560
4561reg_free:
4562 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4563bail:
4564 return rc;
4565}
4566
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004567static int atv_dac_power(int on)
4568{
4569 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004570
4571 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004572 rc = regulator_enable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004573 if (rc) {
4574 pr_err("%s: s4 vreg enable failed (%d)\n",
4575 __func__, rc);
4576 return rc;
4577 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004578 rc = regulator_enable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004579 if (rc) {
4580 pr_err("%s: ldo9 vreg enable failed (%d)\n",
4581 __func__, rc);
4582 return rc;
4583 }
4584 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004585 rc = regulator_disable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004586 if (rc) {
4587 pr_err("%s: ldo9 vreg disable failed (%d)\n",
4588 __func__, rc);
4589 return rc;
4590 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004591 rc = regulator_disable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004592 if (rc) {
4593 pr_err("%s: s4 vreg disable failed (%d)\n",
4594 __func__, rc);
4595 return rc;
4596 }
4597 }
4598 return rc;
4599}
4600
4601static struct tvenc_platform_data atv_pdata = {
4602 .poll = 1,
4603 .pm_vid_en = atv_dac_power,
4604};
4605
4606static void __init msm_fb_add_devices(void)
4607{
4608 msm_fb_register_device("mdp", &mdp_pdata);
4609 msm_fb_register_device("pmdh", &mddi_pdata);
4610 msm_fb_register_device("lcdc", &lcdc_pdata);
4611 msm_fb_register_device("dtv", &dtv_pdata);
4612 msm_fb_register_device("tvenc", &atv_pdata);
4613#ifdef CONFIG_FB_MSM_TVOUT
4614 msm_fb_register_device("tvout_device", NULL);
4615#endif
4616}
4617
4618static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
4619 .gpio_num = lcd_panel_spi_gpio_num,
4620};
4621
4622static struct platform_device lcdc_toshiba_panel_device = {
4623 .name = "lcdc_toshiba_wvga",
4624 .id = 0,
4625 .dev = {
4626 .platform_data = &lcdc_toshiba_panel_data,
4627 }
4628};
4629
4630#if defined(CONFIG_MARIMBA_CORE) && \
4631 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4632static struct platform_device msm_bt_power_device = {
4633 .name = "bt_power",
4634 .id = -1
4635};
4636
4637enum {
4638 BT_RFR,
4639 BT_CTS,
4640 BT_RX,
4641 BT_TX,
4642};
4643
4644static struct msm_gpio bt_config_power_on[] = {
4645 { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4646 "UART1DM_RFR" },
4647 { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4648 "UART1DM_CTS" },
4649 { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4650 "UART1DM_Rx" },
4651 { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4652 "UART1DM_Tx" }
4653};
4654
4655static struct msm_gpio bt_config_power_off[] = {
4656 { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4657 "UART1DM_RFR" },
4658 { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4659 "UART1DM_CTS" },
4660 { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4661 "UART1DM_Rx" },
4662 { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4663 "UART1DM_Tx" }
4664};
4665
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004666static u8 bahama_version;
4667
Justin Paupore3f40f342011-08-10 18:52:16 -07004668static struct regulator_bulk_data regs_bt_marimba[] = {
4669 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4670 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
4671 { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304672 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004673};
4674
4675static struct regulator_bulk_data regs_bt_bahama_v1[] = {
4676 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4677 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
4678 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304679 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004680};
4681
4682static struct regulator_bulk_data regs_bt_bahama_v2[] = {
4683 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4684 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304685 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004686};
4687
4688static struct regulator_bulk_data *regs_bt;
4689static int regs_bt_count;
4690
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004691static int marimba_bt(int on)
4692{
4693 int rc;
4694 int i;
4695 struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
4696
4697 struct marimba_config_register {
4698 u8 reg;
4699 u8 value;
4700 u8 mask;
4701 };
4702
4703 struct marimba_variant_register {
4704 const size_t size;
4705 const struct marimba_config_register *set;
4706 };
4707
4708 const struct marimba_config_register *p;
4709
4710 u8 version;
4711
4712 const struct marimba_config_register v10_bt_on[] = {
4713 { 0xE5, 0x0B, 0x0F },
4714 { 0x05, 0x02, 0x07 },
4715 { 0x06, 0x88, 0xFF },
4716 { 0xE7, 0x21, 0x21 },
4717 { 0xE3, 0x38, 0xFF },
4718 { 0xE4, 0x06, 0xFF },
4719 };
4720
4721 const struct marimba_config_register v10_bt_off[] = {
4722 { 0xE5, 0x0B, 0x0F },
4723 { 0x05, 0x08, 0x0F },
4724 { 0x06, 0x88, 0xFF },
4725 { 0xE7, 0x00, 0x21 },
4726 { 0xE3, 0x00, 0xFF },
4727 { 0xE4, 0x00, 0xFF },
4728 };
4729
4730 const struct marimba_config_register v201_bt_on[] = {
4731 { 0x05, 0x08, 0x07 },
4732 { 0x06, 0x88, 0xFF },
4733 { 0xE7, 0x21, 0x21 },
4734 { 0xE3, 0x38, 0xFF },
4735 { 0xE4, 0x06, 0xFF },
4736 };
4737
4738 const struct marimba_config_register v201_bt_off[] = {
4739 { 0x05, 0x08, 0x07 },
4740 { 0x06, 0x88, 0xFF },
4741 { 0xE7, 0x00, 0x21 },
4742 { 0xE3, 0x00, 0xFF },
4743 { 0xE4, 0x00, 0xFF },
4744 };
4745
4746 const struct marimba_config_register v210_bt_on[] = {
4747 { 0xE9, 0x01, 0x01 },
4748 { 0x06, 0x88, 0xFF },
4749 { 0xE7, 0x21, 0x21 },
4750 { 0xE3, 0x38, 0xFF },
4751 { 0xE4, 0x06, 0xFF },
4752 };
4753
4754 const struct marimba_config_register v210_bt_off[] = {
4755 { 0x06, 0x88, 0xFF },
4756 { 0xE7, 0x00, 0x21 },
4757 { 0xE9, 0x00, 0x01 },
4758 { 0xE3, 0x00, 0xFF },
4759 { 0xE4, 0x00, 0xFF },
4760 };
4761
4762 const struct marimba_variant_register bt_marimba[2][4] = {
4763 {
4764 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4765 { 0, NULL },
4766 { ARRAY_SIZE(v201_bt_off), v201_bt_off },
4767 { ARRAY_SIZE(v210_bt_off), v210_bt_off }
4768 },
4769 {
4770 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4771 { 0, NULL },
4772 { ARRAY_SIZE(v201_bt_on), v201_bt_on },
4773 { ARRAY_SIZE(v210_bt_on), v210_bt_on }
4774 }
4775 };
4776
4777 on = on ? 1 : 0;
4778
4779 rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F);
4780 if (rc < 0) {
4781 printk(KERN_ERR
4782 "%s: version read failed: %d\n",
4783 __func__, rc);
4784 return rc;
4785 }
4786
4787 if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
4788 (bt_marimba[on][version].size == 0)) {
4789 printk(KERN_ERR
4790 "%s: unsupported version\n",
4791 __func__);
4792 return -EIO;
4793 }
4794
4795 p = bt_marimba[on][version].set;
4796
4797 printk(KERN_INFO "%s: found version %d\n", __func__, version);
4798
4799 for (i = 0; i < bt_marimba[on][version].size; i++) {
4800 u8 value = (p+i)->value;
4801 rc = marimba_write_bit_mask(&config,
4802 (p+i)->reg,
4803 &value,
4804 sizeof((p+i)->value),
4805 (p+i)->mask);
4806 if (rc < 0) {
4807 printk(KERN_ERR
4808 "%s: reg %d write failed: %d\n",
4809 __func__, (p+i)->reg, rc);
4810 return rc;
4811 }
4812 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
4813 __func__, (p+i)->reg,
4814 value, (p+i)->mask);
4815 }
4816 return 0;
4817}
4818
4819static int bahama_bt(int on)
4820{
4821 int rc;
4822 int i;
4823 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
4824
4825 struct bahama_variant_register {
4826 const size_t size;
4827 const struct bahama_config_register *set;
4828 };
4829
4830 const struct bahama_config_register *p;
4831
4832
4833 const struct bahama_config_register v10_bt_on[] = {
4834 { 0xE9, 0x00, 0xFF },
4835 { 0xF4, 0x80, 0xFF },
4836 { 0xF0, 0x06, 0xFF },
4837 { 0xE4, 0x00, 0xFF },
4838 { 0xE5, 0x00, 0x0F },
4839#ifdef CONFIG_WLAN
4840 { 0xE6, 0x38, 0x7F },
4841 { 0xE7, 0x06, 0xFF },
4842#endif
4843 { 0x11, 0x13, 0xFF },
4844 { 0xE9, 0x21, 0xFF },
4845 { 0x01, 0x0C, 0x1F },
4846 { 0x01, 0x08, 0x1F },
4847 };
4848
4849 const struct bahama_config_register v20_bt_on_fm_off[] = {
4850 { 0x11, 0x0C, 0xFF },
4851 { 0x13, 0x01, 0xFF },
4852 { 0xF4, 0x80, 0xFF },
4853 { 0xF0, 0x00, 0xFF },
4854 { 0xE9, 0x00, 0xFF },
4855#ifdef CONFIG_WLAN
4856 { 0x81, 0x00, 0xFF },
4857 { 0x82, 0x00, 0xFF },
4858 { 0xE6, 0x38, 0x7F },
4859 { 0xE7, 0x06, 0xFF },
4860#endif
4861 { 0xE9, 0x21, 0xFF }
4862 };
4863
4864 const struct bahama_config_register v20_bt_on_fm_on[] = {
4865 { 0x11, 0x0C, 0xFF },
4866 { 0x13, 0x01, 0xFF },
4867 { 0xF4, 0x86, 0xFF },
4868 { 0xF0, 0x06, 0xFF },
4869 { 0xE9, 0x00, 0xFF },
4870#ifdef CONFIG_WLAN
4871 { 0x81, 0x00, 0xFF },
4872 { 0x82, 0x00, 0xFF },
4873 { 0xE6, 0x38, 0x7F },
4874 { 0xE7, 0x06, 0xFF },
4875#endif
4876 { 0xE9, 0x21, 0xFF }
4877 };
4878
4879 const struct bahama_config_register v10_bt_off[] = {
4880 { 0xE9, 0x00, 0xFF },
4881 };
4882
4883 const struct bahama_config_register v20_bt_off_fm_off[] = {
4884 { 0xF4, 0x84, 0xFF },
4885 { 0xF0, 0x04, 0xFF },
4886 { 0xE9, 0x00, 0xFF }
4887 };
4888
4889 const struct bahama_config_register v20_bt_off_fm_on[] = {
4890 { 0xF4, 0x86, 0xFF },
4891 { 0xF0, 0x06, 0xFF },
4892 { 0xE9, 0x00, 0xFF }
4893 };
4894
4895 const struct bahama_variant_register bt_bahama[2][3] = {
4896 {
4897 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4898 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
4899 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
4900 },
4901 {
4902 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4903 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
4904 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
4905 }
4906 };
4907
4908 u8 offset = 0; /* index into bahama configs */
4909
4910 on = on ? 1 : 0;
4911
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004912
4913 if (bahama_version == VER_2_0) {
4914 if (marimba_get_fm_status(&config))
4915 offset = 0x01;
4916 }
4917
4918 p = bt_bahama[on][bahama_version + offset].set;
4919
4920 dev_info(&msm_bt_power_device.dev,
4921 "%s: found version %d\n", __func__, bahama_version);
4922
4923 for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
4924 u8 value = (p+i)->value;
4925 rc = marimba_write_bit_mask(&config,
4926 (p+i)->reg,
4927 &value,
4928 sizeof((p+i)->value),
4929 (p+i)->mask);
4930 if (rc < 0) {
4931 dev_err(&msm_bt_power_device.dev,
4932 "%s: reg %d write failed: %d\n",
4933 __func__, (p+i)->reg, rc);
4934 return rc;
4935 }
4936 dev_info(&msm_bt_power_device.dev,
4937 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
4938 __func__, (p+i)->reg,
4939 value, (p+i)->mask);
4940 }
4941 /* Update BT status */
4942 if (on)
4943 marimba_set_bt_status(&config, true);
4944 else
4945 marimba_set_bt_status(&config, false);
4946
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004947 return 0;
4948}
4949
Justin Paupore3f40f342011-08-10 18:52:16 -07004950static int bluetooth_regs_init(int bahama_not_marimba)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004951{
Justin Paupore3f40f342011-08-10 18:52:16 -07004952 int rc = 0;
4953 struct device *const dev = &msm_bt_power_device.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004954
4955 if (bahama_not_marimba) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004956 bahama_version = read_bahama_ver();
4957
4958 switch (bahama_version) {
4959 case VER_1_0:
4960 regs_bt = regs_bt_bahama_v1;
4961 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1);
4962 break;
4963 case VER_2_0:
4964 regs_bt = regs_bt_bahama_v2;
4965 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2);
4966 break;
4967 case VER_UNSUPPORTED:
4968 default:
4969 dev_err(dev,
4970 "%s: i2c failure or unsupported version: %d\n",
4971 __func__, bahama_version);
4972 rc = -EIO;
4973 goto out;
4974 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004975 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004976 regs_bt = regs_bt_marimba;
4977 regs_bt_count = ARRAY_SIZE(regs_bt_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004978 }
4979
Justin Paupore3f40f342011-08-10 18:52:16 -07004980 rc = regulator_bulk_get(&msm_bt_power_device.dev,
4981 regs_bt_count, regs_bt);
4982 if (rc) {
4983 dev_err(dev, "%s: could not get regulators: %d\n",
4984 __func__, rc);
4985 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004986 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004987
4988 rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt);
4989 if (rc) {
4990 dev_err(dev, "%s: could not set voltages: %d\n",
4991 __func__, rc);
4992 goto reg_free;
4993 }
4994
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004995 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07004996
4997reg_free:
4998 regulator_bulk_free(regs_bt_count, regs_bt);
4999out:
5000 regs_bt_count = 0;
5001 regs_bt = NULL;
5002 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005003}
5004
5005static int bluetooth_power(int on)
5006{
5007 int rc;
5008 const char *id = "BTPW";
5009
5010 int bahama_not_marimba = bahama_present();
5011
5012 if (bahama_not_marimba == -1) {
5013 printk(KERN_WARNING "%s: bahama_present: %d\n",
5014 __func__, bahama_not_marimba);
5015 return -ENODEV;
5016 }
5017
Justin Paupore3f40f342011-08-10 18:52:16 -07005018 if (unlikely(regs_bt_count == 0)) {
5019 rc = bluetooth_regs_init(bahama_not_marimba);
5020 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005021 return rc;
Justin Paupore3f40f342011-08-10 18:52:16 -07005022 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005023
Justin Paupore3f40f342011-08-10 18:52:16 -07005024 if (on) {
5025 rc = regulator_bulk_enable(regs_bt_count, regs_bt);
5026 if (rc)
5027 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005028
5029 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5030 PMAPP_CLOCK_VOTE_ON);
5031 if (rc < 0)
5032 return -EIO;
5033
5034 if (machine_is_msm8x55_svlte_surf() ||
5035 machine_is_msm8x55_svlte_ffa()) {
5036 rc = marimba_gpio_config(1);
5037 if (rc < 0)
5038 return -EIO;
5039 }
5040
5041 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5042 if (rc < 0)
5043 return -EIO;
5044
5045 msleep(10);
5046
5047 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5048 PMAPP_CLOCK_VOTE_PIN_CTRL);
5049 if (rc < 0)
5050 return -EIO;
5051
5052 if (machine_is_msm8x55_svlte_surf() ||
5053 machine_is_msm8x55_svlte_ffa()) {
5054 rc = marimba_gpio_config(0);
5055 if (rc < 0)
5056 return -EIO;
5057 }
5058
5059 rc = msm_gpios_enable(bt_config_power_on,
5060 ARRAY_SIZE(bt_config_power_on));
5061
5062 if (rc < 0)
5063 return rc;
5064
5065 } else {
5066 rc = msm_gpios_enable(bt_config_power_off,
5067 ARRAY_SIZE(bt_config_power_off));
5068 if (rc < 0)
5069 return rc;
5070
5071 /* check for initial RFKILL block (power off) */
5072 if (platform_get_drvdata(&msm_bt_power_device) == NULL)
5073 goto out;
5074
5075 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5076 if (rc < 0)
5077 return -EIO;
5078
5079 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5080 PMAPP_CLOCK_VOTE_OFF);
5081 if (rc < 0)
5082 return -EIO;
5083
Justin Paupore3f40f342011-08-10 18:52:16 -07005084 rc = regulator_bulk_disable(regs_bt_count, regs_bt);
5085 if (rc)
5086 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005087
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005088 }
5089
5090out:
5091 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
5092
5093 return 0;
5094}
5095
5096static void __init bt_power_init(void)
5097{
Justin Paupore3f40f342011-08-10 18:52:16 -07005098 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005099}
5100#else
5101#define bt_power_init(x) do {} while (0)
5102#endif
5103
5104static struct msm_psy_batt_pdata msm_psy_batt_data = {
5105 .voltage_min_design = 2800,
5106 .voltage_max_design = 4300,
5107 .avail_chg_sources = AC_CHG | USB_CHG ,
5108 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
5109};
5110
5111static struct platform_device msm_batt_device = {
5112 .name = "msm-battery",
5113 .id = -1,
5114 .dev.platform_data = &msm_psy_batt_data,
5115};
5116
5117static char *msm_adc_fluid_device_names[] = {
5118 "LTC_ADC1",
5119 "LTC_ADC2",
5120 "LTC_ADC3",
5121};
5122
5123static char *msm_adc_surf_device_names[] = {
5124 "XO_ADC",
5125};
5126
5127static struct msm_adc_platform_data msm_adc_pdata;
5128
5129static struct platform_device msm_adc_device = {
5130 .name = "msm_adc",
5131 .id = -1,
5132 .dev = {
5133 .platform_data = &msm_adc_pdata,
5134 },
5135};
5136
5137#ifdef CONFIG_MSM_SDIO_AL
5138static struct msm_gpio mdm2ap_status = {
5139 GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5140 "mdm2ap_status"
5141};
5142
5143
5144static int configure_mdm2ap_status(int on)
5145{
5146 if (on)
5147 return msm_gpios_request_enable(&mdm2ap_status, 1);
5148 else {
5149 msm_gpios_disable_free(&mdm2ap_status, 1);
5150 return 0;
5151 }
5152}
5153
5154static int get_mdm2ap_status(void)
5155{
5156 return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
5157}
5158
5159static struct sdio_al_platform_data sdio_al_pdata = {
5160 .config_mdm2ap_status = configure_mdm2ap_status,
5161 .get_mdm2ap_status = get_mdm2ap_status,
5162 .allow_sdioc_version_major_2 = 1,
5163 .peer_sdioc_version_minor = 0x0001,
5164 .peer_sdioc_version_major = 0x0003,
5165 .peer_sdioc_boot_version_minor = 0x0001,
5166 .peer_sdioc_boot_version_major = 0x0003,
5167};
5168
5169struct platform_device msm_device_sdio_al = {
5170 .name = "msm_sdio_al",
5171 .id = -1,
5172 .dev = {
5173 .platform_data = &sdio_al_pdata,
5174 },
5175};
5176
5177#endif /* CONFIG_MSM_SDIO_AL */
5178
Daniel Walker8d747cd2010-02-25 11:37:43 -08005179static struct platform_device *devices[] __initdata = {
Daniel Walker90e37c52010-05-12 14:24:15 -07005180#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005181 &msm_device_uart2,
5182#endif
Justin Paupore637a25d2011-07-14 17:11:04 -07005183#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
5184 &msm_proccomm_regulator_dev,
5185#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005186 &asoc_msm_pcm,
5187 &asoc_msm_dai0,
5188 &asoc_msm_dai1,
5189#if defined (CONFIG_SND_MSM_MVS_DAI_SOC)
5190 &asoc_msm_mvs,
5191 &asoc_mvs_dai0,
5192 &asoc_mvs_dai1,
Daniel Walker90e37c52010-05-12 14:24:15 -07005193#endif
Niranjana Vishwanathapuraa8855e92010-10-06 13:52:10 -07005194 &msm_device_smd,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005195 &msm_device_dmov,
5196 &smc91x_device,
5197 &smsc911x_device,
5198 &msm_device_nand,
5199#ifdef CONFIG_USB_MSM_OTG_72K
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05305200 &msm_device_otg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005201#ifdef CONFIG_USB_GADGET
5202 &msm_device_gadget_peripheral,
5203#endif
5204#endif
5205#ifdef CONFIG_USB_G_ANDROID
5206 &android_usb_device,
5207#endif
5208 &qsd_device_spi,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305209
5210#ifdef CONFIG_MSM_SSBI
5211 &msm_device_ssbi_pmic1,
5212#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005213#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005214 &msm_device_ssbi7,
5215#endif
5216 &android_pmem_device,
5217 &msm_fb_device,
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08005218#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
5219 &msm_v4l2_video_overlay_device,
5220#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005221 &msm_migrate_pages_device,
5222 &mddi_toshiba_device,
5223 &lcdc_toshiba_panel_device,
5224#ifdef CONFIG_MSM_ROTATOR
5225 &msm_rotator_device,
5226#endif
5227 &lcdc_sharp_panel_device,
5228 &android_pmem_adsp_device,
5229 &android_pmem_audio_device,
5230 &msm_device_i2c,
5231 &msm_device_i2c_2,
5232 &msm_device_uart_dm1,
5233 &hs_device,
5234#ifdef CONFIG_MSM7KV2_AUDIO
5235 &msm_aictl_device,
5236 &msm_mi2s_device,
5237 &msm_lpa_device,
5238 &msm_aux_pcm_device,
5239#endif
5240 &msm_device_adspdec,
5241 &qup_device_i2c,
5242#if defined(CONFIG_MARIMBA_CORE) && \
5243 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5244 &msm_bt_power_device,
5245#endif
5246 &msm_kgsl_3d0,
5247 &msm_kgsl_2d0,
5248#ifdef CONFIG_MT9T013
5249 &msm_camera_sensor_mt9t013,
5250#endif
5251#ifdef CONFIG_MT9D112
5252 &msm_camera_sensor_mt9d112,
5253#endif
5254#ifdef CONFIG_WEBCAM_OV9726
5255 &msm_camera_sensor_ov9726,
5256#endif
5257#ifdef CONFIG_S5K3E2FX
5258 &msm_camera_sensor_s5k3e2fx,
5259#endif
5260#ifdef CONFIG_MT9P012
5261 &msm_camera_sensor_mt9p012,
5262#endif
5263#ifdef CONFIG_MT9E013
5264 &msm_camera_sensor_mt9e013,
5265#endif
5266#ifdef CONFIG_VX6953
5267 &msm_camera_sensor_vx6953,
5268#endif
5269#ifdef CONFIG_SN12M0PZ
5270 &msm_camera_sensor_sn12m0pz,
5271#endif
5272 &msm_device_vidc_720p,
5273#ifdef CONFIG_MSM_GEMINI
5274 &msm_gemini_device,
5275#endif
5276#ifdef CONFIG_MSM_VPE
5277 &msm_vpe_device,
5278#endif
5279#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5280 &msm_device_tsif,
5281#endif
5282#ifdef CONFIG_MSM_SDIO_AL
5283 &msm_device_sdio_al,
5284#endif
5285
5286#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5287 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5288 &qcrypto_device,
5289#endif
5290
5291#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5292 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5293 &qcedev_device,
5294#endif
5295
5296 &msm_batt_device,
5297 &msm_adc_device,
5298 &msm_ebi0_thermal,
Laxminath Kasam1d8255d2012-02-15 13:10:19 +05305299 &msm_ebi1_thermal,
5300 &msm_adsp_device
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005301};
5302
5303static struct msm_gpio msm_i2c_gpios_hw[] = {
5304 { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5305 { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5306};
5307
5308static struct msm_gpio msm_i2c_gpios_io[] = {
5309 { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5310 { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5311};
5312
5313static struct msm_gpio qup_i2c_gpios_io[] = {
5314 { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5315 { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5316};
5317static struct msm_gpio qup_i2c_gpios_hw[] = {
5318 { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5319 { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5320};
5321
5322static void
5323msm_i2c_gpio_config(int adap_id, int config_type)
5324{
5325 struct msm_gpio *msm_i2c_table;
5326
5327 /* Each adapter gets 2 lines from the table */
5328 if (adap_id > 0)
5329 return;
5330 if (config_type)
5331 msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
5332 else
5333 msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
5334 msm_gpios_enable(msm_i2c_table, 2);
5335}
5336/*This needs to be enabled only for OEMS*/
5337#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005338static struct regulator *qup_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005339#endif
5340static void
5341qup_i2c_gpio_config(int adap_id, int config_type)
5342{
5343 int rc = 0;
5344 struct msm_gpio *qup_i2c_table;
5345 /* Each adapter gets 2 lines from the table */
5346 if (adap_id != 4)
5347 return;
5348 if (config_type)
5349 qup_i2c_table = qup_i2c_gpios_hw;
5350 else
5351 qup_i2c_table = qup_i2c_gpios_io;
5352 rc = msm_gpios_enable(qup_i2c_table, 2);
5353 if (rc < 0)
5354 printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
5355 /*This needs to be enabled only for OEMS*/
5356#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005357 if (!IS_ERR_OR_NULL(qup_vreg)) {
5358 rc = regulator_enable(qup_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005359 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005360 pr_err("%s: regulator_enable failed: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005361 __func__, rc);
5362 }
5363 }
5364#endif
5365}
5366
5367static struct msm_i2c_platform_data msm_i2c_pdata = {
5368 .clk_freq = 100000,
5369 .pri_clk = 70,
5370 .pri_dat = 71,
5371 .rmutex = 1,
5372 .rsl_id = "D:I2C02000021",
5373 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5374};
5375
5376static void __init msm_device_i2c_init(void)
5377{
5378 if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
5379 pr_err("failed to request I2C gpios\n");
5380
5381 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
5382}
5383
5384static struct msm_i2c_platform_data msm_i2c_2_pdata = {
5385 .clk_freq = 100000,
5386 .rmutex = 1,
5387 .rsl_id = "D:I2C02000022",
5388 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5389};
5390
5391static void __init msm_device_i2c_2_init(void)
5392{
5393 msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
5394}
5395
5396static struct msm_i2c_platform_data qup_i2c_pdata = {
5397 .clk_freq = 384000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005398 .msm_i2c_config_gpio = qup_i2c_gpio_config,
5399};
5400
5401static void __init qup_device_i2c_init(void)
5402{
5403 if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
5404 pr_err("failed to request I2C gpios\n");
5405
5406 qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
5407 /*This needs to be enabled only for OEMS*/
5408#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005409 qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005410 if (IS_ERR(qup_vreg)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005411 dev_err(&qup_device_i2c.dev,
5412 "%s: regulator_get failed: %ld\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005413 __func__, PTR_ERR(qup_vreg));
5414 }
5415#endif
5416}
5417
5418#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005419static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = {
5420 .rsl_id = "D:CODEC_SSBI",
5421 .controller_type = MSM_SBI_CTRL_SSBI,
5422};
5423#endif
5424
Daniel Walker8d747cd2010-02-25 11:37:43 -08005425static void __init msm7x30_init_irq(void)
5426{
5427 msm_init_irq();
5428}
5429
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005430static struct msm_gpio msm_nand_ebi2_cfg_data[] = {
5431 {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
5432 {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
5433};
5434
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005435#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
5436 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
5437 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
5438 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
5439
5440struct sdcc_gpio {
5441 struct msm_gpio *cfg_data;
5442 uint32_t size;
5443 struct msm_gpio *sleep_cfg_data;
5444};
5445#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5446static struct msm_gpio sdc1_lvlshft_cfg_data[] = {
5447 {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
5448};
5449#endif
5450static struct msm_gpio sdc1_cfg_data[] = {
5451 {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
5452 {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
5453 {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
5454 {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
5455 {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
5456 {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
5457};
5458
5459static struct msm_gpio sdc2_cfg_data[] = {
5460 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
5461 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
5462 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
5463 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
5464 {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
5465 {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
5466
5467#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5468 {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
5469 {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
5470 {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
5471 {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
5472#endif
5473};
5474
5475static struct msm_gpio sdc3_cfg_data[] = {
5476 {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
5477 {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
5478 {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
5479 {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
5480 {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
5481 {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
5482};
5483
5484static struct msm_gpio sdc3_sleep_cfg_data[] = {
5485 {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5486 "sdc3_clk"},
5487 {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5488 "sdc3_cmd"},
5489 {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5490 "sdc3_dat_3"},
5491 {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5492 "sdc3_dat_2"},
5493 {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5494 "sdc3_dat_1"},
5495 {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5496 "sdc3_dat_0"},
5497};
5498
5499static struct msm_gpio sdc4_cfg_data[] = {
5500 {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
5501 {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
5502 {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
5503 {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
5504 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
5505 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
5506};
5507
5508static struct sdcc_gpio sdcc_cfg_data[] = {
5509 {
5510 .cfg_data = sdc1_cfg_data,
5511 .size = ARRAY_SIZE(sdc1_cfg_data),
5512 .sleep_cfg_data = NULL,
5513 },
5514 {
5515 .cfg_data = sdc2_cfg_data,
5516 .size = ARRAY_SIZE(sdc2_cfg_data),
5517 .sleep_cfg_data = NULL,
5518 },
5519 {
5520 .cfg_data = sdc3_cfg_data,
5521 .size = ARRAY_SIZE(sdc3_cfg_data),
5522 .sleep_cfg_data = sdc3_sleep_cfg_data,
5523 },
5524 {
5525 .cfg_data = sdc4_cfg_data,
5526 .size = ARRAY_SIZE(sdc4_cfg_data),
5527 .sleep_cfg_data = NULL,
5528 },
5529};
5530
Justin Paupore3f40f342011-08-10 18:52:16 -07005531static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005532
5533static unsigned long vreg_sts, gpio_sts;
5534
5535static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
5536{
5537 int rc = 0;
5538 struct sdcc_gpio *curr;
5539
5540 curr = &sdcc_cfg_data[dev_id - 1];
5541
5542 if (!(test_bit(dev_id, &gpio_sts)^enable))
5543 return rc;
5544
5545 if (enable) {
5546 set_bit(dev_id, &gpio_sts);
5547 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
5548 if (rc)
5549 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
5550 __func__, dev_id);
5551 } else {
5552 clear_bit(dev_id, &gpio_sts);
5553 if (curr->sleep_cfg_data) {
5554 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
5555 msm_gpios_free(curr->sleep_cfg_data, curr->size);
5556 } else {
5557 msm_gpios_disable_free(curr->cfg_data, curr->size);
5558 }
5559 }
5560
5561 return rc;
5562}
5563
5564static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
5565{
5566 int rc = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005567 struct regulator *curr = sdcc_vreg_data[dev_id - 1];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005568 static int enabled_once[] = {0, 0, 0, 0};
5569
Justin Paupore3f40f342011-08-10 18:52:16 -07005570 if (test_bit(dev_id, &vreg_sts) == enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005571 return rc;
5572
Asutosh Das853bbcd2012-02-01 10:40:05 +05305573 if (dev_id == 4) {
5574 if (enable) {
5575 pr_debug("Enable Vdd dev_%d\n", dev_id);
5576 gpio_set_value_cansleep(
5577 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5578 0);
5579 set_bit(dev_id, &vreg_sts);
5580 } else {
5581 pr_debug("Disable Vdd dev_%d\n", dev_id);
5582 gpio_set_value_cansleep(
5583 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5584 1);
5585 clear_bit(dev_id, &vreg_sts);
5586 }
5587 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005588
Asutosh Das853bbcd2012-02-01 10:40:05 +05305589 if (!enable || enabled_once[dev_id - 1])
5590 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005591 if (!curr)
5592 return -ENODEV;
5593
5594 if (IS_ERR(curr))
5595 return PTR_ERR(curr);
5596
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005597 if (enable) {
5598 set_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005599
5600 rc = regulator_enable(curr);
5601 if (rc)
5602 pr_err("%s: could not enable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005603 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005604 enabled_once[dev_id - 1] = 1;
5605 } else {
5606 clear_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005607
5608 rc = regulator_disable(curr);
5609 if (rc)
5610 pr_err("%s: could not disable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005611 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005612 }
5613 return rc;
5614}
5615
5616static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
5617{
5618 int rc = 0;
5619 struct platform_device *pdev;
5620
5621 pdev = container_of(dv, struct platform_device, dev);
5622 rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
5623 if (rc)
5624 goto out;
5625
5626 if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
5627 rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
5628out:
5629 return rc;
5630}
5631
5632#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \
5633 defined(CONFIG_CSDIO_VENDOR_ID) && \
5634 defined(CONFIG_CSDIO_DEVICE_ID) && \
5635 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5636
5637#define MBP_ON 1
5638#define MBP_OFF 0
5639
5640#define MBP_RESET_N \
5641 GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
5642#define MBP_INT0 \
5643 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
5644
5645#define MBP_MODE_CTRL_0 \
5646 GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5647#define MBP_MODE_CTRL_1 \
5648 GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5649#define MBP_MODE_CTRL_2 \
5650 GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5651#define TSIF_EN \
5652 GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5653#define TSIF_DATA \
5654 GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5655#define TSIF_CLK \
5656 GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5657
5658static struct msm_gpio mbp_cfg_data[] = {
5659 {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5660 "mbp_reset"},
5661 {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5662 "mbp_io_voltage"},
5663};
5664
5665static int mbp_config_gpios_pre_init(int enable)
5666{
5667 int rc = 0;
5668
5669 if (enable) {
5670 rc = msm_gpios_request_enable(mbp_cfg_data,
5671 ARRAY_SIZE(mbp_cfg_data));
5672 if (rc) {
5673 printk(KERN_ERR
5674 "%s: Failed to turnon GPIOs for mbp chip(%d)\n",
5675 __func__, rc);
5676 }
5677 } else
5678 msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
5679 return rc;
5680}
5681
Justin Paupore3f40f342011-08-10 18:52:16 -07005682static struct regulator_bulk_data mbp_regs_io[2];
5683static struct regulator_bulk_data mbp_regs_rf[2];
5684static struct regulator_bulk_data mbp_regs_adc[1];
5685static struct regulator_bulk_data mbp_regs_core[1];
5686
5687static int mbp_init_regs(struct device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005688{
Justin Paupore3f40f342011-08-10 18:52:16 -07005689 struct regulator_bulk_data regs[] = {
5690 /* Analog and I/O regs */
5691 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
5692 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
5693 /* RF regs */
5694 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
5695 { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 },
5696 /* ADC regs */
5697 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
5698 /* Core regs */
5699 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
5700 };
5701
5702 struct regulator_bulk_data *regptr = regs;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005703 int rc;
5704
Justin Paupore3f40f342011-08-10 18:52:16 -07005705 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs);
5706
5707 if (rc) {
5708 dev_err(dev, "%s: could not get regulators: %d\n",
5709 __func__, rc);
5710 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005711 }
5712
Justin Paupore3f40f342011-08-10 18:52:16 -07005713 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005714
Justin Paupore3f40f342011-08-10 18:52:16 -07005715 if (rc) {
5716 dev_err(dev, "%s: could not set voltages: %d\n",
5717 __func__, rc);
5718 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005719 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005720
5721 memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io));
5722 regptr += ARRAY_SIZE(mbp_regs_io);
5723
5724 memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf));
5725 regptr += ARRAY_SIZE(mbp_regs_rf);
5726
5727 memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc));
5728 regptr += ARRAY_SIZE(mbp_regs_adc);
5729
5730 memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core));
5731
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005732 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005733
5734reg_free:
5735 regulator_bulk_free(ARRAY_SIZE(regs), regs);
5736out:
5737 return rc;
5738}
5739
5740static int mbp_setup_rf_vregs(int state)
5741{
5742 return state ?
5743 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) :
5744 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005745}
5746
5747static int mbp_setup_vregs(int state)
5748{
Justin Paupore3f40f342011-08-10 18:52:16 -07005749 return state ?
5750 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) :
5751 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005752}
5753
5754static int mbp_set_tcxo_en(int enable)
5755{
5756 int rc;
5757 const char *id = "UBMC";
5758 struct vreg *vreg_analog = NULL;
5759
5760 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
5761 enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
5762 if (rc < 0) {
5763 printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
5764 __func__, enable ? "" : "de-");
5765 return -EIO;
5766 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005767 return rc;
5768}
5769
5770static void mbp_set_freeze_io(int state)
5771{
5772 if (state)
5773 gpio_set_value(85, 0);
5774 else
5775 gpio_set_value(85, 1);
5776}
5777
5778static int mbp_set_core_voltage_en(int enable)
5779{
Justin Paupore3f40f342011-08-10 18:52:16 -07005780 static bool is_enabled;
5781 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005782
Justin Paupore3f40f342011-08-10 18:52:16 -07005783 if (enable && !is_enabled) {
5784 rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core),
5785 mbp_regs_core);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005786 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005787 pr_err("%s: could not enable regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005788 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07005789 } else {
5790 is_enabled = true;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005791 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005792 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005793
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005794 return rc;
5795}
5796
5797static void mbp_set_reset(int state)
5798{
5799 if (state)
5800 gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
5801 else
5802 gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
5803}
5804
5805static int mbp_config_interface_mode(int state)
5806{
5807 if (state) {
5808 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
5809 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
5810 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
5811 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
5812 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
5813 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
5814 } else {
5815 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
5816 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
5817 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
5818 }
5819 return 0;
5820}
5821
5822static int mbp_setup_adc_vregs(int state)
5823{
Justin Paupore3f40f342011-08-10 18:52:16 -07005824 return state ?
5825 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) :
5826 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005827}
5828
5829static int mbp_power_up(void)
5830{
5831 int rc;
5832
5833 rc = mbp_config_gpios_pre_init(MBP_ON);
5834 if (rc)
5835 goto exit;
5836 pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__);
5837
5838 rc = mbp_setup_vregs(MBP_ON);
5839 if (rc)
5840 goto exit;
5841 pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
5842
5843 rc = mbp_set_tcxo_en(MBP_ON);
5844 if (rc)
5845 goto exit;
5846 pr_debug("%s: tcxo clock done\n", __func__);
5847
5848 mbp_set_freeze_io(MBP_OFF);
5849 pr_debug("%s: set gpio 85 to 1 done\n", __func__);
5850
5851 udelay(100);
5852 mbp_set_reset(MBP_ON);
5853
5854 udelay(300);
5855 rc = mbp_config_interface_mode(MBP_ON);
5856 if (rc)
5857 goto exit;
5858 pr_debug("%s: mbp_config_interface_mode() done\n", __func__);
5859
5860 udelay(100 + mbp_set_core_voltage_en(MBP_ON));
5861 pr_debug("%s: power gp16 1.2V done\n", __func__);
5862
5863 mbp_set_freeze_io(MBP_ON);
5864 pr_debug("%s: set gpio 85 to 0 done\n", __func__);
5865
5866 udelay(100);
5867
5868 rc = mbp_setup_rf_vregs(MBP_ON);
5869 if (rc)
5870 goto exit;
5871 pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
5872
5873 rc = mbp_setup_adc_vregs(MBP_ON);
5874 if (rc)
5875 goto exit;
5876 pr_debug("%s: s4 2.2V done\n", __func__);
5877
5878 udelay(200);
5879
5880 mbp_set_reset(MBP_OFF);
5881 pr_debug("%s: close gpio 44 done\n", __func__);
5882
5883 msleep(20);
5884exit:
5885 return rc;
5886}
5887
5888static int mbp_power_down(void)
5889{
5890 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005891
5892 mbp_set_reset(MBP_ON);
5893 pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
5894
5895 udelay(100);
5896
5897 rc = mbp_setup_adc_vregs(MBP_OFF);
5898 if (rc)
5899 goto exit;
5900 pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
5901
5902 udelay(5);
5903
5904 rc = mbp_setup_rf_vregs(MBP_OFF);
5905 if (rc)
5906 goto exit;
5907 pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
5908
5909 udelay(5);
5910
5911 mbp_set_freeze_io(MBP_OFF);
5912 pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
5913
5914 udelay(100);
5915 rc = mbp_set_core_voltage_en(MBP_OFF);
5916 if (rc)
5917 goto exit;
5918 pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
5919
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005920 rc = mbp_set_tcxo_en(MBP_OFF);
5921 if (rc)
5922 goto exit;
5923 pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
5924
Justin Paupore3f40f342011-08-10 18:52:16 -07005925 rc = mbp_setup_vregs(MBP_OFF);
5926 if (rc)
5927 goto exit;
5928 pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__);
5929
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005930 rc = mbp_config_gpios_pre_init(MBP_OFF);
5931 if (rc)
5932 goto exit;
5933exit:
5934 return rc;
5935}
5936
5937static void (*mbp_status_notify_cb)(int card_present, void *dev_id);
5938static void *mbp_status_notify_cb_devid;
5939static int mbp_power_status;
5940static int mbp_power_init_done;
5941
5942static uint32_t mbp_setup_power(struct device *dv,
5943 unsigned int power_status)
5944{
5945 int rc = 0;
5946 struct platform_device *pdev;
5947
5948 pdev = container_of(dv, struct platform_device, dev);
5949
5950 if (power_status == mbp_power_status)
5951 goto exit;
5952 if (power_status) {
5953 pr_debug("turn on power of mbp slot");
5954 rc = mbp_power_up();
5955 mbp_power_status = 1;
5956 } else {
5957 pr_debug("turn off power of mbp slot");
5958 rc = mbp_power_down();
5959 mbp_power_status = 0;
5960 }
5961exit:
5962 return rc;
5963};
5964
5965int mbp_register_status_notify(void (*callback)(int, void *),
5966 void *dev_id)
5967{
5968 mbp_status_notify_cb = callback;
5969 mbp_status_notify_cb_devid = dev_id;
5970 return 0;
5971}
5972
5973static unsigned int mbp_status(struct device *dev)
5974{
5975 return mbp_power_status;
5976}
5977
5978static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd)
5979{
5980 struct platform_device *pdev;
5981 uint32_t rc = 0;
5982
5983 pdev = container_of(dv, struct platform_device, dev);
5984 rc = msm_sdcc_setup_power(dv, vdd);
5985 if (rc) {
5986 pr_err("%s: Failed to setup power (%d)\n",
5987 __func__, rc);
5988 goto out;
5989 }
5990 if (!mbp_power_init_done) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005991 rc = mbp_init_regs(dv);
5992 if (rc) {
5993 dev_err(dv, "%s: regulator init failed: %d\n",
5994 __func__, rc);
5995 goto out;
5996 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005997 mbp_setup_power(dv, 1);
5998 mbp_setup_power(dv, 0);
5999 mbp_power_init_done = 1;
6000 }
6001 if (vdd >= 0x8000) {
6002 rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
6003 if (rc) {
6004 pr_err("%s: Failed to config mbp chip power (%d)\n",
6005 __func__, rc);
6006 goto out;
6007 }
6008 if (mbp_status_notify_cb) {
6009 mbp_status_notify_cb(mbp_power_status,
6010 mbp_status_notify_cb_devid);
6011 }
6012 }
6013out:
6014 /* should return 0 only */
6015 return 0;
6016}
6017
6018#endif
6019
6020#endif
6021
6022#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6023#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6024static unsigned int msm7x30_sdcc_slot_status(struct device *dev)
6025{
6026 return (unsigned int)
6027 gpio_get_value_cansleep(
6028 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1));
6029}
6030#endif
6031
6032static int msm_sdcc_get_wpswitch(struct device *dv)
6033{
6034 void __iomem *wp_addr = 0;
6035 uint32_t ret = 0;
6036 struct platform_device *pdev;
6037
6038 if (!(machine_is_msm7x30_surf()))
6039 return -1;
6040 pdev = container_of(dv, struct platform_device, dev);
6041
6042 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
6043 if (!wp_addr) {
6044 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
6045 return -ENOMEM;
6046 }
6047
6048 ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
6049 pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
6050 pdev->id, ret);
6051 iounmap(wp_addr);
6052
6053 return ret;
6054}
6055#endif
6056
6057#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
6058#if defined(CONFIG_CSDIO_VENDOR_ID) && \
6059 defined(CONFIG_CSDIO_DEVICE_ID) && \
6060 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
6061static struct mmc_platform_data msm7x30_sdc1_data = {
6062 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
6063 .translate_vdd = msm_sdcc_setup_power_mbp,
6064 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6065 .status = mbp_status,
6066 .register_status_notify = mbp_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006067 .msmsdcc_fmin = 144000,
6068 .msmsdcc_fmid = 24576000,
6069 .msmsdcc_fmax = 24576000,
6070 .nonremovable = 0,
6071};
6072#else
6073static struct mmc_platform_data msm7x30_sdc1_data = {
6074 .ocr_mask = MMC_VDD_165_195,
6075 .translate_vdd = msm_sdcc_setup_power,
6076 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006077 .msmsdcc_fmin = 144000,
6078 .msmsdcc_fmid = 24576000,
6079 .msmsdcc_fmax = 49152000,
6080 .nonremovable = 0,
6081};
6082#endif
6083#endif
6084
6085#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
6086static struct mmc_platform_data msm7x30_sdc2_data = {
6087 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
6088 .translate_vdd = msm_sdcc_setup_power,
6089#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
6090 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
6091#else
6092 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6093#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006094 .msmsdcc_fmin = 144000,
6095 .msmsdcc_fmid = 24576000,
6096 .msmsdcc_fmax = 49152000,
6097 .nonremovable = 1,
6098};
6099#endif
6100
6101#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
6102static struct mmc_platform_data msm7x30_sdc3_data = {
6103 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6104 .translate_vdd = msm_sdcc_setup_power,
6105 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6106#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
6107 .sdiowakeup_irq = MSM_GPIO_TO_INT(118),
6108#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006109 .msmsdcc_fmin = 144000,
6110 .msmsdcc_fmid = 24576000,
6111 .msmsdcc_fmax = 49152000,
6112 .nonremovable = 0,
6113};
6114#endif
6115
6116#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6117static struct mmc_platform_data msm7x30_sdc4_data = {
6118 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6119 .translate_vdd = msm_sdcc_setup_power,
6120 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6121#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6122 .status = msm7x30_sdcc_slot_status,
6123 .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
6124 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
6125#endif
6126 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006127 .msmsdcc_fmin = 144000,
6128 .msmsdcc_fmid = 24576000,
6129 .msmsdcc_fmax = 49152000,
6130 .nonremovable = 0,
6131};
6132#endif
6133
6134#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006135static int msm_sdc1_lvlshft_enable(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006136{
Justin Paupore3f40f342011-08-10 18:52:16 -07006137 static struct regulator *ldo5;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006138 int rc;
6139
6140 /* Enable LDO5, an input to the FET that powers slot 1 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006141
Justin Paupore3f40f342011-08-10 18:52:16 -07006142 ldo5 = regulator_get(NULL, "ldo5");
6143
6144 if (IS_ERR(ldo5)) {
6145 rc = PTR_ERR(ldo5);
6146 pr_err("%s: could not get ldo5: %d\n", __func__, rc);
6147 goto out;
6148 }
6149
6150 rc = regulator_set_voltage(ldo5, 2850000, 2850000);
6151 if (rc) {
6152 pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc);
6153 goto ldo5_free;
6154 }
6155
6156 rc = regulator_enable(ldo5);
6157 if (rc) {
6158 pr_err("%s: could not enable ldo5: %d\n", __func__, rc);
6159 goto ldo5_free;
6160 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006161
6162 /* Enable GPIO 35, to turn on the FET that powers slot 1 */
6163 rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
6164 ARRAY_SIZE(sdc1_lvlshft_cfg_data));
6165 if (rc)
6166 printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
6167
6168 rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg),
6169 1);
6170 if (rc)
6171 printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006172
6173 return 0;
6174
6175ldo5_free:
6176 regulator_put(ldo5);
6177out:
6178 ldo5 = NULL;
6179 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006180}
6181#endif
6182
Justin Paupore3f40f342011-08-10 18:52:16 -07006183static int mmc_regulator_init(int sdcc_no, const char *supply, int uV)
6184{
6185 int rc;
6186
6187 BUG_ON(sdcc_no < 1 || sdcc_no > 4);
6188
6189 sdcc_no--;
6190
6191 sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply);
6192
6193 if (IS_ERR(sdcc_vreg_data[sdcc_no])) {
6194 rc = PTR_ERR(sdcc_vreg_data[sdcc_no]);
6195 pr_err("%s: could not get regulator \"%s\": %d\n",
6196 __func__, supply, rc);
6197 goto out;
6198 }
6199
6200 rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV);
6201
6202 if (rc) {
6203 pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n",
6204 __func__, supply, uV, rc);
6205 goto reg_free;
6206 }
6207
6208 return rc;
6209
6210reg_free:
6211 regulator_put(sdcc_vreg_data[sdcc_no]);
6212out:
6213 sdcc_vreg_data[sdcc_no] = NULL;
6214 return rc;
6215}
6216
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006217static void __init msm7x30_init_mmc(void)
6218{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006219#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006220 if (mmc_regulator_init(1, "s3", 1800000))
6221 goto out1;
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05306222 msm7x30_sdc1_data.swfi_latency = msm7x30_power_collapse_latency(
6223 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT);
Justin Paupore3f40f342011-08-10 18:52:16 -07006224
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006225 if (machine_is_msm7x30_fluid()) {
6226 msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
Justin Paupore3f40f342011-08-10 18:52:16 -07006227 if (msm_sdc1_lvlshft_enable()) {
6228 pr_err("%s: could not enable level shift\n");
6229 goto out1;
6230 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006231 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006232
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006233 msm_add_sdcc(1, &msm7x30_sdc1_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006234out1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006235#endif
6236#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006237 if (mmc_regulator_init(2, "s3", 1800000))
6238 goto out2;
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05306239 msm7x30_sdc2_data.swfi_latency = msm7x30_power_collapse_latency(
6240 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT);
Justin Paupore3f40f342011-08-10 18:52:16 -07006241
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006242 if (machine_is_msm8x55_svlte_surf())
6243 msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
Sujith Reddy Thumma84a0f512011-08-29 09:57:03 +05306244 if (machine_is_msm8x55_svlte_surf() ||
6245 machine_is_msm8x55_svlte_ffa()) {
6246 msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
6247 msm7x30_sdc2_data.is_sdio_al_client = 1;
6248 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006249
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006250 msm_add_sdcc(2, &msm7x30_sdc2_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006251out2:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006252#endif
6253#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006254 if (mmc_regulator_init(3, "s3", 1800000))
6255 goto out3;
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05306256 msm7x30_sdc3_data.swfi_latency = msm7x30_power_collapse_latency(
6257 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT);
Justin Paupore3f40f342011-08-10 18:52:16 -07006258
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006259 msm_sdcc_setup_gpio(3, 1);
6260 msm_add_sdcc(3, &msm7x30_sdc3_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006261out3:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006262#endif
6263#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006264 if (mmc_regulator_init(4, "mmc", 2850000))
6265 return;
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05306266 msm7x30_sdc4_data.swfi_latency = msm7x30_power_collapse_latency(
6267 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT);
Justin Paupore3f40f342011-08-10 18:52:16 -07006268
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006269 msm_add_sdcc(4, &msm7x30_sdc4_data);
6270#endif
6271
6272}
6273
6274static void __init msm7x30_init_nand(void)
6275{
6276 char *build_id;
6277 struct flash_platform_data *plat_data;
6278
6279 build_id = socinfo_get_build_id();
6280 if (build_id == NULL) {
6281 pr_err("%s: Build ID not available from socinfo\n", __func__);
6282 return;
6283 }
6284
6285 if (build_id[8] == 'C' &&
6286 !msm_gpios_request_enable(msm_nand_ebi2_cfg_data,
6287 ARRAY_SIZE(msm_nand_ebi2_cfg_data))) {
6288 plat_data = msm_device_nand.dev.platform_data;
6289 plat_data->interleave = 1;
6290 printk(KERN_INFO "%s: Interleave mode Build ID found\n",
6291 __func__);
6292 }
6293}
6294
6295#ifdef CONFIG_SERIAL_MSM_CONSOLE
6296static struct msm_gpio uart2_config_data[] = {
6297 { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
6298 { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
6299 { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
6300 { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
6301};
6302
6303static void msm7x30_init_uart2(void)
6304{
6305 msm_gpios_request_enable(uart2_config_data,
6306 ARRAY_SIZE(uart2_config_data));
6307
6308}
6309#endif
6310
6311/* TSIF begin */
6312#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6313
6314#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6315#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6316#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6317#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6318
6319static const struct msm_gpio tsif_gpios[] = {
6320 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
6321 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
6322 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
6323 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
6324};
6325
6326static struct msm_tsif_platform_data tsif_platform_data = {
6327 .num_gpios = ARRAY_SIZE(tsif_gpios),
6328 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -07006329 .tsif_pclk = "iface_clk",
6330 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006331};
6332#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
6333/* TSIF end */
6334
6335static void __init pmic8058_leds_init(void)
6336{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306337 if (machine_is_msm7x30_surf())
6338 pm8058_7x30_data.leds_pdata = &pm8058_surf_leds_data;
6339 else if (!machine_is_msm7x30_fluid())
6340 pm8058_7x30_data.leds_pdata = &pm8058_ffa_leds_data;
6341 else if (machine_is_msm7x30_fluid())
6342 pm8058_7x30_data.leds_pdata = &pm8058_fluid_leds_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006343}
6344
6345static struct msm_spm_platform_data msm_spm_data __initdata = {
Taniya Das298de8c2012-02-16 11:45:31 +05306346 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006347
6348 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
6349 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
6350 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
6351 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
6352
6353 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
6354 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
6355 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
6356
6357 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
6358 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
6359 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
6360
6361 .awake_vlevel = 0xF2,
6362 .retention_vlevel = 0xE0,
6363 .collapse_vlevel = 0x72,
6364 .retention_mid_vlevel = 0xE0,
6365 .collapse_mid_vlevel = 0xE0,
6366
6367 .vctl_timeout_us = 50,
6368};
6369
6370#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6371 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6372
6373#define TSC2007_TS_PEN_INT 20
6374
6375static struct msm_gpio tsc2007_config_data[] = {
6376 { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
6377 "tsc2007_irq" },
6378};
6379
Justin Paupore3f40f342011-08-10 18:52:16 -07006380static struct regulator_bulk_data tsc2007_regs[] = {
6381 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
6382 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
6383};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006384
6385static int tsc2007_init(void)
6386{
6387 int rc;
6388
Justin Paupore3f40f342011-08-10 18:52:16 -07006389 rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006390
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006391 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006392 pr_err("%s: could not get regulators: %d\n", __func__, rc);
6393 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006394 }
6395
Justin Paupore3f40f342011-08-10 18:52:16 -07006396 rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6397
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006398 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006399 pr_err("%s: could not set voltages: %d\n", __func__, rc);
6400 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006401 }
6402
Justin Paupore3f40f342011-08-10 18:52:16 -07006403 rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006404
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006405 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006406 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
6407 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006408 }
6409
6410 rc = msm_gpios_request_enable(tsc2007_config_data,
6411 ARRAY_SIZE(tsc2007_config_data));
6412 if (rc) {
6413 pr_err("%s: Unable to request gpios\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006414 goto reg_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006415 }
6416
6417 return 0;
6418
Justin Paupore3f40f342011-08-10 18:52:16 -07006419reg_disable:
6420 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6421reg_free:
6422 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6423out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006424 return rc;
6425}
6426
6427static int tsc2007_get_pendown_state(void)
6428{
6429 int rc;
6430
6431 rc = gpio_get_value(TSC2007_TS_PEN_INT);
6432 if (rc < 0) {
6433 pr_err("%s: MSM GPIO %d read failed\n", __func__,
6434 TSC2007_TS_PEN_INT);
6435 return rc;
6436 }
6437
6438 return (rc == 0 ? 1 : 0);
6439}
6440
6441static void tsc2007_exit(void)
6442{
Justin Paupore3f40f342011-08-10 18:52:16 -07006443
6444 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6445 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006446
6447 msm_gpios_disable_free(tsc2007_config_data,
6448 ARRAY_SIZE(tsc2007_config_data));
6449}
6450
6451static int tsc2007_power_shutdown(bool enable)
6452{
6453 int rc;
6454
Justin Paupore3f40f342011-08-10 18:52:16 -07006455 rc = (enable == false) ?
6456 regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) :
6457 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6458
6459 if (rc) {
6460 pr_err("%s: could not %sable regulators: %d\n",
6461 __func__, enable ? "dis" : "en", rc);
6462 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006463 }
6464
Justin Paupore3f40f342011-08-10 18:52:16 -07006465 if (enable == false)
6466 msleep(20);
6467
6468 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006469}
6470
6471static struct tsc2007_platform_data tsc2007_ts_data = {
6472 .model = 2007,
6473 .x_plate_ohms = 300,
Anirudh Ghayala2cf2e22012-01-25 12:29:42 +05306474 .min_x = 210,
6475 .max_x = 3832,
6476 .min_y = 150,
6477 .max_y = 3936,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006478 .irq_flags = IRQF_TRIGGER_LOW,
6479 .init_platform_hw = tsc2007_init,
6480 .exit_platform_hw = tsc2007_exit,
6481 .power_shutdown = tsc2007_power_shutdown,
6482 .invert_x = true,
6483 .invert_y = true,
6484 /* REVISIT: Temporary fix for reversed pressure */
6485 .invert_z1 = true,
6486 .invert_z2 = true,
6487 .get_pendown_state = tsc2007_get_pendown_state,
6488};
6489
6490static struct i2c_board_info tsc_i2c_board_info[] = {
6491 {
6492 I2C_BOARD_INFO("tsc2007", 0x48),
6493 .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
6494 .platform_data = &tsc2007_ts_data,
6495 },
6496};
6497#endif
6498
Justin Paupore3f40f342011-08-10 18:52:16 -07006499static struct regulator_bulk_data regs_isa1200[] = {
6500 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
6501 { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006502};
6503
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006504static int isa1200_power(int vreg_on)
6505{
Justin Paupore3f40f342011-08-10 18:52:16 -07006506 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006507
Justin Paupore3f40f342011-08-10 18:52:16 -07006508 rc = vreg_on ?
6509 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) :
6510 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006511
Justin Paupore3f40f342011-08-10 18:52:16 -07006512 if (rc) {
6513 pr_err("%s: could not %sable regulators: %d\n",
6514 __func__, vreg_on ? "en" : "dis", rc);
6515 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006516 }
6517
6518 /* vote for DO buffer */
6519 rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO,
6520 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
6521 if (rc) {
6522 pr_err("%s: unable to %svote for d0 clk\n",
6523 __func__, vreg_on ? "" : "de-");
6524 goto vreg_fail;
6525 }
6526
6527 return 0;
6528
6529vreg_fail:
Justin Paupore3f40f342011-08-10 18:52:16 -07006530 if (vreg_on)
6531 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6532 else
6533 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6534out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006535 return rc;
6536}
6537
6538static int isa1200_dev_setup(bool enable)
6539{
Justin Paupore3f40f342011-08-10 18:52:16 -07006540 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006541
6542 if (enable == true) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006543 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200),
6544 regs_isa1200);
6545
6546 if (rc) {
6547 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006548 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006549 goto out;
6550 }
6551
6552 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200),
6553 regs_isa1200);
6554 if (rc) {
6555 pr_err("%s: could not set voltages: %d\n",
6556 __func__, rc);
6557 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006558 }
6559
6560 rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
6561 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
6562 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
6563 if (rc) {
6564 pr_err("%s: Could not configure gpio %d\n",
6565 __func__, HAP_LVL_SHFT_MSM_GPIO);
Justin Paupore3f40f342011-08-10 18:52:16 -07006566 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006567 }
6568
6569 rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
6570 if (rc) {
6571 pr_err("%s: unable to request gpio %d (%d)\n",
6572 __func__, HAP_LVL_SHFT_MSM_GPIO, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006573 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006574 }
6575
6576 gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
6577 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006578 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006579 gpio_free(HAP_LVL_SHFT_MSM_GPIO);
6580 }
6581
6582 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07006583
6584reg_free:
6585 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6586out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006587 return rc;
6588}
6589static struct isa1200_platform_data isa1200_1_pdata = {
6590 .name = "vibrator",
6591 .power_on = isa1200_power,
6592 .dev_setup = isa1200_dev_setup,
6593 .pwm_ch_id = 1, /*channel id*/
6594 /*gpio to enable haptic*/
6595 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka03122322011-09-09 15:15:43 +05306596 .hap_len_gpio = -1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006597 .max_timeout = 15000,
6598 .mode_ctrl = PWM_GEN_MODE,
6599 .pwm_fd = {
6600 .pwm_div = 256,
6601 },
6602 .is_erm = false,
6603 .smart_en = true,
6604 .ext_clk_en = true,
6605 .chip_en = 1,
6606};
6607
6608static struct i2c_board_info msm_isa1200_board_info[] = {
6609 {
6610 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
6611 .platform_data = &isa1200_1_pdata,
6612 },
6613};
6614
6615
6616static int kp_flip_mpp_config(void)
6617{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306618 struct pm8xxx_mpp_config_data kp_flip_mpp = {
6619 .type = PM8XXX_MPP_TYPE_D_INPUT,
6620 .level = PM8018_MPP_DIG_LEVEL_S3,
6621 .control = PM8XXX_MPP_DIN_TO_INT,
6622 };
6623
6624 return pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(PM_FLIP_MPP),
6625 &kp_flip_mpp);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006626}
6627
6628static struct flip_switch_pdata flip_switch_data = {
6629 .name = "kp_flip_switch",
6630 .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP,
6631 .left_key = KEY_OPEN,
6632 .right_key = KEY_CLOSE,
6633 .active_low = 0,
6634 .wakeup = 1,
6635 .flip_mpp_config = kp_flip_mpp_config,
6636};
6637
6638static struct platform_device flip_switch_device = {
6639 .name = "kp_flip_switch",
6640 .id = -1,
6641 .dev = {
6642 .platform_data = &flip_switch_data,
6643 }
6644};
6645
Justin Paupore3f40f342011-08-10 18:52:16 -07006646static struct regulator_bulk_data regs_tma300[] = {
6647 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
6648 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006649};
6650
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006651static int tma300_power(int vreg_on)
6652{
Justin Paupore3f40f342011-08-10 18:52:16 -07006653 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006654
Justin Paupore3f40f342011-08-10 18:52:16 -07006655 rc = vreg_on ?
6656 regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) :
6657 regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006658
Justin Paupore3f40f342011-08-10 18:52:16 -07006659 if (rc)
6660 pr_err("%s: could not %sable regulators: %d\n",
6661 __func__, vreg_on ? "en" : "dis", rc);
6662 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006663}
6664
6665#define TS_GPIO_IRQ 150
6666
6667static int tma300_dev_setup(bool enable)
6668{
Justin Paupore3f40f342011-08-10 18:52:16 -07006669 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006670
6671 if (enable) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006672 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300),
6673 regs_tma300);
6674
6675 if (rc) {
6676 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006677 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006678 goto out;
6679 }
6680
6681 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300),
6682 regs_tma300);
6683
6684 if (rc) {
6685 pr_err("%s: could not set voltages: %d\n",
6686 __func__, rc);
6687 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006688 }
6689
6690 /* enable interrupt gpio */
6691 rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
6692 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
6693 if (rc) {
6694 pr_err("%s: Could not configure gpio %d\n",
6695 __func__, TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -07006696 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006697 }
6698
6699 /* virtual keys */
6700 tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
6701 properties_kobj = kobject_create_and_add("board_properties",
6702 NULL);
6703 if (!properties_kobj) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006704 pr_err("%s: failed to create a kobject "
6705 "for board_properties\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006706 rc = -ENOMEM;
Justin Paupore3f40f342011-08-10 18:52:16 -07006707 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006708 }
6709 rc = sysfs_create_group(properties_kobj,
6710 &tma300_properties_attr_group);
6711 if (rc) {
6712 pr_err("%s: failed to create a sysfs entry %s\n",
6713 __func__, tma300_vkeys_attr.attr.name);
Justin Paupore3f40f342011-08-10 18:52:16 -07006714 goto kobj_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006715 }
6716 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006717 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006718 /* destroy virtual keys */
6719 if (properties_kobj) {
6720 sysfs_remove_group(properties_kobj,
6721 &tma300_properties_attr_group);
6722 kobject_put(properties_kobj);
6723 }
6724 }
6725 return 0;
6726
Justin Paupore3f40f342011-08-10 18:52:16 -07006727kobj_free:
6728 kobject_put(properties_kobj);
6729 properties_kobj = NULL;
6730reg_free:
6731 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
6732out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006733 return rc;
6734}
6735
6736static struct cy8c_ts_platform_data cy8ctma300_pdata = {
6737 .power_on = tma300_power,
6738 .dev_setup = tma300_dev_setup,
6739 .ts_name = "msm_tma300_ts",
6740 .dis_min_x = 0,
6741 .dis_max_x = 479,
6742 .dis_min_y = 0,
6743 .dis_max_y = 799,
6744 .res_x = 479,
6745 .res_y = 1009,
6746 .min_tid = 1,
6747 .max_tid = 255,
6748 .min_touch = 0,
6749 .max_touch = 255,
6750 .min_width = 0,
6751 .max_width = 255,
6752 .invert_y = 1,
6753 .nfingers = 4,
6754 .irq_gpio = TS_GPIO_IRQ,
6755 .resout_gpio = -1,
6756};
6757
6758static struct i2c_board_info cy8ctma300_board_info[] = {
6759 {
6760 I2C_BOARD_INFO("cy8ctma300", 0x2),
6761 .platform_data = &cy8ctma300_pdata,
6762 }
6763};
6764
Daniel Walker8d747cd2010-02-25 11:37:43 -08006765static void __init msm7x30_init(void)
6766{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006767 int rc;
6768 unsigned smem_size;
6769 uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56,
6770 0,
6771 GPIO_CFG_OUTPUT,
6772 GPIO_CFG_NO_PULL,
6773 GPIO_CFG_2MA);
6774 uint32_t soc_version = 0;
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05306775
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006776 soc_version = socinfo_get_version();
6777
Stephen Boydbb600ae2011-08-02 20:11:40 -07006778 msm_clock_init(&msm7x30_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006779#ifdef CONFIG_SERIAL_MSM_CONSOLE
6780 msm7x30_init_uart2();
6781#endif
6782 msm_spm_init(&msm_spm_data, 1);
Matt Wagantallec57f062011-08-16 23:54:46 -07006783 acpuclk_init(&acpuclk_7x30_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006784 if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid())
6785 msm7x30_cfg_smsc911x();
6786
6787#ifdef CONFIG_USB_MSM_OTG_72K
6788 if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 &&
6789 SOCINFO_VERSION_MINOR(soc_version) >= 1) {
6790 pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
6791 msm_otg_pdata.ldo_set_voltage = 0;
6792 }
6793
6794 msm_device_otg.dev.platform_data = &msm_otg_pdata;
6795#ifdef CONFIG_USB_GADGET
6796 msm_otg_pdata.swfi_latency =
6797 msm_pm_data
6798 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
6799 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
6800#endif
6801#endif
6802 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
6803 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
6804#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6805 msm_device_tsif.dev.platform_data = &tsif_platform_data;
6806#endif
6807 if (machine_is_msm7x30_fluid()) {
6808 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
6809 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
6810 } else {
6811 msm_adc_pdata.dev_names = msm_adc_surf_device_names;
6812 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names);
6813 }
6814
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306815 pmic8058_leds_init();
6816
6817 buses_init();
6818
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306819#ifdef CONFIG_MSM_SSBI
6820 msm_device_ssbi_pmic1.dev.platform_data =
6821 &msm7x30_ssbi_pm8058_pdata;
6822#endif
6823
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006824 platform_add_devices(msm_footswitch_devices,
6825 msm_num_footswitch_devices);
Daniel Walker8d747cd2010-02-25 11:37:43 -08006826 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006827#ifdef CONFIG_USB_EHCI_MSM_72K
6828 msm_add_host(0, &msm_usb_host_pdata);
6829#endif
6830 msm7x30_init_mmc();
6831 msm7x30_init_nand();
6832 msm_qsd_spi_init();
6833
6834#ifdef CONFIG_SPI_QSD
6835 if (machine_is_msm7x30_fluid())
6836 spi_register_board_info(lcdc_sharp_spi_board_info,
6837 ARRAY_SIZE(lcdc_sharp_spi_board_info));
6838 else
6839 spi_register_board_info(lcdc_toshiba_spi_board_info,
6840 ARRAY_SIZE(lcdc_toshiba_spi_board_info));
6841#endif
6842
Justin Paupore3f40f342011-08-10 18:52:16 -07006843 atv_dac_power_init();
6844 sensors_ldo_init();
6845 hdmi_init_regs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006846 msm_fb_add_devices();
6847 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06006848 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05306849 msm_pm_register_irqs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006850 msm_device_i2c_init();
6851 msm_device_i2c_2_init();
6852 qup_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006853 msm7x30_init_marimba();
6854#ifdef CONFIG_MSM7KV2_AUDIO
6855 snddev_poweramp_gpio_init();
Justin Paupore3f40f342011-08-10 18:52:16 -07006856 snddev_hsed_voltage_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006857 aux_pcm_gpio_init();
6858#endif
6859
6860 i2c_register_board_info(0, msm_i2c_board_info,
6861 ARRAY_SIZE(msm_i2c_board_info));
6862
6863 if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid())
6864 marimba_pdata.tsadc = &marimba_tsadc_pdata;
6865
6866 if (machine_is_msm7x30_fluid())
6867 i2c_register_board_info(0, cy8info,
6868 ARRAY_SIZE(cy8info));
6869#ifdef CONFIG_BOSCH_BMA150
6870 if (machine_is_msm7x30_fluid())
6871 i2c_register_board_info(0, bma150_board_info,
6872 ARRAY_SIZE(bma150_board_info));
6873#endif
6874
6875 i2c_register_board_info(2, msm_marimba_board_info,
6876 ARRAY_SIZE(msm_marimba_board_info));
6877
6878 i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info,
6879 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info));
6880
6881 i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
6882 ARRAY_SIZE(msm_camera_boardinfo));
6883
6884 bt_power_init();
6885#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006886 msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
6887#endif
6888 if (machine_is_msm7x30_fluid())
6889 i2c_register_board_info(0, msm_isa1200_board_info,
6890 ARRAY_SIZE(msm_isa1200_board_info));
6891
6892#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6893 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6894 if (machine_is_msm8x55_svlte_ffa())
6895 i2c_register_board_info(2, tsc_i2c_board_info,
6896 ARRAY_SIZE(tsc_i2c_board_info));
6897#endif
6898
6899 if (machine_is_msm7x30_surf())
6900 platform_device_register(&flip_switch_device);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306901
6902 pm8058_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006903
6904 if (machine_is_msm7x30_fluid()) {
6905 /* Initialize platform data for fluid v2 hardware */
6906 if (SOCINFO_VERSION_MAJOR(
6907 socinfo_get_platform_version()) == 2) {
6908 cy8ctma300_pdata.res_y = 920;
6909 cy8ctma300_pdata.invert_y = 0;
6910 }
6911 i2c_register_board_info(0, cy8ctma300_board_info,
6912 ARRAY_SIZE(cy8ctma300_board_info));
6913 }
6914
6915 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
6916 rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE);
6917 if (rc)
6918 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
6919 __func__, usb_hub_gpio_cfg_value, rc);
6920 }
6921
6922 boot_reason = *(unsigned int *)
6923 (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
6924 printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
6925}
6926
6927static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
6928static int __init pmem_sf_size_setup(char *p)
6929{
6930 pmem_sf_size = memparse(p, NULL);
6931 return 0;
6932}
6933early_param("pmem_sf_size", pmem_sf_size_setup);
6934
6935static unsigned fb_size = MSM_FB_SIZE;
6936static int __init fb_size_setup(char *p)
6937{
6938 fb_size = memparse(p, NULL);
6939 return 0;
6940}
6941early_param("fb_size", fb_size_setup);
6942
6943static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
6944static int __init pmem_adsp_size_setup(char *p)
6945{
6946 pmem_adsp_size = memparse(p, NULL);
6947 return 0;
6948}
6949early_param("pmem_adsp_size", pmem_adsp_size_setup);
6950
6951static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE;
6952static int __init fluid_pmem_adsp_size_setup(char *p)
6953{
6954 fluid_pmem_adsp_size = memparse(p, NULL);
6955 return 0;
6956}
6957early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup);
6958
6959static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
6960static int __init pmem_audio_size_setup(char *p)
6961{
6962 pmem_audio_size = memparse(p, NULL);
6963 return 0;
6964}
6965early_param("pmem_audio_size", pmem_audio_size_setup);
6966
6967static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE;
6968static int __init pmem_kernel_ebi0_size_setup(char *p)
6969{
6970 pmem_kernel_ebi0_size = memparse(p, NULL);
6971 return 0;
6972}
6973early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
6974
6975static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
6976 [MEMTYPE_SMI] = {
6977 },
6978 [MEMTYPE_EBI0] = {
6979 .flags = MEMTYPE_FLAGS_1M_ALIGN,
6980 },
6981 [MEMTYPE_EBI1] = {
6982 .flags = MEMTYPE_FLAGS_1M_ALIGN,
6983 },
6984};
6985
6986static void __init size_pmem_devices(void)
6987{
6988#ifdef CONFIG_ANDROID_PMEM
6989 unsigned long size;
6990
6991 if machine_is_msm7x30_fluid()
6992 size = fluid_pmem_adsp_size;
6993 else
6994 size = pmem_adsp_size;
6995 android_pmem_adsp_pdata.size = size;
6996 android_pmem_audio_pdata.size = pmem_audio_size;
6997 android_pmem_pdata.size = pmem_sf_size;
6998#endif
6999}
7000
7001static void __init reserve_memory_for(struct android_pmem_platform_data *p)
7002{
7003 msm7x30_reserve_table[p->memory_type].size += p->size;
7004}
7005
7006static void __init reserve_pmem_memory(void)
7007{
7008#ifdef CONFIG_ANDROID_PMEM
7009 reserve_memory_for(&android_pmem_adsp_pdata);
7010 reserve_memory_for(&android_pmem_audio_pdata);
7011 reserve_memory_for(&android_pmem_pdata);
7012 msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
7013#endif
7014}
7015
7016static void __init msm7x30_calculate_reserve_sizes(void)
7017{
7018 size_pmem_devices();
7019 reserve_pmem_memory();
7020}
7021
7022static int msm7x30_paddr_to_memtype(unsigned int paddr)
7023{
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307024 if (paddr < phys_add)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007025 return MEMTYPE_EBI0;
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307026 if (paddr >= phys_add && paddr < 0x80000000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007027 return MEMTYPE_EBI1;
7028 return MEMTYPE_NONE;
7029}
7030
7031static struct reserve_info msm7x30_reserve_info __initdata = {
7032 .memtype_reserve_table = msm7x30_reserve_table,
7033 .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes,
7034 .paddr_to_memtype = msm7x30_paddr_to_memtype,
7035};
7036
7037static void __init msm7x30_reserve(void)
7038{
7039 reserve_info = &msm7x30_reserve_info;
7040 msm_reserve();
7041}
7042
7043static void __init msm7x30_allocate_memory_regions(void)
7044{
7045 void *addr;
7046 unsigned long size;
7047
7048 size = fb_size ? : MSM_FB_SIZE;
7049 addr = alloc_bootmem_align(size, 0x1000);
7050 msm_fb_resources[0].start = __pa(addr);
7051 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
7052 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
7053 size, addr, __pa(addr));
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08007054
7055#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
7056 size = MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE;
7057 addr = alloc_bootmem_align(size, 0x1000);
7058 msm_v4l2_video_overlay_resources[0].start = __pa(addr);
7059 msm_v4l2_video_overlay_resources[0].end =
7060 msm_v4l2_video_overlay_resources[0].start + size - 1;
7061 pr_debug("allocating %lu bytes at %p (%lx physical) for v4l2\n",
7062 size, addr, __pa(addr));
7063#endif
Daniel Walker8d747cd2010-02-25 11:37:43 -08007064}
7065
7066static void __init msm7x30_map_io(void)
7067{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007068 msm_shared_ram_phys = 0x00100000;
Daniel Walker8d747cd2010-02-25 11:37:43 -08007069 msm_map_msm7x30_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007070 if (socinfo_init() < 0)
7071 printk(KERN_ERR "%s: socinfo_init() failed!\n",
7072 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007073}
7074
7075static void __init msm7x30_init_early(void)
7076{
7077 msm7x30_allocate_memory_regions();
Daniel Walker8d747cd2010-02-25 11:37:43 -08007078}
7079
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307080static void __init msm7x30_fixup(struct machine_desc *desc, struct tag *tags,
7081 char **cmdline, struct meminfo *mi)
7082{
7083 for (; tags->hdr.size; tags = tag_next(tags)) {
7084 if (tags->hdr.tag == ATAG_MEM && tags->u.mem.start ==
7085 DDR1_BANK_BASE) {
7086 ebi1_phys_offset = DDR1_BANK_BASE;
7087 phys_add = DDR1_BANK_BASE;
7088 break;
7089 }
7090 }
7091}
7092
Daniel Walker8d747cd2010-02-25 11:37:43 -08007093MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00007094 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007095 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007096 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007097 .init_irq = msm7x30_init_irq,
7098 .init_machine = msm7x30_init,
7099 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007100 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307101 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307102 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007103MACHINE_END
7104
7105MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00007106 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007107 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007108 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007109 .init_irq = msm7x30_init_irq,
7110 .init_machine = msm7x30_init,
7111 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007112 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307113 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307114 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007115MACHINE_END
7116
7117MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
Russell Kingb75c1782011-01-04 19:03:16 +00007118 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007119 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007120 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007121 .init_irq = msm7x30_init_irq,
7122 .init_machine = msm7x30_init,
7123 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007124 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307125 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307126 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007127MACHINE_END
7128
7129MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
7130 .boot_params = PHYS_OFFSET + 0x100,
7131 .map_io = msm7x30_map_io,
7132 .reserve = msm7x30_reserve,
7133 .init_irq = msm7x30_init_irq,
7134 .init_machine = msm7x30_init,
7135 .timer = &msm_timer,
7136 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307137 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307138 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007139MACHINE_END
7140
7141MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA")
7142 .boot_params = PHYS_OFFSET + 0x100,
7143 .map_io = msm7x30_map_io,
7144 .reserve = msm7x30_reserve,
7145 .init_irq = msm7x30_init_irq,
7146 .init_machine = msm7x30_init,
7147 .timer = &msm_timer,
7148 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307149 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307150 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007151MACHINE_END
7152MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
7153 .boot_params = PHYS_OFFSET + 0x100,
7154 .map_io = msm7x30_map_io,
7155 .reserve = msm7x30_reserve,
7156 .init_irq = msm7x30_init_irq,
7157 .init_machine = msm7x30_init,
7158 .timer = &msm_timer,
7159 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307160 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307161 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007162MACHINE_END
7163MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA")
7164 .boot_params = PHYS_OFFSET + 0x100,
7165 .map_io = msm7x30_map_io,
7166 .reserve = msm7x30_reserve,
7167 .init_irq = msm7x30_init_irq,
7168 .init_machine = msm7x30_init,
7169 .timer = &msm_timer,
7170 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307171 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307172 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007173MACHINE_END