blob: b9fe340fe8620a3f3e049f8e5fbd522e11ee1845 [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>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070019#include <linux/gpio.h>
20#include <linux/msm_ssbi.h>
21#include <linux/regulator/gpio-regulator.h>
22#include <linux/mfd/pm8xxx/pm8921.h>
23#include <linux/regulator/consumer.h>
24#include <linux/spi/spi.h>
25#include <linux/slimbus/slimbus.h>
26#include <linux/bootmem.h>
Lucille Sylvester34ec3692011-08-16 16:28:04 -060027#include <linux/msm_kgsl.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070028#ifdef CONFIG_ANDROID_PMEM
29#include <linux/android_pmem.h>
30#endif
31#include <linux/cyttsp.h>
32#include <linux/dma-mapping.h>
33#include <linux/platform_data/qcom_crypto_device.h>
Ankur Nandwanib0039b02011-08-09 14:00:45 -070034#include <linux/platform_data/qcom_wcnss_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070035#include <linux/leds.h>
36#include <linux/leds-pm8xxx.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080037
38#include <asm/mach-types.h>
39#include <asm/mach/arch.h>
Larry Basselb4126da2011-07-18 14:31:33 -070040#include <asm/setup.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080041#include <asm/hardware/gic.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070042#include <asm/mach/mmc.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080043
44#include <mach/board.h>
45#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046#include <mach/msm_spi.h>
47#ifdef CONFIG_USB_MSM_OTG_72K
48#include <mach/msm_hsusb.h>
49#else
50#include <linux/usb/msm_hsusb.h>
51#endif
52#include <linux/usb/android.h>
53#include <mach/usbdiag.h>
54#include <mach/socinfo.h>
55#include <mach/rpm.h>
56#include <mach/gpio.h>
Rohit Vaswania513aa8d2011-07-18 15:14:28 -070057#include <mach/gpiomux.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070058#include <mach/msm_bus_board.h>
59#include <mach/msm_memtypes.h>
60#include <mach/dma.h>
61#include <mach/msm_dsps.h>
62#include <mach/msm_xo.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080063
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070064#ifdef CONFIG_WCD9310_CODEC
65#include <linux/slimbus/slimbus.h>
66#include <linux/mfd/wcd9310/core.h>
67#include <linux/mfd/wcd9310/pdata.h>
68#endif
69
Laura Abbottd6183792011-08-19 13:42:24 -070070#include <linux/ion.h>
71#include <mach/ion.h>
72
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070073#include "timer.h"
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -080074#include "devices.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070075#include "devices-msm8x60.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076#include "spm.h"
77#include "board-msm8960.h"
78#include "pm.h"
79#include "cpuidle.h"
80#include "rpm_resources.h"
81#include "mpm.h"
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070082#include "acpuclock.h"
David Collins4c31a872011-08-31 10:07:10 -070083#include "rpm_log.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070084
85static struct platform_device msm_fm_platform_init = {
86 .name = "iris_fm",
87 .id = -1,
88};
89
90struct pm8xxx_gpio_init {
91 unsigned gpio;
92 struct pm_gpio config;
93};
94
95struct pm8xxx_mpp_init {
96 unsigned mpp;
97 struct pm8xxx_mpp_config_data config;
98};
99
100#define PM8XXX_GPIO_INIT(_gpio, _dir, _buf, _val, _pull, _vin, _out_strength, \
101 _func, _inv, _disable) \
102{ \
103 .gpio = PM8921_GPIO_PM_TO_SYS(_gpio), \
104 .config = { \
105 .direction = _dir, \
106 .output_buffer = _buf, \
107 .output_value = _val, \
108 .pull = _pull, \
109 .vin_sel = _vin, \
110 .out_strength = _out_strength, \
111 .function = _func, \
112 .inv_int_pol = _inv, \
113 .disable_pin = _disable, \
114 } \
115}
116
117#define PM8XXX_MPP_INIT(_mpp, _type, _level, _control) \
118{ \
119 .mpp = PM8921_MPP_PM_TO_SYS(_mpp), \
120 .config = { \
121 .type = PM8XXX_MPP_TYPE_##_type, \
122 .level = _level, \
123 .control = PM8XXX_MPP_##_control, \
124 } \
125}
126
127#define PM8XXX_GPIO_DISABLE(_gpio) \
128 PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, 0, 0, 0, PM_GPIO_VIN_S4, \
129 0, 0, 0, 1)
130
131#define PM8XXX_GPIO_OUTPUT(_gpio, _val) \
132 PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
133 PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \
134 PM_GPIO_STRENGTH_HIGH, \
135 PM_GPIO_FUNC_NORMAL, 0, 0)
136
137#define PM8XXX_GPIO_INPUT(_gpio, _pull) \
138 PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, PM_GPIO_OUT_BUF_CMOS, 0, \
139 _pull, PM_GPIO_VIN_S4, \
140 PM_GPIO_STRENGTH_NO, \
141 PM_GPIO_FUNC_NORMAL, 0, 0)
142
143#define PM8XXX_GPIO_OUTPUT_FUNC(_gpio, _val, _func) \
144 PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
145 PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \
146 PM_GPIO_STRENGTH_HIGH, \
147 _func, 0, 0)
148
149/* Initial PM8921 GPIO configurations */
150static struct pm8xxx_gpio_init pm8921_gpios[] __initdata = {
151 PM8XXX_GPIO_DISABLE(6), /* Disable unused */
152 PM8XXX_GPIO_DISABLE(7), /* Disable NFC */
153 PM8XXX_GPIO_INPUT(16, PM_GPIO_PULL_UP_30), /* SD_CARD_WP */
Amir Samuelov0c7270f2011-09-07 03:13:47 +0300154 /* External regulator shared by display and touchscreen on LiQUID */
155 PM8XXX_GPIO_OUTPUT(17, 0), /* DISP 3.3 V Boost */
156 PM8XXX_GPIO_OUTPUT(21, 1), /* Backlight Enable */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700157 PM8XXX_GPIO_DISABLE(22), /* Disable NFC */
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -0700158 PM8XXX_GPIO_OUTPUT_FUNC(24, 0, PM_GPIO_FUNC_2), /* Bl: Off, PWM mode */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700159 PM8XXX_GPIO_INPUT(26, PM_GPIO_PULL_UP_30), /* SD_CARD_DET_N */
160 PM8XXX_GPIO_OUTPUT(43, 0), /* DISP_RESET_N */
161};
162
163/* Initial PM8921 MPP configurations */
164static struct pm8xxx_mpp_init pm8921_mpps[] __initdata = {
165 /* External 5V regulator enable; shared by HDMI and USB_OTG switches. */
166 PM8XXX_MPP_INIT(7, D_INPUT, PM8921_MPP_DIG_LEVEL_VPH, DIN_TO_INT),
167 PM8XXX_MPP_INIT(PM8921_AMUX_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
168 DOUT_CTRL_LOW),
169 PM8XXX_MPP_INIT(PM8921_AMUX_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
170 DOUT_CTRL_LOW),
171};
172
173static void __init pm8921_gpio_mpp_init(void)
174{
175 int i, rc;
176
177 for (i = 0; i < ARRAY_SIZE(pm8921_gpios); i++) {
178 rc = pm8xxx_gpio_config(pm8921_gpios[i].gpio,
179 &pm8921_gpios[i].config);
180 if (rc) {
181 pr_err("%s: pm8xxx_gpio_config: rc=%d\n", __func__, rc);
182 break;
183 }
184 }
185
186 for (i = 0; i < ARRAY_SIZE(pm8921_mpps); i++) {
187 rc = pm8xxx_mpp_config(pm8921_mpps[i].mpp,
188 &pm8921_mpps[i].config);
189 if (rc) {
190 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
191 break;
192 }
193 }
194}
195
196#define FPGA_CS_GPIO 14
197#define KS8851_RST_GPIO 89
198#define KS8851_IRQ_GPIO 90
199
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700200#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
201enum {
Abhijeet Dharmapurikar0fda5602011-08-17 18:00:55 -0700202 GPIO_EXPANDER_IRQ_BASE = (PM8921_IRQ_BASE + PM8921_NR_IRQS),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700203 GPIO_EXPANDER_GPIO_BASE = (PM8921_MPP_BASE + PM8921_NR_MPPS),
204 /* CAM Expander */
205 GPIO_CAM_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE,
206 GPIO_CAM_GP_STROBE_READY = GPIO_CAM_EXPANDER_BASE,
207 GPIO_CAM_GP_AFBUSY,
208 GPIO_CAM_GP_STROBE_CE,
209 GPIO_CAM_GP_CAM1MP_XCLR,
210 GPIO_CAM_GP_CAMIF_RESET_N,
211 GPIO_CAM_GP_XMT_FLASH_INT,
212 GPIO_CAM_GP_LED_EN1,
213 GPIO_CAM_GP_LED_EN2,
214
215};
216#endif
217
Harini Jayaraman608d0462011-08-09 19:10:03 -0600218/* The SPI configurations apply to GSBI 1*/
219static struct gpiomux_setting spi_active = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700220 .func = GPIOMUX_FUNC_1,
221 .drv = GPIOMUX_DRV_8MA,
222 .pull = GPIOMUX_PULL_NONE,
223};
224
Harini Jayaraman608d0462011-08-09 19:10:03 -0600225static struct gpiomux_setting spi_suspended_config = {
226 .func = GPIOMUX_FUNC_GPIO,
227 .drv = GPIOMUX_DRV_2MA,
228 .pull = GPIOMUX_PULL_DOWN,
229};
230
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700231static struct gpiomux_setting gsbi3 = {
232 .func = GPIOMUX_FUNC_1,
233 .drv = GPIOMUX_DRV_8MA,
234 .pull = GPIOMUX_PULL_NONE,
235};
236
237static struct gpiomux_setting gsbi4 = {
238 .func = GPIOMUX_FUNC_1,
239 .drv = GPIOMUX_DRV_8MA,
240 .pull = GPIOMUX_PULL_NONE,
241};
242
243static struct gpiomux_setting gsbi5 = {
244 .func = GPIOMUX_FUNC_1,
245 .drv = GPIOMUX_DRV_8MA,
246 .pull = GPIOMUX_PULL_NONE,
247};
248
249static struct gpiomux_setting gsbi10 = {
250 .func = GPIOMUX_FUNC_2,
251 .drv = GPIOMUX_DRV_8MA,
252 .pull = GPIOMUX_PULL_NONE,
253};
254
255static struct gpiomux_setting gsbi12 = {
256 .func = GPIOMUX_FUNC_1,
257 .drv = GPIOMUX_DRV_8MA,
258 .pull = GPIOMUX_PULL_NONE,
259};
260
261static struct gpiomux_setting cdc_mclk = {
262 .func = GPIOMUX_FUNC_1,
263 .drv = GPIOMUX_DRV_8MA,
264 .pull = GPIOMUX_PULL_NONE,
265};
266
Stepan Moskovchenko41d168272011-08-09 17:09:42 -0700267#ifdef CONFIG_KS8851
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700268static struct gpiomux_setting gpio_eth_config = {
269 .pull = GPIOMUX_PULL_NONE,
270 .drv = GPIOMUX_DRV_8MA,
271 .func = GPIOMUX_FUNC_GPIO,
272};
Stepan Moskovchenko41d168272011-08-09 17:09:42 -0700273#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700274
275static struct gpiomux_setting slimbus = {
276 .func = GPIOMUX_FUNC_1,
277 .drv = GPIOMUX_DRV_8MA,
278 .pull = GPIOMUX_PULL_KEEPER,
279};
280
281struct msm_gpiomux_config msm8960_gpiomux_configs[NR_GPIO_IRQS] = {
Stepan Moskovchenko41d168272011-08-09 17:09:42 -0700282#ifdef CONFIG_KS8851
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700283 {
284 .gpio = KS8851_IRQ_GPIO,
285 .settings = {
286 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
287 }
288 },
289 {
290 .gpio = KS8851_RST_GPIO,
291 .settings = {
292 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
293 }
294 },
295 {
296 .gpio = FPGA_CS_GPIO,
297 .settings = {
298 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
299 }
300 },
Stepan Moskovchenko41d168272011-08-09 17:09:42 -0700301#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700302};
303
304static struct msm_gpiomux_config msm8960_gsbi_configs[] __initdata = {
305 {
306 .gpio = 6, /* GSBI1 QUP SPI_DATA_MOSI */
307 .settings = {
Harini Jayaraman608d0462011-08-09 19:10:03 -0600308 [GPIOMUX_SUSPENDED] = &spi_suspended_config,
309 [GPIOMUX_ACTIVE] = &spi_active,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700310 },
311 },
312 {
313 .gpio = 7, /* GSBI1 QUP SPI_DATA_MISO */
314 .settings = {
Harini Jayaraman608d0462011-08-09 19:10:03 -0600315 [GPIOMUX_SUSPENDED] = &spi_suspended_config,
316 [GPIOMUX_ACTIVE] = &spi_active,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700317 },
318 },
319 {
320 .gpio = 8, /* GSBI1 QUP SPI_CS_N */
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 = 9, /* GSBI1 QUP SPI_CLK */
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 = 16, /* GSBI3 I2C QUP SDA */
335 .settings = {
336 [GPIOMUX_SUSPENDED] = &gsbi3,
337 },
338 },
339 {
340 .gpio = 17, /* GSBI3 I2C QUP SCL */
341 .settings = {
342 [GPIOMUX_SUSPENDED] = &gsbi3,
343 },
344 },
345 {
346 .gpio = 20, /* GSBI4 I2C QUP SDA */
347 .settings = {
348 [GPIOMUX_SUSPENDED] = &gsbi4,
349 },
350 },
351 {
352 .gpio = 21, /* GSBI4 I2C QUP SCL */
353 .settings = {
354 [GPIOMUX_SUSPENDED] = &gsbi4,
355 },
356 },
357 {
358 .gpio = 22, /* GSBI5 UART2 */
359 .settings = {
360 [GPIOMUX_SUSPENDED] = &gsbi5,
361 },
362 },
363 {
364 .gpio = 23, /* GSBI5 UART2 */
365 .settings = {
366 [GPIOMUX_SUSPENDED] = &gsbi5,
367 },
368 },
369 {
370 .gpio = 24, /* GSBI5 UART2 */
371 .settings = {
372 [GPIOMUX_SUSPENDED] = &gsbi5,
373 },
374 },
375 {
376 .gpio = 25, /* GSBI5 UART2 */
377 .settings = {
378 [GPIOMUX_SUSPENDED] = &gsbi5,
379 },
380 },
381 {
382 .gpio = 44, /* GSBI12 I2C QUP SDA */
383 .settings = {
384 [GPIOMUX_SUSPENDED] = &gsbi12,
385 },
386 },
387 {
388 .gpio = 45, /* GSBI12 I2C QUP SCL */
389 .settings = {
390 [GPIOMUX_SUSPENDED] = &gsbi12,
391 },
392 },
393 {
394 .gpio = 73, /* GSBI10 I2C QUP SDA */
395 .settings = {
396 [GPIOMUX_SUSPENDED] = &gsbi10,
397 },
398 },
399 {
400 .gpio = 74, /* GSBI10 I2C QUP SCL */
401 .settings = {
402 [GPIOMUX_SUSPENDED] = &gsbi10,
403 },
404 },
405};
406
407static struct msm_gpiomux_config msm8960_slimbus_config[] __initdata = {
408 {
409 .gpio = 60, /* slimbus data */
410 .settings = {
411 [GPIOMUX_SUSPENDED] = &slimbus,
412 },
413 },
414 {
415 .gpio = 61, /* slimbus clk */
416 .settings = {
417 [GPIOMUX_SUSPENDED] = &slimbus,
418 },
419 },
420};
421
422static struct msm_gpiomux_config msm8960_audio_codec_configs[] __initdata = {
423 {
424 .gpio = 59,
425 .settings = {
426 [GPIOMUX_SUSPENDED] = &cdc_mclk,
427 },
428 },
429};
430static struct gpiomux_setting wcnss_5wire_suspend_cfg = {
431 .func = GPIOMUX_FUNC_GPIO,
432 .drv = GPIOMUX_DRV_2MA,
433 .pull = GPIOMUX_PULL_NONE,
434};
435
436static struct gpiomux_setting wcnss_5wire_active_cfg = {
437 .func = GPIOMUX_FUNC_1,
438 .drv = GPIOMUX_DRV_6MA,
439 .pull = GPIOMUX_PULL_DOWN,
440};
441
442static struct msm_gpiomux_config wcnss_5wire_interface[] = {
443 {
444 .gpio = 84,
445 .settings = {
446 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
447 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
448 },
449 },
450 {
451 .gpio = 85,
452 .settings = {
453 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
454 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
455 },
456 },
457 {
458 .gpio = 86,
459 .settings = {
460 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
461 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
462 },
463 },
464 {
465 .gpio = 87,
466 .settings = {
467 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
468 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
469 },
470 },
471 {
472 .gpio = 88,
473 .settings = {
474 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
475 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
476 },
477 },
478};
Nishant Pandit24153d82011-08-27 16:05:13 +0530479static struct gpiomux_setting cam_settings[] = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530480 {
481 .func = GPIOMUX_FUNC_GPIO, /*suspend*/
482 .drv = GPIOMUX_DRV_2MA,
483 .pull = GPIOMUX_PULL_DOWN,
484 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700485
Nishant Pandit474f2252011-07-23 23:17:56 +0530486 {
487 .func = GPIOMUX_FUNC_1, /*active 1*/
488 .drv = GPIOMUX_DRV_2MA,
489 .pull = GPIOMUX_PULL_NONE,
490 },
491
492 {
493 .func = GPIOMUX_FUNC_GPIO, /*active 2*/
494 .drv = GPIOMUX_DRV_2MA,
495 .pull = GPIOMUX_PULL_NONE,
496 },
497
498 {
499 .func = GPIOMUX_FUNC_1, /*active 3*/
500 .drv = GPIOMUX_DRV_8MA,
501 .pull = GPIOMUX_PULL_UP,
502 },
Nishant Pandit24153d82011-08-27 16:05:13 +0530503
504 {
505 .func = GPIOMUX_FUNC_5, /*active 4*/
506 .drv = GPIOMUX_DRV_8MA,
507 .pull = GPIOMUX_PULL_UP,
508 },
509
510 {
511 .func = GPIOMUX_FUNC_6, /*active 5*/
512 .drv = GPIOMUX_DRV_8MA,
513 .pull = GPIOMUX_PULL_UP,
514 },
515
516 {
517 .func = GPIOMUX_FUNC_2, /*active 6*/
518 .drv = GPIOMUX_DRV_2MA,
519 .pull = GPIOMUX_PULL_UP,
520 },
521
522 {
523 .func = GPIOMUX_FUNC_3, /*active 7*/
524 .drv = GPIOMUX_DRV_8MA,
525 .pull = GPIOMUX_PULL_UP,
526 },
527
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700528};
529
Nishant Pandit24153d82011-08-27 16:05:13 +0530530static struct msm_gpiomux_config msm8960_cam_common_configs[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700531 {
532 .gpio = 2,
533 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530534 [GPIOMUX_ACTIVE] = &cam_settings[2],
535 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700536 },
537 },
538 {
539 .gpio = 3,
540 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530541 [GPIOMUX_ACTIVE] = &cam_settings[1],
542 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700543 },
544 },
545 {
546 .gpio = 4,
547 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530548 [GPIOMUX_ACTIVE] = &cam_settings[1],
549 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700550 },
551 },
552 {
553 .gpio = 5,
554 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530555 [GPIOMUX_ACTIVE] = &cam_settings[1],
556 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700557 },
558 },
559 {
Nishant Pandit24153d82011-08-27 16:05:13 +0530560 .gpio = 76,
561 .settings = {
562 [GPIOMUX_ACTIVE] = &cam_settings[2],
563 [GPIOMUX_SUSPENDED] = &cam_settings[0],
564 },
565 },
566 {
567 .gpio = 107,
568 .settings = {
569 [GPIOMUX_ACTIVE] = &cam_settings[2],
570 [GPIOMUX_SUSPENDED] = &cam_settings[0],
571 },
572 },
573};
574
575static struct msm_gpiomux_config msm8960_cam_2d_configs[] = {
576 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700577 .gpio = 18,
578 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530579 [GPIOMUX_ACTIVE] = &cam_settings[3],
580 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700581 },
582 },
583 {
584 .gpio = 19,
585 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530586 [GPIOMUX_ACTIVE] = &cam_settings[3],
587 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700588 },
589 },
590 {
591 .gpio = 20,
592 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530593 [GPIOMUX_ACTIVE] = &cam_settings[3],
594 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700595 },
596 },
597 {
598 .gpio = 21,
599 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530600 [GPIOMUX_ACTIVE] = &cam_settings[3],
601 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700602 },
603 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700604};
605
606static struct gpiomux_setting cyts_resout_sus_cfg = {
607 .func = GPIOMUX_FUNC_GPIO,
608 .drv = GPIOMUX_DRV_6MA,
609 .pull = GPIOMUX_PULL_UP,
610};
611
612static struct gpiomux_setting cyts_resout_act_cfg = {
613 .func = GPIOMUX_FUNC_GPIO,
614 .drv = GPIOMUX_DRV_6MA,
615 .pull = GPIOMUX_PULL_UP,
616};
617
618static struct gpiomux_setting cyts_sleep_sus_cfg = {
619 .func = GPIOMUX_FUNC_GPIO,
620 .drv = GPIOMUX_DRV_6MA,
621 .pull = GPIOMUX_PULL_DOWN,
622};
623
624static struct gpiomux_setting cyts_sleep_act_cfg = {
625 .func = GPIOMUX_FUNC_GPIO,
626 .drv = GPIOMUX_DRV_6MA,
627 .pull = GPIOMUX_PULL_DOWN,
628};
629
630static struct gpiomux_setting cyts_int_act_cfg = {
631 .func = GPIOMUX_FUNC_GPIO,
632 .drv = GPIOMUX_DRV_8MA,
633 .pull = GPIOMUX_PULL_UP,
634};
635
636static struct gpiomux_setting cyts_int_sus_cfg = {
637 .func = GPIOMUX_FUNC_GPIO,
638 .drv = GPIOMUX_DRV_2MA,
639 .pull = GPIOMUX_PULL_UP,
640};
641
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700642static struct msm_gpiomux_config msm8960_cyts_configs[] __initdata = {
643 { /* TS INTERRUPT */
644 .gpio = 11,
645 .settings = {
646 [GPIOMUX_ACTIVE] = &cyts_int_act_cfg,
647 [GPIOMUX_SUSPENDED] = &cyts_int_sus_cfg,
648 },
649 },
650 { /* TS SLEEP */
651 .gpio = 50,
652 .settings = {
653 [GPIOMUX_ACTIVE] = &cyts_sleep_act_cfg,
654 [GPIOMUX_SUSPENDED] = &cyts_sleep_sus_cfg,
655 },
656 },
657 { /* TS RESOUT */
658 .gpio = 52,
659 .settings = {
660 [GPIOMUX_ACTIVE] = &cyts_resout_act_cfg,
661 [GPIOMUX_SUSPENDED] = &cyts_resout_sus_cfg,
662 },
663 },
664};
665
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700666#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
667enum {
668 SX150X_CAM,
669};
670
Nishant Pandit474f2252011-07-23 23:17:56 +0530671static struct sx150x_platform_data sx150x_data[] = {
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700672 [SX150X_CAM] = {
673 .gpio_base = GPIO_CAM_EXPANDER_BASE,
674 .oscio_is_gpo = false,
675 .io_pullup_ena = 0x0,
Nishant Pandit474f2252011-07-23 23:17:56 +0530676 .io_pulldn_ena = 0xc0,
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700677 .io_open_drain_ena = 0x0,
678 .irq_summary = -1,
679 },
680};
Nishant Pandit474f2252011-07-23 23:17:56 +0530681
682#endif
683
684#ifdef CONFIG_I2C
685
686#define MSM_8960_GSBI4_QUP_I2C_BUS_ID 4
687#define MSM_8960_GSBI3_QUP_I2C_BUS_ID 3
688
689#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
690
691static struct i2c_board_info cam_expander_i2c_info[] = {
692 {
693 I2C_BOARD_INFO("sx1508q", 0x22),
694 .platform_data = &sx150x_data[SX150X_CAM]
695 },
696};
697
698static struct msm_cam_expander_info cam_expander_info[] = {
699 {
700 cam_expander_i2c_info,
701 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
702 },
703};
704#endif
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700705#endif
706
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700707#define MSM_PMEM_KERNEL_EBI1_SIZE 0x110C000
708#define MSM_PMEM_ADSP_SIZE 0x3800000
Ben Romberger09e462d2011-08-09 15:24:37 -0700709#define MSM_PMEM_AUDIO_SIZE 0x28B000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700710#define MSM_PMEM_SIZE 0x1800000 /* 24 Mbytes */
711
Laura Abbottd6183792011-08-19 13:42:24 -0700712#define MSM_ION_EBI_SIZE SZ_8M
713
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700714#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
715static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
716static int __init pmem_kernel_ebi1_size_setup(char *p)
717{
718 pmem_kernel_ebi1_size = memparse(p, NULL);
719 return 0;
720}
721early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
722#endif
723
724#ifdef CONFIG_ANDROID_PMEM
725static unsigned pmem_size = MSM_PMEM_SIZE;
726static int __init pmem_size_setup(char *p)
727{
728 pmem_size = memparse(p, NULL);
729 return 0;
730}
731early_param("pmem_size", pmem_size_setup);
732
733static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
734
735static int __init pmem_adsp_size_setup(char *p)
736{
737 pmem_adsp_size = memparse(p, NULL);
738 return 0;
739}
740early_param("pmem_adsp_size", pmem_adsp_size_setup);
741
742static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
743
744static int __init pmem_audio_size_setup(char *p)
745{
746 pmem_audio_size = memparse(p, NULL);
747 return 0;
748}
749early_param("pmem_audio_size", pmem_audio_size_setup);
750#endif
751
752#ifdef CONFIG_ANDROID_PMEM
753static struct android_pmem_platform_data android_pmem_pdata = {
754 .name = "pmem",
755 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
756 .cached = 1,
757 .memory_type = MEMTYPE_EBI1,
758};
759
760static struct platform_device android_pmem_device = {
761 .name = "android_pmem",
762 .id = 0,
763 .dev = {.platform_data = &android_pmem_pdata},
764};
765
766static struct android_pmem_platform_data android_pmem_adsp_pdata = {
767 .name = "pmem_adsp",
768 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
769 .cached = 0,
770 .memory_type = MEMTYPE_EBI1,
771};
772static struct platform_device android_pmem_adsp_device = {
773 .name = "android_pmem",
774 .id = 2,
775 .dev = { .platform_data = &android_pmem_adsp_pdata },
776};
777
778static struct android_pmem_platform_data android_pmem_audio_pdata = {
779 .name = "pmem_audio",
780 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
781 .cached = 0,
782 .memory_type = MEMTYPE_EBI1,
783};
784
785static struct platform_device android_pmem_audio_device = {
786 .name = "android_pmem",
787 .id = 4,
788 .dev = { .platform_data = &android_pmem_audio_pdata },
789};
790#endif
791
792static struct memtype_reserve msm8960_reserve_table[] __initdata = {
793 [MEMTYPE_SMI] = {
794 },
795 [MEMTYPE_EBI0] = {
796 .flags = MEMTYPE_FLAGS_1M_ALIGN,
797 },
798 [MEMTYPE_EBI1] = {
799 .flags = MEMTYPE_FLAGS_1M_ALIGN,
800 },
801};
802
803static void __init size_pmem_devices(void)
804{
805#ifdef CONFIG_ANDROID_PMEM
806 android_pmem_adsp_pdata.size = pmem_adsp_size;
807 android_pmem_pdata.size = pmem_size;
808 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
809#endif
810}
811
812static void __init reserve_memory_for(struct android_pmem_platform_data *p)
813{
814 msm8960_reserve_table[p->memory_type].size += p->size;
815}
816
817static void __init reserve_pmem_memory(void)
818{
819#ifdef CONFIG_ANDROID_PMEM
820 reserve_memory_for(&android_pmem_adsp_pdata);
821 reserve_memory_for(&android_pmem_pdata);
822 reserve_memory_for(&android_pmem_audio_pdata);
823 msm8960_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
824#endif
825}
826
Larry Basselb4126da2011-07-18 14:31:33 -0700827static int msm8960_paddr_to_memtype(unsigned int paddr)
828{
829 return MEMTYPE_EBI1;
830}
831
Laura Abbottd6183792011-08-19 13:42:24 -0700832#ifdef CONFIG_ION_MSM
833struct ion_platform_data ion_pdata = {
834 .nr = 3,
835 .heaps = {
836 {
837 .id = ION_HEAP_SYSTEM_ID,
838 .type = ION_HEAP_TYPE_SYSTEM,
839 .name = ION_KMALLOC_HEAP_NAME,
840 },
841 {
842 .id = ION_HEAP_SYSTEM_CONTIG_ID,
843 .type = ION_HEAP_TYPE_SYSTEM_CONTIG,
844 .name = ION_VMALLOC_HEAP_NAME,
845 },
846 {
847 .id = ION_HEAP_EBI_ID,
848 .type = ION_HEAP_TYPE_CARVEOUT,
849 .name = ION_EBI1_HEAP_NAME,
850 .size = MSM_ION_EBI_SIZE,
851 .memory_type = ION_EBI_TYPE,
852 },
853 }
854};
855
856struct platform_device ion_dev = {
857 .name = "ion-msm",
858 .id = 1,
859 .dev = { .platform_data = &ion_pdata },
860};
861#endif
862
863static void reserve_ion_memory(void)
864{
865#ifdef CONFIG_ION_MSM
866 msm8960_reserve_table[MEMTYPE_EBI1].size += MSM_ION_EBI_SIZE;
867#endif
868}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700869static void __init msm8960_calculate_reserve_sizes(void)
870{
871 size_pmem_devices();
872 reserve_pmem_memory();
Laura Abbottd6183792011-08-19 13:42:24 -0700873 reserve_ion_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700874}
875
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700876static struct reserve_info msm8960_reserve_info __initdata = {
877 .memtype_reserve_table = msm8960_reserve_table,
878 .calculate_reserve_sizes = msm8960_calculate_reserve_sizes,
879 .paddr_to_memtype = msm8960_paddr_to_memtype,
880};
881
Larry Basselb4126da2011-07-18 14:31:33 -0700882static int msm8960_memory_bank_size(void)
883{
884 return 1<<29;
885}
886
887static void __init locate_unstable_memory(void)
888{
889 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
890 unsigned long bank_size;
891 unsigned long low, high;
892
893 bank_size = msm8960_memory_bank_size();
894 low = meminfo.bank[0].start;
895 high = mb->start + mb->size;
896 low &= ~(bank_size - 1);
897
898 if (high - low <= bank_size)
899 return;
900 msm8960_reserve_info.low_unstable_address = low + bank_size;
901 msm8960_reserve_info.max_unstable_size = high - low - bank_size;
902 msm8960_reserve_info.bank_size = bank_size;
903 pr_info("low unstable address %lx max size %lx bank size %lx\n",
904 msm8960_reserve_info.low_unstable_address,
905 msm8960_reserve_info.max_unstable_size,
906 msm8960_reserve_info.bank_size);
907}
908
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700909static void __init msm8960_reserve(void)
910{
911 reserve_info = &msm8960_reserve_info;
Larry Basselb4126da2011-07-18 14:31:33 -0700912 locate_unstable_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700913 msm_reserve();
914}
915
Larry Bassela4414b12011-08-04 11:11:02 -0700916static int msm8960_change_memory_power(u64 start, u64 size,
917 int change_type)
Larry Bassela7eadea2011-07-14 10:46:00 -0700918{
Larry Bassela4414b12011-08-04 11:11:02 -0700919 return size;
Larry Bassela7eadea2011-07-14 10:46:00 -0700920}
921
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700922#ifdef CONFIG_MSM_CAMERA
923
Nishant Pandit24153d82011-08-27 16:05:13 +0530924static uint16_t msm_cam_gpio_2d_tbl[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700925 5, /*CAMIF_MCLK*/
926 20, /*CAMIF_I2C_DATA*/
927 21, /*CAMIF_I2C_CLK*/
928};
929
Nishant Pandit24153d82011-08-27 16:05:13 +0530930static struct msm_camera_gpio_conf gpio_conf = {
931 .cam_gpiomux_conf_tbl = msm8960_cam_2d_configs,
932 .cam_gpiomux_conf_tbl_size = ARRAY_SIZE(msm8960_cam_2d_configs),
933 .cam_gpio_tbl = msm_cam_gpio_2d_tbl,
934 .cam_gpio_tbl_size = ARRAY_SIZE(msm_cam_gpio_2d_tbl),
935};
936
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700937#define VFE_CAMIF_TIMER1_GPIO 2
938#define VFE_CAMIF_TIMER2_GPIO 3
939#define VFE_CAMIF_TIMER3_GPIO_INT 4
940struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
941 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
942 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
943 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
944 .flash_recharge_duration = 50000,
945 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
946};
947
Nishant Pandit474f2252011-07-23 23:17:56 +0530948#ifdef CONFIG_MSM_CAMERA_FLASH
949static struct msm_camera_sensor_flash_src msm_flash_src = {
950 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
951 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
952 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
953#if defined(CONFIG_I2C) && (defined(CONFIG_GPIO_SX150X) || \
954 defined(CONFIG_GPIO_SX150X_MODULE))
955 ._fsrc.ext_driver_src.expander_info = cam_expander_info,
956#endif
957};
958#endif
959
Nishant Pandit24153d82011-08-27 16:05:13 +0530960struct msm_camera_device_platform_data msm_camera_csi_device_data[] = {
961 {
962 .ioclk.mclk_clk_rate = 24000000,
963 .ioclk.vfe_clk_rate = 228570000,
964 .csid_core = 0,
965 },
966 {
967 .ioclk.mclk_clk_rate = 24000000,
968 .ioclk.vfe_clk_rate = 228570000,
969 .csid_core = 1,
970 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700971};
972
973#ifdef CONFIG_IMX074
974static struct msm_camera_sensor_flash_data flash_imx074 = {
975 .flash_type = MSM_CAMERA_FLASH_LED,
Nishant Pandit474f2252011-07-23 23:17:56 +0530976#ifdef CONFIG_MSM_CAMERA_FLASH
977 .flash_src = &msm_flash_src
978#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700979};
980
Nishant Pandit24153d82011-08-27 16:05:13 +0530981static struct msm_camera_sensor_platform_info sensor_board_info_imx074 = {
982 .mount_angle = 90,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700983 .sensor_reset = 107,
984 .sensor_pwd = 85,
985 .vcm_pwd = 0,
986 .vcm_enable = 1,
Nishant Pandit24153d82011-08-27 16:05:13 +0530987};
988
989static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
990 .sensor_name = "imx074",
991 .pdata = &msm_camera_csi_device_data[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700992 .flash_data = &flash_imx074,
993 .strobe_flash_data = &strobe_flash_xenon,
Nishant Pandit24153d82011-08-27 16:05:13 +0530994 .sensor_platform_info = &sensor_board_info_imx074,
995 .gpio_conf = &gpio_conf,
996 .csi_if = 1,
997 .camera_type = BACK_CAMERA_2D,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700998};
999
1000struct platform_device msm8960_camera_sensor_imx074 = {
1001 .name = "msm_camera_imx074",
1002 .dev = {
1003 .platform_data = &msm_camera_sensor_imx074_data,
1004 },
1005};
1006#endif
1007#ifdef CONFIG_OV2720
1008static struct msm_camera_sensor_flash_data flash_ov2720 = {
Kevin Chan1a990332011-07-26 20:31:23 -07001009 .flash_type = MSM_CAMERA_FLASH_NONE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001010};
1011
Nishant Pandit24153d82011-08-27 16:05:13 +05301012static struct msm_camera_sensor_platform_info sensor_board_info_ov2720 = {
1013 .mount_angle = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001014 .sensor_reset = 76,
1015 .sensor_pwd = 85,
1016 .vcm_pwd = 0,
1017 .vcm_enable = 1,
Nishant Pandit24153d82011-08-27 16:05:13 +05301018};
1019
1020static struct msm_camera_sensor_info msm_camera_sensor_ov2720_data = {
1021 .sensor_name = "ov2720",
1022 .pdata = &msm_camera_csi_device_data[1],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001023 .flash_data = &flash_ov2720,
Nishant Pandit24153d82011-08-27 16:05:13 +05301024 .sensor_platform_info = &sensor_board_info_ov2720,
1025 .gpio_conf = &gpio_conf,
1026 .csi_if = 1,
1027 .camera_type = FRONT_CAMERA_2D,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001028};
1029
1030struct platform_device msm8960_camera_sensor_ov2720 = {
1031 .name = "msm_camera_ov2720",
1032 .dev = {
1033 .platform_data = &msm_camera_sensor_ov2720_data,
1034 },
1035};
1036#endif
Kevin Chandfecce22011-07-13 10:52:41 -07001037
1038static struct msm_camera_sensor_flash_data flash_qs_mt9p017 = {
1039 .flash_type = MSM_CAMERA_FLASH_LED,
1040};
1041
Nishant Pandit24153d82011-08-27 16:05:13 +05301042static struct msm_camera_sensor_platform_info sensor_board_info_qs_mt9p017 = {
1043 .mount_angle = 270,
Kevin Chandfecce22011-07-13 10:52:41 -07001044 .sensor_reset = 107,
1045 .sensor_pwd = 85,
1046 .vcm_pwd = 0,
1047 .vcm_enable = 1,
Nishant Pandit24153d82011-08-27 16:05:13 +05301048};
1049
1050static struct msm_camera_sensor_info msm_camera_sensor_qs_mt9p017_data = {
1051 .sensor_name = "qs_mt9p017",
1052 .pdata = &msm_camera_csi_device_data[0],
Kevin Chandfecce22011-07-13 10:52:41 -07001053 .flash_data = &flash_qs_mt9p017,
Nishant Pandit24153d82011-08-27 16:05:13 +05301054 .sensor_platform_info = &sensor_board_info_qs_mt9p017,
1055 .gpio_conf = &gpio_conf,
1056 .csi_if = 1,
1057 .camera_type = BACK_CAMERA_3D,
Kevin Chandfecce22011-07-13 10:52:41 -07001058};
1059
1060struct platform_device msm8960_camera_sensor_qs_mt9p017 = {
1061 .name = "msm_camera_qs_mt9p017",
1062 .dev = {
1063 .platform_data = &msm_camera_sensor_qs_mt9p017_data,
1064 },
1065};
1066
Kevin Chan8b0d2322011-09-10 21:06:31 -07001067static struct msm8960_privacy_light_cfg privacy_light_info = {
1068 .mpp = PM8921_MPP_PM_TO_SYS(12),
1069};
1070
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001071static void __init msm8960_init_cam(void)
1072{
1073 int i;
1074 struct platform_device *cam_dev[] = {
1075 &msm8960_camera_sensor_imx074,
1076 &msm8960_camera_sensor_ov2720,
Kevin Chandfecce22011-07-13 10:52:41 -07001077 &msm8960_camera_sensor_qs_mt9p017,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001078 };
1079
Kevin Chan8b0d2322011-09-10 21:06:31 -07001080 if (machine_is_msm8960_liquid()) {
1081 struct msm_camera_sensor_info *s_info;
1082 s_info = msm8960_camera_sensor_imx074.dev.platform_data;
1083 s_info->sensor_platform_info->mount_angle = 180;
1084 s_info = msm8960_camera_sensor_ov2720.dev.platform_data;
1085 s_info->sensor_platform_info->privacy_light = 1;
1086 s_info->sensor_platform_info->privacy_light_info =
1087 &privacy_light_info;
1088 }
1089
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001090 for (i = 0; i < ARRAY_SIZE(cam_dev); i++) {
1091 struct msm_camera_sensor_info *s_info;
1092 s_info = cam_dev[i]->dev.platform_data;
1093 msm_get_cam_resources(s_info);
1094 platform_device_register(cam_dev[i]);
1095 }
1096}
1097#endif
1098
1099#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001100/* prim = 1366 x 768 x 3(bpp) x 3(pages) */
1101#define MSM_FB_PRIM_BUF_SIZE roundup(1366 * 768 * 3 * 3, 0x10000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001102#else
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001103/* prim = 1366 x 768 x 3(bpp) x 2(pages) */
1104#define MSM_FB_PRIM_BUF_SIZE roundup(1366 * 768 * 3 * 2, 0x10000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001105#endif
1106
1107#ifdef CONFIG_FB_MSM_MIPI_DSI
Nagamalleswararao Ganji0b8dbd02011-08-18 20:46:59 -07001108#define MIPI_DSI_WRITEBACK_SIZE (1024 * 600 * 3 * 2)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001109#else
1110#define MIPI_DSI_WRITEBACK_SIZE 0
1111#endif
1112
1113#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1114/* hdmi = 1920 x 1088 x 2(bpp) x 1(page) */
1115#define MSM_FB_EXT_BUF_SIZE 0x3FC000
1116#elif defined(CONFIG_FB_MSM_TVOUT)
1117/* tvout = 720 x 576 x 2(bpp) x 2(pages) */
1118#define MSM_FB_EXT_BUF_SIZE 0x195000
1119#else /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1120#define MSM_FB_EXT_BUF_SIZE 0
1121#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1122
1123#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE +\
1124 MIPI_DSI_WRITEBACK_SIZE, 4096)
1125
1126#define MDP_VSYNC_GPIO 0
1127
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001128#define TOSHIBA_PANEL_NAME "mipi_video_toshiba_wsvga"
1129#define TOSHIBA_PANEL_NAME_LEN 24
1130#define CHIMEI_PANEL_NAME "mipi_chimei_wxga"
1131#define CHIMEI_PANEL_NAME_LEN 16
1132
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001133static struct resource msm_fb_resources[] = {
1134 {
1135 .flags = IORESOURCE_DMA,
1136 }
1137};
1138
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001139#ifdef CONFIG_FB_MSM_MIPI_PANEL_DETECT
1140static int msm_fb_detect_panel(const char *name)
1141{
1142 if (machine_is_msm8960_liquid()) {
1143 if (!strncmp(name, CHIMEI_PANEL_NAME, CHIMEI_PANEL_NAME_LEN))
1144 return 0;
1145 } else {
1146 if (!strncmp(name, TOSHIBA_PANEL_NAME, TOSHIBA_PANEL_NAME_LEN))
1147 return 0;
1148 }
1149
1150 pr_warning("%s: not supported '%s'", __func__, name);
1151
1152 return -ENODEV;
1153}
1154
1155static struct msm_fb_platform_data msm_fb_pdata = {
1156 .detect_client = msm_fb_detect_panel,
1157};
1158#endif /* CONFIG_FB_MSM_MIPI_PANEL_DETECT */
1159
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001160static struct platform_device msm_fb_device = {
1161 .name = "msm_fb",
1162 .id = 0,
1163 .num_resources = ARRAY_SIZE(msm_fb_resources),
1164 .resource = msm_fb_resources,
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001165#ifdef CONFIG_FB_MSM_MIPI_PANEL_DETECT
1166 .dev.platform_data = &msm_fb_pdata,
1167#endif /* CONFIG_FB_MSM_MIPI_PANEL_DETECT */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001168};
1169
1170static bool dsi_power_on;
1171
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001172/**
1173 * LiQUID panel on/off
1174 *
1175 * @param on
1176 *
1177 * @return int
1178 */
1179static int mipi_dsi_liquid_panel_power(int on)
1180{
1181 static struct regulator *reg_l2, *reg_ext_3p3v;
1182 static int gpio21, gpio24, gpio43;
1183 int rc;
1184
1185 pr_info("%s: on=%d\n", __func__, on);
1186
1187 gpio21 = PM8921_GPIO_PM_TO_SYS(21); /* disp power enable_n */
1188 gpio43 = PM8921_GPIO_PM_TO_SYS(43); /* Displays Enable (rst_n)*/
1189 gpio24 = PM8921_GPIO_PM_TO_SYS(24); /* Backlight PWM */
1190
1191 if (!dsi_power_on) {
1192
1193 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
1194 "dsi_vdda");
1195 if (IS_ERR(reg_l2)) {
1196 pr_err("could not get 8921_l2, rc = %ld\n",
1197 PTR_ERR(reg_l2));
1198 return -ENODEV;
1199 }
1200
1201 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
1202 if (rc) {
1203 pr_err("set_voltage l2 failed, rc=%d\n", rc);
1204 return -EINVAL;
1205 }
1206
1207 reg_ext_3p3v = regulator_get(&msm_mipi_dsi1_device.dev,
1208 "vdd_lvds_3p3v");
1209 if (IS_ERR(reg_ext_3p3v)) {
1210 pr_err("could not get reg_ext_3p3v, rc = %ld\n",
1211 PTR_ERR(reg_ext_3p3v));
1212 return -ENODEV;
1213 }
1214
1215 rc = gpio_request(gpio21, "disp_pwr_en_n");
1216 if (rc) {
1217 pr_err("request gpio 21 failed, rc=%d\n", rc);
1218 return -ENODEV;
1219 }
1220
1221 rc = gpio_request(gpio43, "disp_rst_n");
1222 if (rc) {
1223 pr_err("request gpio 43 failed, rc=%d\n", rc);
1224 return -ENODEV;
1225 }
1226
1227 rc = gpio_request(gpio24, "disp_backlight_pwm");
1228 if (rc) {
1229 pr_err("request gpio 24 failed, rc=%d\n", rc);
1230 return -ENODEV;
1231 }
1232
1233 dsi_power_on = true;
1234 }
1235
1236 if (on) {
1237 rc = regulator_set_optimum_mode(reg_l2, 100000);
1238 if (rc < 0) {
1239 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1240 return -EINVAL;
1241 }
1242 rc = regulator_enable(reg_l2);
1243 if (rc) {
1244 pr_err("enable l2 failed, rc=%d\n", rc);
1245 return -ENODEV;
1246 }
1247
1248 rc = regulator_enable(reg_ext_3p3v);
1249 if (rc) {
1250 pr_err("enable reg_ext_3p3v failed, rc=%d\n", rc);
1251 return -ENODEV;
1252 }
1253
1254 /* set reset pin before power enable */
1255 gpio_set_value_cansleep(gpio43, 0); /* disp disable (resx=0) */
1256
1257 gpio_set_value_cansleep(gpio21, 0); /* disp power enable_n */
1258 msleep(20);
1259 gpio_set_value_cansleep(gpio43, 1); /* disp enable */
1260 msleep(20);
1261 gpio_set_value_cansleep(gpio43, 0); /* disp enable */
1262 msleep(20);
1263 gpio_set_value_cansleep(gpio43, 1); /* disp enable */
1264 msleep(20);
1265 } else {
1266 gpio_set_value_cansleep(gpio43, 0);
1267 gpio_set_value_cansleep(gpio21, 1);
1268
1269 rc = regulator_disable(reg_l2);
1270 if (rc) {
1271 pr_err("disable reg_l2 failed, rc=%d\n", rc);
1272 return -ENODEV;
1273 }
1274 rc = regulator_disable(reg_ext_3p3v);
1275 if (rc) {
1276 pr_err("disable reg_ext_3p3v failed, rc=%d\n", rc);
1277 return -ENODEV;
1278 }
1279 rc = regulator_set_optimum_mode(reg_l2, 100);
1280 if (rc < 0) {
1281 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1282 return -EINVAL;
1283 }
1284 }
1285
1286 return 0;
1287}
1288
1289static int mipi_dsi_cdp_panel_power(int on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001290{
1291 static struct regulator *reg_l8, *reg_l23, *reg_l2;
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07001292 static int gpio43;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001293 int rc;
1294
1295 struct pm_gpio gpio43_param = {
1296 .direction = PM_GPIO_DIR_OUT,
1297 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
1298 .output_value = 0,
1299 .pull = PM_GPIO_PULL_NO,
1300 .vin_sel = 2,
1301 .out_strength = PM_GPIO_STRENGTH_HIGH,
1302 .function = PM_GPIO_FUNC_PAIRED,
1303 .inv_int_pol = 0,
1304 .disable_pin = 0,
1305 };
1306
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001307 pr_info("%s: state : %d\n", __func__, on);
1308
1309 if (!dsi_power_on) {
1310
1311 reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev,
1312 "dsi_vdc");
1313 if (IS_ERR(reg_l8)) {
1314 pr_err("could not get 8921_l8, rc = %ld\n",
1315 PTR_ERR(reg_l8));
1316 return -ENODEV;
1317 }
1318
1319 reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev,
1320 "dsi_vddio");
1321 if (IS_ERR(reg_l23)) {
1322 pr_err("could not get 8921_l23, rc = %ld\n",
1323 PTR_ERR(reg_l23));
1324 return -ENODEV;
1325 }
1326
1327 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
1328 "dsi_vdda");
1329 if (IS_ERR(reg_l2)) {
1330 pr_err("could not get 8921_l2, rc = %ld\n",
1331 PTR_ERR(reg_l2));
1332 return -ENODEV;
1333 }
1334
1335 rc = regulator_set_voltage(reg_l8, 2800000, 3000000);
1336 if (rc) {
1337 pr_err("set_voltage l8 failed, rc=%d\n", rc);
1338 return -EINVAL;
1339 }
1340 rc = regulator_set_voltage(reg_l23, 1800000, 1800000);
1341 if (rc) {
1342 pr_err("set_voltage l23 failed, rc=%d\n", rc);
1343 return -EINVAL;
1344 }
1345 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
1346 if (rc) {
1347 pr_err("set_voltage l2 failed, rc=%d\n", rc);
1348 return -EINVAL;
1349 }
1350
1351 gpio43 = PM8921_GPIO_PM_TO_SYS(43);
1352 rc = gpio_request(gpio43, "disp_rst_n");
1353 if (rc) {
1354 pr_err("request gpio 43 failed, rc=%d\n", rc);
1355 return -ENODEV;
1356 }
1357
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001358 dsi_power_on = true;
1359 }
1360
1361 if (on) {
1362 rc = regulator_set_optimum_mode(reg_l8, 100000);
1363 if (rc < 0) {
1364 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
1365 return -EINVAL;
1366 }
1367 rc = regulator_set_optimum_mode(reg_l23, 100000);
1368 if (rc < 0) {
1369 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1370 return -EINVAL;
1371 }
1372 rc = regulator_set_optimum_mode(reg_l2, 100000);
1373 if (rc < 0) {
1374 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1375 return -EINVAL;
1376 }
1377 rc = regulator_enable(reg_l8);
1378 if (rc) {
1379 pr_err("enable l8 failed, rc=%d\n", rc);
1380 return -ENODEV;
1381 }
1382 rc = regulator_enable(reg_l23);
1383 if (rc) {
1384 pr_err("enable l8 failed, rc=%d\n", rc);
1385 return -ENODEV;
1386 }
1387 rc = regulator_enable(reg_l2);
1388 if (rc) {
1389 pr_err("enable l2 failed, rc=%d\n", rc);
1390 return -ENODEV;
1391 }
1392
1393 gpio43_param.pull = PM_GPIO_PULL_NO;
1394 rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
1395 if (rc) {
1396 pr_err("gpio_config 43 failed (1), rc=%d\n", rc);
1397 return -EINVAL;
1398 }
1399 gpio43_param.pull = PM_GPIO_PULL_UP_30;
1400 rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
1401 if (rc) {
1402 pr_err("gpio_config 43 failed (2), rc=%d\n", rc);
1403 return -EINVAL;
1404 }
1405 gpio43_param.pull = PM_GPIO_PULL_NO;
1406 rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
1407 if (rc) {
1408 pr_err("gpio_config 43 failed (3), rc=%d\n", rc);
1409 return -EINVAL;
1410 }
1411 gpio43_param.pull = PM_GPIO_PULL_UP_30;
1412 rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
1413 if (rc) {
1414 pr_err("gpio_config 43 failed (4), rc=%d\n", rc);
1415 return -EINVAL;
1416 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001417 gpio_set_value_cansleep(gpio43, 1);
1418 } else {
1419 rc = regulator_set_optimum_mode(reg_l8, 100);
1420 if (rc < 0) {
1421 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
1422 return -EINVAL;
1423 }
1424 rc = regulator_set_optimum_mode(reg_l23, 100);
1425 if (rc < 0) {
1426 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1427 return -EINVAL;
1428 }
1429 rc = regulator_set_optimum_mode(reg_l2, 100);
1430 if (rc < 0) {
1431 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1432 return -EINVAL;
1433 }
1434 gpio_set_value_cansleep(gpio43, 0);
1435 }
1436 return 0;
1437}
1438
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001439static int mipi_dsi_panel_power(int on)
1440{
1441 int ret;
1442
1443 pr_info("%s: on=%d\n", __func__, on);
1444
1445 if (machine_is_msm8960_liquid())
1446 ret = mipi_dsi_liquid_panel_power(on);
1447 else
1448 ret = mipi_dsi_cdp_panel_power(on);
1449
1450 return ret;
1451}
1452
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001453static struct mipi_dsi_platform_data mipi_dsi_pdata = {
1454 .vsync_gpio = MDP_VSYNC_GPIO,
1455 .dsi_power_save = mipi_dsi_panel_power,
1456};
1457
1458#ifdef CONFIG_MSM_BUS_SCALING
1459
1460static struct msm_bus_vectors mdp_init_vectors[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001461 {
1462 .src = MSM_BUS_MASTER_MDP_PORT0,
1463 .dst = MSM_BUS_SLAVE_EBI_CH0,
1464 .ab = 0,
1465 .ib = 0,
1466 },
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001467};
1468
1469static struct msm_bus_vectors mdp_ui_vectors[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001470 {
1471 .src = MSM_BUS_MASTER_MDP_PORT0,
1472 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001473 .ab = 216000000 * 2,
1474 .ib = 270000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001475 },
1476};
1477
1478static struct msm_bus_vectors mdp_vga_vectors[] = {
1479 /* VGA and less video */
1480 {
1481 .src = MSM_BUS_MASTER_MDP_PORT0,
1482 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001483 .ab = 216000000 * 2,
1484 .ib = 270000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001485 },
1486};
1487
1488static struct msm_bus_vectors mdp_720p_vectors[] = {
1489 /* 720p and less video */
1490 {
1491 .src = MSM_BUS_MASTER_MDP_PORT0,
1492 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001493 .ab = 230400000 * 2,
1494 .ib = 288000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001495 },
1496};
1497
1498static struct msm_bus_vectors mdp_1080p_vectors[] = {
1499 /* 1080p and less video */
1500 {
1501 .src = MSM_BUS_MASTER_MDP_PORT0,
1502 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001503 .ab = 334080000 * 2,
1504 .ib = 417600000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001505 },
1506};
1507
1508static struct msm_bus_paths mdp_bus_scale_usecases[] = {
1509 {
1510 ARRAY_SIZE(mdp_init_vectors),
1511 mdp_init_vectors,
1512 },
1513 {
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001514 ARRAY_SIZE(mdp_ui_vectors),
1515 mdp_ui_vectors,
1516 },
1517 {
1518 ARRAY_SIZE(mdp_ui_vectors),
1519 mdp_ui_vectors,
1520 },
1521 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001522 ARRAY_SIZE(mdp_vga_vectors),
1523 mdp_vga_vectors,
1524 },
1525 {
1526 ARRAY_SIZE(mdp_720p_vectors),
1527 mdp_720p_vectors,
1528 },
1529 {
1530 ARRAY_SIZE(mdp_1080p_vectors),
1531 mdp_1080p_vectors,
1532 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001533};
1534
1535static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
1536 mdp_bus_scale_usecases,
1537 ARRAY_SIZE(mdp_bus_scale_usecases),
1538 .name = "mdp",
1539};
1540
1541#endif
1542
1543int mdp_core_clk_rate_table[] = {
1544 85330000,
1545 85330000,
Nagamalleswararao Ganjiad31c982011-08-15 23:24:17 -07001546 160000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001547 200000000,
1548};
1549
1550static struct msm_panel_common_pdata mdp_pdata = {
1551 .gpio = MDP_VSYNC_GPIO,
1552 .mdp_core_clk_rate = 85330000,
1553 .mdp_core_clk_table = mdp_core_clk_rate_table,
1554 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
1555#ifdef CONFIG_MSM_BUS_SCALING
1556 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
1557#endif
1558 .mdp_rev = MDP_REV_42,
1559};
1560
1561static struct platform_device mipi_dsi_renesas_panel_device = {
1562 .name = "mipi_renesas",
1563 .id = 0,
1564};
1565
1566static struct platform_device mipi_dsi_simulator_panel_device = {
1567 .name = "mipi_simulator",
1568 .id = 0,
1569};
1570
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07001571#define LPM_CHANNEL0 0
1572static int toshiba_gpio[] = {LPM_CHANNEL0};
1573
1574static struct mipi_dsi_panel_platform_data toshiba_pdata = {
1575 .gpio = toshiba_gpio,
1576};
1577
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001578static struct platform_device mipi_dsi_toshiba_panel_device = {
1579 .name = "mipi_toshiba",
1580 .id = 0,
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07001581 .dev = {
1582 .platform_data = &toshiba_pdata,
1583 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001584};
1585
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001586static int dsi2lvds_gpio[2] = {
1587 0,/* Backlight PWM-ID=0 for PMIC-GPIO#24 */
1588 0x1F08 /* DSI2LVDS Bridge GPIO Output, mask=0x1f, out=0x08 */
1589 };
1590
1591static struct msm_panel_common_pdata mipi_dsi2lvds_pdata = {
1592 .gpio_num = dsi2lvds_gpio,
1593};
1594
1595static struct platform_device mipi_dsi2lvds_bridge_device = {
1596 .name = "mipi_tc358764",
1597 .id = 0,
1598 .dev.platform_data = &mipi_dsi2lvds_pdata,
1599};
1600
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001601#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1602static struct resource hdmi_msm_resources[] = {
1603 {
1604 .name = "hdmi_msm_qfprom_addr",
1605 .start = 0x00700000,
1606 .end = 0x007060FF,
1607 .flags = IORESOURCE_MEM,
1608 },
1609 {
1610 .name = "hdmi_msm_hdmi_addr",
1611 .start = 0x04A00000,
1612 .end = 0x04A00FFF,
1613 .flags = IORESOURCE_MEM,
1614 },
1615 {
1616 .name = "hdmi_msm_irq",
1617 .start = HDMI_IRQ,
1618 .end = HDMI_IRQ,
1619 .flags = IORESOURCE_IRQ,
1620 },
1621};
1622
1623static int hdmi_enable_5v(int on);
1624static int hdmi_core_power(int on, int show);
1625static int hdmi_cec_power(int on);
1626
1627static struct msm_hdmi_platform_data hdmi_msm_data = {
1628 .irq = HDMI_IRQ,
1629 .enable_5v = hdmi_enable_5v,
1630 .core_power = hdmi_core_power,
1631 .cec_power = hdmi_cec_power,
1632};
1633
1634static struct platform_device hdmi_msm_device = {
1635 .name = "hdmi_msm",
1636 .id = 0,
1637 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
1638 .resource = hdmi_msm_resources,
1639 .dev.platform_data = &hdmi_msm_data,
1640};
1641#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1642
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001643#ifdef CONFIG_MSM_BUS_SCALING
1644static struct msm_bus_vectors dtv_bus_init_vectors[] = {
1645 {
1646 .src = MSM_BUS_MASTER_MDP_PORT0,
1647 .dst = MSM_BUS_SLAVE_EBI_CH0,
1648 .ab = 0,
1649 .ib = 0,
1650 },
1651};
1652static struct msm_bus_vectors dtv_bus_def_vectors[] = {
1653 {
1654 .src = MSM_BUS_MASTER_MDP_PORT0,
1655 .dst = MSM_BUS_SLAVE_EBI_CH0,
1656 .ab = 566092800 * 2,
1657 .ib = 707616000 * 2,
1658 },
1659};
1660static struct msm_bus_paths dtv_bus_scale_usecases[] = {
1661 {
1662 ARRAY_SIZE(dtv_bus_init_vectors),
1663 dtv_bus_init_vectors,
1664 },
1665 {
1666 ARRAY_SIZE(dtv_bus_def_vectors),
1667 dtv_bus_def_vectors,
1668 },
1669};
1670static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
1671 dtv_bus_scale_usecases,
1672 ARRAY_SIZE(dtv_bus_scale_usecases),
1673 .name = "dtv",
1674};
1675
1676static struct lcdc_platform_data dtv_pdata = {
1677 .bus_scale_table = &dtv_bus_scale_pdata,
1678};
1679#endif
1680
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001681static void __init msm_fb_add_devices(void)
1682{
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001683 struct platform_device *ptr = NULL;
1684
1685 if (machine_is_msm8960_liquid())
1686 ptr = &mipi_dsi2lvds_bridge_device;
1687 else
1688 ptr = &mipi_dsi_toshiba_panel_device;
1689 platform_add_devices(&ptr, 1);
1690
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001691 if (machine_is_msm8x60_rumi3()) {
1692 msm_fb_register_device("mdp", NULL);
1693 mipi_dsi_pdata.target_type = 1;
1694 } else
1695 msm_fb_register_device("mdp", &mdp_pdata);
1696 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001697#ifdef CONFIG_MSM_BUS_SCALING
1698 msm_fb_register_device("dtv", &dtv_pdata);
1699#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001700}
1701
Ravishangar Kalyanamba99e512011-07-20 12:57:19 -07001702static struct gpiomux_setting mdp_vsync_suspend_cfg = {
1703 .func = GPIOMUX_FUNC_GPIO,
1704 .drv = GPIOMUX_DRV_2MA,
1705 .pull = GPIOMUX_PULL_DOWN,
1706};
1707
1708static struct gpiomux_setting mdp_vsync_active_cfg = {
1709 .func = GPIOMUX_FUNC_1,
1710 .drv = GPIOMUX_DRV_2MA,
1711 .pull = GPIOMUX_PULL_DOWN,
1712};
1713
1714static struct msm_gpiomux_config msm8960_mdp_vsync_configs[] __initdata = {
1715 {
1716 .gpio = MDP_VSYNC_GPIO,
1717 .settings = {
1718 [GPIOMUX_ACTIVE] = &mdp_vsync_active_cfg,
1719 [GPIOMUX_SUSPENDED] = &mdp_vsync_suspend_cfg,
1720 },
1721 }
1722};
1723
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001724#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1725static struct gpiomux_setting hdmi_suspend_cfg = {
1726 .func = GPIOMUX_FUNC_GPIO,
1727 .drv = GPIOMUX_DRV_2MA,
1728 .pull = GPIOMUX_PULL_DOWN,
1729};
1730
1731static struct gpiomux_setting hdmi_active_1_cfg = {
1732 .func = GPIOMUX_FUNC_1,
1733 .drv = GPIOMUX_DRV_2MA,
1734 .pull = GPIOMUX_PULL_UP,
1735};
1736
1737static struct gpiomux_setting hdmi_active_2_cfg = {
1738 .func = GPIOMUX_FUNC_1,
1739 .drv = GPIOMUX_DRV_2MA,
1740 .pull = GPIOMUX_PULL_DOWN,
1741};
1742
1743static struct msm_gpiomux_config msm8960_hdmi_configs[] __initdata = {
1744 {
1745 .gpio = 99,
1746 .settings = {
1747 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
1748 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1749 },
1750 },
1751 {
1752 .gpio = 100,
1753 .settings = {
1754 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
1755 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1756 },
1757 },
1758 {
1759 .gpio = 101,
1760 .settings = {
1761 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
1762 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1763 },
1764 },
1765 {
1766 .gpio = 102,
1767 .settings = {
1768 [GPIOMUX_ACTIVE] = &hdmi_active_2_cfg,
1769 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1770 },
1771 },
1772};
1773
1774static int hdmi_enable_5v(int on)
1775{
1776 /* TBD: PM8921 regulator instead of 8901 */
1777 static struct regulator *reg_8921_hdmi_mvs; /* HDMI_5V */
1778 static int prev_on;
1779 int rc;
1780
1781 if (on == prev_on)
1782 return 0;
1783
1784 if (!reg_8921_hdmi_mvs)
1785 reg_8921_hdmi_mvs = regulator_get(&hdmi_msm_device.dev,
1786 "hdmi_mvs");
1787
1788 if (on) {
1789 rc = regulator_enable(reg_8921_hdmi_mvs);
1790 if (rc) {
1791 pr_err("'%s' regulator enable failed, rc=%d\n",
1792 "8921_hdmi_mvs", rc);
1793 return rc;
1794 }
1795 pr_debug("%s(on): success\n", __func__);
1796 } else {
1797 rc = regulator_disable(reg_8921_hdmi_mvs);
1798 if (rc)
1799 pr_warning("'%s' regulator disable failed, rc=%d\n",
1800 "8921_hdmi_mvs", rc);
1801 pr_debug("%s(off): success\n", __func__);
1802 }
1803
1804 prev_on = on;
1805
1806 return 0;
1807}
1808
1809static int hdmi_core_power(int on, int show)
1810{
1811 static struct regulator *reg_8921_l23, *reg_8921_s4;
1812 static int prev_on;
1813 int rc;
1814
1815 if (on == prev_on)
1816 return 0;
1817
1818 /* TBD: PM8921 regulator instead of 8901 */
1819 if (!reg_8921_l23)
1820 reg_8921_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
1821
1822 if (!reg_8921_s4)
1823 reg_8921_s4 = regulator_get(&hdmi_msm_device.dev, "hdmi_vcc");
1824
1825 if (on) {
1826 rc = regulator_set_optimum_mode(reg_8921_l23, 100000);
1827 if (rc < 0) {
1828 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1829 return -EINVAL;
1830 }
1831
1832 rc = regulator_set_voltage(reg_8921_l23, 1800000, 1800000);
1833 if (!rc)
1834 rc = regulator_enable(reg_8921_l23);
1835 if (rc) {
1836 pr_err("'%s' regulator enable failed, rc=%d\n",
1837 "hdmi_avdd", rc);
1838 return rc;
1839 }
1840 rc = regulator_set_voltage(reg_8921_s4, 1800000, 1800000);
1841 if (!rc)
1842 rc = regulator_enable(reg_8921_s4);
1843 if (rc) {
1844 pr_err("'%s' regulator enable failed, rc=%d\n",
1845 "hdmi_vcc", rc);
1846 return rc;
1847 }
1848
1849 rc = gpio_request(100, "HDMI_DDC_CLK");
1850 if (rc) {
1851 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1852 "HDMI_DDC_CLK", 100, rc);
1853 goto error1;
1854 }
1855 rc = gpio_request(101, "HDMI_DDC_DATA");
1856 if (rc) {
1857 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1858 "HDMI_DDC_DATA", 101, rc);
1859 goto error2;
1860 }
1861 rc = gpio_request(102, "HDMI_HPD");
1862 if (rc) {
1863 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1864 "HDMI_HPD", 102, rc);
1865 goto error3;
1866 }
1867 pr_debug("%s(on): success\n", __func__);
1868 } else {
1869 gpio_free(100);
1870 gpio_free(101);
1871 gpio_free(102);
1872
1873 rc = regulator_set_optimum_mode(reg_8921_l23, 100);
1874 if (rc < 0) {
1875 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1876 return -EINVAL;
1877 }
1878
1879 pr_debug("%s(off): success\n", __func__);
1880 }
1881
1882 prev_on = on;
1883
1884 return 0;
1885
1886error3:
1887 gpio_free(101);
1888error2:
1889 gpio_free(100);
1890error1:
1891 regulator_disable(reg_8921_l23);
1892 return rc;
1893}
1894
1895static int hdmi_cec_power(int on)
1896{
1897 static int prev_on;
1898 int rc;
1899
1900 if (on == prev_on)
1901 return 0;
1902
1903 if (on) {
1904 rc = gpio_request(99, "HDMI_CEC_VAR");
1905 if (rc) {
1906 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1907 "HDMI_CEC_VAR", 99, rc);
1908 goto error;
1909 }
1910 pr_debug("%s(on): success\n", __func__);
1911 } else {
1912 gpio_free(99);
1913 pr_debug("%s(off): success\n", __func__);
1914 }
1915
1916 prev_on = on;
1917
1918 return 0;
1919error:
1920 return rc;
1921}
1922#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1923
1924static void __init msm8960_allocate_memory_regions(void)
1925{
1926 void *addr;
1927 unsigned long size;
1928
1929 size = MSM_FB_SIZE;
1930 addr = alloc_bootmem_align(size, 0x1000);
1931 msm_fb_resources[0].start = __pa(addr);
1932 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
1933 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
1934 size, addr, __pa(addr));
1935
1936}
1937#ifdef CONFIG_WCD9310_CODEC
1938
1939#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
1940
Patrick Lai3043fba2011-08-01 14:15:57 -07001941/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
1942 * 4 micbiases are used to power various analog and digital
1943 * microphones operating at 1800 mV. Technically, all micbiases
1944 * can source from single cfilter since all microphones operate
1945 * at the same voltage level. The arrangement below is to make
1946 * sure all cfilters are exercised. LDO_H regulator ouput level
1947 * does not need to be as high as 2.85V. It is choosen for
1948 * microphone sensitivity purpose.
1949 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001950static struct tabla_pdata tabla_platform_data = {
1951 .slimbus_slave_device = {
1952 .name = "tabla-slave",
1953 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
1954 },
1955 .irq = MSM_GPIO_TO_INT(62),
1956 .irq_base = TABLA_INTERRUPT_BASE,
1957 .num_irqs = NR_TABLA_IRQS,
1958 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
Patrick Lai3043fba2011-08-01 14:15:57 -07001959 .micbias = {
1960 .ldoh_v = TABLA_LDOH_2P85_V,
1961 .cfilt1_mv = 1800,
1962 .cfilt2_mv = 1800,
1963 .cfilt3_mv = 1800,
1964 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1965 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1966 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1967 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
1968 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001969};
1970
1971static struct slim_device msm_slim_tabla = {
1972 .name = "tabla-slim",
1973 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
1974 .dev = {
1975 .platform_data = &tabla_platform_data,
1976 },
1977};
1978#endif
1979
1980static struct slim_boardinfo msm_slim_devices[] = {
1981#ifdef CONFIG_WCD9310_CODEC
1982 {
1983 .bus_num = 1,
1984 .slim_slave = &msm_slim_tabla,
1985 },
1986#endif
1987 /* add more slimbus slaves as needed */
1988};
1989
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001990#define MSM_WCNSS_PHYS 0x03000000
1991#define MSM_WCNSS_SIZE 0x280000
1992
1993static struct resource resources_wcnss_wlan[] = {
1994 {
1995 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1996 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1997 .name = "wcnss_wlanrx_irq",
1998 .flags = IORESOURCE_IRQ,
1999 },
2000 {
2001 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
2002 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
2003 .name = "wcnss_wlantx_irq",
2004 .flags = IORESOURCE_IRQ,
2005 },
2006 {
2007 .start = MSM_WCNSS_PHYS,
2008 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
2009 .name = "wcnss_mmio",
2010 .flags = IORESOURCE_MEM,
2011 },
2012};
2013
Ankur Nandwanib0039b02011-08-09 14:00:45 -07002014static struct qcom_wcnss_opts qcom_wcnss_pdata = {
2015 .has_48mhz_xo = 1,
2016};
2017
Yunsen Wang5c1a7392011-07-09 19:10:16 -07002018static struct platform_device msm_device_wcnss_wlan = {
2019 .name = "wcnss_wlan",
2020 .id = 0,
2021 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
2022 .resource = resources_wcnss_wlan,
Ankur Nandwanib0039b02011-08-09 14:00:45 -07002023 .dev = {.platform_data = &qcom_wcnss_pdata},
Yunsen Wang5c1a7392011-07-09 19:10:16 -07002024};
2025
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002026#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2027 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
2028 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2029 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2030
2031#define QCE_SIZE 0x10000
2032#define QCE_0_BASE 0x18500000
2033
2034#define QCE_HW_KEY_SUPPORT 0
2035#define QCE_SHA_HMAC_SUPPORT 1
2036#define QCE_SHARE_CE_RESOURCE 1
2037#define QCE_CE_SHARED 0
2038
2039static struct resource qcrypto_resources[] = {
2040 [0] = {
2041 .start = QCE_0_BASE,
2042 .end = QCE_0_BASE + QCE_SIZE - 1,
2043 .flags = IORESOURCE_MEM,
2044 },
2045 [1] = {
2046 .name = "crypto_channels",
2047 .start = DMOV_CE_IN_CHAN,
2048 .end = DMOV_CE_OUT_CHAN,
2049 .flags = IORESOURCE_DMA,
2050 },
2051 [2] = {
2052 .name = "crypto_crci_in",
2053 .start = DMOV_CE_IN_CRCI,
2054 .end = DMOV_CE_IN_CRCI,
2055 .flags = IORESOURCE_DMA,
2056 },
2057 [3] = {
2058 .name = "crypto_crci_out",
2059 .start = DMOV_CE_OUT_CRCI,
2060 .end = DMOV_CE_OUT_CRCI,
2061 .flags = IORESOURCE_DMA,
2062 },
2063};
2064
2065static struct resource qcedev_resources[] = {
2066 [0] = {
2067 .start = QCE_0_BASE,
2068 .end = QCE_0_BASE + QCE_SIZE - 1,
2069 .flags = IORESOURCE_MEM,
2070 },
2071 [1] = {
2072 .name = "crypto_channels",
2073 .start = DMOV_CE_IN_CHAN,
2074 .end = DMOV_CE_OUT_CHAN,
2075 .flags = IORESOURCE_DMA,
2076 },
2077 [2] = {
2078 .name = "crypto_crci_in",
2079 .start = DMOV_CE_IN_CRCI,
2080 .end = DMOV_CE_IN_CRCI,
2081 .flags = IORESOURCE_DMA,
2082 },
2083 [3] = {
2084 .name = "crypto_crci_out",
2085 .start = DMOV_CE_OUT_CRCI,
2086 .end = DMOV_CE_OUT_CRCI,
2087 .flags = IORESOURCE_DMA,
2088 },
2089};
2090
2091#endif
2092
2093#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2094 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2095
2096static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
2097 .ce_shared = QCE_CE_SHARED,
2098 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
2099 .hw_key_support = QCE_HW_KEY_SUPPORT,
2100 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
2101};
2102
2103static struct platform_device qcrypto_device = {
2104 .name = "qcrypto",
2105 .id = 0,
2106 .num_resources = ARRAY_SIZE(qcrypto_resources),
2107 .resource = qcrypto_resources,
2108 .dev = {
2109 .coherent_dma_mask = DMA_BIT_MASK(32),
2110 .platform_data = &qcrypto_ce_hw_suppport,
2111 },
2112};
2113#endif
2114
2115#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2116 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2117
2118static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
2119 .ce_shared = QCE_CE_SHARED,
2120 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
2121 .hw_key_support = QCE_HW_KEY_SUPPORT,
2122 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
2123};
2124
2125static struct platform_device qcedev_device = {
2126 .name = "qce",
2127 .id = 0,
2128 .num_resources = ARRAY_SIZE(qcedev_resources),
2129 .resource = qcedev_resources,
2130 .dev = {
2131 .coherent_dma_mask = DMA_BIT_MASK(32),
2132 .platform_data = &qcedev_ce_hw_suppport,
2133 },
2134};
2135#endif
2136
2137
2138static int __init gpiomux_init(void)
2139{
2140 int rc;
2141
2142 rc = msm_gpiomux_init(NR_GPIO_IRQS);
2143 if (rc) {
2144 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
2145 return rc;
2146 }
2147
Nishant Pandit24153d82011-08-27 16:05:13 +05302148 msm_gpiomux_install(msm8960_cam_common_configs,
2149 ARRAY_SIZE(msm8960_cam_common_configs));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002150
2151 msm_gpiomux_install(msm8960_gpiomux_configs,
Stepan Moskovchenkod2a45a82011-08-09 17:02:57 -07002152 ARRAY_SIZE(msm8960_gpiomux_configs));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002153
2154 msm_gpiomux_install(msm8960_gsbi_configs,
2155 ARRAY_SIZE(msm8960_gsbi_configs));
2156
2157 msm_gpiomux_install(msm8960_cyts_configs,
2158 ARRAY_SIZE(msm8960_cyts_configs));
2159
2160 msm_gpiomux_install(msm8960_slimbus_config,
2161 ARRAY_SIZE(msm8960_slimbus_config));
2162
2163 msm_gpiomux_install(msm8960_audio_codec_configs,
2164 ARRAY_SIZE(msm8960_audio_codec_configs));
2165
2166#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
2167 msm_gpiomux_install(msm8960_hdmi_configs,
2168 ARRAY_SIZE(msm8960_hdmi_configs));
2169#endif
2170
Ravishangar Kalyanamba99e512011-07-20 12:57:19 -07002171 msm_gpiomux_install(msm8960_mdp_vsync_configs,
2172 ARRAY_SIZE(msm8960_mdp_vsync_configs));
2173
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002174 msm_gpiomux_install(wcnss_5wire_interface,
2175 ARRAY_SIZE(wcnss_5wire_interface));
2176
2177 return 0;
2178}
2179
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002180#define MSM_SHARED_RAM_PHYS 0x80000000
2181
2182static struct pm8921_adc_amux pm8921_adc_channels_data[] = {
2183 {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
2184 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2185 {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
2186 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2187 {"dcin", CHANNEL_DCIN, CHAN_PATH_SCALING4, AMUX_RSV1,
2188 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2189 {"ichg", CHANNEL_ICHG, CHAN_PATH_SCALING1, AMUX_RSV1,
2190 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2191 {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
2192 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2193 {"ibat", CHANNEL_IBAT, CHAN_PATH_SCALING1, AMUX_RSV1,
2194 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2195 {"m4", CHANNEL_MPP_1, CHAN_PATH_SCALING1, AMUX_RSV1,
2196 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2197 {"m5", CHANNEL_MPP_2, CHAN_PATH_SCALING2, AMUX_RSV1,
2198 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2199 {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
2200 ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
2201 {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV1,
2202 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2203 {"usbin", CHANNEL_USBIN, CHAN_PATH_SCALING3, AMUX_RSV1,
2204 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2205 {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
2206 ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
2207 {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
2208 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2209 {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
2210 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2211 {"chg_temp", CHANNEL_CHG_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
2212 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2213};
2214
2215static struct pm8921_adc_properties pm8921_adc_data = {
2216 .adc_vdd_reference = 1800, /* milli-voltage for this adc */
2217 .bitresolution = 15,
2218 .bipolar = 0,
2219};
2220
2221static struct pm8921_adc_platform_data pm8921_adc_pdata = {
2222 .adc_channel = pm8921_adc_channels_data,
2223 .adc_num_channel = ARRAY_SIZE(pm8921_adc_channels_data),
2224 .adc_prop = &pm8921_adc_data,
2225};
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08002226
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002227static void __init msm8960_map_io(void)
2228{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002229 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002230 msm_map_msm8960_io();
2231}
2232
2233static void __init msm8960_init_irq(void)
2234{
2235 unsigned int i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002236
2237 msm_mpm_irq_extn_init();
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002238 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002239 (void *)MSM_QGIC_CPU_BASE);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002240
2241 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002242 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002243
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002244 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
2245 mb();
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08002246
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002247 /* FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
2248 * as they are configured as level, which does not play nice with
2249 * handle_percpu_irq.
2250 */
2251 for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
2252 if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
Thomas Gleixner6845664a2011-03-24 13:25:22 +01002253 irq_set_handler(i, handle_percpu_irq);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002254 }
2255}
2256
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002257/* MSM8960 have 5 SDCC controllers */
2258enum sdcc_controllers {
2259 SDCC1,
2260 SDCC2,
2261 SDCC3,
2262 SDCC4,
2263 SDCC5,
2264 MAX_SDCC_CONTROLLER
2265};
2266
2267/* All SDCC controllers requires VDD/VCC voltage */
2268static struct msm_mmc_reg_data mmc_vdd_reg_data[MAX_SDCC_CONTROLLER] = {
2269 /* SDCC1 : eMMC card connected */
2270 [SDCC1] = {
2271 .name = "sdc_vdd",
2272 .set_voltage_sup = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302273 .high_vol_level = 2950000,
2274 .low_vol_level = 2950000,
Subhash Jadavanidd7ef892011-08-18 16:49:57 +05302275 .always_on = 1,
2276 .lpm_sup = 1,
2277 .lpm_uA = 9000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002278 .hpm_uA = 200000, /* 200mA */
2279 },
2280 /* SDCC3 : External card slot connected */
2281 [SDCC3] = {
2282 .name = "sdc_vdd",
2283 .set_voltage_sup = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302284 .high_vol_level = 2950000,
2285 .low_vol_level = 2950000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002286 .hpm_uA = 600000, /* 600mA */
2287 }
2288};
2289
2290/* Only slots having eMMC card will require VCCQ voltage */
2291static struct msm_mmc_reg_data mmc_vccq_reg_data[1] = {
2292 /* SDCC1 : eMMC card connected */
2293 [SDCC1] = {
2294 .name = "sdc_vccq",
2295 .set_voltage_sup = 1,
2296 .always_on = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302297 .high_vol_level = 1800000,
2298 .low_vol_level = 1800000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002299 .hpm_uA = 200000, /* 200mA */
2300 }
2301};
2302
2303/* All SDCC controllers may require voting for VDD PAD voltage */
2304static struct msm_mmc_reg_data mmc_vddp_reg_data[MAX_SDCC_CONTROLLER] = {
2305 /* SDCC3 : External card slot connected */
2306 [SDCC3] = {
2307 .name = "sdc_vddp",
2308 .set_voltage_sup = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302309 .high_vol_level = 2950000,
2310 .low_vol_level = 1850000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002311 .always_on = 1,
2312 .lpm_sup = 1,
2313 /* Max. Active current required is 16 mA */
2314 .hpm_uA = 16000,
2315 /*
2316 * Sleep current required is ~300 uA. But min. vote can be
2317 * in terms of mA (min. 1 mA). So let's vote for 2 mA
2318 * during sleep.
2319 */
2320 .lpm_uA = 2000,
2321 }
2322};
2323
2324static struct msm_mmc_slot_reg_data mmc_slot_vreg_data[MAX_SDCC_CONTROLLER] = {
2325 /* SDCC1 : eMMC card connected */
2326 [SDCC1] = {
2327 .vdd_data = &mmc_vdd_reg_data[SDCC1],
2328 .vccq_data = &mmc_vccq_reg_data[SDCC1],
2329 },
2330 /* SDCC3 : External card slot connected */
2331 [SDCC3] = {
2332 .vdd_data = &mmc_vdd_reg_data[SDCC3],
2333 .vddp_data = &mmc_vddp_reg_data[SDCC3],
2334 }
2335};
2336
2337/* SDC1 pad data */
2338static struct msm_mmc_pad_drv sdc1_pad_drv_on_cfg[] = {
2339 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_16MA},
Subhash Jadavani87bda5a2011-08-30 17:40:44 +05302340 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_10MA},
2341 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_10MA}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002342};
2343
2344static struct msm_mmc_pad_drv sdc1_pad_drv_off_cfg[] = {
2345 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_2MA},
2346 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_2MA},
2347 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_2MA}
2348};
2349
2350static struct msm_mmc_pad_pull sdc1_pad_pull_on_cfg[] = {
Subhash Jadavanib7b5b8a2011-09-13 13:00:40 +05302351 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002352 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_UP},
2353 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_UP}
2354};
2355
2356static struct msm_mmc_pad_pull sdc1_pad_pull_off_cfg[] = {
Subhash Jadavanib7b5b8a2011-09-13 13:00:40 +05302357 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002358 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_DOWN},
2359 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_DOWN}
2360};
2361
2362/* SDC3 pad data */
2363static struct msm_mmc_pad_drv sdc3_pad_drv_on_cfg[] = {
2364 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
2365 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
2366 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
2367};
2368
2369static struct msm_mmc_pad_drv sdc3_pad_drv_off_cfg[] = {
2370 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
2371 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
2372 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
2373};
2374
2375static struct msm_mmc_pad_pull sdc3_pad_pull_on_cfg[] = {
Subhash Jadavanib7b5b8a2011-09-13 13:00:40 +05302376 {TLMM_PULL_SDC3_CLK, GPIO_CFG_NO_PULL},
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002377 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
2378 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
2379};
2380
2381static struct msm_mmc_pad_pull sdc3_pad_pull_off_cfg[] = {
Subhash Jadavanib7b5b8a2011-09-13 13:00:40 +05302382 {TLMM_PULL_SDC3_CLK, GPIO_CFG_NO_PULL},
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002383 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
2384 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
2385};
2386
2387struct msm_mmc_pad_pull_data mmc_pad_pull_data[MAX_SDCC_CONTROLLER] = {
2388 [SDCC1] = {
2389 .on = sdc1_pad_pull_on_cfg,
2390 .off = sdc1_pad_pull_off_cfg,
2391 .size = ARRAY_SIZE(sdc1_pad_pull_on_cfg)
2392 },
2393 [SDCC3] = {
2394 .on = sdc3_pad_pull_on_cfg,
2395 .off = sdc3_pad_pull_off_cfg,
2396 .size = ARRAY_SIZE(sdc3_pad_pull_on_cfg)
2397 },
2398};
2399
2400struct msm_mmc_pad_drv_data mmc_pad_drv_data[MAX_SDCC_CONTROLLER] = {
2401 [SDCC1] = {
2402 .on = sdc1_pad_drv_on_cfg,
2403 .off = sdc1_pad_drv_off_cfg,
2404 .size = ARRAY_SIZE(sdc1_pad_drv_on_cfg)
2405 },
2406 [SDCC3] = {
2407 .on = sdc3_pad_drv_on_cfg,
2408 .off = sdc3_pad_drv_off_cfg,
2409 .size = ARRAY_SIZE(sdc3_pad_drv_on_cfg)
2410 },
2411};
2412
2413struct msm_mmc_pad_data mmc_pad_data[MAX_SDCC_CONTROLLER] = {
2414 [SDCC1] = {
2415 .pull = &mmc_pad_pull_data[SDCC1],
2416 .drv = &mmc_pad_drv_data[SDCC1]
2417 },
2418 [SDCC3] = {
2419 .pull = &mmc_pad_pull_data[SDCC3],
2420 .drv = &mmc_pad_drv_data[SDCC3]
2421 },
2422};
2423
2424struct msm_mmc_pin_data mmc_slot_pin_data[MAX_SDCC_CONTROLLER] = {
2425 [SDCC1] = {
2426 .pad_data = &mmc_pad_data[SDCC1],
2427 },
2428 [SDCC3] = {
2429 .pad_data = &mmc_pad_data[SDCC3],
2430 },
2431};
2432
2433static unsigned int sdc1_sup_clk_rates[] = {
Subhash Jadavani0e027b72011-08-30 17:40:55 +05302434 400000, 24000000, 48000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002435};
2436
2437static unsigned int sdc3_sup_clk_rates[] = {
2438 400000, 24000000, 48000000, 96000000
2439};
2440
2441#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
2442static struct mmc_platform_data msm8960_sdc1_data = {
2443 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
2444#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
2445 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
2446#else
2447 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
2448#endif
2449 .sup_clk_table = sdc1_sup_clk_rates,
2450 .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates),
2451 .nonremovable = 1,
2452 .sdcc_v4_sup = true,
2453 .vreg_data = &mmc_slot_vreg_data[SDCC1],
Subhash Jadavani0e027b72011-08-30 17:40:55 +05302454 .pin_data = &mmc_slot_pin_data[SDCC1]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002455};
2456#endif
2457
2458#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
2459static struct mmc_platform_data msm8960_sdc3_data = {
2460 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
2461 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
2462 .sup_clk_table = sdc3_sup_clk_rates,
2463 .sup_clk_cnt = ARRAY_SIZE(sdc3_sup_clk_rates),
2464 .wpswitch_gpio = PM8921_GPIO_PM_TO_SYS(16),
2465 .sdcc_v4_sup = true,
2466 .vreg_data = &mmc_slot_vreg_data[SDCC3],
2467 .pin_data = &mmc_slot_pin_data[SDCC3],
2468#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
2469 .status_gpio = PM8921_GPIO_PM_TO_SYS(26),
2470 .status_irq = PM8921_GPIO_IRQ(PM8921_IRQ_BASE, 26),
2471 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
2472#endif
2473 .xpc_cap = 1,
2474 .uhs_caps = (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
2475 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_DDR50 |
Subhash Jadavani0e027b72011-08-30 17:40:55 +05302476 MMC_CAP_MAX_CURRENT_600)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002477};
2478#endif
2479
2480static void __init msm8960_init_mmc(void)
2481{
2482#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
2483 /* SDC1 : eMMC card connected */
2484 msm_add_sdcc(1, &msm8960_sdc1_data);
2485#endif
2486#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
2487 /* SDC3: External card slot */
2488 msm_add_sdcc(3, &msm8960_sdc3_data);
2489#endif
2490}
2491
2492static void __init msm8960_init_buses(void)
2493{
2494#ifdef CONFIG_MSM_BUS_SCALING
2495 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
2496 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
2497 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
2498 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
2499 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
2500 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
2501 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
2502 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
2503 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
2504 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
2505#endif
2506}
2507
2508static struct msm_spi_platform_data msm8960_qup_spi_gsbi1_pdata = {
2509 .max_clock_speed = 15060000,
2510};
2511
2512#ifdef CONFIG_USB_MSM_OTG_72K
2513static struct msm_otg_platform_data msm_otg_pdata;
2514#else
2515#define USB_5V_EN 42
2516static void msm_hsusb_vbus_power(bool on)
2517{
2518 int rc;
2519 static bool vbus_is_on;
2520 static struct regulator *mvs_otg_switch;
2521 struct pm_gpio param = {
2522 .direction = PM_GPIO_DIR_OUT,
2523 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
2524 .output_value = 1,
2525 .pull = PM_GPIO_PULL_NO,
2526 .vin_sel = PM_GPIO_VIN_S4,
2527 .out_strength = PM_GPIO_STRENGTH_MED,
2528 .function = PM_GPIO_FUNC_NORMAL,
2529 };
2530
2531 if (vbus_is_on == on)
2532 return;
2533
2534 if (on) {
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002535 mvs_otg_switch = regulator_get(&msm8960_device_otg.dev,
2536 "vbus_otg");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002537 if (IS_ERR(mvs_otg_switch)) {
2538 pr_err("Unable to get mvs_otg_switch\n");
2539 return;
2540 }
2541
2542 rc = gpio_request(PM8921_GPIO_PM_TO_SYS(USB_5V_EN),
2543 "usb_5v_en");
2544 if (rc < 0) {
2545 pr_err("failed to request usb_5v_en gpio\n");
2546 goto put_mvs_otg;
2547 }
2548
2549 if (regulator_enable(mvs_otg_switch)) {
2550 pr_err("unable to enable mvs_otg_switch\n");
2551 goto free_usb_5v_en;
2552 }
2553
2554 rc = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(USB_5V_EN),
2555 &param);
2556 if (rc < 0) {
2557 pr_err("failed to configure usb_5v_en gpio\n");
2558 goto disable_mvs_otg;
2559 }
2560 vbus_is_on = true;
2561 return;
2562 }
2563disable_mvs_otg:
2564 regulator_disable(mvs_otg_switch);
2565free_usb_5v_en:
2566 gpio_free(PM8921_GPIO_PM_TO_SYS(USB_5V_EN));
2567put_mvs_otg:
2568 regulator_put(mvs_otg_switch);
2569 vbus_is_on = false;
2570}
2571
2572static struct msm_otg_platform_data msm_otg_pdata = {
2573 .mode = USB_OTG,
2574 .otg_control = OTG_PMIC_CONTROL,
2575 .phy_type = SNPS_28NM_INTEGRATED_PHY,
2576 .pclk_src_name = "dfab_usb_hs_clk",
2577 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
2578 .vbus_power = msm_hsusb_vbus_power,
2579};
2580#endif
2581
2582#define PID_MAGIC_ID 0x71432909
2583#define SERIAL_NUM_MAGIC_ID 0x61945374
2584#define SERIAL_NUMBER_LENGTH 127
2585#define DLOAD_USB_BASE_ADD 0x2A03F0C8
2586
2587struct magic_num_struct {
2588 uint32_t pid;
2589 uint32_t serial_num;
2590};
2591
2592struct dload_struct {
2593 uint32_t reserved1;
2594 uint32_t reserved2;
2595 uint32_t reserved3;
2596 uint16_t reserved4;
2597 uint16_t pid;
2598 char serial_number[SERIAL_NUMBER_LENGTH];
2599 uint16_t reserved5;
2600 struct magic_num_struct magic_struct;
2601};
2602
2603static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
2604{
2605 struct dload_struct __iomem *dload = 0;
2606
2607 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
2608 if (!dload) {
2609 pr_err("%s: cannot remap I/O memory region: %08x\n",
2610 __func__, DLOAD_USB_BASE_ADD);
2611 return -ENXIO;
2612 }
2613
2614 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
2615 __func__, dload, pid, snum);
2616 /* update pid */
2617 dload->magic_struct.pid = PID_MAGIC_ID;
2618 dload->pid = pid;
2619
2620 /* update serial number */
2621 dload->magic_struct.serial_num = 0;
2622 if (!snum) {
2623 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
2624 goto out;
2625 }
2626
2627 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
2628 strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
2629 dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
2630out:
2631 iounmap(dload);
2632 return 0;
2633}
2634
2635static struct android_usb_platform_data android_usb_pdata = {
2636 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2637};
2638
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002639static struct platform_device android_usb_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002640 .name = "android_usb",
2641 .id = -1,
2642 .dev = {
2643 .platform_data = &android_usb_pdata,
2644 },
2645};
2646
2647static uint8_t spm_wfi_cmd_sequence[] __initdata = {
2648 0x03, 0x0f,
2649};
2650
2651static uint8_t spm_power_collapse_without_rpm[] __initdata = {
2652 0x00, 0x24, 0x54, 0x10,
2653 0x09, 0x03, 0x01,
2654 0x10, 0x54, 0x30, 0x0C,
2655 0x24, 0x30, 0x0f,
2656};
2657
2658static uint8_t spm_power_collapse_with_rpm[] __initdata = {
2659 0x00, 0x24, 0x54, 0x10,
2660 0x09, 0x07, 0x01, 0x0B,
2661 0x10, 0x54, 0x30, 0x0C,
2662 0x24, 0x30, 0x0f,
2663};
2664
2665static struct msm_spm_seq_entry msm_spm_seq_list[] __initdata = {
2666 [0] = {
2667 .mode = MSM_SPM_MODE_CLOCK_GATING,
2668 .notify_rpm = false,
2669 .cmd = spm_wfi_cmd_sequence,
2670 },
2671 [1] = {
2672 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2673 .notify_rpm = false,
2674 .cmd = spm_power_collapse_without_rpm,
2675 },
2676 [2] = {
2677 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2678 .notify_rpm = true,
2679 .cmd = spm_power_collapse_with_rpm,
2680 },
2681};
2682
2683static struct msm_spm_platform_data msm_spm_data[] __initdata = {
2684 [0] = {
2685 .reg_base_addr = MSM_SAW0_BASE,
2686 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
2687 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
2688 .reg_init_values[MSM_SPM_REG_SAW2_VCTL] = 0x9C,
2689#if defined(CONFIG_MSM_AVS_HW)
2690 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2691 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2692#endif
2693 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
2694 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
2695 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2696 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2697 .vctl_timeout_us = 50,
2698 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
2699 .modes = msm_spm_seq_list,
2700 },
2701 [1] = {
2702 .reg_base_addr = MSM_SAW1_BASE,
2703 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
2704 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
2705 .reg_init_values[MSM_SPM_REG_SAW2_VCTL] = 0x9C,
2706#if defined(CONFIG_MSM_AVS_HW)
2707 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2708 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2709#endif
2710 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
2711 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
2712 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2713 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2714 .vctl_timeout_us = 50,
2715 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
2716 .modes = msm_spm_seq_list,
2717 },
2718};
2719
2720static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
2721 0x00, 0x20, 0x03, 0x20,
2722 0x00, 0x0f,
2723};
2724
2725static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
2726 0x00, 0x20, 0x34, 0x64,
2727 0x48, 0x07, 0x48, 0x20,
2728 0x50, 0x64, 0x04, 0x34,
2729 0x50, 0x0f,
2730};
2731static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
2732 0x00, 0x10, 0x34, 0x64,
2733 0x48, 0x07, 0x48, 0x10,
2734 0x50, 0x64, 0x04, 0x34,
2735 0x50, 0x0F,
2736};
2737
2738static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
2739 [0] = {
2740 .mode = MSM_SPM_L2_MODE_RETENTION,
2741 .notify_rpm = false,
2742 .cmd = l2_spm_wfi_cmd_sequence,
2743 },
2744 [1] = {
2745 .mode = MSM_SPM_L2_MODE_GDHS,
2746 .notify_rpm = true,
2747 .cmd = l2_spm_gdhs_cmd_sequence,
2748 },
2749 [2] = {
2750 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
2751 .notify_rpm = true,
2752 .cmd = l2_spm_power_off_cmd_sequence,
2753 },
2754};
2755
2756
2757static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
2758 [0] = {
2759 .reg_base_addr = MSM_SAW_L2_BASE,
2760 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
2761 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
2762 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
2763 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
2764 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
2765 .modes = msm_spm_l2_seq_list,
2766 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
2767 },
2768};
2769
2770#define CYTTSP_TS_GPIO_IRQ 11
2771#define CYTTSP_TS_SLEEP_GPIO 50
2772#define CYTTSP_TS_RESOUT_N_GPIO 52
2773
2774/*virtual key support */
2775static ssize_t tma340_vkeys_show(struct kobject *kobj,
2776 struct kobj_attribute *attr, char *buf)
2777{
2778 return snprintf(buf, 200,
2779 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
2780 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
2781 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
2782 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
2783 "\n");
2784}
2785
2786static struct kobj_attribute tma340_vkeys_attr = {
2787 .attr = {
2788 .mode = S_IRUGO,
2789 },
2790 .show = &tma340_vkeys_show,
2791};
2792
2793static struct attribute *tma340_properties_attrs[] = {
2794 &tma340_vkeys_attr.attr,
2795 NULL
2796};
2797
2798static struct attribute_group tma340_properties_attr_group = {
2799 .attrs = tma340_properties_attrs,
2800};
2801
2802
2803static int cyttsp_platform_init(struct i2c_client *client)
2804{
2805 int rc = 0;
2806 static struct kobject *tma340_properties_kobj;
2807
2808 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
2809 tma340_properties_kobj = kobject_create_and_add("board_properties",
2810 NULL);
2811 if (tma340_properties_kobj)
2812 rc = sysfs_create_group(tma340_properties_kobj,
2813 &tma340_properties_attr_group);
2814 if (!tma340_properties_kobj || rc)
2815 pr_err("%s: failed to create board_properties\n",
2816 __func__);
2817
2818 return 0;
2819}
2820
2821static struct cyttsp_regulator regulator_data[] = {
2822 {
2823 .name = "vdd",
2824 .min_uV = CY_TMA300_VTG_MIN_UV,
2825 .max_uV = CY_TMA300_VTG_MAX_UV,
2826 .load_uA = CY_TMA300_CURR_24HZ_UA,
2827 },
2828 /* TODO: Remove after runtime PM is enabled in I2C driver */
2829 {
2830 .name = "vcc_i2c",
2831 .min_uV = CY_I2C_VTG_MIN_UV,
2832 .max_uV = CY_I2C_VTG_MAX_UV,
2833 .load_uA = CY_I2C_CURR_UA,
2834 },
2835};
2836
2837static struct cyttsp_platform_data cyttsp_pdata = {
2838 .panel_maxx = 634,
2839 .panel_maxy = 1166,
2840 .disp_maxx = 616,
2841 .disp_maxy = 1023,
2842 .disp_minx = 0,
2843 .disp_miny = 16,
2844 .flags = 0x01,
2845 .gen = CY_GEN3, /* or */
2846 .use_st = CY_USE_ST,
2847 .use_mt = CY_USE_MT,
2848 .use_hndshk = CY_SEND_HNDSHK,
2849 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayale96f66d2011-08-11 14:06:38 +05302850 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002851 .use_gestures = CY_USE_GESTURES,
2852 .fw_fname = "cyttsp_8960_cdp.hex",
2853 /* activate up to 4 groups
2854 * and set active distance
2855 */
2856 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
2857 CY_GEST_GRP3 | CY_GEST_GRP4 |
2858 CY_ACT_DIST,
2859 /* change act_intrvl to customize the Active power state
2860 * scanning/processing refresh interval for Operating mode
2861 */
2862 .act_intrvl = CY_ACT_INTRVL_DFLT,
2863 /* change tch_tmout to customize the touch timeout for the
2864 * Active power state for Operating mode
2865 */
2866 .tch_tmout = CY_TCH_TMOUT_DFLT,
2867 /* change lp_intrvl to customize the Low Power power state
2868 * scanning/processing refresh interval for Operating mode
2869 */
2870 .lp_intrvl = CY_LP_INTRVL_DFLT,
2871 .sleep_gpio = CYTTSP_TS_SLEEP_GPIO,
2872 .resout_gpio = CYTTSP_TS_RESOUT_N_GPIO,
2873 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
2874 .regulator_info = regulator_data,
2875 .num_regulators = ARRAY_SIZE(regulator_data),
2876 .init = cyttsp_platform_init,
Mohan Pallaka49c37d62011-08-01 11:52:00 +05302877 .correct_fw_ver = 9,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002878};
2879
2880static struct i2c_board_info cyttsp_info[] __initdata = {
2881 {
2882 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
2883 .platform_data = &cyttsp_pdata,
2884#ifndef CY_USE_TIMER
2885 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
2886#endif /* CY_USE_TIMER */
2887 },
2888};
2889
2890static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
2891{
2892}
2893
2894static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi4_pdata = {
2895 .clk_freq = 100000,
2896 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002897 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2898};
2899
2900static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi3_pdata = {
2901 .clk_freq = 100000,
2902 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002903 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2904};
2905
2906static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi10_pdata = {
2907 .clk_freq = 100000,
2908 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002909 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2910};
2911
2912static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi12_pdata = {
2913 .clk_freq = 100000,
2914 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002915 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2916};
2917
2918static struct msm_rpm_platform_data msm_rpm_data = {
2919 .reg_base_addrs = {
2920 [MSM_RPM_PAGE_STATUS] = MSM_RPM_BASE,
2921 [MSM_RPM_PAGE_CTRL] = MSM_RPM_BASE + 0x400,
2922 [MSM_RPM_PAGE_REQ] = MSM_RPM_BASE + 0x600,
2923 [MSM_RPM_PAGE_ACK] = MSM_RPM_BASE + 0xa00,
2924 },
2925
2926 .irq_ack = RPM_APCC_CPU0_GP_HIGH_IRQ,
2927 .irq_err = RPM_APCC_CPU0_GP_LOW_IRQ,
2928 .irq_vmpm = RPM_APCC_CPU0_GP_MEDIUM_IRQ,
2929 .msm_apps_ipc_rpm_reg = MSM_APCS_GCC_BASE + 0x008,
2930 .msm_apps_ipc_rpm_val = 4,
2931};
2932
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06002933static struct platform_device msm_rpm_device = {
2934 .name = "msm_rpm",
2935 .id = -1,
2936};
2937
2938
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002939static struct spi_board_info spi_board_info[] __initdata = {
2940 {
2941 .modalias = "ks8851",
2942 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2943 .max_speed_hz = 19200000,
2944 .bus_num = 0,
2945 .chip_select = 0,
2946 .mode = SPI_MODE_0,
2947 },
2948};
2949
2950static struct platform_device msm_device_saw_core0 = {
2951 .name = "saw-regulator",
2952 .id = 0,
2953 .dev = {
2954 .platform_data = &msm_saw_regulator_pdata_s5,
2955 },
2956};
2957
2958static struct platform_device msm_device_saw_core1 = {
2959 .name = "saw-regulator",
2960 .id = 1,
2961 .dev = {
2962 .platform_data = &msm_saw_regulator_pdata_s6,
2963 },
2964};
2965
2966#ifdef CONFIG_MSM_FAKE_BATTERY
2967static struct platform_device fish_battery_device = {
2968 .name = "fish_battery",
2969};
2970#endif
2971
David Collins26f05562011-06-20 09:56:28 -07002972static struct platform_device msm8960_device_ext_5v_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002973 .name = GPIO_REGULATOR_DEV_NAME,
2974 .id = PM8921_MPP_PM_TO_SYS(7),
2975 .dev = {
2976 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2977 },
2978};
2979
David Collins26f05562011-06-20 09:56:28 -07002980static struct platform_device msm8960_device_ext_l2_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002981 .name = GPIO_REGULATOR_DEV_NAME,
2982 .id = 91,
2983 .dev = {
2984 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
2985 },
2986};
2987
David Collinsb10be1d2011-09-02 10:29:31 -07002988static struct platform_device msm8960_device_ext_3p3v_vreg __devinitdata = {
2989 .name = GPIO_REGULATOR_DEV_NAME,
2990 .id = PM8921_GPIO_PM_TO_SYS(17),
2991 .dev = {
2992 .platform_data =
2993 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2994 },
2995};
2996
David Collins26f05562011-06-20 09:56:28 -07002997static struct platform_device msm8960_device_rpm_regulator __devinitdata = {
2998 .name = "rpm-regulator",
2999 .id = -1,
3000 .dev = {
3001 .platform_data = &msm_rpm_regulator_pdata,
3002 },
3003};
3004
David Collins4c31a872011-08-31 10:07:10 -07003005static struct msm_rpm_log_platform_data msm_rpm_log_pdata = {
3006 .phys_addr_base = 0x0010C000,
3007 .reg_offsets = {
3008 [MSM_RPM_LOG_PAGE_INDICES] = 0x00000080,
3009 [MSM_RPM_LOG_PAGE_BUFFER] = 0x000000A0,
3010 },
3011 .phys_size = SZ_8K,
3012 .log_len = 4096, /* log's buffer length in bytes */
3013 .log_len_mask = (4096 >> 2) - 1, /* length mask in units of u32 */
3014};
3015
3016static struct platform_device msm_rpm_log_device = {
3017 .name = "msm_rpm_log",
3018 .id = -1,
3019 .dev = {
3020 .platform_data = &msm_rpm_log_pdata,
3021 },
3022};
3023
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003024static struct platform_device *common_devices[] __initdata = {
Stepan Moskovchenkodf13d342011-08-03 19:01:25 -07003025 &msm8960_device_dmov,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003026 &msm_device_smd,
3027 &msm8960_device_uart_gsbi5,
Mayank Rana9f51f582011-08-04 18:35:59 +05303028 &msm_device_uart_dm6,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003029 &msm_device_saw_core0,
3030 &msm_device_saw_core1,
3031 &msm8960_device_ext_5v_vreg,
3032 &msm8960_device_ext_l2_vreg,
3033 &msm8960_device_ssbi_pm8921,
3034 &msm8960_device_qup_spi_gsbi1,
3035 &msm8960_device_qup_i2c_gsbi3,
3036 &msm8960_device_qup_i2c_gsbi4,
3037 &msm8960_device_qup_i2c_gsbi10,
3038#ifndef CONFIG_MSM_DSPS
3039 &msm8960_device_qup_i2c_gsbi12,
3040#endif
3041 &msm_slim_ctrl,
3042 &msm_device_wcnss_wlan,
3043#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3044 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
3045 &qcrypto_device,
3046#endif
3047
3048#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3049 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3050 &qcedev_device,
3051#endif
3052#ifdef CONFIG_MSM_ROTATOR
3053 &msm_rotator_device,
3054#endif
3055 &msm_device_sps,
3056#ifdef CONFIG_MSM_FAKE_BATTERY
3057 &fish_battery_device,
3058#endif
3059#ifdef CONFIG_ANDROID_PMEM
3060 &android_pmem_device,
3061 &android_pmem_adsp_device,
3062 &android_pmem_audio_device,
3063#endif
3064 &msm_fb_device,
3065 &msm_device_vidc,
3066 &msm_device_bam_dmux,
3067 &msm_fm_platform_init,
Mona Hossain9c430e32011-07-27 11:04:47 -07003068
3069#ifdef CONFIG_HW_RANDOM_MSM
3070 &msm_device_rng,
3071#endif
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06003072 &msm_rpm_device,
Laura Abbottd6183792011-08-19 13:42:24 -07003073#ifdef CONFIG_ION_MSM
3074 &ion_dev,
3075#endif
David Collins4c31a872011-08-31 10:07:10 -07003076 &msm_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003077};
3078
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003079static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003080 &msm8960_device_otg,
3081 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003082 &msm_device_hsusb_host,
3083 &android_usb_device,
3084 &msm_device_vidc,
3085 &mipi_dsi_simulator_panel_device,
3086 &msm_bus_apps_fabric,
3087 &msm_bus_sys_fabric,
3088 &msm_bus_mm_fabric,
3089 &msm_bus_sys_fpb,
3090 &msm_bus_cpss_fpb,
3091 &msm_pcm,
3092 &msm_pcm_routing,
3093 &msm_cpudai0,
3094 &msm_cpudai1,
3095 &msm_cpudai_hdmi_rx,
3096 &msm_cpudai_bt_rx,
3097 &msm_cpudai_bt_tx,
3098 &msm_cpudai_fm_rx,
3099 &msm_cpudai_fm_tx,
3100 &msm_cpu_fe,
3101 &msm_stub_codec,
3102 &msm_voice,
3103 &msm_voip,
3104 &msm_lpa_pcm,
3105
3106#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3107 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
3108 &qcrypto_device,
3109#endif
3110
3111#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3112 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3113 &qcedev_device,
3114#endif
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003115};
3116
3117static struct platform_device *rumi3_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003118 &msm_kgsl_3d0,
3119 &msm_kgsl_2d0,
3120 &msm_kgsl_2d1,
3121 &mipi_dsi_renesas_panel_device,
3122#ifdef CONFIG_MSM_GEMINI
3123 &msm8960_gemini_device,
3124#endif
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003125};
3126
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003127static struct platform_device *cdp_devices[] __initdata = {
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003128 &msm8960_device_otg,
3129 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003130 &msm_device_hsusb_host,
3131 &android_usb_device,
3132 &msm_pcm,
3133 &msm_pcm_routing,
3134 &msm_cpudai0,
3135 &msm_cpudai1,
3136 &msm_cpudai_hdmi_rx,
3137 &msm_cpudai_bt_rx,
3138 &msm_cpudai_bt_tx,
3139 &msm_cpudai_fm_rx,
3140 &msm_cpudai_fm_tx,
3141 &msm_cpu_fe,
3142 &msm_stub_codec,
3143 &msm_kgsl_3d0,
3144#ifdef CONFIG_MSM_KGSL_2D
3145 &msm_kgsl_2d0,
3146 &msm_kgsl_2d1,
3147#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003148#ifdef CONFIG_MSM_GEMINI
3149 &msm8960_gemini_device,
3150#endif
3151 &msm_voice,
3152 &msm_voip,
3153 &msm_lpa_pcm,
Laxminath Kasamcee1d602011-08-01 19:26:57 +05303154 &msm_cpudai_afe_01_rx,
3155 &msm_cpudai_afe_01_tx,
3156 &msm_cpudai_afe_02_rx,
3157 &msm_cpudai_afe_02_tx,
3158 &msm_pcm_afe,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003159#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3160 &hdmi_msm_device,
3161#endif
3162 &msm_pcm_hostless,
3163 &msm_bus_apps_fabric,
3164 &msm_bus_sys_fabric,
3165 &msm_bus_mm_fabric,
3166 &msm_bus_sys_fpb,
3167 &msm_bus_cpss_fpb,
3168};
3169
3170static void __init msm8960_i2c_init(void)
3171{
3172 msm8960_device_qup_i2c_gsbi4.dev.platform_data =
3173 &msm8960_i2c_qup_gsbi4_pdata;
3174
3175 msm8960_device_qup_i2c_gsbi3.dev.platform_data =
3176 &msm8960_i2c_qup_gsbi3_pdata;
3177
3178 msm8960_device_qup_i2c_gsbi10.dev.platform_data =
3179 &msm8960_i2c_qup_gsbi10_pdata;
3180
3181 msm8960_device_qup_i2c_gsbi12.dev.platform_data =
3182 &msm8960_i2c_qup_gsbi12_pdata;
3183}
3184
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003185static void __init msm8960_gfx_init(void)
3186{
3187 uint32_t soc_platform_version = socinfo_get_platform_version();
3188 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1) {
3189 struct kgsl_device_platform_data *kgsl_3d0_pdata =
3190 msm_kgsl_3d0.dev.platform_data;
3191 kgsl_3d0_pdata->pwr_data.pwrlevel[0].gpu_freq =
3192 320000000;
3193 kgsl_3d0_pdata->pwr_data.pwrlevel[1].gpu_freq =
3194 266667000;
3195 }
3196}
3197
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003198static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
3199 .irq_base = PM8921_IRQ_BASE,
3200 .devirq = MSM_GPIO_TO_INT(104),
3201 .irq_trigger_flag = IRQF_TRIGGER_LOW,
3202};
3203
3204static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
3205 .gpio_base = PM8921_GPIO_PM_TO_SYS(1),
3206};
3207
3208static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
3209 .mpp_base = PM8921_MPP_PM_TO_SYS(1),
3210};
3211
3212static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
3213 .rtc_write_enable = false,
3214};
3215
3216static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
3217 .pull_up = 1,
3218 .kpd_trigger_delay_us = 970,
3219 .wakeup = 1,
3220};
3221
Mohan Pallaka002e9e02011-08-05 11:23:22 +05303222/* Rotate lock key is not available so use F1 */
3223#define KEY_ROTATE_LOCK KEY_F1
3224
3225static const unsigned int keymap_liquid[] = {
3226 KEY(0, 0, KEY_VOLUMEUP),
3227 KEY(0, 1, KEY_VOLUMEDOWN),
3228 KEY(1, 3, KEY_ROTATE_LOCK),
3229 KEY(1, 4, KEY_HOME),
3230};
3231
3232static struct matrix_keymap_data keymap_data_liquid = {
3233 .keymap_size = ARRAY_SIZE(keymap_liquid),
3234 .keymap = keymap_liquid,
3235};
3236
3237static struct pm8xxx_keypad_platform_data keypad_data_liquid = {
3238 .input_name = "keypad_8960_liquid",
3239 .input_phys_device = "keypad_8960/input0",
3240 .num_rows = 2,
3241 .num_cols = 5,
3242 .rows_gpio_start = PM8921_GPIO_PM_TO_SYS(9),
3243 .cols_gpio_start = PM8921_GPIO_PM_TO_SYS(1),
3244 .debounce_ms = 15,
3245 .scan_delay_ms = 32,
3246 .row_hold_ns = 91500,
3247 .wakeup = 1,
3248 .keymap_data = &keymap_data_liquid,
3249};
3250
3251
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003252static const unsigned int keymap[] = {
3253 KEY(0, 0, KEY_VOLUMEUP),
3254 KEY(0, 1, KEY_VOLUMEDOWN),
3255 KEY(0, 2, KEY_CAMERA_SNAPSHOT),
3256 KEY(0, 3, KEY_CAMERA_FOCUS),
3257};
3258
3259static struct matrix_keymap_data keymap_data = {
3260 .keymap_size = ARRAY_SIZE(keymap),
3261 .keymap = keymap,
3262};
3263
3264static struct pm8xxx_keypad_platform_data keypad_data = {
3265 .input_name = "keypad_8960",
3266 .input_phys_device = "keypad_8960/input0",
3267 .num_rows = 1,
3268 .num_cols = 5,
3269 .rows_gpio_start = PM8921_GPIO_PM_TO_SYS(9),
3270 .cols_gpio_start = PM8921_GPIO_PM_TO_SYS(1),
3271 .debounce_ms = 15,
3272 .scan_delay_ms = 32,
3273 .row_hold_ns = 91500,
3274 .wakeup = 1,
3275 .keymap_data = &keymap_data,
3276};
3277
3278static const unsigned int keymap_sim[] = {
3279 KEY(0, 0, KEY_7),
3280 KEY(0, 1, KEY_DOWN),
3281 KEY(0, 2, KEY_UP),
3282 KEY(0, 3, KEY_RIGHT),
3283 KEY(0, 4, KEY_ENTER),
3284 KEY(0, 5, KEY_L),
3285 KEY(0, 6, KEY_BACK),
3286 KEY(0, 7, KEY_M),
3287
3288 KEY(1, 0, KEY_LEFT),
3289 KEY(1, 1, KEY_SEND),
3290 KEY(1, 2, KEY_1),
3291 KEY(1, 3, KEY_4),
3292 KEY(1, 4, KEY_CLEAR),
3293 KEY(1, 5, KEY_MSDOS),
3294 KEY(1, 6, KEY_SPACE),
3295 KEY(1, 7, KEY_COMMA),
3296
3297 KEY(2, 0, KEY_6),
3298 KEY(2, 1, KEY_5),
3299 KEY(2, 2, KEY_8),
3300 KEY(2, 3, KEY_3),
3301 KEY(2, 4, KEY_NUMERIC_STAR),
3302 KEY(2, 5, KEY_UP),
3303 KEY(2, 6, KEY_DOWN),
3304 KEY(2, 7, KEY_LEFTSHIFT),
3305
3306 KEY(3, 0, KEY_9),
3307 KEY(3, 1, KEY_NUMERIC_POUND),
3308 KEY(3, 2, KEY_0),
3309 KEY(3, 3, KEY_2),
3310 KEY(3, 4, KEY_SLEEP),
3311 KEY(3, 5, KEY_F1),
3312 KEY(3, 6, KEY_F2),
3313 KEY(3, 7, KEY_F3),
3314
3315 KEY(4, 0, KEY_BACK),
3316 KEY(4, 1, KEY_HOME),
3317 KEY(4, 2, KEY_MENU),
3318 KEY(4, 3, KEY_VOLUMEUP),
3319 KEY(4, 4, KEY_VOLUMEDOWN),
3320 KEY(4, 5, KEY_F4),
3321 KEY(4, 6, KEY_F5),
3322 KEY(4, 7, KEY_F6),
3323
3324 KEY(5, 0, KEY_R),
3325 KEY(5, 1, KEY_T),
3326 KEY(5, 2, KEY_Y),
3327 KEY(5, 3, KEY_LEFTALT),
3328 KEY(5, 4, KEY_KPENTER),
3329 KEY(5, 5, KEY_Q),
3330 KEY(5, 6, KEY_W),
3331 KEY(5, 7, KEY_E),
3332
3333 KEY(6, 0, KEY_F),
3334 KEY(6, 1, KEY_G),
3335 KEY(6, 2, KEY_H),
3336 KEY(6, 3, KEY_CAPSLOCK),
3337 KEY(6, 4, KEY_PAGEUP),
3338 KEY(6, 5, KEY_A),
3339 KEY(6, 6, KEY_S),
3340 KEY(6, 7, KEY_D),
3341
3342 KEY(7, 0, KEY_V),
3343 KEY(7, 1, KEY_B),
3344 KEY(7, 2, KEY_N),
3345 KEY(7, 3, KEY_MENU),
3346 KEY(7, 4, KEY_PAGEDOWN),
3347 KEY(7, 5, KEY_Z),
3348 KEY(7, 6, KEY_X),
3349 KEY(7, 7, KEY_C),
3350
3351 KEY(8, 0, KEY_P),
3352 KEY(8, 1, KEY_J),
3353 KEY(8, 2, KEY_K),
3354 KEY(8, 3, KEY_INSERT),
3355 KEY(8, 4, KEY_LINEFEED),
3356 KEY(8, 5, KEY_U),
3357 KEY(8, 6, KEY_I),
3358 KEY(8, 7, KEY_O),
3359
3360 KEY(9, 0, KEY_4),
3361 KEY(9, 1, KEY_5),
3362 KEY(9, 2, KEY_6),
3363 KEY(9, 3, KEY_7),
3364 KEY(9, 4, KEY_8),
3365 KEY(9, 5, KEY_1),
3366 KEY(9, 6, KEY_2),
3367 KEY(9, 7, KEY_3),
3368
3369 KEY(10, 0, KEY_F7),
3370 KEY(10, 1, KEY_F8),
3371 KEY(10, 2, KEY_F9),
3372 KEY(10, 3, KEY_F10),
3373 KEY(10, 4, KEY_FN),
3374 KEY(10, 5, KEY_9),
3375 KEY(10, 6, KEY_0),
3376 KEY(10, 7, KEY_DOT),
3377
3378 KEY(11, 0, KEY_LEFTCTRL),
3379 KEY(11, 1, KEY_F11),
3380 KEY(11, 2, KEY_ENTER),
3381 KEY(11, 3, KEY_SEARCH),
3382 KEY(11, 4, KEY_DELETE),
3383 KEY(11, 5, KEY_RIGHT),
3384 KEY(11, 6, KEY_LEFT),
3385 KEY(11, 7, KEY_RIGHTSHIFT),
3386 KEY(0, 0, KEY_VOLUMEUP),
3387 KEY(0, 1, KEY_VOLUMEDOWN),
3388 KEY(0, 2, KEY_CAMERA_SNAPSHOT),
3389 KEY(0, 3, KEY_CAMERA_FOCUS),
3390};
3391
3392static struct matrix_keymap_data keymap_data_sim = {
3393 .keymap_size = ARRAY_SIZE(keymap_sim),
3394 .keymap = keymap_sim,
3395};
3396
3397static struct pm8xxx_keypad_platform_data keypad_data_sim = {
3398 .input_name = "keypad_8960",
3399 .input_phys_device = "keypad_8960/input0",
3400 .num_rows = 12,
3401 .num_cols = 8,
3402 .rows_gpio_start = PM8921_GPIO_PM_TO_SYS(9),
3403 .cols_gpio_start = PM8921_GPIO_PM_TO_SYS(1),
3404 .debounce_ms = 15,
3405 .scan_delay_ms = 32,
3406 .row_hold_ns = 91500,
3407 .wakeup = 1,
3408 .keymap_data = &keymap_data_sim,
3409};
3410
Abhijeet Dharmapurikarad742362011-08-29 19:50:02 -07003411static int pm8921_therm_mitigation[] = {
3412 1100,
3413 700,
3414 600,
3415 325,
3416};
3417
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003418static struct pm8921_charger_platform_data pm8921_chg_pdata __devinitdata = {
Abhijeet Dharmapurikar34059332011-08-16 19:19:39 -07003419 .safety_time = 180,
3420 .update_time = 1,
3421 .max_voltage = 4200,
3422 .min_voltage = 3200,
3423 .resume_voltage = 4100,
3424 .term_current = 100,
3425 .cool_temp = 10,
3426 .warm_temp = 40,
3427 .temp_check_period = 1,
Abhijeet Dharmapurikarad742362011-08-29 19:50:02 -07003428 .max_bat_chg_current = 1100,
Abhijeet Dharmapurikar34059332011-08-16 19:19:39 -07003429 .cool_bat_chg_current = 350,
3430 .warm_bat_chg_current = 350,
3431 .cool_bat_voltage = 4100,
3432 .warm_bat_voltage = 4100,
Abhijeet Dharmapurikarad742362011-08-29 19:50:02 -07003433 .thermal_mitigation = pm8921_therm_mitigation,
3434 .thermal_levels = ARRAY_SIZE(pm8921_therm_mitigation),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003435};
3436
3437static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
3438 .priority = 0,
3439};
3440
3441static struct pm8921_bms_platform_data pm8921_bms_pdata __devinitdata = {
3442 .r_sense = 10,
3443 .i_test = 2500,
3444 .v_failure = 3000,
3445 .calib_delay_ms = 600000,
3446 .batt_data = &palladium_1500_data,
3447};
3448
Jay Chokshide4cefb2011-08-04 18:10:44 -07003449#define PM8921_LC_LED_MAX_CURRENT 4 /* I = 4mA */
3450
3451/**
3452 * 'flag' stores three values; led id, led mode, and max current of led.
3453 * The bit packing format is as follow,
3454 * reserved (1 byte) | max_current (2 bytes) | led_mode (1 nibble) |
3455 * led_id (1 nibble)
3456 */
3457#define PM8XXX_SET_FLAG(led_id, led_mode, led_max_current) \
3458 (((led_id << PM8XXX_LED_ID_SHIFT) & PM8XXX_LED_ID_MASK) |\
3459 ((led_mode << PM8XXX_LED_MODE_SHIFT) & PM8XXX_LED_MODE_MASK) |\
3460 ((led_max_current << PM8XXX_LED_MAX_CURRENT_SHIFT) & \
3461 PM8XXX_LED_MAX_CURRENT_MASK))
3462
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003463static struct led_info pm8921_led_info[] = {
3464 [0] = {
Jay Chokshide4cefb2011-08-04 18:10:44 -07003465 .name = "led:usb",
3466 .default_trigger = "usb-online",
3467 .flags = PM8XXX_SET_FLAG(PM8XXX_ID_LED_0,
3468 PM8XXX_LED_MODE_MANUAL,
3469 PM8921_LC_LED_MAX_CURRENT),
3470 },
3471 [1] = {
3472 .name = "led:ac",
3473 .default_trigger = "ac-online",
3474 .flags = PM8XXX_SET_FLAG(PM8XXX_ID_LED_1,
3475 PM8XXX_LED_MODE_MANUAL,
3476 PM8921_LC_LED_MAX_CURRENT),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003477 },
3478};
3479
3480static struct led_platform_data pm8xxx_leds_pdata = {
3481 .num_leds = ARRAY_SIZE(pm8921_led_info),
3482 .leds = pm8921_led_info,
3483};
3484
3485static struct pm8921_platform_data pm8921_platform_data __devinitdata = {
3486 .irq_pdata = &pm8xxx_irq_pdata,
3487 .gpio_pdata = &pm8xxx_gpio_pdata,
3488 .mpp_pdata = &pm8xxx_mpp_pdata,
3489 .rtc_pdata = &pm8xxx_rtc_pdata,
3490 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
3491 .keypad_pdata = &keypad_data,
3492 .misc_pdata = &pm8xxx_misc_pdata,
3493 .regulator_pdatas = msm_pm8921_regulator_pdata,
3494 .charger_pdata = &pm8921_chg_pdata,
3495 .bms_pdata = &pm8921_bms_pdata,
3496 .adc_pdata = &pm8921_adc_pdata,
3497 .leds_pdata = &pm8xxx_leds_pdata,
3498};
3499
3500static struct msm_ssbi_platform_data msm8960_ssbi_pm8921_pdata __devinitdata = {
3501 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
3502 .slave = {
3503 .name = "pm8921-core",
3504 .platform_data = &pm8921_platform_data,
3505 },
3506};
3507
3508static void msm8960_wcnss_init(void)
3509{
3510 int i, ret, j;
3511
3512 for (i = 0; i < ARRAY_SIZE(wcnss_5wire_interface); i++) {
3513 ret = gpio_request(wcnss_5wire_interface[i].gpio,
3514 "wcnss_5_wire");
3515 if (ret) {
3516 pr_err("wcnss_5_wire gpio %d failed: %d\n",
3517 wcnss_5wire_interface[i].gpio, ret);
3518 goto fail;
3519 }
3520 }
3521
3522 pr_info("%s: Iris 5-wire gpios configured\n", __func__);
3523
3524 return;
3525
3526fail:
3527 for (j = 0; j < i; j++)
3528 gpio_free(wcnss_5wire_interface[j].gpio);
3529}
3530
Stepan Moskovchenko41d168272011-08-09 17:09:42 -07003531#ifdef CONFIG_KS8851
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003532static int ethernet_init(void)
3533{
3534 int ret;
3535 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
3536 if (ret) {
3537 pr_err("ks8851 gpio_request failed: %d\n", ret);
3538 goto fail;
3539 }
3540
3541 ret = gpio_request(KS8851_RST_GPIO, "ks8851_rst");
3542 if (ret) {
3543 pr_err("ks8851 gpio_request failed: %d\n", ret);
3544 goto fail_rst;
3545 }
3546
3547 ret = gpio_request(FPGA_CS_GPIO, "fpga_cs");
3548 if (ret) {
3549 pr_err("ks8851 gpio_request failed: %d\n", ret);
3550 goto fail_cs;
3551 }
3552
3553 gpio_direction_output(FPGA_CS_GPIO, 1);
3554 gpio_direction_output(KS8851_RST_GPIO, 1);
3555 return 0;
3556fail_cs:
3557 gpio_free(KS8851_RST_GPIO);
3558fail_rst:
3559 gpio_free(KS8851_IRQ_GPIO);
3560fail:
3561 return ret;
3562}
Stepan Moskovchenko41d168272011-08-09 17:09:42 -07003563#else
3564static int ethernet_init(void)
3565{
3566 return 0;
3567}
3568#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003569
3570static struct msm_cpuidle_state msm_cstates[] __initdata = {
3571 {0, 0, "C0", "WFI",
3572 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
3573
3574 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
3575 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
3576
3577 {0, 2, "C2", "POWER_COLLAPSE",
3578 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
3579
3580 {1, 0, "C0", "WFI",
3581 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
3582
3583 {1, 1, "C1", "STANDALONE_POWER_COLLAPSE",
3584 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
3585};
3586
3587static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
3588 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
3589 .idle_supported = 1,
3590 .suspend_supported = 1,
3591 .idle_enabled = 0,
3592 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003593 },
3594
3595 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
3596 .idle_supported = 1,
3597 .suspend_supported = 1,
3598 .idle_enabled = 0,
3599 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003600 },
3601
3602 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
3603 .idle_supported = 1,
3604 .suspend_supported = 1,
3605 .idle_enabled = 1,
3606 .suspend_enabled = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003607 },
3608
3609 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
3610 .idle_supported = 0,
3611 .suspend_supported = 1,
3612 .idle_enabled = 0,
3613 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003614 },
3615
3616 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
3617 .idle_supported = 1,
3618 .suspend_supported = 1,
3619 .idle_enabled = 0,
3620 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003621 },
3622
3623 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
3624 .idle_supported = 1,
3625 .suspend_supported = 0,
3626 .idle_enabled = 1,
3627 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003628 },
3629};
3630
3631static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
3632 {
3633 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
3634 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3635 true,
3636 1, 8000, 100000, 1,
3637 },
3638
3639 {
3640 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
3641 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3642 true,
3643 1500, 5000, 60100000, 3000,
3644 },
3645
3646 {
3647 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3648 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
3649 false,
3650 1800, 5000, 60350000, 3500,
3651 },
3652
3653 {
3654 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3655 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
3656 false,
3657 2800, 2500, 65350000, 4800,
3658 },
3659
3660 {
3661 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3662 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
3663 false,
3664 3800, 4500, 67850000, 5500,
3665 },
3666
3667 {
3668 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3669 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
3670 false,
3671 4800, 2000, 71850000, 6800,
3672 },
3673
3674 {
3675 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3676 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
3677 false,
3678 6800, 500, 75850000, 8800,
3679 },
3680
3681 {
3682 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3683 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
3684 false,
3685 7800, 0, 76350000, 9800,
3686 },
3687};
3688
3689#ifdef CONFIG_I2C
3690#define I2C_SURF 1
3691#define I2C_FFA (1 << 1)
3692#define I2C_RUMI (1 << 2)
3693#define I2C_SIM (1 << 3)
3694#define I2C_FLUID (1 << 4)
Amir Samuelov05f87802011-08-27 18:30:12 +03003695#define I2C_LIQUID (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003696
3697struct i2c_registry {
3698 u8 machs;
3699 int bus;
3700 struct i2c_board_info *info;
3701 int len;
3702};
3703
3704#ifdef CONFIG_MSM_CAMERA
3705static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
3706#ifdef CONFIG_IMX074
3707 {
3708 I2C_BOARD_INFO("imx074", 0x1A),
3709 },
3710#endif
3711#ifdef CONFIG_OV2720
3712 {
3713 I2C_BOARD_INFO("ov2720", 0x6C),
3714 },
3715#endif
Kevin Chandfecce22011-07-13 10:52:41 -07003716 {
3717 I2C_BOARD_INFO("qs_mt9p017", 0x6C >> 1),
3718 },
Nishant Pandit474f2252011-07-23 23:17:56 +05303719#ifdef CONFIG_MSM_CAMERA_FLASH_SC628A
3720 {
3721 I2C_BOARD_INFO("sc628a", 0x6E),
3722 },
3723#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003724};
3725#endif
3726
3727/* Sensors DSPS platform data */
3728#ifdef CONFIG_MSM_DSPS
3729#define DSPS_PIL_GENERIC_NAME "dsps"
3730#endif /* CONFIG_MSM_DSPS */
3731
3732static void __init msm8960_init_dsps(void)
3733{
3734#ifdef CONFIG_MSM_DSPS
3735 struct msm_dsps_platform_data *pdata =
3736 msm_dsps_device.dev.platform_data;
3737 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
3738 pdata->gpios = NULL;
3739 pdata->gpios_num = 0;
3740
3741 platform_device_register(&msm_dsps_device);
3742#endif /* CONFIG_MSM_DSPS */
3743}
3744
3745static struct i2c_registry msm8960_i2c_devices[] __initdata = {
3746#ifdef CONFIG_MSM_CAMERA
3747 {
Amir Samuelov05f87802011-08-27 18:30:12 +03003748 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_LIQUID | I2C_RUMI,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003749 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
3750 msm_camera_boardinfo,
3751 ARRAY_SIZE(msm_camera_boardinfo),
3752 },
3753#endif
3754 {
3755 I2C_SURF | I2C_FFA | I2C_FLUID,
3756 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3757 cyttsp_info,
3758 ARRAY_SIZE(cyttsp_info),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -07003759 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003760};
3761#endif /* CONFIG_I2C */
3762
3763static void __init register_i2c_devices(void)
3764{
3765#ifdef CONFIG_I2C
3766 u8 mach_mask = 0;
3767 int i;
3768
3769 /* Build the matching 'supported_machs' bitmask */
3770 if (machine_is_msm8960_cdp())
3771 mach_mask = I2C_SURF;
3772 else if (machine_is_msm8960_rumi3())
3773 mach_mask = I2C_RUMI;
3774 else if (machine_is_msm8960_sim())
3775 mach_mask = I2C_SIM;
Amy Maloche2d028032011-07-20 14:08:06 -07003776 else if (machine_is_msm8960_fluid())
3777 mach_mask = I2C_FLUID;
Amir Samuelov05f87802011-08-27 18:30:12 +03003778 else if (machine_is_msm8960_liquid())
3779 mach_mask = I2C_LIQUID;
Amy Maloche1b0663f2011-08-02 16:46:22 -07003780 else if (machine_is_msm8960_mtp())
3781 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003782 else
3783 pr_err("unmatched machine ID in register_i2c_devices\n");
3784
3785 /* Run the array and install devices as appropriate */
3786 for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
3787 if (msm8960_i2c_devices[i].machs & mach_mask)
3788 i2c_register_board_info(msm8960_i2c_devices[i].bus,
3789 msm8960_i2c_devices[i].info,
3790 msm8960_i2c_devices[i].len);
3791 }
3792#endif
3793}
3794
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003795static void __init msm8960_sim_init(void)
3796{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003797 if (socinfo_init() < 0)
3798 pr_err("socinfo_init() failed!\n");
3799
3800 BUG_ON(msm_rpm_init(&msm_rpm_data));
3801 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
3802 ARRAY_SIZE(msm_rpmrs_levels)));
3803 regulator_suppress_info_printing();
David Collins26f05562011-06-20 09:56:28 -07003804 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003805 msm_clock_init(&msm8960_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003806 msm8960_device_ssbi_pm8921.dev.platform_data =
3807 &msm8960_ssbi_pm8921_pdata;
3808 pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003809
3810 /* Simulator supports a QWERTY keypad */
3811 pm8921_platform_data.keypad_pdata = &keypad_data_sim;
3812
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003813 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
3814 msm8960_device_gadget_peripheral.dev.parent = &msm8960_device_otg.dev;
3815 msm_device_hsusb_host.dev.parent = &msm8960_device_otg.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003816 gpiomux_init();
3817 ethernet_init();
3818 msm8960_i2c_init();
3819 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3820 msm_spm_l2_init(msm_spm_l2_data);
3821 msm8960_init_buses();
3822 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
3823 pm8921_gpio_mpp_init();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003824 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
Matt Wagantallec57f062011-08-16 23:54:46 -07003825 acpuclk_init(&acpuclk_8960_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003826
3827 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3828 &msm8960_qup_spi_gsbi1_pdata;
3829 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
3830
3831 msm8960_init_mmc();
3832 msm_fb_add_devices();
3833 slim_register_board_info(msm_slim_devices,
3834 ARRAY_SIZE(msm_slim_devices));
3835 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
3836 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
3837 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
3838 msm_pm_data);
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003839}
3840
3841static void __init msm8960_rumi3_init(void)
3842{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003843 if (socinfo_init() < 0)
3844 pr_err("socinfo_init() failed!\n");
3845
3846 BUG_ON(msm_rpm_init(&msm_rpm_data));
3847 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
3848 ARRAY_SIZE(msm_rpmrs_levels)));
3849 regulator_suppress_info_printing();
David Collins26f05562011-06-20 09:56:28 -07003850 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003851 msm_clock_init(&msm8960_dummy_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003852 gpiomux_init();
3853 ethernet_init();
3854 msm8960_device_ssbi_pm8921.dev.platform_data =
3855 &msm8960_ssbi_pm8921_pdata;
3856 pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len;
3857 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3858 &msm8960_qup_spi_gsbi1_pdata;
3859 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
3860 msm8960_i2c_init();
3861 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3862 msm_spm_l2_init(msm_spm_l2_data);
3863 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
3864 pm8921_gpio_mpp_init();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003865 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003866 msm8960_init_mmc();
3867
3868 register_i2c_devices();
3869 msm_fb_add_devices();
3870 slim_register_board_info(msm_slim_devices,
3871 ARRAY_SIZE(msm_slim_devices));
3872 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
3873 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
3874 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
3875 msm_pm_data);
3876}
3877
3878static void __init msm8960_cdp_init(void)
3879{
3880 if (socinfo_init() < 0)
3881 pr_err("socinfo_init() failed!\n");
3882
3883 BUG_ON(msm_rpm_init(&msm_rpm_data));
3884 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
3885 ARRAY_SIZE(msm_rpmrs_levels)));
3886 regulator_suppress_info_printing();
3887 if (msm_xo_init())
3888 pr_err("Failed to initialize XO votes\n");
David Collins26f05562011-06-20 09:56:28 -07003889 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003890 msm_clock_init(&msm8960_clock_init_data);
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003891 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
3892 msm8960_device_gadget_peripheral.dev.parent = &msm8960_device_otg.dev;
3893 msm_device_hsusb_host.dev.parent = &msm8960_device_otg.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003894 gpiomux_init();
3895 ethernet_init();
Mohan Pallaka002e9e02011-08-05 11:23:22 +05303896 if (machine_is_msm8960_liquid())
3897 pm8921_platform_data.keypad_pdata = &keypad_data_liquid;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003898 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3899 &msm8960_qup_spi_gsbi1_pdata;
3900 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
3901 msm8960_device_ssbi_pm8921.dev.platform_data =
3902 &msm8960_ssbi_pm8921_pdata;
3903 pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len;
3904 msm8960_i2c_init();
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003905 msm8960_gfx_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003906 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3907 msm_spm_l2_init(msm_spm_l2_data);
3908 msm8960_init_buses();
3909 platform_add_devices(msm_footswitch_devices,
3910 msm_num_footswitch_devices);
David Collinsb10be1d2011-09-02 10:29:31 -07003911 if (machine_is_msm8960_liquid())
3912 platform_device_register(&msm8960_device_ext_3p3v_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003913 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
3914 pm8921_gpio_mpp_init();
3915 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
3916 msm8960_init_cam();
3917 msm8960_init_mmc();
Matt Wagantallec57f062011-08-16 23:54:46 -07003918 acpuclk_init(&acpuclk_8960_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003919 register_i2c_devices();
3920 msm8960_wcnss_init();
3921 msm_fb_add_devices();
3922 slim_register_board_info(msm_slim_devices,
3923 ARRAY_SIZE(msm_slim_devices));
3924 msm8960_init_dsps();
3925 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
3926 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
3927 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
3928 msm_pm_data);
Larry Bassela7eadea2011-07-14 10:46:00 -07003929 change_memory_power = &msm8960_change_memory_power;
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003930}
3931
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003932MACHINE_START(MSM8960_SIM, "QCT MSM8960 SIMULATOR")
3933 .map_io = msm8960_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003934 .reserve = msm8960_reserve,
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003935 .init_irq = msm8960_init_irq,
3936 .timer = &msm_timer,
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003937 .init_machine = msm8960_sim_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003938 .init_early = msm8960_allocate_memory_regions,
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003939MACHINE_END
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003940
3941MACHINE_START(MSM8960_RUMI3, "QCT MSM8960 RUMI3")
3942 .map_io = msm8960_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003943 .reserve = msm8960_reserve,
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003944 .init_irq = msm8960_init_irq,
3945 .timer = &msm_timer,
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003946 .init_machine = msm8960_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003947 .init_early = msm8960_allocate_memory_regions,
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003948MACHINE_END
3949
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003950MACHINE_START(MSM8960_CDP, "QCT MSM8960 CDP")
3951 .map_io = msm8960_map_io,
3952 .reserve = msm8960_reserve,
3953 .init_irq = msm8960_init_irq,
3954 .timer = &msm_timer,
3955 .init_machine = msm8960_cdp_init,
3956 .init_early = msm8960_allocate_memory_regions,
3957MACHINE_END
3958
3959MACHINE_START(MSM8960_MTP, "QCT MSM8960 MTP")
3960 .map_io = msm8960_map_io,
3961 .reserve = msm8960_reserve,
3962 .init_irq = msm8960_init_irq,
3963 .timer = &msm_timer,
3964 .init_machine = msm8960_cdp_init,
3965 .init_early = msm8960_allocate_memory_regions,
3966MACHINE_END
3967
3968MACHINE_START(MSM8960_FLUID, "QCT MSM8960 FLUID")
3969 .map_io = msm8960_map_io,
3970 .reserve = msm8960_reserve,
3971 .init_irq = msm8960_init_irq,
3972 .timer = &msm_timer,
3973 .init_machine = msm8960_cdp_init,
3974 .init_early = msm8960_allocate_memory_regions,
3975MACHINE_END
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003976
3977MACHINE_START(MSM8960_LIQUID, "QCT MSM8960 LIQUID")
3978 .map_io = msm8960_map_io,
3979 .reserve = msm8960_reserve,
3980 .init_irq = msm8960_init_irq,
3981 .timer = &msm_timer,
3982 .init_machine = msm8960_cdp_init,
3983 .init_early = msm8960_allocate_memory_regions,
3984MACHINE_END