blob: 146c8a8f4a97907285aae827647349e648f5bf06 [file] [log] [blame]
Manu Gautam5143b252012-01-05 19:25:23 -08001/* Copyright (c) 2008-2012, Code Aurora Forum. All rights reserved.
Daniel Walkera32d2fe2010-02-25 11:38:39 -08002 *
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 *
Daniel Walkera32d2fe2010-02-25 11:38:39 -080012 */
13
14#include <linux/kernel.h>
15#include <linux/irq.h>
16#include <linux/gpio.h>
17#include <linux/platform_device.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018#include <linux/android_pmem.h>
19#include <linux/bootmem.h>
20#include <linux/i2c.h>
21#include <linux/spi/spi.h>
Daniel Walkera32d2fe2010-02-25 11:38:39 -080022#include <linux/delay.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070023#include <linux/bma150.h>
24#include <linux/power_supply.h>
25#include <linux/clk.h>
Daniel Walkera32d2fe2010-02-25 11:38:39 -080026
27#include <asm/mach-types.h>
28#include <asm/mach/arch.h>
29#include <asm/io.h>
30#include <asm/setup.h>
31
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070032#include <asm/mach/mmc.h>
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +053033#include <mach/vreg.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070034#include <mach/mpp.h>
35#include <mach/board.h>
36#include <mach/sirc.h>
37#include <mach/dma.h>
38#include <mach/rpc_hsusb.h>
39#include <mach/rpc_pmapp.h>
40#include <mach/msm_hsusb.h>
41#include <mach/msm_serial_hs.h>
42#include <mach/msm_touchpad.h>
43#include <mach/msm_i2ckbd.h>
44#include <mach/pmic.h>
45#include <mach/camera.h>
46#include <mach/memory.h>
47#include <mach/msm_spi.h>
48#include <mach/msm_tsif.h>
49#include <mach/msm_battery.h>
50#include <mach/rpc_server_handset.h>
51#include <mach/socinfo.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070052#include <mach/proc_comm.h>
Daniel Walkera32d2fe2010-02-25 11:38:39 -080053
54#include "devices.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070055#include "timer.h"
56#include "msm-keypad-devices.h"
Matt Wagantall6d9ebee2011-08-26 12:15:24 -070057#include "acpuclock.h"
Matt Wagantall33d01f52012-02-23 23:27:44 -080058#include "clock.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080059#include "pm.h"
Murali Nalajala2a0bbda2012-03-28 12:12:54 +053060#include "irq.h"
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -060061#include "pm-boot.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070062#ifdef CONFIG_USB_ANDROID
63#include <linux/usb/android_composite.h>
64#endif
Daniel Walkera32d2fe2010-02-25 11:38:39 -080065
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070066#define TOUCHPAD_SUSPEND 34
67#define TOUCHPAD_IRQ 38
Daniel Walkera32d2fe2010-02-25 11:38:39 -080068
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070069#define MSM_PMEM_SF_SIZE 0x1700000
Gregory Bean5d73c532010-09-29 13:46:45 -070070
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070071#define SMEM_SPINLOCK_I2C "S:6"
72
73#define MSM_PMEM_ADSP_SIZE 0x2A05000
74#define MSM_FB_SIZE 0x2EE000
75#define MSM_AUDIO_SIZE 0x80000
76
77#ifdef CONFIG_MSM_SOC_REV_A
78#define MSM_SMI_BASE 0xE0000000
79#else
80#define MSM_SMI_BASE 0x00000000
81#endif
82
83#define MSM_SHARED_RAM_PHYS (MSM_SMI_BASE + 0x00100000)
84
85#define MSM_PMEM_SMI_BASE (MSM_SMI_BASE + 0x02B00000)
86#define MSM_PMEM_SMI_SIZE 0x01500000
87
88#define MSM_FB_BASE MSM_PMEM_SMI_BASE
89#define MSM_PMEM_SMIPOOL_BASE (MSM_FB_BASE + MSM_FB_SIZE)
90#define MSM_PMEM_SMIPOOL_SIZE (MSM_PMEM_SMI_SIZE - MSM_FB_SIZE)
91
92#define PMEM_KERNEL_EBI1_SIZE 0x28000
93
94#define PMIC_VREG_WLAN_LEVEL 2600
95#define PMIC_VREG_GP6_LEVEL 2900
96
97#define FPGA_SDCC_STATUS 0x70000280
98
Stephen Boyd7c63ded2010-12-20 15:00:17 -080099static struct resource smc91x_resources[] = {
Gregory Bean5d73c532010-09-29 13:46:45 -0700100 [0] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700101 .flags = IORESOURCE_MEM,
Gregory Bean5d73c532010-09-29 13:46:45 -0700102 },
103 [1] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700104 .flags = IORESOURCE_IRQ,
Gregory Bean5d73c532010-09-29 13:46:45 -0700105 },
106};
107
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700108#ifdef CONFIG_USB_FUNCTION
109static struct usb_mass_storage_platform_data usb_mass_storage_pdata = {
110 .nluns = 0x02,
111 .buf_size = 16384,
112 .vendor = "GOOGLE",
113 .product = "Mass storage",
114 .release = 0xffff,
115};
116
117static struct platform_device mass_storage_device = {
118 .name = "usb_mass_storage",
119 .id = -1,
120 .dev = {
121 .platform_data = &usb_mass_storage_pdata,
122 },
123};
124#endif
125
126#ifdef CONFIG_USB_ANDROID
127static char *usb_functions_default[] = {
128 "diag",
129 "modem",
130 "nmea",
131 "rmnet",
132 "usb_mass_storage",
133};
134
135static char *usb_functions_default_adb[] = {
136 "diag",
137 "adb",
138 "modem",
139 "nmea",
140 "rmnet",
141 "usb_mass_storage",
142};
143
144static char *usb_functions_rndis[] = {
145 "rndis",
146};
147
148static char *usb_functions_rndis_adb[] = {
149 "rndis",
150 "adb",
151};
152
153static char *usb_functions_all[] = {
154#ifdef CONFIG_USB_ANDROID_RNDIS
155 "rndis",
156#endif
157#ifdef CONFIG_USB_ANDROID_DIAG
158 "diag",
159#endif
160 "adb",
161#ifdef CONFIG_USB_F_SERIAL
162 "modem",
163 "nmea",
164#endif
165#ifdef CONFIG_USB_ANDROID_RMNET
166 "rmnet",
167#endif
168 "usb_mass_storage",
169#ifdef CONFIG_USB_ANDROID_ACM
170 "acm",
171#endif
172};
173
174static struct android_usb_product usb_products[] = {
175 {
176 .product_id = 0x9026,
177 .num_functions = ARRAY_SIZE(usb_functions_default),
178 .functions = usb_functions_default,
179 },
180 {
181 .product_id = 0x9025,
182 .num_functions = ARRAY_SIZE(usb_functions_default_adb),
183 .functions = usb_functions_default_adb,
184 },
185 {
186 .product_id = 0xf00e,
187 .num_functions = ARRAY_SIZE(usb_functions_rndis),
188 .functions = usb_functions_rndis,
189 },
190 {
191 .product_id = 0x9024,
192 .num_functions = ARRAY_SIZE(usb_functions_rndis_adb),
193 .functions = usb_functions_rndis_adb,
194 },
195};
196
197static struct usb_mass_storage_platform_data mass_storage_pdata = {
198 .nluns = 1,
199 .vendor = "Qualcomm Incorporated",
200 .product = "Mass storage",
201 .release = 0x0100,
202};
203
204static struct platform_device usb_mass_storage_device = {
205 .name = "usb_mass_storage",
206 .id = -1,
207 .dev = {
208 .platform_data = &mass_storage_pdata,
209 },
210};
211
212static struct usb_ether_platform_data rndis_pdata = {
213 /* ethaddr is filled by board_serialno_setup */
214 .vendorID = 0x05C6,
215 .vendorDescr = "Qualcomm Incorporated",
216};
217
218static struct platform_device rndis_device = {
219 .name = "rndis",
220 .id = -1,
221 .dev = {
222 .platform_data = &rndis_pdata,
223 },
224};
225
226static struct android_usb_platform_data android_usb_pdata = {
227 .vendor_id = 0x05C6,
228 .product_id = 0x9026,
229 .version = 0x0100,
230 .product_name = "Qualcomm HSUSB Device",
231 .manufacturer_name = "Qualcomm Incorporated",
232 .num_products = ARRAY_SIZE(usb_products),
233 .products = usb_products,
234 .num_functions = ARRAY_SIZE(usb_functions_all),
235 .functions = usb_functions_all,
236 .serial_number = "1234567890ABCDEF",
237};
238
239static struct platform_device android_usb_device = {
240 .name = "android_usb",
241 .id = -1,
242 .dev = {
243 .platform_data = &android_usb_pdata,
244 },
245};
246
247static int __init board_serialno_setup(char *serialno)
248{
249 int i;
250 char *src = serialno;
251
252 /* create a fake MAC address from our serial number.
253 * first byte is 0x02 to signify locally administered.
254 */
255 rndis_pdata.ethaddr[0] = 0x02;
256 for (i = 0; *src; i++) {
257 /* XOR the USB serial across the remaining bytes */
258 rndis_pdata.ethaddr[i % (ETH_ALEN - 1) + 1] ^= *src++;
259 }
260
261 android_usb_pdata.serial_number = serialno;
262 return 1;
263}
264__setup("androidboot.serialno=", board_serialno_setup);
265#endif
266
Stephen Boyd7c63ded2010-12-20 15:00:17 -0800267static struct platform_device smc91x_device = {
Gregory Bean5d73c532010-09-29 13:46:45 -0700268 .name = "smc91x",
269 .id = 0,
270 .num_resources = ARRAY_SIZE(smc91x_resources),
271 .resource = smc91x_resources,
272};
273
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700274#ifdef CONFIG_USB_FUNCTION
275static struct usb_function_map usb_functions_map[] = {
276 {"diag", 0},
277 {"adb", 1},
278 {"modem", 2},
279 {"nmea", 3},
280 {"mass_storage", 4},
281 {"ethernet", 5},
282};
283
284/* dynamic composition */
285static struct usb_composition usb_func_composition[] = {
286 {
287 .product_id = 0x9012,
288 .functions = 0x5, /* 0101 */
289 },
290
291 {
292 .product_id = 0x9013,
293 .functions = 0x15, /* 10101 */
294 },
295
296 {
297 .product_id = 0x9014,
298 .functions = 0x30, /* 110000 */
299 },
300
301 {
302 .product_id = 0x9015,
303 .functions = 0x12, /* 10010 */
304 },
305
306 {
307 .product_id = 0x9016,
308 .functions = 0xD, /* 01101 */
309 },
310
311 {
312 .product_id = 0x9017,
313 .functions = 0x1D, /* 11101 */
314 },
315
316 {
317 .product_id = 0xF000,
318 .functions = 0x10, /* 10000 */
319 },
320
321 {
322 .product_id = 0xF009,
323 .functions = 0x20, /* 100000 */
324 },
325
326 {
327 .product_id = 0x9018,
328 .functions = 0x1F, /* 011111 */
329 },
330
331 {
332 .product_id = 0x901A,
333 .functions = 0x0F, /* 01111 */
334 },
335};
336#endif
337
338static struct msm_handset_platform_data hs_platform_data = {
339 .hs_name = "8k_handset",
340 .pwr_key_delay_ms = 500, /* 0 will disable end key */
341};
342
343static struct platform_device hs_device = {
344 .name = "msm-handset",
345 .id = -1,
346 .dev = {
347 .platform_data = &hs_platform_data,
348 },
349};
350
351#ifdef CONFIG_USB_FS_HOST
352static struct msm_gpio fsusb_config[] = {
353 { GPIO_CFG(139, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "fs_dat" },
354 { GPIO_CFG(140, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "fs_se0" },
355 { GPIO_CFG(141, 3, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "fs_oe_n" },
356};
357
358static int fsusb_gpio_init(void)
Gregory Bean5d73c532010-09-29 13:46:45 -0700359{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700360 return msm_gpios_request(fsusb_config, ARRAY_SIZE(fsusb_config));
361}
362
363static void msm_fsusb_setup_gpio(unsigned int enable)
364{
365 if (enable)
366 msm_gpios_enable(fsusb_config, ARRAY_SIZE(fsusb_config));
367 else
368 msm_gpios_disable(fsusb_config, ARRAY_SIZE(fsusb_config));
369
370}
371#endif
372
373#define MSM_USB_BASE ((unsigned)addr)
374
375static struct msm_hsusb_platform_data msm_hsusb_pdata = {
376#ifdef CONFIG_USB_FUNCTION
377 .version = 0x0100,
378 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_180NM),
379 .vendor_id = 0x5c6,
380 .product_name = "Qualcomm HSUSB Device",
381 .serial_number = "1234567890ABCDEF",
382 .manufacturer_name = "Qualcomm Incorporated",
383 .compositions = usb_func_composition,
384 .num_compositions = ARRAY_SIZE(usb_func_composition),
385 .function_map = usb_functions_map,
386 .num_functions = ARRAY_SIZE(usb_functions_map),
387 .config_gpio = NULL,
388
389#endif
390};
391
392static struct vreg *vreg_usb;
393static void msm_hsusb_vbus_power(unsigned phy_info, int on)
394{
395
396 switch (PHY_TYPE(phy_info)) {
397 case USB_PHY_INTEGRATED:
398 if (on)
399 msm_hsusb_vbus_powerup();
400 else
401 msm_hsusb_vbus_shutdown();
402 break;
403 case USB_PHY_SERIAL_PMIC:
404 if (on)
405 vreg_enable(vreg_usb);
406 else
407 vreg_disable(vreg_usb);
408 break;
409 default:
410 pr_err("%s: undefined phy type ( %X ) \n", __func__,
411 phy_info);
412 }
413
414}
415
416static struct msm_usb_host_platform_data msm_usb_host_pdata = {
417 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_180NM),
418};
419
420#ifdef CONFIG_USB_FS_HOST
421static struct msm_usb_host_platform_data msm_usb_host2_pdata = {
422 .phy_info = USB_PHY_SERIAL_PMIC,
423 .config_gpio = msm_fsusb_setup_gpio,
424 .vbus_power = msm_hsusb_vbus_power,
425};
426#endif
427
428static struct android_pmem_platform_data android_pmem_kernel_ebi1_pdata = {
429 .name = PMEM_KERNEL_EBI1_DATA_NAME,
430 /* if no allocator_type, defaults to PMEM_ALLOCATORTYPE_BITMAP,
431 * the only valid choice at this time. The board structure is
432 * set to all zeros by the C runtime initialization and that is now
433 * the enum value of PMEM_ALLOCATORTYPE_BITMAP, now forced to 0 in
434 * include/linux/android_pmem.h.
435 */
436 .cached = 0,
437};
438
439#ifdef CONFIG_KERNEL_PMEM_SMI_REGION
440
441static struct android_pmem_platform_data android_pmem_kernel_smi_pdata = {
442 .name = PMEM_KERNEL_SMI_DATA_NAME,
443 /* if no allocator_type, defaults to PMEM_ALLOCATORTYPE_BITMAP,
444 * the only valid choice at this time. The board structure is
445 * set to all zeros by the C runtime initialization and that is now
446 * the enum value of PMEM_ALLOCATORTYPE_BITMAP, now forced to 0 in
447 * include/linux/android_pmem.h.
448 */
449 .cached = 0,
450};
451
452#endif
453
454static struct android_pmem_platform_data android_pmem_pdata = {
455 .name = "pmem",
456 .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING,
457 .cached = 1,
458};
459
460static struct android_pmem_platform_data android_pmem_adsp_pdata = {
461 .name = "pmem_adsp",
462 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
463 .cached = 0,
464};
465
466static struct android_pmem_platform_data android_pmem_smipool_pdata = {
467 .name = "pmem_smipool",
468 .size = MSM_PMEM_SMIPOOL_SIZE,
469 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
470 .cached = 0,
471};
472
473
474static struct platform_device android_pmem_device = {
475 .name = "android_pmem",
476 .id = 0,
477 .dev = { .platform_data = &android_pmem_pdata },
478};
479
480static struct platform_device android_pmem_adsp_device = {
481 .name = "android_pmem",
482 .id = 1,
483 .dev = { .platform_data = &android_pmem_adsp_pdata },
484};
485
486static struct platform_device android_pmem_smipool_device = {
487 .name = "android_pmem",
488 .id = 2,
489 .dev = { .platform_data = &android_pmem_smipool_pdata },
490};
491
492
493static struct platform_device android_pmem_kernel_ebi1_device = {
494 .name = "android_pmem",
495 .id = 3,
496 .dev = { .platform_data = &android_pmem_kernel_ebi1_pdata },
497};
498
499#ifdef CONFIG_KERNEL_PMEM_SMI_REGION
500static struct platform_device android_pmem_kernel_smi_device = {
501 .name = "android_pmem",
502 .id = 4,
503 .dev = { .platform_data = &android_pmem_kernel_smi_pdata },
504};
505#endif
506
507static struct resource msm_fb_resources[] = {
508 {
509 .flags = IORESOURCE_DMA,
510 }
511};
512
513static int msm_fb_detect_panel(const char *name)
514{
515 int ret = -EPERM;
516
517 if (machine_is_qsd8x50_ffa()) {
518 if (!strncmp(name, "mddi_toshiba_wvga_pt", 20))
519 ret = 0;
520 else
521 ret = -ENODEV;
522 } else if ((machine_is_qsd8x50_surf())
523 && !strcmp(name, "lcdc_external"))
524 ret = 0;
525
526 return ret;
527}
528
529static struct msm_fb_platform_data msm_fb_pdata = {
530 .detect_client = msm_fb_detect_panel,
531};
532
533static struct platform_device msm_fb_device = {
534 .name = "msm_fb",
535 .id = 0,
536 .num_resources = ARRAY_SIZE(msm_fb_resources),
537 .resource = msm_fb_resources,
538 .dev = {
539 .platform_data = &msm_fb_pdata,
540 }
541};
542
543static struct msm_gpio bma_spi_gpio_config_data[] = {
544 { GPIO_CFG(22, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "bma_irq" },
545};
546
547static int msm_bma_gpio_setup(struct device *dev)
548{
549 int rc;
550
551 rc = msm_gpios_request_enable(bma_spi_gpio_config_data,
552 ARRAY_SIZE(bma_spi_gpio_config_data));
553
554 return rc;
555}
556
557static void msm_bma_gpio_teardown(struct device *dev)
558{
559 msm_gpios_disable_free(bma_spi_gpio_config_data,
560 ARRAY_SIZE(bma_spi_gpio_config_data));
561}
562
563static struct bma150_platform_data bma_pdata = {
564 .setup = msm_bma_gpio_setup,
565 .teardown = msm_bma_gpio_teardown,
566};
567
568static struct resource qsd_spi_resources[] = {
569 {
570 .name = "spi_irq_in",
571 .start = INT_SPI_INPUT,
572 .end = INT_SPI_INPUT,
573 .flags = IORESOURCE_IRQ,
574 },
575 {
576 .name = "spi_irq_out",
577 .start = INT_SPI_OUTPUT,
578 .end = INT_SPI_OUTPUT,
579 .flags = IORESOURCE_IRQ,
580 },
581 {
582 .name = "spi_irq_err",
583 .start = INT_SPI_ERROR,
584 .end = INT_SPI_ERROR,
585 .flags = IORESOURCE_IRQ,
586 },
587 {
588 .name = "spi_base",
589 .start = 0xA1200000,
590 .end = 0xA1200000 + SZ_4K - 1,
591 .flags = IORESOURCE_MEM,
592 },
593 {
594 .name = "spidm_channels",
595 .flags = IORESOURCE_DMA,
596 },
597 {
598 .name = "spidm_crci",
599 .flags = IORESOURCE_DMA,
600 },
601};
602
603static struct platform_device qsd_device_spi = {
604 .name = "spi_qsd",
605 .id = 0,
606 .num_resources = ARRAY_SIZE(qsd_spi_resources),
607 .resource = qsd_spi_resources,
608};
609
610static struct spi_board_info msm_spi_board_info[] __initdata = {
611 {
612 .modalias = "bma150",
613 .mode = SPI_MODE_3,
614 .irq = MSM_GPIO_TO_INT(22),
615 .bus_num = 0,
616 .chip_select = 0,
617 .max_speed_hz = 10000000,
618 .platform_data = &bma_pdata,
619 },
620};
621
622#define CT_CSR_PHYS 0xA8700000
623#define TCSR_SPI_MUX (ct_csr_base + 0x54)
624static int msm_qsd_spi_dma_config(void)
625{
626 void __iomem *ct_csr_base = 0;
627 u32 spi_mux;
628 int ret = 0;
629
630 ct_csr_base = ioremap(CT_CSR_PHYS, PAGE_SIZE);
631 if (!ct_csr_base) {
632 pr_err("%s: Could not remap %x\n", __func__, CT_CSR_PHYS);
633 return -1;
634 }
635
636 spi_mux = readl(TCSR_SPI_MUX);
637 switch (spi_mux) {
638 case (1):
639 qsd_spi_resources[4].start = DMOV_HSUART1_RX_CHAN;
640 qsd_spi_resources[4].end = DMOV_HSUART1_TX_CHAN;
641 qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
642 qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
643 break;
644 case (2):
645 qsd_spi_resources[4].start = DMOV_HSUART2_RX_CHAN;
646 qsd_spi_resources[4].end = DMOV_HSUART2_TX_CHAN;
647 qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
648 qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
649 break;
650 case (3):
651 qsd_spi_resources[4].start = DMOV_CE_OUT_CHAN;
652 qsd_spi_resources[4].end = DMOV_CE_IN_CHAN;
653 qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
654 qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
655 break;
656 default:
657 ret = -1;
658 }
659
660 iounmap(ct_csr_base);
661 return ret;
662}
663
664static struct msm_gpio qsd_spi_gpio_config_data[] = {
665 { GPIO_CFG(17, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
666 { GPIO_CFG(18, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
667 { GPIO_CFG(19, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
668 { GPIO_CFG(20, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
669 { GPIO_CFG(21, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "spi_pwr" },
670};
671
672static int msm_qsd_spi_gpio_config(void)
673{
674 int rc;
675
676 rc = msm_gpios_request_enable(qsd_spi_gpio_config_data,
677 ARRAY_SIZE(qsd_spi_gpio_config_data));
678 if (rc)
679 return rc;
680
681 /* Set direction for SPI_PWR */
682 gpio_direction_output(21, 1);
683
684 return 0;
685}
686
687static void msm_qsd_spi_gpio_release(void)
688{
689 msm_gpios_disable_free(qsd_spi_gpio_config_data,
690 ARRAY_SIZE(qsd_spi_gpio_config_data));
691}
692
693static struct msm_spi_platform_data qsd_spi_pdata = {
694 .max_clock_speed = 19200000,
695 .gpio_config = msm_qsd_spi_gpio_config,
696 .gpio_release = msm_qsd_spi_gpio_release,
697 .dma_config = msm_qsd_spi_dma_config,
698};
699
700static void __init msm_qsd_spi_init(void)
701{
702 qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
703}
704
705static int mddi_toshiba_pmic_bl(int level)
706{
707 int ret = -EPERM;
708
709 if (machine_is_qsd8x50_ffa()) {
710 ret = pmic_set_led_intensity(LED_LCD, level);
711
712 if (ret)
713 printk(KERN_WARNING "%s: can't set lcd backlight!\n",
714 __func__);
715 }
716
717 return ret;
718}
719
720static struct msm_panel_common_pdata mddi_toshiba_pdata = {
721 .pmic_backlight = mddi_toshiba_pmic_bl,
722};
723
724static struct platform_device mddi_toshiba_device = {
725 .name = "mddi_toshiba",
726 .id = 0,
727 .dev = {
728 .platform_data = &mddi_toshiba_pdata,
729 }
730};
731
732static void msm_fb_vreg_config(const char *name, int on)
733{
734 struct vreg *vreg;
735 int ret = 0;
736
737 vreg = vreg_get(NULL, name);
738 if (IS_ERR(vreg)) {
739 printk(KERN_ERR "%s: vreg_get(%s) failed (%ld)\n",
740 __func__, name, PTR_ERR(vreg));
741 return;
742 }
743
744 ret = (on) ? vreg_enable(vreg) : vreg_disable(vreg);
745 if (ret)
746 printk(KERN_ERR "%s: %s(%s) failed!\n",
747 __func__, (on) ? "vreg_enable" : "vreg_disable", name);
748}
749
750#define MDDI_RST_OUT_GPIO 100
751
752static int mddi_power_save_on;
753static int msm_fb_mddi_power_save(int on)
754{
755 int flag_on = !!on;
756 int ret = 0;
757
758
759 if (mddi_power_save_on == flag_on)
760 return ret;
761
762 mddi_power_save_on = flag_on;
763
764 if (!flag_on && machine_is_qsd8x50_ffa()) {
765 gpio_set_value(MDDI_RST_OUT_GPIO, 0);
766 mdelay(1);
767 }
768
769 ret = pmic_lp_mode_control(flag_on ? OFF_CMD : ON_CMD,
770 PM_VREG_LP_MSME2_ID);
771 if (ret)
772 printk(KERN_ERR "%s: pmic_lp_mode_control failed!\n", __func__);
773
774 msm_fb_vreg_config("gp5", flag_on);
775 msm_fb_vreg_config("boost", flag_on);
776
777 if (flag_on && machine_is_qsd8x50_ffa()) {
778 gpio_set_value(MDDI_RST_OUT_GPIO, 0);
779 mdelay(1);
780 gpio_set_value(MDDI_RST_OUT_GPIO, 1);
781 gpio_set_value(MDDI_RST_OUT_GPIO, 1);
782 mdelay(1);
783 }
784
785 return ret;
786}
787
788static int msm_fb_mddi_sel_clk(u32 *clk_rate)
789{
790 *clk_rate *= 2;
791 return 0;
792}
793
794static struct mddi_platform_data mddi_pdata = {
795 .mddi_power_save = msm_fb_mddi_power_save,
796 .mddi_sel_clk = msm_fb_mddi_sel_clk,
797};
798
799static struct msm_panel_common_pdata mdp_pdata = {
800 .gpio = 98,
Ravishangar Kalyanam07ef7882011-08-09 15:50:48 -0700801 .mdp_rev = MDP_REV_31,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700802};
803
804static void __init msm_fb_add_devices(void)
805{
806 msm_fb_register_device("mdp", &mdp_pdata);
807 msm_fb_register_device("pmdh", &mddi_pdata);
808 msm_fb_register_device("emdh", &mddi_pdata);
809 msm_fb_register_device("tvenc", 0);
810 msm_fb_register_device("lcdc", 0);
811}
812
813static struct resource msm_audio_resources[] = {
814 {
815 .flags = IORESOURCE_DMA,
816 },
817 {
818 .name = "aux_pcm_dout",
819 .start = 68,
820 .end = 68,
821 .flags = IORESOURCE_IO,
822 },
823 {
824 .name = "aux_pcm_din",
825 .start = 69,
826 .end = 69,
827 .flags = IORESOURCE_IO,
828 },
829 {
830 .name = "aux_pcm_syncout",
831 .start = 70,
832 .end = 70,
833 .flags = IORESOURCE_IO,
834 },
835 {
836 .name = "aux_pcm_clkin_a",
837 .start = 71,
838 .end = 71,
839 .flags = IORESOURCE_IO,
840 },
841 {
842 .name = "sdac_din",
843 .start = 144,
844 .end = 144,
845 .flags = IORESOURCE_IO,
846 },
847 {
848 .name = "sdac_dout",
849 .start = 145,
850 .end = 145,
851 .flags = IORESOURCE_IO,
852 },
853 {
854 .name = "sdac_wsout",
855 .start = 143,
856 .end = 143,
857 .flags = IORESOURCE_IO,
858 },
859 {
860 .name = "cc_i2s_clk",
861 .start = 142,
862 .end = 142,
863 .flags = IORESOURCE_IO,
864 },
865 {
866 .name = "audio_master_clkout",
867 .start = 146,
868 .end = 146,
869 .flags = IORESOURCE_IO,
870 },
871 {
872 .name = "audio_base_addr",
873 .start = 0xa0700000,
874 .end = 0xa0700000 + 4,
875 .flags = IORESOURCE_MEM,
876 },
877
878};
879
880static unsigned audio_gpio_on[] = {
881 GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
882 GPIO_CFG(69, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
883 GPIO_CFG(70, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
884 GPIO_CFG(71, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
885 GPIO_CFG(142, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* CC_I2S_CLK */
886 GPIO_CFG(143, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* SADC_WSOUT */
887 GPIO_CFG(144, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* SADC_DIN */
888 GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* SDAC_DOUT */
889 GPIO_CFG(146, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MA_CLK_OUT */
890};
891
892static void __init audio_gpio_init(void)
893{
894 int pin, rc;
895
896 for (pin = 0; pin < ARRAY_SIZE(audio_gpio_on); pin++) {
897 rc = gpio_tlmm_config(audio_gpio_on[pin],
898 GPIO_CFG_ENABLE);
899 if (rc) {
900 printk(KERN_ERR
901 "%s: gpio_tlmm_config(%#x)=%d\n",
902 __func__, audio_gpio_on[pin], rc);
903 return;
904 }
905 }
906}
907
908static struct platform_device msm_audio_device = {
909 .name = "msm_audio",
910 .id = 0,
911 .num_resources = ARRAY_SIZE(msm_audio_resources),
912 .resource = msm_audio_resources,
913};
914
915static struct resource bluesleep_resources[] = {
916 {
917 .name = "gpio_host_wake",
918 .start = 21,
919 .end = 21,
920 .flags = IORESOURCE_IO,
921 },
922 {
923 .name = "gpio_ext_wake",
924 .start = 19,
925 .end = 19,
926 .flags = IORESOURCE_IO,
927 },
928 {
929 .name = "host_wake",
930 .start = MSM_GPIO_TO_INT(21),
931 .end = MSM_GPIO_TO_INT(21),
932 .flags = IORESOURCE_IRQ,
933 },
934};
935
936static struct platform_device msm_bluesleep_device = {
937 .name = "bluesleep",
938 .id = -1,
939 .num_resources = ARRAY_SIZE(bluesleep_resources),
940 .resource = bluesleep_resources,
941};
942
943#ifdef CONFIG_BT
944static struct platform_device msm_bt_power_device = {
945 .name = "bt_power",
946};
947
948enum {
949 BT_SYSRST,
950 BT_WAKE,
951 BT_HOST_WAKE,
952 BT_VDD_IO,
953 BT_RFR,
954 BT_CTS,
955 BT_RX,
956 BT_TX,
957 BT_VDD_FREG
958};
959
960static struct msm_gpio bt_config_power_off[] = {
961 { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
962 "BT SYSRST" },
963 { GPIO_CFG(19, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
964 "BT WAKE" },
965 { GPIO_CFG(21, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
966 "HOST WAKE" },
967 { GPIO_CFG(22, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
968 "BT VDD_IO" },
969 { GPIO_CFG(43, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
970 "UART1DM_RFR" },
971 { GPIO_CFG(44, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
972 "UART1DM_CTS" },
973 { GPIO_CFG(45, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
974 "UART1DM_RX" },
975 { GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
976 "UART1DM_TX" }
977};
978
979static struct msm_gpio bt_config_power_on[] = {
980 { GPIO_CFG(18, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
981 "BT SYSRST" },
982 { GPIO_CFG(19, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
983 "BT WAKE" },
984 { GPIO_CFG(21, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
985 "HOST WAKE" },
986 { GPIO_CFG(22, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
987 "BT VDD_IO" },
988 { GPIO_CFG(43, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
989 "UART1DM_RFR" },
990 { GPIO_CFG(44, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
991 "UART1DM_CTS" },
992 { GPIO_CFG(45, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
993 "UART1DM_RX" },
994 { GPIO_CFG(46, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
995 "UART1DM_TX" }
996};
997
998static struct msm_gpio wlan_config_power_off[] = {
999 { GPIO_CFG(62, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1000 "SDC2_CLK" },
1001 { GPIO_CFG(63, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1002 "SDC2_CMD" },
1003 { GPIO_CFG(64, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1004 "SDC2_D3" },
1005 { GPIO_CFG(65, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1006 "SDC2_D2" },
1007 { GPIO_CFG(66, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1008 "SDC2_D1" },
1009 { GPIO_CFG(67, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1010 "SDC2_D0" },
1011 { GPIO_CFG(113, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1012 "VDD_WLAN" },
1013 { GPIO_CFG(138, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
1014 "WLAN_PWD" }
1015};
1016
1017static struct msm_gpio wlan_config_power_on[] = {
1018 { GPIO_CFG(62, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1019 "SDC2_CLK" },
1020 { GPIO_CFG(63, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1021 "SDC2_CMD" },
1022 { GPIO_CFG(64, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1023 "SDC2_D3" },
1024 { GPIO_CFG(65, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1025 "SDC2_D2" },
1026 { GPIO_CFG(66, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1027 "SDC2_D1" },
1028 { GPIO_CFG(67, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1029 "SDC2_D0" },
1030 { GPIO_CFG(113, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1031 "VDD_WLAN" },
1032 { GPIO_CFG(138, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1033 "WLAN_PWD" }
1034};
1035
1036static int bluetooth_power(int on)
1037{
1038 int rc;
1039 struct vreg *vreg_wlan;
1040
1041 vreg_wlan = vreg_get(NULL, "wlan");
1042
1043 if (IS_ERR(vreg_wlan)) {
1044 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
1045 __func__, PTR_ERR(vreg_wlan));
1046 return PTR_ERR(vreg_wlan);
1047 }
1048
1049 if (on) {
1050 /* units of mV, steps of 50 mV */
1051 rc = vreg_set_level(vreg_wlan, PMIC_VREG_WLAN_LEVEL);
1052 if (rc) {
1053 printk(KERN_ERR "%s: vreg wlan set level failed (%d)\n",
1054 __func__, rc);
1055 return -EIO;
1056 }
1057 rc = vreg_enable(vreg_wlan);
1058 if (rc) {
1059 printk(KERN_ERR "%s: vreg wlan enable failed (%d)\n",
1060 __func__, rc);
1061 return -EIO;
1062 }
1063
1064 rc = msm_gpios_enable(bt_config_power_on,
1065 ARRAY_SIZE(bt_config_power_on));
1066 if (rc < 0) {
1067 printk(KERN_ERR
1068 "%s: bt power on gpio config failed: %d\n",
1069 __func__, rc);
1070 return rc;
1071 }
1072
1073 if (machine_is_qsd8x50_ffa()) {
1074 rc = msm_gpios_enable
1075 (wlan_config_power_on,
1076 ARRAY_SIZE(wlan_config_power_on));
1077 if (rc < 0) {
1078 printk
1079 (KERN_ERR
1080 "%s: wlan power on gpio config failed: %d\n",
1081 __func__, rc);
1082 return rc;
1083 }
1084 }
1085
1086 gpio_set_value(22, on); /* VDD_IO */
1087 gpio_set_value(18, on); /* SYSRST */
1088
1089 if (machine_is_qsd8x50_ffa()) {
1090 gpio_set_value(138, 0); /* WLAN: CHIP_PWD */
1091 gpio_set_value(113, on); /* WLAN */
1092 }
1093 } else {
1094 if (machine_is_qsd8x50_ffa()) {
1095 gpio_set_value(138, on); /* WLAN: CHIP_PWD */
1096 gpio_set_value(113, on); /* WLAN */
1097 }
1098
1099 gpio_set_value(18, on); /* SYSRST */
1100 gpio_set_value(22, on); /* VDD_IO */
1101
1102 rc = vreg_disable(vreg_wlan);
1103 if (rc) {
1104 printk(KERN_ERR "%s: vreg wlan disable failed (%d)\n",
1105 __func__, rc);
1106 return -EIO;
1107 }
1108
1109 rc = msm_gpios_enable(bt_config_power_off,
1110 ARRAY_SIZE(bt_config_power_off));
1111 if (rc < 0) {
1112 printk(KERN_ERR
1113 "%s: bt power off gpio config failed: %d\n",
1114 __func__, rc);
1115 return rc;
1116 }
1117
1118 if (machine_is_qsd8x50_ffa()) {
1119 rc = msm_gpios_enable
1120 (wlan_config_power_off,
1121 ARRAY_SIZE(wlan_config_power_off));
1122 if (rc < 0) {
1123 printk
1124 (KERN_ERR
1125 "%s: wlan power off gpio config failed: %d\n",
1126 __func__, rc);
1127 return rc;
1128 }
1129 }
1130 }
1131
1132 printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
1133
1134 return 0;
1135}
1136
1137static void __init bt_power_init(void)
1138{
1139 struct vreg *vreg_bt;
1140 int rc;
1141
1142 if (machine_is_qsd8x50_ffa()) {
1143 gpio_set_value(138, 0); /* WLAN: CHIP_PWD */
1144 gpio_set_value(113, 0); /* WLAN */
1145 }
1146
1147 gpio_set_value(18, 0); /* SYSRST */
1148 gpio_set_value(22, 0); /* VDD_IO */
1149
1150 /* do not have vreg bt defined, gp6 is the same */
1151 /* vreg_get parameter 1 (struct device *) is ignored */
1152 vreg_bt = vreg_get(NULL, "gp6");
1153
1154 if (IS_ERR(vreg_bt)) {
1155 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
1156 __func__, PTR_ERR(vreg_bt));
1157 goto exit;
1158 }
1159
1160 /* units of mV, steps of 50 mV */
1161 rc = vreg_set_level(vreg_bt, PMIC_VREG_GP6_LEVEL);
1162 if (rc) {
1163 printk(KERN_ERR "%s: vreg bt set level failed (%d)\n",
1164 __func__, rc);
1165 goto exit;
1166 }
1167 rc = vreg_enable(vreg_bt);
1168 if (rc) {
1169 printk(KERN_ERR "%s: vreg bt enable failed (%d)\n",
1170 __func__, rc);
1171 goto exit;
1172 }
1173
1174 if (bluetooth_power(0))
1175 goto exit;
1176
1177 msm_bt_power_device.dev.platform_data = &bluetooth_power;
1178
1179 printk(KERN_DEBUG "Bluetooth power switch: initialized\n");
1180
1181exit:
1182 return;
1183}
1184#else
1185#define bt_power_init(x) do {} while (0)
1186#endif
1187
1188static struct platform_device msm_device_pmic_leds = {
1189 .name = "pmic-leds",
1190 .id = -1,
1191};
1192
1193/* TSIF begin */
1194#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
1195
1196#define TSIF_A_SYNC GPIO_CFG(106, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1197#define TSIF_A_DATA GPIO_CFG(107, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1198#define TSIF_A_EN GPIO_CFG(108, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1199#define TSIF_A_CLK GPIO_CFG(109, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
1200
1201static const struct msm_gpio tsif_gpios[] = {
1202 { .gpio_cfg = TSIF_A_CLK, .label = "tsif_clk", },
1203 { .gpio_cfg = TSIF_A_EN, .label = "tsif_en", },
1204 { .gpio_cfg = TSIF_A_DATA, .label = "tsif_data", },
1205 { .gpio_cfg = TSIF_A_SYNC, .label = "tsif_sync", },
1206};
1207
1208static struct msm_tsif_platform_data tsif_platform_data = {
1209 .num_gpios = ARRAY_SIZE(tsif_gpios),
1210 .gpios = tsif_gpios,
Matt Wagantall640e5fd2011-08-17 16:08:53 -07001211 .tsif_clk = "core_clk",
1212 .tsif_ref_clk = "ref_clk",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001213};
1214
1215#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
1216/* TSIF end */
1217
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001218static void touchpad_gpio_release(void)
1219{
1220 gpio_free(TOUCHPAD_IRQ);
1221 gpio_free(TOUCHPAD_SUSPEND);
1222}
1223
1224static int touchpad_gpio_setup(void)
1225{
1226 int rc;
1227 int suspend_pin = TOUCHPAD_SUSPEND;
1228 int irq_pin = TOUCHPAD_IRQ;
1229 unsigned suspend_cfg =
1230 GPIO_CFG(suspend_pin, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1231 unsigned irq_cfg =
1232 GPIO_CFG(irq_pin, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1233
1234 rc = gpio_request(irq_pin, "msm_touchpad_irq");
1235 if (rc) {
1236 pr_err("gpio_request failed on pin %d (rc=%d)\n",
1237 irq_pin, rc);
1238 goto err_gpioconfig;
1239 }
1240 rc = gpio_request(suspend_pin, "msm_touchpad_suspend");
1241 if (rc) {
1242 pr_err("gpio_request failed on pin %d (rc=%d)\n",
1243 suspend_pin, rc);
1244 goto err_gpioconfig;
1245 }
1246 rc = gpio_tlmm_config(suspend_cfg, GPIO_CFG_ENABLE);
1247 if (rc) {
1248 pr_err("gpio_tlmm_config failed on pin %d (rc=%d)\n",
1249 suspend_pin, rc);
1250 goto err_gpioconfig;
1251 }
1252 rc = gpio_tlmm_config(irq_cfg, GPIO_CFG_ENABLE);
1253 if (rc) {
1254 pr_err("gpio_tlmm_config failed on pin %d (rc=%d)\n",
1255 irq_pin, rc);
1256 goto err_gpioconfig;
1257 }
1258 return rc;
1259
1260err_gpioconfig:
1261 touchpad_gpio_release();
1262 return rc;
1263}
1264
1265static struct msm_touchpad_platform_data msm_touchpad_data = {
1266 .gpioirq = TOUCHPAD_IRQ,
1267 .gpiosuspend = TOUCHPAD_SUSPEND,
1268 .gpio_setup = touchpad_gpio_setup,
1269 .gpio_shutdown = touchpad_gpio_release
1270};
1271
1272#define KBD_RST 35
1273#define KBD_IRQ 36
1274
1275static void kbd_gpio_release(void)
1276{
1277 gpio_free(KBD_IRQ);
1278 gpio_free(KBD_RST);
1279}
1280
1281static int kbd_gpio_setup(void)
1282{
1283 int rc;
1284 int respin = KBD_RST;
1285 int irqpin = KBD_IRQ;
1286 unsigned rescfg =
1287 GPIO_CFG(respin, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA);
1288 unsigned irqcfg =
1289 GPIO_CFG(irqpin, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
1290
1291 rc = gpio_request(irqpin, "gpio_keybd_irq");
1292 if (rc) {
1293 pr_err("gpio_request failed on pin %d (rc=%d)\n",
1294 irqpin, rc);
1295 goto err_gpioconfig;
1296 }
1297 rc = gpio_request(respin, "gpio_keybd_reset");
1298 if (rc) {
1299 pr_err("gpio_request failed on pin %d (rc=%d)\n",
1300 respin, rc);
1301 goto err_gpioconfig;
1302 }
1303 rc = gpio_tlmm_config(rescfg, GPIO_CFG_ENABLE);
1304 if (rc) {
1305 pr_err("gpio_tlmm_config failed on pin %d (rc=%d)\n",
1306 respin, rc);
1307 goto err_gpioconfig;
1308 }
1309 rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
1310 if (rc) {
1311 pr_err("gpio_tlmm_config failed on pin %d (rc=%d)\n",
1312 irqpin, rc);
1313 goto err_gpioconfig;
1314 }
1315 return rc;
1316
1317err_gpioconfig:
1318 kbd_gpio_release();
1319 return rc;
1320}
1321
1322/* use gpio output pin to toggle keyboard external reset pin */
1323static void kbd_hwreset(int kbd_mclrpin)
1324{
1325 gpio_direction_output(kbd_mclrpin, 0);
1326 gpio_direction_output(kbd_mclrpin, 1);
1327}
1328
1329static struct msm_i2ckbd_platform_data msm_kybd_data = {
1330 .hwrepeat = 0,
1331 .scanset1 = 1,
1332 .gpioreset = KBD_RST,
1333 .gpioirq = KBD_IRQ,
1334 .gpio_setup = kbd_gpio_setup,
1335 .gpio_shutdown = kbd_gpio_release,
1336 .hw_reset = kbd_hwreset,
1337};
1338
1339static struct i2c_board_info msm_i2c_board_info[] __initdata = {
1340 {
1341 I2C_BOARD_INFO("glidesensor", 0x2A),
1342 .irq = MSM_GPIO_TO_INT(TOUCHPAD_IRQ),
1343 .platform_data = &msm_touchpad_data
1344 },
1345 {
1346 I2C_BOARD_INFO("msm-i2ckbd", 0x3A),
1347 .type = "msm-i2ckbd",
1348 .irq = MSM_GPIO_TO_INT(KBD_IRQ),
1349 .platform_data = &msm_kybd_data
1350 },
1351#ifdef CONFIG_MT9D112
1352 {
1353 I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
1354 },
1355#endif
1356#ifdef CONFIG_S5K3E2FX
1357 {
1358 I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
1359 },
1360#endif
1361#ifdef CONFIG_MT9P012
1362 {
1363 I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
1364 },
1365#endif
1366#ifdef CONFIG_MT9P012_KM
1367 {
1368 I2C_BOARD_INFO("mt9p012_km", 0x6C >> 2),
1369 },
1370#endif
1371#if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
1372 {
1373 I2C_BOARD_INFO("mt9t013", 0x6C),
1374 },
1375#endif
1376 {
1377 I2C_BOARD_INFO("tps65023", 0x48),
1378 },
1379};
1380
1381#ifdef CONFIG_MSM_CAMERA
1382static uint32_t camera_off_gpio_table[] = {
1383 /* parallel CAMERA interfaces */
1384 GPIO_CFG(0, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT0 */
1385 GPIO_CFG(1, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT1 */
1386 GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
1387 GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
1388 GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
1389 GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
1390 GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
1391 GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
1392 GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
1393 GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
1394 GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
1395 GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
1396 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
1397 GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
1398 GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
1399 GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
1400};
1401
1402static uint32_t camera_on_gpio_table[] = {
1403 /* parallel CAMERA interfaces */
1404 GPIO_CFG(0, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT0 */
1405 GPIO_CFG(1, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT1 */
1406 GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
1407 GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
1408 GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
1409 GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
1410 GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
1411 GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
1412 GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
1413 GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
1414 GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
1415 GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
1416 GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
1417 GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
1418 GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
1419 GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), /* MCLK */
1420};
1421
1422static uint32_t camera_on_gpio_ffa_table[] = {
1423 /* parallel CAMERA interfaces */
1424 GPIO_CFG(95, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA), /* I2C_SCL */
1425 GPIO_CFG(96, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA), /* I2C_SDA */
1426 /* FFA front Sensor Reset */
1427 GPIO_CFG(137, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA),
1428};
1429
1430static uint32_t camera_off_gpio_ffa_table[] = {
1431 /* FFA front Sensor Reset */
1432 GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA),
1433};
1434
1435static void config_gpio_table(uint32_t *table, int len)
1436{
1437 int n, rc;
1438 for (n = 0; n < len; n++) {
1439 rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
1440 if (rc) {
1441 printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
1442 __func__, table[n], rc);
1443 break;
1444 }
1445 }
1446}
1447
1448static struct vreg *vreg_gp2;
1449static struct vreg *vreg_gp3;
1450
1451static void msm_camera_vreg_config(int vreg_en)
1452{
1453 int rc;
1454
1455 if (vreg_gp2 == NULL) {
1456 vreg_gp2 = vreg_get(NULL, "gp2");
1457 if (IS_ERR(vreg_gp2)) {
1458 printk(KERN_ERR "%s: vreg_get(%s) failed (%ld)\n",
1459 __func__, "gp2", PTR_ERR(vreg_gp2));
1460 return;
1461 }
1462
1463 rc = vreg_set_level(vreg_gp2, 1800);
1464 if (rc) {
1465 printk(KERN_ERR "%s: GP2 set_level failed (%d)\n",
1466 __func__, rc);
1467 }
1468 }
1469
1470 if (vreg_gp3 == NULL) {
1471 vreg_gp3 = vreg_get(NULL, "gp3");
1472 if (IS_ERR(vreg_gp3)) {
1473 printk(KERN_ERR "%s: vreg_get(%s) failed (%ld)\n",
1474 __func__, "gp3", PTR_ERR(vreg_gp3));
1475 return;
1476 }
1477
1478 rc = vreg_set_level(vreg_gp3, 2800);
1479 if (rc) {
1480 printk(KERN_ERR "%s: GP3 set level failed (%d)\n",
1481 __func__, rc);
1482 }
1483 }
1484
1485 if (vreg_en) {
1486 rc = vreg_enable(vreg_gp2);
1487 if (rc) {
1488 printk(KERN_ERR "%s: GP2 enable failed (%d)\n",
1489 __func__, rc);
1490 }
1491
1492 rc = vreg_enable(vreg_gp3);
1493 if (rc) {
1494 printk(KERN_ERR "%s: GP3 enable failed (%d)\n",
1495 __func__, rc);
1496 }
1497 } else {
1498 rc = vreg_disable(vreg_gp2);
1499 if (rc) {
1500 printk(KERN_ERR "%s: GP2 disable failed (%d)\n",
1501 __func__, rc);
1502 }
1503
1504 rc = vreg_disable(vreg_gp3);
1505 if (rc) {
1506 printk(KERN_ERR "%s: GP3 disable failed (%d)\n",
1507 __func__, rc);
1508 }
1509 }
1510}
1511
1512static int config_camera_on_gpios(void)
1513{
1514 int vreg_en = 1;
1515
1516 if (machine_is_qsd8x50_ffa()) {
1517 config_gpio_table(camera_on_gpio_ffa_table,
1518 ARRAY_SIZE(camera_on_gpio_ffa_table));
1519
1520 msm_camera_vreg_config(vreg_en);
1521 gpio_set_value(137, 0);
1522 }
1523 config_gpio_table(camera_on_gpio_table,
1524 ARRAY_SIZE(camera_on_gpio_table));
1525 return 0;
1526}
1527
1528static void config_camera_off_gpios(void)
1529{
1530 int vreg_en = 0;
1531
1532 if (machine_is_qsd8x50_ffa()) {
1533 config_gpio_table(camera_off_gpio_ffa_table,
1534 ARRAY_SIZE(camera_off_gpio_ffa_table));
1535
1536 msm_camera_vreg_config(vreg_en);
1537 }
1538 config_gpio_table(camera_off_gpio_table,
1539 ARRAY_SIZE(camera_off_gpio_table));
1540}
1541
1542static struct resource msm_camera_resources[] = {
1543 {
1544 .start = 0xA0F00000,
1545 .end = 0xA0F00000 + SZ_1M - 1,
1546 .flags = IORESOURCE_MEM,
1547 },
1548 {
1549 .start = INT_VFE,
1550 .end = INT_VFE,
1551 .flags = IORESOURCE_IRQ,
1552 },
1553};
1554
1555static struct msm_camera_device_platform_data msm_camera_device_data = {
1556 .camera_gpio_on = config_camera_on_gpios,
1557 .camera_gpio_off = config_camera_off_gpios,
1558 .ioext.mdcphy = MSM_MDC_PHYS,
1559 .ioext.mdcsz = MSM_MDC_SIZE,
1560 .ioext.appphy = MSM_CLK_CTL_PHYS,
1561 .ioext.appsz = MSM_CLK_CTL_SIZE,
1562};
1563
1564int pmic_set_flash_led_current(enum pmic8058_leds id, unsigned mA)
1565{
1566 int rc;
1567 rc = pmic_flash_led_set_current(mA);
1568 return rc;
1569}
1570static struct msm_camera_sensor_flash_src msm_flash_src = {
1571 .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
1572 ._fsrc.pmic_src.num_of_src = 1,
1573 ._fsrc.pmic_src.low_current = 30,
1574 ._fsrc.pmic_src.high_current = 100,
1575 ._fsrc.pmic_src.led_src_1 = 0,
1576 ._fsrc.pmic_src.led_src_2 = 0,
1577 ._fsrc.pmic_src.pmic_set_current = pmic_set_flash_led_current,
1578};
1579
1580#ifdef CONFIG_MT9D112
1581static struct msm_camera_sensor_flash_data flash_mt9d112 = {
1582 .flash_type = MSM_CAMERA_FLASH_LED,
1583 .flash_src = &msm_flash_src
1584};
1585
1586static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
1587 .sensor_name = "mt9d112",
1588 .sensor_reset = 17,
1589 .sensor_pwd = 85,
1590 .vcm_pwd = 0,
1591 .vcm_enable = 0,
1592 .pdata = &msm_camera_device_data,
1593 .resource = msm_camera_resources,
1594 .num_resources = ARRAY_SIZE(msm_camera_resources),
1595 .flash_data = &flash_mt9d112
1596};
1597
1598static struct platform_device msm_camera_sensor_mt9d112 = {
1599 .name = "msm_camera_mt9d112",
1600 .dev = {
1601 .platform_data = &msm_camera_sensor_mt9d112_data,
1602 },
1603};
1604#endif
1605
1606#ifdef CONFIG_S5K3E2FX
1607static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
1608 .flash_type = MSM_CAMERA_FLASH_LED,
1609 .flash_src = &msm_flash_src
1610};
1611
1612static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
1613 .sensor_name = "s5k3e2fx",
1614 .sensor_reset = 17,
1615 .sensor_pwd = 85,
1616 /*.vcm_pwd = 31, */ /* CAM1_VCM_EN, enabled in a9 */
1617 .vcm_enable = 0,
1618 .pdata = &msm_camera_device_data,
1619 .resource = msm_camera_resources,
1620 .num_resources = ARRAY_SIZE(msm_camera_resources),
1621 .flash_data = &flash_s5k3e2fx
1622};
1623
1624static struct platform_device msm_camera_sensor_s5k3e2fx = {
1625 .name = "msm_camera_s5k3e2fx",
1626 .dev = {
1627 .platform_data = &msm_camera_sensor_s5k3e2fx_data,
1628 },
1629};
1630#endif
1631
1632#ifdef CONFIG_MT9P012
1633static struct msm_camera_sensor_flash_data flash_mt9p012 = {
1634 .flash_type = MSM_CAMERA_FLASH_LED,
1635 .flash_src = &msm_flash_src
1636};
1637
1638static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
1639 .sensor_name = "mt9p012",
1640 .sensor_reset = 17,
1641 .sensor_pwd = 85,
1642 .vcm_pwd = 88,
1643 .vcm_enable = 0,
1644 .pdata = &msm_camera_device_data,
1645 .resource = msm_camera_resources,
1646 .num_resources = ARRAY_SIZE(msm_camera_resources),
1647 .flash_data = &flash_mt9p012
1648};
1649
1650static struct platform_device msm_camera_sensor_mt9p012 = {
1651 .name = "msm_camera_mt9p012",
1652 .dev = {
1653 .platform_data = &msm_camera_sensor_mt9p012_data,
1654 },
1655};
1656#endif
1657
1658#ifdef CONFIG_MT9P012_KM
1659static struct msm_camera_sensor_flash_data flash_mt9p012_km = {
1660 .flash_type = MSM_CAMERA_FLASH_LED,
1661 .flash_src = &msm_flash_src
1662};
1663
1664static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_km_data = {
1665 .sensor_name = "mt9p012_km",
1666 .sensor_reset = 17,
1667 .sensor_pwd = 85,
1668 .vcm_pwd = 88,
1669 .vcm_enable = 0,
1670 .pdata = &msm_camera_device_data,
1671 .resource = msm_camera_resources,
1672 .num_resources = ARRAY_SIZE(msm_camera_resources),
1673 .flash_data = &flash_mt9p012_km
1674};
1675
1676static struct platform_device msm_camera_sensor_mt9p012_km = {
1677 .name = "msm_camera_mt9p012_km",
1678 .dev = {
1679 .platform_data = &msm_camera_sensor_mt9p012_km_data,
1680 },
1681};
1682#endif
1683
1684#ifdef CONFIG_MT9T013
1685static struct msm_camera_sensor_flash_data flash_mt9t013 = {
1686 .flash_type = MSM_CAMERA_FLASH_LED,
1687 .flash_src = &msm_flash_src
1688};
1689
1690static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
1691 .sensor_name = "mt9t013",
1692 .sensor_reset = 17,
1693 .sensor_pwd = 85,
1694 .vcm_pwd = 0,
1695 .vcm_enable = 0,
1696 .pdata = &msm_camera_device_data,
1697 .resource = msm_camera_resources,
1698 .num_resources = ARRAY_SIZE(msm_camera_resources),
1699 .flash_data = &flash_mt9t013
1700};
1701
1702static struct platform_device msm_camera_sensor_mt9t013 = {
1703 .name = "msm_camera_mt9t013",
1704 .dev = {
1705 .platform_data = &msm_camera_sensor_mt9t013_data,
1706 },
1707};
1708#endif
1709#endif /*CONFIG_MSM_CAMERA*/
1710
1711static u32 msm_calculate_batt_capacity(u32 current_voltage);
1712
1713static struct msm_psy_batt_pdata msm_psy_batt_data = {
1714 .voltage_min_design = 3200,
1715 .voltage_max_design = 4200,
1716 .avail_chg_sources = AC_CHG | USB_CHG ,
1717 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
1718 .calculate_capacity = &msm_calculate_batt_capacity,
1719};
1720
1721static u32 msm_calculate_batt_capacity(u32 current_voltage)
1722{
1723 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
1724 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
1725
1726 return (current_voltage - low_voltage) * 100
1727 / (high_voltage - low_voltage);
1728}
1729
1730static struct platform_device msm_batt_device = {
1731 .name = "msm-battery",
1732 .id = -1,
1733 .dev.platform_data = &msm_psy_batt_data,
1734};
1735
1736static int hsusb_rpc_connect(int connect)
1737{
1738 if (connect)
1739 return msm_hsusb_rpc_connect();
1740 else
1741 return msm_hsusb_rpc_close();
1742}
1743
1744static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
1745{
1746 int ret;
1747
1748 if (init) {
1749 ret = msm_pm_app_rpc_init(callback);
1750 } else {
1751 msm_pm_app_rpc_deinit(callback);
1752 ret = 0;
1753 }
1754 return ret;
1755}
1756static int msm_hsusb_ldo_init(int init);
1757static int msm_hsusb_ldo_enable(int enable);
1758
1759static struct msm_otg_platform_data msm_otg_pdata = {
1760 .rpc_connect = hsusb_rpc_connect,
1761 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
1762 .pemp_level = PRE_EMPHASIS_WITH_10_PERCENT,
1763 .cdr_autoreset = CDR_AUTO_RESET_DEFAULT,
1764 .drv_ampl = HS_DRV_AMPLITUDE_5_PERCENT,
1765 .vbus_power = msm_hsusb_vbus_power,
1766 .chg_vbus_draw = hsusb_chg_vbus_draw,
1767 .chg_connected = hsusb_chg_connected,
1768 .chg_init = hsusb_chg_init,
1769 .phy_can_powercollapse = 1,
1770 .ldo_init = msm_hsusb_ldo_init,
1771 .ldo_enable = msm_hsusb_ldo_enable,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001772};
1773
1774static struct msm_hsusb_gadget_platform_data msm_gadget_pdata;
1775
1776static struct platform_device *devices[] __initdata = {
1777 &msm_fb_device,
1778 &mddi_toshiba_device,
1779 &smc91x_device,
1780 &msm_device_smd,
1781 &msm_device_dmov,
1782 &android_pmem_kernel_ebi1_device,
1783#ifdef CONFIG_KERNEL_PMEM_SMI_REGION
1784 &android_pmem_kernel_smi_device,
1785#endif
1786 &android_pmem_device,
1787 &android_pmem_adsp_device,
1788 &android_pmem_smipool_device,
1789 &msm_device_nand,
1790 &msm_device_i2c,
1791 &qsd_device_spi,
1792#ifdef CONFIG_USB_FUNCTION
1793 &mass_storage_device,
1794#endif
1795#ifdef CONFIG_USB_ANDROID
1796 &usb_mass_storage_device,
1797 &rndis_device,
1798#ifdef CONFIG_USB_ANDROID_DIAG
1799 &usb_diag_device,
1800#endif
1801#ifdef CONFIG_USB_F_SERIAL
1802 &usb_gadget_fserial_device,
1803#endif
1804 &android_usb_device,
1805#endif
1806 &msm_device_tssc,
1807 &msm_audio_device,
1808 &msm_device_uart_dm1,
1809 &msm_bluesleep_device,
1810#ifdef CONFIG_BT
1811 &msm_bt_power_device,
1812#endif
1813#if !defined(CONFIG_MSM_SERIAL_DEBUGGER)
1814 &msm_device_uart3,
1815#endif
1816 &msm_device_pmic_leds,
1817 &msm_kgsl_3d0,
1818 &hs_device,
1819#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
1820 &msm_device_tsif,
1821#endif
1822#ifdef CONFIG_MT9T013
1823 &msm_camera_sensor_mt9t013,
1824#endif
1825#ifdef CONFIG_MT9D112
1826 &msm_camera_sensor_mt9d112,
1827#endif
1828#ifdef CONFIG_S5K3E2FX
1829 &msm_camera_sensor_s5k3e2fx,
1830#endif
1831#ifdef CONFIG_MT9P012
1832 &msm_camera_sensor_mt9p012,
1833#endif
1834#ifdef CONFIG_MT9P012_KM
1835 &msm_camera_sensor_mt9p012_km,
1836#endif
1837 &msm_batt_device,
1838};
1839
1840static void __init qsd8x50_init_irq(void)
1841{
1842 msm_init_irq();
1843 msm_init_sirc();
1844}
1845
1846static void usb_mpp_init(void)
1847{
1848 unsigned rc;
1849 unsigned mpp_usb = 20;
1850
1851 if (machine_is_qsd8x50_ffa()) {
1852 rc = mpp_config_digital_out(mpp_usb,
1853 MPP_CFG(MPP_DLOGIC_LVL_VDD,
1854 MPP_DLOGIC_OUT_CTRL_HIGH));
1855 if (rc)
1856 pr_err("%s: configuring mpp pin"
1857 "to enable 3.3V LDO failed\n", __func__);
1858 }
1859}
1860
1861/* TBD: 8x50 FFAs have internal 3p3 voltage regulator as opposed to
1862 * external 3p3 voltage regulator on Surf platform. There is no way
1863 * s/w can detect fi concerned regulator is internal or external to
1864 * to MSM. Internal 3p3 regulator is powered through boost voltage
1865 * regulator where as external 3p3 regulator is powered through VPH.
1866 * So for internal voltage regulator it is required to power on
1867 * boost voltage regulator first. Unfortunately some of the FFAs are
1868 * re-worked to install external 3p3 regulator. For now, assuming all
1869 * FFAs have 3p3 internal regulators and all SURFs have external 3p3
1870 * regulator as there is no way s/w can determine if theregulator is
1871 * internal or external. May be, we can implement this flag as kernel
1872 * boot parameters so that we can change code behaviour dynamically
1873 */
1874static int regulator_3p3_is_internal;
1875static struct vreg *vreg_5v;
1876static struct vreg *vreg_3p3;
1877static int msm_hsusb_ldo_init(int init)
1878{
1879 if (init) {
1880 if (regulator_3p3_is_internal) {
1881 vreg_5v = vreg_get(NULL, "boost");
1882 if (IS_ERR(vreg_5v))
1883 return PTR_ERR(vreg_5v);
1884 vreg_set_level(vreg_5v, 5000);
1885 }
1886
1887 vreg_3p3 = vreg_get(NULL, "usb");
1888 if (IS_ERR(vreg_3p3))
1889 return PTR_ERR(vreg_3p3);
1890 vreg_set_level(vreg_3p3, 3300);
1891 } else {
1892 if (regulator_3p3_is_internal)
1893 vreg_put(vreg_5v);
1894 vreg_put(vreg_3p3);
Gregory Bean5d73c532010-09-29 13:46:45 -07001895 }
1896
1897 return 0;
1898}
Gregory Bean5d73c532010-09-29 13:46:45 -07001899
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001900static int msm_hsusb_ldo_enable(int enable)
1901{
1902 static int ldo_status;
1903 int ret;
Pavankumar Kondeti7032d512010-12-08 13:37:07 +05301904
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001905 if (ldo_status == enable)
1906 return 0;
Pavankumar Kondeti7032d512010-12-08 13:37:07 +05301907
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001908 if (regulator_3p3_is_internal && (!vreg_5v || IS_ERR(vreg_5v)))
1909 return -ENODEV;
1910 if (!vreg_3p3 || IS_ERR(vreg_3p3))
1911 return -ENODEV;
Daniel Walkera32d2fe2010-02-25 11:38:39 -08001912
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001913 ldo_status = enable;
1914
1915 if (enable) {
1916 if (regulator_3p3_is_internal) {
1917 ret = vreg_enable(vreg_5v);
1918 if (ret)
1919 return ret;
1920
1921 /* power supply to 3p3 regulator can vary from
1922 * USB VBUS or VREG 5V. If the power supply is
1923 * USB VBUS cable disconnection cannot be
1924 * deteted. Select power supply to VREG 5V
1925 */
1926 /* TBD: comeup with a better name */
1927 ret = pmic_vote_3p3_pwr_sel_switch(1);
1928 if (ret)
1929 return ret;
1930 }
1931 ret = vreg_enable(vreg_3p3);
1932
1933 return ret;
1934 } else {
1935 if (regulator_3p3_is_internal) {
1936 ret = vreg_disable(vreg_5v);
1937 if (ret)
1938 return ret;
1939 ret = pmic_vote_3p3_pwr_sel_switch(0);
1940 if (ret)
1941 return ret;
1942 }
1943 ret = vreg_disable(vreg_3p3);
1944
1945 return ret;
1946 }
1947}
1948
1949static void __init qsd8x50_init_usb(void)
1950{
1951 usb_mpp_init();
1952
1953 if (machine_is_qsd8x50_ffa())
1954 regulator_3p3_is_internal = 1;
1955
1956#ifdef CONFIG_USB_MSM_OTG_72K
1957 platform_device_register(&msm_device_otg);
1958#endif
1959
1960#ifdef CONFIG_USB_FUNCTION_MSM_HSUSB
1961 platform_device_register(&msm_device_hsusb_peripheral);
1962#endif
1963
1964#ifdef CONFIG_USB_MSM_72K
1965 platform_device_register(&msm_device_gadget_peripheral);
1966#endif
1967
1968 if (machine_is_qsd8x50_ffa())
1969 return;
1970
1971 vreg_usb = vreg_get(NULL, "boost");
1972
1973 if (IS_ERR(vreg_usb)) {
1974 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
1975 __func__, PTR_ERR(vreg_usb));
1976 return;
1977 }
1978
1979 platform_device_register(&msm_device_hsusb_otg);
1980 msm_add_host(0, &msm_usb_host_pdata);
1981#ifdef CONFIG_USB_FS_HOST
1982 if (fsusb_gpio_init())
1983 return;
1984 msm_add_host(1, &msm_usb_host2_pdata);
1985#endif
1986}
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +05301987
1988static struct vreg *vreg_mmc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001989
1990#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
1991 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
1992 || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
1993 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
1994
1995struct sdcc_gpio {
1996 struct msm_gpio *cfg_data;
1997 uint32_t size;
1998};
1999
2000static struct msm_gpio sdc1_cfg_data[] = {
2001 {GPIO_CFG(51, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
2002 {GPIO_CFG(52, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
2003 {GPIO_CFG(53, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
2004 {GPIO_CFG(54, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
2005 {GPIO_CFG(55, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
2006 {GPIO_CFG(56, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "sdc1_clk"},
2007};
2008
2009static struct msm_gpio sdc2_cfg_data[] = {
2010 {GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "sdc2_clk"},
2011 {GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
2012 {GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
2013 {GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
2014 {GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
2015 {GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
2016};
2017
2018static struct msm_gpio sdc3_cfg_data[] = {
2019 {GPIO_CFG(88, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "sdc3_clk"},
2020 {GPIO_CFG(89, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
2021 {GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
2022 {GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
2023 {GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
2024 {GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
2025
2026#ifdef CONFIG_MMC_MSM_SDC3_8_BIT_SUPPORT
2027 {GPIO_CFG(158, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_4"},
2028 {GPIO_CFG(159, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_5"},
2029 {GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_6"},
2030 {GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_7"},
2031#endif
2032};
2033
2034static struct msm_gpio sdc4_cfg_data[] = {
2035 {GPIO_CFG(142, 3, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "sdc4_clk"},
2036 {GPIO_CFG(143, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
2037 {GPIO_CFG(144, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
2038 {GPIO_CFG(145, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
2039 {GPIO_CFG(146, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
2040 {GPIO_CFG(147, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
2041};
2042
2043static struct sdcc_gpio sdcc_cfg_data[] = {
2044 {
2045 .cfg_data = sdc1_cfg_data,
2046 .size = ARRAY_SIZE(sdc1_cfg_data),
2047 },
2048 {
2049 .cfg_data = sdc2_cfg_data,
2050 .size = ARRAY_SIZE(sdc2_cfg_data),
2051 },
2052 {
2053 .cfg_data = sdc3_cfg_data,
2054 .size = ARRAY_SIZE(sdc3_cfg_data),
2055 },
2056 {
2057 .cfg_data = sdc4_cfg_data,
2058 .size = ARRAY_SIZE(sdc4_cfg_data),
2059 },
2060};
2061
2062static unsigned long vreg_sts, gpio_sts;
2063
2064static void msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
2065{
2066 int rc = 0;
2067 struct sdcc_gpio *curr;
2068
2069 curr = &sdcc_cfg_data[dev_id - 1];
2070 if (!(test_bit(dev_id, &gpio_sts)^enable))
2071 return;
2072
2073 if (enable) {
2074 set_bit(dev_id, &gpio_sts);
2075 rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
2076 if (rc)
2077 printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
2078 __func__, dev_id);
2079 } else {
2080 clear_bit(dev_id, &gpio_sts);
2081 msm_gpios_disable_free(curr->cfg_data, curr->size);
2082 }
2083}
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +05302084
2085static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
2086{
2087 int rc = 0;
2088 struct platform_device *pdev;
2089
2090 pdev = container_of(dv, struct platform_device, dev);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002091 msm_sdcc_setup_gpio(pdev->id, !!vdd);
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +05302092
2093 if (vdd == 0) {
2094 if (!vreg_sts)
2095 return 0;
2096
2097 clear_bit(pdev->id, &vreg_sts);
2098
2099 if (!vreg_sts) {
2100 rc = vreg_disable(vreg_mmc);
2101 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002102 printk(KERN_ERR "%s: return val: %d \n",
2103 __func__, rc);
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +05302104 }
2105 return 0;
2106 }
2107
2108 if (!vreg_sts) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002109 rc = vreg_set_level(vreg_mmc, PMIC_VREG_GP6_LEVEL);
2110 if (!rc)
2111 rc = vreg_enable(vreg_mmc);
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +05302112 if (rc)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002113 printk(KERN_ERR "%s: return val: %d \n",
2114 __func__, rc);
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +05302115 }
2116 set_bit(pdev->id, &vreg_sts);
2117 return 0;
2118}
2119
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002120#endif
2121#if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
2122 || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
2123 || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +05302124
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002125static int msm_sdcc_get_wpswitch(struct device *dv)
2126{
2127 void __iomem *wp_addr = 0;
2128 uint32_t ret = 0;
2129 struct platform_device *pdev;
2130
2131 if (!machine_is_qsd8x50_surf())
2132 return -1;
2133
2134 pdev = container_of(dv, struct platform_device, dev);
2135
2136 wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
2137 if (!wp_addr) {
2138 pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
2139 return -ENOMEM;
2140 }
2141
2142 ret = (readl(wp_addr) >> ((pdev->id - 1) << 1)) & (0x03);
2143 pr_info("%s: WP/CD Status for Slot %d = 0x%x \n", __func__,
2144 pdev->id, ret);
2145 iounmap(wp_addr);
2146 return ((ret == 0x02) ? 1 : 0);
2147
2148}
2149#endif
2150
2151#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
2152static struct mmc_platform_data qsd8x50_sdc1_data = {
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +05302153 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
2154 .translate_vdd = msm_sdcc_setup_power,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002155 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
2156 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002157 .msmsdcc_fmin = 144000,
2158 .msmsdcc_fmid = 25000000,
2159 .msmsdcc_fmax = 49152000,
2160 .nonremovable = 0,
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +05302161};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002162#endif
2163
2164#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
2165static struct mmc_platform_data qsd8x50_sdc2_data = {
2166 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
2167 .translate_vdd = msm_sdcc_setup_power,
2168 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
2169 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002170 .msmsdcc_fmin = 144000,
2171 .msmsdcc_fmid = 25000000,
2172 .msmsdcc_fmax = 49152000,
2173 .nonremovable = 1,
2174};
2175#endif
2176
2177#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
2178static struct mmc_platform_data qsd8x50_sdc3_data = {
2179 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
2180 .translate_vdd = msm_sdcc_setup_power,
2181#ifdef CONFIG_MMC_MSM_SDC3_8_BIT_SUPPORT
2182 .mmc_bus_width = MMC_CAP_8_BIT_DATA,
2183#else
2184 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
2185#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002186 .msmsdcc_fmin = 144000,
2187 .msmsdcc_fmid = 25000000,
2188 .msmsdcc_fmax = 49152000,
2189 .nonremovable = 0,
2190};
2191#endif
2192
2193#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
2194static struct mmc_platform_data qsd8x50_sdc4_data = {
2195 .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
2196 .translate_vdd = msm_sdcc_setup_power,
2197 .mmc_bus_width = MMC_CAP_4_BIT_DATA,
2198 .wpswitch = msm_sdcc_get_wpswitch,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002199 .msmsdcc_fmin = 144000,
2200 .msmsdcc_fmid = 25000000,
2201 .msmsdcc_fmax = 49152000,
2202 .nonremovable = 0,
2203};
2204#endif
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +05302205
2206static void __init qsd8x50_init_mmc(void)
2207{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002208 if (machine_is_qsd8x50_ffa())
2209 vreg_mmc = vreg_get(NULL, "gp6");
2210 else
2211 vreg_mmc = vreg_get(NULL, "gp5");
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +05302212
2213 if (IS_ERR(vreg_mmc)) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002214 printk(KERN_ERR "%s: vreg get failed (%ld)\n",
2215 __func__, PTR_ERR(vreg_mmc));
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +05302216 return;
2217 }
2218
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002219#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
2220 msm_add_sdcc(1, &qsd8x50_sdc1_data);
2221#endif
2222
2223 if (machine_is_qsd8x50_surf()) {
2224#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
2225 msm_add_sdcc(2, &qsd8x50_sdc2_data);
2226#endif
2227#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
2228 msm_add_sdcc(3, &qsd8x50_sdc3_data);
2229#endif
2230#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
2231 msm_add_sdcc(4, &qsd8x50_sdc4_data);
2232#endif
2233 }
2234
2235}
2236
2237static void __init qsd8x50_cfg_smc91x(void)
2238{
2239 int rc = 0;
2240
2241 if (machine_is_qsd8x50_surf()) {
2242 smc91x_resources[0].start = 0x70000300;
2243 smc91x_resources[0].end = 0x700003ff;
2244 smc91x_resources[1].start = MSM_GPIO_TO_INT(156);
2245 smc91x_resources[1].end = MSM_GPIO_TO_INT(156);
2246 } else if (machine_is_qsd8x50_ffa()) {
2247 smc91x_resources[0].start = 0x84000300;
2248 smc91x_resources[0].end = 0x840003ff;
2249 smc91x_resources[1].start = MSM_GPIO_TO_INT(87);
2250 smc91x_resources[1].end = MSM_GPIO_TO_INT(87);
2251
2252 rc = gpio_tlmm_config(GPIO_CFG(87, 0, GPIO_CFG_INPUT,
2253 GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
2254 GPIO_CFG_ENABLE);
2255 if (rc) {
2256 printk(KERN_ERR "%s: gpio_tlmm_config=%d\n",
2257 __func__, rc);
2258 }
2259 } else
2260 printk(KERN_ERR "%s: invalid machine type\n", __func__);
2261}
2262
2263static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
2264 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
2265 .idle_supported = 1,
2266 .suspend_supported = 1,
2267 .idle_enabled = 1,
2268 .suspend_enabled = 1,
2269 .latency = 8594,
2270 .residency = 23740,
2271 },
2272
2273 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
2274 .idle_supported = 1,
2275 .suspend_supported = 1,
2276 .idle_enabled = 1,
2277 .suspend_enabled = 1,
2278 .latency = 4594,
2279 .residency = 23740,
2280 },
2281
2282 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
2283 .idle_supported = 1,
2284 .suspend_supported = 1,
2285 .idle_enabled = 0,
2286 .suspend_enabled = 1,
2287 .latency = 443,
2288 .residency = 1098,
2289 },
2290
2291 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
2292 .idle_supported = 1,
2293 .suspend_supported = 1,
2294 .idle_enabled = 1,
2295 .suspend_enabled = 1,
2296 .latency = 2,
2297 .residency = 0,
2298 },
2299};
2300
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06002301static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
2302 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
2303 .v_addr = (unsigned int *)PAGE_OFFSET,
2304};
2305
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002306static void
2307msm_i2c_gpio_config(int iface, int config_type)
2308{
2309 int gpio_scl;
2310 int gpio_sda;
2311 if (iface) {
2312 gpio_scl = 60;
2313 gpio_sda = 61;
2314 } else {
2315 gpio_scl = 95;
2316 gpio_sda = 96;
2317 }
2318 if (config_type) {
2319 gpio_tlmm_config(GPIO_CFG(gpio_scl, 1, GPIO_CFG_INPUT,
2320 GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
2321 gpio_tlmm_config(GPIO_CFG(gpio_sda, 1, GPIO_CFG_INPUT,
2322 GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
2323 } else {
2324 gpio_tlmm_config(GPIO_CFG(gpio_scl, 0, GPIO_CFG_OUTPUT,
2325 GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
2326 gpio_tlmm_config(GPIO_CFG(gpio_sda, 0, GPIO_CFG_OUTPUT,
2327 GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
2328 }
2329}
2330
2331static struct msm_i2c_platform_data msm_i2c_pdata = {
2332 .clk_freq = 100000,
2333 .rsl_id = SMEM_SPINLOCK_I2C,
2334 .pri_clk = 95,
2335 .pri_dat = 96,
2336 .aux_clk = 60,
2337 .aux_dat = 61,
2338 .msm_i2c_config_gpio = msm_i2c_gpio_config,
2339};
2340
2341static void __init msm_device_i2c_init(void)
2342{
2343 if (gpio_request(95, "i2c_pri_clk"))
2344 pr_err("failed to request gpio i2c_pri_clk\n");
2345 if (gpio_request(96, "i2c_pri_dat"))
2346 pr_err("failed to request gpio i2c_pri_dat\n");
2347 if (gpio_request(60, "i2c_sec_clk"))
2348 pr_err("failed to request gpio i2c_sec_clk\n");
2349 if (gpio_request(61, "i2c_sec_dat"))
2350 pr_err("failed to request gpio i2c_sec_dat\n");
2351
2352 msm_i2c_pdata.rmutex = 1;
2353 msm_i2c_pdata.pm_lat =
2354 msm_pm_data[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN]
2355 .latency;
2356 msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
2357}
2358
2359static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
2360static int __init pmem_kernel_ebi1_size_setup(char *p)
2361{
2362 pmem_kernel_ebi1_size = memparse(p, NULL);
2363 return 0;
2364}
2365early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
2366
2367#ifdef CONFIG_KERNEL_PMEM_SMI_REGION
2368static unsigned pmem_kernel_smi_size = MSM_PMEM_SMIPOOL_SIZE;
2369static int __init pmem_kernel_smi_size_setup(char *p)
2370{
2371 pmem_kernel_smi_size = memparse(p, NULL);
2372
2373 /* Make sure that we don't allow more SMI memory then is
2374 available - the kernel mapping code has no way of knowing
2375 if it has gone over the edge */
2376
2377 if (pmem_kernel_smi_size > MSM_PMEM_SMIPOOL_SIZE)
2378 pmem_kernel_smi_size = MSM_PMEM_SMIPOOL_SIZE;
2379 return 0;
2380}
2381early_param("pmem_kernel_smi_size", pmem_kernel_smi_size_setup);
2382#endif
2383
2384static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
2385static int __init pmem_sf_size_setup(char *p)
2386{
2387 pmem_sf_size = memparse(p, NULL);
2388 return 0;
2389}
2390early_param("pmem_sf_size", pmem_sf_size_setup);
2391
2392static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
2393static int __init pmem_adsp_size_setup(char *p)
2394{
2395 pmem_adsp_size = memparse(p, NULL);
2396 return 0;
2397}
2398early_param("pmem_adsp_size", pmem_adsp_size_setup);
2399
2400
2401static unsigned audio_size = MSM_AUDIO_SIZE;
2402static int __init audio_size_setup(char *p)
2403{
2404 audio_size = memparse(p, NULL);
2405 return 0;
2406}
2407early_param("audio_size", audio_size_setup);
2408
2409static void __init qsd8x50_init(void)
2410{
Stephen Boydbb600ae2011-08-02 20:11:40 -07002411 msm_clock_init(&qds8x50_clock_init_data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002412 qsd8x50_cfg_smc91x();
Matt Wagantallbf430eb2012-03-22 11:45:49 -07002413 platform_device_register(&msm8x50_device_acpuclk);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002414
2415 msm_hsusb_pdata.swfi_latency =
2416 msm_pm_data
2417 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
2418 msm_device_hsusb_peripheral.dev.platform_data = &msm_hsusb_pdata;
2419
2420 msm_otg_pdata.swfi_latency =
2421 msm_pm_data
2422 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
2423 msm_device_otg.dev.platform_data = &msm_otg_pdata;
2424 msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
2425 msm_gadget_pdata.is_phy_status_timer_on = 1;
2426
2427#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
2428 msm_device_tsif.dev.platform_data = &tsif_platform_data;
2429#endif
2430 platform_add_devices(devices, ARRAY_SIZE(devices));
2431 msm_fb_add_devices();
2432#ifdef CONFIG_MSM_CAMERA
2433 config_camera_off_gpios(); /* might not be necessary */
2434#endif
2435 qsd8x50_init_usb();
2436 qsd8x50_init_mmc();
2437 bt_power_init();
2438 audio_gpio_init();
2439 msm_device_i2c_init();
2440 msm_qsd_spi_init();
2441 i2c_register_board_info(0, msm_i2c_board_info,
2442 ARRAY_SIZE(msm_i2c_board_info));
2443 spi_register_board_info(msm_spi_board_info,
2444 ARRAY_SIZE(msm_spi_board_info));
2445 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06002446 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Murali Nalajala2a0bbda2012-03-28 12:12:54 +05302447 msm_pm_register_irqs();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002448
2449#ifdef CONFIG_SURF_FFA_GPIO_KEYPAD
2450 if (machine_is_qsd8x50_ffa())
2451 platform_device_register(&keypad_device_8k_ffa);
2452 else
2453 platform_device_register(&keypad_device_surf);
2454#endif
2455}
2456
2457static void __init qsd8x50_allocate_memory_regions(void)
2458{
2459 void *addr;
2460 unsigned long size;
2461
2462 size = pmem_kernel_ebi1_size;
2463 if (size) {
2464 addr = alloc_bootmem_align(size, 0x100000);
2465 android_pmem_kernel_ebi1_pdata.size = size;
2466 pr_info("allocating %lu bytes at %p (%lx physical) for kernel"
2467 " ebi1 pmem arena\n", size, addr, __pa(addr));
2468 }
2469
2470#ifdef CONFIG_KERNEL_PMEM_SMI_REGION
2471 size = pmem_kernel_smi_size;
2472 if (size > MSM_PMEM_SMIPOOL_SIZE) {
2473 printk(KERN_ERR "pmem kernel smi arena size %lu is too big\n",
2474 size);
2475
2476 size = MSM_PMEM_SMIPOOL_SIZE;
2477 }
2478
2479 android_pmem_kernel_smi_pdata.size = size;
2480
2481 pr_info("allocating %lu bytes at %lx (%lx physical)"
2482 "for pmem kernel smi arena\n", size,
2483 (long unsigned int) MSM_PMEM_SMIPOOL_BASE,
2484 __pa(MSM_PMEM_SMIPOOL_BASE));
2485#endif
2486
2487 size = pmem_sf_size;
2488 if (size) {
2489 addr = alloc_bootmem(size);
2490 android_pmem_pdata.size = size;
2491 pr_info("allocating %lu bytes at %p (%lx physical) for sf "
2492 "pmem arena\n", size, addr, __pa(addr));
2493 }
2494
2495 size = pmem_adsp_size;
2496 if (size) {
2497 addr = alloc_bootmem(size);
2498 android_pmem_adsp_pdata.size = size;
2499 pr_info("allocating %lu bytes at %p (%lx physical) for adsp "
2500 "pmem arena\n", size, addr, __pa(addr));
2501 }
2502
2503
2504 size = MSM_FB_SIZE;
2505 addr = (void *)MSM_FB_BASE;
2506 msm_fb_resources[0].start = (unsigned long)addr;
2507 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
2508 pr_info("using %lu bytes of SMI at %lx physical for fb\n",
2509 size, (unsigned long)addr);
2510
2511 size = audio_size ? : MSM_AUDIO_SIZE;
2512 addr = alloc_bootmem(size);
2513 msm_audio_resources[0].start = __pa(addr);
2514 msm_audio_resources[0].end = msm_audio_resources[0].start + size - 1;
2515 pr_info("allocating %lu bytes at %p (%lx physical) for audio\n",
2516 size, addr, __pa(addr));
Sahitya Tummala8b4d95f2011-01-18 11:22:50 +05302517}
2518
Daniel Walkera32d2fe2010-02-25 11:38:39 -08002519static void __init qsd8x50_map_io(void)
2520{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002521 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Daniel Walkera32d2fe2010-02-25 11:38:39 -08002522 msm_map_qsd8x50_io();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002523 qsd8x50_allocate_memory_regions();
Jeff Ohlstein3a77f9f2011-09-06 14:50:20 -07002524 if (socinfo_init() < 0)
2525 printk(KERN_ERR "%s: socinfo_init() failed!\n",
2526 __func__);
Daniel Walkerd1c0d432010-05-05 07:17:31 -07002527}
2528
Daniel Walkera32d2fe2010-02-25 11:38:39 -08002529MACHINE_START(QSD8X50_SURF, "QCT QSD8X50 SURF")
Nicolas Pitref631dd42011-07-05 22:38:14 -04002530 .atag_offset = 0x100,
Daniel Walkera32d2fe2010-02-25 11:38:39 -08002531 .map_io = qsd8x50_map_io,
2532 .init_irq = qsd8x50_init_irq,
2533 .init_machine = qsd8x50_init,
2534 .timer = &msm_timer,
2535MACHINE_END
2536
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002537MACHINE_START(QSD8X50_FFA, "QCT QSD8X50 FFA")
Nicolas Pitref631dd42011-07-05 22:38:14 -04002538 .atag_offset = 0x100,
Daniel Walkera32d2fe2010-02-25 11:38:39 -08002539 .map_io = qsd8x50_map_io,
2540 .init_irq = qsd8x50_init_irq,
2541 .init_machine = qsd8x50_init,
2542 .timer = &msm_timer,
2543MACHINE_END