blob: 3973bd172eaabb614dc90c23da92b168ac98400a [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 },
Sreesudhan Ramakrish Ramkumar66deac32012-04-05 10:15:38 -0700873 {
874 .csid_core = 0,
875 .is_vpe = 1,
876 .ioclk = {
877 .vfe_clk_rate = 153600000,
878 },
879 },
Kiran Kumar H N305c53b2012-03-24 14:14:13 -0700880};
881
882static struct camera_vreg_t msm_7x30_back_cam_vreg[] = {
883 {"gp2", REG_LDO, 2600000, 2600000, -1},
884 {"lvsw1", REG_VS, 0, 0, 0},
885};
886
887static uint32_t camera_off_gpio_table[] = {
888 /* parallel CAMERA interfaces */
889 /* RST */
890 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
891 /* DAT2 */
892 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
893 /* DAT3 */
894 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
895 /* DAT4 */
896 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
897 /* DAT5 */
898 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
899 /* DAT6 */
900 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
901 /* DAT7 */
902 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
903 /* DAT8 */
904 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
905 /* DAT9 */
906 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
907 /* DAT10 */
908 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
909 /* DAT11 */
910 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
911 /* PCLK */
912 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
913 /* HSYNC_IN */
914 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
915 /* VSYNC_IN */
916 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
917 /* MCLK */
918 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
919};
920
921static uint32_t camera_on_gpio_table[] = {
922 /* parallel CAMERA interfaces */
923 /* RST */
924 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
925 /* DAT2 */
926 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
927 /* DAT3 */
928 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
929 /* DAT4 */
930 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
931 /* DAT5 */
932 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
933 /* DAT6 */
934 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
935 /* DAT7 */
936 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
937 /* DAT8 */
938 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
939 /* DAT9 */
940 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
941 /* DAT10 */
942 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
943 /* DAT11 */
944 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
945 /* PCLK */
946 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
947 /* HSYNC_IN */
948 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
949 /* VSYNC_IN */
950 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
951 /* MCLK */
952 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
953};
954
955static struct gpio msm7x30_back_cam_gpio[] = {
956 {0, GPIOF_DIR_OUT, "CAM_RESET"},
957};
958
959static struct msm_gpio_set_tbl msm7x30_back_cam_gpio_set_tbl[] = {
960 {0, GPIOF_OUT_INIT_LOW, 1000},
961 {0, GPIOF_OUT_INIT_HIGH, 4000},
962};
963
964static struct msm_camera_gpio_conf msm_7x30_back_cam_gpio_conf = {
965 .cam_gpio_req_tbl = msm7x30_back_cam_gpio,
966 .cam_gpio_req_tbl_size = ARRAY_SIZE(msm7x30_back_cam_gpio),
967 .cam_gpio_set_tbl = msm7x30_back_cam_gpio_set_tbl,
968 .cam_gpio_set_tbl_size = ARRAY_SIZE(msm7x30_back_cam_gpio_set_tbl),
969 .camera_off_table = camera_off_gpio_table,
970 .camera_off_table_size = ARRAY_SIZE(camera_off_gpio_table),
971 .camera_on_table = camera_on_gpio_table,
972 .camera_on_table_size = ARRAY_SIZE(camera_on_gpio_table),
973 .gpio_no_mux = 1,
974};
975
976static struct msm_camera_sensor_flash_data flash_vx6953 = {
977 .flash_type = MSM_CAMERA_FLASH_NONE,
978};
979
980static struct msm_camera_sensor_platform_info sensor_board_info_vx6953 = {
981 .mount_angle = 0,
982 .cam_vreg = msm_7x30_back_cam_vreg,
983 .num_vreg = ARRAY_SIZE(msm_7x30_back_cam_vreg),
984 .gpio_conf = &msm_7x30_back_cam_gpio_conf,
985};
986
987static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
988 .sensor_name = "vx6953",
989 .pdata = &msm_camera_csi_device_data[0],
990 .flash_data = &flash_vx6953,
991 .sensor_platform_info = &sensor_board_info_vx6953,
992 .csi_if = 1,
993 .camera_type = BACK_CAMERA_2D,
994};
995
996void __init msm7x30_init_cam(void)
997{
998 platform_device_register(&msm_device_csic0);
999 platform_device_register(&msm_device_vfe);
1000 platform_device_register(&msm_device_vpe);
1001}
1002
1003#ifdef CONFIG_I2C
1004static struct i2c_board_info msm_camera_boardinfo[] = {
1005 {
1006 I2C_BOARD_INFO("vx6953", 0x20),
1007 .platform_data = &msm_camera_sensor_vx6953_data,
1008 },
1009};
1010#endif
1011#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001012static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
1013#ifdef CONFIG_MT9D112
1014 {
1015 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
Dima Zavinba5499e2011-01-10 11:00:30 -08001016 },
1017#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001018#ifdef CONFIG_WEBCAM_OV9726
1019 {
1020 I2C_BOARD_INFO("ov9726", 0x10),
1021 },
1022#endif
1023#ifdef CONFIG_S5K3E2FX
1024 {
1025 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
1026 },
1027#endif
1028#ifdef CONFIG_MT9P012
1029 {
1030 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
1031 },
1032#endif
1033#ifdef CONFIG_VX6953
1034 {
1035 I2C_BOARD_INFO("vx6953", 0x20),
1036 },
1037#endif
1038#ifdef CONFIG_MT9E013
1039 {
1040 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
1041 },
1042#endif
1043#ifdef CONFIG_SN12M0PZ
1044 {
1045 I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1),
1046 },
1047#endif
1048#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
1049 {
1050 I2C_BOARD_INFO("mt9t013", 0x6C),
1051 },
1052#endif
1053
Dima Zavinba5499e2011-01-10 11:00:30 -08001054};
1055
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001056#ifdef CONFIG_MSM_CAMERA
1057#define CAM_STNDBY 143
1058static uint32_t camera_off_vcm_gpio_table[] = {
1059GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */
1060};
1061
1062static uint32_t camera_off_gpio_table[] = {
1063 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001064 /* RST */
1065 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1066 /* DAT2 */
1067 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1068 /* DAT3 */
1069 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1070 /* DAT4 */
1071 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1072 /* DAT5 */
1073 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1074 /* DAT6 */
1075 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1076 /* DAT7 */
1077 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1078 /* DAT8 */
1079 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1080 /* DAT9 */
1081 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1082 /* DAT10 */
1083 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1084 /* DAT11 */
1085 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1086 /* PCLK */
1087 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1088 /* HSYNC_IN */
1089 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1090 /* VSYNC_IN */
1091 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1092 /* MCLK */
1093 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001094};
1095
1096static uint32_t camera_on_vcm_gpio_table[] = {
1097GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */
1098};
1099
1100static uint32_t camera_on_gpio_table[] = {
1101 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001102 /* RST */
1103 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1104 /* DAT2 */
1105 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1106 /* DAT3 */
1107 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1108 /* DAT4 */
1109 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1110 /* DAT5 */
1111 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1112 /* DAT6 */
1113 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1114 /* DAT7 */
1115 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1116 /* DAT8 */
1117 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1118 /* DAT9 */
1119 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1120 /* DAT10 */
1121 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1122 /* DAT11 */
1123 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1124 /* PCLK */
1125 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1126 /* HSYNC_IN */
1127 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1128 /* VSYNC_IN */
1129 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1130 /* MCLK */
1131 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001132};
1133
1134static uint32_t camera_off_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 uint32_t camera_on_gpio_fluid_table[] = {
1142 /* FLUID: CAM_VGA_RST_N */
1143 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1144 /* FLUID: CAMIF_STANDBY */
1145 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1146};
1147
1148static void config_gpio_table(uint32_t *table, int len)
1149{
1150 int n, rc;
1151 for (n = 0; n < len; n++) {
1152 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
1153 if (rc) {
1154 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
1155 __func__, table[n], rc);
1156 break;
1157 }
1158 }
1159}
1160static int config_camera_on_gpios(void)
1161{
1162 config_gpio_table(camera_on_gpio_table,
1163 ARRAY_SIZE(camera_on_gpio_table));
1164
1165 if (adie_get_detected_codec_type() != TIMPANI_ID)
1166 /* GPIO1 is shared also used in Timpani RF card so
1167 only configure it for non-Timpani RF card */
1168 config_gpio_table(camera_on_vcm_gpio_table,
1169 ARRAY_SIZE(camera_on_vcm_gpio_table));
1170
1171 if (machine_is_msm7x30_fluid()) {
1172 config_gpio_table(camera_on_gpio_fluid_table,
1173 ARRAY_SIZE(camera_on_gpio_fluid_table));
1174 /* FLUID: turn on 5V booster */
1175 gpio_set_value(
1176 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 1);
1177 /* FLUID: drive high to put secondary sensor to STANDBY */
1178 gpio_set_value(CAM_STNDBY, 1);
1179 }
1180 return 0;
1181}
1182
1183static void config_camera_off_gpios(void)
1184{
1185 config_gpio_table(camera_off_gpio_table,
1186 ARRAY_SIZE(camera_off_gpio_table));
1187
1188 if (adie_get_detected_codec_type() != TIMPANI_ID)
1189 /* GPIO1 is shared also used in Timpani RF card so
1190 only configure it for non-Timpani RF card */
1191 config_gpio_table(camera_off_vcm_gpio_table,
1192 ARRAY_SIZE(camera_off_vcm_gpio_table));
1193
1194 if (machine_is_msm7x30_fluid()) {
1195 config_gpio_table(camera_off_gpio_fluid_table,
1196 ARRAY_SIZE(camera_off_gpio_fluid_table));
1197 /* FLUID: turn off 5V booster */
1198 gpio_set_value(
1199 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 0);
1200 }
1201}
1202
1203struct resource msm_camera_resources[] = {
1204 {
1205 .start = 0xA6000000,
1206 .end = 0xA6000000 + SZ_1M - 1,
1207 .flags = IORESOURCE_MEM,
1208 },
1209 {
1210 .start = INT_VFE,
1211 .end = INT_VFE,
1212 .flags = IORESOURCE_IRQ,
1213 },
1214 {
1215 .flags = IORESOURCE_DMA,
1216 }
1217};
1218
1219struct msm_camera_device_platform_data msm_camera_device_data = {
1220 .camera_gpio_on = config_camera_on_gpios,
1221 .camera_gpio_off = config_camera_off_gpios,
1222 .ioext.camifpadphy = 0xAB000000,
1223 .ioext.camifpadsz = 0x00000400,
1224 .ioext.csiphy = 0xA6100000,
1225 .ioext.csisz = 0x00000400,
1226 .ioext.csiirq = INT_CSI,
1227 .ioclk.mclk_clk_rate = 24000000,
1228 .ioclk.vfe_clk_rate = 147456000,
1229};
1230
1231static struct msm_camera_sensor_flash_src msm_flash_src_pwm = {
1232 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PWM,
1233 ._fsrc.pwm_src.freq = 1000,
1234 ._fsrc.pwm_src.max_load = 300,
1235 ._fsrc.pwm_src.low_load = 30,
1236 ._fsrc.pwm_src.high_load = 100,
1237 ._fsrc.pwm_src.channel = 7,
1238};
1239
1240#ifdef CONFIG_MT9D112
1241static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1242 .flash_type = MSM_CAMERA_FLASH_LED,
1243 .flash_src = &msm_flash_src_pwm
1244};
1245
1246static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1247 .sensor_name = "mt9d112",
1248 .sensor_reset = 0,
1249 .sensor_pwd = 85,
1250 .vcm_pwd = 1,
1251 .vcm_enable = 0,
1252 .pdata = &msm_camera_device_data,
1253 .resource = msm_camera_resources,
1254 .num_resources = ARRAY_SIZE(msm_camera_resources),
1255 .flash_data = &flash_mt9d112,
1256 .csi_if = 0
1257};
1258
1259static struct platform_device msm_camera_sensor_mt9d112 = {
1260 .name = "msm_camera_mt9d112",
1261 .dev = {
1262 .platform_data = &msm_camera_sensor_mt9d112_data,
1263 },
1264};
1265#endif
1266
1267#ifdef CONFIG_WEBCAM_OV9726
1268
1269static struct msm_camera_sensor_platform_info ov9726_sensor_7630_info = {
1270 .mount_angle = 90
1271};
1272
1273static struct msm_camera_sensor_flash_data flash_ov9726 = {
1274 .flash_type = MSM_CAMERA_FLASH_LED,
1275 .flash_src = &msm_flash_src_pwm
1276};
1277static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
1278 .sensor_name = "ov9726",
1279 .sensor_reset = 0,
1280 .sensor_pwd = 85,
1281 .vcm_pwd = 1,
1282 .vcm_enable = 0,
1283 .pdata = &msm_camera_device_data,
1284 .resource = msm_camera_resources,
1285 .num_resources = ARRAY_SIZE(msm_camera_resources),
1286 .flash_data = &flash_ov9726,
1287 .sensor_platform_info = &ov9726_sensor_7630_info,
1288 .csi_if = 1
1289};
1290struct platform_device msm_camera_sensor_ov9726 = {
1291 .name = "msm_camera_ov9726",
1292 .dev = {
1293 .platform_data = &msm_camera_sensor_ov9726_data,
1294 },
1295};
1296#endif
1297
1298#ifdef CONFIG_S5K3E2FX
1299static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1300 .flash_type = MSM_CAMERA_FLASH_LED,
1301 .flash_src = &msm_flash_src_pwm,
1302};
1303
1304static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1305 .sensor_name = "s5k3e2fx",
1306 .sensor_reset = 0,
1307 .sensor_pwd = 85,
1308 .vcm_pwd = 1,
1309 .vcm_enable = 0,
1310 .pdata = &msm_camera_device_data,
1311 .resource = msm_camera_resources,
1312 .num_resources = ARRAY_SIZE(msm_camera_resources),
1313 .flash_data = &flash_s5k3e2fx,
1314 .csi_if = 0
1315};
1316
1317static struct platform_device msm_camera_sensor_s5k3e2fx = {
1318 .name = "msm_camera_s5k3e2fx",
1319 .dev = {
1320 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1321 },
1322};
1323#endif
1324
1325#ifdef CONFIG_MT9P012
1326static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1327 .flash_type = MSM_CAMERA_FLASH_LED,
1328 .flash_src = &msm_flash_src_pwm
1329};
1330
1331static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1332 .sensor_name = "mt9p012",
1333 .sensor_reset = 0,
1334 .sensor_pwd = 85,
1335 .vcm_pwd = 1,
1336 .vcm_enable = 1,
1337 .pdata = &msm_camera_device_data,
1338 .resource = msm_camera_resources,
1339 .num_resources = ARRAY_SIZE(msm_camera_resources),
1340 .flash_data = &flash_mt9p012,
1341 .csi_if = 0
1342};
1343
1344static struct platform_device msm_camera_sensor_mt9p012 = {
1345 .name = "msm_camera_mt9p012",
1346 .dev = {
1347 .platform_data = &msm_camera_sensor_mt9p012_data,
1348 },
1349};
1350#endif
1351
1352#ifdef CONFIG_MT9E013
1353static struct msm_camera_sensor_platform_info mt9e013_sensor_7630_info = {
1354 .mount_angle = 0
1355};
1356
1357static struct msm_camera_sensor_flash_data flash_mt9e013 = {
1358 .flash_type = MSM_CAMERA_FLASH_LED,
1359 .flash_src = &msm_flash_src_pwm
1360};
1361
1362static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
1363 .sensor_name = "mt9e013",
1364 .sensor_reset = 0,
1365 .sensor_pwd = 85,
1366 .vcm_pwd = 1,
1367 .vcm_enable = 1,
1368 .pdata = &msm_camera_device_data,
1369 .resource = msm_camera_resources,
1370 .num_resources = ARRAY_SIZE(msm_camera_resources),
1371 .flash_data = &flash_mt9e013,
1372 .sensor_platform_info = &mt9e013_sensor_7630_info,
1373 .csi_if = 1
1374};
1375
1376static struct platform_device msm_camera_sensor_mt9e013 = {
1377 .name = "msm_camera_mt9e013",
1378 .dev = {
1379 .platform_data = &msm_camera_sensor_mt9e013_data,
1380 },
1381};
1382#endif
1383
1384#ifdef CONFIG_VX6953
Jilai Wang971f97f2011-07-13 14:25:25 -04001385static struct msm_camera_sensor_platform_info vx6953_sensor_7630_info = {
1386 .mount_angle = 0
1387};
1388
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001389static struct msm_camera_sensor_flash_data flash_vx6953 = {
1390 .flash_type = MSM_CAMERA_FLASH_LED,
1391 .flash_src = &msm_flash_src_pwm
1392};
1393static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1394 .sensor_name = "vx6953",
1395 .sensor_reset = 0,
1396 .sensor_pwd = 85,
1397 .vcm_pwd = 1,
1398 .vcm_enable = 0,
1399 .pdata = &msm_camera_device_data,
1400 .resource = msm_camera_resources,
1401 .num_resources = ARRAY_SIZE(msm_camera_resources),
Jilai Wang971f97f2011-07-13 14:25:25 -04001402 .sensor_platform_info = &vx6953_sensor_7630_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001403 .flash_data = &flash_vx6953,
1404 .csi_if = 1
1405};
1406static struct platform_device msm_camera_sensor_vx6953 = {
1407 .name = "msm_camera_vx6953",
1408 .dev = {
1409 .platform_data = &msm_camera_sensor_vx6953_data,
1410 },
1411};
1412#endif
1413
1414#ifdef CONFIG_SN12M0PZ
1415static struct msm_camera_sensor_flash_src msm_flash_src_current_driver = {
1416 .flash_sr_type = MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER,
1417 ._fsrc.current_driver_src.low_current = 210,
1418 ._fsrc.current_driver_src.high_current = 700,
1419 ._fsrc.current_driver_src.driver_channel = &pm8058_fluid_leds_data,
1420};
1421
1422static struct msm_camera_sensor_flash_data flash_sn12m0pz = {
1423 .flash_type = MSM_CAMERA_FLASH_LED,
1424 .flash_src = &msm_flash_src_current_driver
1425};
1426static struct msm_camera_sensor_info msm_camera_sensor_sn12m0pz_data = {
1427 .sensor_name = "sn12m0pz",
1428 .sensor_reset = 0,
1429 .sensor_pwd = 85,
1430 .vcm_pwd = 1,
1431 .vcm_enable = 1,
1432 .pdata = &msm_camera_device_data,
1433 .flash_data = &flash_sn12m0pz,
1434 .resource = msm_camera_resources,
1435 .num_resources = ARRAY_SIZE(msm_camera_resources),
1436 .csi_if = 0
1437};
1438
1439static struct platform_device msm_camera_sensor_sn12m0pz = {
1440 .name = "msm_camera_sn12m0pz",
1441 .dev = {
1442 .platform_data = &msm_camera_sensor_sn12m0pz_data,
1443 },
1444};
1445#endif
1446
1447#ifdef CONFIG_MT9T013
1448static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1449 .flash_type = MSM_CAMERA_FLASH_LED,
1450 .flash_src = &msm_flash_src_pwm
1451};
1452
1453static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1454 .sensor_name = "mt9t013",
1455 .sensor_reset = 0,
1456 .sensor_pwd = 85,
1457 .vcm_pwd = 1,
1458 .vcm_enable = 0,
1459 .pdata = &msm_camera_device_data,
1460 .resource = msm_camera_resources,
1461 .num_resources = ARRAY_SIZE(msm_camera_resources),
1462 .flash_data = &flash_mt9t013,
1463 .csi_if = 1
1464};
1465
1466static struct platform_device msm_camera_sensor_mt9t013 = {
1467 .name = "msm_camera_mt9t013",
1468 .dev = {
1469 .platform_data = &msm_camera_sensor_mt9t013_data,
1470 },
1471};
1472#endif
1473
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001474#ifdef CONFIG_MSM_VPE
1475static struct resource msm_vpe_resources[] = {
1476 {
1477 .start = 0xAD200000,
1478 .end = 0xAD200000 + SZ_1M - 1,
1479 .flags = IORESOURCE_MEM,
1480 },
1481 {
1482 .start = INT_VPE,
1483 .end = INT_VPE,
1484 .flags = IORESOURCE_IRQ,
1485 },
1486};
1487
1488static struct platform_device msm_vpe_device = {
1489 .name = "msm_vpe",
1490 .id = 0,
1491 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1492 .resource = msm_vpe_resources,
1493};
1494#endif
1495
1496#endif /*CONFIG_MSM_CAMERA*/
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001497#endif
1498
1499#ifdef CONFIG_MSM_GEMINI
1500static struct resource msm_gemini_resources[] = {
1501 {
1502 .start = 0xA3A00000,
1503 .end = 0xA3A00000 + 0x0150 - 1,
1504 .flags = IORESOURCE_MEM,
1505 },
1506 {
1507 .start = INT_JPEG,
1508 .end = INT_JPEG,
1509 .flags = IORESOURCE_IRQ,
1510 },
1511};
1512
1513static struct platform_device msm_gemini_device = {
1514 .name = "msm_gemini",
1515 .resource = msm_gemini_resources,
1516 .num_resources = ARRAY_SIZE(msm_gemini_resources),
1517};
1518#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001519
1520#ifdef CONFIG_MSM7KV2_AUDIO
1521static uint32_t audio_pamp_gpio_config =
1522 GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1523
1524static uint32_t audio_fluid_icodec_tx_config =
1525 GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1526
1527static int __init snddev_poweramp_gpio_init(void)
1528{
1529 int rc;
1530
1531 pr_info("snddev_poweramp_gpio_init \n");
1532 rc = gpio_tlmm_config(audio_pamp_gpio_config, GPIO_CFG_ENABLE);
1533 if (rc) {
1534 printk(KERN_ERR
1535 "%s: gpio_tlmm_config(%#x)=%d\n",
1536 __func__, audio_pamp_gpio_config, rc);
1537 }
1538 return rc;
1539}
1540
1541void msm_snddev_tx_route_config(void)
1542{
1543 int rc;
1544
1545 pr_debug("%s()\n", __func__);
1546
1547 if (machine_is_msm7x30_fluid()) {
1548 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1549 GPIO_CFG_ENABLE);
1550 if (rc) {
1551 printk(KERN_ERR
1552 "%s: gpio_tlmm_config(%#x)=%d\n",
1553 __func__, audio_fluid_icodec_tx_config, rc);
1554 } else
1555 gpio_set_value(85, 0);
1556 }
1557}
1558
1559void msm_snddev_tx_route_deconfig(void)
1560{
1561 int rc;
1562
1563 pr_debug("%s()\n", __func__);
1564
1565 if (machine_is_msm7x30_fluid()) {
1566 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1567 GPIO_CFG_DISABLE);
1568 if (rc) {
1569 printk(KERN_ERR
1570 "%s: gpio_tlmm_config(%#x)=%d\n",
1571 __func__, audio_fluid_icodec_tx_config, rc);
1572 }
1573 }
1574}
1575
1576void msm_snddev_poweramp_on(void)
1577{
1578 gpio_set_value(82, 1); /* enable spkr poweramp */
1579 pr_info("%s: power on amplifier\n", __func__);
1580}
1581
1582void msm_snddev_poweramp_off(void)
1583{
1584 gpio_set_value(82, 0); /* disable spkr poweramp */
1585 pr_info("%s: power off amplifier\n", __func__);
1586}
1587
Justin Paupore3f40f342011-08-10 18:52:16 -07001588static struct regulator_bulk_data snddev_regs[] = {
1589 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
1590 { .supply = "ncp", .min_uV = 1800000, .max_uV = 1800000 },
1591};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001592
Justin Paupore3f40f342011-08-10 18:52:16 -07001593static int __init snddev_hsed_voltage_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001594{
1595 int rc;
1596
Justin Paupore3f40f342011-08-10 18:52:16 -07001597 rc = regulator_bulk_get(NULL, ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001598
Justin Paupore3f40f342011-08-10 18:52:16 -07001599 if (rc) {
1600 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1601 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001602 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001603
1604 rc = regulator_bulk_set_voltage(ARRAY_SIZE(snddev_regs), snddev_regs);
1605
1606 if (rc) {
1607 pr_err("%s: could not set regulator voltages: %d\n",
1608 __func__, rc);
1609 goto regs_free;
1610 }
1611
1612 return 0;
1613
1614regs_free:
1615 regulator_bulk_free(ARRAY_SIZE(snddev_regs), snddev_regs);
1616out:
1617 return rc;
1618}
1619
1620
1621void msm_snddev_hsed_voltage_on(void)
1622{
1623 int rc = regulator_bulk_enable(ARRAY_SIZE(snddev_regs), snddev_regs);
1624
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001625 if (rc)
Justin Paupore3f40f342011-08-10 18:52:16 -07001626 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001627}
1628
1629void msm_snddev_hsed_voltage_off(void)
1630{
Justin Paupore3f40f342011-08-10 18:52:16 -07001631 int rc = regulator_bulk_disable(ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001632
Justin Paupore3f40f342011-08-10 18:52:16 -07001633 if (rc) {
1634 pr_err("%s: could not disable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001635 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001636}
1637
1638static unsigned aux_pcm_gpio_on[] = {
1639 GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
1640 GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
1641 GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
1642 GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
1643};
1644
1645static int __init aux_pcm_gpio_init(void)
1646{
1647 int pin, rc;
1648
1649 pr_info("aux_pcm_gpio_init \n");
1650 for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) {
1651 rc = gpio_tlmm_config(aux_pcm_gpio_on[pin],
1652 GPIO_CFG_ENABLE);
1653 if (rc) {
1654 printk(KERN_ERR
1655 "%s: gpio_tlmm_config(%#x)=%d\n",
1656 __func__, aux_pcm_gpio_on[pin], rc);
1657 }
1658 }
1659 return rc;
1660}
1661
1662static struct msm_gpio mi2s_clk_gpios[] = {
1663 { GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1664 "MI2S_SCLK"},
1665 { GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1666 "MI2S_WS"},
1667 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1668 "MI2S_MCLK_A"},
1669};
1670
1671static struct msm_gpio mi2s_rx_data_lines_gpios[] = {
1672 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1673 "MI2S_DATA_SD0_A"},
1674 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1675 "MI2S_DATA_SD1_A"},
1676 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1677 "MI2S_DATA_SD2_A"},
1678 { GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1679 "MI2S_DATA_SD3"},
1680};
1681
1682static struct msm_gpio mi2s_tx_data_lines_gpios[] = {
1683 { GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1684 "MI2S_DATA_SD3"},
1685};
1686
1687int mi2s_config_clk_gpio(void)
1688{
1689 int rc = 0;
1690
1691 rc = msm_gpios_request_enable(mi2s_clk_gpios,
1692 ARRAY_SIZE(mi2s_clk_gpios));
1693 if (rc) {
1694 pr_err("%s: enable mi2s clk gpios failed\n",
1695 __func__);
1696 return rc;
1697 }
1698 return 0;
1699}
1700
1701int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask)
1702{
1703 int i, rc = 0;
1704 sd_line_mask &= MI2S_SD_LINE_MASK;
1705
1706 switch (direction) {
1707 case DIR_TX:
1708 msm_gpios_disable_free(mi2s_tx_data_lines_gpios, 1);
1709 break;
1710 case DIR_RX:
1711 i = 0;
1712 while (sd_line_mask) {
1713 if (sd_line_mask & 0x1)
1714 msm_gpios_disable_free(
1715 mi2s_rx_data_lines_gpios + i , 1);
1716 sd_line_mask = sd_line_mask >> 1;
1717 i++;
1718 }
1719 break;
1720 default:
1721 pr_err("%s: Invaild direction direction = %u\n",
1722 __func__, direction);
1723 rc = -EINVAL;
1724 break;
1725 }
1726 return rc;
1727}
1728
1729int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask)
1730{
1731 int i , rc = 0;
1732 u8 sd_config_done_mask = 0;
1733
1734 sd_line_mask &= MI2S_SD_LINE_MASK;
1735
1736 switch (direction) {
1737 case DIR_TX:
1738 if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) ||
1739 (sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) {
1740 pr_err("%s: can not use SD0 or SD1 or SD2 for TX"
1741 ".only can use SD3. sd_line_mask = 0x%x\n",
1742 __func__ , sd_line_mask);
1743 rc = -EINVAL;
1744 } else {
1745 rc = msm_gpios_request_enable(mi2s_tx_data_lines_gpios,
1746 1);
1747 if (rc)
1748 pr_err("%s: enable mi2s gpios for TX failed\n",
1749 __func__);
1750 }
1751 break;
1752 case DIR_RX:
1753 i = 0;
1754 while (sd_line_mask && (rc == 0)) {
1755 if (sd_line_mask & 0x1) {
1756 rc = msm_gpios_request_enable(
1757 mi2s_rx_data_lines_gpios + i , 1);
1758 if (rc) {
1759 pr_err("%s: enable mi2s gpios for"
1760 "RX failed. SD line = %s\n",
1761 __func__,
1762 (mi2s_rx_data_lines_gpios + i)->label);
1763 mi2s_unconfig_data_gpio(DIR_RX,
1764 sd_config_done_mask);
1765 } else
1766 sd_config_done_mask |= (1 << i);
1767 }
1768 sd_line_mask = sd_line_mask >> 1;
1769 i++;
1770 }
1771 break;
1772 default:
1773 pr_err("%s: Invaild direction direction = %u\n",
1774 __func__, direction);
1775 rc = -EINVAL;
1776 break;
1777 }
1778 return rc;
1779}
1780
1781int mi2s_unconfig_clk_gpio(void)
1782{
1783 msm_gpios_disable_free(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios));
1784 return 0;
1785}
1786
1787#endif /* CONFIG_MSM7KV2_AUDIO */
1788
1789static int __init buses_init(void)
1790{
1791 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT,
1792 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
1793 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
1794 __func__, PMIC_GPIO_INT);
1795
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301796 if (machine_is_msm8x60_fluid())
1797 pm8058_7x30_data.keypad_pdata = &fluid_keypad_data;
1798 else
1799 pm8058_7x30_data.keypad_pdata = &surf_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001800
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001801 return 0;
1802}
1803
1804#define TIMPANI_RESET_GPIO 1
1805
1806struct bahama_config_register{
1807 u8 reg;
1808 u8 value;
1809 u8 mask;
1810};
1811
1812enum version{
1813 VER_1_0,
1814 VER_2_0,
1815 VER_UNSUPPORTED = 0xFF
1816};
1817
Justin Paupore3f40f342011-08-10 18:52:16 -07001818static struct regulator *vreg_marimba_1;
1819static struct regulator *vreg_marimba_2;
1820static struct regulator *vreg_bahama;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001821
1822static struct msm_gpio timpani_reset_gpio_cfg[] = {
1823{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
1824 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} };
1825
1826static u8 read_bahama_ver(void)
1827{
1828 int rc;
1829 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1830 u8 bahama_version;
1831
1832 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
1833 if (rc < 0) {
1834 printk(KERN_ERR
1835 "%s: version read failed: %d\n",
1836 __func__, rc);
1837 return rc;
1838 } else {
1839 printk(KERN_INFO
1840 "%s: version read got: 0x%x\n",
1841 __func__, bahama_version);
1842 }
1843
1844 switch (bahama_version) {
1845 case 0x08: /* varient of bahama v1 */
1846 case 0x10:
1847 case 0x00:
1848 return VER_1_0;
1849 case 0x09: /* variant of bahama v2 */
1850 return VER_2_0;
1851 default:
1852 return VER_UNSUPPORTED;
1853 }
1854}
1855
1856static int config_timpani_reset(void)
1857{
1858 int rc;
1859
1860 rc = msm_gpios_request_enable(timpani_reset_gpio_cfg,
1861 ARRAY_SIZE(timpani_reset_gpio_cfg));
1862 if (rc < 0) {
1863 printk(KERN_ERR
1864 "%s: msm_gpios_request_enable failed (%d)\n",
1865 __func__, rc);
1866 }
1867 return rc;
1868}
1869
1870static unsigned int msm_timpani_setup_power(void)
1871{
1872 int rc;
1873
1874 rc = config_timpani_reset();
1875 if (rc < 0)
1876 goto out;
1877
Justin Paupore3f40f342011-08-10 18:52:16 -07001878 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001879 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001880 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001881 goto out;
1882 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001883
1884 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001885 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001886 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1887 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001888 }
1889
1890 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1);
1891 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001892 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001893 __func__, rc);
1894 msm_gpios_free(timpani_reset_gpio_cfg,
1895 ARRAY_SIZE(timpani_reset_gpio_cfg));
Justin Paupore3f40f342011-08-10 18:52:16 -07001896 goto disable_marimba_2;
1897 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001898
Justin Paupore3f40f342011-08-10 18:52:16 -07001899 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001900
Justin Paupore3f40f342011-08-10 18:52:16 -07001901disable_marimba_2:
1902 regulator_disable(vreg_marimba_2);
1903disable_marimba_1:
1904 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001905out:
1906 return rc;
1907};
1908
1909static void msm_timpani_shutdown_power(void)
1910{
1911 int rc;
1912
Justin Paupore3f40f342011-08-10 18:52:16 -07001913 rc = regulator_disable(vreg_marimba_2);
1914 if (rc)
1915 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1916
1917 rc = regulator_disable(vreg_marimba_1);
1918 if (rc)
1919 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001920
1921 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0);
Justin Paupore3f40f342011-08-10 18:52:16 -07001922 if (rc < 0)
1923 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001924 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001925
1926 msm_gpios_free(timpani_reset_gpio_cfg,
1927 ARRAY_SIZE(timpani_reset_gpio_cfg));
1928};
1929
1930static unsigned int msm_bahama_core_config(int type)
1931{
1932 int rc = 0;
1933
1934 if (type == BAHAMA_ID) {
1935
1936 int i;
1937 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1938
1939 const struct bahama_config_register v20_init[] = {
1940 /* reg, value, mask */
1941 { 0xF4, 0x84, 0xFF }, /* AREG */
1942 { 0xF0, 0x04, 0xFF } /* DREG */
1943 };
1944
1945 if (read_bahama_ver() == VER_2_0) {
1946 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
1947 u8 value = v20_init[i].value;
1948 rc = marimba_write_bit_mask(&config,
1949 v20_init[i].reg,
1950 &value,
1951 sizeof(v20_init[i].value),
1952 v20_init[i].mask);
1953 if (rc < 0) {
1954 printk(KERN_ERR
1955 "%s: reg %d write failed: %d\n",
1956 __func__, v20_init[i].reg, rc);
1957 return rc;
1958 }
1959 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
1960 " mask 0x%02x\n",
1961 __func__, v20_init[i].reg,
1962 v20_init[i].value, v20_init[i].mask);
1963 }
1964 }
1965 }
1966 printk(KERN_INFO "core type: %d\n", type);
1967
1968 return rc;
1969}
1970
1971static unsigned int msm_bahama_setup_power(void)
1972{
Justin Paupore3f40f342011-08-10 18:52:16 -07001973 int rc = regulator_enable(vreg_bahama);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001974
Justin Paupore3f40f342011-08-10 18:52:16 -07001975 if (rc)
1976 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001977
1978 return rc;
1979};
1980
1981static unsigned int msm_bahama_shutdown_power(int value)
1982{
1983 int rc = 0;
1984
1985 if (value != BAHAMA_ID) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001986 rc = regulator_disable(vreg_bahama);
1987
1988 if (rc)
1989 pr_err("%s: regulator_disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001990 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001991 }
1992
1993 return rc;
1994};
1995
1996static struct msm_gpio marimba_svlte_config_clock[] = {
1997 { GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1998 "MARIMBA_SVLTE_CLOCK_ENABLE" },
1999};
2000
2001static unsigned int msm_marimba_gpio_config_svlte(int gpio_cfg_marimba)
2002{
2003 if (machine_is_msm8x55_svlte_surf() ||
2004 machine_is_msm8x55_svlte_ffa()) {
2005 if (gpio_cfg_marimba)
2006 gpio_set_value(GPIO_PIN
2007 (marimba_svlte_config_clock->gpio_cfg), 1);
2008 else
2009 gpio_set_value(GPIO_PIN
2010 (marimba_svlte_config_clock->gpio_cfg), 0);
2011 }
2012
2013 return 0;
2014};
2015
2016static unsigned int msm_marimba_setup_power(void)
2017{
2018 int rc;
2019
Justin Paupore3f40f342011-08-10 18:52:16 -07002020 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002021 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002022 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002023 goto out;
2024 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002025
2026 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002027 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002028 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2029 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002030 }
2031
2032 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
2033 rc = msm_gpios_request_enable(marimba_svlte_config_clock,
2034 ARRAY_SIZE(marimba_svlte_config_clock));
2035 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002036 pr_err("%s: msm_gpios_request_enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002037 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002038 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002039 }
2040
2041 rc = gpio_direction_output(GPIO_PIN
2042 (marimba_svlte_config_clock->gpio_cfg), 0);
2043 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002044 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002045 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002046 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002047 }
2048 }
2049
Justin Paupore3f40f342011-08-10 18:52:16 -07002050 return 0;
2051
2052disable_marimba_2:
2053 regulator_disable(vreg_marimba_2);
2054disable_marimba_1:
2055 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002056out:
2057 return rc;
2058};
2059
2060static void msm_marimba_shutdown_power(void)
2061{
2062 int rc;
2063
Justin Paupore3f40f342011-08-10 18:52:16 -07002064 rc = regulator_disable(vreg_marimba_2);
2065 if (rc)
2066 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
2067
2068 rc = regulator_disable(vreg_marimba_1);
2069 if (rc)
2070 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002071};
2072
2073static int bahama_present(void)
2074{
2075 int id;
2076 switch (id = adie_get_detected_connectivity_type()) {
2077 case BAHAMA_ID:
2078 return 1;
2079
2080 case MARIMBA_ID:
2081 return 0;
2082
2083 case TIMPANI_ID:
2084 default:
2085 printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n",
2086 __func__, id);
2087 return -ENODEV;
2088 }
2089}
2090
Justin Paupore3f40f342011-08-10 18:52:16 -07002091struct regulator *fm_regulator;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002092static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
2093{
Justin Paupore3f40f342011-08-10 18:52:16 -07002094 int rc, voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002095 uint32_t irqcfg;
2096 const char *id = "FMPW";
2097
2098 int bahama_not_marimba = bahama_present();
2099
Justin Paupore3f40f342011-08-10 18:52:16 -07002100 if (bahama_not_marimba < 0) {
2101 pr_warn("%s: bahama_present: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002102 __func__, bahama_not_marimba);
Justin Paupore3f40f342011-08-10 18:52:16 -07002103 rc = -ENODEV;
2104 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002105 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002106 if (bahama_not_marimba) {
2107 fm_regulator = regulator_get(NULL, "s3");
2108 voltage = 1800000;
2109 } else {
2110 fm_regulator = regulator_get(NULL, "s2");
2111 voltage = 1300000;
2112 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002113
2114 if (IS_ERR(fm_regulator)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002115 rc = PTR_ERR(fm_regulator);
2116 pr_err("%s: regulator_get failed (%d)\n", __func__, rc);
2117 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002118 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002119
Justin Paupore3f40f342011-08-10 18:52:16 -07002120 rc = regulator_set_voltage(fm_regulator, voltage, voltage);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002121
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002122 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002123 pr_err("%s: regulator_set_voltage failed (%d)\n", __func__, rc);
2124 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002125 }
2126
Justin Paupore3f40f342011-08-10 18:52:16 -07002127 rc = regulator_enable(fm_regulator);
2128
2129 if (rc) {
2130 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2131 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002132 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002133
2134 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_ON);
2135
2136 if (rc < 0) {
2137 pr_err("%s: clock vote failed (%d)\n", __func__, rc);
2138 goto regulator_disable;
2139 }
2140
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002141 /*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2142 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002143 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002144 rc = marimba_gpio_config(1);
Justin Paupore3f40f342011-08-10 18:52:16 -07002145 if (rc < 0) {
2146 pr_err("%s: clock enable for svlte : %d\n",
2147 __func__, rc);
2148 goto clock_devote;
2149 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002150 }
2151 irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
2152 GPIO_CFG_2MA);
2153 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2154 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002155 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002156 rc = -EIO;
Justin Paupore3f40f342011-08-10 18:52:16 -07002157 goto gpio_deconfig;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002158
2159 }
2160 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002161
Justin Paupore3f40f342011-08-10 18:52:16 -07002162gpio_deconfig:
2163 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa())
2164 marimba_gpio_config(0);
2165clock_devote:
2166 pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_OFF);
2167regulator_disable:
2168 regulator_disable(fm_regulator);
2169regulator_free:
2170 regulator_put(fm_regulator);
2171 fm_regulator = NULL;
2172out:
2173 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002174};
2175
2176static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
2177{
2178 int rc;
2179 const char *id = "FMPW";
2180 uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
2181 GPIO_CFG_2MA);
2182
2183 int bahama_not_marimba = bahama_present();
2184 if (bahama_not_marimba == -1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002185 pr_warn("%s: bahama_present: %d\n",
2186 __func__, bahama_not_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002187 return;
2188 }
2189
2190 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2191 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002192 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002193 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002194 if (!IS_ERR_OR_NULL(fm_regulator)) {
2195 rc = regulator_disable(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002196
Justin Paupore3f40f342011-08-10 18:52:16 -07002197 if (rc)
2198 pr_err("%s: return val: %d\n", __func__, rc);
2199
2200 regulator_put(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002201 fm_regulator = NULL;
2202 }
2203 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
2204 PMAPP_CLOCK_VOTE_OFF);
2205 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002206 pr_err("%s: clock_vote return val: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002207
2208 /*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2209 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002210 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002211 rc = marimba_gpio_config(0);
2212 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002213 pr_err("%s: clock disable for svlte : %d\n",
2214 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002215 }
2216}
2217
2218static struct marimba_fm_platform_data marimba_fm_pdata = {
2219 .fm_setup = fm_radio_setup,
2220 .fm_shutdown = fm_radio_shutdown,
2221 .irq = MSM_GPIO_TO_INT(147),
2222 .vreg_s2 = NULL,
2223 .vreg_xo_out = NULL,
2224 .is_fm_soc_i2s_master = false,
2225 .config_i2s_gpio = NULL,
2226};
2227
2228
2229/* Slave id address for FM/CDC/QMEMBIST
2230 * Values can be programmed using Marimba slave id 0
2231 * should there be a conflict with other I2C devices
2232 * */
2233#define MARIMBA_SLAVE_ID_FM_ADDR 0x2A
2234#define MARIMBA_SLAVE_ID_CDC_ADDR 0x77
2235#define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66
2236
2237#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
2238#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
2239
2240static const char *tsadc_id = "MADC";
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002241
Justin Paupore3f40f342011-08-10 18:52:16 -07002242static struct regulator_bulk_data regs_tsadc_marimba[] = {
2243 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2244 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002245};
Justin Paupore3f40f342011-08-10 18:52:16 -07002246
2247static struct regulator_bulk_data regs_tsadc_timpani[] = {
2248 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2249 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2250 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2251};
2252
2253static struct regulator_bulk_data *regs_tsadc;
2254static int regs_tsadc_count;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002255
2256static int marimba_tsadc_power(int vreg_on)
2257{
Justin Paupore3f40f342011-08-10 18:52:16 -07002258 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002259 int tsadc_adie_type = adie_get_detected_codec_type();
2260
Justin Paupore3f40f342011-08-10 18:52:16 -07002261 switch (tsadc_adie_type) {
2262 case TIMPANI_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002263 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2264 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2265 if (rc) {
2266 pr_err("%s: unable to %svote for d1 clk\n",
2267 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002268 goto D1_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002269 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002270
2271 /* fall through */
2272 case MARIMBA_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002273 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2274 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2275 if (rc) {
2276 pr_err("%s: unable to %svote for d1 clk\n",
2277 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002278 goto D0_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002279 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002280
Justin Paupore3f40f342011-08-10 18:52:16 -07002281 WARN_ON(regs_tsadc_count == 0);
2282
2283 rc = vreg_on ?
2284 regulator_bulk_enable(regs_tsadc_count, regs_tsadc) :
2285 regulator_bulk_disable(regs_tsadc_count, regs_tsadc);
2286
2287 if (rc) {
2288 pr_err("%s: regulator %sable failed: %d\n",
2289 __func__, vreg_on ? "en" : "dis", rc);
2290 goto regulator_switch_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002291 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002292
2293 break;
2294 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002295 pr_err("%s:Adie %d not supported\n",
2296 __func__, tsadc_adie_type);
2297 return -ENODEV;
2298 }
2299
2300 msleep(5); /* ensure power is stable */
2301
2302 return 0;
2303
Justin Paupore3f40f342011-08-10 18:52:16 -07002304regulator_switch_fail:
2305 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2306 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2307D0_vote_fail:
2308 if (tsadc_adie_type == TIMPANI_ID)
2309 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2310 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2311D1_vote_fail:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002312 return rc;
2313}
2314
2315static int marimba_tsadc_init(void)
2316{
Justin Paupore3f40f342011-08-10 18:52:16 -07002317 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002318 int tsadc_adie_type = adie_get_detected_codec_type();
2319
Justin Paupore3f40f342011-08-10 18:52:16 -07002320 switch (tsadc_adie_type) {
2321 case MARIMBA_ID:
2322 regs_tsadc = regs_tsadc_marimba;
2323 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_marimba);
2324 break;
2325 case TIMPANI_ID:
2326 regs_tsadc = regs_tsadc_timpani;
2327 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_timpani);
2328 break;
2329 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002330 pr_err("%s:Adie %d not supported\n",
2331 __func__, tsadc_adie_type);
Justin Paupore3f40f342011-08-10 18:52:16 -07002332 rc = -ENODEV;
2333 goto out;
2334 }
2335
2336 rc = regulator_bulk_get(NULL, regs_tsadc_count, regs_tsadc);
2337 if (rc) {
2338 pr_err("%s: could not get regulators: %d\n",
2339 __func__, rc);
2340 goto out;
2341 }
2342
2343 rc = regulator_bulk_set_voltage(regs_tsadc_count, regs_tsadc);
2344 if (rc) {
2345 pr_err("%s: could not set regulator voltages: %d\n",
2346 __func__, rc);
2347 goto vreg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002348 }
2349
2350 return 0;
2351
Justin Paupore3f40f342011-08-10 18:52:16 -07002352vreg_free:
2353 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2354out:
2355 regs_tsadc = NULL;
2356 regs_tsadc_count = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002357 return rc;
2358}
2359
2360static int marimba_tsadc_exit(void)
2361{
Justin Paupore3f40f342011-08-10 18:52:16 -07002362 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2363 regs_tsadc_count = 0;
2364 regs_tsadc = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002365
Justin Paupore3f40f342011-08-10 18:52:16 -07002366 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002367}
2368
2369
2370static struct msm_ts_platform_data msm_ts_data = {
Anirudh Ghayal82b74722012-01-19 15:35:34 +05302371 .min_x = 284,
2372 .max_x = 3801,
2373 .min_y = 155,
2374 .max_y = 3929,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002375 .min_press = 0,
2376 .max_press = 255,
2377 .inv_x = 4096,
2378 .inv_y = 4096,
2379 .can_wakeup = false,
2380};
2381
2382static struct marimba_tsadc_platform_data marimba_tsadc_pdata = {
2383 .marimba_tsadc_power = marimba_tsadc_power,
2384 .init = marimba_tsadc_init,
2385 .exit = marimba_tsadc_exit,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002386 .tsadc_prechg_en = true,
2387 .can_wakeup = false,
2388 .setup = {
2389 .pen_irq_en = true,
2390 .tsadc_en = true,
2391 },
2392 .params2 = {
2393 .input_clk_khz = 2400,
2394 .sample_prd = TSADC_CLK_3,
2395 },
2396 .params3 = {
2397 .prechg_time_nsecs = 6400,
2398 .stable_time_nsecs = 6400,
2399 .tsadc_test_mode = 0,
2400 },
2401 .tssc_data = &msm_ts_data,
2402};
2403
Justin Paupore3f40f342011-08-10 18:52:16 -07002404static struct regulator_bulk_data codec_regs[] = {
2405 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
2406};
2407
2408static int __init msm_marimba_codec_init(void)
2409{
2410 int rc = regulator_bulk_get(NULL, ARRAY_SIZE(codec_regs), codec_regs);
2411
2412 if (rc) {
2413 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2414 goto out;
2415 }
2416
2417 rc = regulator_bulk_set_voltage(ARRAY_SIZE(codec_regs), codec_regs);
2418 if (rc) {
2419 pr_err("%s: could not set regulator voltages: %d\n",
2420 __func__, rc);
2421 goto reg_free;
2422 }
2423
2424 return rc;
2425
2426reg_free:
2427 regulator_bulk_free(ARRAY_SIZE(codec_regs), codec_regs);
2428out:
2429 return rc;
2430}
2431
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002432static int msm_marimba_codec_power(int vreg_on)
2433{
Justin Paupore3f40f342011-08-10 18:52:16 -07002434 int rc = vreg_on ?
2435 regulator_bulk_enable(ARRAY_SIZE(codec_regs), codec_regs) :
2436 regulator_bulk_disable(ARRAY_SIZE(codec_regs), codec_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002437
Justin Paupore3f40f342011-08-10 18:52:16 -07002438 if (rc) {
2439 pr_err("%s: could not %sable regulators: %d",
2440 __func__, vreg_on ? "en" : "dis", rc);
2441 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002442 }
2443
Justin Paupore3f40f342011-08-10 18:52:16 -07002444 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002445}
2446
2447static struct marimba_codec_platform_data mariba_codec_pdata = {
2448 .marimba_codec_power = msm_marimba_codec_power,
2449#ifdef CONFIG_MARIMBA_CODEC
2450 .snddev_profile_init = msm_snddev_init,
2451#endif
2452};
2453
2454static struct marimba_platform_data marimba_pdata = {
2455 .slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR,
2456 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2457 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2458 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
2459 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
2460 .marimba_setup = msm_marimba_setup_power,
2461 .marimba_shutdown = msm_marimba_shutdown_power,
2462 .bahama_setup = msm_bahama_setup_power,
2463 .bahama_shutdown = msm_bahama_shutdown_power,
2464 .marimba_gpio_config = msm_marimba_gpio_config_svlte,
2465 .bahama_core_config = msm_bahama_core_config,
2466 .fm = &marimba_fm_pdata,
2467 .codec = &mariba_codec_pdata,
2468 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2469};
2470
2471static void __init msm7x30_init_marimba(void)
2472{
2473 int rc;
2474
Justin Paupore3f40f342011-08-10 18:52:16 -07002475 struct regulator_bulk_data regs[] = {
2476 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2477 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2478 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
2479 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002480
Justin Paupore3f40f342011-08-10 18:52:16 -07002481 rc = msm_marimba_codec_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002482
Justin Paupore3f40f342011-08-10 18:52:16 -07002483 if (rc) {
2484 pr_err("%s: msm_marimba_codec_init failed (%d)\n",
2485 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002486 return;
2487 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002488
2489 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
2490
2491 if (rc) {
2492 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2493 return;
2494 }
2495
2496 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
2497
2498 if (rc) {
2499 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2500 regulator_bulk_free(ARRAY_SIZE(regs), regs);
2501 return;
2502 }
2503
2504 vreg_marimba_1 = regs[0].consumer;
2505 vreg_marimba_2 = regs[1].consumer;
2506 vreg_bahama = regs[2].consumer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002507}
2508
2509static struct marimba_codec_platform_data timpani_codec_pdata = {
2510 .marimba_codec_power = msm_marimba_codec_power,
2511#ifdef CONFIG_TIMPANI_CODEC
2512 .snddev_profile_init = msm_snddev_init_timpani,
2513#endif
2514};
2515
2516static struct marimba_platform_data timpani_pdata = {
2517 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2518 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2519 .marimba_setup = msm_timpani_setup_power,
2520 .marimba_shutdown = msm_timpani_shutdown_power,
2521 .codec = &timpani_codec_pdata,
2522 .tsadc = &marimba_tsadc_pdata,
2523 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2524};
2525
2526#define TIMPANI_I2C_SLAVE_ADDR 0xD
2527
2528static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
2529 {
2530 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
2531 .platform_data = &timpani_pdata,
2532 },
2533};
2534
2535#ifdef CONFIG_MSM7KV2_AUDIO
2536static struct resource msm_aictl_resources[] = {
2537 {
2538 .name = "aictl",
2539 .start = 0xa5000100,
2540 .end = 0xa5000100,
2541 .flags = IORESOURCE_MEM,
2542 }
2543};
2544
2545static struct resource msm_mi2s_resources[] = {
2546 {
2547 .name = "hdmi",
2548 .start = 0xac900000,
2549 .end = 0xac900038,
2550 .flags = IORESOURCE_MEM,
2551 },
2552 {
2553 .name = "codec_rx",
2554 .start = 0xac940040,
2555 .end = 0xac940078,
2556 .flags = IORESOURCE_MEM,
2557 },
2558 {
2559 .name = "codec_tx",
2560 .start = 0xac980080,
2561 .end = 0xac9800B8,
2562 .flags = IORESOURCE_MEM,
2563 }
2564
2565};
2566
2567static struct msm_lpa_platform_data lpa_pdata = {
2568 .obuf_hlb_size = 0x2BFF8,
2569 .dsp_proc_id = 0,
2570 .app_proc_id = 2,
2571 .nosb_config = {
2572 .llb_min_addr = 0,
2573 .llb_max_addr = 0x3ff8,
2574 .sb_min_addr = 0,
2575 .sb_max_addr = 0,
2576 },
2577 .sb_config = {
2578 .llb_min_addr = 0,
2579 .llb_max_addr = 0x37f8,
2580 .sb_min_addr = 0x3800,
2581 .sb_max_addr = 0x3ff8,
2582 }
2583};
2584
2585static struct resource msm_lpa_resources[] = {
2586 {
2587 .name = "lpa",
2588 .start = 0xa5000000,
2589 .end = 0xa50000a0,
2590 .flags = IORESOURCE_MEM,
2591 }
2592};
2593
2594static struct resource msm_aux_pcm_resources[] = {
2595
2596 {
2597 .name = "aux_codec_reg_addr",
2598 .start = 0xac9c00c0,
2599 .end = 0xac9c00c8,
2600 .flags = IORESOURCE_MEM,
2601 },
2602 {
2603 .name = "aux_pcm_dout",
2604 .start = 138,
2605 .end = 138,
2606 .flags = IORESOURCE_IO,
2607 },
2608 {
2609 .name = "aux_pcm_din",
2610 .start = 139,
2611 .end = 139,
2612 .flags = IORESOURCE_IO,
2613 },
2614 {
2615 .name = "aux_pcm_syncout",
2616 .start = 140,
2617 .end = 140,
2618 .flags = IORESOURCE_IO,
2619 },
2620 {
2621 .name = "aux_pcm_clkin_a",
2622 .start = 141,
2623 .end = 141,
2624 .flags = IORESOURCE_IO,
2625 },
2626};
2627
2628static struct platform_device msm_aux_pcm_device = {
2629 .name = "msm_aux_pcm",
2630 .id = 0,
2631 .num_resources = ARRAY_SIZE(msm_aux_pcm_resources),
2632 .resource = msm_aux_pcm_resources,
2633};
2634
2635struct platform_device msm_aictl_device = {
2636 .name = "audio_interct",
2637 .id = 0,
2638 .num_resources = ARRAY_SIZE(msm_aictl_resources),
2639 .resource = msm_aictl_resources,
2640};
2641
2642struct platform_device msm_mi2s_device = {
2643 .name = "mi2s",
2644 .id = 0,
2645 .num_resources = ARRAY_SIZE(msm_mi2s_resources),
2646 .resource = msm_mi2s_resources,
2647};
2648
2649struct platform_device msm_lpa_device = {
2650 .name = "lpa",
2651 .id = 0,
2652 .num_resources = ARRAY_SIZE(msm_lpa_resources),
2653 .resource = msm_lpa_resources,
2654 .dev = {
2655 .platform_data = &lpa_pdata,
2656 },
2657};
2658#endif /* CONFIG_MSM7KV2_AUDIO */
2659
2660#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2661 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2662 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2663 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2664 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2665 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2666#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2667 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2668 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2669 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2670 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2671 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2672 #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2673 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2674 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2675 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2676 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2677 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2678 #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2679 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2680 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2681 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2682 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2683 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2684#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
2685
2686static unsigned int dec_concurrency_table[] = {
2687 /* Audio LP */
2688 0,
2689 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2690 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2691 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2692 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)|
2693 (1<<MSM_ADSP_OP_DM)),
2694
2695 /* Concurrency 1 */
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 2 */
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_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2708
2709 /* Concurrency 3 */
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_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2714 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2715
2716 /* Concurrency 4 */
2717 (DEC4_FORMAT),
2718 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2719 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2720 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2721 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2722
2723 /* Concurrency 5 */
2724 (DEC4_FORMAT),
2725 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(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 /* Concurrency 6 */
2731 (DEC4_FORMAT),
2732 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2733 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2734 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2735 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2736};
2737
2738#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
2739 .module_queueid = queueid, .module_decid = decid, \
2740 .nr_codec_support = nr_codec}
2741
2742#define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
2743 .max_instances_same_dec = max_instance_same, \
2744 .max_instances_diff_dec = max_instance_diff}
2745
2746static struct msm_adspdec_info dec_info_list[] = {
2747 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
2748 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
2749 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
2750 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
2751 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
2752};
2753
2754static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
2755 /* Non Turbo Mode */
2756 {
2757 DEC_INSTANCE(4, 3), /* WAV */
2758 DEC_INSTANCE(4, 3), /* ADPCM */
2759 DEC_INSTANCE(4, 2), /* MP3 */
2760 DEC_INSTANCE(0, 0), /* Real Audio */
2761 DEC_INSTANCE(4, 2), /* WMA */
2762 DEC_INSTANCE(3, 2), /* AAC */
2763 DEC_INSTANCE(0, 0), /* Reserved */
2764 DEC_INSTANCE(0, 0), /* MIDI */
2765 DEC_INSTANCE(4, 3), /* YADPCM */
2766 DEC_INSTANCE(4, 3), /* QCELP */
2767 DEC_INSTANCE(4, 3), /* AMRNB */
2768 DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
2769 DEC_INSTANCE(4, 3), /* EVRC */
2770 DEC_INSTANCE(1, 1), /* WMAPRO */
2771 },
2772 /* Turbo Mode */
2773 {
2774 DEC_INSTANCE(4, 3), /* WAV */
2775 DEC_INSTANCE(4, 3), /* ADPCM */
2776 DEC_INSTANCE(4, 3), /* MP3 */
2777 DEC_INSTANCE(0, 0), /* Real Audio */
2778 DEC_INSTANCE(4, 3), /* WMA */
2779 DEC_INSTANCE(4, 3), /* AAC */
2780 DEC_INSTANCE(0, 0), /* Reserved */
2781 DEC_INSTANCE(0, 0), /* MIDI */
2782 DEC_INSTANCE(4, 3), /* YADPCM */
2783 DEC_INSTANCE(4, 3), /* QCELP */
2784 DEC_INSTANCE(4, 3), /* AMRNB */
2785 DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
2786 DEC_INSTANCE(4, 3), /* EVRC */
2787 DEC_INSTANCE(1, 2), /* WMAPRO */
2788 },
2789};
2790
2791static struct msm_adspdec_database msm_device_adspdec_database = {
2792 .num_dec = ARRAY_SIZE(dec_info_list),
2793 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
2794 ARRAY_SIZE(dec_info_list)),
2795 .dec_concurrency_table = dec_concurrency_table,
2796 .dec_info_list = dec_info_list,
2797 .dec_instance_list = &dec_instance_list[0][0],
2798};
2799
2800static struct platform_device msm_device_adspdec = {
2801 .name = "msm_adspdec",
2802 .id = -1,
2803 .dev = {
2804 .platform_data = &msm_device_adspdec_database
2805 },
2806};
2807
2808static struct resource smc91x_resources[] = {
2809 [0] = {
2810 .start = 0x8A000300,
2811 .end = 0x8A0003ff,
2812 .flags = IORESOURCE_MEM,
2813 },
2814 [1] = {
2815 .start = MSM_GPIO_TO_INT(156),
2816 .end = MSM_GPIO_TO_INT(156),
2817 .flags = IORESOURCE_IRQ,
2818 },
2819};
2820
2821static struct platform_device smc91x_device = {
2822 .name = "smc91x",
2823 .id = 0,
2824 .num_resources = ARRAY_SIZE(smc91x_resources),
2825 .resource = smc91x_resources,
2826};
2827
2828static struct smsc911x_platform_config smsc911x_config = {
2829 .phy_interface = PHY_INTERFACE_MODE_MII,
2830 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
2831 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
2832 .flags = SMSC911X_USE_32BIT,
2833};
2834
2835static struct resource smsc911x_resources[] = {
2836 [0] = {
2837 .start = 0x8D000000,
2838 .end = 0x8D000100,
2839 .flags = IORESOURCE_MEM,
2840 },
2841 [1] = {
2842 .start = MSM_GPIO_TO_INT(88),
2843 .end = MSM_GPIO_TO_INT(88),
2844 .flags = IORESOURCE_IRQ,
2845 },
2846};
2847
2848static struct platform_device smsc911x_device = {
2849 .name = "smsc911x",
2850 .id = -1,
2851 .num_resources = ARRAY_SIZE(smsc911x_resources),
2852 .resource = smsc911x_resources,
2853 .dev = {
2854 .platform_data = &smsc911x_config,
2855 },
2856};
2857
2858static struct msm_gpio smsc911x_gpios[] = {
2859 { GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" },
2860 { GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" },
2861 { GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" },
2862 { GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" },
2863 { GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" },
2864 { GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" },
2865 { GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" },
2866 { GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" },
2867};
2868
2869static void msm7x30_cfg_smsc911x(void)
2870{
2871 int rc;
2872
2873 rc = msm_gpios_request_enable(smsc911x_gpios,
2874 ARRAY_SIZE(smsc911x_gpios));
2875 if (rc)
2876 pr_err("%s: unable to enable gpios\n", __func__);
2877}
2878
2879#ifdef CONFIG_USB_G_ANDROID
2880static struct android_usb_platform_data android_usb_pdata = {
2881 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2882};
2883
2884static struct platform_device android_usb_device = {
2885 .name = "android_usb",
2886 .id = -1,
2887 .dev = {
2888 .platform_data = &android_usb_pdata,
2889 },
2890};
2891#endif
2892
2893static struct msm_gpio optnav_config_data[] = {
2894 { GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA),
2895 "optnav_chip_select" },
2896};
2897
Justin Paupore3f40f342011-08-10 18:52:16 -07002898static struct regulator_bulk_data optnav_regulators[] = {
2899 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2900 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
2901 { .supply = "gp9", .min_uV = 1800000, .max_uV = 1800000 },
2902 { .supply = "usb", .min_uV = 3300000, .max_uV = 3300000 },
2903};
2904
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002905static void __iomem *virtual_optnav;
2906
2907static int optnav_gpio_setup(void)
2908{
2909 int rc = -ENODEV;
2910 rc = msm_gpios_request_enable(optnav_config_data,
2911 ARRAY_SIZE(optnav_config_data));
2912
Justin Paupore3f40f342011-08-10 18:52:16 -07002913 if (rc)
2914 return rc;
2915
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002916 /* Configure the FPGA for GPIOs */
2917 virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4);
2918 if (!virtual_optnav) {
2919 pr_err("%s:Could not ioremap region\n", __func__);
2920 return -ENOMEM;
2921 }
2922 /*
2923 * Configure the FPGA to set GPIO 19 as
2924 * normal, active(enabled), output(MSM to SURF)
2925 */
2926 writew(0x311E, virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002927
2928 rc = regulator_bulk_get(NULL, ARRAY_SIZE(optnav_regulators),
2929 optnav_regulators);
2930 if (rc)
2931 return rc;
2932
2933 rc = regulator_bulk_set_voltage(ARRAY_SIZE(optnav_regulators),
2934 optnav_regulators);
2935
2936 if (rc)
2937 goto regulator_put;
2938
2939 return rc;
2940
2941regulator_put:
2942 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002943 return rc;
2944}
2945
2946static void optnav_gpio_release(void)
2947{
2948 msm_gpios_disable_free(optnav_config_data,
2949 ARRAY_SIZE(optnav_config_data));
2950 iounmap(virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002951 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002952}
2953
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002954static int optnav_enable(void)
2955{
2956 int rc;
2957 /*
2958 * Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
2959 * for I2C communication with keyboard.
2960 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002961
Justin Paupore3f40f342011-08-10 18:52:16 -07002962 rc = regulator_bulk_enable(ARRAY_SIZE(optnav_regulators),
2963 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002964
Justin Paupore3f40f342011-08-10 18:52:16 -07002965 if (rc)
2966 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002967
2968 /* Enable the chip select GPIO */
2969 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2970 gpio_set_value(OPTNAV_CHIP_SELECT, 0);
2971
2972 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002973}
2974
2975static void optnav_disable(void)
2976{
Justin Paupore3f40f342011-08-10 18:52:16 -07002977 regulator_bulk_disable(ARRAY_SIZE(optnav_regulators),
2978 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002979
2980 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2981}
2982
2983static struct ofn_atlab_platform_data optnav_data = {
2984 .gpio_setup = optnav_gpio_setup,
2985 .gpio_release = optnav_gpio_release,
2986 .optnav_on = optnav_enable,
2987 .optnav_off = optnav_disable,
2988 .rotate_xy = 0,
2989 .function1 = {
2990 .no_motion1_en = true,
2991 .touch_sensor_en = true,
2992 .ofn_en = true,
2993 .clock_select_khz = 1500,
2994 .cpi_selection = 1200,
2995 },
2996 .function2 = {
2997 .invert_y = false,
2998 .invert_x = true,
2999 .swap_x_y = false,
3000 .hold_a_b_en = true,
3001 .motion_filter_en = true,
3002 },
3003};
3004
3005static int hdmi_comm_power(int on, int show);
3006static int hdmi_init_irq(void);
3007static int hdmi_enable_5v(int on);
3008static int hdmi_core_power(int on, int show);
3009static int hdmi_cec_power(int on);
3010static bool hdmi_check_hdcp_hw_support(void);
3011
3012static struct msm_hdmi_platform_data adv7520_hdmi_data = {
3013 .irq = MSM_GPIO_TO_INT(18),
3014 .comm_power = hdmi_comm_power,
3015 .init_irq = hdmi_init_irq,
3016 .enable_5v = hdmi_enable_5v,
3017 .core_power = hdmi_core_power,
3018 .cec_power = hdmi_cec_power,
3019 .check_hdcp_hw_support = hdmi_check_hdcp_hw_support,
3020};
3021
3022#ifdef CONFIG_BOSCH_BMA150
Justin Paupore3f40f342011-08-10 18:52:16 -07003023
3024static struct regulator_bulk_data sensors_ldo[] = {
3025 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
3026 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
3027};
3028
3029static int __init sensors_ldo_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003030{
3031 int rc;
3032
Justin Paupore3f40f342011-08-10 18:52:16 -07003033 rc = regulator_bulk_get(NULL, ARRAY_SIZE(sensors_ldo), sensors_ldo);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003034
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003035 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003036 pr_err("%s: could not get regulators: %d\n", __func__, rc);
3037 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003038 }
3039
Justin Paupore3f40f342011-08-10 18:52:16 -07003040 rc = regulator_bulk_set_voltage(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3041
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003042 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003043 pr_err("%s: could not set voltages: %d\n", __func__, rc);
3044 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003045 }
3046
3047 return 0;
3048
Justin Paupore3f40f342011-08-10 18:52:16 -07003049reg_free:
3050 regulator_bulk_free(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3051out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003052 return rc;
3053}
3054
Justin Paupore3f40f342011-08-10 18:52:16 -07003055static int sensors_ldo_set(int on)
3056{
3057 int rc = on ?
3058 regulator_bulk_enable(ARRAY_SIZE(sensors_ldo), sensors_ldo) :
3059 regulator_bulk_disable(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3060
3061 if (rc)
3062 pr_err("%s: could not %sable regulators: %d\n",
3063 __func__, on ? "en" : "dis", rc);
3064
3065 return rc;
3066}
3067
3068static int sensors_ldo_enable(void)
3069{
3070 return sensors_ldo_set(1);
3071}
3072
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003073static void sensors_ldo_disable(void)
3074{
Justin Paupore3f40f342011-08-10 18:52:16 -07003075 sensors_ldo_set(0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003076}
Justin Paupore3f40f342011-08-10 18:52:16 -07003077
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003078static struct bma150_platform_data bma150_data = {
3079 .power_on = sensors_ldo_enable,
3080 .power_off = sensors_ldo_disable,
3081};
3082
3083static struct i2c_board_info bma150_board_info[] __initdata = {
3084 {
3085 I2C_BOARD_INFO("bma150", 0x38),
3086 .flags = I2C_CLIENT_WAKE,
3087 .irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
3088 .platform_data = &bma150_data,
3089 },
3090};
3091#endif
3092
3093static struct i2c_board_info msm_i2c_board_info[] = {
3094 {
3095 I2C_BOARD_INFO("m33c01", OPTNAV_I2C_SLAVE_ADDR),
3096 .irq = MSM_GPIO_TO_INT(OPTNAV_IRQ),
3097 .platform_data = &optnav_data,
3098 },
3099 {
3100 I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR),
3101 .platform_data = &adv7520_hdmi_data,
3102 },
3103};
3104
3105static struct i2c_board_info msm_marimba_board_info[] = {
3106 {
3107 I2C_BOARD_INFO("marimba", 0xc),
3108 .platform_data = &marimba_pdata,
3109 }
3110};
3111
3112
3113static struct msm_handset_platform_data hs_platform_data = {
3114 .hs_name = "7k_handset",
3115 .pwr_key_delay_ms = 500, /* 0 will disable end key */
3116};
3117
3118static struct platform_device hs_device = {
3119 .name = "msm-handset",
3120 .id = -1,
3121 .dev = {
3122 .platform_data = &hs_platform_data,
3123 },
3124};
3125
3126static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +05303127 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003128 .idle_supported = 1,
3129 .suspend_supported = 1,
3130 .idle_enabled = 1,
3131 .suspend_enabled = 1,
3132 .latency = 8594,
3133 .residency = 23740,
3134 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303135 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003136 .idle_supported = 1,
3137 .suspend_supported = 1,
3138 .idle_enabled = 1,
3139 .suspend_enabled = 1,
3140 .latency = 4594,
3141 .residency = 23740,
3142 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303143 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003144#ifdef CONFIG_MSM_STANDALONE_POWER_COLLAPSE
3145 .idle_supported = 1,
3146 .suspend_supported = 1,
3147 .idle_enabled = 1,
3148 .suspend_enabled = 0,
3149#else /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3150 .idle_supported = 0,
3151 .suspend_supported = 0,
3152 .idle_enabled = 0,
3153 .suspend_enabled = 0,
3154#endif /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3155 .latency = 500,
3156 .residency = 6000,
3157 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303158 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003159 .idle_supported = 1,
3160 .suspend_supported = 1,
3161 .idle_enabled = 0,
3162 .suspend_enabled = 1,
3163 .latency = 443,
3164 .residency = 1098,
3165 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303166 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003167 .idle_supported = 1,
3168 .suspend_supported = 1,
3169 .idle_enabled = 1,
3170 .suspend_enabled = 1,
3171 .latency = 2,
3172 .residency = 0,
3173 },
3174};
3175
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05303176u32 msm7x30_power_collapse_latency(enum msm_pm_sleep_mode mode)
3177{
3178 switch (mode) {
3179 case MSM_PM_SLEEP_MODE_POWER_COLLAPSE:
3180 return msm_pm_data
3181 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].latency;
3182 case MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN:
3183 return msm_pm_data
3184 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN].latency;
3185 case MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT:
3186 return msm_pm_data
3187 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
3188 case MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT:
3189 return msm_pm_data
3190 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT].latency;
3191 default:
3192 return 0;
3193 }
3194}
3195
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003196static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3197 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
3198 .v_addr = (uint32_t *)PAGE_OFFSET,
3199};
3200
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003201static struct resource qsd_spi_resources[] = {
3202 {
3203 .name = "spi_irq_in",
3204 .start = INT_SPI_INPUT,
3205 .end = INT_SPI_INPUT,
3206 .flags = IORESOURCE_IRQ,
3207 },
3208 {
3209 .name = "spi_irq_out",
3210 .start = INT_SPI_OUTPUT,
3211 .end = INT_SPI_OUTPUT,
3212 .flags = IORESOURCE_IRQ,
3213 },
3214 {
3215 .name = "spi_irq_err",
3216 .start = INT_SPI_ERROR,
3217 .end = INT_SPI_ERROR,
3218 .flags = IORESOURCE_IRQ,
3219 },
3220 {
3221 .name = "spi_base",
3222 .start = 0xA8000000,
3223 .end = 0xA8000000 + SZ_4K - 1,
3224 .flags = IORESOURCE_MEM,
3225 },
3226 {
3227 .name = "spidm_channels",
3228 .flags = IORESOURCE_DMA,
3229 },
3230 {
3231 .name = "spidm_crci",
3232 .flags = IORESOURCE_DMA,
3233 },
3234};
3235
3236#define AMDH0_BASE_PHYS 0xAC200000
3237#define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
3238static int msm_qsd_spi_dma_config(void)
3239{
3240 void __iomem *ct_adm_base = 0;
3241 u32 spi_mux = 0;
3242 int ret = 0;
3243
3244 ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
3245 if (!ct_adm_base) {
3246 pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
3247 return -ENOMEM;
3248 }
3249
3250 spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
3251
3252 qsd_spi_resources[4].start = DMOV_USB_CHAN;
3253 qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
3254
3255 switch (spi_mux) {
3256 case (1):
3257 qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
3258 qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
3259 break;
3260 case (2):
3261 qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
3262 qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
3263 break;
3264 case (3):
3265 qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
3266 qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
3267 break;
3268 default:
3269 ret = -ENOENT;
3270 }
3271
3272 iounmap(ct_adm_base);
3273
3274 return ret;
3275}
3276
3277static struct platform_device qsd_device_spi = {
3278 .name = "spi_qsd",
3279 .id = 0,
3280 .num_resources = ARRAY_SIZE(qsd_spi_resources),
3281 .resource = qsd_spi_resources,
3282};
3283
3284#ifdef CONFIG_SPI_QSD
3285static struct spi_board_info lcdc_sharp_spi_board_info[] __initdata = {
3286 {
3287 .modalias = "lcdc_sharp_ls038y7dx01",
3288 .mode = SPI_MODE_1,
3289 .bus_num = 0,
3290 .chip_select = 0,
3291 .max_speed_hz = 26331429,
3292 }
3293};
3294static struct spi_board_info lcdc_toshiba_spi_board_info[] __initdata = {
3295 {
3296 .modalias = "lcdc_toshiba_ltm030dd40",
3297 .mode = SPI_MODE_3|SPI_CS_HIGH,
3298 .bus_num = 0,
3299 .chip_select = 0,
3300 .max_speed_hz = 9963243,
3301 }
3302};
3303#endif
3304
3305static struct msm_gpio qsd_spi_gpio_config_data[] = {
3306 { GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3307 { GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3308 { GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" },
3309 { GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3310};
3311
3312static int msm_qsd_spi_gpio_config(void)
3313{
3314 return msm_gpios_request_enable(qsd_spi_gpio_config_data,
3315 ARRAY_SIZE(qsd_spi_gpio_config_data));
3316}
3317
3318static void msm_qsd_spi_gpio_release(void)
3319{
3320 msm_gpios_disable_free(qsd_spi_gpio_config_data,
3321 ARRAY_SIZE(qsd_spi_gpio_config_data));
3322}
3323
3324static struct msm_spi_platform_data qsd_spi_pdata = {
3325 .max_clock_speed = 26331429,
3326 .gpio_config = msm_qsd_spi_gpio_config,
3327 .gpio_release = msm_qsd_spi_gpio_release,
3328 .dma_config = msm_qsd_spi_dma_config,
3329};
3330
3331static void __init msm_qsd_spi_init(void)
3332{
3333 qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
3334}
3335
3336#ifdef CONFIG_USB_EHCI_MSM_72K
3337static void msm_hsusb_vbus_power(unsigned phy_info, int on)
3338{
3339 int rc;
3340 static int vbus_is_on;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303341 struct pm8xxx_gpio_init_info usb_vbus = {
3342 PM8058_GPIO_PM_TO_SYS(36),
3343 {
3344 .direction = PM_GPIO_DIR_OUT,
3345 .pull = PM_GPIO_PULL_NO,
3346 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3347 .output_value = 1,
3348 .vin_sel = 2,
3349 .out_strength = PM_GPIO_STRENGTH_MED,
3350 .function = PM_GPIO_FUNC_NORMAL,
3351 .inv_int_pol = 0,
3352 },
3353 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003354
3355 /* If VBUS is already on (or off), do nothing. */
3356 if (unlikely(on == vbus_is_on))
3357 return;
3358
3359 if (on) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303360 rc = pm8xxx_gpio_config(usb_vbus.gpio, &usb_vbus.config);
3361 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003362 pr_err("%s PMIC GPIO 36 write failed\n", __func__);
3363 return;
3364 }
3365 } else {
3366 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(36), 0);
3367 }
3368
3369 vbus_is_on = on;
3370}
3371
3372static struct msm_usb_host_platform_data msm_usb_host_pdata = {
3373 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
3374 .vbus_power = msm_hsusb_vbus_power,
3375 .power_budget = 180,
3376};
3377#endif
3378
3379#ifdef CONFIG_USB_MSM_OTG_72K
3380static int hsusb_rpc_connect(int connect)
3381{
3382 if (connect)
3383 return msm_hsusb_rpc_connect();
3384 else
3385 return msm_hsusb_rpc_close();
3386}
3387#endif
3388
3389#ifdef CONFIG_USB_MSM_OTG_72K
Justin Paupore3f40f342011-08-10 18:52:16 -07003390static struct regulator *vreg_3p3;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003391static int msm_hsusb_ldo_init(int init)
3392{
3393 uint32_t version = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07003394 int def_vol = 3400000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003395
3396 version = socinfo_get_version();
3397
3398 if (SOCINFO_VERSION_MAJOR(version) >= 2 &&
3399 SOCINFO_VERSION_MINOR(version) >= 1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003400 def_vol = 3075000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003401 pr_debug("%s: default voltage:%d\n", __func__, def_vol);
3402 }
3403
3404 if (init) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003405 vreg_3p3 = regulator_get(NULL, "usb");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003406 if (IS_ERR(vreg_3p3))
3407 return PTR_ERR(vreg_3p3);
Justin Paupore3f40f342011-08-10 18:52:16 -07003408 regulator_set_voltage(vreg_3p3, def_vol, def_vol);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003409 } else
Justin Paupore3f40f342011-08-10 18:52:16 -07003410 regulator_put(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003411
3412 return 0;
3413}
3414
3415static int msm_hsusb_ldo_enable(int enable)
3416{
3417 static int ldo_status;
3418
3419 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3420 return -ENODEV;
3421
3422 if (ldo_status == enable)
3423 return 0;
3424
3425 ldo_status = enable;
3426
3427 if (enable)
Justin Paupore3f40f342011-08-10 18:52:16 -07003428 return regulator_enable(vreg_3p3);
3429 else
3430 return regulator_disable(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003431}
3432
3433static int msm_hsusb_ldo_set_voltage(int mV)
3434{
Justin Paupore3f40f342011-08-10 18:52:16 -07003435 static int cur_voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003436
3437 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3438 return -ENODEV;
3439
3440 if (cur_voltage == mV)
3441 return 0;
3442
3443 cur_voltage = mV;
3444
3445 pr_debug("%s: (%d)\n", __func__, mV);
3446
Justin Paupore3f40f342011-08-10 18:52:16 -07003447 return regulator_set_voltage(vreg_3p3, mV*1000, mV*1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003448}
3449#endif
3450
3451#ifndef CONFIG_USB_EHCI_MSM_72K
3452static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init);
3453#endif
3454static struct msm_otg_platform_data msm_otg_pdata = {
3455 .rpc_connect = hsusb_rpc_connect,
3456
3457#ifndef CONFIG_USB_EHCI_MSM_72K
3458 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
3459#else
3460 .vbus_power = msm_hsusb_vbus_power,
3461#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003462 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
3463 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
3464 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
3465 .se1_gating = SE1_GATING_DISABLE,
3466 .chg_vbus_draw = hsusb_chg_vbus_draw,
3467 .chg_connected = hsusb_chg_connected,
3468 .chg_init = hsusb_chg_init,
3469 .ldo_enable = msm_hsusb_ldo_enable,
3470 .ldo_init = msm_hsusb_ldo_init,
3471 .ldo_set_voltage = msm_hsusb_ldo_set_voltage,
3472};
3473
3474#ifdef CONFIG_USB_GADGET
3475static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
3476 .is_phy_status_timer_on = 1,
3477};
3478#endif
3479#ifndef CONFIG_USB_EHCI_MSM_72K
3480typedef void (*notify_vbus_state) (int);
3481notify_vbus_state notify_vbus_state_func_ptr;
3482int vbus_on_irq;
3483static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
3484{
3485 pr_info("%s: vbus notification from pmic\n", __func__);
3486
3487 (*notify_vbus_state_func_ptr) (1);
3488
3489 return IRQ_HANDLED;
3490}
3491static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
3492{
3493 int ret;
3494
3495 if (init) {
3496 if (!callback)
3497 return -ENODEV;
3498
3499 notify_vbus_state_func_ptr = callback;
3500 vbus_on_irq = platform_get_irq_byname(&msm_device_otg,
3501 "vbus_on");
3502 if (vbus_on_irq <= 0) {
3503 pr_err("%s: unable to get vbus on irq\n", __func__);
3504 return -ENODEV;
3505 }
3506
3507 ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq,
3508 IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
3509 if (ret < 0) {
3510 pr_info("%s: request_irq for vbus_on"
3511 "interrupt failed\n", __func__);
3512 return ret;
3513 }
3514 msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
3515 return 0;
3516 } else {
3517 free_irq(vbus_on_irq, 0);
3518 notify_vbus_state_func_ptr = NULL;
3519 return 0;
3520 }
3521}
3522#endif
3523
3524static struct android_pmem_platform_data android_pmem_pdata = {
3525 .name = "pmem",
3526 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
3527 .cached = 1,
3528 .memory_type = MEMTYPE_EBI0,
3529};
3530
3531static struct platform_device android_pmem_device = {
3532 .name = "android_pmem",
3533 .id = 0,
3534 .dev = { .platform_data = &android_pmem_pdata },
3535};
3536
3537#ifndef CONFIG_SPI_QSD
3538static int lcdc_gpio_array_num[] = {
3539 45, /* spi_clk */
3540 46, /* spi_cs */
3541 47, /* spi_mosi */
3542 48, /* spi_miso */
3543 };
3544
3545static struct msm_gpio lcdc_gpio_config_data[] = {
3546 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3547 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3548 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
3549 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3550};
3551
3552static void lcdc_config_gpios(int enable)
3553{
3554 if (enable) {
3555 msm_gpios_request_enable(lcdc_gpio_config_data,
3556 ARRAY_SIZE(
3557 lcdc_gpio_config_data));
3558 } else
3559 msm_gpios_disable_free(lcdc_gpio_config_data,
3560 ARRAY_SIZE(
3561 lcdc_gpio_config_data));
3562}
3563#endif
3564
3565static struct msm_panel_common_pdata lcdc_sharp_panel_data = {
3566#ifndef CONFIG_SPI_QSD
3567 .panel_config_gpio = lcdc_config_gpios,
3568 .gpio_num = lcdc_gpio_array_num,
3569#endif
3570 .gpio = 2, /* LPG PMIC_GPIO26 channel number */
3571};
3572
3573static struct platform_device lcdc_sharp_panel_device = {
3574 .name = "lcdc_sharp_wvga",
3575 .id = 0,
3576 .dev = {
3577 .platform_data = &lcdc_sharp_panel_data,
3578 }
3579};
3580
3581static struct msm_gpio dtv_panel_irq_gpios[] = {
3582 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
3583 "hdmi_int" },
3584};
3585
3586static struct msm_gpio dtv_panel_gpios[] = {
3587 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
3588 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
3589 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
3590 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
3591 { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
3592 { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
3593 { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
3594 { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
3595 { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
3596 { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
3597 { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
3598 { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
3599 { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
3600 { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
3601 { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
3602 { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
3603 { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
3604 { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
3605 { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
3606 { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
3607 { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
3608 { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
3609 { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
3610 { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
3611 { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
3612 { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
3613 { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
3614 { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
3615 { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
3616 { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
3617 { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
3618 { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
3619};
3620
3621
3622#ifdef HDMI_RESET
3623static unsigned dtv_reset_gpio =
3624 GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3625#endif
3626
Justin Paupore3f40f342011-08-10 18:52:16 -07003627static struct regulator_bulk_data hdmi_core_regs[] = {
3628 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3629};
3630
3631static struct regulator_bulk_data hdmi_comm_regs[] = {
3632 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3633 { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 },
3634};
3635
3636static struct regulator_bulk_data hdmi_cec_regs[] = {
3637 { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 },
3638};
3639
3640static int __init hdmi_init_regs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003641{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003642 int rc;
3643
Justin Paupore3f40f342011-08-10 18:52:16 -07003644 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs),
3645 hdmi_core_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003646
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003647 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003648 pr_err("%s: could not get %s regulators: %d\n",
3649 __func__, "core", rc);
3650 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003651 }
3652
Justin Paupore3f40f342011-08-10 18:52:16 -07003653 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs),
3654 hdmi_core_regs);
3655
3656 if (rc) {
3657 pr_err("%s: could not set %s voltages: %d\n",
3658 __func__, "core", rc);
3659 goto free_core;
3660 }
3661
3662 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs),
3663 hdmi_comm_regs);
3664
3665 if (rc) {
3666 pr_err("%s: could not get %s regulators: %d\n",
3667 __func__, "comm", rc);
3668 goto free_core;
3669 }
3670
3671 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs),
3672 hdmi_comm_regs);
3673
3674 if (rc) {
3675 pr_err("%s: could not set %s voltages: %d\n",
3676 __func__, "comm", rc);
3677 goto free_comm;
3678 }
3679
3680 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs),
3681 hdmi_cec_regs);
3682
3683 if (rc) {
3684 pr_err("%s: could not get %s regulators: %d\n",
3685 __func__, "cec", rc);
3686 goto free_comm;
3687 }
3688
3689 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs),
3690 hdmi_cec_regs);
3691
3692 if (rc) {
3693 pr_err("%s: could not set %s voltages: %d\n",
3694 __func__, "cec", rc);
3695 goto free_cec;
3696 }
3697
3698 return 0;
3699
3700free_cec:
3701 regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs);
3702free_comm:
3703 regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs);
3704free_core:
3705 regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs);
3706out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003707 return rc;
3708}
3709
Justin Paupore3f40f342011-08-10 18:52:16 -07003710static int hdmi_init_irq(void)
3711{
3712 int rc = msm_gpios_enable(dtv_panel_irq_gpios,
3713 ARRAY_SIZE(dtv_panel_irq_gpios));
3714 if (rc < 0) {
3715 pr_err("%s: gpio enable failed: %d\n", __func__, rc);
3716 return rc;
3717 }
3718 pr_info("%s\n", __func__);
3719
3720 return 0;
3721}
3722
3723static int hdmi_enable_5v(int on)
3724{
3725 int pmic_gpio_hdmi_5v_en ;
3726
3727 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
3728 machine_is_msm7x30_fluid())
3729 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
3730 else
3731 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
3732
3733 pr_info("%s: %d\n", __func__, on);
3734 if (on) {
3735 int rc;
3736 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
3737 "hdmi_5V_en");
3738 if (rc) {
3739 pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
3740 __func__);
3741 return rc;
3742 }
3743 gpio_set_value_cansleep(
3744 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
3745 } else {
3746 gpio_set_value_cansleep(
3747 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
3748 gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
3749 }
3750 return 0;
3751}
3752
3753static int hdmi_comm_power(int on, int show)
3754{
3755 if (show)
3756 pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
3757 return on ?
3758 regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs),
3759 hdmi_comm_regs) :
3760 regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs),
3761 hdmi_comm_regs);
3762}
3763
3764static int hdmi_core_power(int on, int show)
3765{
3766 if (show)
3767 pr_info("%s: %d <LDO8>\n", __func__, on);
3768 return on ?
3769 regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs),
3770 hdmi_core_regs) :
3771 regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs),
3772 hdmi_core_regs);
3773}
3774
3775static int hdmi_cec_power(int on)
3776{
3777 pr_info("%s: %d <LDO17>\n", __func__, on);
3778 return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs),
3779 hdmi_cec_regs) :
3780 regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs),
3781 hdmi_cec_regs);
3782}
3783
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003784#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
3785/* there is an i2c address conflict between adv7520 and bma150 sensor after
3786 * power up on fluid. As a solution, the default address of adv7520's packet
3787 * memory is changed as soon as possible
3788 */
3789static int __init fluid_i2c_address_fixup(void)
3790{
3791 unsigned char wBuff[16];
3792 unsigned char rBuff[16];
3793 struct i2c_msg msgs[3];
3794 int res;
3795 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003796 struct i2c_adapter *adapter;
3797
3798 if (machine_is_msm7x30_fluid()) {
3799 adapter = i2c_get_adapter(0);
3800 if (!adapter) {
3801 pr_err("%s: invalid i2c adapter\n", __func__);
3802 return PTR_ERR(adapter);
3803 }
3804
3805 /* turn on LDO8 */
Justin Paupore3f40f342011-08-10 18:52:16 -07003806 rc = hdmi_core_power(1, 0);
3807 if (rc) {
3808 pr_err("%s: could not enable hdmi core regs: %d",
3809 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003810 goto adapter_put;
3811 }
3812
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003813 /* change packet memory address to 0x74 */
3814 wBuff[0] = 0x45;
3815 wBuff[1] = 0x74;
3816
3817 msgs[0].addr = ADV7520_I2C_ADDR;
3818 msgs[0].flags = 0;
3819 msgs[0].buf = (unsigned char *) wBuff;
3820 msgs[0].len = 2;
3821
3822 res = i2c_transfer(adapter, msgs, 1);
3823 if (res != 1) {
3824 pr_err("%s: error writing adv7520\n", __func__);
3825 goto ldo8_disable;
3826 }
3827
3828 /* powerdown adv7520 using bit 6 */
3829 /* i2c read first */
3830 wBuff[0] = 0x41;
3831
3832 msgs[0].addr = ADV7520_I2C_ADDR;
3833 msgs[0].flags = 0;
3834 msgs[0].buf = (unsigned char *) wBuff;
3835 msgs[0].len = 1;
3836
3837 msgs[1].addr = ADV7520_I2C_ADDR;
3838 msgs[1].flags = I2C_M_RD;
3839 msgs[1].buf = rBuff;
3840 msgs[1].len = 1;
3841 res = i2c_transfer(adapter, msgs, 2);
3842 if (res != 2) {
3843 pr_err("%s: error reading adv7520\n", __func__);
3844 goto ldo8_disable;
3845 }
3846
3847 /* i2c write back */
3848 wBuff[0] = 0x41;
3849 wBuff[1] = rBuff[0] | 0x40;
3850
3851 msgs[0].addr = ADV7520_I2C_ADDR;
3852 msgs[0].flags = 0;
3853 msgs[0].buf = (unsigned char *) wBuff;
3854 msgs[0].len = 2;
3855
3856 res = i2c_transfer(adapter, msgs, 1);
3857 if (res != 1) {
3858 pr_err("%s: error writing adv7520\n", __func__);
3859 goto ldo8_disable;
3860 }
3861
3862 /* for successful fixup, we release the i2c adapter */
3863 /* but leave ldo8 on so that the adv7520 is not repowered */
3864 i2c_put_adapter(adapter);
3865 pr_info("%s: fluid i2c address conflict resolved\n", __func__);
3866 }
3867 return 0;
3868
3869ldo8_disable:
Justin Paupore3f40f342011-08-10 18:52:16 -07003870 hdmi_core_power(0, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003871adapter_put:
3872 i2c_put_adapter(adapter);
3873 return rc;
3874}
3875fs_initcall_sync(fluid_i2c_address_fixup);
3876#endif
3877
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003878static bool hdmi_check_hdcp_hw_support(void)
3879{
3880 if (machine_is_msm7x30_fluid())
3881 return false;
3882 else
3883 return true;
3884}
3885
3886static int dtv_panel_power(int on)
3887{
3888 int flag_on = !!on;
3889 static int dtv_power_save_on;
3890 int rc;
3891
3892 if (dtv_power_save_on == flag_on)
3893 return 0;
3894
3895 dtv_power_save_on = flag_on;
3896 pr_info("%s: %d\n", __func__, on);
3897
3898#ifdef HDMI_RESET
3899 if (on) {
3900 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
3901 rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
3902 if (rc) {
3903 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
3904 __func__, dtv_reset_gpio, rc);
3905 return rc;
3906 }
3907
3908 /* bring reset line low to hold reset*/
3909 gpio_set_value(37, 0);
3910 }
3911#endif
3912
3913 if (on) {
3914 rc = msm_gpios_enable(dtv_panel_gpios,
3915 ARRAY_SIZE(dtv_panel_gpios));
3916 if (rc < 0) {
3917 printk(KERN_ERR "%s: gpio enable failed: %d\n",
3918 __func__, rc);
3919 return rc;
3920 }
3921 } else {
3922 rc = msm_gpios_disable(dtv_panel_gpios,
3923 ARRAY_SIZE(dtv_panel_gpios));
3924 if (rc < 0) {
3925 printk(KERN_ERR "%s: gpio disable failed: %d\n",
3926 __func__, rc);
3927 return rc;
3928 }
3929 }
3930
3931 mdelay(5); /* ensure power is stable */
3932
3933#ifdef HDMI_RESET
3934 if (on) {
3935 gpio_set_value(37, 1); /* bring reset line high */
3936 mdelay(10); /* 10 msec before IO can be accessed */
3937 }
3938#endif
3939
3940 return rc;
3941}
3942
3943static struct lcdc_platform_data dtv_pdata = {
3944 .lcdc_power_save = dtv_panel_power,
3945};
3946
3947static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3948 .inject_rx_on_wakeup = 1,
3949 .rx_to_inject = 0xFD,
3950};
3951
3952static struct resource msm_fb_resources[] = {
3953 {
3954 .flags = IORESOURCE_DMA,
3955 }
3956};
3957
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08003958#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
3959static struct resource msm_v4l2_video_overlay_resources[] = {
3960 {
3961 .flags = IORESOURCE_DMA,
3962 }
3963};
3964#endif
3965
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003966static int msm_fb_detect_panel(const char *name)
3967{
3968 if (machine_is_msm7x30_fluid()) {
3969 if (!strcmp(name, "lcdc_sharp_wvga_pt"))
3970 return 0;
3971 } else {
3972 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
3973 return -EPERM;
3974 else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20))
3975 return 0;
3976 else if (!strcmp(name, "mddi_orise"))
3977 return -EPERM;
3978 else if (!strcmp(name, "mddi_quickvx"))
3979 return -EPERM;
3980 }
3981 return -ENODEV;
3982}
3983
3984static struct msm_fb_platform_data msm_fb_pdata = {
3985 .detect_client = msm_fb_detect_panel,
3986 .mddi_prescan = 1,
3987};
3988
3989static struct platform_device msm_fb_device = {
3990 .name = "msm_fb",
3991 .id = 0,
3992 .num_resources = ARRAY_SIZE(msm_fb_resources),
3993 .resource = msm_fb_resources,
3994 .dev = {
3995 .platform_data = &msm_fb_pdata,
3996 }
3997};
3998
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08003999#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
4000
4001static struct platform_device msm_v4l2_video_overlay_device = {
4002 .name = "msm_v4l2_overlay_pd",
4003 .id = 0,
4004 .num_resources = ARRAY_SIZE(msm_v4l2_video_overlay_resources),
4005 .resource = msm_v4l2_video_overlay_resources,
4006};
4007#endif
4008
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004009static struct platform_device msm_migrate_pages_device = {
4010 .name = "msm_migrate_pages",
4011 .id = -1,
4012};
4013
4014static struct android_pmem_platform_data android_pmem_adsp_pdata = {
4015 .name = "pmem_adsp",
4016 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4017 .cached = 0,
4018 .memory_type = MEMTYPE_EBI0,
4019};
4020
4021static struct android_pmem_platform_data android_pmem_audio_pdata = {
4022 .name = "pmem_audio",
4023 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4024 .cached = 0,
4025 .memory_type = MEMTYPE_EBI0,
4026};
4027
4028static struct platform_device android_pmem_adsp_device = {
4029 .name = "android_pmem",
4030 .id = 2,
4031 .dev = { .platform_data = &android_pmem_adsp_pdata },
4032};
4033
4034static struct platform_device android_pmem_audio_device = {
4035 .name = "android_pmem",
4036 .id = 4,
4037 .dev = { .platform_data = &android_pmem_audio_pdata },
4038};
4039
4040#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4041 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
4042 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4043 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4044
4045#define QCE_SIZE 0x10000
4046#define QCE_0_BASE 0xA8400000
4047
4048#define QCE_HW_KEY_SUPPORT 1
4049#define QCE_SHA_HMAC_SUPPORT 0
4050#define QCE_SHARE_CE_RESOURCE 0
4051#define QCE_CE_SHARED 0
4052
4053static struct resource qcrypto_resources[] = {
4054 [0] = {
4055 .start = QCE_0_BASE,
4056 .end = QCE_0_BASE + QCE_SIZE - 1,
4057 .flags = IORESOURCE_MEM,
4058 },
4059 [1] = {
4060 .name = "crypto_channels",
4061 .start = DMOV_CE_IN_CHAN,
4062 .end = DMOV_CE_OUT_CHAN,
4063 .flags = IORESOURCE_DMA,
4064 },
4065 [2] = {
4066 .name = "crypto_crci_in",
4067 .start = DMOV_CE_IN_CRCI,
4068 .end = DMOV_CE_IN_CRCI,
4069 .flags = IORESOURCE_DMA,
4070 },
4071 [3] = {
4072 .name = "crypto_crci_out",
4073 .start = DMOV_CE_OUT_CRCI,
4074 .end = DMOV_CE_OUT_CRCI,
4075 .flags = IORESOURCE_DMA,
4076 },
4077 [4] = {
4078 .name = "crypto_crci_hash",
4079 .start = DMOV_CE_HASH_CRCI,
4080 .end = DMOV_CE_HASH_CRCI,
4081 .flags = IORESOURCE_DMA,
4082 },
4083};
4084
4085static struct resource qcedev_resources[] = {
4086 [0] = {
4087 .start = QCE_0_BASE,
4088 .end = QCE_0_BASE + QCE_SIZE - 1,
4089 .flags = IORESOURCE_MEM,
4090 },
4091 [1] = {
4092 .name = "crypto_channels",
4093 .start = DMOV_CE_IN_CHAN,
4094 .end = DMOV_CE_OUT_CHAN,
4095 .flags = IORESOURCE_DMA,
4096 },
4097 [2] = {
4098 .name = "crypto_crci_in",
4099 .start = DMOV_CE_IN_CRCI,
4100 .end = DMOV_CE_IN_CRCI,
4101 .flags = IORESOURCE_DMA,
4102 },
4103 [3] = {
4104 .name = "crypto_crci_out",
4105 .start = DMOV_CE_OUT_CRCI,
4106 .end = DMOV_CE_OUT_CRCI,
4107 .flags = IORESOURCE_DMA,
4108 },
4109 [4] = {
4110 .name = "crypto_crci_hash",
4111 .start = DMOV_CE_HASH_CRCI,
4112 .end = DMOV_CE_HASH_CRCI,
4113 .flags = IORESOURCE_DMA,
4114 },
4115};
4116
4117#endif
4118
4119#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4120 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
4121
4122static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
4123 .ce_shared = QCE_CE_SHARED,
4124 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4125 .hw_key_support = QCE_HW_KEY_SUPPORT,
4126 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004127 /* Bus Scaling declaration*/
4128 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004129};
4130
4131static struct platform_device qcrypto_device = {
4132 .name = "qcrypto",
4133 .id = 0,
4134 .num_resources = ARRAY_SIZE(qcrypto_resources),
4135 .resource = qcrypto_resources,
4136 .dev = {
4137 .coherent_dma_mask = DMA_BIT_MASK(32),
4138 .platform_data = &qcrypto_ce_hw_suppport,
4139 },
4140};
4141#endif
4142
4143#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4144 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4145
4146static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
4147 .ce_shared = QCE_CE_SHARED,
4148 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4149 .hw_key_support = QCE_HW_KEY_SUPPORT,
4150 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004151 /* Bus Scaling declaration*/
4152 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004153};
4154static struct platform_device qcedev_device = {
4155 .name = "qce",
4156 .id = 0,
4157 .num_resources = ARRAY_SIZE(qcedev_resources),
4158 .resource = qcedev_resources,
4159 .dev = {
4160 .coherent_dma_mask = DMA_BIT_MASK(32),
4161 .platform_data = &qcedev_ce_hw_suppport,
4162 },
4163};
4164#endif
4165
4166static int mddi_toshiba_pmic_bl(int level)
4167{
4168 int ret = -EPERM;
4169
4170 ret = pmic_set_led_intensity(LED_LCD, level);
4171
4172 if (ret)
4173 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
4174 __func__);
4175 return ret;
4176}
4177
4178static struct msm_panel_common_pdata mddi_toshiba_pdata = {
4179 .pmic_backlight = mddi_toshiba_pmic_bl,
4180};
4181
4182static struct platform_device mddi_toshiba_device = {
4183 .name = "mddi_toshiba",
4184 .id = 0,
4185 .dev = {
4186 .platform_data = &mddi_toshiba_pdata,
4187 }
4188};
4189
4190static unsigned wega_reset_gpio =
4191 GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4192
4193static struct msm_gpio fluid_vee_reset_gpio[] = {
4194 { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
4195};
4196
4197static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1;
4198static unsigned char quickvx_ldo_enabled;
4199
4200static unsigned quickvx_vlp_gpio =
4201 GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4202
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304203static struct pm8xxx_gpio_init_info pmic_quickvx_clk_gpio = {
4204 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_QUICKVX_CLK),
4205 {
4206 .direction = PM_GPIO_DIR_OUT,
4207 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
4208 .output_value = 1,
4209 .pull = PM_GPIO_PULL_NO,
4210 .vin_sel = PM8058_GPIO_VIN_S3,
4211 .out_strength = PM_GPIO_STRENGTH_HIGH,
4212 .function = PM_GPIO_FUNC_2,
4213 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004214};
4215
Justin Paupore3f40f342011-08-10 18:52:16 -07004216static struct regulator *mddi_ldo20;
4217static struct regulator *mddi_ldo12;
4218static struct regulator *mddi_ldo16;
4219static struct regulator *mddi_ldo6;
4220static struct regulator *mddi_lcd;
4221
4222static int display_common_init(void)
4223{
4224 struct regulator_bulk_data regs[5] = {
4225 { .supply = "ldo20", /* voltage set in display_common_power */},
4226 { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 },
4227 { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 },
4228 { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 },
4229 { .supply = NULL, /* mddi_lcd, initialized below */ },
4230 };
4231
4232 int rc = 0;
4233
4234 if (machine_is_msm7x30_fluid()) {
4235 /* lcd: LDO8 @1.8V */
4236 regs[4].supply = "ldo8";
4237 regs[4].min_uV = 1800000;
4238 regs[4].max_uV = 1800000;
4239 } else {
4240 /* lcd: LDO15 @3.1V */
4241 regs[4].supply = "ldo15";
4242 regs[4].min_uV = 3100000;
4243 regs[4].max_uV = 3100000;
4244 }
4245
4246 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4247 if (rc) {
4248 pr_err("%s: regulator_bulk_get failed: %d\n",
4249 __func__, rc);
4250 goto bail;
4251 }
4252
4253 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4254 if (rc) {
4255 pr_err("%s: regulator_bulk_set_voltage failed: %d\n",
4256 __func__, rc);
4257 goto put_regs;
4258 }
4259
4260 mddi_ldo20 = regs[0].consumer;
4261 mddi_ldo12 = regs[1].consumer;
4262 mddi_ldo6 = regs[2].consumer;
4263 mddi_ldo16 = regs[3].consumer;
4264 mddi_lcd = regs[4].consumer;
4265
4266 return rc;
4267
4268put_regs:
4269 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4270bail:
4271 return rc;
4272}
4273
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004274static int display_common_power(int on)
4275{
4276 int rc = 0, flag_on = !!on;
4277 static int display_common_power_save_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004278 static bool display_regs_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004279
4280 if (display_common_power_save_on == flag_on)
4281 return 0;
4282
4283 display_common_power_save_on = flag_on;
4284
Justin Paupore3f40f342011-08-10 18:52:16 -07004285 if (unlikely(!display_regs_initialized)) {
4286 rc = display_common_init();
4287 if (rc) {
4288 pr_err("%s: regulator init failed: %d\n",
4289 __func__, rc);
4290 return rc;
4291 }
4292 display_regs_initialized = true;
4293 }
4294
4295
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004296 if (on) {
4297 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
4298 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
4299 if (rc) {
4300 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4301 __func__, wega_reset_gpio, rc);
4302 return rc;
4303 }
4304
4305 /* bring reset line low to hold reset*/
4306 gpio_set_value(180, 0);
4307
4308 if (quickvx_mddi_client) {
4309 /* QuickVX chip -- VLP pin -- gpio 97 */
4310 rc = gpio_tlmm_config(quickvx_vlp_gpio,
4311 GPIO_CFG_ENABLE);
4312 if (rc) {
4313 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4314 __func__, quickvx_vlp_gpio, rc);
4315 return rc;
4316 }
4317
4318 /* bring QuickVX VLP line low */
4319 gpio_set_value(97, 0);
4320
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304321 rc = pm8xxx_gpio_config(pmic_quickvx_clk_gpio.gpio,
4322 &pmic_quickvx_clk_gpio.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004323 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304324 pr_err("%s: pm8xxx_gpio_config(%#x)=%d\n",
4325 __func__, pmic_quickvx_clk_gpio.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004326 rc);
4327 return rc;
4328 }
4329
4330 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4331 PMIC_GPIO_QUICKVX_CLK), 0);
4332 }
4333 }
4334
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004335 if (quickvx_mddi_client)
Justin Paupore3f40f342011-08-10 18:52:16 -07004336 rc = regulator_set_voltage(mddi_ldo20, 1800000, 1800000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004337 else
Justin Paupore3f40f342011-08-10 18:52:16 -07004338 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000);
4339
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004340 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004341 pr_err("%s: could not set voltage for ldo20: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004342 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07004343 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004344 }
4345
4346 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004347 rc = regulator_enable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004348 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004349 pr_err("%s: LDO20 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004350 __func__, rc);
4351 return rc;
4352 }
4353
Justin Paupore3f40f342011-08-10 18:52:16 -07004354 rc = regulator_enable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004355 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004356 pr_err("%s: LDO12 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004357 __func__, rc);
4358 return rc;
4359 }
4360
4361 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004362 rc = regulator_enable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004363 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004364 pr_err("%s: LDO16 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004365 __func__, rc);
4366 return rc;
4367 }
4368 }
4369
Justin Paupore3f40f342011-08-10 18:52:16 -07004370 if (quickvx_ldo_enabled) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004371 /* Disable LDO6 during display ON */
Justin Paupore3f40f342011-08-10 18:52:16 -07004372 rc = regulator_disable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004373 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004374 pr_err("%s: LDO6 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004375 __func__, rc);
4376 return rc;
4377 }
4378 quickvx_ldo_enabled = 0;
4379 }
4380
Justin Paupore3f40f342011-08-10 18:52:16 -07004381 rc = regulator_enable(mddi_lcd);
4382 if (rc) {
4383 pr_err("%s: LCD regulator enable failed (%d)\n",
4384 __func__, rc);
4385 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004386 }
4387
4388 mdelay(5); /* ensure power is stable */
4389
4390 if (machine_is_msm7x30_fluid()) {
4391 rc = msm_gpios_request_enable(fluid_vee_reset_gpio,
4392 ARRAY_SIZE(fluid_vee_reset_gpio));
4393 if (rc)
4394 pr_err("%s gpio_request_enable failed rc=%d\n",
4395 __func__, rc);
4396 else {
4397 /* assert vee reset_n */
4398 gpio_set_value(20, 1);
4399 gpio_set_value(20, 0);
4400 mdelay(1);
4401 gpio_set_value(20, 1);
4402 }
4403 }
4404
4405 gpio_set_value(180, 1); /* bring reset line high */
4406 mdelay(10); /* 10 msec before IO can be accessed */
4407
4408 if (quickvx_mddi_client) {
4409 gpio_set_value(97, 1);
4410 msleep(2);
4411 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4412 PMIC_GPIO_QUICKVX_CLK), 1);
4413 msleep(2);
4414 }
4415
4416 rc = pmapp_display_clock_config(1);
4417 if (rc) {
4418 pr_err("%s pmapp_display_clock_config rc=%d\n",
4419 __func__, rc);
4420 return rc;
4421 }
4422
4423 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004424 rc = regulator_disable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004425 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004426 pr_err("%s: LDO20 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004427 __func__, rc);
4428 return rc;
4429 }
4430
4431
4432 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004433 rc = regulator_disable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004434 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004435 pr_err("%s: LDO16 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004436 __func__, rc);
4437 return rc;
4438 }
4439 }
4440
4441 if (quickvx_mddi_client && !quickvx_ldo_enabled) {
4442 /* Enable LDO6 during display OFF for
4443 Quicklogic chip to sleep with data retention */
Justin Paupore3f40f342011-08-10 18:52:16 -07004444 rc = regulator_enable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004445 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004446 pr_err("%s: LDO6 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004447 __func__, rc);
4448 return rc;
4449 }
4450 quickvx_ldo_enabled = 1;
4451 }
4452
4453 gpio_set_value(180, 0); /* bring reset line low */
4454
4455 if (quickvx_mddi_client) {
4456 gpio_set_value(97, 0);
4457 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4458 PMIC_GPIO_QUICKVX_CLK), 0);
4459 }
4460
Justin Paupore3f40f342011-08-10 18:52:16 -07004461 rc = regulator_disable(mddi_lcd);
4462 if (rc) {
4463 pr_err("%s: LCD regulator disable failed (%d)\n",
4464 __func__, rc);
4465 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004466 }
4467
4468 mdelay(5); /* ensure power is stable */
4469
Justin Paupore3f40f342011-08-10 18:52:16 -07004470 rc = regulator_disable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004471 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004472 pr_err("%s: LDO12 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004473 __func__, rc);
4474 return rc;
4475 }
4476
4477 if (machine_is_msm7x30_fluid()) {
4478 msm_gpios_disable_free(fluid_vee_reset_gpio,
4479 ARRAY_SIZE(fluid_vee_reset_gpio));
4480 }
4481
4482 rc = pmapp_display_clock_config(0);
4483 if (rc) {
4484 pr_err("%s pmapp_display_clock_config rc=%d\n",
4485 __func__, rc);
4486 return rc;
4487 }
4488 }
4489
4490 return rc;
4491}
4492
4493static int msm_fb_mddi_sel_clk(u32 *clk_rate)
4494{
4495 *clk_rate *= 2;
4496 return 0;
4497}
4498
4499static int msm_fb_mddi_client_power(u32 client_id)
4500{
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304501 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004502 printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
4503 /* Check if it is Quicklogic client */
4504 if (client_id == 0xc5835800) {
4505 printk(KERN_NOTICE "\n Quicklogic MDDI client");
4506 other_mddi_client = 0;
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304507 if (IS_ERR(mddi_ldo16)) {
4508 rc = PTR_ERR(mddi_ldo16);
4509 pr_err("%s: gp10 vreg get failed (%d)\n", __func__, rc);
4510 return rc;
4511 }
4512 rc = regulator_disable(mddi_ldo16);
4513 if (rc) {
4514 pr_err("%s: LDO16 vreg enable failed (%d)\n",
4515 __func__, rc);
4516 return rc;
4517 }
4518
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004519 } else {
4520 printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
4521 quickvx_mddi_client = 0;
4522 gpio_set_value(97, 0);
4523 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4524 PMIC_GPIO_QUICKVX_CLK), 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004525 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004526
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004527 return 0;
4528}
4529
4530static struct mddi_platform_data mddi_pdata = {
4531 .mddi_power_save = display_common_power,
4532 .mddi_sel_clk = msm_fb_mddi_sel_clk,
4533 .mddi_client_power = msm_fb_mddi_client_power,
4534};
4535
4536int mdp_core_clk_rate_table[] = {
4537 122880000,
4538 122880000,
Pradeep Jilagam3cc12f92011-07-26 22:25:18 +05304539 192000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004540 192000000,
4541};
4542
4543static struct msm_panel_common_pdata mdp_pdata = {
4544 .hw_revision_addr = 0xac001270,
4545 .gpio = 30,
4546 .mdp_core_clk_rate = 122880000,
4547 .mdp_core_clk_table = mdp_core_clk_rate_table,
4548 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07004549 .mdp_rev = MDP_REV_40,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004550};
4551
4552static int lcd_panel_spi_gpio_num[] = {
4553 45, /* spi_clk */
4554 46, /* spi_cs */
4555 47, /* spi_mosi */
4556 48, /* spi_miso */
4557 };
4558
4559static struct msm_gpio lcd_panel_gpios[] = {
4560/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
4561 * input. if there is a hardware revision; we should reassign this GPIO to a
4562 * new open line; and removing it will just ensure that this will be missed in
4563 * the future.
4564 { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
4565 */
4566 { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
4567 { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
4568 { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
4569 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4570 { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
4571 { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
4572 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4573#ifndef CONFIG_SPI_QSD
4574 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
4575 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
4576 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
4577 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
4578#endif
4579 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4580 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4581 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4582 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4583 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4584 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4585 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4586 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4587 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4588 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4589 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4590 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4591 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4592 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4593 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4594 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4595 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4596 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4597 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4598 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4599};
4600
4601static struct msm_gpio lcd_sharp_panel_gpios[] = {
4602 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4603 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4604 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4605 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4606 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4607 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4608 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4609 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4610 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4611 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4612 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4613 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4614 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4615 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4616 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4617 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4618 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4619 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4620 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4621 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4622 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4623 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4624};
4625
4626static int lcdc_toshiba_panel_power(int on)
4627{
4628 int rc, i;
4629 struct msm_gpio *gp;
4630
4631 rc = display_common_power(on);
4632 if (rc < 0) {
4633 printk(KERN_ERR "%s display_common_power failed: %d\n",
4634 __func__, rc);
4635 return rc;
4636 }
4637
4638 if (on) {
4639 rc = msm_gpios_enable(lcd_panel_gpios,
4640 ARRAY_SIZE(lcd_panel_gpios));
4641 if (rc < 0) {
4642 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4643 __func__, rc);
4644 }
4645 } else { /* off */
4646 gp = lcd_panel_gpios;
4647 for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
4648 /* ouput low */
4649 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4650 gp++;
4651 }
4652 }
4653
4654 return rc;
4655}
4656
4657static int lcdc_sharp_panel_power(int on)
4658{
4659 int rc, i;
4660 struct msm_gpio *gp;
4661
4662 rc = display_common_power(on);
4663 if (rc < 0) {
4664 printk(KERN_ERR "%s display_common_power failed: %d\n",
4665 __func__, rc);
4666 return rc;
4667 }
4668
4669 if (on) {
4670 rc = msm_gpios_enable(lcd_sharp_panel_gpios,
4671 ARRAY_SIZE(lcd_sharp_panel_gpios));
4672 if (rc < 0) {
4673 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4674 __func__, rc);
4675 }
4676 } else { /* off */
4677 gp = lcd_sharp_panel_gpios;
4678 for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) {
4679 /* ouput low */
4680 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4681 gp++;
4682 }
4683 }
4684
4685 return rc;
4686}
4687
4688static int lcdc_panel_power(int on)
4689{
4690 int flag_on = !!on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004691 static int lcdc_power_save_on, lcdc_power_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004692
4693 if (lcdc_power_save_on == flag_on)
4694 return 0;
4695
4696 lcdc_power_save_on = flag_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004697
4698 if (unlikely(!lcdc_power_initialized)) {
4699 quickvx_mddi_client = 0;
4700 display_common_init();
4701 lcdc_power_initialized = 1;
4702 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004703
4704 if (machine_is_msm7x30_fluid())
4705 return lcdc_sharp_panel_power(on);
4706 else
4707 return lcdc_toshiba_panel_power(on);
4708}
4709
4710static struct lcdc_platform_data lcdc_pdata = {
4711 .lcdc_power_save = lcdc_panel_power,
4712};
4713
Justin Paupore3f40f342011-08-10 18:52:16 -07004714static struct regulator *atv_s4, *atv_ldo9;
4715
4716static int __init atv_dac_power_init(void)
4717{
4718 int rc;
4719 struct regulator_bulk_data regs[] = {
4720 { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 },
4721 { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 },
4722 };
4723
4724 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4725
4726 if (rc) {
4727 pr_err("%s: could not get regulators: %d\n", __func__, rc);
4728 goto bail;
4729 }
4730
4731 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4732
4733 if (rc) {
4734 pr_err("%s: could not set voltages: %d\n", __func__, rc);
4735 goto reg_free;
4736 }
4737
4738 atv_s4 = regs[0].consumer;
4739 atv_ldo9 = regs[1].consumer;
4740
4741reg_free:
4742 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4743bail:
4744 return rc;
4745}
4746
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004747static int atv_dac_power(int on)
4748{
4749 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004750
4751 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004752 rc = regulator_enable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004753 if (rc) {
4754 pr_err("%s: s4 vreg enable failed (%d)\n",
4755 __func__, rc);
4756 return rc;
4757 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004758 rc = regulator_enable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004759 if (rc) {
4760 pr_err("%s: ldo9 vreg enable failed (%d)\n",
4761 __func__, rc);
4762 return rc;
4763 }
4764 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004765 rc = regulator_disable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004766 if (rc) {
4767 pr_err("%s: ldo9 vreg disable failed (%d)\n",
4768 __func__, rc);
4769 return rc;
4770 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004771 rc = regulator_disable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004772 if (rc) {
4773 pr_err("%s: s4 vreg disable failed (%d)\n",
4774 __func__, rc);
4775 return rc;
4776 }
4777 }
4778 return rc;
4779}
4780
4781static struct tvenc_platform_data atv_pdata = {
4782 .poll = 1,
4783 .pm_vid_en = atv_dac_power,
4784};
4785
4786static void __init msm_fb_add_devices(void)
4787{
4788 msm_fb_register_device("mdp", &mdp_pdata);
4789 msm_fb_register_device("pmdh", &mddi_pdata);
4790 msm_fb_register_device("lcdc", &lcdc_pdata);
4791 msm_fb_register_device("dtv", &dtv_pdata);
4792 msm_fb_register_device("tvenc", &atv_pdata);
4793#ifdef CONFIG_FB_MSM_TVOUT
4794 msm_fb_register_device("tvout_device", NULL);
4795#endif
4796}
4797
4798static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
4799 .gpio_num = lcd_panel_spi_gpio_num,
4800};
4801
4802static struct platform_device lcdc_toshiba_panel_device = {
4803 .name = "lcdc_toshiba_wvga",
4804 .id = 0,
4805 .dev = {
4806 .platform_data = &lcdc_toshiba_panel_data,
4807 }
4808};
4809
4810#if defined(CONFIG_MARIMBA_CORE) && \
4811 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4812static struct platform_device msm_bt_power_device = {
4813 .name = "bt_power",
4814 .id = -1
4815};
4816
4817enum {
4818 BT_RFR,
4819 BT_CTS,
4820 BT_RX,
4821 BT_TX,
4822};
4823
4824static struct msm_gpio bt_config_power_on[] = {
4825 { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4826 "UART1DM_RFR" },
4827 { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4828 "UART1DM_CTS" },
4829 { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4830 "UART1DM_Rx" },
4831 { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4832 "UART1DM_Tx" }
4833};
4834
4835static struct msm_gpio bt_config_power_off[] = {
4836 { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4837 "UART1DM_RFR" },
4838 { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4839 "UART1DM_CTS" },
4840 { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4841 "UART1DM_Rx" },
4842 { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4843 "UART1DM_Tx" }
4844};
4845
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004846static u8 bahama_version;
4847
Justin Paupore3f40f342011-08-10 18:52:16 -07004848static struct regulator_bulk_data regs_bt_marimba[] = {
4849 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4850 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
4851 { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 },
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_v1[] = {
4856 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4857 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
4858 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304859 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004860};
4861
4862static struct regulator_bulk_data regs_bt_bahama_v2[] = {
4863 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4864 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304865 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004866};
4867
4868static struct regulator_bulk_data *regs_bt;
4869static int regs_bt_count;
4870
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004871static int marimba_bt(int on)
4872{
4873 int rc;
4874 int i;
4875 struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
4876
4877 struct marimba_config_register {
4878 u8 reg;
4879 u8 value;
4880 u8 mask;
4881 };
4882
4883 struct marimba_variant_register {
4884 const size_t size;
4885 const struct marimba_config_register *set;
4886 };
4887
4888 const struct marimba_config_register *p;
4889
4890 u8 version;
4891
4892 const struct marimba_config_register v10_bt_on[] = {
4893 { 0xE5, 0x0B, 0x0F },
4894 { 0x05, 0x02, 0x07 },
4895 { 0x06, 0x88, 0xFF },
4896 { 0xE7, 0x21, 0x21 },
4897 { 0xE3, 0x38, 0xFF },
4898 { 0xE4, 0x06, 0xFF },
4899 };
4900
4901 const struct marimba_config_register v10_bt_off[] = {
4902 { 0xE5, 0x0B, 0x0F },
4903 { 0x05, 0x08, 0x0F },
4904 { 0x06, 0x88, 0xFF },
4905 { 0xE7, 0x00, 0x21 },
4906 { 0xE3, 0x00, 0xFF },
4907 { 0xE4, 0x00, 0xFF },
4908 };
4909
4910 const struct marimba_config_register v201_bt_on[] = {
4911 { 0x05, 0x08, 0x07 },
4912 { 0x06, 0x88, 0xFF },
4913 { 0xE7, 0x21, 0x21 },
4914 { 0xE3, 0x38, 0xFF },
4915 { 0xE4, 0x06, 0xFF },
4916 };
4917
4918 const struct marimba_config_register v201_bt_off[] = {
4919 { 0x05, 0x08, 0x07 },
4920 { 0x06, 0x88, 0xFF },
4921 { 0xE7, 0x00, 0x21 },
4922 { 0xE3, 0x00, 0xFF },
4923 { 0xE4, 0x00, 0xFF },
4924 };
4925
4926 const struct marimba_config_register v210_bt_on[] = {
4927 { 0xE9, 0x01, 0x01 },
4928 { 0x06, 0x88, 0xFF },
4929 { 0xE7, 0x21, 0x21 },
4930 { 0xE3, 0x38, 0xFF },
4931 { 0xE4, 0x06, 0xFF },
4932 };
4933
4934 const struct marimba_config_register v210_bt_off[] = {
4935 { 0x06, 0x88, 0xFF },
4936 { 0xE7, 0x00, 0x21 },
4937 { 0xE9, 0x00, 0x01 },
4938 { 0xE3, 0x00, 0xFF },
4939 { 0xE4, 0x00, 0xFF },
4940 };
4941
4942 const struct marimba_variant_register bt_marimba[2][4] = {
4943 {
4944 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4945 { 0, NULL },
4946 { ARRAY_SIZE(v201_bt_off), v201_bt_off },
4947 { ARRAY_SIZE(v210_bt_off), v210_bt_off }
4948 },
4949 {
4950 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4951 { 0, NULL },
4952 { ARRAY_SIZE(v201_bt_on), v201_bt_on },
4953 { ARRAY_SIZE(v210_bt_on), v210_bt_on }
4954 }
4955 };
4956
4957 on = on ? 1 : 0;
4958
4959 rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F);
4960 if (rc < 0) {
4961 printk(KERN_ERR
4962 "%s: version read failed: %d\n",
4963 __func__, rc);
4964 return rc;
4965 }
4966
4967 if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
4968 (bt_marimba[on][version].size == 0)) {
4969 printk(KERN_ERR
4970 "%s: unsupported version\n",
4971 __func__);
4972 return -EIO;
4973 }
4974
4975 p = bt_marimba[on][version].set;
4976
4977 printk(KERN_INFO "%s: found version %d\n", __func__, version);
4978
4979 for (i = 0; i < bt_marimba[on][version].size; i++) {
4980 u8 value = (p+i)->value;
4981 rc = marimba_write_bit_mask(&config,
4982 (p+i)->reg,
4983 &value,
4984 sizeof((p+i)->value),
4985 (p+i)->mask);
4986 if (rc < 0) {
4987 printk(KERN_ERR
4988 "%s: reg %d write failed: %d\n",
4989 __func__, (p+i)->reg, rc);
4990 return rc;
4991 }
4992 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
4993 __func__, (p+i)->reg,
4994 value, (p+i)->mask);
4995 }
4996 return 0;
4997}
4998
4999static int bahama_bt(int on)
5000{
5001 int rc;
5002 int i;
5003 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
5004
5005 struct bahama_variant_register {
5006 const size_t size;
5007 const struct bahama_config_register *set;
5008 };
5009
5010 const struct bahama_config_register *p;
5011
5012
5013 const struct bahama_config_register v10_bt_on[] = {
5014 { 0xE9, 0x00, 0xFF },
5015 { 0xF4, 0x80, 0xFF },
5016 { 0xF0, 0x06, 0xFF },
5017 { 0xE4, 0x00, 0xFF },
5018 { 0xE5, 0x00, 0x0F },
5019#ifdef CONFIG_WLAN
5020 { 0xE6, 0x38, 0x7F },
5021 { 0xE7, 0x06, 0xFF },
5022#endif
5023 { 0x11, 0x13, 0xFF },
5024 { 0xE9, 0x21, 0xFF },
5025 { 0x01, 0x0C, 0x1F },
5026 { 0x01, 0x08, 0x1F },
5027 };
5028
5029 const struct bahama_config_register v20_bt_on_fm_off[] = {
5030 { 0x11, 0x0C, 0xFF },
5031 { 0x13, 0x01, 0xFF },
5032 { 0xF4, 0x80, 0xFF },
5033 { 0xF0, 0x00, 0xFF },
5034 { 0xE9, 0x00, 0xFF },
5035#ifdef CONFIG_WLAN
5036 { 0x81, 0x00, 0xFF },
5037 { 0x82, 0x00, 0xFF },
5038 { 0xE6, 0x38, 0x7F },
5039 { 0xE7, 0x06, 0xFF },
5040#endif
5041 { 0xE9, 0x21, 0xFF }
5042 };
5043
5044 const struct bahama_config_register v20_bt_on_fm_on[] = {
5045 { 0x11, 0x0C, 0xFF },
5046 { 0x13, 0x01, 0xFF },
5047 { 0xF4, 0x86, 0xFF },
5048 { 0xF0, 0x06, 0xFF },
5049 { 0xE9, 0x00, 0xFF },
5050#ifdef CONFIG_WLAN
5051 { 0x81, 0x00, 0xFF },
5052 { 0x82, 0x00, 0xFF },
5053 { 0xE6, 0x38, 0x7F },
5054 { 0xE7, 0x06, 0xFF },
5055#endif
5056 { 0xE9, 0x21, 0xFF }
5057 };
5058
5059 const struct bahama_config_register v10_bt_off[] = {
5060 { 0xE9, 0x00, 0xFF },
5061 };
5062
5063 const struct bahama_config_register v20_bt_off_fm_off[] = {
5064 { 0xF4, 0x84, 0xFF },
5065 { 0xF0, 0x04, 0xFF },
5066 { 0xE9, 0x00, 0xFF }
5067 };
5068
5069 const struct bahama_config_register v20_bt_off_fm_on[] = {
5070 { 0xF4, 0x86, 0xFF },
5071 { 0xF0, 0x06, 0xFF },
5072 { 0xE9, 0x00, 0xFF }
5073 };
5074
5075 const struct bahama_variant_register bt_bahama[2][3] = {
5076 {
5077 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
5078 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
5079 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
5080 },
5081 {
5082 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
5083 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
5084 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
5085 }
5086 };
5087
5088 u8 offset = 0; /* index into bahama configs */
5089
5090 on = on ? 1 : 0;
5091
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005092
5093 if (bahama_version == VER_2_0) {
5094 if (marimba_get_fm_status(&config))
5095 offset = 0x01;
5096 }
5097
5098 p = bt_bahama[on][bahama_version + offset].set;
5099
5100 dev_info(&msm_bt_power_device.dev,
5101 "%s: found version %d\n", __func__, bahama_version);
5102
5103 for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
5104 u8 value = (p+i)->value;
5105 rc = marimba_write_bit_mask(&config,
5106 (p+i)->reg,
5107 &value,
5108 sizeof((p+i)->value),
5109 (p+i)->mask);
5110 if (rc < 0) {
5111 dev_err(&msm_bt_power_device.dev,
5112 "%s: reg %d write failed: %d\n",
5113 __func__, (p+i)->reg, rc);
5114 return rc;
5115 }
5116 dev_info(&msm_bt_power_device.dev,
5117 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
5118 __func__, (p+i)->reg,
5119 value, (p+i)->mask);
5120 }
5121 /* Update BT status */
5122 if (on)
5123 marimba_set_bt_status(&config, true);
5124 else
5125 marimba_set_bt_status(&config, false);
5126
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005127 return 0;
5128}
5129
Justin Paupore3f40f342011-08-10 18:52:16 -07005130static int bluetooth_regs_init(int bahama_not_marimba)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005131{
Justin Paupore3f40f342011-08-10 18:52:16 -07005132 int rc = 0;
5133 struct device *const dev = &msm_bt_power_device.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005134
5135 if (bahama_not_marimba) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005136 bahama_version = read_bahama_ver();
5137
5138 switch (bahama_version) {
5139 case VER_1_0:
5140 regs_bt = regs_bt_bahama_v1;
5141 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1);
5142 break;
5143 case VER_2_0:
5144 regs_bt = regs_bt_bahama_v2;
5145 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2);
5146 break;
5147 case VER_UNSUPPORTED:
5148 default:
5149 dev_err(dev,
5150 "%s: i2c failure or unsupported version: %d\n",
5151 __func__, bahama_version);
5152 rc = -EIO;
5153 goto out;
5154 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005155 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07005156 regs_bt = regs_bt_marimba;
5157 regs_bt_count = ARRAY_SIZE(regs_bt_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005158 }
5159
Justin Paupore3f40f342011-08-10 18:52:16 -07005160 rc = regulator_bulk_get(&msm_bt_power_device.dev,
5161 regs_bt_count, regs_bt);
5162 if (rc) {
5163 dev_err(dev, "%s: could not get regulators: %d\n",
5164 __func__, rc);
5165 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005166 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005167
5168 rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt);
5169 if (rc) {
5170 dev_err(dev, "%s: could not set voltages: %d\n",
5171 __func__, rc);
5172 goto reg_free;
5173 }
5174
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005175 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005176
5177reg_free:
5178 regulator_bulk_free(regs_bt_count, regs_bt);
5179out:
5180 regs_bt_count = 0;
5181 regs_bt = NULL;
5182 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005183}
5184
5185static int bluetooth_power(int on)
5186{
5187 int rc;
5188 const char *id = "BTPW";
5189
5190 int bahama_not_marimba = bahama_present();
5191
5192 if (bahama_not_marimba == -1) {
5193 printk(KERN_WARNING "%s: bahama_present: %d\n",
5194 __func__, bahama_not_marimba);
5195 return -ENODEV;
5196 }
5197
Justin Paupore3f40f342011-08-10 18:52:16 -07005198 if (unlikely(regs_bt_count == 0)) {
5199 rc = bluetooth_regs_init(bahama_not_marimba);
5200 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005201 return rc;
Justin Paupore3f40f342011-08-10 18:52:16 -07005202 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005203
Justin Paupore3f40f342011-08-10 18:52:16 -07005204 if (on) {
5205 rc = regulator_bulk_enable(regs_bt_count, regs_bt);
5206 if (rc)
5207 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005208
5209 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5210 PMAPP_CLOCK_VOTE_ON);
5211 if (rc < 0)
5212 return -EIO;
5213
5214 if (machine_is_msm8x55_svlte_surf() ||
5215 machine_is_msm8x55_svlte_ffa()) {
5216 rc = marimba_gpio_config(1);
5217 if (rc < 0)
5218 return -EIO;
5219 }
5220
5221 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5222 if (rc < 0)
5223 return -EIO;
5224
5225 msleep(10);
5226
5227 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5228 PMAPP_CLOCK_VOTE_PIN_CTRL);
5229 if (rc < 0)
5230 return -EIO;
5231
5232 if (machine_is_msm8x55_svlte_surf() ||
5233 machine_is_msm8x55_svlte_ffa()) {
5234 rc = marimba_gpio_config(0);
5235 if (rc < 0)
5236 return -EIO;
5237 }
5238
5239 rc = msm_gpios_enable(bt_config_power_on,
5240 ARRAY_SIZE(bt_config_power_on));
5241
5242 if (rc < 0)
5243 return rc;
5244
5245 } else {
5246 rc = msm_gpios_enable(bt_config_power_off,
5247 ARRAY_SIZE(bt_config_power_off));
5248 if (rc < 0)
5249 return rc;
5250
5251 /* check for initial RFKILL block (power off) */
5252 if (platform_get_drvdata(&msm_bt_power_device) == NULL)
5253 goto out;
5254
5255 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5256 if (rc < 0)
5257 return -EIO;
5258
5259 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5260 PMAPP_CLOCK_VOTE_OFF);
5261 if (rc < 0)
5262 return -EIO;
5263
Justin Paupore3f40f342011-08-10 18:52:16 -07005264 rc = regulator_bulk_disable(regs_bt_count, regs_bt);
5265 if (rc)
5266 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005267
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005268 }
5269
5270out:
5271 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
5272
5273 return 0;
5274}
5275
5276static void __init bt_power_init(void)
5277{
Justin Paupore3f40f342011-08-10 18:52:16 -07005278 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005279}
5280#else
5281#define bt_power_init(x) do {} while (0)
5282#endif
5283
5284static struct msm_psy_batt_pdata msm_psy_batt_data = {
5285 .voltage_min_design = 2800,
5286 .voltage_max_design = 4300,
5287 .avail_chg_sources = AC_CHG | USB_CHG ,
5288 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
5289};
5290
5291static struct platform_device msm_batt_device = {
5292 .name = "msm-battery",
5293 .id = -1,
5294 .dev.platform_data = &msm_psy_batt_data,
5295};
5296
5297static char *msm_adc_fluid_device_names[] = {
5298 "LTC_ADC1",
5299 "LTC_ADC2",
5300 "LTC_ADC3",
5301};
5302
5303static char *msm_adc_surf_device_names[] = {
5304 "XO_ADC",
5305};
5306
5307static struct msm_adc_platform_data msm_adc_pdata;
5308
5309static struct platform_device msm_adc_device = {
5310 .name = "msm_adc",
5311 .id = -1,
5312 .dev = {
5313 .platform_data = &msm_adc_pdata,
5314 },
5315};
5316
5317#ifdef CONFIG_MSM_SDIO_AL
5318static struct msm_gpio mdm2ap_status = {
5319 GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5320 "mdm2ap_status"
5321};
5322
5323
5324static int configure_mdm2ap_status(int on)
5325{
5326 if (on)
5327 return msm_gpios_request_enable(&mdm2ap_status, 1);
5328 else {
5329 msm_gpios_disable_free(&mdm2ap_status, 1);
5330 return 0;
5331 }
5332}
5333
5334static int get_mdm2ap_status(void)
5335{
5336 return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
5337}
5338
5339static struct sdio_al_platform_data sdio_al_pdata = {
5340 .config_mdm2ap_status = configure_mdm2ap_status,
5341 .get_mdm2ap_status = get_mdm2ap_status,
5342 .allow_sdioc_version_major_2 = 1,
5343 .peer_sdioc_version_minor = 0x0001,
5344 .peer_sdioc_version_major = 0x0003,
5345 .peer_sdioc_boot_version_minor = 0x0001,
5346 .peer_sdioc_boot_version_major = 0x0003,
5347};
5348
5349struct platform_device msm_device_sdio_al = {
5350 .name = "msm_sdio_al",
5351 .id = -1,
5352 .dev = {
5353 .platform_data = &sdio_al_pdata,
5354 },
5355};
5356
5357#endif /* CONFIG_MSM_SDIO_AL */
5358
Daniel Walker8d747cd2010-02-25 11:37:43 -08005359static struct platform_device *devices[] __initdata = {
Daniel Walker90e37c52010-05-12 14:24:15 -07005360#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005361 &msm_device_uart2,
5362#endif
Justin Paupore637a25d2011-07-14 17:11:04 -07005363#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
5364 &msm_proccomm_regulator_dev,
5365#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005366 &asoc_msm_pcm,
5367 &asoc_msm_dai0,
5368 &asoc_msm_dai1,
5369#if defined (CONFIG_SND_MSM_MVS_DAI_SOC)
5370 &asoc_msm_mvs,
5371 &asoc_mvs_dai0,
5372 &asoc_mvs_dai1,
Daniel Walker90e37c52010-05-12 14:24:15 -07005373#endif
Niranjana Vishwanathapuraa8855e92010-10-06 13:52:10 -07005374 &msm_device_smd,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005375 &msm_device_dmov,
5376 &smc91x_device,
5377 &smsc911x_device,
5378 &msm_device_nand,
5379#ifdef CONFIG_USB_MSM_OTG_72K
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05305380 &msm_device_otg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005381#ifdef CONFIG_USB_GADGET
5382 &msm_device_gadget_peripheral,
5383#endif
5384#endif
5385#ifdef CONFIG_USB_G_ANDROID
5386 &android_usb_device,
5387#endif
5388 &qsd_device_spi,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305389
5390#ifdef CONFIG_MSM_SSBI
5391 &msm_device_ssbi_pmic1,
5392#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005393#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005394 &msm_device_ssbi7,
5395#endif
5396 &android_pmem_device,
5397 &msm_fb_device,
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08005398#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
5399 &msm_v4l2_video_overlay_device,
5400#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005401 &msm_migrate_pages_device,
5402 &mddi_toshiba_device,
5403 &lcdc_toshiba_panel_device,
5404#ifdef CONFIG_MSM_ROTATOR
5405 &msm_rotator_device,
5406#endif
5407 &lcdc_sharp_panel_device,
5408 &android_pmem_adsp_device,
5409 &android_pmem_audio_device,
5410 &msm_device_i2c,
5411 &msm_device_i2c_2,
5412 &msm_device_uart_dm1,
5413 &hs_device,
5414#ifdef CONFIG_MSM7KV2_AUDIO
5415 &msm_aictl_device,
5416 &msm_mi2s_device,
5417 &msm_lpa_device,
5418 &msm_aux_pcm_device,
5419#endif
5420 &msm_device_adspdec,
5421 &qup_device_i2c,
5422#if defined(CONFIG_MARIMBA_CORE) && \
5423 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5424 &msm_bt_power_device,
5425#endif
5426 &msm_kgsl_3d0,
5427 &msm_kgsl_2d0,
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005428#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005429#ifdef CONFIG_MT9T013
5430 &msm_camera_sensor_mt9t013,
5431#endif
5432#ifdef CONFIG_MT9D112
5433 &msm_camera_sensor_mt9d112,
5434#endif
5435#ifdef CONFIG_WEBCAM_OV9726
5436 &msm_camera_sensor_ov9726,
5437#endif
5438#ifdef CONFIG_S5K3E2FX
5439 &msm_camera_sensor_s5k3e2fx,
5440#endif
5441#ifdef CONFIG_MT9P012
5442 &msm_camera_sensor_mt9p012,
5443#endif
5444#ifdef CONFIG_MT9E013
5445 &msm_camera_sensor_mt9e013,
5446#endif
5447#ifdef CONFIG_VX6953
5448 &msm_camera_sensor_vx6953,
5449#endif
5450#ifdef CONFIG_SN12M0PZ
5451 &msm_camera_sensor_sn12m0pz,
5452#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005453#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005454 &msm_device_vidc_720p,
5455#ifdef CONFIG_MSM_GEMINI
5456 &msm_gemini_device,
5457#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005458#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005459#ifdef CONFIG_MSM_VPE
5460 &msm_vpe_device,
5461#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005462#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005463#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5464 &msm_device_tsif,
5465#endif
5466#ifdef CONFIG_MSM_SDIO_AL
5467 &msm_device_sdio_al,
5468#endif
5469
5470#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5471 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5472 &qcrypto_device,
5473#endif
5474
5475#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5476 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5477 &qcedev_device,
5478#endif
5479
5480 &msm_batt_device,
5481 &msm_adc_device,
5482 &msm_ebi0_thermal,
Laxminath Kasam1d8255d2012-02-15 13:10:19 +05305483 &msm_ebi1_thermal,
5484 &msm_adsp_device
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005485};
5486
5487static struct msm_gpio msm_i2c_gpios_hw[] = {
5488 { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5489 { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5490};
5491
5492static struct msm_gpio msm_i2c_gpios_io[] = {
5493 { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5494 { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5495};
5496
5497static struct msm_gpio qup_i2c_gpios_io[] = {
5498 { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5499 { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5500};
5501static struct msm_gpio qup_i2c_gpios_hw[] = {
5502 { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5503 { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5504};
5505
5506static void
5507msm_i2c_gpio_config(int adap_id, int config_type)
5508{
5509 struct msm_gpio *msm_i2c_table;
5510
5511 /* Each adapter gets 2 lines from the table */
5512 if (adap_id > 0)
5513 return;
5514 if (config_type)
5515 msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
5516 else
5517 msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
5518 msm_gpios_enable(msm_i2c_table, 2);
5519}
5520/*This needs to be enabled only for OEMS*/
5521#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005522static struct regulator *qup_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005523#endif
5524static void
5525qup_i2c_gpio_config(int adap_id, int config_type)
5526{
5527 int rc = 0;
5528 struct msm_gpio *qup_i2c_table;
5529 /* Each adapter gets 2 lines from the table */
5530 if (adap_id != 4)
5531 return;
5532 if (config_type)
5533 qup_i2c_table = qup_i2c_gpios_hw;
5534 else
5535 qup_i2c_table = qup_i2c_gpios_io;
5536 rc = msm_gpios_enable(qup_i2c_table, 2);
5537 if (rc < 0)
5538 printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
5539 /*This needs to be enabled only for OEMS*/
5540#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005541 if (!IS_ERR_OR_NULL(qup_vreg)) {
5542 rc = regulator_enable(qup_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005543 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005544 pr_err("%s: regulator_enable failed: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005545 __func__, rc);
5546 }
5547 }
5548#endif
5549}
5550
5551static struct msm_i2c_platform_data msm_i2c_pdata = {
5552 .clk_freq = 100000,
5553 .pri_clk = 70,
5554 .pri_dat = 71,
5555 .rmutex = 1,
5556 .rsl_id = "D:I2C02000021",
5557 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5558};
5559
5560static void __init msm_device_i2c_init(void)
5561{
5562 if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
5563 pr_err("failed to request I2C gpios\n");
5564
5565 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
5566}
5567
5568static struct msm_i2c_platform_data msm_i2c_2_pdata = {
5569 .clk_freq = 100000,
5570 .rmutex = 1,
5571 .rsl_id = "D:I2C02000022",
5572 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5573};
5574
5575static void __init msm_device_i2c_2_init(void)
5576{
5577 msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
5578}
5579
5580static struct msm_i2c_platform_data qup_i2c_pdata = {
5581 .clk_freq = 384000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005582 .msm_i2c_config_gpio = qup_i2c_gpio_config,
5583};
5584
5585static void __init qup_device_i2c_init(void)
5586{
5587 if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
5588 pr_err("failed to request I2C gpios\n");
5589
5590 qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
5591 /*This needs to be enabled only for OEMS*/
5592#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005593 qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005594 if (IS_ERR(qup_vreg)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005595 dev_err(&qup_device_i2c.dev,
5596 "%s: regulator_get failed: %ld\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005597 __func__, PTR_ERR(qup_vreg));
5598 }
5599#endif
5600}
5601
5602#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005603static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = {
5604 .rsl_id = "D:CODEC_SSBI",
5605 .controller_type = MSM_SBI_CTRL_SSBI,
5606};
5607#endif
5608
Daniel Walker8d747cd2010-02-25 11:37:43 -08005609static void __init msm7x30_init_irq(void)
5610{
5611 msm_init_irq();
5612}
5613
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005614static struct msm_gpio msm_nand_ebi2_cfg_data[] = {
5615 {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
5616 {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
5617};
5618
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005619#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
5620 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
5621 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
5622 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
5623
5624struct sdcc_gpio {
5625 struct msm_gpio *cfg_data;
5626 uint32_t size;
5627 struct msm_gpio *sleep_cfg_data;
5628};
5629#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5630static struct msm_gpio sdc1_lvlshft_cfg_data[] = {
5631 {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
5632};
5633#endif
5634static struct msm_gpio sdc1_cfg_data[] = {
5635 {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
5636 {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
5637 {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
5638 {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
5639 {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
5640 {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
5641};
5642
5643static struct msm_gpio sdc2_cfg_data[] = {
5644 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
5645 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
5646 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
5647 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
5648 {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
5649 {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
5650
5651#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5652 {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
5653 {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
5654 {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
5655 {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
5656#endif
5657};
5658
5659static struct msm_gpio sdc3_cfg_data[] = {
5660 {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
5661 {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
5662 {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
5663 {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
5664 {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
5665 {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
5666};
5667
5668static struct msm_gpio sdc3_sleep_cfg_data[] = {
5669 {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5670 "sdc3_clk"},
5671 {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5672 "sdc3_cmd"},
5673 {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5674 "sdc3_dat_3"},
5675 {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5676 "sdc3_dat_2"},
5677 {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5678 "sdc3_dat_1"},
5679 {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5680 "sdc3_dat_0"},
5681};
5682
5683static struct msm_gpio sdc4_cfg_data[] = {
5684 {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
5685 {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
5686 {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
5687 {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
5688 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
5689 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
5690};
5691
5692static struct sdcc_gpio sdcc_cfg_data[] = {
5693 {
5694 .cfg_data = sdc1_cfg_data,
5695 .size = ARRAY_SIZE(sdc1_cfg_data),
5696 .sleep_cfg_data = NULL,
5697 },
5698 {
5699 .cfg_data = sdc2_cfg_data,
5700 .size = ARRAY_SIZE(sdc2_cfg_data),
5701 .sleep_cfg_data = NULL,
5702 },
5703 {
5704 .cfg_data = sdc3_cfg_data,
5705 .size = ARRAY_SIZE(sdc3_cfg_data),
5706 .sleep_cfg_data = sdc3_sleep_cfg_data,
5707 },
5708 {
5709 .cfg_data = sdc4_cfg_data,
5710 .size = ARRAY_SIZE(sdc4_cfg_data),
5711 .sleep_cfg_data = NULL,
5712 },
5713};
5714
Justin Paupore3f40f342011-08-10 18:52:16 -07005715static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005716
5717static unsigned long vreg_sts, gpio_sts;
5718
5719static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
5720{
5721 int rc = 0;
5722 struct sdcc_gpio *curr;
5723
5724 curr = &sdcc_cfg_data[dev_id - 1];
5725
5726 if (!(test_bit(dev_id, &gpio_sts)^enable))
5727 return rc;
5728
5729 if (enable) {
5730 set_bit(dev_id, &gpio_sts);
5731 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
5732 if (rc)
5733 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
5734 __func__, dev_id);
5735 } else {
5736 clear_bit(dev_id, &gpio_sts);
5737 if (curr->sleep_cfg_data) {
5738 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
5739 msm_gpios_free(curr->sleep_cfg_data, curr->size);
5740 } else {
5741 msm_gpios_disable_free(curr->cfg_data, curr->size);
5742 }
5743 }
5744
5745 return rc;
5746}
5747
5748static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
5749{
5750 int rc = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005751 struct regulator *curr = sdcc_vreg_data[dev_id - 1];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005752 static int enabled_once[] = {0, 0, 0, 0};
5753
Justin Paupore3f40f342011-08-10 18:52:16 -07005754 if (test_bit(dev_id, &vreg_sts) == enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005755 return rc;
5756
Asutosh Das853bbcd2012-02-01 10:40:05 +05305757 if (dev_id == 4) {
5758 if (enable) {
5759 pr_debug("Enable Vdd dev_%d\n", dev_id);
5760 gpio_set_value_cansleep(
5761 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5762 0);
5763 set_bit(dev_id, &vreg_sts);
5764 } else {
5765 pr_debug("Disable Vdd dev_%d\n", dev_id);
5766 gpio_set_value_cansleep(
5767 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5768 1);
5769 clear_bit(dev_id, &vreg_sts);
5770 }
5771 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005772
Asutosh Das853bbcd2012-02-01 10:40:05 +05305773 if (!enable || enabled_once[dev_id - 1])
5774 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005775 if (!curr)
5776 return -ENODEV;
5777
5778 if (IS_ERR(curr))
5779 return PTR_ERR(curr);
5780
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005781 if (enable) {
5782 set_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005783
5784 rc = regulator_enable(curr);
5785 if (rc)
5786 pr_err("%s: could not enable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005787 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005788 enabled_once[dev_id - 1] = 1;
5789 } else {
5790 clear_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005791
5792 rc = regulator_disable(curr);
5793 if (rc)
5794 pr_err("%s: could not disable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005795 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005796 }
5797 return rc;
5798}
5799
5800static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
5801{
5802 int rc = 0;
5803 struct platform_device *pdev;
5804
5805 pdev = container_of(dv, struct platform_device, dev);
5806 rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
5807 if (rc)
5808 goto out;
5809
5810 if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
5811 rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
5812out:
5813 return rc;
5814}
5815
5816#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \
5817 defined(CONFIG_CSDIO_VENDOR_ID) && \
5818 defined(CONFIG_CSDIO_DEVICE_ID) && \
5819 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5820
5821#define MBP_ON 1
5822#define MBP_OFF 0
5823
5824#define MBP_RESET_N \
5825 GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
5826#define MBP_INT0 \
5827 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
5828
5829#define MBP_MODE_CTRL_0 \
5830 GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5831#define MBP_MODE_CTRL_1 \
5832 GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5833#define MBP_MODE_CTRL_2 \
5834 GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5835#define TSIF_EN \
5836 GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5837#define TSIF_DATA \
5838 GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5839#define TSIF_CLK \
5840 GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5841
5842static struct msm_gpio mbp_cfg_data[] = {
5843 {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5844 "mbp_reset"},
5845 {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5846 "mbp_io_voltage"},
5847};
5848
5849static int mbp_config_gpios_pre_init(int enable)
5850{
5851 int rc = 0;
5852
5853 if (enable) {
5854 rc = msm_gpios_request_enable(mbp_cfg_data,
5855 ARRAY_SIZE(mbp_cfg_data));
5856 if (rc) {
5857 printk(KERN_ERR
5858 "%s: Failed to turnon GPIOs for mbp chip(%d)\n",
5859 __func__, rc);
5860 }
5861 } else
5862 msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
5863 return rc;
5864}
5865
Justin Paupore3f40f342011-08-10 18:52:16 -07005866static struct regulator_bulk_data mbp_regs_io[2];
5867static struct regulator_bulk_data mbp_regs_rf[2];
5868static struct regulator_bulk_data mbp_regs_adc[1];
5869static struct regulator_bulk_data mbp_regs_core[1];
5870
5871static int mbp_init_regs(struct device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005872{
Justin Paupore3f40f342011-08-10 18:52:16 -07005873 struct regulator_bulk_data regs[] = {
5874 /* Analog and I/O regs */
5875 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
5876 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
5877 /* RF regs */
5878 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
5879 { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 },
5880 /* ADC regs */
5881 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
5882 /* Core regs */
5883 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
5884 };
5885
5886 struct regulator_bulk_data *regptr = regs;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005887 int rc;
5888
Justin Paupore3f40f342011-08-10 18:52:16 -07005889 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs);
5890
5891 if (rc) {
5892 dev_err(dev, "%s: could not get regulators: %d\n",
5893 __func__, rc);
5894 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005895 }
5896
Justin Paupore3f40f342011-08-10 18:52:16 -07005897 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005898
Justin Paupore3f40f342011-08-10 18:52:16 -07005899 if (rc) {
5900 dev_err(dev, "%s: could not set voltages: %d\n",
5901 __func__, rc);
5902 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005903 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005904
5905 memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io));
5906 regptr += ARRAY_SIZE(mbp_regs_io);
5907
5908 memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf));
5909 regptr += ARRAY_SIZE(mbp_regs_rf);
5910
5911 memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc));
5912 regptr += ARRAY_SIZE(mbp_regs_adc);
5913
5914 memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core));
5915
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005916 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005917
5918reg_free:
5919 regulator_bulk_free(ARRAY_SIZE(regs), regs);
5920out:
5921 return rc;
5922}
5923
5924static int mbp_setup_rf_vregs(int state)
5925{
5926 return state ?
5927 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) :
5928 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005929}
5930
5931static int mbp_setup_vregs(int state)
5932{
Justin Paupore3f40f342011-08-10 18:52:16 -07005933 return state ?
5934 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) :
5935 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005936}
5937
5938static int mbp_set_tcxo_en(int enable)
5939{
5940 int rc;
5941 const char *id = "UBMC";
5942 struct vreg *vreg_analog = NULL;
5943
5944 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
5945 enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
5946 if (rc < 0) {
5947 printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
5948 __func__, enable ? "" : "de-");
5949 return -EIO;
5950 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005951 return rc;
5952}
5953
5954static void mbp_set_freeze_io(int state)
5955{
5956 if (state)
5957 gpio_set_value(85, 0);
5958 else
5959 gpio_set_value(85, 1);
5960}
5961
5962static int mbp_set_core_voltage_en(int enable)
5963{
Justin Paupore3f40f342011-08-10 18:52:16 -07005964 static bool is_enabled;
5965 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005966
Justin Paupore3f40f342011-08-10 18:52:16 -07005967 if (enable && !is_enabled) {
5968 rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core),
5969 mbp_regs_core);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005970 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005971 pr_err("%s: could not enable regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005972 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07005973 } else {
5974 is_enabled = true;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005975 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005976 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005977
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005978 return rc;
5979}
5980
5981static void mbp_set_reset(int state)
5982{
5983 if (state)
5984 gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
5985 else
5986 gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
5987}
5988
5989static int mbp_config_interface_mode(int state)
5990{
5991 if (state) {
5992 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
5993 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
5994 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
5995 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
5996 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
5997 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
5998 } else {
5999 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
6000 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
6001 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
6002 }
6003 return 0;
6004}
6005
6006static int mbp_setup_adc_vregs(int state)
6007{
Justin Paupore3f40f342011-08-10 18:52:16 -07006008 return state ?
6009 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) :
6010 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006011}
6012
6013static int mbp_power_up(void)
6014{
6015 int rc;
6016
6017 rc = mbp_config_gpios_pre_init(MBP_ON);
6018 if (rc)
6019 goto exit;
6020 pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__);
6021
6022 rc = mbp_setup_vregs(MBP_ON);
6023 if (rc)
6024 goto exit;
6025 pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
6026
6027 rc = mbp_set_tcxo_en(MBP_ON);
6028 if (rc)
6029 goto exit;
6030 pr_debug("%s: tcxo clock done\n", __func__);
6031
6032 mbp_set_freeze_io(MBP_OFF);
6033 pr_debug("%s: set gpio 85 to 1 done\n", __func__);
6034
6035 udelay(100);
6036 mbp_set_reset(MBP_ON);
6037
6038 udelay(300);
6039 rc = mbp_config_interface_mode(MBP_ON);
6040 if (rc)
6041 goto exit;
6042 pr_debug("%s: mbp_config_interface_mode() done\n", __func__);
6043
6044 udelay(100 + mbp_set_core_voltage_en(MBP_ON));
6045 pr_debug("%s: power gp16 1.2V done\n", __func__);
6046
6047 mbp_set_freeze_io(MBP_ON);
6048 pr_debug("%s: set gpio 85 to 0 done\n", __func__);
6049
6050 udelay(100);
6051
6052 rc = mbp_setup_rf_vregs(MBP_ON);
6053 if (rc)
6054 goto exit;
6055 pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
6056
6057 rc = mbp_setup_adc_vregs(MBP_ON);
6058 if (rc)
6059 goto exit;
6060 pr_debug("%s: s4 2.2V done\n", __func__);
6061
6062 udelay(200);
6063
6064 mbp_set_reset(MBP_OFF);
6065 pr_debug("%s: close gpio 44 done\n", __func__);
6066
6067 msleep(20);
6068exit:
6069 return rc;
6070}
6071
6072static int mbp_power_down(void)
6073{
6074 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006075
6076 mbp_set_reset(MBP_ON);
6077 pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
6078
6079 udelay(100);
6080
6081 rc = mbp_setup_adc_vregs(MBP_OFF);
6082 if (rc)
6083 goto exit;
6084 pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
6085
6086 udelay(5);
6087
6088 rc = mbp_setup_rf_vregs(MBP_OFF);
6089 if (rc)
6090 goto exit;
6091 pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
6092
6093 udelay(5);
6094
6095 mbp_set_freeze_io(MBP_OFF);
6096 pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
6097
6098 udelay(100);
6099 rc = mbp_set_core_voltage_en(MBP_OFF);
6100 if (rc)
6101 goto exit;
6102 pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
6103
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006104 rc = mbp_set_tcxo_en(MBP_OFF);
6105 if (rc)
6106 goto exit;
6107 pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
6108
Justin Paupore3f40f342011-08-10 18:52:16 -07006109 rc = mbp_setup_vregs(MBP_OFF);
6110 if (rc)
6111 goto exit;
6112 pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__);
6113
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006114 rc = mbp_config_gpios_pre_init(MBP_OFF);
6115 if (rc)
6116 goto exit;
6117exit:
6118 return rc;
6119}
6120
6121static void (*mbp_status_notify_cb)(int card_present, void *dev_id);
6122static void *mbp_status_notify_cb_devid;
6123static int mbp_power_status;
6124static int mbp_power_init_done;
6125
6126static uint32_t mbp_setup_power(struct device *dv,
6127 unsigned int power_status)
6128{
6129 int rc = 0;
6130 struct platform_device *pdev;
6131
6132 pdev = container_of(dv, struct platform_device, dev);
6133
6134 if (power_status == mbp_power_status)
6135 goto exit;
6136 if (power_status) {
6137 pr_debug("turn on power of mbp slot");
6138 rc = mbp_power_up();
6139 mbp_power_status = 1;
6140 } else {
6141 pr_debug("turn off power of mbp slot");
6142 rc = mbp_power_down();
6143 mbp_power_status = 0;
6144 }
6145exit:
6146 return rc;
6147};
6148
6149int mbp_register_status_notify(void (*callback)(int, void *),
6150 void *dev_id)
6151{
6152 mbp_status_notify_cb = callback;
6153 mbp_status_notify_cb_devid = dev_id;
6154 return 0;
6155}
6156
6157static unsigned int mbp_status(struct device *dev)
6158{
6159 return mbp_power_status;
6160}
6161
6162static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd)
6163{
6164 struct platform_device *pdev;
6165 uint32_t rc = 0;
6166
6167 pdev = container_of(dv, struct platform_device, dev);
6168 rc = msm_sdcc_setup_power(dv, vdd);
6169 if (rc) {
6170 pr_err("%s: Failed to setup power (%d)\n",
6171 __func__, rc);
6172 goto out;
6173 }
6174 if (!mbp_power_init_done) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006175 rc = mbp_init_regs(dv);
6176 if (rc) {
6177 dev_err(dv, "%s: regulator init failed: %d\n",
6178 __func__, rc);
6179 goto out;
6180 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006181 mbp_setup_power(dv, 1);
6182 mbp_setup_power(dv, 0);
6183 mbp_power_init_done = 1;
6184 }
6185 if (vdd >= 0x8000) {
6186 rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
6187 if (rc) {
6188 pr_err("%s: Failed to config mbp chip power (%d)\n",
6189 __func__, rc);
6190 goto out;
6191 }
6192 if (mbp_status_notify_cb) {
6193 mbp_status_notify_cb(mbp_power_status,
6194 mbp_status_notify_cb_devid);
6195 }
6196 }
6197out:
6198 /* should return 0 only */
6199 return 0;
6200}
6201
6202#endif
6203
6204#endif
6205
6206#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6207#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6208static unsigned int msm7x30_sdcc_slot_status(struct device *dev)
6209{
6210 return (unsigned int)
6211 gpio_get_value_cansleep(
6212 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1));
6213}
6214#endif
6215
6216static int msm_sdcc_get_wpswitch(struct device *dv)
6217{
6218 void __iomem *wp_addr = 0;
6219 uint32_t ret = 0;
6220 struct platform_device *pdev;
6221
6222 if (!(machine_is_msm7x30_surf()))
6223 return -1;
6224 pdev = container_of(dv, struct platform_device, dev);
6225
6226 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
6227 if (!wp_addr) {
6228 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
6229 return -ENOMEM;
6230 }
6231
6232 ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
6233 pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
6234 pdev->id, ret);
6235 iounmap(wp_addr);
6236
6237 return ret;
6238}
6239#endif
6240
6241#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
6242#if defined(CONFIG_CSDIO_VENDOR_ID) && \
6243 defined(CONFIG_CSDIO_DEVICE_ID) && \
6244 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
6245static struct mmc_platform_data msm7x30_sdc1_data = {
6246 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
6247 .translate_vdd = msm_sdcc_setup_power_mbp,
6248 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6249 .status = mbp_status,
6250 .register_status_notify = mbp_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006251 .msmsdcc_fmin = 144000,
6252 .msmsdcc_fmid = 24576000,
6253 .msmsdcc_fmax = 24576000,
6254 .nonremovable = 0,
6255};
6256#else
6257static struct mmc_platform_data msm7x30_sdc1_data = {
6258 .ocr_mask = MMC_VDD_165_195,
6259 .translate_vdd = msm_sdcc_setup_power,
6260 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006261 .msmsdcc_fmin = 144000,
6262 .msmsdcc_fmid = 24576000,
6263 .msmsdcc_fmax = 49152000,
6264 .nonremovable = 0,
6265};
6266#endif
6267#endif
6268
6269#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
6270static struct mmc_platform_data msm7x30_sdc2_data = {
6271 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
6272 .translate_vdd = msm_sdcc_setup_power,
6273#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
6274 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
6275#else
6276 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6277#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006278 .msmsdcc_fmin = 144000,
6279 .msmsdcc_fmid = 24576000,
6280 .msmsdcc_fmax = 49152000,
6281 .nonremovable = 1,
6282};
6283#endif
6284
6285#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
6286static struct mmc_platform_data msm7x30_sdc3_data = {
6287 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6288 .translate_vdd = msm_sdcc_setup_power,
6289 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006290 .sdiowakeup_irq = MSM_GPIO_TO_INT(118),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006291 .msmsdcc_fmin = 144000,
6292 .msmsdcc_fmid = 24576000,
6293 .msmsdcc_fmax = 49152000,
6294 .nonremovable = 0,
6295};
6296#endif
6297
6298#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6299static struct mmc_platform_data msm7x30_sdc4_data = {
6300 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6301 .translate_vdd = msm_sdcc_setup_power,
6302 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6303#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6304 .status = msm7x30_sdcc_slot_status,
6305 .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
6306 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
6307#endif
6308 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006309 .msmsdcc_fmin = 144000,
6310 .msmsdcc_fmid = 24576000,
6311 .msmsdcc_fmax = 49152000,
6312 .nonremovable = 0,
6313};
6314#endif
6315
6316#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006317static int msm_sdc1_lvlshft_enable(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006318{
Justin Paupore3f40f342011-08-10 18:52:16 -07006319 static struct regulator *ldo5;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006320 int rc;
6321
6322 /* Enable LDO5, an input to the FET that powers slot 1 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006323
Justin Paupore3f40f342011-08-10 18:52:16 -07006324 ldo5 = regulator_get(NULL, "ldo5");
6325
6326 if (IS_ERR(ldo5)) {
6327 rc = PTR_ERR(ldo5);
6328 pr_err("%s: could not get ldo5: %d\n", __func__, rc);
6329 goto out;
6330 }
6331
6332 rc = regulator_set_voltage(ldo5, 2850000, 2850000);
6333 if (rc) {
6334 pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc);
6335 goto ldo5_free;
6336 }
6337
6338 rc = regulator_enable(ldo5);
6339 if (rc) {
6340 pr_err("%s: could not enable ldo5: %d\n", __func__, rc);
6341 goto ldo5_free;
6342 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006343
6344 /* Enable GPIO 35, to turn on the FET that powers slot 1 */
6345 rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
6346 ARRAY_SIZE(sdc1_lvlshft_cfg_data));
6347 if (rc)
6348 printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
6349
6350 rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg),
6351 1);
6352 if (rc)
6353 printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006354
6355 return 0;
6356
6357ldo5_free:
6358 regulator_put(ldo5);
6359out:
6360 ldo5 = NULL;
6361 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006362}
6363#endif
6364
Justin Paupore3f40f342011-08-10 18:52:16 -07006365static int mmc_regulator_init(int sdcc_no, const char *supply, int uV)
6366{
6367 int rc;
6368
6369 BUG_ON(sdcc_no < 1 || sdcc_no > 4);
6370
6371 sdcc_no--;
6372
6373 sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply);
6374
6375 if (IS_ERR(sdcc_vreg_data[sdcc_no])) {
6376 rc = PTR_ERR(sdcc_vreg_data[sdcc_no]);
6377 pr_err("%s: could not get regulator \"%s\": %d\n",
6378 __func__, supply, rc);
6379 goto out;
6380 }
6381
6382 rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV);
6383
6384 if (rc) {
6385 pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n",
6386 __func__, supply, uV, rc);
6387 goto reg_free;
6388 }
6389
6390 return rc;
6391
6392reg_free:
6393 regulator_put(sdcc_vreg_data[sdcc_no]);
6394out:
6395 sdcc_vreg_data[sdcc_no] = NULL;
6396 return rc;
6397}
6398
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006399static void __init msm7x30_init_mmc(void)
6400{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006401#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006402 if (mmc_regulator_init(1, "s3", 1800000))
6403 goto out1;
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05306404 msm7x30_sdc1_data.swfi_latency = msm7x30_power_collapse_latency(
6405 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT);
Justin Paupore3f40f342011-08-10 18:52:16 -07006406
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006407 if (machine_is_msm7x30_fluid()) {
6408 msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
Justin Paupore3f40f342011-08-10 18:52:16 -07006409 if (msm_sdc1_lvlshft_enable()) {
6410 pr_err("%s: could not enable level shift\n");
6411 goto out1;
6412 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006413 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006414
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006415 msm_add_sdcc(1, &msm7x30_sdc1_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006416out1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006417#endif
6418#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006419 if (mmc_regulator_init(2, "s3", 1800000))
6420 goto out2;
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05306421 msm7x30_sdc2_data.swfi_latency = msm7x30_power_collapse_latency(
6422 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT);
Justin Paupore3f40f342011-08-10 18:52:16 -07006423
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006424 if (machine_is_msm8x55_svlte_surf())
6425 msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
Sujith Reddy Thumma84a0f512011-08-29 09:57:03 +05306426 if (machine_is_msm8x55_svlte_surf() ||
6427 machine_is_msm8x55_svlte_ffa()) {
6428 msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
6429 msm7x30_sdc2_data.is_sdio_al_client = 1;
6430 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006431
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006432 msm_add_sdcc(2, &msm7x30_sdc2_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006433out2:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006434#endif
6435#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006436 if (mmc_regulator_init(3, "s3", 1800000))
6437 goto out3;
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05306438 msm7x30_sdc3_data.swfi_latency = msm7x30_power_collapse_latency(
6439 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT);
Justin Paupore3f40f342011-08-10 18:52:16 -07006440
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006441 msm_sdcc_setup_gpio(3, 1);
6442 msm_add_sdcc(3, &msm7x30_sdc3_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006443out3:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006444#endif
6445#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006446 if (mmc_regulator_init(4, "mmc", 2850000))
6447 return;
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05306448 msm7x30_sdc4_data.swfi_latency = msm7x30_power_collapse_latency(
6449 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT);
Justin Paupore3f40f342011-08-10 18:52:16 -07006450
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006451 msm_add_sdcc(4, &msm7x30_sdc4_data);
6452#endif
6453
6454}
6455
6456static void __init msm7x30_init_nand(void)
6457{
6458 char *build_id;
6459 struct flash_platform_data *plat_data;
6460
6461 build_id = socinfo_get_build_id();
6462 if (build_id == NULL) {
6463 pr_err("%s: Build ID not available from socinfo\n", __func__);
6464 return;
6465 }
6466
6467 if (build_id[8] == 'C' &&
6468 !msm_gpios_request_enable(msm_nand_ebi2_cfg_data,
6469 ARRAY_SIZE(msm_nand_ebi2_cfg_data))) {
6470 plat_data = msm_device_nand.dev.platform_data;
6471 plat_data->interleave = 1;
6472 printk(KERN_INFO "%s: Interleave mode Build ID found\n",
6473 __func__);
6474 }
6475}
6476
6477#ifdef CONFIG_SERIAL_MSM_CONSOLE
6478static struct msm_gpio uart2_config_data[] = {
6479 { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
6480 { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
6481 { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
6482 { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
6483};
6484
6485static void msm7x30_init_uart2(void)
6486{
6487 msm_gpios_request_enable(uart2_config_data,
6488 ARRAY_SIZE(uart2_config_data));
6489
6490}
6491#endif
6492
6493/* TSIF begin */
6494#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6495
6496#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6497#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6498#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6499#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6500
6501static const struct msm_gpio tsif_gpios[] = {
6502 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
6503 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
6504 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
6505 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
6506};
6507
6508static struct msm_tsif_platform_data tsif_platform_data = {
6509 .num_gpios = ARRAY_SIZE(tsif_gpios),
6510 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -07006511 .tsif_pclk = "iface_clk",
6512 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006513};
6514#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
6515/* TSIF end */
6516
6517static void __init pmic8058_leds_init(void)
6518{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306519 if (machine_is_msm7x30_surf())
6520 pm8058_7x30_data.leds_pdata = &pm8058_surf_leds_data;
6521 else if (!machine_is_msm7x30_fluid())
6522 pm8058_7x30_data.leds_pdata = &pm8058_ffa_leds_data;
6523 else if (machine_is_msm7x30_fluid())
6524 pm8058_7x30_data.leds_pdata = &pm8058_fluid_leds_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006525}
6526
6527static struct msm_spm_platform_data msm_spm_data __initdata = {
Taniya Das298de8c2012-02-16 11:45:31 +05306528 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006529
6530 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
6531 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
6532 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
6533 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
6534
6535 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
6536 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
6537 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
6538
6539 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
6540 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
6541 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
6542
6543 .awake_vlevel = 0xF2,
6544 .retention_vlevel = 0xE0,
6545 .collapse_vlevel = 0x72,
6546 .retention_mid_vlevel = 0xE0,
6547 .collapse_mid_vlevel = 0xE0,
6548
6549 .vctl_timeout_us = 50,
6550};
6551
6552#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6553 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6554
6555#define TSC2007_TS_PEN_INT 20
6556
6557static struct msm_gpio tsc2007_config_data[] = {
6558 { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
6559 "tsc2007_irq" },
6560};
6561
Justin Paupore3f40f342011-08-10 18:52:16 -07006562static struct regulator_bulk_data tsc2007_regs[] = {
6563 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
6564 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
6565};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006566
6567static int tsc2007_init(void)
6568{
6569 int rc;
6570
Justin Paupore3f40f342011-08-10 18:52:16 -07006571 rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006572
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006573 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006574 pr_err("%s: could not get regulators: %d\n", __func__, rc);
6575 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006576 }
6577
Justin Paupore3f40f342011-08-10 18:52:16 -07006578 rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6579
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006580 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006581 pr_err("%s: could not set voltages: %d\n", __func__, rc);
6582 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006583 }
6584
Justin Paupore3f40f342011-08-10 18:52:16 -07006585 rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006586
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006587 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006588 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
6589 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006590 }
6591
6592 rc = msm_gpios_request_enable(tsc2007_config_data,
6593 ARRAY_SIZE(tsc2007_config_data));
6594 if (rc) {
6595 pr_err("%s: Unable to request gpios\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006596 goto reg_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006597 }
6598
6599 return 0;
6600
Justin Paupore3f40f342011-08-10 18:52:16 -07006601reg_disable:
6602 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6603reg_free:
6604 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6605out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006606 return rc;
6607}
6608
6609static int tsc2007_get_pendown_state(void)
6610{
6611 int rc;
6612
6613 rc = gpio_get_value(TSC2007_TS_PEN_INT);
6614 if (rc < 0) {
6615 pr_err("%s: MSM GPIO %d read failed\n", __func__,
6616 TSC2007_TS_PEN_INT);
6617 return rc;
6618 }
6619
6620 return (rc == 0 ? 1 : 0);
6621}
6622
6623static void tsc2007_exit(void)
6624{
Justin Paupore3f40f342011-08-10 18:52:16 -07006625
6626 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6627 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006628
6629 msm_gpios_disable_free(tsc2007_config_data,
6630 ARRAY_SIZE(tsc2007_config_data));
6631}
6632
6633static int tsc2007_power_shutdown(bool enable)
6634{
6635 int rc;
6636
Justin Paupore3f40f342011-08-10 18:52:16 -07006637 rc = (enable == false) ?
6638 regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) :
6639 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6640
6641 if (rc) {
6642 pr_err("%s: could not %sable regulators: %d\n",
6643 __func__, enable ? "dis" : "en", rc);
6644 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006645 }
6646
Justin Paupore3f40f342011-08-10 18:52:16 -07006647 if (enable == false)
6648 msleep(20);
6649
6650 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006651}
6652
6653static struct tsc2007_platform_data tsc2007_ts_data = {
6654 .model = 2007,
6655 .x_plate_ohms = 300,
Anirudh Ghayala2cf2e22012-01-25 12:29:42 +05306656 .min_x = 210,
6657 .max_x = 3832,
6658 .min_y = 150,
6659 .max_y = 3936,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006660 .irq_flags = IRQF_TRIGGER_LOW,
6661 .init_platform_hw = tsc2007_init,
6662 .exit_platform_hw = tsc2007_exit,
6663 .power_shutdown = tsc2007_power_shutdown,
6664 .invert_x = true,
6665 .invert_y = true,
6666 /* REVISIT: Temporary fix for reversed pressure */
6667 .invert_z1 = true,
6668 .invert_z2 = true,
6669 .get_pendown_state = tsc2007_get_pendown_state,
6670};
6671
6672static struct i2c_board_info tsc_i2c_board_info[] = {
6673 {
6674 I2C_BOARD_INFO("tsc2007", 0x48),
6675 .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
6676 .platform_data = &tsc2007_ts_data,
6677 },
6678};
6679#endif
6680
Justin Paupore3f40f342011-08-10 18:52:16 -07006681static struct regulator_bulk_data regs_isa1200[] = {
6682 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
6683 { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006684};
6685
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006686static int isa1200_power(int vreg_on)
6687{
Justin Paupore3f40f342011-08-10 18:52:16 -07006688 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006689
Justin Paupore3f40f342011-08-10 18:52:16 -07006690 rc = vreg_on ?
6691 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) :
6692 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006693
Justin Paupore3f40f342011-08-10 18:52:16 -07006694 if (rc) {
6695 pr_err("%s: could not %sable regulators: %d\n",
6696 __func__, vreg_on ? "en" : "dis", rc);
6697 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006698 }
6699
6700 /* vote for DO buffer */
6701 rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO,
6702 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
6703 if (rc) {
6704 pr_err("%s: unable to %svote for d0 clk\n",
6705 __func__, vreg_on ? "" : "de-");
6706 goto vreg_fail;
6707 }
6708
6709 return 0;
6710
6711vreg_fail:
Justin Paupore3f40f342011-08-10 18:52:16 -07006712 if (vreg_on)
6713 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6714 else
6715 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6716out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006717 return rc;
6718}
6719
6720static int isa1200_dev_setup(bool enable)
6721{
Justin Paupore3f40f342011-08-10 18:52:16 -07006722 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006723
6724 if (enable == true) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006725 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200),
6726 regs_isa1200);
6727
6728 if (rc) {
6729 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006730 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006731 goto out;
6732 }
6733
6734 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200),
6735 regs_isa1200);
6736 if (rc) {
6737 pr_err("%s: could not set voltages: %d\n",
6738 __func__, rc);
6739 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006740 }
6741
6742 rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
6743 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
6744 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
6745 if (rc) {
6746 pr_err("%s: Could not configure gpio %d\n",
6747 __func__, HAP_LVL_SHFT_MSM_GPIO);
Justin Paupore3f40f342011-08-10 18:52:16 -07006748 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006749 }
6750
6751 rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
6752 if (rc) {
6753 pr_err("%s: unable to request gpio %d (%d)\n",
6754 __func__, HAP_LVL_SHFT_MSM_GPIO, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006755 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006756 }
6757
6758 gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
6759 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006760 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006761 gpio_free(HAP_LVL_SHFT_MSM_GPIO);
6762 }
6763
6764 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07006765
6766reg_free:
6767 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6768out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006769 return rc;
6770}
6771static struct isa1200_platform_data isa1200_1_pdata = {
6772 .name = "vibrator",
6773 .power_on = isa1200_power,
6774 .dev_setup = isa1200_dev_setup,
6775 .pwm_ch_id = 1, /*channel id*/
6776 /*gpio to enable haptic*/
6777 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka03122322011-09-09 15:15:43 +05306778 .hap_len_gpio = -1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006779 .max_timeout = 15000,
6780 .mode_ctrl = PWM_GEN_MODE,
6781 .pwm_fd = {
6782 .pwm_div = 256,
6783 },
6784 .is_erm = false,
6785 .smart_en = true,
6786 .ext_clk_en = true,
6787 .chip_en = 1,
6788};
6789
6790static struct i2c_board_info msm_isa1200_board_info[] = {
6791 {
6792 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
6793 .platform_data = &isa1200_1_pdata,
6794 },
6795};
6796
6797
6798static int kp_flip_mpp_config(void)
6799{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306800 struct pm8xxx_mpp_config_data kp_flip_mpp = {
6801 .type = PM8XXX_MPP_TYPE_D_INPUT,
6802 .level = PM8018_MPP_DIG_LEVEL_S3,
6803 .control = PM8XXX_MPP_DIN_TO_INT,
6804 };
6805
6806 return pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(PM_FLIP_MPP),
6807 &kp_flip_mpp);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006808}
6809
6810static struct flip_switch_pdata flip_switch_data = {
6811 .name = "kp_flip_switch",
6812 .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP,
6813 .left_key = KEY_OPEN,
6814 .right_key = KEY_CLOSE,
6815 .active_low = 0,
6816 .wakeup = 1,
6817 .flip_mpp_config = kp_flip_mpp_config,
6818};
6819
6820static struct platform_device flip_switch_device = {
6821 .name = "kp_flip_switch",
6822 .id = -1,
6823 .dev = {
6824 .platform_data = &flip_switch_data,
6825 }
6826};
6827
Justin Paupore3f40f342011-08-10 18:52:16 -07006828static struct regulator_bulk_data regs_tma300[] = {
6829 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
6830 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006831};
6832
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006833static int tma300_power(int vreg_on)
6834{
Justin Paupore3f40f342011-08-10 18:52:16 -07006835 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006836
Justin Paupore3f40f342011-08-10 18:52:16 -07006837 rc = vreg_on ?
6838 regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) :
6839 regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006840
Justin Paupore3f40f342011-08-10 18:52:16 -07006841 if (rc)
6842 pr_err("%s: could not %sable regulators: %d\n",
6843 __func__, vreg_on ? "en" : "dis", rc);
6844 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006845}
6846
6847#define TS_GPIO_IRQ 150
6848
6849static int tma300_dev_setup(bool enable)
6850{
Justin Paupore3f40f342011-08-10 18:52:16 -07006851 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006852
6853 if (enable) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006854 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300),
6855 regs_tma300);
6856
6857 if (rc) {
6858 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006859 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006860 goto out;
6861 }
6862
6863 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300),
6864 regs_tma300);
6865
6866 if (rc) {
6867 pr_err("%s: could not set voltages: %d\n",
6868 __func__, rc);
6869 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006870 }
6871
6872 /* enable interrupt gpio */
6873 rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
6874 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
6875 if (rc) {
6876 pr_err("%s: Could not configure gpio %d\n",
6877 __func__, TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -07006878 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006879 }
6880
6881 /* virtual keys */
6882 tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
6883 properties_kobj = kobject_create_and_add("board_properties",
6884 NULL);
6885 if (!properties_kobj) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006886 pr_err("%s: failed to create a kobject "
6887 "for board_properties\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006888 rc = -ENOMEM;
Justin Paupore3f40f342011-08-10 18:52:16 -07006889 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006890 }
6891 rc = sysfs_create_group(properties_kobj,
6892 &tma300_properties_attr_group);
6893 if (rc) {
6894 pr_err("%s: failed to create a sysfs entry %s\n",
6895 __func__, tma300_vkeys_attr.attr.name);
Justin Paupore3f40f342011-08-10 18:52:16 -07006896 goto kobj_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006897 }
6898 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006899 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006900 /* destroy virtual keys */
6901 if (properties_kobj) {
6902 sysfs_remove_group(properties_kobj,
6903 &tma300_properties_attr_group);
6904 kobject_put(properties_kobj);
6905 }
6906 }
6907 return 0;
6908
Justin Paupore3f40f342011-08-10 18:52:16 -07006909kobj_free:
6910 kobject_put(properties_kobj);
6911 properties_kobj = NULL;
6912reg_free:
6913 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
6914out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006915 return rc;
6916}
6917
6918static struct cy8c_ts_platform_data cy8ctma300_pdata = {
6919 .power_on = tma300_power,
6920 .dev_setup = tma300_dev_setup,
6921 .ts_name = "msm_tma300_ts",
6922 .dis_min_x = 0,
6923 .dis_max_x = 479,
6924 .dis_min_y = 0,
6925 .dis_max_y = 799,
6926 .res_x = 479,
6927 .res_y = 1009,
6928 .min_tid = 1,
6929 .max_tid = 255,
6930 .min_touch = 0,
6931 .max_touch = 255,
6932 .min_width = 0,
6933 .max_width = 255,
6934 .invert_y = 1,
6935 .nfingers = 4,
6936 .irq_gpio = TS_GPIO_IRQ,
6937 .resout_gpio = -1,
6938};
6939
6940static struct i2c_board_info cy8ctma300_board_info[] = {
6941 {
6942 I2C_BOARD_INFO("cy8ctma300", 0x2),
6943 .platform_data = &cy8ctma300_pdata,
6944 }
6945};
6946
Daniel Walker8d747cd2010-02-25 11:37:43 -08006947static void __init msm7x30_init(void)
6948{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006949 int rc;
6950 unsigned smem_size;
6951 uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56,
6952 0,
6953 GPIO_CFG_OUTPUT,
6954 GPIO_CFG_NO_PULL,
6955 GPIO_CFG_2MA);
6956 uint32_t soc_version = 0;
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05306957
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006958 soc_version = socinfo_get_version();
6959
Stephen Boydbb600ae2011-08-02 20:11:40 -07006960 msm_clock_init(&msm7x30_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006961#ifdef CONFIG_SERIAL_MSM_CONSOLE
6962 msm7x30_init_uart2();
6963#endif
6964 msm_spm_init(&msm_spm_data, 1);
Matt Wagantallec57f062011-08-16 23:54:46 -07006965 acpuclk_init(&acpuclk_7x30_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006966 if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid())
6967 msm7x30_cfg_smsc911x();
6968
6969#ifdef CONFIG_USB_MSM_OTG_72K
6970 if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 &&
6971 SOCINFO_VERSION_MINOR(soc_version) >= 1) {
6972 pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
6973 msm_otg_pdata.ldo_set_voltage = 0;
6974 }
6975
6976 msm_device_otg.dev.platform_data = &msm_otg_pdata;
6977#ifdef CONFIG_USB_GADGET
6978 msm_otg_pdata.swfi_latency =
6979 msm_pm_data
6980 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
6981 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
6982#endif
6983#endif
6984 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
6985 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
6986#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6987 msm_device_tsif.dev.platform_data = &tsif_platform_data;
6988#endif
6989 if (machine_is_msm7x30_fluid()) {
6990 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
6991 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
6992 } else {
6993 msm_adc_pdata.dev_names = msm_adc_surf_device_names;
6994 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names);
6995 }
6996
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306997 pmic8058_leds_init();
6998
6999 buses_init();
7000
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05307001#ifdef CONFIG_MSM_SSBI
7002 msm_device_ssbi_pmic1.dev.platform_data =
7003 &msm7x30_ssbi_pm8058_pdata;
7004#endif
7005
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007006 platform_add_devices(msm_footswitch_devices,
7007 msm_num_footswitch_devices);
Daniel Walker8d747cd2010-02-25 11:37:43 -08007008 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007009#ifdef CONFIG_USB_EHCI_MSM_72K
7010 msm_add_host(0, &msm_usb_host_pdata);
7011#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07007012#ifdef CONFIG_MSM_CAMERA_V4L2
7013 msm7x30_init_cam();
7014#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007015 msm7x30_init_mmc();
7016 msm7x30_init_nand();
7017 msm_qsd_spi_init();
7018
7019#ifdef CONFIG_SPI_QSD
7020 if (machine_is_msm7x30_fluid())
7021 spi_register_board_info(lcdc_sharp_spi_board_info,
7022 ARRAY_SIZE(lcdc_sharp_spi_board_info));
7023 else
7024 spi_register_board_info(lcdc_toshiba_spi_board_info,
7025 ARRAY_SIZE(lcdc_toshiba_spi_board_info));
7026#endif
7027
Justin Paupore3f40f342011-08-10 18:52:16 -07007028 atv_dac_power_init();
7029 sensors_ldo_init();
7030 hdmi_init_regs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007031 msm_fb_add_devices();
7032 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06007033 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05307034 msm_pm_register_irqs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007035 msm_device_i2c_init();
7036 msm_device_i2c_2_init();
7037 qup_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007038 msm7x30_init_marimba();
7039#ifdef CONFIG_MSM7KV2_AUDIO
7040 snddev_poweramp_gpio_init();
Justin Paupore3f40f342011-08-10 18:52:16 -07007041 snddev_hsed_voltage_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007042 aux_pcm_gpio_init();
7043#endif
7044
7045 i2c_register_board_info(0, msm_i2c_board_info,
7046 ARRAY_SIZE(msm_i2c_board_info));
7047
7048 if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid())
7049 marimba_pdata.tsadc = &marimba_tsadc_pdata;
7050
7051 if (machine_is_msm7x30_fluid())
7052 i2c_register_board_info(0, cy8info,
7053 ARRAY_SIZE(cy8info));
7054#ifdef CONFIG_BOSCH_BMA150
7055 if (machine_is_msm7x30_fluid())
7056 i2c_register_board_info(0, bma150_board_info,
7057 ARRAY_SIZE(bma150_board_info));
7058#endif
7059
7060 i2c_register_board_info(2, msm_marimba_board_info,
7061 ARRAY_SIZE(msm_marimba_board_info));
7062
7063 i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info,
7064 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info));
7065
7066 i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
7067 ARRAY_SIZE(msm_camera_boardinfo));
7068
7069 bt_power_init();
7070#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007071 msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
7072#endif
7073 if (machine_is_msm7x30_fluid())
7074 i2c_register_board_info(0, msm_isa1200_board_info,
7075 ARRAY_SIZE(msm_isa1200_board_info));
7076
7077#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
7078 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
7079 if (machine_is_msm8x55_svlte_ffa())
7080 i2c_register_board_info(2, tsc_i2c_board_info,
7081 ARRAY_SIZE(tsc_i2c_board_info));
7082#endif
7083
7084 if (machine_is_msm7x30_surf())
7085 platform_device_register(&flip_switch_device);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307086
7087 pm8058_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007088
7089 if (machine_is_msm7x30_fluid()) {
7090 /* Initialize platform data for fluid v2 hardware */
7091 if (SOCINFO_VERSION_MAJOR(
7092 socinfo_get_platform_version()) == 2) {
7093 cy8ctma300_pdata.res_y = 920;
7094 cy8ctma300_pdata.invert_y = 0;
7095 }
7096 i2c_register_board_info(0, cy8ctma300_board_info,
7097 ARRAY_SIZE(cy8ctma300_board_info));
7098 }
7099
7100 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
7101 rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE);
7102 if (rc)
7103 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
7104 __func__, usb_hub_gpio_cfg_value, rc);
7105 }
7106
7107 boot_reason = *(unsigned int *)
7108 (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
7109 printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
7110}
7111
7112static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
7113static int __init pmem_sf_size_setup(char *p)
7114{
7115 pmem_sf_size = memparse(p, NULL);
7116 return 0;
7117}
7118early_param("pmem_sf_size", pmem_sf_size_setup);
7119
7120static unsigned fb_size = MSM_FB_SIZE;
7121static int __init fb_size_setup(char *p)
7122{
7123 fb_size = memparse(p, NULL);
7124 return 0;
7125}
7126early_param("fb_size", fb_size_setup);
7127
7128static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
7129static int __init pmem_adsp_size_setup(char *p)
7130{
7131 pmem_adsp_size = memparse(p, NULL);
7132 return 0;
7133}
7134early_param("pmem_adsp_size", pmem_adsp_size_setup);
7135
7136static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE;
7137static int __init fluid_pmem_adsp_size_setup(char *p)
7138{
7139 fluid_pmem_adsp_size = memparse(p, NULL);
7140 return 0;
7141}
7142early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup);
7143
7144static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
7145static int __init pmem_audio_size_setup(char *p)
7146{
7147 pmem_audio_size = memparse(p, NULL);
7148 return 0;
7149}
7150early_param("pmem_audio_size", pmem_audio_size_setup);
7151
7152static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE;
7153static int __init pmem_kernel_ebi0_size_setup(char *p)
7154{
7155 pmem_kernel_ebi0_size = memparse(p, NULL);
7156 return 0;
7157}
7158early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
7159
7160static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
7161 [MEMTYPE_SMI] = {
7162 },
7163 [MEMTYPE_EBI0] = {
7164 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7165 },
7166 [MEMTYPE_EBI1] = {
7167 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7168 },
7169};
7170
7171static void __init size_pmem_devices(void)
7172{
7173#ifdef CONFIG_ANDROID_PMEM
7174 unsigned long size;
7175
7176 if machine_is_msm7x30_fluid()
7177 size = fluid_pmem_adsp_size;
7178 else
7179 size = pmem_adsp_size;
7180 android_pmem_adsp_pdata.size = size;
7181 android_pmem_audio_pdata.size = pmem_audio_size;
7182 android_pmem_pdata.size = pmem_sf_size;
7183#endif
7184}
7185
7186static void __init reserve_memory_for(struct android_pmem_platform_data *p)
7187{
7188 msm7x30_reserve_table[p->memory_type].size += p->size;
7189}
7190
7191static void __init reserve_pmem_memory(void)
7192{
7193#ifdef CONFIG_ANDROID_PMEM
7194 reserve_memory_for(&android_pmem_adsp_pdata);
7195 reserve_memory_for(&android_pmem_audio_pdata);
7196 reserve_memory_for(&android_pmem_pdata);
7197 msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
7198#endif
7199}
7200
7201static void __init msm7x30_calculate_reserve_sizes(void)
7202{
7203 size_pmem_devices();
7204 reserve_pmem_memory();
7205}
7206
7207static int msm7x30_paddr_to_memtype(unsigned int paddr)
7208{
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307209 if (paddr < phys_add)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007210 return MEMTYPE_EBI0;
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307211 if (paddr >= phys_add && paddr < 0x80000000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007212 return MEMTYPE_EBI1;
7213 return MEMTYPE_NONE;
7214}
7215
7216static struct reserve_info msm7x30_reserve_info __initdata = {
7217 .memtype_reserve_table = msm7x30_reserve_table,
7218 .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes,
7219 .paddr_to_memtype = msm7x30_paddr_to_memtype,
7220};
7221
7222static void __init msm7x30_reserve(void)
7223{
7224 reserve_info = &msm7x30_reserve_info;
7225 msm_reserve();
7226}
7227
7228static void __init msm7x30_allocate_memory_regions(void)
7229{
7230 void *addr;
7231 unsigned long size;
7232
7233 size = fb_size ? : MSM_FB_SIZE;
7234 addr = alloc_bootmem_align(size, 0x1000);
7235 msm_fb_resources[0].start = __pa(addr);
7236 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
7237 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
7238 size, addr, __pa(addr));
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08007239
7240#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
7241 size = MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE;
7242 addr = alloc_bootmem_align(size, 0x1000);
7243 msm_v4l2_video_overlay_resources[0].start = __pa(addr);
7244 msm_v4l2_video_overlay_resources[0].end =
7245 msm_v4l2_video_overlay_resources[0].start + size - 1;
7246 pr_debug("allocating %lu bytes at %p (%lx physical) for v4l2\n",
7247 size, addr, __pa(addr));
7248#endif
Daniel Walker8d747cd2010-02-25 11:37:43 -08007249}
7250
7251static void __init msm7x30_map_io(void)
7252{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007253 msm_shared_ram_phys = 0x00100000;
Daniel Walker8d747cd2010-02-25 11:37:43 -08007254 msm_map_msm7x30_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007255 if (socinfo_init() < 0)
7256 printk(KERN_ERR "%s: socinfo_init() failed!\n",
7257 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007258}
7259
7260static void __init msm7x30_init_early(void)
7261{
7262 msm7x30_allocate_memory_regions();
Daniel Walker8d747cd2010-02-25 11:37:43 -08007263}
7264
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307265static void __init msm7x30_fixup(struct machine_desc *desc, struct tag *tags,
7266 char **cmdline, struct meminfo *mi)
7267{
7268 for (; tags->hdr.size; tags = tag_next(tags)) {
7269 if (tags->hdr.tag == ATAG_MEM && tags->u.mem.start ==
7270 DDR1_BANK_BASE) {
7271 ebi1_phys_offset = DDR1_BANK_BASE;
7272 phys_add = DDR1_BANK_BASE;
7273 break;
7274 }
7275 }
7276}
7277
Daniel Walker8d747cd2010-02-25 11:37:43 -08007278MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00007279 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007280 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007281 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007282 .init_irq = msm7x30_init_irq,
7283 .init_machine = msm7x30_init,
7284 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007285 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307286 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307287 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007288MACHINE_END
7289
7290MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00007291 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007292 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007293 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007294 .init_irq = msm7x30_init_irq,
7295 .init_machine = msm7x30_init,
7296 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007297 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307298 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307299 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007300MACHINE_END
7301
7302MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
Russell Kingb75c1782011-01-04 19:03:16 +00007303 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007304 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007305 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007306 .init_irq = msm7x30_init_irq,
7307 .init_machine = msm7x30_init,
7308 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007309 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307310 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307311 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007312MACHINE_END
7313
7314MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
7315 .boot_params = PHYS_OFFSET + 0x100,
7316 .map_io = msm7x30_map_io,
7317 .reserve = msm7x30_reserve,
7318 .init_irq = msm7x30_init_irq,
7319 .init_machine = msm7x30_init,
7320 .timer = &msm_timer,
7321 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307322 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307323 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007324MACHINE_END
7325
7326MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA")
7327 .boot_params = PHYS_OFFSET + 0x100,
7328 .map_io = msm7x30_map_io,
7329 .reserve = msm7x30_reserve,
7330 .init_irq = msm7x30_init_irq,
7331 .init_machine = msm7x30_init,
7332 .timer = &msm_timer,
7333 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307334 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307335 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007336MACHINE_END
7337MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
7338 .boot_params = PHYS_OFFSET + 0x100,
7339 .map_io = msm7x30_map_io,
7340 .reserve = msm7x30_reserve,
7341 .init_irq = msm7x30_init_irq,
7342 .init_machine = msm7x30_init,
7343 .timer = &msm_timer,
7344 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307345 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307346 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007347MACHINE_END
7348MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA")
7349 .boot_params = PHYS_OFFSET + 0x100,
7350 .map_io = msm7x30_map_io,
7351 .reserve = msm7x30_reserve,
7352 .init_irq = msm7x30_init_irq,
7353 .init_machine = msm7x30_init,
7354 .timer = &msm_timer,
7355 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307356 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307357 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007358MACHINE_END