Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2008-2011, 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" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 57 | #include "pm.h" |
Maheshkumar Sivasubramanian | 8ccc16e | 2011-10-25 15:59:57 -0600 | [diff] [blame] | 58 | #include "pm-boot.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 59 | #include "proc_comm.h" |
| 60 | #ifdef CONFIG_USB_ANDROID |
| 61 | #include <linux/usb/android_composite.h> |
| 62 | #endif |
Daniel Walker | a32d2fe | 2010-02-25 11:38:39 -0800 | [diff] [blame] | 63 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 64 | #define TOUCHPAD_SUSPEND 34 |
| 65 | #define TOUCHPAD_IRQ 38 |
Daniel Walker | a32d2fe | 2010-02-25 11:38:39 -0800 | [diff] [blame] | 66 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 67 | #define MSM_PMEM_SF_SIZE 0x1700000 |
Gregory Bean | 5d73c53 | 2010-09-29 13:46:45 -0700 | [diff] [blame] | 68 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 69 | #define SMEM_SPINLOCK_I2C "S:6" |
| 70 | |
| 71 | #define MSM_PMEM_ADSP_SIZE 0x2A05000 |
| 72 | #define MSM_FB_SIZE 0x2EE000 |
| 73 | #define MSM_AUDIO_SIZE 0x80000 |
| 74 | |
| 75 | #ifdef CONFIG_MSM_SOC_REV_A |
| 76 | #define MSM_SMI_BASE 0xE0000000 |
| 77 | #else |
| 78 | #define MSM_SMI_BASE 0x00000000 |
| 79 | #endif |
| 80 | |
| 81 | #define MSM_SHARED_RAM_PHYS (MSM_SMI_BASE + 0x00100000) |
| 82 | |
| 83 | #define MSM_PMEM_SMI_BASE (MSM_SMI_BASE + 0x02B00000) |
| 84 | #define MSM_PMEM_SMI_SIZE 0x01500000 |
| 85 | |
| 86 | #define MSM_FB_BASE MSM_PMEM_SMI_BASE |
| 87 | #define MSM_PMEM_SMIPOOL_BASE (MSM_FB_BASE + MSM_FB_SIZE) |
| 88 | #define MSM_PMEM_SMIPOOL_SIZE (MSM_PMEM_SMI_SIZE - MSM_FB_SIZE) |
| 89 | |
| 90 | #define PMEM_KERNEL_EBI1_SIZE 0x28000 |
| 91 | |
| 92 | #define PMIC_VREG_WLAN_LEVEL 2600 |
| 93 | #define PMIC_VREG_GP6_LEVEL 2900 |
| 94 | |
| 95 | #define FPGA_SDCC_STATUS 0x70000280 |
| 96 | |
Stephen Boyd | 7c63ded | 2010-12-20 15:00:17 -0800 | [diff] [blame] | 97 | static struct resource smc91x_resources[] = { |
Gregory Bean | 5d73c53 | 2010-09-29 13:46:45 -0700 | [diff] [blame] | 98 | [0] = { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 99 | .flags = IORESOURCE_MEM, |
Gregory Bean | 5d73c53 | 2010-09-29 13:46:45 -0700 | [diff] [blame] | 100 | }, |
| 101 | [1] = { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 102 | .flags = IORESOURCE_IRQ, |
Gregory Bean | 5d73c53 | 2010-09-29 13:46:45 -0700 | [diff] [blame] | 103 | }, |
| 104 | }; |
| 105 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 106 | #ifdef CONFIG_USB_FUNCTION |
| 107 | static struct usb_mass_storage_platform_data usb_mass_storage_pdata = { |
| 108 | .nluns = 0x02, |
| 109 | .buf_size = 16384, |
| 110 | .vendor = "GOOGLE", |
| 111 | .product = "Mass storage", |
| 112 | .release = 0xffff, |
| 113 | }; |
| 114 | |
| 115 | static struct platform_device mass_storage_device = { |
| 116 | .name = "usb_mass_storage", |
| 117 | .id = -1, |
| 118 | .dev = { |
| 119 | .platform_data = &usb_mass_storage_pdata, |
| 120 | }, |
| 121 | }; |
| 122 | #endif |
| 123 | |
| 124 | #ifdef CONFIG_USB_ANDROID |
| 125 | static char *usb_functions_default[] = { |
| 126 | "diag", |
| 127 | "modem", |
| 128 | "nmea", |
| 129 | "rmnet", |
| 130 | "usb_mass_storage", |
| 131 | }; |
| 132 | |
| 133 | static char *usb_functions_default_adb[] = { |
| 134 | "diag", |
| 135 | "adb", |
| 136 | "modem", |
| 137 | "nmea", |
| 138 | "rmnet", |
| 139 | "usb_mass_storage", |
| 140 | }; |
| 141 | |
| 142 | static char *usb_functions_rndis[] = { |
| 143 | "rndis", |
| 144 | }; |
| 145 | |
| 146 | static char *usb_functions_rndis_adb[] = { |
| 147 | "rndis", |
| 148 | "adb", |
| 149 | }; |
| 150 | |
| 151 | static char *usb_functions_all[] = { |
| 152 | #ifdef CONFIG_USB_ANDROID_RNDIS |
| 153 | "rndis", |
| 154 | #endif |
| 155 | #ifdef CONFIG_USB_ANDROID_DIAG |
| 156 | "diag", |
| 157 | #endif |
| 158 | "adb", |
| 159 | #ifdef CONFIG_USB_F_SERIAL |
| 160 | "modem", |
| 161 | "nmea", |
| 162 | #endif |
| 163 | #ifdef CONFIG_USB_ANDROID_RMNET |
| 164 | "rmnet", |
| 165 | #endif |
| 166 | "usb_mass_storage", |
| 167 | #ifdef CONFIG_USB_ANDROID_ACM |
| 168 | "acm", |
| 169 | #endif |
| 170 | }; |
| 171 | |
| 172 | static struct android_usb_product usb_products[] = { |
| 173 | { |
| 174 | .product_id = 0x9026, |
| 175 | .num_functions = ARRAY_SIZE(usb_functions_default), |
| 176 | .functions = usb_functions_default, |
| 177 | }, |
| 178 | { |
| 179 | .product_id = 0x9025, |
| 180 | .num_functions = ARRAY_SIZE(usb_functions_default_adb), |
| 181 | .functions = usb_functions_default_adb, |
| 182 | }, |
| 183 | { |
| 184 | .product_id = 0xf00e, |
| 185 | .num_functions = ARRAY_SIZE(usb_functions_rndis), |
| 186 | .functions = usb_functions_rndis, |
| 187 | }, |
| 188 | { |
| 189 | .product_id = 0x9024, |
| 190 | .num_functions = ARRAY_SIZE(usb_functions_rndis_adb), |
| 191 | .functions = usb_functions_rndis_adb, |
| 192 | }, |
| 193 | }; |
| 194 | |
| 195 | static struct usb_mass_storage_platform_data mass_storage_pdata = { |
| 196 | .nluns = 1, |
| 197 | .vendor = "Qualcomm Incorporated", |
| 198 | .product = "Mass storage", |
| 199 | .release = 0x0100, |
| 200 | }; |
| 201 | |
| 202 | static struct platform_device usb_mass_storage_device = { |
| 203 | .name = "usb_mass_storage", |
| 204 | .id = -1, |
| 205 | .dev = { |
| 206 | .platform_data = &mass_storage_pdata, |
| 207 | }, |
| 208 | }; |
| 209 | |
| 210 | static struct usb_ether_platform_data rndis_pdata = { |
| 211 | /* ethaddr is filled by board_serialno_setup */ |
| 212 | .vendorID = 0x05C6, |
| 213 | .vendorDescr = "Qualcomm Incorporated", |
| 214 | }; |
| 215 | |
| 216 | static struct platform_device rndis_device = { |
| 217 | .name = "rndis", |
| 218 | .id = -1, |
| 219 | .dev = { |
| 220 | .platform_data = &rndis_pdata, |
| 221 | }, |
| 222 | }; |
| 223 | |
| 224 | static struct android_usb_platform_data android_usb_pdata = { |
| 225 | .vendor_id = 0x05C6, |
| 226 | .product_id = 0x9026, |
| 227 | .version = 0x0100, |
| 228 | .product_name = "Qualcomm HSUSB Device", |
| 229 | .manufacturer_name = "Qualcomm Incorporated", |
| 230 | .num_products = ARRAY_SIZE(usb_products), |
| 231 | .products = usb_products, |
| 232 | .num_functions = ARRAY_SIZE(usb_functions_all), |
| 233 | .functions = usb_functions_all, |
| 234 | .serial_number = "1234567890ABCDEF", |
| 235 | }; |
| 236 | |
| 237 | static struct platform_device android_usb_device = { |
| 238 | .name = "android_usb", |
| 239 | .id = -1, |
| 240 | .dev = { |
| 241 | .platform_data = &android_usb_pdata, |
| 242 | }, |
| 243 | }; |
| 244 | |
| 245 | static int __init board_serialno_setup(char *serialno) |
| 246 | { |
| 247 | int i; |
| 248 | char *src = serialno; |
| 249 | |
| 250 | /* create a fake MAC address from our serial number. |
| 251 | * first byte is 0x02 to signify locally administered. |
| 252 | */ |
| 253 | rndis_pdata.ethaddr[0] = 0x02; |
| 254 | for (i = 0; *src; i++) { |
| 255 | /* XOR the USB serial across the remaining bytes */ |
| 256 | rndis_pdata.ethaddr[i % (ETH_ALEN - 1) + 1] ^= *src++; |
| 257 | } |
| 258 | |
| 259 | android_usb_pdata.serial_number = serialno; |
| 260 | return 1; |
| 261 | } |
| 262 | __setup("androidboot.serialno=", board_serialno_setup); |
| 263 | #endif |
| 264 | |
Stephen Boyd | 7c63ded | 2010-12-20 15:00:17 -0800 | [diff] [blame] | 265 | static struct platform_device smc91x_device = { |
Gregory Bean | 5d73c53 | 2010-09-29 13:46:45 -0700 | [diff] [blame] | 266 | .name = "smc91x", |
| 267 | .id = 0, |
| 268 | .num_resources = ARRAY_SIZE(smc91x_resources), |
| 269 | .resource = smc91x_resources, |
| 270 | }; |
| 271 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 272 | #ifdef CONFIG_USB_FUNCTION |
| 273 | static struct usb_function_map usb_functions_map[] = { |
| 274 | {"diag", 0}, |
| 275 | {"adb", 1}, |
| 276 | {"modem", 2}, |
| 277 | {"nmea", 3}, |
| 278 | {"mass_storage", 4}, |
| 279 | {"ethernet", 5}, |
| 280 | }; |
| 281 | |
| 282 | /* dynamic composition */ |
| 283 | static struct usb_composition usb_func_composition[] = { |
| 284 | { |
| 285 | .product_id = 0x9012, |
| 286 | .functions = 0x5, /* 0101 */ |
| 287 | }, |
| 288 | |
| 289 | { |
| 290 | .product_id = 0x9013, |
| 291 | .functions = 0x15, /* 10101 */ |
| 292 | }, |
| 293 | |
| 294 | { |
| 295 | .product_id = 0x9014, |
| 296 | .functions = 0x30, /* 110000 */ |
| 297 | }, |
| 298 | |
| 299 | { |
| 300 | .product_id = 0x9015, |
| 301 | .functions = 0x12, /* 10010 */ |
| 302 | }, |
| 303 | |
| 304 | { |
| 305 | .product_id = 0x9016, |
| 306 | .functions = 0xD, /* 01101 */ |
| 307 | }, |
| 308 | |
| 309 | { |
| 310 | .product_id = 0x9017, |
| 311 | .functions = 0x1D, /* 11101 */ |
| 312 | }, |
| 313 | |
| 314 | { |
| 315 | .product_id = 0xF000, |
| 316 | .functions = 0x10, /* 10000 */ |
| 317 | }, |
| 318 | |
| 319 | { |
| 320 | .product_id = 0xF009, |
| 321 | .functions = 0x20, /* 100000 */ |
| 322 | }, |
| 323 | |
| 324 | { |
| 325 | .product_id = 0x9018, |
| 326 | .functions = 0x1F, /* 011111 */ |
| 327 | }, |
| 328 | |
| 329 | { |
| 330 | .product_id = 0x901A, |
| 331 | .functions = 0x0F, /* 01111 */ |
| 332 | }, |
| 333 | }; |
| 334 | #endif |
| 335 | |
| 336 | static struct msm_handset_platform_data hs_platform_data = { |
| 337 | .hs_name = "8k_handset", |
| 338 | .pwr_key_delay_ms = 500, /* 0 will disable end key */ |
| 339 | }; |
| 340 | |
| 341 | static struct platform_device hs_device = { |
| 342 | .name = "msm-handset", |
| 343 | .id = -1, |
| 344 | .dev = { |
| 345 | .platform_data = &hs_platform_data, |
| 346 | }, |
| 347 | }; |
| 348 | |
| 349 | #ifdef CONFIG_USB_FS_HOST |
| 350 | static struct msm_gpio fsusb_config[] = { |
| 351 | { GPIO_CFG(139, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "fs_dat" }, |
| 352 | { GPIO_CFG(140, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "fs_se0" }, |
| 353 | { GPIO_CFG(141, 3, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "fs_oe_n" }, |
| 354 | }; |
| 355 | |
| 356 | static int fsusb_gpio_init(void) |
Gregory Bean | 5d73c53 | 2010-09-29 13:46:45 -0700 | [diff] [blame] | 357 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 358 | return msm_gpios_request(fsusb_config, ARRAY_SIZE(fsusb_config)); |
| 359 | } |
| 360 | |
| 361 | static void msm_fsusb_setup_gpio(unsigned int enable) |
| 362 | { |
| 363 | if (enable) |
| 364 | msm_gpios_enable(fsusb_config, ARRAY_SIZE(fsusb_config)); |
| 365 | else |
| 366 | msm_gpios_disable(fsusb_config, ARRAY_SIZE(fsusb_config)); |
| 367 | |
| 368 | } |
| 369 | #endif |
| 370 | |
| 371 | #define MSM_USB_BASE ((unsigned)addr) |
| 372 | |
| 373 | static struct msm_hsusb_platform_data msm_hsusb_pdata = { |
| 374 | #ifdef CONFIG_USB_FUNCTION |
| 375 | .version = 0x0100, |
| 376 | .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_180NM), |
| 377 | .vendor_id = 0x5c6, |
| 378 | .product_name = "Qualcomm HSUSB Device", |
| 379 | .serial_number = "1234567890ABCDEF", |
| 380 | .manufacturer_name = "Qualcomm Incorporated", |
| 381 | .compositions = usb_func_composition, |
| 382 | .num_compositions = ARRAY_SIZE(usb_func_composition), |
| 383 | .function_map = usb_functions_map, |
| 384 | .num_functions = ARRAY_SIZE(usb_functions_map), |
| 385 | .config_gpio = NULL, |
| 386 | |
| 387 | #endif |
| 388 | }; |
| 389 | |
| 390 | static struct vreg *vreg_usb; |
| 391 | static void msm_hsusb_vbus_power(unsigned phy_info, int on) |
| 392 | { |
| 393 | |
| 394 | switch (PHY_TYPE(phy_info)) { |
| 395 | case USB_PHY_INTEGRATED: |
| 396 | if (on) |
| 397 | msm_hsusb_vbus_powerup(); |
| 398 | else |
| 399 | msm_hsusb_vbus_shutdown(); |
| 400 | break; |
| 401 | case USB_PHY_SERIAL_PMIC: |
| 402 | if (on) |
| 403 | vreg_enable(vreg_usb); |
| 404 | else |
| 405 | vreg_disable(vreg_usb); |
| 406 | break; |
| 407 | default: |
| 408 | pr_err("%s: undefined phy type ( %X ) \n", __func__, |
| 409 | phy_info); |
| 410 | } |
| 411 | |
| 412 | } |
| 413 | |
| 414 | static struct msm_usb_host_platform_data msm_usb_host_pdata = { |
| 415 | .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_180NM), |
| 416 | }; |
| 417 | |
| 418 | #ifdef CONFIG_USB_FS_HOST |
| 419 | static struct msm_usb_host_platform_data msm_usb_host2_pdata = { |
| 420 | .phy_info = USB_PHY_SERIAL_PMIC, |
| 421 | .config_gpio = msm_fsusb_setup_gpio, |
| 422 | .vbus_power = msm_hsusb_vbus_power, |
| 423 | }; |
| 424 | #endif |
| 425 | |
| 426 | static struct android_pmem_platform_data android_pmem_kernel_ebi1_pdata = { |
| 427 | .name = PMEM_KERNEL_EBI1_DATA_NAME, |
| 428 | /* if no allocator_type, defaults to PMEM_ALLOCATORTYPE_BITMAP, |
| 429 | * the only valid choice at this time. The board structure is |
| 430 | * set to all zeros by the C runtime initialization and that is now |
| 431 | * the enum value of PMEM_ALLOCATORTYPE_BITMAP, now forced to 0 in |
| 432 | * include/linux/android_pmem.h. |
| 433 | */ |
| 434 | .cached = 0, |
| 435 | }; |
| 436 | |
| 437 | #ifdef CONFIG_KERNEL_PMEM_SMI_REGION |
| 438 | |
| 439 | static struct android_pmem_platform_data android_pmem_kernel_smi_pdata = { |
| 440 | .name = PMEM_KERNEL_SMI_DATA_NAME, |
| 441 | /* if no allocator_type, defaults to PMEM_ALLOCATORTYPE_BITMAP, |
| 442 | * the only valid choice at this time. The board structure is |
| 443 | * set to all zeros by the C runtime initialization and that is now |
| 444 | * the enum value of PMEM_ALLOCATORTYPE_BITMAP, now forced to 0 in |
| 445 | * include/linux/android_pmem.h. |
| 446 | */ |
| 447 | .cached = 0, |
| 448 | }; |
| 449 | |
| 450 | #endif |
| 451 | |
| 452 | static struct android_pmem_platform_data android_pmem_pdata = { |
| 453 | .name = "pmem", |
| 454 | .allocator_type = PMEM_ALLOCATORTYPE_ALLORNOTHING, |
| 455 | .cached = 1, |
| 456 | }; |
| 457 | |
| 458 | static struct android_pmem_platform_data android_pmem_adsp_pdata = { |
| 459 | .name = "pmem_adsp", |
| 460 | .allocator_type = PMEM_ALLOCATORTYPE_BITMAP, |
| 461 | .cached = 0, |
| 462 | }; |
| 463 | |
| 464 | static struct android_pmem_platform_data android_pmem_smipool_pdata = { |
| 465 | .name = "pmem_smipool", |
| 466 | .size = MSM_PMEM_SMIPOOL_SIZE, |
| 467 | .allocator_type = PMEM_ALLOCATORTYPE_BITMAP, |
| 468 | .cached = 0, |
| 469 | }; |
| 470 | |
| 471 | |
| 472 | static struct platform_device android_pmem_device = { |
| 473 | .name = "android_pmem", |
| 474 | .id = 0, |
| 475 | .dev = { .platform_data = &android_pmem_pdata }, |
| 476 | }; |
| 477 | |
| 478 | static struct platform_device android_pmem_adsp_device = { |
| 479 | .name = "android_pmem", |
| 480 | .id = 1, |
| 481 | .dev = { .platform_data = &android_pmem_adsp_pdata }, |
| 482 | }; |
| 483 | |
| 484 | static struct platform_device android_pmem_smipool_device = { |
| 485 | .name = "android_pmem", |
| 486 | .id = 2, |
| 487 | .dev = { .platform_data = &android_pmem_smipool_pdata }, |
| 488 | }; |
| 489 | |
| 490 | |
| 491 | static struct platform_device android_pmem_kernel_ebi1_device = { |
| 492 | .name = "android_pmem", |
| 493 | .id = 3, |
| 494 | .dev = { .platform_data = &android_pmem_kernel_ebi1_pdata }, |
| 495 | }; |
| 496 | |
| 497 | #ifdef CONFIG_KERNEL_PMEM_SMI_REGION |
| 498 | static struct platform_device android_pmem_kernel_smi_device = { |
| 499 | .name = "android_pmem", |
| 500 | .id = 4, |
| 501 | .dev = { .platform_data = &android_pmem_kernel_smi_pdata }, |
| 502 | }; |
| 503 | #endif |
| 504 | |
| 505 | static struct resource msm_fb_resources[] = { |
| 506 | { |
| 507 | .flags = IORESOURCE_DMA, |
| 508 | } |
| 509 | }; |
| 510 | |
| 511 | static int msm_fb_detect_panel(const char *name) |
| 512 | { |
| 513 | int ret = -EPERM; |
| 514 | |
| 515 | if (machine_is_qsd8x50_ffa()) { |
| 516 | if (!strncmp(name, "mddi_toshiba_wvga_pt", 20)) |
| 517 | ret = 0; |
| 518 | else |
| 519 | ret = -ENODEV; |
| 520 | } else if ((machine_is_qsd8x50_surf()) |
| 521 | && !strcmp(name, "lcdc_external")) |
| 522 | ret = 0; |
| 523 | |
| 524 | return ret; |
| 525 | } |
| 526 | |
| 527 | static struct msm_fb_platform_data msm_fb_pdata = { |
| 528 | .detect_client = msm_fb_detect_panel, |
| 529 | }; |
| 530 | |
| 531 | static struct platform_device msm_fb_device = { |
| 532 | .name = "msm_fb", |
| 533 | .id = 0, |
| 534 | .num_resources = ARRAY_SIZE(msm_fb_resources), |
| 535 | .resource = msm_fb_resources, |
| 536 | .dev = { |
| 537 | .platform_data = &msm_fb_pdata, |
| 538 | } |
| 539 | }; |
| 540 | |
| 541 | static struct msm_gpio bma_spi_gpio_config_data[] = { |
| 542 | { GPIO_CFG(22, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "bma_irq" }, |
| 543 | }; |
| 544 | |
| 545 | static int msm_bma_gpio_setup(struct device *dev) |
| 546 | { |
| 547 | int rc; |
| 548 | |
| 549 | rc = msm_gpios_request_enable(bma_spi_gpio_config_data, |
| 550 | ARRAY_SIZE(bma_spi_gpio_config_data)); |
| 551 | |
| 552 | return rc; |
| 553 | } |
| 554 | |
| 555 | static void msm_bma_gpio_teardown(struct device *dev) |
| 556 | { |
| 557 | msm_gpios_disable_free(bma_spi_gpio_config_data, |
| 558 | ARRAY_SIZE(bma_spi_gpio_config_data)); |
| 559 | } |
| 560 | |
| 561 | static struct bma150_platform_data bma_pdata = { |
| 562 | .setup = msm_bma_gpio_setup, |
| 563 | .teardown = msm_bma_gpio_teardown, |
| 564 | }; |
| 565 | |
| 566 | static struct resource qsd_spi_resources[] = { |
| 567 | { |
| 568 | .name = "spi_irq_in", |
| 569 | .start = INT_SPI_INPUT, |
| 570 | .end = INT_SPI_INPUT, |
| 571 | .flags = IORESOURCE_IRQ, |
| 572 | }, |
| 573 | { |
| 574 | .name = "spi_irq_out", |
| 575 | .start = INT_SPI_OUTPUT, |
| 576 | .end = INT_SPI_OUTPUT, |
| 577 | .flags = IORESOURCE_IRQ, |
| 578 | }, |
| 579 | { |
| 580 | .name = "spi_irq_err", |
| 581 | .start = INT_SPI_ERROR, |
| 582 | .end = INT_SPI_ERROR, |
| 583 | .flags = IORESOURCE_IRQ, |
| 584 | }, |
| 585 | { |
| 586 | .name = "spi_base", |
| 587 | .start = 0xA1200000, |
| 588 | .end = 0xA1200000 + SZ_4K - 1, |
| 589 | .flags = IORESOURCE_MEM, |
| 590 | }, |
| 591 | { |
| 592 | .name = "spidm_channels", |
| 593 | .flags = IORESOURCE_DMA, |
| 594 | }, |
| 595 | { |
| 596 | .name = "spidm_crci", |
| 597 | .flags = IORESOURCE_DMA, |
| 598 | }, |
| 599 | }; |
| 600 | |
| 601 | static struct platform_device qsd_device_spi = { |
| 602 | .name = "spi_qsd", |
| 603 | .id = 0, |
| 604 | .num_resources = ARRAY_SIZE(qsd_spi_resources), |
| 605 | .resource = qsd_spi_resources, |
| 606 | }; |
| 607 | |
| 608 | static struct spi_board_info msm_spi_board_info[] __initdata = { |
| 609 | { |
| 610 | .modalias = "bma150", |
| 611 | .mode = SPI_MODE_3, |
| 612 | .irq = MSM_GPIO_TO_INT(22), |
| 613 | .bus_num = 0, |
| 614 | .chip_select = 0, |
| 615 | .max_speed_hz = 10000000, |
| 616 | .platform_data = &bma_pdata, |
| 617 | }, |
| 618 | }; |
| 619 | |
| 620 | #define CT_CSR_PHYS 0xA8700000 |
| 621 | #define TCSR_SPI_MUX (ct_csr_base + 0x54) |
| 622 | static int msm_qsd_spi_dma_config(void) |
| 623 | { |
| 624 | void __iomem *ct_csr_base = 0; |
| 625 | u32 spi_mux; |
| 626 | int ret = 0; |
| 627 | |
| 628 | ct_csr_base = ioremap(CT_CSR_PHYS, PAGE_SIZE); |
| 629 | if (!ct_csr_base) { |
| 630 | pr_err("%s: Could not remap %x\n", __func__, CT_CSR_PHYS); |
| 631 | return -1; |
| 632 | } |
| 633 | |
| 634 | spi_mux = readl(TCSR_SPI_MUX); |
| 635 | switch (spi_mux) { |
| 636 | case (1): |
| 637 | qsd_spi_resources[4].start = DMOV_HSUART1_RX_CHAN; |
| 638 | qsd_spi_resources[4].end = DMOV_HSUART1_TX_CHAN; |
| 639 | qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI; |
| 640 | qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI; |
| 641 | break; |
| 642 | case (2): |
| 643 | qsd_spi_resources[4].start = DMOV_HSUART2_RX_CHAN; |
| 644 | qsd_spi_resources[4].end = DMOV_HSUART2_TX_CHAN; |
| 645 | qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI; |
| 646 | qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI; |
| 647 | break; |
| 648 | case (3): |
| 649 | qsd_spi_resources[4].start = DMOV_CE_OUT_CHAN; |
| 650 | qsd_spi_resources[4].end = DMOV_CE_IN_CHAN; |
| 651 | qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI; |
| 652 | qsd_spi_resources[5].end = DMOV_CE_IN_CRCI; |
| 653 | break; |
| 654 | default: |
| 655 | ret = -1; |
| 656 | } |
| 657 | |
| 658 | iounmap(ct_csr_base); |
| 659 | return ret; |
| 660 | } |
| 661 | |
| 662 | static struct msm_gpio qsd_spi_gpio_config_data[] = { |
| 663 | { GPIO_CFG(17, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" }, |
| 664 | { GPIO_CFG(18, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" }, |
| 665 | { GPIO_CFG(19, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" }, |
| 666 | { GPIO_CFG(20, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" }, |
| 667 | { GPIO_CFG(21, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "spi_pwr" }, |
| 668 | }; |
| 669 | |
| 670 | static int msm_qsd_spi_gpio_config(void) |
| 671 | { |
| 672 | int rc; |
| 673 | |
| 674 | rc = msm_gpios_request_enable(qsd_spi_gpio_config_data, |
| 675 | ARRAY_SIZE(qsd_spi_gpio_config_data)); |
| 676 | if (rc) |
| 677 | return rc; |
| 678 | |
| 679 | /* Set direction for SPI_PWR */ |
| 680 | gpio_direction_output(21, 1); |
| 681 | |
| 682 | return 0; |
| 683 | } |
| 684 | |
| 685 | static void msm_qsd_spi_gpio_release(void) |
| 686 | { |
| 687 | msm_gpios_disable_free(qsd_spi_gpio_config_data, |
| 688 | ARRAY_SIZE(qsd_spi_gpio_config_data)); |
| 689 | } |
| 690 | |
| 691 | static struct msm_spi_platform_data qsd_spi_pdata = { |
| 692 | .max_clock_speed = 19200000, |
| 693 | .gpio_config = msm_qsd_spi_gpio_config, |
| 694 | .gpio_release = msm_qsd_spi_gpio_release, |
| 695 | .dma_config = msm_qsd_spi_dma_config, |
| 696 | }; |
| 697 | |
| 698 | static void __init msm_qsd_spi_init(void) |
| 699 | { |
| 700 | qsd_device_spi.dev.platform_data = &qsd_spi_pdata; |
| 701 | } |
| 702 | |
| 703 | static int mddi_toshiba_pmic_bl(int level) |
| 704 | { |
| 705 | int ret = -EPERM; |
| 706 | |
| 707 | if (machine_is_qsd8x50_ffa()) { |
| 708 | ret = pmic_set_led_intensity(LED_LCD, level); |
| 709 | |
| 710 | if (ret) |
| 711 | printk(KERN_WARNING "%s: can't set lcd backlight!\n", |
| 712 | __func__); |
| 713 | } |
| 714 | |
| 715 | return ret; |
| 716 | } |
| 717 | |
| 718 | static struct msm_panel_common_pdata mddi_toshiba_pdata = { |
| 719 | .pmic_backlight = mddi_toshiba_pmic_bl, |
| 720 | }; |
| 721 | |
| 722 | static struct platform_device mddi_toshiba_device = { |
| 723 | .name = "mddi_toshiba", |
| 724 | .id = 0, |
| 725 | .dev = { |
| 726 | .platform_data = &mddi_toshiba_pdata, |
| 727 | } |
| 728 | }; |
| 729 | |
| 730 | static void msm_fb_vreg_config(const char *name, int on) |
| 731 | { |
| 732 | struct vreg *vreg; |
| 733 | int ret = 0; |
| 734 | |
| 735 | vreg = vreg_get(NULL, name); |
| 736 | if (IS_ERR(vreg)) { |
| 737 | printk(KERN_ERR "%s: vreg_get(%s) failed (%ld)\n", |
| 738 | __func__, name, PTR_ERR(vreg)); |
| 739 | return; |
| 740 | } |
| 741 | |
| 742 | ret = (on) ? vreg_enable(vreg) : vreg_disable(vreg); |
| 743 | if (ret) |
| 744 | printk(KERN_ERR "%s: %s(%s) failed!\n", |
| 745 | __func__, (on) ? "vreg_enable" : "vreg_disable", name); |
| 746 | } |
| 747 | |
| 748 | #define MDDI_RST_OUT_GPIO 100 |
| 749 | |
| 750 | static int mddi_power_save_on; |
| 751 | static int msm_fb_mddi_power_save(int on) |
| 752 | { |
| 753 | int flag_on = !!on; |
| 754 | int ret = 0; |
| 755 | |
| 756 | |
| 757 | if (mddi_power_save_on == flag_on) |
| 758 | return ret; |
| 759 | |
| 760 | mddi_power_save_on = flag_on; |
| 761 | |
| 762 | if (!flag_on && machine_is_qsd8x50_ffa()) { |
| 763 | gpio_set_value(MDDI_RST_OUT_GPIO, 0); |
| 764 | mdelay(1); |
| 765 | } |
| 766 | |
| 767 | ret = pmic_lp_mode_control(flag_on ? OFF_CMD : ON_CMD, |
| 768 | PM_VREG_LP_MSME2_ID); |
| 769 | if (ret) |
| 770 | printk(KERN_ERR "%s: pmic_lp_mode_control failed!\n", __func__); |
| 771 | |
| 772 | msm_fb_vreg_config("gp5", flag_on); |
| 773 | msm_fb_vreg_config("boost", flag_on); |
| 774 | |
| 775 | if (flag_on && machine_is_qsd8x50_ffa()) { |
| 776 | gpio_set_value(MDDI_RST_OUT_GPIO, 0); |
| 777 | mdelay(1); |
| 778 | gpio_set_value(MDDI_RST_OUT_GPIO, 1); |
| 779 | gpio_set_value(MDDI_RST_OUT_GPIO, 1); |
| 780 | mdelay(1); |
| 781 | } |
| 782 | |
| 783 | return ret; |
| 784 | } |
| 785 | |
| 786 | static int msm_fb_mddi_sel_clk(u32 *clk_rate) |
| 787 | { |
| 788 | *clk_rate *= 2; |
| 789 | return 0; |
| 790 | } |
| 791 | |
| 792 | static struct mddi_platform_data mddi_pdata = { |
| 793 | .mddi_power_save = msm_fb_mddi_power_save, |
| 794 | .mddi_sel_clk = msm_fb_mddi_sel_clk, |
| 795 | }; |
| 796 | |
| 797 | static struct msm_panel_common_pdata mdp_pdata = { |
| 798 | .gpio = 98, |
Ravishangar Kalyanam | 07ef788 | 2011-08-09 15:50:48 -0700 | [diff] [blame] | 799 | .mdp_rev = MDP_REV_31, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 800 | }; |
| 801 | |
| 802 | static void __init msm_fb_add_devices(void) |
| 803 | { |
| 804 | msm_fb_register_device("mdp", &mdp_pdata); |
| 805 | msm_fb_register_device("pmdh", &mddi_pdata); |
| 806 | msm_fb_register_device("emdh", &mddi_pdata); |
| 807 | msm_fb_register_device("tvenc", 0); |
| 808 | msm_fb_register_device("lcdc", 0); |
| 809 | } |
| 810 | |
| 811 | static struct resource msm_audio_resources[] = { |
| 812 | { |
| 813 | .flags = IORESOURCE_DMA, |
| 814 | }, |
| 815 | { |
| 816 | .name = "aux_pcm_dout", |
| 817 | .start = 68, |
| 818 | .end = 68, |
| 819 | .flags = IORESOURCE_IO, |
| 820 | }, |
| 821 | { |
| 822 | .name = "aux_pcm_din", |
| 823 | .start = 69, |
| 824 | .end = 69, |
| 825 | .flags = IORESOURCE_IO, |
| 826 | }, |
| 827 | { |
| 828 | .name = "aux_pcm_syncout", |
| 829 | .start = 70, |
| 830 | .end = 70, |
| 831 | .flags = IORESOURCE_IO, |
| 832 | }, |
| 833 | { |
| 834 | .name = "aux_pcm_clkin_a", |
| 835 | .start = 71, |
| 836 | .end = 71, |
| 837 | .flags = IORESOURCE_IO, |
| 838 | }, |
| 839 | { |
| 840 | .name = "sdac_din", |
| 841 | .start = 144, |
| 842 | .end = 144, |
| 843 | .flags = IORESOURCE_IO, |
| 844 | }, |
| 845 | { |
| 846 | .name = "sdac_dout", |
| 847 | .start = 145, |
| 848 | .end = 145, |
| 849 | .flags = IORESOURCE_IO, |
| 850 | }, |
| 851 | { |
| 852 | .name = "sdac_wsout", |
| 853 | .start = 143, |
| 854 | .end = 143, |
| 855 | .flags = IORESOURCE_IO, |
| 856 | }, |
| 857 | { |
| 858 | .name = "cc_i2s_clk", |
| 859 | .start = 142, |
| 860 | .end = 142, |
| 861 | .flags = IORESOURCE_IO, |
| 862 | }, |
| 863 | { |
| 864 | .name = "audio_master_clkout", |
| 865 | .start = 146, |
| 866 | .end = 146, |
| 867 | .flags = IORESOURCE_IO, |
| 868 | }, |
| 869 | { |
| 870 | .name = "audio_base_addr", |
| 871 | .start = 0xa0700000, |
| 872 | .end = 0xa0700000 + 4, |
| 873 | .flags = IORESOURCE_MEM, |
| 874 | }, |
| 875 | |
| 876 | }; |
| 877 | |
| 878 | static unsigned audio_gpio_on[] = { |
| 879 | GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */ |
| 880 | GPIO_CFG(69, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */ |
| 881 | GPIO_CFG(70, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */ |
| 882 | GPIO_CFG(71, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */ |
| 883 | GPIO_CFG(142, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* CC_I2S_CLK */ |
| 884 | GPIO_CFG(143, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* SADC_WSOUT */ |
| 885 | GPIO_CFG(144, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* SADC_DIN */ |
| 886 | GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* SDAC_DOUT */ |
| 887 | GPIO_CFG(146, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MA_CLK_OUT */ |
| 888 | }; |
| 889 | |
| 890 | static void __init audio_gpio_init(void) |
| 891 | { |
| 892 | int pin, rc; |
| 893 | |
| 894 | for (pin = 0; pin < ARRAY_SIZE(audio_gpio_on); pin++) { |
| 895 | rc = gpio_tlmm_config(audio_gpio_on[pin], |
| 896 | GPIO_CFG_ENABLE); |
| 897 | if (rc) { |
| 898 | printk(KERN_ERR |
| 899 | "%s: gpio_tlmm_config(%#x)=%d\n", |
| 900 | __func__, audio_gpio_on[pin], rc); |
| 901 | return; |
| 902 | } |
| 903 | } |
| 904 | } |
| 905 | |
| 906 | static struct platform_device msm_audio_device = { |
| 907 | .name = "msm_audio", |
| 908 | .id = 0, |
| 909 | .num_resources = ARRAY_SIZE(msm_audio_resources), |
| 910 | .resource = msm_audio_resources, |
| 911 | }; |
| 912 | |
| 913 | static struct resource bluesleep_resources[] = { |
| 914 | { |
| 915 | .name = "gpio_host_wake", |
| 916 | .start = 21, |
| 917 | .end = 21, |
| 918 | .flags = IORESOURCE_IO, |
| 919 | }, |
| 920 | { |
| 921 | .name = "gpio_ext_wake", |
| 922 | .start = 19, |
| 923 | .end = 19, |
| 924 | .flags = IORESOURCE_IO, |
| 925 | }, |
| 926 | { |
| 927 | .name = "host_wake", |
| 928 | .start = MSM_GPIO_TO_INT(21), |
| 929 | .end = MSM_GPIO_TO_INT(21), |
| 930 | .flags = IORESOURCE_IRQ, |
| 931 | }, |
| 932 | }; |
| 933 | |
| 934 | static struct platform_device msm_bluesleep_device = { |
| 935 | .name = "bluesleep", |
| 936 | .id = -1, |
| 937 | .num_resources = ARRAY_SIZE(bluesleep_resources), |
| 938 | .resource = bluesleep_resources, |
| 939 | }; |
| 940 | |
| 941 | #ifdef CONFIG_BT |
| 942 | static struct platform_device msm_bt_power_device = { |
| 943 | .name = "bt_power", |
| 944 | }; |
| 945 | |
| 946 | enum { |
| 947 | BT_SYSRST, |
| 948 | BT_WAKE, |
| 949 | BT_HOST_WAKE, |
| 950 | BT_VDD_IO, |
| 951 | BT_RFR, |
| 952 | BT_CTS, |
| 953 | BT_RX, |
| 954 | BT_TX, |
| 955 | BT_VDD_FREG |
| 956 | }; |
| 957 | |
| 958 | static struct msm_gpio bt_config_power_off[] = { |
| 959 | { GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 960 | "BT SYSRST" }, |
| 961 | { GPIO_CFG(19, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 962 | "BT WAKE" }, |
| 963 | { GPIO_CFG(21, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 964 | "HOST WAKE" }, |
| 965 | { GPIO_CFG(22, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 966 | "BT VDD_IO" }, |
| 967 | { GPIO_CFG(43, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 968 | "UART1DM_RFR" }, |
| 969 | { GPIO_CFG(44, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 970 | "UART1DM_CTS" }, |
| 971 | { GPIO_CFG(45, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 972 | "UART1DM_RX" }, |
| 973 | { GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 974 | "UART1DM_TX" } |
| 975 | }; |
| 976 | |
| 977 | static struct msm_gpio bt_config_power_on[] = { |
| 978 | { GPIO_CFG(18, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 979 | "BT SYSRST" }, |
| 980 | { GPIO_CFG(19, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 981 | "BT WAKE" }, |
| 982 | { GPIO_CFG(21, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 983 | "HOST WAKE" }, |
| 984 | { GPIO_CFG(22, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 985 | "BT VDD_IO" }, |
| 986 | { GPIO_CFG(43, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 987 | "UART1DM_RFR" }, |
| 988 | { GPIO_CFG(44, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 989 | "UART1DM_CTS" }, |
| 990 | { GPIO_CFG(45, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 991 | "UART1DM_RX" }, |
| 992 | { GPIO_CFG(46, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 993 | "UART1DM_TX" } |
| 994 | }; |
| 995 | |
| 996 | static struct msm_gpio wlan_config_power_off[] = { |
| 997 | { GPIO_CFG(62, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 998 | "SDC2_CLK" }, |
| 999 | { GPIO_CFG(63, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 1000 | "SDC2_CMD" }, |
| 1001 | { GPIO_CFG(64, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 1002 | "SDC2_D3" }, |
| 1003 | { GPIO_CFG(65, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 1004 | "SDC2_D2" }, |
| 1005 | { GPIO_CFG(66, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 1006 | "SDC2_D1" }, |
| 1007 | { GPIO_CFG(67, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 1008 | "SDC2_D0" }, |
| 1009 | { GPIO_CFG(113, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 1010 | "VDD_WLAN" }, |
| 1011 | { GPIO_CFG(138, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 1012 | "WLAN_PWD" } |
| 1013 | }; |
| 1014 | |
| 1015 | static struct msm_gpio wlan_config_power_on[] = { |
| 1016 | { GPIO_CFG(62, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1017 | "SDC2_CLK" }, |
| 1018 | { GPIO_CFG(63, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1019 | "SDC2_CMD" }, |
| 1020 | { GPIO_CFG(64, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1021 | "SDC2_D3" }, |
| 1022 | { GPIO_CFG(65, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1023 | "SDC2_D2" }, |
| 1024 | { GPIO_CFG(66, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1025 | "SDC2_D1" }, |
| 1026 | { GPIO_CFG(67, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1027 | "SDC2_D0" }, |
| 1028 | { GPIO_CFG(113, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1029 | "VDD_WLAN" }, |
| 1030 | { GPIO_CFG(138, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1031 | "WLAN_PWD" } |
| 1032 | }; |
| 1033 | |
| 1034 | static int bluetooth_power(int on) |
| 1035 | { |
| 1036 | int rc; |
| 1037 | struct vreg *vreg_wlan; |
| 1038 | |
| 1039 | vreg_wlan = vreg_get(NULL, "wlan"); |
| 1040 | |
| 1041 | if (IS_ERR(vreg_wlan)) { |
| 1042 | printk(KERN_ERR "%s: vreg get failed (%ld)\n", |
| 1043 | __func__, PTR_ERR(vreg_wlan)); |
| 1044 | return PTR_ERR(vreg_wlan); |
| 1045 | } |
| 1046 | |
| 1047 | if (on) { |
| 1048 | /* units of mV, steps of 50 mV */ |
| 1049 | rc = vreg_set_level(vreg_wlan, PMIC_VREG_WLAN_LEVEL); |
| 1050 | if (rc) { |
| 1051 | printk(KERN_ERR "%s: vreg wlan set level failed (%d)\n", |
| 1052 | __func__, rc); |
| 1053 | return -EIO; |
| 1054 | } |
| 1055 | rc = vreg_enable(vreg_wlan); |
| 1056 | if (rc) { |
| 1057 | printk(KERN_ERR "%s: vreg wlan enable failed (%d)\n", |
| 1058 | __func__, rc); |
| 1059 | return -EIO; |
| 1060 | } |
| 1061 | |
| 1062 | rc = msm_gpios_enable(bt_config_power_on, |
| 1063 | ARRAY_SIZE(bt_config_power_on)); |
| 1064 | if (rc < 0) { |
| 1065 | printk(KERN_ERR |
| 1066 | "%s: bt power on gpio config failed: %d\n", |
| 1067 | __func__, rc); |
| 1068 | return rc; |
| 1069 | } |
| 1070 | |
| 1071 | if (machine_is_qsd8x50_ffa()) { |
| 1072 | rc = msm_gpios_enable |
| 1073 | (wlan_config_power_on, |
| 1074 | ARRAY_SIZE(wlan_config_power_on)); |
| 1075 | if (rc < 0) { |
| 1076 | printk |
| 1077 | (KERN_ERR |
| 1078 | "%s: wlan power on gpio config failed: %d\n", |
| 1079 | __func__, rc); |
| 1080 | return rc; |
| 1081 | } |
| 1082 | } |
| 1083 | |
| 1084 | gpio_set_value(22, on); /* VDD_IO */ |
| 1085 | gpio_set_value(18, on); /* SYSRST */ |
| 1086 | |
| 1087 | if (machine_is_qsd8x50_ffa()) { |
| 1088 | gpio_set_value(138, 0); /* WLAN: CHIP_PWD */ |
| 1089 | gpio_set_value(113, on); /* WLAN */ |
| 1090 | } |
| 1091 | } else { |
| 1092 | if (machine_is_qsd8x50_ffa()) { |
| 1093 | gpio_set_value(138, on); /* WLAN: CHIP_PWD */ |
| 1094 | gpio_set_value(113, on); /* WLAN */ |
| 1095 | } |
| 1096 | |
| 1097 | gpio_set_value(18, on); /* SYSRST */ |
| 1098 | gpio_set_value(22, on); /* VDD_IO */ |
| 1099 | |
| 1100 | rc = vreg_disable(vreg_wlan); |
| 1101 | if (rc) { |
| 1102 | printk(KERN_ERR "%s: vreg wlan disable failed (%d)\n", |
| 1103 | __func__, rc); |
| 1104 | return -EIO; |
| 1105 | } |
| 1106 | |
| 1107 | rc = msm_gpios_enable(bt_config_power_off, |
| 1108 | ARRAY_SIZE(bt_config_power_off)); |
| 1109 | if (rc < 0) { |
| 1110 | printk(KERN_ERR |
| 1111 | "%s: bt power off gpio config failed: %d\n", |
| 1112 | __func__, rc); |
| 1113 | return rc; |
| 1114 | } |
| 1115 | |
| 1116 | if (machine_is_qsd8x50_ffa()) { |
| 1117 | rc = msm_gpios_enable |
| 1118 | (wlan_config_power_off, |
| 1119 | ARRAY_SIZE(wlan_config_power_off)); |
| 1120 | if (rc < 0) { |
| 1121 | printk |
| 1122 | (KERN_ERR |
| 1123 | "%s: wlan power off gpio config failed: %d\n", |
| 1124 | __func__, rc); |
| 1125 | return rc; |
| 1126 | } |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | printk(KERN_DEBUG "Bluetooth power switch: %d\n", on); |
| 1131 | |
| 1132 | return 0; |
| 1133 | } |
| 1134 | |
| 1135 | static void __init bt_power_init(void) |
| 1136 | { |
| 1137 | struct vreg *vreg_bt; |
| 1138 | int rc; |
| 1139 | |
| 1140 | if (machine_is_qsd8x50_ffa()) { |
| 1141 | gpio_set_value(138, 0); /* WLAN: CHIP_PWD */ |
| 1142 | gpio_set_value(113, 0); /* WLAN */ |
| 1143 | } |
| 1144 | |
| 1145 | gpio_set_value(18, 0); /* SYSRST */ |
| 1146 | gpio_set_value(22, 0); /* VDD_IO */ |
| 1147 | |
| 1148 | /* do not have vreg bt defined, gp6 is the same */ |
| 1149 | /* vreg_get parameter 1 (struct device *) is ignored */ |
| 1150 | vreg_bt = vreg_get(NULL, "gp6"); |
| 1151 | |
| 1152 | if (IS_ERR(vreg_bt)) { |
| 1153 | printk(KERN_ERR "%s: vreg get failed (%ld)\n", |
| 1154 | __func__, PTR_ERR(vreg_bt)); |
| 1155 | goto exit; |
| 1156 | } |
| 1157 | |
| 1158 | /* units of mV, steps of 50 mV */ |
| 1159 | rc = vreg_set_level(vreg_bt, PMIC_VREG_GP6_LEVEL); |
| 1160 | if (rc) { |
| 1161 | printk(KERN_ERR "%s: vreg bt set level failed (%d)\n", |
| 1162 | __func__, rc); |
| 1163 | goto exit; |
| 1164 | } |
| 1165 | rc = vreg_enable(vreg_bt); |
| 1166 | if (rc) { |
| 1167 | printk(KERN_ERR "%s: vreg bt enable failed (%d)\n", |
| 1168 | __func__, rc); |
| 1169 | goto exit; |
| 1170 | } |
| 1171 | |
| 1172 | if (bluetooth_power(0)) |
| 1173 | goto exit; |
| 1174 | |
| 1175 | msm_bt_power_device.dev.platform_data = &bluetooth_power; |
| 1176 | |
| 1177 | printk(KERN_DEBUG "Bluetooth power switch: initialized\n"); |
| 1178 | |
| 1179 | exit: |
| 1180 | return; |
| 1181 | } |
| 1182 | #else |
| 1183 | #define bt_power_init(x) do {} while (0) |
| 1184 | #endif |
| 1185 | |
| 1186 | static struct platform_device msm_device_pmic_leds = { |
| 1187 | .name = "pmic-leds", |
| 1188 | .id = -1, |
| 1189 | }; |
| 1190 | |
| 1191 | /* TSIF begin */ |
| 1192 | #if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) |
| 1193 | |
| 1194 | #define TSIF_A_SYNC GPIO_CFG(106, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA) |
| 1195 | #define TSIF_A_DATA GPIO_CFG(107, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA) |
| 1196 | #define TSIF_A_EN GPIO_CFG(108, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA) |
| 1197 | #define TSIF_A_CLK GPIO_CFG(109, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA) |
| 1198 | |
| 1199 | static const struct msm_gpio tsif_gpios[] = { |
| 1200 | { .gpio_cfg = TSIF_A_CLK, .label = "tsif_clk", }, |
| 1201 | { .gpio_cfg = TSIF_A_EN, .label = "tsif_en", }, |
| 1202 | { .gpio_cfg = TSIF_A_DATA, .label = "tsif_data", }, |
| 1203 | { .gpio_cfg = TSIF_A_SYNC, .label = "tsif_sync", }, |
| 1204 | }; |
| 1205 | |
| 1206 | static struct msm_tsif_platform_data tsif_platform_data = { |
| 1207 | .num_gpios = ARRAY_SIZE(tsif_gpios), |
| 1208 | .gpios = tsif_gpios, |
Matt Wagantall | 640e5fd | 2011-08-17 16:08:53 -0700 | [diff] [blame] | 1209 | .tsif_clk = "core_clk", |
| 1210 | .tsif_ref_clk = "ref_clk", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1211 | }; |
| 1212 | |
| 1213 | #endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */ |
| 1214 | /* TSIF end */ |
| 1215 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1216 | static void touchpad_gpio_release(void) |
| 1217 | { |
| 1218 | gpio_free(TOUCHPAD_IRQ); |
| 1219 | gpio_free(TOUCHPAD_SUSPEND); |
| 1220 | } |
| 1221 | |
| 1222 | static int touchpad_gpio_setup(void) |
| 1223 | { |
| 1224 | int rc; |
| 1225 | int suspend_pin = TOUCHPAD_SUSPEND; |
| 1226 | int irq_pin = TOUCHPAD_IRQ; |
| 1227 | unsigned suspend_cfg = |
| 1228 | GPIO_CFG(suspend_pin, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA); |
| 1229 | unsigned irq_cfg = |
| 1230 | GPIO_CFG(irq_pin, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA); |
| 1231 | |
| 1232 | rc = gpio_request(irq_pin, "msm_touchpad_irq"); |
| 1233 | if (rc) { |
| 1234 | pr_err("gpio_request failed on pin %d (rc=%d)\n", |
| 1235 | irq_pin, rc); |
| 1236 | goto err_gpioconfig; |
| 1237 | } |
| 1238 | rc = gpio_request(suspend_pin, "msm_touchpad_suspend"); |
| 1239 | if (rc) { |
| 1240 | pr_err("gpio_request failed on pin %d (rc=%d)\n", |
| 1241 | suspend_pin, rc); |
| 1242 | goto err_gpioconfig; |
| 1243 | } |
| 1244 | rc = gpio_tlmm_config(suspend_cfg, GPIO_CFG_ENABLE); |
| 1245 | if (rc) { |
| 1246 | pr_err("gpio_tlmm_config failed on pin %d (rc=%d)\n", |
| 1247 | suspend_pin, rc); |
| 1248 | goto err_gpioconfig; |
| 1249 | } |
| 1250 | rc = gpio_tlmm_config(irq_cfg, GPIO_CFG_ENABLE); |
| 1251 | if (rc) { |
| 1252 | pr_err("gpio_tlmm_config failed on pin %d (rc=%d)\n", |
| 1253 | irq_pin, rc); |
| 1254 | goto err_gpioconfig; |
| 1255 | } |
| 1256 | return rc; |
| 1257 | |
| 1258 | err_gpioconfig: |
| 1259 | touchpad_gpio_release(); |
| 1260 | return rc; |
| 1261 | } |
| 1262 | |
| 1263 | static struct msm_touchpad_platform_data msm_touchpad_data = { |
| 1264 | .gpioirq = TOUCHPAD_IRQ, |
| 1265 | .gpiosuspend = TOUCHPAD_SUSPEND, |
| 1266 | .gpio_setup = touchpad_gpio_setup, |
| 1267 | .gpio_shutdown = touchpad_gpio_release |
| 1268 | }; |
| 1269 | |
| 1270 | #define KBD_RST 35 |
| 1271 | #define KBD_IRQ 36 |
| 1272 | |
| 1273 | static void kbd_gpio_release(void) |
| 1274 | { |
| 1275 | gpio_free(KBD_IRQ); |
| 1276 | gpio_free(KBD_RST); |
| 1277 | } |
| 1278 | |
| 1279 | static int kbd_gpio_setup(void) |
| 1280 | { |
| 1281 | int rc; |
| 1282 | int respin = KBD_RST; |
| 1283 | int irqpin = KBD_IRQ; |
| 1284 | unsigned rescfg = |
| 1285 | GPIO_CFG(respin, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA); |
| 1286 | unsigned irqcfg = |
| 1287 | GPIO_CFG(irqpin, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA); |
| 1288 | |
| 1289 | rc = gpio_request(irqpin, "gpio_keybd_irq"); |
| 1290 | if (rc) { |
| 1291 | pr_err("gpio_request failed on pin %d (rc=%d)\n", |
| 1292 | irqpin, rc); |
| 1293 | goto err_gpioconfig; |
| 1294 | } |
| 1295 | rc = gpio_request(respin, "gpio_keybd_reset"); |
| 1296 | if (rc) { |
| 1297 | pr_err("gpio_request failed on pin %d (rc=%d)\n", |
| 1298 | respin, rc); |
| 1299 | goto err_gpioconfig; |
| 1300 | } |
| 1301 | rc = gpio_tlmm_config(rescfg, GPIO_CFG_ENABLE); |
| 1302 | if (rc) { |
| 1303 | pr_err("gpio_tlmm_config failed on pin %d (rc=%d)\n", |
| 1304 | respin, rc); |
| 1305 | goto err_gpioconfig; |
| 1306 | } |
| 1307 | rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE); |
| 1308 | if (rc) { |
| 1309 | pr_err("gpio_tlmm_config failed on pin %d (rc=%d)\n", |
| 1310 | irqpin, rc); |
| 1311 | goto err_gpioconfig; |
| 1312 | } |
| 1313 | return rc; |
| 1314 | |
| 1315 | err_gpioconfig: |
| 1316 | kbd_gpio_release(); |
| 1317 | return rc; |
| 1318 | } |
| 1319 | |
| 1320 | /* use gpio output pin to toggle keyboard external reset pin */ |
| 1321 | static void kbd_hwreset(int kbd_mclrpin) |
| 1322 | { |
| 1323 | gpio_direction_output(kbd_mclrpin, 0); |
| 1324 | gpio_direction_output(kbd_mclrpin, 1); |
| 1325 | } |
| 1326 | |
| 1327 | static struct msm_i2ckbd_platform_data msm_kybd_data = { |
| 1328 | .hwrepeat = 0, |
| 1329 | .scanset1 = 1, |
| 1330 | .gpioreset = KBD_RST, |
| 1331 | .gpioirq = KBD_IRQ, |
| 1332 | .gpio_setup = kbd_gpio_setup, |
| 1333 | .gpio_shutdown = kbd_gpio_release, |
| 1334 | .hw_reset = kbd_hwreset, |
| 1335 | }; |
| 1336 | |
| 1337 | static struct i2c_board_info msm_i2c_board_info[] __initdata = { |
| 1338 | { |
| 1339 | I2C_BOARD_INFO("glidesensor", 0x2A), |
| 1340 | .irq = MSM_GPIO_TO_INT(TOUCHPAD_IRQ), |
| 1341 | .platform_data = &msm_touchpad_data |
| 1342 | }, |
| 1343 | { |
| 1344 | I2C_BOARD_INFO("msm-i2ckbd", 0x3A), |
| 1345 | .type = "msm-i2ckbd", |
| 1346 | .irq = MSM_GPIO_TO_INT(KBD_IRQ), |
| 1347 | .platform_data = &msm_kybd_data |
| 1348 | }, |
| 1349 | #ifdef CONFIG_MT9D112 |
| 1350 | { |
| 1351 | I2C_BOARD_INFO("mt9d112", 0x78 >> 1), |
| 1352 | }, |
| 1353 | #endif |
| 1354 | #ifdef CONFIG_S5K3E2FX |
| 1355 | { |
| 1356 | I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1), |
| 1357 | }, |
| 1358 | #endif |
| 1359 | #ifdef CONFIG_MT9P012 |
| 1360 | { |
| 1361 | I2C_BOARD_INFO("mt9p012", 0x6C >> 1), |
| 1362 | }, |
| 1363 | #endif |
| 1364 | #ifdef CONFIG_MT9P012_KM |
| 1365 | { |
| 1366 | I2C_BOARD_INFO("mt9p012_km", 0x6C >> 2), |
| 1367 | }, |
| 1368 | #endif |
| 1369 | #if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013) |
| 1370 | { |
| 1371 | I2C_BOARD_INFO("mt9t013", 0x6C), |
| 1372 | }, |
| 1373 | #endif |
| 1374 | { |
| 1375 | I2C_BOARD_INFO("tps65023", 0x48), |
| 1376 | }, |
| 1377 | }; |
| 1378 | |
| 1379 | #ifdef CONFIG_MSM_CAMERA |
| 1380 | static uint32_t camera_off_gpio_table[] = { |
| 1381 | /* parallel CAMERA interfaces */ |
| 1382 | GPIO_CFG(0, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT0 */ |
| 1383 | GPIO_CFG(1, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT1 */ |
| 1384 | GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */ |
| 1385 | GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */ |
| 1386 | GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */ |
| 1387 | GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */ |
| 1388 | GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */ |
| 1389 | GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */ |
| 1390 | GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */ |
| 1391 | GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */ |
| 1392 | GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */ |
| 1393 | GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */ |
| 1394 | GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */ |
| 1395 | GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */ |
| 1396 | GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */ |
| 1397 | GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */ |
| 1398 | }; |
| 1399 | |
| 1400 | static uint32_t camera_on_gpio_table[] = { |
| 1401 | /* parallel CAMERA interfaces */ |
| 1402 | GPIO_CFG(0, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT0 */ |
| 1403 | GPIO_CFG(1, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT1 */ |
| 1404 | GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */ |
| 1405 | GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */ |
| 1406 | GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */ |
| 1407 | GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */ |
| 1408 | GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */ |
| 1409 | GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */ |
| 1410 | GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */ |
| 1411 | GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */ |
| 1412 | GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */ |
| 1413 | GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */ |
| 1414 | GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */ |
| 1415 | GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */ |
| 1416 | GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */ |
| 1417 | GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), /* MCLK */ |
| 1418 | }; |
| 1419 | |
| 1420 | static uint32_t camera_on_gpio_ffa_table[] = { |
| 1421 | /* parallel CAMERA interfaces */ |
| 1422 | GPIO_CFG(95, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA), /* I2C_SCL */ |
| 1423 | GPIO_CFG(96, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA), /* I2C_SDA */ |
| 1424 | /* FFA front Sensor Reset */ |
| 1425 | GPIO_CFG(137, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA), |
| 1426 | }; |
| 1427 | |
| 1428 | static uint32_t camera_off_gpio_ffa_table[] = { |
| 1429 | /* FFA front Sensor Reset */ |
| 1430 | GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA), |
| 1431 | }; |
| 1432 | |
| 1433 | static void config_gpio_table(uint32_t *table, int len) |
| 1434 | { |
| 1435 | int n, rc; |
| 1436 | for (n = 0; n < len; n++) { |
| 1437 | rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE); |
| 1438 | if (rc) { |
| 1439 | printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n", |
| 1440 | __func__, table[n], rc); |
| 1441 | break; |
| 1442 | } |
| 1443 | } |
| 1444 | } |
| 1445 | |
| 1446 | static struct vreg *vreg_gp2; |
| 1447 | static struct vreg *vreg_gp3; |
| 1448 | |
| 1449 | static void msm_camera_vreg_config(int vreg_en) |
| 1450 | { |
| 1451 | int rc; |
| 1452 | |
| 1453 | if (vreg_gp2 == NULL) { |
| 1454 | vreg_gp2 = vreg_get(NULL, "gp2"); |
| 1455 | if (IS_ERR(vreg_gp2)) { |
| 1456 | printk(KERN_ERR "%s: vreg_get(%s) failed (%ld)\n", |
| 1457 | __func__, "gp2", PTR_ERR(vreg_gp2)); |
| 1458 | return; |
| 1459 | } |
| 1460 | |
| 1461 | rc = vreg_set_level(vreg_gp2, 1800); |
| 1462 | if (rc) { |
| 1463 | printk(KERN_ERR "%s: GP2 set_level failed (%d)\n", |
| 1464 | __func__, rc); |
| 1465 | } |
| 1466 | } |
| 1467 | |
| 1468 | if (vreg_gp3 == NULL) { |
| 1469 | vreg_gp3 = vreg_get(NULL, "gp3"); |
| 1470 | if (IS_ERR(vreg_gp3)) { |
| 1471 | printk(KERN_ERR "%s: vreg_get(%s) failed (%ld)\n", |
| 1472 | __func__, "gp3", PTR_ERR(vreg_gp3)); |
| 1473 | return; |
| 1474 | } |
| 1475 | |
| 1476 | rc = vreg_set_level(vreg_gp3, 2800); |
| 1477 | if (rc) { |
| 1478 | printk(KERN_ERR "%s: GP3 set level failed (%d)\n", |
| 1479 | __func__, rc); |
| 1480 | } |
| 1481 | } |
| 1482 | |
| 1483 | if (vreg_en) { |
| 1484 | rc = vreg_enable(vreg_gp2); |
| 1485 | if (rc) { |
| 1486 | printk(KERN_ERR "%s: GP2 enable failed (%d)\n", |
| 1487 | __func__, rc); |
| 1488 | } |
| 1489 | |
| 1490 | rc = vreg_enable(vreg_gp3); |
| 1491 | if (rc) { |
| 1492 | printk(KERN_ERR "%s: GP3 enable failed (%d)\n", |
| 1493 | __func__, rc); |
| 1494 | } |
| 1495 | } else { |
| 1496 | rc = vreg_disable(vreg_gp2); |
| 1497 | if (rc) { |
| 1498 | printk(KERN_ERR "%s: GP2 disable failed (%d)\n", |
| 1499 | __func__, rc); |
| 1500 | } |
| 1501 | |
| 1502 | rc = vreg_disable(vreg_gp3); |
| 1503 | if (rc) { |
| 1504 | printk(KERN_ERR "%s: GP3 disable failed (%d)\n", |
| 1505 | __func__, rc); |
| 1506 | } |
| 1507 | } |
| 1508 | } |
| 1509 | |
| 1510 | static int config_camera_on_gpios(void) |
| 1511 | { |
| 1512 | int vreg_en = 1; |
| 1513 | |
| 1514 | if (machine_is_qsd8x50_ffa()) { |
| 1515 | config_gpio_table(camera_on_gpio_ffa_table, |
| 1516 | ARRAY_SIZE(camera_on_gpio_ffa_table)); |
| 1517 | |
| 1518 | msm_camera_vreg_config(vreg_en); |
| 1519 | gpio_set_value(137, 0); |
| 1520 | } |
| 1521 | config_gpio_table(camera_on_gpio_table, |
| 1522 | ARRAY_SIZE(camera_on_gpio_table)); |
| 1523 | return 0; |
| 1524 | } |
| 1525 | |
| 1526 | static void config_camera_off_gpios(void) |
| 1527 | { |
| 1528 | int vreg_en = 0; |
| 1529 | |
| 1530 | if (machine_is_qsd8x50_ffa()) { |
| 1531 | config_gpio_table(camera_off_gpio_ffa_table, |
| 1532 | ARRAY_SIZE(camera_off_gpio_ffa_table)); |
| 1533 | |
| 1534 | msm_camera_vreg_config(vreg_en); |
| 1535 | } |
| 1536 | config_gpio_table(camera_off_gpio_table, |
| 1537 | ARRAY_SIZE(camera_off_gpio_table)); |
| 1538 | } |
| 1539 | |
| 1540 | static struct resource msm_camera_resources[] = { |
| 1541 | { |
| 1542 | .start = 0xA0F00000, |
| 1543 | .end = 0xA0F00000 + SZ_1M - 1, |
| 1544 | .flags = IORESOURCE_MEM, |
| 1545 | }, |
| 1546 | { |
| 1547 | .start = INT_VFE, |
| 1548 | .end = INT_VFE, |
| 1549 | .flags = IORESOURCE_IRQ, |
| 1550 | }, |
| 1551 | }; |
| 1552 | |
| 1553 | static struct msm_camera_device_platform_data msm_camera_device_data = { |
| 1554 | .camera_gpio_on = config_camera_on_gpios, |
| 1555 | .camera_gpio_off = config_camera_off_gpios, |
| 1556 | .ioext.mdcphy = MSM_MDC_PHYS, |
| 1557 | .ioext.mdcsz = MSM_MDC_SIZE, |
| 1558 | .ioext.appphy = MSM_CLK_CTL_PHYS, |
| 1559 | .ioext.appsz = MSM_CLK_CTL_SIZE, |
| 1560 | }; |
| 1561 | |
| 1562 | int pmic_set_flash_led_current(enum pmic8058_leds id, unsigned mA) |
| 1563 | { |
| 1564 | int rc; |
| 1565 | rc = pmic_flash_led_set_current(mA); |
| 1566 | return rc; |
| 1567 | } |
| 1568 | static struct msm_camera_sensor_flash_src msm_flash_src = { |
| 1569 | .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC, |
| 1570 | ._fsrc.pmic_src.num_of_src = 1, |
| 1571 | ._fsrc.pmic_src.low_current = 30, |
| 1572 | ._fsrc.pmic_src.high_current = 100, |
| 1573 | ._fsrc.pmic_src.led_src_1 = 0, |
| 1574 | ._fsrc.pmic_src.led_src_2 = 0, |
| 1575 | ._fsrc.pmic_src.pmic_set_current = pmic_set_flash_led_current, |
| 1576 | }; |
| 1577 | |
| 1578 | #ifdef CONFIG_MT9D112 |
| 1579 | static struct msm_camera_sensor_flash_data flash_mt9d112 = { |
| 1580 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 1581 | .flash_src = &msm_flash_src |
| 1582 | }; |
| 1583 | |
| 1584 | static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = { |
| 1585 | .sensor_name = "mt9d112", |
| 1586 | .sensor_reset = 17, |
| 1587 | .sensor_pwd = 85, |
| 1588 | .vcm_pwd = 0, |
| 1589 | .vcm_enable = 0, |
| 1590 | .pdata = &msm_camera_device_data, |
| 1591 | .resource = msm_camera_resources, |
| 1592 | .num_resources = ARRAY_SIZE(msm_camera_resources), |
| 1593 | .flash_data = &flash_mt9d112 |
| 1594 | }; |
| 1595 | |
| 1596 | static struct platform_device msm_camera_sensor_mt9d112 = { |
| 1597 | .name = "msm_camera_mt9d112", |
| 1598 | .dev = { |
| 1599 | .platform_data = &msm_camera_sensor_mt9d112_data, |
| 1600 | }, |
| 1601 | }; |
| 1602 | #endif |
| 1603 | |
| 1604 | #ifdef CONFIG_S5K3E2FX |
| 1605 | static struct msm_camera_sensor_flash_data flash_s5k3e2fx = { |
| 1606 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 1607 | .flash_src = &msm_flash_src |
| 1608 | }; |
| 1609 | |
| 1610 | static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = { |
| 1611 | .sensor_name = "s5k3e2fx", |
| 1612 | .sensor_reset = 17, |
| 1613 | .sensor_pwd = 85, |
| 1614 | /*.vcm_pwd = 31, */ /* CAM1_VCM_EN, enabled in a9 */ |
| 1615 | .vcm_enable = 0, |
| 1616 | .pdata = &msm_camera_device_data, |
| 1617 | .resource = msm_camera_resources, |
| 1618 | .num_resources = ARRAY_SIZE(msm_camera_resources), |
| 1619 | .flash_data = &flash_s5k3e2fx |
| 1620 | }; |
| 1621 | |
| 1622 | static struct platform_device msm_camera_sensor_s5k3e2fx = { |
| 1623 | .name = "msm_camera_s5k3e2fx", |
| 1624 | .dev = { |
| 1625 | .platform_data = &msm_camera_sensor_s5k3e2fx_data, |
| 1626 | }, |
| 1627 | }; |
| 1628 | #endif |
| 1629 | |
| 1630 | #ifdef CONFIG_MT9P012 |
| 1631 | static struct msm_camera_sensor_flash_data flash_mt9p012 = { |
| 1632 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 1633 | .flash_src = &msm_flash_src |
| 1634 | }; |
| 1635 | |
| 1636 | static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = { |
| 1637 | .sensor_name = "mt9p012", |
| 1638 | .sensor_reset = 17, |
| 1639 | .sensor_pwd = 85, |
| 1640 | .vcm_pwd = 88, |
| 1641 | .vcm_enable = 0, |
| 1642 | .pdata = &msm_camera_device_data, |
| 1643 | .resource = msm_camera_resources, |
| 1644 | .num_resources = ARRAY_SIZE(msm_camera_resources), |
| 1645 | .flash_data = &flash_mt9p012 |
| 1646 | }; |
| 1647 | |
| 1648 | static struct platform_device msm_camera_sensor_mt9p012 = { |
| 1649 | .name = "msm_camera_mt9p012", |
| 1650 | .dev = { |
| 1651 | .platform_data = &msm_camera_sensor_mt9p012_data, |
| 1652 | }, |
| 1653 | }; |
| 1654 | #endif |
| 1655 | |
| 1656 | #ifdef CONFIG_MT9P012_KM |
| 1657 | static struct msm_camera_sensor_flash_data flash_mt9p012_km = { |
| 1658 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 1659 | .flash_src = &msm_flash_src |
| 1660 | }; |
| 1661 | |
| 1662 | static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_km_data = { |
| 1663 | .sensor_name = "mt9p012_km", |
| 1664 | .sensor_reset = 17, |
| 1665 | .sensor_pwd = 85, |
| 1666 | .vcm_pwd = 88, |
| 1667 | .vcm_enable = 0, |
| 1668 | .pdata = &msm_camera_device_data, |
| 1669 | .resource = msm_camera_resources, |
| 1670 | .num_resources = ARRAY_SIZE(msm_camera_resources), |
| 1671 | .flash_data = &flash_mt9p012_km |
| 1672 | }; |
| 1673 | |
| 1674 | static struct platform_device msm_camera_sensor_mt9p012_km = { |
| 1675 | .name = "msm_camera_mt9p012_km", |
| 1676 | .dev = { |
| 1677 | .platform_data = &msm_camera_sensor_mt9p012_km_data, |
| 1678 | }, |
| 1679 | }; |
| 1680 | #endif |
| 1681 | |
| 1682 | #ifdef CONFIG_MT9T013 |
| 1683 | static struct msm_camera_sensor_flash_data flash_mt9t013 = { |
| 1684 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 1685 | .flash_src = &msm_flash_src |
| 1686 | }; |
| 1687 | |
| 1688 | static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = { |
| 1689 | .sensor_name = "mt9t013", |
| 1690 | .sensor_reset = 17, |
| 1691 | .sensor_pwd = 85, |
| 1692 | .vcm_pwd = 0, |
| 1693 | .vcm_enable = 0, |
| 1694 | .pdata = &msm_camera_device_data, |
| 1695 | .resource = msm_camera_resources, |
| 1696 | .num_resources = ARRAY_SIZE(msm_camera_resources), |
| 1697 | .flash_data = &flash_mt9t013 |
| 1698 | }; |
| 1699 | |
| 1700 | static struct platform_device msm_camera_sensor_mt9t013 = { |
| 1701 | .name = "msm_camera_mt9t013", |
| 1702 | .dev = { |
| 1703 | .platform_data = &msm_camera_sensor_mt9t013_data, |
| 1704 | }, |
| 1705 | }; |
| 1706 | #endif |
| 1707 | #endif /*CONFIG_MSM_CAMERA*/ |
| 1708 | |
| 1709 | static u32 msm_calculate_batt_capacity(u32 current_voltage); |
| 1710 | |
| 1711 | static struct msm_psy_batt_pdata msm_psy_batt_data = { |
| 1712 | .voltage_min_design = 3200, |
| 1713 | .voltage_max_design = 4200, |
| 1714 | .avail_chg_sources = AC_CHG | USB_CHG , |
| 1715 | .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION, |
| 1716 | .calculate_capacity = &msm_calculate_batt_capacity, |
| 1717 | }; |
| 1718 | |
| 1719 | static u32 msm_calculate_batt_capacity(u32 current_voltage) |
| 1720 | { |
| 1721 | u32 low_voltage = msm_psy_batt_data.voltage_min_design; |
| 1722 | u32 high_voltage = msm_psy_batt_data.voltage_max_design; |
| 1723 | |
| 1724 | return (current_voltage - low_voltage) * 100 |
| 1725 | / (high_voltage - low_voltage); |
| 1726 | } |
| 1727 | |
| 1728 | static struct platform_device msm_batt_device = { |
| 1729 | .name = "msm-battery", |
| 1730 | .id = -1, |
| 1731 | .dev.platform_data = &msm_psy_batt_data, |
| 1732 | }; |
| 1733 | |
| 1734 | static int hsusb_rpc_connect(int connect) |
| 1735 | { |
| 1736 | if (connect) |
| 1737 | return msm_hsusb_rpc_connect(); |
| 1738 | else |
| 1739 | return msm_hsusb_rpc_close(); |
| 1740 | } |
| 1741 | |
| 1742 | static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init) |
| 1743 | { |
| 1744 | int ret; |
| 1745 | |
| 1746 | if (init) { |
| 1747 | ret = msm_pm_app_rpc_init(callback); |
| 1748 | } else { |
| 1749 | msm_pm_app_rpc_deinit(callback); |
| 1750 | ret = 0; |
| 1751 | } |
| 1752 | return ret; |
| 1753 | } |
| 1754 | static int msm_hsusb_ldo_init(int init); |
| 1755 | static int msm_hsusb_ldo_enable(int enable); |
| 1756 | |
| 1757 | static struct msm_otg_platform_data msm_otg_pdata = { |
| 1758 | .rpc_connect = hsusb_rpc_connect, |
| 1759 | .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init, |
| 1760 | .pemp_level = PRE_EMPHASIS_WITH_10_PERCENT, |
| 1761 | .cdr_autoreset = CDR_AUTO_RESET_DEFAULT, |
| 1762 | .drv_ampl = HS_DRV_AMPLITUDE_5_PERCENT, |
| 1763 | .vbus_power = msm_hsusb_vbus_power, |
| 1764 | .chg_vbus_draw = hsusb_chg_vbus_draw, |
| 1765 | .chg_connected = hsusb_chg_connected, |
| 1766 | .chg_init = hsusb_chg_init, |
| 1767 | .phy_can_powercollapse = 1, |
| 1768 | .ldo_init = msm_hsusb_ldo_init, |
| 1769 | .ldo_enable = msm_hsusb_ldo_enable, |
| 1770 | .pclk_src_name = "ebi1_usb_clk", |
| 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 | |
| 2300 | static void |
| 2301 | msm_i2c_gpio_config(int iface, int config_type) |
| 2302 | { |
| 2303 | int gpio_scl; |
| 2304 | int gpio_sda; |
| 2305 | if (iface) { |
| 2306 | gpio_scl = 60; |
| 2307 | gpio_sda = 61; |
| 2308 | } else { |
| 2309 | gpio_scl = 95; |
| 2310 | gpio_sda = 96; |
| 2311 | } |
| 2312 | if (config_type) { |
| 2313 | gpio_tlmm_config(GPIO_CFG(gpio_scl, 1, GPIO_CFG_INPUT, |
| 2314 | GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); |
| 2315 | gpio_tlmm_config(GPIO_CFG(gpio_sda, 1, GPIO_CFG_INPUT, |
| 2316 | GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); |
| 2317 | } else { |
| 2318 | gpio_tlmm_config(GPIO_CFG(gpio_scl, 0, GPIO_CFG_OUTPUT, |
| 2319 | GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); |
| 2320 | gpio_tlmm_config(GPIO_CFG(gpio_sda, 0, GPIO_CFG_OUTPUT, |
| 2321 | GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); |
| 2322 | } |
| 2323 | } |
| 2324 | |
| 2325 | static struct msm_i2c_platform_data msm_i2c_pdata = { |
| 2326 | .clk_freq = 100000, |
| 2327 | .rsl_id = SMEM_SPINLOCK_I2C, |
| 2328 | .pri_clk = 95, |
| 2329 | .pri_dat = 96, |
| 2330 | .aux_clk = 60, |
| 2331 | .aux_dat = 61, |
| 2332 | .msm_i2c_config_gpio = msm_i2c_gpio_config, |
| 2333 | }; |
| 2334 | |
| 2335 | static void __init msm_device_i2c_init(void) |
| 2336 | { |
| 2337 | if (gpio_request(95, "i2c_pri_clk")) |
| 2338 | pr_err("failed to request gpio i2c_pri_clk\n"); |
| 2339 | if (gpio_request(96, "i2c_pri_dat")) |
| 2340 | pr_err("failed to request gpio i2c_pri_dat\n"); |
| 2341 | if (gpio_request(60, "i2c_sec_clk")) |
| 2342 | pr_err("failed to request gpio i2c_sec_clk\n"); |
| 2343 | if (gpio_request(61, "i2c_sec_dat")) |
| 2344 | pr_err("failed to request gpio i2c_sec_dat\n"); |
| 2345 | |
| 2346 | msm_i2c_pdata.rmutex = 1; |
| 2347 | msm_i2c_pdata.pm_lat = |
| 2348 | msm_pm_data[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] |
| 2349 | .latency; |
| 2350 | msm_device_i2c.dev.platform_data = &msm_i2c_pdata; |
| 2351 | } |
| 2352 | |
| 2353 | static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE; |
| 2354 | static int __init pmem_kernel_ebi1_size_setup(char *p) |
| 2355 | { |
| 2356 | pmem_kernel_ebi1_size = memparse(p, NULL); |
| 2357 | return 0; |
| 2358 | } |
| 2359 | early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup); |
| 2360 | |
| 2361 | #ifdef CONFIG_KERNEL_PMEM_SMI_REGION |
| 2362 | static unsigned pmem_kernel_smi_size = MSM_PMEM_SMIPOOL_SIZE; |
| 2363 | static int __init pmem_kernel_smi_size_setup(char *p) |
| 2364 | { |
| 2365 | pmem_kernel_smi_size = memparse(p, NULL); |
| 2366 | |
| 2367 | /* Make sure that we don't allow more SMI memory then is |
| 2368 | available - the kernel mapping code has no way of knowing |
| 2369 | if it has gone over the edge */ |
| 2370 | |
| 2371 | if (pmem_kernel_smi_size > MSM_PMEM_SMIPOOL_SIZE) |
| 2372 | pmem_kernel_smi_size = MSM_PMEM_SMIPOOL_SIZE; |
| 2373 | return 0; |
| 2374 | } |
| 2375 | early_param("pmem_kernel_smi_size", pmem_kernel_smi_size_setup); |
| 2376 | #endif |
| 2377 | |
| 2378 | static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE; |
| 2379 | static int __init pmem_sf_size_setup(char *p) |
| 2380 | { |
| 2381 | pmem_sf_size = memparse(p, NULL); |
| 2382 | return 0; |
| 2383 | } |
| 2384 | early_param("pmem_sf_size", pmem_sf_size_setup); |
| 2385 | |
| 2386 | static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE; |
| 2387 | static int __init pmem_adsp_size_setup(char *p) |
| 2388 | { |
| 2389 | pmem_adsp_size = memparse(p, NULL); |
| 2390 | return 0; |
| 2391 | } |
| 2392 | early_param("pmem_adsp_size", pmem_adsp_size_setup); |
| 2393 | |
| 2394 | |
| 2395 | static unsigned audio_size = MSM_AUDIO_SIZE; |
| 2396 | static int __init audio_size_setup(char *p) |
| 2397 | { |
| 2398 | audio_size = memparse(p, NULL); |
| 2399 | return 0; |
| 2400 | } |
| 2401 | early_param("audio_size", audio_size_setup); |
| 2402 | |
| 2403 | static void __init qsd8x50_init(void) |
| 2404 | { |
Stephen Boyd | bb600ae | 2011-08-02 20:11:40 -0700 | [diff] [blame] | 2405 | msm_clock_init(&qds8x50_clock_init_data); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2406 | qsd8x50_cfg_smc91x(); |
Matt Wagantall | ec57f06 | 2011-08-16 23:54:46 -0700 | [diff] [blame] | 2407 | acpuclk_init(&acpuclk_8x50_soc_data); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2408 | |
| 2409 | msm_hsusb_pdata.swfi_latency = |
| 2410 | msm_pm_data |
| 2411 | [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency; |
| 2412 | msm_device_hsusb_peripheral.dev.platform_data = &msm_hsusb_pdata; |
| 2413 | |
| 2414 | msm_otg_pdata.swfi_latency = |
| 2415 | msm_pm_data |
| 2416 | [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency; |
| 2417 | msm_device_otg.dev.platform_data = &msm_otg_pdata; |
| 2418 | msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata; |
| 2419 | msm_gadget_pdata.is_phy_status_timer_on = 1; |
| 2420 | |
| 2421 | #if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) |
| 2422 | msm_device_tsif.dev.platform_data = &tsif_platform_data; |
| 2423 | #endif |
| 2424 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 2425 | msm_fb_add_devices(); |
| 2426 | #ifdef CONFIG_MSM_CAMERA |
| 2427 | config_camera_off_gpios(); /* might not be necessary */ |
| 2428 | #endif |
| 2429 | qsd8x50_init_usb(); |
| 2430 | qsd8x50_init_mmc(); |
| 2431 | bt_power_init(); |
| 2432 | audio_gpio_init(); |
| 2433 | msm_device_i2c_init(); |
| 2434 | msm_qsd_spi_init(); |
| 2435 | i2c_register_board_info(0, msm_i2c_board_info, |
| 2436 | ARRAY_SIZE(msm_i2c_board_info)); |
| 2437 | spi_register_board_info(msm_spi_board_info, |
| 2438 | ARRAY_SIZE(msm_spi_board_info)); |
| 2439 | msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data)); |
Maheshkumar Sivasubramanian | 8ccc16e | 2011-10-25 15:59:57 -0600 | [diff] [blame] | 2440 | BUG_ON(msm_pm_boot_init(MSM_PM_BOOT_CONFIG_RESET_VECTOR, |
| 2441 | (uint32_t *)PAGE_OFFSET)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2442 | |
| 2443 | #ifdef CONFIG_SURF_FFA_GPIO_KEYPAD |
| 2444 | if (machine_is_qsd8x50_ffa()) |
| 2445 | platform_device_register(&keypad_device_8k_ffa); |
| 2446 | else |
| 2447 | platform_device_register(&keypad_device_surf); |
| 2448 | #endif |
| 2449 | } |
| 2450 | |
| 2451 | static void __init qsd8x50_allocate_memory_regions(void) |
| 2452 | { |
| 2453 | void *addr; |
| 2454 | unsigned long size; |
| 2455 | |
| 2456 | size = pmem_kernel_ebi1_size; |
| 2457 | if (size) { |
| 2458 | addr = alloc_bootmem_align(size, 0x100000); |
| 2459 | android_pmem_kernel_ebi1_pdata.size = size; |
| 2460 | pr_info("allocating %lu bytes at %p (%lx physical) for kernel" |
| 2461 | " ebi1 pmem arena\n", size, addr, __pa(addr)); |
| 2462 | } |
| 2463 | |
| 2464 | #ifdef CONFIG_KERNEL_PMEM_SMI_REGION |
| 2465 | size = pmem_kernel_smi_size; |
| 2466 | if (size > MSM_PMEM_SMIPOOL_SIZE) { |
| 2467 | printk(KERN_ERR "pmem kernel smi arena size %lu is too big\n", |
| 2468 | size); |
| 2469 | |
| 2470 | size = MSM_PMEM_SMIPOOL_SIZE; |
| 2471 | } |
| 2472 | |
| 2473 | android_pmem_kernel_smi_pdata.size = size; |
| 2474 | |
| 2475 | pr_info("allocating %lu bytes at %lx (%lx physical)" |
| 2476 | "for pmem kernel smi arena\n", size, |
| 2477 | (long unsigned int) MSM_PMEM_SMIPOOL_BASE, |
| 2478 | __pa(MSM_PMEM_SMIPOOL_BASE)); |
| 2479 | #endif |
| 2480 | |
| 2481 | size = pmem_sf_size; |
| 2482 | if (size) { |
| 2483 | addr = alloc_bootmem(size); |
| 2484 | android_pmem_pdata.size = size; |
| 2485 | pr_info("allocating %lu bytes at %p (%lx physical) for sf " |
| 2486 | "pmem arena\n", size, addr, __pa(addr)); |
| 2487 | } |
| 2488 | |
| 2489 | size = pmem_adsp_size; |
| 2490 | if (size) { |
| 2491 | addr = alloc_bootmem(size); |
| 2492 | android_pmem_adsp_pdata.size = size; |
| 2493 | pr_info("allocating %lu bytes at %p (%lx physical) for adsp " |
| 2494 | "pmem arena\n", size, addr, __pa(addr)); |
| 2495 | } |
| 2496 | |
| 2497 | |
| 2498 | size = MSM_FB_SIZE; |
| 2499 | addr = (void *)MSM_FB_BASE; |
| 2500 | msm_fb_resources[0].start = (unsigned long)addr; |
| 2501 | msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1; |
| 2502 | pr_info("using %lu bytes of SMI at %lx physical for fb\n", |
| 2503 | size, (unsigned long)addr); |
| 2504 | |
| 2505 | size = audio_size ? : MSM_AUDIO_SIZE; |
| 2506 | addr = alloc_bootmem(size); |
| 2507 | msm_audio_resources[0].start = __pa(addr); |
| 2508 | msm_audio_resources[0].end = msm_audio_resources[0].start + size - 1; |
| 2509 | pr_info("allocating %lu bytes at %p (%lx physical) for audio\n", |
| 2510 | size, addr, __pa(addr)); |
Sahitya Tummala | 8b4d95f | 2011-01-18 11:22:50 +0530 | [diff] [blame] | 2511 | } |
| 2512 | |
Daniel Walker | a32d2fe | 2010-02-25 11:38:39 -0800 | [diff] [blame] | 2513 | static void __init qsd8x50_map_io(void) |
| 2514 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2515 | msm_shared_ram_phys = MSM_SHARED_RAM_PHYS; |
Daniel Walker | a32d2fe | 2010-02-25 11:38:39 -0800 | [diff] [blame] | 2516 | msm_map_qsd8x50_io(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2517 | qsd8x50_allocate_memory_regions(); |
Jeff Ohlstein | 3a77f9f | 2011-09-06 14:50:20 -0700 | [diff] [blame] | 2518 | if (socinfo_init() < 0) |
| 2519 | printk(KERN_ERR "%s: socinfo_init() failed!\n", |
| 2520 | __func__); |
Daniel Walker | d1c0d43 | 2010-05-05 07:17:31 -0700 | [diff] [blame] | 2521 | } |
| 2522 | |
Daniel Walker | a32d2fe | 2010-02-25 11:38:39 -0800 | [diff] [blame] | 2523 | MACHINE_START(QSD8X50_SURF, "QCT QSD8X50 SURF") |
Russell King | b75c178 | 2011-01-04 19:03:16 +0000 | [diff] [blame] | 2524 | .boot_params = PLAT_PHYS_OFFSET + 0x100, |
Daniel Walker | a32d2fe | 2010-02-25 11:38:39 -0800 | [diff] [blame] | 2525 | .map_io = qsd8x50_map_io, |
| 2526 | .init_irq = qsd8x50_init_irq, |
| 2527 | .init_machine = qsd8x50_init, |
| 2528 | .timer = &msm_timer, |
| 2529 | MACHINE_END |
| 2530 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2531 | MACHINE_START(QSD8X50_FFA, "QCT QSD8X50 FFA") |
Russell King | b75c178 | 2011-01-04 19:03:16 +0000 | [diff] [blame] | 2532 | .boot_params = PLAT_PHYS_OFFSET + 0x100, |
Daniel Walker | a32d2fe | 2010-02-25 11:38:39 -0800 | [diff] [blame] | 2533 | .map_io = qsd8x50_map_io, |
| 2534 | .init_irq = qsd8x50_init_irq, |
| 2535 | .init_machine = qsd8x50_init, |
| 2536 | .timer = &msm_timer, |
| 2537 | MACHINE_END |