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