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