blob: 1958ab29e9b39d41b9848436daa3c903a0968d7d [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
70#include "timer.h"
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -080071#include "devices.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070072#include "devices-msm8x60.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070073#include "spm.h"
74#include "board-msm8960.h"
75#include "pm.h"
76#include "cpuidle.h"
77#include "rpm_resources.h"
78#include "mpm.h"
79
80static struct platform_device msm_fm_platform_init = {
81 .name = "iris_fm",
82 .id = -1,
83};
84
85struct pm8xxx_gpio_init {
86 unsigned gpio;
87 struct pm_gpio config;
88};
89
90struct pm8xxx_mpp_init {
91 unsigned mpp;
92 struct pm8xxx_mpp_config_data config;
93};
94
95#define PM8XXX_GPIO_INIT(_gpio, _dir, _buf, _val, _pull, _vin, _out_strength, \
96 _func, _inv, _disable) \
97{ \
98 .gpio = PM8921_GPIO_PM_TO_SYS(_gpio), \
99 .config = { \
100 .direction = _dir, \
101 .output_buffer = _buf, \
102 .output_value = _val, \
103 .pull = _pull, \
104 .vin_sel = _vin, \
105 .out_strength = _out_strength, \
106 .function = _func, \
107 .inv_int_pol = _inv, \
108 .disable_pin = _disable, \
109 } \
110}
111
112#define PM8XXX_MPP_INIT(_mpp, _type, _level, _control) \
113{ \
114 .mpp = PM8921_MPP_PM_TO_SYS(_mpp), \
115 .config = { \
116 .type = PM8XXX_MPP_TYPE_##_type, \
117 .level = _level, \
118 .control = PM8XXX_MPP_##_control, \
119 } \
120}
121
122#define PM8XXX_GPIO_DISABLE(_gpio) \
123 PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, 0, 0, 0, PM_GPIO_VIN_S4, \
124 0, 0, 0, 1)
125
126#define PM8XXX_GPIO_OUTPUT(_gpio, _val) \
127 PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
128 PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \
129 PM_GPIO_STRENGTH_HIGH, \
130 PM_GPIO_FUNC_NORMAL, 0, 0)
131
132#define PM8XXX_GPIO_INPUT(_gpio, _pull) \
133 PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, PM_GPIO_OUT_BUF_CMOS, 0, \
134 _pull, PM_GPIO_VIN_S4, \
135 PM_GPIO_STRENGTH_NO, \
136 PM_GPIO_FUNC_NORMAL, 0, 0)
137
138#define PM8XXX_GPIO_OUTPUT_FUNC(_gpio, _val, _func) \
139 PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
140 PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \
141 PM_GPIO_STRENGTH_HIGH, \
142 _func, 0, 0)
143
144/* Initial PM8921 GPIO configurations */
145static struct pm8xxx_gpio_init pm8921_gpios[] __initdata = {
146 PM8XXX_GPIO_DISABLE(6), /* Disable unused */
147 PM8XXX_GPIO_DISABLE(7), /* Disable NFC */
148 PM8XXX_GPIO_INPUT(16, PM_GPIO_PULL_UP_30), /* SD_CARD_WP */
149 PM8XXX_GPIO_DISABLE(22), /* Disable NFC */
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -0700150 PM8XXX_GPIO_OUTPUT_FUNC(24, 0, PM_GPIO_FUNC_2), /* Bl: Off, PWM mode */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700151 PM8XXX_GPIO_INPUT(26, PM_GPIO_PULL_UP_30), /* SD_CARD_DET_N */
152 PM8XXX_GPIO_OUTPUT(43, 0), /* DISP_RESET_N */
153};
154
155/* Initial PM8921 MPP configurations */
156static struct pm8xxx_mpp_init pm8921_mpps[] __initdata = {
157 /* External 5V regulator enable; shared by HDMI and USB_OTG switches. */
158 PM8XXX_MPP_INIT(7, D_INPUT, PM8921_MPP_DIG_LEVEL_VPH, DIN_TO_INT),
159 PM8XXX_MPP_INIT(PM8921_AMUX_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
160 DOUT_CTRL_LOW),
161 PM8XXX_MPP_INIT(PM8921_AMUX_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
162 DOUT_CTRL_LOW),
163};
164
165static void __init pm8921_gpio_mpp_init(void)
166{
167 int i, rc;
168
169 for (i = 0; i < ARRAY_SIZE(pm8921_gpios); i++) {
170 rc = pm8xxx_gpio_config(pm8921_gpios[i].gpio,
171 &pm8921_gpios[i].config);
172 if (rc) {
173 pr_err("%s: pm8xxx_gpio_config: rc=%d\n", __func__, rc);
174 break;
175 }
176 }
177
178 for (i = 0; i < ARRAY_SIZE(pm8921_mpps); i++) {
179 rc = pm8xxx_mpp_config(pm8921_mpps[i].mpp,
180 &pm8921_mpps[i].config);
181 if (rc) {
182 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
183 break;
184 }
185 }
186}
187
188#define FPGA_CS_GPIO 14
189#define KS8851_RST_GPIO 89
190#define KS8851_IRQ_GPIO 90
191
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700192#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
193enum {
Abhijeet Dharmapurikar0fda5602011-08-17 18:00:55 -0700194 GPIO_EXPANDER_IRQ_BASE = (PM8921_IRQ_BASE + PM8921_NR_IRQS),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700195 GPIO_EXPANDER_GPIO_BASE = (PM8921_MPP_BASE + PM8921_NR_MPPS),
196 /* CAM Expander */
197 GPIO_CAM_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE,
198 GPIO_CAM_GP_STROBE_READY = GPIO_CAM_EXPANDER_BASE,
199 GPIO_CAM_GP_AFBUSY,
200 GPIO_CAM_GP_STROBE_CE,
201 GPIO_CAM_GP_CAM1MP_XCLR,
202 GPIO_CAM_GP_CAMIF_RESET_N,
203 GPIO_CAM_GP_XMT_FLASH_INT,
204 GPIO_CAM_GP_LED_EN1,
205 GPIO_CAM_GP_LED_EN2,
206
207};
208#endif
209
Harini Jayaraman608d0462011-08-09 19:10:03 -0600210/* The SPI configurations apply to GSBI 1*/
211static struct gpiomux_setting spi_active = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700212 .func = GPIOMUX_FUNC_1,
213 .drv = GPIOMUX_DRV_8MA,
214 .pull = GPIOMUX_PULL_NONE,
215};
216
Harini Jayaraman608d0462011-08-09 19:10:03 -0600217static struct gpiomux_setting spi_suspended_config = {
218 .func = GPIOMUX_FUNC_GPIO,
219 .drv = GPIOMUX_DRV_2MA,
220 .pull = GPIOMUX_PULL_DOWN,
221};
222
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700223static struct gpiomux_setting gsbi3 = {
224 .func = GPIOMUX_FUNC_1,
225 .drv = GPIOMUX_DRV_8MA,
226 .pull = GPIOMUX_PULL_NONE,
227};
228
229static struct gpiomux_setting gsbi4 = {
230 .func = GPIOMUX_FUNC_1,
231 .drv = GPIOMUX_DRV_8MA,
232 .pull = GPIOMUX_PULL_NONE,
233};
234
235static struct gpiomux_setting gsbi5 = {
236 .func = GPIOMUX_FUNC_1,
237 .drv = GPIOMUX_DRV_8MA,
238 .pull = GPIOMUX_PULL_NONE,
239};
240
241static struct gpiomux_setting gsbi10 = {
242 .func = GPIOMUX_FUNC_2,
243 .drv = GPIOMUX_DRV_8MA,
244 .pull = GPIOMUX_PULL_NONE,
245};
246
247static struct gpiomux_setting gsbi12 = {
248 .func = GPIOMUX_FUNC_1,
249 .drv = GPIOMUX_DRV_8MA,
250 .pull = GPIOMUX_PULL_NONE,
251};
252
253static struct gpiomux_setting cdc_mclk = {
254 .func = GPIOMUX_FUNC_1,
255 .drv = GPIOMUX_DRV_8MA,
256 .pull = GPIOMUX_PULL_NONE,
257};
258
Stepan Moskovchenko41d168272011-08-09 17:09:42 -0700259#ifdef CONFIG_KS8851
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700260static struct gpiomux_setting gpio_eth_config = {
261 .pull = GPIOMUX_PULL_NONE,
262 .drv = GPIOMUX_DRV_8MA,
263 .func = GPIOMUX_FUNC_GPIO,
264};
Stepan Moskovchenko41d168272011-08-09 17:09:42 -0700265#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700266
267static struct gpiomux_setting slimbus = {
268 .func = GPIOMUX_FUNC_1,
269 .drv = GPIOMUX_DRV_8MA,
270 .pull = GPIOMUX_PULL_KEEPER,
271};
272
273struct msm_gpiomux_config msm8960_gpiomux_configs[NR_GPIO_IRQS] = {
Stepan Moskovchenko41d168272011-08-09 17:09:42 -0700274#ifdef CONFIG_KS8851
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700275 {
276 .gpio = KS8851_IRQ_GPIO,
277 .settings = {
278 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
279 }
280 },
281 {
282 .gpio = KS8851_RST_GPIO,
283 .settings = {
284 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
285 }
286 },
287 {
288 .gpio = FPGA_CS_GPIO,
289 .settings = {
290 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
291 }
292 },
Stepan Moskovchenko41d168272011-08-09 17:09:42 -0700293#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700294};
295
296static struct msm_gpiomux_config msm8960_gsbi_configs[] __initdata = {
297 {
298 .gpio = 6, /* GSBI1 QUP SPI_DATA_MOSI */
299 .settings = {
Harini Jayaraman608d0462011-08-09 19:10:03 -0600300 [GPIOMUX_SUSPENDED] = &spi_suspended_config,
301 [GPIOMUX_ACTIVE] = &spi_active,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700302 },
303 },
304 {
305 .gpio = 7, /* GSBI1 QUP SPI_DATA_MISO */
306 .settings = {
Harini Jayaraman608d0462011-08-09 19:10:03 -0600307 [GPIOMUX_SUSPENDED] = &spi_suspended_config,
308 [GPIOMUX_ACTIVE] = &spi_active,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700309 },
310 },
311 {
312 .gpio = 8, /* GSBI1 QUP SPI_CS_N */
313 .settings = {
Harini Jayaraman608d0462011-08-09 19:10:03 -0600314 [GPIOMUX_SUSPENDED] = &spi_suspended_config,
315 [GPIOMUX_ACTIVE] = &spi_active,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700316 },
317 },
318 {
319 .gpio = 9, /* GSBI1 QUP SPI_CLK */
320 .settings = {
Harini Jayaraman608d0462011-08-09 19:10:03 -0600321 [GPIOMUX_SUSPENDED] = &spi_suspended_config,
322 [GPIOMUX_ACTIVE] = &spi_active,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700323 },
324 },
325 {
326 .gpio = 16, /* GSBI3 I2C QUP SDA */
327 .settings = {
328 [GPIOMUX_SUSPENDED] = &gsbi3,
329 },
330 },
331 {
332 .gpio = 17, /* GSBI3 I2C QUP SCL */
333 .settings = {
334 [GPIOMUX_SUSPENDED] = &gsbi3,
335 },
336 },
337 {
338 .gpio = 20, /* GSBI4 I2C QUP SDA */
339 .settings = {
340 [GPIOMUX_SUSPENDED] = &gsbi4,
341 },
342 },
343 {
344 .gpio = 21, /* GSBI4 I2C QUP SCL */
345 .settings = {
346 [GPIOMUX_SUSPENDED] = &gsbi4,
347 },
348 },
349 {
350 .gpio = 22, /* GSBI5 UART2 */
351 .settings = {
352 [GPIOMUX_SUSPENDED] = &gsbi5,
353 },
354 },
355 {
356 .gpio = 23, /* GSBI5 UART2 */
357 .settings = {
358 [GPIOMUX_SUSPENDED] = &gsbi5,
359 },
360 },
361 {
362 .gpio = 24, /* GSBI5 UART2 */
363 .settings = {
364 [GPIOMUX_SUSPENDED] = &gsbi5,
365 },
366 },
367 {
368 .gpio = 25, /* GSBI5 UART2 */
369 .settings = {
370 [GPIOMUX_SUSPENDED] = &gsbi5,
371 },
372 },
373 {
374 .gpio = 44, /* GSBI12 I2C QUP SDA */
375 .settings = {
376 [GPIOMUX_SUSPENDED] = &gsbi12,
377 },
378 },
379 {
380 .gpio = 45, /* GSBI12 I2C QUP SCL */
381 .settings = {
382 [GPIOMUX_SUSPENDED] = &gsbi12,
383 },
384 },
385 {
386 .gpio = 73, /* GSBI10 I2C QUP SDA */
387 .settings = {
388 [GPIOMUX_SUSPENDED] = &gsbi10,
389 },
390 },
391 {
392 .gpio = 74, /* GSBI10 I2C QUP SCL */
393 .settings = {
394 [GPIOMUX_SUSPENDED] = &gsbi10,
395 },
396 },
397};
398
399static struct msm_gpiomux_config msm8960_slimbus_config[] __initdata = {
400 {
401 .gpio = 60, /* slimbus data */
402 .settings = {
403 [GPIOMUX_SUSPENDED] = &slimbus,
404 },
405 },
406 {
407 .gpio = 61, /* slimbus clk */
408 .settings = {
409 [GPIOMUX_SUSPENDED] = &slimbus,
410 },
411 },
412};
413
414static struct msm_gpiomux_config msm8960_audio_codec_configs[] __initdata = {
415 {
416 .gpio = 59,
417 .settings = {
418 [GPIOMUX_SUSPENDED] = &cdc_mclk,
419 },
420 },
421};
422static struct gpiomux_setting wcnss_5wire_suspend_cfg = {
423 .func = GPIOMUX_FUNC_GPIO,
424 .drv = GPIOMUX_DRV_2MA,
425 .pull = GPIOMUX_PULL_NONE,
426};
427
428static struct gpiomux_setting wcnss_5wire_active_cfg = {
429 .func = GPIOMUX_FUNC_1,
430 .drv = GPIOMUX_DRV_6MA,
431 .pull = GPIOMUX_PULL_DOWN,
432};
433
434static struct msm_gpiomux_config wcnss_5wire_interface[] = {
435 {
436 .gpio = 84,
437 .settings = {
438 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
439 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
440 },
441 },
442 {
443 .gpio = 85,
444 .settings = {
445 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
446 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
447 },
448 },
449 {
450 .gpio = 86,
451 .settings = {
452 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
453 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
454 },
455 },
456 {
457 .gpio = 87,
458 .settings = {
459 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
460 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
461 },
462 },
463 {
464 .gpio = 88,
465 .settings = {
466 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
467 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
468 },
469 },
470};
Nishant Pandit474f2252011-07-23 23:17:56 +0530471static struct gpiomux_setting cam_settings[4] = {
472 {
473 .func = GPIOMUX_FUNC_GPIO, /*suspend*/
474 .drv = GPIOMUX_DRV_2MA,
475 .pull = GPIOMUX_PULL_DOWN,
476 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700477
Nishant Pandit474f2252011-07-23 23:17:56 +0530478 {
479 .func = GPIOMUX_FUNC_1, /*active 1*/
480 .drv = GPIOMUX_DRV_2MA,
481 .pull = GPIOMUX_PULL_NONE,
482 },
483
484 {
485 .func = GPIOMUX_FUNC_GPIO, /*active 2*/
486 .drv = GPIOMUX_DRV_2MA,
487 .pull = GPIOMUX_PULL_NONE,
488 },
489
490 {
491 .func = GPIOMUX_FUNC_1, /*active 3*/
492 .drv = GPIOMUX_DRV_8MA,
493 .pull = GPIOMUX_PULL_UP,
494 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700495};
496
Nishant Pandit474f2252011-07-23 23:17:56 +0530497static struct msm_gpiomux_config msm8960_cam_configs[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700498 {
499 .gpio = 2,
500 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530501 [GPIOMUX_ACTIVE] = &cam_settings[2],
502 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700503 },
504 },
505 {
506 .gpio = 3,
507 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530508 [GPIOMUX_ACTIVE] = &cam_settings[1],
509 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700510 },
511 },
512 {
513 .gpio = 4,
514 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530515 [GPIOMUX_ACTIVE] = &cam_settings[1],
516 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700517 },
518 },
519 {
520 .gpio = 5,
521 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530522 [GPIOMUX_ACTIVE] = &cam_settings[1],
523 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700524 },
525 },
526 {
527 .gpio = 18,
528 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530529 [GPIOMUX_ACTIVE] = &cam_settings[3],
530 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700531 },
532 },
533 {
534 .gpio = 19,
535 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530536 [GPIOMUX_ACTIVE] = &cam_settings[3],
537 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700538 },
539 },
540 {
541 .gpio = 20,
542 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530543 [GPIOMUX_ACTIVE] = &cam_settings[3],
544 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700545 },
546 },
547 {
548 .gpio = 21,
549 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530550 [GPIOMUX_ACTIVE] = &cam_settings[3],
551 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700552 },
553 },
554 {
555 .gpio = 76,
556 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530557 [GPIOMUX_ACTIVE] = &cam_settings[2],
558 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700559 },
560 },
561 {
562 .gpio = 107,
563 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530564 [GPIOMUX_ACTIVE] = &cam_settings[2],
565 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700566 },
567 },
568};
569
570static struct gpiomux_setting cyts_resout_sus_cfg = {
571 .func = GPIOMUX_FUNC_GPIO,
572 .drv = GPIOMUX_DRV_6MA,
573 .pull = GPIOMUX_PULL_UP,
574};
575
576static struct gpiomux_setting cyts_resout_act_cfg = {
577 .func = GPIOMUX_FUNC_GPIO,
578 .drv = GPIOMUX_DRV_6MA,
579 .pull = GPIOMUX_PULL_UP,
580};
581
582static struct gpiomux_setting cyts_sleep_sus_cfg = {
583 .func = GPIOMUX_FUNC_GPIO,
584 .drv = GPIOMUX_DRV_6MA,
585 .pull = GPIOMUX_PULL_DOWN,
586};
587
588static struct gpiomux_setting cyts_sleep_act_cfg = {
589 .func = GPIOMUX_FUNC_GPIO,
590 .drv = GPIOMUX_DRV_6MA,
591 .pull = GPIOMUX_PULL_DOWN,
592};
593
594static struct gpiomux_setting cyts_int_act_cfg = {
595 .func = GPIOMUX_FUNC_GPIO,
596 .drv = GPIOMUX_DRV_8MA,
597 .pull = GPIOMUX_PULL_UP,
598};
599
600static struct gpiomux_setting cyts_int_sus_cfg = {
601 .func = GPIOMUX_FUNC_GPIO,
602 .drv = GPIOMUX_DRV_2MA,
603 .pull = GPIOMUX_PULL_UP,
604};
605
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700606static struct msm_gpiomux_config msm8960_cyts_configs[] __initdata = {
607 { /* TS INTERRUPT */
608 .gpio = 11,
609 .settings = {
610 [GPIOMUX_ACTIVE] = &cyts_int_act_cfg,
611 [GPIOMUX_SUSPENDED] = &cyts_int_sus_cfg,
612 },
613 },
614 { /* TS SLEEP */
615 .gpio = 50,
616 .settings = {
617 [GPIOMUX_ACTIVE] = &cyts_sleep_act_cfg,
618 [GPIOMUX_SUSPENDED] = &cyts_sleep_sus_cfg,
619 },
620 },
621 { /* TS RESOUT */
622 .gpio = 52,
623 .settings = {
624 [GPIOMUX_ACTIVE] = &cyts_resout_act_cfg,
625 [GPIOMUX_SUSPENDED] = &cyts_resout_sus_cfg,
626 },
627 },
628};
629
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700630#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
631enum {
632 SX150X_CAM,
633};
634
Nishant Pandit474f2252011-07-23 23:17:56 +0530635static struct sx150x_platform_data sx150x_data[] = {
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700636 [SX150X_CAM] = {
637 .gpio_base = GPIO_CAM_EXPANDER_BASE,
638 .oscio_is_gpo = false,
639 .io_pullup_ena = 0x0,
Nishant Pandit474f2252011-07-23 23:17:56 +0530640 .io_pulldn_ena = 0xc0,
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700641 .io_open_drain_ena = 0x0,
642 .irq_summary = -1,
643 },
644};
Nishant Pandit474f2252011-07-23 23:17:56 +0530645
646#endif
647
648#ifdef CONFIG_I2C
649
650#define MSM_8960_GSBI4_QUP_I2C_BUS_ID 4
651#define MSM_8960_GSBI3_QUP_I2C_BUS_ID 3
652
653#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
654
655static struct i2c_board_info cam_expander_i2c_info[] = {
656 {
657 I2C_BOARD_INFO("sx1508q", 0x22),
658 .platform_data = &sx150x_data[SX150X_CAM]
659 },
660};
661
662static struct msm_cam_expander_info cam_expander_info[] = {
663 {
664 cam_expander_i2c_info,
665 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
666 },
667};
668#endif
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700669#endif
670
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700671#define MSM_PMEM_KERNEL_EBI1_SIZE 0x110C000
672#define MSM_PMEM_ADSP_SIZE 0x3800000
Ben Romberger09e462d2011-08-09 15:24:37 -0700673#define MSM_PMEM_AUDIO_SIZE 0x28B000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700674#define MSM_PMEM_SIZE 0x1800000 /* 24 Mbytes */
675
676#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
677static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
678static int __init pmem_kernel_ebi1_size_setup(char *p)
679{
680 pmem_kernel_ebi1_size = memparse(p, NULL);
681 return 0;
682}
683early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
684#endif
685
686#ifdef CONFIG_ANDROID_PMEM
687static unsigned pmem_size = MSM_PMEM_SIZE;
688static int __init pmem_size_setup(char *p)
689{
690 pmem_size = memparse(p, NULL);
691 return 0;
692}
693early_param("pmem_size", pmem_size_setup);
694
695static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
696
697static int __init pmem_adsp_size_setup(char *p)
698{
699 pmem_adsp_size = memparse(p, NULL);
700 return 0;
701}
702early_param("pmem_adsp_size", pmem_adsp_size_setup);
703
704static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
705
706static int __init pmem_audio_size_setup(char *p)
707{
708 pmem_audio_size = memparse(p, NULL);
709 return 0;
710}
711early_param("pmem_audio_size", pmem_audio_size_setup);
712#endif
713
714#ifdef CONFIG_ANDROID_PMEM
715static struct android_pmem_platform_data android_pmem_pdata = {
716 .name = "pmem",
717 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
718 .cached = 1,
719 .memory_type = MEMTYPE_EBI1,
720};
721
722static struct platform_device android_pmem_device = {
723 .name = "android_pmem",
724 .id = 0,
725 .dev = {.platform_data = &android_pmem_pdata},
726};
727
728static struct android_pmem_platform_data android_pmem_adsp_pdata = {
729 .name = "pmem_adsp",
730 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
731 .cached = 0,
732 .memory_type = MEMTYPE_EBI1,
733};
734static struct platform_device android_pmem_adsp_device = {
735 .name = "android_pmem",
736 .id = 2,
737 .dev = { .platform_data = &android_pmem_adsp_pdata },
738};
739
740static struct android_pmem_platform_data android_pmem_audio_pdata = {
741 .name = "pmem_audio",
742 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
743 .cached = 0,
744 .memory_type = MEMTYPE_EBI1,
745};
746
747static struct platform_device android_pmem_audio_device = {
748 .name = "android_pmem",
749 .id = 4,
750 .dev = { .platform_data = &android_pmem_audio_pdata },
751};
752#endif
753
754static struct memtype_reserve msm8960_reserve_table[] __initdata = {
755 [MEMTYPE_SMI] = {
756 },
757 [MEMTYPE_EBI0] = {
758 .flags = MEMTYPE_FLAGS_1M_ALIGN,
759 },
760 [MEMTYPE_EBI1] = {
761 .flags = MEMTYPE_FLAGS_1M_ALIGN,
762 },
763};
764
765static void __init size_pmem_devices(void)
766{
767#ifdef CONFIG_ANDROID_PMEM
768 android_pmem_adsp_pdata.size = pmem_adsp_size;
769 android_pmem_pdata.size = pmem_size;
770 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
771#endif
772}
773
774static void __init reserve_memory_for(struct android_pmem_platform_data *p)
775{
776 msm8960_reserve_table[p->memory_type].size += p->size;
777}
778
779static void __init reserve_pmem_memory(void)
780{
781#ifdef CONFIG_ANDROID_PMEM
782 reserve_memory_for(&android_pmem_adsp_pdata);
783 reserve_memory_for(&android_pmem_pdata);
784 reserve_memory_for(&android_pmem_audio_pdata);
785 msm8960_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
786#endif
787}
788
Larry Basselb4126da2011-07-18 14:31:33 -0700789static int msm8960_paddr_to_memtype(unsigned int paddr)
790{
791 return MEMTYPE_EBI1;
792}
793
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700794static void __init msm8960_calculate_reserve_sizes(void)
795{
796 size_pmem_devices();
797 reserve_pmem_memory();
798}
799
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700800static struct reserve_info msm8960_reserve_info __initdata = {
801 .memtype_reserve_table = msm8960_reserve_table,
802 .calculate_reserve_sizes = msm8960_calculate_reserve_sizes,
803 .paddr_to_memtype = msm8960_paddr_to_memtype,
804};
805
Larry Basselb4126da2011-07-18 14:31:33 -0700806static int msm8960_memory_bank_size(void)
807{
808 return 1<<29;
809}
810
811static void __init locate_unstable_memory(void)
812{
813 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
814 unsigned long bank_size;
815 unsigned long low, high;
816
817 bank_size = msm8960_memory_bank_size();
818 low = meminfo.bank[0].start;
819 high = mb->start + mb->size;
820 low &= ~(bank_size - 1);
821
822 if (high - low <= bank_size)
823 return;
824 msm8960_reserve_info.low_unstable_address = low + bank_size;
825 msm8960_reserve_info.max_unstable_size = high - low - bank_size;
826 msm8960_reserve_info.bank_size = bank_size;
827 pr_info("low unstable address %lx max size %lx bank size %lx\n",
828 msm8960_reserve_info.low_unstable_address,
829 msm8960_reserve_info.max_unstable_size,
830 msm8960_reserve_info.bank_size);
831}
832
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700833static void __init msm8960_reserve(void)
834{
835 reserve_info = &msm8960_reserve_info;
Larry Basselb4126da2011-07-18 14:31:33 -0700836 locate_unstable_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700837 msm_reserve();
838}
839
Larry Bassela4414b12011-08-04 11:11:02 -0700840static int msm8960_change_memory_power(u64 start, u64 size,
841 int change_type)
Larry Bassela7eadea2011-07-14 10:46:00 -0700842{
Larry Bassela4414b12011-08-04 11:11:02 -0700843 return size;
Larry Bassela7eadea2011-07-14 10:46:00 -0700844}
845
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700846#ifdef CONFIG_MSM_CAMERA
847
Kevin Chan28446522011-07-26 16:39:53 -0700848static uint16_t msm_cam_gpio_tbl[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700849 5, /*CAMIF_MCLK*/
850 20, /*CAMIF_I2C_DATA*/
851 21, /*CAMIF_I2C_CLK*/
852};
853
854#define VFE_CAMIF_TIMER1_GPIO 2
855#define VFE_CAMIF_TIMER2_GPIO 3
856#define VFE_CAMIF_TIMER3_GPIO_INT 4
857struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
858 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
859 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
860 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
861 .flash_recharge_duration = 50000,
862 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
863};
864
Nishant Pandit474f2252011-07-23 23:17:56 +0530865#ifdef CONFIG_MSM_CAMERA_FLASH
866static struct msm_camera_sensor_flash_src msm_flash_src = {
867 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
868 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
869 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
870#if defined(CONFIG_I2C) && (defined(CONFIG_GPIO_SX150X) || \
871 defined(CONFIG_GPIO_SX150X_MODULE))
872 ._fsrc.ext_driver_src.expander_info = cam_expander_info,
873#endif
874};
875#endif
876
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700877#ifdef CONFIG_IMX074
878static struct msm_camera_sensor_platform_info sensor_board_info = {
Mansoor Aftab6d6ff5e2011-07-20 17:25:36 -0700879 .mount_angle = 90
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700880};
881#endif
882
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700883struct msm_camera_device_platform_data msm_camera_csi0_device_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700884 .ioclk.mclk_clk_rate = 24000000,
885 .ioclk.vfe_clk_rate = 228570000,
886 .csid_core = 0,
Kevin Chan28446522011-07-26 16:39:53 -0700887 .cam_gpio_tbl = msm_cam_gpio_tbl,
888 .cam_gpio_tbl_size = ARRAY_SIZE(msm_cam_gpio_tbl),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700889};
890
891struct msm_camera_device_platform_data msm_camera_csi1_device_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700892 .ioclk.mclk_clk_rate = 24000000,
893 .ioclk.vfe_clk_rate = 228570000,
894 .csid_core = 1,
Kevin Chan28446522011-07-26 16:39:53 -0700895 .cam_gpio_tbl = msm_cam_gpio_tbl,
896 .cam_gpio_tbl_size = ARRAY_SIZE(msm_cam_gpio_tbl),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700897};
898
899#ifdef CONFIG_IMX074
900static struct msm_camera_sensor_flash_data flash_imx074 = {
901 .flash_type = MSM_CAMERA_FLASH_LED,
Nishant Pandit474f2252011-07-23 23:17:56 +0530902#ifdef CONFIG_MSM_CAMERA_FLASH
903 .flash_src = &msm_flash_src
904#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700905};
906
907static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
908 .sensor_name = "imx074",
909 .sensor_reset = 107,
910 .sensor_pwd = 85,
911 .vcm_pwd = 0,
912 .vcm_enable = 1,
913 .pdata = &msm_camera_csi0_device_data,
914 .flash_data = &flash_imx074,
915 .strobe_flash_data = &strobe_flash_xenon,
916 .sensor_platform_info = &sensor_board_info,
917 .csi_if = 1
918};
919
920struct platform_device msm8960_camera_sensor_imx074 = {
921 .name = "msm_camera_imx074",
922 .dev = {
923 .platform_data = &msm_camera_sensor_imx074_data,
924 },
925};
926#endif
927#ifdef CONFIG_OV2720
928static struct msm_camera_sensor_flash_data flash_ov2720 = {
Kevin Chan1a990332011-07-26 20:31:23 -0700929 .flash_type = MSM_CAMERA_FLASH_NONE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700930};
931
932static struct msm_camera_sensor_info msm_camera_sensor_ov2720_data = {
933 .sensor_name = "ov2720",
934 .sensor_reset = 76,
935 .sensor_pwd = 85,
936 .vcm_pwd = 0,
937 .vcm_enable = 1,
938 .pdata = &msm_camera_csi1_device_data,
939 .flash_data = &flash_ov2720,
940 .csi_if = 1
941};
942
943struct platform_device msm8960_camera_sensor_ov2720 = {
944 .name = "msm_camera_ov2720",
945 .dev = {
946 .platform_data = &msm_camera_sensor_ov2720_data,
947 },
948};
949#endif
Kevin Chandfecce22011-07-13 10:52:41 -0700950
951static struct msm_camera_sensor_flash_data flash_qs_mt9p017 = {
952 .flash_type = MSM_CAMERA_FLASH_LED,
953};
954
955static struct msm_camera_sensor_info msm_camera_sensor_qs_mt9p017_data = {
956 .sensor_name = "qs_mt9p017",
957 .sensor_reset = 107,
958 .sensor_pwd = 85,
959 .vcm_pwd = 0,
960 .vcm_enable = 1,
961 .pdata = &msm_camera_csi0_device_data,
962 .flash_data = &flash_qs_mt9p017,
963 .sensor_platform_info = &sensor_board_info,
964 .csi_if = 1
965};
966
967struct platform_device msm8960_camera_sensor_qs_mt9p017 = {
968 .name = "msm_camera_qs_mt9p017",
969 .dev = {
970 .platform_data = &msm_camera_sensor_qs_mt9p017_data,
971 },
972};
973
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700974static void __init msm8960_init_cam(void)
975{
976 int i;
977 struct platform_device *cam_dev[] = {
978 &msm8960_camera_sensor_imx074,
979 &msm8960_camera_sensor_ov2720,
Kevin Chandfecce22011-07-13 10:52:41 -0700980 &msm8960_camera_sensor_qs_mt9p017,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700981 };
982
983 for (i = 0; i < ARRAY_SIZE(cam_dev); i++) {
984 struct msm_camera_sensor_info *s_info;
985 s_info = cam_dev[i]->dev.platform_data;
986 msm_get_cam_resources(s_info);
987 platform_device_register(cam_dev[i]);
988 }
989}
990#endif
991
992#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
993/* prim = 608 x 1024 x 4(bpp) x 3(pages) */
994#define MSM_FB_PRIM_BUF_SIZE 0x720000
995#else
996/* prim = 608 x 1024 x 4(bpp) x 2(pages) */
997#define MSM_FB_PRIM_BUF_SIZE 0x4C0000
998#endif
999
1000#ifdef CONFIG_FB_MSM_MIPI_DSI
Nagamalleswararao Ganji0b8dbd02011-08-18 20:46:59 -07001001#define MIPI_DSI_WRITEBACK_SIZE (1024 * 600 * 3 * 2)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001002#else
1003#define MIPI_DSI_WRITEBACK_SIZE 0
1004#endif
1005
1006#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1007/* hdmi = 1920 x 1088 x 2(bpp) x 1(page) */
1008#define MSM_FB_EXT_BUF_SIZE 0x3FC000
1009#elif defined(CONFIG_FB_MSM_TVOUT)
1010/* tvout = 720 x 576 x 2(bpp) x 2(pages) */
1011#define MSM_FB_EXT_BUF_SIZE 0x195000
1012#else /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1013#define MSM_FB_EXT_BUF_SIZE 0
1014#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1015
1016#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE +\
1017 MIPI_DSI_WRITEBACK_SIZE, 4096)
1018
1019#define MDP_VSYNC_GPIO 0
1020
1021static struct resource msm_fb_resources[] = {
1022 {
1023 .flags = IORESOURCE_DMA,
1024 }
1025};
1026
1027static struct platform_device msm_fb_device = {
1028 .name = "msm_fb",
1029 .id = 0,
1030 .num_resources = ARRAY_SIZE(msm_fb_resources),
1031 .resource = msm_fb_resources,
1032};
1033
1034static bool dsi_power_on;
1035
1036static int mipi_dsi_panel_power(int on)
1037{
1038 static struct regulator *reg_l8, *reg_l23, *reg_l2;
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07001039 static int gpio43;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001040 int rc;
1041
1042 struct pm_gpio gpio43_param = {
1043 .direction = PM_GPIO_DIR_OUT,
1044 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
1045 .output_value = 0,
1046 .pull = PM_GPIO_PULL_NO,
1047 .vin_sel = 2,
1048 .out_strength = PM_GPIO_STRENGTH_HIGH,
1049 .function = PM_GPIO_FUNC_PAIRED,
1050 .inv_int_pol = 0,
1051 .disable_pin = 0,
1052 };
1053
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001054 pr_info("%s: state : %d\n", __func__, on);
1055
1056 if (!dsi_power_on) {
1057
1058 reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev,
1059 "dsi_vdc");
1060 if (IS_ERR(reg_l8)) {
1061 pr_err("could not get 8921_l8, rc = %ld\n",
1062 PTR_ERR(reg_l8));
1063 return -ENODEV;
1064 }
1065
1066 reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev,
1067 "dsi_vddio");
1068 if (IS_ERR(reg_l23)) {
1069 pr_err("could not get 8921_l23, rc = %ld\n",
1070 PTR_ERR(reg_l23));
1071 return -ENODEV;
1072 }
1073
1074 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
1075 "dsi_vdda");
1076 if (IS_ERR(reg_l2)) {
1077 pr_err("could not get 8921_l2, rc = %ld\n",
1078 PTR_ERR(reg_l2));
1079 return -ENODEV;
1080 }
1081
1082 rc = regulator_set_voltage(reg_l8, 2800000, 3000000);
1083 if (rc) {
1084 pr_err("set_voltage l8 failed, rc=%d\n", rc);
1085 return -EINVAL;
1086 }
1087 rc = regulator_set_voltage(reg_l23, 1800000, 1800000);
1088 if (rc) {
1089 pr_err("set_voltage l23 failed, rc=%d\n", rc);
1090 return -EINVAL;
1091 }
1092 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
1093 if (rc) {
1094 pr_err("set_voltage l2 failed, rc=%d\n", rc);
1095 return -EINVAL;
1096 }
1097
1098 gpio43 = PM8921_GPIO_PM_TO_SYS(43);
1099 rc = gpio_request(gpio43, "disp_rst_n");
1100 if (rc) {
1101 pr_err("request gpio 43 failed, rc=%d\n", rc);
1102 return -ENODEV;
1103 }
1104
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001105 dsi_power_on = true;
1106 }
1107
1108 if (on) {
1109 rc = regulator_set_optimum_mode(reg_l8, 100000);
1110 if (rc < 0) {
1111 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
1112 return -EINVAL;
1113 }
1114 rc = regulator_set_optimum_mode(reg_l23, 100000);
1115 if (rc < 0) {
1116 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1117 return -EINVAL;
1118 }
1119 rc = regulator_set_optimum_mode(reg_l2, 100000);
1120 if (rc < 0) {
1121 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1122 return -EINVAL;
1123 }
1124 rc = regulator_enable(reg_l8);
1125 if (rc) {
1126 pr_err("enable l8 failed, rc=%d\n", rc);
1127 return -ENODEV;
1128 }
1129 rc = regulator_enable(reg_l23);
1130 if (rc) {
1131 pr_err("enable l8 failed, rc=%d\n", rc);
1132 return -ENODEV;
1133 }
1134 rc = regulator_enable(reg_l2);
1135 if (rc) {
1136 pr_err("enable l2 failed, rc=%d\n", rc);
1137 return -ENODEV;
1138 }
1139
1140 gpio43_param.pull = PM_GPIO_PULL_NO;
1141 rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
1142 if (rc) {
1143 pr_err("gpio_config 43 failed (1), rc=%d\n", rc);
1144 return -EINVAL;
1145 }
1146 gpio43_param.pull = PM_GPIO_PULL_UP_30;
1147 rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
1148 if (rc) {
1149 pr_err("gpio_config 43 failed (2), rc=%d\n", rc);
1150 return -EINVAL;
1151 }
1152 gpio43_param.pull = PM_GPIO_PULL_NO;
1153 rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
1154 if (rc) {
1155 pr_err("gpio_config 43 failed (3), rc=%d\n", rc);
1156 return -EINVAL;
1157 }
1158 gpio43_param.pull = PM_GPIO_PULL_UP_30;
1159 rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
1160 if (rc) {
1161 pr_err("gpio_config 43 failed (4), rc=%d\n", rc);
1162 return -EINVAL;
1163 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001164 gpio_set_value_cansleep(gpio43, 1);
1165 } else {
1166 rc = regulator_set_optimum_mode(reg_l8, 100);
1167 if (rc < 0) {
1168 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
1169 return -EINVAL;
1170 }
1171 rc = regulator_set_optimum_mode(reg_l23, 100);
1172 if (rc < 0) {
1173 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1174 return -EINVAL;
1175 }
1176 rc = regulator_set_optimum_mode(reg_l2, 100);
1177 if (rc < 0) {
1178 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1179 return -EINVAL;
1180 }
1181 gpio_set_value_cansleep(gpio43, 0);
1182 }
1183 return 0;
1184}
1185
1186static struct mipi_dsi_platform_data mipi_dsi_pdata = {
1187 .vsync_gpio = MDP_VSYNC_GPIO,
1188 .dsi_power_save = mipi_dsi_panel_power,
1189};
1190
1191#ifdef CONFIG_MSM_BUS_SCALING
1192
1193static struct msm_bus_vectors mdp_init_vectors[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001194 {
1195 .src = MSM_BUS_MASTER_MDP_PORT0,
1196 .dst = MSM_BUS_SLAVE_EBI_CH0,
1197 .ab = 0,
1198 .ib = 0,
1199 },
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001200};
1201
1202static struct msm_bus_vectors mdp_ui_vectors[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001203 {
1204 .src = MSM_BUS_MASTER_MDP_PORT0,
1205 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001206 .ab = 216000000 * 2,
1207 .ib = 270000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001208 },
1209};
1210
1211static struct msm_bus_vectors mdp_vga_vectors[] = {
1212 /* VGA and less video */
1213 {
1214 .src = MSM_BUS_MASTER_MDP_PORT0,
1215 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001216 .ab = 216000000 * 2,
1217 .ib = 270000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001218 },
1219};
1220
1221static struct msm_bus_vectors mdp_720p_vectors[] = {
1222 /* 720p and less video */
1223 {
1224 .src = MSM_BUS_MASTER_MDP_PORT0,
1225 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001226 .ab = 230400000 * 2,
1227 .ib = 288000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001228 },
1229};
1230
1231static struct msm_bus_vectors mdp_1080p_vectors[] = {
1232 /* 1080p and less video */
1233 {
1234 .src = MSM_BUS_MASTER_MDP_PORT0,
1235 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001236 .ab = 334080000 * 2,
1237 .ib = 417600000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001238 },
1239};
1240
1241static struct msm_bus_paths mdp_bus_scale_usecases[] = {
1242 {
1243 ARRAY_SIZE(mdp_init_vectors),
1244 mdp_init_vectors,
1245 },
1246 {
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001247 ARRAY_SIZE(mdp_ui_vectors),
1248 mdp_ui_vectors,
1249 },
1250 {
1251 ARRAY_SIZE(mdp_ui_vectors),
1252 mdp_ui_vectors,
1253 },
1254 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001255 ARRAY_SIZE(mdp_vga_vectors),
1256 mdp_vga_vectors,
1257 },
1258 {
1259 ARRAY_SIZE(mdp_720p_vectors),
1260 mdp_720p_vectors,
1261 },
1262 {
1263 ARRAY_SIZE(mdp_1080p_vectors),
1264 mdp_1080p_vectors,
1265 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001266};
1267
1268static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
1269 mdp_bus_scale_usecases,
1270 ARRAY_SIZE(mdp_bus_scale_usecases),
1271 .name = "mdp",
1272};
1273
1274#endif
1275
1276int mdp_core_clk_rate_table[] = {
1277 85330000,
1278 85330000,
1279 128000000,
1280 200000000,
1281 200000000,
1282};
1283
1284static struct msm_panel_common_pdata mdp_pdata = {
1285 .gpio = MDP_VSYNC_GPIO,
1286 .mdp_core_clk_rate = 85330000,
1287 .mdp_core_clk_table = mdp_core_clk_rate_table,
1288 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
1289#ifdef CONFIG_MSM_BUS_SCALING
1290 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
1291#endif
1292 .mdp_rev = MDP_REV_42,
1293};
1294
1295static struct platform_device mipi_dsi_renesas_panel_device = {
1296 .name = "mipi_renesas",
1297 .id = 0,
1298};
1299
1300static struct platform_device mipi_dsi_simulator_panel_device = {
1301 .name = "mipi_simulator",
1302 .id = 0,
1303};
1304
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07001305#define LPM_CHANNEL0 0
1306static int toshiba_gpio[] = {LPM_CHANNEL0};
1307
1308static struct mipi_dsi_panel_platform_data toshiba_pdata = {
1309 .gpio = toshiba_gpio,
1310};
1311
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001312static struct platform_device mipi_dsi_toshiba_panel_device = {
1313 .name = "mipi_toshiba",
1314 .id = 0,
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07001315 .dev = {
1316 .platform_data = &toshiba_pdata,
1317 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001318};
1319
1320#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1321static struct resource hdmi_msm_resources[] = {
1322 {
1323 .name = "hdmi_msm_qfprom_addr",
1324 .start = 0x00700000,
1325 .end = 0x007060FF,
1326 .flags = IORESOURCE_MEM,
1327 },
1328 {
1329 .name = "hdmi_msm_hdmi_addr",
1330 .start = 0x04A00000,
1331 .end = 0x04A00FFF,
1332 .flags = IORESOURCE_MEM,
1333 },
1334 {
1335 .name = "hdmi_msm_irq",
1336 .start = HDMI_IRQ,
1337 .end = HDMI_IRQ,
1338 .flags = IORESOURCE_IRQ,
1339 },
1340};
1341
1342static int hdmi_enable_5v(int on);
1343static int hdmi_core_power(int on, int show);
1344static int hdmi_cec_power(int on);
1345
1346static struct msm_hdmi_platform_data hdmi_msm_data = {
1347 .irq = HDMI_IRQ,
1348 .enable_5v = hdmi_enable_5v,
1349 .core_power = hdmi_core_power,
1350 .cec_power = hdmi_cec_power,
1351};
1352
1353static struct platform_device hdmi_msm_device = {
1354 .name = "hdmi_msm",
1355 .id = 0,
1356 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
1357 .resource = hdmi_msm_resources,
1358 .dev.platform_data = &hdmi_msm_data,
1359};
1360#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1361
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001362#ifdef CONFIG_MSM_BUS_SCALING
1363static struct msm_bus_vectors dtv_bus_init_vectors[] = {
1364 {
1365 .src = MSM_BUS_MASTER_MDP_PORT0,
1366 .dst = MSM_BUS_SLAVE_EBI_CH0,
1367 .ab = 0,
1368 .ib = 0,
1369 },
1370};
1371static struct msm_bus_vectors dtv_bus_def_vectors[] = {
1372 {
1373 .src = MSM_BUS_MASTER_MDP_PORT0,
1374 .dst = MSM_BUS_SLAVE_EBI_CH0,
1375 .ab = 566092800 * 2,
1376 .ib = 707616000 * 2,
1377 },
1378};
1379static struct msm_bus_paths dtv_bus_scale_usecases[] = {
1380 {
1381 ARRAY_SIZE(dtv_bus_init_vectors),
1382 dtv_bus_init_vectors,
1383 },
1384 {
1385 ARRAY_SIZE(dtv_bus_def_vectors),
1386 dtv_bus_def_vectors,
1387 },
1388};
1389static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
1390 dtv_bus_scale_usecases,
1391 ARRAY_SIZE(dtv_bus_scale_usecases),
1392 .name = "dtv",
1393};
1394
1395static struct lcdc_platform_data dtv_pdata = {
1396 .bus_scale_table = &dtv_bus_scale_pdata,
1397};
1398#endif
1399
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001400static void __init msm_fb_add_devices(void)
1401{
1402 if (machine_is_msm8x60_rumi3()) {
1403 msm_fb_register_device("mdp", NULL);
1404 mipi_dsi_pdata.target_type = 1;
1405 } else
1406 msm_fb_register_device("mdp", &mdp_pdata);
1407 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001408#ifdef CONFIG_MSM_BUS_SCALING
1409 msm_fb_register_device("dtv", &dtv_pdata);
1410#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001411}
1412
Ravishangar Kalyanamba99e512011-07-20 12:57:19 -07001413static struct gpiomux_setting mdp_vsync_suspend_cfg = {
1414 .func = GPIOMUX_FUNC_GPIO,
1415 .drv = GPIOMUX_DRV_2MA,
1416 .pull = GPIOMUX_PULL_DOWN,
1417};
1418
1419static struct gpiomux_setting mdp_vsync_active_cfg = {
1420 .func = GPIOMUX_FUNC_1,
1421 .drv = GPIOMUX_DRV_2MA,
1422 .pull = GPIOMUX_PULL_DOWN,
1423};
1424
1425static struct msm_gpiomux_config msm8960_mdp_vsync_configs[] __initdata = {
1426 {
1427 .gpio = MDP_VSYNC_GPIO,
1428 .settings = {
1429 [GPIOMUX_ACTIVE] = &mdp_vsync_active_cfg,
1430 [GPIOMUX_SUSPENDED] = &mdp_vsync_suspend_cfg,
1431 },
1432 }
1433};
1434
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001435#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1436static struct gpiomux_setting hdmi_suspend_cfg = {
1437 .func = GPIOMUX_FUNC_GPIO,
1438 .drv = GPIOMUX_DRV_2MA,
1439 .pull = GPIOMUX_PULL_DOWN,
1440};
1441
1442static struct gpiomux_setting hdmi_active_1_cfg = {
1443 .func = GPIOMUX_FUNC_1,
1444 .drv = GPIOMUX_DRV_2MA,
1445 .pull = GPIOMUX_PULL_UP,
1446};
1447
1448static struct gpiomux_setting hdmi_active_2_cfg = {
1449 .func = GPIOMUX_FUNC_1,
1450 .drv = GPIOMUX_DRV_2MA,
1451 .pull = GPIOMUX_PULL_DOWN,
1452};
1453
1454static struct msm_gpiomux_config msm8960_hdmi_configs[] __initdata = {
1455 {
1456 .gpio = 99,
1457 .settings = {
1458 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
1459 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1460 },
1461 },
1462 {
1463 .gpio = 100,
1464 .settings = {
1465 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
1466 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1467 },
1468 },
1469 {
1470 .gpio = 101,
1471 .settings = {
1472 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
1473 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1474 },
1475 },
1476 {
1477 .gpio = 102,
1478 .settings = {
1479 [GPIOMUX_ACTIVE] = &hdmi_active_2_cfg,
1480 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1481 },
1482 },
1483};
1484
1485static int hdmi_enable_5v(int on)
1486{
1487 /* TBD: PM8921 regulator instead of 8901 */
1488 static struct regulator *reg_8921_hdmi_mvs; /* HDMI_5V */
1489 static int prev_on;
1490 int rc;
1491
1492 if (on == prev_on)
1493 return 0;
1494
1495 if (!reg_8921_hdmi_mvs)
1496 reg_8921_hdmi_mvs = regulator_get(&hdmi_msm_device.dev,
1497 "hdmi_mvs");
1498
1499 if (on) {
1500 rc = regulator_enable(reg_8921_hdmi_mvs);
1501 if (rc) {
1502 pr_err("'%s' regulator enable failed, rc=%d\n",
1503 "8921_hdmi_mvs", rc);
1504 return rc;
1505 }
1506 pr_debug("%s(on): success\n", __func__);
1507 } else {
1508 rc = regulator_disable(reg_8921_hdmi_mvs);
1509 if (rc)
1510 pr_warning("'%s' regulator disable failed, rc=%d\n",
1511 "8921_hdmi_mvs", rc);
1512 pr_debug("%s(off): success\n", __func__);
1513 }
1514
1515 prev_on = on;
1516
1517 return 0;
1518}
1519
1520static int hdmi_core_power(int on, int show)
1521{
1522 static struct regulator *reg_8921_l23, *reg_8921_s4;
1523 static int prev_on;
1524 int rc;
1525
1526 if (on == prev_on)
1527 return 0;
1528
1529 /* TBD: PM8921 regulator instead of 8901 */
1530 if (!reg_8921_l23)
1531 reg_8921_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
1532
1533 if (!reg_8921_s4)
1534 reg_8921_s4 = regulator_get(&hdmi_msm_device.dev, "hdmi_vcc");
1535
1536 if (on) {
1537 rc = regulator_set_optimum_mode(reg_8921_l23, 100000);
1538 if (rc < 0) {
1539 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1540 return -EINVAL;
1541 }
1542
1543 rc = regulator_set_voltage(reg_8921_l23, 1800000, 1800000);
1544 if (!rc)
1545 rc = regulator_enable(reg_8921_l23);
1546 if (rc) {
1547 pr_err("'%s' regulator enable failed, rc=%d\n",
1548 "hdmi_avdd", rc);
1549 return rc;
1550 }
1551 rc = regulator_set_voltage(reg_8921_s4, 1800000, 1800000);
1552 if (!rc)
1553 rc = regulator_enable(reg_8921_s4);
1554 if (rc) {
1555 pr_err("'%s' regulator enable failed, rc=%d\n",
1556 "hdmi_vcc", rc);
1557 return rc;
1558 }
1559
1560 rc = gpio_request(100, "HDMI_DDC_CLK");
1561 if (rc) {
1562 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1563 "HDMI_DDC_CLK", 100, rc);
1564 goto error1;
1565 }
1566 rc = gpio_request(101, "HDMI_DDC_DATA");
1567 if (rc) {
1568 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1569 "HDMI_DDC_DATA", 101, rc);
1570 goto error2;
1571 }
1572 rc = gpio_request(102, "HDMI_HPD");
1573 if (rc) {
1574 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1575 "HDMI_HPD", 102, rc);
1576 goto error3;
1577 }
1578 pr_debug("%s(on): success\n", __func__);
1579 } else {
1580 gpio_free(100);
1581 gpio_free(101);
1582 gpio_free(102);
1583
1584 rc = regulator_set_optimum_mode(reg_8921_l23, 100);
1585 if (rc < 0) {
1586 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1587 return -EINVAL;
1588 }
1589
1590 pr_debug("%s(off): success\n", __func__);
1591 }
1592
1593 prev_on = on;
1594
1595 return 0;
1596
1597error3:
1598 gpio_free(101);
1599error2:
1600 gpio_free(100);
1601error1:
1602 regulator_disable(reg_8921_l23);
1603 return rc;
1604}
1605
1606static int hdmi_cec_power(int on)
1607{
1608 static int prev_on;
1609 int rc;
1610
1611 if (on == prev_on)
1612 return 0;
1613
1614 if (on) {
1615 rc = gpio_request(99, "HDMI_CEC_VAR");
1616 if (rc) {
1617 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1618 "HDMI_CEC_VAR", 99, rc);
1619 goto error;
1620 }
1621 pr_debug("%s(on): success\n", __func__);
1622 } else {
1623 gpio_free(99);
1624 pr_debug("%s(off): success\n", __func__);
1625 }
1626
1627 prev_on = on;
1628
1629 return 0;
1630error:
1631 return rc;
1632}
1633#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1634
1635static void __init msm8960_allocate_memory_regions(void)
1636{
1637 void *addr;
1638 unsigned long size;
1639
1640 size = MSM_FB_SIZE;
1641 addr = alloc_bootmem_align(size, 0x1000);
1642 msm_fb_resources[0].start = __pa(addr);
1643 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
1644 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
1645 size, addr, __pa(addr));
1646
1647}
1648#ifdef CONFIG_WCD9310_CODEC
1649
1650#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
1651
Patrick Lai3043fba2011-08-01 14:15:57 -07001652/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
1653 * 4 micbiases are used to power various analog and digital
1654 * microphones operating at 1800 mV. Technically, all micbiases
1655 * can source from single cfilter since all microphones operate
1656 * at the same voltage level. The arrangement below is to make
1657 * sure all cfilters are exercised. LDO_H regulator ouput level
1658 * does not need to be as high as 2.85V. It is choosen for
1659 * microphone sensitivity purpose.
1660 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001661static struct tabla_pdata tabla_platform_data = {
1662 .slimbus_slave_device = {
1663 .name = "tabla-slave",
1664 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
1665 },
1666 .irq = MSM_GPIO_TO_INT(62),
1667 .irq_base = TABLA_INTERRUPT_BASE,
1668 .num_irqs = NR_TABLA_IRQS,
1669 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
Patrick Lai3043fba2011-08-01 14:15:57 -07001670 .micbias = {
1671 .ldoh_v = TABLA_LDOH_2P85_V,
1672 .cfilt1_mv = 1800,
1673 .cfilt2_mv = 1800,
1674 .cfilt3_mv = 1800,
1675 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1676 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1677 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1678 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
1679 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001680};
1681
1682static struct slim_device msm_slim_tabla = {
1683 .name = "tabla-slim",
1684 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
1685 .dev = {
1686 .platform_data = &tabla_platform_data,
1687 },
1688};
1689#endif
1690
1691static struct slim_boardinfo msm_slim_devices[] = {
1692#ifdef CONFIG_WCD9310_CODEC
1693 {
1694 .bus_num = 1,
1695 .slim_slave = &msm_slim_tabla,
1696 },
1697#endif
1698 /* add more slimbus slaves as needed */
1699};
1700
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001701#define MSM_WCNSS_PHYS 0x03000000
1702#define MSM_WCNSS_SIZE 0x280000
1703
1704static struct resource resources_wcnss_wlan[] = {
1705 {
1706 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1707 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1708 .name = "wcnss_wlanrx_irq",
1709 .flags = IORESOURCE_IRQ,
1710 },
1711 {
1712 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1713 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1714 .name = "wcnss_wlantx_irq",
1715 .flags = IORESOURCE_IRQ,
1716 },
1717 {
1718 .start = MSM_WCNSS_PHYS,
1719 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
1720 .name = "wcnss_mmio",
1721 .flags = IORESOURCE_MEM,
1722 },
1723};
1724
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001725static struct qcom_wcnss_opts qcom_wcnss_pdata = {
1726 .has_48mhz_xo = 1,
1727};
1728
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001729static struct platform_device msm_device_wcnss_wlan = {
1730 .name = "wcnss_wlan",
1731 .id = 0,
1732 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
1733 .resource = resources_wcnss_wlan,
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001734 .dev = {.platform_data = &qcom_wcnss_pdata},
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001735};
1736
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001737#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1738 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
1739 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1740 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1741
1742#define QCE_SIZE 0x10000
1743#define QCE_0_BASE 0x18500000
1744
1745#define QCE_HW_KEY_SUPPORT 0
1746#define QCE_SHA_HMAC_SUPPORT 1
1747#define QCE_SHARE_CE_RESOURCE 1
1748#define QCE_CE_SHARED 0
1749
1750static struct resource qcrypto_resources[] = {
1751 [0] = {
1752 .start = QCE_0_BASE,
1753 .end = QCE_0_BASE + QCE_SIZE - 1,
1754 .flags = IORESOURCE_MEM,
1755 },
1756 [1] = {
1757 .name = "crypto_channels",
1758 .start = DMOV_CE_IN_CHAN,
1759 .end = DMOV_CE_OUT_CHAN,
1760 .flags = IORESOURCE_DMA,
1761 },
1762 [2] = {
1763 .name = "crypto_crci_in",
1764 .start = DMOV_CE_IN_CRCI,
1765 .end = DMOV_CE_IN_CRCI,
1766 .flags = IORESOURCE_DMA,
1767 },
1768 [3] = {
1769 .name = "crypto_crci_out",
1770 .start = DMOV_CE_OUT_CRCI,
1771 .end = DMOV_CE_OUT_CRCI,
1772 .flags = IORESOURCE_DMA,
1773 },
1774};
1775
1776static struct resource qcedev_resources[] = {
1777 [0] = {
1778 .start = QCE_0_BASE,
1779 .end = QCE_0_BASE + QCE_SIZE - 1,
1780 .flags = IORESOURCE_MEM,
1781 },
1782 [1] = {
1783 .name = "crypto_channels",
1784 .start = DMOV_CE_IN_CHAN,
1785 .end = DMOV_CE_OUT_CHAN,
1786 .flags = IORESOURCE_DMA,
1787 },
1788 [2] = {
1789 .name = "crypto_crci_in",
1790 .start = DMOV_CE_IN_CRCI,
1791 .end = DMOV_CE_IN_CRCI,
1792 .flags = IORESOURCE_DMA,
1793 },
1794 [3] = {
1795 .name = "crypto_crci_out",
1796 .start = DMOV_CE_OUT_CRCI,
1797 .end = DMOV_CE_OUT_CRCI,
1798 .flags = IORESOURCE_DMA,
1799 },
1800};
1801
1802#endif
1803
1804#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1805 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
1806
1807static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
1808 .ce_shared = QCE_CE_SHARED,
1809 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1810 .hw_key_support = QCE_HW_KEY_SUPPORT,
1811 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
1812};
1813
1814static struct platform_device qcrypto_device = {
1815 .name = "qcrypto",
1816 .id = 0,
1817 .num_resources = ARRAY_SIZE(qcrypto_resources),
1818 .resource = qcrypto_resources,
1819 .dev = {
1820 .coherent_dma_mask = DMA_BIT_MASK(32),
1821 .platform_data = &qcrypto_ce_hw_suppport,
1822 },
1823};
1824#endif
1825
1826#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1827 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1828
1829static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
1830 .ce_shared = QCE_CE_SHARED,
1831 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
1832 .hw_key_support = QCE_HW_KEY_SUPPORT,
1833 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
1834};
1835
1836static struct platform_device qcedev_device = {
1837 .name = "qce",
1838 .id = 0,
1839 .num_resources = ARRAY_SIZE(qcedev_resources),
1840 .resource = qcedev_resources,
1841 .dev = {
1842 .coherent_dma_mask = DMA_BIT_MASK(32),
1843 .platform_data = &qcedev_ce_hw_suppport,
1844 },
1845};
1846#endif
1847
1848
1849static int __init gpiomux_init(void)
1850{
1851 int rc;
1852
1853 rc = msm_gpiomux_init(NR_GPIO_IRQS);
1854 if (rc) {
1855 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
1856 return rc;
1857 }
1858
1859 msm_gpiomux_install(msm8960_cam_configs,
1860 ARRAY_SIZE(msm8960_cam_configs));
1861
1862 msm_gpiomux_install(msm8960_gpiomux_configs,
Stepan Moskovchenkod2a45a82011-08-09 17:02:57 -07001863 ARRAY_SIZE(msm8960_gpiomux_configs));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001864
1865 msm_gpiomux_install(msm8960_gsbi_configs,
1866 ARRAY_SIZE(msm8960_gsbi_configs));
1867
1868 msm_gpiomux_install(msm8960_cyts_configs,
1869 ARRAY_SIZE(msm8960_cyts_configs));
1870
1871 msm_gpiomux_install(msm8960_slimbus_config,
1872 ARRAY_SIZE(msm8960_slimbus_config));
1873
1874 msm_gpiomux_install(msm8960_audio_codec_configs,
1875 ARRAY_SIZE(msm8960_audio_codec_configs));
1876
1877#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1878 msm_gpiomux_install(msm8960_hdmi_configs,
1879 ARRAY_SIZE(msm8960_hdmi_configs));
1880#endif
1881
Ravishangar Kalyanamba99e512011-07-20 12:57:19 -07001882 msm_gpiomux_install(msm8960_mdp_vsync_configs,
1883 ARRAY_SIZE(msm8960_mdp_vsync_configs));
1884
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001885 msm_gpiomux_install(wcnss_5wire_interface,
1886 ARRAY_SIZE(wcnss_5wire_interface));
1887
1888 return 0;
1889}
1890
1891static struct msm_acpu_clock_platform_data msm8960_acpu_clock_data = {
1892 .acpu_switch_time_us = 0,
1893 .vdd_switch_time_us = 0,
1894};
1895
1896#define MSM_SHARED_RAM_PHYS 0x80000000
1897
1898static struct pm8921_adc_amux pm8921_adc_channels_data[] = {
1899 {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
1900 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
1901 {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
1902 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
1903 {"dcin", CHANNEL_DCIN, CHAN_PATH_SCALING4, AMUX_RSV1,
1904 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
1905 {"ichg", CHANNEL_ICHG, CHAN_PATH_SCALING1, AMUX_RSV1,
1906 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
1907 {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
1908 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
1909 {"ibat", CHANNEL_IBAT, CHAN_PATH_SCALING1, AMUX_RSV1,
1910 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
1911 {"m4", CHANNEL_MPP_1, CHAN_PATH_SCALING1, AMUX_RSV1,
1912 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
1913 {"m5", CHANNEL_MPP_2, CHAN_PATH_SCALING2, AMUX_RSV1,
1914 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
1915 {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
1916 ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
1917 {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV1,
1918 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
1919 {"usbin", CHANNEL_USBIN, CHAN_PATH_SCALING3, AMUX_RSV1,
1920 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
1921 {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
1922 ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
1923 {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
1924 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
1925 {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
1926 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
1927 {"chg_temp", CHANNEL_CHG_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
1928 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
1929};
1930
1931static struct pm8921_adc_properties pm8921_adc_data = {
1932 .adc_vdd_reference = 1800, /* milli-voltage for this adc */
1933 .bitresolution = 15,
1934 .bipolar = 0,
1935};
1936
1937static struct pm8921_adc_platform_data pm8921_adc_pdata = {
1938 .adc_channel = pm8921_adc_channels_data,
1939 .adc_num_channel = ARRAY_SIZE(pm8921_adc_channels_data),
1940 .adc_prop = &pm8921_adc_data,
1941};
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08001942
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001943static void __init msm8960_map_io(void)
1944{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001945 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001946 msm_map_msm8960_io();
1947}
1948
1949static void __init msm8960_init_irq(void)
1950{
1951 unsigned int i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001952
1953 msm_mpm_irq_extn_init();
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001954 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001955 (void *)MSM_QGIC_CPU_BASE);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001956
1957 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001958 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001959
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001960 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
1961 mb();
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08001962
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001963 /* FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
1964 * as they are configured as level, which does not play nice with
1965 * handle_percpu_irq.
1966 */
1967 for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
1968 if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001969 irq_set_handler(i, handle_percpu_irq);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001970 }
1971}
1972
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001973/* MSM8960 have 5 SDCC controllers */
1974enum sdcc_controllers {
1975 SDCC1,
1976 SDCC2,
1977 SDCC3,
1978 SDCC4,
1979 SDCC5,
1980 MAX_SDCC_CONTROLLER
1981};
1982
1983/* All SDCC controllers requires VDD/VCC voltage */
1984static struct msm_mmc_reg_data mmc_vdd_reg_data[MAX_SDCC_CONTROLLER] = {
1985 /* SDCC1 : eMMC card connected */
1986 [SDCC1] = {
1987 .name = "sdc_vdd",
1988 .set_voltage_sup = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05301989 .high_vol_level = 2950000,
1990 .low_vol_level = 2950000,
Subhash Jadavanidd7ef892011-08-18 16:49:57 +05301991 .always_on = 1,
1992 .lpm_sup = 1,
1993 .lpm_uA = 9000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001994 .hpm_uA = 200000, /* 200mA */
1995 },
1996 /* SDCC3 : External card slot connected */
1997 [SDCC3] = {
1998 .name = "sdc_vdd",
1999 .set_voltage_sup = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302000 .high_vol_level = 2950000,
2001 .low_vol_level = 2950000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002002 .hpm_uA = 600000, /* 600mA */
2003 }
2004};
2005
2006/* Only slots having eMMC card will require VCCQ voltage */
2007static struct msm_mmc_reg_data mmc_vccq_reg_data[1] = {
2008 /* SDCC1 : eMMC card connected */
2009 [SDCC1] = {
2010 .name = "sdc_vccq",
2011 .set_voltage_sup = 1,
2012 .always_on = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302013 .high_vol_level = 1800000,
2014 .low_vol_level = 1800000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002015 .hpm_uA = 200000, /* 200mA */
2016 }
2017};
2018
2019/* All SDCC controllers may require voting for VDD PAD voltage */
2020static struct msm_mmc_reg_data mmc_vddp_reg_data[MAX_SDCC_CONTROLLER] = {
2021 /* SDCC3 : External card slot connected */
2022 [SDCC3] = {
2023 .name = "sdc_vddp",
2024 .set_voltage_sup = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302025 .high_vol_level = 2950000,
2026 .low_vol_level = 1850000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002027 .always_on = 1,
2028 .lpm_sup = 1,
2029 /* Max. Active current required is 16 mA */
2030 .hpm_uA = 16000,
2031 /*
2032 * Sleep current required is ~300 uA. But min. vote can be
2033 * in terms of mA (min. 1 mA). So let's vote for 2 mA
2034 * during sleep.
2035 */
2036 .lpm_uA = 2000,
2037 }
2038};
2039
2040static struct msm_mmc_slot_reg_data mmc_slot_vreg_data[MAX_SDCC_CONTROLLER] = {
2041 /* SDCC1 : eMMC card connected */
2042 [SDCC1] = {
2043 .vdd_data = &mmc_vdd_reg_data[SDCC1],
2044 .vccq_data = &mmc_vccq_reg_data[SDCC1],
2045 },
2046 /* SDCC3 : External card slot connected */
2047 [SDCC3] = {
2048 .vdd_data = &mmc_vdd_reg_data[SDCC3],
2049 .vddp_data = &mmc_vddp_reg_data[SDCC3],
2050 }
2051};
2052
2053/* SDC1 pad data */
2054static struct msm_mmc_pad_drv sdc1_pad_drv_on_cfg[] = {
2055 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_16MA},
Subhash Jadavani87bda5a2011-08-30 17:40:44 +05302056 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_10MA},
2057 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_10MA}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002058};
2059
2060static struct msm_mmc_pad_drv sdc1_pad_drv_off_cfg[] = {
2061 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_2MA},
2062 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_2MA},
2063 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_2MA}
2064};
2065
2066static struct msm_mmc_pad_pull sdc1_pad_pull_on_cfg[] = {
2067 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_UP},
2068 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_UP}
2069};
2070
2071static struct msm_mmc_pad_pull sdc1_pad_pull_off_cfg[] = {
2072 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_DOWN},
2073 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_DOWN}
2074};
2075
2076/* SDC3 pad data */
2077static struct msm_mmc_pad_drv sdc3_pad_drv_on_cfg[] = {
2078 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
2079 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
2080 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
2081};
2082
2083static struct msm_mmc_pad_drv sdc3_pad_drv_off_cfg[] = {
2084 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
2085 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
2086 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
2087};
2088
2089static struct msm_mmc_pad_pull sdc3_pad_pull_on_cfg[] = {
2090 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
2091 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
2092};
2093
2094static struct msm_mmc_pad_pull sdc3_pad_pull_off_cfg[] = {
2095 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
2096 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
2097};
2098
2099struct msm_mmc_pad_pull_data mmc_pad_pull_data[MAX_SDCC_CONTROLLER] = {
2100 [SDCC1] = {
2101 .on = sdc1_pad_pull_on_cfg,
2102 .off = sdc1_pad_pull_off_cfg,
2103 .size = ARRAY_SIZE(sdc1_pad_pull_on_cfg)
2104 },
2105 [SDCC3] = {
2106 .on = sdc3_pad_pull_on_cfg,
2107 .off = sdc3_pad_pull_off_cfg,
2108 .size = ARRAY_SIZE(sdc3_pad_pull_on_cfg)
2109 },
2110};
2111
2112struct msm_mmc_pad_drv_data mmc_pad_drv_data[MAX_SDCC_CONTROLLER] = {
2113 [SDCC1] = {
2114 .on = sdc1_pad_drv_on_cfg,
2115 .off = sdc1_pad_drv_off_cfg,
2116 .size = ARRAY_SIZE(sdc1_pad_drv_on_cfg)
2117 },
2118 [SDCC3] = {
2119 .on = sdc3_pad_drv_on_cfg,
2120 .off = sdc3_pad_drv_off_cfg,
2121 .size = ARRAY_SIZE(sdc3_pad_drv_on_cfg)
2122 },
2123};
2124
2125struct msm_mmc_pad_data mmc_pad_data[MAX_SDCC_CONTROLLER] = {
2126 [SDCC1] = {
2127 .pull = &mmc_pad_pull_data[SDCC1],
2128 .drv = &mmc_pad_drv_data[SDCC1]
2129 },
2130 [SDCC3] = {
2131 .pull = &mmc_pad_pull_data[SDCC3],
2132 .drv = &mmc_pad_drv_data[SDCC3]
2133 },
2134};
2135
2136struct msm_mmc_pin_data mmc_slot_pin_data[MAX_SDCC_CONTROLLER] = {
2137 [SDCC1] = {
2138 .pad_data = &mmc_pad_data[SDCC1],
2139 },
2140 [SDCC3] = {
2141 .pad_data = &mmc_pad_data[SDCC3],
2142 },
2143};
2144
2145static unsigned int sdc1_sup_clk_rates[] = {
Subhash Jadavani0e027b72011-08-30 17:40:55 +05302146 400000, 24000000, 48000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002147};
2148
2149static unsigned int sdc3_sup_clk_rates[] = {
2150 400000, 24000000, 48000000, 96000000
2151};
2152
2153#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
2154static struct mmc_platform_data msm8960_sdc1_data = {
2155 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
2156#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
2157 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
2158#else
2159 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
2160#endif
2161 .sup_clk_table = sdc1_sup_clk_rates,
2162 .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates),
2163 .nonremovable = 1,
2164 .sdcc_v4_sup = true,
2165 .vreg_data = &mmc_slot_vreg_data[SDCC1],
Subhash Jadavani0e027b72011-08-30 17:40:55 +05302166 .pin_data = &mmc_slot_pin_data[SDCC1]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002167};
2168#endif
2169
2170#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
2171static struct mmc_platform_data msm8960_sdc3_data = {
2172 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
2173 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
2174 .sup_clk_table = sdc3_sup_clk_rates,
2175 .sup_clk_cnt = ARRAY_SIZE(sdc3_sup_clk_rates),
2176 .wpswitch_gpio = PM8921_GPIO_PM_TO_SYS(16),
2177 .sdcc_v4_sup = true,
2178 .vreg_data = &mmc_slot_vreg_data[SDCC3],
2179 .pin_data = &mmc_slot_pin_data[SDCC3],
2180#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
2181 .status_gpio = PM8921_GPIO_PM_TO_SYS(26),
2182 .status_irq = PM8921_GPIO_IRQ(PM8921_IRQ_BASE, 26),
2183 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
2184#endif
2185 .xpc_cap = 1,
2186 .uhs_caps = (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
2187 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_DDR50 |
Subhash Jadavani0e027b72011-08-30 17:40:55 +05302188 MMC_CAP_MAX_CURRENT_600)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002189};
2190#endif
2191
2192static void __init msm8960_init_mmc(void)
2193{
2194#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
2195 /* SDC1 : eMMC card connected */
2196 msm_add_sdcc(1, &msm8960_sdc1_data);
2197#endif
2198#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
2199 /* SDC3: External card slot */
2200 msm_add_sdcc(3, &msm8960_sdc3_data);
2201#endif
2202}
2203
2204static void __init msm8960_init_buses(void)
2205{
2206#ifdef CONFIG_MSM_BUS_SCALING
2207 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
2208 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
2209 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
2210 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
2211 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
2212 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
2213 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
2214 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
2215 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
2216 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
2217#endif
2218}
2219
2220static struct msm_spi_platform_data msm8960_qup_spi_gsbi1_pdata = {
2221 .max_clock_speed = 15060000,
2222};
2223
2224#ifdef CONFIG_USB_MSM_OTG_72K
2225static struct msm_otg_platform_data msm_otg_pdata;
2226#else
2227#define USB_5V_EN 42
2228static void msm_hsusb_vbus_power(bool on)
2229{
2230 int rc;
2231 static bool vbus_is_on;
2232 static struct regulator *mvs_otg_switch;
2233 struct pm_gpio param = {
2234 .direction = PM_GPIO_DIR_OUT,
2235 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
2236 .output_value = 1,
2237 .pull = PM_GPIO_PULL_NO,
2238 .vin_sel = PM_GPIO_VIN_S4,
2239 .out_strength = PM_GPIO_STRENGTH_MED,
2240 .function = PM_GPIO_FUNC_NORMAL,
2241 };
2242
2243 if (vbus_is_on == on)
2244 return;
2245
2246 if (on) {
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002247 mvs_otg_switch = regulator_get(&msm8960_device_otg.dev,
2248 "vbus_otg");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002249 if (IS_ERR(mvs_otg_switch)) {
2250 pr_err("Unable to get mvs_otg_switch\n");
2251 return;
2252 }
2253
2254 rc = gpio_request(PM8921_GPIO_PM_TO_SYS(USB_5V_EN),
2255 "usb_5v_en");
2256 if (rc < 0) {
2257 pr_err("failed to request usb_5v_en gpio\n");
2258 goto put_mvs_otg;
2259 }
2260
2261 if (regulator_enable(mvs_otg_switch)) {
2262 pr_err("unable to enable mvs_otg_switch\n");
2263 goto free_usb_5v_en;
2264 }
2265
2266 rc = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(USB_5V_EN),
2267 &param);
2268 if (rc < 0) {
2269 pr_err("failed to configure usb_5v_en gpio\n");
2270 goto disable_mvs_otg;
2271 }
2272 vbus_is_on = true;
2273 return;
2274 }
2275disable_mvs_otg:
2276 regulator_disable(mvs_otg_switch);
2277free_usb_5v_en:
2278 gpio_free(PM8921_GPIO_PM_TO_SYS(USB_5V_EN));
2279put_mvs_otg:
2280 regulator_put(mvs_otg_switch);
2281 vbus_is_on = false;
2282}
2283
2284static struct msm_otg_platform_data msm_otg_pdata = {
2285 .mode = USB_OTG,
2286 .otg_control = OTG_PMIC_CONTROL,
2287 .phy_type = SNPS_28NM_INTEGRATED_PHY,
2288 .pclk_src_name = "dfab_usb_hs_clk",
2289 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
2290 .vbus_power = msm_hsusb_vbus_power,
2291};
2292#endif
2293
2294#define PID_MAGIC_ID 0x71432909
2295#define SERIAL_NUM_MAGIC_ID 0x61945374
2296#define SERIAL_NUMBER_LENGTH 127
2297#define DLOAD_USB_BASE_ADD 0x2A03F0C8
2298
2299struct magic_num_struct {
2300 uint32_t pid;
2301 uint32_t serial_num;
2302};
2303
2304struct dload_struct {
2305 uint32_t reserved1;
2306 uint32_t reserved2;
2307 uint32_t reserved3;
2308 uint16_t reserved4;
2309 uint16_t pid;
2310 char serial_number[SERIAL_NUMBER_LENGTH];
2311 uint16_t reserved5;
2312 struct magic_num_struct magic_struct;
2313};
2314
2315static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
2316{
2317 struct dload_struct __iomem *dload = 0;
2318
2319 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
2320 if (!dload) {
2321 pr_err("%s: cannot remap I/O memory region: %08x\n",
2322 __func__, DLOAD_USB_BASE_ADD);
2323 return -ENXIO;
2324 }
2325
2326 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
2327 __func__, dload, pid, snum);
2328 /* update pid */
2329 dload->magic_struct.pid = PID_MAGIC_ID;
2330 dload->pid = pid;
2331
2332 /* update serial number */
2333 dload->magic_struct.serial_num = 0;
2334 if (!snum) {
2335 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
2336 goto out;
2337 }
2338
2339 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
2340 strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
2341 dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
2342out:
2343 iounmap(dload);
2344 return 0;
2345}
2346
2347static struct android_usb_platform_data android_usb_pdata = {
2348 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2349};
2350
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002351static struct platform_device android_usb_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002352 .name = "android_usb",
2353 .id = -1,
2354 .dev = {
2355 .platform_data = &android_usb_pdata,
2356 },
2357};
2358
2359static uint8_t spm_wfi_cmd_sequence[] __initdata = {
2360 0x03, 0x0f,
2361};
2362
2363static uint8_t spm_power_collapse_without_rpm[] __initdata = {
2364 0x00, 0x24, 0x54, 0x10,
2365 0x09, 0x03, 0x01,
2366 0x10, 0x54, 0x30, 0x0C,
2367 0x24, 0x30, 0x0f,
2368};
2369
2370static uint8_t spm_power_collapse_with_rpm[] __initdata = {
2371 0x00, 0x24, 0x54, 0x10,
2372 0x09, 0x07, 0x01, 0x0B,
2373 0x10, 0x54, 0x30, 0x0C,
2374 0x24, 0x30, 0x0f,
2375};
2376
2377static struct msm_spm_seq_entry msm_spm_seq_list[] __initdata = {
2378 [0] = {
2379 .mode = MSM_SPM_MODE_CLOCK_GATING,
2380 .notify_rpm = false,
2381 .cmd = spm_wfi_cmd_sequence,
2382 },
2383 [1] = {
2384 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2385 .notify_rpm = false,
2386 .cmd = spm_power_collapse_without_rpm,
2387 },
2388 [2] = {
2389 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2390 .notify_rpm = true,
2391 .cmd = spm_power_collapse_with_rpm,
2392 },
2393};
2394
2395static struct msm_spm_platform_data msm_spm_data[] __initdata = {
2396 [0] = {
2397 .reg_base_addr = MSM_SAW0_BASE,
2398 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
2399 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
2400 .reg_init_values[MSM_SPM_REG_SAW2_VCTL] = 0x9C,
2401#if defined(CONFIG_MSM_AVS_HW)
2402 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2403 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2404#endif
2405 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
2406 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
2407 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2408 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2409 .vctl_timeout_us = 50,
2410 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
2411 .modes = msm_spm_seq_list,
2412 },
2413 [1] = {
2414 .reg_base_addr = MSM_SAW1_BASE,
2415 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
2416 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
2417 .reg_init_values[MSM_SPM_REG_SAW2_VCTL] = 0x9C,
2418#if defined(CONFIG_MSM_AVS_HW)
2419 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2420 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2421#endif
2422 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
2423 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
2424 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2425 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2426 .vctl_timeout_us = 50,
2427 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
2428 .modes = msm_spm_seq_list,
2429 },
2430};
2431
2432static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
2433 0x00, 0x20, 0x03, 0x20,
2434 0x00, 0x0f,
2435};
2436
2437static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
2438 0x00, 0x20, 0x34, 0x64,
2439 0x48, 0x07, 0x48, 0x20,
2440 0x50, 0x64, 0x04, 0x34,
2441 0x50, 0x0f,
2442};
2443static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
2444 0x00, 0x10, 0x34, 0x64,
2445 0x48, 0x07, 0x48, 0x10,
2446 0x50, 0x64, 0x04, 0x34,
2447 0x50, 0x0F,
2448};
2449
2450static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
2451 [0] = {
2452 .mode = MSM_SPM_L2_MODE_RETENTION,
2453 .notify_rpm = false,
2454 .cmd = l2_spm_wfi_cmd_sequence,
2455 },
2456 [1] = {
2457 .mode = MSM_SPM_L2_MODE_GDHS,
2458 .notify_rpm = true,
2459 .cmd = l2_spm_gdhs_cmd_sequence,
2460 },
2461 [2] = {
2462 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
2463 .notify_rpm = true,
2464 .cmd = l2_spm_power_off_cmd_sequence,
2465 },
2466};
2467
2468
2469static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
2470 [0] = {
2471 .reg_base_addr = MSM_SAW_L2_BASE,
2472 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
2473 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
2474 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
2475 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
2476 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
2477 .modes = msm_spm_l2_seq_list,
2478 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
2479 },
2480};
2481
2482#define CYTTSP_TS_GPIO_IRQ 11
2483#define CYTTSP_TS_SLEEP_GPIO 50
2484#define CYTTSP_TS_RESOUT_N_GPIO 52
2485
2486/*virtual key support */
2487static ssize_t tma340_vkeys_show(struct kobject *kobj,
2488 struct kobj_attribute *attr, char *buf)
2489{
2490 return snprintf(buf, 200,
2491 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
2492 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
2493 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
2494 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
2495 "\n");
2496}
2497
2498static struct kobj_attribute tma340_vkeys_attr = {
2499 .attr = {
2500 .mode = S_IRUGO,
2501 },
2502 .show = &tma340_vkeys_show,
2503};
2504
2505static struct attribute *tma340_properties_attrs[] = {
2506 &tma340_vkeys_attr.attr,
2507 NULL
2508};
2509
2510static struct attribute_group tma340_properties_attr_group = {
2511 .attrs = tma340_properties_attrs,
2512};
2513
2514
2515static int cyttsp_platform_init(struct i2c_client *client)
2516{
2517 int rc = 0;
2518 static struct kobject *tma340_properties_kobj;
2519
2520 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
2521 tma340_properties_kobj = kobject_create_and_add("board_properties",
2522 NULL);
2523 if (tma340_properties_kobj)
2524 rc = sysfs_create_group(tma340_properties_kobj,
2525 &tma340_properties_attr_group);
2526 if (!tma340_properties_kobj || rc)
2527 pr_err("%s: failed to create board_properties\n",
2528 __func__);
2529
2530 return 0;
2531}
2532
2533static struct cyttsp_regulator regulator_data[] = {
2534 {
2535 .name = "vdd",
2536 .min_uV = CY_TMA300_VTG_MIN_UV,
2537 .max_uV = CY_TMA300_VTG_MAX_UV,
2538 .load_uA = CY_TMA300_CURR_24HZ_UA,
2539 },
2540 /* TODO: Remove after runtime PM is enabled in I2C driver */
2541 {
2542 .name = "vcc_i2c",
2543 .min_uV = CY_I2C_VTG_MIN_UV,
2544 .max_uV = CY_I2C_VTG_MAX_UV,
2545 .load_uA = CY_I2C_CURR_UA,
2546 },
2547};
2548
2549static struct cyttsp_platform_data cyttsp_pdata = {
2550 .panel_maxx = 634,
2551 .panel_maxy = 1166,
2552 .disp_maxx = 616,
2553 .disp_maxy = 1023,
2554 .disp_minx = 0,
2555 .disp_miny = 16,
2556 .flags = 0x01,
2557 .gen = CY_GEN3, /* or */
2558 .use_st = CY_USE_ST,
2559 .use_mt = CY_USE_MT,
2560 .use_hndshk = CY_SEND_HNDSHK,
2561 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayale96f66d2011-08-11 14:06:38 +05302562 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002563 .use_gestures = CY_USE_GESTURES,
2564 .fw_fname = "cyttsp_8960_cdp.hex",
2565 /* activate up to 4 groups
2566 * and set active distance
2567 */
2568 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
2569 CY_GEST_GRP3 | CY_GEST_GRP4 |
2570 CY_ACT_DIST,
2571 /* change act_intrvl to customize the Active power state
2572 * scanning/processing refresh interval for Operating mode
2573 */
2574 .act_intrvl = CY_ACT_INTRVL_DFLT,
2575 /* change tch_tmout to customize the touch timeout for the
2576 * Active power state for Operating mode
2577 */
2578 .tch_tmout = CY_TCH_TMOUT_DFLT,
2579 /* change lp_intrvl to customize the Low Power power state
2580 * scanning/processing refresh interval for Operating mode
2581 */
2582 .lp_intrvl = CY_LP_INTRVL_DFLT,
2583 .sleep_gpio = CYTTSP_TS_SLEEP_GPIO,
2584 .resout_gpio = CYTTSP_TS_RESOUT_N_GPIO,
2585 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
2586 .regulator_info = regulator_data,
2587 .num_regulators = ARRAY_SIZE(regulator_data),
2588 .init = cyttsp_platform_init,
Mohan Pallaka49c37d62011-08-01 11:52:00 +05302589 .correct_fw_ver = 9,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002590};
2591
2592static struct i2c_board_info cyttsp_info[] __initdata = {
2593 {
2594 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
2595 .platform_data = &cyttsp_pdata,
2596#ifndef CY_USE_TIMER
2597 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
2598#endif /* CY_USE_TIMER */
2599 },
2600};
2601
2602static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
2603{
2604}
2605
2606static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi4_pdata = {
2607 .clk_freq = 100000,
2608 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002609 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2610};
2611
2612static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi3_pdata = {
2613 .clk_freq = 100000,
2614 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002615 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2616};
2617
2618static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi10_pdata = {
2619 .clk_freq = 100000,
2620 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002621 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2622};
2623
2624static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi12_pdata = {
2625 .clk_freq = 100000,
2626 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002627 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2628};
2629
2630static struct msm_rpm_platform_data msm_rpm_data = {
2631 .reg_base_addrs = {
2632 [MSM_RPM_PAGE_STATUS] = MSM_RPM_BASE,
2633 [MSM_RPM_PAGE_CTRL] = MSM_RPM_BASE + 0x400,
2634 [MSM_RPM_PAGE_REQ] = MSM_RPM_BASE + 0x600,
2635 [MSM_RPM_PAGE_ACK] = MSM_RPM_BASE + 0xa00,
2636 },
2637
2638 .irq_ack = RPM_APCC_CPU0_GP_HIGH_IRQ,
2639 .irq_err = RPM_APCC_CPU0_GP_LOW_IRQ,
2640 .irq_vmpm = RPM_APCC_CPU0_GP_MEDIUM_IRQ,
2641 .msm_apps_ipc_rpm_reg = MSM_APCS_GCC_BASE + 0x008,
2642 .msm_apps_ipc_rpm_val = 4,
2643};
2644
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06002645static struct platform_device msm_rpm_device = {
2646 .name = "msm_rpm",
2647 .id = -1,
2648};
2649
2650
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002651static struct spi_board_info spi_board_info[] __initdata = {
2652 {
2653 .modalias = "ks8851",
2654 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2655 .max_speed_hz = 19200000,
2656 .bus_num = 0,
2657 .chip_select = 0,
2658 .mode = SPI_MODE_0,
2659 },
2660};
2661
2662static struct platform_device msm_device_saw_core0 = {
2663 .name = "saw-regulator",
2664 .id = 0,
2665 .dev = {
2666 .platform_data = &msm_saw_regulator_pdata_s5,
2667 },
2668};
2669
2670static struct platform_device msm_device_saw_core1 = {
2671 .name = "saw-regulator",
2672 .id = 1,
2673 .dev = {
2674 .platform_data = &msm_saw_regulator_pdata_s6,
2675 },
2676};
2677
2678#ifdef CONFIG_MSM_FAKE_BATTERY
2679static struct platform_device fish_battery_device = {
2680 .name = "fish_battery",
2681};
2682#endif
2683
David Collins26f05562011-06-20 09:56:28 -07002684static struct platform_device msm8960_device_ext_5v_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002685 .name = GPIO_REGULATOR_DEV_NAME,
2686 .id = PM8921_MPP_PM_TO_SYS(7),
2687 .dev = {
2688 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2689 },
2690};
2691
David Collins26f05562011-06-20 09:56:28 -07002692static struct platform_device msm8960_device_ext_l2_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002693 .name = GPIO_REGULATOR_DEV_NAME,
2694 .id = 91,
2695 .dev = {
2696 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
2697 },
2698};
2699
David Collins26f05562011-06-20 09:56:28 -07002700static struct platform_device msm8960_device_rpm_regulator __devinitdata = {
2701 .name = "rpm-regulator",
2702 .id = -1,
2703 .dev = {
2704 .platform_data = &msm_rpm_regulator_pdata,
2705 },
2706};
2707
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002708static struct platform_device *common_devices[] __initdata = {
Stepan Moskovchenkodf13d342011-08-03 19:01:25 -07002709 &msm8960_device_dmov,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002710 &msm_device_smd,
2711 &msm8960_device_uart_gsbi5,
Mayank Rana9f51f582011-08-04 18:35:59 +05302712 &msm_device_uart_dm6,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002713 &msm_device_saw_core0,
2714 &msm_device_saw_core1,
2715 &msm8960_device_ext_5v_vreg,
2716 &msm8960_device_ext_l2_vreg,
2717 &msm8960_device_ssbi_pm8921,
2718 &msm8960_device_qup_spi_gsbi1,
2719 &msm8960_device_qup_i2c_gsbi3,
2720 &msm8960_device_qup_i2c_gsbi4,
2721 &msm8960_device_qup_i2c_gsbi10,
2722#ifndef CONFIG_MSM_DSPS
2723 &msm8960_device_qup_i2c_gsbi12,
2724#endif
2725 &msm_slim_ctrl,
2726 &msm_device_wcnss_wlan,
2727#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2728 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2729 &qcrypto_device,
2730#endif
2731
2732#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2733 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2734 &qcedev_device,
2735#endif
2736#ifdef CONFIG_MSM_ROTATOR
2737 &msm_rotator_device,
2738#endif
2739 &msm_device_sps,
2740#ifdef CONFIG_MSM_FAKE_BATTERY
2741 &fish_battery_device,
2742#endif
2743#ifdef CONFIG_ANDROID_PMEM
2744 &android_pmem_device,
2745 &android_pmem_adsp_device,
2746 &android_pmem_audio_device,
2747#endif
2748 &msm_fb_device,
2749 &msm_device_vidc,
2750 &msm_device_bam_dmux,
2751 &msm_fm_platform_init,
Mona Hossain9c430e32011-07-27 11:04:47 -07002752
2753#ifdef CONFIG_HW_RANDOM_MSM
2754 &msm_device_rng,
2755#endif
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06002756 &msm_rpm_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002757};
2758
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08002759static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002760 &msm8960_device_otg,
2761 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002762 &msm_device_hsusb_host,
2763 &android_usb_device,
2764 &msm_device_vidc,
2765 &mipi_dsi_simulator_panel_device,
2766 &msm_bus_apps_fabric,
2767 &msm_bus_sys_fabric,
2768 &msm_bus_mm_fabric,
2769 &msm_bus_sys_fpb,
2770 &msm_bus_cpss_fpb,
2771 &msm_pcm,
2772 &msm_pcm_routing,
2773 &msm_cpudai0,
2774 &msm_cpudai1,
2775 &msm_cpudai_hdmi_rx,
2776 &msm_cpudai_bt_rx,
2777 &msm_cpudai_bt_tx,
2778 &msm_cpudai_fm_rx,
2779 &msm_cpudai_fm_tx,
2780 &msm_cpu_fe,
2781 &msm_stub_codec,
2782 &msm_voice,
2783 &msm_voip,
2784 &msm_lpa_pcm,
2785
2786#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2787 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2788 &qcrypto_device,
2789#endif
2790
2791#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2792 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2793 &qcedev_device,
2794#endif
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08002795};
2796
2797static struct platform_device *rumi3_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002798 &msm_kgsl_3d0,
2799 &msm_kgsl_2d0,
2800 &msm_kgsl_2d1,
2801 &mipi_dsi_renesas_panel_device,
2802#ifdef CONFIG_MSM_GEMINI
2803 &msm8960_gemini_device,
2804#endif
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08002805};
2806
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002807static struct platform_device *cdp_devices[] __initdata = {
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002808 &msm8960_device_otg,
2809 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002810 &msm_device_hsusb_host,
2811 &android_usb_device,
2812 &msm_pcm,
2813 &msm_pcm_routing,
2814 &msm_cpudai0,
2815 &msm_cpudai1,
2816 &msm_cpudai_hdmi_rx,
2817 &msm_cpudai_bt_rx,
2818 &msm_cpudai_bt_tx,
2819 &msm_cpudai_fm_rx,
2820 &msm_cpudai_fm_tx,
2821 &msm_cpu_fe,
2822 &msm_stub_codec,
2823 &msm_kgsl_3d0,
2824#ifdef CONFIG_MSM_KGSL_2D
2825 &msm_kgsl_2d0,
2826 &msm_kgsl_2d1,
2827#endif
2828 &mipi_dsi_toshiba_panel_device,
2829#ifdef CONFIG_MSM_GEMINI
2830 &msm8960_gemini_device,
2831#endif
2832 &msm_voice,
2833 &msm_voip,
2834 &msm_lpa_pcm,
2835#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
2836 &hdmi_msm_device,
2837#endif
2838 &msm_pcm_hostless,
2839 &msm_bus_apps_fabric,
2840 &msm_bus_sys_fabric,
2841 &msm_bus_mm_fabric,
2842 &msm_bus_sys_fpb,
2843 &msm_bus_cpss_fpb,
2844};
2845
2846static void __init msm8960_i2c_init(void)
2847{
2848 msm8960_device_qup_i2c_gsbi4.dev.platform_data =
2849 &msm8960_i2c_qup_gsbi4_pdata;
2850
2851 msm8960_device_qup_i2c_gsbi3.dev.platform_data =
2852 &msm8960_i2c_qup_gsbi3_pdata;
2853
2854 msm8960_device_qup_i2c_gsbi10.dev.platform_data =
2855 &msm8960_i2c_qup_gsbi10_pdata;
2856
2857 msm8960_device_qup_i2c_gsbi12.dev.platform_data =
2858 &msm8960_i2c_qup_gsbi12_pdata;
2859}
2860
Lucille Sylvester34ec3692011-08-16 16:28:04 -06002861static void __init msm8960_gfx_init(void)
2862{
2863 uint32_t soc_platform_version = socinfo_get_platform_version();
2864 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1) {
2865 struct kgsl_device_platform_data *kgsl_3d0_pdata =
2866 msm_kgsl_3d0.dev.platform_data;
2867 kgsl_3d0_pdata->pwr_data.pwrlevel[0].gpu_freq =
2868 320000000;
2869 kgsl_3d0_pdata->pwr_data.pwrlevel[1].gpu_freq =
2870 266667000;
2871 }
2872}
2873
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002874static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
2875 .irq_base = PM8921_IRQ_BASE,
2876 .devirq = MSM_GPIO_TO_INT(104),
2877 .irq_trigger_flag = IRQF_TRIGGER_LOW,
2878};
2879
2880static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
2881 .gpio_base = PM8921_GPIO_PM_TO_SYS(1),
2882};
2883
2884static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
2885 .mpp_base = PM8921_MPP_PM_TO_SYS(1),
2886};
2887
2888static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
2889 .rtc_write_enable = false,
2890};
2891
2892static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
2893 .pull_up = 1,
2894 .kpd_trigger_delay_us = 970,
2895 .wakeup = 1,
2896};
2897
2898static const unsigned int keymap[] = {
2899 KEY(0, 0, KEY_VOLUMEUP),
2900 KEY(0, 1, KEY_VOLUMEDOWN),
2901 KEY(0, 2, KEY_CAMERA_SNAPSHOT),
2902 KEY(0, 3, KEY_CAMERA_FOCUS),
2903};
2904
2905static struct matrix_keymap_data keymap_data = {
2906 .keymap_size = ARRAY_SIZE(keymap),
2907 .keymap = keymap,
2908};
2909
2910static struct pm8xxx_keypad_platform_data keypad_data = {
2911 .input_name = "keypad_8960",
2912 .input_phys_device = "keypad_8960/input0",
2913 .num_rows = 1,
2914 .num_cols = 5,
2915 .rows_gpio_start = PM8921_GPIO_PM_TO_SYS(9),
2916 .cols_gpio_start = PM8921_GPIO_PM_TO_SYS(1),
2917 .debounce_ms = 15,
2918 .scan_delay_ms = 32,
2919 .row_hold_ns = 91500,
2920 .wakeup = 1,
2921 .keymap_data = &keymap_data,
2922};
2923
2924static const unsigned int keymap_sim[] = {
2925 KEY(0, 0, KEY_7),
2926 KEY(0, 1, KEY_DOWN),
2927 KEY(0, 2, KEY_UP),
2928 KEY(0, 3, KEY_RIGHT),
2929 KEY(0, 4, KEY_ENTER),
2930 KEY(0, 5, KEY_L),
2931 KEY(0, 6, KEY_BACK),
2932 KEY(0, 7, KEY_M),
2933
2934 KEY(1, 0, KEY_LEFT),
2935 KEY(1, 1, KEY_SEND),
2936 KEY(1, 2, KEY_1),
2937 KEY(1, 3, KEY_4),
2938 KEY(1, 4, KEY_CLEAR),
2939 KEY(1, 5, KEY_MSDOS),
2940 KEY(1, 6, KEY_SPACE),
2941 KEY(1, 7, KEY_COMMA),
2942
2943 KEY(2, 0, KEY_6),
2944 KEY(2, 1, KEY_5),
2945 KEY(2, 2, KEY_8),
2946 KEY(2, 3, KEY_3),
2947 KEY(2, 4, KEY_NUMERIC_STAR),
2948 KEY(2, 5, KEY_UP),
2949 KEY(2, 6, KEY_DOWN),
2950 KEY(2, 7, KEY_LEFTSHIFT),
2951
2952 KEY(3, 0, KEY_9),
2953 KEY(3, 1, KEY_NUMERIC_POUND),
2954 KEY(3, 2, KEY_0),
2955 KEY(3, 3, KEY_2),
2956 KEY(3, 4, KEY_SLEEP),
2957 KEY(3, 5, KEY_F1),
2958 KEY(3, 6, KEY_F2),
2959 KEY(3, 7, KEY_F3),
2960
2961 KEY(4, 0, KEY_BACK),
2962 KEY(4, 1, KEY_HOME),
2963 KEY(4, 2, KEY_MENU),
2964 KEY(4, 3, KEY_VOLUMEUP),
2965 KEY(4, 4, KEY_VOLUMEDOWN),
2966 KEY(4, 5, KEY_F4),
2967 KEY(4, 6, KEY_F5),
2968 KEY(4, 7, KEY_F6),
2969
2970 KEY(5, 0, KEY_R),
2971 KEY(5, 1, KEY_T),
2972 KEY(5, 2, KEY_Y),
2973 KEY(5, 3, KEY_LEFTALT),
2974 KEY(5, 4, KEY_KPENTER),
2975 KEY(5, 5, KEY_Q),
2976 KEY(5, 6, KEY_W),
2977 KEY(5, 7, KEY_E),
2978
2979 KEY(6, 0, KEY_F),
2980 KEY(6, 1, KEY_G),
2981 KEY(6, 2, KEY_H),
2982 KEY(6, 3, KEY_CAPSLOCK),
2983 KEY(6, 4, KEY_PAGEUP),
2984 KEY(6, 5, KEY_A),
2985 KEY(6, 6, KEY_S),
2986 KEY(6, 7, KEY_D),
2987
2988 KEY(7, 0, KEY_V),
2989 KEY(7, 1, KEY_B),
2990 KEY(7, 2, KEY_N),
2991 KEY(7, 3, KEY_MENU),
2992 KEY(7, 4, KEY_PAGEDOWN),
2993 KEY(7, 5, KEY_Z),
2994 KEY(7, 6, KEY_X),
2995 KEY(7, 7, KEY_C),
2996
2997 KEY(8, 0, KEY_P),
2998 KEY(8, 1, KEY_J),
2999 KEY(8, 2, KEY_K),
3000 KEY(8, 3, KEY_INSERT),
3001 KEY(8, 4, KEY_LINEFEED),
3002 KEY(8, 5, KEY_U),
3003 KEY(8, 6, KEY_I),
3004 KEY(8, 7, KEY_O),
3005
3006 KEY(9, 0, KEY_4),
3007 KEY(9, 1, KEY_5),
3008 KEY(9, 2, KEY_6),
3009 KEY(9, 3, KEY_7),
3010 KEY(9, 4, KEY_8),
3011 KEY(9, 5, KEY_1),
3012 KEY(9, 6, KEY_2),
3013 KEY(9, 7, KEY_3),
3014
3015 KEY(10, 0, KEY_F7),
3016 KEY(10, 1, KEY_F8),
3017 KEY(10, 2, KEY_F9),
3018 KEY(10, 3, KEY_F10),
3019 KEY(10, 4, KEY_FN),
3020 KEY(10, 5, KEY_9),
3021 KEY(10, 6, KEY_0),
3022 KEY(10, 7, KEY_DOT),
3023
3024 KEY(11, 0, KEY_LEFTCTRL),
3025 KEY(11, 1, KEY_F11),
3026 KEY(11, 2, KEY_ENTER),
3027 KEY(11, 3, KEY_SEARCH),
3028 KEY(11, 4, KEY_DELETE),
3029 KEY(11, 5, KEY_RIGHT),
3030 KEY(11, 6, KEY_LEFT),
3031 KEY(11, 7, KEY_RIGHTSHIFT),
3032 KEY(0, 0, KEY_VOLUMEUP),
3033 KEY(0, 1, KEY_VOLUMEDOWN),
3034 KEY(0, 2, KEY_CAMERA_SNAPSHOT),
3035 KEY(0, 3, KEY_CAMERA_FOCUS),
3036};
3037
3038static struct matrix_keymap_data keymap_data_sim = {
3039 .keymap_size = ARRAY_SIZE(keymap_sim),
3040 .keymap = keymap_sim,
3041};
3042
3043static struct pm8xxx_keypad_platform_data keypad_data_sim = {
3044 .input_name = "keypad_8960",
3045 .input_phys_device = "keypad_8960/input0",
3046 .num_rows = 12,
3047 .num_cols = 8,
3048 .rows_gpio_start = PM8921_GPIO_PM_TO_SYS(9),
3049 .cols_gpio_start = PM8921_GPIO_PM_TO_SYS(1),
3050 .debounce_ms = 15,
3051 .scan_delay_ms = 32,
3052 .row_hold_ns = 91500,
3053 .wakeup = 1,
3054 .keymap_data = &keymap_data_sim,
3055};
3056
3057static struct pm8921_charger_platform_data pm8921_chg_pdata __devinitdata = {
Abhijeet Dharmapurikar34059332011-08-16 19:19:39 -07003058 .safety_time = 180,
3059 .update_time = 1,
3060 .max_voltage = 4200,
3061 .min_voltage = 3200,
3062 .resume_voltage = 4100,
3063 .term_current = 100,
3064 .cool_temp = 10,
3065 .warm_temp = 40,
3066 .temp_check_period = 1,
3067 .max_bat_chg_current = 400,
3068 .cool_bat_chg_current = 350,
3069 .warm_bat_chg_current = 350,
3070 .cool_bat_voltage = 4100,
3071 .warm_bat_voltage = 4100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003072};
3073
3074static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
3075 .priority = 0,
3076};
3077
3078static struct pm8921_bms_platform_data pm8921_bms_pdata __devinitdata = {
3079 .r_sense = 10,
3080 .i_test = 2500,
3081 .v_failure = 3000,
3082 .calib_delay_ms = 600000,
3083 .batt_data = &palladium_1500_data,
3084};
3085
Jay Chokshide4cefb2011-08-04 18:10:44 -07003086#define PM8921_LC_LED_MAX_CURRENT 4 /* I = 4mA */
3087
3088/**
3089 * 'flag' stores three values; led id, led mode, and max current of led.
3090 * The bit packing format is as follow,
3091 * reserved (1 byte) | max_current (2 bytes) | led_mode (1 nibble) |
3092 * led_id (1 nibble)
3093 */
3094#define PM8XXX_SET_FLAG(led_id, led_mode, led_max_current) \
3095 (((led_id << PM8XXX_LED_ID_SHIFT) & PM8XXX_LED_ID_MASK) |\
3096 ((led_mode << PM8XXX_LED_MODE_SHIFT) & PM8XXX_LED_MODE_MASK) |\
3097 ((led_max_current << PM8XXX_LED_MAX_CURRENT_SHIFT) & \
3098 PM8XXX_LED_MAX_CURRENT_MASK))
3099
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003100static struct led_info pm8921_led_info[] = {
3101 [0] = {
Jay Chokshide4cefb2011-08-04 18:10:44 -07003102 .name = "led:usb",
3103 .default_trigger = "usb-online",
3104 .flags = PM8XXX_SET_FLAG(PM8XXX_ID_LED_0,
3105 PM8XXX_LED_MODE_MANUAL,
3106 PM8921_LC_LED_MAX_CURRENT),
3107 },
3108 [1] = {
3109 .name = "led:ac",
3110 .default_trigger = "ac-online",
3111 .flags = PM8XXX_SET_FLAG(PM8XXX_ID_LED_1,
3112 PM8XXX_LED_MODE_MANUAL,
3113 PM8921_LC_LED_MAX_CURRENT),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003114 },
3115};
3116
3117static struct led_platform_data pm8xxx_leds_pdata = {
3118 .num_leds = ARRAY_SIZE(pm8921_led_info),
3119 .leds = pm8921_led_info,
3120};
3121
3122static struct pm8921_platform_data pm8921_platform_data __devinitdata = {
3123 .irq_pdata = &pm8xxx_irq_pdata,
3124 .gpio_pdata = &pm8xxx_gpio_pdata,
3125 .mpp_pdata = &pm8xxx_mpp_pdata,
3126 .rtc_pdata = &pm8xxx_rtc_pdata,
3127 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
3128 .keypad_pdata = &keypad_data,
3129 .misc_pdata = &pm8xxx_misc_pdata,
3130 .regulator_pdatas = msm_pm8921_regulator_pdata,
3131 .charger_pdata = &pm8921_chg_pdata,
3132 .bms_pdata = &pm8921_bms_pdata,
3133 .adc_pdata = &pm8921_adc_pdata,
3134 .leds_pdata = &pm8xxx_leds_pdata,
3135};
3136
3137static struct msm_ssbi_platform_data msm8960_ssbi_pm8921_pdata __devinitdata = {
3138 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
3139 .slave = {
3140 .name = "pm8921-core",
3141 .platform_data = &pm8921_platform_data,
3142 },
3143};
3144
3145static void msm8960_wcnss_init(void)
3146{
3147 int i, ret, j;
3148
3149 for (i = 0; i < ARRAY_SIZE(wcnss_5wire_interface); i++) {
3150 ret = gpio_request(wcnss_5wire_interface[i].gpio,
3151 "wcnss_5_wire");
3152 if (ret) {
3153 pr_err("wcnss_5_wire gpio %d failed: %d\n",
3154 wcnss_5wire_interface[i].gpio, ret);
3155 goto fail;
3156 }
3157 }
3158
3159 pr_info("%s: Iris 5-wire gpios configured\n", __func__);
3160
3161 return;
3162
3163fail:
3164 for (j = 0; j < i; j++)
3165 gpio_free(wcnss_5wire_interface[j].gpio);
3166}
3167
Stepan Moskovchenko41d168272011-08-09 17:09:42 -07003168#ifdef CONFIG_KS8851
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003169static int ethernet_init(void)
3170{
3171 int ret;
3172 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
3173 if (ret) {
3174 pr_err("ks8851 gpio_request failed: %d\n", ret);
3175 goto fail;
3176 }
3177
3178 ret = gpio_request(KS8851_RST_GPIO, "ks8851_rst");
3179 if (ret) {
3180 pr_err("ks8851 gpio_request failed: %d\n", ret);
3181 goto fail_rst;
3182 }
3183
3184 ret = gpio_request(FPGA_CS_GPIO, "fpga_cs");
3185 if (ret) {
3186 pr_err("ks8851 gpio_request failed: %d\n", ret);
3187 goto fail_cs;
3188 }
3189
3190 gpio_direction_output(FPGA_CS_GPIO, 1);
3191 gpio_direction_output(KS8851_RST_GPIO, 1);
3192 return 0;
3193fail_cs:
3194 gpio_free(KS8851_RST_GPIO);
3195fail_rst:
3196 gpio_free(KS8851_IRQ_GPIO);
3197fail:
3198 return ret;
3199}
Stepan Moskovchenko41d168272011-08-09 17:09:42 -07003200#else
3201static int ethernet_init(void)
3202{
3203 return 0;
3204}
3205#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003206
3207static struct msm_cpuidle_state msm_cstates[] __initdata = {
3208 {0, 0, "C0", "WFI",
3209 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
3210
3211 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
3212 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
3213
3214 {0, 2, "C2", "POWER_COLLAPSE",
3215 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
3216
3217 {1, 0, "C0", "WFI",
3218 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
3219
3220 {1, 1, "C1", "STANDALONE_POWER_COLLAPSE",
3221 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
3222};
3223
3224static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
3225 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
3226 .idle_supported = 1,
3227 .suspend_supported = 1,
3228 .idle_enabled = 0,
3229 .suspend_enabled = 0,
3230 .latency = 4000,
3231 .residency = 13000,
3232 },
3233
3234 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
3235 .idle_supported = 1,
3236 .suspend_supported = 1,
3237 .idle_enabled = 0,
3238 .suspend_enabled = 0,
3239 .latency = 500,
3240 .residency = 6000,
3241 },
3242
3243 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
3244 .idle_supported = 1,
3245 .suspend_supported = 1,
3246 .idle_enabled = 1,
3247 .suspend_enabled = 1,
3248 .latency = 2,
3249 .residency = 0,
3250 },
3251
3252 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
3253 .idle_supported = 0,
3254 .suspend_supported = 1,
3255 .idle_enabled = 0,
3256 .suspend_enabled = 0,
3257 .latency = 600,
3258 .residency = 7200,
3259 },
3260
3261 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
3262 .idle_supported = 1,
3263 .suspend_supported = 1,
3264 .idle_enabled = 0,
3265 .suspend_enabled = 0,
3266 .latency = 500,
3267 .residency = 6000,
3268 },
3269
3270 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
3271 .idle_supported = 1,
3272 .suspend_supported = 0,
3273 .idle_enabled = 1,
3274 .suspend_enabled = 0,
3275 .latency = 2,
3276 .residency = 0,
3277 },
3278};
3279
3280static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
3281 {
3282 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
3283 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3284 true,
3285 1, 8000, 100000, 1,
3286 },
3287
3288 {
3289 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
3290 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3291 true,
3292 1500, 5000, 60100000, 3000,
3293 },
3294
3295 {
3296 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3297 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
3298 false,
3299 1800, 5000, 60350000, 3500,
3300 },
3301
3302 {
3303 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3304 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
3305 false,
3306 2800, 2500, 65350000, 4800,
3307 },
3308
3309 {
3310 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3311 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
3312 false,
3313 3800, 4500, 67850000, 5500,
3314 },
3315
3316 {
3317 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3318 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
3319 false,
3320 4800, 2000, 71850000, 6800,
3321 },
3322
3323 {
3324 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3325 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
3326 false,
3327 6800, 500, 75850000, 8800,
3328 },
3329
3330 {
3331 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3332 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
3333 false,
3334 7800, 0, 76350000, 9800,
3335 },
3336};
3337
3338#ifdef CONFIG_I2C
3339#define I2C_SURF 1
3340#define I2C_FFA (1 << 1)
3341#define I2C_RUMI (1 << 2)
3342#define I2C_SIM (1 << 3)
3343#define I2C_FLUID (1 << 4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003344
3345struct i2c_registry {
3346 u8 machs;
3347 int bus;
3348 struct i2c_board_info *info;
3349 int len;
3350};
3351
3352#ifdef CONFIG_MSM_CAMERA
3353static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
3354#ifdef CONFIG_IMX074
3355 {
3356 I2C_BOARD_INFO("imx074", 0x1A),
3357 },
3358#endif
3359#ifdef CONFIG_OV2720
3360 {
3361 I2C_BOARD_INFO("ov2720", 0x6C),
3362 },
3363#endif
Kevin Chandfecce22011-07-13 10:52:41 -07003364 {
3365 I2C_BOARD_INFO("qs_mt9p017", 0x6C >> 1),
3366 },
Nishant Pandit474f2252011-07-23 23:17:56 +05303367#ifdef CONFIG_MSM_CAMERA_FLASH_SC628A
3368 {
3369 I2C_BOARD_INFO("sc628a", 0x6E),
3370 },
3371#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003372};
3373#endif
3374
3375/* Sensors DSPS platform data */
3376#ifdef CONFIG_MSM_DSPS
3377#define DSPS_PIL_GENERIC_NAME "dsps"
3378#endif /* CONFIG_MSM_DSPS */
3379
3380static void __init msm8960_init_dsps(void)
3381{
3382#ifdef CONFIG_MSM_DSPS
3383 struct msm_dsps_platform_data *pdata =
3384 msm_dsps_device.dev.platform_data;
3385 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
3386 pdata->gpios = NULL;
3387 pdata->gpios_num = 0;
3388
3389 platform_device_register(&msm_dsps_device);
3390#endif /* CONFIG_MSM_DSPS */
3391}
3392
3393static struct i2c_registry msm8960_i2c_devices[] __initdata = {
3394#ifdef CONFIG_MSM_CAMERA
3395 {
3396 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_RUMI,
3397 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
3398 msm_camera_boardinfo,
3399 ARRAY_SIZE(msm_camera_boardinfo),
3400 },
3401#endif
3402 {
3403 I2C_SURF | I2C_FFA | I2C_FLUID,
3404 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3405 cyttsp_info,
3406 ARRAY_SIZE(cyttsp_info),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -07003407 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003408};
3409#endif /* CONFIG_I2C */
3410
3411static void __init register_i2c_devices(void)
3412{
3413#ifdef CONFIG_I2C
3414 u8 mach_mask = 0;
3415 int i;
3416
3417 /* Build the matching 'supported_machs' bitmask */
3418 if (machine_is_msm8960_cdp())
3419 mach_mask = I2C_SURF;
3420 else if (machine_is_msm8960_rumi3())
3421 mach_mask = I2C_RUMI;
3422 else if (machine_is_msm8960_sim())
3423 mach_mask = I2C_SIM;
Amy Maloche2d028032011-07-20 14:08:06 -07003424 else if (machine_is_msm8960_fluid())
3425 mach_mask = I2C_FLUID;
Amy Maloche1b0663f2011-08-02 16:46:22 -07003426 else if (machine_is_msm8960_mtp())
3427 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003428 else
3429 pr_err("unmatched machine ID in register_i2c_devices\n");
3430
3431 /* Run the array and install devices as appropriate */
3432 for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
3433 if (msm8960_i2c_devices[i].machs & mach_mask)
3434 i2c_register_board_info(msm8960_i2c_devices[i].bus,
3435 msm8960_i2c_devices[i].info,
3436 msm8960_i2c_devices[i].len);
3437 }
3438#endif
3439}
3440
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003441static void __init msm8960_sim_init(void)
3442{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003443 if (socinfo_init() < 0)
3444 pr_err("socinfo_init() failed!\n");
3445
3446 BUG_ON(msm_rpm_init(&msm_rpm_data));
3447 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
3448 ARRAY_SIZE(msm_rpmrs_levels)));
3449 regulator_suppress_info_printing();
David Collins26f05562011-06-20 09:56:28 -07003450 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003451 msm_clock_init(&msm8960_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003452 msm8960_device_ssbi_pm8921.dev.platform_data =
3453 &msm8960_ssbi_pm8921_pdata;
3454 pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003455
3456 /* Simulator supports a QWERTY keypad */
3457 pm8921_platform_data.keypad_pdata = &keypad_data_sim;
3458
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003459 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
3460 msm8960_device_gadget_peripheral.dev.parent = &msm8960_device_otg.dev;
3461 msm_device_hsusb_host.dev.parent = &msm8960_device_otg.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003462 gpiomux_init();
3463 ethernet_init();
3464 msm8960_i2c_init();
3465 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3466 msm_spm_l2_init(msm_spm_l2_data);
3467 msm8960_init_buses();
3468 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
3469 pm8921_gpio_mpp_init();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003470 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003471 msm_acpu_clock_init(&msm8960_acpu_clock_data);
3472
3473 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3474 &msm8960_qup_spi_gsbi1_pdata;
3475 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
3476
3477 msm8960_init_mmc();
3478 msm_fb_add_devices();
3479 slim_register_board_info(msm_slim_devices,
3480 ARRAY_SIZE(msm_slim_devices));
3481 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
3482 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
3483 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
3484 msm_pm_data);
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003485}
3486
3487static void __init msm8960_rumi3_init(void)
3488{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003489 if (socinfo_init() < 0)
3490 pr_err("socinfo_init() failed!\n");
3491
3492 BUG_ON(msm_rpm_init(&msm_rpm_data));
3493 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
3494 ARRAY_SIZE(msm_rpmrs_levels)));
3495 regulator_suppress_info_printing();
David Collins26f05562011-06-20 09:56:28 -07003496 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003497 msm_clock_init(&msm8960_dummy_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003498 gpiomux_init();
3499 ethernet_init();
3500 msm8960_device_ssbi_pm8921.dev.platform_data =
3501 &msm8960_ssbi_pm8921_pdata;
3502 pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len;
3503 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3504 &msm8960_qup_spi_gsbi1_pdata;
3505 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
3506 msm8960_i2c_init();
3507 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3508 msm_spm_l2_init(msm_spm_l2_data);
3509 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
3510 pm8921_gpio_mpp_init();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003511 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003512 msm8960_init_mmc();
3513
3514 register_i2c_devices();
3515 msm_fb_add_devices();
3516 slim_register_board_info(msm_slim_devices,
3517 ARRAY_SIZE(msm_slim_devices));
3518 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
3519 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
3520 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
3521 msm_pm_data);
3522}
3523
3524static void __init msm8960_cdp_init(void)
3525{
3526 if (socinfo_init() < 0)
3527 pr_err("socinfo_init() failed!\n");
3528
3529 BUG_ON(msm_rpm_init(&msm_rpm_data));
3530 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
3531 ARRAY_SIZE(msm_rpmrs_levels)));
3532 regulator_suppress_info_printing();
3533 if (msm_xo_init())
3534 pr_err("Failed to initialize XO votes\n");
David Collins26f05562011-06-20 09:56:28 -07003535 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003536 msm_clock_init(&msm8960_clock_init_data);
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003537 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
3538 msm8960_device_gadget_peripheral.dev.parent = &msm8960_device_otg.dev;
3539 msm_device_hsusb_host.dev.parent = &msm8960_device_otg.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003540 gpiomux_init();
3541 ethernet_init();
3542 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3543 &msm8960_qup_spi_gsbi1_pdata;
3544 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
3545 msm8960_device_ssbi_pm8921.dev.platform_data =
3546 &msm8960_ssbi_pm8921_pdata;
3547 pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len;
3548 msm8960_i2c_init();
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003549 msm8960_gfx_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003550 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3551 msm_spm_l2_init(msm_spm_l2_data);
3552 msm8960_init_buses();
3553 platform_add_devices(msm_footswitch_devices,
3554 msm_num_footswitch_devices);
3555 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
3556 pm8921_gpio_mpp_init();
3557 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
3558 msm8960_init_cam();
3559 msm8960_init_mmc();
3560 msm_acpu_clock_init(&msm8960_acpu_clock_data);
3561 register_i2c_devices();
3562 msm8960_wcnss_init();
3563 msm_fb_add_devices();
3564 slim_register_board_info(msm_slim_devices,
3565 ARRAY_SIZE(msm_slim_devices));
3566 msm8960_init_dsps();
3567 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
3568 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
3569 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
3570 msm_pm_data);
Larry Bassela7eadea2011-07-14 10:46:00 -07003571 change_memory_power = &msm8960_change_memory_power;
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003572}
3573
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003574MACHINE_START(MSM8960_SIM, "QCT MSM8960 SIMULATOR")
3575 .map_io = msm8960_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003576 .reserve = msm8960_reserve,
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003577 .init_irq = msm8960_init_irq,
3578 .timer = &msm_timer,
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003579 .init_machine = msm8960_sim_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003580 .init_early = msm8960_allocate_memory_regions,
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003581MACHINE_END
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003582
3583MACHINE_START(MSM8960_RUMI3, "QCT MSM8960 RUMI3")
3584 .map_io = msm8960_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003585 .reserve = msm8960_reserve,
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003586 .init_irq = msm8960_init_irq,
3587 .timer = &msm_timer,
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003588 .init_machine = msm8960_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003589 .init_early = msm8960_allocate_memory_regions,
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003590MACHINE_END
3591
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003592MACHINE_START(MSM8960_CDP, "QCT MSM8960 CDP")
3593 .map_io = msm8960_map_io,
3594 .reserve = msm8960_reserve,
3595 .init_irq = msm8960_init_irq,
3596 .timer = &msm_timer,
3597 .init_machine = msm8960_cdp_init,
3598 .init_early = msm8960_allocate_memory_regions,
3599MACHINE_END
3600
3601MACHINE_START(MSM8960_MTP, "QCT MSM8960 MTP")
3602 .map_io = msm8960_map_io,
3603 .reserve = msm8960_reserve,
3604 .init_irq = msm8960_init_irq,
3605 .timer = &msm_timer,
3606 .init_machine = msm8960_cdp_init,
3607 .init_early = msm8960_allocate_memory_regions,
3608MACHINE_END
3609
3610MACHINE_START(MSM8960_FLUID, "QCT MSM8960 FLUID")
3611 .map_io = msm8960_map_io,
3612 .reserve = msm8960_reserve,
3613 .init_irq = msm8960_init_irq,
3614 .timer = &msm_timer,
3615 .init_machine = msm8960_cdp_init,
3616 .init_early = msm8960_allocate_memory_regions,
3617MACHINE_END
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003618
3619MACHINE_START(MSM8960_LIQUID, "QCT MSM8960 LIQUID")
3620 .map_io = msm8960_map_io,
3621 .reserve = msm8960_reserve,
3622 .init_irq = msm8960_init_irq,
3623 .timer = &msm_timer,
3624 .init_machine = msm8960_cdp_init,
3625 .init_early = msm8960_allocate_memory_regions,
3626MACHINE_END