blob: 5f8e2acb21cce3d6bb1d132b4f7f3aa4746724a7 [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
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700863#ifdef CONFIG_MSM_CAMERA_V4L2
864static struct msm_camera_device_platform_data msm_camera_csi_device_data[] = {
865 {
866 .csid_core = 0,
867 .is_csic = 1,
868 .is_vpe = 1,
869 .ioclk = {
870 .vfe_clk_rate = 153600000,
871 },
872 },
873};
874
875static struct camera_vreg_t msm_7x30_back_cam_vreg[] = {
876 {"gp2", REG_LDO, 2600000, 2600000, -1},
877 {"lvsw1", REG_VS, 0, 0, 0},
878};
879
880static uint32_t camera_off_gpio_table[] = {
881 /* parallel CAMERA interfaces */
882 /* RST */
883 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
884 /* DAT2 */
885 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
886 /* DAT3 */
887 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
888 /* DAT4 */
889 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
890 /* DAT5 */
891 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
892 /* DAT6 */
893 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
894 /* DAT7 */
895 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
896 /* DAT8 */
897 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
898 /* DAT9 */
899 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
900 /* DAT10 */
901 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
902 /* DAT11 */
903 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
904 /* PCLK */
905 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
906 /* HSYNC_IN */
907 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
908 /* VSYNC_IN */
909 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
910 /* MCLK */
911 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
912};
913
914static uint32_t camera_on_gpio_table[] = {
915 /* parallel CAMERA interfaces */
916 /* RST */
917 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
918 /* DAT2 */
919 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
920 /* DAT3 */
921 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
922 /* DAT4 */
923 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
924 /* DAT5 */
925 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
926 /* DAT6 */
927 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
928 /* DAT7 */
929 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
930 /* DAT8 */
931 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
932 /* DAT9 */
933 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
934 /* DAT10 */
935 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
936 /* DAT11 */
937 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
938 /* PCLK */
939 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
940 /* HSYNC_IN */
941 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
942 /* VSYNC_IN */
943 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
944 /* MCLK */
945 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
946};
947
948static struct gpio msm7x30_back_cam_gpio[] = {
949 {0, GPIOF_DIR_OUT, "CAM_RESET"},
950};
951
952static struct msm_gpio_set_tbl msm7x30_back_cam_gpio_set_tbl[] = {
953 {0, GPIOF_OUT_INIT_LOW, 1000},
954 {0, GPIOF_OUT_INIT_HIGH, 4000},
955};
956
957static struct msm_camera_gpio_conf msm_7x30_back_cam_gpio_conf = {
958 .cam_gpio_req_tbl = msm7x30_back_cam_gpio,
959 .cam_gpio_req_tbl_size = ARRAY_SIZE(msm7x30_back_cam_gpio),
960 .cam_gpio_set_tbl = msm7x30_back_cam_gpio_set_tbl,
961 .cam_gpio_set_tbl_size = ARRAY_SIZE(msm7x30_back_cam_gpio_set_tbl),
962 .camera_off_table = camera_off_gpio_table,
963 .camera_off_table_size = ARRAY_SIZE(camera_off_gpio_table),
964 .camera_on_table = camera_on_gpio_table,
965 .camera_on_table_size = ARRAY_SIZE(camera_on_gpio_table),
966 .gpio_no_mux = 1,
967};
968
969static struct msm_camera_sensor_flash_data flash_vx6953 = {
970 .flash_type = MSM_CAMERA_FLASH_NONE,
971};
972
973static struct msm_camera_sensor_platform_info sensor_board_info_vx6953 = {
974 .mount_angle = 0,
975 .cam_vreg = msm_7x30_back_cam_vreg,
976 .num_vreg = ARRAY_SIZE(msm_7x30_back_cam_vreg),
977 .gpio_conf = &msm_7x30_back_cam_gpio_conf,
978};
979
980static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
981 .sensor_name = "vx6953",
982 .pdata = &msm_camera_csi_device_data[0],
983 .flash_data = &flash_vx6953,
984 .sensor_platform_info = &sensor_board_info_vx6953,
985 .csi_if = 1,
986 .camera_type = BACK_CAMERA_2D,
987};
988
989void __init msm7x30_init_cam(void)
990{
991 platform_device_register(&msm_device_csic0);
992 platform_device_register(&msm_device_vfe);
993 platform_device_register(&msm_device_vpe);
994}
995
996#ifdef CONFIG_I2C
997static struct i2c_board_info msm_camera_boardinfo[] = {
998 {
999 I2C_BOARD_INFO("vx6953", 0x20),
1000 .platform_data = &msm_camera_sensor_vx6953_data,
1001 },
1002};
1003#endif
1004#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001005static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
1006#ifdef CONFIG_MT9D112
1007 {
1008 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
Dima Zavinba5499e2011-01-10 11:00:30 -08001009 },
1010#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001011#ifdef CONFIG_WEBCAM_OV9726
1012 {
1013 I2C_BOARD_INFO("ov9726", 0x10),
1014 },
1015#endif
1016#ifdef CONFIG_S5K3E2FX
1017 {
1018 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
1019 },
1020#endif
1021#ifdef CONFIG_MT9P012
1022 {
1023 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
1024 },
1025#endif
1026#ifdef CONFIG_VX6953
1027 {
1028 I2C_BOARD_INFO("vx6953", 0x20),
1029 },
1030#endif
1031#ifdef CONFIG_MT9E013
1032 {
1033 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
1034 },
1035#endif
1036#ifdef CONFIG_SN12M0PZ
1037 {
1038 I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1),
1039 },
1040#endif
1041#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
1042 {
1043 I2C_BOARD_INFO("mt9t013", 0x6C),
1044 },
1045#endif
1046
Dima Zavinba5499e2011-01-10 11:00:30 -08001047};
1048
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001049#ifdef CONFIG_MSM_CAMERA
1050#define CAM_STNDBY 143
1051static uint32_t camera_off_vcm_gpio_table[] = {
1052GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */
1053};
1054
1055static uint32_t camera_off_gpio_table[] = {
1056 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001057 /* RST */
1058 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1059 /* DAT2 */
1060 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1061 /* DAT3 */
1062 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1063 /* DAT4 */
1064 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1065 /* DAT5 */
1066 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1067 /* DAT6 */
1068 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1069 /* DAT7 */
1070 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1071 /* DAT8 */
1072 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1073 /* DAT9 */
1074 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1075 /* DAT10 */
1076 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1077 /* DAT11 */
1078 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1079 /* PCLK */
1080 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1081 /* HSYNC_IN */
1082 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1083 /* VSYNC_IN */
1084 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1085 /* MCLK */
1086 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001087};
1088
1089static uint32_t camera_on_vcm_gpio_table[] = {
1090GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */
1091};
1092
1093static uint32_t camera_on_gpio_table[] = {
1094 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001095 /* RST */
1096 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1097 /* DAT2 */
1098 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1099 /* DAT3 */
1100 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1101 /* DAT4 */
1102 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1103 /* DAT5 */
1104 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1105 /* DAT6 */
1106 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1107 /* DAT7 */
1108 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1109 /* DAT8 */
1110 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1111 /* DAT9 */
1112 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1113 /* DAT10 */
1114 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1115 /* DAT11 */
1116 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1117 /* PCLK */
1118 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1119 /* HSYNC_IN */
1120 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1121 /* VSYNC_IN */
1122 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1123 /* MCLK */
1124 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001125};
1126
1127static uint32_t camera_off_gpio_fluid_table[] = {
1128 /* FLUID: CAM_VGA_RST_N */
1129 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1130 /* FLUID: CAMIF_STANDBY */
1131 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1132};
1133
1134static uint32_t camera_on_gpio_fluid_table[] = {
1135 /* FLUID: CAM_VGA_RST_N */
1136 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1137 /* FLUID: CAMIF_STANDBY */
1138 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1139};
1140
1141static void config_gpio_table(uint32_t *table, int len)
1142{
1143 int n, rc;
1144 for (n = 0; n < len; n++) {
1145 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
1146 if (rc) {
1147 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
1148 __func__, table[n], rc);
1149 break;
1150 }
1151 }
1152}
1153static int config_camera_on_gpios(void)
1154{
1155 config_gpio_table(camera_on_gpio_table,
1156 ARRAY_SIZE(camera_on_gpio_table));
1157
1158 if (adie_get_detected_codec_type() != TIMPANI_ID)
1159 /* GPIO1 is shared also used in Timpani RF card so
1160 only configure it for non-Timpani RF card */
1161 config_gpio_table(camera_on_vcm_gpio_table,
1162 ARRAY_SIZE(camera_on_vcm_gpio_table));
1163
1164 if (machine_is_msm7x30_fluid()) {
1165 config_gpio_table(camera_on_gpio_fluid_table,
1166 ARRAY_SIZE(camera_on_gpio_fluid_table));
1167 /* FLUID: turn on 5V booster */
1168 gpio_set_value(
1169 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 1);
1170 /* FLUID: drive high to put secondary sensor to STANDBY */
1171 gpio_set_value(CAM_STNDBY, 1);
1172 }
1173 return 0;
1174}
1175
1176static void config_camera_off_gpios(void)
1177{
1178 config_gpio_table(camera_off_gpio_table,
1179 ARRAY_SIZE(camera_off_gpio_table));
1180
1181 if (adie_get_detected_codec_type() != TIMPANI_ID)
1182 /* GPIO1 is shared also used in Timpani RF card so
1183 only configure it for non-Timpani RF card */
1184 config_gpio_table(camera_off_vcm_gpio_table,
1185 ARRAY_SIZE(camera_off_vcm_gpio_table));
1186
1187 if (machine_is_msm7x30_fluid()) {
1188 config_gpio_table(camera_off_gpio_fluid_table,
1189 ARRAY_SIZE(camera_off_gpio_fluid_table));
1190 /* FLUID: turn off 5V booster */
1191 gpio_set_value(
1192 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 0);
1193 }
1194}
1195
1196struct resource msm_camera_resources[] = {
1197 {
1198 .start = 0xA6000000,
1199 .end = 0xA6000000 + SZ_1M - 1,
1200 .flags = IORESOURCE_MEM,
1201 },
1202 {
1203 .start = INT_VFE,
1204 .end = INT_VFE,
1205 .flags = IORESOURCE_IRQ,
1206 },
1207 {
1208 .flags = IORESOURCE_DMA,
1209 }
1210};
1211
1212struct msm_camera_device_platform_data msm_camera_device_data = {
1213 .camera_gpio_on = config_camera_on_gpios,
1214 .camera_gpio_off = config_camera_off_gpios,
1215 .ioext.camifpadphy = 0xAB000000,
1216 .ioext.camifpadsz = 0x00000400,
1217 .ioext.csiphy = 0xA6100000,
1218 .ioext.csisz = 0x00000400,
1219 .ioext.csiirq = INT_CSI,
1220 .ioclk.mclk_clk_rate = 24000000,
1221 .ioclk.vfe_clk_rate = 147456000,
1222};
1223
1224static struct msm_camera_sensor_flash_src msm_flash_src_pwm = {
1225 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PWM,
1226 ._fsrc.pwm_src.freq = 1000,
1227 ._fsrc.pwm_src.max_load = 300,
1228 ._fsrc.pwm_src.low_load = 30,
1229 ._fsrc.pwm_src.high_load = 100,
1230 ._fsrc.pwm_src.channel = 7,
1231};
1232
1233#ifdef CONFIG_MT9D112
1234static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1235 .flash_type = MSM_CAMERA_FLASH_LED,
1236 .flash_src = &msm_flash_src_pwm
1237};
1238
1239static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1240 .sensor_name = "mt9d112",
1241 .sensor_reset = 0,
1242 .sensor_pwd = 85,
1243 .vcm_pwd = 1,
1244 .vcm_enable = 0,
1245 .pdata = &msm_camera_device_data,
1246 .resource = msm_camera_resources,
1247 .num_resources = ARRAY_SIZE(msm_camera_resources),
1248 .flash_data = &flash_mt9d112,
1249 .csi_if = 0
1250};
1251
1252static struct platform_device msm_camera_sensor_mt9d112 = {
1253 .name = "msm_camera_mt9d112",
1254 .dev = {
1255 .platform_data = &msm_camera_sensor_mt9d112_data,
1256 },
1257};
1258#endif
1259
1260#ifdef CONFIG_WEBCAM_OV9726
1261
1262static struct msm_camera_sensor_platform_info ov9726_sensor_7630_info = {
1263 .mount_angle = 90
1264};
1265
1266static struct msm_camera_sensor_flash_data flash_ov9726 = {
1267 .flash_type = MSM_CAMERA_FLASH_LED,
1268 .flash_src = &msm_flash_src_pwm
1269};
1270static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
1271 .sensor_name = "ov9726",
1272 .sensor_reset = 0,
1273 .sensor_pwd = 85,
1274 .vcm_pwd = 1,
1275 .vcm_enable = 0,
1276 .pdata = &msm_camera_device_data,
1277 .resource = msm_camera_resources,
1278 .num_resources = ARRAY_SIZE(msm_camera_resources),
1279 .flash_data = &flash_ov9726,
1280 .sensor_platform_info = &ov9726_sensor_7630_info,
1281 .csi_if = 1
1282};
1283struct platform_device msm_camera_sensor_ov9726 = {
1284 .name = "msm_camera_ov9726",
1285 .dev = {
1286 .platform_data = &msm_camera_sensor_ov9726_data,
1287 },
1288};
1289#endif
1290
1291#ifdef CONFIG_S5K3E2FX
1292static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1293 .flash_type = MSM_CAMERA_FLASH_LED,
1294 .flash_src = &msm_flash_src_pwm,
1295};
1296
1297static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1298 .sensor_name = "s5k3e2fx",
1299 .sensor_reset = 0,
1300 .sensor_pwd = 85,
1301 .vcm_pwd = 1,
1302 .vcm_enable = 0,
1303 .pdata = &msm_camera_device_data,
1304 .resource = msm_camera_resources,
1305 .num_resources = ARRAY_SIZE(msm_camera_resources),
1306 .flash_data = &flash_s5k3e2fx,
1307 .csi_if = 0
1308};
1309
1310static struct platform_device msm_camera_sensor_s5k3e2fx = {
1311 .name = "msm_camera_s5k3e2fx",
1312 .dev = {
1313 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1314 },
1315};
1316#endif
1317
1318#ifdef CONFIG_MT9P012
1319static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1320 .flash_type = MSM_CAMERA_FLASH_LED,
1321 .flash_src = &msm_flash_src_pwm
1322};
1323
1324static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1325 .sensor_name = "mt9p012",
1326 .sensor_reset = 0,
1327 .sensor_pwd = 85,
1328 .vcm_pwd = 1,
1329 .vcm_enable = 1,
1330 .pdata = &msm_camera_device_data,
1331 .resource = msm_camera_resources,
1332 .num_resources = ARRAY_SIZE(msm_camera_resources),
1333 .flash_data = &flash_mt9p012,
1334 .csi_if = 0
1335};
1336
1337static struct platform_device msm_camera_sensor_mt9p012 = {
1338 .name = "msm_camera_mt9p012",
1339 .dev = {
1340 .platform_data = &msm_camera_sensor_mt9p012_data,
1341 },
1342};
1343#endif
1344
1345#ifdef CONFIG_MT9E013
1346static struct msm_camera_sensor_platform_info mt9e013_sensor_7630_info = {
1347 .mount_angle = 0
1348};
1349
1350static struct msm_camera_sensor_flash_data flash_mt9e013 = {
1351 .flash_type = MSM_CAMERA_FLASH_LED,
1352 .flash_src = &msm_flash_src_pwm
1353};
1354
1355static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
1356 .sensor_name = "mt9e013",
1357 .sensor_reset = 0,
1358 .sensor_pwd = 85,
1359 .vcm_pwd = 1,
1360 .vcm_enable = 1,
1361 .pdata = &msm_camera_device_data,
1362 .resource = msm_camera_resources,
1363 .num_resources = ARRAY_SIZE(msm_camera_resources),
1364 .flash_data = &flash_mt9e013,
1365 .sensor_platform_info = &mt9e013_sensor_7630_info,
1366 .csi_if = 1
1367};
1368
1369static struct platform_device msm_camera_sensor_mt9e013 = {
1370 .name = "msm_camera_mt9e013",
1371 .dev = {
1372 .platform_data = &msm_camera_sensor_mt9e013_data,
1373 },
1374};
1375#endif
1376
1377#ifdef CONFIG_VX6953
Jilai Wang971f97f2011-07-13 14:25:25 -04001378static struct msm_camera_sensor_platform_info vx6953_sensor_7630_info = {
1379 .mount_angle = 0
1380};
1381
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001382static struct msm_camera_sensor_flash_data flash_vx6953 = {
1383 .flash_type = MSM_CAMERA_FLASH_LED,
1384 .flash_src = &msm_flash_src_pwm
1385};
1386static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1387 .sensor_name = "vx6953",
1388 .sensor_reset = 0,
1389 .sensor_pwd = 85,
1390 .vcm_pwd = 1,
1391 .vcm_enable = 0,
1392 .pdata = &msm_camera_device_data,
1393 .resource = msm_camera_resources,
1394 .num_resources = ARRAY_SIZE(msm_camera_resources),
Jilai Wang971f97f2011-07-13 14:25:25 -04001395 .sensor_platform_info = &vx6953_sensor_7630_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001396 .flash_data = &flash_vx6953,
1397 .csi_if = 1
1398};
1399static struct platform_device msm_camera_sensor_vx6953 = {
1400 .name = "msm_camera_vx6953",
1401 .dev = {
1402 .platform_data = &msm_camera_sensor_vx6953_data,
1403 },
1404};
1405#endif
1406
1407#ifdef CONFIG_SN12M0PZ
1408static struct msm_camera_sensor_flash_src msm_flash_src_current_driver = {
1409 .flash_sr_type = MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER,
1410 ._fsrc.current_driver_src.low_current = 210,
1411 ._fsrc.current_driver_src.high_current = 700,
1412 ._fsrc.current_driver_src.driver_channel = &pm8058_fluid_leds_data,
1413};
1414
1415static struct msm_camera_sensor_flash_data flash_sn12m0pz = {
1416 .flash_type = MSM_CAMERA_FLASH_LED,
1417 .flash_src = &msm_flash_src_current_driver
1418};
1419static struct msm_camera_sensor_info msm_camera_sensor_sn12m0pz_data = {
1420 .sensor_name = "sn12m0pz",
1421 .sensor_reset = 0,
1422 .sensor_pwd = 85,
1423 .vcm_pwd = 1,
1424 .vcm_enable = 1,
1425 .pdata = &msm_camera_device_data,
1426 .flash_data = &flash_sn12m0pz,
1427 .resource = msm_camera_resources,
1428 .num_resources = ARRAY_SIZE(msm_camera_resources),
1429 .csi_if = 0
1430};
1431
1432static struct platform_device msm_camera_sensor_sn12m0pz = {
1433 .name = "msm_camera_sn12m0pz",
1434 .dev = {
1435 .platform_data = &msm_camera_sensor_sn12m0pz_data,
1436 },
1437};
1438#endif
1439
1440#ifdef CONFIG_MT9T013
1441static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1442 .flash_type = MSM_CAMERA_FLASH_LED,
1443 .flash_src = &msm_flash_src_pwm
1444};
1445
1446static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1447 .sensor_name = "mt9t013",
1448 .sensor_reset = 0,
1449 .sensor_pwd = 85,
1450 .vcm_pwd = 1,
1451 .vcm_enable = 0,
1452 .pdata = &msm_camera_device_data,
1453 .resource = msm_camera_resources,
1454 .num_resources = ARRAY_SIZE(msm_camera_resources),
1455 .flash_data = &flash_mt9t013,
1456 .csi_if = 1
1457};
1458
1459static struct platform_device msm_camera_sensor_mt9t013 = {
1460 .name = "msm_camera_mt9t013",
1461 .dev = {
1462 .platform_data = &msm_camera_sensor_mt9t013_data,
1463 },
1464};
1465#endif
1466
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001467#ifdef CONFIG_MSM_VPE
1468static struct resource msm_vpe_resources[] = {
1469 {
1470 .start = 0xAD200000,
1471 .end = 0xAD200000 + SZ_1M - 1,
1472 .flags = IORESOURCE_MEM,
1473 },
1474 {
1475 .start = INT_VPE,
1476 .end = INT_VPE,
1477 .flags = IORESOURCE_IRQ,
1478 },
1479};
1480
1481static struct platform_device msm_vpe_device = {
1482 .name = "msm_vpe",
1483 .id = 0,
1484 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1485 .resource = msm_vpe_resources,
1486};
1487#endif
1488
1489#endif /*CONFIG_MSM_CAMERA*/
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001490#endif
1491
1492#ifdef CONFIG_MSM_GEMINI
1493static struct resource msm_gemini_resources[] = {
1494 {
1495 .start = 0xA3A00000,
1496 .end = 0xA3A00000 + 0x0150 - 1,
1497 .flags = IORESOURCE_MEM,
1498 },
1499 {
1500 .start = INT_JPEG,
1501 .end = INT_JPEG,
1502 .flags = IORESOURCE_IRQ,
1503 },
1504};
1505
1506static struct platform_device msm_gemini_device = {
1507 .name = "msm_gemini",
1508 .resource = msm_gemini_resources,
1509 .num_resources = ARRAY_SIZE(msm_gemini_resources),
1510};
1511#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001512
1513#ifdef CONFIG_MSM7KV2_AUDIO
1514static uint32_t audio_pamp_gpio_config =
1515 GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1516
1517static uint32_t audio_fluid_icodec_tx_config =
1518 GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1519
1520static int __init snddev_poweramp_gpio_init(void)
1521{
1522 int rc;
1523
1524 pr_info("snddev_poweramp_gpio_init \n");
1525 rc = gpio_tlmm_config(audio_pamp_gpio_config, GPIO_CFG_ENABLE);
1526 if (rc) {
1527 printk(KERN_ERR
1528 "%s: gpio_tlmm_config(%#x)=%d\n",
1529 __func__, audio_pamp_gpio_config, rc);
1530 }
1531 return rc;
1532}
1533
1534void msm_snddev_tx_route_config(void)
1535{
1536 int rc;
1537
1538 pr_debug("%s()\n", __func__);
1539
1540 if (machine_is_msm7x30_fluid()) {
1541 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1542 GPIO_CFG_ENABLE);
1543 if (rc) {
1544 printk(KERN_ERR
1545 "%s: gpio_tlmm_config(%#x)=%d\n",
1546 __func__, audio_fluid_icodec_tx_config, rc);
1547 } else
1548 gpio_set_value(85, 0);
1549 }
1550}
1551
1552void msm_snddev_tx_route_deconfig(void)
1553{
1554 int rc;
1555
1556 pr_debug("%s()\n", __func__);
1557
1558 if (machine_is_msm7x30_fluid()) {
1559 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1560 GPIO_CFG_DISABLE);
1561 if (rc) {
1562 printk(KERN_ERR
1563 "%s: gpio_tlmm_config(%#x)=%d\n",
1564 __func__, audio_fluid_icodec_tx_config, rc);
1565 }
1566 }
1567}
1568
1569void msm_snddev_poweramp_on(void)
1570{
1571 gpio_set_value(82, 1); /* enable spkr poweramp */
1572 pr_info("%s: power on amplifier\n", __func__);
1573}
1574
1575void msm_snddev_poweramp_off(void)
1576{
1577 gpio_set_value(82, 0); /* disable spkr poweramp */
1578 pr_info("%s: power off amplifier\n", __func__);
1579}
1580
Justin Paupore3f40f342011-08-10 18:52:16 -07001581static struct regulator_bulk_data snddev_regs[] = {
1582 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
1583 { .supply = "ncp", .min_uV = 1800000, .max_uV = 1800000 },
1584};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001585
Justin Paupore3f40f342011-08-10 18:52:16 -07001586static int __init snddev_hsed_voltage_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001587{
1588 int rc;
1589
Justin Paupore3f40f342011-08-10 18:52:16 -07001590 rc = regulator_bulk_get(NULL, ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001591
Justin Paupore3f40f342011-08-10 18:52:16 -07001592 if (rc) {
1593 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1594 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001595 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001596
1597 rc = regulator_bulk_set_voltage(ARRAY_SIZE(snddev_regs), snddev_regs);
1598
1599 if (rc) {
1600 pr_err("%s: could not set regulator voltages: %d\n",
1601 __func__, rc);
1602 goto regs_free;
1603 }
1604
1605 return 0;
1606
1607regs_free:
1608 regulator_bulk_free(ARRAY_SIZE(snddev_regs), snddev_regs);
1609out:
1610 return rc;
1611}
1612
1613
1614void msm_snddev_hsed_voltage_on(void)
1615{
1616 int rc = regulator_bulk_enable(ARRAY_SIZE(snddev_regs), snddev_regs);
1617
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001618 if (rc)
Justin Paupore3f40f342011-08-10 18:52:16 -07001619 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001620}
1621
1622void msm_snddev_hsed_voltage_off(void)
1623{
Justin Paupore3f40f342011-08-10 18:52:16 -07001624 int rc = regulator_bulk_disable(ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001625
Justin Paupore3f40f342011-08-10 18:52:16 -07001626 if (rc) {
1627 pr_err("%s: could not disable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001628 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001629}
1630
1631static unsigned aux_pcm_gpio_on[] = {
1632 GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
1633 GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
1634 GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
1635 GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
1636};
1637
1638static int __init aux_pcm_gpio_init(void)
1639{
1640 int pin, rc;
1641
1642 pr_info("aux_pcm_gpio_init \n");
1643 for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) {
1644 rc = gpio_tlmm_config(aux_pcm_gpio_on[pin],
1645 GPIO_CFG_ENABLE);
1646 if (rc) {
1647 printk(KERN_ERR
1648 "%s: gpio_tlmm_config(%#x)=%d\n",
1649 __func__, aux_pcm_gpio_on[pin], rc);
1650 }
1651 }
1652 return rc;
1653}
1654
1655static struct msm_gpio mi2s_clk_gpios[] = {
1656 { GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1657 "MI2S_SCLK"},
1658 { GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1659 "MI2S_WS"},
1660 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1661 "MI2S_MCLK_A"},
1662};
1663
1664static struct msm_gpio mi2s_rx_data_lines_gpios[] = {
1665 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1666 "MI2S_DATA_SD0_A"},
1667 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1668 "MI2S_DATA_SD1_A"},
1669 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1670 "MI2S_DATA_SD2_A"},
1671 { GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1672 "MI2S_DATA_SD3"},
1673};
1674
1675static struct msm_gpio mi2s_tx_data_lines_gpios[] = {
1676 { GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1677 "MI2S_DATA_SD3"},
1678};
1679
1680int mi2s_config_clk_gpio(void)
1681{
1682 int rc = 0;
1683
1684 rc = msm_gpios_request_enable(mi2s_clk_gpios,
1685 ARRAY_SIZE(mi2s_clk_gpios));
1686 if (rc) {
1687 pr_err("%s: enable mi2s clk gpios failed\n",
1688 __func__);
1689 return rc;
1690 }
1691 return 0;
1692}
1693
1694int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask)
1695{
1696 int i, rc = 0;
1697 sd_line_mask &= MI2S_SD_LINE_MASK;
1698
1699 switch (direction) {
1700 case DIR_TX:
1701 msm_gpios_disable_free(mi2s_tx_data_lines_gpios, 1);
1702 break;
1703 case DIR_RX:
1704 i = 0;
1705 while (sd_line_mask) {
1706 if (sd_line_mask & 0x1)
1707 msm_gpios_disable_free(
1708 mi2s_rx_data_lines_gpios + i , 1);
1709 sd_line_mask = sd_line_mask >> 1;
1710 i++;
1711 }
1712 break;
1713 default:
1714 pr_err("%s: Invaild direction direction = %u\n",
1715 __func__, direction);
1716 rc = -EINVAL;
1717 break;
1718 }
1719 return rc;
1720}
1721
1722int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask)
1723{
1724 int i , rc = 0;
1725 u8 sd_config_done_mask = 0;
1726
1727 sd_line_mask &= MI2S_SD_LINE_MASK;
1728
1729 switch (direction) {
1730 case DIR_TX:
1731 if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) ||
1732 (sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) {
1733 pr_err("%s: can not use SD0 or SD1 or SD2 for TX"
1734 ".only can use SD3. sd_line_mask = 0x%x\n",
1735 __func__ , sd_line_mask);
1736 rc = -EINVAL;
1737 } else {
1738 rc = msm_gpios_request_enable(mi2s_tx_data_lines_gpios,
1739 1);
1740 if (rc)
1741 pr_err("%s: enable mi2s gpios for TX failed\n",
1742 __func__);
1743 }
1744 break;
1745 case DIR_RX:
1746 i = 0;
1747 while (sd_line_mask && (rc == 0)) {
1748 if (sd_line_mask & 0x1) {
1749 rc = msm_gpios_request_enable(
1750 mi2s_rx_data_lines_gpios + i , 1);
1751 if (rc) {
1752 pr_err("%s: enable mi2s gpios for"
1753 "RX failed. SD line = %s\n",
1754 __func__,
1755 (mi2s_rx_data_lines_gpios + i)->label);
1756 mi2s_unconfig_data_gpio(DIR_RX,
1757 sd_config_done_mask);
1758 } else
1759 sd_config_done_mask |= (1 << i);
1760 }
1761 sd_line_mask = sd_line_mask >> 1;
1762 i++;
1763 }
1764 break;
1765 default:
1766 pr_err("%s: Invaild direction direction = %u\n",
1767 __func__, direction);
1768 rc = -EINVAL;
1769 break;
1770 }
1771 return rc;
1772}
1773
1774int mi2s_unconfig_clk_gpio(void)
1775{
1776 msm_gpios_disable_free(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios));
1777 return 0;
1778}
1779
1780#endif /* CONFIG_MSM7KV2_AUDIO */
1781
1782static int __init buses_init(void)
1783{
1784 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT,
1785 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
1786 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
1787 __func__, PMIC_GPIO_INT);
1788
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301789 if (machine_is_msm8x60_fluid())
1790 pm8058_7x30_data.keypad_pdata = &fluid_keypad_data;
1791 else
1792 pm8058_7x30_data.keypad_pdata = &surf_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001793
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001794 return 0;
1795}
1796
1797#define TIMPANI_RESET_GPIO 1
1798
1799struct bahama_config_register{
1800 u8 reg;
1801 u8 value;
1802 u8 mask;
1803};
1804
1805enum version{
1806 VER_1_0,
1807 VER_2_0,
1808 VER_UNSUPPORTED = 0xFF
1809};
1810
Justin Paupore3f40f342011-08-10 18:52:16 -07001811static struct regulator *vreg_marimba_1;
1812static struct regulator *vreg_marimba_2;
1813static struct regulator *vreg_bahama;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001814
1815static struct msm_gpio timpani_reset_gpio_cfg[] = {
1816{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
1817 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} };
1818
1819static u8 read_bahama_ver(void)
1820{
1821 int rc;
1822 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1823 u8 bahama_version;
1824
1825 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
1826 if (rc < 0) {
1827 printk(KERN_ERR
1828 "%s: version read failed: %d\n",
1829 __func__, rc);
1830 return rc;
1831 } else {
1832 printk(KERN_INFO
1833 "%s: version read got: 0x%x\n",
1834 __func__, bahama_version);
1835 }
1836
1837 switch (bahama_version) {
1838 case 0x08: /* varient of bahama v1 */
1839 case 0x10:
1840 case 0x00:
1841 return VER_1_0;
1842 case 0x09: /* variant of bahama v2 */
1843 return VER_2_0;
1844 default:
1845 return VER_UNSUPPORTED;
1846 }
1847}
1848
1849static int config_timpani_reset(void)
1850{
1851 int rc;
1852
1853 rc = msm_gpios_request_enable(timpani_reset_gpio_cfg,
1854 ARRAY_SIZE(timpani_reset_gpio_cfg));
1855 if (rc < 0) {
1856 printk(KERN_ERR
1857 "%s: msm_gpios_request_enable failed (%d)\n",
1858 __func__, rc);
1859 }
1860 return rc;
1861}
1862
1863static unsigned int msm_timpani_setup_power(void)
1864{
1865 int rc;
1866
1867 rc = config_timpani_reset();
1868 if (rc < 0)
1869 goto out;
1870
Justin Paupore3f40f342011-08-10 18:52:16 -07001871 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001872 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001873 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001874 goto out;
1875 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001876
1877 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001878 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001879 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1880 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001881 }
1882
1883 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1);
1884 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001885 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001886 __func__, rc);
1887 msm_gpios_free(timpani_reset_gpio_cfg,
1888 ARRAY_SIZE(timpani_reset_gpio_cfg));
Justin Paupore3f40f342011-08-10 18:52:16 -07001889 goto disable_marimba_2;
1890 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001891
Justin Paupore3f40f342011-08-10 18:52:16 -07001892 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001893
Justin Paupore3f40f342011-08-10 18:52:16 -07001894disable_marimba_2:
1895 regulator_disable(vreg_marimba_2);
1896disable_marimba_1:
1897 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001898out:
1899 return rc;
1900};
1901
1902static void msm_timpani_shutdown_power(void)
1903{
1904 int rc;
1905
Justin Paupore3f40f342011-08-10 18:52:16 -07001906 rc = regulator_disable(vreg_marimba_2);
1907 if (rc)
1908 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1909
1910 rc = regulator_disable(vreg_marimba_1);
1911 if (rc)
1912 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001913
1914 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0);
Justin Paupore3f40f342011-08-10 18:52:16 -07001915 if (rc < 0)
1916 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001917 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001918
1919 msm_gpios_free(timpani_reset_gpio_cfg,
1920 ARRAY_SIZE(timpani_reset_gpio_cfg));
1921};
1922
1923static unsigned int msm_bahama_core_config(int type)
1924{
1925 int rc = 0;
1926
1927 if (type == BAHAMA_ID) {
1928
1929 int i;
1930 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1931
1932 const struct bahama_config_register v20_init[] = {
1933 /* reg, value, mask */
1934 { 0xF4, 0x84, 0xFF }, /* AREG */
1935 { 0xF0, 0x04, 0xFF } /* DREG */
1936 };
1937
1938 if (read_bahama_ver() == VER_2_0) {
1939 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
1940 u8 value = v20_init[i].value;
1941 rc = marimba_write_bit_mask(&config,
1942 v20_init[i].reg,
1943 &value,
1944 sizeof(v20_init[i].value),
1945 v20_init[i].mask);
1946 if (rc < 0) {
1947 printk(KERN_ERR
1948 "%s: reg %d write failed: %d\n",
1949 __func__, v20_init[i].reg, rc);
1950 return rc;
1951 }
1952 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
1953 " mask 0x%02x\n",
1954 __func__, v20_init[i].reg,
1955 v20_init[i].value, v20_init[i].mask);
1956 }
1957 }
1958 }
1959 printk(KERN_INFO "core type: %d\n", type);
1960
1961 return rc;
1962}
1963
1964static unsigned int msm_bahama_setup_power(void)
1965{
Justin Paupore3f40f342011-08-10 18:52:16 -07001966 int rc = regulator_enable(vreg_bahama);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001967
Justin Paupore3f40f342011-08-10 18:52:16 -07001968 if (rc)
1969 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001970
1971 return rc;
1972};
1973
1974static unsigned int msm_bahama_shutdown_power(int value)
1975{
1976 int rc = 0;
1977
1978 if (value != BAHAMA_ID) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001979 rc = regulator_disable(vreg_bahama);
1980
1981 if (rc)
1982 pr_err("%s: regulator_disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001983 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001984 }
1985
1986 return rc;
1987};
1988
1989static struct msm_gpio marimba_svlte_config_clock[] = {
1990 { GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1991 "MARIMBA_SVLTE_CLOCK_ENABLE" },
1992};
1993
1994static unsigned int msm_marimba_gpio_config_svlte(int gpio_cfg_marimba)
1995{
1996 if (machine_is_msm8x55_svlte_surf() ||
1997 machine_is_msm8x55_svlte_ffa()) {
1998 if (gpio_cfg_marimba)
1999 gpio_set_value(GPIO_PIN
2000 (marimba_svlte_config_clock->gpio_cfg), 1);
2001 else
2002 gpio_set_value(GPIO_PIN
2003 (marimba_svlte_config_clock->gpio_cfg), 0);
2004 }
2005
2006 return 0;
2007};
2008
2009static unsigned int msm_marimba_setup_power(void)
2010{
2011 int rc;
2012
Justin Paupore3f40f342011-08-10 18:52:16 -07002013 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002014 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002015 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002016 goto out;
2017 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002018
2019 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002020 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002021 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2022 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002023 }
2024
2025 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
2026 rc = msm_gpios_request_enable(marimba_svlte_config_clock,
2027 ARRAY_SIZE(marimba_svlte_config_clock));
2028 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002029 pr_err("%s: msm_gpios_request_enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002030 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002031 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002032 }
2033
2034 rc = gpio_direction_output(GPIO_PIN
2035 (marimba_svlte_config_clock->gpio_cfg), 0);
2036 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002037 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002038 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002039 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002040 }
2041 }
2042
Justin Paupore3f40f342011-08-10 18:52:16 -07002043 return 0;
2044
2045disable_marimba_2:
2046 regulator_disable(vreg_marimba_2);
2047disable_marimba_1:
2048 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002049out:
2050 return rc;
2051};
2052
2053static void msm_marimba_shutdown_power(void)
2054{
2055 int rc;
2056
Justin Paupore3f40f342011-08-10 18:52:16 -07002057 rc = regulator_disable(vreg_marimba_2);
2058 if (rc)
2059 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
2060
2061 rc = regulator_disable(vreg_marimba_1);
2062 if (rc)
2063 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002064};
2065
2066static int bahama_present(void)
2067{
2068 int id;
2069 switch (id = adie_get_detected_connectivity_type()) {
2070 case BAHAMA_ID:
2071 return 1;
2072
2073 case MARIMBA_ID:
2074 return 0;
2075
2076 case TIMPANI_ID:
2077 default:
2078 printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n",
2079 __func__, id);
2080 return -ENODEV;
2081 }
2082}
2083
Justin Paupore3f40f342011-08-10 18:52:16 -07002084struct regulator *fm_regulator;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002085static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
2086{
Justin Paupore3f40f342011-08-10 18:52:16 -07002087 int rc, voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002088 uint32_t irqcfg;
2089 const char *id = "FMPW";
2090
2091 int bahama_not_marimba = bahama_present();
2092
Justin Paupore3f40f342011-08-10 18:52:16 -07002093 if (bahama_not_marimba < 0) {
2094 pr_warn("%s: bahama_present: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002095 __func__, bahama_not_marimba);
Justin Paupore3f40f342011-08-10 18:52:16 -07002096 rc = -ENODEV;
2097 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002098 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002099 if (bahama_not_marimba) {
2100 fm_regulator = regulator_get(NULL, "s3");
2101 voltage = 1800000;
2102 } else {
2103 fm_regulator = regulator_get(NULL, "s2");
2104 voltage = 1300000;
2105 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002106
2107 if (IS_ERR(fm_regulator)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002108 rc = PTR_ERR(fm_regulator);
2109 pr_err("%s: regulator_get failed (%d)\n", __func__, rc);
2110 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002111 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002112
Justin Paupore3f40f342011-08-10 18:52:16 -07002113 rc = regulator_set_voltage(fm_regulator, voltage, voltage);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002114
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002115 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002116 pr_err("%s: regulator_set_voltage failed (%d)\n", __func__, rc);
2117 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002118 }
2119
Justin Paupore3f40f342011-08-10 18:52:16 -07002120 rc = regulator_enable(fm_regulator);
2121
2122 if (rc) {
2123 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2124 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002125 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002126
2127 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_ON);
2128
2129 if (rc < 0) {
2130 pr_err("%s: clock vote failed (%d)\n", __func__, rc);
2131 goto regulator_disable;
2132 }
2133
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002134 /*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2135 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002136 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002137 rc = marimba_gpio_config(1);
Justin Paupore3f40f342011-08-10 18:52:16 -07002138 if (rc < 0) {
2139 pr_err("%s: clock enable for svlte : %d\n",
2140 __func__, rc);
2141 goto clock_devote;
2142 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002143 }
2144 irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
2145 GPIO_CFG_2MA);
2146 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2147 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002148 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002149 rc = -EIO;
Justin Paupore3f40f342011-08-10 18:52:16 -07002150 goto gpio_deconfig;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002151
2152 }
2153 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002154
Justin Paupore3f40f342011-08-10 18:52:16 -07002155gpio_deconfig:
2156 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa())
2157 marimba_gpio_config(0);
2158clock_devote:
2159 pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_OFF);
2160regulator_disable:
2161 regulator_disable(fm_regulator);
2162regulator_free:
2163 regulator_put(fm_regulator);
2164 fm_regulator = NULL;
2165out:
2166 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002167};
2168
2169static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
2170{
2171 int rc;
2172 const char *id = "FMPW";
2173 uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
2174 GPIO_CFG_2MA);
2175
2176 int bahama_not_marimba = bahama_present();
2177 if (bahama_not_marimba == -1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002178 pr_warn("%s: bahama_present: %d\n",
2179 __func__, bahama_not_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002180 return;
2181 }
2182
2183 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2184 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002185 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002186 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002187 if (!IS_ERR_OR_NULL(fm_regulator)) {
2188 rc = regulator_disable(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002189
Justin Paupore3f40f342011-08-10 18:52:16 -07002190 if (rc)
2191 pr_err("%s: return val: %d\n", __func__, rc);
2192
2193 regulator_put(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002194 fm_regulator = NULL;
2195 }
2196 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
2197 PMAPP_CLOCK_VOTE_OFF);
2198 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002199 pr_err("%s: clock_vote return val: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002200
2201 /*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2202 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002203 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002204 rc = marimba_gpio_config(0);
2205 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002206 pr_err("%s: clock disable for svlte : %d\n",
2207 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002208 }
2209}
2210
2211static struct marimba_fm_platform_data marimba_fm_pdata = {
2212 .fm_setup = fm_radio_setup,
2213 .fm_shutdown = fm_radio_shutdown,
2214 .irq = MSM_GPIO_TO_INT(147),
2215 .vreg_s2 = NULL,
2216 .vreg_xo_out = NULL,
2217 .is_fm_soc_i2s_master = false,
2218 .config_i2s_gpio = NULL,
2219};
2220
2221
2222/* Slave id address for FM/CDC/QMEMBIST
2223 * Values can be programmed using Marimba slave id 0
2224 * should there be a conflict with other I2C devices
2225 * */
2226#define MARIMBA_SLAVE_ID_FM_ADDR 0x2A
2227#define MARIMBA_SLAVE_ID_CDC_ADDR 0x77
2228#define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66
2229
2230#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
2231#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
2232
2233static const char *tsadc_id = "MADC";
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002234
Justin Paupore3f40f342011-08-10 18:52:16 -07002235static struct regulator_bulk_data regs_tsadc_marimba[] = {
2236 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2237 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002238};
Justin Paupore3f40f342011-08-10 18:52:16 -07002239
2240static struct regulator_bulk_data regs_tsadc_timpani[] = {
2241 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2242 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2243 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2244};
2245
2246static struct regulator_bulk_data *regs_tsadc;
2247static int regs_tsadc_count;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002248
2249static int marimba_tsadc_power(int vreg_on)
2250{
Justin Paupore3f40f342011-08-10 18:52:16 -07002251 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002252 int tsadc_adie_type = adie_get_detected_codec_type();
2253
Justin Paupore3f40f342011-08-10 18:52:16 -07002254 switch (tsadc_adie_type) {
2255 case TIMPANI_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002256 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2257 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2258 if (rc) {
2259 pr_err("%s: unable to %svote for d1 clk\n",
2260 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002261 goto D1_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002262 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002263
2264 /* fall through */
2265 case MARIMBA_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002266 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2267 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2268 if (rc) {
2269 pr_err("%s: unable to %svote for d1 clk\n",
2270 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002271 goto D0_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002272 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002273
Justin Paupore3f40f342011-08-10 18:52:16 -07002274 WARN_ON(regs_tsadc_count == 0);
2275
2276 rc = vreg_on ?
2277 regulator_bulk_enable(regs_tsadc_count, regs_tsadc) :
2278 regulator_bulk_disable(regs_tsadc_count, regs_tsadc);
2279
2280 if (rc) {
2281 pr_err("%s: regulator %sable failed: %d\n",
2282 __func__, vreg_on ? "en" : "dis", rc);
2283 goto regulator_switch_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002284 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002285
2286 break;
2287 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002288 pr_err("%s:Adie %d not supported\n",
2289 __func__, tsadc_adie_type);
2290 return -ENODEV;
2291 }
2292
2293 msleep(5); /* ensure power is stable */
2294
2295 return 0;
2296
Justin Paupore3f40f342011-08-10 18:52:16 -07002297regulator_switch_fail:
2298 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2299 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2300D0_vote_fail:
2301 if (tsadc_adie_type == TIMPANI_ID)
2302 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2303 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2304D1_vote_fail:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002305 return rc;
2306}
2307
2308static int marimba_tsadc_init(void)
2309{
Justin Paupore3f40f342011-08-10 18:52:16 -07002310 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002311 int tsadc_adie_type = adie_get_detected_codec_type();
2312
Justin Paupore3f40f342011-08-10 18:52:16 -07002313 switch (tsadc_adie_type) {
2314 case MARIMBA_ID:
2315 regs_tsadc = regs_tsadc_marimba;
2316 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_marimba);
2317 break;
2318 case TIMPANI_ID:
2319 regs_tsadc = regs_tsadc_timpani;
2320 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_timpani);
2321 break;
2322 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002323 pr_err("%s:Adie %d not supported\n",
2324 __func__, tsadc_adie_type);
Justin Paupore3f40f342011-08-10 18:52:16 -07002325 rc = -ENODEV;
2326 goto out;
2327 }
2328
2329 rc = regulator_bulk_get(NULL, regs_tsadc_count, regs_tsadc);
2330 if (rc) {
2331 pr_err("%s: could not get regulators: %d\n",
2332 __func__, rc);
2333 goto out;
2334 }
2335
2336 rc = regulator_bulk_set_voltage(regs_tsadc_count, regs_tsadc);
2337 if (rc) {
2338 pr_err("%s: could not set regulator voltages: %d\n",
2339 __func__, rc);
2340 goto vreg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002341 }
2342
2343 return 0;
2344
Justin Paupore3f40f342011-08-10 18:52:16 -07002345vreg_free:
2346 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2347out:
2348 regs_tsadc = NULL;
2349 regs_tsadc_count = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002350 return rc;
2351}
2352
2353static int marimba_tsadc_exit(void)
2354{
Justin Paupore3f40f342011-08-10 18:52:16 -07002355 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2356 regs_tsadc_count = 0;
2357 regs_tsadc = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002358
Justin Paupore3f40f342011-08-10 18:52:16 -07002359 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002360}
2361
2362
2363static struct msm_ts_platform_data msm_ts_data = {
Anirudh Ghayal82b74722012-01-19 15:35:34 +05302364 .min_x = 284,
2365 .max_x = 3801,
2366 .min_y = 155,
2367 .max_y = 3929,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002368 .min_press = 0,
2369 .max_press = 255,
2370 .inv_x = 4096,
2371 .inv_y = 4096,
2372 .can_wakeup = false,
2373};
2374
2375static struct marimba_tsadc_platform_data marimba_tsadc_pdata = {
2376 .marimba_tsadc_power = marimba_tsadc_power,
2377 .init = marimba_tsadc_init,
2378 .exit = marimba_tsadc_exit,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002379 .tsadc_prechg_en = true,
2380 .can_wakeup = false,
2381 .setup = {
2382 .pen_irq_en = true,
2383 .tsadc_en = true,
2384 },
2385 .params2 = {
2386 .input_clk_khz = 2400,
2387 .sample_prd = TSADC_CLK_3,
2388 },
2389 .params3 = {
2390 .prechg_time_nsecs = 6400,
2391 .stable_time_nsecs = 6400,
2392 .tsadc_test_mode = 0,
2393 },
2394 .tssc_data = &msm_ts_data,
2395};
2396
Justin Paupore3f40f342011-08-10 18:52:16 -07002397static struct regulator_bulk_data codec_regs[] = {
2398 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
2399};
2400
2401static int __init msm_marimba_codec_init(void)
2402{
2403 int rc = regulator_bulk_get(NULL, ARRAY_SIZE(codec_regs), codec_regs);
2404
2405 if (rc) {
2406 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2407 goto out;
2408 }
2409
2410 rc = regulator_bulk_set_voltage(ARRAY_SIZE(codec_regs), codec_regs);
2411 if (rc) {
2412 pr_err("%s: could not set regulator voltages: %d\n",
2413 __func__, rc);
2414 goto reg_free;
2415 }
2416
2417 return rc;
2418
2419reg_free:
2420 regulator_bulk_free(ARRAY_SIZE(codec_regs), codec_regs);
2421out:
2422 return rc;
2423}
2424
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002425static int msm_marimba_codec_power(int vreg_on)
2426{
Justin Paupore3f40f342011-08-10 18:52:16 -07002427 int rc = vreg_on ?
2428 regulator_bulk_enable(ARRAY_SIZE(codec_regs), codec_regs) :
2429 regulator_bulk_disable(ARRAY_SIZE(codec_regs), codec_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002430
Justin Paupore3f40f342011-08-10 18:52:16 -07002431 if (rc) {
2432 pr_err("%s: could not %sable regulators: %d",
2433 __func__, vreg_on ? "en" : "dis", rc);
2434 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002435 }
2436
Justin Paupore3f40f342011-08-10 18:52:16 -07002437 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002438}
2439
2440static struct marimba_codec_platform_data mariba_codec_pdata = {
2441 .marimba_codec_power = msm_marimba_codec_power,
2442#ifdef CONFIG_MARIMBA_CODEC
2443 .snddev_profile_init = msm_snddev_init,
2444#endif
2445};
2446
2447static struct marimba_platform_data marimba_pdata = {
2448 .slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR,
2449 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2450 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2451 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
2452 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
2453 .marimba_setup = msm_marimba_setup_power,
2454 .marimba_shutdown = msm_marimba_shutdown_power,
2455 .bahama_setup = msm_bahama_setup_power,
2456 .bahama_shutdown = msm_bahama_shutdown_power,
2457 .marimba_gpio_config = msm_marimba_gpio_config_svlte,
2458 .bahama_core_config = msm_bahama_core_config,
2459 .fm = &marimba_fm_pdata,
2460 .codec = &mariba_codec_pdata,
2461 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2462};
2463
2464static void __init msm7x30_init_marimba(void)
2465{
2466 int rc;
2467
Justin Paupore3f40f342011-08-10 18:52:16 -07002468 struct regulator_bulk_data regs[] = {
2469 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2470 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2471 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
2472 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002473
Justin Paupore3f40f342011-08-10 18:52:16 -07002474 rc = msm_marimba_codec_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002475
Justin Paupore3f40f342011-08-10 18:52:16 -07002476 if (rc) {
2477 pr_err("%s: msm_marimba_codec_init failed (%d)\n",
2478 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002479 return;
2480 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002481
2482 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
2483
2484 if (rc) {
2485 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2486 return;
2487 }
2488
2489 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
2490
2491 if (rc) {
2492 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2493 regulator_bulk_free(ARRAY_SIZE(regs), regs);
2494 return;
2495 }
2496
2497 vreg_marimba_1 = regs[0].consumer;
2498 vreg_marimba_2 = regs[1].consumer;
2499 vreg_bahama = regs[2].consumer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002500}
2501
2502static struct marimba_codec_platform_data timpani_codec_pdata = {
2503 .marimba_codec_power = msm_marimba_codec_power,
2504#ifdef CONFIG_TIMPANI_CODEC
2505 .snddev_profile_init = msm_snddev_init_timpani,
2506#endif
2507};
2508
2509static struct marimba_platform_data timpani_pdata = {
2510 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2511 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2512 .marimba_setup = msm_timpani_setup_power,
2513 .marimba_shutdown = msm_timpani_shutdown_power,
2514 .codec = &timpani_codec_pdata,
2515 .tsadc = &marimba_tsadc_pdata,
2516 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2517};
2518
2519#define TIMPANI_I2C_SLAVE_ADDR 0xD
2520
2521static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
2522 {
2523 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
2524 .platform_data = &timpani_pdata,
2525 },
2526};
2527
2528#ifdef CONFIG_MSM7KV2_AUDIO
2529static struct resource msm_aictl_resources[] = {
2530 {
2531 .name = "aictl",
2532 .start = 0xa5000100,
2533 .end = 0xa5000100,
2534 .flags = IORESOURCE_MEM,
2535 }
2536};
2537
2538static struct resource msm_mi2s_resources[] = {
2539 {
2540 .name = "hdmi",
2541 .start = 0xac900000,
2542 .end = 0xac900038,
2543 .flags = IORESOURCE_MEM,
2544 },
2545 {
2546 .name = "codec_rx",
2547 .start = 0xac940040,
2548 .end = 0xac940078,
2549 .flags = IORESOURCE_MEM,
2550 },
2551 {
2552 .name = "codec_tx",
2553 .start = 0xac980080,
2554 .end = 0xac9800B8,
2555 .flags = IORESOURCE_MEM,
2556 }
2557
2558};
2559
2560static struct msm_lpa_platform_data lpa_pdata = {
2561 .obuf_hlb_size = 0x2BFF8,
2562 .dsp_proc_id = 0,
2563 .app_proc_id = 2,
2564 .nosb_config = {
2565 .llb_min_addr = 0,
2566 .llb_max_addr = 0x3ff8,
2567 .sb_min_addr = 0,
2568 .sb_max_addr = 0,
2569 },
2570 .sb_config = {
2571 .llb_min_addr = 0,
2572 .llb_max_addr = 0x37f8,
2573 .sb_min_addr = 0x3800,
2574 .sb_max_addr = 0x3ff8,
2575 }
2576};
2577
2578static struct resource msm_lpa_resources[] = {
2579 {
2580 .name = "lpa",
2581 .start = 0xa5000000,
2582 .end = 0xa50000a0,
2583 .flags = IORESOURCE_MEM,
2584 }
2585};
2586
2587static struct resource msm_aux_pcm_resources[] = {
2588
2589 {
2590 .name = "aux_codec_reg_addr",
2591 .start = 0xac9c00c0,
2592 .end = 0xac9c00c8,
2593 .flags = IORESOURCE_MEM,
2594 },
2595 {
2596 .name = "aux_pcm_dout",
2597 .start = 138,
2598 .end = 138,
2599 .flags = IORESOURCE_IO,
2600 },
2601 {
2602 .name = "aux_pcm_din",
2603 .start = 139,
2604 .end = 139,
2605 .flags = IORESOURCE_IO,
2606 },
2607 {
2608 .name = "aux_pcm_syncout",
2609 .start = 140,
2610 .end = 140,
2611 .flags = IORESOURCE_IO,
2612 },
2613 {
2614 .name = "aux_pcm_clkin_a",
2615 .start = 141,
2616 .end = 141,
2617 .flags = IORESOURCE_IO,
2618 },
2619};
2620
2621static struct platform_device msm_aux_pcm_device = {
2622 .name = "msm_aux_pcm",
2623 .id = 0,
2624 .num_resources = ARRAY_SIZE(msm_aux_pcm_resources),
2625 .resource = msm_aux_pcm_resources,
2626};
2627
2628struct platform_device msm_aictl_device = {
2629 .name = "audio_interct",
2630 .id = 0,
2631 .num_resources = ARRAY_SIZE(msm_aictl_resources),
2632 .resource = msm_aictl_resources,
2633};
2634
2635struct platform_device msm_mi2s_device = {
2636 .name = "mi2s",
2637 .id = 0,
2638 .num_resources = ARRAY_SIZE(msm_mi2s_resources),
2639 .resource = msm_mi2s_resources,
2640};
2641
2642struct platform_device msm_lpa_device = {
2643 .name = "lpa",
2644 .id = 0,
2645 .num_resources = ARRAY_SIZE(msm_lpa_resources),
2646 .resource = msm_lpa_resources,
2647 .dev = {
2648 .platform_data = &lpa_pdata,
2649 },
2650};
2651#endif /* CONFIG_MSM7KV2_AUDIO */
2652
2653#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2654 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2655 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2656 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2657 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2658 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2659#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2660 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2661 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2662 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2663 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2664 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2665 #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2666 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2667 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2668 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2669 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2670 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2671 #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2672 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2673 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2674 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2675 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2676 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2677#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
2678
2679static unsigned int dec_concurrency_table[] = {
2680 /* Audio LP */
2681 0,
2682 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2683 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2684 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2685 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)|
2686 (1<<MSM_ADSP_OP_DM)),
2687
2688 /* Concurrency 1 */
2689 (DEC4_FORMAT),
2690 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2691 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2692 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2693 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2694
2695 /* Concurrency 2 */
2696 (DEC4_FORMAT),
2697 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2698 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2699 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2700 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2701
2702 /* Concurrency 3 */
2703 (DEC4_FORMAT),
2704 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2705 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2706 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2707 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2708
2709 /* Concurrency 4 */
2710 (DEC4_FORMAT),
2711 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2712 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2713 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2714 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2715
2716 /* Concurrency 5 */
2717 (DEC4_FORMAT),
2718 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2719 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2720 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2721 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2722
2723 /* Concurrency 6 */
2724 (DEC4_FORMAT),
2725 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2726 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2727 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2728 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2729};
2730
2731#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
2732 .module_queueid = queueid, .module_decid = decid, \
2733 .nr_codec_support = nr_codec}
2734
2735#define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
2736 .max_instances_same_dec = max_instance_same, \
2737 .max_instances_diff_dec = max_instance_diff}
2738
2739static struct msm_adspdec_info dec_info_list[] = {
2740 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
2741 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
2742 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
2743 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
2744 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
2745};
2746
2747static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
2748 /* Non Turbo Mode */
2749 {
2750 DEC_INSTANCE(4, 3), /* WAV */
2751 DEC_INSTANCE(4, 3), /* ADPCM */
2752 DEC_INSTANCE(4, 2), /* MP3 */
2753 DEC_INSTANCE(0, 0), /* Real Audio */
2754 DEC_INSTANCE(4, 2), /* WMA */
2755 DEC_INSTANCE(3, 2), /* AAC */
2756 DEC_INSTANCE(0, 0), /* Reserved */
2757 DEC_INSTANCE(0, 0), /* MIDI */
2758 DEC_INSTANCE(4, 3), /* YADPCM */
2759 DEC_INSTANCE(4, 3), /* QCELP */
2760 DEC_INSTANCE(4, 3), /* AMRNB */
2761 DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
2762 DEC_INSTANCE(4, 3), /* EVRC */
2763 DEC_INSTANCE(1, 1), /* WMAPRO */
2764 },
2765 /* Turbo Mode */
2766 {
2767 DEC_INSTANCE(4, 3), /* WAV */
2768 DEC_INSTANCE(4, 3), /* ADPCM */
2769 DEC_INSTANCE(4, 3), /* MP3 */
2770 DEC_INSTANCE(0, 0), /* Real Audio */
2771 DEC_INSTANCE(4, 3), /* WMA */
2772 DEC_INSTANCE(4, 3), /* AAC */
2773 DEC_INSTANCE(0, 0), /* Reserved */
2774 DEC_INSTANCE(0, 0), /* MIDI */
2775 DEC_INSTANCE(4, 3), /* YADPCM */
2776 DEC_INSTANCE(4, 3), /* QCELP */
2777 DEC_INSTANCE(4, 3), /* AMRNB */
2778 DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
2779 DEC_INSTANCE(4, 3), /* EVRC */
2780 DEC_INSTANCE(1, 2), /* WMAPRO */
2781 },
2782};
2783
2784static struct msm_adspdec_database msm_device_adspdec_database = {
2785 .num_dec = ARRAY_SIZE(dec_info_list),
2786 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
2787 ARRAY_SIZE(dec_info_list)),
2788 .dec_concurrency_table = dec_concurrency_table,
2789 .dec_info_list = dec_info_list,
2790 .dec_instance_list = &dec_instance_list[0][0],
2791};
2792
2793static struct platform_device msm_device_adspdec = {
2794 .name = "msm_adspdec",
2795 .id = -1,
2796 .dev = {
2797 .platform_data = &msm_device_adspdec_database
2798 },
2799};
2800
2801static struct resource smc91x_resources[] = {
2802 [0] = {
2803 .start = 0x8A000300,
2804 .end = 0x8A0003ff,
2805 .flags = IORESOURCE_MEM,
2806 },
2807 [1] = {
2808 .start = MSM_GPIO_TO_INT(156),
2809 .end = MSM_GPIO_TO_INT(156),
2810 .flags = IORESOURCE_IRQ,
2811 },
2812};
2813
2814static struct platform_device smc91x_device = {
2815 .name = "smc91x",
2816 .id = 0,
2817 .num_resources = ARRAY_SIZE(smc91x_resources),
2818 .resource = smc91x_resources,
2819};
2820
2821static struct smsc911x_platform_config smsc911x_config = {
2822 .phy_interface = PHY_INTERFACE_MODE_MII,
2823 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
2824 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
2825 .flags = SMSC911X_USE_32BIT,
2826};
2827
2828static struct resource smsc911x_resources[] = {
2829 [0] = {
2830 .start = 0x8D000000,
2831 .end = 0x8D000100,
2832 .flags = IORESOURCE_MEM,
2833 },
2834 [1] = {
2835 .start = MSM_GPIO_TO_INT(88),
2836 .end = MSM_GPIO_TO_INT(88),
2837 .flags = IORESOURCE_IRQ,
2838 },
2839};
2840
2841static struct platform_device smsc911x_device = {
2842 .name = "smsc911x",
2843 .id = -1,
2844 .num_resources = ARRAY_SIZE(smsc911x_resources),
2845 .resource = smsc911x_resources,
2846 .dev = {
2847 .platform_data = &smsc911x_config,
2848 },
2849};
2850
2851static struct msm_gpio smsc911x_gpios[] = {
2852 { GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" },
2853 { GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" },
2854 { GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" },
2855 { GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" },
2856 { GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" },
2857 { GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" },
2858 { GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" },
2859 { GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" },
2860};
2861
2862static void msm7x30_cfg_smsc911x(void)
2863{
2864 int rc;
2865
2866 rc = msm_gpios_request_enable(smsc911x_gpios,
2867 ARRAY_SIZE(smsc911x_gpios));
2868 if (rc)
2869 pr_err("%s: unable to enable gpios\n", __func__);
2870}
2871
2872#ifdef CONFIG_USB_G_ANDROID
2873static struct android_usb_platform_data android_usb_pdata = {
2874 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2875};
2876
2877static struct platform_device android_usb_device = {
2878 .name = "android_usb",
2879 .id = -1,
2880 .dev = {
2881 .platform_data = &android_usb_pdata,
2882 },
2883};
2884#endif
2885
2886static struct msm_gpio optnav_config_data[] = {
2887 { GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA),
2888 "optnav_chip_select" },
2889};
2890
Justin Paupore3f40f342011-08-10 18:52:16 -07002891static struct regulator_bulk_data optnav_regulators[] = {
2892 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2893 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
2894 { .supply = "gp9", .min_uV = 1800000, .max_uV = 1800000 },
2895 { .supply = "usb", .min_uV = 3300000, .max_uV = 3300000 },
2896};
2897
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002898static void __iomem *virtual_optnav;
2899
2900static int optnav_gpio_setup(void)
2901{
2902 int rc = -ENODEV;
2903 rc = msm_gpios_request_enable(optnav_config_data,
2904 ARRAY_SIZE(optnav_config_data));
2905
Justin Paupore3f40f342011-08-10 18:52:16 -07002906 if (rc)
2907 return rc;
2908
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002909 /* Configure the FPGA for GPIOs */
2910 virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4);
2911 if (!virtual_optnav) {
2912 pr_err("%s:Could not ioremap region\n", __func__);
2913 return -ENOMEM;
2914 }
2915 /*
2916 * Configure the FPGA to set GPIO 19 as
2917 * normal, active(enabled), output(MSM to SURF)
2918 */
2919 writew(0x311E, virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002920
2921 rc = regulator_bulk_get(NULL, ARRAY_SIZE(optnav_regulators),
2922 optnav_regulators);
2923 if (rc)
2924 return rc;
2925
2926 rc = regulator_bulk_set_voltage(ARRAY_SIZE(optnav_regulators),
2927 optnav_regulators);
2928
2929 if (rc)
2930 goto regulator_put;
2931
2932 return rc;
2933
2934regulator_put:
2935 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002936 return rc;
2937}
2938
2939static void optnav_gpio_release(void)
2940{
2941 msm_gpios_disable_free(optnav_config_data,
2942 ARRAY_SIZE(optnav_config_data));
2943 iounmap(virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002944 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002945}
2946
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002947static int optnav_enable(void)
2948{
2949 int rc;
2950 /*
2951 * Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
2952 * for I2C communication with keyboard.
2953 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002954
Justin Paupore3f40f342011-08-10 18:52:16 -07002955 rc = regulator_bulk_enable(ARRAY_SIZE(optnav_regulators),
2956 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002957
Justin Paupore3f40f342011-08-10 18:52:16 -07002958 if (rc)
2959 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002960
2961 /* Enable the chip select GPIO */
2962 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2963 gpio_set_value(OPTNAV_CHIP_SELECT, 0);
2964
2965 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002966}
2967
2968static void optnav_disable(void)
2969{
Justin Paupore3f40f342011-08-10 18:52:16 -07002970 regulator_bulk_disable(ARRAY_SIZE(optnav_regulators),
2971 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002972
2973 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2974}
2975
2976static struct ofn_atlab_platform_data optnav_data = {
2977 .gpio_setup = optnav_gpio_setup,
2978 .gpio_release = optnav_gpio_release,
2979 .optnav_on = optnav_enable,
2980 .optnav_off = optnav_disable,
2981 .rotate_xy = 0,
2982 .function1 = {
2983 .no_motion1_en = true,
2984 .touch_sensor_en = true,
2985 .ofn_en = true,
2986 .clock_select_khz = 1500,
2987 .cpi_selection = 1200,
2988 },
2989 .function2 = {
2990 .invert_y = false,
2991 .invert_x = true,
2992 .swap_x_y = false,
2993 .hold_a_b_en = true,
2994 .motion_filter_en = true,
2995 },
2996};
2997
2998static int hdmi_comm_power(int on, int show);
2999static int hdmi_init_irq(void);
3000static int hdmi_enable_5v(int on);
3001static int hdmi_core_power(int on, int show);
3002static int hdmi_cec_power(int on);
3003static bool hdmi_check_hdcp_hw_support(void);
3004
3005static struct msm_hdmi_platform_data adv7520_hdmi_data = {
3006 .irq = MSM_GPIO_TO_INT(18),
3007 .comm_power = hdmi_comm_power,
3008 .init_irq = hdmi_init_irq,
3009 .enable_5v = hdmi_enable_5v,
3010 .core_power = hdmi_core_power,
3011 .cec_power = hdmi_cec_power,
3012 .check_hdcp_hw_support = hdmi_check_hdcp_hw_support,
3013};
3014
3015#ifdef CONFIG_BOSCH_BMA150
Justin Paupore3f40f342011-08-10 18:52:16 -07003016
3017static struct regulator_bulk_data sensors_ldo[] = {
3018 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
3019 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
3020};
3021
3022static int __init sensors_ldo_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003023{
3024 int rc;
3025
Justin Paupore3f40f342011-08-10 18:52:16 -07003026 rc = regulator_bulk_get(NULL, ARRAY_SIZE(sensors_ldo), sensors_ldo);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003027
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003028 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003029 pr_err("%s: could not get regulators: %d\n", __func__, rc);
3030 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003031 }
3032
Justin Paupore3f40f342011-08-10 18:52:16 -07003033 rc = regulator_bulk_set_voltage(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3034
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003035 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003036 pr_err("%s: could not set voltages: %d\n", __func__, rc);
3037 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003038 }
3039
3040 return 0;
3041
Justin Paupore3f40f342011-08-10 18:52:16 -07003042reg_free:
3043 regulator_bulk_free(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3044out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003045 return rc;
3046}
3047
Justin Paupore3f40f342011-08-10 18:52:16 -07003048static int sensors_ldo_set(int on)
3049{
3050 int rc = on ?
3051 regulator_bulk_enable(ARRAY_SIZE(sensors_ldo), sensors_ldo) :
3052 regulator_bulk_disable(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3053
3054 if (rc)
3055 pr_err("%s: could not %sable regulators: %d\n",
3056 __func__, on ? "en" : "dis", rc);
3057
3058 return rc;
3059}
3060
3061static int sensors_ldo_enable(void)
3062{
3063 return sensors_ldo_set(1);
3064}
3065
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003066static void sensors_ldo_disable(void)
3067{
Justin Paupore3f40f342011-08-10 18:52:16 -07003068 sensors_ldo_set(0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003069}
Justin Paupore3f40f342011-08-10 18:52:16 -07003070
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003071static struct bma150_platform_data bma150_data = {
3072 .power_on = sensors_ldo_enable,
3073 .power_off = sensors_ldo_disable,
3074};
3075
3076static struct i2c_board_info bma150_board_info[] __initdata = {
3077 {
3078 I2C_BOARD_INFO("bma150", 0x38),
3079 .flags = I2C_CLIENT_WAKE,
3080 .irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
3081 .platform_data = &bma150_data,
3082 },
3083};
3084#endif
3085
3086static struct i2c_board_info msm_i2c_board_info[] = {
3087 {
3088 I2C_BOARD_INFO("m33c01", OPTNAV_I2C_SLAVE_ADDR),
3089 .irq = MSM_GPIO_TO_INT(OPTNAV_IRQ),
3090 .platform_data = &optnav_data,
3091 },
3092 {
3093 I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR),
3094 .platform_data = &adv7520_hdmi_data,
3095 },
3096};
3097
3098static struct i2c_board_info msm_marimba_board_info[] = {
3099 {
3100 I2C_BOARD_INFO("marimba", 0xc),
3101 .platform_data = &marimba_pdata,
3102 }
3103};
3104
3105
3106static struct msm_handset_platform_data hs_platform_data = {
3107 .hs_name = "7k_handset",
3108 .pwr_key_delay_ms = 500, /* 0 will disable end key */
3109};
3110
3111static struct platform_device hs_device = {
3112 .name = "msm-handset",
3113 .id = -1,
3114 .dev = {
3115 .platform_data = &hs_platform_data,
3116 },
3117};
3118
3119static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +05303120 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003121 .idle_supported = 1,
3122 .suspend_supported = 1,
3123 .idle_enabled = 1,
3124 .suspend_enabled = 1,
3125 .latency = 8594,
3126 .residency = 23740,
3127 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303128 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003129 .idle_supported = 1,
3130 .suspend_supported = 1,
3131 .idle_enabled = 1,
3132 .suspend_enabled = 1,
3133 .latency = 4594,
3134 .residency = 23740,
3135 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303136 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003137#ifdef CONFIG_MSM_STANDALONE_POWER_COLLAPSE
3138 .idle_supported = 1,
3139 .suspend_supported = 1,
3140 .idle_enabled = 1,
3141 .suspend_enabled = 0,
3142#else /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3143 .idle_supported = 0,
3144 .suspend_supported = 0,
3145 .idle_enabled = 0,
3146 .suspend_enabled = 0,
3147#endif /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3148 .latency = 500,
3149 .residency = 6000,
3150 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303151 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003152 .idle_supported = 1,
3153 .suspend_supported = 1,
3154 .idle_enabled = 0,
3155 .suspend_enabled = 1,
3156 .latency = 443,
3157 .residency = 1098,
3158 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303159 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003160 .idle_supported = 1,
3161 .suspend_supported = 1,
3162 .idle_enabled = 1,
3163 .suspend_enabled = 1,
3164 .latency = 2,
3165 .residency = 0,
3166 },
3167};
3168
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05303169u32 msm7x30_power_collapse_latency(enum msm_pm_sleep_mode mode)
3170{
3171 switch (mode) {
3172 case MSM_PM_SLEEP_MODE_POWER_COLLAPSE:
3173 return msm_pm_data
3174 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].latency;
3175 case MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN:
3176 return msm_pm_data
3177 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN].latency;
3178 case MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT:
3179 return msm_pm_data
3180 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
3181 case MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT:
3182 return msm_pm_data
3183 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT].latency;
3184 default:
3185 return 0;
3186 }
3187}
3188
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003189static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3190 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
3191 .v_addr = (uint32_t *)PAGE_OFFSET,
3192};
3193
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003194static struct resource qsd_spi_resources[] = {
3195 {
3196 .name = "spi_irq_in",
3197 .start = INT_SPI_INPUT,
3198 .end = INT_SPI_INPUT,
3199 .flags = IORESOURCE_IRQ,
3200 },
3201 {
3202 .name = "spi_irq_out",
3203 .start = INT_SPI_OUTPUT,
3204 .end = INT_SPI_OUTPUT,
3205 .flags = IORESOURCE_IRQ,
3206 },
3207 {
3208 .name = "spi_irq_err",
3209 .start = INT_SPI_ERROR,
3210 .end = INT_SPI_ERROR,
3211 .flags = IORESOURCE_IRQ,
3212 },
3213 {
3214 .name = "spi_base",
3215 .start = 0xA8000000,
3216 .end = 0xA8000000 + SZ_4K - 1,
3217 .flags = IORESOURCE_MEM,
3218 },
3219 {
3220 .name = "spidm_channels",
3221 .flags = IORESOURCE_DMA,
3222 },
3223 {
3224 .name = "spidm_crci",
3225 .flags = IORESOURCE_DMA,
3226 },
3227};
3228
3229#define AMDH0_BASE_PHYS 0xAC200000
3230#define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
3231static int msm_qsd_spi_dma_config(void)
3232{
3233 void __iomem *ct_adm_base = 0;
3234 u32 spi_mux = 0;
3235 int ret = 0;
3236
3237 ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
3238 if (!ct_adm_base) {
3239 pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
3240 return -ENOMEM;
3241 }
3242
3243 spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
3244
3245 qsd_spi_resources[4].start = DMOV_USB_CHAN;
3246 qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
3247
3248 switch (spi_mux) {
3249 case (1):
3250 qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
3251 qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
3252 break;
3253 case (2):
3254 qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
3255 qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
3256 break;
3257 case (3):
3258 qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
3259 qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
3260 break;
3261 default:
3262 ret = -ENOENT;
3263 }
3264
3265 iounmap(ct_adm_base);
3266
3267 return ret;
3268}
3269
3270static struct platform_device qsd_device_spi = {
3271 .name = "spi_qsd",
3272 .id = 0,
3273 .num_resources = ARRAY_SIZE(qsd_spi_resources),
3274 .resource = qsd_spi_resources,
3275};
3276
3277#ifdef CONFIG_SPI_QSD
3278static struct spi_board_info lcdc_sharp_spi_board_info[] __initdata = {
3279 {
3280 .modalias = "lcdc_sharp_ls038y7dx01",
3281 .mode = SPI_MODE_1,
3282 .bus_num = 0,
3283 .chip_select = 0,
3284 .max_speed_hz = 26331429,
3285 }
3286};
3287static struct spi_board_info lcdc_toshiba_spi_board_info[] __initdata = {
3288 {
3289 .modalias = "lcdc_toshiba_ltm030dd40",
3290 .mode = SPI_MODE_3|SPI_CS_HIGH,
3291 .bus_num = 0,
3292 .chip_select = 0,
3293 .max_speed_hz = 9963243,
3294 }
3295};
3296#endif
3297
3298static struct msm_gpio qsd_spi_gpio_config_data[] = {
3299 { GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3300 { GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3301 { GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" },
3302 { GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3303};
3304
3305static int msm_qsd_spi_gpio_config(void)
3306{
3307 return msm_gpios_request_enable(qsd_spi_gpio_config_data,
3308 ARRAY_SIZE(qsd_spi_gpio_config_data));
3309}
3310
3311static void msm_qsd_spi_gpio_release(void)
3312{
3313 msm_gpios_disable_free(qsd_spi_gpio_config_data,
3314 ARRAY_SIZE(qsd_spi_gpio_config_data));
3315}
3316
3317static struct msm_spi_platform_data qsd_spi_pdata = {
3318 .max_clock_speed = 26331429,
3319 .gpio_config = msm_qsd_spi_gpio_config,
3320 .gpio_release = msm_qsd_spi_gpio_release,
3321 .dma_config = msm_qsd_spi_dma_config,
3322};
3323
3324static void __init msm_qsd_spi_init(void)
3325{
3326 qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
3327}
3328
3329#ifdef CONFIG_USB_EHCI_MSM_72K
3330static void msm_hsusb_vbus_power(unsigned phy_info, int on)
3331{
3332 int rc;
3333 static int vbus_is_on;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303334 struct pm8xxx_gpio_init_info usb_vbus = {
3335 PM8058_GPIO_PM_TO_SYS(36),
3336 {
3337 .direction = PM_GPIO_DIR_OUT,
3338 .pull = PM_GPIO_PULL_NO,
3339 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3340 .output_value = 1,
3341 .vin_sel = 2,
3342 .out_strength = PM_GPIO_STRENGTH_MED,
3343 .function = PM_GPIO_FUNC_NORMAL,
3344 .inv_int_pol = 0,
3345 },
3346 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003347
3348 /* If VBUS is already on (or off), do nothing. */
3349 if (unlikely(on == vbus_is_on))
3350 return;
3351
3352 if (on) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303353 rc = pm8xxx_gpio_config(usb_vbus.gpio, &usb_vbus.config);
3354 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003355 pr_err("%s PMIC GPIO 36 write failed\n", __func__);
3356 return;
3357 }
3358 } else {
3359 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(36), 0);
3360 }
3361
3362 vbus_is_on = on;
3363}
3364
3365static struct msm_usb_host_platform_data msm_usb_host_pdata = {
3366 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
3367 .vbus_power = msm_hsusb_vbus_power,
3368 .power_budget = 180,
3369};
3370#endif
3371
3372#ifdef CONFIG_USB_MSM_OTG_72K
3373static int hsusb_rpc_connect(int connect)
3374{
3375 if (connect)
3376 return msm_hsusb_rpc_connect();
3377 else
3378 return msm_hsusb_rpc_close();
3379}
3380#endif
3381
3382#ifdef CONFIG_USB_MSM_OTG_72K
Justin Paupore3f40f342011-08-10 18:52:16 -07003383static struct regulator *vreg_3p3;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003384static int msm_hsusb_ldo_init(int init)
3385{
3386 uint32_t version = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07003387 int def_vol = 3400000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003388
3389 version = socinfo_get_version();
3390
3391 if (SOCINFO_VERSION_MAJOR(version) >= 2 &&
3392 SOCINFO_VERSION_MINOR(version) >= 1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003393 def_vol = 3075000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003394 pr_debug("%s: default voltage:%d\n", __func__, def_vol);
3395 }
3396
3397 if (init) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003398 vreg_3p3 = regulator_get(NULL, "usb");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003399 if (IS_ERR(vreg_3p3))
3400 return PTR_ERR(vreg_3p3);
Justin Paupore3f40f342011-08-10 18:52:16 -07003401 regulator_set_voltage(vreg_3p3, def_vol, def_vol);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003402 } else
Justin Paupore3f40f342011-08-10 18:52:16 -07003403 regulator_put(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003404
3405 return 0;
3406}
3407
3408static int msm_hsusb_ldo_enable(int enable)
3409{
3410 static int ldo_status;
3411
3412 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3413 return -ENODEV;
3414
3415 if (ldo_status == enable)
3416 return 0;
3417
3418 ldo_status = enable;
3419
3420 if (enable)
Justin Paupore3f40f342011-08-10 18:52:16 -07003421 return regulator_enable(vreg_3p3);
3422 else
3423 return regulator_disable(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003424}
3425
3426static int msm_hsusb_ldo_set_voltage(int mV)
3427{
Justin Paupore3f40f342011-08-10 18:52:16 -07003428 static int cur_voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003429
3430 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3431 return -ENODEV;
3432
3433 if (cur_voltage == mV)
3434 return 0;
3435
3436 cur_voltage = mV;
3437
3438 pr_debug("%s: (%d)\n", __func__, mV);
3439
Justin Paupore3f40f342011-08-10 18:52:16 -07003440 return regulator_set_voltage(vreg_3p3, mV*1000, mV*1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003441}
3442#endif
3443
3444#ifndef CONFIG_USB_EHCI_MSM_72K
3445static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init);
3446#endif
3447static struct msm_otg_platform_data msm_otg_pdata = {
3448 .rpc_connect = hsusb_rpc_connect,
3449
3450#ifndef CONFIG_USB_EHCI_MSM_72K
3451 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
3452#else
3453 .vbus_power = msm_hsusb_vbus_power,
3454#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003455 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
3456 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
3457 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
3458 .se1_gating = SE1_GATING_DISABLE,
3459 .chg_vbus_draw = hsusb_chg_vbus_draw,
3460 .chg_connected = hsusb_chg_connected,
3461 .chg_init = hsusb_chg_init,
3462 .ldo_enable = msm_hsusb_ldo_enable,
3463 .ldo_init = msm_hsusb_ldo_init,
3464 .ldo_set_voltage = msm_hsusb_ldo_set_voltage,
3465};
3466
3467#ifdef CONFIG_USB_GADGET
3468static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
3469 .is_phy_status_timer_on = 1,
3470};
3471#endif
3472#ifndef CONFIG_USB_EHCI_MSM_72K
3473typedef void (*notify_vbus_state) (int);
3474notify_vbus_state notify_vbus_state_func_ptr;
3475int vbus_on_irq;
3476static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
3477{
3478 pr_info("%s: vbus notification from pmic\n", __func__);
3479
3480 (*notify_vbus_state_func_ptr) (1);
3481
3482 return IRQ_HANDLED;
3483}
3484static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
3485{
3486 int ret;
3487
3488 if (init) {
3489 if (!callback)
3490 return -ENODEV;
3491
3492 notify_vbus_state_func_ptr = callback;
3493 vbus_on_irq = platform_get_irq_byname(&msm_device_otg,
3494 "vbus_on");
3495 if (vbus_on_irq <= 0) {
3496 pr_err("%s: unable to get vbus on irq\n", __func__);
3497 return -ENODEV;
3498 }
3499
3500 ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq,
3501 IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
3502 if (ret < 0) {
3503 pr_info("%s: request_irq for vbus_on"
3504 "interrupt failed\n", __func__);
3505 return ret;
3506 }
3507 msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
3508 return 0;
3509 } else {
3510 free_irq(vbus_on_irq, 0);
3511 notify_vbus_state_func_ptr = NULL;
3512 return 0;
3513 }
3514}
3515#endif
3516
3517static struct android_pmem_platform_data android_pmem_pdata = {
3518 .name = "pmem",
3519 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
3520 .cached = 1,
3521 .memory_type = MEMTYPE_EBI0,
3522};
3523
3524static struct platform_device android_pmem_device = {
3525 .name = "android_pmem",
3526 .id = 0,
3527 .dev = { .platform_data = &android_pmem_pdata },
3528};
3529
3530#ifndef CONFIG_SPI_QSD
3531static int lcdc_gpio_array_num[] = {
3532 45, /* spi_clk */
3533 46, /* spi_cs */
3534 47, /* spi_mosi */
3535 48, /* spi_miso */
3536 };
3537
3538static struct msm_gpio lcdc_gpio_config_data[] = {
3539 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3540 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3541 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
3542 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3543};
3544
3545static void lcdc_config_gpios(int enable)
3546{
3547 if (enable) {
3548 msm_gpios_request_enable(lcdc_gpio_config_data,
3549 ARRAY_SIZE(
3550 lcdc_gpio_config_data));
3551 } else
3552 msm_gpios_disable_free(lcdc_gpio_config_data,
3553 ARRAY_SIZE(
3554 lcdc_gpio_config_data));
3555}
3556#endif
3557
3558static struct msm_panel_common_pdata lcdc_sharp_panel_data = {
3559#ifndef CONFIG_SPI_QSD
3560 .panel_config_gpio = lcdc_config_gpios,
3561 .gpio_num = lcdc_gpio_array_num,
3562#endif
3563 .gpio = 2, /* LPG PMIC_GPIO26 channel number */
3564};
3565
3566static struct platform_device lcdc_sharp_panel_device = {
3567 .name = "lcdc_sharp_wvga",
3568 .id = 0,
3569 .dev = {
3570 .platform_data = &lcdc_sharp_panel_data,
3571 }
3572};
3573
3574static struct msm_gpio dtv_panel_irq_gpios[] = {
3575 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
3576 "hdmi_int" },
3577};
3578
3579static struct msm_gpio dtv_panel_gpios[] = {
3580 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
3581 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
3582 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
3583 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
3584 { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
3585 { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
3586 { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
3587 { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
3588 { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
3589 { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
3590 { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
3591 { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
3592 { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
3593 { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
3594 { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
3595 { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
3596 { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
3597 { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
3598 { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
3599 { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
3600 { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
3601 { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
3602 { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
3603 { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
3604 { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
3605 { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
3606 { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
3607 { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
3608 { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
3609 { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
3610 { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
3611 { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
3612};
3613
3614
3615#ifdef HDMI_RESET
3616static unsigned dtv_reset_gpio =
3617 GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3618#endif
3619
Justin Paupore3f40f342011-08-10 18:52:16 -07003620static struct regulator_bulk_data hdmi_core_regs[] = {
3621 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3622};
3623
3624static struct regulator_bulk_data hdmi_comm_regs[] = {
3625 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3626 { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 },
3627};
3628
3629static struct regulator_bulk_data hdmi_cec_regs[] = {
3630 { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 },
3631};
3632
3633static int __init hdmi_init_regs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003634{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003635 int rc;
3636
Justin Paupore3f40f342011-08-10 18:52:16 -07003637 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs),
3638 hdmi_core_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003639
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003640 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003641 pr_err("%s: could not get %s regulators: %d\n",
3642 __func__, "core", rc);
3643 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003644 }
3645
Justin Paupore3f40f342011-08-10 18:52:16 -07003646 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs),
3647 hdmi_core_regs);
3648
3649 if (rc) {
3650 pr_err("%s: could not set %s voltages: %d\n",
3651 __func__, "core", rc);
3652 goto free_core;
3653 }
3654
3655 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs),
3656 hdmi_comm_regs);
3657
3658 if (rc) {
3659 pr_err("%s: could not get %s regulators: %d\n",
3660 __func__, "comm", rc);
3661 goto free_core;
3662 }
3663
3664 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs),
3665 hdmi_comm_regs);
3666
3667 if (rc) {
3668 pr_err("%s: could not set %s voltages: %d\n",
3669 __func__, "comm", rc);
3670 goto free_comm;
3671 }
3672
3673 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs),
3674 hdmi_cec_regs);
3675
3676 if (rc) {
3677 pr_err("%s: could not get %s regulators: %d\n",
3678 __func__, "cec", rc);
3679 goto free_comm;
3680 }
3681
3682 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs),
3683 hdmi_cec_regs);
3684
3685 if (rc) {
3686 pr_err("%s: could not set %s voltages: %d\n",
3687 __func__, "cec", rc);
3688 goto free_cec;
3689 }
3690
3691 return 0;
3692
3693free_cec:
3694 regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs);
3695free_comm:
3696 regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs);
3697free_core:
3698 regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs);
3699out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003700 return rc;
3701}
3702
Justin Paupore3f40f342011-08-10 18:52:16 -07003703static int hdmi_init_irq(void)
3704{
3705 int rc = msm_gpios_enable(dtv_panel_irq_gpios,
3706 ARRAY_SIZE(dtv_panel_irq_gpios));
3707 if (rc < 0) {
3708 pr_err("%s: gpio enable failed: %d\n", __func__, rc);
3709 return rc;
3710 }
3711 pr_info("%s\n", __func__);
3712
3713 return 0;
3714}
3715
3716static int hdmi_enable_5v(int on)
3717{
3718 int pmic_gpio_hdmi_5v_en ;
3719
3720 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
3721 machine_is_msm7x30_fluid())
3722 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
3723 else
3724 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
3725
3726 pr_info("%s: %d\n", __func__, on);
3727 if (on) {
3728 int rc;
3729 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
3730 "hdmi_5V_en");
3731 if (rc) {
3732 pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
3733 __func__);
3734 return rc;
3735 }
3736 gpio_set_value_cansleep(
3737 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
3738 } else {
3739 gpio_set_value_cansleep(
3740 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
3741 gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
3742 }
3743 return 0;
3744}
3745
3746static int hdmi_comm_power(int on, int show)
3747{
3748 if (show)
3749 pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
3750 return on ?
3751 regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs),
3752 hdmi_comm_regs) :
3753 regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs),
3754 hdmi_comm_regs);
3755}
3756
3757static int hdmi_core_power(int on, int show)
3758{
3759 if (show)
3760 pr_info("%s: %d <LDO8>\n", __func__, on);
3761 return on ?
3762 regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs),
3763 hdmi_core_regs) :
3764 regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs),
3765 hdmi_core_regs);
3766}
3767
3768static int hdmi_cec_power(int on)
3769{
3770 pr_info("%s: %d <LDO17>\n", __func__, on);
3771 return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs),
3772 hdmi_cec_regs) :
3773 regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs),
3774 hdmi_cec_regs);
3775}
3776
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003777#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
3778/* there is an i2c address conflict between adv7520 and bma150 sensor after
3779 * power up on fluid. As a solution, the default address of adv7520's packet
3780 * memory is changed as soon as possible
3781 */
3782static int __init fluid_i2c_address_fixup(void)
3783{
3784 unsigned char wBuff[16];
3785 unsigned char rBuff[16];
3786 struct i2c_msg msgs[3];
3787 int res;
3788 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003789 struct i2c_adapter *adapter;
3790
3791 if (machine_is_msm7x30_fluid()) {
3792 adapter = i2c_get_adapter(0);
3793 if (!adapter) {
3794 pr_err("%s: invalid i2c adapter\n", __func__);
3795 return PTR_ERR(adapter);
3796 }
3797
3798 /* turn on LDO8 */
Justin Paupore3f40f342011-08-10 18:52:16 -07003799 rc = hdmi_core_power(1, 0);
3800 if (rc) {
3801 pr_err("%s: could not enable hdmi core regs: %d",
3802 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003803 goto adapter_put;
3804 }
3805
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003806 /* change packet memory address to 0x74 */
3807 wBuff[0] = 0x45;
3808 wBuff[1] = 0x74;
3809
3810 msgs[0].addr = ADV7520_I2C_ADDR;
3811 msgs[0].flags = 0;
3812 msgs[0].buf = (unsigned char *) wBuff;
3813 msgs[0].len = 2;
3814
3815 res = i2c_transfer(adapter, msgs, 1);
3816 if (res != 1) {
3817 pr_err("%s: error writing adv7520\n", __func__);
3818 goto ldo8_disable;
3819 }
3820
3821 /* powerdown adv7520 using bit 6 */
3822 /* i2c read first */
3823 wBuff[0] = 0x41;
3824
3825 msgs[0].addr = ADV7520_I2C_ADDR;
3826 msgs[0].flags = 0;
3827 msgs[0].buf = (unsigned char *) wBuff;
3828 msgs[0].len = 1;
3829
3830 msgs[1].addr = ADV7520_I2C_ADDR;
3831 msgs[1].flags = I2C_M_RD;
3832 msgs[1].buf = rBuff;
3833 msgs[1].len = 1;
3834 res = i2c_transfer(adapter, msgs, 2);
3835 if (res != 2) {
3836 pr_err("%s: error reading adv7520\n", __func__);
3837 goto ldo8_disable;
3838 }
3839
3840 /* i2c write back */
3841 wBuff[0] = 0x41;
3842 wBuff[1] = rBuff[0] | 0x40;
3843
3844 msgs[0].addr = ADV7520_I2C_ADDR;
3845 msgs[0].flags = 0;
3846 msgs[0].buf = (unsigned char *) wBuff;
3847 msgs[0].len = 2;
3848
3849 res = i2c_transfer(adapter, msgs, 1);
3850 if (res != 1) {
3851 pr_err("%s: error writing adv7520\n", __func__);
3852 goto ldo8_disable;
3853 }
3854
3855 /* for successful fixup, we release the i2c adapter */
3856 /* but leave ldo8 on so that the adv7520 is not repowered */
3857 i2c_put_adapter(adapter);
3858 pr_info("%s: fluid i2c address conflict resolved\n", __func__);
3859 }
3860 return 0;
3861
3862ldo8_disable:
Justin Paupore3f40f342011-08-10 18:52:16 -07003863 hdmi_core_power(0, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003864adapter_put:
3865 i2c_put_adapter(adapter);
3866 return rc;
3867}
3868fs_initcall_sync(fluid_i2c_address_fixup);
3869#endif
3870
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003871static bool hdmi_check_hdcp_hw_support(void)
3872{
3873 if (machine_is_msm7x30_fluid())
3874 return false;
3875 else
3876 return true;
3877}
3878
3879static int dtv_panel_power(int on)
3880{
3881 int flag_on = !!on;
3882 static int dtv_power_save_on;
3883 int rc;
3884
3885 if (dtv_power_save_on == flag_on)
3886 return 0;
3887
3888 dtv_power_save_on = flag_on;
3889 pr_info("%s: %d\n", __func__, on);
3890
3891#ifdef HDMI_RESET
3892 if (on) {
3893 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
3894 rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
3895 if (rc) {
3896 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
3897 __func__, dtv_reset_gpio, rc);
3898 return rc;
3899 }
3900
3901 /* bring reset line low to hold reset*/
3902 gpio_set_value(37, 0);
3903 }
3904#endif
3905
3906 if (on) {
3907 rc = msm_gpios_enable(dtv_panel_gpios,
3908 ARRAY_SIZE(dtv_panel_gpios));
3909 if (rc < 0) {
3910 printk(KERN_ERR "%s: gpio enable failed: %d\n",
3911 __func__, rc);
3912 return rc;
3913 }
3914 } else {
3915 rc = msm_gpios_disable(dtv_panel_gpios,
3916 ARRAY_SIZE(dtv_panel_gpios));
3917 if (rc < 0) {
3918 printk(KERN_ERR "%s: gpio disable failed: %d\n",
3919 __func__, rc);
3920 return rc;
3921 }
3922 }
3923
3924 mdelay(5); /* ensure power is stable */
3925
3926#ifdef HDMI_RESET
3927 if (on) {
3928 gpio_set_value(37, 1); /* bring reset line high */
3929 mdelay(10); /* 10 msec before IO can be accessed */
3930 }
3931#endif
3932
3933 return rc;
3934}
3935
3936static struct lcdc_platform_data dtv_pdata = {
3937 .lcdc_power_save = dtv_panel_power,
3938};
3939
3940static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3941 .inject_rx_on_wakeup = 1,
3942 .rx_to_inject = 0xFD,
3943};
3944
3945static struct resource msm_fb_resources[] = {
3946 {
3947 .flags = IORESOURCE_DMA,
3948 }
3949};
3950
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08003951#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
3952static struct resource msm_v4l2_video_overlay_resources[] = {
3953 {
3954 .flags = IORESOURCE_DMA,
3955 }
3956};
3957#endif
3958
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003959static int msm_fb_detect_panel(const char *name)
3960{
3961 if (machine_is_msm7x30_fluid()) {
3962 if (!strcmp(name, "lcdc_sharp_wvga_pt"))
3963 return 0;
3964 } else {
3965 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
3966 return -EPERM;
3967 else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20))
3968 return 0;
3969 else if (!strcmp(name, "mddi_orise"))
3970 return -EPERM;
3971 else if (!strcmp(name, "mddi_quickvx"))
3972 return -EPERM;
3973 }
3974 return -ENODEV;
3975}
3976
3977static struct msm_fb_platform_data msm_fb_pdata = {
3978 .detect_client = msm_fb_detect_panel,
3979 .mddi_prescan = 1,
3980};
3981
3982static struct platform_device msm_fb_device = {
3983 .name = "msm_fb",
3984 .id = 0,
3985 .num_resources = ARRAY_SIZE(msm_fb_resources),
3986 .resource = msm_fb_resources,
3987 .dev = {
3988 .platform_data = &msm_fb_pdata,
3989 }
3990};
3991
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08003992#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
3993
3994static struct platform_device msm_v4l2_video_overlay_device = {
3995 .name = "msm_v4l2_overlay_pd",
3996 .id = 0,
3997 .num_resources = ARRAY_SIZE(msm_v4l2_video_overlay_resources),
3998 .resource = msm_v4l2_video_overlay_resources,
3999};
4000#endif
4001
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004002static struct platform_device msm_migrate_pages_device = {
4003 .name = "msm_migrate_pages",
4004 .id = -1,
4005};
4006
4007static struct android_pmem_platform_data android_pmem_adsp_pdata = {
4008 .name = "pmem_adsp",
4009 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4010 .cached = 0,
4011 .memory_type = MEMTYPE_EBI0,
4012};
4013
4014static struct android_pmem_platform_data android_pmem_audio_pdata = {
4015 .name = "pmem_audio",
4016 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4017 .cached = 0,
4018 .memory_type = MEMTYPE_EBI0,
4019};
4020
4021static struct platform_device android_pmem_adsp_device = {
4022 .name = "android_pmem",
4023 .id = 2,
4024 .dev = { .platform_data = &android_pmem_adsp_pdata },
4025};
4026
4027static struct platform_device android_pmem_audio_device = {
4028 .name = "android_pmem",
4029 .id = 4,
4030 .dev = { .platform_data = &android_pmem_audio_pdata },
4031};
4032
4033#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4034 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
4035 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4036 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4037
4038#define QCE_SIZE 0x10000
4039#define QCE_0_BASE 0xA8400000
4040
4041#define QCE_HW_KEY_SUPPORT 1
4042#define QCE_SHA_HMAC_SUPPORT 0
4043#define QCE_SHARE_CE_RESOURCE 0
4044#define QCE_CE_SHARED 0
4045
4046static struct resource qcrypto_resources[] = {
4047 [0] = {
4048 .start = QCE_0_BASE,
4049 .end = QCE_0_BASE + QCE_SIZE - 1,
4050 .flags = IORESOURCE_MEM,
4051 },
4052 [1] = {
4053 .name = "crypto_channels",
4054 .start = DMOV_CE_IN_CHAN,
4055 .end = DMOV_CE_OUT_CHAN,
4056 .flags = IORESOURCE_DMA,
4057 },
4058 [2] = {
4059 .name = "crypto_crci_in",
4060 .start = DMOV_CE_IN_CRCI,
4061 .end = DMOV_CE_IN_CRCI,
4062 .flags = IORESOURCE_DMA,
4063 },
4064 [3] = {
4065 .name = "crypto_crci_out",
4066 .start = DMOV_CE_OUT_CRCI,
4067 .end = DMOV_CE_OUT_CRCI,
4068 .flags = IORESOURCE_DMA,
4069 },
4070 [4] = {
4071 .name = "crypto_crci_hash",
4072 .start = DMOV_CE_HASH_CRCI,
4073 .end = DMOV_CE_HASH_CRCI,
4074 .flags = IORESOURCE_DMA,
4075 },
4076};
4077
4078static struct resource qcedev_resources[] = {
4079 [0] = {
4080 .start = QCE_0_BASE,
4081 .end = QCE_0_BASE + QCE_SIZE - 1,
4082 .flags = IORESOURCE_MEM,
4083 },
4084 [1] = {
4085 .name = "crypto_channels",
4086 .start = DMOV_CE_IN_CHAN,
4087 .end = DMOV_CE_OUT_CHAN,
4088 .flags = IORESOURCE_DMA,
4089 },
4090 [2] = {
4091 .name = "crypto_crci_in",
4092 .start = DMOV_CE_IN_CRCI,
4093 .end = DMOV_CE_IN_CRCI,
4094 .flags = IORESOURCE_DMA,
4095 },
4096 [3] = {
4097 .name = "crypto_crci_out",
4098 .start = DMOV_CE_OUT_CRCI,
4099 .end = DMOV_CE_OUT_CRCI,
4100 .flags = IORESOURCE_DMA,
4101 },
4102 [4] = {
4103 .name = "crypto_crci_hash",
4104 .start = DMOV_CE_HASH_CRCI,
4105 .end = DMOV_CE_HASH_CRCI,
4106 .flags = IORESOURCE_DMA,
4107 },
4108};
4109
4110#endif
4111
4112#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4113 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
4114
4115static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
4116 .ce_shared = QCE_CE_SHARED,
4117 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4118 .hw_key_support = QCE_HW_KEY_SUPPORT,
4119 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004120 /* Bus Scaling declaration*/
4121 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004122};
4123
4124static struct platform_device qcrypto_device = {
4125 .name = "qcrypto",
4126 .id = 0,
4127 .num_resources = ARRAY_SIZE(qcrypto_resources),
4128 .resource = qcrypto_resources,
4129 .dev = {
4130 .coherent_dma_mask = DMA_BIT_MASK(32),
4131 .platform_data = &qcrypto_ce_hw_suppport,
4132 },
4133};
4134#endif
4135
4136#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4137 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4138
4139static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
4140 .ce_shared = QCE_CE_SHARED,
4141 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4142 .hw_key_support = QCE_HW_KEY_SUPPORT,
4143 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004144 /* Bus Scaling declaration*/
4145 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004146};
4147static struct platform_device qcedev_device = {
4148 .name = "qce",
4149 .id = 0,
4150 .num_resources = ARRAY_SIZE(qcedev_resources),
4151 .resource = qcedev_resources,
4152 .dev = {
4153 .coherent_dma_mask = DMA_BIT_MASK(32),
4154 .platform_data = &qcedev_ce_hw_suppport,
4155 },
4156};
4157#endif
4158
4159static int mddi_toshiba_pmic_bl(int level)
4160{
4161 int ret = -EPERM;
4162
4163 ret = pmic_set_led_intensity(LED_LCD, level);
4164
4165 if (ret)
4166 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
4167 __func__);
4168 return ret;
4169}
4170
4171static struct msm_panel_common_pdata mddi_toshiba_pdata = {
4172 .pmic_backlight = mddi_toshiba_pmic_bl,
4173};
4174
4175static struct platform_device mddi_toshiba_device = {
4176 .name = "mddi_toshiba",
4177 .id = 0,
4178 .dev = {
4179 .platform_data = &mddi_toshiba_pdata,
4180 }
4181};
4182
4183static unsigned wega_reset_gpio =
4184 GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4185
4186static struct msm_gpio fluid_vee_reset_gpio[] = {
4187 { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
4188};
4189
4190static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1;
4191static unsigned char quickvx_ldo_enabled;
4192
4193static unsigned quickvx_vlp_gpio =
4194 GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4195
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304196static struct pm8xxx_gpio_init_info pmic_quickvx_clk_gpio = {
4197 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_QUICKVX_CLK),
4198 {
4199 .direction = PM_GPIO_DIR_OUT,
4200 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
4201 .output_value = 1,
4202 .pull = PM_GPIO_PULL_NO,
4203 .vin_sel = PM8058_GPIO_VIN_S3,
4204 .out_strength = PM_GPIO_STRENGTH_HIGH,
4205 .function = PM_GPIO_FUNC_2,
4206 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004207};
4208
Justin Paupore3f40f342011-08-10 18:52:16 -07004209static struct regulator *mddi_ldo20;
4210static struct regulator *mddi_ldo12;
4211static struct regulator *mddi_ldo16;
4212static struct regulator *mddi_ldo6;
4213static struct regulator *mddi_lcd;
4214
4215static int display_common_init(void)
4216{
4217 struct regulator_bulk_data regs[5] = {
4218 { .supply = "ldo20", /* voltage set in display_common_power */},
4219 { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 },
4220 { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 },
4221 { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 },
4222 { .supply = NULL, /* mddi_lcd, initialized below */ },
4223 };
4224
4225 int rc = 0;
4226
4227 if (machine_is_msm7x30_fluid()) {
4228 /* lcd: LDO8 @1.8V */
4229 regs[4].supply = "ldo8";
4230 regs[4].min_uV = 1800000;
4231 regs[4].max_uV = 1800000;
4232 } else {
4233 /* lcd: LDO15 @3.1V */
4234 regs[4].supply = "ldo15";
4235 regs[4].min_uV = 3100000;
4236 regs[4].max_uV = 3100000;
4237 }
4238
4239 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4240 if (rc) {
4241 pr_err("%s: regulator_bulk_get failed: %d\n",
4242 __func__, rc);
4243 goto bail;
4244 }
4245
4246 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4247 if (rc) {
4248 pr_err("%s: regulator_bulk_set_voltage failed: %d\n",
4249 __func__, rc);
4250 goto put_regs;
4251 }
4252
4253 mddi_ldo20 = regs[0].consumer;
4254 mddi_ldo12 = regs[1].consumer;
4255 mddi_ldo6 = regs[2].consumer;
4256 mddi_ldo16 = regs[3].consumer;
4257 mddi_lcd = regs[4].consumer;
4258
4259 return rc;
4260
4261put_regs:
4262 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4263bail:
4264 return rc;
4265}
4266
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004267static int display_common_power(int on)
4268{
4269 int rc = 0, flag_on = !!on;
4270 static int display_common_power_save_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004271 static bool display_regs_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004272
4273 if (display_common_power_save_on == flag_on)
4274 return 0;
4275
4276 display_common_power_save_on = flag_on;
4277
Justin Paupore3f40f342011-08-10 18:52:16 -07004278 if (unlikely(!display_regs_initialized)) {
4279 rc = display_common_init();
4280 if (rc) {
4281 pr_err("%s: regulator init failed: %d\n",
4282 __func__, rc);
4283 return rc;
4284 }
4285 display_regs_initialized = true;
4286 }
4287
4288
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004289 if (on) {
4290 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
4291 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
4292 if (rc) {
4293 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4294 __func__, wega_reset_gpio, rc);
4295 return rc;
4296 }
4297
4298 /* bring reset line low to hold reset*/
4299 gpio_set_value(180, 0);
4300
4301 if (quickvx_mddi_client) {
4302 /* QuickVX chip -- VLP pin -- gpio 97 */
4303 rc = gpio_tlmm_config(quickvx_vlp_gpio,
4304 GPIO_CFG_ENABLE);
4305 if (rc) {
4306 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4307 __func__, quickvx_vlp_gpio, rc);
4308 return rc;
4309 }
4310
4311 /* bring QuickVX VLP line low */
4312 gpio_set_value(97, 0);
4313
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304314 rc = pm8xxx_gpio_config(pmic_quickvx_clk_gpio.gpio,
4315 &pmic_quickvx_clk_gpio.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004316 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304317 pr_err("%s: pm8xxx_gpio_config(%#x)=%d\n",
4318 __func__, pmic_quickvx_clk_gpio.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004319 rc);
4320 return rc;
4321 }
4322
4323 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4324 PMIC_GPIO_QUICKVX_CLK), 0);
4325 }
4326 }
4327
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004328 if (quickvx_mddi_client)
Justin Paupore3f40f342011-08-10 18:52:16 -07004329 rc = regulator_set_voltage(mddi_ldo20, 1800000, 1800000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004330 else
Justin Paupore3f40f342011-08-10 18:52:16 -07004331 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000);
4332
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004333 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004334 pr_err("%s: could not set voltage for ldo20: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004335 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07004336 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004337 }
4338
4339 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004340 rc = regulator_enable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004341 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004342 pr_err("%s: LDO20 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004343 __func__, rc);
4344 return rc;
4345 }
4346
Justin Paupore3f40f342011-08-10 18:52:16 -07004347 rc = regulator_enable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004348 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004349 pr_err("%s: LDO12 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004350 __func__, rc);
4351 return rc;
4352 }
4353
4354 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004355 rc = regulator_enable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004356 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004357 pr_err("%s: LDO16 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004358 __func__, rc);
4359 return rc;
4360 }
4361 }
4362
Justin Paupore3f40f342011-08-10 18:52:16 -07004363 if (quickvx_ldo_enabled) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004364 /* Disable LDO6 during display ON */
Justin Paupore3f40f342011-08-10 18:52:16 -07004365 rc = regulator_disable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004366 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004367 pr_err("%s: LDO6 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004368 __func__, rc);
4369 return rc;
4370 }
4371 quickvx_ldo_enabled = 0;
4372 }
4373
Justin Paupore3f40f342011-08-10 18:52:16 -07004374 rc = regulator_enable(mddi_lcd);
4375 if (rc) {
4376 pr_err("%s: LCD regulator enable failed (%d)\n",
4377 __func__, rc);
4378 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004379 }
4380
4381 mdelay(5); /* ensure power is stable */
4382
4383 if (machine_is_msm7x30_fluid()) {
4384 rc = msm_gpios_request_enable(fluid_vee_reset_gpio,
4385 ARRAY_SIZE(fluid_vee_reset_gpio));
4386 if (rc)
4387 pr_err("%s gpio_request_enable failed rc=%d\n",
4388 __func__, rc);
4389 else {
4390 /* assert vee reset_n */
4391 gpio_set_value(20, 1);
4392 gpio_set_value(20, 0);
4393 mdelay(1);
4394 gpio_set_value(20, 1);
4395 }
4396 }
4397
4398 gpio_set_value(180, 1); /* bring reset line high */
4399 mdelay(10); /* 10 msec before IO can be accessed */
4400
4401 if (quickvx_mddi_client) {
4402 gpio_set_value(97, 1);
4403 msleep(2);
4404 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4405 PMIC_GPIO_QUICKVX_CLK), 1);
4406 msleep(2);
4407 }
4408
4409 rc = pmapp_display_clock_config(1);
4410 if (rc) {
4411 pr_err("%s pmapp_display_clock_config rc=%d\n",
4412 __func__, rc);
4413 return rc;
4414 }
4415
4416 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004417 rc = regulator_disable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004418 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004419 pr_err("%s: LDO20 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004420 __func__, rc);
4421 return rc;
4422 }
4423
4424
4425 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004426 rc = regulator_disable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004427 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004428 pr_err("%s: LDO16 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004429 __func__, rc);
4430 return rc;
4431 }
4432 }
4433
4434 if (quickvx_mddi_client && !quickvx_ldo_enabled) {
4435 /* Enable LDO6 during display OFF for
4436 Quicklogic chip to sleep with data retention */
Justin Paupore3f40f342011-08-10 18:52:16 -07004437 rc = regulator_enable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004438 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004439 pr_err("%s: LDO6 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004440 __func__, rc);
4441 return rc;
4442 }
4443 quickvx_ldo_enabled = 1;
4444 }
4445
4446 gpio_set_value(180, 0); /* bring reset line low */
4447
4448 if (quickvx_mddi_client) {
4449 gpio_set_value(97, 0);
4450 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4451 PMIC_GPIO_QUICKVX_CLK), 0);
4452 }
4453
Justin Paupore3f40f342011-08-10 18:52:16 -07004454 rc = regulator_disable(mddi_lcd);
4455 if (rc) {
4456 pr_err("%s: LCD regulator disable failed (%d)\n",
4457 __func__, rc);
4458 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004459 }
4460
4461 mdelay(5); /* ensure power is stable */
4462
Justin Paupore3f40f342011-08-10 18:52:16 -07004463 rc = regulator_disable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004464 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004465 pr_err("%s: LDO12 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004466 __func__, rc);
4467 return rc;
4468 }
4469
4470 if (machine_is_msm7x30_fluid()) {
4471 msm_gpios_disable_free(fluid_vee_reset_gpio,
4472 ARRAY_SIZE(fluid_vee_reset_gpio));
4473 }
4474
4475 rc = pmapp_display_clock_config(0);
4476 if (rc) {
4477 pr_err("%s pmapp_display_clock_config rc=%d\n",
4478 __func__, rc);
4479 return rc;
4480 }
4481 }
4482
4483 return rc;
4484}
4485
4486static int msm_fb_mddi_sel_clk(u32 *clk_rate)
4487{
4488 *clk_rate *= 2;
4489 return 0;
4490}
4491
4492static int msm_fb_mddi_client_power(u32 client_id)
4493{
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304494 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004495 printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
4496 /* Check if it is Quicklogic client */
4497 if (client_id == 0xc5835800) {
4498 printk(KERN_NOTICE "\n Quicklogic MDDI client");
4499 other_mddi_client = 0;
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304500 if (IS_ERR(mddi_ldo16)) {
4501 rc = PTR_ERR(mddi_ldo16);
4502 pr_err("%s: gp10 vreg get failed (%d)\n", __func__, rc);
4503 return rc;
4504 }
4505 rc = regulator_disable(mddi_ldo16);
4506 if (rc) {
4507 pr_err("%s: LDO16 vreg enable failed (%d)\n",
4508 __func__, rc);
4509 return rc;
4510 }
4511
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004512 } else {
4513 printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
4514 quickvx_mddi_client = 0;
4515 gpio_set_value(97, 0);
4516 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4517 PMIC_GPIO_QUICKVX_CLK), 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004518 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004519
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004520 return 0;
4521}
4522
4523static struct mddi_platform_data mddi_pdata = {
4524 .mddi_power_save = display_common_power,
4525 .mddi_sel_clk = msm_fb_mddi_sel_clk,
4526 .mddi_client_power = msm_fb_mddi_client_power,
4527};
4528
4529int mdp_core_clk_rate_table[] = {
4530 122880000,
4531 122880000,
Pradeep Jilagam3cc12f92011-07-26 22:25:18 +05304532 192000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004533 192000000,
4534};
4535
4536static struct msm_panel_common_pdata mdp_pdata = {
4537 .hw_revision_addr = 0xac001270,
4538 .gpio = 30,
4539 .mdp_core_clk_rate = 122880000,
4540 .mdp_core_clk_table = mdp_core_clk_rate_table,
4541 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07004542 .mdp_rev = MDP_REV_40,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004543};
4544
4545static int lcd_panel_spi_gpio_num[] = {
4546 45, /* spi_clk */
4547 46, /* spi_cs */
4548 47, /* spi_mosi */
4549 48, /* spi_miso */
4550 };
4551
4552static struct msm_gpio lcd_panel_gpios[] = {
4553/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
4554 * input. if there is a hardware revision; we should reassign this GPIO to a
4555 * new open line; and removing it will just ensure that this will be missed in
4556 * the future.
4557 { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
4558 */
4559 { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
4560 { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
4561 { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
4562 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4563 { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
4564 { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
4565 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4566#ifndef CONFIG_SPI_QSD
4567 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
4568 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
4569 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
4570 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
4571#endif
4572 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4573 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4574 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4575 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4576 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4577 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4578 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4579 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4580 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4581 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4582 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4583 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4584 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4585 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4586 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4587 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4588 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4589 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4590 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4591 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4592};
4593
4594static struct msm_gpio lcd_sharp_panel_gpios[] = {
4595 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4596 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4597 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4598 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4599 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4600 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4601 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4602 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4603 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4604 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4605 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4606 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4607 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4608 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4609 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4610 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4611 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4612 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4613 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4614 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4615 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4616 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4617};
4618
4619static int lcdc_toshiba_panel_power(int on)
4620{
4621 int rc, i;
4622 struct msm_gpio *gp;
4623
4624 rc = display_common_power(on);
4625 if (rc < 0) {
4626 printk(KERN_ERR "%s display_common_power failed: %d\n",
4627 __func__, rc);
4628 return rc;
4629 }
4630
4631 if (on) {
4632 rc = msm_gpios_enable(lcd_panel_gpios,
4633 ARRAY_SIZE(lcd_panel_gpios));
4634 if (rc < 0) {
4635 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4636 __func__, rc);
4637 }
4638 } else { /* off */
4639 gp = lcd_panel_gpios;
4640 for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
4641 /* ouput low */
4642 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4643 gp++;
4644 }
4645 }
4646
4647 return rc;
4648}
4649
4650static int lcdc_sharp_panel_power(int on)
4651{
4652 int rc, i;
4653 struct msm_gpio *gp;
4654
4655 rc = display_common_power(on);
4656 if (rc < 0) {
4657 printk(KERN_ERR "%s display_common_power failed: %d\n",
4658 __func__, rc);
4659 return rc;
4660 }
4661
4662 if (on) {
4663 rc = msm_gpios_enable(lcd_sharp_panel_gpios,
4664 ARRAY_SIZE(lcd_sharp_panel_gpios));
4665 if (rc < 0) {
4666 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4667 __func__, rc);
4668 }
4669 } else { /* off */
4670 gp = lcd_sharp_panel_gpios;
4671 for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) {
4672 /* ouput low */
4673 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4674 gp++;
4675 }
4676 }
4677
4678 return rc;
4679}
4680
4681static int lcdc_panel_power(int on)
4682{
4683 int flag_on = !!on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004684 static int lcdc_power_save_on, lcdc_power_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004685
4686 if (lcdc_power_save_on == flag_on)
4687 return 0;
4688
4689 lcdc_power_save_on = flag_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004690
4691 if (unlikely(!lcdc_power_initialized)) {
4692 quickvx_mddi_client = 0;
4693 display_common_init();
4694 lcdc_power_initialized = 1;
4695 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004696
4697 if (machine_is_msm7x30_fluid())
4698 return lcdc_sharp_panel_power(on);
4699 else
4700 return lcdc_toshiba_panel_power(on);
4701}
4702
4703static struct lcdc_platform_data lcdc_pdata = {
4704 .lcdc_power_save = lcdc_panel_power,
4705};
4706
Justin Paupore3f40f342011-08-10 18:52:16 -07004707static struct regulator *atv_s4, *atv_ldo9;
4708
4709static int __init atv_dac_power_init(void)
4710{
4711 int rc;
4712 struct regulator_bulk_data regs[] = {
4713 { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 },
4714 { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 },
4715 };
4716
4717 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4718
4719 if (rc) {
4720 pr_err("%s: could not get regulators: %d\n", __func__, rc);
4721 goto bail;
4722 }
4723
4724 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4725
4726 if (rc) {
4727 pr_err("%s: could not set voltages: %d\n", __func__, rc);
4728 goto reg_free;
4729 }
4730
4731 atv_s4 = regs[0].consumer;
4732 atv_ldo9 = regs[1].consumer;
4733
4734reg_free:
4735 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4736bail:
4737 return rc;
4738}
4739
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004740static int atv_dac_power(int on)
4741{
4742 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004743
4744 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004745 rc = regulator_enable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004746 if (rc) {
4747 pr_err("%s: s4 vreg enable failed (%d)\n",
4748 __func__, rc);
4749 return rc;
4750 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004751 rc = regulator_enable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004752 if (rc) {
4753 pr_err("%s: ldo9 vreg enable failed (%d)\n",
4754 __func__, rc);
4755 return rc;
4756 }
4757 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004758 rc = regulator_disable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004759 if (rc) {
4760 pr_err("%s: ldo9 vreg disable failed (%d)\n",
4761 __func__, rc);
4762 return rc;
4763 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004764 rc = regulator_disable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004765 if (rc) {
4766 pr_err("%s: s4 vreg disable failed (%d)\n",
4767 __func__, rc);
4768 return rc;
4769 }
4770 }
4771 return rc;
4772}
4773
4774static struct tvenc_platform_data atv_pdata = {
4775 .poll = 1,
4776 .pm_vid_en = atv_dac_power,
4777};
4778
4779static void __init msm_fb_add_devices(void)
4780{
4781 msm_fb_register_device("mdp", &mdp_pdata);
4782 msm_fb_register_device("pmdh", &mddi_pdata);
4783 msm_fb_register_device("lcdc", &lcdc_pdata);
4784 msm_fb_register_device("dtv", &dtv_pdata);
4785 msm_fb_register_device("tvenc", &atv_pdata);
4786#ifdef CONFIG_FB_MSM_TVOUT
4787 msm_fb_register_device("tvout_device", NULL);
4788#endif
4789}
4790
4791static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
4792 .gpio_num = lcd_panel_spi_gpio_num,
4793};
4794
4795static struct platform_device lcdc_toshiba_panel_device = {
4796 .name = "lcdc_toshiba_wvga",
4797 .id = 0,
4798 .dev = {
4799 .platform_data = &lcdc_toshiba_panel_data,
4800 }
4801};
4802
4803#if defined(CONFIG_MARIMBA_CORE) && \
4804 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4805static struct platform_device msm_bt_power_device = {
4806 .name = "bt_power",
4807 .id = -1
4808};
4809
4810enum {
4811 BT_RFR,
4812 BT_CTS,
4813 BT_RX,
4814 BT_TX,
4815};
4816
4817static struct msm_gpio bt_config_power_on[] = {
4818 { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4819 "UART1DM_RFR" },
4820 { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4821 "UART1DM_CTS" },
4822 { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4823 "UART1DM_Rx" },
4824 { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4825 "UART1DM_Tx" }
4826};
4827
4828static struct msm_gpio bt_config_power_off[] = {
4829 { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4830 "UART1DM_RFR" },
4831 { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4832 "UART1DM_CTS" },
4833 { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4834 "UART1DM_Rx" },
4835 { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4836 "UART1DM_Tx" }
4837};
4838
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004839static u8 bahama_version;
4840
Justin Paupore3f40f342011-08-10 18:52:16 -07004841static struct regulator_bulk_data regs_bt_marimba[] = {
4842 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4843 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
4844 { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304845 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004846};
4847
4848static struct regulator_bulk_data regs_bt_bahama_v1[] = {
4849 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4850 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
4851 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304852 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004853};
4854
4855static struct regulator_bulk_data regs_bt_bahama_v2[] = {
4856 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4857 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304858 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004859};
4860
4861static struct regulator_bulk_data *regs_bt;
4862static int regs_bt_count;
4863
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004864static int marimba_bt(int on)
4865{
4866 int rc;
4867 int i;
4868 struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
4869
4870 struct marimba_config_register {
4871 u8 reg;
4872 u8 value;
4873 u8 mask;
4874 };
4875
4876 struct marimba_variant_register {
4877 const size_t size;
4878 const struct marimba_config_register *set;
4879 };
4880
4881 const struct marimba_config_register *p;
4882
4883 u8 version;
4884
4885 const struct marimba_config_register v10_bt_on[] = {
4886 { 0xE5, 0x0B, 0x0F },
4887 { 0x05, 0x02, 0x07 },
4888 { 0x06, 0x88, 0xFF },
4889 { 0xE7, 0x21, 0x21 },
4890 { 0xE3, 0x38, 0xFF },
4891 { 0xE4, 0x06, 0xFF },
4892 };
4893
4894 const struct marimba_config_register v10_bt_off[] = {
4895 { 0xE5, 0x0B, 0x0F },
4896 { 0x05, 0x08, 0x0F },
4897 { 0x06, 0x88, 0xFF },
4898 { 0xE7, 0x00, 0x21 },
4899 { 0xE3, 0x00, 0xFF },
4900 { 0xE4, 0x00, 0xFF },
4901 };
4902
4903 const struct marimba_config_register v201_bt_on[] = {
4904 { 0x05, 0x08, 0x07 },
4905 { 0x06, 0x88, 0xFF },
4906 { 0xE7, 0x21, 0x21 },
4907 { 0xE3, 0x38, 0xFF },
4908 { 0xE4, 0x06, 0xFF },
4909 };
4910
4911 const struct marimba_config_register v201_bt_off[] = {
4912 { 0x05, 0x08, 0x07 },
4913 { 0x06, 0x88, 0xFF },
4914 { 0xE7, 0x00, 0x21 },
4915 { 0xE3, 0x00, 0xFF },
4916 { 0xE4, 0x00, 0xFF },
4917 };
4918
4919 const struct marimba_config_register v210_bt_on[] = {
4920 { 0xE9, 0x01, 0x01 },
4921 { 0x06, 0x88, 0xFF },
4922 { 0xE7, 0x21, 0x21 },
4923 { 0xE3, 0x38, 0xFF },
4924 { 0xE4, 0x06, 0xFF },
4925 };
4926
4927 const struct marimba_config_register v210_bt_off[] = {
4928 { 0x06, 0x88, 0xFF },
4929 { 0xE7, 0x00, 0x21 },
4930 { 0xE9, 0x00, 0x01 },
4931 { 0xE3, 0x00, 0xFF },
4932 { 0xE4, 0x00, 0xFF },
4933 };
4934
4935 const struct marimba_variant_register bt_marimba[2][4] = {
4936 {
4937 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4938 { 0, NULL },
4939 { ARRAY_SIZE(v201_bt_off), v201_bt_off },
4940 { ARRAY_SIZE(v210_bt_off), v210_bt_off }
4941 },
4942 {
4943 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4944 { 0, NULL },
4945 { ARRAY_SIZE(v201_bt_on), v201_bt_on },
4946 { ARRAY_SIZE(v210_bt_on), v210_bt_on }
4947 }
4948 };
4949
4950 on = on ? 1 : 0;
4951
4952 rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F);
4953 if (rc < 0) {
4954 printk(KERN_ERR
4955 "%s: version read failed: %d\n",
4956 __func__, rc);
4957 return rc;
4958 }
4959
4960 if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
4961 (bt_marimba[on][version].size == 0)) {
4962 printk(KERN_ERR
4963 "%s: unsupported version\n",
4964 __func__);
4965 return -EIO;
4966 }
4967
4968 p = bt_marimba[on][version].set;
4969
4970 printk(KERN_INFO "%s: found version %d\n", __func__, version);
4971
4972 for (i = 0; i < bt_marimba[on][version].size; i++) {
4973 u8 value = (p+i)->value;
4974 rc = marimba_write_bit_mask(&config,
4975 (p+i)->reg,
4976 &value,
4977 sizeof((p+i)->value),
4978 (p+i)->mask);
4979 if (rc < 0) {
4980 printk(KERN_ERR
4981 "%s: reg %d write failed: %d\n",
4982 __func__, (p+i)->reg, rc);
4983 return rc;
4984 }
4985 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
4986 __func__, (p+i)->reg,
4987 value, (p+i)->mask);
4988 }
4989 return 0;
4990}
4991
4992static int bahama_bt(int on)
4993{
4994 int rc;
4995 int i;
4996 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
4997
4998 struct bahama_variant_register {
4999 const size_t size;
5000 const struct bahama_config_register *set;
5001 };
5002
5003 const struct bahama_config_register *p;
5004
5005
5006 const struct bahama_config_register v10_bt_on[] = {
5007 { 0xE9, 0x00, 0xFF },
5008 { 0xF4, 0x80, 0xFF },
5009 { 0xF0, 0x06, 0xFF },
5010 { 0xE4, 0x00, 0xFF },
5011 { 0xE5, 0x00, 0x0F },
5012#ifdef CONFIG_WLAN
5013 { 0xE6, 0x38, 0x7F },
5014 { 0xE7, 0x06, 0xFF },
5015#endif
5016 { 0x11, 0x13, 0xFF },
5017 { 0xE9, 0x21, 0xFF },
5018 { 0x01, 0x0C, 0x1F },
5019 { 0x01, 0x08, 0x1F },
5020 };
5021
5022 const struct bahama_config_register v20_bt_on_fm_off[] = {
5023 { 0x11, 0x0C, 0xFF },
5024 { 0x13, 0x01, 0xFF },
5025 { 0xF4, 0x80, 0xFF },
5026 { 0xF0, 0x00, 0xFF },
5027 { 0xE9, 0x00, 0xFF },
5028#ifdef CONFIG_WLAN
5029 { 0x81, 0x00, 0xFF },
5030 { 0x82, 0x00, 0xFF },
5031 { 0xE6, 0x38, 0x7F },
5032 { 0xE7, 0x06, 0xFF },
5033#endif
5034 { 0xE9, 0x21, 0xFF }
5035 };
5036
5037 const struct bahama_config_register v20_bt_on_fm_on[] = {
5038 { 0x11, 0x0C, 0xFF },
5039 { 0x13, 0x01, 0xFF },
5040 { 0xF4, 0x86, 0xFF },
5041 { 0xF0, 0x06, 0xFF },
5042 { 0xE9, 0x00, 0xFF },
5043#ifdef CONFIG_WLAN
5044 { 0x81, 0x00, 0xFF },
5045 { 0x82, 0x00, 0xFF },
5046 { 0xE6, 0x38, 0x7F },
5047 { 0xE7, 0x06, 0xFF },
5048#endif
5049 { 0xE9, 0x21, 0xFF }
5050 };
5051
5052 const struct bahama_config_register v10_bt_off[] = {
5053 { 0xE9, 0x00, 0xFF },
5054 };
5055
5056 const struct bahama_config_register v20_bt_off_fm_off[] = {
5057 { 0xF4, 0x84, 0xFF },
5058 { 0xF0, 0x04, 0xFF },
5059 { 0xE9, 0x00, 0xFF }
5060 };
5061
5062 const struct bahama_config_register v20_bt_off_fm_on[] = {
5063 { 0xF4, 0x86, 0xFF },
5064 { 0xF0, 0x06, 0xFF },
5065 { 0xE9, 0x00, 0xFF }
5066 };
5067
5068 const struct bahama_variant_register bt_bahama[2][3] = {
5069 {
5070 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
5071 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
5072 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
5073 },
5074 {
5075 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
5076 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
5077 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
5078 }
5079 };
5080
5081 u8 offset = 0; /* index into bahama configs */
5082
5083 on = on ? 1 : 0;
5084
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005085
5086 if (bahama_version == VER_2_0) {
5087 if (marimba_get_fm_status(&config))
5088 offset = 0x01;
5089 }
5090
5091 p = bt_bahama[on][bahama_version + offset].set;
5092
5093 dev_info(&msm_bt_power_device.dev,
5094 "%s: found version %d\n", __func__, bahama_version);
5095
5096 for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
5097 u8 value = (p+i)->value;
5098 rc = marimba_write_bit_mask(&config,
5099 (p+i)->reg,
5100 &value,
5101 sizeof((p+i)->value),
5102 (p+i)->mask);
5103 if (rc < 0) {
5104 dev_err(&msm_bt_power_device.dev,
5105 "%s: reg %d write failed: %d\n",
5106 __func__, (p+i)->reg, rc);
5107 return rc;
5108 }
5109 dev_info(&msm_bt_power_device.dev,
5110 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
5111 __func__, (p+i)->reg,
5112 value, (p+i)->mask);
5113 }
5114 /* Update BT status */
5115 if (on)
5116 marimba_set_bt_status(&config, true);
5117 else
5118 marimba_set_bt_status(&config, false);
5119
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005120 return 0;
5121}
5122
Justin Paupore3f40f342011-08-10 18:52:16 -07005123static int bluetooth_regs_init(int bahama_not_marimba)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005124{
Justin Paupore3f40f342011-08-10 18:52:16 -07005125 int rc = 0;
5126 struct device *const dev = &msm_bt_power_device.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005127
5128 if (bahama_not_marimba) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005129 bahama_version = read_bahama_ver();
5130
5131 switch (bahama_version) {
5132 case VER_1_0:
5133 regs_bt = regs_bt_bahama_v1;
5134 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1);
5135 break;
5136 case VER_2_0:
5137 regs_bt = regs_bt_bahama_v2;
5138 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2);
5139 break;
5140 case VER_UNSUPPORTED:
5141 default:
5142 dev_err(dev,
5143 "%s: i2c failure or unsupported version: %d\n",
5144 __func__, bahama_version);
5145 rc = -EIO;
5146 goto out;
5147 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005148 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07005149 regs_bt = regs_bt_marimba;
5150 regs_bt_count = ARRAY_SIZE(regs_bt_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005151 }
5152
Justin Paupore3f40f342011-08-10 18:52:16 -07005153 rc = regulator_bulk_get(&msm_bt_power_device.dev,
5154 regs_bt_count, regs_bt);
5155 if (rc) {
5156 dev_err(dev, "%s: could not get regulators: %d\n",
5157 __func__, rc);
5158 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005159 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005160
5161 rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt);
5162 if (rc) {
5163 dev_err(dev, "%s: could not set voltages: %d\n",
5164 __func__, rc);
5165 goto reg_free;
5166 }
5167
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005168 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005169
5170reg_free:
5171 regulator_bulk_free(regs_bt_count, regs_bt);
5172out:
5173 regs_bt_count = 0;
5174 regs_bt = NULL;
5175 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005176}
5177
5178static int bluetooth_power(int on)
5179{
5180 int rc;
5181 const char *id = "BTPW";
5182
5183 int bahama_not_marimba = bahama_present();
5184
5185 if (bahama_not_marimba == -1) {
5186 printk(KERN_WARNING "%s: bahama_present: %d\n",
5187 __func__, bahama_not_marimba);
5188 return -ENODEV;
5189 }
5190
Justin Paupore3f40f342011-08-10 18:52:16 -07005191 if (unlikely(regs_bt_count == 0)) {
5192 rc = bluetooth_regs_init(bahama_not_marimba);
5193 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005194 return rc;
Justin Paupore3f40f342011-08-10 18:52:16 -07005195 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005196
Justin Paupore3f40f342011-08-10 18:52:16 -07005197 if (on) {
5198 rc = regulator_bulk_enable(regs_bt_count, regs_bt);
5199 if (rc)
5200 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005201
5202 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5203 PMAPP_CLOCK_VOTE_ON);
5204 if (rc < 0)
5205 return -EIO;
5206
5207 if (machine_is_msm8x55_svlte_surf() ||
5208 machine_is_msm8x55_svlte_ffa()) {
5209 rc = marimba_gpio_config(1);
5210 if (rc < 0)
5211 return -EIO;
5212 }
5213
5214 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5215 if (rc < 0)
5216 return -EIO;
5217
5218 msleep(10);
5219
5220 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5221 PMAPP_CLOCK_VOTE_PIN_CTRL);
5222 if (rc < 0)
5223 return -EIO;
5224
5225 if (machine_is_msm8x55_svlte_surf() ||
5226 machine_is_msm8x55_svlte_ffa()) {
5227 rc = marimba_gpio_config(0);
5228 if (rc < 0)
5229 return -EIO;
5230 }
5231
5232 rc = msm_gpios_enable(bt_config_power_on,
5233 ARRAY_SIZE(bt_config_power_on));
5234
5235 if (rc < 0)
5236 return rc;
5237
5238 } else {
5239 rc = msm_gpios_enable(bt_config_power_off,
5240 ARRAY_SIZE(bt_config_power_off));
5241 if (rc < 0)
5242 return rc;
5243
5244 /* check for initial RFKILL block (power off) */
5245 if (platform_get_drvdata(&msm_bt_power_device) == NULL)
5246 goto out;
5247
5248 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5249 if (rc < 0)
5250 return -EIO;
5251
5252 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5253 PMAPP_CLOCK_VOTE_OFF);
5254 if (rc < 0)
5255 return -EIO;
5256
Justin Paupore3f40f342011-08-10 18:52:16 -07005257 rc = regulator_bulk_disable(regs_bt_count, regs_bt);
5258 if (rc)
5259 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005260
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005261 }
5262
5263out:
5264 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
5265
5266 return 0;
5267}
5268
5269static void __init bt_power_init(void)
5270{
Justin Paupore3f40f342011-08-10 18:52:16 -07005271 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005272}
5273#else
5274#define bt_power_init(x) do {} while (0)
5275#endif
5276
5277static struct msm_psy_batt_pdata msm_psy_batt_data = {
5278 .voltage_min_design = 2800,
5279 .voltage_max_design = 4300,
5280 .avail_chg_sources = AC_CHG | USB_CHG ,
5281 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
5282};
5283
5284static struct platform_device msm_batt_device = {
5285 .name = "msm-battery",
5286 .id = -1,
5287 .dev.platform_data = &msm_psy_batt_data,
5288};
5289
5290static char *msm_adc_fluid_device_names[] = {
5291 "LTC_ADC1",
5292 "LTC_ADC2",
5293 "LTC_ADC3",
5294};
5295
5296static char *msm_adc_surf_device_names[] = {
5297 "XO_ADC",
5298};
5299
5300static struct msm_adc_platform_data msm_adc_pdata;
5301
5302static struct platform_device msm_adc_device = {
5303 .name = "msm_adc",
5304 .id = -1,
5305 .dev = {
5306 .platform_data = &msm_adc_pdata,
5307 },
5308};
5309
5310#ifdef CONFIG_MSM_SDIO_AL
5311static struct msm_gpio mdm2ap_status = {
5312 GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5313 "mdm2ap_status"
5314};
5315
5316
5317static int configure_mdm2ap_status(int on)
5318{
5319 if (on)
5320 return msm_gpios_request_enable(&mdm2ap_status, 1);
5321 else {
5322 msm_gpios_disable_free(&mdm2ap_status, 1);
5323 return 0;
5324 }
5325}
5326
5327static int get_mdm2ap_status(void)
5328{
5329 return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
5330}
5331
5332static struct sdio_al_platform_data sdio_al_pdata = {
5333 .config_mdm2ap_status = configure_mdm2ap_status,
5334 .get_mdm2ap_status = get_mdm2ap_status,
5335 .allow_sdioc_version_major_2 = 1,
5336 .peer_sdioc_version_minor = 0x0001,
5337 .peer_sdioc_version_major = 0x0003,
5338 .peer_sdioc_boot_version_minor = 0x0001,
5339 .peer_sdioc_boot_version_major = 0x0003,
5340};
5341
5342struct platform_device msm_device_sdio_al = {
5343 .name = "msm_sdio_al",
5344 .id = -1,
5345 .dev = {
5346 .platform_data = &sdio_al_pdata,
5347 },
5348};
5349
5350#endif /* CONFIG_MSM_SDIO_AL */
5351
Daniel Walker8d747cd2010-02-25 11:37:43 -08005352static struct platform_device *devices[] __initdata = {
Daniel Walker90e37c52010-05-12 14:24:15 -07005353#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005354 &msm_device_uart2,
5355#endif
Justin Paupore637a25d2011-07-14 17:11:04 -07005356#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
5357 &msm_proccomm_regulator_dev,
5358#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005359 &asoc_msm_pcm,
5360 &asoc_msm_dai0,
5361 &asoc_msm_dai1,
5362#if defined (CONFIG_SND_MSM_MVS_DAI_SOC)
5363 &asoc_msm_mvs,
5364 &asoc_mvs_dai0,
5365 &asoc_mvs_dai1,
Daniel Walker90e37c52010-05-12 14:24:15 -07005366#endif
Niranjana Vishwanathapuraa8855e92010-10-06 13:52:10 -07005367 &msm_device_smd,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005368 &msm_device_dmov,
5369 &smc91x_device,
5370 &smsc911x_device,
5371 &msm_device_nand,
5372#ifdef CONFIG_USB_MSM_OTG_72K
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05305373 &msm_device_otg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005374#ifdef CONFIG_USB_GADGET
5375 &msm_device_gadget_peripheral,
5376#endif
5377#endif
5378#ifdef CONFIG_USB_G_ANDROID
5379 &android_usb_device,
5380#endif
5381 &qsd_device_spi,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305382
5383#ifdef CONFIG_MSM_SSBI
5384 &msm_device_ssbi_pmic1,
5385#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005386#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005387 &msm_device_ssbi7,
5388#endif
5389 &android_pmem_device,
5390 &msm_fb_device,
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08005391#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
5392 &msm_v4l2_video_overlay_device,
5393#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005394 &msm_migrate_pages_device,
5395 &mddi_toshiba_device,
5396 &lcdc_toshiba_panel_device,
5397#ifdef CONFIG_MSM_ROTATOR
5398 &msm_rotator_device,
5399#endif
5400 &lcdc_sharp_panel_device,
5401 &android_pmem_adsp_device,
5402 &android_pmem_audio_device,
5403 &msm_device_i2c,
5404 &msm_device_i2c_2,
5405 &msm_device_uart_dm1,
5406 &hs_device,
5407#ifdef CONFIG_MSM7KV2_AUDIO
5408 &msm_aictl_device,
5409 &msm_mi2s_device,
5410 &msm_lpa_device,
5411 &msm_aux_pcm_device,
5412#endif
5413 &msm_device_adspdec,
5414 &qup_device_i2c,
5415#if defined(CONFIG_MARIMBA_CORE) && \
5416 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5417 &msm_bt_power_device,
5418#endif
5419 &msm_kgsl_3d0,
5420 &msm_kgsl_2d0,
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005421#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005422#ifdef CONFIG_MT9T013
5423 &msm_camera_sensor_mt9t013,
5424#endif
5425#ifdef CONFIG_MT9D112
5426 &msm_camera_sensor_mt9d112,
5427#endif
5428#ifdef CONFIG_WEBCAM_OV9726
5429 &msm_camera_sensor_ov9726,
5430#endif
5431#ifdef CONFIG_S5K3E2FX
5432 &msm_camera_sensor_s5k3e2fx,
5433#endif
5434#ifdef CONFIG_MT9P012
5435 &msm_camera_sensor_mt9p012,
5436#endif
5437#ifdef CONFIG_MT9E013
5438 &msm_camera_sensor_mt9e013,
5439#endif
5440#ifdef CONFIG_VX6953
5441 &msm_camera_sensor_vx6953,
5442#endif
5443#ifdef CONFIG_SN12M0PZ
5444 &msm_camera_sensor_sn12m0pz,
5445#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005446#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005447 &msm_device_vidc_720p,
5448#ifdef CONFIG_MSM_GEMINI
5449 &msm_gemini_device,
5450#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005451#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005452#ifdef CONFIG_MSM_VPE
5453 &msm_vpe_device,
5454#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005455#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005456#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5457 &msm_device_tsif,
5458#endif
5459#ifdef CONFIG_MSM_SDIO_AL
5460 &msm_device_sdio_al,
5461#endif
5462
5463#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5464 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5465 &qcrypto_device,
5466#endif
5467
5468#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5469 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5470 &qcedev_device,
5471#endif
5472
5473 &msm_batt_device,
5474 &msm_adc_device,
5475 &msm_ebi0_thermal,
Laxminath Kasam1d8255d2012-02-15 13:10:19 +05305476 &msm_ebi1_thermal,
5477 &msm_adsp_device
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005478};
5479
5480static struct msm_gpio msm_i2c_gpios_hw[] = {
5481 { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5482 { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5483};
5484
5485static struct msm_gpio msm_i2c_gpios_io[] = {
5486 { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5487 { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5488};
5489
5490static struct msm_gpio qup_i2c_gpios_io[] = {
5491 { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5492 { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5493};
5494static struct msm_gpio qup_i2c_gpios_hw[] = {
5495 { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5496 { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5497};
5498
5499static void
5500msm_i2c_gpio_config(int adap_id, int config_type)
5501{
5502 struct msm_gpio *msm_i2c_table;
5503
5504 /* Each adapter gets 2 lines from the table */
5505 if (adap_id > 0)
5506 return;
5507 if (config_type)
5508 msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
5509 else
5510 msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
5511 msm_gpios_enable(msm_i2c_table, 2);
5512}
5513/*This needs to be enabled only for OEMS*/
5514#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005515static struct regulator *qup_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005516#endif
5517static void
5518qup_i2c_gpio_config(int adap_id, int config_type)
5519{
5520 int rc = 0;
5521 struct msm_gpio *qup_i2c_table;
5522 /* Each adapter gets 2 lines from the table */
5523 if (adap_id != 4)
5524 return;
5525 if (config_type)
5526 qup_i2c_table = qup_i2c_gpios_hw;
5527 else
5528 qup_i2c_table = qup_i2c_gpios_io;
5529 rc = msm_gpios_enable(qup_i2c_table, 2);
5530 if (rc < 0)
5531 printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
5532 /*This needs to be enabled only for OEMS*/
5533#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005534 if (!IS_ERR_OR_NULL(qup_vreg)) {
5535 rc = regulator_enable(qup_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005536 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005537 pr_err("%s: regulator_enable failed: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005538 __func__, rc);
5539 }
5540 }
5541#endif
5542}
5543
5544static struct msm_i2c_platform_data msm_i2c_pdata = {
5545 .clk_freq = 100000,
5546 .pri_clk = 70,
5547 .pri_dat = 71,
5548 .rmutex = 1,
5549 .rsl_id = "D:I2C02000021",
5550 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5551};
5552
5553static void __init msm_device_i2c_init(void)
5554{
5555 if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
5556 pr_err("failed to request I2C gpios\n");
5557
5558 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
5559}
5560
5561static struct msm_i2c_platform_data msm_i2c_2_pdata = {
5562 .clk_freq = 100000,
5563 .rmutex = 1,
5564 .rsl_id = "D:I2C02000022",
5565 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5566};
5567
5568static void __init msm_device_i2c_2_init(void)
5569{
5570 msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
5571}
5572
5573static struct msm_i2c_platform_data qup_i2c_pdata = {
5574 .clk_freq = 384000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005575 .msm_i2c_config_gpio = qup_i2c_gpio_config,
5576};
5577
5578static void __init qup_device_i2c_init(void)
5579{
5580 if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
5581 pr_err("failed to request I2C gpios\n");
5582
5583 qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
5584 /*This needs to be enabled only for OEMS*/
5585#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005586 qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005587 if (IS_ERR(qup_vreg)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005588 dev_err(&qup_device_i2c.dev,
5589 "%s: regulator_get failed: %ld\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005590 __func__, PTR_ERR(qup_vreg));
5591 }
5592#endif
5593}
5594
5595#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005596static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = {
5597 .rsl_id = "D:CODEC_SSBI",
5598 .controller_type = MSM_SBI_CTRL_SSBI,
5599};
5600#endif
5601
Daniel Walker8d747cd2010-02-25 11:37:43 -08005602static void __init msm7x30_init_irq(void)
5603{
5604 msm_init_irq();
5605}
5606
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005607static struct msm_gpio msm_nand_ebi2_cfg_data[] = {
5608 {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
5609 {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
5610};
5611
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005612#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
5613 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
5614 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
5615 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
5616
5617struct sdcc_gpio {
5618 struct msm_gpio *cfg_data;
5619 uint32_t size;
5620 struct msm_gpio *sleep_cfg_data;
5621};
5622#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5623static struct msm_gpio sdc1_lvlshft_cfg_data[] = {
5624 {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
5625};
5626#endif
5627static struct msm_gpio sdc1_cfg_data[] = {
5628 {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
5629 {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
5630 {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
5631 {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
5632 {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
5633 {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
5634};
5635
5636static struct msm_gpio sdc2_cfg_data[] = {
5637 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
5638 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
5639 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
5640 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
5641 {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
5642 {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
5643
5644#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5645 {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
5646 {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
5647 {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
5648 {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
5649#endif
5650};
5651
5652static struct msm_gpio sdc3_cfg_data[] = {
5653 {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
5654 {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
5655 {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
5656 {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
5657 {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
5658 {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
5659};
5660
5661static struct msm_gpio sdc3_sleep_cfg_data[] = {
5662 {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5663 "sdc3_clk"},
5664 {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5665 "sdc3_cmd"},
5666 {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5667 "sdc3_dat_3"},
5668 {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5669 "sdc3_dat_2"},
5670 {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5671 "sdc3_dat_1"},
5672 {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5673 "sdc3_dat_0"},
5674};
5675
5676static struct msm_gpio sdc4_cfg_data[] = {
5677 {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
5678 {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
5679 {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
5680 {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
5681 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
5682 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
5683};
5684
5685static struct sdcc_gpio sdcc_cfg_data[] = {
5686 {
5687 .cfg_data = sdc1_cfg_data,
5688 .size = ARRAY_SIZE(sdc1_cfg_data),
5689 .sleep_cfg_data = NULL,
5690 },
5691 {
5692 .cfg_data = sdc2_cfg_data,
5693 .size = ARRAY_SIZE(sdc2_cfg_data),
5694 .sleep_cfg_data = NULL,
5695 },
5696 {
5697 .cfg_data = sdc3_cfg_data,
5698 .size = ARRAY_SIZE(sdc3_cfg_data),
5699 .sleep_cfg_data = sdc3_sleep_cfg_data,
5700 },
5701 {
5702 .cfg_data = sdc4_cfg_data,
5703 .size = ARRAY_SIZE(sdc4_cfg_data),
5704 .sleep_cfg_data = NULL,
5705 },
5706};
5707
Justin Paupore3f40f342011-08-10 18:52:16 -07005708static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005709
5710static unsigned long vreg_sts, gpio_sts;
5711
5712static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
5713{
5714 int rc = 0;
5715 struct sdcc_gpio *curr;
5716
5717 curr = &sdcc_cfg_data[dev_id - 1];
5718
5719 if (!(test_bit(dev_id, &gpio_sts)^enable))
5720 return rc;
5721
5722 if (enable) {
5723 set_bit(dev_id, &gpio_sts);
5724 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
5725 if (rc)
5726 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
5727 __func__, dev_id);
5728 } else {
5729 clear_bit(dev_id, &gpio_sts);
5730 if (curr->sleep_cfg_data) {
5731 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
5732 msm_gpios_free(curr->sleep_cfg_data, curr->size);
5733 } else {
5734 msm_gpios_disable_free(curr->cfg_data, curr->size);
5735 }
5736 }
5737
5738 return rc;
5739}
5740
5741static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
5742{
5743 int rc = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005744 struct regulator *curr = sdcc_vreg_data[dev_id - 1];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005745 static int enabled_once[] = {0, 0, 0, 0};
5746
Justin Paupore3f40f342011-08-10 18:52:16 -07005747 if (test_bit(dev_id, &vreg_sts) == enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005748 return rc;
5749
Asutosh Das853bbcd2012-02-01 10:40:05 +05305750 if (dev_id == 4) {
5751 if (enable) {
5752 pr_debug("Enable Vdd dev_%d\n", dev_id);
5753 gpio_set_value_cansleep(
5754 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5755 0);
5756 set_bit(dev_id, &vreg_sts);
5757 } else {
5758 pr_debug("Disable Vdd dev_%d\n", dev_id);
5759 gpio_set_value_cansleep(
5760 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5761 1);
5762 clear_bit(dev_id, &vreg_sts);
5763 }
5764 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005765
Asutosh Das853bbcd2012-02-01 10:40:05 +05305766 if (!enable || enabled_once[dev_id - 1])
5767 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005768 if (!curr)
5769 return -ENODEV;
5770
5771 if (IS_ERR(curr))
5772 return PTR_ERR(curr);
5773
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005774 if (enable) {
5775 set_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005776
5777 rc = regulator_enable(curr);
5778 if (rc)
5779 pr_err("%s: could not enable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005780 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005781 enabled_once[dev_id - 1] = 1;
5782 } else {
5783 clear_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005784
5785 rc = regulator_disable(curr);
5786 if (rc)
5787 pr_err("%s: could not disable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005788 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005789 }
5790 return rc;
5791}
5792
5793static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
5794{
5795 int rc = 0;
5796 struct platform_device *pdev;
5797
5798 pdev = container_of(dv, struct platform_device, dev);
5799 rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
5800 if (rc)
5801 goto out;
5802
5803 if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
5804 rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
5805out:
5806 return rc;
5807}
5808
5809#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \
5810 defined(CONFIG_CSDIO_VENDOR_ID) && \
5811 defined(CONFIG_CSDIO_DEVICE_ID) && \
5812 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5813
5814#define MBP_ON 1
5815#define MBP_OFF 0
5816
5817#define MBP_RESET_N \
5818 GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
5819#define MBP_INT0 \
5820 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
5821
5822#define MBP_MODE_CTRL_0 \
5823 GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5824#define MBP_MODE_CTRL_1 \
5825 GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5826#define MBP_MODE_CTRL_2 \
5827 GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5828#define TSIF_EN \
5829 GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5830#define TSIF_DATA \
5831 GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5832#define TSIF_CLK \
5833 GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5834
5835static struct msm_gpio mbp_cfg_data[] = {
5836 {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5837 "mbp_reset"},
5838 {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5839 "mbp_io_voltage"},
5840};
5841
5842static int mbp_config_gpios_pre_init(int enable)
5843{
5844 int rc = 0;
5845
5846 if (enable) {
5847 rc = msm_gpios_request_enable(mbp_cfg_data,
5848 ARRAY_SIZE(mbp_cfg_data));
5849 if (rc) {
5850 printk(KERN_ERR
5851 "%s: Failed to turnon GPIOs for mbp chip(%d)\n",
5852 __func__, rc);
5853 }
5854 } else
5855 msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
5856 return rc;
5857}
5858
Justin Paupore3f40f342011-08-10 18:52:16 -07005859static struct regulator_bulk_data mbp_regs_io[2];
5860static struct regulator_bulk_data mbp_regs_rf[2];
5861static struct regulator_bulk_data mbp_regs_adc[1];
5862static struct regulator_bulk_data mbp_regs_core[1];
5863
5864static int mbp_init_regs(struct device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005865{
Justin Paupore3f40f342011-08-10 18:52:16 -07005866 struct regulator_bulk_data regs[] = {
5867 /* Analog and I/O regs */
5868 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
5869 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
5870 /* RF regs */
5871 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
5872 { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 },
5873 /* ADC regs */
5874 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
5875 /* Core regs */
5876 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
5877 };
5878
5879 struct regulator_bulk_data *regptr = regs;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005880 int rc;
5881
Justin Paupore3f40f342011-08-10 18:52:16 -07005882 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs);
5883
5884 if (rc) {
5885 dev_err(dev, "%s: could not get regulators: %d\n",
5886 __func__, rc);
5887 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005888 }
5889
Justin Paupore3f40f342011-08-10 18:52:16 -07005890 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005891
Justin Paupore3f40f342011-08-10 18:52:16 -07005892 if (rc) {
5893 dev_err(dev, "%s: could not set voltages: %d\n",
5894 __func__, rc);
5895 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005896 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005897
5898 memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io));
5899 regptr += ARRAY_SIZE(mbp_regs_io);
5900
5901 memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf));
5902 regptr += ARRAY_SIZE(mbp_regs_rf);
5903
5904 memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc));
5905 regptr += ARRAY_SIZE(mbp_regs_adc);
5906
5907 memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core));
5908
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005909 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005910
5911reg_free:
5912 regulator_bulk_free(ARRAY_SIZE(regs), regs);
5913out:
5914 return rc;
5915}
5916
5917static int mbp_setup_rf_vregs(int state)
5918{
5919 return state ?
5920 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) :
5921 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005922}
5923
5924static int mbp_setup_vregs(int state)
5925{
Justin Paupore3f40f342011-08-10 18:52:16 -07005926 return state ?
5927 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) :
5928 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005929}
5930
5931static int mbp_set_tcxo_en(int enable)
5932{
5933 int rc;
5934 const char *id = "UBMC";
5935 struct vreg *vreg_analog = NULL;
5936
5937 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
5938 enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
5939 if (rc < 0) {
5940 printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
5941 __func__, enable ? "" : "de-");
5942 return -EIO;
5943 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005944 return rc;
5945}
5946
5947static void mbp_set_freeze_io(int state)
5948{
5949 if (state)
5950 gpio_set_value(85, 0);
5951 else
5952 gpio_set_value(85, 1);
5953}
5954
5955static int mbp_set_core_voltage_en(int enable)
5956{
Justin Paupore3f40f342011-08-10 18:52:16 -07005957 static bool is_enabled;
5958 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005959
Justin Paupore3f40f342011-08-10 18:52:16 -07005960 if (enable && !is_enabled) {
5961 rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core),
5962 mbp_regs_core);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005963 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005964 pr_err("%s: could not enable regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005965 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07005966 } else {
5967 is_enabled = true;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005968 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005969 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005970
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005971 return rc;
5972}
5973
5974static void mbp_set_reset(int state)
5975{
5976 if (state)
5977 gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
5978 else
5979 gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
5980}
5981
5982static int mbp_config_interface_mode(int state)
5983{
5984 if (state) {
5985 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
5986 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
5987 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
5988 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
5989 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
5990 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
5991 } else {
5992 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
5993 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
5994 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
5995 }
5996 return 0;
5997}
5998
5999static int mbp_setup_adc_vregs(int state)
6000{
Justin Paupore3f40f342011-08-10 18:52:16 -07006001 return state ?
6002 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) :
6003 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006004}
6005
6006static int mbp_power_up(void)
6007{
6008 int rc;
6009
6010 rc = mbp_config_gpios_pre_init(MBP_ON);
6011 if (rc)
6012 goto exit;
6013 pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__);
6014
6015 rc = mbp_setup_vregs(MBP_ON);
6016 if (rc)
6017 goto exit;
6018 pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
6019
6020 rc = mbp_set_tcxo_en(MBP_ON);
6021 if (rc)
6022 goto exit;
6023 pr_debug("%s: tcxo clock done\n", __func__);
6024
6025 mbp_set_freeze_io(MBP_OFF);
6026 pr_debug("%s: set gpio 85 to 1 done\n", __func__);
6027
6028 udelay(100);
6029 mbp_set_reset(MBP_ON);
6030
6031 udelay(300);
6032 rc = mbp_config_interface_mode(MBP_ON);
6033 if (rc)
6034 goto exit;
6035 pr_debug("%s: mbp_config_interface_mode() done\n", __func__);
6036
6037 udelay(100 + mbp_set_core_voltage_en(MBP_ON));
6038 pr_debug("%s: power gp16 1.2V done\n", __func__);
6039
6040 mbp_set_freeze_io(MBP_ON);
6041 pr_debug("%s: set gpio 85 to 0 done\n", __func__);
6042
6043 udelay(100);
6044
6045 rc = mbp_setup_rf_vregs(MBP_ON);
6046 if (rc)
6047 goto exit;
6048 pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
6049
6050 rc = mbp_setup_adc_vregs(MBP_ON);
6051 if (rc)
6052 goto exit;
6053 pr_debug("%s: s4 2.2V done\n", __func__);
6054
6055 udelay(200);
6056
6057 mbp_set_reset(MBP_OFF);
6058 pr_debug("%s: close gpio 44 done\n", __func__);
6059
6060 msleep(20);
6061exit:
6062 return rc;
6063}
6064
6065static int mbp_power_down(void)
6066{
6067 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006068
6069 mbp_set_reset(MBP_ON);
6070 pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
6071
6072 udelay(100);
6073
6074 rc = mbp_setup_adc_vregs(MBP_OFF);
6075 if (rc)
6076 goto exit;
6077 pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
6078
6079 udelay(5);
6080
6081 rc = mbp_setup_rf_vregs(MBP_OFF);
6082 if (rc)
6083 goto exit;
6084 pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
6085
6086 udelay(5);
6087
6088 mbp_set_freeze_io(MBP_OFF);
6089 pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
6090
6091 udelay(100);
6092 rc = mbp_set_core_voltage_en(MBP_OFF);
6093 if (rc)
6094 goto exit;
6095 pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
6096
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006097 rc = mbp_set_tcxo_en(MBP_OFF);
6098 if (rc)
6099 goto exit;
6100 pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
6101
Justin Paupore3f40f342011-08-10 18:52:16 -07006102 rc = mbp_setup_vregs(MBP_OFF);
6103 if (rc)
6104 goto exit;
6105 pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__);
6106
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006107 rc = mbp_config_gpios_pre_init(MBP_OFF);
6108 if (rc)
6109 goto exit;
6110exit:
6111 return rc;
6112}
6113
6114static void (*mbp_status_notify_cb)(int card_present, void *dev_id);
6115static void *mbp_status_notify_cb_devid;
6116static int mbp_power_status;
6117static int mbp_power_init_done;
6118
6119static uint32_t mbp_setup_power(struct device *dv,
6120 unsigned int power_status)
6121{
6122 int rc = 0;
6123 struct platform_device *pdev;
6124
6125 pdev = container_of(dv, struct platform_device, dev);
6126
6127 if (power_status == mbp_power_status)
6128 goto exit;
6129 if (power_status) {
6130 pr_debug("turn on power of mbp slot");
6131 rc = mbp_power_up();
6132 mbp_power_status = 1;
6133 } else {
6134 pr_debug("turn off power of mbp slot");
6135 rc = mbp_power_down();
6136 mbp_power_status = 0;
6137 }
6138exit:
6139 return rc;
6140};
6141
6142int mbp_register_status_notify(void (*callback)(int, void *),
6143 void *dev_id)
6144{
6145 mbp_status_notify_cb = callback;
6146 mbp_status_notify_cb_devid = dev_id;
6147 return 0;
6148}
6149
6150static unsigned int mbp_status(struct device *dev)
6151{
6152 return mbp_power_status;
6153}
6154
6155static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd)
6156{
6157 struct platform_device *pdev;
6158 uint32_t rc = 0;
6159
6160 pdev = container_of(dv, struct platform_device, dev);
6161 rc = msm_sdcc_setup_power(dv, vdd);
6162 if (rc) {
6163 pr_err("%s: Failed to setup power (%d)\n",
6164 __func__, rc);
6165 goto out;
6166 }
6167 if (!mbp_power_init_done) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006168 rc = mbp_init_regs(dv);
6169 if (rc) {
6170 dev_err(dv, "%s: regulator init failed: %d\n",
6171 __func__, rc);
6172 goto out;
6173 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006174 mbp_setup_power(dv, 1);
6175 mbp_setup_power(dv, 0);
6176 mbp_power_init_done = 1;
6177 }
6178 if (vdd >= 0x8000) {
6179 rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
6180 if (rc) {
6181 pr_err("%s: Failed to config mbp chip power (%d)\n",
6182 __func__, rc);
6183 goto out;
6184 }
6185 if (mbp_status_notify_cb) {
6186 mbp_status_notify_cb(mbp_power_status,
6187 mbp_status_notify_cb_devid);
6188 }
6189 }
6190out:
6191 /* should return 0 only */
6192 return 0;
6193}
6194
6195#endif
6196
6197#endif
6198
6199#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6200#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6201static unsigned int msm7x30_sdcc_slot_status(struct device *dev)
6202{
6203 return (unsigned int)
6204 gpio_get_value_cansleep(
6205 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1));
6206}
6207#endif
6208
6209static int msm_sdcc_get_wpswitch(struct device *dv)
6210{
6211 void __iomem *wp_addr = 0;
6212 uint32_t ret = 0;
6213 struct platform_device *pdev;
6214
6215 if (!(machine_is_msm7x30_surf()))
6216 return -1;
6217 pdev = container_of(dv, struct platform_device, dev);
6218
6219 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
6220 if (!wp_addr) {
6221 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
6222 return -ENOMEM;
6223 }
6224
6225 ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
6226 pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
6227 pdev->id, ret);
6228 iounmap(wp_addr);
6229
6230 return ret;
6231}
6232#endif
6233
6234#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
6235#if defined(CONFIG_CSDIO_VENDOR_ID) && \
6236 defined(CONFIG_CSDIO_DEVICE_ID) && \
6237 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
6238static struct mmc_platform_data msm7x30_sdc1_data = {
6239 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
6240 .translate_vdd = msm_sdcc_setup_power_mbp,
6241 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6242 .status = mbp_status,
6243 .register_status_notify = mbp_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006244 .msmsdcc_fmin = 144000,
6245 .msmsdcc_fmid = 24576000,
6246 .msmsdcc_fmax = 24576000,
6247 .nonremovable = 0,
6248};
6249#else
6250static struct mmc_platform_data msm7x30_sdc1_data = {
6251 .ocr_mask = MMC_VDD_165_195,
6252 .translate_vdd = msm_sdcc_setup_power,
6253 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006254 .msmsdcc_fmin = 144000,
6255 .msmsdcc_fmid = 24576000,
6256 .msmsdcc_fmax = 49152000,
6257 .nonremovable = 0,
6258};
6259#endif
6260#endif
6261
6262#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
6263static struct mmc_platform_data msm7x30_sdc2_data = {
6264 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
6265 .translate_vdd = msm_sdcc_setup_power,
6266#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
6267 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
6268#else
6269 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6270#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006271 .msmsdcc_fmin = 144000,
6272 .msmsdcc_fmid = 24576000,
6273 .msmsdcc_fmax = 49152000,
6274 .nonremovable = 1,
6275};
6276#endif
6277
6278#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
6279static struct mmc_platform_data msm7x30_sdc3_data = {
6280 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6281 .translate_vdd = msm_sdcc_setup_power,
6282 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006283 .sdiowakeup_irq = MSM_GPIO_TO_INT(118),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006284 .msmsdcc_fmin = 144000,
6285 .msmsdcc_fmid = 24576000,
6286 .msmsdcc_fmax = 49152000,
6287 .nonremovable = 0,
6288};
6289#endif
6290
6291#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6292static struct mmc_platform_data msm7x30_sdc4_data = {
6293 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6294 .translate_vdd = msm_sdcc_setup_power,
6295 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6296#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6297 .status = msm7x30_sdcc_slot_status,
6298 .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
6299 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
6300#endif
6301 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006302 .msmsdcc_fmin = 144000,
6303 .msmsdcc_fmid = 24576000,
6304 .msmsdcc_fmax = 49152000,
6305 .nonremovable = 0,
6306};
6307#endif
6308
6309#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006310static int msm_sdc1_lvlshft_enable(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006311{
Justin Paupore3f40f342011-08-10 18:52:16 -07006312 static struct regulator *ldo5;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006313 int rc;
6314
6315 /* Enable LDO5, an input to the FET that powers slot 1 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006316
Justin Paupore3f40f342011-08-10 18:52:16 -07006317 ldo5 = regulator_get(NULL, "ldo5");
6318
6319 if (IS_ERR(ldo5)) {
6320 rc = PTR_ERR(ldo5);
6321 pr_err("%s: could not get ldo5: %d\n", __func__, rc);
6322 goto out;
6323 }
6324
6325 rc = regulator_set_voltage(ldo5, 2850000, 2850000);
6326 if (rc) {
6327 pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc);
6328 goto ldo5_free;
6329 }
6330
6331 rc = regulator_enable(ldo5);
6332 if (rc) {
6333 pr_err("%s: could not enable ldo5: %d\n", __func__, rc);
6334 goto ldo5_free;
6335 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006336
6337 /* Enable GPIO 35, to turn on the FET that powers slot 1 */
6338 rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
6339 ARRAY_SIZE(sdc1_lvlshft_cfg_data));
6340 if (rc)
6341 printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
6342
6343 rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg),
6344 1);
6345 if (rc)
6346 printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006347
6348 return 0;
6349
6350ldo5_free:
6351 regulator_put(ldo5);
6352out:
6353 ldo5 = NULL;
6354 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006355}
6356#endif
6357
Justin Paupore3f40f342011-08-10 18:52:16 -07006358static int mmc_regulator_init(int sdcc_no, const char *supply, int uV)
6359{
6360 int rc;
6361
6362 BUG_ON(sdcc_no < 1 || sdcc_no > 4);
6363
6364 sdcc_no--;
6365
6366 sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply);
6367
6368 if (IS_ERR(sdcc_vreg_data[sdcc_no])) {
6369 rc = PTR_ERR(sdcc_vreg_data[sdcc_no]);
6370 pr_err("%s: could not get regulator \"%s\": %d\n",
6371 __func__, supply, rc);
6372 goto out;
6373 }
6374
6375 rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV);
6376
6377 if (rc) {
6378 pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n",
6379 __func__, supply, uV, rc);
6380 goto reg_free;
6381 }
6382
6383 return rc;
6384
6385reg_free:
6386 regulator_put(sdcc_vreg_data[sdcc_no]);
6387out:
6388 sdcc_vreg_data[sdcc_no] = NULL;
6389 return rc;
6390}
6391
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006392static void __init msm7x30_init_mmc(void)
6393{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006394#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006395 if (mmc_regulator_init(1, "s3", 1800000))
6396 goto out1;
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05306397 msm7x30_sdc1_data.swfi_latency = msm7x30_power_collapse_latency(
6398 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT);
Justin Paupore3f40f342011-08-10 18:52:16 -07006399
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006400 if (machine_is_msm7x30_fluid()) {
6401 msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
Justin Paupore3f40f342011-08-10 18:52:16 -07006402 if (msm_sdc1_lvlshft_enable()) {
6403 pr_err("%s: could not enable level shift\n");
6404 goto out1;
6405 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006406 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006407
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006408 msm_add_sdcc(1, &msm7x30_sdc1_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006409out1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006410#endif
6411#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006412 if (mmc_regulator_init(2, "s3", 1800000))
6413 goto out2;
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05306414 msm7x30_sdc2_data.swfi_latency = msm7x30_power_collapse_latency(
6415 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT);
Justin Paupore3f40f342011-08-10 18:52:16 -07006416
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006417 if (machine_is_msm8x55_svlte_surf())
6418 msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
Sujith Reddy Thumma84a0f512011-08-29 09:57:03 +05306419 if (machine_is_msm8x55_svlte_surf() ||
6420 machine_is_msm8x55_svlte_ffa()) {
6421 msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
6422 msm7x30_sdc2_data.is_sdio_al_client = 1;
6423 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006424
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006425 msm_add_sdcc(2, &msm7x30_sdc2_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006426out2:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006427#endif
6428#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006429 if (mmc_regulator_init(3, "s3", 1800000))
6430 goto out3;
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05306431 msm7x30_sdc3_data.swfi_latency = msm7x30_power_collapse_latency(
6432 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT);
Justin Paupore3f40f342011-08-10 18:52:16 -07006433
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006434 msm_sdcc_setup_gpio(3, 1);
6435 msm_add_sdcc(3, &msm7x30_sdc3_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006436out3:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006437#endif
6438#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006439 if (mmc_regulator_init(4, "mmc", 2850000))
6440 return;
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05306441 msm7x30_sdc4_data.swfi_latency = msm7x30_power_collapse_latency(
6442 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT);
Justin Paupore3f40f342011-08-10 18:52:16 -07006443
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006444 msm_add_sdcc(4, &msm7x30_sdc4_data);
6445#endif
6446
6447}
6448
6449static void __init msm7x30_init_nand(void)
6450{
6451 char *build_id;
6452 struct flash_platform_data *plat_data;
6453
6454 build_id = socinfo_get_build_id();
6455 if (build_id == NULL) {
6456 pr_err("%s: Build ID not available from socinfo\n", __func__);
6457 return;
6458 }
6459
6460 if (build_id[8] == 'C' &&
6461 !msm_gpios_request_enable(msm_nand_ebi2_cfg_data,
6462 ARRAY_SIZE(msm_nand_ebi2_cfg_data))) {
6463 plat_data = msm_device_nand.dev.platform_data;
6464 plat_data->interleave = 1;
6465 printk(KERN_INFO "%s: Interleave mode Build ID found\n",
6466 __func__);
6467 }
6468}
6469
6470#ifdef CONFIG_SERIAL_MSM_CONSOLE
6471static struct msm_gpio uart2_config_data[] = {
6472 { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
6473 { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
6474 { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
6475 { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
6476};
6477
6478static void msm7x30_init_uart2(void)
6479{
6480 msm_gpios_request_enable(uart2_config_data,
6481 ARRAY_SIZE(uart2_config_data));
6482
6483}
6484#endif
6485
6486/* TSIF begin */
6487#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6488
6489#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6490#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6491#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6492#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6493
6494static const struct msm_gpio tsif_gpios[] = {
6495 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
6496 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
6497 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
6498 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
6499};
6500
6501static struct msm_tsif_platform_data tsif_platform_data = {
6502 .num_gpios = ARRAY_SIZE(tsif_gpios),
6503 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -07006504 .tsif_pclk = "iface_clk",
6505 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006506};
6507#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
6508/* TSIF end */
6509
6510static void __init pmic8058_leds_init(void)
6511{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306512 if (machine_is_msm7x30_surf())
6513 pm8058_7x30_data.leds_pdata = &pm8058_surf_leds_data;
6514 else if (!machine_is_msm7x30_fluid())
6515 pm8058_7x30_data.leds_pdata = &pm8058_ffa_leds_data;
6516 else if (machine_is_msm7x30_fluid())
6517 pm8058_7x30_data.leds_pdata = &pm8058_fluid_leds_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006518}
6519
6520static struct msm_spm_platform_data msm_spm_data __initdata = {
Taniya Das298de8c2012-02-16 11:45:31 +05306521 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006522
6523 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
6524 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
6525 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
6526 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
6527
6528 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
6529 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
6530 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
6531
6532 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
6533 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
6534 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
6535
6536 .awake_vlevel = 0xF2,
6537 .retention_vlevel = 0xE0,
6538 .collapse_vlevel = 0x72,
6539 .retention_mid_vlevel = 0xE0,
6540 .collapse_mid_vlevel = 0xE0,
6541
6542 .vctl_timeout_us = 50,
6543};
6544
6545#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6546 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6547
6548#define TSC2007_TS_PEN_INT 20
6549
6550static struct msm_gpio tsc2007_config_data[] = {
6551 { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
6552 "tsc2007_irq" },
6553};
6554
Justin Paupore3f40f342011-08-10 18:52:16 -07006555static struct regulator_bulk_data tsc2007_regs[] = {
6556 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
6557 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
6558};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006559
6560static int tsc2007_init(void)
6561{
6562 int rc;
6563
Justin Paupore3f40f342011-08-10 18:52:16 -07006564 rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006565
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006566 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006567 pr_err("%s: could not get regulators: %d\n", __func__, rc);
6568 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006569 }
6570
Justin Paupore3f40f342011-08-10 18:52:16 -07006571 rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6572
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006573 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006574 pr_err("%s: could not set voltages: %d\n", __func__, rc);
6575 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006576 }
6577
Justin Paupore3f40f342011-08-10 18:52:16 -07006578 rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006579
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006580 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006581 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
6582 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006583 }
6584
6585 rc = msm_gpios_request_enable(tsc2007_config_data,
6586 ARRAY_SIZE(tsc2007_config_data));
6587 if (rc) {
6588 pr_err("%s: Unable to request gpios\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006589 goto reg_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006590 }
6591
6592 return 0;
6593
Justin Paupore3f40f342011-08-10 18:52:16 -07006594reg_disable:
6595 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6596reg_free:
6597 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6598out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006599 return rc;
6600}
6601
6602static int tsc2007_get_pendown_state(void)
6603{
6604 int rc;
6605
6606 rc = gpio_get_value(TSC2007_TS_PEN_INT);
6607 if (rc < 0) {
6608 pr_err("%s: MSM GPIO %d read failed\n", __func__,
6609 TSC2007_TS_PEN_INT);
6610 return rc;
6611 }
6612
6613 return (rc == 0 ? 1 : 0);
6614}
6615
6616static void tsc2007_exit(void)
6617{
Justin Paupore3f40f342011-08-10 18:52:16 -07006618
6619 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6620 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006621
6622 msm_gpios_disable_free(tsc2007_config_data,
6623 ARRAY_SIZE(tsc2007_config_data));
6624}
6625
6626static int tsc2007_power_shutdown(bool enable)
6627{
6628 int rc;
6629
Justin Paupore3f40f342011-08-10 18:52:16 -07006630 rc = (enable == false) ?
6631 regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) :
6632 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6633
6634 if (rc) {
6635 pr_err("%s: could not %sable regulators: %d\n",
6636 __func__, enable ? "dis" : "en", rc);
6637 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006638 }
6639
Justin Paupore3f40f342011-08-10 18:52:16 -07006640 if (enable == false)
6641 msleep(20);
6642
6643 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006644}
6645
6646static struct tsc2007_platform_data tsc2007_ts_data = {
6647 .model = 2007,
6648 .x_plate_ohms = 300,
Anirudh Ghayala2cf2e22012-01-25 12:29:42 +05306649 .min_x = 210,
6650 .max_x = 3832,
6651 .min_y = 150,
6652 .max_y = 3936,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006653 .irq_flags = IRQF_TRIGGER_LOW,
6654 .init_platform_hw = tsc2007_init,
6655 .exit_platform_hw = tsc2007_exit,
6656 .power_shutdown = tsc2007_power_shutdown,
6657 .invert_x = true,
6658 .invert_y = true,
6659 /* REVISIT: Temporary fix for reversed pressure */
6660 .invert_z1 = true,
6661 .invert_z2 = true,
6662 .get_pendown_state = tsc2007_get_pendown_state,
6663};
6664
6665static struct i2c_board_info tsc_i2c_board_info[] = {
6666 {
6667 I2C_BOARD_INFO("tsc2007", 0x48),
6668 .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
6669 .platform_data = &tsc2007_ts_data,
6670 },
6671};
6672#endif
6673
Justin Paupore3f40f342011-08-10 18:52:16 -07006674static struct regulator_bulk_data regs_isa1200[] = {
6675 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
6676 { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006677};
6678
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006679static int isa1200_power(int vreg_on)
6680{
Justin Paupore3f40f342011-08-10 18:52:16 -07006681 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006682
Justin Paupore3f40f342011-08-10 18:52:16 -07006683 rc = vreg_on ?
6684 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) :
6685 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006686
Justin Paupore3f40f342011-08-10 18:52:16 -07006687 if (rc) {
6688 pr_err("%s: could not %sable regulators: %d\n",
6689 __func__, vreg_on ? "en" : "dis", rc);
6690 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006691 }
6692
6693 /* vote for DO buffer */
6694 rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO,
6695 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
6696 if (rc) {
6697 pr_err("%s: unable to %svote for d0 clk\n",
6698 __func__, vreg_on ? "" : "de-");
6699 goto vreg_fail;
6700 }
6701
6702 return 0;
6703
6704vreg_fail:
Justin Paupore3f40f342011-08-10 18:52:16 -07006705 if (vreg_on)
6706 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6707 else
6708 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6709out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006710 return rc;
6711}
6712
6713static int isa1200_dev_setup(bool enable)
6714{
Justin Paupore3f40f342011-08-10 18:52:16 -07006715 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006716
6717 if (enable == true) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006718 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200),
6719 regs_isa1200);
6720
6721 if (rc) {
6722 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006723 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006724 goto out;
6725 }
6726
6727 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200),
6728 regs_isa1200);
6729 if (rc) {
6730 pr_err("%s: could not set voltages: %d\n",
6731 __func__, rc);
6732 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006733 }
6734
6735 rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
6736 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
6737 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
6738 if (rc) {
6739 pr_err("%s: Could not configure gpio %d\n",
6740 __func__, HAP_LVL_SHFT_MSM_GPIO);
Justin Paupore3f40f342011-08-10 18:52:16 -07006741 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006742 }
6743
6744 rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
6745 if (rc) {
6746 pr_err("%s: unable to request gpio %d (%d)\n",
6747 __func__, HAP_LVL_SHFT_MSM_GPIO, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006748 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006749 }
6750
6751 gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
6752 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006753 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006754 gpio_free(HAP_LVL_SHFT_MSM_GPIO);
6755 }
6756
6757 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07006758
6759reg_free:
6760 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6761out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006762 return rc;
6763}
6764static struct isa1200_platform_data isa1200_1_pdata = {
6765 .name = "vibrator",
6766 .power_on = isa1200_power,
6767 .dev_setup = isa1200_dev_setup,
6768 .pwm_ch_id = 1, /*channel id*/
6769 /*gpio to enable haptic*/
6770 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka03122322011-09-09 15:15:43 +05306771 .hap_len_gpio = -1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006772 .max_timeout = 15000,
6773 .mode_ctrl = PWM_GEN_MODE,
6774 .pwm_fd = {
6775 .pwm_div = 256,
6776 },
6777 .is_erm = false,
6778 .smart_en = true,
6779 .ext_clk_en = true,
6780 .chip_en = 1,
6781};
6782
6783static struct i2c_board_info msm_isa1200_board_info[] = {
6784 {
6785 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
6786 .platform_data = &isa1200_1_pdata,
6787 },
6788};
6789
6790
6791static int kp_flip_mpp_config(void)
6792{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306793 struct pm8xxx_mpp_config_data kp_flip_mpp = {
6794 .type = PM8XXX_MPP_TYPE_D_INPUT,
6795 .level = PM8018_MPP_DIG_LEVEL_S3,
6796 .control = PM8XXX_MPP_DIN_TO_INT,
6797 };
6798
6799 return pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(PM_FLIP_MPP),
6800 &kp_flip_mpp);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006801}
6802
6803static struct flip_switch_pdata flip_switch_data = {
6804 .name = "kp_flip_switch",
6805 .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP,
6806 .left_key = KEY_OPEN,
6807 .right_key = KEY_CLOSE,
6808 .active_low = 0,
6809 .wakeup = 1,
6810 .flip_mpp_config = kp_flip_mpp_config,
6811};
6812
6813static struct platform_device flip_switch_device = {
6814 .name = "kp_flip_switch",
6815 .id = -1,
6816 .dev = {
6817 .platform_data = &flip_switch_data,
6818 }
6819};
6820
Justin Paupore3f40f342011-08-10 18:52:16 -07006821static struct regulator_bulk_data regs_tma300[] = {
6822 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
6823 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006824};
6825
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006826static int tma300_power(int vreg_on)
6827{
Justin Paupore3f40f342011-08-10 18:52:16 -07006828 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006829
Justin Paupore3f40f342011-08-10 18:52:16 -07006830 rc = vreg_on ?
6831 regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) :
6832 regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006833
Justin Paupore3f40f342011-08-10 18:52:16 -07006834 if (rc)
6835 pr_err("%s: could not %sable regulators: %d\n",
6836 __func__, vreg_on ? "en" : "dis", rc);
6837 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006838}
6839
6840#define TS_GPIO_IRQ 150
6841
6842static int tma300_dev_setup(bool enable)
6843{
Justin Paupore3f40f342011-08-10 18:52:16 -07006844 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006845
6846 if (enable) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006847 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300),
6848 regs_tma300);
6849
6850 if (rc) {
6851 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006852 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006853 goto out;
6854 }
6855
6856 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300),
6857 regs_tma300);
6858
6859 if (rc) {
6860 pr_err("%s: could not set voltages: %d\n",
6861 __func__, rc);
6862 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006863 }
6864
6865 /* enable interrupt gpio */
6866 rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
6867 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
6868 if (rc) {
6869 pr_err("%s: Could not configure gpio %d\n",
6870 __func__, TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -07006871 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006872 }
6873
6874 /* virtual keys */
6875 tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
6876 properties_kobj = kobject_create_and_add("board_properties",
6877 NULL);
6878 if (!properties_kobj) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006879 pr_err("%s: failed to create a kobject "
6880 "for board_properties\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006881 rc = -ENOMEM;
Justin Paupore3f40f342011-08-10 18:52:16 -07006882 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006883 }
6884 rc = sysfs_create_group(properties_kobj,
6885 &tma300_properties_attr_group);
6886 if (rc) {
6887 pr_err("%s: failed to create a sysfs entry %s\n",
6888 __func__, tma300_vkeys_attr.attr.name);
Justin Paupore3f40f342011-08-10 18:52:16 -07006889 goto kobj_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006890 }
6891 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006892 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006893 /* destroy virtual keys */
6894 if (properties_kobj) {
6895 sysfs_remove_group(properties_kobj,
6896 &tma300_properties_attr_group);
6897 kobject_put(properties_kobj);
6898 }
6899 }
6900 return 0;
6901
Justin Paupore3f40f342011-08-10 18:52:16 -07006902kobj_free:
6903 kobject_put(properties_kobj);
6904 properties_kobj = NULL;
6905reg_free:
6906 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
6907out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006908 return rc;
6909}
6910
6911static struct cy8c_ts_platform_data cy8ctma300_pdata = {
6912 .power_on = tma300_power,
6913 .dev_setup = tma300_dev_setup,
6914 .ts_name = "msm_tma300_ts",
6915 .dis_min_x = 0,
6916 .dis_max_x = 479,
6917 .dis_min_y = 0,
6918 .dis_max_y = 799,
6919 .res_x = 479,
6920 .res_y = 1009,
6921 .min_tid = 1,
6922 .max_tid = 255,
6923 .min_touch = 0,
6924 .max_touch = 255,
6925 .min_width = 0,
6926 .max_width = 255,
6927 .invert_y = 1,
6928 .nfingers = 4,
6929 .irq_gpio = TS_GPIO_IRQ,
6930 .resout_gpio = -1,
6931};
6932
6933static struct i2c_board_info cy8ctma300_board_info[] = {
6934 {
6935 I2C_BOARD_INFO("cy8ctma300", 0x2),
6936 .platform_data = &cy8ctma300_pdata,
6937 }
6938};
6939
Daniel Walker8d747cd2010-02-25 11:37:43 -08006940static void __init msm7x30_init(void)
6941{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006942 int rc;
6943 unsigned smem_size;
6944 uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56,
6945 0,
6946 GPIO_CFG_OUTPUT,
6947 GPIO_CFG_NO_PULL,
6948 GPIO_CFG_2MA);
6949 uint32_t soc_version = 0;
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05306950
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006951 soc_version = socinfo_get_version();
6952
Stephen Boydbb600ae2011-08-02 20:11:40 -07006953 msm_clock_init(&msm7x30_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006954#ifdef CONFIG_SERIAL_MSM_CONSOLE
6955 msm7x30_init_uart2();
6956#endif
6957 msm_spm_init(&msm_spm_data, 1);
Matt Wagantallec57f062011-08-16 23:54:46 -07006958 acpuclk_init(&acpuclk_7x30_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006959 if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid())
6960 msm7x30_cfg_smsc911x();
6961
6962#ifdef CONFIG_USB_MSM_OTG_72K
6963 if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 &&
6964 SOCINFO_VERSION_MINOR(soc_version) >= 1) {
6965 pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
6966 msm_otg_pdata.ldo_set_voltage = 0;
6967 }
6968
6969 msm_device_otg.dev.platform_data = &msm_otg_pdata;
6970#ifdef CONFIG_USB_GADGET
6971 msm_otg_pdata.swfi_latency =
6972 msm_pm_data
6973 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
6974 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
6975#endif
6976#endif
6977 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
6978 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
6979#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6980 msm_device_tsif.dev.platform_data = &tsif_platform_data;
6981#endif
6982 if (machine_is_msm7x30_fluid()) {
6983 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
6984 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
6985 } else {
6986 msm_adc_pdata.dev_names = msm_adc_surf_device_names;
6987 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names);
6988 }
6989
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306990 pmic8058_leds_init();
6991
6992 buses_init();
6993
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306994#ifdef CONFIG_MSM_SSBI
6995 msm_device_ssbi_pmic1.dev.platform_data =
6996 &msm7x30_ssbi_pm8058_pdata;
6997#endif
6998
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006999 platform_add_devices(msm_footswitch_devices,
7000 msm_num_footswitch_devices);
Daniel Walker8d747cd2010-02-25 11:37:43 -08007001 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007002#ifdef CONFIG_USB_EHCI_MSM_72K
7003 msm_add_host(0, &msm_usb_host_pdata);
7004#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07007005#ifdef CONFIG_MSM_CAMERA_V4L2
7006 msm7x30_init_cam();
7007#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007008 msm7x30_init_mmc();
7009 msm7x30_init_nand();
7010 msm_qsd_spi_init();
7011
7012#ifdef CONFIG_SPI_QSD
7013 if (machine_is_msm7x30_fluid())
7014 spi_register_board_info(lcdc_sharp_spi_board_info,
7015 ARRAY_SIZE(lcdc_sharp_spi_board_info));
7016 else
7017 spi_register_board_info(lcdc_toshiba_spi_board_info,
7018 ARRAY_SIZE(lcdc_toshiba_spi_board_info));
7019#endif
7020
Justin Paupore3f40f342011-08-10 18:52:16 -07007021 atv_dac_power_init();
7022 sensors_ldo_init();
7023 hdmi_init_regs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007024 msm_fb_add_devices();
7025 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06007026 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05307027 msm_pm_register_irqs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007028 msm_device_i2c_init();
7029 msm_device_i2c_2_init();
7030 qup_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007031 msm7x30_init_marimba();
7032#ifdef CONFIG_MSM7KV2_AUDIO
7033 snddev_poweramp_gpio_init();
Justin Paupore3f40f342011-08-10 18:52:16 -07007034 snddev_hsed_voltage_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007035 aux_pcm_gpio_init();
7036#endif
7037
7038 i2c_register_board_info(0, msm_i2c_board_info,
7039 ARRAY_SIZE(msm_i2c_board_info));
7040
7041 if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid())
7042 marimba_pdata.tsadc = &marimba_tsadc_pdata;
7043
7044 if (machine_is_msm7x30_fluid())
7045 i2c_register_board_info(0, cy8info,
7046 ARRAY_SIZE(cy8info));
7047#ifdef CONFIG_BOSCH_BMA150
7048 if (machine_is_msm7x30_fluid())
7049 i2c_register_board_info(0, bma150_board_info,
7050 ARRAY_SIZE(bma150_board_info));
7051#endif
7052
7053 i2c_register_board_info(2, msm_marimba_board_info,
7054 ARRAY_SIZE(msm_marimba_board_info));
7055
7056 i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info,
7057 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info));
7058
7059 i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
7060 ARRAY_SIZE(msm_camera_boardinfo));
7061
7062 bt_power_init();
7063#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007064 msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
7065#endif
7066 if (machine_is_msm7x30_fluid())
7067 i2c_register_board_info(0, msm_isa1200_board_info,
7068 ARRAY_SIZE(msm_isa1200_board_info));
7069
7070#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
7071 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
7072 if (machine_is_msm8x55_svlte_ffa())
7073 i2c_register_board_info(2, tsc_i2c_board_info,
7074 ARRAY_SIZE(tsc_i2c_board_info));
7075#endif
7076
7077 if (machine_is_msm7x30_surf())
7078 platform_device_register(&flip_switch_device);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307079
7080 pm8058_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007081
7082 if (machine_is_msm7x30_fluid()) {
7083 /* Initialize platform data for fluid v2 hardware */
7084 if (SOCINFO_VERSION_MAJOR(
7085 socinfo_get_platform_version()) == 2) {
7086 cy8ctma300_pdata.res_y = 920;
7087 cy8ctma300_pdata.invert_y = 0;
7088 }
7089 i2c_register_board_info(0, cy8ctma300_board_info,
7090 ARRAY_SIZE(cy8ctma300_board_info));
7091 }
7092
7093 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
7094 rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE);
7095 if (rc)
7096 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
7097 __func__, usb_hub_gpio_cfg_value, rc);
7098 }
7099
7100 boot_reason = *(unsigned int *)
7101 (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
7102 printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
7103}
7104
7105static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
7106static int __init pmem_sf_size_setup(char *p)
7107{
7108 pmem_sf_size = memparse(p, NULL);
7109 return 0;
7110}
7111early_param("pmem_sf_size", pmem_sf_size_setup);
7112
7113static unsigned fb_size = MSM_FB_SIZE;
7114static int __init fb_size_setup(char *p)
7115{
7116 fb_size = memparse(p, NULL);
7117 return 0;
7118}
7119early_param("fb_size", fb_size_setup);
7120
7121static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
7122static int __init pmem_adsp_size_setup(char *p)
7123{
7124 pmem_adsp_size = memparse(p, NULL);
7125 return 0;
7126}
7127early_param("pmem_adsp_size", pmem_adsp_size_setup);
7128
7129static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE;
7130static int __init fluid_pmem_adsp_size_setup(char *p)
7131{
7132 fluid_pmem_adsp_size = memparse(p, NULL);
7133 return 0;
7134}
7135early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup);
7136
7137static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
7138static int __init pmem_audio_size_setup(char *p)
7139{
7140 pmem_audio_size = memparse(p, NULL);
7141 return 0;
7142}
7143early_param("pmem_audio_size", pmem_audio_size_setup);
7144
7145static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE;
7146static int __init pmem_kernel_ebi0_size_setup(char *p)
7147{
7148 pmem_kernel_ebi0_size = memparse(p, NULL);
7149 return 0;
7150}
7151early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
7152
7153static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
7154 [MEMTYPE_SMI] = {
7155 },
7156 [MEMTYPE_EBI0] = {
7157 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7158 },
7159 [MEMTYPE_EBI1] = {
7160 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7161 },
7162};
7163
7164static void __init size_pmem_devices(void)
7165{
7166#ifdef CONFIG_ANDROID_PMEM
7167 unsigned long size;
7168
7169 if machine_is_msm7x30_fluid()
7170 size = fluid_pmem_adsp_size;
7171 else
7172 size = pmem_adsp_size;
7173 android_pmem_adsp_pdata.size = size;
7174 android_pmem_audio_pdata.size = pmem_audio_size;
7175 android_pmem_pdata.size = pmem_sf_size;
7176#endif
7177}
7178
7179static void __init reserve_memory_for(struct android_pmem_platform_data *p)
7180{
7181 msm7x30_reserve_table[p->memory_type].size += p->size;
7182}
7183
7184static void __init reserve_pmem_memory(void)
7185{
7186#ifdef CONFIG_ANDROID_PMEM
7187 reserve_memory_for(&android_pmem_adsp_pdata);
7188 reserve_memory_for(&android_pmem_audio_pdata);
7189 reserve_memory_for(&android_pmem_pdata);
7190 msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
7191#endif
7192}
7193
7194static void __init msm7x30_calculate_reserve_sizes(void)
7195{
7196 size_pmem_devices();
7197 reserve_pmem_memory();
7198}
7199
7200static int msm7x30_paddr_to_memtype(unsigned int paddr)
7201{
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307202 if (paddr < phys_add)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007203 return MEMTYPE_EBI0;
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307204 if (paddr >= phys_add && paddr < 0x80000000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007205 return MEMTYPE_EBI1;
7206 return MEMTYPE_NONE;
7207}
7208
7209static struct reserve_info msm7x30_reserve_info __initdata = {
7210 .memtype_reserve_table = msm7x30_reserve_table,
7211 .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes,
7212 .paddr_to_memtype = msm7x30_paddr_to_memtype,
7213};
7214
7215static void __init msm7x30_reserve(void)
7216{
7217 reserve_info = &msm7x30_reserve_info;
7218 msm_reserve();
7219}
7220
7221static void __init msm7x30_allocate_memory_regions(void)
7222{
7223 void *addr;
7224 unsigned long size;
7225
7226 size = fb_size ? : MSM_FB_SIZE;
7227 addr = alloc_bootmem_align(size, 0x1000);
7228 msm_fb_resources[0].start = __pa(addr);
7229 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
7230 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
7231 size, addr, __pa(addr));
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08007232
7233#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
7234 size = MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE;
7235 addr = alloc_bootmem_align(size, 0x1000);
7236 msm_v4l2_video_overlay_resources[0].start = __pa(addr);
7237 msm_v4l2_video_overlay_resources[0].end =
7238 msm_v4l2_video_overlay_resources[0].start + size - 1;
7239 pr_debug("allocating %lu bytes at %p (%lx physical) for v4l2\n",
7240 size, addr, __pa(addr));
7241#endif
Daniel Walker8d747cd2010-02-25 11:37:43 -08007242}
7243
7244static void __init msm7x30_map_io(void)
7245{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007246 msm_shared_ram_phys = 0x00100000;
Daniel Walker8d747cd2010-02-25 11:37:43 -08007247 msm_map_msm7x30_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007248 if (socinfo_init() < 0)
7249 printk(KERN_ERR "%s: socinfo_init() failed!\n",
7250 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007251}
7252
7253static void __init msm7x30_init_early(void)
7254{
7255 msm7x30_allocate_memory_regions();
Daniel Walker8d747cd2010-02-25 11:37:43 -08007256}
7257
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307258static void __init msm7x30_fixup(struct machine_desc *desc, struct tag *tags,
7259 char **cmdline, struct meminfo *mi)
7260{
7261 for (; tags->hdr.size; tags = tag_next(tags)) {
7262 if (tags->hdr.tag == ATAG_MEM && tags->u.mem.start ==
7263 DDR1_BANK_BASE) {
7264 ebi1_phys_offset = DDR1_BANK_BASE;
7265 phys_add = DDR1_BANK_BASE;
7266 break;
7267 }
7268 }
7269}
7270
Daniel Walker8d747cd2010-02-25 11:37:43 -08007271MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00007272 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007273 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007274 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007275 .init_irq = msm7x30_init_irq,
7276 .init_machine = msm7x30_init,
7277 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007278 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307279 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307280 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007281MACHINE_END
7282
7283MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00007284 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007285 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007286 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007287 .init_irq = msm7x30_init_irq,
7288 .init_machine = msm7x30_init,
7289 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007290 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307291 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307292 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007293MACHINE_END
7294
7295MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
Russell Kingb75c1782011-01-04 19:03:16 +00007296 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007297 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007298 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007299 .init_irq = msm7x30_init_irq,
7300 .init_machine = msm7x30_init,
7301 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007302 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307303 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307304 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007305MACHINE_END
7306
7307MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
7308 .boot_params = PHYS_OFFSET + 0x100,
7309 .map_io = msm7x30_map_io,
7310 .reserve = msm7x30_reserve,
7311 .init_irq = msm7x30_init_irq,
7312 .init_machine = msm7x30_init,
7313 .timer = &msm_timer,
7314 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307315 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307316 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007317MACHINE_END
7318
7319MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA")
7320 .boot_params = PHYS_OFFSET + 0x100,
7321 .map_io = msm7x30_map_io,
7322 .reserve = msm7x30_reserve,
7323 .init_irq = msm7x30_init_irq,
7324 .init_machine = msm7x30_init,
7325 .timer = &msm_timer,
7326 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307327 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307328 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007329MACHINE_END
7330MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
7331 .boot_params = PHYS_OFFSET + 0x100,
7332 .map_io = msm7x30_map_io,
7333 .reserve = msm7x30_reserve,
7334 .init_irq = msm7x30_init_irq,
7335 .init_machine = msm7x30_init,
7336 .timer = &msm_timer,
7337 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307338 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307339 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007340MACHINE_END
7341MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA")
7342 .boot_params = PHYS_OFFSET + 0x100,
7343 .map_io = msm7x30_map_io,
7344 .reserve = msm7x30_reserve,
7345 .init_irq = msm7x30_init_irq,
7346 .init_machine = msm7x30_init,
7347 .timer = &msm_timer,
7348 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307349 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307350 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007351MACHINE_END