blob: 3ac41ed36063adf447833659c5b7e691068a24f1 [file] [log] [blame]
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
2 *
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 *
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080012 */
13#include <linux/kernel.h>
14#include <linux/platform_device.h>
15#include <linux/io.h>
16#include <linux/irq.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070017#include <linux/i2c.h>
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -070018#include <linux/i2c/sx150x.h>
Amir Samuelov5137e392011-09-21 17:31:25 +030019#include <linux/i2c/isl9519.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070020#include <linux/gpio.h>
21#include <linux/msm_ssbi.h>
22#include <linux/regulator/gpio-regulator.h>
23#include <linux/mfd/pm8xxx/pm8921.h>
Siddartha Mohanadoss77d106e2011-09-20 16:25:59 -070024#include <linux/mfd/pm8xxx/pm8921-adc.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070025#include <linux/regulator/consumer.h>
26#include <linux/spi/spi.h>
27#include <linux/slimbus/slimbus.h>
28#include <linux/bootmem.h>
Lucille Sylvester34ec3692011-08-16 16:28:04 -060029#include <linux/msm_kgsl.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070030#ifdef CONFIG_ANDROID_PMEM
31#include <linux/android_pmem.h>
32#endif
33#include <linux/cyttsp.h>
34#include <linux/dma-mapping.h>
35#include <linux/platform_data/qcom_crypto_device.h>
Ankur Nandwanib0039b02011-08-09 14:00:45 -070036#include <linux/platform_data/qcom_wcnss_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070037#include <linux/leds.h>
38#include <linux/leds-pm8xxx.h>
Mohan Pallaka50837382011-09-07 11:00:57 +053039#include <linux/i2c/atmel_mxt_ts.h>
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -070040#include <linux/msm_tsens.h>
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -070041#include <linux/ks8851.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080042
43#include <asm/mach-types.h>
44#include <asm/mach/arch.h>
Larry Basselb4126da2011-07-18 14:31:33 -070045#include <asm/setup.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080046#include <asm/hardware/gic.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070047#include <asm/mach/mmc.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080048
49#include <mach/board.h>
50#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051#include <mach/msm_spi.h>
52#ifdef CONFIG_USB_MSM_OTG_72K
53#include <mach/msm_hsusb.h>
54#else
55#include <linux/usb/msm_hsusb.h>
56#endif
57#include <linux/usb/android.h>
58#include <mach/usbdiag.h>
59#include <mach/socinfo.h>
60#include <mach/rpm.h>
61#include <mach/gpio.h>
Rohit Vaswania513aa8d2011-07-18 15:14:28 -070062#include <mach/gpiomux.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070063#include <mach/msm_bus_board.h>
64#include <mach/msm_memtypes.h>
65#include <mach/dma.h>
66#include <mach/msm_dsps.h>
67#include <mach/msm_xo.h>
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -070068#include <mach/restart.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080069
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070070#ifdef CONFIG_WCD9310_CODEC
71#include <linux/slimbus/slimbus.h>
72#include <linux/mfd/wcd9310/core.h>
73#include <linux/mfd/wcd9310/pdata.h>
74#endif
75
Laura Abbottd6183792011-08-19 13:42:24 -070076#include <linux/ion.h>
77#include <mach/ion.h>
78
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070079#include "timer.h"
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -080080#include "devices.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070081#include "devices-msm8x60.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070082#include "spm.h"
83#include "board-msm8960.h"
84#include "pm.h"
85#include "cpuidle.h"
86#include "rpm_resources.h"
87#include "mpm.h"
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070088#include "acpuclock.h"
David Collins4c31a872011-08-31 10:07:10 -070089#include "rpm_log.h"
Naveen Ramaraj76483ad2011-09-06 14:25:44 -070090#include "smd_private.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070091
92static struct platform_device msm_fm_platform_init = {
93 .name = "iris_fm",
94 .id = -1,
95};
96
97struct pm8xxx_gpio_init {
98 unsigned gpio;
99 struct pm_gpio config;
100};
101
102struct pm8xxx_mpp_init {
103 unsigned mpp;
104 struct pm8xxx_mpp_config_data config;
105};
106
107#define PM8XXX_GPIO_INIT(_gpio, _dir, _buf, _val, _pull, _vin, _out_strength, \
108 _func, _inv, _disable) \
109{ \
110 .gpio = PM8921_GPIO_PM_TO_SYS(_gpio), \
111 .config = { \
112 .direction = _dir, \
113 .output_buffer = _buf, \
114 .output_value = _val, \
115 .pull = _pull, \
116 .vin_sel = _vin, \
117 .out_strength = _out_strength, \
118 .function = _func, \
119 .inv_int_pol = _inv, \
120 .disable_pin = _disable, \
121 } \
122}
123
124#define PM8XXX_MPP_INIT(_mpp, _type, _level, _control) \
125{ \
126 .mpp = PM8921_MPP_PM_TO_SYS(_mpp), \
127 .config = { \
128 .type = PM8XXX_MPP_TYPE_##_type, \
129 .level = _level, \
130 .control = PM8XXX_MPP_##_control, \
131 } \
132}
133
134#define PM8XXX_GPIO_DISABLE(_gpio) \
135 PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, 0, 0, 0, PM_GPIO_VIN_S4, \
136 0, 0, 0, 1)
137
138#define PM8XXX_GPIO_OUTPUT(_gpio, _val) \
139 PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
140 PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \
141 PM_GPIO_STRENGTH_HIGH, \
142 PM_GPIO_FUNC_NORMAL, 0, 0)
143
144#define PM8XXX_GPIO_INPUT(_gpio, _pull) \
145 PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, PM_GPIO_OUT_BUF_CMOS, 0, \
146 _pull, PM_GPIO_VIN_S4, \
147 PM_GPIO_STRENGTH_NO, \
148 PM_GPIO_FUNC_NORMAL, 0, 0)
149
150#define PM8XXX_GPIO_OUTPUT_FUNC(_gpio, _val, _func) \
151 PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
152 PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \
153 PM_GPIO_STRENGTH_HIGH, \
154 _func, 0, 0)
155
156/* Initial PM8921 GPIO configurations */
157static struct pm8xxx_gpio_init pm8921_gpios[] __initdata = {
158 PM8XXX_GPIO_DISABLE(6), /* Disable unused */
159 PM8XXX_GPIO_DISABLE(7), /* Disable NFC */
160 PM8XXX_GPIO_INPUT(16, PM_GPIO_PULL_UP_30), /* SD_CARD_WP */
Amir Samuelov0c7270f2011-09-07 03:13:47 +0300161 /* External regulator shared by display and touchscreen on LiQUID */
162 PM8XXX_GPIO_OUTPUT(17, 0), /* DISP 3.3 V Boost */
163 PM8XXX_GPIO_OUTPUT(21, 1), /* Backlight Enable */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700164 PM8XXX_GPIO_DISABLE(22), /* Disable NFC */
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -0700165 PM8XXX_GPIO_OUTPUT_FUNC(24, 0, PM_GPIO_FUNC_2), /* Bl: Off, PWM mode */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700166 PM8XXX_GPIO_INPUT(26, PM_GPIO_PULL_UP_30), /* SD_CARD_DET_N */
Nagamalleswararao Ganjica0adc02011-09-22 20:35:53 -0700167 PM8XXX_GPIO_OUTPUT(43, PM_GPIO_PULL_UP_30), /* DISP_RESET_N */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700168};
169
170/* Initial PM8921 MPP configurations */
171static struct pm8xxx_mpp_init pm8921_mpps[] __initdata = {
172 /* External 5V regulator enable; shared by HDMI and USB_OTG switches. */
173 PM8XXX_MPP_INIT(7, D_INPUT, PM8921_MPP_DIG_LEVEL_VPH, DIN_TO_INT),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700174 PM8XXX_MPP_INIT(PM8921_AMUX_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
175 DOUT_CTRL_LOW),
176};
177
178static void __init pm8921_gpio_mpp_init(void)
179{
180 int i, rc;
181
182 for (i = 0; i < ARRAY_SIZE(pm8921_gpios); i++) {
183 rc = pm8xxx_gpio_config(pm8921_gpios[i].gpio,
184 &pm8921_gpios[i].config);
185 if (rc) {
186 pr_err("%s: pm8xxx_gpio_config: rc=%d\n", __func__, rc);
187 break;
188 }
189 }
190
191 for (i = 0; i < ARRAY_SIZE(pm8921_mpps); i++) {
192 rc = pm8xxx_mpp_config(pm8921_mpps[i].mpp,
193 &pm8921_mpps[i].config);
194 if (rc) {
195 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
196 break;
197 }
198 }
199}
200
201#define FPGA_CS_GPIO 14
202#define KS8851_RST_GPIO 89
203#define KS8851_IRQ_GPIO 90
204
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700205#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
206enum {
Abhijeet Dharmapurikar0fda5602011-08-17 18:00:55 -0700207 GPIO_EXPANDER_IRQ_BASE = (PM8921_IRQ_BASE + PM8921_NR_IRQS),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700208 GPIO_EXPANDER_GPIO_BASE = (PM8921_MPP_BASE + PM8921_NR_MPPS),
209 /* CAM Expander */
210 GPIO_CAM_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE,
211 GPIO_CAM_GP_STROBE_READY = GPIO_CAM_EXPANDER_BASE,
212 GPIO_CAM_GP_AFBUSY,
213 GPIO_CAM_GP_STROBE_CE,
214 GPIO_CAM_GP_CAM1MP_XCLR,
215 GPIO_CAM_GP_CAMIF_RESET_N,
216 GPIO_CAM_GP_XMT_FLASH_INT,
217 GPIO_CAM_GP_LED_EN1,
218 GPIO_CAM_GP_LED_EN2,
219
220};
221#endif
222
Harini Jayaraman608d0462011-08-09 19:10:03 -0600223/* The SPI configurations apply to GSBI 1*/
224static struct gpiomux_setting spi_active = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700225 .func = GPIOMUX_FUNC_1,
226 .drv = GPIOMUX_DRV_8MA,
227 .pull = GPIOMUX_PULL_NONE,
228};
229
Harini Jayaraman608d0462011-08-09 19:10:03 -0600230static struct gpiomux_setting spi_suspended_config = {
231 .func = GPIOMUX_FUNC_GPIO,
232 .drv = GPIOMUX_DRV_2MA,
233 .pull = GPIOMUX_PULL_DOWN,
234};
235
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700236static struct gpiomux_setting gsbi3 = {
237 .func = GPIOMUX_FUNC_1,
238 .drv = GPIOMUX_DRV_8MA,
239 .pull = GPIOMUX_PULL_NONE,
240};
241
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700242static struct gpiomux_setting gsbi5 = {
243 .func = GPIOMUX_FUNC_1,
244 .drv = GPIOMUX_DRV_8MA,
245 .pull = GPIOMUX_PULL_NONE,
246};
247
248static struct gpiomux_setting gsbi10 = {
249 .func = GPIOMUX_FUNC_2,
250 .drv = GPIOMUX_DRV_8MA,
251 .pull = GPIOMUX_PULL_NONE,
252};
253
254static struct gpiomux_setting gsbi12 = {
255 .func = GPIOMUX_FUNC_1,
256 .drv = GPIOMUX_DRV_8MA,
257 .pull = GPIOMUX_PULL_NONE,
258};
259
260static struct gpiomux_setting cdc_mclk = {
261 .func = GPIOMUX_FUNC_1,
262 .drv = GPIOMUX_DRV_8MA,
263 .pull = GPIOMUX_PULL_NONE,
264};
265
Bhalchandra Gajare0e795c42011-08-15 18:10:30 -0700266static struct gpiomux_setting audio_auxpcm[] = {
267 /* Suspended state */
268 {
269 .func = GPIOMUX_FUNC_GPIO,
270 .drv = GPIOMUX_DRV_2MA,
271 .pull = GPIOMUX_PULL_NONE,
272 },
273 /* Active state */
274 {
275 .func = GPIOMUX_FUNC_1,
276 .drv = GPIOMUX_DRV_2MA,
277 .pull = GPIOMUX_PULL_NONE,
278 },
279};
280
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -0700281#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700282static struct gpiomux_setting gpio_eth_config = {
283 .pull = GPIOMUX_PULL_NONE,
284 .drv = GPIOMUX_DRV_8MA,
285 .func = GPIOMUX_FUNC_GPIO,
286};
Stepan Moskovchenko41d168272011-08-09 17:09:42 -0700287#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700288
289static struct gpiomux_setting slimbus = {
290 .func = GPIOMUX_FUNC_1,
291 .drv = GPIOMUX_DRV_8MA,
292 .pull = GPIOMUX_PULL_KEEPER,
293};
294
295struct msm_gpiomux_config msm8960_gpiomux_configs[NR_GPIO_IRQS] = {
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -0700296#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700297 {
298 .gpio = KS8851_IRQ_GPIO,
299 .settings = {
300 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
301 }
302 },
303 {
304 .gpio = KS8851_RST_GPIO,
305 .settings = {
306 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
307 }
308 },
309 {
310 .gpio = FPGA_CS_GPIO,
311 .settings = {
312 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
313 }
314 },
Stepan Moskovchenko41d168272011-08-09 17:09:42 -0700315#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700316};
317
318static struct msm_gpiomux_config msm8960_gsbi_configs[] __initdata = {
319 {
320 .gpio = 6, /* GSBI1 QUP SPI_DATA_MOSI */
321 .settings = {
Harini Jayaraman608d0462011-08-09 19:10:03 -0600322 [GPIOMUX_SUSPENDED] = &spi_suspended_config,
323 [GPIOMUX_ACTIVE] = &spi_active,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700324 },
325 },
326 {
327 .gpio = 7, /* GSBI1 QUP SPI_DATA_MISO */
328 .settings = {
Harini Jayaraman608d0462011-08-09 19:10:03 -0600329 [GPIOMUX_SUSPENDED] = &spi_suspended_config,
330 [GPIOMUX_ACTIVE] = &spi_active,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700331 },
332 },
333 {
334 .gpio = 8, /* GSBI1 QUP SPI_CS_N */
335 .settings = {
Harini Jayaraman608d0462011-08-09 19:10:03 -0600336 [GPIOMUX_SUSPENDED] = &spi_suspended_config,
337 [GPIOMUX_ACTIVE] = &spi_active,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700338 },
339 },
340 {
341 .gpio = 9, /* GSBI1 QUP SPI_CLK */
342 .settings = {
Harini Jayaraman608d0462011-08-09 19:10:03 -0600343 [GPIOMUX_SUSPENDED] = &spi_suspended_config,
344 [GPIOMUX_ACTIVE] = &spi_active,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700345 },
346 },
347 {
348 .gpio = 16, /* GSBI3 I2C QUP SDA */
349 .settings = {
350 [GPIOMUX_SUSPENDED] = &gsbi3,
351 },
352 },
353 {
354 .gpio = 17, /* GSBI3 I2C QUP SCL */
355 .settings = {
356 [GPIOMUX_SUSPENDED] = &gsbi3,
357 },
358 },
359 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700360 .gpio = 22, /* GSBI5 UART2 */
361 .settings = {
362 [GPIOMUX_SUSPENDED] = &gsbi5,
363 },
364 },
365 {
366 .gpio = 23, /* GSBI5 UART2 */
367 .settings = {
368 [GPIOMUX_SUSPENDED] = &gsbi5,
369 },
370 },
371 {
372 .gpio = 24, /* GSBI5 UART2 */
373 .settings = {
374 [GPIOMUX_SUSPENDED] = &gsbi5,
375 },
376 },
377 {
378 .gpio = 25, /* GSBI5 UART2 */
379 .settings = {
380 [GPIOMUX_SUSPENDED] = &gsbi5,
381 },
382 },
383 {
384 .gpio = 44, /* GSBI12 I2C QUP SDA */
385 .settings = {
386 [GPIOMUX_SUSPENDED] = &gsbi12,
387 },
388 },
389 {
390 .gpio = 45, /* GSBI12 I2C QUP SCL */
391 .settings = {
392 [GPIOMUX_SUSPENDED] = &gsbi12,
393 },
394 },
395 {
396 .gpio = 73, /* GSBI10 I2C QUP SDA */
397 .settings = {
398 [GPIOMUX_SUSPENDED] = &gsbi10,
399 },
400 },
401 {
402 .gpio = 74, /* GSBI10 I2C QUP SCL */
403 .settings = {
404 [GPIOMUX_SUSPENDED] = &gsbi10,
405 },
406 },
407};
408
409static struct msm_gpiomux_config msm8960_slimbus_config[] __initdata = {
410 {
411 .gpio = 60, /* slimbus data */
412 .settings = {
413 [GPIOMUX_SUSPENDED] = &slimbus,
414 },
415 },
416 {
417 .gpio = 61, /* slimbus clk */
418 .settings = {
419 [GPIOMUX_SUSPENDED] = &slimbus,
420 },
421 },
422};
423
424static struct msm_gpiomux_config msm8960_audio_codec_configs[] __initdata = {
425 {
426 .gpio = 59,
427 .settings = {
428 [GPIOMUX_SUSPENDED] = &cdc_mclk,
429 },
430 },
431};
Bhalchandra Gajare0e795c42011-08-15 18:10:30 -0700432
433static struct msm_gpiomux_config msm8960_audio_auxpcm_configs[] __initdata = {
434 {
435 .gpio = 63,
436 .settings = {
437 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
438 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
439 },
440 },
441 {
442 .gpio = 64,
443 .settings = {
444 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
445 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
446 },
447 },
448 {
449 .gpio = 65,
450 .settings = {
451 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
452 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
453 },
454 },
455 {
456 .gpio = 66,
457 .settings = {
458 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
459 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
460 },
461 },
462};
463
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700464static struct gpiomux_setting wcnss_5wire_suspend_cfg = {
465 .func = GPIOMUX_FUNC_GPIO,
466 .drv = GPIOMUX_DRV_2MA,
Ankur Nandwaniad0d9ac2011-09-26 11:49:25 -0700467 .pull = GPIOMUX_PULL_UP,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700468};
469
470static struct gpiomux_setting wcnss_5wire_active_cfg = {
471 .func = GPIOMUX_FUNC_1,
472 .drv = GPIOMUX_DRV_6MA,
473 .pull = GPIOMUX_PULL_DOWN,
474};
475
476static struct msm_gpiomux_config wcnss_5wire_interface[] = {
477 {
478 .gpio = 84,
479 .settings = {
480 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
481 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
482 },
483 },
484 {
485 .gpio = 85,
486 .settings = {
487 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
488 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
489 },
490 },
491 {
492 .gpio = 86,
493 .settings = {
494 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
495 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
496 },
497 },
498 {
499 .gpio = 87,
500 .settings = {
501 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
502 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
503 },
504 },
505 {
506 .gpio = 88,
507 .settings = {
508 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
509 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
510 },
511 },
512};
Nishant Pandit24153d82011-08-27 16:05:13 +0530513static struct gpiomux_setting cam_settings[] = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530514 {
515 .func = GPIOMUX_FUNC_GPIO, /*suspend*/
516 .drv = GPIOMUX_DRV_2MA,
517 .pull = GPIOMUX_PULL_DOWN,
518 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700519
Nishant Pandit474f2252011-07-23 23:17:56 +0530520 {
521 .func = GPIOMUX_FUNC_1, /*active 1*/
522 .drv = GPIOMUX_DRV_2MA,
523 .pull = GPIOMUX_PULL_NONE,
524 },
525
526 {
527 .func = GPIOMUX_FUNC_GPIO, /*active 2*/
528 .drv = GPIOMUX_DRV_2MA,
529 .pull = GPIOMUX_PULL_NONE,
530 },
531
532 {
533 .func = GPIOMUX_FUNC_1, /*active 3*/
534 .drv = GPIOMUX_DRV_8MA,
Kevin Chan4c58d292011-09-13 11:03:25 -0700535 .pull = GPIOMUX_PULL_NONE,
Nishant Pandit474f2252011-07-23 23:17:56 +0530536 },
Nishant Pandit24153d82011-08-27 16:05:13 +0530537
538 {
539 .func = GPIOMUX_FUNC_5, /*active 4*/
540 .drv = GPIOMUX_DRV_8MA,
541 .pull = GPIOMUX_PULL_UP,
542 },
543
544 {
545 .func = GPIOMUX_FUNC_6, /*active 5*/
546 .drv = GPIOMUX_DRV_8MA,
547 .pull = GPIOMUX_PULL_UP,
548 },
549
550 {
551 .func = GPIOMUX_FUNC_2, /*active 6*/
552 .drv = GPIOMUX_DRV_2MA,
553 .pull = GPIOMUX_PULL_UP,
554 },
555
556 {
557 .func = GPIOMUX_FUNC_3, /*active 7*/
558 .drv = GPIOMUX_DRV_8MA,
559 .pull = GPIOMUX_PULL_UP,
560 },
561
Kevin Chan4c58d292011-09-13 11:03:25 -0700562 {
563 .func = GPIOMUX_FUNC_GPIO, /*i2c suspend*/
564 .drv = GPIOMUX_DRV_2MA,
565 .pull = GPIOMUX_PULL_KEEPER,
566 },
567
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700568};
569
Nishant Pandit24153d82011-08-27 16:05:13 +0530570static struct msm_gpiomux_config msm8960_cam_common_configs[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700571 {
572 .gpio = 2,
573 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530574 [GPIOMUX_ACTIVE] = &cam_settings[2],
575 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700576 },
577 },
578 {
579 .gpio = 3,
580 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530581 [GPIOMUX_ACTIVE] = &cam_settings[1],
582 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700583 },
584 },
585 {
586 .gpio = 4,
587 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530588 [GPIOMUX_ACTIVE] = &cam_settings[1],
589 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700590 },
591 },
592 {
593 .gpio = 5,
594 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530595 [GPIOMUX_ACTIVE] = &cam_settings[1],
596 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700597 },
598 },
599 {
Nishant Pandit24153d82011-08-27 16:05:13 +0530600 .gpio = 76,
601 .settings = {
602 [GPIOMUX_ACTIVE] = &cam_settings[2],
603 [GPIOMUX_SUSPENDED] = &cam_settings[0],
604 },
605 },
606 {
607 .gpio = 107,
608 .settings = {
609 [GPIOMUX_ACTIVE] = &cam_settings[2],
610 [GPIOMUX_SUSPENDED] = &cam_settings[0],
611 },
612 },
613};
614
615static struct msm_gpiomux_config msm8960_cam_2d_configs[] = {
616 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700617 .gpio = 18,
618 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530619 [GPIOMUX_ACTIVE] = &cam_settings[3],
Kevin Chan4c58d292011-09-13 11:03:25 -0700620 [GPIOMUX_SUSPENDED] = &cam_settings[8],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700621 },
622 },
623 {
624 .gpio = 19,
625 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530626 [GPIOMUX_ACTIVE] = &cam_settings[3],
Kevin Chan4c58d292011-09-13 11:03:25 -0700627 [GPIOMUX_SUSPENDED] = &cam_settings[8],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700628 },
629 },
630 {
631 .gpio = 20,
632 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530633 [GPIOMUX_ACTIVE] = &cam_settings[3],
Kevin Chan4c58d292011-09-13 11:03:25 -0700634 [GPIOMUX_SUSPENDED] = &cam_settings[8],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700635 },
636 },
637 {
638 .gpio = 21,
639 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530640 [GPIOMUX_ACTIVE] = &cam_settings[3],
Kevin Chan4c58d292011-09-13 11:03:25 -0700641 [GPIOMUX_SUSPENDED] = &cam_settings[8],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700642 },
643 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700644};
645
646static struct gpiomux_setting cyts_resout_sus_cfg = {
647 .func = GPIOMUX_FUNC_GPIO,
648 .drv = GPIOMUX_DRV_6MA,
649 .pull = GPIOMUX_PULL_UP,
650};
651
652static struct gpiomux_setting cyts_resout_act_cfg = {
653 .func = GPIOMUX_FUNC_GPIO,
654 .drv = GPIOMUX_DRV_6MA,
655 .pull = GPIOMUX_PULL_UP,
656};
657
658static struct gpiomux_setting cyts_sleep_sus_cfg = {
659 .func = GPIOMUX_FUNC_GPIO,
660 .drv = GPIOMUX_DRV_6MA,
661 .pull = GPIOMUX_PULL_DOWN,
662};
663
664static struct gpiomux_setting cyts_sleep_act_cfg = {
665 .func = GPIOMUX_FUNC_GPIO,
666 .drv = GPIOMUX_DRV_6MA,
667 .pull = GPIOMUX_PULL_DOWN,
668};
669
670static struct gpiomux_setting cyts_int_act_cfg = {
671 .func = GPIOMUX_FUNC_GPIO,
672 .drv = GPIOMUX_DRV_8MA,
673 .pull = GPIOMUX_PULL_UP,
674};
675
676static struct gpiomux_setting cyts_int_sus_cfg = {
677 .func = GPIOMUX_FUNC_GPIO,
678 .drv = GPIOMUX_DRV_2MA,
Mohan Pallakacbc5d162011-09-13 15:23:21 +0530679 .pull = GPIOMUX_PULL_DOWN,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700680};
681
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700682static struct msm_gpiomux_config msm8960_cyts_configs[] __initdata = {
683 { /* TS INTERRUPT */
684 .gpio = 11,
685 .settings = {
686 [GPIOMUX_ACTIVE] = &cyts_int_act_cfg,
687 [GPIOMUX_SUSPENDED] = &cyts_int_sus_cfg,
688 },
689 },
690 { /* TS SLEEP */
691 .gpio = 50,
692 .settings = {
693 [GPIOMUX_ACTIVE] = &cyts_sleep_act_cfg,
694 [GPIOMUX_SUSPENDED] = &cyts_sleep_sus_cfg,
695 },
696 },
697 { /* TS RESOUT */
698 .gpio = 52,
699 .settings = {
700 [GPIOMUX_ACTIVE] = &cyts_resout_act_cfg,
701 [GPIOMUX_SUSPENDED] = &cyts_resout_sus_cfg,
702 },
703 },
704};
705
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700706#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
707enum {
708 SX150X_CAM,
709};
710
Nishant Pandit474f2252011-07-23 23:17:56 +0530711static struct sx150x_platform_data sx150x_data[] = {
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700712 [SX150X_CAM] = {
713 .gpio_base = GPIO_CAM_EXPANDER_BASE,
714 .oscio_is_gpo = false,
715 .io_pullup_ena = 0x0,
Nishant Pandit474f2252011-07-23 23:17:56 +0530716 .io_pulldn_ena = 0xc0,
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700717 .io_open_drain_ena = 0x0,
718 .irq_summary = -1,
719 },
720};
Nishant Pandit474f2252011-07-23 23:17:56 +0530721
722#endif
723
724#ifdef CONFIG_I2C
725
726#define MSM_8960_GSBI4_QUP_I2C_BUS_ID 4
727#define MSM_8960_GSBI3_QUP_I2C_BUS_ID 3
Amir Samuelov5137e392011-09-21 17:31:25 +0300728#define MSM_8960_GSBI10_QUP_I2C_BUS_ID 10
Nishant Pandit474f2252011-07-23 23:17:56 +0530729
730#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
731
732static struct i2c_board_info cam_expander_i2c_info[] = {
733 {
734 I2C_BOARD_INFO("sx1508q", 0x22),
735 .platform_data = &sx150x_data[SX150X_CAM]
736 },
737};
738
739static struct msm_cam_expander_info cam_expander_info[] = {
740 {
741 cam_expander_i2c_info,
742 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
743 },
744};
745#endif
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700746#endif
747
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700748#define MSM_PMEM_KERNEL_EBI1_SIZE 0x110C000
749#define MSM_PMEM_ADSP_SIZE 0x3800000
Ben Romberger09e462d2011-08-09 15:24:37 -0700750#define MSM_PMEM_AUDIO_SIZE 0x28B000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700751#define MSM_PMEM_SIZE 0x1800000 /* 24 Mbytes */
752
Laura Abbottd6183792011-08-19 13:42:24 -0700753#define MSM_ION_EBI_SIZE SZ_8M
754
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700755#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
756static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
757static int __init pmem_kernel_ebi1_size_setup(char *p)
758{
759 pmem_kernel_ebi1_size = memparse(p, NULL);
760 return 0;
761}
762early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
763#endif
764
765#ifdef CONFIG_ANDROID_PMEM
766static unsigned pmem_size = MSM_PMEM_SIZE;
767static int __init pmem_size_setup(char *p)
768{
769 pmem_size = memparse(p, NULL);
770 return 0;
771}
772early_param("pmem_size", pmem_size_setup);
773
774static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
775
776static int __init pmem_adsp_size_setup(char *p)
777{
778 pmem_adsp_size = memparse(p, NULL);
779 return 0;
780}
781early_param("pmem_adsp_size", pmem_adsp_size_setup);
782
783static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
784
785static int __init pmem_audio_size_setup(char *p)
786{
787 pmem_audio_size = memparse(p, NULL);
788 return 0;
789}
790early_param("pmem_audio_size", pmem_audio_size_setup);
791#endif
792
793#ifdef CONFIG_ANDROID_PMEM
794static struct android_pmem_platform_data android_pmem_pdata = {
795 .name = "pmem",
796 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
797 .cached = 1,
798 .memory_type = MEMTYPE_EBI1,
799};
800
801static struct platform_device android_pmem_device = {
802 .name = "android_pmem",
803 .id = 0,
804 .dev = {.platform_data = &android_pmem_pdata},
805};
806
807static struct android_pmem_platform_data android_pmem_adsp_pdata = {
808 .name = "pmem_adsp",
809 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
810 .cached = 0,
811 .memory_type = MEMTYPE_EBI1,
812};
813static struct platform_device android_pmem_adsp_device = {
814 .name = "android_pmem",
815 .id = 2,
816 .dev = { .platform_data = &android_pmem_adsp_pdata },
817};
818
819static struct android_pmem_platform_data android_pmem_audio_pdata = {
820 .name = "pmem_audio",
821 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
822 .cached = 0,
823 .memory_type = MEMTYPE_EBI1,
824};
825
826static struct platform_device android_pmem_audio_device = {
827 .name = "android_pmem",
828 .id = 4,
829 .dev = { .platform_data = &android_pmem_audio_pdata },
830};
831#endif
832
833static struct memtype_reserve msm8960_reserve_table[] __initdata = {
834 [MEMTYPE_SMI] = {
835 },
836 [MEMTYPE_EBI0] = {
837 .flags = MEMTYPE_FLAGS_1M_ALIGN,
838 },
839 [MEMTYPE_EBI1] = {
840 .flags = MEMTYPE_FLAGS_1M_ALIGN,
841 },
842};
843
844static void __init size_pmem_devices(void)
845{
846#ifdef CONFIG_ANDROID_PMEM
847 android_pmem_adsp_pdata.size = pmem_adsp_size;
848 android_pmem_pdata.size = pmem_size;
849 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
850#endif
851}
852
853static void __init reserve_memory_for(struct android_pmem_platform_data *p)
854{
855 msm8960_reserve_table[p->memory_type].size += p->size;
856}
857
858static void __init reserve_pmem_memory(void)
859{
860#ifdef CONFIG_ANDROID_PMEM
861 reserve_memory_for(&android_pmem_adsp_pdata);
862 reserve_memory_for(&android_pmem_pdata);
863 reserve_memory_for(&android_pmem_audio_pdata);
864 msm8960_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
865#endif
866}
867
Larry Basselb4126da2011-07-18 14:31:33 -0700868static int msm8960_paddr_to_memtype(unsigned int paddr)
869{
870 return MEMTYPE_EBI1;
871}
872
Laura Abbottd6183792011-08-19 13:42:24 -0700873#ifdef CONFIG_ION_MSM
874struct ion_platform_data ion_pdata = {
875 .nr = 3,
876 .heaps = {
877 {
878 .id = ION_HEAP_SYSTEM_ID,
879 .type = ION_HEAP_TYPE_SYSTEM,
880 .name = ION_KMALLOC_HEAP_NAME,
881 },
882 {
883 .id = ION_HEAP_SYSTEM_CONTIG_ID,
884 .type = ION_HEAP_TYPE_SYSTEM_CONTIG,
885 .name = ION_VMALLOC_HEAP_NAME,
886 },
887 {
888 .id = ION_HEAP_EBI_ID,
889 .type = ION_HEAP_TYPE_CARVEOUT,
890 .name = ION_EBI1_HEAP_NAME,
891 .size = MSM_ION_EBI_SIZE,
892 .memory_type = ION_EBI_TYPE,
893 },
894 }
895};
896
897struct platform_device ion_dev = {
898 .name = "ion-msm",
899 .id = 1,
900 .dev = { .platform_data = &ion_pdata },
901};
902#endif
903
904static void reserve_ion_memory(void)
905{
906#ifdef CONFIG_ION_MSM
907 msm8960_reserve_table[MEMTYPE_EBI1].size += MSM_ION_EBI_SIZE;
908#endif
909}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700910static void __init msm8960_calculate_reserve_sizes(void)
911{
912 size_pmem_devices();
913 reserve_pmem_memory();
Laura Abbottd6183792011-08-19 13:42:24 -0700914 reserve_ion_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700915}
916
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700917static struct reserve_info msm8960_reserve_info __initdata = {
918 .memtype_reserve_table = msm8960_reserve_table,
919 .calculate_reserve_sizes = msm8960_calculate_reserve_sizes,
920 .paddr_to_memtype = msm8960_paddr_to_memtype,
921};
922
Larry Basselb4126da2011-07-18 14:31:33 -0700923static int msm8960_memory_bank_size(void)
924{
925 return 1<<29;
926}
927
928static void __init locate_unstable_memory(void)
929{
930 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
931 unsigned long bank_size;
932 unsigned long low, high;
933
934 bank_size = msm8960_memory_bank_size();
935 low = meminfo.bank[0].start;
936 high = mb->start + mb->size;
937 low &= ~(bank_size - 1);
938
939 if (high - low <= bank_size)
940 return;
941 msm8960_reserve_info.low_unstable_address = low + bank_size;
942 msm8960_reserve_info.max_unstable_size = high - low - bank_size;
943 msm8960_reserve_info.bank_size = bank_size;
944 pr_info("low unstable address %lx max size %lx bank size %lx\n",
945 msm8960_reserve_info.low_unstable_address,
946 msm8960_reserve_info.max_unstable_size,
947 msm8960_reserve_info.bank_size);
948}
949
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700950static void __init msm8960_reserve(void)
951{
952 reserve_info = &msm8960_reserve_info;
Larry Basselb4126da2011-07-18 14:31:33 -0700953 locate_unstable_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700954 msm_reserve();
955}
956
Larry Bassela4414b12011-08-04 11:11:02 -0700957static int msm8960_change_memory_power(u64 start, u64 size,
958 int change_type)
Larry Bassela7eadea2011-07-14 10:46:00 -0700959{
Naveen Ramarajb03bb1b2011-09-12 14:34:31 -0700960 return soc_change_memory_power(start, size, change_type);
Larry Bassela7eadea2011-07-14 10:46:00 -0700961}
962
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700963#ifdef CONFIG_MSM_CAMERA
964
Nishant Pandit24153d82011-08-27 16:05:13 +0530965static uint16_t msm_cam_gpio_2d_tbl[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700966 5, /*CAMIF_MCLK*/
967 20, /*CAMIF_I2C_DATA*/
968 21, /*CAMIF_I2C_CLK*/
969};
970
Nishant Pandit24153d82011-08-27 16:05:13 +0530971static struct msm_camera_gpio_conf gpio_conf = {
972 .cam_gpiomux_conf_tbl = msm8960_cam_2d_configs,
973 .cam_gpiomux_conf_tbl_size = ARRAY_SIZE(msm8960_cam_2d_configs),
974 .cam_gpio_tbl = msm_cam_gpio_2d_tbl,
975 .cam_gpio_tbl_size = ARRAY_SIZE(msm_cam_gpio_2d_tbl),
976};
977
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700978#define VFE_CAMIF_TIMER1_GPIO 2
979#define VFE_CAMIF_TIMER2_GPIO 3
980#define VFE_CAMIF_TIMER3_GPIO_INT 4
981struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
982 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
983 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
984 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
985 .flash_recharge_duration = 50000,
986 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
987};
988
Nishant Pandit474f2252011-07-23 23:17:56 +0530989#ifdef CONFIG_MSM_CAMERA_FLASH
990static struct msm_camera_sensor_flash_src msm_flash_src = {
991 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
992 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
993 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
994#if defined(CONFIG_I2C) && (defined(CONFIG_GPIO_SX150X) || \
995 defined(CONFIG_GPIO_SX150X_MODULE))
996 ._fsrc.ext_driver_src.expander_info = cam_expander_info,
997#endif
998};
999#endif
1000
Shuzhen Wang65c3b1d2011-09-20 12:53:08 -07001001#ifdef CONFIG_MSM_BUS_SCALING
1002
1003static struct msm_bus_vectors cam_init_vectors[] = {
1004 {
1005 .src = MSM_BUS_MASTER_VFE,
1006 .dst = MSM_BUS_SLAVE_EBI_CH0,
1007 .ab = 0,
1008 .ib = 0,
1009 },
1010 {
1011 .src = MSM_BUS_MASTER_VPE,
1012 .dst = MSM_BUS_SLAVE_EBI_CH0,
1013 .ab = 0,
1014 .ib = 0,
1015 },
1016 {
1017 .src = MSM_BUS_MASTER_JPEG_ENC,
1018 .dst = MSM_BUS_SLAVE_EBI_CH0,
1019 .ab = 0,
1020 .ib = 0,
1021 },
1022};
1023
1024static struct msm_bus_vectors cam_preview_vectors[] = {
1025 {
1026 .src = MSM_BUS_MASTER_VFE,
1027 .dst = MSM_BUS_SLAVE_EBI_CH0,
1028 .ab = 27648000,
1029 .ib = 110592000,
1030 },
1031 {
1032 .src = MSM_BUS_MASTER_VPE,
1033 .dst = MSM_BUS_SLAVE_EBI_CH0,
1034 .ab = 0,
1035 .ib = 0,
1036 },
1037 {
1038 .src = MSM_BUS_MASTER_JPEG_ENC,
1039 .dst = MSM_BUS_SLAVE_EBI_CH0,
1040 .ab = 0,
1041 .ib = 0,
1042 },
1043};
1044
1045static struct msm_bus_vectors cam_video_vectors[] = {
1046 {
1047 .src = MSM_BUS_MASTER_VFE,
1048 .dst = MSM_BUS_SLAVE_EBI_CH0,
1049 .ab = 140451840,
1050 .ib = 561807360,
1051 },
1052 {
1053 .src = MSM_BUS_MASTER_VPE,
1054 .dst = MSM_BUS_SLAVE_EBI_CH0,
1055 .ab = 206807040,
1056 .ib = 488816640,
1057 },
1058 {
1059 .src = MSM_BUS_MASTER_JPEG_ENC,
1060 .dst = MSM_BUS_SLAVE_EBI_CH0,
1061 .ab = 0,
1062 .ib = 0,
1063 },
1064};
1065
1066static struct msm_bus_vectors cam_snapshot_vectors[] = {
1067 {
1068 .src = MSM_BUS_MASTER_VFE,
1069 .dst = MSM_BUS_SLAVE_EBI_CH0,
1070 .ab = 274423680,
1071 .ib = 1097694720,
1072 },
1073 {
1074 .src = MSM_BUS_MASTER_VPE,
1075 .dst = MSM_BUS_SLAVE_EBI_CH0,
1076 .ab = 0,
1077 .ib = 0,
1078 },
1079 {
1080 .src = MSM_BUS_MASTER_JPEG_ENC,
1081 .dst = MSM_BUS_SLAVE_EBI_CH0,
1082 .ab = 540000000,
1083 .ib = 1350000000,
1084 },
1085};
1086
1087static struct msm_bus_vectors cam_zsl_vectors[] = {
1088 {
1089 .src = MSM_BUS_MASTER_VFE,
1090 .dst = MSM_BUS_SLAVE_EBI_CH0,
1091 .ab = 302071680,
1092 .ib = 1208286720,
1093 },
1094 {
1095 .src = MSM_BUS_MASTER_VPE,
1096 .dst = MSM_BUS_SLAVE_EBI_CH0,
1097 .ab = 0,
1098 .ib = 0,
1099 },
1100 {
1101 .src = MSM_BUS_MASTER_JPEG_ENC,
1102 .dst = MSM_BUS_SLAVE_EBI_CH0,
1103 .ab = 540000000,
1104 .ib = 1350000000,
1105 },
1106};
1107
1108static struct msm_bus_paths cam_bus_client_config[] = {
1109 {
1110 ARRAY_SIZE(cam_init_vectors),
1111 cam_init_vectors,
1112 },
1113 {
1114 ARRAY_SIZE(cam_preview_vectors),
1115 cam_preview_vectors,
1116 },
1117 {
1118 ARRAY_SIZE(cam_video_vectors),
1119 cam_video_vectors,
1120 },
1121 {
1122 ARRAY_SIZE(cam_snapshot_vectors),
1123 cam_snapshot_vectors,
1124 },
1125 {
1126 ARRAY_SIZE(cam_zsl_vectors),
1127 cam_zsl_vectors,
1128 },
1129};
1130
1131static struct msm_bus_scale_pdata cam_bus_client_pdata = {
1132 cam_bus_client_config,
1133 ARRAY_SIZE(cam_bus_client_config),
1134 .name = "msm_camera",
1135};
1136#endif
1137
Nishant Pandit24153d82011-08-27 16:05:13 +05301138struct msm_camera_device_platform_data msm_camera_csi_device_data[] = {
1139 {
1140 .ioclk.mclk_clk_rate = 24000000,
1141 .ioclk.vfe_clk_rate = 228570000,
1142 .csid_core = 0,
Shuzhen Wang65c3b1d2011-09-20 12:53:08 -07001143#ifdef CONFIG_MSM_BUS_SCALING
1144 .cam_bus_scale_table = &cam_bus_client_pdata,
1145#endif
Nishant Pandit24153d82011-08-27 16:05:13 +05301146 },
1147 {
1148 .ioclk.mclk_clk_rate = 24000000,
1149 .ioclk.vfe_clk_rate = 228570000,
1150 .csid_core = 1,
Shuzhen Wang65c3b1d2011-09-20 12:53:08 -07001151#ifdef CONFIG_MSM_BUS_SCALING
1152 .cam_bus_scale_table = &cam_bus_client_pdata,
1153#endif
Nishant Pandit24153d82011-08-27 16:05:13 +05301154 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001155};
1156
Sreesudhan Ramakrish Ramkumarb54fd242011-09-12 17:11:19 -07001157#ifdef CONFIG_IMX074_ACT
1158static struct i2c_board_info imx074_actuator_i2c_info = {
1159 I2C_BOARD_INFO("imx074_act", 0x11),
1160};
1161
1162static struct msm_actuator_info imx074_actuator_info = {
1163 .board_info = &imx074_actuator_i2c_info,
1164 .bus_id = MSM_8960_GSBI4_QUP_I2C_BUS_ID,
1165 .vcm_pwd = 0,
1166 .vcm_enable = 1,
1167};
1168#endif
1169
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001170#ifdef CONFIG_IMX074
1171static struct msm_camera_sensor_flash_data flash_imx074 = {
1172 .flash_type = MSM_CAMERA_FLASH_LED,
Nishant Pandit474f2252011-07-23 23:17:56 +05301173#ifdef CONFIG_MSM_CAMERA_FLASH
1174 .flash_src = &msm_flash_src
1175#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001176};
1177
Nishant Pandit24153d82011-08-27 16:05:13 +05301178static struct msm_camera_sensor_platform_info sensor_board_info_imx074 = {
1179 .mount_angle = 90,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001180 .sensor_reset = 107,
1181 .sensor_pwd = 85,
1182 .vcm_pwd = 0,
1183 .vcm_enable = 1,
Nishant Pandit24153d82011-08-27 16:05:13 +05301184};
1185
1186static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
1187 .sensor_name = "imx074",
1188 .pdata = &msm_camera_csi_device_data[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001189 .flash_data = &flash_imx074,
1190 .strobe_flash_data = &strobe_flash_xenon,
Nishant Pandit24153d82011-08-27 16:05:13 +05301191 .sensor_platform_info = &sensor_board_info_imx074,
1192 .gpio_conf = &gpio_conf,
1193 .csi_if = 1,
1194 .camera_type = BACK_CAMERA_2D,
Sreesudhan Ramakrish Ramkumarb54fd242011-09-12 17:11:19 -07001195#ifdef CONFIG_IMX074_ACT
1196 .actuator_info = &imx074_actuator_info
1197#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001198};
1199
1200struct platform_device msm8960_camera_sensor_imx074 = {
1201 .name = "msm_camera_imx074",
1202 .dev = {
1203 .platform_data = &msm_camera_sensor_imx074_data,
1204 },
1205};
1206#endif
1207#ifdef CONFIG_OV2720
1208static struct msm_camera_sensor_flash_data flash_ov2720 = {
Kevin Chan1a990332011-07-26 20:31:23 -07001209 .flash_type = MSM_CAMERA_FLASH_NONE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001210};
1211
Nishant Pandit24153d82011-08-27 16:05:13 +05301212static struct msm_camera_sensor_platform_info sensor_board_info_ov2720 = {
1213 .mount_angle = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001214 .sensor_reset = 76,
1215 .sensor_pwd = 85,
1216 .vcm_pwd = 0,
1217 .vcm_enable = 1,
Nishant Pandit24153d82011-08-27 16:05:13 +05301218};
1219
1220static struct msm_camera_sensor_info msm_camera_sensor_ov2720_data = {
1221 .sensor_name = "ov2720",
1222 .pdata = &msm_camera_csi_device_data[1],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001223 .flash_data = &flash_ov2720,
Nishant Pandit24153d82011-08-27 16:05:13 +05301224 .sensor_platform_info = &sensor_board_info_ov2720,
1225 .gpio_conf = &gpio_conf,
1226 .csi_if = 1,
1227 .camera_type = FRONT_CAMERA_2D,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001228};
1229
1230struct platform_device msm8960_camera_sensor_ov2720 = {
1231 .name = "msm_camera_ov2720",
1232 .dev = {
1233 .platform_data = &msm_camera_sensor_ov2720_data,
1234 },
1235};
1236#endif
Kevin Chandfecce22011-07-13 10:52:41 -07001237
1238static struct msm_camera_sensor_flash_data flash_qs_mt9p017 = {
1239 .flash_type = MSM_CAMERA_FLASH_LED,
1240};
1241
Nishant Pandit24153d82011-08-27 16:05:13 +05301242static struct msm_camera_sensor_platform_info sensor_board_info_qs_mt9p017 = {
1243 .mount_angle = 270,
Kevin Chandfecce22011-07-13 10:52:41 -07001244 .sensor_reset = 107,
1245 .sensor_pwd = 85,
1246 .vcm_pwd = 0,
1247 .vcm_enable = 1,
Nishant Pandit24153d82011-08-27 16:05:13 +05301248};
1249
1250static struct msm_camera_sensor_info msm_camera_sensor_qs_mt9p017_data = {
1251 .sensor_name = "qs_mt9p017",
1252 .pdata = &msm_camera_csi_device_data[0],
Kevin Chandfecce22011-07-13 10:52:41 -07001253 .flash_data = &flash_qs_mt9p017,
Nishant Pandit24153d82011-08-27 16:05:13 +05301254 .sensor_platform_info = &sensor_board_info_qs_mt9p017,
1255 .gpio_conf = &gpio_conf,
1256 .csi_if = 1,
1257 .camera_type = BACK_CAMERA_3D,
Kevin Chandfecce22011-07-13 10:52:41 -07001258};
1259
1260struct platform_device msm8960_camera_sensor_qs_mt9p017 = {
1261 .name = "msm_camera_qs_mt9p017",
1262 .dev = {
1263 .platform_data = &msm_camera_sensor_qs_mt9p017_data,
1264 },
1265};
1266
Kevin Chan8b0d2322011-09-10 21:06:31 -07001267static struct msm8960_privacy_light_cfg privacy_light_info = {
1268 .mpp = PM8921_MPP_PM_TO_SYS(12),
1269};
1270
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001271static void __init msm8960_init_cam(void)
1272{
1273 int i;
1274 struct platform_device *cam_dev[] = {
1275 &msm8960_camera_sensor_imx074,
1276 &msm8960_camera_sensor_ov2720,
Kevin Chandfecce22011-07-13 10:52:41 -07001277 &msm8960_camera_sensor_qs_mt9p017,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001278 };
1279
Kevin Chan8b0d2322011-09-10 21:06:31 -07001280 if (machine_is_msm8960_liquid()) {
1281 struct msm_camera_sensor_info *s_info;
1282 s_info = msm8960_camera_sensor_imx074.dev.platform_data;
1283 s_info->sensor_platform_info->mount_angle = 180;
1284 s_info = msm8960_camera_sensor_ov2720.dev.platform_data;
1285 s_info->sensor_platform_info->privacy_light = 1;
1286 s_info->sensor_platform_info->privacy_light_info =
1287 &privacy_light_info;
1288 }
1289
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001290 for (i = 0; i < ARRAY_SIZE(cam_dev); i++) {
1291 struct msm_camera_sensor_info *s_info;
1292 s_info = cam_dev[i]->dev.platform_data;
1293 msm_get_cam_resources(s_info);
1294 platform_device_register(cam_dev[i]);
1295 }
1296}
1297#endif
1298
1299#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
kuogee hsieh3830eb92011-09-12 15:25:57 -07001300#define MSM_FB_PRIM_BUF_SIZE (1376 * 768 * 4 * 3) /* 4 bpp x 3 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001301#else
kuogee hsieh3830eb92011-09-12 15:25:57 -07001302#define MSM_FB_PRIM_BUF_SIZE (1376 * 768 * 4 * 2) /* 4 bpp x 2 pages */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001303#endif
1304
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001305
1306#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
kuogee hsieh3830eb92011-09-12 15:25:57 -07001307#define MSM_FB_EXT_BUF_SIZE (1920 * 1088 * 2 * 1) /* 2 bpp x 1 page */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001308#elif defined(CONFIG_FB_MSM_TVOUT)
kuogee hsieh3830eb92011-09-12 15:25:57 -07001309#define MSM_FB_EXT_BUF_SIZE (720 * 576 * 2 * 2) /* 2 bpp x 2 pages */
1310#else
1311#define MSM_FB_EXT_BUF_SIZE 0
1312#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001313
kuogee hsieh3830eb92011-09-12 15:25:57 -07001314#ifdef CONFIG_FB_MSM_OVERLAY_WRITEBACK
1315/* width x height x 3 bpp x 2 frame buffer */
1316#define MSM_FB_WRITEBACK_SIZE (1376 * 768 * 3 * 2)
1317#define MSM_FB_WRITEBACK_OFFSET \
1318 (MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE)
1319#else
1320#define MSM_FB_WRITEBACK_SIZE 0
1321#define MSM_FB_WRITEBACK_OFFSET 0
1322#endif
1323
1324
1325/* Note: must be multiple of 4096 */
1326#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE + \
1327 MSM_FB_WRITEBACK_SIZE, 4096)
1328
1329static int writeback_offset(void)
1330{
1331 return MSM_FB_WRITEBACK_OFFSET;
1332}
1333
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001334
1335#define MDP_VSYNC_GPIO 0
1336
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001337#define TOSHIBA_PANEL_NAME "mipi_video_toshiba_wsvga"
1338#define TOSHIBA_PANEL_NAME_LEN 24
1339#define CHIMEI_PANEL_NAME "mipi_chimei_wxga"
1340#define CHIMEI_PANEL_NAME_LEN 16
1341
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001342static struct resource msm_fb_resources[] = {
1343 {
1344 .flags = IORESOURCE_DMA,
1345 }
1346};
1347
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001348#ifdef CONFIG_FB_MSM_MIPI_PANEL_DETECT
1349static int msm_fb_detect_panel(const char *name)
1350{
1351 if (machine_is_msm8960_liquid()) {
1352 if (!strncmp(name, CHIMEI_PANEL_NAME, CHIMEI_PANEL_NAME_LEN))
1353 return 0;
1354 } else {
1355 if (!strncmp(name, TOSHIBA_PANEL_NAME, TOSHIBA_PANEL_NAME_LEN))
1356 return 0;
1357 }
1358
1359 pr_warning("%s: not supported '%s'", __func__, name);
1360
1361 return -ENODEV;
1362}
1363
1364static struct msm_fb_platform_data msm_fb_pdata = {
1365 .detect_client = msm_fb_detect_panel,
1366};
1367#endif /* CONFIG_FB_MSM_MIPI_PANEL_DETECT */
1368
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001369static struct platform_device msm_fb_device = {
1370 .name = "msm_fb",
1371 .id = 0,
1372 .num_resources = ARRAY_SIZE(msm_fb_resources),
1373 .resource = msm_fb_resources,
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001374#ifdef CONFIG_FB_MSM_MIPI_PANEL_DETECT
1375 .dev.platform_data = &msm_fb_pdata,
1376#endif /* CONFIG_FB_MSM_MIPI_PANEL_DETECT */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001377};
1378
1379static bool dsi_power_on;
1380
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001381/**
1382 * LiQUID panel on/off
1383 *
1384 * @param on
1385 *
1386 * @return int
1387 */
1388static int mipi_dsi_liquid_panel_power(int on)
1389{
1390 static struct regulator *reg_l2, *reg_ext_3p3v;
1391 static int gpio21, gpio24, gpio43;
1392 int rc;
1393
1394 pr_info("%s: on=%d\n", __func__, on);
1395
1396 gpio21 = PM8921_GPIO_PM_TO_SYS(21); /* disp power enable_n */
1397 gpio43 = PM8921_GPIO_PM_TO_SYS(43); /* Displays Enable (rst_n)*/
1398 gpio24 = PM8921_GPIO_PM_TO_SYS(24); /* Backlight PWM */
1399
1400 if (!dsi_power_on) {
1401
1402 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
1403 "dsi_vdda");
1404 if (IS_ERR(reg_l2)) {
1405 pr_err("could not get 8921_l2, rc = %ld\n",
1406 PTR_ERR(reg_l2));
1407 return -ENODEV;
1408 }
1409
1410 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
1411 if (rc) {
1412 pr_err("set_voltage l2 failed, rc=%d\n", rc);
1413 return -EINVAL;
1414 }
1415
1416 reg_ext_3p3v = regulator_get(&msm_mipi_dsi1_device.dev,
1417 "vdd_lvds_3p3v");
1418 if (IS_ERR(reg_ext_3p3v)) {
1419 pr_err("could not get reg_ext_3p3v, rc = %ld\n",
1420 PTR_ERR(reg_ext_3p3v));
1421 return -ENODEV;
1422 }
1423
1424 rc = gpio_request(gpio21, "disp_pwr_en_n");
1425 if (rc) {
1426 pr_err("request gpio 21 failed, rc=%d\n", rc);
1427 return -ENODEV;
1428 }
1429
1430 rc = gpio_request(gpio43, "disp_rst_n");
1431 if (rc) {
1432 pr_err("request gpio 43 failed, rc=%d\n", rc);
1433 return -ENODEV;
1434 }
1435
1436 rc = gpio_request(gpio24, "disp_backlight_pwm");
1437 if (rc) {
1438 pr_err("request gpio 24 failed, rc=%d\n", rc);
1439 return -ENODEV;
1440 }
1441
1442 dsi_power_on = true;
1443 }
1444
1445 if (on) {
1446 rc = regulator_set_optimum_mode(reg_l2, 100000);
1447 if (rc < 0) {
1448 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1449 return -EINVAL;
1450 }
1451 rc = regulator_enable(reg_l2);
1452 if (rc) {
1453 pr_err("enable l2 failed, rc=%d\n", rc);
1454 return -ENODEV;
1455 }
1456
1457 rc = regulator_enable(reg_ext_3p3v);
1458 if (rc) {
1459 pr_err("enable reg_ext_3p3v failed, rc=%d\n", rc);
1460 return -ENODEV;
1461 }
1462
1463 /* set reset pin before power enable */
1464 gpio_set_value_cansleep(gpio43, 0); /* disp disable (resx=0) */
1465
1466 gpio_set_value_cansleep(gpio21, 0); /* disp power enable_n */
1467 msleep(20);
1468 gpio_set_value_cansleep(gpio43, 1); /* disp enable */
1469 msleep(20);
1470 gpio_set_value_cansleep(gpio43, 0); /* disp enable */
1471 msleep(20);
1472 gpio_set_value_cansleep(gpio43, 1); /* disp enable */
1473 msleep(20);
1474 } else {
1475 gpio_set_value_cansleep(gpio43, 0);
1476 gpio_set_value_cansleep(gpio21, 1);
1477
1478 rc = regulator_disable(reg_l2);
1479 if (rc) {
1480 pr_err("disable reg_l2 failed, rc=%d\n", rc);
1481 return -ENODEV;
1482 }
1483 rc = regulator_disable(reg_ext_3p3v);
1484 if (rc) {
1485 pr_err("disable reg_ext_3p3v failed, rc=%d\n", rc);
1486 return -ENODEV;
1487 }
1488 rc = regulator_set_optimum_mode(reg_l2, 100);
1489 if (rc < 0) {
1490 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1491 return -EINVAL;
1492 }
1493 }
1494
1495 return 0;
1496}
1497
1498static int mipi_dsi_cdp_panel_power(int on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001499{
1500 static struct regulator *reg_l8, *reg_l23, *reg_l2;
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07001501 static int gpio43;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001502 int rc;
1503
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001504 pr_info("%s: state : %d\n", __func__, on);
1505
1506 if (!dsi_power_on) {
1507
1508 reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev,
1509 "dsi_vdc");
1510 if (IS_ERR(reg_l8)) {
1511 pr_err("could not get 8921_l8, rc = %ld\n",
1512 PTR_ERR(reg_l8));
1513 return -ENODEV;
1514 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001515 reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev,
1516 "dsi_vddio");
1517 if (IS_ERR(reg_l23)) {
1518 pr_err("could not get 8921_l23, rc = %ld\n",
1519 PTR_ERR(reg_l23));
1520 return -ENODEV;
1521 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001522 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
1523 "dsi_vdda");
1524 if (IS_ERR(reg_l2)) {
1525 pr_err("could not get 8921_l2, rc = %ld\n",
1526 PTR_ERR(reg_l2));
1527 return -ENODEV;
1528 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001529 rc = regulator_set_voltage(reg_l8, 2800000, 3000000);
1530 if (rc) {
1531 pr_err("set_voltage l8 failed, rc=%d\n", rc);
1532 return -EINVAL;
1533 }
1534 rc = regulator_set_voltage(reg_l23, 1800000, 1800000);
1535 if (rc) {
1536 pr_err("set_voltage l23 failed, rc=%d\n", rc);
1537 return -EINVAL;
1538 }
1539 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
1540 if (rc) {
1541 pr_err("set_voltage l2 failed, rc=%d\n", rc);
1542 return -EINVAL;
1543 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001544 gpio43 = PM8921_GPIO_PM_TO_SYS(43);
1545 rc = gpio_request(gpio43, "disp_rst_n");
1546 if (rc) {
1547 pr_err("request gpio 43 failed, rc=%d\n", rc);
1548 return -ENODEV;
1549 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001550 dsi_power_on = true;
1551 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001552 if (on) {
1553 rc = regulator_set_optimum_mode(reg_l8, 100000);
1554 if (rc < 0) {
1555 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
1556 return -EINVAL;
1557 }
1558 rc = regulator_set_optimum_mode(reg_l23, 100000);
1559 if (rc < 0) {
1560 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1561 return -EINVAL;
1562 }
1563 rc = regulator_set_optimum_mode(reg_l2, 100000);
1564 if (rc < 0) {
1565 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1566 return -EINVAL;
1567 }
1568 rc = regulator_enable(reg_l8);
1569 if (rc) {
1570 pr_err("enable l8 failed, rc=%d\n", rc);
1571 return -ENODEV;
1572 }
1573 rc = regulator_enable(reg_l23);
1574 if (rc) {
1575 pr_err("enable l8 failed, rc=%d\n", rc);
1576 return -ENODEV;
1577 }
1578 rc = regulator_enable(reg_l2);
1579 if (rc) {
1580 pr_err("enable l2 failed, rc=%d\n", rc);
1581 return -ENODEV;
1582 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001583 gpio_set_value_cansleep(gpio43, 1);
1584 } else {
Nagamalleswararao Ganjica0adc02011-09-22 20:35:53 -07001585 rc = regulator_disable(reg_l2);
1586 if (rc) {
1587 pr_err("disable reg_l2 failed, rc=%d\n", rc);
1588 return -ENODEV;
1589 }
1590 rc = regulator_disable(reg_l8);
1591 if (rc) {
1592 pr_err("disable reg_l8 failed, rc=%d\n", rc);
1593 return -ENODEV;
1594 }
1595 rc = regulator_disable(reg_l23);
1596 if (rc) {
1597 pr_err("disable reg_l23 failed, rc=%d\n", rc);
1598 return -ENODEV;
1599 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001600 rc = regulator_set_optimum_mode(reg_l8, 100);
1601 if (rc < 0) {
1602 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
1603 return -EINVAL;
1604 }
1605 rc = regulator_set_optimum_mode(reg_l23, 100);
1606 if (rc < 0) {
1607 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1608 return -EINVAL;
1609 }
1610 rc = regulator_set_optimum_mode(reg_l2, 100);
1611 if (rc < 0) {
1612 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1613 return -EINVAL;
1614 }
1615 gpio_set_value_cansleep(gpio43, 0);
1616 }
1617 return 0;
1618}
1619
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001620static int mipi_dsi_panel_power(int on)
1621{
1622 int ret;
1623
1624 pr_info("%s: on=%d\n", __func__, on);
1625
1626 if (machine_is_msm8960_liquid())
1627 ret = mipi_dsi_liquid_panel_power(on);
1628 else
1629 ret = mipi_dsi_cdp_panel_power(on);
1630
1631 return ret;
1632}
1633
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001634static struct mipi_dsi_platform_data mipi_dsi_pdata = {
1635 .vsync_gpio = MDP_VSYNC_GPIO,
1636 .dsi_power_save = mipi_dsi_panel_power,
1637};
1638
1639#ifdef CONFIG_MSM_BUS_SCALING
1640
1641static struct msm_bus_vectors mdp_init_vectors[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001642 {
1643 .src = MSM_BUS_MASTER_MDP_PORT0,
1644 .dst = MSM_BUS_SLAVE_EBI_CH0,
1645 .ab = 0,
1646 .ib = 0,
1647 },
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001648};
1649
1650static struct msm_bus_vectors mdp_ui_vectors[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001651 {
1652 .src = MSM_BUS_MASTER_MDP_PORT0,
1653 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001654 .ab = 216000000 * 2,
1655 .ib = 270000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001656 },
1657};
1658
1659static struct msm_bus_vectors mdp_vga_vectors[] = {
1660 /* VGA and less video */
1661 {
1662 .src = MSM_BUS_MASTER_MDP_PORT0,
1663 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001664 .ab = 216000000 * 2,
1665 .ib = 270000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001666 },
1667};
1668
1669static struct msm_bus_vectors mdp_720p_vectors[] = {
1670 /* 720p and less video */
1671 {
1672 .src = MSM_BUS_MASTER_MDP_PORT0,
1673 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001674 .ab = 230400000 * 2,
1675 .ib = 288000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001676 },
1677};
1678
1679static struct msm_bus_vectors mdp_1080p_vectors[] = {
1680 /* 1080p and less video */
1681 {
1682 .src = MSM_BUS_MASTER_MDP_PORT0,
1683 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001684 .ab = 334080000 * 2,
1685 .ib = 417600000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001686 },
1687};
1688
1689static struct msm_bus_paths mdp_bus_scale_usecases[] = {
1690 {
1691 ARRAY_SIZE(mdp_init_vectors),
1692 mdp_init_vectors,
1693 },
1694 {
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001695 ARRAY_SIZE(mdp_ui_vectors),
1696 mdp_ui_vectors,
1697 },
1698 {
1699 ARRAY_SIZE(mdp_ui_vectors),
1700 mdp_ui_vectors,
1701 },
1702 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001703 ARRAY_SIZE(mdp_vga_vectors),
1704 mdp_vga_vectors,
1705 },
1706 {
1707 ARRAY_SIZE(mdp_720p_vectors),
1708 mdp_720p_vectors,
1709 },
1710 {
1711 ARRAY_SIZE(mdp_1080p_vectors),
1712 mdp_1080p_vectors,
1713 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001714};
1715
1716static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
1717 mdp_bus_scale_usecases,
1718 ARRAY_SIZE(mdp_bus_scale_usecases),
1719 .name = "mdp",
1720};
1721
1722#endif
1723
1724int mdp_core_clk_rate_table[] = {
1725 85330000,
1726 85330000,
Nagamalleswararao Ganjiad31c982011-08-15 23:24:17 -07001727 160000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001728 200000000,
1729};
1730
1731static struct msm_panel_common_pdata mdp_pdata = {
1732 .gpio = MDP_VSYNC_GPIO,
1733 .mdp_core_clk_rate = 85330000,
1734 .mdp_core_clk_table = mdp_core_clk_rate_table,
1735 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
1736#ifdef CONFIG_MSM_BUS_SCALING
1737 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
1738#endif
1739 .mdp_rev = MDP_REV_42,
kuogee hsieh3830eb92011-09-12 15:25:57 -07001740 .writeback_offset = writeback_offset,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001741};
1742
1743static struct platform_device mipi_dsi_renesas_panel_device = {
1744 .name = "mipi_renesas",
1745 .id = 0,
1746};
1747
1748static struct platform_device mipi_dsi_simulator_panel_device = {
1749 .name = "mipi_simulator",
1750 .id = 0,
1751};
1752
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07001753#define LPM_CHANNEL0 0
1754static int toshiba_gpio[] = {LPM_CHANNEL0};
1755
1756static struct mipi_dsi_panel_platform_data toshiba_pdata = {
1757 .gpio = toshiba_gpio,
1758};
1759
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001760static struct platform_device mipi_dsi_toshiba_panel_device = {
1761 .name = "mipi_toshiba",
1762 .id = 0,
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07001763 .dev = {
1764 .platform_data = &toshiba_pdata,
1765 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001766};
1767
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001768static int dsi2lvds_gpio[2] = {
1769 0,/* Backlight PWM-ID=0 for PMIC-GPIO#24 */
1770 0x1F08 /* DSI2LVDS Bridge GPIO Output, mask=0x1f, out=0x08 */
1771 };
1772
1773static struct msm_panel_common_pdata mipi_dsi2lvds_pdata = {
1774 .gpio_num = dsi2lvds_gpio,
1775};
1776
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07001777static struct mipi_dsi_phy_ctrl dsi_novatek_cmd_mode_phy_db = {
1778
1779/* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */
1780 {0x0F, 0x0a, 0x04, 0x00, 0x20}, /* regulator */
1781 /* timing */
1782 {0xab, 0x8a, 0x18, 0x00, 0x92, 0x97, 0x1b, 0x8c,
1783 0x0c, 0x03, 0x04, 0xa0},
1784 {0x5f, 0x00, 0x00, 0x10}, /* phy ctrl */
1785 {0xff, 0x00, 0x06, 0x00}, /* strength */
1786 /* pll control */
1787 {0x40, 0xf9, 0x30, 0xda, 0x00, 0x40, 0x03, 0x62,
1788 0x40, 0x07, 0x03,
1789 0x00, 0x1a, 0x00, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01},
1790};
1791
1792static struct mipi_dsi_panel_platform_data novatek_pdata = {
1793 .phy_ctrl_settings = &dsi_novatek_cmd_mode_phy_db,
1794};
1795
1796static struct platform_device mipi_dsi_novatek_panel_device = {
1797 .name = "mipi_novatek",
1798 .id = 0,
1799 .dev = {
1800 .platform_data = &novatek_pdata,
1801 }
1802};
1803
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001804static struct platform_device mipi_dsi2lvds_bridge_device = {
1805 .name = "mipi_tc358764",
1806 .id = 0,
1807 .dev.platform_data = &mipi_dsi2lvds_pdata,
1808};
1809
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001810#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1811static struct resource hdmi_msm_resources[] = {
1812 {
1813 .name = "hdmi_msm_qfprom_addr",
1814 .start = 0x00700000,
1815 .end = 0x007060FF,
1816 .flags = IORESOURCE_MEM,
1817 },
1818 {
1819 .name = "hdmi_msm_hdmi_addr",
1820 .start = 0x04A00000,
1821 .end = 0x04A00FFF,
1822 .flags = IORESOURCE_MEM,
1823 },
1824 {
1825 .name = "hdmi_msm_irq",
1826 .start = HDMI_IRQ,
1827 .end = HDMI_IRQ,
1828 .flags = IORESOURCE_IRQ,
1829 },
1830};
1831
1832static int hdmi_enable_5v(int on);
1833static int hdmi_core_power(int on, int show);
1834static int hdmi_cec_power(int on);
1835
1836static struct msm_hdmi_platform_data hdmi_msm_data = {
1837 .irq = HDMI_IRQ,
1838 .enable_5v = hdmi_enable_5v,
1839 .core_power = hdmi_core_power,
1840 .cec_power = hdmi_cec_power,
1841};
1842
1843static struct platform_device hdmi_msm_device = {
1844 .name = "hdmi_msm",
1845 .id = 0,
1846 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
1847 .resource = hdmi_msm_resources,
1848 .dev.platform_data = &hdmi_msm_data,
1849};
1850#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1851
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001852#ifdef CONFIG_MSM_BUS_SCALING
1853static struct msm_bus_vectors dtv_bus_init_vectors[] = {
1854 {
1855 .src = MSM_BUS_MASTER_MDP_PORT0,
1856 .dst = MSM_BUS_SLAVE_EBI_CH0,
1857 .ab = 0,
1858 .ib = 0,
1859 },
1860};
1861static struct msm_bus_vectors dtv_bus_def_vectors[] = {
1862 {
1863 .src = MSM_BUS_MASTER_MDP_PORT0,
1864 .dst = MSM_BUS_SLAVE_EBI_CH0,
1865 .ab = 566092800 * 2,
1866 .ib = 707616000 * 2,
1867 },
1868};
1869static struct msm_bus_paths dtv_bus_scale_usecases[] = {
1870 {
1871 ARRAY_SIZE(dtv_bus_init_vectors),
1872 dtv_bus_init_vectors,
1873 },
1874 {
1875 ARRAY_SIZE(dtv_bus_def_vectors),
1876 dtv_bus_def_vectors,
1877 },
1878};
1879static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
1880 dtv_bus_scale_usecases,
1881 ARRAY_SIZE(dtv_bus_scale_usecases),
1882 .name = "dtv",
1883};
1884
1885static struct lcdc_platform_data dtv_pdata = {
1886 .bus_scale_table = &dtv_bus_scale_pdata,
1887};
1888#endif
1889
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001890static void __init msm_fb_add_devices(void)
1891{
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001892 struct platform_device *ptr = NULL;
1893
1894 if (machine_is_msm8960_liquid())
1895 ptr = &mipi_dsi2lvds_bridge_device;
1896 else
1897 ptr = &mipi_dsi_toshiba_panel_device;
1898 platform_add_devices(&ptr, 1);
1899
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001900 if (machine_is_msm8x60_rumi3()) {
1901 msm_fb_register_device("mdp", NULL);
1902 mipi_dsi_pdata.target_type = 1;
1903 } else
1904 msm_fb_register_device("mdp", &mdp_pdata);
1905 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001906#ifdef CONFIG_MSM_BUS_SCALING
1907 msm_fb_register_device("dtv", &dtv_pdata);
1908#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001909}
1910
Ravishangar Kalyanamba99e512011-07-20 12:57:19 -07001911static struct gpiomux_setting mdp_vsync_suspend_cfg = {
1912 .func = GPIOMUX_FUNC_GPIO,
1913 .drv = GPIOMUX_DRV_2MA,
1914 .pull = GPIOMUX_PULL_DOWN,
1915};
1916
1917static struct gpiomux_setting mdp_vsync_active_cfg = {
1918 .func = GPIOMUX_FUNC_1,
1919 .drv = GPIOMUX_DRV_2MA,
1920 .pull = GPIOMUX_PULL_DOWN,
1921};
1922
1923static struct msm_gpiomux_config msm8960_mdp_vsync_configs[] __initdata = {
1924 {
1925 .gpio = MDP_VSYNC_GPIO,
1926 .settings = {
1927 [GPIOMUX_ACTIVE] = &mdp_vsync_active_cfg,
1928 [GPIOMUX_SUSPENDED] = &mdp_vsync_suspend_cfg,
1929 },
1930 }
1931};
1932
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001933#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1934static struct gpiomux_setting hdmi_suspend_cfg = {
1935 .func = GPIOMUX_FUNC_GPIO,
1936 .drv = GPIOMUX_DRV_2MA,
1937 .pull = GPIOMUX_PULL_DOWN,
1938};
1939
1940static struct gpiomux_setting hdmi_active_1_cfg = {
1941 .func = GPIOMUX_FUNC_1,
1942 .drv = GPIOMUX_DRV_2MA,
1943 .pull = GPIOMUX_PULL_UP,
1944};
1945
1946static struct gpiomux_setting hdmi_active_2_cfg = {
1947 .func = GPIOMUX_FUNC_1,
1948 .drv = GPIOMUX_DRV_2MA,
1949 .pull = GPIOMUX_PULL_DOWN,
1950};
1951
1952static struct msm_gpiomux_config msm8960_hdmi_configs[] __initdata = {
1953 {
1954 .gpio = 99,
1955 .settings = {
1956 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
1957 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1958 },
1959 },
1960 {
1961 .gpio = 100,
1962 .settings = {
1963 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
1964 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1965 },
1966 },
1967 {
1968 .gpio = 101,
1969 .settings = {
1970 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
1971 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1972 },
1973 },
1974 {
1975 .gpio = 102,
1976 .settings = {
1977 [GPIOMUX_ACTIVE] = &hdmi_active_2_cfg,
1978 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1979 },
1980 },
1981};
1982
1983static int hdmi_enable_5v(int on)
1984{
1985 /* TBD: PM8921 regulator instead of 8901 */
1986 static struct regulator *reg_8921_hdmi_mvs; /* HDMI_5V */
1987 static int prev_on;
1988 int rc;
1989
1990 if (on == prev_on)
1991 return 0;
1992
1993 if (!reg_8921_hdmi_mvs)
1994 reg_8921_hdmi_mvs = regulator_get(&hdmi_msm_device.dev,
1995 "hdmi_mvs");
1996
1997 if (on) {
1998 rc = regulator_enable(reg_8921_hdmi_mvs);
1999 if (rc) {
2000 pr_err("'%s' regulator enable failed, rc=%d\n",
2001 "8921_hdmi_mvs", rc);
2002 return rc;
2003 }
2004 pr_debug("%s(on): success\n", __func__);
2005 } else {
2006 rc = regulator_disable(reg_8921_hdmi_mvs);
2007 if (rc)
2008 pr_warning("'%s' regulator disable failed, rc=%d\n",
2009 "8921_hdmi_mvs", rc);
2010 pr_debug("%s(off): success\n", __func__);
2011 }
2012
2013 prev_on = on;
2014
2015 return 0;
2016}
2017
2018static int hdmi_core_power(int on, int show)
2019{
2020 static struct regulator *reg_8921_l23, *reg_8921_s4;
2021 static int prev_on;
2022 int rc;
2023
2024 if (on == prev_on)
2025 return 0;
2026
2027 /* TBD: PM8921 regulator instead of 8901 */
Nagamalleswararao Ganjica0adc02011-09-22 20:35:53 -07002028 if (!reg_8921_l23) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002029 reg_8921_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
Nagamalleswararao Ganjica0adc02011-09-22 20:35:53 -07002030 if (IS_ERR(reg_8921_l23)) {
2031 pr_err("could not get reg_8921_l23, rc = %ld\n",
2032 PTR_ERR(reg_8921_l23));
2033 return -ENODEV;
2034 }
2035 rc = regulator_set_voltage(reg_8921_l23, 1800000, 1800000);
2036 if (rc) {
2037 pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc);
2038 return -EINVAL;
2039 }
2040 }
2041 if (!reg_8921_s4) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002042 reg_8921_s4 = regulator_get(&hdmi_msm_device.dev, "hdmi_vcc");
Nagamalleswararao Ganjica0adc02011-09-22 20:35:53 -07002043 if (IS_ERR(reg_8921_s4)) {
2044 pr_err("could not get reg_8921_s4, rc = %ld\n",
2045 PTR_ERR(reg_8921_s4));
2046 return -ENODEV;
2047 }
2048 rc = regulator_set_voltage(reg_8921_s4, 1800000, 1800000);
2049 if (rc) {
2050 pr_err("set_voltage failed for 8921_s4, rc=%d\n", rc);
2051 return -EINVAL;
2052 }
2053 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002054
2055 if (on) {
2056 rc = regulator_set_optimum_mode(reg_8921_l23, 100000);
2057 if (rc < 0) {
2058 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
2059 return -EINVAL;
2060 }
Nagamalleswararao Ganjica0adc02011-09-22 20:35:53 -07002061 rc = regulator_enable(reg_8921_l23);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002062 if (rc) {
2063 pr_err("'%s' regulator enable failed, rc=%d\n",
2064 "hdmi_avdd", rc);
2065 return rc;
2066 }
Nagamalleswararao Ganjica0adc02011-09-22 20:35:53 -07002067 rc = regulator_enable(reg_8921_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002068 if (rc) {
2069 pr_err("'%s' regulator enable failed, rc=%d\n",
2070 "hdmi_vcc", rc);
2071 return rc;
2072 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002073 rc = gpio_request(100, "HDMI_DDC_CLK");
2074 if (rc) {
2075 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
2076 "HDMI_DDC_CLK", 100, rc);
2077 goto error1;
2078 }
2079 rc = gpio_request(101, "HDMI_DDC_DATA");
2080 if (rc) {
2081 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
2082 "HDMI_DDC_DATA", 101, rc);
2083 goto error2;
2084 }
2085 rc = gpio_request(102, "HDMI_HPD");
2086 if (rc) {
2087 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
2088 "HDMI_HPD", 102, rc);
2089 goto error3;
2090 }
2091 pr_debug("%s(on): success\n", __func__);
2092 } else {
2093 gpio_free(100);
2094 gpio_free(101);
2095 gpio_free(102);
2096
Nagamalleswararao Ganjica0adc02011-09-22 20:35:53 -07002097 rc = regulator_disable(reg_8921_l23);
2098 if (rc) {
2099 pr_err("disable reg_8921_l23 failed, rc=%d\n", rc);
2100 return -ENODEV;
2101 }
2102 rc = regulator_disable(reg_8921_s4);
2103 if (rc) {
2104 pr_err("disable reg_8921_s4 failed, rc=%d\n", rc);
2105 return -ENODEV;
2106 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002107 rc = regulator_set_optimum_mode(reg_8921_l23, 100);
2108 if (rc < 0) {
2109 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
2110 return -EINVAL;
2111 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002112 pr_debug("%s(off): success\n", __func__);
2113 }
2114
2115 prev_on = on;
2116
2117 return 0;
2118
2119error3:
2120 gpio_free(101);
2121error2:
2122 gpio_free(100);
2123error1:
2124 regulator_disable(reg_8921_l23);
Nagamalleswararao Ganjica0adc02011-09-22 20:35:53 -07002125 regulator_disable(reg_8921_s4);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002126 return rc;
2127}
2128
2129static int hdmi_cec_power(int on)
2130{
2131 static int prev_on;
2132 int rc;
2133
2134 if (on == prev_on)
2135 return 0;
2136
2137 if (on) {
2138 rc = gpio_request(99, "HDMI_CEC_VAR");
2139 if (rc) {
2140 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
2141 "HDMI_CEC_VAR", 99, rc);
2142 goto error;
2143 }
2144 pr_debug("%s(on): success\n", __func__);
2145 } else {
2146 gpio_free(99);
2147 pr_debug("%s(off): success\n", __func__);
2148 }
2149
2150 prev_on = on;
2151
2152 return 0;
2153error:
2154 return rc;
2155}
2156#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
2157
2158static void __init msm8960_allocate_memory_regions(void)
2159{
2160 void *addr;
2161 unsigned long size;
2162
2163 size = MSM_FB_SIZE;
2164 addr = alloc_bootmem_align(size, 0x1000);
2165 msm_fb_resources[0].start = __pa(addr);
2166 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
2167 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
2168 size, addr, __pa(addr));
2169
2170}
2171#ifdef CONFIG_WCD9310_CODEC
2172
2173#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
2174
Patrick Lai3043fba2011-08-01 14:15:57 -07002175/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
2176 * 4 micbiases are used to power various analog and digital
2177 * microphones operating at 1800 mV. Technically, all micbiases
2178 * can source from single cfilter since all microphones operate
2179 * at the same voltage level. The arrangement below is to make
2180 * sure all cfilters are exercised. LDO_H regulator ouput level
2181 * does not need to be as high as 2.85V. It is choosen for
2182 * microphone sensitivity purpose.
2183 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002184static struct tabla_pdata tabla_platform_data = {
2185 .slimbus_slave_device = {
2186 .name = "tabla-slave",
2187 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
2188 },
2189 .irq = MSM_GPIO_TO_INT(62),
2190 .irq_base = TABLA_INTERRUPT_BASE,
2191 .num_irqs = NR_TABLA_IRQS,
2192 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
Patrick Lai3043fba2011-08-01 14:15:57 -07002193 .micbias = {
2194 .ldoh_v = TABLA_LDOH_2P85_V,
2195 .cfilt1_mv = 1800,
2196 .cfilt2_mv = 1800,
2197 .cfilt3_mv = 1800,
2198 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
2199 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
2200 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
2201 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
2202 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002203};
2204
2205static struct slim_device msm_slim_tabla = {
2206 .name = "tabla-slim",
2207 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
2208 .dev = {
2209 .platform_data = &tabla_platform_data,
2210 },
2211};
2212#endif
2213
2214static struct slim_boardinfo msm_slim_devices[] = {
2215#ifdef CONFIG_WCD9310_CODEC
2216 {
2217 .bus_num = 1,
2218 .slim_slave = &msm_slim_tabla,
2219 },
2220#endif
2221 /* add more slimbus slaves as needed */
2222};
2223
Yunsen Wang5c1a7392011-07-09 19:10:16 -07002224#define MSM_WCNSS_PHYS 0x03000000
2225#define MSM_WCNSS_SIZE 0x280000
2226
2227static struct resource resources_wcnss_wlan[] = {
2228 {
2229 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
2230 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
2231 .name = "wcnss_wlanrx_irq",
2232 .flags = IORESOURCE_IRQ,
2233 },
2234 {
2235 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
2236 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
2237 .name = "wcnss_wlantx_irq",
2238 .flags = IORESOURCE_IRQ,
2239 },
2240 {
2241 .start = MSM_WCNSS_PHYS,
2242 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
2243 .name = "wcnss_mmio",
2244 .flags = IORESOURCE_MEM,
2245 },
Ankur Nandwaniad0d9ac2011-09-26 11:49:25 -07002246 {
2247 .start = 84,
2248 .end = 88,
2249 .name = "wcnss_gpios_5wire",
2250 .flags = IORESOURCE_IO,
2251 },
Yunsen Wang5c1a7392011-07-09 19:10:16 -07002252};
2253
Ankur Nandwanib0039b02011-08-09 14:00:45 -07002254static struct qcom_wcnss_opts qcom_wcnss_pdata = {
2255 .has_48mhz_xo = 1,
2256};
2257
Yunsen Wang5c1a7392011-07-09 19:10:16 -07002258static struct platform_device msm_device_wcnss_wlan = {
2259 .name = "wcnss_wlan",
2260 .id = 0,
2261 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
2262 .resource = resources_wcnss_wlan,
Ankur Nandwanib0039b02011-08-09 14:00:45 -07002263 .dev = {.platform_data = &qcom_wcnss_pdata},
Yunsen Wang5c1a7392011-07-09 19:10:16 -07002264};
2265
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002266#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2267 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
2268 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2269 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2270
2271#define QCE_SIZE 0x10000
2272#define QCE_0_BASE 0x18500000
2273
2274#define QCE_HW_KEY_SUPPORT 0
2275#define QCE_SHA_HMAC_SUPPORT 1
2276#define QCE_SHARE_CE_RESOURCE 1
2277#define QCE_CE_SHARED 0
2278
2279static struct resource qcrypto_resources[] = {
2280 [0] = {
2281 .start = QCE_0_BASE,
2282 .end = QCE_0_BASE + QCE_SIZE - 1,
2283 .flags = IORESOURCE_MEM,
2284 },
2285 [1] = {
2286 .name = "crypto_channels",
2287 .start = DMOV_CE_IN_CHAN,
2288 .end = DMOV_CE_OUT_CHAN,
2289 .flags = IORESOURCE_DMA,
2290 },
2291 [2] = {
2292 .name = "crypto_crci_in",
2293 .start = DMOV_CE_IN_CRCI,
2294 .end = DMOV_CE_IN_CRCI,
2295 .flags = IORESOURCE_DMA,
2296 },
2297 [3] = {
2298 .name = "crypto_crci_out",
2299 .start = DMOV_CE_OUT_CRCI,
2300 .end = DMOV_CE_OUT_CRCI,
2301 .flags = IORESOURCE_DMA,
2302 },
2303};
2304
2305static struct resource qcedev_resources[] = {
2306 [0] = {
2307 .start = QCE_0_BASE,
2308 .end = QCE_0_BASE + QCE_SIZE - 1,
2309 .flags = IORESOURCE_MEM,
2310 },
2311 [1] = {
2312 .name = "crypto_channels",
2313 .start = DMOV_CE_IN_CHAN,
2314 .end = DMOV_CE_OUT_CHAN,
2315 .flags = IORESOURCE_DMA,
2316 },
2317 [2] = {
2318 .name = "crypto_crci_in",
2319 .start = DMOV_CE_IN_CRCI,
2320 .end = DMOV_CE_IN_CRCI,
2321 .flags = IORESOURCE_DMA,
2322 },
2323 [3] = {
2324 .name = "crypto_crci_out",
2325 .start = DMOV_CE_OUT_CRCI,
2326 .end = DMOV_CE_OUT_CRCI,
2327 .flags = IORESOURCE_DMA,
2328 },
2329};
2330
2331#endif
2332
2333#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2334 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2335
2336static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
2337 .ce_shared = QCE_CE_SHARED,
2338 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
2339 .hw_key_support = QCE_HW_KEY_SUPPORT,
2340 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
2341};
2342
2343static struct platform_device qcrypto_device = {
2344 .name = "qcrypto",
2345 .id = 0,
2346 .num_resources = ARRAY_SIZE(qcrypto_resources),
2347 .resource = qcrypto_resources,
2348 .dev = {
2349 .coherent_dma_mask = DMA_BIT_MASK(32),
2350 .platform_data = &qcrypto_ce_hw_suppport,
2351 },
2352};
2353#endif
2354
2355#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2356 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2357
2358static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
2359 .ce_shared = QCE_CE_SHARED,
2360 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
2361 .hw_key_support = QCE_HW_KEY_SUPPORT,
2362 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
2363};
2364
2365static struct platform_device qcedev_device = {
2366 .name = "qce",
2367 .id = 0,
2368 .num_resources = ARRAY_SIZE(qcedev_resources),
2369 .resource = qcedev_resources,
2370 .dev = {
2371 .coherent_dma_mask = DMA_BIT_MASK(32),
2372 .platform_data = &qcedev_ce_hw_suppport,
2373 },
2374};
2375#endif
2376
2377
2378static int __init gpiomux_init(void)
2379{
2380 int rc;
2381
2382 rc = msm_gpiomux_init(NR_GPIO_IRQS);
2383 if (rc) {
2384 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
2385 return rc;
2386 }
2387
Nishant Pandit24153d82011-08-27 16:05:13 +05302388 msm_gpiomux_install(msm8960_cam_common_configs,
2389 ARRAY_SIZE(msm8960_cam_common_configs));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002390
2391 msm_gpiomux_install(msm8960_gpiomux_configs,
Stepan Moskovchenkod2a45a82011-08-09 17:02:57 -07002392 ARRAY_SIZE(msm8960_gpiomux_configs));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002393
2394 msm_gpiomux_install(msm8960_gsbi_configs,
2395 ARRAY_SIZE(msm8960_gsbi_configs));
2396
2397 msm_gpiomux_install(msm8960_cyts_configs,
2398 ARRAY_SIZE(msm8960_cyts_configs));
2399
2400 msm_gpiomux_install(msm8960_slimbus_config,
2401 ARRAY_SIZE(msm8960_slimbus_config));
2402
2403 msm_gpiomux_install(msm8960_audio_codec_configs,
2404 ARRAY_SIZE(msm8960_audio_codec_configs));
2405
Bhalchandra Gajare0e795c42011-08-15 18:10:30 -07002406 msm_gpiomux_install(msm8960_audio_auxpcm_configs,
2407 ARRAY_SIZE(msm8960_audio_auxpcm_configs));
2408
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002409#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
2410 msm_gpiomux_install(msm8960_hdmi_configs,
2411 ARRAY_SIZE(msm8960_hdmi_configs));
2412#endif
2413
Ravishangar Kalyanamba99e512011-07-20 12:57:19 -07002414 msm_gpiomux_install(msm8960_mdp_vsync_configs,
2415 ARRAY_SIZE(msm8960_mdp_vsync_configs));
2416
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002417 msm_gpiomux_install(wcnss_5wire_interface,
2418 ARRAY_SIZE(wcnss_5wire_interface));
2419
2420 return 0;
2421}
2422
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002423#define MSM_SHARED_RAM_PHYS 0x80000000
2424
2425static struct pm8921_adc_amux pm8921_adc_channels_data[] = {
2426 {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
2427 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2428 {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
2429 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2430 {"dcin", CHANNEL_DCIN, CHAN_PATH_SCALING4, AMUX_RSV1,
2431 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2432 {"ichg", CHANNEL_ICHG, CHAN_PATH_SCALING1, AMUX_RSV1,
2433 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2434 {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
2435 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2436 {"ibat", CHANNEL_IBAT, CHAN_PATH_SCALING1, AMUX_RSV1,
2437 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002438 {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
2439 ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
2440 {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV1,
2441 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2442 {"usbin", CHANNEL_USBIN, CHAN_PATH_SCALING3, AMUX_RSV1,
2443 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2444 {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
2445 ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
2446 {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
2447 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2448 {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
2449 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2450 {"chg_temp", CHANNEL_CHG_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
2451 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
Siddartha Mohanadoss77d106e2011-09-20 16:25:59 -07002452 {"pa_therm1", ADC_MPP_1_AMUX8, CHAN_PATH_SCALING1, AMUX_RSV1,
Siddartha Mohanadossb9e4d282011-09-13 17:50:11 -07002453 ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM},
2454 {"xo_therm", CHANNEL_MUXOFF, CHAN_PATH_SCALING1, AMUX_RSV0,
2455 ADC_DECIMATION_TYPE2, ADC_SCALE_XOTHERM},
Siddartha Mohanadoss77d106e2011-09-20 16:25:59 -07002456 {"pa_therm0", ADC_MPP_1_AMUX3, CHAN_PATH_SCALING1, AMUX_RSV1,
2457 ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM},
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002458};
2459
2460static struct pm8921_adc_properties pm8921_adc_data = {
2461 .adc_vdd_reference = 1800, /* milli-voltage for this adc */
2462 .bitresolution = 15,
2463 .bipolar = 0,
2464};
2465
2466static struct pm8921_adc_platform_data pm8921_adc_pdata = {
2467 .adc_channel = pm8921_adc_channels_data,
Siddartha Mohanadoss77d106e2011-09-20 16:25:59 -07002468 .adc_num_board_channel = ARRAY_SIZE(pm8921_adc_channels_data),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002469 .adc_prop = &pm8921_adc_data,
Siddartha Mohanadoss77d106e2011-09-20 16:25:59 -07002470 .adc_mpp_base = PM8921_MPP_PM_TO_SYS(1),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002471};
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08002472
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002473static void __init msm8960_map_io(void)
2474{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002475 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002476 msm_map_msm8960_io();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07002477
2478 if (socinfo_init() < 0)
2479 pr_err("socinfo_init() failed!\n");
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002480}
2481
2482static void __init msm8960_init_irq(void)
2483{
2484 unsigned int i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002485
2486 msm_mpm_irq_extn_init();
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002487 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002488 (void *)MSM_QGIC_CPU_BASE);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002489
2490 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002491 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002492
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002493 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
2494 mb();
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08002495
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002496 /* FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
2497 * as they are configured as level, which does not play nice with
2498 * handle_percpu_irq.
2499 */
2500 for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
2501 if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
Thomas Gleixner6845664a2011-03-24 13:25:22 +01002502 irq_set_handler(i, handle_percpu_irq);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002503 }
2504}
2505
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002506/* MSM8960 have 5 SDCC controllers */
2507enum sdcc_controllers {
2508 SDCC1,
2509 SDCC2,
2510 SDCC3,
2511 SDCC4,
2512 SDCC5,
2513 MAX_SDCC_CONTROLLER
2514};
2515
2516/* All SDCC controllers requires VDD/VCC voltage */
2517static struct msm_mmc_reg_data mmc_vdd_reg_data[MAX_SDCC_CONTROLLER] = {
2518 /* SDCC1 : eMMC card connected */
2519 [SDCC1] = {
2520 .name = "sdc_vdd",
2521 .set_voltage_sup = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302522 .high_vol_level = 2950000,
2523 .low_vol_level = 2950000,
Subhash Jadavanidd7ef892011-08-18 16:49:57 +05302524 .always_on = 1,
2525 .lpm_sup = 1,
2526 .lpm_uA = 9000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002527 .hpm_uA = 200000, /* 200mA */
2528 },
2529 /* SDCC3 : External card slot connected */
2530 [SDCC3] = {
2531 .name = "sdc_vdd",
2532 .set_voltage_sup = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302533 .high_vol_level = 2950000,
2534 .low_vol_level = 2950000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002535 .hpm_uA = 600000, /* 600mA */
2536 }
2537};
2538
2539/* Only slots having eMMC card will require VCCQ voltage */
2540static struct msm_mmc_reg_data mmc_vccq_reg_data[1] = {
2541 /* SDCC1 : eMMC card connected */
2542 [SDCC1] = {
2543 .name = "sdc_vccq",
2544 .set_voltage_sup = 1,
2545 .always_on = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302546 .high_vol_level = 1800000,
2547 .low_vol_level = 1800000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002548 .hpm_uA = 200000, /* 200mA */
2549 }
2550};
2551
2552/* All SDCC controllers may require voting for VDD PAD voltage */
2553static struct msm_mmc_reg_data mmc_vddp_reg_data[MAX_SDCC_CONTROLLER] = {
2554 /* SDCC3 : External card slot connected */
2555 [SDCC3] = {
2556 .name = "sdc_vddp",
2557 .set_voltage_sup = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302558 .high_vol_level = 2950000,
2559 .low_vol_level = 1850000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002560 .always_on = 1,
2561 .lpm_sup = 1,
2562 /* Max. Active current required is 16 mA */
2563 .hpm_uA = 16000,
2564 /*
2565 * Sleep current required is ~300 uA. But min. vote can be
2566 * in terms of mA (min. 1 mA). So let's vote for 2 mA
2567 * during sleep.
2568 */
2569 .lpm_uA = 2000,
2570 }
2571};
2572
2573static struct msm_mmc_slot_reg_data mmc_slot_vreg_data[MAX_SDCC_CONTROLLER] = {
2574 /* SDCC1 : eMMC card connected */
2575 [SDCC1] = {
2576 .vdd_data = &mmc_vdd_reg_data[SDCC1],
2577 .vccq_data = &mmc_vccq_reg_data[SDCC1],
2578 },
2579 /* SDCC3 : External card slot connected */
2580 [SDCC3] = {
2581 .vdd_data = &mmc_vdd_reg_data[SDCC3],
2582 .vddp_data = &mmc_vddp_reg_data[SDCC3],
2583 }
2584};
2585
2586/* SDC1 pad data */
2587static struct msm_mmc_pad_drv sdc1_pad_drv_on_cfg[] = {
2588 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_16MA},
Subhash Jadavani87bda5a2011-08-30 17:40:44 +05302589 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_10MA},
2590 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_10MA}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002591};
2592
2593static struct msm_mmc_pad_drv sdc1_pad_drv_off_cfg[] = {
2594 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_2MA},
2595 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_2MA},
2596 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_2MA}
2597};
2598
2599static struct msm_mmc_pad_pull sdc1_pad_pull_on_cfg[] = {
Subhash Jadavanib7b5b8a2011-09-13 13:00:40 +05302600 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002601 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_UP},
2602 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_UP}
2603};
2604
2605static struct msm_mmc_pad_pull sdc1_pad_pull_off_cfg[] = {
Subhash Jadavanib7b5b8a2011-09-13 13:00:40 +05302606 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002607 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_DOWN},
2608 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_DOWN}
2609};
2610
2611/* SDC3 pad data */
2612static struct msm_mmc_pad_drv sdc3_pad_drv_on_cfg[] = {
2613 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
2614 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
2615 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
2616};
2617
2618static struct msm_mmc_pad_drv sdc3_pad_drv_off_cfg[] = {
2619 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
2620 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
2621 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
2622};
2623
2624static struct msm_mmc_pad_pull sdc3_pad_pull_on_cfg[] = {
Subhash Jadavanib7b5b8a2011-09-13 13:00:40 +05302625 {TLMM_PULL_SDC3_CLK, GPIO_CFG_NO_PULL},
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002626 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
2627 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
2628};
2629
2630static struct msm_mmc_pad_pull sdc3_pad_pull_off_cfg[] = {
Subhash Jadavanib7b5b8a2011-09-13 13:00:40 +05302631 {TLMM_PULL_SDC3_CLK, GPIO_CFG_NO_PULL},
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002632 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
2633 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
2634};
2635
2636struct msm_mmc_pad_pull_data mmc_pad_pull_data[MAX_SDCC_CONTROLLER] = {
2637 [SDCC1] = {
2638 .on = sdc1_pad_pull_on_cfg,
2639 .off = sdc1_pad_pull_off_cfg,
2640 .size = ARRAY_SIZE(sdc1_pad_pull_on_cfg)
2641 },
2642 [SDCC3] = {
2643 .on = sdc3_pad_pull_on_cfg,
2644 .off = sdc3_pad_pull_off_cfg,
2645 .size = ARRAY_SIZE(sdc3_pad_pull_on_cfg)
2646 },
2647};
2648
2649struct msm_mmc_pad_drv_data mmc_pad_drv_data[MAX_SDCC_CONTROLLER] = {
2650 [SDCC1] = {
2651 .on = sdc1_pad_drv_on_cfg,
2652 .off = sdc1_pad_drv_off_cfg,
2653 .size = ARRAY_SIZE(sdc1_pad_drv_on_cfg)
2654 },
2655 [SDCC3] = {
2656 .on = sdc3_pad_drv_on_cfg,
2657 .off = sdc3_pad_drv_off_cfg,
2658 .size = ARRAY_SIZE(sdc3_pad_drv_on_cfg)
2659 },
2660};
2661
2662struct msm_mmc_pad_data mmc_pad_data[MAX_SDCC_CONTROLLER] = {
2663 [SDCC1] = {
2664 .pull = &mmc_pad_pull_data[SDCC1],
2665 .drv = &mmc_pad_drv_data[SDCC1]
2666 },
2667 [SDCC3] = {
2668 .pull = &mmc_pad_pull_data[SDCC3],
2669 .drv = &mmc_pad_drv_data[SDCC3]
2670 },
2671};
2672
2673struct msm_mmc_pin_data mmc_slot_pin_data[MAX_SDCC_CONTROLLER] = {
2674 [SDCC1] = {
2675 .pad_data = &mmc_pad_data[SDCC1],
2676 },
2677 [SDCC3] = {
2678 .pad_data = &mmc_pad_data[SDCC3],
2679 },
2680};
2681
2682static unsigned int sdc1_sup_clk_rates[] = {
Subhash Jadavani0e027b72011-08-30 17:40:55 +05302683 400000, 24000000, 48000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002684};
2685
2686static unsigned int sdc3_sup_clk_rates[] = {
2687 400000, 24000000, 48000000, 96000000
2688};
2689
2690#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
2691static struct mmc_platform_data msm8960_sdc1_data = {
2692 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
2693#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
2694 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
2695#else
2696 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
2697#endif
2698 .sup_clk_table = sdc1_sup_clk_rates,
2699 .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates),
Subhash Jadavanib7655b62011-09-27 19:12:36 +05302700 .pclk_src_dfab = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002701 .nonremovable = 1,
2702 .sdcc_v4_sup = true,
2703 .vreg_data = &mmc_slot_vreg_data[SDCC1],
Subhash Jadavani0e027b72011-08-30 17:40:55 +05302704 .pin_data = &mmc_slot_pin_data[SDCC1]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002705};
2706#endif
2707
2708#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
2709static struct mmc_platform_data msm8960_sdc3_data = {
2710 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
2711 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
2712 .sup_clk_table = sdc3_sup_clk_rates,
2713 .sup_clk_cnt = ARRAY_SIZE(sdc3_sup_clk_rates),
Subhash Jadavanib7655b62011-09-27 19:12:36 +05302714 .pclk_src_dfab = 1,
Subhash Jadavanib9ef7472011-09-21 18:37:28 +05302715#ifdef CONFIG_MMC_MSM_SDC3_WP_SUPPORT
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002716 .wpswitch_gpio = PM8921_GPIO_PM_TO_SYS(16),
Subhash Jadavanib9ef7472011-09-21 18:37:28 +05302717#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002718 .sdcc_v4_sup = true,
2719 .vreg_data = &mmc_slot_vreg_data[SDCC3],
2720 .pin_data = &mmc_slot_pin_data[SDCC3],
2721#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
2722 .status_gpio = PM8921_GPIO_PM_TO_SYS(26),
2723 .status_irq = PM8921_GPIO_IRQ(PM8921_IRQ_BASE, 26),
2724 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
2725#endif
2726 .xpc_cap = 1,
2727 .uhs_caps = (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
2728 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_DDR50 |
Subhash Jadavani0e027b72011-08-30 17:40:55 +05302729 MMC_CAP_MAX_CURRENT_600)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002730};
2731#endif
2732
2733static void __init msm8960_init_mmc(void)
2734{
2735#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
2736 /* SDC1 : eMMC card connected */
2737 msm_add_sdcc(1, &msm8960_sdc1_data);
2738#endif
2739#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
2740 /* SDC3: External card slot */
2741 msm_add_sdcc(3, &msm8960_sdc3_data);
2742#endif
2743}
2744
2745static void __init msm8960_init_buses(void)
2746{
2747#ifdef CONFIG_MSM_BUS_SCALING
2748 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
2749 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
2750 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
2751 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
2752 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
2753 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
2754 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
2755 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
2756 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
2757 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
Gagan Macdc1dc142011-09-16 15:13:35 -06002758 msm_bus_rpm_set_mt_mask();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002759#endif
2760}
2761
2762static struct msm_spi_platform_data msm8960_qup_spi_gsbi1_pdata = {
2763 .max_clock_speed = 15060000,
2764};
2765
2766#ifdef CONFIG_USB_MSM_OTG_72K
2767static struct msm_otg_platform_data msm_otg_pdata;
2768#else
2769#define USB_5V_EN 42
2770static void msm_hsusb_vbus_power(bool on)
2771{
2772 int rc;
2773 static bool vbus_is_on;
2774 static struct regulator *mvs_otg_switch;
2775 struct pm_gpio param = {
2776 .direction = PM_GPIO_DIR_OUT,
2777 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
2778 .output_value = 1,
2779 .pull = PM_GPIO_PULL_NO,
2780 .vin_sel = PM_GPIO_VIN_S4,
2781 .out_strength = PM_GPIO_STRENGTH_MED,
2782 .function = PM_GPIO_FUNC_NORMAL,
2783 };
2784
2785 if (vbus_is_on == on)
2786 return;
2787
2788 if (on) {
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002789 mvs_otg_switch = regulator_get(&msm8960_device_otg.dev,
2790 "vbus_otg");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002791 if (IS_ERR(mvs_otg_switch)) {
2792 pr_err("Unable to get mvs_otg_switch\n");
2793 return;
2794 }
2795
2796 rc = gpio_request(PM8921_GPIO_PM_TO_SYS(USB_5V_EN),
2797 "usb_5v_en");
2798 if (rc < 0) {
2799 pr_err("failed to request usb_5v_en gpio\n");
2800 goto put_mvs_otg;
2801 }
2802
2803 if (regulator_enable(mvs_otg_switch)) {
2804 pr_err("unable to enable mvs_otg_switch\n");
2805 goto free_usb_5v_en;
2806 }
2807
2808 rc = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(USB_5V_EN),
2809 &param);
2810 if (rc < 0) {
2811 pr_err("failed to configure usb_5v_en gpio\n");
2812 goto disable_mvs_otg;
2813 }
2814 vbus_is_on = true;
2815 return;
2816 }
2817disable_mvs_otg:
2818 regulator_disable(mvs_otg_switch);
2819free_usb_5v_en:
2820 gpio_free(PM8921_GPIO_PM_TO_SYS(USB_5V_EN));
2821put_mvs_otg:
2822 regulator_put(mvs_otg_switch);
2823 vbus_is_on = false;
2824}
2825
2826static struct msm_otg_platform_data msm_otg_pdata = {
2827 .mode = USB_OTG,
2828 .otg_control = OTG_PMIC_CONTROL,
2829 .phy_type = SNPS_28NM_INTEGRATED_PHY,
2830 .pclk_src_name = "dfab_usb_hs_clk",
2831 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
2832 .vbus_power = msm_hsusb_vbus_power,
Anji jonnala4e3e6772011-09-15 18:53:42 +05302833 .power_budget = 750,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002834};
2835#endif
2836
2837#define PID_MAGIC_ID 0x71432909
2838#define SERIAL_NUM_MAGIC_ID 0x61945374
2839#define SERIAL_NUMBER_LENGTH 127
2840#define DLOAD_USB_BASE_ADD 0x2A03F0C8
2841
2842struct magic_num_struct {
2843 uint32_t pid;
2844 uint32_t serial_num;
2845};
2846
2847struct dload_struct {
2848 uint32_t reserved1;
2849 uint32_t reserved2;
2850 uint32_t reserved3;
2851 uint16_t reserved4;
2852 uint16_t pid;
2853 char serial_number[SERIAL_NUMBER_LENGTH];
2854 uint16_t reserved5;
2855 struct magic_num_struct magic_struct;
2856};
2857
2858static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
2859{
2860 struct dload_struct __iomem *dload = 0;
2861
2862 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
2863 if (!dload) {
2864 pr_err("%s: cannot remap I/O memory region: %08x\n",
2865 __func__, DLOAD_USB_BASE_ADD);
2866 return -ENXIO;
2867 }
2868
2869 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
2870 __func__, dload, pid, snum);
2871 /* update pid */
2872 dload->magic_struct.pid = PID_MAGIC_ID;
2873 dload->pid = pid;
2874
2875 /* update serial number */
2876 dload->magic_struct.serial_num = 0;
2877 if (!snum) {
2878 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
2879 goto out;
2880 }
2881
2882 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
2883 strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
2884 dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
2885out:
2886 iounmap(dload);
2887 return 0;
2888}
2889
2890static struct android_usb_platform_data android_usb_pdata = {
2891 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2892};
2893
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002894static struct platform_device android_usb_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002895 .name = "android_usb",
2896 .id = -1,
2897 .dev = {
2898 .platform_data = &android_usb_pdata,
2899 },
2900};
2901
2902static uint8_t spm_wfi_cmd_sequence[] __initdata = {
2903 0x03, 0x0f,
2904};
2905
2906static uint8_t spm_power_collapse_without_rpm[] __initdata = {
2907 0x00, 0x24, 0x54, 0x10,
2908 0x09, 0x03, 0x01,
2909 0x10, 0x54, 0x30, 0x0C,
2910 0x24, 0x30, 0x0f,
2911};
2912
2913static uint8_t spm_power_collapse_with_rpm[] __initdata = {
2914 0x00, 0x24, 0x54, 0x10,
2915 0x09, 0x07, 0x01, 0x0B,
2916 0x10, 0x54, 0x30, 0x0C,
2917 0x24, 0x30, 0x0f,
2918};
2919
2920static struct msm_spm_seq_entry msm_spm_seq_list[] __initdata = {
2921 [0] = {
2922 .mode = MSM_SPM_MODE_CLOCK_GATING,
2923 .notify_rpm = false,
2924 .cmd = spm_wfi_cmd_sequence,
2925 },
2926 [1] = {
2927 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2928 .notify_rpm = false,
2929 .cmd = spm_power_collapse_without_rpm,
2930 },
2931 [2] = {
2932 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2933 .notify_rpm = true,
2934 .cmd = spm_power_collapse_with_rpm,
2935 },
2936};
2937
2938static struct msm_spm_platform_data msm_spm_data[] __initdata = {
2939 [0] = {
2940 .reg_base_addr = MSM_SAW0_BASE,
2941 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
2942 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
2943 .reg_init_values[MSM_SPM_REG_SAW2_VCTL] = 0x9C,
2944#if defined(CONFIG_MSM_AVS_HW)
2945 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2946 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2947#endif
2948 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
2949 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
2950 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2951 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2952 .vctl_timeout_us = 50,
2953 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
2954 .modes = msm_spm_seq_list,
2955 },
2956 [1] = {
2957 .reg_base_addr = MSM_SAW1_BASE,
2958 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
2959 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
2960 .reg_init_values[MSM_SPM_REG_SAW2_VCTL] = 0x9C,
2961#if defined(CONFIG_MSM_AVS_HW)
2962 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2963 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2964#endif
2965 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
2966 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
2967 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2968 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2969 .vctl_timeout_us = 50,
2970 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
2971 .modes = msm_spm_seq_list,
2972 },
2973};
2974
2975static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
2976 0x00, 0x20, 0x03, 0x20,
2977 0x00, 0x0f,
2978};
2979
2980static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
2981 0x00, 0x20, 0x34, 0x64,
2982 0x48, 0x07, 0x48, 0x20,
2983 0x50, 0x64, 0x04, 0x34,
2984 0x50, 0x0f,
2985};
2986static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
2987 0x00, 0x10, 0x34, 0x64,
2988 0x48, 0x07, 0x48, 0x10,
2989 0x50, 0x64, 0x04, 0x34,
2990 0x50, 0x0F,
2991};
2992
2993static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
2994 [0] = {
2995 .mode = MSM_SPM_L2_MODE_RETENTION,
2996 .notify_rpm = false,
2997 .cmd = l2_spm_wfi_cmd_sequence,
2998 },
2999 [1] = {
3000 .mode = MSM_SPM_L2_MODE_GDHS,
3001 .notify_rpm = true,
3002 .cmd = l2_spm_gdhs_cmd_sequence,
3003 },
3004 [2] = {
3005 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
3006 .notify_rpm = true,
3007 .cmd = l2_spm_power_off_cmd_sequence,
3008 },
3009};
3010
3011
3012static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
3013 [0] = {
3014 .reg_base_addr = MSM_SAW_L2_BASE,
3015 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
3016 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
3017 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
3018 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
3019 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
3020 .modes = msm_spm_l2_seq_list,
3021 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
3022 },
3023};
3024
3025#define CYTTSP_TS_GPIO_IRQ 11
3026#define CYTTSP_TS_SLEEP_GPIO 50
3027#define CYTTSP_TS_RESOUT_N_GPIO 52
3028
3029/*virtual key support */
3030static ssize_t tma340_vkeys_show(struct kobject *kobj,
3031 struct kobj_attribute *attr, char *buf)
3032{
3033 return snprintf(buf, 200,
3034 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
3035 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
3036 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
3037 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
3038 "\n");
3039}
3040
3041static struct kobj_attribute tma340_vkeys_attr = {
3042 .attr = {
3043 .mode = S_IRUGO,
3044 },
3045 .show = &tma340_vkeys_show,
3046};
3047
3048static struct attribute *tma340_properties_attrs[] = {
3049 &tma340_vkeys_attr.attr,
3050 NULL
3051};
3052
3053static struct attribute_group tma340_properties_attr_group = {
3054 .attrs = tma340_properties_attrs,
3055};
3056
3057
3058static int cyttsp_platform_init(struct i2c_client *client)
3059{
3060 int rc = 0;
3061 static struct kobject *tma340_properties_kobj;
3062
3063 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
3064 tma340_properties_kobj = kobject_create_and_add("board_properties",
3065 NULL);
3066 if (tma340_properties_kobj)
3067 rc = sysfs_create_group(tma340_properties_kobj,
3068 &tma340_properties_attr_group);
3069 if (!tma340_properties_kobj || rc)
3070 pr_err("%s: failed to create board_properties\n",
3071 __func__);
3072
3073 return 0;
3074}
3075
3076static struct cyttsp_regulator regulator_data[] = {
3077 {
3078 .name = "vdd",
3079 .min_uV = CY_TMA300_VTG_MIN_UV,
3080 .max_uV = CY_TMA300_VTG_MAX_UV,
3081 .load_uA = CY_TMA300_CURR_24HZ_UA,
3082 },
3083 /* TODO: Remove after runtime PM is enabled in I2C driver */
3084 {
3085 .name = "vcc_i2c",
3086 .min_uV = CY_I2C_VTG_MIN_UV,
3087 .max_uV = CY_I2C_VTG_MAX_UV,
3088 .load_uA = CY_I2C_CURR_UA,
3089 },
3090};
3091
3092static struct cyttsp_platform_data cyttsp_pdata = {
3093 .panel_maxx = 634,
3094 .panel_maxy = 1166,
3095 .disp_maxx = 616,
3096 .disp_maxy = 1023,
3097 .disp_minx = 0,
3098 .disp_miny = 16,
3099 .flags = 0x01,
3100 .gen = CY_GEN3, /* or */
3101 .use_st = CY_USE_ST,
3102 .use_mt = CY_USE_MT,
3103 .use_hndshk = CY_SEND_HNDSHK,
3104 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayale96f66d2011-08-11 14:06:38 +05303105 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003106 .use_gestures = CY_USE_GESTURES,
3107 .fw_fname = "cyttsp_8960_cdp.hex",
3108 /* activate up to 4 groups
3109 * and set active distance
3110 */
3111 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
3112 CY_GEST_GRP3 | CY_GEST_GRP4 |
3113 CY_ACT_DIST,
3114 /* change act_intrvl to customize the Active power state
3115 * scanning/processing refresh interval for Operating mode
3116 */
3117 .act_intrvl = CY_ACT_INTRVL_DFLT,
3118 /* change tch_tmout to customize the touch timeout for the
3119 * Active power state for Operating mode
3120 */
3121 .tch_tmout = CY_TCH_TMOUT_DFLT,
3122 /* change lp_intrvl to customize the Low Power power state
3123 * scanning/processing refresh interval for Operating mode
3124 */
3125 .lp_intrvl = CY_LP_INTRVL_DFLT,
3126 .sleep_gpio = CYTTSP_TS_SLEEP_GPIO,
3127 .resout_gpio = CYTTSP_TS_RESOUT_N_GPIO,
3128 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
3129 .regulator_info = regulator_data,
3130 .num_regulators = ARRAY_SIZE(regulator_data),
3131 .init = cyttsp_platform_init,
Mohan Pallaka49c37d62011-08-01 11:52:00 +05303132 .correct_fw_ver = 9,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003133};
3134
3135static struct i2c_board_info cyttsp_info[] __initdata = {
3136 {
3137 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
3138 .platform_data = &cyttsp_pdata,
3139#ifndef CY_USE_TIMER
3140 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
3141#endif /* CY_USE_TIMER */
3142 },
3143};
3144
Mohan Pallaka50837382011-09-07 11:00:57 +05303145/* configuration data */
3146static const u8 mxt_config_data[] = {
3147 /* T6 Object */
3148 0, 0, 0, 0, 0, 0,
3149 /* T38 Object */
3150 11, 0, 0, 6, 9, 11, 0, 0, 0, 0,
3151 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3152 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3153 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3154 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3156 0, 0, 0, 0,
3157 /* T7 Object */
3158 10, 10, 50,
3159 /* T8 Object */
3160 8, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3161 /* T9 Object */
3162 131, 0, 0, 26, 42, 0, 32, 60, 2, 5,
3163 0, 5, 5, 34, 10, 10, 10, 10, 85, 5,
3164 255, 2, 8, 9, 9, 9, 0, 0, 5, 20,
3165 0, 5, 45, 46,
3166 /* T15 Object */
3167 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3168 0,
3169 /* T22 Object */
3170 0, 0, 0, 0, 0, 0, 0, 0, 30, 0,
3171 0, 0, 255, 255, 255, 255, 0,
3172 /* T24 Object */
3173 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3174 0, 0, 0, 0, 0, 0, 0, 0, 0,
3175 /* T25 Object */
3176 3, 0, 188, 52, 52, 33, 0, 0, 0, 0,
3177 0, 0, 0, 0,
3178 /* T27 Object */
3179 0, 0, 0, 0, 0, 0, 0,
3180 /* T28 Object */
3181 0, 0, 0, 8, 8, 8,
3182 /* T40 Object */
3183 0, 0, 0, 0, 0,
3184 /* T41 Object */
3185 0, 0, 0, 0, 0, 0,
3186 /* T43 Object */
3187 0, 0, 0, 0, 0, 0,
3188};
3189
3190#define MXT_TS_GPIO_IRQ 11
3191#define MXT_TS_LDO_EN_GPIO 50
3192#define MXT_TS_RESET_GPIO 52
3193
3194static void mxt_init_hw_liquid(void)
3195{
3196 int rc;
3197
3198 rc = gpio_request(MXT_TS_GPIO_IRQ, "mxt_ts_irq_gpio");
3199 if (rc) {
3200 pr_err("%s: unable to request mxt_ts_irq gpio [%d]\n",
3201 __func__, MXT_TS_GPIO_IRQ);
3202 return;
3203 }
3204
3205 rc = gpio_direction_input(MXT_TS_GPIO_IRQ);
3206 if (rc) {
3207 pr_err("%s: unable to set_direction for mxt_ts_irq gpio [%d]\n",
3208 __func__, MXT_TS_GPIO_IRQ);
3209 goto err_irq_gpio_req;
3210 }
3211
3212 rc = gpio_request(MXT_TS_LDO_EN_GPIO, "mxt_ldo_en_gpio");
3213 if (rc) {
3214 pr_err("%s: unable to request mxt_ldo_en gpio [%d]\n",
3215 __func__, MXT_TS_LDO_EN_GPIO);
3216 goto err_irq_gpio_req;
3217 }
3218
3219 rc = gpio_direction_output(MXT_TS_LDO_EN_GPIO, 1);
3220 if (rc) {
3221 pr_err("%s: unable to set_direction for mxt_ldo_en gpio [%d]\n",
3222 __func__, MXT_TS_LDO_EN_GPIO);
3223 goto err_ldo_gpio_req;
3224 }
3225
3226 rc = gpio_request(MXT_TS_RESET_GPIO, "mxt_reset_gpio");
3227 if (rc) {
3228 pr_err("%s: unable to request mxt_reset gpio [%d]\n",
3229 __func__, MXT_TS_RESET_GPIO);
3230 goto err_ldo_gpio_set_dir;
3231 }
3232
3233 rc = gpio_direction_output(MXT_TS_RESET_GPIO, 1);
3234 if (rc) {
3235 pr_err("%s: unable to set_direction for mxt_reset gpio [%d]\n",
3236 __func__, MXT_TS_RESET_GPIO);
3237 goto err_reset_gpio_req;
3238 }
3239
3240 return;
3241
3242err_reset_gpio_req:
3243 gpio_free(MXT_TS_RESET_GPIO);
3244err_ldo_gpio_set_dir:
3245 gpio_set_value(MXT_TS_LDO_EN_GPIO, 0);
3246err_ldo_gpio_req:
3247 gpio_free(MXT_TS_LDO_EN_GPIO);
3248err_irq_gpio_req:
3249 gpio_free(MXT_TS_GPIO_IRQ);
3250}
3251
3252static struct mxt_platform_data mxt_platform_data = {
3253 .config = mxt_config_data,
3254 .config_length = ARRAY_SIZE(mxt_config_data),
3255 .x_line = 26,
3256 .y_line = 42,
3257 .x_size = 767,
3258 .y_size = 1365,
3259 .blen = 32,
3260 .threshold = 40,
3261 .voltage = 3300000, /* 3.3V */
3262 .orient = MXT_ROTATED_90,
3263 .irqflags = IRQF_TRIGGER_FALLING,
3264};
3265
3266static struct i2c_board_info mxt_device_info[] __initdata = {
3267 {
3268 I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
3269 .platform_data = &mxt_platform_data,
3270 .irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
3271 },
3272};
3273
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003274static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
3275{
3276}
3277
3278static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi4_pdata = {
3279 .clk_freq = 100000,
3280 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003281 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
3282};
3283
3284static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi3_pdata = {
3285 .clk_freq = 100000,
3286 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003287 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
3288};
3289
3290static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi10_pdata = {
3291 .clk_freq = 100000,
3292 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003293 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
3294};
3295
3296static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi12_pdata = {
3297 .clk_freq = 100000,
3298 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003299 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
3300};
3301
3302static struct msm_rpm_platform_data msm_rpm_data = {
3303 .reg_base_addrs = {
3304 [MSM_RPM_PAGE_STATUS] = MSM_RPM_BASE,
3305 [MSM_RPM_PAGE_CTRL] = MSM_RPM_BASE + 0x400,
3306 [MSM_RPM_PAGE_REQ] = MSM_RPM_BASE + 0x600,
3307 [MSM_RPM_PAGE_ACK] = MSM_RPM_BASE + 0xa00,
3308 },
3309
3310 .irq_ack = RPM_APCC_CPU0_GP_HIGH_IRQ,
3311 .irq_err = RPM_APCC_CPU0_GP_LOW_IRQ,
3312 .irq_vmpm = RPM_APCC_CPU0_GP_MEDIUM_IRQ,
3313 .msm_apps_ipc_rpm_reg = MSM_APCS_GCC_BASE + 0x008,
3314 .msm_apps_ipc_rpm_val = 4,
3315};
3316
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07003317static struct ks8851_pdata spi_eth_pdata = {
3318 .irq_gpio = KS8851_IRQ_GPIO,
3319 .rst_gpio = KS8851_RST_GPIO,
3320};
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06003321
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003322static struct spi_board_info spi_board_info[] __initdata = {
3323 {
3324 .modalias = "ks8851",
3325 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
3326 .max_speed_hz = 19200000,
3327 .bus_num = 0,
3328 .chip_select = 0,
3329 .mode = SPI_MODE_0,
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07003330 .platform_data = &spi_eth_pdata
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003331 },
3332};
3333
3334static struct platform_device msm_device_saw_core0 = {
3335 .name = "saw-regulator",
3336 .id = 0,
3337 .dev = {
3338 .platform_data = &msm_saw_regulator_pdata_s5,
3339 },
3340};
3341
3342static struct platform_device msm_device_saw_core1 = {
3343 .name = "saw-regulator",
3344 .id = 1,
3345 .dev = {
3346 .platform_data = &msm_saw_regulator_pdata_s6,
3347 },
3348};
3349
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07003350static struct tsens_platform_data msm_tsens_pdata = {
3351 .slope = 910,
3352 .tsens_factor = 1000,
3353 .hw_type = MSM_8960,
3354 .tsens_num_sensor = 5,
3355};
3356
3357static struct platform_device msm_tsens_device = {
3358 .name = "tsens8960-tm",
3359 .id = -1,
3360 .dev = {
3361 .platform_data = &msm_tsens_pdata,
3362 },
3363};
3364
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003365#ifdef CONFIG_MSM_FAKE_BATTERY
3366static struct platform_device fish_battery_device = {
3367 .name = "fish_battery",
3368};
3369#endif
3370
David Collins26f05562011-06-20 09:56:28 -07003371static struct platform_device msm8960_device_ext_5v_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003372 .name = GPIO_REGULATOR_DEV_NAME,
3373 .id = PM8921_MPP_PM_TO_SYS(7),
3374 .dev = {
3375 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
3376 },
3377};
3378
David Collins26f05562011-06-20 09:56:28 -07003379static struct platform_device msm8960_device_ext_l2_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003380 .name = GPIO_REGULATOR_DEV_NAME,
3381 .id = 91,
3382 .dev = {
3383 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
3384 },
3385};
3386
David Collinsb10be1d2011-09-02 10:29:31 -07003387static struct platform_device msm8960_device_ext_3p3v_vreg __devinitdata = {
3388 .name = GPIO_REGULATOR_DEV_NAME,
3389 .id = PM8921_GPIO_PM_TO_SYS(17),
3390 .dev = {
3391 .platform_data =
3392 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
3393 },
3394};
3395
David Collins26f05562011-06-20 09:56:28 -07003396static struct platform_device msm8960_device_rpm_regulator __devinitdata = {
3397 .name = "rpm-regulator",
3398 .id = -1,
3399 .dev = {
3400 .platform_data = &msm_rpm_regulator_pdata,
3401 },
3402};
3403
David Collins4c31a872011-08-31 10:07:10 -07003404static struct msm_rpm_log_platform_data msm_rpm_log_pdata = {
3405 .phys_addr_base = 0x0010C000,
3406 .reg_offsets = {
3407 [MSM_RPM_LOG_PAGE_INDICES] = 0x00000080,
3408 [MSM_RPM_LOG_PAGE_BUFFER] = 0x000000A0,
3409 },
3410 .phys_size = SZ_8K,
3411 .log_len = 4096, /* log's buffer length in bytes */
3412 .log_len_mask = (4096 >> 2) - 1, /* length mask in units of u32 */
3413};
3414
3415static struct platform_device msm_rpm_log_device = {
3416 .name = "msm_rpm_log",
3417 .id = -1,
3418 .dev = {
3419 .platform_data = &msm_rpm_log_pdata,
3420 },
3421};
3422
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003423static struct platform_device *common_devices[] __initdata = {
Stepan Moskovchenkodf13d342011-08-03 19:01:25 -07003424 &msm8960_device_dmov,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003425 &msm_device_smd,
3426 &msm8960_device_uart_gsbi5,
Mayank Rana9f51f582011-08-04 18:35:59 +05303427 &msm_device_uart_dm6,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003428 &msm_device_saw_core0,
3429 &msm_device_saw_core1,
3430 &msm8960_device_ext_5v_vreg,
3431 &msm8960_device_ext_l2_vreg,
3432 &msm8960_device_ssbi_pm8921,
3433 &msm8960_device_qup_spi_gsbi1,
3434 &msm8960_device_qup_i2c_gsbi3,
3435 &msm8960_device_qup_i2c_gsbi4,
3436 &msm8960_device_qup_i2c_gsbi10,
3437#ifndef CONFIG_MSM_DSPS
3438 &msm8960_device_qup_i2c_gsbi12,
3439#endif
3440 &msm_slim_ctrl,
3441 &msm_device_wcnss_wlan,
3442#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3443 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
3444 &qcrypto_device,
3445#endif
3446
3447#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3448 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3449 &qcedev_device,
3450#endif
3451#ifdef CONFIG_MSM_ROTATOR
3452 &msm_rotator_device,
3453#endif
3454 &msm_device_sps,
3455#ifdef CONFIG_MSM_FAKE_BATTERY
3456 &fish_battery_device,
3457#endif
3458#ifdef CONFIG_ANDROID_PMEM
3459 &android_pmem_device,
3460 &android_pmem_adsp_device,
3461 &android_pmem_audio_device,
3462#endif
3463 &msm_fb_device,
3464 &msm_device_vidc,
3465 &msm_device_bam_dmux,
3466 &msm_fm_platform_init,
Mona Hossain9c430e32011-07-27 11:04:47 -07003467
3468#ifdef CONFIG_HW_RANDOM_MSM
3469 &msm_device_rng,
3470#endif
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06003471 &msm_rpm_device,
Laura Abbottd6183792011-08-19 13:42:24 -07003472#ifdef CONFIG_ION_MSM
3473 &ion_dev,
3474#endif
David Collins4c31a872011-08-31 10:07:10 -07003475 &msm_rpm_log_device,
Pratik Patel7831c082011-06-08 21:44:37 -07003476#ifdef CONFIG_MSM_QDSS
3477 &msm_etb_device,
3478 &msm_tpiu_device,
3479 &msm_funnel_device,
3480 &msm_ptm_device,
3481#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003482};
3483
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003484static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003485 &msm8960_device_otg,
3486 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003487 &msm_device_hsusb_host,
Vijayavardhan Vennapusaeb566482011-09-18 07:48:37 +05303488 &msm_device_hsic_host,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003489 &android_usb_device,
3490 &msm_device_vidc,
3491 &mipi_dsi_simulator_panel_device,
3492 &msm_bus_apps_fabric,
3493 &msm_bus_sys_fabric,
3494 &msm_bus_mm_fabric,
3495 &msm_bus_sys_fpb,
3496 &msm_bus_cpss_fpb,
3497 &msm_pcm,
3498 &msm_pcm_routing,
3499 &msm_cpudai0,
3500 &msm_cpudai1,
3501 &msm_cpudai_hdmi_rx,
3502 &msm_cpudai_bt_rx,
3503 &msm_cpudai_bt_tx,
3504 &msm_cpudai_fm_rx,
3505 &msm_cpudai_fm_tx,
Bhalchandra Gajare0e795c42011-08-15 18:10:30 -07003506 &msm_cpudai_auxpcm_rx,
3507 &msm_cpudai_auxpcm_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003508 &msm_cpu_fe,
3509 &msm_stub_codec,
3510 &msm_voice,
3511 &msm_voip,
3512 &msm_lpa_pcm,
3513
3514#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3515 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
3516 &qcrypto_device,
3517#endif
3518
3519#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3520 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3521 &qcedev_device,
3522#endif
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003523};
3524
3525static struct platform_device *rumi3_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003526 &msm_kgsl_3d0,
3527 &msm_kgsl_2d0,
3528 &msm_kgsl_2d1,
3529 &mipi_dsi_renesas_panel_device,
3530#ifdef CONFIG_MSM_GEMINI
3531 &msm8960_gemini_device,
3532#endif
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003533};
3534
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003535static struct platform_device *cdp_devices[] __initdata = {
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003536 &msm8960_device_otg,
3537 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003538 &msm_device_hsusb_host,
Vijayavardhan Vennapusaeb566482011-09-18 07:48:37 +05303539 &msm_device_hsic_host,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003540 &android_usb_device,
3541 &msm_pcm,
3542 &msm_pcm_routing,
3543 &msm_cpudai0,
3544 &msm_cpudai1,
3545 &msm_cpudai_hdmi_rx,
3546 &msm_cpudai_bt_rx,
3547 &msm_cpudai_bt_tx,
3548 &msm_cpudai_fm_rx,
3549 &msm_cpudai_fm_tx,
Bhalchandra Gajare0e795c42011-08-15 18:10:30 -07003550 &msm_cpudai_auxpcm_rx,
3551 &msm_cpudai_auxpcm_tx,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003552 &msm_cpu_fe,
3553 &msm_stub_codec,
3554 &msm_kgsl_3d0,
3555#ifdef CONFIG_MSM_KGSL_2D
3556 &msm_kgsl_2d0,
3557 &msm_kgsl_2d1,
3558#endif
Chandan Uddaraju83eac3c2011-09-11 18:32:23 -07003559 &mipi_dsi_novatek_panel_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003560#ifdef CONFIG_MSM_GEMINI
3561 &msm8960_gemini_device,
3562#endif
3563 &msm_voice,
3564 &msm_voip,
3565 &msm_lpa_pcm,
Laxminath Kasamcee1d602011-08-01 19:26:57 +05303566 &msm_cpudai_afe_01_rx,
3567 &msm_cpudai_afe_01_tx,
3568 &msm_cpudai_afe_02_rx,
3569 &msm_cpudai_afe_02_tx,
3570 &msm_pcm_afe,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003571#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3572 &hdmi_msm_device,
3573#endif
3574 &msm_pcm_hostless,
3575 &msm_bus_apps_fabric,
3576 &msm_bus_sys_fabric,
3577 &msm_bus_mm_fabric,
3578 &msm_bus_sys_fpb,
3579 &msm_bus_cpss_fpb,
Siddartha Mohanadossba21fdd2011-08-18 10:05:27 -07003580 &msm_tsens_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003581};
3582
3583static void __init msm8960_i2c_init(void)
3584{
3585 msm8960_device_qup_i2c_gsbi4.dev.platform_data =
3586 &msm8960_i2c_qup_gsbi4_pdata;
3587
3588 msm8960_device_qup_i2c_gsbi3.dev.platform_data =
3589 &msm8960_i2c_qup_gsbi3_pdata;
3590
3591 msm8960_device_qup_i2c_gsbi10.dev.platform_data =
3592 &msm8960_i2c_qup_gsbi10_pdata;
3593
3594 msm8960_device_qup_i2c_gsbi12.dev.platform_data =
3595 &msm8960_i2c_qup_gsbi12_pdata;
3596}
3597
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003598static void __init msm8960_gfx_init(void)
3599{
3600 uint32_t soc_platform_version = socinfo_get_platform_version();
3601 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1) {
3602 struct kgsl_device_platform_data *kgsl_3d0_pdata =
3603 msm_kgsl_3d0.dev.platform_data;
3604 kgsl_3d0_pdata->pwr_data.pwrlevel[0].gpu_freq =
3605 320000000;
3606 kgsl_3d0_pdata->pwr_data.pwrlevel[1].gpu_freq =
3607 266667000;
3608 }
3609}
3610
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003611static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
3612 .irq_base = PM8921_IRQ_BASE,
3613 .devirq = MSM_GPIO_TO_INT(104),
3614 .irq_trigger_flag = IRQF_TRIGGER_LOW,
3615};
3616
3617static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
3618 .gpio_base = PM8921_GPIO_PM_TO_SYS(1),
3619};
3620
3621static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
3622 .mpp_base = PM8921_MPP_PM_TO_SYS(1),
3623};
3624
3625static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
3626 .rtc_write_enable = false,
3627};
3628
3629static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
3630 .pull_up = 1,
3631 .kpd_trigger_delay_us = 970,
3632 .wakeup = 1,
3633};
3634
Mohan Pallaka002e9e02011-08-05 11:23:22 +05303635/* Rotate lock key is not available so use F1 */
3636#define KEY_ROTATE_LOCK KEY_F1
3637
3638static const unsigned int keymap_liquid[] = {
3639 KEY(0, 0, KEY_VOLUMEUP),
3640 KEY(0, 1, KEY_VOLUMEDOWN),
3641 KEY(1, 3, KEY_ROTATE_LOCK),
3642 KEY(1, 4, KEY_HOME),
3643};
3644
3645static struct matrix_keymap_data keymap_data_liquid = {
3646 .keymap_size = ARRAY_SIZE(keymap_liquid),
3647 .keymap = keymap_liquid,
3648};
3649
3650static struct pm8xxx_keypad_platform_data keypad_data_liquid = {
3651 .input_name = "keypad_8960_liquid",
3652 .input_phys_device = "keypad_8960/input0",
3653 .num_rows = 2,
3654 .num_cols = 5,
3655 .rows_gpio_start = PM8921_GPIO_PM_TO_SYS(9),
3656 .cols_gpio_start = PM8921_GPIO_PM_TO_SYS(1),
3657 .debounce_ms = 15,
3658 .scan_delay_ms = 32,
3659 .row_hold_ns = 91500,
3660 .wakeup = 1,
3661 .keymap_data = &keymap_data_liquid,
3662};
3663
3664
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003665static const unsigned int keymap[] = {
3666 KEY(0, 0, KEY_VOLUMEUP),
3667 KEY(0, 1, KEY_VOLUMEDOWN),
3668 KEY(0, 2, KEY_CAMERA_SNAPSHOT),
3669 KEY(0, 3, KEY_CAMERA_FOCUS),
3670};
3671
3672static struct matrix_keymap_data keymap_data = {
3673 .keymap_size = ARRAY_SIZE(keymap),
3674 .keymap = keymap,
3675};
3676
3677static struct pm8xxx_keypad_platform_data keypad_data = {
3678 .input_name = "keypad_8960",
3679 .input_phys_device = "keypad_8960/input0",
3680 .num_rows = 1,
3681 .num_cols = 5,
3682 .rows_gpio_start = PM8921_GPIO_PM_TO_SYS(9),
3683 .cols_gpio_start = PM8921_GPIO_PM_TO_SYS(1),
3684 .debounce_ms = 15,
3685 .scan_delay_ms = 32,
3686 .row_hold_ns = 91500,
3687 .wakeup = 1,
3688 .keymap_data = &keymap_data,
3689};
3690
3691static const unsigned int keymap_sim[] = {
3692 KEY(0, 0, KEY_7),
3693 KEY(0, 1, KEY_DOWN),
3694 KEY(0, 2, KEY_UP),
3695 KEY(0, 3, KEY_RIGHT),
3696 KEY(0, 4, KEY_ENTER),
3697 KEY(0, 5, KEY_L),
3698 KEY(0, 6, KEY_BACK),
3699 KEY(0, 7, KEY_M),
3700
3701 KEY(1, 0, KEY_LEFT),
3702 KEY(1, 1, KEY_SEND),
3703 KEY(1, 2, KEY_1),
3704 KEY(1, 3, KEY_4),
3705 KEY(1, 4, KEY_CLEAR),
3706 KEY(1, 5, KEY_MSDOS),
3707 KEY(1, 6, KEY_SPACE),
3708 KEY(1, 7, KEY_COMMA),
3709
3710 KEY(2, 0, KEY_6),
3711 KEY(2, 1, KEY_5),
3712 KEY(2, 2, KEY_8),
3713 KEY(2, 3, KEY_3),
3714 KEY(2, 4, KEY_NUMERIC_STAR),
3715 KEY(2, 5, KEY_UP),
3716 KEY(2, 6, KEY_DOWN),
3717 KEY(2, 7, KEY_LEFTSHIFT),
3718
3719 KEY(3, 0, KEY_9),
3720 KEY(3, 1, KEY_NUMERIC_POUND),
3721 KEY(3, 2, KEY_0),
3722 KEY(3, 3, KEY_2),
3723 KEY(3, 4, KEY_SLEEP),
3724 KEY(3, 5, KEY_F1),
3725 KEY(3, 6, KEY_F2),
3726 KEY(3, 7, KEY_F3),
3727
3728 KEY(4, 0, KEY_BACK),
3729 KEY(4, 1, KEY_HOME),
3730 KEY(4, 2, KEY_MENU),
3731 KEY(4, 3, KEY_VOLUMEUP),
3732 KEY(4, 4, KEY_VOLUMEDOWN),
3733 KEY(4, 5, KEY_F4),
3734 KEY(4, 6, KEY_F5),
3735 KEY(4, 7, KEY_F6),
3736
3737 KEY(5, 0, KEY_R),
3738 KEY(5, 1, KEY_T),
3739 KEY(5, 2, KEY_Y),
3740 KEY(5, 3, KEY_LEFTALT),
3741 KEY(5, 4, KEY_KPENTER),
3742 KEY(5, 5, KEY_Q),
3743 KEY(5, 6, KEY_W),
3744 KEY(5, 7, KEY_E),
3745
3746 KEY(6, 0, KEY_F),
3747 KEY(6, 1, KEY_G),
3748 KEY(6, 2, KEY_H),
3749 KEY(6, 3, KEY_CAPSLOCK),
3750 KEY(6, 4, KEY_PAGEUP),
3751 KEY(6, 5, KEY_A),
3752 KEY(6, 6, KEY_S),
3753 KEY(6, 7, KEY_D),
3754
3755 KEY(7, 0, KEY_V),
3756 KEY(7, 1, KEY_B),
3757 KEY(7, 2, KEY_N),
3758 KEY(7, 3, KEY_MENU),
3759 KEY(7, 4, KEY_PAGEDOWN),
3760 KEY(7, 5, KEY_Z),
3761 KEY(7, 6, KEY_X),
3762 KEY(7, 7, KEY_C),
3763
3764 KEY(8, 0, KEY_P),
3765 KEY(8, 1, KEY_J),
3766 KEY(8, 2, KEY_K),
3767 KEY(8, 3, KEY_INSERT),
3768 KEY(8, 4, KEY_LINEFEED),
3769 KEY(8, 5, KEY_U),
3770 KEY(8, 6, KEY_I),
3771 KEY(8, 7, KEY_O),
3772
3773 KEY(9, 0, KEY_4),
3774 KEY(9, 1, KEY_5),
3775 KEY(9, 2, KEY_6),
3776 KEY(9, 3, KEY_7),
3777 KEY(9, 4, KEY_8),
3778 KEY(9, 5, KEY_1),
3779 KEY(9, 6, KEY_2),
3780 KEY(9, 7, KEY_3),
3781
3782 KEY(10, 0, KEY_F7),
3783 KEY(10, 1, KEY_F8),
3784 KEY(10, 2, KEY_F9),
3785 KEY(10, 3, KEY_F10),
3786 KEY(10, 4, KEY_FN),
3787 KEY(10, 5, KEY_9),
3788 KEY(10, 6, KEY_0),
3789 KEY(10, 7, KEY_DOT),
3790
3791 KEY(11, 0, KEY_LEFTCTRL),
3792 KEY(11, 1, KEY_F11),
3793 KEY(11, 2, KEY_ENTER),
3794 KEY(11, 3, KEY_SEARCH),
3795 KEY(11, 4, KEY_DELETE),
3796 KEY(11, 5, KEY_RIGHT),
3797 KEY(11, 6, KEY_LEFT),
3798 KEY(11, 7, KEY_RIGHTSHIFT),
3799 KEY(0, 0, KEY_VOLUMEUP),
3800 KEY(0, 1, KEY_VOLUMEDOWN),
3801 KEY(0, 2, KEY_CAMERA_SNAPSHOT),
3802 KEY(0, 3, KEY_CAMERA_FOCUS),
3803};
3804
3805static struct matrix_keymap_data keymap_data_sim = {
3806 .keymap_size = ARRAY_SIZE(keymap_sim),
3807 .keymap = keymap_sim,
3808};
3809
3810static struct pm8xxx_keypad_platform_data keypad_data_sim = {
3811 .input_name = "keypad_8960",
3812 .input_phys_device = "keypad_8960/input0",
3813 .num_rows = 12,
3814 .num_cols = 8,
3815 .rows_gpio_start = PM8921_GPIO_PM_TO_SYS(9),
3816 .cols_gpio_start = PM8921_GPIO_PM_TO_SYS(1),
3817 .debounce_ms = 15,
3818 .scan_delay_ms = 32,
3819 .row_hold_ns = 91500,
3820 .wakeup = 1,
3821 .keymap_data = &keymap_data_sim,
3822};
3823
Abhijeet Dharmapurikarad742362011-08-29 19:50:02 -07003824static int pm8921_therm_mitigation[] = {
3825 1100,
3826 700,
3827 600,
3828 325,
3829};
3830
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003831static struct pm8921_charger_platform_data pm8921_chg_pdata __devinitdata = {
Abhijeet Dharmapurikar34059332011-08-16 19:19:39 -07003832 .safety_time = 180,
Abhijeet Dharmapurikar33fe6fb2011-09-14 16:03:11 -07003833 .update_time = 60000,
Abhijeet Dharmapurikar34059332011-08-16 19:19:39 -07003834 .max_voltage = 4200,
3835 .min_voltage = 3200,
3836 .resume_voltage = 4100,
3837 .term_current = 100,
3838 .cool_temp = 10,
3839 .warm_temp = 40,
3840 .temp_check_period = 1,
Abhijeet Dharmapurikarad742362011-08-29 19:50:02 -07003841 .max_bat_chg_current = 1100,
Abhijeet Dharmapurikar34059332011-08-16 19:19:39 -07003842 .cool_bat_chg_current = 350,
3843 .warm_bat_chg_current = 350,
3844 .cool_bat_voltage = 4100,
3845 .warm_bat_voltage = 4100,
Abhijeet Dharmapurikarad742362011-08-29 19:50:02 -07003846 .thermal_mitigation = pm8921_therm_mitigation,
3847 .thermal_levels = ARRAY_SIZE(pm8921_therm_mitigation),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003848};
3849
3850static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
3851 .priority = 0,
3852};
3853
3854static struct pm8921_bms_platform_data pm8921_bms_pdata __devinitdata = {
3855 .r_sense = 10,
3856 .i_test = 2500,
3857 .v_failure = 3000,
3858 .calib_delay_ms = 600000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003859};
3860
Jay Chokshide4cefb2011-08-04 18:10:44 -07003861#define PM8921_LC_LED_MAX_CURRENT 4 /* I = 4mA */
3862
3863/**
3864 * 'flag' stores three values; led id, led mode, and max current of led.
3865 * The bit packing format is as follow,
3866 * reserved (1 byte) | max_current (2 bytes) | led_mode (1 nibble) |
3867 * led_id (1 nibble)
3868 */
3869#define PM8XXX_SET_FLAG(led_id, led_mode, led_max_current) \
3870 (((led_id << PM8XXX_LED_ID_SHIFT) & PM8XXX_LED_ID_MASK) |\
3871 ((led_mode << PM8XXX_LED_MODE_SHIFT) & PM8XXX_LED_MODE_MASK) |\
3872 ((led_max_current << PM8XXX_LED_MAX_CURRENT_SHIFT) & \
3873 PM8XXX_LED_MAX_CURRENT_MASK))
3874
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003875static struct led_info pm8921_led_info[] = {
3876 [0] = {
Jay Chokshide4cefb2011-08-04 18:10:44 -07003877 .name = "led:usb",
3878 .default_trigger = "usb-online",
3879 .flags = PM8XXX_SET_FLAG(PM8XXX_ID_LED_0,
3880 PM8XXX_LED_MODE_MANUAL,
3881 PM8921_LC_LED_MAX_CURRENT),
3882 },
3883 [1] = {
3884 .name = "led:ac",
3885 .default_trigger = "ac-online",
3886 .flags = PM8XXX_SET_FLAG(PM8XXX_ID_LED_1,
3887 PM8XXX_LED_MODE_MANUAL,
3888 PM8921_LC_LED_MAX_CURRENT),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003889 },
3890};
3891
3892static struct led_platform_data pm8xxx_leds_pdata = {
3893 .num_leds = ARRAY_SIZE(pm8921_led_info),
3894 .leds = pm8921_led_info,
3895};
3896
3897static struct pm8921_platform_data pm8921_platform_data __devinitdata = {
3898 .irq_pdata = &pm8xxx_irq_pdata,
3899 .gpio_pdata = &pm8xxx_gpio_pdata,
3900 .mpp_pdata = &pm8xxx_mpp_pdata,
3901 .rtc_pdata = &pm8xxx_rtc_pdata,
3902 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
3903 .keypad_pdata = &keypad_data,
3904 .misc_pdata = &pm8xxx_misc_pdata,
3905 .regulator_pdatas = msm_pm8921_regulator_pdata,
3906 .charger_pdata = &pm8921_chg_pdata,
3907 .bms_pdata = &pm8921_bms_pdata,
3908 .adc_pdata = &pm8921_adc_pdata,
3909 .leds_pdata = &pm8xxx_leds_pdata,
3910};
3911
3912static struct msm_ssbi_platform_data msm8960_ssbi_pm8921_pdata __devinitdata = {
3913 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
3914 .slave = {
3915 .name = "pm8921-core",
3916 .platform_data = &pm8921_platform_data,
3917 },
3918};
3919
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07003920#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
3921static int fpga_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003922{
3923 int ret;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003924
3925 ret = gpio_request(FPGA_CS_GPIO, "fpga_cs");
3926 if (ret) {
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07003927 pr_err("FPGA CS gpio_request failed: %d\n", ret);
3928 goto fail;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003929 }
3930
3931 gpio_direction_output(FPGA_CS_GPIO, 1);
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07003932
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003933 return 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003934fail:
3935 return ret;
3936}
Stepan Moskovchenko41d168272011-08-09 17:09:42 -07003937#else
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07003938static int fpga_init(void)
Stepan Moskovchenko41d168272011-08-09 17:09:42 -07003939{
3940 return 0;
3941}
3942#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003943
3944static struct msm_cpuidle_state msm_cstates[] __initdata = {
3945 {0, 0, "C0", "WFI",
3946 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
3947
3948 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
3949 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
3950
3951 {0, 2, "C2", "POWER_COLLAPSE",
3952 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
3953
3954 {1, 0, "C0", "WFI",
3955 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
3956
3957 {1, 1, "C1", "STANDALONE_POWER_COLLAPSE",
3958 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
3959};
3960
3961static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
3962 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
3963 .idle_supported = 1,
3964 .suspend_supported = 1,
3965 .idle_enabled = 0,
3966 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003967 },
3968
3969 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
3970 .idle_supported = 1,
3971 .suspend_supported = 1,
3972 .idle_enabled = 0,
3973 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003974 },
3975
3976 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
3977 .idle_supported = 1,
3978 .suspend_supported = 1,
3979 .idle_enabled = 1,
3980 .suspend_enabled = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003981 },
3982
3983 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
3984 .idle_supported = 0,
3985 .suspend_supported = 1,
3986 .idle_enabled = 0,
3987 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003988 },
3989
3990 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
3991 .idle_supported = 1,
3992 .suspend_supported = 1,
3993 .idle_enabled = 0,
3994 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003995 },
3996
3997 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
3998 .idle_supported = 1,
3999 .suspend_supported = 0,
4000 .idle_enabled = 1,
4001 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004002 },
4003};
4004
4005static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
4006 {
4007 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
4008 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
4009 true,
4010 1, 8000, 100000, 1,
4011 },
4012
4013 {
4014 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
4015 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
4016 true,
4017 1500, 5000, 60100000, 3000,
4018 },
4019
4020 {
4021 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
4022 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
4023 false,
4024 1800, 5000, 60350000, 3500,
4025 },
4026
4027 {
4028 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
4029 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
4030 false,
4031 2800, 2500, 65350000, 4800,
4032 },
4033
4034 {
4035 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
4036 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
4037 false,
4038 3800, 4500, 67850000, 5500,
4039 },
4040
4041 {
4042 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
4043 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
4044 false,
4045 4800, 2000, 71850000, 6800,
4046 },
4047
4048 {
4049 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
4050 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
4051 false,
4052 6800, 500, 75850000, 8800,
4053 },
4054
4055 {
4056 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
4057 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
4058 false,
4059 7800, 0, 76350000, 9800,
4060 },
4061};
4062
4063#ifdef CONFIG_I2C
4064#define I2C_SURF 1
4065#define I2C_FFA (1 << 1)
4066#define I2C_RUMI (1 << 2)
4067#define I2C_SIM (1 << 3)
4068#define I2C_FLUID (1 << 4)
Amir Samuelov05f87802011-08-27 18:30:12 +03004069#define I2C_LIQUID (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004070
4071struct i2c_registry {
4072 u8 machs;
4073 int bus;
4074 struct i2c_board_info *info;
4075 int len;
4076};
4077
4078#ifdef CONFIG_MSM_CAMERA
4079static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
4080#ifdef CONFIG_IMX074
4081 {
4082 I2C_BOARD_INFO("imx074", 0x1A),
4083 },
4084#endif
4085#ifdef CONFIG_OV2720
4086 {
4087 I2C_BOARD_INFO("ov2720", 0x6C),
4088 },
4089#endif
Kevin Chandfecce22011-07-13 10:52:41 -07004090 {
4091 I2C_BOARD_INFO("qs_mt9p017", 0x6C >> 1),
4092 },
Nishant Pandit474f2252011-07-23 23:17:56 +05304093#ifdef CONFIG_MSM_CAMERA_FLASH_SC628A
4094 {
4095 I2C_BOARD_INFO("sc628a", 0x6E),
4096 },
4097#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004098};
4099#endif
4100
4101/* Sensors DSPS platform data */
4102#ifdef CONFIG_MSM_DSPS
4103#define DSPS_PIL_GENERIC_NAME "dsps"
4104#endif /* CONFIG_MSM_DSPS */
4105
4106static void __init msm8960_init_dsps(void)
4107{
4108#ifdef CONFIG_MSM_DSPS
4109 struct msm_dsps_platform_data *pdata =
4110 msm_dsps_device.dev.platform_data;
4111 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
4112 pdata->gpios = NULL;
4113 pdata->gpios_num = 0;
4114
4115 platform_device_register(&msm_dsps_device);
4116#endif /* CONFIG_MSM_DSPS */
4117}
4118
Amir Samuelov5137e392011-09-21 17:31:25 +03004119#ifdef CONFIG_ISL9519_CHARGER
4120static struct isl_platform_data isl_data __initdata = {
4121 .valid_n_gpio = 0, /* Not required when notify-by-pmic */
4122 .chg_detection_config = NULL, /* Not required when notify-by-pmic */
4123 .max_system_voltage = 4200,
4124 .min_system_voltage = 3200,
4125 .chgcurrent = 1000, /* 1900, */
4126 .term_current = 400, /* Need fine tuning */
4127 .input_current = 2048,
4128};
4129
4130static struct i2c_board_info isl_charger_i2c_info[] __initdata = {
4131 {
4132 I2C_BOARD_INFO("isl9519q", 0x9),
4133 .irq = 0, /* Not required when notify-by-pmic */
4134 .platform_data = &isl_data,
4135 },
4136};
4137#endif /* CONFIG_ISL9519_CHARGER */
4138
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004139static struct i2c_registry msm8960_i2c_devices[] __initdata = {
4140#ifdef CONFIG_MSM_CAMERA
4141 {
Amir Samuelov05f87802011-08-27 18:30:12 +03004142 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_LIQUID | I2C_RUMI,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004143 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
4144 msm_camera_boardinfo,
4145 ARRAY_SIZE(msm_camera_boardinfo),
4146 },
4147#endif
Amir Samuelov5137e392011-09-21 17:31:25 +03004148#ifdef CONFIG_ISL9519_CHARGER
4149 {
4150 I2C_LIQUID,
4151 MSM_8960_GSBI10_QUP_I2C_BUS_ID,
4152 isl_charger_i2c_info,
4153 ARRAY_SIZE(isl_charger_i2c_info),
4154 },
4155#endif /* CONFIG_ISL9519_CHARGER */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004156 {
4157 I2C_SURF | I2C_FFA | I2C_FLUID,
4158 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
4159 cyttsp_info,
4160 ARRAY_SIZE(cyttsp_info),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -07004161 },
Mohan Pallaka50837382011-09-07 11:00:57 +05304162 {
4163 I2C_LIQUID,
4164 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
4165 mxt_device_info,
4166 ARRAY_SIZE(mxt_device_info),
4167 },
4168
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004169};
4170#endif /* CONFIG_I2C */
4171
4172static void __init register_i2c_devices(void)
4173{
4174#ifdef CONFIG_I2C
4175 u8 mach_mask = 0;
4176 int i;
4177
4178 /* Build the matching 'supported_machs' bitmask */
4179 if (machine_is_msm8960_cdp())
4180 mach_mask = I2C_SURF;
4181 else if (machine_is_msm8960_rumi3())
4182 mach_mask = I2C_RUMI;
4183 else if (machine_is_msm8960_sim())
4184 mach_mask = I2C_SIM;
Amy Maloche2d028032011-07-20 14:08:06 -07004185 else if (machine_is_msm8960_fluid())
4186 mach_mask = I2C_FLUID;
Amir Samuelov05f87802011-08-27 18:30:12 +03004187 else if (machine_is_msm8960_liquid())
4188 mach_mask = I2C_LIQUID;
Amy Maloche1b0663f2011-08-02 16:46:22 -07004189 else if (machine_is_msm8960_mtp())
4190 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004191 else
4192 pr_err("unmatched machine ID in register_i2c_devices\n");
4193
4194 /* Run the array and install devices as appropriate */
4195 for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
4196 if (msm8960_i2c_devices[i].machs & mach_mask)
4197 i2c_register_board_info(msm8960_i2c_devices[i].bus,
4198 msm8960_i2c_devices[i].info,
4199 msm8960_i2c_devices[i].len);
4200 }
4201#endif
4202}
4203
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08004204static void __init msm8960_sim_init(void)
4205{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004206 BUG_ON(msm_rpm_init(&msm_rpm_data));
4207 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
4208 ARRAY_SIZE(msm_rpmrs_levels)));
4209 regulator_suppress_info_printing();
David Collins26f05562011-06-20 09:56:28 -07004210 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07004211 msm_clock_init(&msm8960_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004212 msm8960_device_ssbi_pm8921.dev.platform_data =
4213 &msm8960_ssbi_pm8921_pdata;
4214 pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004215
4216 /* Simulator supports a QWERTY keypad */
4217 pm8921_platform_data.keypad_pdata = &keypad_data_sim;
4218
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07004219 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
4220 msm8960_device_gadget_peripheral.dev.parent = &msm8960_device_otg.dev;
4221 msm_device_hsusb_host.dev.parent = &msm8960_device_otg.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004222 gpiomux_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004223 msm8960_i2c_init();
4224 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
4225 msm_spm_l2_init(msm_spm_l2_data);
4226 msm8960_init_buses();
4227 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
4228 pm8921_gpio_mpp_init();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08004229 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
Matt Wagantallec57f062011-08-16 23:54:46 -07004230 acpuclk_init(&acpuclk_8960_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004231
4232 msm8960_device_qup_spi_gsbi1.dev.platform_data =
4233 &msm8960_qup_spi_gsbi1_pdata;
4234 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
4235
4236 msm8960_init_mmc();
4237 msm_fb_add_devices();
4238 slim_register_board_info(msm_slim_devices,
4239 ARRAY_SIZE(msm_slim_devices));
4240 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
4241 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
4242 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
4243 msm_pm_data);
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08004244}
4245
4246static void __init msm8960_rumi3_init(void)
4247{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004248 BUG_ON(msm_rpm_init(&msm_rpm_data));
4249 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
4250 ARRAY_SIZE(msm_rpmrs_levels)));
4251 regulator_suppress_info_printing();
David Collins26f05562011-06-20 09:56:28 -07004252 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07004253 msm_clock_init(&msm8960_dummy_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004254 gpiomux_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004255 msm8960_device_ssbi_pm8921.dev.platform_data =
4256 &msm8960_ssbi_pm8921_pdata;
4257 pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len;
4258 msm8960_device_qup_spi_gsbi1.dev.platform_data =
4259 &msm8960_qup_spi_gsbi1_pdata;
4260 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
4261 msm8960_i2c_init();
4262 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
4263 msm_spm_l2_init(msm_spm_l2_data);
4264 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
4265 pm8921_gpio_mpp_init();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08004266 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004267 msm8960_init_mmc();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004268 register_i2c_devices();
4269 msm_fb_add_devices();
4270 slim_register_board_info(msm_slim_devices,
4271 ARRAY_SIZE(msm_slim_devices));
4272 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
4273 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
4274 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
4275 msm_pm_data);
4276}
4277
4278static void __init msm8960_cdp_init(void)
4279{
Naveen Ramaraj76483ad2011-09-06 14:25:44 -07004280 if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
4281 pr_err("meminfo_init() failed!\n");
4282
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004283 BUG_ON(msm_rpm_init(&msm_rpm_data));
4284 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
4285 ARRAY_SIZE(msm_rpmrs_levels)));
Abhijeet Dharmapurikar6d565fd2011-09-15 18:49:56 -07004286
4287 pmic_reset_irq = PM8921_IRQ_BASE + PM8921_RESOUT_IRQ;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004288 regulator_suppress_info_printing();
4289 if (msm_xo_init())
4290 pr_err("Failed to initialize XO votes\n");
David Collins26f05562011-06-20 09:56:28 -07004291 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07004292 msm_clock_init(&msm8960_clock_init_data);
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07004293 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
4294 msm8960_device_gadget_peripheral.dev.parent = &msm8960_device_otg.dev;
4295 msm_device_hsusb_host.dev.parent = &msm8960_device_otg.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004296 gpiomux_init();
Stepan Moskovchenko93d79ec2011-09-21 16:52:16 -07004297 if (machine_is_msm8960_cdp())
4298 fpga_init();
Mohan Pallaka002e9e02011-08-05 11:23:22 +05304299 if (machine_is_msm8960_liquid())
4300 pm8921_platform_data.keypad_pdata = &keypad_data_liquid;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004301 msm8960_device_qup_spi_gsbi1.dev.platform_data =
4302 &msm8960_qup_spi_gsbi1_pdata;
4303 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
4304 msm8960_device_ssbi_pm8921.dev.platform_data =
4305 &msm8960_ssbi_pm8921_pdata;
4306 pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len;
4307 msm8960_i2c_init();
Lucille Sylvester34ec3692011-08-16 16:28:04 -06004308 msm8960_gfx_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004309 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
4310 msm_spm_l2_init(msm_spm_l2_data);
4311 msm8960_init_buses();
4312 platform_add_devices(msm_footswitch_devices,
4313 msm_num_footswitch_devices);
David Collinsb10be1d2011-09-02 10:29:31 -07004314 if (machine_is_msm8960_liquid())
4315 platform_device_register(&msm8960_device_ext_3p3v_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004316 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
4317 pm8921_gpio_mpp_init();
4318 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
4319 msm8960_init_cam();
4320 msm8960_init_mmc();
Matt Wagantallec57f062011-08-16 23:54:46 -07004321 acpuclk_init(&acpuclk_8960_soc_data);
Mohan Pallaka50837382011-09-07 11:00:57 +05304322 if (machine_is_msm8960_liquid())
4323 mxt_init_hw_liquid();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004324 register_i2c_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004325 msm_fb_add_devices();
4326 slim_register_board_info(msm_slim_devices,
4327 ARRAY_SIZE(msm_slim_devices));
4328 msm8960_init_dsps();
4329 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
4330 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
4331 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
4332 msm_pm_data);
Larry Bassela7eadea2011-07-14 10:46:00 -07004333 change_memory_power = &msm8960_change_memory_power;
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08004334}
4335
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08004336MACHINE_START(MSM8960_SIM, "QCT MSM8960 SIMULATOR")
4337 .map_io = msm8960_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004338 .reserve = msm8960_reserve,
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08004339 .init_irq = msm8960_init_irq,
4340 .timer = &msm_timer,
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08004341 .init_machine = msm8960_sim_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004342 .init_early = msm8960_allocate_memory_regions,
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08004343MACHINE_END
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08004344
4345MACHINE_START(MSM8960_RUMI3, "QCT MSM8960 RUMI3")
4346 .map_io = msm8960_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004347 .reserve = msm8960_reserve,
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08004348 .init_irq = msm8960_init_irq,
4349 .timer = &msm_timer,
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08004350 .init_machine = msm8960_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004351 .init_early = msm8960_allocate_memory_regions,
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08004352MACHINE_END
4353
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07004354MACHINE_START(MSM8960_CDP, "QCT MSM8960 CDP")
4355 .map_io = msm8960_map_io,
4356 .reserve = msm8960_reserve,
4357 .init_irq = msm8960_init_irq,
4358 .timer = &msm_timer,
4359 .init_machine = msm8960_cdp_init,
4360 .init_early = msm8960_allocate_memory_regions,
4361MACHINE_END
4362
4363MACHINE_START(MSM8960_MTP, "QCT MSM8960 MTP")
4364 .map_io = msm8960_map_io,
4365 .reserve = msm8960_reserve,
4366 .init_irq = msm8960_init_irq,
4367 .timer = &msm_timer,
4368 .init_machine = msm8960_cdp_init,
4369 .init_early = msm8960_allocate_memory_regions,
4370MACHINE_END
4371
4372MACHINE_START(MSM8960_FLUID, "QCT MSM8960 FLUID")
4373 .map_io = msm8960_map_io,
4374 .reserve = msm8960_reserve,
4375 .init_irq = msm8960_init_irq,
4376 .timer = &msm_timer,
4377 .init_machine = msm8960_cdp_init,
4378 .init_early = msm8960_allocate_memory_regions,
4379MACHINE_END
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03004380
4381MACHINE_START(MSM8960_LIQUID, "QCT MSM8960 LIQUID")
4382 .map_io = msm8960_map_io,
4383 .reserve = msm8960_reserve,
4384 .init_irq = msm8960_init_irq,
4385 .timer = &msm_timer,
4386 .init_machine = msm8960_cdp_init,
4387 .init_early = msm8960_allocate_memory_regions,
4388MACHINE_END