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