blob: 9eade592851abb62ad36e57f5b59b6207baf281a [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
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001067static void __init msm8960_init_cam(void)
1068{
1069 int i;
1070 struct platform_device *cam_dev[] = {
1071 &msm8960_camera_sensor_imx074,
1072 &msm8960_camera_sensor_ov2720,
Kevin Chandfecce22011-07-13 10:52:41 -07001073 &msm8960_camera_sensor_qs_mt9p017,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001074 };
1075
1076 for (i = 0; i < ARRAY_SIZE(cam_dev); i++) {
1077 struct msm_camera_sensor_info *s_info;
1078 s_info = cam_dev[i]->dev.platform_data;
1079 msm_get_cam_resources(s_info);
1080 platform_device_register(cam_dev[i]);
1081 }
1082}
1083#endif
1084
1085#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001086/* prim = 1366 x 768 x 3(bpp) x 3(pages) */
1087#define MSM_FB_PRIM_BUF_SIZE roundup(1366 * 768 * 3 * 3, 0x10000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001088#else
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001089/* prim = 1366 x 768 x 3(bpp) x 2(pages) */
1090#define MSM_FB_PRIM_BUF_SIZE roundup(1366 * 768 * 3 * 2, 0x10000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001091#endif
1092
1093#ifdef CONFIG_FB_MSM_MIPI_DSI
Nagamalleswararao Ganji0b8dbd02011-08-18 20:46:59 -07001094#define MIPI_DSI_WRITEBACK_SIZE (1024 * 600 * 3 * 2)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001095#else
1096#define MIPI_DSI_WRITEBACK_SIZE 0
1097#endif
1098
1099#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1100/* hdmi = 1920 x 1088 x 2(bpp) x 1(page) */
1101#define MSM_FB_EXT_BUF_SIZE 0x3FC000
1102#elif defined(CONFIG_FB_MSM_TVOUT)
1103/* tvout = 720 x 576 x 2(bpp) x 2(pages) */
1104#define MSM_FB_EXT_BUF_SIZE 0x195000
1105#else /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1106#define MSM_FB_EXT_BUF_SIZE 0
1107#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1108
1109#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE +\
1110 MIPI_DSI_WRITEBACK_SIZE, 4096)
1111
1112#define MDP_VSYNC_GPIO 0
1113
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001114#define TOSHIBA_PANEL_NAME "mipi_video_toshiba_wsvga"
1115#define TOSHIBA_PANEL_NAME_LEN 24
1116#define CHIMEI_PANEL_NAME "mipi_chimei_wxga"
1117#define CHIMEI_PANEL_NAME_LEN 16
1118
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001119static struct resource msm_fb_resources[] = {
1120 {
1121 .flags = IORESOURCE_DMA,
1122 }
1123};
1124
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001125#ifdef CONFIG_FB_MSM_MIPI_PANEL_DETECT
1126static int msm_fb_detect_panel(const char *name)
1127{
1128 if (machine_is_msm8960_liquid()) {
1129 if (!strncmp(name, CHIMEI_PANEL_NAME, CHIMEI_PANEL_NAME_LEN))
1130 return 0;
1131 } else {
1132 if (!strncmp(name, TOSHIBA_PANEL_NAME, TOSHIBA_PANEL_NAME_LEN))
1133 return 0;
1134 }
1135
1136 pr_warning("%s: not supported '%s'", __func__, name);
1137
1138 return -ENODEV;
1139}
1140
1141static struct msm_fb_platform_data msm_fb_pdata = {
1142 .detect_client = msm_fb_detect_panel,
1143};
1144#endif /* CONFIG_FB_MSM_MIPI_PANEL_DETECT */
1145
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001146static struct platform_device msm_fb_device = {
1147 .name = "msm_fb",
1148 .id = 0,
1149 .num_resources = ARRAY_SIZE(msm_fb_resources),
1150 .resource = msm_fb_resources,
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001151#ifdef CONFIG_FB_MSM_MIPI_PANEL_DETECT
1152 .dev.platform_data = &msm_fb_pdata,
1153#endif /* CONFIG_FB_MSM_MIPI_PANEL_DETECT */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001154};
1155
1156static bool dsi_power_on;
1157
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001158/**
1159 * LiQUID panel on/off
1160 *
1161 * @param on
1162 *
1163 * @return int
1164 */
1165static int mipi_dsi_liquid_panel_power(int on)
1166{
1167 static struct regulator *reg_l2, *reg_ext_3p3v;
1168 static int gpio21, gpio24, gpio43;
1169 int rc;
1170
1171 pr_info("%s: on=%d\n", __func__, on);
1172
1173 gpio21 = PM8921_GPIO_PM_TO_SYS(21); /* disp power enable_n */
1174 gpio43 = PM8921_GPIO_PM_TO_SYS(43); /* Displays Enable (rst_n)*/
1175 gpio24 = PM8921_GPIO_PM_TO_SYS(24); /* Backlight PWM */
1176
1177 if (!dsi_power_on) {
1178
1179 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
1180 "dsi_vdda");
1181 if (IS_ERR(reg_l2)) {
1182 pr_err("could not get 8921_l2, rc = %ld\n",
1183 PTR_ERR(reg_l2));
1184 return -ENODEV;
1185 }
1186
1187 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
1188 if (rc) {
1189 pr_err("set_voltage l2 failed, rc=%d\n", rc);
1190 return -EINVAL;
1191 }
1192
1193 reg_ext_3p3v = regulator_get(&msm_mipi_dsi1_device.dev,
1194 "vdd_lvds_3p3v");
1195 if (IS_ERR(reg_ext_3p3v)) {
1196 pr_err("could not get reg_ext_3p3v, rc = %ld\n",
1197 PTR_ERR(reg_ext_3p3v));
1198 return -ENODEV;
1199 }
1200
1201 rc = gpio_request(gpio21, "disp_pwr_en_n");
1202 if (rc) {
1203 pr_err("request gpio 21 failed, rc=%d\n", rc);
1204 return -ENODEV;
1205 }
1206
1207 rc = gpio_request(gpio43, "disp_rst_n");
1208 if (rc) {
1209 pr_err("request gpio 43 failed, rc=%d\n", rc);
1210 return -ENODEV;
1211 }
1212
1213 rc = gpio_request(gpio24, "disp_backlight_pwm");
1214 if (rc) {
1215 pr_err("request gpio 24 failed, rc=%d\n", rc);
1216 return -ENODEV;
1217 }
1218
1219 dsi_power_on = true;
1220 }
1221
1222 if (on) {
1223 rc = regulator_set_optimum_mode(reg_l2, 100000);
1224 if (rc < 0) {
1225 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1226 return -EINVAL;
1227 }
1228 rc = regulator_enable(reg_l2);
1229 if (rc) {
1230 pr_err("enable l2 failed, rc=%d\n", rc);
1231 return -ENODEV;
1232 }
1233
1234 rc = regulator_enable(reg_ext_3p3v);
1235 if (rc) {
1236 pr_err("enable reg_ext_3p3v failed, rc=%d\n", rc);
1237 return -ENODEV;
1238 }
1239
1240 /* set reset pin before power enable */
1241 gpio_set_value_cansleep(gpio43, 0); /* disp disable (resx=0) */
1242
1243 gpio_set_value_cansleep(gpio21, 0); /* disp power enable_n */
1244 msleep(20);
1245 gpio_set_value_cansleep(gpio43, 1); /* disp enable */
1246 msleep(20);
1247 gpio_set_value_cansleep(gpio43, 0); /* disp enable */
1248 msleep(20);
1249 gpio_set_value_cansleep(gpio43, 1); /* disp enable */
1250 msleep(20);
1251 } else {
1252 gpio_set_value_cansleep(gpio43, 0);
1253 gpio_set_value_cansleep(gpio21, 1);
1254
1255 rc = regulator_disable(reg_l2);
1256 if (rc) {
1257 pr_err("disable reg_l2 failed, rc=%d\n", rc);
1258 return -ENODEV;
1259 }
1260 rc = regulator_disable(reg_ext_3p3v);
1261 if (rc) {
1262 pr_err("disable reg_ext_3p3v failed, rc=%d\n", rc);
1263 return -ENODEV;
1264 }
1265 rc = regulator_set_optimum_mode(reg_l2, 100);
1266 if (rc < 0) {
1267 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1268 return -EINVAL;
1269 }
1270 }
1271
1272 return 0;
1273}
1274
1275static int mipi_dsi_cdp_panel_power(int on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001276{
1277 static struct regulator *reg_l8, *reg_l23, *reg_l2;
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07001278 static int gpio43;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001279 int rc;
1280
1281 struct pm_gpio gpio43_param = {
1282 .direction = PM_GPIO_DIR_OUT,
1283 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
1284 .output_value = 0,
1285 .pull = PM_GPIO_PULL_NO,
1286 .vin_sel = 2,
1287 .out_strength = PM_GPIO_STRENGTH_HIGH,
1288 .function = PM_GPIO_FUNC_PAIRED,
1289 .inv_int_pol = 0,
1290 .disable_pin = 0,
1291 };
1292
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001293 pr_info("%s: state : %d\n", __func__, on);
1294
1295 if (!dsi_power_on) {
1296
1297 reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev,
1298 "dsi_vdc");
1299 if (IS_ERR(reg_l8)) {
1300 pr_err("could not get 8921_l8, rc = %ld\n",
1301 PTR_ERR(reg_l8));
1302 return -ENODEV;
1303 }
1304
1305 reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev,
1306 "dsi_vddio");
1307 if (IS_ERR(reg_l23)) {
1308 pr_err("could not get 8921_l23, rc = %ld\n",
1309 PTR_ERR(reg_l23));
1310 return -ENODEV;
1311 }
1312
1313 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
1314 "dsi_vdda");
1315 if (IS_ERR(reg_l2)) {
1316 pr_err("could not get 8921_l2, rc = %ld\n",
1317 PTR_ERR(reg_l2));
1318 return -ENODEV;
1319 }
1320
1321 rc = regulator_set_voltage(reg_l8, 2800000, 3000000);
1322 if (rc) {
1323 pr_err("set_voltage l8 failed, rc=%d\n", rc);
1324 return -EINVAL;
1325 }
1326 rc = regulator_set_voltage(reg_l23, 1800000, 1800000);
1327 if (rc) {
1328 pr_err("set_voltage l23 failed, rc=%d\n", rc);
1329 return -EINVAL;
1330 }
1331 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
1332 if (rc) {
1333 pr_err("set_voltage l2 failed, rc=%d\n", rc);
1334 return -EINVAL;
1335 }
1336
1337 gpio43 = PM8921_GPIO_PM_TO_SYS(43);
1338 rc = gpio_request(gpio43, "disp_rst_n");
1339 if (rc) {
1340 pr_err("request gpio 43 failed, rc=%d\n", rc);
1341 return -ENODEV;
1342 }
1343
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001344 dsi_power_on = true;
1345 }
1346
1347 if (on) {
1348 rc = regulator_set_optimum_mode(reg_l8, 100000);
1349 if (rc < 0) {
1350 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
1351 return -EINVAL;
1352 }
1353 rc = regulator_set_optimum_mode(reg_l23, 100000);
1354 if (rc < 0) {
1355 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1356 return -EINVAL;
1357 }
1358 rc = regulator_set_optimum_mode(reg_l2, 100000);
1359 if (rc < 0) {
1360 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1361 return -EINVAL;
1362 }
1363 rc = regulator_enable(reg_l8);
1364 if (rc) {
1365 pr_err("enable l8 failed, rc=%d\n", rc);
1366 return -ENODEV;
1367 }
1368 rc = regulator_enable(reg_l23);
1369 if (rc) {
1370 pr_err("enable l8 failed, rc=%d\n", rc);
1371 return -ENODEV;
1372 }
1373 rc = regulator_enable(reg_l2);
1374 if (rc) {
1375 pr_err("enable l2 failed, rc=%d\n", rc);
1376 return -ENODEV;
1377 }
1378
1379 gpio43_param.pull = PM_GPIO_PULL_NO;
1380 rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
1381 if (rc) {
1382 pr_err("gpio_config 43 failed (1), rc=%d\n", rc);
1383 return -EINVAL;
1384 }
1385 gpio43_param.pull = PM_GPIO_PULL_UP_30;
1386 rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
1387 if (rc) {
1388 pr_err("gpio_config 43 failed (2), rc=%d\n", rc);
1389 return -EINVAL;
1390 }
1391 gpio43_param.pull = PM_GPIO_PULL_NO;
1392 rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
1393 if (rc) {
1394 pr_err("gpio_config 43 failed (3), rc=%d\n", rc);
1395 return -EINVAL;
1396 }
1397 gpio43_param.pull = PM_GPIO_PULL_UP_30;
1398 rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
1399 if (rc) {
1400 pr_err("gpio_config 43 failed (4), rc=%d\n", rc);
1401 return -EINVAL;
1402 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001403 gpio_set_value_cansleep(gpio43, 1);
1404 } else {
1405 rc = regulator_set_optimum_mode(reg_l8, 100);
1406 if (rc < 0) {
1407 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
1408 return -EINVAL;
1409 }
1410 rc = regulator_set_optimum_mode(reg_l23, 100);
1411 if (rc < 0) {
1412 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1413 return -EINVAL;
1414 }
1415 rc = regulator_set_optimum_mode(reg_l2, 100);
1416 if (rc < 0) {
1417 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1418 return -EINVAL;
1419 }
1420 gpio_set_value_cansleep(gpio43, 0);
1421 }
1422 return 0;
1423}
1424
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001425static int mipi_dsi_panel_power(int on)
1426{
1427 int ret;
1428
1429 pr_info("%s: on=%d\n", __func__, on);
1430
1431 if (machine_is_msm8960_liquid())
1432 ret = mipi_dsi_liquid_panel_power(on);
1433 else
1434 ret = mipi_dsi_cdp_panel_power(on);
1435
1436 return ret;
1437}
1438
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001439static struct mipi_dsi_platform_data mipi_dsi_pdata = {
1440 .vsync_gpio = MDP_VSYNC_GPIO,
1441 .dsi_power_save = mipi_dsi_panel_power,
1442};
1443
1444#ifdef CONFIG_MSM_BUS_SCALING
1445
1446static struct msm_bus_vectors mdp_init_vectors[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001447 {
1448 .src = MSM_BUS_MASTER_MDP_PORT0,
1449 .dst = MSM_BUS_SLAVE_EBI_CH0,
1450 .ab = 0,
1451 .ib = 0,
1452 },
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001453};
1454
1455static struct msm_bus_vectors mdp_ui_vectors[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001456 {
1457 .src = MSM_BUS_MASTER_MDP_PORT0,
1458 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001459 .ab = 216000000 * 2,
1460 .ib = 270000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001461 },
1462};
1463
1464static struct msm_bus_vectors mdp_vga_vectors[] = {
1465 /* VGA and less video */
1466 {
1467 .src = MSM_BUS_MASTER_MDP_PORT0,
1468 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001469 .ab = 216000000 * 2,
1470 .ib = 270000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001471 },
1472};
1473
1474static struct msm_bus_vectors mdp_720p_vectors[] = {
1475 /* 720p and less video */
1476 {
1477 .src = MSM_BUS_MASTER_MDP_PORT0,
1478 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001479 .ab = 230400000 * 2,
1480 .ib = 288000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001481 },
1482};
1483
1484static struct msm_bus_vectors mdp_1080p_vectors[] = {
1485 /* 1080p and less video */
1486 {
1487 .src = MSM_BUS_MASTER_MDP_PORT0,
1488 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001489 .ab = 334080000 * 2,
1490 .ib = 417600000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001491 },
1492};
1493
1494static struct msm_bus_paths mdp_bus_scale_usecases[] = {
1495 {
1496 ARRAY_SIZE(mdp_init_vectors),
1497 mdp_init_vectors,
1498 },
1499 {
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001500 ARRAY_SIZE(mdp_ui_vectors),
1501 mdp_ui_vectors,
1502 },
1503 {
1504 ARRAY_SIZE(mdp_ui_vectors),
1505 mdp_ui_vectors,
1506 },
1507 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001508 ARRAY_SIZE(mdp_vga_vectors),
1509 mdp_vga_vectors,
1510 },
1511 {
1512 ARRAY_SIZE(mdp_720p_vectors),
1513 mdp_720p_vectors,
1514 },
1515 {
1516 ARRAY_SIZE(mdp_1080p_vectors),
1517 mdp_1080p_vectors,
1518 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001519};
1520
1521static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
1522 mdp_bus_scale_usecases,
1523 ARRAY_SIZE(mdp_bus_scale_usecases),
1524 .name = "mdp",
1525};
1526
1527#endif
1528
1529int mdp_core_clk_rate_table[] = {
1530 85330000,
1531 85330000,
Nagamalleswararao Ganjiad31c982011-08-15 23:24:17 -07001532 160000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001533 200000000,
1534};
1535
1536static struct msm_panel_common_pdata mdp_pdata = {
1537 .gpio = MDP_VSYNC_GPIO,
1538 .mdp_core_clk_rate = 85330000,
1539 .mdp_core_clk_table = mdp_core_clk_rate_table,
1540 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
1541#ifdef CONFIG_MSM_BUS_SCALING
1542 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
1543#endif
1544 .mdp_rev = MDP_REV_42,
1545};
1546
1547static struct platform_device mipi_dsi_renesas_panel_device = {
1548 .name = "mipi_renesas",
1549 .id = 0,
1550};
1551
1552static struct platform_device mipi_dsi_simulator_panel_device = {
1553 .name = "mipi_simulator",
1554 .id = 0,
1555};
1556
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07001557#define LPM_CHANNEL0 0
1558static int toshiba_gpio[] = {LPM_CHANNEL0};
1559
1560static struct mipi_dsi_panel_platform_data toshiba_pdata = {
1561 .gpio = toshiba_gpio,
1562};
1563
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001564static struct platform_device mipi_dsi_toshiba_panel_device = {
1565 .name = "mipi_toshiba",
1566 .id = 0,
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07001567 .dev = {
1568 .platform_data = &toshiba_pdata,
1569 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001570};
1571
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001572static int dsi2lvds_gpio[2] = {
1573 0,/* Backlight PWM-ID=0 for PMIC-GPIO#24 */
1574 0x1F08 /* DSI2LVDS Bridge GPIO Output, mask=0x1f, out=0x08 */
1575 };
1576
1577static struct msm_panel_common_pdata mipi_dsi2lvds_pdata = {
1578 .gpio_num = dsi2lvds_gpio,
1579};
1580
1581static struct platform_device mipi_dsi2lvds_bridge_device = {
1582 .name = "mipi_tc358764",
1583 .id = 0,
1584 .dev.platform_data = &mipi_dsi2lvds_pdata,
1585};
1586
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001587#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1588static struct resource hdmi_msm_resources[] = {
1589 {
1590 .name = "hdmi_msm_qfprom_addr",
1591 .start = 0x00700000,
1592 .end = 0x007060FF,
1593 .flags = IORESOURCE_MEM,
1594 },
1595 {
1596 .name = "hdmi_msm_hdmi_addr",
1597 .start = 0x04A00000,
1598 .end = 0x04A00FFF,
1599 .flags = IORESOURCE_MEM,
1600 },
1601 {
1602 .name = "hdmi_msm_irq",
1603 .start = HDMI_IRQ,
1604 .end = HDMI_IRQ,
1605 .flags = IORESOURCE_IRQ,
1606 },
1607};
1608
1609static int hdmi_enable_5v(int on);
1610static int hdmi_core_power(int on, int show);
1611static int hdmi_cec_power(int on);
1612
1613static struct msm_hdmi_platform_data hdmi_msm_data = {
1614 .irq = HDMI_IRQ,
1615 .enable_5v = hdmi_enable_5v,
1616 .core_power = hdmi_core_power,
1617 .cec_power = hdmi_cec_power,
1618};
1619
1620static struct platform_device hdmi_msm_device = {
1621 .name = "hdmi_msm",
1622 .id = 0,
1623 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
1624 .resource = hdmi_msm_resources,
1625 .dev.platform_data = &hdmi_msm_data,
1626};
1627#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1628
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001629#ifdef CONFIG_MSM_BUS_SCALING
1630static struct msm_bus_vectors dtv_bus_init_vectors[] = {
1631 {
1632 .src = MSM_BUS_MASTER_MDP_PORT0,
1633 .dst = MSM_BUS_SLAVE_EBI_CH0,
1634 .ab = 0,
1635 .ib = 0,
1636 },
1637};
1638static struct msm_bus_vectors dtv_bus_def_vectors[] = {
1639 {
1640 .src = MSM_BUS_MASTER_MDP_PORT0,
1641 .dst = MSM_BUS_SLAVE_EBI_CH0,
1642 .ab = 566092800 * 2,
1643 .ib = 707616000 * 2,
1644 },
1645};
1646static struct msm_bus_paths dtv_bus_scale_usecases[] = {
1647 {
1648 ARRAY_SIZE(dtv_bus_init_vectors),
1649 dtv_bus_init_vectors,
1650 },
1651 {
1652 ARRAY_SIZE(dtv_bus_def_vectors),
1653 dtv_bus_def_vectors,
1654 },
1655};
1656static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
1657 dtv_bus_scale_usecases,
1658 ARRAY_SIZE(dtv_bus_scale_usecases),
1659 .name = "dtv",
1660};
1661
1662static struct lcdc_platform_data dtv_pdata = {
1663 .bus_scale_table = &dtv_bus_scale_pdata,
1664};
1665#endif
1666
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001667static void __init msm_fb_add_devices(void)
1668{
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001669 struct platform_device *ptr = NULL;
1670
1671 if (machine_is_msm8960_liquid())
1672 ptr = &mipi_dsi2lvds_bridge_device;
1673 else
1674 ptr = &mipi_dsi_toshiba_panel_device;
1675 platform_add_devices(&ptr, 1);
1676
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001677 if (machine_is_msm8x60_rumi3()) {
1678 msm_fb_register_device("mdp", NULL);
1679 mipi_dsi_pdata.target_type = 1;
1680 } else
1681 msm_fb_register_device("mdp", &mdp_pdata);
1682 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001683#ifdef CONFIG_MSM_BUS_SCALING
1684 msm_fb_register_device("dtv", &dtv_pdata);
1685#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001686}
1687
Ravishangar Kalyanamba99e512011-07-20 12:57:19 -07001688static struct gpiomux_setting mdp_vsync_suspend_cfg = {
1689 .func = GPIOMUX_FUNC_GPIO,
1690 .drv = GPIOMUX_DRV_2MA,
1691 .pull = GPIOMUX_PULL_DOWN,
1692};
1693
1694static struct gpiomux_setting mdp_vsync_active_cfg = {
1695 .func = GPIOMUX_FUNC_1,
1696 .drv = GPIOMUX_DRV_2MA,
1697 .pull = GPIOMUX_PULL_DOWN,
1698};
1699
1700static struct msm_gpiomux_config msm8960_mdp_vsync_configs[] __initdata = {
1701 {
1702 .gpio = MDP_VSYNC_GPIO,
1703 .settings = {
1704 [GPIOMUX_ACTIVE] = &mdp_vsync_active_cfg,
1705 [GPIOMUX_SUSPENDED] = &mdp_vsync_suspend_cfg,
1706 },
1707 }
1708};
1709
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001710#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1711static struct gpiomux_setting hdmi_suspend_cfg = {
1712 .func = GPIOMUX_FUNC_GPIO,
1713 .drv = GPIOMUX_DRV_2MA,
1714 .pull = GPIOMUX_PULL_DOWN,
1715};
1716
1717static struct gpiomux_setting hdmi_active_1_cfg = {
1718 .func = GPIOMUX_FUNC_1,
1719 .drv = GPIOMUX_DRV_2MA,
1720 .pull = GPIOMUX_PULL_UP,
1721};
1722
1723static struct gpiomux_setting hdmi_active_2_cfg = {
1724 .func = GPIOMUX_FUNC_1,
1725 .drv = GPIOMUX_DRV_2MA,
1726 .pull = GPIOMUX_PULL_DOWN,
1727};
1728
1729static struct msm_gpiomux_config msm8960_hdmi_configs[] __initdata = {
1730 {
1731 .gpio = 99,
1732 .settings = {
1733 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
1734 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1735 },
1736 },
1737 {
1738 .gpio = 100,
1739 .settings = {
1740 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
1741 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1742 },
1743 },
1744 {
1745 .gpio = 101,
1746 .settings = {
1747 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
1748 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1749 },
1750 },
1751 {
1752 .gpio = 102,
1753 .settings = {
1754 [GPIOMUX_ACTIVE] = &hdmi_active_2_cfg,
1755 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1756 },
1757 },
1758};
1759
1760static int hdmi_enable_5v(int on)
1761{
1762 /* TBD: PM8921 regulator instead of 8901 */
1763 static struct regulator *reg_8921_hdmi_mvs; /* HDMI_5V */
1764 static int prev_on;
1765 int rc;
1766
1767 if (on == prev_on)
1768 return 0;
1769
1770 if (!reg_8921_hdmi_mvs)
1771 reg_8921_hdmi_mvs = regulator_get(&hdmi_msm_device.dev,
1772 "hdmi_mvs");
1773
1774 if (on) {
1775 rc = regulator_enable(reg_8921_hdmi_mvs);
1776 if (rc) {
1777 pr_err("'%s' regulator enable failed, rc=%d\n",
1778 "8921_hdmi_mvs", rc);
1779 return rc;
1780 }
1781 pr_debug("%s(on): success\n", __func__);
1782 } else {
1783 rc = regulator_disable(reg_8921_hdmi_mvs);
1784 if (rc)
1785 pr_warning("'%s' regulator disable failed, rc=%d\n",
1786 "8921_hdmi_mvs", rc);
1787 pr_debug("%s(off): success\n", __func__);
1788 }
1789
1790 prev_on = on;
1791
1792 return 0;
1793}
1794
1795static int hdmi_core_power(int on, int show)
1796{
1797 static struct regulator *reg_8921_l23, *reg_8921_s4;
1798 static int prev_on;
1799 int rc;
1800
1801 if (on == prev_on)
1802 return 0;
1803
1804 /* TBD: PM8921 regulator instead of 8901 */
1805 if (!reg_8921_l23)
1806 reg_8921_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
1807
1808 if (!reg_8921_s4)
1809 reg_8921_s4 = regulator_get(&hdmi_msm_device.dev, "hdmi_vcc");
1810
1811 if (on) {
1812 rc = regulator_set_optimum_mode(reg_8921_l23, 100000);
1813 if (rc < 0) {
1814 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1815 return -EINVAL;
1816 }
1817
1818 rc = regulator_set_voltage(reg_8921_l23, 1800000, 1800000);
1819 if (!rc)
1820 rc = regulator_enable(reg_8921_l23);
1821 if (rc) {
1822 pr_err("'%s' regulator enable failed, rc=%d\n",
1823 "hdmi_avdd", rc);
1824 return rc;
1825 }
1826 rc = regulator_set_voltage(reg_8921_s4, 1800000, 1800000);
1827 if (!rc)
1828 rc = regulator_enable(reg_8921_s4);
1829 if (rc) {
1830 pr_err("'%s' regulator enable failed, rc=%d\n",
1831 "hdmi_vcc", rc);
1832 return rc;
1833 }
1834
1835 rc = gpio_request(100, "HDMI_DDC_CLK");
1836 if (rc) {
1837 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1838 "HDMI_DDC_CLK", 100, rc);
1839 goto error1;
1840 }
1841 rc = gpio_request(101, "HDMI_DDC_DATA");
1842 if (rc) {
1843 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1844 "HDMI_DDC_DATA", 101, rc);
1845 goto error2;
1846 }
1847 rc = gpio_request(102, "HDMI_HPD");
1848 if (rc) {
1849 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1850 "HDMI_HPD", 102, rc);
1851 goto error3;
1852 }
1853 pr_debug("%s(on): success\n", __func__);
1854 } else {
1855 gpio_free(100);
1856 gpio_free(101);
1857 gpio_free(102);
1858
1859 rc = regulator_set_optimum_mode(reg_8921_l23, 100);
1860 if (rc < 0) {
1861 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1862 return -EINVAL;
1863 }
1864
1865 pr_debug("%s(off): success\n", __func__);
1866 }
1867
1868 prev_on = on;
1869
1870 return 0;
1871
1872error3:
1873 gpio_free(101);
1874error2:
1875 gpio_free(100);
1876error1:
1877 regulator_disable(reg_8921_l23);
1878 return rc;
1879}
1880
1881static int hdmi_cec_power(int on)
1882{
1883 static int prev_on;
1884 int rc;
1885
1886 if (on == prev_on)
1887 return 0;
1888
1889 if (on) {
1890 rc = gpio_request(99, "HDMI_CEC_VAR");
1891 if (rc) {
1892 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1893 "HDMI_CEC_VAR", 99, rc);
1894 goto error;
1895 }
1896 pr_debug("%s(on): success\n", __func__);
1897 } else {
1898 gpio_free(99);
1899 pr_debug("%s(off): success\n", __func__);
1900 }
1901
1902 prev_on = on;
1903
1904 return 0;
1905error:
1906 return rc;
1907}
1908#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1909
1910static void __init msm8960_allocate_memory_regions(void)
1911{
1912 void *addr;
1913 unsigned long size;
1914
1915 size = MSM_FB_SIZE;
1916 addr = alloc_bootmem_align(size, 0x1000);
1917 msm_fb_resources[0].start = __pa(addr);
1918 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
1919 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
1920 size, addr, __pa(addr));
1921
1922}
1923#ifdef CONFIG_WCD9310_CODEC
1924
1925#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
1926
Patrick Lai3043fba2011-08-01 14:15:57 -07001927/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
1928 * 4 micbiases are used to power various analog and digital
1929 * microphones operating at 1800 mV. Technically, all micbiases
1930 * can source from single cfilter since all microphones operate
1931 * at the same voltage level. The arrangement below is to make
1932 * sure all cfilters are exercised. LDO_H regulator ouput level
1933 * does not need to be as high as 2.85V. It is choosen for
1934 * microphone sensitivity purpose.
1935 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001936static struct tabla_pdata tabla_platform_data = {
1937 .slimbus_slave_device = {
1938 .name = "tabla-slave",
1939 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
1940 },
1941 .irq = MSM_GPIO_TO_INT(62),
1942 .irq_base = TABLA_INTERRUPT_BASE,
1943 .num_irqs = NR_TABLA_IRQS,
1944 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
Patrick Lai3043fba2011-08-01 14:15:57 -07001945 .micbias = {
1946 .ldoh_v = TABLA_LDOH_2P85_V,
1947 .cfilt1_mv = 1800,
1948 .cfilt2_mv = 1800,
1949 .cfilt3_mv = 1800,
1950 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1951 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1952 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1953 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
1954 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001955};
1956
1957static struct slim_device msm_slim_tabla = {
1958 .name = "tabla-slim",
1959 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
1960 .dev = {
1961 .platform_data = &tabla_platform_data,
1962 },
1963};
1964#endif
1965
1966static struct slim_boardinfo msm_slim_devices[] = {
1967#ifdef CONFIG_WCD9310_CODEC
1968 {
1969 .bus_num = 1,
1970 .slim_slave = &msm_slim_tabla,
1971 },
1972#endif
1973 /* add more slimbus slaves as needed */
1974};
1975
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001976#define MSM_WCNSS_PHYS 0x03000000
1977#define MSM_WCNSS_SIZE 0x280000
1978
1979static struct resource resources_wcnss_wlan[] = {
1980 {
1981 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1982 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1983 .name = "wcnss_wlanrx_irq",
1984 .flags = IORESOURCE_IRQ,
1985 },
1986 {
1987 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1988 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1989 .name = "wcnss_wlantx_irq",
1990 .flags = IORESOURCE_IRQ,
1991 },
1992 {
1993 .start = MSM_WCNSS_PHYS,
1994 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
1995 .name = "wcnss_mmio",
1996 .flags = IORESOURCE_MEM,
1997 },
1998};
1999
Ankur Nandwanib0039b02011-08-09 14:00:45 -07002000static struct qcom_wcnss_opts qcom_wcnss_pdata = {
2001 .has_48mhz_xo = 1,
2002};
2003
Yunsen Wang5c1a7392011-07-09 19:10:16 -07002004static struct platform_device msm_device_wcnss_wlan = {
2005 .name = "wcnss_wlan",
2006 .id = 0,
2007 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
2008 .resource = resources_wcnss_wlan,
Ankur Nandwanib0039b02011-08-09 14:00:45 -07002009 .dev = {.platform_data = &qcom_wcnss_pdata},
Yunsen Wang5c1a7392011-07-09 19:10:16 -07002010};
2011
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002012#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2013 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
2014 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2015 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2016
2017#define QCE_SIZE 0x10000
2018#define QCE_0_BASE 0x18500000
2019
2020#define QCE_HW_KEY_SUPPORT 0
2021#define QCE_SHA_HMAC_SUPPORT 1
2022#define QCE_SHARE_CE_RESOURCE 1
2023#define QCE_CE_SHARED 0
2024
2025static struct resource qcrypto_resources[] = {
2026 [0] = {
2027 .start = QCE_0_BASE,
2028 .end = QCE_0_BASE + QCE_SIZE - 1,
2029 .flags = IORESOURCE_MEM,
2030 },
2031 [1] = {
2032 .name = "crypto_channels",
2033 .start = DMOV_CE_IN_CHAN,
2034 .end = DMOV_CE_OUT_CHAN,
2035 .flags = IORESOURCE_DMA,
2036 },
2037 [2] = {
2038 .name = "crypto_crci_in",
2039 .start = DMOV_CE_IN_CRCI,
2040 .end = DMOV_CE_IN_CRCI,
2041 .flags = IORESOURCE_DMA,
2042 },
2043 [3] = {
2044 .name = "crypto_crci_out",
2045 .start = DMOV_CE_OUT_CRCI,
2046 .end = DMOV_CE_OUT_CRCI,
2047 .flags = IORESOURCE_DMA,
2048 },
2049};
2050
2051static struct resource qcedev_resources[] = {
2052 [0] = {
2053 .start = QCE_0_BASE,
2054 .end = QCE_0_BASE + QCE_SIZE - 1,
2055 .flags = IORESOURCE_MEM,
2056 },
2057 [1] = {
2058 .name = "crypto_channels",
2059 .start = DMOV_CE_IN_CHAN,
2060 .end = DMOV_CE_OUT_CHAN,
2061 .flags = IORESOURCE_DMA,
2062 },
2063 [2] = {
2064 .name = "crypto_crci_in",
2065 .start = DMOV_CE_IN_CRCI,
2066 .end = DMOV_CE_IN_CRCI,
2067 .flags = IORESOURCE_DMA,
2068 },
2069 [3] = {
2070 .name = "crypto_crci_out",
2071 .start = DMOV_CE_OUT_CRCI,
2072 .end = DMOV_CE_OUT_CRCI,
2073 .flags = IORESOURCE_DMA,
2074 },
2075};
2076
2077#endif
2078
2079#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2080 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2081
2082static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
2083 .ce_shared = QCE_CE_SHARED,
2084 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
2085 .hw_key_support = QCE_HW_KEY_SUPPORT,
2086 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
2087};
2088
2089static struct platform_device qcrypto_device = {
2090 .name = "qcrypto",
2091 .id = 0,
2092 .num_resources = ARRAY_SIZE(qcrypto_resources),
2093 .resource = qcrypto_resources,
2094 .dev = {
2095 .coherent_dma_mask = DMA_BIT_MASK(32),
2096 .platform_data = &qcrypto_ce_hw_suppport,
2097 },
2098};
2099#endif
2100
2101#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2102 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2103
2104static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
2105 .ce_shared = QCE_CE_SHARED,
2106 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
2107 .hw_key_support = QCE_HW_KEY_SUPPORT,
2108 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
2109};
2110
2111static struct platform_device qcedev_device = {
2112 .name = "qce",
2113 .id = 0,
2114 .num_resources = ARRAY_SIZE(qcedev_resources),
2115 .resource = qcedev_resources,
2116 .dev = {
2117 .coherent_dma_mask = DMA_BIT_MASK(32),
2118 .platform_data = &qcedev_ce_hw_suppport,
2119 },
2120};
2121#endif
2122
2123
2124static int __init gpiomux_init(void)
2125{
2126 int rc;
2127
2128 rc = msm_gpiomux_init(NR_GPIO_IRQS);
2129 if (rc) {
2130 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
2131 return rc;
2132 }
2133
Nishant Pandit24153d82011-08-27 16:05:13 +05302134 msm_gpiomux_install(msm8960_cam_common_configs,
2135 ARRAY_SIZE(msm8960_cam_common_configs));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002136
2137 msm_gpiomux_install(msm8960_gpiomux_configs,
Stepan Moskovchenkod2a45a82011-08-09 17:02:57 -07002138 ARRAY_SIZE(msm8960_gpiomux_configs));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002139
2140 msm_gpiomux_install(msm8960_gsbi_configs,
2141 ARRAY_SIZE(msm8960_gsbi_configs));
2142
2143 msm_gpiomux_install(msm8960_cyts_configs,
2144 ARRAY_SIZE(msm8960_cyts_configs));
2145
2146 msm_gpiomux_install(msm8960_slimbus_config,
2147 ARRAY_SIZE(msm8960_slimbus_config));
2148
2149 msm_gpiomux_install(msm8960_audio_codec_configs,
2150 ARRAY_SIZE(msm8960_audio_codec_configs));
2151
2152#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
2153 msm_gpiomux_install(msm8960_hdmi_configs,
2154 ARRAY_SIZE(msm8960_hdmi_configs));
2155#endif
2156
Ravishangar Kalyanamba99e512011-07-20 12:57:19 -07002157 msm_gpiomux_install(msm8960_mdp_vsync_configs,
2158 ARRAY_SIZE(msm8960_mdp_vsync_configs));
2159
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002160 msm_gpiomux_install(wcnss_5wire_interface,
2161 ARRAY_SIZE(wcnss_5wire_interface));
2162
2163 return 0;
2164}
2165
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002166#define MSM_SHARED_RAM_PHYS 0x80000000
2167
2168static struct pm8921_adc_amux pm8921_adc_channels_data[] = {
2169 {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
2170 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2171 {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
2172 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2173 {"dcin", CHANNEL_DCIN, CHAN_PATH_SCALING4, AMUX_RSV1,
2174 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2175 {"ichg", CHANNEL_ICHG, CHAN_PATH_SCALING1, AMUX_RSV1,
2176 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2177 {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
2178 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2179 {"ibat", CHANNEL_IBAT, CHAN_PATH_SCALING1, AMUX_RSV1,
2180 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2181 {"m4", CHANNEL_MPP_1, CHAN_PATH_SCALING1, AMUX_RSV1,
2182 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2183 {"m5", CHANNEL_MPP_2, CHAN_PATH_SCALING2, AMUX_RSV1,
2184 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2185 {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
2186 ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
2187 {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV1,
2188 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2189 {"usbin", CHANNEL_USBIN, CHAN_PATH_SCALING3, AMUX_RSV1,
2190 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2191 {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
2192 ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
2193 {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
2194 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2195 {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
2196 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2197 {"chg_temp", CHANNEL_CHG_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
2198 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2199};
2200
2201static struct pm8921_adc_properties pm8921_adc_data = {
2202 .adc_vdd_reference = 1800, /* milli-voltage for this adc */
2203 .bitresolution = 15,
2204 .bipolar = 0,
2205};
2206
2207static struct pm8921_adc_platform_data pm8921_adc_pdata = {
2208 .adc_channel = pm8921_adc_channels_data,
2209 .adc_num_channel = ARRAY_SIZE(pm8921_adc_channels_data),
2210 .adc_prop = &pm8921_adc_data,
2211};
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08002212
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002213static void __init msm8960_map_io(void)
2214{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002215 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002216 msm_map_msm8960_io();
2217}
2218
2219static void __init msm8960_init_irq(void)
2220{
2221 unsigned int i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002222
2223 msm_mpm_irq_extn_init();
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002224 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002225 (void *)MSM_QGIC_CPU_BASE);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002226
2227 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002228 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002229
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002230 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
2231 mb();
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08002232
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002233 /* FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
2234 * as they are configured as level, which does not play nice with
2235 * handle_percpu_irq.
2236 */
2237 for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
2238 if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
Thomas Gleixner6845664a2011-03-24 13:25:22 +01002239 irq_set_handler(i, handle_percpu_irq);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002240 }
2241}
2242
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002243/* MSM8960 have 5 SDCC controllers */
2244enum sdcc_controllers {
2245 SDCC1,
2246 SDCC2,
2247 SDCC3,
2248 SDCC4,
2249 SDCC5,
2250 MAX_SDCC_CONTROLLER
2251};
2252
2253/* All SDCC controllers requires VDD/VCC voltage */
2254static struct msm_mmc_reg_data mmc_vdd_reg_data[MAX_SDCC_CONTROLLER] = {
2255 /* SDCC1 : eMMC card connected */
2256 [SDCC1] = {
2257 .name = "sdc_vdd",
2258 .set_voltage_sup = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302259 .high_vol_level = 2950000,
2260 .low_vol_level = 2950000,
Subhash Jadavanidd7ef892011-08-18 16:49:57 +05302261 .always_on = 1,
2262 .lpm_sup = 1,
2263 .lpm_uA = 9000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002264 .hpm_uA = 200000, /* 200mA */
2265 },
2266 /* SDCC3 : External card slot connected */
2267 [SDCC3] = {
2268 .name = "sdc_vdd",
2269 .set_voltage_sup = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302270 .high_vol_level = 2950000,
2271 .low_vol_level = 2950000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002272 .hpm_uA = 600000, /* 600mA */
2273 }
2274};
2275
2276/* Only slots having eMMC card will require VCCQ voltage */
2277static struct msm_mmc_reg_data mmc_vccq_reg_data[1] = {
2278 /* SDCC1 : eMMC card connected */
2279 [SDCC1] = {
2280 .name = "sdc_vccq",
2281 .set_voltage_sup = 1,
2282 .always_on = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302283 .high_vol_level = 1800000,
2284 .low_vol_level = 1800000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002285 .hpm_uA = 200000, /* 200mA */
2286 }
2287};
2288
2289/* All SDCC controllers may require voting for VDD PAD voltage */
2290static struct msm_mmc_reg_data mmc_vddp_reg_data[MAX_SDCC_CONTROLLER] = {
2291 /* SDCC3 : External card slot connected */
2292 [SDCC3] = {
2293 .name = "sdc_vddp",
2294 .set_voltage_sup = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302295 .high_vol_level = 2950000,
2296 .low_vol_level = 1850000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002297 .always_on = 1,
2298 .lpm_sup = 1,
2299 /* Max. Active current required is 16 mA */
2300 .hpm_uA = 16000,
2301 /*
2302 * Sleep current required is ~300 uA. But min. vote can be
2303 * in terms of mA (min. 1 mA). So let's vote for 2 mA
2304 * during sleep.
2305 */
2306 .lpm_uA = 2000,
2307 }
2308};
2309
2310static struct msm_mmc_slot_reg_data mmc_slot_vreg_data[MAX_SDCC_CONTROLLER] = {
2311 /* SDCC1 : eMMC card connected */
2312 [SDCC1] = {
2313 .vdd_data = &mmc_vdd_reg_data[SDCC1],
2314 .vccq_data = &mmc_vccq_reg_data[SDCC1],
2315 },
2316 /* SDCC3 : External card slot connected */
2317 [SDCC3] = {
2318 .vdd_data = &mmc_vdd_reg_data[SDCC3],
2319 .vddp_data = &mmc_vddp_reg_data[SDCC3],
2320 }
2321};
2322
2323/* SDC1 pad data */
2324static struct msm_mmc_pad_drv sdc1_pad_drv_on_cfg[] = {
2325 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_16MA},
Subhash Jadavani87bda5a2011-08-30 17:40:44 +05302326 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_10MA},
2327 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_10MA}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002328};
2329
2330static struct msm_mmc_pad_drv sdc1_pad_drv_off_cfg[] = {
2331 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_2MA},
2332 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_2MA},
2333 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_2MA}
2334};
2335
2336static struct msm_mmc_pad_pull sdc1_pad_pull_on_cfg[] = {
Subhash Jadavanib7b5b8a2011-09-13 13:00:40 +05302337 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002338 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_UP},
2339 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_UP}
2340};
2341
2342static struct msm_mmc_pad_pull sdc1_pad_pull_off_cfg[] = {
Subhash Jadavanib7b5b8a2011-09-13 13:00:40 +05302343 {TLMM_PULL_SDC1_CLK, GPIO_CFG_NO_PULL},
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002344 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_DOWN},
2345 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_DOWN}
2346};
2347
2348/* SDC3 pad data */
2349static struct msm_mmc_pad_drv sdc3_pad_drv_on_cfg[] = {
2350 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
2351 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
2352 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
2353};
2354
2355static struct msm_mmc_pad_drv sdc3_pad_drv_off_cfg[] = {
2356 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
2357 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
2358 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
2359};
2360
2361static struct msm_mmc_pad_pull sdc3_pad_pull_on_cfg[] = {
Subhash Jadavanib7b5b8a2011-09-13 13:00:40 +05302362 {TLMM_PULL_SDC3_CLK, GPIO_CFG_NO_PULL},
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002363 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
2364 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
2365};
2366
2367static struct msm_mmc_pad_pull sdc3_pad_pull_off_cfg[] = {
Subhash Jadavanib7b5b8a2011-09-13 13:00:40 +05302368 {TLMM_PULL_SDC3_CLK, GPIO_CFG_NO_PULL},
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002369 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
2370 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
2371};
2372
2373struct msm_mmc_pad_pull_data mmc_pad_pull_data[MAX_SDCC_CONTROLLER] = {
2374 [SDCC1] = {
2375 .on = sdc1_pad_pull_on_cfg,
2376 .off = sdc1_pad_pull_off_cfg,
2377 .size = ARRAY_SIZE(sdc1_pad_pull_on_cfg)
2378 },
2379 [SDCC3] = {
2380 .on = sdc3_pad_pull_on_cfg,
2381 .off = sdc3_pad_pull_off_cfg,
2382 .size = ARRAY_SIZE(sdc3_pad_pull_on_cfg)
2383 },
2384};
2385
2386struct msm_mmc_pad_drv_data mmc_pad_drv_data[MAX_SDCC_CONTROLLER] = {
2387 [SDCC1] = {
2388 .on = sdc1_pad_drv_on_cfg,
2389 .off = sdc1_pad_drv_off_cfg,
2390 .size = ARRAY_SIZE(sdc1_pad_drv_on_cfg)
2391 },
2392 [SDCC3] = {
2393 .on = sdc3_pad_drv_on_cfg,
2394 .off = sdc3_pad_drv_off_cfg,
2395 .size = ARRAY_SIZE(sdc3_pad_drv_on_cfg)
2396 },
2397};
2398
2399struct msm_mmc_pad_data mmc_pad_data[MAX_SDCC_CONTROLLER] = {
2400 [SDCC1] = {
2401 .pull = &mmc_pad_pull_data[SDCC1],
2402 .drv = &mmc_pad_drv_data[SDCC1]
2403 },
2404 [SDCC3] = {
2405 .pull = &mmc_pad_pull_data[SDCC3],
2406 .drv = &mmc_pad_drv_data[SDCC3]
2407 },
2408};
2409
2410struct msm_mmc_pin_data mmc_slot_pin_data[MAX_SDCC_CONTROLLER] = {
2411 [SDCC1] = {
2412 .pad_data = &mmc_pad_data[SDCC1],
2413 },
2414 [SDCC3] = {
2415 .pad_data = &mmc_pad_data[SDCC3],
2416 },
2417};
2418
2419static unsigned int sdc1_sup_clk_rates[] = {
Subhash Jadavani0e027b72011-08-30 17:40:55 +05302420 400000, 24000000, 48000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002421};
2422
2423static unsigned int sdc3_sup_clk_rates[] = {
2424 400000, 24000000, 48000000, 96000000
2425};
2426
2427#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
2428static struct mmc_platform_data msm8960_sdc1_data = {
2429 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
2430#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
2431 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
2432#else
2433 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
2434#endif
2435 .sup_clk_table = sdc1_sup_clk_rates,
2436 .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates),
2437 .nonremovable = 1,
2438 .sdcc_v4_sup = true,
2439 .vreg_data = &mmc_slot_vreg_data[SDCC1],
Subhash Jadavani0e027b72011-08-30 17:40:55 +05302440 .pin_data = &mmc_slot_pin_data[SDCC1]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002441};
2442#endif
2443
2444#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
2445static struct mmc_platform_data msm8960_sdc3_data = {
2446 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
2447 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
2448 .sup_clk_table = sdc3_sup_clk_rates,
2449 .sup_clk_cnt = ARRAY_SIZE(sdc3_sup_clk_rates),
2450 .wpswitch_gpio = PM8921_GPIO_PM_TO_SYS(16),
2451 .sdcc_v4_sup = true,
2452 .vreg_data = &mmc_slot_vreg_data[SDCC3],
2453 .pin_data = &mmc_slot_pin_data[SDCC3],
2454#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
2455 .status_gpio = PM8921_GPIO_PM_TO_SYS(26),
2456 .status_irq = PM8921_GPIO_IRQ(PM8921_IRQ_BASE, 26),
2457 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
2458#endif
2459 .xpc_cap = 1,
2460 .uhs_caps = (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
2461 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_DDR50 |
Subhash Jadavani0e027b72011-08-30 17:40:55 +05302462 MMC_CAP_MAX_CURRENT_600)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002463};
2464#endif
2465
2466static void __init msm8960_init_mmc(void)
2467{
2468#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
2469 /* SDC1 : eMMC card connected */
2470 msm_add_sdcc(1, &msm8960_sdc1_data);
2471#endif
2472#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
2473 /* SDC3: External card slot */
2474 msm_add_sdcc(3, &msm8960_sdc3_data);
2475#endif
2476}
2477
2478static void __init msm8960_init_buses(void)
2479{
2480#ifdef CONFIG_MSM_BUS_SCALING
2481 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
2482 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
2483 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
2484 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
2485 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
2486 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
2487 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
2488 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
2489 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
2490 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
2491#endif
2492}
2493
2494static struct msm_spi_platform_data msm8960_qup_spi_gsbi1_pdata = {
2495 .max_clock_speed = 15060000,
2496};
2497
2498#ifdef CONFIG_USB_MSM_OTG_72K
2499static struct msm_otg_platform_data msm_otg_pdata;
2500#else
2501#define USB_5V_EN 42
2502static void msm_hsusb_vbus_power(bool on)
2503{
2504 int rc;
2505 static bool vbus_is_on;
2506 static struct regulator *mvs_otg_switch;
2507 struct pm_gpio param = {
2508 .direction = PM_GPIO_DIR_OUT,
2509 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
2510 .output_value = 1,
2511 .pull = PM_GPIO_PULL_NO,
2512 .vin_sel = PM_GPIO_VIN_S4,
2513 .out_strength = PM_GPIO_STRENGTH_MED,
2514 .function = PM_GPIO_FUNC_NORMAL,
2515 };
2516
2517 if (vbus_is_on == on)
2518 return;
2519
2520 if (on) {
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002521 mvs_otg_switch = regulator_get(&msm8960_device_otg.dev,
2522 "vbus_otg");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002523 if (IS_ERR(mvs_otg_switch)) {
2524 pr_err("Unable to get mvs_otg_switch\n");
2525 return;
2526 }
2527
2528 rc = gpio_request(PM8921_GPIO_PM_TO_SYS(USB_5V_EN),
2529 "usb_5v_en");
2530 if (rc < 0) {
2531 pr_err("failed to request usb_5v_en gpio\n");
2532 goto put_mvs_otg;
2533 }
2534
2535 if (regulator_enable(mvs_otg_switch)) {
2536 pr_err("unable to enable mvs_otg_switch\n");
2537 goto free_usb_5v_en;
2538 }
2539
2540 rc = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(USB_5V_EN),
2541 &param);
2542 if (rc < 0) {
2543 pr_err("failed to configure usb_5v_en gpio\n");
2544 goto disable_mvs_otg;
2545 }
2546 vbus_is_on = true;
2547 return;
2548 }
2549disable_mvs_otg:
2550 regulator_disable(mvs_otg_switch);
2551free_usb_5v_en:
2552 gpio_free(PM8921_GPIO_PM_TO_SYS(USB_5V_EN));
2553put_mvs_otg:
2554 regulator_put(mvs_otg_switch);
2555 vbus_is_on = false;
2556}
2557
2558static struct msm_otg_platform_data msm_otg_pdata = {
2559 .mode = USB_OTG,
2560 .otg_control = OTG_PMIC_CONTROL,
2561 .phy_type = SNPS_28NM_INTEGRATED_PHY,
2562 .pclk_src_name = "dfab_usb_hs_clk",
2563 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
2564 .vbus_power = msm_hsusb_vbus_power,
2565};
2566#endif
2567
2568#define PID_MAGIC_ID 0x71432909
2569#define SERIAL_NUM_MAGIC_ID 0x61945374
2570#define SERIAL_NUMBER_LENGTH 127
2571#define DLOAD_USB_BASE_ADD 0x2A03F0C8
2572
2573struct magic_num_struct {
2574 uint32_t pid;
2575 uint32_t serial_num;
2576};
2577
2578struct dload_struct {
2579 uint32_t reserved1;
2580 uint32_t reserved2;
2581 uint32_t reserved3;
2582 uint16_t reserved4;
2583 uint16_t pid;
2584 char serial_number[SERIAL_NUMBER_LENGTH];
2585 uint16_t reserved5;
2586 struct magic_num_struct magic_struct;
2587};
2588
2589static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
2590{
2591 struct dload_struct __iomem *dload = 0;
2592
2593 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
2594 if (!dload) {
2595 pr_err("%s: cannot remap I/O memory region: %08x\n",
2596 __func__, DLOAD_USB_BASE_ADD);
2597 return -ENXIO;
2598 }
2599
2600 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
2601 __func__, dload, pid, snum);
2602 /* update pid */
2603 dload->magic_struct.pid = PID_MAGIC_ID;
2604 dload->pid = pid;
2605
2606 /* update serial number */
2607 dload->magic_struct.serial_num = 0;
2608 if (!snum) {
2609 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
2610 goto out;
2611 }
2612
2613 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
2614 strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
2615 dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
2616out:
2617 iounmap(dload);
2618 return 0;
2619}
2620
2621static struct android_usb_platform_data android_usb_pdata = {
2622 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2623};
2624
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002625static struct platform_device android_usb_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002626 .name = "android_usb",
2627 .id = -1,
2628 .dev = {
2629 .platform_data = &android_usb_pdata,
2630 },
2631};
2632
2633static uint8_t spm_wfi_cmd_sequence[] __initdata = {
2634 0x03, 0x0f,
2635};
2636
2637static uint8_t spm_power_collapse_without_rpm[] __initdata = {
2638 0x00, 0x24, 0x54, 0x10,
2639 0x09, 0x03, 0x01,
2640 0x10, 0x54, 0x30, 0x0C,
2641 0x24, 0x30, 0x0f,
2642};
2643
2644static uint8_t spm_power_collapse_with_rpm[] __initdata = {
2645 0x00, 0x24, 0x54, 0x10,
2646 0x09, 0x07, 0x01, 0x0B,
2647 0x10, 0x54, 0x30, 0x0C,
2648 0x24, 0x30, 0x0f,
2649};
2650
2651static struct msm_spm_seq_entry msm_spm_seq_list[] __initdata = {
2652 [0] = {
2653 .mode = MSM_SPM_MODE_CLOCK_GATING,
2654 .notify_rpm = false,
2655 .cmd = spm_wfi_cmd_sequence,
2656 },
2657 [1] = {
2658 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2659 .notify_rpm = false,
2660 .cmd = spm_power_collapse_without_rpm,
2661 },
2662 [2] = {
2663 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2664 .notify_rpm = true,
2665 .cmd = spm_power_collapse_with_rpm,
2666 },
2667};
2668
2669static struct msm_spm_platform_data msm_spm_data[] __initdata = {
2670 [0] = {
2671 .reg_base_addr = MSM_SAW0_BASE,
2672 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
2673 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
2674 .reg_init_values[MSM_SPM_REG_SAW2_VCTL] = 0x9C,
2675#if defined(CONFIG_MSM_AVS_HW)
2676 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2677 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2678#endif
2679 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
2680 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
2681 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2682 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2683 .vctl_timeout_us = 50,
2684 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
2685 .modes = msm_spm_seq_list,
2686 },
2687 [1] = {
2688 .reg_base_addr = MSM_SAW1_BASE,
2689 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
2690 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
2691 .reg_init_values[MSM_SPM_REG_SAW2_VCTL] = 0x9C,
2692#if defined(CONFIG_MSM_AVS_HW)
2693 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2694 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2695#endif
2696 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
2697 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
2698 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2699 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2700 .vctl_timeout_us = 50,
2701 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
2702 .modes = msm_spm_seq_list,
2703 },
2704};
2705
2706static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
2707 0x00, 0x20, 0x03, 0x20,
2708 0x00, 0x0f,
2709};
2710
2711static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
2712 0x00, 0x20, 0x34, 0x64,
2713 0x48, 0x07, 0x48, 0x20,
2714 0x50, 0x64, 0x04, 0x34,
2715 0x50, 0x0f,
2716};
2717static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
2718 0x00, 0x10, 0x34, 0x64,
2719 0x48, 0x07, 0x48, 0x10,
2720 0x50, 0x64, 0x04, 0x34,
2721 0x50, 0x0F,
2722};
2723
2724static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
2725 [0] = {
2726 .mode = MSM_SPM_L2_MODE_RETENTION,
2727 .notify_rpm = false,
2728 .cmd = l2_spm_wfi_cmd_sequence,
2729 },
2730 [1] = {
2731 .mode = MSM_SPM_L2_MODE_GDHS,
2732 .notify_rpm = true,
2733 .cmd = l2_spm_gdhs_cmd_sequence,
2734 },
2735 [2] = {
2736 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
2737 .notify_rpm = true,
2738 .cmd = l2_spm_power_off_cmd_sequence,
2739 },
2740};
2741
2742
2743static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
2744 [0] = {
2745 .reg_base_addr = MSM_SAW_L2_BASE,
2746 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
2747 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
2748 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
2749 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
2750 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
2751 .modes = msm_spm_l2_seq_list,
2752 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
2753 },
2754};
2755
2756#define CYTTSP_TS_GPIO_IRQ 11
2757#define CYTTSP_TS_SLEEP_GPIO 50
2758#define CYTTSP_TS_RESOUT_N_GPIO 52
2759
2760/*virtual key support */
2761static ssize_t tma340_vkeys_show(struct kobject *kobj,
2762 struct kobj_attribute *attr, char *buf)
2763{
2764 return snprintf(buf, 200,
2765 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
2766 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
2767 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
2768 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
2769 "\n");
2770}
2771
2772static struct kobj_attribute tma340_vkeys_attr = {
2773 .attr = {
2774 .mode = S_IRUGO,
2775 },
2776 .show = &tma340_vkeys_show,
2777};
2778
2779static struct attribute *tma340_properties_attrs[] = {
2780 &tma340_vkeys_attr.attr,
2781 NULL
2782};
2783
2784static struct attribute_group tma340_properties_attr_group = {
2785 .attrs = tma340_properties_attrs,
2786};
2787
2788
2789static int cyttsp_platform_init(struct i2c_client *client)
2790{
2791 int rc = 0;
2792 static struct kobject *tma340_properties_kobj;
2793
2794 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
2795 tma340_properties_kobj = kobject_create_and_add("board_properties",
2796 NULL);
2797 if (tma340_properties_kobj)
2798 rc = sysfs_create_group(tma340_properties_kobj,
2799 &tma340_properties_attr_group);
2800 if (!tma340_properties_kobj || rc)
2801 pr_err("%s: failed to create board_properties\n",
2802 __func__);
2803
2804 return 0;
2805}
2806
2807static struct cyttsp_regulator regulator_data[] = {
2808 {
2809 .name = "vdd",
2810 .min_uV = CY_TMA300_VTG_MIN_UV,
2811 .max_uV = CY_TMA300_VTG_MAX_UV,
2812 .load_uA = CY_TMA300_CURR_24HZ_UA,
2813 },
2814 /* TODO: Remove after runtime PM is enabled in I2C driver */
2815 {
2816 .name = "vcc_i2c",
2817 .min_uV = CY_I2C_VTG_MIN_UV,
2818 .max_uV = CY_I2C_VTG_MAX_UV,
2819 .load_uA = CY_I2C_CURR_UA,
2820 },
2821};
2822
2823static struct cyttsp_platform_data cyttsp_pdata = {
2824 .panel_maxx = 634,
2825 .panel_maxy = 1166,
2826 .disp_maxx = 616,
2827 .disp_maxy = 1023,
2828 .disp_minx = 0,
2829 .disp_miny = 16,
2830 .flags = 0x01,
2831 .gen = CY_GEN3, /* or */
2832 .use_st = CY_USE_ST,
2833 .use_mt = CY_USE_MT,
2834 .use_hndshk = CY_SEND_HNDSHK,
2835 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayale96f66d2011-08-11 14:06:38 +05302836 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002837 .use_gestures = CY_USE_GESTURES,
2838 .fw_fname = "cyttsp_8960_cdp.hex",
2839 /* activate up to 4 groups
2840 * and set active distance
2841 */
2842 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
2843 CY_GEST_GRP3 | CY_GEST_GRP4 |
2844 CY_ACT_DIST,
2845 /* change act_intrvl to customize the Active power state
2846 * scanning/processing refresh interval for Operating mode
2847 */
2848 .act_intrvl = CY_ACT_INTRVL_DFLT,
2849 /* change tch_tmout to customize the touch timeout for the
2850 * Active power state for Operating mode
2851 */
2852 .tch_tmout = CY_TCH_TMOUT_DFLT,
2853 /* change lp_intrvl to customize the Low Power power state
2854 * scanning/processing refresh interval for Operating mode
2855 */
2856 .lp_intrvl = CY_LP_INTRVL_DFLT,
2857 .sleep_gpio = CYTTSP_TS_SLEEP_GPIO,
2858 .resout_gpio = CYTTSP_TS_RESOUT_N_GPIO,
2859 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
2860 .regulator_info = regulator_data,
2861 .num_regulators = ARRAY_SIZE(regulator_data),
2862 .init = cyttsp_platform_init,
Mohan Pallaka49c37d62011-08-01 11:52:00 +05302863 .correct_fw_ver = 9,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002864};
2865
2866static struct i2c_board_info cyttsp_info[] __initdata = {
2867 {
2868 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
2869 .platform_data = &cyttsp_pdata,
2870#ifndef CY_USE_TIMER
2871 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
2872#endif /* CY_USE_TIMER */
2873 },
2874};
2875
2876static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
2877{
2878}
2879
2880static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi4_pdata = {
2881 .clk_freq = 100000,
2882 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002883 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2884};
2885
2886static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi3_pdata = {
2887 .clk_freq = 100000,
2888 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002889 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2890};
2891
2892static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi10_pdata = {
2893 .clk_freq = 100000,
2894 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002895 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2896};
2897
2898static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi12_pdata = {
2899 .clk_freq = 100000,
2900 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002901 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2902};
2903
2904static struct msm_rpm_platform_data msm_rpm_data = {
2905 .reg_base_addrs = {
2906 [MSM_RPM_PAGE_STATUS] = MSM_RPM_BASE,
2907 [MSM_RPM_PAGE_CTRL] = MSM_RPM_BASE + 0x400,
2908 [MSM_RPM_PAGE_REQ] = MSM_RPM_BASE + 0x600,
2909 [MSM_RPM_PAGE_ACK] = MSM_RPM_BASE + 0xa00,
2910 },
2911
2912 .irq_ack = RPM_APCC_CPU0_GP_HIGH_IRQ,
2913 .irq_err = RPM_APCC_CPU0_GP_LOW_IRQ,
2914 .irq_vmpm = RPM_APCC_CPU0_GP_MEDIUM_IRQ,
2915 .msm_apps_ipc_rpm_reg = MSM_APCS_GCC_BASE + 0x008,
2916 .msm_apps_ipc_rpm_val = 4,
2917};
2918
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06002919static struct platform_device msm_rpm_device = {
2920 .name = "msm_rpm",
2921 .id = -1,
2922};
2923
2924
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002925static struct spi_board_info spi_board_info[] __initdata = {
2926 {
2927 .modalias = "ks8851",
2928 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2929 .max_speed_hz = 19200000,
2930 .bus_num = 0,
2931 .chip_select = 0,
2932 .mode = SPI_MODE_0,
2933 },
2934};
2935
2936static struct platform_device msm_device_saw_core0 = {
2937 .name = "saw-regulator",
2938 .id = 0,
2939 .dev = {
2940 .platform_data = &msm_saw_regulator_pdata_s5,
2941 },
2942};
2943
2944static struct platform_device msm_device_saw_core1 = {
2945 .name = "saw-regulator",
2946 .id = 1,
2947 .dev = {
2948 .platform_data = &msm_saw_regulator_pdata_s6,
2949 },
2950};
2951
2952#ifdef CONFIG_MSM_FAKE_BATTERY
2953static struct platform_device fish_battery_device = {
2954 .name = "fish_battery",
2955};
2956#endif
2957
David Collins26f05562011-06-20 09:56:28 -07002958static struct platform_device msm8960_device_ext_5v_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002959 .name = GPIO_REGULATOR_DEV_NAME,
2960 .id = PM8921_MPP_PM_TO_SYS(7),
2961 .dev = {
2962 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2963 },
2964};
2965
David Collins26f05562011-06-20 09:56:28 -07002966static struct platform_device msm8960_device_ext_l2_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002967 .name = GPIO_REGULATOR_DEV_NAME,
2968 .id = 91,
2969 .dev = {
2970 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
2971 },
2972};
2973
David Collinsb10be1d2011-09-02 10:29:31 -07002974static struct platform_device msm8960_device_ext_3p3v_vreg __devinitdata = {
2975 .name = GPIO_REGULATOR_DEV_NAME,
2976 .id = PM8921_GPIO_PM_TO_SYS(17),
2977 .dev = {
2978 .platform_data =
2979 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2980 },
2981};
2982
David Collins26f05562011-06-20 09:56:28 -07002983static struct platform_device msm8960_device_rpm_regulator __devinitdata = {
2984 .name = "rpm-regulator",
2985 .id = -1,
2986 .dev = {
2987 .platform_data = &msm_rpm_regulator_pdata,
2988 },
2989};
2990
David Collins4c31a872011-08-31 10:07:10 -07002991static struct msm_rpm_log_platform_data msm_rpm_log_pdata = {
2992 .phys_addr_base = 0x0010C000,
2993 .reg_offsets = {
2994 [MSM_RPM_LOG_PAGE_INDICES] = 0x00000080,
2995 [MSM_RPM_LOG_PAGE_BUFFER] = 0x000000A0,
2996 },
2997 .phys_size = SZ_8K,
2998 .log_len = 4096, /* log's buffer length in bytes */
2999 .log_len_mask = (4096 >> 2) - 1, /* length mask in units of u32 */
3000};
3001
3002static struct platform_device msm_rpm_log_device = {
3003 .name = "msm_rpm_log",
3004 .id = -1,
3005 .dev = {
3006 .platform_data = &msm_rpm_log_pdata,
3007 },
3008};
3009
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003010static struct platform_device *common_devices[] __initdata = {
Stepan Moskovchenkodf13d342011-08-03 19:01:25 -07003011 &msm8960_device_dmov,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003012 &msm_device_smd,
3013 &msm8960_device_uart_gsbi5,
Mayank Rana9f51f582011-08-04 18:35:59 +05303014 &msm_device_uart_dm6,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003015 &msm_device_saw_core0,
3016 &msm_device_saw_core1,
3017 &msm8960_device_ext_5v_vreg,
3018 &msm8960_device_ext_l2_vreg,
3019 &msm8960_device_ssbi_pm8921,
3020 &msm8960_device_qup_spi_gsbi1,
3021 &msm8960_device_qup_i2c_gsbi3,
3022 &msm8960_device_qup_i2c_gsbi4,
3023 &msm8960_device_qup_i2c_gsbi10,
3024#ifndef CONFIG_MSM_DSPS
3025 &msm8960_device_qup_i2c_gsbi12,
3026#endif
3027 &msm_slim_ctrl,
3028 &msm_device_wcnss_wlan,
3029#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3030 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
3031 &qcrypto_device,
3032#endif
3033
3034#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3035 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3036 &qcedev_device,
3037#endif
3038#ifdef CONFIG_MSM_ROTATOR
3039 &msm_rotator_device,
3040#endif
3041 &msm_device_sps,
3042#ifdef CONFIG_MSM_FAKE_BATTERY
3043 &fish_battery_device,
3044#endif
3045#ifdef CONFIG_ANDROID_PMEM
3046 &android_pmem_device,
3047 &android_pmem_adsp_device,
3048 &android_pmem_audio_device,
3049#endif
3050 &msm_fb_device,
3051 &msm_device_vidc,
3052 &msm_device_bam_dmux,
3053 &msm_fm_platform_init,
Mona Hossain9c430e32011-07-27 11:04:47 -07003054
3055#ifdef CONFIG_HW_RANDOM_MSM
3056 &msm_device_rng,
3057#endif
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06003058 &msm_rpm_device,
Laura Abbottd6183792011-08-19 13:42:24 -07003059#ifdef CONFIG_ION_MSM
3060 &ion_dev,
3061#endif
David Collins4c31a872011-08-31 10:07:10 -07003062 &msm_rpm_log_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003063};
3064
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003065static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003066 &msm8960_device_otg,
3067 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003068 &msm_device_hsusb_host,
3069 &android_usb_device,
3070 &msm_device_vidc,
3071 &mipi_dsi_simulator_panel_device,
3072 &msm_bus_apps_fabric,
3073 &msm_bus_sys_fabric,
3074 &msm_bus_mm_fabric,
3075 &msm_bus_sys_fpb,
3076 &msm_bus_cpss_fpb,
3077 &msm_pcm,
3078 &msm_pcm_routing,
3079 &msm_cpudai0,
3080 &msm_cpudai1,
3081 &msm_cpudai_hdmi_rx,
3082 &msm_cpudai_bt_rx,
3083 &msm_cpudai_bt_tx,
3084 &msm_cpudai_fm_rx,
3085 &msm_cpudai_fm_tx,
3086 &msm_cpu_fe,
3087 &msm_stub_codec,
3088 &msm_voice,
3089 &msm_voip,
3090 &msm_lpa_pcm,
3091
3092#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3093 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
3094 &qcrypto_device,
3095#endif
3096
3097#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3098 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3099 &qcedev_device,
3100#endif
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003101};
3102
3103static struct platform_device *rumi3_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003104 &msm_kgsl_3d0,
3105 &msm_kgsl_2d0,
3106 &msm_kgsl_2d1,
3107 &mipi_dsi_renesas_panel_device,
3108#ifdef CONFIG_MSM_GEMINI
3109 &msm8960_gemini_device,
3110#endif
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003111};
3112
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003113static struct platform_device *cdp_devices[] __initdata = {
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003114 &msm8960_device_otg,
3115 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003116 &msm_device_hsusb_host,
3117 &android_usb_device,
3118 &msm_pcm,
3119 &msm_pcm_routing,
3120 &msm_cpudai0,
3121 &msm_cpudai1,
3122 &msm_cpudai_hdmi_rx,
3123 &msm_cpudai_bt_rx,
3124 &msm_cpudai_bt_tx,
3125 &msm_cpudai_fm_rx,
3126 &msm_cpudai_fm_tx,
3127 &msm_cpu_fe,
3128 &msm_stub_codec,
3129 &msm_kgsl_3d0,
3130#ifdef CONFIG_MSM_KGSL_2D
3131 &msm_kgsl_2d0,
3132 &msm_kgsl_2d1,
3133#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003134#ifdef CONFIG_MSM_GEMINI
3135 &msm8960_gemini_device,
3136#endif
3137 &msm_voice,
3138 &msm_voip,
3139 &msm_lpa_pcm,
Laxminath Kasamcee1d602011-08-01 19:26:57 +05303140 &msm_cpudai_afe_01_rx,
3141 &msm_cpudai_afe_01_tx,
3142 &msm_cpudai_afe_02_rx,
3143 &msm_cpudai_afe_02_tx,
3144 &msm_pcm_afe,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003145#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3146 &hdmi_msm_device,
3147#endif
3148 &msm_pcm_hostless,
3149 &msm_bus_apps_fabric,
3150 &msm_bus_sys_fabric,
3151 &msm_bus_mm_fabric,
3152 &msm_bus_sys_fpb,
3153 &msm_bus_cpss_fpb,
3154};
3155
3156static void __init msm8960_i2c_init(void)
3157{
3158 msm8960_device_qup_i2c_gsbi4.dev.platform_data =
3159 &msm8960_i2c_qup_gsbi4_pdata;
3160
3161 msm8960_device_qup_i2c_gsbi3.dev.platform_data =
3162 &msm8960_i2c_qup_gsbi3_pdata;
3163
3164 msm8960_device_qup_i2c_gsbi10.dev.platform_data =
3165 &msm8960_i2c_qup_gsbi10_pdata;
3166
3167 msm8960_device_qup_i2c_gsbi12.dev.platform_data =
3168 &msm8960_i2c_qup_gsbi12_pdata;
3169}
3170
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003171static void __init msm8960_gfx_init(void)
3172{
3173 uint32_t soc_platform_version = socinfo_get_platform_version();
3174 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1) {
3175 struct kgsl_device_platform_data *kgsl_3d0_pdata =
3176 msm_kgsl_3d0.dev.platform_data;
3177 kgsl_3d0_pdata->pwr_data.pwrlevel[0].gpu_freq =
3178 320000000;
3179 kgsl_3d0_pdata->pwr_data.pwrlevel[1].gpu_freq =
3180 266667000;
3181 }
3182}
3183
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003184static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
3185 .irq_base = PM8921_IRQ_BASE,
3186 .devirq = MSM_GPIO_TO_INT(104),
3187 .irq_trigger_flag = IRQF_TRIGGER_LOW,
3188};
3189
3190static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
3191 .gpio_base = PM8921_GPIO_PM_TO_SYS(1),
3192};
3193
3194static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
3195 .mpp_base = PM8921_MPP_PM_TO_SYS(1),
3196};
3197
3198static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
3199 .rtc_write_enable = false,
3200};
3201
3202static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
3203 .pull_up = 1,
3204 .kpd_trigger_delay_us = 970,
3205 .wakeup = 1,
3206};
3207
3208static const unsigned int keymap[] = {
3209 KEY(0, 0, KEY_VOLUMEUP),
3210 KEY(0, 1, KEY_VOLUMEDOWN),
3211 KEY(0, 2, KEY_CAMERA_SNAPSHOT),
3212 KEY(0, 3, KEY_CAMERA_FOCUS),
3213};
3214
3215static struct matrix_keymap_data keymap_data = {
3216 .keymap_size = ARRAY_SIZE(keymap),
3217 .keymap = keymap,
3218};
3219
3220static struct pm8xxx_keypad_platform_data keypad_data = {
3221 .input_name = "keypad_8960",
3222 .input_phys_device = "keypad_8960/input0",
3223 .num_rows = 1,
3224 .num_cols = 5,
3225 .rows_gpio_start = PM8921_GPIO_PM_TO_SYS(9),
3226 .cols_gpio_start = PM8921_GPIO_PM_TO_SYS(1),
3227 .debounce_ms = 15,
3228 .scan_delay_ms = 32,
3229 .row_hold_ns = 91500,
3230 .wakeup = 1,
3231 .keymap_data = &keymap_data,
3232};
3233
3234static const unsigned int keymap_sim[] = {
3235 KEY(0, 0, KEY_7),
3236 KEY(0, 1, KEY_DOWN),
3237 KEY(0, 2, KEY_UP),
3238 KEY(0, 3, KEY_RIGHT),
3239 KEY(0, 4, KEY_ENTER),
3240 KEY(0, 5, KEY_L),
3241 KEY(0, 6, KEY_BACK),
3242 KEY(0, 7, KEY_M),
3243
3244 KEY(1, 0, KEY_LEFT),
3245 KEY(1, 1, KEY_SEND),
3246 KEY(1, 2, KEY_1),
3247 KEY(1, 3, KEY_4),
3248 KEY(1, 4, KEY_CLEAR),
3249 KEY(1, 5, KEY_MSDOS),
3250 KEY(1, 6, KEY_SPACE),
3251 KEY(1, 7, KEY_COMMA),
3252
3253 KEY(2, 0, KEY_6),
3254 KEY(2, 1, KEY_5),
3255 KEY(2, 2, KEY_8),
3256 KEY(2, 3, KEY_3),
3257 KEY(2, 4, KEY_NUMERIC_STAR),
3258 KEY(2, 5, KEY_UP),
3259 KEY(2, 6, KEY_DOWN),
3260 KEY(2, 7, KEY_LEFTSHIFT),
3261
3262 KEY(3, 0, KEY_9),
3263 KEY(3, 1, KEY_NUMERIC_POUND),
3264 KEY(3, 2, KEY_0),
3265 KEY(3, 3, KEY_2),
3266 KEY(3, 4, KEY_SLEEP),
3267 KEY(3, 5, KEY_F1),
3268 KEY(3, 6, KEY_F2),
3269 KEY(3, 7, KEY_F3),
3270
3271 KEY(4, 0, KEY_BACK),
3272 KEY(4, 1, KEY_HOME),
3273 KEY(4, 2, KEY_MENU),
3274 KEY(4, 3, KEY_VOLUMEUP),
3275 KEY(4, 4, KEY_VOLUMEDOWN),
3276 KEY(4, 5, KEY_F4),
3277 KEY(4, 6, KEY_F5),
3278 KEY(4, 7, KEY_F6),
3279
3280 KEY(5, 0, KEY_R),
3281 KEY(5, 1, KEY_T),
3282 KEY(5, 2, KEY_Y),
3283 KEY(5, 3, KEY_LEFTALT),
3284 KEY(5, 4, KEY_KPENTER),
3285 KEY(5, 5, KEY_Q),
3286 KEY(5, 6, KEY_W),
3287 KEY(5, 7, KEY_E),
3288
3289 KEY(6, 0, KEY_F),
3290 KEY(6, 1, KEY_G),
3291 KEY(6, 2, KEY_H),
3292 KEY(6, 3, KEY_CAPSLOCK),
3293 KEY(6, 4, KEY_PAGEUP),
3294 KEY(6, 5, KEY_A),
3295 KEY(6, 6, KEY_S),
3296 KEY(6, 7, KEY_D),
3297
3298 KEY(7, 0, KEY_V),
3299 KEY(7, 1, KEY_B),
3300 KEY(7, 2, KEY_N),
3301 KEY(7, 3, KEY_MENU),
3302 KEY(7, 4, KEY_PAGEDOWN),
3303 KEY(7, 5, KEY_Z),
3304 KEY(7, 6, KEY_X),
3305 KEY(7, 7, KEY_C),
3306
3307 KEY(8, 0, KEY_P),
3308 KEY(8, 1, KEY_J),
3309 KEY(8, 2, KEY_K),
3310 KEY(8, 3, KEY_INSERT),
3311 KEY(8, 4, KEY_LINEFEED),
3312 KEY(8, 5, KEY_U),
3313 KEY(8, 6, KEY_I),
3314 KEY(8, 7, KEY_O),
3315
3316 KEY(9, 0, KEY_4),
3317 KEY(9, 1, KEY_5),
3318 KEY(9, 2, KEY_6),
3319 KEY(9, 3, KEY_7),
3320 KEY(9, 4, KEY_8),
3321 KEY(9, 5, KEY_1),
3322 KEY(9, 6, KEY_2),
3323 KEY(9, 7, KEY_3),
3324
3325 KEY(10, 0, KEY_F7),
3326 KEY(10, 1, KEY_F8),
3327 KEY(10, 2, KEY_F9),
3328 KEY(10, 3, KEY_F10),
3329 KEY(10, 4, KEY_FN),
3330 KEY(10, 5, KEY_9),
3331 KEY(10, 6, KEY_0),
3332 KEY(10, 7, KEY_DOT),
3333
3334 KEY(11, 0, KEY_LEFTCTRL),
3335 KEY(11, 1, KEY_F11),
3336 KEY(11, 2, KEY_ENTER),
3337 KEY(11, 3, KEY_SEARCH),
3338 KEY(11, 4, KEY_DELETE),
3339 KEY(11, 5, KEY_RIGHT),
3340 KEY(11, 6, KEY_LEFT),
3341 KEY(11, 7, KEY_RIGHTSHIFT),
3342 KEY(0, 0, KEY_VOLUMEUP),
3343 KEY(0, 1, KEY_VOLUMEDOWN),
3344 KEY(0, 2, KEY_CAMERA_SNAPSHOT),
3345 KEY(0, 3, KEY_CAMERA_FOCUS),
3346};
3347
3348static struct matrix_keymap_data keymap_data_sim = {
3349 .keymap_size = ARRAY_SIZE(keymap_sim),
3350 .keymap = keymap_sim,
3351};
3352
3353static struct pm8xxx_keypad_platform_data keypad_data_sim = {
3354 .input_name = "keypad_8960",
3355 .input_phys_device = "keypad_8960/input0",
3356 .num_rows = 12,
3357 .num_cols = 8,
3358 .rows_gpio_start = PM8921_GPIO_PM_TO_SYS(9),
3359 .cols_gpio_start = PM8921_GPIO_PM_TO_SYS(1),
3360 .debounce_ms = 15,
3361 .scan_delay_ms = 32,
3362 .row_hold_ns = 91500,
3363 .wakeup = 1,
3364 .keymap_data = &keymap_data_sim,
3365};
3366
Abhijeet Dharmapurikarad742362011-08-29 19:50:02 -07003367static int pm8921_therm_mitigation[] = {
3368 1100,
3369 700,
3370 600,
3371 325,
3372};
3373
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003374static struct pm8921_charger_platform_data pm8921_chg_pdata __devinitdata = {
Abhijeet Dharmapurikar34059332011-08-16 19:19:39 -07003375 .safety_time = 180,
3376 .update_time = 1,
3377 .max_voltage = 4200,
3378 .min_voltage = 3200,
3379 .resume_voltage = 4100,
3380 .term_current = 100,
3381 .cool_temp = 10,
3382 .warm_temp = 40,
3383 .temp_check_period = 1,
Abhijeet Dharmapurikarad742362011-08-29 19:50:02 -07003384 .max_bat_chg_current = 1100,
Abhijeet Dharmapurikar34059332011-08-16 19:19:39 -07003385 .cool_bat_chg_current = 350,
3386 .warm_bat_chg_current = 350,
3387 .cool_bat_voltage = 4100,
3388 .warm_bat_voltage = 4100,
Abhijeet Dharmapurikarad742362011-08-29 19:50:02 -07003389 .thermal_mitigation = pm8921_therm_mitigation,
3390 .thermal_levels = ARRAY_SIZE(pm8921_therm_mitigation),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003391};
3392
3393static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
3394 .priority = 0,
3395};
3396
3397static struct pm8921_bms_platform_data pm8921_bms_pdata __devinitdata = {
3398 .r_sense = 10,
3399 .i_test = 2500,
3400 .v_failure = 3000,
3401 .calib_delay_ms = 600000,
3402 .batt_data = &palladium_1500_data,
3403};
3404
Jay Chokshide4cefb2011-08-04 18:10:44 -07003405#define PM8921_LC_LED_MAX_CURRENT 4 /* I = 4mA */
3406
3407/**
3408 * 'flag' stores three values; led id, led mode, and max current of led.
3409 * The bit packing format is as follow,
3410 * reserved (1 byte) | max_current (2 bytes) | led_mode (1 nibble) |
3411 * led_id (1 nibble)
3412 */
3413#define PM8XXX_SET_FLAG(led_id, led_mode, led_max_current) \
3414 (((led_id << PM8XXX_LED_ID_SHIFT) & PM8XXX_LED_ID_MASK) |\
3415 ((led_mode << PM8XXX_LED_MODE_SHIFT) & PM8XXX_LED_MODE_MASK) |\
3416 ((led_max_current << PM8XXX_LED_MAX_CURRENT_SHIFT) & \
3417 PM8XXX_LED_MAX_CURRENT_MASK))
3418
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003419static struct led_info pm8921_led_info[] = {
3420 [0] = {
Jay Chokshide4cefb2011-08-04 18:10:44 -07003421 .name = "led:usb",
3422 .default_trigger = "usb-online",
3423 .flags = PM8XXX_SET_FLAG(PM8XXX_ID_LED_0,
3424 PM8XXX_LED_MODE_MANUAL,
3425 PM8921_LC_LED_MAX_CURRENT),
3426 },
3427 [1] = {
3428 .name = "led:ac",
3429 .default_trigger = "ac-online",
3430 .flags = PM8XXX_SET_FLAG(PM8XXX_ID_LED_1,
3431 PM8XXX_LED_MODE_MANUAL,
3432 PM8921_LC_LED_MAX_CURRENT),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003433 },
3434};
3435
3436static struct led_platform_data pm8xxx_leds_pdata = {
3437 .num_leds = ARRAY_SIZE(pm8921_led_info),
3438 .leds = pm8921_led_info,
3439};
3440
3441static struct pm8921_platform_data pm8921_platform_data __devinitdata = {
3442 .irq_pdata = &pm8xxx_irq_pdata,
3443 .gpio_pdata = &pm8xxx_gpio_pdata,
3444 .mpp_pdata = &pm8xxx_mpp_pdata,
3445 .rtc_pdata = &pm8xxx_rtc_pdata,
3446 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
3447 .keypad_pdata = &keypad_data,
3448 .misc_pdata = &pm8xxx_misc_pdata,
3449 .regulator_pdatas = msm_pm8921_regulator_pdata,
3450 .charger_pdata = &pm8921_chg_pdata,
3451 .bms_pdata = &pm8921_bms_pdata,
3452 .adc_pdata = &pm8921_adc_pdata,
3453 .leds_pdata = &pm8xxx_leds_pdata,
3454};
3455
3456static struct msm_ssbi_platform_data msm8960_ssbi_pm8921_pdata __devinitdata = {
3457 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
3458 .slave = {
3459 .name = "pm8921-core",
3460 .platform_data = &pm8921_platform_data,
3461 },
3462};
3463
3464static void msm8960_wcnss_init(void)
3465{
3466 int i, ret, j;
3467
3468 for (i = 0; i < ARRAY_SIZE(wcnss_5wire_interface); i++) {
3469 ret = gpio_request(wcnss_5wire_interface[i].gpio,
3470 "wcnss_5_wire");
3471 if (ret) {
3472 pr_err("wcnss_5_wire gpio %d failed: %d\n",
3473 wcnss_5wire_interface[i].gpio, ret);
3474 goto fail;
3475 }
3476 }
3477
3478 pr_info("%s: Iris 5-wire gpios configured\n", __func__);
3479
3480 return;
3481
3482fail:
3483 for (j = 0; j < i; j++)
3484 gpio_free(wcnss_5wire_interface[j].gpio);
3485}
3486
Stepan Moskovchenko41d168272011-08-09 17:09:42 -07003487#ifdef CONFIG_KS8851
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003488static int ethernet_init(void)
3489{
3490 int ret;
3491 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
3492 if (ret) {
3493 pr_err("ks8851 gpio_request failed: %d\n", ret);
3494 goto fail;
3495 }
3496
3497 ret = gpio_request(KS8851_RST_GPIO, "ks8851_rst");
3498 if (ret) {
3499 pr_err("ks8851 gpio_request failed: %d\n", ret);
3500 goto fail_rst;
3501 }
3502
3503 ret = gpio_request(FPGA_CS_GPIO, "fpga_cs");
3504 if (ret) {
3505 pr_err("ks8851 gpio_request failed: %d\n", ret);
3506 goto fail_cs;
3507 }
3508
3509 gpio_direction_output(FPGA_CS_GPIO, 1);
3510 gpio_direction_output(KS8851_RST_GPIO, 1);
3511 return 0;
3512fail_cs:
3513 gpio_free(KS8851_RST_GPIO);
3514fail_rst:
3515 gpio_free(KS8851_IRQ_GPIO);
3516fail:
3517 return ret;
3518}
Stepan Moskovchenko41d168272011-08-09 17:09:42 -07003519#else
3520static int ethernet_init(void)
3521{
3522 return 0;
3523}
3524#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003525
3526static struct msm_cpuidle_state msm_cstates[] __initdata = {
3527 {0, 0, "C0", "WFI",
3528 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
3529
3530 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
3531 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
3532
3533 {0, 2, "C2", "POWER_COLLAPSE",
3534 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
3535
3536 {1, 0, "C0", "WFI",
3537 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
3538
3539 {1, 1, "C1", "STANDALONE_POWER_COLLAPSE",
3540 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
3541};
3542
3543static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
3544 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
3545 .idle_supported = 1,
3546 .suspend_supported = 1,
3547 .idle_enabled = 0,
3548 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003549 },
3550
3551 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
3552 .idle_supported = 1,
3553 .suspend_supported = 1,
3554 .idle_enabled = 0,
3555 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003556 },
3557
3558 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
3559 .idle_supported = 1,
3560 .suspend_supported = 1,
3561 .idle_enabled = 1,
3562 .suspend_enabled = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003563 },
3564
3565 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
3566 .idle_supported = 0,
3567 .suspend_supported = 1,
3568 .idle_enabled = 0,
3569 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003570 },
3571
3572 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
3573 .idle_supported = 1,
3574 .suspend_supported = 1,
3575 .idle_enabled = 0,
3576 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003577 },
3578
3579 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
3580 .idle_supported = 1,
3581 .suspend_supported = 0,
3582 .idle_enabled = 1,
3583 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003584 },
3585};
3586
3587static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
3588 {
3589 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
3590 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3591 true,
3592 1, 8000, 100000, 1,
3593 },
3594
3595 {
3596 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
3597 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3598 true,
3599 1500, 5000, 60100000, 3000,
3600 },
3601
3602 {
3603 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3604 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
3605 false,
3606 1800, 5000, 60350000, 3500,
3607 },
3608
3609 {
3610 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3611 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
3612 false,
3613 2800, 2500, 65350000, 4800,
3614 },
3615
3616 {
3617 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3618 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
3619 false,
3620 3800, 4500, 67850000, 5500,
3621 },
3622
3623 {
3624 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3625 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
3626 false,
3627 4800, 2000, 71850000, 6800,
3628 },
3629
3630 {
3631 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3632 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
3633 false,
3634 6800, 500, 75850000, 8800,
3635 },
3636
3637 {
3638 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3639 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
3640 false,
3641 7800, 0, 76350000, 9800,
3642 },
3643};
3644
3645#ifdef CONFIG_I2C
3646#define I2C_SURF 1
3647#define I2C_FFA (1 << 1)
3648#define I2C_RUMI (1 << 2)
3649#define I2C_SIM (1 << 3)
3650#define I2C_FLUID (1 << 4)
Amir Samuelov05f87802011-08-27 18:30:12 +03003651#define I2C_LIQUID (1 << 5)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003652
3653struct i2c_registry {
3654 u8 machs;
3655 int bus;
3656 struct i2c_board_info *info;
3657 int len;
3658};
3659
3660#ifdef CONFIG_MSM_CAMERA
3661static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
3662#ifdef CONFIG_IMX074
3663 {
3664 I2C_BOARD_INFO("imx074", 0x1A),
3665 },
3666#endif
3667#ifdef CONFIG_OV2720
3668 {
3669 I2C_BOARD_INFO("ov2720", 0x6C),
3670 },
3671#endif
Kevin Chandfecce22011-07-13 10:52:41 -07003672 {
3673 I2C_BOARD_INFO("qs_mt9p017", 0x6C >> 1),
3674 },
Nishant Pandit474f2252011-07-23 23:17:56 +05303675#ifdef CONFIG_MSM_CAMERA_FLASH_SC628A
3676 {
3677 I2C_BOARD_INFO("sc628a", 0x6E),
3678 },
3679#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003680};
3681#endif
3682
3683/* Sensors DSPS platform data */
3684#ifdef CONFIG_MSM_DSPS
3685#define DSPS_PIL_GENERIC_NAME "dsps"
3686#endif /* CONFIG_MSM_DSPS */
3687
3688static void __init msm8960_init_dsps(void)
3689{
3690#ifdef CONFIG_MSM_DSPS
3691 struct msm_dsps_platform_data *pdata =
3692 msm_dsps_device.dev.platform_data;
3693 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
3694 pdata->gpios = NULL;
3695 pdata->gpios_num = 0;
3696
3697 platform_device_register(&msm_dsps_device);
3698#endif /* CONFIG_MSM_DSPS */
3699}
3700
3701static struct i2c_registry msm8960_i2c_devices[] __initdata = {
3702#ifdef CONFIG_MSM_CAMERA
3703 {
Amir Samuelov05f87802011-08-27 18:30:12 +03003704 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_LIQUID | I2C_RUMI,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003705 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
3706 msm_camera_boardinfo,
3707 ARRAY_SIZE(msm_camera_boardinfo),
3708 },
3709#endif
3710 {
3711 I2C_SURF | I2C_FFA | I2C_FLUID,
3712 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3713 cyttsp_info,
3714 ARRAY_SIZE(cyttsp_info),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -07003715 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003716};
3717#endif /* CONFIG_I2C */
3718
3719static void __init register_i2c_devices(void)
3720{
3721#ifdef CONFIG_I2C
3722 u8 mach_mask = 0;
3723 int i;
3724
3725 /* Build the matching 'supported_machs' bitmask */
3726 if (machine_is_msm8960_cdp())
3727 mach_mask = I2C_SURF;
3728 else if (machine_is_msm8960_rumi3())
3729 mach_mask = I2C_RUMI;
3730 else if (machine_is_msm8960_sim())
3731 mach_mask = I2C_SIM;
Amy Maloche2d028032011-07-20 14:08:06 -07003732 else if (machine_is_msm8960_fluid())
3733 mach_mask = I2C_FLUID;
Amir Samuelov05f87802011-08-27 18:30:12 +03003734 else if (machine_is_msm8960_liquid())
3735 mach_mask = I2C_LIQUID;
Amy Maloche1b0663f2011-08-02 16:46:22 -07003736 else if (machine_is_msm8960_mtp())
3737 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003738 else
3739 pr_err("unmatched machine ID in register_i2c_devices\n");
3740
3741 /* Run the array and install devices as appropriate */
3742 for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
3743 if (msm8960_i2c_devices[i].machs & mach_mask)
3744 i2c_register_board_info(msm8960_i2c_devices[i].bus,
3745 msm8960_i2c_devices[i].info,
3746 msm8960_i2c_devices[i].len);
3747 }
3748#endif
3749}
3750
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003751static void __init msm8960_sim_init(void)
3752{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003753 if (socinfo_init() < 0)
3754 pr_err("socinfo_init() failed!\n");
3755
3756 BUG_ON(msm_rpm_init(&msm_rpm_data));
3757 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
3758 ARRAY_SIZE(msm_rpmrs_levels)));
3759 regulator_suppress_info_printing();
David Collins26f05562011-06-20 09:56:28 -07003760 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003761 msm_clock_init(&msm8960_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003762 msm8960_device_ssbi_pm8921.dev.platform_data =
3763 &msm8960_ssbi_pm8921_pdata;
3764 pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003765
3766 /* Simulator supports a QWERTY keypad */
3767 pm8921_platform_data.keypad_pdata = &keypad_data_sim;
3768
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003769 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
3770 msm8960_device_gadget_peripheral.dev.parent = &msm8960_device_otg.dev;
3771 msm_device_hsusb_host.dev.parent = &msm8960_device_otg.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003772 gpiomux_init();
3773 ethernet_init();
3774 msm8960_i2c_init();
3775 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3776 msm_spm_l2_init(msm_spm_l2_data);
3777 msm8960_init_buses();
3778 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
3779 pm8921_gpio_mpp_init();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003780 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
Matt Wagantallec57f062011-08-16 23:54:46 -07003781 acpuclk_init(&acpuclk_8960_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003782
3783 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3784 &msm8960_qup_spi_gsbi1_pdata;
3785 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
3786
3787 msm8960_init_mmc();
3788 msm_fb_add_devices();
3789 slim_register_board_info(msm_slim_devices,
3790 ARRAY_SIZE(msm_slim_devices));
3791 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
3792 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
3793 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
3794 msm_pm_data);
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003795}
3796
3797static void __init msm8960_rumi3_init(void)
3798{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003799 if (socinfo_init() < 0)
3800 pr_err("socinfo_init() failed!\n");
3801
3802 BUG_ON(msm_rpm_init(&msm_rpm_data));
3803 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
3804 ARRAY_SIZE(msm_rpmrs_levels)));
3805 regulator_suppress_info_printing();
David Collins26f05562011-06-20 09:56:28 -07003806 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003807 msm_clock_init(&msm8960_dummy_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003808 gpiomux_init();
3809 ethernet_init();
3810 msm8960_device_ssbi_pm8921.dev.platform_data =
3811 &msm8960_ssbi_pm8921_pdata;
3812 pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len;
3813 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3814 &msm8960_qup_spi_gsbi1_pdata;
3815 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
3816 msm8960_i2c_init();
3817 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3818 msm_spm_l2_init(msm_spm_l2_data);
3819 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
3820 pm8921_gpio_mpp_init();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003821 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003822 msm8960_init_mmc();
3823
3824 register_i2c_devices();
3825 msm_fb_add_devices();
3826 slim_register_board_info(msm_slim_devices,
3827 ARRAY_SIZE(msm_slim_devices));
3828 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
3829 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
3830 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
3831 msm_pm_data);
3832}
3833
3834static void __init msm8960_cdp_init(void)
3835{
3836 if (socinfo_init() < 0)
3837 pr_err("socinfo_init() failed!\n");
3838
3839 BUG_ON(msm_rpm_init(&msm_rpm_data));
3840 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
3841 ARRAY_SIZE(msm_rpmrs_levels)));
3842 regulator_suppress_info_printing();
3843 if (msm_xo_init())
3844 pr_err("Failed to initialize XO votes\n");
David Collins26f05562011-06-20 09:56:28 -07003845 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003846 msm_clock_init(&msm8960_clock_init_data);
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003847 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
3848 msm8960_device_gadget_peripheral.dev.parent = &msm8960_device_otg.dev;
3849 msm_device_hsusb_host.dev.parent = &msm8960_device_otg.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003850 gpiomux_init();
3851 ethernet_init();
3852 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3853 &msm8960_qup_spi_gsbi1_pdata;
3854 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
3855 msm8960_device_ssbi_pm8921.dev.platform_data =
3856 &msm8960_ssbi_pm8921_pdata;
3857 pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len;
3858 msm8960_i2c_init();
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003859 msm8960_gfx_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003860 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3861 msm_spm_l2_init(msm_spm_l2_data);
3862 msm8960_init_buses();
3863 platform_add_devices(msm_footswitch_devices,
3864 msm_num_footswitch_devices);
David Collinsb10be1d2011-09-02 10:29:31 -07003865 if (machine_is_msm8960_liquid())
3866 platform_device_register(&msm8960_device_ext_3p3v_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003867 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
3868 pm8921_gpio_mpp_init();
3869 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
3870 msm8960_init_cam();
3871 msm8960_init_mmc();
Matt Wagantallec57f062011-08-16 23:54:46 -07003872 acpuclk_init(&acpuclk_8960_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003873 register_i2c_devices();
3874 msm8960_wcnss_init();
3875 msm_fb_add_devices();
3876 slim_register_board_info(msm_slim_devices,
3877 ARRAY_SIZE(msm_slim_devices));
3878 msm8960_init_dsps();
3879 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
3880 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
3881 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
3882 msm_pm_data);
Larry Bassela7eadea2011-07-14 10:46:00 -07003883 change_memory_power = &msm8960_change_memory_power;
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003884}
3885
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003886MACHINE_START(MSM8960_SIM, "QCT MSM8960 SIMULATOR")
3887 .map_io = msm8960_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003888 .reserve = msm8960_reserve,
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003889 .init_irq = msm8960_init_irq,
3890 .timer = &msm_timer,
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003891 .init_machine = msm8960_sim_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003892 .init_early = msm8960_allocate_memory_regions,
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003893MACHINE_END
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003894
3895MACHINE_START(MSM8960_RUMI3, "QCT MSM8960 RUMI3")
3896 .map_io = msm8960_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003897 .reserve = msm8960_reserve,
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003898 .init_irq = msm8960_init_irq,
3899 .timer = &msm_timer,
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003900 .init_machine = msm8960_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003901 .init_early = msm8960_allocate_memory_regions,
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003902MACHINE_END
3903
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003904MACHINE_START(MSM8960_CDP, "QCT MSM8960 CDP")
3905 .map_io = msm8960_map_io,
3906 .reserve = msm8960_reserve,
3907 .init_irq = msm8960_init_irq,
3908 .timer = &msm_timer,
3909 .init_machine = msm8960_cdp_init,
3910 .init_early = msm8960_allocate_memory_regions,
3911MACHINE_END
3912
3913MACHINE_START(MSM8960_MTP, "QCT MSM8960 MTP")
3914 .map_io = msm8960_map_io,
3915 .reserve = msm8960_reserve,
3916 .init_irq = msm8960_init_irq,
3917 .timer = &msm_timer,
3918 .init_machine = msm8960_cdp_init,
3919 .init_early = msm8960_allocate_memory_regions,
3920MACHINE_END
3921
3922MACHINE_START(MSM8960_FLUID, "QCT MSM8960 FLUID")
3923 .map_io = msm8960_map_io,
3924 .reserve = msm8960_reserve,
3925 .init_irq = msm8960_init_irq,
3926 .timer = &msm_timer,
3927 .init_machine = msm8960_cdp_init,
3928 .init_early = msm8960_allocate_memory_regions,
3929MACHINE_END
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003930
3931MACHINE_START(MSM8960_LIQUID, "QCT MSM8960 LIQUID")
3932 .map_io = msm8960_map_io,
3933 .reserve = msm8960_reserve,
3934 .init_irq = msm8960_init_irq,
3935 .timer = &msm_timer,
3936 .init_machine = msm8960_cdp_init,
3937 .init_early = msm8960_allocate_memory_regions,
3938MACHINE_END