blob: 87896df046a5ff7289ee932157c6bd6be495e3c4 [file] [log] [blame]
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08001/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080012 */
13#include <linux/kernel.h>
14#include <linux/platform_device.h>
15#include <linux/io.h>
16#include <linux/irq.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070017#include <linux/i2c.h>
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -070018#include <linux/i2c/sx150x.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070019#include <linux/gpio.h>
20#include <linux/msm_ssbi.h>
21#include <linux/regulator/gpio-regulator.h>
22#include <linux/mfd/pm8xxx/pm8921.h>
23#include <linux/regulator/consumer.h>
24#include <linux/spi/spi.h>
25#include <linux/slimbus/slimbus.h>
26#include <linux/bootmem.h>
Lucille Sylvester34ec3692011-08-16 16:28:04 -060027#include <linux/msm_kgsl.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070028#ifdef CONFIG_ANDROID_PMEM
29#include <linux/android_pmem.h>
30#endif
31#include <linux/cyttsp.h>
32#include <linux/dma-mapping.h>
33#include <linux/platform_data/qcom_crypto_device.h>
Ankur Nandwanib0039b02011-08-09 14:00:45 -070034#include <linux/platform_data/qcom_wcnss_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070035#include <linux/leds.h>
36#include <linux/leds-pm8xxx.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080037
38#include <asm/mach-types.h>
39#include <asm/mach/arch.h>
Larry Basselb4126da2011-07-18 14:31:33 -070040#include <asm/setup.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080041#include <asm/hardware/gic.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070042#include <asm/mach/mmc.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080043
44#include <mach/board.h>
45#include <mach/msm_iomap.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046#include <mach/msm_spi.h>
47#ifdef CONFIG_USB_MSM_OTG_72K
48#include <mach/msm_hsusb.h>
49#else
50#include <linux/usb/msm_hsusb.h>
51#endif
52#include <linux/usb/android.h>
53#include <mach/usbdiag.h>
54#include <mach/socinfo.h>
55#include <mach/rpm.h>
56#include <mach/gpio.h>
Rohit Vaswania513aa8d2011-07-18 15:14:28 -070057#include <mach/gpiomux.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070058#include <mach/msm_bus_board.h>
59#include <mach/msm_memtypes.h>
60#include <mach/dma.h>
61#include <mach/msm_dsps.h>
62#include <mach/msm_xo.h>
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -080063
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070064#ifdef CONFIG_WCD9310_CODEC
65#include <linux/slimbus/slimbus.h>
66#include <linux/mfd/wcd9310/core.h>
67#include <linux/mfd/wcd9310/pdata.h>
68#endif
69
Laura Abbottd6183792011-08-19 13:42:24 -070070#include <linux/ion.h>
71#include <mach/ion.h>
72
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070073#include "timer.h"
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -080074#include "devices.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070075#include "devices-msm8x60.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076#include "spm.h"
77#include "board-msm8960.h"
78#include "pm.h"
79#include "cpuidle.h"
80#include "rpm_resources.h"
81#include "mpm.h"
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070082#include "acpuclock.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070083
84static struct platform_device msm_fm_platform_init = {
85 .name = "iris_fm",
86 .id = -1,
87};
88
89struct pm8xxx_gpio_init {
90 unsigned gpio;
91 struct pm_gpio config;
92};
93
94struct pm8xxx_mpp_init {
95 unsigned mpp;
96 struct pm8xxx_mpp_config_data config;
97};
98
99#define PM8XXX_GPIO_INIT(_gpio, _dir, _buf, _val, _pull, _vin, _out_strength, \
100 _func, _inv, _disable) \
101{ \
102 .gpio = PM8921_GPIO_PM_TO_SYS(_gpio), \
103 .config = { \
104 .direction = _dir, \
105 .output_buffer = _buf, \
106 .output_value = _val, \
107 .pull = _pull, \
108 .vin_sel = _vin, \
109 .out_strength = _out_strength, \
110 .function = _func, \
111 .inv_int_pol = _inv, \
112 .disable_pin = _disable, \
113 } \
114}
115
116#define PM8XXX_MPP_INIT(_mpp, _type, _level, _control) \
117{ \
118 .mpp = PM8921_MPP_PM_TO_SYS(_mpp), \
119 .config = { \
120 .type = PM8XXX_MPP_TYPE_##_type, \
121 .level = _level, \
122 .control = PM8XXX_MPP_##_control, \
123 } \
124}
125
126#define PM8XXX_GPIO_DISABLE(_gpio) \
127 PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, 0, 0, 0, PM_GPIO_VIN_S4, \
128 0, 0, 0, 1)
129
130#define PM8XXX_GPIO_OUTPUT(_gpio, _val) \
131 PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
132 PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \
133 PM_GPIO_STRENGTH_HIGH, \
134 PM_GPIO_FUNC_NORMAL, 0, 0)
135
136#define PM8XXX_GPIO_INPUT(_gpio, _pull) \
137 PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_IN, PM_GPIO_OUT_BUF_CMOS, 0, \
138 _pull, PM_GPIO_VIN_S4, \
139 PM_GPIO_STRENGTH_NO, \
140 PM_GPIO_FUNC_NORMAL, 0, 0)
141
142#define PM8XXX_GPIO_OUTPUT_FUNC(_gpio, _val, _func) \
143 PM8XXX_GPIO_INIT(_gpio, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, _val, \
144 PM_GPIO_PULL_NO, PM_GPIO_VIN_S4, \
145 PM_GPIO_STRENGTH_HIGH, \
146 _func, 0, 0)
147
148/* Initial PM8921 GPIO configurations */
149static struct pm8xxx_gpio_init pm8921_gpios[] __initdata = {
150 PM8XXX_GPIO_DISABLE(6), /* Disable unused */
151 PM8XXX_GPIO_DISABLE(7), /* Disable NFC */
152 PM8XXX_GPIO_INPUT(16, PM_GPIO_PULL_UP_30), /* SD_CARD_WP */
Amir Samuelov0c7270f2011-09-07 03:13:47 +0300153 /* External regulator shared by display and touchscreen on LiQUID */
154 PM8XXX_GPIO_OUTPUT(17, 0), /* DISP 3.3 V Boost */
155 PM8XXX_GPIO_OUTPUT(21, 1), /* Backlight Enable */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700156 PM8XXX_GPIO_DISABLE(22), /* Disable NFC */
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -0700157 PM8XXX_GPIO_OUTPUT_FUNC(24, 0, PM_GPIO_FUNC_2), /* Bl: Off, PWM mode */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700158 PM8XXX_GPIO_INPUT(26, PM_GPIO_PULL_UP_30), /* SD_CARD_DET_N */
159 PM8XXX_GPIO_OUTPUT(43, 0), /* DISP_RESET_N */
160};
161
162/* Initial PM8921 MPP configurations */
163static struct pm8xxx_mpp_init pm8921_mpps[] __initdata = {
164 /* External 5V regulator enable; shared by HDMI and USB_OTG switches. */
165 PM8XXX_MPP_INIT(7, D_INPUT, PM8921_MPP_DIG_LEVEL_VPH, DIN_TO_INT),
166 PM8XXX_MPP_INIT(PM8921_AMUX_MPP_3, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH6,
167 DOUT_CTRL_LOW),
168 PM8XXX_MPP_INIT(PM8921_AMUX_MPP_8, A_INPUT, PM8XXX_MPP_AIN_AMUX_CH8,
169 DOUT_CTRL_LOW),
170};
171
172static void __init pm8921_gpio_mpp_init(void)
173{
174 int i, rc;
175
176 for (i = 0; i < ARRAY_SIZE(pm8921_gpios); i++) {
177 rc = pm8xxx_gpio_config(pm8921_gpios[i].gpio,
178 &pm8921_gpios[i].config);
179 if (rc) {
180 pr_err("%s: pm8xxx_gpio_config: rc=%d\n", __func__, rc);
181 break;
182 }
183 }
184
185 for (i = 0; i < ARRAY_SIZE(pm8921_mpps); i++) {
186 rc = pm8xxx_mpp_config(pm8921_mpps[i].mpp,
187 &pm8921_mpps[i].config);
188 if (rc) {
189 pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc);
190 break;
191 }
192 }
193}
194
195#define FPGA_CS_GPIO 14
196#define KS8851_RST_GPIO 89
197#define KS8851_IRQ_GPIO 90
198
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700199#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
200enum {
Abhijeet Dharmapurikar0fda5602011-08-17 18:00:55 -0700201 GPIO_EXPANDER_IRQ_BASE = (PM8921_IRQ_BASE + PM8921_NR_IRQS),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700202 GPIO_EXPANDER_GPIO_BASE = (PM8921_MPP_BASE + PM8921_NR_MPPS),
203 /* CAM Expander */
204 GPIO_CAM_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE,
205 GPIO_CAM_GP_STROBE_READY = GPIO_CAM_EXPANDER_BASE,
206 GPIO_CAM_GP_AFBUSY,
207 GPIO_CAM_GP_STROBE_CE,
208 GPIO_CAM_GP_CAM1MP_XCLR,
209 GPIO_CAM_GP_CAMIF_RESET_N,
210 GPIO_CAM_GP_XMT_FLASH_INT,
211 GPIO_CAM_GP_LED_EN1,
212 GPIO_CAM_GP_LED_EN2,
213
214};
215#endif
216
Harini Jayaraman608d0462011-08-09 19:10:03 -0600217/* The SPI configurations apply to GSBI 1*/
218static struct gpiomux_setting spi_active = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700219 .func = GPIOMUX_FUNC_1,
220 .drv = GPIOMUX_DRV_8MA,
221 .pull = GPIOMUX_PULL_NONE,
222};
223
Harini Jayaraman608d0462011-08-09 19:10:03 -0600224static struct gpiomux_setting spi_suspended_config = {
225 .func = GPIOMUX_FUNC_GPIO,
226 .drv = GPIOMUX_DRV_2MA,
227 .pull = GPIOMUX_PULL_DOWN,
228};
229
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700230static struct gpiomux_setting gsbi3 = {
231 .func = GPIOMUX_FUNC_1,
232 .drv = GPIOMUX_DRV_8MA,
233 .pull = GPIOMUX_PULL_NONE,
234};
235
236static struct gpiomux_setting gsbi4 = {
237 .func = GPIOMUX_FUNC_1,
238 .drv = GPIOMUX_DRV_8MA,
239 .pull = GPIOMUX_PULL_NONE,
240};
241
242static struct gpiomux_setting gsbi5 = {
243 .func = GPIOMUX_FUNC_1,
244 .drv = GPIOMUX_DRV_8MA,
245 .pull = GPIOMUX_PULL_NONE,
246};
247
248static struct gpiomux_setting gsbi10 = {
249 .func = GPIOMUX_FUNC_2,
250 .drv = GPIOMUX_DRV_8MA,
251 .pull = GPIOMUX_PULL_NONE,
252};
253
254static struct gpiomux_setting gsbi12 = {
255 .func = GPIOMUX_FUNC_1,
256 .drv = GPIOMUX_DRV_8MA,
257 .pull = GPIOMUX_PULL_NONE,
258};
259
260static struct gpiomux_setting cdc_mclk = {
261 .func = GPIOMUX_FUNC_1,
262 .drv = GPIOMUX_DRV_8MA,
263 .pull = GPIOMUX_PULL_NONE,
264};
265
Stepan Moskovchenko41d168272011-08-09 17:09:42 -0700266#ifdef CONFIG_KS8851
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700267static struct gpiomux_setting gpio_eth_config = {
268 .pull = GPIOMUX_PULL_NONE,
269 .drv = GPIOMUX_DRV_8MA,
270 .func = GPIOMUX_FUNC_GPIO,
271};
Stepan Moskovchenko41d168272011-08-09 17:09:42 -0700272#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700273
274static struct gpiomux_setting slimbus = {
275 .func = GPIOMUX_FUNC_1,
276 .drv = GPIOMUX_DRV_8MA,
277 .pull = GPIOMUX_PULL_KEEPER,
278};
279
280struct msm_gpiomux_config msm8960_gpiomux_configs[NR_GPIO_IRQS] = {
Stepan Moskovchenko41d168272011-08-09 17:09:42 -0700281#ifdef CONFIG_KS8851
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700282 {
283 .gpio = KS8851_IRQ_GPIO,
284 .settings = {
285 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
286 }
287 },
288 {
289 .gpio = KS8851_RST_GPIO,
290 .settings = {
291 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
292 }
293 },
294 {
295 .gpio = FPGA_CS_GPIO,
296 .settings = {
297 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
298 }
299 },
Stepan Moskovchenko41d168272011-08-09 17:09:42 -0700300#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700301};
302
303static struct msm_gpiomux_config msm8960_gsbi_configs[] __initdata = {
304 {
305 .gpio = 6, /* GSBI1 QUP SPI_DATA_MOSI */
306 .settings = {
Harini Jayaraman608d0462011-08-09 19:10:03 -0600307 [GPIOMUX_SUSPENDED] = &spi_suspended_config,
308 [GPIOMUX_ACTIVE] = &spi_active,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700309 },
310 },
311 {
312 .gpio = 7, /* GSBI1 QUP SPI_DATA_MISO */
313 .settings = {
Harini Jayaraman608d0462011-08-09 19:10:03 -0600314 [GPIOMUX_SUSPENDED] = &spi_suspended_config,
315 [GPIOMUX_ACTIVE] = &spi_active,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700316 },
317 },
318 {
319 .gpio = 8, /* GSBI1 QUP SPI_CS_N */
320 .settings = {
Harini Jayaraman608d0462011-08-09 19:10:03 -0600321 [GPIOMUX_SUSPENDED] = &spi_suspended_config,
322 [GPIOMUX_ACTIVE] = &spi_active,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700323 },
324 },
325 {
326 .gpio = 9, /* GSBI1 QUP SPI_CLK */
327 .settings = {
Harini Jayaraman608d0462011-08-09 19:10:03 -0600328 [GPIOMUX_SUSPENDED] = &spi_suspended_config,
329 [GPIOMUX_ACTIVE] = &spi_active,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700330 },
331 },
332 {
333 .gpio = 16, /* GSBI3 I2C QUP SDA */
334 .settings = {
335 [GPIOMUX_SUSPENDED] = &gsbi3,
336 },
337 },
338 {
339 .gpio = 17, /* GSBI3 I2C QUP SCL */
340 .settings = {
341 [GPIOMUX_SUSPENDED] = &gsbi3,
342 },
343 },
344 {
345 .gpio = 20, /* GSBI4 I2C QUP SDA */
346 .settings = {
347 [GPIOMUX_SUSPENDED] = &gsbi4,
348 },
349 },
350 {
351 .gpio = 21, /* GSBI4 I2C QUP SCL */
352 .settings = {
353 [GPIOMUX_SUSPENDED] = &gsbi4,
354 },
355 },
356 {
357 .gpio = 22, /* GSBI5 UART2 */
358 .settings = {
359 [GPIOMUX_SUSPENDED] = &gsbi5,
360 },
361 },
362 {
363 .gpio = 23, /* GSBI5 UART2 */
364 .settings = {
365 [GPIOMUX_SUSPENDED] = &gsbi5,
366 },
367 },
368 {
369 .gpio = 24, /* GSBI5 UART2 */
370 .settings = {
371 [GPIOMUX_SUSPENDED] = &gsbi5,
372 },
373 },
374 {
375 .gpio = 25, /* GSBI5 UART2 */
376 .settings = {
377 [GPIOMUX_SUSPENDED] = &gsbi5,
378 },
379 },
380 {
381 .gpio = 44, /* GSBI12 I2C QUP SDA */
382 .settings = {
383 [GPIOMUX_SUSPENDED] = &gsbi12,
384 },
385 },
386 {
387 .gpio = 45, /* GSBI12 I2C QUP SCL */
388 .settings = {
389 [GPIOMUX_SUSPENDED] = &gsbi12,
390 },
391 },
392 {
393 .gpio = 73, /* GSBI10 I2C QUP SDA */
394 .settings = {
395 [GPIOMUX_SUSPENDED] = &gsbi10,
396 },
397 },
398 {
399 .gpio = 74, /* GSBI10 I2C QUP SCL */
400 .settings = {
401 [GPIOMUX_SUSPENDED] = &gsbi10,
402 },
403 },
404};
405
406static struct msm_gpiomux_config msm8960_slimbus_config[] __initdata = {
407 {
408 .gpio = 60, /* slimbus data */
409 .settings = {
410 [GPIOMUX_SUSPENDED] = &slimbus,
411 },
412 },
413 {
414 .gpio = 61, /* slimbus clk */
415 .settings = {
416 [GPIOMUX_SUSPENDED] = &slimbus,
417 },
418 },
419};
420
421static struct msm_gpiomux_config msm8960_audio_codec_configs[] __initdata = {
422 {
423 .gpio = 59,
424 .settings = {
425 [GPIOMUX_SUSPENDED] = &cdc_mclk,
426 },
427 },
428};
429static struct gpiomux_setting wcnss_5wire_suspend_cfg = {
430 .func = GPIOMUX_FUNC_GPIO,
431 .drv = GPIOMUX_DRV_2MA,
432 .pull = GPIOMUX_PULL_NONE,
433};
434
435static struct gpiomux_setting wcnss_5wire_active_cfg = {
436 .func = GPIOMUX_FUNC_1,
437 .drv = GPIOMUX_DRV_6MA,
438 .pull = GPIOMUX_PULL_DOWN,
439};
440
441static struct msm_gpiomux_config wcnss_5wire_interface[] = {
442 {
443 .gpio = 84,
444 .settings = {
445 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
446 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
447 },
448 },
449 {
450 .gpio = 85,
451 .settings = {
452 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
453 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
454 },
455 },
456 {
457 .gpio = 86,
458 .settings = {
459 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
460 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
461 },
462 },
463 {
464 .gpio = 87,
465 .settings = {
466 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
467 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
468 },
469 },
470 {
471 .gpio = 88,
472 .settings = {
473 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
474 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
475 },
476 },
477};
Nishant Pandit474f2252011-07-23 23:17:56 +0530478static struct gpiomux_setting cam_settings[4] = {
479 {
480 .func = GPIOMUX_FUNC_GPIO, /*suspend*/
481 .drv = GPIOMUX_DRV_2MA,
482 .pull = GPIOMUX_PULL_DOWN,
483 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700484
Nishant Pandit474f2252011-07-23 23:17:56 +0530485 {
486 .func = GPIOMUX_FUNC_1, /*active 1*/
487 .drv = GPIOMUX_DRV_2MA,
488 .pull = GPIOMUX_PULL_NONE,
489 },
490
491 {
492 .func = GPIOMUX_FUNC_GPIO, /*active 2*/
493 .drv = GPIOMUX_DRV_2MA,
494 .pull = GPIOMUX_PULL_NONE,
495 },
496
497 {
498 .func = GPIOMUX_FUNC_1, /*active 3*/
499 .drv = GPIOMUX_DRV_8MA,
500 .pull = GPIOMUX_PULL_UP,
501 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700502};
503
Nishant Pandit474f2252011-07-23 23:17:56 +0530504static struct msm_gpiomux_config msm8960_cam_configs[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700505 {
506 .gpio = 2,
507 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530508 [GPIOMUX_ACTIVE] = &cam_settings[2],
509 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700510 },
511 },
512 {
513 .gpio = 3,
514 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530515 [GPIOMUX_ACTIVE] = &cam_settings[1],
516 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700517 },
518 },
519 {
520 .gpio = 4,
521 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530522 [GPIOMUX_ACTIVE] = &cam_settings[1],
523 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700524 },
525 },
526 {
527 .gpio = 5,
528 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530529 [GPIOMUX_ACTIVE] = &cam_settings[1],
530 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700531 },
532 },
533 {
534 .gpio = 18,
535 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530536 [GPIOMUX_ACTIVE] = &cam_settings[3],
537 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700538 },
539 },
540 {
541 .gpio = 19,
542 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530543 [GPIOMUX_ACTIVE] = &cam_settings[3],
544 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700545 },
546 },
547 {
548 .gpio = 20,
549 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530550 [GPIOMUX_ACTIVE] = &cam_settings[3],
551 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700552 },
553 },
554 {
555 .gpio = 21,
556 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530557 [GPIOMUX_ACTIVE] = &cam_settings[3],
558 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700559 },
560 },
561 {
562 .gpio = 76,
563 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530564 [GPIOMUX_ACTIVE] = &cam_settings[2],
565 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700566 },
567 },
568 {
569 .gpio = 107,
570 .settings = {
Nishant Pandit474f2252011-07-23 23:17:56 +0530571 [GPIOMUX_ACTIVE] = &cam_settings[2],
572 [GPIOMUX_SUSPENDED] = &cam_settings[0],
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700573 },
574 },
575};
576
577static struct gpiomux_setting cyts_resout_sus_cfg = {
578 .func = GPIOMUX_FUNC_GPIO,
579 .drv = GPIOMUX_DRV_6MA,
580 .pull = GPIOMUX_PULL_UP,
581};
582
583static struct gpiomux_setting cyts_resout_act_cfg = {
584 .func = GPIOMUX_FUNC_GPIO,
585 .drv = GPIOMUX_DRV_6MA,
586 .pull = GPIOMUX_PULL_UP,
587};
588
589static struct gpiomux_setting cyts_sleep_sus_cfg = {
590 .func = GPIOMUX_FUNC_GPIO,
591 .drv = GPIOMUX_DRV_6MA,
592 .pull = GPIOMUX_PULL_DOWN,
593};
594
595static struct gpiomux_setting cyts_sleep_act_cfg = {
596 .func = GPIOMUX_FUNC_GPIO,
597 .drv = GPIOMUX_DRV_6MA,
598 .pull = GPIOMUX_PULL_DOWN,
599};
600
601static struct gpiomux_setting cyts_int_act_cfg = {
602 .func = GPIOMUX_FUNC_GPIO,
603 .drv = GPIOMUX_DRV_8MA,
604 .pull = GPIOMUX_PULL_UP,
605};
606
607static struct gpiomux_setting cyts_int_sus_cfg = {
608 .func = GPIOMUX_FUNC_GPIO,
609 .drv = GPIOMUX_DRV_2MA,
610 .pull = GPIOMUX_PULL_UP,
611};
612
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700613static struct msm_gpiomux_config msm8960_cyts_configs[] __initdata = {
614 { /* TS INTERRUPT */
615 .gpio = 11,
616 .settings = {
617 [GPIOMUX_ACTIVE] = &cyts_int_act_cfg,
618 [GPIOMUX_SUSPENDED] = &cyts_int_sus_cfg,
619 },
620 },
621 { /* TS SLEEP */
622 .gpio = 50,
623 .settings = {
624 [GPIOMUX_ACTIVE] = &cyts_sleep_act_cfg,
625 [GPIOMUX_SUSPENDED] = &cyts_sleep_sus_cfg,
626 },
627 },
628 { /* TS RESOUT */
629 .gpio = 52,
630 .settings = {
631 [GPIOMUX_ACTIVE] = &cyts_resout_act_cfg,
632 [GPIOMUX_SUSPENDED] = &cyts_resout_sus_cfg,
633 },
634 },
635};
636
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700637#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
638enum {
639 SX150X_CAM,
640};
641
Nishant Pandit474f2252011-07-23 23:17:56 +0530642static struct sx150x_platform_data sx150x_data[] = {
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700643 [SX150X_CAM] = {
644 .gpio_base = GPIO_CAM_EXPANDER_BASE,
645 .oscio_is_gpo = false,
646 .io_pullup_ena = 0x0,
Nishant Pandit474f2252011-07-23 23:17:56 +0530647 .io_pulldn_ena = 0xc0,
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700648 .io_open_drain_ena = 0x0,
649 .irq_summary = -1,
650 },
651};
Nishant Pandit474f2252011-07-23 23:17:56 +0530652
653#endif
654
655#ifdef CONFIG_I2C
656
657#define MSM_8960_GSBI4_QUP_I2C_BUS_ID 4
658#define MSM_8960_GSBI3_QUP_I2C_BUS_ID 3
659
660#if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE)
661
662static struct i2c_board_info cam_expander_i2c_info[] = {
663 {
664 I2C_BOARD_INFO("sx1508q", 0x22),
665 .platform_data = &sx150x_data[SX150X_CAM]
666 },
667};
668
669static struct msm_cam_expander_info cam_expander_info[] = {
670 {
671 cam_expander_i2c_info,
672 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
673 },
674};
675#endif
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -0700676#endif
677
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700678#define MSM_PMEM_KERNEL_EBI1_SIZE 0x110C000
679#define MSM_PMEM_ADSP_SIZE 0x3800000
Ben Romberger09e462d2011-08-09 15:24:37 -0700680#define MSM_PMEM_AUDIO_SIZE 0x28B000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700681#define MSM_PMEM_SIZE 0x1800000 /* 24 Mbytes */
682
Laura Abbottd6183792011-08-19 13:42:24 -0700683#define MSM_ION_EBI_SIZE SZ_8M
684
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700685#ifdef CONFIG_KERNEL_PMEM_EBI_REGION
686static unsigned pmem_kernel_ebi1_size = MSM_PMEM_KERNEL_EBI1_SIZE;
687static int __init pmem_kernel_ebi1_size_setup(char *p)
688{
689 pmem_kernel_ebi1_size = memparse(p, NULL);
690 return 0;
691}
692early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
693#endif
694
695#ifdef CONFIG_ANDROID_PMEM
696static unsigned pmem_size = MSM_PMEM_SIZE;
697static int __init pmem_size_setup(char *p)
698{
699 pmem_size = memparse(p, NULL);
700 return 0;
701}
702early_param("pmem_size", pmem_size_setup);
703
704static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
705
706static int __init pmem_adsp_size_setup(char *p)
707{
708 pmem_adsp_size = memparse(p, NULL);
709 return 0;
710}
711early_param("pmem_adsp_size", pmem_adsp_size_setup);
712
713static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
714
715static int __init pmem_audio_size_setup(char *p)
716{
717 pmem_audio_size = memparse(p, NULL);
718 return 0;
719}
720early_param("pmem_audio_size", pmem_audio_size_setup);
721#endif
722
723#ifdef CONFIG_ANDROID_PMEM
724static struct android_pmem_platform_data android_pmem_pdata = {
725 .name = "pmem",
726 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
727 .cached = 1,
728 .memory_type = MEMTYPE_EBI1,
729};
730
731static struct platform_device android_pmem_device = {
732 .name = "android_pmem",
733 .id = 0,
734 .dev = {.platform_data = &android_pmem_pdata},
735};
736
737static struct android_pmem_platform_data android_pmem_adsp_pdata = {
738 .name = "pmem_adsp",
739 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
740 .cached = 0,
741 .memory_type = MEMTYPE_EBI1,
742};
743static struct platform_device android_pmem_adsp_device = {
744 .name = "android_pmem",
745 .id = 2,
746 .dev = { .platform_data = &android_pmem_adsp_pdata },
747};
748
749static struct android_pmem_platform_data android_pmem_audio_pdata = {
750 .name = "pmem_audio",
751 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
752 .cached = 0,
753 .memory_type = MEMTYPE_EBI1,
754};
755
756static struct platform_device android_pmem_audio_device = {
757 .name = "android_pmem",
758 .id = 4,
759 .dev = { .platform_data = &android_pmem_audio_pdata },
760};
761#endif
762
763static struct memtype_reserve msm8960_reserve_table[] __initdata = {
764 [MEMTYPE_SMI] = {
765 },
766 [MEMTYPE_EBI0] = {
767 .flags = MEMTYPE_FLAGS_1M_ALIGN,
768 },
769 [MEMTYPE_EBI1] = {
770 .flags = MEMTYPE_FLAGS_1M_ALIGN,
771 },
772};
773
774static void __init size_pmem_devices(void)
775{
776#ifdef CONFIG_ANDROID_PMEM
777 android_pmem_adsp_pdata.size = pmem_adsp_size;
778 android_pmem_pdata.size = pmem_size;
779 android_pmem_audio_pdata.size = MSM_PMEM_AUDIO_SIZE;
780#endif
781}
782
783static void __init reserve_memory_for(struct android_pmem_platform_data *p)
784{
785 msm8960_reserve_table[p->memory_type].size += p->size;
786}
787
788static void __init reserve_pmem_memory(void)
789{
790#ifdef CONFIG_ANDROID_PMEM
791 reserve_memory_for(&android_pmem_adsp_pdata);
792 reserve_memory_for(&android_pmem_pdata);
793 reserve_memory_for(&android_pmem_audio_pdata);
794 msm8960_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
795#endif
796}
797
Larry Basselb4126da2011-07-18 14:31:33 -0700798static int msm8960_paddr_to_memtype(unsigned int paddr)
799{
800 return MEMTYPE_EBI1;
801}
802
Laura Abbottd6183792011-08-19 13:42:24 -0700803#ifdef CONFIG_ION_MSM
804struct ion_platform_data ion_pdata = {
805 .nr = 3,
806 .heaps = {
807 {
808 .id = ION_HEAP_SYSTEM_ID,
809 .type = ION_HEAP_TYPE_SYSTEM,
810 .name = ION_KMALLOC_HEAP_NAME,
811 },
812 {
813 .id = ION_HEAP_SYSTEM_CONTIG_ID,
814 .type = ION_HEAP_TYPE_SYSTEM_CONTIG,
815 .name = ION_VMALLOC_HEAP_NAME,
816 },
817 {
818 .id = ION_HEAP_EBI_ID,
819 .type = ION_HEAP_TYPE_CARVEOUT,
820 .name = ION_EBI1_HEAP_NAME,
821 .size = MSM_ION_EBI_SIZE,
822 .memory_type = ION_EBI_TYPE,
823 },
824 }
825};
826
827struct platform_device ion_dev = {
828 .name = "ion-msm",
829 .id = 1,
830 .dev = { .platform_data = &ion_pdata },
831};
832#endif
833
834static void reserve_ion_memory(void)
835{
836#ifdef CONFIG_ION_MSM
837 msm8960_reserve_table[MEMTYPE_EBI1].size += MSM_ION_EBI_SIZE;
838#endif
839}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700840static void __init msm8960_calculate_reserve_sizes(void)
841{
842 size_pmem_devices();
843 reserve_pmem_memory();
Laura Abbottd6183792011-08-19 13:42:24 -0700844 reserve_ion_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700845}
846
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700847static struct reserve_info msm8960_reserve_info __initdata = {
848 .memtype_reserve_table = msm8960_reserve_table,
849 .calculate_reserve_sizes = msm8960_calculate_reserve_sizes,
850 .paddr_to_memtype = msm8960_paddr_to_memtype,
851};
852
Larry Basselb4126da2011-07-18 14:31:33 -0700853static int msm8960_memory_bank_size(void)
854{
855 return 1<<29;
856}
857
858static void __init locate_unstable_memory(void)
859{
860 struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
861 unsigned long bank_size;
862 unsigned long low, high;
863
864 bank_size = msm8960_memory_bank_size();
865 low = meminfo.bank[0].start;
866 high = mb->start + mb->size;
867 low &= ~(bank_size - 1);
868
869 if (high - low <= bank_size)
870 return;
871 msm8960_reserve_info.low_unstable_address = low + bank_size;
872 msm8960_reserve_info.max_unstable_size = high - low - bank_size;
873 msm8960_reserve_info.bank_size = bank_size;
874 pr_info("low unstable address %lx max size %lx bank size %lx\n",
875 msm8960_reserve_info.low_unstable_address,
876 msm8960_reserve_info.max_unstable_size,
877 msm8960_reserve_info.bank_size);
878}
879
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700880static void __init msm8960_reserve(void)
881{
882 reserve_info = &msm8960_reserve_info;
Larry Basselb4126da2011-07-18 14:31:33 -0700883 locate_unstable_memory();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700884 msm_reserve();
885}
886
Larry Bassela4414b12011-08-04 11:11:02 -0700887static int msm8960_change_memory_power(u64 start, u64 size,
888 int change_type)
Larry Bassela7eadea2011-07-14 10:46:00 -0700889{
Larry Bassela4414b12011-08-04 11:11:02 -0700890 return size;
Larry Bassela7eadea2011-07-14 10:46:00 -0700891}
892
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700893#ifdef CONFIG_MSM_CAMERA
894
Kevin Chan28446522011-07-26 16:39:53 -0700895static uint16_t msm_cam_gpio_tbl[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700896 5, /*CAMIF_MCLK*/
897 20, /*CAMIF_I2C_DATA*/
898 21, /*CAMIF_I2C_CLK*/
899};
900
901#define VFE_CAMIF_TIMER1_GPIO 2
902#define VFE_CAMIF_TIMER2_GPIO 3
903#define VFE_CAMIF_TIMER3_GPIO_INT 4
904struct msm_camera_sensor_strobe_flash_data strobe_flash_xenon = {
905 .flash_trigger = VFE_CAMIF_TIMER2_GPIO,
906 .flash_charge = VFE_CAMIF_TIMER1_GPIO,
907 .flash_charge_done = VFE_CAMIF_TIMER3_GPIO_INT,
908 .flash_recharge_duration = 50000,
909 .irq = MSM_GPIO_TO_INT(VFE_CAMIF_TIMER3_GPIO_INT),
910};
911
Nishant Pandit474f2252011-07-23 23:17:56 +0530912#ifdef CONFIG_MSM_CAMERA_FLASH
913static struct msm_camera_sensor_flash_src msm_flash_src = {
914 .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT,
915 ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1,
916 ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2,
917#if defined(CONFIG_I2C) && (defined(CONFIG_GPIO_SX150X) || \
918 defined(CONFIG_GPIO_SX150X_MODULE))
919 ._fsrc.ext_driver_src.expander_info = cam_expander_info,
920#endif
921};
922#endif
923
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700924#ifdef CONFIG_IMX074
925static struct msm_camera_sensor_platform_info sensor_board_info = {
Mansoor Aftab6d6ff5e2011-07-20 17:25:36 -0700926 .mount_angle = 90
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700927};
928#endif
929
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700930struct msm_camera_device_platform_data msm_camera_csi0_device_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700931 .ioclk.mclk_clk_rate = 24000000,
932 .ioclk.vfe_clk_rate = 228570000,
933 .csid_core = 0,
Kevin Chan28446522011-07-26 16:39:53 -0700934 .cam_gpio_tbl = msm_cam_gpio_tbl,
935 .cam_gpio_tbl_size = ARRAY_SIZE(msm_cam_gpio_tbl),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700936};
937
938struct msm_camera_device_platform_data msm_camera_csi1_device_data = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700939 .ioclk.mclk_clk_rate = 24000000,
940 .ioclk.vfe_clk_rate = 228570000,
941 .csid_core = 1,
Kevin Chan28446522011-07-26 16:39:53 -0700942 .cam_gpio_tbl = msm_cam_gpio_tbl,
943 .cam_gpio_tbl_size = ARRAY_SIZE(msm_cam_gpio_tbl),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700944};
945
946#ifdef CONFIG_IMX074
947static struct msm_camera_sensor_flash_data flash_imx074 = {
948 .flash_type = MSM_CAMERA_FLASH_LED,
Nishant Pandit474f2252011-07-23 23:17:56 +0530949#ifdef CONFIG_MSM_CAMERA_FLASH
950 .flash_src = &msm_flash_src
951#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700952};
953
954static struct msm_camera_sensor_info msm_camera_sensor_imx074_data = {
955 .sensor_name = "imx074",
956 .sensor_reset = 107,
957 .sensor_pwd = 85,
958 .vcm_pwd = 0,
959 .vcm_enable = 1,
960 .pdata = &msm_camera_csi0_device_data,
961 .flash_data = &flash_imx074,
962 .strobe_flash_data = &strobe_flash_xenon,
963 .sensor_platform_info = &sensor_board_info,
964 .csi_if = 1
965};
966
967struct platform_device msm8960_camera_sensor_imx074 = {
968 .name = "msm_camera_imx074",
969 .dev = {
970 .platform_data = &msm_camera_sensor_imx074_data,
971 },
972};
973#endif
974#ifdef CONFIG_OV2720
975static struct msm_camera_sensor_flash_data flash_ov2720 = {
Kevin Chan1a990332011-07-26 20:31:23 -0700976 .flash_type = MSM_CAMERA_FLASH_NONE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700977};
978
979static struct msm_camera_sensor_info msm_camera_sensor_ov2720_data = {
980 .sensor_name = "ov2720",
981 .sensor_reset = 76,
982 .sensor_pwd = 85,
983 .vcm_pwd = 0,
984 .vcm_enable = 1,
985 .pdata = &msm_camera_csi1_device_data,
986 .flash_data = &flash_ov2720,
987 .csi_if = 1
988};
989
990struct platform_device msm8960_camera_sensor_ov2720 = {
991 .name = "msm_camera_ov2720",
992 .dev = {
993 .platform_data = &msm_camera_sensor_ov2720_data,
994 },
995};
996#endif
Kevin Chandfecce22011-07-13 10:52:41 -0700997
998static struct msm_camera_sensor_flash_data flash_qs_mt9p017 = {
999 .flash_type = MSM_CAMERA_FLASH_LED,
1000};
1001
1002static struct msm_camera_sensor_info msm_camera_sensor_qs_mt9p017_data = {
1003 .sensor_name = "qs_mt9p017",
1004 .sensor_reset = 107,
1005 .sensor_pwd = 85,
1006 .vcm_pwd = 0,
1007 .vcm_enable = 1,
1008 .pdata = &msm_camera_csi0_device_data,
1009 .flash_data = &flash_qs_mt9p017,
1010 .sensor_platform_info = &sensor_board_info,
1011 .csi_if = 1
1012};
1013
1014struct platform_device msm8960_camera_sensor_qs_mt9p017 = {
1015 .name = "msm_camera_qs_mt9p017",
1016 .dev = {
1017 .platform_data = &msm_camera_sensor_qs_mt9p017_data,
1018 },
1019};
1020
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001021static void __init msm8960_init_cam(void)
1022{
1023 int i;
1024 struct platform_device *cam_dev[] = {
1025 &msm8960_camera_sensor_imx074,
1026 &msm8960_camera_sensor_ov2720,
Kevin Chandfecce22011-07-13 10:52:41 -07001027 &msm8960_camera_sensor_qs_mt9p017,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001028 };
1029
1030 for (i = 0; i < ARRAY_SIZE(cam_dev); i++) {
1031 struct msm_camera_sensor_info *s_info;
1032 s_info = cam_dev[i]->dev.platform_data;
1033 msm_get_cam_resources(s_info);
1034 platform_device_register(cam_dev[i]);
1035 }
1036}
1037#endif
1038
1039#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001040/* prim = 1366 x 768 x 3(bpp) x 3(pages) */
1041#define MSM_FB_PRIM_BUF_SIZE roundup(1366 * 768 * 3 * 3, 0x10000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001042#else
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001043/* prim = 1366 x 768 x 3(bpp) x 2(pages) */
1044#define MSM_FB_PRIM_BUF_SIZE roundup(1366 * 768 * 3 * 2, 0x10000)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001045#endif
1046
1047#ifdef CONFIG_FB_MSM_MIPI_DSI
Nagamalleswararao Ganji0b8dbd02011-08-18 20:46:59 -07001048#define MIPI_DSI_WRITEBACK_SIZE (1024 * 600 * 3 * 2)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001049#else
1050#define MIPI_DSI_WRITEBACK_SIZE 0
1051#endif
1052
1053#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1054/* hdmi = 1920 x 1088 x 2(bpp) x 1(page) */
1055#define MSM_FB_EXT_BUF_SIZE 0x3FC000
1056#elif defined(CONFIG_FB_MSM_TVOUT)
1057/* tvout = 720 x 576 x 2(bpp) x 2(pages) */
1058#define MSM_FB_EXT_BUF_SIZE 0x195000
1059#else /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1060#define MSM_FB_EXT_BUF_SIZE 0
1061#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1062
1063#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE +\
1064 MIPI_DSI_WRITEBACK_SIZE, 4096)
1065
1066#define MDP_VSYNC_GPIO 0
1067
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001068#define TOSHIBA_PANEL_NAME "mipi_video_toshiba_wsvga"
1069#define TOSHIBA_PANEL_NAME_LEN 24
1070#define CHIMEI_PANEL_NAME "mipi_chimei_wxga"
1071#define CHIMEI_PANEL_NAME_LEN 16
1072
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001073static struct resource msm_fb_resources[] = {
1074 {
1075 .flags = IORESOURCE_DMA,
1076 }
1077};
1078
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001079#ifdef CONFIG_FB_MSM_MIPI_PANEL_DETECT
1080static int msm_fb_detect_panel(const char *name)
1081{
1082 if (machine_is_msm8960_liquid()) {
1083 if (!strncmp(name, CHIMEI_PANEL_NAME, CHIMEI_PANEL_NAME_LEN))
1084 return 0;
1085 } else {
1086 if (!strncmp(name, TOSHIBA_PANEL_NAME, TOSHIBA_PANEL_NAME_LEN))
1087 return 0;
1088 }
1089
1090 pr_warning("%s: not supported '%s'", __func__, name);
1091
1092 return -ENODEV;
1093}
1094
1095static struct msm_fb_platform_data msm_fb_pdata = {
1096 .detect_client = msm_fb_detect_panel,
1097};
1098#endif /* CONFIG_FB_MSM_MIPI_PANEL_DETECT */
1099
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001100static struct platform_device msm_fb_device = {
1101 .name = "msm_fb",
1102 .id = 0,
1103 .num_resources = ARRAY_SIZE(msm_fb_resources),
1104 .resource = msm_fb_resources,
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001105#ifdef CONFIG_FB_MSM_MIPI_PANEL_DETECT
1106 .dev.platform_data = &msm_fb_pdata,
1107#endif /* CONFIG_FB_MSM_MIPI_PANEL_DETECT */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001108};
1109
1110static bool dsi_power_on;
1111
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001112/**
1113 * LiQUID panel on/off
1114 *
1115 * @param on
1116 *
1117 * @return int
1118 */
1119static int mipi_dsi_liquid_panel_power(int on)
1120{
1121 static struct regulator *reg_l2, *reg_ext_3p3v;
1122 static int gpio21, gpio24, gpio43;
1123 int rc;
1124
1125 pr_info("%s: on=%d\n", __func__, on);
1126
1127 gpio21 = PM8921_GPIO_PM_TO_SYS(21); /* disp power enable_n */
1128 gpio43 = PM8921_GPIO_PM_TO_SYS(43); /* Displays Enable (rst_n)*/
1129 gpio24 = PM8921_GPIO_PM_TO_SYS(24); /* Backlight PWM */
1130
1131 if (!dsi_power_on) {
1132
1133 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
1134 "dsi_vdda");
1135 if (IS_ERR(reg_l2)) {
1136 pr_err("could not get 8921_l2, rc = %ld\n",
1137 PTR_ERR(reg_l2));
1138 return -ENODEV;
1139 }
1140
1141 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
1142 if (rc) {
1143 pr_err("set_voltage l2 failed, rc=%d\n", rc);
1144 return -EINVAL;
1145 }
1146
1147 reg_ext_3p3v = regulator_get(&msm_mipi_dsi1_device.dev,
1148 "vdd_lvds_3p3v");
1149 if (IS_ERR(reg_ext_3p3v)) {
1150 pr_err("could not get reg_ext_3p3v, rc = %ld\n",
1151 PTR_ERR(reg_ext_3p3v));
1152 return -ENODEV;
1153 }
1154
1155 rc = gpio_request(gpio21, "disp_pwr_en_n");
1156 if (rc) {
1157 pr_err("request gpio 21 failed, rc=%d\n", rc);
1158 return -ENODEV;
1159 }
1160
1161 rc = gpio_request(gpio43, "disp_rst_n");
1162 if (rc) {
1163 pr_err("request gpio 43 failed, rc=%d\n", rc);
1164 return -ENODEV;
1165 }
1166
1167 rc = gpio_request(gpio24, "disp_backlight_pwm");
1168 if (rc) {
1169 pr_err("request gpio 24 failed, rc=%d\n", rc);
1170 return -ENODEV;
1171 }
1172
1173 dsi_power_on = true;
1174 }
1175
1176 if (on) {
1177 rc = regulator_set_optimum_mode(reg_l2, 100000);
1178 if (rc < 0) {
1179 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1180 return -EINVAL;
1181 }
1182 rc = regulator_enable(reg_l2);
1183 if (rc) {
1184 pr_err("enable l2 failed, rc=%d\n", rc);
1185 return -ENODEV;
1186 }
1187
1188 rc = regulator_enable(reg_ext_3p3v);
1189 if (rc) {
1190 pr_err("enable reg_ext_3p3v failed, rc=%d\n", rc);
1191 return -ENODEV;
1192 }
1193
1194 /* set reset pin before power enable */
1195 gpio_set_value_cansleep(gpio43, 0); /* disp disable (resx=0) */
1196
1197 gpio_set_value_cansleep(gpio21, 0); /* disp power enable_n */
1198 msleep(20);
1199 gpio_set_value_cansleep(gpio43, 1); /* disp enable */
1200 msleep(20);
1201 gpio_set_value_cansleep(gpio43, 0); /* disp enable */
1202 msleep(20);
1203 gpio_set_value_cansleep(gpio43, 1); /* disp enable */
1204 msleep(20);
1205 } else {
1206 gpio_set_value_cansleep(gpio43, 0);
1207 gpio_set_value_cansleep(gpio21, 1);
1208
1209 rc = regulator_disable(reg_l2);
1210 if (rc) {
1211 pr_err("disable reg_l2 failed, rc=%d\n", rc);
1212 return -ENODEV;
1213 }
1214 rc = regulator_disable(reg_ext_3p3v);
1215 if (rc) {
1216 pr_err("disable reg_ext_3p3v failed, rc=%d\n", rc);
1217 return -ENODEV;
1218 }
1219 rc = regulator_set_optimum_mode(reg_l2, 100);
1220 if (rc < 0) {
1221 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1222 return -EINVAL;
1223 }
1224 }
1225
1226 return 0;
1227}
1228
1229static int mipi_dsi_cdp_panel_power(int on)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001230{
1231 static struct regulator *reg_l8, *reg_l23, *reg_l2;
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07001232 static int gpio43;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001233 int rc;
1234
1235 struct pm_gpio gpio43_param = {
1236 .direction = PM_GPIO_DIR_OUT,
1237 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
1238 .output_value = 0,
1239 .pull = PM_GPIO_PULL_NO,
1240 .vin_sel = 2,
1241 .out_strength = PM_GPIO_STRENGTH_HIGH,
1242 .function = PM_GPIO_FUNC_PAIRED,
1243 .inv_int_pol = 0,
1244 .disable_pin = 0,
1245 };
1246
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001247 pr_info("%s: state : %d\n", __func__, on);
1248
1249 if (!dsi_power_on) {
1250
1251 reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev,
1252 "dsi_vdc");
1253 if (IS_ERR(reg_l8)) {
1254 pr_err("could not get 8921_l8, rc = %ld\n",
1255 PTR_ERR(reg_l8));
1256 return -ENODEV;
1257 }
1258
1259 reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev,
1260 "dsi_vddio");
1261 if (IS_ERR(reg_l23)) {
1262 pr_err("could not get 8921_l23, rc = %ld\n",
1263 PTR_ERR(reg_l23));
1264 return -ENODEV;
1265 }
1266
1267 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
1268 "dsi_vdda");
1269 if (IS_ERR(reg_l2)) {
1270 pr_err("could not get 8921_l2, rc = %ld\n",
1271 PTR_ERR(reg_l2));
1272 return -ENODEV;
1273 }
1274
1275 rc = regulator_set_voltage(reg_l8, 2800000, 3000000);
1276 if (rc) {
1277 pr_err("set_voltage l8 failed, rc=%d\n", rc);
1278 return -EINVAL;
1279 }
1280 rc = regulator_set_voltage(reg_l23, 1800000, 1800000);
1281 if (rc) {
1282 pr_err("set_voltage l23 failed, rc=%d\n", rc);
1283 return -EINVAL;
1284 }
1285 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
1286 if (rc) {
1287 pr_err("set_voltage l2 failed, rc=%d\n", rc);
1288 return -EINVAL;
1289 }
1290
1291 gpio43 = PM8921_GPIO_PM_TO_SYS(43);
1292 rc = gpio_request(gpio43, "disp_rst_n");
1293 if (rc) {
1294 pr_err("request gpio 43 failed, rc=%d\n", rc);
1295 return -ENODEV;
1296 }
1297
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001298 dsi_power_on = true;
1299 }
1300
1301 if (on) {
1302 rc = regulator_set_optimum_mode(reg_l8, 100000);
1303 if (rc < 0) {
1304 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
1305 return -EINVAL;
1306 }
1307 rc = regulator_set_optimum_mode(reg_l23, 100000);
1308 if (rc < 0) {
1309 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1310 return -EINVAL;
1311 }
1312 rc = regulator_set_optimum_mode(reg_l2, 100000);
1313 if (rc < 0) {
1314 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1315 return -EINVAL;
1316 }
1317 rc = regulator_enable(reg_l8);
1318 if (rc) {
1319 pr_err("enable l8 failed, rc=%d\n", rc);
1320 return -ENODEV;
1321 }
1322 rc = regulator_enable(reg_l23);
1323 if (rc) {
1324 pr_err("enable l8 failed, rc=%d\n", rc);
1325 return -ENODEV;
1326 }
1327 rc = regulator_enable(reg_l2);
1328 if (rc) {
1329 pr_err("enable l2 failed, rc=%d\n", rc);
1330 return -ENODEV;
1331 }
1332
1333 gpio43_param.pull = PM_GPIO_PULL_NO;
1334 rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
1335 if (rc) {
1336 pr_err("gpio_config 43 failed (1), rc=%d\n", rc);
1337 return -EINVAL;
1338 }
1339 gpio43_param.pull = PM_GPIO_PULL_UP_30;
1340 rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
1341 if (rc) {
1342 pr_err("gpio_config 43 failed (2), rc=%d\n", rc);
1343 return -EINVAL;
1344 }
1345 gpio43_param.pull = PM_GPIO_PULL_NO;
1346 rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
1347 if (rc) {
1348 pr_err("gpio_config 43 failed (3), rc=%d\n", rc);
1349 return -EINVAL;
1350 }
1351 gpio43_param.pull = PM_GPIO_PULL_UP_30;
1352 rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
1353 if (rc) {
1354 pr_err("gpio_config 43 failed (4), rc=%d\n", rc);
1355 return -EINVAL;
1356 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001357 gpio_set_value_cansleep(gpio43, 1);
1358 } else {
1359 rc = regulator_set_optimum_mode(reg_l8, 100);
1360 if (rc < 0) {
1361 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
1362 return -EINVAL;
1363 }
1364 rc = regulator_set_optimum_mode(reg_l23, 100);
1365 if (rc < 0) {
1366 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1367 return -EINVAL;
1368 }
1369 rc = regulator_set_optimum_mode(reg_l2, 100);
1370 if (rc < 0) {
1371 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
1372 return -EINVAL;
1373 }
1374 gpio_set_value_cansleep(gpio43, 0);
1375 }
1376 return 0;
1377}
1378
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001379static int mipi_dsi_panel_power(int on)
1380{
1381 int ret;
1382
1383 pr_info("%s: on=%d\n", __func__, on);
1384
1385 if (machine_is_msm8960_liquid())
1386 ret = mipi_dsi_liquid_panel_power(on);
1387 else
1388 ret = mipi_dsi_cdp_panel_power(on);
1389
1390 return ret;
1391}
1392
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001393static struct mipi_dsi_platform_data mipi_dsi_pdata = {
1394 .vsync_gpio = MDP_VSYNC_GPIO,
1395 .dsi_power_save = mipi_dsi_panel_power,
1396};
1397
1398#ifdef CONFIG_MSM_BUS_SCALING
1399
1400static struct msm_bus_vectors mdp_init_vectors[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001401 {
1402 .src = MSM_BUS_MASTER_MDP_PORT0,
1403 .dst = MSM_BUS_SLAVE_EBI_CH0,
1404 .ab = 0,
1405 .ib = 0,
1406 },
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001407};
1408
1409static struct msm_bus_vectors mdp_ui_vectors[] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001410 {
1411 .src = MSM_BUS_MASTER_MDP_PORT0,
1412 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001413 .ab = 216000000 * 2,
1414 .ib = 270000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001415 },
1416};
1417
1418static struct msm_bus_vectors mdp_vga_vectors[] = {
1419 /* VGA and less video */
1420 {
1421 .src = MSM_BUS_MASTER_MDP_PORT0,
1422 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001423 .ab = 216000000 * 2,
1424 .ib = 270000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001425 },
1426};
1427
1428static struct msm_bus_vectors mdp_720p_vectors[] = {
1429 /* 720p and less video */
1430 {
1431 .src = MSM_BUS_MASTER_MDP_PORT0,
1432 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001433 .ab = 230400000 * 2,
1434 .ib = 288000000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001435 },
1436};
1437
1438static struct msm_bus_vectors mdp_1080p_vectors[] = {
1439 /* 1080p and less video */
1440 {
1441 .src = MSM_BUS_MASTER_MDP_PORT0,
1442 .dst = MSM_BUS_SLAVE_EBI_CH0,
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001443 .ab = 334080000 * 2,
1444 .ib = 417600000 * 2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001445 },
1446};
1447
1448static struct msm_bus_paths mdp_bus_scale_usecases[] = {
1449 {
1450 ARRAY_SIZE(mdp_init_vectors),
1451 mdp_init_vectors,
1452 },
1453 {
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001454 ARRAY_SIZE(mdp_ui_vectors),
1455 mdp_ui_vectors,
1456 },
1457 {
1458 ARRAY_SIZE(mdp_ui_vectors),
1459 mdp_ui_vectors,
1460 },
1461 {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001462 ARRAY_SIZE(mdp_vga_vectors),
1463 mdp_vga_vectors,
1464 },
1465 {
1466 ARRAY_SIZE(mdp_720p_vectors),
1467 mdp_720p_vectors,
1468 },
1469 {
1470 ARRAY_SIZE(mdp_1080p_vectors),
1471 mdp_1080p_vectors,
1472 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001473};
1474
1475static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
1476 mdp_bus_scale_usecases,
1477 ARRAY_SIZE(mdp_bus_scale_usecases),
1478 .name = "mdp",
1479};
1480
1481#endif
1482
1483int mdp_core_clk_rate_table[] = {
1484 85330000,
1485 85330000,
Nagamalleswararao Ganjiad31c982011-08-15 23:24:17 -07001486 160000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001487 200000000,
1488};
1489
1490static struct msm_panel_common_pdata mdp_pdata = {
1491 .gpio = MDP_VSYNC_GPIO,
1492 .mdp_core_clk_rate = 85330000,
1493 .mdp_core_clk_table = mdp_core_clk_rate_table,
1494 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
1495#ifdef CONFIG_MSM_BUS_SCALING
1496 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
1497#endif
1498 .mdp_rev = MDP_REV_42,
1499};
1500
1501static struct platform_device mipi_dsi_renesas_panel_device = {
1502 .name = "mipi_renesas",
1503 .id = 0,
1504};
1505
1506static struct platform_device mipi_dsi_simulator_panel_device = {
1507 .name = "mipi_simulator",
1508 .id = 0,
1509};
1510
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07001511#define LPM_CHANNEL0 0
1512static int toshiba_gpio[] = {LPM_CHANNEL0};
1513
1514static struct mipi_dsi_panel_platform_data toshiba_pdata = {
1515 .gpio = toshiba_gpio,
1516};
1517
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001518static struct platform_device mipi_dsi_toshiba_panel_device = {
1519 .name = "mipi_toshiba",
1520 .id = 0,
Nagamalleswararao Ganjieac5dfa2011-07-23 17:31:16 -07001521 .dev = {
1522 .platform_data = &toshiba_pdata,
1523 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001524};
1525
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001526static int dsi2lvds_gpio[2] = {
1527 0,/* Backlight PWM-ID=0 for PMIC-GPIO#24 */
1528 0x1F08 /* DSI2LVDS Bridge GPIO Output, mask=0x1f, out=0x08 */
1529 };
1530
1531static struct msm_panel_common_pdata mipi_dsi2lvds_pdata = {
1532 .gpio_num = dsi2lvds_gpio,
1533};
1534
1535static struct platform_device mipi_dsi2lvds_bridge_device = {
1536 .name = "mipi_tc358764",
1537 .id = 0,
1538 .dev.platform_data = &mipi_dsi2lvds_pdata,
1539};
1540
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001541#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1542static struct resource hdmi_msm_resources[] = {
1543 {
1544 .name = "hdmi_msm_qfprom_addr",
1545 .start = 0x00700000,
1546 .end = 0x007060FF,
1547 .flags = IORESOURCE_MEM,
1548 },
1549 {
1550 .name = "hdmi_msm_hdmi_addr",
1551 .start = 0x04A00000,
1552 .end = 0x04A00FFF,
1553 .flags = IORESOURCE_MEM,
1554 },
1555 {
1556 .name = "hdmi_msm_irq",
1557 .start = HDMI_IRQ,
1558 .end = HDMI_IRQ,
1559 .flags = IORESOURCE_IRQ,
1560 },
1561};
1562
1563static int hdmi_enable_5v(int on);
1564static int hdmi_core_power(int on, int show);
1565static int hdmi_cec_power(int on);
1566
1567static struct msm_hdmi_platform_data hdmi_msm_data = {
1568 .irq = HDMI_IRQ,
1569 .enable_5v = hdmi_enable_5v,
1570 .core_power = hdmi_core_power,
1571 .cec_power = hdmi_cec_power,
1572};
1573
1574static struct platform_device hdmi_msm_device = {
1575 .name = "hdmi_msm",
1576 .id = 0,
1577 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
1578 .resource = hdmi_msm_resources,
1579 .dev.platform_data = &hdmi_msm_data,
1580};
1581#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1582
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001583#ifdef CONFIG_MSM_BUS_SCALING
1584static struct msm_bus_vectors dtv_bus_init_vectors[] = {
1585 {
1586 .src = MSM_BUS_MASTER_MDP_PORT0,
1587 .dst = MSM_BUS_SLAVE_EBI_CH0,
1588 .ab = 0,
1589 .ib = 0,
1590 },
1591};
1592static struct msm_bus_vectors dtv_bus_def_vectors[] = {
1593 {
1594 .src = MSM_BUS_MASTER_MDP_PORT0,
1595 .dst = MSM_BUS_SLAVE_EBI_CH0,
1596 .ab = 566092800 * 2,
1597 .ib = 707616000 * 2,
1598 },
1599};
1600static struct msm_bus_paths dtv_bus_scale_usecases[] = {
1601 {
1602 ARRAY_SIZE(dtv_bus_init_vectors),
1603 dtv_bus_init_vectors,
1604 },
1605 {
1606 ARRAY_SIZE(dtv_bus_def_vectors),
1607 dtv_bus_def_vectors,
1608 },
1609};
1610static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
1611 dtv_bus_scale_usecases,
1612 ARRAY_SIZE(dtv_bus_scale_usecases),
1613 .name = "dtv",
1614};
1615
1616static struct lcdc_platform_data dtv_pdata = {
1617 .bus_scale_table = &dtv_bus_scale_pdata,
1618};
1619#endif
1620
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001621static void __init msm_fb_add_devices(void)
1622{
Amir Samuelov0c7270f2011-09-07 03:13:47 +03001623 struct platform_device *ptr = NULL;
1624
1625 if (machine_is_msm8960_liquid())
1626 ptr = &mipi_dsi2lvds_bridge_device;
1627 else
1628 ptr = &mipi_dsi_toshiba_panel_device;
1629 platform_add_devices(&ptr, 1);
1630
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001631 if (machine_is_msm8x60_rumi3()) {
1632 msm_fb_register_device("mdp", NULL);
1633 mipi_dsi_pdata.target_type = 1;
1634 } else
1635 msm_fb_register_device("mdp", &mdp_pdata);
1636 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
Ravishangar Kalyanam882930f2011-07-08 17:51:52 -07001637#ifdef CONFIG_MSM_BUS_SCALING
1638 msm_fb_register_device("dtv", &dtv_pdata);
1639#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001640}
1641
Ravishangar Kalyanamba99e512011-07-20 12:57:19 -07001642static struct gpiomux_setting mdp_vsync_suspend_cfg = {
1643 .func = GPIOMUX_FUNC_GPIO,
1644 .drv = GPIOMUX_DRV_2MA,
1645 .pull = GPIOMUX_PULL_DOWN,
1646};
1647
1648static struct gpiomux_setting mdp_vsync_active_cfg = {
1649 .func = GPIOMUX_FUNC_1,
1650 .drv = GPIOMUX_DRV_2MA,
1651 .pull = GPIOMUX_PULL_DOWN,
1652};
1653
1654static struct msm_gpiomux_config msm8960_mdp_vsync_configs[] __initdata = {
1655 {
1656 .gpio = MDP_VSYNC_GPIO,
1657 .settings = {
1658 [GPIOMUX_ACTIVE] = &mdp_vsync_active_cfg,
1659 [GPIOMUX_SUSPENDED] = &mdp_vsync_suspend_cfg,
1660 },
1661 }
1662};
1663
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001664#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1665static struct gpiomux_setting hdmi_suspend_cfg = {
1666 .func = GPIOMUX_FUNC_GPIO,
1667 .drv = GPIOMUX_DRV_2MA,
1668 .pull = GPIOMUX_PULL_DOWN,
1669};
1670
1671static struct gpiomux_setting hdmi_active_1_cfg = {
1672 .func = GPIOMUX_FUNC_1,
1673 .drv = GPIOMUX_DRV_2MA,
1674 .pull = GPIOMUX_PULL_UP,
1675};
1676
1677static struct gpiomux_setting hdmi_active_2_cfg = {
1678 .func = GPIOMUX_FUNC_1,
1679 .drv = GPIOMUX_DRV_2MA,
1680 .pull = GPIOMUX_PULL_DOWN,
1681};
1682
1683static struct msm_gpiomux_config msm8960_hdmi_configs[] __initdata = {
1684 {
1685 .gpio = 99,
1686 .settings = {
1687 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
1688 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1689 },
1690 },
1691 {
1692 .gpio = 100,
1693 .settings = {
1694 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
1695 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1696 },
1697 },
1698 {
1699 .gpio = 101,
1700 .settings = {
1701 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
1702 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1703 },
1704 },
1705 {
1706 .gpio = 102,
1707 .settings = {
1708 [GPIOMUX_ACTIVE] = &hdmi_active_2_cfg,
1709 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
1710 },
1711 },
1712};
1713
1714static int hdmi_enable_5v(int on)
1715{
1716 /* TBD: PM8921 regulator instead of 8901 */
1717 static struct regulator *reg_8921_hdmi_mvs; /* HDMI_5V */
1718 static int prev_on;
1719 int rc;
1720
1721 if (on == prev_on)
1722 return 0;
1723
1724 if (!reg_8921_hdmi_mvs)
1725 reg_8921_hdmi_mvs = regulator_get(&hdmi_msm_device.dev,
1726 "hdmi_mvs");
1727
1728 if (on) {
1729 rc = regulator_enable(reg_8921_hdmi_mvs);
1730 if (rc) {
1731 pr_err("'%s' regulator enable failed, rc=%d\n",
1732 "8921_hdmi_mvs", rc);
1733 return rc;
1734 }
1735 pr_debug("%s(on): success\n", __func__);
1736 } else {
1737 rc = regulator_disable(reg_8921_hdmi_mvs);
1738 if (rc)
1739 pr_warning("'%s' regulator disable failed, rc=%d\n",
1740 "8921_hdmi_mvs", rc);
1741 pr_debug("%s(off): success\n", __func__);
1742 }
1743
1744 prev_on = on;
1745
1746 return 0;
1747}
1748
1749static int hdmi_core_power(int on, int show)
1750{
1751 static struct regulator *reg_8921_l23, *reg_8921_s4;
1752 static int prev_on;
1753 int rc;
1754
1755 if (on == prev_on)
1756 return 0;
1757
1758 /* TBD: PM8921 regulator instead of 8901 */
1759 if (!reg_8921_l23)
1760 reg_8921_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
1761
1762 if (!reg_8921_s4)
1763 reg_8921_s4 = regulator_get(&hdmi_msm_device.dev, "hdmi_vcc");
1764
1765 if (on) {
1766 rc = regulator_set_optimum_mode(reg_8921_l23, 100000);
1767 if (rc < 0) {
1768 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1769 return -EINVAL;
1770 }
1771
1772 rc = regulator_set_voltage(reg_8921_l23, 1800000, 1800000);
1773 if (!rc)
1774 rc = regulator_enable(reg_8921_l23);
1775 if (rc) {
1776 pr_err("'%s' regulator enable failed, rc=%d\n",
1777 "hdmi_avdd", rc);
1778 return rc;
1779 }
1780 rc = regulator_set_voltage(reg_8921_s4, 1800000, 1800000);
1781 if (!rc)
1782 rc = regulator_enable(reg_8921_s4);
1783 if (rc) {
1784 pr_err("'%s' regulator enable failed, rc=%d\n",
1785 "hdmi_vcc", rc);
1786 return rc;
1787 }
1788
1789 rc = gpio_request(100, "HDMI_DDC_CLK");
1790 if (rc) {
1791 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1792 "HDMI_DDC_CLK", 100, rc);
1793 goto error1;
1794 }
1795 rc = gpio_request(101, "HDMI_DDC_DATA");
1796 if (rc) {
1797 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1798 "HDMI_DDC_DATA", 101, rc);
1799 goto error2;
1800 }
1801 rc = gpio_request(102, "HDMI_HPD");
1802 if (rc) {
1803 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1804 "HDMI_HPD", 102, rc);
1805 goto error3;
1806 }
1807 pr_debug("%s(on): success\n", __func__);
1808 } else {
1809 gpio_free(100);
1810 gpio_free(101);
1811 gpio_free(102);
1812
1813 rc = regulator_set_optimum_mode(reg_8921_l23, 100);
1814 if (rc < 0) {
1815 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1816 return -EINVAL;
1817 }
1818
1819 pr_debug("%s(off): success\n", __func__);
1820 }
1821
1822 prev_on = on;
1823
1824 return 0;
1825
1826error3:
1827 gpio_free(101);
1828error2:
1829 gpio_free(100);
1830error1:
1831 regulator_disable(reg_8921_l23);
1832 return rc;
1833}
1834
1835static int hdmi_cec_power(int on)
1836{
1837 static int prev_on;
1838 int rc;
1839
1840 if (on == prev_on)
1841 return 0;
1842
1843 if (on) {
1844 rc = gpio_request(99, "HDMI_CEC_VAR");
1845 if (rc) {
1846 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1847 "HDMI_CEC_VAR", 99, rc);
1848 goto error;
1849 }
1850 pr_debug("%s(on): success\n", __func__);
1851 } else {
1852 gpio_free(99);
1853 pr_debug("%s(off): success\n", __func__);
1854 }
1855
1856 prev_on = on;
1857
1858 return 0;
1859error:
1860 return rc;
1861}
1862#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1863
1864static void __init msm8960_allocate_memory_regions(void)
1865{
1866 void *addr;
1867 unsigned long size;
1868
1869 size = MSM_FB_SIZE;
1870 addr = alloc_bootmem_align(size, 0x1000);
1871 msm_fb_resources[0].start = __pa(addr);
1872 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
1873 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
1874 size, addr, __pa(addr));
1875
1876}
1877#ifdef CONFIG_WCD9310_CODEC
1878
1879#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
1880
Patrick Lai3043fba2011-08-01 14:15:57 -07001881/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
1882 * 4 micbiases are used to power various analog and digital
1883 * microphones operating at 1800 mV. Technically, all micbiases
1884 * can source from single cfilter since all microphones operate
1885 * at the same voltage level. The arrangement below is to make
1886 * sure all cfilters are exercised. LDO_H regulator ouput level
1887 * does not need to be as high as 2.85V. It is choosen for
1888 * microphone sensitivity purpose.
1889 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001890static struct tabla_pdata tabla_platform_data = {
1891 .slimbus_slave_device = {
1892 .name = "tabla-slave",
1893 .e_addr = {0, 0, 0x10, 0, 0x17, 2},
1894 },
1895 .irq = MSM_GPIO_TO_INT(62),
1896 .irq_base = TABLA_INTERRUPT_BASE,
1897 .num_irqs = NR_TABLA_IRQS,
1898 .reset_gpio = PM8921_GPIO_PM_TO_SYS(34),
Patrick Lai3043fba2011-08-01 14:15:57 -07001899 .micbias = {
1900 .ldoh_v = TABLA_LDOH_2P85_V,
1901 .cfilt1_mv = 1800,
1902 .cfilt2_mv = 1800,
1903 .cfilt3_mv = 1800,
1904 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
1905 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
1906 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
1907 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
1908 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001909};
1910
1911static struct slim_device msm_slim_tabla = {
1912 .name = "tabla-slim",
1913 .e_addr = {0, 1, 0x10, 0, 0x17, 2},
1914 .dev = {
1915 .platform_data = &tabla_platform_data,
1916 },
1917};
1918#endif
1919
1920static struct slim_boardinfo msm_slim_devices[] = {
1921#ifdef CONFIG_WCD9310_CODEC
1922 {
1923 .bus_num = 1,
1924 .slim_slave = &msm_slim_tabla,
1925 },
1926#endif
1927 /* add more slimbus slaves as needed */
1928};
1929
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001930#define MSM_WCNSS_PHYS 0x03000000
1931#define MSM_WCNSS_SIZE 0x280000
1932
1933static struct resource resources_wcnss_wlan[] = {
1934 {
1935 .start = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1936 .end = RIVA_APPS_WLAN_RX_DATA_AVAIL_IRQ,
1937 .name = "wcnss_wlanrx_irq",
1938 .flags = IORESOURCE_IRQ,
1939 },
1940 {
1941 .start = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1942 .end = RIVA_APPS_WLAN_DATA_XFER_DONE_IRQ,
1943 .name = "wcnss_wlantx_irq",
1944 .flags = IORESOURCE_IRQ,
1945 },
1946 {
1947 .start = MSM_WCNSS_PHYS,
1948 .end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
1949 .name = "wcnss_mmio",
1950 .flags = IORESOURCE_MEM,
1951 },
1952};
1953
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001954static struct qcom_wcnss_opts qcom_wcnss_pdata = {
1955 .has_48mhz_xo = 1,
1956};
1957
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001958static struct platform_device msm_device_wcnss_wlan = {
1959 .name = "wcnss_wlan",
1960 .id = 0,
1961 .num_resources = ARRAY_SIZE(resources_wcnss_wlan),
1962 .resource = resources_wcnss_wlan,
Ankur Nandwanib0039b02011-08-09 14:00:45 -07001963 .dev = {.platform_data = &qcom_wcnss_pdata},
Yunsen Wang5c1a7392011-07-09 19:10:16 -07001964};
1965
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001966#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
1967 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) || \
1968 defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
1969 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
1970
1971#define QCE_SIZE 0x10000
1972#define QCE_0_BASE 0x18500000
1973
1974#define QCE_HW_KEY_SUPPORT 0
1975#define QCE_SHA_HMAC_SUPPORT 1
1976#define QCE_SHARE_CE_RESOURCE 1
1977#define QCE_CE_SHARED 0
1978
1979static struct resource qcrypto_resources[] = {
1980 [0] = {
1981 .start = QCE_0_BASE,
1982 .end = QCE_0_BASE + QCE_SIZE - 1,
1983 .flags = IORESOURCE_MEM,
1984 },
1985 [1] = {
1986 .name = "crypto_channels",
1987 .start = DMOV_CE_IN_CHAN,
1988 .end = DMOV_CE_OUT_CHAN,
1989 .flags = IORESOURCE_DMA,
1990 },
1991 [2] = {
1992 .name = "crypto_crci_in",
1993 .start = DMOV_CE_IN_CRCI,
1994 .end = DMOV_CE_IN_CRCI,
1995 .flags = IORESOURCE_DMA,
1996 },
1997 [3] = {
1998 .name = "crypto_crci_out",
1999 .start = DMOV_CE_OUT_CRCI,
2000 .end = DMOV_CE_OUT_CRCI,
2001 .flags = IORESOURCE_DMA,
2002 },
2003};
2004
2005static struct resource qcedev_resources[] = {
2006 [0] = {
2007 .start = QCE_0_BASE,
2008 .end = QCE_0_BASE + QCE_SIZE - 1,
2009 .flags = IORESOURCE_MEM,
2010 },
2011 [1] = {
2012 .name = "crypto_channels",
2013 .start = DMOV_CE_IN_CHAN,
2014 .end = DMOV_CE_OUT_CHAN,
2015 .flags = IORESOURCE_DMA,
2016 },
2017 [2] = {
2018 .name = "crypto_crci_in",
2019 .start = DMOV_CE_IN_CRCI,
2020 .end = DMOV_CE_IN_CRCI,
2021 .flags = IORESOURCE_DMA,
2022 },
2023 [3] = {
2024 .name = "crypto_crci_out",
2025 .start = DMOV_CE_OUT_CRCI,
2026 .end = DMOV_CE_OUT_CRCI,
2027 .flags = IORESOURCE_DMA,
2028 },
2029};
2030
2031#endif
2032
2033#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2034 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2035
2036static struct msm_ce_hw_support qcrypto_ce_hw_suppport = {
2037 .ce_shared = QCE_CE_SHARED,
2038 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
2039 .hw_key_support = QCE_HW_KEY_SUPPORT,
2040 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
2041};
2042
2043static struct platform_device qcrypto_device = {
2044 .name = "qcrypto",
2045 .id = 0,
2046 .num_resources = ARRAY_SIZE(qcrypto_resources),
2047 .resource = qcrypto_resources,
2048 .dev = {
2049 .coherent_dma_mask = DMA_BIT_MASK(32),
2050 .platform_data = &qcrypto_ce_hw_suppport,
2051 },
2052};
2053#endif
2054
2055#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2056 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2057
2058static struct msm_ce_hw_support qcedev_ce_hw_suppport = {
2059 .ce_shared = QCE_CE_SHARED,
2060 .shared_ce_resource = QCE_SHARE_CE_RESOURCE,
2061 .hw_key_support = QCE_HW_KEY_SUPPORT,
2062 .sha_hmac = QCE_SHA_HMAC_SUPPORT,
2063};
2064
2065static struct platform_device qcedev_device = {
2066 .name = "qce",
2067 .id = 0,
2068 .num_resources = ARRAY_SIZE(qcedev_resources),
2069 .resource = qcedev_resources,
2070 .dev = {
2071 .coherent_dma_mask = DMA_BIT_MASK(32),
2072 .platform_data = &qcedev_ce_hw_suppport,
2073 },
2074};
2075#endif
2076
2077
2078static int __init gpiomux_init(void)
2079{
2080 int rc;
2081
2082 rc = msm_gpiomux_init(NR_GPIO_IRQS);
2083 if (rc) {
2084 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
2085 return rc;
2086 }
2087
2088 msm_gpiomux_install(msm8960_cam_configs,
2089 ARRAY_SIZE(msm8960_cam_configs));
2090
2091 msm_gpiomux_install(msm8960_gpiomux_configs,
Stepan Moskovchenkod2a45a82011-08-09 17:02:57 -07002092 ARRAY_SIZE(msm8960_gpiomux_configs));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002093
2094 msm_gpiomux_install(msm8960_gsbi_configs,
2095 ARRAY_SIZE(msm8960_gsbi_configs));
2096
2097 msm_gpiomux_install(msm8960_cyts_configs,
2098 ARRAY_SIZE(msm8960_cyts_configs));
2099
2100 msm_gpiomux_install(msm8960_slimbus_config,
2101 ARRAY_SIZE(msm8960_slimbus_config));
2102
2103 msm_gpiomux_install(msm8960_audio_codec_configs,
2104 ARRAY_SIZE(msm8960_audio_codec_configs));
2105
2106#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
2107 msm_gpiomux_install(msm8960_hdmi_configs,
2108 ARRAY_SIZE(msm8960_hdmi_configs));
2109#endif
2110
Ravishangar Kalyanamba99e512011-07-20 12:57:19 -07002111 msm_gpiomux_install(msm8960_mdp_vsync_configs,
2112 ARRAY_SIZE(msm8960_mdp_vsync_configs));
2113
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002114 msm_gpiomux_install(wcnss_5wire_interface,
2115 ARRAY_SIZE(wcnss_5wire_interface));
2116
2117 return 0;
2118}
2119
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002120#define MSM_SHARED_RAM_PHYS 0x80000000
2121
2122static struct pm8921_adc_amux pm8921_adc_channels_data[] = {
2123 {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
2124 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2125 {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
2126 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2127 {"dcin", CHANNEL_DCIN, CHAN_PATH_SCALING4, AMUX_RSV1,
2128 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2129 {"ichg", CHANNEL_ICHG, CHAN_PATH_SCALING1, AMUX_RSV1,
2130 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2131 {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
2132 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2133 {"ibat", CHANNEL_IBAT, CHAN_PATH_SCALING1, AMUX_RSV1,
2134 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2135 {"m4", CHANNEL_MPP_1, CHAN_PATH_SCALING1, AMUX_RSV1,
2136 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2137 {"m5", CHANNEL_MPP_2, CHAN_PATH_SCALING2, AMUX_RSV1,
2138 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2139 {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
2140 ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
2141 {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV1,
2142 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2143 {"usbin", CHANNEL_USBIN, CHAN_PATH_SCALING3, AMUX_RSV1,
2144 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2145 {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
2146 ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
2147 {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
2148 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2149 {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
2150 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2151 {"chg_temp", CHANNEL_CHG_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
2152 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
2153};
2154
2155static struct pm8921_adc_properties pm8921_adc_data = {
2156 .adc_vdd_reference = 1800, /* milli-voltage for this adc */
2157 .bitresolution = 15,
2158 .bipolar = 0,
2159};
2160
2161static struct pm8921_adc_platform_data pm8921_adc_pdata = {
2162 .adc_channel = pm8921_adc_channels_data,
2163 .adc_num_channel = ARRAY_SIZE(pm8921_adc_channels_data),
2164 .adc_prop = &pm8921_adc_data,
2165};
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08002166
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002167static void __init msm8960_map_io(void)
2168{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002169 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002170 msm_map_msm8960_io();
2171}
2172
2173static void __init msm8960_init_irq(void)
2174{
2175 unsigned int i;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002176
2177 msm_mpm_irq_extn_init();
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002178 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002179 (void *)MSM_QGIC_CPU_BASE);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002180
2181 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002182 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002183
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002184 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
2185 mb();
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08002186
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002187 /* FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
2188 * as they are configured as level, which does not play nice with
2189 * handle_percpu_irq.
2190 */
2191 for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
2192 if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
Thomas Gleixner6845664a2011-03-24 13:25:22 +01002193 irq_set_handler(i, handle_percpu_irq);
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08002194 }
2195}
2196
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002197/* MSM8960 have 5 SDCC controllers */
2198enum sdcc_controllers {
2199 SDCC1,
2200 SDCC2,
2201 SDCC3,
2202 SDCC4,
2203 SDCC5,
2204 MAX_SDCC_CONTROLLER
2205};
2206
2207/* All SDCC controllers requires VDD/VCC voltage */
2208static struct msm_mmc_reg_data mmc_vdd_reg_data[MAX_SDCC_CONTROLLER] = {
2209 /* SDCC1 : eMMC card connected */
2210 [SDCC1] = {
2211 .name = "sdc_vdd",
2212 .set_voltage_sup = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302213 .high_vol_level = 2950000,
2214 .low_vol_level = 2950000,
Subhash Jadavanidd7ef892011-08-18 16:49:57 +05302215 .always_on = 1,
2216 .lpm_sup = 1,
2217 .lpm_uA = 9000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002218 .hpm_uA = 200000, /* 200mA */
2219 },
2220 /* SDCC3 : External card slot connected */
2221 [SDCC3] = {
2222 .name = "sdc_vdd",
2223 .set_voltage_sup = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302224 .high_vol_level = 2950000,
2225 .low_vol_level = 2950000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002226 .hpm_uA = 600000, /* 600mA */
2227 }
2228};
2229
2230/* Only slots having eMMC card will require VCCQ voltage */
2231static struct msm_mmc_reg_data mmc_vccq_reg_data[1] = {
2232 /* SDCC1 : eMMC card connected */
2233 [SDCC1] = {
2234 .name = "sdc_vccq",
2235 .set_voltage_sup = 1,
2236 .always_on = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302237 .high_vol_level = 1800000,
2238 .low_vol_level = 1800000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002239 .hpm_uA = 200000, /* 200mA */
2240 }
2241};
2242
2243/* All SDCC controllers may require voting for VDD PAD voltage */
2244static struct msm_mmc_reg_data mmc_vddp_reg_data[MAX_SDCC_CONTROLLER] = {
2245 /* SDCC3 : External card slot connected */
2246 [SDCC3] = {
2247 .name = "sdc_vddp",
2248 .set_voltage_sup = 1,
Subhash Jadavani99ba53a2011-08-01 16:04:18 +05302249 .high_vol_level = 2950000,
2250 .low_vol_level = 1850000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002251 .always_on = 1,
2252 .lpm_sup = 1,
2253 /* Max. Active current required is 16 mA */
2254 .hpm_uA = 16000,
2255 /*
2256 * Sleep current required is ~300 uA. But min. vote can be
2257 * in terms of mA (min. 1 mA). So let's vote for 2 mA
2258 * during sleep.
2259 */
2260 .lpm_uA = 2000,
2261 }
2262};
2263
2264static struct msm_mmc_slot_reg_data mmc_slot_vreg_data[MAX_SDCC_CONTROLLER] = {
2265 /* SDCC1 : eMMC card connected */
2266 [SDCC1] = {
2267 .vdd_data = &mmc_vdd_reg_data[SDCC1],
2268 .vccq_data = &mmc_vccq_reg_data[SDCC1],
2269 },
2270 /* SDCC3 : External card slot connected */
2271 [SDCC3] = {
2272 .vdd_data = &mmc_vdd_reg_data[SDCC3],
2273 .vddp_data = &mmc_vddp_reg_data[SDCC3],
2274 }
2275};
2276
2277/* SDC1 pad data */
2278static struct msm_mmc_pad_drv sdc1_pad_drv_on_cfg[] = {
2279 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_16MA},
Subhash Jadavani87bda5a2011-08-30 17:40:44 +05302280 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_10MA},
2281 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_10MA}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002282};
2283
2284static struct msm_mmc_pad_drv sdc1_pad_drv_off_cfg[] = {
2285 {TLMM_HDRV_SDC1_CLK, GPIO_CFG_2MA},
2286 {TLMM_HDRV_SDC1_CMD, GPIO_CFG_2MA},
2287 {TLMM_HDRV_SDC1_DATA, GPIO_CFG_2MA}
2288};
2289
2290static struct msm_mmc_pad_pull sdc1_pad_pull_on_cfg[] = {
2291 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_UP},
2292 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_UP}
2293};
2294
2295static struct msm_mmc_pad_pull sdc1_pad_pull_off_cfg[] = {
2296 {TLMM_PULL_SDC1_CMD, GPIO_CFG_PULL_DOWN},
2297 {TLMM_PULL_SDC1_DATA, GPIO_CFG_PULL_DOWN}
2298};
2299
2300/* SDC3 pad data */
2301static struct msm_mmc_pad_drv sdc3_pad_drv_on_cfg[] = {
2302 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_8MA},
2303 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_8MA},
2304 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_8MA}
2305};
2306
2307static struct msm_mmc_pad_drv sdc3_pad_drv_off_cfg[] = {
2308 {TLMM_HDRV_SDC3_CLK, GPIO_CFG_2MA},
2309 {TLMM_HDRV_SDC3_CMD, GPIO_CFG_2MA},
2310 {TLMM_HDRV_SDC3_DATA, GPIO_CFG_2MA}
2311};
2312
2313static struct msm_mmc_pad_pull sdc3_pad_pull_on_cfg[] = {
2314 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_UP},
2315 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_UP}
2316};
2317
2318static struct msm_mmc_pad_pull sdc3_pad_pull_off_cfg[] = {
2319 {TLMM_PULL_SDC3_CMD, GPIO_CFG_PULL_DOWN},
2320 {TLMM_PULL_SDC3_DATA, GPIO_CFG_PULL_DOWN}
2321};
2322
2323struct msm_mmc_pad_pull_data mmc_pad_pull_data[MAX_SDCC_CONTROLLER] = {
2324 [SDCC1] = {
2325 .on = sdc1_pad_pull_on_cfg,
2326 .off = sdc1_pad_pull_off_cfg,
2327 .size = ARRAY_SIZE(sdc1_pad_pull_on_cfg)
2328 },
2329 [SDCC3] = {
2330 .on = sdc3_pad_pull_on_cfg,
2331 .off = sdc3_pad_pull_off_cfg,
2332 .size = ARRAY_SIZE(sdc3_pad_pull_on_cfg)
2333 },
2334};
2335
2336struct msm_mmc_pad_drv_data mmc_pad_drv_data[MAX_SDCC_CONTROLLER] = {
2337 [SDCC1] = {
2338 .on = sdc1_pad_drv_on_cfg,
2339 .off = sdc1_pad_drv_off_cfg,
2340 .size = ARRAY_SIZE(sdc1_pad_drv_on_cfg)
2341 },
2342 [SDCC3] = {
2343 .on = sdc3_pad_drv_on_cfg,
2344 .off = sdc3_pad_drv_off_cfg,
2345 .size = ARRAY_SIZE(sdc3_pad_drv_on_cfg)
2346 },
2347};
2348
2349struct msm_mmc_pad_data mmc_pad_data[MAX_SDCC_CONTROLLER] = {
2350 [SDCC1] = {
2351 .pull = &mmc_pad_pull_data[SDCC1],
2352 .drv = &mmc_pad_drv_data[SDCC1]
2353 },
2354 [SDCC3] = {
2355 .pull = &mmc_pad_pull_data[SDCC3],
2356 .drv = &mmc_pad_drv_data[SDCC3]
2357 },
2358};
2359
2360struct msm_mmc_pin_data mmc_slot_pin_data[MAX_SDCC_CONTROLLER] = {
2361 [SDCC1] = {
2362 .pad_data = &mmc_pad_data[SDCC1],
2363 },
2364 [SDCC3] = {
2365 .pad_data = &mmc_pad_data[SDCC3],
2366 },
2367};
2368
2369static unsigned int sdc1_sup_clk_rates[] = {
Subhash Jadavani0e027b72011-08-30 17:40:55 +05302370 400000, 24000000, 48000000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002371};
2372
2373static unsigned int sdc3_sup_clk_rates[] = {
2374 400000, 24000000, 48000000, 96000000
2375};
2376
2377#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
2378static struct mmc_platform_data msm8960_sdc1_data = {
2379 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
2380#ifdef CONFIG_MMC_MSM_SDC1_8_BIT_SUPPORT
2381 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
2382#else
2383 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
2384#endif
2385 .sup_clk_table = sdc1_sup_clk_rates,
2386 .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates),
2387 .nonremovable = 1,
2388 .sdcc_v4_sup = true,
2389 .vreg_data = &mmc_slot_vreg_data[SDCC1],
Subhash Jadavani0e027b72011-08-30 17:40:55 +05302390 .pin_data = &mmc_slot_pin_data[SDCC1]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002391};
2392#endif
2393
2394#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
2395static struct mmc_platform_data msm8960_sdc3_data = {
2396 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
2397 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
2398 .sup_clk_table = sdc3_sup_clk_rates,
2399 .sup_clk_cnt = ARRAY_SIZE(sdc3_sup_clk_rates),
2400 .wpswitch_gpio = PM8921_GPIO_PM_TO_SYS(16),
2401 .sdcc_v4_sup = true,
2402 .vreg_data = &mmc_slot_vreg_data[SDCC3],
2403 .pin_data = &mmc_slot_pin_data[SDCC3],
2404#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
2405 .status_gpio = PM8921_GPIO_PM_TO_SYS(26),
2406 .status_irq = PM8921_GPIO_IRQ(PM8921_IRQ_BASE, 26),
2407 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
2408#endif
2409 .xpc_cap = 1,
2410 .uhs_caps = (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
2411 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_DDR50 |
Subhash Jadavani0e027b72011-08-30 17:40:55 +05302412 MMC_CAP_MAX_CURRENT_600)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002413};
2414#endif
2415
2416static void __init msm8960_init_mmc(void)
2417{
2418#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
2419 /* SDC1 : eMMC card connected */
2420 msm_add_sdcc(1, &msm8960_sdc1_data);
2421#endif
2422#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
2423 /* SDC3: External card slot */
2424 msm_add_sdcc(3, &msm8960_sdc3_data);
2425#endif
2426}
2427
2428static void __init msm8960_init_buses(void)
2429{
2430#ifdef CONFIG_MSM_BUS_SCALING
2431 msm_bus_apps_fabric_pdata.rpm_enabled = 1;
2432 msm_bus_sys_fabric_pdata.rpm_enabled = 1;
2433 msm_bus_mm_fabric_pdata.rpm_enabled = 1;
2434 msm_bus_sys_fpb_pdata.rpm_enabled = 1;
2435 msm_bus_cpss_fpb_pdata.rpm_enabled = 1;
2436 msm_bus_apps_fabric.dev.platform_data = &msm_bus_apps_fabric_pdata;
2437 msm_bus_sys_fabric.dev.platform_data = &msm_bus_sys_fabric_pdata;
2438 msm_bus_mm_fabric.dev.platform_data = &msm_bus_mm_fabric_pdata;
2439 msm_bus_sys_fpb.dev.platform_data = &msm_bus_sys_fpb_pdata;
2440 msm_bus_cpss_fpb.dev.platform_data = &msm_bus_cpss_fpb_pdata;
2441#endif
2442}
2443
2444static struct msm_spi_platform_data msm8960_qup_spi_gsbi1_pdata = {
2445 .max_clock_speed = 15060000,
2446};
2447
2448#ifdef CONFIG_USB_MSM_OTG_72K
2449static struct msm_otg_platform_data msm_otg_pdata;
2450#else
2451#define USB_5V_EN 42
2452static void msm_hsusb_vbus_power(bool on)
2453{
2454 int rc;
2455 static bool vbus_is_on;
2456 static struct regulator *mvs_otg_switch;
2457 struct pm_gpio param = {
2458 .direction = PM_GPIO_DIR_OUT,
2459 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
2460 .output_value = 1,
2461 .pull = PM_GPIO_PULL_NO,
2462 .vin_sel = PM_GPIO_VIN_S4,
2463 .out_strength = PM_GPIO_STRENGTH_MED,
2464 .function = PM_GPIO_FUNC_NORMAL,
2465 };
2466
2467 if (vbus_is_on == on)
2468 return;
2469
2470 if (on) {
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002471 mvs_otg_switch = regulator_get(&msm8960_device_otg.dev,
2472 "vbus_otg");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002473 if (IS_ERR(mvs_otg_switch)) {
2474 pr_err("Unable to get mvs_otg_switch\n");
2475 return;
2476 }
2477
2478 rc = gpio_request(PM8921_GPIO_PM_TO_SYS(USB_5V_EN),
2479 "usb_5v_en");
2480 if (rc < 0) {
2481 pr_err("failed to request usb_5v_en gpio\n");
2482 goto put_mvs_otg;
2483 }
2484
2485 if (regulator_enable(mvs_otg_switch)) {
2486 pr_err("unable to enable mvs_otg_switch\n");
2487 goto free_usb_5v_en;
2488 }
2489
2490 rc = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(USB_5V_EN),
2491 &param);
2492 if (rc < 0) {
2493 pr_err("failed to configure usb_5v_en gpio\n");
2494 goto disable_mvs_otg;
2495 }
2496 vbus_is_on = true;
2497 return;
2498 }
2499disable_mvs_otg:
2500 regulator_disable(mvs_otg_switch);
2501free_usb_5v_en:
2502 gpio_free(PM8921_GPIO_PM_TO_SYS(USB_5V_EN));
2503put_mvs_otg:
2504 regulator_put(mvs_otg_switch);
2505 vbus_is_on = false;
2506}
2507
2508static struct msm_otg_platform_data msm_otg_pdata = {
2509 .mode = USB_OTG,
2510 .otg_control = OTG_PMIC_CONTROL,
2511 .phy_type = SNPS_28NM_INTEGRATED_PHY,
2512 .pclk_src_name = "dfab_usb_hs_clk",
2513 .pmic_id_irq = PM8921_USB_ID_IN_IRQ(PM8921_IRQ_BASE),
2514 .vbus_power = msm_hsusb_vbus_power,
2515};
2516#endif
2517
2518#define PID_MAGIC_ID 0x71432909
2519#define SERIAL_NUM_MAGIC_ID 0x61945374
2520#define SERIAL_NUMBER_LENGTH 127
2521#define DLOAD_USB_BASE_ADD 0x2A03F0C8
2522
2523struct magic_num_struct {
2524 uint32_t pid;
2525 uint32_t serial_num;
2526};
2527
2528struct dload_struct {
2529 uint32_t reserved1;
2530 uint32_t reserved2;
2531 uint32_t reserved3;
2532 uint16_t reserved4;
2533 uint16_t pid;
2534 char serial_number[SERIAL_NUMBER_LENGTH];
2535 uint16_t reserved5;
2536 struct magic_num_struct magic_struct;
2537};
2538
2539static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
2540{
2541 struct dload_struct __iomem *dload = 0;
2542
2543 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
2544 if (!dload) {
2545 pr_err("%s: cannot remap I/O memory region: %08x\n",
2546 __func__, DLOAD_USB_BASE_ADD);
2547 return -ENXIO;
2548 }
2549
2550 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
2551 __func__, dload, pid, snum);
2552 /* update pid */
2553 dload->magic_struct.pid = PID_MAGIC_ID;
2554 dload->pid = pid;
2555
2556 /* update serial number */
2557 dload->magic_struct.serial_num = 0;
2558 if (!snum) {
2559 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
2560 goto out;
2561 }
2562
2563 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
2564 strncpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
2565 dload->serial_number[SERIAL_NUMBER_LENGTH - 1] = '\0';
2566out:
2567 iounmap(dload);
2568 return 0;
2569}
2570
2571static struct android_usb_platform_data android_usb_pdata = {
2572 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
2573};
2574
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002575static struct platform_device android_usb_device = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002576 .name = "android_usb",
2577 .id = -1,
2578 .dev = {
2579 .platform_data = &android_usb_pdata,
2580 },
2581};
2582
2583static uint8_t spm_wfi_cmd_sequence[] __initdata = {
2584 0x03, 0x0f,
2585};
2586
2587static uint8_t spm_power_collapse_without_rpm[] __initdata = {
2588 0x00, 0x24, 0x54, 0x10,
2589 0x09, 0x03, 0x01,
2590 0x10, 0x54, 0x30, 0x0C,
2591 0x24, 0x30, 0x0f,
2592};
2593
2594static uint8_t spm_power_collapse_with_rpm[] __initdata = {
2595 0x00, 0x24, 0x54, 0x10,
2596 0x09, 0x07, 0x01, 0x0B,
2597 0x10, 0x54, 0x30, 0x0C,
2598 0x24, 0x30, 0x0f,
2599};
2600
2601static struct msm_spm_seq_entry msm_spm_seq_list[] __initdata = {
2602 [0] = {
2603 .mode = MSM_SPM_MODE_CLOCK_GATING,
2604 .notify_rpm = false,
2605 .cmd = spm_wfi_cmd_sequence,
2606 },
2607 [1] = {
2608 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2609 .notify_rpm = false,
2610 .cmd = spm_power_collapse_without_rpm,
2611 },
2612 [2] = {
2613 .mode = MSM_SPM_MODE_POWER_COLLAPSE,
2614 .notify_rpm = true,
2615 .cmd = spm_power_collapse_with_rpm,
2616 },
2617};
2618
2619static struct msm_spm_platform_data msm_spm_data[] __initdata = {
2620 [0] = {
2621 .reg_base_addr = MSM_SAW0_BASE,
2622 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
2623 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
2624 .reg_init_values[MSM_SPM_REG_SAW2_VCTL] = 0x9C,
2625#if defined(CONFIG_MSM_AVS_HW)
2626 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2627 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2628#endif
2629 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
2630 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
2631 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2632 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2633 .vctl_timeout_us = 50,
2634 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
2635 .modes = msm_spm_seq_list,
2636 },
2637 [1] = {
2638 .reg_base_addr = MSM_SAW1_BASE,
2639 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
2640 .reg_init_values[MSM_SPM_REG_SAW2_CFG] = 0x1F,
2641 .reg_init_values[MSM_SPM_REG_SAW2_VCTL] = 0x9C,
2642#if defined(CONFIG_MSM_AVS_HW)
2643 .reg_init_values[MSM_SPM_REG_SAW2_AVS_CTL] = 0x00,
2644 .reg_init_values[MSM_SPM_REG_SAW2_AVS_HYSTERESIS] = 0x00,
2645#endif
2646 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x01,
2647 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
2648 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x0060009C,
2649 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x0000001C,
2650 .vctl_timeout_us = 50,
2651 .num_modes = ARRAY_SIZE(msm_spm_seq_list),
2652 .modes = msm_spm_seq_list,
2653 },
2654};
2655
2656static uint8_t l2_spm_wfi_cmd_sequence[] __initdata = {
2657 0x00, 0x20, 0x03, 0x20,
2658 0x00, 0x0f,
2659};
2660
2661static uint8_t l2_spm_gdhs_cmd_sequence[] __initdata = {
2662 0x00, 0x20, 0x34, 0x64,
2663 0x48, 0x07, 0x48, 0x20,
2664 0x50, 0x64, 0x04, 0x34,
2665 0x50, 0x0f,
2666};
2667static uint8_t l2_spm_power_off_cmd_sequence[] __initdata = {
2668 0x00, 0x10, 0x34, 0x64,
2669 0x48, 0x07, 0x48, 0x10,
2670 0x50, 0x64, 0x04, 0x34,
2671 0x50, 0x0F,
2672};
2673
2674static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
2675 [0] = {
2676 .mode = MSM_SPM_L2_MODE_RETENTION,
2677 .notify_rpm = false,
2678 .cmd = l2_spm_wfi_cmd_sequence,
2679 },
2680 [1] = {
2681 .mode = MSM_SPM_L2_MODE_GDHS,
2682 .notify_rpm = true,
2683 .cmd = l2_spm_gdhs_cmd_sequence,
2684 },
2685 [2] = {
2686 .mode = MSM_SPM_L2_MODE_POWER_COLLAPSE,
2687 .notify_rpm = true,
2688 .cmd = l2_spm_power_off_cmd_sequence,
2689 },
2690};
2691
2692
2693static struct msm_spm_platform_data msm_spm_l2_data[] __initdata = {
2694 [0] = {
2695 .reg_base_addr = MSM_SAW_L2_BASE,
2696 .reg_init_values[MSM_SPM_REG_SAW2_SECURE] = 0x00,
2697 .reg_init_values[MSM_SPM_REG_SAW2_SPM_CTL] = 0x00,
2698 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DLY] = 0x02020202,
2699 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_0] = 0x00A000AE,
2700 .reg_init_values[MSM_SPM_REG_SAW2_PMIC_DATA_1] = 0x00A00020,
2701 .modes = msm_spm_l2_seq_list,
2702 .num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
2703 },
2704};
2705
2706#define CYTTSP_TS_GPIO_IRQ 11
2707#define CYTTSP_TS_SLEEP_GPIO 50
2708#define CYTTSP_TS_RESOUT_N_GPIO 52
2709
2710/*virtual key support */
2711static ssize_t tma340_vkeys_show(struct kobject *kobj,
2712 struct kobj_attribute *attr, char *buf)
2713{
2714 return snprintf(buf, 200,
2715 __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
2716 ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
2717 ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
2718 ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
2719 "\n");
2720}
2721
2722static struct kobj_attribute tma340_vkeys_attr = {
2723 .attr = {
2724 .mode = S_IRUGO,
2725 },
2726 .show = &tma340_vkeys_show,
2727};
2728
2729static struct attribute *tma340_properties_attrs[] = {
2730 &tma340_vkeys_attr.attr,
2731 NULL
2732};
2733
2734static struct attribute_group tma340_properties_attr_group = {
2735 .attrs = tma340_properties_attrs,
2736};
2737
2738
2739static int cyttsp_platform_init(struct i2c_client *client)
2740{
2741 int rc = 0;
2742 static struct kobject *tma340_properties_kobj;
2743
2744 tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
2745 tma340_properties_kobj = kobject_create_and_add("board_properties",
2746 NULL);
2747 if (tma340_properties_kobj)
2748 rc = sysfs_create_group(tma340_properties_kobj,
2749 &tma340_properties_attr_group);
2750 if (!tma340_properties_kobj || rc)
2751 pr_err("%s: failed to create board_properties\n",
2752 __func__);
2753
2754 return 0;
2755}
2756
2757static struct cyttsp_regulator regulator_data[] = {
2758 {
2759 .name = "vdd",
2760 .min_uV = CY_TMA300_VTG_MIN_UV,
2761 .max_uV = CY_TMA300_VTG_MAX_UV,
2762 .load_uA = CY_TMA300_CURR_24HZ_UA,
2763 },
2764 /* TODO: Remove after runtime PM is enabled in I2C driver */
2765 {
2766 .name = "vcc_i2c",
2767 .min_uV = CY_I2C_VTG_MIN_UV,
2768 .max_uV = CY_I2C_VTG_MAX_UV,
2769 .load_uA = CY_I2C_CURR_UA,
2770 },
2771};
2772
2773static struct cyttsp_platform_data cyttsp_pdata = {
2774 .panel_maxx = 634,
2775 .panel_maxy = 1166,
2776 .disp_maxx = 616,
2777 .disp_maxy = 1023,
2778 .disp_minx = 0,
2779 .disp_miny = 16,
2780 .flags = 0x01,
2781 .gen = CY_GEN3, /* or */
2782 .use_st = CY_USE_ST,
2783 .use_mt = CY_USE_MT,
2784 .use_hndshk = CY_SEND_HNDSHK,
2785 .use_trk_id = CY_USE_TRACKING_ID,
Anirudh Ghayale96f66d2011-08-11 14:06:38 +05302786 .use_sleep = CY_USE_DEEP_SLEEP_SEL | CY_USE_LOW_POWER_SEL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002787 .use_gestures = CY_USE_GESTURES,
2788 .fw_fname = "cyttsp_8960_cdp.hex",
2789 /* activate up to 4 groups
2790 * and set active distance
2791 */
2792 .gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
2793 CY_GEST_GRP3 | CY_GEST_GRP4 |
2794 CY_ACT_DIST,
2795 /* change act_intrvl to customize the Active power state
2796 * scanning/processing refresh interval for Operating mode
2797 */
2798 .act_intrvl = CY_ACT_INTRVL_DFLT,
2799 /* change tch_tmout to customize the touch timeout for the
2800 * Active power state for Operating mode
2801 */
2802 .tch_tmout = CY_TCH_TMOUT_DFLT,
2803 /* change lp_intrvl to customize the Low Power power state
2804 * scanning/processing refresh interval for Operating mode
2805 */
2806 .lp_intrvl = CY_LP_INTRVL_DFLT,
2807 .sleep_gpio = CYTTSP_TS_SLEEP_GPIO,
2808 .resout_gpio = CYTTSP_TS_RESOUT_N_GPIO,
2809 .irq_gpio = CYTTSP_TS_GPIO_IRQ,
2810 .regulator_info = regulator_data,
2811 .num_regulators = ARRAY_SIZE(regulator_data),
2812 .init = cyttsp_platform_init,
Mohan Pallaka49c37d62011-08-01 11:52:00 +05302813 .correct_fw_ver = 9,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002814};
2815
2816static struct i2c_board_info cyttsp_info[] __initdata = {
2817 {
2818 I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
2819 .platform_data = &cyttsp_pdata,
2820#ifndef CY_USE_TIMER
2821 .irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
2822#endif /* CY_USE_TIMER */
2823 },
2824};
2825
2826static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
2827{
2828}
2829
2830static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi4_pdata = {
2831 .clk_freq = 100000,
2832 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002833 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2834};
2835
2836static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi3_pdata = {
2837 .clk_freq = 100000,
2838 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002839 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2840};
2841
2842static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi10_pdata = {
2843 .clk_freq = 100000,
2844 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002845 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2846};
2847
2848static struct msm_i2c_platform_data msm8960_i2c_qup_gsbi12_pdata = {
2849 .clk_freq = 100000,
2850 .src_clk_rate = 24000000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002851 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
2852};
2853
2854static struct msm_rpm_platform_data msm_rpm_data = {
2855 .reg_base_addrs = {
2856 [MSM_RPM_PAGE_STATUS] = MSM_RPM_BASE,
2857 [MSM_RPM_PAGE_CTRL] = MSM_RPM_BASE + 0x400,
2858 [MSM_RPM_PAGE_REQ] = MSM_RPM_BASE + 0x600,
2859 [MSM_RPM_PAGE_ACK] = MSM_RPM_BASE + 0xa00,
2860 },
2861
2862 .irq_ack = RPM_APCC_CPU0_GP_HIGH_IRQ,
2863 .irq_err = RPM_APCC_CPU0_GP_LOW_IRQ,
2864 .irq_vmpm = RPM_APCC_CPU0_GP_MEDIUM_IRQ,
2865 .msm_apps_ipc_rpm_reg = MSM_APCS_GCC_BASE + 0x008,
2866 .msm_apps_ipc_rpm_val = 4,
2867};
2868
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06002869static struct platform_device msm_rpm_device = {
2870 .name = "msm_rpm",
2871 .id = -1,
2872};
2873
2874
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002875static struct spi_board_info spi_board_info[] __initdata = {
2876 {
2877 .modalias = "ks8851",
2878 .irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
2879 .max_speed_hz = 19200000,
2880 .bus_num = 0,
2881 .chip_select = 0,
2882 .mode = SPI_MODE_0,
2883 },
2884};
2885
2886static struct platform_device msm_device_saw_core0 = {
2887 .name = "saw-regulator",
2888 .id = 0,
2889 .dev = {
2890 .platform_data = &msm_saw_regulator_pdata_s5,
2891 },
2892};
2893
2894static struct platform_device msm_device_saw_core1 = {
2895 .name = "saw-regulator",
2896 .id = 1,
2897 .dev = {
2898 .platform_data = &msm_saw_regulator_pdata_s6,
2899 },
2900};
2901
2902#ifdef CONFIG_MSM_FAKE_BATTERY
2903static struct platform_device fish_battery_device = {
2904 .name = "fish_battery",
2905};
2906#endif
2907
David Collins26f05562011-06-20 09:56:28 -07002908static struct platform_device msm8960_device_ext_5v_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002909 .name = GPIO_REGULATOR_DEV_NAME,
2910 .id = PM8921_MPP_PM_TO_SYS(7),
2911 .dev = {
2912 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_5V],
2913 },
2914};
2915
David Collins26f05562011-06-20 09:56:28 -07002916static struct platform_device msm8960_device_ext_l2_vreg __devinitdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002917 .name = GPIO_REGULATOR_DEV_NAME,
2918 .id = 91,
2919 .dev = {
2920 .platform_data = &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_L2],
2921 },
2922};
2923
David Collinsb10be1d2011-09-02 10:29:31 -07002924static struct platform_device msm8960_device_ext_3p3v_vreg __devinitdata = {
2925 .name = GPIO_REGULATOR_DEV_NAME,
2926 .id = PM8921_GPIO_PM_TO_SYS(17),
2927 .dev = {
2928 .platform_data =
2929 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_3P3V],
2930 },
2931};
2932
David Collins26f05562011-06-20 09:56:28 -07002933static struct platform_device msm8960_device_rpm_regulator __devinitdata = {
2934 .name = "rpm-regulator",
2935 .id = -1,
2936 .dev = {
2937 .platform_data = &msm_rpm_regulator_pdata,
2938 },
2939};
2940
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002941static struct platform_device *common_devices[] __initdata = {
Stepan Moskovchenkodf13d342011-08-03 19:01:25 -07002942 &msm8960_device_dmov,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002943 &msm_device_smd,
2944 &msm8960_device_uart_gsbi5,
Mayank Rana9f51f582011-08-04 18:35:59 +05302945 &msm_device_uart_dm6,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002946 &msm_device_saw_core0,
2947 &msm_device_saw_core1,
2948 &msm8960_device_ext_5v_vreg,
2949 &msm8960_device_ext_l2_vreg,
2950 &msm8960_device_ssbi_pm8921,
2951 &msm8960_device_qup_spi_gsbi1,
2952 &msm8960_device_qup_i2c_gsbi3,
2953 &msm8960_device_qup_i2c_gsbi4,
2954 &msm8960_device_qup_i2c_gsbi10,
2955#ifndef CONFIG_MSM_DSPS
2956 &msm8960_device_qup_i2c_gsbi12,
2957#endif
2958 &msm_slim_ctrl,
2959 &msm_device_wcnss_wlan,
2960#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
2961 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
2962 &qcrypto_device,
2963#endif
2964
2965#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
2966 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
2967 &qcedev_device,
2968#endif
2969#ifdef CONFIG_MSM_ROTATOR
2970 &msm_rotator_device,
2971#endif
2972 &msm_device_sps,
2973#ifdef CONFIG_MSM_FAKE_BATTERY
2974 &fish_battery_device,
2975#endif
2976#ifdef CONFIG_ANDROID_PMEM
2977 &android_pmem_device,
2978 &android_pmem_adsp_device,
2979 &android_pmem_audio_device,
2980#endif
2981 &msm_fb_device,
2982 &msm_device_vidc,
2983 &msm_device_bam_dmux,
2984 &msm_fm_platform_init,
Mona Hossain9c430e32011-07-27 11:04:47 -07002985
2986#ifdef CONFIG_HW_RANDOM_MSM
2987 &msm_device_rng,
2988#endif
Praveen Chidambaram043f4ce2011-08-02 09:37:59 -06002989 &msm_rpm_device,
Laura Abbottd6183792011-08-19 13:42:24 -07002990#ifdef CONFIG_ION_MSM
2991 &ion_dev,
2992#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002993};
2994
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08002995static struct platform_device *sim_devices[] __initdata = {
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07002996 &msm8960_device_otg,
2997 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002998 &msm_device_hsusb_host,
2999 &android_usb_device,
3000 &msm_device_vidc,
3001 &mipi_dsi_simulator_panel_device,
3002 &msm_bus_apps_fabric,
3003 &msm_bus_sys_fabric,
3004 &msm_bus_mm_fabric,
3005 &msm_bus_sys_fpb,
3006 &msm_bus_cpss_fpb,
3007 &msm_pcm,
3008 &msm_pcm_routing,
3009 &msm_cpudai0,
3010 &msm_cpudai1,
3011 &msm_cpudai_hdmi_rx,
3012 &msm_cpudai_bt_rx,
3013 &msm_cpudai_bt_tx,
3014 &msm_cpudai_fm_rx,
3015 &msm_cpudai_fm_tx,
3016 &msm_cpu_fe,
3017 &msm_stub_codec,
3018 &msm_voice,
3019 &msm_voip,
3020 &msm_lpa_pcm,
3021
3022#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
3023 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
3024 &qcrypto_device,
3025#endif
3026
3027#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
3028 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
3029 &qcedev_device,
3030#endif
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003031};
3032
3033static struct platform_device *rumi3_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003034 &msm_kgsl_3d0,
3035 &msm_kgsl_2d0,
3036 &msm_kgsl_2d1,
3037 &mipi_dsi_renesas_panel_device,
3038#ifdef CONFIG_MSM_GEMINI
3039 &msm8960_gemini_device,
3040#endif
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003041};
3042
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003043static struct platform_device *cdp_devices[] __initdata = {
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003044 &msm8960_device_otg,
3045 &msm8960_device_gadget_peripheral,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003046 &msm_device_hsusb_host,
3047 &android_usb_device,
3048 &msm_pcm,
3049 &msm_pcm_routing,
3050 &msm_cpudai0,
3051 &msm_cpudai1,
3052 &msm_cpudai_hdmi_rx,
3053 &msm_cpudai_bt_rx,
3054 &msm_cpudai_bt_tx,
3055 &msm_cpudai_fm_rx,
3056 &msm_cpudai_fm_tx,
3057 &msm_cpu_fe,
3058 &msm_stub_codec,
3059 &msm_kgsl_3d0,
3060#ifdef CONFIG_MSM_KGSL_2D
3061 &msm_kgsl_2d0,
3062 &msm_kgsl_2d1,
3063#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003064#ifdef CONFIG_MSM_GEMINI
3065 &msm8960_gemini_device,
3066#endif
3067 &msm_voice,
3068 &msm_voip,
3069 &msm_lpa_pcm,
Laxminath Kasamcee1d602011-08-01 19:26:57 +05303070 &msm_cpudai_afe_01_rx,
3071 &msm_cpudai_afe_01_tx,
3072 &msm_cpudai_afe_02_rx,
3073 &msm_cpudai_afe_02_tx,
3074 &msm_pcm_afe,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003075#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
3076 &hdmi_msm_device,
3077#endif
3078 &msm_pcm_hostless,
3079 &msm_bus_apps_fabric,
3080 &msm_bus_sys_fabric,
3081 &msm_bus_mm_fabric,
3082 &msm_bus_sys_fpb,
3083 &msm_bus_cpss_fpb,
3084};
3085
3086static void __init msm8960_i2c_init(void)
3087{
3088 msm8960_device_qup_i2c_gsbi4.dev.platform_data =
3089 &msm8960_i2c_qup_gsbi4_pdata;
3090
3091 msm8960_device_qup_i2c_gsbi3.dev.platform_data =
3092 &msm8960_i2c_qup_gsbi3_pdata;
3093
3094 msm8960_device_qup_i2c_gsbi10.dev.platform_data =
3095 &msm8960_i2c_qup_gsbi10_pdata;
3096
3097 msm8960_device_qup_i2c_gsbi12.dev.platform_data =
3098 &msm8960_i2c_qup_gsbi12_pdata;
3099}
3100
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003101static void __init msm8960_gfx_init(void)
3102{
3103 uint32_t soc_platform_version = socinfo_get_platform_version();
3104 if (SOCINFO_VERSION_MAJOR(soc_platform_version) == 1) {
3105 struct kgsl_device_platform_data *kgsl_3d0_pdata =
3106 msm_kgsl_3d0.dev.platform_data;
3107 kgsl_3d0_pdata->pwr_data.pwrlevel[0].gpu_freq =
3108 320000000;
3109 kgsl_3d0_pdata->pwr_data.pwrlevel[1].gpu_freq =
3110 266667000;
3111 }
3112}
3113
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003114static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
3115 .irq_base = PM8921_IRQ_BASE,
3116 .devirq = MSM_GPIO_TO_INT(104),
3117 .irq_trigger_flag = IRQF_TRIGGER_LOW,
3118};
3119
3120static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
3121 .gpio_base = PM8921_GPIO_PM_TO_SYS(1),
3122};
3123
3124static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
3125 .mpp_base = PM8921_MPP_PM_TO_SYS(1),
3126};
3127
3128static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
3129 .rtc_write_enable = false,
3130};
3131
3132static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
3133 .pull_up = 1,
3134 .kpd_trigger_delay_us = 970,
3135 .wakeup = 1,
3136};
3137
3138static const unsigned int keymap[] = {
3139 KEY(0, 0, KEY_VOLUMEUP),
3140 KEY(0, 1, KEY_VOLUMEDOWN),
3141 KEY(0, 2, KEY_CAMERA_SNAPSHOT),
3142 KEY(0, 3, KEY_CAMERA_FOCUS),
3143};
3144
3145static struct matrix_keymap_data keymap_data = {
3146 .keymap_size = ARRAY_SIZE(keymap),
3147 .keymap = keymap,
3148};
3149
3150static struct pm8xxx_keypad_platform_data keypad_data = {
3151 .input_name = "keypad_8960",
3152 .input_phys_device = "keypad_8960/input0",
3153 .num_rows = 1,
3154 .num_cols = 5,
3155 .rows_gpio_start = PM8921_GPIO_PM_TO_SYS(9),
3156 .cols_gpio_start = PM8921_GPIO_PM_TO_SYS(1),
3157 .debounce_ms = 15,
3158 .scan_delay_ms = 32,
3159 .row_hold_ns = 91500,
3160 .wakeup = 1,
3161 .keymap_data = &keymap_data,
3162};
3163
3164static const unsigned int keymap_sim[] = {
3165 KEY(0, 0, KEY_7),
3166 KEY(0, 1, KEY_DOWN),
3167 KEY(0, 2, KEY_UP),
3168 KEY(0, 3, KEY_RIGHT),
3169 KEY(0, 4, KEY_ENTER),
3170 KEY(0, 5, KEY_L),
3171 KEY(0, 6, KEY_BACK),
3172 KEY(0, 7, KEY_M),
3173
3174 KEY(1, 0, KEY_LEFT),
3175 KEY(1, 1, KEY_SEND),
3176 KEY(1, 2, KEY_1),
3177 KEY(1, 3, KEY_4),
3178 KEY(1, 4, KEY_CLEAR),
3179 KEY(1, 5, KEY_MSDOS),
3180 KEY(1, 6, KEY_SPACE),
3181 KEY(1, 7, KEY_COMMA),
3182
3183 KEY(2, 0, KEY_6),
3184 KEY(2, 1, KEY_5),
3185 KEY(2, 2, KEY_8),
3186 KEY(2, 3, KEY_3),
3187 KEY(2, 4, KEY_NUMERIC_STAR),
3188 KEY(2, 5, KEY_UP),
3189 KEY(2, 6, KEY_DOWN),
3190 KEY(2, 7, KEY_LEFTSHIFT),
3191
3192 KEY(3, 0, KEY_9),
3193 KEY(3, 1, KEY_NUMERIC_POUND),
3194 KEY(3, 2, KEY_0),
3195 KEY(3, 3, KEY_2),
3196 KEY(3, 4, KEY_SLEEP),
3197 KEY(3, 5, KEY_F1),
3198 KEY(3, 6, KEY_F2),
3199 KEY(3, 7, KEY_F3),
3200
3201 KEY(4, 0, KEY_BACK),
3202 KEY(4, 1, KEY_HOME),
3203 KEY(4, 2, KEY_MENU),
3204 KEY(4, 3, KEY_VOLUMEUP),
3205 KEY(4, 4, KEY_VOLUMEDOWN),
3206 KEY(4, 5, KEY_F4),
3207 KEY(4, 6, KEY_F5),
3208 KEY(4, 7, KEY_F6),
3209
3210 KEY(5, 0, KEY_R),
3211 KEY(5, 1, KEY_T),
3212 KEY(5, 2, KEY_Y),
3213 KEY(5, 3, KEY_LEFTALT),
3214 KEY(5, 4, KEY_KPENTER),
3215 KEY(5, 5, KEY_Q),
3216 KEY(5, 6, KEY_W),
3217 KEY(5, 7, KEY_E),
3218
3219 KEY(6, 0, KEY_F),
3220 KEY(6, 1, KEY_G),
3221 KEY(6, 2, KEY_H),
3222 KEY(6, 3, KEY_CAPSLOCK),
3223 KEY(6, 4, KEY_PAGEUP),
3224 KEY(6, 5, KEY_A),
3225 KEY(6, 6, KEY_S),
3226 KEY(6, 7, KEY_D),
3227
3228 KEY(7, 0, KEY_V),
3229 KEY(7, 1, KEY_B),
3230 KEY(7, 2, KEY_N),
3231 KEY(7, 3, KEY_MENU),
3232 KEY(7, 4, KEY_PAGEDOWN),
3233 KEY(7, 5, KEY_Z),
3234 KEY(7, 6, KEY_X),
3235 KEY(7, 7, KEY_C),
3236
3237 KEY(8, 0, KEY_P),
3238 KEY(8, 1, KEY_J),
3239 KEY(8, 2, KEY_K),
3240 KEY(8, 3, KEY_INSERT),
3241 KEY(8, 4, KEY_LINEFEED),
3242 KEY(8, 5, KEY_U),
3243 KEY(8, 6, KEY_I),
3244 KEY(8, 7, KEY_O),
3245
3246 KEY(9, 0, KEY_4),
3247 KEY(9, 1, KEY_5),
3248 KEY(9, 2, KEY_6),
3249 KEY(9, 3, KEY_7),
3250 KEY(9, 4, KEY_8),
3251 KEY(9, 5, KEY_1),
3252 KEY(9, 6, KEY_2),
3253 KEY(9, 7, KEY_3),
3254
3255 KEY(10, 0, KEY_F7),
3256 KEY(10, 1, KEY_F8),
3257 KEY(10, 2, KEY_F9),
3258 KEY(10, 3, KEY_F10),
3259 KEY(10, 4, KEY_FN),
3260 KEY(10, 5, KEY_9),
3261 KEY(10, 6, KEY_0),
3262 KEY(10, 7, KEY_DOT),
3263
3264 KEY(11, 0, KEY_LEFTCTRL),
3265 KEY(11, 1, KEY_F11),
3266 KEY(11, 2, KEY_ENTER),
3267 KEY(11, 3, KEY_SEARCH),
3268 KEY(11, 4, KEY_DELETE),
3269 KEY(11, 5, KEY_RIGHT),
3270 KEY(11, 6, KEY_LEFT),
3271 KEY(11, 7, KEY_RIGHTSHIFT),
3272 KEY(0, 0, KEY_VOLUMEUP),
3273 KEY(0, 1, KEY_VOLUMEDOWN),
3274 KEY(0, 2, KEY_CAMERA_SNAPSHOT),
3275 KEY(0, 3, KEY_CAMERA_FOCUS),
3276};
3277
3278static struct matrix_keymap_data keymap_data_sim = {
3279 .keymap_size = ARRAY_SIZE(keymap_sim),
3280 .keymap = keymap_sim,
3281};
3282
3283static struct pm8xxx_keypad_platform_data keypad_data_sim = {
3284 .input_name = "keypad_8960",
3285 .input_phys_device = "keypad_8960/input0",
3286 .num_rows = 12,
3287 .num_cols = 8,
3288 .rows_gpio_start = PM8921_GPIO_PM_TO_SYS(9),
3289 .cols_gpio_start = PM8921_GPIO_PM_TO_SYS(1),
3290 .debounce_ms = 15,
3291 .scan_delay_ms = 32,
3292 .row_hold_ns = 91500,
3293 .wakeup = 1,
3294 .keymap_data = &keymap_data_sim,
3295};
3296
3297static struct pm8921_charger_platform_data pm8921_chg_pdata __devinitdata = {
Abhijeet Dharmapurikar34059332011-08-16 19:19:39 -07003298 .safety_time = 180,
3299 .update_time = 1,
3300 .max_voltage = 4200,
3301 .min_voltage = 3200,
3302 .resume_voltage = 4100,
3303 .term_current = 100,
3304 .cool_temp = 10,
3305 .warm_temp = 40,
3306 .temp_check_period = 1,
3307 .max_bat_chg_current = 400,
3308 .cool_bat_chg_current = 350,
3309 .warm_bat_chg_current = 350,
3310 .cool_bat_voltage = 4100,
3311 .warm_bat_voltage = 4100,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003312};
3313
3314static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
3315 .priority = 0,
3316};
3317
3318static struct pm8921_bms_platform_data pm8921_bms_pdata __devinitdata = {
3319 .r_sense = 10,
3320 .i_test = 2500,
3321 .v_failure = 3000,
3322 .calib_delay_ms = 600000,
3323 .batt_data = &palladium_1500_data,
3324};
3325
Jay Chokshide4cefb2011-08-04 18:10:44 -07003326#define PM8921_LC_LED_MAX_CURRENT 4 /* I = 4mA */
3327
3328/**
3329 * 'flag' stores three values; led id, led mode, and max current of led.
3330 * The bit packing format is as follow,
3331 * reserved (1 byte) | max_current (2 bytes) | led_mode (1 nibble) |
3332 * led_id (1 nibble)
3333 */
3334#define PM8XXX_SET_FLAG(led_id, led_mode, led_max_current) \
3335 (((led_id << PM8XXX_LED_ID_SHIFT) & PM8XXX_LED_ID_MASK) |\
3336 ((led_mode << PM8XXX_LED_MODE_SHIFT) & PM8XXX_LED_MODE_MASK) |\
3337 ((led_max_current << PM8XXX_LED_MAX_CURRENT_SHIFT) & \
3338 PM8XXX_LED_MAX_CURRENT_MASK))
3339
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003340static struct led_info pm8921_led_info[] = {
3341 [0] = {
Jay Chokshide4cefb2011-08-04 18:10:44 -07003342 .name = "led:usb",
3343 .default_trigger = "usb-online",
3344 .flags = PM8XXX_SET_FLAG(PM8XXX_ID_LED_0,
3345 PM8XXX_LED_MODE_MANUAL,
3346 PM8921_LC_LED_MAX_CURRENT),
3347 },
3348 [1] = {
3349 .name = "led:ac",
3350 .default_trigger = "ac-online",
3351 .flags = PM8XXX_SET_FLAG(PM8XXX_ID_LED_1,
3352 PM8XXX_LED_MODE_MANUAL,
3353 PM8921_LC_LED_MAX_CURRENT),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003354 },
3355};
3356
3357static struct led_platform_data pm8xxx_leds_pdata = {
3358 .num_leds = ARRAY_SIZE(pm8921_led_info),
3359 .leds = pm8921_led_info,
3360};
3361
3362static struct pm8921_platform_data pm8921_platform_data __devinitdata = {
3363 .irq_pdata = &pm8xxx_irq_pdata,
3364 .gpio_pdata = &pm8xxx_gpio_pdata,
3365 .mpp_pdata = &pm8xxx_mpp_pdata,
3366 .rtc_pdata = &pm8xxx_rtc_pdata,
3367 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
3368 .keypad_pdata = &keypad_data,
3369 .misc_pdata = &pm8xxx_misc_pdata,
3370 .regulator_pdatas = msm_pm8921_regulator_pdata,
3371 .charger_pdata = &pm8921_chg_pdata,
3372 .bms_pdata = &pm8921_bms_pdata,
3373 .adc_pdata = &pm8921_adc_pdata,
3374 .leds_pdata = &pm8xxx_leds_pdata,
3375};
3376
3377static struct msm_ssbi_platform_data msm8960_ssbi_pm8921_pdata __devinitdata = {
3378 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
3379 .slave = {
3380 .name = "pm8921-core",
3381 .platform_data = &pm8921_platform_data,
3382 },
3383};
3384
3385static void msm8960_wcnss_init(void)
3386{
3387 int i, ret, j;
3388
3389 for (i = 0; i < ARRAY_SIZE(wcnss_5wire_interface); i++) {
3390 ret = gpio_request(wcnss_5wire_interface[i].gpio,
3391 "wcnss_5_wire");
3392 if (ret) {
3393 pr_err("wcnss_5_wire gpio %d failed: %d\n",
3394 wcnss_5wire_interface[i].gpio, ret);
3395 goto fail;
3396 }
3397 }
3398
3399 pr_info("%s: Iris 5-wire gpios configured\n", __func__);
3400
3401 return;
3402
3403fail:
3404 for (j = 0; j < i; j++)
3405 gpio_free(wcnss_5wire_interface[j].gpio);
3406}
3407
Stepan Moskovchenko41d168272011-08-09 17:09:42 -07003408#ifdef CONFIG_KS8851
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003409static int ethernet_init(void)
3410{
3411 int ret;
3412 ret = gpio_request(KS8851_IRQ_GPIO, "ks8851_irq");
3413 if (ret) {
3414 pr_err("ks8851 gpio_request failed: %d\n", ret);
3415 goto fail;
3416 }
3417
3418 ret = gpio_request(KS8851_RST_GPIO, "ks8851_rst");
3419 if (ret) {
3420 pr_err("ks8851 gpio_request failed: %d\n", ret);
3421 goto fail_rst;
3422 }
3423
3424 ret = gpio_request(FPGA_CS_GPIO, "fpga_cs");
3425 if (ret) {
3426 pr_err("ks8851 gpio_request failed: %d\n", ret);
3427 goto fail_cs;
3428 }
3429
3430 gpio_direction_output(FPGA_CS_GPIO, 1);
3431 gpio_direction_output(KS8851_RST_GPIO, 1);
3432 return 0;
3433fail_cs:
3434 gpio_free(KS8851_RST_GPIO);
3435fail_rst:
3436 gpio_free(KS8851_IRQ_GPIO);
3437fail:
3438 return ret;
3439}
Stepan Moskovchenko41d168272011-08-09 17:09:42 -07003440#else
3441static int ethernet_init(void)
3442{
3443 return 0;
3444}
3445#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003446
3447static struct msm_cpuidle_state msm_cstates[] __initdata = {
3448 {0, 0, "C0", "WFI",
3449 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
3450
3451 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
3452 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
3453
3454 {0, 2, "C2", "POWER_COLLAPSE",
3455 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
3456
3457 {1, 0, "C0", "WFI",
3458 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
3459
3460 {1, 1, "C1", "STANDALONE_POWER_COLLAPSE",
3461 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
3462};
3463
3464static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
3465 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
3466 .idle_supported = 1,
3467 .suspend_supported = 1,
3468 .idle_enabled = 0,
3469 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003470 },
3471
3472 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
3473 .idle_supported = 1,
3474 .suspend_supported = 1,
3475 .idle_enabled = 0,
3476 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003477 },
3478
3479 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
3480 .idle_supported = 1,
3481 .suspend_supported = 1,
3482 .idle_enabled = 1,
3483 .suspend_enabled = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003484 },
3485
3486 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
3487 .idle_supported = 0,
3488 .suspend_supported = 1,
3489 .idle_enabled = 0,
3490 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003491 },
3492
3493 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
3494 .idle_supported = 1,
3495 .suspend_supported = 1,
3496 .idle_enabled = 0,
3497 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003498 },
3499
3500 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
3501 .idle_supported = 1,
3502 .suspend_supported = 0,
3503 .idle_enabled = 1,
3504 .suspend_enabled = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003505 },
3506};
3507
3508static struct msm_rpmrs_level msm_rpmrs_levels[] __initdata = {
3509 {
3510 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
3511 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3512 true,
3513 1, 8000, 100000, 1,
3514 },
3515
3516 {
3517 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
3518 MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
3519 true,
3520 1500, 5000, 60100000, 3000,
3521 },
3522
3523 {
3524 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3525 MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
3526 false,
3527 1800, 5000, 60350000, 3500,
3528 },
3529
3530 {
3531 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3532 MSM_RPMRS_LIMITS(ON, HSFS_OPEN, MAX, ACTIVE),
3533 false,
3534 2800, 2500, 65350000, 4800,
3535 },
3536
3537 {
3538 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3539 MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
3540 false,
3541 3800, 4500, 67850000, 5500,
3542 },
3543
3544 {
3545 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3546 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
3547 false,
3548 4800, 2000, 71850000, 6800,
3549 },
3550
3551 {
3552 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3553 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
3554 false,
3555 6800, 500, 75850000, 8800,
3556 },
3557
3558 {
3559 MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
3560 MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
3561 false,
3562 7800, 0, 76350000, 9800,
3563 },
3564};
3565
3566#ifdef CONFIG_I2C
3567#define I2C_SURF 1
3568#define I2C_FFA (1 << 1)
3569#define I2C_RUMI (1 << 2)
3570#define I2C_SIM (1 << 3)
3571#define I2C_FLUID (1 << 4)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003572
3573struct i2c_registry {
3574 u8 machs;
3575 int bus;
3576 struct i2c_board_info *info;
3577 int len;
3578};
3579
3580#ifdef CONFIG_MSM_CAMERA
3581static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
3582#ifdef CONFIG_IMX074
3583 {
3584 I2C_BOARD_INFO("imx074", 0x1A),
3585 },
3586#endif
3587#ifdef CONFIG_OV2720
3588 {
3589 I2C_BOARD_INFO("ov2720", 0x6C),
3590 },
3591#endif
Kevin Chandfecce22011-07-13 10:52:41 -07003592 {
3593 I2C_BOARD_INFO("qs_mt9p017", 0x6C >> 1),
3594 },
Nishant Pandit474f2252011-07-23 23:17:56 +05303595#ifdef CONFIG_MSM_CAMERA_FLASH_SC628A
3596 {
3597 I2C_BOARD_INFO("sc628a", 0x6E),
3598 },
3599#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003600};
3601#endif
3602
3603/* Sensors DSPS platform data */
3604#ifdef CONFIG_MSM_DSPS
3605#define DSPS_PIL_GENERIC_NAME "dsps"
3606#endif /* CONFIG_MSM_DSPS */
3607
3608static void __init msm8960_init_dsps(void)
3609{
3610#ifdef CONFIG_MSM_DSPS
3611 struct msm_dsps_platform_data *pdata =
3612 msm_dsps_device.dev.platform_data;
3613 pdata->pil_name = DSPS_PIL_GENERIC_NAME;
3614 pdata->gpios = NULL;
3615 pdata->gpios_num = 0;
3616
3617 platform_device_register(&msm_dsps_device);
3618#endif /* CONFIG_MSM_DSPS */
3619}
3620
3621static struct i2c_registry msm8960_i2c_devices[] __initdata = {
3622#ifdef CONFIG_MSM_CAMERA
3623 {
3624 I2C_SURF | I2C_FFA | I2C_FLUID | I2C_RUMI,
3625 MSM_8960_GSBI4_QUP_I2C_BUS_ID,
3626 msm_camera_boardinfo,
3627 ARRAY_SIZE(msm_camera_boardinfo),
3628 },
3629#endif
3630 {
3631 I2C_SURF | I2C_FFA | I2C_FLUID,
3632 MSM_8960_GSBI3_QUP_I2C_BUS_ID,
3633 cyttsp_info,
3634 ARRAY_SIZE(cyttsp_info),
Rohit Vaswanicd2a59b2011-07-19 12:00:48 -07003635 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003636};
3637#endif /* CONFIG_I2C */
3638
3639static void __init register_i2c_devices(void)
3640{
3641#ifdef CONFIG_I2C
3642 u8 mach_mask = 0;
3643 int i;
3644
3645 /* Build the matching 'supported_machs' bitmask */
3646 if (machine_is_msm8960_cdp())
3647 mach_mask = I2C_SURF;
3648 else if (machine_is_msm8960_rumi3())
3649 mach_mask = I2C_RUMI;
3650 else if (machine_is_msm8960_sim())
3651 mach_mask = I2C_SIM;
Amy Maloche2d028032011-07-20 14:08:06 -07003652 else if (machine_is_msm8960_fluid())
3653 mach_mask = I2C_FLUID;
Amy Maloche1b0663f2011-08-02 16:46:22 -07003654 else if (machine_is_msm8960_mtp())
3655 mach_mask = I2C_FFA;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003656 else
3657 pr_err("unmatched machine ID in register_i2c_devices\n");
3658
3659 /* Run the array and install devices as appropriate */
3660 for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
3661 if (msm8960_i2c_devices[i].machs & mach_mask)
3662 i2c_register_board_info(msm8960_i2c_devices[i].bus,
3663 msm8960_i2c_devices[i].info,
3664 msm8960_i2c_devices[i].len);
3665 }
3666#endif
3667}
3668
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003669static void __init msm8960_sim_init(void)
3670{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003671 if (socinfo_init() < 0)
3672 pr_err("socinfo_init() failed!\n");
3673
3674 BUG_ON(msm_rpm_init(&msm_rpm_data));
3675 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
3676 ARRAY_SIZE(msm_rpmrs_levels)));
3677 regulator_suppress_info_printing();
David Collins26f05562011-06-20 09:56:28 -07003678 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003679 msm_clock_init(&msm8960_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003680 msm8960_device_ssbi_pm8921.dev.platform_data =
3681 &msm8960_ssbi_pm8921_pdata;
3682 pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003683
3684 /* Simulator supports a QWERTY keypad */
3685 pm8921_platform_data.keypad_pdata = &keypad_data_sim;
3686
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003687 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
3688 msm8960_device_gadget_peripheral.dev.parent = &msm8960_device_otg.dev;
3689 msm_device_hsusb_host.dev.parent = &msm8960_device_otg.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003690 gpiomux_init();
3691 ethernet_init();
3692 msm8960_i2c_init();
3693 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3694 msm_spm_l2_init(msm_spm_l2_data);
3695 msm8960_init_buses();
3696 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
3697 pm8921_gpio_mpp_init();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003698 platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices));
Matt Wagantallec57f062011-08-16 23:54:46 -07003699 acpuclk_init(&acpuclk_8960_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003700
3701 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3702 &msm8960_qup_spi_gsbi1_pdata;
3703 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
3704
3705 msm8960_init_mmc();
3706 msm_fb_add_devices();
3707 slim_register_board_info(msm_slim_devices,
3708 ARRAY_SIZE(msm_slim_devices));
3709 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
3710 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
3711 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
3712 msm_pm_data);
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003713}
3714
3715static void __init msm8960_rumi3_init(void)
3716{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003717 if (socinfo_init() < 0)
3718 pr_err("socinfo_init() failed!\n");
3719
3720 BUG_ON(msm_rpm_init(&msm_rpm_data));
3721 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
3722 ARRAY_SIZE(msm_rpmrs_levels)));
3723 regulator_suppress_info_printing();
David Collins26f05562011-06-20 09:56:28 -07003724 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003725 msm_clock_init(&msm8960_dummy_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003726 gpiomux_init();
3727 ethernet_init();
3728 msm8960_device_ssbi_pm8921.dev.platform_data =
3729 &msm8960_ssbi_pm8921_pdata;
3730 pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len;
3731 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3732 &msm8960_qup_spi_gsbi1_pdata;
3733 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
3734 msm8960_i2c_init();
3735 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3736 msm_spm_l2_init(msm_spm_l2_data);
3737 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
3738 pm8921_gpio_mpp_init();
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003739 platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003740 msm8960_init_mmc();
3741
3742 register_i2c_devices();
3743 msm_fb_add_devices();
3744 slim_register_board_info(msm_slim_devices,
3745 ARRAY_SIZE(msm_slim_devices));
3746 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
3747 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
3748 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
3749 msm_pm_data);
3750}
3751
3752static void __init msm8960_cdp_init(void)
3753{
3754 if (socinfo_init() < 0)
3755 pr_err("socinfo_init() failed!\n");
3756
3757 BUG_ON(msm_rpm_init(&msm_rpm_data));
3758 BUG_ON(msm_rpmrs_levels_init(msm_rpmrs_levels,
3759 ARRAY_SIZE(msm_rpmrs_levels)));
3760 regulator_suppress_info_printing();
3761 if (msm_xo_init())
3762 pr_err("Failed to initialize XO votes\n");
David Collins26f05562011-06-20 09:56:28 -07003763 platform_device_register(&msm8960_device_rpm_regulator);
Stephen Boydbb600ae2011-08-02 20:11:40 -07003764 msm_clock_init(&msm8960_clock_init_data);
Stepan Moskovchenko14aa6492011-08-08 15:15:01 -07003765 msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
3766 msm8960_device_gadget_peripheral.dev.parent = &msm8960_device_otg.dev;
3767 msm_device_hsusb_host.dev.parent = &msm8960_device_otg.dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003768 gpiomux_init();
3769 ethernet_init();
3770 msm8960_device_qup_spi_gsbi1.dev.platform_data =
3771 &msm8960_qup_spi_gsbi1_pdata;
3772 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
3773 msm8960_device_ssbi_pm8921.dev.platform_data =
3774 &msm8960_ssbi_pm8921_pdata;
3775 pm8921_platform_data.num_regulators = msm_pm8921_regulator_pdata_len;
3776 msm8960_i2c_init();
Lucille Sylvester34ec3692011-08-16 16:28:04 -06003777 msm8960_gfx_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003778 msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
3779 msm_spm_l2_init(msm_spm_l2_data);
3780 msm8960_init_buses();
3781 platform_add_devices(msm_footswitch_devices,
3782 msm_num_footswitch_devices);
David Collinsb10be1d2011-09-02 10:29:31 -07003783 if (machine_is_msm8960_liquid())
3784 platform_device_register(&msm8960_device_ext_3p3v_vreg);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003785 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
3786 pm8921_gpio_mpp_init();
3787 platform_add_devices(cdp_devices, ARRAY_SIZE(cdp_devices));
3788 msm8960_init_cam();
3789 msm8960_init_mmc();
Matt Wagantallec57f062011-08-16 23:54:46 -07003790 acpuclk_init(&acpuclk_8960_soc_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003791 register_i2c_devices();
3792 msm8960_wcnss_init();
3793 msm_fb_add_devices();
3794 slim_register_board_info(msm_slim_devices,
3795 ARRAY_SIZE(msm_slim_devices));
3796 msm8960_init_dsps();
3797 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
3798 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
3799 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
3800 msm_pm_data);
Larry Bassela7eadea2011-07-14 10:46:00 -07003801 change_memory_power = &msm8960_change_memory_power;
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003802}
3803
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003804MACHINE_START(MSM8960_SIM, "QCT MSM8960 SIMULATOR")
3805 .map_io = msm8960_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003806 .reserve = msm8960_reserve,
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003807 .init_irq = msm8960_init_irq,
3808 .timer = &msm_timer,
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003809 .init_machine = msm8960_sim_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003810 .init_early = msm8960_allocate_memory_regions,
Stepan Moskovchenkof441ca22010-12-01 19:31:16 -08003811MACHINE_END
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003812
3813MACHINE_START(MSM8960_RUMI3, "QCT MSM8960 RUMI3")
3814 .map_io = msm8960_map_io,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003815 .reserve = msm8960_reserve,
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003816 .init_irq = msm8960_init_irq,
3817 .timer = &msm_timer,
Stepan Moskovchenkod056fca2011-01-27 12:12:07 -08003818 .init_machine = msm8960_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003819 .init_early = msm8960_allocate_memory_regions,
Stepan Moskovchenko50ede4e2010-12-13 18:12:19 -08003820MACHINE_END
3821
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003822MACHINE_START(MSM8960_CDP, "QCT MSM8960 CDP")
3823 .map_io = msm8960_map_io,
3824 .reserve = msm8960_reserve,
3825 .init_irq = msm8960_init_irq,
3826 .timer = &msm_timer,
3827 .init_machine = msm8960_cdp_init,
3828 .init_early = msm8960_allocate_memory_regions,
3829MACHINE_END
3830
3831MACHINE_START(MSM8960_MTP, "QCT MSM8960 MTP")
3832 .map_io = msm8960_map_io,
3833 .reserve = msm8960_reserve,
3834 .init_irq = msm8960_init_irq,
3835 .timer = &msm_timer,
3836 .init_machine = msm8960_cdp_init,
3837 .init_early = msm8960_allocate_memory_regions,
3838MACHINE_END
3839
3840MACHINE_START(MSM8960_FLUID, "QCT MSM8960 FLUID")
3841 .map_io = msm8960_map_io,
3842 .reserve = msm8960_reserve,
3843 .init_irq = msm8960_init_irq,
3844 .timer = &msm_timer,
3845 .init_machine = msm8960_cdp_init,
3846 .init_early = msm8960_allocate_memory_regions,
3847MACHINE_END
Amir Samuelov0d1f8ae2011-07-28 11:13:58 +03003848
3849MACHINE_START(MSM8960_LIQUID, "QCT MSM8960 LIQUID")
3850 .map_io = msm8960_map_io,
3851 .reserve = msm8960_reserve,
3852 .init_irq = msm8960_init_irq,
3853 .timer = &msm_timer,
3854 .init_machine = msm8960_cdp_init,
3855 .init_early = msm8960_allocate_memory_regions,
3856MACHINE_END