blob: 0dbf555fab415c7152359bf6c2624a91525bf632 [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
102#define MSM_PMEM_ADSP_SIZE 0x1E00000
103#define MSM_FLUID_PMEM_ADSP_SIZE 0x2800000
104#define PMEM_KERNEL_EBI0_SIZE 0x600000
105#define MSM_PMEM_AUDIO_SIZE 0x200000
Daniel Walker90e37c52010-05-12 14:24:15 -0700106
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700107#define PMIC_GPIO_INT 27
108#define PMIC_VREG_WLAN_LEVEL 2900
109#define PMIC_GPIO_SD_DET 36
110#define PMIC_GPIO_SDC4_EN_N 17 /* PMIC GPIO Number 18 */
111#define PMIC_GPIO_HDMI_5V_EN_V3 32 /* PMIC GPIO for V3 H/W */
112#define PMIC_GPIO_HDMI_5V_EN_V2 39 /* PMIC GPIO for V2 H/W */
113
114#define ADV7520_I2C_ADDR 0x39
115
116#define FPGA_SDCC_STATUS 0x8E0001A8
117
118#define FPGA_OPTNAV_GPIO_ADDR 0x8E000026
119#define OPTNAV_I2C_SLAVE_ADDR (0xB0 >> 1)
120#define OPTNAV_IRQ 20
121#define OPTNAV_CHIP_SELECT 19
Asutosh Das853bbcd2012-02-01 10:40:05 +0530122#define PMIC_GPIO_SDC4_PWR_EN_N 24 /* PMIC GPIO Number 25 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700123
124/* Macros assume PMIC GPIOs start at 0 */
125#define PM8058_GPIO_PM_TO_SYS(pm_gpio) (pm_gpio + NR_GPIO_IRQS)
126#define PM8058_GPIO_SYS_TO_PM(sys_gpio) (sys_gpio - NR_GPIO_IRQS)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530127#define PM8058_MPP_BASE PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS)
128#define PM8058_MPP_PM_TO_SYS(pm_gpio) (pm_gpio + PM8058_MPP_BASE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700129
130#define PMIC_GPIO_FLASH_BOOST_ENABLE 15 /* PMIC GPIO Number 16 */
131#define PMIC_GPIO_HAP_ENABLE 16 /* PMIC GPIO Number 17 */
132
133#define PMIC_GPIO_WLAN_EXT_POR 22 /* PMIC GPIO NUMBER 23 */
134
135#define BMA150_GPIO_INT 1
136
137#define HAP_LVL_SHFT_MSM_GPIO 24
138
139#define PMIC_GPIO_QUICKVX_CLK 37 /* PMIC GPIO 38 */
140
141#define PM_FLIP_MPP 5 /* PMIC MPP 06 */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530142
Pankaj Kumarac69ee62012-01-26 00:21:56 +0530143#define DDR1_BANK_BASE 0X20000000
144#define DDR2_BANK_BASE 0X40000000
145
146static unsigned int phys_add = DDR2_BANK_BASE;
147unsigned long ebi1_phys_offset = DDR2_BANK_BASE;
148EXPORT_SYMBOL(ebi1_phys_offset);
149
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530150struct pm8xxx_gpio_init_info {
151 unsigned gpio;
152 struct pm_gpio config;
153};
154
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700155static int pm8058_gpios_init(void)
156{
157 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700158
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530159 struct pm8xxx_gpio_init_info sdc4_en = {
160 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_EN_N),
161 {
162 .direction = PM_GPIO_DIR_OUT,
163 .pull = PM_GPIO_PULL_NO,
164 .vin_sel = PM8058_GPIO_VIN_L5,
165 .function = PM_GPIO_FUNC_NORMAL,
166 .inv_int_pol = 0,
167 .out_strength = PM_GPIO_STRENGTH_LOW,
168 .output_value = 0,
169 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700170 };
171
Asutosh Das853bbcd2012-02-01 10:40:05 +0530172 struct pm8xxx_gpio_init_info sdc4_pwr_en = {
173 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
174 {
175 .direction = PM_GPIO_DIR_OUT,
176 .pull = PM_GPIO_PULL_NO,
177 .vin_sel = PM8058_GPIO_VIN_L5,
178 .function = PM_GPIO_FUNC_NORMAL,
179 .inv_int_pol = 0,
180 .out_strength = PM_GPIO_STRENGTH_LOW,
181 .output_value = 0,
182 },
183 };
184
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530185 struct pm8xxx_gpio_init_info haptics_enable = {
186 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
187 {
188 .direction = PM_GPIO_DIR_OUT,
189 .pull = PM_GPIO_PULL_NO,
190 .out_strength = PM_GPIO_STRENGTH_HIGH,
191 .function = PM_GPIO_FUNC_NORMAL,
192 .inv_int_pol = 0,
193 .vin_sel = 2,
194 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
195 .output_value = 0,
196 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700197 };
198
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530199 struct pm8xxx_gpio_init_info hdmi_5V_en = {
200 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HDMI_5V_EN_V3),
201 {
202 .direction = PM_GPIO_DIR_OUT,
203 .pull = PM_GPIO_PULL_NO,
204 .vin_sel = PM8058_GPIO_VIN_VPH,
205 .function = PM_GPIO_FUNC_NORMAL,
206 .out_strength = PM_GPIO_STRENGTH_LOW,
207 .output_value = 0,
208 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700209 };
210
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530211 struct pm8xxx_gpio_init_info flash_boost_enable = {
212 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE),
213 {
214 .direction = PM_GPIO_DIR_OUT,
215 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
216 .output_value = 0,
217 .pull = PM_GPIO_PULL_NO,
218 .vin_sel = PM8058_GPIO_VIN_S3,
219 .out_strength = PM_GPIO_STRENGTH_HIGH,
220 .function = PM_GPIO_FUNC_2,
221 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700222 };
223
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530224 struct pm8xxx_gpio_init_info gpio23 = {
225 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_WLAN_EXT_POR),
226 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700227 .direction = PM_GPIO_DIR_OUT,
228 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
229 .output_value = 0,
230 .pull = PM_GPIO_PULL_NO,
231 .vin_sel = 2,
232 .out_strength = PM_GPIO_STRENGTH_LOW,
233 .function = PM_GPIO_FUNC_NORMAL,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530234 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700235 };
236
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700237#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530238 struct pm8xxx_gpio_init_info sdcc_det = {
239 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1),
240 {
241 .direction = PM_GPIO_DIR_IN,
242 .pull = PM_GPIO_PULL_UP_1P5,
243 .vin_sel = 2,
244 .function = PM_GPIO_FUNC_NORMAL,
245 .inv_int_pol = 0,
246 },
247 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700248
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530249 if (machine_is_msm7x30_fluid())
250 sdcc_det.config.inv_int_pol = 1;
251
252 rc = pm8xxx_gpio_config(sdcc_det.gpio, &sdcc_det.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700253 if (rc) {
254 pr_err("%s PMIC_GPIO_SD_DET config failed\n", __func__);
255 return rc;
256 }
257#endif
258
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530259 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
260 machine_is_msm7x30_fluid())
261 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V2;
262 else
263 hdmi_5V_en.gpio = PMIC_GPIO_HDMI_5V_EN_V3;
264
265 hdmi_5V_en.gpio = PM8058_GPIO_PM_TO_SYS(hdmi_5V_en.gpio);
266
267 rc = pm8xxx_gpio_config(hdmi_5V_en.gpio, &hdmi_5V_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700268 if (rc) {
269 pr_err("%s PMIC_GPIO_HDMI_5V_EN config failed\n", __func__);
270 return rc;
271 }
272
273 /* Deassert GPIO#23 (source for Ext_POR on WLAN-Volans) */
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530274 rc = pm8xxx_gpio_config(gpio23.gpio, &gpio23.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700275 if (rc) {
276 pr_err("%s PMIC_GPIO_WLAN_EXT_POR config failed\n", __func__);
277 return rc;
278 }
279
280 if (machine_is_msm7x30_fluid()) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530281 /* Haptics gpio */
282 rc = pm8xxx_gpio_config(haptics_enable.gpio,
283 &haptics_enable.config);
284 if (rc) {
285 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
286 haptics_enable.gpio);
287 return rc;
288 }
289 /* Flash boost gpio */
290 rc = pm8xxx_gpio_config(flash_boost_enable.gpio,
291 &flash_boost_enable.config);
292 if (rc) {
293 pr_err("%s: PMIC GPIO %d write failed\n", __func__,
294 flash_boost_enable.gpio);
295 return rc;
296 }
297 /* SCD4 gpio */
298 rc = pm8xxx_gpio_config(sdc4_en.gpio, &sdc4_en.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700299 if (rc) {
300 pr_err("%s PMIC_GPIO_SDC4_EN_N config failed\n",
301 __func__);
302 return rc;
303 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530304 rc = gpio_request(sdc4_en.gpio, "sdc4_en");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700305 if (rc) {
306 pr_err("%s PMIC_GPIO_SDC4_EN_N gpio_request failed\n",
307 __func__);
308 return rc;
309 }
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530310 gpio_set_value_cansleep(sdc4_en.gpio, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700311 }
Asutosh Das853bbcd2012-02-01 10:40:05 +0530312 /* FFA -> gpio_25 controls vdd of sdcc4 */
313 else {
314 /* SCD4 gpio_25 */
315 rc = pm8xxx_gpio_config(sdc4_pwr_en.gpio, &sdc4_pwr_en.config);
316 if (rc) {
317 pr_err("%s PMIC_GPIO_SDC4_PWR_EN_N config failed: %d\n",
318 __func__, rc);
319 return rc;
320 }
321
322 rc = gpio_request(sdc4_pwr_en.gpio, "sdc4_pwr_en");
323 if (rc) {
324 pr_err("PMIC_GPIO_SDC4_PWR_EN_N gpio_req failed: %d\n",
325 rc);
326 return rc;
327 }
328 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700329
330 return 0;
331}
332
Justin Paupore637a25d2011-07-14 17:11:04 -0700333/* Regulator API support */
334
335#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
336static struct platform_device msm_proccomm_regulator_dev = {
337 .name = PROCCOMM_REGULATOR_DEV_NAME,
338 .id = -1,
339 .dev = {
340 .platform_data = &msm7x30_proccomm_regulator_data
341 }
342};
343#endif
344
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700345/*virtual key support */
346static ssize_t tma300_vkeys_show(struct kobject *kobj,
347 struct kobj_attribute *attr, char *buf)
348{
349 return sprintf(buf,
350 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":50:842:80:100"
351 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":170:842:80:100"
352 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":290:842:80:100"
353 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":410:842:80:100"
354 "\n");
355}
356
357static struct kobj_attribute tma300_vkeys_attr = {
358 .attr = {
359 .mode = S_IRUGO,
360 },
361 .show = &tma300_vkeys_show,
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530362};
363
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700364static struct attribute *tma300_properties_attrs[] = {
365 &tma300_vkeys_attr.attr,
366 NULL
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +0530367};
368
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700369static struct attribute_group tma300_properties_attr_group = {
370 .attrs = tma300_properties_attrs,
371};
372
373static struct kobject *properties_kobj;
Justin Paupore3f40f342011-08-10 18:52:16 -0700374static struct regulator_bulk_data cyttsp_regs[] = {
375 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
376 { .supply = "ldo15", .min_uV = 3050000, .max_uV = 3100000 },
377};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700378
379#define CYTTSP_TS_GPIO_IRQ 150
380static int cyttsp_platform_init(struct i2c_client *client)
381{
382 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700383
Justin Paupore3f40f342011-08-10 18:52:16 -0700384 rc = regulator_bulk_get(NULL, ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700385
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700386 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700387 pr_err("%s: could not get regulators: %d\n", __func__, rc);
388 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700389 }
390
Justin Paupore3f40f342011-08-10 18:52:16 -0700391 rc = regulator_bulk_set_voltage(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
392
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700393 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700394 pr_err("%s: could not set regulator voltages: %d\n", __func__,
395 rc);
396 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700397 }
398
Justin Paupore3f40f342011-08-10 18:52:16 -0700399 rc = regulator_bulk_enable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700400
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700401 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -0700402 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
403 goto regs_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700404 }
405
406 /* check this device active by reading first byte/register */
407 rc = i2c_smbus_read_byte_data(client, 0x01);
408 if (rc < 0) {
409 pr_err("%s: i2c sanity check failed\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -0700410 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700411 }
412
413 rc = gpio_tlmm_config(GPIO_CFG(CYTTSP_TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
414 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
415 if (rc) {
416 pr_err("%s: Could not configure gpio %d\n",
417 __func__, CYTTSP_TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -0700418 goto regs_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700419 }
420
421 /* virtual keys */
422 tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
423 properties_kobj = kobject_create_and_add("board_properties",
424 NULL);
425 if (properties_kobj)
426 rc = sysfs_create_group(properties_kobj,
427 &tma300_properties_attr_group);
428 if (!properties_kobj || rc)
429 pr_err("%s: failed to create board_properties\n",
430 __func__);
431
432 return CY_OK;
433
Justin Paupore3f40f342011-08-10 18:52:16 -0700434regs_disable:
435 regulator_bulk_disable(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
436regs_free:
437 regulator_bulk_free(ARRAY_SIZE(cyttsp_regs), cyttsp_regs);
438out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700439 return rc;
440}
441
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530442/* TODO: Put the regulator to LPM / HPM in suspend/resume*/
443static int cyttsp_platform_suspend(struct i2c_client *client)
444{
445 msleep(20);
446
447 return CY_OK;
448}
449
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700450static int cyttsp_platform_resume(struct i2c_client *client)
451{
452 /* add any special code to strobe a wakeup pin or chip reset */
453 mdelay(10);
454
455 return CY_OK;
456}
457
458static struct cyttsp_platform_data cyttsp_data = {
459 .fw_fname = "cyttsp_7630_fluid.hex",
460 .panel_maxx = 479,
461 .panel_maxy = 799,
462 .disp_maxx = 469,
463 .disp_maxy = 799,
464 .disp_minx = 10,
465 .disp_miny = 0,
466 .flags = 0,
467 .gen = CY_GEN3, /* or */
468 .use_st = CY_USE_ST,
469 .use_mt = CY_USE_MT,
470 .use_hndshk = CY_SEND_HNDSHK,
471 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayal15187772011-06-22 17:39:41 +0530472 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700473 .use_gestures = CY_USE_GESTURES,
474 /* activate up to 4 groups
475 * and set active distance
476 */
477 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
478 CY_GEST_GRP3 | CY_GEST_GRP4 |
479 CY_ACT_DIST,
480 /* change act_intrvl to customize the Active power state
481 * scanning/processing refresh interval for Operating mode
482 */
483 .act_intrvl = CY_ACT_INTRVL_DFLT,
484 /* change tch_tmout to customize the touch timeout for the
485 * Active power state for Operating mode
486 */
487 .tch_tmout = CY_TCH_TMOUT_DFLT,
488 /* change lp_intrvl to customize the Low Power power state
489 * scanning/processing refresh interval for Operating mode
490 */
491 .lp_intrvl = CY_LP_INTRVL_DFLT,
492 .resume = cyttsp_platform_resume,
Anirudh Ghayalf9929b12011-09-07 15:57:36 +0530493 .suspend = cyttsp_platform_suspend,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700494 .init = cyttsp_platform_init,
495 .sleep_gpio = -1,
496 .resout_gpio = -1,
497 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
Mohan Pallaka49c37d62011-08-01 11:52:00 +0530498 .correct_fw_ver = 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700499};
500
501static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
502{
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530503 struct pm_gpio pwm_gpio_config = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700504 .direction = PM_GPIO_DIR_OUT,
505 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
506 .output_value = 0,
507 .pull = PM_GPIO_PULL_NO,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530508 .vin_sel = PM8058_GPIO_VIN_S3,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700509 .out_strength = PM_GPIO_STRENGTH_HIGH,
510 .function = PM_GPIO_FUNC_2,
511 };
512 int rc = -EINVAL;
513 int id, mode, max_mA;
514
515 id = mode = max_mA = 0;
516 switch (ch) {
517 case 0:
518 case 1:
519 case 2:
520 if (on) {
521 id = 24 + ch;
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530522 rc = pm8xxx_gpio_config(PM8058_GPIO_PM_TO_SYS(id - 1),
523 &pwm_gpio_config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700524 if (rc)
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530525 pr_err("%s: pm8xxx_gpio_config(%d): rc=%d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700526 __func__, id, rc);
527 }
528 break;
529
530 case 3:
531 id = PM_PWM_LED_KPD;
532 mode = PM_PWM_CONF_DTEST3;
533 max_mA = 200;
534 break;
535
536 case 4:
537 id = PM_PWM_LED_0;
538 mode = PM_PWM_CONF_PWM1;
539 max_mA = 40;
540 break;
541
542 case 5:
543 id = PM_PWM_LED_2;
544 mode = PM_PWM_CONF_PWM2;
545 max_mA = 40;
546 break;
547
548 case 6:
549 id = PM_PWM_LED_FLASH;
550 mode = PM_PWM_CONF_DTEST3;
551 max_mA = 200;
552 break;
553
554 default:
555 break;
556 }
557
558 if (ch >= 3 && ch <= 6) {
559 if (!on) {
560 mode = PM_PWM_CONF_NONE;
561 max_mA = 0;
562 }
563 rc = pm8058_pwm_config_led(pwm, id, mode, max_mA);
564 if (rc)
565 pr_err("%s: pm8058_pwm_config_led(ch=%d): rc=%d\n",
566 __func__, ch, rc);
567 }
568
569 return rc;
570}
571
572static int pm8058_pwm_enable(struct pwm_device *pwm, int ch, int on)
573{
574 int rc;
575
576 switch (ch) {
577 case 7:
578 rc = pm8058_pwm_set_dtest(pwm, on);
579 if (rc)
580 pr_err("%s: pwm_set_dtest(%d): rc=%d\n",
581 __func__, on, rc);
582 break;
583 default:
584 rc = -EINVAL;
585 break;
586 }
587 return rc;
588}
589
590static const unsigned int fluid_keymap[] = {
591 KEY(0, 0, KEY_7),
592 KEY(0, 1, KEY_ENTER),
593 KEY(0, 2, KEY_UP),
594 /* drop (0,3) as it always shows up in pair with(0,2) */
595 KEY(0, 4, KEY_DOWN),
596
597 KEY(1, 0, KEY_CAMERA_SNAPSHOT),
598 KEY(1, 1, KEY_SELECT),
599 KEY(1, 2, KEY_1),
600 KEY(1, 3, KEY_VOLUMEUP),
601 KEY(1, 4, KEY_VOLUMEDOWN),
602};
603
604static const unsigned int surf_keymap[] = {
605 KEY(0, 0, KEY_7),
606 KEY(0, 1, KEY_DOWN),
607 KEY(0, 2, KEY_UP),
608 KEY(0, 3, KEY_RIGHT),
609 KEY(0, 4, KEY_ENTER),
610 KEY(0, 5, KEY_L),
611 KEY(0, 6, KEY_BACK),
612 KEY(0, 7, KEY_M),
613
614 KEY(1, 0, KEY_LEFT),
615 KEY(1, 1, KEY_SEND),
616 KEY(1, 2, KEY_1),
617 KEY(1, 3, KEY_4),
618 KEY(1, 4, KEY_CLEAR),
619 KEY(1, 5, KEY_MSDOS),
620 KEY(1, 6, KEY_SPACE),
621 KEY(1, 7, KEY_COMMA),
622
623 KEY(2, 0, KEY_6),
624 KEY(2, 1, KEY_5),
625 KEY(2, 2, KEY_8),
626 KEY(2, 3, KEY_3),
627 KEY(2, 4, KEY_NUMERIC_STAR),
628 KEY(2, 5, KEY_UP),
629 KEY(2, 6, KEY_DOWN), /* SYN */
630 KEY(2, 7, KEY_LEFTSHIFT),
631
632 KEY(3, 0, KEY_9),
633 KEY(3, 1, KEY_NUMERIC_POUND),
634 KEY(3, 2, KEY_0),
635 KEY(3, 3, KEY_2),
636 KEY(3, 4, KEY_SLEEP),
637 KEY(3, 5, KEY_F1),
638 KEY(3, 6, KEY_F2),
639 KEY(3, 7, KEY_F3),
640
641 KEY(4, 0, KEY_BACK),
642 KEY(4, 1, KEY_HOME),
643 KEY(4, 2, KEY_MENU),
644 KEY(4, 3, KEY_VOLUMEUP),
645 KEY(4, 4, KEY_VOLUMEDOWN),
646 KEY(4, 5, KEY_F4),
647 KEY(4, 6, KEY_F5),
648 KEY(4, 7, KEY_F6),
649
650 KEY(5, 0, KEY_R),
651 KEY(5, 1, KEY_T),
652 KEY(5, 2, KEY_Y),
653 KEY(5, 3, KEY_LEFTALT),
654 KEY(5, 4, KEY_KPENTER),
655 KEY(5, 5, KEY_Q),
656 KEY(5, 6, KEY_W),
657 KEY(5, 7, KEY_E),
658
659 KEY(6, 0, KEY_F),
660 KEY(6, 1, KEY_G),
661 KEY(6, 2, KEY_H),
662 KEY(6, 3, KEY_CAPSLOCK),
663 KEY(6, 4, KEY_PAGEUP),
664 KEY(6, 5, KEY_A),
665 KEY(6, 6, KEY_S),
666 KEY(6, 7, KEY_D),
667
668 KEY(7, 0, KEY_V),
669 KEY(7, 1, KEY_B),
670 KEY(7, 2, KEY_N),
671 KEY(7, 3, KEY_MENU), /* REVISIT - SYM */
672 KEY(7, 4, KEY_PAGEDOWN),
673 KEY(7, 5, KEY_Z),
674 KEY(7, 6, KEY_X),
675 KEY(7, 7, KEY_C),
676
677 KEY(8, 0, KEY_P),
678 KEY(8, 1, KEY_J),
679 KEY(8, 2, KEY_K),
680 KEY(8, 3, KEY_INSERT),
681 KEY(8, 4, KEY_LINEFEED),
682 KEY(8, 5, KEY_U),
683 KEY(8, 6, KEY_I),
684 KEY(8, 7, KEY_O),
685
686 KEY(9, 0, KEY_4),
687 KEY(9, 1, KEY_5),
688 KEY(9, 2, KEY_6),
689 KEY(9, 3, KEY_7),
690 KEY(9, 4, KEY_8),
691 KEY(9, 5, KEY_1),
692 KEY(9, 6, KEY_2),
693 KEY(9, 7, KEY_3),
694
695 KEY(10, 0, KEY_F7),
696 KEY(10, 1, KEY_F8),
697 KEY(10, 2, KEY_F9),
698 KEY(10, 3, KEY_F10),
699 KEY(10, 4, KEY_FN),
700 KEY(10, 5, KEY_9),
701 KEY(10, 6, KEY_0),
702 KEY(10, 7, KEY_DOT),
703
704 KEY(11, 0, KEY_LEFTCTRL),
705 KEY(11, 1, KEY_F11), /* START */
706 KEY(11, 2, KEY_ENTER),
707 KEY(11, 3, KEY_SEARCH),
708 KEY(11, 4, KEY_DELETE),
709 KEY(11, 5, KEY_RIGHT),
710 KEY(11, 6, KEY_LEFT),
711 KEY(11, 7, KEY_RIGHTSHIFT),
712};
713
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700714static struct matrix_keymap_data surf_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530715 .keymap_size = ARRAY_SIZE(surf_keymap),
716 .keymap = surf_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700717};
718
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530719static struct pm8xxx_keypad_platform_data surf_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700720 .input_name = "surf_keypad",
721 .input_phys_device = "surf_keypad/input0",
722 .num_rows = 12,
723 .num_cols = 8,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530724 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
725 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
726 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700727 .scan_delay_ms = 32,
728 .row_hold_ns = 91500,
729 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530730 .keymap_data = &surf_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700731};
732
733static struct matrix_keymap_data fluid_keymap_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530734 .keymap_size = ARRAY_SIZE(fluid_keymap),
735 .keymap = fluid_keymap,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700736};
737
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530738static struct pm8xxx_keypad_platform_data fluid_keypad_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700739 .input_name = "fluid-keypad",
740 .input_phys_device = "fluid-keypad/input0",
741 .num_rows = 5,
742 .num_cols = 5,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530743 .rows_gpio_start = PM8058_GPIO_PM_TO_SYS(8),
744 .cols_gpio_start = PM8058_GPIO_PM_TO_SYS(0),
745 .debounce_ms = 15,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700746 .scan_delay_ms = 32,
747 .row_hold_ns = 91500,
748 .wakeup = 1,
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530749 .keymap_data = &fluid_keymap_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700750};
751
752static struct pm8058_pwm_pdata pm8058_pwm_data = {
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530753 .config = pm8058_pwm_config,
754 .enable = pm8058_pwm_enable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700755};
756
757static struct pmic8058_led pmic8058_ffa_leds[] = {
758 [0] = {
759 .name = "keyboard-backlight",
760 .max_brightness = 15,
761 .id = PMIC8058_ID_LED_KB_LIGHT,
Dima Zavinba5499e2011-01-10 11:00:30 -0800762 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700763};
764
765static struct pmic8058_leds_platform_data pm8058_ffa_leds_data = {
766 .num_leds = ARRAY_SIZE(pmic8058_ffa_leds),
767 .leds = pmic8058_ffa_leds,
768};
769
770static struct pmic8058_led pmic8058_surf_leds[] = {
771 [0] = {
772 .name = "keyboard-backlight",
773 .max_brightness = 15,
774 .id = PMIC8058_ID_LED_KB_LIGHT,
775 },
776 [1] = {
777 .name = "voice:red",
778 .max_brightness = 20,
779 .id = PMIC8058_ID_LED_0,
780 },
781 [2] = {
782 .name = "wlan:green",
783 .max_brightness = 20,
784 .id = PMIC8058_ID_LED_2,
785 },
786};
787
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700788static struct pmic8058_leds_platform_data pm8058_surf_leds_data = {
789 .num_leds = ARRAY_SIZE(pmic8058_surf_leds),
790 .leds = pmic8058_surf_leds,
791};
792
793static struct pmic8058_led pmic8058_fluid_leds[] = {
794 [0] = {
795 .name = "keyboard-backlight",
796 .max_brightness = 15,
797 .id = PMIC8058_ID_LED_KB_LIGHT,
798 },
799 [1] = {
800 .name = "flash:led_0",
801 .max_brightness = 15,
802 .id = PMIC8058_ID_FLASH_LED_0,
803 },
804 [2] = {
805 .name = "flash:led_1",
806 .max_brightness = 15,
807 .id = PMIC8058_ID_FLASH_LED_1,
808 },
809};
810
811static struct pmic8058_leds_platform_data pm8058_fluid_leds_data = {
812 .num_leds = ARRAY_SIZE(pmic8058_fluid_leds),
813 .leds = pmic8058_fluid_leds,
814};
815
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530816static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata = {
817 .irq_base = PMIC8058_IRQ_BASE,
818 .devirq = MSM_GPIO_TO_INT(PMIC_GPIO_INT),
819 .irq_trigger_flag = IRQF_TRIGGER_LOW,
820};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700821
Anirudh Ghayalc2019332011-11-12 06:29:10 +0530822static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata = {
823 .gpio_base = PM8058_GPIO_PM_TO_SYS(0),
824};
825
826static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata = {
827 .mpp_base = PM8058_MPP_PM_TO_SYS(0),
828};
829
830static struct pm8058_platform_data pm8058_7x30_data = {
831 .irq_pdata = &pm8xxx_irq_pdata,
832 .gpio_pdata = &pm8xxx_gpio_pdata,
833 .mpp_pdata = &pm8xxx_mpp_pdata,
834 .pwm_pdata = &pm8058_pwm_data,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700835};
836
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530837#ifdef CONFIG_MSM_SSBI
838static struct msm_ssbi_platform_data msm7x30_ssbi_pm8058_pdata = {
Kenneth Heitke48952912012-01-12 14:02:06 -0700839 .rsl_id = "D:PMIC_SSBI",
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +0530840 .controller_type = MSM_SBI_CTRL_SSBI2,
841 .slave = {
842 .name = "pm8058-core",
843 .platform_data = &pm8058_7x30_data,
844 },
845};
846#endif
847
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700848static struct i2c_board_info cy8info[] __initdata = {
849 {
850 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
851 .platform_data = &cyttsp_data,
852#ifndef CY_USE_TIMER
853 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
854#endif /* CY_USE_TIMER */
855 },
856};
857
858static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
859#ifdef CONFIG_MT9D112
860 {
861 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
Dima Zavinba5499e2011-01-10 11:00:30 -0800862 },
863#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700864#ifdef CONFIG_WEBCAM_OV9726
865 {
866 I2C_BOARD_INFO("ov9726", 0x10),
867 },
868#endif
869#ifdef CONFIG_S5K3E2FX
870 {
871 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
872 },
873#endif
874#ifdef CONFIG_MT9P012
875 {
876 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
877 },
878#endif
879#ifdef CONFIG_VX6953
880 {
881 I2C_BOARD_INFO("vx6953", 0x20),
882 },
883#endif
884#ifdef CONFIG_MT9E013
885 {
886 I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
887 },
888#endif
889#ifdef CONFIG_SN12M0PZ
890 {
891 I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1),
892 },
893#endif
894#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
895 {
896 I2C_BOARD_INFO("mt9t013", 0x6C),
897 },
898#endif
899
Dima Zavinba5499e2011-01-10 11:00:30 -0800900};
901
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700902#ifdef CONFIG_MSM_CAMERA
903#define CAM_STNDBY 143
904static uint32_t camera_off_vcm_gpio_table[] = {
905GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */
906};
907
908static uint32_t camera_off_gpio_table[] = {
909 /* parallel CAMERA interfaces */
910 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RST */
911 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
912 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
913 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
914 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
915 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
916 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
917 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
918 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
919 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
920 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
921 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
922 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
923 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
924 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
925};
926
927static uint32_t camera_on_vcm_gpio_table[] = {
928GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */
929};
930
931static uint32_t camera_on_gpio_table[] = {
932 /* parallel CAMERA interfaces */
933 GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RST */
934 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
935 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
936 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
937 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
938 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
939 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
940 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
941 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
942 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
943 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
944 GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
945 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
946 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
947 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
948};
949
950static uint32_t camera_off_gpio_fluid_table[] = {
951 /* FLUID: CAM_VGA_RST_N */
952 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
953 /* FLUID: CAMIF_STANDBY */
954 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
955};
956
957static uint32_t camera_on_gpio_fluid_table[] = {
958 /* FLUID: CAM_VGA_RST_N */
959 GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
960 /* FLUID: CAMIF_STANDBY */
961 GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
962};
963
964static void config_gpio_table(uint32_t *table, int len)
965{
966 int n, rc;
967 for (n = 0; n < len; n++) {
968 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
969 if (rc) {
970 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
971 __func__, table[n], rc);
972 break;
973 }
974 }
975}
976static int config_camera_on_gpios(void)
977{
978 config_gpio_table(camera_on_gpio_table,
979 ARRAY_SIZE(camera_on_gpio_table));
980
981 if (adie_get_detected_codec_type() != TIMPANI_ID)
982 /* GPIO1 is shared also used in Timpani RF card so
983 only configure it for non-Timpani RF card */
984 config_gpio_table(camera_on_vcm_gpio_table,
985 ARRAY_SIZE(camera_on_vcm_gpio_table));
986
987 if (machine_is_msm7x30_fluid()) {
988 config_gpio_table(camera_on_gpio_fluid_table,
989 ARRAY_SIZE(camera_on_gpio_fluid_table));
990 /* FLUID: turn on 5V booster */
991 gpio_set_value(
992 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 1);
993 /* FLUID: drive high to put secondary sensor to STANDBY */
994 gpio_set_value(CAM_STNDBY, 1);
995 }
996 return 0;
997}
998
999static void config_camera_off_gpios(void)
1000{
1001 config_gpio_table(camera_off_gpio_table,
1002 ARRAY_SIZE(camera_off_gpio_table));
1003
1004 if (adie_get_detected_codec_type() != TIMPANI_ID)
1005 /* GPIO1 is shared also used in Timpani RF card so
1006 only configure it for non-Timpani RF card */
1007 config_gpio_table(camera_off_vcm_gpio_table,
1008 ARRAY_SIZE(camera_off_vcm_gpio_table));
1009
1010 if (machine_is_msm7x30_fluid()) {
1011 config_gpio_table(camera_off_gpio_fluid_table,
1012 ARRAY_SIZE(camera_off_gpio_fluid_table));
1013 /* FLUID: turn off 5V booster */
1014 gpio_set_value(
1015 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_FLASH_BOOST_ENABLE), 0);
1016 }
1017}
1018
1019struct resource msm_camera_resources[] = {
1020 {
1021 .start = 0xA6000000,
1022 .end = 0xA6000000 + SZ_1M - 1,
1023 .flags = IORESOURCE_MEM,
1024 },
1025 {
1026 .start = INT_VFE,
1027 .end = INT_VFE,
1028 .flags = IORESOURCE_IRQ,
1029 },
1030 {
1031 .flags = IORESOURCE_DMA,
1032 }
1033};
1034
1035struct msm_camera_device_platform_data msm_camera_device_data = {
1036 .camera_gpio_on = config_camera_on_gpios,
1037 .camera_gpio_off = config_camera_off_gpios,
1038 .ioext.camifpadphy = 0xAB000000,
1039 .ioext.camifpadsz = 0x00000400,
1040 .ioext.csiphy = 0xA6100000,
1041 .ioext.csisz = 0x00000400,
1042 .ioext.csiirq = INT_CSI,
1043 .ioclk.mclk_clk_rate = 24000000,
1044 .ioclk.vfe_clk_rate = 147456000,
1045};
1046
1047static struct msm_camera_sensor_flash_src msm_flash_src_pwm = {
1048 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PWM,
1049 ._fsrc.pwm_src.freq = 1000,
1050 ._fsrc.pwm_src.max_load = 300,
1051 ._fsrc.pwm_src.low_load = 30,
1052 ._fsrc.pwm_src.high_load = 100,
1053 ._fsrc.pwm_src.channel = 7,
1054};
1055
1056#ifdef CONFIG_MT9D112
1057static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1058 .flash_type = MSM_CAMERA_FLASH_LED,
1059 .flash_src = &msm_flash_src_pwm
1060};
1061
1062static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1063 .sensor_name = "mt9d112",
1064 .sensor_reset = 0,
1065 .sensor_pwd = 85,
1066 .vcm_pwd = 1,
1067 .vcm_enable = 0,
1068 .pdata = &msm_camera_device_data,
1069 .resource = msm_camera_resources,
1070 .num_resources = ARRAY_SIZE(msm_camera_resources),
1071 .flash_data = &flash_mt9d112,
1072 .csi_if = 0
1073};
1074
1075static struct platform_device msm_camera_sensor_mt9d112 = {
1076 .name = "msm_camera_mt9d112",
1077 .dev = {
1078 .platform_data = &msm_camera_sensor_mt9d112_data,
1079 },
1080};
1081#endif
1082
1083#ifdef CONFIG_WEBCAM_OV9726
1084
1085static struct msm_camera_sensor_platform_info ov9726_sensor_7630_info = {
1086 .mount_angle = 90
1087};
1088
1089static struct msm_camera_sensor_flash_data flash_ov9726 = {
1090 .flash_type = MSM_CAMERA_FLASH_LED,
1091 .flash_src = &msm_flash_src_pwm
1092};
1093static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = {
1094 .sensor_name = "ov9726",
1095 .sensor_reset = 0,
1096 .sensor_pwd = 85,
1097 .vcm_pwd = 1,
1098 .vcm_enable = 0,
1099 .pdata = &msm_camera_device_data,
1100 .resource = msm_camera_resources,
1101 .num_resources = ARRAY_SIZE(msm_camera_resources),
1102 .flash_data = &flash_ov9726,
1103 .sensor_platform_info = &ov9726_sensor_7630_info,
1104 .csi_if = 1
1105};
1106struct platform_device msm_camera_sensor_ov9726 = {
1107 .name = "msm_camera_ov9726",
1108 .dev = {
1109 .platform_data = &msm_camera_sensor_ov9726_data,
1110 },
1111};
1112#endif
1113
1114#ifdef CONFIG_S5K3E2FX
1115static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1116 .flash_type = MSM_CAMERA_FLASH_LED,
1117 .flash_src = &msm_flash_src_pwm,
1118};
1119
1120static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1121 .sensor_name = "s5k3e2fx",
1122 .sensor_reset = 0,
1123 .sensor_pwd = 85,
1124 .vcm_pwd = 1,
1125 .vcm_enable = 0,
1126 .pdata = &msm_camera_device_data,
1127 .resource = msm_camera_resources,
1128 .num_resources = ARRAY_SIZE(msm_camera_resources),
1129 .flash_data = &flash_s5k3e2fx,
1130 .csi_if = 0
1131};
1132
1133static struct platform_device msm_camera_sensor_s5k3e2fx = {
1134 .name = "msm_camera_s5k3e2fx",
1135 .dev = {
1136 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1137 },
1138};
1139#endif
1140
1141#ifdef CONFIG_MT9P012
1142static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1143 .flash_type = MSM_CAMERA_FLASH_LED,
1144 .flash_src = &msm_flash_src_pwm
1145};
1146
1147static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1148 .sensor_name = "mt9p012",
1149 .sensor_reset = 0,
1150 .sensor_pwd = 85,
1151 .vcm_pwd = 1,
1152 .vcm_enable = 1,
1153 .pdata = &msm_camera_device_data,
1154 .resource = msm_camera_resources,
1155 .num_resources = ARRAY_SIZE(msm_camera_resources),
1156 .flash_data = &flash_mt9p012,
1157 .csi_if = 0
1158};
1159
1160static struct platform_device msm_camera_sensor_mt9p012 = {
1161 .name = "msm_camera_mt9p012",
1162 .dev = {
1163 .platform_data = &msm_camera_sensor_mt9p012_data,
1164 },
1165};
1166#endif
1167
1168#ifdef CONFIG_MT9E013
1169static struct msm_camera_sensor_platform_info mt9e013_sensor_7630_info = {
1170 .mount_angle = 0
1171};
1172
1173static struct msm_camera_sensor_flash_data flash_mt9e013 = {
1174 .flash_type = MSM_CAMERA_FLASH_LED,
1175 .flash_src = &msm_flash_src_pwm
1176};
1177
1178static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = {
1179 .sensor_name = "mt9e013",
1180 .sensor_reset = 0,
1181 .sensor_pwd = 85,
1182 .vcm_pwd = 1,
1183 .vcm_enable = 1,
1184 .pdata = &msm_camera_device_data,
1185 .resource = msm_camera_resources,
1186 .num_resources = ARRAY_SIZE(msm_camera_resources),
1187 .flash_data = &flash_mt9e013,
1188 .sensor_platform_info = &mt9e013_sensor_7630_info,
1189 .csi_if = 1
1190};
1191
1192static struct platform_device msm_camera_sensor_mt9e013 = {
1193 .name = "msm_camera_mt9e013",
1194 .dev = {
1195 .platform_data = &msm_camera_sensor_mt9e013_data,
1196 },
1197};
1198#endif
1199
1200#ifdef CONFIG_VX6953
Jilai Wang971f97f2011-07-13 14:25:25 -04001201static struct msm_camera_sensor_platform_info vx6953_sensor_7630_info = {
1202 .mount_angle = 0
1203};
1204
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001205static struct msm_camera_sensor_flash_data flash_vx6953 = {
1206 .flash_type = MSM_CAMERA_FLASH_LED,
1207 .flash_src = &msm_flash_src_pwm
1208};
1209static struct msm_camera_sensor_info msm_camera_sensor_vx6953_data = {
1210 .sensor_name = "vx6953",
1211 .sensor_reset = 0,
1212 .sensor_pwd = 85,
1213 .vcm_pwd = 1,
1214 .vcm_enable = 0,
1215 .pdata = &msm_camera_device_data,
1216 .resource = msm_camera_resources,
1217 .num_resources = ARRAY_SIZE(msm_camera_resources),
Jilai Wang971f97f2011-07-13 14:25:25 -04001218 .sensor_platform_info = &vx6953_sensor_7630_info,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001219 .flash_data = &flash_vx6953,
1220 .csi_if = 1
1221};
1222static struct platform_device msm_camera_sensor_vx6953 = {
1223 .name = "msm_camera_vx6953",
1224 .dev = {
1225 .platform_data = &msm_camera_sensor_vx6953_data,
1226 },
1227};
1228#endif
1229
1230#ifdef CONFIG_SN12M0PZ
1231static struct msm_camera_sensor_flash_src msm_flash_src_current_driver = {
1232 .flash_sr_type = MSM_CAMERA_FLASH_SRC_CURRENT_DRIVER,
1233 ._fsrc.current_driver_src.low_current = 210,
1234 ._fsrc.current_driver_src.high_current = 700,
1235 ._fsrc.current_driver_src.driver_channel = &pm8058_fluid_leds_data,
1236};
1237
1238static struct msm_camera_sensor_flash_data flash_sn12m0pz = {
1239 .flash_type = MSM_CAMERA_FLASH_LED,
1240 .flash_src = &msm_flash_src_current_driver
1241};
1242static struct msm_camera_sensor_info msm_camera_sensor_sn12m0pz_data = {
1243 .sensor_name = "sn12m0pz",
1244 .sensor_reset = 0,
1245 .sensor_pwd = 85,
1246 .vcm_pwd = 1,
1247 .vcm_enable = 1,
1248 .pdata = &msm_camera_device_data,
1249 .flash_data = &flash_sn12m0pz,
1250 .resource = msm_camera_resources,
1251 .num_resources = ARRAY_SIZE(msm_camera_resources),
1252 .csi_if = 0
1253};
1254
1255static struct platform_device msm_camera_sensor_sn12m0pz = {
1256 .name = "msm_camera_sn12m0pz",
1257 .dev = {
1258 .platform_data = &msm_camera_sensor_sn12m0pz_data,
1259 },
1260};
1261#endif
1262
1263#ifdef CONFIG_MT9T013
1264static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1265 .flash_type = MSM_CAMERA_FLASH_LED,
1266 .flash_src = &msm_flash_src_pwm
1267};
1268
1269static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1270 .sensor_name = "mt9t013",
1271 .sensor_reset = 0,
1272 .sensor_pwd = 85,
1273 .vcm_pwd = 1,
1274 .vcm_enable = 0,
1275 .pdata = &msm_camera_device_data,
1276 .resource = msm_camera_resources,
1277 .num_resources = ARRAY_SIZE(msm_camera_resources),
1278 .flash_data = &flash_mt9t013,
1279 .csi_if = 1
1280};
1281
1282static struct platform_device msm_camera_sensor_mt9t013 = {
1283 .name = "msm_camera_mt9t013",
1284 .dev = {
1285 .platform_data = &msm_camera_sensor_mt9t013_data,
1286 },
1287};
1288#endif
1289
1290#ifdef CONFIG_MSM_GEMINI
1291static struct resource msm_gemini_resources[] = {
1292 {
1293 .start = 0xA3A00000,
1294 .end = 0xA3A00000 + 0x0150 - 1,
1295 .flags = IORESOURCE_MEM,
1296 },
1297 {
1298 .start = INT_JPEG,
1299 .end = INT_JPEG,
1300 .flags = IORESOURCE_IRQ,
1301 },
1302};
1303
1304static struct platform_device msm_gemini_device = {
1305 .name = "msm_gemini",
1306 .resource = msm_gemini_resources,
1307 .num_resources = ARRAY_SIZE(msm_gemini_resources),
1308};
1309#endif
1310
1311#ifdef CONFIG_MSM_VPE
1312static struct resource msm_vpe_resources[] = {
1313 {
1314 .start = 0xAD200000,
1315 .end = 0xAD200000 + SZ_1M - 1,
1316 .flags = IORESOURCE_MEM,
1317 },
1318 {
1319 .start = INT_VPE,
1320 .end = INT_VPE,
1321 .flags = IORESOURCE_IRQ,
1322 },
1323};
1324
1325static struct platform_device msm_vpe_device = {
1326 .name = "msm_vpe",
1327 .id = 0,
1328 .num_resources = ARRAY_SIZE(msm_vpe_resources),
1329 .resource = msm_vpe_resources,
1330};
1331#endif
1332
1333#endif /*CONFIG_MSM_CAMERA*/
1334
1335#ifdef CONFIG_MSM7KV2_AUDIO
1336static uint32_t audio_pamp_gpio_config =
1337 GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1338
1339static uint32_t audio_fluid_icodec_tx_config =
1340 GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1341
1342static int __init snddev_poweramp_gpio_init(void)
1343{
1344 int rc;
1345
1346 pr_info("snddev_poweramp_gpio_init \n");
1347 rc = gpio_tlmm_config(audio_pamp_gpio_config, GPIO_CFG_ENABLE);
1348 if (rc) {
1349 printk(KERN_ERR
1350 "%s: gpio_tlmm_config(%#x)=%d\n",
1351 __func__, audio_pamp_gpio_config, rc);
1352 }
1353 return rc;
1354}
1355
1356void msm_snddev_tx_route_config(void)
1357{
1358 int rc;
1359
1360 pr_debug("%s()\n", __func__);
1361
1362 if (machine_is_msm7x30_fluid()) {
1363 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1364 GPIO_CFG_ENABLE);
1365 if (rc) {
1366 printk(KERN_ERR
1367 "%s: gpio_tlmm_config(%#x)=%d\n",
1368 __func__, audio_fluid_icodec_tx_config, rc);
1369 } else
1370 gpio_set_value(85, 0);
1371 }
1372}
1373
1374void msm_snddev_tx_route_deconfig(void)
1375{
1376 int rc;
1377
1378 pr_debug("%s()\n", __func__);
1379
1380 if (machine_is_msm7x30_fluid()) {
1381 rc = gpio_tlmm_config(audio_fluid_icodec_tx_config,
1382 GPIO_CFG_DISABLE);
1383 if (rc) {
1384 printk(KERN_ERR
1385 "%s: gpio_tlmm_config(%#x)=%d\n",
1386 __func__, audio_fluid_icodec_tx_config, rc);
1387 }
1388 }
1389}
1390
1391void msm_snddev_poweramp_on(void)
1392{
1393 gpio_set_value(82, 1); /* enable spkr poweramp */
1394 pr_info("%s: power on amplifier\n", __func__);
1395}
1396
1397void msm_snddev_poweramp_off(void)
1398{
1399 gpio_set_value(82, 0); /* disable spkr poweramp */
1400 pr_info("%s: power off amplifier\n", __func__);
1401}
1402
Justin Paupore3f40f342011-08-10 18:52:16 -07001403static struct regulator_bulk_data snddev_regs[] = {
1404 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
1405 { .supply = "ncp", .min_uV = 1800000, .max_uV = 1800000 },
1406};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001407
Justin Paupore3f40f342011-08-10 18:52:16 -07001408static int __init snddev_hsed_voltage_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001409{
1410 int rc;
1411
Justin Paupore3f40f342011-08-10 18:52:16 -07001412 rc = regulator_bulk_get(NULL, ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001413
Justin Paupore3f40f342011-08-10 18:52:16 -07001414 if (rc) {
1415 pr_err("%s: could not get regulators: %d\n", __func__, rc);
1416 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001417 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001418
1419 rc = regulator_bulk_set_voltage(ARRAY_SIZE(snddev_regs), snddev_regs);
1420
1421 if (rc) {
1422 pr_err("%s: could not set regulator voltages: %d\n",
1423 __func__, rc);
1424 goto regs_free;
1425 }
1426
1427 return 0;
1428
1429regs_free:
1430 regulator_bulk_free(ARRAY_SIZE(snddev_regs), snddev_regs);
1431out:
1432 return rc;
1433}
1434
1435
1436void msm_snddev_hsed_voltage_on(void)
1437{
1438 int rc = regulator_bulk_enable(ARRAY_SIZE(snddev_regs), snddev_regs);
1439
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001440 if (rc)
Justin Paupore3f40f342011-08-10 18:52:16 -07001441 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001442}
1443
1444void msm_snddev_hsed_voltage_off(void)
1445{
Justin Paupore3f40f342011-08-10 18:52:16 -07001446 int rc = regulator_bulk_disable(ARRAY_SIZE(snddev_regs), snddev_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001447
Justin Paupore3f40f342011-08-10 18:52:16 -07001448 if (rc) {
1449 pr_err("%s: could not disable regulators: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001450 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001451}
1452
1453static unsigned aux_pcm_gpio_on[] = {
1454 GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
1455 GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
1456 GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
1457 GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
1458};
1459
1460static int __init aux_pcm_gpio_init(void)
1461{
1462 int pin, rc;
1463
1464 pr_info("aux_pcm_gpio_init \n");
1465 for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) {
1466 rc = gpio_tlmm_config(aux_pcm_gpio_on[pin],
1467 GPIO_CFG_ENABLE);
1468 if (rc) {
1469 printk(KERN_ERR
1470 "%s: gpio_tlmm_config(%#x)=%d\n",
1471 __func__, aux_pcm_gpio_on[pin], rc);
1472 }
1473 }
1474 return rc;
1475}
1476
1477static struct msm_gpio mi2s_clk_gpios[] = {
1478 { GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1479 "MI2S_SCLK"},
1480 { GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1481 "MI2S_WS"},
1482 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1483 "MI2S_MCLK_A"},
1484};
1485
1486static struct msm_gpio mi2s_rx_data_lines_gpios[] = {
1487 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1488 "MI2S_DATA_SD0_A"},
1489 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1490 "MI2S_DATA_SD1_A"},
1491 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1492 "MI2S_DATA_SD2_A"},
1493 { GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1494 "MI2S_DATA_SD3"},
1495};
1496
1497static struct msm_gpio mi2s_tx_data_lines_gpios[] = {
1498 { GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1499 "MI2S_DATA_SD3"},
1500};
1501
1502int mi2s_config_clk_gpio(void)
1503{
1504 int rc = 0;
1505
1506 rc = msm_gpios_request_enable(mi2s_clk_gpios,
1507 ARRAY_SIZE(mi2s_clk_gpios));
1508 if (rc) {
1509 pr_err("%s: enable mi2s clk gpios failed\n",
1510 __func__);
1511 return rc;
1512 }
1513 return 0;
1514}
1515
1516int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask)
1517{
1518 int i, rc = 0;
1519 sd_line_mask &= MI2S_SD_LINE_MASK;
1520
1521 switch (direction) {
1522 case DIR_TX:
1523 msm_gpios_disable_free(mi2s_tx_data_lines_gpios, 1);
1524 break;
1525 case DIR_RX:
1526 i = 0;
1527 while (sd_line_mask) {
1528 if (sd_line_mask & 0x1)
1529 msm_gpios_disable_free(
1530 mi2s_rx_data_lines_gpios + i , 1);
1531 sd_line_mask = sd_line_mask >> 1;
1532 i++;
1533 }
1534 break;
1535 default:
1536 pr_err("%s: Invaild direction direction = %u\n",
1537 __func__, direction);
1538 rc = -EINVAL;
1539 break;
1540 }
1541 return rc;
1542}
1543
1544int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask)
1545{
1546 int i , rc = 0;
1547 u8 sd_config_done_mask = 0;
1548
1549 sd_line_mask &= MI2S_SD_LINE_MASK;
1550
1551 switch (direction) {
1552 case DIR_TX:
1553 if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) ||
1554 (sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) {
1555 pr_err("%s: can not use SD0 or SD1 or SD2 for TX"
1556 ".only can use SD3. sd_line_mask = 0x%x\n",
1557 __func__ , sd_line_mask);
1558 rc = -EINVAL;
1559 } else {
1560 rc = msm_gpios_request_enable(mi2s_tx_data_lines_gpios,
1561 1);
1562 if (rc)
1563 pr_err("%s: enable mi2s gpios for TX failed\n",
1564 __func__);
1565 }
1566 break;
1567 case DIR_RX:
1568 i = 0;
1569 while (sd_line_mask && (rc == 0)) {
1570 if (sd_line_mask & 0x1) {
1571 rc = msm_gpios_request_enable(
1572 mi2s_rx_data_lines_gpios + i , 1);
1573 if (rc) {
1574 pr_err("%s: enable mi2s gpios for"
1575 "RX failed. SD line = %s\n",
1576 __func__,
1577 (mi2s_rx_data_lines_gpios + i)->label);
1578 mi2s_unconfig_data_gpio(DIR_RX,
1579 sd_config_done_mask);
1580 } else
1581 sd_config_done_mask |= (1 << i);
1582 }
1583 sd_line_mask = sd_line_mask >> 1;
1584 i++;
1585 }
1586 break;
1587 default:
1588 pr_err("%s: Invaild direction direction = %u\n",
1589 __func__, direction);
1590 rc = -EINVAL;
1591 break;
1592 }
1593 return rc;
1594}
1595
1596int mi2s_unconfig_clk_gpio(void)
1597{
1598 msm_gpios_disable_free(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios));
1599 return 0;
1600}
1601
1602#endif /* CONFIG_MSM7KV2_AUDIO */
1603
1604static int __init buses_init(void)
1605{
1606 if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT,
1607 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
1608 pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
1609 __func__, PMIC_GPIO_INT);
1610
Anirudh Ghayalc2019332011-11-12 06:29:10 +05301611 if (machine_is_msm8x60_fluid())
1612 pm8058_7x30_data.keypad_pdata = &fluid_keypad_data;
1613 else
1614 pm8058_7x30_data.keypad_pdata = &surf_keypad_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001615
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001616 return 0;
1617}
1618
1619#define TIMPANI_RESET_GPIO 1
1620
1621struct bahama_config_register{
1622 u8 reg;
1623 u8 value;
1624 u8 mask;
1625};
1626
1627enum version{
1628 VER_1_0,
1629 VER_2_0,
1630 VER_UNSUPPORTED = 0xFF
1631};
1632
Justin Paupore3f40f342011-08-10 18:52:16 -07001633static struct regulator *vreg_marimba_1;
1634static struct regulator *vreg_marimba_2;
1635static struct regulator *vreg_bahama;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001636
1637static struct msm_gpio timpani_reset_gpio_cfg[] = {
1638{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
1639 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} };
1640
1641static u8 read_bahama_ver(void)
1642{
1643 int rc;
1644 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1645 u8 bahama_version;
1646
1647 rc = marimba_read_bit_mask(&config, 0x00, &bahama_version, 1, 0x1F);
1648 if (rc < 0) {
1649 printk(KERN_ERR
1650 "%s: version read failed: %d\n",
1651 __func__, rc);
1652 return rc;
1653 } else {
1654 printk(KERN_INFO
1655 "%s: version read got: 0x%x\n",
1656 __func__, bahama_version);
1657 }
1658
1659 switch (bahama_version) {
1660 case 0x08: /* varient of bahama v1 */
1661 case 0x10:
1662 case 0x00:
1663 return VER_1_0;
1664 case 0x09: /* variant of bahama v2 */
1665 return VER_2_0;
1666 default:
1667 return VER_UNSUPPORTED;
1668 }
1669}
1670
1671static int config_timpani_reset(void)
1672{
1673 int rc;
1674
1675 rc = msm_gpios_request_enable(timpani_reset_gpio_cfg,
1676 ARRAY_SIZE(timpani_reset_gpio_cfg));
1677 if (rc < 0) {
1678 printk(KERN_ERR
1679 "%s: msm_gpios_request_enable failed (%d)\n",
1680 __func__, rc);
1681 }
1682 return rc;
1683}
1684
1685static unsigned int msm_timpani_setup_power(void)
1686{
1687 int rc;
1688
1689 rc = config_timpani_reset();
1690 if (rc < 0)
1691 goto out;
1692
Justin Paupore3f40f342011-08-10 18:52:16 -07001693 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001694 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001695 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001696 goto out;
1697 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001698
1699 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001700 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001701 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1702 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001703 }
1704
1705 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 1);
1706 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001707 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001708 __func__, rc);
1709 msm_gpios_free(timpani_reset_gpio_cfg,
1710 ARRAY_SIZE(timpani_reset_gpio_cfg));
Justin Paupore3f40f342011-08-10 18:52:16 -07001711 goto disable_marimba_2;
1712 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001713
Justin Paupore3f40f342011-08-10 18:52:16 -07001714 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001715
Justin Paupore3f40f342011-08-10 18:52:16 -07001716disable_marimba_2:
1717 regulator_disable(vreg_marimba_2);
1718disable_marimba_1:
1719 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001720out:
1721 return rc;
1722};
1723
1724static void msm_timpani_shutdown_power(void)
1725{
1726 int rc;
1727
Justin Paupore3f40f342011-08-10 18:52:16 -07001728 rc = regulator_disable(vreg_marimba_2);
1729 if (rc)
1730 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1731
1732 rc = regulator_disable(vreg_marimba_1);
1733 if (rc)
1734 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001735
1736 rc = gpio_direction_output(TIMPANI_RESET_GPIO, 0);
Justin Paupore3f40f342011-08-10 18:52:16 -07001737 if (rc < 0)
1738 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001739 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001740
1741 msm_gpios_free(timpani_reset_gpio_cfg,
1742 ARRAY_SIZE(timpani_reset_gpio_cfg));
1743};
1744
1745static unsigned int msm_bahama_core_config(int type)
1746{
1747 int rc = 0;
1748
1749 if (type == BAHAMA_ID) {
1750
1751 int i;
1752 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
1753
1754 const struct bahama_config_register v20_init[] = {
1755 /* reg, value, mask */
1756 { 0xF4, 0x84, 0xFF }, /* AREG */
1757 { 0xF0, 0x04, 0xFF } /* DREG */
1758 };
1759
1760 if (read_bahama_ver() == VER_2_0) {
1761 for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
1762 u8 value = v20_init[i].value;
1763 rc = marimba_write_bit_mask(&config,
1764 v20_init[i].reg,
1765 &value,
1766 sizeof(v20_init[i].value),
1767 v20_init[i].mask);
1768 if (rc < 0) {
1769 printk(KERN_ERR
1770 "%s: reg %d write failed: %d\n",
1771 __func__, v20_init[i].reg, rc);
1772 return rc;
1773 }
1774 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
1775 " mask 0x%02x\n",
1776 __func__, v20_init[i].reg,
1777 v20_init[i].value, v20_init[i].mask);
1778 }
1779 }
1780 }
1781 printk(KERN_INFO "core type: %d\n", type);
1782
1783 return rc;
1784}
1785
1786static unsigned int msm_bahama_setup_power(void)
1787{
Justin Paupore3f40f342011-08-10 18:52:16 -07001788 int rc = regulator_enable(vreg_bahama);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001789
Justin Paupore3f40f342011-08-10 18:52:16 -07001790 if (rc)
1791 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001792
1793 return rc;
1794};
1795
1796static unsigned int msm_bahama_shutdown_power(int value)
1797{
1798 int rc = 0;
1799
1800 if (value != BAHAMA_ID) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001801 rc = regulator_disable(vreg_bahama);
1802
1803 if (rc)
1804 pr_err("%s: regulator_disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001805 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001806 }
1807
1808 return rc;
1809};
1810
1811static struct msm_gpio marimba_svlte_config_clock[] = {
1812 { GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1813 "MARIMBA_SVLTE_CLOCK_ENABLE" },
1814};
1815
1816static unsigned int msm_marimba_gpio_config_svlte(int gpio_cfg_marimba)
1817{
1818 if (machine_is_msm8x55_svlte_surf() ||
1819 machine_is_msm8x55_svlte_ffa()) {
1820 if (gpio_cfg_marimba)
1821 gpio_set_value(GPIO_PIN
1822 (marimba_svlte_config_clock->gpio_cfg), 1);
1823 else
1824 gpio_set_value(GPIO_PIN
1825 (marimba_svlte_config_clock->gpio_cfg), 0);
1826 }
1827
1828 return 0;
1829};
1830
1831static unsigned int msm_marimba_setup_power(void)
1832{
1833 int rc;
1834
Justin Paupore3f40f342011-08-10 18:52:16 -07001835 rc = regulator_enable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001836 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001837 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001838 goto out;
1839 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001840
1841 rc = regulator_enable(vreg_marimba_2);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001842 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001843 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1844 goto disable_marimba_1;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001845 }
1846
1847 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
1848 rc = msm_gpios_request_enable(marimba_svlte_config_clock,
1849 ARRAY_SIZE(marimba_svlte_config_clock));
1850 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001851 pr_err("%s: msm_gpios_request_enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001852 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07001853 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001854 }
1855
1856 rc = gpio_direction_output(GPIO_PIN
1857 (marimba_svlte_config_clock->gpio_cfg), 0);
1858 if (rc < 0) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001859 pr_err("%s: gpio_direction_output failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001860 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07001861 goto disable_marimba_2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001862 }
1863 }
1864
Justin Paupore3f40f342011-08-10 18:52:16 -07001865 return 0;
1866
1867disable_marimba_2:
1868 regulator_disable(vreg_marimba_2);
1869disable_marimba_1:
1870 regulator_disable(vreg_marimba_1);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001871out:
1872 return rc;
1873};
1874
1875static void msm_marimba_shutdown_power(void)
1876{
1877 int rc;
1878
Justin Paupore3f40f342011-08-10 18:52:16 -07001879 rc = regulator_disable(vreg_marimba_2);
1880 if (rc)
1881 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
1882
1883 rc = regulator_disable(vreg_marimba_1);
1884 if (rc)
1885 pr_err("%s: regulator_disable failed (%d)\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001886};
1887
1888static int bahama_present(void)
1889{
1890 int id;
1891 switch (id = adie_get_detected_connectivity_type()) {
1892 case BAHAMA_ID:
1893 return 1;
1894
1895 case MARIMBA_ID:
1896 return 0;
1897
1898 case TIMPANI_ID:
1899 default:
1900 printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n",
1901 __func__, id);
1902 return -ENODEV;
1903 }
1904}
1905
Justin Paupore3f40f342011-08-10 18:52:16 -07001906struct regulator *fm_regulator;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001907static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
1908{
Justin Paupore3f40f342011-08-10 18:52:16 -07001909 int rc, voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001910 uint32_t irqcfg;
1911 const char *id = "FMPW";
1912
1913 int bahama_not_marimba = bahama_present();
1914
Justin Paupore3f40f342011-08-10 18:52:16 -07001915 if (bahama_not_marimba < 0) {
1916 pr_warn("%s: bahama_present: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001917 __func__, bahama_not_marimba);
Justin Paupore3f40f342011-08-10 18:52:16 -07001918 rc = -ENODEV;
1919 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001920 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001921 if (bahama_not_marimba) {
1922 fm_regulator = regulator_get(NULL, "s3");
1923 voltage = 1800000;
1924 } else {
1925 fm_regulator = regulator_get(NULL, "s2");
1926 voltage = 1300000;
1927 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001928
1929 if (IS_ERR(fm_regulator)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001930 rc = PTR_ERR(fm_regulator);
1931 pr_err("%s: regulator_get failed (%d)\n", __func__, rc);
1932 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001933 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001934
Justin Paupore3f40f342011-08-10 18:52:16 -07001935 rc = regulator_set_voltage(fm_regulator, voltage, voltage);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001936
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001937 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001938 pr_err("%s: regulator_set_voltage failed (%d)\n", __func__, rc);
1939 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001940 }
1941
Justin Paupore3f40f342011-08-10 18:52:16 -07001942 rc = regulator_enable(fm_regulator);
1943
1944 if (rc) {
1945 pr_err("%s: regulator_enable failed (%d)\n", __func__, rc);
1946 goto regulator_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001947 }
Justin Paupore3f40f342011-08-10 18:52:16 -07001948
1949 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_ON);
1950
1951 if (rc < 0) {
1952 pr_err("%s: clock vote failed (%d)\n", __func__, rc);
1953 goto regulator_disable;
1954 }
1955
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001956 /*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
1957 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07001958 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001959 rc = marimba_gpio_config(1);
Justin Paupore3f40f342011-08-10 18:52:16 -07001960 if (rc < 0) {
1961 pr_err("%s: clock enable for svlte : %d\n",
1962 __func__, rc);
1963 goto clock_devote;
1964 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001965 }
1966 irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
1967 GPIO_CFG_2MA);
1968 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
1969 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07001970 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001971 rc = -EIO;
Justin Paupore3f40f342011-08-10 18:52:16 -07001972 goto gpio_deconfig;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001973
1974 }
1975 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001976
Justin Paupore3f40f342011-08-10 18:52:16 -07001977gpio_deconfig:
1978 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa())
1979 marimba_gpio_config(0);
1980clock_devote:
1981 pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO, PMAPP_CLOCK_VOTE_OFF);
1982regulator_disable:
1983 regulator_disable(fm_regulator);
1984regulator_free:
1985 regulator_put(fm_regulator);
1986 fm_regulator = NULL;
1987out:
1988 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001989};
1990
1991static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
1992{
1993 int rc;
1994 const char *id = "FMPW";
1995 uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
1996 GPIO_CFG_2MA);
1997
1998 int bahama_not_marimba = bahama_present();
1999 if (bahama_not_marimba == -1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002000 pr_warn("%s: bahama_present: %d\n",
2001 __func__, bahama_not_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002002 return;
2003 }
2004
2005 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
2006 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002007 pr_err("%s: gpio_tlmm_config(%#x)=%d\n", __func__, irqcfg, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002008 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002009 if (!IS_ERR_OR_NULL(fm_regulator)) {
2010 rc = regulator_disable(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002011
Justin Paupore3f40f342011-08-10 18:52:16 -07002012 if (rc)
2013 pr_err("%s: return val: %d\n", __func__, rc);
2014
2015 regulator_put(fm_regulator);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002016 fm_regulator = NULL;
2017 }
2018 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
2019 PMAPP_CLOCK_VOTE_OFF);
2020 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002021 pr_err("%s: clock_vote return val: %d\n", __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002022
2023 /*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
2024 of svlte*/
Justin Paupore3f40f342011-08-10 18:52:16 -07002025 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002026 rc = marimba_gpio_config(0);
2027 if (rc < 0)
Justin Paupore3f40f342011-08-10 18:52:16 -07002028 pr_err("%s: clock disable for svlte : %d\n",
2029 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002030 }
2031}
2032
2033static struct marimba_fm_platform_data marimba_fm_pdata = {
2034 .fm_setup = fm_radio_setup,
2035 .fm_shutdown = fm_radio_shutdown,
2036 .irq = MSM_GPIO_TO_INT(147),
2037 .vreg_s2 = NULL,
2038 .vreg_xo_out = NULL,
2039 .is_fm_soc_i2s_master = false,
2040 .config_i2s_gpio = NULL,
2041};
2042
2043
2044/* Slave id address for FM/CDC/QMEMBIST
2045 * Values can be programmed using Marimba slave id 0
2046 * should there be a conflict with other I2C devices
2047 * */
2048#define MARIMBA_SLAVE_ID_FM_ADDR 0x2A
2049#define MARIMBA_SLAVE_ID_CDC_ADDR 0x77
2050#define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66
2051
2052#define BAHAMA_SLAVE_ID_FM_ADDR 0x2A
2053#define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B
2054
2055static const char *tsadc_id = "MADC";
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002056
Justin Paupore3f40f342011-08-10 18:52:16 -07002057static struct regulator_bulk_data regs_tsadc_marimba[] = {
2058 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2059 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002060};
Justin Paupore3f40f342011-08-10 18:52:16 -07002061
2062static struct regulator_bulk_data regs_tsadc_timpani[] = {
2063 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2064 { .supply = "gp12", .min_uV = 2200000, .max_uV = 2200000 },
2065 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2066};
2067
2068static struct regulator_bulk_data *regs_tsadc;
2069static int regs_tsadc_count;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002070
2071static int marimba_tsadc_power(int vreg_on)
2072{
Justin Paupore3f40f342011-08-10 18:52:16 -07002073 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002074 int tsadc_adie_type = adie_get_detected_codec_type();
2075
Justin Paupore3f40f342011-08-10 18:52:16 -07002076 switch (tsadc_adie_type) {
2077 case TIMPANI_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002078 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2079 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2080 if (rc) {
2081 pr_err("%s: unable to %svote for d1 clk\n",
2082 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002083 goto D1_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002084 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002085
2086 /* fall through */
2087 case MARIMBA_ID:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002088 rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2089 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
2090 if (rc) {
2091 pr_err("%s: unable to %svote for d1 clk\n",
2092 __func__, vreg_on ? "" : "de-");
Justin Paupore3f40f342011-08-10 18:52:16 -07002093 goto D0_vote_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002094 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002095
Justin Paupore3f40f342011-08-10 18:52:16 -07002096 WARN_ON(regs_tsadc_count == 0);
2097
2098 rc = vreg_on ?
2099 regulator_bulk_enable(regs_tsadc_count, regs_tsadc) :
2100 regulator_bulk_disable(regs_tsadc_count, regs_tsadc);
2101
2102 if (rc) {
2103 pr_err("%s: regulator %sable failed: %d\n",
2104 __func__, vreg_on ? "en" : "dis", rc);
2105 goto regulator_switch_fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002106 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002107
2108 break;
2109 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002110 pr_err("%s:Adie %d not supported\n",
2111 __func__, tsadc_adie_type);
2112 return -ENODEV;
2113 }
2114
2115 msleep(5); /* ensure power is stable */
2116
2117 return 0;
2118
Justin Paupore3f40f342011-08-10 18:52:16 -07002119regulator_switch_fail:
2120 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
2121 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2122D0_vote_fail:
2123 if (tsadc_adie_type == TIMPANI_ID)
2124 pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_D1,
2125 vreg_on ? PMAPP_CLOCK_VOTE_OFF : PMAPP_CLOCK_VOTE_ON);
2126D1_vote_fail:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002127 return rc;
2128}
2129
2130static int marimba_tsadc_init(void)
2131{
Justin Paupore3f40f342011-08-10 18:52:16 -07002132 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002133 int tsadc_adie_type = adie_get_detected_codec_type();
2134
Justin Paupore3f40f342011-08-10 18:52:16 -07002135 switch (tsadc_adie_type) {
2136 case MARIMBA_ID:
2137 regs_tsadc = regs_tsadc_marimba;
2138 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_marimba);
2139 break;
2140 case TIMPANI_ID:
2141 regs_tsadc = regs_tsadc_timpani;
2142 regs_tsadc_count = ARRAY_SIZE(regs_tsadc_timpani);
2143 break;
2144 default:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002145 pr_err("%s:Adie %d not supported\n",
2146 __func__, tsadc_adie_type);
Justin Paupore3f40f342011-08-10 18:52:16 -07002147 rc = -ENODEV;
2148 goto out;
2149 }
2150
2151 rc = regulator_bulk_get(NULL, regs_tsadc_count, regs_tsadc);
2152 if (rc) {
2153 pr_err("%s: could not get regulators: %d\n",
2154 __func__, rc);
2155 goto out;
2156 }
2157
2158 rc = regulator_bulk_set_voltage(regs_tsadc_count, regs_tsadc);
2159 if (rc) {
2160 pr_err("%s: could not set regulator voltages: %d\n",
2161 __func__, rc);
2162 goto vreg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002163 }
2164
2165 return 0;
2166
Justin Paupore3f40f342011-08-10 18:52:16 -07002167vreg_free:
2168 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2169out:
2170 regs_tsadc = NULL;
2171 regs_tsadc_count = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002172 return rc;
2173}
2174
2175static int marimba_tsadc_exit(void)
2176{
Justin Paupore3f40f342011-08-10 18:52:16 -07002177 regulator_bulk_free(regs_tsadc_count, regs_tsadc);
2178 regs_tsadc_count = 0;
2179 regs_tsadc = NULL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002180
Justin Paupore3f40f342011-08-10 18:52:16 -07002181 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002182}
2183
2184
2185static struct msm_ts_platform_data msm_ts_data = {
Anirudh Ghayal82b74722012-01-19 15:35:34 +05302186 .min_x = 284,
2187 .max_x = 3801,
2188 .min_y = 155,
2189 .max_y = 3929,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002190 .min_press = 0,
2191 .max_press = 255,
2192 .inv_x = 4096,
2193 .inv_y = 4096,
2194 .can_wakeup = false,
2195};
2196
2197static struct marimba_tsadc_platform_data marimba_tsadc_pdata = {
2198 .marimba_tsadc_power = marimba_tsadc_power,
2199 .init = marimba_tsadc_init,
2200 .exit = marimba_tsadc_exit,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002201 .tsadc_prechg_en = true,
2202 .can_wakeup = false,
2203 .setup = {
2204 .pen_irq_en = true,
2205 .tsadc_en = true,
2206 },
2207 .params2 = {
2208 .input_clk_khz = 2400,
2209 .sample_prd = TSADC_CLK_3,
2210 },
2211 .params3 = {
2212 .prechg_time_nsecs = 6400,
2213 .stable_time_nsecs = 6400,
2214 .tsadc_test_mode = 0,
2215 },
2216 .tssc_data = &msm_ts_data,
2217};
2218
Justin Paupore3f40f342011-08-10 18:52:16 -07002219static struct regulator_bulk_data codec_regs[] = {
2220 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
2221};
2222
2223static int __init msm_marimba_codec_init(void)
2224{
2225 int rc = regulator_bulk_get(NULL, ARRAY_SIZE(codec_regs), codec_regs);
2226
2227 if (rc) {
2228 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2229 goto out;
2230 }
2231
2232 rc = regulator_bulk_set_voltage(ARRAY_SIZE(codec_regs), codec_regs);
2233 if (rc) {
2234 pr_err("%s: could not set regulator voltages: %d\n",
2235 __func__, rc);
2236 goto reg_free;
2237 }
2238
2239 return rc;
2240
2241reg_free:
2242 regulator_bulk_free(ARRAY_SIZE(codec_regs), codec_regs);
2243out:
2244 return rc;
2245}
2246
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002247static int msm_marimba_codec_power(int vreg_on)
2248{
Justin Paupore3f40f342011-08-10 18:52:16 -07002249 int rc = vreg_on ?
2250 regulator_bulk_enable(ARRAY_SIZE(codec_regs), codec_regs) :
2251 regulator_bulk_disable(ARRAY_SIZE(codec_regs), codec_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002252
Justin Paupore3f40f342011-08-10 18:52:16 -07002253 if (rc) {
2254 pr_err("%s: could not %sable regulators: %d",
2255 __func__, vreg_on ? "en" : "dis", rc);
2256 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002257 }
2258
Justin Paupore3f40f342011-08-10 18:52:16 -07002259 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002260}
2261
2262static struct marimba_codec_platform_data mariba_codec_pdata = {
2263 .marimba_codec_power = msm_marimba_codec_power,
2264#ifdef CONFIG_MARIMBA_CODEC
2265 .snddev_profile_init = msm_snddev_init,
2266#endif
2267};
2268
2269static struct marimba_platform_data marimba_pdata = {
2270 .slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR,
2271 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2272 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2273 .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR,
2274 .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR,
2275 .marimba_setup = msm_marimba_setup_power,
2276 .marimba_shutdown = msm_marimba_shutdown_power,
2277 .bahama_setup = msm_bahama_setup_power,
2278 .bahama_shutdown = msm_bahama_shutdown_power,
2279 .marimba_gpio_config = msm_marimba_gpio_config_svlte,
2280 .bahama_core_config = msm_bahama_core_config,
2281 .fm = &marimba_fm_pdata,
2282 .codec = &mariba_codec_pdata,
2283 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2284};
2285
2286static void __init msm7x30_init_marimba(void)
2287{
2288 int rc;
2289
Justin Paupore3f40f342011-08-10 18:52:16 -07002290 struct regulator_bulk_data regs[] = {
2291 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
2292 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
2293 { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 },
2294 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002295
Justin Paupore3f40f342011-08-10 18:52:16 -07002296 rc = msm_marimba_codec_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002297
Justin Paupore3f40f342011-08-10 18:52:16 -07002298 if (rc) {
2299 pr_err("%s: msm_marimba_codec_init failed (%d)\n",
2300 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002301 return;
2302 }
Justin Paupore3f40f342011-08-10 18:52:16 -07002303
2304 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
2305
2306 if (rc) {
2307 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2308 return;
2309 }
2310
2311 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
2312
2313 if (rc) {
2314 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2315 regulator_bulk_free(ARRAY_SIZE(regs), regs);
2316 return;
2317 }
2318
2319 vreg_marimba_1 = regs[0].consumer;
2320 vreg_marimba_2 = regs[1].consumer;
2321 vreg_bahama = regs[2].consumer;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002322}
2323
2324static struct marimba_codec_platform_data timpani_codec_pdata = {
2325 .marimba_codec_power = msm_marimba_codec_power,
2326#ifdef CONFIG_TIMPANI_CODEC
2327 .snddev_profile_init = msm_snddev_init_timpani,
2328#endif
2329};
2330
2331static struct marimba_platform_data timpani_pdata = {
2332 .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
2333 .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
2334 .marimba_setup = msm_timpani_setup_power,
2335 .marimba_shutdown = msm_timpani_shutdown_power,
2336 .codec = &timpani_codec_pdata,
2337 .tsadc = &marimba_tsadc_pdata,
2338 .tsadc_ssbi_adap = MARIMBA_SSBI_ADAP,
2339};
2340
2341#define TIMPANI_I2C_SLAVE_ADDR 0xD
2342
2343static struct i2c_board_info msm_i2c_gsbi7_timpani_info[] = {
2344 {
2345 I2C_BOARD_INFO("timpani", TIMPANI_I2C_SLAVE_ADDR),
2346 .platform_data = &timpani_pdata,
2347 },
2348};
2349
2350#ifdef CONFIG_MSM7KV2_AUDIO
2351static struct resource msm_aictl_resources[] = {
2352 {
2353 .name = "aictl",
2354 .start = 0xa5000100,
2355 .end = 0xa5000100,
2356 .flags = IORESOURCE_MEM,
2357 }
2358};
2359
2360static struct resource msm_mi2s_resources[] = {
2361 {
2362 .name = "hdmi",
2363 .start = 0xac900000,
2364 .end = 0xac900038,
2365 .flags = IORESOURCE_MEM,
2366 },
2367 {
2368 .name = "codec_rx",
2369 .start = 0xac940040,
2370 .end = 0xac940078,
2371 .flags = IORESOURCE_MEM,
2372 },
2373 {
2374 .name = "codec_tx",
2375 .start = 0xac980080,
2376 .end = 0xac9800B8,
2377 .flags = IORESOURCE_MEM,
2378 }
2379
2380};
2381
2382static struct msm_lpa_platform_data lpa_pdata = {
2383 .obuf_hlb_size = 0x2BFF8,
2384 .dsp_proc_id = 0,
2385 .app_proc_id = 2,
2386 .nosb_config = {
2387 .llb_min_addr = 0,
2388 .llb_max_addr = 0x3ff8,
2389 .sb_min_addr = 0,
2390 .sb_max_addr = 0,
2391 },
2392 .sb_config = {
2393 .llb_min_addr = 0,
2394 .llb_max_addr = 0x37f8,
2395 .sb_min_addr = 0x3800,
2396 .sb_max_addr = 0x3ff8,
2397 }
2398};
2399
2400static struct resource msm_lpa_resources[] = {
2401 {
2402 .name = "lpa",
2403 .start = 0xa5000000,
2404 .end = 0xa50000a0,
2405 .flags = IORESOURCE_MEM,
2406 }
2407};
2408
2409static struct resource msm_aux_pcm_resources[] = {
2410
2411 {
2412 .name = "aux_codec_reg_addr",
2413 .start = 0xac9c00c0,
2414 .end = 0xac9c00c8,
2415 .flags = IORESOURCE_MEM,
2416 },
2417 {
2418 .name = "aux_pcm_dout",
2419 .start = 138,
2420 .end = 138,
2421 .flags = IORESOURCE_IO,
2422 },
2423 {
2424 .name = "aux_pcm_din",
2425 .start = 139,
2426 .end = 139,
2427 .flags = IORESOURCE_IO,
2428 },
2429 {
2430 .name = "aux_pcm_syncout",
2431 .start = 140,
2432 .end = 140,
2433 .flags = IORESOURCE_IO,
2434 },
2435 {
2436 .name = "aux_pcm_clkin_a",
2437 .start = 141,
2438 .end = 141,
2439 .flags = IORESOURCE_IO,
2440 },
2441};
2442
2443static struct platform_device msm_aux_pcm_device = {
2444 .name = "msm_aux_pcm",
2445 .id = 0,
2446 .num_resources = ARRAY_SIZE(msm_aux_pcm_resources),
2447 .resource = msm_aux_pcm_resources,
2448};
2449
2450struct platform_device msm_aictl_device = {
2451 .name = "audio_interct",
2452 .id = 0,
2453 .num_resources = ARRAY_SIZE(msm_aictl_resources),
2454 .resource = msm_aictl_resources,
2455};
2456
2457struct platform_device msm_mi2s_device = {
2458 .name = "mi2s",
2459 .id = 0,
2460 .num_resources = ARRAY_SIZE(msm_mi2s_resources),
2461 .resource = msm_mi2s_resources,
2462};
2463
2464struct platform_device msm_lpa_device = {
2465 .name = "lpa",
2466 .id = 0,
2467 .num_resources = ARRAY_SIZE(msm_lpa_resources),
2468 .resource = msm_lpa_resources,
2469 .dev = {
2470 .platform_data = &lpa_pdata,
2471 },
2472};
2473#endif /* CONFIG_MSM7KV2_AUDIO */
2474
2475#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2476 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2477 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2478 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2479 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2480 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2481#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2482 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2483 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2484 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2485 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2486 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2487 #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2488 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2489 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2490 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2491 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2492 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2493 #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
2494 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
2495 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
2496 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
2497 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
2498 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
2499#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
2500
2501static unsigned int dec_concurrency_table[] = {
2502 /* Audio LP */
2503 0,
2504 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2505 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2506 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2507 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)|
2508 (1<<MSM_ADSP_OP_DM)),
2509
2510 /* Concurrency 1 */
2511 (DEC4_FORMAT),
2512 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2513 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2514 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2515 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2516
2517 /* Concurrency 2 */
2518 (DEC4_FORMAT),
2519 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2520 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2521 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2522 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2523
2524 /* Concurrency 3 */
2525 (DEC4_FORMAT),
2526 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2527 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2528 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2529 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2530
2531 /* Concurrency 4 */
2532 (DEC4_FORMAT),
2533 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2534 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2535 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2536 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2537
2538 /* Concurrency 5 */
2539 (DEC4_FORMAT),
2540 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
2541 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2542 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2543 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2544
2545 /* Concurrency 6 */
2546 (DEC4_FORMAT),
2547 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2548 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2549 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2550 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
2551};
2552
2553#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
2554 .module_queueid = queueid, .module_decid = decid, \
2555 .nr_codec_support = nr_codec}
2556
2557#define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
2558 .max_instances_same_dec = max_instance_same, \
2559 .max_instances_diff_dec = max_instance_diff}
2560
2561static struct msm_adspdec_info dec_info_list[] = {
2562 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
2563 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
2564 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
2565 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
2566 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
2567};
2568
2569static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
2570 /* Non Turbo Mode */
2571 {
2572 DEC_INSTANCE(4, 3), /* WAV */
2573 DEC_INSTANCE(4, 3), /* ADPCM */
2574 DEC_INSTANCE(4, 2), /* MP3 */
2575 DEC_INSTANCE(0, 0), /* Real Audio */
2576 DEC_INSTANCE(4, 2), /* WMA */
2577 DEC_INSTANCE(3, 2), /* AAC */
2578 DEC_INSTANCE(0, 0), /* Reserved */
2579 DEC_INSTANCE(0, 0), /* MIDI */
2580 DEC_INSTANCE(4, 3), /* YADPCM */
2581 DEC_INSTANCE(4, 3), /* QCELP */
2582 DEC_INSTANCE(4, 3), /* AMRNB */
2583 DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
2584 DEC_INSTANCE(4, 3), /* EVRC */
2585 DEC_INSTANCE(1, 1), /* WMAPRO */
2586 },
2587 /* Turbo Mode */
2588 {
2589 DEC_INSTANCE(4, 3), /* WAV */
2590 DEC_INSTANCE(4, 3), /* ADPCM */
2591 DEC_INSTANCE(4, 3), /* MP3 */
2592 DEC_INSTANCE(0, 0), /* Real Audio */
2593 DEC_INSTANCE(4, 3), /* WMA */
2594 DEC_INSTANCE(4, 3), /* AAC */
2595 DEC_INSTANCE(0, 0), /* Reserved */
2596 DEC_INSTANCE(0, 0), /* MIDI */
2597 DEC_INSTANCE(4, 3), /* YADPCM */
2598 DEC_INSTANCE(4, 3), /* QCELP */
2599 DEC_INSTANCE(4, 3), /* AMRNB */
2600 DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
2601 DEC_INSTANCE(4, 3), /* EVRC */
2602 DEC_INSTANCE(1, 2), /* WMAPRO */
2603 },
2604};
2605
2606static struct msm_adspdec_database msm_device_adspdec_database = {
2607 .num_dec = ARRAY_SIZE(dec_info_list),
2608 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
2609 ARRAY_SIZE(dec_info_list)),
2610 .dec_concurrency_table = dec_concurrency_table,
2611 .dec_info_list = dec_info_list,
2612 .dec_instance_list = &dec_instance_list[0][0],
2613};
2614
2615static struct platform_device msm_device_adspdec = {
2616 .name = "msm_adspdec",
2617 .id = -1,
2618 .dev = {
2619 .platform_data = &msm_device_adspdec_database
2620 },
2621};
2622
2623static struct resource smc91x_resources[] = {
2624 [0] = {
2625 .start = 0x8A000300,
2626 .end = 0x8A0003ff,
2627 .flags = IORESOURCE_MEM,
2628 },
2629 [1] = {
2630 .start = MSM_GPIO_TO_INT(156),
2631 .end = MSM_GPIO_TO_INT(156),
2632 .flags = IORESOURCE_IRQ,
2633 },
2634};
2635
2636static struct platform_device smc91x_device = {
2637 .name = "smc91x",
2638 .id = 0,
2639 .num_resources = ARRAY_SIZE(smc91x_resources),
2640 .resource = smc91x_resources,
2641};
2642
2643static struct smsc911x_platform_config smsc911x_config = {
2644 .phy_interface = PHY_INTERFACE_MODE_MII,
2645 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
2646 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
2647 .flags = SMSC911X_USE_32BIT,
2648};
2649
2650static struct resource smsc911x_resources[] = {
2651 [0] = {
2652 .start = 0x8D000000,
2653 .end = 0x8D000100,
2654 .flags = IORESOURCE_MEM,
2655 },
2656 [1] = {
2657 .start = MSM_GPIO_TO_INT(88),
2658 .end = MSM_GPIO_TO_INT(88),
2659 .flags = IORESOURCE_IRQ,
2660 },
2661};
2662
2663static struct platform_device smsc911x_device = {
2664 .name = "smsc911x",
2665 .id = -1,
2666 .num_resources = ARRAY_SIZE(smsc911x_resources),
2667 .resource = smsc911x_resources,
2668 .dev = {
2669 .platform_data = &smsc911x_config,
2670 },
2671};
2672
2673static struct msm_gpio smsc911x_gpios[] = {
2674 { GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" },
2675 { GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" },
2676 { GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" },
2677 { GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" },
2678 { GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" },
2679 { GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" },
2680 { GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" },
2681 { GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" },
2682};
2683
2684static void msm7x30_cfg_smsc911x(void)
2685{
2686 int rc;
2687
2688 rc = msm_gpios_request_enable(smsc911x_gpios,
2689 ARRAY_SIZE(smsc911x_gpios));
2690 if (rc)
2691 pr_err("%s: unable to enable gpios\n", __func__);
2692}
2693
2694#ifdef CONFIG_USB_G_ANDROID
2695static struct android_usb_platform_data android_usb_pdata = {
2696 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2697};
2698
2699static struct platform_device android_usb_device = {
2700 .name = "android_usb",
2701 .id = -1,
2702 .dev = {
2703 .platform_data = &android_usb_pdata,
2704 },
2705};
2706#endif
2707
2708static struct msm_gpio optnav_config_data[] = {
2709 { GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA),
2710 "optnav_chip_select" },
2711};
2712
Justin Paupore3f40f342011-08-10 18:52:16 -07002713static struct regulator_bulk_data optnav_regulators[] = {
2714 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2715 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
2716 { .supply = "gp9", .min_uV = 1800000, .max_uV = 1800000 },
2717 { .supply = "usb", .min_uV = 3300000, .max_uV = 3300000 },
2718};
2719
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002720static void __iomem *virtual_optnav;
2721
2722static int optnav_gpio_setup(void)
2723{
2724 int rc = -ENODEV;
2725 rc = msm_gpios_request_enable(optnav_config_data,
2726 ARRAY_SIZE(optnav_config_data));
2727
Justin Paupore3f40f342011-08-10 18:52:16 -07002728 if (rc)
2729 return rc;
2730
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002731 /* Configure the FPGA for GPIOs */
2732 virtual_optnav = ioremap(FPGA_OPTNAV_GPIO_ADDR, 0x4);
2733 if (!virtual_optnav) {
2734 pr_err("%s:Could not ioremap region\n", __func__);
2735 return -ENOMEM;
2736 }
2737 /*
2738 * Configure the FPGA to set GPIO 19 as
2739 * normal, active(enabled), output(MSM to SURF)
2740 */
2741 writew(0x311E, virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002742
2743 rc = regulator_bulk_get(NULL, ARRAY_SIZE(optnav_regulators),
2744 optnav_regulators);
2745 if (rc)
2746 return rc;
2747
2748 rc = regulator_bulk_set_voltage(ARRAY_SIZE(optnav_regulators),
2749 optnav_regulators);
2750
2751 if (rc)
2752 goto regulator_put;
2753
2754 return rc;
2755
2756regulator_put:
2757 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002758 return rc;
2759}
2760
2761static void optnav_gpio_release(void)
2762{
2763 msm_gpios_disable_free(optnav_config_data,
2764 ARRAY_SIZE(optnav_config_data));
2765 iounmap(virtual_optnav);
Justin Paupore3f40f342011-08-10 18:52:16 -07002766 regulator_bulk_free(ARRAY_SIZE(optnav_regulators), optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002767}
2768
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002769static int optnav_enable(void)
2770{
2771 int rc;
2772 /*
2773 * Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
2774 * for I2C communication with keyboard.
2775 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002776
Justin Paupore3f40f342011-08-10 18:52:16 -07002777 rc = regulator_bulk_enable(ARRAY_SIZE(optnav_regulators),
2778 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002779
Justin Paupore3f40f342011-08-10 18:52:16 -07002780 if (rc)
2781 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002782
2783 /* Enable the chip select GPIO */
2784 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2785 gpio_set_value(OPTNAV_CHIP_SELECT, 0);
2786
2787 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002788}
2789
2790static void optnav_disable(void)
2791{
Justin Paupore3f40f342011-08-10 18:52:16 -07002792 regulator_bulk_disable(ARRAY_SIZE(optnav_regulators),
2793 optnav_regulators);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002794
2795 gpio_set_value(OPTNAV_CHIP_SELECT, 1);
2796}
2797
2798static struct ofn_atlab_platform_data optnav_data = {
2799 .gpio_setup = optnav_gpio_setup,
2800 .gpio_release = optnav_gpio_release,
2801 .optnav_on = optnav_enable,
2802 .optnav_off = optnav_disable,
2803 .rotate_xy = 0,
2804 .function1 = {
2805 .no_motion1_en = true,
2806 .touch_sensor_en = true,
2807 .ofn_en = true,
2808 .clock_select_khz = 1500,
2809 .cpi_selection = 1200,
2810 },
2811 .function2 = {
2812 .invert_y = false,
2813 .invert_x = true,
2814 .swap_x_y = false,
2815 .hold_a_b_en = true,
2816 .motion_filter_en = true,
2817 },
2818};
2819
2820static int hdmi_comm_power(int on, int show);
2821static int hdmi_init_irq(void);
2822static int hdmi_enable_5v(int on);
2823static int hdmi_core_power(int on, int show);
2824static int hdmi_cec_power(int on);
2825static bool hdmi_check_hdcp_hw_support(void);
2826
2827static struct msm_hdmi_platform_data adv7520_hdmi_data = {
2828 .irq = MSM_GPIO_TO_INT(18),
2829 .comm_power = hdmi_comm_power,
2830 .init_irq = hdmi_init_irq,
2831 .enable_5v = hdmi_enable_5v,
2832 .core_power = hdmi_core_power,
2833 .cec_power = hdmi_cec_power,
2834 .check_hdcp_hw_support = hdmi_check_hdcp_hw_support,
2835};
2836
2837#ifdef CONFIG_BOSCH_BMA150
Justin Paupore3f40f342011-08-10 18:52:16 -07002838
2839static struct regulator_bulk_data sensors_ldo[] = {
2840 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
2841 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
2842};
2843
2844static int __init sensors_ldo_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002845{
2846 int rc;
2847
Justin Paupore3f40f342011-08-10 18:52:16 -07002848 rc = regulator_bulk_get(NULL, ARRAY_SIZE(sensors_ldo), sensors_ldo);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002849
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002850 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002851 pr_err("%s: could not get regulators: %d\n", __func__, rc);
2852 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002853 }
2854
Justin Paupore3f40f342011-08-10 18:52:16 -07002855 rc = regulator_bulk_set_voltage(ARRAY_SIZE(sensors_ldo), sensors_ldo);
2856
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002857 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07002858 pr_err("%s: could not set voltages: %d\n", __func__, rc);
2859 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002860 }
2861
2862 return 0;
2863
Justin Paupore3f40f342011-08-10 18:52:16 -07002864reg_free:
2865 regulator_bulk_free(ARRAY_SIZE(sensors_ldo), sensors_ldo);
2866out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002867 return rc;
2868}
2869
Justin Paupore3f40f342011-08-10 18:52:16 -07002870static int sensors_ldo_set(int on)
2871{
2872 int rc = on ?
2873 regulator_bulk_enable(ARRAY_SIZE(sensors_ldo), sensors_ldo) :
2874 regulator_bulk_disable(ARRAY_SIZE(sensors_ldo), sensors_ldo);
2875
2876 if (rc)
2877 pr_err("%s: could not %sable regulators: %d\n",
2878 __func__, on ? "en" : "dis", rc);
2879
2880 return rc;
2881}
2882
2883static int sensors_ldo_enable(void)
2884{
2885 return sensors_ldo_set(1);
2886}
2887
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002888static void sensors_ldo_disable(void)
2889{
Justin Paupore3f40f342011-08-10 18:52:16 -07002890 sensors_ldo_set(0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002891}
Justin Paupore3f40f342011-08-10 18:52:16 -07002892
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002893static struct bma150_platform_data bma150_data = {
2894 .power_on = sensors_ldo_enable,
2895 .power_off = sensors_ldo_disable,
2896};
2897
2898static struct i2c_board_info bma150_board_info[] __initdata = {
2899 {
2900 I2C_BOARD_INFO("bma150", 0x38),
2901 .flags = I2C_CLIENT_WAKE,
2902 .irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
2903 .platform_data = &bma150_data,
2904 },
2905};
2906#endif
2907
2908static struct i2c_board_info msm_i2c_board_info[] = {
2909 {
2910 I2C_BOARD_INFO("m33c01", OPTNAV_I2C_SLAVE_ADDR),
2911 .irq = MSM_GPIO_TO_INT(OPTNAV_IRQ),
2912 .platform_data = &optnav_data,
2913 },
2914 {
2915 I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR),
2916 .platform_data = &adv7520_hdmi_data,
2917 },
2918};
2919
2920static struct i2c_board_info msm_marimba_board_info[] = {
2921 {
2922 I2C_BOARD_INFO("marimba", 0xc),
2923 .platform_data = &marimba_pdata,
2924 }
2925};
2926
2927
2928static struct msm_handset_platform_data hs_platform_data = {
2929 .hs_name = "7k_handset",
2930 .pwr_key_delay_ms = 500, /* 0 will disable end key */
2931};
2932
2933static struct platform_device hs_device = {
2934 .name = "msm-handset",
2935 .id = -1,
2936 .dev = {
2937 .platform_data = &hs_platform_data,
2938 },
2939};
2940
2941static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +05302942 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002943 .idle_supported = 1,
2944 .suspend_supported = 1,
2945 .idle_enabled = 1,
2946 .suspend_enabled = 1,
2947 .latency = 8594,
2948 .residency = 23740,
2949 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05302950 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002951 .idle_supported = 1,
2952 .suspend_supported = 1,
2953 .idle_enabled = 1,
2954 .suspend_enabled = 1,
2955 .latency = 4594,
2956 .residency = 23740,
2957 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05302958 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002959#ifdef CONFIG_MSM_STANDALONE_POWER_COLLAPSE
2960 .idle_supported = 1,
2961 .suspend_supported = 1,
2962 .idle_enabled = 1,
2963 .suspend_enabled = 0,
2964#else /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
2965 .idle_supported = 0,
2966 .suspend_supported = 0,
2967 .idle_enabled = 0,
2968 .suspend_enabled = 0,
2969#endif /*CONFIG_MSM_STANDALONE_POWER_COLLAPSE*/
2970 .latency = 500,
2971 .residency = 6000,
2972 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05302973 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002974 .idle_supported = 1,
2975 .suspend_supported = 1,
2976 .idle_enabled = 0,
2977 .suspend_enabled = 1,
2978 .latency = 443,
2979 .residency = 1098,
2980 },
Murali Nalajalab10363d2012-01-12 16:29:01 +05302981 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002982 .idle_supported = 1,
2983 .suspend_supported = 1,
2984 .idle_enabled = 1,
2985 .suspend_enabled = 1,
2986 .latency = 2,
2987 .residency = 0,
2988 },
2989};
2990
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05302991u32 msm7x30_power_collapse_latency(enum msm_pm_sleep_mode mode)
2992{
2993 switch (mode) {
2994 case MSM_PM_SLEEP_MODE_POWER_COLLAPSE:
2995 return msm_pm_data
2996 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].latency;
2997 case MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN:
2998 return msm_pm_data
2999 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN].latency;
3000 case MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT:
3001 return msm_pm_data
3002 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
3003 case MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT:
3004 return msm_pm_data
3005 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT].latency;
3006 default:
3007 return 0;
3008 }
3009}
3010
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06003011static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
3012 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
3013 .v_addr = (uint32_t *)PAGE_OFFSET,
3014};
3015
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003016static struct resource qsd_spi_resources[] = {
3017 {
3018 .name = "spi_irq_in",
3019 .start = INT_SPI_INPUT,
3020 .end = INT_SPI_INPUT,
3021 .flags = IORESOURCE_IRQ,
3022 },
3023 {
3024 .name = "spi_irq_out",
3025 .start = INT_SPI_OUTPUT,
3026 .end = INT_SPI_OUTPUT,
3027 .flags = IORESOURCE_IRQ,
3028 },
3029 {
3030 .name = "spi_irq_err",
3031 .start = INT_SPI_ERROR,
3032 .end = INT_SPI_ERROR,
3033 .flags = IORESOURCE_IRQ,
3034 },
3035 {
3036 .name = "spi_base",
3037 .start = 0xA8000000,
3038 .end = 0xA8000000 + SZ_4K - 1,
3039 .flags = IORESOURCE_MEM,
3040 },
3041 {
3042 .name = "spidm_channels",
3043 .flags = IORESOURCE_DMA,
3044 },
3045 {
3046 .name = "spidm_crci",
3047 .flags = IORESOURCE_DMA,
3048 },
3049};
3050
3051#define AMDH0_BASE_PHYS 0xAC200000
3052#define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
3053static int msm_qsd_spi_dma_config(void)
3054{
3055 void __iomem *ct_adm_base = 0;
3056 u32 spi_mux = 0;
3057 int ret = 0;
3058
3059 ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
3060 if (!ct_adm_base) {
3061 pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
3062 return -ENOMEM;
3063 }
3064
3065 spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
3066
3067 qsd_spi_resources[4].start = DMOV_USB_CHAN;
3068 qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
3069
3070 switch (spi_mux) {
3071 case (1):
3072 qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
3073 qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
3074 break;
3075 case (2):
3076 qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
3077 qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
3078 break;
3079 case (3):
3080 qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
3081 qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
3082 break;
3083 default:
3084 ret = -ENOENT;
3085 }
3086
3087 iounmap(ct_adm_base);
3088
3089 return ret;
3090}
3091
3092static struct platform_device qsd_device_spi = {
3093 .name = "spi_qsd",
3094 .id = 0,
3095 .num_resources = ARRAY_SIZE(qsd_spi_resources),
3096 .resource = qsd_spi_resources,
3097};
3098
3099#ifdef CONFIG_SPI_QSD
3100static struct spi_board_info lcdc_sharp_spi_board_info[] __initdata = {
3101 {
3102 .modalias = "lcdc_sharp_ls038y7dx01",
3103 .mode = SPI_MODE_1,
3104 .bus_num = 0,
3105 .chip_select = 0,
3106 .max_speed_hz = 26331429,
3107 }
3108};
3109static struct spi_board_info lcdc_toshiba_spi_board_info[] __initdata = {
3110 {
3111 .modalias = "lcdc_toshiba_ltm030dd40",
3112 .mode = SPI_MODE_3|SPI_CS_HIGH,
3113 .bus_num = 0,
3114 .chip_select = 0,
3115 .max_speed_hz = 9963243,
3116 }
3117};
3118#endif
3119
3120static struct msm_gpio qsd_spi_gpio_config_data[] = {
3121 { GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3122 { GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3123 { GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" },
3124 { GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3125};
3126
3127static int msm_qsd_spi_gpio_config(void)
3128{
3129 return msm_gpios_request_enable(qsd_spi_gpio_config_data,
3130 ARRAY_SIZE(qsd_spi_gpio_config_data));
3131}
3132
3133static void msm_qsd_spi_gpio_release(void)
3134{
3135 msm_gpios_disable_free(qsd_spi_gpio_config_data,
3136 ARRAY_SIZE(qsd_spi_gpio_config_data));
3137}
3138
3139static struct msm_spi_platform_data qsd_spi_pdata = {
3140 .max_clock_speed = 26331429,
3141 .gpio_config = msm_qsd_spi_gpio_config,
3142 .gpio_release = msm_qsd_spi_gpio_release,
3143 .dma_config = msm_qsd_spi_dma_config,
3144};
3145
3146static void __init msm_qsd_spi_init(void)
3147{
3148 qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
3149}
3150
3151#ifdef CONFIG_USB_EHCI_MSM_72K
3152static void msm_hsusb_vbus_power(unsigned phy_info, int on)
3153{
3154 int rc;
3155 static int vbus_is_on;
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303156 struct pm8xxx_gpio_init_info usb_vbus = {
3157 PM8058_GPIO_PM_TO_SYS(36),
3158 {
3159 .direction = PM_GPIO_DIR_OUT,
3160 .pull = PM_GPIO_PULL_NO,
3161 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
3162 .output_value = 1,
3163 .vin_sel = 2,
3164 .out_strength = PM_GPIO_STRENGTH_MED,
3165 .function = PM_GPIO_FUNC_NORMAL,
3166 .inv_int_pol = 0,
3167 },
3168 };
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003169
3170 /* If VBUS is already on (or off), do nothing. */
3171 if (unlikely(on == vbus_is_on))
3172 return;
3173
3174 if (on) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05303175 rc = pm8xxx_gpio_config(usb_vbus.gpio, &usb_vbus.config);
3176 if (rc) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003177 pr_err("%s PMIC GPIO 36 write failed\n", __func__);
3178 return;
3179 }
3180 } else {
3181 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(36), 0);
3182 }
3183
3184 vbus_is_on = on;
3185}
3186
3187static struct msm_usb_host_platform_data msm_usb_host_pdata = {
3188 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
3189 .vbus_power = msm_hsusb_vbus_power,
3190 .power_budget = 180,
3191};
3192#endif
3193
3194#ifdef CONFIG_USB_MSM_OTG_72K
3195static int hsusb_rpc_connect(int connect)
3196{
3197 if (connect)
3198 return msm_hsusb_rpc_connect();
3199 else
3200 return msm_hsusb_rpc_close();
3201}
3202#endif
3203
3204#ifdef CONFIG_USB_MSM_OTG_72K
Justin Paupore3f40f342011-08-10 18:52:16 -07003205static struct regulator *vreg_3p3;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003206static int msm_hsusb_ldo_init(int init)
3207{
3208 uint32_t version = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07003209 int def_vol = 3400000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003210
3211 version = socinfo_get_version();
3212
3213 if (SOCINFO_VERSION_MAJOR(version) >= 2 &&
3214 SOCINFO_VERSION_MINOR(version) >= 1) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003215 def_vol = 3075000;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003216 pr_debug("%s: default voltage:%d\n", __func__, def_vol);
3217 }
3218
3219 if (init) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003220 vreg_3p3 = regulator_get(NULL, "usb");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003221 if (IS_ERR(vreg_3p3))
3222 return PTR_ERR(vreg_3p3);
Justin Paupore3f40f342011-08-10 18:52:16 -07003223 regulator_set_voltage(vreg_3p3, def_vol, def_vol);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003224 } else
Justin Paupore3f40f342011-08-10 18:52:16 -07003225 regulator_put(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003226
3227 return 0;
3228}
3229
3230static int msm_hsusb_ldo_enable(int enable)
3231{
3232 static int ldo_status;
3233
3234 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3235 return -ENODEV;
3236
3237 if (ldo_status == enable)
3238 return 0;
3239
3240 ldo_status = enable;
3241
3242 if (enable)
Justin Paupore3f40f342011-08-10 18:52:16 -07003243 return regulator_enable(vreg_3p3);
3244 else
3245 return regulator_disable(vreg_3p3);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003246}
3247
3248static int msm_hsusb_ldo_set_voltage(int mV)
3249{
Justin Paupore3f40f342011-08-10 18:52:16 -07003250 static int cur_voltage;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003251
3252 if (!vreg_3p3 || IS_ERR(vreg_3p3))
3253 return -ENODEV;
3254
3255 if (cur_voltage == mV)
3256 return 0;
3257
3258 cur_voltage = mV;
3259
3260 pr_debug("%s: (%d)\n", __func__, mV);
3261
Justin Paupore3f40f342011-08-10 18:52:16 -07003262 return regulator_set_voltage(vreg_3p3, mV*1000, mV*1000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003263}
3264#endif
3265
3266#ifndef CONFIG_USB_EHCI_MSM_72K
3267static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init);
3268#endif
3269static struct msm_otg_platform_data msm_otg_pdata = {
3270 .rpc_connect = hsusb_rpc_connect,
3271
3272#ifndef CONFIG_USB_EHCI_MSM_72K
3273 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
3274#else
3275 .vbus_power = msm_hsusb_vbus_power,
3276#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003277 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
3278 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
3279 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
3280 .se1_gating = SE1_GATING_DISABLE,
3281 .chg_vbus_draw = hsusb_chg_vbus_draw,
3282 .chg_connected = hsusb_chg_connected,
3283 .chg_init = hsusb_chg_init,
3284 .ldo_enable = msm_hsusb_ldo_enable,
3285 .ldo_init = msm_hsusb_ldo_init,
3286 .ldo_set_voltage = msm_hsusb_ldo_set_voltage,
3287};
3288
3289#ifdef CONFIG_USB_GADGET
3290static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
3291 .is_phy_status_timer_on = 1,
3292};
3293#endif
3294#ifndef CONFIG_USB_EHCI_MSM_72K
3295typedef void (*notify_vbus_state) (int);
3296notify_vbus_state notify_vbus_state_func_ptr;
3297int vbus_on_irq;
3298static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
3299{
3300 pr_info("%s: vbus notification from pmic\n", __func__);
3301
3302 (*notify_vbus_state_func_ptr) (1);
3303
3304 return IRQ_HANDLED;
3305}
3306static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
3307{
3308 int ret;
3309
3310 if (init) {
3311 if (!callback)
3312 return -ENODEV;
3313
3314 notify_vbus_state_func_ptr = callback;
3315 vbus_on_irq = platform_get_irq_byname(&msm_device_otg,
3316 "vbus_on");
3317 if (vbus_on_irq <= 0) {
3318 pr_err("%s: unable to get vbus on irq\n", __func__);
3319 return -ENODEV;
3320 }
3321
3322 ret = request_any_context_irq(vbus_on_irq, pmic_vbus_on_irq,
3323 IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
3324 if (ret < 0) {
3325 pr_info("%s: request_irq for vbus_on"
3326 "interrupt failed\n", __func__);
3327 return ret;
3328 }
3329 msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
3330 return 0;
3331 } else {
3332 free_irq(vbus_on_irq, 0);
3333 notify_vbus_state_func_ptr = NULL;
3334 return 0;
3335 }
3336}
3337#endif
3338
3339static struct android_pmem_platform_data android_pmem_pdata = {
3340 .name = "pmem",
3341 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
3342 .cached = 1,
3343 .memory_type = MEMTYPE_EBI0,
3344};
3345
3346static struct platform_device android_pmem_device = {
3347 .name = "android_pmem",
3348 .id = 0,
3349 .dev = { .platform_data = &android_pmem_pdata },
3350};
3351
3352#ifndef CONFIG_SPI_QSD
3353static int lcdc_gpio_array_num[] = {
3354 45, /* spi_clk */
3355 46, /* spi_cs */
3356 47, /* spi_mosi */
3357 48, /* spi_miso */
3358 };
3359
3360static struct msm_gpio lcdc_gpio_config_data[] = {
3361 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
3362 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
3363 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
3364 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
3365};
3366
3367static void lcdc_config_gpios(int enable)
3368{
3369 if (enable) {
3370 msm_gpios_request_enable(lcdc_gpio_config_data,
3371 ARRAY_SIZE(
3372 lcdc_gpio_config_data));
3373 } else
3374 msm_gpios_disable_free(lcdc_gpio_config_data,
3375 ARRAY_SIZE(
3376 lcdc_gpio_config_data));
3377}
3378#endif
3379
3380static struct msm_panel_common_pdata lcdc_sharp_panel_data = {
3381#ifndef CONFIG_SPI_QSD
3382 .panel_config_gpio = lcdc_config_gpios,
3383 .gpio_num = lcdc_gpio_array_num,
3384#endif
3385 .gpio = 2, /* LPG PMIC_GPIO26 channel number */
3386};
3387
3388static struct platform_device lcdc_sharp_panel_device = {
3389 .name = "lcdc_sharp_wvga",
3390 .id = 0,
3391 .dev = {
3392 .platform_data = &lcdc_sharp_panel_data,
3393 }
3394};
3395
3396static struct msm_gpio dtv_panel_irq_gpios[] = {
3397 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
3398 "hdmi_int" },
3399};
3400
3401static struct msm_gpio dtv_panel_gpios[] = {
3402 { GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
3403 { GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
3404 { GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
3405 { GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
3406 { GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
3407 { GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
3408 { GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
3409 { GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
3410 { GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
3411 { GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
3412 { GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
3413 { GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
3414 { GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
3415 { GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
3416 { GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
3417 { GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
3418 { GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
3419 { GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
3420 { GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
3421 { GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
3422 { GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
3423 { GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
3424 { GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
3425 { GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
3426 { GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
3427 { GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
3428 { GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
3429 { GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
3430 { GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
3431 { GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
3432 { GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
3433 { GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
3434};
3435
3436
3437#ifdef HDMI_RESET
3438static unsigned dtv_reset_gpio =
3439 GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3440#endif
3441
Justin Paupore3f40f342011-08-10 18:52:16 -07003442static struct regulator_bulk_data hdmi_core_regs[] = {
3443 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3444};
3445
3446static struct regulator_bulk_data hdmi_comm_regs[] = {
3447 { .supply = "ldo8", .min_uV = 1800000, .max_uV = 1800000 },
3448 { .supply = "ldo10", .min_uV = 2600000, .max_uV = 2600000 },
3449};
3450
3451static struct regulator_bulk_data hdmi_cec_regs[] = {
3452 { .supply = "ldo17", .min_uV = 2600000, .max_uV = 2600000 },
3453};
3454
3455static int __init hdmi_init_regs(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003456{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003457 int rc;
3458
Justin Paupore3f40f342011-08-10 18:52:16 -07003459 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_core_regs),
3460 hdmi_core_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003461
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003462 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07003463 pr_err("%s: could not get %s regulators: %d\n",
3464 __func__, "core", rc);
3465 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003466 }
3467
Justin Paupore3f40f342011-08-10 18:52:16 -07003468 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_core_regs),
3469 hdmi_core_regs);
3470
3471 if (rc) {
3472 pr_err("%s: could not set %s voltages: %d\n",
3473 __func__, "core", rc);
3474 goto free_core;
3475 }
3476
3477 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_comm_regs),
3478 hdmi_comm_regs);
3479
3480 if (rc) {
3481 pr_err("%s: could not get %s regulators: %d\n",
3482 __func__, "comm", rc);
3483 goto free_core;
3484 }
3485
3486 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_comm_regs),
3487 hdmi_comm_regs);
3488
3489 if (rc) {
3490 pr_err("%s: could not set %s voltages: %d\n",
3491 __func__, "comm", rc);
3492 goto free_comm;
3493 }
3494
3495 rc = regulator_bulk_get(NULL, ARRAY_SIZE(hdmi_cec_regs),
3496 hdmi_cec_regs);
3497
3498 if (rc) {
3499 pr_err("%s: could not get %s regulators: %d\n",
3500 __func__, "cec", rc);
3501 goto free_comm;
3502 }
3503
3504 rc = regulator_bulk_set_voltage(ARRAY_SIZE(hdmi_cec_regs),
3505 hdmi_cec_regs);
3506
3507 if (rc) {
3508 pr_err("%s: could not set %s voltages: %d\n",
3509 __func__, "cec", rc);
3510 goto free_cec;
3511 }
3512
3513 return 0;
3514
3515free_cec:
3516 regulator_bulk_free(ARRAY_SIZE(hdmi_cec_regs), hdmi_cec_regs);
3517free_comm:
3518 regulator_bulk_free(ARRAY_SIZE(hdmi_comm_regs), hdmi_comm_regs);
3519free_core:
3520 regulator_bulk_free(ARRAY_SIZE(hdmi_core_regs), hdmi_core_regs);
3521out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003522 return rc;
3523}
3524
Justin Paupore3f40f342011-08-10 18:52:16 -07003525static int hdmi_init_irq(void)
3526{
3527 int rc = msm_gpios_enable(dtv_panel_irq_gpios,
3528 ARRAY_SIZE(dtv_panel_irq_gpios));
3529 if (rc < 0) {
3530 pr_err("%s: gpio enable failed: %d\n", __func__, rc);
3531 return rc;
3532 }
3533 pr_info("%s\n", __func__);
3534
3535 return 0;
3536}
3537
3538static int hdmi_enable_5v(int on)
3539{
3540 int pmic_gpio_hdmi_5v_en ;
3541
3542 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa() ||
3543 machine_is_msm7x30_fluid())
3544 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V2 ;
3545 else
3546 pmic_gpio_hdmi_5v_en = PMIC_GPIO_HDMI_5V_EN_V3 ;
3547
3548 pr_info("%s: %d\n", __func__, on);
3549 if (on) {
3550 int rc;
3551 rc = gpio_request(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en),
3552 "hdmi_5V_en");
3553 if (rc) {
3554 pr_err("%s PMIC_GPIO_HDMI_5V_EN gpio_request failed\n",
3555 __func__);
3556 return rc;
3557 }
3558 gpio_set_value_cansleep(
3559 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 1);
3560 } else {
3561 gpio_set_value_cansleep(
3562 PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en), 0);
3563 gpio_free(PM8058_GPIO_PM_TO_SYS(pmic_gpio_hdmi_5v_en));
3564 }
3565 return 0;
3566}
3567
3568static int hdmi_comm_power(int on, int show)
3569{
3570 if (show)
3571 pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
3572 return on ?
3573 regulator_bulk_enable(ARRAY_SIZE(hdmi_comm_regs),
3574 hdmi_comm_regs) :
3575 regulator_bulk_disable(ARRAY_SIZE(hdmi_comm_regs),
3576 hdmi_comm_regs);
3577}
3578
3579static int hdmi_core_power(int on, int show)
3580{
3581 if (show)
3582 pr_info("%s: %d <LDO8>\n", __func__, on);
3583 return on ?
3584 regulator_bulk_enable(ARRAY_SIZE(hdmi_core_regs),
3585 hdmi_core_regs) :
3586 regulator_bulk_disable(ARRAY_SIZE(hdmi_core_regs),
3587 hdmi_core_regs);
3588}
3589
3590static int hdmi_cec_power(int on)
3591{
3592 pr_info("%s: %d <LDO17>\n", __func__, on);
3593 return on ? regulator_bulk_enable(ARRAY_SIZE(hdmi_cec_regs),
3594 hdmi_cec_regs) :
3595 regulator_bulk_disable(ARRAY_SIZE(hdmi_cec_regs),
3596 hdmi_cec_regs);
3597}
3598
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003599#if defined(CONFIG_FB_MSM_HDMI_ADV7520_PANEL) || defined(CONFIG_BOSCH_BMA150)
3600/* there is an i2c address conflict between adv7520 and bma150 sensor after
3601 * power up on fluid. As a solution, the default address of adv7520's packet
3602 * memory is changed as soon as possible
3603 */
3604static int __init fluid_i2c_address_fixup(void)
3605{
3606 unsigned char wBuff[16];
3607 unsigned char rBuff[16];
3608 struct i2c_msg msgs[3];
3609 int res;
3610 int rc = -EINVAL;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003611 struct i2c_adapter *adapter;
3612
3613 if (machine_is_msm7x30_fluid()) {
3614 adapter = i2c_get_adapter(0);
3615 if (!adapter) {
3616 pr_err("%s: invalid i2c adapter\n", __func__);
3617 return PTR_ERR(adapter);
3618 }
3619
3620 /* turn on LDO8 */
Justin Paupore3f40f342011-08-10 18:52:16 -07003621 rc = hdmi_core_power(1, 0);
3622 if (rc) {
3623 pr_err("%s: could not enable hdmi core regs: %d",
3624 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003625 goto adapter_put;
3626 }
3627
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003628 /* change packet memory address to 0x74 */
3629 wBuff[0] = 0x45;
3630 wBuff[1] = 0x74;
3631
3632 msgs[0].addr = ADV7520_I2C_ADDR;
3633 msgs[0].flags = 0;
3634 msgs[0].buf = (unsigned char *) wBuff;
3635 msgs[0].len = 2;
3636
3637 res = i2c_transfer(adapter, msgs, 1);
3638 if (res != 1) {
3639 pr_err("%s: error writing adv7520\n", __func__);
3640 goto ldo8_disable;
3641 }
3642
3643 /* powerdown adv7520 using bit 6 */
3644 /* i2c read first */
3645 wBuff[0] = 0x41;
3646
3647 msgs[0].addr = ADV7520_I2C_ADDR;
3648 msgs[0].flags = 0;
3649 msgs[0].buf = (unsigned char *) wBuff;
3650 msgs[0].len = 1;
3651
3652 msgs[1].addr = ADV7520_I2C_ADDR;
3653 msgs[1].flags = I2C_M_RD;
3654 msgs[1].buf = rBuff;
3655 msgs[1].len = 1;
3656 res = i2c_transfer(adapter, msgs, 2);
3657 if (res != 2) {
3658 pr_err("%s: error reading adv7520\n", __func__);
3659 goto ldo8_disable;
3660 }
3661
3662 /* i2c write back */
3663 wBuff[0] = 0x41;
3664 wBuff[1] = rBuff[0] | 0x40;
3665
3666 msgs[0].addr = ADV7520_I2C_ADDR;
3667 msgs[0].flags = 0;
3668 msgs[0].buf = (unsigned char *) wBuff;
3669 msgs[0].len = 2;
3670
3671 res = i2c_transfer(adapter, msgs, 1);
3672 if (res != 1) {
3673 pr_err("%s: error writing adv7520\n", __func__);
3674 goto ldo8_disable;
3675 }
3676
3677 /* for successful fixup, we release the i2c adapter */
3678 /* but leave ldo8 on so that the adv7520 is not repowered */
3679 i2c_put_adapter(adapter);
3680 pr_info("%s: fluid i2c address conflict resolved\n", __func__);
3681 }
3682 return 0;
3683
3684ldo8_disable:
Justin Paupore3f40f342011-08-10 18:52:16 -07003685 hdmi_core_power(0, 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003686adapter_put:
3687 i2c_put_adapter(adapter);
3688 return rc;
3689}
3690fs_initcall_sync(fluid_i2c_address_fixup);
3691#endif
3692
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003693static bool hdmi_check_hdcp_hw_support(void)
3694{
3695 if (machine_is_msm7x30_fluid())
3696 return false;
3697 else
3698 return true;
3699}
3700
3701static int dtv_panel_power(int on)
3702{
3703 int flag_on = !!on;
3704 static int dtv_power_save_on;
3705 int rc;
3706
3707 if (dtv_power_save_on == flag_on)
3708 return 0;
3709
3710 dtv_power_save_on = flag_on;
3711 pr_info("%s: %d\n", __func__, on);
3712
3713#ifdef HDMI_RESET
3714 if (on) {
3715 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
3716 rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
3717 if (rc) {
3718 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
3719 __func__, dtv_reset_gpio, rc);
3720 return rc;
3721 }
3722
3723 /* bring reset line low to hold reset*/
3724 gpio_set_value(37, 0);
3725 }
3726#endif
3727
3728 if (on) {
3729 rc = msm_gpios_enable(dtv_panel_gpios,
3730 ARRAY_SIZE(dtv_panel_gpios));
3731 if (rc < 0) {
3732 printk(KERN_ERR "%s: gpio enable failed: %d\n",
3733 __func__, rc);
3734 return rc;
3735 }
3736 } else {
3737 rc = msm_gpios_disable(dtv_panel_gpios,
3738 ARRAY_SIZE(dtv_panel_gpios));
3739 if (rc < 0) {
3740 printk(KERN_ERR "%s: gpio disable failed: %d\n",
3741 __func__, rc);
3742 return rc;
3743 }
3744 }
3745
3746 mdelay(5); /* ensure power is stable */
3747
3748#ifdef HDMI_RESET
3749 if (on) {
3750 gpio_set_value(37, 1); /* bring reset line high */
3751 mdelay(10); /* 10 msec before IO can be accessed */
3752 }
3753#endif
3754
3755 return rc;
3756}
3757
3758static struct lcdc_platform_data dtv_pdata = {
3759 .lcdc_power_save = dtv_panel_power,
3760};
3761
3762static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
3763 .inject_rx_on_wakeup = 1,
3764 .rx_to_inject = 0xFD,
3765};
3766
3767static struct resource msm_fb_resources[] = {
3768 {
3769 .flags = IORESOURCE_DMA,
3770 }
3771};
3772
3773static int msm_fb_detect_panel(const char *name)
3774{
3775 if (machine_is_msm7x30_fluid()) {
3776 if (!strcmp(name, "lcdc_sharp_wvga_pt"))
3777 return 0;
3778 } else {
3779 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
3780 return -EPERM;
3781 else if (!strncmp(name, "lcdc_toshiba_wvga_pt", 20))
3782 return 0;
3783 else if (!strcmp(name, "mddi_orise"))
3784 return -EPERM;
3785 else if (!strcmp(name, "mddi_quickvx"))
3786 return -EPERM;
3787 }
3788 return -ENODEV;
3789}
3790
3791static struct msm_fb_platform_data msm_fb_pdata = {
3792 .detect_client = msm_fb_detect_panel,
3793 .mddi_prescan = 1,
3794};
3795
3796static struct platform_device msm_fb_device = {
3797 .name = "msm_fb",
3798 .id = 0,
3799 .num_resources = ARRAY_SIZE(msm_fb_resources),
3800 .resource = msm_fb_resources,
3801 .dev = {
3802 .platform_data = &msm_fb_pdata,
3803 }
3804};
3805
3806static struct platform_device msm_migrate_pages_device = {
3807 .name = "msm_migrate_pages",
3808 .id = -1,
3809};
3810
3811static struct android_pmem_platform_data android_pmem_adsp_pdata = {
3812 .name = "pmem_adsp",
3813 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
3814 .cached = 0,
3815 .memory_type = MEMTYPE_EBI0,
3816};
3817
3818static struct android_pmem_platform_data android_pmem_audio_pdata = {
3819 .name = "pmem_audio",
3820 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
3821 .cached = 0,
3822 .memory_type = MEMTYPE_EBI0,
3823};
3824
3825static struct platform_device android_pmem_adsp_device = {
3826 .name = "android_pmem",
3827 .id = 2,
3828 .dev = { .platform_data = &android_pmem_adsp_pdata },
3829};
3830
3831static struct platform_device android_pmem_audio_device = {
3832 .name = "android_pmem",
3833 .id = 4,
3834 .dev = { .platform_data = &android_pmem_audio_pdata },
3835};
3836
3837#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3838 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
3839 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3840 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3841
3842#define QCE_SIZE 0x10000
3843#define QCE_0_BASE 0xA8400000
3844
3845#define QCE_HW_KEY_SUPPORT 1
3846#define QCE_SHA_HMAC_SUPPORT 0
3847#define QCE_SHARE_CE_RESOURCE 0
3848#define QCE_CE_SHARED 0
3849
3850static struct resource qcrypto_resources[] = {
3851 [0] = {
3852 .start = QCE_0_BASE,
3853 .end = QCE_0_BASE + QCE_SIZE - 1,
3854 .flags = IORESOURCE_MEM,
3855 },
3856 [1] = {
3857 .name = "crypto_channels",
3858 .start = DMOV_CE_IN_CHAN,
3859 .end = DMOV_CE_OUT_CHAN,
3860 .flags = IORESOURCE_DMA,
3861 },
3862 [2] = {
3863 .name = "crypto_crci_in",
3864 .start = DMOV_CE_IN_CRCI,
3865 .end = DMOV_CE_IN_CRCI,
3866 .flags = IORESOURCE_DMA,
3867 },
3868 [3] = {
3869 .name = "crypto_crci_out",
3870 .start = DMOV_CE_OUT_CRCI,
3871 .end = DMOV_CE_OUT_CRCI,
3872 .flags = IORESOURCE_DMA,
3873 },
3874 [4] = {
3875 .name = "crypto_crci_hash",
3876 .start = DMOV_CE_HASH_CRCI,
3877 .end = DMOV_CE_HASH_CRCI,
3878 .flags = IORESOURCE_DMA,
3879 },
3880};
3881
3882static struct resource qcedev_resources[] = {
3883 [0] = {
3884 .start = QCE_0_BASE,
3885 .end = QCE_0_BASE + QCE_SIZE - 1,
3886 .flags = IORESOURCE_MEM,
3887 },
3888 [1] = {
3889 .name = "crypto_channels",
3890 .start = DMOV_CE_IN_CHAN,
3891 .end = DMOV_CE_OUT_CHAN,
3892 .flags = IORESOURCE_DMA,
3893 },
3894 [2] = {
3895 .name = "crypto_crci_in",
3896 .start = DMOV_CE_IN_CRCI,
3897 .end = DMOV_CE_IN_CRCI,
3898 .flags = IORESOURCE_DMA,
3899 },
3900 [3] = {
3901 .name = "crypto_crci_out",
3902 .start = DMOV_CE_OUT_CRCI,
3903 .end = DMOV_CE_OUT_CRCI,
3904 .flags = IORESOURCE_DMA,
3905 },
3906 [4] = {
3907 .name = "crypto_crci_hash",
3908 .start = DMOV_CE_HASH_CRCI,
3909 .end = DMOV_CE_HASH_CRCI,
3910 .flags = IORESOURCE_DMA,
3911 },
3912};
3913
3914#endif
3915
3916#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3917 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
3918
3919static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
3920 .ce_shared = QCE_CE_SHARED,
3921 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
3922 .hw_key_support = QCE_HW_KEY_SUPPORT,
3923 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08003924 /* Bus Scaling declaration*/
3925 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003926};
3927
3928static struct platform_device qcrypto_device = {
3929 .name = "qcrypto",
3930 .id = 0,
3931 .num_resources = ARRAY_SIZE(qcrypto_resources),
3932 .resource = qcrypto_resources,
3933 .dev = {
3934 .coherent_dma_mask = DMA_BIT_MASK(32),
3935 .platform_data = &qcrypto_ce_hw_suppport,
3936 },
3937};
3938#endif
3939
3940#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3941 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3942
3943static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
3944 .ce_shared = QCE_CE_SHARED,
3945 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
3946 .hw_key_support = QCE_HW_KEY_SUPPORT,
3947 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
Ramesh Masavarapu49259682011-12-02 14:00:18 -08003948 /* Bus Scaling declaration*/
3949 .bus_scale_table = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003950};
3951static struct platform_device qcedev_device = {
3952 .name = "qce",
3953 .id = 0,
3954 .num_resources = ARRAY_SIZE(qcedev_resources),
3955 .resource = qcedev_resources,
3956 .dev = {
3957 .coherent_dma_mask = DMA_BIT_MASK(32),
3958 .platform_data = &qcedev_ce_hw_suppport,
3959 },
3960};
3961#endif
3962
3963static int mddi_toshiba_pmic_bl(int level)
3964{
3965 int ret = -EPERM;
3966
3967 ret = pmic_set_led_intensity(LED_LCD, level);
3968
3969 if (ret)
3970 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
3971 __func__);
3972 return ret;
3973}
3974
3975static struct msm_panel_common_pdata mddi_toshiba_pdata = {
3976 .pmic_backlight = mddi_toshiba_pmic_bl,
3977};
3978
3979static struct platform_device mddi_toshiba_device = {
3980 .name = "mddi_toshiba",
3981 .id = 0,
3982 .dev = {
3983 .platform_data = &mddi_toshiba_pdata,
3984 }
3985};
3986
3987static unsigned wega_reset_gpio =
3988 GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3989
3990static struct msm_gpio fluid_vee_reset_gpio[] = {
3991 { GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
3992};
3993
3994static unsigned char quickvx_mddi_client = 1, other_mddi_client = 1;
3995static unsigned char quickvx_ldo_enabled;
3996
3997static unsigned quickvx_vlp_gpio =
3998 GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
3999
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304000static struct pm8xxx_gpio_init_info pmic_quickvx_clk_gpio = {
4001 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_QUICKVX_CLK),
4002 {
4003 .direction = PM_GPIO_DIR_OUT,
4004 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
4005 .output_value = 1,
4006 .pull = PM_GPIO_PULL_NO,
4007 .vin_sel = PM8058_GPIO_VIN_S3,
4008 .out_strength = PM_GPIO_STRENGTH_HIGH,
4009 .function = PM_GPIO_FUNC_2,
4010 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004011};
4012
Justin Paupore3f40f342011-08-10 18:52:16 -07004013static struct regulator *mddi_ldo20;
4014static struct regulator *mddi_ldo12;
4015static struct regulator *mddi_ldo16;
4016static struct regulator *mddi_ldo6;
4017static struct regulator *mddi_lcd;
4018
4019static int display_common_init(void)
4020{
4021 struct regulator_bulk_data regs[5] = {
4022 { .supply = "ldo20", /* voltage set in display_common_power */},
4023 { .supply = "ldo12", .min_uV = 1800000, .max_uV = 1800000 },
4024 { .supply = "ldo6", .min_uV = 3075000, .max_uV = 3400000 },
4025 { .supply = "ldo16", .min_uV = 2600000, .max_uV = 2600000 },
4026 { .supply = NULL, /* mddi_lcd, initialized below */ },
4027 };
4028
4029 int rc = 0;
4030
4031 if (machine_is_msm7x30_fluid()) {
4032 /* lcd: LDO8 @1.8V */
4033 regs[4].supply = "ldo8";
4034 regs[4].min_uV = 1800000;
4035 regs[4].max_uV = 1800000;
4036 } else {
4037 /* lcd: LDO15 @3.1V */
4038 regs[4].supply = "ldo15";
4039 regs[4].min_uV = 3100000;
4040 regs[4].max_uV = 3100000;
4041 }
4042
4043 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4044 if (rc) {
4045 pr_err("%s: regulator_bulk_get failed: %d\n",
4046 __func__, rc);
4047 goto bail;
4048 }
4049
4050 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4051 if (rc) {
4052 pr_err("%s: regulator_bulk_set_voltage failed: %d\n",
4053 __func__, rc);
4054 goto put_regs;
4055 }
4056
4057 mddi_ldo20 = regs[0].consumer;
4058 mddi_ldo12 = regs[1].consumer;
4059 mddi_ldo6 = regs[2].consumer;
4060 mddi_ldo16 = regs[3].consumer;
4061 mddi_lcd = regs[4].consumer;
4062
4063 return rc;
4064
4065put_regs:
4066 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4067bail:
4068 return rc;
4069}
4070
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004071static int display_common_power(int on)
4072{
4073 int rc = 0, flag_on = !!on;
4074 static int display_common_power_save_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004075 static bool display_regs_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004076
4077 if (display_common_power_save_on == flag_on)
4078 return 0;
4079
4080 display_common_power_save_on = flag_on;
4081
Justin Paupore3f40f342011-08-10 18:52:16 -07004082 if (unlikely(!display_regs_initialized)) {
4083 rc = display_common_init();
4084 if (rc) {
4085 pr_err("%s: regulator init failed: %d\n",
4086 __func__, rc);
4087 return rc;
4088 }
4089 display_regs_initialized = true;
4090 }
4091
4092
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004093 if (on) {
4094 /* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
4095 rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
4096 if (rc) {
4097 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4098 __func__, wega_reset_gpio, rc);
4099 return rc;
4100 }
4101
4102 /* bring reset line low to hold reset*/
4103 gpio_set_value(180, 0);
4104
4105 if (quickvx_mddi_client) {
4106 /* QuickVX chip -- VLP pin -- gpio 97 */
4107 rc = gpio_tlmm_config(quickvx_vlp_gpio,
4108 GPIO_CFG_ENABLE);
4109 if (rc) {
4110 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
4111 __func__, quickvx_vlp_gpio, rc);
4112 return rc;
4113 }
4114
4115 /* bring QuickVX VLP line low */
4116 gpio_set_value(97, 0);
4117
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304118 rc = pm8xxx_gpio_config(pmic_quickvx_clk_gpio.gpio,
4119 &pmic_quickvx_clk_gpio.config);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004120 if (rc) {
Anirudh Ghayalc2019332011-11-12 06:29:10 +05304121 pr_err("%s: pm8xxx_gpio_config(%#x)=%d\n",
4122 __func__, pmic_quickvx_clk_gpio.gpio,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004123 rc);
4124 return rc;
4125 }
4126
4127 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4128 PMIC_GPIO_QUICKVX_CLK), 0);
4129 }
4130 }
4131
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004132 if (quickvx_mddi_client)
Justin Paupore3f40f342011-08-10 18:52:16 -07004133 rc = regulator_set_voltage(mddi_ldo20, 1800000, 1800000);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004134 else
Justin Paupore3f40f342011-08-10 18:52:16 -07004135 rc = regulator_set_voltage(mddi_ldo20, 1500000, 1500000);
4136
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004137 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004138 pr_err("%s: could not set voltage for ldo20: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004139 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07004140 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004141 }
4142
4143 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004144 rc = regulator_enable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004145 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004146 pr_err("%s: LDO20 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004147 __func__, rc);
4148 return rc;
4149 }
4150
Justin Paupore3f40f342011-08-10 18:52:16 -07004151 rc = regulator_enable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004152 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004153 pr_err("%s: LDO12 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004154 __func__, rc);
4155 return rc;
4156 }
4157
4158 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004159 rc = regulator_enable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004160 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004161 pr_err("%s: LDO16 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004162 __func__, rc);
4163 return rc;
4164 }
4165 }
4166
Justin Paupore3f40f342011-08-10 18:52:16 -07004167 if (quickvx_ldo_enabled) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004168 /* Disable LDO6 during display ON */
Justin Paupore3f40f342011-08-10 18:52:16 -07004169 rc = regulator_disable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004170 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004171 pr_err("%s: LDO6 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004172 __func__, rc);
4173 return rc;
4174 }
4175 quickvx_ldo_enabled = 0;
4176 }
4177
Justin Paupore3f40f342011-08-10 18:52:16 -07004178 rc = regulator_enable(mddi_lcd);
4179 if (rc) {
4180 pr_err("%s: LCD regulator enable failed (%d)\n",
4181 __func__, rc);
4182 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004183 }
4184
4185 mdelay(5); /* ensure power is stable */
4186
4187 if (machine_is_msm7x30_fluid()) {
4188 rc = msm_gpios_request_enable(fluid_vee_reset_gpio,
4189 ARRAY_SIZE(fluid_vee_reset_gpio));
4190 if (rc)
4191 pr_err("%s gpio_request_enable failed rc=%d\n",
4192 __func__, rc);
4193 else {
4194 /* assert vee reset_n */
4195 gpio_set_value(20, 1);
4196 gpio_set_value(20, 0);
4197 mdelay(1);
4198 gpio_set_value(20, 1);
4199 }
4200 }
4201
4202 gpio_set_value(180, 1); /* bring reset line high */
4203 mdelay(10); /* 10 msec before IO can be accessed */
4204
4205 if (quickvx_mddi_client) {
4206 gpio_set_value(97, 1);
4207 msleep(2);
4208 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4209 PMIC_GPIO_QUICKVX_CLK), 1);
4210 msleep(2);
4211 }
4212
4213 rc = pmapp_display_clock_config(1);
4214 if (rc) {
4215 pr_err("%s pmapp_display_clock_config rc=%d\n",
4216 __func__, rc);
4217 return rc;
4218 }
4219
4220 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004221 rc = regulator_disable(mddi_ldo20);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004222 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004223 pr_err("%s: LDO20 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004224 __func__, rc);
4225 return rc;
4226 }
4227
4228
4229 if (other_mddi_client) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004230 rc = regulator_disable(mddi_ldo16);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004231 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004232 pr_err("%s: LDO16 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004233 __func__, rc);
4234 return rc;
4235 }
4236 }
4237
4238 if (quickvx_mddi_client && !quickvx_ldo_enabled) {
4239 /* Enable LDO6 during display OFF for
4240 Quicklogic chip to sleep with data retention */
Justin Paupore3f40f342011-08-10 18:52:16 -07004241 rc = regulator_enable(mddi_ldo6);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004242 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004243 pr_err("%s: LDO6 regulator enable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004244 __func__, rc);
4245 return rc;
4246 }
4247 quickvx_ldo_enabled = 1;
4248 }
4249
4250 gpio_set_value(180, 0); /* bring reset line low */
4251
4252 if (quickvx_mddi_client) {
4253 gpio_set_value(97, 0);
4254 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4255 PMIC_GPIO_QUICKVX_CLK), 0);
4256 }
4257
Justin Paupore3f40f342011-08-10 18:52:16 -07004258 rc = regulator_disable(mddi_lcd);
4259 if (rc) {
4260 pr_err("%s: LCD regulator disable failed (%d)\n",
4261 __func__, rc);
4262 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004263 }
4264
4265 mdelay(5); /* ensure power is stable */
4266
Justin Paupore3f40f342011-08-10 18:52:16 -07004267 rc = regulator_disable(mddi_ldo12);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004268 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004269 pr_err("%s: LDO12 regulator disable failed (%d)\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004270 __func__, rc);
4271 return rc;
4272 }
4273
4274 if (machine_is_msm7x30_fluid()) {
4275 msm_gpios_disable_free(fluid_vee_reset_gpio,
4276 ARRAY_SIZE(fluid_vee_reset_gpio));
4277 }
4278
4279 rc = pmapp_display_clock_config(0);
4280 if (rc) {
4281 pr_err("%s pmapp_display_clock_config rc=%d\n",
4282 __func__, rc);
4283 return rc;
4284 }
4285 }
4286
4287 return rc;
4288}
4289
4290static int msm_fb_mddi_sel_clk(u32 *clk_rate)
4291{
4292 *clk_rate *= 2;
4293 return 0;
4294}
4295
4296static int msm_fb_mddi_client_power(u32 client_id)
4297{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004298 printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
4299 /* Check if it is Quicklogic client */
4300 if (client_id == 0xc5835800) {
4301 printk(KERN_NOTICE "\n Quicklogic MDDI client");
4302 other_mddi_client = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004303 } else {
4304 printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
4305 quickvx_mddi_client = 0;
4306 gpio_set_value(97, 0);
4307 gpio_set_value_cansleep(PM8058_GPIO_PM_TO_SYS(
4308 PMIC_GPIO_QUICKVX_CLK), 0);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004309 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004310
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004311 return 0;
4312}
4313
4314static struct mddi_platform_data mddi_pdata = {
4315 .mddi_power_save = display_common_power,
4316 .mddi_sel_clk = msm_fb_mddi_sel_clk,
4317 .mddi_client_power = msm_fb_mddi_client_power,
4318};
4319
4320int mdp_core_clk_rate_table[] = {
4321 122880000,
4322 122880000,
Pradeep Jilagam3cc12f92011-07-26 22:25:18 +05304323 192000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004324 192000000,
4325};
4326
4327static struct msm_panel_common_pdata mdp_pdata = {
4328 .hw_revision_addr = 0xac001270,
4329 .gpio = 30,
4330 .mdp_core_clk_rate = 122880000,
4331 .mdp_core_clk_table = mdp_core_clk_rate_table,
4332 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -07004333 .mdp_rev = MDP_REV_40,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004334};
4335
4336static int lcd_panel_spi_gpio_num[] = {
4337 45, /* spi_clk */
4338 46, /* spi_cs */
4339 47, /* spi_mosi */
4340 48, /* spi_miso */
4341 };
4342
4343static struct msm_gpio lcd_panel_gpios[] = {
4344/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
4345 * input. if there is a hardware revision; we should reassign this GPIO to a
4346 * new open line; and removing it will just ensure that this will be missed in
4347 * the future.
4348 { GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
4349 */
4350 { GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
4351 { GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
4352 { GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
4353 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4354 { GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
4355 { GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
4356 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4357#ifndef CONFIG_SPI_QSD
4358 { GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
4359 { GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
4360 { GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
4361 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
4362#endif
4363 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4364 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4365 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4366 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4367 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4368 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4369 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4370 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4371 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4372 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4373 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4374 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4375 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4376 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4377 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4378 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4379 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4380 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4381 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4382 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4383};
4384
4385static struct msm_gpio lcd_sharp_panel_gpios[] = {
4386 { GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
4387 { GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
4388 { GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
4389 { GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
4390 { GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
4391 { GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
4392 { GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
4393 { GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
4394 { GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
4395 { GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
4396 { GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
4397 { GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
4398 { GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
4399 { GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
4400 { GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
4401 { GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
4402 { GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
4403 { GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
4404 { GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
4405 { GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
4406 { GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
4407 { GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
4408};
4409
4410static int lcdc_toshiba_panel_power(int on)
4411{
4412 int rc, i;
4413 struct msm_gpio *gp;
4414
4415 rc = display_common_power(on);
4416 if (rc < 0) {
4417 printk(KERN_ERR "%s display_common_power failed: %d\n",
4418 __func__, rc);
4419 return rc;
4420 }
4421
4422 if (on) {
4423 rc = msm_gpios_enable(lcd_panel_gpios,
4424 ARRAY_SIZE(lcd_panel_gpios));
4425 if (rc < 0) {
4426 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4427 __func__, rc);
4428 }
4429 } else { /* off */
4430 gp = lcd_panel_gpios;
4431 for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
4432 /* ouput low */
4433 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4434 gp++;
4435 }
4436 }
4437
4438 return rc;
4439}
4440
4441static int lcdc_sharp_panel_power(int on)
4442{
4443 int rc, i;
4444 struct msm_gpio *gp;
4445
4446 rc = display_common_power(on);
4447 if (rc < 0) {
4448 printk(KERN_ERR "%s display_common_power failed: %d\n",
4449 __func__, rc);
4450 return rc;
4451 }
4452
4453 if (on) {
4454 rc = msm_gpios_enable(lcd_sharp_panel_gpios,
4455 ARRAY_SIZE(lcd_sharp_panel_gpios));
4456 if (rc < 0) {
4457 printk(KERN_ERR "%s: gpio enable failed: %d\n",
4458 __func__, rc);
4459 }
4460 } else { /* off */
4461 gp = lcd_sharp_panel_gpios;
4462 for (i = 0; i < ARRAY_SIZE(lcd_sharp_panel_gpios); i++) {
4463 /* ouput low */
4464 gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
4465 gp++;
4466 }
4467 }
4468
4469 return rc;
4470}
4471
4472static int lcdc_panel_power(int on)
4473{
4474 int flag_on = !!on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004475 static int lcdc_power_save_on, lcdc_power_initialized;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004476
4477 if (lcdc_power_save_on == flag_on)
4478 return 0;
4479
4480 lcdc_power_save_on = flag_on;
Justin Paupore3f40f342011-08-10 18:52:16 -07004481
4482 if (unlikely(!lcdc_power_initialized)) {
4483 quickvx_mddi_client = 0;
4484 display_common_init();
4485 lcdc_power_initialized = 1;
4486 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004487
4488 if (machine_is_msm7x30_fluid())
4489 return lcdc_sharp_panel_power(on);
4490 else
4491 return lcdc_toshiba_panel_power(on);
4492}
4493
4494static struct lcdc_platform_data lcdc_pdata = {
4495 .lcdc_power_save = lcdc_panel_power,
4496};
4497
Justin Paupore3f40f342011-08-10 18:52:16 -07004498static struct regulator *atv_s4, *atv_ldo9;
4499
4500static int __init atv_dac_power_init(void)
4501{
4502 int rc;
4503 struct regulator_bulk_data regs[] = {
4504 { .supply = "smps4", .min_uV = 2200000, .max_uV = 2200000 },
4505 { .supply = "ldo9", .min_uV = 2050000, .max_uV = 2050000 },
4506 };
4507
4508 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs), regs);
4509
4510 if (rc) {
4511 pr_err("%s: could not get regulators: %d\n", __func__, rc);
4512 goto bail;
4513 }
4514
4515 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
4516
4517 if (rc) {
4518 pr_err("%s: could not set voltages: %d\n", __func__, rc);
4519 goto reg_free;
4520 }
4521
4522 atv_s4 = regs[0].consumer;
4523 atv_ldo9 = regs[1].consumer;
4524
4525reg_free:
4526 regulator_bulk_free(ARRAY_SIZE(regs), regs);
4527bail:
4528 return rc;
4529}
4530
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004531static int atv_dac_power(int on)
4532{
4533 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004534
4535 if (on) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004536 rc = regulator_enable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004537 if (rc) {
4538 pr_err("%s: s4 vreg enable failed (%d)\n",
4539 __func__, rc);
4540 return rc;
4541 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004542 rc = regulator_enable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004543 if (rc) {
4544 pr_err("%s: ldo9 vreg enable failed (%d)\n",
4545 __func__, rc);
4546 return rc;
4547 }
4548 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004549 rc = regulator_disable(atv_ldo9);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004550 if (rc) {
4551 pr_err("%s: ldo9 vreg disable failed (%d)\n",
4552 __func__, rc);
4553 return rc;
4554 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004555 rc = regulator_disable(atv_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004556 if (rc) {
4557 pr_err("%s: s4 vreg disable failed (%d)\n",
4558 __func__, rc);
4559 return rc;
4560 }
4561 }
4562 return rc;
4563}
4564
4565static struct tvenc_platform_data atv_pdata = {
4566 .poll = 1,
4567 .pm_vid_en = atv_dac_power,
4568};
4569
4570static void __init msm_fb_add_devices(void)
4571{
4572 msm_fb_register_device("mdp", &mdp_pdata);
4573 msm_fb_register_device("pmdh", &mddi_pdata);
4574 msm_fb_register_device("lcdc", &lcdc_pdata);
4575 msm_fb_register_device("dtv", &dtv_pdata);
4576 msm_fb_register_device("tvenc", &atv_pdata);
4577#ifdef CONFIG_FB_MSM_TVOUT
4578 msm_fb_register_device("tvout_device", NULL);
4579#endif
4580}
4581
4582static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
4583 .gpio_num = lcd_panel_spi_gpio_num,
4584};
4585
4586static struct platform_device lcdc_toshiba_panel_device = {
4587 .name = "lcdc_toshiba_wvga",
4588 .id = 0,
4589 .dev = {
4590 .platform_data = &lcdc_toshiba_panel_data,
4591 }
4592};
4593
4594#if defined(CONFIG_MARIMBA_CORE) && \
4595 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
4596static struct platform_device msm_bt_power_device = {
4597 .name = "bt_power",
4598 .id = -1
4599};
4600
4601enum {
4602 BT_RFR,
4603 BT_CTS,
4604 BT_RX,
4605 BT_TX,
4606};
4607
4608static struct msm_gpio bt_config_power_on[] = {
4609 { GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4610 "UART1DM_RFR" },
4611 { GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4612 "UART1DM_CTS" },
4613 { GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4614 "UART1DM_Rx" },
4615 { GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
4616 "UART1DM_Tx" }
4617};
4618
4619static struct msm_gpio bt_config_power_off[] = {
4620 { GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4621 "UART1DM_RFR" },
4622 { GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4623 "UART1DM_CTS" },
4624 { GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4625 "UART1DM_Rx" },
4626 { GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
4627 "UART1DM_Tx" }
4628};
4629
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004630static u8 bahama_version;
4631
Justin Paupore3f40f342011-08-10 18:52:16 -07004632static struct regulator_bulk_data regs_bt_marimba[] = {
4633 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4634 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
4635 { .supply = "ldo24", .min_uV = 1200000, .max_uV = 1200000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304636 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004637};
4638
4639static struct regulator_bulk_data regs_bt_bahama_v1[] = {
4640 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4641 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
4642 { .supply = "smps2", .min_uV = 1300000, .max_uV = 1300000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304643 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004644};
4645
4646static struct regulator_bulk_data regs_bt_bahama_v2[] = {
4647 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
4648 { .supply = "ldo7", .min_uV = 1800000, .max_uV = 1800000 },
Pankaj Kumara2320de2011-11-30 12:55:12 +05304649 { .supply = "ldo13", .min_uV = 2900000, .max_uV = 3050000 },
Justin Paupore3f40f342011-08-10 18:52:16 -07004650};
4651
4652static struct regulator_bulk_data *regs_bt;
4653static int regs_bt_count;
4654
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004655static int marimba_bt(int on)
4656{
4657 int rc;
4658 int i;
4659 struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
4660
4661 struct marimba_config_register {
4662 u8 reg;
4663 u8 value;
4664 u8 mask;
4665 };
4666
4667 struct marimba_variant_register {
4668 const size_t size;
4669 const struct marimba_config_register *set;
4670 };
4671
4672 const struct marimba_config_register *p;
4673
4674 u8 version;
4675
4676 const struct marimba_config_register v10_bt_on[] = {
4677 { 0xE5, 0x0B, 0x0F },
4678 { 0x05, 0x02, 0x07 },
4679 { 0x06, 0x88, 0xFF },
4680 { 0xE7, 0x21, 0x21 },
4681 { 0xE3, 0x38, 0xFF },
4682 { 0xE4, 0x06, 0xFF },
4683 };
4684
4685 const struct marimba_config_register v10_bt_off[] = {
4686 { 0xE5, 0x0B, 0x0F },
4687 { 0x05, 0x08, 0x0F },
4688 { 0x06, 0x88, 0xFF },
4689 { 0xE7, 0x00, 0x21 },
4690 { 0xE3, 0x00, 0xFF },
4691 { 0xE4, 0x00, 0xFF },
4692 };
4693
4694 const struct marimba_config_register v201_bt_on[] = {
4695 { 0x05, 0x08, 0x07 },
4696 { 0x06, 0x88, 0xFF },
4697 { 0xE7, 0x21, 0x21 },
4698 { 0xE3, 0x38, 0xFF },
4699 { 0xE4, 0x06, 0xFF },
4700 };
4701
4702 const struct marimba_config_register v201_bt_off[] = {
4703 { 0x05, 0x08, 0x07 },
4704 { 0x06, 0x88, 0xFF },
4705 { 0xE7, 0x00, 0x21 },
4706 { 0xE3, 0x00, 0xFF },
4707 { 0xE4, 0x00, 0xFF },
4708 };
4709
4710 const struct marimba_config_register v210_bt_on[] = {
4711 { 0xE9, 0x01, 0x01 },
4712 { 0x06, 0x88, 0xFF },
4713 { 0xE7, 0x21, 0x21 },
4714 { 0xE3, 0x38, 0xFF },
4715 { 0xE4, 0x06, 0xFF },
4716 };
4717
4718 const struct marimba_config_register v210_bt_off[] = {
4719 { 0x06, 0x88, 0xFF },
4720 { 0xE7, 0x00, 0x21 },
4721 { 0xE9, 0x00, 0x01 },
4722 { 0xE3, 0x00, 0xFF },
4723 { 0xE4, 0x00, 0xFF },
4724 };
4725
4726 const struct marimba_variant_register bt_marimba[2][4] = {
4727 {
4728 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4729 { 0, NULL },
4730 { ARRAY_SIZE(v201_bt_off), v201_bt_off },
4731 { ARRAY_SIZE(v210_bt_off), v210_bt_off }
4732 },
4733 {
4734 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4735 { 0, NULL },
4736 { ARRAY_SIZE(v201_bt_on), v201_bt_on },
4737 { ARRAY_SIZE(v210_bt_on), v210_bt_on }
4738 }
4739 };
4740
4741 on = on ? 1 : 0;
4742
4743 rc = marimba_read_bit_mask(&config, 0x11, &version, 1, 0x1F);
4744 if (rc < 0) {
4745 printk(KERN_ERR
4746 "%s: version read failed: %d\n",
4747 __func__, rc);
4748 return rc;
4749 }
4750
4751 if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
4752 (bt_marimba[on][version].size == 0)) {
4753 printk(KERN_ERR
4754 "%s: unsupported version\n",
4755 __func__);
4756 return -EIO;
4757 }
4758
4759 p = bt_marimba[on][version].set;
4760
4761 printk(KERN_INFO "%s: found version %d\n", __func__, version);
4762
4763 for (i = 0; i < bt_marimba[on][version].size; i++) {
4764 u8 value = (p+i)->value;
4765 rc = marimba_write_bit_mask(&config,
4766 (p+i)->reg,
4767 &value,
4768 sizeof((p+i)->value),
4769 (p+i)->mask);
4770 if (rc < 0) {
4771 printk(KERN_ERR
4772 "%s: reg %d write failed: %d\n",
4773 __func__, (p+i)->reg, rc);
4774 return rc;
4775 }
4776 printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
4777 __func__, (p+i)->reg,
4778 value, (p+i)->mask);
4779 }
4780 return 0;
4781}
4782
4783static int bahama_bt(int on)
4784{
4785 int rc;
4786 int i;
4787 struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
4788
4789 struct bahama_variant_register {
4790 const size_t size;
4791 const struct bahama_config_register *set;
4792 };
4793
4794 const struct bahama_config_register *p;
4795
4796
4797 const struct bahama_config_register v10_bt_on[] = {
4798 { 0xE9, 0x00, 0xFF },
4799 { 0xF4, 0x80, 0xFF },
4800 { 0xF0, 0x06, 0xFF },
4801 { 0xE4, 0x00, 0xFF },
4802 { 0xE5, 0x00, 0x0F },
4803#ifdef CONFIG_WLAN
4804 { 0xE6, 0x38, 0x7F },
4805 { 0xE7, 0x06, 0xFF },
4806#endif
4807 { 0x11, 0x13, 0xFF },
4808 { 0xE9, 0x21, 0xFF },
4809 { 0x01, 0x0C, 0x1F },
4810 { 0x01, 0x08, 0x1F },
4811 };
4812
4813 const struct bahama_config_register v20_bt_on_fm_off[] = {
4814 { 0x11, 0x0C, 0xFF },
4815 { 0x13, 0x01, 0xFF },
4816 { 0xF4, 0x80, 0xFF },
4817 { 0xF0, 0x00, 0xFF },
4818 { 0xE9, 0x00, 0xFF },
4819#ifdef CONFIG_WLAN
4820 { 0x81, 0x00, 0xFF },
4821 { 0x82, 0x00, 0xFF },
4822 { 0xE6, 0x38, 0x7F },
4823 { 0xE7, 0x06, 0xFF },
4824#endif
4825 { 0xE9, 0x21, 0xFF }
4826 };
4827
4828 const struct bahama_config_register v20_bt_on_fm_on[] = {
4829 { 0x11, 0x0C, 0xFF },
4830 { 0x13, 0x01, 0xFF },
4831 { 0xF4, 0x86, 0xFF },
4832 { 0xF0, 0x06, 0xFF },
4833 { 0xE9, 0x00, 0xFF },
4834#ifdef CONFIG_WLAN
4835 { 0x81, 0x00, 0xFF },
4836 { 0x82, 0x00, 0xFF },
4837 { 0xE6, 0x38, 0x7F },
4838 { 0xE7, 0x06, 0xFF },
4839#endif
4840 { 0xE9, 0x21, 0xFF }
4841 };
4842
4843 const struct bahama_config_register v10_bt_off[] = {
4844 { 0xE9, 0x00, 0xFF },
4845 };
4846
4847 const struct bahama_config_register v20_bt_off_fm_off[] = {
4848 { 0xF4, 0x84, 0xFF },
4849 { 0xF0, 0x04, 0xFF },
4850 { 0xE9, 0x00, 0xFF }
4851 };
4852
4853 const struct bahama_config_register v20_bt_off_fm_on[] = {
4854 { 0xF4, 0x86, 0xFF },
4855 { 0xF0, 0x06, 0xFF },
4856 { 0xE9, 0x00, 0xFF }
4857 };
4858
4859 const struct bahama_variant_register bt_bahama[2][3] = {
4860 {
4861 { ARRAY_SIZE(v10_bt_off), v10_bt_off },
4862 { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
4863 { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
4864 },
4865 {
4866 { ARRAY_SIZE(v10_bt_on), v10_bt_on },
4867 { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
4868 { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
4869 }
4870 };
4871
4872 u8 offset = 0; /* index into bahama configs */
4873
4874 on = on ? 1 : 0;
4875
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004876
4877 if (bahama_version == VER_2_0) {
4878 if (marimba_get_fm_status(&config))
4879 offset = 0x01;
4880 }
4881
4882 p = bt_bahama[on][bahama_version + offset].set;
4883
4884 dev_info(&msm_bt_power_device.dev,
4885 "%s: found version %d\n", __func__, bahama_version);
4886
4887 for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
4888 u8 value = (p+i)->value;
4889 rc = marimba_write_bit_mask(&config,
4890 (p+i)->reg,
4891 &value,
4892 sizeof((p+i)->value),
4893 (p+i)->mask);
4894 if (rc < 0) {
4895 dev_err(&msm_bt_power_device.dev,
4896 "%s: reg %d write failed: %d\n",
4897 __func__, (p+i)->reg, rc);
4898 return rc;
4899 }
4900 dev_info(&msm_bt_power_device.dev,
4901 "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
4902 __func__, (p+i)->reg,
4903 value, (p+i)->mask);
4904 }
4905 /* Update BT status */
4906 if (on)
4907 marimba_set_bt_status(&config, true);
4908 else
4909 marimba_set_bt_status(&config, false);
4910
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004911 return 0;
4912}
4913
Justin Paupore3f40f342011-08-10 18:52:16 -07004914static int bluetooth_regs_init(int bahama_not_marimba)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004915{
Justin Paupore3f40f342011-08-10 18:52:16 -07004916 int rc = 0;
4917 struct device *const dev = &msm_bt_power_device.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004918
4919 if (bahama_not_marimba) {
Justin Paupore3f40f342011-08-10 18:52:16 -07004920 bahama_version = read_bahama_ver();
4921
4922 switch (bahama_version) {
4923 case VER_1_0:
4924 regs_bt = regs_bt_bahama_v1;
4925 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v1);
4926 break;
4927 case VER_2_0:
4928 regs_bt = regs_bt_bahama_v2;
4929 regs_bt_count = ARRAY_SIZE(regs_bt_bahama_v2);
4930 break;
4931 case VER_UNSUPPORTED:
4932 default:
4933 dev_err(dev,
4934 "%s: i2c failure or unsupported version: %d\n",
4935 __func__, bahama_version);
4936 rc = -EIO;
4937 goto out;
4938 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004939 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07004940 regs_bt = regs_bt_marimba;
4941 regs_bt_count = ARRAY_SIZE(regs_bt_marimba);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004942 }
4943
Justin Paupore3f40f342011-08-10 18:52:16 -07004944 rc = regulator_bulk_get(&msm_bt_power_device.dev,
4945 regs_bt_count, regs_bt);
4946 if (rc) {
4947 dev_err(dev, "%s: could not get regulators: %d\n",
4948 __func__, rc);
4949 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004950 }
Justin Paupore3f40f342011-08-10 18:52:16 -07004951
4952 rc = regulator_bulk_set_voltage(regs_bt_count, regs_bt);
4953 if (rc) {
4954 dev_err(dev, "%s: could not set voltages: %d\n",
4955 __func__, rc);
4956 goto reg_free;
4957 }
4958
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004959 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07004960
4961reg_free:
4962 regulator_bulk_free(regs_bt_count, regs_bt);
4963out:
4964 regs_bt_count = 0;
4965 regs_bt = NULL;
4966 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004967}
4968
4969static int bluetooth_power(int on)
4970{
4971 int rc;
4972 const char *id = "BTPW";
4973
4974 int bahama_not_marimba = bahama_present();
4975
4976 if (bahama_not_marimba == -1) {
4977 printk(KERN_WARNING "%s: bahama_present: %d\n",
4978 __func__, bahama_not_marimba);
4979 return -ENODEV;
4980 }
4981
Justin Paupore3f40f342011-08-10 18:52:16 -07004982 if (unlikely(regs_bt_count == 0)) {
4983 rc = bluetooth_regs_init(bahama_not_marimba);
4984 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004985 return rc;
Justin Paupore3f40f342011-08-10 18:52:16 -07004986 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004987
Justin Paupore3f40f342011-08-10 18:52:16 -07004988 if (on) {
4989 rc = regulator_bulk_enable(regs_bt_count, regs_bt);
4990 if (rc)
4991 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004992
4993 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
4994 PMAPP_CLOCK_VOTE_ON);
4995 if (rc < 0)
4996 return -EIO;
4997
4998 if (machine_is_msm8x55_svlte_surf() ||
4999 machine_is_msm8x55_svlte_ffa()) {
5000 rc = marimba_gpio_config(1);
5001 if (rc < 0)
5002 return -EIO;
5003 }
5004
5005 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5006 if (rc < 0)
5007 return -EIO;
5008
5009 msleep(10);
5010
5011 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5012 PMAPP_CLOCK_VOTE_PIN_CTRL);
5013 if (rc < 0)
5014 return -EIO;
5015
5016 if (machine_is_msm8x55_svlte_surf() ||
5017 machine_is_msm8x55_svlte_ffa()) {
5018 rc = marimba_gpio_config(0);
5019 if (rc < 0)
5020 return -EIO;
5021 }
5022
5023 rc = msm_gpios_enable(bt_config_power_on,
5024 ARRAY_SIZE(bt_config_power_on));
5025
5026 if (rc < 0)
5027 return rc;
5028
5029 } else {
5030 rc = msm_gpios_enable(bt_config_power_off,
5031 ARRAY_SIZE(bt_config_power_off));
5032 if (rc < 0)
5033 return rc;
5034
5035 /* check for initial RFKILL block (power off) */
5036 if (platform_get_drvdata(&msm_bt_power_device) == NULL)
5037 goto out;
5038
5039 rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
5040 if (rc < 0)
5041 return -EIO;
5042
5043 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
5044 PMAPP_CLOCK_VOTE_OFF);
5045 if (rc < 0)
5046 return -EIO;
5047
Justin Paupore3f40f342011-08-10 18:52:16 -07005048 rc = regulator_bulk_disable(regs_bt_count, regs_bt);
5049 if (rc)
5050 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005051
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005052 }
5053
5054out:
5055 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
5056
5057 return 0;
5058}
5059
5060static void __init bt_power_init(void)
5061{
Justin Paupore3f40f342011-08-10 18:52:16 -07005062 msm_bt_power_device.dev.platform_data = &bluetooth_power;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005063}
5064#else
5065#define bt_power_init(x) do {} while (0)
5066#endif
5067
5068static struct msm_psy_batt_pdata msm_psy_batt_data = {
5069 .voltage_min_design = 2800,
5070 .voltage_max_design = 4300,
5071 .avail_chg_sources = AC_CHG | USB_CHG ,
5072 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
5073};
5074
5075static struct platform_device msm_batt_device = {
5076 .name = "msm-battery",
5077 .id = -1,
5078 .dev.platform_data = &msm_psy_batt_data,
5079};
5080
5081static char *msm_adc_fluid_device_names[] = {
5082 "LTC_ADC1",
5083 "LTC_ADC2",
5084 "LTC_ADC3",
5085};
5086
5087static char *msm_adc_surf_device_names[] = {
5088 "XO_ADC",
5089};
5090
5091static struct msm_adc_platform_data msm_adc_pdata;
5092
5093static struct platform_device msm_adc_device = {
5094 .name = "msm_adc",
5095 .id = -1,
5096 .dev = {
5097 .platform_data = &msm_adc_pdata,
5098 },
5099};
5100
5101#ifdef CONFIG_MSM_SDIO_AL
5102static struct msm_gpio mdm2ap_status = {
5103 GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5104 "mdm2ap_status"
5105};
5106
5107
5108static int configure_mdm2ap_status(int on)
5109{
5110 if (on)
5111 return msm_gpios_request_enable(&mdm2ap_status, 1);
5112 else {
5113 msm_gpios_disable_free(&mdm2ap_status, 1);
5114 return 0;
5115 }
5116}
5117
5118static int get_mdm2ap_status(void)
5119{
5120 return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
5121}
5122
5123static struct sdio_al_platform_data sdio_al_pdata = {
5124 .config_mdm2ap_status = configure_mdm2ap_status,
5125 .get_mdm2ap_status = get_mdm2ap_status,
5126 .allow_sdioc_version_major_2 = 1,
5127 .peer_sdioc_version_minor = 0x0001,
5128 .peer_sdioc_version_major = 0x0003,
5129 .peer_sdioc_boot_version_minor = 0x0001,
5130 .peer_sdioc_boot_version_major = 0x0003,
5131};
5132
5133struct platform_device msm_device_sdio_al = {
5134 .name = "msm_sdio_al",
5135 .id = -1,
5136 .dev = {
5137 .platform_data = &sdio_al_pdata,
5138 },
5139};
5140
5141#endif /* CONFIG_MSM_SDIO_AL */
5142
Daniel Walker8d747cd2010-02-25 11:37:43 -08005143static struct platform_device *devices[] __initdata = {
Daniel Walker90e37c52010-05-12 14:24:15 -07005144#if defined(CONFIG_SERIAL_MSM) || defined(CONFIG_MSM_SERIAL_DEBUGGER)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005145 &msm_device_uart2,
5146#endif
Justin Paupore637a25d2011-07-14 17:11:04 -07005147#ifdef CONFIG_MSM_PROC_COMM_REGULATOR
5148 &msm_proccomm_regulator_dev,
5149#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005150 &asoc_msm_pcm,
5151 &asoc_msm_dai0,
5152 &asoc_msm_dai1,
5153#if defined (CONFIG_SND_MSM_MVS_DAI_SOC)
5154 &asoc_msm_mvs,
5155 &asoc_mvs_dai0,
5156 &asoc_mvs_dai1,
Daniel Walker90e37c52010-05-12 14:24:15 -07005157#endif
Niranjana Vishwanathapuraa8855e92010-10-06 13:52:10 -07005158 &msm_device_smd,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005159 &msm_device_dmov,
5160 &smc91x_device,
5161 &smsc911x_device,
5162 &msm_device_nand,
5163#ifdef CONFIG_USB_MSM_OTG_72K
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05305164 &msm_device_otg,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005165#ifdef CONFIG_USB_GADGET
5166 &msm_device_gadget_peripheral,
5167#endif
5168#endif
5169#ifdef CONFIG_USB_G_ANDROID
5170 &android_usb_device,
5171#endif
5172 &qsd_device_spi,
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05305173
5174#ifdef CONFIG_MSM_SSBI
5175 &msm_device_ssbi_pmic1,
5176#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005177#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005178 &msm_device_ssbi7,
5179#endif
5180 &android_pmem_device,
5181 &msm_fb_device,
5182 &msm_migrate_pages_device,
5183 &mddi_toshiba_device,
5184 &lcdc_toshiba_panel_device,
5185#ifdef CONFIG_MSM_ROTATOR
5186 &msm_rotator_device,
5187#endif
5188 &lcdc_sharp_panel_device,
5189 &android_pmem_adsp_device,
5190 &android_pmem_audio_device,
5191 &msm_device_i2c,
5192 &msm_device_i2c_2,
5193 &msm_device_uart_dm1,
5194 &hs_device,
5195#ifdef CONFIG_MSM7KV2_AUDIO
5196 &msm_aictl_device,
5197 &msm_mi2s_device,
5198 &msm_lpa_device,
5199 &msm_aux_pcm_device,
5200#endif
5201 &msm_device_adspdec,
5202 &qup_device_i2c,
5203#if defined(CONFIG_MARIMBA_CORE) && \
5204 (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
5205 &msm_bt_power_device,
5206#endif
5207 &msm_kgsl_3d0,
5208 &msm_kgsl_2d0,
5209#ifdef CONFIG_MT9T013
5210 &msm_camera_sensor_mt9t013,
5211#endif
5212#ifdef CONFIG_MT9D112
5213 &msm_camera_sensor_mt9d112,
5214#endif
5215#ifdef CONFIG_WEBCAM_OV9726
5216 &msm_camera_sensor_ov9726,
5217#endif
5218#ifdef CONFIG_S5K3E2FX
5219 &msm_camera_sensor_s5k3e2fx,
5220#endif
5221#ifdef CONFIG_MT9P012
5222 &msm_camera_sensor_mt9p012,
5223#endif
5224#ifdef CONFIG_MT9E013
5225 &msm_camera_sensor_mt9e013,
5226#endif
5227#ifdef CONFIG_VX6953
5228 &msm_camera_sensor_vx6953,
5229#endif
5230#ifdef CONFIG_SN12M0PZ
5231 &msm_camera_sensor_sn12m0pz,
5232#endif
5233 &msm_device_vidc_720p,
5234#ifdef CONFIG_MSM_GEMINI
5235 &msm_gemini_device,
5236#endif
5237#ifdef CONFIG_MSM_VPE
5238 &msm_vpe_device,
5239#endif
5240#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
5241 &msm_device_tsif,
5242#endif
5243#ifdef CONFIG_MSM_SDIO_AL
5244 &msm_device_sdio_al,
5245#endif
5246
5247#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
5248 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
5249 &qcrypto_device,
5250#endif
5251
5252#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
5253 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
5254 &qcedev_device,
5255#endif
5256
5257 &msm_batt_device,
5258 &msm_adc_device,
5259 &msm_ebi0_thermal,
Laxminath Kasam1d8255d2012-02-15 13:10:19 +05305260 &msm_ebi1_thermal,
5261 &msm_adsp_device
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005262};
5263
5264static struct msm_gpio msm_i2c_gpios_hw[] = {
5265 { GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5266 { GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5267};
5268
5269static struct msm_gpio msm_i2c_gpios_io[] = {
5270 { GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
5271 { GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
5272};
5273
5274static struct msm_gpio qup_i2c_gpios_io[] = {
5275 { GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5276 { GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5277};
5278static struct msm_gpio qup_i2c_gpios_hw[] = {
5279 { GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
5280 { GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
5281};
5282
5283static void
5284msm_i2c_gpio_config(int adap_id, int config_type)
5285{
5286 struct msm_gpio *msm_i2c_table;
5287
5288 /* Each adapter gets 2 lines from the table */
5289 if (adap_id > 0)
5290 return;
5291 if (config_type)
5292 msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
5293 else
5294 msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
5295 msm_gpios_enable(msm_i2c_table, 2);
5296}
5297/*This needs to be enabled only for OEMS*/
5298#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005299static struct regulator *qup_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005300#endif
5301static void
5302qup_i2c_gpio_config(int adap_id, int config_type)
5303{
5304 int rc = 0;
5305 struct msm_gpio *qup_i2c_table;
5306 /* Each adapter gets 2 lines from the table */
5307 if (adap_id != 4)
5308 return;
5309 if (config_type)
5310 qup_i2c_table = qup_i2c_gpios_hw;
5311 else
5312 qup_i2c_table = qup_i2c_gpios_io;
5313 rc = msm_gpios_enable(qup_i2c_table, 2);
5314 if (rc < 0)
5315 printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
5316 /*This needs to be enabled only for OEMS*/
5317#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005318 if (!IS_ERR_OR_NULL(qup_vreg)) {
5319 rc = regulator_enable(qup_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005320 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005321 pr_err("%s: regulator_enable failed: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005322 __func__, rc);
5323 }
5324 }
5325#endif
5326}
5327
5328static struct msm_i2c_platform_data msm_i2c_pdata = {
5329 .clk_freq = 100000,
5330 .pri_clk = 70,
5331 .pri_dat = 71,
5332 .rmutex = 1,
5333 .rsl_id = "D:I2C02000021",
5334 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5335};
5336
5337static void __init msm_device_i2c_init(void)
5338{
5339 if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
5340 pr_err("failed to request I2C gpios\n");
5341
5342 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
5343}
5344
5345static struct msm_i2c_platform_data msm_i2c_2_pdata = {
5346 .clk_freq = 100000,
5347 .rmutex = 1,
5348 .rsl_id = "D:I2C02000022",
5349 .msm_i2c_config_gpio = msm_i2c_gpio_config,
5350};
5351
5352static void __init msm_device_i2c_2_init(void)
5353{
5354 msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
5355}
5356
5357static struct msm_i2c_platform_data qup_i2c_pdata = {
5358 .clk_freq = 384000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005359 .msm_i2c_config_gpio = qup_i2c_gpio_config,
5360};
5361
5362static void __init qup_device_i2c_init(void)
5363{
5364 if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
5365 pr_err("failed to request I2C gpios\n");
5366
5367 qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
5368 /*This needs to be enabled only for OEMS*/
5369#ifndef CONFIG_QUP_EXCLUSIVE_TO_CAMERA
Justin Paupore3f40f342011-08-10 18:52:16 -07005370 qup_vreg = regulator_get(&qup_device_i2c.dev, "lvsw1");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005371 if (IS_ERR(qup_vreg)) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005372 dev_err(&qup_device_i2c.dev,
5373 "%s: regulator_get failed: %ld\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005374 __func__, PTR_ERR(qup_vreg));
5375 }
5376#endif
5377}
5378
5379#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005380static struct msm_i2c_ssbi_platform_data msm_i2c_ssbi7_pdata = {
5381 .rsl_id = "D:CODEC_SSBI",
5382 .controller_type = MSM_SBI_CTRL_SSBI,
5383};
5384#endif
5385
Daniel Walker8d747cd2010-02-25 11:37:43 -08005386static void __init msm7x30_init_irq(void)
5387{
5388 msm_init_irq();
5389}
5390
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005391static struct msm_gpio msm_nand_ebi2_cfg_data[] = {
5392 {GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
5393 {GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
5394};
5395
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005396#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
5397 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
5398 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
5399 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
5400
5401struct sdcc_gpio {
5402 struct msm_gpio *cfg_data;
5403 uint32_t size;
5404 struct msm_gpio *sleep_cfg_data;
5405};
5406#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
5407static struct msm_gpio sdc1_lvlshft_cfg_data[] = {
5408 {GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
5409};
5410#endif
5411static struct msm_gpio sdc1_cfg_data[] = {
5412 {GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
5413 {GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
5414 {GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
5415 {GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
5416 {GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
5417 {GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
5418};
5419
5420static struct msm_gpio sdc2_cfg_data[] = {
5421 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
5422 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
5423 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
5424 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
5425 {GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
5426 {GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
5427
5428#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
5429 {GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
5430 {GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
5431 {GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
5432 {GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
5433#endif
5434};
5435
5436static struct msm_gpio sdc3_cfg_data[] = {
5437 {GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
5438 {GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
5439 {GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
5440 {GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
5441 {GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
5442 {GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
5443};
5444
5445static struct msm_gpio sdc3_sleep_cfg_data[] = {
5446 {GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5447 "sdc3_clk"},
5448 {GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5449 "sdc3_cmd"},
5450 {GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5451 "sdc3_dat_3"},
5452 {GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5453 "sdc3_dat_2"},
5454 {GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5455 "sdc3_dat_1"},
5456 {GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
5457 "sdc3_dat_0"},
5458};
5459
5460static struct msm_gpio sdc4_cfg_data[] = {
5461 {GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
5462 {GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
5463 {GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
5464 {GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
5465 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
5466 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
5467};
5468
5469static struct sdcc_gpio sdcc_cfg_data[] = {
5470 {
5471 .cfg_data = sdc1_cfg_data,
5472 .size = ARRAY_SIZE(sdc1_cfg_data),
5473 .sleep_cfg_data = NULL,
5474 },
5475 {
5476 .cfg_data = sdc2_cfg_data,
5477 .size = ARRAY_SIZE(sdc2_cfg_data),
5478 .sleep_cfg_data = NULL,
5479 },
5480 {
5481 .cfg_data = sdc3_cfg_data,
5482 .size = ARRAY_SIZE(sdc3_cfg_data),
5483 .sleep_cfg_data = sdc3_sleep_cfg_data,
5484 },
5485 {
5486 .cfg_data = sdc4_cfg_data,
5487 .size = ARRAY_SIZE(sdc4_cfg_data),
5488 .sleep_cfg_data = NULL,
5489 },
5490};
5491
Justin Paupore3f40f342011-08-10 18:52:16 -07005492static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005493
5494static unsigned long vreg_sts, gpio_sts;
5495
5496static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
5497{
5498 int rc = 0;
5499 struct sdcc_gpio *curr;
5500
5501 curr = &sdcc_cfg_data[dev_id - 1];
5502
5503 if (!(test_bit(dev_id, &gpio_sts)^enable))
5504 return rc;
5505
5506 if (enable) {
5507 set_bit(dev_id, &gpio_sts);
5508 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
5509 if (rc)
5510 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
5511 __func__, dev_id);
5512 } else {
5513 clear_bit(dev_id, &gpio_sts);
5514 if (curr->sleep_cfg_data) {
5515 msm_gpios_enable(curr->sleep_cfg_data, curr->size);
5516 msm_gpios_free(curr->sleep_cfg_data, curr->size);
5517 } else {
5518 msm_gpios_disable_free(curr->cfg_data, curr->size);
5519 }
5520 }
5521
5522 return rc;
5523}
5524
5525static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
5526{
5527 int rc = 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005528 struct regulator *curr = sdcc_vreg_data[dev_id - 1];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005529 static int enabled_once[] = {0, 0, 0, 0};
5530
Justin Paupore3f40f342011-08-10 18:52:16 -07005531 if (test_bit(dev_id, &vreg_sts) == enable)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005532 return rc;
5533
Asutosh Das853bbcd2012-02-01 10:40:05 +05305534 if (dev_id == 4) {
5535 if (enable) {
5536 pr_debug("Enable Vdd dev_%d\n", dev_id);
5537 gpio_set_value_cansleep(
5538 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5539 0);
5540 set_bit(dev_id, &vreg_sts);
5541 } else {
5542 pr_debug("Disable Vdd dev_%d\n", dev_id);
5543 gpio_set_value_cansleep(
5544 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SDC4_PWR_EN_N),
5545 1);
5546 clear_bit(dev_id, &vreg_sts);
5547 }
5548 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005549
Asutosh Das853bbcd2012-02-01 10:40:05 +05305550 if (!enable || enabled_once[dev_id - 1])
5551 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005552 if (!curr)
5553 return -ENODEV;
5554
5555 if (IS_ERR(curr))
5556 return PTR_ERR(curr);
5557
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005558 if (enable) {
5559 set_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005560
5561 rc = regulator_enable(curr);
5562 if (rc)
5563 pr_err("%s: could not enable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005564 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005565 enabled_once[dev_id - 1] = 1;
5566 } else {
5567 clear_bit(dev_id, &vreg_sts);
Justin Paupore3f40f342011-08-10 18:52:16 -07005568
5569 rc = regulator_disable(curr);
5570 if (rc)
5571 pr_err("%s: could not disable regulator: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005572 __func__, rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005573 }
5574 return rc;
5575}
5576
5577static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
5578{
5579 int rc = 0;
5580 struct platform_device *pdev;
5581
5582 pdev = container_of(dv, struct platform_device, dev);
5583 rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
5584 if (rc)
5585 goto out;
5586
5587 if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
5588 rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
5589out:
5590 return rc;
5591}
5592
5593#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) && \
5594 defined(CONFIG_CSDIO_VENDOR_ID) && \
5595 defined(CONFIG_CSDIO_DEVICE_ID) && \
5596 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
5597
5598#define MBP_ON 1
5599#define MBP_OFF 0
5600
5601#define MBP_RESET_N \
5602 GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
5603#define MBP_INT0 \
5604 GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
5605
5606#define MBP_MODE_CTRL_0 \
5607 GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5608#define MBP_MODE_CTRL_1 \
5609 GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5610#define MBP_MODE_CTRL_2 \
5611 GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
5612#define TSIF_EN \
5613 GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5614#define TSIF_DATA \
5615 GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5616#define TSIF_CLK \
5617 GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
5618
5619static struct msm_gpio mbp_cfg_data[] = {
5620 {GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5621 "mbp_reset"},
5622 {GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
5623 "mbp_io_voltage"},
5624};
5625
5626static int mbp_config_gpios_pre_init(int enable)
5627{
5628 int rc = 0;
5629
5630 if (enable) {
5631 rc = msm_gpios_request_enable(mbp_cfg_data,
5632 ARRAY_SIZE(mbp_cfg_data));
5633 if (rc) {
5634 printk(KERN_ERR
5635 "%s: Failed to turnon GPIOs for mbp chip(%d)\n",
5636 __func__, rc);
5637 }
5638 } else
5639 msm_gpios_disable_free(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
5640 return rc;
5641}
5642
Justin Paupore3f40f342011-08-10 18:52:16 -07005643static struct regulator_bulk_data mbp_regs_io[2];
5644static struct regulator_bulk_data mbp_regs_rf[2];
5645static struct regulator_bulk_data mbp_regs_adc[1];
5646static struct regulator_bulk_data mbp_regs_core[1];
5647
5648static int mbp_init_regs(struct device *dev)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005649{
Justin Paupore3f40f342011-08-10 18:52:16 -07005650 struct regulator_bulk_data regs[] = {
5651 /* Analog and I/O regs */
5652 { .supply = "gp4", .min_uV = 2600000, .max_uV = 2600000 },
5653 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
5654 /* RF regs */
5655 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
5656 { .supply = "rf", .min_uV = 2600000, .max_uV = 2600000 },
5657 /* ADC regs */
5658 { .supply = "s4", .min_uV = 2200000, .max_uV = 2200000 },
5659 /* Core regs */
5660 { .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
5661 };
5662
5663 struct regulator_bulk_data *regptr = regs;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005664 int rc;
5665
Justin Paupore3f40f342011-08-10 18:52:16 -07005666 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs), regs);
5667
5668 if (rc) {
5669 dev_err(dev, "%s: could not get regulators: %d\n",
5670 __func__, rc);
5671 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005672 }
5673
Justin Paupore3f40f342011-08-10 18:52:16 -07005674 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs), regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005675
Justin Paupore3f40f342011-08-10 18:52:16 -07005676 if (rc) {
5677 dev_err(dev, "%s: could not set voltages: %d\n",
5678 __func__, rc);
5679 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005680 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005681
5682 memcpy(mbp_regs_io, regptr, sizeof(mbp_regs_io));
5683 regptr += ARRAY_SIZE(mbp_regs_io);
5684
5685 memcpy(mbp_regs_rf, regptr, sizeof(mbp_regs_rf));
5686 regptr += ARRAY_SIZE(mbp_regs_rf);
5687
5688 memcpy(mbp_regs_adc, regptr, sizeof(mbp_regs_adc));
5689 regptr += ARRAY_SIZE(mbp_regs_adc);
5690
5691 memcpy(mbp_regs_core, regptr, sizeof(mbp_regs_core));
5692
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005693 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07005694
5695reg_free:
5696 regulator_bulk_free(ARRAY_SIZE(regs), regs);
5697out:
5698 return rc;
5699}
5700
5701static int mbp_setup_rf_vregs(int state)
5702{
5703 return state ?
5704 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf) :
5705 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_rf), mbp_regs_rf);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005706}
5707
5708static int mbp_setup_vregs(int state)
5709{
Justin Paupore3f40f342011-08-10 18:52:16 -07005710 return state ?
5711 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io) :
5712 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_io), mbp_regs_io);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005713}
5714
5715static int mbp_set_tcxo_en(int enable)
5716{
5717 int rc;
5718 const char *id = "UBMC";
5719 struct vreg *vreg_analog = NULL;
5720
5721 rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
5722 enable ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
5723 if (rc < 0) {
5724 printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
5725 __func__, enable ? "" : "de-");
5726 return -EIO;
5727 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005728 return rc;
5729}
5730
5731static void mbp_set_freeze_io(int state)
5732{
5733 if (state)
5734 gpio_set_value(85, 0);
5735 else
5736 gpio_set_value(85, 1);
5737}
5738
5739static int mbp_set_core_voltage_en(int enable)
5740{
Justin Paupore3f40f342011-08-10 18:52:16 -07005741 static bool is_enabled;
5742 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005743
Justin Paupore3f40f342011-08-10 18:52:16 -07005744 if (enable && !is_enabled) {
5745 rc = regulator_bulk_enable(ARRAY_SIZE(mbp_regs_core),
5746 mbp_regs_core);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005747 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005748 pr_err("%s: could not enable regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005749 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07005750 } else {
5751 is_enabled = true;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005752 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005753 }
Justin Paupore3f40f342011-08-10 18:52:16 -07005754
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005755 return rc;
5756}
5757
5758static void mbp_set_reset(int state)
5759{
5760 if (state)
5761 gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
5762 else
5763 gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
5764}
5765
5766static int mbp_config_interface_mode(int state)
5767{
5768 if (state) {
5769 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
5770 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
5771 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
5772 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
5773 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
5774 gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
5775 } else {
5776 gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
5777 gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
5778 gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
5779 }
5780 return 0;
5781}
5782
5783static int mbp_setup_adc_vregs(int state)
5784{
Justin Paupore3f40f342011-08-10 18:52:16 -07005785 return state ?
5786 regulator_bulk_enable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc) :
5787 regulator_bulk_disable(ARRAY_SIZE(mbp_regs_adc), mbp_regs_adc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005788}
5789
5790static int mbp_power_up(void)
5791{
5792 int rc;
5793
5794 rc = mbp_config_gpios_pre_init(MBP_ON);
5795 if (rc)
5796 goto exit;
5797 pr_debug("%s: mbp_config_gpios_pre_init() done\n", __func__);
5798
5799 rc = mbp_setup_vregs(MBP_ON);
5800 if (rc)
5801 goto exit;
5802 pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
5803
5804 rc = mbp_set_tcxo_en(MBP_ON);
5805 if (rc)
5806 goto exit;
5807 pr_debug("%s: tcxo clock done\n", __func__);
5808
5809 mbp_set_freeze_io(MBP_OFF);
5810 pr_debug("%s: set gpio 85 to 1 done\n", __func__);
5811
5812 udelay(100);
5813 mbp_set_reset(MBP_ON);
5814
5815 udelay(300);
5816 rc = mbp_config_interface_mode(MBP_ON);
5817 if (rc)
5818 goto exit;
5819 pr_debug("%s: mbp_config_interface_mode() done\n", __func__);
5820
5821 udelay(100 + mbp_set_core_voltage_en(MBP_ON));
5822 pr_debug("%s: power gp16 1.2V done\n", __func__);
5823
5824 mbp_set_freeze_io(MBP_ON);
5825 pr_debug("%s: set gpio 85 to 0 done\n", __func__);
5826
5827 udelay(100);
5828
5829 rc = mbp_setup_rf_vregs(MBP_ON);
5830 if (rc)
5831 goto exit;
5832 pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
5833
5834 rc = mbp_setup_adc_vregs(MBP_ON);
5835 if (rc)
5836 goto exit;
5837 pr_debug("%s: s4 2.2V done\n", __func__);
5838
5839 udelay(200);
5840
5841 mbp_set_reset(MBP_OFF);
5842 pr_debug("%s: close gpio 44 done\n", __func__);
5843
5844 msleep(20);
5845exit:
5846 return rc;
5847}
5848
5849static int mbp_power_down(void)
5850{
5851 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005852
5853 mbp_set_reset(MBP_ON);
5854 pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
5855
5856 udelay(100);
5857
5858 rc = mbp_setup_adc_vregs(MBP_OFF);
5859 if (rc)
5860 goto exit;
5861 pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
5862
5863 udelay(5);
5864
5865 rc = mbp_setup_rf_vregs(MBP_OFF);
5866 if (rc)
5867 goto exit;
5868 pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
5869
5870 udelay(5);
5871
5872 mbp_set_freeze_io(MBP_OFF);
5873 pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
5874
5875 udelay(100);
5876 rc = mbp_set_core_voltage_en(MBP_OFF);
5877 if (rc)
5878 goto exit;
5879 pr_debug("%s: mbp_set_core_voltage_en(MBP_OFF) done\n", __func__);
5880
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005881 rc = mbp_set_tcxo_en(MBP_OFF);
5882 if (rc)
5883 goto exit;
5884 pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
5885
Justin Paupore3f40f342011-08-10 18:52:16 -07005886 rc = mbp_setup_vregs(MBP_OFF);
5887 if (rc)
5888 goto exit;
5889 pr_debug("%s: mbp_setup_vregs(MBP_OFF) done\n", __func__);
5890
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005891 rc = mbp_config_gpios_pre_init(MBP_OFF);
5892 if (rc)
5893 goto exit;
5894exit:
5895 return rc;
5896}
5897
5898static void (*mbp_status_notify_cb)(int card_present, void *dev_id);
5899static void *mbp_status_notify_cb_devid;
5900static int mbp_power_status;
5901static int mbp_power_init_done;
5902
5903static uint32_t mbp_setup_power(struct device *dv,
5904 unsigned int power_status)
5905{
5906 int rc = 0;
5907 struct platform_device *pdev;
5908
5909 pdev = container_of(dv, struct platform_device, dev);
5910
5911 if (power_status == mbp_power_status)
5912 goto exit;
5913 if (power_status) {
5914 pr_debug("turn on power of mbp slot");
5915 rc = mbp_power_up();
5916 mbp_power_status = 1;
5917 } else {
5918 pr_debug("turn off power of mbp slot");
5919 rc = mbp_power_down();
5920 mbp_power_status = 0;
5921 }
5922exit:
5923 return rc;
5924};
5925
5926int mbp_register_status_notify(void (*callback)(int, void *),
5927 void *dev_id)
5928{
5929 mbp_status_notify_cb = callback;
5930 mbp_status_notify_cb_devid = dev_id;
5931 return 0;
5932}
5933
5934static unsigned int mbp_status(struct device *dev)
5935{
5936 return mbp_power_status;
5937}
5938
5939static uint32_t msm_sdcc_setup_power_mbp(struct device *dv, unsigned int vdd)
5940{
5941 struct platform_device *pdev;
5942 uint32_t rc = 0;
5943
5944 pdev = container_of(dv, struct platform_device, dev);
5945 rc = msm_sdcc_setup_power(dv, vdd);
5946 if (rc) {
5947 pr_err("%s: Failed to setup power (%d)\n",
5948 __func__, rc);
5949 goto out;
5950 }
5951 if (!mbp_power_init_done) {
Justin Paupore3f40f342011-08-10 18:52:16 -07005952 rc = mbp_init_regs(dv);
5953 if (rc) {
5954 dev_err(dv, "%s: regulator init failed: %d\n",
5955 __func__, rc);
5956 goto out;
5957 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005958 mbp_setup_power(dv, 1);
5959 mbp_setup_power(dv, 0);
5960 mbp_power_init_done = 1;
5961 }
5962 if (vdd >= 0x8000) {
5963 rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
5964 if (rc) {
5965 pr_err("%s: Failed to config mbp chip power (%d)\n",
5966 __func__, rc);
5967 goto out;
5968 }
5969 if (mbp_status_notify_cb) {
5970 mbp_status_notify_cb(mbp_power_status,
5971 mbp_status_notify_cb_devid);
5972 }
5973 }
5974out:
5975 /* should return 0 only */
5976 return 0;
5977}
5978
5979#endif
5980
5981#endif
5982
5983#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
5984#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
5985static unsigned int msm7x30_sdcc_slot_status(struct device *dev)
5986{
5987 return (unsigned int)
5988 gpio_get_value_cansleep(
5989 PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_SD_DET - 1));
5990}
5991#endif
5992
5993static int msm_sdcc_get_wpswitch(struct device *dv)
5994{
5995 void __iomem *wp_addr = 0;
5996 uint32_t ret = 0;
5997 struct platform_device *pdev;
5998
5999 if (!(machine_is_msm7x30_surf()))
6000 return -1;
6001 pdev = container_of(dv, struct platform_device, dev);
6002
6003 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
6004 if (!wp_addr) {
6005 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
6006 return -ENOMEM;
6007 }
6008
6009 ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
6010 pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
6011 pdev->id, ret);
6012 iounmap(wp_addr);
6013
6014 return ret;
6015}
6016#endif
6017
6018#if defined(CONFIG_MMC_MSM_SDC1_SUPPORT)
6019#if defined(CONFIG_CSDIO_VENDOR_ID) && \
6020 defined(CONFIG_CSDIO_DEVICE_ID) && \
6021 (CONFIG_CSDIO_VENDOR_ID == 0x70 && CONFIG_CSDIO_DEVICE_ID == 0x1117)
6022static struct mmc_platform_data msm7x30_sdc1_data = {
6023 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
6024 .translate_vdd = msm_sdcc_setup_power_mbp,
6025 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6026 .status = mbp_status,
6027 .register_status_notify = mbp_register_status_notify,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006028 .msmsdcc_fmin = 144000,
6029 .msmsdcc_fmid = 24576000,
6030 .msmsdcc_fmax = 24576000,
6031 .nonremovable = 0,
6032};
6033#else
6034static struct mmc_platform_data msm7x30_sdc1_data = {
6035 .ocr_mask = MMC_VDD_165_195,
6036 .translate_vdd = msm_sdcc_setup_power,
6037 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006038 .msmsdcc_fmin = 144000,
6039 .msmsdcc_fmid = 24576000,
6040 .msmsdcc_fmax = 49152000,
6041 .nonremovable = 0,
6042};
6043#endif
6044#endif
6045
6046#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
6047static struct mmc_platform_data msm7x30_sdc2_data = {
6048 .ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
6049 .translate_vdd = msm_sdcc_setup_power,
6050#ifdef CONFIG_MMC_MSM_SDC2_8_BIT_SUPPORT
6051 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
6052#else
6053 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6054#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006055 .msmsdcc_fmin = 144000,
6056 .msmsdcc_fmid = 24576000,
6057 .msmsdcc_fmax = 49152000,
6058 .nonremovable = 1,
6059};
6060#endif
6061
6062#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
6063static struct mmc_platform_data msm7x30_sdc3_data = {
6064 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6065 .translate_vdd = msm_sdcc_setup_power,
6066 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6067#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
6068 .sdiowakeup_irq = MSM_GPIO_TO_INT(118),
6069#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006070 .msmsdcc_fmin = 144000,
6071 .msmsdcc_fmid = 24576000,
6072 .msmsdcc_fmax = 49152000,
6073 .nonremovable = 0,
6074};
6075#endif
6076
6077#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
6078static struct mmc_platform_data msm7x30_sdc4_data = {
6079 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
6080 .translate_vdd = msm_sdcc_setup_power,
6081 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
6082#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
6083 .status = msm7x30_sdcc_slot_status,
6084 .status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
6085 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
6086#endif
6087 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006088 .msmsdcc_fmin = 144000,
6089 .msmsdcc_fmid = 24576000,
6090 .msmsdcc_fmax = 49152000,
6091 .nonremovable = 0,
6092};
6093#endif
6094
6095#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006096static int msm_sdc1_lvlshft_enable(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006097{
Justin Paupore3f40f342011-08-10 18:52:16 -07006098 static struct regulator *ldo5;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006099 int rc;
6100
6101 /* Enable LDO5, an input to the FET that powers slot 1 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006102
Justin Paupore3f40f342011-08-10 18:52:16 -07006103 ldo5 = regulator_get(NULL, "ldo5");
6104
6105 if (IS_ERR(ldo5)) {
6106 rc = PTR_ERR(ldo5);
6107 pr_err("%s: could not get ldo5: %d\n", __func__, rc);
6108 goto out;
6109 }
6110
6111 rc = regulator_set_voltage(ldo5, 2850000, 2850000);
6112 if (rc) {
6113 pr_err("%s: could not set ldo5 voltage: %d\n", __func__, rc);
6114 goto ldo5_free;
6115 }
6116
6117 rc = regulator_enable(ldo5);
6118 if (rc) {
6119 pr_err("%s: could not enable ldo5: %d\n", __func__, rc);
6120 goto ldo5_free;
6121 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006122
6123 /* Enable GPIO 35, to turn on the FET that powers slot 1 */
6124 rc = msm_gpios_request_enable(sdc1_lvlshft_cfg_data,
6125 ARRAY_SIZE(sdc1_lvlshft_cfg_data));
6126 if (rc)
6127 printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
6128
6129 rc = gpio_direction_output(GPIO_PIN(sdc1_lvlshft_cfg_data[0].gpio_cfg),
6130 1);
6131 if (rc)
6132 printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006133
6134 return 0;
6135
6136ldo5_free:
6137 regulator_put(ldo5);
6138out:
6139 ldo5 = NULL;
6140 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006141}
6142#endif
6143
Justin Paupore3f40f342011-08-10 18:52:16 -07006144static int mmc_regulator_init(int sdcc_no, const char *supply, int uV)
6145{
6146 int rc;
6147
6148 BUG_ON(sdcc_no < 1 || sdcc_no > 4);
6149
6150 sdcc_no--;
6151
6152 sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply);
6153
6154 if (IS_ERR(sdcc_vreg_data[sdcc_no])) {
6155 rc = PTR_ERR(sdcc_vreg_data[sdcc_no]);
6156 pr_err("%s: could not get regulator \"%s\": %d\n",
6157 __func__, supply, rc);
6158 goto out;
6159 }
6160
6161 rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV);
6162
6163 if (rc) {
6164 pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n",
6165 __func__, supply, uV, rc);
6166 goto reg_free;
6167 }
6168
6169 return rc;
6170
6171reg_free:
6172 regulator_put(sdcc_vreg_data[sdcc_no]);
6173out:
6174 sdcc_vreg_data[sdcc_no] = NULL;
6175 return rc;
6176}
6177
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006178static void __init msm7x30_init_mmc(void)
6179{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006180#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006181 if (mmc_regulator_init(1, "s3", 1800000))
6182 goto out1;
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05306183 msm7x30_sdc1_data.swfi_latency = msm7x30_power_collapse_latency(
6184 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT);
Justin Paupore3f40f342011-08-10 18:52:16 -07006185
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006186 if (machine_is_msm7x30_fluid()) {
6187 msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
Justin Paupore3f40f342011-08-10 18:52:16 -07006188 if (msm_sdc1_lvlshft_enable()) {
6189 pr_err("%s: could not enable level shift\n");
6190 goto out1;
6191 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006192 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006193
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006194 msm_add_sdcc(1, &msm7x30_sdc1_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006195out1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006196#endif
6197#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006198 if (mmc_regulator_init(2, "s3", 1800000))
6199 goto out2;
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05306200 msm7x30_sdc2_data.swfi_latency = msm7x30_power_collapse_latency(
6201 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT);
Justin Paupore3f40f342011-08-10 18:52:16 -07006202
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006203 if (machine_is_msm8x55_svlte_surf())
6204 msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
Sujith Reddy Thumma84a0f512011-08-29 09:57:03 +05306205 if (machine_is_msm8x55_svlte_surf() ||
6206 machine_is_msm8x55_svlte_ffa()) {
6207 msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
6208 msm7x30_sdc2_data.is_sdio_al_client = 1;
6209 }
Justin Paupore3f40f342011-08-10 18:52:16 -07006210
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006211 msm_add_sdcc(2, &msm7x30_sdc2_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006212out2:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006213#endif
6214#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006215 if (mmc_regulator_init(3, "s3", 1800000))
6216 goto out3;
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05306217 msm7x30_sdc3_data.swfi_latency = msm7x30_power_collapse_latency(
6218 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT);
Justin Paupore3f40f342011-08-10 18:52:16 -07006219
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006220 msm_sdcc_setup_gpio(3, 1);
6221 msm_add_sdcc(3, &msm7x30_sdc3_data);
Justin Paupore3f40f342011-08-10 18:52:16 -07006222out3:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006223#endif
6224#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
Justin Paupore3f40f342011-08-10 18:52:16 -07006225 if (mmc_regulator_init(4, "mmc", 2850000))
6226 return;
Pratibhasagar V3e7c0fc2012-02-28 11:04:28 +05306227 msm7x30_sdc4_data.swfi_latency = msm7x30_power_collapse_latency(
6228 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT);
Justin Paupore3f40f342011-08-10 18:52:16 -07006229
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006230 msm_add_sdcc(4, &msm7x30_sdc4_data);
6231#endif
6232
6233}
6234
6235static void __init msm7x30_init_nand(void)
6236{
6237 char *build_id;
6238 struct flash_platform_data *plat_data;
6239
6240 build_id = socinfo_get_build_id();
6241 if (build_id == NULL) {
6242 pr_err("%s: Build ID not available from socinfo\n", __func__);
6243 return;
6244 }
6245
6246 if (build_id[8] == 'C' &&
6247 !msm_gpios_request_enable(msm_nand_ebi2_cfg_data,
6248 ARRAY_SIZE(msm_nand_ebi2_cfg_data))) {
6249 plat_data = msm_device_nand.dev.platform_data;
6250 plat_data->interleave = 1;
6251 printk(KERN_INFO "%s: Interleave mode Build ID found\n",
6252 __func__);
6253 }
6254}
6255
6256#ifdef CONFIG_SERIAL_MSM_CONSOLE
6257static struct msm_gpio uart2_config_data[] = {
6258 { GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
6259 { GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
6260 { GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
6261 { GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
6262};
6263
6264static void msm7x30_init_uart2(void)
6265{
6266 msm_gpios_request_enable(uart2_config_data,
6267 ARRAY_SIZE(uart2_config_data));
6268
6269}
6270#endif
6271
6272/* TSIF begin */
6273#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6274
6275#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6276#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6277#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6278#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
6279
6280static const struct msm_gpio tsif_gpios[] = {
6281 { .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
6282 { .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
6283 { .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
6284 { .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
6285};
6286
6287static struct msm_tsif_platform_data tsif_platform_data = {
6288 .num_gpios = ARRAY_SIZE(tsif_gpios),
6289 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -07006290 .tsif_pclk = "iface_clk",
6291 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006292};
6293#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
6294/* TSIF end */
6295
6296static void __init pmic8058_leds_init(void)
6297{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306298 if (machine_is_msm7x30_surf())
6299 pm8058_7x30_data.leds_pdata = &pm8058_surf_leds_data;
6300 else if (!machine_is_msm7x30_fluid())
6301 pm8058_7x30_data.leds_pdata = &pm8058_ffa_leds_data;
6302 else if (machine_is_msm7x30_fluid())
6303 pm8058_7x30_data.leds_pdata = &pm8058_fluid_leds_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006304}
6305
6306static struct msm_spm_platform_data msm_spm_data __initdata = {
6307 .reg_base_addr = MSM_SAW_BASE,
6308
6309 .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
6310 .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
6311 .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
6312 .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
6313
6314 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
6315 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
6316 .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
6317
6318 .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
6319 .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
6320 .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
6321
6322 .awake_vlevel = 0xF2,
6323 .retention_vlevel = 0xE0,
6324 .collapse_vlevel = 0x72,
6325 .retention_mid_vlevel = 0xE0,
6326 .collapse_mid_vlevel = 0xE0,
6327
6328 .vctl_timeout_us = 50,
6329};
6330
6331#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6332 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6333
6334#define TSC2007_TS_PEN_INT 20
6335
6336static struct msm_gpio tsc2007_config_data[] = {
6337 { GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
6338 "tsc2007_irq" },
6339};
6340
Justin Paupore3f40f342011-08-10 18:52:16 -07006341static struct regulator_bulk_data tsc2007_regs[] = {
6342 { .supply = "s3", .min_uV = 1800000, .max_uV = 1800000 },
6343 { .supply = "s2", .min_uV = 1300000, .max_uV = 1300000 },
6344};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006345
6346static int tsc2007_init(void)
6347{
6348 int rc;
6349
Justin Paupore3f40f342011-08-10 18:52:16 -07006350 rc = regulator_bulk_get(NULL, ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006351
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006352 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006353 pr_err("%s: could not get regulators: %d\n", __func__, rc);
6354 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006355 }
6356
Justin Paupore3f40f342011-08-10 18:52:16 -07006357 rc = regulator_bulk_set_voltage(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6358
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006359 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006360 pr_err("%s: could not set voltages: %d\n", __func__, rc);
6361 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006362 }
6363
Justin Paupore3f40f342011-08-10 18:52:16 -07006364 rc = regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006365
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006366 if (rc) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006367 pr_err("%s: could not enable regulators: %d\n", __func__, rc);
6368 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006369 }
6370
6371 rc = msm_gpios_request_enable(tsc2007_config_data,
6372 ARRAY_SIZE(tsc2007_config_data));
6373 if (rc) {
6374 pr_err("%s: Unable to request gpios\n", __func__);
Justin Paupore3f40f342011-08-10 18:52:16 -07006375 goto reg_disable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006376 }
6377
6378 return 0;
6379
Justin Paupore3f40f342011-08-10 18:52:16 -07006380reg_disable:
6381 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6382reg_free:
6383 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6384out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006385 return rc;
6386}
6387
6388static int tsc2007_get_pendown_state(void)
6389{
6390 int rc;
6391
6392 rc = gpio_get_value(TSC2007_TS_PEN_INT);
6393 if (rc < 0) {
6394 pr_err("%s: MSM GPIO %d read failed\n", __func__,
6395 TSC2007_TS_PEN_INT);
6396 return rc;
6397 }
6398
6399 return (rc == 0 ? 1 : 0);
6400}
6401
6402static void tsc2007_exit(void)
6403{
Justin Paupore3f40f342011-08-10 18:52:16 -07006404
6405 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6406 regulator_bulk_free(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006407
6408 msm_gpios_disable_free(tsc2007_config_data,
6409 ARRAY_SIZE(tsc2007_config_data));
6410}
6411
6412static int tsc2007_power_shutdown(bool enable)
6413{
6414 int rc;
6415
Justin Paupore3f40f342011-08-10 18:52:16 -07006416 rc = (enable == false) ?
6417 regulator_bulk_enable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs) :
6418 regulator_bulk_disable(ARRAY_SIZE(tsc2007_regs), tsc2007_regs);
6419
6420 if (rc) {
6421 pr_err("%s: could not %sable regulators: %d\n",
6422 __func__, enable ? "dis" : "en", rc);
6423 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006424 }
6425
Justin Paupore3f40f342011-08-10 18:52:16 -07006426 if (enable == false)
6427 msleep(20);
6428
6429 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006430}
6431
6432static struct tsc2007_platform_data tsc2007_ts_data = {
6433 .model = 2007,
6434 .x_plate_ohms = 300,
Anirudh Ghayala2cf2e22012-01-25 12:29:42 +05306435 .min_x = 210,
6436 .max_x = 3832,
6437 .min_y = 150,
6438 .max_y = 3936,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006439 .irq_flags = IRQF_TRIGGER_LOW,
6440 .init_platform_hw = tsc2007_init,
6441 .exit_platform_hw = tsc2007_exit,
6442 .power_shutdown = tsc2007_power_shutdown,
6443 .invert_x = true,
6444 .invert_y = true,
6445 /* REVISIT: Temporary fix for reversed pressure */
6446 .invert_z1 = true,
6447 .invert_z2 = true,
6448 .get_pendown_state = tsc2007_get_pendown_state,
6449};
6450
6451static struct i2c_board_info tsc_i2c_board_info[] = {
6452 {
6453 I2C_BOARD_INFO("tsc2007", 0x48),
6454 .irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
6455 .platform_data = &tsc2007_ts_data,
6456 },
6457};
6458#endif
6459
Justin Paupore3f40f342011-08-10 18:52:16 -07006460static struct regulator_bulk_data regs_isa1200[] = {
6461 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
6462 { .supply = "gp10", .min_uV = 2600000, .max_uV = 2600000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006463};
6464
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006465static int isa1200_power(int vreg_on)
6466{
Justin Paupore3f40f342011-08-10 18:52:16 -07006467 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006468
Justin Paupore3f40f342011-08-10 18:52:16 -07006469 rc = vreg_on ?
6470 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200) :
6471 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006472
Justin Paupore3f40f342011-08-10 18:52:16 -07006473 if (rc) {
6474 pr_err("%s: could not %sable regulators: %d\n",
6475 __func__, vreg_on ? "en" : "dis", rc);
6476 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006477 }
6478
6479 /* vote for DO buffer */
6480 rc = pmapp_clock_vote("VIBR", PMAPP_CLOCK_ID_DO,
6481 vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
6482 if (rc) {
6483 pr_err("%s: unable to %svote for d0 clk\n",
6484 __func__, vreg_on ? "" : "de-");
6485 goto vreg_fail;
6486 }
6487
6488 return 0;
6489
6490vreg_fail:
Justin Paupore3f40f342011-08-10 18:52:16 -07006491 if (vreg_on)
6492 regulator_bulk_disable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6493 else
6494 regulator_bulk_enable(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6495out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006496 return rc;
6497}
6498
6499static int isa1200_dev_setup(bool enable)
6500{
Justin Paupore3f40f342011-08-10 18:52:16 -07006501 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006502
6503 if (enable == true) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006504 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_isa1200),
6505 regs_isa1200);
6506
6507 if (rc) {
6508 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006509 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006510 goto out;
6511 }
6512
6513 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_isa1200),
6514 regs_isa1200);
6515 if (rc) {
6516 pr_err("%s: could not set voltages: %d\n",
6517 __func__, rc);
6518 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006519 }
6520
6521 rc = gpio_tlmm_config(GPIO_CFG(HAP_LVL_SHFT_MSM_GPIO, 0,
6522 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
6523 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
6524 if (rc) {
6525 pr_err("%s: Could not configure gpio %d\n",
6526 __func__, HAP_LVL_SHFT_MSM_GPIO);
Justin Paupore3f40f342011-08-10 18:52:16 -07006527 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006528 }
6529
6530 rc = gpio_request(HAP_LVL_SHFT_MSM_GPIO, "haptics_shft_lvl_oe");
6531 if (rc) {
6532 pr_err("%s: unable to request gpio %d (%d)\n",
6533 __func__, HAP_LVL_SHFT_MSM_GPIO, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006534 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006535 }
6536
6537 gpio_set_value(HAP_LVL_SHFT_MSM_GPIO, 1);
6538 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006539 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006540 gpio_free(HAP_LVL_SHFT_MSM_GPIO);
6541 }
6542
6543 return 0;
Justin Paupore3f40f342011-08-10 18:52:16 -07006544
6545reg_free:
6546 regulator_bulk_free(ARRAY_SIZE(regs_isa1200), regs_isa1200);
6547out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006548 return rc;
6549}
6550static struct isa1200_platform_data isa1200_1_pdata = {
6551 .name = "vibrator",
6552 .power_on = isa1200_power,
6553 .dev_setup = isa1200_dev_setup,
6554 .pwm_ch_id = 1, /*channel id*/
6555 /*gpio to enable haptic*/
6556 .hap_en_gpio = PM8058_GPIO_PM_TO_SYS(PMIC_GPIO_HAP_ENABLE),
Mohan Pallaka03122322011-09-09 15:15:43 +05306557 .hap_len_gpio = -1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006558 .max_timeout = 15000,
6559 .mode_ctrl = PWM_GEN_MODE,
6560 .pwm_fd = {
6561 .pwm_div = 256,
6562 },
6563 .is_erm = false,
6564 .smart_en = true,
6565 .ext_clk_en = true,
6566 .chip_en = 1,
6567};
6568
6569static struct i2c_board_info msm_isa1200_board_info[] = {
6570 {
6571 I2C_BOARD_INFO("isa1200_1", 0x90>>1),
6572 .platform_data = &isa1200_1_pdata,
6573 },
6574};
6575
6576
6577static int kp_flip_mpp_config(void)
6578{
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306579 struct pm8xxx_mpp_config_data kp_flip_mpp = {
6580 .type = PM8XXX_MPP_TYPE_D_INPUT,
6581 .level = PM8018_MPP_DIG_LEVEL_S3,
6582 .control = PM8XXX_MPP_DIN_TO_INT,
6583 };
6584
6585 return pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(PM_FLIP_MPP),
6586 &kp_flip_mpp);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006587}
6588
6589static struct flip_switch_pdata flip_switch_data = {
6590 .name = "kp_flip_switch",
6591 .flip_gpio = PM8058_GPIO_PM_TO_SYS(PM8058_GPIOS) + PM_FLIP_MPP,
6592 .left_key = KEY_OPEN,
6593 .right_key = KEY_CLOSE,
6594 .active_low = 0,
6595 .wakeup = 1,
6596 .flip_mpp_config = kp_flip_mpp_config,
6597};
6598
6599static struct platform_device flip_switch_device = {
6600 .name = "kp_flip_switch",
6601 .id = -1,
6602 .dev = {
6603 .platform_data = &flip_switch_data,
6604 }
6605};
6606
Justin Paupore3f40f342011-08-10 18:52:16 -07006607static struct regulator_bulk_data regs_tma300[] = {
6608 { .supply = "gp6", .min_uV = 3050000, .max_uV = 3100000 },
6609 { .supply = "gp7", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006610};
6611
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006612static int tma300_power(int vreg_on)
6613{
Justin Paupore3f40f342011-08-10 18:52:16 -07006614 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006615
Justin Paupore3f40f342011-08-10 18:52:16 -07006616 rc = vreg_on ?
6617 regulator_bulk_enable(ARRAY_SIZE(regs_tma300), regs_tma300) :
6618 regulator_bulk_disable(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006619
Justin Paupore3f40f342011-08-10 18:52:16 -07006620 if (rc)
6621 pr_err("%s: could not %sable regulators: %d\n",
6622 __func__, vreg_on ? "en" : "dis", rc);
6623 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006624}
6625
6626#define TS_GPIO_IRQ 150
6627
6628static int tma300_dev_setup(bool enable)
6629{
Justin Paupore3f40f342011-08-10 18:52:16 -07006630 int rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006631
6632 if (enable) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006633 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_tma300),
6634 regs_tma300);
6635
6636 if (rc) {
6637 pr_err("%s: could not get regulators: %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006638 __func__, rc);
Justin Paupore3f40f342011-08-10 18:52:16 -07006639 goto out;
6640 }
6641
6642 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_tma300),
6643 regs_tma300);
6644
6645 if (rc) {
6646 pr_err("%s: could not set voltages: %d\n",
6647 __func__, rc);
6648 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006649 }
6650
6651 /* enable interrupt gpio */
6652 rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
6653 GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
6654 if (rc) {
6655 pr_err("%s: Could not configure gpio %d\n",
6656 __func__, TS_GPIO_IRQ);
Justin Paupore3f40f342011-08-10 18:52:16 -07006657 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006658 }
6659
6660 /* virtual keys */
6661 tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
6662 properties_kobj = kobject_create_and_add("board_properties",
6663 NULL);
6664 if (!properties_kobj) {
Justin Paupore3f40f342011-08-10 18:52:16 -07006665 pr_err("%s: failed to create a kobject "
6666 "for board_properties\n", __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006667 rc = -ENOMEM;
Justin Paupore3f40f342011-08-10 18:52:16 -07006668 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006669 }
6670 rc = sysfs_create_group(properties_kobj,
6671 &tma300_properties_attr_group);
6672 if (rc) {
6673 pr_err("%s: failed to create a sysfs entry %s\n",
6674 __func__, tma300_vkeys_attr.attr.name);
Justin Paupore3f40f342011-08-10 18:52:16 -07006675 goto kobj_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006676 }
6677 } else {
Justin Paupore3f40f342011-08-10 18:52:16 -07006678 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006679 /* destroy virtual keys */
6680 if (properties_kobj) {
6681 sysfs_remove_group(properties_kobj,
6682 &tma300_properties_attr_group);
6683 kobject_put(properties_kobj);
6684 }
6685 }
6686 return 0;
6687
Justin Paupore3f40f342011-08-10 18:52:16 -07006688kobj_free:
6689 kobject_put(properties_kobj);
6690 properties_kobj = NULL;
6691reg_free:
6692 regulator_bulk_free(ARRAY_SIZE(regs_tma300), regs_tma300);
6693out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006694 return rc;
6695}
6696
6697static struct cy8c_ts_platform_data cy8ctma300_pdata = {
6698 .power_on = tma300_power,
6699 .dev_setup = tma300_dev_setup,
6700 .ts_name = "msm_tma300_ts",
6701 .dis_min_x = 0,
6702 .dis_max_x = 479,
6703 .dis_min_y = 0,
6704 .dis_max_y = 799,
6705 .res_x = 479,
6706 .res_y = 1009,
6707 .min_tid = 1,
6708 .max_tid = 255,
6709 .min_touch = 0,
6710 .max_touch = 255,
6711 .min_width = 0,
6712 .max_width = 255,
6713 .invert_y = 1,
6714 .nfingers = 4,
6715 .irq_gpio = TS_GPIO_IRQ,
6716 .resout_gpio = -1,
6717};
6718
6719static struct i2c_board_info cy8ctma300_board_info[] = {
6720 {
6721 I2C_BOARD_INFO("cy8ctma300", 0x2),
6722 .platform_data = &cy8ctma300_pdata,
6723 }
6724};
6725
Daniel Walker8d747cd2010-02-25 11:37:43 -08006726static void __init msm7x30_init(void)
6727{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006728 int rc;
6729 unsigned smem_size;
6730 uint32_t usb_hub_gpio_cfg_value = GPIO_CFG(56,
6731 0,
6732 GPIO_CFG_OUTPUT,
6733 GPIO_CFG_NO_PULL,
6734 GPIO_CFG_2MA);
6735 uint32_t soc_version = 0;
Pavankumar Kondeti5155e2c2010-12-08 13:37:08 +05306736
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006737 soc_version = socinfo_get_version();
6738
Stephen Boydbb600ae2011-08-02 20:11:40 -07006739 msm_clock_init(&msm7x30_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006740#ifdef CONFIG_SERIAL_MSM_CONSOLE
6741 msm7x30_init_uart2();
6742#endif
6743 msm_spm_init(&msm_spm_data, 1);
Matt Wagantallec57f062011-08-16 23:54:46 -07006744 acpuclk_init(&acpuclk_7x30_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006745 if (machine_is_msm7x30_surf() || machine_is_msm7x30_fluid())
6746 msm7x30_cfg_smsc911x();
6747
6748#ifdef CONFIG_USB_MSM_OTG_72K
6749 if (SOCINFO_VERSION_MAJOR(soc_version) >= 2 &&
6750 SOCINFO_VERSION_MINOR(soc_version) >= 1) {
6751 pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
6752 msm_otg_pdata.ldo_set_voltage = 0;
6753 }
6754
6755 msm_device_otg.dev.platform_data = &msm_otg_pdata;
6756#ifdef CONFIG_USB_GADGET
6757 msm_otg_pdata.swfi_latency =
6758 msm_pm_data
6759 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
6760 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
6761#endif
6762#endif
6763 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
6764 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
6765#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
6766 msm_device_tsif.dev.platform_data = &tsif_platform_data;
6767#endif
6768 if (machine_is_msm7x30_fluid()) {
6769 msm_adc_pdata.dev_names = msm_adc_fluid_device_names;
6770 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_fluid_device_names);
6771 } else {
6772 msm_adc_pdata.dev_names = msm_adc_surf_device_names;
6773 msm_adc_pdata.num_adc = ARRAY_SIZE(msm_adc_surf_device_names);
6774 }
6775
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306776 pmic8058_leds_init();
6777
6778 buses_init();
6779
Anirudh Ghayal9d9cdc22011-10-10 17:17:07 +05306780#ifdef CONFIG_MSM_SSBI
6781 msm_device_ssbi_pmic1.dev.platform_data =
6782 &msm7x30_ssbi_pm8058_pdata;
6783#endif
6784
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006785 platform_add_devices(msm_footswitch_devices,
6786 msm_num_footswitch_devices);
Daniel Walker8d747cd2010-02-25 11:37:43 -08006787 platform_add_devices(devices, ARRAY_SIZE(devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006788#ifdef CONFIG_USB_EHCI_MSM_72K
6789 msm_add_host(0, &msm_usb_host_pdata);
6790#endif
6791 msm7x30_init_mmc();
6792 msm7x30_init_nand();
6793 msm_qsd_spi_init();
6794
6795#ifdef CONFIG_SPI_QSD
6796 if (machine_is_msm7x30_fluid())
6797 spi_register_board_info(lcdc_sharp_spi_board_info,
6798 ARRAY_SIZE(lcdc_sharp_spi_board_info));
6799 else
6800 spi_register_board_info(lcdc_toshiba_spi_board_info,
6801 ARRAY_SIZE(lcdc_toshiba_spi_board_info));
6802#endif
6803
Justin Paupore3f40f342011-08-10 18:52:16 -07006804 atv_dac_power_init();
6805 sensors_ldo_init();
6806 hdmi_init_regs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006807 msm_fb_add_devices();
6808 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06006809 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006810 msm_device_i2c_init();
6811 msm_device_i2c_2_init();
6812 qup_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006813 msm7x30_init_marimba();
6814#ifdef CONFIG_MSM7KV2_AUDIO
6815 snddev_poweramp_gpio_init();
Justin Paupore3f40f342011-08-10 18:52:16 -07006816 snddev_hsed_voltage_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006817 aux_pcm_gpio_init();
6818#endif
6819
6820 i2c_register_board_info(0, msm_i2c_board_info,
6821 ARRAY_SIZE(msm_i2c_board_info));
6822
6823 if (!machine_is_msm8x55_svlte_ffa() && !machine_is_msm7x30_fluid())
6824 marimba_pdata.tsadc = &marimba_tsadc_pdata;
6825
6826 if (machine_is_msm7x30_fluid())
6827 i2c_register_board_info(0, cy8info,
6828 ARRAY_SIZE(cy8info));
6829#ifdef CONFIG_BOSCH_BMA150
6830 if (machine_is_msm7x30_fluid())
6831 i2c_register_board_info(0, bma150_board_info,
6832 ARRAY_SIZE(bma150_board_info));
6833#endif
6834
6835 i2c_register_board_info(2, msm_marimba_board_info,
6836 ARRAY_SIZE(msm_marimba_board_info));
6837
6838 i2c_register_board_info(2, msm_i2c_gsbi7_timpani_info,
6839 ARRAY_SIZE(msm_i2c_gsbi7_timpani_info));
6840
6841 i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
6842 ARRAY_SIZE(msm_camera_boardinfo));
6843
6844 bt_power_init();
6845#ifdef CONFIG_I2C_SSBI
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006846 msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
6847#endif
6848 if (machine_is_msm7x30_fluid())
6849 i2c_register_board_info(0, msm_isa1200_board_info,
6850 ARRAY_SIZE(msm_isa1200_board_info));
6851
6852#if defined(CONFIG_TOUCHSCREEN_TSC2007) || \
6853 defined(CONFIG_TOUCHSCREEN_TSC2007_MODULE)
6854 if (machine_is_msm8x55_svlte_ffa())
6855 i2c_register_board_info(2, tsc_i2c_board_info,
6856 ARRAY_SIZE(tsc_i2c_board_info));
6857#endif
6858
6859 if (machine_is_msm7x30_surf())
6860 platform_device_register(&flip_switch_device);
Anirudh Ghayalc2019332011-11-12 06:29:10 +05306861
6862 pm8058_gpios_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006863
6864 if (machine_is_msm7x30_fluid()) {
6865 /* Initialize platform data for fluid v2 hardware */
6866 if (SOCINFO_VERSION_MAJOR(
6867 socinfo_get_platform_version()) == 2) {
6868 cy8ctma300_pdata.res_y = 920;
6869 cy8ctma300_pdata.invert_y = 0;
6870 }
6871 i2c_register_board_info(0, cy8ctma300_board_info,
6872 ARRAY_SIZE(cy8ctma300_board_info));
6873 }
6874
6875 if (machine_is_msm8x55_svlte_surf() || machine_is_msm8x55_svlte_ffa()) {
6876 rc = gpio_tlmm_config(usb_hub_gpio_cfg_value, GPIO_CFG_ENABLE);
6877 if (rc)
6878 pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
6879 __func__, usb_hub_gpio_cfg_value, rc);
6880 }
6881
6882 boot_reason = *(unsigned int *)
6883 (smem_get_entry(SMEM_POWER_ON_STATUS_INFO, &smem_size));
6884 printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
6885}
6886
6887static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
6888static int __init pmem_sf_size_setup(char *p)
6889{
6890 pmem_sf_size = memparse(p, NULL);
6891 return 0;
6892}
6893early_param("pmem_sf_size", pmem_sf_size_setup);
6894
6895static unsigned fb_size = MSM_FB_SIZE;
6896static int __init fb_size_setup(char *p)
6897{
6898 fb_size = memparse(p, NULL);
6899 return 0;
6900}
6901early_param("fb_size", fb_size_setup);
6902
6903static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
6904static int __init pmem_adsp_size_setup(char *p)
6905{
6906 pmem_adsp_size = memparse(p, NULL);
6907 return 0;
6908}
6909early_param("pmem_adsp_size", pmem_adsp_size_setup);
6910
6911static unsigned fluid_pmem_adsp_size = MSM_FLUID_PMEM_ADSP_SIZE;
6912static int __init fluid_pmem_adsp_size_setup(char *p)
6913{
6914 fluid_pmem_adsp_size = memparse(p, NULL);
6915 return 0;
6916}
6917early_param("fluid_pmem_adsp_size", fluid_pmem_adsp_size_setup);
6918
6919static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
6920static int __init pmem_audio_size_setup(char *p)
6921{
6922 pmem_audio_size = memparse(p, NULL);
6923 return 0;
6924}
6925early_param("pmem_audio_size", pmem_audio_size_setup);
6926
6927static unsigned pmem_kernel_ebi0_size = PMEM_KERNEL_EBI0_SIZE;
6928static int __init pmem_kernel_ebi0_size_setup(char *p)
6929{
6930 pmem_kernel_ebi0_size = memparse(p, NULL);
6931 return 0;
6932}
6933early_param("pmem_kernel_ebi0_size", pmem_kernel_ebi0_size_setup);
6934
6935static struct memtype_reserve msm7x30_reserve_table[] __initdata = {
6936 [MEMTYPE_SMI] = {
6937 },
6938 [MEMTYPE_EBI0] = {
6939 .flags = MEMTYPE_FLAGS_1M_ALIGN,
6940 },
6941 [MEMTYPE_EBI1] = {
6942 .flags = MEMTYPE_FLAGS_1M_ALIGN,
6943 },
6944};
6945
6946static void __init size_pmem_devices(void)
6947{
6948#ifdef CONFIG_ANDROID_PMEM
6949 unsigned long size;
6950
6951 if machine_is_msm7x30_fluid()
6952 size = fluid_pmem_adsp_size;
6953 else
6954 size = pmem_adsp_size;
6955 android_pmem_adsp_pdata.size = size;
6956 android_pmem_audio_pdata.size = pmem_audio_size;
6957 android_pmem_pdata.size = pmem_sf_size;
6958#endif
6959}
6960
6961static void __init reserve_memory_for(struct android_pmem_platform_data *p)
6962{
6963 msm7x30_reserve_table[p->memory_type].size += p->size;
6964}
6965
6966static void __init reserve_pmem_memory(void)
6967{
6968#ifdef CONFIG_ANDROID_PMEM
6969 reserve_memory_for(&android_pmem_adsp_pdata);
6970 reserve_memory_for(&android_pmem_audio_pdata);
6971 reserve_memory_for(&android_pmem_pdata);
6972 msm7x30_reserve_table[MEMTYPE_EBI0].size += pmem_kernel_ebi0_size;
6973#endif
6974}
6975
6976static void __init msm7x30_calculate_reserve_sizes(void)
6977{
6978 size_pmem_devices();
6979 reserve_pmem_memory();
6980}
6981
6982static int msm7x30_paddr_to_memtype(unsigned int paddr)
6983{
Pankaj Kumarac69ee62012-01-26 00:21:56 +05306984 if (paddr < phys_add)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006985 return MEMTYPE_EBI0;
Pankaj Kumarac69ee62012-01-26 00:21:56 +05306986 if (paddr >= phys_add && paddr < 0x80000000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07006987 return MEMTYPE_EBI1;
6988 return MEMTYPE_NONE;
6989}
6990
6991static struct reserve_info msm7x30_reserve_info __initdata = {
6992 .memtype_reserve_table = msm7x30_reserve_table,
6993 .calculate_reserve_sizes = msm7x30_calculate_reserve_sizes,
6994 .paddr_to_memtype = msm7x30_paddr_to_memtype,
6995};
6996
6997static void __init msm7x30_reserve(void)
6998{
6999 reserve_info = &msm7x30_reserve_info;
7000 msm_reserve();
7001}
7002
7003static void __init msm7x30_allocate_memory_regions(void)
7004{
7005 void *addr;
7006 unsigned long size;
7007
7008 size = fb_size ? : MSM_FB_SIZE;
7009 addr = alloc_bootmem_align(size, 0x1000);
7010 msm_fb_resources[0].start = __pa(addr);
7011 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
7012 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
7013 size, addr, __pa(addr));
Daniel Walker8d747cd2010-02-25 11:37:43 -08007014}
7015
7016static void __init msm7x30_map_io(void)
7017{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007018 msm_shared_ram_phys = 0x00100000;
Daniel Walker8d747cd2010-02-25 11:37:43 -08007019 msm_map_msm7x30_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07007020 if (socinfo_init() < 0)
7021 printk(KERN_ERR "%s: socinfo_init() failed!\n",
7022 __func__);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007023}
7024
7025static void __init msm7x30_init_early(void)
7026{
7027 msm7x30_allocate_memory_regions();
Daniel Walker8d747cd2010-02-25 11:37:43 -08007028}
7029
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307030static void __init msm7x30_fixup(struct machine_desc *desc, struct tag *tags,
7031 char **cmdline, struct meminfo *mi)
7032{
7033 for (; tags->hdr.size; tags = tag_next(tags)) {
7034 if (tags->hdr.tag == ATAG_MEM && tags->u.mem.start ==
7035 DDR1_BANK_BASE) {
7036 ebi1_phys_offset = DDR1_BANK_BASE;
7037 phys_add = DDR1_BANK_BASE;
7038 break;
7039 }
7040 }
7041}
7042
Daniel Walker8d747cd2010-02-25 11:37:43 -08007043MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
Russell Kingb75c1782011-01-04 19:03:16 +00007044 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007045 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007046 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007047 .init_irq = msm7x30_init_irq,
7048 .init_machine = msm7x30_init,
7049 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007050 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307051 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307052 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007053MACHINE_END
7054
7055MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
Russell Kingb75c1782011-01-04 19:03:16 +00007056 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007057 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007058 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007059 .init_irq = msm7x30_init_irq,
7060 .init_machine = msm7x30_init,
7061 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007062 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307063 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307064 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007065MACHINE_END
7066
7067MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
Russell Kingb75c1782011-01-04 19:03:16 +00007068 .boot_params = PLAT_PHYS_OFFSET + 0x100,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007069 .map_io = msm7x30_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007070 .reserve = msm7x30_reserve,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007071 .init_irq = msm7x30_init_irq,
7072 .init_machine = msm7x30_init,
7073 .timer = &msm_timer,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007074 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307075 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307076 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007077MACHINE_END
7078
7079MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
7080 .boot_params = PHYS_OFFSET + 0x100,
7081 .map_io = msm7x30_map_io,
7082 .reserve = msm7x30_reserve,
7083 .init_irq = msm7x30_init_irq,
7084 .init_machine = msm7x30_init,
7085 .timer = &msm_timer,
7086 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307087 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307088 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007089MACHINE_END
7090
7091MACHINE_START(MSM8X55_FFA, "QCT MSM8X55 FFA")
7092 .boot_params = PHYS_OFFSET + 0x100,
7093 .map_io = msm7x30_map_io,
7094 .reserve = msm7x30_reserve,
7095 .init_irq = msm7x30_init_irq,
7096 .init_machine = msm7x30_init,
7097 .timer = &msm_timer,
7098 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307099 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307100 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007101MACHINE_END
7102MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
7103 .boot_params = PHYS_OFFSET + 0x100,
7104 .map_io = msm7x30_map_io,
7105 .reserve = msm7x30_reserve,
7106 .init_irq = msm7x30_init_irq,
7107 .init_machine = msm7x30_init,
7108 .timer = &msm_timer,
7109 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307110 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307111 .fixup = msm7x30_fixup,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07007112MACHINE_END
7113MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA")
7114 .boot_params = PHYS_OFFSET + 0x100,
7115 .map_io = msm7x30_map_io,
7116 .reserve = msm7x30_reserve,
7117 .init_irq = msm7x30_init_irq,
7118 .init_machine = msm7x30_init,
7119 .timer = &msm_timer,
7120 .init_early = msm7x30_init_early,
Taniya Dasbae99fb2011-10-12 09:55:13 +05307121 .handle_irq = vic_handle_irq,
Pankaj Kumarac69ee62012-01-26 00:21:56 +05307122 .fixup = msm7x30_fixup,
Daniel Walker8d747cd2010-02-25 11:37:43 -08007123MACHINE_END