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