blob: 7fa4968053e418e0f6e3cd70488d3e33d8983714 [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
Kevin Chan94b4c832012-03-02 21:27:16 -0800996static struct platform_device msm_camera_server = {
997 .name = "msm_cam_server",
998 .id = 0,
999};
1000
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001001void __init msm7x30_init_cam(void)
1002{
Kevin Chan94b4c832012-03-02 21:27:16 -08001003 platform_device_register(&msm_camera_server);
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001004 platform_device_register(&msm_device_csic0);
1005 platform_device_register(&msm_device_vfe);
1006 platform_device_register(&msm_device_vpe);
1007}
1008
1009#ifdef CONFIG_I2C
1010static struct i2c_board_info msm_camera_boardinfo[] = {
1011 {
1012 I2C_BOARD_INFO("vx6953", 0x20),
1013 .platform_data = &msm_camera_sensor_vx6953_data,
1014 },
1015};
1016#endif
1017#else
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001018static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
1019#ifdef CONFIG_MT9D112
1020 {
1021 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
Dima Zavinba5499e2011-01-10 11:00:30 -08001022 },
1023#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001024#ifdef CONFIG_WEBCAM_OV9726
1025 {
1026 I2C_BOARD_INFO("ov9726", 0x10),
1027 },
1028#endif
1029#ifdef CONFIG_S5K3E2FX
1030 {
1031 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
1032 },
1033#endif
1034#ifdef CONFIG_MT9P012
1035 {
1036 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
1037 },
1038#endif
1039#ifdef CONFIG_VX6953
1040 {
1041 I2C_BOARD_INFO("vx6953", 0x20),
1042 },
1043#endif
1044#ifdef CONFIG_MT9E013
1045 {
1046 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
1047 },
1048#endif
1049#ifdef CONFIG_SN12M0PZ
1050 {
1051 I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1),
1052 },
1053#endif
1054#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
1055 {
1056 I2C_BOARD_INFO("mt9t013", 0x6C),
1057 },
1058#endif
1059
Dima Zavinba5499e2011-01-10 11:00:30 -08001060};
1061
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001062#ifdef CONFIG_MSM_CAMERA
1063#define CAM_STNDBY 143
1064static uint32_t camera_off_vcm_gpio_table[] = {
1065GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */
1066};
1067
1068static uint32_t camera_off_gpio_table[] = {
1069 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001070 /* RST */
1071 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1072 /* DAT2 */
1073 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1074 /* DAT3 */
1075 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1076 /* DAT4 */
1077 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1078 /* DAT5 */
1079 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1080 /* DAT6 */
1081 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1082 /* DAT7 */
1083 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1084 /* DAT8 */
1085 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1086 /* DAT9 */
1087 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1088 /* DAT10 */
1089 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1090 /* DAT11 */
1091 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1092 /* PCLK */
1093 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1094 /* HSYNC_IN */
1095 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1096 /* VSYNC_IN */
1097 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1098 /* MCLK */
1099 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001100};
1101
1102static uint32_t camera_on_vcm_gpio_table[] = {
1103GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */
1104};
1105
1106static uint32_t camera_on_gpio_table[] = {
1107 /* parallel CAMERA interfaces */
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001108 /* RST */
1109 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1110 /* DAT2 */
1111 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1112 /* DAT3 */
1113 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1114 /* DAT4 */
1115 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1116 /* DAT5 */
1117 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1118 /* DAT6 */
1119 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1120 /* DAT7 */
1121 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1122 /* DAT8 */
1123 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1124 /* DAT9 */
1125 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1126 /* DAT10 */
1127 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1128 /* DAT11 */
1129 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1130 /* PCLK */
1131 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1132 /* HSYNC_IN */
1133 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1134 /* VSYNC_IN */
1135 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1136 /* MCLK */
1137 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001138};
1139
1140static uint32_t camera_off_gpio_fluid_table[] = {
1141 /* FLUID: CAM_VGA_RST_N */
1142 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1143 /* FLUID: CAMIF_STANDBY */
1144 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1145};
1146
1147static uint32_t camera_on_gpio_fluid_table[] = {
1148 /* FLUID: CAM_VGA_RST_N */
1149 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1150 /* FLUID: CAMIF_STANDBY */
1151 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
1152};
1153
1154static void config_gpio_table(uint32_t *table, int len)
1155{
1156 int n, rc;
1157 for (n = 0; n < len; n++) {
1158 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
1159 if (rc) {
1160 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
1161 __func__, table[n], rc);
1162 break;
1163 }
1164 }
1165}
1166static int config_camera_on_gpios(void)
1167{
1168 config_gpio_table(camera_on_gpio_table,
1169 ARRAY_SIZE(camera_on_gpio_table));
1170
1171 if (adie_get_detected_codec_type() != TIMPANI_ID)
1172 /* GPIO1 is shared also used in Timpani RF card so
1173 only configure it for non-Timpani RF card */
1174 config_gpio_table(camera_on_vcm_gpio_table,
1175 ARRAY_SIZE(camera_on_vcm_gpio_table));
1176
1177 if (machine_is_msm7x30_fluid()) {
1178 config_gpio_table(camera_on_gpio_fluid_table,
1179 ARRAY_SIZE(camera_on_gpio_fluid_table));
1180 /* FLUID: turn on 5V booster */
1181 gpio_set_value(
1182 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 1);
1183 /* FLUID: drive high to put secondary sensor to STANDBY */
1184 gpio_set_value(CAM_STNDBY, 1);
1185 }
1186 return 0;
1187}
1188
1189static void config_camera_off_gpios(void)
1190{
1191 config_gpio_table(camera_off_gpio_table,
1192 ARRAY_SIZE(camera_off_gpio_table));
1193
1194 if (adie_get_detected_codec_type() != TIMPANI_ID)
1195 /* GPIO1 is shared also used in Timpani RF card so
1196 only configure it for non-Timpani RF card */
1197 config_gpio_table(camera_off_vcm_gpio_table,
1198 ARRAY_SIZE(camera_off_vcm_gpio_table));
1199
1200 if (machine_is_msm7x30_fluid()) {
1201 config_gpio_table(camera_off_gpio_fluid_table,
1202 ARRAY_SIZE(camera_off_gpio_fluid_table));
1203 /* FLUID: turn off 5V booster */
1204 gpio_set_value(
1205 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 0);
1206 }
1207}
1208
1209struct resource msm_camera_resources[] = {
1210 {
1211 .start = 0xA6000000,
1212 .end = 0xA6000000 + SZ_1M - 1,
1213 .flags = IORESOURCE_MEM,
1214 },
1215 {
1216 .start = INT_VFE,
1217 .end = INT_VFE,
1218 .flags = IORESOURCE_IRQ,
1219 },
1220 {
1221 .flags = IORESOURCE_DMA,
1222 }
1223};
1224
1225struct msm_camera_device_platform_data msm_camera_device_data = {
1226 .camera_gpio_on = config_camera_on_gpios,
1227 .camera_gpio_off = config_camera_off_gpios,
1228 .ioext.camifpadphy = 0xAB000000,
1229 .ioext.camifpadsz = 0x00000400,
1230 .ioext.csiphy = 0xA6100000,
1231 .ioext.csisz = 0x00000400,
1232 .ioext.csiirq = INT_CSI,
1233 .ioclk.mclk_clk_rate = 24000000,
1234 .ioclk.vfe_clk_rate = 147456000,
1235};
1236
1237static struct msm_camera_sensor_flash_src msm_flash_src_pwm = {
1238 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PWM,
1239 ._fsrc.pwm_src.freq = 1000,
1240 ._fsrc.pwm_src.max_load = 300,
1241 ._fsrc.pwm_src.low_load = 30,
1242 ._fsrc.pwm_src.high_load = 100,
1243 ._fsrc.pwm_src.channel = 7,
1244};
1245
1246#ifdef CONFIG_MT9D112
1247static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1248 .flash_type = MSM_CAMERA_FLASH_LED,
1249 .flash_src = &msm_flash_src_pwm
1250};
1251
1252static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1253 .sensor_name = "mt9d112",
1254 .sensor_reset = 0,
1255 .sensor_pwd = 85,
1256 .vcm_pwd = 1,
1257 .vcm_enable = 0,
1258 .pdata = &msm_camera_device_data,
1259 .resource = msm_camera_resources,
1260 .num_resources = ARRAY_SIZE(msm_camera_resources),
1261 .flash_data = &flash_mt9d112,
1262 .csi_if = 0
1263};
1264
1265static struct platform_device msm_camera_sensor_mt9d112 = {
1266 .name = "msm_camera_mt9d112",
1267 .dev = {
1268 .platform_data = &msm_camera_sensor_mt9d112_data,
1269 },
1270};
1271#endif
1272
1273#ifdef CONFIG_WEBCAM_OV9726
1274
1275static struct msm_camera_sensor_platform_info ov9726_sensor_7630_info = {
1276 .mount_angle = 90
1277};
1278
1279static struct msm_camera_sensor_flash_data flash_ov9726 = {
1280 .flash_type = MSM_CAMERA_FLASH_LED,
1281 .flash_src = &msm_flash_src_pwm
1282};
1283static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
1284 .sensor_name = "ov9726",
1285 .sensor_reset = 0,
1286 .sensor_pwd = 85,
1287 .vcm_pwd = 1,
1288 .vcm_enable = 0,
1289 .pdata = &msm_camera_device_data,
1290 .resource = msm_camera_resources,
1291 .num_resources = ARRAY_SIZE(msm_camera_resources),
1292 .flash_data = &flash_ov9726,
1293 .sensor_platform_info = &ov9726_sensor_7630_info,
1294 .csi_if = 1
1295};
1296struct platform_device msm_camera_sensor_ov9726 = {
1297 .name = "msm_camera_ov9726",
1298 .dev = {
1299 .platform_data = &msm_camera_sensor_ov9726_data,
1300 },
1301};
1302#endif
1303
1304#ifdef CONFIG_S5K3E2FX
1305static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1306 .flash_type = MSM_CAMERA_FLASH_LED,
1307 .flash_src = &msm_flash_src_pwm,
1308};
1309
1310static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1311 .sensor_name = "s5k3e2fx",
1312 .sensor_reset = 0,
1313 .sensor_pwd = 85,
1314 .vcm_pwd = 1,
1315 .vcm_enable = 0,
1316 .pdata = &msm_camera_device_data,
1317 .resource = msm_camera_resources,
1318 .num_resources = ARRAY_SIZE(msm_camera_resources),
1319 .flash_data = &flash_s5k3e2fx,
1320 .csi_if = 0
1321};
1322
1323static struct platform_device msm_camera_sensor_s5k3e2fx = {
1324 .name = "msm_camera_s5k3e2fx",
1325 .dev = {
1326 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1327 },
1328};
1329#endif
1330
1331#ifdef CONFIG_MT9P012
1332static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1333 .flash_type = MSM_CAMERA_FLASH_LED,
1334 .flash_src = &msm_flash_src_pwm
1335};
1336
1337static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1338 .sensor_name = "mt9p012",
1339 .sensor_reset = 0,
1340 .sensor_pwd = 85,
1341 .vcm_pwd = 1,
1342 .vcm_enable = 1,
1343 .pdata = &msm_camera_device_data,
1344 .resource = msm_camera_resources,
1345 .num_resources = ARRAY_SIZE(msm_camera_resources),
1346 .flash_data = &flash_mt9p012,
1347 .csi_if = 0
1348};
1349
1350static struct platform_device msm_camera_sensor_mt9p012 = {
1351 .name = "msm_camera_mt9p012",
1352 .dev = {
1353 .platform_data = &msm_camera_sensor_mt9p012_data,
1354 },
1355};
1356#endif
1357
1358#ifdef CONFIG_MT9E013
1359static struct msm_camera_sensor_platform_info mt9e013_sensor_7630_info = {
1360 .mount_angle = 0
1361};
1362
1363static struct msm_camera_sensor_flash_data flash_mt9e013 = {
1364 .flash_type = MSM_CAMERA_FLASH_LED,
1365 .flash_src = &msm_flash_src_pwm
1366};
1367
1368static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
1369 .sensor_name = "mt9e013",
1370 .sensor_reset = 0,
1371 .sensor_pwd = 85,
1372 .vcm_pwd = 1,
1373 .vcm_enable = 1,
1374 .pdata = &msm_camera_device_data,
1375 .resource = msm_camera_resources,
1376 .num_resources = ARRAY_SIZE(msm_camera_resources),
1377 .flash_data = &flash_mt9e013,
1378 .sensor_platform_info = &mt9e013_sensor_7630_info,
1379 .csi_if = 1
1380};
1381
1382static struct platform_device msm_camera_sensor_mt9e013 = {
1383 .name = "msm_camera_mt9e013",
1384 .dev = {
1385 .platform_data = &msm_camera_sensor_mt9e013_data,
1386 },
1387};
1388#endif
1389
1390#ifdef CONFIG_VX6953
Jilai Wang971f97f2011-07-13 14:25:25 -04001391static struct msm_camera_sensor_platform_info vx6953_sensor_7630_info = {
1392 .mount_angle = 0
1393};
1394
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001395static struct msm_camera_sensor_flash_data flash_vx6953 = {
1396 .flash_type = MSM_CAMERA_FLASH_LED,
1397 .flash_src = &msm_flash_src_pwm
1398};
1399static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1400 .sensor_name = "vx6953",
1401 .sensor_reset = 0,
1402 .sensor_pwd = 85,
1403 .vcm_pwd = 1,
1404 .vcm_enable = 0,
1405 .pdata = &msm_camera_device_data,
1406 .resource = msm_camera_resources,
1407 .num_resources = ARRAY_SIZE(msm_camera_resources),
Jilai Wang971f97f2011-07-13 14:25:25 -04001408 .sensor_platform_info = &vx6953_sensor_7630_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001409 .flash_data = &flash_vx6953,
1410 .csi_if = 1
1411};
1412static struct platform_device msm_camera_sensor_vx6953 = {
1413 .name = "msm_camera_vx6953",
1414 .dev = {
1415 .platform_data = &msm_camera_sensor_vx6953_data,
1416 },
1417};
1418#endif
1419
1420#ifdef CONFIG_SN12M0PZ
1421static struct msm_camera_sensor_flash_src msm_flash_src_current_driver = {
1422 .flash_sr_type = MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER,
1423 ._fsrc.current_driver_src.low_current = 210,
1424 ._fsrc.current_driver_src.high_current = 700,
1425 ._fsrc.current_driver_src.driver_channel = &pm8058_fluid_leds_data,
1426};
1427
1428static struct msm_camera_sensor_flash_data flash_sn12m0pz = {
1429 .flash_type = MSM_CAMERA_FLASH_LED,
1430 .flash_src = &msm_flash_src_current_driver
1431};
1432static struct msm_camera_sensor_info msm_camera_sensor_sn12m0pz_data = {
1433 .sensor_name = "sn12m0pz",
1434 .sensor_reset = 0,
1435 .sensor_pwd = 85,
1436 .vcm_pwd = 1,
1437 .vcm_enable = 1,
1438 .pdata = &msm_camera_device_data,
1439 .flash_data = &flash_sn12m0pz,
1440 .resource = msm_camera_resources,
1441 .num_resources = ARRAY_SIZE(msm_camera_resources),
1442 .csi_if = 0
1443};
1444
1445static struct platform_device msm_camera_sensor_sn12m0pz = {
1446 .name = "msm_camera_sn12m0pz",
1447 .dev = {
1448 .platform_data = &msm_camera_sensor_sn12m0pz_data,
1449 },
1450};
1451#endif
1452
1453#ifdef CONFIG_MT9T013
1454static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1455 .flash_type = MSM_CAMERA_FLASH_LED,
1456 .flash_src = &msm_flash_src_pwm
1457};
1458
1459static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1460 .sensor_name = "mt9t013",
1461 .sensor_reset = 0,
1462 .sensor_pwd = 85,
1463 .vcm_pwd = 1,
1464 .vcm_enable = 0,
1465 .pdata = &msm_camera_device_data,
1466 .resource = msm_camera_resources,
1467 .num_resources = ARRAY_SIZE(msm_camera_resources),
1468 .flash_data = &flash_mt9t013,
1469 .csi_if = 1
1470};
1471
1472static struct platform_device msm_camera_sensor_mt9t013 = {
1473 .name = "msm_camera_mt9t013",
1474 .dev = {
1475 .platform_data = &msm_camera_sensor_mt9t013_data,
1476 },
1477};
1478#endif
1479
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001480#ifdef CONFIG_MSM_VPE
1481static struct resource msm_vpe_resources[] = {
1482 {
1483 .start = 0xAD200000,
1484 .end = 0xAD200000 + SZ_1M - 1,
1485 .flags = IORESOURCE_MEM,
1486 },
1487 {
1488 .start = INT_VPE,
1489 .end = INT_VPE,
1490 .flags = IORESOURCE_IRQ,
1491 },
1492};
1493
1494static struct platform_device msm_vpe_device = {
1495 .name = "msm_vpe",
1496 .id = 0,
1497 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1498 .resource = msm_vpe_resources,
1499};
1500#endif
1501
1502#endif /*CONFIG_MSM_CAMERA*/
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07001503#endif
1504
1505#ifdef CONFIG_MSM_GEMINI
1506static struct resource msm_gemini_resources[] = {
1507 {
1508 .start = 0xA3A00000,
1509 .end = 0xA3A00000 + 0x0150 - 1,
1510 .flags = IORESOURCE_MEM,
1511 },
1512 {
1513 .start = INT_JPEG,
1514 .end = INT_JPEG,
1515 .flags = IORESOURCE_IRQ,
1516 },
1517};
1518
1519static struct platform_device msm_gemini_device = {
1520 .name = "msm_gemini",
1521 .resource = msm_gemini_resources,
1522 .num_resources = ARRAY_SIZE(msm_gemini_resources),
1523};
1524#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001525
1526#ifdef CONFIG_MSM7KV2_AUDIO
1527static uint32_t audio_pamp_gpio_config =
1528 GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1529
1530static uint32_t audio_fluid_icodec_tx_config =
1531 GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1532
1533static int __init snddev_poweramp_gpio_init(void)
1534{
1535 int rc;
1536
1537 pr_info("snddev_poweramp_gpio_init \n");
1538 rc = gpio_tlmm_config(audio_pamp_gpio_config, GPIO_CFG_ENABLE);
1539 if (rc) {
1540 printk(KERN_ERR
1541 "%s: gpio_tlmm_config(%#x)=%d\n",
1542 __func__, audio_pamp_gpio_config, rc);
1543 }
1544 return rc;
1545}
1546
1547void msm_snddev_tx_route_config(void)
1548{
1549 int rc;
1550
1551 pr_debug("%s()\n", __func__);
1552
1553 if (machine_is_msm7x30_fluid()) {
1554 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1555 GPIO_CFG_ENABLE);
1556 if (rc) {
1557 printk(KERN_ERR
1558 "%s: gpio_tlmm_config(%#x)=%d\n",
1559 __func__, audio_fluid_icodec_tx_config, rc);
1560 } else
1561 gpio_set_value(85, 0);
1562 }
1563}
1564
1565void msm_snddev_tx_route_deconfig(void)
1566{
1567 int rc;
1568
1569 pr_debug("%s()\n", __func__);
1570
1571 if (machine_is_msm7x30_fluid()) {
1572 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1573 GPIO_CFG_DISABLE);
1574 if (rc) {
1575 printk(KERN_ERR
1576 "%s: gpio_tlmm_config(%#x)=%d\n",
1577 __func__, audio_fluid_icodec_tx_config, rc);
1578 }
1579 }
1580}
1581
1582void msm_snddev_poweramp_on(void)
1583{
1584 gpio_set_value(82, 1); /* enable spkr poweramp */
1585 pr_info("%s: power on amplifier\n", __func__);
1586}
1587
1588void msm_snddev_poweramp_off(void)
1589{
1590 gpio_set_value(82, 0); /* disable spkr poweramp */
1591 pr_info("%s: power off amplifier\n", __func__);
1592}
1593
Justin Paupore3f40f342011-08-10 18:52:16 -07001594static struct regulator_bulk_data snddev_regs[] = {
1595 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
1596 { .supply = "ncp", .min_uV = 1800000, .max_uV = 1800000 },
1597};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001598
Justin Paupore3f40f342011-08-10 18:52:16 -07001599static int __init snddev_hsed_voltage_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001600{
1601 int rc;
1602
Justin Paupore3f40f342011-08-10 18:52:16 -07001603 rc = regulator_bulk_get(NULL, ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001604
Justin Paupore3f40f342011-08-10 18:52:16 -07001605 if (rc) {
1606 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1607 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001608 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001609
1610 rc = regulator_bulk_set_voltage(ARRAY_SIZE(snddev_regs), snddev_regs);
1611
1612 if (rc) {
1613 pr_err("%s: could not set regulator voltages: %d\n",
1614 __func__, rc);
1615 goto regs_free;
1616 }
1617
1618 return 0;
1619
1620regs_free:
1621 regulator_bulk_free(ARRAY_SIZE(snddev_regs), snddev_regs);
1622out:
1623 return rc;
1624}
1625
1626
1627void msm_snddev_hsed_voltage_on(void)
1628{
1629 int rc = regulator_bulk_enable(ARRAY_SIZE(snddev_regs), snddev_regs);
1630
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001631 if (rc)
Justin Paupore3f40f342011-08-10 18:52:16 -07001632 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001633}
1634
1635void msm_snddev_hsed_voltage_off(void)
1636{
Justin Paupore3f40f342011-08-10 18:52:16 -07001637 int rc = regulator_bulk_disable(ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001638
Justin Paupore3f40f342011-08-10 18:52:16 -07001639 if (rc) {
1640 pr_err("%s: could not disable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001641 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001642}
1643
1644static unsigned aux_pcm_gpio_on[] = {
1645 GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
1646 GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
1647 GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
1648 GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
1649};
1650
1651static int __init aux_pcm_gpio_init(void)
1652{
1653 int pin, rc;
1654
1655 pr_info("aux_pcm_gpio_init \n");
1656 for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) {
1657 rc = gpio_tlmm_config(aux_pcm_gpio_on[pin],
1658 GPIO_CFG_ENABLE);
1659 if (rc) {
1660 printk(KERN_ERR
1661 "%s: gpio_tlmm_config(%#x)=%d\n",
1662 __func__, aux_pcm_gpio_on[pin], rc);
1663 }
1664 }
1665 return rc;
1666}
1667
1668static struct msm_gpio mi2s_clk_gpios[] = {
1669 { GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1670 "MI2S_SCLK"},
1671 { GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1672 "MI2S_WS"},
1673 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1674 "MI2S_MCLK_A"},
1675};
1676
1677static struct msm_gpio mi2s_rx_data_lines_gpios[] = {
1678 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1679 "MI2S_DATA_SD0_A"},
1680 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1681 "MI2S_DATA_SD1_A"},
1682 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1683 "MI2S_DATA_SD2_A"},
1684 { GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1685 "MI2S_DATA_SD3"},
1686};
1687
1688static struct msm_gpio mi2s_tx_data_lines_gpios[] = {
1689 { GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1690 "MI2S_DATA_SD3"},
1691};
1692
1693int mi2s_config_clk_gpio(void)
1694{
1695 int rc = 0;
1696
1697 rc = msm_gpios_request_enable(mi2s_clk_gpios,
1698 ARRAY_SIZE(mi2s_clk_gpios));
1699 if (rc) {
1700 pr_err("%s: enable mi2s clk gpios failed\n",
1701 __func__);
1702 return rc;
1703 }
1704 return 0;
1705}
1706
1707int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask)
1708{
1709 int i, rc = 0;
1710 sd_line_mask &= MI2S_SD_LINE_MASK;
1711
1712 switch (direction) {
1713 case DIR_TX:
1714 msm_gpios_disable_free(mi2s_tx_data_lines_gpios, 1);
1715 break;
1716 case DIR_RX:
1717 i = 0;
1718 while (sd_line_mask) {
1719 if (sd_line_mask & 0x1)
1720 msm_gpios_disable_free(
1721 mi2s_rx_data_lines_gpios + i , 1);
1722 sd_line_mask = sd_line_mask >> 1;
1723 i++;
1724 }
1725 break;
1726 default:
1727 pr_err("%s: Invaild direction direction = %u\n",
1728 __func__, direction);
1729 rc = -EINVAL;
1730 break;
1731 }
1732 return rc;
1733}
1734
1735int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask)
1736{
1737 int i , rc = 0;
1738 u8 sd_config_done_mask = 0;
1739
1740 sd_line_mask &= MI2S_SD_LINE_MASK;
1741
1742 switch (direction) {
1743 case DIR_TX:
1744 if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) ||
1745 (sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) {
1746 pr_err("%s: can not use SD0 or SD1 or SD2 for TX"
1747 ".only can use SD3. sd_line_mask = 0x%x\n",
1748 __func__ , sd_line_mask);
1749 rc = -EINVAL;
1750 } else {
1751 rc = msm_gpios_request_enable(mi2s_tx_data_lines_gpios,
1752 1);
1753 if (rc)
1754 pr_err("%s: enable mi2s gpios for TX failed\n",
1755 __func__);
1756 }
1757 break;
1758 case DIR_RX:
1759 i = 0;
1760 while (sd_line_mask && (rc == 0)) {
1761 if (sd_line_mask & 0x1) {
1762 rc = msm_gpios_request_enable(
1763 mi2s_rx_data_lines_gpios + i , 1);
1764 if (rc) {
1765 pr_err("%s: enable mi2s gpios for"
1766 "RX failed. SD line = %s\n",
1767 __func__,
1768 (mi2s_rx_data_lines_gpios + i)->label);
1769 mi2s_unconfig_data_gpio(DIR_RX,
1770 sd_config_done_mask);
1771 } else
1772 sd_config_done_mask |= (1 << i);
1773 }
1774 sd_line_mask = sd_line_mask >> 1;
1775 i++;
1776 }
1777 break;
1778 default:
1779 pr_err("%s: Invaild direction direction = %u\n",
1780 __func__, direction);
1781 rc = -EINVAL;
1782 break;
1783 }
1784 return rc;
1785}
1786
1787int mi2s_unconfig_clk_gpio(void)
1788{
1789 msm_gpios_disable_free(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios));
1790 return 0;
1791}
1792
1793#endif /* CONFIG_MSM7KV2_AUDIO */
1794
1795static int __init buses_init(void)
1796{
1797 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT,
1798 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
1799 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
1800 __func__, PMIC_GPIO_INT);
1801
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301802 if (machine_is_msm8x60_fluid())
1803 pm8058_7x30_data.keypad_pdata = &fluid_keypad_data;
1804 else
1805 pm8058_7x30_data.keypad_pdata = &surf_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001806
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001807 return 0;
1808}
1809
1810#define TIMPANI_RESET_GPIO 1
1811
1812struct bahama_config_register{
1813 u8 reg;
1814 u8 value;
1815 u8 mask;
1816};
1817
1818enum version{
1819 VER_1_0,
1820 VER_2_0,
1821 VER_UNSUPPORTED = 0xFF
1822};
1823
Justin Paupore3f40f342011-08-10 18:52:16 -07001824static struct regulator *vreg_marimba_1;
1825static struct regulator *vreg_marimba_2;
1826static struct regulator *vreg_bahama;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001827
1828static struct msm_gpio timpani_reset_gpio_cfg[] = {
1829{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
1830 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} };
1831
1832static u8 read_bahama_ver(void)
1833{
1834 int rc;
1835 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1836 u8 bahama_version;
1837
1838 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
1839 if (rc < 0) {
1840 printk(KERN_ERR
1841 "%s: version read failed: %d\n",
1842 __func__, rc);
1843 return rc;
1844 } else {
1845 printk(KERN_INFO
1846 "%s: version read got: 0x%x\n",
1847 __func__, bahama_version);
1848 }
1849
1850 switch (bahama_version) {
1851 case 0x08: /* varient of bahama v1 */
1852 case 0x10:
1853 case 0x00:
1854 return VER_1_0;
1855 case 0x09: /* variant of bahama v2 */
1856 return VER_2_0;
1857 default:
1858 return VER_UNSUPPORTED;
1859 }
1860}
1861
1862static int config_timpani_reset(void)
1863{
1864 int rc;
1865
1866 rc = msm_gpios_request_enable(timpani_reset_gpio_cfg,
1867 ARRAY_SIZE(timpani_reset_gpio_cfg));
1868 if (rc < 0) {
1869 printk(KERN_ERR
1870 "%s: msm_gpios_request_enable failed (%d)\n",
1871 __func__, rc);
1872 }
1873 return rc;
1874}
1875
1876static unsigned int msm_timpani_setup_power(void)
1877{
1878 int rc;
1879
1880 rc = config_timpani_reset();
1881 if (rc < 0)
1882 goto out;
1883
Justin Paupore3f40f342011-08-10 18:52:16 -07001884 rc = regulator_enable(vreg_marimba_1);
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);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001887 goto out;
1888 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001889
1890 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001891 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001892 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1893 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001894 }
1895
1896 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1);
1897 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001898 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001899 __func__, rc);
1900 msm_gpios_free(timpani_reset_gpio_cfg,
1901 ARRAY_SIZE(timpani_reset_gpio_cfg));
Justin Paupore3f40f342011-08-10 18:52:16 -07001902 goto disable_marimba_2;
1903 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001904
Justin Paupore3f40f342011-08-10 18:52:16 -07001905 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001906
Justin Paupore3f40f342011-08-10 18:52:16 -07001907disable_marimba_2:
1908 regulator_disable(vreg_marimba_2);
1909disable_marimba_1:
1910 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001911out:
1912 return rc;
1913};
1914
1915static void msm_timpani_shutdown_power(void)
1916{
1917 int rc;
1918
Justin Paupore3f40f342011-08-10 18:52:16 -07001919 rc = regulator_disable(vreg_marimba_2);
1920 if (rc)
1921 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1922
1923 rc = regulator_disable(vreg_marimba_1);
1924 if (rc)
1925 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001926
1927 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0);
Justin Paupore3f40f342011-08-10 18:52:16 -07001928 if (rc < 0)
1929 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001930 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001931
1932 msm_gpios_free(timpani_reset_gpio_cfg,
1933 ARRAY_SIZE(timpani_reset_gpio_cfg));
1934};
1935
1936static unsigned int msm_bahama_core_config(int type)
1937{
1938 int rc = 0;
1939
1940 if (type == BAHAMA_ID) {
1941
1942 int i;
1943 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1944
1945 const struct bahama_config_register v20_init[] = {
1946 /* reg, value, mask */
1947 { 0xF4, 0x84, 0xFF }, /* AREG */
1948 { 0xF0, 0x04, 0xFF } /* DREG */
1949 };
1950
1951 if (read_bahama_ver() == VER_2_0) {
1952 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
1953 u8 value = v20_init[i].value;
1954 rc = marimba_write_bit_mask(&config,
1955 v20_init[i].reg,
1956 &value,
1957 sizeof(v20_init[i].value),
1958 v20_init[i].mask);
1959 if (rc < 0) {
1960 printk(KERN_ERR
1961 "%s: reg %d write failed: %d\n",
1962 __func__, v20_init[i].reg, rc);
1963 return rc;
1964 }
1965 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
1966 " mask 0x%02x\n",
1967 __func__, v20_init[i].reg,
1968 v20_init[i].value, v20_init[i].mask);
1969 }
1970 }
1971 }
1972 printk(KERN_INFO "core type: %d\n", type);
1973
1974 return rc;
1975}
1976
1977static unsigned int msm_bahama_setup_power(void)
1978{
Justin Paupore3f40f342011-08-10 18:52:16 -07001979 int rc = regulator_enable(vreg_bahama);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001980
Justin Paupore3f40f342011-08-10 18:52:16 -07001981 if (rc)
1982 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001983
1984 return rc;
1985};
1986
1987static unsigned int msm_bahama_shutdown_power(int value)
1988{
1989 int rc = 0;
1990
1991 if (value != BAHAMA_ID) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001992 rc = regulator_disable(vreg_bahama);
1993
1994 if (rc)
1995 pr_err("%s: regulator_disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001996 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001997 }
1998
1999 return rc;
2000};
2001
2002static struct msm_gpio marimba_svlte_config_clock[] = {
2003 { GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
2004 "MARIMBA_SVLTE_CLOCK_ENABLE" },
2005};
2006
2007static unsigned int msm_marimba_gpio_config_svlte(int gpio_cfg_marimba)
2008{
2009 if (machine_is_msm8x55_svlte_surf() ||
2010 machine_is_msm8x55_svlte_ffa()) {
2011 if (gpio_cfg_marimba)
2012 gpio_set_value(GPIO_PIN
2013 (marimba_svlte_config_clock->gpio_cfg), 1);
2014 else
2015 gpio_set_value(GPIO_PIN
2016 (marimba_svlte_config_clock->gpio_cfg), 0);
2017 }
2018
2019 return 0;
2020};
2021
2022static unsigned int msm_marimba_setup_power(void)
2023{
2024 int rc;
2025
Justin Paupore3f40f342011-08-10 18:52:16 -07002026 rc = regulator_enable(vreg_marimba_1);
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);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002029 goto out;
2030 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002031
2032 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002033 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002034 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2035 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002036 }
2037
2038 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
2039 rc = msm_gpios_request_enable(marimba_svlte_config_clock,
2040 ARRAY_SIZE(marimba_svlte_config_clock));
2041 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002042 pr_err("%s: msm_gpios_request_enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002043 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002044 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002045 }
2046
2047 rc = gpio_direction_output(GPIO_PIN
2048 (marimba_svlte_config_clock->gpio_cfg), 0);
2049 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002050 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002051 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07002052 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002053 }
2054 }
2055
Justin Paupore3f40f342011-08-10 18:52:16 -07002056 return 0;
2057
2058disable_marimba_2:
2059 regulator_disable(vreg_marimba_2);
2060disable_marimba_1:
2061 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002062out:
2063 return rc;
2064};
2065
2066static void msm_marimba_shutdown_power(void)
2067{
2068 int rc;
2069
Justin Paupore3f40f342011-08-10 18:52:16 -07002070 rc = regulator_disable(vreg_marimba_2);
2071 if (rc)
2072 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
2073
2074 rc = regulator_disable(vreg_marimba_1);
2075 if (rc)
2076 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002077};
2078
2079static int bahama_present(void)
2080{
2081 int id;
2082 switch (id = adie_get_detected_connectivity_type()) {
2083 case BAHAMA_ID:
2084 return 1;
2085
2086 case MARIMBA_ID:
2087 return 0;
2088
2089 case TIMPANI_ID:
2090 default:
2091 printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n",
2092 __func__, id);
2093 return -ENODEV;
2094 }
2095}
2096
Justin Paupore3f40f342011-08-10 18:52:16 -07002097struct regulator *fm_regulator;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002098static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
2099{
Justin Paupore3f40f342011-08-10 18:52:16 -07002100 int rc, voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002101 uint32_t irqcfg;
2102 const char *id = "FMPW";
2103
2104 int bahama_not_marimba = bahama_present();
2105
Justin Paupore3f40f342011-08-10 18:52:16 -07002106 if (bahama_not_marimba < 0) {
2107 pr_warn("%s: bahama_present: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002108 __func__, bahama_not_marimba);
Justin Paupore3f40f342011-08-10 18:52:16 -07002109 rc = -ENODEV;
2110 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002111 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002112 if (bahama_not_marimba) {
2113 fm_regulator = regulator_get(NULL, "s3");
2114 voltage = 1800000;
2115 } else {
2116 fm_regulator = regulator_get(NULL, "s2");
2117 voltage = 1300000;
2118 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002119
2120 if (IS_ERR(fm_regulator)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002121 rc = PTR_ERR(fm_regulator);
2122 pr_err("%s: regulator_get failed (%d)\n", __func__, rc);
2123 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002124 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002125
Justin Paupore3f40f342011-08-10 18:52:16 -07002126 rc = regulator_set_voltage(fm_regulator, voltage, voltage);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002127
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002128 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002129 pr_err("%s: regulator_set_voltage failed (%d)\n", __func__, rc);
2130 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002131 }
2132
Justin Paupore3f40f342011-08-10 18:52:16 -07002133 rc = regulator_enable(fm_regulator);
2134
2135 if (rc) {
2136 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
2137 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002138 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002139
2140 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_ON);
2141
2142 if (rc < 0) {
2143 pr_err("%s: clock vote failed (%d)\n", __func__, rc);
2144 goto regulator_disable;
2145 }
2146
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002147 /*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2148 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002149 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002150 rc = marimba_gpio_config(1);
Justin Paupore3f40f342011-08-10 18:52:16 -07002151 if (rc < 0) {
2152 pr_err("%s: clock enable for svlte : %d\n",
2153 __func__, rc);
2154 goto clock_devote;
2155 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002156 }
2157 irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
2158 GPIO_CFG_2MA);
2159 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2160 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002161 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002162 rc = -EIO;
Justin Paupore3f40f342011-08-10 18:52:16 -07002163 goto gpio_deconfig;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002164
2165 }
2166 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002167
Justin Paupore3f40f342011-08-10 18:52:16 -07002168gpio_deconfig:
2169 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa())
2170 marimba_gpio_config(0);
2171clock_devote:
2172 pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_OFF);
2173regulator_disable:
2174 regulator_disable(fm_regulator);
2175regulator_free:
2176 regulator_put(fm_regulator);
2177 fm_regulator = NULL;
2178out:
2179 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002180};
2181
2182static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
2183{
2184 int rc;
2185 const char *id = "FMPW";
2186 uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
2187 GPIO_CFG_2MA);
2188
2189 int bahama_not_marimba = bahama_present();
2190 if (bahama_not_marimba == -1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002191 pr_warn("%s: bahama_present: %d\n",
2192 __func__, bahama_not_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002193 return;
2194 }
2195
2196 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2197 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002198 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002199 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002200 if (!IS_ERR_OR_NULL(fm_regulator)) {
2201 rc = regulator_disable(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002202
Justin Paupore3f40f342011-08-10 18:52:16 -07002203 if (rc)
2204 pr_err("%s: return val: %d\n", __func__, rc);
2205
2206 regulator_put(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002207 fm_regulator = NULL;
2208 }
2209 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
2210 PMAPP_CLOCK_VOTE_OFF);
2211 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002212 pr_err("%s: clock_vote return val: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002213
2214 /*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2215 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002216 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002217 rc = marimba_gpio_config(0);
2218 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002219 pr_err("%s: clock disable for svlte : %d\n",
2220 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002221 }
2222}
2223
2224static struct marimba_fm_platform_data marimba_fm_pdata = {
2225 .fm_setup = fm_radio_setup,
2226 .fm_shutdown = fm_radio_shutdown,
2227 .irq = MSM_GPIO_TO_INT(147),
2228 .vreg_s2 = NULL,
2229 .vreg_xo_out = NULL,
2230 .is_fm_soc_i2s_master = false,
2231 .config_i2s_gpio = NULL,
2232};
2233
2234
2235/* Slave id address for FM/CDC/QMEMBIST
2236 * Values can be programmed using Marimba slave id 0
2237 * should there be a conflict with other I2C devices
2238 * */
2239#define MARIMBA_SLAVE_ID_FM_ADDR 0x2A
2240#define MARIMBA_SLAVE_ID_CDC_ADDR 0x77
2241#define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66
2242
2243#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
2244#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
2245
2246static const char *tsadc_id = "MADC";
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002247
Justin Paupore3f40f342011-08-10 18:52:16 -07002248static struct regulator_bulk_data regs_tsadc_marimba[] = {
2249 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2250 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002251};
Justin Paupore3f40f342011-08-10 18:52:16 -07002252
2253static struct regulator_bulk_data regs_tsadc_timpani[] = {
2254 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2255 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2256 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2257};
2258
2259static struct regulator_bulk_data *regs_tsadc;
2260static int regs_tsadc_count;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002261
2262static int marimba_tsadc_power(int vreg_on)
2263{
Justin Paupore3f40f342011-08-10 18:52:16 -07002264 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002265 int tsadc_adie_type = adie_get_detected_codec_type();
2266
Justin Paupore3f40f342011-08-10 18:52:16 -07002267 switch (tsadc_adie_type) {
2268 case TIMPANI_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002269 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2270 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2271 if (rc) {
2272 pr_err("%s: unable to %svote for d1 clk\n",
2273 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002274 goto D1_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002275 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002276
2277 /* fall through */
2278 case MARIMBA_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002279 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2280 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2281 if (rc) {
2282 pr_err("%s: unable to %svote for d1 clk\n",
2283 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002284 goto D0_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002285 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002286
Justin Paupore3f40f342011-08-10 18:52:16 -07002287 WARN_ON(regs_tsadc_count == 0);
2288
2289 rc = vreg_on ?
2290 regulator_bulk_enable(regs_tsadc_count, regs_tsadc) :
2291 regulator_bulk_disable(regs_tsadc_count, regs_tsadc);
2292
2293 if (rc) {
2294 pr_err("%s: regulator %sable failed: %d\n",
2295 __func__, vreg_on ? "en" : "dis", rc);
2296 goto regulator_switch_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002297 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002298
2299 break;
2300 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002301 pr_err("%s:Adie %d not supported\n",
2302 __func__, tsadc_adie_type);
2303 return -ENODEV;
2304 }
2305
2306 msleep(5); /* ensure power is stable */
2307
2308 return 0;
2309
Justin Paupore3f40f342011-08-10 18:52:16 -07002310regulator_switch_fail:
2311 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2312 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2313D0_vote_fail:
2314 if (tsadc_adie_type == TIMPANI_ID)
2315 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2316 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2317D1_vote_fail:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002318 return rc;
2319}
2320
2321static int marimba_tsadc_init(void)
2322{
Justin Paupore3f40f342011-08-10 18:52:16 -07002323 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002324 int tsadc_adie_type = adie_get_detected_codec_type();
2325
Justin Paupore3f40f342011-08-10 18:52:16 -07002326 switch (tsadc_adie_type) {
2327 case MARIMBA_ID:
2328 regs_tsadc = regs_tsadc_marimba;
2329 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_marimba);
2330 break;
2331 case TIMPANI_ID:
2332 regs_tsadc = regs_tsadc_timpani;
2333 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_timpani);
2334 break;
2335 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002336 pr_err("%s:Adie %d not supported\n",
2337 __func__, tsadc_adie_type);
Justin Paupore3f40f342011-08-10 18:52:16 -07002338 rc = -ENODEV;
2339 goto out;
2340 }
2341
2342 rc = regulator_bulk_get(NULL, regs_tsadc_count, regs_tsadc);
2343 if (rc) {
2344 pr_err("%s: could not get regulators: %d\n",
2345 __func__, rc);
2346 goto out;
2347 }
2348
2349 rc = regulator_bulk_set_voltage(regs_tsadc_count, regs_tsadc);
2350 if (rc) {
2351 pr_err("%s: could not set regulator voltages: %d\n",
2352 __func__, rc);
2353 goto vreg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002354 }
2355
2356 return 0;
2357
Justin Paupore3f40f342011-08-10 18:52:16 -07002358vreg_free:
2359 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2360out:
2361 regs_tsadc = NULL;
2362 regs_tsadc_count = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002363 return rc;
2364}
2365
2366static int marimba_tsadc_exit(void)
2367{
Justin Paupore3f40f342011-08-10 18:52:16 -07002368 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2369 regs_tsadc_count = 0;
2370 regs_tsadc = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002371
Justin Paupore3f40f342011-08-10 18:52:16 -07002372 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002373}
2374
2375
2376static struct msm_ts_platform_data msm_ts_data = {
Anirudh Ghayal82b74722012-01-19 15:35:34 +05302377 .min_x = 284,
2378 .max_x = 3801,
2379 .min_y = 155,
2380 .max_y = 3929,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002381 .min_press = 0,
2382 .max_press = 255,
2383 .inv_x = 4096,
2384 .inv_y = 4096,
2385 .can_wakeup = false,
2386};
2387
2388static struct marimba_tsadc_platform_data marimba_tsadc_pdata = {
2389 .marimba_tsadc_power = marimba_tsadc_power,
2390 .init = marimba_tsadc_init,
2391 .exit = marimba_tsadc_exit,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002392 .tsadc_prechg_en = true,
2393 .can_wakeup = false,
2394 .setup = {
2395 .pen_irq_en = true,
2396 .tsadc_en = true,
2397 },
2398 .params2 = {
2399 .input_clk_khz = 2400,
2400 .sample_prd = TSADC_CLK_3,
2401 },
2402 .params3 = {
2403 .prechg_time_nsecs = 6400,
2404 .stable_time_nsecs = 6400,
2405 .tsadc_test_mode = 0,
2406 },
2407 .tssc_data = &msm_ts_data,
2408};
2409
Justin Paupore3f40f342011-08-10 18:52:16 -07002410static struct regulator_bulk_data codec_regs[] = {
2411 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
2412};
2413
2414static int __init msm_marimba_codec_init(void)
2415{
2416 int rc = regulator_bulk_get(NULL, ARRAY_SIZE(codec_regs), codec_regs);
2417
2418 if (rc) {
2419 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2420 goto out;
2421 }
2422
2423 rc = regulator_bulk_set_voltage(ARRAY_SIZE(codec_regs), codec_regs);
2424 if (rc) {
2425 pr_err("%s: could not set regulator voltages: %d\n",
2426 __func__, rc);
2427 goto reg_free;
2428 }
2429
2430 return rc;
2431
2432reg_free:
2433 regulator_bulk_free(ARRAY_SIZE(codec_regs), codec_regs);
2434out:
2435 return rc;
2436}
2437
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002438static int msm_marimba_codec_power(int vreg_on)
2439{
Justin Paupore3f40f342011-08-10 18:52:16 -07002440 int rc = vreg_on ?
2441 regulator_bulk_enable(ARRAY_SIZE(codec_regs), codec_regs) :
2442 regulator_bulk_disable(ARRAY_SIZE(codec_regs), codec_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002443
Justin Paupore3f40f342011-08-10 18:52:16 -07002444 if (rc) {
2445 pr_err("%s: could not %sable regulators: %d",
2446 __func__, vreg_on ? "en" : "dis", rc);
2447 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002448 }
2449
Justin Paupore3f40f342011-08-10 18:52:16 -07002450 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002451}
2452
2453static struct marimba_codec_platform_data mariba_codec_pdata = {
2454 .marimba_codec_power = msm_marimba_codec_power,
2455#ifdef CONFIG_MARIMBA_CODEC
2456 .snddev_profile_init = msm_snddev_init,
2457#endif
2458};
2459
2460static struct marimba_platform_data marimba_pdata = {
2461 .slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR,
2462 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2463 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2464 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
2465 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
2466 .marimba_setup = msm_marimba_setup_power,
2467 .marimba_shutdown = msm_marimba_shutdown_power,
2468 .bahama_setup = msm_bahama_setup_power,
2469 .bahama_shutdown = msm_bahama_shutdown_power,
2470 .marimba_gpio_config = msm_marimba_gpio_config_svlte,
2471 .bahama_core_config = msm_bahama_core_config,
2472 .fm = &marimba_fm_pdata,
2473 .codec = &mariba_codec_pdata,
2474 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2475};
2476
2477static void __init msm7x30_init_marimba(void)
2478{
2479 int rc;
2480
Justin Paupore3f40f342011-08-10 18:52:16 -07002481 struct regulator_bulk_data regs[] = {
2482 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2483 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2484 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
2485 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002486
Justin Paupore3f40f342011-08-10 18:52:16 -07002487 rc = msm_marimba_codec_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002488
Justin Paupore3f40f342011-08-10 18:52:16 -07002489 if (rc) {
2490 pr_err("%s: msm_marimba_codec_init failed (%d)\n",
2491 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002492 return;
2493 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002494
2495 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
2496
2497 if (rc) {
2498 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2499 return;
2500 }
2501
2502 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
2503
2504 if (rc) {
2505 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2506 regulator_bulk_free(ARRAY_SIZE(regs), regs);
2507 return;
2508 }
2509
2510 vreg_marimba_1 = regs[0].consumer;
2511 vreg_marimba_2 = regs[1].consumer;
2512 vreg_bahama = regs[2].consumer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002513}
2514
2515static struct marimba_codec_platform_data timpani_codec_pdata = {
2516 .marimba_codec_power = msm_marimba_codec_power,
2517#ifdef CONFIG_TIMPANI_CODEC
2518 .snddev_profile_init = msm_snddev_init_timpani,
2519#endif
2520};
2521
2522static struct marimba_platform_data timpani_pdata = {
2523 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2524 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2525 .marimba_setup = msm_timpani_setup_power,
2526 .marimba_shutdown = msm_timpani_shutdown_power,
2527 .codec = &timpani_codec_pdata,
2528 .tsadc = &marimba_tsadc_pdata,
2529 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2530};
2531
2532#define TIMPANI_I2C_SLAVE_ADDR 0xD
2533
2534static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
2535 {
2536 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
2537 .platform_data = &timpani_pdata,
2538 },
2539};
2540
2541#ifdef CONFIG_MSM7KV2_AUDIO
2542static struct resource msm_aictl_resources[] = {
2543 {
2544 .name = "aictl",
2545 .start = 0xa5000100,
2546 .end = 0xa5000100,
2547 .flags = IORESOURCE_MEM,
2548 }
2549};
2550
2551static struct resource msm_mi2s_resources[] = {
2552 {
2553 .name = "hdmi",
2554 .start = 0xac900000,
2555 .end = 0xac900038,
2556 .flags = IORESOURCE_MEM,
2557 },
2558 {
2559 .name = "codec_rx",
2560 .start = 0xac940040,
2561 .end = 0xac940078,
2562 .flags = IORESOURCE_MEM,
2563 },
2564 {
2565 .name = "codec_tx",
2566 .start = 0xac980080,
2567 .end = 0xac9800B8,
2568 .flags = IORESOURCE_MEM,
2569 }
2570
2571};
2572
2573static struct msm_lpa_platform_data lpa_pdata = {
2574 .obuf_hlb_size = 0x2BFF8,
2575 .dsp_proc_id = 0,
2576 .app_proc_id = 2,
2577 .nosb_config = {
2578 .llb_min_addr = 0,
2579 .llb_max_addr = 0x3ff8,
2580 .sb_min_addr = 0,
2581 .sb_max_addr = 0,
2582 },
2583 .sb_config = {
2584 .llb_min_addr = 0,
2585 .llb_max_addr = 0x37f8,
2586 .sb_min_addr = 0x3800,
2587 .sb_max_addr = 0x3ff8,
2588 }
2589};
2590
2591static struct resource msm_lpa_resources[] = {
2592 {
2593 .name = "lpa",
2594 .start = 0xa5000000,
2595 .end = 0xa50000a0,
2596 .flags = IORESOURCE_MEM,
2597 }
2598};
2599
2600static struct resource msm_aux_pcm_resources[] = {
2601
2602 {
2603 .name = "aux_codec_reg_addr",
2604 .start = 0xac9c00c0,
2605 .end = 0xac9c00c8,
2606 .flags = IORESOURCE_MEM,
2607 },
2608 {
2609 .name = "aux_pcm_dout",
2610 .start = 138,
2611 .end = 138,
2612 .flags = IORESOURCE_IO,
2613 },
2614 {
2615 .name = "aux_pcm_din",
2616 .start = 139,
2617 .end = 139,
2618 .flags = IORESOURCE_IO,
2619 },
2620 {
2621 .name = "aux_pcm_syncout",
2622 .start = 140,
2623 .end = 140,
2624 .flags = IORESOURCE_IO,
2625 },
2626 {
2627 .name = "aux_pcm_clkin_a",
2628 .start = 141,
2629 .end = 141,
2630 .flags = IORESOURCE_IO,
2631 },
2632};
2633
2634static struct platform_device msm_aux_pcm_device = {
2635 .name = "msm_aux_pcm",
2636 .id = 0,
2637 .num_resources = ARRAY_SIZE(msm_aux_pcm_resources),
2638 .resource = msm_aux_pcm_resources,
2639};
2640
2641struct platform_device msm_aictl_device = {
2642 .name = "audio_interct",
2643 .id = 0,
2644 .num_resources = ARRAY_SIZE(msm_aictl_resources),
2645 .resource = msm_aictl_resources,
2646};
2647
2648struct platform_device msm_mi2s_device = {
2649 .name = "mi2s",
2650 .id = 0,
2651 .num_resources = ARRAY_SIZE(msm_mi2s_resources),
2652 .resource = msm_mi2s_resources,
2653};
2654
2655struct platform_device msm_lpa_device = {
2656 .name = "lpa",
2657 .id = 0,
2658 .num_resources = ARRAY_SIZE(msm_lpa_resources),
2659 .resource = msm_lpa_resources,
2660 .dev = {
2661 .platform_data = &lpa_pdata,
2662 },
2663};
2664#endif /* CONFIG_MSM7KV2_AUDIO */
2665
2666#define DEC0_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 DEC1_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 DEC2_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 DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2685 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2686 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2687 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2688 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2689 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2690#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
2691
2692static unsigned int dec_concurrency_table[] = {
2693 /* Audio LP */
2694 0,
2695 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2696 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2697 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2698 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)|
2699 (1<<MSM_ADSP_OP_DM)),
2700
2701 /* Concurrency 1 */
2702 (DEC4_FORMAT),
2703 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2704 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2705 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2706 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2707
2708 /* Concurrency 2 */
2709 (DEC4_FORMAT),
2710 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2711 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2712 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2713 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2714
2715 /* Concurrency 3 */
2716 (DEC4_FORMAT),
2717 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2718 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2719 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2720 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2721
2722 /* Concurrency 4 */
2723 (DEC4_FORMAT),
2724 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2725 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2726 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2727 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2728
2729 /* Concurrency 5 */
2730 (DEC4_FORMAT),
2731 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2732 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2733 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2734 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2735
2736 /* Concurrency 6 */
2737 (DEC4_FORMAT),
2738 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2739 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2740 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2741 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2742};
2743
2744#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
2745 .module_queueid = queueid, .module_decid = decid, \
2746 .nr_codec_support = nr_codec}
2747
2748#define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
2749 .max_instances_same_dec = max_instance_same, \
2750 .max_instances_diff_dec = max_instance_diff}
2751
2752static struct msm_adspdec_info dec_info_list[] = {
2753 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
2754 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
2755 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
2756 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
2757 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
2758};
2759
2760static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
2761 /* Non Turbo Mode */
2762 {
2763 DEC_INSTANCE(4, 3), /* WAV */
2764 DEC_INSTANCE(4, 3), /* ADPCM */
2765 DEC_INSTANCE(4, 2), /* MP3 */
2766 DEC_INSTANCE(0, 0), /* Real Audio */
2767 DEC_INSTANCE(4, 2), /* WMA */
2768 DEC_INSTANCE(3, 2), /* AAC */
2769 DEC_INSTANCE(0, 0), /* Reserved */
2770 DEC_INSTANCE(0, 0), /* MIDI */
2771 DEC_INSTANCE(4, 3), /* YADPCM */
2772 DEC_INSTANCE(4, 3), /* QCELP */
2773 DEC_INSTANCE(4, 3), /* AMRNB */
2774 DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
2775 DEC_INSTANCE(4, 3), /* EVRC */
2776 DEC_INSTANCE(1, 1), /* WMAPRO */
2777 },
2778 /* Turbo Mode */
2779 {
2780 DEC_INSTANCE(4, 3), /* WAV */
2781 DEC_INSTANCE(4, 3), /* ADPCM */
2782 DEC_INSTANCE(4, 3), /* MP3 */
2783 DEC_INSTANCE(0, 0), /* Real Audio */
2784 DEC_INSTANCE(4, 3), /* WMA */
2785 DEC_INSTANCE(4, 3), /* AAC */
2786 DEC_INSTANCE(0, 0), /* Reserved */
2787 DEC_INSTANCE(0, 0), /* MIDI */
2788 DEC_INSTANCE(4, 3), /* YADPCM */
2789 DEC_INSTANCE(4, 3), /* QCELP */
2790 DEC_INSTANCE(4, 3), /* AMRNB */
2791 DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
2792 DEC_INSTANCE(4, 3), /* EVRC */
2793 DEC_INSTANCE(1, 2), /* WMAPRO */
2794 },
2795};
2796
2797static struct msm_adspdec_database msm_device_adspdec_database = {
2798 .num_dec = ARRAY_SIZE(dec_info_list),
2799 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
2800 ARRAY_SIZE(dec_info_list)),
2801 .dec_concurrency_table = dec_concurrency_table,
2802 .dec_info_list = dec_info_list,
2803 .dec_instance_list = &dec_instance_list[0][0],
2804};
2805
2806static struct platform_device msm_device_adspdec = {
2807 .name = "msm_adspdec",
2808 .id = -1,
2809 .dev = {
2810 .platform_data = &msm_device_adspdec_database
2811 },
2812};
2813
2814static struct resource smc91x_resources[] = {
2815 [0] = {
2816 .start = 0x8A000300,
2817 .end = 0x8A0003ff,
2818 .flags = IORESOURCE_MEM,
2819 },
2820 [1] = {
2821 .start = MSM_GPIO_TO_INT(156),
2822 .end = MSM_GPIO_TO_INT(156),
2823 .flags = IORESOURCE_IRQ,
2824 },
2825};
2826
2827static struct platform_device smc91x_device = {
2828 .name = "smc91x",
2829 .id = 0,
2830 .num_resources = ARRAY_SIZE(smc91x_resources),
2831 .resource = smc91x_resources,
2832};
2833
2834static struct smsc911x_platform_config smsc911x_config = {
2835 .phy_interface = PHY_INTERFACE_MODE_MII,
2836 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
2837 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
2838 .flags = SMSC911X_USE_32BIT,
2839};
2840
2841static struct resource smsc911x_resources[] = {
2842 [0] = {
2843 .start = 0x8D000000,
2844 .end = 0x8D000100,
2845 .flags = IORESOURCE_MEM,
2846 },
2847 [1] = {
2848 .start = MSM_GPIO_TO_INT(88),
2849 .end = MSM_GPIO_TO_INT(88),
2850 .flags = IORESOURCE_IRQ,
2851 },
2852};
2853
2854static struct platform_device smsc911x_device = {
2855 .name = "smsc911x",
2856 .id = -1,
2857 .num_resources = ARRAY_SIZE(smsc911x_resources),
2858 .resource = smsc911x_resources,
2859 .dev = {
2860 .platform_data = &smsc911x_config,
2861 },
2862};
2863
2864static struct msm_gpio smsc911x_gpios[] = {
2865 { GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" },
2866 { GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" },
2867 { GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" },
2868 { GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" },
2869 { GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" },
2870 { GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" },
2871 { GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" },
2872 { GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" },
2873};
2874
2875static void msm7x30_cfg_smsc911x(void)
2876{
2877 int rc;
2878
2879 rc = msm_gpios_request_enable(smsc911x_gpios,
2880 ARRAY_SIZE(smsc911x_gpios));
2881 if (rc)
2882 pr_err("%s: unable to enable gpios\n", __func__);
2883}
2884
2885#ifdef CONFIG_USB_G_ANDROID
2886static struct android_usb_platform_data android_usb_pdata = {
2887 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2888};
2889
2890static struct platform_device android_usb_device = {
2891 .name = "android_usb",
2892 .id = -1,
2893 .dev = {
2894 .platform_data = &android_usb_pdata,
2895 },
2896};
2897#endif
2898
2899static struct msm_gpio optnav_config_data[] = {
2900 { GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA),
2901 "optnav_chip_select" },
2902};
2903
Justin Paupore3f40f342011-08-10 18:52:16 -07002904static struct regulator_bulk_data optnav_regulators[] = {
2905 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2906 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
2907 { .supply = "gp9", .min_uV = 1800000, .max_uV = 1800000 },
2908 { .supply = "usb", .min_uV = 3300000, .max_uV = 3300000 },
2909};
2910
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002911static void __iomem *virtual_optnav;
2912
2913static int optnav_gpio_setup(void)
2914{
2915 int rc = -ENODEV;
2916 rc = msm_gpios_request_enable(optnav_config_data,
2917 ARRAY_SIZE(optnav_config_data));
2918
Justin Paupore3f40f342011-08-10 18:52:16 -07002919 if (rc)
2920 return rc;
2921
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002922 /* Configure the FPGA for GPIOs */
2923 virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4);
2924 if (!virtual_optnav) {
2925 pr_err("%s:Could not ioremap region\n", __func__);
2926 return -ENOMEM;
2927 }
2928 /*
2929 * Configure the FPGA to set GPIO 19 as
2930 * normal, active(enabled), output(MSM to SURF)
2931 */
2932 writew(0x311E, virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002933
2934 rc = regulator_bulk_get(NULL, ARRAY_SIZE(optnav_regulators),
2935 optnav_regulators);
2936 if (rc)
2937 return rc;
2938
2939 rc = regulator_bulk_set_voltage(ARRAY_SIZE(optnav_regulators),
2940 optnav_regulators);
2941
2942 if (rc)
2943 goto regulator_put;
2944
2945 return rc;
2946
2947regulator_put:
2948 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002949 return rc;
2950}
2951
2952static void optnav_gpio_release(void)
2953{
2954 msm_gpios_disable_free(optnav_config_data,
2955 ARRAY_SIZE(optnav_config_data));
2956 iounmap(virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002957 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002958}
2959
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002960static int optnav_enable(void)
2961{
2962 int rc;
2963 /*
2964 * Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
2965 * for I2C communication with keyboard.
2966 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002967
Justin Paupore3f40f342011-08-10 18:52:16 -07002968 rc = regulator_bulk_enable(ARRAY_SIZE(optnav_regulators),
2969 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002970
Justin Paupore3f40f342011-08-10 18:52:16 -07002971 if (rc)
2972 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002973
2974 /* Enable the chip select GPIO */
2975 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2976 gpio_set_value(OPTNAV_CHIP_SELECT, 0);
2977
2978 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002979}
2980
2981static void optnav_disable(void)
2982{
Justin Paupore3f40f342011-08-10 18:52:16 -07002983 regulator_bulk_disable(ARRAY_SIZE(optnav_regulators),
2984 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002985
2986 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2987}
2988
2989static struct ofn_atlab_platform_data optnav_data = {
2990 .gpio_setup = optnav_gpio_setup,
2991 .gpio_release = optnav_gpio_release,
2992 .optnav_on = optnav_enable,
2993 .optnav_off = optnav_disable,
2994 .rotate_xy = 0,
2995 .function1 = {
2996 .no_motion1_en = true,
2997 .touch_sensor_en = true,
2998 .ofn_en = true,
2999 .clock_select_khz = 1500,
3000 .cpi_selection = 1200,
3001 },
3002 .function2 = {
3003 .invert_y = false,
3004 .invert_x = true,
3005 .swap_x_y = false,
3006 .hold_a_b_en = true,
3007 .motion_filter_en = true,
3008 },
3009};
3010
3011static int hdmi_comm_power(int on, int show);
3012static int hdmi_init_irq(void);
3013static int hdmi_enable_5v(int on);
3014static int hdmi_core_power(int on, int show);
3015static int hdmi_cec_power(int on);
3016static bool hdmi_check_hdcp_hw_support(void);
3017
3018static struct msm_hdmi_platform_data adv7520_hdmi_data = {
3019 .irq = MSM_GPIO_TO_INT(18),
3020 .comm_power = hdmi_comm_power,
3021 .init_irq = hdmi_init_irq,
3022 .enable_5v = hdmi_enable_5v,
3023 .core_power = hdmi_core_power,
3024 .cec_power = hdmi_cec_power,
3025 .check_hdcp_hw_support = hdmi_check_hdcp_hw_support,
3026};
3027
3028#ifdef CONFIG_BOSCH_BMA150
Justin Paupore3f40f342011-08-10 18:52:16 -07003029
3030static struct regulator_bulk_data sensors_ldo[] = {
3031 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
3032 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
3033};
3034
3035static int __init sensors_ldo_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003036{
3037 int rc;
3038
Justin Paupore3f40f342011-08-10 18:52:16 -07003039 rc = regulator_bulk_get(NULL, ARRAY_SIZE(sensors_ldo), sensors_ldo);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003040
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003041 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003042 pr_err("%s: could not get regulators: %d\n", __func__, rc);
3043 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003044 }
3045
Justin Paupore3f40f342011-08-10 18:52:16 -07003046 rc = regulator_bulk_set_voltage(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3047
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003048 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003049 pr_err("%s: could not set voltages: %d\n", __func__, rc);
3050 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003051 }
3052
3053 return 0;
3054
Justin Paupore3f40f342011-08-10 18:52:16 -07003055reg_free:
3056 regulator_bulk_free(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3057out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003058 return rc;
3059}
3060
Justin Paupore3f40f342011-08-10 18:52:16 -07003061static int sensors_ldo_set(int on)
3062{
3063 int rc = on ?
3064 regulator_bulk_enable(ARRAY_SIZE(sensors_ldo), sensors_ldo) :
3065 regulator_bulk_disable(ARRAY_SIZE(sensors_ldo), sensors_ldo);
3066
3067 if (rc)
3068 pr_err("%s: could not %sable regulators: %d\n",
3069 __func__, on ? "en" : "dis", rc);
3070
3071 return rc;
3072}
3073
3074static int sensors_ldo_enable(void)
3075{
3076 return sensors_ldo_set(1);
3077}
3078
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003079static void sensors_ldo_disable(void)
3080{
Justin Paupore3f40f342011-08-10 18:52:16 -07003081 sensors_ldo_set(0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003082}
Justin Paupore3f40f342011-08-10 18:52:16 -07003083
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003084static struct bma150_platform_data bma150_data = {
3085 .power_on = sensors_ldo_enable,
3086 .power_off = sensors_ldo_disable,
3087};
3088
3089static struct i2c_board_info bma150_board_info[] __initdata = {
3090 {
3091 I2C_BOARD_INFO("bma150", 0x38),
3092 .flags = I2C_CLIENT_WAKE,
3093 .irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
3094 .platform_data = &bma150_data,
3095 },
3096};
3097#endif
3098
3099static struct i2c_board_info msm_i2c_board_info[] = {
3100 {
3101 I2C_BOARD_INFO("m33c01", OPTNAV_I2C_SLAVE_ADDR),
3102 .irq = MSM_GPIO_TO_INT(OPTNAV_IRQ),
3103 .platform_data = &optnav_data,
3104 },
3105 {
3106 I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR),
3107 .platform_data = &adv7520_hdmi_data,
3108 },
3109};
3110
3111static struct i2c_board_info msm_marimba_board_info[] = {
3112 {
3113 I2C_BOARD_INFO("marimba", 0xc),
3114 .platform_data = &marimba_pdata,
3115 }
3116};
3117
3118
3119static struct msm_handset_platform_data hs_platform_data = {
3120 .hs_name = "7k_handset",
3121 .pwr_key_delay_ms = 500, /* 0 will disable end key */
3122};
3123
3124static struct platform_device hs_device = {
3125 .name = "msm-handset",
3126 .id = -1,
3127 .dev = {
3128 .platform_data = &hs_platform_data,
3129 },
3130};
3131
3132static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +05303133 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003134 .idle_supported = 1,
3135 .suspend_supported = 1,
3136 .idle_enabled = 1,
3137 .suspend_enabled = 1,
3138 .latency = 8594,
3139 .residency = 23740,
3140 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303141 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003142 .idle_supported = 1,
3143 .suspend_supported = 1,
3144 .idle_enabled = 1,
3145 .suspend_enabled = 1,
3146 .latency = 4594,
3147 .residency = 23740,
3148 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303149 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003150#ifdef CONFIG_MSM_STANDALONE_POWER_COLLAPSE
3151 .idle_supported = 1,
3152 .suspend_supported = 1,
3153 .idle_enabled = 1,
3154 .suspend_enabled = 0,
3155#else /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3156 .idle_supported = 0,
3157 .suspend_supported = 0,
3158 .idle_enabled = 0,
3159 .suspend_enabled = 0,
3160#endif /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
3161 .latency = 500,
3162 .residency = 6000,
3163 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303164 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003165 .idle_supported = 1,
3166 .suspend_supported = 1,
3167 .idle_enabled = 0,
3168 .suspend_enabled = 1,
3169 .latency = 443,
3170 .residency = 1098,
3171 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05303172 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003173 .idle_supported = 1,
3174 .suspend_supported = 1,
3175 .idle_enabled = 1,
3176 .suspend_enabled = 1,
3177 .latency = 2,
3178 .residency = 0,
3179 },
3180};
3181
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003182static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3183 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
3184 .v_addr = (uint32_t *)PAGE_OFFSET,
3185};
3186
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003187static struct resource qsd_spi_resources[] = {
3188 {
3189 .name = "spi_irq_in",
3190 .start = INT_SPI_INPUT,
3191 .end = INT_SPI_INPUT,
3192 .flags = IORESOURCE_IRQ,
3193 },
3194 {
3195 .name = "spi_irq_out",
3196 .start = INT_SPI_OUTPUT,
3197 .end = INT_SPI_OUTPUT,
3198 .flags = IORESOURCE_IRQ,
3199 },
3200 {
3201 .name = "spi_irq_err",
3202 .start = INT_SPI_ERROR,
3203 .end = INT_SPI_ERROR,
3204 .flags = IORESOURCE_IRQ,
3205 },
3206 {
3207 .name = "spi_base",
3208 .start = 0xA8000000,
3209 .end = 0xA8000000 + SZ_4K - 1,
3210 .flags = IORESOURCE_MEM,
3211 },
3212 {
3213 .name = "spidm_channels",
3214 .flags = IORESOURCE_DMA,
3215 },
3216 {
3217 .name = "spidm_crci",
3218 .flags = IORESOURCE_DMA,
3219 },
3220};
3221
3222#define AMDH0_BASE_PHYS 0xAC200000
3223#define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
3224static int msm_qsd_spi_dma_config(void)
3225{
3226 void __iomem *ct_adm_base = 0;
3227 u32 spi_mux = 0;
3228 int ret = 0;
3229
3230 ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
3231 if (!ct_adm_base) {
3232 pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
3233 return -ENOMEM;
3234 }
3235
3236 spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
3237
3238 qsd_spi_resources[4].start = DMOV_USB_CHAN;
3239 qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
3240
3241 switch (spi_mux) {
3242 case (1):
3243 qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
3244 qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
3245 break;
3246 case (2):
3247 qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
3248 qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
3249 break;
3250 case (3):
3251 qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
3252 qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
3253 break;
3254 default:
3255 ret = -ENOENT;
3256 }
3257
3258 iounmap(ct_adm_base);
3259
3260 return ret;
3261}
3262
3263static struct platform_device qsd_device_spi = {
3264 .name = "spi_qsd",
3265 .id = 0,
3266 .num_resources = ARRAY_SIZE(qsd_spi_resources),
3267 .resource = qsd_spi_resources,
3268};
3269
3270#ifdef CONFIG_SPI_QSD
3271static struct spi_board_info lcdc_sharp_spi_board_info[] __initdata = {
3272 {
3273 .modalias = "lcdc_sharp_ls038y7dx01",
3274 .mode = SPI_MODE_1,
3275 .bus_num = 0,
3276 .chip_select = 0,
3277 .max_speed_hz = 26331429,
3278 }
3279};
3280static struct spi_board_info lcdc_toshiba_spi_board_info[] __initdata = {
3281 {
3282 .modalias = "lcdc_toshiba_ltm030dd40",
3283 .mode = SPI_MODE_3|SPI_CS_HIGH,
3284 .bus_num = 0,
3285 .chip_select = 0,
3286 .max_speed_hz = 9963243,
3287 }
3288};
3289#endif
3290
3291static struct msm_gpio qsd_spi_gpio_config_data[] = {
3292 { GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3293 { GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3294 { GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" },
3295 { GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3296};
3297
3298static int msm_qsd_spi_gpio_config(void)
3299{
3300 return msm_gpios_request_enable(qsd_spi_gpio_config_data,
3301 ARRAY_SIZE(qsd_spi_gpio_config_data));
3302}
3303
3304static void msm_qsd_spi_gpio_release(void)
3305{
3306 msm_gpios_disable_free(qsd_spi_gpio_config_data,
3307 ARRAY_SIZE(qsd_spi_gpio_config_data));
3308}
3309
3310static struct msm_spi_platform_data qsd_spi_pdata = {
3311 .max_clock_speed = 26331429,
3312 .gpio_config = msm_qsd_spi_gpio_config,
3313 .gpio_release = msm_qsd_spi_gpio_release,
3314 .dma_config = msm_qsd_spi_dma_config,
3315};
3316
3317static void __init msm_qsd_spi_init(void)
3318{
3319 qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
3320}
3321
3322#ifdef CONFIG_USB_EHCI_MSM_72K
3323static void msm_hsusb_vbus_power(unsigned phy_info, int on)
3324{
3325 int rc;
3326 static int vbus_is_on;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303327 struct pm8xxx_gpio_init_info usb_vbus = {
3328 PM8058_GPIO_PM_TO_SYS(36),
3329 {
3330 .direction = PM_GPIO_DIR_OUT,
3331 .pull = PM_GPIO_PULL_NO,
3332 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3333 .output_value = 1,
3334 .vin_sel = 2,
3335 .out_strength = PM_GPIO_STRENGTH_MED,
3336 .function = PM_GPIO_FUNC_NORMAL,
3337 .inv_int_pol = 0,
3338 },
3339 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003340
3341 /* If VBUS is already on (or off), do nothing. */
3342 if (unlikely(on == vbus_is_on))
3343 return;
3344
3345 if (on) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303346 rc = pm8xxx_gpio_config(usb_vbus.gpio, &usb_vbus.config);
3347 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003348 pr_err("%s PMIC GPIO 36 write failed\n", __func__);
3349 return;
3350 }
3351 } else {
3352 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(36), 0);
3353 }
3354
3355 vbus_is_on = on;
3356}
3357
3358static struct msm_usb_host_platform_data msm_usb_host_pdata = {
3359 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
3360 .vbus_power = msm_hsusb_vbus_power,
3361 .power_budget = 180,
3362};
3363#endif
3364
3365#ifdef CONFIG_USB_MSM_OTG_72K
3366static int hsusb_rpc_connect(int connect)
3367{
3368 if (connect)
3369 return msm_hsusb_rpc_connect();
3370 else
3371 return msm_hsusb_rpc_close();
3372}
3373#endif
3374
3375#ifdef CONFIG_USB_MSM_OTG_72K
Justin Paupore3f40f342011-08-10 18:52:16 -07003376static struct regulator *vreg_3p3;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003377static int msm_hsusb_ldo_init(int init)
3378{
3379 uint32_t version = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07003380 int def_vol = 3400000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003381
3382 version = socinfo_get_version();
3383
3384 if (SOCINFO_VERSION_MAJOR(version) >= 2 &&
3385 SOCINFO_VERSION_MINOR(version) >= 1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003386 def_vol = 3075000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003387 pr_debug("%s: default voltage:%d\n", __func__, def_vol);
3388 }
3389
3390 if (init) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003391 vreg_3p3 = regulator_get(NULL, "usb");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003392 if (IS_ERR(vreg_3p3))
3393 return PTR_ERR(vreg_3p3);
Justin Paupore3f40f342011-08-10 18:52:16 -07003394 regulator_set_voltage(vreg_3p3, def_vol, def_vol);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003395 } else
Justin Paupore3f40f342011-08-10 18:52:16 -07003396 regulator_put(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003397
3398 return 0;
3399}
3400
3401static int msm_hsusb_ldo_enable(int enable)
3402{
3403 static int ldo_status;
3404
3405 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3406 return -ENODEV;
3407
3408 if (ldo_status == enable)
3409 return 0;
3410
3411 ldo_status = enable;
3412
3413 if (enable)
Justin Paupore3f40f342011-08-10 18:52:16 -07003414 return regulator_enable(vreg_3p3);
3415 else
3416 return regulator_disable(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003417}
3418
3419static int msm_hsusb_ldo_set_voltage(int mV)
3420{
Justin Paupore3f40f342011-08-10 18:52:16 -07003421 static int cur_voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003422
3423 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3424 return -ENODEV;
3425
3426 if (cur_voltage == mV)
3427 return 0;
3428
3429 cur_voltage = mV;
3430
3431 pr_debug("%s: (%d)\n", __func__, mV);
3432
Justin Paupore3f40f342011-08-10 18:52:16 -07003433 return regulator_set_voltage(vreg_3p3, mV*1000, mV*1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003434}
3435#endif
3436
3437#ifndef CONFIG_USB_EHCI_MSM_72K
3438static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init);
3439#endif
3440static struct msm_otg_platform_data msm_otg_pdata = {
3441 .rpc_connect = hsusb_rpc_connect,
3442
3443#ifndef CONFIG_USB_EHCI_MSM_72K
3444 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
3445#else
3446 .vbus_power = msm_hsusb_vbus_power,
3447#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003448 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
3449 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
3450 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
3451 .se1_gating = SE1_GATING_DISABLE,
3452 .chg_vbus_draw = hsusb_chg_vbus_draw,
3453 .chg_connected = hsusb_chg_connected,
3454 .chg_init = hsusb_chg_init,
3455 .ldo_enable = msm_hsusb_ldo_enable,
3456 .ldo_init = msm_hsusb_ldo_init,
3457 .ldo_set_voltage = msm_hsusb_ldo_set_voltage,
3458};
3459
3460#ifdef CONFIG_USB_GADGET
3461static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
3462 .is_phy_status_timer_on = 1,
3463};
3464#endif
3465#ifndef CONFIG_USB_EHCI_MSM_72K
3466typedef void (*notify_vbus_state) (int);
3467notify_vbus_state notify_vbus_state_func_ptr;
3468int vbus_on_irq;
3469static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
3470{
3471 pr_info("%s: vbus notification from pmic\n", __func__);
3472
3473 (*notify_vbus_state_func_ptr) (1);
3474
3475 return IRQ_HANDLED;
3476}
3477static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
3478{
3479 int ret;
3480
3481 if (init) {
3482 if (!callback)
3483 return -ENODEV;
3484
3485 notify_vbus_state_func_ptr = callback;
3486 vbus_on_irq = platform_get_irq_byname(&msm_device_otg,
3487 "vbus_on");
3488 if (vbus_on_irq <= 0) {
3489 pr_err("%s: unable to get vbus on irq\n", __func__);
3490 return -ENODEV;
3491 }
3492
3493 ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq,
3494 IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
3495 if (ret < 0) {
3496 pr_info("%s: request_irq for vbus_on"
3497 "interrupt failed\n", __func__);
3498 return ret;
3499 }
3500 msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
3501 return 0;
3502 } else {
3503 free_irq(vbus_on_irq, 0);
3504 notify_vbus_state_func_ptr = NULL;
3505 return 0;
3506 }
3507}
3508#endif
3509
3510static struct android_pmem_platform_data android_pmem_pdata = {
3511 .name = "pmem",
3512 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
3513 .cached = 1,
3514 .memory_type = MEMTYPE_EBI0,
3515};
3516
3517static struct platform_device android_pmem_device = {
3518 .name = "android_pmem",
3519 .id = 0,
3520 .dev = { .platform_data = &android_pmem_pdata },
3521};
3522
3523#ifndef CONFIG_SPI_QSD
3524static int lcdc_gpio_array_num[] = {
3525 45, /* spi_clk */
3526 46, /* spi_cs */
3527 47, /* spi_mosi */
3528 48, /* spi_miso */
3529 };
3530
3531static struct msm_gpio lcdc_gpio_config_data[] = {
3532 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3533 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3534 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
3535 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3536};
3537
3538static void lcdc_config_gpios(int enable)
3539{
3540 if (enable) {
3541 msm_gpios_request_enable(lcdc_gpio_config_data,
3542 ARRAY_SIZE(
3543 lcdc_gpio_config_data));
3544 } else
3545 msm_gpios_disable_free(lcdc_gpio_config_data,
3546 ARRAY_SIZE(
3547 lcdc_gpio_config_data));
3548}
3549#endif
3550
3551static struct msm_panel_common_pdata lcdc_sharp_panel_data = {
3552#ifndef CONFIG_SPI_QSD
3553 .panel_config_gpio = lcdc_config_gpios,
3554 .gpio_num = lcdc_gpio_array_num,
3555#endif
3556 .gpio = 2, /* LPG PMIC_GPIO26 channel number */
3557};
3558
3559static struct platform_device lcdc_sharp_panel_device = {
3560 .name = "lcdc_sharp_wvga",
3561 .id = 0,
3562 .dev = {
3563 .platform_data = &lcdc_sharp_panel_data,
3564 }
3565};
3566
3567static struct msm_gpio dtv_panel_irq_gpios[] = {
3568 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
3569 "hdmi_int" },
3570};
3571
3572static struct msm_gpio dtv_panel_gpios[] = {
3573 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
3574 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
3575 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
3576 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
3577 { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
3578 { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
3579 { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
3580 { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
3581 { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
3582 { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
3583 { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
3584 { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
3585 { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
3586 { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
3587 { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
3588 { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
3589 { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
3590 { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
3591 { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
3592 { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
3593 { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
3594 { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
3595 { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
3596 { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
3597 { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
3598 { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
3599 { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
3600 { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
3601 { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
3602 { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
3603 { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
3604 { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
3605};
3606
3607
3608#ifdef HDMI_RESET
3609static unsigned dtv_reset_gpio =
3610 GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3611#endif
3612
Justin Paupore3f40f342011-08-10 18:52:16 -07003613static struct regulator_bulk_data hdmi_core_regs[] = {
3614 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3615};
3616
3617static struct regulator_bulk_data hdmi_comm_regs[] = {
3618 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3619 { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 },
3620};
3621
3622static struct regulator_bulk_data hdmi_cec_regs[] = {
3623 { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 },
3624};
3625
3626static int __init hdmi_init_regs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003627{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003628 int rc;
3629
Justin Paupore3f40f342011-08-10 18:52:16 -07003630 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs),
3631 hdmi_core_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003632
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003633 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003634 pr_err("%s: could not get %s regulators: %d\n",
3635 __func__, "core", rc);
3636 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003637 }
3638
Justin Paupore3f40f342011-08-10 18:52:16 -07003639 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs),
3640 hdmi_core_regs);
3641
3642 if (rc) {
3643 pr_err("%s: could not set %s voltages: %d\n",
3644 __func__, "core", rc);
3645 goto free_core;
3646 }
3647
3648 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs),
3649 hdmi_comm_regs);
3650
3651 if (rc) {
3652 pr_err("%s: could not get %s regulators: %d\n",
3653 __func__, "comm", rc);
3654 goto free_core;
3655 }
3656
3657 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs),
3658 hdmi_comm_regs);
3659
3660 if (rc) {
3661 pr_err("%s: could not set %s voltages: %d\n",
3662 __func__, "comm", rc);
3663 goto free_comm;
3664 }
3665
3666 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs),
3667 hdmi_cec_regs);
3668
3669 if (rc) {
3670 pr_err("%s: could not get %s regulators: %d\n",
3671 __func__, "cec", rc);
3672 goto free_comm;
3673 }
3674
3675 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs),
3676 hdmi_cec_regs);
3677
3678 if (rc) {
3679 pr_err("%s: could not set %s voltages: %d\n",
3680 __func__, "cec", rc);
3681 goto free_cec;
3682 }
3683
3684 return 0;
3685
3686free_cec:
3687 regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs);
3688free_comm:
3689 regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs);
3690free_core:
3691 regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs);
3692out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003693 return rc;
3694}
3695
Justin Paupore3f40f342011-08-10 18:52:16 -07003696static int hdmi_init_irq(void)
3697{
3698 int rc = msm_gpios_enable(dtv_panel_irq_gpios,
3699 ARRAY_SIZE(dtv_panel_irq_gpios));
3700 if (rc < 0) {
3701 pr_err("%s: gpio enable failed: %d\n", __func__, rc);
3702 return rc;
3703 }
3704 pr_info("%s\n", __func__);
3705
3706 return 0;
3707}
3708
3709static int hdmi_enable_5v(int on)
3710{
3711 int pmic_gpio_hdmi_5v_en ;
3712
3713 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
3714 machine_is_msm7x30_fluid())
3715 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
3716 else
3717 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
3718
3719 pr_info("%s: %d\n", __func__, on);
3720 if (on) {
3721 int rc;
3722 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
3723 "hdmi_5V_en");
3724 if (rc) {
3725 pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
3726 __func__);
3727 return rc;
3728 }
3729 gpio_set_value_cansleep(
3730 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
3731 } else {
3732 gpio_set_value_cansleep(
3733 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
3734 gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
3735 }
3736 return 0;
3737}
3738
3739static int hdmi_comm_power(int on, int show)
3740{
3741 if (show)
3742 pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
3743 return on ?
3744 regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs),
3745 hdmi_comm_regs) :
3746 regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs),
3747 hdmi_comm_regs);
3748}
3749
3750static int hdmi_core_power(int on, int show)
3751{
3752 if (show)
3753 pr_info("%s: %d <LDO8>\n", __func__, on);
3754 return on ?
3755 regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs),
3756 hdmi_core_regs) :
3757 regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs),
3758 hdmi_core_regs);
3759}
3760
3761static int hdmi_cec_power(int on)
3762{
3763 pr_info("%s: %d <LDO17>\n", __func__, on);
3764 return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs),
3765 hdmi_cec_regs) :
3766 regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs),
3767 hdmi_cec_regs);
3768}
3769
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003770#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
3771/* there is an i2c address conflict between adv7520 and bma150 sensor after
3772 * power up on fluid. As a solution, the default address of adv7520's packet
3773 * memory is changed as soon as possible
3774 */
3775static int __init fluid_i2c_address_fixup(void)
3776{
3777 unsigned char wBuff[16];
3778 unsigned char rBuff[16];
3779 struct i2c_msg msgs[3];
3780 int res;
3781 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003782 struct i2c_adapter *adapter;
3783
3784 if (machine_is_msm7x30_fluid()) {
3785 adapter = i2c_get_adapter(0);
3786 if (!adapter) {
3787 pr_err("%s: invalid i2c adapter\n", __func__);
3788 return PTR_ERR(adapter);
3789 }
3790
3791 /* turn on LDO8 */
Justin Paupore3f40f342011-08-10 18:52:16 -07003792 rc = hdmi_core_power(1, 0);
3793 if (rc) {
3794 pr_err("%s: could not enable hdmi core regs: %d",
3795 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003796 goto adapter_put;
3797 }
3798
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003799 /* change packet memory address to 0x74 */
3800 wBuff[0] = 0x45;
3801 wBuff[1] = 0x74;
3802
3803 msgs[0].addr = ADV7520_I2C_ADDR;
3804 msgs[0].flags = 0;
3805 msgs[0].buf = (unsigned char *) wBuff;
3806 msgs[0].len = 2;
3807
3808 res = i2c_transfer(adapter, msgs, 1);
3809 if (res != 1) {
3810 pr_err("%s: error writing adv7520\n", __func__);
3811 goto ldo8_disable;
3812 }
3813
3814 /* powerdown adv7520 using bit 6 */
3815 /* i2c read first */
3816 wBuff[0] = 0x41;
3817
3818 msgs[0].addr = ADV7520_I2C_ADDR;
3819 msgs[0].flags = 0;
3820 msgs[0].buf = (unsigned char *) wBuff;
3821 msgs[0].len = 1;
3822
3823 msgs[1].addr = ADV7520_I2C_ADDR;
3824 msgs[1].flags = I2C_M_RD;
3825 msgs[1].buf = rBuff;
3826 msgs[1].len = 1;
3827 res = i2c_transfer(adapter, msgs, 2);
3828 if (res != 2) {
3829 pr_err("%s: error reading adv7520\n", __func__);
3830 goto ldo8_disable;
3831 }
3832
3833 /* i2c write back */
3834 wBuff[0] = 0x41;
3835 wBuff[1] = rBuff[0] | 0x40;
3836
3837 msgs[0].addr = ADV7520_I2C_ADDR;
3838 msgs[0].flags = 0;
3839 msgs[0].buf = (unsigned char *) wBuff;
3840 msgs[0].len = 2;
3841
3842 res = i2c_transfer(adapter, msgs, 1);
3843 if (res != 1) {
3844 pr_err("%s: error writing adv7520\n", __func__);
3845 goto ldo8_disable;
3846 }
3847
3848 /* for successful fixup, we release the i2c adapter */
3849 /* but leave ldo8 on so that the adv7520 is not repowered */
3850 i2c_put_adapter(adapter);
3851 pr_info("%s: fluid i2c address conflict resolved\n", __func__);
3852 }
3853 return 0;
3854
3855ldo8_disable:
Justin Paupore3f40f342011-08-10 18:52:16 -07003856 hdmi_core_power(0, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003857adapter_put:
3858 i2c_put_adapter(adapter);
3859 return rc;
3860}
3861fs_initcall_sync(fluid_i2c_address_fixup);
3862#endif
3863
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003864static bool hdmi_check_hdcp_hw_support(void)
3865{
3866 if (machine_is_msm7x30_fluid())
3867 return false;
3868 else
3869 return true;
3870}
3871
3872static int dtv_panel_power(int on)
3873{
3874 int flag_on = !!on;
3875 static int dtv_power_save_on;
3876 int rc;
3877
3878 if (dtv_power_save_on == flag_on)
3879 return 0;
3880
3881 dtv_power_save_on = flag_on;
3882 pr_info("%s: %d\n", __func__, on);
3883
3884#ifdef HDMI_RESET
3885 if (on) {
3886 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
3887 rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
3888 if (rc) {
3889 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
3890 __func__, dtv_reset_gpio, rc);
3891 return rc;
3892 }
3893
3894 /* bring reset line low to hold reset*/
3895 gpio_set_value(37, 0);
3896 }
3897#endif
3898
3899 if (on) {
3900 rc = msm_gpios_enable(dtv_panel_gpios,
3901 ARRAY_SIZE(dtv_panel_gpios));
3902 if (rc < 0) {
3903 printk(KERN_ERR "%s: gpio enable failed: %d\n",
3904 __func__, rc);
3905 return rc;
3906 }
3907 } else {
3908 rc = msm_gpios_disable(dtv_panel_gpios,
3909 ARRAY_SIZE(dtv_panel_gpios));
3910 if (rc < 0) {
3911 printk(KERN_ERR "%s: gpio disable failed: %d\n",
3912 __func__, rc);
3913 return rc;
3914 }
3915 }
3916
3917 mdelay(5); /* ensure power is stable */
3918
3919#ifdef HDMI_RESET
3920 if (on) {
3921 gpio_set_value(37, 1); /* bring reset line high */
3922 mdelay(10); /* 10 msec before IO can be accessed */
3923 }
3924#endif
3925
3926 return rc;
3927}
3928
3929static struct lcdc_platform_data dtv_pdata = {
3930 .lcdc_power_save = dtv_panel_power,
3931};
3932
3933static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3934 .inject_rx_on_wakeup = 1,
3935 .rx_to_inject = 0xFD,
3936};
3937
3938static struct resource msm_fb_resources[] = {
3939 {
3940 .flags = IORESOURCE_DMA,
3941 }
3942};
3943
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08003944#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
3945static struct resource msm_v4l2_video_overlay_resources[] = {
3946 {
3947 .flags = IORESOURCE_DMA,
3948 }
3949};
3950#endif
3951
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003952static int msm_fb_detect_panel(const char *name)
3953{
3954 if (machine_is_msm7x30_fluid()) {
3955 if (!strcmp(name, "lcdc_sharp_wvga_pt"))
3956 return 0;
3957 } else {
3958 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
3959 return -EPERM;
3960 else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20))
3961 return 0;
3962 else if (!strcmp(name, "mddi_orise"))
3963 return -EPERM;
3964 else if (!strcmp(name, "mddi_quickvx"))
3965 return -EPERM;
3966 }
3967 return -ENODEV;
3968}
3969
3970static struct msm_fb_platform_data msm_fb_pdata = {
3971 .detect_client = msm_fb_detect_panel,
3972 .mddi_prescan = 1,
3973};
3974
3975static struct platform_device msm_fb_device = {
3976 .name = "msm_fb",
3977 .id = 0,
3978 .num_resources = ARRAY_SIZE(msm_fb_resources),
3979 .resource = msm_fb_resources,
3980 .dev = {
3981 .platform_data = &msm_fb_pdata,
3982 }
3983};
3984
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08003985#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
3986
3987static struct platform_device msm_v4l2_video_overlay_device = {
3988 .name = "msm_v4l2_overlay_pd",
3989 .id = 0,
3990 .num_resources = ARRAY_SIZE(msm_v4l2_video_overlay_resources),
3991 .resource = msm_v4l2_video_overlay_resources,
3992};
3993#endif
3994
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003995static struct platform_device msm_migrate_pages_device = {
3996 .name = "msm_migrate_pages",
3997 .id = -1,
3998};
3999
4000static struct android_pmem_platform_data android_pmem_adsp_pdata = {
4001 .name = "pmem_adsp",
4002 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4003 .cached = 0,
4004 .memory_type = MEMTYPE_EBI0,
4005};
4006
4007static struct android_pmem_platform_data android_pmem_audio_pdata = {
4008 .name = "pmem_audio",
4009 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
4010 .cached = 0,
4011 .memory_type = MEMTYPE_EBI0,
4012};
4013
4014static struct platform_device android_pmem_adsp_device = {
4015 .name = "android_pmem",
4016 .id = 2,
4017 .dev = { .platform_data = &android_pmem_adsp_pdata },
4018};
4019
4020static struct platform_device android_pmem_audio_device = {
4021 .name = "android_pmem",
4022 .id = 4,
4023 .dev = { .platform_data = &android_pmem_audio_pdata },
4024};
4025
4026#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4027 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
4028 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4029 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4030
4031#define QCE_SIZE 0x10000
4032#define QCE_0_BASE 0xA8400000
4033
4034#define QCE_HW_KEY_SUPPORT 1
4035#define QCE_SHA_HMAC_SUPPORT 0
4036#define QCE_SHARE_CE_RESOURCE 0
4037#define QCE_CE_SHARED 0
4038
4039static struct resource qcrypto_resources[] = {
4040 [0] = {
4041 .start = QCE_0_BASE,
4042 .end = QCE_0_BASE + QCE_SIZE - 1,
4043 .flags = IORESOURCE_MEM,
4044 },
4045 [1] = {
4046 .name = "crypto_channels",
4047 .start = DMOV_CE_IN_CHAN,
4048 .end = DMOV_CE_OUT_CHAN,
4049 .flags = IORESOURCE_DMA,
4050 },
4051 [2] = {
4052 .name = "crypto_crci_in",
4053 .start = DMOV_CE_IN_CRCI,
4054 .end = DMOV_CE_IN_CRCI,
4055 .flags = IORESOURCE_DMA,
4056 },
4057 [3] = {
4058 .name = "crypto_crci_out",
4059 .start = DMOV_CE_OUT_CRCI,
4060 .end = DMOV_CE_OUT_CRCI,
4061 .flags = IORESOURCE_DMA,
4062 },
4063 [4] = {
4064 .name = "crypto_crci_hash",
4065 .start = DMOV_CE_HASH_CRCI,
4066 .end = DMOV_CE_HASH_CRCI,
4067 .flags = IORESOURCE_DMA,
4068 },
4069};
4070
4071static struct resource qcedev_resources[] = {
4072 [0] = {
4073 .start = QCE_0_BASE,
4074 .end = QCE_0_BASE + QCE_SIZE - 1,
4075 .flags = IORESOURCE_MEM,
4076 },
4077 [1] = {
4078 .name = "crypto_channels",
4079 .start = DMOV_CE_IN_CHAN,
4080 .end = DMOV_CE_OUT_CHAN,
4081 .flags = IORESOURCE_DMA,
4082 },
4083 [2] = {
4084 .name = "crypto_crci_in",
4085 .start = DMOV_CE_IN_CRCI,
4086 .end = DMOV_CE_IN_CRCI,
4087 .flags = IORESOURCE_DMA,
4088 },
4089 [3] = {
4090 .name = "crypto_crci_out",
4091 .start = DMOV_CE_OUT_CRCI,
4092 .end = DMOV_CE_OUT_CRCI,
4093 .flags = IORESOURCE_DMA,
4094 },
4095 [4] = {
4096 .name = "crypto_crci_hash",
4097 .start = DMOV_CE_HASH_CRCI,
4098 .end = DMOV_CE_HASH_CRCI,
4099 .flags = IORESOURCE_DMA,
4100 },
4101};
4102
4103#endif
4104
4105#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
4106 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
4107
4108static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
4109 .ce_shared = QCE_CE_SHARED,
4110 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4111 .hw_key_support = QCE_HW_KEY_SUPPORT,
4112 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004113 /* Bus Scaling declaration*/
4114 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004115};
4116
4117static struct platform_device qcrypto_device = {
4118 .name = "qcrypto",
4119 .id = 0,
4120 .num_resources = ARRAY_SIZE(qcrypto_resources),
4121 .resource = qcrypto_resources,
4122 .dev = {
4123 .coherent_dma_mask = DMA_BIT_MASK(32),
4124 .platform_data = &qcrypto_ce_hw_suppport,
4125 },
4126};
4127#endif
4128
4129#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
4130 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
4131
4132static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
4133 .ce_shared = QCE_CE_SHARED,
4134 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
4135 .hw_key_support = QCE_HW_KEY_SUPPORT,
4136 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08004137 /* Bus Scaling declaration*/
4138 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004139};
4140static struct platform_device qcedev_device = {
4141 .name = "qce",
4142 .id = 0,
4143 .num_resources = ARRAY_SIZE(qcedev_resources),
4144 .resource = qcedev_resources,
4145 .dev = {
4146 .coherent_dma_mask = DMA_BIT_MASK(32),
4147 .platform_data = &qcedev_ce_hw_suppport,
4148 },
4149};
4150#endif
4151
4152static int mddi_toshiba_pmic_bl(int level)
4153{
4154 int ret = -EPERM;
4155
4156 ret = pmic_set_led_intensity(LED_LCD, level);
4157
4158 if (ret)
4159 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
4160 __func__);
4161 return ret;
4162}
4163
4164static struct msm_panel_common_pdata mddi_toshiba_pdata = {
4165 .pmic_backlight = mddi_toshiba_pmic_bl,
4166};
4167
4168static struct platform_device mddi_toshiba_device = {
4169 .name = "mddi_toshiba",
4170 .id = 0,
4171 .dev = {
4172 .platform_data = &mddi_toshiba_pdata,
4173 }
4174};
4175
4176static unsigned wega_reset_gpio =
4177 GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4178
4179static struct msm_gpio fluid_vee_reset_gpio[] = {
4180 { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
4181};
4182
4183static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1;
4184static unsigned char quickvx_ldo_enabled;
4185
4186static unsigned quickvx_vlp_gpio =
4187 GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
4188
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304189static struct pm8xxx_gpio_init_info pmic_quickvx_clk_gpio = {
4190 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_QUICKVX_CLK),
4191 {
4192 .direction = PM_GPIO_DIR_OUT,
4193 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
4194 .output_value = 1,
4195 .pull = PM_GPIO_PULL_NO,
4196 .vin_sel = PM8058_GPIO_VIN_S3,
4197 .out_strength = PM_GPIO_STRENGTH_HIGH,
4198 .function = PM_GPIO_FUNC_2,
4199 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004200};
4201
Justin Paupore3f40f342011-08-10 18:52:16 -07004202static struct regulator *mddi_ldo20;
4203static struct regulator *mddi_ldo12;
4204static struct regulator *mddi_ldo16;
4205static struct regulator *mddi_ldo6;
4206static struct regulator *mddi_lcd;
4207
4208static int display_common_init(void)
4209{
4210 struct regulator_bulk_data regs[5] = {
4211 { .supply = "ldo20", /* voltage set in display_common_power */},
4212 { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 },
4213 { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 },
4214 { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 },
4215 { .supply = NULL, /* mddi_lcd, initialized below */ },
4216 };
4217
4218 int rc = 0;
4219
4220 if (machine_is_msm7x30_fluid()) {
4221 /* lcd: LDO8 @1.8V */
4222 regs[4].supply = "ldo8";
4223 regs[4].min_uV = 1800000;
4224 regs[4].max_uV = 1800000;
4225 } else {
4226 /* lcd: LDO15 @3.1V */
4227 regs[4].supply = "ldo15";
4228 regs[4].min_uV = 3100000;
4229 regs[4].max_uV = 3100000;
4230 }
4231
4232 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4233 if (rc) {
4234 pr_err("%s: regulator_bulk_get failed: %d\n",
4235 __func__, rc);
4236 goto bail;
4237 }
4238
4239 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4240 if (rc) {
4241 pr_err("%s: regulator_bulk_set_voltage failed: %d\n",
4242 __func__, rc);
4243 goto put_regs;
4244 }
4245
4246 mddi_ldo20 = regs[0].consumer;
4247 mddi_ldo12 = regs[1].consumer;
4248 mddi_ldo6 = regs[2].consumer;
4249 mddi_ldo16 = regs[3].consumer;
4250 mddi_lcd = regs[4].consumer;
4251
4252 return rc;
4253
4254put_regs:
4255 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4256bail:
4257 return rc;
4258}
4259
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004260static int display_common_power(int on)
4261{
4262 int rc = 0, flag_on = !!on;
4263 static int display_common_power_save_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004264 static bool display_regs_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004265
4266 if (display_common_power_save_on == flag_on)
4267 return 0;
4268
4269 display_common_power_save_on = flag_on;
4270
Justin Paupore3f40f342011-08-10 18:52:16 -07004271 if (unlikely(!display_regs_initialized)) {
4272 rc = display_common_init();
4273 if (rc) {
4274 pr_err("%s: regulator init failed: %d\n",
4275 __func__, rc);
4276 return rc;
4277 }
4278 display_regs_initialized = true;
4279 }
4280
4281
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004282 if (on) {
4283 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
4284 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
4285 if (rc) {
4286 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4287 __func__, wega_reset_gpio, rc);
4288 return rc;
4289 }
4290
4291 /* bring reset line low to hold reset*/
4292 gpio_set_value(180, 0);
4293
4294 if (quickvx_mddi_client) {
4295 /* QuickVX chip -- VLP pin -- gpio 97 */
4296 rc = gpio_tlmm_config(quickvx_vlp_gpio,
4297 GPIO_CFG_ENABLE);
4298 if (rc) {
4299 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4300 __func__, quickvx_vlp_gpio, rc);
4301 return rc;
4302 }
4303
4304 /* bring QuickVX VLP line low */
4305 gpio_set_value(97, 0);
4306
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304307 rc = pm8xxx_gpio_config(pmic_quickvx_clk_gpio.gpio,
4308 &pmic_quickvx_clk_gpio.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004309 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304310 pr_err("%s: pm8xxx_gpio_config(%#x)=%d\n",
4311 __func__, pmic_quickvx_clk_gpio.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004312 rc);
4313 return rc;
4314 }
4315
4316 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4317 PMIC_GPIO_QUICKVX_CLK), 0);
4318 }
4319 }
4320
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004321 if (quickvx_mddi_client)
Justin Paupore3f40f342011-08-10 18:52:16 -07004322 rc = regulator_set_voltage(mddi_ldo20, 1800000, 1800000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004323 else
Justin Paupore3f40f342011-08-10 18:52:16 -07004324 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000);
4325
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004326 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004327 pr_err("%s: could not set voltage for ldo20: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004328 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07004329 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004330 }
4331
4332 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004333 rc = regulator_enable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004334 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004335 pr_err("%s: LDO20 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004336 __func__, rc);
4337 return rc;
4338 }
4339
Justin Paupore3f40f342011-08-10 18:52:16 -07004340 rc = regulator_enable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004341 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004342 pr_err("%s: LDO12 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004343 __func__, rc);
4344 return rc;
4345 }
4346
4347 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004348 rc = regulator_enable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004349 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004350 pr_err("%s: LDO16 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004351 __func__, rc);
4352 return rc;
4353 }
4354 }
4355
Justin Paupore3f40f342011-08-10 18:52:16 -07004356 if (quickvx_ldo_enabled) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004357 /* Disable LDO6 during display ON */
Justin Paupore3f40f342011-08-10 18:52:16 -07004358 rc = regulator_disable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004359 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004360 pr_err("%s: LDO6 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004361 __func__, rc);
4362 return rc;
4363 }
4364 quickvx_ldo_enabled = 0;
4365 }
4366
Justin Paupore3f40f342011-08-10 18:52:16 -07004367 rc = regulator_enable(mddi_lcd);
4368 if (rc) {
4369 pr_err("%s: LCD regulator enable failed (%d)\n",
4370 __func__, rc);
4371 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004372 }
4373
4374 mdelay(5); /* ensure power is stable */
4375
4376 if (machine_is_msm7x30_fluid()) {
4377 rc = msm_gpios_request_enable(fluid_vee_reset_gpio,
4378 ARRAY_SIZE(fluid_vee_reset_gpio));
4379 if (rc)
4380 pr_err("%s gpio_request_enable failed rc=%d\n",
4381 __func__, rc);
4382 else {
4383 /* assert vee reset_n */
4384 gpio_set_value(20, 1);
4385 gpio_set_value(20, 0);
4386 mdelay(1);
4387 gpio_set_value(20, 1);
4388 }
4389 }
4390
4391 gpio_set_value(180, 1); /* bring reset line high */
4392 mdelay(10); /* 10 msec before IO can be accessed */
4393
4394 if (quickvx_mddi_client) {
4395 gpio_set_value(97, 1);
4396 msleep(2);
4397 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4398 PMIC_GPIO_QUICKVX_CLK), 1);
4399 msleep(2);
4400 }
4401
4402 rc = pmapp_display_clock_config(1);
4403 if (rc) {
4404 pr_err("%s pmapp_display_clock_config rc=%d\n",
4405 __func__, rc);
4406 return rc;
4407 }
4408
4409 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004410 rc = regulator_disable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004411 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004412 pr_err("%s: LDO20 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004413 __func__, rc);
4414 return rc;
4415 }
4416
4417
4418 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004419 rc = regulator_disable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004420 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004421 pr_err("%s: LDO16 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004422 __func__, rc);
4423 return rc;
4424 }
4425 }
4426
4427 if (quickvx_mddi_client && !quickvx_ldo_enabled) {
4428 /* Enable LDO6 during display OFF for
4429 Quicklogic chip to sleep with data retention */
Justin Paupore3f40f342011-08-10 18:52:16 -07004430 rc = regulator_enable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004431 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004432 pr_err("%s: LDO6 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004433 __func__, rc);
4434 return rc;
4435 }
4436 quickvx_ldo_enabled = 1;
4437 }
4438
4439 gpio_set_value(180, 0); /* bring reset line low */
4440
4441 if (quickvx_mddi_client) {
4442 gpio_set_value(97, 0);
4443 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4444 PMIC_GPIO_QUICKVX_CLK), 0);
4445 }
4446
Justin Paupore3f40f342011-08-10 18:52:16 -07004447 rc = regulator_disable(mddi_lcd);
4448 if (rc) {
4449 pr_err("%s: LCD regulator disable failed (%d)\n",
4450 __func__, rc);
4451 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004452 }
4453
4454 mdelay(5); /* ensure power is stable */
4455
Justin Paupore3f40f342011-08-10 18:52:16 -07004456 rc = regulator_disable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004457 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004458 pr_err("%s: LDO12 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004459 __func__, rc);
4460 return rc;
4461 }
4462
4463 if (machine_is_msm7x30_fluid()) {
4464 msm_gpios_disable_free(fluid_vee_reset_gpio,
4465 ARRAY_SIZE(fluid_vee_reset_gpio));
4466 }
4467
4468 rc = pmapp_display_clock_config(0);
4469 if (rc) {
4470 pr_err("%s pmapp_display_clock_config rc=%d\n",
4471 __func__, rc);
4472 return rc;
4473 }
4474 }
4475
4476 return rc;
4477}
4478
4479static int msm_fb_mddi_sel_clk(u32 *clk_rate)
4480{
4481 *clk_rate *= 2;
4482 return 0;
4483}
4484
4485static int msm_fb_mddi_client_power(u32 client_id)
4486{
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304487 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004488 printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
4489 /* Check if it is Quicklogic client */
4490 if (client_id == 0xc5835800) {
4491 printk(KERN_NOTICE "\n Quicklogic MDDI client");
4492 other_mddi_client = 0;
Padmanabhan Komandurue9c820f2012-02-17 19:20:52 +05304493 if (IS_ERR(mddi_ldo16)) {
4494 rc = PTR_ERR(mddi_ldo16);
4495 pr_err("%s: gp10 vreg get failed (%d)\n", __func__, rc);
4496 return rc;
4497 }
4498 rc = regulator_disable(mddi_ldo16);
4499 if (rc) {
4500 pr_err("%s: LDO16 vreg enable failed (%d)\n",
4501 __func__, rc);
4502 return rc;
4503 }
4504
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004505 } else {
4506 printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
4507 quickvx_mddi_client = 0;
4508 gpio_set_value(97, 0);
4509 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4510 PMIC_GPIO_QUICKVX_CLK), 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004511 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004512
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004513 return 0;
4514}
4515
4516static struct mddi_platform_data mddi_pdata = {
4517 .mddi_power_save = display_common_power,
4518 .mddi_sel_clk = msm_fb_mddi_sel_clk,
4519 .mddi_client_power = msm_fb_mddi_client_power,
4520};
4521
4522int mdp_core_clk_rate_table[] = {
4523 122880000,
4524 122880000,
Pradeep Jilagam3cc12f92011-07-26 22:25:18 +05304525 192000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004526 192000000,
4527};
4528
4529static struct msm_panel_common_pdata mdp_pdata = {
4530 .hw_revision_addr = 0xac001270,
4531 .gpio = 30,
4532 .mdp_core_clk_rate = 122880000,
4533 .mdp_core_clk_table = mdp_core_clk_rate_table,
4534 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07004535 .mdp_rev = MDP_REV_40,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004536};
4537
4538static int lcd_panel_spi_gpio_num[] = {
4539 45, /* spi_clk */
4540 46, /* spi_cs */
4541 47, /* spi_mosi */
4542 48, /* spi_miso */
4543 };
4544
4545static struct msm_gpio lcd_panel_gpios[] = {
4546/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
4547 * input. if there is a hardware revision; we should reassign this GPIO to a
4548 * new open line; and removing it will just ensure that this will be missed in
4549 * the future.
4550 { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
4551 */
4552 { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
4553 { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
4554 { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
4555 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4556 { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
4557 { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
4558 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4559#ifndef CONFIG_SPI_QSD
4560 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
4561 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
4562 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
4563 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
4564#endif
4565 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4566 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4567 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4568 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4569 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4570 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4571 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4572 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4573 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4574 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4575 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4576 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4577 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4578 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4579 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4580 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4581 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4582 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4583 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4584 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4585};
4586
4587static struct msm_gpio lcd_sharp_panel_gpios[] = {
4588 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4589 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4590 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4591 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4592 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4593 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4594 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4595 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4596 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4597 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4598 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4599 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4600 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4601 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4602 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4603 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4604 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4605 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4606 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4607 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4608 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4609 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4610};
4611
4612static int lcdc_toshiba_panel_power(int on)
4613{
4614 int rc, i;
4615 struct msm_gpio *gp;
4616
4617 rc = display_common_power(on);
4618 if (rc < 0) {
4619 printk(KERN_ERR "%s display_common_power failed: %d\n",
4620 __func__, rc);
4621 return rc;
4622 }
4623
4624 if (on) {
4625 rc = msm_gpios_enable(lcd_panel_gpios,
4626 ARRAY_SIZE(lcd_panel_gpios));
4627 if (rc < 0) {
4628 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4629 __func__, rc);
4630 }
4631 } else { /* off */
4632 gp = lcd_panel_gpios;
4633 for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
4634 /* ouput low */
4635 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4636 gp++;
4637 }
4638 }
4639
4640 return rc;
4641}
4642
4643static int lcdc_sharp_panel_power(int on)
4644{
4645 int rc, i;
4646 struct msm_gpio *gp;
4647
4648 rc = display_common_power(on);
4649 if (rc < 0) {
4650 printk(KERN_ERR "%s display_common_power failed: %d\n",
4651 __func__, rc);
4652 return rc;
4653 }
4654
4655 if (on) {
4656 rc = msm_gpios_enable(lcd_sharp_panel_gpios,
4657 ARRAY_SIZE(lcd_sharp_panel_gpios));
4658 if (rc < 0) {
4659 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4660 __func__, rc);
4661 }
4662 } else { /* off */
4663 gp = lcd_sharp_panel_gpios;
4664 for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) {
4665 /* ouput low */
4666 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4667 gp++;
4668 }
4669 }
4670
4671 return rc;
4672}
4673
4674static int lcdc_panel_power(int on)
4675{
4676 int flag_on = !!on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004677 static int lcdc_power_save_on, lcdc_power_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004678
4679 if (lcdc_power_save_on == flag_on)
4680 return 0;
4681
4682 lcdc_power_save_on = flag_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004683
4684 if (unlikely(!lcdc_power_initialized)) {
4685 quickvx_mddi_client = 0;
4686 display_common_init();
4687 lcdc_power_initialized = 1;
4688 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004689
4690 if (machine_is_msm7x30_fluid())
4691 return lcdc_sharp_panel_power(on);
4692 else
4693 return lcdc_toshiba_panel_power(on);
4694}
4695
4696static struct lcdc_platform_data lcdc_pdata = {
4697 .lcdc_power_save = lcdc_panel_power,
4698};
4699
Justin Paupore3f40f342011-08-10 18:52:16 -07004700static struct regulator *atv_s4, *atv_ldo9;
4701
4702static int __init atv_dac_power_init(void)
4703{
4704 int rc;
4705 struct regulator_bulk_data regs[] = {
4706 { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 },
4707 { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 },
4708 };
4709
4710 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4711
4712 if (rc) {
4713 pr_err("%s: could not get regulators: %d\n", __func__, rc);
4714 goto bail;
4715 }
4716
4717 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4718
4719 if (rc) {
4720 pr_err("%s: could not set voltages: %d\n", __func__, rc);
4721 goto reg_free;
4722 }
4723
4724 atv_s4 = regs[0].consumer;
4725 atv_ldo9 = regs[1].consumer;
4726
4727reg_free:
4728 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4729bail:
4730 return rc;
4731}
4732
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004733static int atv_dac_power(int on)
4734{
4735 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004736
4737 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004738 rc = regulator_enable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004739 if (rc) {
4740 pr_err("%s: s4 vreg enable failed (%d)\n",
4741 __func__, rc);
4742 return rc;
4743 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004744 rc = regulator_enable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004745 if (rc) {
4746 pr_err("%s: ldo9 vreg enable failed (%d)\n",
4747 __func__, rc);
4748 return rc;
4749 }
4750 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004751 rc = regulator_disable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004752 if (rc) {
4753 pr_err("%s: ldo9 vreg disable failed (%d)\n",
4754 __func__, rc);
4755 return rc;
4756 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004757 rc = regulator_disable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004758 if (rc) {
4759 pr_err("%s: s4 vreg disable failed (%d)\n",
4760 __func__, rc);
4761 return rc;
4762 }
4763 }
4764 return rc;
4765}
4766
4767static struct tvenc_platform_data atv_pdata = {
4768 .poll = 1,
4769 .pm_vid_en = atv_dac_power,
4770};
4771
4772static void __init msm_fb_add_devices(void)
4773{
4774 msm_fb_register_device("mdp", &mdp_pdata);
4775 msm_fb_register_device("pmdh", &mddi_pdata);
4776 msm_fb_register_device("lcdc", &lcdc_pdata);
4777 msm_fb_register_device("dtv", &dtv_pdata);
4778 msm_fb_register_device("tvenc", &atv_pdata);
4779#ifdef CONFIG_FB_MSM_TVOUT
4780 msm_fb_register_device("tvout_device", NULL);
4781#endif
4782}
4783
4784static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
4785 .gpio_num = lcd_panel_spi_gpio_num,
4786};
4787
4788static struct platform_device lcdc_toshiba_panel_device = {
4789 .name = "lcdc_toshiba_wvga",
4790 .id = 0,
4791 .dev = {
4792 .platform_data = &lcdc_toshiba_panel_data,
4793 }
4794};
4795
4796#if defined(CONFIG_MARIMBA_CORE) && \
4797 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4798static struct platform_device msm_bt_power_device = {
4799 .name = "bt_power",
4800 .id = -1
4801};
4802
4803enum {
4804 BT_RFR,
4805 BT_CTS,
4806 BT_RX,
4807 BT_TX,
4808};
4809
4810static struct msm_gpio bt_config_power_on[] = {
4811 { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4812 "UART1DM_RFR" },
4813 { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4814 "UART1DM_CTS" },
4815 { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4816 "UART1DM_Rx" },
4817 { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4818 "UART1DM_Tx" }
4819};
4820
4821static struct msm_gpio bt_config_power_off[] = {
4822 { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4823 "UART1DM_RFR" },
4824 { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4825 "UART1DM_CTS" },
4826 { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4827 "UART1DM_Rx" },
4828 { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4829 "UART1DM_Tx" }
4830};
4831
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004832static u8 bahama_version;
4833
Justin Paupore3f40f342011-08-10 18:52:16 -07004834static struct regulator_bulk_data regs_bt_marimba[] = {
4835 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4836 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
4837 { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304838 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004839};
4840
4841static struct regulator_bulk_data regs_bt_bahama_v1[] = {
4842 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4843 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
4844 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304845 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004846};
4847
4848static struct regulator_bulk_data regs_bt_bahama_v2[] = {
4849 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4850 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304851 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004852};
4853
4854static struct regulator_bulk_data *regs_bt;
4855static int regs_bt_count;
4856
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004857static int marimba_bt(int on)
4858{
4859 int rc;
4860 int i;
4861 struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
4862
4863 struct marimba_config_register {
4864 u8 reg;
4865 u8 value;
4866 u8 mask;
4867 };
4868
4869 struct marimba_variant_register {
4870 const size_t size;
4871 const struct marimba_config_register *set;
4872 };
4873
4874 const struct marimba_config_register *p;
4875
4876 u8 version;
4877
4878 const struct marimba_config_register v10_bt_on[] = {
4879 { 0xE5, 0x0B, 0x0F },
4880 { 0x05, 0x02, 0x07 },
4881 { 0x06, 0x88, 0xFF },
4882 { 0xE7, 0x21, 0x21 },
4883 { 0xE3, 0x38, 0xFF },
4884 { 0xE4, 0x06, 0xFF },
4885 };
4886
4887 const struct marimba_config_register v10_bt_off[] = {
4888 { 0xE5, 0x0B, 0x0F },
4889 { 0x05, 0x08, 0x0F },
4890 { 0x06, 0x88, 0xFF },
4891 { 0xE7, 0x00, 0x21 },
4892 { 0xE3, 0x00, 0xFF },
4893 { 0xE4, 0x00, 0xFF },
4894 };
4895
4896 const struct marimba_config_register v201_bt_on[] = {
4897 { 0x05, 0x08, 0x07 },
4898 { 0x06, 0x88, 0xFF },
4899 { 0xE7, 0x21, 0x21 },
4900 { 0xE3, 0x38, 0xFF },
4901 { 0xE4, 0x06, 0xFF },
4902 };
4903
4904 const struct marimba_config_register v201_bt_off[] = {
4905 { 0x05, 0x08, 0x07 },
4906 { 0x06, 0x88, 0xFF },
4907 { 0xE7, 0x00, 0x21 },
4908 { 0xE3, 0x00, 0xFF },
4909 { 0xE4, 0x00, 0xFF },
4910 };
4911
4912 const struct marimba_config_register v210_bt_on[] = {
4913 { 0xE9, 0x01, 0x01 },
4914 { 0x06, 0x88, 0xFF },
4915 { 0xE7, 0x21, 0x21 },
4916 { 0xE3, 0x38, 0xFF },
4917 { 0xE4, 0x06, 0xFF },
4918 };
4919
4920 const struct marimba_config_register v210_bt_off[] = {
4921 { 0x06, 0x88, 0xFF },
4922 { 0xE7, 0x00, 0x21 },
4923 { 0xE9, 0x00, 0x01 },
4924 { 0xE3, 0x00, 0xFF },
4925 { 0xE4, 0x00, 0xFF },
4926 };
4927
4928 const struct marimba_variant_register bt_marimba[2][4] = {
4929 {
4930 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4931 { 0, NULL },
4932 { ARRAY_SIZE(v201_bt_off), v201_bt_off },
4933 { ARRAY_SIZE(v210_bt_off), v210_bt_off }
4934 },
4935 {
4936 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4937 { 0, NULL },
4938 { ARRAY_SIZE(v201_bt_on), v201_bt_on },
4939 { ARRAY_SIZE(v210_bt_on), v210_bt_on }
4940 }
4941 };
4942
4943 on = on ? 1 : 0;
4944
4945 rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F);
4946 if (rc < 0) {
4947 printk(KERN_ERR
4948 "%s: version read failed: %d\n",
4949 __func__, rc);
4950 return rc;
4951 }
4952
4953 if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
4954 (bt_marimba[on][version].size == 0)) {
4955 printk(KERN_ERR
4956 "%s: unsupported version\n",
4957 __func__);
4958 return -EIO;
4959 }
4960
4961 p = bt_marimba[on][version].set;
4962
4963 printk(KERN_INFO "%s: found version %d\n", __func__, version);
4964
4965 for (i = 0; i < bt_marimba[on][version].size; i++) {
4966 u8 value = (p+i)->value;
4967 rc = marimba_write_bit_mask(&config,
4968 (p+i)->reg,
4969 &value,
4970 sizeof((p+i)->value),
4971 (p+i)->mask);
4972 if (rc < 0) {
4973 printk(KERN_ERR
4974 "%s: reg %d write failed: %d\n",
4975 __func__, (p+i)->reg, rc);
4976 return rc;
4977 }
4978 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
4979 __func__, (p+i)->reg,
4980 value, (p+i)->mask);
4981 }
4982 return 0;
4983}
4984
4985static int bahama_bt(int on)
4986{
4987 int rc;
4988 int i;
4989 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
4990
4991 struct bahama_variant_register {
4992 const size_t size;
4993 const struct bahama_config_register *set;
4994 };
4995
4996 const struct bahama_config_register *p;
4997
4998
4999 const struct bahama_config_register v10_bt_on[] = {
5000 { 0xE9, 0x00, 0xFF },
5001 { 0xF4, 0x80, 0xFF },
5002 { 0xF0, 0x06, 0xFF },
5003 { 0xE4, 0x00, 0xFF },
5004 { 0xE5, 0x00, 0x0F },
5005#ifdef CONFIG_WLAN
5006 { 0xE6, 0x38, 0x7F },
5007 { 0xE7, 0x06, 0xFF },
5008#endif
5009 { 0x11, 0x13, 0xFF },
5010 { 0xE9, 0x21, 0xFF },
5011 { 0x01, 0x0C, 0x1F },
5012 { 0x01, 0x08, 0x1F },
5013 };
5014
5015 const struct bahama_config_register v20_bt_on_fm_off[] = {
5016 { 0x11, 0x0C, 0xFF },
5017 { 0x13, 0x01, 0xFF },
5018 { 0xF4, 0x80, 0xFF },
5019 { 0xF0, 0x00, 0xFF },
5020 { 0xE9, 0x00, 0xFF },
5021#ifdef CONFIG_WLAN
5022 { 0x81, 0x00, 0xFF },
5023 { 0x82, 0x00, 0xFF },
5024 { 0xE6, 0x38, 0x7F },
5025 { 0xE7, 0x06, 0xFF },
5026#endif
5027 { 0xE9, 0x21, 0xFF }
5028 };
5029
5030 const struct bahama_config_register v20_bt_on_fm_on[] = {
5031 { 0x11, 0x0C, 0xFF },
5032 { 0x13, 0x01, 0xFF },
5033 { 0xF4, 0x86, 0xFF },
5034 { 0xF0, 0x06, 0xFF },
5035 { 0xE9, 0x00, 0xFF },
5036#ifdef CONFIG_WLAN
5037 { 0x81, 0x00, 0xFF },
5038 { 0x82, 0x00, 0xFF },
5039 { 0xE6, 0x38, 0x7F },
5040 { 0xE7, 0x06, 0xFF },
5041#endif
5042 { 0xE9, 0x21, 0xFF }
5043 };
5044
5045 const struct bahama_config_register v10_bt_off[] = {
5046 { 0xE9, 0x00, 0xFF },
5047 };
5048
5049 const struct bahama_config_register v20_bt_off_fm_off[] = {
5050 { 0xF4, 0x84, 0xFF },
5051 { 0xF0, 0x04, 0xFF },
5052 { 0xE9, 0x00, 0xFF }
5053 };
5054
5055 const struct bahama_config_register v20_bt_off_fm_on[] = {
5056 { 0xF4, 0x86, 0xFF },
5057 { 0xF0, 0x06, 0xFF },
5058 { 0xE9, 0x00, 0xFF }
5059 };
5060
5061 const struct bahama_variant_register bt_bahama[2][3] = {
5062 {
5063 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
5064 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
5065 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
5066 },
5067 {
5068 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
5069 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
5070 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
5071 }
5072 };
5073
5074 u8 offset = 0; /* index into bahama configs */
5075
5076 on = on ? 1 : 0;
5077
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005078
5079 if (bahama_version == VER_2_0) {
5080 if (marimba_get_fm_status(&config))
5081 offset = 0x01;
5082 }
5083
5084 p = bt_bahama[on][bahama_version + offset].set;
5085
5086 dev_info(&msm_bt_power_device.dev,
5087 "%s: found version %d\n", __func__, bahama_version);
5088
5089 for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
5090 u8 value = (p+i)->value;
5091 rc = marimba_write_bit_mask(&config,
5092 (p+i)->reg,
5093 &value,
5094 sizeof((p+i)->value),
5095 (p+i)->mask);
5096 if (rc < 0) {
5097 dev_err(&msm_bt_power_device.dev,
5098 "%s: reg %d write failed: %d\n",
5099 __func__, (p+i)->reg, rc);
5100 return rc;
5101 }
5102 dev_info(&msm_bt_power_device.dev,
5103 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
5104 __func__, (p+i)->reg,
5105 value, (p+i)->mask);
5106 }
5107 /* Update BT status */
5108 if (on)
5109 marimba_set_bt_status(&config, true);
5110 else
5111 marimba_set_bt_status(&config, false);
5112
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005113 return 0;
5114}
5115
Justin Paupore3f40f342011-08-10 18:52:16 -07005116static int bluetooth_regs_init(int bahama_not_marimba)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005117{
Justin Paupore3f40f342011-08-10 18:52:16 -07005118 int rc = 0;
5119 struct device *const dev = &msm_bt_power_device.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005120
5121 if (bahama_not_marimba) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005122 bahama_version = read_bahama_ver();
5123
5124 switch (bahama_version) {
5125 case VER_1_0:
5126 regs_bt = regs_bt_bahama_v1;
5127 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1);
5128 break;
5129 case VER_2_0:
5130 regs_bt = regs_bt_bahama_v2;
5131 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2);
5132 break;
5133 case VER_UNSUPPORTED:
5134 default:
5135 dev_err(dev,
5136 "%s: i2c failure or unsupported version: %d\n",
5137 __func__, bahama_version);
5138 rc = -EIO;
5139 goto out;
5140 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005141 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07005142 regs_bt = regs_bt_marimba;
5143 regs_bt_count = ARRAY_SIZE(regs_bt_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005144 }
5145
Justin Paupore3f40f342011-08-10 18:52:16 -07005146 rc = regulator_bulk_get(&msm_bt_power_device.dev,
5147 regs_bt_count, regs_bt);
5148 if (rc) {
5149 dev_err(dev, "%s: could not get regulators: %d\n",
5150 __func__, rc);
5151 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005152 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005153
5154 rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt);
5155 if (rc) {
5156 dev_err(dev, "%s: could not set voltages: %d\n",
5157 __func__, rc);
5158 goto reg_free;
5159 }
5160
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005161 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005162
5163reg_free:
5164 regulator_bulk_free(regs_bt_count, regs_bt);
5165out:
5166 regs_bt_count = 0;
5167 regs_bt = NULL;
5168 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005169}
5170
5171static int bluetooth_power(int on)
5172{
5173 int rc;
5174 const char *id = "BTPW";
5175
5176 int bahama_not_marimba = bahama_present();
5177
5178 if (bahama_not_marimba == -1) {
5179 printk(KERN_WARNING "%s: bahama_present: %d\n",
5180 __func__, bahama_not_marimba);
5181 return -ENODEV;
5182 }
5183
Justin Paupore3f40f342011-08-10 18:52:16 -07005184 if (unlikely(regs_bt_count == 0)) {
5185 rc = bluetooth_regs_init(bahama_not_marimba);
5186 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005187 return rc;
Justin Paupore3f40f342011-08-10 18:52:16 -07005188 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005189
Justin Paupore3f40f342011-08-10 18:52:16 -07005190 if (on) {
5191 rc = regulator_bulk_enable(regs_bt_count, regs_bt);
5192 if (rc)
5193 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005194
5195 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5196 PMAPP_CLOCK_VOTE_ON);
5197 if (rc < 0)
5198 return -EIO;
5199
5200 if (machine_is_msm8x55_svlte_surf() ||
5201 machine_is_msm8x55_svlte_ffa()) {
5202 rc = marimba_gpio_config(1);
5203 if (rc < 0)
5204 return -EIO;
5205 }
5206
5207 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5208 if (rc < 0)
5209 return -EIO;
5210
5211 msleep(10);
5212
5213 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5214 PMAPP_CLOCK_VOTE_PIN_CTRL);
5215 if (rc < 0)
5216 return -EIO;
5217
5218 if (machine_is_msm8x55_svlte_surf() ||
5219 machine_is_msm8x55_svlte_ffa()) {
5220 rc = marimba_gpio_config(0);
5221 if (rc < 0)
5222 return -EIO;
5223 }
5224
5225 rc = msm_gpios_enable(bt_config_power_on,
5226 ARRAY_SIZE(bt_config_power_on));
5227
5228 if (rc < 0)
5229 return rc;
5230
5231 } else {
5232 rc = msm_gpios_enable(bt_config_power_off,
5233 ARRAY_SIZE(bt_config_power_off));
5234 if (rc < 0)
5235 return rc;
5236
5237 /* check for initial RFKILL block (power off) */
5238 if (platform_get_drvdata(&msm_bt_power_device) == NULL)
5239 goto out;
5240
5241 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5242 if (rc < 0)
5243 return -EIO;
5244
5245 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5246 PMAPP_CLOCK_VOTE_OFF);
5247 if (rc < 0)
5248 return -EIO;
5249
Justin Paupore3f40f342011-08-10 18:52:16 -07005250 rc = regulator_bulk_disable(regs_bt_count, regs_bt);
5251 if (rc)
5252 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005253
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005254 }
5255
5256out:
5257 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
5258
5259 return 0;
5260}
5261
5262static void __init bt_power_init(void)
5263{
Justin Paupore3f40f342011-08-10 18:52:16 -07005264 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005265}
5266#else
5267#define bt_power_init(x) do {} while (0)
5268#endif
5269
5270static struct msm_psy_batt_pdata msm_psy_batt_data = {
5271 .voltage_min_design = 2800,
5272 .voltage_max_design = 4300,
5273 .avail_chg_sources = AC_CHG | USB_CHG ,
5274 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
5275};
5276
5277static struct platform_device msm_batt_device = {
5278 .name = "msm-battery",
5279 .id = -1,
5280 .dev.platform_data = &msm_psy_batt_data,
5281};
5282
5283static char *msm_adc_fluid_device_names[] = {
5284 "LTC_ADC1",
5285 "LTC_ADC2",
5286 "LTC_ADC3",
5287};
5288
5289static char *msm_adc_surf_device_names[] = {
5290 "XO_ADC",
5291};
5292
5293static struct msm_adc_platform_data msm_adc_pdata;
5294
5295static struct platform_device msm_adc_device = {
5296 .name = "msm_adc",
5297 .id = -1,
5298 .dev = {
5299 .platform_data = &msm_adc_pdata,
5300 },
5301};
5302
5303#ifdef CONFIG_MSM_SDIO_AL
5304static struct msm_gpio mdm2ap_status = {
5305 GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5306 "mdm2ap_status"
5307};
5308
5309
5310static int configure_mdm2ap_status(int on)
5311{
5312 if (on)
5313 return msm_gpios_request_enable(&mdm2ap_status, 1);
5314 else {
5315 msm_gpios_disable_free(&mdm2ap_status, 1);
5316 return 0;
5317 }
5318}
5319
5320static int get_mdm2ap_status(void)
5321{
5322 return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
5323}
5324
5325static struct sdio_al_platform_data sdio_al_pdata = {
5326 .config_mdm2ap_status = configure_mdm2ap_status,
5327 .get_mdm2ap_status = get_mdm2ap_status,
5328 .allow_sdioc_version_major_2 = 1,
5329 .peer_sdioc_version_minor = 0x0001,
5330 .peer_sdioc_version_major = 0x0003,
5331 .peer_sdioc_boot_version_minor = 0x0001,
5332 .peer_sdioc_boot_version_major = 0x0003,
5333};
5334
5335struct platform_device msm_device_sdio_al = {
5336 .name = "msm_sdio_al",
5337 .id = -1,
5338 .dev = {
5339 .platform_data = &sdio_al_pdata,
5340 },
5341};
5342
5343#endif /* CONFIG_MSM_SDIO_AL */
5344
Daniel Walker8d747cd2010-02-25 11:37:43 -08005345static struct platform_device *devices[] __initdata = {
Daniel Walker90e37c52010-05-12 14:24:15 -07005346#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005347 &msm_device_uart2,
5348#endif
Justin Paupore637a25d2011-07-14 17:11:04 -07005349#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
5350 &msm_proccomm_regulator_dev,
5351#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005352 &asoc_msm_pcm,
5353 &asoc_msm_dai0,
5354 &asoc_msm_dai1,
5355#if defined (CONFIG_SND_MSM_MVS_DAI_SOC)
5356 &asoc_msm_mvs,
5357 &asoc_mvs_dai0,
5358 &asoc_mvs_dai1,
Daniel Walker90e37c52010-05-12 14:24:15 -07005359#endif
Niranjana Vishwanathapuraa8855e92010-10-06 13:52:10 -07005360 &msm_device_smd,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005361 &msm_device_dmov,
5362 &smc91x_device,
5363 &smsc911x_device,
5364 &msm_device_nand,
5365#ifdef CONFIG_USB_MSM_OTG_72K
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05305366 &msm_device_otg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005367#ifdef CONFIG_USB_GADGET
5368 &msm_device_gadget_peripheral,
5369#endif
5370#endif
5371#ifdef CONFIG_USB_G_ANDROID
5372 &android_usb_device,
5373#endif
5374 &qsd_device_spi,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305375
5376#ifdef CONFIG_MSM_SSBI
5377 &msm_device_ssbi_pmic1,
5378#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005379#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005380 &msm_device_ssbi7,
5381#endif
5382 &android_pmem_device,
5383 &msm_fb_device,
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08005384#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
5385 &msm_v4l2_video_overlay_device,
5386#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005387 &msm_migrate_pages_device,
5388 &mddi_toshiba_device,
5389 &lcdc_toshiba_panel_device,
5390#ifdef CONFIG_MSM_ROTATOR
5391 &msm_rotator_device,
5392#endif
5393 &lcdc_sharp_panel_device,
5394 &android_pmem_adsp_device,
5395 &android_pmem_audio_device,
5396 &msm_device_i2c,
5397 &msm_device_i2c_2,
5398 &msm_device_uart_dm1,
5399 &hs_device,
5400#ifdef CONFIG_MSM7KV2_AUDIO
5401 &msm_aictl_device,
5402 &msm_mi2s_device,
5403 &msm_lpa_device,
5404 &msm_aux_pcm_device,
5405#endif
5406 &msm_device_adspdec,
5407 &qup_device_i2c,
5408#if defined(CONFIG_MARIMBA_CORE) && \
5409 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5410 &msm_bt_power_device,
5411#endif
5412 &msm_kgsl_3d0,
5413 &msm_kgsl_2d0,
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005414#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005415#ifdef CONFIG_MT9T013
5416 &msm_camera_sensor_mt9t013,
5417#endif
5418#ifdef CONFIG_MT9D112
5419 &msm_camera_sensor_mt9d112,
5420#endif
5421#ifdef CONFIG_WEBCAM_OV9726
5422 &msm_camera_sensor_ov9726,
5423#endif
5424#ifdef CONFIG_S5K3E2FX
5425 &msm_camera_sensor_s5k3e2fx,
5426#endif
5427#ifdef CONFIG_MT9P012
5428 &msm_camera_sensor_mt9p012,
5429#endif
5430#ifdef CONFIG_MT9E013
5431 &msm_camera_sensor_mt9e013,
5432#endif
5433#ifdef CONFIG_VX6953
5434 &msm_camera_sensor_vx6953,
5435#endif
5436#ifdef CONFIG_SN12M0PZ
5437 &msm_camera_sensor_sn12m0pz,
5438#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005439#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005440 &msm_device_vidc_720p,
5441#ifdef CONFIG_MSM_GEMINI
5442 &msm_gemini_device,
5443#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005444#ifndef CONFIG_MSM_CAMERA_V4L2
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005445#ifdef CONFIG_MSM_VPE
5446 &msm_vpe_device,
5447#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07005448#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005449#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5450 &msm_device_tsif,
5451#endif
5452#ifdef CONFIG_MSM_SDIO_AL
5453 &msm_device_sdio_al,
5454#endif
5455
5456#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5457 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5458 &qcrypto_device,
5459#endif
5460
5461#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5462 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5463 &qcedev_device,
5464#endif
5465
5466 &msm_batt_device,
5467 &msm_adc_device,
5468 &msm_ebi0_thermal,
Laxminath Kasam1d8255d2012-02-15 13:10:19 +05305469 &msm_ebi1_thermal,
5470 &msm_adsp_device
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005471};
5472
5473static struct msm_gpio msm_i2c_gpios_hw[] = {
5474 { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5475 { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5476};
5477
5478static struct msm_gpio msm_i2c_gpios_io[] = {
5479 { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5480 { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5481};
5482
5483static struct msm_gpio qup_i2c_gpios_io[] = {
5484 { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5485 { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5486};
5487static struct msm_gpio qup_i2c_gpios_hw[] = {
5488 { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5489 { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5490};
5491
5492static void
5493msm_i2c_gpio_config(int adap_id, int config_type)
5494{
5495 struct msm_gpio *msm_i2c_table;
5496
5497 /* Each adapter gets 2 lines from the table */
5498 if (adap_id > 0)
5499 return;
5500 if (config_type)
5501 msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
5502 else
5503 msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
5504 msm_gpios_enable(msm_i2c_table, 2);
5505}
5506/*This needs to be enabled only for OEMS*/
5507#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005508static struct regulator *qup_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005509#endif
5510static void
5511qup_i2c_gpio_config(int adap_id, int config_type)
5512{
5513 int rc = 0;
5514 struct msm_gpio *qup_i2c_table;
5515 /* Each adapter gets 2 lines from the table */
5516 if (adap_id != 4)
5517 return;
5518 if (config_type)
5519 qup_i2c_table = qup_i2c_gpios_hw;
5520 else
5521 qup_i2c_table = qup_i2c_gpios_io;
5522 rc = msm_gpios_enable(qup_i2c_table, 2);
5523 if (rc < 0)
5524 printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
5525 /*This needs to be enabled only for OEMS*/
5526#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005527 if (!IS_ERR_OR_NULL(qup_vreg)) {
5528 rc = regulator_enable(qup_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005529 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005530 pr_err("%s: regulator_enable failed: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005531 __func__, rc);
5532 }
5533 }
5534#endif
5535}
5536
5537static struct msm_i2c_platform_data msm_i2c_pdata = {
5538 .clk_freq = 100000,
5539 .pri_clk = 70,
5540 .pri_dat = 71,
5541 .rmutex = 1,
5542 .rsl_id = "D:I2C02000021",
5543 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5544};
5545
5546static void __init msm_device_i2c_init(void)
5547{
5548 if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
5549 pr_err("failed to request I2C gpios\n");
5550
5551 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
5552}
5553
5554static struct msm_i2c_platform_data msm_i2c_2_pdata = {
5555 .clk_freq = 100000,
5556 .rmutex = 1,
5557 .rsl_id = "D:I2C02000022",
5558 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5559};
5560
5561static void __init msm_device_i2c_2_init(void)
5562{
5563 msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
5564}
5565
5566static struct msm_i2c_platform_data qup_i2c_pdata = {
5567 .clk_freq = 384000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005568 .msm_i2c_config_gpio = qup_i2c_gpio_config,
5569};
5570
5571static void __init qup_device_i2c_init(void)
5572{
5573 if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
5574 pr_err("failed to request I2C gpios\n");
5575
5576 qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
5577 /*This needs to be enabled only for OEMS*/
5578#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005579 qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005580 if (IS_ERR(qup_vreg)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005581 dev_err(&qup_device_i2c.dev,
5582 "%s: regulator_get failed: %ld\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005583 __func__, PTR_ERR(qup_vreg));
5584 }
5585#endif
5586}
5587
5588#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005589static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = {
5590 .rsl_id = "D:CODEC_SSBI",
5591 .controller_type = MSM_SBI_CTRL_SSBI,
5592};
5593#endif
5594
Daniel Walker8d747cd2010-02-25 11:37:43 -08005595static void __init msm7x30_init_irq(void)
5596{
5597 msm_init_irq();
5598}
5599
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005600static struct msm_gpio msm_nand_ebi2_cfg_data[] = {
5601 {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
5602 {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
5603};
5604
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005605#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
5606 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
5607 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
5608 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
5609
5610struct sdcc_gpio {
5611 struct msm_gpio *cfg_data;
5612 uint32_t size;
5613 struct msm_gpio *sleep_cfg_data;
5614};
5615#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5616static struct msm_gpio sdc1_lvlshft_cfg_data[] = {
5617 {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
5618};
5619#endif
5620static struct msm_gpio sdc1_cfg_data[] = {
5621 {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
5622 {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
5623 {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
5624 {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
5625 {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
5626 {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
5627};
5628
5629static struct msm_gpio sdc2_cfg_data[] = {
5630 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
5631 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
5632 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
5633 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
5634 {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
5635 {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
5636
5637#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5638 {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
5639 {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
5640 {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
5641 {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
5642#endif
5643};
5644
5645static struct msm_gpio sdc3_cfg_data[] = {
5646 {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
5647 {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
5648 {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
5649 {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
5650 {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
5651 {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
5652};
5653
5654static struct msm_gpio sdc3_sleep_cfg_data[] = {
5655 {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5656 "sdc3_clk"},
5657 {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5658 "sdc3_cmd"},
5659 {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5660 "sdc3_dat_3"},
5661 {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5662 "sdc3_dat_2"},
5663 {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5664 "sdc3_dat_1"},
5665 {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5666 "sdc3_dat_0"},
5667};
5668
5669static struct msm_gpio sdc4_cfg_data[] = {
5670 {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
5671 {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
5672 {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
5673 {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
5674 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
5675 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
5676};
5677
5678static struct sdcc_gpio sdcc_cfg_data[] = {
5679 {
5680 .cfg_data = sdc1_cfg_data,
5681 .size = ARRAY_SIZE(sdc1_cfg_data),
5682 .sleep_cfg_data = NULL,
5683 },
5684 {
5685 .cfg_data = sdc2_cfg_data,
5686 .size = ARRAY_SIZE(sdc2_cfg_data),
5687 .sleep_cfg_data = NULL,
5688 },
5689 {
5690 .cfg_data = sdc3_cfg_data,
5691 .size = ARRAY_SIZE(sdc3_cfg_data),
5692 .sleep_cfg_data = sdc3_sleep_cfg_data,
5693 },
5694 {
5695 .cfg_data = sdc4_cfg_data,
5696 .size = ARRAY_SIZE(sdc4_cfg_data),
5697 .sleep_cfg_data = NULL,
5698 },
5699};
5700
Justin Paupore3f40f342011-08-10 18:52:16 -07005701static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005702
5703static unsigned long vreg_sts, gpio_sts;
5704
5705static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
5706{
5707 int rc = 0;
5708 struct sdcc_gpio *curr;
5709
5710 curr = &sdcc_cfg_data[dev_id - 1];
5711
5712 if (!(test_bit(dev_id, &gpio_sts)^enable))
5713 return rc;
5714
5715 if (enable) {
5716 set_bit(dev_id, &gpio_sts);
5717 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
5718 if (rc)
5719 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
5720 __func__, dev_id);
5721 } else {
5722 clear_bit(dev_id, &gpio_sts);
5723 if (curr->sleep_cfg_data) {
5724 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
5725 msm_gpios_free(curr->sleep_cfg_data, curr->size);
5726 } else {
5727 msm_gpios_disable_free(curr->cfg_data, curr->size);
5728 }
5729 }
5730
5731 return rc;
5732}
5733
5734static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
5735{
5736 int rc = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005737 struct regulator *curr = sdcc_vreg_data[dev_id - 1];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005738 static int enabled_once[] = {0, 0, 0, 0};
5739
Justin Paupore3f40f342011-08-10 18:52:16 -07005740 if (test_bit(dev_id, &vreg_sts) == enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005741 return rc;
5742
Asutosh Das853bbcd2012-02-01 10:40:05 +05305743 if (dev_id == 4) {
5744 if (enable) {
5745 pr_debug("Enable Vdd dev_%d\n", dev_id);
5746 gpio_set_value_cansleep(
5747 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5748 0);
5749 set_bit(dev_id, &vreg_sts);
5750 } else {
5751 pr_debug("Disable Vdd dev_%d\n", dev_id);
5752 gpio_set_value_cansleep(
5753 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5754 1);
5755 clear_bit(dev_id, &vreg_sts);
5756 }
5757 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005758
Asutosh Das853bbcd2012-02-01 10:40:05 +05305759 if (!enable || enabled_once[dev_id - 1])
5760 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005761 if (!curr)
5762 return -ENODEV;
5763
5764 if (IS_ERR(curr))
5765 return PTR_ERR(curr);
5766
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005767 if (enable) {
5768 set_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005769
5770 rc = regulator_enable(curr);
5771 if (rc)
5772 pr_err("%s: could not enable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005773 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005774 enabled_once[dev_id - 1] = 1;
5775 } else {
5776 clear_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005777
5778 rc = regulator_disable(curr);
5779 if (rc)
5780 pr_err("%s: could not disable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005781 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005782 }
5783 return rc;
5784}
5785
5786static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
5787{
5788 int rc = 0;
5789 struct platform_device *pdev;
5790
5791 pdev = container_of(dv, struct platform_device, dev);
5792 rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
5793 if (rc)
5794 goto out;
5795
5796 if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
5797 rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
5798out:
5799 return rc;
5800}
5801
5802#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \
5803 defined(CONFIG_CSDIO_VENDOR_ID) && \
5804 defined(CONFIG_CSDIO_DEVICE_ID) && \
5805 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5806
5807#define MBP_ON 1
5808#define MBP_OFF 0
5809
5810#define MBP_RESET_N \
5811 GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
5812#define MBP_INT0 \
5813 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
5814
5815#define MBP_MODE_CTRL_0 \
5816 GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5817#define MBP_MODE_CTRL_1 \
5818 GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5819#define MBP_MODE_CTRL_2 \
5820 GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5821#define TSIF_EN \
5822 GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5823#define TSIF_DATA \
5824 GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5825#define TSIF_CLK \
5826 GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5827
5828static struct msm_gpio mbp_cfg_data[] = {
5829 {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5830 "mbp_reset"},
5831 {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5832 "mbp_io_voltage"},
5833};
5834
5835static int mbp_config_gpios_pre_init(int enable)
5836{
5837 int rc = 0;
5838
5839 if (enable) {
5840 rc = msm_gpios_request_enable(mbp_cfg_data,
5841 ARRAY_SIZE(mbp_cfg_data));
5842 if (rc) {
5843 printk(KERN_ERR
5844 "%s: Failed to turnon GPIOs for mbp chip(%d)\n",
5845 __func__, rc);
5846 }
5847 } else
5848 msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
5849 return rc;
5850}
5851
Justin Paupore3f40f342011-08-10 18:52:16 -07005852static struct regulator_bulk_data mbp_regs_io[2];
5853static struct regulator_bulk_data mbp_regs_rf[2];
5854static struct regulator_bulk_data mbp_regs_adc[1];
5855static struct regulator_bulk_data mbp_regs_core[1];
5856
5857static int mbp_init_regs(struct device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005858{
Justin Paupore3f40f342011-08-10 18:52:16 -07005859 struct regulator_bulk_data regs[] = {
5860 /* Analog and I/O regs */
5861 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
5862 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
5863 /* RF regs */
5864 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
5865 { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 },
5866 /* ADC regs */
5867 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
5868 /* Core regs */
5869 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
5870 };
5871
5872 struct regulator_bulk_data *regptr = regs;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005873 int rc;
5874
Justin Paupore3f40f342011-08-10 18:52:16 -07005875 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs);
5876
5877 if (rc) {
5878 dev_err(dev, "%s: could not get regulators: %d\n",
5879 __func__, rc);
5880 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005881 }
5882
Justin Paupore3f40f342011-08-10 18:52:16 -07005883 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005884
Justin Paupore3f40f342011-08-10 18:52:16 -07005885 if (rc) {
5886 dev_err(dev, "%s: could not set voltages: %d\n",
5887 __func__, rc);
5888 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005889 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005890
5891 memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io));
5892 regptr += ARRAY_SIZE(mbp_regs_io);
5893
5894 memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf));
5895 regptr += ARRAY_SIZE(mbp_regs_rf);
5896
5897 memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc));
5898 regptr += ARRAY_SIZE(mbp_regs_adc);
5899
5900 memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core));
5901
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005902 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005903
5904reg_free:
5905 regulator_bulk_free(ARRAY_SIZE(regs), regs);
5906out:
5907 return rc;
5908}
5909
5910static int mbp_setup_rf_vregs(int state)
5911{
5912 return state ?
5913 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) :
5914 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005915}
5916
5917static int mbp_setup_vregs(int state)
5918{
Justin Paupore3f40f342011-08-10 18:52:16 -07005919 return state ?
5920 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) :
5921 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005922}
5923
5924static int mbp_set_tcxo_en(int enable)
5925{
5926 int rc;
5927 const char *id = "UBMC";
5928 struct vreg *vreg_analog = NULL;
5929
5930 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
5931 enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
5932 if (rc < 0) {
5933 printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
5934 __func__, enable ? "" : "de-");
5935 return -EIO;
5936 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005937 return rc;
5938}
5939
5940static void mbp_set_freeze_io(int state)
5941{
5942 if (state)
5943 gpio_set_value(85, 0);
5944 else
5945 gpio_set_value(85, 1);
5946}
5947
5948static int mbp_set_core_voltage_en(int enable)
5949{
Justin Paupore3f40f342011-08-10 18:52:16 -07005950 static bool is_enabled;
5951 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005952
Justin Paupore3f40f342011-08-10 18:52:16 -07005953 if (enable && !is_enabled) {
5954 rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core),
5955 mbp_regs_core);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005956 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005957 pr_err("%s: could not enable regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005958 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07005959 } else {
5960 is_enabled = true;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005961 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005962 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005963
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005964 return rc;
5965}
5966
5967static void mbp_set_reset(int state)
5968{
5969 if (state)
5970 gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
5971 else
5972 gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
5973}
5974
5975static int mbp_config_interface_mode(int state)
5976{
5977 if (state) {
5978 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
5979 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
5980 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
5981 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
5982 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
5983 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
5984 } else {
5985 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
5986 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
5987 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
5988 }
5989 return 0;
5990}
5991
5992static int mbp_setup_adc_vregs(int state)
5993{
Justin Paupore3f40f342011-08-10 18:52:16 -07005994 return state ?
5995 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) :
5996 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005997}
5998
5999static int mbp_power_up(void)
6000{
6001 int rc;
6002
6003 rc = mbp_config_gpios_pre_init(MBP_ON);
6004 if (rc)
6005 goto exit;
6006 pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__);
6007
6008 rc = mbp_setup_vregs(MBP_ON);
6009 if (rc)
6010 goto exit;
6011 pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
6012
6013 rc = mbp_set_tcxo_en(MBP_ON);
6014 if (rc)
6015 goto exit;
6016 pr_debug("%s: tcxo clock done\n", __func__);
6017
6018 mbp_set_freeze_io(MBP_OFF);
6019 pr_debug("%s: set gpio 85 to 1 done\n", __func__);
6020
6021 udelay(100);
6022 mbp_set_reset(MBP_ON);
6023
6024 udelay(300);
6025 rc = mbp_config_interface_mode(MBP_ON);
6026 if (rc)
6027 goto exit;
6028 pr_debug("%s: mbp_config_interface_mode() done\n", __func__);
6029
6030 udelay(100 + mbp_set_core_voltage_en(MBP_ON));
6031 pr_debug("%s: power gp16 1.2V done\n", __func__);
6032
6033 mbp_set_freeze_io(MBP_ON);
6034 pr_debug("%s: set gpio 85 to 0 done\n", __func__);
6035
6036 udelay(100);
6037
6038 rc = mbp_setup_rf_vregs(MBP_ON);
6039 if (rc)
6040 goto exit;
6041 pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
6042
6043 rc = mbp_setup_adc_vregs(MBP_ON);
6044 if (rc)
6045 goto exit;
6046 pr_debug("%s: s4 2.2V done\n", __func__);
6047
6048 udelay(200);
6049
6050 mbp_set_reset(MBP_OFF);
6051 pr_debug("%s: close gpio 44 done\n", __func__);
6052
6053 msleep(20);
6054exit:
6055 return rc;
6056}
6057
6058static int mbp_power_down(void)
6059{
6060 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006061
6062 mbp_set_reset(MBP_ON);
6063 pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
6064
6065 udelay(100);
6066
6067 rc = mbp_setup_adc_vregs(MBP_OFF);
6068 if (rc)
6069 goto exit;
6070 pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
6071
6072 udelay(5);
6073
6074 rc = mbp_setup_rf_vregs(MBP_OFF);
6075 if (rc)
6076 goto exit;
6077 pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
6078
6079 udelay(5);
6080
6081 mbp_set_freeze_io(MBP_OFF);
6082 pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
6083
6084 udelay(100);
6085 rc = mbp_set_core_voltage_en(MBP_OFF);
6086 if (rc)
6087 goto exit;
6088 pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
6089
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006090 rc = mbp_set_tcxo_en(MBP_OFF);
6091 if (rc)
6092 goto exit;
6093 pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
6094
Justin Paupore3f40f342011-08-10 18:52:16 -07006095 rc = mbp_setup_vregs(MBP_OFF);
6096 if (rc)
6097 goto exit;
6098 pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__);
6099
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006100 rc = mbp_config_gpios_pre_init(MBP_OFF);
6101 if (rc)
6102 goto exit;
6103exit:
6104 return rc;
6105}
6106
6107static void (*mbp_status_notify_cb)(int card_present, void *dev_id);
6108static void *mbp_status_notify_cb_devid;
6109static int mbp_power_status;
6110static int mbp_power_init_done;
6111
6112static uint32_t mbp_setup_power(struct device *dv,
6113 unsigned int power_status)
6114{
6115 int rc = 0;
6116 struct platform_device *pdev;
6117
6118 pdev = container_of(dv, struct platform_device, dev);
6119
6120 if (power_status == mbp_power_status)
6121 goto exit;
6122 if (power_status) {
6123 pr_debug("turn on power of mbp slot");
6124 rc = mbp_power_up();
6125 mbp_power_status = 1;
6126 } else {
6127 pr_debug("turn off power of mbp slot");
6128 rc = mbp_power_down();
6129 mbp_power_status = 0;
6130 }
6131exit:
6132 return rc;
6133};
6134
6135int mbp_register_status_notify(void (*callback)(int, void *),
6136 void *dev_id)
6137{
6138 mbp_status_notify_cb = callback;
6139 mbp_status_notify_cb_devid = dev_id;
6140 return 0;
6141}
6142
6143static unsigned int mbp_status(struct device *dev)
6144{
6145 return mbp_power_status;
6146}
6147
6148static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd)
6149{
6150 struct platform_device *pdev;
6151 uint32_t rc = 0;
6152
6153 pdev = container_of(dv, struct platform_device, dev);
6154 rc = msm_sdcc_setup_power(dv, vdd);
6155 if (rc) {
6156 pr_err("%s: Failed to setup power (%d)\n",
6157 __func__, rc);
6158 goto out;
6159 }
6160 if (!mbp_power_init_done) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006161 rc = mbp_init_regs(dv);
6162 if (rc) {
6163 dev_err(dv, "%s: regulator init failed: %d\n",
6164 __func__, rc);
6165 goto out;
6166 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006167 mbp_setup_power(dv, 1);
6168 mbp_setup_power(dv, 0);
6169 mbp_power_init_done = 1;
6170 }
6171 if (vdd >= 0x8000) {
6172 rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
6173 if (rc) {
6174 pr_err("%s: Failed to config mbp chip power (%d)\n",
6175 __func__, rc);
6176 goto out;
6177 }
6178 if (mbp_status_notify_cb) {
6179 mbp_status_notify_cb(mbp_power_status,
6180 mbp_status_notify_cb_devid);
6181 }
6182 }
6183out:
6184 /* should return 0 only */
6185 return 0;
6186}
6187
6188#endif
6189
6190#endif
6191
6192#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6193#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6194static unsigned int msm7x30_sdcc_slot_status(struct device *dev)
6195{
6196 return (unsigned int)
6197 gpio_get_value_cansleep(
6198 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1));
6199}
6200#endif
6201
6202static int msm_sdcc_get_wpswitch(struct device *dv)
6203{
6204 void __iomem *wp_addr = 0;
6205 uint32_t ret = 0;
6206 struct platform_device *pdev;
6207
6208 if (!(machine_is_msm7x30_surf()))
6209 return -1;
6210 pdev = container_of(dv, struct platform_device, dev);
6211
6212 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
6213 if (!wp_addr) {
6214 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
6215 return -ENOMEM;
6216 }
6217
6218 ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
6219 pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
6220 pdev->id, ret);
6221 iounmap(wp_addr);
6222
6223 return ret;
6224}
6225#endif
6226
6227#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
6228#if defined(CONFIG_CSDIO_VENDOR_ID) && \
6229 defined(CONFIG_CSDIO_DEVICE_ID) && \
6230 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
6231static struct mmc_platform_data msm7x30_sdc1_data = {
6232 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
6233 .translate_vdd = msm_sdcc_setup_power_mbp,
6234 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6235 .status = mbp_status,
6236 .register_status_notify = mbp_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006237 .msmsdcc_fmin = 144000,
6238 .msmsdcc_fmid = 24576000,
6239 .msmsdcc_fmax = 24576000,
6240 .nonremovable = 0,
6241};
6242#else
6243static struct mmc_platform_data msm7x30_sdc1_data = {
6244 .ocr_mask = MMC_VDD_165_195,
6245 .translate_vdd = msm_sdcc_setup_power,
6246 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006247 .msmsdcc_fmin = 144000,
6248 .msmsdcc_fmid = 24576000,
6249 .msmsdcc_fmax = 49152000,
6250 .nonremovable = 0,
6251};
6252#endif
6253#endif
6254
6255#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
6256static struct mmc_platform_data msm7x30_sdc2_data = {
6257 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
6258 .translate_vdd = msm_sdcc_setup_power,
6259#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
6260 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
6261#else
6262 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6263#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006264 .msmsdcc_fmin = 144000,
6265 .msmsdcc_fmid = 24576000,
6266 .msmsdcc_fmax = 49152000,
6267 .nonremovable = 1,
6268};
6269#endif
6270
6271#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
6272static struct mmc_platform_data msm7x30_sdc3_data = {
6273 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6274 .translate_vdd = msm_sdcc_setup_power,
6275 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006276 .sdiowakeup_irq = MSM_GPIO_TO_INT(118),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006277 .msmsdcc_fmin = 144000,
6278 .msmsdcc_fmid = 24576000,
6279 .msmsdcc_fmax = 49152000,
6280 .nonremovable = 0,
6281};
6282#endif
6283
6284#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6285static struct mmc_platform_data msm7x30_sdc4_data = {
6286 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6287 .translate_vdd = msm_sdcc_setup_power,
6288 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6289#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6290 .status = msm7x30_sdcc_slot_status,
6291 .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
6292 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
6293#endif
6294 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006295 .msmsdcc_fmin = 144000,
6296 .msmsdcc_fmid = 24576000,
6297 .msmsdcc_fmax = 49152000,
6298 .nonremovable = 0,
6299};
6300#endif
6301
6302#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006303static int msm_sdc1_lvlshft_enable(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006304{
Justin Paupore3f40f342011-08-10 18:52:16 -07006305 static struct regulator *ldo5;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006306 int rc;
6307
6308 /* Enable LDO5, an input to the FET that powers slot 1 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006309
Justin Paupore3f40f342011-08-10 18:52:16 -07006310 ldo5 = regulator_get(NULL, "ldo5");
6311
6312 if (IS_ERR(ldo5)) {
6313 rc = PTR_ERR(ldo5);
6314 pr_err("%s: could not get ldo5: %d\n", __func__, rc);
6315 goto out;
6316 }
6317
6318 rc = regulator_set_voltage(ldo5, 2850000, 2850000);
6319 if (rc) {
6320 pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc);
6321 goto ldo5_free;
6322 }
6323
6324 rc = regulator_enable(ldo5);
6325 if (rc) {
6326 pr_err("%s: could not enable ldo5: %d\n", __func__, rc);
6327 goto ldo5_free;
6328 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006329
6330 /* Enable GPIO 35, to turn on the FET that powers slot 1 */
6331 rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
6332 ARRAY_SIZE(sdc1_lvlshft_cfg_data));
6333 if (rc)
6334 printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
6335
6336 rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg),
6337 1);
6338 if (rc)
6339 printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006340
6341 return 0;
6342
6343ldo5_free:
6344 regulator_put(ldo5);
6345out:
6346 ldo5 = NULL;
6347 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006348}
6349#endif
6350
Justin Paupore3f40f342011-08-10 18:52:16 -07006351static int mmc_regulator_init(int sdcc_no, const char *supply, int uV)
6352{
6353 int rc;
6354
6355 BUG_ON(sdcc_no < 1 || sdcc_no > 4);
6356
6357 sdcc_no--;
6358
6359 sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply);
6360
6361 if (IS_ERR(sdcc_vreg_data[sdcc_no])) {
6362 rc = PTR_ERR(sdcc_vreg_data[sdcc_no]);
6363 pr_err("%s: could not get regulator \"%s\": %d\n",
6364 __func__, supply, rc);
6365 goto out;
6366 }
6367
6368 rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV);
6369
6370 if (rc) {
6371 pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n",
6372 __func__, supply, uV, rc);
6373 goto reg_free;
6374 }
6375
6376 return rc;
6377
6378reg_free:
6379 regulator_put(sdcc_vreg_data[sdcc_no]);
6380out:
6381 sdcc_vreg_data[sdcc_no] = NULL;
6382 return rc;
6383}
6384
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006385static void __init msm7x30_init_mmc(void)
6386{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006387#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006388 if (mmc_regulator_init(1, "s3", 1800000))
6389 goto out1;
6390
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006391 if (machine_is_msm7x30_fluid()) {
6392 msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
Justin Paupore3f40f342011-08-10 18:52:16 -07006393 if (msm_sdc1_lvlshft_enable()) {
6394 pr_err("%s: could not enable level shift\n");
6395 goto out1;
6396 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006397 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006398
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006399 msm_add_sdcc(1, &msm7x30_sdc1_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006400out1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006401#endif
6402#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006403 if (mmc_regulator_init(2, "s3", 1800000))
6404 goto out2;
6405
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006406 if (machine_is_msm8x55_svlte_surf())
6407 msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
Sujith Reddy Thumma84a0f512011-08-29 09:57:03 +05306408 if (machine_is_msm8x55_svlte_surf() ||
6409 machine_is_msm8x55_svlte_ffa()) {
6410 msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
6411 msm7x30_sdc2_data.is_sdio_al_client = 1;
6412 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006413
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006414 msm_add_sdcc(2, &msm7x30_sdc2_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006415out2:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006416#endif
6417#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006418 if (mmc_regulator_init(3, "s3", 1800000))
6419 goto out3;
6420
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006421 msm_sdcc_setup_gpio(3, 1);
6422 msm_add_sdcc(3, &msm7x30_sdc3_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006423out3:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006424#endif
6425#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006426 if (mmc_regulator_init(4, "mmc", 2850000))
6427 return;
6428
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006429 msm_add_sdcc(4, &msm7x30_sdc4_data);
6430#endif
6431
6432}
6433
6434static void __init msm7x30_init_nand(void)
6435{
6436 char *build_id;
6437 struct flash_platform_data *plat_data;
6438
6439 build_id = socinfo_get_build_id();
6440 if (build_id == NULL) {
6441 pr_err("%s: Build ID not available from socinfo\n", __func__);
6442 return;
6443 }
6444
6445 if (build_id[8] == 'C' &&
6446 !msm_gpios_request_enable(msm_nand_ebi2_cfg_data,
6447 ARRAY_SIZE(msm_nand_ebi2_cfg_data))) {
6448 plat_data = msm_device_nand.dev.platform_data;
6449 plat_data->interleave = 1;
6450 printk(KERN_INFO "%s: Interleave mode Build ID found\n",
6451 __func__);
6452 }
6453}
6454
6455#ifdef CONFIG_SERIAL_MSM_CONSOLE
6456static struct msm_gpio uart2_config_data[] = {
6457 { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
6458 { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
6459 { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
6460 { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
6461};
6462
6463static void msm7x30_init_uart2(void)
6464{
6465 msm_gpios_request_enable(uart2_config_data,
6466 ARRAY_SIZE(uart2_config_data));
6467
6468}
6469#endif
6470
6471/* TSIF begin */
6472#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6473
6474#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6475#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6476#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6477#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6478
6479static const struct msm_gpio tsif_gpios[] = {
6480 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
6481 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
6482 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
6483 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
6484};
6485
6486static struct msm_tsif_platform_data tsif_platform_data = {
6487 .num_gpios = ARRAY_SIZE(tsif_gpios),
6488 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -07006489 .tsif_pclk = "iface_clk",
6490 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006491};
6492#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
6493/* TSIF end */
6494
6495static void __init pmic8058_leds_init(void)
6496{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306497 if (machine_is_msm7x30_surf())
6498 pm8058_7x30_data.leds_pdata = &pm8058_surf_leds_data;
6499 else if (!machine_is_msm7x30_fluid())
6500 pm8058_7x30_data.leds_pdata = &pm8058_ffa_leds_data;
6501 else if (machine_is_msm7x30_fluid())
6502 pm8058_7x30_data.leds_pdata = &pm8058_fluid_leds_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006503}
6504
6505static struct msm_spm_platform_data msm_spm_data __initdata = {
Taniya Das298de8c2012-02-16 11:45:31 +05306506 .reg_base_addr = MSM_SAW0_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006507
6508 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
6509 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
6510 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
6511 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
6512
6513 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
6514 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
6515 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
6516
6517 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
6518 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
6519 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
6520
6521 .awake_vlevel = 0xF2,
6522 .retention_vlevel = 0xE0,
6523 .collapse_vlevel = 0x72,
6524 .retention_mid_vlevel = 0xE0,
6525 .collapse_mid_vlevel = 0xE0,
6526
6527 .vctl_timeout_us = 50,
6528};
6529
6530#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6531 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6532
6533#define TSC2007_TS_PEN_INT 20
6534
6535static struct msm_gpio tsc2007_config_data[] = {
6536 { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
6537 "tsc2007_irq" },
6538};
6539
Justin Paupore3f40f342011-08-10 18:52:16 -07006540static struct regulator_bulk_data tsc2007_regs[] = {
6541 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
6542 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
6543};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006544
6545static int tsc2007_init(void)
6546{
6547 int rc;
6548
Justin Paupore3f40f342011-08-10 18:52:16 -07006549 rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006550
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006551 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006552 pr_err("%s: could not get regulators: %d\n", __func__, rc);
6553 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006554 }
6555
Justin Paupore3f40f342011-08-10 18:52:16 -07006556 rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6557
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006558 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006559 pr_err("%s: could not set voltages: %d\n", __func__, rc);
6560 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006561 }
6562
Justin Paupore3f40f342011-08-10 18:52:16 -07006563 rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006564
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006565 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006566 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
6567 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006568 }
6569
6570 rc = msm_gpios_request_enable(tsc2007_config_data,
6571 ARRAY_SIZE(tsc2007_config_data));
6572 if (rc) {
6573 pr_err("%s: Unable to request gpios\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006574 goto reg_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006575 }
6576
6577 return 0;
6578
Justin Paupore3f40f342011-08-10 18:52:16 -07006579reg_disable:
6580 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6581reg_free:
6582 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6583out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006584 return rc;
6585}
6586
6587static int tsc2007_get_pendown_state(void)
6588{
6589 int rc;
6590
6591 rc = gpio_get_value(TSC2007_TS_PEN_INT);
6592 if (rc < 0) {
6593 pr_err("%s: MSM GPIO %d read failed\n", __func__,
6594 TSC2007_TS_PEN_INT);
6595 return rc;
6596 }
6597
6598 return (rc == 0 ? 1 : 0);
6599}
6600
6601static void tsc2007_exit(void)
6602{
Justin Paupore3f40f342011-08-10 18:52:16 -07006603
6604 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6605 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006606
6607 msm_gpios_disable_free(tsc2007_config_data,
6608 ARRAY_SIZE(tsc2007_config_data));
6609}
6610
6611static int tsc2007_power_shutdown(bool enable)
6612{
6613 int rc;
6614
Justin Paupore3f40f342011-08-10 18:52:16 -07006615 rc = (enable == false) ?
6616 regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) :
6617 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6618
6619 if (rc) {
6620 pr_err("%s: could not %sable regulators: %d\n",
6621 __func__, enable ? "dis" : "en", rc);
6622 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006623 }
6624
Justin Paupore3f40f342011-08-10 18:52:16 -07006625 if (enable == false)
6626 msleep(20);
6627
6628 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006629}
6630
6631static struct tsc2007_platform_data tsc2007_ts_data = {
6632 .model = 2007,
6633 .x_plate_ohms = 300,
Anirudh Ghayala2cf2e22012-01-25 12:29:42 +05306634 .min_x = 210,
6635 .max_x = 3832,
6636 .min_y = 150,
6637 .max_y = 3936,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006638 .irq_flags = IRQF_TRIGGER_LOW,
6639 .init_platform_hw = tsc2007_init,
6640 .exit_platform_hw = tsc2007_exit,
6641 .power_shutdown = tsc2007_power_shutdown,
6642 .invert_x = true,
6643 .invert_y = true,
6644 /* REVISIT: Temporary fix for reversed pressure */
6645 .invert_z1 = true,
6646 .invert_z2 = true,
6647 .get_pendown_state = tsc2007_get_pendown_state,
6648};
6649
6650static struct i2c_board_info tsc_i2c_board_info[] = {
6651 {
6652 I2C_BOARD_INFO("tsc2007", 0x48),
6653 .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
6654 .platform_data = &tsc2007_ts_data,
6655 },
6656};
6657#endif
6658
Justin Paupore3f40f342011-08-10 18:52:16 -07006659static struct regulator_bulk_data regs_isa1200[] = {
6660 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
6661 { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006662};
6663
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006664static int isa1200_power(int vreg_on)
6665{
Justin Paupore3f40f342011-08-10 18:52:16 -07006666 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006667
Justin Paupore3f40f342011-08-10 18:52:16 -07006668 rc = vreg_on ?
6669 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) :
6670 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006671
Justin Paupore3f40f342011-08-10 18:52:16 -07006672 if (rc) {
6673 pr_err("%s: could not %sable regulators: %d\n",
6674 __func__, vreg_on ? "en" : "dis", rc);
6675 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006676 }
6677
6678 /* vote for DO buffer */
6679 rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO,
6680 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
6681 if (rc) {
6682 pr_err("%s: unable to %svote for d0 clk\n",
6683 __func__, vreg_on ? "" : "de-");
6684 goto vreg_fail;
6685 }
6686
6687 return 0;
6688
6689vreg_fail:
Justin Paupore3f40f342011-08-10 18:52:16 -07006690 if (vreg_on)
6691 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6692 else
6693 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6694out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006695 return rc;
6696}
6697
6698static int isa1200_dev_setup(bool enable)
6699{
Justin Paupore3f40f342011-08-10 18:52:16 -07006700 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006701
6702 if (enable == true) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006703 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200),
6704 regs_isa1200);
6705
6706 if (rc) {
6707 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006708 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006709 goto out;
6710 }
6711
6712 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200),
6713 regs_isa1200);
6714 if (rc) {
6715 pr_err("%s: could not set voltages: %d\n",
6716 __func__, rc);
6717 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006718 }
6719
6720 rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
6721 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
6722 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
6723 if (rc) {
6724 pr_err("%s: Could not configure gpio %d\n",
6725 __func__, HAP_LVL_SHFT_MSM_GPIO);
Justin Paupore3f40f342011-08-10 18:52:16 -07006726 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006727 }
6728
6729 rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
6730 if (rc) {
6731 pr_err("%s: unable to request gpio %d (%d)\n",
6732 __func__, HAP_LVL_SHFT_MSM_GPIO, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006733 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006734 }
6735
6736 gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
6737 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006738 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006739 gpio_free(HAP_LVL_SHFT_MSM_GPIO);
6740 }
6741
6742 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07006743
6744reg_free:
6745 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6746out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006747 return rc;
6748}
6749static struct isa1200_platform_data isa1200_1_pdata = {
6750 .name = "vibrator",
6751 .power_on = isa1200_power,
6752 .dev_setup = isa1200_dev_setup,
6753 .pwm_ch_id = 1, /*channel id*/
6754 /*gpio to enable haptic*/
6755 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka03122322011-09-09 15:15:43 +05306756 .hap_len_gpio = -1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006757 .max_timeout = 15000,
6758 .mode_ctrl = PWM_GEN_MODE,
6759 .pwm_fd = {
6760 .pwm_div = 256,
6761 },
6762 .is_erm = false,
6763 .smart_en = true,
6764 .ext_clk_en = true,
6765 .chip_en = 1,
6766};
6767
6768static struct i2c_board_info msm_isa1200_board_info[] = {
6769 {
6770 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
6771 .platform_data = &isa1200_1_pdata,
6772 },
6773};
6774
6775
6776static int kp_flip_mpp_config(void)
6777{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306778 struct pm8xxx_mpp_config_data kp_flip_mpp = {
6779 .type = PM8XXX_MPP_TYPE_D_INPUT,
6780 .level = PM8018_MPP_DIG_LEVEL_S3,
6781 .control = PM8XXX_MPP_DIN_TO_INT,
6782 };
6783
6784 return pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(PM_FLIP_MPP),
6785 &kp_flip_mpp);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006786}
6787
6788static struct flip_switch_pdata flip_switch_data = {
6789 .name = "kp_flip_switch",
6790 .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP,
6791 .left_key = KEY_OPEN,
6792 .right_key = KEY_CLOSE,
6793 .active_low = 0,
6794 .wakeup = 1,
6795 .flip_mpp_config = kp_flip_mpp_config,
6796};
6797
6798static struct platform_device flip_switch_device = {
6799 .name = "kp_flip_switch",
6800 .id = -1,
6801 .dev = {
6802 .platform_data = &flip_switch_data,
6803 }
6804};
6805
Justin Paupore3f40f342011-08-10 18:52:16 -07006806static struct regulator_bulk_data regs_tma300[] = {
6807 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
6808 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006809};
6810
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006811static int tma300_power(int vreg_on)
6812{
Justin Paupore3f40f342011-08-10 18:52:16 -07006813 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006814
Justin Paupore3f40f342011-08-10 18:52:16 -07006815 rc = vreg_on ?
6816 regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) :
6817 regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006818
Justin Paupore3f40f342011-08-10 18:52:16 -07006819 if (rc)
6820 pr_err("%s: could not %sable regulators: %d\n",
6821 __func__, vreg_on ? "en" : "dis", rc);
6822 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006823}
6824
6825#define TS_GPIO_IRQ 150
6826
6827static int tma300_dev_setup(bool enable)
6828{
Justin Paupore3f40f342011-08-10 18:52:16 -07006829 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006830
6831 if (enable) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006832 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300),
6833 regs_tma300);
6834
6835 if (rc) {
6836 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006837 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006838 goto out;
6839 }
6840
6841 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300),
6842 regs_tma300);
6843
6844 if (rc) {
6845 pr_err("%s: could not set voltages: %d\n",
6846 __func__, rc);
6847 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006848 }
6849
6850 /* enable interrupt gpio */
6851 rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
6852 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
6853 if (rc) {
6854 pr_err("%s: Could not configure gpio %d\n",
6855 __func__, TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -07006856 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006857 }
6858
6859 /* virtual keys */
6860 tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
6861 properties_kobj = kobject_create_and_add("board_properties",
6862 NULL);
6863 if (!properties_kobj) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006864 pr_err("%s: failed to create a kobject "
6865 "for board_properties\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006866 rc = -ENOMEM;
Justin Paupore3f40f342011-08-10 18:52:16 -07006867 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006868 }
6869 rc = sysfs_create_group(properties_kobj,
6870 &tma300_properties_attr_group);
6871 if (rc) {
6872 pr_err("%s: failed to create a sysfs entry %s\n",
6873 __func__, tma300_vkeys_attr.attr.name);
Justin Paupore3f40f342011-08-10 18:52:16 -07006874 goto kobj_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006875 }
6876 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006877 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006878 /* destroy virtual keys */
6879 if (properties_kobj) {
6880 sysfs_remove_group(properties_kobj,
6881 &tma300_properties_attr_group);
6882 kobject_put(properties_kobj);
6883 }
6884 }
6885 return 0;
6886
Justin Paupore3f40f342011-08-10 18:52:16 -07006887kobj_free:
6888 kobject_put(properties_kobj);
6889 properties_kobj = NULL;
6890reg_free:
6891 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
6892out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006893 return rc;
6894}
6895
6896static struct cy8c_ts_platform_data cy8ctma300_pdata = {
6897 .power_on = tma300_power,
6898 .dev_setup = tma300_dev_setup,
6899 .ts_name = "msm_tma300_ts",
6900 .dis_min_x = 0,
6901 .dis_max_x = 479,
6902 .dis_min_y = 0,
6903 .dis_max_y = 799,
6904 .res_x = 479,
6905 .res_y = 1009,
6906 .min_tid = 1,
6907 .max_tid = 255,
6908 .min_touch = 0,
6909 .max_touch = 255,
6910 .min_width = 0,
6911 .max_width = 255,
6912 .invert_y = 1,
6913 .nfingers = 4,
6914 .irq_gpio = TS_GPIO_IRQ,
6915 .resout_gpio = -1,
6916};
6917
6918static struct i2c_board_info cy8ctma300_board_info[] = {
6919 {
6920 I2C_BOARD_INFO("cy8ctma300", 0x2),
6921 .platform_data = &cy8ctma300_pdata,
6922 }
6923};
6924
Daniel Walker8d747cd2010-02-25 11:37:43 -08006925static void __init msm7x30_init(void)
6926{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006927 int rc;
6928 unsigned smem_size;
6929 uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56,
6930 0,
6931 GPIO_CFG_OUTPUT,
6932 GPIO_CFG_NO_PULL,
6933 GPIO_CFG_2MA);
6934 uint32_t soc_version = 0;
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05306935
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006936 soc_version = socinfo_get_version();
6937
Stephen Boydbb600ae2011-08-02 20:11:40 -07006938 msm_clock_init(&msm7x30_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006939#ifdef CONFIG_SERIAL_MSM_CONSOLE
6940 msm7x30_init_uart2();
6941#endif
6942 msm_spm_init(&msm_spm_data, 1);
Matt Wagantallec57f062011-08-16 23:54:46 -07006943 acpuclk_init(&acpuclk_7x30_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006944 if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid())
6945 msm7x30_cfg_smsc911x();
6946
6947#ifdef CONFIG_USB_MSM_OTG_72K
6948 if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 &&
6949 SOCINFO_VERSION_MINOR(soc_version) >= 1) {
6950 pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
6951 msm_otg_pdata.ldo_set_voltage = 0;
6952 }
6953
6954 msm_device_otg.dev.platform_data = &msm_otg_pdata;
6955#ifdef CONFIG_USB_GADGET
6956 msm_otg_pdata.swfi_latency =
6957 msm_pm_data
6958 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
6959 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
6960#endif
6961#endif
6962 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
6963 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
6964#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6965 msm_device_tsif.dev.platform_data = &tsif_platform_data;
6966#endif
6967 if (machine_is_msm7x30_fluid()) {
6968 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
6969 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
6970 } else {
6971 msm_adc_pdata.dev_names = msm_adc_surf_device_names;
6972 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names);
6973 }
6974
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306975 pmic8058_leds_init();
6976
6977 buses_init();
6978
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306979#ifdef CONFIG_MSM_SSBI
6980 msm_device_ssbi_pmic1.dev.platform_data =
6981 &msm7x30_ssbi_pm8058_pdata;
6982#endif
6983
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006984 platform_add_devices(msm_footswitch_devices,
6985 msm_num_footswitch_devices);
Daniel Walker8d747cd2010-02-25 11:37:43 -08006986 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006987#ifdef CONFIG_USB_EHCI_MSM_72K
6988 msm_add_host(0, &msm_usb_host_pdata);
6989#endif
Kiran Kumar H N305c53b2012-03-24 14:14:13 -07006990#ifdef CONFIG_MSM_CAMERA_V4L2
6991 msm7x30_init_cam();
6992#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006993 msm7x30_init_mmc();
6994 msm7x30_init_nand();
6995 msm_qsd_spi_init();
6996
6997#ifdef CONFIG_SPI_QSD
6998 if (machine_is_msm7x30_fluid())
6999 spi_register_board_info(lcdc_sharp_spi_board_info,
7000 ARRAY_SIZE(lcdc_sharp_spi_board_info));
7001 else
7002 spi_register_board_info(lcdc_toshiba_spi_board_info,
7003 ARRAY_SIZE(lcdc_toshiba_spi_board_info));
7004#endif
7005
Justin Paupore3f40f342011-08-10 18:52:16 -07007006 atv_dac_power_init();
7007 sensors_ldo_init();
7008 hdmi_init_regs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007009 msm_fb_add_devices();
7010 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06007011 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05307012 msm_pm_register_irqs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007013 msm_device_i2c_init();
7014 msm_device_i2c_2_init();
7015 qup_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007016 msm7x30_init_marimba();
7017#ifdef CONFIG_MSM7KV2_AUDIO
7018 snddev_poweramp_gpio_init();
Justin Paupore3f40f342011-08-10 18:52:16 -07007019 snddev_hsed_voltage_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007020 aux_pcm_gpio_init();
7021#endif
7022
7023 i2c_register_board_info(0, msm_i2c_board_info,
7024 ARRAY_SIZE(msm_i2c_board_info));
7025
7026 if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid())
7027 marimba_pdata.tsadc = &marimba_tsadc_pdata;
7028
7029 if (machine_is_msm7x30_fluid())
7030 i2c_register_board_info(0, cy8info,
7031 ARRAY_SIZE(cy8info));
7032#ifdef CONFIG_BOSCH_BMA150
7033 if (machine_is_msm7x30_fluid())
7034 i2c_register_board_info(0, bma150_board_info,
7035 ARRAY_SIZE(bma150_board_info));
7036#endif
7037
7038 i2c_register_board_info(2, msm_marimba_board_info,
7039 ARRAY_SIZE(msm_marimba_board_info));
7040
7041 i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info,
7042 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info));
7043
7044 i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
7045 ARRAY_SIZE(msm_camera_boardinfo));
7046
7047 bt_power_init();
7048#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007049 msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
7050#endif
7051 if (machine_is_msm7x30_fluid())
7052 i2c_register_board_info(0, msm_isa1200_board_info,
7053 ARRAY_SIZE(msm_isa1200_board_info));
7054
7055#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
7056 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
7057 if (machine_is_msm8x55_svlte_ffa())
7058 i2c_register_board_info(2, tsc_i2c_board_info,
7059 ARRAY_SIZE(tsc_i2c_board_info));
7060#endif
7061
7062 if (machine_is_msm7x30_surf())
7063 platform_device_register(&flip_switch_device);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05307064
7065 pm8058_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007066
7067 if (machine_is_msm7x30_fluid()) {
7068 /* Initialize platform data for fluid v2 hardware */
7069 if (SOCINFO_VERSION_MAJOR(
7070 socinfo_get_platform_version()) == 2) {
7071 cy8ctma300_pdata.res_y = 920;
7072 cy8ctma300_pdata.invert_y = 0;
7073 }
7074 i2c_register_board_info(0, cy8ctma300_board_info,
7075 ARRAY_SIZE(cy8ctma300_board_info));
7076 }
7077
7078 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
7079 rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE);
7080 if (rc)
7081 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
7082 __func__, usb_hub_gpio_cfg_value, rc);
7083 }
7084
7085 boot_reason = *(unsigned int *)
7086 (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
7087 printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
7088}
7089
7090static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
7091static int __init pmem_sf_size_setup(char *p)
7092{
7093 pmem_sf_size = memparse(p, NULL);
7094 return 0;
7095}
7096early_param("pmem_sf_size", pmem_sf_size_setup);
7097
7098static unsigned fb_size = MSM_FB_SIZE;
7099static int __init fb_size_setup(char *p)
7100{
7101 fb_size = memparse(p, NULL);
7102 return 0;
7103}
7104early_param("fb_size", fb_size_setup);
7105
7106static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
7107static int __init pmem_adsp_size_setup(char *p)
7108{
7109 pmem_adsp_size = memparse(p, NULL);
7110 return 0;
7111}
7112early_param("pmem_adsp_size", pmem_adsp_size_setup);
7113
7114static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE;
7115static int __init fluid_pmem_adsp_size_setup(char *p)
7116{
7117 fluid_pmem_adsp_size = memparse(p, NULL);
7118 return 0;
7119}
7120early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup);
7121
7122static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
7123static int __init pmem_audio_size_setup(char *p)
7124{
7125 pmem_audio_size = memparse(p, NULL);
7126 return 0;
7127}
7128early_param("pmem_audio_size", pmem_audio_size_setup);
7129
7130static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE;
7131static int __init pmem_kernel_ebi0_size_setup(char *p)
7132{
7133 pmem_kernel_ebi0_size = memparse(p, NULL);
7134 return 0;
7135}
7136early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
7137
7138static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
7139 [MEMTYPE_SMI] = {
7140 },
7141 [MEMTYPE_EBI0] = {
7142 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7143 },
7144 [MEMTYPE_EBI1] = {
7145 .flags = MEMTYPE_FLAGS_1M_ALIGN,
7146 },
7147};
7148
7149static void __init size_pmem_devices(void)
7150{
7151#ifdef CONFIG_ANDROID_PMEM
7152 unsigned long size;
7153
7154 if machine_is_msm7x30_fluid()
7155 size = fluid_pmem_adsp_size;
7156 else
7157 size = pmem_adsp_size;
7158 android_pmem_adsp_pdata.size = size;
7159 android_pmem_audio_pdata.size = pmem_audio_size;
7160 android_pmem_pdata.size = pmem_sf_size;
7161#endif
7162}
7163
7164static void __init reserve_memory_for(struct android_pmem_platform_data *p)
7165{
7166 msm7x30_reserve_table[p->memory_type].size += p->size;
7167}
7168
7169static void __init reserve_pmem_memory(void)
7170{
7171#ifdef CONFIG_ANDROID_PMEM
7172 reserve_memory_for(&android_pmem_adsp_pdata);
7173 reserve_memory_for(&android_pmem_audio_pdata);
7174 reserve_memory_for(&android_pmem_pdata);
7175 msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
7176#endif
7177}
7178
7179static void __init msm7x30_calculate_reserve_sizes(void)
7180{
7181 size_pmem_devices();
7182 reserve_pmem_memory();
7183}
7184
7185static int msm7x30_paddr_to_memtype(unsigned int paddr)
7186{
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307187 if (paddr < phys_add)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007188 return MEMTYPE_EBI0;
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307189 if (paddr >= phys_add && paddr < 0x80000000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007190 return MEMTYPE_EBI1;
7191 return MEMTYPE_NONE;
7192}
7193
7194static struct reserve_info msm7x30_reserve_info __initdata = {
7195 .memtype_reserve_table = msm7x30_reserve_table,
7196 .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes,
7197 .paddr_to_memtype = msm7x30_paddr_to_memtype,
7198};
7199
7200static void __init msm7x30_reserve(void)
7201{
7202 reserve_info = &msm7x30_reserve_info;
7203 msm_reserve();
7204}
7205
7206static void __init msm7x30_allocate_memory_regions(void)
7207{
7208 void *addr;
7209 unsigned long size;
7210
7211 size = fb_size ? : MSM_FB_SIZE;
7212 addr = alloc_bootmem_align(size, 0x1000);
7213 msm_fb_resources[0].start = __pa(addr);
7214 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
7215 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
7216 size, addr, __pa(addr));
Alhad Purnapatrec55856c2012-02-28 13:24:57 -08007217
7218#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
7219 size = MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE;
7220 addr = alloc_bootmem_align(size, 0x1000);
7221 msm_v4l2_video_overlay_resources[0].start = __pa(addr);
7222 msm_v4l2_video_overlay_resources[0].end =
7223 msm_v4l2_video_overlay_resources[0].start + size - 1;
7224 pr_debug("allocating %lu bytes at %p (%lx physical) for v4l2\n",
7225 size, addr, __pa(addr));
7226#endif
Daniel Walker8d747cd2010-02-25 11:37:43 -08007227}
7228
7229static void __init msm7x30_map_io(void)
7230{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007231 msm_shared_ram_phys = 0x00100000;
Daniel Walker8d747cd2010-02-25 11:37:43 -08007232 msm_map_msm7x30_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007233 if (socinfo_init() < 0)
7234 printk(KERN_ERR "%s: socinfo_init() failed!\n",
7235 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007236}
7237
7238static void __init msm7x30_init_early(void)
7239{
7240 msm7x30_allocate_memory_regions();
Daniel Walker8d747cd2010-02-25 11:37:43 -08007241}
7242
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307243static void __init msm7x30_fixup(struct machine_desc *desc, struct tag *tags,
7244 char **cmdline, struct meminfo *mi)
7245{
7246 for (; tags->hdr.size; tags = tag_next(tags)) {
7247 if (tags->hdr.tag == ATAG_MEM && tags->u.mem.start ==
7248 DDR1_BANK_BASE) {
7249 ebi1_phys_offset = DDR1_BANK_BASE;
7250 phys_add = DDR1_BANK_BASE;
7251 break;
7252 }
7253 }
7254}
7255
Daniel Walker8d747cd2010-02-25 11:37:43 -08007256MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00007257 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007258 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007259 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007260 .init_irq = msm7x30_init_irq,
7261 .init_machine = msm7x30_init,
7262 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007263 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307264 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307265 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007266MACHINE_END
7267
7268MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00007269 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007270 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007271 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007272 .init_irq = msm7x30_init_irq,
7273 .init_machine = msm7x30_init,
7274 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007275 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307276 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307277 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007278MACHINE_END
7279
7280MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
Russell Kingb75c1782011-01-04 19:03:16 +00007281 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007282 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007283 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007284 .init_irq = msm7x30_init_irq,
7285 .init_machine = msm7x30_init,
7286 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007287 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307288 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307289 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007290MACHINE_END
7291
7292MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
7293 .boot_params = PHYS_OFFSET + 0x100,
7294 .map_io = msm7x30_map_io,
7295 .reserve = msm7x30_reserve,
7296 .init_irq = msm7x30_init_irq,
7297 .init_machine = msm7x30_init,
7298 .timer = &msm_timer,
7299 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307300 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307301 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007302MACHINE_END
7303
7304MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA")
7305 .boot_params = PHYS_OFFSET + 0x100,
7306 .map_io = msm7x30_map_io,
7307 .reserve = msm7x30_reserve,
7308 .init_irq = msm7x30_init_irq,
7309 .init_machine = msm7x30_init,
7310 .timer = &msm_timer,
7311 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307312 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307313 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007314MACHINE_END
7315MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
7316 .boot_params = PHYS_OFFSET + 0x100,
7317 .map_io = msm7x30_map_io,
7318 .reserve = msm7x30_reserve,
7319 .init_irq = msm7x30_init_irq,
7320 .init_machine = msm7x30_init,
7321 .timer = &msm_timer,
7322 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307323 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307324 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007325MACHINE_END
7326MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE 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,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007336MACHINE_END